From b1d3febd7a124af8540501de795f7dbfd6b68e3d Mon Sep 17 00:00:00 2001 From: Joshua Best Date: Tue, 9 Oct 2018 21:24:39 +0200 Subject: [PATCH] Implemented Three.js as Background of Impress.js --- .idea/RootPresentation.iml | 13 + .idea/dictionaries/Joshua.xml | 10 + .idea/inspectionProfiles/Project_Default.xml | 6 + .idea/jsLibraryMappings.xml | 6 + .idea/jsLinters/jscs.xml | 4 + .idea/jsLinters/jshint.xml | 16 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 7 + .idea/workspace.xml | 340 ++ css/impress-demo.css | 12 +- index.html | 584 +-- js/impress.js | 11 +- three/jsutil/AnimationClipCreator.js | 114 + three/jsutil/Car.js | 305 ++ three/jsutil/Cloth.js | 336 ++ three/jsutil/ConvexObjectBreaker.js | 522 +++ three/jsutil/CurveExtras.js | 425 ++ three/jsutil/GPUComputationRenderer.js | 368 ++ three/jsutil/GPUParticleSystem.js | 501 ++ three/jsutil/Gyroscope.js | 65 + three/jsutil/ImprovedNoise.js | 71 + three/jsutil/MD2Character.js | 259 ++ three/jsutil/MD2CharacterComplex.js | 560 +++ three/jsutil/MarchingCubes.js | 1067 +++++ three/jsutil/MorphAnimMesh.js | 69 + three/jsutil/MorphBlendMesh.js | 319 ++ three/jsutil/Ocean.js | 359 ++ three/jsutil/Octree.js | 2138 +++++++++ three/jsutil/PRNG.js | 23 + three/jsutil/ParametricGeometries.js | 263 ++ three/jsutil/QuickHull.js | 1217 +++++ three/jsutil/RollerCoaster.js | 544 +++ three/jsutil/ShaderGodRays.js | 332 ++ three/jsutil/ShaderSkin.js | 698 +++ three/jsutil/ShaderTerrain.js | 324 ++ three/jsutil/ShaderToon.js | 331 ++ three/jsutil/ShaderTranslucent.js | 206 + three/jsutil/SimplexNoise.js | 324 ++ three/jsutil/TimelinerController.js | 280 ++ three/jsutil/TypedArrayUtils.js | 602 +++ three/jsutil/UCSCharacter.js | 141 + three/jsutil/Volume.js | 447 ++ three/jsutil/VolumeSlice.js | 214 + three/jsutil/WebGL.js | 94 + three/jsutil/animation/CCDIKSolver.js | 455 ++ three/jsutil/animation/MMDAnimationHelper.js | 1041 +++++ three/jsutil/animation/MMDPhysics.js | 1406 ++++++ three/jsutil/cameras/CinematicCamera.js | 198 + .../controls/DeviceOrientationControls.js | 111 + three/jsutil/controls/DragControls.js | 282 ++ three/jsutil/controls/EditorControls.js | 314 ++ three/jsutil/controls/FirstPersonControls.js | 300 ++ three/jsutil/controls/FlyControls.js | 283 ++ three/jsutil/controls/MapControls.js | 1155 +++++ three/jsutil/controls/OrbitControls.js | 1051 +++++ .../controls/OrthographicTrackballControls.js | 626 +++ three/jsutil/controls/PointerLockControls.js | 126 + three/jsutil/controls/TrackballControls.js | 619 +++ three/jsutil/controls/TransformControls.js | 1470 ++++++ three/jsutil/crossfade/gui.js | 39 + three/jsutil/crossfade/scenes.js | 111 + three/jsutil/crossfade/transition.js | 166 + three/jsutil/curves/NURBSCurve.js | 69 + three/jsutil/curves/NURBSSurface.js | 53 + three/jsutil/curves/NURBSUtils.js | 469 ++ three/jsutil/effects/AnaglyphEffect.js | 154 + three/jsutil/effects/AsciiEffect.js | 283 ++ three/jsutil/effects/OutlineEffect.js | 517 +++ three/jsutil/effects/ParallaxBarrierEffect.js | 96 + three/jsutil/effects/PeppersGhostEffect.js | 143 + three/jsutil/effects/StereoEffect.js | 50 + three/jsutil/exporters/ColladaExporter.js | 602 +++ three/jsutil/exporters/GLTFExporter.js | 1856 ++++++++ three/jsutil/exporters/MMDExporter.js | 210 + three/jsutil/exporters/OBJExporter.js | 262 ++ three/jsutil/exporters/PLYExporter.js | 549 +++ three/jsutil/exporters/STLExporter.js | 166 + .../jsutil/exporters/TypedGeometryExporter.js | 55 + three/jsutil/geometries/BoxLineGeometry.js | 67 + three/jsutil/geometries/ConvexGeometry.js | 81 + three/jsutil/geometries/DecalGeometry.js | 357 ++ .../jsutil/geometries/TeapotBufferGeometry.js | 718 +++ three/jsutil/geometries/hilbert2D.js | 63 + three/jsutil/geometries/hilbert3D.js | 88 + three/jsutil/libs/ammo.js | 31 + three/jsutil/libs/dat.gui.min.js | 14 + three/jsutil/libs/draco/README.md | 32 + three/jsutil/libs/draco/draco_decoder.js | 31 + three/jsutil/libs/draco/draco_decoder.wasm | Bin 0 -> 330634 bytes three/jsutil/libs/draco/draco_wasm_wrapper.js | 129 + three/jsutil/libs/draco/gltf/draco_decoder.js | 31 + .../jsutil/libs/draco/gltf/draco_decoder.wasm | Bin 0 -> 229813 bytes three/jsutil/libs/draco/gltf/draco_encoder.js | 33 + .../libs/draco/gltf/draco_wasm_wrapper.js | 119 + three/jsutil/libs/gunzip.min.js | 26 + three/jsutil/libs/inflate.min.js | 15 + three/jsutil/libs/jszip.min.js | 14 + three/jsutil/libs/mmdparser.min.js | 6 + three/jsutil/libs/o3dgc.js | 2913 ++++++++++++ three/jsutil/libs/opentype.min.js | 118 + three/jsutil/libs/stats.min.js | 5 + three/jsutil/libs/system.min.js | 4 + three/jsutil/libs/timeliner_gui.min.js | 182 + three/jsutil/libs/tween.min.js | 13 + .../jsutil/lights/RectAreaLightUniformsLib.js | 47 + three/jsutil/lines/Line2.js | 31 + three/jsutil/lines/LineGeometry.js | 98 + three/jsutil/lines/LineMaterial.js | 391 ++ three/jsutil/lines/LineSegments2.js | 65 + three/jsutil/lines/LineSegmentsGeometry.js | 260 ++ three/jsutil/lines/Wireframe.js | 65 + three/jsutil/lines/WireframeGeometry2.js | 32 + three/jsutil/loaders/3MFLoader.js | 614 +++ three/jsutil/loaders/AMFLoader.js | 495 ++ three/jsutil/loaders/AWDLoader.js | 1239 +++++ three/jsutil/loaders/AssimpJSONLoader.js | 289 ++ three/jsutil/loaders/AssimpLoader.js | 2374 ++++++++++ three/jsutil/loaders/BVHLoader.js | 414 ++ three/jsutil/loaders/BabylonLoader.js | 255 + three/jsutil/loaders/ColladaLoader.js | 3896 ++++++++++++++++ three/jsutil/loaders/DDSLoader.js | 272 ++ three/jsutil/loaders/DRACOLoader.js | 512 ++ three/jsutil/loaders/EXRLoader.js | 1184 +++++ .../loaders/EquirectangularToCubeGenerator.js | 116 + three/jsutil/loaders/FBXLoader.js | 4121 +++++++++++++++++ three/jsutil/loaders/GCodeLoader.js | 225 + three/jsutil/loaders/GLTFLoader.js | 3186 +++++++++++++ three/jsutil/loaders/HDRCubeTextureLoader.js | 194 + three/jsutil/loaders/KMZLoader.js | 112 + three/jsutil/loaders/KTXLoader.js | 174 + three/jsutil/loaders/LoaderSupport.js | 1545 ++++++ three/jsutil/loaders/MD2Loader.js | 387 ++ three/jsutil/loaders/MMDLoader.js | 1899 ++++++++ three/jsutil/loaders/MTLLoader.js | 568 +++ three/jsutil/loaders/NRRDLoader.js | 599 +++ three/jsutil/loaders/NodeMaterialLoader.js | 265 ++ three/jsutil/loaders/OBJLoader.js | 793 ++++ three/jsutil/loaders/OBJLoader2.js | 1456 ++++++ three/jsutil/loaders/PCDLoader.js | 308 ++ three/jsutil/loaders/PDBLoader.js | 217 + three/jsutil/loaders/PLYLoader.js | 505 ++ three/jsutil/loaders/PRWMLoader.js | 299 ++ three/jsutil/loaders/PVRLoader.js | 246 + three/jsutil/loaders/PlayCanvasLoader.js | 203 + three/jsutil/loaders/RGBELoader.js | 346 ++ three/jsutil/loaders/STLLoader.js | 342 ++ three/jsutil/loaders/SVGLoader.js | 1012 ++++ three/jsutil/loaders/TDSLoader.js | 1127 +++++ three/jsutil/loaders/TGALoader.js | 548 +++ three/jsutil/loaders/TTFLoader.js | 200 + three/jsutil/loaders/VRMLLoader.js | 1298 ++++++ three/jsutil/loaders/VRMLoader.js | 87 + three/jsutil/loaders/VTKLoader.js | 1162 +++++ three/jsutil/loaders/XLoader.js | 1605 +++++++ three/jsutil/loaders/ctm/CTMLoader.js | 259 ++ three/jsutil/loaders/ctm/CTMWorker.js | 19 + three/jsutil/loaders/ctm/ctm.js | 658 +++ three/jsutil/loaders/ctm/license/OpenCTM.txt | 20 + three/jsutil/loaders/ctm/license/js-lzma.txt | 19 + .../jsutil/loaders/ctm/license/js-openctm.txt | 19 + three/jsutil/loaders/ctm/lzma.js | 517 +++ .../loaders/deprecated/LegacyGLTFLoader.js | 2238 +++++++++ three/jsutil/loaders/sea3d/SEA3D.js | 3309 +++++++++++++ three/jsutil/loaders/sea3d/SEA3DDeflate.js | 887 ++++ three/jsutil/loaders/sea3d/SEA3DDraco.js | 212 + three/jsutil/loaders/sea3d/SEA3DLZMA.js | 810 ++++ three/jsutil/loaders/sea3d/SEA3DLegacy.js | 774 ++++ three/jsutil/loaders/sea3d/SEA3DLoader.js | 3845 +++++++++++++++ three/jsutil/loaders/sea3d/o3dgc/SEA3DGC.js | 154 + .../jsutil/loaders/sea3d/physics/SEA3DAmmo.js | 409 ++ .../loaders/sea3d/physics/SEA3DAmmoLoader.js | 590 +++ .../loaders/sea3d/physics/SEA3DRigidBody.js | 442 ++ three/jsutil/math/ColorConverter.js | 88 + three/jsutil/math/Lut.js | 496 ++ three/jsutil/modifiers/ExplodeModifier.js | 42 + three/jsutil/modifiers/SimplifyModifier.js | 494 ++ three/jsutil/modifiers/SubdivisionModifier.js | 401 ++ three/jsutil/modifiers/TessellateModifier.js | 236 + three/jsutil/nodes/Nodes.js | 112 + three/jsutil/nodes/THREE.Nodes.js | 223 + three/jsutil/nodes/accessors/CameraNode.js | 236 + three/jsutil/nodes/accessors/ColorsNode.js | 55 + three/jsutil/nodes/accessors/LightNode.js | 61 + three/jsutil/nodes/accessors/NormalNode.js | 114 + three/jsutil/nodes/accessors/PositionNode.js | 136 + three/jsutil/nodes/accessors/ReflectNode.js | 103 + .../jsutil/nodes/accessors/ResolutionNode.js | 59 + three/jsutil/nodes/accessors/ScreenUVNode.js | 65 + three/jsutil/nodes/accessors/UVNode.js | 69 + .../bsdfs/BlinnExponentToRoughnessNode.js | 50 + .../nodes/bsdfs/BlinnShininessExponentNode.js | 31 + .../bsdfs/RoughnessToBlinnExponentNode.js | 92 + three/jsutil/nodes/core/AttributeNode.js | 70 + three/jsutil/nodes/core/ConstNode.js | 125 + three/jsutil/nodes/core/ExpressionNode.js | 17 + three/jsutil/nodes/core/FunctionCallNode.js | 108 + three/jsutil/nodes/core/FunctionNode.js | 266 ++ three/jsutil/nodes/core/InputNode.js | 85 + three/jsutil/nodes/core/Node.js | 180 + three/jsutil/nodes/core/NodeBuilder.js | 958 ++++ three/jsutil/nodes/core/NodeFrame.js | 58 + three/jsutil/nodes/core/NodeLib.js | 68 + three/jsutil/nodes/core/NodeUniform.js | 36 + three/jsutil/nodes/core/NodeUtils.js | 75 + three/jsutil/nodes/core/StructNode.js | 107 + three/jsutil/nodes/core/TempNode.js | 133 + three/jsutil/nodes/core/VarNode.js | 66 + three/jsutil/nodes/effects/BlurNode.js | 168 + .../nodes/effects/ColorAdjustmentNode.js | 136 + three/jsutil/nodes/effects/LuminanceNode.js | 73 + three/jsutil/nodes/inputs/ColorNode.js | 56 + three/jsutil/nodes/inputs/CubeTextureNode.js | 96 + three/jsutil/nodes/inputs/FloatNode.js | 51 + three/jsutil/nodes/inputs/IntNode.js | 51 + three/jsutil/nodes/inputs/Matrix3Node.js | 70 + three/jsutil/nodes/inputs/Matrix4Node.js | 69 + three/jsutil/nodes/inputs/PropertyNode.js | 57 + three/jsutil/nodes/inputs/RTTNode.js | 143 + three/jsutil/nodes/inputs/ReflectorNode.js | 89 + three/jsutil/nodes/inputs/ScreenNode.js | 30 + three/jsutil/nodes/inputs/TextureNode.js | 103 + three/jsutil/nodes/inputs/Vector2Node.js | 55 + three/jsutil/nodes/inputs/Vector3Node.js | 56 + three/jsutil/nodes/inputs/Vector4Node.js | 57 + .../materials/MeshStandardNodeMaterial.js | 34 + three/jsutil/nodes/materials/NodeMaterial.js | 185 + .../nodes/materials/PhongNodeMaterial.js | 38 + .../nodes/materials/SpriteNodeMaterial.js | 29 + .../nodes/materials/StandardNodeMaterial.js | 40 + .../nodes/materials/nodes/MeshStandardNode.js | 113 + .../jsutil/nodes/materials/nodes/PhongNode.js | 393 ++ three/jsutil/nodes/materials/nodes/RawNode.js | 62 + .../nodes/materials/nodes/SpriteNode.js | 213 + .../nodes/materials/nodes/StandardNode.js | 471 ++ three/jsutil/nodes/math/CondNode.js | 107 + three/jsutil/nodes/math/Math1Node.js | 117 + three/jsutil/nodes/math/Math2Node.js | 140 + three/jsutil/nodes/math/Math3Node.js | 120 + three/jsutil/nodes/math/OperatorNode.js | 87 + three/jsutil/nodes/misc/BumpMapNode.js | 166 + three/jsutil/nodes/misc/NormalMapNode.js | 117 + three/jsutil/nodes/misc/TextureCubeNode.js | 64 + three/jsutil/nodes/misc/TextureCubeUVNode.js | 209 + three/jsutil/nodes/postprocessing/NodePass.js | 91 + .../postprocessing/NodePostProcessing.js | 128 + three/jsutil/nodes/procedural/CheckerNode.js | 75 + three/jsutil/nodes/procedural/NoiseNode.js | 69 + three/jsutil/nodes/utils/BypassNode.js | 85 + three/jsutil/nodes/utils/ColorSpaceNode.js | 297 ++ three/jsutil/nodes/utils/JoinNode.js | 114 + three/jsutil/nodes/utils/MaxMIPLevelNode.js | 61 + three/jsutil/nodes/utils/SwitchNode.js | 102 + three/jsutil/nodes/utils/TimerNode.js | 105 + three/jsutil/nodes/utils/UVTransformNode.js | 66 + three/jsutil/nodes/utils/VelocityNode.js | 174 + three/jsutil/objects/Lensflare.js | 376 ++ three/jsutil/objects/Reflector.js | 262 ++ three/jsutil/objects/ReflectorRTT.js | 9 + three/jsutil/objects/Refractor.js | 332 ++ three/jsutil/objects/ShadowMesh.js | 69 + three/jsutil/objects/Sky.js | 222 + three/jsutil/objects/Water.js | 308 ++ three/jsutil/objects/Water2.js | 338 ++ three/jsutil/pmrem/PMREMCubeUVPacker.js | 203 + three/jsutil/pmrem/PMREMGenerator.js | 285 ++ .../postprocessing/AdaptiveToneMappingPass.js | 344 ++ three/jsutil/postprocessing/AfterimagePass.js | 88 + three/jsutil/postprocessing/BloomPass.js | 119 + three/jsutil/postprocessing/BokehPass.js | 125 + three/jsutil/postprocessing/ClearPass.js | 44 + .../jsutil/postprocessing/CubeTexturePass.js | 57 + three/jsutil/postprocessing/DotScreenPass.js | 60 + three/jsutil/postprocessing/EffectComposer.js | 189 + three/jsutil/postprocessing/FilmPass.js | 61 + three/jsutil/postprocessing/GlitchPass.js | 116 + three/jsutil/postprocessing/HalftonePass.js | 74 + three/jsutil/postprocessing/MaskPass.js | 97 + three/jsutil/postprocessing/OutlinePass.js | 571 +++ three/jsutil/postprocessing/RenderPass.js | 63 + three/jsutil/postprocessing/SAOPass.js | 389 ++ three/jsutil/postprocessing/SMAAPass.js | 169 + three/jsutil/postprocessing/SSAARenderPass.js | 180 + three/jsutil/postprocessing/SSAOPass.js | 190 + three/jsutil/postprocessing/SavePass.js | 64 + three/jsutil/postprocessing/ShaderPass.js | 67 + three/jsutil/postprocessing/TAARenderPass.js | 131 + three/jsutil/postprocessing/TexturePass.js | 60 + .../jsutil/postprocessing/UnrealBloomPass.js | 384 ++ three/jsutil/renderers/CSS2DRenderer.js | 173 + three/jsutil/renderers/CSS3DRenderer.js | 324 ++ three/jsutil/renderers/CanvasRenderer.js | 1153 +++++ three/jsutil/renderers/Projector.js | 1108 +++++ three/jsutil/renderers/RaytracingRenderer.js | 287 ++ three/jsutil/renderers/RaytracingWorker.js | 541 +++ three/jsutil/renderers/SVGRenderer.js | 505 ++ three/jsutil/renderers/SoftwareRenderer.js | 1556 +++++++ .../jsutil/renderers/WebGLDeferredRenderer.js | 2522 ++++++++++ three/jsutil/shaders/AfterimageShader.js | 60 + three/jsutil/shaders/BasicShader.js | 31 + three/jsutil/shaders/BleachBypassShader.js | 64 + three/jsutil/shaders/BlendShader.js | 51 + three/jsutil/shaders/BokehShader.js | 146 + three/jsutil/shaders/BokehShader2.js | 398 ++ .../shaders/BrightnessContrastShader.js | 58 + three/jsutil/shaders/ColorCorrectionShader.js | 50 + three/jsutil/shaders/ColorifyShader.js | 49 + three/jsutil/shaders/ConvolutionShader.js | 101 + three/jsutil/shaders/CopyShader.js | 46 + three/jsutil/shaders/DOFMipMapShader.js | 58 + .../jsutil/shaders/DepthLimitedBlurShader.js | 155 + three/jsutil/shaders/DigitalGlitch.js | 103 + three/jsutil/shaders/DotScreenShader.js | 68 + three/jsutil/shaders/FXAAShader.js | 1115 +++++ three/jsutil/shaders/FilmShader.js | 104 + three/jsutil/shaders/FocusShader.js | 91 + three/jsutil/shaders/FreiChenShader.js | 93 + three/jsutil/shaders/FresnelShader.js | 74 + three/jsutil/shaders/GammaCorrectionShader.js | 45 + three/jsutil/shaders/HalftoneShader.js | 314 ++ three/jsutil/shaders/HorizontalBlurShader.js | 62 + .../shaders/HorizontalTiltShiftShader.js | 65 + three/jsutil/shaders/HueSaturationShader.js | 69 + three/jsutil/shaders/KaleidoShader.js | 60 + .../shaders/LuminosityHighPassShader.js | 64 + three/jsutil/shaders/LuminosityShader.js | 50 + three/jsutil/shaders/MirrorShader.js | 58 + three/jsutil/shaders/NormalMapShader.js | 53 + three/jsutil/shaders/OceanShaders.js | 365 ++ three/jsutil/shaders/ParallaxShader.js | 184 + three/jsutil/shaders/PixelShader.js | 47 + three/jsutil/shaders/RGBShiftShader.js | 56 + three/jsutil/shaders/SAOShader.js | 177 + three/jsutil/shaders/SMAAShader.js | 462 ++ three/jsutil/shaders/SSAOShader.js | 233 + three/jsutil/shaders/SepiaShader.js | 54 + three/jsutil/shaders/SobelOperatorShader.js | 90 + three/jsutil/shaders/TechnicolorShader.js | 47 + three/jsutil/shaders/ToneMapShader.js | 77 + three/jsutil/shaders/TriangleBlurShader.js | 72 + three/jsutil/shaders/UnpackDepthRGBAShader.js | 49 + three/jsutil/shaders/VerticalBlurShader.js | 62 + .../jsutil/shaders/VerticalTiltShiftShader.js | 65 + three/jsutil/shaders/VignetteShader.js | 63 + three/jsutil/shaders/VolumeShader.js | 324 ++ three/jsutil/shaders/WaterRefractionShader.js | 101 + three/jsutil/utils/BufferGeometryUtils.js | 385 ++ three/jsutil/utils/GeometryUtils.js | 300 ++ three/jsutil/utils/MathUtils.js | 63 + three/jsutil/utils/SceneUtils.js | 38 + three/jsutil/utils/ShadowMapViewer.js | 192 + three/jsutil/utils/SkeletonUtils.js | 533 +++ three/jsutil/utils/UVsDebug.js | 189 + three/jsutil/vr/PaintViveController.js | 184 + three/jsutil/vr/ViveController.js | 128 + three/jsutil/vr/WebVR.js | 238 + .../vr/deprecated/DaydreamController.js | 118 + .../jsutil/vr/deprecated/GearVRController.js | 132 + three/jsutil/workers/OffscreenCanvas.js | 76 + three/models/dmgh/DamagedHelmet.bin | Bin 0 -> 558504 bytes three/models/dmgh/DamagedHelmet.gltf | 204 + three/models/dmgh/Default_AO.jpg | Bin 0 -> 361678 bytes three/models/dmgh/Default_albedo.jpg | Bin 0 -> 935629 bytes three/models/dmgh/Default_emissive.jpg | Bin 0 -> 97499 bytes three/models/dmgh/Default_metalRoughness.jpg | Bin 0 -> 1300661 bytes three/models/dmgh/Default_normal.jpg | Bin 0 -> 517757 bytes three/models/sphere.bin | Bin 0 -> 10080 bytes three/models/sphere.gltf | 139 + three/models/sphere.json | 33 + three/textures/MilkyWay/dark-s_nx.jpg | Bin 0 -> 259233 bytes three/textures/MilkyWay/dark-s_ny.jpg | Bin 0 -> 348867 bytes three/textures/MilkyWay/dark-s_nz.jpg | Bin 0 -> 372622 bytes three/textures/MilkyWay/dark-s_px.jpg | Bin 0 -> 266566 bytes three/textures/MilkyWay/dark-s_py.jpg | Bin 0 -> 394125 bytes three/textures/MilkyWay/dark-s_pz.jpg | Bin 0 -> 415877 bytes 375 files changed, 121717 insertions(+), 457 deletions(-) create mode 100644 .idea/RootPresentation.iml create mode 100644 .idea/dictionaries/Joshua.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 .idea/jsLinters/jscs.xml create mode 100644 .idea/jsLinters/jshint.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 three/jsutil/AnimationClipCreator.js create mode 100644 three/jsutil/Car.js create mode 100644 three/jsutil/Cloth.js create mode 100644 three/jsutil/ConvexObjectBreaker.js create mode 100644 three/jsutil/CurveExtras.js create mode 100644 three/jsutil/GPUComputationRenderer.js create mode 100644 three/jsutil/GPUParticleSystem.js create mode 100644 three/jsutil/Gyroscope.js create mode 100644 three/jsutil/ImprovedNoise.js create mode 100644 three/jsutil/MD2Character.js create mode 100644 three/jsutil/MD2CharacterComplex.js create mode 100644 three/jsutil/MarchingCubes.js create mode 100644 three/jsutil/MorphAnimMesh.js create mode 100644 three/jsutil/MorphBlendMesh.js create mode 100644 three/jsutil/Ocean.js create mode 100644 three/jsutil/Octree.js create mode 100644 three/jsutil/PRNG.js create mode 100644 three/jsutil/ParametricGeometries.js create mode 100644 three/jsutil/QuickHull.js create mode 100644 three/jsutil/RollerCoaster.js create mode 100644 three/jsutil/ShaderGodRays.js create mode 100644 three/jsutil/ShaderSkin.js create mode 100644 three/jsutil/ShaderTerrain.js create mode 100644 three/jsutil/ShaderToon.js create mode 100644 three/jsutil/ShaderTranslucent.js create mode 100644 three/jsutil/SimplexNoise.js create mode 100644 three/jsutil/TimelinerController.js create mode 100644 three/jsutil/TypedArrayUtils.js create mode 100644 three/jsutil/UCSCharacter.js create mode 100644 three/jsutil/Volume.js create mode 100644 three/jsutil/VolumeSlice.js create mode 100644 three/jsutil/WebGL.js create mode 100644 three/jsutil/animation/CCDIKSolver.js create mode 100644 three/jsutil/animation/MMDAnimationHelper.js create mode 100644 three/jsutil/animation/MMDPhysics.js create mode 100644 three/jsutil/cameras/CinematicCamera.js create mode 100644 three/jsutil/controls/DeviceOrientationControls.js create mode 100644 three/jsutil/controls/DragControls.js create mode 100644 three/jsutil/controls/EditorControls.js create mode 100644 three/jsutil/controls/FirstPersonControls.js create mode 100644 three/jsutil/controls/FlyControls.js create mode 100644 three/jsutil/controls/MapControls.js create mode 100644 three/jsutil/controls/OrbitControls.js create mode 100644 three/jsutil/controls/OrthographicTrackballControls.js create mode 100644 three/jsutil/controls/PointerLockControls.js create mode 100644 three/jsutil/controls/TrackballControls.js create mode 100644 three/jsutil/controls/TransformControls.js create mode 100644 three/jsutil/crossfade/gui.js create mode 100644 three/jsutil/crossfade/scenes.js create mode 100644 three/jsutil/crossfade/transition.js create mode 100644 three/jsutil/curves/NURBSCurve.js create mode 100644 three/jsutil/curves/NURBSSurface.js create mode 100644 three/jsutil/curves/NURBSUtils.js create mode 100644 three/jsutil/effects/AnaglyphEffect.js create mode 100644 three/jsutil/effects/AsciiEffect.js create mode 100644 three/jsutil/effects/OutlineEffect.js create mode 100644 three/jsutil/effects/ParallaxBarrierEffect.js create mode 100644 three/jsutil/effects/PeppersGhostEffect.js create mode 100644 three/jsutil/effects/StereoEffect.js create mode 100644 three/jsutil/exporters/ColladaExporter.js create mode 100644 three/jsutil/exporters/GLTFExporter.js create mode 100644 three/jsutil/exporters/MMDExporter.js create mode 100644 three/jsutil/exporters/OBJExporter.js create mode 100644 three/jsutil/exporters/PLYExporter.js create mode 100644 three/jsutil/exporters/STLExporter.js create mode 100644 three/jsutil/exporters/TypedGeometryExporter.js create mode 100644 three/jsutil/geometries/BoxLineGeometry.js create mode 100644 three/jsutil/geometries/ConvexGeometry.js create mode 100644 three/jsutil/geometries/DecalGeometry.js create mode 100644 three/jsutil/geometries/TeapotBufferGeometry.js create mode 100644 three/jsutil/geometries/hilbert2D.js create mode 100644 three/jsutil/geometries/hilbert3D.js create mode 100644 three/jsutil/libs/ammo.js create mode 100644 three/jsutil/libs/dat.gui.min.js create mode 100644 three/jsutil/libs/draco/README.md create mode 100644 three/jsutil/libs/draco/draco_decoder.js create mode 100644 three/jsutil/libs/draco/draco_decoder.wasm create mode 100644 three/jsutil/libs/draco/draco_wasm_wrapper.js create mode 100644 three/jsutil/libs/draco/gltf/draco_decoder.js create mode 100644 three/jsutil/libs/draco/gltf/draco_decoder.wasm create mode 100644 three/jsutil/libs/draco/gltf/draco_encoder.js create mode 100644 three/jsutil/libs/draco/gltf/draco_wasm_wrapper.js create mode 100644 three/jsutil/libs/gunzip.min.js create mode 100644 three/jsutil/libs/inflate.min.js create mode 100644 three/jsutil/libs/jszip.min.js create mode 100644 three/jsutil/libs/mmdparser.min.js create mode 100644 three/jsutil/libs/o3dgc.js create mode 100644 three/jsutil/libs/opentype.min.js create mode 100644 three/jsutil/libs/stats.min.js create mode 100644 three/jsutil/libs/system.min.js create mode 100644 three/jsutil/libs/timeliner_gui.min.js create mode 100644 three/jsutil/libs/tween.min.js create mode 100644 three/jsutil/lights/RectAreaLightUniformsLib.js create mode 100644 three/jsutil/lines/Line2.js create mode 100644 three/jsutil/lines/LineGeometry.js create mode 100644 three/jsutil/lines/LineMaterial.js create mode 100644 three/jsutil/lines/LineSegments2.js create mode 100644 three/jsutil/lines/LineSegmentsGeometry.js create mode 100644 three/jsutil/lines/Wireframe.js create mode 100644 three/jsutil/lines/WireframeGeometry2.js create mode 100644 three/jsutil/loaders/3MFLoader.js create mode 100644 three/jsutil/loaders/AMFLoader.js create mode 100644 three/jsutil/loaders/AWDLoader.js create mode 100644 three/jsutil/loaders/AssimpJSONLoader.js create mode 100644 three/jsutil/loaders/AssimpLoader.js create mode 100644 three/jsutil/loaders/BVHLoader.js create mode 100644 three/jsutil/loaders/BabylonLoader.js create mode 100644 three/jsutil/loaders/ColladaLoader.js create mode 100644 three/jsutil/loaders/DDSLoader.js create mode 100644 three/jsutil/loaders/DRACOLoader.js create mode 100644 three/jsutil/loaders/EXRLoader.js create mode 100644 three/jsutil/loaders/EquirectangularToCubeGenerator.js create mode 100644 three/jsutil/loaders/FBXLoader.js create mode 100644 three/jsutil/loaders/GCodeLoader.js create mode 100644 three/jsutil/loaders/GLTFLoader.js create mode 100644 three/jsutil/loaders/HDRCubeTextureLoader.js create mode 100644 three/jsutil/loaders/KMZLoader.js create mode 100644 three/jsutil/loaders/KTXLoader.js create mode 100644 three/jsutil/loaders/LoaderSupport.js create mode 100644 three/jsutil/loaders/MD2Loader.js create mode 100644 three/jsutil/loaders/MMDLoader.js create mode 100644 three/jsutil/loaders/MTLLoader.js create mode 100644 three/jsutil/loaders/NRRDLoader.js create mode 100644 three/jsutil/loaders/NodeMaterialLoader.js create mode 100644 three/jsutil/loaders/OBJLoader.js create mode 100644 three/jsutil/loaders/OBJLoader2.js create mode 100644 three/jsutil/loaders/PCDLoader.js create mode 100644 three/jsutil/loaders/PDBLoader.js create mode 100644 three/jsutil/loaders/PLYLoader.js create mode 100644 three/jsutil/loaders/PRWMLoader.js create mode 100644 three/jsutil/loaders/PVRLoader.js create mode 100644 three/jsutil/loaders/PlayCanvasLoader.js create mode 100644 three/jsutil/loaders/RGBELoader.js create mode 100644 three/jsutil/loaders/STLLoader.js create mode 100644 three/jsutil/loaders/SVGLoader.js create mode 100644 three/jsutil/loaders/TDSLoader.js create mode 100644 three/jsutil/loaders/TGALoader.js create mode 100644 three/jsutil/loaders/TTFLoader.js create mode 100644 three/jsutil/loaders/VRMLLoader.js create mode 100644 three/jsutil/loaders/VRMLoader.js create mode 100644 three/jsutil/loaders/VTKLoader.js create mode 100644 three/jsutil/loaders/XLoader.js create mode 100644 three/jsutil/loaders/ctm/CTMLoader.js create mode 100644 three/jsutil/loaders/ctm/CTMWorker.js create mode 100644 three/jsutil/loaders/ctm/ctm.js create mode 100644 three/jsutil/loaders/ctm/license/OpenCTM.txt create mode 100644 three/jsutil/loaders/ctm/license/js-lzma.txt create mode 100644 three/jsutil/loaders/ctm/license/js-openctm.txt create mode 100644 three/jsutil/loaders/ctm/lzma.js create mode 100644 three/jsutil/loaders/deprecated/LegacyGLTFLoader.js create mode 100644 three/jsutil/loaders/sea3d/SEA3D.js create mode 100644 three/jsutil/loaders/sea3d/SEA3DDeflate.js create mode 100644 three/jsutil/loaders/sea3d/SEA3DDraco.js create mode 100644 three/jsutil/loaders/sea3d/SEA3DLZMA.js create mode 100644 three/jsutil/loaders/sea3d/SEA3DLegacy.js create mode 100644 three/jsutil/loaders/sea3d/SEA3DLoader.js create mode 100644 three/jsutil/loaders/sea3d/o3dgc/SEA3DGC.js create mode 100644 three/jsutil/loaders/sea3d/physics/SEA3DAmmo.js create mode 100644 three/jsutil/loaders/sea3d/physics/SEA3DAmmoLoader.js create mode 100644 three/jsutil/loaders/sea3d/physics/SEA3DRigidBody.js create mode 100644 three/jsutil/math/ColorConverter.js create mode 100644 three/jsutil/math/Lut.js create mode 100644 three/jsutil/modifiers/ExplodeModifier.js create mode 100644 three/jsutil/modifiers/SimplifyModifier.js create mode 100644 three/jsutil/modifiers/SubdivisionModifier.js create mode 100644 three/jsutil/modifiers/TessellateModifier.js create mode 100644 three/jsutil/nodes/Nodes.js create mode 100644 three/jsutil/nodes/THREE.Nodes.js create mode 100644 three/jsutil/nodes/accessors/CameraNode.js create mode 100644 three/jsutil/nodes/accessors/ColorsNode.js create mode 100644 three/jsutil/nodes/accessors/LightNode.js create mode 100644 three/jsutil/nodes/accessors/NormalNode.js create mode 100644 three/jsutil/nodes/accessors/PositionNode.js create mode 100644 three/jsutil/nodes/accessors/ReflectNode.js create mode 100644 three/jsutil/nodes/accessors/ResolutionNode.js create mode 100644 three/jsutil/nodes/accessors/ScreenUVNode.js create mode 100644 three/jsutil/nodes/accessors/UVNode.js create mode 100644 three/jsutil/nodes/bsdfs/BlinnExponentToRoughnessNode.js create mode 100644 three/jsutil/nodes/bsdfs/BlinnShininessExponentNode.js create mode 100644 three/jsutil/nodes/bsdfs/RoughnessToBlinnExponentNode.js create mode 100644 three/jsutil/nodes/core/AttributeNode.js create mode 100644 three/jsutil/nodes/core/ConstNode.js create mode 100644 three/jsutil/nodes/core/ExpressionNode.js create mode 100644 three/jsutil/nodes/core/FunctionCallNode.js create mode 100644 three/jsutil/nodes/core/FunctionNode.js create mode 100644 three/jsutil/nodes/core/InputNode.js create mode 100644 three/jsutil/nodes/core/Node.js create mode 100644 three/jsutil/nodes/core/NodeBuilder.js create mode 100644 three/jsutil/nodes/core/NodeFrame.js create mode 100644 three/jsutil/nodes/core/NodeLib.js create mode 100644 three/jsutil/nodes/core/NodeUniform.js create mode 100644 three/jsutil/nodes/core/NodeUtils.js create mode 100644 three/jsutil/nodes/core/StructNode.js create mode 100644 three/jsutil/nodes/core/TempNode.js create mode 100644 three/jsutil/nodes/core/VarNode.js create mode 100644 three/jsutil/nodes/effects/BlurNode.js create mode 100644 three/jsutil/nodes/effects/ColorAdjustmentNode.js create mode 100644 three/jsutil/nodes/effects/LuminanceNode.js create mode 100644 three/jsutil/nodes/inputs/ColorNode.js create mode 100644 three/jsutil/nodes/inputs/CubeTextureNode.js create mode 100644 three/jsutil/nodes/inputs/FloatNode.js create mode 100644 three/jsutil/nodes/inputs/IntNode.js create mode 100644 three/jsutil/nodes/inputs/Matrix3Node.js create mode 100644 three/jsutil/nodes/inputs/Matrix4Node.js create mode 100644 three/jsutil/nodes/inputs/PropertyNode.js create mode 100644 three/jsutil/nodes/inputs/RTTNode.js create mode 100644 three/jsutil/nodes/inputs/ReflectorNode.js create mode 100644 three/jsutil/nodes/inputs/ScreenNode.js create mode 100644 three/jsutil/nodes/inputs/TextureNode.js create mode 100644 three/jsutil/nodes/inputs/Vector2Node.js create mode 100644 three/jsutil/nodes/inputs/Vector3Node.js create mode 100644 three/jsutil/nodes/inputs/Vector4Node.js create mode 100644 three/jsutil/nodes/materials/MeshStandardNodeMaterial.js create mode 100644 three/jsutil/nodes/materials/NodeMaterial.js create mode 100644 three/jsutil/nodes/materials/PhongNodeMaterial.js create mode 100644 three/jsutil/nodes/materials/SpriteNodeMaterial.js create mode 100644 three/jsutil/nodes/materials/StandardNodeMaterial.js create mode 100644 three/jsutil/nodes/materials/nodes/MeshStandardNode.js create mode 100644 three/jsutil/nodes/materials/nodes/PhongNode.js create mode 100644 three/jsutil/nodes/materials/nodes/RawNode.js create mode 100644 three/jsutil/nodes/materials/nodes/SpriteNode.js create mode 100644 three/jsutil/nodes/materials/nodes/StandardNode.js create mode 100644 three/jsutil/nodes/math/CondNode.js create mode 100644 three/jsutil/nodes/math/Math1Node.js create mode 100644 three/jsutil/nodes/math/Math2Node.js create mode 100644 three/jsutil/nodes/math/Math3Node.js create mode 100644 three/jsutil/nodes/math/OperatorNode.js create mode 100644 three/jsutil/nodes/misc/BumpMapNode.js create mode 100644 three/jsutil/nodes/misc/NormalMapNode.js create mode 100644 three/jsutil/nodes/misc/TextureCubeNode.js create mode 100644 three/jsutil/nodes/misc/TextureCubeUVNode.js create mode 100644 three/jsutil/nodes/postprocessing/NodePass.js create mode 100644 three/jsutil/nodes/postprocessing/NodePostProcessing.js create mode 100644 three/jsutil/nodes/procedural/CheckerNode.js create mode 100644 three/jsutil/nodes/procedural/NoiseNode.js create mode 100644 three/jsutil/nodes/utils/BypassNode.js create mode 100644 three/jsutil/nodes/utils/ColorSpaceNode.js create mode 100644 three/jsutil/nodes/utils/JoinNode.js create mode 100644 three/jsutil/nodes/utils/MaxMIPLevelNode.js create mode 100644 three/jsutil/nodes/utils/SwitchNode.js create mode 100644 three/jsutil/nodes/utils/TimerNode.js create mode 100644 three/jsutil/nodes/utils/UVTransformNode.js create mode 100644 three/jsutil/nodes/utils/VelocityNode.js create mode 100644 three/jsutil/objects/Lensflare.js create mode 100644 three/jsutil/objects/Reflector.js create mode 100644 three/jsutil/objects/ReflectorRTT.js create mode 100644 three/jsutil/objects/Refractor.js create mode 100644 three/jsutil/objects/ShadowMesh.js create mode 100644 three/jsutil/objects/Sky.js create mode 100644 three/jsutil/objects/Water.js create mode 100644 three/jsutil/objects/Water2.js create mode 100644 three/jsutil/pmrem/PMREMCubeUVPacker.js create mode 100644 three/jsutil/pmrem/PMREMGenerator.js create mode 100644 three/jsutil/postprocessing/AdaptiveToneMappingPass.js create mode 100644 three/jsutil/postprocessing/AfterimagePass.js create mode 100644 three/jsutil/postprocessing/BloomPass.js create mode 100644 three/jsutil/postprocessing/BokehPass.js create mode 100644 three/jsutil/postprocessing/ClearPass.js create mode 100644 three/jsutil/postprocessing/CubeTexturePass.js create mode 100644 three/jsutil/postprocessing/DotScreenPass.js create mode 100644 three/jsutil/postprocessing/EffectComposer.js create mode 100644 three/jsutil/postprocessing/FilmPass.js create mode 100644 three/jsutil/postprocessing/GlitchPass.js create mode 100644 three/jsutil/postprocessing/HalftonePass.js create mode 100644 three/jsutil/postprocessing/MaskPass.js create mode 100644 three/jsutil/postprocessing/OutlinePass.js create mode 100644 three/jsutil/postprocessing/RenderPass.js create mode 100644 three/jsutil/postprocessing/SAOPass.js create mode 100644 three/jsutil/postprocessing/SMAAPass.js create mode 100644 three/jsutil/postprocessing/SSAARenderPass.js create mode 100644 three/jsutil/postprocessing/SSAOPass.js create mode 100644 three/jsutil/postprocessing/SavePass.js create mode 100644 three/jsutil/postprocessing/ShaderPass.js create mode 100644 three/jsutil/postprocessing/TAARenderPass.js create mode 100644 three/jsutil/postprocessing/TexturePass.js create mode 100644 three/jsutil/postprocessing/UnrealBloomPass.js create mode 100644 three/jsutil/renderers/CSS2DRenderer.js create mode 100644 three/jsutil/renderers/CSS3DRenderer.js create mode 100644 three/jsutil/renderers/CanvasRenderer.js create mode 100644 three/jsutil/renderers/Projector.js create mode 100644 three/jsutil/renderers/RaytracingRenderer.js create mode 100644 three/jsutil/renderers/RaytracingWorker.js create mode 100644 three/jsutil/renderers/SVGRenderer.js create mode 100644 three/jsutil/renderers/SoftwareRenderer.js create mode 100644 three/jsutil/renderers/WebGLDeferredRenderer.js create mode 100644 three/jsutil/shaders/AfterimageShader.js create mode 100644 three/jsutil/shaders/BasicShader.js create mode 100644 three/jsutil/shaders/BleachBypassShader.js create mode 100644 three/jsutil/shaders/BlendShader.js create mode 100644 three/jsutil/shaders/BokehShader.js create mode 100644 three/jsutil/shaders/BokehShader2.js create mode 100644 three/jsutil/shaders/BrightnessContrastShader.js create mode 100644 three/jsutil/shaders/ColorCorrectionShader.js create mode 100644 three/jsutil/shaders/ColorifyShader.js create mode 100644 three/jsutil/shaders/ConvolutionShader.js create mode 100644 three/jsutil/shaders/CopyShader.js create mode 100644 three/jsutil/shaders/DOFMipMapShader.js create mode 100644 three/jsutil/shaders/DepthLimitedBlurShader.js create mode 100644 three/jsutil/shaders/DigitalGlitch.js create mode 100644 three/jsutil/shaders/DotScreenShader.js create mode 100644 three/jsutil/shaders/FXAAShader.js create mode 100644 three/jsutil/shaders/FilmShader.js create mode 100644 three/jsutil/shaders/FocusShader.js create mode 100644 three/jsutil/shaders/FreiChenShader.js create mode 100644 three/jsutil/shaders/FresnelShader.js create mode 100644 three/jsutil/shaders/GammaCorrectionShader.js create mode 100644 three/jsutil/shaders/HalftoneShader.js create mode 100644 three/jsutil/shaders/HorizontalBlurShader.js create mode 100644 three/jsutil/shaders/HorizontalTiltShiftShader.js create mode 100644 three/jsutil/shaders/HueSaturationShader.js create mode 100644 three/jsutil/shaders/KaleidoShader.js create mode 100644 three/jsutil/shaders/LuminosityHighPassShader.js create mode 100644 three/jsutil/shaders/LuminosityShader.js create mode 100644 three/jsutil/shaders/MirrorShader.js create mode 100644 three/jsutil/shaders/NormalMapShader.js create mode 100644 three/jsutil/shaders/OceanShaders.js create mode 100644 three/jsutil/shaders/ParallaxShader.js create mode 100644 three/jsutil/shaders/PixelShader.js create mode 100644 three/jsutil/shaders/RGBShiftShader.js create mode 100644 three/jsutil/shaders/SAOShader.js create mode 100644 three/jsutil/shaders/SMAAShader.js create mode 100644 three/jsutil/shaders/SSAOShader.js create mode 100644 three/jsutil/shaders/SepiaShader.js create mode 100644 three/jsutil/shaders/SobelOperatorShader.js create mode 100644 three/jsutil/shaders/TechnicolorShader.js create mode 100644 three/jsutil/shaders/ToneMapShader.js create mode 100644 three/jsutil/shaders/TriangleBlurShader.js create mode 100644 three/jsutil/shaders/UnpackDepthRGBAShader.js create mode 100644 three/jsutil/shaders/VerticalBlurShader.js create mode 100644 three/jsutil/shaders/VerticalTiltShiftShader.js create mode 100644 three/jsutil/shaders/VignetteShader.js create mode 100644 three/jsutil/shaders/VolumeShader.js create mode 100644 three/jsutil/shaders/WaterRefractionShader.js create mode 100644 three/jsutil/utils/BufferGeometryUtils.js create mode 100644 three/jsutil/utils/GeometryUtils.js create mode 100644 three/jsutil/utils/MathUtils.js create mode 100644 three/jsutil/utils/SceneUtils.js create mode 100644 three/jsutil/utils/ShadowMapViewer.js create mode 100644 three/jsutil/utils/SkeletonUtils.js create mode 100644 three/jsutil/utils/UVsDebug.js create mode 100644 three/jsutil/vr/PaintViveController.js create mode 100644 three/jsutil/vr/ViveController.js create mode 100644 three/jsutil/vr/WebVR.js create mode 100644 three/jsutil/vr/deprecated/DaydreamController.js create mode 100644 three/jsutil/vr/deprecated/GearVRController.js create mode 100644 three/jsutil/workers/OffscreenCanvas.js create mode 100644 three/models/dmgh/DamagedHelmet.bin create mode 100644 three/models/dmgh/DamagedHelmet.gltf create mode 100644 three/models/dmgh/Default_AO.jpg create mode 100644 three/models/dmgh/Default_albedo.jpg create mode 100644 three/models/dmgh/Default_emissive.jpg create mode 100644 three/models/dmgh/Default_metalRoughness.jpg create mode 100644 three/models/dmgh/Default_normal.jpg create mode 100644 three/models/sphere.bin create mode 100644 three/models/sphere.gltf create mode 100644 three/models/sphere.json create mode 100644 three/textures/MilkyWay/dark-s_nx.jpg create mode 100644 three/textures/MilkyWay/dark-s_ny.jpg create mode 100644 three/textures/MilkyWay/dark-s_nz.jpg create mode 100644 three/textures/MilkyWay/dark-s_px.jpg create mode 100644 three/textures/MilkyWay/dark-s_py.jpg create mode 100644 three/textures/MilkyWay/dark-s_pz.jpg diff --git a/.idea/RootPresentation.iml b/.idea/RootPresentation.iml new file mode 100644 index 000000000..2d9df833d --- /dev/null +++ b/.idea/RootPresentation.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/Joshua.xml b/.idea/dictionaries/Joshua.xml new file mode 100644 index 000000000..1e499cfa1 --- /dev/null +++ b/.idea/dictionaries/Joshua.xml @@ -0,0 +1,10 @@ + + + + antialias + dmgh + gltf + jsutil + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..eff7139dc --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 000000000..d4280b0ba --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jsLinters/jscs.xml b/.idea/jsLinters/jscs.xml new file mode 100644 index 000000000..228832d36 --- /dev/null +++ b/.idea/jsLinters/jscs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/jsLinters/jshint.xml b/.idea/jsLinters/jshint.xml new file mode 100644 index 000000000..396d6b0f3 --- /dev/null +++ b/.idea/jsLinters/jshint.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..7787a81f4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..f77be66c0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..e1f727b76 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..9f3bb8bfb --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,340 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + transition + config + transitionDuration + = + (GlobalDuration/(GlobalDuration-(state[7]-Date.now()))) + *translationScale + key + bar + window.impress + next() + Duration + duration + state + Date.now + ease-in-out + ease + Globaldur + GlobalDuration + window.init + window.impress() + window.impress().next + impress().next + current + currentState + GlobalDur + GlobalDurat + keyboard + keyevent + deltaProgress + GlobalDura + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; + + // NOTE: We're not optimizing the attribute arrays here, so they're all the same length and + // can therefore share the same triangle indices. However, MeshLab seems to have trouble opening + // models with attributes that share an offset. + // MeshLab Bug#424: https://sourceforge.net/p/meshlab/bugs/424/ + + // serialize normals + var triangleInputs = ``; + if ( 'normal' in bufferGeometry.attributes ) { + + var normName = `${ meshid }-normal`; + gnode += getAttribute( bufferGeometry.attributes.normal, normName, [ 'X', 'Y', 'Z' ], 'float' ); + triangleInputs += ``; + + } + + // serialize uvs + if ( 'uv' in bufferGeometry.attributes ) { + + var uvName = `${ meshid }-texcoord`; + gnode += getAttribute( bufferGeometry.attributes.uv, uvName, [ 'S', 'T' ], 'float' ); + triangleInputs += ``; + + } + + // serialize colors + if ( 'color' in bufferGeometry.attributes ) { + + var colName = `${ meshid }-color`; + gnode += getAttribute( bufferGeometry.attributes.color, colName, [ 'X', 'Y', 'Z' ], 'uint8' ); + triangleInputs += ``; + + } + + var indexArray = null; + if ( bufferGeometry.index ) { + + indexArray = attrBufferToArray( bufferGeometry.index ); + + } else { + + indexArray = new Array( indexCount ); + for ( var i = 0, l = indexArray.length; i < l; i ++ ) indexArray[ i ] = i; + + } + + for ( var i = 0, l = groups.length; i < l; i ++ ) { + + var group = groups[ i ]; + var subarr = subArray( indexArray, group.start, group.count ); + var polycount = subarr.length / 3; + gnode += ``; + gnode += triangleInputs; + + gnode += `

${ subarr.join( ' ' ) }

`; + gnode += '
'; + + } + + gnode += ``; + + libraryGeometries.push( gnode ); + + info = { meshid: meshid, bufferGeometry: bufferGeometry }; + geometryInfo.set( g, info ); + + } + + return info; + + } + + // Process the given texture into the image library + // Returns the image library + function processTexture( tex ) { + + var texid = imageMap.get( tex ); + if ( texid == null ) { + + texid = `image-${ libraryImages.length + 1 }`; + + var ext = 'png'; + var name = tex.name || texid; + var imageNode = ``; + + if ( version === '1.5.0' ) { + + imageNode += `${ options.textureDirectory }${ name }.${ ext }`; + + } else { + + // version image node 1.4.1 + imageNode += `${ options.textureDirectory }${ name }.${ ext }`; + + } + + imageNode += ''; + + libraryImages.push( imageNode ); + imageMap.set( tex, texid ); + textures.push( { + directory: options.textureDirectory, + name, + ext, + data: imageToData( tex.image, ext ), + original: tex + } ); + + } + + return texid; + + } + + // Process the given material into the material and effect libraries + // Returns the material id + function processMaterial( m ) { + + var matid = materialMap.get( m ); + + if ( matid == null ) { + + matid = `Mat${ libraryEffects.length + 1 }`; + + var type = 'phong'; + + if ( m instanceof THREE.MeshLambertMaterial ) { + + type = 'lambert'; + + } else if ( m instanceof THREE.MeshBasicMaterial ) { + + type = 'constant'; + + } + + var emissive = m.emissive ? m.emissive : new THREE.Color( 0, 0, 0 ); + var diffuse = m.color ? m.color : new THREE.Color( 0, 0, 0 ); + var specular = m.specular ? m.specular : new THREE.Color( 1, 1, 1 ); + var shininess = m.shininess || 0; + var reflectivity = m.reflectivity || 0; + + // Do not export and alpha map for the reasons mentioned in issue (#13792) + // in THREE.js alpha maps are black and white, but collada expects the alpha + // channel to specify the transparency + var transparencyNode = ''; + if ( m.transparent === true ) { + + transparencyNode += + `` + + ( + m.map ? + `` : + '1' + ) + + ''; + + if ( m.opacity < 1 ) { + + transparencyNode += `${ m.opacity }`; + + } + + } + + var techniqueNode = `<${ type }>` + + + '' + + + ( + m.emissiveMap ? + '' : + `${ emissive.r } ${ emissive.g } ${ emissive.b } 1` + ) + + + '' + + + '' + + + ( + m.map ? + '' : + `${ diffuse.r } ${ diffuse.g } ${ diffuse.b } 1` + ) + + + '' + + + `${ specular.r } ${ specular.g } ${ specular.b } 1` + + + '' + + + ( + m.specularMap ? + '' : + `${ shininess }` + ) + + + '' + + + `${ diffuse.r } ${ diffuse.g } ${ diffuse.b } 1` + + + `${ reflectivity }` + + + transparencyNode + + + ``; + + var effectnode = + `` + + '' + + + ( + m.map ? + '' + + `${ processTexture( m.map ) }` + + '' + + 'diffuse-surface' : + '' + ) + + + ( + m.specularMap ? + '' + + `${ processTexture( m.specularMap ) }` + + '' + + 'specular-surface' : + '' + ) + + + ( + m.emissiveMap ? + '' + + `${ processTexture( m.emissiveMap ) }` + + '' + + 'emissive-surface' : + '' + ) + + + techniqueNode + + + ( + m.side === THREE.DoubleSide ? + `1` : + '' + ) + + + '' + + + ''; + + libraryMaterials.push( `` ); + libraryEffects.push( effectnode ); + materialMap.set( m, matid ); + + } + + return matid; + + } + + // Recursively process the object into a scene + function processObject( o ) { + + var node = ``; + + node += getTransform( o ); + + if ( o instanceof THREE.Mesh && o.geometry != null ) { + + // function returns the id associated with the mesh and a "BufferGeometry" version + // of the geometry in case it's not a geometry. + var geomInfo = processGeometry( o.geometry ); + var meshid = geomInfo.meshid; + var geometry = geomInfo.bufferGeometry; + + // ids of the materials to bind to the geometry + var matids = null; + + // get a list of materials to bind to the sub groups of the geometry. + // If the amount of subgroups is greater than the materials, than reuse + // the materials. + var mat = o.material || new THREE.MeshBasicMaterial(); + var materials = Array.isArray( mat ) ? mat : [ mat ]; + matids = new Array( geometry.groups.length ) + .fill() + .map( ( v, i ) => processMaterial( materials[ i % materials.length ] ) ); + + + node += + `` + + + ( + matids != null ? + '' + + matids.map( ( id, i ) => + + `` + + + '' + + + '' + ).join( '' ) + + '' : + '' + ) + + + ''; + + } + + o.children.forEach( c => node += processObject( c ) ); + + node += ''; + + return node; + + } + + var geometryInfo = new WeakMap(); + var materialMap = new WeakMap(); + var imageMap = new WeakMap(); + var textures = []; + + var libraryImages = []; + var libraryGeometries = []; + var libraryEffects = []; + var libraryMaterials = []; + var libraryVisualScenes = processObject( object ); + + var specLink = version === '1.4.1' ? 'http://www.collada.org/2005/11/COLLADASchema' : 'https://www.khronos.org/collada/'; + var dae = + '' + + `` + + '' + + ( + '' + + 'THREE.js Collada Exporter' + + ( options.author !== null ? `${ options.author }` : '' ) + + '' + + `${ ( new Date() ).toISOString() }` + + `${ ( new Date() ).toISOString() }` + + 'Y_UP' + ) + + ''; + + dae += `${ libraryImages.join( '' ) }`; + + dae += `${ libraryEffects.join( '' ) }`; + + dae += `${ libraryMaterials.join( '' ) }`; + + dae += `${ libraryGeometries.join( '' ) }`; + + dae += `${ libraryVisualScenes }`; + + dae += ''; + + dae += ''; + + var res = { + data: format( dae ), + textures + }; + + if ( typeof onDone === 'function' ) { + + requestAnimationFrame( () => onDone( res ) ); + + } + + return res; + + } + +}; diff --git a/three/jsutil/exporters/GLTFExporter.js b/three/jsutil/exporters/GLTFExporter.js new file mode 100644 index 000000000..271f96646 --- /dev/null +++ b/three/jsutil/exporters/GLTFExporter.js @@ -0,0 +1,1856 @@ +/** + * @author fernandojsg / http://fernandojsg.com + * @author Don McCurdy / https://www.donmccurdy.com + * @author Takahiro / https://github.com/takahirox + */ + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ +var WEBGL_CONSTANTS = { + POINTS: 0x0000, + LINES: 0x0001, + LINE_LOOP: 0x0002, + LINE_STRIP: 0x0003, + TRIANGLES: 0x0004, + TRIANGLE_STRIP: 0x0005, + TRIANGLE_FAN: 0x0006, + + UNSIGNED_BYTE: 0x1401, + UNSIGNED_SHORT: 0x1403, + FLOAT: 0x1406, + UNSIGNED_INT: 0x1405, + ARRAY_BUFFER: 0x8892, + ELEMENT_ARRAY_BUFFER: 0x8893, + + NEAREST: 0x2600, + LINEAR: 0x2601, + NEAREST_MIPMAP_NEAREST: 0x2700, + LINEAR_MIPMAP_NEAREST: 0x2701, + NEAREST_MIPMAP_LINEAR: 0x2702, + LINEAR_MIPMAP_LINEAR: 0x2703 +}; + +var THREE_TO_WEBGL = { + // @TODO Replace with computed property name [THREE.*] when available on es6 + 1003: WEBGL_CONSTANTS.NEAREST, + 1004: WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST, + 1005: WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR, + 1006: WEBGL_CONSTANTS.LINEAR, + 1007: WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST, + 1008: WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR +}; + +var PATH_PROPERTIES = { + scale: 'scale', + position: 'translation', + quaternion: 'rotation', + morphTargetInfluences: 'weights' +}; + +//------------------------------------------------------------------------------ +// GLTF Exporter +//------------------------------------------------------------------------------ +THREE.GLTFExporter = function () {}; + +THREE.GLTFExporter.prototype = { + + constructor: THREE.GLTFExporter, + + /** + * Parse scenes and generate GLTF output + * @param {THREE.Scene or [THREE.Scenes]} input THREE.Scene or Array of THREE.Scenes + * @param {Function} onDone Callback on completed + * @param {Object} options options + */ + parse: function ( input, onDone, options ) { + + var DEFAULT_OPTIONS = { + binary: false, + trs: false, + onlyVisible: true, + truncateDrawRange: true, + embedImages: true, + animations: [], + forceIndices: false, + forcePowerOfTwoTextures: false + }; + + options = Object.assign( {}, DEFAULT_OPTIONS, options ); + + if ( options.animations.length > 0 ) { + + // Only TRS properties, and not matrices, may be targeted by animation. + options.trs = true; + + } + + var outputJSON = { + + asset: { + + version: "2.0", + generator: "THREE.GLTFExporter" + + } + + }; + + var byteOffset = 0; + var buffers = []; + var pending = []; + var nodeMap = new Map(); + var skins = []; + var extensionsUsed = {}; + var cachedData = { + + attributes: new Map(), + materials: new Map(), + textures: new Map(), + images: new Map() + + }; + + var cachedCanvas; + + /** + * Compare two arrays + */ + /** + * Compare two arrays + * @param {Array} array1 Array 1 to compare + * @param {Array} array2 Array 2 to compare + * @return {Boolean} Returns true if both arrays are equal + */ + function equalArray( array1, array2 ) { + + return ( array1.length === array2.length ) && array1.every( function ( element, index ) { + + return element === array2[ index ]; + + } ); + + } + + /** + * Converts a string to an ArrayBuffer. + * @param {string} text + * @return {ArrayBuffer} + */ + function stringToArrayBuffer( text ) { + + if ( window.TextEncoder !== undefined ) { + + return new TextEncoder().encode( text ).buffer; + + } + + var array = new Uint8Array( new ArrayBuffer( text.length ) ); + + for ( var i = 0, il = text.length; i < il; i ++ ) { + + var value = text.charCodeAt( i ); + + // Replacing multi-byte character with space(0x20). + array[ i ] = value > 0xFF ? 0x20 : value; + + } + + return array.buffer; + + } + + /** + * Get the min and max vectors from the given attribute + * @param {THREE.BufferAttribute} attribute Attribute to find the min/max in range from start to start + count + * @param {Integer} start + * @param {Integer} count + * @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components) + */ + function getMinMax( attribute, start, count ) { + + var output = { + + min: new Array( attribute.itemSize ).fill( Number.POSITIVE_INFINITY ), + max: new Array( attribute.itemSize ).fill( Number.NEGATIVE_INFINITY ) + + }; + + for ( var i = start; i < start + count; i ++ ) { + + for ( var a = 0; a < attribute.itemSize; a ++ ) { + + var value = attribute.array[ i * attribute.itemSize + a ]; + output.min[ a ] = Math.min( output.min[ a ], value ); + output.max[ a ] = Math.max( output.max[ a ], value ); + + } + + } + + return output; + + } + + /** + * Checks if image size is POT. + * + * @param {Image} image The image to be checked. + * @returns {Boolean} Returns true if image size is POT. + * + */ + function isPowerOfTwo( image ) { + + return THREE.Math.isPowerOfTwo( image.width ) && THREE.Math.isPowerOfTwo( image.height ); + + } + + /** + * Checks if normal attribute values are normalized. + * + * @param {THREE.BufferAttribute} normal + * @returns {Boolean} + * + */ + function isNormalizedNormalAttribute( normal ) { + + if ( cachedData.attributes.has( normal ) ) { + + return false; + + } + + var v = new THREE.Vector3(); + + for ( var i = 0, il = normal.count; i < il; i ++ ) { + + // 0.0005 is from glTF-validator + if ( Math.abs( v.fromArray( normal.array, i * 3 ).length() - 1.0 ) > 0.0005 ) return false; + + } + + return true; + + } + + /** + * Creates normalized normal buffer attribute. + * + * @param {THREE.BufferAttribute} normal + * @returns {THREE.BufferAttribute} + * + */ + function createNormalizedNormalAttribute( normal ) { + + if ( cachedData.attributes.has( normal ) ) { + + return cachedData.attributes.get( normal ); + + } + + var attribute = normal.clone(); + + var v = new THREE.Vector3(); + + for ( var i = 0, il = attribute.count; i < il; i ++ ) { + + v.fromArray( attribute.array, i * 3 ); + + if ( v.x === 0 && v.y === 0 && v.z === 0 ) { + + // if values can't be normalized set (1, 0, 0) + v.setX( 1.0 ); + + } else { + + v.normalize(); + + } + + v.toArray( attribute.array, i * 3 ); + + } + + cachedData.attributes.set( normal, attribute ); + + return attribute; + + } + + /** + * Get the required size + padding for a buffer, rounded to the next 4-byte boundary. + * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment + * + * @param {Integer} bufferSize The size the original buffer. + * @returns {Integer} new buffer size with required padding. + * + */ + function getPaddedBufferSize( bufferSize ) { + + return Math.ceil( bufferSize / 4 ) * 4; + + } + + /** + * Returns a buffer aligned to 4-byte boundary. + * + * @param {ArrayBuffer} arrayBuffer Buffer to pad + * @param {Integer} paddingByte (Optional) + * @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer + */ + function getPaddedArrayBuffer( arrayBuffer, paddingByte ) { + + paddingByte = paddingByte || 0; + + var paddedLength = getPaddedBufferSize( arrayBuffer.byteLength ); + + if ( paddedLength !== arrayBuffer.byteLength ) { + + var array = new Uint8Array( paddedLength ); + array.set( new Uint8Array( arrayBuffer ) ); + + if ( paddingByte !== 0 ) { + + for ( var i = arrayBuffer.byteLength; i < paddedLength; i ++ ) { + + array[ i ] = paddingByte; + + } + + } + + return array.buffer; + + } + + return arrayBuffer; + + } + + /** + * Serializes a userData. + * + * @param {THREE.Object3D|THREE.Material} object + * @returns {Object} + */ + function serializeUserData( object ) { + + try { + + return JSON.parse( JSON.stringify( object.userData ) ); + + } catch ( error ) { + + console.warn( 'THREE.GLTFExporter: userData of \'' + object.name + '\' ' + + 'won\'t be serialized because of JSON.stringify error - ' + error.message ); + + return {}; + + } + + } + + /** + * Process a buffer to append to the default one. + * @param {ArrayBuffer} buffer + * @return {Integer} + */ + function processBuffer( buffer ) { + + if ( ! outputJSON.buffers ) { + + outputJSON.buffers = [ { byteLength: 0 } ]; + + } + + // All buffers are merged before export. + buffers.push( buffer ); + + return 0; + + } + + /** + * Process and generate a BufferView + * @param {THREE.BufferAttribute} attribute + * @param {number} componentType + * @param {number} start + * @param {number} count + * @param {number} target (Optional) Target usage of the BufferView + * @return {Object} + */ + function processBufferView( attribute, componentType, start, count, target ) { + + if ( ! outputJSON.bufferViews ) { + + outputJSON.bufferViews = []; + + } + + // Create a new dataview and dump the attribute's array into it + + var componentSize; + + if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) { + + componentSize = 1; + + } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) { + + componentSize = 2; + + } else { + + componentSize = 4; + + } + + var byteLength = getPaddedBufferSize( count * attribute.itemSize * componentSize ); + var dataView = new DataView( new ArrayBuffer( byteLength ) ); + var offset = 0; + + for ( var i = start; i < start + count; i ++ ) { + + for ( var a = 0; a < attribute.itemSize; a ++ ) { + + // @TODO Fails on InterleavedBufferAttribute, and could probably be + // optimized for normal BufferAttribute. + var value = attribute.array[ i * attribute.itemSize + a ]; + + if ( componentType === WEBGL_CONSTANTS.FLOAT ) { + + dataView.setFloat32( offset, value, true ); + + } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_INT ) { + + dataView.setUint32( offset, value, true ); + + } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) { + + dataView.setUint16( offset, value, true ); + + } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) { + + dataView.setUint8( offset, value ); + + } + + offset += componentSize; + + } + + } + + var gltfBufferView = { + + buffer: processBuffer( dataView.buffer ), + byteOffset: byteOffset, + byteLength: byteLength + + }; + + if ( target !== undefined ) gltfBufferView.target = target; + + if ( target === WEBGL_CONSTANTS.ARRAY_BUFFER ) { + + // Only define byteStride for vertex attributes. + gltfBufferView.byteStride = attribute.itemSize * componentSize; + + } + + byteOffset += byteLength; + + outputJSON.bufferViews.push( gltfBufferView ); + + // @TODO Merge bufferViews where possible. + var output = { + + id: outputJSON.bufferViews.length - 1, + byteLength: 0 + + }; + + return output; + + } + + /** + * Process and generate a BufferView from an image Blob. + * @param {Blob} blob + * @return {Promise} + */ + function processBufferViewImage( blob ) { + + if ( ! outputJSON.bufferViews ) { + + outputJSON.bufferViews = []; + + } + + return new Promise( function ( resolve ) { + + var reader = new window.FileReader(); + reader.readAsArrayBuffer( blob ); + reader.onloadend = function () { + + var buffer = getPaddedArrayBuffer( reader.result ); + + var bufferView = { + buffer: processBuffer( buffer ), + byteOffset: byteOffset, + byteLength: buffer.byteLength + }; + + byteOffset += buffer.byteLength; + + outputJSON.bufferViews.push( bufferView ); + + resolve( outputJSON.bufferViews.length - 1 ); + + }; + + } ); + + } + + /** + * Process attribute to generate an accessor + * @param {THREE.BufferAttribute} attribute Attribute to process + * @param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range + * @param {Integer} start (Optional) + * @param {Integer} count (Optional) + * @return {Integer} Index of the processed accessor on the "accessors" array + */ + function processAccessor( attribute, geometry, start, count ) { + + var types = { + + 1: 'SCALAR', + 2: 'VEC2', + 3: 'VEC3', + 4: 'VEC4', + 16: 'MAT4' + + }; + + var componentType; + + // Detect the component type of the attribute array (float, uint or ushort) + if ( attribute.array.constructor === Float32Array ) { + + componentType = WEBGL_CONSTANTS.FLOAT; + + } else if ( attribute.array.constructor === Uint32Array ) { + + componentType = WEBGL_CONSTANTS.UNSIGNED_INT; + + } else if ( attribute.array.constructor === Uint16Array ) { + + componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT; + + } else if ( attribute.array.constructor === Uint8Array ) { + + componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE; + + } else { + + throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type.' ); + + } + + if ( start === undefined ) start = 0; + if ( count === undefined ) count = attribute.count; + + // @TODO Indexed buffer geometry with drawRange not supported yet + if ( options.truncateDrawRange && geometry !== undefined && geometry.index === null ) { + + var end = start + count; + var end2 = geometry.drawRange.count === Infinity + ? attribute.count + : geometry.drawRange.start + geometry.drawRange.count; + + start = Math.max( start, geometry.drawRange.start ); + count = Math.min( end, end2 ) - start; + + if ( count < 0 ) count = 0; + + } + + // Skip creating an accessor if the attribute doesn't have data to export + if ( count === 0 ) { + + return null; + + } + + var minMax = getMinMax( attribute, start, count ); + + var bufferViewTarget; + + // If geometry isn't provided, don't infer the target usage of the bufferView. For + // animation samplers, target must not be set. + if ( geometry !== undefined ) { + + bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS.ARRAY_BUFFER; + + } + + var bufferView = processBufferView( attribute, componentType, start, count, bufferViewTarget ); + + var gltfAccessor = { + + bufferView: bufferView.id, + byteOffset: bufferView.byteOffset, + componentType: componentType, + count: count, + max: minMax.max, + min: minMax.min, + type: types[ attribute.itemSize ] + + }; + + if ( ! outputJSON.accessors ) { + + outputJSON.accessors = []; + + } + + outputJSON.accessors.push( gltfAccessor ); + + return outputJSON.accessors.length - 1; + + } + + /** + * Process image + * @param {Image} image to process + * @param {Integer} format of the image (e.g. THREE.RGBFormat, THREE.RGBAFormat etc) + * @param {Boolean} flipY before writing out the image + * @return {Integer} Index of the processed texture in the "images" array + */ + function processImage( image, format, flipY ) { + + if ( ! cachedData.images.has( image ) ) { + + cachedData.images.set( image, {} ); + + } + + var cachedImages = cachedData.images.get( image ); + var mimeType = format === THREE.RGBAFormat ? 'image/png' : 'image/jpeg'; + var key = mimeType + ":flipY/" + flipY.toString(); + + if ( cachedImages[ key ] !== undefined ) { + + return cachedImages[ key ]; + + } + + if ( ! outputJSON.images ) { + + outputJSON.images = []; + + } + + var gltfImage = { mimeType: mimeType }; + + if ( options.embedImages ) { + + var canvas = cachedCanvas = cachedCanvas || document.createElement( 'canvas' ); + + canvas.width = image.width; + canvas.height = image.height; + + if ( options.forcePowerOfTwoTextures && ! isPowerOfTwo( image ) ) { + + console.warn( 'GLTFExporter: Resized non-power-of-two image.', image ); + + canvas.width = THREE.Math.floorPowerOfTwo( canvas.width ); + canvas.height = THREE.Math.floorPowerOfTwo( canvas.height ); + + } + + var ctx = canvas.getContext( '2d' ); + + if ( flipY === true ) { + + ctx.translate( 0, canvas.height ); + ctx.scale( 1, - 1 ); + + } + + ctx.drawImage( image, 0, 0, canvas.width, canvas.height ); + + if ( options.binary === true ) { + + pending.push( new Promise( function ( resolve ) { + + canvas.toBlob( function ( blob ) { + + processBufferViewImage( blob ).then( function ( bufferViewIndex ) { + + gltfImage.bufferView = bufferViewIndex; + + resolve(); + + } ); + + }, mimeType ); + + } ) ); + + } else { + + gltfImage.uri = canvas.toDataURL( mimeType ); + + } + + } else { + + gltfImage.uri = image.src; + + } + + outputJSON.images.push( gltfImage ); + + var index = outputJSON.images.length - 1; + cachedImages[ key ] = index; + + return index; + + } + + /** + * Process sampler + * @param {Texture} map Texture to process + * @return {Integer} Index of the processed texture in the "samplers" array + */ + function processSampler( map ) { + + if ( ! outputJSON.samplers ) { + + outputJSON.samplers = []; + + } + + var gltfSampler = { + + magFilter: THREE_TO_WEBGL[ map.magFilter ], + minFilter: THREE_TO_WEBGL[ map.minFilter ], + wrapS: THREE_TO_WEBGL[ map.wrapS ], + wrapT: THREE_TO_WEBGL[ map.wrapT ] + + }; + + outputJSON.samplers.push( gltfSampler ); + + return outputJSON.samplers.length - 1; + + } + + /** + * Process texture + * @param {Texture} map Map to process + * @return {Integer} Index of the processed texture in the "textures" array + */ + function processTexture( map ) { + + if ( cachedData.textures.has( map ) ) { + + return cachedData.textures.get( map ); + + } + + if ( ! outputJSON.textures ) { + + outputJSON.textures = []; + + } + + var gltfTexture = { + + sampler: processSampler( map ), + source: processImage( map.image, map.format, map.flipY ) + + }; + + outputJSON.textures.push( gltfTexture ); + + var index = outputJSON.textures.length - 1; + cachedData.textures.set( map, index ); + + return index; + + } + + /** + * Process material + * @param {THREE.Material} material Material to process + * @return {Integer} Index of the processed material in the "materials" array + */ + function processMaterial( material ) { + + if ( cachedData.materials.has( material ) ) { + + return cachedData.materials.get( material ); + + } + + if ( ! outputJSON.materials ) { + + outputJSON.materials = []; + + } + + if ( material.isShaderMaterial ) { + + console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' ); + return null; + + } + + // @QUESTION Should we avoid including any attribute that has the default value? + var gltfMaterial = { + + pbrMetallicRoughness: {} + + }; + + if ( material.isMeshBasicMaterial ) { + + gltfMaterial.extensions = { KHR_materials_unlit: {} }; + + extensionsUsed[ 'KHR_materials_unlit' ] = true; + + } else if ( ! material.isMeshStandardMaterial ) { + + console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' ); + + } + + // pbrMetallicRoughness.baseColorFactor + var color = material.color.toArray().concat( [ material.opacity ] ); + + if ( ! equalArray( color, [ 1, 1, 1, 1 ] ) ) { + + gltfMaterial.pbrMetallicRoughness.baseColorFactor = color; + + } + + if ( material.isMeshStandardMaterial ) { + + gltfMaterial.pbrMetallicRoughness.metallicFactor = material.metalness; + gltfMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness; + + } else if ( material.isMeshBasicMaterial ) { + + gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.0; + gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.9; + + } else { + + gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.5; + gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.5; + + } + + // pbrMetallicRoughness.metallicRoughnessTexture + if ( material.metalnessMap || material.roughnessMap ) { + + if ( material.metalnessMap === material.roughnessMap ) { + + gltfMaterial.pbrMetallicRoughness.metallicRoughnessTexture = { + + index: processTexture( material.metalnessMap ) + + }; + + } else { + + console.warn( 'THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.' ); + + } + + } + + // pbrMetallicRoughness.baseColorTexture + if ( material.map ) { + + gltfMaterial.pbrMetallicRoughness.baseColorTexture = { + + index: processTexture( material.map ) + + }; + + } + + if ( material.isMeshBasicMaterial || + material.isLineBasicMaterial || + material.isPointsMaterial ) { + + } else { + + // emissiveFactor + var emissive = material.emissive.clone().multiplyScalar( material.emissiveIntensity ).toArray(); + + if ( ! equalArray( emissive, [ 0, 0, 0 ] ) ) { + + gltfMaterial.emissiveFactor = emissive; + + } + + // emissiveTexture + if ( material.emissiveMap ) { + + gltfMaterial.emissiveTexture = { + + index: processTexture( material.emissiveMap ) + + }; + + } + + } + + // normalTexture + if ( material.normalMap ) { + + gltfMaterial.normalTexture = { + + index: processTexture( material.normalMap ) + + }; + + if ( material.normalScale.x !== - 1 ) { + + if ( material.normalScale.x !== material.normalScale.y ) { + + console.warn( 'THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X.' ); + + } + + gltfMaterial.normalTexture.scale = material.normalScale.x; + + } + + } + + // occlusionTexture + if ( material.aoMap ) { + + gltfMaterial.occlusionTexture = { + + index: processTexture( material.aoMap ) + + }; + + if ( material.aoMapIntensity !== 1.0 ) { + + gltfMaterial.occlusionTexture.strength = material.aoMapIntensity; + + } + + } + + // alphaMode + if ( material.transparent || material.alphaTest > 0.0 ) { + + gltfMaterial.alphaMode = material.opacity < 1.0 ? 'BLEND' : 'MASK'; + + // Write alphaCutoff if it's non-zero and different from the default (0.5). + if ( material.alphaTest > 0.0 && material.alphaTest !== 0.5 ) { + + gltfMaterial.alphaCutoff = material.alphaTest; + + } + + } + + // doubleSided + if ( material.side === THREE.DoubleSide ) { + + gltfMaterial.doubleSided = true; + + } + + if ( material.name !== '' ) { + + gltfMaterial.name = material.name; + + } + + if ( Object.keys( material.userData ).length > 0 ) { + + gltfMaterial.extras = serializeUserData( material ); + + } + + outputJSON.materials.push( gltfMaterial ); + + var index = outputJSON.materials.length - 1; + cachedData.materials.set( material, index ); + + return index; + + } + + /** + * Process mesh + * @param {THREE.Mesh} mesh Mesh to process + * @return {Integer} Index of the processed mesh in the "meshes" array + */ + function processMesh( mesh ) { + + var geometry = mesh.geometry; + + var mode; + + // Use the correct mode + if ( mesh.isLineSegments ) { + + mode = WEBGL_CONSTANTS.LINES; + + } else if ( mesh.isLineLoop ) { + + mode = WEBGL_CONSTANTS.LINE_LOOP; + + } else if ( mesh.isLine ) { + + mode = WEBGL_CONSTANTS.LINE_STRIP; + + } else if ( mesh.isPoints ) { + + mode = WEBGL_CONSTANTS.POINTS; + + } else { + + if ( ! geometry.isBufferGeometry ) { + + var geometryTemp = new THREE.BufferGeometry(); + geometryTemp.fromGeometry( geometry ); + geometry = geometryTemp; + + } + + if ( mesh.drawMode === THREE.TriangleFanDrawMode ) { + + console.warn( 'GLTFExporter: TriangleFanDrawMode and wireframe incompatible.' ); + mode = WEBGL_CONSTANTS.TRIANGLE_FAN; + + } else if ( mesh.drawMode === THREE.TriangleStripDrawMode ) { + + mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINE_STRIP : WEBGL_CONSTANTS.TRIANGLE_STRIP; + + } else { + + mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES; + + } + + } + + var gltfMesh = {}; + + var attributes = {}; + var primitives = []; + var targets = []; + + // Conversion between attributes names in threejs and gltf spec + var nameConversion = { + + uv: 'TEXCOORD_0', + uv2: 'TEXCOORD_1', + color: 'COLOR_0', + skinWeight: 'WEIGHTS_0', + skinIndex: 'JOINTS_0' + + }; + + var originalNormal = geometry.getAttribute( 'normal' ); + + if ( originalNormal !== undefined && ! isNormalizedNormalAttribute( originalNormal ) ) { + + console.warn( 'THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.' ); + + geometry.addAttribute( 'normal', createNormalizedNormalAttribute( originalNormal ) ); + + } + + // @QUESTION Detect if .vertexColors = THREE.VertexColors? + // For every attribute create an accessor + for ( var attributeName in geometry.attributes ) { + + var attribute = geometry.attributes[ attributeName ]; + attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase(); + + // JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT. + var array = attribute.array; + if ( attributeName === 'JOINTS_0' && + ! ( array instanceof Uint16Array ) && + ! ( array instanceof Uint8Array ) ) { + + console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' ); + attribute = new THREE.BufferAttribute( new Uint16Array( array ), attribute.itemSize, attribute.normalized ); + + } + + if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) { + + var accessor = processAccessor( attribute, geometry ); + if ( accessor !== null ) { + + attributes[ attributeName ] = accessor; + + } + + } + + } + + if ( originalNormal !== undefined ) geometry.addAttribute( 'normal', originalNormal ); + + // Skip if no exportable attributes found + if ( Object.keys( attributes ).length === 0 ) { + + return null; + + } + + // Morph targets + if ( mesh.morphTargetInfluences !== undefined && mesh.morphTargetInfluences.length > 0 ) { + + var weights = []; + var targetNames = []; + var reverseDictionary = {}; + + if ( mesh.morphTargetDictionary !== undefined ) { + + for ( var key in mesh.morphTargetDictionary ) { + + reverseDictionary[ mesh.morphTargetDictionary[ key ] ] = key; + + } + + } + + for ( var i = 0; i < mesh.morphTargetInfluences.length; ++ i ) { + + var target = {}; + + var warned = false; + + for ( var attributeName in geometry.morphAttributes ) { + + // glTF 2.0 morph supports only POSITION/NORMAL/TANGENT. + // Three.js doesn't support TANGENT yet. + + if ( attributeName !== 'position' && attributeName !== 'normal' ) { + + if ( ! warned ) { + + console.warn( 'GLTFExporter: Only POSITION and NORMAL morph are supported.' ); + warned = true; + + } + + continue; + + } + + var attribute = geometry.morphAttributes[ attributeName ][ i ]; + + // Three.js morph attribute has absolute values while the one of glTF has relative values. + // + // glTF 2.0 Specification: + // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets + + var baseAttribute = geometry.attributes[ attributeName ]; + // Clones attribute not to override + var relativeAttribute = attribute.clone(); + + for ( var j = 0, jl = attribute.count; j < jl; j ++ ) { + + relativeAttribute.setXYZ( + j, + attribute.getX( j ) - baseAttribute.getX( j ), + attribute.getY( j ) - baseAttribute.getY( j ), + attribute.getZ( j ) - baseAttribute.getZ( j ) + ); + + } + + target[ attributeName.toUpperCase() ] = processAccessor( relativeAttribute, geometry ); + + } + + targets.push( target ); + + weights.push( mesh.morphTargetInfluences[ i ] ); + if ( mesh.morphTargetDictionary !== undefined ) targetNames.push( reverseDictionary[ i ] ); + + } + + gltfMesh.weights = weights; + + if ( targetNames.length > 0 ) { + + gltfMesh.extras = {}; + gltfMesh.extras.targetNames = targetNames; + + } + + } + + var extras = ( Object.keys( geometry.userData ).length > 0 ) ? serializeUserData( geometry ) : undefined; + + var forceIndices = options.forceIndices; + var isMultiMaterial = Array.isArray( mesh.material ); + + if ( isMultiMaterial && geometry.groups.length === 0 ) return null; + + if ( ! forceIndices && geometry.index === null && isMultiMaterial ) { + + // temporal workaround. + console.warn( 'THREE.GLTFExporter: Creating index for non-indexed multi-material mesh.' ); + forceIndices = true; + + } + + var didForceIndices = false; + + if ( geometry.index === null && forceIndices ) { + + var indices = []; + + for ( var i = 0, il = geometry.attributes.position.count; i < il; i ++ ) { + + indices[ i ] = i; + + } + + geometry.setIndex( indices ); + + didForceIndices = true; + + } + + var materials = isMultiMaterial ? mesh.material : [ mesh.material ]; + var groups = isMultiMaterial ? geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ]; + + for ( var i = 0, il = groups.length; i < il; i ++ ) { + + var primitive = { + mode: mode, + attributes: attributes, + }; + + if ( extras ) primitive.extras = extras; + + if ( targets.length > 0 ) primitive.targets = targets; + + if ( geometry.index !== null ) { + + primitive.indices = processAccessor( geometry.index, geometry, groups[ i ].start, groups[ i ].count ); + + } + + var material = processMaterial( materials[ groups[ i ].materialIndex ] ); + + if ( material !== null ) { + + primitive.material = material; + + } + + primitives.push( primitive ); + + } + + if ( didForceIndices ) { + + geometry.setIndex( null ); + + } + + gltfMesh.primitives = primitives; + + if ( ! outputJSON.meshes ) { + + outputJSON.meshes = []; + + } + + outputJSON.meshes.push( gltfMesh ); + + return outputJSON.meshes.length - 1; + + } + + /** + * Process camera + * @param {THREE.Camera} camera Camera to process + * @return {Integer} Index of the processed mesh in the "camera" array + */ + function processCamera( camera ) { + + if ( ! outputJSON.cameras ) { + + outputJSON.cameras = []; + + } + + var isOrtho = camera.isOrthographicCamera; + + var gltfCamera = { + + type: isOrtho ? 'orthographic' : 'perspective' + + }; + + if ( isOrtho ) { + + gltfCamera.orthographic = { + + xmag: camera.right * 2, + ymag: camera.top * 2, + zfar: camera.far <= 0 ? 0.001 : camera.far, + znear: camera.near < 0 ? 0 : camera.near + + }; + + } else { + + gltfCamera.perspective = { + + aspectRatio: camera.aspect, + yfov: THREE.Math.degToRad( camera.fov ) / camera.aspect, + zfar: camera.far <= 0 ? 0.001 : camera.far, + znear: camera.near < 0 ? 0 : camera.near + + }; + + } + + if ( camera.name !== '' ) { + + gltfCamera.name = camera.type; + + } + + outputJSON.cameras.push( gltfCamera ); + + return outputJSON.cameras.length - 1; + + } + + /** + * Creates glTF animation entry from AnimationClip object. + * + * Status: + * - Only properties listed in PATH_PROPERTIES may be animated. + * + * @param {THREE.AnimationClip} clip + * @param {THREE.Object3D} root + * @return {number} + */ + function processAnimation( clip, root ) { + + if ( ! outputJSON.animations ) { + + outputJSON.animations = []; + + } + + var channels = []; + var samplers = []; + + for ( var i = 0; i < clip.tracks.length; ++ i ) { + + var track = clip.tracks[ i ]; + var trackBinding = THREE.PropertyBinding.parseTrackName( track.name ); + var trackNode = THREE.PropertyBinding.findNode( root, trackBinding.nodeName ); + var trackProperty = PATH_PROPERTIES[ trackBinding.propertyName ]; + + if ( trackBinding.objectName === 'bones' ) { + + if ( trackNode.isSkinnedMesh === true ) { + + trackNode = trackNode.skeleton.getBoneByName( trackBinding.objectIndex ); + + } else { + + trackNode = undefined; + + } + + } + + if ( ! trackNode || ! trackProperty ) { + + console.warn( 'THREE.GLTFExporter: Could not export animation track "%s".', track.name ); + return null; + + } + + var inputItemSize = 1; + var outputItemSize = track.values.length / track.times.length; + + if ( trackProperty === PATH_PROPERTIES.morphTargetInfluences ) { + + if ( trackNode.morphTargetInfluences.length !== 1 && + trackBinding.propertyIndex !== undefined ) { + + console.warn( 'THREE.GLTFExporter: Skipping animation track "%s". ' + + 'Morph target keyframe tracks must target all available morph targets ' + + 'for the given mesh.', track.name ); + continue; + + } + + outputItemSize /= trackNode.morphTargetInfluences.length; + + } + + var interpolation; + + // @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE + + // Detecting glTF cubic spline interpolant by checking factory method's special property + // GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return + // valid value from .getInterpolation(). + if ( track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true ) { + + interpolation = 'CUBICSPLINE'; + + // itemSize of CUBICSPLINE keyframe is 9 + // (VEC3 * 3: inTangent, splineVertex, and outTangent) + // but needs to be stored as VEC3 so dividing by 3 here. + outputItemSize /= 3; + + } else if ( track.getInterpolation() === THREE.InterpolateDiscrete ) { + + interpolation = 'STEP'; + + } else { + + interpolation = 'LINEAR'; + + } + + samplers.push( { + + input: processAccessor( new THREE.BufferAttribute( track.times, inputItemSize ) ), + output: processAccessor( new THREE.BufferAttribute( track.values, outputItemSize ) ), + interpolation: interpolation + + } ); + + channels.push( { + + sampler: samplers.length - 1, + target: { + node: nodeMap.get( trackNode ), + path: trackProperty + } + + } ); + + } + + outputJSON.animations.push( { + + name: clip.name || 'clip_' + outputJSON.animations.length, + samplers: samplers, + channels: channels + + } ); + + return outputJSON.animations.length - 1; + + } + + function processSkin( object ) { + + var node = outputJSON.nodes[ nodeMap.get( object ) ]; + + var skeleton = object.skeleton; + var rootJoint = object.skeleton.bones[ 0 ]; + + if ( rootJoint === undefined ) return null; + + var joints = []; + var inverseBindMatrices = new Float32Array( skeleton.bones.length * 16 ); + + for ( var i = 0; i < skeleton.bones.length; ++ i ) { + + joints.push( nodeMap.get( skeleton.bones[ i ] ) ); + + skeleton.boneInverses[ i ].toArray( inverseBindMatrices, i * 16 ); + + } + + if ( outputJSON.skins === undefined ) { + + outputJSON.skins = []; + + } + + outputJSON.skins.push( { + + inverseBindMatrices: processAccessor( new THREE.BufferAttribute( inverseBindMatrices, 16 ) ), + joints: joints, + skeleton: nodeMap.get( rootJoint ) + + } ); + + var skinIndex = node.skin = outputJSON.skins.length - 1; + + return skinIndex; + + } + + /** + * Process Object3D node + * @param {THREE.Object3D} node Object3D to processNode + * @return {Integer} Index of the node in the nodes list + */ + function processNode( object ) { + + if ( object.isLight ) { + + console.warn( 'GLTFExporter: Unsupported node type:', object.constructor.name ); + return null; + + } + + if ( ! outputJSON.nodes ) { + + outputJSON.nodes = []; + + } + + var gltfNode = {}; + + if ( options.trs ) { + + var rotation = object.quaternion.toArray(); + var position = object.position.toArray(); + var scale = object.scale.toArray(); + + if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) { + + gltfNode.rotation = rotation; + + } + + if ( ! equalArray( position, [ 0, 0, 0 ] ) ) { + + gltfNode.translation = position; + + } + + if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) { + + gltfNode.scale = scale; + + } + + } else { + + object.updateMatrix(); + if ( ! equalArray( object.matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) ) { + + gltfNode.matrix = object.matrix.elements; + + } + + } + + // We don't export empty strings name because it represents no-name in Three.js. + if ( object.name !== '' ) { + + gltfNode.name = String( object.name ); + + } + + if ( object.userData && Object.keys( object.userData ).length > 0 ) { + + gltfNode.extras = serializeUserData( object ); + + } + + if ( object.isMesh || object.isLine || object.isPoints ) { + + var mesh = processMesh( object ); + + if ( mesh !== null ) { + + gltfNode.mesh = mesh; + + } + + } else if ( object.isCamera ) { + + gltfNode.camera = processCamera( object ); + + } + + if ( object.isSkinnedMesh ) { + + skins.push( object ); + + } + + if ( object.children.length > 0 ) { + + var children = []; + + for ( var i = 0, l = object.children.length; i < l; i ++ ) { + + var child = object.children[ i ]; + + if ( child.visible || options.onlyVisible === false ) { + + var node = processNode( child ); + + if ( node !== null ) { + + children.push( node ); + + } + + } + + } + + if ( children.length > 0 ) { + + gltfNode.children = children; + + } + + + } + + outputJSON.nodes.push( gltfNode ); + + var nodeIndex = outputJSON.nodes.length - 1; + nodeMap.set( object, nodeIndex ); + + return nodeIndex; + + } + + /** + * Process Scene + * @param {THREE.Scene} node Scene to process + */ + function processScene( scene ) { + + if ( ! outputJSON.scenes ) { + + outputJSON.scenes = []; + outputJSON.scene = 0; + + } + + var gltfScene = { + + nodes: [] + + }; + + if ( scene.name !== '' ) { + + gltfScene.name = scene.name; + + } + + outputJSON.scenes.push( gltfScene ); + + var nodes = []; + + for ( var i = 0, l = scene.children.length; i < l; i ++ ) { + + var child = scene.children[ i ]; + + if ( child.visible || options.onlyVisible === false ) { + + var node = processNode( child ); + + if ( node !== null ) { + + nodes.push( node ); + + } + + } + + } + + if ( nodes.length > 0 ) { + + gltfScene.nodes = nodes; + + } + + } + + /** + * Creates a THREE.Scene to hold a list of objects and parse it + * @param {Array} objects List of objects to process + */ + function processObjects( objects ) { + + var scene = new THREE.Scene(); + scene.name = 'AuxScene'; + + for ( var i = 0; i < objects.length; i ++ ) { + + // We push directly to children instead of calling `add` to prevent + // modify the .parent and break its original scene and hierarchy + scene.children.push( objects[ i ] ); + + } + + processScene( scene ); + + } + + function processInput( input ) { + + input = input instanceof Array ? input : [ input ]; + + var objectsWithoutScene = []; + + for ( var i = 0; i < input.length; i ++ ) { + + if ( input[ i ] instanceof THREE.Scene ) { + + processScene( input[ i ] ); + + } else { + + objectsWithoutScene.push( input[ i ] ); + + } + + } + + if ( objectsWithoutScene.length > 0 ) { + + processObjects( objectsWithoutScene ); + + } + + for ( var i = 0; i < skins.length; ++ i ) { + + processSkin( skins[ i ] ); + + } + + for ( var i = 0; i < options.animations.length; ++ i ) { + + processAnimation( options.animations[ i ], input[ 0 ] ); + + } + + } + + processInput( input ); + + Promise.all( pending ).then( function () { + + // Merge buffers. + var blob = new Blob( buffers, { type: 'application/octet-stream' } ); + + // Declare extensions. + var extensionsUsedList = Object.keys( extensionsUsed ); + if ( extensionsUsedList.length > 0 ) outputJSON.extensionsUsed = extensionsUsedList; + + if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) { + + // Update bytelength of the single buffer. + outputJSON.buffers[ 0 ].byteLength = blob.size; + + var reader = new window.FileReader(); + + if ( options.binary === true ) { + + // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification + + var GLB_HEADER_BYTES = 12; + var GLB_HEADER_MAGIC = 0x46546C67; + var GLB_VERSION = 2; + + var GLB_CHUNK_PREFIX_BYTES = 8; + var GLB_CHUNK_TYPE_JSON = 0x4E4F534A; + var GLB_CHUNK_TYPE_BIN = 0x004E4942; + + reader.readAsArrayBuffer( blob ); + reader.onloadend = function () { + + // Binary chunk. + var binaryChunk = getPaddedArrayBuffer( reader.result ); + var binaryChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) ); + binaryChunkPrefix.setUint32( 0, binaryChunk.byteLength, true ); + binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true ); + + // JSON chunk. + var jsonChunk = getPaddedArrayBuffer( stringToArrayBuffer( JSON.stringify( outputJSON ) ), 0x20 ); + var jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) ); + jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true ); + jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true ); + + // GLB header. + var header = new ArrayBuffer( GLB_HEADER_BYTES ); + var headerView = new DataView( header ); + headerView.setUint32( 0, GLB_HEADER_MAGIC, true ); + headerView.setUint32( 4, GLB_VERSION, true ); + var totalByteLength = GLB_HEADER_BYTES + + jsonChunkPrefix.byteLength + jsonChunk.byteLength + + binaryChunkPrefix.byteLength + binaryChunk.byteLength; + headerView.setUint32( 8, totalByteLength, true ); + + var glbBlob = new Blob( [ + header, + jsonChunkPrefix, + jsonChunk, + binaryChunkPrefix, + binaryChunk + ], { type: 'application/octet-stream' } ); + + var glbReader = new window.FileReader(); + glbReader.readAsArrayBuffer( glbBlob ); + glbReader.onloadend = function () { + + onDone( glbReader.result ); + + }; + + }; + + } else { + + reader.readAsDataURL( blob ); + reader.onloadend = function () { + + var base64data = reader.result; + outputJSON.buffers[ 0 ].uri = base64data; + onDone( outputJSON ); + + }; + + } + + } else { + + onDone( outputJSON ); + + } + + } ); + + } + +}; diff --git a/three/jsutil/exporters/MMDExporter.js b/three/jsutil/exporters/MMDExporter.js new file mode 100644 index 000000000..dfb4bf889 --- /dev/null +++ b/three/jsutil/exporters/MMDExporter.js @@ -0,0 +1,210 @@ +/** + * @author takahiro / http://github.com/takahirox + * + * Dependencies + * - mmd-parser https://github.com/takahirox/mmd-parser + */ + +THREE.MMDExporter = function () { + + // Unicode to Shift_JIS table + var u2sTable; + + function unicodeToShiftjis( str ) { + + if ( u2sTable === undefined ) { + + var encoder = new MMDParser.CharsetEncoder(); + var table = encoder.s2uTable; + u2sTable = {}; + + var keys = Object.keys( table ); + + for ( var i = 0, il = keys.length; i < il; i ++ ) { + + var key = keys[ i ]; + + var value = table[ key ]; + key = parseInt( key ); + + u2sTable[ value ] = key; + + } + + } + + var array = []; + + for ( var i = 0, il = str.length; i < il; i ++ ) { + + var code = str.charCodeAt( i ); + + var value = u2sTable[ code ]; + + if ( value === undefined ) { + + throw 'cannot convert charcode 0x' + code.toString( 16 ); + + } else if ( value > 0xff ) { + + array.push( ( value >> 8 ) & 0xff ); + array.push( value & 0xff ); + + } else { + + array.push( value & 0xff ); + + } + + } + + return new Uint8Array( array ); + + } + + function getBindBones( skin ) { + + // any more efficient ways? + var poseSkin = skin.clone(); + poseSkin.pose(); + return poseSkin.skeleton.bones; + + } + + /* TODO: implement + // mesh -> pmd + this.parsePmd = function ( object ) { + + }; + */ + + /* TODO: implement + // mesh -> pmx + this.parsePmx = function ( object ) { + + }; + */ + + /* + * skeleton -> vpd + * Returns Shift_JIS encoded Uint8Array. Otherwise return strings. + */ + this.parseVpd = function ( skin, outputShiftJis, useOriginalBones ) { + + if ( skin.isSkinnedMesh !== true ) { + + console.warn( 'THREE.MMDExporter: parseVpd() requires SkinnedMesh instance.' ); + return null; + + } + + function toStringsFromNumber( num ) { + + if ( Math.abs( num ) < 1e-6 ) num = 0; + + var a = num.toString(); + + if ( a.indexOf( '.' ) === - 1 ) { + + a += '.'; + + } + + a += '000000'; + + var index = a.indexOf( '.' ); + + var d = a.slice( 0, index ); + var p = a.slice( index + 1, index + 7 ); + + return d + '.' + p; + + } + + function toStringsFromArray( array ) { + + var a = []; + + for ( var i = 0, il = array.length; i < il; i ++ ) { + + a.push( toStringsFromNumber( array[ i ] ) ); + + } + + return a.join( ',' ); + + } + + skin.updateMatrixWorld( true ); + + var bones = skin.skeleton.bones; + var bones2 = getBindBones( skin ); + + var position = new THREE.Vector3(); + var quaternion = new THREE.Quaternion(); + var quaternion2 = new THREE.Quaternion(); + var matrix = new THREE.Matrix4(); + + var array = []; + array.push( 'Vocaloid Pose Data file' ); + array.push( '' ); + array.push( ( skin.name !== '' ? skin.name.replace( /\s/g, '_' ) : 'skin' ) + '.osm;' ); + array.push( bones.length + ';' ); + array.push( '' ); + + for ( var i = 0, il = bones.length; i < il; i ++ ) { + + var bone = bones[ i ]; + var bone2 = bones2[ i ]; + + /* + * use the bone matrix saved before solving IK. + * see CCDIKSolver for the detail. + */ + if ( useOriginalBones === true && + bone.userData.ik !== undefined && + bone.userData.ik.originalMatrix !== undefined ) { + + matrix.fromArray( bone.userData.ik.originalMatrix ); + + } else { + + matrix.copy( bone.matrix ); + + } + + position.setFromMatrixPosition( matrix ); + quaternion.setFromRotationMatrix( matrix ); + + var pArray = position.sub( bone2.position ).toArray(); + var qArray = quaternion2.copy( bone2.quaternion ).conjugate().multiply( quaternion ).toArray(); + + // right to left + pArray[ 2 ] = - pArray[ 2 ]; + qArray[ 0 ] = - qArray[ 0 ]; + qArray[ 1 ] = - qArray[ 1 ]; + + array.push( 'Bone' + i + '{' + bone.name ); + array.push( ' ' + toStringsFromArray( pArray ) + ';' ); + array.push( ' ' + toStringsFromArray( qArray ) + ';' ); + array.push( '}' ); + array.push( '' ); + + } + + array.push( '' ); + + var lines = array.join( '\n' ); + + return ( outputShiftJis === true ) ? unicodeToShiftjis( lines ) : lines; + + }; + + /* TODO: implement + // animation + skeleton -> vmd + this.parseVmd = function ( object ) { + + }; + */ + +}; diff --git a/three/jsutil/exporters/OBJExporter.js b/three/jsutil/exporters/OBJExporter.js new file mode 100644 index 000000000..77fc4595d --- /dev/null +++ b/three/jsutil/exporters/OBJExporter.js @@ -0,0 +1,262 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.OBJExporter = function () {}; + +THREE.OBJExporter.prototype = { + + constructor: THREE.OBJExporter, + + parse: function ( object ) { + + var output = ''; + + var indexVertex = 0; + var indexVertexUvs = 0; + var indexNormals = 0; + + var vertex = new THREE.Vector3(); + var normal = new THREE.Vector3(); + var uv = new THREE.Vector2(); + + var i, j, k, l, m, face = []; + + var parseMesh = function ( mesh ) { + + var nbVertex = 0; + var nbNormals = 0; + var nbVertexUvs = 0; + + var geometry = mesh.geometry; + + var normalMatrixWorld = new THREE.Matrix3(); + + if ( geometry instanceof THREE.Geometry ) { + + geometry = new THREE.BufferGeometry().setFromObject( mesh ); + + } + + if ( geometry instanceof THREE.BufferGeometry ) { + + // shortcuts + var vertices = geometry.getAttribute( 'position' ); + var normals = geometry.getAttribute( 'normal' ); + var uvs = geometry.getAttribute( 'uv' ); + var indices = geometry.getIndex(); + + // name of the mesh object + output += 'o ' + mesh.name + '\n'; + + // name of the mesh material + if ( mesh.material && mesh.material.name ) { + + output += 'usemtl ' + mesh.material.name + '\n'; + + } + + // vertices + + if ( vertices !== undefined ) { + + for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) { + + vertex.x = vertices.getX( i ); + vertex.y = vertices.getY( i ); + vertex.z = vertices.getZ( i ); + + // transfrom the vertex to world space + vertex.applyMatrix4( mesh.matrixWorld ); + + // transform the vertex to export format + output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n'; + + } + + } + + // uvs + + if ( uvs !== undefined ) { + + for ( i = 0, l = uvs.count; i < l; i ++, nbVertexUvs ++ ) { + + uv.x = uvs.getX( i ); + uv.y = uvs.getY( i ); + + // transform the uv to export format + output += 'vt ' + uv.x + ' ' + uv.y + '\n'; + + } + + } + + // normals + + if ( normals !== undefined ) { + + normalMatrixWorld.getNormalMatrix( mesh.matrixWorld ); + + for ( i = 0, l = normals.count; i < l; i ++, nbNormals ++ ) { + + normal.x = normals.getX( i ); + normal.y = normals.getY( i ); + normal.z = normals.getZ( i ); + + // transfrom the normal to world space + normal.applyMatrix3( normalMatrixWorld ); + + // transform the normal to export format + output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n'; + + } + + } + + // faces + + if ( indices !== null ) { + + for ( i = 0, l = indices.count; i < l; i += 3 ) { + + for ( m = 0; m < 3; m ++ ) { + + j = indices.getX( i + m ) + 1; + + face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' ); + + } + + // transform the face to export format + output += 'f ' + face.join( ' ' ) + "\n"; + + } + + } else { + + for ( i = 0, l = vertices.count; i < l; i += 3 ) { + + for ( m = 0; m < 3; m ++ ) { + + j = i + m + 1; + + face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' ); + + } + + // transform the face to export format + output += 'f ' + face.join( ' ' ) + "\n"; + + } + + } + + } else { + + console.warn( 'THREE.OBJExporter.parseMesh(): geometry type unsupported', geometry ); + + } + + // update index + indexVertex += nbVertex; + indexVertexUvs += nbVertexUvs; + indexNormals += nbNormals; + + }; + + var parseLine = function ( line ) { + + var nbVertex = 0; + + var geometry = line.geometry; + var type = line.type; + + if ( geometry instanceof THREE.Geometry ) { + + geometry = new THREE.BufferGeometry().setFromObject( line ); + + } + + if ( geometry instanceof THREE.BufferGeometry ) { + + // shortcuts + var vertices = geometry.getAttribute( 'position' ); + + // name of the line object + output += 'o ' + line.name + '\n'; + + if ( vertices !== undefined ) { + + for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) { + + vertex.x = vertices.getX( i ); + vertex.y = vertices.getY( i ); + vertex.z = vertices.getZ( i ); + + // transfrom the vertex to world space + vertex.applyMatrix4( line.matrixWorld ); + + // transform the vertex to export format + output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n'; + + } + + } + + if ( type === 'Line' ) { + + output += 'l '; + + for ( j = 1, l = vertices.count; j <= l; j ++ ) { + + output += ( indexVertex + j ) + ' '; + + } + + output += '\n'; + + } + + if ( type === 'LineSegments' ) { + + for ( j = 1, k = j + 1, l = vertices.count; j < l; j += 2, k = j + 1 ) { + + output += 'l ' + ( indexVertex + j ) + ' ' + ( indexVertex + k ) + '\n'; + + } + + } + + } else { + + console.warn( 'THREE.OBJExporter.parseLine(): geometry type unsupported', geometry ); + + } + + // update index + indexVertex += nbVertex; + + }; + + object.traverse( function ( child ) { + + if ( child instanceof THREE.Mesh ) { + + parseMesh( child ); + + } + + if ( child instanceof THREE.Line ) { + + parseLine( child ); + + } + + } ); + + return output; + + } + +}; diff --git a/three/jsutil/exporters/PLYExporter.js b/three/jsutil/exporters/PLYExporter.js new file mode 100644 index 000000000..45602189a --- /dev/null +++ b/three/jsutil/exporters/PLYExporter.js @@ -0,0 +1,549 @@ +/** + * @author Garrett Johnson / http://gkjohnson.github.io/ + * https://github.com/gkjohnson/ply-exporter-js + * + * Usage: + * var exporter = new THREE.PLYExporter(); + * + * // second argument is a list of options + * exporter.parse(mesh, data => console.log(data), { binary: true, excludeAttributes: [ 'color' ] }); + * + * Format Definition: + * http://paulbourke.net/dataformats/ply/ + */ + +THREE.PLYExporter = function () {}; + +THREE.PLYExporter.prototype = { + + constructor: THREE.PLYExporter, + + parse: function ( object, onDone, options ) { + + if ( onDone && typeof onDone === 'object' ) { + + console.warn( 'THREE.PLYExporter: The options parameter is now the third argument to the "parse" function. See the documentation for the new API.' ); + options = onDone; + onDone = undefined; + + } + + // Iterate over the valid meshes in the object + function traverseMeshes( cb ) { + + object.traverse( function ( child ) { + + if ( child.isMesh === true ) { + + var mesh = child; + var geometry = mesh.geometry; + + if ( geometry.isGeometry === true ) { + + geometry = geomToBufferGeom.get( geometry ); + + } + + if ( geometry.isBufferGeometry === true ) { + + if ( geometry.getAttribute( 'position' ) !== undefined ) { + + cb( mesh, geometry ); + + } + + } + + } + + } ); + + } + + // Default options + var defaultOptions = { + binary: false, + excludeAttributes: [] // normal, uv, color, index + }; + + options = Object.assign( defaultOptions, options ); + + var excludeAttributes = options.excludeAttributes; + var geomToBufferGeom = new WeakMap(); + var includeNormals = false; + var includeColors = false; + var includeUVs = false; + + // count the vertices, check which properties are used, + // and cache the BufferGeometry + var vertexCount = 0; + var faceCount = 0; + object.traverse( function ( child ) { + + if ( child.isMesh === true ) { + + var mesh = child; + var geometry = mesh.geometry; + + if ( geometry.isGeometry === true ) { + + var bufferGeometry = geomToBufferGeom.get( geometry ) || new THREE.BufferGeometry().setFromObject( mesh ); + geomToBufferGeom.set( geometry, bufferGeometry ); + geometry = bufferGeometry; + + } + + if ( geometry.isBufferGeometry === true ) { + + var vertices = geometry.getAttribute( 'position' ); + var normals = geometry.getAttribute( 'normal' ); + var uvs = geometry.getAttribute( 'uv' ); + var colors = geometry.getAttribute( 'color' ); + var indices = geometry.getIndex(); + + if ( vertices === undefined ) { + + return; + + } + + vertexCount += vertices.count; + faceCount += indices ? indices.count / 3 : vertices.count / 3; + + if ( normals !== undefined ) includeNormals = true; + + if ( uvs !== undefined ) includeUVs = true; + + if ( colors !== undefined ) includeColors = true; + + } + + } + + } ); + + var includeIndices = excludeAttributes.indexOf( 'index' ) === - 1; + includeNormals = includeNormals && excludeAttributes.indexOf( 'normal' ) === - 1; + includeColors = includeColors && excludeAttributes.indexOf( 'color' ) === - 1; + includeUVs = includeUVs && excludeAttributes.indexOf( 'uv' ) === - 1; + + + if ( includeIndices && faceCount !== Math.floor( faceCount ) ) { + + // point cloud meshes will not have an index array and may not have a + // number of vertices that is divisble by 3 (and therefore representable + // as triangles) + console.error( + + 'PLYExporter: Failed to generate a valid PLY file with triangle indices because the ' + + 'number of indices is not divisible by 3.' + + ); + + return null; + + } + + // get how many bytes will be needed to save out the faces + // so we can use a minimal amount of memory / data + var indexByteCount = 1; + + if ( vertexCount > 256 ) { // 2^8 bits + + indexByteCount = 2; + + } + + if ( vertexCount > 65536 ) { // 2^16 bits + + indexByteCount = 4; + + } + + + var header = + 'ply\n' + + `format ${ options.binary ? 'binary_big_endian' : 'ascii' } 1.0\n` + + `element vertex ${vertexCount}\n` + + + // position + 'property float x\n' + + 'property float y\n' + + 'property float z\n'; + + if ( includeNormals === true ) { + + // normal + header += + 'property float nx\n' + + 'property float ny\n' + + 'property float nz\n'; + + } + + if ( includeUVs === true ) { + + // uvs + header += + 'property float s\n' + + 'property float t\n'; + + } + + if ( includeColors === true ) { + + // colors + header += + 'property uchar red\n' + + 'property uchar green\n' + + 'property uchar blue\n'; + + } + + if ( includeIndices === true ) { + + // faces + header += + `element face ${faceCount}\n` + + `property list uchar uint${ indexByteCount * 8 } vertex_index\n`; + + } + + header += 'end_header\n'; + + + // Generate attribute data + var vertex = new THREE.Vector3(); + var normalMatrixWorld = new THREE.Matrix3(); + var result = null; + + if ( options.binary === true ) { + + // Binary File Generation + var headerBin = new TextEncoder().encode( header ); + + // 3 position values at 4 bytes + // 3 normal values at 4 bytes + // 3 color channels with 1 byte + // 2 uv values at 4 bytes + var vertexListLength = vertexCount * ( 4 * 3 + ( includeNormals ? 4 * 3 : 0 ) + ( includeColors ? 3 : 0 ) + ( includeUVs ? 4 * 2 : 0 ) ); + + // 1 byte shape desciptor + // 3 vertex indices at ${indexByteCount} bytes + var faceListLength = includeIndices ? faceCount * ( indexByteCount * 3 + 1 ) : 0; + var output = new DataView( new ArrayBuffer( headerBin.length + vertexListLength + faceListLength ) ); + new Uint8Array( output.buffer ).set( headerBin, 0 ); + + + var vOffset = headerBin.length; + var fOffset = headerBin.length + vertexListLength; + var writtenVertices = 0; + traverseMeshes( function ( mesh, geometry ) { + + var vertices = geometry.getAttribute( 'position' ); + var normals = geometry.getAttribute( 'normal' ); + var uvs = geometry.getAttribute( 'uv' ); + var colors = geometry.getAttribute( 'color' ); + var indices = geometry.getIndex(); + + normalMatrixWorld.getNormalMatrix( mesh.matrixWorld ); + + for ( var i = 0, l = vertices.count; i < l; i ++ ) { + + vertex.x = vertices.getX( i ); + vertex.y = vertices.getY( i ); + vertex.z = vertices.getZ( i ); + + vertex.applyMatrix4( mesh.matrixWorld ); + + + // Position information + output.setFloat32( vOffset, vertex.x ); + vOffset += 4; + + output.setFloat32( vOffset, vertex.y ); + vOffset += 4; + + output.setFloat32( vOffset, vertex.z ); + vOffset += 4; + + // Normal information + if ( includeNormals === true ) { + + if ( normals != null ) { + + vertex.x = normals.getX( i ); + vertex.y = normals.getY( i ); + vertex.z = normals.getZ( i ); + + vertex.applyMatrix3( normalMatrixWorld ); + + output.setFloat32( vOffset, vertex.x ); + vOffset += 4; + + output.setFloat32( vOffset, vertex.y ); + vOffset += 4; + + output.setFloat32( vOffset, vertex.z ); + vOffset += 4; + + } else { + + output.setFloat32( vOffset, 0 ); + vOffset += 4; + + output.setFloat32( vOffset, 0 ); + vOffset += 4; + + output.setFloat32( vOffset, 0 ); + vOffset += 4; + + } + + } + + // UV information + if ( includeUVs === true ) { + + if ( uvs != null ) { + + output.setFloat32( vOffset, uvs.getX( i ) ); + vOffset += 4; + + output.setFloat32( vOffset, uvs.getY( i ) ); + vOffset += 4; + + } else if ( includeUVs !== false ) { + + output.setFloat32( vOffset, 0 ); + vOffset += 4; + + output.setFloat32( vOffset, 0 ); + vOffset += 4; + + } + + } + + // Color information + if ( includeColors === true ) { + + if ( colors != null ) { + + output.setUint8( vOffset, Math.floor( colors.getX( i ) * 255 ) ); + vOffset += 1; + + output.setUint8( vOffset, Math.floor( colors.getY( i ) * 255 ) ); + vOffset += 1; + + output.setUint8( vOffset, Math.floor( colors.getZ( i ) * 255 ) ); + vOffset += 1; + + } else { + + output.setUint8( vOffset, 255 ); + vOffset += 1; + + output.setUint8( vOffset, 255 ); + vOffset += 1; + + output.setUint8( vOffset, 255 ); + vOffset += 1; + + } + + } + + } + + if ( includeIndices === true ) { + + // Create the face list + var faceIndexFunc = `setUint${indexByteCount * 8}`; + if ( indices !== null ) { + + for ( var i = 0, l = indices.count; i < l; i += 3 ) { + + output.setUint8( fOffset, 3 ); + fOffset += 1; + + output[ faceIndexFunc ]( fOffset, indices.getX( i + 0 ) + writtenVertices ); + fOffset += indexByteCount; + + output[ faceIndexFunc ]( fOffset, indices.getX( i + 1 ) + writtenVertices ); + fOffset += indexByteCount; + + output[ faceIndexFunc ]( fOffset, indices.getX( i + 2 ) + writtenVertices ); + fOffset += indexByteCount; + + } + + } else { + + for ( var i = 0, l = vertices.count; i < l; i += 3 ) { + + output.setUint8( fOffset, 3 ); + fOffset += 1; + + output[ faceIndexFunc ]( fOffset, writtenVertices + i ); + fOffset += indexByteCount; + + output[ faceIndexFunc ]( fOffset, writtenVertices + i + 1 ); + fOffset += indexByteCount; + + output[ faceIndexFunc ]( fOffset, writtenVertices + i + 2 ); + fOffset += indexByteCount; + + } + + } + + } + + + // Save the amount of verts we've already written so we can offset + // the face index on the next mesh + writtenVertices += vertices.count; + + } ); + + result = output.buffer; + + } else { + + // Ascii File Generation + // count the number of vertices + var writtenVertices = 0; + var vertexList = ''; + var faceList = ''; + + traverseMeshes( function ( mesh, geometry ) { + + var vertices = geometry.getAttribute( 'position' ); + var normals = geometry.getAttribute( 'normal' ); + var uvs = geometry.getAttribute( 'uv' ); + var colors = geometry.getAttribute( 'color' ); + var indices = geometry.getIndex(); + + normalMatrixWorld.getNormalMatrix( mesh.matrixWorld ); + + // form each line + for ( var i = 0, l = vertices.count; i < l; i ++ ) { + + vertex.x = vertices.getX( i ); + vertex.y = vertices.getY( i ); + vertex.z = vertices.getZ( i ); + + vertex.applyMatrix4( mesh.matrixWorld ); + + + // Position information + var line = + vertex.x + ' ' + + vertex.y + ' ' + + vertex.z; + + // Normal information + if ( includeNormals === true ) { + + if ( normals != null ) { + + vertex.x = normals.getX( i ); + vertex.y = normals.getY( i ); + vertex.z = normals.getZ( i ); + + vertex.applyMatrix3( normalMatrixWorld ); + + line += ' ' + + vertex.x + ' ' + + vertex.y + ' ' + + vertex.z; + + } else { + + line += ' 0 0 0'; + + } + + } + + // UV information + if ( includeUVs === true ) { + + if ( uvs != null ) { + + line += ' ' + + uvs.getX( i ) + ' ' + + uvs.getY( i ); + + } else if ( includeUVs !== false ) { + + line += ' 0 0'; + + } + + } + + // Color information + if ( includeColors === true ) { + + if ( colors != null ) { + + line += ' ' + + Math.floor( colors.getX( i ) * 255 ) + ' ' + + Math.floor( colors.getY( i ) * 255 ) + ' ' + + Math.floor( colors.getZ( i ) * 255 ); + + } else { + + line += ' 255 255 255'; + + } + + } + + vertexList += line + '\n'; + + } + + // Create the face list + if ( includeIndices === true ) { + + if ( indices !== null ) { + + for ( var i = 0, l = indices.count; i < l; i += 3 ) { + + faceList += `3 ${ indices.getX( i + 0 ) + writtenVertices }`; + faceList += ` ${ indices.getX( i + 1 ) + writtenVertices }`; + faceList += ` ${ indices.getX( i + 2 ) + writtenVertices }\n`; + + } + + } else { + + for ( var i = 0, l = vertices.count; i < l; i += 3 ) { + + faceList += `3 ${ writtenVertices + i } ${ writtenVertices + i + 1 } ${ writtenVertices + i + 2 }\n`; + + } + + } + + faceCount += indices ? indices.count / 3 : vertices.count / 3; + + } + + writtenVertices += vertices.count; + + } ); + + result = `${ header }${vertexList}\n${ includeIndices ? `${faceList}\n` : '' }`; + + } + + if ( typeof onDone === 'function' ) requestAnimationFrame( () => onDone( result ) ); + return result; + + } + +}; diff --git a/three/jsutil/exporters/STLExporter.js b/three/jsutil/exporters/STLExporter.js new file mode 100644 index 000000000..5c1ddc1ad --- /dev/null +++ b/three/jsutil/exporters/STLExporter.js @@ -0,0 +1,166 @@ +/** + * @author kovacsv / http://kovacsv.hu/ + * @author mrdoob / http://mrdoob.com/ + * @author mudcube / http://mudcu.be/ + * @author Mugen87 / https://github.com/Mugen87 + * + * Usage: + * var exporter = new THREE.STLExporter(); + * + * // second argument is a list of options + * var data = exporter.parse( mesh, { binary: true } ); + * + */ + +THREE.STLExporter = function () {}; + +THREE.STLExporter.prototype = { + + constructor: THREE.STLExporter, + + parse: ( function () { + + var vector = new THREE.Vector3(); + var normalMatrixWorld = new THREE.Matrix3(); + + return function parse( scene, options ) { + + if ( options === undefined ) options = {}; + + var binary = options.binary !== undefined ? options.binary : false; + + // + + var objects = []; + var triangles = 0; + + scene.traverse( function ( object ) { + + if ( object.isMesh ) { + + var geometry = object.geometry; + + if ( geometry.isBufferGeometry ) { + + geometry = new THREE.Geometry().fromBufferGeometry( geometry ); + + } + + if ( geometry.isGeometry ) { + + triangles += geometry.faces.length; + + objects.push( { + + geometry: geometry, + matrixWorld: object.matrixWorld + + } ); + + } + + } + + } ); + + if ( binary ) { + + var offset = 80; // skip header + var bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4; + var arrayBuffer = new ArrayBuffer( bufferLength ); + var output = new DataView( arrayBuffer ); + output.setUint32( offset, triangles, true ); offset += 4; + + for ( var i = 0, il = objects.length; i < il; i ++ ) { + + var object = objects[ i ]; + + var vertices = object.geometry.vertices; + var faces = object.geometry.faces; + var matrixWorld = object.matrixWorld; + + normalMatrixWorld.getNormalMatrix( matrixWorld ); + + for ( var j = 0, jl = faces.length; j < jl; j ++ ) { + + var face = faces[ j ]; + + vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize(); + + output.setFloat32( offset, vector.x, true ); offset += 4; // normal + output.setFloat32( offset, vector.y, true ); offset += 4; + output.setFloat32( offset, vector.z, true ); offset += 4; + + var indices = [ face.a, face.b, face.c ]; + + for ( var k = 0; k < 3; k ++ ) { + + vector.copy( vertices[ indices[ k ] ] ).applyMatrix4( matrixWorld ); + + output.setFloat32( offset, vector.x, true ); offset += 4; // vertices + output.setFloat32( offset, vector.y, true ); offset += 4; + output.setFloat32( offset, vector.z, true ); offset += 4; + + } + + output.setUint16( offset, 0, true ); offset += 2; // attribute byte count + + } + + } + + return output; + + } else { + + var output = ''; + + output += 'solid exported\n'; + + for ( var i = 0, il = objects.length; i < il; i ++ ) { + + var object = objects[ i ]; + + var vertices = object.geometry.vertices; + var faces = object.geometry.faces; + var matrixWorld = object.matrixWorld; + + normalMatrixWorld.getNormalMatrix( matrixWorld ); + + for ( var j = 0, jl = faces.length; j < jl; j ++ ) { + + var face = faces[ j ]; + + vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize(); + + output += '\tfacet normal ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n'; + output += '\t\touter loop\n'; + + var indices = [ face.a, face.b, face.c ]; + + for ( var k = 0; k < 3; k ++ ) { + + vector.copy( vertices[ indices[ k ] ] ).applyMatrix4( matrixWorld ); + + output += '\t\t\tvertex ' + vector.x + ' ' + vector.y + ' ' + vector.z + '\n'; + + } + + output += '\t\tendloop\n'; + output += '\tendfacet\n'; + + } + + } + + output += 'endsolid exported\n'; + + return output; + + } + + }; + + }() ) + +}; diff --git a/three/jsutil/exporters/TypedGeometryExporter.js b/three/jsutil/exporters/TypedGeometryExporter.js new file mode 100644 index 000000000..dfaf587e5 --- /dev/null +++ b/three/jsutil/exporters/TypedGeometryExporter.js @@ -0,0 +1,55 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.TypedGeometryExporter = function () {}; + +THREE.TypedGeometryExporter.prototype = { + + constructor: THREE.TypedGeometryExporter, + + parse: function ( geometry ) { + + var output = { + metadata: { + version: 4.0, + type: 'TypedGeometry', + generator: 'TypedGeometryExporter' + } + }; + + var attributes = [ 'vertices', 'normals', 'uvs' ]; + + for ( var key in attributes ) { + + var attribute = attributes[ key ]; + + var typedArray = geometry[ attribute ]; + var array = []; + + for ( var i = 0, l = typedArray.length; i < l; i ++ ) { + + array[ i ] = typedArray[ i ]; + + } + + output[ attribute ] = array; + + } + + var boundingSphere = geometry.boundingSphere; + + if ( boundingSphere !== null ) { + + output.boundingSphere = { + center: boundingSphere.center.toArray(), + radius: boundingSphere.radius + }; + + } + + return output; + + } + +}; diff --git a/three/jsutil/geometries/BoxLineGeometry.js b/three/jsutil/geometries/BoxLineGeometry.js new file mode 100644 index 000000000..4c7ed5060 --- /dev/null +++ b/three/jsutil/geometries/BoxLineGeometry.js @@ -0,0 +1,67 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.BoxLineGeometry = function ( width, height, depth, widthSegments, heightSegments, depthSegments ) { + + THREE.BufferGeometry.call( this ); + + width = width || 1; + height = height || 1; + depth = depth || 1; + + widthSegments = Math.floor( widthSegments ) || 1; + heightSegments = Math.floor( heightSegments ) || 1; + depthSegments = Math.floor( depthSegments ) || 1; + + var widthHalf = width / 2; + var heightHalf = height / 2; + var depthHalf = depth / 2; + + var segmentWidth = width / widthSegments; + var segmentHeight = height / heightSegments; + var segmentDepth = depth / depthSegments; + + var vertices = []; + + var x = - widthHalf, y = - heightHalf, z = - depthHalf; + + for ( var i = 0; i <= widthSegments; i ++ ) { + + vertices.push( x, - heightHalf, - depthHalf, x, heightHalf, - depthHalf ); + vertices.push( x, heightHalf, - depthHalf, x, heightHalf, depthHalf ); + vertices.push( x, heightHalf, depthHalf, x, - heightHalf, depthHalf ); + vertices.push( x, - heightHalf, depthHalf, x, - heightHalf, - depthHalf ); + + x += segmentWidth; + + } + + for ( var i = 0; i <= heightSegments; i ++ ) { + + vertices.push( - widthHalf, y, - depthHalf, widthHalf, y, - depthHalf ); + vertices.push( widthHalf, y, - depthHalf, widthHalf, y, depthHalf ); + vertices.push( widthHalf, y, depthHalf, - widthHalf, y, depthHalf ); + vertices.push( - widthHalf, y, depthHalf, - widthHalf, y, - depthHalf ); + + y += segmentHeight; + + } + + for ( var i = 0; i <= depthSegments; i ++ ) { + + vertices.push( - widthHalf, - heightHalf, z, - widthHalf, heightHalf, z ); + vertices.push( - widthHalf, heightHalf, z, widthHalf, heightHalf, z ); + vertices.push( widthHalf, heightHalf, z, widthHalf, - heightHalf, z ); + vertices.push( widthHalf, - heightHalf, z, - widthHalf, - heightHalf, z ); + + z += segmentDepth; + + } + + this.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + +} + +THREE.BoxLineGeometry.prototype = Object.create( THREE.BufferGeometry.prototype ); +THREE.BoxLineGeometry.prototype.constructor = THREE.BoxLineGeometry; diff --git a/three/jsutil/geometries/ConvexGeometry.js b/three/jsutil/geometries/ConvexGeometry.js new file mode 100644 index 000000000..296f03e71 --- /dev/null +++ b/three/jsutil/geometries/ConvexGeometry.js @@ -0,0 +1,81 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + */ + +( function () { + + // ConvexGeometry + + function ConvexGeometry( points ) { + + THREE.Geometry.call( this ); + + this.fromBufferGeometry( new ConvexBufferGeometry( points ) ); + this.mergeVertices(); + + } + + ConvexGeometry.prototype = Object.create( THREE.Geometry.prototype ); + ConvexGeometry.prototype.constructor = ConvexGeometry; + + // ConvexBufferGeometry + + function ConvexBufferGeometry( points ) { + + THREE.BufferGeometry.call( this ); + + // buffers + + var vertices = []; + var normals = []; + + // execute QuickHull + + if ( THREE.QuickHull === undefined ) { + + console.error( 'THREE.ConvexBufferGeometry: ConvexBufferGeometry relies on THREE.QuickHull' ); + + } + + var quickHull = new THREE.QuickHull().setFromPoints( points ); + + // generate vertices and normals + + var faces = quickHull.faces; + + for ( var i = 0; i < faces.length; i ++ ) { + + var face = faces[ i ]; + var edge = face.edge; + + // we move along a doubly-connected edge list to access all face points (see HalfEdge docs) + + do { + + var point = edge.head().point; + + vertices.push( point.x, point.y, point.z ); + normals.push( face.normal.x, face.normal.y, face.normal.z ); + + edge = edge.next; + + } while ( edge !== face.edge ); + + } + + // build geometry + + this.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + this.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + } + + ConvexBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype ); + ConvexBufferGeometry.prototype.constructor = ConvexBufferGeometry; + + // export + + THREE.ConvexGeometry = ConvexGeometry; + THREE.ConvexBufferGeometry = ConvexBufferGeometry; + +} )(); diff --git a/three/jsutil/geometries/DecalGeometry.js b/three/jsutil/geometries/DecalGeometry.js new file mode 100644 index 000000000..09d1e99aa --- /dev/null +++ b/three/jsutil/geometries/DecalGeometry.js @@ -0,0 +1,357 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + * @author spite / https://github.com/spite + * + * You can use this geometry to create a decal mesh, that serves different kinds of purposes. + * e.g. adding unique details to models, performing dynamic visual environmental changes or covering seams. + * + * Constructor parameter: + * + * mesh — Any mesh object + * position — Position of the decal projector + * orientation — Orientation of the decal projector + * size — Size of the decal projector + * + * reference: http://blog.wolfire.com/2009/06/how-to-project-decals/ + * + */ + +( function () { + + function DecalGeometry( mesh, position, orientation, size ) { + + THREE.BufferGeometry.call( this ); + + // buffers + + var vertices = []; + var normals = []; + var uvs = []; + + // helpers + + var plane = new THREE.Vector3(); + + // this matrix represents the transformation of the decal projector + + var projectorMatrix = new THREE.Matrix4(); + projectorMatrix.makeRotationFromEuler( orientation ); + projectorMatrix.setPosition( position ); + + var projectorMatrixInverse = new THREE.Matrix4().getInverse( projectorMatrix ); + + // generate buffers + + generate(); + + // build geometry + + this.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + this.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + this.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + + function generate() { + + var i; + var geometry = new THREE.BufferGeometry(); + var decalVertices = []; + + var vertex = new THREE.Vector3(); + var normal = new THREE.Vector3(); + + // handle different geometry types + + if ( mesh.geometry.isGeometry ) { + + geometry.fromGeometry( mesh.geometry ); + + } else { + + geometry.copy( mesh.geometry ); + + } + + var positionAttribute = geometry.attributes.position; + var normalAttribute = geometry.attributes.normal; + + // first, create an array of 'DecalVertex' objects + // three consecutive 'DecalVertex' objects represent a single face + // + // this data structure will be later used to perform the clipping + + if ( geometry.index !== null ) { + + // indexed BufferGeometry + + var index = geometry.index; + + for ( i = 0; i < index.count; i ++ ) { + + vertex.fromBufferAttribute( positionAttribute, index.getX( i ) ); + normal.fromBufferAttribute( normalAttribute, index.getX( i ) ); + + pushDecalVertex( decalVertices, vertex, normal ); + + } + + } else { + + // non-indexed BufferGeometry + + for ( i = 0; i < positionAttribute.count; i ++ ) { + + vertex.fromBufferAttribute( positionAttribute, i ); + normal.fromBufferAttribute( normalAttribute, i ); + + pushDecalVertex( decalVertices, vertex, normal ); + + } + + } + + // second, clip the geometry so that it doesn't extend out from the projector + + decalVertices = clipGeometry( decalVertices, plane.set( 1, 0, 0 ) ); + decalVertices = clipGeometry( decalVertices, plane.set( - 1, 0, 0 ) ); + decalVertices = clipGeometry( decalVertices, plane.set( 0, 1, 0 ) ); + decalVertices = clipGeometry( decalVertices, plane.set( 0, - 1, 0 ) ); + decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, 1 ) ); + decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, - 1 ) ); + + // third, generate final vertices, normals and uvs + + for ( i = 0; i < decalVertices.length; i ++ ) { + + var decalVertex = decalVertices[ i ]; + + // create texture coordinates (we are still in projector space) + + uvs.push( + 0.5 + ( decalVertex.position.x / size.x ), + 0.5 + ( decalVertex.position.y / size.y ) + ); + + // transform the vertex back to world space + + decalVertex.position.applyMatrix4( projectorMatrix ); + + // now create vertex and normal buffer data + + vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z ); + normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z ); + + } + + } + + function pushDecalVertex( decalVertices, vertex, normal ) { + + // transform the vertex to world space, then to projector space + + vertex.applyMatrix4( mesh.matrixWorld ); + vertex.applyMatrix4( projectorMatrixInverse ); + + decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) ); + + } + + function clipGeometry( inVertices, plane ) { + + var outVertices = []; + + var s = 0.5 * Math.abs( size.dot( plane ) ); + + // a single iteration clips one face, + // which consists of three consecutive 'DecalVertex' objects + + for ( var i = 0; i < inVertices.length; i += 3 ) { + + var v1Out, v2Out, v3Out, total = 0; + var nV1, nV2, nV3, nV4; + + var d1 = inVertices[ i + 0 ].position.dot( plane ) - s; + var d2 = inVertices[ i + 1 ].position.dot( plane ) - s; + var d3 = inVertices[ i + 2 ].position.dot( plane ) - s; + + v1Out = d1 > 0; + v2Out = d2 > 0; + v3Out = d3 > 0; + + // calculate, how many vertices of the face lie outside of the clipping plane + + total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 ); + + switch ( total ) { + + case 0: { + + // the entire face lies inside of the plane, no clipping needed + + outVertices.push( inVertices[ i ] ); + outVertices.push( inVertices[ i + 1 ] ); + outVertices.push( inVertices[ i + 2 ] ); + break; + + } + + case 1: { + + // one vertex lies outside of the plane, perform clipping + + if ( v1Out ) { + + nV1 = inVertices[ i + 1 ]; + nV2 = inVertices[ i + 2 ]; + nV3 = clip( inVertices[ i ], nV1, plane, s ); + nV4 = clip( inVertices[ i ], nV2, plane, s ); + + } + + if ( v2Out ) { + + nV1 = inVertices[ i ]; + nV2 = inVertices[ i + 2 ]; + nV3 = clip( inVertices[ i + 1 ], nV1, plane, s ); + nV4 = clip( inVertices[ i + 1 ], nV2, plane, s ); + + outVertices.push( nV3 ); + outVertices.push( nV2.clone() ); + outVertices.push( nV1.clone() ); + + outVertices.push( nV2.clone() ); + outVertices.push( nV3.clone() ); + outVertices.push( nV4 ); + break; + + } + + if ( v3Out ) { + + nV1 = inVertices[ i ]; + nV2 = inVertices[ i + 1 ]; + nV3 = clip( inVertices[ i + 2 ], nV1, plane, s ); + nV4 = clip( inVertices[ i + 2 ], nV2, plane, s ); + + } + + outVertices.push( nV1.clone() ); + outVertices.push( nV2.clone() ); + outVertices.push( nV3 ); + + outVertices.push( nV4 ); + outVertices.push( nV3.clone() ); + outVertices.push( nV2.clone() ); + + break; + + } + + case 2: { + + // two vertices lies outside of the plane, perform clipping + + if ( ! v1Out ) { + + nV1 = inVertices[ i ].clone(); + nV2 = clip( nV1, inVertices[ i + 1 ], plane, s ); + nV3 = clip( nV1, inVertices[ i + 2 ], plane, s ); + outVertices.push( nV1 ); + outVertices.push( nV2 ); + outVertices.push( nV3 ); + + } + + if ( ! v2Out ) { + + nV1 = inVertices[ i + 1 ].clone(); + nV2 = clip( nV1, inVertices[ i + 2 ], plane, s ); + nV3 = clip( nV1, inVertices[ i ], plane, s ); + outVertices.push( nV1 ); + outVertices.push( nV2 ); + outVertices.push( nV3 ); + + } + + if ( ! v3Out ) { + + nV1 = inVertices[ i + 2 ].clone(); + nV2 = clip( nV1, inVertices[ i ], plane, s ); + nV3 = clip( nV1, inVertices[ i + 1 ], plane, s ); + outVertices.push( nV1 ); + outVertices.push( nV2 ); + outVertices.push( nV3 ); + + } + + break; + + } + + case 3: { + + // the entire face lies outside of the plane, so let's discard the corresponding vertices + + break; + + } + + } + + } + + return outVertices; + + } + + function clip( v0, v1, p, s ) { + + var d0 = v0.position.dot( p ) - s; + var d1 = v1.position.dot( p ) - s; + + var s0 = d0 / ( d0 - d1 ); + + var v = new DecalVertex( + new THREE.Vector3( + v0.position.x + s0 * ( v1.position.x - v0.position.x ), + v0.position.y + s0 * ( v1.position.y - v0.position.y ), + v0.position.z + s0 * ( v1.position.z - v0.position.z ) + ), + new THREE.Vector3( + v0.normal.x + s0 * ( v1.normal.x - v0.normal.x ), + v0.normal.y + s0 * ( v1.normal.y - v0.normal.y ), + v0.normal.z + s0 * ( v1.normal.z - v0.normal.z ) + ) + ); + + // need to clip more values (texture coordinates)? do it this way: + // intersectpoint.value = a.value + s * ( b.value - a.value ); + + return v; + + } + + } + + DecalGeometry.prototype = Object.create( THREE.BufferGeometry.prototype ); + DecalGeometry.prototype.constructor = DecalGeometry; + + // helper + + function DecalVertex( position, normal ) { + + this.position = position; + this.normal = normal; + + } + + DecalVertex.prototype.clone = function () { + + return new DecalVertex( this.position.clone(), this.normal.clone() ); + + }; + + // export + + THREE.DecalGeometry = DecalGeometry; + +} )(); diff --git a/three/jsutil/geometries/TeapotBufferGeometry.js b/three/jsutil/geometries/TeapotBufferGeometry.js new file mode 100644 index 000000000..3b8811fd6 --- /dev/null +++ b/three/jsutil/geometries/TeapotBufferGeometry.js @@ -0,0 +1,718 @@ +/** + * @author Eric Haines / http://erichaines.com/ + * + * Tessellates the famous Utah teapot database by Martin Newell into triangles. + * + * THREE.TeapotBufferGeometry = function ( size, segments, bottom, lid, body, fitLid, blinn ) + * + * defaults: size = 50, segments = 10, bottom = true, lid = true, body = true, + * fitLid = false, blinn = true + * + * size is a relative scale: I've scaled the teapot to fit vertically between -1 and 1. + * Think of it as a "radius". + * segments - number of line segments to subdivide each patch edge; + * 1 is possible but gives degenerates, so two is the real minimum. + * bottom - boolean, if true (default) then the bottom patches are added. Some consider + * adding the bottom heresy, so set this to "false" to adhere to the One True Way. + * lid - to remove the lid and look inside, set to true. + * body - to remove the body and leave the lid, set this and "bottom" to false. + * fitLid - the lid is a tad small in the original. This stretches it a bit so you can't + * see the teapot's insides through the gap. + * blinn - Jim Blinn scaled the original data vertically by dividing by about 1.3 to look + * nicer. If you want to see the original teapot, similar to the real-world model, set + * this to false. True by default. + * See http://en.wikipedia.org/wiki/File:Original_Utah_Teapot.jpg for the original + * real-world teapot (from http://en.wikipedia.org/wiki/Utah_teapot). + * + * Note that the bottom (the last four patches) is not flat - blame Frank Crow, not me. + * + * The teapot should normally be rendered as a double sided object, since for some + * patches both sides can be seen, e.g., the gap around the lid and inside the spout. + * + * Segments 'n' determines the number of triangles output. + * Total triangles = 32*2*n*n - 8*n [degenerates at the top and bottom cusps are deleted] + * + * size_factor # triangles + * 1 56 + * 2 240 + * 3 552 + * 4 992 + * + * 10 6320 + * 20 25440 + * 30 57360 + * + * Code converted from my ancient SPD software, http://tog.acm.org/resources/SPD/ + * Created for the Udacity course "Interactive Rendering", http://bit.ly/ericity + * Lesson: https://www.udacity.com/course/viewer#!/c-cs291/l-68866048/m-106482448 + * YouTube video on teapot history: https://www.youtube.com/watch?v=DxMfblPzFNc + * + * See https://en.wikipedia.org/wiki/Utah_teapot for the history of the teapot + * + */ +/*global THREE */ + +THREE.TeapotBufferGeometry = function ( size, segments, bottom, lid, body, fitLid, blinn ) { + + // 32 * 4 * 4 Bezier spline patches + var teapotPatches = [ + /*rim*/ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27, + 18, 28, 29, 30, 21, 31, 32, 33, 24, 34, 35, 36, 27, 37, 38, 39, + 30, 40, 41, 0, 33, 42, 43, 4, 36, 44, 45, 8, 39, 46, 47, 12, + /*body*/ + 12, 13, 14, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 15, 25, 26, 27, 51, 60, 61, 62, 55, 63, 64, 65, 59, 66, 67, 68, + 27, 37, 38, 39, 62, 69, 70, 71, 65, 72, 73, 74, 68, 75, 76, 77, + 39, 46, 47, 12, 71, 78, 79, 48, 74, 80, 81, 52, 77, 82, 83, 56, + 56, 57, 58, 59, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 59, 66, 67, 68, 87, 96, 97, 98, 91, 99, 100, 101, 95, 102, 103, 104, + 68, 75, 76, 77, 98, 105, 106, 107, 101, 108, 109, 110, 104, 111, 112, 113, + 77, 82, 83, 56, 107, 114, 115, 84, 110, 116, 117, 88, 113, 118, 119, 92, + /*handle*/ + 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 123, 136, 137, 120, 127, 138, 139, 124, 131, 140, 141, 128, 135, 142, 143, 132, + 132, 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 151, 68, 152, 153, 154, + 135, 142, 143, 132, 147, 155, 156, 144, 151, 157, 158, 148, 154, 159, 160, 68, + /*spout*/ + 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, + 164, 177, 178, 161, 168, 179, 180, 165, 172, 181, 182, 169, 176, 183, 184, 173, + 173, 174, 175, 176, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, + 176, 183, 184, 173, 188, 197, 198, 185, 192, 199, 200, 189, 196, 201, 202, 193, + /*lid*/ + 203, 203, 203, 203, 204, 205, 206, 207, 208, 208, 208, 208, 209, 210, 211, 212, + 203, 203, 203, 203, 207, 213, 214, 215, 208, 208, 208, 208, 212, 216, 217, 218, + 203, 203, 203, 203, 215, 219, 220, 221, 208, 208, 208, 208, 218, 222, 223, 224, + 203, 203, 203, 203, 221, 225, 226, 204, 208, 208, 208, 208, 224, 227, 228, 209, + 209, 210, 211, 212, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, + 212, 216, 217, 218, 232, 241, 242, 243, 236, 244, 245, 246, 240, 247, 248, 249, + 218, 222, 223, 224, 243, 250, 251, 252, 246, 253, 254, 255, 249, 256, 257, 258, + 224, 227, 228, 209, 252, 259, 260, 229, 255, 261, 262, 233, 258, 263, 264, 237, + /*bottom*/ + 265, 265, 265, 265, 266, 267, 268, 269, 270, 271, 272, 273, 92, 119, 118, 113, + 265, 265, 265, 265, 269, 274, 275, 276, 273, 277, 278, 279, 113, 112, 111, 104, + 265, 265, 265, 265, 276, 280, 281, 282, 279, 283, 284, 285, 104, 103, 102, 95, + 265, 265, 265, 265, 282, 286, 287, 266, 285, 288, 289, 270, 95, 94, 93, 92 + ]; + + var teapotVertices = [ + 1.4, 0, 2.4, + 1.4, - 0.784, 2.4, + 0.784, - 1.4, 2.4, + 0, - 1.4, 2.4, + 1.3375, 0, 2.53125, + 1.3375, - 0.749, 2.53125, + 0.749, - 1.3375, 2.53125, + 0, - 1.3375, 2.53125, + 1.4375, 0, 2.53125, + 1.4375, - 0.805, 2.53125, + 0.805, - 1.4375, 2.53125, + 0, - 1.4375, 2.53125, + 1.5, 0, 2.4, + 1.5, - 0.84, 2.4, + 0.84, - 1.5, 2.4, + 0, - 1.5, 2.4, + - 0.784, - 1.4, 2.4, + - 1.4, - 0.784, 2.4, + - 1.4, 0, 2.4, + - 0.749, - 1.3375, 2.53125, + - 1.3375, - 0.749, 2.53125, + - 1.3375, 0, 2.53125, + - 0.805, - 1.4375, 2.53125, + - 1.4375, - 0.805, 2.53125, + - 1.4375, 0, 2.53125, + - 0.84, - 1.5, 2.4, + - 1.5, - 0.84, 2.4, + - 1.5, 0, 2.4, + - 1.4, 0.784, 2.4, + - 0.784, 1.4, 2.4, + 0, 1.4, 2.4, + - 1.3375, 0.749, 2.53125, + - 0.749, 1.3375, 2.53125, + 0, 1.3375, 2.53125, + - 1.4375, 0.805, 2.53125, + - 0.805, 1.4375, 2.53125, + 0, 1.4375, 2.53125, + - 1.5, 0.84, 2.4, + - 0.84, 1.5, 2.4, + 0, 1.5, 2.4, + 0.784, 1.4, 2.4, + 1.4, 0.784, 2.4, + 0.749, 1.3375, 2.53125, + 1.3375, 0.749, 2.53125, + 0.805, 1.4375, 2.53125, + 1.4375, 0.805, 2.53125, + 0.84, 1.5, 2.4, + 1.5, 0.84, 2.4, + 1.75, 0, 1.875, + 1.75, - 0.98, 1.875, + 0.98, - 1.75, 1.875, + 0, - 1.75, 1.875, + 2, 0, 1.35, + 2, - 1.12, 1.35, + 1.12, - 2, 1.35, + 0, - 2, 1.35, + 2, 0, 0.9, + 2, - 1.12, 0.9, + 1.12, - 2, 0.9, + 0, - 2, 0.9, + - 0.98, - 1.75, 1.875, + - 1.75, - 0.98, 1.875, + - 1.75, 0, 1.875, + - 1.12, - 2, 1.35, + - 2, - 1.12, 1.35, + - 2, 0, 1.35, + - 1.12, - 2, 0.9, + - 2, - 1.12, 0.9, + - 2, 0, 0.9, + - 1.75, 0.98, 1.875, + - 0.98, 1.75, 1.875, + 0, 1.75, 1.875, + - 2, 1.12, 1.35, + - 1.12, 2, 1.35, + 0, 2, 1.35, + - 2, 1.12, 0.9, + - 1.12, 2, 0.9, + 0, 2, 0.9, + 0.98, 1.75, 1.875, + 1.75, 0.98, 1.875, + 1.12, 2, 1.35, + 2, 1.12, 1.35, + 1.12, 2, 0.9, + 2, 1.12, 0.9, + 2, 0, 0.45, + 2, - 1.12, 0.45, + 1.12, - 2, 0.45, + 0, - 2, 0.45, + 1.5, 0, 0.225, + 1.5, - 0.84, 0.225, + 0.84, - 1.5, 0.225, + 0, - 1.5, 0.225, + 1.5, 0, 0.15, + 1.5, - 0.84, 0.15, + 0.84, - 1.5, 0.15, + 0, - 1.5, 0.15, + - 1.12, - 2, 0.45, + - 2, - 1.12, 0.45, + - 2, 0, 0.45, + - 0.84, - 1.5, 0.225, + - 1.5, - 0.84, 0.225, + - 1.5, 0, 0.225, + - 0.84, - 1.5, 0.15, + - 1.5, - 0.84, 0.15, + - 1.5, 0, 0.15, + - 2, 1.12, 0.45, + - 1.12, 2, 0.45, + 0, 2, 0.45, + - 1.5, 0.84, 0.225, + - 0.84, 1.5, 0.225, + 0, 1.5, 0.225, + - 1.5, 0.84, 0.15, + - 0.84, 1.5, 0.15, + 0, 1.5, 0.15, + 1.12, 2, 0.45, + 2, 1.12, 0.45, + 0.84, 1.5, 0.225, + 1.5, 0.84, 0.225, + 0.84, 1.5, 0.15, + 1.5, 0.84, 0.15, + - 1.6, 0, 2.025, + - 1.6, - 0.3, 2.025, + - 1.5, - 0.3, 2.25, + - 1.5, 0, 2.25, + - 2.3, 0, 2.025, + - 2.3, - 0.3, 2.025, + - 2.5, - 0.3, 2.25, + - 2.5, 0, 2.25, + - 2.7, 0, 2.025, + - 2.7, - 0.3, 2.025, + - 3, - 0.3, 2.25, + - 3, 0, 2.25, + - 2.7, 0, 1.8, + - 2.7, - 0.3, 1.8, + - 3, - 0.3, 1.8, + - 3, 0, 1.8, + - 1.5, 0.3, 2.25, + - 1.6, 0.3, 2.025, + - 2.5, 0.3, 2.25, + - 2.3, 0.3, 2.025, + - 3, 0.3, 2.25, + - 2.7, 0.3, 2.025, + - 3, 0.3, 1.8, + - 2.7, 0.3, 1.8, + - 2.7, 0, 1.575, + - 2.7, - 0.3, 1.575, + - 3, - 0.3, 1.35, + - 3, 0, 1.35, + - 2.5, 0, 1.125, + - 2.5, - 0.3, 1.125, + - 2.65, - 0.3, 0.9375, + - 2.65, 0, 0.9375, + - 2, - 0.3, 0.9, + - 1.9, - 0.3, 0.6, + - 1.9, 0, 0.6, + - 3, 0.3, 1.35, + - 2.7, 0.3, 1.575, + - 2.65, 0.3, 0.9375, + - 2.5, 0.3, 1.125, + - 1.9, 0.3, 0.6, + - 2, 0.3, 0.9, + 1.7, 0, 1.425, + 1.7, - 0.66, 1.425, + 1.7, - 0.66, 0.6, + 1.7, 0, 0.6, + 2.6, 0, 1.425, + 2.6, - 0.66, 1.425, + 3.1, - 0.66, 0.825, + 3.1, 0, 0.825, + 2.3, 0, 2.1, + 2.3, - 0.25, 2.1, + 2.4, - 0.25, 2.025, + 2.4, 0, 2.025, + 2.7, 0, 2.4, + 2.7, - 0.25, 2.4, + 3.3, - 0.25, 2.4, + 3.3, 0, 2.4, + 1.7, 0.66, 0.6, + 1.7, 0.66, 1.425, + 3.1, 0.66, 0.825, + 2.6, 0.66, 1.425, + 2.4, 0.25, 2.025, + 2.3, 0.25, 2.1, + 3.3, 0.25, 2.4, + 2.7, 0.25, 2.4, + 2.8, 0, 2.475, + 2.8, - 0.25, 2.475, + 3.525, - 0.25, 2.49375, + 3.525, 0, 2.49375, + 2.9, 0, 2.475, + 2.9, - 0.15, 2.475, + 3.45, - 0.15, 2.5125, + 3.45, 0, 2.5125, + 2.8, 0, 2.4, + 2.8, - 0.15, 2.4, + 3.2, - 0.15, 2.4, + 3.2, 0, 2.4, + 3.525, 0.25, 2.49375, + 2.8, 0.25, 2.475, + 3.45, 0.15, 2.5125, + 2.9, 0.15, 2.475, + 3.2, 0.15, 2.4, + 2.8, 0.15, 2.4, + 0, 0, 3.15, + 0.8, 0, 3.15, + 0.8, - 0.45, 3.15, + 0.45, - 0.8, 3.15, + 0, - 0.8, 3.15, + 0, 0, 2.85, + 0.2, 0, 2.7, + 0.2, - 0.112, 2.7, + 0.112, - 0.2, 2.7, + 0, - 0.2, 2.7, + - 0.45, - 0.8, 3.15, + - 0.8, - 0.45, 3.15, + - 0.8, 0, 3.15, + - 0.112, - 0.2, 2.7, + - 0.2, - 0.112, 2.7, + - 0.2, 0, 2.7, + - 0.8, 0.45, 3.15, + - 0.45, 0.8, 3.15, + 0, 0.8, 3.15, + - 0.2, 0.112, 2.7, + - 0.112, 0.2, 2.7, + 0, 0.2, 2.7, + 0.45, 0.8, 3.15, + 0.8, 0.45, 3.15, + 0.112, 0.2, 2.7, + 0.2, 0.112, 2.7, + 0.4, 0, 2.55, + 0.4, - 0.224, 2.55, + 0.224, - 0.4, 2.55, + 0, - 0.4, 2.55, + 1.3, 0, 2.55, + 1.3, - 0.728, 2.55, + 0.728, - 1.3, 2.55, + 0, - 1.3, 2.55, + 1.3, 0, 2.4, + 1.3, - 0.728, 2.4, + 0.728, - 1.3, 2.4, + 0, - 1.3, 2.4, + - 0.224, - 0.4, 2.55, + - 0.4, - 0.224, 2.55, + - 0.4, 0, 2.55, + - 0.728, - 1.3, 2.55, + - 1.3, - 0.728, 2.55, + - 1.3, 0, 2.55, + - 0.728, - 1.3, 2.4, + - 1.3, - 0.728, 2.4, + - 1.3, 0, 2.4, + - 0.4, 0.224, 2.55, + - 0.224, 0.4, 2.55, + 0, 0.4, 2.55, + - 1.3, 0.728, 2.55, + - 0.728, 1.3, 2.55, + 0, 1.3, 2.55, + - 1.3, 0.728, 2.4, + - 0.728, 1.3, 2.4, + 0, 1.3, 2.4, + 0.224, 0.4, 2.55, + 0.4, 0.224, 2.55, + 0.728, 1.3, 2.55, + 1.3, 0.728, 2.55, + 0.728, 1.3, 2.4, + 1.3, 0.728, 2.4, + 0, 0, 0, + 1.425, 0, 0, + 1.425, 0.798, 0, + 0.798, 1.425, 0, + 0, 1.425, 0, + 1.5, 0, 0.075, + 1.5, 0.84, 0.075, + 0.84, 1.5, 0.075, + 0, 1.5, 0.075, + - 0.798, 1.425, 0, + - 1.425, 0.798, 0, + - 1.425, 0, 0, + - 0.84, 1.5, 0.075, + - 1.5, 0.84, 0.075, + - 1.5, 0, 0.075, + - 1.425, - 0.798, 0, + - 0.798, - 1.425, 0, + 0, - 1.425, 0, + - 1.5, - 0.84, 0.075, + - 0.84, - 1.5, 0.075, + 0, - 1.5, 0.075, + 0.798, - 1.425, 0, + 1.425, - 0.798, 0, + 0.84, - 1.5, 0.075, + 1.5, - 0.84, 0.075 + ]; + + THREE.BufferGeometry.call( this ); + + size = size || 50; + + // number of segments per patch + segments = segments !== undefined ? Math.max( 2, Math.floor( segments ) || 10 ) : 10; + + // which parts should be visible + bottom = bottom === undefined ? true : bottom; + lid = lid === undefined ? true : lid; + body = body === undefined ? true : body; + + // Should the lid be snug? It's not traditional, but we make it snug by default + fitLid = fitLid === undefined ? true : fitLid; + + // Jim Blinn scaled the teapot down in size by about 1.3 for + // some rendering tests. He liked the new proportions that he kept + // the data in this form. The model was distributed with these new + // proportions and became the norm. Trivia: comparing images of the + // real teapot and the computer model, the ratio for the bowl of the + // real teapot is more like 1.25, but since 1.3 is the traditional + // value given, we use it here. + var blinnScale = 1.3; + blinn = blinn === undefined ? true : blinn; + + // scale the size to be the real scaling factor + var maxHeight = 3.15 * ( blinn ? 1 : blinnScale ); + + var maxHeight2 = maxHeight / 2; + var trueSize = size / maxHeight2; + + // Number of elements depends on what is needed. Subtract degenerate + // triangles at tip of bottom and lid out in advance. + var numTriangles = bottom ? ( 8 * segments - 4 ) * segments : 0; + numTriangles += lid ? ( 16 * segments - 4 ) * segments : 0; + numTriangles += body ? 40 * segments * segments : 0; + + var indices = new Uint32Array( numTriangles * 3 ); + + var numVertices = bottom ? 4 : 0; + numVertices += lid ? 8 : 0; + numVertices += body ? 20 : 0; + numVertices *= ( segments + 1 ) * ( segments + 1 ); + + var vertices = new Float32Array( numVertices * 3 ); + var normals = new Float32Array( numVertices * 3 ); + var uvs = new Float32Array( numVertices * 2 ); + + // Bezier form + var ms = new THREE.Matrix4(); + ms.set( + - 1.0, 3.0, - 3.0, 1.0, + 3.0, - 6.0, 3.0, 0.0, + - 3.0, 3.0, 0.0, 0.0, + 1.0, 0.0, 0.0, 0.0 ); + + var g = []; + var i, r, c; + + var sp = []; + var tp = []; + var dsp = []; + var dtp = []; + + // M * G * M matrix, sort of see + // http://www.cs.helsinki.fi/group/goa/mallinnus/curves/surfaces.html + var mgm = []; + + var vert = []; + var sdir = []; + var tdir = []; + + var norm = new THREE.Vector3(); + + var tcoord; + + var sstep, tstep; + var vertPerRow; + + var s, t, sval, tval, p; + var dsval = 0; + var dtval = 0; + + var normOut = new THREE.Vector3(); + var v1, v2, v3, v4; + + var gmx = new THREE.Matrix4(); + var tmtx = new THREE.Matrix4(); + + var vsp = new THREE.Vector4(); + var vtp = new THREE.Vector4(); + var vdsp = new THREE.Vector4(); + var vdtp = new THREE.Vector4(); + + var vsdir = new THREE.Vector3(); + var vtdir = new THREE.Vector3(); + + var mst = ms.clone(); + mst.transpose(); + + // internal function: test if triangle has any matching vertices; + // if so, don't save triangle, since it won't display anything. + var notDegenerate = function ( vtx1, vtx2, vtx3 ) { + + // if any vertex matches, return false + return ! ( ( ( vertices[ vtx1 * 3 ] === vertices[ vtx2 * 3 ] ) && + ( vertices[ vtx1 * 3 + 1 ] === vertices[ vtx2 * 3 + 1 ] ) && + ( vertices[ vtx1 * 3 + 2 ] === vertices[ vtx2 * 3 + 2 ] ) ) || + ( ( vertices[ vtx1 * 3 ] === vertices[ vtx3 * 3 ] ) && + ( vertices[ vtx1 * 3 + 1 ] === vertices[ vtx3 * 3 + 1 ] ) && + ( vertices[ vtx1 * 3 + 2 ] === vertices[ vtx3 * 3 + 2 ] ) ) || + ( ( vertices[ vtx2 * 3 ] === vertices[ vtx3 * 3 ] ) && + ( vertices[ vtx2 * 3 + 1 ] === vertices[ vtx3 * 3 + 1 ] ) && + ( vertices[ vtx2 * 3 + 2 ] === vertices[ vtx3 * 3 + 2 ] ) ) ); + + }; + + + for ( i = 0; i < 3; i ++ ) { + + mgm[ i ] = new THREE.Matrix4(); + + } + + var minPatches = body ? 0 : 20; + var maxPatches = bottom ? 32 : 28; + + vertPerRow = segments + 1; + + var surfCount = 0; + + var vertCount = 0; + var normCount = 0; + var uvCount = 0; + + var indexCount = 0; + + for ( var surf = minPatches; surf < maxPatches; surf ++ ) { + + // lid is in the middle of the data, patches 20-27, + // so ignore it for this part of the loop if the lid is not desired + if ( lid || ( surf < 20 || surf >= 28 ) ) { + + // get M * G * M matrix for x,y,z + for ( i = 0; i < 3; i ++ ) { + + // get control patches + for ( r = 0; r < 4; r ++ ) { + + for ( c = 0; c < 4; c ++ ) { + + // transposed + g[ c * 4 + r ] = teapotVertices[ teapotPatches[ surf * 16 + r * 4 + c ] * 3 + i ]; + + // is the lid to be made larger, and is this a point on the lid + // that is X or Y? + if ( fitLid && ( surf >= 20 && surf < 28 ) && ( i !== 2 ) ) { + + // increase XY size by 7.7%, found empirically. I don't + // increase Z so that the teapot will continue to fit in the + // space -1 to 1 for Y (Y is up for the final model). + g[ c * 4 + r ] *= 1.077; + + } + + // Blinn "fixed" the teapot by dividing Z by blinnScale, and that's the + // data we now use. The original teapot is taller. Fix it: + if ( ! blinn && ( i === 2 ) ) { + + g[ c * 4 + r ] *= blinnScale; + + } + + } + + } + + gmx.set( g[ 0 ], g[ 1 ], g[ 2 ], g[ 3 ], g[ 4 ], g[ 5 ], g[ 6 ], g[ 7 ], g[ 8 ], g[ 9 ], g[ 10 ], g[ 11 ], g[ 12 ], g[ 13 ], g[ 14 ], g[ 15 ] ); + + tmtx.multiplyMatrices( gmx, ms ); + mgm[ i ].multiplyMatrices( mst, tmtx ); + + } + + // step along, get points, and output + for ( sstep = 0; sstep <= segments; sstep ++ ) { + + s = sstep / segments; + + for ( tstep = 0; tstep <= segments; tstep ++ ) { + + t = tstep / segments; + + // point from basis + // get power vectors and their derivatives + for ( p = 4, sval = tval = 1.0; p --; ) { + + sp[ p ] = sval; + tp[ p ] = tval; + sval *= s; + tval *= t; + + if ( p === 3 ) { + + dsp[ p ] = dtp[ p ] = 0.0; + dsval = dtval = 1.0; + + } else { + + dsp[ p ] = dsval * ( 3 - p ); + dtp[ p ] = dtval * ( 3 - p ); + dsval *= s; + dtval *= t; + + } + + } + + vsp.fromArray( sp ); + vtp.fromArray( tp ); + vdsp.fromArray( dsp ); + vdtp.fromArray( dtp ); + + // do for x,y,z + for ( i = 0; i < 3; i ++ ) { + + // multiply power vectors times matrix to get value + tcoord = vsp.clone(); + tcoord.applyMatrix4( mgm[ i ] ); + vert[ i ] = tcoord.dot( vtp ); + + // get s and t tangent vectors + tcoord = vdsp.clone(); + tcoord.applyMatrix4( mgm[ i ] ); + sdir[ i ] = tcoord.dot( vtp ); + + tcoord = vsp.clone(); + tcoord.applyMatrix4( mgm[ i ] ); + tdir[ i ] = tcoord.dot( vdtp ); + + } + + // find normal + vsdir.fromArray( sdir ); + vtdir.fromArray( tdir ); + norm.crossVectors( vtdir, vsdir ); + norm.normalize(); + + // if X and Z length is 0, at the cusp, so point the normal up or down, depending on patch number + if ( vert[ 0 ] === 0 && vert[ 1 ] === 0 ) { + + // if above the middle of the teapot, normal points up, else down + normOut.set( 0, vert[ 2 ] > maxHeight2 ? 1 : - 1, 0 ); + + } else { + + // standard output: rotate on X axis + normOut.set( norm.x, norm.z, - norm.y ); + + } + + // store it all + vertices[ vertCount ++ ] = trueSize * vert[ 0 ]; + vertices[ vertCount ++ ] = trueSize * ( vert[ 2 ] - maxHeight2 ); + vertices[ vertCount ++ ] = - trueSize * vert[ 1 ]; + + normals[ normCount ++ ] = normOut.x; + normals[ normCount ++ ] = normOut.y; + normals[ normCount ++ ] = normOut.z; + + uvs[ uvCount ++ ] = 1 - t; + uvs[ uvCount ++ ] = 1 - s; + + } + + } + + // save the faces + for ( sstep = 0; sstep < segments; sstep ++ ) { + + for ( tstep = 0; tstep < segments; tstep ++ ) { + + v1 = surfCount * vertPerRow * vertPerRow + sstep * vertPerRow + tstep; + v2 = v1 + 1; + v3 = v2 + vertPerRow; + v4 = v1 + vertPerRow; + + // Normals and UVs cannot be shared. Without clone(), you can see the consequences + // of sharing if you call geometry.applyMatrix( matrix ). + if ( notDegenerate( v1, v2, v3 ) ) { + + indices[ indexCount ++ ] = v1; + indices[ indexCount ++ ] = v2; + indices[ indexCount ++ ] = v3; + + } + if ( notDegenerate( v1, v3, v4 ) ) { + + indices[ indexCount ++ ] = v1; + indices[ indexCount ++ ] = v3; + indices[ indexCount ++ ] = v4; + + } + + } + + } + + // increment only if a surface was used + surfCount ++; + + } + + } + + this.setIndex( new THREE.BufferAttribute( indices, 1 ) ); + this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); + this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) ); + this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) ); + + this.computeBoundingSphere(); + +}; + + +THREE.TeapotBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype ); +THREE.TeapotBufferGeometry.prototype.constructor = THREE.TeapotBufferGeometry; diff --git a/three/jsutil/geometries/hilbert2D.js b/three/jsutil/geometries/hilbert2D.js new file mode 100644 index 000000000..c63501e2b --- /dev/null +++ b/three/jsutil/geometries/hilbert2D.js @@ -0,0 +1,63 @@ +/** + * Hilbert Curve: Generates 2D-Coordinates in a very fast way. + * + * @author Dylan Grafmyre + * + * Based on work by: + * @author Thomas Diewald + * @link http://www.openprocessing.org/sketch/15493 + * + * @param center Center of Hilbert curve. + * @param size Total width of Hilbert curve. + * @param iterations Number of subdivisions. + * @param v0 Corner index -X, -Z. + * @param v1 Corner index -X, +Z. + * @param v2 Corner index +X, +Z. + * @param v3 Corner index +X, -Z. + */ +function hilbert2D( center, size, iterations, v0, v1, v2, v3 ) { + + // Default Vars + var center = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ), + size = undefined !== size ? size : 10, + half = size / 2, + iterations = undefined !== iterations ? iterations : 1, + v0 = undefined !== v0 ? v0 : 0, + v1 = undefined !== v1 ? v1 : 1, + v2 = undefined !== v2 ? v2 : 2, + v3 = undefined !== v3 ? v3 : 3 + ; + + var vec_s = [ + new THREE.Vector3( center.x - half, center.y, center.z - half ), + new THREE.Vector3( center.x - half, center.y, center.z + half ), + new THREE.Vector3( center.x + half, center.y, center.z + half ), + new THREE.Vector3( center.x + half, center.y, center.z - half ) + ]; + + var vec = [ + vec_s[ v0 ], + vec_s[ v1 ], + vec_s[ v2 ], + vec_s[ v3 ] + ]; + + // Recurse iterations + if ( 0 <= -- iterations ) { + + var tmp = []; + + Array.prototype.push.apply( tmp, hilbert2D( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) ); + Array.prototype.push.apply( tmp, hilbert2D( vec[ 1 ], half, iterations, v0, v1, v2, v3 ) ); + Array.prototype.push.apply( tmp, hilbert2D( vec[ 2 ], half, iterations, v0, v1, v2, v3 ) ); + Array.prototype.push.apply( tmp, hilbert2D( vec[ 3 ], half, iterations, v2, v1, v0, v3 ) ); + + // Return recursive call + return tmp; + + } + + // Return complete Hilbert Curve. + return vec; + +} diff --git a/three/jsutil/geometries/hilbert3D.js b/three/jsutil/geometries/hilbert3D.js new file mode 100644 index 000000000..23d6ca82c --- /dev/null +++ b/three/jsutil/geometries/hilbert3D.js @@ -0,0 +1,88 @@ +/** + * Hilbert Curve: Generates 2D-Coordinates in a very fast way. + * + * @author Dylan Grafmyre + * + * Based on work by: + * @author Thomas Diewald + * @link http://www.openprocessing.org/visuals/?visualID=15599 + * + * Based on `examples/canvas_lines_colors.html`: + * @author OpenShift guest + * @link https://github.com/mrdoob/three.js/blob/8413a860aa95ed29c79cbb7f857c97d7880d260f/examples/canvas_lines_colors.html + * @see Line 149 - 186 + * + * @param center Center of Hilbert curve. + * @param size Total width of Hilbert curve. + * @param iterations Number of subdivisions. + * @param v0 Corner index -X, +Y, -Z. + * @param v1 Corner index -X, +Y, +Z. + * @param v2 Corner index -X, -Y, +Z. + * @param v3 Corner index -X, -Y, -Z. + * @param v4 Corner index +X, -Y, -Z. + * @param v5 Corner index +X, -Y, +Z. + * @param v6 Corner index +X, +Y, +Z. + * @param v7 Corner index +X, +Y, -Z. + */ +function hilbert3D( center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7 ) { + + // Default Vars + var center = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ), + size = undefined !== size ? size : 10, + half = size / 2, + iterations = undefined !== iterations ? iterations : 1, + v0 = undefined !== v0 ? v0 : 0, + v1 = undefined !== v1 ? v1 : 1, + v2 = undefined !== v2 ? v2 : 2, + v3 = undefined !== v3 ? v3 : 3, + v4 = undefined !== v4 ? v4 : 4, + v5 = undefined !== v5 ? v5 : 5, + v6 = undefined !== v6 ? v6 : 6, + v7 = undefined !== v7 ? v7 : 7 + ; + + var vec_s = [ + new THREE.Vector3( center.x - half, center.y + half, center.z - half ), + new THREE.Vector3( center.x - half, center.y + half, center.z + half ), + new THREE.Vector3( center.x - half, center.y - half, center.z + half ), + new THREE.Vector3( center.x - half, center.y - half, center.z - half ), + new THREE.Vector3( center.x + half, center.y - half, center.z - half ), + new THREE.Vector3( center.x + half, center.y - half, center.z + half ), + new THREE.Vector3( center.x + half, center.y + half, center.z + half ), + new THREE.Vector3( center.x + half, center.y + half, center.z - half ) + ]; + + var vec = [ + vec_s[ v0 ], + vec_s[ v1 ], + vec_s[ v2 ], + vec_s[ v3 ], + vec_s[ v4 ], + vec_s[ v5 ], + vec_s[ v6 ], + vec_s[ v7 ] + ]; + + // Recurse iterations + if ( -- iterations >= 0 ) { + + var tmp = []; + + Array.prototype.push.apply( tmp, hilbert3D( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 1 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 2 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 3 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 4 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 5 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 6 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) ); + Array.prototype.push.apply( tmp, hilbert3D( vec[ 7 ], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7 ) ); + + // Return recursive call + return tmp; + + } + + // Return complete Hilbert Curve. + return vec; + +} diff --git a/three/jsutil/libs/ammo.js b/three/jsutil/libs/ammo.js new file mode 100644 index 000000000..24cd1aa99 --- /dev/null +++ b/three/jsutil/libs/ammo.js @@ -0,0 +1,31 @@ + +// This is ammo.js, a port of Bullet Physics to JavaScript. zlib licensed. +var AmmoLib = function(Module) { + Module = Module || {}; + +var Module;if(!Module)Module=(typeof AmmoLib!=="undefined"?AmmoLib:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=console.log;if(!Module["printErr"])Module["printErr"]=console.warn;var nodeFS;var nodePath;Module["read"]=function read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.join(__dirname,"..","src",filename);ret=nodeFS["readFileSync"](filename)}if(ret&&!binary)ret=ret.toString();return ret};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response)}else{onerror()}};xhr.onerror=onerror;xhr.send(null)};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.warn(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){abort("NO_DYNAMIC_EXECUTION=1 was set, cannot eval")}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,prepVararg:(function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr}),getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){if(!args.splice)args=Array.prototype.slice.call(args);args.splice(0,0,ptr);return Module["dynCall_"+sig].apply(null,args)}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[],addFunction:(function(func){for(var i=0;i=TOTAL_MEMORY){var success=enlargeMemory();if(!success){DYNAMICTOP=ret;return 0}}return ret}),alignMemory:(function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret}),makeBigInt:(function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret}),GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];if(!func){abort("NO_DYNAMIC_EXECUTION=1 was set, cannot eval")}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var ccall;((function(){var JSfuncs={"stackSave":(function(){Runtime.stackSave()}),"stackRestore":(function(){Runtime.stackRestore()}),"arrayToC":(function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=Runtime.stackAlloc((str.length<<2)+1);writeStringToMemory(str,ret)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}var ALLOC_NORMAL=0;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[typeof _malloc==="function"?_malloc:Runtime.staticAlloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}function UTF8ArrayToString(u8Array,idx){var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}function demangle(func){var hasLibcxxabi=!!Module["___cxa_demangle"];if(hasLibcxxabi){try{var buf=_malloc(func.length);writeStringToMemory(func.substr(1),buf);var status=_malloc(4);var ret=Module["___cxa_demangle"](buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){return func}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}}Runtime.warnOnce("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling");return func}function demangleAll(text){return text.replace(/__Z[\w\d_]+/g,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){return demangleAll(jsStackTrace())}var PAGE_SIZE=4096;function alignMemoryPage(x){if(x%4096>0){x+=4096-x%4096}return x}var HEAP;var buffer;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE=0,STATICTOP=0,staticSealed=false;var STACK_BASE=0,STACKTOP=0,STACK_MAX=0;var DYNAMIC_BASE=0,DYNAMICTOP=0;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||67108864;var totalMemory=64*1024;while(totalMemory0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Runtime.dynCall("v",func)}else{Runtime.dynCall("vi",func,[callback.arg])}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function writeStringToMemory(string,buffer,dontAddNull){var array=intArrayFromString(string,dontAddNull);var i=0;while(i>0]=chr;i=i+1}}function writeArrayToMemory(array,buffer){for(var i=0;i>0]=array[i]}}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=(function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32});Math.clz32=Math["clz32"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_min=Math.min;var Math_clz32=Math.clz32;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;Module["preloadedImages"]={};Module["preloadedAudios"]={};var ASM_CONSTS=[(function($0,$1,$2,$3,$4,$5,$6,$7){{var self=Module["getCache"](Module["ConcreteContactResultCallback"])[$0];if(!self.hasOwnProperty("addSingleResult"))throw"a JSImplementation must implement all functions, you forgot ConcreteContactResultCallback::addSingleResult.";return self["addSingleResult"]($1,$2,$3,$4,$5,$6,$7)}})];function _emscripten_asm_const_diiiiiiii(code,a0,a1,a2,a3,a4,a5,a6,a7){return ASM_CONSTS[code](a0,a1,a2,a3,a4,a5,a6,a7)}STATIC_BASE=8;STATICTOP=STATIC_BASE+26272;__ATINIT__.push({func:(function(){__GLOBAL__sub_I_btQuickprof_cpp()})});allocate([88,37,0,0,220,37,0,0,128,37,0,0,7,38,0,0,8,0,0,0,0,0,0,0,88,37,0,0,57,38,0,0,88,37,0,0,78,38,0,0,128,37,0,0,94,38,0,0,40,0,0,0,0,0,0,0,88,37,0,0,117,38,0,0,128,37,0,0,145,38,0,0,64,0,0,0,0,0,0,0,88,37,0,0,167,38,0,0,128,37,0,0,207,38,0,0,88,0,0,0,0,0,0,0,88,37,0,0,254,38,0,0,128,37,0,0,42,39,0,0,112,0,0,0,0,0,0,0,128,37,0,0,114,40,0,0,152,0,0,0,0,0,0,0,88,37,0,0,140,40,0,0,128,37,0,0,159,40,0,0,0,4,0,0,0,0,0,0,128,37,0,0,203,40,0,0,192,0,0,0,0,0,0,0,88,37,0,0,248,40,0,0,128,37,0,0,25,41,0,0,192,0,0,0,0,0,0,0,128,37,0,0,71,41,0,0,192,0,0,0,0,0,0,0,128,37,0,0,123,41,0,0,192,0,0,0,0,0,0,0,128,37,0,0,182,41,0,0,176,3,0,0,0,0,0,0,128,37,0,0,136,42,0,0,24,1,0,0,0,0,0,0,88,37,0,0,168,42,0,0,88,37,0,0,187,42,0,0,128,37,0,0,208,42,0,0,32,1,0,0,0,0,0,0,128,37,0,0,230,42,0,0,48,8,0,0,0,0,0,0,128,37,0,0,60,43,0,0,24,1,0,0,0,0,0,0,128,37,0,0,95,43,0,0,104,1,0,0,0,0,0,0,128,37,0,0,129,43,0,0,24,1,0,0,0,0,0,0,128,37,0,0,162,43,0,0,176,7,0,0,0,0,0,0,128,37,0,0,230,43,0,0,104,1,0,0,0,0,0,0,128,37,0,0,8,44,0,0,24,1,0,0,0,0,0,0,128,37,0,0,42,44,0,0,184,1,0,0,0,0,0,0,88,37,0,0,74,44,0,0,128,37,0,0,97,44,0,0,184,1,0,0,0,0,0,0,128,37,0,0,135,44,0,0,208,7,0,0,0,0,0,0,128,37,0,0,164,44,0,0,208,7,0,0,0,0,0,0,88,37,0,0,68,45,0,0,128,37,0,0,97,45,0,0,120,7,0,0,0,0,0,0,128,37,0,0,124,45,0,0,96,2,0,0,0,0,0,0,128,37,0,0,159,45,0,0,40,2,0,0,0,0,0,0,128,37,0,0,185,45,0,0,56,2,0,0,0,0,0,0,88,37,0,0,211,45,0,0,128,37,0,0,37,46,0,0,184,1,0,0,0,0,0,0,128,37,0,0,68,46,0,0,176,3,0,0,0,0,0,0,128,37,0,0,103,46,0,0,112,2,0,0,0,0,0,0,128,37,0,0,129,46,0,0,40,5,0,0,0,0,0,0,128,37,0,0,36,47,0,0,16,0,0,0,0,0,0,0,128,37,0,0,53,48,0,0,160,2,0,0,0,0,0,0,88,37,0,0,83,48,0,0,128,37,0,0,129,48,0,0,184,2,0,0,0,0,0,0,188,37,0,0,155,48,0,0,0,0,0,0,1,0,0,0,208,2,0,0,2,4,0,0,88,37,0,0,175,48,0,0,128,37,0,0,219,48,0,0,168,2,0,0,0,0,0,0,128,37,0,0,29,49,0,0,184,2,0,0,0,0,0,0,128,37,0,0,115,49,0,0,184,2,0,0,0,0,0,0,128,37,0,0,159,49,0,0,184,2,0,0,0,0,0,0,128,37,0,0,209,49,0,0,184,2,0,0,0,0,0,0,128,37,0,0,0,50,0,0,56,3,0,0,0,0,0,0,88,37,0,0,38,50,0,0,128,37,0,0,133,50,0,0,80,3,0,0,0,0,0,0,88,37,0,0,152,50,0,0,128,37,0,0,172,50,0,0,32,0,0,0,0,0,0,0,128,37,0,0,200,50,0,0,120,3,0,0,0,0,0,0,128,37,0,0,233,50,0,0,80,3,0,0,0,0,0,0,128,37,0,0,10,51,0,0,16,0,0,0,0,0,0,0,128,37,0,0,56,51,0,0,168,3,0,0,0,0,0,0,88,37,0,0,81,51,0,0,88,37,0,0,96,51,0,0,128,37,0,0,143,51,0,0,176,3,0,0,0,0,0,0,128,37,0,0,159,51,0,0,184,3,0,0,0,0,0,0,128,37,0,0,186,51,0,0,136,9,0,0,0,0,0,0,128,37,0,0,210,51,0,0,248,3,0,0,0,0,0,0,88,37,0,0,236,51,0,0,128,37,0,0,0,52,0,0,16,4,0,0,0,0,0,0,88,37,0,0,34,52,0,0,128,37,0,0,61,52,0,0,192,0,0,0,0,0,0,0,128,37,0,0,111,52,0,0,192,0,0,0,0,0,0,0,128,37,0,0,168,52,0,0,192,0,0,0,0,0,0,0,128,37,0,0,213,52,0,0,192,0,0,0,0,0,0,0,128,37,0,0,10,53,0,0,192,0,0,0,0,0,0,0,128,37,0,0,62,53,0,0,192,0,0,0,0,0,0,0,128,37,0,0,95,53,0,0,192,0,0,0,0,0,0,0,128,37,0,0,144,53,0,0,192,0,0,0,0,0,0,0,128,37,0,0,195,53,0,0,192,0,0,0,0,0,0,0,128,37,0,0,238,53,0,0,192,0,0,0,0,0,0,0,88,37,0,0,30,54,0,0,128,37,0,0,101,54,0,0,184,1,0,0,0,0,0,0,128,37,0,0,135,54,0,0,56,10,0,0,0,0,0,0,128,37,0,0,171,54,0,0,208,7,0,0,0,0,0,0,128,37,0,0,198,54,0,0,208,7,0,0,0,0,0,0,128,37,0,0,100,55,0,0,56,10,0,0,0,0,0,0,128,37,0,0,129,55,0,0,32,5,0,0,0,0,0,0,88,37,0,0,148,55,0,0,88,37,0,0,196,55,0,0,188,37,0,0,189,56,0,0,0,0,0,0,2,0,0,0,208,7,0,0,2,0,0,0,216,7,0,0,2,4,0,0,128,37,0,0,209,56,0,0,40,2,0,0,0,0,0,0,128,37,0,0,231,56,0,0,152,9,0,0,0,0,0,0,128,37,0,0,122,57,0,0,152,9,0,0,0,0,0,0,128,37,0,0,15,58,0,0,24,1,0,0,0,0,0,0,128,37,0,0,141,58,0,0,88,0,0,0,0,0,0,0,128,37,0,0,78,59,0,0,168,9,0,0,0,0,0,0,128,37,0,0,253,59,0,0,168,9,0,0,0,0,0,0,128,37,0,0,194,60,0,0,8,0,0,0,0,0,0,0,128,37,0,0,111,61,0,0,40,2,0,0,0,0,0,0,128,37,0,0,135,61,0,0,56,2,0,0,0,0,0,0,128,37,0,0,161,61,0,0,16,5,0,0,0,0,0,0,128,37,0,0,187,61,0,0,56,10,0,0,0,0,0,0,128,37,0,0,224,61,0,0,192,0,0,0,0,0,0,0,128,37,0,0,8,62,0,0,56,10,0,0,0,0,0,0,128,37,0,0,34,62,0,0,32,5,0,0,0,0,0,0,128,37,0,0,167,62,0,0,32,5,0,0,0,0,0,0,128,37,0,0,52,63,0,0,16,5,0,0,0,0,0,0,128,37,0,0,79,63,0,0,56,10,0,0,0,0,0,0,128,37,0,0,110,63,0,0,24,1,0,0,0,0,0,0,128,37,0,0,135,63,0,0,56,10,0,0,0,0,0,0,128,37,0,0,174,63,0,0,24,1,0,0,0,0,0,0,128,37,0,0,207,63,0,0,152,7,0,0,0,0,0,0,128,37,0,0,23,64,0,0,176,7,0,0,0,0,0,0,128,37,0,0,58,64,0,0,176,6,0,0,0,0,0,0,128,37,0,0,79,64,0,0,176,6,0,0,0,0,0,0,128,37,0,0,100,64,0,0,176,7,0,0,0,0,0,0,128,37,0,0,123,64,0,0,56,7,0,0,0,0,0,0,128,37,0,0,188,64,0,0,16,7,0,0,0,0,0,0,88,37,0,0,42,65,0,0,128,37,0,0,66,65,0,0,16,7,0,0,0,0,0,0,128,37,0,0,170,65,0,0,16,7,0,0,0,0,0,0,128,37,0,0,27,66,0,0,48,8,0,0,0,0,0,0,128,37,0,0,62,66,0,0,216,7,0,0,0,0,0,0,128,37,0,0,164,66,0,0,208,7,0,0,0,0,0,0,128,37,0,0,188,66,0,0,48,8,0,0,0,0,0,0,128,37,0,0,244,66,0,0,176,7,0,0,0,0,0,0,128,37,0,0,14,67,0,0,120,7,0,0,0,0,0,0,88,37,0,0,51,67,0,0,128,37,0,0,91,67,0,0,152,7,0,0,0,0,0,0,128,37,0,0,107,67,0,0,160,7,0,0,0,0,0,0,128,37,0,0,131,67,0,0,136,7,0,0,0,0,0,0,88,37,0,0,180,67,0,0,88,37,0,0,201,67,0,0,128,37,0,0,235,67,0,0,176,7,0,0,0,0,0,0,128,37,0,0,28,68,0,0,224,7,0,0,0,0,0,0,128,37,0,0,55,68,0,0,224,7,0,0,0,0,0,0,128,37,0,0,82,68,0,0,136,7,0,0,0,0,0,0,128,37,0,0,124,68,0,0,216,7,0,0,0,0,0,0,128,37,0,0,153,68,0,0,152,7,0,0,0,0,0,0,128,37,0,0,170,68,0,0,120,7,0,0,0,0,0,0,128,37,0,0,187,68,0,0,144,9,0,0,0,0,0,0,128,37,0,0,204,68,0,0,216,7,0,0,0,0,0,0,128,37,0,0,48,69,0,0,216,7,0,0,0,0,0,0,128,37,0,0,139,69,0,0,48,8,0,0,0,0,0,0,128,37,0,0,179,69,0,0,176,7,0,0,0,0,0,0,128,37,0,0,227,69,0,0,144,8,0,0,0,0,0,0,128,37,0,0,0,70,0,0,144,8,0,0,0,0,0,0,128,37,0,0,29,70,0,0,152,10,0,0,0,0,0,0,128,37,0,0,46,70,0,0,224,8,0,0,0,0,0,0,88,37,0,0,72,70,0,0,128,37,0,0,96,70,0,0,248,8,0,0,0,0,0,0,128,37,0,0,114,70,0,0,64,0,0,0,0,0,0,0,128,37,0,0,139,70,0,0,208,8,0,0,0,0,0,0,128,37,0,0,154,70,0,0,248,8,0,0,0,0,0,0,128,37,0,0,185,70,0,0,248,3,0,0,0,0,0,0,128,37,0,0,58,71,0,0,248,3,0,0,0,0,0,0,128,37,0,0,168,71,0,0,224,8,0,0,0,0,0,0,128,37,0,0,187,71,0,0,24,1,0,0,0,0,0,0,128,37,0,0,208,71,0,0,24,1,0,0,0,0,0,0,128,37,0,0,230,71,0,0,24,1,0,0,0,0,0,0,88,37,0,0,253,71,0,0,88,37,0,0,12,72,0,0,128,37,0,0,120,72,0,0,208,7,0,0,0,0,0,0,128,37,0,0,148,72,0,0,208,7,0,0,0,0,0,0,128,37,0,0,179,72,0,0,200,9,0,0,0,0,0,0,88,37,0,0,215,72,0,0,128,37,0,0,248,72,0,0,32,5,0,0,0,0,0,0,128,37,0,0,163,73,0,0,200,9,0,0,0,0,0,0,128,37,0,0,196,73,0,0,168,3,0,0,0,0,0,0,128,37,0,0,214,73,0,0,32,5,0,0,0,0,0,0,128,37,0,0,233,73,0,0,168,3,0,0,0,0,0,0,128,37,0,0,7,74,0,0,48,10,0,0,0,0,0,0,88,37,0,0,27,74,0,0,128,37,0,0,66,74,0,0,184,1,0,0,0,0,0,0,128,37,0,0,99,74,0,0,184,1,0,0,0,0,0,0,128,37,0,0,118,74,0,0,56,10,0,0,0,0,0,0,128,37,0,0,153,74,0,0,48,10,0,0,0,0,0,0,128,37,0,0,172,74,0,0,48,10,0,0,0,0,0,0,88,37,0,0,197,74,0,0,88,37,0,0,223,74,0,0,128,37,0,0,244,74,0,0,168,10,0,0,0,0,0,0,88,37,0,0,17,75,0,0,88,37,0,0,74,86,0,0,128,37,0,0,40,86,0,0,216,10,0,0,0,0,0,0,128,37,0,0,213,85,0,0,184,10,0,0,0,0,0,0,128,37,0,0,250,85,0,0,232,10,0,0,0,0,0,0,88,37,0,0,27,86,0,0,128,37,0,0,16,87,0,0,176,10,0,0,0,0,0,0,128,37,0,0,80,87,0,0,216,10,0,0,0,0,0,0,128,37,0,0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,12,0,0,0,0,0,0,0,8,2,0,0,47,0,0,0,48,0,0,0,49,0,0,0,50,0,0,0,19,0,0,0,23,0,0,0,51,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,20,0,0,0,52,0,0,0,21,0,0,0,1,0,0,0,19,0,0,0,22,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,53,0,0,0,27,0,0,0,16,0,0,0,28,0,0,0,29,0,0,0,24,0,0,0,25,0,0,0,8,0,0,0,9,0,0,0,26,0,0,0,54,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,8,0,0,0,9,0,0,0,55,0,0,0,34,0,0,0,10,0,0,0,11,0,0,0,12,0,0,0,56,0,0,0,35,0,0,0,13,0,0,0,0,0,0,0,24,2,0,0,57,0,0,0,58,0,0,0,10,0,0,0,0,0,0,0,64,2,0,0,59,0,0,0,60,0,0,0,4,0,0,0,3,0,0,0,36,0,0,0,0,0,0,0,80,2,0,0,11,0,0,0,61,0,0,0,62,0,0,0,37,0,0,0,27,0,0,0,6,0,0,0,38,0,0,0,0,0,0,0,96,2,0,0,63,0,0,0,64,0,0,0,49,0,0,0,50,0,0,0,19,0,0,0,23,0,0,0,65,0,0,0,13,0,0,0,17,0,0,0,15,0,0,0,39,0,0,0,52,0,0,0,40,0,0,0,1,0,0,0,19,0,0,0,22,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,53,0,0,0,27,0,0,0,16,0,0,0,28,0,0,0,29,0,0,0,24,0,0,0,25,0,0,0,8,0,0,0,9,0,0,0,28,0,0,0,54,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,14,0,0,0,9,0,0,0,55,0,0,0,34,0,0,0,10,0,0,0,15,0,0,0,12,0,0,0,56,0,0,0,35,0,0,0,13,0,0,0,0,0,0,0,128,2,0,0,66,0,0,0,67,0,0,0,12,0,0,0,3,0,0,0,0,0,0,0,144,2,0,0,68,0,0,0,69,0,0,0,1,0,0,0,0,0,0,0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,53,0,0,0,54,0,0,0,4,0,0,0,55,0,0,0,56,0,0,0,57,0,0,0,5,0,0,0,37,0,0,0,93,0,0,0,38,0,0,0,58,0,0,0,0,0,0,0,136,3,0,0,66,0,0,0,94,0,0,0,1,0,0,0,9,0,0,0,0,0,0,0,152,3,0,0,95,0,0,0,96,0,0,0,1,0,0,0,10,215,163,60,1,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,176,3,0,0,4,0,0,0,97,0,0,0,98,0,0,0,37,0,0,0,39,0,0,0,14,0,0,0,7,0,0,0,0,0,0,0,184,3,0,0,4,0,0,0,99,0,0,0,100,0,0,0,37,0,0,0,39,0,0,0,14,0,0,0,7,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,200,3,0,0,4,0,0,0,101,0,0,0,102,0,0,0,37,0,0,0,39,0,0,0,14,0,0,0,7,0,0,0,25,0,0,0,21,0,0,0,0,0,0,0,216,3,0,0,103,0,0,0,104,0,0,0,7,0,0,0,15,0,0,0,59,0,0,0,60,0,0,0,16,0,0,0,17,0,0,0,22,0,0,0,40,0,0,0,13,0,0,0,41,0,0,0,42,0,0,0,43,0,0,0,14,0,0,0,61,0,0,0,0,0,0,0,232,3,0,0,105,0,0,0,106,0,0,0,15,0,0,0,0,0,0,0,0,4,0,0,107,0,0,0,108,0,0,0,5,0,0,0,6,0,0,0,18,0,0,0,7,0,0,0,0,0,0,0,24,4,0,0,16,0,0,0,109,0,0,0,8,0,0,0,0,0,0,0,40,4,0,0,16,0,0,0,110,0,0,0,9,0,0,0,0,0,0,0,56,4,0,0,16,0,0,0,111,0,0,0,10,0,0,0,0,0,0,0,72,4,0,0,16,0,0,0,112,0,0,0,11,0,0,0,0,0,0,0,88,4,0,0,16,0,0,0,113,0,0,0,12,0,0,0,0,0,0,0,104,4,0,0,16,0,0,0,114,0,0,0,13,0,0,0,0,0,0,0,120,4,0,0,16,0,0,0,115,0,0,0,14,0,0,0,0,0,0,0,136,4,0,0,16,0,0,0,116,0,0,0,15,0,0,0,0,0,0,0,152,4,0,0,16,0,0,0,117,0,0,0,16,0,0,0,0,0,0,0,168,4,0,0,16,0,0,0,118,0,0,0,17,0,0,0,0,0,0,0,184,4,0,0,119,0,0,0,120,0,0,0,26,0,0,0,62,0,0,0,0,0,0,0,192,4,0,0,121,0,0,0,122,0,0,0,5,0,0,0,4,0,0,0,63,0,0,0,0,0,0,0,208,4,0,0,123,0,0,0,124,0,0,0,6,0,0,0,5,0,0,0,64,0,0,0,0,0,0,0,224,4,0,0,125,0,0,0,126,0,0,0,23,0,0,0,0,0,0,0,240,4,0,0,41,0,0,0,127,0,0,0,24,0,0,0,0,0,0,0,0,5,0,0,128,0,0,0,129,0,0,0,7,0,0,0,6,0,0,0,65,0,0,0,0,0,0,0,16,5,0,0,130,0,0,0,131,0,0,0,27,0,0,0,28,0,0,0,3,0,0,0,0,0,0,0,40,5,0,0,132,0,0,0,133,0,0,0,49,0,0,0,50,0,0,0,19,0,0,0,23,0,0,0,134,0,0,0,13,0,0,0,17,0,0,0,25,0,0,0,66,0,0,0,52,0,0,0,67,0,0,0,0,0,0,0,48,5,0,0,135,0,0,0,136,0,0,0,26,0,0,0,27,0,0,0,252,255,255,255,48,5,0,0,137,0,0,0,138,0,0,0,28,0,0,0,0,0,0,0,80,5,0,0,57,0,0,0,139,0,0,0,16,0,0,0,0,0,0,0,96,5,0,0,41,0,0,0,140,0,0,0,29,0,0,0,1,0,0,0,0,0,0,0,112,5,0,0,41,0,0,0,141,0,0,0,29,0,0,0,2,0,0,0,0,0,0,0,128,5,0,0,23,0,0,0,142,0,0,0,7,0,0,0,68,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,144,5,0,0,143,0,0,0,144,0,0,0,17,0,0,0,10,0,0,0,0,0,0,0,160,5,0,0,41,0,0,0,145,0,0,0,30,0,0,0,1,0,0,0,0,0,0,0,176,5,0,0,41,0,0,0,146,0,0,0,30,0,0,0,2,0,0,0,0,0,0,0,192,5,0,0,66,0,0,0,147,0,0,0,18,0,0,0,11,0,0,0,0,0,0,0,208,5,0,0,57,0,0,0,148,0,0,0,19,0,0,0,0,0,0,0,224,5,0,0,57,0,0,0,149,0,0,0,20,0,0,0,0,0,0,0,240,5,0,0,130,0,0,0,150,0,0,0,27,0,0,0,28,0,0,0,4,0,0,0,0,0,0,0,0,6,0,0,151,0,0,0,152,0,0,0,8,0,0,0,7,0,0,0,69,0,0,0,0,0,0,0,16,6,0,0,153,0,0,0,154,0,0,0,18,0,0,0,0,0,0,0,32,6,0,0,155,0,0,0,156,0,0,0,9,0,0,0,8,0,0,0,70,0,0,0,0,0,0,0,48,6,0,0,130,0,0,0,157,0,0,0,29,0,0,0,30,0,0,0,5,0,0,0,0,0,0,0,64,6,0,0,130,0,0,0,158,0,0,0,31,0,0,0,32,0,0,0,6,0,0,0,0,0,0,0,80,6,0,0,130,0,0,0,159,0,0,0,27,0,0,0,28,0,0,0,7,0,0,0,0,0,0,0,96,6,0,0,160,0,0,0,161,0,0,0,10,0,0,0,9,0,0,0,71,0,0,0,0,0,0,0,112,6,0,0,23,0,0,0,162,0,0,0,7,0,0,0,72,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,128,6,0,0,163,0,0,0,164,0,0,0,11,0,0,0,10,0,0,0,73,0,0,0,0,0,0,0,144,6,0,0,23,0,0,0,165,0,0,0,33,0,0,0,15,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,160,6,0,0,166,0,0,0,167,0,0,0,31,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,74,0,0,0,44,0,0,0,5,0,0,0,45,0,0,0,10,0,0,0,18,0,0,0,5,0,0,0,46,0,0,0,19,0,0,0,11,0,0,0,75,0,0,0,168,0,0,0,0,0,0,0,176,6,0,0,31,0,0,0,169,0,0,0,32,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,76,0,0,0,13,0,0,0,6,0,0,0,47,0,0,0,77,0,0,0,7,0,0,0,4,0,0,0,48,0,0,0,20,0,0,0,11,0,0,0,34,0,0,0,35,0,0,0,1,0,0,0,33,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,0,0,0,0,192,6,0,0,31,0,0,0,170,0,0,0,32,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,76,0,0,0,13,0,0,0,6,0,0,0,49,0,0,0,78,0,0,0,7,0,0,0,4,0,0,0,48,0,0,0,20,0,0,0,11,0,0,0,34,0,0,0,35,0,0,0,1,0,0,0,33,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,0,0,0,0,208,6,0,0,31,0,0,0,171,0,0,0,32,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,76,0,0,0,13,0,0,0,6,0,0,0,50,0,0,0,79,0,0,0,7,0,0,0,4,0,0,0,48,0,0,0,20,0,0,0,11,0,0,0,34,0,0,0,35,0,0,0,1,0,0,0,33,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,0,0,0,0,224,6,0,0,31,0,0,0,172,0,0,0,34,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,14,0,0,0,13,0,0,0,7,0,0,0,51,0,0,0,10,0,0,0,19,0,0,0,6,0,0,0,15,0,0,0,5,0,0,0,11,0,0,0,36,0,0,0,37,0,0,0,1,0,0,0,35,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,0,0,0,0,240,6,0,0,173,0,0,0,174,0,0,0,36,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,80,0,0,0,52,0,0,0,8,0,0,0,53,0,0,0,10,0,0,0,4,0,0,0,2,0,0,0,54,0,0,0,21,0,0,0,11,0,0,0,37,0,0,0,38,0,0,0,39,0,0,0,81,0,0,0,82,0,0,0,0,0,0,0,0,7,0,0,175,0,0,0,176,0,0,0,40,0,0,0,0,0,0,0,24,7,0,0,175,0,0,0,177,0,0,0,41,0,0,0,0,0,0,0,40,7,0,0,175,0,0,0,178,0,0,0,42,0,0,0,0,0,0,0,56,7,0,0,179,0,0,0,180,0,0,0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,77,0,0,0,57,0,0,0,4,0,0,0,55,0,0,0,0,0,0,0,80,8,0,0,195,0,0,0,196,0,0,0,19,0,0,0,78,0,0,0,25,0,0,0,90,0,0,0,91,0,0,0,20,0,0,0,0,0,0,0,96,8,0,0,181,0,0,0,197,0,0,0,58,0,0,0,0,0,0,0,112,8,0,0,181,0,0,0,198,0,0,0,59,0,0,0,0,0,0,0,128,8,0,0,199,0,0,0,200,0,0,0,60,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,92,0,0,0,79,0,0,0,13,0,0,0,80,0,0,0,10,0,0,0,4,0,0,0,2,0,0,0,12,0,0,0,4,0,0,0,11,0,0,0,61,0,0,0,12,0,0,0,0,0,0,0,144,8,0,0,31,0,0,0,201,0,0,0,62,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,93,0,0,0,13,0,0,0,14,0,0,0,81,0,0,0,94,0,0,0,22,0,0,0,4,0,0,0,82,0,0,0,26,0,0,0,11,0,0,0,56,0,0,0,57,0,0,0,1,0,0,0,63,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,7,0,0,0,0,0,0,0,160,8,0,0,31,0,0,0,202,0,0,0,62,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,93,0,0,0,13,0,0,0,14,0,0,0,83,0,0,0,94,0,0,0,22,0,0,0,4,0,0,0,82,0,0,0,26,0,0,0,11,0,0,0,56,0,0,0,58,0,0,0,1,0,0,0,64,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,8,0,0,0,0,0,0,0,176,8,0,0,31,0,0,0,203,0,0,0,62,0,0,0,8,0,0,0,1,0,0,0,1,0,0,0,93,0,0,0,13,0,0,0,14,0,0,0,84,0,0,0,94,0,0,0,22,0,0,0,4,0,0,0,82,0,0,0,26,0,0,0,11,0,0,0,56,0,0,0,59,0,0,0,1,0,0,0,65,0,0,0,5,0,0,0,16,0,0,0,11,0,0,0,9,0,0,0,0,0,0,0,192,8,0,0,204,0,0,0,205,0,0,0,66,0,0,0,1,0,0,0,2,0,0,0,95,0,0,0,96,0,0,0,85,0,0,0,97,0,0,0,98,0,0,0,86,0,0,0,60,0,0,0,61,0,0,0,87,0,0,0,27,0,0,0,0,0,0,0,208,8,0,0,206,0,0,0,207,0,0,0,1,0,0,0,62,0,0,0,12,0,0,0,67,0,0,0,2,0,0,0,68,0,0,0,99,0,0,0,88,0,0,0,89,0,0,0,63,0,0,0,100,0,0,0,208,0,0,0,0,0,0,0,232,8,0,0,209,0,0,0,210,0,0,0,28,0,0,0,21,0,0,0,64,0,0,0,90,0,0,0,91,0,0,0,92,0,0,0,65,0,0,0,93,0,0,0,66,0,0,0,101,0,0,0,67,0,0,0,29,0,0,0,94,0,0,0,102,0,0,0,103,0,0,0,0,0,0,0,8,9,0,0,206,0,0,0,211,0,0,0,1,0,0,0,62,0,0,0,12,0,0,0,67,0,0,0,2,0,0,0,68,0,0,0,99,0,0,0,88,0,0,0,89,0,0,0,63,0,0,0,100,0,0,0,208,0,0,0,0,0,0,0,24,9,0,0,212,0,0,0,213,0,0,0,30,0,0,0,22,0,0,0,68,0,0,0,95,0,0,0,96,0,0,0,97,0,0,0,69,0,0,0,98,0,0,0,70,0,0,0,104,0,0,0,71,0,0,0,31,0,0,0,99,0,0,0,105,0,0,0,106,0,0,0,0,0,0,0,40,9,0,0,105,0,0,0,214,0,0,0,21,0,0,0,0,0,0,0,56,9,0,0,105,0,0,0,215,0,0,0,22,0,0,0,0,0,0,0,72,9,0,0,216,0,0,0,217,0,0,0,2,0,0,0,72,0,0,0,13,0,0,0,69,0,0,0,3,0,0,0,70,0,0,0,107,0,0,0,100,0,0,0,101,0,0,0,73,0,0,0,108,0,0,0,218,0,0,0,0,0,0,0,88,9,0,0,23,0,0,0,219,0,0,0,74,0,0,0,109,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,104,9,0,0,23,0,0,0,220,0,0,0,7,0,0,0,110,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,120,9,0,0,23,0,0,0,221,0,0,0,7,0,0,0,111,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,144,9,0,0,222,0,0,0,223,0,0,0,19,0,0,0,78,0,0,0,25,0,0,0,90,0,0,0,91,0,0,0,0,0,0,0,168,9,0,0,41,0,0,0,224,0,0,0,30,0,0,0,1,0,0,0,0,0,0,0,184,9,0,0,225,0,0,0,226,0,0,0,1,0,0,0,0,0,0,0,208,9,0,0,130,0,0,0,227,0,0,0,75,0,0,0,76,0,0,0,8,0,0,0,0,0,0,0,224,9,0,0,225,0,0,0,228,0,0,0,2,0,0,0,0,0,0,0,240,9,0,0,95,0,0,0,229,0,0,0,2,0,0,0,0,0,0,0,0,10,0,0,130,0,0,0,230,0,0,0,77,0,0,0,78,0,0,0,9,0,0,0,0,0,0,0,16,10,0,0,95,0,0,0,231,0,0,0,3,0,0,0,0,0,0,0,32,10,0,0,232,0,0,0,233,0,0,0,14,0,0,0,0,0,0,0,72,10,0,0,234,0,0,0,235,0,0,0,15,0,0,0,11,0,0,0,112,0,0,0,0,0,0,0,88,10,0,0,236,0,0,0,237,0,0,0,16,0,0,0,12,0,0,0,113,0,0,0,0,0,0,0,104,10,0,0,232,0,0,0,238,0,0,0,17,0,0,0,0,0,0,0,120,10,0,0,232,0,0,0,239,0,0,0,18,0,0,0,0,0,0,0,136,10,0,0,240,0,0,0,241,0,0,0,32,0,0,0,33,0,0,0,102,0,0,0,0,0,0,0,144,10,0,0,242,0,0,0,243,0,0,0,0,0,0,0,152,10,0,0,244,0,0,0,245,0,0,0,66,0,0,0,1,0,0,0,2,0,0,0,95,0,0,0,96,0,0,0,85,0,0,0,114,0,0,0,115,0,0,0,86,0,0,0,60,0,0,0,61,0,0,0,87,0,0,0,27,0,0,0,96,100,0,0,255,255,255,255,5,0,0,0,0,0,0,0,0,0,0,0,103,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,0,0,0,35,0,0,0,157,102,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,184,10,0,0,246,0,0,0,247,0,0,0,248,0,0,0,249,0,0,0,36,0,0,0,4,0,0,0,19,0,0,0,71,0,0,0,0,0,0,0,200,10,0,0,246,0,0,0,250,0,0,0,248,0,0,0,249,0,0,0,36,0,0,0,5,0,0,0,20,0,0,0,72,0,0,0,0,0,0,0,240,10,0,0,251,0,0,0,252,0,0,0,104,0,0,0,0,0,0,0,32,11,0,0,246,0,0,0,253,0,0,0,248,0,0,0,249,0,0,0,36,0,0,0,6,0,0,0,21,0,0,0,73,0,0,0,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,48,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,0,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,55,67,108,111,115,101,115,116,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,0,49,56,98,116,86,101,104,105,99,108,101,82,97,121,99,97,115,116,101,114,0,49,51,98,116,77,111,116,105,111,110,83,116,97,116,101,0,50,48,98,116,68,101,102,97,117,108,116,77,111,116,105,111,110,83,116,97,116,101,0,50,53,98,116,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,67,97,108,108,98,97,99,107,0,49,57,98,116,71,104,111,115,116,80,97,105,114,67,97,108,108,98,97,99,107,0,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,49,55,82,97,121,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,0,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,52,67,108,111,115,101,115,116,82,97,121,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,0,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,49,67,111,110,116,97,99,116,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,0,50,57,67,111,110,99,114,101,116,101,67,111,110,116,97,99,116,82,101,115,117,108,116,67,97,108,108,98,97,99,107,0,123,32,118,97,114,32,115,101,108,102,32,61,32,77,111,100,117,108,101,91,39,103,101,116,67,97,99,104,101,39,93,40,77,111,100,117,108,101,91,39,67,111,110,99,114,101,116,101,67,111,110,116,97,99,116,82,101,115,117,108,116,67,97,108,108,98,97,99,107,39,93,41,91,36,48,93,59,32,105,102,32,40,33,115,101,108,102,46,104,97,115,79,119,110,80,114,111,112,101,114,116,121,40,39,97,100,100,83,105,110,103,108,101,82,101,115,117,108,116,39,41,41,32,116,104,114,111,119,32,39,97,32,74,83,73,109,112,108,101,109,101,110,116,97,116,105,111,110,32,109,117,115,116,32,105,109,112,108,101,109,101,110,116,32,97,108,108,32,102,117,110,99,116,105,111,110,115,44,32,121,111,117,32,102,111,114,103,111,116,32],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE);allocate([67,111,110,99,114,101,116,101,67,111,110,116,97,99,116,82,101,115,117,108,116,67,97,108,108,98,97,99,107,58,58,97,100,100,83,105,110,103,108,101,82,101,115,117,108,116,46,39,59,32,114,101,116,117,114,110,32,115,101,108,102,91,39,97,100,100,83,105,110,103,108,101,82,101,115,117,108,116,39,93,40,36,49,44,36,50,44,36,51,44,36,52,44,36,53,44,36,54,44,36,55,41,59,32,125,0,50,51,98,116,68,101,102,97,117,108,116,83,111,102,116,66,111,100,121,83,111,108,118,101,114,0,49,54,98,116,83,111,102,116,66,111,100,121,83,111,108,118,101,114,0,52,49,98,116,83,111,102,116,66,111,100,121,82,105,103,105,100,66,111,100,121,67,111,108,108,105,115,105,111,110,67,111,110,102,105,103,117,114,97,116,105,111,110,0,78,50,56,98,116,83,111,102,116,83,111,102,116,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,51,48,98,116,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,67,114,101,97,116,101,70,117,110,99,0,78,50,57,98,116,83,111,102,116,82,105,103,105,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,53,98,116,83,111,102,116,66,111,100,121,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,53,98,116,83,111,102,116,66,111,100,121,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,55,83,119,97,112,112,101,100,67,114,101,97,116,101,70,117,110,99,69,0,49,48,98,116,83,111,102,116,66,111,100,121,0,83,111,102,116,66,111,100,121,77,97,116,101,114,105,97,108,68,97,116,97,0,83,111,102,116,66,111,100,121,78,111,100,101,68,97,116,97,0,83,111,102,116,66,111,100,121,76,105,110,107,68,97,116,97,0,83,111,102,116,66,111,100,121,70,97,99,101,68,97,116,97,0,83,111,102,116,66,111,100,121,84,101,116,114,97,68,97,116,97,0,83,111,102,116,82,105,103,105,100,65,110,99,104,111,114,68,97,116,97,0,102,108,111,97,116,0,83,111,102,116,66,111,100,121,80,111,115,101,68,97,116,97,0,83,111,102,116,66,111,100,121,67,108,117,115,116,101,114,68,97,116,97,0,105,110,116,0,98,116,83,111,102,116,66,111,100,121,74,111,105,110,116,68,97,116,97,0,98,116,83,111,102,116,66,111,100,121,70,108,111,97,116,68,97,116,97,0,78,49,48,98,116,83,111,102,116,66,111,100,121,49,53,82,97,121,70,114,111,109,84,111,67,97,115,116,101,114,69,0,78,54,98,116,68,98,118,116,56,73,67,111,108,108,105,100,101,69,0,78,49,48,98,116,83,111,102,116,66,111,100,121,53,74,111,105,110,116,69,0,78,49,48,98,116,83,111,102,116,66,111,100,121,54,67,74,111,105,110,116,69,0,50,52,98,116,83,111,102,116,66,111,100,121,67,111,108,108,105,115,105,111,110,83,104,97,112,101,0,83,111,102,116,66,111,100,121,0,85,112,100,97,116,101,67,108,117,115,116,101,114,115,0,83,111,102,116,66,111,100,121,32,97,112,112,108,121,70,111,114,99,101,115,0,65,112,112,108,121,67,108,117,115,116,101,114,115,0,78,49,53,98,116,83,111,102,116,67,111,108,108,105,100,101,114,115,49,51,67,111,108,108,105,100,101,83,68,70,95,82,83,69,0,78,49,53,98,116,83,111,102,116,67,111,108,108,105,100,101,114,115,49,50,67,111,108,108,105,100,101,67,76,95,82,83,69,0,78,49,53,98,116,83,111,102,116,67,111,108,108,105,100,101,114,115,49,49,67,108,117,115,116,101,114,66,97,115,101,69,0,50,55,98,116,83,111,102,116,67,108,117,115,116,101,114,67,111,108,108,105,115,105,111,110,83,104,97,112,101,0,83,79,70,84,67,76,85,83,84,69,82,0,98,116,67,111,110,118,101,120,73,110,116,101,114,110,97,108,83,104,97,112,101,68,97,116,97,0,78,49,53,98,116,83,111,102,116,67,111,108,108,105,100,101,114,115,49,50,67,111,108,108,105,100,101,67,76,95,83,83,69,0,78,49,53,98,116,83,111,102,116,67,111,108,108,105,100,101,114,115,49,50,67,111,108,108,105,100,101,86,70,95,83,83,69,0,50,57,98,116,83,111,102,116,82,105,103,105,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,50,48,98,116,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,51,53,98,116,83,111,102,116,66,111,100,121,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,50,54,98,116,83,111,102,116,66,111,100,121,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,0,90,78,51,53,98,116,83,111,102,116,66,111,100,121,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,50,49,99,97,108,99,117,108,97,116,101,84,105,109,101,79,102,73,109,112,97,99,116,69,80,49,55,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,83,49,95,82,75,49,54,98,116,68,105,115,112,97,116,99,104,101,114,73,110,102,111,80,49,54,98,116,77,97,110,105,102,111,108,100,82,101,115,117,108,116,69,51,49,76,111,99,97,108,84,114,105,97,110,103,108,101,83,112,104,101,114,101,67,97,115,116,67,97,108,108,98,97,99,107,0,78,49,50,98,116,67,111,110,118,101,120,67,97,115,116,49,48,67,97,115,116,82,101,115,117,108,116,69,0,49,53,98,116,84,114,105,97,110,103,108,101,83,104,97,112,101,0,84,114,105,97,110,103,108,101,0,50,52,98,116,83,111,102,116,82,105,103,105,100,68,121,110,97,109,105,99,115,87,111,114,108,100,0,114,97,121,84,101,115,116,0,50,51,98,116,83,111,102,116,83,105,110,103,108,101,82,97,121,67,97,108,108,98,97,99,107,0,50,51,98,116,66,114,111,97,100,112,104,97,115,101,82,97,121,67,97,108,108,98,97,99,107,0,50,52,98,116,66,114,111,97,100,112,104,97,115,101,65,97,98,98,67,97,108,108,98,97,99,107,0,112,114,101,100,105,99,116,85,110,99,111,110,115,116,114,97,105,110,116,77,111,116,105,111,110,83,111,102,116,66,111,100,121,0,115,111,108,118,101,83,111,102,116,67,111,110,115,116,114,97,105,110,116,115,0,50,56,98,116,83,111,102,116,83,111,102,116,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,49,49,98,116,82,105,103,105,100,66,111,100,121,0,98,116,82,105,103,105,100,66,111,100,121,70,108,111,97,116,68,97,116,97,0,50,51,98,116,68,105,115,99,114,101,116,101,68,121,110,97,109,105,99,115,87,111,114,108,100,0,49,53,98,116,68,121,110,97,109,105,99,115,87,111,114,108,100,0,100,101,98,117,103,68,114,97,119,87,111,114,108,100,0,98,116,68,121,110,97,109,105,99,115,87,111,114,108,100,70,108,111,97,116,68,97,116,97,0,115,116,101,112,83,105,109,117,108,97,116,105,111,110,0,115,121,110,99,104,114,111,110,105,122,101,77,111,116,105,111,110,83,116,97,116,101,115,0,112,114,101,100,105,99,116,85,110,99,111,110,115,116,114,97,105,110,116,77,111,116,105,111,110,0,105,110,116,101,103,114,97,116,101,84,114,97,110,115,102,111,114,109,115,0,67,67,68,32,109,111,116,105,111,110,32,99,108,97,109,112,105,110,103,0,51,52,98,116,67,108,111,115,101,115,116,78,111,116,77,101,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,0,97,112,112,108,121,32,115,112,101,99,117,108,97,116,105,118,101,32,99,111,110,116,97,99,116,32,114,101,115,116,105,116,117,116,105,111,110,0,99,97,108,99,117,108,97,116,101,83,105,109,117,108,97,116,105,111,110,73,115,108,97,110,100,115,0,115,111,108,118,101,67,111,110,115,116,114,97,105,110,116,115,0,117,112,100,97,116,101,65,99,116,105,118,97,116,105,111,110,83,116,97,116,101,0,105,110,116,101,114,110,97,108,83,105,110,103,108,101,83,116,101,112,83,105,109,117,108,97,116,105,111,110,0,99,114,101,97,116,101,80,114,101,100,105,99,116,105,118,101,67,111,110,116,97,99,116,115,0,114,101,108,101,97,115,101,32,112,114,101,100,105,99,116,105,118,101,32,99,111,110,116,97,99,116,32,109,97,110,105,102,111,108,100,115,0,112,114,101,100,105,99,116,105,118,101,32,99,111,110,118,101,120,83,119,101,101,112,84,101,115,116,0,117,112,100,97,116,101,65,99,116,105,111,110,115,0,50,55,73,110,112,108,97,99,101,83,111,108,118,101,114,73,115,108,97,110,100,67,97,108,108,98,97,99,107,0,78,50,53,98,116,83,105,109,117,108,97,116,105,111,110,73,115,108,97,110,100,77,97,110,97,103,101,114,49,52,73,115,108,97,110,100,67,97,108,108,98,97,99,107,69,0,50,51,98,116,71,101,110,101,114,105,99,54,68,111,102,67,111,110,115,116,114,97,105,110,116,0,49,55,98,116,84,121,112,101,100,67,111,110,115,116,114,97,105,110,116,0,49,51,98,116,84,121,112,101,100,79,98,106,101,99,116,0,98,116,71,101,110,101,114,105,99,54,68,111,102,67,111,110,115,116,114,97,105,110,116,68,97,116,97,0,50,57,98,116,71,101,110,101,114,105,99,54,68,111,102,83,112,114,105,110,103,67,111,110,115,116,114,97,105,110,116,0,98,116,71,101,110,101,114,105,99,54,68,111,102,83,112,114,105,110,103,67,111,110,115,116,114,97,105,110,116,68,97,116,97,0,50,51,98,116,80,111,105,110,116,50,80,111,105,110,116,67,111,110,115,116,114,97,105,110,116,0,98,116,80,111,105,110,116,50,80,111,105,110,116,67,111,110,115,116,114,97,105,110,116,70,108,111,97,116,68,97,116,97,0,98,116,84,121,112,101,100,67,111,110,115,116,114,97,105,110,116,70,108,111,97,116,68,97,116,97,0,49,56,98,116,83,108,105,100,101,114,67,111,110,115,116,114,97,105,110,116,0,98,116,83,108,105,100,101,114,67,111,110,115,116,114,97,105,110,116,68,97,116,97,0,50,49,98,116,67,111,110,101,84,119,105,115,116,67,111,110,115,116,114,97,105,110,116,0,98,116,67,111,110,101,84,119,105,115,116,67,111,110,115,116,114,97,105,110,116,68,97,116,97,0,49,55,98,116,72,105,110,103,101,67,111,110,115,116,114,97,105,110,116,0,98,116,72,105,110,103,101,67,111,110,115,116,114,97,105,110,116,70,108,111,97,116,68,97,116,97,0,51,53,98,116,83,101,113,117,101,110,116,105,97,108,73,109,112,117,108,115,101,67,111,110,115,116,114,97,105,110,116,83,111,108,118,101,114,0,49,56,98,116,67,111,110,115,116,114,97,105,110,116,83,111,108,118,101,114,0,115,111,108,118,101,71,114,111,117,112,0,115,111,108,118,101,71,114,111,117,112,67,97,99,104,101,70,114,105,101,110,100,108,121,83,101,116,117,112,0,115,111,108,118,101,71,114,111,117,112,67,97,99,104,101,70,114,105,101,110,100,108,121,73,116,101,114,97,116,105,111,110,115,0,49,54,98,116,82,97,121,99,97,115,116,86,101,104,105,99,108,101,0,49,55,98,116,65,99,116,105,111,110,73,110,116,101,114,102,97,99,101,0,50,53,98,116,68,101,102,97,117,108,116,86,101,104,105,99,108,101,82,97,121,99,97,115,116,101,114,0,51,48,98,116,75,105,110,101,109,97,116,105,99,67,104,97,114,97,99,116,101,114,67,111,110,116,114,111,108,108,101,114,0,51,48,98,116,67,104,97,114,97,99,116,101,114,67,111,110,116,114,111,108,108,101,114,73,110,116,101,114,102,97,99,101,0,52,51,98,116,75,105,110,101,109,97,116,105,99,67,108,111,115,101,115,116,78,111,116,77,101,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,0,50,50,98,116,83,117,98,115,105,109,112,108,101,120,67,111,110,118,101,120,67,97,115,116,0,49,50,98,116,67,111,110,118,101,120,67,97,115,116,0,49,55,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,0,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,70,108,111,97,116,68,97,116,97,0,49,51,98,116,71,104,111,115,116,79,98,106,101,99,116,0,50,52,98,116,80,97,105,114,67,97,99,104,105,110,103,71,104,111,115,116,79,98,106,101,99,116,0,50,49,98,116,67,111,108,108,105,115,105,111,110,68,105,115,112,97,116,99,104,101,114,0,50,51,98,116,67,111,108,108,105,115,105,111,110,80,97,105,114,67,97,108,108,98,97,99,107,0,49,55,98,116,79,118,101,114,108,97,112,67,97,108,108,98,97,99,107,0,51,49,98,116,68,101,102,97,117,108,116,67,111,108,108,105,115,105,111,110,67,111,110,102,105,103,117,114,97,116,105,111,110,0,50,52,98,116,67,111,108,108,105,115,105,111,110,67,111,110,102,105,103,117,114,97,116,105,111,110,0,78,51,51,98,116,67,111,110,118,101,120,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,51,98,116,67,111,110,118,101,120,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,55,83,119,97,112,112,101,100,67,114,101,97,116,101,70,117,110,99,69,0,78,50,56,98,116,67,111,109,112,111,117,110,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,54,98,116,67,111,109,112,111,117,110,100,67,111,109,112,111,117,110,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,50,56,98,116,67,111,109,112,111,117,110,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,55,83,119,97,112,112,101,100,67,114,101,97,116,101,70,117,110,99,69,0,78,49,54,98,116,69,109,112,116,121,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,50,98,116,83,112,104,101,114,101,83,112,104,101,114,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,52,98,116,83,112,104,101,114,101,84,114,105,97,110,103,108,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,50,54,98,116,66,111,120,66,111,120,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,78,51,49,98,116,67,111,110,118,101,120,80,108,97,110,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,50,53,98,116,83,105,109,117,108,97,116,105,111,110,73,115,108,97,110,100,77,97,110,97,103,101,114,0,105,115,108,97,110,100,85,110,105,111,110,70,105,110,100,65,110,100,81,117,105,99,107,83,111,114,116,0,112,114,111,99,101,115,115,73,115,108,97,110,100,115,0,51,49,98,116,67,111,110,118,101,120,80,108,97,110,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,51,51,98,116,67,111,110,118,101,120,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,50,52,98,116,67,111,110,118,101,120,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,0,90,78,51,51,98,116,67,111,110,118,101,120,67,111,110,99,97,118,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,50,49,99,97,108,99,117,108,97,116,101,84,105,109,101,79,102,73,109,112,97,99,116,69,80,49,55,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,83,49,95,82,75,49,54,98,116,68,105,115,112,97,116,99,104,101,114,73,110,102,111,80,49,54,98,116,77,97,110,105,102,111,108,100,82,101,115,117,108,116,69,51,49,76,111,99,97,108,84,114,105,97,110,103,108,101,83,112,104,101,114,101,67,97,115,116,67,97,108,108,98,97,99,107,0,50,54,98,116,66,111,120,66,111,120,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,49,54,98,116,77,97,110,105,102,111,108,100,82,101,115,117,108,116,0,78,51,54,98,116,68,105,115,99,114,101,116,101,67,111,108,108,105,115,105,111,110,68,101,116,101,99,116,111,114,73,110,116,101,114,102,97,99,101,54,82,101,115,117,108,116,69,0,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,0,117,112,100,97,116,101,65,97,98,98,115,0,1,79,118,101,114,102,108,111,119,32,105,110,32,65,65,66,66,44,32,111,98,106,101,99,116,32,114,101,109,111,118,101,100,32,102,114,111,109,32,115,105,109,117,108,97,116,105,111,110,0,73,102,32,121,111,117,32,99,97,110,32,114,101,112,114,111,100,117,99,101,32,116,104,105,115,44,32,112,108,101,97,115,101,32,101,109,97,105,108,32,98,117,103,115,64,99,111,110,116,105,110,117,111,117,115,112,104,121,115,105,99,115,46,99,111,109,10,0,80,108,101,97,115,101,32,105,110,99,108,117,100,101,32,97,98,111,118,101,32,105,110,102,111,114,109,97,116,105,111,110,44,32,121,111,117,114,32,80,108,97,116,102,111,114,109,44,32,118,101,114,115,105,111,110,32,111,102,32,79,83,46,10,0,84,104,97,110,107,115,46,10,0,99,97,108,99,117,108,97,116,101,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,115,0,49,55,68,101,98,117,103,68,114,97,119,99,97,108,108,98,97,99,107,0,49,57,98,116,83,105,110,103,108,101,82,97,121,67,97,108,108,98,97,99,107,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,49,114,97,121,84,101,115,116,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,50,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,49,55,82,97,121,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,69,50,57,66,114,105,100,103,101,84,114,105,97,110,103,108,101,82,97,121,99,97,115,116,67,97,108,108,98,97,99,107,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,49,114,97,121,84,101,115,116,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,50,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,49,55,82,97,121,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,69,50,57,66,114,105,100,103,101,84,114,105,97,110,103,108,101,82,97,121,99,97,115,116,67,97,108,108,98,97,99,107,95,48,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,49,114,97,121,84,101,115,116,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,50,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,49,55,82,97,121,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,69,57,82,97,121,84,101,115,116,101,114,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,49,114,97,121,84,101,115,116,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,50,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,49,55,82,97,121,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,69,49,53,76,111,99,97,108,73,110,102,111,65,100,100,101,114,50,0,112,101,114,102,111,114,109,68,105,115,99,114,101,116,101,67,111,108,108,105,115,105,111,110,68,101,116,101,99,116,105,111,110,0,100,105,115,112,97,116,99,104,65,108,108,67,111,108,108,105,115,105,111,110,80,97,105,114,115,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,53,111,98,106,101,99,116,81,117,101,114,121,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,80,75,49,51,98,116,67,111,110,118,101,120,83,104,97,112,101,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,53,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,50,48,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,102,69,51,50,66,114,105,100,103,101,84,114,105,97,110,103,108,101,67,111,110,118,101,120,99,97,115,116,67,97,108,108,98,97,99,107,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,53,111,98,106,101,99,116,81,117,101,114,121,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,80,75,49,51,98,116,67,111,110,118,101,120,83,104,97,112,101,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,53,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,50,48,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,102,69,51,50,66,114,105,100,103,101,84,114,105,97,110,103,108,101,67,111,110,118,101,120,99,97,115,116,67,97,108,108,98,97,99,107,95,48,0,99,111,110,118,101,120,83,119,101,101,112,67,111,109,112,111,117,110,100,0,90,78,49,54,98,116,67,111,108,108,105,115,105,111,110,87,111,114,108,100,50,53,111,98,106,101,99,116,81,117,101,114,121,83,105,110,103,108,101,73,110,116,101,114,110,97,108,69,80,75,49,51,98,116,67,111,110,118,101,120,83,104,97,112,101,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,53,95,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,82,78,83,95,50,48,67,111,110,118,101,120,82,101,115,117,108,116,67,97,108,108,98,97,99,107,69,102,69,49,52,76,111,99,97,108,73,110,102,111,65,100,100,101,114,0,99,111,110,118,101,120,83,119,101,101,112,84,101,115,116,0,50,49,98,116,83,105,110,103,108,101,83,119,101,101,112,67,97,108,108,98,97,99,107,0,50,51,98,116,83,105,110,103,108,101,67,111,110,116,97,99,116,67,97,108,108,98,97,99,107,0,50,51,98,116,66,114,105,100,103,101,100,77,97,110,105,102,111,108,100,82,101,115,117,108,116,0,51,52,98,116,83,112,104,101,114,101,84,114,105,97,110,103,108,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,78,50,51,98,116,67,111,110,118,101,120,67,111,110,118,101,120,65,108,103,111,114,105,116,104,109,49,48,67,114,101,97,116,101,70,117,110,99,69,0,50,51,98,116,67,111,110,118,101,120,67,111,110,118,101,120,65,108,103,111,114,105,116,104,109,0,90,78,50,51,98,116,67,111,110,118,101,120,67,111,110,118,101,120,65,108,103,111,114,105,116,104,109,49,54,112,114,111,99,101,115,115,67,111,108,108,105,115,105,111,110,69,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,83,50,95,82,75,49,54,98,116,68,105,115,112,97,116,99,104,101,114,73,110,102,111,80,49,54,98,116,77,97,110,105,102,111,108,100,82,101,115,117,108,116,69,49,51,98,116,68,117,109,109,121,82,101,115,117,108,116,0,90,78,50,51,98,116,67,111,110,118,101,120,67,111,110,118,101,120,65,108,103,111,114,105,116,104,109,49,54,112,114,111,99,101,115,115,67,111,108,108,105,115,105,111,110,69,80,75,50,52,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99,116,87,114,97,112,112,101,114,83,50,95,82,75,49,54,98,116,68,105,115,112,97,116,99,104,101,114,73,110,102,111,80,49,54,98,116,77,97,110,105,102,111,108,100,82,101,115,117,108,116,69,50,49,98,116,87,105,116,104,111,117,116,77,97,114,103,105,110,82,101,115,117,108,116,0,50,52,98,116,80,101,114,116,117,114,98,101,100,67,111,110,116,97,99,116,82,101,115,117,108,116,0,50,56,98,116,67,111,109,112,111,117,110,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,50,50,98,116,67,111,109,112,111,117,110,100,76,101,97,102,67,97,108,108,98,97,99,107,0,51,54,98,116,67,111,109,112,111,117,110,100,67,111,109,112,111,117,110,100,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,51,48,98,116,67,111,109,112,111,117,110,100,67,111,109,112,111,117,110,100,76,101,97,102,67,97,108,108,98,97,99,107,0,49,53,98,116,67,111,109,112,111,117,110,100,83,104,97,112,101,0,67,111,109,112,111,117,110,100,0,98,116,67,111,109,112,111,117,110,100,83,104,97,112,101,67,104,105,108,100,68,97,116,97,0,98,116,67,111,109,112,111,117,110,100,83,104,97,112,101,68,97,116,97,0,49,49,98,116,67,111,110,101,83,104,97,112,101,0,67,111,110,101,0,98,116,67,111,110,101,83,104,97,112,101,68,97,116,97,0,49,50,98,116,67,111,110,101,83,104,97,112,101,90,0,67,111,110,101,90,0,49,50,98,116,67,111,110,101,83,104,97,112,101,88,0,67,111,110,101,88,0,49,51,98,116,83,112,104,101,114,101,83,104,97,112,101,0,83,80,72,69,82,69,0,50,50,98,116,66,118,104,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,0,66,86,72,84,82,73,65,78,71,76,69,77,69,83,72,0,98,116,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,68,97,116,97,0,90,78,75,50,50,98,116,66,118,104,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,49,57,112,114,111,99,101,115,115,65,108,108,84,114,105,97,110,103,108,101,115,69,80,49,56,98,116,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,82,75,57,98,116,86,101,99,116,111,114,51,83,52,95,69,50,49,77,121,78,111,100,101,79,118,101,114,108,97,112,67,97,108,108,98,97,99,107,0,50,49,98,116,78,111,100,101,79,118,101,114,108,97,112,67,97,108,108,98,97,99,107,0,90,78,50,50,98,116,66,118,104,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,49,52,112,101,114,102,111,114,109,82,97,121,99,97,115,116,69,80,49,56,98,116,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,82,75,57,98,116,86,101,99,116,111,114,51,83,52,95,69,50,49,77,121,78,111,100,101,79,118,101,114,108,97,112,67,97,108,108,98,97,99,107,0,90,78,50,50,98,116,66,118,104,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,49,55,112,101,114,102,111,114,109,67,111,110,118,101,120,99,97,115,116,69,80,49,56,98,116,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,82,75,57,98,116,86,101,99,116,111,114,51,83,52,95,83,52,95,83,52,95,69,50,49,77,121,78,111,100,101,79,118,101,114,108,97,112,67,97,108,108,98,97,99,107,0,49,57,98,116,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,0,84,82,73,65,78,71,76,69,77,69,83,72,0,90,78,75,49,57,98,116,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,49,57,112,114,111,99,101,115,115,65,108,108,84,114,105,97,110,103,108,101,115,69,80,49,56,98,116,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,82,75,57,98,116,86,101,99,116,111,114,51,83,52,95,69,49,54,70,105,108,116,101,114,101,100,67,97,108,108,98,97,99,107,0,50,49,83,117,112,112,111,114,116,86,101,114,116,101,120,67,97,108,108,98,97,99,107,0,49,56,98,116,83,116,97,116,105,99,80,108,97,110,101,83,104,97,112,101,0,83,84,65,84,73,67,80,76,65,78,69,0,98,116,83,116,97,116,105,99,80,108,97,110,101,83,104,97,112,101,68,97,116,97,0,50,51,98,116,80,111,108,121,104,101,100,114,97,108,67,111,110,118,101,120,83,104,97,112,101,0,51,52,98,116,80,111,108,121,104,101,100,114,97,108,67,111,110,118,101,120,65,97,98,98,67,97,99,104,105,110,103,83,104,97,112,101,0,49,54,98,116,67,111,108,108,105,115,105,111,110,83,104,97,112,101,0,98,116,67,111,108,108,105,115,105,111,110,83,104,97,112,101,68,97,116,97,0,49,51,98,116,67,111,110,118,101,120,83,104,97,112,101,0,50,49,98,116,67,111,110,118,101,120,73,110,116,101,114,110,97,108,83,104,97,112,101,0,49,55,98,116,67,111,110,118,101,120,72,117,108,108,83,104,97,112,101,0,67,111,110,118,101,120,0,98,116,67,111,110,118,101,120,72,117,108,108,83,104,97,112,101,68,97,116,97,0,49,56,98,116,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,0,51,49,98,116,73,110,116,101,114,110,97,108,84,114,105,97,110,103,108,101,73,110,100,101,120,67,97,108,108,98,97,99,107,0,49,52,98,116,67,97,112,115,117,108,101,83,104,97,112,101,0,67,97,112,115,117,108,101,83,104,97,112,101,0,98,116,67,97,112,115,117,108,101,83,104,97,112,101,68,97,116,97,0,49,53,98,116,67,97,112,115,117,108,101,83,104,97,112,101,88,0,67,97,112,115,117,108,101,88,0,49,53,98,116,67,97,112,115,117,108,101,83,104,97,112,101,90,0,67,97,112,115,117,108,101,90,0,50,53,98,116,67,111,110,118,101,120,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97,112,101,0,67,111,110,118,101,120,84,114,105,109,101,115,104,0,50,54,76,111,99,97,108,83,117,112,112,111,114,116,86,101,114,116,101,120,67,97,108,108,98,97,99,107,0,49,52,98,116,67,111,110,99,97,118,101,83,104,97,112,101,0,49,48,98,116,66,111,120,83,104,97,112,101,0,66,111,120,0,49,52,98,116,79,112,116,105,109,105,122,101,100,66,118,104,0,90,78,49,52,98,116,79,112,116,105,109,105,122,101,100,66,118,104,53,98,117,105,108,100,69,80,50,51,98,116,83,116,114,105,100,105,110,103,77,101,115,104,73,110,116,101,114,102,97,99,101,98,82,75,57,98,116,86,101,99,116,111,114,51,83,52,95,69,50,57,81,117,97,110,116,105,122,101,100,78,111,100,101,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,0,90,78,49,52,98,116,79,112,116,105,109,105,122,101,100,66,118,104,53,98,117,105,108,100,69,80,50,51,98,116,83,116,114,105,100,105,110,103,77,101,115,104,73,110,116,101,114,102,97,99,101,98,82,75,57,98,116,86,101,99,116,111,114,51,83,52,95,69,50,48,78,111,100,101,84,114,105,97,110,103,108,101,67,97,108,108,98,97,99,107,0,50,53,98,116,72,101,105,103,104,116,102,105,101,108,100,84,101,114,114,97,105,110,83,104,97,112,101,0,72,69,73,71,72,84,70,73,69,76,68,0,49,53,98,116,67,121,108,105,110,100,101,114,83,104,97,112,101,0,67,121,108,105,110,100,101,114,89,0,98,116,67,121,108,105,110,100,101,114,83,104,97,112,101,68,97,116,97,0,49,54,98,116,67,121,108,105,110,100,101,114,83,104,97,112,101,88,0,67,121,108,105,110,100,101,114,88,0,49,54,98,116,67,121,108,105,110,100,101,114,83,104,97,112,101,90,0,67,121,108,105,110,100,101,114,90,0,49,52,98,116,84,114,105,97,110,103,108,101,77,101,115,104,0,50,48,98,116,65,120,105,115,83,119,101,101,112,51,73,110,116,101,114,110,97,108,73,116,69,0,50,49,98,116,66,114,111,97,100,112,104,97,115,101,73,110,116,101,114,102,97,99,101,0,49,53,98,116,78,117,108,108,80,97,105,114,67,97,99,104,101,0,50,50,98,116,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,67,97,99,104,101,0,49,50,98,116,65,120,105,115,83,119,101,101,112,51,0,50,56,98,116,72,97,115,104,101,100,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,67,97,99,104,101,0,90,78,50,56,98,116,72,97,115,104,101,100,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,67,97,99,104,101,51,55,114,101,109,111,118,101,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,115,67,111,110,116,97,105,110,105,110,103,80,114,111,120,121,69,80,49,55,98,116,66,114,111,97,100,112,104,97,115,101,80,114,111,120,121,80,49,50,98,116,68,105,115,112,97,116,99,104,101,114,69,49,56,82,101,109,111,118,101,80,97,105,114,67,97,108,108,98,97,99,107,0,90,78,50,56,98,116,72,97,115,104,101,100,79,118,101,114,108,97,112,112,105,110,103,80,97,105,114,67,97,99,104,101,49,57,99,108,101,97,110,80,114,111,120,121,70,114,111,109,80,97,105,114,115,69,80,49,55,98,116,66,114,111,97,100,112,104,97,115,101,80,114,111,120,121,80,49,50,98,116,68,105,115,112,97,116,99,104,101,114,69,49,55,67,108,101,97,110,80,97,105,114,67,97,108,108,98,97,99,107,0,49,54,98,116,68,98,118,116,66,114,111,97,100,112,104,97,115,101,0,49,56,98,116,68,98,118,116,84,114,101,101,67,111,108,108,105,100,101,114,0,49,57,66,114,111,97,100,112,104,97,115,101,82,97,121,84,101,115,116,101,114,0,50,48,66,114,111,97,100,112,104,97,115,101,65,97,98,98,84,101,115,116,101,114,0,49,50,98,116,68,105,115,112,97,116,99,104,101,114,0,49,52,98,116,81,117,97,110,116,105,122,101,100,66,118,104,0,98,116,79,112,116,105,109,105,122,101,100,66,118,104,78,111,100,101,68,97,116,97,0,98,116,81,117,97,110,116,105,122,101,100,66,118,104,78,111,100,101,68,97,116,97,0,98,116,66,118,104,83,117,98,116,114,101,101,73,110,102,111,68,97,116,97,0,98,116,81,117,97,110,116,105,122,101,100,66,118,104,70,108,111,97,116,68,97,116,97,0,50,53,98,116,84,114,105,97,110,103,108,101,82,97,121,99,97,115,116,67,97,108,108,98,97,99,107,0,50,56,98,116,84,114,105,97,110,103,108,101,67,111,110,118,101,120,99,97,115,116,67,97,108,108,98,97,99,107,0,51,51,98,116,77,105,110,107,111,119,115,107,105,80,101,110,101,116,114,97,116,105,111,110,68,101,112,116,104,83,111,108,118,101,114,0,51,48,98,116,67,111,110,118,101,120,80,101,110,101,116,114,97,116,105,111,110,68,101,112,116,104,83,111,108,118,101,114,0,90,78,51,51,98,116,77,105,110,107,111,119,115,107,105,80,101,110,101,116,114,97,116,105,111,110,68,101,112,116,104,83,111,108,118,101,114,49,50,99,97,108,99,80,101,110,68,101,112,116,104,69,82,50,50,98,116,86,111,114,111,110,111,105,83,105,109,112,108,101,120,83,111,108,118,101,114,80,75,49,51,98,116,67,111,110,118,101,120,83,104,97,112,101,83,52,95,82,75,49,49,98,116,84,114,97,110,115,102,111,114,109,83,55,95,82,57,98,116,86,101,99,116,111,114,51,83,57,95,83,57,95,80,49,50,98,116,73,68,101,98,117,103,68,114,97,119,69,50,48,98,116,73,110,116,101,114,109,101,100,105,97,116,101,82,101,115,117,108,116,0,51,48,98,116,71,106,107,69,112,97,80,101,110,101,116,114,97,116,105,111,110,68,101,112,116,104,83,111,108,118,101,114,0,49,53,98,116,71,106,107,67,111,110,118,101,120,67,97,115,116,0,49,54,98,116,80,111,105,110,116,67,111,108,108,101,99,116,111,114,0,50,55,98,116,67,111,110,116,105,110,117,111,117,115,67,111,110,118,101,120,67,111,108,108,105,115,105,111,110,0,49,55,98,116,71,106,107,80,97,105,114,68,101,116,101,99,116,111,114,0,51,54,98,116,68,105,115,99,114,101,116,101,67,111,108,108,105,115,105,111,110,68,101,116,101,99,116,111,114,73,110,116,101,114,102,97,99,101,0,51,48,98,116,65,99,116,105,118,97,116,105,110,103,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,49,54,98,116,69,109,112,116,121,65,108,103,111,114,105,116,104,109,0,51,50,98,116,83,112,104,101,114,101,83,112,104,101,114,101,67,111,108,108,105,115,105,111,110,65,108,103,111,114,105,116,104,109,0,49,54,98,116,66,111,120,66,111,120,68,101,116,101,99,116,111,114,0,50,50,83,112,104,101,114,101,84,114,105,97,110,103,108,101,68,101,116,101,99,116,111,114,0,50,51,98,116,72,97,115,104,101,100,83,105,109,112,108,101,80,97,105,114,67,97,99,104,101,0,49,56,98,116,67,111,110,118,101,120,80,111,108,121,104,101,100,114,111,110,0,50,54,98,116,84,114,105,97,110,103,108,101,73,110,100,101,120,86,101,114,116,101,120,65,114,114,97,121,0,50,51,98,116,83,116,114,105,100,105,110,103,77,101,115,104,73,110,116,101,114,102,97,99,101,0,98,116,73,110,116,73,110,100,101,120,68,97,116,97,0,98,116,83,104,111,114,116,73,110,116,73,110,100,101,120,84,114,105,112,108,101,116,68,97,116,97,0,98,116,67,104,97,114,73,110,100,101,120,84,114,105,112,108,101,116,68,97,116,97,0,98,116,86,101,99,116,111,114,51,70,108,111,97,116,68,97,116,97,0,98,116,86,101,99,116,111,114,51,68,111,117,98,108,101,68,97,116,97,0,98,116,77,101,115,104,80,97,114,116,68,97,116,97,0,98,116,83,116,114,105,100,105,110,103,77,101,115,104,73,110,116,101,114,102,97,99,101,68,97,116,97,0,82,111,111,116,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE+10240);allocate([115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,83,116,57,101,120,99,101,112,116,105,111,110,0,117,110,99,97,117,103,104,116,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,83,116,57,98,97,100,95,97,108,108,111,99,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE+20480);var tempDoublePtr=STATICTOP;STATICTOP+=16;Module["_i64Subtract"]=_i64Subtract;function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(name){switch(name){case 30:return PAGE_SIZE;case 85:return totalMemory/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:{if(typeof navigator==="object")return navigator["hardwareConcurrency"]||1;return 1}}___setErrNo(ERRNO_CODES.EINVAL);return-1}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0){if(info.destructor){Runtime.dynCall("vi",info.destructor,[ptr])}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}EXCEPTIONS.clearRef(EXCEPTIONS.deAdjust(ptr));throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(asm["setTempRet0"](0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(asm["setTempRet0"](0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(asm["setTempRet0"](typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(asm["setTempRet0"](throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}Module["_memset"]=_memset;function ___gxx_personality_v0(){}Module["_bitshift64Shl"]=_bitshift64Shl;function _abort(){Module["abort"]()}function _pthread_once(ptr,func){if(!_pthread_once.seen)_pthread_once.seen={};if(ptr in _pthread_once.seen)return;Runtime.dynCall("v",func);_pthread_once.seen[ptr]=1}var PTHREAD_SPECIFIC={};function _pthread_getspecific(key){return PTHREAD_SPECIFIC[key]||0}Module["_i64Add"]=_i64Add;var PTHREAD_SPECIFIC_NEXT_KEY=1;function _pthread_key_create(key,destructor){if(key==0){return ERRNO_CODES.EINVAL}HEAP32[key>>2]=PTHREAD_SPECIFIC_NEXT_KEY;PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0;PTHREAD_SPECIFIC_NEXT_KEY++;return 0}var _llvm_pow_f32=Math_pow;function _pthread_setspecific(key,value){if(!(key in PTHREAD_SPECIFIC)){return ERRNO_CODES.EINVAL}PTHREAD_SPECIFIC[key]=value;return 0}function _malloc(bytes){var ptr=Runtime.dynamicAlloc(bytes+8);return ptr+8&4294967288}Module["_malloc"]=_malloc;function ___cxa_allocate_exception(size){return _malloc(size)}Module["_bitshift64Ashr"]=_bitshift64Ashr;Module["_bitshift64Lshr"]=_bitshift64Lshr;function ___cxa_pure_virtual(){ABORT=true;throw"Pure virtual function called!"}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function _pthread_cleanup_push(routine,arg){__ATEXIT__.push((function(){Runtime.dynCall("vi",routine,[arg])}));_pthread_cleanup_push.level=__ATEXIT__.length}function ___cxa_guard_acquire(variable){if(!HEAP8[variable>>0]){HEAP8[variable>>0]=1;return 1}return 0}function _pthread_cleanup_pop(){assert(_pthread_cleanup_push.level==__ATEXIT__.length,"cannot pop if something else added meanwhile!");__ATEXIT__.pop();_pthread_cleanup_push.level=__ATEXIT__.length}function ___cxa_begin_catch(ptr){__ZSt18uncaught_exceptionv.uncaught_exception--;EXCEPTIONS.caught.push(ptr);EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));return ptr}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}Module["_memcpy"]=_memcpy;var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall6(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD();FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function _sbrk(bytes){var self=_sbrk;if(!self.called){DYNAMICTOP=alignMemoryPage(DYNAMICTOP);self.called=true;assert(Runtime.dynamicAlloc);self.alloc=Runtime.dynamicAlloc;Runtime.dynamicAlloc=(function(){abort("cannot dynamically allocate, sbrk now has control")})}var ret=DYNAMICTOP;if(bytes!=0){var success=self.alloc(bytes);if(!success)return-1>>>0}return ret}Module["_memmove"]=_memmove;function _gettimeofday(ptr){var now=Date.now();HEAP32[ptr>>2]=now/1e3|0;HEAP32[ptr+4>>2]=now%1e3*1e3|0;return 0}var _llvm_fabs_f32=Math_abs;Module["_llvm_bswap_i32"]=_llvm_bswap_i32;function _llvm_trap(){abort("trap!")}function ___cxa_guard_release(){}function _pthread_self(){return 0}function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;assert(offset_high===0);FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffer){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]|0;c[d+128>>2]=q;o=c[a+84>>2]|0;c[d+128+4>>2]=o;m=c[a+100>>2]|0;c[d+128+8>>2]=m;g[d+128+12>>2]=0.0;l=d+128+16|0;t=c[a+72>>2]|0;c[l>>2]=t;s=c[a+88>>2]|0;c[d+128+20>>2]=s;r=c[a+104>>2]|0;c[d+128+24>>2]=r;g[d+128+28>>2]=0.0;j=d+128+32|0;w=c[a+76>>2]|0;c[j>>2]=w;v=c[a+92>>2]|0;c[d+128+36>>2]=v;u=c[a+108>>2]|0;c[d+128+40>>2]=u;g[d+128+44>>2]=0.0;p=-+g[a+116>>2];n=-+g[a+120>>2];h=-+g[a+124>>2];e=(c[k>>2]=w,+g[k>>2])*p;e=e+(c[k>>2]=v,+g[k>>2])*n;e=e+(c[k>>2]=u,+g[k>>2])*h;f=(c[k>>2]=t,+g[k>>2])*p;f=f+(c[k>>2]=s,+g[k>>2])*n;f=f+(c[k>>2]=r,+g[k>>2])*h;p=(c[k>>2]=q,+g[k>>2])*p;n=p+(c[k>>2]=o,+g[k>>2])*n;h=n+(c[k>>2]=m,+g[k>>2])*h;c[d>>2]=c[d+128>>2];c[d+4>>2]=c[d+128+4>>2];c[d+8>>2]=c[d+128+8>>2];c[d+12>>2]=c[d+128+12>>2];c[d+16>>2]=c[l>>2];c[d+16+4>>2]=c[l+4>>2];c[d+16+8>>2]=c[l+8>>2];c[d+16+12>>2]=c[l+12>>2];c[d+32>>2]=c[j>>2];c[d+32+4>>2]=c[j+4>>2];c[d+32+8>>2]=c[j+8>>2];c[d+32+12>>2]=c[j+12>>2];g[d+48>>2]=h;g[d+52>>2]=f;g[d+56>>2]=e;g[d+60>>2]=0.0;dh(d+64|0,d,a+4|0);c[b>>2]=c[d+64>>2];c[b+4>>2]=c[d+64+4>>2];c[b+8>>2]=c[d+64+8>>2];c[b+12>>2]=c[d+64+12>>2];c[b+16>>2]=c[d+64+16>>2];c[b+16+4>>2]=c[d+64+16+4>>2];c[b+16+8>>2]=c[d+64+16+8>>2];c[b+16+12>>2]=c[d+64+16+12>>2];c[b+32>>2]=c[d+64+32>>2];c[b+32+4>>2]=c[d+64+32+4>>2];c[b+32+8>>2]=c[d+64+32+8>>2];c[b+32+12>>2]=c[d+64+32+12>>2];c[b+48>>2]=c[d+64+48>>2];c[b+48+4>>2]=c[d+64+48+4>>2];c[b+48+8>>2]=c[d+64+48+8>>2];c[b+48+12>>2]=c[d+64+48+12>>2];i=d;return}function Ef(a,e,f){a=a|0;e=e|0;f=f|0;var h=0.0,i=0.0,j=0.0,k=0;si(a,e,f)|0;c[e+52>>2]=c[a+552>>2];c[e+56>>2]=c[a+556>>2];c[e+60>>2]=c[a+560>>2];c[e+64>>2]=c[a+564>>2];c[e+68>>2]=c[a+568>>2];c[e+72>>2]=c[a+572>>2];c[e+76>>2]=c[a+576>>2];c[e+80>>2]=c[a+580>>2];c[e+84>>2]=c[a+584>>2];c[e+88>>2]=c[a+588>>2];c[e+92>>2]=c[a+592>>2];c[e+96>>2]=c[a+596>>2];c[e+100>>2]=c[a+600>>2];c[e+104>>2]=c[a+604>>2];c[e+108>>2]=c[a+608>>2];c[e+112>>2]=c[a+612>>2];c[e+116>>2]=c[a+616>>2];c[e+120>>2]=c[a+620>>2];c[e+124>>2]=c[a+624>>2];c[e+128>>2]=c[a+628>>2];c[e+132>>2]=c[a+632>>2];c[e+136>>2]=c[a+636>>2];c[e+140>>2]=c[a+640>>2];c[e+144>>2]=c[a+644>>2];c[e+148>>2]=c[a+648>>2];c[e+152>>2]=c[a+652>>2];c[e+156>>2]=c[a+656>>2];c[e+160>>2]=c[a+660>>2];c[e+164>>2]=c[a+664>>2];c[e+168>>2]=c[a+668>>2];c[e+172>>2]=c[a+672>>2];c[e+176>>2]=c[a+676>>2];f=b[a+736>>1]|0;c[e+184>>2]=f&255;c[e+188>>2]=(f&65535)>>>8&65535;c[e+196>>2]=c[a+684>>2];c[e+192>>2]=c[a+680>>2];c[e+180>>2]=d[a+740>>0];i=+g[a+688>>2];j=+g[a+692>>2];h=+eh(i-j,6.2831854820251465);if(!(h<-3.1415927410125732)){if(h>3.1415927410125732)h=h+-6.2831854820251465}else h=h+6.2831854820251465;g[e+200>>2]=h;h=+eh(i+j,6.2831854820251465);if(h<-3.1415927410125732){j=h+6.2831854820251465;f=e+204|0;g[f>>2]=j;f=a+696|0;f=c[f>>2]|0;k=e+208|0;c[k>>2]=f;k=a+700|0;k=c[k>>2]|0;f=e+212|0;c[f>>2]=k;f=a+704|0;f=c[f>>2]|0;a=e+216|0;c[a>>2]=f;return 12773}if(!(h>3.1415927410125732)){j=h;k=e+204|0;g[k>>2]=j;k=a+696|0;k=c[k>>2]|0;f=e+208|0;c[f>>2]=k;f=a+700|0;f=c[f>>2]|0;k=e+212|0;c[k>>2]=f;a=a+704|0;a=c[a>>2]|0;k=e+216|0;c[k>>2]=a;return 12773}j=h+-6.2831854820251465;k=e+204|0;g[k>>2]=j;k=a+696|0;k=c[k>>2]|0;f=e+208|0;c[f>>2]=k;f=a+700|0;f=c[f>>2]|0;k=e+212|0;c[k>>2]=f;a=a+704|0;a=c[a>>2]|0;k=e+216|0;c[k>>2]=a;return 12773}function Ff(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;i=c[b+4>>2]|0;if((i|0)==(c[b+8>>2]|0)?(h=i|0?i<<1:1,(i|0)<(h|0)):0){if(!h){e=0;f=i}else{c[6435]=(c[6435]|0)+1;e=yc((h*244|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[b+4>>2]|0}if((f|0)>0){g=0;do{k=e+(g*244|0)|0;j=c[b+12>>2]|0;l=j+(g*244|0)|0;c[k>>2]=c[l>>2];c[k+4>>2]=c[l+4>>2];c[k+8>>2]=c[l+8>>2];c[k+12>>2]=c[l+12>>2];k=e+(g*244|0)+16|0;l=j+(g*244|0)+16|0;c[k>>2]=c[l>>2];c[k+4>>2]=c[l+4>>2];c[k+8>>2]=c[l+8>>2];c[k+12>>2]=c[l+12>>2];k=e+(g*244|0)+32|0;l=j+(g*244|0)+32|0;c[k>>2]=c[l>>2];c[k+4>>2]=c[l+4>>2];c[k+8>>2]=c[l+8>>2];c[k+12>>2]=c[l+12>>2];k=e+(g*244|0)+48|0;l=j+(g*244|0)+48|0;c[k>>2]=c[l>>2];c[k+4>>2]=c[l+4>>2];c[k+8>>2]=c[l+8>>2];c[k+12>>2]=c[l+12>>2];_m(e+(g*244|0)+64|0,j+(g*244|0)+64|0,180)|0;g=g+1|0}while((g|0)!=(f|0))}f=c[b+12>>2]|0;if(f|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=e;c[b+8>>2]=h;e=c[b+4>>2]|0}else e=i;c[b+4>>2]=e+1;l=c[b+12>>2]|0;c[l+(i*244|0)>>2]=c[d>>2];c[l+(i*244|0)+4>>2]=c[d+4>>2];c[l+(i*244|0)+8>>2]=c[d+8>>2];c[l+(i*244|0)+12>>2]=c[d+12>>2];c[l+(i*244|0)+16>>2]=c[d+16>>2];c[l+(i*244|0)+16+4>>2]=c[d+16+4>>2];c[l+(i*244|0)+16+8>>2]=c[d+16+8>>2];c[l+(i*244|0)+16+12>>2]=c[d+16+12>>2];c[l+(i*244|0)+32>>2]=c[d+32>>2];c[l+(i*244|0)+32+4>>2]=c[d+32+4>>2];c[l+(i*244|0)+32+8>>2]=c[d+32+8>>2];c[l+(i*244|0)+32+12>>2]=c[d+32+12>>2];c[l+(i*244|0)+48>>2]=c[d+48>>2];c[l+(i*244|0)+48+4>>2]=c[d+48+4>>2];c[l+(i*244|0)+48+8>>2]=c[d+48+8>>2];c[l+(i*244|0)+48+12>>2]=c[d+48+12>>2];_m(l+(i*244|0)+64|0,d+64|0,180)|0;return (c[b+12>>2]|0)+(i*244|0)|0}function Gf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0;l=i;i=i+64|0;n=+g[a+20>>2];u=+g[a+40>>2];p=+g[a+24>>2];s=+g[a+36>>2];t=+g[a+32>>2];m=+g[a+16>>2];k=+g[a>>2];j=+g[a+4>>2];q=+g[a+8>>2];h=1.0/((n*u-p*s)*k+j*(p*t-u*m)+(s*m-n*t)*q);z=+g[b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g[d+4>>2]=A*h*k;g[d+8>>2]=A*j*k;i=l;return}}function Hf(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;i=c[b+12>>2]|0;j=c[b+36>>2]|0;if((i|0)<=(j|0))return;if((i|0)>=(j|0)){do if((c[b+40>>2]|0)<(i|0)){if(!i){d=0;e=j}else{c[6435]=(c[6435]|0)+1;d=yc((i<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+36>>2]|0}f=c[b+44>>2]|0;if((e|0)<=0){if(!f){a[b+48>>0]=1;c[b+44>>2]=d;c[b+40>>2]=i;break}}else{g=0;do{c[d+(g<<2)>>2]=c[f+(g<<2)>>2];g=g+1|0}while((g|0)!=(e|0))}if(a[b+48>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[b+48>>0]=1;c[b+44>>2]=d;c[b+40>>2]=i}else d=c[b+44>>2]|0;while(0);Qn(d+(j<<2)|0,0,i-j<<2|0)|0}c[b+36>>2]=i;h=c[b+56>>2]|0;if((i|0)>(h|0)){do if((c[b+60>>2]|0)<(i|0)){if(!i){d=0;e=h}else{c[6435]=(c[6435]|0)+1;d=yc((i<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+56>>2]|0}f=c[b+64>>2]|0;if((e|0)<=0){if(!f){a[b+68>>0]=1;c[b+64>>2]=d;c[b+60>>2]=i;break}}else{g=0;do{c[d+(g<<2)>>2]=c[f+(g<<2)>>2];g=g+1|0}while((g|0)!=(e|0))}if(a[b+68>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[b+68>>0]=1;c[b+64>>2]=d;c[b+60>>2]=i}else d=c[b+64>>2]|0;while(0);Qn(d+(h<<2)|0,0,i-h<<2|0)|0}c[b+56>>2]=i;if((i|0)>0){Qn(c[b+44>>2]|0,-1,i<<2|0)|0;Qn(c[b+64>>2]|0,-1,i<<2|0)|0}if((j|0)<=0)return;d=c[b+16>>2]|0;e=c[b+44>>2]|0;f=c[b+64>>2]|0;g=0;do{i=c[(c[d+(g<<4)+4>>2]|0)+12>>2]<<16|c[(c[d+(g<<4)>>2]|0)+12>>2];i=(i+~(i<<15)>>10^i+~(i<<15))*9|0;i=e+((((i>>6^i)+~((i>>6^i)<<11)>>16^(i>>6^i)+~((i>>6^i)<<11))&(c[b+12>>2]|0)+-1)<<2)|0;c[f+(g<<2)>>2]=c[i>>2];c[i>>2]=g;g=g+1|0}while((g|0)!=(j|0));return}function If(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;if((c[b+8>>2]|0)>=(d|0))return;if((d|0)!=0?(c[6435]=(c[6435]|0)+1,e=yc((d*36|3)+16|0)|0,(e|0)!=0):0){c[(e+4+15&-16)+-4>>2]=e;o=e+4+15&-16}else o=0;i=c[b+4>>2]|0;if((i|0)>0){m=0;do{j=o+(m*36|0)|0;k=c[b+12>>2]|0;a[j+16>>0]=1;c[j+12>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;l=c[k+(m*36|0)+4>>2]|0;if((l|0)>0){c[6435]=(c[6435]|0)+1;e=yc((l<<2|3)+16|0)|0;if(!e)h=0;else{c[(e+4+15&-16)+-4>>2]=e;h=e+4+15&-16}g=c[j+4>>2]|0;f=c[j+12>>2]|0;if((g|0)<=0)if(!f){a[j+16>>0]=1;c[j+12>>2]=h;c[j+8>>2]=l;Qn(h|0,0,l<<2|0)|0}else n=14;else{e=0;do{c[h+(e<<2)>>2]=c[f+(e<<2)>>2];e=e+1|0}while((e|0)!=(g|0));n=14}if((n|0)==14){n=0;if(a[j+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[j+16>>0]=1;c[j+12>>2]=h;c[j+8>>2]=l;Qn(h|0,0,l<<2|0)|0}e=c[j+12>>2]|0;c[j+4>>2]=l;f=c[k+(m*36|0)+12>>2]|0;g=0;do{c[e+(g<<2)>>2]=c[f+(g<<2)>>2];g=g+1|0}while((g|0)!=(l|0))}else c[j+4>>2]=l;l=k+(m*36|0)+20|0;c[j+20>>2]=c[l>>2];c[j+20+4>>2]=c[l+4>>2];c[j+20+8>>2]=c[l+8>>2];c[j+20+12>>2]=c[l+12>>2];m=m+1|0}while((m|0)!=(i|0));e=c[b+4>>2]|0;if((e|0)>0){k=0;do{g=c[b+12>>2]|0;h=g+(k*36|0)+4|0;i=g+(k*36|0)+12|0;j=c[i>>2]|0;f=g+(k*36|0)+16|0;if(j|0){if(a[f>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[i>>2]=0}a[f>>0]=1;c[i>>2]=0;c[h>>2]=0;c[g+(k*36|0)+8>>2]=0;k=k+1|0}while((k|0)!=(e|0))}}e=c[b+12>>2]|0;if(e|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=o;c[b+8>>2]=d;return}function Jf(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,i=0.0,j=0.0,k=0.0,l=0.0;c[b+4>>2]=4;c[b>>2]=4432;c[b+8>>2]=-1;c[b+12>>2]=-1;g[b+16>>2]=3402823466385288598117041.0e14;a[b+20>>0]=1;a[b+21>>0]=0;c[b+24>>2]=-1;c[b+28>>2]=d;Il();c[b+32>>2]=23268;g[b+36>>2]=0.0;g[b+40>>2]=.30000001192092896;c[b+44>>2]=0;c[b>>2]=4704;c[b+552>>2]=c[e>>2];c[b+552+4>>2]=c[e+4>>2];c[b+552+8>>2]=c[e+8>>2];c[b+552+12>>2]=c[e+12>>2];c[b+568>>2]=c[e+16>>2];c[b+568+4>>2]=c[e+16+4>>2];c[b+568+8>>2]=c[e+16+8>>2];c[b+568+12>>2]=c[e+16+12>>2];c[b+584>>2]=c[e+32>>2];c[b+584+4>>2]=c[e+32+4>>2];c[b+584+8>>2]=c[e+32+8>>2];c[b+584+12>>2]=c[e+32+12>>2];c[b+600>>2]=c[e+48>>2];c[b+600+4>>2]=c[e+48+4>>2];c[b+600+8>>2]=c[e+48+8>>2];c[b+600+12>>2]=c[e+48+12>>2];c[b+616>>2]=c[e>>2];c[b+616+4>>2]=c[e+4>>2];c[b+616+8>>2]=c[e+8>>2];c[b+616+12>>2]=c[e+12>>2];c[b+632>>2]=c[e+16>>2];c[b+632+4>>2]=c[e+16+4>>2];c[b+632+8>>2]=c[e+16+8>>2];c[b+632+12>>2]=c[e+16+12>>2];c[b+648>>2]=c[e+32>>2];c[b+648+4>>2]=c[e+32+4>>2];c[b+648+8>>2]=c[e+32+8>>2];c[b+648+12>>2]=c[e+32+12>>2];c[b+664>>2]=c[e+48>>2];c[b+664+4>>2]=c[e+48+4>>2];c[b+664+8>>2]=c[e+48+8>>2];c[b+664+12>>2]=c[e+48+12>>2];g[b+688>>2]=0.0;g[b+692>>2]=-1.0;g[b+696>>2]=.8999999761581421;g[b+700>>2]=.30000001192092896;g[b+704>>2]=1.0;g[b+708>>2]=0.0;g[b+712>>2]=0.0;a[b+716>>0]=0;a[b+736>>0]=0;a[b+737>>0]=0;a[b+738>>0]=0;a[b+739>>0]=1;a[b+740>>0]=f&1;c[b+748>>2]=0;e=c[b+28>>2]|0;l=+g[b+600>>2];k=+g[b+604>>2];j=+g[b+608>>2];i=l*+g[e+20>>2]+k*+g[e+24>>2]+j*+g[e+28>>2]+ +g[e+56>>2];h=l*+g[e+36>>2]+k*+g[e+40>>2]+j*+g[e+44>>2]+ +g[e+60>>2];g[b+664>>2]=l*+g[e+4>>2]+k*+g[e+8>>2]+j*+g[e+12>>2]+ +g[e+52>>2];g[b+668>>2]=i;g[b+672>>2]=h;g[b+676>>2]=0.0;g[b+732>>2]=f?-1.0:1.0;return}function Kf(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;i=c[b+12>>2]|0;j=c[b+32>>2]|0;if((i|0)<=(j|0))return;if((i|0)>=(j|0)){do if((c[b+36>>2]|0)<(i|0)){if(!i){d=0;e=j}else{c[6435]=(c[6435]|0)+1;d=yc((i<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+32>>2]|0}f=c[b+40>>2]|0;if((e|0)<=0){if(!f){a[b+44>>0]=1;c[b+40>>2]=d;c[b+36>>2]=i;break}}else{g=0;do{c[d+(g<<2)>>2]=c[f+(g<<2)>>2];g=g+1|0}while((g|0)!=(e|0))}if(a[b+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[b+44>>0]=1;c[b+40>>2]=d;c[b+36>>2]=i}else d=c[b+40>>2]|0;while(0);Qn(d+(j<<2)|0,0,i-j<<2|0)|0}c[b+32>>2]=i;h=c[b+52>>2]|0;if((i|0)>(h|0)){do if((c[b+56>>2]|0)<(i|0)){if(!i){d=0;e=h}else{c[6435]=(c[6435]|0)+1;d=yc((i<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+52>>2]|0}f=c[b+60>>2]|0;if((e|0)<=0){if(!f){a[b+64>>0]=1;c[b+60>>2]=d;c[b+56>>2]=i;break}}else{g=0;do{c[d+(g<<2)>>2]=c[f+(g<<2)>>2];g=g+1|0}while((g|0)!=(e|0))}if(a[b+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[b+64>>0]=1;c[b+60>>2]=d;c[b+56>>2]=i}else d=c[b+60>>2]|0;while(0);Qn(d+(h<<2)|0,0,i-h<<2|0)|0}c[b+52>>2]=i;if((i|0)>0){Qn(c[b+40>>2]|0,-1,i<<2|0)|0;Qn(c[b+60>>2]|0,-1,i<<2|0)|0}if((j|0)<=0)return;d=c[b+16>>2]|0;e=c[b+40>>2]|0;f=c[b+60>>2]|0;g=0;do{i=c[d+(g*12|0)+4>>2]<<16|c[d+(g*12|0)>>2];i=(i+~(i<<15)>>10^i+~(i<<15))*9|0;i=e+((((i>>6^i)+~((i>>6^i)<<11)>>16^(i>>6^i)+~((i>>6^i)<<11))&(c[b+12>>2]|0)+-1)<<2)|0;c[f+(g<<2)>>2]=c[i>>2];c[i>>2]=g;g=g+1|0}while((g|0)!=(j|0));return}function Lf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;g=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=g;if(g|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+20>>2]=c[a+72>>2];e=c[a+16>>2]|0;c[b+16>>2]=e;c[b+12>>2]=0;if(!e)return 16387;g=Ob[c[(c[d>>2]|0)+16>>2]&63](d,76,e)|0;e=c[g+8>>2]|0;c[b+12>>2]=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;if((c[b+16>>2]|0)>0){f=0;while(1){h=c[a+24>>2]|0;c[e+72>>2]=c[h+(f*80|0)+72>>2];c[e+64>>2]=Zb[c[(c[d>>2]|0)+28>>2]&31](d,c[h+(f*80|0)+64>>2]|0)|0;if(!(Zb[c[(c[d>>2]|0)+24>>2]&31](d,c[(c[a+24>>2]|0)+(f*80|0)+64>>2]|0)|0)){h=c[(c[d>>2]|0)+16>>2]|0;i=c[(c[a+24>>2]|0)+(f*80|0)+64>>2]|0;i=Eb[c[(c[i>>2]|0)+52>>2]&127](i)|0;i=Ob[h&63](d,i,1)|0;h=c[(c[a+24>>2]|0)+(f*80|0)+64>>2]|0;h=Ob[c[(c[h>>2]|0)+56>>2]&63](h,c[i+8>>2]|0,d)|0;yb[c[(c[d>>2]|0)+20>>2]&31](d,i,h,1346455635,c[(c[a+24>>2]|0)+(f*80|0)+64>>2]|0)}i=c[a+24>>2]|0;c[e+68>>2]=c[i+(f*80|0)+68>>2];c[e>>2]=c[i+(f*80|0)>>2];c[e+4>>2]=c[i+(f*80|0)+4>>2];c[e+8>>2]=c[i+(f*80|0)+8>>2];c[e+12>>2]=c[i+(f*80|0)+12>>2];c[e+16>>2]=c[i+(f*80|0)+16>>2];c[e+20>>2]=c[i+(f*80|0)+20>>2];c[e+24>>2]=c[i+(f*80|0)+24>>2];c[e+28>>2]=c[i+(f*80|0)+28>>2];c[e+32>>2]=c[i+(f*80|0)+32>>2];c[e+36>>2]=c[i+(f*80|0)+36>>2];c[e+40>>2]=c[i+(f*80|0)+40>>2];c[e+44>>2]=c[i+(f*80|0)+44>>2];c[e+48>>2]=c[i+(f*80|0)+48>>2];c[e+52>>2]=c[i+(f*80|0)+52>>2];c[e+56>>2]=c[i+(f*80|0)+56>>2];c[e+60>>2]=c[i+(f*80|0)+60>>2];f=f+1|0;if((f|0)>=(c[b+16>>2]|0)){e=d;break}else e=e+76|0}}else e=d;yb[c[(c[e>>2]|0)+20>>2]&31](d,g,16362,1497453121,c[g+8>>2]|0);return 16387}function Mf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0;f=i;i=i+256|0;c[f+32>>2]=5736;l=f+32+36|0;c[l>>2]=c[b>>2];c[l+4>>2]=c[b+4>>2];c[l+8>>2]=c[b+8>>2];c[l+12>>2]=c[b+12>>2];m=f+32+52|0;c[m>>2]=c[d>>2];c[m+4>>2]=c[d+4>>2];c[m+8>>2]=c[d+8>>2];c[m+12>>2]=c[d+12>>2];c[f+32+212>>2]=a;c[f+32+216>>2]=e;c[f+32+68>>2]=1065353216;c[f+32+72>>2]=0;c[f+32+72+4>>2]=0;c[f+32+72+8>>2]=0;c[f+32+72+12>>2]=0;c[f+32+88>>2]=1065353216;c[f+32+92>>2]=0;c[f+32+92+4>>2]=0;c[f+32+92+8>>2]=0;c[f+32+92+12>>2]=0;c[f+32+108>>2]=1065353216;c[f+32+112>>2]=0;c[f+32+116>>2]=c[l>>2];c[f+32+116+4>>2]=c[l+4>>2];c[f+32+116+8>>2]=c[l+8>>2];c[f+32+116+12>>2]=c[l+12>>2];c[f+32+132>>2]=1065353216;c[f+32+136>>2]=0;c[f+32+136+4>>2]=0;c[f+32+136+8>>2]=0;c[f+32+136+12>>2]=0;c[f+32+152>>2]=1065353216;c[f+32+156>>2]=0;c[f+32+156+4>>2]=0;c[f+32+156+8>>2]=0;c[f+32+156+12>>2]=0;c[f+32+172>>2]=1065353216;c[f+32+176>>2]=0;c[f+32+180>>2]=c[d>>2];c[f+32+180+4>>2]=c[d+4>>2];c[f+32+180+8>>2]=c[d+8>>2];c[f+32+180+12>>2]=c[d+12>>2];n=+g[d>>2]-+g[b>>2];k=+g[d+4>>2]-+g[b+4>>2];j=+g[d+8>>2]-+g[b+8>>2];h=1.0/+O(+(n*n+k*k+j*j));q=n*h==0.0?999999984306749440.0:1.0/(n*h);g[f+32+4>>2]=q;p=k*h==0.0?999999984306749440.0:1.0/(k*h);g[f+32+8>>2]=p;o=j*h==0.0?999999984306749440.0:1.0/(j*h);g[f+32+12>>2]=o;c[f+32+20>>2]=q<0.0&1;c[f+32+24>>2]=p<0.0&1;c[f+32+28>>2]=o<0.0&1;g[f+32+32>>2]=n*h*(+g[m>>2]-+g[l>>2])+k*h*(+g[f+32+56>>2]-+g[f+32+40>>2])+j*h*(+g[f+32+60>>2]-+g[f+32+44>>2]);a=c[a+68>>2]|0;e=c[(c[a>>2]|0)+24>>2]|0;c[f+16>>2]=0;c[f+16+4>>2]=0;c[f+16+8>>2]=0;c[f+16+12>>2]=0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;Qb[e&7](a,b,d,f+32|0,f+16|0,f);i=f;return}function Nf(b,d,e,f,h,j,k,l,m){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0,q=0;q=i;i=i+80|0;g[q+16+60>>2]=0.0;g[q+16+8>>2]=0.0;g[q+16+12>>2]=.10000000149011612;g[q+16+16>>2]=300.0;g[q+16>>2]=1.0;g[q+16+4>>2]=-1.0;g[q+16+28>>2]=0.0;g[q+16+32>>2]=.20000000298023224;g[q+16+36>>2]=0.0;g[q+16+40>>2]=0.0;g[q+16+20>>2]=1.0;g[q+16+24>>2]=.5;c[q+16+56>>2]=0;g[q+16+48>>2]=0.0;a[q+16+44>>0]=0;p=0;do{n=c[b+856+(p<<2)>>2]|0;o=a[b+788+p>>0]|0;if(!((n|0)==0&o<<24>>24==0)){g[q+16+40>>2]=0.0;c[q+16+56>>2]=n;c[q+16+52>>2]=c[b+840+(p<<2)>>2];c[q+16+48>>2]=c[b+824+(p<<2)>>2];c[q+16+20>>2]=c[b+732>>2];a[q+16+44>>0]=o;c[q+16+4>>2]=c[b+696+(p<<2)>>2];c[q+16+24>>2]=c[b+728>>2];c[q+16>>2]=c[b+680+(p<<2)>>2];g[q+16+16>>2]=0.0;c[q+16+12>>2]=c[b+808+(p<<2)>>2];c[q+16+8>>2]=c[b+792+(p<<2)>>2];c[q>>2]=c[b+1064+(p<<2)>>2];c[q+4>>2]=c[b+1080+(p<<2)>>2];c[q+8>>2]=c[b+1096+(p<<2)>>2];g[q+12>>2]=0.0;o=c[b+1304>>2]>>p*3;if(!(o&1))n=c[d+32>>2]|0;else n=b+740+(p<<2)|0;c[q+16+28>>2]=c[n>>2];if(!(o&2))n=c[d+32>>2]|0;else n=b+772+(p<<2)|0;c[q+16+36>>2]=c[n>>2];c[q+16+32>>2]=c[((o&4|0)==0?d+4|0:b+756+(p<<2)|0)>>2];if(!(a[b+1301>>0]|0))n=Dd(b,q+16|0,f,h,j,k,l,m,d,e,q,0,0)|0;else{o=p+1|0;if(!(c[b+868+(((o|0)==3?0:o)<<6)+56>>2]|0))n=1;else n=(c[b+868+(((p+2|0)%3|0)<<6)+56>>2]|0)==0&1;n=Dd(b,q+16|0,f,h,j,k,l,m,d,e,q,0,n)|0}e=n+e|0}p=p+1|0}while((p|0)!=3);i=q;return e|0}function Of(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;h=i;i=i+128|0;if(!b){i=h;return}if(c[b+40>>2]|0){Of(a,c[b+36>>2]|0,d+1|0,e,f);Of(a,c[b+40>>2]|0,d+1|0,e,f)}if((d|0)<0){i=h;return}m=+g[b>>2];r=+g[b+16>>2];k=+g[b+4>>2];q=+g[b+20>>2];j=+g[b+8>>2];p=+g[b+24>>2];l=(m+r)*.5-(r-m)*.5;n=(k+q)*.5-(q-k)*.5;o=(j+p)*.5-(p-j)*.5;m=(m+r)*.5+(r-m)*.5;k=(k+q)*.5+(q-k)*.5;j=(j+p)*.5+(p-j)*.5;b=(c[b+40>>2]|0)==0?f:e;g[h>>2]=l;g[h+4>>2]=n;g[h+8>>2]=o;g[h+12>>2]=0.0;g[h+16>>2]=m;g[h+20>>2]=n;g[h+24>>2]=o;g[h+28>>2]=0.0;g[h+32>>2]=m;g[h+36>>2]=k;g[h+40>>2]=o;g[h+44>>2]=0.0;g[h+48>>2]=l;g[h+52>>2]=k;g[h+56>>2]=o;g[h+60>>2]=0.0;g[h+64>>2]=l;g[h+68>>2]=n;g[h+72>>2]=j;g[h+76>>2]=0.0;g[h+80>>2]=m;g[h+84>>2]=n;g[h+88>>2]=j;g[h+92>>2]=0.0;g[h+96>>2]=m;g[h+100>>2]=k;g[h+104>>2]=j;g[h+108>>2]=0.0;g[h+112>>2]=l;g[h+116>>2]=k;g[h+120>>2]=j;g[h+124>>2]=0.0;mc[c[(c[a>>2]|0)+8>>2]&127](a,h,h+16|0,b);mc[c[(c[a>>2]|0)+8>>2]&127](a,h+16|0,h+32|0,b);mc[c[(c[a>>2]|0)+8>>2]&127](a,h+32|0,h+48|0,b);mc[c[(c[a>>2]|0)+8>>2]&127](a,h+48|0,h,b);mc[c[(c[a>>2]|0)+8>>2]&127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>>2]|0;else q=j;j=c[b+772>>2]|0;if((j|0)==(c[b+776>>2]|0)?(p=j|0?j<<1:1,(j|0)<(p|0)):0){if(!p)o=0;else{c[6435]=(c[6435]|0)+1;j=yc((p*104|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}o=j;j=c[b+772>>2]|0}if((j|0)>0){k=0;do{m=o+(k*104|0)|0;l=(c[b+780>>2]|0)+(k*104|0)|0;n=m+104|0;do{c[m>>2]=c[l>>2];m=m+4|0;l=l+4|0}while((m|0)<(n|0));k=k+1|0}while((k|0)!=(j|0))}j=c[b+780>>2]|0;if(j|0){if(a[b+784>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[b+780>>2]=0}a[b+784>>0]=1;c[b+780>>2]=o;c[b+776>>2]=p;j=c[b+772>>2]|0}m=c[b+780>>2]|0;c[m+(j*104|0)>>2]=0;c[m+(j*104|0)+4>>2]=q;m=m+(j*104|0)+8|0;l=r;n=m+96|0;do{c[m>>2]=c[l>>2];m=m+4|0;l=l+4|0}while((m|0)<(n|0));q=c[b+772>>2]|0;c[b+772>>2]=q+1;p=c[b+780>>2]|0;l=c[b+720>>2]|0;c[p+(q*104|0)+8>>2]=l+(d*104|0);o=c[b+720>>2]|0;c[p+(q*104|0)+12>>2]=o+(e*104|0);m=c[b+720>>2]|0;c[p+(q*104|0)+16>>2]=m+(f*104|0);n=c[b+720>>2]|0;c[p+(q*104|0)+20>>2]=n+(h*104|0);z=+g[l+(d*104|0)+8>>2];w=+g[l+(d*104|0)+12>>2];A=+g[l+(d*104|0)+16>>2];t=+g[m+(f*104|0)+8>>2]-z;y=+g[m+(f*104|0)+12>>2]-w;v=+g[m+(f*104|0)+16>>2]-A;u=+g[n+(h*104|0)+8>>2]-z;x=+g[n+(h*104|0)+12>>2]-w;s=+g[n+(h*104|0)+16>>2]-A;g[p+(q*104|0)+24>>2]=(+g[o+(e*104|0)+16>>2]-A)*(t*x-y*u)+((+g[o+(e*104|0)+8>>2]-z)*(y*s-v*x)+(+g[o+(e*104|0)+12>>2]-w)*(v*u-t*s));a[b+924>>0]=1;i=r;return}function Rf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0;q=i;i=i+48|0;p=c[b+720>>2]|0;a:do if(h?(l=c[b+732>>2]|0,(l|0)>0):0){j=c[b+740>>2]|0;k=0;while(1){h=c[j+(k*52|0)+8>>2]|0;if((h|0)==(p+(d*104|0)|0)?(c[j+(k*52|0)+12>>2]|0)==(p+(e*104|0)|0):0){h=25;break}if((h|0)==(p+(e*104|0)|0)?(c[j+(k*52|0)+12>>2]|0)==(p+(d*104|0)|0):0){h=25;break}k=k+1|0;if((k|0)>=(l|0))break a}if((h|0)==25){i=q;return}}while(0);l=q;m=l+44|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(m|0));if(!f)n=c[c[b+880>>2]>>2]|0;else n=f;h=c[b+732>>2]|0;if((h|0)==(c[b+736>>2]|0)?(o=h|0?h<<1:1,(h|0)<(o|0)):0){if(!o)f=0;else{c[6435]=(c[6435]|0)+1;h=yc((o*52|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}f=h;h=c[b+732>>2]|0}if((h|0)>0){j=0;do{l=f+(j*52|0)|0;k=(c[b+740>>2]|0)+(j*52|0)|0;m=l+52|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(m|0));j=j+1|0}while((j|0)!=(h|0))}h=c[b+740>>2]|0;if(h|0){if(a[b+744>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+740>>2]=0}a[b+744>>0]=1;c[b+740>>2]=f;c[b+736>>2]=o;h=c[b+732>>2]|0}l=c[b+740>>2]|0;c[l+(h*52|0)>>2]=0;c[l+(h*52|0)+4>>2]=n;l=l+(h*52|0)+8|0;k=q;m=l+44|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(m|0));o=c[b+732>>2]|0;c[b+732>>2]=o+1;n=c[b+740>>2]|0;c[n+(o*52|0)+8>>2]=p+(d*104|0);c[n+(o*52|0)+12>>2]=p+(e*104|0);t=+g[p+(d*104|0)+8>>2]-+g[p+(e*104|0)+8>>2];s=+g[p+(d*104|0)+12>>2]-+g[p+(e*104|0)+12>>2];r=+g[p+(d*104|0)+16>>2]-+g[p+(e*104|0)+16>>2];g[n+(o*52|0)+16>>2]=+O(+(t*t+s*s+r*r));a[b+924>>0]=1;i=q;return}function Sf(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0;f=i;i=i+784|0;c[f+712>>2]=1065353216;c[f+712+4>>2]=0;c[f+712+4+4>>2]=0;c[f+712+4+8>>2]=0;c[f+712+4+12>>2]=0;c[f+712+20>>2]=1065353216;c[f+712+24>>2]=0;c[f+712+24+4>>2]=0;c[f+712+24+8>>2]=0;c[f+712+24+12>>2]=0;c[f+712+40>>2]=1065353216;e=f+712+44|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[f+536>>2]=3708;c[f+536+168>>2]=0;g[f+536+172>>2]=0.0;c[f+536+164>>2]=c[b+200>>2];e=c[b+196>>2]|0;c[f+480+8>>2]=0;c[f+480+12>>2]=1065353216;c[f+480+16>>2]=1065353216;c[f+480+20>>2]=1065353216;g[f+480+24>>2]=0.0;c[f+480>>2]=6672;c[f+480+4>>2]=8;c[f+480+28>>2]=e;c[f+480+44>>2]=e;c[f+376+8>>2]=0;c[f+376+12>>2]=1065353216;c[f+376+16>>2]=1065353216;c[f+376+20>>2]=1065353216;g[f+376+24>>2]=0.0;g[f+376+44>>2]=.03999999910593033;c[f+376+52>>2]=0;c[f+376>>2]=3736;c[f+376+4>>2]=1;c[f+376+56>>2]=c[d>>2];c[f+376+56+4>>2]=c[d+4>>2];c[f+376+56+8>>2]=c[d+8>>2];c[f+376+56+12>>2]=c[d+12>>2];c[f+376+72>>2]=c[d+16>>2];c[f+376+72+4>>2]=c[d+16+4>>2];c[f+376+72+8>>2]=c[d+16+8>>2];c[f+376+72+12>>2]=c[d+16+12>>2];c[f+376+88>>2]=c[d+32>>2];c[f+376+88+4>>2]=c[d+32+4>>2];c[f+376+88+8>>2]=c[d+32+8>>2];c[f+376+88+12>>2]=c[d+32+12>>2];g[f+16+308>>2]=9.999999747378752e-05;a[f+16+332>>0]=0;c[f>>2]=4960;c[f+4>>2]=f+16;c[f+8>>2]=f+480;c[f+12>>2]=f+376;if(od(f,b+4|0,b+68|0,f+712|0,f+712|0,f+536|0)|0?(h=+g[f+536+164>>2],+g[b+200>>2]>h):0)g[b+200>>2]=h;c[f+376>>2]=7124;e=c[f+376+52>>2]|0;if(!e){i=f;return}Ab[c[c[e>>2]>>2]&255](e);e=c[f+376+52>>2]|0;if(!e){i=f;return}c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);i=f;return}function Tf(d,e,f,g,h,j,k,l,m){d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0;o=i;i=i+48|0;c[6435]=(c[6435]|0)+1;g=yc(83)|0;if(!g)n=0;else{c[(g+4+15&-16)+-4>>2]=g;n=g+4+15&-16}c[n>>2]=h;b[n+4>>1]=j;b[n+6>>1]=k;j=n+16|0;c[j>>2]=c[e>>2];c[j+4>>2]=c[e+4>>2];c[j+8>>2]=c[e+8>>2];c[j+12>>2]=c[e+12>>2];j=n+32|0;c[j>>2]=c[f>>2];c[j+4>>2]=c[f+4>>2];c[j+8>>2]=c[f+8>>2];c[j+12>>2]=c[f+12>>2];c[n+8>>2]=0;j=n+56|0;c[j>>2]=0;k=n+52|0;c[k>>2]=0;c[o+16>>2]=c[e>>2];c[o+16+4>>2]=c[e+4>>2];c[o+16+8>>2]=c[e+8>>2];c[o+16+12>>2]=c[e+12>>2];c[o+16+16>>2]=c[f>>2];c[o+16+16+4>>2]=c[f+4>>2];c[o+16+16+8>>2]=c[f+8>>2];c[o+16+16+12>>2]=c[f+12>>2];c[n+60>>2]=c[d+144>>2];g=(c[d+188>>2]|0)+1|0;c[d+188>>2]=g;c[n+12>>2]=g;g=c[d+8>>2]|0;if(!g){c[6435]=(c[6435]|0)+1;g=yc(63)|0;if(!g)g=0;else{c[(g+4+15&-16)+-4>>2]=g;g=g+4+15&-16}l=g;m=l+44|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(m|0))}else c[d+8>>2]=0;c[g+32>>2]=0;c[g+36>>2]=n;c[g+40>>2]=0;c[g>>2]=c[o+16>>2];c[g+4>>2]=c[o+16+4>>2];c[g+8>>2]=c[o+16+8>>2];c[g+12>>2]=c[o+16+12>>2];c[g+16>>2]=c[o+16+16>>2];c[g+20>>2]=c[o+16+20>>2];c[g+24>>2]=c[o+16+24>>2];c[g+28>>2]=c[o+16+28>>2];lf(d+4|0,c[d+4>>2]|0,g);c[d+16>>2]=(c[d+16>>2]|0)+1;c[n+48>>2]=g;l=d+124+(c[d+144>>2]<<2)|0;c[k>>2]=0;c[j>>2]=c[l>>2];g=c[l>>2]|0;if(g|0)c[g+52>>2]=n;c[l>>2]=n;if(a[d+193>>0]|0){i=o;return n|0}c[o>>2]=8904;c[o+4>>2]=d;c[o+8>>2]=n;bg(c[d+4>>2]|0,o+16|0,o);bg(c[d+64>>2]|0,o+16|0,o);i=o;return n|0}function Uf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0;f=i;i=i+608|0;p=+g[d+116>>2]-+g[d+52>>2];o=+g[d+120>>2]-+g[d+56>>2];n=+g[d+124>>2]-+g[d+60>>2];j=+g[e+116>>2]-+g[e+52>>2];k=+g[e+120>>2]-+g[e+56>>2];l=+g[e+124>>2]-+g[e+60>>2];m=+g[d+252>>2];if(p*p+o*o+n*n>2],j*j+k*k+l*l>2]|0;h=c[e+248>>2]|0;c[f+552+8>>2]=0;c[f+552+12>>2]=1065353216;c[f+552+16>>2]=1065353216;c[f+552+20>>2]=1065353216;g[f+552+24>>2]=0.0;c[f+552>>2]=6672;c[f+552+4>>2]=8;c[f+552+28>>2]=h;c[f+552+44>>2]=h;c[f+376>>2]=3708;g[f+376+164>>2]=999999984306749440.0;c[f+376+168>>2]=0;g[f+376+172>>2]=0.0;g[f+16+308>>2]=9.999999747378752e-05;a[f+16+332>>0]=0;c[f>>2]=9140;c[f+4>>2]=f+16;c[f+8>>2]=b;c[f+12>>2]=f+552;if(Ed(f,d+4|0,d+68|0,e+4|0,e+68|0,f+376|0)|0){j=+g[f+376+164>>2];if(+g[d+244>>2]>j)g[d+244>>2]=j;if(+g[e+244>>2]>j)g[e+244>>2]=j;if(j<1.0)k=j;else k=1.0}else k=1.0;b=c[e+192>>2]|0;h=c[d+248>>2]|0;c[f+552+8>>2]=0;c[f+552+12>>2]=1065353216;c[f+552+16>>2]=1065353216;c[f+552+20>>2]=1065353216;g[f+552+24>>2]=0.0;c[f+552>>2]=6672;c[f+552+4>>2]=8;c[f+552+28>>2]=h;c[f+552+44>>2]=h;c[f+376>>2]=3708;g[f+376+164>>2]=999999984306749440.0;c[f+376+168>>2]=0;g[f+376+172>>2]=0.0;g[f+16+308>>2]=9.999999747378752e-05;a[f+16+332>>0]=0;c[f>>2]=9140;c[f+4>>2]=f+16;c[f+8>>2]=f+552;c[f+12>>2]=b;if(Ed(f,d+4|0,d+68|0,e+4|0,e+68|0,f+376|0)|0){j=+g[f+376+164>>2];if(+g[d+244>>2]>j)g[d+244>>2]=j;if(+g[e+244>>2]>j)g[e+244>>2]=j;if(!(k>j))j=k}else j=k;p=j;i=f;return +p}function Vf(a,d){a=a|0;d=d|0;var e=0,f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0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g[b+36>>2];p=l*+g[b+8>>2]+m*+g[b+24>>2]+n*+g[b+40>>2];g[j>>2]=+g[b>>2]*l+ +g[b+16>>2]*m+ +g[b+32>>2]*n;g[j+4>>2]=o;g[j+8>>2]=p;g[j+12>>2]=0.0;ic[q&127](j+16|0,a,j);p=+g[j+16>>2];o=+g[j+16+4>>2];n=+g[j+16+8>>2];m=p*+g[b+16>>2]+o*+g[b+20>>2]+n*+g[b+24>>2]+ +g[b+52>>2];l=p*+g[b+32>>2]+o*+g[b+36>>2]+n*+g[b+40>>2]+ +g[b+56>>2];g[j+48>>2]=p*+g[b>>2]+o*+g[b+4>>2]+n*+g[b+8>>2]+ +g[b+48>>2];g[j+48+4>>2]=m;g[j+48+8>>2]=l;g[j+48+12>>2]=0.0;g[d+(h<<2)>>2]=+g[k>>2]-f;h=h+1|0}while((h|0)!=3);i=j;return}function Xf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;l=i;i=i+160|0;j=c[b+12>>2]|0;if(!j){i=l;return}m=(a[b+16>>0]|0)!=0;n=m?e:d;e=m?d:e;p=c[n+4>>2]|0;o=c[e+4>>2]|0;c[h+4>>2]=j;d=c[j+752>>2]|0;c[l+136>>2]=9304;c[l+136+4>>2]=p;c[l+136+8>>2]=o;c[l+136+12>>2]=d;g[l+128>>2]=999999984306749440.0;d=c[n+12>>2]|0;c[l>>2]=c[d>>2];c[l+4>>2]=c[d+4>>2];c[l+8>>2]=c[d+8>>2];c[l+12>>2]=c[d+12>>2];c[l+16>>2]=c[d+16>>2];c[l+16+4>>2]=c[d+16+4>>2];c[l+16+8>>2]=c[d+16+8>>2];c[l+16+12>>2]=c[d+16+12>>2];c[l+32>>2]=c[d+32>>2];c[l+32+4>>2]=c[d+32+4>>2];c[l+32+8>>2]=c[d+32+8>>2];c[l+32+12>>2]=c[d+32+12>>2];c[l+48>>2]=c[d+48>>2];c[l+48+4>>2]=c[d+48+4>>2];c[l+48+8>>2]=c[d+48+8>>2];c[l+48+12>>2]=c[d+48+12>>2];e=c[e+12>>2]|0;c[l+64>>2]=c[e>>2];c[l+64+4>>2]=c[e+4>>2];c[l+64+8>>2]=c[e+8>>2];c[l+64+12>>2]=c[e+12>>2];c[l+80>>2]=c[e+16>>2];c[l+80+4>>2]=c[e+16+4>>2];c[l+80+8>>2]=c[e+16+8>>2];c[l+80+12>>2]=c[e+16+12>>2];c[l+96>>2]=c[e+32>>2];c[l+96+4>>2]=c[e+32+4>>2];c[l+96+8>>2]=c[e+32+8>>2];c[l+96+12>>2]=c[e+32+12>>2];c[l+112>>2]=c[e+48>>2];c[l+112+4>>2]=c[e+48+4>>2];c[l+112+8>>2]=c[e+48+8>>2];c[l+112+12>>2]=c[e+48+12>>2];$d(l+136|0,l,h,c[f+20>>2]|0,m);do if(a[b+8>>0]|0?(k=c[h+4>>2]|0,c[k+748>>2]|0):0){d=c[k+740>>2]|0;e=c[(c[h+8>>2]|0)+8>>2]|0;j=c[(c[h+12>>2]|0)+8>>2]|0;if((d|0)==(e|0)){ef(k,d+4|0,j+4|0);break}else{ef(k,j+4|0,e+4|0);break}}while(0);i=l;return}function Yf(d,e,f){d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0;c[d+4>>2]=1065353216;c[d+8>>2]=1065353216;c[d+12>>2]=1065353216;g[d+16>>2]=0.0;a[d+36>>0]=1;c[d+32>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;c[d+48>>2]=0;c[d>>2]=8452;a[d+100>>0]=1;c[d+96>>2]=0;c[d+88>>2]=0;c[d+92>>2]=0;a[d+120>>0]=1;c[d+116>>2]=0;c[d+108>>2]=0;c[d+112>>2]=0;a[d+140>>0]=1;c[d+136>>2]=0;c[d+128>>2]=0;c[d+132>>2]=0;a[d+160>>0]=1;c[d+156>>2]=0;c[d+148>>2]=0;c[d+152>>2]=0;a[d+164>>0]=e&1;a[d+165>>0]=f&1;g[d+168>>2]=0.0;c[6435]=(c[6435]|0)+1;e=yc(51)|0;if(!e)h=0;else{c[(e+4+15&-16)+-4>>2]=e;h=e+4+15&-16}e=c[d+24>>2]|0;if((e|0)>0){f=0;do{i=h+(f<<5)|0;j=(c[d+32>>2]|0)+(f<<5)|0;c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];c[i+16>>2]=c[j+16>>2];c[i+20>>2]=c[j+20>>2];c[i+24>>2]=c[j+24>>2];c[i+28>>2]=c[j+28>>2];f=f+1|0}while((f|0)!=(e|0))}e=c[d+32>>2]|0;if(e|0){if(a[d+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[d+32>>2]=0}a[d+36>>0]=1;c[d+32>>2]=h;c[d+28>>2]=1;e=c[d+24>>2]|0;c[h+(e<<5)>>2]=0;c[h+(e<<5)+4>>2]=0;c[h+(e<<5)+8>>2]=12;c[h+(e<<5)+12>>2]=0;c[h+(e<<5)+16>>2]=0;c[h+(e<<5)+20>>2]=16;c[h+(e<<5)+24>>2]=2;c[h+(e<<5)+28>>2]=0;c[d+24>>2]=(c[d+24>>2]|0)+1;e=b[d+164>>1]|0;if(!((e&255)<<24>>24)){f=c[d+32>>2]|0;c[f>>2]=(c[d+148>>2]|0)/3|0;c[f+4>>2]=0;c[f+24>>2]=3;c[f+8>>2]=6}else{f=c[d+32>>2]|0;c[f>>2]=(c[d+128>>2]|0)/3|0;c[f+4>>2]=0;c[f+24>>2]=2;c[f+8>>2]=12}if((e&65535)<256){i=12;d=(c[d+108>>2]|0)/3|0;j=f+12|0;c[j>>2]=d;j=f+16|0;c[j>>2]=0;j=f+20|0;c[j>>2]=i;return}else{i=16;d=c[d+88>>2]|0;j=f+12|0;c[j>>2]=d;j=f+16|0;c[j>>2]=0;j=f+20|0;c[j>>2]=i;return}}function Zf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0;q=i;i=i+48|0;if((f|0)==(d|0)|((d|0)==(e|0)|(e|0)==(f|0))){i=q;return}l=q;m=l+36|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(m|0));if(!h)p=c[c[b+880>>2]>>2]|0;else p=h;h=c[b+752>>2]|0;if((h|0)==(c[b+756>>2]|0)?(o=h|0?h<<1:1,(h|0)<(o|0)):0){if(!o)n=0;else{c[6435]=(c[6435]|0)+1;h=yc((o*44|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}n=h;h=c[b+752>>2]|0}if((h|0)>0){j=0;do{l=n+(j*44|0)|0;k=(c[b+760>>2]|0)+(j*44|0)|0;m=l+44|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(m|0));j=j+1|0}while((j|0)!=(h|0))}h=c[b+760>>2]|0;if(h|0){if(a[b+764>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+760>>2]=0}a[b+764>>0]=1;c[b+760>>2]=n;c[b+756>>2]=o;h=c[b+752>>2]|0}l=c[b+760>>2]|0;c[l+(h*44|0)>>2]=0;c[l+(h*44|0)+4>>2]=p;l=l+(h*44|0)+8|0;k=q;m=l+36|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(m|0));p=c[b+752>>2]|0;c[b+752>>2]=p+1;o=c[b+760>>2]|0;l=c[b+720>>2]|0;c[o+(p*44|0)+8>>2]=l+(d*104|0);m=c[b+720>>2]|0;c[o+(p*44|0)+12>>2]=m+(e*104|0);n=c[b+720>>2]|0;c[o+(p*44|0)+16>>2]=n+(f*104|0);t=+g[l+(d*104|0)+8>>2];v=+g[l+(d*104|0)+12>>2];r=+g[l+(d*104|0)+16>>2];s=+g[m+(e*104|0)+8>>2]-t;w=+g[m+(e*104|0)+12>>2]-v;u=+g[m+(e*104|0)+16>>2]-r;t=+g[n+(f*104|0)+8>>2]-t;v=+g[n+(f*104|0)+12>>2]-v;r=+g[n+(f*104|0)+16>>2]-r;g[o+(p*44|0)+36>>2]=+O(+((s*v-w*t)*(s*v-w*t)+((w*r-u*v)*(w*r-u*v)+(u*t-s*r)*(u*t-s*r))));a[b+924>>0]=1;i=q;return}function _f(b,d){b=b|0;d=+d;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0;m=i;i=i+16|0;li(12187);e=c[b+232>>2]|0;if((e|0)>0){l=(a[26260]|0)==0;k=0;do{j=c[(c[b+240>>2]|0)+(k<<2)>>2]|0;a:do if(j){f=c[j+216>>2]|0;b:do switch(f|0){case 4:case 2:{if((f|0)==4)break a;break}default:{q=+g[j+312>>2];p=+g[j+316>>2];o=+g[j+320>>2];n=+g[j+472>>2];if(q*q+p*p+o*o>2],o=+g[j+332>>2],p=+g[j+336>>2],q=+g[j+476>>2],n*n+o*o+p*p>2]=+g[j+220>>2]+d;break b}g[j+220>>2]=0.0;if((f&-2|0)!=4){c[j+216>>2]=0;f=0}}}while(0);h=f&-2;do if(l){if((h|0)!=2?!(+g[j+220>>2]>2.0):0)break;if(c[j+204>>2]&3|0){if((h|0)==4)break a;c[j+216>>2]=2;break a}if((f|0)==1){if((h|0)==4)break a;c[j+216>>2]=3;break a}else{if((f|0)!=2)break a;e=(c[j+260>>2]|0)+2|0;c[j+328>>2]=0;c[j+328+4>>2]=0;c[j+328+8>>2]=0;c[j+328+12>>2]=0;c[j+260>>2]=e;c[j+312>>2]=0;c[j+312+4>>2]=0;c[j+312+8>>2]=0;c[j+312+12>>2]=0;e=c[b+232>>2]|0;break a}}while(0);if((h|0)!=4)c[j+216>>2]=1}while(0);k=k+1|0}while((k|0)<(e|0))}e=c[2357]|0;b=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=b;if(b|0){i=m;return}do if(c[e+4>>2]|0){tb(m|0,0)|0;b=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[m+4>>2]|0)-(c[b+4>>2]|0)+(((c[m>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[e+16>>2]|0)){e=c[2357]|0;break}else{i=m;return}}while(0);c[2357]=c[e+20>>2];i=m;return}function $f(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0,G=0.0,H=0;H=i;i=i+32|0;k=+g[b+16>>2];f=+g[b>>2];l=+g[b+20>>2];h=+g[b+4>>2];n=+g[b+24>>2];j=+g[b+8>>2];r=+g[b+32>>2];v=+g[b+36>>2];w=+g[b+40>>2];B=(l-h)*(w-j)-(n-j)*(v-h);C=(n-j)*(r-f)-(k-f)*(w-j);D=(k-f)*(v-h)-(l-h)*(r-f);g[H+16>>2]=B;g[H+16+4>>2]=C;g[H+16+8>>2]=D;g[H+16+12>>2]=0.0;o=+g[a+4>>2];s=+g[a+8>>2];x=+g[a+12>>2];E=B*o+C*s+D*x-(f*B+h*C+j*D);p=+g[a+20>>2];t=+g[a+24>>2];y=+g[a+28>>2];if(E*(B*p+C*t+D*y-(f*B+h*C+j*D))>=0.0){i=H;return}F=c[a+36>>2]|0;if(E<=0.0&(F&1|0)!=0){i=H;return}G=E/(E-(B*p+C*t+D*y-(f*B+h*C+j*D)));if(!(G<+g[a+40>>2])){i=H;return}A=(B*B+C*C+D*D)*-9.999999747378752e-05;z=f-(p*G+o*(1.0-G));u=h-(t*G+s*(1.0-G));q=j-(y*G+x*(1.0-G));m=k-(p*G+o*(1.0-G));l=l-(t*G+s*(1.0-G));k=n-(y*G+x*(1.0-G));if(!(D*(z*l-u*m)+(B*(u*k-q*l)+C*(q*m-z*k))>=A)){i=H;return}j=r-(p*G+o*(1.0-G));h=v-(t*G+s*(1.0-G));f=w-(y*G+x*(1.0-G));if(!(D*(m*h-l*j)+(B*(l*f-k*h)+C*(k*j-m*f))>=A)){i=H;return}if(!(D*(u*j-z*h)+(B*(q*h-u*f)+C*(z*f-q*j))>=A)){i=H;return}f=1.0/+O(+(B*B+C*C+D*D));g[H+16>>2]=B*f;g[H+16+4>>2]=C*f;g[H+16+8>>2]=D*f;b=c[(c[a>>2]|0)+12>>2]|0;if(E<=0.0&(F&2|0)==0){g[H>>2]=-(B*f);g[H+4>>2]=-(C*f);g[H+8>>2]=-(D*f);g[H+12>>2]=0.0;g[a+40>>2]=+ec[b&3](a,H,G,d,e);i=H;return}else{g[a+40>>2]=+ec[b&3](a,H+16|0,G,d,e);i=H;return}}function ag(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0;l=i;i=i+144|0;j=c[b+12>>2]|0;if(!j){i=l;return}n=c[d+4>>2]|0;m=c[e+4>>2]|0;c[h+4>>2]=j;g[l+12+128>>2]=999999984306749440.0;d=c[d+12>>2]|0;c[l+12>>2]=c[d>>2];c[l+12+4>>2]=c[d+4>>2];c[l+12+8>>2]=c[d+8>>2];c[l+12+12>>2]=c[d+12>>2];c[l+12+16>>2]=c[d+16>>2];c[l+12+16+4>>2]=c[d+16+4>>2];c[l+12+16+8>>2]=c[d+16+8>>2];c[l+12+16+12>>2]=c[d+16+12>>2];c[l+12+32>>2]=c[d+32>>2];c[l+12+32+4>>2]=c[d+32+4>>2];c[l+12+32+8>>2]=c[d+32+8>>2];c[l+12+32+12>>2]=c[d+32+12>>2];c[l+12+48>>2]=c[d+48>>2];c[l+12+48+4>>2]=c[d+48+4>>2];c[l+12+48+8>>2]=c[d+48+8>>2];c[l+12+48+12>>2]=c[d+48+12>>2];e=c[e+12>>2]|0;c[l+12+64>>2]=c[e>>2];c[l+12+64+4>>2]=c[e+4>>2];c[l+12+64+8>>2]=c[e+8>>2];c[l+12+64+12>>2]=c[e+12>>2];c[l+12+80>>2]=c[e+16>>2];c[l+12+80+4>>2]=c[e+16+4>>2];c[l+12+80+8>>2]=c[e+16+8>>2];c[l+12+80+12>>2]=c[e+16+12>>2];c[l+12+96>>2]=c[e+32>>2];c[l+12+96+4>>2]=c[e+32+4>>2];c[l+12+96+8>>2]=c[e+32+8>>2];c[l+12+96+12>>2]=c[e+32+12>>2];c[l+12+112>>2]=c[e+48>>2];c[l+12+112+4>>2]=c[e+48+4>>2];c[l+12+112+8>>2]=c[e+48+8>>2];c[l+12+112+12>>2]=c[e+48+12>>2];c[l>>2]=9284;c[l+4>>2]=n;c[l+8>>2]=m;xc(l,l+12|0,h,c[f+20>>2]|0,0);do if(a[b+8>>0]|0?(k=c[h+4>>2]|0,c[k+748>>2]|0):0){d=c[k+740>>2]|0;e=c[(c[h+8>>2]|0)+8>>2]|0;j=c[(c[h+12>>2]|0)+8>>2]|0;if((d|0)==(e|0)){ef(k,d+4|0,j+4|0);break}else{ef(k,j+4|0,e+4|0);break}}while(0);i=l;return}function bg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0,s=0.0,t=0;if(!a)return;n=+g[b>>2];o=+g[b+4>>2];q=+g[b+8>>2];s=+g[b+16>>2];m=+g[b+20>>2];l=+g[b+24>>2];c[6435]=(c[6435]|0)+1;b=yc(275)|0;c[(b+4+15&-16)+-4>>2]=b;c[(b+4+15&-16)>>2]=a;k=1;a=64;b=b+4+15&-16;while(1){e=k+-1|0;i=c[b+(e<<2)>>2]|0;do if(((((+g[i>>2]<=s?+g[i+16>>2]>=n:0)?+g[i+4>>2]<=m:0)?+g[i+20>>2]>=o:0)?+g[i+8>>2]<=l:0)?+g[i+24>>2]>=q:0){if(!(c[i+40>>2]|0)){Cb[c[(c[d>>2]|0)+12>>2]&127](d,i);break}j=c[i+36>>2]|0;do if((e|0)==(a|0)?(p=a|0?a<<1:1,(k|0)<=(p|0)):0){if((p|0)!=0?(c[6435]=(c[6435]|0)+1,r=yc((p<<2|3)+16|0)|0,(r|0)!=0):0){c[(r+4+15&-16)+-4>>2]=r;h=r+4+15&-16}else h=0;if((k|0)<=1){if(!b){a=p;b=h;break}}else{f=0;do{c[h+(f<<2)>>2]=c[b+(f<<2)>>2];f=f+1|0}while((f|0)!=(a|0))}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);a=p;b=h}while(0);c[b+(e<<2)>>2]=j;h=c[i+40>>2]|0;do if((k|0)==(a|0)){a=k|0?k<<1:1;if((k|0)<(a|0)){if((a|0)!=0?(c[6435]=(c[6435]|0)+1,t=yc((a<<2|3)+16|0)|0,(t|0)!=0):0){c[(t+4+15&-16)+-4>>2]=t;f=t+4+15&-16}else f=0;if((k|0)<=0){if(!b){b=f;break}}else{e=0;do{c[f+(e<<2)>>2]=c[b+(e<<2)>>2];e=e+1|0}while((e|0)!=(k|0))}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);b=f}else a=k}while(0);c[b+(k<<2)>>2]=h;e=k+1|0}while(0);if((e|0)>0)k=e;else break}if(!b)return;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function cg(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;if((c[b+104>>2]|0)>0){l=0;do{h=c[(c[b+4>>2]|0)+684>>2]|0;i=(c[b+112>>2]|0)+(l<<3)+4|0;d=c[i>>2]|0;if((c[h+60>>2]|0)>0){k=0;do{j=(c[h+68>>2]|0)+(k<<2)|0;e=c[j>>2]|0;a:do if(e|0){f=0;do{g=f+280|0;b:do if(!f)while(1){f=e;e=c[e+280>>2]|0;if((c[f+276>>2]|0)!=(d|0))break b;c[j>>2]=e;hd(f);if(!e)break a}else while(1){f=e;e=c[e+280>>2]|0;if((c[f+276>>2]|0)!=(d|0))break b;c[g>>2]=e;hd(f);if(!e)break a}while(0)}while((e|0)!=0)}while(0);k=k+1|0}while((k|0)<(c[h+60>>2]|0));d=c[i>>2]|0}if(d|0)Ab[c[(c[d>>2]|0)+4>>2]&255](d);l=l+1|0}while((l|0)<(c[b+104>>2]|0))}d=c[b+72>>2]|0;if(d|0){if(a[b+76>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+72>>2]=0}a[b+76>>0]=1;c[b+72>>2]=0;c[b+64>>2]=0;c[b+68>>2]=0;d=c[b+92>>2]|0;if(d|0){if(a[b+96>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+92>>2]=0}a[b+96>>0]=1;c[b+92>>2]=0;c[b+84>>2]=0;c[b+88>>2]=0;d=c[b+112>>2]|0;if(d|0){if(a[b+116>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+112>>2]=0}a[b+116>>0]=1;c[b+112>>2]=0;c[b+104>>2]=0;c[b+108>>2]=0;d=c[b+132>>2]|0;if(!d){a[b+136>>0]=1;c[b+132>>2]=0;c[b+124>>2]=0;b=b+128|0;c[b>>2]=0;return}if(a[b+136>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+132>>2]=0;a[b+136>>0]=1;c[b+132>>2]=0;c[b+124>>2]=0;b=b+128|0;c[b>>2]=0;return}function dg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=c[a+56>>2]|0;if(!e){e=c[a+52>>2]|0;if(!e){c[6435]=(c[6435]|0)+1;e=yc(31)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[a+60>>2]|0;c[e+4>>2]=f;g=e+8|0;c[g>>2]=0;c[6435]=(c[6435]|0)+1;f=yc((f*24|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}c[e>>2]=f;c[g>>2]=c[a+48>>2];c[a+48>>2]=e}else c[a+52>>2]=c[e+8>>2];h=c[e+4>>2]|0;e=c[e>>2]|0;if((h|0)>0){f=0;g=e;do{f=f+1|0;i=g;g=g+24|0;c[i>>2]=(f|0)<(h|0)?g:0}while((f|0)!=(h|0));i=e}else i=e}else i=e;c[a+56>>2]=c[i>>2];c[i>>2]=0;c[i+4>>2]=0;c[i+8>>2]=0;c[i+12>>2]=0;c[i+16>>2]=0;c[i+20>>2]=0;e=c[a+56>>2]|0;if(!e){e=c[a+52>>2]|0;if(!e){c[6435]=(c[6435]|0)+1;e=yc(31)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[a+60>>2]|0;c[e+4>>2]=f;g=e+8|0;c[g>>2]=0;c[6435]=(c[6435]|0)+1;f=yc((f*24|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}c[e>>2]=f;c[g>>2]=c[a+48>>2];c[a+48>>2]=e}else c[a+52>>2]=c[e+8>>2];h=c[e+4>>2]|0;e=c[e>>2]|0;if((h|0)>0){f=0;g=e;do{f=f+1|0;j=g;g=g+24|0;c[j>>2]=(f|0)<(h|0)?g:0}while((f|0)!=(h|0))}}c[a+56>>2]=c[e>>2];c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[i+8>>2]=e;c[e+8>>2]=i;j=c[a+100>>2]|0;c[i+20>>2]=j;c[e+20>>2]=j;c[i+12>>2]=d;c[e+12>>2]=b;c[i+16>>2]=0;c[e+16>>2]=0;e=c[a+116>>2]|0;c[a+116>>2]=e+1;if((e|0)<(c[a+120>>2]|0))return i|0;c[a+120>>2]=e+1;return i|0}function eg(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0;b=c[a+752>>2]|0;if((b|0)>0){d=c[a+760>>2]|0;e=0;do{o=c[d+(e*44|0)+8>>2]|0;f=c[d+(e*44|0)+12>>2]|0;h=c[d+(e*44|0)+16>>2]|0;k=+g[o+8>>2];m=+g[o+12>>2];i=+g[o+16>>2];j=+g[f+8>>2]-k;n=+g[f+12>>2]-m;l=+g[f+16>>2]-i;k=+g[h+8>>2]-k;m=+g[h+12>>2]-m;i=+g[h+16>>2]-i;g[d+(e*44|0)+36>>2]=+O(+((j*m-n*k)*(j*m-n*k)+((n*i-l*m)*(n*i-l*m)+(l*k-j*i)*(l*k-j*i))));e=e+1|0}while((e|0)!=(b|0))}d=c[a+712>>2]|0;if((d|0)>0){c[6435]=(c[6435]|0)+1;b=yc((d<<2|3)+16|0)|0;if(!b)f=0;else{c[(b+4+15&-16)+-4>>2]=b;f=b+4+15&-16}Qn(f|0,0,d<<2|0)|0;d=c[a+712>>2]|0;if((d|0)>0){b=c[a+720>>2]|0;e=0;do{g[b+(e*104|0)+92>>2]=0.0;e=e+1|0}while((e|0)!=(d|0));h=f}else h=f}else h=0;f=c[a+752>>2]|0;if((f|0)>0){b=c[a+760>>2]|0;d=c[a+720>>2]|0;e=0;do{n=+N(+(+g[b+(e*44|0)+36>>2]));o=c[b+(e*44|0)+8>>2]|0;p=h+(((o-d|0)/104|0)<<2)|0;c[p>>2]=(c[p>>2]|0)+1;g[o+92>>2]=n+ +g[o+92>>2];o=c[b+(e*44|0)+12>>2]|0;p=h+(((o-d|0)/104|0)<<2)|0;c[p>>2]=(c[p>>2]|0)+1;g[o+92>>2]=n+ +g[o+92>>2];o=c[b+(e*44|0)+16>>2]|0;p=h+(((o-d|0)/104|0)<<2)|0;c[p>>2]=(c[p>>2]|0)+1;g[o+92>>2]=n+ +g[o+92>>2];e=e+1|0}while((e|0)!=(f|0));d=c[a+712>>2]|0}if((d|0)<=0){if(!h)return}else{e=0;do{b=c[h+(e<<2)>>2]|0;if((b|0)>0){p=(c[a+720>>2]|0)+(e*104|0)+92|0;g[p>>2]=+g[p>>2]/+(b|0)}else g[(c[a+720>>2]|0)+(e*104|0)+92>>2]=0.0;e=e+1|0}while((e|0)!=(d|0))}c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);return}function fg(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;l=i;i=i+16|0;j=c[b+28>>2]|0;k=c[b+32>>2]|0;if(!(a[b+1301>>0]|0)){h=0;e=Nf(b,d,0,j+4|0,k+4|0,j+312|0,k+312|0,j+328|0,k+328|0)|0;do{f=b+868+(h<<6)|0;if(!((c[b+868+(h<<6)+56>>2]|0)==0?(a[b+868+(h<<6)+44>>0]|0)==0:0)){g=b+1208+(h<<4)|0;c[l>>2]=c[g>>2];c[l+4>>2]=c[g+4>>2];c[l+8>>2]=c[g+8>>2];c[l+12>>2]=c[g+12>>2];g=c[b+1304>>2]>>(h*3|0)+9;if(!(g&1))c[b+868+(h<<6)+28>>2]=c[c[d+32>>2]>>2];if(!(g&2))c[b+868+(h<<6)+36>>2]=c[c[d+32>>2]>>2];if(!(g&4))c[b+868+(h<<6)+32>>2]=c[d+4>>2];e=(Dd(b,f,j+4|0,k+4|0,j+312|0,k+312|0,j+328|0,k+328|0,d,e,l,1,0)|0)+e|0}h=h+1|0}while((h|0)!=3);i=l;return}h=0;e=0;do{f=b+868+(h<<6)|0;if(!((c[b+868+(h<<6)+56>>2]|0)==0?(a[b+868+(h<<6)+44>>0]|0)==0:0)){g=b+1208+(h<<4)|0;c[l>>2]=c[g>>2];c[l+4>>2]=c[g+4>>2];c[l+8>>2]=c[g+8>>2];c[l+12>>2]=c[g+12>>2];g=c[b+1304>>2]>>(h*3|0)+9;if(!(g&1))c[b+868+(h<<6)+28>>2]=c[c[d+32>>2]>>2];if(!(g&2))c[b+868+(h<<6)+36>>2]=c[c[d+32>>2]>>2];if(!(g&4))c[b+868+(h<<6)+32>>2]=c[d+4>>2];e=(Dd(b,f,j+4|0,k+4|0,j+312|0,k+312|0,j+328|0,k+328|0,d,e,l,1,0)|0)+e|0}h=h+1|0}while((h|0)!=3);Nf(b,d,e,j+4|0,k+4|0,j+312|0,k+312|0,j+328|0,k+328|0)|0;i=l;return}function gg(b){b=b|0;var d=0,e=0,f=0,h=0.0,i=0.0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0.0;d=c[b+988>>2]|0;if(d|0)xn(b+988|0,d);d=c[b+992>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+992>>2]=0;c[b+996>>2]=-1;d=c[b+1020>>2]|0;if(d|0){if(a[b+1024>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+1020>>2]=0}a[b+1024>>0]=1;c[b+1020>>2]=0;c[b+1012>>2]=0;c[b+1016>>2]=0;c[b+1004>>2]=0;if((c[b+752>>2]|0)<=0)return;r=0;do{j=c[b+760>>2]|0;k=j+(r*44|0)|0;e=c[j+(r*44|0)+8>>2]|0;f=c[j+(r*44|0)+12>>2]|0;d=c[j+(r*44|0)+16>>2]|0;o=+g[e+8>>2];p=+g[e+12>>2];q=+g[e+16>>2];i=+g[e+20>>2];v=+g[f+8>>2];l=v>2];m=s>2];n=t>2];h=u>2];l=u>2];m=t>2];n=s>2];h=v>2]|0;if(!d){c[6435]=(c[6435]|0)+1;d=yc(63)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=d;f=e+44|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(f|0))}else c[b+992>>2]=0;c[d+32>>2]=0;c[d+36>>2]=k;c[d+40>>2]=0;g[d>>2]=l;g[d+4>>2]=m;g[d+8>>2]=n;g[d+12>>2]=h;g[d+16>>2]=o;g[d+20>>2]=p;g[d+24>>2]=q;g[d+28>>2]=i;lf(b+988|0,c[b+988>>2]|0,d);c[b+1e3>>2]=(c[b+1e3>>2]|0)+1;c[j+(r*44|0)+40>>2]=d;r=r+1|0}while((r|0)<(c[b+752>>2]|0));return}function hg(b){b=b|0;var d=0,e=0.0,f=0,h=0,j=0.0,k=0.0,l=0;l=i;i=i+64|0;li(11978);a:do if(!(a[b+274>>0]|0)){d=c[b+232>>2]|0;if((d|0)>0){h=0;while(1){f=c[(c[b+240>>2]|0)+(h<<2)>>2]|0;switch(c[f+216>>2]|0){case 2:case 5:break;default:if((c[f+480>>2]|0)!=0?(c[f+204>>2]&3|0)==0:0){if((a[b+300>>0]|0)!=0?(k=+g[b+268>>2],k!=0.0):0)e=+g[b+264>>2]-k;else e=+g[b+264>>2]*+g[f+244>>2];Zg(f+68|0,+g[f+132>>2],+g[f+136>>2],+g[f+140>>2],f+148|0,e,l);d=c[f+480>>2]|0;Cb[c[(c[d>>2]|0)+12>>2]&127](d,l);d=c[b+232>>2]|0}}h=h+1|0;if((h|0)>=(d|0))break a}}}else{d=c[b+8>>2]|0;if((d|0)>0){h=0;do{f=c[(c[b+16>>2]|0)+(h<<2)>>2]|0;if((!((f|0)==0?1:(c[f+236>>2]&2|0)==0)?(c[f+480>>2]|0)!=0:0)?(c[f+204>>2]&3|0)==0:0){if((a[b+300>>0]|0)!=0?(j=+g[b+268>>2],j!=0.0):0)e=+g[b+264>>2]-j;else e=+g[b+264>>2]*+g[f+244>>2];Zg(f+68|0,+g[f+132>>2],+g[f+136>>2],+g[f+140>>2],f+148|0,e,l);d=c[f+480>>2]|0;Cb[c[(c[d>>2]|0)+12>>2]&127](d,l);d=c[b+8>>2]|0}h=h+1|0}while((h|0)<(d|0))}}while(0);d=c[2357]|0;b=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=b;if(b|0){i=l;return}do if(c[d+4>>2]|0){tb(l|0,0)|0;b=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[l+4>>2]|0)-(c[b+4>>2]|0)+(((c[l>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=l;return}}while(0);c[2357]=c[d+20>>2];i=l;return}function ig(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;n=i;i=i+32|0;if((b|0)<0)b=c[a+12>>2]|0;d=c[a>>2]|0;if(!((b|0)>0&(d|0)!=0)){i=n;return}while(1){e=d+40|0;if(c[e>>2]|0){m=0;while(1){l=(c[a+16>>2]|0)>>>m&1;f=d+32|0;g=c[f>>2]|0;if(g>>>0>d>>>0){h=(c[g+40>>2]|0)==(d|0)&1;j=c[g+36+((h^1)<<2)>>2]|0;k=c[g+32>>2]|0;if(!k)c[a>>2]=d;else c[k+36+(((c[k+40>>2]|0)==(g|0)&1)<<2)>>2]=d;c[j+32>>2]=d;c[g+32>>2]=d;c[f>>2]=k;k=d+36|0;c[g+36>>2]=c[k>>2];c[g+40>>2]=c[e>>2];c[(c[k>>2]|0)+32>>2]=g;c[(c[e>>2]|0)+32>>2]=g;c[d+36+(h<<2)>>2]=g;c[d+36+((h^1)<<2)>>2]=j;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];c[n+12>>2]=c[g+12>>2];c[n+16>>2]=c[g+16>>2];c[n+20>>2]=c[g+20>>2];c[n+24>>2]=c[g+24>>2];c[n+28>>2]=c[g+28>>2];c[g>>2]=c[d>>2];c[g+4>>2]=c[d+4>>2];c[g+8>>2]=c[d+8>>2];c[g+12>>2]=c[d+12>>2];c[g+16>>2]=c[d+16>>2];c[g+20>>2]=c[d+20>>2];c[g+24>>2]=c[d+24>>2];c[g+28>>2]=c[d+28>>2];c[d>>2]=c[n>>2];c[d+4>>2]=c[n+4>>2];c[d+8>>2]=c[n+8>>2];c[d+12>>2]=c[n+12>>2];c[d+16>>2]=c[n+16>>2];c[d+20>>2]=c[n+20>>2];c[d+24>>2]=c[n+24>>2];c[d+28>>2]=c[n+28>>2];d=g}d=c[d+36+(l<<2)>>2]|0;e=d+40|0;if(!(c[e>>2]|0))break;else m=m+1&31}}if(!(hh(a,d)|0))e=0;else e=c[a>>2]|0;lf(a,e,d);c[a+16>>2]=(c[a+16>>2]|0)+1;b=b+-1|0;if(!b)break;d=c[a>>2]|0}i=n;return}function jg(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0;j=i;i=i+32|0;d=a[b+8>>0]|0?d:e;if(((c[(c[d+4>>2]|0)+4>>2]|0)+-21|0)>>>0>=9){i=j;return}e=c[(c[d+8>>2]|0)+192>>2]|0;y=+Sb[c[(c[e>>2]|0)+48>>2]&15](e);c[b+64>>2]=f;g[b+68>>2]=y+.05999999865889549;c[b+56>>2]=h;h=c[b+16>>2]|0;ic[c[(c[h>>2]|0)+28>>2]&127](h,j+16|0,j);y=+g[j>>2];x=+g[j+16>>2];w=+g[j+4>>2];v=+g[j+16+4>>2];u=+g[j+8>>2];t=+g[j+16+8>>2];h=c[d+12>>2]|0;B=+g[h>>2];o=+g[h+16>>2];C=+g[h+32>>2];z=+g[h+4>>2];m=+g[h+20>>2];A=+g[h+36>>2];q=+g[h+8>>2];k=+g[h+24>>2];r=+g[h+40>>2];D=-+g[h+48>>2];s=-+g[h+52>>2];l=-+g[h+56>>2];p=(y+x)*.5*B+(w+v)*.5*o+(u+t)*.5*C+(B*D+o*s+C*l);n=(y+x)*.5*z+(w+v)*.5*m+(u+t)*.5*A+(z*D+m*s+A*l);l=(y+x)*.5*q+(w+v)*.5*k+(u+t)*.5*r+(q*D+k*s+r*l);s=+g[b+68>>2];o=((y-x)*.5+s)*+N(+(B+o*0.0+C*0.0))+((w-v)*.5+s)*+N(+(B*0.0+o+C*0.0))+((u-t)*.5+s)*+N(+(C+(B*0.0+o*0.0)));m=((y-x)*.5+s)*+N(+(z+m*0.0+A*0.0))+((w-v)*.5+s)*+N(+(z*0.0+m+A*0.0))+((u-t)*.5+s)*+N(+(A+(z*0.0+m*0.0)));k=((y-x)*.5+s)*+N(+(q+k*0.0+r*0.0))+((w-v)*.5+s)*+N(+(q*0.0+k+r*0.0))+((u-t)*.5+s)*+N(+(r+(q*0.0+k*0.0)));g[b+24>>2]=p-o;g[b+28>>2]=n-m;g[b+32>>2]=l-k;g[b+36>>2]=0.0;g[b+40>>2]=p+o;g[b+44>>2]=n+m;g[b+48>>2]=l+k;g[b+52>>2]=0.0;mc[c[(c[e>>2]|0)+64>>2]&127](e,b+12|0,b+24|0,b+40|0);i=j;return}function kg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0;l=i;i=i+16|0;c[b+8>>2]=0;c[b+12>>2]=1065353216;c[b+16>>2]=1065353216;c[b+20>>2]=1065353216;g[b+24>>2]=0.0;g[b+44>>2]=.03999999910593033;c[b+52>>2]=0;c[b+56>>2]=1065353216;c[b+60>>2]=1065353216;c[b+64>>2]=1065353216;g[b+68>>2]=0.0;c[b+72>>2]=-1082130432;c[b+76>>2]=-1082130432;c[b+80>>2]=-1082130432;g[b+84>>2]=0.0;a[b+88>>0]=0;c[b>>2]=7256;a[b+108>>0]=1;c[b+104>>2]=0;c[b+96>>2]=0;c[b+100>>2]=0;c[b+4>>2]=4;if((e|0)<=0){c[b+96>>2]=e;vj(b);i=l;return}c[6435]=(c[6435]|0)+1;h=yc((e<<4|3)+16|0)|0;if(!h)k=0;else{c[(h+4+15&-16)+-4>>2]=h;k=h+4+15&-16}h=c[b+96>>2]|0;if((h|0)>0){j=0;do{m=k+(j<<4)|0;n=(c[b+104>>2]|0)+(j<<4)|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];j=j+1|0}while((j|0)!=(h|0))}h=c[b+104>>2]|0;if(h|0){if(a[b+108>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+104>>2]=0}a[b+108>>0]=1;c[b+104>>2]=k;c[b+100>>2]=e;c[k>>2]=c[l>>2];c[k+4>>2]=c[l+4>>2];c[k+8>>2]=c[l+8>>2];c[k+12>>2]=c[l+12>>2];if((e|0)!=1){h=1;do{n=(c[b+104>>2]|0)+(h<<4)|0;c[n>>2]=c[l>>2];c[n+4>>2]=c[l+4>>2];c[n+8>>2]=c[l+8>>2];c[n+12>>2]=c[l+12>>2];h=h+1|0}while((h|0)!=(e|0))}c[b+96>>2]=e;j=0;h=d;while(1){n=c[b+104>>2]|0;d=c[h+4>>2]|0;m=c[h+8>>2]|0;c[n+(j<<4)>>2]=c[h>>2];c[n+(j<<4)+4>>2]=d;c[n+(j<<4)+8>>2]=m;g[n+(j<<4)+12>>2]=0.0;j=j+1|0;if((j|0)==(e|0))break;else h=h+f|0}vj(b);i=l;return}function lg(b){b=b|0;var d=0;c[b>>2]=4756;d=c[b+176>>2]|0;if(d|0){if(a[b+180>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+176>>2]=0}a[b+180>>0]=1;c[b+176>>2]=0;c[b+168>>2]=0;c[b+172>>2]=0;d=c[b+156>>2]|0;if(d|0){if(a[b+160>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+156>>2]=0}a[b+160>>0]=1;c[b+156>>2]=0;c[b+148>>2]=0;c[b+152>>2]=0;d=c[b+136>>2]|0;if(d|0){if(a[b+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+136>>2]=0}a[b+140>>0]=1;c[b+136>>2]=0;c[b+128>>2]=0;c[b+132>>2]=0;d=c[b+116>>2]|0;if(d|0){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+116>>2]=0}a[b+120>>0]=1;c[b+116>>2]=0;c[b+108>>2]=0;c[b+112>>2]=0;d=c[b+96>>2]|0;if(d|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=0;c[b+88>>2]=0;c[b+92>>2]=0;d=c[b+76>>2]|0;if(d|0){if(a[b+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+76>>2]=0}a[b+80>>0]=1;c[b+76>>2]=0;c[b+68>>2]=0;c[b+72>>2]=0;d=c[b+56>>2]|0;if(d|0){if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+56>>2]=0}a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;d=c[b+36>>2]|0;if(d|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;d=c[b+16>>2]|0;if(!d){a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}function mg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0.0;x=i;i=i+48|0;t=+g[e>>2];u=+g[d>>2];v=+g[e+4>>2];w=+g[d+4>>2];s=+g[e+8>>2];h=+g[d+8>>2];j=+O(+((t-u)*.5*(t-u)*.5+(v-w)*.5*(v-w)*.5+(s-h)*.5*(s-h)*.5));k=+g[a+56>>2];d=+N(+k)>.7071067690849304;l=+g[a+52>>2];if(d){r=1.0/+O(+(k*k+l*l));y=+g[a+48>>2];f=y*-(k*r);m=y;n=0.0;o=-(k*r);p=l*r;q=(k*k+l*l)*r;r=-(y*l*r)}else{q=+g[a+48>>2];r=1.0/+O(+(q*q+l*l));f=(q*q+l*l)*r;m=q;n=-(l*r);o=q*r;p=0.0;q=-(k*q*r);r=k*-(l*r)}y=(t+u)*.5*m+(v+w)*.5*l+(s+h)*.5*k-+g[a+64>>2];m=(t+u)*.5-m*y;n=j*n;o=j*o;u=j*p;q=j*q;r=j*r;t=j*f;g[x>>2]=q+(n+m);g[x+4>>2]=r+(o+((v+w)*.5-l*y));g[x+8>>2]=t+(u+((s+h)*.5-k*y));g[x+12>>2]=0.0;g[x+16>>2]=n+m-q;g[x+20>>2]=o+((v+w)*.5-l*y)-r;g[x+24>>2]=u+((s+h)*.5-k*y)-t;g[x+28>>2]=0.0;g[x+32>>2]=m-n-q;g[x+36>>2]=(v+w)*.5-l*y-o-r;g[x+40>>2]=(s+h)*.5-k*y-u-t;g[x+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,x,0,0);g[x>>2]=m-n-q;g[x+4>>2]=(v+w)*.5-l*y-o-r;g[x+8>>2]=(s+h)*.5-k*y-u-t;g[x+12>>2]=0.0;g[x+16>>2]=q+(m-n);g[x+20>>2]=r+((v+w)*.5-l*y-o);g[x+24>>2]=t+((s+h)*.5-k*y-u);g[x+28>>2]=0.0;g[x+32>>2]=q+(n+m);g[x+36>>2]=r+(o+((v+w)*.5-l*y));g[x+40>>2]=t+(u+((s+h)*.5-k*y));g[x+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,x,0,1);i=x;return}function ng(a,b,e){a=a|0;b=b|0;e=e|0;mf(a,b,e)|0;c[b+256>>2]=c[a+264>>2];c[b+260>>2]=c[a+268>>2];c[b+264>>2]=c[a+272>>2];c[b+268>>2]=c[a+276>>2];c[b+272>>2]=c[a+280>>2];c[b+276>>2]=c[a+284>>2];c[b+280>>2]=c[a+288>>2];c[b+284>>2]=c[a+292>>2];c[b+288>>2]=c[a+296>>2];c[b+292>>2]=c[a+300>>2];c[b+296>>2]=c[a+304>>2];c[b+300>>2]=c[a+308>>2];c[b+304>>2]=c[a+312>>2];c[b+308>>2]=c[a+316>>2];c[b+312>>2]=c[a+320>>2];c[b+316>>2]=c[a+324>>2];c[b+320>>2]=c[a+328>>2];c[b+324>>2]=c[a+332>>2];c[b+328>>2]=c[a+336>>2];c[b+332>>2]=c[a+340>>2];c[b+448>>2]=c[a+344>>2];c[b+336>>2]=c[a+544>>2];c[b+340>>2]=c[a+548>>2];c[b+344>>2]=c[a+552>>2];c[b+348>>2]=c[a+556>>2];c[b+352>>2]=c[a+348>>2];c[b+356>>2]=c[a+352>>2];c[b+360>>2]=c[a+356>>2];c[b+364>>2]=c[a+360>>2];c[b+368>>2]=c[a+364>>2];c[b+372>>2]=c[a+368>>2];c[b+376>>2]=c[a+372>>2];c[b+380>>2]=c[a+376>>2];c[b+384>>2]=c[a+380>>2];c[b+388>>2]=c[a+384>>2];c[b+392>>2]=c[a+388>>2];c[b+396>>2]=c[a+392>>2];c[b+400>>2]=c[a+396>>2];c[b+404>>2]=c[a+400>>2];c[b+408>>2]=c[a+404>>2];c[b+412>>2]=c[a+408>>2];c[b+416>>2]=c[a+412>>2];c[b+420>>2]=c[a+416>>2];c[b+424>>2]=c[a+420>>2];c[b+428>>2]=c[a+424>>2];c[b+432>>2]=c[a+428>>2];c[b+436>>2]=c[a+432>>2];c[b+440>>2]=c[a+436>>2];c[b+444>>2]=c[a+440>>2];c[b+452>>2]=c[a+444>>2];c[b+456>>2]=c[a+448>>2];c[b+484>>2]=d[a+452>>0];c[b+460>>2]=c[a+456>>2];c[b+464>>2]=c[a+460>>2];c[b+468>>2]=c[a+464>>2];c[b+472>>2]=c[a+468>>2];c[b+476>>2]=c[a+472>>2];c[b+480>>2]=c[a+476>>2];return 11858}function og(b,d,e,f,h){b=b|0;d=+d;e=e|0;f=f|0;h=h|0;var j=0;j=i;i=i+144|0;c[b+164>>2]=1065353216;c[b+168>>2]=1065353216;c[b+172>>2]=1065353216;g[b+176>>2]=0.0;c[b+180>>2]=0;g[b+184>>2]=999999984306749440.0;c[b+188>>2]=0;c[b+188+4>>2]=0;c[b+188+8>>2]=0;c[b+188+12>>2]=0;c[b+204>>2]=1;c[b+208>>2]=-1;c[b+212>>2]=-1;c[b+216>>2]=1;g[b+220>>2]=0.0;g[b+224>>2]=.5;g[b+228>>2]=0.0;g[b+232>>2]=0.0;c[b+236>>2]=1;c[b+240>>2]=0;g[b+244>>2]=1.0;c[b+248>>2]=0;c[b+248+4>>2]=0;c[b+248+8>>2]=0;c[b+248+12>>2]=0;c[b+4>>2]=1065353216;c[b+8>>2]=0;c[b+8+4>>2]=0;c[b+8+8>>2]=0;c[b+8+12>>2]=0;c[b+24>>2]=1065353216;c[b+28>>2]=0;c[b+28+4>>2]=0;c[b+28+8>>2]=0;c[b+28+12>>2]=0;c[b+44>>2]=1065353216;c[b+48>>2]=0;c[b+48+4>>2]=0;c[b+48+8>>2]=0;c[b+48+12>>2]=0;c[b+48+16>>2]=0;c[b>>2]=4108;a[b+500>>0]=1;c[b+496>>2]=0;c[b+488>>2]=0;c[b+492>>2]=0;g[j>>2]=d;c[j+4>>2]=e;c[j+72>>2]=f;c[j+76>>2]=c[h>>2];c[j+76+4>>2]=c[h+4>>2];c[j+76+8>>2]=c[h+8>>2];c[j+76+12>>2]=c[h+12>>2];g[j+92>>2]=0.0;g[j+96>>2]=0.0;g[j+100>>2]=.5;g[j+104>>2]=0.0;g[j+108>>2]=0.0;g[j+112>>2]=.800000011920929;g[j+116>>2]=1.0;a[j+120>>0]=0;g[j+124>>2]=.004999999888241291;g[j+128>>2]=.009999999776482582;g[j+132>>2]=.009999999776482582;g[j+136>>2]=.009999999776482582;c[j+8>>2]=1065353216;c[j+12>>2]=0;c[j+12+4>>2]=0;c[j+12+8>>2]=0;c[j+12+12>>2]=0;c[j+28>>2]=1065353216;c[j+32>>2]=0;c[j+32+4>>2]=0;c[j+32+8>>2]=0;c[j+32+12>>2]=0;c[j+48>>2]=1065353216;c[j+52>>2]=0;c[j+52+4>>2]=0;c[j+52+8>>2]=0;c[j+52+12>>2]=0;c[j+52+16>>2]=0;Od(b,j);i=j;return}function pg(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0;c[6435]=(c[6435]|0)+1;e=yc(627)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e+4>>2]=5;c[e>>2]=4432;c[e+8>>2]=-1;c[e+12>>2]=-1;g[e+16>>2]=3402823466385288598117041.0e14;a[e+20>>0]=1;a[e+21>>0]=0;c[e+24>>2]=-1;c[e+28>>2]=b;Il();c[e+32>>2]=23268;g[e+36>>2]=0.0;g[e+40>>2]=.30000001192092896;c[e+44>>2]=0;c[e>>2]=4648;h=e+300|0;c[h>>2]=c[d>>2];c[h+4>>2]=c[d+4>>2];c[h+8>>2]=c[d+8>>2];c[h+12>>2]=c[d+12>>2];f=e+316|0;c[f>>2]=c[d+16>>2];c[f+4>>2]=c[d+16+4>>2];c[f+8>>2]=c[d+16+8>>2];c[f+12>>2]=c[d+16+12>>2];b=e+332|0;c[b>>2]=c[d+32>>2];c[b+4>>2]=c[d+32+4>>2];c[b+8>>2]=c[d+32+8>>2];c[b+12>>2]=c[d+32+12>>2];i=e+348|0;c[i>>2]=c[d+48>>2];c[i+4>>2]=c[d+48+4>>2];c[i+8>>2]=c[d+48+8>>2];c[i+12>>2]=c[d+48+12>>2];d=e+364|0;a[e+527>>0]=0;c[d>>2]=c[h>>2];c[d+4>>2]=c[h+4>>2];c[d+8>>2]=c[h+8>>2];c[d+12>>2]=c[h+12>>2];d=e+380|0;c[d>>2]=c[f>>2];c[d+4>>2]=c[f+4>>2];c[d+8>>2]=c[f+8>>2];c[d+12>>2]=c[f+12>>2];d=e+396|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];d=e+412|0;a[e+524>>0]=0;a[e+525>>0]=0;a[e+526>>0]=0;a[e+552>>0]=0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;g[e+572>>2]=-1.0;g[e+444>>2]=999999984306749440.0;g[e+448>>2]=999999984306749440.0;g[e+452>>2]=999999984306749440.0;g[e+428>>2]=1.0;g[e+432>>2]=.30000001192092896;g[e+436>>2]=1.0;g[e+440>>2]=.009999999776482582;g[e+456>>2]=.05000000074505806;c[e+592>>2]=0;g[e+596>>2]=0.0;g[e+600>>2]=.699999988079071;g[e+604>>2]=0.0;return e|0}function qg(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;Zd(b,d);c[b>>2]=3068;c[6435]=(c[6435]|0)+1;e=yc(27)|0;i=e+4+15&-16;c[i+-4>>2]=e;a[i+4>>0]=0;c[(e+4+15&-16)>>2]=3100;c[b+92>>2]=i;c[6435]=(c[6435]|0)+1;i=yc(27)|0;e=i+4+15&-16;c[e+-4>>2]=i;a[e+4>>0]=0;c[(i+4+15&-16)>>2]=3120;c[b+96>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e>>2]=3120;c[b+100>>2]=e;a[e+4>>0]=1;c[6435]=(c[6435]|0)+1;i=yc(27)|0;e=i+4+15&-16;c[e+-4>>2]=i;a[e+4>>0]=0;c[(i+4+15&-16)>>2]=3140;c[b+104>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e>>2]=3160;c[b+108>>2]=e;a[e+4>>0]=1;if(!(a[b+20>>0]|0))return;e=c[b+16>>2]|0;if(!e)return;if((c[e>>2]|0)>=156)return;f=c[e+16>>2]|0;if(f){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);e=c[b+16>>2]|0;if(!e)i=b+16|0;else{f=b+16|0;g=11}}else{f=b+16|0;g=11}if((g|0)==11){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);i=f}c[6435]=(c[6435]|0)+1;e=yc(39)|0;if(!e)h=0;else{c[(e+4+15&-16)+-4>>2]=e;h=e+4+15&-16}e=c[d+12>>2]|0;c[h>>2]=156;f=h+4|0;c[f>>2]=e;c[6435]=(c[6435]|0)+1;e=yc((e*156|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[h+16>>2]=e;c[h+12>>2]=e;f=c[f>>2]|0;c[h+8>>2]=f;if(f+-1|0){b=c[h>>2]|0;g=f+-1|0;d=e;do{j=d;d=d+b|0;c[j>>2]=d;g=g+-1|0}while((g|0)!=0);e=e+(_(b,f+-1|0)|0)|0}c[e>>2]=0;c[i>>2]=h;return}function rg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0;c[6435]=(c[6435]|0)+1;h=yc(627)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[h+4>>2]=5;c[h+8>>2]=-1;c[h+12>>2]=-1;g[h+16>>2]=3402823466385288598117041.0e14;a[h+20>>0]=1;a[h+21>>0]=0;c[h+24>>2]=-1;c[h+28>>2]=b;c[h+32>>2]=d;g[h+36>>2]=0.0;g[h+40>>2]=.30000001192092896;c[h+44>>2]=0;c[h>>2]=4648;d=h+300|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];d=h+316|0;c[d>>2]=c[e+16>>2];c[d+4>>2]=c[e+16+4>>2];c[d+8>>2]=c[e+16+8>>2];c[d+12>>2]=c[e+16+12>>2];d=h+332|0;c[d>>2]=c[e+32>>2];c[d+4>>2]=c[e+32+4>>2];c[d+8>>2]=c[e+32+8>>2];c[d+12>>2]=c[e+32+12>>2];d=h+348|0;c[d>>2]=c[e+48>>2];c[d+4>>2]=c[e+48+4>>2];c[d+8>>2]=c[e+48+8>>2];c[d+12>>2]=c[e+48+12>>2];e=h+364|0;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];e=h+380|0;c[e>>2]=c[f+16>>2];c[e+4>>2]=c[f+16+4>>2];c[e+8>>2]=c[f+16+8>>2];c[e+12>>2]=c[f+16+12>>2];e=h+396|0;c[e>>2]=c[f+32>>2];c[e+4>>2]=c[f+32+4>>2];c[e+8>>2]=c[f+32+8>>2];c[e+12>>2]=c[f+32+12>>2];e=h+412|0;c[e>>2]=c[f+48>>2];c[e+4>>2]=c[f+48+4>>2];c[e+8>>2]=c[f+48+8>>2];c[e+12>>2]=c[f+48+12>>2];a[h+552>>0]=0;c[h+524>>2]=0;g[h+572>>2]=-1.0;g[h+444>>2]=999999984306749440.0;g[h+448>>2]=999999984306749440.0;g[h+452>>2]=999999984306749440.0;g[h+428>>2]=1.0;g[h+432>>2]=.30000001192092896;g[h+436>>2]=1.0;g[h+440>>2]=.009999999776482582;g[h+456>>2]=.05000000074505806;c[h+592>>2]=0;g[h+596>>2]=0.0;g[h+600>>2]=.699999988079071;g[h+604>>2]=0.0;return h|0}function sg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;l=c[d>>2]|0;l=Zb[c[(c[l>>2]|0)+56>>2]&31](l,48)|0;c[l+4>>2]=c[d>>2];c[l>>2]=6228;a[l+28>>0]=1;c[l+24>>2]=0;c[l+16>>2]=0;c[l+20>>2]=0;c[l+32>>2]=c[d+4>>2];a[l+36>>0]=0;c[6435]=(c[6435]|0)+1;b=yc(87)|0;if(!b)k=0;else{c[(b+4+15&-16)+-4>>2]=b;k=b+4+15&-16}c[k>>2]=9324;h=k+20|0;a[h>>0]=1;i=k+16|0;c[i>>2]=0;d=k+8|0;c[d>>2]=0;j=k+12|0;c[j>>2]=0;a[k+24>>0]=0;a[k+44>>0]=1;c[k+40>>2]=0;c[k+32>>2]=0;c[k+36>>2]=0;a[k+64>>0]=1;c[k+60>>2]=0;c[k+52>>2]=0;c[k+56>>2]=0;c[6435]=(c[6435]|0)+1;b=yc(43)|0;if(!b)g=0;else{c[(b+4+15&-16)+-4>>2]=b;g=b+4+15&-16}b=c[d>>2]|0;if((b|0)>0){d=0;do{m=g+(d*12|0)|0;n=(c[i>>2]|0)+(d*12|0)|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];d=d+1|0}while((d|0)!=(b|0))}b=c[i>>2]|0;if(!b){a[h>>0]=1;c[i>>2]=g;c[j>>2]=2;Kf(k);n=l+8|0;c[n>>2]=k;n=e+4|0;n=c[n>>2]|0;n=n+68|0;n=c[n>>2]|0;m=l+40|0;c[m>>2]=n;m=f+4|0;m=c[m>>2]|0;m=m+68|0;m=c[m>>2]|0;n=l+44|0;c[n>>2]=m;return l|0}if(a[h>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0)}c[i>>2]=0;a[h>>0]=1;c[i>>2]=g;c[j>>2]=2;Kf(k);n=l+8|0;c[n>>2]=k;n=e+4|0;n=c[n>>2]|0;n=n+68|0;n=c[n>>2]|0;m=l+40|0;c[m>>2]=n;m=f+4|0;m=c[m>>2]|0;m=m+68|0;m=c[m>>2]|0;n=l+44|0;c[n>>2]=m;return l|0}function tg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;Ab[c[(c[b>>2]|0)+32>>2]&255](b);d=Ob[c[(c[b>>2]|0)+16>>2]&63](b,104,1)|0;e=c[d+8>>2]|0;f=e;g=f+104|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(g|0));c[e+88>>2]=c[a+248>>2];c[e+92>>2]=c[a+252>>2];c[e+96>>2]=c[a+256>>2];c[e+100>>2]=c[a+260>>2];c[e>>2]=c[a+92>>2];c[e+4>>2]=c[a+96>>2];c[e+8>>2]=c[a+100>>2];c[e+12>>2]=c[a+104>>2];c[e+16>>2]=c[a+108>>2];c[e+20>>2]=c[a+116>>2];c[e+24>>2]=c[a+120>>2];c[e+28>>2]=c[a+124>>2];c[e+32>>2]=c[a+128>>2];c[e+36>>2]=c[a+132>>2];c[e+40>>2]=c[a+140>>2];c[e+44>>2]=c[a+144>>2];c[e+48>>2]=c[a+148>>2];c[e+52>>2]=c[a+152>>2];c[e+56>>2]=c[a+168>>2];c[e+60>>2]=c[a+172>>2];c[e+64>>2]=c[a+112>>2];c[e+68>>2]=c[a+156>>2];c[e+72>>2]=c[a+160>>2];c[e+76>>2]=c[a+164>>2];c[e+80>>2]=c[a+136>>2];yb[c[(c[b>>2]|0)+20>>2]&31](b,d,11938,1145853764,e);d=c[a+8>>2]|0;if((d|0)<=0){mj(a,b);td(a,b);a=c[b>>2]|0;a=a+36|0;a=c[a>>2]|0;Ab[a&255](b);return}f=0;do{e=c[(c[a+16>>2]|0)+(f<<2)>>2]|0;if(c[e+236>>2]&8){g=Eb[c[(c[e>>2]|0)+16>>2]&127](e)|0;g=Ob[c[(c[b>>2]|0)+16>>2]&63](b,g,1)|0;d=Ob[c[(c[e>>2]|0)+20>>2]&63](e,c[g+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,g,d,1497645651,e);d=c[a+8>>2]|0}f=f+1|0}while((f|0)<(d|0));mj(a,b);td(a,b);a=c[b>>2]|0;a=a+36|0;a=c[a>>2]|0;Ab[a&255](b);return}function ug(a,b){a=a|0;b=+b;var d=0,e=0,f=0,h=0,j=0.0,k=0.0,l=0.0;h=i;i=i+32|0;d=c[a+8>>2]|0;if((d|0)<=0){i=h;return}f=0;do{e=c[(c[a+16>>2]|0)+(f<<2)>>2]|0;if((!((e|0)==0?1:(c[e+236>>2]&2|0)==0)?(c[e+216>>2]|0)!=2:0)?!(b==0.0?1:(c[e+204>>2]&2|0)==0):0){d=c[e+480>>2]|0;if(!d)d=e+4|0;else{Cb[c[(c[d>>2]|0)+8>>2]&127](d,e+4|0);d=e+4|0}k=1.0/b*(+g[e+56>>2]-+g[e+120>>2]);l=1.0/b*(+g[e+60>>2]-+g[e+124>>2]);g[e+312>>2]=1.0/b*(+g[e+52>>2]-+g[e+116>>2]);g[e+316>>2]=k;g[e+320>>2]=l;g[e+324>>2]=0.0;Gf(e+68|0,d,h+8|0,h);l=+g[h>>2];k=1.0/b*l*+g[h+8+4>>2];j=1.0/b*l*+g[h+8+8>>2];g[e+328>>2]=1.0/b*+g[h+8>>2]*l;g[e+332>>2]=k;g[e+336>>2]=j;g[e+340>>2]=0.0;c[e+132>>2]=c[e+312>>2];c[e+132+4>>2]=c[e+312+4>>2];c[e+132+8>>2]=c[e+312+8>>2];c[e+132+12>>2]=c[e+312+12>>2];c[e+148>>2]=c[e+328>>2];c[e+148+4>>2]=c[e+328+4>>2];c[e+148+8>>2]=c[e+328+8>>2];c[e+148+12>>2]=c[e+328+12>>2];c[e+68>>2]=c[d>>2];c[e+68+4>>2]=c[d+4>>2];c[e+68+8>>2]=c[d+8>>2];c[e+68+12>>2]=c[d+12>>2];c[e+84>>2]=c[e+20>>2];c[e+84+4>>2]=c[e+20+4>>2];c[e+84+8>>2]=c[e+20+8>>2];c[e+84+12>>2]=c[e+20+12>>2];c[e+100>>2]=c[e+36>>2];c[e+100+4>>2]=c[e+36+4>>2];c[e+100+8>>2]=c[e+36+8>>2];c[e+100+12>>2]=c[e+36+12>>2];c[e+116>>2]=c[e+52>>2];c[e+116+4>>2]=c[e+52+4>>2];c[e+116+8>>2]=c[e+52+8>>2];c[e+116+12>>2]=c[e+52+12>>2];d=c[a+8>>2]|0}f=f+1|0}while((f|0)<(d|0));i=h;return}function vg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c[6421]=(c[6421]|0)+1;g=((d<<16|b)+~((d<<16|b)<<15)>>10^(d<<16|b)+~((d<<16|b)<<15))*9|0;l=c[a+40>>2]|0;g=l+(((c[a+12>>2]|0)+-1&((g>>6^g)+~((g>>6^g)<<11)>>16^(g>>6^g)+~((g>>6^g)<<11)))<<2)|0;f=c[g>>2]|0;if((f|0)==-1){n=0;return n|0}m=c[a+16>>2]|0;e=f;while(1){k=m+(e*12|0)|0;if((c[k>>2]|0)==(b|0)?(c[m+(e*12|0)+4>>2]|0)==(d|0):0)break;e=c[(c[a+60>>2]|0)+(e<<2)>>2]|0;if((e|0)==-1){e=0;n=21;break}}if((n|0)==21)return e|0;if(!k){n=0;return n|0}j=c[m+(e*12|0)+8>>2]|0;i=(e*12|0)/12|0;b=c[a+60>>2]|0;if((f|0)!=(i|0)){while(1){d=b+(f<<2)|0;e=c[d>>2]|0;if((e|0)==(i|0))break;else f=e}e=c[b+(i<<2)>>2]|0;if((f|0)==-1)n=11;else c[d>>2]=e}else{e=c[b+(f<<2)>>2]|0;n=11}if((n|0)==11)c[g>>2]=e;g=(c[a+8>>2]|0)+-1|0;if((g|0)==(i|0)){c[a+8>>2]=i;n=j;return n|0}h=c[m+(g*12|0)+4>>2]<<16|c[m+(g*12|0)>>2];h=(h+~(h<<15)>>10^h+~(h<<15))*9|0;h=((h>>6^h)+~((h>>6^h)<<11)>>16^(h>>6^h)+~((h>>6^h)<<11))&(c[a+12>>2]|0)+-1;e=c[l+(h<<2)>>2]|0;b=c[a+60>>2]|0;if((e|0)!=(g|0)){f=e;while(1){d=b+(f<<2)|0;e=c[d>>2]|0;if((e|0)==(g|0))break;else f=e}e=c[b+(g<<2)>>2]|0;if((f|0)==-1)n=19;else c[d>>2]=e}else{e=c[b+(g<<2)>>2]|0;n=19}if((n|0)==19)c[l+(h<<2)>>2]=e;c[k>>2]=c[m+(g*12|0)>>2];c[k+4>>2]=c[m+(g*12|0)+4>>2];c[k+8>>2]=c[m+(g*12|0)+8>>2];n=(c[a+40>>2]|0)+(h<<2)|0;c[(c[a+60>>2]|0)+(i<<2)>>2]=c[n>>2];c[n>>2]=i;c[a+8>>2]=(c[a+8>>2]|0)+-1;n=j;return n|0}function wg(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;d=c[b+236>>2]|0;if((b|0)==0|(d|0)!=8){if(!((b|0)==0|(d&2|0)==0)){Cb[c[(c[a>>2]|0)+92>>2]&127](a,b);return}d=c[b+188>>2]|0;if(d|0){h=c[a+68>>2]|0;h=Eb[c[(c[h>>2]|0)+36>>2]&127](h)|0;ic[c[(c[h>>2]|0)+40>>2]&127](h,d,c[a+24>>2]|0);h=c[a+68>>2]|0;ic[c[(c[h>>2]|0)+12>>2]&127](h,d,c[a+24>>2]|0);c[b+188>>2]=0}d=c[a+8>>2]|0;if((d|0)<=0)return;e=c[a+16>>2]|0;h=0;while(1){f=e+(h<<2)|0;if((c[f>>2]|0)==(b|0))break;g=h+1|0;if((g|0)<(d|0))h=g;else{i=26;break}}if((i|0)==26)return;if((h|0)>=(d|0))return;c[f>>2]=c[e+(d+-1<<2)>>2];c[(c[a+16>>2]|0)+(d+-1<<2)>>2]=b;c[a+8>>2]=d+-1;return}f=c[a+328>>2]|0;a:do if((f|0)>0){g=c[a+336>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0))break a}if((d|0)<(f|0)){c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+336>>2]|0)+(f+-1<<2)>>2]=b;c[a+328>>2]=f+-1}}while(0);d=c[b+188>>2]|0;if(d|0){h=c[a+68>>2]|0;h=Eb[c[(c[h>>2]|0)+36>>2]&127](h)|0;ic[c[(c[h>>2]|0)+40>>2]&127](h,d,c[a+24>>2]|0);h=c[a+68>>2]|0;ic[c[(c[h>>2]|0)+12>>2]&127](h,d,c[a+24>>2]|0);c[b+188>>2]=0}d=c[a+8>>2]|0;if((d|0)<=0)return;e=c[a+16>>2]|0;h=0;while(1){f=e+(h<<2)|0;if((c[f>>2]|0)==(b|0))break;g=h+1|0;if((g|0)<(d|0))h=g;else{i=26;break}}if((i|0)==26)return;if((h|0)>=(d|0))return;c[f>>2]=c[e+(d+-1<<2)>>2];c[(c[a+16>>2]|0)+(d+-1<<2)>>2]=b;c[a+8>>2]=d+-1;return}function xg(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0;c[6435]=(c[6435]|0)+1;i=yc(783)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}c[i+4>>2]=4;c[i+8>>2]=-1;c[i+12>>2]=-1;g[i+16>>2]=3402823466385288598117041.0e14;a[i+20>>0]=1;a[i+21>>0]=0;c[i+24>>2]=-1;c[i+28>>2]=b;c[i+32>>2]=d;g[i+36>>2]=0.0;g[i+40>>2]=.30000001192092896;c[i+44>>2]=0;c[i>>2]=4704;d=i+552|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];d=i+568|0;c[d>>2]=c[e+16>>2];c[d+4>>2]=c[e+16+4>>2];c[d+8>>2]=c[e+16+8>>2];c[d+12>>2]=c[e+16+12>>2];d=i+584|0;c[d>>2]=c[e+32>>2];c[d+4>>2]=c[e+32+4>>2];c[d+8>>2]=c[e+32+8>>2];c[d+12>>2]=c[e+32+12>>2];d=i+600|0;c[d>>2]=c[e+48>>2];c[d+4>>2]=c[e+48+4>>2];c[d+8>>2]=c[e+48+8>>2];c[d+12>>2]=c[e+48+12>>2];e=i+616|0;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];e=i+632|0;c[e>>2]=c[f+16>>2];c[e+4>>2]=c[f+16+4>>2];c[e+8>>2]=c[f+16+8>>2];c[e+12>>2]=c[f+16+12>>2];e=i+648|0;c[e>>2]=c[f+32>>2];c[e+4>>2]=c[f+32+4>>2];c[e+8>>2]=c[f+32+8>>2];c[e+12>>2]=c[f+32+12>>2];e=i+664|0;c[e>>2]=c[f+48>>2];c[e+4>>2]=c[f+48+4>>2];c[e+8>>2]=c[f+48+8>>2];c[e+12>>2]=c[f+48+12>>2];g[i+688>>2]=0.0;g[i+692>>2]=-1.0;g[i+696>>2]=.8999999761581421;g[i+700>>2]=.30000001192092896;g[i+704>>2]=1.0;g[i+708>>2]=0.0;g[i+712>>2]=0.0;a[i+716>>0]=0;a[i+736>>0]=0;a[i+737>>0]=0;a[i+738>>0]=0;a[i+739>>0]=1;a[i+740>>0]=h&1;c[i+748>>2]=0;g[i+732>>2]=h?-1.0:1.0;return i|0}function yg(a,b,d){a=a|0;b=+b;d=+d;var e=0,f=0,h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0,x=0.0,y=0.0,z=0.0,A=0.0;h=i;i=i+16|0;d=+g[a+336>>2]*b;b=+g[a+452>>2];e=c[a+792>>2]|0;if((e|0)<=0){i=h;return}f=0;do{t=c[a+800>>2]|0;k=t+(f*96|0)+20|0;w=c[k>>2]|0;o=c[t+(f*96|0)>>2]|0;z=+g[t+(f*96|0)+4>>2];y=+g[t+(f*96|0)+8>>2];x=+g[t+(f*96|0)+12>>2];j=t+(f*96|0)+76|0;v=+g[w+332>>2];q=+g[t+(f*96|0)+84>>2];A=+g[w+336>>2];m=+g[t+(f*96|0)+80>>2];l=+g[j>>2];n=+g[w+328>>2];s=+g[o+8>>2];r=+g[o+12>>2];p=+g[o+16>>2];u=d*(z*+g[w+4>>2]+y*+g[w+8>>2]+x*+g[w+12>>2]+ +g[w+52>>2]-s)+(b*(v*q-A*m+ +g[w+312>>2])-(s-+g[o+24>>2]));q=d*(z*+g[w+20>>2]+y*+g[w+24>>2]+x*+g[w+28>>2]+ +g[w+56>>2]-r)+(b*(+g[w+316>>2]+(A*l-q*n))-(r-+g[o+28>>2]));l=d*(z*+g[w+36>>2]+y*+g[w+40>>2]+x*+g[w+44>>2]+ +g[w+60>>2]-p)+(b*(m*n-v*l+ +g[w+320>>2])-(p-+g[o+32>>2]));v=+g[t+(f*96|0)+24>>2];n=(u*+g[t+(f*96|0)+28>>2]+q*+g[t+(f*96|0)+32>>2]+ +g[t+(f*96|0)+36>>2]*l)*v;m=(u*+g[t+(f*96|0)+44>>2]+q*+g[t+(f*96|0)+48>>2]+l*+g[t+(f*96|0)+52>>2])*v;l=v*(u*+g[t+(f*96|0)+60>>2]+q*+g[t+(f*96|0)+64>>2]+l*+g[t+(f*96|0)+68>>2]);q=+g[t+(f*96|0)+92>>2];g[o+8>>2]=s+n*q;g[o+12>>2]=q*m+r;g[o+16>>2]=q*l+p;k=c[k>>2]|0;g[h>>2]=-n;g[h+4>>2]=-m;g[h+8>>2]=-l;g[h+12>>2]=0.0;gj(k,h,j);f=f+1|0}while((f|0)!=(e|0));i=h;return}function zg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;h=+g[d+100>>2];k=+g[d+16>>2];i=+g[d+20>>2];j=+g[d+24>>2];e=+g[d+108>>2];e=+g[d+112>>2]-h*+g[d+116>>2]-(k*+g[a+64>>2]+i*+g[a+68>>2]+j*+g[a+72>>2]+(+g[d>>2]*+g[a+80>>2]+ +g[d+4>>2]*+g[a+84>>2]+ +g[d+8>>2]*+g[a+88>>2]))*e-e*(+g[d+48>>2]*+g[b+64>>2]+ +g[d+52>>2]*+g[b+68>>2]+ +g[d+56>>2]*+g[b+72>>2]+(+g[d+32>>2]*+g[b+80>>2]+ +g[d+36>>2]*+g[b+84>>2]+ +g[d+40>>2]*+g[b+88>>2]));f=+g[d+120>>2];do if(!(h+e>2];if(h+e>f){g[d+100>>2]=f;e=f-h;break}else{g[d+100>>2]=h+e;break}}else{g[d+100>>2]=f;e=f-h}while(0);if(c[a+240>>2]|0){i=e*i*+g[a+132>>2]*+g[a+116>>2];j=e*j*+g[a+136>>2]*+g[a+120>>2];g[a+64>>2]=+g[a+112>>2]*e*k*+g[a+128>>2]+ +g[a+64>>2];g[a+68>>2]=i+ +g[a+68>>2];g[a+72>>2]=j+ +g[a+72>>2];j=e*+g[a+100>>2]*+g[d+68>>2];k=e*+g[a+104>>2]*+g[d+72>>2];g[a+80>>2]=e*+g[a+96>>2]*+g[d+64>>2]+ +g[a+80>>2];g[a+84>>2]=j+ +g[a+84>>2];g[a+88>>2]=k+ +g[a+88>>2]}if(!(c[b+240>>2]|0))return;k=e*+g[d+52>>2]*+g[b+132>>2]*+g[b+116>>2];j=e*+g[d+56>>2]*+g[b+136>>2]*+g[b+120>>2];g[b+64>>2]=+g[b+112>>2]*e*+g[d+48>>2]*+g[b+128>>2]+ +g[b+64>>2];g[b+68>>2]=k+ +g[b+68>>2];g[b+72>>2]=j+ +g[b+72>>2];j=e*+g[b+100>>2]*+g[d+84>>2];k=e*+g[b+104>>2]*+g[d+88>>2];g[b+80>>2]=e*+g[b+96>>2]*+g[d+80>>2]+ +g[b+80>>2];g[b+84>>2]=j+ +g[b+84>>2];g[b+88>>2]=k+ +g[b+88>>2];return}function Ag(a,b){a=a|0;b=b|0;var d=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;p=i;i=i+32|0;o=c[a+92>>2]|0;if(!(Eb[c[(c[o>>2]|0)+56>>2]&127](o)|0)){i=p;return}o=c[a+92>>2]|0;o=Eb[c[(c[o>>2]|0)+28>>2]&127](o)|0;d=c[o+4>>2]|0;if((d|0)>1){Vd(o,0,d+-1|0);d=c[o+4>>2]|0}d=d-(c[a+104>>2]|0)|0;c[p+16>>2]=0;c[p+16+4>>2]=0;c[p+16+8>>2]=0;c[p+16+12>>2]=0;yi(o,d,p+16|0);c[a+104>>2]=0;d=c[o+4>>2]|0;if((d|0)>0){f=0;l=0;m=0;h=0;while(1){k=c[o+12>>2]|0;j=k+(l<<4)|0;q=m;m=c[j>>2]|0;k=k+(l<<4)+4|0;g=c[k>>2]|0;if(!((m|0)==(q|0)&(g|0)==(h|0))){q=m+54|0;h=m+48|0;if(!((((((e[q>>1]|0)>=(e[g+48>>1]|0)?(e[g+54>>1]|0)>=(e[h>>1]|0):0)?(e[q+2>>1]|0)>=(e[g+48+2>>1]|0):0)?(e[g+54+2>>1]|0)>=(e[h+2>>1]|0):0)?(e[q+4>>1]|0)>=(e[g+52>>1]|0):0)?(e[g+54+4>>1]|0)>=(e[m+52>>1]|0):0))n=13}else{g=h;n=13}if((n|0)==13){n=0;f=c[a+92>>2]|0;ic[c[(c[f>>2]|0)+32>>2]&127](f,j,b);c[j>>2]=0;c[k>>2]=0;f=(c[a+104>>2]|0)+1|0;c[a+104>>2]=f;c[6163]=(c[6163]|0)+-1;d=c[o+4>>2]|0}l=l+1|0;if((l|0)>=(d|0))break;else h=g}if((d|0)>1){Vd(o,0,d+-1|0);f=c[a+104>>2]|0;d=c[o+4>>2]|0}}else f=0;c[p>>2]=0;c[p+4>>2]=0;c[p+8>>2]=0;c[p+12>>2]=0;yi(o,d-f|0,p);c[a+104>>2]=0;i=p;return}function Bg(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0,l=0,m=0.0,n=0.0,o=0,p=0.0;b=c[a+712>>2]|0;if((b|0)>0){d=0;do{l=(c[a+720>>2]|0)+(d*104|0)+72|0;d=d+1|0;c[l>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0}while((d|0)!=(b|0))}b=c[a+752>>2]|0;if((b|0)>0){d=0;do{o=c[a+760>>2]|0;k=c[o+(d*44|0)+12>>2]|0;i=c[o+(d*44|0)+8>>2]|0;j=+g[i+8>>2];e=+g[k+8>>2]-j;f=+g[i+12>>2];h=+g[k+12>>2]-f;m=+g[i+16>>2];n=+g[k+16>>2]-m;l=c[o+(d*44|0)+16>>2]|0;j=+g[l+8>>2]-j;f=+g[l+12>>2]-f;m=+g[l+16>>2]-m;p=1.0/+O(+((e*f-h*j)*(e*f-h*j)+((h*m-n*f)*(h*m-n*f)+(n*j-e*m)*(n*j-e*m))));g[o+(d*44|0)+20>>2]=p*(h*m-n*f);g[o+(d*44|0)+24>>2]=p*(n*j-e*m);g[o+(d*44|0)+28>>2]=(e*f-h*j)*p;c[o+(d*44|0)+32>>2]=0;g[i+72>>2]=h*m-n*f+ +g[i+72>>2];g[i+76>>2]=n*j-e*m+ +g[i+76>>2];g[i+80>>2]=e*f-h*j+ +g[i+80>>2];g[k+72>>2]=h*m-n*f+ +g[k+72>>2];g[k+76>>2]=n*j-e*m+ +g[k+76>>2];g[k+80>>2]=e*f-h*j+ +g[k+80>>2];g[l+72>>2]=h*m-n*f+ +g[l+72>>2];g[l+76>>2]=n*j-e*m+ +g[l+76>>2];g[l+80>>2]=e*f-h*j+ +g[l+80>>2];d=d+1|0}while((d|0)!=(b|0))}l=c[a+712>>2]|0;if((l|0)<=0)return;a=c[a+720>>2]|0;k=0;do{i=a+(k*104|0)+72|0;j=+g[i>>2];b=a+(k*104|0)+76|0;e=+g[b>>2];d=a+(k*104|0)+80|0;f=+g[d>>2];h=+O(+(j*j+e*e+f*f));if(h>1.1920928955078125e-07){g[i>>2]=j*(1.0/h);g[b>>2]=1.0/h*e;g[d>>2]=1.0/h*f}k=k+1|0}while((k|0)!=(l|0));return}function Cg(b,d,e,f){b=b|0;d=+d;e=e|0;f=+f;var h=0,j=0.0,k=0,l=0;l=i;i=i+16|0;tb(c[6434]|0,0)|0;Vq(25696);c[6425]=(c[6425]|0)+1;k=c[6428]|0;c[6428]=k+1;if(!k){tb(l|0,0)|0;k=c[6434]|0;c[6427]=(c[l+4>>2]|0)-(c[k+4>>2]|0)+(((c[l>>2]|0)-(c[k>>2]|0)|0)*1e6|0)}c[6433]=0;tb(l|0,0)|0;li(11963);if(e){g[b+268>>2]=f;j=+g[b+264>>2]+d;g[b+264>>2]=j;if(!(j>=f)){d=f;k=0}else{g[b+264>>2]=j-+(~~(j/f)|0)*f;d=f;k=~~(j/f)}}else{g[b+264>>2]=a[b+300>>0]|0?0.0:d;g[b+268>>2]=0.0;k=!(+N(+d)<1.1920928955078125e-07)&1;e=k}if(Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0){h=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;a[26260]=(Eb[c[(c[h>>2]|0)+48>>2]&127](h)|0)>>>4&1}if(k){e=(k|0)>(e|0)?e:k;zb[c[(c[b>>2]|0)+164>>2]&31](b,d*+(e|0));Ab[c[(c[b>>2]|0)+168>>2]&255](b);if((e|0)>0){h=0;do{zb[c[(c[b>>2]|0)+160>>2]&31](b,d);Ab[c[(c[b>>2]|0)+80>>2]&255](b);h=h+1|0}while((h|0)<(e|0));e=b}else e=b}else{Ab[c[(c[b>>2]|0)+80>>2]&255](b);e=b}Ab[c[(c[e>>2]|0)+120>>2]&255](b);c[6433]=(c[6433]|0)+1;e=c[2357]|0;b=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=b;if(b|0){i=l;return k|0}do if(c[e+4>>2]|0){tb(l|0,0)|0;b=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[l+4>>2]|0)-(c[b+4>>2]|0)+(((c[l>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[e+16>>2]|0)){e=c[2357]|0;break}else{i=l;return k|0}}while(0);c[2357]=c[e+20>>2];i=l;return k|0}function Dg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0;c[6435]=(c[6435]|0)+1;h=yc(783)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[h+4>>2]=4;c[h+8>>2]=-1;c[h+12>>2]=-1;g[h+16>>2]=3402823466385288598117041.0e14;a[h+20>>0]=1;a[h+21>>0]=0;c[h+24>>2]=-1;c[h+28>>2]=b;c[h+32>>2]=d;g[h+36>>2]=0.0;g[h+40>>2]=.30000001192092896;c[h+44>>2]=0;c[h>>2]=4704;d=h+552|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];d=h+568|0;c[d>>2]=c[e+16>>2];c[d+4>>2]=c[e+16+4>>2];c[d+8>>2]=c[e+16+8>>2];c[d+12>>2]=c[e+16+12>>2];d=h+584|0;c[d>>2]=c[e+32>>2];c[d+4>>2]=c[e+32+4>>2];c[d+8>>2]=c[e+32+8>>2];c[d+12>>2]=c[e+32+12>>2];d=h+600|0;c[d>>2]=c[e+48>>2];c[d+4>>2]=c[e+48+4>>2];c[d+8>>2]=c[e+48+8>>2];c[d+12>>2]=c[e+48+12>>2];e=h+616|0;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];e=h+632|0;c[e>>2]=c[f+16>>2];c[e+4>>2]=c[f+16+4>>2];c[e+8>>2]=c[f+16+8>>2];c[e+12>>2]=c[f+16+12>>2];e=h+648|0;c[e>>2]=c[f+32>>2];c[e+4>>2]=c[f+32+4>>2];c[e+8>>2]=c[f+32+8>>2];c[e+12>>2]=c[f+32+12>>2];e=h+664|0;c[e>>2]=c[f+48>>2];c[e+4>>2]=c[f+48+4>>2];c[e+8>>2]=c[f+48+8>>2];c[e+12>>2]=c[f+48+12>>2];g[h+688>>2]=0.0;g[h+692>>2]=-1.0;g[h+696>>2]=.8999999761581421;g[h+700>>2]=.30000001192092896;g[h+704>>2]=1.0;g[h+708>>2]=0.0;g[h+712>>2]=0.0;a[h+716>>0]=0;a[h+736>>0]=0;a[h+737>>0]=0;a[h+738>>0]=0;a[h+739>>0]=1;a[h+740>>0]=0;c[h+748>>2]=0;g[h+732>>2]=1.0;return h|0}function Eg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0.0;m=i;i=i+672|0;c[m+568+8>>2]=0;c[m+568+12>>2]=1065353216;c[m+568+16>>2]=1065353216;c[m+568+20>>2]=1065353216;g[m+568+24>>2]=0.0;c[m+568+52>>2]=0;c[m+568>>2]=3736;c[m+568+4>>2]=1;c[m+568+56>>2]=c[d>>2];c[m+568+56+4>>2]=c[d+4>>2];c[m+568+56+8>>2]=c[d+8>>2];c[m+568+56+12>>2]=c[d+12>>2];c[m+568+72>>2]=c[d+16>>2];c[m+568+72+4>>2]=c[d+16+4>>2];c[m+568+72+8>>2]=c[d+16+8>>2];c[m+568+72+12>>2]=c[d+16+12>>2];c[m+568+88>>2]=c[d+32>>2];c[m+568+88+4>>2]=c[d+32+4>>2];c[m+568+88+8>>2]=c[d+32+8>>2];c[m+568+88+12>>2]=c[d+32+12>>2];c[m+568+44>>2]=c[b+204>>2];g[m+208+308>>2]=9.999999747378752e-05;a[m+208+332>>0]=0;c[m+200>>2]=9120;d=c[b+4>>2]|0;c[m+176>>2]=9188;c[m+176+4>>2]=m+208;c[m+176+8>>2]=m+200;c[m+176+12>>2]=d;c[m+176+16>>2]=m+568;c[m+176+20>>2]=0;c[m>>2]=3708;c[m+168>>2]=0;g[m+164>>2]=1.0;c[m+172>>2]=c[b+208>>2];if((Xd(m+176|0,b+8|0,b+72|0,b+136|0,b+136|0,m)|0?(h=+g[m+132>>2],j=+g[m+136>>2],k=+g[m+140>>2],h*h+j*j+k*k>9.999999747378752e-05):0)?(l=+g[m+164>>2],l<+g[b+200>>2]):0){n=1.0/+O(+(h*h+j*j+k*k));g[m+132>>2]=h*n;g[m+136>>2]=j*n;g[m+140>>2]=k*n;+Ub[c[(c[b>>2]|0)+12>>2]&3](b,m+132|0,m+148|0,l,e,f)}c[m+568>>2]=7124;e=c[m+568+52>>2]|0;if(!e){i=m;return}Ab[c[c[e>>2]>>2]&255](e);e=c[m+568+52>>2]|0;if(!e){i=m;return}c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);i=m;return}function Fg(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0;q=i;i=i+32|0;p=c[a+12>>2]|0;if(!p){i=q;return}c[f+4>>2]=p;a=c[b+4>>2]|0;r=c[d+4>>2]|0;b=c[b+12>>2]|0;e=c[d+12>>2]|0;h=+g[b+48>>2]-+g[e+48>>2];j=+g[b+52>>2]-+g[e+52>>2];l=+g[b+56>>2]-+g[e+56>>2];m=+O(+(h*h+j*j+l*l));n=+g[r+28>>2]*+g[r+12>>2];o=+g[a+28>>2]*+g[a+12>>2]+n;if(m>o){if(!(c[p+748>>2]|0)){i=q;return}a=c[p+740>>2]|0;b=c[(c[f+8>>2]|0)+8>>2]|0;e=c[(c[f+12>>2]|0)+8>>2]|0;if((a|0)==(b|0)){ef(p,a+4|0,e+4|0);i=q;return}else{ef(p,e+4|0,b+4|0);i=q;return}}c[q+16>>2]=1065353216;c[q+16+4>>2]=0;c[q+16+8>>2]=0;g[q+16+12>>2]=0.0;if(m>1.1920928955078125e-07){g[q+16>>2]=h*(1.0/m);g[q+16+4>>2]=j*(1.0/m);g[q+16+8>>2]=l*(1.0/m);g[q+16+12>>2]=0.0;k=h*(1.0/m);j=j*(1.0/m);h=l*(1.0/m)}else{k=1.0;j=0.0;h=0.0}j=n*j+ +g[e+52>>2];l=n*h+ +g[e+56>>2];g[q>>2]=n*k+ +g[e+48>>2];g[q+4>>2]=j;g[q+8>>2]=l;g[q+12>>2]=0.0;hc[c[(c[f>>2]|0)+16>>2]&15](f,q+16|0,q,m-o);a=c[f+4>>2]|0;do if(c[a+748>>2]|0){b=c[a+740>>2]|0;d=c[(c[f+8>>2]|0)+8>>2]|0;e=c[(c[f+12>>2]|0)+8>>2]|0;if((b|0)==(d|0)){ef(a,b+4|0,e+4|0);break}else{ef(a,e+4|0,d+4|0);break}}while(0);i=q;return}function Gg(a,b){a=a|0;b=b|0;var d=0,e=0;c[6435]=(c[6435]|0)+1;d=yc(219)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d>>2]=2896;e=d+4|0;c[e>>2]=c[a>>2];c[e+4>>2]=c[a+4>>2];c[e+8>>2]=c[a+8>>2];c[e+12>>2]=c[a+12>>2];e=d+20|0;c[e>>2]=c[a+16>>2];c[e+4>>2]=c[a+16+4>>2];c[e+8>>2]=c[a+16+8>>2];c[e+12>>2]=c[a+16+12>>2];e=d+36|0;c[e>>2]=c[a+32>>2];c[e+4>>2]=c[a+32+4>>2];c[e+8>>2]=c[a+32+8>>2];c[e+12>>2]=c[a+32+12>>2];e=d+52|0;c[e>>2]=c[a+48>>2];c[e+4>>2]=c[a+48+4>>2];c[e+8>>2]=c[a+48+8>>2];c[e+12>>2]=c[a+48+12>>2];e=d+68|0;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];e=d+84|0;c[e>>2]=c[b+16>>2];c[e+4>>2]=c[b+16+4>>2];c[e+8>>2]=c[b+16+8>>2];c[e+12>>2]=c[b+16+12>>2];e=d+100|0;c[e>>2]=c[b+32>>2];c[e+4>>2]=c[b+32+4>>2];c[e+8>>2]=c[b+32+8>>2];c[e+12>>2]=c[b+32+12>>2];e=d+116|0;c[e>>2]=c[b+48>>2];c[e+4>>2]=c[b+48+4>>2];c[e+8>>2]=c[b+48+8>>2];c[e+12>>2]=c[b+48+12>>2];b=d+132|0;c[b>>2]=c[a>>2];c[b+4>>2]=c[a+4>>2];c[b+8>>2]=c[a+8>>2];c[b+12>>2]=c[a+12>>2];b=d+148|0;c[b>>2]=c[a+16>>2];c[b+4>>2]=c[a+16+4>>2];c[b+8>>2]=c[a+16+8>>2];c[b+12>>2]=c[a+16+12>>2];b=d+164|0;c[b>>2]=c[a+32>>2];c[b+4>>2]=c[a+32+4>>2];c[b+8>>2]=c[a+32+8>>2];c[b+12>>2]=c[a+32+12>>2];b=d+180|0;c[b>>2]=c[a+48>>2];c[b+4>>2]=c[a+48+4>>2];c[b+8>>2]=c[a+48+8>>2];c[b+12>>2]=c[a+48+12>>2];c[d+196>>2]=0;return d|0}function Hg(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;if(!(a[d+164>>0]|0)){f=c[d+148>>2]|0;if((f|0)==(c[d+152>>2]|0)?(k=f|0?f<<1:1,(f|0)<(k|0)):0){if(!k)i=0;else{c[6435]=(c[6435]|0)+1;f=yc((k<<1)+19|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}i=f;f=c[d+148>>2]|0}h=c[d+156>>2]|0;if((f|0)<=0)if(!h)f=d+160|0;else g=27;else{g=0;do{b[i+(g<<1)>>1]=b[h+(g<<1)>>1]|0;g=g+1|0}while((g|0)!=(f|0));g=27}if((g|0)==27){if(a[d+160>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[d+156>>2]=0;f=d+160|0}a[f>>0]=1;c[d+156>>2]=i;c[d+152>>2]=k;f=c[d+148>>2]|0}k=c[d+156>>2]|0;b[k+(f<<1)>>1]=e;c[d+148>>2]=f+1;c[(c[d+32>>2]|0)+4>>2]=k;return}else{f=c[d+128>>2]|0;if((f|0)==(c[d+132>>2]|0)?(j=f|0?f<<1:1,(f|0)<(j|0)):0){if(!j)i=0;else{c[6435]=(c[6435]|0)+1;f=yc((j<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}i=f;f=c[d+128>>2]|0}h=c[d+136>>2]|0;if((f|0)<=0)if(!h)f=d+140|0;else g=12;else{g=0;do{c[i+(g<<2)>>2]=c[h+(g<<2)>>2];g=g+1|0}while((g|0)!=(f|0));g=12}if((g|0)==12){if(a[d+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[d+136>>2]=0;f=d+140|0}a[f>>0]=1;c[d+136>>2]=i;c[d+132>>2]=j;f=c[d+128>>2]|0}k=c[d+136>>2]|0;c[k+(f<<2)>>2]=e;c[d+128>>2]=(c[d+128>>2]|0)+1;c[(c[d+32>>2]|0)+4>>2]=k;return}}function Ig(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0;e=+g[d+128>>2];if(!(e!=0.0))return;c[5971]=(c[5971]|0)+1;k=+g[d+96>>2];f=+g[d+16>>2];h=+g[d+20>>2];i=+g[d+24>>2];j=+g[d+108>>2];j=e-k*+g[d+116>>2]-(f*+g[a+144>>2]+h*+g[a+148>>2]+i*+g[a+152>>2]+(+g[d>>2]*+g[a+160>>2]+ +g[d+4>>2]*+g[a+164>>2]+ +g[d+8>>2]*+g[a+168>>2]))*j-j*(+g[d+48>>2]*+g[b+144>>2]+ +g[d+52>>2]*+g[b+148>>2]+ +g[d+56>>2]*+g[b+152>>2]+(+g[d+32>>2]*+g[b+160>>2]+ +g[d+36>>2]*+g[b+164>>2]+ +g[d+40>>2]*+g[b+168>>2]));l=+g[d+120>>2];e=k+j>2]=k+j>2]|0){l=e*h*+g[a+132>>2]*+g[a+116>>2];k=e*i*+g[a+136>>2]*+g[a+120>>2];g[a+144>>2]=+g[a+112>>2]*e*f*+g[a+128>>2]+ +g[a+144>>2];g[a+148>>2]=l+ +g[a+148>>2];g[a+152>>2]=k+ +g[a+152>>2];k=e*+g[a+100>>2]*+g[d+68>>2];l=e*+g[a+104>>2]*+g[d+72>>2];g[a+160>>2]=e*+g[a+96>>2]*+g[d+64>>2]+ +g[a+160>>2];g[a+164>>2]=k+ +g[a+164>>2];g[a+168>>2]=l+ +g[a+168>>2]}if(!(c[b+240>>2]|0))return;l=e*+g[d+52>>2]*+g[b+132>>2]*+g[b+116>>2];k=e*+g[d+56>>2]*+g[b+136>>2]*+g[b+120>>2];g[b+144>>2]=+g[b+112>>2]*e*+g[d+48>>2]*+g[b+128>>2]+ +g[b+144>>2];g[b+148>>2]=l+ +g[b+148>>2];g[b+152>>2]=k+ +g[b+152>>2];k=e*+g[b+100>>2]*+g[d+84>>2];l=e*+g[b+104>>2]*+g[d+88>>2];g[b+160>>2]=e*+g[b+96>>2]*+g[d+80>>2]+ +g[b+160>>2];g[b+164>>2]=k+ +g[b+164>>2];g[b+168>>2]=l+ +g[b+168>>2];return}function Jg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;g=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=g;if(g|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];g=c[a+48>>2]|0;Ob[c[(c[g>>2]|0)+56>>2]&63](g,b+12|0,d)|0;c[b+52>>2]=c[a+12>>2];do if((c[a+52>>2]|0)!=0?((Eb[c[(c[d>>2]|0)+52>>2]&127](d)|0)&1|0)==0:0){e=Zb[c[(c[d>>2]|0)+24>>2]&31](d,c[a+52>>2]|0)|0;if(!e){c[b+40>>2]=Zb[c[(c[d>>2]|0)+28>>2]&31](d,c[a+52>>2]|0)|0;c[b+44>>2]=0;e=c[a+52>>2]|0;e=Eb[c[(c[e>>2]|0)+12>>2]&127](e)|0;e=Ob[c[(c[d>>2]|0)+16>>2]&63](d,e,1)|0;g=c[a+52>>2]|0;g=Ob[c[(c[g>>2]|0)+16>>2]&63](g,c[e+8>>2]|0,d)|0;yb[c[(c[d>>2]|0)+20>>2]&31](d,e,g,1213612625,c[a+52>>2]|0);break}else{c[b+40>>2]=e;c[b+44>>2]=0;break}}else f=8;while(0);if((f|0)==8){c[b+40>>2]=0;c[b+44>>2]=0}if(c[a+56>>2]|0?((Eb[c[(c[d>>2]|0)+52>>2]&127](d)|0)&2|0)==0:0){e=Zb[c[(c[d>>2]|0)+24>>2]&31](d,c[a+56>>2]|0)|0;if(!e){c[b+48>>2]=Zb[c[(c[d>>2]|0)+28>>2]&31](d,c[a+56>>2]|0)|0;b=c[a+56>>2]|0;b=Eb[c[(c[b>>2]|0)+8>>2]&127](b)|0;b=Ob[c[(c[d>>2]|0)+16>>2]&63](d,b,1)|0;g=c[a+56>>2]|0;g=Ob[c[(c[g>>2]|0)+12>>2]&63](g,c[b+8>>2]|0,d)|0;yb[c[(c[d>>2]|0)+20>>2]&31](d,b,g,1346456916,c[a+56>>2]|0);return 16548}else{c[b+48>>2]=e;return 16548}}c[b+48>>2]=0;return 16548}function Kg(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c[6422]=(c[6422]|0)+1;k=((e<<16|d)+~((e<<16|d)<<15)>>10^(e<<16|d)+~((e<<16|d)<<15))*9|0;k=(k>>6^k)+~((k>>6^k)<<11)>>16^(k>>6^k)+~((k>>6^k)<<11);l=c[b+12>>2]|0;f=c[(c[b+40>>2]|0)+((l+-1&k)<<2)>>2]|0;a:do if((f|0)!=-1){h=c[b+16>>2]|0;while(1){g=h+(f*12|0)|0;if((c[g>>2]|0)==(d|0)?(c[h+(f*12|0)+4>>2]|0)==(e|0):0)break;f=c[(c[b+60>>2]|0)+(f<<2)>>2]|0;if((f|0)==-1)break a}if(g|0){b=g;return b|0}}while(0);j=c[b+8>>2]|0;if((j|0)==(l|0)){h=l|0?l<<1:1;if((l|0)<(h|0)){if(!h){f=0;g=l}else{c[6435]=(c[6435]|0)+1;f=yc((h*12|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}g=c[b+8>>2]|0}if((g|0)>0){i=0;do{m=f+(i*12|0)|0;n=(c[b+16>>2]|0)+(i*12|0)|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];i=i+1|0}while((i|0)!=(g|0))}g=c[b+16>>2]|0;if(g|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=f;c[b+12>>2]=h;f=c[b+8>>2]|0}else{f=l;h=l}}else{f=j;h=l}c[b+8>>2]=f+1;g=c[b+16>>2]|0;if((l|0)<(h|0)){Kf(b);f=(c[b+12>>2]|0)+-1&k}else f=l+-1&k;c[g+(j*12|0)>>2]=d;c[g+(j*12|0)+4>>2]=e;c[g+(j*12|0)+8>>2]=0;n=(c[b+40>>2]|0)+(f<<2)|0;c[(c[b+60>>2]|0)+(j<<2)>>2]=c[n>>2];c[n>>2]=j;n=g+(j*12|0)|0;return n|0}function Lg(a){a=a|0;var b=0,d=0,e=0;c[6435]=(c[6435]|0)+1;b=yc(219)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}ml();c[b>>2]=2896;d=b+52|0;e=b+4|0;c[e>>2]=c[a>>2];c[e+4>>2]=c[a+4>>2];c[e+8>>2]=c[a+8>>2];c[e+12>>2]=c[a+12>>2];e=b+20|0;c[e>>2]=c[a+16>>2];c[e+4>>2]=c[a+16+4>>2];c[e+8>>2]=c[a+16+8>>2];c[e+12>>2]=c[a+16+12>>2];e=b+36|0;c[e>>2]=c[a+32>>2];c[e+4>>2]=c[a+32+4>>2];c[e+8>>2]=c[a+32+8>>2];c[e+12>>2]=c[a+32+12>>2];c[d>>2]=c[a+48>>2];c[d+4>>2]=c[a+48+4>>2];c[d+8>>2]=c[a+48+8>>2];c[d+12>>2]=c[a+48+12>>2];d=b+116|0;e=b+68|0;c[e>>2]=c[5710];c[e+4>>2]=c[5711];c[e+8>>2]=c[5712];c[e+12>>2]=c[5713];e=b+84|0;c[e>>2]=c[5714];c[e+4>>2]=c[5715];c[e+8>>2]=c[5716];c[e+12>>2]=c[5717];e=b+100|0;c[e>>2]=c[5718];c[e+4>>2]=c[5719];c[e+8>>2]=c[5720];c[e+12>>2]=c[5721];c[d>>2]=c[5722];c[d+4>>2]=c[5723];c[d+8>>2]=c[5724];c[d+12>>2]=c[5725];d=b+180|0;e=b+132|0;c[e>>2]=c[a>>2];c[e+4>>2]=c[a+4>>2];c[e+8>>2]=c[a+8>>2];c[e+12>>2]=c[a+12>>2];e=b+148|0;c[e>>2]=c[a+16>>2];c[e+4>>2]=c[a+16+4>>2];c[e+8>>2]=c[a+16+8>>2];c[e+12>>2]=c[a+16+12>>2];e=b+164|0;c[e>>2]=c[a+32>>2];c[e+4>>2]=c[a+32+4>>2];c[e+8>>2]=c[a+32+8>>2];c[e+12>>2]=c[a+32+12>>2];c[d>>2]=c[a+48>>2];c[d+4>>2]=c[a+48+4>>2];c[d+8>>2]=c[a+48+8>>2];c[d+12>>2]=c[a+48+12>>2];c[b+196>>2]=0;return b|0}function Mg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0;k=+g[d+100>>2];h=+g[d+16>>2];e=+g[d+20>>2];f=+g[d+24>>2];j=+g[d+108>>2];j=+g[d+112>>2]-k*+g[d+116>>2]-(h*+g[a+64>>2]+e*+g[a+68>>2]+f*+g[a+72>>2]+(+g[d>>2]*+g[a+80>>2]+ +g[d+4>>2]*+g[a+84>>2]+ +g[d+8>>2]*+g[a+88>>2]))*j-j*(+g[d+48>>2]*+g[b+64>>2]+ +g[d+52>>2]*+g[b+68>>2]+ +g[d+56>>2]*+g[b+72>>2]+(+g[d+32>>2]*+g[b+80>>2]+ +g[d+36>>2]*+g[b+84>>2]+ +g[d+40>>2]*+g[b+88>>2]));l=+g[d+120>>2];i=k+j>2]=k+j>2]|0){l=i*e*+g[a+132>>2]*+g[a+116>>2];k=i*f*+g[a+136>>2]*+g[a+120>>2];g[a+64>>2]=+g[a+112>>2]*i*h*+g[a+128>>2]+ +g[a+64>>2];g[a+68>>2]=l+ +g[a+68>>2];g[a+72>>2]=k+ +g[a+72>>2];k=i*+g[a+100>>2]*+g[d+68>>2];l=i*+g[a+104>>2]*+g[d+72>>2];g[a+80>>2]=i*+g[a+96>>2]*+g[d+64>>2]+ +g[a+80>>2];g[a+84>>2]=k+ +g[a+84>>2];g[a+88>>2]=l+ +g[a+88>>2]}if(!(c[b+240>>2]|0))return;l=i*+g[d+52>>2]*+g[b+132>>2]*+g[b+116>>2];k=i*+g[d+56>>2]*+g[b+136>>2]*+g[b+120>>2];g[b+64>>2]=+g[b+112>>2]*i*+g[d+48>>2]*+g[b+128>>2]+ +g[b+64>>2];g[b+68>>2]=l+ +g[b+68>>2];g[b+72>>2]=k+ +g[b+72>>2];k=i*+g[b+100>>2]*+g[d+84>>2];l=i*+g[b+104>>2]*+g[d+88>>2];g[b+80>>2]=i*+g[b+96>>2]*+g[d+80>>2]+ +g[b+80>>2];g[b+84>>2]=k+ +g[b+84>>2];g[b+88>>2]=l+ +g[b+88>>2];return}function Ng(b,d,e,f,h,i,j,k,l){b=b|0;d=d|0;e=e|0;f=+f;h=+h;i=+i;j=j|0;k=k|0;l=l|0;var m=0,n=0.0,o=0.0,p=0.0;c[6435]=(c[6435]|0)+1;m=yc(143)|0;if(!m)m=0;else{c[(m+4+15&-16)+-4>>2]=m;m=m+4+15&-16}c[m+8>>2]=0;g[m+12>>2]=0.0;c[m>>2]=8060;c[m+4>>2]=24;c[m+64>>2]=b;c[m+68>>2]=d;g[m+72>>2]=h;g[m+76>>2]=i;g[m+80>>2]=+(b+-1|0);g[m+84>>2]=+(d+-1|0);g[m+88>>2]=f;c[m+92>>2]=e;c[m+96>>2]=k;a[m+100>>0]=l&1;a[m+101>>0]=0;a[m+102>>0]=0;c[m+104>>2]=j;c[m+108>>2]=1065353216;c[m+112>>2]=1065353216;c[m+116>>2]=1065353216;g[m+120>>2]=0.0;switch(j|0){case 0:{g[m+16>>2]=h;c[m+20>>2]=0;c[m+24>>2]=0;g[m+28>>2]=0.0;g[m+32>>2]=i;g[m+36>>2]=+(b+-1|0);g[m+40>>2]=+(d+-1|0);g[m+44>>2]=0.0;o=i;p=h;f=+(b+-1|0);n=0.0;i=+(d+-1|0);h=0.0;break}case 1:{c[m+16>>2]=0;g[m+20>>2]=h;c[m+24>>2]=0;g[m+28>>2]=0.0;g[m+32>>2]=+(b+-1|0);g[m+36>>2]=i;g[m+40>>2]=+(d+-1|0);g[m+44>>2]=0.0;o=+(b+-1|0);p=0.0;f=i;n=h;i=+(d+-1|0);h=0.0;break}case 2:{c[m+16>>2]=0;c[m+20>>2]=0;g[m+24>>2]=h;g[m+28>>2]=0.0;g[m+32>>2]=+(b+-1|0);g[m+36>>2]=+(d+-1|0);g[m+40>>2]=i;g[m+44>>2]=0.0;o=+(b+-1|0);p=0.0;f=+(d+-1|0);n=0.0;break}default:{o=+g[m+32>>2];p=+g[m+16>>2];f=+g[m+36>>2];n=+g[m+20>>2];i=+g[m+40>>2];h=+g[m+24>>2]}}g[m+48>>2]=(p+o)*.5;g[m+52>>2]=(n+f)*.5;g[m+56>>2]=(h+i)*.5;g[m+60>>2]=0.0;return m|0}function Og(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0;if(a[b+1308>>0]|0){c[d>>2]=0;c[d+4>>2]=0;return}sd(b,(c[b+28>>2]|0)+4|0,(c[b+32>>2]|0)+4|0);c[d>>2]=0;c[d+4>>2]=6;if((c[b+856>>2]|0)==0?(a[b+788>>0]|0)==0:0){e=0;f=6}else{c[d>>2]=1;c[d+4>>2]=5;e=1;f=5}if(!((c[b+860>>2]|0)==0?(a[b+789>>0]|0)==0:0)){e=e+1|0;c[d>>2]=e;f=f+-1|0;c[d+4>>2]=f}if((c[b+864>>2]|0)==0?(a[b+790>>0]|0)==0:0)l=0;else{e=e+1|0;c[d>>2]=e;f=f+-1|0;c[d+4>>2]=f;l=0}do{i=+g[b+868+(l<<6)>>2];j=+g[b+868+(l<<6)+4>>2];k=+ik(+g[b+1192+(l<<2)>>2],i,j);g[b+868+(l<<6)+52>>2]=k;do if(!(i>j)){if(i>k){c[b+868+(l<<6)+56>>2]=1;h=b+868+(l<<6)+48|0;g[h>>2]=k-i;if(k-i>3.1415927410125732){g[h>>2]=k-i+-6.2831854820251465;h=21;break}if(!(k-i<-3.1415927410125732)){h=21;break}g[h>>2]=k-i+6.2831854820251465;h=21;break}h=b+868+(l<<6)+56|0;if(!(j>2]=0;h=20;break}c[h>>2]=2;h=b+868+(l<<6)+48|0;g[h>>2]=k-j;if(k-j>3.1415927410125732){g[h>>2]=k-j+-6.2831854820251465;h=21;break}if(k-j<-3.1415927410125732){g[h>>2]=k-j+6.2831854820251465;h=21}else h=21}else{c[b+868+(l<<6)+56>>2]=0;h=20}while(0);if((h|0)==20){h=0;if(a[b+868+(l<<6)+44>>0]|0)h=21}if((h|0)==21){e=e+1|0;c[d>>2]=e;f=f+-1|0;c[d+4>>2]=f}l=l+1|0}while((l|0)!=3);return}function Pg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0;l=i;i=i+96|0;g=c[b+8>>2]|0;if((g|0)==(c[b+12>>2]|0)?(k=g|0?g<<1:1,(g|0)<(k|0)):0){if(!k)j=0;else{c[6435]=(c[6435]|0)+1;g=yc((k<<2|3)+16|0)|0;if(!g)g=0;else{c[(g+4+15&-16)+-4>>2]=g;g=g+4+15&-16}j=g;g=c[b+8>>2]|0}if((g|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[b+16>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(g|0))}h=c[b+16>>2]|0;if(h){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);g=c[b+8>>2]|0}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=j;c[b+12>>2]=k}c[(c[b+16>>2]|0)+(g<<2)>>2]=d;c[b+8>>2]=g+1;c[l+32>>2]=c[d+4>>2];c[l+32+4>>2]=c[d+4+4>>2];c[l+32+8>>2]=c[d+4+8>>2];c[l+32+12>>2]=c[d+4+12>>2];c[l+32+16>>2]=c[d+20>>2];c[l+32+16+4>>2]=c[d+20+4>>2];c[l+32+16+8>>2]=c[d+20+8>>2];c[l+32+16+12>>2]=c[d+20+12>>2];c[l+32+32>>2]=c[d+36>>2];c[l+32+32+4>>2]=c[d+36+4>>2];c[l+32+32+8>>2]=c[d+36+8>>2];c[l+32+32+12>>2]=c[d+36+12>>2];c[l+32+48>>2]=c[d+52>>2];c[l+32+48+4>>2]=c[d+52+4>>2];c[l+32+48+8>>2]=c[d+52+8>>2];c[l+32+48+12>>2]=c[d+52+12>>2];k=c[d+192>>2]|0;mc[c[(c[k>>2]|0)+8>>2]&127](k,l+32|0,l+16|0,l);k=c[b+68>>2]|0;c[d+188>>2]=gc[c[(c[k>>2]|0)+8>>2]&3](k,l+16|0,l,c[(c[d+192>>2]|0)+4>>2]|0,d,e,f,c[b+24>>2]|0,0)|0;i=l;return}function Qg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0.0,x=0,y=0;x=i;i=i+16|0;f=c[a+52>>2]|0;w=+g[a+28+(((f+2|0)%3|0)<<2)>>2];if((e|0)<=0){i=x;return}h=0;while(1){c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;c[x+12>>2]=0;c[x+(f<<2)>>2]=c[a+28+(f<<2)>>2];f=b+(h<<4)|0;u=b+(h<<4)+4|0;v=b+(h<<4)+8|0;j=w*+g[f>>2]+ +g[x>>2];k=w*+g[u>>2]+ +g[x+4>>2];l=w*+g[v>>2]+ +g[x+8>>2];m=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);n=+g[f>>2];o=+g[u>>2];p=+g[v>>2];if(n*(j-m*n)+o*(k-m*o)+p*(l-m*p)>-999999984306749440.0){g[d+(h<<4)>>2]=j-m*n;g[d+(h<<4)+4>>2]=k-m*o;g[d+(h<<4)+8>>2]=l-m*p;g[d+(h<<4)+12>>2]=0.0;q=+g[f>>2];s=+g[u>>2];t=+g[v>>2];r=n*(j-m*n)+o*(k-m*o)+p*(l-m*p)}else{q=n;s=o;t=p;r=-999999984306749440.0}c[x>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;c[x+12>>2]=0;y=c[a+52>>2]|0;g[x+(y<<2)>>2]=-+g[a+28+(y<<2)>>2];p=w*q+ +g[x>>2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+g[d+40>>2];g[a+32>>2]=q;g[a+36>>2]=o;g[a+40>>2]=m;g[a+44>>2]=0.0;u=+g[i>>2]*u;t=+g[i+4>>2]*t;s=+g[i+8>>2]*s;g[a+48>>2]=u;g[a+52>>2]=t;g[a+56>>2]=s;g[a+60>>2]=0.0;r=+g[k>>2]*q;p=+g[k+4>>2]*o;n=+g[k+8>>2]*m;g[a+64>>2]=r;g[a+68>>2]=p;g[a+72>>2]=n;g[a+76>>2]=0.0;g[a+80>>2]=u*+g[a+16>>2]+t*+g[a+20>>2]+s*+g[a+24>>2]+j+l+(r*q+p*o+n*m);return}function Sg(b){b=b|0;var d=0,e=0,f=0;c[b>>2]=4144;if(a[b+272>>0]|0?(d=c[b+204>>2]|0,Ab[c[c[d>>2]>>2]&255](d),d=c[b+204>>2]|0,d|0):0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+196>>2]|0;if(d|0?(Ab[c[c[d>>2]>>2]&255](d),e=c[b+196>>2]|0,e|0):0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}if(a[b+273>>0]|0?(f=c[b+200>>2]|0,Ab[c[c[f>>2]>>2]&255](f),f=c[b+200>>2]|0,f|0):0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}d=c[b+316>>2]|0;if(d|0){if(a[b+320>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+316>>2]=0}a[b+320>>0]=1;c[b+316>>2]=0;c[b+308>>2]=0;c[b+312>>2]=0;d=c[b+288>>2]|0;if(d|0){if(a[b+292>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+288>>2]=0}a[b+292>>0]=1;c[b+288>>2]=0;c[b+280>>2]=0;c[b+284>>2]=0;d=c[b+240>>2]|0;if(d|0){if(a[b+244>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+240>>2]=0}a[b+244>>0]=1;c[b+240>>2]=0;c[b+232>>2]=0;c[b+236>>2]=0;d=c[b+220>>2]|0;if(d|0){if(a[b+224>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+220>>2]=0}a[b+224>>0]=1;c[b+220>>2]=0;c[b+212>>2]=0;c[b+216>>2]=0;d=c[b+188>>2]|0;if(!d){a[b+192>>0]=1;c[b+188>>2]=0;c[b+180>>2]=0;f=b+184|0;c[f>>2]=0;_j(b);return}if(a[b+192>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+188>>2]=0;a[b+192>>0]=1;c[b+188>>2]=0;c[b+180>>2]=0;f=b+184|0;c[f>>2]=0;_j(b);return}function Tg(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0;h=i;i=i+64|0;a[d+84>>0]=0;c[h>>2]=c[b+4>>2];c[h+4>>2]=c[b+4+4>>2];c[h+8>>2]=c[b+4+8>>2];c[h+12>>2]=c[b+4+12>>2];c[h+16>>2]=c[b+20>>2];c[h+16+4>>2]=c[b+20+4>>2];c[h+16+8>>2]=c[b+20+8>>2];c[h+16+12>>2]=c[b+20+12>>2];c[h+32>>2]=c[b+36>>2];c[h+32+4>>2]=c[b+36+4>>2];c[h+32+8>>2]=c[b+36+8>>2];c[h+32+12>>2]=c[b+36+12>>2];c[h+48>>2]=c[b+52>>2];c[h+48+4>>2]=c[b+52+4>>2];c[h+48+8>>2]=c[b+52+8>>2];c[h+48+12>>2]=c[b+52+12>>2];if(e?(f=c[b+480>>2]|0,f|0):0)Cb[c[(c[f>>2]|0)+8>>2]&127](f,h);w=+g[d+156>>2];u=+g[h>>2];v=+g[d+160>>2];t=+g[h+4>>2];o=+g[d+164>>2];s=+g[h+8>>2];r=+g[h+16>>2];q=+g[h+20>>2];p=+g[h+24>>2];n=+g[h+32>>2];l=+g[h+36>>2];j=+g[h+40>>2];m=w*r+v*q+o*p+ +g[h+52>>2];k=w*n+v*l+o*j+ +g[h+56>>2];g[d+36>>2]=w*u+v*t+o*s+ +g[h+48>>2];g[d+40>>2]=m;g[d+44>>2]=k;g[d+48>>2]=0.0;k=+g[d+172>>2];m=+g[d+176>>2];o=+g[d+180>>2];g[d+52>>2]=u*k+t*m+s*o;g[d+56>>2]=k*r+m*q+o*p;g[d+60>>2]=k*n+m*l+o*j;g[d+64>>2]=0.0;o=+g[d+188>>2];m=+g[d+192>>2];k=+g[d+196>>2];g[d+68>>2]=u*o+t*m+s*k;g[d+72>>2]=o*r+m*q+k*p;g[d+76>>2]=o*n+m*l+k*j;g[d+80>>2]=0.0;i=h;return}function Ug(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{e=(c[d>>2]|0)+(4-1)&~(4-1);b=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=b;break a}case 10:{b=(c[d>>2]|0)+(4-1)&~(4-1);e=c[b>>2]|0;c[d>>2]=b+4;c[a>>2]=e;c[a+4>>2]=((e|0)<0)<<31>>31;break a}case 11:{b=(c[d>>2]|0)+(4-1)&~(4-1);e=c[b>>2]|0;c[d>>2]=b+4;c[a>>2]=e;c[a+4>>2]=0;break a}case 12:{f=(c[d>>2]|0)+(8-1)&~(8-1);b=c[f>>2]|0;e=c[f+4>>2]|0;c[d>>2]=f+8;c[a>>2]=b;c[a+4>>2]=e;break a}case 13:{e=(c[d>>2]|0)+(4-1)&~(4-1);f=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=(f&65535)<<16>>16;c[a+4>>2]=(((f&65535)<<16>>16|0)<0)<<31>>31;break a}case 14:{e=(c[d>>2]|0)+(4-1)&~(4-1);f=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=f&65535;c[a+4>>2]=0;break a}case 15:{e=(c[d>>2]|0)+(4-1)&~(4-1);f=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=(f&255)<<24>>24;c[a+4>>2]=(((f&255)<<24>>24|0)<0)<<31>>31;break a}case 16:{e=(c[d>>2]|0)+(4-1)&~(4-1);f=c[e>>2]|0;c[d>>2]=e+4;c[a>>2]=f&255;c[a+4>>2]=0;break a}case 17:{f=(c[d>>2]|0)+(8-1)&~(8-1);g=+h[f>>3];c[d>>2]=f+8;h[a>>3]=g;break a}case 18:{f=(c[d>>2]|0)+(8-1)&~(8-1);g=+h[f>>3];c[d>>2]=f+8;h[a>>3]=g;break a}default:break a}while(0);while(0);return}function Vg(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0.0,y=0;w=i;i=i+2048|0;if((e|0)>0)f=0;else{i=w;return}do{g[d+(f<<4)+12>>2]=-999999984306749440.0;f=f+1|0}while((f|0)!=(e|0));t=0;do{if((Eb[c[(c[a>>2]|0)+96>>2]&127](a)|0)>0){r=b+(t<<4)|0;s=b+(t<<4)+4|0;o=b+(t<<4)+8|0;p=d+(t<<4)+12|0;q=d+(t<<4)|0;u=0;do{if(((Eb[c[(c[a>>2]|0)+96>>2]&127](a)|0)-u|0)<128){f=(Eb[c[(c[a>>2]|0)+96>>2]&127](a)|0)-u|0;if((f|0)>0)v=10;else{j=-3402823466385288598117041.0e14;f=-1}}else{f=128;v=10}if((v|0)==10){v=0;h=0;do{ic[c[(c[a>>2]|0)+108>>2]&127](a,h,w+(h<<4)|0);h=h+1|0}while((h|0)!=(f|0));k=+g[r>>2];l=+g[s>>2];m=+g[o>>2];n=0;j=-3402823466385288598117041.0e14;h=-1;do{x=k*+g[w+(n<<4)>>2]+l*+g[w+(n<<4)+4>>2]+m*+g[w+(n<<4)+8>>2];y=x>j;h=y?n:h;j=y?x:j;n=n+1|0}while((n|0)!=(f|0));f=h}if(j>+g[p>>2]){y=w+(f<<4)|0;c[q>>2]=c[y>>2];c[q+4>>2]=c[y+4>>2];c[q+8>>2]=c[y+8>>2];c[q+12>>2]=c[y+12>>2];g[p>>2]=j}u=u+128|0}while((u|0)<(Eb[c[(c[a>>2]|0)+96>>2]&127](a)|0))}t=t+1|0}while((t|0)!=(e|0));i=w;return}function Wg(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0,j=0,l=0,m=0,n=0.0;h=i;i=i+16|0;d=+g[a>>2];e=+g[a+20>>2];f=+g[a+40>>2];if(d+e+f>0.0){f=+O(+(d+e+f+1.0));g[h+12>>2]=f*.5;n=(+g[a+36>>2]-+g[a+24>>2])*(.5/f);g[h>>2]=n;d=(+g[a+8>>2]-+g[a+32>>2])*(.5/f);g[h+4>>2]=d;e=(+g[a+16>>2]-+g[a+4>>2])*(.5/f);g[h+8>>2]=e;a=(g[k>>2]=n,c[k>>2]|0);m=(g[k>>2]=d,c[k>>2]|0);l=(g[k>>2]=e,c[k>>2]|0);j=(g[k>>2]=f*.5,c[k>>2]|0);c[b>>2]=a;a=b+4|0;c[a>>2]=m;a=b+8|0;c[a>>2]=l;a=b+12|0;c[a>>2]=j;i=h;return}else{m=d>2]-+g[a+((((m+1|0)>>>0)%3|0)<<4)+((((m+1|0)>>>0)%3|0)<<2)>>2]-+g[a+((((m+2|0)>>>0)%3|0)<<4)+((((m+2|0)>>>0)%3|0)<<2)>>2]+1.0));g[h+(m<<2)>>2]=n*.5;g[h+12>>2]=(+g[a+((((m+2|0)>>>0)%3|0)<<4)+((((m+1|0)>>>0)%3|0)<<2)>>2]-+g[a+((((m+1|0)>>>0)%3|0)<<4)+((((m+2|0)>>>0)%3|0)<<2)>>2])*(.5/n);g[h+((((m+1|0)>>>0)%3|0)<<2)>>2]=(+g[a+((((m+1|0)>>>0)%3|0)<<4)+(m<<2)>>2]+ +g[a+(m<<4)+((((m+1|0)>>>0)%3|0)<<2)>>2])*(.5/n);g[h+((((m+2|0)>>>0)%3|0)<<2)>>2]=(+g[a+((((m+2|0)>>>0)%3|0)<<4)+(m<<2)>>2]+ +g[a+(m<<4)+((((m+2|0)>>>0)%3|0)<<2)>>2])*(.5/n);m=c[h>>2]|0;a=c[h+4>>2]|0;j=c[h+8>>2]|0;l=c[h+12>>2]|0;c[b>>2]=m;m=b+4|0;c[m>>2]=a;m=b+8|0;c[m>>2]=j;m=b+12|0;c[m>>2]=l;i=h;return}}function Xg(a,b){a=a|0;b=b|0;var d=0,e=0;d=i;i=i+48|0;e=(c[a+48>>2]|0)+4|0;c[e>>2]=c[b>>2];c[e+4>>2]=c[b+4>>2];c[e+8>>2]=c[b+8>>2];c[e+12>>2]=c[b+12>>2];c[d+32>>2]=0;c[d+32+4>>2]=0;c[d+32+8>>2]=0;c[d+32+12>>2]=0;g[d+32>>2]=1.0;ic[c[(c[a>>2]|0)+68>>2]&127](d+16|0,a,d+32|0);g[a+32>>2]=+g[d+16>>2]+ +g[a+12>>2];g[d+32>>2]=-1.0;ic[c[(c[a>>2]|0)+68>>2]&127](d,a,d+32|0);c[d+16>>2]=c[d>>2];c[d+16+4>>2]=c[d+4>>2];c[d+16+8>>2]=c[d+8>>2];c[d+16+12>>2]=c[d+12>>2];g[a+16>>2]=+g[d+16>>2]-+g[a+12>>2];c[d+32>>2]=0;c[d+32+4>>2]=0;c[d+32+8>>2]=0;c[d+32+12>>2]=0;g[d+32+4>>2]=1.0;ic[c[(c[a>>2]|0)+68>>2]&127](d+16|0,a,d+32|0);g[a+36>>2]=+g[d+16+4>>2]+ +g[a+12>>2];g[d+32+4>>2]=-1.0;ic[c[(c[a>>2]|0)+68>>2]&127](d,a,d+32|0);c[d+16>>2]=c[d>>2];c[d+16+4>>2]=c[d+4>>2];c[d+16+8>>2]=c[d+8>>2];c[d+16+12>>2]=c[d+12>>2];g[a+20>>2]=+g[d+16+4>>2]-+g[a+12>>2];c[d+32>>2]=0;c[d+32+4>>2]=0;c[d+32+8>>2]=0;c[d+32+12>>2]=0;g[d+32+8>>2]=1.0;ic[c[(c[a>>2]|0)+68>>2]&127](d+16|0,a,d+32|0);g[a+40>>2]=+g[d+16+8>>2]+ +g[a+12>>2];g[d+32+8>>2]=-1.0;ic[c[(c[a>>2]|0)+68>>2]&127](d,a,d+32|0);c[d+16>>2]=c[d>>2];c[d+16+4>>2]=c[d+4>>2];c[d+16+8>>2]=c[d+8>>2];c[d+16+12>>2]=c[d+12>>2];g[a+24>>2]=+g[d+16+8>>2]-+g[a+12>>2];i=d;return}function Yg(a,b,d,e,f,h,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0;r=i;i=i+16|0;g[e>>2]=3402823466385288598117041.0e14;g[f>>2]=-3402823466385288598117041.0e14;n=c[a+96>>2]|0;if((n|0)>0){q=0;do{t=c[a+104>>2]|0;s=+g[t+(q<<4)>>2]*+g[a+12>>2];p=+g[t+(q<<4)+4>>2]*+g[a+16>>2];o=+g[t+(q<<4)+8>>2]*+g[a+20>>2];l=s*+g[b>>2]+p*+g[b+4>>2]+o*+g[b+8>>2]+ +g[b+48>>2];m=s*+g[b+16>>2]+p*+g[b+20>>2]+o*+g[b+24>>2]+ +g[b+52>>2];o=s*+g[b+32>>2]+p*+g[b+36>>2]+o*+g[b+40>>2]+ +g[b+56>>2];p=l*+g[d>>2]+m*+g[d+4>>2]+o*+g[d+8>>2];if(p<+g[e>>2]){g[e>>2]=p;g[h>>2]=l;g[h+4>>2]=m;g[h+8>>2]=o;g[h+12>>2]=0.0}if(p>+g[f>>2]){g[f>>2]=p;g[j>>2]=l;g[j+4>>2]=m;g[j+8>>2]=o;g[j+12>>2]=0.0}q=q+1|0}while((q|0)!=(n|0));s=+g[f>>2];m=s;n=(g[k>>2]=s,c[k>>2]|0)}else{m=-3402823466385288598117041.0e14;n=-8388609}l=+g[e>>2];if(!(l>m)){i=r;return}c[e>>2]=n;g[f>>2]=l;c[r>>2]=c[h>>2];c[r+4>>2]=c[h+4>>2];c[r+8>>2]=c[h+8>>2];c[r+12>>2]=c[h+12>>2];c[h>>2]=c[j>>2];c[h+4>>2]=c[j+4>>2];c[h+8>>2]=c[j+8>>2];c[h+12>>2]=c[j+12>>2];c[j>>2]=c[r>>2];c[j+4>>2]=c[r+4>>2];c[j+8>>2]=c[r+8>>2];c[j+12>>2]=c[r+12>>2];i=r;return}function Zg(a,b,c,d,e,f,h){a=a|0;b=+b;c=+c;d=+d;e=e|0;f=+f;h=h|0;var j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;l=i;i=i+16|0;k=c*f+ +g[a+52>>2];j=d*f+ +g[a+56>>2];g[h+48>>2]=b*f+ +g[a+48>>2];g[h+52>>2]=k;g[h+56>>2]=j;g[h+60>>2]=0.0;j=+g[e>>2];k=+g[e+4>>2];c=+g[e+8>>2];d=+O(+(j*j+k*k+c*c));d=d*f>.7853981852531433?.7853981852531433/f:d;if(d<1.0000000474974513e-03)b=f*.5-d*f*f*f*.02083333395421505*d;else b=+R(+(d*.5*f))/d;o=j*b;n=k*b;j=c*b;q=+Q(+(d*f*.5));Wg(a,l);b=+g[l>>2];p=+g[l+12>>2];c=+g[l+8>>2];f=+g[l+4>>2];r=1.0/+O(+((q*p-o*b-n*f-j*c)*(q*p-o*b-n*f-j*c)+((j*p+q*c+o*f-n*b)*(j*p+q*c+o*f-n*b)+((q*b+o*p+n*c-j*f)*(q*b+o*p+n*c-j*f)+(j*b+(n*p+q*f)-o*c)*(j*b+(n*p+q*f)-o*c)))));d=(q*b+o*p+n*c-j*f)*r;k=r*(j*b+(n*p+q*f)-o*c);m=r*(j*p+q*c+o*f-n*b);c=r*(q*p-o*b-n*f-j*c);j=d*(2.0/(c*c+(m*m+(d*d+k*k))));f=k*(2.0/(c*c+(m*m+(d*d+k*k))));b=m*(2.0/(c*c+(m*m+(d*d+k*k))));g[h>>2]=1.0-(k*f+m*b);g[h+4>>2]=d*f-c*b;g[h+8>>2]=d*b+c*f;g[h+12>>2]=0.0;g[h+16>>2]=d*f+c*b;g[h+20>>2]=1.0-(d*j+m*b);g[h+24>>2]=k*b-c*j;g[h+28>>2]=0.0;g[h+32>>2]=d*b-c*f;g[h+36>>2]=k*b+c*j;g[h+40>>2]=1.0-(d*j+k*f);g[h+44>>2]=0.0;i=l;return}function _g(b,d,e){b=b|0;d=+d;e=e|0;var f=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0;f=c[b+8>>2]|0;if(f|0?(c[f+204>>2]&3|0)==0:0){if((c[f+216>>2]&-2|0)!=4)c[f+216>>2]=1;g[f+220>>2]=0.0}f=c[b+12>>2]|0;if(f|0?(c[f+204>>2]&3|0)==0:0){if((c[f+216>>2]&-2|0)!=4)c[f+216>>2]=1;g[f+220>>2]=0.0}f=c[b+20>>2]|0;if(f|0?(c[f+204>>2]&3|0)==0:0){if((c[f+216>>2]&-2|0)!=4)c[f+216>>2]=1;g[f+220>>2]=0.0}f=c[b+24>>2]|0;if(f|0?(c[f+204>>2]&3|0)==0:0){if((c[f+216>>2]&-2|0)!=4)c[f+216>>2]=1;g[f+220>>2]=0.0}f=c[b+156>>2]|0;c[b+156>>2]=f+1;a[b+152>>0]=(f|0)>=(c[b+160>>2]|0)&1;if(f|0){c[b+72>>2]=0;c[b+72+4>>2]=0;c[b+72+8>>2]=0;c[b+72+12>>2]=0;c[b+72+16>>2]=0;c[b+72+20>>2]=0;c[b+72+24>>2]=0;c[b+72+28>>2]=0;return}j=+g[b+64>>2];i=1.0/d*+g[b+72>>2]*j;h=1.0/d*j*+g[b+76>>2];d=1.0/d*j*+g[b+80>>2];g[b+72>>2]=i;g[b+76>>2]=h;g[b+80>>2]=d;g[b+84>>2]=0.0;j=+g[b+68>>2];if(j>0.0){l=j*i*+g[b+120>>2]+j*h*+g[b+124>>2]+j*d*+g[b+128>>2];k=j*i*+g[b+136>>2]+j*h*+g[b+140>>2]+j*d*+g[b+144>>2];g[b+88>>2]=j*i*+g[b+104>>2]+j*h*+g[b+108>>2]+j*d*+g[b+112>>2];g[b+92>>2]=l;g[b+96>>2]=k;g[b+100>>2]=0.0;g[b+72>>2]=(1.0-j)*i;g[b+76>>2]=(1.0-j)*h;g[b+80>>2]=(1.0-j)*d;i=(1.0-j)*i;h=(1.0-j)*h;d=(1.0-j)*d}g[b+72>>2]=1.0/+(e|0)*i;g[b+76>>2]=1.0/+(e|0)*h;g[b+80>>2]=1.0/+(e|0)*d;return}function $g(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;while(1){k=c[a+12>>2]|0;l=c[k+(((b+d|0)/2|0)<<2)>>2]|0;e=b;f=d;while(1){j=c[(c[l+740>>2]|0)+208>>2]|0;if((j|0)>-1)while(1){h=c[k+(e<<2)>>2]|0;g=c[(c[h+740>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+744>>2]|0)+208>>2]|0;if((g|0)<(j|0))e=e+1|0;else break}else{i=c[(c[l+744>>2]|0)+208>>2]|0;while(1){h=c[k+(e<<2)>>2]|0;g=c[(c[h+740>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+744>>2]|0)+208>>2]|0;if((g|0)<(i|0))e=e+1|0;else break}}if((j|0)>-1)while(1){h=c[k+(f<<2)>>2]|0;g=c[(c[h+740>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+744>>2]|0)+208>>2]|0;if((j|0)<(g|0))f=f+-1|0;else break}else{i=c[(c[l+744>>2]|0)+208>>2]|0;while(1){h=c[k+(f<<2)>>2]|0;g=c[(c[h+740>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+744>>2]|0)+208>>2]|0;if((i|0)<(g|0))f=f+-1|0;else break}}if((e|0)<=(f|0)){i=k+(e<<2)|0;j=c[i>>2]|0;c[i>>2]=c[k+(f<<2)>>2];c[(c[a+12>>2]|0)+(f<<2)>>2]=j;e=e+1|0;f=f+-1|0}if((e|0)>(f|0))break;k=c[a+12>>2]|0}if((f|0)>(b|0))$g(a,b,f);if((e|0)<(d|0))b=e;else break}return}function ah(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0;k=i;i=i+64|0;n=+g[d>>2];o=+g[d+4>>2];m=+g[d+8>>2];p=n*+g[b+4>>2]+o*+g[b+20>>2]+m*+g[b+36>>2];q=n*+g[b+8>>2]+o*+g[b+24>>2]+m*+g[b+40>>2];g[k+48>>2]=+g[b>>2]*n+ +g[b+16>>2]*o+ +g[b+32>>2]*m;g[k+48+4>>2]=p;g[k+48+8>>2]=q;g[k+48+12>>2]=0.0;ic[c[(c[a>>2]|0)+64>>2]&127](k+32|0,a,k+48|0);q=+g[k+32>>2];p=+g[k+32+4>>2];m=+g[k+32+8>>2];o=q*+g[b>>2]+p*+g[b+4>>2]+m*+g[b+8>>2]+ +g[b+48>>2];n=q*+g[b+16>>2]+p*+g[b+20>>2]+m*+g[b+24>>2]+ +g[b+52>>2];m=q*+g[b+32>>2]+p*+g[b+36>>2]+m*+g[b+40>>2]+ +g[b+56>>2];r=c[(c[a>>2]|0)+64>>2]|0;p=-+g[k+48+4>>2];q=-+g[k+48+8>>2];g[k>>2]=-+g[k+48>>2];g[k+4>>2]=p;g[k+8>>2]=q;g[k+12>>2]=0.0;ic[r&127](k+16|0,a,k);q=+g[k+16>>2];p=+g[k+16+4>>2];h=+g[k+16+8>>2];l=q*+g[b>>2]+p*+g[b+4>>2]+h*+g[b+8>>2]+ +g[b+48>>2];j=q*+g[b+16>>2]+p*+g[b+20>>2]+h*+g[b+24>>2]+ +g[b+52>>2];h=q*+g[b+32>>2]+p*+g[b+36>>2]+h*+g[b+40>>2]+ +g[b+56>>2];g[e>>2]=o*+g[d>>2]+n*+g[d+4>>2]+m*+g[d+8>>2];h=l*+g[d>>2]+j*+g[d+4>>2]+h*+g[d+8>>2];g[f>>2]=h;j=+g[e>>2];if(!(j>h)){i=k;return}g[e>>2]=h;g[f>>2]=j;i=k;return}function bh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;while(1){k=c[a+12>>2]|0;l=c[k+(((b+d|0)/2|0)<<2)>>2]|0;e=b;f=d;while(1){j=c[(c[l+28>>2]|0)+208>>2]|0;if((j|0)>-1)while(1){h=c[k+(e<<2)>>2]|0;g=c[(c[h+28>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+32>>2]|0)+208>>2]|0;if((g|0)<(j|0))e=e+1|0;else break}else{i=c[(c[l+32>>2]|0)+208>>2]|0;while(1){h=c[k+(e<<2)>>2]|0;g=c[(c[h+28>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+32>>2]|0)+208>>2]|0;if((g|0)<(i|0))e=e+1|0;else break}}if((j|0)>-1)while(1){h=c[k+(f<<2)>>2]|0;g=c[(c[h+28>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+32>>2]|0)+208>>2]|0;if((j|0)<(g|0))f=f+-1|0;else break}else{i=c[(c[l+32>>2]|0)+208>>2]|0;while(1){h=c[k+(f<<2)>>2]|0;g=c[(c[h+28>>2]|0)+208>>2]|0;if((g|0)<=-1)g=c[(c[h+32>>2]|0)+208>>2]|0;if((i|0)<(g|0))f=f+-1|0;else break}}if((e|0)<=(f|0)){i=k+(e<<2)|0;j=c[i>>2]|0;c[i>>2]=c[k+(f<<2)>>2];c[(c[a+12>>2]|0)+(f<<2)>>2]=j;e=e+1|0;f=f+-1|0}if((e|0)>(f|0))break;k=c[a+12>>2]|0}if((f|0)>(b|0))bh(a,b,f);if((e|0)<(d|0))b=e;else break}return}function ch(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;m=i;i=i+16|0;h=c[a+12>>2]|0;j=c[h+(((d+b|0)/2|0)<<4)>>2]|0;k=c[h+(((d+b|0)/2|0)<<4)+4>>2]|0;l=c[h+(((d+b|0)/2|0)<<4)+8>>2]|0;e=b;f=d;while(1){g=e;while(1){e=c[h+(g<<4)+4>>2]|0;if((e|0)>=(k|0)){if((e|0)!=(k|0))break;e=c[h+(g<<4)>>2]|0;if((e|0)>=(j|0)){if((e|0)!=(j|0))break;if((c[h+(g<<4)+8>>2]|0)>=(l|0))break}}g=g+1|0}while(1){e=c[h+(f<<4)+4>>2]|0;if((k|0)>=(e|0)){if((k|0)!=(e|0))break;e=c[h+(f<<4)>>2]|0;if((j|0)>=(e|0)){if((j|0)!=(e|0))break;if((l|0)>=(c[h+(f<<4)+8>>2]|0))break}}f=f+-1|0}if((g|0)>(f|0))e=g;else{e=h+(g<<4)|0;c[m>>2]=c[e>>2];c[m+4>>2]=c[e+4>>2];c[m+8>>2]=c[e+8>>2];c[m+12>>2]=c[e+12>>2];h=h+(f<<4)|0;c[e>>2]=c[h>>2];c[e+4>>2]=c[h+4>>2];c[e+8>>2]=c[h+8>>2];c[e+12>>2]=c[h+12>>2];e=(c[a+12>>2]|0)+(f<<4)|0;c[e>>2]=c[m>>2];c[e+4>>2]=c[m+4>>2];c[e+8>>2]=c[m+8>>2];c[e+12>>2]=c[m+12>>2];e=g+1|0;f=f+-1|0}if((e|0)>(f|0))break;h=c[a+12>>2]|0}if((f|0)>(b|0))ch(a,b,f);if((e|0)>=(d|0)){i=m;return}ch(a,e,d);i=m;return}function dh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0;e=i;i=i+48|0;y=+g[d>>2];n=+g[b>>2];x=+g[d+16>>2];l=+g[b+4>>2];w=+g[d+32>>2];j=+g[b+8>>2];v=+g[d+4>>2];u=+g[d+20>>2];t=+g[d+36>>2];k=+g[d+8>>2];m=+g[d+24>>2];o=+g[d+40>>2];q=+g[b+16>>2];p=+g[b+20>>2];h=+g[b+24>>2];s=+g[b+32>>2];r=+g[b+36>>2];f=+g[b+40>>2];g[e>>2]=y*n+x*l+w*j;g[e+4>>2]=v*n+u*l+t*j;g[e+8>>2]=k*n+m*l+o*j;g[e+12>>2]=0.0;g[e+16>>2]=y*q+x*p+w*h;g[e+20>>2]=v*q+u*p+t*h;g[e+24>>2]=k*q+m*p+o*h;g[e+28>>2]=0.0;g[e+32>>2]=y*s+x*r+w*f;g[e+36>>2]=v*s+u*r+t*f;g[e+40>>2]=k*s+m*r+o*f;g[e+44>>2]=0.0;o=+g[d+48>>2];m=+g[d+52>>2];k=+g[d+56>>2];f=o*s+m*r+k*f+ +g[b+56>>2];h=o*q+m*p+k*h+ +g[b+52>>2];j=o*n+m*l+k*j+ +g[b+48>>2];c[a>>2]=c[e>>2];c[a+4>>2]=c[e+4>>2];c[a+8>>2]=c[e+8>>2];c[a+12>>2]=c[e+12>>2];c[a+16>>2]=c[e+16>>2];c[a+16+4>>2]=c[e+16+4>>2];c[a+16+8>>2]=c[e+16+8>>2];c[a+16+12>>2]=c[e+16+12>>2];c[a+32>>2]=c[e+32>>2];c[a+32+4>>2]=c[e+32+4>>2];c[a+32+8>>2]=c[e+32+8>>2];c[a+32+12>>2]=c[e+32+12>>2];g[a+48>>2]=j;g[a+52>>2]=h;g[a+56>>2]=f;g[a+60>>2]=0.0;i=e;return}function eh(a,b){a=+a;b=+b;var d=0,e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0.0;m=(g[k>>2]=a,c[k>>2]|0);i=(g[k>>2]=b,c[k>>2]|0);a:do if((i<<1|0)!=0?(o=+N(+b),!((g[k>>2]=o,c[k>>2]|0)>>>0>2139095040|(m>>>23&255|0)==255)):0){if(m<<1>>>0<=i<<1>>>0)return +((m<<1|0)==(i<<1|0)?a*0.0:a);if(!(m>>>23&255)){if((m<<9|0)>-1){d=0;e=m<<9;do{d=d+-1|0;e=e<<1}while((e|0)>-1);e=d}else e=0;d=e;f=m<<1-e}else{d=m>>>23&255;f=m&8388607|8388608}if(!(i>>>23&255)){if((i<<9|0)>-1){e=0;h=i<<9;do{e=e+-1|0;h=h<<1}while((h|0)>-1)}else e=0;j=e;l=i<<1-e}else{j=i>>>23&255;l=i&8388607|8388608}h=f-l|0;b:do if((d|0)>(j|0)){i=(h|0)>-1;e=h;while(1){if(i){if((f|0)==(l|0))break}else e=f;f=e<<1;d=d+-1|0;h=f-l|0;if((d|0)>(j|0)){i=(h|0)>-1;e=h}else{e=h;h=(h|0)>-1;break b}}b=a*0.0;break a}else{e=h;h=(h|0)>-1}while(0);if(h){if((f|0)==(l|0)){b=a*0.0;break}}else e=f;if(e>>>0<8388608)do{e=e<<1;d=d+-1|0}while(e>>>0<8388608);if((d|0)>0)d=e+-8388608|d<<23;else d=e>>>(1-d|0);b=(c[k>>2]=d|m&-2147483648,+g[k>>2])}else n=3;while(0);if((n|0)==3)b=a*b/(a*b);return +b}function fh(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0;n=i;i=i+16|0;if((f|0)>-3&(f+3|0)>-1){if((f+3|0)!=0?(c[6435]=(c[6435]|0)+1,h=yc((f+3<<4|3)+16|0)|0,(h|0)!=0):0){c[(h+4+15&-16)+-4>>2]=h;a=h+4+15&-16}else a=0;h=0;do{m=a+(h<<4)|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];h=h+1|0}while((h|0)!=(f+3|0));m=a}else m=0;if((f|0)>-3){h=m;l=0;while(1){if(!l)j=0.0;else{a=l;k=.5;j=0.0;while(1){j=(a&1|0)==0?j:j+k;a=a>>1;if(!a)break;else k=k*.5}}k=j*2.0+-1.0;o=(+(l<<1|0)*3.1415927410125732+3.1415927410125732)/+(f+3|0);p=+O(+(1.0-k*k));j=p*+R(+o);g[h>>2]=p*+Q(+o);g[h+4>>2]=j;g[h+8>>2]=k;g[h+12>>2]=0.0;l=l+1|0;if((l|0)==(f+3|0))break;else h=h+16|0}a=0;do{q=m+(a<<4)|0;h=m+(a<<4)+4|0;l=m+(a<<4)+8|0;o=+g[h>>2]*+g[e+4>>2]+ +g[d+4>>2];p=+g[l>>2]*+g[e+8>>2]+ +g[d+8>>2];g[q>>2]=+g[q>>2]*+g[e>>2]+ +g[d>>2];g[h>>2]=o;g[l>>2]=p;g[m+(a<<4)+12>>2]=0.0;a=a+1|0}while((a|0)<(f+3|0))}a=rc(b,m,f+3|0,1)|0;if(!m){i=n;return a|0}c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0);i=n;return a|0}function gh(a,b,d,e,f,h,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0;r=i;i=i+16|0;g[e>>2]=3402823466385288598117041.0e14;g[f>>2]=-3402823466385288598117041.0e14;n=c[a+8>>2]|0;if((n|0)>0){q=0;do{t=c[a+16>>2]|0;s=+g[t+(q<<4)>>2];p=+g[t+(q<<4)+4>>2];o=+g[t+(q<<4)+8>>2];l=s*+g[b>>2]+p*+g[b+4>>2]+o*+g[b+8>>2]+ +g[b+48>>2];m=s*+g[b+16>>2]+p*+g[b+20>>2]+o*+g[b+24>>2]+ +g[b+52>>2];o=s*+g[b+32>>2]+p*+g[b+36>>2]+o*+g[b+40>>2]+ +g[b+56>>2];p=l*+g[d>>2]+m*+g[d+4>>2]+o*+g[d+8>>2];if(p<+g[e>>2]){g[e>>2]=p;g[h>>2]=l;g[h+4>>2]=m;g[h+8>>2]=o;g[h+12>>2]=0.0}if(p>+g[f>>2]){g[f>>2]=p;g[j>>2]=l;g[j+4>>2]=m;g[j+8>>2]=o;g[j+12>>2]=0.0}q=q+1|0}while((q|0)!=(n|0));s=+g[f>>2];m=s;n=(g[k>>2]=s,c[k>>2]|0)}else{m=-3402823466385288598117041.0e14;n=-8388609}l=+g[e>>2];if(!(l>m)){i=r;return}c[e>>2]=n;g[f>>2]=l;c[r>>2]=c[h>>2];c[r+4>>2]=c[h+4>>2];c[r+8>>2]=c[h+8>>2];c[r+12>>2]=c[h+12>>2];c[h>>2]=c[j>>2];c[h+4>>2]=c[j+4>>2];c[h+8>>2]=c[j+8>>2];c[h+12>>2]=c[j+12>>2];c[j>>2]=c[r>>2];c[j+4>>2]=c[r+4>>2];c[j+8>>2]=c[r+8>>2];c[j+12>>2]=c[r+12>>2];i=r;return}function hh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0,x=0,y=0;if((c[a>>2]|0)==(b|0)){c[a>>2]=0;a=0;return a|0}e=c[b+32>>2]|0;d=c[e+32>>2]|0;b=c[e+36+(((c[e+40>>2]|0)!=(b|0)&1)<<2)>>2]|0;if(!d){c[a>>2]=b;c[b+32>>2]=0;d=c[a+4>>2]|0;if(!d)d=b;else{c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);d=c[a>>2]|0}c[a+4>>2]=e;a=d;return a|0}c[d+36+(((c[d+40>>2]|0)==(e|0)&1)<<2)>>2]=b;c[b+32>>2]=d;b=c[a+4>>2]|0;if(b|0){c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0)}c[a+4>>2]=e;do{s=+g[d>>2];x=d+4|0;q=+g[x>>2];v=d+8|0;o=+g[v>>2];y=d+16|0;m=+g[y>>2];w=d+20|0;i=+g[w>>2];e=d+24|0;k=+g[e>>2];u=c[d+36>>2]|0;b=c[d+40>>2]|0;t=+g[u>>2];r=+g[b>>2];r=t>2]=r;t=+g[u+16>>2];l=+g[b+16>>2];l=t>l?t:l;g[y>>2]=l;t=+g[u+4>>2];p=+g[b+4>>2];p=t>2]=p;t=+g[u+20>>2];h=+g[b+20>>2];h=t>h?t:h;g[w>>2]=h;t=+g[u+8>>2];n=+g[b+8>>2];n=t>2]=n;t=+g[u+24>>2];j=+g[b+24>>2];j=t>j?t:j;g[e>>2]=j;if(!(s!=r|q!=p|o!=n|m!=l)?!(k!=j|i!=h):0){f=14;break}d=c[d+32>>2]|0}while((d|0)!=0);if((f|0)==14)return d|0;y=c[a>>2]|0;return y|0}function ih(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,h=0.0,i=0,j=0;i=c[a+28>>2]|0;e=0.0;f=0.0;h=0.0;j=0;a:while(1){switch(j|0){case 0:{e=+g[a+80>>2]+ +g[a+64>>2];f=+g[a+84>>2]+ +g[a+68>>2];h=+g[a+88>>2]+ +g[a+72>>2];break}case 1:{e=+g[a+80>>2]+ +g[a+64>>2];f=+g[a+84>>2]+ +g[a+68>>2];h=+g[a+72>>2]-+g[a+88>>2];break}case 2:{e=+g[a+80>>2]+ +g[a+64>>2];f=+g[a+68>>2]-+g[a+84>>2];h=+g[a+88>>2]+ +g[a+72>>2];break}case 3:{e=+g[a+80>>2]+ +g[a+64>>2];f=+g[a+68>>2]-+g[a+84>>2];h=+g[a+72>>2]-+g[a+88>>2];break}case 4:{e=+g[a+64>>2]-+g[a+80>>2];f=+g[a+84>>2]+ +g[a+68>>2];h=+g[a+88>>2]+ +g[a+72>>2];break}case 5:{e=+g[a+64>>2]-+g[a+80>>2];f=+g[a+84>>2]+ +g[a+68>>2];h=+g[a+72>>2]-+g[a+88>>2];break}case 6:{e=+g[a+64>>2]-+g[a+80>>2];f=+g[a+68>>2]-+g[a+84>>2];h=+g[a+88>>2]+ +g[a+72>>2];break}case 7:{e=+g[a+64>>2]-+g[a+80>>2];f=+g[a+68>>2]-+g[a+84>>2];h=+g[a+72>>2]-+g[a+88>>2];break}default:{}}if((i|0)>0){b=c[a+36>>2]|0;d=0;do{if(+g[b+(d*36|0)+32>>2]+(e*+g[b+(d*36|0)+20>>2]+f*+g[b+(d*36|0)+24>>2]+h*+g[b+(d*36|0)+28>>2])>0.0){b=0;d=16;break a}d=d+1|0}while((d|0)<(i|0))}j=j+1|0;if((j|0)>=8){b=1;d=16;break}}if((d|0)==16)return b|0;return 0}function jh(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;var h=0,i=0.0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0;o=+g[d>>2];if(+g[b>>2]<=o){i=+g[d+4>>2];if((((+g[b+4>>2]<=i?+g[b+8>>2]<=+g[d+8>>2]:0)?+g[b+16>>2]>=+g[d+16>>2]:0)?+g[b+20>>2]>=+g[d+20>>2]:0)?+g[b+24>>2]>=+g[d+24>>2]:0){d=0;return d|0}else h=d+4|0}else{h=d+4|0;i=+g[d+4>>2]}g[d>>2]=o-f;m=i-f;g[h>>2]=m;p=+g[d+8>>2]-f;g[d+8>>2]=p;i=+g[d+16>>2]+f;g[d+16>>2]=i;n=+g[d+20>>2]+f;g[d+20>>2]=n;q=+g[d+24>>2]+f;g[d+24>>2]=q;l=+g[e>>2];if(l>0.0)g[d+16>>2]=l+i;else g[d>>2]=l+(o-f);i=+g[e+4>>2];if(i>0.0)g[d+20>>2]=i+n;else g[h>>2]=i+m;i=+g[e+8>>2];if(i>0.0)g[d+24>>2]=i+q;else g[d+8>>2]=i+p;h=hh(a,b)|0;a:do if(h){j=c[a+8>>2]|0;if((j|0)<=-1){h=c[a>>2]|0;break}if((j|0)>0){k=0;while(1){e=c[h+32>>2]|0;k=k+1|0;if(!e)break a;if((k|0)>=(j|0)){h=e;break}else h=e}}}else h=0;while(0);c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];c[b+16>>2]=c[d+16>>2];c[b+20>>2]=c[d+20>>2];c[b+24>>2]=c[d+24>>2];c[b+28>>2]=c[d+28>>2];lf(a,h,b);d=1;return d|0}function kh(a,d,e){a=a|0;d=d|0;e=e|0;si(a,d,e)|0;c[d+52>>2]=c[a+48>>2];c[d+56>>2]=c[a+52>>2];c[d+60>>2]=c[a+56>>2];c[d+64>>2]=c[a+60>>2];c[d+68>>2]=c[a+64>>2];c[d+72>>2]=c[a+68>>2];c[d+76>>2]=c[a+72>>2];c[d+80>>2]=c[a+76>>2];c[d+84>>2]=c[a+80>>2];c[d+88>>2]=c[a+84>>2];c[d+92>>2]=c[a+88>>2];c[d+96>>2]=c[a+92>>2];c[d+100>>2]=c[a+96>>2];c[d+104>>2]=c[a+100>>2];c[d+108>>2]=c[a+104>>2];c[d+112>>2]=c[a+108>>2];c[d+116>>2]=c[a+112>>2];c[d+120>>2]=c[a+116>>2];c[d+124>>2]=c[a+120>>2];c[d+128>>2]=c[a+124>>2];c[d+132>>2]=c[a+128>>2];c[d+136>>2]=c[a+132>>2];c[d+140>>2]=c[a+136>>2];c[d+144>>2]=c[a+140>>2];c[d+148>>2]=c[a+144>>2];c[d+152>>2]=c[a+148>>2];c[d+156>>2]=c[a+152>>2];c[d+160>>2]=c[a+156>>2];c[d+164>>2]=c[a+160>>2];c[d+168>>2]=c[a+164>>2];c[d+172>>2]=c[a+168>>2];c[d+176>>2]=c[a+172>>2];c[d+228>>2]=c[a+868>>2];c[d+212>>2]=c[a+872>>2];c[d+196>>2]=c[a+680>>2];c[d+180>>2]=c[a+696>>2];c[d+232>>2]=c[a+932>>2];c[d+216>>2]=c[a+936>>2];c[d+200>>2]=c[a+684>>2];c[d+184>>2]=c[a+700>>2];c[d+236>>2]=c[a+996>>2];c[d+220>>2]=c[a+1e3>>2];c[d+204>>2]=c[a+688>>2];c[d+188>>2]=c[a+704>>2];a=b[a+1300>>1]|0;c[d+244>>2]=a&255;c[d+248>>2]=(a&65535)>>>8&65535;return 12479}function lh(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0;m=i;i=i+32|0;h=(a[b+28>>0]|0)!=0;l=h?e:d;h=h?d:e;j=c[l+4>>2]|0;k=c[j+16>>2]|0;g=c[b+12>>2]|0;if((g|0)<(k|0)){if((c[b+16>>2]|0)<(k|0)){if(!k){d=0;e=g}else{c[6435]=(c[6435]|0)+1;d=yc((k<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+12>>2]|0}if((e|0)>0){f=0;do{c[d+(f<<2)>>2]=c[(c[b+20>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(e|0))}e=c[b+20>>2]|0;if(e|0){if(a[b+24>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+20>>2]=0}a[b+24>>0]=1;c[b+20>>2]=d;c[b+16>>2]=k;e=b+20|0}else e=b+20|0;d=g;do{c[(c[e>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(k|0))}c[b+12>>2]=k;if((k|0)<=0){i=m;return}d=0;do{if(!(c[j+64>>2]|0)){e=c[(c[j+24>>2]|0)+(d*80|0)+64>>2]|0;f=c[l+8>>2]|0;g=c[l+12>>2]|0;c[m>>2]=l;c[m+4>>2]=e;c[m+8>>2]=f;c[m+12>>2]=g;c[m+16>>2]=-1;c[m+20>>2]=d;g=c[b+4>>2]|0;g=Ib[c[(c[g>>2]|0)+8>>2]&31](g,m,h,c[b+32>>2]|0)|0;c[(c[b+20>>2]|0)+(d<<2)>>2]=g}else c[(c[b+20>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(k|0));i=m;return}function mh(){var a=0,b=0,d=0;c[6435]=(c[6435]|0)+1;a=yc(219)|0;if(!a)a=0;else{c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16}ml();ml();c[a>>2]=2896;b=a+52|0;d=a+4|0;c[d>>2]=c[5710];c[d+4>>2]=c[5711];c[d+8>>2]=c[5712];c[d+12>>2]=c[5713];d=a+20|0;c[d>>2]=c[5714];c[d+4>>2]=c[5715];c[d+8>>2]=c[5716];c[d+12>>2]=c[5717];d=a+36|0;c[d>>2]=c[5718];c[d+4>>2]=c[5719];c[d+8>>2]=c[5720];c[d+12>>2]=c[5721];c[b>>2]=c[5722];c[b+4>>2]=c[5723];c[b+8>>2]=c[5724];c[b+12>>2]=c[5725];b=a+116|0;d=a+68|0;c[d>>2]=c[5710];c[d+4>>2]=c[5711];c[d+8>>2]=c[5712];c[d+12>>2]=c[5713];d=a+84|0;c[d>>2]=c[5714];c[d+4>>2]=c[5715];c[d+8>>2]=c[5716];c[d+12>>2]=c[5717];d=a+100|0;c[d>>2]=c[5718];c[d+4>>2]=c[5719];c[d+8>>2]=c[5720];c[d+12>>2]=c[5721];c[b>>2]=c[5722];c[b+4>>2]=c[5723];c[b+8>>2]=c[5724];c[b+12>>2]=c[5725];b=a+180|0;d=a+132|0;c[d>>2]=c[5710];c[d+4>>2]=c[5711];c[d+8>>2]=c[5712];c[d+12>>2]=c[5713];d=a+148|0;c[d>>2]=c[5714];c[d+4>>2]=c[5715];c[d+8>>2]=c[5716];c[d+12>>2]=c[5717];d=a+164|0;c[d>>2]=c[5718];c[d+4>>2]=c[5719];c[d+8>>2]=c[5720];c[d+12>>2]=c[5721];c[b>>2]=c[5722];c[b+4>>2]=c[5723];c[b+8>>2]=c[5724];c[b+12>>2]=c[5725];c[a+196>>2]=0;return a|0}function nh(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;d=c[b+32>>2]|0;if(!d)f=0;else f=c[b+40>>2]|0;i=c[b+52>>2]|0;if(!i)g=0;else g=c[b+60>>2]|0;e=c[b+72>>2]|0;if(!e)h=0;else h=c[b+80>>2]|0;j=c[b+8>>2]|0;+$b[c[(c[j>>2]|0)+12>>2]&3](j,f,d,g,i,h,e,c[b+4>>2]|0,c[b+20>>2]|0,c[b+24>>2]|0);d=c[b+32>>2]|0;if((d|0)<0){if((c[b+36>>2]|0)<0){e=c[b+40>>2]|0;if(e|0){if(a[b+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+40>>2]=0}a[b+44>>0]=1;c[b+40>>2]=0;c[b+36>>2]=0}do{c[(c[b+40>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=0)}c[b+32>>2]=0;d=c[b+52>>2]|0;if((d|0)<0){if((c[b+56>>2]|0)<0){e=c[b+60>>2]|0;if(e|0){if(a[b+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+60>>2]=0}a[b+64>>0]=1;c[b+60>>2]=0;c[b+56>>2]=0}do{c[(c[b+60>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=0)}c[b+52>>2]=0;d=c[b+72>>2]|0;if((d|0)>=0){c[b+72>>2]=0;return}if((c[b+76>>2]|0)<0){e=c[b+80>>2]|0;if(e|0){if(a[b+84>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+80>>2]=0}a[b+84>>0]=1;c[b+80>>2]=0;c[b+76>>2]=0}do{c[(c[b+80>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=0);c[b+72>>2]=0;return}function oh(b,d,e){b=b|0;d=+d;e=e|0;var f=0.0,h=0,i=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;j=c[b+712>>2]|0;if(e){if((j|0)>0){e=c[b+720>>2]|0;h=0;do{g[e+(h*104|0)+88>>2]=0.0;h=h+1|0}while((h|0)!=(j|0))}e=c[b+752>>2]|0;if((e|0)>0){h=c[b+760>>2]|0;i=0;do{m=c[h+(i*44|0)+8>>2]|0;l=c[h+(i*44|0)+12>>2]|0;k=c[h+(i*44|0)+16>>2]|0;o=+g[m+8>>2];q=+g[m+12>>2];f=+g[m+16>>2];n=+g[l+8>>2]-o;r=+g[l+12>>2]-q;p=+g[l+16>>2]-f;o=+g[k+8>>2]-o;q=+g[k+12>>2]-q;f=+g[k+16>>2]-f;f=+O(+((n*q-r*o)*(n*q-r*o)+((r*f-p*q)*(r*f-p*q)+(p*o-n*f)*(p*o-n*f))));g[m+88>>2]=f+ +g[m+88>>2];g[l+88>>2]=f+ +g[l+88>>2];g[k+88>>2]=f+ +g[k+88>>2];i=i+1|0}while((i|0)!=(e|0))}if((j|0)<=0){m=b+924|0;a[m>>0]=1;return}e=c[b+720>>2]|0;h=0;do{m=e+(h*104|0)+88|0;g[m>>2]=1.0/+g[m>>2];h=h+1|0}while((h|0)!=(j|0))}if((j|0)<=0){m=b+924|0;a[m>>0]=1;return}i=c[b+720>>2]|0;e=0;f=0.0;do{r=+g[i+(e*104|0)+88>>2];f=f+(r>0.0?1.0/r:0.0);e=e+1|0}while((e|0)!=(j|0));f=1.0/f*d;e=c[b+712>>2]|0;h=0;do{m=i+(h*104|0)+88|0;g[m>>2]=+g[m>>2]/f;h=h+1|0}while((h|0)<(e|0));m=b+924|0;a[m>>0]=1;return}function ph(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;c[6435]=(c[6435]|0)+1;d=yc(39)|0;if(!d)i=0;else{c[(d+4+15&-16)+-4>>2]=d;i=d+4+15&-16}g=i;c[i>>2]=0;c[i+4>>2]=0;c[i+8>>2]=0;c[i+12>>2]=0;c[i+16>>2]=0;if((c[b+872>>2]|0)>0){h=c[c[b+880>>2]>>2]|0;c[i>>2]=c[h>>2];c[i+4>>2]=c[h+4>>2];c[i+8>>2]=c[h+8>>2];c[i+12>>2]=c[h+12>>2];c[i+16>>2]=c[h+16>>2]}else{c[i>>2]=0;c[i+4>>2]=0;c[i+8>>2]=0;c[i+12>>2]=0;c[i+16>>2]=0}e=c[b+872>>2]|0;if((e|0)!=(c[b+876>>2]|0)){h=e;f=b+880|0;f=c[f>>2]|0;f=f+(h<<2)|0;c[f>>2]=g;h=h+1|0;c[b+872>>2]=h;return i|0}h=e|0?e<<1:1;if((e|0)>=(h|0)){h=e;f=b+880|0;f=c[f>>2]|0;f=f+(h<<2)|0;c[f>>2]=g;h=h+1|0;c[b+872>>2]=h;return i|0}if(!h)d=0;else{c[6435]=(c[6435]|0)+1;d=yc((h<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+872>>2]|0}if((e|0)>0){f=0;do{c[d+(f<<2)>>2]=c[(c[b+880>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(e|0))}f=c[b+880>>2]|0;if(f){if(a[b+884>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);e=c[b+872>>2]|0}c[b+880>>2]=0}a[b+884>>0]=1;c[b+880>>2]=d;c[b+876>>2]=h;h=e;f=b+880|0;f=c[f>>2]|0;f=f+(h<<2)|0;c[f>>2]=g;h=h+1|0;c[b+872>>2]=h;return i|0}function qh(b,d,e,f,h,i){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0;c[6435]=(c[6435]|0)+1;b=yc((h+2|0)>>>0>268435455?18:(h+2<<4|3)+16|0)|0;if(!b)m=0;else{c[(b+4+15&-16)+-4>>2]=b;m=b+4+15&-16}j=(h+2|0)>>>0>1073741823?-1:h+2<<2;j=(j|0)==0?1:j;while(1){k=yc(j)|0;if(k|0)break;b=c[6564]|0;c[6564]=b+0;if(!b){l=7;break}jc[b&3]()}if((l|0)==7){h=Ya(4)|0;c[h>>2]=9640;pb(h|0,2800,251)}if((h|0)>-2){b=0;do{q=+(b|0)/+(h+1|0);p=+g[e>>2];o=+g[e+4>>2];o=o+q*(+g[f+4>>2]-o);n=+g[e+8>>2];n=n+q*(+g[f+8>>2]-n);g[m+(b<<4)>>2]=p+q*(+g[f>>2]-p);g[m+(b<<4)+4>>2]=o;g[m+(b<<4)+8>>2]=n;g[m+(b<<4)+12>>2]=0.0;g[k+(b<<2)>>2]=1.0;b=b+1|0}while((b|0)<(h+2|0))}c[6435]=(c[6435]|0)+1;b=yc(1271)|0;if(!b)j=0;else{c[(b+4+15&-16)+-4>>2]=b;j=b+4+15&-16}Kc(j,d,h+2|0,m,k);if(i&1|0){g[(c[j+720>>2]|0)+88>>2]=0.0;a[j+924>>0]=1}if(i&2|0){g[(c[j+720>>2]|0)+((h+1|0)*104|0)+88>>2]=0.0;a[j+924>>0]=1}if(m|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0)}hd(k);if((h+2|0)>1)b=1;else return j|0;do{Rf(j,b+-1|0,b,0,0);b=b+1|0}while((b|0)!=(h+2|0));return j|0}function rh(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0,j=0,l=0,m=0.0,n=0,o=0,p=0.0,q=0.0;mc[c[(c[a>>2]|0)+8>>2]&127](a,b,f,h);l=c[h>>2]|0;o=c[h+4>>2]|0;i=c[h+8>>2]|0;n=c[f>>2]|0;j=c[f+4>>2]|0;b=c[f+8>>2]|0;m=+g[d>>2];p=+g[d+4>>2];q=+g[d+8>>2];if(m>0.0)l=(g[k>>2]=(c[k>>2]=l,+g[k>>2])+m,c[k>>2]|0);else n=(g[k>>2]=(c[k>>2]=n,+g[k>>2])+m,c[k>>2]|0);if(p>0.0)d=(g[k>>2]=(c[k>>2]=o,+g[k>>2])+p,c[k>>2]|0);else{d=o;j=(g[k>>2]=(c[k>>2]=j,+g[k>>2])+p,c[k>>2]|0)}if(q>0.0)i=(g[k>>2]=(c[k>>2]=i,+g[k>>2])+q,c[k>>2]|0);else b=(g[k>>2]=(c[k>>2]=b,+g[k>>2])+q,c[k>>2]|0);m=+g[e>>2];p=+g[e+4>>2];q=+g[e+8>>2];q=+O(+(m*m+p*p+q*q));q=q*+Sb[c[(c[a>>2]|0)+16>>2]&15](a);c[f>>2]=n;c[f+4>>2]=j;c[f+8>>2]=b;g[f+12>>2]=0.0;c[h>>2]=l;c[h+4>>2]=d;c[h+8>>2]=i;g[h+12>>2]=0.0;g[f>>2]=+g[f>>2]-q;g[f+4>>2]=+g[f+4>>2]-q;g[f+8>>2]=+g[f+8>>2]-q;g[h>>2]=q+ +g[h>>2];g[h+4>>2]=q+ +g[h+4>>2];g[h+8>>2]=q+ +g[h+8>>2];return}function sh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;n=i;i=i+112|0;m=c[d+4>>2]|0;k=n;l=k+100|0;do{c[k>>2]=0;k=k+4|0}while((k|0)<(l|0));h=c[b+712>>2]|0;a:do if((h|0)>(m|0))e=b+720|0;else{if((h|0)<(m|0)?(c[b+716>>2]|0)<(m|0):0){if((m|0)!=0?(c[6435]=(c[6435]|0)+1,e=yc((m*104|3)+16|0)|0,(e|0)!=0):0){c[(e+4+15&-16)+-4>>2]=e;g=e+4+15&-16}else g=0;e=c[b+712>>2]|0;f=0;while(1){if((f|0)>=(e|0))break;k=g+(f*104|0)|0;j=(c[b+720>>2]|0)+(f*104|0)|0;l=k+104|0;do{c[k>>2]=c[j>>2];k=k+4|0;j=j+4|0}while((k|0)<(l|0));f=f+1|0}e=c[b+720>>2]|0;if(e|0){if(!((a[b+724>>0]&1)==0|(e|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+720>>2]=0}a[b+724>>0]=1;c[b+720>>2]=g;c[b+716>>2]=m}e=h;while(1){if((e|0)>=(m|0)){e=b+720|0;break a}k=c[b+720>>2]|0;c[k+(e*104|0)>>2]=0;k=k+(e*104|0)+4|0;j=n;l=k+100|0;do{c[k>>2]=c[j>>2];k=k+4|0;j=j+4|0}while((k|0)<(l|0));e=e+1|0}}while(0);c[b+712>>2]=m;e=c[e>>2]|0;f=0;while(1){if((f|0)>=(m|0))break;k=e+(f*104|0)|0;j=(c[d+12>>2]|0)+(f*104|0)|0;l=k+104|0;do{c[k>>2]=c[j>>2];k=k+4|0;j=j+4|0}while((k|0)<(l|0));f=f+1|0}i=n;return}function th(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;e=c[b+4>>2]|0;if((e|0)==(c[b+8>>2]|0)){If(b,e|0?e<<1:1);e=c[b+4>>2]|0}j=(c[b+12>>2]|0)+(e*36|0)|0;a[j+16>>0]=1;c[j+12>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;k=c[d+4>>2]|0;if((k|0)<=0){c[j+4>>2]=k;k=j+20|0;d=d+20|0;c[k>>2]=c[d>>2];c[k+4>>2]=c[d+4>>2];c[k+8>>2]=c[d+8>>2];c[k+12>>2]=c[d+12>>2];d=c[b+4>>2]|0;d=d+1|0;c[b+4>>2]=d;return}c[6435]=(c[6435]|0)+1;e=yc((k<<2|3)+16|0)|0;if(!e)h=0;else{c[(e+4+15&-16)+-4>>2]=e;h=e+4+15&-16}g=c[j+4>>2]|0;f=c[j+12>>2]|0;if((g|0)<=0)if(!f){a[j+16>>0]=1;c[j+12>>2]=h;c[j+8>>2]=k;Qn(h|0,0,k<<2|0)|0}else i=11;else{e=0;do{c[h+(e<<2)>>2]=c[f+(e<<2)>>2];e=e+1|0}while((e|0)!=(g|0));i=11}if((i|0)==11){if(a[j+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[j+16>>0]=1;c[j+12>>2]=h;c[j+8>>2]=k;Qn(h|0,0,k<<2|0)|0}e=c[j+12>>2]|0;c[j+4>>2]=k;f=c[d+12>>2]|0;g=0;do{c[e+(g<<2)>>2]=c[f+(g<<2)>>2];g=g+1|0}while((g|0)!=(k|0));k=j+20|0;d=d+20|0;c[k>>2]=c[d>>2];c[k+4>>2]=c[d+4>>2];c[k+8>>2]=c[d+8>>2];c[k+12>>2]=c[d+12>>2];d=c[b+4>>2]|0;d=d+1|0;c[b+4>>2]=d;return}function uh(a,d,f,g){a=a|0;d=d|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;i=c[a+68+(d<<2)>>2]|0;h=b[i+((f&65535)<<2)+-4>>1]|0;if((e[i+((f&65535)<<2)>>1]|0)>=(h&65535))return;k=c[a+60>>2]|0;l=k+((e[i+((f&65535)<<2)+2>>1]|0)<<6)+54+(d<<1)|0;j=i+((f&65535)<<2)|0;f=i+((f&65535)<<2)+-4|0;while(1){i=e[j+-2>>1]|0;if(!(h&1)){h=e[j+2>>1]|0;if(((((e[k+(h<<6)+54+((1<>1]|0)>=(e[k+(i<<6)+48+((1<>1]|0)?(e[k+(i<<6)+54+((1<>1]|0)>=(e[k+(h<<6)+48+((1<>1]|0):0)?(e[k+(h<<6)+54+((1<<(1<>1]|0)>=(e[k+(i<<6)+48+((1<<(1<>1]|0):0)?(e[k+(i<<6)+54+((1<<(1<>1]|0)>=(e[k+(h<<6)+48+((1<<(1<>1]|0):0)?(o=c[a+92>>2]|0,m=k+(h<<6)|0,n=k+(i<<6)|0,Ib[c[(c[o>>2]|0)+12>>2]&31](o,m,n,g)|0,o=c[a+96>>2]|0,o|0):0)Ib[c[(c[o>>2]|0)+12>>2]&31](o,m,n,g)|0;k=k+(i<<6)+48+(d<<1)|0;b[k>>1]=(b[k>>1]|0)+1<<16>>16}else{k=k+(i<<6)+54+(d<<1)|0;b[k>>1]=(b[k>>1]|0)+1<<16>>16}b[l>>1]=(b[l>>1]|0)+-1<<16>>16;i=e[j>>1]|e[j+2>>1]<<16;h=e[f>>1]|e[f+2>>1]<<16;b[j>>1]=h;b[j+2>>1]=h>>>16;b[f>>1]=i;b[f+2>>1]=i>>>16;i=j+-4|0;f=f+-4|0;h=b[f>>1]|0;if((e[i>>1]|0)>=(h&65535))break;k=c[a+60>>2]|0;j=i}return}function vh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0;k=i;i=i+48|0;g=c[a+28>>2]|0;c[k+32>>2]=g;g=(c[a+20>>2]|0)-g|0;c[k+32+4>>2]=g;c[k+32+8>>2]=b;c[k+32+12>>2]=d;j=k+32|0;f=2;g=g+d|0;while(1){if(!0){c[k+16>>2]=c[a+60>>2];c[k+16+4>>2]=j;c[k+16+8>>2]=f;b=wb(146,k+16|0)|0;if(b>>>0>4294963200){if(!0)e=25748;else e=c[(ib()|0)+64>>2]|0;c[e>>2]=0-b;b=-1}}else{rb(254,a|0);c[k>>2]=c[a+60>>2];c[k+4>>2]=j;c[k+8>>2]=f;b=wb(146,k|0)|0;if(b>>>0>4294963200){if(!0)e=25748;else e=c[(ib()|0)+64>>2]|0;c[e>>2]=0-b;b=-1}Ua(0)}if((g|0)==(b|0)){b=13;break}if((b|0)<0){b=15;break}g=g-b|0;e=c[j+4>>2]|0;if(b>>>0<=e>>>0)if((f|0)==2){c[a+28>>2]=(c[a+28>>2]|0)+b;h=e;e=j;f=2}else{h=e;e=j}else{h=c[a+44>>2]|0;c[a+28>>2]=h;c[a+20>>2]=h;h=c[j+12>>2]|0;b=b-e|0;e=j+8|0;f=f+-1|0}c[e>>2]=(c[e>>2]|0)+b;c[e+4>>2]=h-b;j=e}if((b|0)==13){j=c[a+44>>2]|0;c[a+16>>2]=j+(c[a+48>>2]|0);c[a+28>>2]=j;c[a+20>>2]=j}else if((b|0)==15){c[a+16>>2]=0;c[a+28>>2]=0;c[a+20>>2]=0;c[a>>2]=c[a>>2]|32;if((f|0)==2)d=0;else d=d-(c[j+4>>2]|0)|0}i=k;return d|0}function wh(a,d,f){a=a|0;d=d|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=c[a+68+(d<<2)>>2]|0;m=c[a+60>>2]|0;n=e[h+((f&65535)<<2)+2>>1]|0;g=b[h+((f&65535)<<2)+-4>>1]|0;if((e[h+((f&65535)<<2)>>1]|0)>=(g&65535))return;j=m;i=h+((f&65535)<<2)|0;f=h+((f&65535)<<2)+-4|0;while(1){h=e[i+-2>>1]|0;if(!(g&1)){j=j+(h<<6)+48+(d<<1)|0;b[j>>1]=(b[j>>1]|0)+1<<16>>16}else{if(((((e[m+(n<<6)+54+((1<>1]|0)>=(e[j+(h<<6)+48+((1<>1]|0)?(e[j+(h<<6)+54+((1<>1]|0)>=(e[m+(n<<6)+48+((1<>1]|0):0)?(e[m+(n<<6)+54+((1<<(1<>1]|0)>=(e[j+(h<<6)+48+((1<<(1<>1]|0):0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return l|0}c[k>>2]=c[m+4>>2];c[k+4>>2]=c[m+4+4>>2];c[k+8>>2]=c[m+4+8>>2];c[k+12>>2]=c[m+4+12>>2];c[l>>2]=c[m+20>>2];c[l+4>>2]=c[m+20+4>>2];c[l+8>>2]=c[m+20+8>>2];c[l+12>>2]=c[m+20+12>>2];c[j>>2]=c[m+36>>2];c[j+4>>2]=c[m+36+4>>2];c[j+8>>2]=c[m+36+8>>2];c[j+12>>2]=c[m+36+12>>2];l=0;i=m;return l|0}function yh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0,k=0,l=0,m=0.0,n=0.0,o=0,p=0,q=0.0,r=0;p=i;i=i+2048|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;e=+g[d>>2];h=+g[d+4>>2];f=+g[d+8>>2];if(e*e+h*h+f*f<9.999999747378752e-05){n=1.0;m=0.0;h=0.0}else{q=1.0/+O(+(e*e+h*h+f*f));n=e*q;m=f*q;h=h*q}if((Eb[c[(c[b>>2]|0)+96>>2]&127](b)|0)<=0){i=p;return}l=0;f=-999999984306749440.0;while(1){if(((Eb[c[(c[b>>2]|0)+96>>2]&127](b)|0)-l|0)<128){d=(Eb[c[(c[b>>2]|0)+96>>2]&127](b)|0)-l|0;if((d|0)>0)o=8;else{e=-3402823466385288598117041.0e14;d=-1}}else{d=128;o=8}if((o|0)==8){o=0;j=0;do{ic[c[(c[b>>2]|0)+108>>2]&127](b,j,p+(j<<4)|0);j=j+1|0}while((j|0)!=(d|0));k=0;e=-3402823466385288598117041.0e14;j=-1;do{q=n*+g[p+(k<<4)>>2]+h*+g[p+(k<<4)+4>>2]+m*+g[p+(k<<4)+8>>2];r=q>e;j=r?k:j;e=r?q:e;k=k+1|0}while((k|0)!=(d|0));d=j}if(e>f){r=p+(d<<4)|0;c[a>>2]=c[r>>2];c[a+4>>2]=c[r+4>>2];c[a+8>>2]=c[r+8>>2];c[a+12>>2]=c[r+12>>2]}else e=f;l=l+128|0;if((l|0)>=(Eb[c[(c[b>>2]|0)+96>>2]&127](b)|0))break;else f=e}i=p;return}function zh(b,e,f,h,i,j){b=b|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;var k=0;if((d[h+55>>0]|0|0)==(e|0)){h=0;return h|0}k=c[4976+(i<<2)>>2]|0;if(+g[h>>2]*+g[f+16>>2]+ +g[h+4>>2]*+g[f+20>>2]+ +g[h+8>>2]*+g[f+24>>2]-+g[h+16>>2]<-9.999999747378752e-06){k=nf(b,c[h+20+(k<<2)>>2]|0,c[h+20+(i<<2)>>2]|0,f,0)|0;if(!k){h=0;return h|0}a[k+52>>0]=i;c[k+32>>2]=h;a[h+52+i>>0]=0;c[h+32+(i<<2)>>2]=k;i=c[j>>2]|0;if(!i)c[j+4>>2]=k;else{a[i+53>>0]=2;c[i+36>>2]=k;a[k+54>>0]=1;c[k+40>>2]=i}c[j>>2]=k;c[j+8>>2]=(c[j+8>>2]|0)+1;h=1;return h|0}i=c[4988+(i<<2)>>2]|0;a[h+55>>0]=e;if(!(zh(b,e,f,c[h+32+(k<<2)>>2]|0,d[h+52+k>>0]|0,j)|0)){h=0;return h|0}if(!(zh(b,e,f,c[h+32+(i<<2)>>2]|0,d[h+52+i>>0]|0,j)|0)){h=0;return h|0}i=c[h+48>>2]|0;if(i|0)c[i+44>>2]=c[h+44>>2];i=c[h+44>>2]|0;if(i|0)c[i+48>>2]=c[h+48>>2];if((c[b+9280>>2]|0)==(h|0))c[b+9280>>2]=c[h+48>>2];c[b+9284>>2]=(c[b+9284>>2]|0)+-1;c[h+44>>2]=0;c[h+48>>2]=c[b+9288>>2];i=c[b+9288>>2]|0;if(i|0)c[i+44>>2]=h;c[b+9288>>2]=h;c[b+9292>>2]=(c[b+9292>>2]|0)+1;h=1;return h|0}function Ah(b,d){b=b|0;d=d|0;var e=0,f=0,h=0.0,i=0,j=0,k=0.0,l=0.0;e=c[d+204>>2]|0;if((e&3|0)==0?(c[d+504>>2]&1|0)==0:0){h=+g[d+344>>2];if(h!=0.0){l=1.0/h*+g[b+252>>2];k=1.0/h*+g[b+256>>2];g[d+364>>2]=1.0/h*+g[b+248>>2];g[d+368>>2]=l;g[d+372>>2]=k;g[d+376>>2]=0.0}c[d+380>>2]=c[b+248>>2];c[d+380+4>>2]=c[b+248+4>>2];c[d+380+8>>2]=c[b+248+8>>2];c[d+380+12>>2]=c[b+248+12>>2]}if(!(c[d+192>>2]|0))return;if(e&1){if((c[d+216>>2]&-2|0)!=4)c[d+216>>2]=2}else{f=c[b+232>>2]|0;if((f|0)==(c[b+236>>2]|0)?(j=f|0?f<<1:1,(f|0)<(j|0)):0){if(!j)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((j<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[b+232>>2]|0}if((f|0)>0){i=0;do{c[e+(i<<2)>>2]=c[(c[b+240>>2]|0)+(i<<2)>>2];i=i+1|0}while((i|0)!=(f|0))}i=c[b+240>>2]|0;if(i){if(a[b+244>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[i+-4>>2]|0);f=c[b+232>>2]|0}c[b+240>>2]=0}a[b+244>>0]=1;c[b+240>>2]=e;c[b+236>>2]=j;e=c[d+204>>2]|0}c[(c[b+240>>2]|0)+(f<<2)>>2]=d;c[b+232>>2]=f+1}j=(e&3|0)==0;mc[c[(c[b>>2]|0)+36>>2]&127](b,d,j?1:2,j?-1:-3);return}function Bh(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0,k=0,l=0,m=0.0,n=0.0;h=c[d+204>>2]|0;if((h&3|0)==0?(c[d+504>>2]&1|0)==0:0){i=+g[d+344>>2];if(i!=0.0){n=1.0/i*+g[b+252>>2];m=1.0/i*+g[b+256>>2];g[d+364>>2]=1.0/i*+g[b+248>>2];g[d+368>>2]=n;g[d+372>>2]=m;g[d+376>>2]=0.0}c[d+380>>2]=c[b+248>>2];c[d+380+4>>2]=c[b+248+4>>2];c[d+380+8>>2]=c[b+248+8>>2];c[d+380+12>>2]=c[b+248+12>>2]}if(!(c[d+192>>2]|0))return;if(h&1){if((c[d+216>>2]&-2|0)!=4)c[d+216>>2]=2}else{h=c[b+232>>2]|0;if((h|0)==(c[b+236>>2]|0)?(l=h|0?h<<1:1,(h|0)<(l|0)):0){if(!l)k=0;else{c[6435]=(c[6435]|0)+1;h=yc((l<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}k=h;h=c[b+232>>2]|0}if((h|0)>0){j=0;do{c[k+(j<<2)>>2]=c[(c[b+240>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(h|0))}j=c[b+240>>2]|0;if(j){if(a[b+244>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);h=c[b+232>>2]|0}c[b+240>>2]=0}a[b+244>>0]=1;c[b+240>>2]=k;c[b+236>>2]=l}c[(c[b+240>>2]|0)+(h<<2)>>2]=d;c[b+232>>2]=h+1}mc[c[(c[b>>2]|0)+36>>2]&127](b,d,e,f);return}function Ch(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0;o=(+g[a+32>>2]-+g[a+16>>2])*.5;l=(+g[a+36>>2]-+g[a+20>>2])*.5;i=(+g[a+40>>2]-+g[a+24>>2])*.5;n=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);k=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);i=i+ +Sb[c[(c[a>>2]|0)+48>>2]&15](a);B=(+g[a+32>>2]+ +g[a+16>>2])*.5;z=(+g[a+36>>2]+ +g[a+20>>2])*.5;x=(+g[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+g[b+20>>2];p=+N(+A);n=+g[b+24>>2];o=+N(+n);y=+g[b+32>>2];l=+N(+y);w=+g[b+36>>2];j=+N(+w);f=+g[b+40>>2];h=+N(+f);z=F?0.0:(H+z)*.5;x=F?0.0:(G+x)*.5;v=F?0.0:(E+v)*.5;r=z*D+x*C+v*r+ +g[b+48>>2];n=z*B+x*A+v*n+ +g[b+52>>2];f=z*y+x*w+v*f+ +g[b+56>>2];g[d>>2]=r-(m*u+k*t+i*s);g[d+4>>2]=n-(m*q+k*p+i*o);g[d+8>>2]=f-(m*l+k*j+i*h);g[d+12>>2]=0.0;g[e>>2]=m*u+k*t+i*s+r;g[e+4>>2]=m*q+k*p+i*o+n;g[e+8>>2]=m*l+k*j+i*h+f;g[e+12>>2]=0.0;return}function Eh(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0,l=0.0,m=0.0;if(a[b+48>>0]|0){c[d>>2]=0;c[d+4>>2]=0;return}c[d>>2]=4;c[d+4>>2]=2;kd(b,(c[b+28>>2]|0)+4|0,(c[b+32>>2]|0)+4|0);g[b+1088>>2]=0.0;a[b+297>>0]=0;f=+g[b+192>>2];h=+g[b+196>>2];do if(f<=h){m=+g[b+892>>2];l=+g[b+908>>2];i=+g[b+924>>2];i=+ik(+W(+(+g[b+832>>2]*m+ +g[b+848>>2]*l+ +g[b+864>>2]*i),+(+g[b+828>>2]*m+ +g[b+844>>2]*l+ +g[b+860>>2]*i)),f,h);g[b+1084>>2]=i;if(i>2]=i-f;a[b+297>>0]=1;j=1;break}if(i>h){g[b+1088>>2]=i-h;a[b+297>>0]=1;j=1}else j=0}else j=0;while(0);a[b+296>>0]=0;e=c[b+1032>>2]|0;c[b+1080>>2]=e;f=+g[b+184>>2];h=+g[b+188>>2];i=(c[k>>2]=e,+g[k>>2]);do if(f<=h){if(i>h){g[b+1032>>2]=i-h;a[b+296>>0]=1;e=14;break}if(i>2]=i-f;a[b+296>>0]=1;e=14}else e=13}else e=13;while(0);if((e|0)==13?(g[b+1032>>2]=0.0,a[b+1096>>0]|0):0)e=14;if((e|0)==14){c[d>>2]=(c[d>>2]|0)+1;c[d+4>>2]=(c[d+4>>2]|0)+-1}if(j<<24>>24==0?(a[b+1112>>0]|0)==0:0)return;c[d>>2]=(c[d>>2]|0)+1;c[d+4>>2]=(c[d+4>>2]|0)+-1;return}function Fh(a){a=a|0;var b=0,d=0.0,e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0,p=0.0;c[6435]=(c[6435]|0)+1;b=yc(75)|0;if(!b)i=0;else{c[(b+4+15&-16)+-4>>2]=b;i=b+4+15&-16}c[i+8>>2]=0;e=i+12|0;c[e>>2]=1065353216;f=i+16|0;c[f>>2]=1065353216;h=i+20|0;c[h>>2]=1065353216;g[i+24>>2]=0.0;b=i+44|0;g[b>>2]=.03999999910593033;c[i+52>>2]=0;c[i>>2]=7844;c[i+4>>2]=0;k=+g[a>>2];j=+g[a+4>>2];d=+g[a+8>>2];d=+g[a+((k>2]*.10000000149011612;if(d<.03999999910593033){p=+xz(i);n=+Sb[c[(c[i>>2]|0)+48>>2]&15](i);k=+Sb[c[(c[i>>2]|0)+48>>2]&15](i);o=i+28|0;p=p+ +g[o>>2];m=i+32|0;n=n+ +g[m>>2];l=i+36|0;k=k+ +g[l>>2];g[b>>2]=d;d=+Sb[c[(c[i>>2]|0)+48>>2]&15](i);j=+Sb[c[(c[i>>2]|0)+48>>2]&15](i);k=k-+Sb[c[(c[i>>2]|0)+48>>2]&15](i);g[o>>2]=p-d;g[m>>2]=n-j;g[l>>2]=k;g[i+40>>2]=0.0;b=c[i>>2]|0}else b=7844;k=+Sb[c[b+48>>2]&15](i);n=+Sb[c[(c[i>>2]|0)+48>>2]&15](i);p=+Sb[c[(c[i>>2]|0)+48>>2]&15](i);n=+g[a+4>>2]*+g[f>>2]-n;p=+g[a+8>>2]*+g[h>>2]-p;g[i+28>>2]=+g[a>>2]*+g[e>>2]-k;g[i+32>>2]=n;g[i+36>>2]=p;g[i+40>>2]=0.0;return i|0}function Gh(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;f=c[a+212>>2]|0;a:do if((f|0)>0){g=c[a+220>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0))break a}if((d|0)<(f|0)){c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+220>>2]|0)+(f+-1<<2)>>2]=b;c[a+212>>2]=f+-1}}while(0);a=c[b+28>>2]|0;d=c[a+488>>2]|0;b:do if((d|0)>0){g=c[a+496>>2]|0;e=0;while(1){f=g+(e<<2)|0;if((c[f>>2]|0)==(b|0))break;e=e+1|0;if((e|0)>=(d|0))break b}if((e|0)<(d|0)){c[f>>2]=c[g+(d+-1<<2)>>2];c[(c[a+496>>2]|0)+(d+-1<<2)>>2]=b;c[a+488>>2]=d+-1;d=d+-1|0}}while(0);c[a+256>>2]=(d|0)>0&1;a=c[b+32>>2]|0;d=c[a+488>>2]|0;if((d|0)<=0){b=d;b=(b|0)>0;b=b&1;h=a+256|0;c[h>>2]=b;return}g=c[a+496>>2]|0;e=0;while(1){f=g+(e<<2)|0;if((c[f>>2]|0)==(b|0))break;e=e+1|0;if((e|0)>=(d|0)){h=19;break}}if((h|0)==19){b=(d|0)>0;b=b&1;h=a+256|0;c[h>>2]=b;return}if((e|0)>=(d|0)){b=d;b=(b|0)>0;b=b&1;h=a+256|0;c[h>>2]=b;return}c[f>>2]=c[g+(d+-1<<2)>>2];c[(c[a+496>>2]|0)+(d+-1<<2)>>2]=b;c[a+488>>2]=d+-1;b=d+-1|0;b=(b|0)>0;b=b&1;h=a+256|0;c[h>>2]=b;return}function Hh(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0;j=Eb[c[(c[b>>2]|0)+28>>2]&127](b)|0;i=+g[j>>2]-+g[d>>2];h=+g[j+4>>2]-+g[d+4>>2];f=+g[j+8>>2]-+g[d+8>>2];if(!(i*i+h*h+f*f>1.1920928955078125e-07))return;Xg(b,d);if((a[b+61>>0]|0)!=0?(e=c[b+52>>2]|0,Ab[c[c[e>>2]>>2]&255](e),e=c[b+52>>2]|0,(e|0)!=0):0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=b+52|0}else d=b+52|0;c[6435]=(c[6435]|0)+1;e=yc(191)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e+52>>2]=282;a[e+60>>0]=0;a[e+80>>0]=1;c[e+76>>2]=0;c[e+68>>2]=0;c[e+72>>2]=0;a[e+100>>0]=1;c[e+96>>2]=0;c[e+88>>2]=0;c[e+92>>2]=0;a[e+120>>0]=1;c[e+116>>2]=0;c[e+108>>2]=0;c[e+112>>2]=0;a[e+140>>0]=1;c[e+136>>2]=0;c[e+128>>2]=0;c[e+132>>2]=0;c[e+144>>2]=0;a[e+164>>0]=1;c[e+160>>2]=0;c[e+152>>2]=0;c[e+156>>2]=0;c[e+168>>2]=0;c[e+4>>2]=-8388609;c[e+8>>2]=-8388609;c[e+12>>2]=-8388609;g[e+16>>2]=0.0;c[e+20>>2]=2139095039;c[e+24>>2]=2139095039;c[e+28>>2]=2139095039;g[e+32>>2]=0.0;c[e>>2]=7980;c[d>>2]=e;pd(e,c[b+48>>2]|0,(a[b+60>>0]|0)!=0,b+16|0,b+32|0);a[b+61>>0]=1;return}function Ih(b,d){b=b|0;d=d|0;var e=0.0,f=0.0;if(a[b+1309>>0]|0){e=(+g[b+1256>>2]-+g[b+1316>>2])*+g[b+1340>>2];g[b+792>>2]=e*(+g[d>>2]*+g[b+1364>>2]/+(c[d+48>>2]|0));e=+N(+e);g[b+808>>2]=e/+g[d>>2]}if(a[b+1310>>0]|0){e=(+g[b+1260>>2]-+g[b+1320>>2])*+g[b+1344>>2];g[b+796>>2]=e*(+g[d>>2]*+g[b+1368>>2]/+(c[d+48>>2]|0));e=+N(+e);g[b+812>>2]=e/+g[d>>2]}if(a[b+1311>>0]|0){e=(+g[b+1264>>2]-+g[b+1324>>2])*+g[b+1348>>2];g[b+800>>2]=e*(+g[d>>2]*+g[b+1372>>2]/+(c[d+48>>2]|0));e=+N(+e);g[b+816>>2]=e/+g[d>>2]}if(a[b+1312>>0]|0){f=-((+g[b+1192>>2]-+g[b+1328>>2])*+g[b+1352>>2]);e=+g[d>>2];g[b+876>>2]=e*+g[b+1376>>2]/+(c[d+48>>2]|0)*f;g[b+880>>2]=+N(+f)/e}if(a[b+1313>>0]|0){e=-((+g[b+1196>>2]-+g[b+1332>>2])*+g[b+1356>>2]);f=+g[d>>2];g[b+940>>2]=f*+g[b+1380>>2]/+(c[d+48>>2]|0)*e;g[b+944>>2]=+N(+e)/f}if(!(a[b+1314>>0]|0)){fg(b,d);return}e=-((+g[b+1200>>2]-+g[b+1336>>2])*+g[b+1360>>2]);f=+g[d>>2];g[b+1004>>2]=f*+g[b+1384>>2]/+(c[d+48>>2]|0)*e;g[b+1008>>2]=+N(+e)/f;fg(b,d);return}function Jh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0.0,j=0.0,k=0.0;e=i;i=i+160|0;c[e+136>>2]=0;c[e+136+4>>2]=0;c[e+136+8>>2]=0;c[e+136+12>>2]=0;c[e+136+16>>2]=0;c[e+32>>2]=7028;f=e+32+4|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[e+32+20>>2]=1065353216;c[e+32+24>>2]=0;c[e+32+24+4>>2]=0;c[e+32+24+8>>2]=0;c[e+32+24+12>>2]=0;c[e+32+40>>2]=1065353216;c[e+32+44>>2]=0;c[e+32+44+4>>2]=0;c[e+32+44+8>>2]=0;c[e+32+44+12>>2]=0;c[e+32+60>>2]=1065353216;c[e+32+64>>2]=0;c[e+32+68>>2]=c[e+136+4>>2];c[e+32+68+4>>2]=c[e+136+4+4>>2];c[e+32+68+8>>2]=c[e+136+4+8>>2];c[e+32+68+12>>2]=c[e+136+4+12>>2];g[e+32+84>>2]=-999999984306749440.0;k=+g[d>>2];j=+g[d+4>>2];h=+g[d+8>>2];g[e+32+88>>2]=k+j*0.0+h*0.0;g[e+32+92>>2]=k*0.0+j+h*0.0;g[e+32+96>>2]=k*0.0+j*0.0+h;g[e+32+100>>2]=0.0;c[e+16>>2]=1566444395;c[e+16+4>>2]=1566444395;c[e+16+8>>2]=1566444395;g[e+16+12>>2]=0.0;d=c[(c[b>>2]|0)+64>>2]|0;g[e>>2]=-999999984306749440.0;g[e+4>>2]=-999999984306749440.0;g[e+8>>2]=-999999984306749440.0;g[e+12>>2]=0.0;mc[d&127](b,e+32|0,e,e+16|0);c[a>>2]=c[f>>2];c[a+4>>2]=c[f+4>>2];c[a+8>>2]=c[f+8>>2];c[a+12>>2]=c[f+12>>2];i=e;return}function Kh(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0;q=i;i=i+16|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;e=+g[d>>2];f=+g[d+4>>2];h=+g[d+8>>2];if(e*e+f*f+h*h<9.999999747378752e-05){p=1.0;o=0.0;n=0.0}else{n=1.0/+O(+(e*e+f*f+h*h));p=e*n;o=f*n;n=h*n}d=c[b+52>>2]|0;m=+g[b+28+(((d+2|0)%3|0)<<2)>>2];c[q>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;c[q+(d<<2)>>2]=c[b+28+(d<<2)>>2];k=p*m;l=o*m;m=n*m;e=k+ +g[q>>2];f=l+ +g[q+4>>2];j=m+ +g[q+8>>2];h=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);e=e-p*h;f=f-o*h;h=j-n*h;j=n*h+(p*e+o*f);if(j>-999999984306749440.0){g[a>>2]=e;g[a+4>>2]=f;g[a+8>>2]=h;g[a+12>>2]=0.0}else j=-999999984306749440.0;c[q>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;d=c[b+52>>2]|0;g[q+(d<<2)>>2]=-+g[b+28+(d<<2)>>2];e=k+ +g[q>>2];f=l+ +g[q+4>>2];m=m+ +g[q+8>>2];h=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);e=e-p*h;f=f-o*h;h=m-n*h;if(!(n*h+(p*e+o*f)>j)){i=q;return}g[a>>2]=e;g[a+4>>2]=f;g[a+8>>2]=h;g[a+12>>2]=0.0;i=q;return}function Lh(a,b,d,e,f,h,j,k,l,m){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;h=+h;j=+j;k=+k;l=+l;m=+m;var n=0;n=i;i=i+128|0;c[n+80>>2]=c[a+4>>2];c[n+80+4>>2]=c[a+20>>2];c[n+80+8>>2]=c[a+36>>2];g[n+80+12>>2]=0.0;c[n+80+16>>2]=c[a+8>>2];c[n+80+20>>2]=c[a+24>>2];c[n+80+24>>2]=c[a+40>>2];g[n+80+28>>2]=0.0;c[n+80+32>>2]=c[a+12>>2];c[n+80+36>>2]=c[a+28>>2];c[n+80+40>>2]=c[a+44>>2];g[n+80+44>>2]=0.0;c[n+32>>2]=c[b+4>>2];c[n+32+4>>2]=c[b+20>>2];c[n+32+8>>2]=c[b+36>>2];g[n+32+12>>2]=0.0;c[n+32+16>>2]=c[b+8>>2];c[n+32+20>>2]=c[b+24>>2];c[n+32+24>>2]=c[b+40>>2];g[n+32+28>>2]=0.0;c[n+32+32>>2]=c[b+12>>2];c[n+32+36>>2]=c[b+28>>2];c[n+32+40>>2]=c[b+44>>2];g[n+32+44>>2]=0.0;h=h-+g[a+56>>2];j=j-+g[a+60>>2];g[n+16>>2]=f-+g[a+52>>2];g[n+16+4>>2]=h;g[n+16+8>>2]=j;g[n+16+12>>2]=0.0;l=l-+g[b+56>>2];m=m-+g[b+60>>2];g[n>>2]=k-+g[b+52>>2];g[n+4>>2]=l;g[n+8>>2]=m;g[n+12>>2]=0.0;Rg(d,n+80|0,n+32|0,n+16|0,n,e,a+396|0,+g[a+344>>2],b+396|0,+g[b+344>>2]);i=n;return}function Mh(a,b,c,d,e,f,h,i,j,k,l,m,n,o){a=a|0;b=+b;c=+c;d=+d;e=+e;f=+f;h=+h;i=+i;j=+j;k=+k;l=+l;m=+m;n=+n;o=+o;var p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0;s=(j-f)*(n-h)-(k-h)*(m-f);q=(k-h)*(l-e)-(i-e)*(n-h);r=(i-e)*(m-f)-(j-f)*(l-e);if(+N(+(r*d+(s*b+q*c)))<1.1920928955078125e-07){d=-1.0;return +d}t=+g[a>>2];v=+g[a+4>>2];u=+g[a+8>>2];p=-(s*t+q*v+r*u-(r*h+(s*e+q*f)))/(r*d+(s*b+q*c));if(((p>1.1920928955078125e-06&p-1.1920928955078125e-06:0)?r*((m-(v+p*c))*(i-(t+p*b))-(j-(v+p*c))*(l-(t+p*b)))+(s*((j-(v+p*c))*(n-(u+p*d))-(k-(u+p*d))*(m-(v+p*c)))+q*((k-(u+p*d))*(l-(t+p*b))-(n-(u+p*d))*(i-(t+p*b))))>-1.1920928955078125e-06:0)?r*((f-(v+p*c))*(l-(t+p*b))-(m-(v+p*c))*(e-(t+p*b)))+(s*((m-(v+p*c))*(h-(u+p*d))-(n-(u+p*d))*(f-(v+p*c)))+q*((n-(u+p*d))*(e-(t+p*b))-(h-(u+p*d))*(l-(t+p*b))))>-1.1920928955078125e-06:0){v=p;return +v}v=-1.0;return +v}function Nh(a,b,d,e,f){a=a|0;b=+b;d=+d;e=+e;f=f|0;var h=0,j=0,k=0,l=0,m=0.0,n=0.0;k=i;i=i+48|0;m=1.0/+O(+(b*b+d*d+e*e));g[f>>2]=m*b;g[f+4>>2]=m*d;g[f+8>>2]=m*e;g[f+12>>2]=0.0;h=c[a+120>>2]|0;l=c[a+124>>2]|0;j=(c[a>>2]|0)+(l>>1)|0;if(l&1)h=c[(c[j>>2]|0)+h>>2]|0;ic[h&127](k,j,f);b=-+g[f>>2];d=-+g[f+4>>2];e=-+g[f+8>>2];h=c[a+120>>2]|0;l=c[a+124>>2]|0;j=(c[a+4>>2]|0)+(l>>1)|0;if(l&1)h=c[(c[j>>2]|0)+h>>2]|0;m=+g[a+24>>2]*b+ +g[a+28>>2]*d+ +g[a+32>>2]*e;n=+g[a+40>>2]*b+ +g[a+44>>2]*d+ +g[a+48>>2]*e;g[k+16>>2]=+g[a+8>>2]*b+ +g[a+12>>2]*d+ +g[a+16>>2]*e;g[k+16+4>>2]=m;g[k+16+8>>2]=n;g[k+16+12>>2]=0.0;ic[h&127](k+32|0,j,k+16|0);n=+g[k+32>>2];b=+g[k+32+4>>2];d=+g[k+32+8>>2];e=+g[k+4>>2]-(n*+g[a+72>>2]+b*+g[a+76>>2]+d*+g[a+80>>2]+ +g[a+108>>2]);m=+g[k+8>>2]-(n*+g[a+88>>2]+b*+g[a+92>>2]+d*+g[a+96>>2]+ +g[a+112>>2]);g[f+16>>2]=+g[k>>2]-(n*+g[a+56>>2]+b*+g[a+60>>2]+d*+g[a+64>>2]+ +g[a+104>>2]);g[f+20>>2]=e;g[f+24>>2]=m;g[f+28>>2]=0.0;i=k;return}function Oh(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;if(a[b+165>>0]|0){if((c[b+92>>2]|0)>=(d|0))return;if((d|0)!=0?(c[6435]=(c[6435]|0)+1,e=yc((d<<4|3)+16|0)|0,(e|0)!=0):0){c[(e+4+15&-16)+-4>>2]=e;g=e+4+15&-16}else g=0;e=c[b+88>>2]|0;if((e|0)>0){f=0;do{i=g+(f<<4)|0;h=(c[b+96>>2]|0)+(f<<4)|0;c[i>>2]=c[h>>2];c[i+4>>2]=c[h+4>>2];c[i+8>>2]=c[h+8>>2];c[i+12>>2]=c[h+12>>2];f=f+1|0}while((f|0)!=(e|0))}e=c[b+96>>2]|0;if(e|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=g;c[b+92>>2]=d;return}if((c[b+112>>2]|0)>=(d|0))return;if((d|0)!=0?(c[6435]=(c[6435]|0)+1,f=yc((d<<2|3)+16|0)|0,(f|0)!=0):0){c[(f+4+15&-16)+-4>>2]=f;h=f+4+15&-16}else h=0;f=c[b+108>>2]|0;g=c[b+116>>2]|0;if((f|0)<=0)if(!g)e=b+120|0;else i=21;else{e=0;do{c[h+(e<<2)>>2]=c[g+(e<<2)>>2];e=e+1|0}while((e|0)!=(f|0));i=21}if((i|0)==21){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[b+116>>2]=0;e=b+120|0}a[e>>0]=1;c[b+116>>2]=h;c[b+112>>2]=d;return}function Ph(){var b=0,d=0,e=0;c[6435]=(c[6435]|0)+1;b=yc(307)|0;if(!b)d=0;else{c[(b+4+15&-16)+-4>>2]=b;d=b+4+15&-16}c[d+164>>2]=1065353216;c[d+168>>2]=1065353216;c[d+172>>2]=1065353216;g[d+176>>2]=0.0;c[d+180>>2]=0;g[d+184>>2]=999999984306749440.0;b=d+188|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[d+204>>2]=1;c[d+208>>2]=-1;c[d+212>>2]=-1;c[d+216>>2]=1;g[d+220>>2]=0.0;g[d+224>>2]=.5;g[d+228>>2]=0.0;g[d+232>>2]=0.0;c[d+240>>2]=0;g[d+244>>2]=1.0;b=d+248|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[d+4>>2]=1065353216;b=d+8|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[d+24>>2]=1065353216;b=d+28|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[d+44>>2]=1065353216;b=d+48|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[b+16>>2]=0;a[d+280>>0]=1;c[d+276>>2]=0;c[d+268>>2]=0;c[d+272>>2]=0;c[d+236>>2]=4;c[d>>2]=5088;c[6435]=(c[6435]|0)+1;b=yc(95)|0;if(!b){e=0;Ri(e);b=d+284|0;c[b>>2]=e;return d|0}c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16;Ri(b);e=d+284|0;c[e>>2]=b;return d|0}function Qh(a,b,d,e,f,g,h,i,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;if(!(c[i+44>>2]|0))return;b=c[i+20>>2]|0;if(!(c[i+64>>2]&256)){if((b|0)<=0)return;j=0;do{g=c[a+28>>2]|0;if((g|0)>0){b=0;do{f=c[(c[a+116>>2]|0)+(b<<2)>>2]|0;h=c[a+36>>2]|0;d=c[a+16>>2]|0;Ig(d+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,d+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0);b=b+1|0}while((b|0)!=(g|0));b=c[i+20>>2]|0}j=j+1|0}while((j|0)<(b|0));return}else{if((b|0)<=0)return;j=0;do{g=c[a+28>>2]|0;if((g|0)>0){b=0;do{f=c[(c[a+116>>2]|0)+(b<<2)>>2]|0;h=c[a+36>>2]|0;d=c[a+16>>2]|0;Ig(d+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,d+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0);b=b+1|0}while((b|0)!=(g|0));b=c[i+20>>2]|0}j=j+1|0}while((j|0)<(b|0));return}}function Rh(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;if(!(a[d+164>>0]|0)){if((c[d+152>>2]|0)>=(e|0))return;if((e|0)!=0?(c[6435]=(c[6435]|0)+1,g=yc((e<<1)+19|0)|0,(g|0)!=0):0){c[(g+4+15&-16)+-4>>2]=g;i=g+4+15&-16}else i=0;g=c[d+148>>2]|0;h=c[d+156>>2]|0;if((g|0)<=0)if(!h)f=d+160|0;else j=22;else{f=0;do{b[i+(f<<1)>>1]=b[h+(f<<1)>>1]|0;f=f+1|0}while((f|0)!=(g|0));j=22}if((j|0)==22){if(a[d+160>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[d+156>>2]=0;f=d+160|0}a[f>>0]=1;c[d+156>>2]=i;c[d+152>>2]=e;return}else{if((c[d+132>>2]|0)>=(e|0))return;if((e|0)!=0?(c[6435]=(c[6435]|0)+1,f=yc((e<<2|3)+16|0)|0,(f|0)!=0):0){c[(f+4+15&-16)+-4>>2]=f;i=f+4+15&-16}else i=0;g=c[d+128>>2]|0;h=c[d+136>>2]|0;if((g|0)<=0)if(!h)f=d+140|0;else j=10;else{f=0;do{c[i+(f<<2)>>2]=c[h+(f<<2)>>2];f=f+1|0}while((f|0)!=(g|0));j=10}if((j|0)==10){if(a[d+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[d+136>>2]=0;f=d+140|0}a[f>>0]=1;c[d+136>>2]=i;c[d+132>>2]=e;return}}function Sh(a,b,d){a=a|0;b=b|0;d=d|0;si(a,b,d)|0;c[b+52>>2]=c[a+300>>2];c[b+56>>2]=c[a+304>>2];c[b+60>>2]=c[a+308>>2];c[b+64>>2]=c[a+312>>2];c[b+68>>2]=c[a+316>>2];c[b+72>>2]=c[a+320>>2];c[b+76>>2]=c[a+324>>2];c[b+80>>2]=c[a+328>>2];c[b+84>>2]=c[a+332>>2];c[b+88>>2]=c[a+336>>2];c[b+92>>2]=c[a+340>>2];c[b+96>>2]=c[a+344>>2];c[b+100>>2]=c[a+348>>2];c[b+104>>2]=c[a+352>>2];c[b+108>>2]=c[a+356>>2];c[b+112>>2]=c[a+360>>2];c[b+116>>2]=c[a+364>>2];c[b+120>>2]=c[a+368>>2];c[b+124>>2]=c[a+372>>2];c[b+128>>2]=c[a+376>>2];c[b+132>>2]=c[a+380>>2];c[b+136>>2]=c[a+384>>2];c[b+140>>2]=c[a+388>>2];c[b+144>>2]=c[a+392>>2];c[b+148>>2]=c[a+396>>2];c[b+152>>2]=c[a+400>>2];c[b+156>>2]=c[a+404>>2];c[b+160>>2]=c[a+408>>2];c[b+164>>2]=c[a+412>>2];c[b+168>>2]=c[a+416>>2];c[b+172>>2]=c[a+420>>2];c[b+176>>2]=c[a+424>>2];c[b+180>>2]=c[a+444>>2];c[b+184>>2]=c[a+448>>2];c[b+188>>2]=c[a+452>>2];c[b+192>>2]=c[a+428>>2];c[b+196>>2]=c[a+432>>2];c[b+200>>2]=c[a+436>>2];c[b+204>>2]=c[a+440>>2];return 12727}function Th(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0.0,h=0.0,j=0.0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0;k=i;i=i+32|0;n=+g[a+56>>2];r=+g[a+72>>2]-n;m=+g[a+60>>2];p=+g[a+76>>2]-m;l=+g[a+64>>2];s=+g[a+80>>2]-l;o=+g[a+88>>2]-n;q=+g[a+92>>2]-m;h=+g[a+96>>2]-l;j=1.0/+O(+((r*q-p*o)*(r*q-p*o)+((p*h-s*q)*(p*h-s*q)+(s*o-r*h)*(s*o-r*h))));f=j*(p*h-s*q);h=j*(s*o-r*h);j=(r*q-p*o)*j;l=j*+g[b+8>>2]+(+g[b>>2]*f+ +g[b+4>>2]*h)-(f*n+h*m+j*l);if(!(l>=-d)|!(l<=d)){a=0;i=k;return a|0}e=0;while(1){mc[c[(c[a>>2]|0)+104>>2]&127](a,e,k+16|0,k);n=+g[k+16>>2];s=+g[k>>2]-n;p=+g[k+16+4>>2];o=+g[k+4>>2]-p;m=+g[k+16+8>>2];r=+g[k+8>>2]-m;q=1.0/+O(+((h*s-f*o)*(h*s-f*o)+((j*o-h*r)*(j*o-h*r)+(f*r-j*s)*(f*r-j*s))));e=e+1|0;if((h*s-f*o)*q*+g[b+8>>2]+(+g[b>>2]*q*(j*o-h*r)+ +g[b+4>>2]*q*(f*r-j*s))-(m*(h*s-f*o)*q+(n*q*(j*o-h*r)+p*q*(f*r-j*s)))<-d){e=0;b=5;break}if((e|0)>=3){e=1;b=5;break}}if((b|0)==5){i=k;return e|0}return 0}function Uh(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0;c[6435]=(c[6435]|0)+1;h=yc(55)|0;if(!h)j=0;else{c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}c[j>>2]=d;c[j+4>>2]=e;c[j+8>>2]=f;c[j+12>>2]=-1;c[j+16>>2]=-1;c[j+20>>2]=-1;c[j+28>>2]=-1;g[j+32>>2]=0.0;f=j;d=c[b+4>>2]|0;c[j+24>>2]=d;if((d|0)!=(c[b+8>>2]|0)){i=d;e=b+12|0;e=c[e>>2]|0;e=e+(i<<2)|0;c[e>>2]=f;i=i+1|0;c[b+4>>2]=i;return j|0}i=d|0?d<<1:1;if((d|0)>=(i|0)){i=d;e=b+12|0;e=c[e>>2]|0;e=e+(i<<2)|0;c[e>>2]=f;i=i+1|0;c[b+4>>2]=i;return j|0}if(!i)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((i<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}d=c[b+4>>2]|0}if((d|0)>0){e=0;do{c[h+(e<<2)>>2]=c[(c[b+12>>2]|0)+(e<<2)>>2];e=e+1|0}while((e|0)!=(d|0))}e=c[b+12>>2]|0;if(e){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[b+4>>2]|0}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=h;c[b+8>>2]=i;i=d;e=b+12|0;e=c[e>>2]|0;e=e+(i<<2)|0;c[e>>2]=f;i=i+1|0;c[b+4>>2]=i;return j|0}function Vh(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=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f+(y<<2)>>2]=(c[k>>2]=z,+g[k>>2])+ +g[a+28+(y<<2)>>2];l=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);o=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);l=l+ +g[f>>2];g[f>>2]=l;h=h+ +g[f+4>>2];g[f+4>>2]=h;o=o+ +g[f+8>>2];v=+N(+(+g[b>>2]));u=+N(+(+g[b+4>>2]));w=+N(+(+g[b+8>>2]));r=+N(+(+g[b+16>>2]));q=+N(+(+g[b+20>>2]));s=+N(+(+g[b+24>>2]));m=+N(+(+g[b+32>>2]));j=+N(+(+g[b+36>>2]));n=+N(+(+g[b+40>>2]));x=+g[b+48>>2];t=+g[b+52>>2];p=+g[b+56>>2];g[d>>2]=x-(o*w+(v*l+u*h));g[d+4>>2]=t-(o*s+(r*l+q*h));g[d+8>>2]=p-(o*n+(m*l+j*h));g[d+12>>2]=0.0;g[e>>2]=x+(o*w+(v*l+u*h));g[e+4>>2]=t+(o*s+(r*l+q*h));g[e+8>>2]=p+(o*n+(m*l+j*h));g[e+12>>2]=0.0;i=f;return}function Xh(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0;if(a[d+32>>0]&1){f=c[b+4>>2]|0;if(f|0)gj(f,d,e);f=c[b>>2]|0;if(f|0){n=+g[d>>2];l=+g[f+128>>2];m=+g[d+4>>2];k=+g[d+8>>2];h=+g[e+4>>2];p=+g[e+8>>2];o=+g[e>>2];j=+g[f+180>>2]*(k*h-m*p)+ +g[f+184>>2]*(n*p-k*o)+(m*o-n*h)*+g[f+188>>2];i=(k*h-m*p)*+g[f+196>>2]+(n*p-k*o)*+g[f+200>>2]+(m*o-n*h)*+g[f+204>>2];h=(k*h-m*p)*+g[f+212>>2]+(n*p-k*o)*+g[f+216>>2]+(m*o-n*h)*+g[f+220>>2];g[f+244>>2]=n*l+ +g[f+244>>2];g[f+248>>2]=l*m+ +g[f+248>>2];g[f+252>>2]=l*k+ +g[f+252>>2];g[f+316>>2]=n*l+ +g[f+316>>2];g[f+320>>2]=l*m+ +g[f+320>>2];g[f+324>>2]=l*k+ +g[f+324>>2];g[f+260>>2]=j+ +g[f+260>>2];g[f+264>>2]=i+ +g[f+264>>2];g[f+268>>2]=h+ +g[f+268>>2];g[f+332>>2]=j+ +g[f+332>>2];g[f+336>>2]=i+ +g[f+336>>2];g[f+340>>2]=h+ +g[f+340>>2];c[f+308>>2]=(c[f+308>>2]|0)+1}}if(!(a[d+32>>0]&2))return;jj(b,d+16|0,e);return}function Yh(a){a=a|0;var b=0,d=0,e=0,f=0;d=i;i=i+16|0;li(15122);Ab[c[(c[a>>2]|0)+8>>2]&255](a);Ab[c[(c[a>>2]|0)+12>>2]&255](a);b=c[a+24>>2]|0;li(15156);if(b|0){f=c[(c[b>>2]|0)+32>>2]|0;e=c[a+68>>2]|0;e=Eb[c[(c[e>>2]|0)+36>>2]&127](e)|0;mc[f&127](b,e,a+28|0,c[a+24>>2]|0)}a=c[2357]|0;f=(c[a+16>>2]|0)+-1|0;c[a+16>>2]=f;do if(!f){if(c[a+4>>2]|0){tb(d|0,0)|0;b=c[6434]|0;g[a+8>>2]=+g[a+8>>2]+ +(((c[d+4>>2]|0)-(c[b+4>>2]|0)+(((c[d>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[a+12>>2]|0)|0)>>>0)/1.0e3;b=c[2357]|0;if(c[a+16>>2]|0)break}else b=a;b=c[b+20>>2]|0;c[2357]=b}else b=a;while(0);a=b+16|0;f=(c[a>>2]|0)+-1|0;c[a>>2]=f;if(f|0){i=d;return}do if(c[b+4>>2]|0){tb(d|0,0)|0;e=c[6434]|0;f=b+8|0;g[f>>2]=+g[f>>2]+ +(((c[d+4>>2]|0)-(c[e+4>>2]|0)+(((c[d>>2]|0)-(c[e>>2]|0)|0)*1e6|0)-(c[b+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[a>>2]|0)){b=c[2357]|0;break}else{i=d;return}}while(0);c[2357]=c[b+20>>2];i=d;return}function Zh(b,d){b=b|0;d=d|0;var e=0;c[b>>2]=8840;a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=-1;c[b+16>>2]=0;c[b+20>>2]=0;a[b+100>>0]=1;c[b+96>>2]=0;c[b+88>>2]=0;c[b+92>>2]=0;a[b+120>>0]=1;c[b+116>>2]=0;c[b+108>>2]=0;c[b+112>>2]=0;c[b+64>>2]=0;c[b+68>>2]=0;c[b+72>>2]=-1;c[b+76>>2]=0;c[b+80>>2]=0;a[b+193>>0]=0;a[b+194>>0]=1;a[b+192>>0]=(d|0)!=0^1;g[b+140>>2]=0.0;c[b+144>>2]=0;c[b+164>>2]=0;c[b+148>>2]=1;c[b+152>>2]=0;c[b+156>>2]=10;c[b+160>>2]=1;c[b+168>>2]=0;c[b+172>>2]=0;g[b+176>>2]=0.0;if(d|0){e=d;d=b+136|0;c[d>>2]=e;d=b+188|0;c[d>>2]=0;d=b+180|0;c[d>>2]=0;d=b+184|0;c[d>>2]=0;b=b+124|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;return}c[6435]=(c[6435]|0)+1;d=yc(95)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}Ri(d);e=b+136|0;c[e>>2]=d;e=b+188|0;c[e>>2]=0;e=b+180|0;c[e>>2]=0;e=b+184|0;c[e>>2]=0;e=b+124|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;return}function _h(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0.0;i=c[b>>2]|0;if((i|0)==(c[a+80>>2]|0)){k=1.0;return +k}if(c[i+204>>2]&4|0){k=1.0;return +k}h=+g[b+8>>2];f=+g[b+12>>2];e=+g[b+16>>2];if(d){j=h;k=f}else{j=+g[i+4>>2]*h+ +g[i+8>>2]*f+ +g[i+12>>2]*e;k=h*+g[i+20>>2]+f*+g[i+24>>2]+e*+g[i+28>>2];e=h*+g[i+36>>2]+f*+g[i+40>>2]+e*+g[i+44>>2]}if(j*+g[a+84>>2]+k*+g[a+88>>2]+e*+g[a+92>>2]<+g[a+100>>2]){k=1.0;return +k}c[a+4>>2]=c[b+40>>2];c[a+76>>2]=i;if(d){c[a+44>>2]=c[b+8>>2];c[a+44+4>>2]=c[b+8+4>>2];c[a+44+8>>2]=c[b+8+8>>2];c[a+44+12>>2]=c[b+8+12>>2]}else{e=+g[b+8>>2];f=+g[b+12>>2];h=+g[b+16>>2];j=e*+g[i+20>>2]+f*+g[i+24>>2]+h*+g[i+28>>2];k=e*+g[i+36>>2]+f*+g[i+40>>2]+h*+g[i+44>>2];g[a+44>>2]=+g[i+4>>2]*e+ +g[i+8>>2]*f+ +g[i+12>>2]*h;g[a+48>>2]=j;g[a+52>>2]=k;g[a+56>>2]=0.0}c[a+60>>2]=c[b+24>>2];c[a+60+4>>2]=c[b+24+4>>2];c[a+60+8>>2]=c[b+24+8>>2];c[a+60+12>>2]=c[b+24+12>>2];k=+g[b+40>>2];return +k}function $h(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;d=c[b+16>>2]|0;if(d|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;d=c[b+40>>2]|0;if(d|0){if(a[b+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+40>>2]=0}a[b+44>>0]=1;c[b+40>>2]=0;c[b+32>>2]=0;c[b+36>>2]=0;d=c[b+60>>2]|0;if(d|0){if(a[b+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+60>>2]=0}a[b+64>>0]=1;c[b+60>>2]=0;c[b+52>>2]=0;c[b+56>>2]=0;if((c[b+12>>2]|0)>=2){Kf(b);return}c[6435]=(c[6435]|0)+1;d=yc(43)|0;if(!d)f=0;else{c[(d+4+15&-16)+-4>>2]=d;f=d+4+15&-16}d=c[b+8>>2]|0;if((d|0)>0){e=0;do{g=f+(e*12|0)|0;h=(c[b+16>>2]|0)+(e*12|0)|0;c[g>>2]=c[h>>2];c[g+4>>2]=c[h+4>>2];c[g+8>>2]=c[h+8>>2];e=e+1|0}while((e|0)!=(d|0))}d=c[b+16>>2]|0;if(d|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=f;c[b+12>>2]=2;Kf(b);return}function ai(a,b,e){a=a|0;b=b|0;e=e|0;si(a,b,e)|0;c[b+52>>2]=c[a+52>>2];c[b+56>>2]=c[a+56>>2];c[b+60>>2]=c[a+60>>2];c[b+64>>2]=c[a+64>>2];c[b+68>>2]=c[a+68>>2];c[b+72>>2]=c[a+72>>2];c[b+76>>2]=c[a+76>>2];c[b+80>>2]=c[a+80>>2];c[b+84>>2]=c[a+84>>2];c[b+88>>2]=c[a+88>>2];c[b+92>>2]=c[a+92>>2];c[b+96>>2]=c[a+96>>2];c[b+100>>2]=c[a+100>>2];c[b+104>>2]=c[a+104>>2];c[b+108>>2]=c[a+108>>2];c[b+112>>2]=c[a+112>>2];c[b+116>>2]=c[a+116>>2];c[b+120>>2]=c[a+120>>2];c[b+124>>2]=c[a+124>>2];c[b+128>>2]=c[a+128>>2];c[b+132>>2]=c[a+132>>2];c[b+136>>2]=c[a+136>>2];c[b+140>>2]=c[a+140>>2];c[b+144>>2]=c[a+144>>2];c[b+148>>2]=c[a+148>>2];c[b+152>>2]=c[a+152>>2];c[b+156>>2]=c[a+156>>2];c[b+160>>2]=c[a+160>>2];c[b+164>>2]=c[a+164>>2];c[b+168>>2]=c[a+168>>2];c[b+172>>2]=c[a+172>>2];c[b+176>>2]=c[a+176>>2];c[b+180>>2]=c[a+188>>2];c[b+184>>2]=c[a+184>>2];c[b+188>>2]=c[a+196>>2];c[b+192>>2]=c[a+192>>2];c[b+196>>2]=d[a+180>>0];c[b+200>>2]=d[a+49>>0];return 12680}function bi(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0;e=i;i=i+32|0;d=c[b+388>>2]|0;switch(c[a+388>>2]&48&d|0){case 32:{if((a|0)==(b|0)&(d&64|0)==0){i=e;return}g[e+4>>2]=1.0;c[e+8>>2]=0;c[e+8+4>>2]=0;c[e+8+8>>2]=0;c[e+8+12>>2]=0;c[e>>2]=3540;c[e+8>>2]=c[a+456>>2];d=c[a+192>>2]|0;f=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);d=c[b+192>>2]|0;g[e+12>>2]=f+ +Sb[c[(c[d>>2]|0)+48>>2]&15](d);c[e+16>>2]=c[(+g[a+316>>2]<+g[b+316>>2]?a+316|0:b+316|0)>>2];c[e+24>>2]=a;c[e+28>>2]=b;We(c[a+1048>>2]|0,c[b+1048>>2]|0,e);i=e;return}case 16:{if((a|0)==(b|0)){i=e;return}c[e>>2]=3576;d=c[a+192>>2]|0;f=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);d=c[b+192>>2]|0;g[e+12>>2]=f+ +Sb[c[(c[d>>2]|0)+48>>2]&15](d);c[e+4>>2]=a;c[e+8>>2]=b;We(c[a+928>>2]|0,c[b+988>>2]|0,e);c[e+4>>2]=b;c[e+8>>2]=a;We(c[b+928>>2]|0,c[a+988>>2]|0,e);i=e;return}default:{i=e;return}}}function ci(a,d,e,f){a=a|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0;h=i;i=i+96|0;g[h+4>>2]=1.0;c[h+8>>2]=0;b[h+12>>1]=1;b[h+14>>1]=-1;c[h+16>>2]=0;c[h>>2]=2948;c[h+20>>2]=c[d>>2];c[h+20+4>>2]=c[d+4>>2];c[h+20+8>>2]=c[d+8>>2];c[h+20+12>>2]=c[d+12>>2];c[h+36>>2]=c[e>>2];c[h+36+4>>2]=c[e+4>>2];c[h+36+8>>2]=c[e+8>>2];c[h+36+12>>2]=c[e+12>>2];a=c[a+4>>2]|0;mc[c[(c[a>>2]|0)+32>>2]&127](a,d,e,h);d=c[h+8>>2]|0;if(!d){f=0;i=h;return f|0}if(!(c[d+236>>2]&2)){f=0;i=h;return f|0}if(c[d+204>>2]&4|0){f=0;i=h;return f|0}c[f>>2]=c[h+68>>2];c[f+4>>2]=c[h+68+4>>2];c[f+8>>2]=c[h+68+8>>2];c[f+12>>2]=c[h+68+12>>2];c[f+16>>2]=c[h+52>>2];c[f+16+4>>2]=c[h+52+4>>2];c[f+16+8>>2]=c[h+52+8>>2];c[f+16+12>>2]=c[h+52+12>>2];m=+g[f+16>>2];l=+g[f+20>>2];k=+g[f+24>>2];j=1.0/+O(+(m*m+l*l+k*k));g[f+16>>2]=m*j;g[f+20>>2]=l*j;g[f+24>>2]=k*j;c[f+32>>2]=c[h+4>>2];f=d;i=h;return f|0}function di(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b+288|0;f=d;g=e+104|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(g|0));i=c[d+108>>2]|0;e=c[b+396>>2]|0;a:do if((e|0)>(i|0))e=b+404|0;else{if((e|0)<(i|0)?(c[b+400>>2]|0)<(i|0):0){if((i|0)!=0?(c[6435]=(c[6435]|0)+1,h=yc((i<<2|3)+16|0)|0,(h|0)!=0):0){c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}else h=0;f=c[b+396>>2]|0;g=0;while(1){if((g|0)>=(f|0))break;c[h+(g<<2)>>2]=c[(c[b+404>>2]|0)+(g<<2)>>2];g=g+1|0}f=c[b+404>>2]|0;if(f|0){if(!((a[b+408>>0]&1)==0|(f|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+404>>2]=0}a[b+408>>0]=1;c[b+404>>2]=h;c[b+400>>2]=i}while(1){if((e|0)>=(i|0)){e=b+404|0;break a}c[(c[b+404>>2]|0)+(e<<2)>>2]=0;e=e+1|0}}while(0);c[b+396>>2]=i;e=c[e>>2]|0;f=0;while(1){if((f|0)>=(i|0))break;c[e+(f<<2)>>2]=c[(c[d+116>>2]|0)+(f<<2)>>2];f=f+1|0}Yi(b+412|0,d+124|0);Yi(b+432|0,d+144|0);return}function ei(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;Ab[c[(c[b>>2]|0)+32>>2]&255](b);d=Ob[c[(c[b>>2]|0)+16>>2]&63](b,104,1)|0;e=c[d+8>>2]|0;f=e;g=f+104|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(g|0));c[e+88>>2]=c[a+248>>2];c[e+92>>2]=c[a+252>>2];c[e+96>>2]=c[a+256>>2];c[e+100>>2]=c[a+260>>2];c[e>>2]=c[a+92>>2];c[e+4>>2]=c[a+96>>2];c[e+8>>2]=c[a+100>>2];c[e+12>>2]=c[a+104>>2];c[e+16>>2]=c[a+108>>2];c[e+20>>2]=c[a+116>>2];c[e+24>>2]=c[a+120>>2];c[e+28>>2]=c[a+124>>2];c[e+32>>2]=c[a+128>>2];c[e+36>>2]=c[a+132>>2];c[e+40>>2]=c[a+140>>2];c[e+44>>2]=c[a+144>>2];c[e+48>>2]=c[a+148>>2];c[e+52>>2]=c[a+152>>2];c[e+56>>2]=c[a+168>>2];c[e+60>>2]=c[a+172>>2];c[e+64>>2]=c[a+112>>2];c[e+68>>2]=c[a+156>>2];c[e+72>>2]=c[a+160>>2];c[e+76>>2]=c[a+164>>2];c[e+80>>2]=c[a+136>>2];yb[c[(c[b>>2]|0)+20>>2]&31](b,d,11938,1145853764,e);mj(a,b);td(a,b);Ab[c[(c[b>>2]|0)+36>>2]&255](b);return}function fi(b,d){b=b|0;d=d|0;if((c[b+16>>2]|0)!=(0-(c[b+76>>2]|0)|0))return;d=c[b+4>>2]|0;if(d|0)xn(b+4|0,d);d=c[b+8>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+8>>2]=0;c[b+12>>2]=-1;d=c[b+36>>2]|0;if(d|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;c[b+20>>2]=0;d=c[b+64>>2]|0;if(d|0)xn(b+64|0,d);d=c[b+68>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+68>>2]=0;c[b+72>>2]=-1;d=c[b+96>>2]|0;if(d|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=0;c[b+88>>2]=0;c[b+92>>2]=0;c[b+80>>2]=0;a[b+193>>0]=0;a[b+194>>0]=1;c[b+144>>2]=0;c[b+164>>2]=0;c[b+148>>2]=1;c[b+152>>2]=0;c[b+156>>2]=10;c[b+160>>2]=1;c[b+124>>2]=0;c[b+124+4>>2]=0;c[b+124+8>>2]=0;c[b+168>>2]=0;c[b+168+4>>2]=0;c[b+168+8>>2]=0;c[b+168+12>>2]=0;c[b+168+16>>2]=0;c[b+168+20>>2]=0;return}function gi(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0,k=0.0;j=i;i=i+32|0;c[j+16>>2]=c[d>>2];c[j+16+4>>2]=c[d+4>>2];c[j+16+8>>2]=c[d+8>>2];c[j+16+12>>2]=c[d+12>>2];e=+g[j+16>>2];h=+g[j+16+4>>2];f=+g[j+16+8>>2];if(e*e+h*h+f*f<1.4210854715202004e-14){c[j+16>>2]=-1082130432;c[j+16+4>>2]=-1082130432;c[j+16+8>>2]=-1082130432;g[j+16+12>>2]=0.0;e=-1.0;h=-1.0;f=-1.0}k=1.0/+O(+(e*e+h*h+f*f));g[j+16>>2]=e*k;g[j+16+4>>2]=h*k;g[j+16+8>>2]=f*k;Gd(j,b,j+16|0);switch(c[b+4>>2]|0){case 8:{e=+g[b+28>>2]*+g[b+12>>2];break}case 0:{e=+g[b+44>>2];break}case 1:{e=+g[b+44>>2];break}case 13:{e=+g[b+44>>2];break}case 11:{e=+g[b+44>>2];break}case 10:{e=+g[b+44>>2];break}case 4:case 5:{e=+g[b+44>>2];break}default:e=+Sb[c[(c[b>>2]|0)+48>>2]&15](b)}h=e*+g[j+16+4>>2]+ +g[j+4>>2];k=e*+g[j+16+8>>2]+ +g[j+8>>2];g[a>>2]=e*+g[j+16>>2]+ +g[j>>2];g[a+4>>2]=h;g[a+8>>2]=k;g[a+12>>2]=0.0;i=j;return}function hi(a,b){a=a|0;b=b|0;var d=0.0,e=0,f=0.0,h=0.0,i=0.0,j=0.0;c[a+4>>2]=35;c[a+8>>2]=0;c[a+12>>2]=1065353216;c[a+16>>2]=1065353216;c[a+20>>2]=1065353216;g[a+24>>2]=0.0;g[a+44>>2]=.03999999910593033;c[a>>2]=8140;c[a+52>>2]=1;h=+g[b>>2];f=+g[b+4>>2];d=+g[b+8>>2];d=+g[b+((h>2]*.10000000149011612;if(d<.03999999910593033){j=+xz(a);i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);j=j+ +g[a+28>>2];i=i+ +g[a+32>>2];h=h+ +g[a+36>>2];g[a+44>>2]=d;d=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);f=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=h-+Sb[c[(c[a>>2]|0)+48>>2]&15](a);g[a+28>>2]=j-d;g[a+32>>2]=i-f;g[a+36>>2]=h;g[a+40>>2]=0.0;e=c[a>>2]|0}else e=8140;h=+Sb[c[e+48>>2]&15](a);i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);j=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);i=+g[b+4>>2]*+g[a+16>>2]-i;j=+g[b+8>>2]*+g[a+20>>2]-j;g[a+28>>2]=+g[b>>2]*+g[a+12>>2]-h;g[a+32>>2]=i;g[a+36>>2]=j;g[a+40>>2]=0.0;c[a+4>>2]=13;return}function ii(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,j=0,l=0,m=0,n=0,o=0.0;m=i;i=i+80|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;e=+g[d>>2];f=+g[d+4>>2];h=+g[d+8>>2];if(e*e+f*f+h*h<9.999999747378752e-05){l=1065353216;j=0;e=0.0;d=0}else{o=1.0/+O(+(e*e+f*f+h*h));l=(g[k>>2]=e*o,c[k>>2]|0);n=(g[k>>2]=f*o,c[k>>2]|0);j=(g[k>>2]=h*o,c[k>>2]|0);e=+g[d+12>>2];d=n}c[m+32>>2]=7824;n=m+32+4|0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;g[m+32+20>>2]=-999999984306749440.0;c[m+32+24>>2]=l;c[m+32+28>>2]=d;c[m+32+32>>2]=j;g[m+32+36>>2]=e;c[m+16>>2]=1566444395;c[m+16+4>>2]=1566444395;c[m+16+8>>2]=1566444395;g[m+16+12>>2]=0.0;b=c[b+92>>2]|0;l=c[(c[b>>2]|0)+8>>2]|0;g[m>>2]=-999999984306749440.0;g[m+4>>2]=-999999984306749440.0;g[m+8>>2]=-999999984306749440.0;g[m+12>>2]=0.0;mc[l&127](b,m+32|0,m,m+16|0);c[a>>2]=c[n>>2];c[a+4>>2]=c[n+4>>2];c[a+8>>2]=c[n+8>>2];c[a+12>>2]=c[n+12>>2];i=m;return}function ji(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,h=0.0,i=0,j=0.0,k=0.0,l=0,m=0.0;e=+g[b+60>>2]*.5;l=c[b+68>>2]|0;h=+g[d>>2];j=+g[d+4>>2];k=+g[d+8>>2];k=+O(+(h*h+j*j+k*k));f=c[b+64>>2]|0;do if(!(+g[d+(l<<2)>>2]>k*+g[b+52>>2])){h=+g[d+(f<<2)>>2];i=c[b+72>>2]|0;j=+g[d+(i<<2)>>2];k=+O(+(h*h+j*j));if(k>1.1920928955078125e-07){k=+g[b+56>>2]/k;g[a+(f<<2)>>2]=h*k;g[a+(l<<2)>>2]=-e;g[a+(i<<2)>>2]=j*k;break}else{g[a+(f<<2)>>2]=0.0;g[a+(l<<2)>>2]=-e;g[a+(i<<2)>>2]=0.0;break}}else{g[a+(f<<2)>>2]=0.0;g[a+(l<<2)>>2]=e;g[a+(c[b+72>>2]<<2)>>2]=0.0}while(0);if(!(+Sb[c[(c[b>>2]|0)+48>>2]&15](b)!=0.0))return;h=+g[d>>2];j=+g[d+4>>2];k=+g[d+8>>2];m=h*h+j*j+k*k<1.4210854715202004e-14?-1.0:h;e=h*h+j*j+k*k<1.4210854715202004e-14?-1.0:j;k=h*h+j*j+k*k<1.4210854715202004e-14?-1.0:k;j=1.0/+O(+(k*k+(m*m+e*e)));h=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);g[a>>2]=+g[a>>2]+h*j*m;g[a+4>>2]=h*j*e+ +g[a+4>>2];g[a+8>>2]=h*j*k+ +g[a+8>>2];return}function ki(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;g=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=g;if(g|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+28>>2]=c[a+28>>2];c[b+32>>2]=c[a+32>>2];c[b+36>>2]=c[a+36>>2];c[b+40>>2]=c[a+40>>2];c[b+12>>2]=c[a+12>>2];c[b+16>>2]=c[a+16>>2];c[b+20>>2]=c[a+20>>2];c[b+24>>2]=c[a+24>>2];c[b+44>>2]=c[a+44>>2];f=c[a+96>>2]|0;c[b+60>>2]=f;if(!f){c[b+52>>2]=0;c[b+56>>2]=0;return 17310}c[b+52>>2]=Zb[c[(c[d>>2]|0)+28>>2]&31](d,c[a+104>>2]|0)|0;c[b+56>>2]=0;g=Ob[c[(c[d>>2]|0)+16>>2]&63](d,16,f)|0;if((f|0)>0){e=c[a+104>>2]|0;b=0;a=c[g+8>>2]|0;while(1){c[a>>2]=c[e+(b<<4)>>2];c[a+4>>2]=c[e+(b<<4)+4>>2];c[a+8>>2]=c[e+(b<<4)+8>>2];c[a+12>>2]=c[e+(b<<4)+12>>2];b=b+1|0;if((b|0)==(f|0))break;else a=a+16|0}}else e=c[a+104>>2]|0;yb[c[(c[d>>2]|0)+20>>2]&31](d,g,19308,1497453121,e);return 17310}function li(a){a=a|0;var b=0,d=0,e=0,f=0;f=i;i=i+16|0;d=c[2357]|0;if((c[d>>2]|0)==(a|0))b=d;else{b=c[d+24>>2]|0;a:do if(!b)e=5;else while(1){if((c[b>>2]|0)==(a|0))break a;b=c[b+28>>2]|0;if(!b){e=5;break}}while(0);do if((e|0)==5){while(1){b=yc(36)|0;if(b|0){e=9;break}b=c[6564]|0;c[6564]=b+0;if(!b){e=8;break}jc[b&3]();e=5}if((e|0)==8){f=Ya(4)|0;c[f>>2]=9640;pb(f|0,2800,251)}else if((e|0)==9){c[b>>2]=a;c[b+4>>2]=0;c[b+4+4>>2]=0;c[b+4+8>>2]=0;c[b+4+12>>2]=0;c[b+20>>2]=d;c[b+24>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;Vq(b);c[b+28>>2]=c[d+24>>2];c[d+24>>2]=b;break}}while(0);c[2357]=b}a=b+4|0;c[a>>2]=(c[a>>2]|0)+1;a=b+16|0;e=c[a>>2]|0;c[a>>2]=e+1;if(e|0){i=f;return}tb(f|0,0)|0;e=c[6434]|0;c[b+12>>2]=(c[f+4>>2]|0)-(c[e+4>>2]|0)+(((c[f>>2]|0)-(c[e>>2]|0)|0)*1e6|0);i=f;return}function mi(a,b,d){a=a|0;b=b|0;d=d|0;c[a+300>>2]=c[b>>2];c[a+300+4>>2]=c[b+4>>2];c[a+300+8>>2]=c[b+8>>2];c[a+300+12>>2]=c[b+12>>2];c[a+316>>2]=c[b+16>>2];c[a+316+4>>2]=c[b+16+4>>2];c[a+316+8>>2]=c[b+16+8>>2];c[a+316+12>>2]=c[b+16+12>>2];c[a+332>>2]=c[b+32>>2];c[a+332+4>>2]=c[b+32+4>>2];c[a+332+8>>2]=c[b+32+8>>2];c[a+332+12>>2]=c[b+32+12>>2];c[a+348>>2]=c[b+48>>2];c[a+348+4>>2]=c[b+48+4>>2];c[a+348+8>>2]=c[b+48+8>>2];c[a+348+12>>2]=c[b+48+12>>2];c[a+364>>2]=c[d>>2];c[a+364+4>>2]=c[d+4>>2];c[a+364+8>>2]=c[d+8>>2];c[a+364+12>>2]=c[d+12>>2];c[a+380>>2]=c[d+16>>2];c[a+380+4>>2]=c[d+16+4>>2];c[a+380+8>>2]=c[d+16+8>>2];c[a+380+12>>2]=c[d+16+12>>2];c[a+396>>2]=c[d+32>>2];c[a+396+4>>2]=c[d+32+4>>2];c[a+396+8>>2]=c[d+32+8>>2];c[a+396+12>>2]=c[d+32+12>>2];c[a+412>>2]=c[d+48>>2];c[a+412+4>>2]=c[d+48+4>>2];c[a+412+8>>2]=c[d+48+8>>2];c[a+412+12>>2]=c[d+48+12>>2];Ab[c[(c[a>>2]|0)+8>>2]&255](a);return}function ni(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0.0;m=c[a+4>>2]|0;a=c[a+64>>2]|0;do if(!m)if(!a){e=0.0;n=0.0;j=0.0;l=0.0;h=0.0;k=0.0;i=0.0;f=0.0}else{e=+g[a>>2];n=+g[a+12>>2];j=+g[a+16>>2];l=+g[a+20>>2];h=+g[a+24>>2];k=+g[a+28>>2];i=+g[a+4>>2];f=+g[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l*k+j*h-f*e)*d;Yd(a,c+32|0);i=c;return}function pi(b){b=b|0;var d=0;d=c[b>>2]|0;if(d|0)xn(b,d);d=c[b+4>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+4>>2]=0;c[b+8>>2]=-1;d=c[b+32>>2]|0;if(d|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;c[b+16>>2]=0;d=c[b+52>>2]|0;if(!d){a[b+56>>0]=1;c[b+52>>2]=0;c[b+44>>2]=0;c[b+48>>2]=0;a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;return}if(!(a[b+56>>0]|0)){a[b+56>>0]=1;c[b+52>>2]=0;c[b+44>>2]=0;c[b+48>>2]=0;a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;return}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);d=c[b+32>>2]|0;a[b+56>>0]=1;c[b+52>>2]=0;c[b+44>>2]=0;c[b+48>>2]=0;if(!d){a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;return}if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0;a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;return}function qi(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;if(!e)e=c[b+188>>2]|0;j=c[d>>2]|0;f=c[b+268>>2]|0;a:do if((f|0)>0){h=c[b+276>>2]|0;g=0;while(1){if((c[h+(g<<2)>>2]|0)==(j|0))break;g=g+1|0;if((g|0)>=(f|0))break a}if((g|0)!=(f|0))return}while(0);if((f|0)==(c[b+272>>2]|0)?(i=f|0?f<<1:1,(f|0)<(i|0)):0){if(!i)h=0;else{c[6435]=(c[6435]|0)+1;f=yc((i<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=f;f=c[b+268>>2]|0}if((f|0)>0){g=0;do{c[h+(g<<2)>>2]=c[(c[b+276>>2]|0)+(g<<2)>>2];g=g+1|0}while((g|0)!=(f|0))}g=c[b+276>>2]|0;if(g){if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0);f=c[b+268>>2]|0}c[b+276>>2]=0}a[b+280>>0]=1;c[b+276>>2]=h;c[b+272>>2]=i}c[(c[b+276>>2]|0)+(f<<2)>>2]=j;c[b+268>>2]=f+1;b=c[b+284>>2]|0;Ob[c[(c[b>>2]|0)+8>>2]&63](b,e,d)|0;return}function ri(b){b=b|0;var d=0;if((a[22496]|0)==0?Wa(22496)|0:0){if((a[22456]|0)==0?Wa(22456)|0:0){if((a[22464]|0)==0?Wa(22464)|0:0){c[5698]=1065353216;c[5699]=0;c[5700]=0;c[5701]=0;c[5702]=0;c[5703]=1065353216;c[5704]=0;c[5705]=0;c[5706]=0;c[5707]=0;c[5708]=1065353216;g[5709]=0.0;_a(22464)}c[5710]=c[5698];c[5711]=c[5699];c[5712]=c[5700];c[5713]=c[5701];c[5714]=c[5702];c[5715]=c[5703];c[5716]=c[5704];c[5717]=c[5705];c[5718]=c[5706];c[5719]=c[5707];c[5720]=c[5708];c[5721]=c[5709];c[5722]=0;c[5723]=0;c[5724]=0;c[5725]=0;_a(22456)}c[5755]=c[5710];c[5756]=c[5711];c[5757]=c[5712];c[5758]=c[5713];c[5759]=c[5714];c[5760]=c[5715];c[5761]=c[5716];c[5762]=c[5717];c[5763]=c[5718];c[5764]=c[5719];c[5765]=c[5720];c[5766]=c[5721];c[5767]=c[5722];c[5768]=c[5723];c[5769]=c[5724];c[5770]=c[5725];_a(22496)}d=c[b+8>>2]|0;if(!d){b=c[b>>2]|0;return ((b|0)==0?23020:b+60|0)|0}else return d+4|0;return 0}function si(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0;c[b>>2]=Zb[c[(c[e>>2]|0)+28>>2]&31](e,c[a+28>>2]|0)|0;c[b+4>>2]=Zb[c[(c[e>>2]|0)+28>>2]&31](e,c[a+32>>2]|0)|0;f=Zb[c[(c[e>>2]|0)+40>>2]&31](e,a)|0;g=Zb[c[(c[e>>2]|0)+28>>2]&31](e,f)|0;c[b+8>>2]=g;if(g|0)Cb[c[(c[e>>2]|0)+48>>2]&127](e,f);c[b+12>>2]=c[a+4>>2];c[b+24>>2]=d[a+21>>0];c[b+40>>2]=c[a+24>>2];c[b+44>>2]=c[a+16>>2];c[b+48>>2]=d[a+20>>0];c[b+20>>2]=c[a+12>>2];c[b+16>>2]=c[a+8>>2];c[b+28>>2]=c[a+36>>2];c[b+32>>2]=c[a+40>>2];c[b+36>>2]=0;f=c[a+28>>2]|0;if((c[f+488>>2]|0)>0){e=0;do{if((c[(c[f+496>>2]|0)+(e<<2)>>2]|0)==(a|0)){c[b+36>>2]=1;f=c[a+28>>2]|0}e=e+1|0}while((e|0)<(c[f+488>>2]|0))}f=c[a+32>>2]|0;if((c[f+488>>2]|0)>0)e=0;else return 12632;do{if((c[(c[f+496>>2]|0)+(e<<2)>>2]|0)==(a|0)){c[b+36>>2]=1;f=c[a+32>>2]|0}e=e+1|0}while((e|0)<(c[f+488>>2]|0));return 12632}function ti(b,d,e,f){b=+b;d=d|0;e=e|0;f=f|0;var h=0,i=0;while(1){h=yc(140)|0;if(h|0){i=6;break}h=c[6564]|0;c[6564]=h+0;if(!h){i=5;break}jc[h&3]()}if((i|0)==5){f=Ya(4)|0;c[f>>2]=9640;pb(f|0,2800,251)}else if((i|0)==6){g[h>>2]=b;c[h+4>>2]=d;c[h+72>>2]=e;c[h+76>>2]=c[f>>2];c[h+76+4>>2]=c[f+4>>2];c[h+76+8>>2]=c[f+8>>2];c[h+76+12>>2]=c[f+12>>2];g[h+92>>2]=0.0;g[h+96>>2]=0.0;g[h+100>>2]=.5;g[h+104>>2]=0.0;g[h+108>>2]=0.0;g[h+112>>2]=.800000011920929;g[h+116>>2]=1.0;a[h+120>>0]=0;g[h+124>>2]=.004999999888241291;g[h+128>>2]=.009999999776482582;g[h+132>>2]=.009999999776482582;g[h+136>>2]=.009999999776482582;c[h+8>>2]=1065353216;c[h+12>>2]=0;c[h+12+4>>2]=0;c[h+12+8>>2]=0;c[h+12+12>>2]=0;c[h+28>>2]=1065353216;c[h+32>>2]=0;c[h+32+4>>2]=0;c[h+32+8>>2]=0;c[h+32+12>>2]=0;c[h+48>>2]=1065353216;c[h+52>>2]=0;c[h+52+4>>2]=0;c[h+52+8>>2]=0;c[h+52+12>>2]=0;c[h+52+16>>2]=0;return h|0}return 0}function ui(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;if(Eb[c[(c[d>>2]|0)+16>>2]&127](d)|0)return;j=c[b+712>>2]|0;i=Eb[c[(c[d>>2]|0)+36>>2]&127](d)|0;if(Eb[c[(c[d>>2]|0)+8>>2]&127](d)|0?(f=Eb[c[(c[d>>2]|0)+20>>2]&127](d)|0,h=Eb[c[(c[d>>2]|0)+24>>2]&127](d)|0,(j|0)>0):0){e=c[b+720>>2]|0;g=0;a=i+(f<<2)|0;while(1){k=c[e+(g*104|0)+12>>2]|0;f=c[e+(g*104|0)+16>>2]|0;c[a>>2]=c[e+(g*104|0)+8>>2];c[a+4>>2]=k;c[a+8>>2]=f;g=g+1|0;if((g|0)==(j|0))break;else a=a+(h<<2)|0}}if(!(Eb[c[(c[d>>2]|0)+12>>2]&127](d)|0))return;a=Eb[c[(c[d>>2]|0)+28>>2]&127](d)|0;g=Eb[c[(c[d>>2]|0)+32>>2]&127](d)|0;if((j|0)<=0)return;f=c[b+720>>2]|0;a=i+(a<<2)|0;e=0;while(1){b=c[f+(e*104|0)+76>>2]|0;k=c[f+(e*104|0)+80>>2]|0;c[a>>2]=c[f+(e*104|0)+72>>2];c[a+4>>2]=b;c[a+8>>2]=k;e=e+1|0;if((e|0)==(j|0))break;else a=a+(g<<2)|0}return}function vi(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0,j=0,k=0.0,l=0,m=0.0,n=0.0,o=0,p=0,q=0;q=i;i=i+16|0;if((e|0)<=0){i=q;return}p=0;do{o=d+(p<<4)|0;f=+g[a+60>>2]*.5;h=c[a+68>>2]|0;k=+g[b+(p<<4)>>2];m=+g[b+(p<<4)+4>>2];n=+g[b+(p<<4)+8>>2];n=+O(+(k*k+m*m+n*n));j=c[a+64>>2]|0;do if(!(+g[b+(p<<4)+(h<<2)>>2]>n*+g[a+52>>2])){k=+g[b+(p<<4)+(j<<2)>>2];l=c[a+72>>2]|0;m=+g[b+(p<<4)+(l<<2)>>2];n=+O(+(k*k+m*m));if(n>1.1920928955078125e-07){n=+g[a+56>>2]/n;g[q+(j<<2)>>2]=k*n;g[q+(h<<2)>>2]=-f;g[q+(l<<2)>>2]=m*n;break}else{g[q+(j<<2)>>2]=0.0;g[q+(h<<2)>>2]=-f;g[q+(l<<2)>>2]=0.0;break}}else{g[q+(j<<2)>>2]=0.0;g[q+(h<<2)>>2]=f;g[q+(c[a+72>>2]<<2)>>2]=0.0}while(0);c[o>>2]=c[q>>2];c[o+4>>2]=c[q+4>>2];c[o+8>>2]=c[q+8>>2];c[o+12>>2]=c[q+12>>2];p=p+1|0}while((p|0)!=(e|0));i=q;return}function wi(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;c[b>>2]=9352;d=c[b+56>>2]|0;if(d|0){if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+56>>2]=0}a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;e=c[b+28>>2]|0;if((e|0)>0){j=0;do{f=c[b+36>>2]|0;g=f+(j*36|0)+4|0;h=f+(j*36|0)+12|0;i=c[h>>2]|0;d=f+(j*36|0)+16|0;if(i|0){if(a[d>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[i+-4>>2]|0)}c[h>>2]=0}a[d>>0]=1;c[h>>2]=0;c[g>>2]=0;c[f+(j*36|0)+8>>2]=0;j=j+1|0}while((j|0)!=(e|0))}d=c[b+36>>2]|0;if(d|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;d=c[b+16>>2]|0;if(!d){a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}function xi(b){b=b|0;var d=0;c[b>>2]=8452;d=c[b+156>>2]|0;if(d|0){if(a[b+160>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+156>>2]=0}a[b+160>>0]=1;c[b+156>>2]=0;c[b+148>>2]=0;c[b+152>>2]=0;d=c[b+136>>2]|0;if(d|0){if(a[b+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+136>>2]=0}a[b+140>>0]=1;c[b+136>>2]=0;c[b+128>>2]=0;c[b+132>>2]=0;d=c[b+116>>2]|0;if(d|0){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+116>>2]=0}a[b+120>>0]=1;c[b+116>>2]=0;c[b+108>>2]=0;c[b+112>>2]=0;d=c[b+96>>2]|0;if(d|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=0;c[b+88>>2]=0;c[b+92>>2]=0;c[b>>2]=9368;d=c[b+32>>2]|0;if(!d){a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;b=b+28|0;c[b>>2]=0;return}if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0;a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;b=b+28|0;c[b>>2]=0;return}function yi(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;i=c[b+4>>2]|0;if((i|0)>=(d|0)){c[b+4>>2]=d;return}if((c[b+8>>2]|0)<(d|0)){if(!d){f=0;g=i}else{c[6435]=(c[6435]|0)+1;f=yc((d<<4|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}g=c[b+4>>2]|0}if((g|0)>0){h=0;do{j=c[b+12>>2]|0;c[f+(h<<4)>>2]=c[j+(h<<4)>>2];c[f+(h<<4)+4>>2]=c[j+(h<<4)+4>>2];c[f+(h<<4)+8>>2]=c[j+(h<<4)+8>>2];c[f+(h<<4)+12>>2]=c[j+(h<<4)+12>>2];h=h+1|0}while((h|0)!=(g|0))}g=c[b+12>>2]|0;if(g|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=f;c[b+8>>2]=d;g=b+12|0}else g=b+12|0;f=i;do{j=c[g>>2]|0;c[j+(f<<4)>>2]=c[e>>2];c[j+(f<<4)+4>>2]=c[e+4>>2];c[j+(f<<4)+8>>2]=c[e+8>>2];c[j+(f<<4)+12>>2]=c[e+12>>2];f=f+1|0}while((f|0)!=(d|0));c[b+4>>2]=d;return}function zi(b){b=b|0;var d=0,e=0;c[6435]=(c[6435]|0)+1;d=yc(635)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+164>>2]=1065353216;c[d+168>>2]=1065353216;c[d+172>>2]=1065353216;g[d+176>>2]=0.0;c[d+180>>2]=0;g[d+184>>2]=999999984306749440.0;e=d+188|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[d+204>>2]=1;c[d+208>>2]=-1;c[d+212>>2]=-1;c[d+216>>2]=1;g[d+220>>2]=0.0;g[d+224>>2]=.5;g[d+228>>2]=0.0;g[d+232>>2]=0.0;c[d+236>>2]=1;c[d+240>>2]=0;g[d+244>>2]=1.0;e=d+248|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[d+4>>2]=1065353216;e=d+8|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[d+24>>2]=1065353216;e=d+28|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[d+44>>2]=1065353216;e=d+48|0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;c[e+16>>2]=0;c[d>>2]=4108;a[d+500>>0]=1;c[d+496>>2]=0;c[d+488>>2]=0;c[d+492>>2]=0;Od(d,b);return d|0}function Ai(b){b=b|0;var d=0;c[b>>2]=9012;d=c[b+160>>2]|0;if(d|0){if(a[b+164>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+160>>2]=0}a[b+164>>0]=1;c[b+160>>2]=0;c[b+152>>2]=0;c[b+156>>2]=0;d=c[b+136>>2]|0;if(d|0){if(a[b+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+136>>2]=0}a[b+140>>0]=1;c[b+136>>2]=0;c[b+128>>2]=0;c[b+132>>2]=0;d=c[b+116>>2]|0;if(d|0){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+116>>2]=0}a[b+120>>0]=1;c[b+116>>2]=0;c[b+108>>2]=0;c[b+112>>2]=0;d=c[b+96>>2]|0;if(d|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=0;c[b+88>>2]=0;c[b+92>>2]=0;d=c[b+76>>2]|0;if(!d){a[b+80>>0]=1;c[b+76>>2]=0;c[b+68>>2]=0;b=b+72|0;c[b>>2]=0;return}if(a[b+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+76>>2]=0;a[b+80>>0]=1;c[b+76>>2]=0;c[b+68>>2]=0;b=b+72|0;c[b>>2]=0;return}function Bi(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;do if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)==(e|0)?(c[d+28>>2]|0)!=1:0)c[d+28>>2]=f}else{if((b|0)!=(c[d>>2]|0)){b=c[b+8>>2]|0;yb[c[(c[b>>2]|0)+24>>2]&31](b,d,e,f,g);break}if((c[d+16>>2]|0)!=(e|0)?(c[d+20>>2]|0)!=(e|0):0){c[d+32>>2]=f;if((c[d+44>>2]|0)==4)break;a[d+52>>0]=0;a[d+53>>0]=0;b=c[b+8>>2]|0;Qb[c[(c[b>>2]|0)+20>>2]&7](b,d,e,e,1,g);if(a[d+53>>0]|0)if(!(a[d+52>>0]|0)){f=1;b=13}else b=17;else{f=0;b=13}do if((b|0)==13){c[d+20>>2]=e;c[d+40>>2]=(c[d+40>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0){a[d+54>>0]=1;if(f){b=17;break}else{f=4;break}}if(f)b=17;else f=4}while(0);if((b|0)==17)f=3;c[d+44>>2]=f;break}if((f|0)==1)c[d+32>>2]=1}while(0);return}function Ci(b){b=b|0;var d=0;c[b>>2]=4816;d=c[b+144>>2]|0;if(d|0){if(a[b+148>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+144>>2]=0}a[b+148>>0]=1;c[b+144>>2]=0;c[b+136>>2]=0;c[b+140>>2]=0;d=c[b+76>>2]|0;if(d|0){if(a[b+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+76>>2]=0}a[b+80>>0]=1;c[b+76>>2]=0;c[b+68>>2]=0;c[b+72>>2]=0;d=c[b+56>>2]|0;if(d|0){if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+56>>2]=0}a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;d=c[b+36>>2]|0;if(d|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;d=c[b+16>>2]|0;if(!d){a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}function Di(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0;o=(+g[a+32>>2]-+g[a+16>>2])*+g[a+108>>2]*.5;m=(+g[a+36>>2]-+g[a+20>>2])*+g[a+112>>2]*.5;k=(+g[a+40>>2]-+g[a+24>>2])*+g[a+116>>2]*.5;t=+N(+(+g[b>>2]));s=+N(+(+g[b+4>>2]));r=+N(+(+g[b+8>>2]));n=+N(+(+g[b+16>>2]));l=+N(+(+g[b+20>>2]));j=+N(+(+g[b+24>>2]));w=+N(+(+g[b+32>>2]));v=+N(+(+g[b+36>>2]));f=+N(+(+g[b+40>>2]));u=+g[b+48>>2];p=+g[b+52>>2];h=+g[b+56>>2];q=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);f=o*w+m*v+k*f+ +Sb[c[(c[a>>2]|0)+48>>2]&15](a);g[d>>2]=u-(o*t+m*s+k*r+q);g[d+4>>2]=p-(o*n+m*l+k*j+i);g[d+8>>2]=h-f;g[d+12>>2]=0.0;g[e>>2]=u+(o*t+m*s+k*r+q);g[e+4>>2]=p+(o*n+m*l+k*j+i);g[e+8>>2]=h+f;g[e+12>>2]=0.0;return}function Ei(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0;c[6435]=(c[6435]|0)+1;e=yc(379)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e+4>>2]=3;c[e>>2]=4432;c[e+8>>2]=-1;c[e+12>>2]=-1;g[e+16>>2]=3402823466385288598117041.0e14;a[e+20>>0]=1;a[e+21>>0]=0;c[e+24>>2]=-1;c[e+28>>2]=b;Il();c[e+32>>2]=23268;g[e+36>>2]=0.0;g[e+40>>2]=.30000001192092896;c[e+44>>2]=0;c[e>>2]=4544;l=e+300|0;c[l>>2]=c[d>>2];c[l+4>>2]=c[d+4>>2];c[l+8>>2]=c[d+8>>2];c[l+12>>2]=c[d+12>>2];k=+g[d>>2];j=+g[d+4>>2];i=+g[d+8>>2];h=k*+g[b+20>>2]+j*+g[b+24>>2]+i*+g[b+28>>2]+ +g[b+56>>2];f=k*+g[b+36>>2]+j*+g[b+40>>2]+i*+g[b+44>>2]+ +g[b+60>>2];g[e+316>>2]=k*+g[b+4>>2]+j*+g[b+8>>2]+i*+g[b+12>>2]+ +g[b+52>>2];g[e+320>>2]=h;g[e+324>>2]=f;g[e+328>>2]=0.0;c[e+332>>2]=0;a[e+344>>0]=0;g[e+348>>2]=.30000001192092896;g[e+352>>2]=1.0;g[e+356>>2]=0.0;return e|0}function Fi(b,d,e){b=+b;d=d|0;e=e|0;var f=0,h=0;while(1){f=yc(140)|0;if(f|0){h=6;break}f=c[6564]|0;c[6564]=f+0;if(!f){h=5;break}jc[f&3]()}if((h|0)==5){e=Ya(4)|0;c[e>>2]=9640;pb(e|0,2800,251)}else if((h|0)==6){g[f>>2]=b;c[f+4>>2]=d;c[f+72>>2]=e;c[f+76>>2]=0;c[f+76+4>>2]=0;c[f+76+8>>2]=0;c[f+76+12>>2]=0;c[f+76+16>>2]=0;c[f+76+20>>2]=0;g[f+100>>2]=.5;g[f+104>>2]=0.0;g[f+108>>2]=0.0;g[f+112>>2]=.800000011920929;g[f+116>>2]=1.0;a[f+120>>0]=0;g[f+124>>2]=.004999999888241291;g[f+128>>2]=.009999999776482582;g[f+132>>2]=.009999999776482582;g[f+136>>2]=.009999999776482582;c[f+8>>2]=1065353216;c[f+12>>2]=0;c[f+12+4>>2]=0;c[f+12+8>>2]=0;c[f+12+12>>2]=0;c[f+28>>2]=1065353216;c[f+32>>2]=0;c[f+32+4>>2]=0;c[f+32+8>>2]=0;c[f+32+12>>2]=0;c[f+48>>2]=1065353216;c[f+52>>2]=0;c[f+52+4>>2]=0;c[f+52+8>>2]=0;c[f+52+12>>2]=0;c[f+52+16>>2]=0;return f|0}return 0}function Gi(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;e=c[b>>2]|0;if((e|0)==(c[a+80>>2]|0)){f=1.0;return +f}if(c[e+204>>2]&4|0){f=1.0;return +f}if((+g[a+28>>2]-+g[a+12>>2])*+g[b+8>>2]+(+g[a+32>>2]-+g[a+16>>2])*+g[b+12>>2]+(+g[a+36>>2]-+g[a+20>>2])*+g[b+16>>2]>=-+g[a+84>>2]){f=1.0;return +f}c[a+4>>2]=c[b+40>>2];c[a+76>>2]=e;if(d){c[a+44>>2]=c[b+8>>2];c[a+44+4>>2]=c[b+8+4>>2];c[a+44+8>>2]=c[b+8+8>>2];c[a+44+12>>2]=c[b+8+12>>2]}else{k=+g[b+8>>2];j=+g[b+12>>2];i=+g[b+16>>2];h=k*+g[e+20>>2]+j*+g[e+24>>2]+i*+g[e+28>>2];f=k*+g[e+36>>2]+j*+g[e+40>>2]+i*+g[e+44>>2];g[a+44>>2]=+g[e+4>>2]*k+ +g[e+8>>2]*j+ +g[e+12>>2]*i;g[a+48>>2]=h;g[a+52>>2]=f;g[a+56>>2]=0.0}c[a+60>>2]=c[b+24>>2];c[a+60+4>>2]=c[b+24+4>>2];c[a+60+8>>2]=c[b+24+8>>2];c[a+60+12>>2]=c[b+24+12>>2];k=+g[b+40>>2];return +k}function Hi(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0;j=i;i=i+80|0;if((e|0)>0)f=0;else{i=j;return}do{g[d+(f<<4)+12>>2]=-999999984306749440.0;f=f+1|0}while((f|0)!=(e|0));f=j+32+4|0;h=0;do{k=b+(h<<4)|0;c[j+32>>2]=7824;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;g[j+32+20>>2]=-999999984306749440.0;c[j+32+24>>2]=c[k>>2];c[j+32+24+4>>2]=c[k+4>>2];c[j+32+24+8>>2]=c[k+8>>2];c[j+32+24+12>>2]=c[k+12>>2];c[j+16>>2]=1566444395;c[j+16+4>>2]=1566444395;c[j+16+8>>2]=1566444395;g[j+16+12>>2]=0.0;k=c[a+92>>2]|0;l=c[(c[k>>2]|0)+8>>2]|0;g[j>>2]=-999999984306749440.0;g[j+4>>2]=-999999984306749440.0;g[j+8>>2]=-999999984306749440.0;g[j+12>>2]=0.0;mc[l&127](k,j+32|0,j,j+16|0);k=d+(h<<4)|0;c[k>>2]=c[f>>2];c[k+4>>2]=c[f+4>>2];c[k+8>>2]=c[f+8>>2];c[k+12>>2]=c[f+12>>2];h=h+1|0}while((h|0)<(e|0));i=j;return}function Ii(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;f=c[b+96>>2]|0;if((f|0)==(c[b+100>>2]|0)?(i=f|0?f<<1:1,(f|0)<(i|0)):0){if(!i)h=0;else{c[6435]=(c[6435]|0)+1;f=yc((i<<4|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=f;f=c[b+96>>2]|0}if((f|0)>0){g=0;do{j=h+(g<<4)|0;k=(c[b+104>>2]|0)+(g<<4)|0;c[j>>2]=c[k>>2];c[j+4>>2]=c[k+4>>2];c[j+8>>2]=c[k+8>>2];c[j+12>>2]=c[k+12>>2];g=g+1|0}while((g|0)!=(f|0))}f=c[b+104>>2]|0;if(f|0){if(a[b+108>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+104>>2]=0}a[b+108>>0]=1;c[b+104>>2]=h;c[b+100>>2]=i;f=c[b+96>>2]|0}k=(c[b+104>>2]|0)+(f<<4)|0;c[k>>2]=c[d>>2];c[k+4>>2]=c[d+4>>2];c[k+8>>2]=c[d+8>>2];c[k+12>>2]=c[d+12>>2];c[b+96>>2]=(c[b+96>>2]|0)+1;if(!e)return;vj(b);return}function Ji(b){b=b|0;var d=0,e=0,f=0,h=0;c[b+32>>2]=262144;h=c[b+4>>2]|0;if((h|0)<2383){if((c[b+8>>2]|0)<2383){c[6435]=(c[6435]|0)+1;d=yc(9551)|0;if(!d)f=0;else{c[(d+4+15&-16)+-4>>2]=d;f=d+4+15&-16}d=c[b+4>>2]|0;if((d|0)>0){e=0;do{c[f+(e<<2)>>2]=c[(c[b+12>>2]|0)+(e<<2)>>2];e=e+1|0}while((e|0)!=(d|0))}d=c[b+12>>2]|0;if(d|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=f;c[b+8>>2]=2383;e=b+12|0}else e=b+12|0;d=h;do{c[(c[e>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=2383)}c[b+4>>2]=2383;e=0;do{h=(c[b+12>>2]|0)+(e<<2)|0;d=c[h>>2]|0;c[h>>2]=0;if(d|0)do{h=d;d=c[d+280>>2]|0;hd(h)}while((d|0)!=0);e=e+1|0}while((e|0)!=2383);g[b+20>>2]=.25;c[b+24>>2]=0;c[b+28>>2]=0;c[b+36>>2]=1;c[b+40>>2]=1;return}function Ki(){var b=0,d=0;c[6435]=(c[6435]|0)+1;b=yc(303)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}c[b+164>>2]=1065353216;c[b+168>>2]=1065353216;c[b+172>>2]=1065353216;g[b+176>>2]=0.0;c[b+180>>2]=0;g[b+184>>2]=999999984306749440.0;d=b+188|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[b+204>>2]=1;c[b+208>>2]=-1;c[b+212>>2]=-1;c[b+216>>2]=1;g[b+220>>2]=0.0;g[b+224>>2]=.5;g[b+228>>2]=0.0;g[b+232>>2]=0.0;c[b+240>>2]=0;g[b+244>>2]=1.0;d=b+248|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[b+4>>2]=1065353216;d=b+8|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[b+24>>2]=1065353216;d=b+28|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[b+44>>2]=1065353216;d=b+48|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[b>>2]=5044;a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;c[b+272>>2]=0;c[b+236>>2]=4;return b|0}function Li(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0.0,r=0,s=0.0,t=0;if((e|0)>0)f=0;else return;do{g[d+(f<<4)+12>>2]=-999999984306749440.0;f=f+1|0}while((f|0)!=(e|0));p=0;do{h=+g[a+12>>2];i=+g[b+(p<<4)>>2]*h;j=+g[a+16>>2];k=+g[b+(p<<4)+4>>2]*j;l=+g[a+20>>2];m=+g[b+(p<<4)+8>>2]*l;f=c[a+96>>2]|0;if((f|0)>0){n=c[a+104>>2]|0;o=0;q=-3402823466385288598117041.0e14;r=-1;do{s=i*+g[n+(o<<4)>>2]+k*+g[n+(o<<4)+4>>2]+m*+g[n+(o<<4)+8>>2];t=s>q;r=t?o:r;q=t?s:q;o=o+1|0}while((o|0)!=(f|0));m=+g[n+(r<<4)+4>>2]*j;s=+g[n+(r<<4)+8>>2]*l;g[d+(p<<4)>>2]=+g[n+(r<<4)>>2]*h;g[d+(p<<4)+4>>2]=m;g[d+(p<<4)+8>>2]=s;g[d+(p<<4)+12>>2]=q}else g[d+(p<<4)+12>>2]=-999999984306749440.0;p=p+1|0}while((p|0)!=(e|0));return}function Mi(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;i=i+96|0;b=c[b>>2]|0;if((b|0)==(c[a+4>>2]|0)){i=d;return 1}e=c[a+12>>2]|0;if(!(Zb[c[(c[e>>2]|0)+8>>2]&31](e,c[b+188>>2]|0)|0)){i=d;return 1}e=c[a+4>>2]|0;f=c[e+192>>2]|0;c[d+64>>2]=0;c[d+64+4>>2]=f;c[d+64+8>>2]=e;c[d+64+12>>2]=e+4;c[d+64+16>>2]=-1;c[d+64+20>>2]=-1;e=c[b+192>>2]|0;c[d+40>>2]=0;c[d+40+4>>2]=e;c[d+40+8>>2]=b;c[d+40+12>>2]=b+4;c[d+40+16>>2]=-1;c[d+40+20>>2]=-1;b=c[(c[a+8>>2]|0)+24>>2]|0;b=Ib[c[(c[b>>2]|0)+8>>2]&31](b,d+64|0,d+40|0,0)|0;if(b|0){f=c[a+12>>2]|0;c[d+4>>2]=0;c[d+8>>2]=d+64;c[d+12>>2]=d+40;c[d>>2]=5976;c[d+32>>2]=f;yb[c[(c[b>>2]|0)+8>>2]&31](b,d+64|0,d+40|0,(c[a+8>>2]|0)+28|0,d);Ab[c[c[b>>2]>>2]&255](b);f=c[(c[a+8>>2]|0)+24>>2]|0;Cb[c[(c[f>>2]|0)+60>>2]&127](f,b)}i=d;return 1}function Ni(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,h=0,j=0,k=0,l=0;l=i;i=i+80|0;h=c[c[a>>2]>>2]|0;j=c[c[a+4>>2]>>2]|0;if(!(Ob[c[(c[b>>2]|0)+24>>2]&63](b,h,j)|0)){i=l;return}f=c[h+192>>2]|0;c[l+56>>2]=0;c[l+56+4>>2]=f;c[l+56+8>>2]=h;c[l+56+12>>2]=h+4;c[l+56+16>>2]=-1;c[l+56+20>>2]=-1;f=c[j+192>>2]|0;c[l+32>>2]=0;c[l+32+4>>2]=f;c[l+32+8>>2]=j;c[l+32+12>>2]=j+4;c[l+32+16>>2]=-1;c[l+32+20>>2]=-1;f=c[a+8>>2]|0;if(!f){f=Ib[c[(c[b>>2]|0)+8>>2]&31](b,l+56|0,l+32|0,0)|0;c[a+8>>2]=f;if(f|0)k=4}else k=4;if((k|0)==4){c[l>>2]=5604;c[l+4>>2]=0;c[l+8>>2]=l+56;c[l+12>>2]=l+32;if((c[d+8>>2]|0)!=1){e=+Mb[c[(c[f>>2]|0)+12>>2]&15](f,h,j,d,l);if(+g[d+12>>2]>e)g[d+12>>2]=e}else yb[c[(c[f>>2]|0)+8>>2]&31](f,l+56|0,l+32|0,d,l)}i=l;return}function Oi(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;i=c[d+4>>2]|0;f=c[b+24>>2]|0;if((f|0)<(i|0)){if((c[b+28>>2]|0)<(i|0)){if(!i){e=0;g=f}else{c[6435]=(c[6435]|0)+1;e=yc((i<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}g=c[b+24>>2]|0}if((g|0)>0){h=0;do{c[e+(h<<2)>>2]=c[(c[b+32>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(g|0))}g=c[b+32>>2]|0;if(g|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=e;c[b+28>>2]=i;e=b+32|0}else e=b+32|0;do{c[(c[e>>2]|0)+(f<<2)>>2]=0;f=f+1|0}while((f|0)!=(i|0))}else e=b+32|0;c[b+24>>2]=i;e=c[e>>2]|0;if((i|0)<=0)return;f=0;do{c[e+(f<<2)>>2]=c[(c[d+12>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(i|0));return}function Pi(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=c[b+488>>2]|0;a:do if((e|0)>0){g=c[b+496>>2]|0;f=0;while(1){if((c[g+(f<<2)>>2]|0)==(d|0))break;f=f+1|0;if((f|0)>=(e|0))break a}if((f|0)!=(e|0)){b=b+256|0;c[b>>2]=1;return}}while(0);if((e|0)==(c[b+492>>2]|0)?(h=e|0?e<<1:1,(e|0)<(h|0)):0){if(!h)g=0;else{c[6435]=(c[6435]|0)+1;e=yc((h<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}g=e;e=c[b+488>>2]|0}if((e|0)>0){f=0;do{c[g+(f<<2)>>2]=c[(c[b+496>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(e|0))}f=c[b+496>>2]|0;if(f){if(a[b+500>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);e=c[b+488>>2]|0}c[b+496>>2]=0}a[b+500>>0]=1;c[b+496>>2]=g;c[b+492>>2]=h}c[(c[b+496>>2]|0)+(e<<2)>>2]=d;c[b+488>>2]=e+1;b=b+256|0;c[b>>2]=1;return}function Qi(a,b,c,d,e,f,h,i,j,k,l){a=a|0;b=b|0;c=+c;d=+d;e=+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f+(e<<4)+12>>2]=c[g+(e<<4)+12>>2];e=e+1|0}while((e|0)!=(d|0))}d=c[b+16>>2]|0;if(!d){a[b+20>>0]=1;c[b+16>>2]=f;c[b+12>>2]=2;Hf(b);return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=f;c[b+12>>2]=2;Hf(b);return}function Si(a,b,d){a=a|0;b=b|0;d=d|0;do if(!((b|0)==32&(d|0)==32)){if((b|0)==32){if((d|0)<20){b=a+96|0;break}if((d+-21|0)>>>0<9){b=a+104|0;break}}else{if((b|0)<20&(d|0)==32){b=a+100|0;break}if((b+-21|0)>>>0<9&(d|0)==32){b=a+108|0;break}if((b|0)==8&(d|0)==8){b=a+60|0;break}if((b|0)==8&(d|0)==1){b=a+76|0;break}if((b|0)==1&(d|0)==8){b=a+80|0;break}}if(!(d|b)){b=a+72|0;break}if((b|0)<20&(d|0)==28){b=a+88|0;break}if((b|0)==28&(d|0)<20){b=a+84|0;break}if((b|0)<20){if((d|0)<20){b=a+32|0;break}if((d+-21|0)>>>0<9){b=a+36|0;break}}else{if((d|0)<20&(b+-21|0)>>>0<9){b=a+40|0;break}if((b|0)==31)if((d|0)==31){b=a+48|0;break}else{b=a+44|0;break}}if((d|0)==31){b=a+52|0;break}else{b=a+56|0;break}}else b=a+92|0;while(0);return c[b>>2]|0}function Ti(a,b,d,e,f,h,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;o=i;i=i+16|0;li(12899);Xb[c[(c[a>>2]|0)+32>>2]&1](a,b,d,e,f,h,j,k,l);n=c[a+184>>2]|0;m=c[k+20>>2]|0;m=(n|0)>(m|0)?n:m;if((m|0)>0){n=0;do{+$b[c[(c[a>>2]|0)+40>>2]&3](a,n,b,d,e,f,h,j,k,l);n=n+1|0}while((n|0)<(m|0))}m=c[2357]|0;a=(c[m+16>>2]|0)+-1|0;c[m+16>>2]=a;if(a|0){i=o;return 0.0}do if(c[m+4>>2]|0){tb(o|0,0)|0;a=c[6434]|0;g[m+8>>2]=+g[m+8>>2]+ +(((c[o+4>>2]|0)-(c[a+4>>2]|0)+(((c[o>>2]|0)-(c[a>>2]|0)|0)*1e6|0)-(c[m+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[m+16>>2]|0)){m=c[2357]|0;break}else{i=o;return 0.0}}while(0);c[2357]=c[m+20>>2];i=o;return 0.0}function Ui(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=c[d>>2]|0;d=c[b+268>>2]|0;a:do if((d|0)>0){f=c[b+276>>2]|0;e=0;while(1){if((c[f+(e<<2)>>2]|0)==(g|0))break;e=e+1|0;if((e|0)>=(d|0))break a}if((e|0)!=(d|0))return}while(0);if((d|0)==(c[b+272>>2]|0)?(h=d|0?d<<1:1,(d|0)<(h|0)):0){if(!h)f=0;else{c[6435]=(c[6435]|0)+1;d=yc((h<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}f=d;d=c[b+268>>2]|0}if((d|0)>0){e=0;do{c[f+(e<<2)>>2]=c[(c[b+276>>2]|0)+(e<<2)>>2];e=e+1|0}while((e|0)!=(d|0))}e=c[b+276>>2]|0;if(e){if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[b+268>>2]|0}c[b+276>>2]=0}a[b+280>>0]=1;c[b+276>>2]=f;c[b+272>>2]=h}c[(c[b+276>>2]|0)+(d<<2)>>2]=g;c[b+268>>2]=d+1;return}function Vi(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;f=c[a+232>>2]|0;a:do if((f|0)>0){g=c[a+240>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0))break a}if((d|0)<(f|0)){c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+240>>2]|0)+(f+-1<<2)>>2]=b;c[a+232>>2]=f+-1}}while(0);d=c[b+188>>2]|0;if(d|0){g=c[a+68>>2]|0;g=Eb[c[(c[g>>2]|0)+36>>2]&127](g)|0;ic[c[(c[g>>2]|0)+40>>2]&127](g,d,c[a+24>>2]|0);g=c[a+68>>2]|0;ic[c[(c[g>>2]|0)+12>>2]&127](g,d,c[a+24>>2]|0);c[b+188>>2]=0}f=c[a+8>>2]|0;if((f|0)<=0)return;g=c[a+16>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0)){h=15;break}}if((h|0)==15)return;if((d|0)>=(f|0))return;c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+16>>2]|0)+(f+-1<<2)>>2]=b;c[a+8>>2]=f+-1;return}function Wi(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;f=c[a+328>>2]|0;a:do if((f|0)>0){g=c[a+336>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0))break a}if((d|0)<(f|0)){c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+336>>2]|0)+(f+-1<<2)>>2]=b;c[a+328>>2]=f+-1}}while(0);d=c[b+188>>2]|0;if(d|0){g=c[a+68>>2]|0;g=Eb[c[(c[g>>2]|0)+36>>2]&127](g)|0;ic[c[(c[g>>2]|0)+40>>2]&127](g,d,c[a+24>>2]|0);g=c[a+68>>2]|0;ic[c[(c[g>>2]|0)+12>>2]&127](g,d,c[a+24>>2]|0);c[b+188>>2]=0}f=c[a+8>>2]|0;if((f|0)<=0)return;g=c[a+16>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0)){h=15;break}}if((h|0)==15)return;if((d|0)>=(f|0))return;c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+16>>2]|0)+(f+-1<<2)>>2]=b;c[a+8>>2]=f+-1;return}function Xi(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=c[d+4>>2]|0;e=c[b+872>>2]|0;a:do if((e|0)>(i|0))e=b+880|0;else{if((e|0)<(i|0)?(c[b+876>>2]|0)<(i|0):0){if((i|0)!=0?(c[6435]=(c[6435]|0)+1,f=yc((i<<2|3)+16|0)|0,(f|0)!=0):0){c[(f+4+15&-16)+-4>>2]=f;h=f+4+15&-16}else h=0;f=c[b+872>>2]|0;g=0;while(1){if((g|0)>=(f|0))break;c[h+(g<<2)>>2]=c[(c[b+880>>2]|0)+(g<<2)>>2];g=g+1|0}f=c[b+880>>2]|0;if(f|0){if(!((a[b+884>>0]&1)==0|(f|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+880>>2]=0}a[b+884>>0]=1;c[b+880>>2]=h;c[b+876>>2]=i}while(1){if((e|0)>=(i|0)){e=b+880|0;break a}c[(c[b+880>>2]|0)+(e<<2)>>2]=0;e=e+1|0}}while(0);c[b+872>>2]=i;e=c[e>>2]|0;f=0;while(1){if((f|0)>=(i|0))break;c[e+(f<<2)>>2]=c[(c[d+12>>2]|0)+(f<<2)>>2];f=f+1|0}return}function Yi(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;i=c[d+4>>2]|0;e=c[b+4>>2]|0;a:do if((e|0)>(i|0))e=b+12|0;else{if((e|0)<(i|0)?(c[b+8>>2]|0)<(i|0):0){if((i|0)!=0?(c[6435]=(c[6435]|0)+1,f=yc((i<<2|3)+16|0)|0,(f|0)!=0):0){c[(f+4+15&-16)+-4>>2]=f;h=f+4+15&-16}else h=0;f=c[b+4>>2]|0;g=0;while(1){if((g|0)>=(f|0))break;c[h+(g<<2)>>2]=c[(c[b+12>>2]|0)+(g<<2)>>2];g=g+1|0}f=c[b+12>>2]|0;if(f|0){if(!((a[b+16>>0]&1)==0|(f|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=h;c[b+8>>2]=i}while(1){if((e|0)>=(i|0)){e=b+12|0;break a}c[(c[b+12>>2]|0)+(e<<2)>>2]=0;e=e+1|0}}while(0);c[b+4>>2]=i;e=c[e>>2]|0;f=0;while(1){if((f|0)>=(i|0))break;c[e+(f<<2)>>2]=c[(c[d+12>>2]|0)+(f<<2)>>2];f=f+1|0}return}function Zi(b){b=b|0;var d=0,e=0;d=c[b+92>>2]|0;if(d|0){if(a[b+96>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+92>>2]=0}a[b+96>>0]=1;c[b+92>>2]=0;c[b+84>>2]=0;c[b+88>>2]=0;d=c[b+64>>2]|0;if(d|0)do{c[b+64>>2]=c[d+8>>2];e=c[d>>2]|0;if(e|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);d=c[b+64>>2]|0}while((d|0)!=0);d=c[b+48>>2]|0;if(d|0)do{c[b+48>>2]=c[d+8>>2];e=c[d>>2]|0;if(e|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);d=c[b+48>>2]|0}while((d|0)!=0);d=c[b+32>>2]|0;if(!d)return;do{c[b+32>>2]=c[d+8>>2];e=c[d>>2]|0;if(e|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);d=c[b+32>>2]|0}while((d|0)!=0);return}function _i(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;h=c[d>>2]|0;h=Zb[c[(c[h>>2]|0)+56>>2]&31](h,28)|0;j=(a[b+4>>0]|0)==0;i=c[b+8>>2]|0;g=c[b+12>>2]|0;b=c[d>>2]|0;c[h+4>>2]=b;c[h>>2]=5480;a[h+8>>0]=0;c[h+12>>2]=0;if(j){a[h+16>>0]=0;c[h+20>>2]=i;c[h+24>>2]=g;if(!(Ob[c[(c[b>>2]|0)+24>>2]&63](b,c[e+8>>2]|0,c[f+8>>2]|0)|0))return h|0;j=c[h+4>>2]|0;c[h+12>>2]=Ob[c[(c[j>>2]|0)+12>>2]&63](j,c[e+8>>2]|0,c[f+8>>2]|0)|0;a[h+8>>0]=1;return h|0}else{a[h+16>>0]=1;c[h+20>>2]=i;c[h+24>>2]=g;if(!(Ob[c[(c[b>>2]|0)+24>>2]&63](b,c[f+8>>2]|0,c[e+8>>2]|0)|0))return h|0;j=c[h+4>>2]|0;c[h+12>>2]=Ob[c[(c[j>>2]|0)+12>>2]&63](j,c[f+8>>2]|0,c[e+8>>2]|0)|0;a[h+8>>0]=1;return h|0}return 0}function $i(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;c[a+4>>2]=c[b+40>>2];e=c[b>>2]|0;c[a+76>>2]=e;if(d){c[a+44>>2]=c[b+8>>2];c[a+44+4>>2]=c[b+8+4>>2];c[a+44+8>>2]=c[b+8+8>>2];c[a+44+12>>2]=c[b+8+12>>2];a=a+60|0;d=b+24|0;c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];f=+g[b+40>>2];return +f}else{k=+g[b+8>>2];j=+g[b+12>>2];i=+g[b+16>>2];h=+g[e+20>>2]*k+ +g[e+24>>2]*j+ +g[e+28>>2]*i;f=+g[e+36>>2]*k+ +g[e+40>>2]*j+ +g[e+44>>2]*i;g[a+44>>2]=+g[e+4>>2]*k+ +g[e+8>>2]*j+ +g[e+12>>2]*i;g[a+48>>2]=h;g[a+52>>2]=f;g[a+56>>2]=0.0;a=a+60|0;d=b+24|0;c[a>>2]=c[d>>2];c[a+4>>2]=c[d+4>>2];c[a+8>>2]=c[d+8>>2];c[a+12>>2]=c[d+12>>2];f=+g[b+40>>2];return +f}return 0.0}function aj(){var b=0,d=0;c[6435]=(c[6435]|0)+1;b=yc(791)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}c[b>>2]=1025;c[b+116>>2]=0;a[b+120>>0]=0;d=b+124|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;c[b+300>>2]=0;a[b+304>>0]=0;d=b+308|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;c[b+484>>2]=0;a[b+488>>0]=0;d=b+492|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;c[b+668>>2]=0;a[b+672>>0]=0;d=b+676|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;c[b+740>>2]=0;c[b+744>>2]=0;c[b+748>>2]=0;c[b+768>>2]=0;return b|0}function bj(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0.0,k=0.0,l=0,m=0;f=i;i=i+48|0;if((c[b+136>>2]|0)<=0){i=f;return}e=0;do{m=c[b+144>>2]|0;c[f+32>>2]=(a[m+(e*284|0)+84>>0]|0)==0?1065353216:0;c[f+32+4>>2]=0;c[f+32+8>>2]=1065353216;g[f+32+12>>2]=0.0;l=m+(e*284|0)+140|0;c[f+16>>2]=c[l>>2];c[f+16+4>>2]=c[l+4>>2];c[f+16+8>>2]=c[l+8>>2];c[f+16+12>>2]=c[l+12>>2];l=c[b+120>>2]|0;h=c[(c[d>>2]|0)+8>>2]|0;k=+g[m+(e*284|0)+108+(l<<2)>>2]+ +g[f+16+4>>2];j=+g[m+(e*284|0)+124+(l<<2)>>2]+ +g[f+16+8>>2];g[f>>2]=+g[m+(e*284|0)+92+(l<<2)>>2]+ +g[f+16>>2];g[f+4>>2]=k;g[f+8>>2]=j;g[f+12>>2]=0.0;mc[h&127](d,f+16|0,f,f+32|0);mc[c[(c[d>>2]|0)+8>>2]&127](d,f+16|0,(c[b+144>>2]|0)+(e*284|0)+16|0,f+32|0);e=e+1|0}while((e|0)<(c[b+136>>2]|0));i=f;return}function cj(d,e,f,g,h,i){d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;if((d|0)==(c[e+8>>2]|0))zl(e,f,g,h);else{l=b[e+52>>1]|0;j=c[d+12>>2]|0;a[e+52>>0]=0;a[e+53>>0]=0;On(d+16|0,e,f,g,h,i);a:do if((j|0)>1){m=d+24|0;do{if(a[e+54>>0]|0)break a;k=b[e+52>>1]|0;if(!((k&255)<<24>>24)){if((k&65535)>=256?(c[d+8>>2]&1|0)==0:0)break a}else{if((c[e+24>>2]|0)==1)break a;if(!(c[d+8>>2]&2))break a}a[e+52>>0]=0;a[e+53>>0]=0;On(m,e,f,g,h,i);m=m+8|0}while(m>>>0<(d+16+(j<<3)|0)>>>0)}while(0);a[e+52>>0]=l;a[e+53>>0]=(l&65535)>>>8}return}function dj(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;switch(b|0){case 2:{if((e|0)<1){g[a+232>>2]=d;c[a+300>>2]=c[a+300>>2]|512;return}if((e|0)<3){g[a+264>>2]=d;c[a+300>>2]=c[a+300>>2]|32;return}if((e|0)==3){g[a+248>>2]=d;c[a+300>>2]=c[a+300>>2]|2048;return}if((e|0)>=6)return;g[a+280>>2]=d;c[a+300>>2]=c[a+300>>2]|128;return}case 3:{if((e|0)<1){g[a+212>>2]=d;c[a+300>>2]=c[a+300>>2]|1;return}if((e|0)!=3)return;g[a+228>>2]=d;c[a+300>>2]=c[a+300>>2]|4;return}case 4:{if((e|0)<1){g[a+244>>2]=d;c[a+300>>2]=c[a+300>>2]|256;return}if((e|0)<3){g[a+276>>2]=d;c[a+300>>2]=c[a+300>>2]|16;return}if((e|0)==3){g[a+260>>2]=d;c[a+300>>2]=c[a+300>>2]|1024;return}if((e|0)>=6)return;g[a+292>>2]=d;c[a+300>>2]=c[a+300>>2]|64;return}default:return}}function ej(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;f=i;i=i+240|0;c[f+80>>2]=d;d=f+96|0;e=d+40|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(e|0));c[f+136>>2]=c[f+80>>2];if((Bc(0,b,f+136|0,f,f+96|0)|0)>=0){d=c[2359]|0;if((a[9510]|0)<1)c[2359]=d&-33;if(!(c[2371]|0)){e=c[2370]|0;c[2370]=f+152;c[2366]=f+152;c[2364]=f+152;c[2371]=80;c[2363]=f+152+80;Bc(9436,b,f+136|0,f,f+96|0)|0;if(e|0){Ob[c[9472>>2]&63](9436,0,0)|0;c[2370]=e;c[2371]=0;c[2363]=0;c[2366]=0;c[2364]=0}}else Bc(9436,b,f+136|0,f,f+96|0)|0;c[2359]=c[2359]|d&32}d=(a[9511]|0)==10;do if((c[2378]|0)<0){if(!d?(g=c[2364]|0,g>>>0<(c[2363]|0)>>>0):0){c[2364]=g+1;a[g>>0]=10;break}om(9436,10)|0}else{if(!d?(h=c[2364]|0,h>>>0<(c[2363]|0)>>>0):0){c[2364]=h+1;a[h>>0]=10;break}om(9436,10)|0}while(0);Va()}function fj(a,b,d){a=a|0;b=+b;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0;e=i;i=i+96|0;c[e+32>>2]=1065353216;c[e+32+4>>2]=0;c[e+32+4+4>>2]=0;c[e+32+4+8>>2]=0;c[e+32+4+12>>2]=0;c[e+32+20>>2]=1065353216;c[e+32+24>>2]=0;c[e+32+24+4>>2]=0;c[e+32+24+8>>2]=0;c[e+32+24+12>>2]=0;c[e+32+40>>2]=1065353216;l=e+32+44|0;c[l>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;c[l+16>>2]=0;mc[c[(c[a>>2]|0)+8>>2]&127](a,e+32|0,e+16|0,e);j=(+g[e>>2]-+g[e+16>>2])*.5;h=(+g[e+4>>2]-+g[e+16+4>>2])*.5;k=(+g[e+8>>2]-+g[e+16+8>>2])*.5;f=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);g[d>>2]=b*.0833333283662796*((h+f)*2.0*(h+f)*2.0+(k+f)*2.0*(k+f)*2.0);g[d+4>>2]=b*.0833333283662796*((j+f)*2.0*(j+f)*2.0+(k+f)*2.0*(k+f)*2.0);g[d+8>>2]=b*.0833333283662796*((j+f)*2.0*(j+f)*2.0+(h+f)*2.0*(h+f)*2.0);g[d+12>>2]=0.0;i=e;return}function gj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0;d=+g[a+344>>2];if(!(d!=0.0))return;f=+g[a+348>>2];i=+g[a+352>>2];k=+g[a+356>>2];l=+g[b+4>>2]*i*d;h=+g[b+8>>2]*k*d;g[a+312>>2]=+g[a+312>>2]+ +g[b>>2]*f*d;g[a+316>>2]=+g[a+316>>2]+l;g[a+320>>2]=+g[a+320>>2]+h;f=+g[b>>2]*f;i=+g[b+4>>2]*i;k=+g[b+8>>2]*k;h=+g[c+4>>2];l=+g[c+8>>2];j=+g[c>>2];e=(+g[a+280>>2]*(h*k-l*i)+ +g[a+284>>2]*(l*f-j*k)+ +g[a+288>>2]*(j*i-h*f))*+g[a+548>>2];d=(+g[a+296>>2]*(h*k-l*i)+ +g[a+300>>2]*(l*f-j*k)+ +g[a+304>>2]*(j*i-h*f))*+g[a+552>>2];g[a+328>>2]=+g[a+328>>2]+(+g[a+264>>2]*(h*k-l*i)+ +g[a+268>>2]*(l*f-j*k)+ +g[a+272>>2]*(j*i-h*f))*+g[a+544>>2];g[a+332>>2]=+g[a+332>>2]+e;g[a+336>>2]=+g[a+336>>2]+d;return}function hj(a,b,d,e,f,h,j,k,l,m){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0;n=i;i=i+16|0;li(12859);+bc[c[(c[a>>2]|0)+44>>2]&3](a,b,d,e,f,h,j,k,l);+bc[c[(c[a>>2]|0)+48>>2]&3](a,b,d,e,f,h,j,k,l);+fc[c[(c[a>>2]|0)+36>>2]&1](a,b,d,k);m=c[2357]|0;a=(c[m+16>>2]|0)+-1|0;c[m+16>>2]=a;if(a|0){i=n;return 0.0}do if(c[m+4>>2]|0){tb(n|0,0)|0;a=c[6434]|0;g[m+8>>2]=+g[m+8>>2]+ +(((c[n+4>>2]|0)-(c[a+4>>2]|0)+(((c[n>>2]|0)-(c[a>>2]|0)|0)*1e6|0)-(c[m+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[m+16>>2]|0)){m=c[2357]|0;break}else{i=n;return 0.0}}while(0);c[2357]=c[m+20>>2];i=n;return 0.0}function ij(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=c[b+212>>2]|0;if((f|0)==(c[b+216>>2]|0)?(i=f|0?f<<1:1,(f|0)<(i|0)):0){if(!i)h=0;else{c[6435]=(c[6435]|0)+1;f=yc((i<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=f;f=c[b+212>>2]|0}if((f|0)>0){g=0;do{c[h+(g<<2)>>2]=c[(c[b+220>>2]|0)+(g<<2)>>2];g=g+1|0}while((g|0)!=(f|0))}g=c[b+220>>2]|0;if(g){if(a[b+224>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0);f=c[b+212>>2]|0}c[b+220>>2]=0}a[b+224>>0]=1;c[b+220>>2]=h;c[b+216>>2]=i}c[(c[b+220>>2]|0)+(f<<2)>>2]=d;c[b+212>>2]=f+1;if(!e)return;Pi(c[d+28>>2]|0,d);Pi(c[d+32>>2]|0,d);return}function jj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0;e=c[a+4>>2]|0;if(e|0)gj(e,b,d);e=c[a>>2]|0;if(!e)return;m=+g[b>>2];k=+g[e+128>>2];l=+g[b+4>>2];j=+g[b+8>>2];f=+g[d+4>>2];o=+g[d+8>>2];n=+g[d>>2];i=+g[e+180>>2]*(j*f-l*o)+ +g[e+184>>2]*(m*o-j*n)+(l*n-m*f)*+g[e+188>>2];h=(j*f-l*o)*+g[e+196>>2]+(m*o-j*n)*+g[e+200>>2]+(l*n-m*f)*+g[e+204>>2];f=(j*f-l*o)*+g[e+212>>2]+(m*o-j*n)*+g[e+216>>2]+(l*n-m*f)*+g[e+220>>2];g[e+276>>2]=m*k+ +g[e+276>>2];g[e+280>>2]=k*l+ +g[e+280>>2];g[e+284>>2]=k*j+ +g[e+284>>2];g[e+292>>2]=i+ +g[e+292>>2];g[e+296>>2]=h+ +g[e+296>>2];g[e+300>>2]=f+ +g[e+300>>2];c[e+312>>2]=(c[e+312>>2]|0)+1;return}function kj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0;v=+g[a+552>>2];u=+g[a+568>>2];t=+g[a+584>>2];s=+g[b>>2];r=+g[b+4>>2];q=+g[b+8>>2];o=+g[b+16>>2];n=+g[b+20>>2];m=+g[b+24>>2];k=+g[b+32>>2];i=+g[b+36>>2];f=+g[b+40>>2];j=+g[a+556>>2];h=+g[a+572>>2];e=+g[a+588>>2];x=+g[a+620>>2];w=+g[a+636>>2];d=+g[a+652>>2];p=x*+g[c>>2]+w*+g[c+4>>2]+d*+g[c+8>>2];l=x*+g[c+16>>2]+w*+g[c+20>>2]+d*+g[c+24>>2];d=x*+g[c+32>>2]+w*+g[c+36>>2]+d*+g[c+40>>2];d=+W(+((v*s+u*r+t*q)*p+(v*o+u*n+t*m)*l+(v*k+u*i+t*f)*d),+((s*j+r*h+q*e)*p+(o*j+n*h+m*e)*l+(k*j+i*h+f*e)*d));return +(d*+g[a+732>>2])}function lj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;a:do if((e|0)!=0&(b&3|0)!=0){f=e;while(1){if((a[b>>0]|0)==(d&255)<<24>>24)break a;b=b+1|0;e=f+-1|0;if((e|0)!=0&(b&3|0)!=0)f=e;else{f=e;e=(e|0)!=0;g=5;break}}}else{f=e;e=(e|0)!=0;g=5}while(0);b:do if((g|0)==5)if(e){if((a[b>>0]|0)!=(d&255)<<24>>24){e=_(d&255,16843009)|0;c:do if(f>>>0>3)while(1){h=c[b>>2]^e;if((h&-2139062144^-2139062144)&h+-16843009|0)break;b=b+4|0;f=f+-4|0;if(f>>>0<=3){g=11;break c}}else g=11;while(0);if((g|0)==11)if(!f){f=0;break}while(1){if((a[b>>0]|0)==(d&255)<<24>>24)break b;b=b+1|0;f=f+-1|0;if(!f){f=0;break}}}}else f=0;while(0);return (f|0?b:0)|0}function mj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=c[a+8>>2]|0;if((d|0)>0){f=0;do{e=c[(c[a+16>>2]|0)+(f<<2)>>2]|0;if(c[e+236>>2]&2){g=Eb[c[(c[e>>2]|0)+16>>2]&127](e)|0;g=Ob[c[(c[b>>2]|0)+16>>2]&63](b,g,1)|0;d=Ob[c[(c[e>>2]|0)+20>>2]&63](e,c[g+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,g,d,1497645650,e);d=c[a+8>>2]|0}f=f+1|0}while((f|0)<(d|0))}if((c[a+212>>2]|0)<=0)return;d=0;do{g=c[(c[a+220>>2]|0)+(d<<2)>>2]|0;e=Eb[c[(c[g>>2]|0)+36>>2]&127](g)|0;e=Ob[c[(c[b>>2]|0)+16>>2]&63](b,e,1)|0;f=Ob[c[(c[g>>2]|0)+40>>2]&63](g,c[e+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,e,f,1397641027,g);d=d+1|0}while((d|0)<(c[a+212>>2]|0));return}function nj(a){a=a|0;var b=0.0,d=0,e=0,f=0,h=0;e=i;i=i+32|0;c[a+32>>2]=1566444395;c[a+36>>2]=1566444395;c[a+40>>2]=1566444395;g[a+44>>2]=0.0;c[a+48>>2]=-581039253;c[a+52>>2]=-581039253;c[a+56>>2]=-581039253;g[a+60>>2]=0.0;if((c[a+16>>2]|0)<=0){i=e;return}d=0;do{f=c[a+24>>2]|0;h=c[f+(d*80|0)+64>>2]|0;mc[c[(c[h>>2]|0)+8>>2]&127](h,f+(d*80|0)|0,e+16|0,e);b=+g[e+16>>2];if(+g[a+32>>2]>b)g[a+32>>2]=b;b=+g[e>>2];if(+g[a+48>>2]>2]=b;b=+g[e+16+4>>2];if(+g[a+36>>2]>b)g[a+36>>2]=b;b=+g[e+4>>2];if(+g[a+52>>2]>2]=b;b=+g[e+16+8>>2];if(+g[a+40>>2]>b)g[a+40>>2]=b;b=+g[e+8>>2];if(+g[a+56>>2]>2]=b;d=d+1|0}while((d|0)<(c[a+16>>2]|0));i=e;return}function oj(a,b,d){a=a|0;b=+b;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0;e=i;i=i+96|0;j=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);c[e+32>>2]=1065353216;c[e+32+4>>2]=0;c[e+32+4+4>>2]=0;c[e+32+4+8>>2]=0;c[e+32+4+12>>2]=0;c[e+32+20>>2]=1065353216;c[e+32+24>>2]=0;c[e+32+24+4>>2]=0;c[e+32+24+8>>2]=0;c[e+32+24+12>>2]=0;c[e+32+40>>2]=1065353216;k=e+32+44|0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;mc[c[(c[a>>2]|0)+8>>2]&127](a,e+32|0,e+16|0,e);h=(j+(+g[e>>2]-+g[e+16>>2])*.5)*2.0;f=(j+(+g[e+4>>2]-+g[e+16+4>>2])*.5)*2.0;j=(j+(+g[e+8>>2]-+g[e+16+8>>2])*.5)*2.0;g[d>>2]=b*.0833333283662796*(f*f+j*j);g[d+4>>2]=b*.0833333283662796*(h*h+j*j);g[d+8>>2]=b*.0833333283662796*(h*h+f*f);g[d+12>>2]=0.0;i=e;return}function pj(b){b=b|0;var d=0;d=c[b+72>>2]|0;if(d|0){if(a[b+76>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+72>>2]=0}a[b+76>>0]=1;c[b+72>>2]=0;c[b+64>>2]=0;c[b+68>>2]=0;d=c[b+52>>2]|0;if(d|0){if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+52>>2]=0}a[b+56>>0]=1;c[b+52>>2]=0;c[b+44>>2]=0;c[b+48>>2]=0;d=c[b+32>>2]|0;if(d|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;d=c[b+12>>2]|0;if(!d){a[b+16>>0]=1;c[b+12>>2]=0;c[b+4>>2]=0;b=b+8|0;c[b>>2]=0;return}if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+12>>2]=0;a[b+16>>0]=1;c[b+12>>2]=0;c[b+4>>2]=0;b=b+8|0;c[b>>2]=0;return}function qj(a,b){a=a|0;b=+b;var d=0,e=0,f=0,h=0.0,i=0.0,j=0.0,k=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0;e=c[a+732>>2]|0;if((e|0)<=0)return;a=c[a+740>>2]|0;d=0;do{n=c[a+(d*52|0)+8>>2]|0;f=c[a+(d*52|0)+12>>2]|0;s=+g[n+40>>2];q=+g[n+44>>2];i=+g[n+48>>2];k=a+(d*52|0)+36|0;r=+g[k>>2];m=a+(d*52|0)+40|0;p=+g[m>>2];l=a+(d*52|0)+44|0;o=+g[l>>2];j=-(+g[a+(d*52|0)+32>>2]*((s-+g[f+40>>2])*r+(q-+g[f+44>>2])*p+(i-+g[f+48>>2])*o)*b);h=+g[n+88>>2]*j;g[n+40>>2]=s+r*h;g[n+44>>2]=q+p*h;g[n+48>>2]=o*h+i;j=+g[f+88>>2]*j;i=j*+g[m>>2];h=j*+g[l>>2];g[f+40>>2]=+g[f+40>>2]-+g[k>>2]*j;g[f+44>>2]=+g[f+44>>2]-i;g[f+48>>2]=+g[f+48>>2]-h;d=d+1|0}while((d|0)!=(e|0));return}function rj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=c[b+12>>2]|0;if(!e)return;if(!(a[b+8>>0]|0))return;f=c[d+4>>2]|0;if((f|0)==(c[d+8>>2]|0)?(h=f|0?f<<1:1,(f|0)<(h|0)):0){if(!h)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((h<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[d+4>>2]|0}if((f|0)>0){g=0;do{c[e+(g<<2)>>2]=c[(c[d+12>>2]|0)+(g<<2)>>2];g=g+1|0}while((g|0)!=(f|0))}g=c[d+12>>2]|0;if(g){if(a[d+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0);f=c[d+4>>2]|0}c[d+12>>2]=0}a[d+16>>0]=1;c[d+12>>2]=e;c[d+8>>2]=h;e=c[b+12>>2]|0}c[(c[d+12>>2]|0)+(f<<2)>>2]=e;c[d+4>>2]=f+1;return}function sj(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;g=c[b+328>>2]|0;if((g|0)==(c[b+332>>2]|0)?(j=g|0?g<<1:1,(g|0)<(j|0)):0){if(!j)i=0;else{c[6435]=(c[6435]|0)+1;g=yc((j<<2|3)+16|0)|0;if(!g)g=0;else{c[(g+4+15&-16)+-4>>2]=g;g=g+4+15&-16}i=g;g=c[b+328>>2]|0}if((g|0)>0){h=0;do{c[i+(h<<2)>>2]=c[(c[b+336>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(g|0))}h=c[b+336>>2]|0;if(h){if(a[b+340>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);g=c[b+328>>2]|0}c[b+336>>2]=0}a[b+340>>0]=1;c[b+336>>2]=i;c[b+332>>2]=j}c[(c[b+336>>2]|0)+(g<<2)>>2]=d;c[b+328>>2]=g+1;c[d+284>>2]=c[b+452>>2];Pg(b,d,e,f);return}function tj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=c[b+20>>2]|0;if(!e)return;if(!(a[b+16>>0]|0))return;f=c[d+4>>2]|0;if((f|0)==(c[d+8>>2]|0)?(h=f|0?f<<1:1,(f|0)<(h|0)):0){if(!h)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((h<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[d+4>>2]|0}if((f|0)>0){g=0;do{c[e+(g<<2)>>2]=c[(c[d+12>>2]|0)+(g<<2)>>2];g=g+1|0}while((g|0)!=(f|0))}g=c[d+12>>2]|0;if(g){if(a[d+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0);f=c[d+4>>2]|0}c[d+12>>2]=0}a[d+16>>0]=1;c[d+12>>2]=e;c[d+8>>2]=h;e=c[b+20>>2]|0}c[(c[d+12>>2]|0)+(f<<2)>>2]=e;c[d+4>>2]=f+1;return}function uj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;j=+g[a+24>>2];k=+g[a+28>>2];i=+g[a+32>>2];f=j*+g[b>>2]+k*+g[b+4>>2]+i*+g[b+8>>2];h=+g[a+20>>2];if(f>h){g[a+20>>2]=f;c[a+4>>2]=c[b>>2];c[a+4+4>>2]=c[b+4>>2];c[a+4+8>>2]=c[b+8>>2];c[a+4+12>>2]=c[b+12>>2]}else f=h;h=j*+g[b+16>>2]+k*+g[b+20>>2]+i*+g[b+24>>2];if(h>f){g[a+20>>2]=h;c[a+4>>2]=c[b+16>>2];c[a+4+4>>2]=c[b+16+4>>2];c[a+4+8>>2]=c[b+16+8>>2];c[a+4+12>>2]=c[b+16+12>>2]}else h=f;f=j*+g[b+32>>2]+k*+g[b+36>>2]+i*+g[b+40>>2];if(!(f>h))return;g[a+20>>2]=f;c[a+4>>2]=c[b+32>>2];c[a+4+4>>2]=c[b+32+4>>2];c[a+4+8>>2]=c[b+32+8>>2];c[a+4+12>>2]=c[b+32+12>>2];return}function vj(b){b=b|0;var d=0,e=0,f=0,h=0.0;e=i;i=i+96|0;a[b+88>>0]=1;if((a[22568]|0)==0?Wa(22568)|0:0){c[6139]=1065353216;c[6140]=0;c[6141]=0;c[6142]=0;c[6143]=0;c[6144]=1065353216;c[6145]=0;c[6146]=0;c[6147]=0;c[6148]=0;c[6149]=1065353216;g[6150]=0.0;c[6151]=-1082130432;c[6152]=0;c[6153]=0;c[6154]=0;c[6155]=0;c[6156]=-1082130432;c[6157]=0;c[6158]=0;c[6159]=0;c[6160]=0;c[6161]=-1082130432;g[6162]=0.0;_a(22568)}d=e;f=d+96|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(f|0));mc[c[(c[b>>2]|0)+76>>2]&127](b,24556,e,6);h=+g[b+44>>2];g[b+72>>2]=+g[e>>2]+h;g[b+56>>2]=+g[e+48>>2]-h;g[b+76>>2]=+g[e+20>>2]+h;g[b+60>>2]=+g[e+68>>2]-h;g[b+80>>2]=+g[e+40>>2]+h;g[b+64>>2]=+g[e+88>>2]-h;i=e;return}function wj(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,j=0;j=i;i=i+64|0;h=c[d>>2]|0;g=d+(c[h+-8>>2]|0)|0;h=c[h+-4>>2]|0;c[j>>2]=e;c[j+4>>2]=d;c[j+8>>2]=2776;d=j+12|0;f=d+40|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(f|0));b[j+12+40>>1]=0;a[j+12+42>>0]=0;a:do if((h|0)==(e|0)){c[j+48>>2]=1;Qb[c[(c[e>>2]|0)+20>>2]&7](e,j,g,g,1,0);d=(c[j+24>>2]|0)==1?g:0}else{yb[c[(c[h>>2]|0)+24>>2]&31](h,j,g,1,0);switch(c[j+36>>2]|0){case 0:{d=((c[j+40>>2]|0)==1?(c[j+28>>2]|0)==1:0)&(c[j+32>>2]|0)==1?c[j+20>>2]|0:0;break a}case 1:break;default:{d=0;break a}}if((c[j+24>>2]|0)!=1?!(((c[j+40>>2]|0)==0?(c[j+28>>2]|0)==1:0)&(c[j+32>>2]|0)==1):0){d=0;break}d=c[j+16>>2]|0}while(0);i=j;return d|0}function xj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;j=+g[a+88>>2];k=+g[a+92>>2];i=+g[a+96>>2];f=j*+g[b>>2]+k*+g[b+4>>2]+i*+g[b+8>>2];h=+g[a+84>>2];if(f>h){g[a+84>>2]=f;c[a+4>>2]=c[b>>2];c[a+4+4>>2]=c[b+4>>2];c[a+4+8>>2]=c[b+8>>2];c[a+4+12>>2]=c[b+12>>2]}else f=h;h=j*+g[b+16>>2]+k*+g[b+20>>2]+i*+g[b+24>>2];if(h>f){g[a+84>>2]=h;c[a+4>>2]=c[b+16>>2];c[a+4+4>>2]=c[b+16+4>>2];c[a+4+8>>2]=c[b+16+8>>2];c[a+4+12>>2]=c[b+16+12>>2]}else h=f;f=j*+g[b+32>>2]+k*+g[b+36>>2]+i*+g[b+40>>2];if(!(f>h))return;g[a+84>>2]=f;c[a+4>>2]=c[b+32>>2];c[a+4+4>>2]=c[b+32+4>>2];c[a+4+8>>2]=c[b+32+8>>2];c[a+4+12>>2]=c[b+32+12>>2];return}function yj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;while(1){j=c[a+12>>2]|0;k=c[j+(((b+d|0)/2|0)<<3)>>2]|0;e=b;f=d;while(1){while(1){h=e+1|0;if((c[j+(e<<3)>>2]|0)<(k|0))e=h;else{i=f;break}}while(1){g=j+(i<<3)|0;f=i+-1|0;if((k|0)<(c[g>>2]|0))i=f;else break}if((e|0)>(i|0))f=i;else{e=j+(e<<3)|0;l=c[e>>2]|0;j=c[e+4>>2]|0;m=c[g+4>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=m;e=(c[a+12>>2]|0)+(i<<3)|0;c[e>>2]=l;c[e+4>>2]=j;e=h}if((e|0)>(f|0))break;j=c[a+12>>2]|0}if((f|0)>(b|0))yj(a,b,f);if((e|0)<(d|0))b=e;else break}return}function zj(a,b,e){a=a|0;b=b|0;e=e|0;kh(a,b,e)|0;c[b+276>>2]=c[a+1316>>2];c[b+324>>2]=c[a+1364>>2];c[b+252>>2]=d[a+1309>>0];c[b+300>>2]=c[a+1340>>2];c[b+280>>2]=c[a+1320>>2];c[b+328>>2]=c[a+1368>>2];c[b+256>>2]=d[a+1310>>0];c[b+304>>2]=c[a+1344>>2];c[b+284>>2]=c[a+1324>>2];c[b+332>>2]=c[a+1372>>2];c[b+260>>2]=d[a+1311>>0];c[b+308>>2]=c[a+1348>>2];c[b+288>>2]=c[a+1328>>2];c[b+336>>2]=c[a+1376>>2];c[b+264>>2]=d[a+1312>>0];c[b+312>>2]=c[a+1352>>2];c[b+292>>2]=c[a+1332>>2];c[b+340>>2]=c[a+1380>>2];c[b+268>>2]=d[a+1313>>0];c[b+316>>2]=c[a+1356>>2];c[b+296>>2]=c[a+1336>>2];c[b+344>>2]=c[a+1384>>2];c[b+272>>2]=d[a+1314>>0];c[b+320>>2]=c[a+1360>>2];return 12539}function Aj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0;i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);m=i+ +g[a+28>>2];k=i+ +g[a+32>>2];i=i+ +g[a+36>>2];u=+N(+(+g[b>>2]));t=+N(+(+g[b+4>>2]));s=+N(+(+g[b+8>>2]));q=+N(+(+g[b+16>>2]));p=+N(+(+g[b+20>>2]));o=+N(+(+g[b+24>>2]));l=+N(+(+g[b+32>>2]));j=+N(+(+g[b+36>>2]));h=+N(+(+g[b+40>>2]));r=+g[b+48>>2];n=+g[b+52>>2];f=+g[b+56>>2];g[d>>2]=r-(m*u+k*t+i*s);g[d+4>>2]=n-(m*q+k*p+i*o);g[d+8>>2]=f-(m*l+k*j+i*h);g[d+12>>2]=0.0;g[e>>2]=m*u+k*t+i*s+r;g[e+4>>2]=m*q+k*p+i*o+n;g[e+8>>2]=m*l+k*j+i*h+f;g[e+12>>2]=0.0;return}function Bj(a,c,d,e,f,h){a=a|0;c=c|0;d=+d;e=+e;f=+f;h=h|0;var i=0,j=0;d=(d-+g[a+8>>2])*+g[a+40>>2];e=(e-+g[a+12>>2])*+g[a+44>>2];f=(f-+g[a+16>>2])*+g[a+48>>2];do if(!(d<=0.0)){i=b[a+6>>1]|0;j=b[a+4>>1]|0;if(!(d>=+(i&65535))){i=j&(~~d&65535)&65535|h;break}else{i=j&i&65535|h;break}}else i=h;while(0);b[c>>1]=i;do if(!(e<=0.0)){i=b[a+6>>1]|0;j=b[a+4>>1]|0;if(!(e>=+(i&65535))){i=j&(~~e&65535)&65535|h;break}else{i=j&i&65535|h;break}}else i=h;while(0);b[c+2>>1]=i;if(f<=0.0){h=h&65535;c=c+4|0;b[c>>1]=h;return}j=b[a+6>>1]|0;i=b[a+4>>1]|0;if(!(f>=+(j&65535))){h=i&(~~f&65535)&65535|h;h=h&65535;c=c+4|0;b[c>>1]=h;return}else{h=i&j&65535|h;h=h&65535;c=c+4|0;b[c>>1]=h;return}}function Cj(b){b=b|0;var d=0;c[b>>2]=8520;if(c[b+108>>2]|0){d=c[b+112>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+112>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+108>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+108>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}}d=c[b+88>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+84>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+80>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+60>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}if(!(a[b+100>>0]|0))return;d=c[b+92>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+92>>2]|0;if(!d)return;c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);return}function Dj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=c[b+76>>2]|0;if(!e)return;f=c[d+4>>2]|0;if((f|0)==(c[d+8>>2]|0)?(h=f|0?f<<1:1,(f|0)<(h|0)):0){if(!h)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((h<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[d+4>>2]|0}if((f|0)>0){g=0;do{c[e+(g<<2)>>2]=c[(c[d+12>>2]|0)+(g<<2)>>2];g=g+1|0}while((g|0)!=(f|0))}g=c[d+12>>2]|0;if(g){if(a[d+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0);f=c[d+4>>2]|0}c[d+12>>2]=0}a[d+16>>0]=1;c[d+12>>2]=e;c[d+8>>2]=h;e=c[b+76>>2]|0}c[(c[d+12>>2]|0)+(f<<2)>>2]=e;c[d+4>>2]=f+1;return}function Ej(a,b,d,e){a=a|0;b=b|0;d=+d;e=+e;var f=0,h=0.0,i=0.0,j=0.0,l=0,m=0.0,n=0.0,o=0.0;j=+Q(+d);i=+R(+d);f=c[b+444>>2]|0;l=+N(+j)>1.1920928955078125e-07;d=(c[k>>2]=f,+g[k>>2]);if(l){m=+g[b+448>>2];m=+O(+((i*i/(j*j)+1.0)/(1.0/(m*m)+i*i/(j*j)/(d*d))));d=i*i;h=j*j;f=(g[k>>2]=m,c[k>>2]|0)}else{d=i*i;h=j*j}m=+O(+(h+0.0+d));n=(c[k>>2]=f,+g[k>>2])*.5;m=+R(+n)/m;n=+Q(+n);o=n*e+j*m*0.0-i*m*-0.0;h=n*0.0-i*m*e-m*0.0*0.0;d=n*0.0+m*0.0*0.0-j*m*e;e=-(m*0.0*e)-j*m*0.0-i*m*-0.0;g[a>>2]=i*m*h+(n*o+e*-(m*0.0))-d*-(j*m);g[a+4>>2]=d*-(m*0.0)+(n*h+e*-(j*m))-i*m*o;g[a+8>>2]=o*-(j*m)+(i*m*e+n*d)-h*-(m*0.0);g[a+12>>2]=0.0;return}function Fj(a,d,f,h){a=a|0;d=d|0;f=f|0;h=h|0;var i=0,j=0,k=0,l=0,m=0;i=c[a+108>>2]|0;if(i|0){mc[c[(c[i>>2]|0)+28>>2]&127](i,d,f,h);return}i=b[a+56>>1]|0;if((i&65535)<<1>>>0<=1)return;k=1;m=1;do{j=c[a+68>>2]|0;if(b[j+(k<<2)>>1]&1){l=c[a+60>>2]|0;k=e[j+(k<<2)+2>>1]|0;if(!(+g[d>>2]>+g[l+(k<<6)+32>>2])?!(+g[f>>2]<+g[l+(k<<6)+16>>2]):0)j=1;else j=0;if(!(!(+g[d+8>>2]>+g[l+(k<<6)+40>>2])?!(+g[f+8>>2]<+g[l+(k<<6)+24>>2]):0))j=0;if(!(+g[d+4>>2]>+g[l+(k<<6)+36>>2])?!(+g[f+4>>2]<+g[l+(k<<6)+20>>2]|j^1):0){Zb[c[(c[h>>2]|0)+8>>2]&31](h,l+(k<<6)|0)|0;i=b[a+56>>1]|0}}m=m+1<<16>>16;k=m&65535}while(k>>>0<((i&65535)<<1|1)>>>0);return}function Gj(a,b,d){a=a|0;b=+b;d=+d;var e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0;f=c[a+732>>2]|0;if((f|0)<=0)return;a=c[a+740>>2]|0;e=0;do{d=+g[a+(e*52|0)+24>>2];if(d>0.0?(p=c[a+(e*52|0)+8>>2]|0,h=c[a+(e*52|0)+12>>2]|0,i=+g[p+8>>2],j=+g[h+8>>2]-i,k=+g[p+12>>2],l=+g[h+12>>2]-k,m=+g[p+16>>2],n=+g[h+16>>2]-m,o=+g[a+(e*52|0)+28>>2],o+(j*j+l*l+n*n)>1.1920928955078125e-07):0){d=(o-(j*j+l*l+n*n))/(d*(o+(j*j+l*l+n*n)))*b;q=d*+g[p+88>>2];g[p+8>>2]=i-j*q;g[p+12>>2]=k-l*q;g[p+16>>2]=m-n*q;d=d*+g[h+88>>2];g[h+8>>2]=+g[h+8>>2]+j*d;g[h+12>>2]=l*d+ +g[h+12>>2];g[h+16>>2]=n*d+ +g[h+16>>2]}e=e+1|0}while((e|0)!=(f|0));return}function Hj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0;e=i;i=i+96|0;c[e+32>>2]=1065353216;c[e+32+4>>2]=0;c[e+32+4+4>>2]=0;c[e+32+4+8>>2]=0;c[e+32+4+12>>2]=0;c[e+32+20>>2]=1065353216;c[e+32+24>>2]=0;c[e+32+24+4>>2]=0;c[e+32+24+8>>2]=0;c[e+32+24+12>>2]=0;c[e+32+40>>2]=1065353216;n=e+32+44|0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;c[n+16>>2]=0;mc[c[(c[a>>2]|0)+8>>2]&127](a,e+32|0,e+16|0,e);l=+g[e>>2];m=+g[e+16>>2];j=+g[e+4>>2];k=+g[e+16+4>>2];f=+g[e+8>>2];h=+g[e+16+8>>2];g[d>>2]=+O(+((l-m)*(l-m)+(j-k)*(j-k)+(f-h)*(f-h)))*.5;g[b>>2]=(m+l)*.5;g[b+4>>2]=(k+j)*.5;g[b+8>>2]=(h+f)*.5;g[b+12>>2]=0.0;i=e;return}function Ij(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;c[a+4>>2]=c[b+24>>2];e=c[b>>2]|0;c[a+8>>2]=e;if(d){c[a+52>>2]=c[b+8>>2];c[a+52+4>>2]=c[b+8+4>>2];c[a+52+8>>2]=c[b+8+8>>2];c[a+52+12>>2]=c[b+8+12>>2]}else{k=+g[b+8>>2];j=+g[b+12>>2];i=+g[b+16>>2];h=+g[e+20>>2]*k+ +g[e+24>>2]*j+ +g[e+28>>2]*i;f=+g[e+36>>2]*k+ +g[e+40>>2]*j+ +g[e+44>>2]*i;g[a+52>>2]=+g[e+4>>2]*k+ +g[e+8>>2]*j+ +g[e+12>>2]*i;g[a+56>>2]=h;g[a+60>>2]=f;g[a+64>>2]=0.0}k=+g[b+24>>2];g[a+68>>2]=(1.0-k)*+g[a+20>>2]+ +g[a+36>>2]*k;g[a+72>>2]=(1.0-k)*+g[a+24>>2]+ +g[a+40>>2]*k;g[a+76>>2]=(1.0-k)*+g[a+28>>2]+ +g[a+44>>2]*k;return +(+g[b+24>>2])}function Jj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0;f=+g[b>>2];h=+g[b+16>>2];j=f>2];if((j+g[a+24>>2])return;k=f>h?b:b+16|0;if(+g[(+g[k>>2]>i?k:b+32|0)>>2]<+g[a+8>>2])return;f=+g[b+8>>2];h=+g[b+24>>2];j=f>2];if((j+g[a+32>>2])return;k=f>h?b+8|0:b+24|0;if(+g[(+g[k>>2]>i?k:b+40|0)>>2]<+g[a+16>>2])return;f=+g[b+4>>2];h=+g[b+20>>2];j=f>2];if((j+g[a+28>>2])return;k=f>h?b+4|0:b+20|0;if(+g[(+g[k>>2]>i?k:b+36|0)>>2]<+g[a+12>>2])return;k=c[a+4>>2]|0;mc[c[(c[k>>2]|0)+8>>2]&127](k,b,d,e);return}function Kj(b,d,e,f){b=b|0;d=d|0;e=e|0;f=+f;var h=0,j=0.0,k=0.0,l=0.0;h=i;i=i+16|0;g[b+32>>2]=f;c[b+8>>2]=c[d>>2];c[b+8+4>>2]=c[d+4>>2];c[b+8+8>>2]=c[d+8>>2];c[b+8+12>>2]=c[d+12>>2];j=+g[b+28>>2];l=+g[e+4>>2]-j*+g[d+4>>2];k=+g[e+8>>2]-j*+g[d+8>>2];g[h>>2]=+g[e>>2]-+g[d>>2]*j;g[h+4>>2]=l;g[h+8>>2]=k;g[h+12>>2]=0.0;f=+g[b+24>>2]+j+f;g[b+32>>2]=f;if(!(f<0.0)){b=b+4|0;b=c[b>>2]|0;e=c[b>>2]|0;e=e+16|0;e=c[e>>2]|0;hc[e&15](b,d,h,f);i=h;return}a[b+36>>0]=1;b=b+4|0;b=c[b>>2]|0;e=c[b>>2]|0;e=e+16|0;e=c[e>>2]|0;hc[e&15](b,d,h,f);i=h;return}function Lj(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;c[b>>2]=6228;d=c[b+8>>2]|0;e=c[d+8>>2]|0;if((e|0)>0){g=0;do{f=c[(c[d+16>>2]|0)+(g*12|0)+8>>2]|0;if(f|0){Ab[c[c[f>>2]>>2]&255](f);h=c[b+4>>2]|0;Cb[c[(c[h>>2]|0)+60>>2]&127](h,f)}g=g+1|0}while((g|0)!=(e|0));d=c[b+8>>2]|0}$h(d);d=c[b+8>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+8>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+24>>2]|0;if(!d){a[b+28>>0]=1;c[b+24>>2]=0;c[b+16>>2]=0;h=b+20|0;c[h>>2]=0;return}if(a[b+28>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+24>>2]=0;a[b+28>>0]=1;c[b+24>>2]=0;c[b+16>>2]=0;h=b+20|0;c[h>>2]=0;return}function Mj(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0;d=i;i=i+64|0;c[d+4>>2]=0;c[d+4+4>>2]=0;c[d+24>>2]=0;c[d+24+4>>2]=0;c[d+44>>2]=0;c[d+44+4>>2]=0;c[d+44+8>>2]=0;c[d+44+12>>2]=0;c[d+44+16>>2]=0;j=+g[b>>2];f=+g[b+4>>2];m=+g[b+8>>2];k=+g[b+12>>2];h=j*(2.0/(j*j+f*f+m*m+k*k));e=f*(2.0/(j*j+f*f+m*m+k*k));l=m*(2.0/(j*j+f*f+m*m+k*k));g[d>>2]=1.0-(f*e+m*l);g[d+4>>2]=j*e-k*l;g[d+8>>2]=j*l+k*e;g[d+12>>2]=0.0;g[d+16>>2]=j*e+k*l;g[d+20>>2]=1.0-(j*h+m*l);g[d+24>>2]=f*l-k*h;g[d+28>>2]=0.0;g[d+32>>2]=j*l-k*e;g[d+36>>2]=f*l+k*h;g[d+40>>2]=1.0-(j*h+f*e);g[d+44>>2]=0.0;Pd(a,d);i=d;return}function Nj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;while(1){b=yc(152)|0;if(b|0){f=6;break}b=c[6564]|0;c[6564]=b+0;if(!b){f=5;break}jc[b&3]()}if((f|0)==5){e=Ya(4)|0;c[e>>2]=9640;pb(e|0,2800,251)}else if((f|0)==6){c[b>>2]=4816;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;a[b+80>>0]=1;c[b+76>>2]=0;c[b+68>>2]=0;c[b+72>>2]=0;c[b+100>>2]=e;g[b+104>>2]=0.0;a[b+148>>0]=1;c[b+144>>2]=0;c[b+136>>2]=0;c[b+140>>2]=0;c[b+116>>2]=d;c[b+120>>2]=0;c[b+124>>2]=2;c[b+128>>2]=1;g[b+112>>2]=0.0;g[b+108>>2]=0.0;return b|0}return 0}function Oj(){var b=0;c[6435]=(c[6435]|0)+1;b=yc(215)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}c[b>>2]=4756;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;a[b+80>>0]=1;c[b+76>>2]=0;c[b+68>>2]=0;c[b+72>>2]=0;a[b+100>>0]=1;c[b+96>>2]=0;c[b+88>>2]=0;c[b+92>>2]=0;a[b+120>>0]=1;c[b+116>>2]=0;c[b+108>>2]=0;c[b+112>>2]=0;a[b+140>>0]=1;c[b+136>>2]=0;c[b+128>>2]=0;c[b+132>>2]=0;a[b+160>>0]=1;c[b+156>>2]=0;c[b+148>>2]=0;c[b+152>>2]=0;a[b+180>>0]=1;c[b+176>>2]=0;c[b+168>>2]=0;c[b+172>>2]=0;c[b+192>>2]=0;return b|0}function Pj(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;if((c[d+60>>2]|0)==2){f=c[d+48>>2]|0;hh(b+64|0,f)|0;g=c[b+68>>2]|0;if(g|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[b+68>>2]=f;c[b+76>>2]=(c[b+76>>2]|0)+-1}else{f=c[d+48>>2]|0;hh(b+4|0,f)|0;g=c[b+8>>2]|0;if(g|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[b+8>>2]=f;c[b+16>>2]=(c[b+16>>2]|0)+-1}f=c[d+52>>2]|0;g=c[d+56>>2]|0;if(!f)c[b+124+(c[d+60>>2]<<2)>>2]=g;else c[f+56>>2]=g;f=c[d+56>>2]|0;if(f|0)c[f+52>>2]=c[d+52>>2];g=c[b+136>>2]|0;ic[c[(c[g>>2]|0)+16>>2]&127](g,d,e);c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);a[b+194>>0]=1;return}function Qj(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=i;i=i+96|0;g=c[b+192>>2]|0;c[f+64>>2]=0;c[f+64+4>>2]=g;c[f+64+8>>2]=b;c[f+64+12>>2]=b+4;c[f+64+16>>2]=-1;c[f+64+20>>2]=-1;b=c[d+192>>2]|0;c[f+40>>2]=0;c[f+40+4>>2]=b;c[f+40+8>>2]=d;c[f+40+12>>2]=d+4;c[f+40+16>>2]=-1;c[f+40+20>>2]=-1;b=c[a+24>>2]|0;b=Ib[c[(c[b>>2]|0)+8>>2]&31](b,f+64|0,f+40|0,0)|0;if(!b){i=f;return}c[f+4>>2]=0;c[f+8>>2]=f+64;c[f+12>>2]=f+40;c[f>>2]=5976;c[f+32>>2]=e;yb[c[(c[b>>2]|0)+8>>2]&31](b,f+64|0,f+40|0,a+28|0,f);Ab[c[c[b>>2]>>2]&255](b);g=c[a+24>>2]|0;Cb[c[(c[g>>2]|0)+60>>2]&127](g,b);i=f;return}function Rj(a,b,d){a=a|0;b=+b;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;e=+g[a+28>>2];i=+g[a+32>>2];h=+g[a+36>>2];j=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);f=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a)+h;switch(c[a+52>>2]|0){case 0:{j=b*.25*(f+i)*(f+i)+b/12.0*(j+e)*(j+e)*4.0;g[d>>2]=b*.5*(f+i)*(f+i);g[d+4>>2]=j;g[d+8>>2]=j;g[d+12>>2]=0.0;return}case 2:{g[d>>2]=b*.25*(j+e)*(j+e)+b/12.0*h*h*4.0;g[d+4>>2]=b*.25*(j+e)*(j+e)+b/12.0*h*h*4.0;g[d+8>>2]=b*.5*(j+e)*(j+e);g[d+12>>2]=0.0;return}default:{i=b*.25*(j+e)*(j+e)+b/12.0*(f+i)*(f+i)*4.0;g[d>>2]=i;g[d+4>>2]=b*.5*(j+e)*(j+e);g[d+8>>2]=i;g[d+12>>2]=0.0;return}}}function Sj(b,d){b=b|0;d=d|0;c[b+8>>2]=0;c[b>>2]=6292;a[b+28>>0]=1;c[b+24>>2]=0;c[b+16>>2]=0;c[b+20>>2]=0;c[b+32>>2]=1566444395;c[b+36>>2]=1566444395;c[b+40>>2]=1566444395;g[b+44>>2]=0.0;c[b+48>>2]=-581039253;c[b+52>>2]=-581039253;c[b+56>>2]=-581039253;g[b+60>>2]=0.0;c[b+64>>2]=0;c[b+68>>2]=1;g[b+72>>2]=0.0;c[b+76>>2]=1065353216;c[b+80>>2]=1065353216;c[b+84>>2]=1065353216;g[b+88>>2]=0.0;c[b+4>>2]=31;if(!d)return;c[6435]=(c[6435]|0)+1;d=yc(79)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}a[d+36>>0]=1;c[d+32>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;a[d+56>>0]=1;c[d+52>>2]=0;c[d+44>>2]=0;c[d+48>>2]=0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=-1;c[d+12>>2]=0;c[d+16>>2]=0;c[b+64>>2]=d;return}function Tj(a){a=a|0;var b=0;c[a>>2]=3068;b=c[a+92>>2]|0;Ab[c[c[b>>2]>>2]&255](b);b=c[a+92>>2]|0;if(b|0){c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0)}b=c[a+96>>2]|0;Ab[c[c[b>>2]>>2]&255](b);b=c[a+96>>2]|0;if(b|0){c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0)}b=c[a+100>>2]|0;Ab[c[c[b>>2]>>2]&255](b);b=c[a+100>>2]|0;if(b|0){c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0)}b=c[a+104>>2]|0;Ab[c[c[b>>2]>>2]&255](b);b=c[a+104>>2]|0;if(b|0){c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0)}b=c[a+108>>2]|0;Ab[c[c[b>>2]>>2]&255](b);b=c[a+108>>2]|0;if(!b){kf(a);return}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);kf(a);return}function Uj(b,d,e,f){b=b|0;d=d|0;e=+e;f=f|0;var h=0,i=0;c[6435]=(c[6435]|0)+1;h=yc(203)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[h>>2]=4872;i=h+60|0;a[h+144>>0]=1;c[h+140>>2]=0;c[h+132>>2]=0;c[h+136>>2]=0;c[h+176>>2]=f;g[h+56>>2]=.019999999552965164;c[i>>2]=0;c[i+4>>2]=0;c[i+8>>2]=0;c[i+12>>2]=0;a[h+170>>0]=1;c[h+8>>2]=b;g[h+52>>2]=e;g[h+48>>2]=0.0;c[h+12>>2]=d;a[h+171>>0]=1;g[h+172>>2]=0.0;g[h+16>>2]=0.0;g[h+20>>2]=0.0;g[h+44>>2]=29.399999618530273;g[h+24>>2]=55.0;g[h+28>>2]=10.0;a[h+168>>0]=0;a[h+169>>0]=0;a[h+180>>0]=1;g[h+36>>2]=.7853981852531433;g[h+40>>2]=.7071067690849304;g[h+108>>2]=0.0;a[h+181>>0]=0;a[h+182>>0]=0;return h|0}function Vj(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0;m=c[b+52>>2]|0;l=c[m+32>>2]|0;b=c[l>>2]|0;m=c[m+24>>2]|0;if((m|0)<=1){m=b;m=m+8|0;c[a>>2]=c[m>>2];c[a+4>>2]=c[m+4>>2];c[a+8>>2]=c[m+8>>2];c[a+12>>2]=c[m+12>>2];return}j=+g[d>>2];k=+g[d+4>>2];i=+g[d+8>>2];f=j*+g[b+8>>2]+k*+g[b+12>>2]+i*+g[b+16>>2];d=1;h=0;while(1){b=c[l+(d<<2)>>2]|0;e=j*+g[b+8>>2]+k*+g[b+12>>2]+i*+g[b+16>>2];b=e>f;h=b?d:h;d=d+1|0;if((d|0)==(m|0))break;else f=b?e:f}m=c[l+(h<<2)>>2]|0;m=m+8|0;c[a>>2]=c[m>>2];c[a+4>>2]=c[m+4>>2];c[a+8>>2]=c[m+8>>2];c[a+12>>2]=c[m+12>>2];return} +function Ld(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0,M=0,N=0,O=0;h=i;i=i+256|0;if(!(c[b+16>>2]|0)){K=c[b+12>>2]|0;b=c[b+20>>2]|0;n=+g[d>>2];q=+g[d+4>>2];u=+g[d+8>>2];k=+g[d+16>>2];r=+g[d+20>>2];j=+g[d+24>>2];m=+g[d+32>>2];s=+g[d+36>>2];l=+g[d+40>>2];F=+g[d+48>>2];E=+g[d+52>>2];D=+g[d+56>>2];J=+g[e>>2];I=+g[e+16>>2];y=+g[e+32>>2];H=+g[e+4>>2];G=+g[e+20>>2];w=+g[e+36>>2];v=+g[e+8>>2];z=+g[e+24>>2];x=+g[e+40>>2];C=-+g[e+48>>2];B=-+g[e+52>>2];p=-+g[e+56>>2];d=c[(c[K>>2]|0)+64>>2]|0;A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h;return}else{N=c[b+4>>2]|0;a[N+312>>0]=0;c[N>>2]=0;a[N+356>>0]=1;c[N+292>>2]=1566444395;c[N+296>>2]=1566444395;c[N+300>>2]=1566444395;g[N+304>>2]=0.0;c[N+336>>2]=0;c[N+336+4>>2]=0;c[N+336+8>>2]=0;c[N+336+12>>2]=0;a[N+336+16>>0]=0;a[N+332>>0]=a[N+332>>0]&-16;N=c[b+12>>2]|0;M=c[b+16>>2]|0;L=c[N+4>>2]|0;K=c[M+4>>2]|0;I=+Sb[c[(c[N>>2]|0)+48>>2]&15](N);O=c[b+16>>2]|0;J=+Sb[c[(c[O>>2]|0)+48>>2]&15](O);O=c[b+4>>2]|0;b=c[b+8>>2]|0;c[h+168>>2]=9208;c[h+168+4>>2]=0;c[h+168+8>>2]=1065353216;c[h+168+12>>2]=0;g[h+168+16>>2]=0.0;c[h+168+20>>2]=b;c[h+168+24>>2]=O;c[h+168+28>>2]=N;c[h+168+32>>2]=M;c[h+168+36>>2]=L;c[h+168+40>>2]=K;g[h+168+44>>2]=I;g[h+168+48>>2]=J;a[h+168+52>>0]=0;c[h+168+60>>2]=-1;c[h+168+72>>2]=1;c[h+168+76>>2]=1;g[h+32+128>>2]=999999984306749440.0;c[h+32>>2]=c[d>>2];c[h+32+4>>2]=c[d+4>>2];c[h+32+8>>2]=c[d+8>>2];c[h+32+12>>2]=c[d+12>>2];c[h+32+16>>2]=c[d+16>>2];c[h+32+16+4>>2]=c[d+16+4>>2];c[h+32+16+8>>2]=c[d+16+8>>2];c[h+32+16+12>>2]=c[d+16+12>>2];c[h+32+32>>2]=c[d+32>>2];c[h+32+32+4>>2]=c[d+32+4>>2];c[h+32+32+8>>2]=c[d+32+8>>2];c[h+32+32+12>>2]=c[d+32+12>>2];c[h+32+48>>2]=c[d+48>>2];c[h+32+48+4>>2]=c[d+48+4>>2];c[h+32+48+8>>2]=c[d+48+8>>2];c[h+32+48+12>>2]=c[d+48+12>>2];c[h+32+64>>2]=c[e>>2];c[h+32+64+4>>2]=c[e+4>>2];c[h+32+64+8>>2]=c[e+8>>2];c[h+32+64+12>>2]=c[e+12>>2];c[h+32+80>>2]=c[e+16>>2];c[h+32+80+4>>2]=c[e+16+4>>2];c[h+32+80+8>>2]=c[e+16+8>>2];c[h+32+80+12>>2]=c[e+16+12>>2];c[h+32+96>>2]=c[e+32>>2];c[h+32+96+4>>2]=c[e+32+4>>2];c[h+32+96+8>>2]=c[e+32+8>>2];c[h+32+96+12>>2]=c[e+32+12>>2];c[h+32+112>>2]=c[e+48>>2];c[h+32+112+4>>2]=c[e+48+4>>2];c[h+32+112+8>>2]=c[e+48+8>>2];c[h+32+112+12>>2]=c[e+48+12>>2];Vc(h+168|0,h+32|0,f,0,0);i=h;return}}function Md(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;t=i;i=i+32|0;g=Eb[c[(c[d>>2]|0)+28>>2]&127](d)|0;c[e+20>>2]=g;c[e>>2]=0;if(!g){s=d+4|0;f=e+4|0;s=c[s>>2]|0;c[f>>2]=s;f=d+8|0;f=c[f>>2]|0;s=e+8|0;c[s>>2]=f;s=d+12|0;s=c[s>>2]|0;f=e+12|0;c[f>>2]=s;f=d+16|0;f=c[f>>2]|0;d=e+16|0;c[d>>2]=f;i=t;return 19362}s=Ob[c[(c[f>>2]|0)+16>>2]&63](f,32,g)|0;g=c[s+8>>2]|0;c[e>>2]=Zb[c[(c[f>>2]|0)+28>>2]&31](f,g)|0;r=Eb[c[(c[d>>2]|0)+28>>2]&127](d)|0;a:do if((r|0)>0){q=0;while(1){Yb[c[(c[d>>2]|0)+16>>2]&3](d,t+28|0,t+4|0,t+16|0,t+8|0,t+24|0,t+20|0,t,t+12|0,q);c[g+24>>2]=c[t>>2];c[g+28>>2]=c[t+4>>2];k=g+12|0;m=g+16|0;p=g+4|0;c[g>>2]=0;c[g+4>>2]=0;c[g+8>>2]=0;c[g+12>>2]=0;c[g+16>>2]=0;c[g+20>>2]=0;switch(c[t+12>>2]|0){case 2:{j=c[t>>2]|0;if(j|0){j=Ob[c[(c[f>>2]|0)+16>>2]&63](f,4,j*3|0)|0;k=c[j+8>>2]|0;c[g+8>>2]=Zb[c[(c[f>>2]|0)+28>>2]&31](f,k)|0;if((c[t>>2]|0)>0){l=c[t+24>>2]|0;m=0;do{n=l+(_(c[t+20>>2]|0,m)|0)|0;o=m*3|0;c[k+(o<<2)>>2]=c[n>>2];c[k+(o+1<<2)>>2]=c[n+4>>2];c[k+(o+2<<2)>>2]=c[n+8>>2];m=m+1|0}while((m|0)<(c[t>>2]|0))}yb[c[(c[f>>2]|0)+20>>2]&31](f,j,19243,1497453121,c[j+8>>2]|0)}break}case 3:{j=c[t>>2]|0;if(j|0){n=Ob[c[(c[f>>2]|0)+16>>2]&63](f,8,j)|0;o=c[n+8>>2]|0;c[k>>2]=Zb[c[(c[f>>2]|0)+28>>2]&31](f,o)|0;j=c[t>>2]|0;if((j|0)>0){k=c[t+24>>2]|0;l=c[t+20>>2]|0;m=0;do{u=k+(_(l,m)|0)|0;b[o+(m<<3)>>1]=b[u>>1]|0;b[o+(m<<3)+2>>1]=b[u+2>>1]|0;b[o+(m<<3)+4>>1]=b[u+4>>1]|0;m=m+1|0}while((m|0)!=(j|0))}yb[c[(c[f>>2]|0)+20>>2]&31](f,n,19258,1497453121,c[n+8>>2]|0)}break}case 5:{j=c[t>>2]|0;if(j|0){k=Ob[c[(c[f>>2]|0)+16>>2]&63](f,4,j)|0;l=c[k+8>>2]|0;c[m>>2]=Zb[c[(c[f>>2]|0)+28>>2]&31](f,l)|0;if((c[t>>2]|0)>0){j=0;do{u=(c[t+24>>2]|0)+(_(c[t+20>>2]|0,j)|0)|0;a[l+(j<<2)>>0]=a[u>>0]|0;a[l+(j<<2)+1>>0]=a[u+1>>0]|0;a[l+(j<<2)+2>>0]=a[u+2>>0]|0;j=j+1|0}while((j|0)<(c[t>>2]|0))}yb[c[(c[f>>2]|0)+20>>2]&31](f,k,19285,1497453121,c[k+8>>2]|0)}break}default:{}}switch(c[t+16>>2]|0){case 0:{j=c[t+4>>2]|0;if(j|0){j=Ob[c[(c[f>>2]|0)+16>>2]&63](f,16,j)|0;k=c[j+8>>2]|0;c[g>>2]=Zb[c[(c[f>>2]|0)+28>>2]&31](f,k)|0;l=c[t+4>>2]|0;if((l|0)>0){m=c[t+28>>2]|0;n=c[t+8>>2]|0;o=0;do{u=m+(_(n,o)|0)|0;c[k+(o<<4)>>2]=c[u>>2];c[k+(o<<4)+4>>2]=c[u+4>>2];c[k+(o<<4)+8>>2]=c[u+8>>2];o=o+1|0}while((o|0)!=(l|0))}yb[c[(c[f>>2]|0)+20>>2]&31](f,j,19308,1497453121,c[j+8>>2]|0)}break}case 1:{j=c[t+4>>2]|0;if(j|0){n=Ob[c[(c[f>>2]|0)+16>>2]&63](f,32,j)|0;o=c[n+8>>2]|0;c[p>>2]=Zb[c[(c[f>>2]|0)+28>>2]&31](f,o)|0;j=c[t+4>>2]|0;if((j|0)>0){k=c[t+28>>2]|0;l=c[t+8>>2]|0;m=0;do{u=k+(_(l,m)|0)|0;h[o+(m<<5)>>3]=+h[u>>3];h[o+(m<<5)+8>>3]=+h[u+8>>3];h[o+(m<<5)+16>>3]=+h[u+16>>3];m=m+1|0}while((m|0)!=(j|0))}yb[c[(c[f>>2]|0)+20>>2]&31](f,n,19327,1497453121,c[n+8>>2]|0)}break}default:{}}Cb[c[(c[d>>2]|0)+24>>2]&127](d,q);q=q+1|0;if((q|0)==(r|0)){g=f;break a}else g=g+32|0}}else g=f;while(0);yb[c[(c[g>>2]|0)+20>>2]&31](f,s,19347,1497453121,c[s+8>>2]|0);f=d+4|0;u=e+4|0;f=c[f>>2]|0;c[u>>2]=f;u=d+8|0;u=c[u>>2]|0;f=e+8|0;c[f>>2]=u;f=d+12|0;f=c[f>>2]|0;u=e+12|0;c[u>>2]=f;d=d+16|0;d=c[d>>2]|0;u=e+16|0;c[u>>2]=d;i=t;return 19362}function Nd(b,d,e,f,h,i){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;var j=0,l=0,m=0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0,C=0,D=0;D=c[b+88>>2]|0;if((D|0)==(c[b+92>>2]|0)?(o=D|0?D<<1:1,(D|0)<(o|0)):0){if(!o){j=0;l=D}else{c[6435]=(c[6435]|0)+1;j=yc((o*152|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}l=c[b+88>>2]|0}if((l|0)>0){m=0;do{_m(j+(m*152|0)|0,(c[b+96>>2]|0)+(m*152|0)|0,152)|0;m=m+1|0}while((m|0)!=(l|0))}l=c[b+96>>2]|0;if(l|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=j;c[b+92>>2]=o;j=c[b+88>>2]|0}else j=D;c[b+88>>2]=j+1;C=c[b+96>>2]|0;c[C+(D*152|0)+140>>2]=h;c[C+(D*152|0)+16>>2]=0;c[C+(D*152|0)+16+4>>2]=0;c[C+(D*152|0)+16+8>>2]=0;c[C+(D*152|0)+16+12>>2]=0;g[C+(D*152|0)+48>>2]=-0.0;g[C+(D*152|0)+52>>2]=-0.0;g[C+(D*152|0)+56>>2]=-0.0;g[C+(D*152|0)+60>>2]=0.0;b=c[b+16>>2]|0;o=c[b+(e*244|0)+240>>2]|0;B=c[b+(f*244|0)+240>>2]|0;c[C+(D*152|0)+144>>2]=e;c[C+(D*152|0)+148>>2]=f;h=c[i+88>>2]|0;c[C+(D*152|0)+104>>2]=h;c[C+(D*152|0)+132>>2]=0;g[C+(D*152|0)+100>>2]=0.0;g[C+(D*152|0)+96>>2]=0.0;x=-+g[d>>2];y=-+g[d+4>>2];z=-+g[d+8>>2];g[C+(D*152|0)>>2]=x;g[C+(D*152|0)+4>>2]=y;g[C+(D*152|0)+8>>2]=z;g[C+(D*152|0)+12>>2]=0.0;A=(c[k>>2]=h,+g[k>>2]);if(o|0){j=(g[k>>2]=(+g[o+264>>2]*x+ +g[o+268>>2]*y+ +g[o+272>>2]*z)*+g[o+544>>2],c[k>>2]|0);l=(g[k>>2]=(+g[o+280>>2]*x+ +g[o+284>>2]*y+ +g[o+288>>2]*z)*+g[o+548>>2],c[k>>2]|0);m=(g[k>>2]=(+g[o+296>>2]*x+ +g[o+300>>2]*y+ +g[o+304>>2]*z)*+g[o+552>>2],c[k>>2]|0)}else{j=0;l=0;m=0}c[C+(D*152|0)+64>>2]=j;c[C+(D*152|0)+68>>2]=l;c[C+(D*152|0)+72>>2]=m;g[C+(D*152|0)+76>>2]=0.0;u=+g[d>>2];v=+g[d+4>>2];w=+g[d+8>>2];d=c[d+12>>2]|0;g[C+(D*152|0)+32>>2]=u;g[C+(D*152|0)+36>>2]=v;g[C+(D*152|0)+40>>2]=w;c[C+(D*152|0)+44>>2]=d;if(B|0){j=(g[k>>2]=(u*+g[B+264>>2]+v*+g[B+268>>2]+w*+g[B+272>>2])*+g[B+544>>2],c[k>>2]|0);l=(g[k>>2]=(u*+g[B+280>>2]+v*+g[B+284>>2]+w*+g[B+288>>2])*+g[B+548>>2],c[k>>2]|0);m=(g[k>>2]=(u*+g[B+296>>2]+v*+g[B+300>>2]+w*+g[B+304>>2])*+g[B+552>>2],c[k>>2]|0)}else{j=0;l=0;m=0}c[C+(D*152|0)+80>>2]=j;c[C+(D*152|0)+84>>2]=l;c[C+(D*152|0)+88>>2]=m;g[C+(D*152|0)+92>>2]=0.0;if(o|0){n=+g[o+264>>2]*x+ +g[o+268>>2]*y+ +g[o+272>>2]*z;p=+g[o+280>>2]*x+ +g[o+284>>2]*y+ +g[o+288>>2]*z;q=+g[o+296>>2]*x+ +g[o+300>>2]*y+ +g[o+304>>2]*z}else{n=0.0;p=0.0;q=0.0}if(B|0){r=+g[B+264>>2]*u+ +g[B+268>>2]*v+ +g[B+272>>2]*w;s=u*+g[B+280>>2]+v*+g[B+284>>2]+w*+g[B+288>>2];t=u*+g[B+296>>2]+v*+g[B+300>>2]+w*+g[B+304>>2]}else{r=0.0;s=0.0;t=0.0}s=1.0/(n*x+p*y+q*z+0.0+(r*u+s*v+t*w));g[C+(D*152|0)+108>>2]=s;if(o|0){p=+g[b+(e*244|0)+192>>2];q=+g[b+(e*244|0)+196>>2];r=+g[b+(e*244|0)+200>>2];n=(+g[b+(e*244|0)+176>>2]+ +g[b+(e*244|0)+208>>2])*0.0+(+g[b+(e*244|0)+180>>2]+ +g[b+(e*244|0)+212>>2])*0.0+(+g[b+(e*244|0)+184>>2]+ +g[b+(e*244|0)+216>>2])*0.0}else{p=0.0;q=0.0;r=0.0;n=0.0}n=n+(p*x+q*y+r*z);if(!B){t=0.0;x=0.0;z=0.0;y=-0.0;u=t*u;x=x*v;x=u+x;z=z*w;z=x+z;z=y+z;z=n+z;z=0.0-z;z=s*z;f=C+(D*152|0)+112|0;g[f>>2]=z;f=C+(D*152|0)+116|0;g[f>>2]=0.0;A=-A;f=C+(D*152|0)+120|0;g[f>>2]=A;f=C+(D*152|0)+124|0;c[f>>2]=h;return}t=+g[b+(f*244|0)+192>>2];x=+g[b+(f*244|0)+196>>2];z=+g[b+(f*244|0)+200>>2];y=(+g[b+(f*244|0)+176>>2]+ +g[b+(f*244|0)+208>>2])*-0.0+(+g[b+(f*244|0)+180>>2]+ +g[b+(f*244|0)+212>>2])*-0.0+(+g[b+(f*244|0)+184>>2]+ +g[b+(f*244|0)+216>>2])*-0.0;u=t*u;x=x*v;x=u+x;z=z*w;z=x+z;z=y+z;z=n+z;z=0.0-z;z=s*z;f=C+(D*152|0)+112|0;g[f>>2]=z;f=C+(D*152|0)+116|0;g[f>>2]=0.0;A=-A;f=C+(D*152|0)+120|0;g[f>>2]=A;f=C+(D*152|0)+124|0;c[f>>2]=h;return}function Od(b,d){b=b|0;d=d|0;var e=0,f=0.0,h=0,j=0,l=0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0;n=i;i=i+32|0;c[b+236>>2]=2;c[b+312>>2]=0;c[b+312+4>>2]=0;c[b+312+8>>2]=0;c[b+312+12>>2]=0;c[b+312+16>>2]=0;c[b+312+20>>2]=0;c[b+312+24>>2]=0;c[b+312+28>>2]=0;c[b+544>>2]=1065353216;c[b+548>>2]=1065353216;c[b+552>>2]=1065353216;g[b+556>>2]=0.0;c[b+348>>2]=1065353216;c[b+352>>2]=1065353216;c[b+356>>2]=1065353216;e=b+360|0;h=e+36|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(h|0));c[b+412>>2]=0;c[b+412+4>>2]=0;c[b+412+8>>2]=0;c[b+412+12>>2]=0;c[b+412+16>>2]=0;c[b+412+20>>2]=0;c[b+412+24>>2]=0;c[b+412+28>>2]=0;f=+g[d+92>>2];m=+g[d+96>>2];g[n+20>>2]=f;g[n+16>>2]=m;g[n+12>>2]=0.0;g[n+8>>2]=1.0;c[b+444>>2]=c[(f<0.0?n+12|0:f>1.0?n+8|0:n+20|0)>>2];g[n+4>>2]=0.0;g[n>>2]=1.0;c[b+448>>2]=c[(m<0.0?n+4|0:m>1.0?n:n+16|0)>>2];c[b+472>>2]=c[d+112>>2];c[b+476>>2]=c[d+116>>2];e=c[d+4>>2]|0;c[b+480>>2]=e;c[b+608>>2]=0;c[b+612>>2]=0;a[b+452>>0]=a[d+120>>0]|0;c[b+456>>2]=c[d+124>>2];c[b+460>>2]=c[d+128>>2];c[b+464>>2]=c[d+132>>2];c[b+468>>2]=c[d+136>>2];if(!e){c[b+4>>2]=c[d+8>>2];c[b+4+4>>2]=c[d+8+4>>2];c[b+4+8>>2]=c[d+8+8>>2];c[b+4+12>>2]=c[d+8+12>>2];c[b+20>>2]=c[d+24>>2];c[b+20+4>>2]=c[d+24+4>>2];c[b+20+8>>2]=c[d+24+8>>2];c[b+20+12>>2]=c[d+24+12>>2];c[b+36>>2]=c[d+40>>2];c[b+36+4>>2]=c[d+40+4>>2];c[b+36+8>>2]=c[d+40+8>>2];c[b+36+12>>2]=c[d+40+12>>2];c[b+52>>2]=c[d+56>>2];c[b+52+4>>2]=c[d+56+4>>2];c[b+52+8>>2]=c[d+56+8>>2];c[b+52+12>>2]=c[d+56+12>>2];e=b+4|0;h=b+20|0;j=b+36|0;l=b+52|0}else{Cb[c[(c[e>>2]|0)+8>>2]&127](e,b+4|0);e=b+4|0;h=b+20|0;j=b+36|0;l=b+52|0}c[b+68>>2]=c[e>>2];c[b+68+4>>2]=c[e+4>>2];c[b+68+8>>2]=c[e+8>>2];c[b+68+12>>2]=c[e+12>>2];c[b+84>>2]=c[h>>2];c[b+84+4>>2]=c[h+4>>2];c[b+84+8>>2]=c[h+8>>2];c[b+84+12>>2]=c[h+12>>2];c[b+100>>2]=c[j>>2];c[b+100+4>>2]=c[j+4>>2];c[b+100+8>>2]=c[j+8>>2];c[b+100+12>>2]=c[j+12>>2];c[b+116>>2]=c[l>>2];c[b+116+4>>2]=c[l+4>>2];c[b+116+8>>2]=c[l+8>>2];c[b+116+12>>2]=c[l+12>>2];c[b+132>>2]=0;c[b+132+4>>2]=0;c[b+132+8>>2]=0;c[b+132+12>>2]=0;c[b+132+16>>2]=0;c[b+132+20>>2]=0;c[b+132+24>>2]=0;c[b+132+28>>2]=0;c[b+224>>2]=c[d+100>>2];c[b+232>>2]=c[d+104>>2];c[b+228>>2]=c[d+108>>2];Cb[c[(c[b>>2]|0)+12>>2]&127](b,c[d+72>>2]|0);e=c[5815]|0;c[5815]=e+1;c[b+508>>2]=e;f=+g[d>>2];e=c[b+204>>2]|0;if(f==0.0){c[b+204>>2]=e|1;m=0.0}else{c[b+204>>2]=e&-2;m=1.0/f}g[b+344>>2]=m;p=f*+g[b+384>>2];o=f*+g[b+388>>2];g[b+364>>2]=f*+g[b+380>>2];g[b+368>>2]=p;g[b+372>>2]=o;g[b+376>>2]=0.0;f=+g[d+76>>2];h=f!=0.0?(g[k>>2]=1.0/f,c[k>>2]|0):0;f=+g[d+80>>2];e=f!=0.0?(g[k>>2]=1.0/f,c[k>>2]|0):0;f=+g[d+84>>2];d=f!=0.0?(g[k>>2]=1.0/f,c[k>>2]|0):0;c[b+396>>2]=h;c[b+400>>2]=e;c[b+404>>2]=d;g[b+408>>2]=0.0;r=m*+g[b+352>>2];x=m*+g[b+356>>2];g[b+560>>2]=m*+g[b+348>>2];g[b+564>>2]=r;g[b+568>>2]=x;g[b+572>>2]=0.0;x=+g[b+4>>2];r=(c[k>>2]=h,+g[k>>2]);w=+g[b+8>>2];f=(c[k>>2]=e,+g[k>>2]);v=+g[b+12>>2];o=(c[k>>2]=d,+g[k>>2]);u=+g[b+20>>2];t=+g[b+24>>2];s=+g[b+28>>2];q=+g[b+36>>2];p=+g[b+40>>2];m=+g[b+44>>2];g[b+264>>2]=x*x*r+w*w*f+v*v*o;g[b+268>>2]=x*r*u+w*f*t+v*o*s;g[b+272>>2]=x*r*q+w*f*p+v*o*m;g[b+276>>2]=0.0;g[b+280>>2]=x*r*u+w*f*t+v*o*s;g[b+284>>2]=u*r*u+t*f*t+s*o*s;g[b+288>>2]=r*u*q+f*t*p+o*s*m;g[b+292>>2]=0.0;g[b+296>>2]=x*r*q+w*f*p+v*o*m;g[b+300>>2]=u*r*q+t*f*p+s*o*m;g[b+304>>2]=q*r*q+p*f*p+m*o*m;g[b+308>>2]=0.0;c[b+504>>2]=0;c[b+512>>2]=0;c[b+512+4>>2]=0;c[b+512+8>>2]=0;c[b+512+12>>2]=0;c[b+512+16>>2]=0;c[b+512+20>>2]=0;c[b+512+24>>2]=0;c[b+512+28>>2]=0;m=+g[b+344>>2];o=m*+g[b+352>>2];p=m*+g[b+356>>2];g[b+560>>2]=+g[b+348>>2]*m;g[b+564>>2]=o;g[b+568>>2]=p;e=b+572|0;h=e+36|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(h|0));i=n;return}function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=hh(a+928|0,l)|0;a:do if(d){f=c[a+936>>2]|0;if((f|0)<=-1){d=c[a+928>>2]|0;break}if((f|0)>0){h=0;while(1){e=c[d+32>>2]|0;h=h+1|0;if(!e)break a;if((h|0)>=(f|0)){d=e;break}else d=e}}}else d=0;while(0);g[l>>2]=i-m;g[l+4>>2]=j-m;g[l+8>>2]=k-m;g[l+12>>2]=0.0;g[l+16>>2]=m+i;g[l+20>>2]=m+j;g[l+24>>2]=m+k;g[l+28>>2]=0.0;lf(a+928|0,d,l);o=o+1|0}while((o|0)!=(n|0))}Bg(a);d=c[a+928>>2]|0;if(d){o=c[a+192>>2]|0;r=+Sb[c[(c[o>>2]|0)+48>>2]&15](o);t=+g[d+4>>2]-r;s=+g[d+8>>2]-r;g[a+892>>2]=+g[d>>2]-r;g[a+896>>2]=t;g[a+900>>2]=s;g[a+904>>2]=0.0;s=r+ +g[d+20>>2];t=r+ +g[d+24>>2];g[a+908>>2]=r+ +g[d+16>>2];g[a+912>>2]=s;g[a+916>>2]=t;g[a+920>>2]=0.0;d=c[a+188>>2]|0;if(d|0){o=c[a+684>>2]|0;n=c[o+32>>2]|0;yb[c[(c[n>>2]|0)+16>>2]&31](n,d,a+892|0,a+908|0,c[o+36>>2]|0)}}else{c[a+892>>2]=0;c[a+892+4>>2]=0;c[a+892+8>>2]=0;c[a+892+12>>2]=0;c[a+892+16>>2]=0;c[a+892+20>>2]=0;c[a+892+24>>2]=0;c[a+892+28>>2]=0}f=c[a+732>>2]|0;if((f|0)<=0){eg(a);o=a+1148|0;c[o>>2]=c[b>>2];c[o+4>>2]=c[b+4>>2];c[o+8>>2]=c[b+8>>2];c[o+12>>2]=c[b+12>>2];o=a+1164|0;n=b+16|0;c[o>>2]=c[n>>2];c[o+4>>2]=c[n+4>>2];c[o+8>>2]=c[n+8>>2];c[o+12>>2]=c[n+12>>2];o=a+1180|0;n=b+32|0;c[o>>2]=c[n>>2];c[o+4>>2]=c[n+4>>2];c[o+8>>2]=c[n+8>>2];c[o+12>>2]=c[n+12>>2];a=a+1196|0;b=b+48|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}d=c[a+740>>2]|0;e=0;do{n=c[d+(e*52|0)+8>>2]|0;o=c[d+(e*52|0)+12>>2]|0;r=+g[n+8>>2]-+g[o+8>>2];s=+g[n+12>>2]-+g[o+12>>2];t=+g[n+16>>2]-+g[o+16>>2];t=+O(+(r*r+s*s+t*t));g[d+(e*52|0)+16>>2]=t;g[d+(e*52|0)+28>>2]=t*t;e=e+1|0}while((e|0)!=(f|0));d=c[a+740>>2]|0;e=0;do{g[d+(e*52|0)+24>>2]=(+g[(c[d+(e*52|0)+8>>2]|0)+88>>2]+ +g[(c[d+(e*52|0)+12>>2]|0)+88>>2])/+g[(c[d+(e*52|0)+4>>2]|0)+4>>2];e=e+1|0}while((e|0)!=(f|0));eg(a);o=a+1148|0;c[o>>2]=c[b>>2];c[o+4>>2]=c[b+4>>2];c[o+8>>2]=c[b+8>>2];c[o+12>>2]=c[b+12>>2];o=a+1164|0;n=b+16|0;c[o>>2]=c[n>>2];c[o+4>>2]=c[n+4>>2];c[o+8>>2]=c[n+8>>2];c[o+12>>2]=c[n+12>>2];o=a+1180|0;n=b+32|0;c[o>>2]=c[n>>2];c[o+4>>2]=c[n+4>>2];c[o+8>>2]=c[n+8>>2];c[o+12>>2]=c[n+12>>2];a=a+1196|0;b=b+48|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function Qd(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0,j=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0,F=0,G=0,H=0,I=0;F=i;i=i+96|0;d=c[a+216>>2]|0;if(+g[d+4>>2]==0.0){E=0;i=F;return E|0}E=c[b>>2]|0;if(!(Zb[c[(c[d>>2]|0)+8>>2]&31](d,c[E+188>>2]|0)|0)){E=1;i=F;return E|0}b=c[E+192>>2]|0;D=c[a+216>>2]|0;if((c[b+4>>2]|0)!=32){c[F+32>>2]=0;c[F+32+4>>2]=b;c[F+32+8>>2]=E;c[F+32+12>>2]=E+4;c[F+32+16>>2]=-1;c[F+32+20>>2]=-1;bd(a+68|0,a+132|0,F+32|0,D);E=1;i=F;return E|0}if((E|0)==0?1:(c[E+236>>2]|0)!=8){E=1;i=F;return E|0}if(c[E+752>>2]|0?(c[E+988>>2]|0)==0:0)gg(E);A=+g[a+180>>2]-+g[a+116>>2];B=+g[a+184>>2]-+g[a+120>>2];C=+g[a+188>>2]-+g[a+124>>2];b=c[E+988>>2]|0;if(!b){q=c[E+752>>2]|0;if((q|0)>0){p=c[E+760>>2]|0;f=1.0;d=0;r=0;b=-1;l=1065353216;h=0;do{I=c[p+(r*44|0)+8>>2]|0;H=c[p+(r*44|0)+12>>2]|0;G=c[p+(r*44|0)+16>>2]|0;e=+Mh(a+116|0,A,B,C,+g[I+8>>2],+g[I+12>>2],+g[I+16>>2],+g[H+8>>2],+g[H+12>>2],+g[H+16>>2],+g[G+8>>2],+g[G+12>>2],+g[G+16>>2],f);if(e>0.0){f=e;d=d+1|0;b=r;l=(g[k>>2]=e,c[k>>2]|0);h=3}r=r+1|0}while((r|0)!=(q|0))}else{d=0;b=-1;l=1065353216;h=0}}else{c[F+32>>2]=3220;c[F+32+4>>2]=c[a+116>>2];c[F+32+4+4>>2]=c[a+116+4>>2];c[F+32+4+8>>2]=c[a+116+8>>2];c[F+32+4+12>>2]=c[a+116+12>>2];g[F+32+36>>2]=A;g[F+32+40>>2]=B;g[F+32+44>>2]=C;g[F+32+48>>2]=0.0;c[F+32+20>>2]=c[a+180>>2];c[F+32+20+4>>2]=c[a+180+4>>2];c[F+32+20+8>>2]=c[a+180+8>>2];c[F+32+20+12>>2]=c[a+180+12>>2];c[F+32+52>>2]=1065353216;c[F+32+56>>2]=0;c[F+32+60>>2]=0;ff(b,a+116|0,a+180|0,F+32|0);b=c[F+32+56>>2]|0;if(!b){d=0;b=-1;l=1065353216;h=0}else{d=1;b=(b-(c[E+760>>2]|0)|0)/44|0;l=c[F+32+52>>2]|0;h=3}}r=c[E+772>>2]|0;if((r|0)>0){q=c[E+780>>2]|0;f=(c[k>>2]=l,+g[k>>2]);p=0;do{I=c[q+(p*104|0)+8>>2]|0;x=+g[I+8>>2];y=+g[I+12>>2];z=+g[I+16>>2];I=c[q+(p*104|0)+12>>2]|0;o=+g[I+8>>2];s=+g[I+12>>2];t=+g[I+16>>2];I=c[q+(p*104|0)+16>>2]|0;u=+g[I+8>>2];v=+g[I+12>>2];w=+g[I+16>>2];e=+Mh(a+116|0,A,B,C,x,y,z,o,s,t,u,v,w,f);if(e>0.0){f=e;d=d+1|0;b=p;l=(g[k>>2]=e,c[k>>2]|0);h=4}I=c[q+(p*104|0)+20>>2]|0;j=+g[I+8>>2];m=+g[I+12>>2];n=+g[I+16>>2];e=+Mh(a+116|0,A,B,C,x,y,z,o,s,t,j,m,n,f);if(e>0.0){f=e;d=d+1|0;b=p;l=(g[k>>2]=e,c[k>>2]|0);h=4}e=+Mh(a+116|0,A,B,C,o,s,t,u,v,w,j,m,n,f);if(e>0.0){f=e;d=d+1|0;b=p;l=(g[k>>2]=e,c[k>>2]|0);h=4}e=+Mh(a+116|0,A,B,C,x,y,z,u,v,w,j,m,n,f);if(e>0.0){f=e;d=d+1|0;b=p;l=(g[k>>2]=e,c[k>>2]|0);h=4}p=p+1|0}while((p|0)!=(r|0))}if(!d){I=1;i=F;return I|0}if(!((c[k>>2]=l,+g[k>>2])<=+g[D+4>>2])){I=1;i=F;return I|0}c[F+32>>2]=0;c[F+32+4>>2]=b;m=+g[a+180>>2]-+g[a+116>>2];n=+g[a+184>>2]-+g[a+120>>2];o=+g[a+188>>2]-+g[a+124>>2];e=1.0/+O(+(m*m+n*n+o*o));if((h|0)==3){d=c[E+748+12>>2]|0;e=+g[d+(b*44|0)+20>>2];j=+g[d+(b*44|0)+24>>2];f=+g[d+(b*44|0)+28>>2];if(m*e+n*j+o*f>0.0){m=-e;j=-j;f=-f;e=0.0}else{m=e;e=+g[d+(b*44|0)+32>>2]}}else{m=-(m*e);j=-(n*e);f=-(o*e);e=0.0}c[F>>2]=E;c[F+4>>2]=F+32;g[F+8>>2]=m;g[F+12>>2]=j;g[F+16>>2]=f;g[F+20>>2]=e;c[F+24>>2]=l;+_b[c[(c[D>>2]|0)+12>>2]&15](D,F,1);I=1;i=F;return I|0}function Rd(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0;m=i;i=i+400|0;f=c[d+36>>2]|0;d=c[e+36>>2]|0;e=c[b+24>>2]|0;if(((e|0)==(c[b+28>>2]|0)?c[e+1132>>2]|0:0)?(k=(_(c[d+380>>2]|0,c[e+1112>>2]|0)|0)+(c[f+380>>2]|0)|0,a[(c[e+1140>>2]|0)+k>>0]|0):0){c[5802]=(c[5802]|0)+1;i=m;return}c[m+344+4>>2]=35;c[m+344+8>>2]=0;c[m+344+12>>2]=1065353216;c[m+344+16>>2]=1065353216;c[m+344+20>>2]=1065353216;g[m+344+24>>2]=0.0;c[m+344>>2]=3436;c[m+344+52>>2]=f;g[m+344+44>>2]=0.0;c[m+288+4>>2]=35;c[m+288+8>>2]=0;c[m+288+12>>2]=1065353216;c[m+288+16>>2]=1065353216;c[m+288+20>>2]=1065353216;g[m+288+24>>2]=0.0;c[m+288>>2]=3436;c[m+288+52>>2]=d;g[m+288+44>>2]=0.0;if((a[22456]|0)==0?Wa(22456)|0:0){if((a[22464]|0)==0?Wa(22464)|0:0){c[5698]=1065353216;c[5699]=0;c[5700]=0;c[5701]=0;c[5702]=0;c[5703]=1065353216;c[5704]=0;c[5705]=0;c[5706]=0;c[5707]=0;c[5708]=1065353216;g[5709]=0.0;_a(22464)}c[5710]=c[5698];c[5711]=c[5699];c[5712]=c[5700];c[5713]=c[5701];c[5714]=c[5702];c[5715]=c[5703];c[5716]=c[5704];c[5717]=c[5705];c[5718]=c[5706];c[5719]=c[5707];c[5720]=c[5708];c[5721]=c[5709];c[5722]=0;c[5723]=0;c[5724]=0;c[5725]=0;_a(22456)}if((a[22456]|0)==0?Wa(22456)|0:0){if((a[22464]|0)==0?Wa(22464)|0:0){c[5698]=1065353216;c[5699]=0;c[5700]=0;c[5701]=0;c[5702]=0;c[5703]=1065353216;c[5704]=0;c[5705]=0;c[5706]=0;c[5707]=0;c[5708]=1065353216;g[5709]=0.0;_a(22464)}c[5710]=c[5698];c[5711]=c[5699];c[5712]=c[5700];c[5713]=c[5701];c[5714]=c[5702];c[5715]=c[5703];c[5716]=c[5704];c[5717]=c[5705];c[5718]=c[5706];c[5719]=c[5707];c[5720]=c[5708];c[5721]=c[5709];c[5722]=0;c[5723]=0;c[5724]=0;c[5725]=0;_a(22456)}o=+g[f+232>>2]-+g[d+232>>2];n=+g[f+236>>2]-+g[d+236>>2];g[m>>2]=+g[f+228>>2]-+g[d+228>>2];g[m+4>>2]=o;g[m+8>>2]=n;g[m+12>>2]=0.0;if(!(!(Jd(m+344|0,22840,m+288|0,22840,m,m+232|0)|0)?!(Pc(m+344|0,22840,m+288|0,22840,m,m+232|0,0)|0):0))h=18;if((h|0)==18?(k=m+16+4|0,a[m+16+152>>0]=0,c[k>>2]=0,c[k+4>>2]=0,c[k+8>>2]=0,c[k+12>>2]=0,c[k+16>>2]=0,c[k+20>>2]=0,c[m+16>>2]=3256,jd(b,m+232|0,f,0,0,d,0,0,m+16|0)|0):0){c[6435]=(c[6435]|0)+1;d=yc(235)|0;if(!d)k=0;else{c[(d+4+15&-16)+-4>>2]=d;k=d+4+15&-16}d=k+152|0;Qn(k|0,0,156)|0;c[k>>2]=3256;e=k+4|0;f=m+16+4|0;h=e+100|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(h|0));e=k+104|0;c[e>>2]=c[m+16+104>>2];c[e+4>>2]=c[m+16+104+4>>2];c[e+8>>2]=c[m+16+104+8>>2];c[e+12>>2]=c[m+16+104+12>>2];e=k+120|0;c[e>>2]=c[m+16+120>>2];c[e+4>>2]=c[m+16+120+4>>2];c[e+8>>2]=c[m+16+120+8>>2];c[e+12>>2]=c[m+16+120+12>>2];e=k+136|0;c[e>>2]=c[m+16+136>>2];c[e+4>>2]=c[m+16+136+4>>2];c[e+8>>2]=c[m+16+136+8>>2];c[e+12>>2]=c[m+16+136+12>>2];a[d>>0]=a[m+16+152>>0]|0;e=k+156|0;f=m+16+156|0;h=e+60|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(h|0));h=c[b+24>>2]|0;j=k;d=c[h+852>>2]|0;if((d|0)==(c[h+856>>2]|0)?(l=d|0?d<<1:1,(d|0)<(l|0)):0){if(!l)f=0;else{c[6435]=(c[6435]|0)+1;d=yc((l<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}f=d;d=c[h+852>>2]|0}if((d|0)>0){e=0;do{c[f+(e<<2)>>2]=c[(c[h+860>>2]|0)+(e<<2)>>2];e=e+1|0}while((e|0)!=(d|0))}e=c[h+860>>2]|0;if(e){if(a[h+864>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[h+852>>2]|0}c[h+860>>2]=0}a[h+864>>0]=1;c[h+860>>2]=f;c[h+856>>2]=l}c[(c[h+860>>2]|0)+(d<<2)>>2]=j;c[h+852>>2]=d+1;j=c[b+24>>2]|0;l=c[b+28>>2]|0;n=+g[j+348>>2];o=+g[l+348>>2];b=k+64|0;g[b>>2]=+g[b>>2]*(n>o?n:o);b=k+68|0;g[b>>2]=+g[b>>2]*(+g[j+360>>2]+ +g[l+360>>2])*.5}i=m;return}function Sd(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0.0,q=0.0,r=0.0;if(a[b+165>>0]|0){f=c[b+88>>2]|0;a:do if((f|0)>0&e){h=c[b+96>>2]|0;m=+g[d>>2];j=+g[d+4>>2];k=+g[d+8>>2];l=+g[b+168>>2];e=0;while(1){r=+g[h+(e<<4)>>2]-m;q=+g[h+(e<<4)+4>>2]-j;p=+g[h+(e<<4)+8>>2]-k;if(r*r+q*q+p*p<=l)break;e=e+1|0;if((e|0)>=(f|0))break a}return e|0}while(0);o=(c[b+32>>2]|0)+12|0;c[o>>2]=(c[o>>2]|0)+1;if((f|0)==(c[b+92>>2]|0)?(i=f|0?f<<1:1,(f|0)<(i|0)):0){if(!i)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((i<<4|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[b+88>>2]|0}if((f|0)>0){h=0;do{o=e+(h<<4)|0;n=(c[b+96>>2]|0)+(h<<4)|0;c[o>>2]=c[n>>2];c[o+4>>2]=c[n+4>>2];c[o+8>>2]=c[n+8>>2];c[o+12>>2]=c[n+12>>2];h=h+1|0}while((h|0)!=(f|0))}f=c[b+96>>2]|0;if(f|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=e;c[b+92>>2]=i;e=c[b+88>>2]|0}else e=f;o=(c[b+96>>2]|0)+(e<<4)|0;c[o>>2]=c[d>>2];c[o+4>>2]=c[d+4>>2];c[o+8>>2]=c[d+8>>2];c[o+12>>2]=c[d+12>>2];d=c[b+88>>2]|0;c[b+88>>2]=d+1;c[(c[b+32>>2]|0)+16>>2]=c[b+96>>2];return d|0}h=c[b+108>>2]|0;b:do if((h|0)>0&e){e=c[b+116>>2]|0;j=+g[d>>2];k=+g[d+4>>2];l=+g[d+8>>2];m=+g[b+168>>2];i=0;while(1){p=+g[e+(i<<2)>>2]-j;q=+g[e+(i+1<<2)>>2]-k;r=+g[e+(i+2<<2)>>2]-l;f=i+3|0;if(p*p+q*q+r*r<=m)break;if((f|0)<(h|0))i=f;else break b}d=(i|0)/3|0;return d|0}while(0);e=c[b+112>>2]|0;if((h|0)==(e|0)){n=h|0?h<<1:1;if((h|0)<(n|0)){if(!n)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((n<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=c[b+108>>2]|0}i=c[b+116>>2]|0;if((h|0)<=0)if(!i)f=b+120|0;else o=34;else{f=0;do{c[e+(f<<2)>>2]=c[i+(f<<2)>>2];f=f+1|0}while((f|0)!=(h|0));o=34}if((o|0)==34){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[i+-4>>2]|0)}c[b+116>>2]=0;f=b+120|0}a[f>>0]=1;c[b+116>>2]=e;c[b+112>>2]=n;f=c[b+108>>2]|0;h=n}else f=h}else{f=h;h=e}c[(c[b+116>>2]|0)+(f<<2)>>2]=c[d>>2];e=f+1|0;c[b+108>>2]=e;if((e|0)==(h|0)){n=h|0?h<<1:1;if((h|0)<(n|0)){if(!n)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((n<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=c[b+108>>2]|0}i=c[b+116>>2]|0;if((h|0)<=0)if(!i)f=b+120|0;else o=48;else{f=0;do{c[e+(f<<2)>>2]=c[i+(f<<2)>>2];f=f+1|0}while((f|0)!=(h|0));o=48}if((o|0)==48){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[i+-4>>2]|0)}c[b+116>>2]=0;f=b+120|0}a[f>>0]=1;c[b+116>>2]=e;c[b+112>>2]=n;e=c[b+108>>2]|0;h=n}else e=h}c[(c[b+116>>2]|0)+(e<<2)>>2]=c[d+4>>2];e=e+1|0;c[b+108>>2]=e;if((e|0)==(h|0)){n=h|0?h<<1:1;if((h|0)<(n|0)){if(!n)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((n<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=c[b+108>>2]|0}i=c[b+116>>2]|0;if((h|0)<=0)if(!i)f=b+120|0;else o=62;else{f=0;do{c[e+(f<<2)>>2]=c[i+(f<<2)>>2];f=f+1|0}while((f|0)!=(h|0));o=62}if((o|0)==62){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[i+-4>>2]|0)}c[b+116>>2]=0;f=b+120|0}a[f>>0]=1;c[b+116>>2]=e;c[b+112>>2]=n;e=c[b+108>>2]|0}else e=h}o=c[b+116>>2]|0;c[o+(e<<2)>>2]=c[d+8>>2];d=e+1|0;c[b+108>>2]=d;b=c[b+32>>2]|0;c[b+12>>2]=(c[b+12>>2]|0)+1;c[b+16>>2]=o;d=((d|0)/3|0)+-1|0;return d|0}function Td(b){b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0;k=i;i=i+16|0;if(!(a[b+1308>>0]|0)){i=k;return}g[b+928>>2]=0.0;g[b+992>>2]=0.0;g[b+1056>>2]=0.0;c[b+712>>2]=0;c[b+712+4>>2]=0;c[b+712+8>>2]=0;c[b+712+12>>2]=0;sd(b,(c[b+28>>2]|0)+4|0,(c[b+32>>2]|0)+4|0);Ab[c[(c[b>>2]|0)+44>>2]&255](b);e=+g[b+1284>>2];f=+g[b+1288>>2];h=+g[b+1292>>2];if(+g[b+696>>2]>=+g[b+680>>2]){l=(a[b+1300>>0]|0)==0;j=c[(l?b+1160|0:b+1096|0)>>2]|0;d=c[(l?b+1144|0:b+1080|0)>>2]|0;c[k>>2]=c[(l?b+1128|0:b+1064|0)>>2];c[k+4>>2]=d;c[k+8>>2]=j;g[k+12>>2]=0.0;Lh(c[b+28>>2]|0,c[b+32>>2]|0,b+176|0,k,e,f,h,e,f,h)}if(+g[b+700>>2]>=+g[b+684>>2]){d=(a[b+1300>>0]|0)==0;l=c[(d?b+1164|0:b+1100|0)>>2]|0;j=c[(d?b+1148|0:b+1084|0)>>2]|0;c[k>>2]=c[(d?b+1132|0:b+1068|0)>>2];c[k+4>>2]=j;c[k+8>>2]=l;g[k+12>>2]=0.0;Lh(c[b+28>>2]|0,c[b+32>>2]|0,b+260|0,k,e,f,h,e,f,h)}if(+g[b+704>>2]>=+g[b+688>>2]){d=(a[b+1300>>0]|0)==0;l=c[(d?b+1168|0:b+1104|0)>>2]|0;j=c[(d?b+1152|0:b+1088|0)>>2]|0;c[k>>2]=c[(d?b+1136|0:b+1072|0)>>2];c[k+4>>2]=j;c[k+8>>2]=l;g[k+12>>2]=0.0;Lh(c[b+28>>2]|0,c[b+32>>2]|0,b+344|0,k,e,f,h,e,f,h)}j=0;do{e=+g[b+868+(j<<6)>>2];f=+g[b+868+(j<<6)+4>>2];h=+ik(+g[b+1192+(j<<2)>>2],e,f);g[b+868+(j<<6)+52>>2]=h;do if(!(e>f)){if(e>h){c[b+868+(j<<6)+56>>2]=1;d=b+868+(j<<6)+48|0;g[d>>2]=h-e;if(h-e>3.1415927410125732){g[d>>2]=h-e+-6.2831854820251465;d=19;break}if(!(h-e<-3.1415927410125732)){d=19;break}g[d>>2]=h-e+6.2831854820251465;d=19;break}d=b+868+(j<<6)+56|0;if(!(f>2]=0;d=18;break}c[d>>2]=2;d=b+868+(j<<6)+48|0;g[d>>2]=h-f;if(h-f>3.1415927410125732){g[d>>2]=h-f+-6.2831854820251465;d=19;break}if(h-f<-3.1415927410125732){g[d>>2]=h-f+6.2831854820251465;d=19}else d=19}else{c[b+868+(j<<6)+56>>2]=0;d=18}while(0);if((d|0)==18?(d=0,a[b+868+(j<<6)+44>>0]|0):0)d=19;if((d|0)==19){K=b+1208+(j<<4)|0;c[k>>2]=c[K>>2];c[k+4>>2]=c[K+4>>2];c[k+8>>2]=c[K+8>>2];c[k+12>>2]=c[K+12>>2];K=b+428+(j*84|0)|0;d=c[b+28>>2]|0;J=+g[d+4>>2];I=+g[d+20>>2];H=+g[d+36>>2];F=+g[d+8>>2];E=+g[d+24>>2];D=+g[d+40>>2];B=+g[d+12>>2];A=+g[d+28>>2];z=+g[d+44>>2];l=c[b+32>>2]|0;x=+g[l+4>>2];w=+g[l+20>>2];v=+g[l+36>>2];t=+g[l+8>>2];s=+g[l+24>>2];r=+g[l+40>>2];p=+g[l+12>>2];n=+g[l+28>>2];e=+g[l+44>>2];c[K>>2]=0;c[K+4>>2]=0;c[K+8>>2]=0;c[K+12>>2]=0;o=+g[k>>2];m=+g[k+4>>2];f=+g[k+8>>2];g[b+428+(j*84|0)+16>>2]=J*o+I*m+H*f;g[b+428+(j*84|0)+20>>2]=F*o+E*m+D*f;g[b+428+(j*84|0)+24>>2]=B*o+A*m+z*f;g[b+428+(j*84|0)+28>>2]=0.0;g[b+428+(j*84|0)+32>>2]=x*-o+w*-m+v*-f;g[b+428+(j*84|0)+36>>2]=t*-o+s*-m+r*-f;g[b+428+(j*84|0)+40>>2]=p*-o+n*-m+e*-f;g[b+428+(j*84|0)+44>>2]=0.0;G=(J*o+I*m+H*f)*+g[d+396>>2];C=(F*o+E*m+D*f)*+g[d+400>>2];y=(B*o+A*m+z*f)*+g[d+404>>2];g[b+428+(j*84|0)+48>>2]=G;g[b+428+(j*84|0)+52>>2]=C;g[b+428+(j*84|0)+56>>2]=y;g[b+428+(j*84|0)+60>>2]=0.0;u=(x*-o+w*-m+v*-f)*+g[l+396>>2];q=(t*-o+s*-m+r*-f)*+g[l+400>>2];h=(p*-o+n*-m+e*-f)*+g[l+404>>2];g[b+428+(j*84|0)+64>>2]=u;g[b+428+(j*84|0)+68>>2]=q;g[b+428+(j*84|0)+72>>2]=h;g[b+428+(j*84|0)+76>>2]=0.0;g[b+428+(j*84|0)+80>>2]=(J*o+I*m+H*f)*G+(F*o+E*m+D*f)*C+(B*o+A*m+z*f)*y+((x*-o+w*-m+v*-f)*u+(t*-o+s*-m+r*-f)*q+(p*-o+n*-m+e*-f)*h)}j=j+1|0}while((j|0)!=3);i=k;return}function Ud(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,h=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0;p=i;i=i+128|0;c[b+68>>2]=(c[b+68>>2]|0)+1;c[p>>2]=c[d>>2];c[p+4>>2]=c[d+4>>2];c[p+8>>2]=c[d+8>>2];c[p+12>>2]=c[d+12>>2];c[p+16>>2]=c[d+16>>2];c[p+16+4>>2]=c[d+16+4>>2];c[p+16+8>>2]=c[d+16+8>>2];c[p+16+12>>2]=c[d+16+12>>2];c[p+32>>2]=c[d+32>>2];c[p+32+4>>2]=c[d+32+4>>2];c[p+32+8>>2]=c[d+32+8>>2];c[p+32+12>>2]=c[d+32+12>>2];c[p+48>>2]=c[d+48>>2];c[p+48+4>>2]=c[d+48+4>>2];c[p+48+8>>2]=c[d+48+8>>2];c[p+48+12>>2]=c[d+48+12>>2];n=c[e+4>>2]|0;o=+Sb[c[(c[e>>2]|0)+48>>2]&15](e);mc[c[(c[e>>2]|0)+8>>2]&127](e,d,p+112|0,p+96|0);f=+g[p+112>>2];if(+g[b+32>>2]>f)g[b+32>>2]=f;f=+g[p+96>>2];if(+g[b+48>>2]>2]=f;f=+g[p+112+4>>2];if(+g[b+36>>2]>f)g[b+36>>2]=f;f=+g[p+96+4>>2];if(+g[b+52>>2]>2]=f;f=+g[p+112+8>>2];if(+g[b+40>>2]>f)g[b+40>>2]=f;f=+g[p+96+8>>2];if(+g[b+56>>2]>2]=f;l=c[b+64>>2]|0;if(!l){l=b+16|0;k=0}else{c[p+64>>2]=c[p+112>>2];c[p+64+4>>2]=c[p+112+4>>2];c[p+64+8>>2]=c[p+112+8>>2];c[p+64+12>>2]=c[p+112+12>>2];c[p+64+16>>2]=c[p+96>>2];c[p+64+16+4>>2]=c[p+96+4>>2];c[p+64+16+8>>2]=c[p+96+8>>2];c[p+64+16+12>>2]=c[p+96+12>>2];k=c[b+16>>2]|0;d=c[l+4>>2]|0;if(!d){c[6435]=(c[6435]|0)+1;d=yc(63)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}h=d;j=h+44|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(j|0))}else c[l+4>>2]=0;c[d+32>>2]=0;c[d+36>>2]=k;c[d+40>>2]=0;c[d>>2]=c[p+64>>2];c[d+4>>2]=c[p+64+4>>2];c[d+8>>2]=c[p+64+8>>2];c[d+12>>2]=c[p+64+12>>2];c[d+16>>2]=c[p+64+16>>2];c[d+20>>2]=c[p+64+20>>2];c[d+24>>2]=c[p+64+24>>2];c[d+28>>2]=c[p+64+28>>2];lf(l,c[l>>2]|0,d);c[l+12>>2]=(c[l+12>>2]|0)+1;l=b+16|0;k=d}d=c[l>>2]|0;if((d|0)==(c[b+20>>2]|0)?(m=d|0?d<<1:1,(d|0)<(m|0)):0){if(!m)j=0;else{c[6435]=(c[6435]|0)+1;d=yc((m*80|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}j=d;d=c[l>>2]|0}if((d|0)>0){h=0;do{q=j+(h*80|0)|0;r=c[b+24>>2]|0;s=r+(h*80|0)|0;c[q>>2]=c[s>>2];c[q+4>>2]=c[s+4>>2];c[q+8>>2]=c[s+8>>2];c[q+12>>2]=c[s+12>>2];q=j+(h*80|0)+16|0;s=r+(h*80|0)+16|0;c[q>>2]=c[s>>2];c[q+4>>2]=c[s+4>>2];c[q+8>>2]=c[s+8>>2];c[q+12>>2]=c[s+12>>2];q=j+(h*80|0)+32|0;s=r+(h*80|0)+32|0;c[q>>2]=c[s>>2];c[q+4>>2]=c[s+4>>2];c[q+8>>2]=c[s+8>>2];c[q+12>>2]=c[s+12>>2];q=j+(h*80|0)+48|0;s=r+(h*80|0)+48|0;c[q>>2]=c[s>>2];c[q+4>>2]=c[s+4>>2];c[q+8>>2]=c[s+8>>2];c[q+12>>2]=c[s+12>>2];q=j+(h*80|0)+64|0;r=r+(h*80|0)+64|0;c[q>>2]=c[r>>2];c[q+4>>2]=c[r+4>>2];c[q+8>>2]=c[r+8>>2];c[q+12>>2]=c[r+12>>2];h=h+1|0}while((h|0)!=(d|0))}d=c[b+24>>2]|0;if(d|0){if(a[b+28>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+24>>2]=0}a[b+28>>0]=1;c[b+24>>2]=j;c[b+20>>2]=m;d=c[l>>2]|0}s=c[b+24>>2]|0;r=s+(d*80|0)|0;c[r>>2]=c[p>>2];c[r+4>>2]=c[p+4>>2];c[r+8>>2]=c[p+8>>2];c[r+12>>2]=c[p+12>>2];r=s+(d*80|0)+16|0;c[r>>2]=c[p+16>>2];c[r+4>>2]=c[p+16+4>>2];c[r+8>>2]=c[p+16+8>>2];c[r+12>>2]=c[p+16+12>>2];r=s+(d*80|0)+32|0;c[r>>2]=c[p+32>>2];c[r+4>>2]=c[p+32+4>>2];c[r+8>>2]=c[p+32+8>>2];c[r+12>>2]=c[p+32+12>>2];r=s+(d*80|0)+48|0;c[r>>2]=c[p+48>>2];c[r+4>>2]=c[p+48+4>>2];c[r+8>>2]=c[p+48+8>>2];c[r+12>>2]=c[p+48+12>>2];s=s+(d*80|0)+64|0;c[s>>2]=e;c[s+4>>2]=n;g[s+8>>2]=o;c[s+12>>2]=k;c[l>>2]=(c[l>>2]|0)+1;i=p;return}function Vd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;while(1){p=(b+d|0)/2|0;m=c[a+12>>2]|0;n=c[m+(p<<4)>>2]|0;o=c[m+(p<<4)+4>>2]|0;p=c[m+(p<<4)+8>>2]|0;e=b;f=d;while(1){a:do if(!n)while(1){j=c[m+(e<<4)>>2]|0;if(!j)g=-1;else g=c[j+12>>2]|0;k=c[m+(e<<4)+4>>2]|0;if(!k)h=-1;else h=c[k+12>>2]|0;if(!o)i=-1;else i=c[o+12>>2]|0;do if((g|0)<=-1){g=(h|0)>(i|0);if(g|(j|0)==0^1)if((j|0)==0&g)break;else break a;if((k|0)!=(o|0))break a;if((c[m+(e<<4)+8>>2]|0)>>>0<=p>>>0)break a}while(0);e=e+1|0}else{l=c[n+12>>2]|0;if(!o)while(1){i=c[m+(e<<4)>>2]|0;if(!i)g=-1;else g=c[i+12>>2]|0;j=c[m+(e<<4)+4>>2]|0;if(!j)h=-1;else h=c[j+12>>2]|0;do if((g|0)<=(l|0)){g=(h|0)>-1;if(g|(i|0)==(n|0)^1)if((i|0)==(n|0)&g)break;else break a;if(j|0)break a;if((c[m+(e<<4)+8>>2]|0)>>>0<=p>>>0)break a}while(0);e=e+1|0}k=c[o+12>>2]|0;while(1){i=c[m+(e<<4)>>2]|0;if(!i)g=-1;else g=c[i+12>>2]|0;j=c[m+(e<<4)+4>>2]|0;if(!j)h=-1;else h=c[j+12>>2]|0;do if((g|0)<=(l|0)){g=(h|0)>(k|0);if(g|(i|0)==(n|0)^1)if((i|0)==(n|0)&g)break;else break a;if((j|0)!=(o|0))break a;if((c[m+(e<<4)+8>>2]|0)>>>0<=p>>>0)break a}while(0);e=e+1|0}}while(0);b:do if(!n)while(1){j=c[m+(f<<4)>>2]|0;if(!j)g=-1;else g=c[j+12>>2]|0;if(!o)h=-1;else h=c[o+12>>2]|0;k=c[m+(f<<4)+4>>2]|0;if(!k)i=-1;else i=c[k+12>>2]|0;do if((g|0)>=-1){g=(h|0)>(i|0);if(g|(j|0)==0^1)if((j|0)==0&g)break;else break b;if((o|0)!=(k|0))break b;if(p>>>0<=(c[m+(f<<4)+8>>2]|0)>>>0)break b}while(0);f=f+-1|0}else{l=c[n+12>>2]|0;if(!o)while(1){i=c[m+(f<<4)>>2]|0;if(!i)g=-1;else g=c[i+12>>2]|0;j=c[m+(f<<4)+4>>2]|0;if(!j)h=-1;else h=c[j+12>>2]|0;do if((l|0)<=(g|0)){g=(h|0)<-1;if(g|(n|0)==(i|0)^1)if((n|0)==(i|0)&g)break;else break b;if(j|0)break b;if(p>>>0<=(c[m+(f<<4)+8>>2]|0)>>>0)break b}while(0);f=f+-1|0}k=c[o+12>>2]|0;while(1){i=c[m+(f<<4)>>2]|0;if(!i)g=-1;else g=c[i+12>>2]|0;j=c[m+(f<<4)+4>>2]|0;if(!j)h=-1;else h=c[j+12>>2]|0;do if((l|0)<=(g|0)){g=(k|0)>(h|0);if(g|(n|0)==(i|0)^1)if((n|0)==(i|0)&g)break;else break b;if((o|0)!=(j|0))break b;if(p>>>0<=(c[m+(f<<4)+8>>2]|0)>>>0)break b}while(0);f=f+-1|0}}while(0);if((e|0)<=(f|0)){h=m+(e<<4)|0;i=c[h>>2]|0;j=c[m+(e<<4)+4>>2]|0;k=c[m+(e<<4)+8>>2]|0;l=c[m+(e<<4)+12>>2]|0;m=m+(f<<4)|0;c[h>>2]=c[m>>2];c[h+4>>2]=c[m+4>>2];c[h+8>>2]=c[m+8>>2];c[h+12>>2]=c[m+12>>2];m=c[a+12>>2]|0;c[m+(f<<4)>>2]=i;c[m+(f<<4)+4>>2]=j;c[m+(f<<4)+8>>2]=k;c[m+(f<<4)+12>>2]=l;e=e+1|0;f=f+-1|0}if((e|0)>(f|0))break;m=c[a+12>>2]|0}if((f|0)>(b|0))Vd(a,b,f);if((e|0)<(d|0))b=e;else break}return}function Wd(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0,h=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0;D=i;i=i+16|0;li(11054);C=c[a+712>>2]|0;if((C|0)>0){c[6435]=(c[6435]|0)+1;d=yc((C<<4|3)+16|0)|0;if(!d)h=0;else{c[(d+4+15&-16)+-4>>2]=d;h=d+4+15&-16}d=0;do{B=h+(d<<4)|0;d=d+1|0;c[B>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0}while((d|0)!=(C|0));f=c[a+712>>2]|0;if((f|0)>0){c[6435]=(c[6435]|0)+1;d=yc((f<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}Qn(d|0,0,f<<2|0)|0;B=h;A=d}else{B=h;A=0}}else{B=0;A=0}s=c[a+1112>>2]|0;if(b){if((s|0)>0){h=c[a+1120>>2]|0;j=0;do{d=c[h+(j<<2)>>2]|0;f=c[d+312>>2]|0;if(f|0){g[d+276>>2]=1.0/+(f|0)*+g[d+276>>2];g[d+280>>2]=1.0/+(f|0)*+g[d+280>>2];g[d+284>>2]=1.0/+(f|0)*+g[d+284>>2];g[d+292>>2]=+g[d+292>>2]*(1.0/+(f|0));g[d+296>>2]=1.0/+(f|0)*+g[d+296>>2];g[d+300>>2]=1.0/+(f|0)*+g[d+300>>2]}j=j+1|0}while((j|0)!=(s|0));j=13}}else j=13;if((j|0)==13?(s|0)>0:0){l=c[a+1120>>2]|0;if(b){b=0;do{d=c[l+(b<<2)>>2]|0;if((c[d+312>>2]|0)>0?(y=+g[a+452>>2],t=+g[d+276>>2]*y,u=y*+g[d+280>>2],v=y*+g[d+284>>2],w=y*+g[d+292>>2],x=y*+g[d+296>>2],y=y*+g[d+300>>2],z=c[d+24>>2]|0,(z|0)>0):0){f=c[d+32>>2]|0;h=c[a+720>>2]|0;j=c[d+12>>2]|0;k=0;do{r=c[f+(k<<2)>>2]|0;q=+g[j+(k<<2)>>2];p=+g[r+8>>2]-+g[d+228>>2];o=+g[r+12>>2]-+g[d+232>>2];n=+g[r+16>>2]-+g[d+236>>2];E=B+(((r-h|0)/104|0)<<4)|0;g[E>>2]=+g[E>>2]+q*(t+(x*n-y*o));E=B+(((r-h|0)/104|0)<<4)+4|0;g[E>>2]=+g[E>>2]+q*(u+(y*p-w*n));E=B+(((r-h|0)/104|0)<<4)+8|0;g[E>>2]=q*(v+(w*o-x*p))+ +g[E>>2];r=A+(((r-h|0)/104|0)<<2)|0;g[r>>2]=q+ +g[r>>2];k=k+1|0}while((k|0)!=(z|0))}b=b+1|0}while((b|0)!=(s|0))}else{b=0;do{d=c[l+(b<<2)>>2]|0;if((c[d+308>>2]|0)>0?(q=+g[a+452>>2],e=+g[d+244>>2]*q,m=q*+g[d+248>>2],n=q*+g[d+252>>2],o=q*+g[d+260>>2],p=q*+g[d+264>>2],q=q*+g[d+268>>2],r=c[d+24>>2]|0,(r|0)>0):0){f=c[d+32>>2]|0;h=c[a+720>>2]|0;j=c[d+12>>2]|0;k=0;do{E=c[f+(k<<2)>>2]|0;y=+g[j+(k<<2)>>2];x=+g[E+8>>2]-+g[d+228>>2];w=+g[E+12>>2]-+g[d+232>>2];v=+g[E+16>>2]-+g[d+236>>2];z=B+(((E-h|0)/104|0)<<4)|0;g[z>>2]=+g[z>>2]+y*(e+(p*v-q*w));z=B+(((E-h|0)/104|0)<<4)+4|0;g[z>>2]=+g[z>>2]+y*(m+(q*x-o*v));z=B+(((E-h|0)/104|0)<<4)+8|0;g[z>>2]=y*(n+(o*w-p*x))+ +g[z>>2];E=A+(((E-h|0)/104|0)<<2)|0;g[E>>2]=y+ +g[E>>2];k=k+1|0}while((k|0)!=(r|0))}b=b+1|0}while((b|0)!=(s|0))}}if((C|0)>0){d=0;do{e=+g[A+(d<<2)>>2];if(e>0.0){E=c[a+720>>2]|0;x=1.0/e*+g[B+(d<<4)+4>>2];y=1.0/e*+g[B+(d<<4)+8>>2];z=E+(d*104|0)+8|0;g[z>>2]=1.0/e*+g[B+(d<<4)>>2]+ +g[z>>2];z=E+(d*104|0)+12|0;g[z>>2]=x+ +g[z>>2];E=E+(d*104|0)+16|0;g[E>>2]=y+ +g[E>>2]}d=d+1|0}while((d|0)!=(C|0))}if(A|0){c[6436]=(c[6436]|0)+1;hd(c[A+-4>>2]|0)}if(B|0){c[6436]=(c[6436]|0)+1;hd(c[B+-4>>2]|0)}d=c[2357]|0;E=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=E;if(E|0){i=D;return}do if(c[d+4>>2]|0){tb(D|0,0)|0;E=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[D+4>>2]|0)-(c[E+4>>2]|0)+(((c[D>>2]|0)-(c[E>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=D;return}}while(0);c[2357]=c[d+20>>2];i=D;return}function Xd(b,d,e,f,h,j){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0,m=0.0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0;C=i;i=i+304|0;B=+g[e+48>>2]-+g[d+48>>2];z=+g[e+52>>2]-+g[d+52>>2];A=+g[e+56>>2]-+g[d+56>>2];Gf(d,e,C+288|0,C+240|0);v=+g[C+240>>2];t=+g[C+288>>2]*v;u=v*+g[C+288+4>>2];v=v*+g[C+288+8>>2];g[C+208>>2]=t;g[C+208+4>>2]=u;g[C+208+8>>2]=v;g[C+208+12>>2]=0.0;w=+g[h+48>>2]-+g[f+48>>2];x=+g[h+52>>2]-+g[f+52>>2];y=+g[h+56>>2]-+g[f+56>>2];Gf(f,h,C+288|0,C+240|0);r=+g[C+240>>2];p=+g[C+288>>2]*r;q=r*+g[C+288+4>>2];r=r*+g[C+288+8>>2];g[C+192>>2]=p;g[C+192+4>>2]=q;g[C+192+8>>2]=r;g[C+192+12>>2]=0.0;e=c[b+12>>2]|0;s=+Sb[c[(c[e>>2]|0)+16>>2]&15](e);e=c[b+16>>2]|0;if(!e)m=0.0;else m=+Sb[c[(c[e>>2]|0)+16>>2]&15](e);s=s*+O(+(t*t+u*u+v*v))+m*+O(+(p*p+q*q+r*r));if(s+ +O(+((w-B)*(w-B)+(x-z)*(x-z)+(y-A)*(y-A)))==0.0){j=0;i=C;return j|0}c[C+240>>2]=9160;g[C+240+36>>2]=999999984306749440.0;a[C+240+40>>0]=0;Ld(b,d,f,C+240|0);h=(a[C+240+40>>0]|0)==0;c[C+288>>2]=c[C+240+20>>2];c[C+288+4>>2]=c[C+240+20+4>>2];c[C+288+8>>2]=c[C+240+20+8>>2];c[C+288+12>>2]=c[C+240+20+12>>2];a:do if(!h?(o=c[C+240+4>>2]|0,l=c[C+240+8>>2]|0,n=c[C+240+12>>2]|0,v=(w-B)*(c[k>>2]=o,+g[k>>2]),v=v+(x-z)*(c[k>>2]=l,+g[k>>2]),!(s+(v+(y-A)*(c[k>>2]=n,+g[k>>2]))<=1.1920928955078125e-07)):0){m=+g[C+240+16>>2];p=+g[C+240+36>>2]+ +g[j+172>>2];b:do if(p>1.0000000474974513e-03){q=p;r=0.0;h=0;while(1){e=c[j+168>>2]|0;if(e|0){D=c[(c[e>>2]|0)+20>>2]|0;c[C+224>>2]=1065353216;c[C+224+4>>2]=1065353216;c[C+224+8>>2]=1065353216;g[C+224+12>>2]=0.0;Fb[D&7](e,C+288|0,.20000000298023224,C+224|0)}m=(w-B)*(c[k>>2]=o,+g[k>>2]);m=m+(x-z)*(c[k>>2]=l,+g[k>>2]);m=s+(m+(y-A)*(c[k>>2]=n,+g[k>>2]));if(m<=1.1920928955078125e-07){l=0;break a}p=r+q/m;if(!(!(p<=r)&(!(p<0.0)&!(p>1.0)))){l=0;break a}Zg(d,B,z,A,C+208|0,p,C+112|0);Zg(f,w,x,y,C+192|0,p,C+48|0);l=c[j+168>>2]|0;if(l|0){D=c[(c[l>>2]|0)+20>>2]|0;c[C+176>>2]=1065353216;c[C+176+4>>2]=0;c[C+176+8>>2]=0;g[C+176+12>>2]=0.0;Fb[D&7](l,C+112+48|0,.20000000298023224,C+176|0)}zb[c[c[j>>2]>>2]&31](j,p);c[C>>2]=9160;g[C+36>>2]=999999984306749440.0;a[C+40>>0]=0;Ld(b,C+112|0,C+48|0,C);if(!(a[C+40>>0]|0)){l=15;break}m=+g[C+36>>2];q=+g[j+172>>2];c[C+288>>2]=c[C+20>>2];c[C+288+4>>2]=c[C+20+4>>2];c[C+288+8>>2]=c[C+20+8>>2];c[C+288+12>>2]=c[C+20+12>>2];e=h+1|0;if((h|0)>63){l=16;break}n=c[C+12>>2]|0;l=c[C+8>>2]|0;o=c[C+4>>2]|0;q=m+q;if(!(q>1.0000000474974513e-03)){m=+g[C+16>>2];break b}else{r=p;h=e}}if((l|0)==15)ic[c[(c[j>>2]|0)+8>>2]&127](j,-1,h);else if((l|0)==16)ic[c[(c[j>>2]|0)+8>>2]&127](j,-2,e);l=0;break a}else p=0.0;while(0);g[j+164>>2]=p;c[j+132>>2]=o;c[j+136>>2]=l;c[j+140>>2]=n;g[j+144>>2]=m;c[j+148>>2]=c[C+288>>2];c[j+148+4>>2]=c[C+288+4>>2];c[j+148+8>>2]=c[C+288+8>>2];c[j+148+12>>2]=c[C+288+12>>2];l=1}else l=0;while(0);D=l;i=C;return D|0}function Yd(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0,i=0,j=0.0,l=0.0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0.0,x=0.0,y=0,z=0.0,A=0.0,B=0.0;c[a+556>>2]=c[b>>2];c[a+556+4>>2]=c[b+4>>2];c[a+556+8>>2]=c[b+8>>2];c[a+556+12>>2]=c[b+12>>2];q=+g[a+568>>2];r=+g[a+560>>2];s=+g[a+564>>2];p=+g[a+556>>2];d=-p-r*0.0-s*0.0;e=(s+q*0.0-p*0.0)*-s+(q*(q+r*0.0-s*0.0)+d*-p)-(q*0.0+p*0.0-r)*-r;f=(q*0.0+p*0.0-r)*-p+(q*(s+q*0.0-p*0.0)+d*-r)-(q+r*0.0-s*0.0)*-s;d=(q+r*0.0-s*0.0)*-r+(d*-s+q*(q*0.0+p*0.0-r))-(s+q*0.0-p*0.0)*-p;if(d*0.0+(f*0.0+e)<-.9999998807907104){j=-0.0;l=1.0;d=0.0;e=0.0}else{B=+O(+((d*0.0+(f*0.0+e)+1.0)*2.0));j=(d*0.0-f*0.0)*(1.0/B);l=(e*0.0-d)*(1.0/B);d=(f-e*0.0)*(1.0/B);e=B*.5}z=1.0/+O(+(e*e+(j*j+l*l+d*d)));j=j*z;n=(g[k>>2]=j,c[k>>2]|0);w=l*z;t=d*z;v=(g[k>>2]=t,c[k>>2]|0);d=e*z;u=(g[k>>2]=d,c[k>>2]|0);e=1.0/+O(+((d*q-p*-j-r*-w-s*-t)*(d*q-p*-j-r*-w-s*-t)+((q*-t+d*s+r*-j-p*-w)*(q*-t+d*s+r*-j-p*-w)+((p*d+q*-j+s*-w-r*-t)*(p*d+q*-j+s*-w-r*-t)+(p*-t+(q*-w+d*r)-s*-j)*(p*-t+(q*-w+d*r)-s*-j)))));z=(p*d+q*-j+s*-w-r*-t)*e;i=(g[k>>2]=z,c[k>>2]|0);A=e*(p*-t+(q*-w+d*r)-s*-j);b=(g[k>>2]=A,c[k>>2]|0);B=e*(q*-t+d*s+r*-j-p*-w);h=(g[k>>2]=B,c[k>>2]|0);p=e*(d*q-p*-j-r*-w-s*-t);e=+g[a+444>>2];m=(g[k>>2]=e,c[k>>2]|0);if(e>=.05000000074505806?(x=+g[a+448>>2],x>=.05000000074505806):0){d=d<-1.0?-1.0:d;d=+T(+(d>1.0?1.0:d))*2.0;if(d>1.1920928955078125e-07){f=1.0/+O(+(t*t+(j*j+w*w)));if(+N(+(w*f))>1.1920928955078125e-07){x=+O(+((t*f*t*f/(w*f*w*f)+1.0)/(1.0/(x*x)+t*f*t*f/(w*f*w*f)/(e*e))));j=j*f;l=w*f;f=t*f;m=(g[k>>2]=x,c[k>>2]|0)}else{j=j*f;l=w*f;f=t*f}}else{j=0.0;l=0.0;f=0.0;m=0}if(+N(+d)>1.1920928955078125e-07){e=(c[k>>2]=m,+g[k>>2]);if(!(d>e)){if(d<-e)d=-e}else d=e;x=d*.5;w=+R(+x)/+O(+(j*j+l*l+f*f));x=+Q(+x);y=(g[k>>2]=j*w,c[k>>2]|0);v=(g[k>>2]=f*w,c[k>>2]|0);w=l*w;u=(g[k>>2]=x,c[k>>2]|0)}else y=n}else y=n;d=+g[a+452>>2];if(d>=.05000000074505806){e=p<-1.0?-1.0:p;e=+T(+(e>1.0?1.0:e))*2.0;if(e>3.1415927410125732){o=(g[k>>2]=-z,c[k>>2]|0);n=(g[k>>2]=-A,c[k>>2]|0);e=-p<-1.0?-1.0:-p;m=(g[k>>2]=-B,c[k>>2]|0);e=+T(+(e>1.0?1.0:e))*2.0}else{o=i;n=b;m=h}f=(c[k>>2]=o,+g[k>>2]);j=(c[k>>2]=n,+g[k>>2]);l=(c[k>>2]=m,+g[k>>2]);if(e>1.1920928955078125e-07){B=1.0/+O(+(f*f+j*j+l*l));o=(g[k>>2]=f*B,c[k>>2]|0);n=(g[k>>2]=j*B,c[k>>2]|0);m=(g[k>>2]=l*B,c[k>>2]|0)}if(+N(+e)>1.1920928955078125e-07){if(!(e>d))if(e<-d)d=-d;else d=e;x=(c[k>>2]=o,+g[k>>2]);z=(c[k>>2]=n,+g[k>>2]);A=(c[k>>2]=m,+g[k>>2]);d=d*.5;B=+R(+d)/+O(+(A*A+(z*z+x*x)));d=+Q(+d);i=(g[k>>2]=x*B,c[k>>2]|0);b=(g[k>>2]=z*B,c[k>>2]|0);h=(g[k>>2]=A*B,c[k>>2]|0)}else d=p}else d=p;s=(c[k>>2]=u,+g[k>>2]);x=(c[k>>2]=i,+g[k>>2]);t=(c[k>>2]=y,+g[k>>2]);B=(c[k>>2]=h,+g[k>>2]);A=(c[k>>2]=v,+g[k>>2]);z=(c[k>>2]=b,+g[k>>2]);g[a+556>>2]=w*B+(s*x+t*d)-A*z;g[a+560>>2]=A*x+(s*z+w*d)-t*B;g[a+564>>2]=t*z+(s*B+A*d)-w*x;g[a+568>>2]=s*d-t*x-w*z-A*B;return}function Zd(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0;c[b>>2]=5224;c[6435]=(c[6435]|0)+1;e=yc(379)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}g[e+308>>2]=9.999999747378752e-05;f=e+332|0;a[f>>0]=a[f>>0]&-16;c[b+24>>2]=e;f=(c[d+20>>2]|0)==0;c[6435]=(c[6435]|0)+1;e=yc(23)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}if(f){c[e>>2]=9072;c[b+28>>2]=e;f=b+28|0}else{c[e>>2]=9120;c[b+28>>2]=e;f=b+28|0}c[6435]=(c[6435]|0)+1;e=yc(43)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}k=c[b+24>>2]|0;l=c[f>>2]|0;a[e+4>>0]=0;c[e>>2]=6032;c[e+16>>2]=0;c[e+20>>2]=3;c[e+12>>2]=k;c[e+8>>2]=l;c[b+32>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5256;c[b+36>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5276;c[b+40>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5296;c[b+44>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5316;c[b+48>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5336;c[b+52>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5356;c[b+56>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5376;c[b+60>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5396;c[b+76>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e>>2]=5396;c[b+80>>2]=e;a[e+4>>0]=1;c[6435]=(c[6435]|0)+1;e=yc(27)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5416;c[b+72>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(35)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}a[e+4>>0]=0;c[e>>2]=5436;c[e+8>>2]=1;c[e+12>>2]=0;c[b+88>>2]=e;c[6435]=(c[6435]|0)+1;e=yc(35)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e>>2]=5436;c[e+8>>2]=1;c[e+12>>2]=0;c[b+84>>2]=e;a[e+4>>0]=1;l=c[d+16>>2]|0;l=(l|0)>80?l:80;e=c[d>>2]|0;if(!e){a[b+12>>0]=1;c[6435]=(c[6435]|0)+1;e=yc(39)|0;if(!e)k=0;else{c[(e+4+15&-16)+-4>>2]=e;k=e+4+15&-16}e=c[d+8>>2]|0;c[k>>2]=772;f=k+4|0;c[f>>2]=e;c[6435]=(c[6435]|0)+1;e=yc((e*772|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[k+16>>2]=e;c[k+12>>2]=e;f=c[f>>2]|0;c[k+8>>2]=f;if(f+-1|0){h=c[k>>2]|0;i=f+-1|0;j=e;do{m=j;j=j+h|0;c[m>>2]=j;i=i+-1|0}while((i|0)!=0);e=e+(_(h,f+-1|0)|0)|0}c[e>>2]=0;c[b+8>>2]=k}else{a[b+12>>0]=0;c[b+8>>2]=e}e=c[d+4>>2]|0;if(e|0){a[b+20>>0]=0;c[b+16>>2]=e;return}a[b+20>>0]=1;c[6435]=(c[6435]|0)+1;e=yc(39)|0;if(!e)k=0;else{c[(e+4+15&-16)+-4>>2]=e;k=e+4+15&-16}e=c[d+12>>2]|0;c[k>>2]=l;f=k+4|0;c[f>>2]=e;e=_(e,l)|0;c[6435]=(c[6435]|0)+1;e=yc(e+19|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[k+16>>2]=e;c[k+12>>2]=e;f=c[f>>2]|0;c[k+8>>2]=f;if(f+-1|0){h=c[k>>2]|0;i=f+-1|0;j=e;do{m=j;j=j+h|0;c[m>>2]=j;i=i+-1|0}while((i|0)!=0);e=e+(_(h,f+-1|0)|0)|0}c[e>>2]=0;c[b+16>>2]=k;return}function _d(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=+h;var j=0,k=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0;D=i;i=i+80|0;B=+g[e+4>>2];C=+g[e+20>>2];o=+g[e+36>>2];p=+g[e+8>>2];q=+g[e+24>>2];r=+g[e+40>>2];s=+g[e+12>>2];t=+g[e+28>>2];u=+g[e+44>>2];v=-+g[e+52>>2];w=-+g[e+56>>2];x=-+g[e+60>>2];l=c[b+720>>2]|0;y=+g[l+(d*104|0)+8>>2];z=+g[l+(d*104|0)+12>>2];A=+g[l+(d*104|0)+16>>2];a:do if(f){f=c[b+268>>2]|0;b:do if((f|0)>0){k=c[b+276>>2]|0;j=0;while(1){if((c[k+(j<<2)>>2]|0)==(e|0))break;j=j+1|0;if((j|0)>=(f|0))break b}if((j|0)!=(f|0)){f=l;break a}}while(0);if((f|0)==(c[b+272>>2]|0)?(m=f|0?f<<1:1,(f|0)<(m|0)):0){if(!m)k=0;else{c[6435]=(c[6435]|0)+1;f=yc((m<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}k=f;f=c[b+268>>2]|0}if((f|0)>0){j=0;do{c[k+(j<<2)>>2]=c[(c[b+276>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(f|0))}j=c[b+276>>2]|0;if(j){if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);f=c[b+268>>2]|0}c[b+276>>2]=0}a[b+280>>0]=1;c[b+276>>2]=k;c[b+272>>2]=m}c[(c[b+276>>2]|0)+(f<<2)>>2]=e;c[b+268>>2]=f+1;f=c[b+720>>2]|0}else f=l;while(0);l=f+(d*104|0)|0;f=f+(d*104|0)+100|0;a[f>>0]=a[f>>0]|1;f=c[b+792>>2]|0;if((f|0)==(c[b+796>>2]|0)?(n=f|0?f<<1:1,(f|0)<(n|0)):0){if(!n)k=0;else{c[6435]=(c[6435]|0)+1;f=yc(n*96|19)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}k=f;f=c[b+792>>2]|0}if((f|0)>0){j=0;do{d=k+(j*96|0)|0;m=c[b+800>>2]|0;E=m+(j*96|0)|0;c[d>>2]=c[E>>2];c[d+4>>2]=c[E+4>>2];c[d+8>>2]=c[E+8>>2];c[d+12>>2]=c[E+12>>2];c[d+16>>2]=c[E+16>>2];c[d+20>>2]=c[E+20>>2];c[d+24>>2]=c[E+24>>2];d=k+(j*96|0)+28|0;E=m+(j*96|0)+28|0;c[d>>2]=c[E>>2];c[d+4>>2]=c[E+4>>2];c[d+8>>2]=c[E+8>>2];c[d+12>>2]=c[E+12>>2];d=k+(j*96|0)+44|0;E=m+(j*96|0)+44|0;c[d>>2]=c[E>>2];c[d+4>>2]=c[E+4>>2];c[d+8>>2]=c[E+8>>2];c[d+12>>2]=c[E+12>>2];d=k+(j*96|0)+60|0;E=m+(j*96|0)+60|0;c[d>>2]=c[E>>2];c[d+4>>2]=c[E+4>>2];c[d+8>>2]=c[E+8>>2];c[d+12>>2]=c[E+12>>2];d=k+(j*96|0)+76|0;m=m+(j*96|0)+76|0;c[d>>2]=c[m>>2];c[d+4>>2]=c[m+4>>2];c[d+8>>2]=c[m+8>>2];c[d+12>>2]=c[m+12>>2];c[d+16>>2]=c[m+16>>2];j=j+1|0}while((j|0)!=(f|0))}f=c[b+800>>2]|0;if(f|0){if(a[b+804>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+800>>2]=0}a[b+804>>0]=1;c[b+800>>2]=k;c[b+796>>2]=n;f=c[b+792>>2]|0}E=c[b+800>>2]|0;c[E+(f*96|0)>>2]=l;g[E+(f*96|0)+4>>2]=B*v+C*w+o*x+(B*y+C*z+o*A);g[E+(f*96|0)+8>>2]=p*v+q*w+r*x+(p*y+q*z+r*A);g[E+(f*96|0)+12>>2]=s*v+t*w+u*x+(s*y+t*z+u*A);g[E+(f*96|0)+16>>2]=0.0;c[E+(f*96|0)+20>>2]=e;g[E+(f*96|0)+24>>2]=h;e=E+(f*96|0)+28|0;c[e>>2]=c[D+56>>2];c[e+4>>2]=c[D+56+4>>2];c[e+8>>2]=c[D+56+8>>2];c[e+12>>2]=c[D+56+12>>2];e=E+(f*96|0)+44|0;c[e>>2]=c[D+40>>2];c[e+4>>2]=c[D+40+4>>2];c[e+8>>2]=c[D+40+8>>2];c[e+12>>2]=c[D+40+12>>2];e=E+(f*96|0)+60|0;c[e>>2]=c[D+24>>2];c[e+4>>2]=c[D+24+4>>2];c[e+8>>2]=c[D+24+8>>2];c[e+12>>2]=c[D+24+12>>2];E=E+(f*96|0)+76|0;c[E>>2]=c[D>>2];c[E+4>>2]=c[D+4>>2];c[E+8>>2]=c[D+8>>2];c[E+12>>2]=c[D+12>>2];c[E+16>>2]=c[D+16>>2];c[b+792>>2]=(c[b+792>>2]|0)+1;i=D;return}function $d(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0;E=i;i=i+64|0;A=+g[b+48>>2]-+g[b+112>>2];h=+g[b+52>>2]-+g[b+116>>2];D=+g[b+56>>2]-+g[b+120>>2];B=A*+g[b+64>>2]+h*+g[b+80>>2]+D*+g[b+96>>2];C=A*+g[b+68>>2]+h*+g[b+84>>2]+D*+g[b+100>>2];D=A*+g[b+72>>2]+h*+g[b+88>>2]+D*+g[b+104>>2];e=c[a+8>>2]|0;z=c[a+4>>2]|0;h=+g[z+28>>2]*+g[z+12>>2];A=h+ +g[a+12>>2];p=+g[e+72>>2];q=+g[e+56>>2];r=+g[e+76>>2];s=+g[e+60>>2];t=+g[e+80>>2];u=+g[e+64>>2];v=+g[e+88>>2];w=+g[e+92>>2];x=+g[e+96>>2];k=(r-s)*(x-u)-(t-u)*(w-s);m=(t-u)*(v-q)-(p-q)*(x-u);o=(p-q)*(w-s)-(r-s)*(v-q);n=1.0/+O(+(o*o+(k*k+m*m)));j=(B-q)*n*k+(C-s)*n*m+n*o*(D-u);if(j<0.0){y=-j;l=-(n*k);j=-(n*m);k=-(n*o)}else{y=j;l=n*k;j=n*m;k=n*o}if(!(y0.0&(o>0.0&t>0.0))?!(x<=0.0&(o<=0.0&t<=0.0)):0){if((Eb[c[(c[e>>2]|0)+100>>2]&127](e)|0)<=0){i=E;return}s=0.0;r=0.0;q=0.0;e=0;z=0;do{F=c[a+8>>2]|0;mc[c[(c[F>>2]|0)+104>>2]&127](F,z,E+48|0,E+32|0);m=+g[E+48>>2];w=+g[E+48+4>>2];u=+g[E+48+8>>2];n=+g[E+32>>2]-m;x=+g[E+32+4>>2]-w;v=+g[E+32+8>>2]-u;do if((B-m)*n+(C-w)*x+(D-u)*v>0.0)if((B-m)*n+(C-w)*x+(D-u)*v>2]|0}while((z|0)<(Eb[c[(c[F>>2]|0)+100>>2]&127](F)|0));if(!(e&1)){i=E;return}else p=A*A}else{p=A*A;s=B-y*l;r=D-y*k;q=C-y*j}n=B-s;o=C-q;m=D-r;if(!(n*n+o*o+m*m1.1920928955078125e-07){j=+O(+(n*n+o*o+m*m));h=h-j;l=n*(1.0/j);k=m*(1.0/j);j=o*(1.0/j)}h=-h;if(f){x=+g[b+64>>2];y=+g[b+68>>2];A=+g[b+72>>2];B=x*l+y*j+A*k;o=+g[b+80>>2];p=+g[b+84>>2];t=+g[b+88>>2];C=l*o+j*p+k*t;u=+g[b+96>>2];v=+g[b+100>>2];w=+g[b+104>>2];D=l*u+j*v+k*w;g[E+48>>2]=-B;g[E+48+4>>2]=-C;g[E+48+8>>2]=-D;g[E+48+12>>2]=0.0;C=s*o+q*p+r*t+ +g[b+116>>2]+C*h;D=s*u+q*v+r*w+ +g[b+120>>2]+D*h;g[E+32>>2]=s*x+q*y+r*A+ +g[b+112>>2]+B*h;g[E+32+4>>2]=C;g[E+32+8>>2]=D;g[E+32+12>>2]=0.0;hc[c[(c[d>>2]|0)+16>>2]&15](d,E+48|0,E+32|0,h);i=E;return}else{F=c[(c[d>>2]|0)+16>>2]|0;y=+g[b+64>>2];A=+g[b+68>>2];B=+g[b+72>>2];u=+g[b+80>>2];v=+g[b+84>>2];C=+g[b+88>>2];w=+g[b+96>>2];x=+g[b+100>>2];D=+g[b+104>>2];g[E+16>>2]=y*l+A*j+B*k;g[E+16+4>>2]=l*u+j*v+k*C;g[E+16+8>>2]=l*w+j*x+k*D;g[E+16+12>>2]=0.0;C=s*u+q*v+r*C+ +g[b+116>>2];D=s*w+q*x+r*D+ +g[b+120>>2];g[E>>2]=s*y+q*A+r*B+ +g[b+112>>2];g[E+4>>2]=C;g[E+8>>2]=D;g[E+12>>2]=0.0;hc[F&15](d,E+16|0,E,h);i=E;return}}function ae(b){b=b|0;var d=0.0,e=0,f=0,h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0;r=i;i=i+80|0;if((Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0?(q=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0,(Eb[c[(c[q>>2]|0)+48>>2]&127](q)|0)&8|0):0)?(e=c[b+24>>2]|0,e=Eb[c[(c[e>>2]|0)+36>>2]&127](e)|0,c[r+64>>2]=1065353216,c[r+64+4>>2]=1065353216,c[r+64+8>>2]=0,g[r+64+12>>2]=0.0,(e|0)>0):0){j=0;do{f=c[b+24>>2]|0;f=Zb[c[(c[f>>2]|0)+40>>2]&31](f,j)|0;h=c[f+748>>2]|0;if((h|0)>0){k=0;do{q=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;Bb[c[(c[q>>2]|0)+32>>2]&0](q,f+4+(k*184|0)+32|0,f+4+(k*184|0)+64|0,+g[f+4+(k*184|0)+80>>2],c[f+4+(k*184|0)+148>>2]|0,r+64|0);k=k+1|0}while((k|0)!=(h|0))}j=j+1|0}while((j|0)!=(e|0))}if(!(Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0)){i=r;return}q=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;if(!((Eb[c[(c[q>>2]|0)+48>>2]&127](q)|0)&3)){i=r;return}if((c[b+8>>2]|0)<=0){i=r;return}h=r+64+4|0;j=r+64+8|0;k=r+64+12|0;q=0;do{f=c[(c[b+16>>2]|0)+(q<<2)>>2]|0;if(!(c[f+204>>2]&32)){if(Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0?(e=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0,(Eb[c[(c[e>>2]|0)+48>>2]&127](e)|0)&1|0):0){c[r+64>>2]=1065353216;c[h>>2]=1065353216;c[j>>2]=1065353216;g[k>>2]=0.0;switch(c[f+216>>2]|0){case 1:{c[r+64>>2]=1065353216;c[h>>2]=1065353216;c[j>>2]=1065353216;g[k>>2]=0.0;break}case 2:{c[r+64>>2]=0;c[h>>2]=1065353216;c[j>>2]=0;g[k>>2]=0.0;break}case 3:{c[r+64>>2]=0;c[h>>2]=1065353216;c[j>>2]=1065353216;g[k>>2]=0.0;break}case 4:{c[r+64>>2]=1065353216;c[h>>2]=0;c[j>>2]=0;g[k>>2]=0.0;break}case 5:{c[r+64>>2]=1065353216;c[h>>2]=1065353216;c[j>>2]=0;g[k>>2]=0.0;break}default:{c[r+64>>2]=1065353216;c[h>>2]=0;c[j>>2]=0;g[k>>2]=0.0}}mc[c[(c[b>>2]|0)+28>>2]&127](b,f+4|0,c[f+192>>2]|0,r+64|0)}e=c[b+72>>2]|0;if(e|0?(Eb[c[(c[e>>2]|0)+48>>2]&127](e)|0)&2|0:0){c[r+32>>2]=1065353216;c[r+32+4>>2]=0;c[r+32+8>>2]=0;g[r+32+12>>2]=0.0;e=c[f+192>>2]|0;mc[c[(c[e>>2]|0)+8>>2]&127](e,f+4|0,r+64|0,r+48|0);g[r+64>>2]=+g[r+64>>2]+-.019999999552965164;g[r+64+4>>2]=+g[r+64+4>>2]+-.019999999552965164;g[r+64+8>>2]=+g[r+64+8>>2]+-.019999999552965164;g[r+48>>2]=+g[r+48>>2]+.019999999552965164;g[r+48+4>>2]=+g[r+48+4>>2]+.019999999552965164;g[r+48+8>>2]=+g[r+48+8>>2]+.019999999552965164;do if((a[b+44>>0]|0?(c[f+236>>2]|0)==2:0)?(c[f+204>>2]&3|0)==0:0){e=c[f+192>>2]|0;mc[c[(c[e>>2]|0)+8>>2]&127](e,f+68|0,r+16|0,r);d=+g[r+16>>2]+-.019999999552965164;g[r+16>>2]=d;l=+g[r+16+4>>2]+-.019999999552965164;g[r+16+4>>2]=l;m=+g[r+16+8>>2]+-.019999999552965164;g[r+16+8>>2]=m;n=+g[r>>2]+.019999999552965164;g[r>>2]=n;o=+g[r+4>>2]+.019999999552965164;g[r+4>>2]=o;p=+g[r+8>>2]+.019999999552965164;g[r+8>>2]=p;if(d<+g[r+64>>2])g[r+64>>2]=d;if(l<+g[r+64+4>>2])g[r+64+4>>2]=l;if(m<+g[r+64+8>>2])g[r+64+8>>2]=m;d=+g[r+16+12>>2];if(d<+g[r+64+12>>2])g[r+64+12>>2]=d;if(+g[r+48>>2]>2]=n;if(+g[r+48+4>>2]>2]=o;if(+g[r+48+8>>2]>2]=p;d=+g[r+12>>2];if(!(+g[r+48+12>>2]>2]=d}while(0);f=c[b+72>>2]|0;mc[c[(c[f>>2]|0)+52>>2]&127](f,r+64|0,r+48|0,r+32|0)}}q=q+1|0}while((q|0)<(c[b+8>>2]|0));i=r;return}function be(b,d,e,f,h,i,j,k,l,m,n){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;var o=0,p=0,q=0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0,z=0.0,A=0;if((j|0)<2|(k|0)<2){n=0;return n|0}y=_(k,j)|0;c[6435]=(c[6435]|0)+1;b=yc(y>>>0>268435455?18:(y<<4|3)+16|0)|0;if(!b)t=0;else{c[(b+4+15&-16)+-4>>2]=b;t=b+4+15&-16}o=y>>>0>1073741823?-1:y<<2;o=(o|0)==0?1:o;while(1){q=yc(o)|0;if(q|0)break;b=c[6564]|0;c[6564]=b+0;if(!b){p=8;break}jc[b&3]()}if((p|0)==8){n=Ya(4)|0;c[n>>2]=9640;pb(n|0,2800,251)}if((k|0)>0?(j|0)>0:0){p=0;do{z=+(p|0)/+(k+-1|0);r=+g[e>>2];r=r+z*(+g[h>>2]-r);s=+g[e+4>>2];s=s+z*(+g[h+4>>2]-s);u=+g[e+8>>2];u=u+z*(+g[h+8>>2]-u);v=+g[f>>2];w=+g[f+4>>2];x=+g[f+8>>2];b=_(p,j)|0;v=v+z*(+g[i>>2]-v)-r;w=w+z*(+g[i+4>>2]-w)-s;x=x+z*(+g[i+8>>2]-x)-u;o=0;do{z=+(o|0)/+(j+-1|0);A=o+b|0;g[t+(A<<4)>>2]=r+v*z;g[t+(A<<4)+4>>2]=s+w*z;g[t+(A<<4)+8>>2]=u+x*z;g[t+(A<<4)+12>>2]=0.0;g[q+(A<<2)>>2]=1.0;o=o+1|0}while((o|0)!=(j|0));p=p+1|0}while((p|0)!=(k|0))}c[6435]=(c[6435]|0)+1;b=yc(1271)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}Kc(b,d,y,t,q);if(l&1|0){g[(c[b+720>>2]|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&2|0){g[(c[b+720>>2]|0)+((j+-1|0)*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&4|0){A=_(k+-1|0,j)|0;g[(c[b+720>>2]|0)+(A*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&8|0){A=j+-1+(_(k+-1|0,j)|0)|0;g[(c[b+720>>2]|0)+(A*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&16|0){g[(c[b+720>>2]|0)+(((j+-1|0)/2|0)*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&32|0){A=_((k+-1|0)/2|0,j)|0;g[(c[b+720>>2]|0)+(A*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&64|0){A=j+-1+(_((k+-1|0)/2|0,j)|0)|0;g[(c[b+720>>2]|0)+(A*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&128|0){A=(_(k+-1|0,j)|0)+((j+-1|0)/2|0)|0;g[(c[b+720>>2]|0)+(A*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&256|0){A=(_((k+-1|0)/2|0,j)|0)+((j+-1|0)/2|0)|0;g[(c[b+720>>2]|0)+(A*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(t|0){c[6436]=(c[6436]|0)+1;hd(c[t+-4>>2]|0)}hd(q);if((k|0)<=0){A=b;return A|0}y=j+-1|0;d=0;o=0;while(1){p=d;d=d+1|0;a:do if((j|0)>0){t=_(p,j)|0;i=_(d,j)|0;s=1.0/+(k+-1|0)*+(k+-1-p|0);r=1.0/+(k+-1|0)*+(k+-2-p|0);if((d|0)<(k|0)){f=0;h=o}else{if((j|0)>1){q=1;p=0}else break;while(1){Rf(b,p+t|0,q+t|0,0,0);p=q+1|0;if((p|0)==(j|0))break a;else{A=q;q=p;p=A}}}while(1){p=f+1|0;q=f+t|0;e=f+i|0;if((f|0)==(j+-1|0))break;Rf(b,q,p+t|0,0,0);Rf(b,q,e,0,0);Zf(b,q,e,p+i|0,0);if(!n)Zf(b,p+i|0,p+t|0,q,0);else{z=1.0/+(j+-1|0)*+(f|0);g[n+(h<<2)>>2]=z;g[n+(h+1<<2)>>2]=s;g[n+(h+2<<2)>>2]=z;g[n+(h+3<<2)>>2]=r;x=1.0/+(j+-1|0)*+(p|0);g[n+(h+4<<2)>>2]=x;g[n+(h+5<<2)>>2]=r;Zf(b,p+i|0,p+t|0,q,0);g[n+(h+6<<2)>>2]=x;g[n+(h+7<<2)>>2]=r;g[n+(h+8<<2)>>2]=x;g[n+(h+9<<2)>>2]=s;g[n+(h+10<<2)>>2]=z;g[n+(h+11<<2)>>2]=s}if(m)Rf(b,q,p+i|0,0,0);f=p;h=h+12|0}Rf(b,y,e,0,0);o=(j*12|0)+-12+o|0}while(0);if((d|0)==(k|0))break;else y=y+j|0}return b|0}function ce(b,d,e,f,h,j,k,l){b=b|0;d=d|0;e=e|0;f=f|0;h=+h;j=+j;k=k|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;w=i;i=i+288|0;c[w+208>>2]=c[d>>2];c[w+208+4>>2]=c[d+4>>2];c[w+208+8>>2]=c[d+8>>2];c[w+208+12>>2]=c[d+12>>2];o=w+208+16|0;c[o>>2]=c[e>>2];c[o+4>>2]=c[e+4>>2];c[o+8>>2]=c[e+8>>2];c[o+12>>2]=c[e+12>>2];e=w+208+32|0;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];r=c[k>>2]|0;t=c[k+4>>2]|0;u=c[k+8>>2]|0;v=c[k+16>>2]|0;q=c[k+12>>2]|0;p=c[k+20>>2]|0;c[w>>2]=c[w+208>>2];c[w+4>>2]=c[w+208+4>>2];c[w+8>>2]=c[w+208+8>>2];c[w+12>>2]=c[w+208+12>>2];c[w+16>>2]=c[o>>2];c[w+16+4>>2]=c[o+4>>2];c[w+16+8>>2]=c[o+8>>2];c[w+16+12>>2]=c[o+12>>2];c[w+32>>2]=c[e>>2];c[w+32+4>>2]=c[e+4>>2];c[w+32+8>>2]=c[e+8>>2];c[w+32+12>>2]=c[e+12>>2];e=c[b+136>>2]|0;if((e|0)==(c[b+140>>2]|0)?(s=e|0?e<<1:1,(e|0)<(s|0)):0){if(!s)d=0;else{c[6435]=(c[6435]|0)+1;d=yc((s*284|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=c[b+136>>2]|0}if((e|0)>0){k=0;do{f=c[b+144>>2]|0;m=d+(k*284|0)|0;n=f+(k*284|0)|0;o=m+92|0;do{c[m>>2]=c[n>>2];m=m+4|0;n=n+4|0}while((m|0)<(o|0));m=d+(k*284|0)+92|0;n=f+(k*284|0)+92|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];m=d+(k*284|0)+108|0;n=f+(k*284|0)+108|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];m=d+(k*284|0)+124|0;n=f+(k*284|0)+124|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];m=d+(k*284|0)+140|0;n=f+(k*284|0)+140|0;c[m>>2]=c[n>>2];c[m+4>>2]=c[n+4>>2];c[m+8>>2]=c[n+8>>2];c[m+12>>2]=c[n+12>>2];m=d+(k*284|0)+156|0;n=f+(k*284|0)+156|0;o=m+128|0;do{c[m>>2]=c[n>>2];m=m+4|0;n=n+4|0}while((m|0)<(o|0));k=k+1|0}while((k|0)!=(e|0))}e=c[b+144>>2]|0;if(e|0){if(a[b+148>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+144>>2]=0}a[b+148>>0]=1;c[b+144>>2]=d;c[b+140>>2]=s;e=c[b+136>>2]|0}d=c[b+144>>2]|0;m=d+(e*284|0)|0;n=w+48|0;o=m+92|0;do{c[m>>2]=c[n>>2];m=m+4|0;n=n+4|0}while((m|0)<(o|0));m=d+(e*284|0)+92|0;c[m>>2]=c[w+192>>2];c[m+4>>2]=c[w+192+4>>2];c[m+8>>2]=c[w+192+8>>2];c[m+12>>2]=c[w+192+12>>2];m=d+(e*284|0)+108|0;c[m>>2]=c[w+176>>2];c[m+4>>2]=c[w+176+4>>2];c[m+8>>2]=c[w+176+8>>2];c[m+12>>2]=c[w+176+12>>2];m=d+(e*284|0)+124|0;c[m>>2]=c[w+160>>2];c[m+4>>2]=c[w+160+4>>2];c[m+8>>2]=c[w+160+8>>2];c[m+12>>2]=c[w+160+12>>2];m=d+(e*284|0)+140|0;c[m>>2]=c[w+144>>2];c[m+4>>2]=c[w+144+4>>2];c[m+8>>2]=c[w+144+8>>2];c[m+12>>2]=c[w+144+12>>2];d=d+(e*284|0)+156|0;m=d;n=w;o=m+48|0;do{c[m>>2]=c[n>>2];m=m+4|0;n=n+4|0}while((m|0)<(o|0));g[d+48>>2]=h;c[d+52>>2]=q;g[d+56>>2]=j;c[d+60>>2]=r;c[d+64>>2]=t;c[d+68>>2]=u;c[d+72>>2]=v;g[d+76>>2]=0.0;g[d+80>>2]=0.0;g[d+84>>2]=0.0;g[d+88>>2]=.10000000149011612;c[d+92>>2]=p;g[d+96>>2]=0.0;g[d+100>>2]=0.0;a[d+104>>0]=l&1;m=d+105|0;n=w+256|0;o=m+23|0;do{a[m>>0]=a[n>>0]|0;m=m+1|0;n=n+1|0}while((m|0)<(o|0));l=c[b+136>>2]|0;c[b+136>>2]=l+1;l=(c[b+144>>2]|0)+(l*284|0)|0;Tg(c[b+116>>2]|0,l,0);Ae(c[b+116>>2]|0,c[b+144>>2]|0,(c[b+136>>2]|0)+-1|0,0);i=w;return l|0}function de(a,d,f,h,j){a=a|0;d=d|0;f=f|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0;I=i;i=i+16|0;c[d+16>>2]=c[f>>2];c[d+16+4>>2]=c[f+4>>2];c[d+16+8>>2]=c[f+8>>2];c[d+16+12>>2]=c[f+12>>2];c[d+32>>2]=c[h>>2];c[d+32+4>>2]=c[h+4>>2];c[d+32+8>>2]=c[h+8>>2];c[d+32+12>>2]=c[h+12>>2];D=c[a+60>>2]|0;E=c[d+12>>2]&65535;Bj(a,I+6|0,+g[f>>2],+g[f+4>>2],+g[f+8>>2],0);Bj(a,I,+g[h>>2],+g[h+4>>2],+g[h+8>>2],1);H=0;do{t=b[D+(E<<6)+48+(H<<1)>>1]|0;w=b[D+(E<<6)+54+(H<<1)>>1]|0;q=b[I+6+(H<<1)>>1]|0;l=a+68+(H<<2)|0;s=c[l>>2]|0;m=(q&65535)-(e[s+((t&65535)<<2)>>1]|0)|0;r=b[I+(H<<1)>>1]|0;y=(r&65535)-(e[s+((w&65535)<<2)>>1]|0)|0;b[s+((t&65535)<<2)>>1]=q;b[s+((w&65535)<<2)>>1]=r;if((m|0)<0)wh(a,H,t);a:do if((y|0)>0?(z=c[l>>2]|0,A=c[a+60>>2]|0,B=e[z+((w&65535)<<2)+2>>1]|0,C=b[z+((w&65535)<<2)+6>>1]|0,C<<16>>16):0){n=1<>1]|0;if((e[s>>1]|0)<(p&65535))break a;q=c[a+60>>2]|0;k=k&65535;if(!(p&1)){if(((((e[A+(B<<6)+54+(n<<1)>>1]|0)>=(e[q+(k<<6)+48+(n<<1)>>1]|0)?(e[q+(k<<6)+54+(n<<1)>>1]|0)>=(e[A+(B<<6)+48+(n<<1)>>1]|0):0)?(e[A+(B<<6)+54+((1<>1]|0)>=(e[q+(k<<6)+48+((1<>1]|0):0)?(e[q+(k<<6)+54+((1<>1]|0)>=(e[A+(B<<6)+48+((1<>1]|0):0)?(G=c[a+92>>2]|0,F=q+((e[s+2>>1]|0)<<6)|0,Ob[c[(c[G>>2]|0)+8>>2]&63](G,F,q+(k<<6)|0)|0,G=c[a+96>>2]|0,G|0):0)Ob[c[(c[G>>2]|0)+8>>2]&63](G,F,q+(k<<6)|0)|0;q=q+(k<<6)+48+(H<<1)|0;b[q>>1]=(b[q>>1]|0)+-1<<16>>16}else{q=q+(k<<6)+54+(H<<1)|0;b[q>>1]=(b[q>>1]|0)+-1<<16>>16}b[o>>1]=(b[o>>1]|0)+1<<16>>16;k=e[s>>1]|e[s+2>>1]<<16;q=e[r>>1]|e[r+2>>1]<<16;b[s>>1]=q;b[s+2>>1]=q>>>16;b[r>>1]=k;b[r+2>>1]=k>>>16;k=b[s+10>>1]|0}while(k<<16>>16!=0)}while(0);b:do if((m|0)>0?(u=c[l>>2]|0,v=b[u+((t&65535)<<2)+6>>1]|0,v<<16>>16):0){p=(c[a+60>>2]|0)+((e[u+((t&65535)<<2)+2>>1]|0)<<6)+48+(H<<1)|0;q=1<>1]|0;if((e[o>>1]|0)<(k&65535))break b;m=c[a+60>>2]|0;l=l&65535;if(!(k&1)){t=m+(l<<6)+48+(H<<1)|0;b[t>>1]=(b[t>>1]|0)+-1<<16>>16}else{k=e[o+2>>1]|0;if(((((e[m+(k<<6)+54+(q<<1)>>1]|0)>=(e[m+(l<<6)+48+(q<<1)>>1]|0)?(e[m+(l<<6)+54+(q<<1)>>1]|0)>=(e[m+(k<<6)+48+(q<<1)>>1]|0):0)?(e[m+(k<<6)+54+((1<>1]|0)>=(e[m+(l<<6)+48+((1<>1]|0):0)?(e[m+(l<<6)+54+((1<>1]|0)>=(e[m+(k<<6)+48+((1<>1]|0):0)?(x=c[a+92>>2]|0,Ib[c[(c[x>>2]|0)+12>>2]&31](x,m+(k<<6)|0,m+(l<<6)|0,j)|0,x=c[a+96>>2]|0,x|0):0)Ib[c[(c[x>>2]|0)+12>>2]&31](x,m+(k<<6)|0,m+(l<<6)|0,j)|0;t=m+(l<<6)+54+(H<<1)|0;b[t>>1]=(b[t>>1]|0)+-1<<16>>16}b[p>>1]=(b[p>>1]|0)+1<<16>>16;l=e[o>>1]|e[o+2>>1]<<16;t=e[n>>1]|e[n+2>>1]<<16;b[o>>1]=t;b[o+2>>1]=t>>>16;b[n>>1]=l;b[n+2>>1]=l>>>16;l=b[o+10>>1]|0}while(l<<16>>16!=0)}while(0);if((y|0)<0)uh(a,H,w,j);H=H+1|0}while((H|0)!=3);k=c[a+108>>2]|0;if(!k){i=I;return}yb[c[(c[k>>2]|0)+16>>2]&31](k,c[d+60>>2]|0,f,h,j);i=I;return}function ee(b,d,e){b=b|0;d=+d;e=+e;var f=0,h=0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0.0,u=0.0,v=0.0;s=i;i=i+144|0;f=c[b+8>>2]|0;if(!f){f=c[b+4>>2]|0;if(!f){d=0.0;k=0.0;n=0.0;o=0.0;l=0.0;m=0.0}else{r=+g[f+336>>2];n=+g[b+172>>2];o=+g[f+340>>2];p=+g[b+168>>2];m=+g[b+164>>2];q=+g[f+332>>2];d=r*n-o*p;k=+g[f+316>>2];n=o*m-n*q;o=+g[f+320>>2];l=+g[f+324>>2];m=p*q-r*m}}else{r=+g[f+332>>2];n=+g[b+172>>2];o=+g[f+336>>2];p=+g[b+168>>2];m=+g[b+164>>2];q=+g[f+328>>2];d=r*n-o*p;k=+g[f+312>>2];n=o*m-n*q;o=+g[f+316>>2];l=+g[f+320>>2];m=p*q-r*m}p=k+d;r=o+n;q=l+m;f=c[b+20>>2]|0;if(!f){f=c[b+16>>2]|0;if(!f){d=0.0;k=0.0;n=0.0;o=0.0;l=0.0;m=0.0}else{t=+g[f+336>>2];n=+g[b+188>>2];o=+g[f+340>>2];v=+g[b+184>>2];m=+g[b+180>>2];u=+g[f+332>>2];d=t*n-o*v;k=+g[f+316>>2];n=o*m-n*u;o=+g[f+320>>2];l=+g[f+324>>2];m=v*u-t*m}}else{v=+g[f+332>>2];n=+g[b+188>>2];o=+g[f+336>>2];t=+g[b+184>>2];m=+g[b+180>>2];u=+g[f+328>>2];d=v*n-o*t;k=+g[f+312>>2];n=o*m-n*u;o=+g[f+316>>2];l=+g[f+320>>2];m=t*u-v*m}p=p-(k+d);n=r-(o+n);d=q-(l+m);k=+g[b+196>>2];l=+g[b+200>>2];m=+g[b+204>>2];a[s+108+32>>0]=1;c[s+108+16>>2]=0;c[s+108+16+4>>2]=0;c[s+108+16+8>>2]=0;c[s+108+16+12>>2]=0;c[s+108>>2]=c[b+72>>2];c[s+108+4>>2]=c[b+72+4>>2];c[s+108+8>>2]=c[b+72+8>>2];c[s+108+12>>2]=c[b+72+12>>2];if(k*p+n*l+d*m<0.0){t=+g[b+212>>2];u=+g[s+108>>2]+((k*p+n*l+d*m)*k+(p-(k*p+n*l+d*m)*k)*t);g[s+108>>2]=u;v=(k*p+n*l+d*m)*l+t*(n-(k*p+n*l+d*m)*l)+ +g[s+108+4>>2];g[s+108+4>>2]=v;l=(k*p+n*l+d*m)*m+t*(d-(k*p+n*l+d*m)*m)+ +g[s+108+8>>2];g[s+108+8>>2]=l;f=s+108+4|0;h=s+108+8|0;j=s+108|0;d=u;k=v}else{f=s+108+4|0;h=s+108+8|0;j=s+108|0;d=+g[s+108>>2];k=+g[s+108+4>>2];l=+g[s+108+8>>2]}m=(+g[b+104>>2]*d+ +g[b+108>>2]*k+ +g[b+112>>2]*l)*e;n=(d*+g[b+120>>2]+k*+g[b+124>>2]+l*+g[b+128>>2])*e;d=(d*+g[b+136>>2]+k*+g[b+140>>2]+l*+g[b+144>>2])*e;g[j>>2]=m;g[f>>2]=n;g[h>>2]=d;g[s+108+12>>2]=0.0;f=c[b+4>>2]|0;if((f|0)!=(c[b+16>>2]|0)){f=s;h=s+108|0;j=f+36|0;do{c[f>>2]=c[h>>2];f=f+4|0;h=h+4|0}while((f|0)<(j|0));v=-+g[s+4>>2];u=-+g[s+8>>2];g[s>>2]=-+g[s>>2];g[s+4>>2]=v;g[s+8>>2]=u;g[s+12>>2]=0.0;u=-+g[s+20>>2];v=-+g[s+24>>2];g[s+16>>2]=-+g[s+16>>2];g[s+20>>2]=u;g[s+24>>2]=v;g[s+28>>2]=0.0;Xh(b+4|0,s,b+164|0);Xh(b+16|0,s+108|0,b+180|0);i=s;return}if(!(m==m&n==n&(d==d&0.0==0.0))){i=s;return}v=+O(+(m*m+n*n+d*d));if(v<+g[f+368>>2]){i=s;return}h=c[s+108+32>>2]|0;v=+g[f+372>>2];g[s+72+12>>2]=0.0;g[s+72+28>>2]=0.0;c[s+72+32>>2]=h;g[s+72>>2]=-(m*v);g[s+72+4>>2]=-(n*v);g[s+72+8>>2]=-(d*v);g[s+72+16>>2]=v*-0.0;g[s+72+20>>2]=v*-0.0;g[s+72+24>>2]=v*-0.0;Xh(b+4|0,s+72|0,b+164|0);d=+g[(c[b+4>>2]|0)+372>>2];f=s+36|0;h=s+108|0;j=f+36|0;do{c[f>>2]=c[h>>2];f=f+4|0;h=h+4|0}while((f|0)<(j|0));g[s+36>>2]=d*+g[s+36>>2];g[s+36+4>>2]=d*+g[s+36+4>>2];g[s+36+8>>2]=d*+g[s+36+8>>2];g[s+36+16>>2]=d*+g[s+36+16>>2];g[s+36+20>>2]=d*+g[s+36+20>>2];g[s+36+24>>2]=d*+g[s+36+24>>2];Xh(b+16|0,s+36|0,b+180|0);i=s;return}function fe(b,d,e,f){b=b|0;d=d|0;e=e|0;f=+f;var h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0,E=0;A=i;i=i+192|0;x=c[b+4>>2]|0;if(+g[x+752>>2]>2]|0;w=(c[b+8>>2]|0)+8|0;y=c[w>>2]|0;l=+g[e>>2];n=+g[d>>2]*f+l;h=+g[e+4>>2];o=+g[d+4>>2]*f+h;j=+g[e+8>>2];r=+g[d+8>>2]*f+j;v=(c[b+12>>2]|0)+8|0;p=c[v>>2]|0;m=+g[p+52>>2];if((z|0)!=(y|0)){k=o-+g[p+56>>2];u=r-+g[p+60>>2];B=l-+g[y+52>>2];l=h-+g[y+56>>2];h=j-+g[y+60>>2];s=(n-m)*+g[p+4>>2]+k*+g[p+20>>2]+u*+g[p+36>>2];t=(n-m)*+g[p+8>>2]+k*+g[p+24>>2]+u*+g[p+40>>2];u=(n-m)*+g[p+12>>2]+k*+g[p+28>>2]+u*+g[p+44>>2];j=B*+g[y+4>>2]+l*+g[y+20>>2]+h*+g[y+36>>2];k=B*+g[y+8>>2]+l*+g[y+24>>2]+h*+g[y+40>>2];h=B*+g[y+12>>2]+l*+g[y+28>>2]+h*+g[y+44>>2]}else{C=n-+g[z+52>>2];k=o-+g[z+56>>2];u=r-+g[z+60>>2];B=h-+g[p+56>>2];h=j-+g[p+60>>2];s=C*+g[z+4>>2]+k*+g[z+20>>2]+u*+g[z+36>>2];t=C*+g[z+8>>2]+k*+g[z+24>>2]+u*+g[z+40>>2];u=C*+g[z+12>>2]+k*+g[z+28>>2]+u*+g[z+44>>2];j=(l-m)*+g[p+4>>2]+B*+g[p+20>>2]+h*+g[p+36>>2];k=(l-m)*+g[p+8>>2]+B*+g[p+24>>2]+h*+g[p+40>>2];h=(l-m)*+g[p+12>>2]+B*+g[p+28>>2]+h*+g[p+44>>2]}g[A>>2]=s;g[A+4>>2]=t;g[A+8>>2]=u;g[A+12>>2]=0.0;g[A+16>>2]=j;g[A+20>>2]=k;g[A+24>>2]=h;g[A+28>>2]=0.0;c[A+64>>2]=c[d>>2];c[A+64+4>>2]=c[d+4>>2];c[A+64+8>>2]=c[d+8>>2];c[A+64+12>>2]=c[d+12>>2];g[A+80>>2]=f;g[A+84>>2]=0.0;g[A+88>>2]=0.0;g[A+92>>2]=0.0;c[A+112>>2]=0;a[A+116>>0]=0;c[A+120>>2]=0;c[A+120+4>>2]=0;c[A+120+8>>2]=0;c[A+120+12>>2]=0;c[A+120+16>>2]=0;c[A+120+20>>2]=0;c[A+120+24>>2]=0;c[A+120+28>>2]=0;g[A+48>>2]=n;g[A+52>>2]=o;g[A+56>>2]=r;g[A+60>>2]=0.0;c[A+32>>2]=c[e>>2];c[A+32+4>>2]=c[e+4>>2];c[A+32+8>>2]=c[e+8>>2];c[A+32+12>>2]=c[e+12>>2];h=+g[x+752>>2];e=c[x+748>>2]|0;if((e|0)>0){q=0;p=-1;l=h*h;while(1){h=+g[x+4+(q*184|0)>>2]-s;j=+g[x+4+(q*184|0)+4>>2]-t;k=+g[x+4+(q*184|0)+8>>2]-u;d=h*h+j*j+k*k>2]|0;w=c[v>>2]|0;h=+g[q+224>>2]*+g[w+224>>2];h=h<-10.0?-10.0:h;g[A+84>>2]=h>10.0?10.0:h;g[A+92>>2]=+g[q+228>>2]*+g[w+228>>2];h=+g[q+232>>2]*+g[w+232>>2];h=h<-10.0?-10.0:h;g[A+88>>2]=h>10.0?10.0:h;h=+g[A+72>>2];w=+N(+h)>.7071067690849304;l=+g[A+68>>2];if(w){C=1.0/+O(+(h*h+l*l));n=+g[A+64>>2];m=-(C*l*n);n=n*-(C*h);o=-(C*h);j=(h*h+l*l)*C;k=0.0;h=C*l}else{j=+g[A+64>>2];k=1.0/+O(+(j*j+l*l));m=h*-(l*k);n=(j*j+l*l)*k;o=k*j;j=-(k*j*h);k=-(l*k);h=0.0}g[A+152>>2]=k;g[A+156>>2]=o;g[A+160>>2]=h;g[A+168>>2]=j;g[A+172>>2]=m;g[A+176>>2]=n;v=c[b+20>>2]|0;q=c[b+16>>2]|0;w=c[b+28>>2]|0;b=c[b+24>>2]|0;c[A+96>>2]=(z|0)!=(y|0)?v:q;c[A+100>>2]=(z|0)!=(y|0)?q:v;c[A+104>>2]=(z|0)!=(y|0)?w:b;c[A+108>>2]=(z|0)!=(y|0)?b:w;if((p|0)>-1){b=x+4+(p*184|0)+148|0;z=c[b>>2]|0;e=x+4+(p*184|0)+120|0;d=c[e>>2]|0;v=x+4+(p*184|0)+124|0;q=c[v>>2]|0;y=x+4+(p*184|0)+128|0;w=c[y>>2]|0;D=x+4+(p*184|0)+112|0;E=c[D>>2]|0;_m(x+4+(p*184|0)|0,A|0,184)|0;c[D>>2]=E;c[e>>2]=d;c[v>>2]=q;c[y>>2]=w;c[b>>2]=z}else _e(x,A)|0;i=A;return}function ge(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0;if((h|0)<0){o=c[b+8>>2]|0;+$b[c[(c[o>>2]|0)+12>>2]&3](o,d,e,f,g,c[b+12>>2]|0,c[b+16>>2]|0,c[b+4>>2]|0,c[b+20>>2]|0,c[b+24>>2]|0);return}n=c[b+16>>2]|0;a:do if((n|0)>0){m=c[b+12>>2]|0;i=0;while(1){l=m+(i<<2)|0;k=c[l>>2]|0;j=c[(c[k+28>>2]|0)+208>>2]|0;if((j|0)<=-1)j=c[(c[k+32>>2]|0)+208>>2]|0;if((j|0)==(h|0)){o=l;break a}i=i+1|0;if((i|0)>=(n|0)){o=0;break}}}else{i=0;o=0}while(0);if((i|0)<(n|0)){m=c[b+12>>2]|0;j=0;do{l=c[m+(i<<2)>>2]|0;k=c[(c[l+28>>2]|0)+208>>2]|0;if((k|0)<=-1)k=c[(c[l+32>>2]|0)+208>>2]|0;j=((k|0)==(h|0)&1)+j|0;i=i+1|0}while((i|0)!=(n|0));h=j}else h=0;i=c[b+4>>2]|0;if((c[i+72>>2]|0)<2){n=c[b+8>>2]|0;+$b[c[(c[n>>2]|0)+12>>2]&3](n,d,e,f,g,o,h,i,c[b+20>>2]|0,c[b+24>>2]|0);return}if((e|0)>0){i=c[b+32>>2]|0;j=c[b+36>>2]|0;n=0;do{m=d+(n<<2)|0;if((i|0)==(j|0)){l=j|0?j<<1:1;if((j|0)<(l|0)){if(!l)i=0;else{c[6435]=(c[6435]|0)+1;i=yc((l<<2|3)+16|0)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}j=c[b+32>>2]|0}if((j|0)>0){k=0;do{c[i+(k<<2)>>2]=c[(c[b+40>>2]|0)+(k<<2)>>2];k=k+1|0}while((k|0)!=(j|0))}k=c[b+40>>2]|0;if(k){if(a[b+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0);j=c[b+32>>2]|0}c[b+40>>2]=0}a[b+44>>0]=1;c[b+40>>2]=i;c[b+36>>2]=l;i=j;j=l}else i=j}c[(c[b+40>>2]|0)+(i<<2)>>2]=c[m>>2];i=i+1|0;c[b+32>>2]=i;n=n+1|0}while((n|0)!=(e|0))}if((g|0)>0){i=c[b+52>>2]|0;j=c[b+56>>2]|0;n=0;do{m=f+(n<<2)|0;if((i|0)==(j|0)){l=j|0?j<<1:1;if((j|0)<(l|0)){if(!l)i=0;else{c[6435]=(c[6435]|0)+1;i=yc((l<<2|3)+16|0)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}j=c[b+52>>2]|0}if((j|0)>0){k=0;do{c[i+(k<<2)>>2]=c[(c[b+60>>2]|0)+(k<<2)>>2];k=k+1|0}while((k|0)!=(j|0))}k=c[b+60>>2]|0;if(k){if(a[b+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0);j=c[b+52>>2]|0}c[b+60>>2]=0}a[b+64>>0]=1;c[b+60>>2]=i;c[b+56>>2]=l;i=j;j=l}else i=j}c[(c[b+60>>2]|0)+(i<<2)>>2]=c[m>>2];i=i+1|0;c[b+52>>2]=i;n=n+1|0}while((n|0)!=(g|0))}if((h|0)>0){i=c[b+72>>2]|0;j=c[b+76>>2]|0;n=0;do{m=o+(n<<2)|0;if((i|0)==(j|0)){l=j|0?j<<1:1;if((j|0)<(l|0)){if(!l){k=0;i=j}else{c[6435]=(c[6435]|0)+1;i=yc((l<<2|3)+16|0)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}k=i;i=c[b+72>>2]|0}if((i|0)>0){j=0;do{c[k+(j<<2)>>2]=c[(c[b+80>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(i|0))}j=c[b+80>>2]|0;if(j){if(a[b+84>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);i=c[b+72>>2]|0}c[b+80>>2]=0}a[b+84>>0]=1;c[b+80>>2]=k;c[b+76>>2]=l;j=l}else i=j}c[(c[b+80>>2]|0)+(i<<2)>>2]=c[m>>2];i=i+1|0;c[b+72>>2]=i;n=n+1|0}while((n|0)!=(h|0))}else i=c[b+72>>2]|0;if(((c[b+52>>2]|0)+i|0)<=(c[(c[b+4>>2]|0)+72>>2]|0))return;nh(b);return}function he(d,e,f,h,j){d=d|0;e=e|0;f=+f;h=+h;j=+j;var k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0;q=i;i=i+240|0;o=+g[d+96>>2]+h;p=+g[d+100>>2]+j;g[d+112>>2]=+g[d+92>>2]+f;g[d+116>>2]=o;g[d+120>>2]=p;g[d+124>>2]=0.0;c[q+168>>2]=1065353216;c[q+168+4>>2]=0;c[q+168+4+4>>2]=0;c[q+168+4+8>>2]=0;c[q+168+4+12>>2]=0;c[q+168+20>>2]=1065353216;c[q+168+24>>2]=0;c[q+168+24+4>>2]=0;c[q+168+24+8>>2]=0;c[q+168+24+12>>2]=0;c[q+168+40>>2]=1065353216;k=q+168+44|0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;c[q+104>>2]=1065353216;c[q+104+4>>2]=0;c[q+104+4+4>>2]=0;c[q+104+4+8>>2]=0;c[q+104+4+12>>2]=0;c[q+104+20>>2]=1065353216;c[q+104+24>>2]=0;c[q+104+24+4>>2]=0;c[q+104+24+8>>2]=0;c[q+104+24+12>>2]=0;c[q+104+40>>2]=1065353216;k=q+104+44|0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;p=1.0;k=10;while(1){if((k|0)<=0){k=14;break}k=k+-1|0;c[q+168+48>>2]=c[d+92>>2];c[q+168+48+4>>2]=c[d+92+4>>2];c[q+168+48+8>>2]=c[d+92+8>>2];c[q+168+48+12>>2]=c[d+92+12>>2];c[q+104+48>>2]=c[d+112>>2];c[q+104+48+4>>2]=c[d+112+4>>2];c[q+104+48+8>>2]=c[d+112+8>>2];c[q+104+48+12>>2]=c[d+112+12>>2];n=+g[d+92>>2]-+g[d+112>>2];o=+g[d+96>>2]-+g[d+116>>2];f=+g[d+100>>2]-+g[d+120>>2];r=c[d+8>>2]|0;g[q+4>>2]=1.0;b[q+8>>1]=1;b[q+10>>1]=-1;c[q+76>>2]=0;c[q+12>>2]=0;c[q+12+4>>2]=0;c[q+12+8>>2]=0;c[q+12+12>>2]=0;c[q+12+16>>2]=0;c[q+12+20>>2]=0;c[q+12+24>>2]=0;c[q+12+28>>2]=0;c[q>>2]=4936;c[q+80>>2]=r;g[q+84>>2]=n;g[q+88>>2]=o;g[q+92>>2]=f;g[q+96>>2]=0.0;g[q+100>>2]=0.0;r=c[(c[r+188>>2]|0)+4>>2]|0;b[q+8>>1]=r;b[q+10>>1]=r>>>16;r=c[d+12>>2]|0;f=+Sb[c[(c[r>>2]|0)+48>>2]&15](r);r=c[d+12>>2]|0;zb[c[(c[r>>2]|0)+44>>2]&31](r,f+ +g[d+56>>2]);if(!(a[d+170>>0]|0))Kd(e,c[d+12>>2]|0,q+168|0,q+104|0,q,+g[e+56>>2]);else wd(c[d+8>>2]|0,c[d+12>>2]|0,q+168|0,q+104|0,q,+g[e+56>>2]);r=c[d+12>>2]|0;zb[c[(c[r>>2]|0)+44>>2]&31](r,f);o=+g[q+4>>2];p=p-o;if(o<1.0){h=+g[d+112>>2];m=+g[d+92>>2];j=+g[d+116>>2];n=+g[d+96>>2];l=+g[d+120>>2];o=+g[d+100>>2];f=+O(+((h-m)*(h-m)+(j-n)*(j-n)+(l-o)*(l-o)));if(f>1.1920928955078125e-07){v=+g[q+44>>2];t=+g[q+48>>2];x=+g[q+52>>2];w=((h-m)*(1.0/f)*v+(j-n)*(1.0/f)*t+(l-o)*(1.0/f)*x)*2.0;u=(h-m)*(1.0/f)-v*w;s=(j-n)*(1.0/f)-t*w;w=(l-o)*(1.0/f)-x*w;l=1.0/+O(+(w*w+(u*u+s*s)));c[d+112>>2]=c[d+92>>2];c[d+112+4>>2]=c[d+92+4>>2];c[d+112+8>>2]=c[d+92+8>>2];c[d+112+12>>2]=c[d+92+12>>2];h=f*(l*u-v*(x*l*w+(v*l*u+t*l*s)))+ +g[d+112>>2];g[d+112>>2]=h;j=f*(l*s-t*(x*l*w+(v*l*u+t*l*s)))+ +g[d+116>>2];g[d+116>>2]=j;l=f*(l*w-x*(x*l*w+(v*l*u+t*l*s)))+ +g[d+120>>2];g[d+120>>2]=l;f=j}else f=j;j=h-m;h=f-n;f=l-o;if(!(j*j+h*h+f*f>1.1920928955078125e-07)){k=11;break}x=1.0/+O(+(j*j+h*h+f*f));if(+g[d+76>>2]*j*x+h*x*+g[d+80>>2]+f*x*+g[d+84>>2]<=0.0){k=11;break}}else{c[d+92>>2]=c[d+112>>2];c[d+92+4>>2]=c[d+112+4>>2];c[d+92+8>>2]=c[d+112+8>>2];c[d+92+12>>2]=c[d+112+12>>2]}if(!(p>.009999999776482582)){k=14;break}}if((k|0)==11){i=q;return}else if((k|0)==14){i=q;return}}function ie(d,f,h,j){d=d|0;f=f|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0;w=i;i=i+80|0;v=c[d+48>>2]|0;c[w>>2]=6864;c[w+4>>2]=v;c[w+8>>2]=f;v=c[d+52>>2]|0;if(!(a[v+60>>0]|0)){f=c[v+56>>2]|0;if((f|0)>0){d=f;m=0;p=c[v+96>>2]|0;f=0;while(1){f=f+1|0;if(!(+g[h>>2]>+g[p+16>>2])?!(+g[j>>2]<+g[p>>2]):0)k=1;else k=0;if(!(!(+g[h+8>>2]>+g[p+24>>2])?!(+g[j+8>>2]<+g[p+8>>2]):0))k=0;if(!(+g[h+4>>2]>+g[p+20>>2])?!(+g[j+4>>2]<+g[p+4>>2]):0){l=c[p+32>>2]|0;if(k&(l|0)==-1){ic[c[(c[w>>2]|0)+8>>2]&127](w,c[p+36>>2]|0,c[p+40>>2]|0);d=c[v+56>>2]|0;o=43}else{n=(l|0)==-1;o=42}}else{l=c[p+32>>2]|0;k=0;n=(l|0)==-1;o=42}if((o|0)==42){o=0;if(n|k)o=43;else{m=l+m|0;k=p+(l<<6)|0}}if((o|0)==43){m=m+1|0;k=p+64|0}if((m|0)<(d|0))p=k;else break}}else f=0;if((c[6167]|0)>=(f|0)){i=w;return}c[6167]=f;i=w;return}D=+g[h>>2];H=+g[h+4>>2];z=+g[h+8>>2];G=+g[v+4>>2];D=D>2];H=H>2];z=z>2];A=+g[v+24>>2];E=+g[v+28>>2];F=+g[v+36>>2];x=+g[v+40>>2];B=+g[v+44>>2];u=~~(((I>1]=u;s=~~(((E>1]=t;b[w+66+4>>1]=s;H=+g[j>>2];z=+g[j+4>>2];D=+g[j+8>>2];H=H>1]=r;j=(~~(((E>1]=q;b[w+60+4>>1]=j;switch(c[v+144>>2]|0){case 0:{o=c[v+56>>2]|0;if((o|0)>0){d=0;k=c[v+136>>2]|0;f=0;do{f=f+1|0;l=((r&65535)>=(e[k>>1]|0)?(u&65535)<=(e[k+6>>1]|0):0)&(s&65535)<=(e[k+10>>1]|0)&(j&65535)>=(e[k+4>>1]|0)&(t&65535)<=(e[k+8>>1]|0)&(q&65535)>=(e[k+2>>1]|0);m=k+12|0;n=c[m>>2]|0;if((n|0)>-1&l)ic[c[(c[w>>2]|0)+8>>2]&127](w,n>>21,n&2097151);if(l|(n|0)>-1){d=d+1|0;k=k+16|0}else{v=c[m>>2]|0;d=d-v|0;k=k+(0-v<<4)|0}}while((d|0)<(o|0))}else f=0;if((c[6167]|0)<(f|0))c[6167]=f;break}case 1:{if((c[v+152>>2]|0)>0){h=0;do{f=c[v+160>>2]|0;if(((r&65535)>=(e[f+(h<<5)>>1]|0)?(u&65535)<=(e[f+(h<<5)+6>>1]|0):0)&(s&65535)<=(e[f+(h<<5)+10>>1]|0)&(j&65535)>=(e[f+(h<<5)+4>>1]|0)&(t&65535)<=(e[f+(h<<5)+8>>1]|0)&(q&65535)>=(e[f+(h<<5)+2>>1]|0)){p=c[f+(h<<5)+12>>2]|0;o=c[f+(h<<5)+16>>2]|0;if((o|0)>0){d=p;k=(c[v+136>>2]|0)+(p<<4)|0;f=0;do{f=f+1|0;l=((r&65535)>=(e[k>>1]|0)?(u&65535)<=(e[k+6>>1]|0):0)&(s&65535)<=(e[k+10>>1]|0)&(j&65535)>=(e[k+4>>1]|0)&(t&65535)<=(e[k+8>>1]|0)&(q&65535)>=(e[k+2>>1]|0);m=k+12|0;n=c[m>>2]|0;if((n|0)>-1&l)ic[c[(c[w>>2]|0)+8>>2]&127](w,n>>21,n&2097151);if(l|(n|0)>-1){d=d+1|0;k=k+16|0}else{n=c[m>>2]|0;d=d-n|0;k=k+(0-n<<4)|0}}while((d|0)<(o+p|0))}else f=0;if((c[6167]|0)<(f|0))c[6167]=f}h=h+1|0}while((h|0)<(c[v+152>>2]|0))}break}case 2:{Lk(c[v+136>>2]|0,w,w+66|0,w+60|0);break}default:{}}i=w;return}function je(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;c[b+24>>2]=d;g[b+28>>2]=0.0;c[b+32>>2]=0;c[b+36>>2]=1;g[b+40>>2]=1.0;a[b+44>>0]=1;c[b+48>>2]=0;a[b+52>>0]=0;a[b+53>>0]=1;a[b+54>>0]=1;g[b+56>>2]=.03999999910593033;a[b+60>>0]=0;g[b+64>>2]=0.0;c[b+68>>2]=e;c[b+72>>2]=0;a[b+76>>0]=1;c[b+80>>2]=0;c[b+84>>2]=0;c[b+88>>2]=0;g[b+92>>2]=.6000000238418579;g[b+96>>2]=1.0;g[b+100>>2]=.30000001192092896;g[b+104>>2]=.01666666753590107;g[b+108>>2]=0.0;g[b+116>>2]=20.0;c[b+112>>2]=10;g[b+124>>2]=.20000000298023224;g[b+128>>2]=.800000011920929;g[b+132>>2]=0.0;g[b+120>>2]=1.0;c[b+136>>2]=1;g[b+140>>2]=-.03999999910593033;g[b+144>>2]=.10000000149011612;g[b+148>>2]=0.0;g[b+152>>2]=.8500000238418579;c[b+156>>2]=260;c[b+160>>2]=2;c[b+164>>2]=128;g[b+168>>2]=100.0;g[b+172>>2]=1000000015047466219876688.0e6;c[b>>2]=4144;a[b+192>>0]=1;c[b+188>>2]=0;c[b+180>>2]=0;c[b+184>>2]=0;c[b+196>>2]=0;c[b+200>>2]=f;a[b+224>>0]=1;c[b+220>>2]=0;c[b+212>>2]=0;c[b+216>>2]=0;a[b+244>>0]=1;c[b+240>>2]=0;c[b+232>>2]=0;c[b+236>>2]=0;c[b+248>>2]=0;c[b+252>>2]=-1054867456;a[b+274>>0]=0;a[b+275>>0]=0;c[b+256>>2]=0;c[b+256+4>>2]=0;c[b+256+8>>2]=0;c[b+256+12>>2]=0;a[b+292>>0]=1;c[b+288>>2]=0;c[b+280>>2]=0;c[b+284>>2]=0;c[b+296>>2]=0;a[b+300>>0]=1;a[b+320>>0]=1;c[b+316>>2]=0;c[b+308>>2]=0;c[b+312>>2]=0;if(!f){c[6435]=(c[6435]|0)+1;f=yc(215)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}c[f>>2]=4756;a[f+20>>0]=1;c[f+16>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;a[f+40>>0]=1;c[f+36>>2]=0;c[f+28>>2]=0;c[f+32>>2]=0;a[f+60>>0]=1;c[f+56>>2]=0;c[f+48>>2]=0;c[f+52>>2]=0;a[f+80>>0]=1;c[f+76>>2]=0;c[f+68>>2]=0;c[f+72>>2]=0;a[f+100>>0]=1;c[f+96>>2]=0;c[f+88>>2]=0;c[f+92>>2]=0;a[f+120>>0]=1;c[f+116>>2]=0;c[f+108>>2]=0;c[f+112>>2]=0;a[f+140>>0]=1;c[f+136>>2]=0;c[f+128>>2]=0;c[f+132>>2]=0;a[f+160>>0]=1;c[f+156>>2]=0;c[f+148>>2]=0;c[f+152>>2]=0;a[f+180>>0]=1;c[f+176>>2]=0;c[f+168>>2]=0;c[f+172>>2]=0;c[f+192>>2]=0;c[b+200>>2]=f;a[b+273>>0]=1}else a[b+273>>0]=0;c[6435]=(c[6435]|0)+1;f=yc(87)|0;if(!f)f=0;else{c[(f+4+15&-16)+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|0;var e=0,f=0,h=0.0,j=0,k=0.0,l=0,m=0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0.0;u=i;i=i+96|0;s=c[b+12>>2]|0;mc[c[(c[s>>2]|0)+8>>2]&127](s,(c[b+8>>2]|0)+4|0,u+80|0,u+64|0);s=c[d+68>>2]|0;yb[c[(c[s>>2]|0)+16>>2]&31](s,c[(c[b+8>>2]|0)+188>>2]|0,u+80|0,u+64|0,c[d+24>>2]|0);s=c[d+24>>2]|0;mc[c[(c[s>>2]|0)+32>>2]&127](s,c[(c[b+8>>2]|0)+284>>2]|0,d+28|0,s);s=c[b+8>>2]|0;c[b+92>>2]=c[s+52>>2];c[b+92+4>>2]=c[s+52+4>>2];c[b+92+8>>2]=c[s+52+8>>2];c[b+92+12>>2]=c[s+52+12>>2];s=c[s+284>>2]|0;if((Eb[c[(c[s>>2]|0)+36>>2]&127](s)|0)>0){s=0;h=0.0;d=0;do{e=c[b+132>>2]|0;if((e|0)<0){if((c[b+136>>2]|0)<0){f=c[b+140>>2]|0;if(f|0){if(a[b+144>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+140>>2]=0}a[b+144>>0]=1;c[b+140>>2]=0;c[b+136>>2]=0}do{c[(c[b+140>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=0)}c[b+132>>2]=0;e=c[(c[b+8>>2]|0)+284>>2]|0;e=c[(Eb[c[(c[e>>2]|0)+28>>2]&127](e)|0)+12>>2]|0;r=c[c[e+(s<<4)>>2]>>2]|0;f=c[c[e+(s<<4)+4>>2]>>2]|0;if(!((r|0)!=0?(c[r+204>>2]&4|0)!=0:0))t=14;do if((t|0)==14){t=0;if(f|0?c[f+204>>2]&4|0:0)break;e=c[e+(s<<4)+8>>2]|0;if(e|0)Cb[c[(c[e>>2]|0)+16>>2]&127](e,b+128|0);q=c[b+132>>2]|0;if((q|0)>0){o=c[b+140>>2]|0;p=c[b+8>>2]|0;r=0;do{m=c[o+(r<<2)>>2]|0;n=(c[m+740>>2]|0)==(p|0)?-1.0:1.0;e=c[m+748>>2]|0;if((e|0)>0){l=0;do{k=+g[m+4+(l*184|0)+80>>2];if(k<0.0){j=m+4+(l*184|0)+64|0;if(k>2];f=m+4+(l*184|0)+72|0;h=n*+g[f>>2];g[b+152>>2]=n*+g[j>>2];g[b+156>>2]=v;g[b+160>>2]=h;g[b+164>>2]=0.0;e=c[m+748>>2]|0;h=k}else{d=m+4+(l*184|0)+68|0;f=m+4+(l*184|0)+72|0}w=k*n*+g[d>>2]*.20000000298023224;v=k*n*+g[f>>2]*.20000000298023224;g[b+92>>2]=k*n*+g[j>>2]*.20000000298023224+ +g[b+92>>2];g[b+96>>2]=w+ +g[b+96>>2];g[b+100>>2]=v+ +g[b+100>>2];d=1}l=l+1|0}while((l|0)<(e|0))}r=r+1|0}while((r|0)!=(q|0))}}while(0);s=s+1|0;r=c[(c[b+8>>2]|0)+284>>2]|0}while((s|0)<(Eb[c[(c[r>>2]|0)+36>>2]&127](r)|0))}else d=0;t=c[b+8>>2]|0;c[u>>2]=c[t+4>>2];c[u+4>>2]=c[t+4+4>>2];c[u+8>>2]=c[t+4+8>>2];c[u+12>>2]=c[t+4+12>>2];c[u+16>>2]=c[t+20>>2];c[u+16+4>>2]=c[t+20+4>>2];c[u+16+8>>2]=c[t+20+8>>2];c[u+16+12>>2]=c[t+20+12>>2];c[u+32>>2]=c[t+36>>2];c[u+32+4>>2]=c[t+36+4>>2];c[u+32+8>>2]=c[t+36+8>>2];c[u+32+12>>2]=c[t+36+12>>2];c[u+48>>2]=c[b+92>>2];c[u+48+4>>2]=c[b+92+4>>2];c[u+48+8>>2]=c[b+92+8>>2];c[u+48+12>>2]=c[b+92+12>>2];c[t+260>>2]=(c[t+260>>2]|0)+1;c[t+4>>2]=c[u>>2];c[t+4+4>>2]=c[u+4>>2];c[t+4+8>>2]=c[u+8>>2];c[t+4+12>>2]=c[u+12>>2];c[t+20>>2]=c[u+16>>2];c[t+20+4>>2]=c[u+16+4>>2];c[t+20+8>>2]=c[u+16+8>>2];c[t+20+12>>2]=c[u+16+12>>2];c[t+36>>2]=c[u+32>>2];c[t+36+4>>2]=c[u+32+4>>2];c[t+36+8>>2]=c[u+32+8>>2];c[t+36+12>>2]=c[u+32+12>>2];c[t+52>>2]=c[u+48>>2];c[t+52+4>>2]=c[u+48+4>>2];c[t+52+8>>2]=c[u+48+8>>2];c[t+52+12>>2]=c[u+48+12>>2];i=u;return d|0}function le(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0.0,u=0.0;s=i;i=i+48|0;c[s+16>>2]=c[e>>2];c[s+16+4>>2]=c[e+4>>2];c[s+16+8>>2]=c[e+8>>2];c[s+16+12>>2]=c[e+12>>2];c[s+16+16>>2]=c[f>>2];c[s+16+16+4>>2]=c[f+4>>2];c[s+16+16+8>>2]=c[f+8>>2];c[s+16+16+12>>2]=c[f+12>>2];do if((c[d+60>>2]|0)==2){h=c[d+48>>2]|0;hh(b+64|0,h)|0;j=c[b+68>>2]|0;if(j|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[b+68>>2]=h;c[b+76>>2]=(c[b+76>>2]|0)+-1;h=c[b+8>>2]|0;if(!h){c[6435]=(c[6435]|0)+1;h=yc(63)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=h;k=j+44|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(k|0))}else c[b+8>>2]=0;c[h+32>>2]=0;c[h+36>>2]=d;c[h+40>>2]=0;c[h>>2]=c[s+16>>2];c[h+4>>2]=c[s+16+4>>2];c[h+8>>2]=c[s+16+8>>2];c[h+12>>2]=c[s+16+12>>2];c[h+16>>2]=c[s+16+16>>2];c[h+20>>2]=c[s+16+20>>2];c[h+24>>2]=c[s+16+24>>2];c[h+28>>2]=c[s+16+28>>2];lf(b+4|0,c[b+4>>2]|0,h);c[b+16>>2]=(c[b+16>>2]|0)+1;c[d+48>>2]=h;k=1}else{c[b+168>>2]=(c[b+168>>2]|0)+1;r=c[d+48>>2]|0;if(((((+g[r>>2]<=+g[s+16+16>>2]?+g[r+16>>2]>=+g[s+16>>2]:0)?+g[r+4>>2]<=+g[s+16+20>>2]:0)?+g[r+20>>2]>=+g[s+16+4>>2]:0)?+g[r+8>>2]<=+g[s+16+24>>2]:0)?+g[r+24>>2]>=+g[s+16+8>>2]:0){l=+g[d+16>>2];t=+g[e>>2]-l;m=+g[d+20>>2];o=+g[e+4>>2]-m;n=+g[d+24>>2];p=+g[e+8>>2]-n;u=+g[b+140>>2];l=(+g[d+32>>2]-l)*.5*u;m=(+g[d+36>>2]-m)*.5*u;n=u*(+g[d+40>>2]-n)*.5;g[s>>2]=l;g[s+4>>2]=m;g[s+8>>2]=n;g[s+12>>2]=0.0;if(t<0.0)g[s>>2]=-l;if(o<0.0)g[s+4>>2]=-m;if(p<0.0)g[s+8>>2]=-n;if(jh(b+4|0,r,s+16|0,s,.05000000074505806)|0){c[b+172>>2]=(c[b+172>>2]|0)+1;h=1}else h=0;k=h;break}h=hh(b+4|0,r)|0;a:do if(h){k=c[b+12>>2]|0;if((k|0)<=-1){h=c[b+4>>2]|0;break}if((k|0)>0){q=0;while(1){j=c[h+32>>2]|0;q=q+1|0;if(!j)break a;if((q|0)>=(k|0)){h=j;break}else h=j}}}else h=0;while(0);c[r>>2]=c[s+16>>2];c[r+4>>2]=c[s+16+4>>2];c[r+8>>2]=c[s+16+8>>2];c[r+12>>2]=c[s+16+12>>2];c[r+16>>2]=c[s+16+16>>2];c[r+20>>2]=c[s+16+20>>2];c[r+24>>2]=c[s+16+24>>2];c[r+28>>2]=c[s+16+28>>2];lf(b+4|0,h,r);c[b+172>>2]=(c[b+172>>2]|0)+1;k=1}while(0);h=c[d+52>>2]|0;j=c[d+56>>2]|0;if(!h)c[b+124+(c[d+60>>2]<<2)>>2]=j;else c[h+56>>2]=j;h=c[d+56>>2]|0;if(h|0)c[h+52>>2]=c[d+52>>2];c[d+16>>2]=c[e>>2];c[d+16+4>>2]=c[e+4>>2];c[d+16+8>>2]=c[e+8>>2];c[d+16+12>>2]=c[e+12>>2];c[d+32>>2]=c[f>>2];c[d+32+4>>2]=c[f+4>>2];c[d+32+8>>2]=c[f+8>>2];c[d+32+12>>2]=c[f+12>>2];h=c[b+144>>2]|0;c[d+60>>2]=h;c[d+52>>2]=0;c[d+56>>2]=c[b+124+(h<<2)>>2];j=c[b+124+(h<<2)>>2]|0;if(j|0)c[j+52>>2]=d;c[b+124+(h<<2)>>2]=d;if(!k){i=s;return}a[b+194>>0]=1;if(a[b+193>>0]|0){i=s;return}c[s>>2]=8904;c[s+4>>2]=b;we(b+64|0,c[b+64>>2]|0,c[d+48>>2]|0,s);we(b+4|0,c[b+4>>2]|0,c[d+48>>2]|0,s);i=s;return}function me(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0;m=i;i=i+352|0;e=c[d+36>>2]|0;c[m+288+4>>2]=35;c[m+288+8>>2]=0;c[m+288+12>>2]=1065353216;c[m+288+16>>2]=1065353216;c[m+288+20>>2]=1065353216;g[m+288+24>>2]=0.0;c[m+288>>2]=3436;c[m+288+52>>2]=e;g[m+288+44>>2]=0.0;k=c[b+28>>2]|0;d=c[k+4>>2]|0;if(c[(c[k+8>>2]|0)+204>>2]&3|0?a[e+376>>0]|0:0){i=m;return}if((a[22456]|0)==0?Wa(22456)|0:0){if((a[22464]|0)==0?Wa(22464)|0:0){c[5698]=1065353216;c[5699]=0;c[5700]=0;c[5701]=0;c[5702]=0;c[5703]=1065353216;c[5704]=0;c[5705]=0;c[5706]=0;c[5707]=0;c[5708]=1065353216;g[5709]=0.0;_a(22464)}c[5710]=c[5698];c[5711]=c[5699];c[5712]=c[5700];c[5713]=c[5701];c[5714]=c[5702];c[5715]=c[5703];c[5716]=c[5704];c[5717]=c[5705];c[5718]=c[5706];c[5719]=c[5707];c[5720]=c[5708];c[5721]=c[5709];c[5722]=0;c[5723]=0;c[5724]=0;c[5725]=0;_a(22456)}f=c[(c[b+28>>2]|0)+12>>2]|0;c[m>>2]=1065353216;c[m+4>>2]=0;c[m+8>>2]=0;g[m+12>>2]=0.0;if(!(!(Jd(m+288|0,22840,d,f,m,m+232|0)|0)?!(Pc(m+288|0,22840,d,f,m,m+232|0,0)|0):0)){k=m+16+4|0;a[m+16+152>>0]=0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;c[k+20>>2]=0;c[m+16>>2]=3256;k=c[(c[b+28>>2]|0)+8>>2]|0;do if(jd(b,m+232|0,e,0,0,0,(c[k+236>>2]&2|0)==0?0:k,k,m+16|0)|0){c[6435]=(c[6435]|0)+1;d=yc(235)|0;if(!d)k=0;else{c[(d+4+15&-16)+-4>>2]=d;k=d+4+15&-16}d=k+152|0;Qn(k|0,0,156)|0;c[k>>2]=3256;e=k+4|0;f=m+16+4|0;h=e+100|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(h|0));e=k+104|0;c[e>>2]=c[m+16+104>>2];c[e+4>>2]=c[m+16+104+4>>2];c[e+8>>2]=c[m+16+104+8>>2];c[e+12>>2]=c[m+16+104+12>>2];e=k+120|0;c[e>>2]=c[m+16+120>>2];c[e+4>>2]=c[m+16+120+4>>2];c[e+8>>2]=c[m+16+120+8>>2];c[e+12>>2]=c[m+16+120+12>>2];e=k+136|0;c[e>>2]=c[m+16+136>>2];c[e+4>>2]=c[m+16+136+4>>2];c[e+8>>2]=c[m+16+136+8>>2];c[e+12>>2]=c[m+16+136+12>>2];a[d>>0]=a[m+16+152>>0]|0;e=k+156|0;f=m+16+156|0;h=e+60|0;do{c[e>>2]=c[f>>2];e=e+4|0;f=f+4|0}while((e|0)<(h|0));h=c[b+24>>2]|0;j=k;d=c[h+852>>2]|0;if((d|0)==(c[h+856>>2]|0)?(l=d|0?d<<1:1,(d|0)<(l|0)):0){if(!l)f=0;else{c[6435]=(c[6435]|0)+1;d=yc((l<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}f=d;d=c[h+852>>2]|0}if((d|0)>0){e=0;do{c[f+(e<<2)>>2]=c[(c[h+860>>2]|0)+(e<<2)>>2];e=e+1|0}while((e|0)!=(d|0))}e=c[h+860>>2]|0;if(e){if(a[h+864>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[h+852>>2]|0}c[h+860>>2]=0}a[h+864>>0]=1;c[h+860>>2]=f;c[h+856>>2]=l}c[(c[h+860>>2]|0)+(d<<2)>>2]=j;c[h+852>>2]=d+1;d=c[b+24>>2]|0;if(!(c[(c[(c[b+28>>2]|0)+8>>2]|0)+204>>2]&3)){b=k+64|0;g[b>>2]=+g[d+340>>2]*+g[b>>2];b=k+68|0;g[b>>2]=+g[d+352>>2]*+g[b>>2];break}else{b=k+64|0;g[b>>2]=+g[d+344>>2]*+g[b>>2];b=k+68|0;g[b>>2]=+g[d+356>>2]*+g[b>>2];break}}while(0)}i=m;return}function ne(b,d,e,f,h,i,j,l){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;l=l|0;var m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0;c[b+4>>2]=4;c[b+8>>2]=-1;c[b+12>>2]=-1;g[b+16>>2]=3402823466385288598117041.0e14;a[b+20>>0]=1;a[b+21>>0]=0;c[b+24>>2]=-1;c[b+28>>2]=d;c[b+32>>2]=e;g[b+36>>2]=0.0;g[b+40>>2]=.30000001192092896;c[b+44>>2]=0;c[b>>2]=4704;g[b+688>>2]=0.0;g[b+692>>2]=-1.0;g[b+696>>2]=.8999999761581421;g[b+700>>2]=.30000001192092896;g[b+704>>2]=1.0;g[b+708>>2]=0.0;g[b+712>>2]=0.0;a[b+716>>0]=0;a[b+736>>0]=0;a[b+737>>0]=0;a[b+738>>0]=0;a[b+739>>0]=1;a[b+740>>0]=l&1;c[b+748>>2]=0;c[b+600>>2]=c[f>>2];c[b+600+4>>2]=c[f+4>>2];c[b+600+8>>2]=c[f+8>>2];c[b+600+12>>2]=c[f+12>>2];m=+g[d+4>>2];n=+g[d+20>>2];o=+g[d+36>>2];p=+g[i>>2];q=+g[i+4>>2];r=+g[i+8>>2];do if(!(m*p+n*q+o*r>=.9999998807907104))if(!(m*p+n*q+o*r<=-.9999998807907104)){e=(g[k>>2]=o*q-n*r,c[k>>2]|0);f=(g[k>>2]=m*r-o*p,c[k>>2]|0);l=(g[k>>2]=n*p-m*q,c[k>>2]|0);u=(g[k>>2]=r*(m*r-o*p)-q*(n*p-m*q),c[k>>2]|0);v=(g[k>>2]=p*(n*p-m*q)-r*(o*q-n*r),c[k>>2]|0);t=(g[k>>2]=q*(o*q-n*r)-p*(m*r-o*p),c[k>>2]|0);break}else{u=c[d+12>>2]|0;v=c[d+28>>2]|0;t=c[d+44>>2]|0;e=c[d+8>>2]|0;l=c[d+40>>2]|0;f=c[d+24>>2]|0;break}else{u=(g[k>>2]=-+g[d+12>>2],c[k>>2]|0);v=(g[k>>2]=-+g[d+28>>2],c[k>>2]|0);t=(g[k>>2]=-+g[d+44>>2],c[k>>2]|0);e=c[d+8>>2]|0;l=c[d+40>>2]|0;f=c[d+24>>2]|0}while(0);c[b+552>>2]=u;c[b+556>>2]=e;c[b+560>>2]=c[i>>2];g[b+564>>2]=0.0;c[b+568>>2]=v;c[b+572>>2]=f;c[b+576>>2]=c[i+4>>2];g[b+580>>2]=0.0;c[b+584>>2]=t;c[b+588>>2]=l;c[b+592>>2]=c[i+8>>2];g[b+596>>2]=0.0;o=+g[i+4>>2];q=+g[j+8>>2];m=+g[i+8>>2];r=+g[j+4>>2];s=+g[j>>2];n=+g[i>>2];do if(q*m+(o*r+s*n)<-.9999998807907104)if(+N(+m)>.7071067690849304){n=1.0/+O(+(o*o+m*m));e=0;p=0.0;m=-(m*n);f=(g[k>>2]=o*n,c[k>>2]|0);break}else{m=1.0/+O(+(o*o+n*n));e=(g[k>>2]=-(o*m),c[k>>2]|0);p=0.0;m=n*m;f=0;break}else{w=+O(+((q*m+(o*r+s*n)+1.0)*2.0));e=(g[k>>2]=(o*q-m*r)*(1.0/w),c[k>>2]|0);p=w*.5;m=(m*s-q*n)*(1.0/w);f=(g[k>>2]=(r*n-o*s)*(1.0/w),c[k>>2]|0)}while(0);o=(c[k>>2]=u,+g[k>>2]);A=(c[k>>2]=t,+g[k>>2]);z=(c[k>>2]=f,+g[k>>2]);w=(c[k>>2]=v,+g[k>>2]);B=o*p+A*m-w*z;n=(c[k>>2]=e,+g[k>>2]);x=w*p+o*z-A*n;y=A*p+w*n-o*m;A=-(o*n)-w*m-A*z;m=-m;w=x*-z+(p*B+A*-n)-y*m;o=y*-n+(p*x+A*m)-B*-z;p=B*m+(A*-z+p*y)-x*-n;c[b+664>>2]=c[h>>2];c[b+664+4>>2]=c[h+4>>2];c[b+664+8>>2]=c[h+8>>2];c[b+664+12>>2]=c[h+12>>2];g[b+616>>2]=w;g[b+620>>2]=r*p-q*o;c[b+624>>2]=c[j>>2];g[b+628>>2]=0.0;g[b+632>>2]=o;g[b+636>>2]=q*w-s*p;c[b+640>>2]=c[j+4>>2];g[b+644>>2]=0.0;g[b+648>>2]=p;g[b+652>>2]=s*o-r*w;c[b+656>>2]=c[j+8>>2];g[b+660>>2]=0.0;g[b+732>>2]=a[b+740>>0]|0?-1.0:1.0;return}function oe(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0;p=i;i=i+144|0;if((c[a+16>>2]|0)<=0){o=a+76|0;c[o>>2]=c[b>>2];c[o+4>>2]=c[b+4>>2];c[o+8>>2]=c[b+8>>2];c[o+12>>2]=c[b+12>>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=c[p+16+12>>2];m=n+(o*80|0)+16|0;c[m>>2]=c[j>>2];c[m+4>>2]=c[j+4>>2];c[m+8>>2]=c[j+8>>2];c[m+12>>2]=c[j+12>>2];m=n+(o*80|0)+32|0;c[m>>2]=c[k>>2];c[m+4>>2]=c[k+4>>2];c[m+8>>2]=c[k+8>>2];c[m+12>>2]=c[k+12>>2];n=n+(o*80|0)+48|0;c[n>>2]=c[l>>2];c[n+4>>2]=c[l+4>>2];c[n+8>>2]=c[l+8>>2];c[n+12>>2]=c[l+12>>2];if(c[a+64>>2]|0){m=c[(c[a+24>>2]|0)+(o*80|0)+64>>2]|0;mc[c[(c[m>>2]|0)+8>>2]&127](m,p+16|0,p+128|0,p+112|0);c[p+80>>2]=c[p+128>>2];c[p+80+4>>2]=c[p+128+4>>2];c[p+80+8>>2]=c[p+128+8>>2];c[p+80+12>>2]=c[p+128+12>>2];c[p+80+16>>2]=c[p+112>>2];c[p+80+16+4>>2]=c[p+112+4>>2];c[p+80+16+8>>2]=c[p+112+8>>2];c[p+80+16+12>>2]=c[p+112+12>>2];m=c[a+64>>2]|0;n=c[(c[a+24>>2]|0)+(o*80|0)+76>>2]|0;d=hh(m,n)|0;a:do if(d){f=c[m+8>>2]|0;if((f|0)<=-1){d=c[m>>2]|0;break}if((f|0)>0){h=0;while(1){e=c[d+32>>2]|0;h=h+1|0;if(!e)break a;if((h|0)>=(f|0)){d=e;break}else d=e}}}else d=0;while(0);c[n>>2]=c[p+80>>2];c[n+4>>2]=c[p+80+4>>2];c[n+8>>2]=c[p+80+8>>2];c[n+12>>2]=c[p+80+12>>2];c[n+16>>2]=c[p+80+16>>2];c[n+20>>2]=c[p+80+20>>2];c[n+24>>2]=c[p+80+24>>2];c[n+28>>2]=c[p+80+28>>2];lf(m,d,n)}o=o+1|0}while((o|0)<(c[a+16>>2]|0));o=a+76|0;c[o>>2]=c[b>>2];c[o+4>>2]=c[b+4>>2];c[o+8>>2]=c[b+8>>2];c[o+12>>2]=c[b+12>>2];b=c[a>>2]|0;b=b+68|0;b=c[b>>2]|0;Ab[b&255](a);i=p;return}function pe(d,f,h,i,j,k){d=d|0;f=f|0;h=h|0;i=i|0;j=j|0;k=k|0;var l=0.0,m=0.0,n=0.0;c[d>>2]=8520;b[d+4>>1]=-2;b[d+6>>1]=-1;c[d+92>>2]=j;c[d+96>>2]=0;a[d+100>>0]=0;c[d+104>>2]=0;c[d+108>>2]=0;if(!j){c[6435]=(c[6435]|0)+1;j=yc(95)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}Ri(j);c[d+92>>2]=j;a[d+100>>0]=1}if(!k){c[6435]=(c[6435]|0)+1;j=yc(43)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}c[j>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;c[j+12>>2]=0;c[j+16>>2]=0;c[j+20>>2]=0;c[j>>2]=8584;a[j+20>>0]=1;c[j+16>>2]=0;c[j+8>>2]=0;c[j+12>>2]=0;c[d+112>>2]=j;c[6435]=(c[6435]|0)+1;j=yc(215)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}Zh(j,c[d+112>>2]|0);c[d+108>>2]=j;a[j+193>>0]=1}c[d+8>>2]=c[f>>2];c[d+8+4>>2]=c[f+4>>2];c[d+8+8>>2]=c[f+8>>2];c[d+8+12>>2]=c[f+12>>2];c[d+24>>2]=c[h>>2];c[d+24+4>>2]=c[h+4>>2];c[d+24+8>>2]=c[h+8>>2];c[d+24+12>>2]=c[h+12>>2];n=+(e[d+6>>1]|0);m=n/(+g[d+28>>2]-+g[d+12>>2]);l=n/(+g[d+32>>2]-+g[d+16>>2]);g[d+40>>2]=n/(+g[d+24>>2]-+g[d+8>>2]);g[d+44>>2]=m;g[d+48>>2]=l;g[d+52>>2]=0.0;f=(i&65535)+1&65535;c[6435]=(c[6435]|0)+1;j=yc(f<<6|19)|0;if(!j)h=0;else{c[(j+4+15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h;h=c[d+60>>2]|0;c[h>>2]=0;f=h+48|0;b[f>>1]=0;f=h+54|0;b[f>>1]=1;f=c[d+68>>2]|0;b[f>>1]=0;k=f+2|0;b[k>>1]=0;k=b[d+6>>1]|0;j=f+4|0;b[j>>1]=k;f=f+6|0;b[f>>1]=0;f=h+50|0;b[f>>1]=0;f=h+56|0;b[f>>1]=1;f=c[d+72>>2]|0;b[f>>1]=0;j=f+2|0;b[j>>1]=0;j=b[d+6>>1]|0;k=f+4|0;b[k>>1]=j;f=f+6|0;b[f>>1]=0;f=h+52|0;b[f>>1]=0;h=h+58|0;b[h>>1]=1;i=c[i>>2]|0;b[i>>1]=0;h=i+2|0;b[h>>1]=0;h=b[d+6>>1]|0;f=i+4|0;b[f>>1]=h;i=i+6|0;b[i>>1]=0;c[d>>2]=8660;return}function qe(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0;Il();c[b+4>>2]=6;c[b+8>>2]=-1;c[b+12>>2]=-1;g[b+16>>2]=3402823466385288598117041.0e14;a[b+20>>0]=1;a[b+21>>0]=0;c[b+24>>2]=-1;c[b+28>>2]=23268;c[b+32>>2]=d;g[b+36>>2]=0.0;g[b+40>>2]=.30000001192092896;c[b+44>>2]=0;c[b>>2]=4376;c[b+112>>2]=c[e>>2];c[b+112+4>>2]=c[e+4>>2];c[b+112+8>>2]=c[e+8>>2];c[b+112+12>>2]=c[e+12>>2];c[b+128>>2]=c[e+16>>2];c[b+128+4>>2]=c[e+16+4>>2];c[b+128+8>>2]=c[e+16+8>>2];c[b+128+12>>2]=c[e+16+12>>2];c[b+144>>2]=c[e+32>>2];c[b+144+4>>2]=c[e+32+4>>2];c[b+144+8>>2]=c[e+32+8>>2];c[b+144+12>>2]=c[e+32+12>>2];c[b+160>>2]=c[e+48>>2];c[b+160+4>>2]=c[e+48+4>>2];c[b+160+8>>2]=c[e+48+8>>2];c[b+160+12>>2]=c[e+48+12>>2];e=b+680|0;h=e+48|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(h|0));c[b+740>>2]=0;c[b+740+4>>2]=0;c[b+740+8>>2]=0;c[b+740+12>>2]=0;c[b+756>>2]=1045220557;c[b+760>>2]=1045220557;c[b+764>>2]=1045220557;c[b+768>>2]=0;c[b+768+4>>2]=0;c[b+768+8>>2]=0;c[b+768+12>>2]=0;c[b+768+16>>2]=0;g[b+728>>2]=.699999988079071;g[b+732>>2]=1.0;g[b+736>>2]=.5;a[b+788>>0]=0;g[b+792>>2]=0.0;g[b+808>>2]=0.0;a[b+789>>0]=0;g[b+796>>2]=0.0;g[b+812>>2]=0.0;a[b+790>>0]=0;g[b+800>>2]=0.0;g[b+816>>2]=0.0;g[b+928>>2]=0.0;g[b+876>>2]=0.0;g[b+880>>2]=.10000000149011612;g[b+884>>2]=300.0;g[b+868>>2]=1.0;g[b+872>>2]=-1.0;g[b+896>>2]=0.0;g[b+900>>2]=.20000000298023224;g[b+904>>2]=0.0;g[b+908>>2]=0.0;g[b+888>>2]=1.0;g[b+892>>2]=.5;c[b+924>>2]=0;g[b+916>>2]=0.0;a[b+912>>0]=0;g[b+992>>2]=0.0;g[b+940>>2]=0.0;g[b+944>>2]=.10000000149011612;g[b+948>>2]=300.0;g[b+932>>2]=1.0;g[b+936>>2]=-1.0;g[b+960>>2]=0.0;g[b+964>>2]=.20000000298023224;g[b+968>>2]=0.0;g[b+972>>2]=0.0;g[b+952>>2]=1.0;g[b+956>>2]=.5;c[b+988>>2]=0;g[b+980>>2]=0.0;a[b+976>>0]=0;g[b+1056>>2]=0.0;g[b+1004>>2]=0.0;g[b+1008>>2]=.10000000149011612;g[b+1012>>2]=300.0;g[b+996>>2]=1.0;g[b+1e3>>2]=-1.0;g[b+1024>>2]=0.0;g[b+1028>>2]=.20000000298023224;g[b+1032>>2]=0.0;g[b+1036>>2]=0.0;g[b+1016>>2]=1.0;g[b+1020>>2]=.5;c[b+1052>>2]=0;g[b+1044>>2]=0.0;a[b+1040>>0]=0;a[b+1300>>0]=f&1;a[b+1301>>0]=1;c[b+1304>>2]=0;a[b+1308>>0]=0;w=+g[b+112>>2];C=+g[d+4>>2];v=+g[b+128>>2];B=+g[d+8>>2];u=+g[b+144>>2];A=+g[d+12>>2];t=+g[b+116>>2];s=+g[b+132>>2];r=+g[b+148>>2];q=+g[b+120>>2];o=+g[b+136>>2];m=+g[b+152>>2];z=+g[d+20>>2];y=+g[d+24>>2];x=+g[d+28>>2];p=+g[d+36>>2];n=+g[d+40>>2];l=+g[d+44>>2];E=+g[b+160>>2];D=+g[b+164>>2];i=+g[b+168>>2];k=+g[d+52>>2]+(C*E+B*D+A*i);j=z*E+y*D+x*i+ +g[d+56>>2];i=p*E+n*D+l*i+ +g[d+60>>2];g[b+48>>2]=w*C+v*B+u*A;g[b+52>>2]=C*t+B*s+A*r;g[b+56>>2]=C*q+B*o+A*m;g[b+60>>2]=0.0;g[b+64>>2]=w*z+v*y+u*x;g[b+68>>2]=t*z+s*y+r*x;g[b+72>>2]=q*z+o*y+m*x;g[b+76>>2]=0.0;g[b+80>>2]=w*p+v*n+u*l;g[b+84>>2]=t*p+s*n+r*l;g[b+88>>2]=q*p+o*n+m*l;g[b+92>>2]=0.0;g[b+96>>2]=k;g[b+100>>2]=j;g[b+104>>2]=i;g[b+108>>2]=0.0;sd(b,(c[b+28>>2]|0)+4|0,(c[b+32>>2]|0)+4|0);return}function re(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0,X=0.0,Y=0.0;W=i;i=i+240|0;f=(a[b+8>>0]|0)!=0;h=f?e:d;f=f?d:e;S=+g[h+116>>2]-+g[h+52>>2];T=+g[h+120>>2]-+g[h+56>>2];U=+g[h+124>>2]-+g[h+60>>2];V=+g[h+252>>2];if(S*S+T*T+U*U>2];G=+g[f+20>>2];H=+g[f+36>>2];I=+g[f+8>>2];J=+g[f+24>>2];K=+g[f+40>>2];L=+g[f+12>>2];M=+g[f+28>>2];N=+g[f+44>>2];k=-+g[f+52>>2];l=-+g[f+56>>2];m=-+g[f+60>>2];O=+g[h+4>>2];P=+g[h+20>>2];Q=+g[h+36>>2];R=+g[h+8>>2];S=+g[h+24>>2];T=+g[h+40>>2];U=+g[h+12>>2];V=+g[h+28>>2];p=+g[h+44>>2];u=+g[h+52>>2];t=+g[h+56>>2];s=+g[h+60>>2];q=F*k+G*l+H*m+(F*u+G*t+H*s);r=I*k+J*l+K*m+(I*u+J*t+K*s);s=L*k+M*l+N*m+(L*u+M*t+N*s);t=+g[h+68>>2];u=+g[h+84>>2];v=+g[h+100>>2];w=+g[h+72>>2];x=+g[h+88>>2];y=+g[h+104>>2];z=+g[h+76>>2];A=+g[h+92>>2];B=+g[h+108>>2];n=+g[h+116>>2];o=+g[h+120>>2];E=+g[h+124>>2];C=F*k+G*l+H*m+(F*n+G*o+H*E);D=I*k+J*l+K*m+(I*n+J*o+K*E);E=L*k+M*l+N*m+(L*n+M*o+N*E);f=c[f+192>>2]|0;if(((c[f+4>>2]|0)+-21|0)>>>0>=9){X=1.0;i=W;return +X}g[W+224>>2]=q;g[W+224+4>>2]=r;g[W+224+8>>2]=s;g[W+224+12>>2]=0.0;if(C>2]=C;j=C}else j=q;if(D>2]=D;k=D}else k=r;if(E>2]=E;l=E}else l=s;g[W+208>>2]=q;g[W+208+4>>2]=r;g[W+208+8>>2]=s;g[W+208+12>>2]=0.0;if(q>2]=C;m=C}else m=q;if(r>2]=D;n=D}else n=r;if(s>2]=E;o=E}else o=s;Y=+g[h+248>>2];g[W+224>>2]=j-Y;g[W+224+4>>2]=k-Y;g[W+224+8>>2]=l-Y;g[W+208>>2]=Y+m;g[W+208+4>>2]=Y+n;g[W+208+8>>2]=Y+o;c[W>>2]=3688;g[W+4>>2]=F*O+G*P+H*Q;g[W+8>>2]=F*R+G*S+H*T;g[W+12>>2]=F*U+G*V+H*p;g[W+16>>2]=0.0;g[W+20>>2]=I*O+J*P+K*Q;g[W+24>>2]=I*R+J*S+K*T;g[W+28>>2]=I*U+J*V+K*p;g[W+32>>2]=0.0;g[W+36>>2]=L*O+M*P+N*Q;g[W+40>>2]=L*R+M*S+N*T;g[W+44>>2]=L*U+M*V+N*p;g[W+48>>2]=0.0;g[W+52>>2]=q;g[W+56>>2]=r;g[W+60>>2]=s;g[W+64>>2]=0.0;g[W+68>>2]=F*t+G*u+H*v;g[W+72>>2]=F*w+G*x+H*y;g[W+76>>2]=F*z+G*A+H*B;g[W+80>>2]=0.0;g[W+84>>2]=I*t+J*u+K*v;g[W+88>>2]=I*w+J*x+K*y;g[W+92>>2]=I*z+J*A+K*B;g[W+96>>2]=0.0;g[W+100>>2]=L*t+M*u+N*v;g[W+104>>2]=L*w+M*x+N*y;g[W+108>>2]=L*z+M*A+N*B;g[W+112>>2]=0.0;g[W+116>>2]=C;g[W+120>>2]=D;g[W+124>>2]=E;g[W+128>>2]=0.0;g[W+196>>2]=Y;c[W+200>>2]=c[h+244>>2];if(f|0?(mc[c[(c[f>>2]|0)+64>>2]&127](f,W,W+224|0,W+208|0),X=+g[W+200>>2],X<+g[h+244>>2]):0){g[h+244>>2]=X;Y=X;i=W;return +Y}Y=1.0;i=W;return +Y}function se(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0,X=0.0,Y=0.0;W=i;i=i+240|0;f=(a[b+8>>0]|0)!=0;h=f?e:d;f=f?d:e;S=+g[h+116>>2]-+g[h+52>>2];T=+g[h+120>>2]-+g[h+56>>2];U=+g[h+124>>2]-+g[h+60>>2];V=+g[h+252>>2];if(S*S+T*T+U*U>2];G=+g[f+20>>2];H=+g[f+36>>2];I=+g[f+8>>2];J=+g[f+24>>2];K=+g[f+40>>2];L=+g[f+12>>2];M=+g[f+28>>2];N=+g[f+44>>2];k=-+g[f+52>>2];l=-+g[f+56>>2];m=-+g[f+60>>2];O=+g[h+4>>2];P=+g[h+20>>2];Q=+g[h+36>>2];R=+g[h+8>>2];S=+g[h+24>>2];T=+g[h+40>>2];U=+g[h+12>>2];V=+g[h+28>>2];p=+g[h+44>>2];u=+g[h+52>>2];t=+g[h+56>>2];s=+g[h+60>>2];q=F*k+G*l+H*m+(F*u+G*t+H*s);r=I*k+J*l+K*m+(I*u+J*t+K*s);s=L*k+M*l+N*m+(L*u+M*t+N*s);t=+g[h+68>>2];u=+g[h+84>>2];v=+g[h+100>>2];w=+g[h+72>>2];x=+g[h+88>>2];y=+g[h+104>>2];z=+g[h+76>>2];A=+g[h+92>>2];B=+g[h+108>>2];n=+g[h+116>>2];o=+g[h+120>>2];E=+g[h+124>>2];C=F*k+G*l+H*m+(F*n+G*o+H*E);D=I*k+J*l+K*m+(I*n+J*o+K*E);E=L*k+M*l+N*m+(L*n+M*o+N*E);f=c[f+192>>2]|0;if(((c[f+4>>2]|0)+-21|0)>>>0>=9){X=1.0;i=W;return +X}g[W+224>>2]=q;g[W+224+4>>2]=r;g[W+224+8>>2]=s;g[W+224+12>>2]=0.0;if(C>2]=C;j=C}else j=q;if(D>2]=D;k=D}else k=r;if(E>2]=E;l=E}else l=s;g[W+208>>2]=q;g[W+208+4>>2]=r;g[W+208+8>>2]=s;g[W+208+12>>2]=0.0;if(q>2]=C;m=C}else m=q;if(r>2]=D;n=D}else n=r;if(s>2]=E;o=E}else o=s;Y=+g[h+248>>2];g[W+224>>2]=j-Y;g[W+224+4>>2]=k-Y;g[W+224+8>>2]=l-Y;g[W+208>>2]=Y+m;g[W+208+4>>2]=Y+n;g[W+208+8>>2]=Y+o;c[W>>2]=5556;g[W+4>>2]=F*O+G*P+H*Q;g[W+8>>2]=F*R+G*S+H*T;g[W+12>>2]=F*U+G*V+H*p;g[W+16>>2]=0.0;g[W+20>>2]=I*O+J*P+K*Q;g[W+24>>2]=I*R+J*S+K*T;g[W+28>>2]=I*U+J*V+K*p;g[W+32>>2]=0.0;g[W+36>>2]=L*O+M*P+N*Q;g[W+40>>2]=L*R+M*S+N*T;g[W+44>>2]=L*U+M*V+N*p;g[W+48>>2]=0.0;g[W+52>>2]=q;g[W+56>>2]=r;g[W+60>>2]=s;g[W+64>>2]=0.0;g[W+68>>2]=F*t+G*u+H*v;g[W+72>>2]=F*w+G*x+H*y;g[W+76>>2]=F*z+G*A+H*B;g[W+80>>2]=0.0;g[W+84>>2]=I*t+J*u+K*v;g[W+88>>2]=I*w+J*x+K*y;g[W+92>>2]=I*z+J*A+K*B;g[W+96>>2]=0.0;g[W+100>>2]=L*t+M*u+N*v;g[W+104>>2]=L*w+M*x+N*y;g[W+108>>2]=L*z+M*A+N*B;g[W+112>>2]=0.0;g[W+116>>2]=C;g[W+120>>2]=D;g[W+124>>2]=E;g[W+128>>2]=0.0;g[W+196>>2]=Y;c[W+200>>2]=c[h+244>>2];if(f|0?(mc[c[(c[f>>2]|0)+64>>2]&127](f,W,W+224|0,W+208|0),X=+g[W+200>>2],X<+g[h+244>>2]):0){g[h+244>>2]=X;Y=X;i=W;return +Y}Y=1.0;i=W;return +Y}function te(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;m=0;do{k=m;m=m+1|0;l=(m|0)==3;j=c[b+((l?0:m)<<2)>>2]|0;k=c[b+(((k+2|0)%3|0)<<2)>>2]|0;e=c[d>>2]|0;f=c[d+4>>2]|0;do if((e|0)==(k|0)&(f|0)==(j|0)){e=2;n=3}else{if(!((e|0)==(j|0)&(f|0)==(k|0))){g=c[d+8>>2]|0;if((f|0)==(k|0)&(g|0)==(j|0)){e=0;n=3;break}if(!((f|0)==(j|0)&(g|0)==(k|0))){if(!((g|0)!=(k|0)|(e|0)==(j|0)^1)){e=1;n=3;break}if((g|0)!=(j|0)|(e|0)==(k|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=d+12+(e<<2)|0}while(0);if((n|0)==3){n=0;e=d+12+(e<<2)|0}i=c[e>>2]|0;e=c[b>>2]|0;f=c[b+4>>2]|0;do if((e|0)==(j|0)&(f|0)==(k|0)){e=2;n=11}else{if(!((e|0)==(k|0)&(f|0)==(j|0))){g=c[b+8>>2]|0;if((f|0)==(j|0)&(g|0)==(k|0)){e=0;n=11;break}if(!((f|0)==(k|0)&(g|0)==(j|0))){if(!((g|0)!=(j|0)|(e|0)==(k|0)^1)){e=1;n=11;break}if((g|0)!=(k|0)|(e|0)==(j|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=b+12+(e<<2)|0}while(0);if((n|0)==11){n=0;e=b+12+(e<<2)|0}h=c[a+(c[e>>2]<<2)>>2]|0;e=c[h>>2]|0;f=c[h+4>>2]|0;do if((e|0)==(k|0)&(f|0)==(j|0)){e=2;n=19}else{if(!((e|0)==(j|0)&(f|0)==(k|0))){g=c[h+8>>2]|0;if((f|0)==(k|0)&(g|0)==(j|0)){e=0;n=19;break}if(!((f|0)==(j|0)&(g|0)==(k|0))){if(!((g|0)!=(k|0)|(e|0)==(j|0)^1)){e=1;n=19;break}if((g|0)!=(j|0)|(e|0)==(k|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=h+12+(e<<2)|0}while(0);if((n|0)==19){n=0;e=h+12+(e<<2)|0}c[e>>2]=i;e=c[b>>2]|0;f=c[b+4>>2]|0;do if((e|0)==(j|0)&(f|0)==(k|0)){e=2;n=27}else{if(!((e|0)==(k|0)&(f|0)==(j|0))){g=c[b+8>>2]|0;if((f|0)==(j|0)&(g|0)==(k|0)){e=0;n=27;break}if(!((f|0)==(k|0)&(g|0)==(j|0))){if(!((g|0)!=(j|0)|(e|0)==(k|0)^1)){e=1;n=27;break}if((g|0)!=(k|0)|(e|0)==(j|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=b+12+(e<<2)|0}while(0);if((n|0)==27){n=0;e=b+12+(e<<2)|0}i=c[e>>2]|0;e=c[d>>2]|0;f=c[d+4>>2]|0;do if((e|0)==(k|0)&(f|0)==(j|0)){e=2;n=35}else{if(!((e|0)==(j|0)&(f|0)==(k|0))){g=c[d+8>>2]|0;if((f|0)==(k|0)&(g|0)==(j|0)){e=0;n=35;break}if(!((f|0)==(j|0)&(g|0)==(k|0))){if(!((g|0)!=(k|0)|(e|0)==(j|0)^1)){e=1;n=35;break}if((g|0)!=(j|0)|(e|0)==(k|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=d+12+(e<<2)|0}while(0);if((n|0)==35){n=0;e=d+12+(e<<2)|0}h=c[a+(c[e>>2]<<2)>>2]|0;e=c[h>>2]|0;f=c[h+4>>2]|0;do if((e|0)==(j|0)&(f|0)==(k|0)){e=2;n=43}else{if(!((e|0)==(k|0)&(f|0)==(j|0))){g=c[h+8>>2]|0;if((f|0)==(j|0)&(g|0)==(k|0)){e=0;n=43;break}if(!((f|0)==(k|0)&(g|0)==(j|0))){if(!((g|0)!=(j|0)|(e|0)==(k|0)^1)){e=1;n=43;break}if((g|0)!=(k|0)|(e|0)==(j|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=h+12+(e<<2)|0}while(0);if((n|0)==43){n=0;e=h+12+(e<<2)|0}c[e>>2]=i}while(!l);return}function ue(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;l=c[b>>2]|0;m=c[b+4>>2]|0;i=c[b+8>>2]|0;n=c[a+4>>2]|0;p=Uh(a,d,m,i)|0;c[p+12>>2]=c[b+12>>2];c[p+16>>2]=n+1;c[p+20>>2]=n+2;h=c[(c[a+12>>2]|0)+(c[b+12>>2]<<2)>>2]|0;e=c[h>>2]|0;f=c[h+4>>2]|0;do if((e|0)==(m|0)&(f|0)==(i|0)){e=2;o=2}else{if(!((e|0)==(i|0)&(f|0)==(m|0))){g=c[h+8>>2]|0;if((f|0)==(m|0)&(g|0)==(i|0)){e=0;o=2;break}if(!((f|0)==(i|0)&(g|0)==(m|0))){if(!((g|0)!=(m|0)|(e|0)==(i|0)^1)){e=1;o=2;break}if((g|0)!=(i|0)|(e|0)==(m|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=h+12+(e<<2)|0}while(0);if((o|0)==2)e=h+12+(e<<2)|0;c[e>>2]=n;k=Uh(a,d,i,l)|0;c[k+12>>2]=c[b+12+4>>2];c[k+16>>2]=n+2;c[k+20>>2]=n;h=c[(c[a+12>>2]|0)+(c[b+12+4>>2]<<2)>>2]|0;e=c[h>>2]|0;f=c[h+4>>2]|0;do if((e|0)==(i|0)&(f|0)==(l|0)){e=2;o=10}else{if(!((e|0)==(l|0)&(f|0)==(i|0))){g=c[h+8>>2]|0;if((f|0)==(i|0)&(g|0)==(l|0)){e=0;o=10;break}if(!((f|0)==(l|0)&(g|0)==(i|0))){if(!((g|0)!=(i|0)|(e|0)==(l|0)^1)){e=1;o=10;break}if((g|0)!=(l|0)|(e|0)==(i|0)^1){e=9432;break}else e=1}else e=0}else e=2;e=h+12+(e<<2)|0}while(0);if((o|0)==10)e=h+12+(e<<2)|0;c[e>>2]=n+1;j=Uh(a,d,l,m)|0;c[j+12>>2]=c[b+12+8>>2];c[j+16>>2]=n;c[j+20>>2]=n+1;e=c[a+12>>2]|0;i=c[e+(c[b+12+8>>2]<<2)>>2]|0;f=c[i>>2]|0;g=c[i+4>>2]|0;do if((f|0)==(l|0)&(g|0)==(m|0)){f=2;o=18}else{if(!((f|0)==(m|0)&(g|0)==(l|0))){h=c[i+8>>2]|0;if((g|0)==(l|0)&(h|0)==(m|0)){f=0;o=18;break}if(!((g|0)==(m|0)&(h|0)==(l|0))){if(!((h|0)!=(l|0)|(f|0)==(m|0)^1)){f=1;o=18;break}if((h|0)!=(m|0)|(f|0)==(l|0)^1){f=9432;break}else f=1}else f=0}else f=2;f=i+12+(f<<2)|0}while(0);if((o|0)==18)f=i+12+(f<<2)|0;c[f>>2]=n+2;f=c[e+(c[p+12>>2]<<2)>>2]|0;if(!(((c[f>>2]|0)!=(d|0)?(c[f+4>>2]|0)!=(d|0):0)?(c[f+8>>2]|0)!=(d|0):0)){te(c[a+12>>2]|0,p,f);c[(c[a+12>>2]|0)+(c[p+24>>2]<<2)>>2]=0;c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0);c[(c[a+12>>2]|0)+(c[f+24>>2]<<2)>>2]=0;if(f|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}e=c[a+12>>2]|0}f=c[e+(c[k+12>>2]<<2)>>2]|0;if(!(((c[f>>2]|0)!=(d|0)?(c[f+4>>2]|0)!=(d|0):0)?(c[f+8>>2]|0)!=(d|0):0)){te(c[a+12>>2]|0,k,f);c[(c[a+12>>2]|0)+(c[k+24>>2]<<2)>>2]=0;c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0);c[(c[a+12>>2]|0)+(c[f+24>>2]<<2)>>2]=0;if(f|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}e=c[a+12>>2]|0}f=c[e+(c[j+12>>2]<<2)>>2]|0;if(!(((c[f>>2]|0)!=(d|0)?(c[f+4>>2]|0)!=(d|0):0)?(c[f+8>>2]|0)!=(d|0):0)){te(c[a+12>>2]|0,j,f);c[(c[a+12>>2]|0)+(c[j+24>>2]<<2)>>2]=0;c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);c[(c[a+12>>2]|0)+(c[f+24>>2]<<2)>>2]=0;if(f|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}e=c[a+12>>2]|0}c[e+(c[b+24>>2]<<2)>>2]=0;if(!b)return;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function ve(b){b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0.0,x=0.0,y=0;v=i;i=i+176|0;if(!(a[b+527>>0]|0)){i=v;return}g[b+36>>2]=0.0;g[b+520>>2]=0.0;g[b+516>>2]=0.0;c[b+576>>2]=0;c[b+576+4>>2]=0;c[b+576+8>>2]=0;c[b+576+12>>2]=0;if(!(a[b+524>>0]|0)){d=c[b+28>>2]|0;k=+g[b+348>>2];l=+g[b+352>>2];r=+g[b+356>>2];t=k*+g[d+20>>2]+l*+g[d+24>>2]+r*+g[d+28>>2]+ +g[d+56>>2];j=c[b+32>>2]|0;m=+g[b+412>>2];n=+g[b+416>>2];s=+g[b+420>>2];o=+g[j+52>>2];e=+g[j+56>>2];u=m*+g[j+20>>2]+n*+g[j+24>>2]+s*+g[j+28>>2]+e;p=m*+g[j+36>>2]+n*+g[j+40>>2]+s*+g[j+44>>2]+ +g[j+60>>2];q=k*+g[d+4>>2]+l*+g[d+8>>2]+r*+g[d+12>>2]+ +g[d+52>>2];r=k*+g[d+36>>2]+l*+g[d+40>>2]+r*+g[d+44>>2]+ +g[d+60>>2];s=m*+g[j+4>>2]+n*+g[j+8>>2]+s*+g[j+12>>2]+o;if((s-q)*(s-q)+(u-t)*(u-t)+(p-r)*(p-r)>1.1920928955078125e-07){h=1.0/+O(+((s-q)*(s-q)+(u-t)*(u-t)+(p-r)*(p-r)));g[v+128>>2]=(s-q)*h;g[v+128+4>>2]=(u-t)*h;g[v+128+8>>2]=(p-r)*h;c[v+128+12>>2]=0;k=(p-r)*h;f=(u-t)*h;h=(s-q)*h}else{c[v+128>>2]=1065353216;c[v+128+4>>2]=0;c[v+128+8>>2]=0;g[v+128+12>>2]=0.0;k=0.0;f=0.0;h=1.0}if(+N(+k)>.7071067690849304){x=k*k+f*f;w=1.0/+O(+x);m=-(w*k);k=w*f;n=-(k*h);l=h*m;f=x*w;h=k;k=0.0}else{m=h*h+f*f;l=1.0/+O(+m);x=-(f*l);f=l*h;n=k*x;l=m*l;m=f;f=-(f*k);h=0.0;k=x}g[v+128+16>>2]=k;g[v+128+20>>2]=m;g[v+128+24>>2]=h;g[v+128+32>>2]=f;g[v+128+36>>2]=n;g[v+128+40>>2]=l;f=o;d=0;while(1){y=c[b+28>>2]|0;c[v+80>>2]=c[y+4>>2];c[v+80+4>>2]=c[y+20>>2];c[v+80+8>>2]=c[y+36>>2];g[v+80+12>>2]=0.0;c[v+80+16>>2]=c[y+8>>2];c[v+80+20>>2]=c[y+24>>2];c[v+80+24>>2]=c[y+40>>2];g[v+80+28>>2]=0.0;c[v+80+32>>2]=c[y+12>>2];c[v+80+36>>2]=c[y+28>>2];c[v+80+40>>2]=c[y+44>>2];g[v+80+44>>2]=0.0;c[v+32>>2]=c[j+4>>2];c[v+32+4>>2]=c[j+20>>2];c[v+32+8>>2]=c[j+36>>2];g[v+32+12>>2]=0.0;c[v+32+16>>2]=c[j+8>>2];c[v+32+20>>2]=c[j+24>>2];c[v+32+24>>2]=c[j+40>>2];g[v+32+28>>2]=0.0;c[v+32+32>>2]=c[j+12>>2];c[v+32+36>>2]=c[j+28>>2];c[v+32+40>>2]=c[j+44>>2];g[v+32+44>>2]=0.0;w=t-+g[y+56>>2];x=r-+g[y+60>>2];g[v+16>>2]=q-+g[y+52>>2];g[v+16+4>>2]=w;g[v+16+8>>2]=x;g[v+16+12>>2]=0.0;x=p-+g[j+60>>2];g[v>>2]=s-f;g[v+4>>2]=u-e;g[v+8>>2]=x;g[v+12>>2]=0.0;y=c[b+28>>2]|0;j=c[b+32>>2]|0;Rg(b+48+(d*84|0)|0,v+80|0,v+32|0,v+16|0,v,v+128+(d<<4)|0,y+396|0,+g[y+344>>2],j+396|0,+g[j+344>>2]);d=d+1|0;if((d|0)==3)break;y=c[b+32>>2]|0;j=y;f=+g[y+52>>2];e=+g[y+56>>2]}d=b+32|0}else d=b+32|0;j=c[b+28>>2]|0;y=c[d>>2]|0;Fc(b,j+4|0,y+4|0,j+264|0,y+264|0);i=v;return}function we(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(!((d|0)!=0&(e|0)!=0))return;if((c[b+24>>2]|0)<128?(c[b+28>>2]|0)<128:0){c[6435]=(c[6435]|0)+1;h=yc(1043)|0;if(!h)j=0;else{c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}h=c[b+24>>2]|0;if((h|0)>0){i=0;do{l=(c[b+32>>2]|0)+(i<<3)|0;m=c[l+4>>2]|0;n=j+(i<<3)|0;c[n>>2]=c[l>>2];c[n+4>>2]=m;i=i+1|0}while((i|0)!=(h|0))}h=c[b+32>>2]|0;if(h|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=j;c[b+28>>2]=128}c[b+24>>2]=128;n=c[b+32>>2]|0;c[n>>2]=d;c[n+4>>2]=e;n=1;j=124;while(1){h=n+-1|0;i=c[b+32>>2]|0;l=c[i+(h<<3)>>2]|0;m=c[i+(h<<3)+4>>2]|0;if((h|0)>(j|0)){e=c[b+24>>2]|0;if((e|0)<(e<<1|0)?(c[b+28>>2]|0)<(e<<1|0):0){if(e){c[6435]=(c[6435]|0)+1;i=yc((e<<4|3)+16|0)|0;if(!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n<<3)>>2]=c[l+40>>2];c[h+(n<<3)+4>>2]=o;h=n+2|0;o=c[b+32>>2]|0;k=c[m+40>>2]|0;c[o+(p<<3)>>2]=c[l+36>>2];c[o+(p<<3)+4>>2]=k;p=c[b+32>>2]|0;o=c[m+40>>2]|0;c[p+(h<<3)>>2]=c[l+40>>2];c[p+(h<<3)+4>>2]=o;h=n+3|0;break}else{c[e>>2]=k;c[i+(h<<3)+4>>2]=m;h=c[b+32>>2]|0;c[h+(n<<3)>>2]=c[l+40>>2];c[h+(n<<3)+4>>2]=m;h=n+1|0;break}}}while(0);if(!h)break;else n=h}return}function xe(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+80|0;c[a+68>>2]=(c[a+68>>2]|0)+1;e=c[a+64>>2]|0;if(e|0){f=c[(c[a+24>>2]|0)+(b*80|0)+76>>2]|0;hh(e,f)|0;d=c[e+4>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[e+4>>2]=f;c[e+12>>2]=(c[e+12>>2]|0)+-1}f=(c[a+16>>2]|0)+-1|0;e=c[a+24>>2]|0;c[g>>2]=c[e+(b*80|0)>>2];c[g+4>>2]=c[e+(b*80|0)+4>>2];c[g+8>>2]=c[e+(b*80|0)+8>>2];c[g+12>>2]=c[e+(b*80|0)+12>>2];c[g+16>>2]=c[e+(b*80|0)+16>>2];c[g+16+4>>2]=c[e+(b*80|0)+16+4>>2];c[g+16+8>>2]=c[e+(b*80|0)+16+8>>2];c[g+16+12>>2]=c[e+(b*80|0)+16+12>>2];c[g+32>>2]=c[e+(b*80|0)+32>>2];c[g+32+4>>2]=c[e+(b*80|0)+32+4>>2];c[g+32+8>>2]=c[e+(b*80|0)+32+8>>2];c[g+32+12>>2]=c[e+(b*80|0)+32+12>>2];c[g+48>>2]=c[e+(b*80|0)+48>>2];c[g+48+4>>2]=c[e+(b*80|0)+48+4>>2];c[g+48+8>>2]=c[e+(b*80|0)+48+8>>2];c[g+48+12>>2]=c[e+(b*80|0)+48+12>>2];c[g+64>>2]=c[e+(b*80|0)+64>>2];c[g+64+4>>2]=c[e+(b*80|0)+64+4>>2];c[g+64+8>>2]=c[e+(b*80|0)+64+8>>2];c[g+64+12>>2]=c[e+(b*80|0)+64+12>>2];c[e+(b*80|0)>>2]=c[e+(f*80|0)>>2];c[e+(b*80|0)+4>>2]=c[e+(f*80|0)+4>>2];c[e+(b*80|0)+8>>2]=c[e+(f*80|0)+8>>2];c[e+(b*80|0)+12>>2]=c[e+(f*80|0)+12>>2];c[e+(b*80|0)+16>>2]=c[e+(f*80|0)+16>>2];c[e+(b*80|0)+16+4>>2]=c[e+(f*80|0)+16+4>>2];c[e+(b*80|0)+16+8>>2]=c[e+(f*80|0)+16+8>>2];c[e+(b*80|0)+16+12>>2]=c[e+(f*80|0)+16+12>>2];c[e+(b*80|0)+32>>2]=c[e+(f*80|0)+32>>2];c[e+(b*80|0)+32+4>>2]=c[e+(f*80|0)+32+4>>2];c[e+(b*80|0)+32+8>>2]=c[e+(f*80|0)+32+8>>2];c[e+(b*80|0)+32+12>>2]=c[e+(f*80|0)+32+12>>2];c[e+(b*80|0)+48>>2]=c[e+(f*80|0)+48>>2];c[e+(b*80|0)+48+4>>2]=c[e+(f*80|0)+48+4>>2];c[e+(b*80|0)+48+8>>2]=c[e+(f*80|0)+48+8>>2];c[e+(b*80|0)+48+12>>2]=c[e+(f*80|0)+48+12>>2];c[e+(b*80|0)+64>>2]=c[e+(f*80|0)+64>>2];c[e+(b*80|0)+64+4>>2]=c[e+(f*80|0)+64+4>>2];c[e+(b*80|0)+64+8>>2]=c[e+(f*80|0)+64+8>>2];c[e+(b*80|0)+64+12>>2]=c[e+(f*80|0)+64+12>>2];e=c[a+24>>2]|0;c[e+(f*80|0)>>2]=c[g>>2];c[e+(f*80|0)+4>>2]=c[g+4>>2];c[e+(f*80|0)+8>>2]=c[g+8>>2];c[e+(f*80|0)+12>>2]=c[g+12>>2];c[e+(f*80|0)+16>>2]=c[g+16>>2];c[e+(f*80|0)+16+4>>2]=c[g+16+4>>2];c[e+(f*80|0)+16+8>>2]=c[g+16+8>>2];c[e+(f*80|0)+16+12>>2]=c[g+16+12>>2];c[e+(f*80|0)+32>>2]=c[g+32>>2];c[e+(f*80|0)+32+4>>2]=c[g+32+4>>2];c[e+(f*80|0)+32+8>>2]=c[g+32+8>>2];c[e+(f*80|0)+32+12>>2]=c[g+32+12>>2];c[e+(f*80|0)+48>>2]=c[g+48>>2];c[e+(f*80|0)+48+4>>2]=c[g+48+4>>2];c[e+(f*80|0)+48+8>>2]=c[g+48+8>>2];c[e+(f*80|0)+48+12>>2]=c[g+48+12>>2];c[e+(f*80|0)+64>>2]=c[g+64>>2];c[e+(f*80|0)+64+4>>2]=c[g+64+4>>2];c[e+(f*80|0)+64+8>>2]=c[g+64+8>>2];c[e+(f*80|0)+64+12>>2]=c[g+64+12>>2];if(!(c[a+64>>2]|0)){b=c[a+16>>2]|0;b=b+-1|0;c[a+16>>2]=b;i=g;return}c[(c[(c[a+24>>2]|0)+(b*80|0)+76>>2]|0)+36>>2]=b;b=c[a+16>>2]|0;b=b+-1|0;c[a+16>>2]=b;i=g;return}function ye(b,d,e,f,h,j){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=i;i=i+80|0;if((h|0)>0){k=0;b=0;do{r=c[f+(k<<2)>>2]|0;b=(r|0)>(b|0)?r:b;k=k+1|0}while((k|0)<(h*3|0))}else b=0;p=b+1|0;l=_(p,p)|0;if(!l)r=0;else{c[6435]=(c[6435]|0)+1;k=yc(l+19|0)|0;if(!k)k=0;else{c[(k+4+15&-16)+-4>>2]=k;k=k+4+15&-16}Qn(k|0,0,l|0)|0;r=k}if((b|0)>-1){if((p|0)!=0?(c[6435]=(c[6435]|0)+1,m=yc((p<<4|3)+16|0)|0,(m|0)!=0):0){c[(m+4+15&-16)+-4>>2]=m;l=m+4+15&-16}else l=0;b=0;do{q=l+(b<<4)|0;c[q>>2]=c[s>>2];c[q+4>>2]=c[s+4>>2];c[q+8>>2]=c[s+8>>2];c[q+12>>2]=c[s+12>>2];b=b+1|0}while((b|0)!=(p|0));b=0;k=0;while(1){o=c[e+(b+1<<2)>>2]|0;q=c[e+(b+2<<2)>>2]|0;c[l+(k<<4)>>2]=c[e+(b<<2)>>2];c[l+(k<<4)+4>>2]=o;c[l+(k<<4)+8>>2]=q;g[l+(k<<4)+12>>2]=0.0;b=b+3|0;if((b|0)>=(p*3|0))break;else k=k+1|0}}else l=0;c[6435]=(c[6435]|0)+1;b=yc(1271)|0;if(!b)q=0;else{c[(b+4+15&-16)+-4>>2]=b;q=b+4+15&-16}Kc(q,d,p,l,0);if((h|0)>0){o=0;do{e=c[f+(o<<2)>>2]|0;d=c[f+(o+1<<2)>>2]|0;n=c[f+(o+2<<2)>>2]|0;k=_(e,p)|0;b=r+(k+n)|0;if(!(a[b>>0]|0)){a[b>>0]=1;a[r+(e+(_(n,p)|0))>>0]=1;Rf(q,n,e,0,0)}m=_(d,p)|0;b=r+(m+e)|0;if(!(a[b>>0]|0)){a[b>>0]=1;a[r+(d+k)>>0]=1;Rf(q,e,d,0,0)}b=r+((_(n,p)|0)+d)|0;if(!(a[b>>0]|0)){a[b>>0]=1;a[r+(n+m)>>0]=1;Rf(q,d,n,0,0)}Zf(q,e,d,n,0);o=o+3|0}while((o|0)<(h*3|0))}if(j){k=c[q+732>>2]|0;if((k|0)>0){m=q+740|0;n=0;b=243703;do{e=c[m>>2]|0;d=e+(n*52|0)|0;b=(_(b,1664525)|0)+1013904223|0;o=s+16|0;p=d;f=o+52|0;do{c[o>>2]=c[p>>2];o=o+4|0;p=p+4|0}while((o|0)<(f|0));o=d;p=e+(((b>>>0)%(k>>>0)|0)*52|0)|0;f=o+52|0;do{c[o>>2]=c[p>>2];o=o+4|0;p=p+4|0}while((o|0)<(f|0));o=e+(((b>>>0)%(k>>>0)|0)*52|0)|0;p=s+16|0;f=o+52|0;do{c[o>>2]=c[p>>2];o=o+4|0;p=p+4|0}while((o|0)<(f|0));n=n+1|0}while((n|0)!=(k|0))}else b=243703;d=c[q+752>>2]|0;if((d|0)>0){e=q+760|0;n=0;do{m=c[e>>2]|0;k=m+(n*44|0)|0;b=(_(b,1664525)|0)+1013904223|0;m=m+(((b>>>0)%(d>>>0)|0)*44|0)|0;o=s+16|0;p=k;f=o+44|0;do{c[o>>2]=c[p>>2];o=o+4|0;p=p+4|0}while((o|0)<(f|0));o=k;p=m;f=o+44|0;do{c[o>>2]=c[p>>2];o=o+4|0;p=p+4|0}while((o|0)<(f|0));o=m;p=s+16|0;f=o+44|0;do{c[o>>2]=c[p>>2];o=o+4|0;p=p+4|0}while((o|0)<(f|0));n=n+1|0}while((n|0)!=(d|0))}}if(l|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}if(!r){i=s;return q|0}c[6436]=(c[6436]|0)+1;hd(c[r+-4>>2]|0);i=s;return q|0}function ze(a,d,f,h,j,k,l,m,n){a=a|0;d=d|0;f=f|0;h=+h;j=+j;k=+k;l=l|0;m=m|0;n=n|0;var o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0.0,I=0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0,U=0.0,V=0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0;V=i;i=i+32|0;H=+g[f>>2];Q=+g[f+4>>2];S=+g[f+8>>2];J=1.0/+O(+((h-H)*(h-H)+(j-Q)*(j-Q)+(k-S)*(k-S)));N=(h-H)*J==0.0?999999984306749440.0:1.0/((h-H)*J);P=(j-Q)*J==0.0?999999984306749440.0:1.0/((j-Q)*J);R=(k-S)*J==0.0?999999984306749440.0:1.0/((k-S)*J);ea=(H>h?h:H)+ +g[l>>2];ca=(Q>j?j:Q)+ +g[l+4>>2];da=(S>k?k:S)+ +g[l+8>>2];aa=(H>2];t=(Q>2];Y=(S>2];$=+g[a+4>>2];ea=ea<$?$:ea;u=+g[a+8>>2];ca=ca>2];da=da>2];s=+g[a+24>>2];Z=+g[a+28>>2];_=+g[a+36>>2];v=+g[a+40>>2];W=+g[a+44>>2];T=~~(((ba0){p=0;q=c[a+136>>2]|0;o=0;do{o=o+1|0;r=q+6|0;w=b[q>>1]|0;x=q+10|0;y=b[q+4>>1]|0;z=q+8|0;A=b[q+2>>1]|0;B=q+12|0;C=(c[B>>2]|0)>-1;do if(((I&65535)>=(w&65535)?(T&65535)<=(e[r>>1]|0):0)&(E&65535)<=(e[x>>1]|0)&(D&65535)>=(y&65535)&(G&65535)<=(e[z>>1]|0)&(F&65535)>=(A&65535)){aa=+g[a+36>>2];ca=+g[a+40>>2];ea=+g[a+44>>2];ba=+g[a+4>>2];da=+g[a+8>>2];u=+g[a+12>>2];g[V+12>>2]=0.0;v=+(e[r>>1]|0)/aa+ba;s=+(e[z>>1]|0)/ca+da;t=+(e[x>>1]|0)/ea+u;g[V+28>>2]=0.0;g[V>>2]=+(w&65535)/aa+ba-+g[m>>2];g[V+4>>2]=+(A&65535)/ca+da-+g[m+4>>2];g[V+8>>2]=+(y&65535)/ea+u-+g[m+8>>2];g[V+16>>2]=v-+g[l>>2];g[V+20>>2]=s-+g[l+4>>2];g[V+24>>2]=t-+g[l+8>>2];t=+g[f>>2];s=N*(+g[V+((N<0.0&1)<<4)>>2]-t);t=N*(+g[V+((N<0.0^1)<<4)>>2]-t);v=+g[f+4>>2];u=P*(+g[V+((P<0.0&1)<<4)+4>>2]-v);v=P*(+g[V+((P<0.0^1)<<4)+4>>2]-v);if(!(u>t|s>v)?(K=u>s?u:s,U=v>2],L=R*(+g[V+((R<0.0&1)<<4)+8>>2]-M),M=R*(+g[V+((R<0.0^1)<<4)+8>>2]-M),!(L>U|K>M)):0){r=(M0.0?(L>K?L:K)<(k-S)*(k-S)*J+((h-H)*(h-H)*J+(j-Q)*(j-Q)*J):0;if(!(C&r)){w=9;break}w=c[B>>2]|0;ic[c[(c[d>>2]|0)+8>>2]&127](d,w>>21,w&2097151);w=10;break}r=0;w=9}else{r=0;w=9}while(0);if((w|0)==9){w=0;if(C|r)w=10;else{C=c[B>>2]|0;p=p-C|0;q=q+(0-C<<4)|0}}if((w|0)==10){p=p+1|0;q=q+16|0}}while((p|0)<(n|0))}else o=0;if((c[6167]|0)>=(o|0)){i=V;return}c[6167]=o;i=V;return}function Ae(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0;Tg(a,b+(c*284|0)|0,d);m=+g[b+(c*284|0)+52>>2];h=+g[b+(c*284|0)+56>>2];q=+g[b+(c*284|0)+60>>2];G=+g[b+(c*284|0)+76>>2];x=+g[b+(c*284|0)+72>>2];z=+g[b+(c*284|0)+68>>2];w=1.0/+O(+((x*-m-z*-h)*(x*-m-z*-h)+((G*-h-x*-q)*(G*-h-x*-q)+(z*-q-G*-m)*(z*-q-G*-m))));v=(G*-h-x*-q)*w;u=w*(z*-q-G*-m);w=w*(x*-m-z*-h);e=+g[b+(c*284|0)+232>>2]*.5;k=+R(+e)/+O(+(m*m+h*h+q*q));e=+Q(+e);l=2.0/(e*e+(k*-q*k*-q+(k*-m*k*-m+k*-h*k*-h)));E=1.0-(k*-h*k*-h*l+k*-q*k*-q*l);D=k*-m*k*-h*l-e*k*-q*l;F=k*-m*k*-q*l+e*k*-h*l;B=k*-m*k*-h*l+e*k*-q*l;A=1.0-(k*-m*k*-m*l+k*-q*k*-q*l);C=k*-h*k*-q*l-e*k*-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+u*(l*k+(j*i+e*f)));g[b+(c*284|0)+132>>2]=(j*t+e*s+l*r)*-q+((l*p+(e*o+j*n))*-m+(l*k+(j*i+e*f))*-h);g[b+(c*284|0)+136>>2]=0.0;h=+g[b+(c*284|0)+32>>2];f=h*+g[b+(c*284|0)+56>>2]+ +g[b+(c*284|0)+40>>2];e=h*+g[b+(c*284|0)+60>>2]+ +g[b+(c*284|0)+44>>2];g[b+(c*284|0)+140>>2]=+g[b+(c*284|0)+52>>2]*h+ +g[b+(c*284|0)+36>>2];g[b+(c*284|0)+144>>2]=f;g[b+(c*284|0)+148>>2]=e;g[b+(c*284|0)+152>>2]=0.0;return}function Be(b,d,e,f,h,j,k,l,m){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=+j;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0.0;D=i;i=i+32|0;if(!d){i=D;return}q=c[b+44>>2]|0;if((q|0)<128){if((c[b+48>>2]|0)<128){c[6435]=(c[6435]|0)+1;n=yc(531)|0;if(!n)p=0;else{c[(n+4+15&-16)+-4>>2]=n;p=n+4+15&-16}n=c[b+44>>2]|0;if((n|0)>0){o=0;do{c[p+(o<<2)>>2]=c[(c[b+52>>2]|0)+(o<<2)>>2];o=o+1|0}while((o|0)!=(n|0))}n=c[b+52>>2]|0;if(n|0){if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}c[b+52>>2]=0}a[b+56>>0]=1;c[b+52>>2]=p;c[b+48>>2]=128;o=b+52|0}else o=b+52|0;n=q;do{c[(c[o>>2]|0)+(n<<2)>>2]=0;n=n+1|0}while((n|0)!=128);y=b+48|0}else{o=b+52|0;y=b+48|0}c[b+44>>2]=128;c[c[o>>2]>>2]=d;x=1;n=126;while(1){p=x+-1|0;q=c[o>>2]|0;w=c[q+(p<<2)>>2]|0;t=+g[w+4>>2]-+g[l+4>>2];r=+g[w+8>>2]-+g[l+8>>2];g[D>>2]=+g[w>>2]-+g[l>>2];g[D+4>>2]=t;g[D+8>>2]=r;g[D+12>>2]=0.0;r=+g[w+20>>2]-+g[k+4>>2];t=+g[w+24>>2]-+g[k+8>>2];g[D+16>>2]=+g[w+16>>2]-+g[k>>2];g[D+20>>2]=r;g[D+24>>2]=t;g[D+28>>2]=0.0;v=c[h>>2]|0;t=+g[e>>2];r=+g[f>>2];s=(+g[D+(v<<4)>>2]-t)*r;t=r*(+g[D+(1-v<<4)>>2]-t);v=c[h+4>>2]|0;r=+g[e+4>>2];E=+g[f+4>>2];u=(+g[D+(v<<4)+4>>2]-r)*E;r=E*(+g[D+(1-v<<4)+4>>2]-r);do if((!(u>t|s>r)?(z=u>s?u:s,C=r>2]|0,B=+g[e+8>>2],E=+g[f+8>>2],A=(+g[D+(v<<4)+8>>2]-B)*E,B=E*(+g[D+(1-v<<4)+8>>2]-B),!(A>C|z>B)):0)?((B0.0?(A>z?A:z)>2]|0)){Cb[c[(c[m>>2]|0)+12>>2]&127](m,w);break}if((p|0)>(n|0)){v=c[b+44>>2]|0;if((v|0)<(v<<1|0)){if((c[y>>2]|0)<(v<<1|0)){if(v){c[6435]=(c[6435]|0)+1;n=yc((v<<3|3)+16|0)|0;if(!n)n=0;else{c[(n+4+15&-16)+-4>>2]=n;n=n+4+15&-16}q=c[b+44>>2]|0;if((q|0)>0){d=0;do{c[n+(d<<2)>>2]=c[(c[o>>2]|0)+(d<<2)>>2];d=d+1|0}while((d|0)!=(q|0))}}else n=0;q=c[o>>2]|0;if(q|0){if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}c[o>>2]=0}a[b+56>>0]=1;c[o>>2]=n;c[y>>2]=v<<1;q=v}else{n=q;q=v}do{c[n+(q<<2)>>2]=0;q=q+1|0;n=c[o>>2]|0}while((q|0)!=(v<<1|0))}else n=q;c[b+44>>2]=v<<1;q=n;n=(v<<1)+-2|0}c[q+(p<<2)>>2]=c[w+36>>2];c[(c[o>>2]|0)+(x<<2)>>2]=c[w+40>>2];p=x+1|0}while(0);if(!p)break;else x=p}i=D;return}function Ce(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0.0;D=i;i=i+32|0;q=+g[d>>2];j=(g[k>>2]=q,c[k>>2]|0);t=q<999999984306749440.0?j:1566444395;p=+g[d+4>>2];m=(g[k>>2]=p,c[k>>2]|0);u=p<999999984306749440.0?m:1566444395;E=+g[d+8>>2];o=(g[k>>2]=E,c[k>>2]|0);w=E<999999984306749440.0?o:1566444395;s=+g[d+12>>2];y=s<0.0?s:0.0;j=q>-999999984306749440.0?j:-581039253;m=p>-999999984306749440.0?m:-581039253;o=E>-999999984306749440.0?o:-581039253;s=s>0.0?s:0.0;E=+g[d+16>>2];B=E<(c[k>>2]=t,+g[k>>2]);h=(g[k>>2]=E,c[k>>2]|0);t=B?h:t;p=+g[d+20>>2];B=p<(c[k>>2]=u,+g[k>>2]);l=(g[k>>2]=p,c[k>>2]|0);u=B?l:u;q=+g[d+24>>2];B=q<(c[k>>2]=w,+g[k>>2]);n=(g[k>>2]=q,c[k>>2]|0);w=B?n:w;r=+g[d+28>>2];y=r>2]=j,+g[k>>2])>2]=m,+g[k>>2])>2]=o,+g[k>>2])>2];B=E<(c[k>>2]=t,+g[k>>2]);h=(g[k>>2]=E,c[k>>2]|0);B=B?h:t;q=+g[d+36>>2];A=q<(c[k>>2]=u,+g[k>>2]);j=(g[k>>2]=q,c[k>>2]|0);A=A?j:u;r=+g[d+40>>2];z=r<(c[k>>2]=w,+g[k>>2]);l=(g[k>>2]=r,c[k>>2]|0);z=z?l:w;p=+g[d+44>>2];y=p>2]=x,+g[k>>2])>2]=v,+g[k>>2])>2]=m,+g[k>>2])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4>>2];n=+g[d+8>>2];j=+g[e>>2];k=+g[e+4>>2];h=+g[e+8>>2];if(!(a[b+228>>0]|0)){z=+g[b+100>>2];w=+g[b+116>>2];C=+g[b+132>>2];y=+g[b+104>>2];u=+g[b+120>>2];B=+g[b+136>>2];x=+g[b+108>>2];s=+g[b+124>>2];A=+g[b+140>>2];F=-+g[b+148>>2];E=-+g[b+152>>2];D=-+g[b+156>>2];J=+g[b+164>>2];I=+g[b+168>>2];r=+g[b+172>>2];H=+g[b+180>>2];G=+g[b+184>>2];q=+g[b+188>>2];v=+g[b+196>>2];t=+g[b+200>>2];p=+g[b+204>>2];r=h*(C*J+B*I+A*r)+(j*(z*J+y*I+x*r)+k*(w*J+u*I+s*r))+(J*(z*F+w*E+C*D)+(y*F+u*E+B*D)*I+(x*F+s*E+A*D)*r+ +g[b+212>>2]);q=h*(C*H+B*G+A*q)+(j*(z*H+y*G+x*q)+k*(w*H+u*G+s*q))+((z*F+w*E+C*D)*H+(y*F+u*E+B*D)*G+(x*F+s*E+A*D)*q+ +g[b+216>>2]);p=(z*F+w*E+C*D)*v+(y*F+u*E+B*D)*t+(x*F+s*E+A*D)*p+ +g[b+220>>2]+(h*(C*v+B*t+A*p)+(j*(z*v+y*t+x*p)+k*(w*v+u*t+s*p)));g[o>>2]=r;g[o+4>>2]=q;g[o+8>>2]=p;f=(l*f+j-r)*+g[d>>2]+(m*f+k-q)*+g[d+4>>2]+(n*f+h-p)*+g[d+8>>2];e=o+12|0;g[e>>2]=0.0;b=b+32|0;b=c[b>>2]|0;e=c[b>>2]|0;e=e+16|0;e=c[e>>2]|0;hc[e&15](b,d,o,f);i=o;return}else{z=+g[b+36>>2];C=+g[b+52>>2];w=+g[b+68>>2];A=+g[b+40>>2];E=+g[b+56>>2];x=+g[b+72>>2];B=+g[b+44>>2];G=+g[b+60>>2];y=+g[b+76>>2];t=-+g[b+84>>2];u=-+g[b+88>>2];v=-+g[b+92>>2];p=+g[b+164>>2];q=+g[b+168>>2];H=+g[b+172>>2];r=+g[b+180>>2];s=+g[b+184>>2];I=+g[b+188>>2];D=+g[b+196>>2];F=+g[b+200>>2];J=+g[b+204>>2];H=(n*f+h)*(w*p+x*q+y*H)+((l*f+j)*(z*p+A*q+B*H)+(m*f+k)*(C*p+E*q+G*H))+(p*(z*t+C*u+w*v)+(A*t+E*u+x*v)*q+(B*t+G*u+y*v)*H+ +g[b+212>>2]);I=(n*f+h)*(w*r+x*s+y*I)+((l*f+j)*(z*r+A*s+B*I)+(m*f+k)*(C*r+E*s+G*I))+((z*t+C*u+w*v)*r+(A*t+E*u+x*v)*s+(B*t+G*u+y*v)*I+ +g[b+216>>2]);J=(z*t+C*u+w*v)*D+(A*t+E*u+x*v)*F+(B*t+G*u+y*v)*J+ +g[b+220>>2]+((n*f+h)*(w*D+x*F+y*J)+((l*f+j)*(z*D+A*F+B*J)+(m*f+k)*(C*D+E*F+G*J)));g[o>>2]=H+l*(l*(H-j)+m*(I-k)+n*(J-h));g[o+4>>2]=I+m*(l*(H-j)+m*(I-k)+n*(J-h));g[o+8>>2]=J+n*(l*(H-j)+m*(I-k)+n*(J-h));J=l*(H-j)+m*(I-k)+n*(J-h);e=o+12|0;g[e>>2]=0.0;b=b+32|0;b=c[b>>2]|0;e=c[b>>2]|0;e=e+16|0;e=c[e>>2]|0;hc[e&15](b,d,o,J);i=o;return}}function Ee(b,d,e,f,h,i,j,k,l,m){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0;if((j|0)<2|(k|0)<2){m=0;return m|0}r=_(k,j)|0;c[6435]=(c[6435]|0)+1;b=yc(r>>>0>268435455?18:(r<<4|3)+16|0)|0;if(!b)q=0;else{c[(b+4+15&-16)+-4>>2]=b;q=b+4+15&-16}n=r>>>0>1073741823?-1:r<<2;n=(n|0)==0?1:n;while(1){p=yc(n)|0;if(p|0)break;b=c[6564]|0;c[6564]=b+0;if(!b){o=8;break}jc[b&3]()}if((o|0)==8){m=Ya(4)|0;c[m>>2]=9640;pb(m|0,2800,251)}if((k|0)>0?(j|0)>0:0){o=0;do{y=+(o|0)/+(k+-1|0);s=+g[e>>2];s=s+y*(+g[h>>2]-s);t=+g[e+4>>2];t=t+y*(+g[h+4>>2]-t);u=+g[e+8>>2];u=u+y*(+g[h+8>>2]-u);v=+g[f>>2];w=+g[f+4>>2];x=+g[f+8>>2];b=_(o,j)|0;v=v+y*(+g[i>>2]-v)-s;w=w+y*(+g[i+4>>2]-w)-t;x=x+y*(+g[i+8>>2]-x)-u;n=0;do{y=+(n|0)/+(j+-1|0);z=n+b|0;g[q+(z<<4)>>2]=s+v*y;g[q+(z<<4)+4>>2]=t+w*y;g[q+(z<<4)+8>>2]=u+x*y;g[q+(z<<4)+12>>2]=0.0;g[p+(z<<2)>>2]=1.0;n=n+1|0}while((n|0)!=(j|0));o=o+1|0}while((o|0)!=(k|0))}c[6435]=(c[6435]|0)+1;b=yc(1271)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}Kc(b,d,r,q,p);if(l&1|0){g[(c[b+720>>2]|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&2|0){g[(c[b+720>>2]|0)+((j+-1|0)*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&4|0){z=_(k+-1|0,j)|0;g[(c[b+720>>2]|0)+(z*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(l&8|0){z=j+-1+(_(k+-1|0,j)|0)|0;g[(c[b+720>>2]|0)+(z*104|0)+88>>2]=0.0;a[b+924>>0]=1}if(q|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}hd(p);if((k|0)<=0){z=b;return z|0}q=0;while(1){a:do if((j|0)>0){r=_(q,j)|0;n=q+1|0;o=_(n,j)|0;if((n|0)<(k|0))h=0;else{o=0;while(1){p=o;o=o+1|0;if((o|0)<(j|0))Rf(b,p+r|0,o+r|0,0,0);if((o|0)==(j|0))break a}}do{p=h+r|0;i=h;h=h+1|0;do if((h|0)<(j|0)){e=h+r|0;Rf(b,p,e,0,0);Rf(b,p,i+o|0,0,0);if(!(i+q&1)){Zf(b,i+o|0,p,e,0);Zf(b,i+o|0,e,h+o|0,0);if(!m)break;Rf(b,e,i+o|0,0,0);break}else{f=h+o|0;Zf(b,p,e,f,0);Zf(b,p,f,i+o|0,0);if(!m)break;Rf(b,p,f,0,0);break}}else Rf(b,p,i+o|0,0,0);while(0)}while((h|0)!=(j|0))}else n=q+1|0;while(0);if((n|0)==(k|0))break;else q=n}return b|0}function Fe(b,d){b=b|0;d=+d;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+16|0;o=c[b+452>>2]|0;ic[c[(c[o>>2]|0)+16>>2]&127](o,b+324|0,0);o=c[b+452>>2]|0;Eb[c[(c[o>>2]|0)+12>>2]&127](o)|0;ad(b,d);li(11792);o=c[b+328>>2]|0;if((o|0)>0){e=c[b+336>>2]|0;f=0;l=0;do{n=c[(c[e+(f<<2)>>2]|0)+384>>2]|0;l=(l|0)>(n|0)?l:n;f=f+1|0}while((f|0)!=(o|0));f=0;while(1){e=c[e+(f<<2)>>2]|0;if((c[e+852>>2]|0)>0){h=0;do{n=c[(c[e+860>>2]|0)+(h<<2)>>2]|0;Jb[c[(c[n>>2]|0)+8>>2]&15](n,+g[e+452>>2],l);h=h+1|0}while((h|0)<(c[e+852>>2]|0))}f=f+1|0;if((f|0)==(o|0))break;e=c[b+336>>2]|0}if((l|0)>0){j=0;do{k=0;do{e=c[(c[b+336>>2]|0)+(k<<2)>>2]|0;f=c[e+852>>2]|0;if((f|0)>0){h=0;do{n=c[(c[e+860>>2]|0)+(h<<2)>>2]|0;Nb[c[(c[n>>2]|0)+12>>2]&7](n,+g[e+452>>2],1.0);h=h+1|0}while((h|0)!=(f|0))}k=k+1|0}while((k|0)!=(o|0));j=j+1|0}while((j|0)!=(l|0));n=0}else n=0;do{m=c[(c[b+336>>2]|0)+(n<<2)>>2]|0;if((c[m+852>>2]|0)>0){h=0;do{e=c[(c[m+860>>2]|0)+(h<<2)>>2]|0;zb[c[(c[e>>2]|0)+16>>2]&31](e,+g[m+452>>2]);e=c[m+860>>2]|0;f=c[e+(h<<2)>>2]|0;a:do if(a[f+152>>0]|0){if(!f)l=e;else{c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);l=c[m+860>>2]|0}e=h+-1|0;f=c[m+852>>2]|0;if((f|0)>0){k=c[l+(h<<2)>>2]|0;h=0;while(1){j=l+(h<<2)|0;if((c[j>>2]|0)==(k|0))break;h=h+1|0;if((h|0)>=(f|0))break a}if((h|0)<(f|0)){c[j>>2]=c[l+(f+-1<<2)>>2];c[(c[m+860>>2]|0)+(f+-1<<2)>>2]=k;c[m+852>>2]=f+-1;f=f+-1|0}}}else{f=c[m+852>>2]|0;e=h}while(0);h=e+1|0}while((h|0)<(f|0))}n=n+1|0}while((n|0)!=(o|0))}e=c[b+452>>2]|0;zb[c[(c[e>>2]|0)+28>>2]&31](e,+g[e+12>>2]*d);e=c[2357]|0;o=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=o;do if(!o){if(c[e+4>>2]|0){tb(p|0,0)|0;o=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[p+4>>2]|0)-(c[o+4>>2]|0)+(((c[p>>2]|0)-(c[o>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(c[e+16>>2]|0)break;e=c[2357]|0}c[2357]=c[e+20>>2]}while(0);if((c[b+328>>2]|0)<=0){b=c[b+452>>2]|0;o=c[b>>2]|0;o=o+32|0;o=c[o>>2]|0;Ab[o&255](b);i=p;return}e=0;do{o=c[(c[b+336>>2]|0)+(e<<2)>>2]|0;bi(o,o);e=e+1|0}while((e|0)<(c[b+328>>2]|0));b=c[b+452>>2]|0;o=c[b>>2]|0;o=o+32|0;o=c[o>>2]|0;Ab[o&255](b);i=p;return}function Ge(b){b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+64|0;li(14295);d=c[b+8>>2]|0;if((d|0)>0){o=0;do{n=c[(c[b+16>>2]|0)+(o<<2)>>2]|0;if(!(a[b+76>>0]|0))switch(c[n+216>>2]|0){case 2:case 5:break;default:q=11}else q=11;if((q|0)==11){q=0;d=c[n+192>>2]|0;mc[c[(c[d>>2]|0)+8>>2]&127](d,n+4|0,r+48|0,r+32|0);e=+g[r+48>>2]+-.019999999552965164;g[r+48>>2]=e;f=+g[r+48+4>>2]+-.019999999552965164;g[r+48+4>>2]=f;h=+g[r+48+8>>2]+-.019999999552965164;g[r+48+8>>2]=h;j=+g[r+32>>2]+.019999999552965164;g[r+32>>2]=j;k=+g[r+32+4>>2]+.019999999552965164;g[r+32+4>>2]=k;l=+g[r+32+8>>2]+.019999999552965164;g[r+32+8>>2]=l;if(((a[b+44>>0]|0)!=0?(c[n+236>>2]|0)==2:0)?(c[n+204>>2]&3|0)==0:0){d=c[n+192>>2]|0;mc[c[(c[d>>2]|0)+8>>2]&127](d,n+68|0,r+16|0,r);f=+g[r+16>>2]+-.019999999552965164;g[r+16>>2]=f;h=+g[r+16+4>>2]+-.019999999552965164;g[r+16+4>>2]=h;j=+g[r+16+8>>2]+-.019999999552965164;g[r+16+8>>2]=j;k=+g[r>>2]+.019999999552965164;g[r>>2]=k;l=+g[r+4>>2]+.019999999552965164;g[r+4>>2]=l;m=+g[r+8>>2]+.019999999552965164;g[r+8>>2]=m;e=+g[r+48>>2];if(f>2]=f;e=f}f=+g[r+48+4>>2];if(h>2]=h;f=h}h=+g[r+48+8>>2];if(j>2]=j;h=j}j=+g[r+16+12>>2];if(j<+g[r+48+12>>2])g[r+48+12>>2]=j;j=+g[r+32>>2];if(j>2]=k;j=k}k=+g[r+32+4>>2];if(k>2]=l;k=l}l=+g[r+32+8>>2];if(l>2]=m;l=m}m=+g[r+12>>2];if(+g[r+32+12>>2]>2]=m}d=c[b+68>>2]|0;if((c[n+204>>2]&1|0)==0?(j=j-e,k=k-f,m=l-h,!(j*j+k*k+m*m<999999995904.0)):0){if((c[n+216>>2]&-2|0)!=4)c[n+216>>2]=5;if(a[14307]|0?(p=c[b+72>>2]|0,p|0):0){a[14307]=0;Cb[c[(c[p>>2]|0)+36>>2]&127](p,14308);n=c[b+72>>2]|0;Cb[c[(c[n>>2]|0)+36>>2]&127](n,14357);n=c[b+72>>2]|0;Cb[c[(c[n>>2]|0)+36>>2]&127](n,14425);n=c[b+72>>2]|0;Cb[c[(c[n>>2]|0)+36>>2]&127](n,14490)}}else yb[c[(c[d>>2]|0)+16>>2]&31](d,c[n+188>>2]|0,r+48|0,r+32|0,c[b+24>>2]|0);d=c[b+8>>2]|0}o=o+1|0}while((o|0)<(d|0))}d=c[2357]|0;q=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=q;if(q|0){i=r;return}do if(c[d+4>>2]|0){tb(r+48|0,0)|0;q=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[r+48+4>>2]|0)-(c[q+4>>2]|0)+(((c[r+48>>2]|0)-(c[q>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=r;return}}while(0);c[2357]=c[d+20>>2];i=r;return}function He(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0,j=0,k=0.0;a=i;i=i+192|0;switch(c[b+388>>2]&15|0){case 1:{c[a+160>>2]=3364;h=c[d+8>>2]|0;h=(c[h+236>>2]&2|0)==0?0:h;j=c[d+12>>2]|0;k=+g[j+48>>2];e=+g[j+52>>2];f=+g[j+56>>2];f=+O(+((k-k)*(k-k)+(e-e)*(e-e)+(f-f)*(f-f)));j=c[b+192>>2]|0;e=+Sb[c[(c[j>>2]|0)+48>>2]&15](j);j=c[d+4>>2]|0;mc[c[(c[j>>2]|0)+8>>2]&127](j,c[d+12>>2]|0,a+144|0,a+128|0);c[a+32>>2]=c[a+144>>2];c[a+32+4>>2]=c[a+144+4>>2];c[a+32+8>>2]=c[a+144+8>>2];c[a+32+12>>2]=c[a+144+12>>2];c[a+32+16>>2]=c[a+128>>2];c[a+32+16+4>>2]=c[a+128+4>>2];c[a+32+16+8>>2]=c[a+128+8>>2];c[a+32+16+12>>2]=c[a+128+12>>2];c[a+96>>2]=c[a+32>>2];c[a+96+4>>2]=c[a+32+4>>2];c[a+96+8>>2]=c[a+32+8>>2];c[a+96+12>>2]=c[a+32+12>>2];c[a+96+16>>2]=c[a+32+16>>2];c[a+96+20>>2]=c[a+32+20>>2];c[a+96+24>>2]=c[a+32+24>>2];c[a+96+28>>2]=c[a+32+28>>2];g[a+96>>2]=+g[a+96>>2]-e;g[a+96+4>>2]=+g[a+96+4>>2]-e;g[a+96+8>>2]=+g[a+96+8>>2]-e;g[a+96+16>>2]=e+ +g[a+96+16>>2];g[a+96+20>>2]=e+ +g[a+96+20>>2];g[a+96+24>>2]=e+ +g[a+96+24>>2];c[a+160+4>>2]=b;c[a+160+8>>2]=d;c[a+160+12>>2]=h;g[a+160+16>>2]=f+e;g[a+160+20>>2]=e;bg(c[b+928>>2]|0,a+96|0,a+160|0);i=a;return}case 2:{g[a+4>>2]=1.0;c[a+8>>2]=0;c[a+8+4>>2]=0;c[a+8+8>>2]=0;c[a+8+12>>2]=0;c[a>>2]=3400;c[a+24>>2]=b;c[a+28>>2]=d;c[a+8>>2]=c[b+456>>2];j=c[d+4>>2]|0;k=+Sb[c[(c[j>>2]|0)+48>>2]&15](j);j=c[b+192>>2]|0;k=k+ +Sb[c[(c[j>>2]|0)+48>>2]&15](j);g[a+12>>2]=k;f=+g[(c[d+8>>2]|0)+224>>2];g[a+160>>2]=f;c[a+16>>2]=c[(+g[b+316>>2]>2];j=c[d+4>>2]|0;mc[c[(c[j>>2]|0)+8>>2]&127](j,c[d+12>>2]|0,a+144|0,a+128|0);c[a+64>>2]=c[a+144>>2];c[a+64+4>>2]=c[a+144+4>>2];c[a+64+8>>2]=c[a+144+8>>2];c[a+64+12>>2]=c[a+144+12>>2];c[a+64+16>>2]=c[a+128>>2];c[a+64+16+4>>2]=c[a+128+4>>2];c[a+64+16+8>>2]=c[a+128+8>>2];c[a+64+16+12>>2]=c[a+128+12>>2];c[a+96>>2]=c[a+64>>2];c[a+96+4>>2]=c[a+64+4>>2];c[a+96+8>>2]=c[a+64+8>>2];c[a+96+12>>2]=c[a+64+12>>2];c[a+96+16>>2]=c[a+64+16>>2];c[a+96+20>>2]=c[a+64+20>>2];c[a+96+24>>2]=c[a+64+24>>2];c[a+96+28>>2]=c[a+64+28>>2];g[a+96>>2]=+g[a+96>>2]-k;g[a+96+4>>2]=+g[a+96+4>>2]-k;g[a+96+8>>2]=+g[a+96+8>>2]-k;g[a+96+16>>2]=k+ +g[a+96+16>>2];g[a+96+20>>2]=k+ +g[a+96+20>>2];g[a+96+24>>2]=k+ +g[a+96+24>>2];bg(c[b+1048>>2]|0,a+96|0,a);i=a;return}default:{i=a;return}}}function Ie(a,b,d){a=a|0;b=b|0;d=d|0;var f=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+80|0;o=c[a+4>>2]|0;Yb[c[(c[o>>2]|0)+16>>2]&3](o,r+28|0,r+24|0,r+20|0,r+16|0,r+12|0,r+8|0,r+4|0,r,b);o=(c[r+12>>2]|0)+(_(c[r+8>>2]|0,d)|0)|0;q=c[a+4>>2]|0;p=(c[r+20>>2]|0)==0;n=c[r+28>>2]|0;if((c[r>>2]|0)==3){m=c[r+16>>2]|0;l=n+(_(m,e[o+4>>1]|0)|0)|0;if(p){j=+g[l+8>>2]*+g[q+12>>2];k=+g[l+4>>2]*+g[q+8>>2];f=+g[l>>2]*+g[q+4>>2]}else{j=+h[l+16>>3]*+g[q+12>>2];k=+h[l+8>>3]*+g[q+8>>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+g[q+12>>2];k=+h[l+8>>3]*+g[q+8>>2];f=+h[l>>3]*+g[q+4>>2]}g[r+32+16>>2]=f;g[r+32+20>>2]=k;g[r+32+24>>2]=j;g[r+32+28>>2]=0.0;l=n+(_(m,c[o>>2]|0)|0)|0;if(p){j=+g[l+8>>2]*+g[q+12>>2];k=+g[l+4>>2]*+g[q+8>>2];f=+g[l>>2]*+g[q+4>>2]}else{j=+h[l+16>>3]*+g[q+12>>2];k=+h[l+8>>3]*+g[q+8>>2];f=+h[l>>3]*+g[q+4>>2]}g[r+32>>2]=f;g[r+32+4>>2]=k;g[r+32+8>>2]=j;g[r+32+12>>2]=0.0;q=a+8|0;q=c[q>>2]|0;p=c[q>>2]|0;p=p+8|0;p=c[p>>2]|0;mc[p&127](q,r+32|0,b,d);a=c[a+4>>2]|0;d=c[a>>2]|0;d=d+24|0;d=c[d>>2]|0;Cb[d&127](a,b);i=r;return}}function Je(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0,J=0;c[6435]=(c[6435]|0)+1;f=yc(1147)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}Il();c[f+4>>2]=7;c[f+8>>2]=-1;c[f+12>>2]=-1;g[f+16>>2]=3402823466385288598117041.0e14;a[f+20>>0]=1;a[f+21>>0]=0;c[f+24>>2]=-1;i=f+28|0;c[i>>2]=23268;h=f+32|0;c[h>>2]=b;g[f+36>>2]=0.0;g[f+40>>2]=.30000001192092896;c[f+44>>2]=0;c[f>>2]=4596;a[f+48>>0]=0;J=f+116|0;c[J>>2]=c[d>>2];c[J+4>>2]=c[d+4>>2];c[J+8>>2]=c[d+8>>2];c[J+12>>2]=c[d+12>>2];I=f+132|0;c[I>>2]=c[d+16>>2];c[I+4>>2]=c[d+16+4>>2];c[I+8>>2]=c[d+16+8>>2];c[I+12>>2]=c[d+16+12>>2];H=f+148|0;c[H>>2]=c[d+32>>2];c[H+4>>2]=c[d+32+4>>2];c[H+8>>2]=c[d+32+8>>2];c[H+12>>2]=c[d+32+12>>2];G=f+164|0;c[G>>2]=c[d+48>>2];c[G+4>>2]=c[d+48+4>>2];c[G+8>>2]=c[d+48+8>>2];c[G+12>>2]=c[d+48+12>>2];a[f+180>>0]=e&1;x=+g[J>>2];D=+g[b+4>>2];w=+g[I>>2];C=+g[b+8>>2];v=+g[H>>2];B=+g[b+12>>2];u=+g[f+120>>2];t=+g[f+136>>2];s=+g[f+152>>2];r=+g[f+124>>2];p=+g[f+140>>2];n=+g[f+156>>2];A=+g[b+20>>2];z=+g[b+24>>2];y=+g[b+28>>2];q=+g[b+36>>2];o=+g[b+40>>2];m=+g[b+44>>2];F=+g[G>>2];E=+g[f+168>>2];j=+g[f+172>>2];l=+g[b+52>>2]+(D*F+C*E+B*j);k=A*F+z*E+y*j+ +g[b+56>>2];j=q*F+o*E+m*j+ +g[b+60>>2];g[f+52>>2]=x*D+w*C+v*B;g[f+56>>2]=D*u+C*t+B*s;g[f+60>>2]=D*r+C*p+B*n;g[f+64>>2]=0.0;g[f+68>>2]=x*A+w*z+v*y;g[f+72>>2]=u*A+t*z+s*y;g[f+76>>2]=r*A+p*z+n*y;g[f+80>>2]=0.0;g[f+84>>2]=x*q+w*o+v*m;g[f+88>>2]=u*q+t*o+s*m;g[f+92>>2]=r*q+p*o+n*m;g[f+96>>2]=0.0;g[f+100>>2]=l;g[f+104>>2]=k;g[f+108>>2]=j;g[f+112>>2]=0.0;g[f+184>>2]=1.0;g[f+188>>2]=-1.0;g[f+192>>2]=0.0;g[f+196>>2]=0.0;g[f+200>>2]=1.0;g[f+204>>2]=.699999988079071;g[f+208>>2]=0.0;g[f+212>>2]=0.0;g[f+216>>2]=1.0;g[f+220>>2]=.699999988079071;g[f+224>>2]=0.0;g[f+228>>2]=0.0;g[f+264>>2]=1.0;g[f+268>>2]=.699999988079071;g[f+272>>2]=1.0;g[f+276>>2]=0.0;g[f+280>>2]=1.0;g[f+284>>2]=.699999988079071;g[f+288>>2]=1.0;g[f+292>>2]=0.0;g[f+232>>2]=1.0;g[f+236>>2]=.699999988079071;g[f+240>>2]=1.0;g[f+244>>2]=0.0;g[f+248>>2]=1.0;g[f+252>>2]=.699999988079071;g[f+256>>2]=1.0;g[f+260>>2]=0.0;a[f+1096>>0]=0;e=f+1100|0;g[f+1116>>2]=0.0;g[f+1120>>2]=0.0;g[f+1124>>2]=0.0;c[f+300>>2]=0;c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;a[e+12>>0]=0;a[f+49>>0]=1;kd(f,(c[i>>2]|0)+4|0,(c[h>>2]|0)+4|0);return f|0}function Ke(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0,G=0.0,H=0.0,I=0.0;d=i;i=i+96|0;l=+g[b>>2];s=+g[a+28>>2];B=+g[b+4>>2];D=+g[a+32>>2];m=+g[b+8>>2];n=+g[a+36>>2];o=+g[a+44>>2];p=+g[a+48>>2];q=+g[a+52>>2];r=+g[a+60>>2];t=+g[a+64>>2];u=+g[a+68>>2];v=+g[a+76>>2];w=+g[a+80>>2];x=+g[a+84>>2];g[d+80>>2]=l*s+B*D+m*n+v;g[d+80+4>>2]=l*o+B*p+m*q+w;g[d+80+8>>2]=l*r+B*t+m*u+x;g[d+80+12>>2]=0.0;y=+g[b+16>>2];z=+g[b+20>>2];A=+g[b+24>>2];g[d+64>>2]=y*s+z*D+A*n+v;g[d+64+4>>2]=y*o+z*p+A*q+w;g[d+64+8>>2]=y*r+z*t+A*u+x;g[d+64+12>>2]=0.0;C=+g[b+32>>2];E=+g[b+36>>2];k=+g[b+40>>2];g[d+48>>2]=C*s+E*D+k*n+v;g[d+48+4>>2]=C*o+E*p+k*q+w;g[d+48+8>>2]=C*r+E*t+k*u+x;g[d+48+12>>2]=0.0;f=(l*s+B*D+m*n+v+(y*s+z*D+A*n+v)+(C*s+E*D+k*n+v))*.3333333432674408;h=(l*o+B*p+m*q+w+(y*o+z*p+A*q+w)+(C*o+E*p+k*q+w))*.3333333432674408;j=(l*r+B*t+m*u+x+(y*r+z*t+A*u+x)+(C*r+E*t+k*u+x))*.3333333432674408;g[d+32>>2]=f;g[d+32+4>>2]=h;g[d+32+8>>2]=j;g[d+32+12>>2]=0.0;b=c[a+8>>2]|0;if(!((Eb[c[(c[b>>2]|0)+48>>2]&127](b)|0)&16384)){e=c[a+8>>2]|0;F=c[e>>2]|0;F=F+8|0;F=c[F>>2]|0;b=a+12|0;mc[F&127](e,d+80|0,d+64|0,b);e=c[a+8>>2]|0;F=c[e>>2]|0;F=F+8|0;F=c[F>>2]|0;mc[F&127](e,d+64|0,d+48|0,b);a=c[a+8>>2]|0;e=c[a>>2]|0;e=e+8|0;e=c[e>>2]|0;mc[e&127](a,d+48|0,d+80|0,b);i=d;return}I=+g[d+80>>2];H=y*o+z*p+A*q+w-(l*o+B*p+m*q+w);G=y*r+z*t+A*u+x-(l*r+B*t+m*u+x);w=C*o+E*p+k*q+w-(l*o+B*p+m*q+w);x=C*r+E*t+k*u+x-(l*r+B*t+m*u+x);B=G*(C*s+E*D+k*n+v-I)-(y*s+z*D+A*n+v-I)*x;E=(y*s+z*D+A*n+v-I)*w-H*(C*s+E*D+k*n+v-I);D=1.0/+O(+(E*E+((H*x-G*w)*(H*x-G*w)+B*B)));c[d+16>>2]=1065353216;c[d+16+4>>2]=1065353216;c[d+16+8>>2]=0;g[d+16+12>>2]=0.0;b=c[a+8>>2]|0;e=c[(c[b>>2]|0)+8>>2]|0;g[d>>2]=D*(H*x-G*w)+f;g[d+4>>2]=D*B+h;g[d+8>>2]=D*E+j;g[d+12>>2]=0.0;mc[e&127](b,d+32|0,d,d+16|0);b=c[a+8>>2]|0;e=c[b>>2]|0;e=e+8|0;e=c[e>>2]|0;F=a+12|0;mc[e&127](b,d+80|0,d+64|0,F);b=c[a+8>>2]|0;e=c[b>>2]|0;e=e+8|0;e=c[e>>2]|0;mc[e&127](b,d+64|0,d+48|0,F);a=c[a+8>>2]|0;b=c[a>>2]|0;b=b+8|0;b=c[b>>2]|0;mc[b&127](a,d+48|0,d+80|0,F);i=d;return}function Le(b,d,e,f,h,i){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;c[b+4>>2]=6;c[b+8>>2]=-1;c[b+12>>2]=-1;g[b+16>>2]=3402823466385288598117041.0e14;a[b+20>>0]=1;a[b+21>>0]=0;c[b+24>>2]=-1;c[b+28>>2]=d;c[b+32>>2]=e;g[b+36>>2]=0.0;g[b+40>>2]=.30000001192092896;c[b+44>>2]=0;c[b>>2]=4376;c[b+48>>2]=c[f>>2];c[b+48+4>>2]=c[f+4>>2];c[b+48+8>>2]=c[f+8>>2];c[b+48+12>>2]=c[f+12>>2];c[b+64>>2]=c[f+16>>2];c[b+64+4>>2]=c[f+16+4>>2];c[b+64+8>>2]=c[f+16+8>>2];c[b+64+12>>2]=c[f+16+12>>2];c[b+80>>2]=c[f+32>>2];c[b+80+4>>2]=c[f+32+4>>2];c[b+80+8>>2]=c[f+32+8>>2];c[b+80+12>>2]=c[f+32+12>>2];c[b+96>>2]=c[f+48>>2];c[b+96+4>>2]=c[f+48+4>>2];c[b+96+8>>2]=c[f+48+8>>2];c[b+96+12>>2]=c[f+48+12>>2];c[b+112>>2]=c[h>>2];c[b+112+4>>2]=c[h+4>>2];c[b+112+8>>2]=c[h+8>>2];c[b+112+12>>2]=c[h+12>>2];c[b+128>>2]=c[h+16>>2];c[b+128+4>>2]=c[h+16+4>>2];c[b+128+8>>2]=c[h+16+8>>2];c[b+128+12>>2]=c[h+16+12>>2];c[b+144>>2]=c[h+32>>2];c[b+144+4>>2]=c[h+32+4>>2];c[b+144+8>>2]=c[h+32+8>>2];c[b+144+12>>2]=c[h+32+12>>2];c[b+160>>2]=c[h+48>>2];c[b+160+4>>2]=c[h+48+4>>2];c[b+160+8>>2]=c[h+48+8>>2];c[b+160+12>>2]=c[h+48+12>>2];f=b+680|0;h=f+48|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(h|0));c[b+740>>2]=0;c[b+740+4>>2]=0;c[b+740+8>>2]=0;c[b+740+12>>2]=0;c[b+756>>2]=1045220557;c[b+760>>2]=1045220557;c[b+764>>2]=1045220557;c[b+768>>2]=0;c[b+768+4>>2]=0;c[b+768+8>>2]=0;c[b+768+12>>2]=0;c[b+768+16>>2]=0;g[b+728>>2]=.699999988079071;g[b+732>>2]=1.0;g[b+736>>2]=.5;a[b+788>>0]=0;g[b+792>>2]=0.0;g[b+808>>2]=0.0;a[b+789>>0]=0;g[b+796>>2]=0.0;g[b+812>>2]=0.0;a[b+790>>0]=0;g[b+800>>2]=0.0;g[b+816>>2]=0.0;g[b+928>>2]=0.0;g[b+876>>2]=0.0;g[b+880>>2]=.10000000149011612;g[b+884>>2]=300.0;g[b+868>>2]=1.0;g[b+872>>2]=-1.0;g[b+896>>2]=0.0;g[b+900>>2]=.20000000298023224;g[b+904>>2]=0.0;g[b+908>>2]=0.0;g[b+888>>2]=1.0;g[b+892>>2]=.5;c[b+924>>2]=0;g[b+916>>2]=0.0;a[b+912>>0]=0;g[b+992>>2]=0.0;g[b+940>>2]=0.0;g[b+944>>2]=.10000000149011612;g[b+948>>2]=300.0;g[b+932>>2]=1.0;g[b+936>>2]=-1.0;g[b+960>>2]=0.0;g[b+964>>2]=.20000000298023224;g[b+968>>2]=0.0;g[b+972>>2]=0.0;g[b+952>>2]=1.0;g[b+956>>2]=.5;c[b+988>>2]=0;g[b+980>>2]=0.0;a[b+976>>0]=0;g[b+1056>>2]=0.0;g[b+1004>>2]=0.0;g[b+1008>>2]=.10000000149011612;g[b+1012>>2]=300.0;g[b+996>>2]=1.0;g[b+1e3>>2]=-1.0;g[b+1024>>2]=0.0;g[b+1028>>2]=.20000000298023224;g[b+1032>>2]=0.0;g[b+1036>>2]=0.0;g[b+1016>>2]=1.0;g[b+1020>>2]=.5;c[b+1052>>2]=0;g[b+1044>>2]=0.0;a[b+1040>>0]=0;a[b+1300>>0]=i&1;a[b+1301>>0]=1;c[b+1304>>2]=0;a[b+1308>>0]=0;sd(b,(c[b+28>>2]|0)+4|0,(c[b+32>>2]|0)+4|0);return}function Me(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0;if(!b)b=0;else b=(c[b+236>>2]&2|0)==0?0:b;c[a+64>>2]=0;c[a+64+4>>2]=0;c[a+64+8>>2]=0;c[a+64+12>>2]=0;c[a+64+16>>2]=0;c[a+64+20>>2]=0;c[a+64+24>>2]=0;c[a+64+28>>2]=0;c[a+144>>2]=0;c[a+144+4>>2]=0;c[a+144+8>>2]=0;c[a+144+12>>2]=0;c[a+144+16>>2]=0;c[a+144+20>>2]=0;c[a+144+24>>2]=0;c[a+144+28>>2]=0;if(!b){c[a>>2]=1065353216;c[a+4>>2]=0;c[a+4+4>>2]=0;c[a+4+8>>2]=0;c[a+4+12>>2]=0;c[a+20>>2]=1065353216;c[a+24>>2]=0;c[a+24+4>>2]=0;c[a+24+8>>2]=0;c[a+24+12>>2]=0;c[a+40>>2]=1065353216;c[a+44>>2]=0;c[a+44+4>>2]=0;c[a+44+8>>2]=0;c[a+44+12>>2]=0;c[a+44+16>>2]=0;c[a+240>>2]=0;c[a+128>>2]=0;c[a+128+4>>2]=0;c[a+128+8>>2]=0;c[a+128+12>>2]=0;c[a+96>>2]=1065353216;c[a+100>>2]=1065353216;c[a+104>>2]=1065353216;g[a+108>>2]=0.0;c[a+112>>2]=1065353216;c[a+116>>2]=1065353216;c[a+120>>2]=1065353216;g[a+124>>2]=0.0;b=a+176|0;e=b+60|0;do{c[b>>2]=0;b=b+4|0}while((b|0)<(e|0));a=a+236|0;g[a>>2]=0.0;return}else{e=b+4|0;c[a>>2]=c[e>>2];c[a+4>>2]=c[e+4>>2];c[a+8>>2]=c[e+8>>2];c[a+12>>2]=c[e+12>>2];e=b+20|0;c[a+16>>2]=c[e>>2];c[a+16+4>>2]=c[e+4>>2];c[a+16+8>>2]=c[e+8>>2];c[a+16+12>>2]=c[e+12>>2];e=b+36|0;c[a+32>>2]=c[e>>2];c[a+32+4>>2]=c[e+4>>2];c[a+32+8>>2]=c[e+8>>2];c[a+32+12>>2]=c[e+12>>2];e=b+52|0;c[a+48>>2]=c[e>>2];c[a+48+4>>2]=c[e+4>>2];c[a+48+8>>2]=c[e+8>>2];c[a+48+12>>2]=c[e+12>>2];e=b+344|0;k=+g[e>>2];l=b+348|0;j=k*+g[b+352>>2];i=k*+g[b+356>>2];g[a+128>>2]=k*+g[l>>2];g[a+132>>2]=j;g[a+136>>2]=i;g[a+140>>2]=0.0;c[a+240>>2]=b;m=b+544|0;c[a+96>>2]=c[m>>2];c[a+96+4>>2]=c[m+4>>2];c[a+96+8>>2]=c[m+8>>2];c[a+96+12>>2]=c[m+12>>2];c[a+112>>2]=c[l>>2];c[a+112+4>>2]=c[l+4>>2];c[a+112+8>>2]=c[l+8>>2];c[a+112+12>>2]=c[l+12>>2];l=b+312|0;c[a+176>>2]=c[l>>2];c[a+176+4>>2]=c[l+4>>2];c[a+176+8>>2]=c[l+8>>2];c[a+176+12>>2]=c[l+12>>2];l=b+328|0;c[a+192>>2]=c[l>>2];c[a+192+4>>2]=c[l+4>>2];c[a+192+8>>2]=c[l+8>>2];c[a+192+12>>2]=c[l+12>>2];i=+g[e>>2];j=i*+g[b+416>>2]*d;k=i*+g[b+420>>2]*d;g[a+208>>2]=i*+g[b+412>>2]*d;g[a+212>>2]=j;g[a+216>>2]=k;g[a+220>>2]=0.0;k=+g[b+428>>2];j=+g[b+432>>2];i=+g[b+436>>2];h=(k*+g[b+268>>2]+j*+g[b+284>>2]+i*+g[b+300>>2])*d;f=(k*+g[b+272>>2]+j*+g[b+288>>2]+i*+g[b+304>>2])*d;g[a+224>>2]=(+g[b+264>>2]*k+ +g[b+280>>2]*j+ +g[b+296>>2]*i)*d;g[a+228>>2]=h;g[a+232>>2]=f;a=a+236|0;g[a>>2]=0.0;return}}function Ne(a,e,f){a=a|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;c[e+16>>2]=c[a+20>>2];c[e+20>>2]=c[a+24>>2];c[e+24>>2]=c[a+28>>2];c[e+28>>2]=c[a+32>>2];c[e>>2]=c[a+4>>2];c[e+4>>2]=c[a+8>>2];c[e+8>>2]=c[a+12>>2];c[e+12>>2]=c[a+16>>2];c[e+32>>2]=c[a+36>>2];c[e+36>>2]=c[a+40>>2];c[e+40>>2]=c[a+44>>2];c[e+44>>2]=c[a+48>>2];c[e+48>>2]=c[a+56>>2];c[e+52>>2]=d[a+60>>0];k=c[a+88>>2]|0;c[e+56>>2]=k;if(k){k=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[a+96>>2]|0)|0;c[e+64>>2]=k;if(k|0){h=c[a+88>>2]|0;k=Ob[c[(c[f>>2]|0)+16>>2]&63](f,48,h)|0;if((h|0)>0){g=c[a+96>>2]|0;i=0;j=c[k+8>>2]|0;while(1){c[j+16>>2]=c[g+(i<<6)+16>>2];c[j+20>>2]=c[g+(i<<6)+20>>2];c[j+24>>2]=c[g+(i<<6)+24>>2];c[j+28>>2]=c[g+(i<<6)+28>>2];c[j>>2]=c[g+(i<<6)>>2];c[j+4>>2]=c[g+(i<<6)+4>>2];c[j+8>>2]=c[g+(i<<6)+8>>2];c[j+12>>2]=c[g+(i<<6)+12>>2];c[j+32>>2]=c[g+(i<<6)+32>>2];c[j+36>>2]=c[g+(i<<6)+36>>2];c[j+40>>2]=c[g+(i<<6)+40>>2];i=i+1|0;if((i|0)==(h|0))break;else j=j+48|0}}else g=c[a+96>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,k,18461,1497453121,g)}}else c[e+64>>2]=0;k=c[a+128>>2]|0;c[e+60>>2]=k;if(k){k=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[a+136>>2]|0)|0;c[e+68>>2]=k;if(k|0){h=c[a+128>>2]|0;k=Ob[c[(c[f>>2]|0)+16>>2]&63](f,16,h)|0;if((h|0)>0){g=c[a+136>>2]|0;i=0;j=c[k+8>>2]|0;while(1){c[j+12>>2]=c[g+(i<<4)+12>>2];b[j+6>>1]=b[g+(i<<4)+6>>1]|0;b[j+8>>1]=b[g+(i<<4)+8>>1]|0;b[j+10>>1]=b[g+(i<<4)+10>>1]|0;b[j>>1]=b[g+(i<<4)>>1]|0;b[j+2>>1]=b[g+(i<<4)+2>>1]|0;b[j+4>>1]=b[g+(i<<4)+4>>1]|0;i=i+1|0;if((i|0)==(h|0))break;else j=j+16|0}}else g=c[a+136>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,k,18484,1497453121,g)}}else c[e+68>>2]=0;c[e+76>>2]=c[a+144>>2];k=c[a+152>>2]|0;c[e+80>>2]=k;if(!k){c[e+72>>2]=0;return 18528}k=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[a+160>>2]|0)|0;c[e+72>>2]=k;if(!k)return 18528;j=c[a+152>>2]|0;k=Ob[c[(c[f>>2]|0)+16>>2]&63](f,20,j)|0;if((j|0)>0){g=c[a+160>>2]|0;h=0;i=c[k+8>>2]|0;while(1){b[i+14>>1]=b[g+(h<<5)+6>>1]|0;b[i+16>>1]=b[g+(h<<5)+8>>1]|0;b[i+18>>1]=b[g+(h<<5)+10>>1]|0;b[i+8>>1]=b[g+(h<<5)>>1]|0;b[i+10>>1]=b[g+(h<<5)+2>>1]|0;b[i+12>>1]=b[g+(h<<5)+4>>1]|0;c[i>>2]=c[g+(h<<5)+12>>2];c[i+4>>2]=c[g+(h<<5)+16>>2];h=h+1|0;if((h|0)==(j|0))break;else i=i+20|0}}else g=c[a+160>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,k,18507,1497453121,g);return 18528}function Oe(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0,M=0;L=i;i=i+64|0;c[L+48>>2]=a;c[L+48+4>>2]=b;c[L+48+8>>2]=d;C=+g[a>>2];F=+g[b>>2];J=+g[a+4>>2];K=+g[b+4>>2];z=+g[a+8>>2];A=+g[b+8>>2];g[L>>2]=C-F;g[L+4>>2]=J-K;g[L+8>>2]=z-A;g[L+12>>2]=0.0;B=+g[d>>2];D=+g[d+4>>2];E=+g[d+8>>2];g[L+16>>2]=F-B;g[L+20>>2]=K-D;g[L+24>>2]=A-E;g[L+28>>2]=0.0;g[L+32>>2]=B-C;g[L+36>>2]=D-J;g[L+40>>2]=E-z;g[L+44>>2]=0.0;G=(J-K)*(A-E)-(z-A)*(K-D);H=(z-A)*(F-B)-(A-E)*(C-F);I=(K-D)*(C-F)-(J-K)*(F-B);if(I*I+(G*G+H*H)>0.0){o=J-K;p=z-A;q=C-F;v=C;w=J;x=z;m=0;y=-1.0;n=0;h=0;j=0}else{K=-1.0;i=L;return +K}while(1){if(v*(I*o-H*p)+w*(G*p-I*q)+(H*q-G*o)*x>0.0){u=c[4976+(m<<2)>>2]|0;M=c[L+48+(u<<2)>>2]|0;l=+g[M>>2];p=l-v;q=+g[M+4>>2];r=q-w;s=+g[M+8>>2];t=s-x;do if(p*p+r*r+t*t>0.0){o=-(v*p+w*r+x*t)/(p*p+r*r+t*t);if(o>=1.0){l=l*l+q*q+s*s;n=2;h=0;j=1065353216;break}if(!(o<=0.0)){j=(g[k>>2]=o,c[k>>2]|0);v=v+p*o;l=w+r*o;x=x+t*o;l=x*x+(v*v+l*l);n=3;h=(g[k>>2]=1.0-o,c[k>>2]|0);break}else{l=v*v+w*w+x*x;n=1;h=1065353216;j=0;break}}else l=-1.0;while(0);if(y<0.0|l>2]=(n&1|0?1<>2]=h;c[e+(u<<2)>>2]=j;g[e+(c[4976+(u<<2)>>2]<<2)>>2]=0.0}else l=y}else l=y;m=m+1|0;if((m|0)==3)break;M=c[L+48+(m<<2)>>2]|0;o=+g[L+(m<<4)+4>>2];p=+g[L+(m<<4)+8>>2];q=+g[L+(m<<4)>>2];v=+g[M>>2];w=+g[M+4>>2];x=+g[M+8>>2];y=l}if(!(l<0.0)){K=l;i=L;return +K}x=+O(+(I*I+(G*G+H*H)));y=(G*+g[a>>2]+H*+g[a+4>>2]+I*+g[a+8>>2])/(I*I+(G*G+H*H));c[f>>2]=7;v=+g[b>>2]-G*y;t=+g[b+4>>2]-H*y;w=+g[b+8>>2]-I*y;K=+O(+((t*(F-B)-v*(K-D))*(t*(F-B)-v*(K-D))+(((K-D)*w-t*(A-E))*((K-D)*w-t*(A-E))+(v*(A-E)-w*(F-B))*(v*(A-E)-w*(F-B)))))/x;g[e>>2]=K;A=+g[d>>2]-G*y;w=+g[d+4>>2]-H*y;F=+g[d+8>>2]-I*y;J=+O(+((w*(B-C)-A*(D-J))*(w*(B-C)-A*(D-J))+(((D-J)*F-w*(E-z))*((D-J)*F-w*(E-z))+(A*(E-z)-F*(B-C))*(A*(E-z)-F*(B-C)))))/x;g[e+4>>2]=J;g[e+8>>2]=1.0-(J+K);K=I*y*I*y+(G*y*G*y+H*y*H*y);i=L;return +K}function Pe(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0;d=i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,+g[k>>2])+n-n;g[d+16>>2]=m+p-p;g[d+16+4>>2]=q+o-o;g[d+16+8>>2]=n;g[d+16+12>>2]=0.0;n=+g[a+316>>2];o=n*(c[k>>2]=y,+g[k>>2]);q=+g[a+320>>2];o=o+q*(c[k>>2]=x,+g[k>>2]);p=+g[a+324>>2];o=o+p*(c[k>>2]=w,+g[k>>2]);m=n*(c[k>>2]=v,+g[k>>2]);m=m+q*(c[k>>2]=u,+g[k>>2]);m=m+p*(c[k>>2]=t,+g[k>>2]);n=n*(c[k>>2]=s,+g[k>>2]);q=n+q*(c[k>>2]=r,+g[k>>2]);n=+g[f+52>>2];l=+g[f+56>>2];j=+g[f+60>>2];j=q+p*(c[k>>2]=h,+g[k>>2])+j-j;g[d>>2]=o+n-n;g[d+4>>2]=m+l-l;g[d+8>>2]=j;g[d+12>>2]=0.0;h=c[a+28>>2]|0;f=c[a+32>>2]|0;Rg(a+48+(b*84|0)|0,d+80|0,d+32|0,d+16|0,d,d+128|0,h+396|0,+g[h+344>>2],f+396|0,+g[f+344>>2]);g[e>>2]=0.0;b=b+1|0}while((b|0)!=3);i=d;return}function Qe(a,b,d,e,f,h){a=a|0;b=b|0;d=+d;e=+e;f=+f;h=h|0;var i=0,j=0,k=0.0,l=0.0,m=0,n=0.0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0,y=0.0,z=0.0,A=0,B=0,C=0.0;a:while(1){B=c[h+12>>2]|0;if((b|0)>0){j=0;i=-1;do{do if(c[B+(j<<2)>>2]|0){if((i|0)!=-1?!(+g[a+(j<<4)>>2]*d+ +g[a+(j<<4)+4>>2]*e+ +g[a+(j<<4)+8>>2]*f>+g[a+(i<<4)>>2]*d+ +g[a+(i<<4)+4>>2]*e+ +g[a+(i<<4)+8>>2]*f):0)break;i=j}while(0);j=j+1|0}while((j|0)!=(b|0))}else i=-1;A=B+(i<<2)|0;if((c[A>>2]|0)==3){j=37;break}k=+O(+((e-f*0.0)*(e-f*0.0)+(f*0.0-d)*(f*0.0-d)+(d*0.0-e*0.0)*(d*0.0-e*0.0)));l=+O(+((d-e*0.0)*(d-e*0.0)+((e*0.0-f)*(e*0.0-f)+(f*0.0-d*0.0)*(f*0.0-d*0.0))));if(k>l){y=(e-f*0.0)*(1.0/k);z=(d*0.0-e*0.0)*(1.0/k);w=(f*0.0-d)*(1.0/k)}else{y=(e*0.0-f)*(1.0/l);z=(d-e*0.0)*(1.0/l);w=(f*0.0-d*0.0)*(1.0/l)}r=w*f-z*e;s=z*d-y*f;t=y*e-w*d;u=(i|0)==-1;j=-1;x=0;while(1){v=+(x|0);q=+R(+(v*.01745329238474369));n=+Q(+(v*.01745329238474369));k=(y*q+r*n)*.02500000037252903+d;l=(w*q+s*n)*.02500000037252903+e;n=(z*q+t*n)*.02500000037252903+f;if((b|0)>0){o=0;m=-1;do{do if(c[B+(o<<2)>>2]|0){if((m|0)!=-1?!(k*+g[a+(o<<4)>>2]+l*+g[a+(o<<4)+4>>2]+n*+g[a+(o<<4)+8>>2]>k*+g[a+(m<<4)>>2]+l*+g[a+(m<<4)+4>>2]+n*+g[a+(m<<4)+8>>2]):0)break;m=o}while(0);o=o+1|0}while((o|0)!=(b|0))}else m=-1;if((j|0)==(i|0)&(m|0)==(i|0)){j=20;break a}b:do if(!((j|0)==-1|(j|0)==(m|0))?v+-40.0<=v:0){if((b|0)>0)q=v+-40.0;else{k=v+-40.0;while(1){if((j|0)==(i|0)&u){i=-1;j=33;break a}k=k+5.0;if(!(k<=v))break b;else j=-1}}while(1){n=q*.01745329238474369;C=+R(+n);n=+Q(+n);k=(y*C+r*n)*.02500000037252903+d;l=(w*C+s*n)*.02500000037252903+e;n=(z*C+t*n)*.02500000037252903+f;p=0;o=-1;do{do if(c[B+(p<<2)>>2]|0){if((o|0)!=-1?!(k*+g[a+(p<<4)>>2]+l*+g[a+(p<<4)+4>>2]+n*+g[a+(p<<4)+8>>2]>k*+g[a+(o<<4)>>2]+l*+g[a+(o<<4)+4>>2]+n*+g[a+(o<<4)+8>>2]):0)break;o=p}while(0);p=p+1|0}while((p|0)!=(b|0));if((j|0)==(i|0)&(o|0)==(i|0)){j=33;break a}q=q+5.0;if(!(q<=v))break;else j=o}}while(0);x=x+45|0;if((x|0)>360)break;else j=m}c[A>>2]=0}if((j|0)==20){c[A>>2]=3;B=i;return B|0}else if((j|0)==33){c[B+(i<<2)>>2]=3;B=i;return B|0}else if((j|0)==37)return i|0;return 0}function Re(a,b,d,e,f,h,j,k){a=a|0;b=b|0;d=d|0;e=+e;f=+f;h=+h;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0.0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0;V=i;i=i+32|0;G=+g[d>>2];I=+g[d+4>>2];T=+g[d+8>>2];t=+g[j>>2];u=+g[j+4>>2];w=+g[j+8>>2];p=+g[k>>2];r=+g[k+4>>2];s=+g[k+8>>2];H=1.0/+O(+((e-G)*(e-G)+(f-I)*(f-I)+(h-T)*(h-T)));J=(e-G)*H==0.0?999999984306749440.0:1.0/((e-G)*H);K=(f-I)*H==0.0?999999984306749440.0:1.0/((f-I)*H);L=(h-T)*H==0.0?999999984306749440.0:1.0/((h-T)*H);M=(G>e?e:G)+t;N=(I>f?f:I)+u;P=(T>h?h:T)+w;Q=(G>2]|0;a:do if((m|0)>0){x=0;y=c[a+96>>2]|0;l=0;while(1){l=l+1|0;c[V>>2]=c[y>>2];c[V+4>>2]=c[y+4>>2];c[V+8>>2]=c[y+8>>2];c[V+12>>2]=c[y+12>>2];v=y+16|0;c[V+16>>2]=c[v>>2];c[V+16+4>>2]=c[v+4>>2];c[V+16+8>>2]=c[v+8>>2];c[V+16+12>>2]=c[v+12>>2];g[V>>2]=+g[V>>2]-p;g[V+4>>2]=+g[V+4>>2]-r;g[V+8>>2]=+g[V+8>>2]-s;g[V+16>>2]=+g[V+16>>2]-t;g[V+20>>2]=+g[V+20>>2]-u;g[V+24>>2]=+g[V+24>>2]-w;if(!(M>+g[v>>2])?!(Q<+g[y>>2]):0)n=1;else n=0;if(!(!(P>+g[y+24>>2])?!(S<+g[y+8>>2]):0))n=0;if(((!(N>+g[y+20>>2])?!(R<+g[y+4>>2]|n^1):0)?(A=+g[d>>2],z=J*(+g[V+((J<0.0&1)<<4)>>2]-A),A=J*(+g[V+((J<0.0^1)<<4)>>2]-A),C=+g[d+4>>2],B=K*(+g[V+((K<0.0&1)<<4)+4>>2]-C),C=K*(+g[V+((K<0.0^1)<<4)+4>>2]-C),!(B>A|z>C)):0)?(D=B>z?B:z,U=C>2],E=L*(+g[V+((L<0.0&1)<<4)+8>>2]-F),F=L*(+g[V+((L<0.0^1)<<4)+8>>2]-F),!(E>U|D>F)):0){n=(F0.0?(E>D?E:D)<(h-T)*(h-T)*H+((e-G)*(e-G)*H+(f-I)*(f-I)*H):0;o=c[y+32>>2]|0;if(n&(o|0)==-1){ic[c[(c[b>>2]|0)+8>>2]&127](b,c[y+36>>2]|0,c[y+40>>2]|0);m=c[a+56>>2]|0;v=17}else{q=(o|0)==-1;v=16}}else{o=c[y+32>>2]|0;n=0;q=(o|0)==-1;v=16}if((v|0)==16){v=0;if(q|n)v=17;else{q=o+x|0;n=y+(o<<6)|0}}if((v|0)==17){q=x+1|0;n=y+64|0}if((q|0)>=(m|0))break a;p=+g[k>>2];r=+g[k+4>>2];s=+g[k+8>>2];t=+g[j>>2];u=+g[j+4>>2];w=+g[j+8>>2];x=q;y=n}}else l=0;while(0);if((c[6167]|0)>=(l|0)){i=V;return}c[6167]=l;i=V;return}function Se(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0;if(!(c[a+204>>2]&2)){c[a+68>>2]=c[b>>2];c[a+68+4>>2]=c[b+4>>2];c[a+68+8>>2]=c[b+8>>2];c[a+68+12>>2]=c[b+12>>2];c[a+84>>2]=c[b+16>>2];c[a+84+4>>2]=c[b+16+4>>2];c[a+84+8>>2]=c[b+16+8>>2];c[a+84+12>>2]=c[b+16+12>>2];c[a+100>>2]=c[b+32>>2];c[a+100+4>>2]=c[b+32+4>>2];c[a+100+8>>2]=c[b+32+8>>2];c[a+100+12>>2]=c[b+32+12>>2];c[a+116>>2]=c[b+48>>2];c[a+116+4>>2]=c[b+48+4>>2];c[a+116+8>>2]=c[b+48+8>>2];c[a+116+12>>2]=c[b+48+12>>2];d=a+20|0;e=b+16|0;f=a+36|0;h=b+32|0;i=a+52|0;j=b+48|0;k=a+4|0}else{c[a+68>>2]=c[a+4>>2];c[a+68+4>>2]=c[a+4+4>>2];c[a+68+8>>2]=c[a+4+8>>2];c[a+68+12>>2]=c[a+4+12>>2];c[a+84>>2]=c[a+20>>2];c[a+84+4>>2]=c[a+20+4>>2];c[a+84+8>>2]=c[a+20+8>>2];c[a+84+12>>2]=c[a+20+12>>2];c[a+100>>2]=c[a+36>>2];c[a+100+4>>2]=c[a+36+4>>2];c[a+100+8>>2]=c[a+36+8>>2];c[a+100+12>>2]=c[a+36+12>>2];c[a+116>>2]=c[a+52>>2];c[a+116+4>>2]=c[a+52+4>>2];c[a+116+8>>2]=c[a+52+8>>2];c[a+116+12>>2]=c[a+52+12>>2];d=a+20|0;e=b+16|0;f=a+36|0;h=b+32|0;i=a+52|0;j=b+48|0;k=a+4|0}c[a+132>>2]=c[a+312>>2];c[a+132+4>>2]=c[a+312+4>>2];c[a+132+8>>2]=c[a+312+8>>2];c[a+132+12>>2]=c[a+312+12>>2];c[a+148>>2]=c[a+328>>2];c[a+148+4>>2]=c[a+328+4>>2];c[a+148+8>>2]=c[a+328+8>>2];c[a+148+12>>2]=c[a+328+12>>2];c[k>>2]=c[b>>2];c[k+4>>2]=c[b+4>>2];c[k+8>>2]=c[b+8>>2];c[k+12>>2]=c[b+12>>2];c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];c[f>>2]=c[h>>2];c[f+4>>2]=c[h+4>>2];c[f+8>>2]=c[h+8>>2];c[f+12>>2]=c[h+12>>2];c[i>>2]=c[j>>2];c[i+4>>2]=c[j+4>>2];c[i+8>>2]=c[j+8>>2];c[i+12>>2]=c[j+12>>2];w=+g[a+4>>2];q=+g[a+396>>2];v=+g[a+8>>2];o=+g[a+400>>2];u=+g[a+12>>2];m=+g[a+404>>2];t=+g[a+20>>2];s=+g[a+24>>2];r=+g[a+28>>2];p=+g[a+36>>2];n=+g[a+40>>2];l=+g[a+44>>2];g[a+264>>2]=w*w*q+v*v*o+u*u*m;g[a+268>>2]=w*q*t+v*o*s+u*m*r;g[a+272>>2]=w*q*p+v*o*n+u*m*l;g[a+276>>2]=0.0;g[a+280>>2]=w*q*t+v*o*s+u*m*r;g[a+284>>2]=t*q*t+s*o*s+r*m*r;g[a+288>>2]=q*t*p+o*s*n+m*r*l;g[a+292>>2]=0.0;g[a+296>>2]=w*q*p+v*o*n+u*m*l;g[a+300>>2]=t*q*p+s*o*n+r*m*l;g[a+304>>2]=p*q*p+n*o*n+l*m*l;g[a+308>>2]=0.0;return}function Te(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0;h=i;i=i+160|0;e=c[a+4>>2]|0;f=c[e+12>>2]|0;D=+g[f>>2];C=+g[f+4>>2];B=+g[f+8>>2];A=+g[f+16>>2];z=+g[f+20>>2];y=+g[f+24>>2];r=+g[f+32>>2];p=+g[f+36>>2];n=+g[f+40>>2];e=c[(c[e+4>>2]|0)+24>>2]|0;x=+g[e+(d*80|0)>>2];w=+g[e+(d*80|0)+16>>2];v=+g[e+(d*80|0)+32>>2];u=+g[e+(d*80|0)+4>>2];t=+g[e+(d*80|0)+20>>2];s=+g[e+(d*80|0)+36>>2];q=+g[e+(d*80|0)+8>>2];o=+g[e+(d*80|0)+24>>2];m=+g[e+(d*80|0)+40>>2];F=+g[e+(d*80|0)+48>>2];E=+g[e+(d*80|0)+52>>2];j=+g[e+(d*80|0)+56>>2];l=+g[f+48>>2]+(D*F+C*E+B*j);k=+g[f+52>>2]+(A*F+z*E+y*j);j=+g[f+56>>2]+(r*F+p*E+n*j);g[h+88>>2]=D*x+C*w+B*v;g[h+88+4>>2]=D*u+C*t+B*s;g[h+88+8>>2]=D*q+C*o+B*m;g[h+88+12>>2]=0.0;g[h+88+16>>2]=A*x+z*w+y*v;g[h+88+20>>2]=A*u+z*t+y*s;g[h+88+24>>2]=A*q+z*o+y*m;g[h+88+28>>2]=0.0;g[h+88+32>>2]=r*x+p*w+n*v;g[h+88+36>>2]=r*u+p*t+n*s;g[h+88+40>>2]=r*q+p*o+n*m;g[h+88+44>>2]=0.0;g[h+88+48>>2]=l;g[h+88+52>>2]=k;g[h+88+56>>2]=j;g[h+88+60>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,h+88|0,h+72|0,h+56|0);f=c[a+8>>2]|0;e=c[f+4>>2]|0;mc[c[(c[e>>2]|0)+8>>2]&127](e,c[f+12>>2]|0,h+40|0,h+24|0);if(!(+g[h+72>>2]>+g[h+24>>2])?!(+g[h+56>>2]<+g[h+40>>2]):0)e=1;else e=0;if(!(!(+g[h+72+8>>2]>+g[h+24+8>>2])?!(+g[h+56+8>>2]<+g[h+40+8>>2]):0))e=0;if(+g[h+72+4>>2]>+g[h+24+4>>2]){i=h;return}if(+g[h+56+4>>2]<+g[h+40+4>>2]|e^1){i=h;return}e=c[a+4>>2]|0;f=c[e+8>>2]|0;c[h>>2]=e;c[h+4>>2]=b;c[h+8>>2]=f;c[h+12>>2]=h+88;c[h+16>>2]=-1;c[h+20>>2]=d;if(!(c[(c[a+24>>2]|0)+(d<<2)>>2]|0)){e=c[a+12>>2]|0;e=Ib[c[(c[e>>2]|0)+8>>2]&31](e,h,c[a+8>>2]|0,c[a+28>>2]|0)|0;c[(c[a+24>>2]|0)+(d<<2)>>2]=e;e=c[a+4>>2]|0}f=c[a+20>>2]|0;b=c[f+8>>2]|0;if((c[b+8>>2]|0)==(c[e+8>>2]|0)){c[f+8>>2]=h;ic[c[(c[f>>2]|0)+8>>2]&127](f,-1,d)}else{b=c[f+12>>2]|0;c[f+12>>2]=h;ic[c[(c[f>>2]|0)+12>>2]&127](f,-1,d)}e=c[(c[a+24>>2]|0)+(d<<2)>>2]|0;yb[c[(c[e>>2]|0)+8>>2]&31](e,h,c[a+8>>2]|0,c[a+16>>2]|0,c[a+20>>2]|0);e=c[a+20>>2]|0;if((c[(c[e+8>>2]|0)+8>>2]|0)==(c[(c[a+4>>2]|0)+8>>2]|0))c[e+8>>2]=b;else c[e+12>>2]=b;i=h;return}function Ue(){if(a[22576]|0)return;if(!(Wa(22576)|0))return;c[6168]=0;c[6169]=-2147483648;c[6170]=-1082130432;g[6171]=0.0;c[6172]=1060716128;c[6173]=-1090087446;c[6174]=-1092290076;g[6175]=0.0;c[6176]=-1098022214;c[6177]=-1084636126;c[6178]=-1092290076;g[6179]=0.0;c[6180]=-1083901670;c[6181]=-2147483648;c[6182]=-1092290177;g[6183]=0.0;c[6184]=-1098022214;c[6185]=1062847522;c[6186]=-1092290043;g[6187]=0.0;c[6188]=1060716128;c[6189]=1057396202;c[6190]=-1092290076;g[6191]=0.0;c[6192]=1049461434;c[6193]=-1084636126;c[6194]=1055193605;g[6195]=0.0;c[6196]=-1086767520;c[6197]=-1090087446;c[6198]=1055193572;g[6199]=0.0;c[6200]=-1086767520;c[6201]=1057396202;c[6202]=1055193572;g[6203]=0.0;c[6204]=1049461434;c[6205]=1062847522;c[6206]=1055193572;g[6207]=0.0;c[6208]=1063581978;c[6209]=0;c[6210]=1055193471;g[6211]=0.0;c[6212]=-2147483648;c[6213]=0;c[6214]=1065353216;g[6215]=0.0;c[6216]=1054458864;c[6217]=-1096927567;c[6218]=-1084636042;g[6219]=0.0;c[6220]=-1104782626;c[6221]=-1090519208;c[6222]=-1084636042;g[6223]=0.0;c[6224]=1049007812;c[6225]=-1085334679;c[6226]=-1090087228;g[6227]=0.0;c[6228]=1054458864;c[6229]=1050556081;c[6230]=-1084636042;g[6231]=0.0;c[6232]=1062847505;c[6233]=-2147483648;c[6234]=-1090087262;g[6235]=0.0;c[6236]=-1090087362;c[6237]=-2147483648;c[6238]=-1084636076;g[6239]=0.0;c[6240]=-1087361736;c[6241]=-1090519141;c[6242]=-1090087262;g[6243]=0.0;c[6244]=-1104782626;c[6245]=1056964440;c[6246]=-1084636042;g[6247]=0.0;c[6248]=-1087361736;c[6249]=1056964507;c[6250]=-1090087262;g[6251]=0.0;c[6252]=1049007812;c[6253]=1062148969;c[6254]=-1090087228;g[6255]=0.0;c[6256]=1064532105;c[6257]=1050556148;c[6258]=0;g[6259]=0.0;c[6260]=1064532105;c[6261]=-1096927500;c[6262]=0;g[6263]=0.0;c[6264]=1058437413;c[6265]=-1085334595;c[6266]=0;g[6267]=0.0;c[6268]=0;c[6269]=-1082130432;c[6270]=0;g[6271]=0.0;c[6272]=-1089046235;c[6273]=-1085334595;c[6274]=0;g[6275]=0.0;c[6276]=-1082951543;c[6277]=-1096927500;c[6278]=-2147483648;g[6279]=0.0;c[6280]=-1082951543;c[6281]=1050556148;c[6282]=-2147483648;g[6283]=0.0;c[6284]=-1089046235;c[6285]=1062149053;c[6286]=-2147483648;g[6287]=0.0;c[6288]=-2147483648;c[6289]=1065353216;c[6290]=-2147483648;g[6291]=0.0;c[6292]=1058437413;c[6293]=1062149053;c[6294]=-2147483648;g[6295]=0.0;c[6296]=1060121912;c[6297]=-1090519141;c[6298]=1057396386;g[6299]=0.0;c[6300]=-1098475836;c[6301]=-1085334679;c[6302]=1057396420;g[6303]=0.0;c[6304]=-1084636143;c[6305]=0;c[6306]=1057396386;g[6307]=0.0;c[6308]=-1098475836;c[6309]=1062148969;c[6310]=1057396420;g[6311]=0.0;c[6312]=1060121912;c[6313]=1056964507;c[6314]=1057396386;g[6315]=0.0;c[6316]=1057396286;c[6317]=0;c[6318]=1062847572;g[6319]=0.0;c[6320]=1042701022;c[6321]=-1090519208;c[6322]=1062847606;g[6323]=0.0;c[6324]=-1093024784;c[6325]=-1096927567;c[6326]=1062847606;g[6327]=0.0;c[6328]=-1093024784;c[6329]=1050556081;c[6330]=1062847606;g[6331]=0.0;c[6332]=1042701022;c[6333]=1056964440;c[6334]=1062847606;g[6335]=0.0;_a(22576);return}function Ve(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0;u=a[h+16>>0]&-16;a[h+16>>0]=u;w=+g[e>>2];x=+g[d>>2];y=+g[e+4>>2];z=+g[d+4>>2];q=+g[e+8>>2];r=+g[d+8>>2];s=+g[f>>2];t=+g[f+4>>2];v=+g[f+8>>2];m=+g[b>>2];n=+g[b+4>>2];i=+g[b+8>>2];o=(w-x)*(m-x)+(y-z)*(n-z)+(q-r)*(i-r);p=(s-x)*(m-x)+(t-z)*(n-z)+(v-r)*(i-r);if(o<=0.0&p<=0.0){c[h>>2]=c[d>>2];c[h+4>>2]=c[d+4>>2];c[h+8>>2]=c[d+8>>2];c[h+12>>2]=c[d+12>>2];a[h+16>>0]=u|1;g[h+20>>2]=1.0;g[h+24>>2]=0.0;g[h+28>>2]=0.0;g[h+32>>2]=0.0;return}k=(w-x)*(m-w)+(y-z)*(n-y)+(q-r)*(i-q);l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g[h+28>>2]=z;g[h+32>>2]=0.0;return}m=1.0/(o*l-k*p+(k*i-j*l+(j*p-o*i)));n=(j*p-o*i)*m;p=(o*l-k*p)*m;g[h>>2]=(s-x)*p+((w-x)*n+x);g[h+4>>2]=(t-z)*p+((y-z)*n+z);g[h+8>>2]=(v-r)*p+((q-r)*n+r);g[h+12>>2]=0.0;a[h+16>>0]=u|7;g[h+20>>2]=1.0-n-p;g[h+24>>2]=n;g[h+28>>2]=p;g[h+32>>2]=0.0;return}function We(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(!((a|0)!=0&(b|0)!=0))return;c[6435]=(c[6435]|0)+1;e=yc(1043)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e>>2]=a;c[e+4>>2]=b;n=1;b=128;h=128;i=e;f=124;while(1){e=n+-1|0;l=c[i+(e<<3)>>2]|0;m=c[i+(e<<3)+4>>2]|0;if((e|0)>(f|0)){f=h<<1;do if((h|0)<(f|0)&(b|0)<(f|0)){if(h){c[6435]=(c[6435]|0)+1;a=yc((h<<4|3)+16|0)|0;if(!a)a=0;else{c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16}if((h|0)>0){b=0;do{p=i+(b<<3)|0;j=c[p+4>>2]|0;k=a+(b<<3)|0;c[k>>2]=c[p>>2];c[k+4>>2]=j;b=b+1|0}while((b|0)!=(h|0))}else o=12}else{a=0;o=12}if((o|0)==12){o=0;if(!i){b=f;break}}c[6436]=(c[6436]|0)+1;hd(c[i+-4>>2]|0);b=f}else a=i;while(0);k=f;j=f+-4|0}else{k=h;a=i;j=f}do if((l|0)==(m|0)){if(c[l+40>>2]|0){p=c[l+36>>2]|0;c[a+(e<<3)>>2]=p;c[a+(e<<3)+4>>2]=p;e=n+1|0;p=c[l+40>>2]|0;c[a+(n<<3)>>2]=p;c[a+(n<<3)+4>>2]=p;p=c[l+40>>2]|0;c[a+(e<<3)>>2]=c[l+36>>2];c[a+(e<<3)+4>>2]=p;e=n+2|0}}else if(((((+g[l>>2]<=+g[m+16>>2]?+g[l+16>>2]>=+g[m>>2]:0)?+g[l+4>>2]<=+g[m+20>>2]:0)?+g[l+20>>2]>=+g[m+4>>2]:0)?+g[l+8>>2]<=+g[m+24>>2]:0)?+g[l+24>>2]>=+g[m+8>>2]:0){f=(c[m+40>>2]|0)!=0;if(!(c[l+40>>2]|0))if(f){p=c[m+36>>2]|0;c[a+(e<<3)>>2]=l;c[a+(e<<3)+4>>2]=p;e=c[m+40>>2]|0;c[a+(n<<3)>>2]=l;c[a+(n<<3)+4>>2]=e;e=n+1|0;break}else{ic[c[(c[d>>2]|0)+8>>2]&127](d,l,m);break}else{h=a+(e<<3)|0;i=c[l+36>>2]|0;if(f){p=c[m+36>>2]|0;c[h>>2]=i;c[a+(e<<3)+4>>2]=p;p=n+1|0;e=c[m+36>>2]|0;c[a+(n<<3)>>2]=c[l+40>>2];c[a+(n<<3)+4>>2]=e;e=n+2|0;i=c[m+40>>2]|0;c[a+(p<<3)>>2]=c[l+36>>2];c[a+(p<<3)+4>>2]=i;p=c[m+40>>2]|0;c[a+(e<<3)>>2]=c[l+40>>2];c[a+(e<<3)+4>>2]=p;e=n+3|0;break}else{c[h>>2]=i;c[a+(e<<3)+4>>2]=m;c[a+(n<<3)>>2]=c[l+40>>2];c[a+(n<<3)+4>>2]=m;e=n+1|0;break}}}while(0);if(!e)break;else{n=e;h=k;i=a;f=j}}if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Xe(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0;n=c[a+192>>2]|0;m=+Sb[c[(c[n>>2]|0)+48>>2]&15](n);n=c[a+712>>2]|0;if((n|0)>0){o=0;do{l=c[a+720>>2]|0;d=l+(o*104|0)+8|0;i=+g[b>>2]*+g[d>>2];g[d>>2]=i;d=l+(o*104|0)+12|0;j=+g[b+4>>2]*+g[d>>2];g[d>>2]=j;d=l+(o*104|0)+16|0;k=+g[b+8>>2]*+g[d>>2];g[d>>2]=k;d=l+(o*104|0)+24|0;g[d>>2]=+g[b>>2]*+g[d>>2];d=l+(o*104|0)+28|0;g[d>>2]=+g[b+4>>2]*+g[d>>2];d=l+(o*104|0)+32|0;g[d>>2]=+g[b+8>>2]*+g[d>>2];l=c[l+(o*104|0)+96>>2]|0;d=hh(a+928|0,l)|0;a:do if(d){f=c[a+936>>2]|0;if((f|0)<=-1){d=c[a+928>>2]|0;break}if((f|0)>0){h=0;while(1){e=c[d+32>>2]|0;h=h+1|0;if(!e)break a;if((h|0)>=(f|0)){d=e;break}else d=e}}}else d=0;while(0);g[l>>2]=i-m;g[l+4>>2]=j-m;g[l+8>>2]=k-m;g[l+12>>2]=0.0;g[l+16>>2]=m+i;g[l+20>>2]=m+j;g[l+24>>2]=m+k;g[l+28>>2]=0.0;lf(a+928|0,d,l);o=o+1|0}while((o|0)!=(n|0))}Bg(a);d=c[a+928>>2]|0;if(d){o=c[a+192>>2]|0;j=+Sb[c[(c[o>>2]|0)+48>>2]&15](o);m=+g[d+4>>2]-j;k=+g[d+8>>2]-j;g[a+892>>2]=+g[d>>2]-j;g[a+896>>2]=m;g[a+900>>2]=k;g[a+904>>2]=0.0;k=j+ +g[d+20>>2];m=j+ +g[d+24>>2];g[a+908>>2]=j+ +g[d+16>>2];g[a+912>>2]=k;g[a+916>>2]=m;g[a+920>>2]=0.0;d=c[a+188>>2]|0;if(d|0){o=c[a+684>>2]|0;b=c[o+32>>2]|0;yb[c[(c[b>>2]|0)+16>>2]&31](b,d,a+892|0,a+908|0,c[o+36>>2]|0)}}else{c[a+892>>2]=0;c[a+892+4>>2]=0;c[a+892+8>>2]=0;c[a+892+12>>2]=0;c[a+892+16>>2]=0;c[a+892+20>>2]=0;c[a+892+24>>2]=0;c[a+892+28>>2]=0}f=c[a+732>>2]|0;if((f|0)<=0){eg(a);return}d=c[a+740>>2]|0;e=0;do{b=c[d+(e*52|0)+8>>2]|0;o=c[d+(e*52|0)+12>>2]|0;j=+g[b+8>>2]-+g[o+8>>2];k=+g[b+12>>2]-+g[o+12>>2];m=+g[b+16>>2]-+g[o+16>>2];m=+O(+(j*j+k*k+m*m));g[d+(e*52|0)+16>>2]=m;g[d+(e*52|0)+28>>2]=m*m;e=e+1|0}while((e|0)!=(f|0));d=c[a+740>>2]|0;e=0;do{g[d+(e*52|0)+24>>2]=(+g[(c[d+(e*52|0)+8>>2]|0)+88>>2]+ +g[(c[d+(e*52|0)+12>>2]|0)+88>>2])/+g[(c[d+(e*52|0)+4>>2]|0)+4>>2];e=e+1|0}while((e|0)!=(f|0));eg(a);return}function Ye(b,d,e,f){b=b|0;d=d|0;e=e|0;f=+f;var h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0,x=0.0,y=0,z=0;w=i;i=i+192|0;u=c[(c[b+4>>2]|0)+740>>2]|0;v=c[(c[b+8>>2]|0)+8>>2]|0;o=+g[e>>2];r=+g[d>>2]*f+o;h=+g[e+4>>2];s=+g[d+4>>2]*f+h;j=+g[e+8>>2];t=+g[d+8>>2]*f+j;p=c[(c[b+12>>2]|0)+8>>2]|0;q=+g[p+52>>2];if((u|0)!=(v|0)){m=s-+g[p+56>>2];l=t-+g[p+60>>2];x=o-+g[v+52>>2];o=h-+g[v+56>>2];h=j-+g[v+60>>2];j=(r-q)*+g[p+4>>2]+m*+g[p+20>>2]+l*+g[p+36>>2];k=(r-q)*+g[p+8>>2]+m*+g[p+24>>2]+l*+g[p+40>>2];l=(r-q)*+g[p+12>>2]+m*+g[p+28>>2]+l*+g[p+44>>2];m=x*+g[v+4>>2]+o*+g[v+20>>2]+h*+g[v+36>>2];n=x*+g[v+8>>2]+o*+g[v+24>>2]+h*+g[v+40>>2];h=x*+g[v+12>>2]+o*+g[v+28>>2]+h*+g[v+44>>2]}else{n=r-+g[u+52>>2];m=s-+g[u+56>>2];l=t-+g[u+60>>2];x=h-+g[p+56>>2];h=j-+g[p+60>>2];j=n*+g[u+4>>2]+m*+g[u+20>>2]+l*+g[u+36>>2];k=n*+g[u+8>>2]+m*+g[u+24>>2]+l*+g[u+40>>2];l=n*+g[u+12>>2]+m*+g[u+28>>2]+l*+g[u+44>>2];m=(o-q)*+g[p+4>>2]+x*+g[p+20>>2]+h*+g[p+36>>2];n=(o-q)*+g[p+8>>2]+x*+g[p+24>>2]+h*+g[p+40>>2];h=(o-q)*+g[p+12>>2]+x*+g[p+28>>2]+h*+g[p+44>>2]}g[w>>2]=j;g[w+4>>2]=k;g[w+8>>2]=l;g[w+12>>2]=0.0;g[w+16>>2]=m;g[w+20>>2]=n;g[w+24>>2]=h;g[w+28>>2]=0.0;c[w+64>>2]=c[d>>2];c[w+64+4>>2]=c[d+4>>2];c[w+64+8>>2]=c[d+8>>2];c[w+64+12>>2]=c[d+12>>2];g[w+80>>2]=f;g[w+84>>2]=0.0;g[w+88>>2]=0.0;g[w+92>>2]=0.0;c[w+112>>2]=0;a[w+116>>0]=0;c[w+120>>2]=0;c[w+120+4>>2]=0;c[w+120+8>>2]=0;c[w+120+12>>2]=0;c[w+120+16>>2]=0;c[w+120+20>>2]=0;c[w+120+24>>2]=0;c[w+120+28>>2]=0;g[w+48>>2]=r;g[w+52>>2]=s;g[w+56>>2]=t;g[w+60>>2]=0.0;c[w+32>>2]=c[e>>2];c[w+32+4>>2]=c[e+4>>2];c[w+32+8>>2]=c[e+8>>2];c[w+32+12>>2]=c[e+12>>2];d=c[b+20>>2]|0;p=c[b+16>>2]|0;e=c[b+28>>2]|0;z=c[b+24>>2]|0;y=(u|0)!=(v|0)?d:p;d=(u|0)!=(v|0)?p:d;p=(u|0)!=(v|0)?e:z;e=(u|0)!=(v|0)?z:e;c[w+96>>2]=y;c[w+100>>2]=d;c[w+104>>2]=p;c[w+108>>2]=e;z=c[b+32>>2]|0;+Kb[c[(c[z>>2]|0)+12>>2]&1](z,w,c[((u|0)!=(v|0)?b+12|0:b+8|0)>>2]|0,y,p,c[((u|0)!=(v|0)?b+8|0:b+12|0)>>2]|0,d,e);i=w;return}function Ze(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0;h=i;i=i+48|0;c[b+8>>2]=0;g[b+12>>2]=0.0;c[b>>2]=6924;c[b+48>>2]=d;c[b+4>>2]=21;if(Eb[c[(c[d>>2]|0)+40>>2]&127](d)|0)ic[c[(c[d>>2]|0)+48>>2]&127](d,b+16|0,b+32|0);else{c[h+32>>2]=0;c[h+32+4>>2]=0;c[h+32+8>>2]=0;c[h+32+12>>2]=0;g[h+32>>2]=1.0;ic[c[(c[b>>2]|0)+68>>2]&127](h+16|0,b,h+32|0);g[b+32>>2]=+g[h+16>>2]+ +g[b+12>>2];g[h+32>>2]=-1.0;ic[c[(c[b>>2]|0)+68>>2]&127](h,b,h+32|0);c[h+16>>2]=c[h>>2];c[h+16+4>>2]=c[h+4>>2];c[h+16+8>>2]=c[h+8>>2];c[h+16+12>>2]=c[h+12>>2];g[b+16>>2]=+g[h+16>>2]-+g[b+12>>2];c[h+32>>2]=0;c[h+32+4>>2]=0;c[h+32+8>>2]=0;c[h+32+12>>2]=0;g[h+32+4>>2]=1.0;ic[c[(c[b>>2]|0)+68>>2]&127](h+16|0,b,h+32|0);g[b+36>>2]=+g[h+16+4>>2]+ +g[b+12>>2];g[h+32+4>>2]=-1.0;ic[c[(c[b>>2]|0)+68>>2]&127](h,b,h+32|0);c[h+16>>2]=c[h>>2];c[h+16+4>>2]=c[h+4>>2];c[h+16+8>>2]=c[h+8>>2];c[h+16+12>>2]=c[h+12>>2];g[b+20>>2]=+g[h+16+4>>2]-+g[b+12>>2];c[h+32>>2]=0;c[h+32+4>>2]=0;c[h+32+8>>2]=0;c[h+32+12>>2]=0;g[h+32+8>>2]=1.0;ic[c[(c[b>>2]|0)+68>>2]&127](h+16|0,b,h+32|0);g[b+40>>2]=+g[h+16+8>>2]+ +g[b+12>>2];g[h+32+8>>2]=-1.0;ic[c[(c[b>>2]|0)+68>>2]&127](h,b,h+32|0);c[h+16>>2]=c[h>>2];c[h+16+4>>2]=c[h+4>>2];c[h+16+8>>2]=c[h+8>>2];c[h+16+12>>2]=c[h+12>>2];g[b+24>>2]=+g[h+16+8>>2]-+g[b+12>>2]}c[b>>2]=6772;c[b+52>>2]=0;c[b+56>>2]=0;a[b+60>>0]=e&1;a[b+61>>0]=0;c[b+4>>2]=21;if(!f){i=h;return}c[6435]=(c[6435]|0)+1;f=yc(191)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}c[f+52>>2]=282;a[f+60>>0]=0;a[f+80>>0]=1;c[f+76>>2]=0;c[f+68>>2]=0;c[f+72>>2]=0;a[f+100>>0]=1;c[f+96>>2]=0;c[f+88>>2]=0;c[f+92>>2]=0;a[f+120>>0]=1;c[f+116>>2]=0;c[f+108>>2]=0;c[f+112>>2]=0;a[f+140>>0]=1;c[f+136>>2]=0;c[f+128>>2]=0;c[f+132>>2]=0;c[f+144>>2]=0;a[f+164>>0]=1;c[f+160>>2]=0;c[f+152>>2]=0;c[f+156>>2]=0;c[f+168>>2]=0;c[f+4>>2]=-8388609;c[f+8>>2]=-8388609;c[f+12>>2]=-8388609;g[f+16>>2]=0.0;c[f+20>>2]=2139095039;c[f+24>>2]=2139095039;c[f+28>>2]=2139095039;g[f+32>>2]=0.0;c[f>>2]=7980;c[b+52>>2]=f;pd(f,c[b+48>>2]|0,(a[b+60>>0]|0)!=0,b+16|0,b+32|0);a[b+61>>0]=1;i=h;return}function _e(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0,h=0,i=0.0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0;d=c[a+748>>2]|0;if((d|0)!=4){c[a+748>>2]=d+1;x=d;w=(x|0)<0;x=w?0:x;a=a+4+(x*184|0)|0;_m(a|0,b|0,184)|0;return x|0}y=+g[b+80>>2];v=+g[a+84>>2];u=v>2];s=t>2];w=+g[a+636>>2]<(r>31;y=+g[b>>2];if(d){e=+g[a+188>>2];i=+g[b+4>>2];l=+g[a+192>>2];m=+g[b+8>>2];n=+g[a+196>>2];p=+g[a+556>>2];s=+g[a+372>>2];q=+g[a+560>>2];r=+g[a+376>>2];v=+g[a+564>>2];j=+g[a+380>>2];h=(g[k>>2]=((y-e)*(q-r)-(i-l)*(p-s))*((y-e)*(q-r)-(i-l)*(p-s))+(((i-l)*(v-j)-(m-n)*(q-r))*((i-l)*(v-j)-(m-n)*(q-r))+((m-n)*(p-s)-(y-e)*(v-j))*((m-n)*(p-s)-(y-e)*(v-j))),c[k>>2]|0);if((d|0)==1){o=+g[a+12>>2];t=p;u=q;p=+g[a+4>>2];q=+g[a+8>>2];f=0;x=7}else{t=p;u=q;x=6}}else{e=+g[a+188>>2];l=+g[a+192>>2];n=+g[a+196>>2];i=+g[b+4>>2];m=+g[b+8>>2];s=+g[a+372>>2];t=+g[a+556>>2];r=+g[a+376>>2];u=+g[a+560>>2];j=+g[a+380>>2];v=+g[a+564>>2];h=0;x=6}if((x|0)==6){p=+g[a+4>>2];q=+g[a+8>>2];D=i-q;o=+g[a+12>>2];B=m-o;A=t-s;C=u-r;z=v-j;f=(g[k>>2]=((y-p)*C-D*A)*((y-p)*C-D*A)+((D*z-B*C)*(D*z-B*C)+(B*A-(y-p)*z)*(B*A-(y-p)*z)),c[k>>2]|0);if((d|0)==2){d=0;x=8}else x=7}if((x|0)==7){C=y-p;E=i-q;A=m-o;B=t-e;z=u-l;D=v-n;d=(g[k>>2]=(C*z-E*B)*(C*z-E*B)+((E*D-A*z)*(E*D-A*z)+(A*B-C*D)*(A*B-C*D)),c[k>>2]|0);if(w)e=0.0;else x=8}if((x|0)==8){E=y-p;A=i-q;C=m-o;D=s-e;B=r-l;e=j-n;e=(E*B-A*D)*(E*B-A*D)+((A*e-C*B)*(A*e-C*B)+(C*D-E*e)*(C*D-E*e))}E=+N(+(c[k>>2]=h,+g[k>>2]));C=+N(+(c[k>>2]=f,+g[k>>2]));A=+N(+(c[k>>2]=d,+g[k>>2]));z=+N(+e);D=E>-999999984306749440.0?E:-999999984306749440.0;B=C>D?C:D;x=z>(A>B?A:B)?3:A>B?2:C>D?1:(E>-999999984306749440.0^1)<<31>>31;w=(x|0)<0;x=w?0:x;a=a+4+(x*184|0)|0;_m(a|0,b|0,184)|0;return x|0}function $e(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(!b)if(!e){if(f|0){c[f>>2]=(a>>>0)%(d>>>0);c[f+4>>2]=0}e=0;f=(a>>>0)/(d>>>0)>>>0;return (C=e,f)|0}else{if(!f){e=0;f=0;return (C=e,f)|0}c[f>>2]=a|0;c[f+4>>2]=b&0;e=0;f=0;return (C=e,f)|0}do if(d){if(e|0){h=(aa(e|0)|0)-(aa(b|0)|0)|0;if(h>>>0<=31){n=h+1|0;i=a>>>((h+1|0)>>>0)&h-31>>31|b<<31-h;m=b>>>((h+1|0)>>>0)&h-31>>31;g=0;h=a<<31-h;break}if(!f){e=0;f=0;return (C=e,f)|0}c[f>>2]=a|0;c[f+4>>2]=b|b&0;e=0;f=0;return (C=e,f)|0}if(d-1&d|0){h=(aa(d|0)|0)+33-(aa(b|0)|0)|0;n=h;i=32-h-1>>31&b>>>((h-32|0)>>>0)|(b<<32-h|a>>>(h>>>0))&h-32>>31;m=h-32>>31&b>>>(h>>>0);g=a<<64-h&32-h>>31;h=(b<<64-h|a>>>((h-32|0)>>>0))&32-h>>31|a<<32-h&h-33>>31;break}if(f|0){c[f>>2]=d-1&a;c[f+4>>2]=0}if((d|0)==1){e=b|b&0;f=a|0|0;return (C=e,f)|0}else{f=Sp(d|0)|0;e=b>>>(f>>>0)|0;f=b<<32-f|a>>>(f>>>0)|0;return (C=e,f)|0}}else{if(!e){if(f|0){c[f>>2]=(b>>>0)%(d>>>0);c[f+4>>2]=0}e=0;f=(b>>>0)/(d>>>0)>>>0;return (C=e,f)|0}if(!a){if(f|0){c[f>>2]=0;c[f+4>>2]=(b>>>0)%(e>>>0)}d=0;f=(b>>>0)/(e>>>0)>>>0;return (C=d,f)|0}if(!(e-1&e)){if(f|0){c[f>>2]=a|0;c[f+4>>2]=e-1&b|b&0}d=0;f=b>>>((Sp(e|0)|0)>>>0);return (C=d,f)|0}h=(aa(e|0)|0)-(aa(b|0)|0)|0;if(h>>>0<=30){n=h+1|0;i=b<<31-h|a>>>((h+1|0)>>>0);m=b>>>((h+1|0)>>>0);g=0;h=a<<31-h;break}if(!f){e=0;f=0;return (C=e,f)|0}c[f>>2]=a|0;c[f+4>>2]=b|b&0;e=0;f=0;return (C=e,f)|0}while(0);if(!n){j=h;b=m;a=0;h=0}else{k=Kt(d|0|0,e|e&0|0,-1,-1)|0;l=C;j=h;b=m;a=n;h=0;do{p=j;j=g>>>31|j<<1;g=h|g<<1;p=i<<1|p>>>31|0;o=i>>>31|b<<1|0;Is(k|0,l|0,p|0,o|0)|0;n=C;m=n>>31|((n|0)<0?-1:0)<<1;h=m&1;i=Is(p|0,o|0,m&(d|0)|0,(((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1)&(e|e&0)|0)|0;b=C;a=a-1|0}while((a|0)!=0);a=0}if(f|0){c[f>>2]=i;c[f+4>>2]=b}o=(g|0)>>>31|j<<1|(0<<1|g>>>31)&0|a;p=(g<<1|0>>>31)&-2|h;return (C=o,p)|0}function af(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0;l=i;i=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124>>2]=0.0;c[e>>2]=c[l>>2];c[e+4>>2]=c[l+4>>2];c[e+8>>2]=c[l+8>>2];c[e+12>>2]=c[l+12>>2];c[d>>2]=c[l>>2];c[d+4>>2]=c[l+4>>2];c[d+8>>2]=c[l+8>>2];c[d+12>>2]=c[l+12>>2];b=1;do{f=+g[l+(b<<4)>>2];if(f<+g[d>>2])g[d>>2]=f;h=+g[l+(b<<4)+4>>2];if(h<+g[d+4>>2])g[d+4>>2]=h;j=+g[l+(b<<4)+8>>2];if(j<+g[d+8>>2])g[d+8>>2]=j;k=+g[l+(b<<4)+12>>2];if(k<+g[d+12>>2])g[d+12>>2]=k;if(+g[e>>2]>2]=f;if(+g[e+4>>2]>2]=h;if(+g[e+8>>2]>2]=j;if(+g[e+12>>2]>2]=k;b=b+1|0}while((b|0)!=8);i=l;return}function bf(b){b=b|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+16|0;li(12143);l=c[b+204>>2]|0;ic[c[(c[l>>2]|0)+8>>2]&127](l,b,c[b+24>>2]|0);l=c[b+308>>2]|0;if((l|0)>0){k=c[b+316>>2]|0;m=0;do{e=c[k+(m<<2)>>2]|0;d=c[e+740>>2]|0;e=c[e+744>>2]|0;if((d|0?(e|0?(c[d+204>>2]&3|0)==0:0):0)?(c[e+204>>2]&3|0)==0:0){h=c[d+208>>2]|0;d=c[e+208>>2]|0;j=c[(c[b+204>>2]|0)+16>>2]|0;e=c[j+(h<<3)>>2]|0;if((e|0)!=(h|0)){f=j+(h<<3)|0;do{h=j+(e<<3)|0;c[f>>2]=c[h>>2];h=c[h>>2]|0;f=j+(h<<3)|0;e=c[f>>2]|0}while((h|0)!=(e|0))}e=c[j+(d<<3)>>2]|0;if((e|0)!=(d|0)){f=j+(d<<3)|0;do{d=j+(e<<3)|0;c[f>>2]=c[d>>2];d=c[d>>2]|0;f=j+(d<<3)|0;e=c[f>>2]|0}while((d|0)!=(e|0))}if((h|0)!=(d|0)){c[j+(h<<3)>>2]=d;f=j+(d<<3)+4|0;c[f>>2]=(c[f>>2]|0)+(c[j+(h<<3)+4>>2]|0)}}m=m+1|0}while((m|0)!=(l|0))}l=c[b+212>>2]|0;if((l|0)>0){k=c[b+220>>2]|0;m=0;do{d=c[k+(m<<2)>>2]|0;if((a[d+20>>0]|0?(n=c[d+28>>2]|0,(c[n+204>>2]&3|0)==0):0)?(o=c[d+32>>2]|0,(c[o+204>>2]&3|0)==0):0){f=c[n+208>>2]|0;d=c[o+208>>2]|0;j=c[(c[b+204>>2]|0)+16>>2]|0;e=c[j+(f<<3)>>2]|0;if((e|0)==(f|0))h=f;else{f=j+(f<<3)|0;do{h=j+(e<<3)|0;c[f>>2]=c[h>>2];h=c[h>>2]|0;f=j+(h<<3)|0;e=c[f>>2]|0}while((h|0)!=(e|0))}e=c[j+(d<<3)>>2]|0;if((e|0)!=(d|0)){f=j+(d<<3)|0;do{d=j+(e<<3)|0;c[f>>2]=c[d>>2];d=c[d>>2]|0;f=j+(d<<3)|0;e=c[f>>2]|0}while((d|0)!=(e|0))}if((h|0)!=(d|0)){c[j+(h<<3)>>2]=d;f=j+(d<<3)+4|0;c[f>>2]=(c[f>>2]|0)+(c[j+(h<<3)+4>>2]|0)}}m=m+1|0}while((m|0)!=(l|0))}d=c[b+204>>2]|0;Cb[c[(c[d>>2]|0)+12>>2]&127](d,b);d=c[2357]|0;b=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=b;if(b|0){i=p;return}do if(c[d+4>>2]|0){tb(p|0,0)|0;b=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[p+4>>2]|0)-(c[b+4>>2]|0)+(((c[p>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=p;return}}while(0);c[2357]=c[d+20>>2];i=p;return}function cf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0.0,q=0;o=i;i=i+128|0;h=+g[b>>2];j=+g[b+16>>2];p=h>2];if((p+g[a+28>>2]){i=o;return}m=h>j?b:b+16|0;if(+g[(+g[m>>2]>k?m:b+32|0)>>2]<+g[a+12>>2]){i=o;return}h=+g[b+8>>2];j=+g[b+24>>2];p=h>2];if((p+g[a+36>>2]){i=o;return}m=h>j?b+8|0:b+24|0;if(+g[(+g[m>>2]>k?m:b+40|0)>>2]<+g[a+20>>2]){i=o;return}h=+g[b+4>>2];j=+g[b+20>>2];p=h>2];if((p+g[a+32>>2]){i=o;return}m=h>j?b+4|0:b+20|0;if(+g[(+g[m>>2]>k?m:b+36|0)>>2]<+g[a+16>>2]){i=o;return}m=c[a+48>>2]|0;f=c[a+4>>2]|0;if((c[(c[f+4>>2]|0)+4>>2]|0)>=20){i=o;return}c[o+24+8>>2]=0;c[o+24+12>>2]=1065353216;c[o+24+16>>2]=1065353216;c[o+24+20>>2]=1065353216;g[o+24+24>>2]=0.0;c[o+24+52>>2]=0;c[o+24>>2]=3736;c[o+24+4>>2]=1;c[o+24+56>>2]=c[b>>2];c[o+24+56+4>>2]=c[b+4>>2];c[o+24+56+8>>2]=c[b+8>>2];c[o+24+56+12>>2]=c[b+12>>2];c[o+24+72>>2]=c[b+16>>2];c[o+24+72+4>>2]=c[b+16+4>>2];c[o+24+72+8>>2]=c[b+16+8>>2];c[o+24+72+12>>2]=c[b+16+12>>2];c[o+24+88>>2]=c[b+32>>2];c[o+24+88+4>>2]=c[b+32+4>>2];c[o+24+88+8>>2]=c[b+32+8>>2];c[o+24+88+12>>2]=c[b+32+12>>2];c[o+24+44>>2]=c[a+56>>2];q=c[a+8>>2]|0;b=c[q+8>>2]|0;l=c[q+12>>2]|0;c[o>>2]=q;c[o+4>>2]=o+24;c[o+8>>2]=b;c[o+12>>2]=l;c[o+16>>2]=d;c[o+20>>2]=e;l=Ib[c[(c[m>>2]|0)+8>>2]&31](m,f,o,c[a+64>>2]|0)|0;f=c[a+44>>2]|0;b=c[f+8>>2]|0;if((c[b+8>>2]|0)==(c[(c[a+8>>2]|0)+8>>2]|0)){c[f+8>>2]=o;ic[c[(c[f>>2]|0)+8>>2]&127](f,d,e)}else{b=c[f+12>>2]|0;c[f+12>>2]=o;ic[c[(c[f>>2]|0)+12>>2]&127](f,d,e)}yb[c[(c[l>>2]|0)+8>>2]&31](l,c[a+4>>2]|0,o,c[a+52>>2]|0,c[a+44>>2]|0);f=c[a+44>>2]|0;if((c[(c[f+8>>2]|0)+8>>2]|0)==(c[(c[a+8>>2]|0)+8>>2]|0))c[f+8>>2]=b;else c[f+12>>2]=b;Ab[c[c[l>>2]>>2]&255](l);Cb[c[(c[m>>2]|0)+60>>2]&127](m,l);c[o+24>>2]=7124;f=c[o+24+52>>2]|0;if(f|0?(Ab[c[c[f>>2]>>2]&255](f),n=c[o+24+52>>2]|0,n|0):0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}i=o;return}function df(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0;k=i;i=i+64|0;l=(a[b+8>>0]|0)!=0;j=l?e:d;d=l?d:e;e=c[d+4>>2]|0;if(((c[e+4>>2]|0)+-21|0)>>>0>=9){i=k;return}if((c[(c[j+4>>2]|0)+4>>2]|0)>=20){i=k;return}m=+Sb[c[(c[e>>2]|0)+48>>2]&15](e);c[h+4>>2]=c[b+76>>2];c[b+16>>2]=j;c[b+20>>2]=d;c[b+64>>2]=f;g[b+68>>2]=m;c[b+56>>2]=h;l=c[d+12>>2]|0;B=+g[l>>2];A=+g[l+16>>2];z=+g[l+32>>2];y=+g[l+4>>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==(f|0)){ef(e,j+4|0,d+4|0);break}else{ef(e,d+4|0,f+4|0);break}}while(0);c[b+16>>2]=0;c[b+20>>2]=0;i=k;return}function ef(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0.0,i=0.0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0;f=c[b+748>>2]|0;if((f|0)<=0)return;do{k=f;f=f+-1|0;p=+g[b+4+(f*184|0)>>2];q=+g[b+4+(f*184|0)+4>>2];h=+g[b+4+(f*184|0)+8>>2];o=p*+g[d>>2]+q*+g[d+4>>2]+h*+g[d+8>>2]+ +g[d+48>>2];m=p*+g[d+16>>2]+q*+g[d+20>>2]+h*+g[d+24>>2]+ +g[d+52>>2];h=p*+g[d+32>>2]+q*+g[d+36>>2]+h*+g[d+40>>2]+ +g[d+56>>2];g[b+4+(f*184|0)+48>>2]=o;g[b+4+(f*184|0)+52>>2]=m;g[b+4+(f*184|0)+56>>2]=h;g[b+4+(f*184|0)+60>>2]=0.0;q=+g[b+4+(f*184|0)+16>>2];p=+g[b+4+(f*184|0)+20>>2];i=+g[b+4+(f*184|0)+24>>2];n=q*+g[e>>2]+p*+g[e+4>>2]+i*+g[e+8>>2]+ +g[e+48>>2];l=q*+g[e+16>>2]+p*+g[e+20>>2]+i*+g[e+24>>2]+ +g[e+52>>2];i=q*+g[e+32>>2]+p*+g[e+36>>2]+i*+g[e+40>>2]+ +g[e+56>>2];g[b+4+(f*184|0)+32>>2]=n;g[b+4+(f*184|0)+36>>2]=l;g[b+4+(f*184|0)+40>>2]=i;g[b+4+(f*184|0)+44>>2]=0.0;g[b+4+(f*184|0)+80>>2]=(o-n)*+g[b+4+(f*184|0)+64>>2]+(m-l)*+g[b+4+(f*184|0)+68>>2]+(h-i)*+g[b+4+(f*184|0)+72>>2];j=b+4+(f*184|0)+148|0;c[j>>2]=(c[j>>2]|0)+1}while((k|0)>1);f=c[b+748>>2]|0;if((f|0)<=0)return;e=f;j=f;while(1){k=j;j=j+-1|0;d=b+4+(j*184|0)|0;h=+g[b+4+(j*184|0)+80>>2];i=+g[b+752>>2];if(h<=i){o=+g[b+4+(j*184|0)+32>>2]-(+g[b+4+(j*184|0)+48>>2]-+g[b+4+(j*184|0)+64>>2]*h);p=+g[b+4+(j*184|0)+36>>2]-(+g[b+4+(j*184|0)+52>>2]-h*+g[b+4+(j*184|0)+68>>2]);q=+g[b+4+(j*184|0)+40>>2]-(+g[b+4+(j*184|0)+56>>2]-h*+g[b+4+(j*184|0)+72>>2]);if(o*o+p*p+q*q>i*i){f=e+-1|0;if((f|0)==(j|0))f=e;else{_m(d|0,b+4+(f*184|0)|0,184)|0;c[b+4+(f*184|0)+112>>2]=0;g[b+4+(f*184|0)+120>>2]=0.0;a[b+4+(f*184|0)+116>>0]=0;g[b+4+(f*184|0)+124>>2]=0.0;g[b+4+(f*184|0)+128>>2]=0.0;c[b+4+(f*184|0)+148>>2]=0;f=c[b+748>>2]|0}f=f+-1|0;c[b+748>>2]=f}else f=e}else{f=e+-1|0;if((f|0)==(j|0))f=e;else{_m(d|0,b+4+(f*184|0)|0,184)|0;c[b+4+(f*184|0)+112>>2]=0;g[b+4+(f*184|0)+120>>2]=0.0;a[b+4+(f*184|0)+116>>0]=0;g[b+4+(f*184|0)+124>>2]=0.0;g[b+4+(f*184|0)+128>>2]=0.0;c[b+4+(f*184|0)+148>>2]=0;f=c[b+748>>2]|0}f=f+-1|0;c[b+748>>2]=f}if((k|0)<=1)break;else e=f}return}function ff(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0;D=i;i=i+32|0;if(!a){i=D;return}w=+g[d>>2]-+g[b>>2];x=+g[d+4>>2]-+g[b+4>>2];r=+g[d+8>>2]-+g[b+8>>2];s=1.0/+O(+(w*w+x*x+r*r));t=w*s==0.0?999999984306749440.0:1.0/(w*s);u=x*s==0.0?999999984306749440.0:1.0/(x*s);v=r*s==0.0?999999984306749440.0:1.0/(r*s);c[6435]=(c[6435]|0)+1;d=yc(531)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}Qn(d|0,0,512)|0;c[d>>2]=a;q=1;a=128;m=128;f=126;while(1){n=q+-1|0;p=c[d+(n<<2)>>2]|0;c[D>>2]=c[p>>2];c[D+4>>2]=c[p+4>>2];c[D+8>>2]=c[p+8>>2];c[D+12>>2]=c[p+12>>2];c[D+16>>2]=c[p+16>>2];c[D+16+4>>2]=c[p+16+4>>2];c[D+16+8>>2]=c[p+16+8>>2];c[D+16+12>>2]=c[p+16+12>>2];j=+g[b>>2];h=t*(+g[D+((t<0.0&1)<<4)>>2]-j);j=t*(+g[D+((t<0.0^1)<<4)>>2]-j);l=+g[b+4>>2];k=u*(+g[D+((u<0.0&1)<<4)+4>>2]-l);l=u*(+g[D+((u<0.0^1)<<4)+4>>2]-l);do if((!(k>j|h>l)?(y=k>h?k:h,B=l>2],z=v*(+g[D+((v<0.0&1)<<4)+8>>2]-A),A=v*(+g[D+((v<0.0^1)<<4)+8>>2]-A),!(z>B|y>A)):0)?((A0.0?(z>y?z:y)>2]|0)){Cb[c[(c[e>>2]|0)+12>>2]&127](e,p);break}if((n|0)>(f|0)){o=m<<1;if((m|0)<(o|0)){do if((a|0)<(o|0)){if(m){c[6435]=(c[6435]|0)+1;a=yc((m<<3|3)+16|0)|0;if(!a)a=0;else{c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16}if((m|0)>0){f=0;do{c[a+(f<<2)>>2]=c[d+(f<<2)>>2];f=f+1|0}while((f|0)!=(m|0))}else C=17}else{a=0;C=17}if((C|0)==17){C=0;if(!d){f=o;d=a;break}}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);f=o;d=a}else f=a;while(0);Qn(d+(m<<2)|0,0,m<<2|0)|0;a=f}m=o;f=o+-2|0}c[d+(n<<2)>>2]=c[p+36>>2];c[d+(q<<2)>>2]=c[p+40>>2];n=q+1|0}while(0);if(!n)break;else q=n}if(!d){i=D;return}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);i=D;return}function gf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0;f=i;i=i+256|0;li(11671);c[f+32>>2]=4060;l=f+32+36|0;c[l>>2]=c[b>>2];c[l+4>>2]=c[b+4>>2];c[l+8>>2]=c[b+8>>2];c[l+12>>2]=c[b+12>>2];m=f+32+52|0;c[m>>2]=c[d>>2];c[m+4>>2]=c[d+4>>2];c[m+8>>2]=c[d+8>>2];c[m+12>>2]=c[d+12>>2];c[f+32+212>>2]=a;c[f+32+216>>2]=e;c[f+32+68>>2]=1065353216;c[f+32+72>>2]=0;c[f+32+72+4>>2]=0;c[f+32+72+8>>2]=0;c[f+32+72+12>>2]=0;c[f+32+88>>2]=1065353216;c[f+32+92>>2]=0;c[f+32+92+4>>2]=0;c[f+32+92+8>>2]=0;c[f+32+92+12>>2]=0;c[f+32+108>>2]=1065353216;c[f+32+112>>2]=0;c[f+32+116>>2]=c[l>>2];c[f+32+116+4>>2]=c[l+4>>2];c[f+32+116+8>>2]=c[l+8>>2];c[f+32+116+12>>2]=c[l+12>>2];c[f+32+132>>2]=1065353216;c[f+32+136>>2]=0;c[f+32+136+4>>2]=0;c[f+32+136+8>>2]=0;c[f+32+136+12>>2]=0;c[f+32+152>>2]=1065353216;c[f+32+156>>2]=0;c[f+32+156+4>>2]=0;c[f+32+156+8>>2]=0;c[f+32+156+12>>2]=0;c[f+32+172>>2]=1065353216;c[f+32+176>>2]=0;c[f+32+180>>2]=c[d>>2];c[f+32+180+4>>2]=c[d+4>>2];c[f+32+180+8>>2]=c[d+8>>2];c[f+32+180+12>>2]=c[d+12>>2];n=+g[d>>2]-+g[b>>2];k=+g[d+4>>2]-+g[b+4>>2];j=+g[d+8>>2]-+g[b+8>>2];h=1.0/+O(+(n*n+k*k+j*j));q=n*h==0.0?1000000015047466219876688.0e6:1.0/(n*h);g[f+32+4>>2]=q;p=k*h==0.0?1000000015047466219876688.0e6:1.0/(k*h);g[f+32+8>>2]=p;o=j*h==0.0?1000000015047466219876688.0e6:1.0/(j*h);g[f+32+12>>2]=o;c[f+32+20>>2]=q<0.0&1;c[f+32+24>>2]=p<0.0&1;c[f+32+28>>2]=o<0.0&1;g[f+32+32>>2]=n*h*(+g[m>>2]-+g[l>>2])+k*h*(+g[f+32+56>>2]-+g[f+32+40>>2])+j*h*(+g[f+32+60>>2]-+g[f+32+44>>2]);a=c[a+68>>2]|0;e=c[(c[a>>2]|0)+24>>2]|0;c[f+16>>2]=0;c[f+16+4>>2]=0;c[f+16+8>>2]=0;c[f+16+12>>2]=0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;Qb[e&7](a,b,d,f+32|0,f+16|0,f);b=c[2357]|0;a=(c[b+16>>2]|0)+-1|0;c[b+16>>2]=a;if(a|0){i=f;return}do if(c[b+4>>2]|0){tb(f+32|0,0)|0;m=c[6434]|0;g[b+8>>2]=+g[b+8>>2]+ +(((c[f+32+4>>2]|0)-(c[m+4>>2]|0)+(((c[f+32>>2]|0)-(c[m>>2]|0)|0)*1e6|0)-(c[b+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[b+16>>2]|0)){b=c[2357]|0;break}else{i=f;return}}while(0);c[2357]=c[b+20>>2];i=f;return}function hf(b,d){b=b|0;d=+d;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0.0;s=i;i=i+16|0;li(12002);e=c[b+232>>2]|0;if((e|0)>0){r=0;do{q=c[(c[b+240>>2]|0)+(r<<2)>>2]|0;if(!(c[q+204>>2]&3)){n=+g[q+444>>2];f=+P(+(1.0-n),+d);j=f*+g[q+312>>2];g[q+312>>2]=j;h=f*+g[q+316>>2];g[q+316>>2]=h;f=f*+g[q+320>>2];g[q+320>>2]=f;p=+g[q+448>>2];m=+P(+(1.0-p),+d);k=m*+g[q+328>>2];g[q+328>>2]=k;l=m*+g[q+332>>2];g[q+332>>2]=l;m=m*+g[q+336>>2];g[q+336>>2]=m;do if(a[q+452>>0]|0){if(m*m+(k*k+l*l)<+g[q+464>>2]?j*j+h*h+f*f<+g[q+460>>2]:0){t=+g[q+456>>2];g[q+328>>2]=k*t;g[q+332>>2]=t*l;g[q+336>>2]=t*m;g[q+312>>2]=t*j;g[q+316>>2]=t*h;g[q+320>>2]=t*f;f=t*f;o=k*t;l=t*l;m=t*m;j=t*j;h=t*h}else o=k;k=+O(+(j*j+h*h+f*f));do if(k.004999999888241291){j=j-j*(1.0/k)*.004999999888241291;g[q+312>>2]=j;h=h-h*(1.0/k)*.004999999888241291;g[q+316>>2]=h;f=f-f*(1.0/k)*.004999999888241291;g[q+320>>2]=f;break}else{c[q+312>>2]=0;c[q+312+4>>2]=0;c[q+312+8>>2]=0;c[q+312+12>>2]=0;j=0.0;h=0.0;f=0.0;break}while(0);k=+O(+(o*o+l*l+m*m));if(k.004999999888241291){g[q+328>>2]=o-o*(1.0/k)*.004999999888241291;g[q+332>>2]=l-l*(1.0/k)*.004999999888241291;g[q+336>>2]=m-m*(1.0/k)*.004999999888241291;break}else{c[q+328>>2]=0;c[q+328+4>>2]=0;c[q+328+8>>2]=0;c[q+328+12>>2]=0;break}}while(0);Zg(q+4|0,j,h,f,q+328|0,d,q+68|0);e=c[b+232>>2]|0}r=r+1|0}while((r|0)<(e|0))}e=c[2357]|0;b=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=b;if(b|0){i=s;return}do if(c[e+4>>2]|0){tb(s|0,0)|0;b=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[s+4>>2]|0)-(c[b+4>>2]|0)+(((c[s>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[e+16>>2]|0)){e=c[2357]|0;break}else{i=s;return}}while(0);c[2357]=c[e+20>>2];i=s;return}function jf(a,d,f){a=a|0;d=d|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;g=c[a+108>>2]|0;if(g|0)ic[c[(c[g>>2]|0)+12>>2]&127](g,c[d+60>>2]|0,f);q=c[d+12>>2]|0;p=c[a+60>>2]|0;o=c[a+92>>2]|0;if(!(Eb[c[(c[o>>2]|0)+56>>2]&127](o)|0)){o=c[a+92>>2]|0;ic[c[(c[o>>2]|0)+16>>2]&127](o,p+((q&65535)<<6)|0,f)}m=e[a+56>>1]|0;g=c[a+60>>2]|0;b[g+54>>1]=(e[g+54>>1]|0)+65534;b[g+56>>1]=(e[g+56>>1]|0)+65534;b[g+58>>1]=(e[g+58>>1]|0)+65534;g=b[a+6>>1]|0;o=0;do{l=a+68+(o<<2)|0;n=c[l>>2]|0;f=e[p+((q&65535)<<6)+54+(o<<1)>>1]|0;b[n+(f<<2)>>1]=g;d=b[n+(f<<2)+6>>1]|0;if(!(d<<16>>16))f=n;else{k=(c[a+60>>2]|0)+((e[n+(f<<2)+2>>1]|0)<<6)+54+(o<<1)|0;i=n+(f<<2)|0;while(1){j=i;i=i+4|0;h=b[i>>1]|0;if((g&65535)<(h&65535))break;f=c[a+60>>2]|0;g=d&65535;if(!(h&1)){h=f+(g<<6)+48+(o<<1)|0;b[h>>1]=(b[h>>1]|0)+-1<<16>>16}else{h=f+(g<<6)+54+(o<<1)|0;b[h>>1]=(b[h>>1]|0)+-1<<16>>16}b[k>>1]=(b[k>>1]|0)+1<<16>>16;g=e[j>>1]|e[j+2>>1]<<16;d=e[i>>1]|e[i+2>>1]<<16;b[j>>1]=d;b[j+2>>1]=d>>>16;b[i>>1]=g;b[i+2>>1]=g>>>16;d=b[j+10>>1]|0;if(!(d<<16>>16))break;else g=g&65535}g=b[a+6>>1]|0;f=c[l>>2]|0}d=e[p+((q&65535)<<6)+48+(o<<1)>>1]|0;b[n+(d<<2)>>1]=g;i=f+(d<<2)|0;h=b[i+6>>1]|0;if(h<<16>>16){k=(c[a+60>>2]|0)+((e[f+(d<<2)+2>>1]|0)<<6)+48+(o<<1)|0;g=b[i>>1]|0;while(1){j=i;i=i+4|0;f=b[i>>1]|0;if((g&65535)<(f&65535))break;d=c[a+60>>2]|0;g=h&65535;if(!(f&1)){l=d+(g<<6)+48+(o<<1)|0;b[l>>1]=(b[l>>1]|0)+-1<<16>>16}else{l=d+(g<<6)+54+(o<<1)|0;b[l>>1]=(b[l>>1]|0)+-1<<16>>16}b[k>>1]=(b[k>>1]|0)+1<<16>>16;g=e[j>>1]|e[j+2>>1]<<16;h=e[i>>1]|e[i+2>>1]<<16;b[j>>1]=h;b[j+2>>1]=h>>>16;b[i>>1]=g;b[i+2>>1]=g>>>16;h=b[j+10>>1]|0;if(!(h<<16>>16))break;else g=g&65535}g=b[a+6>>1]|0}b[n+((m<<1)+-1<<2)+2>>1]=0;b[n+((m<<1)+-1<<2)>>1]=g;o=o+1|0}while((o|0)!=3);b[(c[a+60>>2]|0)+((q&65535)<<6)+48>>1]=b[a+64>>1]|0;b[a+64>>1]=q;b[a+56>>1]=(b[a+56>>1]|0)+-1<<16>>16;return}function kf(b){b=b|0;var d=0,e=0;c[b>>2]=5224;if(a[b+20>>0]|0){d=c[b+16>>2]|0;e=c[d+16>>2]|0;if(e){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[b+16>>2]|0}if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}}if(a[b+12>>0]|0){d=c[b+8>>2]|0;e=c[d+16>>2]|0;if(e){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[b+8>>2]|0}if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}}d=c[b+32>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+32>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+36>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+36>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+40>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+40>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+44>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+44>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+48>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+48>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+52>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+52>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+56>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+56>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+60>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+60>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+76>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+76>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+80>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+80>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+72>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+72>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+88>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+88>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+84>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+84>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+24>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+28>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+28>>2]|0;if(!d)return;c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);return}function lf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0.0;if(!(c[a>>2]|0)){c[a>>2]=d;c[d+32>>2]=0;return}e=c[b+40>>2]|0;if(!e)o=b;else{k=+g[d>>2]+ +g[d+16>>2];i=+g[d+4>>2]+ +g[d+20>>2];j=+g[d+8>>2]+ +g[d+24>>2];do{p=c[b+36>>2]|0;n=+N(+(k-(+g[p>>2]+ +g[p+16>>2])))+ +N(+(i-(+g[p+4>>2]+ +g[p+20>>2])))+ +N(+(j-(+g[p+8>>2]+ +g[p+24>>2])));b=c[b+36+((!(n<+N(+(k-(+g[e>>2]+ +g[e+16>>2])))+ +N(+(i-(+g[e+4>>2]+ +g[e+20>>2])))+ +N(+(j-(+g[e+8>>2]+ +g[e+24>>2]))))&1)<<2)>>2]|0;e=c[b+40>>2]|0}while((e|0)!=0);o=b}p=o+32|0;e=c[p>>2]|0;b=c[a+4>>2]|0;if(!b){c[6435]=(c[6435]|0)+1;b=yc(63)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}f=b;h=f+44|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(h|0))}else c[a+4>>2]=0;c[b+32>>2]=e;c[b+36>>2]=0;f=b+40|0;c[f>>2]=0;q=+g[d>>2];n=+g[o>>2];n=q>2]=n;q=+g[d+16>>2];k=+g[o+16>>2];k=q>k?q:k;g[b+16>>2]=k;q=+g[d+4>>2];m=+g[o+4>>2];m=q>2]=m;q=+g[d+20>>2];j=+g[o+20>>2];j=q>j?q:j;g[b+20>>2]=j;q=+g[d+8>>2];l=+g[o+8>>2];l=q>2]=l;q=+g[d+24>>2];i=+g[o+24>>2];i=q>i?q:i;g[b+24>>2]=i;if(!e){c[b+36>>2]=o;c[p>>2]=b;c[f>>2]=d;c[d+32>>2]=b;c[a>>2]=b;return}c[e+36+(((c[(c[p>>2]|0)+40>>2]|0)==(o|0)&1)<<2)>>2]=b;c[b+36>>2]=o;c[p>>2]=b;c[f>>2]=d;c[d+32>>2]=b;while(1){b=e+4|0;if(((((+g[e>>2]<=n?+g[b>>2]<=m:0)?+g[e+8>>2]<=l:0)?+g[e+16>>2]>=k:0)?+g[e+20>>2]>=j:0)?+g[e+24>>2]>=i:0){b=21;break}d=c[e+36>>2]|0;a=c[e+40>>2]|0;q=+g[d>>2];n=+g[a>>2];n=q>2]=n;q=+g[d+16>>2];k=+g[a+16>>2];k=q>k?q:k;g[e+16>>2]=k;q=+g[d+4>>2];m=+g[a+4>>2];m=q>2]=m;q=+g[d+20>>2];j=+g[a+20>>2];j=q>j?q:j;g[e+20>>2]=j;q=+g[d+8>>2];l=+g[a+8>>2];l=q>2]=l;q=+g[d+24>>2];i=+g[a+24>>2];i=q>i?q:i;g[e+24>>2]=i;e=c[e+32>>2]|0;if(!e){b=21;break}}if((b|0)==21)return}function mf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;c[b+16>>2]=c[a+4>>2];c[b+20>>2]=c[a+8>>2];c[b+24>>2]=c[a+12>>2];c[b+28>>2]=c[a+16>>2];c[b+32>>2]=c[a+20>>2];c[b+36>>2]=c[a+24>>2];c[b+40>>2]=c[a+28>>2];c[b+44>>2]=c[a+32>>2];c[b+48>>2]=c[a+36>>2];c[b+52>>2]=c[a+40>>2];c[b+56>>2]=c[a+44>>2];c[b+60>>2]=c[a+48>>2];c[b+64>>2]=c[a+52>>2];c[b+68>>2]=c[a+56>>2];c[b+72>>2]=c[a+60>>2];c[b+76>>2]=c[a+64>>2];c[b+80>>2]=c[a+68>>2];c[b+84>>2]=c[a+72>>2];c[b+88>>2]=c[a+76>>2];c[b+92>>2]=c[a+80>>2];c[b+96>>2]=c[a+84>>2];c[b+100>>2]=c[a+88>>2];c[b+104>>2]=c[a+92>>2];c[b+108>>2]=c[a+96>>2];c[b+112>>2]=c[a+100>>2];c[b+116>>2]=c[a+104>>2];c[b+120>>2]=c[a+108>>2];c[b+124>>2]=c[a+112>>2];c[b+128>>2]=c[a+116>>2];c[b+132>>2]=c[a+120>>2];c[b+136>>2]=c[a+124>>2];c[b+140>>2]=c[a+128>>2];c[b+144>>2]=c[a+132>>2];c[b+148>>2]=c[a+136>>2];c[b+152>>2]=c[a+140>>2];c[b+156>>2]=c[a+144>>2];c[b+160>>2]=c[a+148>>2];c[b+164>>2]=c[a+152>>2];c[b+168>>2]=c[a+156>>2];c[b+172>>2]=c[a+160>>2];c[b+176>>2]=c[a+164>>2];c[b+180>>2]=c[a+168>>2];c[b+184>>2]=c[a+172>>2];c[b+188>>2]=c[a+176>>2];c[b+224>>2]=c[a+180>>2];c[b+192>>2]=c[a+184>>2];c[b>>2]=0;c[b+4>>2]=Zb[c[(c[d>>2]|0)+28>>2]&31](d,c[a+192>>2]|0)|0;c[b+8>>2]=0;c[b+228>>2]=c[a+204>>2];c[b+232>>2]=c[a+208>>2];c[b+236>>2]=c[a+212>>2];c[b+240>>2]=c[a+216>>2];c[b+196>>2]=c[a+220>>2];c[b+200>>2]=c[a+224>>2];c[b+204>>2]=c[a+232>>2];c[b+208>>2]=c[a+228>>2];c[b+244>>2]=c[a+236>>2];e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b+12>>2]=f;if(!f){d=a+244|0;d=c[d>>2]|0;f=b+212|0;c[f>>2]=d;f=a+248|0;f=c[f>>2]|0;d=b+216|0;c[d>>2]=f;d=a+252|0;d=c[d>>2]|0;f=b+220|0;c[f>>2]=d;a=a+256|0;a=c[a>>2]|0;f=b+248|0;c[f>>2]=a;return 13172}Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);d=a+244|0;d=c[d>>2]|0;f=b+212|0;c[f>>2]=d;f=a+248|0;f=c[f>>2]|0;d=b+216|0;c[d>>2]=f;d=a+252|0;d=c[d>>2]|0;f=b+220|0;c[f>>2]=d;a=a+256|0;a=c[a>>2]|0;f=b+248|0;c[f>>2]=a;return 13172}function nf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0;q=c[b+9288>>2]|0;if(!q){c[b>>2]=5;b=0;return b|0}i=c[q+48>>2]|0;if(i|0)c[i+44>>2]=c[q+44>>2];i=c[q+44>>2]|0;if(i|0)c[i+48>>2]=c[q+48>>2];if((c[b+9288>>2]|0)==(q|0))c[b+9288>>2]=c[q+48>>2];c[b+9292>>2]=(c[b+9292>>2]|0)+-1;c[q+44>>2]=0;c[q+48>>2]=c[b+9280>>2];i=c[b+9280>>2]|0;if(i|0)c[i+44>>2]=q;c[b+9280>>2]=q;c[b+9284>>2]=(c[b+9284>>2]|0)+1;a[q+55>>0]=0;c[q+20>>2]=d;c[q+24>>2]=e;c[q+28>>2]=f;m=+g[d+16>>2];j=+g[e+16>>2]-m;n=+g[d+20>>2];k=+g[e+20>>2]-n;o=+g[d+24>>2];l=+g[e+24>>2]-o;m=+g[f+16>>2]-m;n=+g[f+20>>2]-n;o=+g[f+24>>2]-o;g[q>>2]=k*o-l*n;g[q+4>>2]=l*m-j*o;g[q+8>>2]=j*n-k*m;g[q+12>>2]=0.0;p=+O(+((k*o-l*n)*(k*o-l*n)+(l*m-j*o)*(l*m-j*o)+(j*n-k*m)*(j*n-k*m)));do if(p>9.999999747378752e-05){if((!($k(k*o-l*n,l*m-j*o,j*n-k*m,+g[d+16>>2],+g[d+20>>2],+g[d+24>>2],+g[e+16>>2],+g[e+20>>2],+g[e+24>>2],q+16|0)|0)?!($k(+g[q>>2],+g[q+4>>2],+g[q+8>>2],+g[e+16>>2],+g[e+20>>2],+g[e+24>>2],+g[f+16>>2],+g[f+20>>2],+g[f+24>>2],q+16|0)|0):0)?!($k(+g[q>>2],+g[q+4>>2],+g[q+8>>2],+g[f+16>>2],+g[f+20>>2],+g[f+24>>2],+g[d+16>>2],+g[d+20>>2],+g[d+24>>2],q+16|0)|0):0)g[q+16>>2]=(+g[d+16>>2]*+g[q>>2]+ +g[d+20>>2]*+g[q+4>>2]+ +g[d+24>>2]*+g[q+8>>2])/p;g[q>>2]=1.0/p*+g[q>>2];g[q+4>>2]=1.0/p*+g[q+4>>2];g[q+8>>2]=1.0/p*+g[q+8>>2];if(h){b=q;return b|0}if(!(+g[q+16>>2]>=-9.999999747378752e-06)){c[b>>2]=3;break}else{b=q;return b|0}}else c[b>>2]=2;while(0);i=c[q+48>>2]|0;if(i|0)c[i+44>>2]=c[q+44>>2];i=c[q+44>>2]|0;if(i|0)c[i+48>>2]=c[q+48>>2];if((c[b+9280>>2]|0)==(q|0))c[b+9280>>2]=c[q+48>>2];c[b+9284>>2]=(c[b+9284>>2]|0)+-1;c[q+44>>2]=0;c[q+48>>2]=c[b+9288>>2];i=c[b+9288>>2]|0;if(i|0)c[i+44>>2]=q;c[b+9288>>2]=q;c[b+9292>>2]=(c[b+9292>>2]|0)+1;b=0;return b|0}function of(a,b,f){a=a|0;b=b|0;f=f|0;var j=0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=i;i=i+32|0;o=c[a+4>>2]|0;Yb[c[(c[o>>2]|0)+16>>2]&3](o,t+28|0,t+24|0,t+20|0,t+16|0,t+12|0,t+8|0,t+4|0,t,b);o=(c[t+12>>2]|0)+(_(c[t+8>>2]|0,f)|0)|0;s=c[a+4>>2]|0;n=c[t>>2]|0;switch(n|0){case 3:{j=e[o+4>>1]|0;break}case 2:{j=c[o+8>>2]|0;break}default:j=d[o+2>>0]|0}r=(c[t+20>>2]|0)==0;p=c[t+28>>2]|0;q=c[t+16>>2]|0;j=p+(_(q,j)|0)|0;if(r){l=+g[j+8>>2]*+g[s+12>>2];m=+g[j+4>>2]*+g[s+8>>2];k=+g[j>>2]*+g[s+4>>2]}else{l=+h[j+16>>3]*+g[s+12>>2];m=+h[j+8>>3]*+g[s+8>>2];k=+h[j>>3]*+g[s+4>>2]}g[a+44>>2]=k;g[a+48>>2]=m;g[a+52>>2]=l;g[a+56>>2]=0.0;switch(n|0){case 3:{j=e[o+2>>1]|0;break}case 2:{j=c[o+4>>2]|0;break}default:j=d[o+1>>0]|0}j=p+(_(q,j)|0)|0;if(r){l=+g[j+8>>2]*+g[s+12>>2];m=+g[j+4>>2]*+g[s+8>>2];k=+g[j>>2]*+g[s+4>>2]}else{l=+h[j+16>>3]*+g[s+12>>2];m=+h[j+8>>3]*+g[s+8>>2];k=+h[j>>3]*+g[s+4>>2]}g[a+28>>2]=k;g[a+32>>2]=m;g[a+36>>2]=l;g[a+40>>2]=0.0;switch(n|0){case 3:{j=e[o>>1]|0;break}case 2:{j=c[o>>2]|0;break}default:j=d[o>>0]|0}j=p+(_(q,j)|0)|0;if(r){m=+g[j+8>>2]*+g[s+12>>2];l=+g[j+4>>2]*+g[s+8>>2];k=+g[j>>2]*+g[s+4>>2];r=a+12|0;g[r>>2]=k;r=a+16|0;g[r>>2]=l;r=a+20|0;g[r>>2]=m;r=a+24|0;g[r>>2]=0.0;r=a+8|0;r=c[r>>2]|0;q=c[r>>2]|0;q=q+8|0;q=c[q>>2]|0;s=a+12|0;mc[q&127](r,s,b,f);a=c[a+4>>2]|0;f=c[a>>2]|0;f=f+24|0;f=c[f>>2]|0;Cb[f&127](a,b);i=t;return}else{m=+h[j+16>>3]*+g[s+12>>2];l=+h[j+8>>3]*+g[s+8>>2];k=+h[j>>3]*+g[s+4>>2];r=a+12|0;g[r>>2]=k;r=a+16|0;g[r>>2]=l;r=a+20|0;g[r>>2]=m;r=a+24|0;g[r>>2]=0.0;r=a+8|0;r=c[r>>2]|0;q=c[r>>2]|0;q=q+8|0;q=c[q>>2]|0;s=a+12|0;mc[q&127](r,s,b,f);a=c[a+4>>2]|0;f=c[a>>2]|0;f=f+24|0;f=c[f>>2]|0;Cb[f&127](a,b);i=t;return}}function pf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c[6435]=(c[6435]|0)+1;f=yc(479)|0;if(!f)s=0;else{c[(f+4+15&-16)+-4>>2]=f;s=f+4+15&-16}je(s,b,d,e);c[s>>2]=3872;a[s+340>>0]=1;c[s+336>>2]=0;c[s+328>>2]=0;c[s+332>>2]=0;k=s+352|0;g[k>>2]=1.2000000476837158;l=s+356|0;g[l>>2]=0.0;m=s+360|0;g[m>>2]=0.0;g[s+364>>2]=1.0e3;n=s+368|0;o=s+396|0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;c[n+16>>2]=0;c[n+20>>2]=0;c[n+24>>2]=0;c[o>>2]=-1054867456;p=s+400|0;c[p>>2]=0;q=s+404|0;g[q>>2]=0.0;a[s+424>>0]=1;r=s+420|0;c[r>>2]=0;j=s+412|0;c[j>>2]=0;c[s+416>>2]=0;e=s+452|0;c[e>>2]=h;i=s+456|0;a[i>>0]=0;if(!h){c[6435]=(c[6435]|0)+1;f=yc(59)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}g[f+12>>2]=1.0;c[f+8>>2]=0;c[f+4>>2]=5;c[f>>2]=2996;a[f+36>>0]=1;c[f+32>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;a[f+16>>0]=1;c[e>>2]=f;a[i>>0]=1}c[s+344>>2]=4302;a[s+348>>0]=1;a[s+349>>0]=0;a[s+350>>0]=0;c[s+384>>2]=d;c[s+388>>2]=b;h=s+408|0;Ji(h);e=c[j>>2]|0;if((e|0)>0)i=0;else{r=s+428|0;g[r>>2]=.25;r=s+432|0;c[r>>2]=0;r=s+436|0;c[r>>2]=0;r=s+444|0;c[r>>2]=1;r=s+448|0;c[r>>2]=1;g[k>>2]=1.2000000476837158;g[l>>2]=0.0;g[m>>2]=0.0;r=s+392|0;c[r>>2]=0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;c[o>>2]=-1054867456;c[p>>2]=0;g[q>>2]=0.0;Ji(h);return s|0}do{d=(c[r>>2]|0)+(i<<2)|0;f=c[d>>2]|0;c[d>>2]=0;if(f|0)do{d=f;f=c[f+280>>2]|0;hd(d)}while((f|0)!=0);i=i+1|0}while((i|0)!=(e|0));r=s+428|0;g[r>>2]=.25;r=s+432|0;c[r>>2]=0;r=s+436|0;c[r>>2]=0;r=s+444|0;c[r>>2]=1;r=s+448|0;c[r>>2]=1;g[k>>2]=1.2000000476837158;g[l>>2]=0.0;g[m>>2]=0.0;r=s+392|0;c[r>>2]=0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;c[o>>2]=-1054867456;c[p>>2]=0;g[q>>2]=0.0;Ji(h);return s|0}function qf(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0,h=0,i=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0;j=c[a+28>>2]|0;k=c[a+32>>2]|0;f=c[b+8>>2]|0;g[f>>2]=1.0;h=c[b+24>>2]|0;g[f+(h+1<<2)>>2]=1.0;g[f+((h<<1)+2<<2)>>2]=1.0;l=+g[a+300>>2];q=+g[a+304>>2];e=+g[a+308>>2];o=+g[j+4>>2]*l+ +g[j+8>>2]*q+ +g[j+12>>2]*e;m=l*+g[j+20>>2]+q*+g[j+24>>2]+e*+g[j+28>>2];e=l*+g[j+36>>2]+q*+g[j+40>>2]+e*+g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a+340>>2]}e=+g[a+356>>2];if(e>0.0){g[c[b+36>>2]>>2]=-e;g[c[b+40>>2]>>2]=e;d=+g[a+356>>2]}else d=e;if(d>0.0){k=c[b+24>>2]|0;g[(c[b+36>>2]|0)+(k<<2)>>2]=-e;g[(c[b+40>>2]|0)+(k<<2)>>2]=e;d=+g[a+356>>2]}if(!(d>0.0)){j=a+352|0;j=c[j>>2]|0;k=b+52|0;c[k>>2]=j;return}j=c[b+24>>2]<<1;g[(c[b+36>>2]|0)+(j<<2)>>2]=-e;g[(c[b+40>>2]|0)+(j<<2)>>2]=e;j=a+352|0;j=c[j>>2]|0;k=b+52|0;c[k>>2]=j;return}function rf(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,l=0,m=0;f=c[d+8>>2]|0;if((f|0)>0){h=c[d+16>>2]|0;j=0;e=0;do{i=c[h+(j<<2)>>2]|0;if(!(c[i+204>>2]&3)){c[i+208>>2]=e;e=e+1|0}c[i+212>>2]=-1;g[i+244>>2]=1.0;j=j+1|0}while((j|0)!=(f|0));j=e}else j=0;i=c[b+8>>2]|0;if((i|0)<(j|0)){if((c[b+12>>2]|0)<(j|0)){if(!j){e=0;f=i}else{c[6435]=(c[6435]|0)+1;e=yc((j<<3|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[b+8>>2]|0}if((f|0)>0){h=0;do{m=(c[b+16>>2]|0)+(h<<3)|0;k=c[m+4>>2]|0;l=e+(h<<3)|0;c[l>>2]=c[m>>2];c[l+4>>2]=k;h=h+1|0}while((h|0)!=(f|0))}f=c[b+16>>2]|0;if(f|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=e;c[b+12>>2]=j;f=b+16|0}else f=b+16|0;e=i;do{m=(c[f>>2]|0)+(e<<3)|0;c[m>>2]=0;c[m+4>>2]=0;e=e+1|0}while((e|0)!=(j|0))}c[b+8>>2]=j;if((j|0)>0){e=c[b+16>>2]|0;f=0;do{c[e+(f<<3)>>2]=f;c[e+(f<<3)+4>>2]=1;f=f+1|0}while((f|0)!=(j|0))}e=c[d+68>>2]|0;e=Eb[c[(c[e>>2]|0)+36>>2]&127](e)|0;l=Eb[c[(c[e>>2]|0)+36>>2]&127](e)|0;if(!l)return;d=Eb[c[(c[e>>2]|0)+20>>2]&127](e)|0;if((l|0)<=0)return;k=0;do{e=c[c[d+(k<<4)>>2]>>2]|0;f=c[c[d+(k<<4)+4>>2]>>2]|0;if((e|0?(f|0?(c[e+204>>2]&7|0)==0:0):0)?(c[f+204>>2]&7|0)==0:0){i=c[e+208>>2]|0;e=c[f+208>>2]|0;j=c[b+16>>2]|0;f=c[j+(i<<3)>>2]|0;if((f|0)!=(i|0)){h=j+(i<<3)|0;do{i=j+(f<<3)|0;c[h>>2]=c[i>>2];i=c[i>>2]|0;h=j+(i<<3)|0;f=c[h>>2]|0}while((i|0)!=(f|0))}f=c[j+(e<<3)>>2]|0;if((f|0)!=(e|0)){h=j+(e<<3)|0;do{e=j+(f<<3)|0;c[h>>2]=c[e>>2];e=c[e>>2]|0;h=j+(e<<3)|0;f=c[h>>2]|0}while((e|0)!=(f|0))}if((i|0)!=(e|0)){c[j+(i<<3)>>2]=e;m=j+(e<<3)+4|0;c[m>>2]=(c[m>>2]|0)+(c[j+(i<<3)+4>>2]|0)}}k=k+1|0}while((k|0)!=(l|0));return}function sf(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;a:do if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)==(e|0)?(c[d+28>>2]|0)!=1:0)c[d+28>>2]=f}else{if((b|0)!=(c[d>>2]|0)){i=c[b+12>>2]|0;$n(b+16|0,d,e,f,g);if((i|0)<=1)break;h=c[b+8>>2]|0;if((h&2|0)==0?(c[d+36>>2]|0)!=1:0){if(!(h&1)){h=b+24|0;while(1){if(a[d+54>>0]|0)break a;if((c[d+36>>2]|0)==1)break a;$n(h,d,e,f,g);h=h+8|0;if(h>>>0>=(b+16+(i<<3)|0)>>>0)break a}}h=b+24|0;while(1){if(a[d+54>>0]|0)break a;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==1:0)break a;$n(h,d,e,f,g);h=h+8|0;if(h>>>0>=(b+16+(i<<3)|0)>>>0)break a}}h=b+24|0;while(1){if(a[d+54>>0]|0)break a;$n(h,d,e,f,g);h=h+8|0;if(h>>>0>=(b+16+(i<<3)|0)>>>0)break a}}if((c[d+16>>2]|0)!=(e|0)?(c[d+20>>2]|0)!=(e|0):0){c[d+32>>2]=f;if((c[d+44>>2]|0)==4)break;f=b+16+(c[b+12>>2]<<3)|0;k=0;h=0;j=b+16|0;b:while(1){if(j>>>0>=f>>>0){i=20;break}a[d+52>>0]=0;a[d+53>>0]=0;On(j,d,e,e,1,g);if(a[d+54>>0]|0){i=20;break}do if(a[d+53>>0]|0){if(!(a[d+52>>0]|0))if(!(c[b+8>>2]&1)){h=1;i=20;break b}else{i=k;h=1;break}if((c[d+24>>2]|0)==1){i=25;break b}if(!(c[b+8>>2]&2)){i=25;break b}else{i=1;h=1}}else i=k;while(0);k=i;j=j+8|0}do if((i|0)==20){if((!k?(c[d+20>>2]=e,c[d+40>>2]=(c[d+40>>2]|0)+1,(c[d+36>>2]|0)==1):0)?(c[d+24>>2]|0)==2:0){a[d+54>>0]=1;if(h){i=25;break}else{h=4;break}}if(h)i=25;else h=4}while(0);if((i|0)==25)h=3;c[d+44>>2]=h;break}if((f|0)==1)c[d+32>>2]=1}while(0);return}function tf(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0,j=0;c[6435]=(c[6435]|0)+1;i=yc(1147)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}c[i+4>>2]=7;c[i+8>>2]=-1;c[i+12>>2]=-1;g[i+16>>2]=3402823466385288598117041.0e14;a[i+20>>0]=1;a[i+21>>0]=0;c[i+24>>2]=-1;j=i+28|0;c[j>>2]=b;b=i+32|0;c[b>>2]=d;g[i+36>>2]=0.0;g[i+40>>2]=.30000001192092896;c[i+44>>2]=0;c[i>>2]=4596;a[i+48>>0]=0;d=i+52|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];d=i+68|0;c[d>>2]=c[e+16>>2];c[d+4>>2]=c[e+16+4>>2];c[d+8>>2]=c[e+16+8>>2];c[d+12>>2]=c[e+16+12>>2];d=i+84|0;c[d>>2]=c[e+32>>2];c[d+4>>2]=c[e+32+4>>2];c[d+8>>2]=c[e+32+8>>2];c[d+12>>2]=c[e+32+12>>2];d=i+100|0;c[d>>2]=c[e+48>>2];c[d+4>>2]=c[e+48+4>>2];c[d+8>>2]=c[e+48+8>>2];c[d+12>>2]=c[e+48+12>>2];e=i+116|0;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];e=i+132|0;c[e>>2]=c[f+16>>2];c[e+4>>2]=c[f+16+4>>2];c[e+8>>2]=c[f+16+8>>2];c[e+12>>2]=c[f+16+12>>2];e=i+148|0;c[e>>2]=c[f+32>>2];c[e+4>>2]=c[f+32+4>>2];c[e+8>>2]=c[f+32+8>>2];c[e+12>>2]=c[f+32+12>>2];e=i+164|0;c[e>>2]=c[f+48>>2];c[e+4>>2]=c[f+48+4>>2];c[e+8>>2]=c[f+48+8>>2];c[e+12>>2]=c[f+48+12>>2];a[i+180>>0]=h&1;g[i+184>>2]=1.0;g[i+188>>2]=-1.0;g[i+192>>2]=0.0;g[i+196>>2]=0.0;g[i+200>>2]=1.0;g[i+204>>2]=.699999988079071;g[i+208>>2]=0.0;g[i+212>>2]=0.0;g[i+216>>2]=1.0;g[i+220>>2]=.699999988079071;g[i+224>>2]=0.0;g[i+228>>2]=0.0;g[i+264>>2]=1.0;g[i+268>>2]=.699999988079071;g[i+272>>2]=1.0;g[i+276>>2]=0.0;g[i+280>>2]=1.0;g[i+284>>2]=.699999988079071;g[i+288>>2]=1.0;g[i+292>>2]=0.0;g[i+232>>2]=1.0;g[i+236>>2]=.699999988079071;g[i+240>>2]=1.0;g[i+244>>2]=0.0;g[i+248>>2]=1.0;g[i+252>>2]=.699999988079071;g[i+256>>2]=1.0;g[i+260>>2]=0.0;a[i+1096>>0]=0;h=i+1100|0;g[i+1116>>2]=0.0;g[i+1120>>2]=0.0;g[i+1124>>2]=0.0;c[i+300>>2]=0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;a[h+12>>0]=0;a[i+49>>0]=1;kd(i,(c[j>>2]|0)+4|0,(c[b>>2]|0)+4|0);return i|0}function uf(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c[6165]=(c[6165]|0)+1;g=c[d+24>>2]|0;if(!g){g=c[e+4>>2]|0;if(!((b[f+6>>1]&(g&65535))<<16>>16)){d=0;return d|0}if(!((b[f+4>>1]&(g>>>16&65535))<<16>>16)){d=0;return d|0}}else if(!(Ob[c[(c[g>>2]|0)+8>>2]&63](g,e,f)|0)){d=0;return d|0}l=(c[e+12>>2]|0)>(c[f+12>>2]|0);m=l?f:e;h=c[m+12>>2]|0;l=l?e:f;e=c[l+12>>2]|0;j=((e<<16|h)+~((e<<16|h)<<15)>>10^(e<<16|h)+~((e<<16|h)<<15))*9|0;j=(j>>6^j)+~((j>>6^j)<<11)>>16^(j>>6^j)+~((j>>6^j)<<11);k=c[d+12>>2]|0;g=c[(c[d+44>>2]|0)+((j&k+-1)<<2)>>2]|0;a:do if((g|0)!=-1){f=c[d+16>>2]|0;while(1){if((c[(c[f+(g<<4)>>2]|0)+12>>2]|0)==(h|0)?(c[(c[f+(g<<4)+4>>2]|0)+12>>2]|0)==(e|0):0)break;g=c[(c[d+64>>2]|0)+(g<<2)>>2]|0;if((g|0)==-1)break a}g=f+(g<<4)|0;if(g|0){d=g;return d|0}}while(0);i=c[d+8>>2]|0;if((i|0)==(k|0)){g=k|0?k<<1:1;if((k|0)<(g|0)){if(!g){e=0;f=k}else{c[6435]=(c[6435]|0)+1;e=yc((g<<4|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[d+8>>2]|0}if((f|0)>0){h=0;do{n=c[d+16>>2]|0;c[e+(h<<4)>>2]=c[n+(h<<4)>>2];c[e+(h<<4)+4>>2]=c[n+(h<<4)+4>>2];c[e+(h<<4)+8>>2]=c[n+(h<<4)+8>>2];c[e+(h<<4)+12>>2]=c[n+(h<<4)+12>>2];h=h+1|0}while((h|0)!=(f|0))}h=c[d+16>>2]|0;if(h){if(a[d+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);f=c[d+8>>2]|0}c[d+16>>2]=0}a[d+20>>0]=1;c[d+16>>2]=e;c[d+12>>2]=g}else{f=k;g=k}}else{f=i;g=k}c[d+8>>2]=f+1;f=c[d+16>>2]|0;e=c[d+72>>2]|0;if(e){Ob[c[(c[e>>2]|0)+8>>2]&63](e,m,l)|0;g=c[d+12>>2]|0}if((k|0)<(g|0)){Hf(d);g=(c[d+12>>2]|0)+-1&j}else g=j&k+-1;n=(c[m+12>>2]|0)<(c[l+12>>2]|0);c[f+(i<<4)>>2]=n?m:l;c[f+(i<<4)+4>>2]=n?l:m;c[f+(i<<4)+8>>2]=0;c[f+(i<<4)+8+4>>2]=0;n=(c[d+44>>2]|0)+(g<<2)|0;c[(c[d+64>>2]|0)+(i<<2)>>2]=c[n>>2];c[n>>2]=i;n=f+(i<<4)|0;return n|0}function vf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.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0.0;g[a+128>>2]=B*n+A*m+z*l;g[a+132>>2]=y*v*n+x*v*m+w*v*l;g[a+136>>2]=u*r*n+t*r*m+s*r*l;g[a+140>>2]=0.0;g[a+144>>2]=B*k+A*i+z*f;g[a+148>>2]=y*v*k+x*v*i+w*v*f;g[a+152>>2]=u*r*k+t*r*i+s*r*f;g[a+156>>2]=0.0;g[a+160>>2]=q*0.0+p*0.0+o*0.0+(q*j+p*h+o*e);g[a+164>>2]=n*0.0+m*0.0+l*0.0+(n*j+m*h+l*e);g[a+168>>2]=k*0.0+i*0.0+f*0.0+(k*j+i*h+f*e);g[a+172>>2]=0.0;sd(a,(c[a+28>>2]|0)+4|0,(c[a+32>>2]|0)+4|0);return}function wf(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0.0,l=0,m=0,n=0,o=0.0;n=i;i=i+16|0;c[6138]=(c[6138]|0)+1;if(!(c[b+4>>2]&2))f=4972;else{f=c[d+192>>2]|0;o=+cc[c[(c[f>>2]|0)+20>>2]&1](f,.019999999552965164);g[n+4>>2]=o;f=c[e+192>>2]|0;k=+cc[c[(c[f>>2]|0)+20>>2]&1](f,.019999999552965164);g[n>>2]=k;f=o>2]|0;o=+g[d+184>>2];k=+g[e+184>>2];k=o>2]|0;h=c[f+8>>2]|0;if(!h){if(c[b+4>>2]&4|0){b=0;i=n;return b|0}c[6435]=(c[6435]|0)+1;f=yc(791)|0;if(!f)l=0;else{c[(f+4+15&-16)+-4>>2]=f;l=f+4+15&-16}}else{l=c[f+12>>2]|0;c[f+12>>2]=c[l>>2];c[f+8>>2]=h+-1}c[l>>2]=1025;c[l+116>>2]=0;a[l+120>>0]=0;f=l+124|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;c[l+300>>2]=0;a[l+304>>0]=0;f=l+308|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;c[l+484>>2]=0;a[l+488>>0]=0;f=l+492|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;c[l+668>>2]=0;a[l+672>>0]=0;f=l+676|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+20>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;c[l+740>>2]=d;c[l+744>>2]=e;c[l+748>>2]=0;c[l+752>>2]=j;g[l+756>>2]=k;d=l;f=c[b+12>>2]|0;c[l+768>>2]=f;if((f|0)==(c[b+16>>2]|0)?(m=f|0?f<<1:1,(f|0)<(m|0)):0){if(!m)j=0;else{c[6435]=(c[6435]|0)+1;f=yc((m<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=f;f=c[b+12>>2]|0}if((f|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[b+20>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}h=c[b+20>>2]|0;if(h){if(a[b+24>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);f=c[b+12>>2]|0}c[b+20>>2]=0}a[b+24>>0]=1;c[b+20>>2]=j;c[b+16>>2]=m}c[(c[b+20>>2]|0)+(f<<2)>>2]=d;c[b+12>>2]=f+1;b=l;i=n;return b|0}function xf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0,x=0;w=i;i=i+32|0;s=c[a+12>>2]|0;t=+g[s+(((e+d|0)/2|0)*24|0)>>2];u=+g[s+(((e+d|0)/2|0)*24|0)+4>>2];v=+g[s+(((e+d|0)/2|0)*24|0)+8>>2];q=+g[s+(((e+d|0)/2|0)*24|0)+16>>2];r=c[s+(((e+d|0)/2|0)*24|0)+20>>2]|0;f=d;h=e;while(1){m=+g[b>>2];n=+g[b+4>>2];o=+g[b+8>>2];p=(t-m)*(t-m)+(u-n)*(u-n)+(v-o)*(v-o);a:while(1){j=+g[s+(f*24|0)+16>>2];do if(j!=q){if(!(j>2]-m;k=+g[s+(f*24|0)+4>>2]-n;l=+g[s+(f*24|0)+8>>2]-o;if(j*j+k*k+l*l!=p)if(j*j+k*k+l*l>2]|0)<(r|0))break;else break a}while(0);f=f+1|0}b:while(1){j=+g[s+(h*24|0)+16>>2];do if(q!=j){if(!(q>2]-m;k=+g[s+(h*24|0)+4>>2]-n;l=+g[s+(h*24|0)+8>>2]-o;if(p!=j*j+k*k+l*l)if(p>2]|0))break;else break b}while(0);h=h+-1|0}if((f|0)<=(h|0)){x=s+(f*24|0)|0;c[w>>2]=c[x>>2];c[w+4>>2]=c[x+4>>2];c[w+8>>2]=c[x+8>>2];c[w+12>>2]=c[x+12>>2];c[w+16>>2]=c[x+16>>2];c[w+20>>2]=c[x+20>>2];s=s+(h*24|0)|0;c[x>>2]=c[s>>2];c[x+4>>2]=c[s+4>>2];c[x+8>>2]=c[s+8>>2];c[x+12>>2]=c[s+12>>2];c[x+16>>2]=c[s+16>>2];c[x+20>>2]=c[s+20>>2];s=(c[a+12>>2]|0)+(h*24|0)|0;c[s>>2]=c[w>>2];c[s+4>>2]=c[w+4>>2];c[s+8>>2]=c[w+8>>2];c[s+12>>2]=c[w+12>>2];c[s+16>>2]=c[w+16>>2];c[s+20>>2]=c[w+20>>2];f=f+1|0;h=h+-1|0}if((f|0)>(h|0))break;s=c[a+12>>2]|0}if((h|0)>(d|0))xf(a,b,d,h);if((f|0)>=(e|0)){i=w;return}xf(a,b,f,e);i=w;return}function yf(a,b,d){a=a|0;b=+b;d=+d;var e=0.0,f=0,h=0,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2];g[u+8>>2]=m+w*d;g[u+12>>2]=o+w*e;g[u+16>>2]=w*v+p;h=c[x+8>>2]|0;u=n+(y*56|0)+52|0;w=+g[u>>2]*+g[i>>2];g[h+8>>2]=+g[h+8>>2]-d*w;g[h+12>>2]=+g[h+12>>2]-e*w;g[h+16>>2]=+g[h+16>>2]-v*w;i=c[x+12>>2]|0;w=+g[u>>2]*+g[j>>2];g[i+8>>2]=+g[i+8>>2]-d*w;g[i+12>>2]=+g[i+12>>2]-e*w;g[i+16>>2]=+g[i+16>>2]-v*w;x=c[x+16>>2]|0;w=+g[u>>2]*+g[l>>2];g[x+8>>2]=+g[x+8>>2]-d*w;g[x+12>>2]=+g[x+12>>2]-e*w;g[x+16>>2]=+g[x+16>>2]-v*w;y=y+1|0}while((y|0)!=(z|0));return}function zf(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c[6164]=(c[6164]|0)+1;j=(c[b+12>>2]|0)>(c[d+12>>2]|0);l=j?d:b;h=c[l+12>>2]|0;j=j?b:d;f=c[j+12>>2]|0;i=((f<<16|h)+~((f<<16|h)<<15)>>10^(f<<16|h)+~((f<<16|h)<<15))*9|0;i=((i>>6^i)+~((i>>6^i)<<11)>>16^(i>>6^i)+~((i>>6^i)<<11))&(c[a+12>>2]|0)+-1;b=c[(c[a+44>>2]|0)+(i<<2)>>2]|0;if((b|0)==-1){o=0;return o|0}g=c[a+16>>2]|0;d=b;while(1){if((c[(c[g+(d<<4)>>2]|0)+12>>2]|0)==(h|0)?(c[(c[g+(d<<4)+4>>2]|0)+12>>2]|0)==(f|0):0)break;b=c[(c[a+64>>2]|0)+(d<<2)>>2]|0;if((b|0)==-1){b=0;o=24;break}else d=b}if((o|0)==24)return b|0;b=g+(d<<4)|0;if(!b){o=0;return o|0}ic[c[(c[a>>2]|0)+32>>2]&127](a,b,e);n=c[g+(d<<4)+12>>2]|0;m=b-(c[a+16>>2]|0)>>4;h=(c[a+44>>2]|0)+(i<<2)|0;b=c[h>>2]|0;d=c[a+64>>2]|0;if((b|0)!=(m|0)){g=b;while(1){f=d+(g<<2)|0;b=c[f>>2]|0;if((b|0)==(m|0))break;else g=b}b=c[d+(m<<2)>>2]|0;if((g|0)==-1)o=12;else c[f>>2]=b}else{b=c[d+(m<<2)>>2]|0;o=12}if((o|0)==12)c[h>>2]=b;k=(c[a+8>>2]|0)+-1|0;b=c[a+72>>2]|0;if(b|0)Ib[c[(c[b>>2]|0)+12>>2]&31](b,l,j,e)|0;if((k|0)==(m|0)){c[a+8>>2]=(c[a+8>>2]|0)+-1;o=n;return o|0}j=c[a+16>>2]|0;h=c[(c[j+(k<<4)+4>>2]|0)+12>>2]<<16|c[(c[j+(k<<4)>>2]|0)+12>>2];h=(h+~(h<<15)>>10^h+~(h<<15))*9|0;h=((h>>6^h)+~((h>>6^h)<<11)>>16^(h>>6^h)+~((h>>6^h)<<11))&(c[a+12>>2]|0)+-1;i=(c[a+44>>2]|0)+(h<<2)|0;b=c[i>>2]|0;d=c[a+64>>2]|0;if((b|0)!=(k|0)){g=b;while(1){f=d+(g<<2)|0;b=c[f>>2]|0;if((b|0)==(k|0))break;else g=b}b=c[d+(k<<2)>>2]|0;if((g|0)==-1)o=22;else c[f>>2]=b}else{b=c[d+(k<<2)>>2]|0;o=22}if((o|0)==22)c[i>>2]=b;c[j+(m<<4)>>2]=c[j+(k<<4)>>2];c[j+(m<<4)+4>>2]=c[j+(k<<4)+4>>2];c[j+(m<<4)+8>>2]=c[j+(k<<4)+8>>2];c[j+(m<<4)+12>>2]=c[j+(k<<4)+12>>2];o=(c[a+44>>2]|0)+(h<<2)|0;c[(c[a+64>>2]|0)+(m<<2)>>2]=c[o>>2];c[o>>2]=m;c[a+8>>2]=(c[a+8>>2]|0)+-1;o=n;return o|0}function Af(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0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60>>2]=r+(m*G+n*F+o*D);g[C+64>>2]=0.0;E=c[(c[b+20>>2]|0)+(B<<2)>>2]|0;D=+Mb[c[(c[E>>2]|0)+12>>2]&15](E,C,z,f,h);i=D>2]|0)+1|0;c[C+260>>2]=x;g[C+4>>2]=j;g[C+8>>2]=t;g[C+12>>2]=u;c[C+16>>2]=v;g[C+20>>2]=w;g[C+24>>2]=k;g[C+28>>2]=l;c[C+32>>2]=d;g[C+36>>2]=m;g[C+40>>2]=n;g[C+44>>2]=o;c[C+48>>2]=e;g[C+52>>2]=p;g[C+56>>2]=q;g[C+60>>2]=r;c[C+64>>2]=s;B=B+1|0}while((B|0)!=(A|0));return +i}function Bf(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;a[p+16>>0]=1;c[p+12>>2]=0;c[p+4>>2]=0;c[p+8>>2]=0;e=c[b+8>>2]|0;if((e|0)>0){g=0;h=0;f=0;n=0;while(1){l=c[b+16>>2]|0;m=l+(n<<4)|0;if((g|0)==(f|0)){k=f|0?f<<1:1;if((f|0)<(k|0)){if(k){c[6435]=(c[6435]|0)+1;e=yc((k<<4|3)+16|0)|0;if(!e){j=0;f=g}else{c[(e+4+15&-16)+-4>>2]=e;j=e+4+15&-16;f=g}}else j=0;if((f|0)>0){e=0;do{h=c[p+12>>2]|0;c[j+(e<<4)>>2]=c[h+(e<<4)>>2];c[j+(e<<4)+4>>2]=c[h+(e<<4)+4>>2];c[j+(e<<4)+8>>2]=c[h+(e<<4)+8>>2];c[j+(e<<4)+12>>2]=c[h+(e<<4)+12>>2];e=e+1|0}while((e|0)!=(f|0))}e=c[p+12>>2]|0;if(!e)g=f;else{c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);c[p+12>>2]=0}a[p+16>>0]=1;c[p+12>>2]=j;c[p+8>>2]=k;e=c[b+8>>2]|0;h=g}else{k=f;j=h;h=f}}else{k=f;j=h;h=g}c[j+(h<<4)>>2]=c[m>>2];c[j+(h<<4)+4>>2]=c[l+(n<<4)+4>>2];c[j+(h<<4)+8>>2]=c[l+(n<<4)+8>>2];c[j+(h<<4)+12>>2]=c[l+(n<<4)+12>>2];g=h+1|0;n=n+1|0;if((n|0)>=(e|0))break;else{h=j;f=k}}c[p+4>>2]=g;if((h|0)>-1){e=c[p+12>>2]|0;f=0;while(1){Ib[c[(c[b>>2]|0)+12>>2]&31](b,c[e+(f<<4)>>2]|0,c[e+(f<<4)+4>>2]|0,d)|0;if((f|0)<(h|0))f=f+1|0;else break}}}else g=0;if((c[b+56>>2]|0)>0){e=c[b+64>>2]|0;f=0;do{c[e+(f<<2)>>2]=-1;f=f+1|0}while((f|0)<(c[b+56>>2]|0))}if((g|0)<=1)if((g|0)>0)o=24;else e=c[p+12>>2]|0;else{Vd(p,0,g+-1|0);o=24}if((o|0)==24){e=c[p+12>>2]|0;f=0;do{Ob[c[(c[b>>2]|0)+8>>2]&63](b,c[e+(f<<4)>>2]|0,c[e+(f<<4)+4>>2]|0)|0;f=f+1|0}while((f|0)<(g|0))}if(!e){i=p;return}c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);c[p+12>>2]=0;i=p;return}function Cf(a,b,d){a=a|0;b=+b;d=+d;var e=0,f=0,h=0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0,A=0.0,B=0.0,C=0.0,D=0.0;z=i;i=i+16|0;q=+g[a+452>>2];x=c[a+192>>2]|0;v=+Sb[c[(c[x>>2]|0)+48>>2]&15](x);x=c[a+812>>2]|0;if((x|0)<=0){i=z;return}y=0;do{r=c[a+820>>2]|0;p=c[r+(y*104|0)>>2]|0;p=(c[p+236>>2]&2|0)==0?0:p;if(p|0){u=+g[p+332>>2];n=+g[r+(y*104|0)+84>>2];m=+g[p+336>>2];o=+g[r+(y*104|0)+80>>2];w=+g[r+(y*104|0)+76>>2];t=+g[p+328>>2];e=(g[k>>2]=q*(u*n-m*o+ +g[p+312>>2]),c[k>>2]|0);f=(g[k>>2]=q*(+g[p+316>>2]+(m*w-n*t)),c[k>>2]|0);h=(g[k>>2]=q*(o*t-u*w+ +g[p+320>>2]),c[k>>2]|0)}else{e=0;f=0;h=0}s=c[r+(y*104|0)+24>>2]|0;t=+g[s+8>>2];u=+g[s+12>>2];w=+g[s+16>>2];o=t-+g[s+24>>2]-(c[k>>2]=e,+g[k>>2]);n=u-+g[s+28>>2]-(c[k>>2]=f,+g[k>>2]);d=w-+g[s+32>>2]-(c[k>>2]=h,+g[k>>2]);j=+g[r+(y*104|0)+4>>2];l=+g[r+(y*104|0)+8>>2];m=+g[r+(y*104|0)+12>>2];if(o*j+n*l+d*m<=1.1920928955078125e-07?(C=t*j+u*l+w*m+ +g[r+(y*104|0)+20>>2],D=+g[r+(y*104|0)+96>>2],C=(C>2],B=(o-(o-j*(o*j+n*l+d*m))*D+j*C)*b,A=(n-(n-l*(o*j+n*l+d*m))*D+C*l)*b,o=(d-(d-m*(o*j+n*l+d*m))*D+C*m)*b,l=+g[r+(y*104|0)+28>>2]*B+ +g[r+(y*104|0)+32>>2]*A+ +g[r+(y*104|0)+36>>2]*o,m=B*+g[r+(y*104|0)+44>>2]+A*+g[r+(y*104|0)+48>>2]+o*+g[r+(y*104|0)+52>>2],o=B*+g[r+(y*104|0)+60>>2]+A*+g[r+(y*104|0)+64>>2]+o*+g[r+(y*104|0)+68>>2],g[z>>2]=l,g[z+4>>2]=m,g[z+8>>2]=o,g[z+12>>2]=0.0,n=+g[r+(y*104|0)+92>>2],g[s+8>>2]=t-l*n,g[s+12>>2]=u-n*m,g[s+16>>2]=w-n*o,p|0):0)gj(p,z,r+(y*104|0)+76|0);y=y+1|0}while((y|0)!=(x|0));i=z;return} +function Sc(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0;s=i;i=i+240|0;n=c[b+48>>2]|0;k=c[b+52>>2]|0;if((k|0?(h=c[k+20>>2]|0,h|0):0)?(Eb[c[(c[h>>2]|0)+48>>2]&127](h)|0)&1|0:0){c[s+144>>2]=1065353216;c[s+144+4>>2]=1065353216;c[s+144+8>>2]=0;g[s+144+12>>2]=0.0;l=c[b+8>>2]|0;r=c[(c[b+52>>2]|0)+20>>2]|0;q=c[(c[r>>2]|0)+8>>2]|0;t=+g[d>>2];u=+g[d+4>>2];v=+g[d+8>>2];w=t*+g[l+20>>2]+u*+g[l+24>>2]+v*+g[l+28>>2]+ +g[l+56>>2];x=t*+g[l+36>>2]+u*+g[l+40>>2]+v*+g[l+44>>2]+ +g[l+60>>2];g[s+128>>2]=t*+g[l+4>>2]+u*+g[l+8>>2]+v*+g[l+12>>2]+ +g[l+52>>2];g[s+128+4>>2]=w;g[s+128+8>>2]=x;g[s+128+12>>2]=0.0;x=+g[d+16>>2];w=+g[d+20>>2];v=+g[d+24>>2];u=x*+g[l+20>>2]+w*+g[l+24>>2]+v*+g[l+28>>2]+ +g[l+56>>2];t=x*+g[l+36>>2]+w*+g[l+40>>2]+v*+g[l+44>>2]+ +g[l+60>>2];g[s+88>>2]=x*+g[l+4>>2]+w*+g[l+8>>2]+v*+g[l+12>>2]+ +g[l+52>>2];g[s+88+4>>2]=u;g[s+88+8>>2]=t;g[s+88+12>>2]=0.0;mc[q&127](r,s+128|0,s+88|0,s+144|0);r=c[(c[b+52>>2]|0)+20>>2]|0;q=c[(c[r>>2]|0)+8>>2]|0;t=+g[d+16>>2];u=+g[d+20>>2];v=+g[d+24>>2];w=t*+g[l+20>>2]+u*+g[l+24>>2]+v*+g[l+28>>2]+ +g[l+56>>2];x=t*+g[l+36>>2]+u*+g[l+40>>2]+v*+g[l+44>>2]+ +g[l+60>>2];g[s+72>>2]=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<11));a:do if(h>>>0<(c[b+64>>2]|0)>>>0?(m=c[(c[b+72>>2]|0)+(h<<2)>>2]|0,(m|0)!=-1):0){l=c[b+132>>2]|0;k=m;while(1){if((e<<21|f|0)==(c[l+(k<<2)>>2]|0))break;h=c[(c[b+92>>2]|0)+(k<<2)>>2]|0;if((h|0)==-1)break a;else k=h}h=c[b+112>>2]|0;if(h+(k<<3)|0){q=c[h+(k<<3)+4>>2]|0;r=c[b+8>>2]|0;c[q+8>>2]=c[(c[r+192>>2]|0)+8>>2];p=c[b+4>>2]|0;o=c[p+192>>2]|0;c[s+144>>2]=0;c[s+144+4>>2]=o;c[s+144+8>>2]=p;c[s+144+12>>2]=p+4;c[s+144+16>>2]=-1;c[s+144+20>>2]=-1;c[s+104>>2]=0;c[s+104+4>>2]=q;c[s+104+8>>2]=r;c[s+104+12>>2]=r+4;c[s+104+16>>2]=e;c[s+104+20>>2]=f;r=Ib[c[(c[n>>2]|0)+8>>2]&31](n,s+144|0,s+104|0,0)|0;yb[c[(c[r>>2]|0)+8>>2]&31](r,s+144|0,s+104|0,c[b+52>>2]|0,c[b+44>>2]|0);Ab[c[c[r>>2]>>2]&255](r);Cb[c[(c[n>>2]|0)+60>>2]&127](n,r);i=s;return}}while(0);C=+g[d+16>>2];F=+g[d>>2];B=+g[d+20>>2];E=+g[d+4>>2];A=+g[d+24>>2];D=+g[d+8>>2];z=+g[d+32>>2];t=+g[d+36>>2];v=+g[d+40>>2];y=(B-E)*(v-D)-(A-D)*(t-E);u=(A-D)*(z-F)-(C-F)*(v-D);x=(C-F)*(t-E)-(B-E)*(z-F);w=1.0/+O(+(x*x+(y*y+u*u)));g[s+144>>2]=F+w*y*.05999999865889549;g[s+144+4>>2]=E+w*u*.05999999865889549;g[s+144+8>>2]=w*x*.05999999865889549+D;g[s+144+12>>2]=0.0;g[s+144+16>>2]=w*y*.05999999865889549+C;g[s+144+20>>2]=w*u*.05999999865889549+B;g[s+144+24>>2]=w*x*.05999999865889549+A;g[s+144+28>>2]=0.0;g[s+144+32>>2]=w*y*.05999999865889549+z;g[s+144+36>>2]=w*u*.05999999865889549+t;g[s+144+40>>2]=w*x*.05999999865889549+v;g[s+144+44>>2]=0.0;g[s+144+48>>2]=F-w*y*.05999999865889549;g[s+144+52>>2]=E-w*u*.05999999865889549;g[s+144+56>>2]=D-w*x*.05999999865889549;g[s+144+60>>2]=0.0;g[s+144+64>>2]=C-w*y*.05999999865889549;g[s+144+68>>2]=B-w*u*.05999999865889549;g[s+144+72>>2]=A-w*x*.05999999865889549;g[s+144+76>>2]=0.0;g[s+144+80>>2]=z-w*y*.05999999865889549;g[s+144+84>>2]=t-w*u*.05999999865889549;g[s+144+88>>2]=v-w*x*.05999999865889549;g[s+144+92>>2]=0.0;c[6435]=(c[6435]|0)+1;h=yc(131)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}kg(h,s+144|0,6,16);r=c[b+8>>2]|0;c[h+8>>2]=c[(c[r+192>>2]|0)+8>>2];q=c[b+4>>2]|0;d=c[q+192>>2]|0;c[s+104>>2]=0;c[s+104+4>>2]=d;c[s+104+8>>2]=q;c[s+104+12>>2]=q+4;c[s+104+16>>2]=-1;c[s+104+20>>2]=-1;c[s+32>>2]=0;c[s+32+4>>2]=h;c[s+32+8>>2]=r;c[s+32+12>>2]=r+4;c[s+32+16>>2]=e;c[s+32+20>>2]=f;r=Ib[c[(c[n>>2]|0)+8>>2]&31](n,s+104|0,s+32|0,0)|0;yb[c[(c[r>>2]|0)+8>>2]&31](r,s+104|0,s+32|0,c[b+52>>2]|0,c[b+44>>2]|0);Ab[c[c[r>>2]>>2]&255](r);Cb[c[(c[n>>2]|0)+60>>2]&127](n,r);r=((e<<21|f)+~(f<<15)>>10^(e<<21|f)+~(f<<15))*9|0;r=(r>>6^r)+~((r>>6^r)<<11)>>16^(r>>6^r)+~((r>>6^r)<<11);n=c[b+108>>2]|0;b:do if((r&n+-1)>>>0<(c[b+64>>2]|0)>>>0?(j=c[(c[b+72>>2]|0)+((r&n+-1)<<2)>>2]|0,(j|0)!=-1):0){k=c[b+132>>2]|0;while(1){if((e<<21|f|0)==(c[k+(j<<2)>>2]|0))break;j=c[(c[b+92>>2]|0)+(j<<2)>>2]|0;if((j|0)==-1){o=20;break b}}b=c[b+112>>2]|0;c[b+(j<<3)>>2]=e<<21|f;c[b+(j<<3)+4>>2]=h}else o=20;while(0);if((o|0)==20){q=c[b+104>>2]|0;if((q|0)==(n|0)){m=n|0?n<<1:1;if((n|0)<(m|0)){if(!m){j=0;k=n}else{c[6435]=(c[6435]|0)+1;j=yc((m<<3|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}k=c[b+104>>2]|0}if((k|0)>0){l=0;do{H=(c[b+112>>2]|0)+(l<<3)|0;G=c[H+4>>2]|0;d=j+(l<<3)|0;c[d>>2]=c[H>>2];c[d+4>>2]=G;l=l+1|0}while((l|0)!=(k|0))}k=c[b+112>>2]|0;if(k|0){if(a[b+116>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[b+112>>2]=0}a[b+116>>0]=1;c[b+112>>2]=j;c[b+108>>2]=m;j=c[b+104>>2]|0}else j=n}else j=q;H=c[b+112>>2]|0;c[H+(j<<3)>>2]=e<<21|f;c[H+(j<<3)+4>>2]=h;c[b+104>>2]=(c[b+104>>2]|0)+1;h=c[b+124>>2]|0;if((h|0)==(c[b+128>>2]|0)?(p=h|0?h<<1:1,(h|0)<(p|0)):0){if(!p)l=0;else{c[6435]=(c[6435]|0)+1;h=yc((p<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}l=h;h=c[b+124>>2]|0}k=c[b+132>>2]|0;if((h|0)<=0)if(!k)h=b+136|0;else o=43;else{j=0;do{c[l+(j<<2)>>2]=c[k+(j<<2)>>2];j=j+1|0}while((j|0)!=(h|0));o=43}if((o|0)==43){if(a[b+136>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[b+132>>2]=0;h=b+136|0}a[h>>0]=1;c[b+132>>2]=l;c[b+128>>2]=p;h=c[b+124>>2]|0}c[(c[b+132>>2]|0)+(h<<2)>>2]=e<<21|f;c[b+124>>2]=(c[b+124>>2]|0)+1;d=c[b+108>>2]|0;if((n|0)<(d|0)){n=c[b+64>>2]|0;if((d|0)>(n|0)){if((d|0)>=(n|0)){do if((c[b+68>>2]|0)<(d|0)){if(!d){h=0;j=n}else{c[6435]=(c[6435]|0)+1;h=yc((d<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[b+64>>2]|0}k=c[b+72>>2]|0;if((j|0)<=0){if(!k){a[b+76>>0]=1;c[b+72>>2]=h;c[b+68>>2]=d;break}}else{l=0;do{c[h+(l<<2)>>2]=c[k+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0))}if(a[b+76>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}a[b+76>>0]=1;c[b+72>>2]=h;c[b+68>>2]=d}else h=c[b+72>>2]|0;while(0);Qn(h+(n<<2)|0,0,d-n<<2|0)|0}c[b+64>>2]=d;m=c[b+84>>2]|0;if((d|0)>(m|0)){do if((c[b+88>>2]|0)<(d|0)){if(!d){h=0;j=m}else{c[6435]=(c[6435]|0)+1;h=yc((d<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[b+84>>2]|0}k=c[b+92>>2]|0;if((j|0)<=0){if(!k){a[b+96>>0]=1;c[b+92>>2]=h;c[b+88>>2]=d;break}}else{l=0;do{c[h+(l<<2)>>2]=c[k+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0))}if(a[b+96>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}a[b+96>>0]=1;c[b+92>>2]=h;c[b+88>>2]=d}else h=c[b+92>>2]|0;while(0);Qn(h+(m<<2)|0,0,d-m<<2|0)|0}c[b+84>>2]=d;if((d|0)>0){Qn(c[b+72>>2]|0,-1,d<<2|0)|0;Qn(c[b+92>>2]|0,-1,d<<2|0)|0}if((n|0)>0){h=c[b+132>>2]|0;j=c[b+72>>2]|0;k=c[b+92>>2]|0;l=0;do{H=c[h+(l<<2)>>2]|0;H=(H+~(H<<15)>>10^H+~(H<<15))*9|0;H=j+((((H>>6^H)+~((H>>6^H)<<11)>>16^(H>>6^H)+~((H>>6^H)<<11))&(c[b+108>>2]|0)+-1)<<2)|0;c[k+(l<<2)>>2]=c[H>>2];c[H>>2]=l;l=l+1|0}while((l|0)!=(n|0))}}h=r&(c[b+108>>2]|0)+-1}else h=r&n+-1;H=(c[b+72>>2]|0)+(h<<2)|0;c[(c[b+92>>2]|0)+(q<<2)>>2]=c[H>>2];c[H>>2]=q}i=s;return}function Tc(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=i;i=i+16|0;li(12170);k=c[b+212>>2]|0;j=c[b+180>>2]|0;if((j|0)<(k|0)){if((c[b+184>>2]|0)<(k|0)){if(!k){e=0;f=j}else{c[6435]=(c[6435]|0)+1;e=yc((k<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}f=c[b+180>>2]|0}if((f|0)>0){h=0;do{c[e+(h<<2)>>2]=c[(c[b+188>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}f=c[b+188>>2]|0;if(f|0){if(a[b+192>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+188>>2]=0}a[b+192>>0]=1;c[b+188>>2]=e;c[b+184>>2]=k;f=b+188|0}else f=b+188|0;e=j;do{c[(c[f>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=(k|0))}else f=b+188|0;c[b+180>>2]=k;e=0;while(1){if((e|0)>=(Eb[c[(c[b>>2]|0)+104>>2]&127](b)|0))break;c[(c[f>>2]|0)+(e<<2)>>2]=c[(c[b+220>>2]|0)+(e<<2)>>2];e=e+1|0}e=c[b+180>>2]|0;if((e|0)>1)bh(b+176|0,0,e+-1|0);if(!(Eb[c[(c[b>>2]|0)+104>>2]&127](b)|0))e=0;else e=c[f>>2]|0;h=c[b+196>>2]|0;t=c[b+180>>2]|0;u=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;c[h+4>>2]=d;c[h+12>>2]=e;c[h+16>>2]=t;c[h+20>>2]=u;e=c[h+32>>2]|0;if((e|0)<0){if((c[h+36>>2]|0)<0){f=c[h+40>>2]|0;if(f|0){if(a[h+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[h+40>>2]=0}a[h+44>>0]=1;c[h+40>>2]=0;c[h+36>>2]=0}do{c[(c[h+40>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=0)}c[h+32>>2]=0;e=c[h+52>>2]|0;if((e|0)<0){if((c[h+56>>2]|0)<0){f=c[h+60>>2]|0;if(f|0){if(a[h+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[h+60>>2]=0}a[h+64>>0]=1;c[h+60>>2]=0;c[h+56>>2]=0}do{c[(c[h+60>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=0)}c[h+52>>2]=0;e=c[h+72>>2]|0;if((e|0)<0){if((c[h+76>>2]|0)<0){f=c[h+80>>2]|0;if(f|0){if(a[h+84>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[h+80>>2]=0}a[h+84>>0]=1;c[h+80>>2]=0;c[h+76>>2]=0}do{c[(c[h+80>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=0)}c[h+72>>2]=0;u=c[b+200>>2]|0;e=c[(c[u>>2]|0)+8>>2]|0;s=c[b+8>>2]|0;t=c[b+24>>2]|0;t=Eb[c[(c[t>>2]|0)+36>>2]&127](t)|0;ic[e&127](u,s,t);t=c[b+204>>2]|0;s=c[b+24>>2]|0;u=c[b+196>>2]|0;li(13882);e=c[t+28>>2]|0;if((e|0)<0){if((c[t+32>>2]|0)<0){f=c[t+36>>2]|0;if(f|0){if(a[t+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[t+36>>2]=0}a[t+40>>0]=1;c[t+36>>2]=0;c[t+32>>2]=0}do{c[(c[t+36>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=0)}c[t+28>>2]=0;j=c[t+8>>2]|0;if((j|0)>0){k=c[t+16>>2]|0;m=0;do{l=k+(m<<3)|0;e=c[l>>2]|0;if((e|0)==(m|0))e=m;else{f=e;h=l;do{e=k+(f<<3)|0;c[h>>2]=c[e>>2];e=c[e>>2]|0;h=k+(e<<3)|0;f=c[h>>2]|0}while((e|0)!=(f|0))}c[l>>2]=e;m=m+1|0}while((m|0)!=(j|0));if((j|0)>1){yj(t+4|0,0,j+-1|0);j=c[t+8>>2]|0}if((j|0)>0){m=c[t+16>>2]|0;f=0;while(1){n=c[m+(f<<3)>>2]|0;q=f;while(1){p=q+1|0;if((p|0)>=(j|0)){l=0;break}if((c[m+(p<<3)>>2]|0)==(n|0))q=p;else{l=1;break}}a:do if((f|0)<=(q|0)){o=c[b+16>>2]|0;e=1;k=f;while(1){h=c[o+(c[m+(k<<3)+4>>2]<<2)>>2]|0;if((c[h+208>>2]|0)==(n|0)){h=c[h+216>>2]|0;e=(h|0)!=4&(e&(h|0)!=1)}if((k|0)<(q|0))k=k+1|0;else break}if(e){e=m;while(1){e=c[o+(c[e+(f<<3)+4>>2]<<2)>>2]|0;if((c[e+208>>2]|0)==(n|0)?(c[e+216>>2]&-2|0)!=4:0)c[e+216>>2]=2;if((f|0)>=(q|0))break a;e=c[t+16>>2]|0;f=f+1|0}}else{e=m;while(1){e=c[o+(c[e+(f<<3)+4>>2]<<2)>>2]|0;if((c[e+208>>2]|0)==(n|0)?(c[e+216>>2]|0)==2:0){c[e+216>>2]=3;g[e+220>>2]=0.0}if((f|0)>=(q|0))break a;e=c[t+16>>2]|0;f=f+1|0}}}while(0);if(l)f=p;else break}}}j=Eb[c[(c[s>>2]|0)+36>>2]&127](s)|0;if((j|0)>0){l=0;do{k=Zb[c[(c[s>>2]|0)+40>>2]&31](s,l)|0;f=c[k+740>>2]|0;h=c[k+744>>2]|0;if((f|0)!=0?(c[f+216>>2]|0)!=2:0)e=92;else e=90;if(((e|0)==90?(e=0,h|0):0)?(c[h+216>>2]|0)!=2:0)e=92;if((e|0)==92){e=c[f+204>>2]|0;if((e&2|0?((e&4|0)==0?(c[f+216>>2]|0)!=2:0):0)?(c[h+204>>2]&3|0)==0:0){if((c[h+216>>2]&-2|0)!=4)c[h+216>>2]=1;g[h+220>>2]=0.0}q=c[h+204>>2]|0;if(q&2|0?((q&4|e&3|0)==0?(c[h+216>>2]|0)!=2:0):0){if((c[f+216>>2]&-2|0)!=4)c[f+216>>2]=1;g[f+220>>2]=0.0}if(a[t+64>>0]|0?Ob[c[(c[s>>2]|0)+28>>2]&63](s,f,h)|0:0){e=c[t+28>>2]|0;if((e|0)==(c[t+32>>2]|0)?(r=e|0?e<<1:1,(e|0)<(r|0)):0){if(!r)h=0;else{c[6435]=(c[6435]|0)+1;e=yc((r<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=e;e=c[t+28>>2]|0}if((e|0)>0){f=0;do{c[h+(f<<2)>>2]=c[(c[t+36>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(e|0))}f=c[t+36>>2]|0;if(f){if(a[t+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);e=c[t+28>>2]|0}c[t+36>>2]=0}a[t+40>>0]=1;c[t+36>>2]=h;c[t+32>>2]=r}c[(c[t+36>>2]|0)+(e<<2)>>2]=k;c[t+28>>2]=e+1}}l=l+1|0}while((l|0)<(j|0))}e=c[2357]|0;r=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=r;do if(!r){if(c[e+4>>2]|0){tb(v|0,0)|0;r=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[v+4>>2]|0)-(c[r+4>>2]|0)+(((c[v>>2]|0)-(c[r>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(c[e+16>>2]|0)break;e=c[2357]|0}c[2357]=c[e+20>>2]}while(0);r=c[t+8>>2]|0;li(13910);if(a[t+64>>0]|0){p=c[t+28>>2]|0;if((p|0)>1)$g(t+24|0,0,p+-1|0);if((r|0)>0){n=1;f=0;q=0;while(1){e=c[t+16>>2]|0;o=c[e+(f<<3)>>2]|0;b:do if((f|0)<(r|0)){k=c[t+48>>2]|0;h=c[t+52>>2]|0;m=1;while(1){l=c[(c[b+16>>2]|0)+(c[e+(f<<3)+4>>2]<<2)>>2]|0;do if((k|0)==(h|0)){k=h|0?h<<1:1;if((h|0)>=(k|0)){e=h;break}if(!k)e=0;else{c[6435]=(c[6435]|0)+1;e=yc((k<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=c[t+48>>2]|0}if((h|0)>0){j=0;do{c[e+(j<<2)>>2]=c[(c[t+56>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(h|0))}j=c[t+56>>2]|0;if(j){if(a[t+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);h=c[t+48>>2]|0}c[t+56>>2]=0}a[t+60>>0]=1;c[t+56>>2]=e;c[t+52>>2]=k;e=h;h=k}else e=k;while(0);c[(c[t+56>>2]|0)+(e<<2)>>2]=l;k=e+1|0;c[t+48>>2]=k;j=c[l+216>>2]|0;j=m&((j|0)==2|(j|0)==5);f=f+1|0;if((f|0)>=(r|0)){m=f;break b}e=c[t+16>>2]|0;if((c[e+(f<<3)>>2]|0)!=(o|0)){m=f;break}else m=j}}else{m=f;j=1}while(0);if((q|0)<(p|0)){l=c[t+36>>2]|0;e=l+(q<<2)|0;h=c[e>>2]|0;f=c[(c[h+740>>2]|0)+208>>2]|0;if((f|0)<=-1)f=c[(c[h+744>>2]|0)+208>>2]|0;if((f|0)==(o|0)){k=q;do{k=k+1|0;if((k|0)>=(p|0))break;h=c[l+(k<<2)>>2]|0;f=c[(c[h+740>>2]|0)+208>>2]|0;if((f|0)<=-1)f=c[(c[h+744>>2]|0)+208>>2]|0}while((o|0)==(f|0));h=k;f=k-q|0}else{h=n;f=0;e=0}}else{h=n;f=0;e=0}if(!j)Qb[c[(c[u>>2]|0)+8>>2]&7](u,c[t+56>>2]|0,c[t+48>>2]|0,e,f,o);q=(f|0)==0?q:h;e=c[t+48>>2]|0;if((e|0)<0){if((c[t+52>>2]|0)<0){f=c[t+56>>2]|0;if(f|0){if(a[t+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[t+56>>2]=0}a[t+60>>0]=1;c[t+56>>2]=0;c[t+52>>2]=0}do{c[(c[t+56>>2]|0)+(e<<2)>>2]=0;e=e+1|0}while((e|0)!=0)}c[t+48>>2]=0;if((m|0)>=(r|0))break;else{n=h;f=m}}}}else{r=Eb[c[(c[s>>2]|0)+44>>2]&127](s)|0;t=Eb[c[(c[s>>2]|0)+36>>2]&127](s)|0;Qb[c[(c[u>>2]|0)+8>>2]&7](u,c[b+16>>2]|0,c[b+8>>2]|0,r,t,-1)}e=c[2357]|0;u=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=u;do if(!u){if(c[e+4>>2]|0){tb(v|0,0)|0;u=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[v+4>>2]|0)-(c[u+4>>2]|0)+(((c[v>>2]|0)-(c[u>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(c[e+16>>2]|0)break;e=c[2357]|0}c[2357]=c[e+20>>2]}while(0);nh(c[b+196>>2]|0);e=c[b+200>>2]|0;ic[c[(c[e>>2]|0)+16>>2]&127](e,d,c[b+72>>2]|0);e=c[2357]|0;b=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=b;if(b|0){i=v;return}do if(c[e+4>>2]|0){tb(v|0,0)|0;b=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[v+4>>2]|0)-(c[b+4>>2]|0)+(((c[v>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[e+16>>2]|0)){e=c[2357]|0;break}else{i=v;return}}while(0);c[2357]=c[e+20>>2];i=v;return}function Uc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,h=0.0,j=0.0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0.0,u=0,v=0.0,w=0,x=0,y=0.0,z=0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0;A=i;i=i+176|0;c[a+348>>2]=a+220;c[a+352>>2]=a+252;c[a+356>>2]=a+284;c[a+360>>2]=a+316;c[a+364>>2]=4;c[a+368>>2]=0;c[a+376>>2]=0;x=c[b+4>>2]|0;c[a>>2]=c[b>>2];c[a+4>>2]=x;c[a+8>>2]=c[b+8>>2];c[a+8+4>>2]=c[b+8+4>>2];c[a+8+8>>2]=c[b+8+8>>2];c[a+8+12>>2]=c[b+8+12>>2];c[a+24>>2]=c[b+24>>2];c[a+24+4>>2]=c[b+24+4>>2];c[a+24+8>>2]=c[b+24+8>>2];c[a+24+12>>2]=c[b+24+12>>2];c[a+40>>2]=c[b+40>>2];c[a+40+4>>2]=c[b+40+4>>2];c[a+40+8>>2]=c[b+40+8>>2];c[a+40+12>>2]=c[b+40+12>>2];c[a+56>>2]=c[b+56>>2];c[a+56+4>>2]=c[b+56+4>>2];c[a+56+8>>2]=c[b+56+8>>2];c[a+56+12>>2]=c[b+56+12>>2];c[a+72>>2]=c[b+72>>2];c[a+72+4>>2]=c[b+72+4>>2];c[a+72+8>>2]=c[b+72+8>>2];c[a+72+12>>2]=c[b+72+12>>2];c[a+88>>2]=c[b+88>>2];c[a+88+4>>2]=c[b+88+4>>2];c[a+88+8>>2]=c[b+88+8>>2];c[a+88+12>>2]=c[b+88+12>>2];c[a+104>>2]=c[b+104>>2];c[a+104+4>>2]=c[b+104+4>>2];c[a+104+8>>2]=c[b+104+8>>2];c[a+104+12>>2]=c[b+104+12>>2];x=c[b+124>>2]|0;c[a+120>>2]=c[b+120>>2];c[a+124>>2]=x;g[a+144>>2]=0.0;c[a+180>>2]=0;c[a+128>>2]=c[d>>2];c[a+128+4>>2]=c[d+4>>2];c[a+128+8>>2]=c[d+8>>2];c[a+128+12>>2]=c[d+12>>2];e=+g[a+128>>2];h=+g[a+132>>2];j=+g[a+136>>2];if(e*e+h*h+j*j>0.0){d=(g[k>>2]=-e,c[k>>2]|0);b=(g[k>>2]=-h,c[k>>2]|0);f=(g[k>>2]=-j,c[k>>2]|0)}else{d=1065353216;b=0;f=0}g[a+164>>2]=0.0;c[a+364>>2]=3;c[a+148>>2]=a+316;c[a+180>>2]=1;t=(c[k>>2]=d,+g[k>>2]);v=(c[k>>2]=b,+g[k>>2]);Nh(a,t,v,(c[k>>2]=f,+g[k>>2]),a+316|0);g[a+164>>2]=1.0;w=(c[a+148>>2]|0)+16|0;c[a+128>>2]=c[w>>2];c[a+128+4>>2]=c[w+4>>2];c[a+128+8>>2]=c[w+8>>2];c[a+128+12>>2]=c[w+12>>2];c[A+24+48>>2]=c[w>>2];c[A+24+48+4>>2]=c[w+4>>2];c[A+24+48+8>>2]=c[w+8>>2];c[A+24+48+12>>2]=c[w+12>>2];c[A+24+32>>2]=c[w>>2];c[A+24+32+4>>2]=c[w+4>>2];c[A+24+32+8>>2]=c[w+8>>2];c[A+24+32+12>>2]=c[w+12>>2];c[A+24+16>>2]=c[w>>2];c[A+24+16+4>>2]=c[w+4>>2];c[A+24+16+8>>2]=c[w+8>>2];c[A+24+16+12>>2]=c[w+12>>2];c[A+24>>2]=c[w>>2];c[A+24+4>>2]=c[w+4>>2];c[A+24+8>>2]=c[w+8>>2];c[A+24+12>>2]=c[w+12>>2];v=0.0;w=0;x=0;e=e*e+h*h+j*j;a:do{u=c[a+368>>2]|0;l=+g[a+128>>2];h=+g[a+132>>2];j=+g[a+136>>2];o=+O(+(l*l+h*h+j*j));if(o<9.999999747378752e-05){z=5;break}g[a+148+(u*36|0)+16+(c[a+148+(u*36|0)+32>>2]<<2)>>2]=0.0;d=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=d;c[a+148+(u*36|0)+(c[a+148+(u*36|0)+32>>2]<<2)>>2]=c[a+348+(d<<2)>>2];d=c[a+148+(u*36|0)+32>>2]|0;c[a+148+(u*36|0)+32>>2]=d+1;Nh(a,-l,-h,-j,c[a+148+(u*36|0)+(d<<2)>>2]|0);d=c[a+148+(u*36|0)+32>>2]|0;b=c[a+148+(u*36|0)+(d+-1<<2)>>2]|0;h=+g[b+16>>2];j=+g[b+20>>2];l=+g[b+24>>2];q=h-+g[A+24>>2];r=j-+g[A+24+4>>2];t=l-+g[A+24+8>>2];if(q*q+r*r+t*t<9.999999747378752e-05){z=8;break}q=h-+g[A+24+16>>2];r=j-+g[A+24+20>>2];t=l-+g[A+24+24>>2];if(q*q+r*r+t*t<9.999999747378752e-05){z=8;break}q=h-+g[A+24+32>>2];r=j-+g[A+24+36>>2];t=l-+g[A+24+40>>2];if(q*q+r*r+t*t<9.999999747378752e-05){z=8;break}q=h-+g[A+24+48>>2];r=j-+g[A+24+52>>2];t=l-+g[A+24+56>>2];if(q*q+r*r+t*t<9.999999747378752e-05){z=8;break}w=w+1&3;s=A+24+(w<<4)|0;c[s>>2]=c[b+16>>2];c[s+4>>2]=c[b+16+4>>2];c[s+8>>2]=c[b+16+8>>2];c[s+12>>2]=c[b+16+12>>2];t=(+g[a+128>>2]*h+ +g[a+132>>2]*j+ +g[a+136>>2]*l)/o;v=t>v?t:v;if(o-v-o*9.999999747378752e-05<=0.0){z=9;break}c[A>>2]=0;b:do switch(d|0){case 2:{s=c[a+148+(u*36|0)>>2]|0;n=c[a+148+(u*36|0)+4>>2]|0;e=+g[n+16>>2];h=+g[s+16>>2];j=+g[n+20>>2];l=+g[s+20>>2];o=+g[n+24>>2];p=+g[s+24>>2];if(!((e-h)*(e-h)+(j-l)*(j-l)+(o-p)*(o-p)>0.0)){z=39;break a}q=-(h*(e-h)+l*(j-l)+p*(o-p))/((e-h)*(e-h)+(j-l)*(j-l)+(o-p)*(o-p));if(q>=1.0){g[A+8>>2]=0.0;g[A+8+4>>2]=1.0;c[A>>2]=2;e=e*e+j*j+o*o;break b}if(!(q<=0.0)){g[A+8+4>>2]=q;g[A+8>>2]=1.0-q;c[A>>2]=3;e=((e-h)*q+h)*((e-h)*q+h)+((j-l)*q+l)*((j-l)*q+l)+((o-p)*q+p)*((o-p)*q+p);break b}else{g[A+8>>2]=1.0;g[A+8+4>>2]=0.0;c[A>>2]=1;e=h*h+l*l+p*p;break b}}case 3:{e=+Oe((c[a+148+(u*36|0)>>2]|0)+16|0,(c[a+148+(u*36|0)+4>>2]|0)+16|0,(c[a+148+(u*36|0)+8>>2]|0)+16|0,A+8|0,A);break}case 4:{f=c[a+148+(u*36|0)>>2]|0;m=c[a+148+(u*36|0)+4>>2]|0;n=c[a+148+(u*36|0)+8>>2]|0;s=c[a+148+(u*36|0)+12>>2]|0;c[A+152>>2]=f+16;c[A+152+4>>2]=m+16;c[A+152+8>>2]=n+16;c[A+152+12>>2]=s+16;j=+g[f+16>>2];l=+g[s+16>>2];e=+g[f+20>>2];o=+g[s+20>>2];h=+g[f+24>>2];p=+g[s+24>>2];g[A+104>>2]=j-l;g[A+104+4>>2]=e-o;g[A+104+8>>2]=h-p;g[A+104+12>>2]=0.0;B=+g[m+16>>2];D=+g[m+20>>2];r=+g[m+24>>2];g[A+104+16>>2]=B-l;g[A+104+20>>2]=D-o;g[A+104+24>>2]=r-p;g[A+104+28>>2]=0.0;q=+g[n+16>>2];E=+g[n+20>>2];C=+g[n+24>>2];g[A+104+32>>2]=q-l;g[A+104+36>>2]=E-o;g[A+104+40>>2]=C-p;g[A+104+44>>2]=0.0;t=(e-o)*(r-p)*(q-l)+(h-p)*(B-l)*(E-o)-(E-o)*(r-p)*(j-l)-(e-o)*(B-l)*(C-p)+(C-p)*(j-l)*(D-o)-(q-l)*(h-p)*(D-o);if(t!=t|0.0!=0.0|t==0.0|!(t*(h*((B-q)*(e-D)-(D-E)*(j-B))+(j*((D-E)*(h-r)-(r-C)*(e-D))+e*((r-C)*(j-B)-(B-q)*(h-r))))<=0.0))e=-1.0;else{c[A+92>>2]=0;c[A+92+4>>2]=0;c[A+92+8>>2]=0;c[A+88>>2]=0;r=e-o;q=h-p;h=j-l;d=0;e=-1.0;while(1){b=c[4976+(d<<2)>>2]|0;C=+g[A+104+(b<<4)+8>>2];D=+g[A+104+(b<<4)+4>>2];E=+g[A+104+(b<<4)>>2];if(t*((r*C-q*D)*l+o*(q*E-C*h)+(D*h-r*E)*p)>0.0?(y=+Oe(c[A+152+(d<<2)>>2]|0,c[A+152+(b<<2)>>2]|0,s+16|0,A+92|0,A+88|0),e<0.0|y>2]|0;c[A>>2]=(F&2|0?1<>2]=c[A+92>>2];c[A+8+(b<<2)>>2]=c[A+92+4>>2];g[A+8+(c[4976+(b<<2)>>2]<<2)>>2]=0.0;c[A+8+12>>2]=c[A+92+8>>2];e=y}d=d+1|0;if((d|0)==3)break;r=+g[A+104+(d<<4)+4>>2];q=+g[A+104+(d<<4)+8>>2];h=+g[A+104+(d<<4)>>2];l=+g[s+16>>2];o=+g[s+20>>2];p=+g[s+24>>2]}if(e<0.0){c[A>>2]=15;l=+g[n+20>>2];E=+g[m+24>>2];D=+g[s+16>>2];h=+g[n+24>>2];C=+g[m+16>>2];o=+g[s+20>>2];j=+g[n+16>>2];B=+g[s+24>>2];q=+g[m+20>>2];g[A+8>>2]=(l*E*D+h*C*o-o*E*j-l*C*B+B*j*q-D*h*q)/t;e=+g[f+20>>2];p=+g[f+24>>2];r=+g[f+16>>2];g[A+8+4>>2]=(e*h*D+p*j*o-o*h*r-e*j*B+B*r*l-D*p*l)/t;g[A+8+8>>2]=(q*p*D+E*r*o-o*p*C-q*r*B+B*C*e-D*E*e)/t;g[A+8+12>>2]=1.0-((l*E*D+h*C*o-o*E*j-l*C*B+B*j*q-D*h*q)/t+(e*h*D+p*j*o-o*h*r-e*j*B+B*r*l-D*p*l)/t+(q*p*D+E*r*o-o*p*C-q*r*B+B*C*e-D*E*e)/t);e=0.0}}break}default:{}}while(0);if(!(e>=0.0)){z=39;break}c[a+148+((1-u|0)*36|0)+32>>2]=0;c[a+128>>2]=0;c[a+128+4>>2]=0;c[a+128+8>>2]=0;c[a+128+12>>2]=0;c[a+368>>2]=1-u;d=c[a+148+(u*36|0)+32>>2]|0;b=c[A>>2]|0;if(d|0){n=0;do{f=a+148+(u*36|0)+(n<<2)|0;m=c[f>>2]|0;if(!(b&1<>2]|0;c[a+364>>2]=F+1;c[a+348+(F<<2)>>2]=m}else{c[a+148+((1-u|0)*36|0)+(c[a+148+((1-u|0)*36|0)+32>>2]<<2)>>2]=m;s=c[A+8+(n<<2)>>2]|0;F=c[a+148+((1-u|0)*36|0)+32>>2]|0;c[a+148+((1-u|0)*36|0)+32>>2]=F+1;c[a+148+((1-u|0)*36|0)+16+(F<<2)>>2]=s;F=c[f>>2]|0;C=(c[k>>2]=s,+g[k>>2]);D=C*+g[F+20>>2];E=C*+g[F+24>>2];g[a+128>>2]=+g[F+16>>2]*C+ +g[a+128>>2];g[a+132>>2]=D+ +g[a+132>>2];g[a+136>>2]=E+ +g[a+136>>2]}n=n+1|0}while((n|0)!=(d|0))}if((b|0)==15)c[a+376>>2]=1;x=x+1|0;if(x>>>0>=128){z=38;break}}while(!(c[a+376>>2]|0));if((z|0)==5)c[a+376>>2]=1;else if((z|0)==8){F=c[a+368>>2]|0;z=(c[a+148+(F*36|0)+32>>2]|0)+-1|0;c[a+148+(F*36|0)+32>>2]=z;z=c[a+148+(F*36|0)+(z<<2)>>2]|0;F=c[a+364>>2]|0;c[a+364>>2]=F+1;c[a+348+(F<<2)>>2]=z}else if((z|0)==9){F=c[a+368>>2]|0;z=(c[a+148+(F*36|0)+32>>2]|0)+-1|0;c[a+148+(F*36|0)+32>>2]=z;z=c[a+148+(F*36|0)+(z<<2)>>2]|0;F=c[a+364>>2]|0;c[a+364>>2]=F+1;c[a+348+(F<<2)>>2]=z}else if((z|0)==38)c[a+376>>2]=2;else if((z|0)==39){F=c[a+368>>2]|0;z=(c[a+148+(F*36|0)+32>>2]|0)+-1|0;c[a+148+(F*36|0)+32>>2]=z;z=c[a+148+(F*36|0)+(z<<2)>>2]|0;F=c[a+364>>2]|0;c[a+364>>2]=F+1;c[a+348+(F<<2)>>2]=z}c[a+372>>2]=a+148+((c[a+368>>2]|0)*36|0);d=c[a+376>>2]|0;switch(d|0){case 0:{C=+g[a+128>>2];D=+g[a+132>>2];E=+g[a+136>>2];g[a+144>>2]=+O(+(C*C+D*D+E*E));i=A;return d|0}case 1:{g[a+144>>2]=0.0;i=A;return d|0}default:{i=A;return d|0}}return 0}function Vc(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0,G=0.0,H=0.0,I=0,J=0.0,K=0.0,L=0.0,M=0.0,N=0,P=0,Q=0.0,R=0.0,S=0.0,T=0;P=i;i=i+224|0;g[b+56>>2]=0.0;I=P+208+4|0;N=P+208+8|0;c[P+208>>2]=0;c[P+208+4>>2]=0;c[P+208+8>>2]=0;c[P+208+12>>2]=0;c[P+144>>2]=c[d>>2];c[P+144+4>>2]=c[d+4>>2];c[P+144+8>>2]=c[d+8>>2];c[P+144+12>>2]=c[d+12>>2];c[P+144+16>>2]=c[d+16>>2];c[P+144+16+4>>2]=c[d+16+4>>2];c[P+144+16+8>>2]=c[d+16+8>>2];c[P+144+16+12>>2]=c[d+16+12>>2];c[P+144+32>>2]=c[d+32>>2];c[P+144+32+4>>2]=c[d+32+4>>2];c[P+144+32+8>>2]=c[d+32+8>>2];c[P+144+32+12>>2]=c[d+32+12>>2];A=P+144+48|0;c[A>>2]=c[d+48>>2];c[A+4>>2]=c[d+48+4>>2];c[A+8>>2]=c[d+48+8>>2];c[A+12>>2]=c[d+48+12>>2];c[P+80>>2]=c[d+64>>2];c[P+80+4>>2]=c[d+64+4>>2];c[P+80+8>>2]=c[d+64+8>>2];c[P+80+12>>2]=c[d+64+12>>2];c[P+80+16>>2]=c[d+80>>2];c[P+80+16+4>>2]=c[d+80+4>>2];c[P+80+16+8>>2]=c[d+80+8>>2];c[P+80+16+12>>2]=c[d+80+12>>2];c[P+80+32>>2]=c[d+96>>2];c[P+80+32+4>>2]=c[d+96+4>>2];c[P+80+32+8>>2]=c[d+96+8>>2];c[P+80+32+12>>2]=c[d+96+12>>2];B=P+80+48|0;c[B>>2]=c[d+112>>2];c[B+4>>2]=c[d+112+4>>2];c[B+8>>2]=c[d+112+8>>2];c[B+12>>2]=c[d+112+12>>2];G=+g[A>>2];H=+g[B>>2];J=+g[P+144+52>>2];K=+g[P+80+52>>2];L=+g[P+144+56>>2];M=+g[P+80+56>>2];g[A>>2]=G-(G+H)*.5;g[P+144+52>>2]=J-(J+K)*.5;g[P+144+56>>2]=L-(L+M)*.5;g[B>>2]=H-(G+H)*.5;g[P+80+52>>2]=K-(J+K)*.5;g[P+80+56>>2]=M-(L+M)*.5;if(((c[(c[b+28>>2]|0)+4>>2]|0)+-17|0)>>>0<2)A=((c[(c[b+32>>2]|0)+4>>2]|0)+-17|0)>>>0<2;else A=0;v=+g[b+44>>2];u=+g[b+48>>2];c[6420]=(c[6420]|0)+1;B=a[b+52>>0]|0;c[b+64>>2]=0;c[b+4>>2]=0;c[b+8>>2]=1065353216;c[b+12>>2]=0;g[b+16>>2]=0.0;c[b+68>>2]=0;c[b+60>>2]=-1;p=c[b+24>>2]|0;a[p+312>>0]=0;c[p>>2]=0;a[p+356>>0]=1;c[p+292>>2]=1566444395;c[p+296>>2]=1566444395;c[p+300>>2]=1566444395;g[p+304>>2]=0.0;c[p+336>>2]=0;c[p+336+4>>2]=0;c[p+336+8>>2]=0;c[p+336+12>>2]=0;a[p+336+16>>0]=0;a[p+332>>0]=a[p+332>>0]&-16;p=0;q=999999984306749440.0;do{o=+g[b+4>>2];n=+g[b+8>>2];k=+g[b+12>>2];l=+g[d+4>>2]*-o+ +g[d+20>>2]*-n+ +g[d+36>>2]*-k;m=+g[d+8>>2]*-o+ +g[d+24>>2]*-n+ +g[d+40>>2]*-k;g[P+64>>2]=+g[d>>2]*-o+ +g[d+16>>2]*-n+ +g[d+32>>2]*-k;g[P+64+4>>2]=l;g[P+64+8>>2]=m;g[P+64+12>>2]=0.0;m=o*+g[d+68>>2]+n*+g[d+84>>2]+k*+g[d+100>>2];l=o*+g[d+72>>2]+n*+g[d+88>>2]+k*+g[d+104>>2];g[P+48>>2]=+g[d+64>>2]*o+ +g[d+80>>2]*n+ +g[d+96>>2]*k;g[P+48+4>>2]=m;g[P+48+8>>2]=l;g[P+48+12>>2]=0.0;Gd(P+32|0,c[b+28>>2]|0,P+64|0);Gd(P+16|0,c[b+32>>2]|0,P+48|0);l=+g[P+32>>2];m=+g[P+32+4>>2];k=+g[P+32+8>>2];n=l*+g[P+144>>2]+m*+g[P+144+4>>2]+k*+g[P+144+8>>2]+ +g[P+144+48>>2];o=l*+g[P+144+16>>2]+m*+g[P+144+20>>2]+k*+g[P+144+24>>2]+ +g[P+144+52>>2];k=l*+g[P+144+32>>2]+m*+g[P+144+36>>2]+k*+g[P+144+40>>2]+ +g[P+144+56>>2];m=+g[P+16>>2];l=+g[P+16+4>>2];t=+g[P+16+8>>2];r=m*+g[P+80>>2]+l*+g[P+80+4>>2]+t*+g[P+80+8>>2]+ +g[P+80+48>>2];s=m*+g[P+80+16>>2]+l*+g[P+80+20>>2]+t*+g[P+80+24>>2]+ +g[P+80+52>>2];t=m*+g[P+80+32>>2]+l*+g[P+80+36>>2]+t*+g[P+80+40>>2]+ +g[P+80+56>>2];l=A?0.0:t;m=A?0.0:k;t=(A?0.0:k)-(A?0.0:t);k=+g[b+4>>2]*(n-r)+ +g[b+8>>2]*(o-s)+ +g[b+12>>2]*t;if(k>0.0?k*k>q*+g[d+128>>2]:0){c[b+68>>2]=10;h=0;p=1}else T=7;do if((T|0)==7){T=0;y=c[b+24>>2]|0;z=c[y>>2]|0;if((z|0)>0){j=+g[y+308>>2];x=0;h=0;do{C=n-r-+g[y+4+(h<<4)>>2];D=o-s-+g[y+4+(h<<4)+4>>2];E=t-+g[y+4+(h<<4)+8>>2];x=x|C*C+D*D+E*E<=j;h=h+1|0}while((h|0)!=(z|0))}else x=0;if((+g[y+304>>2]==0.0?t==+g[y+300>>2]:0)?o-s==+g[y+296>>2]:0)h=n-r==+g[y+292>>2];else h=0;if(x|h){c[b+68>>2]=1;h=0;p=1;break}j=q-k;if(j<=q*9.999999974752427e-07){c[b+68>>2]=!(j<=0.0)?11:2;h=0;p=1;break}g[y+292>>2]=n-r;g[y+296>>2]=o-s;g[y+300>>2]=t;g[y+304>>2]=0.0;a[y+356>>0]=1;g[y+4+(z<<4)>>2]=n-r;g[y+4+(z<<4)+4>>2]=o-s;g[y+4+(z<<4)+8>>2]=t;g[y+4+(z<<4)+12>>2]=0.0;h=c[y>>2]|0;g[y+84+(h<<4)>>2]=n;g[y+84+(h<<4)+4>>2]=o;g[y+84+(h<<4)+8>>2]=m;g[y+84+(h<<4)+12>>2]=0.0;h=c[y>>2]|0;g[y+164+(h<<4)>>2]=r;g[y+164+(h<<4)+4>>2]=s;g[y+164+(h<<4)+8>>2]=l;g[y+164+(h<<4)+12>>2]=0.0;c[y>>2]=(c[y>>2]|0)+1;h=c[b+24>>2]|0;z=Ec(h)|0;j=+g[h+276>>2];k=+g[h+280>>2];l=+g[h+284>>2];h=c[h+288>>2]|0;if(!z){c[b+68>>2]=3;h=0;p=1;break}if(j*j+k*k+l*l<9.999999974752427e-07){g[b+4>>2]=j;g[b+8>>2]=k;g[b+12>>2]=l;c[b+16>>2]=h;c[b+68>>2]=6;h=0;p=1;break}if(q-(j*j+k*k+l*l)<=q*1.1920928955078125e-07){c[b+68>>2]=12;h=0;p=1;q=j*j+k*k+l*l;break}g[b+4>>2]=j;g[b+8>>2]=k;g[b+12>>2]=l;c[b+16>>2]=h;z=c[b+64>>2]|0;c[b+64>>2]=z+1;if((z|0)<=1e3)if((c[c[b+24>>2]>>2]|0)==4){c[b+68>>2]=13;h=0;q=j*j+k*k+l*l}else{h=1;q=j*j+k*k+l*l}else{h=0;q=j*j+k*k+l*l}}while(0)}while(h);u=B<<24>>24==0?u:0.0;t=(B<<24>>24==0?v:0.0)+u;do if(p){B=c[b+24>>2]|0;Ec(B)|0;j=+g[B+260>>2];l=+g[B+264>>2];n=+g[B+268>>2];c[P+208>>2]=c[b+4>>2];c[P+208+4>>2]=c[b+4+4>>2];c[P+208+8>>2]=c[b+4+8>>2];c[P+208+12>>2]=c[b+4+12>>2];k=+g[b+4>>2];m=+g[b+8>>2];o=+g[b+12>>2];if(k*k+m*m+o*o<.0001)c[b+68>>2]=5;if(k*k+m*m+o*o>1.4210854715202004e-14){E=1.0/+O(+(k*k+m*m+o*o));g[P+208>>2]=E*+g[P+208>>2];g[I>>2]=E*+g[I>>2];g[N>>2]=E*+g[N>>2];w=u/+O(+q);c[b+60>>2]=1;E=1.0/E-t;x=1;D=w*k+j;C=w*m+l;n=w*o+n;break}else{c[b+60>>2]=2;E=0.0;x=0;D=j;C=l;break}}else{E=0.0;x=0;D=0.0;C=0.0;n=0.0}while(0);if(((c[b+72>>2]|0)!=0?(c[b+20>>2]|0)!=0:0)?(c[b+68>>2]|0)!=0:0)h=t+E<.01;else h=0;p=x^1;do if(h|p?(F=c[b+20>>2]|0,(F|0)!=0):0){c[6419]=(c[6419]|0)+1;c[b+4>>2]=0;c[b+4+4>>2]=0;c[b+4+8>>2]=0;c[b+4+12>>2]=0;if(Db[c[(c[F>>2]|0)+8>>2]&3](F,c[b+24>>2]|0,c[b+28>>2]|0,c[b+32>>2]|0,P+144|0,P+80|0,b+4|0,P+64|0,P+48|0,f)|0){l=+g[P+48>>2];o=+g[P+64>>2];k=+g[P+48+4>>2];q=+g[P+64+4>>2];j=+g[P+48+8>>2];r=+g[P+64+8>>2];if(!((l-o)*(l-o)+(k-q)*(k-q)+(j-r)*(j-r)<=1.4210854715202004e-14)){m=(l-o)*(l-o)+(k-q)*(k-q)+(j-r)*(j-r);t=l-o;u=j-r;v=0.0;w=k-q}else{t=+g[b+4>>2];w=+g[b+8>>2];u=+g[b+12>>2];m=t*t+w*w+u*u;v=+g[b+16>>2]}if(m>1.4210854715202004e-14){s=1.0/+O(+m);m=-+O(+((o-l)*(o-l)+(q-k)*(q-k)+(r-j)*(r-j)));if(E>m|p){g[P+208>>2]=t*s;g[I>>2]=w*s;g[N>>2]=u*s;g[P+208+12>>2]=v;c[b+60>>2]=3;break}else h=8}else h=9;c[b+60>>2]=h;if(x){m=E;l=D;k=C;j=n;break}i=P;return}else{k=+g[b+4>>2];o=+g[b+8>>2];r=+g[b+12>>2];if(!(k*k+o*o+r*r>0.0)){if(x){m=E;l=D;k=C;j=n;break}i=P;return}l=+g[P+48>>2];v=+g[P+64>>2]-l;q=+g[P+48+4>>2];w=+g[P+64+4>>2]-q;s=+g[P+48+8>>2];j=+g[P+64+8>>2]-s;j=+O(+(v*v+w*w+j*j))-t;if(j>2]=c[b+4>>2];c[P+208+4>>2]=c[b+4+4>>2];c[P+208+8>>2]=c[b+4+8>>2];c[P+208+12>>2]=c[b+4+12>>2];C=+g[P+208>>2];D=+g[I>>2];E=+g[N>>2];m=1.0/+O(+(C*C+D*D+E*E));g[P+208>>2]=C*m;g[I>>2]=D*m;g[N>>2]=E*m;c[b+60>>2]=6;m=j;l=u*k+l;k=u*o+q;j=u*r+s;break}c[b+60>>2]=5;if(x){m=E;l=D;k=C;j=n;break}i=P;return}}else T=52;while(0);if((T|0)==52)if(x){m=E;l=D;k=C;j=n}else{i=P;return}if(!(m<0.0)?!(m*m<+g[d+128>>2]):0){i=P;return}if(c[b+76>>2]|0?(T=c[b+28>>2]|0,mc[c[(c[T>>2]|0)+8>>2]&127](T,P+144|0,P+64|0,P+48|0),C=(+g[P+48>>2]+ +g[P+64>>2])*.5,D=(+g[P+48+4>>2]+ +g[P+64+4>>2])*.5,E=(+g[P+48+8>>2]+ +g[P+64+8>>2])*.5,T=c[b+32>>2]|0,mc[c[(c[T>>2]|0)+8>>2]&127](T,P+80|0,P+64|0,P+48|0),Q=+g[P+208>>2],R=+g[I>>2],S=+g[N>>2],(C-(+g[P+64>>2]+ +g[P+48>>2])*.5)*Q+(D-(+g[P+64+4>>2]+ +g[P+48+4>>2])*.5)*R+(E-(+g[P+64+8>>2]+ +g[P+48+8>>2])*.5)*S<0.0):0){g[P+208>>2]=-Q;g[I>>2]=-R;g[N>>2]=-S}c[b+4>>2]=c[P+208>>2];c[b+4+4>>2]=c[P+208+4>>2];c[b+4+8>>2]=c[P+208+8>>2];c[b+4+12>>2]=c[P+208+12>>2];g[b+56>>2]=m;T=c[(c[e>>2]|0)+16>>2]|0;g[P>>2]=(G+H)*.5+l;g[P+4>>2]=(J+K)*.5+k;g[P+8>>2]=(L+M)*.5+j;g[P+12>>2]=0.0;hc[T&15](e,P+208|0,P,m);i=P;return}function Wc(b,d,e,f,h,j,k){b=b|0;d=d|0;e=e|0;f=f|0;h=+h;j=+j;k=k|0;var l=0,m=0,n=0.0,o=0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0.0,F=0.0,G=0.0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0,ba=0;X=i;i=i+64|0;a[X+32+16>>0]=1;W=X+32+12|0;c[W>>2]=0;c[X+32+4>>2]=0;c[X+32+8>>2]=0;q=c[f+4>>2]|0;if((q|0)>0){c[6435]=(c[6435]|0)+1;l=yc((q<<4|3)+16|0)|0;if(!l)o=0;else{c[(l+4+15&-16)+-4>>2]=l;o=l+4+15&-16}l=c[X+32+4>>2]|0;if((l|0)>0){m=0;do{V=o+(m<<4)|0;U=(c[W>>2]|0)+(m<<4)|0;c[V>>2]=c[U>>2];c[V+4>>2]=c[U+4>>2];c[V+8>>2]=c[U+8>>2];c[V+12>>2]=c[U+12>>2];m=m+1|0}while((m|0)!=(l|0))}l=c[W>>2]|0;if(l|0){if(a[X+32+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[W>>2]=0}a[X+32+16>>0]=1;c[W>>2]=o;c[X+32+8>>2]=q}l=c[d+28>>2]|0;if((l|0)>0){U=c[d+36>>2]|0;A=+g[e>>2];B=+g[e+4>>2];E=+g[e+8>>2];F=+g[e+16>>2];G=+g[e+20>>2];s=+g[e+24>>2];r=+g[e+32>>2];p=+g[e+36>>2];n=+g[e+40>>2];t=+g[b>>2];u=+g[b+4>>2];v=+g[b+8>>2];V=-1;z=3402823466385288598117041.0e14;o=0;while(1){w=+g[U+(o*36|0)+20>>2];x=+g[U+(o*36|0)+24>>2];y=+g[U+(o*36|0)+28>>2];m=(w*A+x*B+y*E)*t+(w*F+x*G+y*s)*u+(w*r+x*p+y*n)*v=0){L=c[U+(V*36|0)+4>>2]|0;if((L|0)>0){M=U+(V*36|0)+12|0;N=U+(V*36|0)+20|0;O=U+(V*36|0)+24|0;P=U+(V*36|0)+28|0;t=A;x=B;w=E;v=F;u=G;K=0;J=f;f=X+32|0;while(1){I=c[M>>2]|0;l=c[I+(K<<2)>>2]|0;H=c[d+16>>2]|0;K=K+1|0;I=c[I+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>2]=C;c[H+4>>2]=(c[H+4>>2]|0)+1}while(0);m=D+1|0;if((m|0)==(l|0))break;o=c[I+12>>2]|0;n=y;p=v;s=x;r=w;D=m}l=c[I+4>>2]|0}if((l|0)<0){if((c[I+8>>2]|0)<0){m=c[I+12>>2]|0;if(m|0){if(a[I+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0)}c[I+12>>2]=0}a[I+16>>0]=1;c[I+12>>2]=0;c[I+8>>2]=0}do{ba=(c[I+12>>2]|0)+(l<<4)|0;c[ba>>2]=c[X>>2];c[ba+4>>2]=c[X+4>>2];c[ba+8>>2]=c[X+8>>2];c[ba+12>>2]=c[X+12>>2];l=l+1|0}while((l|0)!=0)}c[I+4>>2]=0;t=+g[e>>2];x=+g[e+4>>2];w=+g[e+8>>2];v=+g[e+16>>2];u=+g[e+20>>2];s=+g[e+24>>2];r=+g[e+32>>2];p=+g[e+36>>2];n=+g[e+40>>2];if((K|0)>=(L|0)){o=N;m=O;l=P;C=e+48|0;D=e+52|0;q=e+56|0;break}else{ba=f;f=J;J=ba}}}else{o=U+(V*36|0)+20|0;m=U+(V*36|0)+24|0;l=U+(V*36|0)+28|0;C=e+48|0;D=e+52|0;q=e+56|0;t=A;x=B;w=E;v=F;u=G}Z=+g[o>>2];_=+g[m>>2];$=+g[l>>2];t=Z*t+_*x+$*w;s=Z*v+_*u+$*s;r=Z*r+_*p+$*n;p=+g[U+(V*36|0)+32>>2]-(t*+g[C>>2]+s*+g[D>>2]+r*+g[q>>2]);l=c[f+4>>2]|0;if((l|0)>0){o=0;do{m=c[f+12>>2]|0;n=p+(t*+g[m+(o<<4)>>2]+s*+g[m+(o<<4)+4>>2]+r*+g[m+(o<<4)+8>>2]);n=n<=h?h:n;if(n<=j){l=m+(o<<4)|0;c[X+16>>2]=c[l>>2];c[X+16+4>>2]=c[l+4>>2];c[X+16+8>>2]=c[l+8>>2];c[X+16+12>>2]=c[l+12>>2];hc[c[(c[k>>2]|0)+16>>2]&15](k,b,X+16|0,n);l=c[f+4>>2]|0}o=o+1|0}while((o|0)<(l|0))}}}l=c[W>>2]|0;if(!l){i=X;return}if(a[X+32+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[W>>2]=0;i=X;return}function Xc(b){b=b|0;var d=0.0,e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0;w=i;i=i+176|0;if(!(a[b+738>>0]|0)){i=w;return}g[b+36>>2]=0.0;g[b+744>>2]=0.0;if(!(a[b+736>>0]|0)){e=c[b+28>>2]|0;l=+g[b+600>>2];m=+g[b+604>>2];r=+g[b+608>>2];t=l*+g[e+20>>2]+m*+g[e+24>>2]+r*+g[e+28>>2]+ +g[e+56>>2];f=c[b+32>>2]|0;n=+g[b+664>>2];o=+g[b+668>>2];s=+g[b+672>>2];p=+g[f+52>>2];d=+g[f+56>>2];u=n*+g[f+20>>2]+o*+g[f+24>>2]+s*+g[f+28>>2]+d;v=n*+g[f+36>>2]+o*+g[f+40>>2]+s*+g[f+44>>2]+ +g[f+60>>2];q=l*+g[e+4>>2]+m*+g[e+8>>2]+r*+g[e+12>>2]+ +g[e+52>>2];r=l*+g[e+36>>2]+m*+g[e+40>>2]+r*+g[e+44>>2]+ +g[e+60>>2];s=n*+g[f+4>>2]+o*+g[f+8>>2]+s*+g[f+12>>2]+p;if((s-q)*(s-q)+(u-t)*(u-t)+(v-r)*(v-r)>1.1920928955078125e-07){j=1.0/+O(+((s-q)*(s-q)+(u-t)*(u-t)+(v-r)*(v-r)));g[w+128>>2]=(s-q)*j;g[w+128+4>>2]=(u-t)*j;g[w+128+8>>2]=(v-r)*j;c[w+128+12>>2]=0;n=(v-r)*j;h=(u-t)*j;j=(s-q)*j}else{c[w+128>>2]=1065353216;c[w+128+4>>2]=0;c[w+128+8>>2]=0;g[w+128+12>>2]=0.0;n=0.0;h=0.0;j=1.0}if(+N(+n)>.7071067690849304){y=n*n+h*h;x=1.0/+O(+y);l=-(x*n);n=x*h;o=-(n*j);k=j*l;m=0.0;h=y*x;j=n}else{l=j*j+h*h;k=1.0/+O(+l);m=-(h*k);h=k*j;o=n*m;k=l*k;l=h;h=-(h*n);j=0.0}g[w+128+16>>2]=m;g[w+128+20>>2]=l;g[w+128+24>>2]=j;g[w+128+32>>2]=h;g[w+128+36>>2]=o;g[w+128+40>>2]=k;h=p;e=0;while(1){z=c[b+28>>2]|0;c[w+80>>2]=c[z+4>>2];c[w+80+4>>2]=c[z+20>>2];c[w+80+8>>2]=c[z+36>>2];g[w+80+12>>2]=0.0;c[w+80+16>>2]=c[z+8>>2];c[w+80+20>>2]=c[z+24>>2];c[w+80+24>>2]=c[z+40>>2];g[w+80+28>>2]=0.0;c[w+80+32>>2]=c[z+12>>2];c[w+80+36>>2]=c[z+28>>2];c[w+80+40>>2]=c[z+44>>2];g[w+80+44>>2]=0.0;c[w+32>>2]=c[f+4>>2];c[w+32+4>>2]=c[f+20>>2];c[w+32+8>>2]=c[f+36>>2];g[w+32+12>>2]=0.0;c[w+32+16>>2]=c[f+8>>2];c[w+32+20>>2]=c[f+24>>2];c[w+32+24>>2]=c[f+40>>2];g[w+32+28>>2]=0.0;c[w+32+32>>2]=c[f+12>>2];c[w+32+36>>2]=c[f+28>>2];c[w+32+40>>2]=c[f+44>>2];g[w+32+44>>2]=0.0;x=t-+g[z+56>>2];y=r-+g[z+60>>2];g[w+16>>2]=q-+g[z+52>>2];g[w+16+4>>2]=x;g[w+16+8>>2]=y;g[w+16+12>>2]=0.0;y=v-+g[f+60>>2];g[w>>2]=s-h;g[w+4>>2]=u-d;g[w+8>>2]=y;g[w+12>>2]=0.0;z=c[b+28>>2]|0;f=c[b+32>>2]|0;Rg(b+48+(e*84|0)|0,w+80|0,w+32|0,w+16|0,w,w+128+(e<<4)|0,z+396|0,+g[z+344>>2],f+396|0,+g[f+344>>2]);e=e+1|0;if((e|0)==3)break;z=c[b+32>>2]|0;f=z;h=+g[z+52>>2];d=+g[z+56>>2]}}h=+g[b+560>>2];j=+g[b+576>>2];k=+g[b+592>>2];if(+N(+k)>.7071067690849304){p=1.0/+O(+(k*k+j*j));d=h*-(k*p);l=0.0;m=j*p;n=-(k*p);o=(k*k+j*j)*p;p=-(h*j*p)}else{p=1.0/+O(+(h*h+j*j));d=(h*h+j*j)*p;l=-(j*p);m=0.0;n=h*p;o=-(k*h*p);p=k*-(j*p)}f=c[b+28>>2]|0;I=+g[f+4>>2];H=+g[f+8>>2];u=+g[f+12>>2];R=l*I+n*H+m*u;G=+g[f+20>>2];F=+g[f+24>>2];x=+g[f+28>>2];T=l*G+n*F+m*x;E=+g[f+36>>2];s=+g[f+40>>2];C=+g[f+44>>2];W=l*E+n*s+m*C;B=o*I+p*H+d*u;K=o*G+p*F+d*x;L=o*E+p*s+d*C;e=c[b+32>>2]|0;A=+g[e+4>>2];l=+g[e+20>>2];m=+g[e+36>>2];q=+g[e+8>>2];r=+g[e+24>>2];v=+g[e+40>>2];P=+g[e+12>>2];S=+g[e+28>>2];V=+g[e+44>>2];c[b+300>>2]=0;c[b+300+4>>2]=0;c[b+300+8>>2]=0;c[b+300+12>>2]=0;g[b+316>>2]=R*I+T*G+W*E;g[b+320>>2]=R*H+T*F+W*s;g[b+324>>2]=R*u+T*x+W*C;g[b+328>>2]=0.0;g[b+332>>2]=A*-R+l*-T+m*-W;g[b+336>>2]=q*-R+r*-T+v*-W;g[b+340>>2]=P*-R+S*-T+V*-W;g[b+344>>2]=0.0;D=(R*I+T*G+W*E)*+g[f+396>>2];J=(R*H+T*F+W*s)*+g[f+400>>2];d=(R*u+T*x+W*C)*+g[f+404>>2];g[b+348>>2]=D;g[b+352>>2]=J;g[b+356>>2]=d;g[b+360>>2]=0.0;p=(A*-R+l*-T+m*-W)*+g[e+396>>2];y=(q*-R+r*-T+v*-W)*+g[e+400>>2];X=(P*-R+S*-T+V*-W)*+g[e+404>>2];g[b+364>>2]=p;g[b+368>>2]=y;g[b+372>>2]=X;g[b+376>>2]=0.0;g[b+380>>2]=(R*I+T*G+W*E)*D+(R*H+T*F+W*s)*J+(R*u+T*x+W*C)*d+((A*-R+l*-T+m*-W)*p+(q*-R+r*-T+v*-W)*y+(P*-R+S*-T+V*-W)*X);e=c[b+28>>2]|0;X=+g[e+4>>2];W=+g[e+20>>2];V=+g[e+36>>2];T=+g[e+8>>2];S=+g[e+24>>2];R=+g[e+40>>2];P=+g[e+12>>2];y=+g[e+28>>2];v=+g[e+44>>2];f=c[b+32>>2]|0;r=+g[f+4>>2];q=+g[f+20>>2];p=+g[f+36>>2];m=+g[f+8>>2];l=+g[f+24>>2];A=+g[f+40>>2];d=+g[f+12>>2];J=+g[f+28>>2];D=+g[f+44>>2];c[b+384>>2]=0;c[b+384+4>>2]=0;c[b+384+8>>2]=0;c[b+384+12>>2]=0;g[b+400>>2]=B*X+K*W+L*V;g[b+404>>2]=B*T+K*S+L*R;g[b+408>>2]=B*P+K*y+L*v;g[b+412>>2]=0.0;g[b+416>>2]=r*-B+q*-K+p*-L;g[b+420>>2]=m*-B+l*-K+A*-L;g[b+424>>2]=d*-B+J*-K+D*-L;g[b+428>>2]=0.0;U=(B*X+K*W+L*V)*+g[e+396>>2];Q=(B*T+K*S+L*R)*+g[e+400>>2];t=(B*P+K*y+L*v)*+g[e+404>>2];g[b+432>>2]=U;g[b+436>>2]=Q;g[b+440>>2]=t;g[b+444>>2]=0.0;n=(r*-B+q*-K+p*-L)*+g[f+396>>2];o=(m*-B+l*-K+A*-L)*+g[f+400>>2];M=(d*-B+J*-K+D*-L)*+g[f+404>>2];g[b+448>>2]=n;g[b+452>>2]=o;g[b+456>>2]=M;g[b+460>>2]=0.0;g[b+464>>2]=(B*X+K*W+L*V)*U+(B*T+K*S+L*R)*Q+(B*P+K*y+L*v)*t+((r*-B+q*-K+p*-L)*n+(m*-B+l*-K+A*-L)*o+(d*-B+J*-K+D*-L)*M);f=c[b+28>>2]|0;M=+g[f+4>>2];L=+g[f+20>>2];D=+g[f+36>>2];K=+g[f+8>>2];J=+g[f+24>>2];B=+g[f+40>>2];d=+g[f+12>>2];o=+g[f+28>>2];A=+g[f+44>>2];e=c[b+32>>2]|0;l=+g[e+4>>2];m=+g[e+20>>2];n=+g[e+36>>2];p=+g[e+8>>2];q=+g[e+24>>2];r=+g[e+40>>2];t=+g[e+12>>2];v=+g[e+28>>2];y=+g[e+44>>2];c[b+468>>2]=0;c[b+468+4>>2]=0;c[b+468+8>>2]=0;c[b+468+12>>2]=0;D=(I*h+H*j+u*k)*M+(G*h+F*j+x*k)*L+(E*h+s*j+C*k)*D;B=(I*h+H*j+u*k)*K+(G*h+F*j+x*k)*J+(E*h+s*j+C*k)*B;A=(I*h+H*j+u*k)*d+(G*h+F*j+x*k)*o+(E*h+s*j+C*k)*A;g[b+484>>2]=D;g[b+488>>2]=B;g[b+492>>2]=A;g[b+496>>2]=0.0;u=-(I*h+H*j+u*k);x=-(G*h+F*j+x*k);h=-(E*h+s*j+C*k);g[b+500>>2]=l*u+m*x+n*h;g[b+504>>2]=p*u+q*x+r*h;g[b+508>>2]=t*u+v*x+y*h;g[b+512>>2]=0.0;C=D*+g[f+396>>2];j=B*+g[f+400>>2];k=A*+g[f+404>>2];g[b+516>>2]=C;g[b+520>>2]=j;g[b+524>>2]=k;g[b+528>>2]=0.0;o=(l*u+m*x+n*h)*+g[e+396>>2];s=(p*u+q*x+r*h)*+g[e+400>>2];d=(t*u+v*x+y*h)*+g[e+404>>2];g[b+532>>2]=o;g[b+536>>2]=s;g[b+540>>2]=d;g[b+544>>2]=0.0;g[b+548>>2]=D*C+B*j+A*k+((l*u+m*x+n*h)*o+(p*u+q*x+r*h)*s+(t*u+v*x+y*h)*d);g[b+724>>2]=0.0;e=c[b+28>>2]|0;f=c[b+32>>2]|0;d=+kj(b,e+4|0,f+4|0);g[b+728>>2]=d;g[b+708>>2]=0.0;g[b+712>>2]=0.0;a[b+716>>0]=0;h=+g[b+692>>2];do if(h>=0.0){d=+eh(d-+g[b+688>>2],6.2831854820251465);if(!(d<-3.1415927410125732)){if(d>3.1415927410125732)d=d+-6.2831854820251465}else d=d+6.2831854820251465;if(d<-h){a[b+716>>0]=1;g[b+708>>2]=-(d+h);g[b+712>>2]=1.0;break}if(d>h){a[b+716>>0]=1;g[b+708>>2]=h-d;g[b+712>>2]=-1.0}}while(0);T=+g[b+560>>2];U=+g[b+576>>2];X=+g[b+592>>2];V=T*+g[e+4>>2]+U*+g[e+8>>2]+X*+g[e+12>>2];W=T*+g[e+20>>2]+U*+g[e+24>>2]+X*+g[e+28>>2];X=T*+g[e+36>>2]+U*+g[e+40>>2]+X*+g[e+44>>2];g[b+720>>2]=1.0/(V*(V*+g[e+264>>2]+W*+g[e+280>>2]+X*+g[e+296>>2])+W*(V*+g[e+268>>2]+W*+g[e+284>>2]+X*+g[e+300>>2])+X*(V*+g[e+272>>2]+W*+g[e+288>>2]+X*+g[e+304>>2])+(V*(V*+g[f+264>>2]+W*+g[f+280>>2]+X*+g[f+296>>2])+W*(V*+g[f+268>>2]+W*+g[f+284>>2]+X*+g[f+300>>2])+X*(V*+g[f+272>>2]+W*+g[f+288>>2]+X*+g[f+304>>2])));i=w;return}function Yc(b,d,e,f,h,j,l,m,n,o){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;l=l|0;m=m|0;n=n|0;o=o|0;var p=0.0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0;B=i;i=i+4224|0;if(((c[e+4>>2]|0)+-17|0)>>>0<2)A=((c[f+4>>2]|0)+-17|0)>>>0<2;else A=0;b=0;do{Ue();t=+g[24672+(b<<4)>>2];u=+g[24672+(b<<4)+4>>2];v=+g[24672+(b<<4)+8>>2];y=+g[h+4>>2]*-t+ +g[h+20>>2]*-u+ +g[h+36>>2]*-v;w=+g[h+8>>2]*-t+ +g[h+24>>2]*-u+ +g[h+40>>2]*-v;g[B+1248+(b<<4)>>2]=+g[h>>2]*-t+ +g[h+16>>2]*-u+ +g[h+32>>2]*-v;g[B+1248+(b<<4)+4>>2]=y;g[B+1248+(b<<4)+8>>2]=w;g[B+1248+(b<<4)+12>>2]=0.0;w=t*+g[j+4>>2]+u*+g[j+20>>2]+v*+g[j+36>>2];y=t*+g[j+8>>2]+u*+g[j+24>>2]+v*+g[j+40>>2];g[B+256+(b<<4)>>2]=t*+g[j>>2]+u*+g[j+16>>2]+v*+g[j+32>>2];g[B+256+(b<<4)+4>>2]=w;g[B+256+(b<<4)+8>>2]=y;g[B+256+(b<<4)+12>>2]=0.0;b=b+1|0}while((b|0)!=42);b=Eb[c[(c[e>>2]|0)+84>>2]&127](e)|0;if((b|0)>0){q=0;r=42;while(1){ic[c[(c[e>>2]|0)+88>>2]&127](e,q,B+176|0);w=+g[B+176>>2];y=+g[B+176+4>>2];v=+g[B+176+8>>2];u=w*+g[h+16>>2]+y*+g[h+20>>2]+v*+g[h+24>>2];t=w*+g[h+32>>2]+y*+g[h+36>>2]+v*+g[h+40>>2];g[B+176>>2]=+g[h>>2]*w+ +g[h+4>>2]*y+ +g[h+8>>2]*v;g[B+176+4>>2]=u;g[B+176+8>>2]=t;g[B+176+12>>2]=0.0;Ue();z=24672+(r<<4)|0;c[z>>2]=c[B+176>>2];c[z+4>>2]=c[B+176+4>>2];c[z+8>>2]=c[B+176+8>>2];c[z+12>>2]=c[B+176+12>>2];t=+g[B+176>>2];u=+g[B+176+4>>2];v=+g[B+176+8>>2];y=+g[h+4>>2]*-t+ +g[h+20>>2]*-u+ +g[h+36>>2]*-v;w=+g[h+8>>2]*-t+ +g[h+24>>2]*-u+ +g[h+40>>2]*-v;g[B+1248+(r<<4)>>2]=+g[h>>2]*-t+ +g[h+16>>2]*-u+ +g[h+32>>2]*-v;g[B+1248+(r<<4)+4>>2]=y;g[B+1248+(r<<4)+8>>2]=w;g[B+1248+(r<<4)+12>>2]=0.0;w=t*+g[j+4>>2]+u*+g[j+20>>2]+v*+g[j+36>>2];y=t*+g[j+8>>2]+u*+g[j+24>>2]+v*+g[j+40>>2];g[B+256+(r<<4)>>2]=+g[j>>2]*t+ +g[j+16>>2]*u+ +g[j+32>>2]*v;g[B+256+(r<<4)+4>>2]=w;g[B+256+(r<<4)+8>>2]=y;g[B+256+(r<<4)+12>>2]=0.0;q=q+1|0;if((q|0)==(b|0))break;else r=r+1|0}r=b+42|0}else r=42;b=Eb[c[(c[f>>2]|0)+84>>2]&127](f)|0;if((b|0)>0){q=0;s=r;while(1){ic[c[(c[f>>2]|0)+88>>2]&127](f,q,B+176|0);w=+g[B+176>>2];y=+g[B+176+4>>2];v=+g[B+176+8>>2];u=w*+g[j+16>>2]+y*+g[j+20>>2]+v*+g[j+24>>2];t=w*+g[j+32>>2]+y*+g[j+36>>2]+v*+g[j+40>>2];g[B+176>>2]=+g[j>>2]*w+ +g[j+4>>2]*y+ +g[j+8>>2]*v;g[B+176+4>>2]=u;g[B+176+8>>2]=t;g[B+176+12>>2]=0.0;Ue();z=24672+(s<<4)|0;c[z>>2]=c[B+176>>2];c[z+4>>2]=c[B+176+4>>2];c[z+8>>2]=c[B+176+8>>2];c[z+12>>2]=c[B+176+12>>2];t=+g[B+176>>2];u=+g[B+176+4>>2];v=+g[B+176+8>>2];y=+g[h+4>>2]*-t+ +g[h+20>>2]*-u+ +g[h+36>>2]*-v;w=+g[h+8>>2]*-t+ +g[h+24>>2]*-u+ +g[h+40>>2]*-v;g[B+1248+(s<<4)>>2]=+g[h>>2]*-t+ +g[h+16>>2]*-u+ +g[h+32>>2]*-v;g[B+1248+(s<<4)+4>>2]=y;g[B+1248+(s<<4)+8>>2]=w;g[B+1248+(s<<4)+12>>2]=0.0;w=t*+g[j+4>>2]+u*+g[j+20>>2]+v*+g[j+36>>2];y=t*+g[j+8>>2]+u*+g[j+24>>2]+v*+g[j+40>>2];g[B+256+(s<<4)>>2]=+g[j>>2]*t+ +g[j+16>>2]*u+ +g[j+32>>2]*v;g[B+256+(s<<4)+4>>2]=w;g[B+256+(s<<4)+8>>2]=y;g[B+256+(s<<4)+12>>2]=0.0;q=q+1|0;if((q|0)==(b|0))break;else s=s+1|0}r=b+r|0}mc[c[(c[e>>2]|0)+76>>2]&127](e,B+1248|0,B+3232|0,r);mc[c[(c[f>>2]|0)+76>>2]&127](f,B+256|0,B+2240|0,r);if((r|0)>0){z=0;b=0;q=0;s=0;w=0.0;u=999999984306749440.0;while(1){Ue();p=+g[24672+(z<<4)>>2];t=+g[24672+(z<<4)+4>>2];y=+g[24672+(z<<4)+12>>2];v=A?0.0:+g[24672+(z<<4)+8>>2];if(p*p+t*t+v*v>.01?(D=+g[B+3232+(z<<4)>>2],C=+g[B+3232+(z<<4)+4>>2],x=+g[B+3232+(z<<4)+8>>2],G=+g[B+2240+(z<<4)>>2],F=+g[B+2240+(z<<4)+4>>2],E=+g[B+2240+(z<<4)+8>>2],x=p*(G*+g[j>>2]+F*+g[j+4>>2]+E*+g[j+8>>2]+ +g[j+48>>2]-(D*+g[h>>2]+C*+g[h+4>>2]+x*+g[h+8>>2]+ +g[h+48>>2]))+t*(G*+g[j+16>>2]+F*+g[j+20>>2]+E*+g[j+24>>2]+ +g[j+52>>2]-(D*+g[h+16>>2]+C*+g[h+20>>2]+x*+g[h+24>>2]+ +g[h+52>>2]))+v*((A?0.0:G*+g[j+32>>2]+F*+g[j+36>>2]+E*+g[j+40>>2]+ +g[j+56>>2])-(A?0.0:D*+g[h+32>>2]+C*+g[h+36>>2]+x*+g[h+40>>2]+ +g[h+56>>2])),x>2]=p,c[k>>2]|0);q=(g[k>>2]=t,c[k>>2]|0);s=(g[k>>2]=v,c[k>>2]|0);u=x}else y=w;z=z+1|0;if((z|0)==(r|0)){z=b;r=s;break}else w=y}}else{z=0;q=0;r=0;y=0.0;u=999999984306749440.0}switch(c[e+4>>2]|0){case 4:case 5:case 10:case 11:case 13:case 1:case 0:case 8:break;default:+Sb[c[(c[e>>2]|0)+48>>2]&15](e)}v=(c[k>>2]=z,+g[k>>2]);w=(c[k>>2]=q,+g[k>>2]);x=(c[k>>2]=r,+g[k>>2]);switch(c[f+4>>2]|0){case 4:case 5:case 10:case 11:case 13:case 1:case 0:case 8:break;default:+Sb[c[(c[f>>2]|0)+48>>2]&15](f)}if(u<0.0){l=0;i=B;return l|0}switch(c[e+4>>2]|0){case 8:{p=+g[e+28>>2]*+g[e+12>>2];break}case 0:{p=+g[e+44>>2];break}case 1:{p=+g[e+44>>2];break}case 13:{p=+g[e+44>>2];break}case 11:{p=+g[e+44>>2];break}case 10:{p=+g[e+44>>2];break}case 4:case 5:{p=+g[e+44>>2];break}default:p=+Sb[c[(c[e>>2]|0)+48>>2]&15](e)}b=c[f+4>>2]|0;switch(b|0){case 8:{t=+g[f+28>>2]*+g[f+12>>2];b=8;break}case 0:{t=+g[f+44>>2];b=0;break}case 1:{t=+g[f+44>>2];b=1;break}case 13:{t=+g[f+44>>2];b=13;break}case 11:{t=+g[f+44>>2];b=11;break}case 10:{t=+g[f+44>>2];b=10;break}case 4:case 5:{t=+g[f+44>>2];break}default:{t=+Sb[c[(c[f>>2]|0)+48>>2]&15](f);b=c[f+4>>2]|0}}p=u+(p+t+.5);c[B+176>>2]=9208;c[B+176+4>>2]=0;c[B+176+8>>2]=1065353216;c[B+176+12>>2]=0;g[B+176+16>>2]=0.0;c[B+176+20>>2]=0;c[B+176+24>>2]=d;c[B+176+28>>2]=e;c[B+176+32>>2]=f;c[B+176+36>>2]=c[e+4>>2];c[B+176+40>>2]=b;g[B+176+44>>2]=+Sb[c[(c[e>>2]|0)+48>>2]&15](e);g[B+176+48>>2]=+Sb[c[(c[f>>2]|0)+48>>2]&15](f);a[B+176+52>>0]=0;c[B+176+60>>2]=-1;c[B+176+72>>2]=1;c[B+176+76>>2]=1;E=v*p+ +g[h+48>>2];F=w*p+ +g[h+52>>2];G=x*p+ +g[h+56>>2];c[B+44>>2]=c[h>>2];c[B+44+4>>2]=c[h+4>>2];c[B+44+8>>2]=c[h+8>>2];c[B+44+12>>2]=c[h+12>>2];c[B+44+16>>2]=c[h+16>>2];c[B+44+16+4>>2]=c[h+16+4>>2];c[B+44+16+8>>2]=c[h+16+8>>2];c[B+44+16+12>>2]=c[h+16+12>>2];c[B+44+32>>2]=c[h+32>>2];c[B+44+32+4>>2]=c[h+32+4>>2];c[B+44+32+8>>2]=c[h+32+8>>2];c[B+44+32+12>>2]=c[h+32+12>>2];g[B+44+48>>2]=E;g[B+44+52>>2]=F;g[B+44+56>>2]=G;g[B+44+60>>2]=0.0;c[B+44+64>>2]=c[j>>2];c[B+44+64+4>>2]=c[j+4>>2];c[B+44+64+8>>2]=c[j+8>>2];c[B+44+64+12>>2]=c[j+12>>2];c[B+44+80>>2]=c[j+16>>2];c[B+44+80+4>>2]=c[j+16+4>>2];c[B+44+80+8>>2]=c[j+16+8>>2];c[B+44+80+12>>2]=c[j+16+12>>2];c[B+44+96>>2]=c[j+32>>2];c[B+44+96+4>>2]=c[j+32+4>>2];c[B+44+96+8>>2]=c[j+32+8>>2];c[B+44+96+12>>2]=c[j+32+12>>2];c[B+44+112>>2]=c[j+48>>2];c[B+44+112+4>>2]=c[j+48+4>>2];c[B+44+112+8>>2]=c[j+48+8>>2];c[B+44+112+12>>2]=c[j+48+12>>2];g[B+44+128>>2]=999999984306749440.0;c[B>>2]=9092;a[B+40>>0]=0;g[B+176+4>>2]=-v;g[B+176+8>>2]=-w;g[B+176+12>>2]=-x;g[B+176+16>>2]=0.0;Vc(B+176|0,B+44|0,B,o,0);p=p-+g[B+36>>2];b=a[B+40>>0]|0;if(b<<24>>24){F=+g[B+24>>2]-w*p;G=+g[B+28>>2]-x*p;g[m>>2]=+g[B+20>>2]-v*p;g[m+4>>2]=F;g[m+8>>2]=G;g[m+12>>2]=0.0;c[n>>2]=c[B+20>>2];c[n+4>>2]=c[B+20+4>>2];c[n+8>>2]=c[B+20+8>>2];c[n+12>>2]=c[B+20+12>>2];c[l>>2]=z;c[l+4>>2]=q;c[l+8>>2]=r;g[l+12>>2]=y}l=b<<24>>24!=0;i=B;return l|0}function Zc(d,f,h,i){d=d|0;f=f|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0;c[d+168>>2]=c[d+152>>2];c[f>>2]=9012;c[f+52>>2]=282;a[f+60>>0]=0;a[f+80>>0]=1;c[f+76>>2]=0;c[f+68>>2]=0;c[f+72>>2]=0;a[f+100>>0]=1;c[f+96>>2]=0;c[f+88>>2]=0;c[f+92>>2]=0;a[f+120>>0]=1;c[f+116>>2]=0;c[f+108>>2]=0;c[f+112>>2]=0;a[f+140>>0]=1;c[f+136>>2]=0;c[f+128>>2]=0;c[f+132>>2]=0;c[f+144>>2]=0;a[f+164>>0]=1;c[f+160>>2]=0;c[f+152>>2]=0;c[f+156>>2]=0;c[f+168>>2]=0;c[f+4>>2]=-8388609;c[f+8>>2]=-8388609;c[f+12>>2]=-8388609;g[f+16>>2]=0.0;c[f+20>>2]=2139095039;c[f+24>>2]=2139095039;c[f+28>>2]=2139095039;g[f+32>>2]=0.0;h=c[d+56>>2]|0;if(i){c[f+56>>2]=ow(h|0)|0;a[f+4>>0]=a[d+4+3>>0]|0;a[f+5>>0]=a[d+4+2>>0]|0;a[f+6>>0]=a[d+4+1>>0]|0;a[f+7>>0]=a[d+4>>0]|0;a[f+8>>0]=a[d+8+3>>0]|0;a[f+9>>0]=a[d+8+2>>0]|0;a[f+10>>0]=a[d+8+1>>0]|0;a[f+11>>0]=a[d+8>>0]|0;a[f+12>>0]=a[d+12+3>>0]|0;a[f+13>>0]=a[d+12+2>>0]|0;a[f+14>>0]=a[d+12+1>>0]|0;a[f+15>>0]=a[d+12>>0]|0;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h+-4>>2]|0)}c[f+96>>2]=0}c[f+88>>2]=0;c[f+88+4>>2]=0;c[f+88+8>>2]=0;a[f+88+12>>0]=0;h=l<<6}else{h=c[f+136>>2]|0;if(h|0){if(a[f+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[f+136>>2]=0}c[f+128>>2]=0;c[f+128+4>>2]=0;c[f+128+8>>2]=0;a[f+128+12>>0]=0;c[f+136>>2]=f+172;c[f+128>>2]=l;c[f+132>>2]=l;if(i){if((l|0)>0){h=c[d+136>>2]|0;j=0;do{o=e[h+(j<<4)>>1]|0;b[f+172+(j<<4)>>1]=o>>>8|o<<8;o=e[h+(j<<4)+2>>1]|0;b[f+172+(j<<4)+2>>1]=o>>>8|o<<8;o=e[h+(j<<4)+4>>1]|0;b[f+172+(j<<4)+4>>1]=o>>>8|o<<8;o=e[h+(j<<4)+6>>1]|0;b[f+172+(j<<4)+6>>1]=o>>>8|o<<8;o=e[h+(j<<4)+8>>1]|0;b[f+172+(j<<4)+8>>1]=o>>>8|o<<8;o=e[h+(j<<4)+10>>1]|0;b[f+172+(j<<4)+10>>1]=o>>>8|o<<8;c[f+172+(j<<4)+12>>2]=ow(c[h+(j<<4)+12>>2]|0)|0;j=j+1|0}while((j|0)!=(l|0))}}else if((l|0)>0){h=c[d+136>>2]|0;j=0;do{b[f+172+(j<<4)>>1]=b[h+(j<<4)>>1]|0;b[f+172+(j<<4)+2>>1]=b[h+(j<<4)+2>>1]|0;b[f+172+(j<<4)+4>>1]=b[h+(j<<4)+4>>1]|0;b[f+172+(j<<4)+6>>1]=b[h+(j<<4)+6>>1]|0;b[f+172+(j<<4)+8>>1]=b[h+(j<<4)+8>>1]|0;b[f+172+(j<<4)+10>>1]=b[h+(j<<4)+10>>1]|0;c[f+172+(j<<4)+12>>2]=c[h+(j<<4)+12>>2];j=j+1|0}while((j|0)!=(l|0))}if(c[f+136>>2]|0)c[f+136>>2]=0;c[f+128>>2]=0;c[f+128+4>>2]=0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+(j<<5)+28>>2]=0;j=j+1|0}while((j|0)<(c[d+168>>2]|0))}if(!(c[f+160>>2]|0)){c[f>>2]=0;c[f+152>>2]=0;c[f+152+4>>2]=0;c[f+152+8>>2]=0;a[f+152+12>>0]=0;return 1}c[f+160>>2]=0;c[f>>2]=0;c[f+152>>2]=0;c[f+152+4>>2]=0;c[f+152+8>>2]=0;a[f+152+12>>0]=0;return 1}function _c(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0,J=0,K=0,L=0,M=0.0,P=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0,ca=0.0,da=0.0,ea=0.0,fa=0.0,ga=0.0,ha=0.0,ia=0.0,ja=0.0,ka=0.0,la=0.0,ma=0.0,na=0.0,oa=0.0;I=i;i=i+96|0;if(!(c[b+12>>2]|0)){i=I;return}f=(a[b+16>>0]|0)!=0;L=f?e:d;f=f?d:e;j=c[L+4>>2]|0;k=c[f+4>>2]|0;L=c[L+12>>2]|0;aa=+g[L>>2];$=+g[L+16>>2];_=+g[L+32>>2];Z=+g[L+4>>2];Y=+g[L+20>>2];o=+g[L+36>>2];l=+g[L+8>>2];r=+g[L+24>>2];y=+g[L+40>>2];T=+g[L+48>>2];S=+g[L+52>>2];P=+g[L+56>>2];K=c[f+12>>2]|0;X=+g[K>>2];W=+g[K+16>>2];p=+g[K+32>>2];V=+g[K+4>>2];U=+g[K+20>>2];q=+g[K+36>>2];x=+g[K+8>>2];v=+g[K+24>>2];t=+g[K+40>>2];M=-+g[K+48>>2];E=-+g[K+52>>2];F=-+g[K+56>>2];G=+g[L>>2];H=+g[L+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>2];z=+g[L+36>>2];A=+g[L+40>>2];B=+g[L+48>>2];C=+g[L+52>>2];D=+g[L+56>>2];L=c[b+12>>2]|0;K=o<+g[L+752>>2];c[h+4>>2]=L;if(K){L=c[f+12>>2]|0;$=l*+g[L+16>>2]+m*+g[L+20>>2]+n*+g[L+24>>2];aa=l*+g[L+32>>2]+m*+g[L+36>>2]+n*+g[L+40>>2];g[I+80>>2]=+g[L>>2]*l+ +g[L+4>>2]*m+ +g[L+8>>2]*n;g[I+80+4>>2]=$;g[I+80+8>>2]=aa;g[I+80+12>>2]=0.0;g[I+64>>2]=u*r+(s*p+t*q)+B;g[I+64+4>>2]=p*v+q*w+r*x+C;g[I+64+8>>2]=p*y+q*z+r*A+D;g[I+64+12>>2]=0.0;hc[c[(c[h>>2]|0)+16>>2]&15](h,I+80|0,I+64|0,o)}if((c[j+4>>2]|0)<7?(c[(c[h+4>>2]|0)+748>>2]|0)<(c[b+24>>2]|0):0){l=+g[k+56>>2];if(+N(+l)>.7071067690849304){n=+g[k+52>>2];aa=1.0/+O(+(l*l+n*n));m=0.0;n=n*aa;l=-(l*aa)}else{aa=+g[k+48>>2];m=+g[k+52>>2];l=1.0/+O(+(aa*aa+m*m));m=-(m*l);n=0.0;l=aa*l}F=.019999999552965164/+Sb[c[(c[j>>2]|0)+16>>2]&15](j);F=(F>.39269909262657166?.39269909262657166:F)*.5;E=+R(+F)/+O(+(m*m+l*l+n*n));H=m*E;G=l*E;E=n*E;F=+Q(+F);f=c[b+20>>2]|0;if((f|0)>0){j=0;do{v=+g[k+48>>2];aa=+g[k+52>>2];B=+g[k+56>>2];z=+(j|0)*(6.2831854820251465/+(f|0))*.5;$=+R(+z)/+O(+(v*v+aa*aa+B*B));z=+Q(+z);A=E*-(aa*$)+(H*z+F*-(v*$))-G*-(B*$);x=H*-(B*$)+(G*z+F*-(aa*$))-E*-(v*$);da=G*-(v*$)+(E*z+F*-(B*$))-H*-(aa*$);D=F*z-H*-(v*$)-G*-(aa*$)-E*-(B*$);ia=B*$*x+(v*$*D+z*A)-aa*$*da;ha=v*$*da+(z*x+aa*$*D)-B*$*A;la=aa*$*A+(B*$*D+z*da)-v*$*x;da=z*D-v*$*A-aa*$*x-B*$*da;f=(a[b+16>>0]|0)!=0;ba=f?e:d;f=f?d:e;L=c[ba+4>>2]|0;K=c[f+4>>2]|0;ba=c[ba+12>>2]|0;$=+g[ba>>2];B=+g[ba+4>>2];x=+g[ba+8>>2];aa=+g[ba+16>>2];A=+g[ba+20>>2];v=+g[ba+24>>2];D=+g[ba+32>>2];z=+g[ba+36>>2];t=+g[ba+40>>2];V=+g[ba+48>>2];W=+g[ba+52>>2];X=+g[ba+56>>2];ba=c[f+12>>2]|0;P=+g[ba>>2];S=+g[ba+16>>2];p=+g[ba+32>>2];T=+g[ba+4>>2];U=+g[ba+20>>2];q=+g[ba+36>>2];w=+g[ba+8>>2];u=+g[ba+24>>2];s=+g[ba+40>>2];Y=-+g[ba+48>>2];Z=-+g[ba+52>>2];_=-+g[ba+56>>2];ga=ia*(2.0/(ia*ia+ha*ha+la*la+da*da));n=ha*(2.0/(ia*ia+ha*ha+la*la+da*da));ca=la*(2.0/(ia*ia+ha*ha+la*la+da*da));na=x*(ia*ca-da*n)+(B*(ia*n+da*ca)+$*(1.0-(ha*n+la*ca)));ka=x*(ha*ca+da*ga)+($*(ia*n-da*ca)+B*(1.0-(ia*ga+la*ca)));l=$*(ia*ca+da*n)+B*(ha*ca-da*ga)+x*(1.0-(ia*ga+ha*n));ma=v*(ia*ca-da*n)+(A*(ia*n+da*ca)+aa*(1.0-(ha*n+la*ca)));ja=v*(ha*ca+da*ga)+(aa*(ia*n-da*ca)+A*(1.0-(ia*ga+la*ca)));y=aa*(ia*ca+da*n)+A*(ha*ca-da*ga)+v*(1.0-(ia*ga+ha*n));oa=t*(ia*ca-da*n)+(z*(ia*n+da*ca)+D*(1.0-(ha*n+la*ca)));la=t*(ha*ca+da*ga)+(D*(ia*n-da*ca)+z*(1.0-(ia*ga+la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)+(($*w+aa*u+D*s)*C+(B*w+A*u+z*s)*y+(x*w+v*u+t*s)*r)-n*o;K=c[f+12>>2]|0;s=+g[K>>2];t=+g[K+4>>2];u=+g[K+8>>2];v=+g[K+16>>2];w=+g[K+20>>2];x=+g[K+24>>2];y=+g[K+32>>2];z=+g[K+36>>2];A=+g[K+40>>2];B=+g[K+48>>2];C=+g[K+52>>2];D=+g[K+56>>2];K=c[b+12>>2]|0;L=o<+g[K+752>>2];c[h+4>>2]=K;if(L){ba=c[f+12>>2]|0;na=l*+g[ba+16>>2]+m*+g[ba+20>>2]+n*+g[ba+24>>2];oa=l*+g[ba+32>>2]+m*+g[ba+36>>2]+n*+g[ba+40>>2];g[I+48>>2]=+g[ba>>2]*l+ +g[ba+4>>2]*m+ +g[ba+8>>2]*n;g[I+48+4>>2]=na;g[I+48+8>>2]=oa;g[I+48+12>>2]=0.0;g[I+32>>2]=u*r+(s*p+t*q)+B;g[I+32+4>>2]=p*v+q*w+r*x+C;g[I+32+8>>2]=p*y+q*z+r*A+D;g[I+32+12>>2]=0.0;hc[c[(c[h>>2]|0)+16>>2]&15](h,I+48|0,I+32|0,o)}j=j+1|0;f=c[b+20>>2]|0}while((j|0)<(f|0))}}do if((a[b+8>>0]|0?c[(c[b+12>>2]|0)+748>>2]|0:0)?(J=c[h+4>>2]|0,c[J+748>>2]|0):0){j=c[J+740>>2]|0;k=c[(c[h+8>>2]|0)+8>>2]|0;f=c[(c[h+12>>2]|0)+8>>2]|0;if((j|0)==(k|0)){ef(J,j+4|0,f+4|0);break}else{ef(J,f+4|0,k+4|0);break}}while(0);i=I;return}function $c(b){b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0,F=0,G=0,H=0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0;H=i;i=i+192|0;li(11018);d=c[b+1112>>2]|0;if((d|0)>0){G=0;do{F=c[(c[b+1120>>2]|0)+(G<<2)>>2]|0;E=c[F+24>>2]|0;if(E){j=H+144|0;k=j+48|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(k|0));g[H+144>>2]=9.999999747378752e-05;g[H+144+20>>2]=1.9999999494757503e-04;g[H+144+40>>2]=2.9999998514540493e-04;if((E|0)>0){d=c[F+32>>2]|0;j=c[F+12>>2]|0;f=0.0;h=0.0;e=0.0;k=0;do{D=c[d+(k<<2)>>2]|0;C=+g[j+(k<<2)>>2];f=f+ +g[D+8>>2]*C;e=e+C*+g[D+12>>2];h=h+C*+g[D+16>>2];k=k+1|0}while((k|0)!=(E|0))}else{f=0.0;h=0.0;e=0.0}r=+g[F+128>>2];t=f*r;s=e*r;r=h*r;g[F+228>>2]=t;g[F+232>>2]=s;g[F+236>>2]=r;g[F+240>>2]=0.0;if((E|0)>0){d=c[F+32>>2]|0;j=c[F+52>>2]|0;e=9.999999747378752e-05;f=+g[H+144+4>>2];h=+g[H+144+8>>2];l=+g[H+144+16>>2];m=1.9999999494757503e-04;n=+g[H+144+24>>2];o=0.0;p=0.0;q=2.9999998514540493e-04;k=0;while(1){D=c[d+(k<<2)>>2]|0;x=+g[D+8>>2]-t;y=+g[D+12>>2]-s;B=+g[D+16>>2]-r;z=+g[j+(k<<4)>>2];A=+g[j+(k<<4)+4>>2];C=+g[j+(k<<4)+8>>2];e=x*z+e;f=x*A+f;h=x*C+h;l=y*z+l;m=y*A+m;n=y*C+n;o=B*z+o;p=B*A+p;q=B*C+q;if((k|0)==(E+-1|0))break;k=k+1|0}g[H+144>>2]=e;g[H+144+4>>2]=f;g[H+144+8>>2]=h;g[H+144+16>>2]=l;g[H+144+20>>2]=m;g[H+144+24>>2]=n;g[H+144+32>>2]=o;g[H+144+36>>2]=p;g[H+144+40>>2]=q}if((a[22520]|0)==0?Wa(22520)|0:0){g[5787]=9.999999747378752e-05;c[5788]=16;_a(22520)}md(H+144|0,H+96|0,H+48|0);c[F+108>>2]=c[F+228>>2];c[F+108+4>>2]=c[F+228+4>>2];c[F+108+8>>2]=c[F+228+8>>2];c[F+108+12>>2]=c[F+228+12>>2];c[F+60>>2]=c[H+96>>2];c[F+60+4>>2]=c[H+96+4>>2];c[F+60+8>>2]=c[H+96+8>>2];c[F+60+12>>2]=c[H+96+12>>2];c[F+76>>2]=c[H+96+16>>2];c[F+76+4>>2]=c[H+96+16+4>>2];c[F+76+8>>2]=c[H+96+16+8>>2];c[F+76+12>>2]=c[H+96+16+12>>2];c[F+92>>2]=c[H+96+32>>2];c[F+92+4>>2]=c[H+96+32+4>>2];c[F+92+8>>2]=c[H+96+32+8>>2];c[F+92+12>>2]=c[H+96+32+12>>2];m=+g[F+132>>2];K=+g[F+60>>2];n=+g[F+148>>2];J=+g[F+64>>2];o=+g[F+164>>2];A=+g[F+68>>2];p=+g[F+136>>2];q=+g[F+152>>2];r=+g[F+168>>2];s=+g[F+140>>2];t=+g[F+156>>2];C=+g[F+172>>2];I=+g[F+76>>2];e=+g[F+80>>2];B=+g[F+84>>2];l=+g[F+92>>2];h=+g[F+96>>2];f=+g[F+100>>2];u=(m*K+n*J+o*A)*K+(K*p+J*q+A*r)*J+(K*s+J*t+A*C)*A;v=(m*K+n*J+o*A)*I+(K*p+J*q+A*r)*e+(K*s+J*t+A*C)*B;w=(m*K+n*J+o*A)*l+(K*p+J*q+A*r)*h+(K*s+J*t+A*C)*f;x=(m*I+n*e+o*B)*K+(p*I+q*e+r*B)*J+(s*I+t*e+C*B)*A;y=(m*I+n*e+o*B)*I+(p*I+q*e+r*B)*e+(s*I+t*e+C*B)*B;z=(m*I+n*e+o*B)*l+(p*I+q*e+r*B)*h+(s*I+t*e+C*B)*f;A=K*(m*l+n*h+o*f)+(p*l+q*h+r*f)*J+(s*l+t*h+C*f)*A;B=I*(m*l+n*h+o*f)+(p*l+q*h+r*f)*e+(s*l+t*h+C*f)*B;C=(m*l+n*h+o*f)*l+(p*l+q*h+r*f)*h+(s*l+t*h+C*f)*f;g[F+180>>2]=u;g[F+184>>2]=v;g[F+188>>2]=w;g[F+192>>2]=0.0;g[F+196>>2]=x;g[F+200>>2]=y;g[F+204>>2]=z;g[F+208>>2]=0.0;g[F+212>>2]=A;g[F+216>>2]=B;g[F+220>>2]=C;g[F+224>>2]=0.0;c[F+316>>2]=0;c[F+316+4>>2]=0;c[F+316+8>>2]=0;c[F+316+12>>2]=0;c[F+316+16>>2]=0;c[F+316+20>>2]=0;c[F+316+24>>2]=0;c[F+316+28>>2]=0;if((E|0)>0){d=c[F+32>>2]|0;j=c[F+12>>2]|0;r=+g[F+228>>2];s=+g[F+232>>2];t=+g[F+236>>2];q=0.0;p=0.0;o=0.0;n=0.0;m=0.0;e=0.0;k=0;do{D=c[d+(k<<2)>>2]|0;M=+g[j+(k<<2)>>2];J=+g[D+40>>2]*M;L=M*+g[D+44>>2];M=M*+g[D+48>>2];q=J+q;g[F+316>>2]=q;p=L+p;g[F+320>>2]=p;o=M+o;g[F+324>>2]=o;I=+g[D+8>>2]-r;K=+g[D+12>>2]-s;N=+g[D+16>>2]-t;n=n+(M*K-L*N);g[F+332>>2]=n;m=J*N-M*I+m;g[F+336>>2]=m;e=L*I-J*K+e;g[F+340>>2]=e;k=k+1|0}while((k|0)!=(E|0));d=F+332|0;D=F+316|0}else{d=F+332|0;D=F+316|0;q=0.0;p=0.0;o=0.0;n=0.0;m=0.0;e=0.0}M=+g[F+128>>2];N=1.0-+g[F+356>>2];g[F+316>>2]=q*M*N;g[F+320>>2]=M*p*N;g[F+324>>2]=M*o*N;g[F+328>>2]=0.0;N=1.0-+g[F+360>>2];g[d>>2]=(u*n+v*m+w*e)*N;g[F+336>>2]=(n*x+m*y+e*z)*N;g[F+340>>2]=N*(n*A+m*B+e*C);g[F+344>>2]=0.0;j=F+244|0;k=j+72|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(k|0));e=+g[F+364>>2];a:do if(e>0.0?(c[F+24>>2]|0)>0:0){d=0;while(1){k=c[(c[F+32>>2]|0)+(d<<2)>>2]|0;j=c[F+52>>2]|0;I=+g[j+(d<<4)>>2];J=+g[j+(d<<4)+4>>2];K=+g[j+(d<<4)+8>>2];L=+g[k+8>>2];M=+g[k+12>>2];N=+g[k+16>>2];M=M+e*(I*+g[F+76>>2]+J*+g[F+80>>2]+K*+g[F+84>>2]+ +g[F+112>>2]-M);N=N+e*(I*l+J*h+K*f+ +g[F+116>>2]-N);g[k+8>>2]=L+e*(I*+g[F+60>>2]+J*+g[F+64>>2]+K*+g[F+68>>2]+ +g[F+108>>2]-L);g[k+12>>2]=M;g[k+16>>2]=N;g[k+20>>2]=0.0;d=d+1|0;if((d|0)>=(c[F+24>>2]|0))break a;l=+g[F+92>>2];h=+g[F+96>>2];f=+g[F+100>>2];e=+g[F+364>>2]}}while(0);if(a[F+377>>0]|0){d=c[F+32>>2]|0;k=c[d>>2]|0;e=+g[k+8>>2];q=+g[k+12>>2];r=+g[k+16>>2];f=+g[k+20>>2];if((E|0)>1){j=1;o=e;p=r;n=f;m=q;l=e;h=f;f=q;e=r;do{k=c[d+(j<<2)>>2]|0;K=+g[k+8>>2];o=K>2];m=L>2];p=M>2];n=N>2]=o;g[H+4>>2]=m;g[H+8>>2]=p;g[H+12>>2]=n;g[H+16>>2]=l;g[H+20>>2]=f;g[H+24>>2]=e;g[H+28>>2]=h;d=c[F+348>>2]|0;if(!d){d=c[b+1052>>2]|0;if(!d){c[6435]=(c[6435]|0)+1;d=yc(63)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}j=d;k=j+44|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(k|0))}else c[b+1052>>2]=0;c[d+32>>2]=0;c[d+36>>2]=F;c[d+40>>2]=0;c[d>>2]=c[H>>2];c[d+4>>2]=c[H+4>>2];c[d+8>>2]=c[H+8>>2];c[d+12>>2]=c[H+12>>2];c[d+16>>2]=c[H+16>>2];c[d+20>>2]=c[H+20>>2];c[d+24>>2]=c[H+24>>2];c[d+28>>2]=c[H+28>>2];lf(b+1048|0,c[b+1048>>2]|0,d);c[b+1060>>2]=(c[b+1060>>2]|0)+1;c[F+348>>2]=d}else{L=+g[b+452>>2];M=L*+g[F+320>>2]*3.0;N=L*+g[F+324>>2]*3.0;g[H+32>>2]=+g[D>>2]*L*3.0;g[H+32+4>>2]=M;g[H+32+8>>2]=N;g[H+32+12>>2]=0.0;jh(b+1048|0,d,H,H+32|0,+g[b+464>>2])|0}}d=c[b+1112>>2]|0}G=G+1|0}while((G|0)<(d|0))}d=c[2357]|0;b=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=b;if(b|0){i=H;return}do if(c[d+4>>2]|0){tb(H+144|0,0)|0;b=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[H+144+4>>2]|0)-(c[b+4>>2]|0)+(((c[H+144>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=H;return}}while(0);c[2357]=c[d+20>>2];i=H;return}function ad(d,e){d=d|0;e=+e;var f=0,h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0;B=i;i=i+464|0;li(12209);f=c[d+84>>2]|0;if(f|0)zb[f&31](d,e);zb[c[(c[d>>2]|0)+140>>2]&31](d,e);g[d+28>>2]=e;c[d+32>>2]=0;c[d+48>>2]=Eb[c[(c[d>>2]|0)+20>>2]&127](d)|0;li(12238);li(12263);f=c[d+316>>2]|0;if((c[d+308>>2]|0)>0){h=0;do{s=c[d+24>>2]|0;Cb[c[(c[s>>2]|0)+16>>2]&127](s,c[f+(h<<2)>>2]|0);h=h+1|0;f=c[d+316>>2]|0}while((h|0)<(c[d+308>>2]|0))}if(f|0){if(a[d+320>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[d+316>>2]=0}a[d+320>>0]=1;c[d+316>>2]=0;c[d+308>>2]=0;c[d+312>>2]=0;f=c[2357]|0;s=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=s;do if(!s){if(c[f+4>>2]|0){tb(B+368|0,0)|0;s=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[B+368+4>>2]|0)-(c[s+4>>2]|0)+(((c[B+368>>2]|0)-(c[s>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(c[f+16>>2]|0)break;f=c[2357]|0}c[2357]=c[f+20>>2]}while(0);a:do if((c[d+232>>2]|0)>0){q=B+304+48|0;r=B+368+44|0;s=0;while(1){k=c[(c[d+240>>2]|0)+(s<<2)>>2]|0;g[k+244>>2]=1.0;b:do switch(c[k+216>>2]|0){case 2:case 5:break;default:if(((c[k+204>>2]&3|0)==0?(Zg(k+4|0,+g[k+312>>2],+g[k+316>>2],+g[k+320>>2],k+328|0,e,B+304|0),t=+g[q>>2],u=t-+g[k+52>>2],v=+g[B+304+52>>2],w=v-+g[k+56>>2],x=+g[B+304+56>>2],y=x-+g[k+60>>2],a[d+44>>0]|0):0)?(o=+g[k+252>>2],o*o!=0.0?o*o>2]|0)+4>>2]|0)<20?(c[5816]=(c[5816]|0)+1,j=c[d+68>>2]|0,j=Eb[c[(c[j>>2]|0)+36>>2]&127](j)|0,p=c[d+24>>2]|0,g[B+368+4>>2]=1.0,b[B+368+8>>1]=1,b[B+368+10>>1]=-1,c[B+368>>2]=2872,c[B+368+12>>2]=c[k+52>>2],c[B+368+12+4>>2]=c[k+52+4>>2],c[B+368+12+8>>2]=c[k+52+8>>2],c[B+368+12+12>>2]=c[k+52+12>>2],c[B+368+28>>2]=c[q>>2],c[B+368+28+4>>2]=c[q+4>>2],c[B+368+28+8>>2]=c[q+8>>2],c[B+368+28+12>>2]=c[q+12>>2],c[B+368+76>>2]=0,c[B+368>>2]=4332,c[B+368+80>>2]=k,c[B+368+88>>2]=j,c[B+368+92>>2]=p,p=c[k+248>>2]|0,c[B+248+8>>2]=0,c[B+248+12>>2]=1065353216,c[B+248+16>>2]=1065353216,c[B+248+20>>2]=1065353216,g[B+248+24>>2]=0.0,c[B+248>>2]=6672,c[B+248+4>>2]=8,c[B+248+28>>2]=p,c[B+248+44>>2]=p,c[B+368+84>>2]=c[d+56>>2],p=c[(c[k+188>>2]|0)+4>>2]|0,b[B+368+8>>1]=p,b[B+368+10>>1]=p>>>16,c[B+184+48>>2]=c[q>>2],c[B+184+48+4>>2]=c[q+4>>2],c[B+184+48+8>>2]=c[q+8>>2],c[B+184+48+12>>2]=c[q+12>>2],c[B+184>>2]=c[k+4>>2],c[B+184+4>>2]=c[k+4+4>>2],c[B+184+8>>2]=c[k+4+8>>2],c[B+184+12>>2]=c[k+4+12>>2],c[B+184+16>>2]=c[k+20>>2],c[B+184+16+4>>2]=c[k+20+4>>2],c[B+184+16+8>>2]=c[k+20+8>>2],c[B+184+16+12>>2]=c[k+20+12>>2],c[B+184+32>>2]=c[k+36>>2],c[B+184+32+4>>2]=c[k+36+4>>2],c[B+184+32+8>>2]=c[k+36+8>>2],c[B+184+32+12>>2]=c[k+36+12>>2],Kd(d,B+248|0,k+4|0,B+184|0,B+368|0,0.0),z=+g[B+368+4>>2],z<1.0):0){l=z*(t-+g[k+52>>2]);m=z*(v-+g[k+56>>2]);n=z*(x-+g[k+60>>2]);o=-(m*+g[B+368+48>>2])-l*+g[r>>2]-n*+g[B+368+52>>2];p=c[d+24>>2]|0;p=Ob[c[(c[p>>2]|0)+12>>2]&63](p,k,c[B+368+76>>2]|0)|0;f=c[d+308>>2]|0;if((f|0)==(c[d+312>>2]|0)?(A=f|0?f<<1:1,(f|0)<(A|0)):0){if(!A)j=0;else{c[6435]=(c[6435]|0)+1;f=yc((A<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=f;f=c[d+308>>2]|0}if((f|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[d+316>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}h=c[d+316>>2]|0;if(h){if(a[d+320>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);f=c[d+308>>2]|0}c[d+316>>2]=0}a[d+320>>0]=1;c[d+316>>2]=j;c[d+312>>2]=A}c[(c[d+316>>2]|0)+(f<<2)>>2]=p;c[d+308>>2]=f+1;l=l+ +g[k+52>>2];m=m+ +g[k+56>>2];n=n+ +g[k+60>>2];j=c[B+368+76>>2]|0;N=+g[j+4>>2];M=+g[j+20>>2];L=+g[j+36>>2];K=+g[j+8>>2];J=+g[j+24>>2];I=+g[j+40>>2];H=+g[j+12>>2];F=+g[j+28>>2];D=+g[j+44>>2];G=-+g[j+52>>2];E=-+g[j+56>>2];C=-+g[j+60>>2];c[B>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0;g[B+16>>2]=l*N+m*M+n*L+(N*G+M*E+L*C);g[B+20>>2]=l*K+m*J+n*I+(K*G+J*E+I*C);g[B+24>>2]=l*H+m*F+n*D+(H*G+F*E+D*C);g[B+28>>2]=0.0;c[B+64>>2]=c[r>>2];c[B+64+4>>2]=c[r+4>>2];c[B+64+8>>2]=c[r+8>>2];c[B+64+12>>2]=c[r+12>>2];g[B+80>>2]=o;g[B+84>>2]=0.0;g[B+88>>2]=0.0;g[B+92>>2]=0.0;c[B+112>>2]=0;a[B+116>>0]=0;c[B+120>>2]=0;c[B+120+4>>2]=0;c[B+120+8>>2]=0;c[B+120+12>>2]=0;c[B+120+16>>2]=0;c[B+120+20>>2]=0;c[B+120+24>>2]=0;c[B+120+28>>2]=0;j=_e(p,B)|0;g[p+4+(j*184|0)+92>>2]=0.0;o=+g[k+224>>2]*+g[(c[B+368+76>>2]|0)+224>>2];o=o<-10.0?-10.0:o;g[p+4+(j*184|0)+84>>2]=o>10.0?10.0:o;c[p+4+(j*184|0)+48>>2]=c[k+52>>2];c[p+4+(j*184|0)+48+4>>2]=c[k+52+4>>2];c[p+4+(j*184|0)+48+8>>2]=c[k+52+8>>2];c[p+4+(j*184|0)+48+12>>2]=c[k+52+12>>2];g[p+4+(j*184|0)+32>>2]=l;g[p+4+(j*184|0)+36>>2]=m;g[p+4+(j*184|0)+40>>2]=n;g[p+4+(j*184|0)+44>>2]=0.0}f=c[2357]|0;p=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=p;if(!p){if(c[f+4>>2]|0){tb(B+368|0,0)|0;p=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[B+368+4>>2]|0)-(c[p+4>>2]|0)+(((c[B+368>>2]|0)-(c[p>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(c[f+16>>2]|0)break b;f=c[2357]|0}c[2357]=c[f+20>>2]}}}while(0);s=s+1|0;if((s|0)>=(c[d+232>>2]|0))break a}}while(0);f=c[2357]|0;A=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=A;do if(!A){if(c[f+4>>2]|0){tb(B+368|0,0)|0;A=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[B+368+4>>2]|0)-(c[A+4>>2]|0)+(((c[B+368>>2]|0)-(c[A>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(c[f+16>>2]|0)break;f=c[2357]|0}c[2357]=c[f+20>>2]}while(0);Ab[c[(c[d>>2]|0)+44>>2]&255](d);Ab[c[(c[d>>2]|0)+148>>2]&255](d);g[d+104>>2]=e;Cb[c[(c[d>>2]|0)+152>>2]&127](d,d+92|0);zb[c[(c[d>>2]|0)+144>>2]&31](d,e);li(12327);if((c[d+280>>2]|0)>0){f=0;do{A=c[(c[d+288>>2]|0)+(f<<2)>>2]|0;kc[c[(c[A>>2]|0)+8>>2]&7](A,d,e);f=f+1|0}while((f|0)<(c[d+280>>2]|0))}f=c[2357]|0;A=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=A;do if(!A){if(c[f+4>>2]|0){tb(B+368|0,0)|0;A=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[B+368+4>>2]|0)-(c[A+4>>2]|0)+(((c[B+368>>2]|0)-(c[A>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(c[f+16>>2]|0)break;f=c[2357]|0}c[2357]=c[f+20>>2]}while(0);zb[c[(c[d>>2]|0)+156>>2]&31](d,e);f=c[d+80>>2]|0;if(f|0)zb[f&31](d,e);f=c[2357]|0;d=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=d;if(d|0){i=B;return}do if(c[f+4>>2]|0){tb(B+368|0,0)|0;d=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[B+368+4>>2]|0)-(c[d+4>>2]|0)+(((c[B+368>>2]|0)-(c[d>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[f+16>>2]|0)){f=c[2357]|0;break}else{i=B;return}}while(0);c[2357]=c[f+20>>2];i=B;return}function bd(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0;x=i;i=i+784|0;c[x+168+8>>2]=0;c[x+168+12>>2]=1065353216;c[x+168+16>>2]=1065353216;c[x+168+20>>2]=1065353216;g[x+168+24>>2]=0.0;c[x+168>>2]=6672;c[x+168+4>>2]=8;g[x+168+28>>2]=0.0;g[x+168+44>>2]=0.0;v=c[e+4>>2]|0;w=c[e+12>>2]|0;h=c[v+4>>2]|0;if((h|0)<20){c[x+600>>2]=3708;c[x+600+168>>2]=0;g[x+600+172>>2]=0.0;c[x+600+164>>2]=c[f+4>>2];g[x+240+308>>2]=9.999999747378752e-05;a[x+240+332>>0]=0;c[x+224>>2]=4960;c[x+224+4>>2]=x+240;c[x+224+8>>2]=x+168;c[x+224+12>>2]=v;c[x+152>>2]=9140;c[x+152+4>>2]=x+240;c[x+152+8>>2]=x+168;c[x+152+12>>2]=v;v=(c[f+16>>2]&4|0)==0?x+152|0:x+224|0;if((Tb[c[(c[v>>2]|0)+8>>2]&3](v,b,d,w,w,x+600|0)|0?(j=x+600+132|0,k=+g[j>>2],l=+g[x+600+136>>2],m=+g[x+600+140>>2],k*k+l*l+m*m>9.999999747378752e-05):0)?(n=+g[x+600+164>>2],n<+g[f+4>>2]):0){u=1.0/+O(+(k*k+l*l+m*m));g[j>>2]=k*u;g[x+600+136>>2]=l*u;g[x+600+140>>2]=m*u;c[x+120>>2]=c[e+8>>2];c[x+120+4>>2]=0;c[x+120+8>>2]=c[j>>2];c[x+120+8+4>>2]=c[j+4>>2];c[x+120+8+8>>2]=c[j+8>>2];c[x+120+8+12>>2]=c[j+12>>2];g[x+120+24>>2]=n;+_b[c[(c[f>>2]|0)+12>>2]&15](f,x+120|0,1)}i=x;return}if((h+-21|0)>>>0>=9){if((h|0)!=31){i=x;return}h=c[v+64>>2]|0;e=c[e+8>>2]|0;c[x+600>>2]=5804;c[x+600+4>>2]=e;c[x+600+8>>2]=v;c[x+600+12>>2]=w;c[x+600+16>>2]=b;c[x+600+20>>2]=d;c[x+600+24>>2]=f;if(!h){h=c[v+16>>2]|0;if((h|0)>0){j=0;do{Vf(x+600|0,j);j=j+1|0}while((j|0)<(h|0))}}else{p=+g[w+48>>2];B=+g[b+48>>2]-p;r=+g[w+52>>2];A=+g[b+52>>2]-r;t=+g[w+56>>2];z=+g[b+56>>2]-t;y=+g[w>>2];k=+g[w+16>>2];l=+g[w+32>>2];m=+g[w+4>>2];n=+g[w+20>>2];o=+g[w+36>>2];q=+g[w+8>>2];s=+g[w+24>>2];u=+g[w+40>>2];g[x+240>>2]=B*y+A*k+z*l;g[x+240+4>>2]=B*m+A*n+z*o;g[x+240+8>>2]=B*q+A*s+z*u;g[x+240+12>>2]=0.0;p=+g[d+48>>2]-p;r=+g[d+52>>2]-r;t=+g[d+56>>2]-t;g[x+224>>2]=p*y+r*k+t*l;g[x+224+4>>2]=p*m+r*n+t*o;g[x+224+8>>2]=p*q+r*s+t*u;g[x+224+12>>2]=0.0;ff(c[h>>2]|0,x+240|0,x+224|0,x+600|0)}i=x;return}E=+g[w>>2];D=+g[w+16>>2];k=+g[w+32>>2];C=+g[w+4>>2];o=+g[w+20>>2];l=+g[w+36>>2];A=+g[w+8>>2];B=+g[w+24>>2];m=+g[w+40>>2];p=-+g[w+48>>2];y=-+g[w+52>>2];z=-+g[w+56>>2];q=+g[b+48>>2];r=+g[b+52>>2];n=+g[b+56>>2];g[x+152>>2]=E*p+D*y+k*z+(E*q+D*r+k*n);g[x+152+4>>2]=C*p+o*y+l*z+(C*q+o*r+l*n);g[x+152+8>>2]=A*p+B*y+m*z+(A*q+B*r+m*n);g[x+152+12>>2]=0.0;t=+g[d+48>>2];u=+g[d+52>>2];s=+g[d+56>>2];k=E*p+D*y+k*z+(E*t+D*u+k*s);l=C*p+o*y+l*z+(C*t+o*u+l*s);m=A*p+B*y+m*z+(A*t+B*u+m*s);g[x+120>>2]=k;g[x+120+4>>2]=l;g[x+120+8>>2]=m;g[x+120+12>>2]=0.0;switch(c[v+4>>2]|0){case 21:{h=c[e+8>>2]|0;e=c[f+16>>2]|0;c[x+4>>2]=c[x+152>>2];c[x+4+4>>2]=c[x+152+4>>2];c[x+4+8>>2]=c[x+152+8>>2];c[x+4+12>>2]=c[x+152+12>>2];c[x+20>>2]=c[x+120>>2];c[x+20+4>>2]=c[x+120+4>>2];c[x+20+8>>2]=c[x+120+8>>2];c[x+20+12>>2]=c[x+120+12>>2];c[x+36>>2]=e;g[x+40>>2]=1.0;c[x>>2]=5756;c[x+44>>2]=f;c[x+48>>2]=h;c[x+52>>2]=v;c[x+56>>2]=c[w>>2];c[x+56+4>>2]=c[w+4>>2];c[x+56+8>>2]=c[w+8>>2];c[x+56+12>>2]=c[w+12>>2];c[x+72>>2]=c[w+16>>2];c[x+72+4>>2]=c[w+16+4>>2];c[x+72+8>>2]=c[w+16+8>>2];c[x+72+12>>2]=c[w+16+12>>2];c[x+88>>2]=c[w+32>>2];c[x+88+4>>2]=c[w+32+4>>2];c[x+88+8>>2]=c[w+32+8>>2];c[x+88+12>>2]=c[w+32+12>>2];c[x+104>>2]=c[w+48>>2];c[x+104+4>>2]=c[w+48+4>>2];c[x+104+8>>2]=c[w+48+8>>2];c[x+104+12>>2]=c[w+48+12>>2];c[x+40>>2]=c[f+4>>2];h=c[v+48>>2]|0;c[x+224>>2]=6884;c[x+224+4>>2]=h;c[x+224+8>>2]=x;h=c[v+52>>2]|0;c[x+600>>2]=0;c[x+600+4>>2]=0;c[x+600+8>>2]=0;c[x+600+12>>2]=0;c[x+240>>2]=0;c[x+240+4>>2]=0;c[x+240+8>>2]=0;c[x+240+12>>2]=0;if(!(a[h+60>>0]|0))Re(h,x+224|0,x+152|0,k,l,m,x+600|0,x+240|0);else ze(h,x+224|0,x+152|0,k,l,m,x+600|0,x+240|0,c[h+56>>2]|0);break}case 25:{e=c[e+8>>2]|0;d=c[f+16>>2]|0;c[x+600+4>>2]=c[x+152>>2];c[x+600+4+4>>2]=c[x+152+4>>2];c[x+600+4+8>>2]=c[x+152+8>>2];c[x+600+4+12>>2]=c[x+152+12>>2];c[x+600+20>>2]=c[x+120>>2];c[x+600+20+4>>2]=c[x+120+4>>2];c[x+600+20+8>>2]=c[x+120+8>>2];c[x+600+20+12>>2]=c[x+120+12>>2];c[x+600+36>>2]=d;g[x+600+40>>2]=1.0;c[x+600>>2]=5756;c[x+600+44>>2]=f;c[x+600+48>>2]=e;c[x+600+52>>2]=v;c[x+600+56>>2]=c[w>>2];c[x+600+56+4>>2]=c[w+4>>2];c[x+600+56+8>>2]=c[w+8>>2];c[x+600+56+12>>2]=c[w+12>>2];c[x+600+72>>2]=c[w+16>>2];c[x+600+72+4>>2]=c[w+16+4>>2];c[x+600+72+8>>2]=c[w+16+8>>2];c[x+600+72+12>>2]=c[w+16+12>>2];c[x+600+88>>2]=c[w+32>>2];c[x+600+88+4>>2]=c[w+32+4>>2];c[x+600+88+8>>2]=c[w+32+8>>2];c[x+600+88+12>>2]=c[w+32+12>>2];c[x+600+104>>2]=c[w+48>>2];c[x+600+104+4>>2]=c[w+48+4>>2];c[x+600+104+8>>2]=c[w+48+8>>2];c[x+600+104+12>>2]=c[w+48+12>>2];c[x+600+40>>2]=c[f+4>>2];mc[c[(c[v>>2]|0)+144>>2]&127](v,x+600|0,x+152|0,x+120|0);break}default:{H=+g[w>>2];G=+g[w+16>>2];m=+g[w+32>>2];F=+g[w+4>>2];y=+g[w+20>>2];z=+g[w+36>>2];D=+g[w+8>>2];E=+g[w+24>>2];k=+g[w+40>>2];A=-+g[w+48>>2];B=-+g[w+52>>2];C=-+g[w+56>>2];o=H*A+G*B+m*C+(H*q+G*r+m*n);p=F*A+y*B+z*C+(F*q+y*r+z*n);l=D*A+E*B+k*C+(D*q+E*r+k*n);m=H*A+G*B+m*C+(H*t+G*u+m*s);n=F*A+y*B+z*C+(F*t+y*u+z*s);k=D*A+E*B+k*C+(D*t+E*u+k*s);e=c[e+8>>2]|0;d=c[f+16>>2]|0;g[x+600+4>>2]=o;g[x+600+8>>2]=p;g[x+600+12>>2]=l;g[x+600+16>>2]=0.0;g[x+600+20>>2]=m;g[x+600+24>>2]=n;g[x+600+28>>2]=k;g[x+600+32>>2]=0.0;c[x+600+36>>2]=d;g[x+600+40>>2]=1.0;c[x+600>>2]=5780;c[x+600+44>>2]=f;c[x+600+48>>2]=e;c[x+600+52>>2]=v;c[x+600+56>>2]=c[w>>2];c[x+600+56+4>>2]=c[w+4>>2];c[x+600+56+8>>2]=c[w+8>>2];c[x+600+56+12>>2]=c[w+12>>2];c[x+600+72>>2]=c[w+16>>2];c[x+600+72+4>>2]=c[w+16+4>>2];c[x+600+72+8>>2]=c[w+16+8>>2];c[x+600+72+12>>2]=c[w+16+12>>2];c[x+600+88>>2]=c[w+32>>2];c[x+600+88+4>>2]=c[w+32+4>>2];c[x+600+88+8>>2]=c[w+32+8>>2];c[x+600+88+12>>2]=c[w+32+12>>2];c[x+600+104>>2]=c[w+48>>2];c[x+600+104+4>>2]=c[w+48+4>>2];c[x+600+104+8>>2]=c[w+48+8>>2];c[x+600+104+12>>2]=c[w+48+12>>2];c[x+600+40>>2]=c[f+4>>2];g[x+240>>2]=o;g[x+240+4>>2]=p;g[x+240+8>>2]=l;g[x+240+12>>2]=0.0;if(m>2]=m;if(n>2]=n;if(k>2]=k;g[x+224>>2]=o;g[x+224+4>>2]=p;g[x+224+8>>2]=l;g[x+224+12>>2]=0.0;if(o>2]=m;if(p>2]=n;if(l>2]=k;mc[c[(c[v>>2]|0)+64>>2]&127](v,x+600|0,x+240|0,x+224|0)}}i=x;return}function cd(b,d,e,f,h,i,j,k,l,m){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0;o=c[b+48>>2]|0;q=c[b+28>>2]|0;r=c[b+68>>2]|0;if(c[l+64>>2]&1|0){if((o|0)>0){f=c[b+136>>2]|0;m=c[b+192>>2]|0;p=0;do{h=f+(p<<2)|0;i=c[h>>2]|0;p=p+1|0;m=(_(m,1664525)|0)+1013904223|0;if(p>>>0<65537){e=m>>>16^m;if(p>>>0<257)if(p>>>0<17){e=(e>>>8^e)>>>4^(e>>>8^e);if(p>>>0<5)if(p>>>0<3)e=(e>>>2^e)>>>1^(e>>>2^e);else e=e>>>2^e}else e=e>>>8^e}else e=m;e=f+(((e>>>0)%(p>>>0)|0)<<2)|0;c[h>>2]=c[e>>2];c[e>>2]=i}while((p|0)!=(o|0));c[b+192>>2]=m}if((c[l+20>>2]|0)>(d|0)){if((q|0)>0){f=c[b+116>>2]|0;m=c[b+192>>2]|0;o=0;do{h=f+(o<<2)|0;i=c[h>>2]|0;o=o+1|0;m=(_(m,1664525)|0)+1013904223|0;if(o>>>0<65537){e=m>>>16^m;if(o>>>0<257)if(o>>>0<17){e=(e>>>8^e)>>>4^(e>>>8^e);if(o>>>0<5)if(o>>>0<3)e=(e>>>2^e)>>>1^(e>>>2^e);else e=e>>>2^e}else e=e>>>8^e}else e=m;p=f+(((e>>>0)%(o>>>0)|0)<<2)|0;c[h>>2]=c[p>>2];c[p>>2]=i}while((o|0)!=(q|0));c[b+192>>2]=m}if((r|0)>0){f=c[b+156>>2]|0;m=c[b+192>>2]|0;o=0;do{h=f+(o<<2)|0;i=c[h>>2]|0;o=o+1|0;m=(_(m,1664525)|0)+1013904223|0;if(o>>>0<65537){e=m>>>16^m;if(o>>>0<257)if(o>>>0<17){e=(e>>>8^e)>>>4^(e>>>8^e);if(o>>>0<5)if(o>>>0<3)e=(e>>>2^e)>>>1^(e>>>2^e);else e=e>>>2^e}else e=e>>>8^e}else e=m;q=f+(((e>>>0)%(o>>>0)|0)<<2)|0;c[h>>2]=c[q>>2];c[q>>2]=i}while((o|0)!=(r|0));c[b+192>>2]=m}}}e=c[b+48>>2]|0;if(!(c[l+64>>2]&256)){if((e|0)>0){i=0;do{f=c[(c[b+136>>2]|0)+(i<<2)>>2]|0;h=c[b+56>>2]|0;if((c[h+(f*152|0)+136>>2]|0)>(d|0)){e=c[b+16>>2]|0;zg(e+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,e+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0);e=c[b+48>>2]|0}i=i+1|0}while((i|0)<(e|0))}if((c[l+20>>2]|0)<=(d|0))return 0.0;if((k|0)>0){h=0;do{e=j+(h<<2)|0;f=c[e>>2]|0;if(a[f+20>>0]|0){d=bk(b,c[f+28>>2]|0,+g[l+12>>2])|0;t=bk(b,c[(c[e>>2]|0)+32>>2]|0,+g[l+12>>2])|0;s=c[b+16>>2]|0;r=c[e>>2]|0;hc[c[(c[r>>2]|0)+24>>2]&15](r,s+(d*244|0)|0,s+(t*244|0)|0,+g[l+12>>2])}h=h+1|0}while((h|0)!=(k|0))}e=c[b+28>>2]|0;if((e|0)>0){f=0;do{l=c[(c[b+116>>2]|0)+(f<<2)>>2]|0;k=c[b+36>>2]|0;j=c[b+16>>2]|0;Mg(j+((c[k+(l*152|0)+144>>2]|0)*244|0)|0,j+((c[k+(l*152|0)+148>>2]|0)*244|0)|0,k+(l*152|0)|0);f=f+1|0}while((f|0)!=(e|0))}e=c[b+68>>2]|0;if((e|0)>0){i=0;do{f=c[(c[b+156>>2]|0)+(i<<2)>>2]|0;h=c[b+76>>2]|0;n=+g[(c[b+36>>2]|0)+((c[h+(f*152|0)+140>>2]|0)*152|0)+100>>2];if(n>0.0){n=n*+g[h+(f*152|0)+104>>2];g[h+(f*152|0)+120>>2]=-n;g[h+(f*152|0)+124>>2]=n;l=c[b+16>>2]|0;zg(l+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,l+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0)}i=i+1|0}while((i|0)!=(e|0))}e=c[b+88>>2]|0;if((e|0)<=0)return 0.0;h=0;do{f=c[b+96>>2]|0;n=+g[(c[b+36>>2]|0)+((c[f+(h*152|0)+140>>2]|0)*152|0)+100>>2];if(n>0.0){u=+g[f+(h*152|0)+104>>2];n=n*u>u?u:n*u;g[f+(h*152|0)+120>>2]=-n;g[f+(h*152|0)+124>>2]=n;l=c[b+16>>2]|0;zg(l+((c[f+(h*152|0)+144>>2]|0)*244|0)|0,l+((c[f+(h*152|0)+148>>2]|0)*244|0)|0,f+(h*152|0)|0)}h=h+1|0}while((h|0)!=(e|0));return 0.0}if((e|0)>0){i=0;do{f=c[(c[b+136>>2]|0)+(i<<2)>>2]|0;h=c[b+56>>2]|0;if((c[h+(f*152|0)+136>>2]|0)>(d|0)){e=c[b+16>>2]|0;zg(e+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,e+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0);e=c[b+48>>2]|0}i=i+1|0}while((i|0)<(e|0))}if((c[l+20>>2]|0)<=(d|0))return 0.0;if((k|0)>0){h=0;do{e=j+(h<<2)|0;f=c[e>>2]|0;if(a[f+20>>0]|0){q=bk(b,c[f+28>>2]|0,+g[l+12>>2])|0;d=bk(b,c[(c[e>>2]|0)+32>>2]|0,+g[l+12>>2])|0;r=c[b+16>>2]|0;p=c[e>>2]|0;hc[c[(c[p>>2]|0)+24>>2]&15](p,r+(q*244|0)|0,r+(d*244|0)|0,+g[l+12>>2])}h=h+1|0}while((h|0)!=(k|0))}e=c[l+64>>2]|0;o=c[b+28>>2]|0;if(e&512|0){if((o|0)<=0)return 0.0;m=0;do{f=c[(c[b+116>>2]|0)+(m<<2)>>2]|0;h=c[b+36>>2]|0;i=c[b+16>>2]|0;Mg(i+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,i+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0);n=+g[h+(f*152|0)+100>>2];f=_(m,(e>>>4&1)+1|0)|0;h=c[(c[b+156>>2]|0)+(f<<2)>>2]|0;i=c[b+76>>2]|0;if(n>0.0){u=n*+g[i+(h*152|0)+104>>2];g[i+(h*152|0)+120>>2]=-u;g[i+(h*152|0)+124>>2]=u;k=c[b+16>>2]|0;zg(k+((c[i+(h*152|0)+144>>2]|0)*244|0)|0,k+((c[i+(h*152|0)+148>>2]|0)*244|0)|0,i+(h*152|0)|0)}if(c[l+64>>2]&16|0?(s=c[(c[b+156>>2]|0)+(f+1<<2)>>2]|0,t=c[b+76>>2]|0,n>0.0):0){u=n*+g[t+(s*152|0)+104>>2];g[t+(s*152|0)+120>>2]=-u;g[t+(s*152|0)+124>>2]=u;k=c[b+16>>2]|0;zg(k+((c[t+(s*152|0)+144>>2]|0)*244|0)|0,k+((c[t+(s*152|0)+148>>2]|0)*244|0)|0,t+(s*152|0)|0)}m=m+1|0}while((m|0)!=(o|0));return 0.0}if((o|0)>0){e=0;do{l=c[(c[b+116>>2]|0)+(e<<2)>>2]|0;k=c[b+36>>2]|0;j=c[b+16>>2]|0;Mg(j+((c[k+(l*152|0)+144>>2]|0)*244|0)|0,j+((c[k+(l*152|0)+148>>2]|0)*244|0)|0,k+(l*152|0)|0);e=e+1|0}while((e|0)!=(o|0))}e=c[b+68>>2]|0;if((e|0)>0){i=0;do{f=c[(c[b+156>>2]|0)+(i<<2)>>2]|0;h=c[b+76>>2]|0;n=+g[(c[b+36>>2]|0)+((c[h+(f*152|0)+140>>2]|0)*152|0)+100>>2];if(n>0.0){u=n*+g[h+(f*152|0)+104>>2];g[h+(f*152|0)+120>>2]=-u;g[h+(f*152|0)+124>>2]=u;l=c[b+16>>2]|0;zg(l+((c[h+(f*152|0)+144>>2]|0)*244|0)|0,l+((c[h+(f*152|0)+148>>2]|0)*244|0)|0,h+(f*152|0)|0)}i=i+1|0}while((i|0)!=(e|0))}e=c[b+88>>2]|0;if((e|0)<=0)return 0.0;h=0;do{f=c[b+96>>2]|0;n=+g[(c[b+36>>2]|0)+((c[f+(h*152|0)+140>>2]|0)*152|0)+100>>2];if(n>0.0){u=+g[f+(h*152|0)+104>>2];u=n*u>u?u:n*u;g[f+(h*152|0)+120>>2]=-u;g[f+(h*152|0)+124>>2]=u;l=c[b+16>>2]|0;zg(l+((c[f+(h*152|0)+144>>2]|0)*244|0)|0,l+((c[f+(h*152|0)+148>>2]|0)*244|0)|0,f+(h*152|0)|0)}h=h+1|0}while((h|0)!=(e|0));return 0.0}function dd(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0;r=i;i=i+80|0;j=c[b+28>>2]|0;d=c[f+64>>2]|0;a:do if((d&4|0)!=0&(j|0)>0){l=c[b+36>>2]|0;h=c[b+76>>2]|0;if(!(d&16)){d=0;while(1){m=c[l+(d*152|0)+132>>2]|0;c[m+120>>2]=c[l+(d*152|0)+100>>2];c[m+124>>2]=c[h+((c[l+(d*152|0)+140>>2]|0)*152|0)+100>>2];d=d+1|0;if((d|0)==(j|0))break a}}else{e=h;d=0}while(1){m=c[l+(d*152|0)+132>>2]|0;c[m+120>>2]=c[l+(d*152|0)+100>>2];s=c[l+(d*152|0)+140>>2]|0;c[m+124>>2]=c[h+(s*152|0)+100>>2];c[m+128>>2]=c[e+((s+1|0)*152|0)+100>>2];d=d+1|0;if((d|0)==(j|0))break a;e=c[b+76>>2]|0}}while(0);e=c[b+48>>2]|0;if((e|0)>0){m=0;do{h=c[b+56>>2]|0;j=c[h+(m*152|0)+132>>2]|0;l=c[j+44>>2]|0;d=h+(m*152|0)+100|0;if(l|0){q=+g[d>>2];s=c[j+28>>2]|0;p=1.0/+g[f+12>>2];o=q*+g[h+(m*152|0)+20>>2]*+g[s+352>>2]*p;n=q*+g[h+(m*152|0)+24>>2]*+g[s+356>>2]*p;g[l>>2]=+g[l>>2]+ +g[h+(m*152|0)+16>>2]*q*+g[s+348>>2]*p;g[l+4>>2]=o+ +g[l+4>>2];g[l+8>>2]=n+ +g[l+8>>2];n=+g[d>>2];s=c[j+32>>2]|0;o=1.0/+g[f+12>>2];p=n*+g[h+(m*152|0)+52>>2]*+g[s+352>>2]*o;q=n*+g[h+(m*152|0)+56>>2]*+g[s+356>>2]*o;g[l+32>>2]=+g[l+32>>2]+ +g[h+(m*152|0)+48>>2]*n*+g[s+348>>2]*o;g[l+36>>2]=p+ +g[l+36>>2];g[l+40>>2]=q+ +g[l+40>>2];s=c[j+28>>2]|0;q=+g[d>>2];p=1.0/+g[f+12>>2];o=+g[h+(m*152|0)+4>>2]*+g[s+548>>2]*q*p;n=q*+g[h+(m*152|0)+8>>2]*+g[s+552>>2]*p;g[l+16>>2]=+g[l+16>>2]+ +g[h+(m*152|0)>>2]*+g[s+544>>2]*q*p;g[l+20>>2]=o+ +g[l+20>>2];g[l+24>>2]=n+ +g[l+24>>2];s=c[j+32>>2]|0;n=+g[d>>2];o=1.0/+g[f+12>>2];p=+g[h+(m*152|0)+36>>2]*+g[s+548>>2]*n*o;q=n*+g[h+(m*152|0)+40>>2]*+g[s+552>>2]*o;g[l+48>>2]=+g[l+48>>2]+ +g[h+(m*152|0)+32>>2]*+g[s+544>>2]*n*o;g[l+52>>2]=p+ +g[l+52>>2];g[l+56>>2]=q+ +g[l+56>>2]}s=c[d>>2]|0;c[j+36>>2]=s;q=+N(+(c[k>>2]=s,+g[k>>2]));if(q>=+g[j+16>>2])a[j+20>>0]=0;m=m+1|0}while((m|0)!=(e|0))}d=c[b+8>>2]|0;if((d|0)>0){l=0;do{e=c[b+16>>2]|0;h=e+(l*244|0)|0;j=c[e+(l*244|0)+240>>2]|0;if(j){if(!(c[f+44>>2]|0)){h=e+(l*244|0)+176|0;o=+g[e+(l*244|0)+64>>2]+ +g[h>>2];g[h>>2]=o;h=e+(l*244|0)+180|0;p=+g[e+(l*244|0)+68>>2]+ +g[h>>2];g[h>>2]=p;h=e+(l*244|0)+184|0;n=+g[e+(l*244|0)+72>>2]+ +g[h>>2];g[h>>2]=n;h=e+(l*244|0)+192|0;g[h>>2]=+g[e+(l*244|0)+80>>2]+ +g[h>>2];h=e+(l*244|0)+196|0;g[h>>2]=+g[e+(l*244|0)+84>>2]+ +g[h>>2];h=e+(l*244|0)+200|0;g[h>>2]=+g[e+(l*244|0)+88>>2]+ +g[h>>2];h=e;d=j}else{o=+g[f+12>>2];p=+g[f+52>>2];s=e+(l*244|0)+176|0;g[s>>2]=+g[e+(l*244|0)+64>>2]+ +g[s>>2];s=e+(l*244|0)+180|0;g[s>>2]=+g[e+(l*244|0)+68>>2]+ +g[s>>2];s=e+(l*244|0)+184|0;g[s>>2]=+g[e+(l*244|0)+72>>2]+ +g[s>>2];s=e+(l*244|0)+192|0;g[s>>2]=+g[e+(l*244|0)+80>>2]+ +g[s>>2];s=e+(l*244|0)+196|0;g[s>>2]=+g[e+(l*244|0)+84>>2]+ +g[s>>2];s=e+(l*244|0)+200|0;g[s>>2]=+g[e+(l*244|0)+88>>2]+ +g[s>>2];q=+g[e+(l*244|0)+144>>2];n=+g[e+(l*244|0)+148>>2];if((((!(q!=0.0|n!=0.0)?!(+g[e+(l*244|0)+152>>2]!=0.0):0)?!(+g[e+(l*244|0)+160>>2]!=0.0):0)?!(+g[e+(l*244|0)+164>>2]!=0.0):0)?!(+g[e+(l*244|0)+168>>2]!=0.0):0)d=j;else{u=+g[e+(l*244|0)+164>>2]*p;t=+g[e+(l*244|0)+168>>2]*p;g[r>>2]=+g[e+(l*244|0)+160>>2]*p;g[r+4>>2]=u;g[r+8>>2]=t;g[r+12>>2]=0.0;Zg(h,q,n,+g[e+(l*244|0)+152>>2],r,o,r+16|0);c[h>>2]=c[r+16>>2];c[h+4>>2]=c[r+16+4>>2];c[h+8>>2]=c[r+16+8>>2];c[h+12>>2]=c[r+16+12>>2];d=e+(l*244|0)+16|0;c[d>>2]=c[r+16+16>>2];c[d+4>>2]=c[r+16+16+4>>2];c[d+8>>2]=c[r+16+16+8>>2];c[d+12>>2]=c[r+16+16+12>>2];d=e+(l*244|0)+32|0;c[d>>2]=c[r+16+32>>2];c[d+4>>2]=c[r+16+32+4>>2];c[d+8>>2]=c[r+16+32+8>>2];c[d+12>>2]=c[r+16+32+12>>2];d=e+(l*244|0)+48|0;c[d>>2]=c[r+16+48>>2];c[d+4>>2]=c[r+16+48+4>>2];c[d+8>>2]=c[r+16+48+8>>2];c[d+12>>2]=c[r+16+48+12>>2];d=c[b+16>>2]|0;e=d;d=c[d+(l*244|0)+240>>2]|0}h=e;o=+g[e+(l*244|0)+176>>2];p=+g[e+(l*244|0)+180>>2];n=+g[e+(l*244|0)+184>>2]}u=o+ +g[h+(l*244|0)+208>>2];t=p+ +g[h+(l*244|0)+212>>2];q=n+ +g[h+(l*244|0)+216>>2];m=d+260|0;c[m>>2]=(c[m>>2]|0)+1;g[d+312>>2]=u;g[d+316>>2]=t;g[d+320>>2]=q;g[d+324>>2]=0.0;m=c[b+16>>2]|0;s=c[m+(l*244|0)+240>>2]|0;q=+g[m+(l*244|0)+192>>2]+ +g[m+(l*244|0)+224>>2];t=+g[m+(l*244|0)+196>>2]+ +g[m+(l*244|0)+228>>2];u=+g[m+(l*244|0)+200>>2]+ +g[m+(l*244|0)+232>>2];c[s+260>>2]=(c[s+260>>2]|0)+1;g[s+328>>2]=q;g[s+332>>2]=t;g[s+336>>2]=u;g[s+340>>2]=0.0;if(c[f+44>>2]|0){m=c[b+16>>2]|0;s=c[m+(l*244|0)+240>>2]|0;j=m+(l*244|0)|0;c[s+260>>2]=(c[s+260>>2]|0)+1;c[s+4>>2]=c[j>>2];c[s+4+4>>2]=c[j+4>>2];c[s+4+8>>2]=c[j+8>>2];c[s+4+12>>2]=c[j+12>>2];j=m+(l*244|0)+16|0;c[s+20>>2]=c[j>>2];c[s+20+4>>2]=c[j+4>>2];c[s+20+8>>2]=c[j+8>>2];c[s+20+12>>2]=c[j+12>>2];j=m+(l*244|0)+32|0;c[s+36>>2]=c[j>>2];c[s+36+4>>2]=c[j+4>>2];c[s+36+8>>2]=c[j+8>>2];c[s+36+12>>2]=c[j+12>>2];m=m+(l*244|0)+48|0;c[s+52>>2]=c[m>>2];c[s+52+4>>2]=c[m+4>>2];c[s+52+8>>2]=c[m+8>>2];c[s+52+12>>2]=c[m+12>>2]}c[(c[(c[b+16>>2]|0)+(l*244|0)+240>>2]|0)+212>>2]=-1;d=c[b+8>>2]|0}l=l+1|0}while((l|0)<(d|0))}if((c[b+28>>2]|0)<0?(c[b+32>>2]|0)<0:0){d=c[b+36>>2]|0;if(d|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=0;c[b+32>>2]=0}c[b+28>>2]=0;if((c[b+48>>2]|0)<0?(c[b+52>>2]|0)<0:0){d=c[b+56>>2]|0;if(d|0){if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+56>>2]=0}a[b+60>>0]=1;c[b+56>>2]=0;c[b+52>>2]=0}c[b+48>>2]=0;if((c[b+68>>2]|0)<0?(c[b+72>>2]|0)<0:0){d=c[b+76>>2]|0;if(d|0){if(a[b+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+76>>2]=0}a[b+80>>0]=1;c[b+76>>2]=0;c[b+72>>2]=0}c[b+68>>2]=0;if((c[b+88>>2]|0)<0?(c[b+92>>2]|0)<0:0){d=c[b+96>>2]|0;if(d|0){if(a[b+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+96>>2]=0}a[b+100>>0]=1;c[b+96>>2]=0;c[b+92>>2]=0}c[b+88>>2]=0;if((c[b+8>>2]|0)>=0){c[b+8>>2]=0;i=r;return 0.0}if((c[b+12>>2]|0)>=0){c[b+8>>2]=0;i=r;return 0.0}d=c[b+16>>2]|0;if(d|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=0;c[b+12>>2]=0;c[b+8>>2]=0;i=r;return 0.0}function ed(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0;u=i;i=i+704|0;c[u+480+8>>2]=0;c[u+480+12>>2]=1065353216;c[u+480+16>>2]=1065353216;c[u+480+20>>2]=1065353216;g[u+480+24>>2]=0.0;c[u+480>>2]=6672;c[u+480+4>>2]=8;g[u+480+28>>2]=0.0;g[u+480+44>>2]=0.0;g[u+416>>2]=1.0;m=u+416+4|0;c[m>>2]=0;c[m+4>>2]=0;c[m+8>>2]=0;c[m+12>>2]=0;g[u+416+20>>2]=1.0;n=u+416+24|0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;g[u+416+40>>2]=1.0;g[u+416+44>>2]=0.0;c[u+416+48>>2]=c[a>>2];c[u+416+48+4>>2]=c[a+4>>2];c[u+416+48+8>>2]=c[a+8>>2];c[u+416+48+12>>2]=c[a+12>>2];a=e;l=a+36|0;do{c[a>>2]=0;a=a+4|0}while((a|0)<(l|0));c[u+536>>2]=b;c[u+536+4>>2]=u+480;H=+g[d>>2];G=+g[d+16>>2];F=+g[d+32>>2];E=+g[d+4>>2];D=+g[d+20>>2];C=+g[d+36>>2];s=+g[d+8>>2];q=+g[d+24>>2];o=+g[d+40>>2];g[u+536+8>>2]=H+G*0.0+F*0.0;g[u+536+12>>2]=E+D*0.0+C*0.0;g[u+536+16>>2]=s+q*0.0+o*0.0;g[u+536+20>>2]=0.0;g[u+536+24>>2]=H*0.0+G+F*0.0;g[u+536+28>>2]=E*0.0+D+C*0.0;g[u+536+32>>2]=s*0.0+q+o*0.0;g[u+536+36>>2]=0.0;g[u+536+40>>2]=H*0.0+G*0.0+F;g[u+536+44>>2]=E*0.0+D*0.0+C;g[u+536+48>>2]=s*0.0+q*0.0+o;g[u+536+52>>2]=0.0;o=+g[u+416+48>>2]-+g[d+48>>2];q=+g[u+416+52>>2]-+g[d+52>>2];s=+g[u+416+56>>2]-+g[d+56>>2];B=+g[u+416>>2];A=+g[u+416+16>>2];z=+g[u+416+32>>2];y=+g[m>>2];x=+g[u+416+20>>2];w=+g[u+416+36>>2];v=+g[u+416+8>>2];f=+g[n>>2];h=+g[u+416+40>>2];p=+g[d+8>>2];r=+g[d+24>>2];t=+g[d+40>>2];j=o*+g[d>>2]+q*+g[d+16>>2]+s*+g[d+32>>2];k=o*+g[d+4>>2]+q*+g[d+20>>2]+s*+g[d+36>>2];g[u+536+56>>2]=H*B+G*A+F*z;g[u+536+60>>2]=H*y+G*x+F*w;g[u+536+64>>2]=H*v+G*f+F*h;g[u+536+68>>2]=0.0;g[u+536+72>>2]=B*E+A*D+z*C;g[u+536+76>>2]=y*E+x*D+w*C;g[u+536+80>>2]=v*E+f*D+h*C;g[u+536+84>>2]=0.0;g[u+536+88>>2]=B*p+A*r+z*t;g[u+536+92>>2]=y*p+x*r+w*t;g[u+536+96>>2]=v*p+f*r+h*t;g[u+536+100>>2]=0.0;g[u+536+104>>2]=j;g[u+536+108>>2]=k;g[u+536+112>>2]=o*p+q*r+s*t;g[u+536+116>>2]=0.0;c[u+536+120>>2]=80;c[u+536+124>>2]=0;a=u+32+128|0;c[u+32+364>>2]=0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;c[u+32+376>>2]=2;c[u+32+368>>2]=0;g[u+32+144>>2]=0.0;c[u+16>>2]=1065353216;c[u+16+4>>2]=1065353216;c[u+16+8>>2]=1065353216;g[u+16+12>>2]=0.0;switch(Uc(u+32|0,u+536|0,u+16|0)|0){case 0:{a=c[u+32+372>>2]|0;if(!(c[a+32>>2]|0)){k=0.0;j=0.0;f=0.0;r=0.0;q=0.0;h=0.0}else{n=0;k=0.0;j=0.0;f=0.0;r=0.0;q=0.0;h=0.0;do{t=+g[a+16+(n<<2)>>2];l=c[u+536+120>>2]|0;I=c[u+536+124>>2]|0;m=(c[u+536>>2]|0)+(I>>1)|0;if(I&1)l=c[(c[m>>2]|0)+l>>2]|0;ic[l&127](u,m,c[a+(n<<2)>>2]|0);k=k+t*+g[u>>2];f=f+t*+g[u+4>>2];j=j+t*+g[u+8>>2];a=c[(c[u+32+372>>2]|0)+(n<<2)>>2]|0;o=-+g[a>>2];p=-+g[a+4>>2];s=-+g[a+8>>2];a=c[u+536+120>>2]|0;I=c[u+536+124>>2]|0;l=(c[u+536+4>>2]|0)+(I>>1)|0;if(I&1)a=c[(c[l>>2]|0)+a>>2]|0;G=+g[u+536+24>>2]*o+ +g[u+536+28>>2]*p+ +g[u+536+32>>2]*s;F=+g[u+536+40>>2]*o+ +g[u+536+44>>2]*p+ +g[u+536+48>>2]*s;g[u+664>>2]=+g[u+536+8>>2]*o+ +g[u+536+12>>2]*p+ +g[u+536+16>>2]*s;g[u+664+4>>2]=G;g[u+664+8>>2]=F;g[u+664+12>>2]=0.0;ic[a&127](u+680|0,l,u+664|0);F=+g[u+680>>2];G=+g[u+680+4>>2];H=+g[u+680+8>>2];r=r+t*(F*+g[u+536+56>>2]+G*+g[u+536+60>>2]+H*+g[u+536+64>>2]+ +g[u+536+104>>2]);h=h+t*(F*+g[u+536+72>>2]+G*+g[u+536+76>>2]+H*+g[u+536+80>>2]+ +g[u+536+108>>2]);q=q+t*(F*+g[u+536+88>>2]+G*+g[u+536+92>>2]+H*+g[u+536+96>>2]+ +g[u+536+112>>2]);n=n+1|0;a=c[u+32+372>>2]|0}while(n>>>0<(c[a+32>>2]|0)>>>0)}s=k*+g[d>>2]+f*+g[d+4>>2]+j*+g[d+8>>2]+ +g[d+48>>2];t=k*+g[d+16>>2]+f*+g[d+20>>2]+j*+g[d+24>>2]+ +g[d+52>>2];k=k*+g[d+32>>2]+f*+g[d+36>>2]+j*+g[d+40>>2]+ +g[d+56>>2];g[e+4>>2]=s;g[e+8>>2]=t;g[e+12>>2]=k;g[e+16>>2]=0.0;o=r*+g[d>>2]+h*+g[d+4>>2]+q*+g[d+8>>2]+ +g[d+48>>2];p=r*+g[d+16>>2]+h*+g[d+20>>2]+q*+g[d+24>>2]+ +g[d+52>>2];j=r*+g[d+32>>2]+h*+g[d+36>>2]+q*+g[d+40>>2]+ +g[d+56>>2];g[e+20>>2]=o;g[e+24>>2]=p;g[e+28>>2]=j;g[e+32>>2]=0.0;switch(c[b+4>>2]|0){case 8:{f=+g[b+28>>2]*+g[b+12>>2];break}case 0:{f=+g[b+44>>2];break}case 1:{f=+g[b+44>>2];break}case 13:{f=+g[b+44>>2];break}case 11:{f=+g[b+44>>2];break}case 10:{f=+g[b+44>>2];break}case 4:case 5:{f=+g[b+44>>2];break}default:f=+Sb[c[(c[b>>2]|0)+48>>2]&15](b)}switch(c[u+480+4>>2]|0){case 8:{h=+g[u+480+28>>2]*+g[u+480+12>>2];break}case 0:{h=+g[u+480+44>>2];break}case 1:{h=+g[u+480+44>>2];break}case 13:{h=+g[u+480+44>>2];break}case 11:{h=+g[u+480+44>>2];break}case 10:{h=+g[u+480+44>>2];break}case 4:case 5:{h=+g[u+480+44>>2];break}default:h=+Sb[c[(c[u+480>>2]|0)+48>>2]&15](u+480|0)}H=f+h;G=+O(+((o-s)*(o-s)+(p-t)*(p-t)+(j-k)*(j-k)));g[e+36>>2]=(o-s)*(1.0/G);g[e+40>>2]=(p-t)*(1.0/G);g[e+44>>2]=(j-k)*(1.0/G);g[e+48>>2]=0.0;g[e+4>>2]=H*(o-s)*(1.0/G)+ +g[e+4>>2];g[e+8>>2]=H*(p-t)*(1.0/G)+ +g[e+8>>2];g[e+12>>2]=H*(j-k)*(1.0/G)+ +g[e+12>>2];H=G-H;i=u;return +H}case 1:{if(!(Pc(b,d,u+480|0,u+416|0,a,e,1)|0)){H=3402823466385288598117041.0e14;i=u;return +H}f=+g[e+4>>2]-+g[e+20>>2];h=+g[e+8>>2]-+g[e+24>>2];j=+g[e+12>>2]-+g[e+28>>2];k=+O(+(f*f+h*h+j*j));if(k>=1.1920928955078125e-07){g[e+36>>2]=f*(1.0/k);g[e+40>>2]=h*(1.0/k);g[e+44>>2]=j*(1.0/k);g[e+48>>2]=0.0}H=-k;i=u;return +H}default:{H=3402823466385288598117041.0e14;i=u;return +H}}return 0.0}function fd(a,b){a=a|0;b=+b;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0;o=i;i=i+48|0;d=c[a+24>>2]|0;if((d|0)<=0){i=o;return}n=0;do{m=c[(c[a+32>>2]|0)+(n<<2)>>2]|0;switch(c[m+216>>2]|0){case 2:case 5:break;default:{Wd(m,0);d=c[m+732>>2]|0;if((d|0)>0){e=0;do{l=c[m+740>>2]|0;j=c[l+(e*52|0)+12>>2]|0;k=c[l+(e*52|0)+8>>2]|0;y=+g[j+24>>2]-+g[k+24>>2];x=+g[j+28>>2]-+g[k+28>>2];b=+g[j+32>>2]-+g[k+32>>2];g[l+(e*52|0)+36>>2]=y;g[l+(e*52|0)+40>>2]=x;g[l+(e*52|0)+44>>2]=b;g[l+(e*52|0)+48>>2]=0.0;g[l+(e*52|0)+32>>2]=1.0/(+g[l+(e*52|0)+24>>2]*(y*y+x*x+b*b));e=e+1|0}while((e|0)!=(d|0))}e=c[m+792>>2]|0;if((e|0)>0){b=+g[m+452>>2];f=0;do{l=c[m+800>>2]|0;d=l+(f*96|0)+20|0;h=c[d>>2]|0;B=+g[l+(f*96|0)+4>>2];A=+g[l+(f*96|0)+8>>2];y=+g[l+(f*96|0)+12>>2];z=+g[h+4>>2]*B+ +g[h+8>>2]*A+ +g[h+12>>2]*y;x=B*+g[h+20>>2]+A*+g[h+24>>2]+y*+g[h+28>>2];y=B*+g[h+36>>2]+A*+g[h+40>>2]+y*+g[h+44>>2];j=l+(f*96|0)+28|0;k=l+(f*96|0)|0;Pf(o,b,+g[(c[k>>2]|0)+88>>2],+g[h+344>>2],h+264|0,z,x,y);c[j>>2]=c[o>>2];c[j+4>>2]=c[o+4>>2];c[j+8>>2]=c[o+8>>2];c[j+12>>2]=c[o+12>>2];j=l+(f*96|0)+44|0;c[j>>2]=c[o+16>>2];c[j+4>>2]=c[o+16+4>>2];c[j+8>>2]=c[o+16+8>>2];c[j+12>>2]=c[o+16+12>>2];j=l+(f*96|0)+60|0;c[j>>2]=c[o+32>>2];c[j+4>>2]=c[o+32+4>>2];c[j+8>>2]=c[o+32+8>>2];c[j+12>>2]=c[o+32+12>>2];g[l+(f*96|0)+76>>2]=z;g[l+(f*96|0)+80>>2]=x;g[l+(f*96|0)+84>>2]=y;g[l+(f*96|0)+88>>2]=0.0;b=+g[m+452>>2];g[l+(f*96|0)+92>>2]=b*+g[(c[k>>2]|0)+88>>2];d=c[d>>2]|0;if(!(c[d+204>>2]&3)){if((c[d+216>>2]&-2|0)!=4)c[d+216>>2]=1;g[d+220>>2]=0.0}f=f+1|0}while((f|0)!=(e|0))}d=c[m+372>>2]|0;if((d|0)>0){e=c[m+396>>2]|0;f=0;do{if((e|0)>0){d=0;do{zb[((c[(c[m+404>>2]|0)+(d<<2)>>2]|0)==0?23:0)&31](m,1.0);d=d+1|0;e=c[m+396>>2]|0}while((d|0)<(e|0));d=c[m+372>>2]|0}f=f+1|0}while((f|0)<(d|0));d=c[m+712>>2]|0;if((d|0)>0){e=0;do{l=c[m+720>>2]|0;z=+g[m+452>>2];A=z*+g[l+(e*104|0)+44>>2]+ +g[l+(e*104|0)+28>>2];B=z*+g[l+(e*104|0)+48>>2]+ +g[l+(e*104|0)+32>>2];g[l+(e*104|0)+8>>2]=+g[l+(e*104|0)+40>>2]*z+ +g[l+(e*104|0)+24>>2];g[l+(e*104|0)+12>>2]=A;g[l+(e*104|0)+16>>2]=B;g[l+(e*104|0)+20>>2]=0.0;e=e+1|0}while((e|0)!=(d|0))}}d=c[m+376>>2]|0;if((d|0)>0){e=c[m+416>>2]|0;h=0;do{b=+(h|0)/+(d|0);if((e|0)>0){f=0;do{switch(c[(c[m+424>>2]|0)+(f<<2)>>2]|0){case 1:{d=2;break}case 0:{d=3;break}case 2:{d=4;break}case 3:{d=5;break}default:d=0}Nb[d&7](m,1.0,b);f=f+1|0;e=c[m+416>>2]|0}while((f|0)<(e|0));d=c[m+376>>2]|0}h=h+1|0}while((h|0)<(d|0));b=+g[m+456>>2]*(1.0-+g[m+296>>2]);d=c[m+712>>2]|0;if((d|0)>0){e=0;do{l=c[m+720>>2]|0;A=b*(+g[l+(e*104|0)+12>>2]-+g[l+(e*104|0)+28>>2]);B=b*(+g[l+(e*104|0)+16>>2]-+g[l+(e*104|0)+32>>2]);g[l+(e*104|0)+40>>2]=b*(+g[l+(e*104|0)+8>>2]-+g[l+(e*104|0)+24>>2]);g[l+(e*104|0)+44>>2]=A;g[l+(e*104|0)+48>>2]=B;l=l+(e*104|0)+52|0;e=e+1|0;c[l>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;c[l+16>>2]=0}while((e|0)!=(d|0))}}d=c[m+380>>2]|0;if((d|0)>0){b=+g[m+292>>2]*+g[m+456>>2];e=c[m+712>>2]|0;if((e|0)>0){d=0;do{k=c[m+720>>2]|0;l=k+(d*104|0)+24|0;k=k+(d*104|0)+8|0;c[l>>2]=c[k>>2];c[l+4>>2]=c[k+4>>2];c[l+8>>2]=c[k+8>>2];c[l+12>>2]=c[k+12>>2];d=d+1|0}while((d|0)!=(e|0));d=c[m+380>>2]|0;if((d|0)>0)w=42}else w=42;if((w|0)==42){w=0;e=c[m+436>>2]|0;h=0;do{if((e|0)>0){f=0;do{switch(c[(c[m+444>>2]|0)+(f<<2)>>2]|0){case 1:{d=2;break}case 0:{d=3;break}case 2:{d=4;break}case 3:{d=5;break}default:d=0}Nb[d&7](m,1.0,0.0);f=f+1|0;e=c[m+436>>2]|0}while((f|0)<(e|0));d=c[m+380>>2]|0}h=h+1|0}while((h|0)<(d|0))}d=c[m+712>>2]|0;if((d|0)>0){e=c[m+720>>2]|0;f=0;do{A=b*(+g[e+(f*104|0)+12>>2]-+g[e+(f*104|0)+28>>2]);B=b*(+g[e+(f*104|0)+16>>2]-+g[e+(f*104|0)+32>>2]);l=e+(f*104|0)+40|0;g[l>>2]=b*(+g[e+(f*104|0)+8>>2]-+g[e+(f*104|0)+24>>2])+ +g[l>>2];l=e+(f*104|0)+44|0;g[l>>2]=A+ +g[l>>2];l=e+(f*104|0)+48|0;g[l>>2]=B+ +g[l>>2];f=f+1|0}while((f|0)!=(d|0))}}d=c[m+1112>>2]|0;if((d|0)>0){e=c[m+1120>>2]|0;k=0;do{f=c[e+(k<<2)>>2]|0;if(+g[f+352>>2]>0.0?(p=c[f+24>>2]|0,(p|0)>0):0){h=c[f+32>>2]|0;l=0;do{j=c[h+(l<<2)>>2]|0;if(+g[j+88>>2]>0.0?(t=+g[j+24>>2]-+g[f+228>>2],v=+g[j+28>>2]-+g[f+232>>2],r=+g[j+32>>2]-+g[f+236>>2],s=+g[f+336>>2],B=+g[f+340>>2],u=+g[f+332>>2],q=+g[f+316>>2]+(s*r-v*B),r=+g[f+320>>2]+(t*B-r*u),s=v*u-t*s+ +g[f+324>>2],t=+g[j+40>>2],u=+g[j+44>>2],v=+g[j+48>>2],q*q+r*r+s*s<=t*t+u*u+v*v):0){B=+g[f+352>>2];g[j+40>>2]=t+(q-t)*B;g[j+44>>2]=(r-u)*B+u;g[j+48>>2]=(s-v)*B+v}l=l+1|0}while((l|0)!=(p|0))}k=k+1|0}while((k|0)!=(d|0))}Wd(m,1);d=c[a+24>>2]|0}}n=n+1|0}while((n|0)<(d|0));i=o;return}function gd(d,e){d=d|0;e=+e;var f=0,h=0.0,j=0,k=0.0,l=0.0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0,t=0.0,u=0;s=i;i=i+304|0;li(12028);a:do if((c[d+232>>2]|0)>0){n=s+136+48|0;o=0;while(1){m=c[(c[d+240>>2]|0)+(o<<2)>>2]|0;g[m+244>>2]=1.0;b:do switch(c[m+216>>2]|0){case 2:case 5:break;default:if(!(c[m+204>>2]&3)){Zg(m+4|0,+g[m+312>>2],+g[m+316>>2],+g[m+320>>2],m+328|0,e,s+136|0);h=+g[n>>2]-+g[m+52>>2];k=+g[s+136+52>>2]-+g[m+56>>2];l=+g[s+136+56>>2]-+g[m+60>>2];if(a[d+44>>0]|0?(t=+g[m+252>>2],t*t!=0.0?t*t>2]|0)+4>>2]|0)<20){c[5816]=(c[5816]|0)+1;f=c[d+68>>2]|0;f=Eb[c[(c[f>>2]|0)+36>>2]&127](f)|0;j=c[d+24>>2]|0;g[s+200+4>>2]=1.0;b[s+200+8>>1]=1;b[s+200+10>>1]=-1;c[s+200>>2]=2872;c[s+200+12>>2]=c[m+52>>2];c[s+200+12+4>>2]=c[m+52+4>>2];c[s+200+12+8>>2]=c[m+52+8>>2];c[s+200+12+12>>2]=c[m+52+12>>2];c[s+200+28>>2]=c[n>>2];c[s+200+28+4>>2]=c[n+4>>2];c[s+200+28+8>>2]=c[n+8>>2];c[s+200+28+12>>2]=c[n+12>>2];c[s+200+76>>2]=0;c[s+200>>2]=4332;c[s+200+80>>2]=m;c[s+200+88>>2]=f;c[s+200+92>>2]=j;j=c[m+248>>2]|0;c[s+64+8>>2]=0;c[s+64+12>>2]=1065353216;c[s+64+16>>2]=1065353216;c[s+64+20>>2]=1065353216;g[s+64+24>>2]=0.0;c[s+64>>2]=6672;c[s+64+4>>2]=8;c[s+64+28>>2]=j;c[s+64+44>>2]=j;c[s+200+84>>2]=c[d+56>>2];j=c[(c[m+188>>2]|0)+4>>2]|0;b[s+200+8>>1]=j;b[s+200+10>>1]=j>>>16;c[s+48>>2]=c[n>>2];c[s+48+4>>2]=c[n+4>>2];c[s+48+8>>2]=c[n+8>>2];c[s+48+12>>2]=c[n+12>>2];c[s>>2]=c[m+4>>2];c[s+4>>2]=c[m+4+4>>2];c[s+8>>2]=c[m+4+8>>2];c[s+12>>2]=c[m+4+12>>2];c[s+16>>2]=c[m+20>>2];c[s+16+4>>2]=c[m+20+4>>2];c[s+16+8>>2]=c[m+20+8>>2];c[s+16+12>>2]=c[m+20+12>>2];c[s+32>>2]=c[m+36>>2];c[s+32+4>>2]=c[m+36+4>>2];c[s+32+8>>2]=c[m+36+8>>2];c[s+32+12>>2]=c[m+36+12>>2];Kd(d,s+64|0,m+4|0,s,s+200|0,0.0);h=+g[s+200+4>>2];if(h<1.0){g[m+244>>2]=h;Zg(m+4|0,+g[m+312>>2],+g[m+316>>2],+g[m+320>>2],m+328|0,h*e,s+136|0);g[m+244>>2]=0.0;Se(m,s+136|0);f=4}else f=0;if(!f)p=12}else p=12;if((p|0)==12){p=0;f=0}j=c[2357]|0;u=(c[j+16>>2]|0)+-1|0;c[j+16>>2]=u;do if(!u){if(c[j+4>>2]|0){tb(s+200|0,0)|0;u=c[6434]|0;g[j+8>>2]=+g[j+8>>2]+ +(((c[s+200+4>>2]|0)-(c[u+4>>2]|0)+(((c[s+200>>2]|0)-(c[u>>2]|0)|0)*1e6|0)-(c[j+12>>2]|0)|0)>>>0)/1.0e3;if(c[j+16>>2]|0)break;j=c[2357]|0}c[2357]=c[j+20>>2]}while(0);if(f|0)break b}Se(m,s+136|0)}}while(0);o=o+1|0;if((o|0)>=(c[d+232>>2]|0))break a}}while(0);do if(a[d+275>>0]|0){li(12105);if((c[d+308>>2]|0)>0){p=0;do{o=c[(c[d+316>>2]|0)+(p<<2)>>2]|0;m=c[o+740>>2]|0;m=(c[m+236>>2]&2|0)==0?0:m;n=c[o+744>>2]|0;n=(c[n+236>>2]&2|0)==0?0:n;f=c[o+748>>2]|0;if((f|0)>0)if(!m){j=0;do{h=+g[57]*+g[n+228>>2];if(h>0.0?(q=+g[o+4+(j*184|0)+120>>2],q!=0.0):0){l=h*+g[o+4+(j*184|0)+64>>2]*q;e=h*+g[o+4+(j*184|0)+68>>2]*q;t=h*+g[o+4+(j*184|0)+72>>2]*q;h=+g[o+4+(j*184|0)+36>>2]-+g[n+56>>2];k=+g[o+4+(j*184|0)+40>>2]-+g[n+60>>2];g[s>>2]=+g[o+4+(j*184|0)+32>>2]-+g[n+52>>2];g[s+4>>2]=h;g[s+8>>2]=k;g[s+12>>2]=0.0;g[s+120>>2]=l;g[s+120+4>>2]=e;g[s+120+8>>2]=t;g[s+120+12>>2]=0.0;gj(n,s+120|0,s);f=c[o+748>>2]|0}j=j+1|0}while((j|0)<(f|0))}else{j=0;do{h=+g[m+228>>2]*+g[n+228>>2];if(h>0.0?(r=+g[o+4+(j*184|0)+120>>2],r!=0.0):0){l=h*+g[o+4+(j*184|0)+64>>2]*r;e=h*+g[o+4+(j*184|0)+68>>2]*r;t=h*+g[o+4+(j*184|0)+72>>2]*r;g[s+200>>2]=-l;g[s+200+4>>2]=-e;g[s+200+8>>2]=-t;g[s+200+12>>2]=0.0;k=+g[o+4+(j*184|0)+52>>2]-+g[m+56>>2];h=+g[o+4+(j*184|0)+56>>2]-+g[m+60>>2];g[s+64>>2]=+g[o+4+(j*184|0)+48>>2]-+g[m+52>>2];g[s+64+4>>2]=k;g[s+64+8>>2]=h;g[s+64+12>>2]=0.0;h=+g[o+4+(j*184|0)+36>>2]-+g[n+56>>2];k=+g[o+4+(j*184|0)+40>>2]-+g[n+60>>2];g[s>>2]=+g[o+4+(j*184|0)+32>>2]-+g[n+52>>2];g[s+4>>2]=h;g[s+8>>2]=k;g[s+12>>2]=0.0;gj(m,s+200|0,s+64|0);g[s+120>>2]=l;g[s+120+4>>2]=e;g[s+120+8>>2]=t;g[s+120+12>>2]=0.0;gj(n,s+120|0,s);f=c[o+748>>2]|0}j=j+1|0}while((j|0)<(f|0))}p=p+1|0}while((p|0)<(c[d+308>>2]|0))}f=c[2357]|0;u=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=u;if(!u){if(c[f+4>>2]|0){tb(s+200|0,0)|0;u=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[s+200+4>>2]|0)-(c[u+4>>2]|0)+(((c[s+200>>2]|0)-(c[u>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(c[f+16>>2]|0)break;f=c[2357]|0}c[2357]=c[f+20>>2]}}while(0);f=c[2357]|0;u=(c[f+16>>2]|0)+-1|0;c[f+16>>2]=u;if(u|0){i=s;return}do if(c[f+4>>2]|0){tb(s+200|0,0)|0;u=c[6434]|0;g[f+8>>2]=+g[f+8>>2]+ +(((c[s+200+4>>2]|0)-(c[u+4>>2]|0)+(((c[s+200>>2]|0)-(c[u>>2]|0)|0)*1e6|0)-(c[f+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[f+16>>2]|0)){f=c[2357]|0;break}else{i=s;return}}while(0);c[2357]=c[f+20>>2];i=s;return}function hd(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;if(!a)return;h=c[6442]|0;if((a+-8|0)>>>0>>0)Va();b=c[a+-4>>2]|0;if((b&3|0)==1)Va();n=a+-8+(b&-8)|0;do if(!(b&1)){e=c[a+-8>>2]|0;if(!(b&3))return;k=a+-8+(0-e)|0;j=e+(b&-8)|0;if(k>>>0>>0)Va();if((k|0)==(c[6443]|0)){a=c[n+4>>2]|0;if((a&3|0)!=3){q=k;f=j;break}c[6440]=j;c[n+4>>2]=a&-2;c[k+4>>2]=j|1;c[k+j>>2]=j;return}if(e>>>0<256){a=c[k+8>>2]|0;b=c[k+12>>2]|0;if((a|0)!=(25792+(e>>>3<<1<<2)|0)){if(a>>>0>>0)Va();if((c[a+12>>2]|0)!=(k|0))Va()}if((b|0)==(a|0)){c[6438]=c[6438]&~(1<<(e>>>3));q=k;f=j;break}if((b|0)!=(25792+(e>>>3<<1<<2)|0)){if(b>>>0>>0)Va();if((c[b+8>>2]|0)!=(k|0))Va();else d=b+8|0}else d=b+8|0;c[a+12>>2]=b;c[d>>2]=a;q=k;f=j;break}g=c[k+24>>2]|0;a=c[k+12>>2]|0;do if((a|0)==(k|0)){a=c[k+16+4>>2]|0;if(!a){a=c[k+16>>2]|0;if(!a){i=0;break}else e=k+16|0}else e=k+16+4|0;while(1){b=a+20|0;d=c[b>>2]|0;if(d|0){a=d;e=b;continue}b=a+16|0;d=c[b>>2]|0;if(!d)break;else{a=d;e=b}}if(e>>>0>>0)Va();else{c[e>>2]=0;i=a;break}}else{b=c[k+8>>2]|0;if(b>>>0>>0)Va();if((c[b+12>>2]|0)!=(k|0))Va();if((c[a+8>>2]|0)==(k|0)){c[b+12>>2]=a;c[a+8>>2]=b;i=a;break}else Va()}while(0);if(g){a=c[k+28>>2]|0;if((k|0)==(c[26056+(a<<2)>>2]|0)){c[26056+(a<<2)>>2]=i;if(!i){c[6439]=c[6439]&~(1<>>0<(c[6442]|0)>>>0)Va();if((c[g+16>>2]|0)==(k|0))c[g+16>>2]=i;else c[g+20>>2]=i;if(!i){q=k;f=j;break}}b=c[6442]|0;if(i>>>0>>0)Va();c[i+24>>2]=g;a=c[k+16>>2]|0;do if(a|0)if(a>>>0>>0)Va();else{c[i+16>>2]=a;c[a+24>>2]=i;break}while(0);a=c[k+16+4>>2]|0;if(a)if(a>>>0<(c[6442]|0)>>>0)Va();else{c[i+20>>2]=a;c[a+24>>2]=i;q=k;f=j;break}else{q=k;f=j}}else{q=k;f=j}}else{q=a+-8|0;f=b&-8}while(0);if(q>>>0>=n>>>0)Va();d=c[n+4>>2]|0;if(!(d&1))Va();if(!(d&2)){if((n|0)==(c[6444]|0)){p=(c[6441]|0)+f|0;c[6441]=p;c[6444]=q;c[q+4>>2]=p|1;if((q|0)!=(c[6443]|0))return;c[6443]=0;c[6440]=0;return}if((n|0)==(c[6443]|0)){p=(c[6440]|0)+f|0;c[6440]=p;c[6443]=q;c[q+4>>2]=p|1;c[q+p>>2]=p;return}f=(d&-8)+f|0;do if(d>>>0>=256){g=c[n+24>>2]|0;a=c[n+12>>2]|0;do if((a|0)==(n|0)){a=c[n+16+4>>2]|0;if(!a){a=c[n+16>>2]|0;if(!a){m=0;break}else e=n+16|0}else e=n+16+4|0;while(1){b=a+20|0;d=c[b>>2]|0;if(d|0){a=d;e=b;continue}b=a+16|0;d=c[b>>2]|0;if(!d)break;else{a=d;e=b}}if(e>>>0<(c[6442]|0)>>>0)Va();else{c[e>>2]=0;m=a;break}}else{b=c[n+8>>2]|0;if(b>>>0<(c[6442]|0)>>>0)Va();if((c[b+12>>2]|0)!=(n|0))Va();if((c[a+8>>2]|0)==(n|0)){c[b+12>>2]=a;c[a+8>>2]=b;m=a;break}else Va()}while(0);if(g|0){a=c[n+28>>2]|0;if((n|0)==(c[26056+(a<<2)>>2]|0)){c[26056+(a<<2)>>2]=m;if(!m){c[6439]=c[6439]&~(1<>>0<(c[6442]|0)>>>0)Va();if((c[g+16>>2]|0)==(n|0))c[g+16>>2]=m;else c[g+20>>2]=m;if(!m)break}b=c[6442]|0;if(m>>>0>>0)Va();c[m+24>>2]=g;a=c[n+16>>2]|0;do if(a|0)if(a>>>0>>0)Va();else{c[m+16>>2]=a;c[a+24>>2]=m;break}while(0);a=c[n+16+4>>2]|0;if(a|0)if(a>>>0<(c[6442]|0)>>>0)Va();else{c[m+20>>2]=a;c[a+24>>2]=m;break}}}else{a=c[n+8>>2]|0;b=c[n+12>>2]|0;if((a|0)!=(25792+(d>>>3<<1<<2)|0)){if(a>>>0<(c[6442]|0)>>>0)Va();if((c[a+12>>2]|0)!=(n|0))Va()}if((b|0)==(a|0)){c[6438]=c[6438]&~(1<<(d>>>3));break}if((b|0)!=(25792+(d>>>3<<1<<2)|0)){if(b>>>0<(c[6442]|0)>>>0)Va();if((c[b+8>>2]|0)!=(n|0))Va();else l=b+8|0}else l=b+8|0;c[a+12>>2]=b;c[l>>2]=a}while(0);c[q+4>>2]=f|1;c[q+f>>2]=f;if((q|0)==(c[6443]|0)){c[6440]=f;return}}else{c[n+4>>2]=d&-2;c[q+4>>2]=f|1;c[q+f>>2]=f}b=f>>>3;if(f>>>0<256){a=c[6438]|0;if(a&1<>2]|0;if(a>>>0<(c[6442]|0)>>>0)Va();else{o=25792+(b<<1<<2)+8|0;p=a}}else{c[6438]=a|1<>2]=q;c[p+12>>2]=q;c[q+8>>2]=p;c[q+12>>2]=25792+(b<<1<<2);return}a=f>>>8;if(a)if(f>>>0>16777215)d=31;else{d=a<<((a+1048320|0)>>>16&8)<<(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4);d=14-(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4|(a+1048320|0)>>>16&8|(d+245760|0)>>>16&2)+(d<<((d+245760|0)>>>16&2)>>>15)|0;d=f>>>(d+7|0)&1|d<<1}else d=0;e=26056+(d<<2)|0;c[q+28>>2]=d;c[q+20>>2]=0;c[q+16>>2]=0;a=c[6439]|0;b=1<>>1)|0);e=c[e>>2]|0;while(1){if((c[e+4>>2]&-8|0)==(f|0)){a=130;break}b=e+16+(d>>>31<<2)|0;a=c[b>>2]|0;if(!a){a=127;break}else{d=d<<1;e=a}}if((a|0)==127)if(b>>>0<(c[6442]|0)>>>0)Va();else{c[b>>2]=q;c[q+24>>2]=e;c[q+12>>2]=q;c[q+8>>2]=q;break}else if((a|0)==130){a=e+8|0;b=c[a>>2]|0;p=c[6442]|0;if(b>>>0>=p>>>0&e>>>0>=p>>>0){c[b+12>>2]=q;c[a>>2]=q;c[q+8>>2]=b;c[q+12>>2]=e;c[q+24>>2]=0;break}else Va()}}else{c[6439]=a|b;c[e>>2]=q;c[q+24>>2]=e;c[q+12>>2]=q;c[q+8>>2]=q}while(0);q=(c[6446]|0)+-1|0;c[6446]=q;if(!q)a=26208;else return;while(1){a=c[a>>2]|0;if(!a)break;else a=a+8|0}c[6446]=-1;return}function id(b,d,e){b=b|0;d=d|0;e=+e;var f=0,h=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0,p=0.0,q=0,r=0,s=0;s=i;i=i+112|0;q=c[b+716>>2]|0;if((q|0)==(c[b+712>>2]|0)){a:do if(q){k=c[b+720>>2]|0;if((q|0)>0){h=k;j=0;while(1){f=c[h+(j*104|0)+96>>2]|0;if(f|0)c[f+36>>2]=j;f=j+1|0;if((f|0)==(q|0))break a;h=c[b+720>>2]|0;j=f}}}else k=0;while(0);f=c[b+732>>2]|0;if((f|0)>0){h=0;do{o=(c[b+740>>2]|0)+(h*52|0)+8|0;c[o>>2]=((c[o>>2]|0)-k|0)/104|0;o=(c[b+740>>2]|0)+(h*52|0)+12|0;c[o>>2]=((c[o>>2]|0)-k|0)/104|0;h=h+1|0}while((h|0)!=(f|0))}f=c[b+752>>2]|0;if((f|0)>0){j=0;do{h=(c[b+760>>2]|0)+(j*44|0)+8|0;c[h>>2]=((c[h>>2]|0)-k|0)/104|0;h=(c[b+760>>2]|0)+(j*44|0)+12|0;c[h>>2]=((c[h>>2]|0)-k|0)/104|0;h=(c[b+760>>2]|0)+(j*44|0)+16|0;c[h>>2]=((c[h>>2]|0)-k|0)/104|0;h=c[(c[b+760>>2]|0)+(j*44|0)+40>>2]|0;if(h|0)c[h+36>>2]=j;j=j+1|0}while((j|0)!=(f|0))}f=c[b+792>>2]|0;if((f|0)>0){h=c[b+800>>2]|0;j=0;do{o=h+(j*96|0)|0;c[o>>2]=((c[o>>2]|0)-k|0)/104|0;j=j+1|0}while((j|0)!=(f|0))}j=c[b+692>>2]|0;if((j|0)>0){f=c[b+700>>2]|0;l=0;do{if((c[f+(l*60|0)+24>>2]|0)>0){h=0;do{f=f+(l*60|0)+28+(h<<2)|0;c[f>>2]=((c[f>>2]|0)-k|0)/104|0;h=h+1|0;f=c[b+700>>2]|0}while((h|0)<(c[f+(l*60|0)+24>>2]|0))}l=l+1|0}while((l|0)!=(j|0))}if((q|0)<(q<<1|1|0)){c[6435]=(c[6435]|0)+1;f=yc(((q<<1|1)*104|3)+16|0)|0;if(!f)j=0;else{c[(f+4+15&-16)+-4>>2]=f;j=f+4+15&-16}f=c[b+712>>2]|0;if((f|0)>0){h=0;do{l=j+(h*104|0)|0;k=(c[b+720>>2]|0)+(h*104|0)|0;o=l+104|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(o|0));h=h+1|0}while((h|0)!=(f|0))}f=c[b+720>>2]|0;if(f|0){if(a[b+724>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+720>>2]=0}a[b+724>>0]=1;c[b+720>>2]=j;c[b+716>>2]=q<<1|1;j=c[b+712>>2]|0}else j=q;b:do if(j){k=c[b+720>>2]|0;if((j|0)>0){l=k;f=0;while(1){h=c[l+(f*104|0)+96>>2]|0;if(h|0)c[h+36>>2]=l+(f*104|0);f=f+1|0;if((f|0)==(j|0)){l=k;break b}l=c[b+720>>2]|0}}else l=k}else l=0;while(0);f=c[b+732>>2]|0;if((f|0)>0){h=0;do{q=(c[b+740>>2]|0)+(h*52|0)+8|0;c[q>>2]=l+((c[q>>2]|0)*104|0);q=(c[b+740>>2]|0)+(h*52|0)+12|0;c[q>>2]=l+((c[q>>2]|0)*104|0);h=h+1|0}while((h|0)!=(f|0))}f=c[b+752>>2]|0;if((f|0)>0){k=0;do{h=(c[b+760>>2]|0)+(k*44|0)+8|0;c[h>>2]=l+((c[h>>2]|0)*104|0);h=(c[b+760>>2]|0)+(k*44|0)+12|0;c[h>>2]=l+((c[h>>2]|0)*104|0);h=(c[b+760>>2]|0)+(k*44|0)+16|0;c[h>>2]=l+((c[h>>2]|0)*104|0);h=c[b+760>>2]|0;j=c[h+(k*44|0)+40>>2]|0;if(j|0)c[j+36>>2]=h+(k*44|0);k=k+1|0}while((k|0)!=(f|0))}f=c[b+792>>2]|0;if((f|0)>0){h=c[b+800>>2]|0;j=0;do{c[h+(j*96|0)>>2]=l+((c[h+(j*96|0)>>2]|0)*104|0);j=j+1|0}while((j|0)!=(f|0))}j=c[b+692>>2]|0;if((j|0)>0){f=c[b+700>>2]|0;k=0;do{if((c[f+(k*60|0)+24>>2]|0)>0){h=0;do{f=f+(k*60|0)+28+(h<<2)|0;c[f>>2]=l+((c[f>>2]|0)*104|0);h=h+1|0;f=c[b+700>>2]|0}while((h|0)<(c[f+(k*60|0)+24>>2]|0))}k=k+1|0}while((k|0)!=(j|0))}}l=c[b+192>>2]|0;p=+Sb[c[(c[l>>2]|0)+48>>2]&15](l);l=s;o=l+100|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(o|0));f=c[b+712>>2]|0;if((f|0)==(c[b+716>>2]|0)?(r=f|0?f<<1:1,(f|0)<(r|0)):0){if(!r)j=0;else{c[6435]=(c[6435]|0)+1;f=yc((r*104|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=f;f=c[b+712>>2]|0}if((f|0)>0){h=0;do{l=j+(h*104|0)|0;k=(c[b+720>>2]|0)+(h*104|0)|0;o=l+104|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(o|0));h=h+1|0}while((h|0)!=(f|0))}f=c[b+720>>2]|0;if(f|0){if(a[b+724>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+720>>2]=0}a[b+724>>0]=1;c[b+720>>2]=j;c[b+716>>2]=r;f=c[b+712>>2]|0}l=c[b+720>>2]|0;c[l+(f*104|0)>>2]=0;l=l+(f*104|0)+4|0;k=s;o=l+100|0;do{c[l>>2]=c[k>>2];l=l+4|0;k=k+4|0}while((l|0)<(o|0));h=c[b+712>>2]|0;c[b+712>>2]=h+1;j=c[b+720>>2]|0;l=j+(h*104|0)|0;o=l+104|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(o|0));c[j+(h*104|0)+8>>2]=c[d>>2];c[j+(h*104|0)+8+4>>2]=c[d+4>>2];c[j+(h*104|0)+8+8>>2]=c[d+8>>2];c[j+(h*104|0)+8+12>>2]=c[d+12>>2];Bp(j+(h*104|0)+24|0,d|0,16)|0;g[j+(h*104|0)+88>>2]=e>0.0?1.0/e:0.0;c[j+(h*104|0)+4>>2]=c[c[b+880>>2]>>2];e=+g[j+(h*104|0)+8>>2];m=+g[j+(h*104|0)+12>>2];n=+g[j+(h*104|0)+16>>2];f=c[b+932>>2]|0;if(f|0){c[b+932>>2]=0;d=f;r=d+32|0;c[r>>2]=0;r=d+36|0;c[r>>2]=j+(h*104|0);r=d+40|0;c[r>>2]=0;g[d>>2]=e-p;r=d+4|0;g[r>>2]=m-p;r=d+8|0;g[r>>2]=n-p;r=d+12|0;g[r>>2]=0.0;r=d+16|0;g[r>>2]=p+e;r=d+20|0;g[r>>2]=p+m;r=d+24|0;g[r>>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F*F+w*w));l=ri(G)|0;y=+g[d+4>>2]-+g[l+48>>2];z=+g[d+8>>2]-+g[l+52>>2];A=+g[d+12>>2]-+g[l+56>>2];l=ri(G+16|0)|0;B=+g[d+20>>2]-+g[l+48>>2];C=+g[d+24>>2]-+g[l+52>>2];D=+g[d+28>>2]-+g[l+56>>2];if(!f)if(!e){n=0.0;o=0.0;r=0.0;s=0.0;p=0.0;q=0.0}else{q=+g[e+336>>2];r=+g[e+340>>2];v=+g[e+332>>2];n=A*q-z*r;o=+g[e+316>>2];r=y*r-A*v;s=+g[e+320>>2];p=+g[e+324>>2];q=z*v-y*q}else{q=+g[f+332>>2];r=+g[f+336>>2];v=+g[f+328>>2];n=A*q-z*r;o=+g[f+312>>2];r=y*r-A*v;s=+g[f+316>>2];p=+g[f+320>>2];q=z*v-y*q}v=o+n;u=s+r;t=p+q;if(!k)if(!j){p=0.0;q=0.0;r=0.0;s=0.0;n=0.0;o=0.0}else{o=+g[j+336>>2];r=+g[j+340>>2];H=+g[j+332>>2];p=D*o-C*r;q=+g[j+316>>2];r=B*r-D*H;s=+g[j+320>>2];n=+g[j+324>>2];o=C*H-B*o}else{o=+g[k+332>>2];r=+g[k+336>>2];H=+g[k+328>>2];p=D*o-C*r;q=+g[k+312>>2];r=B*r-D*H;s=+g[k+316>>2];n=+g[k+320>>2];o=C*H-B*o}q=v-(q+p);u=u-(s+r);t=t-(n+o);v=w*x*t+(F*x*u+E*x*q);H=+g[d+52>>2]-+g[b+12>>2];c[m+4>>2]=c[G>>2];c[m+4+4>>2]=c[G+4>>2];c[m+4+8>>2]=c[G+8>>2];c[m+16>>2]=c[G+16>>2];c[m+16+4>>2]=c[G+16+4>>2];c[m+16+8>>2]=c[G+16+8>>2];d=ri(G)|0;s=y*+g[d+4>>2]+z*+g[d+20>>2]+A*+g[d+36>>2];r=y*+g[d+8>>2]+z*+g[d+24>>2]+A*+g[d+40>>2];g[m+28>>2]=y*+g[d>>2]+z*+g[d+16>>2]+A*+g[d+32>>2];g[m+32>>2]=s;g[m+36>>2]=r;g[m+40>>2]=0.0;d=ri(G+16|0)|0;r=B*+g[d+4>>2]+C*+g[d+20>>2]+D*+g[d+36>>2];s=B*+g[d+8>>2]+C*+g[d+24>>2]+D*+g[d+40>>2];g[m+44>>2]=B*+g[d>>2]+C*+g[d+16>>2]+D*+g[d+32>>2];g[m+48>>2]=r;g[m+52>>2]=s;g[m+56>>2]=0.0;g[m+164>>2]=y;g[m+168>>2]=z;g[m+172>>2]=A;g[m+176>>2]=0.0;g[m+180>>2]=B;g[m+184>>2]=C;g[m+188>>2]=D;g[m+192>>2]=0.0;g[m+60>>2]=1.0;g[m+64>>2]=1.0;c[m+156>>2]=0;c[m+160>>2]=0;g[m+68>>2]=1.0;g[m+72>>2]=E*x*H;g[m+76>>2]=F*x*H;g[m+80>>2]=w*x*H;g[m+84>>2]=0.0;g[m+196>>2]=E*x;g[m+200>>2]=F*x;g[m+204>>2]=w*x;c[m+208>>2]=h;a[m+152>>0]=0;H=+g[b+16>>2];g[m+212>>2]=(t-w*x*v)*(t-w*x*v)+((q-E*x*v)*(q-E*x*v)+(u-F*x*v)*(u-F*x*v))>2]|0;if(!h){h=c[G>>2]|0;if(!h)o=0.0;else o=+g[h+128>>2]}else o=+g[h+344>>2];if((a[22504]|0)==0?Wa(22504)|0:0){h=23084;l=h+48|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(l|0));_a(22504)}h=c[G+4>>2]|0;if(!h){e=c[G>>2]|0;e=(e|0)==0?23084:e+180|0}else e=h+264|0;h=c[G+16+4>>2]|0;if(!h){h=c[G+16>>2]|0;if(!h)n=0.0;else n=+g[h+128>>2]}else n=+g[h+344>>2];if((a[22504]|0)==0?Wa(22504)|0:0){h=23084;l=h+48|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(l|0));_a(22504)}h=c[G+16+4>>2]|0;if(!h){h=c[G+16>>2]|0;h=(h|0)==0?23084:h+180|0}else h=h+264|0;V=+g[m+172>>2];M=+g[m+168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b+136>>2];p=+g[b+152>>2];q=+g[b+124>>2];s=+g[b+140>>2];t=+g[b+156>>2];j=+g[e+16>>2];m=+g[e+20>>2];o=+g[e+24>>2];r=+g[e+32>>2];z=+g[e+36>>2];A=+g[e+40>>2];h=+g[b+164>>2];f=+g[b+168>>2];v=+g[b+172>>2];u=+g[e+48>>2]+(i*h+C*f+D*v);B=j*h+m*f+o*v+ +g[e+52>>2];v=r*h+z*f+A*v+ +g[e+56>>2];g[b+824>>2]=w*i+x*C+y*D;g[b+828>>2]=i*l+C*n+D*p;g[b+832>>2]=i*q+C*s+D*t;g[b+836>>2]=0.0;g[b+840>>2]=w*j+x*m+y*o;g[b+844>>2]=l*j+n*m+p*o;g[b+848>>2]=q*j+s*m+t*o;g[b+852>>2]=0.0;g[b+856>>2]=w*r+x*z+y*A;g[b+860>>2]=l*r+n*z+p*A;g[b+864>>2]=q*r+s*z+t*A;g[b+868>>2]=0.0;g[b+872>>2]=u;g[b+876>>2]=B;g[b+880>>2]=v;g[b+884>>2]=0.0;v=+g[b+52>>2];B=+g[d>>2];u=+g[b+68>>2];A=+g[d+4>>2];t=+g[b+84>>2];z=+g[d+8>>2];s=+g[b+56>>2];r=+g[b+72>>2];q=+g[b+88>>2];p=+g[b+60>>2];n=+g[b+76>>2];l=+g[b+92>>2];y=+g[d+16>>2];x=+g[d+20>>2];w=+g[d+24>>2];o=+g[d+32>>2];m=+g[d+36>>2];j=+g[d+40>>2];D=+g[b+100>>2];C=+g[b+104>>2];i=+g[b+108>>2];f=+g[d+48>>2]+(B*D+A*C+z*i);h=y*D+x*C+w*i+ +g[d+52>>2];i=o*D+m*C+j*i+ +g[d+56>>2];g[b+888>>2]=v*B+u*A+t*z;g[b+892>>2]=B*s+A*r+z*q;g[b+896>>2]=B*p+A*n+z*l;g[b+900>>2]=0.0;g[b+904>>2]=v*y+u*x+t*w;g[b+908>>2]=s*y+r*x+q*w;g[b+912>>2]=p*y+n*x+l*w;g[b+916>>2]=0.0;g[b+920>>2]=v*o+u*m+t*j;g[b+924>>2]=s*o+r*m+q*j;g[b+928>>2]=p*o+n*m+l*j;g[b+932>>2]=0.0;g[b+936>>2]=f;g[b+940>>2]=h;g[b+944>>2]=i;g[b+948>>2]=0.0;d=b+856|0;e=b+840|0}else{o=+g[b+52>>2];D=+g[d>>2];n=+g[b+68>>2];h=+g[d+4>>2];m=+g[b+84>>2];f=+g[d+8>>2];z=+g[b+56>>2];x=+g[b+72>>2];v=+g[b+88>>2];u=+g[b+60>>2];s=+g[b+76>>2];r=+g[b+92>>2];A=+g[d+16>>2];y=+g[d+20>>2];w=+g[d+24>>2];t=+g[d+32>>2];l=+g[d+36>>2];j=+g[d+40>>2];C=+g[b+100>>2];B=+g[b+104>>2];p=+g[b+108>>2];q=+g[d+48>>2]+(D*C+h*B+f*p);i=A*C+y*B+w*p+ +g[d+52>>2];p=t*C+l*B+j*p+ +g[d+56>>2];g[b+824>>2]=o*D+n*h+m*f;g[b+828>>2]=D*z+h*x+f*v;g[b+832>>2]=D*u+h*s+f*r;g[b+836>>2]=0.0;g[b+840>>2]=o*A+n*y+m*w;g[b+844>>2]=z*A+x*y+v*w;g[b+848>>2]=u*A+s*y+r*w;g[b+852>>2]=0.0;g[b+856>>2]=o*t+n*l+m*j;g[b+860>>2]=z*t+x*l+v*j;g[b+864>>2]=u*t+s*l+r*j;g[b+868>>2]=0.0;g[b+872>>2]=q;g[b+876>>2]=i;g[b+880>>2]=p;g[b+884>>2]=0.0;p=+g[b+116>>2];i=+g[e>>2];q=+g[b+132>>2];j=+g[e+4>>2];r=+g[b+148>>2];l=+g[e+8>>2];s=+g[b+120>>2];t=+g[b+136>>2];u=+g[b+152>>2];v=+g[b+124>>2];x=+g[b+140>>2];z=+g[b+156>>2];m=+g[e+16>>2];n=+g[e+20>>2];o=+g[e+24>>2];w=+g[e+32>>2];y=+g[e+36>>2];A=+g[e+40>>2];f=+g[b+164>>2];h=+g[b+168>>2];D=+g[b+172>>2];B=+g[e+48>>2]+(i*f+j*h+l*D);C=m*f+n*h+o*D+ +g[e+52>>2];D=w*f+y*h+A*D+ +g[e+56>>2];g[b+888>>2]=p*i+q*j+r*l;g[b+892>>2]=i*s+j*t+l*u;g[b+896>>2]=i*v+j*x+l*z;g[b+900>>2]=0.0;g[b+904>>2]=p*m+q*n+r*o;g[b+908>>2]=s*m+t*n+u*o;g[b+912>>2]=v*m+x*n+z*o;g[b+916>>2]=0.0;g[b+920>>2]=p*w+q*y+r*A;g[b+924>>2]=s*w+t*y+u*A;g[b+928>>2]=v*w+x*y+z*A;g[b+932>>2]=0.0;g[b+936>>2]=B;g[b+940>>2]=C;g[b+944>>2]=D;g[b+948>>2]=0.0;d=b+856|0;e=b+840|0}c[b+968>>2]=c[b+872>>2];c[b+968+4>>2]=c[b+872+4>>2];c[b+968+8>>2]=c[b+872+8>>2];c[b+968+12>>2]=c[b+872+12>>2];c[b+984>>2]=c[b+936>>2];c[b+984+4>>2]=c[b+936+4>>2];c[b+984+8>>2]=c[b+936+8>>2];c[b+984+12>>2]=c[b+936+12>>2];F=c[b+824>>2]|0;E=c[e>>2]|0;e=c[d>>2]|0;c[b+952>>2]=F;c[b+956>>2]=E;c[b+960>>2]=e;g[b+964>>2]=0.0;f=(c[k>>2]=F,+g[k>>2]);h=(c[k>>2]=E,+g[k>>2]);i=(c[k>>2]=e,+g[k>>2]);if((a[b+180>>0]|0)==0?(a[b+48>>0]|0)==0:0){u=+g[b+968>>2];A=u-+g[b+984>>2];v=+g[b+972>>2];C=v-+g[b+988>>2];w=+g[b+976>>2];D=w-+g[b+992>>2];g[b+1016>>2]=A;g[b+1020>>2]=C;g[b+1024>>2]=D;g[b+1028>>2]=0.0;B=f*A;x=h*C;x=B+x;B=i*D;B=x+B;x=f*B;y=h*B;z=i*B;x=u+x;y=v+y;z=w+z;F=b+1e3|0;g[F>>2]=x;F=b+1004|0;g[F>>2]=y;F=b+1008|0;g[F>>2]=z;F=b+1012|0;g[F>>2]=0.0;F=b+1032|0;g[F>>2]=B;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[b+40>>2]|0)){j=c[b+12>>2]|0;if((j|0)>0){l=0;do{k=c[(c[b+20>>2]|0)+(l<<2)>>2]|0;if(k|0){Ab[c[c[k>>2]>>2]&255](k);n=c[b+4>>2]|0;Cb[c[(c[n>>2]|0)+60>>2]&127](n,c[(c[b+20>>2]|0)+(l<<2)>>2]|0)}l=l+1|0}while((l|0)!=(j|0))}lh(b,d,e)}n=c[r+64>>2]|0;j=c[b+4>>2]|0;k=c[b+20>>2]|0;m=c[b+32>>2]|0;c[s+192>>2]=6192;c[s+192+4>>2]=p;c[s+192+8>>2]=q;c[s+192+12>>2]=j;c[s+192+16>>2]=f;c[s+192+20>>2]=h;c[s+192+24>>2]=k;c[s+192+28>>2]=m;a[s+128+16>>0]=1;m=s+128+12|0;c[m>>2]=0;c[s+128+4>>2]=0;c[s+128+8>>2]=0;j=c[b+12>>2]|0;if((j|0)>0){d=k;f=0;while(1){k=c[d+(f<<2)>>2]|0;if(k){Cb[c[(c[k>>2]|0)+16>>2]&127](k,s+128|0);j=c[s+128+4>>2]|0;if((j|0)>0){l=0;do{e=c[(c[m>>2]|0)+(l<<2)>>2]|0;if(c[e+748>>2]|0){c[h+4>>2]=e;j=c[e+740>>2]|0;k=c[(c[h+8>>2]|0)+8>>2]|0;d=c[(c[h+12>>2]|0)+8>>2]|0;if((j|0)==(k|0))ef(e,j+4|0,d+4|0);else ef(e,d+4|0,k+4|0);c[h+4>>2]=0;j=c[s+128+4>>2]|0}l=l+1|0}while((l|0)<(j|0))}if((j|0)<0){if((c[s+128+8>>2]|0)<0){k=c[m>>2]|0;if(k|0){if(a[s+128+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[m>>2]=0}a[s+128+16>>0]=1;c[m>>2]=0;c[s+128+8>>2]=0}do{c[(c[m>>2]|0)+(j<<2)>>2]=0;j=j+1|0}while((j|0)!=0)}c[s+128+4>>2]=0;j=c[b+12>>2]|0}k=f+1|0;if((k|0)>=(j|0))break;d=c[b+20>>2]|0;f=k}j=c[m>>2]|0;if(j|0){if(a[s+128+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[m>>2]=0}}if(!n){k=c[b+12>>2]|0;if((k|0)>0){j=0;do{Te(s+192|0,c[(c[r+24>>2]|0)+(j*80|0)+64>>2]|0,j);j=j+1|0}while((j|0)<(k|0));o=38}}else{o=c[p+12>>2]|0;H=+g[o>>2];G=+g[o+16>>2];F=+g[o+32>>2];E=+g[o+4>>2];D=+g[o+20>>2];C=+g[o+36>>2];y=+g[o+8>>2];w=+g[o+24>>2];u=+g[o+40>>2];B=-+g[o+48>>2];A=-+g[o+52>>2];z=-+g[o+56>>2];o=c[q+12>>2]|0;Q=+g[o>>2];P=+g[o+16>>2];O=+g[o+32>>2];N=+g[o+4>>2];M=+g[o+20>>2];L=+g[o+36>>2];K=+g[o+8>>2];J=+g[o+24>>2];I=+g[o+40>>2];x=+g[o+48>>2];v=+g[o+52>>2];t=+g[o+56>>2];g[s+48>>2]=H*Q+G*P+F*O;g[s+48+4>>2]=H*N+G*M+F*L;g[s+48+8>>2]=H*K+G*J+F*I;g[s+48+12>>2]=0.0;g[s+48+16>>2]=E*Q+D*P+C*O;g[s+48+20>>2]=E*N+D*M+C*L;g[s+48+24>>2]=E*K+D*J+C*I;g[s+48+28>>2]=0.0;g[s+48+32>>2]=y*Q+w*P+u*O;g[s+48+36>>2]=y*N+w*M+u*L;g[s+48+40>>2]=y*K+w*J+u*I;g[s+48+44>>2]=0.0;g[s+48+48>>2]=H*B+G*A+F*z+(H*x+G*v+F*t);g[s+48+52>>2]=E*B+D*A+C*z+(E*x+D*v+C*t);g[s+48+56>>2]=y*B+w*A+u*z+(y*x+w*v+u*t);g[s+48+60>>2]=0.0;o=c[q+4>>2]|0;mc[c[(c[o>>2]|0)+8>>2]&127](o,s+48|0,s+128|0,s+112|0);c[s+16>>2]=c[s+128>>2];c[s+16+4>>2]=c[s+128+4>>2];c[s+16+8>>2]=c[s+128+8>>2];c[s+16+12>>2]=c[s+128+12>>2];c[s+16+16>>2]=c[s+112>>2];c[s+16+16+4>>2]=c[s+112+4>>2];c[s+16+16+8>>2]=c[s+112+8>>2];c[s+16+16+12>>2]=c[s+112+12>>2];bg(c[n>>2]|0,s+16|0,s+192|0);o=38}if((o|0)==38)k=c[b+12>>2]|0;if((k|0)<=0){i=s;return}d=0;do{do if(c[(c[b+20>>2]|0)+(d<<2)>>2]|0){n=c[r+24>>2]|0;o=c[n+(d*80|0)+64>>2]|0;h=c[p+12>>2]|0;w=+g[h>>2];x=+g[h+4>>2];y=+g[h+8>>2];z=+g[h+16>>2];A=+g[h+20>>2];B=+g[h+24>>2];I=+g[h+32>>2];K=+g[h+36>>2];M=+g[h+40>>2];C=+g[n+(d*80|0)>>2];D=+g[n+(d*80|0)+16>>2];E=+g[n+(d*80|0)+32>>2];F=+g[n+(d*80|0)+4>>2];G=+g[n+(d*80|0)+20>>2];H=+g[n+(d*80|0)+36>>2];J=+g[n+(d*80|0)+8>>2];L=+g[n+(d*80|0)+24>>2];N=+g[n+(d*80|0)+40>>2];u=+g[n+(d*80|0)+48>>2];v=+g[n+(d*80|0)+52>>2];Q=+g[n+(d*80|0)+56>>2];O=+g[h+48>>2]+(w*u+x*v+y*Q);P=+g[h+52>>2]+(z*u+A*v+B*Q);Q=+g[h+56>>2]+(I*u+K*v+M*Q);g[s+128>>2]=w*C+x*D+y*E;g[s+128+4>>2]=w*F+x*G+y*H;g[s+128+8>>2]=w*J+x*L+y*N;g[s+128+12>>2]=0.0;g[s+128+16>>2]=z*C+A*D+B*E;g[s+128+20>>2]=z*F+A*G+B*H;g[s+128+24>>2]=z*J+A*L+B*N;g[s+128+28>>2]=0.0;g[s+128+32>>2]=I*C+K*D+M*E;g[s+128+36>>2]=I*F+K*G+M*H;g[s+128+40>>2]=I*J+K*L+M*N;g[s+128+44>>2]=0.0;g[s+128+48>>2]=O;g[s+128+52>>2]=P;g[s+128+56>>2]=Q;g[s+128+60>>2]=0.0;mc[c[(c[o>>2]|0)+8>>2]&127](o,s+128|0,s+112|0,s+48|0);o=c[q+4>>2]|0;mc[c[(c[o>>2]|0)+8>>2]&127](o,c[q+12>>2]|0,s+16|0,s);if(!(+g[s+112>>2]>+g[s>>2])?!(+g[s+48>>2]<+g[s+16>>2]):0)j=1;else j=0;if(!(!(+g[s+112+8>>2]>+g[s+8>>2])?!(+g[s+48+8>>2]<+g[s+16+8>>2]):0))j=0;if(!(+g[s+112+4>>2]>+g[s+4>>2])?!(+g[s+48+4>>2]<+g[s+16+4>>2]|j^1):0)break;o=c[(c[b+20>>2]|0)+(d<<2)>>2]|0;Ab[c[c[o>>2]>>2]&255](o);o=c[b+4>>2]|0;Cb[c[(c[o>>2]|0)+60>>2]&127](o,c[(c[b+20>>2]|0)+(d<<2)>>2]|0);c[(c[b+20>>2]|0)+(d<<2)>>2]=0}while(0);d=d+1|0}while((d|0)<(k|0));i=s;return}function md(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,O=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0;c[b>>2]=c[a>>2];c[b+4>>2]=c[a+4>>2];c[b+8>>2]=c[a+8>>2];c[b+12>>2]=c[a+12>>2];c[b+16>>2]=c[a+16>>2];c[b+16+4>>2]=c[a+16+4>>2];c[b+16+8>>2]=c[a+16+8>>2];c[b+16+12>>2]=c[a+16+12>>2];c[b+32>>2]=c[a+32>>2];c[b+32+4>>2]=c[a+32+4>>2];c[b+32+8>>2]=c[a+32+8>>2];c[b+32+12>>2]=c[a+32+12>>2];o=+g[a+20>>2];v=+g[a+40>>2];m=+g[a+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+(K*G+M*I+Q*T);U=A*L+C*O+E*R+(K*B+M*D+Q*W);W=A*B+C*D+E*W+(A*B+C*D+E*W);T=F*G+H*I+J*T+(F*G+H*I+J*T);R=K*L+M*O+Q*R+(K*L+M*O+Q*R);S=S*.5;U=U*.5;V=V*.5;R=R*.5;g[d>>2]=R;g[d+4>>2]=S;g[d+8>>2]=U;g[d+12>>2]=0.0;g[d+16>>2]=S;T=T*.5;g[d+20>>2]=T;g[d+24>>2]=V;g[d+28>>2]=0.0;g[d+32>>2]=U;g[d+36>>2]=V;W=W*.5;g[d+40>>2]=W;g[d+44>>2]=0.0;return}function nd(a,b,f,j){a=a|0;b=b|0;f=f|0;j=j|0;var k=0.0,l=0.0,m=0.0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0;o=i;i=i+80|0;f=Eb[c[(c[a>>2]|0)+28>>2]&127](a)|0;k=+g[a+4>>2];l=+g[a+8>>2];m=+g[a+12>>2];if((f|0)<=0){i=o;return}n=0;do{Yb[c[(c[a>>2]|0)+16>>2]&3](a,o+76|0,o+52|0,o+64|0,o+56|0,o+72|0,o+68|0,o+48|0,o+60|0,n);a:do switch(c[o+64>>2]|0){case 0:{switch(c[o+60>>2]|0){case 2:{if((c[o+48>>2]|0)>0)j=0;else break a;do{r=(c[o+72>>2]|0)+(_(c[o+68>>2]|0,j)|0)|0;t=c[o+76>>2]|0;s=c[o+56>>2]|0;u=t+(_(s,c[r>>2]|0)|0)|0;q=l*+g[u+4>>2];p=m*+g[u+8>>2];g[o>>2]=k*+g[u>>2];g[o+4>>2]=q;g[o+8>>2]=p;g[o+12>>2]=0.0;u=t+(_(s,c[r+4>>2]|0)|0)|0;p=l*+g[u+4>>2];q=m*+g[u+8>>2];g[o+16>>2]=k*+g[u>>2];g[o+20>>2]=p;g[o+24>>2]=q;g[o+28>>2]=0.0;r=t+(_(s,c[r+8>>2]|0)|0)|0;q=l*+g[r+4>>2];p=m*+g[r+8>>2];g[o+32>>2]=k*+g[r>>2];g[o+36>>2]=q;g[o+40>>2]=p;g[o+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,o,n,j);j=j+1|0}while((j|0)<(c[o+48>>2]|0));break}case 3:{if((c[o+48>>2]|0)>0)j=0;else break a;do{t=(c[o+72>>2]|0)+(_(c[o+68>>2]|0,j)|0)|0;s=c[o+76>>2]|0;u=c[o+56>>2]|0;r=s+(_(e[t>>1]|0,u)|0)|0;p=l*+g[r+4>>2];q=m*+g[r+8>>2];g[o>>2]=k*+g[r>>2];g[o+4>>2]=p;g[o+8>>2]=q;g[o+12>>2]=0.0;r=s+(_(e[t+2>>1]|0,u)|0)|0;q=l*+g[r+4>>2];p=m*+g[r+8>>2];g[o+16>>2]=k*+g[r>>2];g[o+20>>2]=q;g[o+24>>2]=p;g[o+28>>2]=0.0;u=s+(_(e[t+4>>1]|0,u)|0)|0;p=l*+g[u+4>>2];q=m*+g[u+8>>2];g[o+32>>2]=k*+g[u>>2];g[o+36>>2]=p;g[o+40>>2]=q;g[o+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,o,n,j);j=j+1|0}while((j|0)<(c[o+48>>2]|0));break}case 5:{if((c[o+48>>2]|0)>0)j=0;else break a;do{t=(c[o+72>>2]|0)+(_(c[o+68>>2]|0,j)|0)|0;s=c[o+76>>2]|0;u=c[o+56>>2]|0;r=s+(_(d[t>>0]|0,u)|0)|0;p=l*+g[r+4>>2];q=m*+g[r+8>>2];g[o>>2]=k*+g[r>>2];g[o+4>>2]=p;g[o+8>>2]=q;g[o+12>>2]=0.0;r=s+(_(d[t+1>>0]|0,u)|0)|0;q=l*+g[r+4>>2];p=m*+g[r+8>>2];g[o+16>>2]=k*+g[r>>2];g[o+20>>2]=q;g[o+24>>2]=p;g[o+28>>2]=0.0;u=s+(_(d[t+2>>0]|0,u)|0)|0;p=l*+g[u+4>>2];q=m*+g[u+8>>2];g[o+32>>2]=k*+g[u>>2];g[o+36>>2]=p;g[o+40>>2]=q;g[o+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,o,n,j);j=j+1|0}while((j|0)<(c[o+48>>2]|0));break}default:break a}break}case 1:{switch(c[o+60>>2]|0){case 2:{if((c[o+48>>2]|0)>0)j=0;else break a;do{u=(c[o+72>>2]|0)+(_(c[o+68>>2]|0,j)|0)|0;s=c[o+76>>2]|0;t=c[o+56>>2]|0;r=s+(_(t,c[u>>2]|0)|0)|0;p=l*+h[r+8>>3];q=m*+h[r+16>>3];g[o>>2]=k*+h[r>>3];g[o+4>>2]=p;g[o+8>>2]=q;g[o+12>>2]=0.0;r=s+(_(t,c[u+4>>2]|0)|0)|0;q=l*+h[r+8>>3];p=m*+h[r+16>>3];g[o+16>>2]=k*+h[r>>3];g[o+20>>2]=q;g[o+24>>2]=p;g[o+28>>2]=0.0;u=s+(_(t,c[u+8>>2]|0)|0)|0;p=l*+h[u+8>>3];q=m*+h[u+16>>3];g[o+32>>2]=k*+h[u>>3];g[o+36>>2]=p;g[o+40>>2]=q;g[o+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,o,n,j);j=j+1|0}while((j|0)<(c[o+48>>2]|0));break}case 3:{if((c[o+48>>2]|0)>0)j=0;else break a;do{t=(c[o+72>>2]|0)+(_(c[o+68>>2]|0,j)|0)|0;s=c[o+76>>2]|0;u=c[o+56>>2]|0;r=s+(_(e[t>>1]|0,u)|0)|0;p=l*+h[r+8>>3];q=m*+h[r+16>>3];g[o>>2]=k*+h[r>>3];g[o+4>>2]=p;g[o+8>>2]=q;g[o+12>>2]=0.0;r=s+(_(e[t+2>>1]|0,u)|0)|0;q=l*+h[r+8>>3];p=m*+h[r+16>>3];g[o+16>>2]=k*+h[r>>3];g[o+20>>2]=q;g[o+24>>2]=p;g[o+28>>2]=0.0;u=s+(_(e[t+4>>1]|0,u)|0)|0;p=l*+h[u+8>>3];q=m*+h[u+16>>3];g[o+32>>2]=k*+h[u>>3];g[o+36>>2]=p;g[o+40>>2]=q;g[o+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,o,n,j);j=j+1|0}while((j|0)<(c[o+48>>2]|0));break}case 5:{if((c[o+48>>2]|0)>0)j=0;else break a;do{t=(c[o+72>>2]|0)+(_(c[o+68>>2]|0,j)|0)|0;s=c[o+76>>2]|0;u=c[o+56>>2]|0;r=s+(_(d[t>>0]|0,u)|0)|0;p=l*+h[r+8>>3];q=m*+h[r+16>>3];g[o>>2]=k*+h[r>>3];g[o+4>>2]=p;g[o+8>>2]=q;g[o+12>>2]=0.0;r=s+(_(d[t+1>>0]|0,u)|0)|0;q=l*+h[r+8>>3];p=m*+h[r+16>>3];g[o+16>>2]=k*+h[r>>3];g[o+20>>2]=q;g[o+24>>2]=p;g[o+28>>2]=0.0;u=s+(_(d[t+2>>0]|0,u)|0)|0;p=l*+h[u+8>>3];q=m*+h[u+16>>3];g[o+32>>2]=k*+h[u>>3];g[o+36>>2]=p;g[o+40>>2]=q;g[o+44>>2]=0.0;mc[c[(c[b>>2]|0)+8>>2]&127](b,o,n,j);j=j+1|0}while((j|0)<(c[o+48>>2]|0));break}default:break a}break}default:{}}while(0);Cb[c[(c[a>>2]|0)+24>>2]&127](a,n);n=n+1|0}while((n|0)!=(f|0));i=o;return}function od(b,d,e,f,h,j){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0,z=0.0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0.0,M=0.0,N=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0,fa=0,ga=0.0;fa=i;i=i+128|0;K=c[b+4>>2]|0;a[K+312>>0]=0;c[K>>2]=0;a[K+356>>0]=1;c[K+292>>2]=1566444395;c[K+296>>2]=1566444395;c[K+300>>2]=1566444395;g[K+304>>2]=0.0;c[K+336>>2]=0;c[K+336+4>>2]=0;c[K+336+8>>2]=0;c[K+336+12>>2]=0;a[K+336+16>>0]=0;a[K+332>>0]=a[K+332>>0]&-16;m=+g[d+48>>2];n=+g[d+52>>2];o=+g[d+56>>2];p=+g[f+48>>2];u=+g[f+52>>2];v=+g[f+56>>2];L=+g[d>>2];M=+g[d+4>>2];N=+g[d+8>>2];P=+g[d+16>>2];Q=+g[d+20>>2];R=+g[d+24>>2];S=+g[d+32>>2];T=+g[d+36>>2];U=+g[d+40>>2];V=+g[f>>2];W=+g[f+4>>2];X=+g[f+8>>2];Y=+g[f+16>>2];Z=+g[f+20>>2];_=+g[f+24>>2];$=+g[f+32>>2];aa=+g[f+36>>2];ba=+g[f+40>>2];ca=+g[e+48>>2]-m-(+g[h+48>>2]-p);da=+g[e+52>>2]-n-(+g[h+52>>2]-u);ea=+g[e+56>>2]-o-(+g[h+56>>2]-v);K=c[b+8>>2]|0;B=c[(c[K>>2]|0)+64>>2]|0;g[fa+96>>2]=L*-ca+P*-da+S*-ea;g[fa+96+4>>2]=M*-ca+Q*-da+T*-ea;g[fa+96+8>>2]=N*-ca+R*-da+U*-ea;g[fa+96+12>>2]=0.0;ic[B&127](fa+112|0,K,fa+96|0);I=+g[fa+112>>2];J=+g[fa+112+4>>2];H=+g[fa+112+8>>2];w=I*+g[d>>2]+J*+g[d+4>>2]+H*+g[d+8>>2]+ +g[d+48>>2];z=I*+g[d+16>>2]+J*+g[d+20>>2]+H*+g[d+24>>2]+ +g[d+52>>2];H=I*+g[d+32>>2]+J*+g[d+36>>2]+H*+g[d+40>>2]+ +g[d+56>>2];K=c[b+12>>2]|0;B=c[(c[K>>2]|0)+64>>2]|0;J=ca*+g[f+4>>2]+da*+g[f+20>>2]+ea*+g[f+36>>2];I=ca*+g[f+8>>2]+da*+g[f+24>>2]+ea*+g[f+40>>2];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.0){l=0;q=24;break}if(C>0.0){n=ca*w+da*z+ea*x;if(n>=-1.4210854715202004e-14){l=0;q=24;break}m=m-C/n;C=(1.0-m)*+g[d+48>>2]+m*+g[e+48>>2];n=(1.0-m)*+g[d+52>>2]+m*+g[e+52>>2];o=(1.0-m)*+g[d+56>>2]+m*+g[e+56>>2];p=(1.0-m)*+g[f+48>>2]+m*+g[h+48>>2];u=(1.0-m)*+g[f+52>>2]+m*+g[h+52>>2];v=(1.0-m)*+g[f+56>>2]+m*+g[h+56>>2];s=q;t=A;r=y;l=B}else C=D;A=c[b+4>>2]|0;B=c[A>>2]|0;if((B|0)>0){w=+g[A+308>>2];y=0;q=0;do{z=E-H-+g[A+4+(q<<4)>>2];D=F-I-+g[A+4+(q<<4)+4>>2];ga=G-J-+g[A+4+(q<<4)+8>>2];y=y|z*z+D*D+ga*ga<=w;q=q+1|0}while((q|0)!=(B|0))}else y=0;if((+g[A+304>>2]==0.0?G-J==+g[A+300>>2]:0)?F-I==+g[A+296>>2]:0)q=E-H==+g[A+292>>2];else q=0;if(!(y|q)){g[A+292>>2]=E-H;g[A+296>>2]=F-I;g[A+300>>2]=G-J;g[A+304>>2]=0.0;a[A+356>>0]=1;g[A+4+(B<<4)>>2]=E-H;g[A+4+(B<<4)+4>>2]=F-I;g[A+4+(B<<4)+8>>2]=G-J;g[A+4+(B<<4)+12>>2]=0.0;B=c[A>>2]|0;g[A+84+(B<<4)>>2]=E;g[A+84+(B<<4)+4>>2]=F;g[A+84+(B<<4)+8>>2]=G;g[A+84+(B<<4)+12>>2]=0.0;B=c[A>>2]|0;g[A+164+(B<<4)>>2]=H;g[A+164+(B<<4)+4>>2]=I;g[A+164+(B<<4)+8>>2]=J;g[A+164+(B<<4)+12>>2]=0.0;c[A>>2]=(c[A>>2]|0)+1;A=c[b+4>>2]|0}B=Ec(A)|0;w=+g[A+276>>2];z=+g[A+280>>2];x=+g[A+284>>2];if(!B)break a;if(!(w*w+z*z+x*x>9.999999747378752e-05))break a;else{D=C;A=c[A+288>>2]|0}}if((q|0)==24){i=fa;return l|0}}else{m=0.0;s=0;t=0;r=0;l=0}while(0);g[j+164>>2]=m;m=(c[k>>2]=s,+g[k>>2]);n=(c[k>>2]=r,+g[k>>2]);p=(c[k>>2]=l,+g[k>>2]);if(!(m*m+n*n+p*p>=1.4210854715202004e-14)){c[j+132>>2]=0;c[j+132+4>>2]=0;c[j+132+8>>2]=0;c[j+132+12>>2]=0;o=0.0;n=0.0;m=0.0}else{ga=1.0/+O(+(m*m+n*n+p*p));g[j+132>>2]=m*ga;g[j+136>>2]=n*ga;g[j+140>>2]=p*ga;c[j+144>>2]=t;o=m*ga;n=n*ga;m=p*ga}if(ca*o+da*n+ea*m>=-+g[j+172>>2]){b=0;i=fa;return b|0}b=c[b+4>>2]|0;Ec(b)|0;Bp(j+148|0,b+260|0,16)|0;b=1;i=fa;return b|0}function pd(d,e,f,h,j){d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var k=0.0,l=0.0,m=0,n=0,o=0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0;A=i;i=i+160|0;a[d+60>>0]=f&1;if(f){r=+g[h>>2]+-1.0;u=+g[h+4>>2]+-1.0;s=+g[h+8>>2]+-1.0;g[d+4>>2]=r;g[d+8>>2]=u;g[d+12>>2]=s;g[d+16>>2]=0.0;v=+g[j>>2]+1.0;x=+g[j+4>>2]+1.0;y=+g[j+8>>2]+1.0;g[d+20>>2]=v;g[d+24>>2]=x;g[d+28>>2]=y;g[d+32>>2]=0.0;g[d+36>>2]=65533.0/(v-r);g[d+40>>2]=65533.0/(x-u);g[d+44>>2]=65533.0/(y-s);g[d+48>>2]=0.0;a[d+60>>0]=1;k=r+ +(~~((r-r)*(65533.0/(v-r)))&65534)/(65533.0/(v-r))+-1.0;l=u+ +(~~((u-u)*(65533.0/(x-u)))&65534)/(65533.0/(x-u))+-1.0;p=s+ +(~~((s-s)*(65533.0/(y-s)))&65534)/(65533.0/(y-s))+-1.0;if(k>2]=k;z=k}else z=r;if(l>2]=l;w=l}else w=u;if(p>2]=p;t=p}else t=s;p=z+ +((~~((v-z)*(65533.0/(v-r))+1.0)&65535|1)&65535)/(65533.0/(v-r))+1.0;l=w+ +((~~((x-w)*(65533.0/(x-u))+1.0)&65535|1)&65535)/(65533.0/(x-u))+1.0;k=t+ +((~~((y-t)*(65533.0/(y-s))+1.0)&65535|1)&65535)/(65533.0/(y-s))+1.0;if(v>2]=p;else p=v;if(x>2]=l;else l=x;if(y>2]=k;else k=y;g[d+36>>2]=65533.0/(p-z);g[d+40>>2]=65533.0/(l-w);g[d+44>>2]=65533.0/(k-t);g[d+48>>2]=0.0;c[A+144>>2]=8020;c[A+144+4>>2]=d+104;c[A+144+8>>2]=d;mc[c[(c[e>>2]|0)+8>>2]&127](e,A+144|0,d+4|0,d+20|0);f=c[d+108>>2]|0;c[A+128>>2]=0;c[A+128+4>>2]=0;c[A+128+8>>2]=0;c[A+128+12>>2]=0;m=c[d+128>>2]|0;if((m|0)<(f<<1|0)){if((c[d+132>>2]|0)<(f<<1|0)){if(!f){h=0;j=m}else{c[6435]=(c[6435]|0)+1;h=yc(f<<5|19)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[d+128>>2]|0}if((j|0)>0){e=0;do{q=h+(e<<4)|0;o=(c[d+136>>2]|0)+(e<<4)|0;c[q>>2]=c[o>>2];c[q+4>>2]=c[o+4>>2];c[q+8>>2]=c[o+8>>2];c[q+12>>2]=c[o+12>>2];e=e+1|0}while((e|0)!=(j|0))}j=c[d+136>>2]|0;if(j|0){if(a[d+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[d+136>>2]=0}a[d+140>>0]=1;c[d+136>>2]=h;c[d+132>>2]=f<<1;j=d+136|0}else j=d+136|0;h=m;do{q=(c[j>>2]|0)+(h<<4)|0;c[q>>2]=c[A+128>>2];c[q+4>>2]=c[A+128+4>>2];c[q+8>>2]=c[A+128+8>>2];c[q+12>>2]=c[A+128+12>>2];h=h+1|0}while((h|0)!=(f<<1|0))}c[d+128>>2]=f<<1}else{c[A+144>>2]=8040;c[A+144+4>>2]=d+64;c[A+112>>2]=-581039253;c[A+112+4>>2]=-581039253;c[A+112+8>>2]=-581039253;g[A+112+12>>2]=0.0;c[A+96>>2]=1566444395;c[A+96+4>>2]=1566444395;c[A+96+8>>2]=1566444395;g[A+96+12>>2]=0.0;mc[c[(c[e>>2]|0)+8>>2]&127](e,A+144|0,A+112|0,A+96|0);f=c[d+68>>2]|0;m=A+32|0;o=m+64|0;do{c[m>>2]=0;m=m+4|0}while((m|0)<(o|0));q=c[d+88>>2]|0;if((q|0)<(f<<1|0)){if((c[d+92>>2]|0)<(f<<1|0)){if(!f){h=0;j=q}else{c[6435]=(c[6435]|0)+1;h=yc(f<<7|19)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[d+88>>2]|0}if((j|0)>0){e=0;do{m=h+(e<<6)|0;n=(c[d+96>>2]|0)+(e<<6)|0;o=m+64|0;do{c[m>>2]=c[n>>2];m=m+4|0;n=n+4|0}while((m|0)<(o|0));e=e+1|0}while((e|0)!=(j|0))}j=c[d+96>>2]|0;if(j|0){if(a[d+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[d+96>>2]=0}a[d+100>>0]=1;c[d+96>>2]=h;c[d+92>>2]=f<<1;j=d+96|0}else j=d+96|0;h=q;do{m=(c[j>>2]|0)+(h<<6)|0;n=A+32|0;o=m+64|0;do{c[m>>2]=c[n>>2];m=m+4|0;n=n+4|0}while((m|0)<(o|0));h=h+1|0}while((h|0)!=(f<<1|0))}c[d+88>>2]=f<<1}c[d+56>>2]=0;Lc(d,0,f);if(a[d+60>>0]|0?(c[d+152>>2]|0)==0:0){if(!(c[d+156>>2]|0)){c[6435]=(c[6435]|0)+1;f=yc(51)|0;if(!f)e=0;else{c[(f+4+15&-16)+-4>>2]=f;e=f+4+15&-16}f=c[d+152>>2]|0;if((f|0)>0){h=0;do{q=e+(h<<5)|0;o=(c[d+160>>2]|0)+(h<<5)|0;c[q>>2]=c[o>>2];c[q+4>>2]=c[o+4>>2];c[q+8>>2]=c[o+8>>2];c[q+12>>2]=c[o+12>>2];c[q+16>>2]=c[o+16>>2];c[q+20>>2]=c[o+20>>2];c[q+24>>2]=c[o+24>>2];c[q+28>>2]=c[o+28>>2];h=h+1|0}while((h|0)!=(f|0))}f=c[d+160>>2]|0;if(f|0){if(a[d+164>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[d+160>>2]=0}a[d+164>>0]=1;c[d+160>>2]=e;c[d+156>>2]=1;h=d+160|0;j=(c[d+152>>2]|0)+1|0;f=e}else{h=d+160|0;j=1;f=c[d+160>>2]|0}c[d+152>>2]=j;c[f>>2]=c[A>>2];c[f+4>>2]=c[A+4>>2];c[f+8>>2]=c[A+8>>2];c[f+12>>2]=c[A+12>>2];c[f+16>>2]=c[A+16>>2];c[f+20>>2]=c[A+20>>2];c[f+24>>2]=c[A+24>>2];c[f+28>>2]=c[A+28>>2];q=c[h>>2]|0;o=c[d+136>>2]|0;b[q>>1]=b[o>>1]|0;b[q+2>>1]=b[o+2>>1]|0;b[q+4>>1]=b[o+4>>1]|0;b[q+6>>1]=b[o+6>>1]|0;b[q+8>>1]=b[o+8>>1]|0;b[q+10>>1]=b[o+10>>1]|0;c[q+12>>2]=0;o=c[o+12>>2]|0;c[q+16>>2]=(o|0)>-1?1:0-o|0}c[d+168>>2]=c[d+152>>2];f=c[d+116>>2]|0;if(f|0){if(a[d+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[d+116>>2]=0}a[d+120>>0]=1;c[d+116>>2]=0;c[d+108>>2]=0;c[d+112>>2]=0;f=c[d+76>>2]|0;if(!f){a[d+80>>0]=1;c[d+76>>2]=0;c[d+68>>2]=0;d=d+72|0;c[d>>2]=0;i=A;return}if(a[d+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[d+76>>2]=0;a[d+80>>0]=1;c[d+76>>2]=0;c[d+68>>2]=0;d=d+72|0;c[d>>2]=0;i=A;return}function qd(b,d,e,f,h,i,j,l,m,n,o){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;l=l|0;m=+m;n=+n;o=+o;var p=0,q=0,r=0,s=0.0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0,N=0,O=0.0,P=0.0,Q=0.0,R=0.0;N=c[b+68>>2]|0;if((N|0)==(c[b+72>>2]|0)?(t=N|0?N<<1:1,(N|0)<(t|0)):0){if(!t){p=0;q=N}else{c[6435]=(c[6435]|0)+1;p=yc((t*152|3)+16|0)|0;if(!p)p=0;else{c[(p+4+15&-16)+-4>>2]=p;p=p+4+15&-16}q=c[b+68>>2]|0}if((q|0)>0){r=0;do{_m(p+(r*152|0)|0,(c[b+76>>2]|0)+(r*152|0)|0,152)|0;r=r+1|0}while((r|0)!=(q|0))}q=c[b+76>>2]|0;if(q|0){if(a[b+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}c[b+76>>2]=0}a[b+80>>0]=1;c[b+76>>2]=p;c[b+72>>2]=t;p=c[b+68>>2]|0}else p=N;c[b+68>>2]=p+1;M=c[b+76>>2]|0;c[M+(N*152|0)+140>>2]=h;r=c[b+16>>2]|0;p=c[r+(e*244|0)+240>>2]|0;t=c[r+(f*244|0)+240>>2]|0;c[M+(N*152|0)+144>>2]=e;c[M+(N*152|0)+148>>2]=f;q=c[i+84>>2]|0;c[M+(N*152|0)+104>>2]=q;c[M+(N*152|0)+132>>2]=0;g[M+(N*152|0)+100>>2]=0.0;g[M+(N*152|0)+96>>2]=0.0;L=(c[k>>2]=q,+g[k>>2]);if(p|0){c[M+(N*152|0)+16>>2]=c[d>>2];c[M+(N*152|0)+16+4>>2]=c[d+4>>2];c[M+(N*152|0)+16+8>>2]=c[d+8>>2];c[M+(N*152|0)+16+12>>2]=c[d+12>>2];K=+g[j+4>>2];D=+g[M+(N*152|0)+24>>2];H=+g[j+8>>2];I=+g[M+(N*152|0)+20>>2];E=+g[M+(N*152|0)+16>>2];J=+g[j>>2];g[M+(N*152|0)>>2]=K*D-H*I;g[M+(N*152|0)+4>>2]=H*E-D*J;g[M+(N*152|0)+8>>2]=I*J-K*E;g[M+(N*152|0)+12>>2]=0.0;v=((K*D-H*I)*+g[p+264>>2]+(H*E-D*J)*+g[p+268>>2]+(I*J-K*E)*+g[p+272>>2])*+g[p+544>>2];s=((K*D-H*I)*+g[p+280>>2]+(H*E-D*J)*+g[p+284>>2]+(I*J-K*E)*+g[p+288>>2])*+g[p+548>>2];u=((K*D-H*I)*+g[p+296>>2]+(H*E-D*J)*+g[p+300>>2]+(I*J-K*E)*+g[p+304>>2])*+g[p+552>>2];g[M+(N*152|0)+64>>2]=v;g[M+(N*152|0)+68>>2]=s;g[M+(N*152|0)+72>>2]=u;g[M+(N*152|0)+76>>2]=0.0;z=E;A=I;B=D;C=K*D-H*I;D=H*E-D*J;E=I*J-K*E}else{c[M+(N*152|0)+64>>2]=0;c[M+(N*152|0)+64+4>>2]=0;c[M+(N*152|0)+64+8>>2]=0;c[M+(N*152|0)+64+12>>2]=0;c[M+(N*152|0)>>2]=0;c[M+(N*152|0)+4>>2]=0;c[M+(N*152|0)+8>>2]=0;c[M+(N*152|0)+12>>2]=0;c[M+(N*152|0)+16>>2]=0;c[M+(N*152|0)+20>>2]=0;c[M+(N*152|0)+24>>2]=0;c[M+(N*152|0)+28>>2]=0;s=0.0;u=0.0;v=0.0;z=0.0;A=0.0;B=0.0;C=0.0;D=0.0;E=0.0}if(t|0){K=-+g[d>>2];P=-+g[d+4>>2];J=-+g[d+8>>2];g[M+(N*152|0)+48>>2]=K;g[M+(N*152|0)+52>>2]=P;g[M+(N*152|0)+56>>2]=J;g[M+(N*152|0)+60>>2]=0.0;O=+g[l+4>>2];R=+g[l+8>>2];Q=+g[l>>2];g[M+(N*152|0)+32>>2]=O*J-R*P;g[M+(N*152|0)+36>>2]=R*K-Q*J;g[M+(N*152|0)+40>>2]=Q*P-O*K;g[M+(N*152|0)+44>>2]=0.0;w=((O*J-R*P)*+g[t+264>>2]+(R*K-Q*J)*+g[t+268>>2]+(Q*P-O*K)*+g[t+272>>2])*+g[t+544>>2];x=((O*J-R*P)*+g[t+280>>2]+(R*K-Q*J)*+g[t+284>>2]+(Q*P-O*K)*+g[t+288>>2])*+g[t+548>>2];y=((O*J-R*P)*+g[t+296>>2]+(R*K-Q*J)*+g[t+300>>2]+(Q*P-O*K)*+g[t+304>>2])*+g[t+552>>2];g[M+(N*152|0)+80>>2]=w;g[M+(N*152|0)+84>>2]=x;g[M+(N*152|0)+88>>2]=y;g[M+(N*152|0)+92>>2]=0.0;F=K;G=P;H=J;I=O*J-R*P;J=R*K-Q*J;K=Q*P-O*K}else{c[M+(N*152|0)+80>>2]=0;c[M+(N*152|0)+80+4>>2]=0;c[M+(N*152|0)+80+8>>2]=0;c[M+(N*152|0)+80+12>>2]=0;c[M+(N*152|0)+32>>2]=0;c[M+(N*152|0)+32+4>>2]=0;c[M+(N*152|0)+32+8>>2]=0;c[M+(N*152|0)+32+12>>2]=0;c[M+(N*152|0)+32+16>>2]=0;c[M+(N*152|0)+32+20>>2]=0;c[M+(N*152|0)+32+24>>2]=0;c[M+(N*152|0)+32+28>>2]=0;w=0.0;x=0.0;y=0.0;F=0.0;G=0.0;H=0.0;I=0.0;J=0.0;K=0.0}if(p|0){P=+g[j+8>>2];Q=+g[j+4>>2];R=+g[j>>2];u=+g[p+344>>2]+((s*P-u*Q)*+g[d>>2]+(u*R-P*v)*+g[d+4>>2]+(Q*v-s*R)*+g[d+8>>2])}else u=0.0;if(t|0){Q=-w;s=-x;y=-y;O=+g[l+8>>2];P=+g[l+4>>2];R=+g[l>>2];s=+g[t+344>>2]+((O*s-P*y)*+g[d>>2]+(R*y-O*Q)*+g[d+4>>2]+(P*Q-R*s)*+g[d+8>>2])}else s=0.0;x=m/(u+s);g[M+(N*152|0)+108>>2]=x;if(p|0){u=+g[r+(e*244|0)+192>>2];v=+g[r+(e*244|0)+196>>2];w=+g[r+(e*244|0)+200>>2];s=(+g[r+(e*244|0)+176>>2]+ +g[r+(e*244|0)+208>>2])*z+(+g[r+(e*244|0)+180>>2]+ +g[r+(e*244|0)+212>>2])*A+(+g[r+(e*244|0)+184>>2]+ +g[r+(e*244|0)+216>>2])*B}else{u=0.0;v=0.0;w=0.0;s=z*0.0+A*0.0+B*0.0}s=s+(u*C+v*D+w*E);if(t|0){O=+g[r+(f*244|0)+192>>2];P=+g[r+(f*244|0)+196>>2];R=+g[r+(f*244|0)+200>>2];Q=(+g[r+(f*244|0)+176>>2]+ +g[r+(f*244|0)+208>>2])*F+(+g[r+(f*244|0)+180>>2]+ +g[r+(f*244|0)+212>>2])*G+(+g[r+(f*244|0)+184>>2]+ +g[r+(f*244|0)+216>>2])*H;O=O*I;P=P*J;P=O+P;R=R*K;R=P+R;R=Q+R;R=s+R;R=n-R;R=x*R;f=M+(N*152|0)+112|0;g[f>>2]=R;f=M+(N*152|0)+116|0;g[f>>2]=o;R=-L;f=M+(N*152|0)+120|0;g[f>>2]=R;f=M+(N*152|0)+124|0;c[f>>2]=q;return}else{O=0.0;P=0.0;R=0.0;Q=F*0.0+G*0.0+H*0.0;O=O*I;P=P*J;P=O+P;R=R*K;R=P+R;R=Q+R;R=s+R;R=n-R;R=x*R;f=M+(N*152|0)+112|0;g[f>>2]=R;f=M+(N*152|0)+116|0;g[f>>2]=o;R=-L;f=M+(N*152|0)+120|0;g[f>>2]=R;f=M+(N*152|0)+124|0;c[f>>2]=q;return}}function rd(b,d){b=b|0;d=+d;var e=0,f=0,h=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0;C=i;i=i+64|0;e=c[b+136>>2]|0;if((e|0)>0){f=0;do{Ae(c[b+116>>2]|0,c[b+144>>2]|0,f,0);f=f+1|0;e=c[b+136>>2]|0}while((f|0)<(e|0))}f=c[b+116>>2]|0;t=+g[f+312>>2];u=+g[f+316>>2];h=+g[f+320>>2];h=+O(+(t*t+u*u+h*h))*3.5999999046325684;g[b+112>>2]=h;B=c[b+128>>2]|0;if(+g[f+4+(B<<2)>>2]*+g[f+312>>2]+ +g[f+20+(B<<2)>>2]*+g[f+316>>2]+ +g[f+36+(B<<2)>>2]*+g[f+320>>2]<0.0)g[b+112>>2]=-h;if((e|0)>0){B=0;do{A=c[b+144>>2]|0;p=A+(B*284|0)|0;Tg(f,p,0);o=A+(B*284|0)+204|0;e=A+(B*284|0)+212|0;h=+g[o>>2]+ +g[e>>2];q=A+(B*284|0)+52|0;v=A+(B*284|0)+56|0;w=A+(B*284|0)+60|0;D=A+(B*284|0)+36|0;x=A+(B*284|0)+16|0;t=h*+g[v>>2]+ +g[A+(B*284|0)+40>>2];u=h*+g[w>>2]+ +g[A+(B*284|0)+44>>2];g[A+(B*284|0)+16>>2]=+g[q>>2]*h+ +g[D>>2];y=A+(B*284|0)+20|0;g[y>>2]=t;z=A+(B*284|0)+24|0;g[z>>2]=u;g[A+(B*284|0)+28>>2]=0.0;g[C+32>>2]=-1.0;f=c[b+100>>2]|0;D=Ib[c[(c[f>>2]|0)+8>>2]&31](f,D,x,C)|0;f=A+(B*284|0)+88|0;c[f>>2]=0;do if(D){h=h*+g[C+32>>2];c[p>>2]=c[C+16>>2];c[p+4>>2]=c[C+16+4>>2];c[p+8>>2]=c[C+16+8>>2];c[p+12>>2]=c[C+16+12>>2];a[A+(B*284|0)+84>>0]=1;if((a[22552]|0)==0?Wa(22552)|0:0){c[C+40>>2]=0;c[C+40+4>>2]=0;c[C+40+8>>2]=0;c[C+40+12>>2]=0;og(23888,0.0,0,0,C+40|0);_a(22552)}c[6023]=c[6023]|1;g[6058]=0.0;j=+g[6068]*0.0;k=+g[6069]*0.0;g[6063]=+g[6067]*0.0;g[6064]=j;g[6065]=k;g[6066]=0.0;c[6071]=0;c[6072]=0;c[6073]=0;c[6074]=0;k=+g[6060]*0.0;j=+g[6061]*0.0;g[6112]=+g[6059]*0.0;g[6113]=k;g[6114]=j;g[6115]=0.0;c[f>>2]=23888;h=h-+g[e>>2];e=A+(B*284|0)+32|0;g[e>>2]=h;j=+g[o>>2];k=+g[A+(B*284|0)+208>>2]*.009999999776482582;if(h>2]=j-k;h=j-k}if(h>j+k)g[e>>2]=j+k;c[x>>2]=c[C>>2];c[x+4>>2]=c[C+4>>2];c[x+8>>2]=c[C+8>>2];c[x+12>>2]=c[C+12>>2];s=+g[p>>2];t=+g[A+(B*284|0)+4>>2];u=+g[A+(B*284|0)+8>>2];r=s*+g[q>>2]+t*+g[v>>2]+u*+g[w>>2];e=c[b+116>>2]|0;n=+g[x>>2]-+g[e+52>>2];m=+g[y>>2]-+g[e+56>>2];h=+g[z>>2]-+g[e+60>>2];j=+g[e+332>>2];k=+g[e+336>>2];l=+g[e+328>>2];if(!(r>=-.10000000149011612)){g[A+(B*284|0)+272>>2]=-1.0/r*(s*(j*h-m*k+ +g[e+312>>2])+t*(n*k-h*l+ +g[e+316>>2])+u*(m*l-n*j+ +g[e+320>>2]));g[A+(B*284|0)+268>>2]=-1.0/r;break}else{g[A+(B*284|0)+272>>2]=0.0;g[A+(B*284|0)+268>>2]=10.0;break}}else{c[A+(B*284|0)+32>>2]=c[o>>2];g[A+(B*284|0)+272>>2]=0.0;t=-+g[v>>2];u=-+g[w>>2];g[p>>2]=-+g[q>>2];g[A+(B*284|0)+4>>2]=t;g[A+(B*284|0)+8>>2]=u;g[A+(B*284|0)+12>>2]=0.0;g[A+(B*284|0)+268>>2]=1.0}while(0);B=B+1|0;e=c[b+136>>2]|0;f=c[b+116>>2]|0}while((B|0)<(e|0));j=1.0/+g[f+344>>2];if((e|0)>0){f=0;do{e=c[b+144>>2]|0;if(!(a[e+(f*284|0)+84>>0]|0))h=0.0;else{h=+g[e+(f*284|0)+272>>2];h=j*(+g[e+(f*284|0)+216>>2]*(+g[e+(f*284|0)+204>>2]-+g[e+(f*284|0)+32>>2])*+g[e+(f*284|0)+268>>2]-h*+g[(h<0.0?e+(f*284|0)+220|0:e+(f*284|0)+224|0)>>2]);h=h<0.0?0.0:h}g[e+(f*284|0)+276>>2]=h;f=f+1|0;e=c[b+136>>2]|0}while((f|0)<(e|0));if((e|0)>0){e=0;do{B=c[b+144>>2]|0;s=+g[B+(e*284|0)+276>>2];u=+g[B+(e*284|0)+248>>2];s=s>u?u:s;u=s*+g[B+(e*284|0)+4>>2]*d;t=s*+g[B+(e*284|0)+8>>2]*d;g[C+40>>2]=+g[B+(e*284|0)>>2]*s*d;g[C+40+4>>2]=u;g[C+40+8>>2]=t;g[C+40+12>>2]=0.0;D=c[b+116>>2]|0;t=+g[B+(e*284|0)+20>>2]-+g[D+56>>2];u=+g[B+(e*284|0)+24>>2]-+g[D+60>>2];g[C>>2]=+g[B+(e*284|0)+16>>2]-+g[D+52>>2];g[C+4>>2]=t;g[C+8>>2]=u;g[C+12>>2]=0.0;gj(D,C+40|0,C);e=e+1|0}while((e|0)<(c[b+136>>2]|0))}}}zb[c[(c[b>>2]|0)+20>>2]&31](b,d);f=c[b+136>>2]|0;if((f|0)<=0){i=C;return}o=c[b+144>>2]|0;p=c[b+116>>2]|0;q=0;do{h=+g[o+(q*284|0)+36>>2]-+g[p+52>>2];j=+g[o+(q*284|0)+40>>2]-+g[p+56>>2];k=+g[o+(q*284|0)+44>>2]-+g[p+60>>2];l=+g[p+332>>2];m=+g[p+336>>2];n=+g[p+328>>2];if(!(a[o+(q*284|0)+84>>0]|0)){e=o+(q*284|0)+240|0;h=+g[e>>2];D=o+(q*284|0)+236|0;g[D>>2]=h+ +g[D>>2]}else{e=c[b+128>>2]|0;F=+g[p+4+(e<<2)>>2];r=+g[p+20+(e<<2)>>2];t=+g[p+36+(e<<2)>>2];E=+g[o+(q*284|0)>>2];s=+g[o+(q*284|0)+4>>2];u=+g[o+(q*284|0)+8>>2];h=((j*n-h*l+ +g[p+320>>2])*(t-u*(F*E+r*s+t*u))+((l*k-j*m+ +g[p+312>>2])*(F-E*(F*E+r*s+t*u))+(h*m-k*n+ +g[p+316>>2])*(r-s*(F*E+r*s+t*u))))*d/+g[o+(q*284|0)+212>>2];e=o+(q*284|0)+240|0;g[e>>2]=h;D=o+(q*284|0)+236|0;g[D>>2]=+g[D>>2]+h}g[e>>2]=h*.9900000095367432;q=q+1|0}while((q|0)!=(f|0));i=C;return}function sd(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0;C=+g[b+48>>2];i=+g[d>>2];D=+g[b+64>>2];j=+g[d+4>>2];E=+g[b+80>>2];p=+g[d+8>>2];s=+g[b+52>>2];r=+g[b+68>>2];q=+g[b+84>>2];w=+g[b+56>>2];y=+g[b+72>>2];z=+g[b+88>>2];v=+g[d+16>>2];u=+g[d+20>>2];t=+g[d+24>>2];x=+g[d+32>>2];F=+g[d+36>>2];G=+g[d+40>>2];k=+g[b+96>>2];h=+g[b+100>>2];B=+g[b+104>>2];A=+g[d+48>>2]+(i*k+j*h+p*B);f=v*k+u*h+t*B+ +g[d+52>>2];B=x*k+F*h+G*B+ +g[d+56>>2];g[b+1064>>2]=C*i+D*j+E*p;g[b+1068>>2]=i*s+j*r+p*q;g[b+1072>>2]=i*w+j*y+p*z;g[b+1076>>2]=0.0;g[b+1080>>2]=C*v+D*u+E*t;g[b+1084>>2]=s*v+r*u+q*t;g[b+1088>>2]=w*v+y*u+z*t;g[b+1092>>2]=0.0;g[b+1096>>2]=C*x+D*F+E*G;g[b+1100>>2]=s*x+r*F+q*G;g[b+1104>>2]=w*x+y*F+z*G;g[b+1108>>2]=0.0;g[b+1112>>2]=A;g[b+1116>>2]=f;g[b+1120>>2]=B;g[b+1124>>2]=0.0;B=+g[b+112>>2];f=+g[e>>2];A=+g[b+128>>2];G=+g[e+4>>2];z=+g[b+144>>2];F=+g[e+8>>2];y=+g[b+116>>2];x=+g[b+132>>2];w=+g[b+148>>2];q=+g[b+120>>2];r=+g[b+136>>2];s=+g[b+152>>2];E=+g[e+16>>2];D=+g[e+20>>2];C=+g[e+24>>2];t=+g[e+32>>2];u=+g[e+36>>2];v=+g[e+40>>2];p=+g[b+160>>2];j=+g[b+164>>2];i=+g[b+168>>2];h=+g[e+48>>2]+(f*p+G*j+F*i);k=E*p+D*j+C*i+ +g[e+52>>2];i=t*p+u*j+v*i+ +g[e+56>>2];g[b+1128>>2]=B*f+A*G+z*F;g[b+1132>>2]=f*y+G*x+F*w;g[b+1136>>2]=f*q+G*r+F*s;g[b+1140>>2]=0.0;g[b+1144>>2]=B*E+A*D+z*C;g[b+1148>>2]=y*E+x*D+w*C;g[b+1152>>2]=q*E+r*D+s*C;g[b+1156>>2]=0.0;g[b+1160>>2]=B*t+A*u+z*v;g[b+1164>>2]=y*t+x*u+w*v;g[b+1168>>2]=q*t+r*u+s*v;g[b+1172>>2]=0.0;g[b+1176>>2]=h;g[b+1180>>2]=k;g[b+1184>>2]=i;g[b+1188>>2]=0.0;h=h-+g[b+1112>>2];k=k-+g[b+1116>>2];i=i-+g[b+1120>>2];w=+g[b+1084>>2];x=+g[b+1104>>2];y=+g[b+1088>>2];z=+g[b+1100>>2];A=+g[b+1096>>2];B=+g[b+1080>>2];C=+g[b+1064>>2];D=+g[b+1068>>2];E=+g[b+1072>>2];F=1.0/((w*x-y*z)*C+D*(y*A-x*B)+(z*B-w*A)*E);G=(z*B-w*A)*F;f=i*(y*D-w*E)*F+(h*(w*x-y*z)*F+k*(z*E-x*D)*F);j=i*(B*E-y*C)*F+(h*(y*A-x*B)*F+k*(x*C-A*E)*F);k=i*(w*C-B*D)*F+(h*G+k*(A*D-z*C)*F);g[b+1256>>2]=f;g[b+1260>>2]=j;g[b+1264>>2]=k;g[b+1268>>2]=0.0;g[b+840>>2]=f;h=+g[b+680>>2];i=+g[b+696>>2];do if(!(h>i)){if(h>f){c[b+856>>2]=2;g[b+824>>2]=f-h;break}if(i>2]=1;g[b+824>>2]=f-i;break}else{c[b+856>>2]=0;g[b+824>>2]=0.0;break}}else{c[b+856>>2]=0;g[b+824>>2]=0.0}while(0);g[b+844>>2]=j;f=+g[b+684>>2];h=+g[b+700>>2];do if(!(f>h)){if(f>j){c[b+860>>2]=2;g[b+828>>2]=j-f;break}if(h>2]=1;g[b+828>>2]=j-h;break}else{c[b+860>>2]=0;g[b+828>>2]=0.0;break}}else{c[b+860>>2]=0;g[b+828>>2]=0.0}while(0);g[b+848>>2]=k;f=+g[b+688>>2];h=+g[b+704>>2];do if(!(f>h)){if(f>k){c[b+864>>2]=2;g[b+832>>2]=k-f;break}if(h>2]=1;g[b+832>>2]=k-h;break}else{c[b+864>>2]=0;g[b+832>>2]=0.0;break}}else{c[b+864>>2]=0;g[b+832>>2]=0.0}while(0);h=+g[b+1128>>2];i=+g[b+1144>>2];j=+g[b+1160>>2];k=+g[b+1132>>2];l=+g[b+1148>>2];m=+g[b+1164>>2];n=(w*x-y*z)*F*k+(z*E-x*D)*F*l+(y*D-w*E)*F*m;o=k*(y*A-x*B)*F+(x*C-A*E)*F*l+(B*E-y*C)*F*m;p=j*(w*C-B*D)*F+(h*G+i*(A*D-z*C)*F);f=G*+g[b+1136>>2]+(A*D-z*C)*F*+g[b+1152>>2]+(w*C-B*D)*F*(q*t+r*u+s*v);do if(p<1.0)if(p>-1.0){g[b+1192>>2]=+W(+-(k*G+(A*D-z*C)*F*l+(w*C-B*D)*F*m),+f);G=p<-1.0?-1.0:p;g[b+1196>>2]=+U(+(G>1.0?1.0:G));g[b+1200>>2]=+W(+-(j*(B*E-y*C)*F+(h*(y*A-x*B)*F+i*(x*C-A*E)*F)),+(j*(y*D-w*E)*F+(h*(w*x-y*z)*F+i*(z*E-x*D)*F)));break}else{g[b+1192>>2]=-+W(+n,+o);g[b+1196>>2]=-1.5707963705062866;g[b+1200>>2]=0.0;break}else{g[b+1192>>2]=+W(+n,+o);g[b+1196>>2]=1.5707963705062866;g[b+1200>>2]=0.0}while(0);g[b+1236>>2]=0.0;z=x*(h*x-j*E)-y*(i*E-h*y);A=E*(i*E-h*y)-x*(j*y-i*x);B=y*(j*y-i*x)-E*(h*x-j*E);g[b+1220>>2]=0.0;C=i*(i*E-h*y)-j*(h*x-j*E);D=j*(j*y-i*x)-h*(i*E-h*y);F=h*(h*x-j*E)-i*(j*y-i*x);g[b+1252>>2]=0.0;G=1.0/+O(+(z*z+A*A+B*B));g[b+1208>>2]=z*G;g[b+1212>>2]=A*G;g[b+1216>>2]=B*G;G=1.0/+O(+((j*y-i*x)*(j*y-i*x)+(h*x-j*E)*(h*x-j*E)+(i*E-h*y)*(i*E-h*y)));g[b+1224>>2]=(j*y-i*x)*G;g[b+1228>>2]=(h*x-j*E)*G;g[b+1232>>2]=(i*E-h*y)*G;G=1.0/+O(+(C*C+D*D+F*F));g[b+1240>>2]=C*G;g[b+1244>>2]=D*G;g[b+1248>>2]=F*G;if(!(a[b+1301>>0]|0))return;F=+g[(c[b+28>>2]|0)+344>>2];G=+g[(c[b+32>>2]|0)+344>>2];a[b+1280>>0]=(F<1.1920928955078125e-07|G<1.1920928955078125e-07)&1;G=F+G>0.0?G/(F+G):.5;g[b+1272>>2]=G;g[b+1276>>2]=1.0-G;return}function td(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;x=i;i=i+80|0;e=c[b+8>>2]|0;if((e|0)>0){g=0;do{f=c[(c[b+16>>2]|0)+(g<<2)>>2]|0;if((c[f+236>>2]|0)==1){Cb[c[(c[f>>2]|0)+24>>2]&127](f,d);e=c[b+8>>2]|0}g=g+1|0}while((g|0)<(e|0))}a[x+16>>0]=1;c[x+12>>2]=0;c[x+4>>2]=0;c[x+8>>2]=0;a[x+36>>0]=1;c[x+32>>2]=0;c[x+24>>2]=0;c[x+28>>2]=0;a[x+56>>0]=1;c[x+52>>2]=0;c[x+44>>2]=0;c[x+48>>2]=0;a[x+76>>0]=1;c[x+72>>2]=0;c[x+64>>2]=0;c[x+68>>2]=0;if((e|0)<=0){pj(x);i=x;return}j=0;k=0;g=0;f=0;r=0;while(1){q=c[(c[(c[b+16>>2]|0)+(r<<2)>>2]|0)+192>>2]|0;p=(q+~(q<<15)>>10^q+~(q<<15))*9|0;p=(p>>6^p)+~((p>>6^p)<<11)>>16^(p>>6^p)+~((p>>6^p)<<11);o=p&j+-1;l=o>>>0>>0;a:do if(l){h=c[g+(o<<2)>>2]|0;if((h|0)!=-1){m=c[x+72>>2]|0;while(1){if((q|0)==(c[m+(h<<3)>>2]|0)){n=13;break}k=c[f+(h<<2)>>2]|0;if((k|0)==-1)break;else h=k}if((n|0)==13?(n=0,(c[x+52>>2]|0)+(h<<2)|0):0)break;if(!l){n=20;break}}e=c[g+(o<<2)>>2]|0;if((e|0)!=-1){h=c[x+72>>2]|0;while(1){if((q|0)==(c[h+(e<<3)>>2]|0))break;e=c[f+(e<<2)>>2]|0;if((e|0)==-1){n=20;break a}}c[(c[x+52>>2]|0)+(e<<2)>>2]=q;e=j;n=82}else n=20}else n=20;while(0);if((n|0)==20){l=c[x+44>>2]|0;if((l|0)==(j|0)){e=j|0?j<<1:1;if((j|0)<(e|0)){if((e|0)!=0?(c[6435]=(c[6435]|0)+1,w=yc((e<<2|3)+16|0)|0,(w|0)!=0):0){c[(w+4+15&-16)+-4>>2]=w;g=w+4+15&-16}else g=0;if((j|0)>0){f=0;do{c[g+(f<<2)>>2]=c[(c[x+52>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(j|0))}f=c[x+52>>2]|0;if(f|0){if(a[x+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[x+52>>2]=0}a[x+56>>0]=1;c[x+52>>2]=g;c[x+48>>2]=e;f=j}else{f=j;e=j}}else{f=l;e=j}c[(c[x+52>>2]|0)+(f<<2)>>2]=q;c[x+44>>2]=f+1;f=c[x+64>>2]|0;if((f|0)==(c[x+68>>2]|0)?(s=f|0?f<<1:1,(f|0)<(s|0)):0){if((s|0)!=0?(c[6435]=(c[6435]|0)+1,t=yc((s<<3|3)+16|0)|0,(t|0)!=0):0){c[(t+4+15&-16)+-4>>2]=t;g=t+4+15&-16}else g=0;if((f|0)>0){e=0;do{k=(c[x+72>>2]|0)+(e<<3)|0;m=c[k+4>>2]|0;n=g+(e<<3)|0;c[n>>2]=c[k>>2];c[n+4>>2]=m;e=e+1|0}while((e|0)!=(f|0))}e=c[x+72>>2]|0;if(e|0){if(a[x+76>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[x+72>>2]=0}a[x+76>>0]=1;c[x+72>>2]=g;c[x+68>>2]=s;f=c[x+64>>2]|0;e=c[x+48>>2]|0}n=(c[x+72>>2]|0)+(f<<3)|0;c[n>>2]=q;c[n+4>>2]=0;c[x+64>>2]=f+1;if((j|0)<(e|0)){k=c[x+4>>2]|0;do if((e|0)>(k|0)){if((e|0)>=(k|0)){do if((c[x+8>>2]|0)<(e|0)){if((e|0)!=0?(c[6435]=(c[6435]|0)+1,u=yc((e<<2|3)+16|0)|0,(u|0)!=0):0){c[(u+4+15&-16)+-4>>2]=u;f=u+4+15&-16}else f=0;g=c[x+12>>2]|0;if((k|0)<=0){if(!g){a[x+16>>0]=1;c[x+12>>2]=f;c[x+8>>2]=e;break}}else{h=0;do{c[f+(h<<2)>>2]=c[g+(h<<2)>>2];h=h+1|0}while((h|0)!=(k|0))}if(a[x+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}a[x+16>>0]=1;c[x+12>>2]=f;c[x+8>>2]=e}else f=c[x+12>>2]|0;while(0);Qn(f+(k<<2)|0,0,e-k<<2|0)|0}c[x+4>>2]=e;j=c[x+24>>2]|0;if((e|0)>(j|0)){do if((c[x+28>>2]|0)<(e|0)){if((e|0)!=0?(c[6435]=(c[6435]|0)+1,v=yc((e<<2|3)+16|0)|0,(v|0)!=0):0){c[(v+4+15&-16)+-4>>2]=v;f=v+4+15&-16}else f=0;g=c[x+32>>2]|0;if((j|0)<=0){if(!g){a[x+36>>0]=1;c[x+32>>2]=f;c[x+28>>2]=e;break}}else{h=0;do{c[f+(h<<2)>>2]=c[g+(h<<2)>>2];h=h+1|0}while((h|0)!=(j|0))}if(a[x+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}a[x+36>>0]=1;c[x+32>>2]=f;c[x+28>>2]=e}else f=c[x+32>>2]|0;while(0);Qn(f+(j<<2)|0,0,e-j<<2|0)|0}c[x+24>>2]=e;if((e|0)>0){o=e<<2;Qn(c[x+12>>2]|0,-1,o|0)|0;Qn(c[x+32>>2]|0,-1,o|0)|0}if((k|0)<=0){e=c[x+48>>2]|0;break}f=c[x+72>>2]|0;g=c[x+12>>2]|0;h=c[x+32>>2]|0;e=c[x+48>>2]|0;j=0;do{o=c[f+(j<<3)>>2]|0;o=(o+~(o<<15)>>10^o+~(o<<15))*9|0;o=g+((((o>>6^o)+~((o>>6^o)<<11)>>16^(o>>6^o)+~((o>>6^o)<<11))&e+-1)<<2)|0;c[h+(j<<2)>>2]=c[o>>2];c[o>>2]=j;j=j+1|0}while((j|0)!=(k|0))}while(0);f=e;e=p&e+-1}else{f=e;e=o}g=c[x+12>>2]|0;e=g+(e<<2)|0;n=c[x+32>>2]|0;c[n+(l<<2)>>2]=c[e>>2];c[e>>2]=l;e=f;f=n;n=82}if((n|0)==82){n=0;Cb[c[(c[q>>2]|0)+60>>2]&127](q,d);j=e;e=c[b+8>>2]|0}h=r+1|0;if((h|0)>=(e|0))break;k=c[x+4>>2]|0;r=h}pj(x);i=x;return}function ud(b,d){b=b|0;d=d|0;var e=0,f=0,h=0.0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+32|0;ig(b+4|0,((_(c[b+152>>2]|0,c[b+16>>2]|0)|0)/100|0)+1|0);if(c[b+164>>2]|0){p=((_(c[b+148>>2]|0,c[b+76>>2]|0)|0)/100|0)+1|0;ig(b+64|0,p);p=(c[b+164>>2]|0)-p|0;c[b+164>>2]=(p|0)<0?0:p}e=((c[b+144>>2]|0)+1|0)%2|0;c[b+144>>2]=e;e=c[b+124+(e<<2)>>2]|0;if(e|0){do{l=e+56|0;m=e;e=c[l>>2]|0;k=c[m+52>>2]|0;j=e;if(!k)c[b+124+(c[m+60>>2]<<2)>>2]=j;else c[k+56>>2]=j;j=c[l>>2]|0;if(j|0)c[j+52>>2]=c[m+52>>2];c[m+52>>2]=0;c[l>>2]=c[b+132>>2];j=c[b+132>>2]|0;if(j|0)c[j+52>>2]=m;c[b+132>>2]=m;j=c[m+48>>2]|0;hh(b+4|0,j)|0;k=c[b+8>>2]|0;if(k|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[b+8>>2]=j;c[b+16>>2]=(c[b+16>>2]|0)+-1;c[r>>2]=c[m+16>>2];c[r+4>>2]=c[m+16+4>>2];c[r+8>>2]=c[m+16+8>>2];c[r+12>>2]=c[m+16+12>>2];c[r+16>>2]=c[m+32>>2];c[r+16+4>>2]=c[m+32+4>>2];c[r+16+8>>2]=c[m+32+8>>2];c[r+16+12>>2]=c[m+32+12>>2];j=c[b+68>>2]|0;if(!j){c[6435]=(c[6435]|0)+1;j=yc(63)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}k=j;l=k+44|0;do{c[k>>2]=0;k=k+4|0}while((k|0)<(l|0))}else c[b+68>>2]=0;c[j+32>>2]=0;c[j+36>>2]=m;c[j+40>>2]=0;c[j>>2]=c[r>>2];c[j+4>>2]=c[r+4>>2];c[j+8>>2]=c[r+8>>2];c[j+12>>2]=c[r+12>>2];c[j+16>>2]=c[r+16>>2];c[j+20>>2]=c[r+20>>2];c[j+24>>2]=c[r+24>>2];c[j+28>>2]=c[r+28>>2];lf(b+64|0,c[b+64>>2]|0,j);k=(c[b+76>>2]|0)+1|0;c[b+76>>2]=k;c[m+48>>2]=j;c[m+60>>2]=2}while((e|0)!=0);c[b+164>>2]=k;a[b+194>>0]=1}c[r>>2]=8904;c[r+4>>2]=b;if(a[b+193>>0]|0?(we(b+4|0,c[b+4>>2]|0,c[b+64>>2]|0,r),a[b+193>>0]|0):0){p=c[b+4>>2]|0;we(b+4|0,p,p,r)}if(a[b+194>>0]|0?(n=c[b+136>>2]|0,n=Eb[c[(c[n>>2]|0)+28>>2]&127](n)|0,f=c[n+4>>2]|0,(f|0)>0):0){e=(_(c[b+156>>2]|0,f)|0)/100|0;p=c[b+160>>2]|0;e=(p|0)>(e|0)?p:e;e=(f|0)<(e|0)?f:e;if((e|0)>0){j=0;do{l=((c[b+184>>2]|0)+j|0)%(f|0)|0;o=c[n+12>>2]|0;k=c[o+(l<<4)>>2]|0;l=c[o+(l<<4)+4>>2]|0;o=c[k+48>>2]|0;p=c[l+48>>2]|0;if(!(((((+g[o>>2]<=+g[p+16>>2]?+g[o+16>>2]>=+g[p>>2]:0)?+g[o+4>>2]<=+g[p+20>>2]:0)?+g[o+20>>2]>=+g[p+4>>2]:0)?+g[o+8>>2]<=+g[p+24>>2]:0)?+g[o+24>>2]>=+g[p+8>>2]:0)){f=c[b+136>>2]|0;Ib[c[(c[f>>2]|0)+12>>2]&31](f,k,l,d)|0;f=c[n+4>>2]|0;j=j+-1|0;e=e+-1|0}j=j+1|0}while((j|0)<(e|0));if((f|0)>0)q=37;else e=0}else q=37;if((q|0)==37)e=((c[b+184>>2]|0)+e|0)%(f|0)|0;c[b+184>>2]=e}c[b+180>>2]=(c[b+180>>2]|0)+1;c[b+160>>2]=1;a[b+194>>0]=0;f=c[b+168>>2]|0;e=c[b+172>>2]|0;if(!f)h=0.0;else h=+(e>>>0)/+(f>>>0);g[b+176>>2]=h;c[b+172>>2]=e>>>1;c[b+168>>2]=f>>>1;p=c[b+136>>2]|0;if(!(Eb[c[(c[p>>2]|0)+56>>2]&127](p)|0)){i=r;return}p=c[b+136>>2]|0;p=Eb[c[(c[p>>2]|0)+28>>2]&127](p)|0;e=c[p+4>>2]|0;if((e|0)>1){Vd(p,0,e+-1|0);j=0;k=0;l=0;f=0;q=44}else{j=0;o=0;n=0;f=0}while(1){if((q|0)==44){q=0;e=c[p+4>>2]|0;o=k;n=l}if((j|0)>=(e|0))break;m=c[p+12>>2]|0;k=m+(j<<4)|0;l=c[k>>2]|0;m=m+(j<<4)+4|0;e=c[m>>2]|0;if(!((l|0)==(n|0)&(e|0)==(f|0))){f=c[l+48>>2]|0;n=c[e+48>>2]|0;if(((((+g[f>>2]<=+g[n+16>>2]?+g[f+16>>2]>=+g[n>>2]:0)?+g[f+4>>2]<=+g[n+20>>2]:0)?+g[f+20>>2]>=+g[n+4>>2]:0)?+g[f+8>>2]<=+g[n+24>>2]:0)?+g[f+24>>2]>=+g[n+8>>2]:0){f=e;e=o}else q=53}else{e=f;q=53}if((q|0)==53){f=c[b+136>>2]|0;ic[c[(c[f>>2]|0)+32>>2]&127](f,k,d);c[k>>2]=0;c[m>>2]=0;f=e;e=o+1|0}j=j+1|0;k=e;q=44}if((e|0)>1){Vd(p,0,e+-1|0);k=c[p+4>>2]|0}else k=e;l=k-o|0;if((o|0)<0){if((c[p+8>>2]|0)<(l|0)){if((k|0)!=(o|0)){c[6435]=(c[6435]|0)+1;e=yc((l<<4|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e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q+(p<<2)+8>>2]=s;g[q+(p<<2)+12>>2]=0.0;g[q+(p<<1<<2)>>2]=m;g[q+(p<<1<<2)+4>>2]=-s;c[q+(p<<1<<2)+8>>2]=0;g[q+(p<<1<<2)+12>>2]=0.0;q=c[d+16>>2]|0;g[q>>2]=-1.0;g[q+(p+1<<2)>>2]=-1.0;g[q+((p<<1)+2<<2)>>2]=-1.0;u=+g[b+412>>2];l=+g[b+416>>2];k=+g[b+420>>2];t=+g[h+4>>2]*u+ +g[h+8>>2]*l+ +g[h+12>>2]*k;j=u*+g[h+20>>2]+l*+g[h+24>>2]+k*+g[h+28>>2];k=u*+g[h+36>>2]+l*+g[h+40>>2]+k*+g[h+44>>2];p=c[d+20>>2]|0;q=c[d+24>>2]|0;c[p>>2]=0;g[p+4>>2]=-k;g[p+8>>2]=j;g[p+12>>2]=0.0;g[p+(q<<2)>>2]=k;c[p+(q<<2)+4>>2]=0;g[p+(q<<2)+8>>2]=-t;g[p+(q<<2)+12>>2]=0.0;g[p+(q<<1<<2)>>2]=-j;g[p+(q<<1<<2)+4>>2]=t;c[p+(q<<1<<2)+8>>2]=0;g[p+(q<<1<<2)+12>>2]=0.0;q=c[b+592>>2]|0;l=+g[((q&2|0)==0?d+4|0:b+600|0)>>2]*+g[d>>2];r=c[d+24>>2]|0;i=c[d+28>>2]|0;f=c[d+36>>2]|0;e=c[d+40>>2]|0;g[i>>2]=l*(t+ +g[h+52>>2]-s-+g[o+52>>2]);g[f>>2]=-3402823466385288598117041.0e14;g[e>>2]=3402823466385288598117041.0e14;if(!(q&1)){g[i+(r<<2)>>2]=l*(j+ +g[h+56>>2]-m-+g[o+56>>2]);g[f+(r<<2)>>2]=-3402823466385288598117041.0e14;g[e+(r<<2)>>2]=3402823466385288598117041.0e14;g[i+(r<<1<<2)>>2]=l*(k+ +g[h+60>>2]-n-+g[o+60>>2]);g[f+(r<<1<<2)>>2]=-3402823466385288598117041.0e14;g[e+(r<<1<<2)>>2]=3402823466385288598117041.0e14}else{v=c[d+32>>2]|0;c[v>>2]=c[b+596>>2];g[i+(r<<2)>>2]=l*(j+ +g[h+56>>2]-m-+g[o+56>>2]);g[f+(r<<2)>>2]=-3402823466385288598117041.0e14;g[e+(r<<2)>>2]=3402823466385288598117041.0e14;c[v+(r<<2)>>2]=c[b+596>>2];g[i+(r<<1<<2)>>2]=l*(k+ +g[h+60>>2]-n-+g[o+60>>2]);g[f+(r<<1<<2)>>2]=-3402823466385288598117041.0e14;g[e+(r<<1<<2)>>2]=3402823466385288598117041.0e14;c[v+(r<<1<<2)>>2]=c[b+596>>2]}do if(!(a[b+526>>0]|0))h=r*3|0;else{h=c[d+12>>2]|0;u=+g[b+456>>2];if(+g[b+444>>2]>2]>2];y=+g[o+8>>2];x=+g[o+12>>2];D=+g[b+304>>2];C=+g[b+320>>2];B=+g[b+336>>2];l=+g[b+308>>2];n=+g[b+324>>2];t=+g[b+340>>2];w=+g[o+20>>2];j=+g[o+24>>2];k=+g[o+28>>2];m=+g[o+36>>2];s=+g[o+40>>2];u=+g[o+44>>2];g[h+(r*3<<2)>>2]=z*D+y*C+x*B;g[h+((r*3|0)+1<<2)>>2]=D*w+C*j+B*k;g[h+((r*3|0)+2<<2)>>2]=D*m+C*s+B*u;g[h+(r<<2<<2)>>2]=z*l+y*n+x*t;g[h+((r<<2|1)<<2)>>2]=l*w+n*j+t*k;g[h+((r<<2|2)<<2)>>2]=l*m+n*s+t*u;g[p+(r*3<<2)>>2]=-(z*D+y*C+x*B);g[p+((r*3|0)+1<<2)>>2]=-(D*w+C*j+B*k);g[p+((r*3|0)+2<<2)>>2]=-(D*m+C*s+B*u);g[p+(r<<2<<2)>>2]=-(z*l+y*n+x*t);g[p+((r<<2|1)<<2)>>2]=-(l*w+n*j+t*k);g[p+((r<<2|2)<<2)>>2]=-(l*m+n*s+t*u);A=+g[d>>2]*+g[b+436>>2];i=c[d+28>>2]|0;g[i+(r*3<<2)>>2]=A*((z*D+y*C+x*B)*+g[b+460>>2]+(D*w+C*j+B*k)*+g[b+464>>2]+(D*m+C*s+B*u)*+g[b+468>>2]);g[i+(r<<2<<2)>>2]=A*((z*l+y*n+x*t)*+g[b+460>>2]+(l*w+n*j+t*k)*+g[b+464>>2]+(l*m+n*s+t*u)*+g[b+468>>2]);f=c[d+36>>2]|0;g[f+(r*3<<2)>>2]=-3402823466385288598117041.0e14;e=c[d+40>>2]|0;g[e+(r*3<<2)>>2]=3402823466385288598117041.0e14;g[f+(r<<2<<2)>>2]=-3402823466385288598117041.0e14;g[e+(r<<2<<2)>>2]=3402823466385288598117041.0e14;h=(c[d+24>>2]|0)+(r<<2)|0;break}D=+g[b+436>>2];B=D*+g[b+460>>2]*D;C=D*D*+g[b+464>>2];D=D*D*+g[b+468>>2];g[h+(r*3<<2)>>2]=B;g[h+((r*3|0)+1<<2)>>2]=C;g[h+((r*3|0)+2<<2)>>2]=D;g[p+(r*3<<2)>>2]=-B;g[p+((r*3|0)+1<<2)>>2]=-C;g[p+((r*3|0)+2<<2)>>2]=-D;g[i+(r*3<<2)>>2]=+g[d>>2]*+g[b+432>>2]*+g[b+504>>2];if(q&4|0)c[(c[d+32>>2]|0)+(r*3<<2)>>2]=c[b+604>>2];g[f+(r*3<<2)>>2]=0.0;g[e+(r*3<<2)>>2]=3402823466385288598117041.0e14;h=r<<2}while(0);if(!(a[b+525>>0]|0))return;D=+g[b+436>>2];B=D*+g[b+476>>2]*D;C=D*D*+g[b+480>>2];D=D*D*+g[b+484>>2];p=c[d+12>>2]|0;r=c[d+20>>2]|0;g[p+(h<<2)>>2]=B;q=h+1|0;g[p+(q<<2)>>2]=C;v=h+2|0;g[p+(v<<2)>>2]=D;g[r+(h<<2)>>2]=-B;g[r+(q<<2)>>2]=-C;g[r+(v<<2)>>2]=-D;g[i+(h<<2)>>2]=+g[d>>2]*+g[b+432>>2]*+g[b+508>>2];if(c[b+592>>2]&4|0)c[(c[d+32>>2]|0)+(h<<2)>>2]=c[b+604>>2];if(!(+g[b+452>>2]>0.0)){g[f+(h<<2)>>2]=-3402823466385288598117041.0e14;g[e+(h<<2)>>2]=3402823466385288598117041.0e14;return}f=f+(h<<2)|0;e=c[d+40>>2]|0;if(+g[b+508>>2]>0.0){g[f>>2]=0.0;g[e+(h<<2)>>2]=3402823466385288598117041.0e14;return}else{g[f>>2]=-3402823466385288598117041.0e14;g[e+(h<<2)>>2]=0.0;return}}function wd(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=+h;var j=0.0,l=0,m=0.0,n=0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0.0,F=0.0,G=0.0,H=0,I=0,J=0,K=0,L=0.0,M=0.0,N=0.0,O=0.0;K=i;i=i+288|0;c[K+144>>2]=c[d>>2];c[K+144+4>>2]=c[d+4>>2];c[K+144+8>>2]=c[d+8>>2];c[K+144+12>>2]=c[d+12>>2];c[K+144+16>>2]=c[d+16>>2];c[K+144+16+4>>2]=c[d+16+4>>2];c[K+144+16+8>>2]=c[d+16+8>>2];c[K+144+16+12>>2]=c[d+16+12>>2];c[K+144+32>>2]=c[d+32>>2];c[K+144+32+4>>2]=c[d+32+4>>2];c[K+144+32+8>>2]=c[d+32+8>>2];c[K+144+32+12>>2]=c[d+32+12>>2];c[K+144+48>>2]=c[d+48>>2];c[K+144+48+4>>2]=c[d+48+4>>2];c[K+144+48+8>>2]=c[d+48+8>>2];c[K+144+48+12>>2]=c[d+48+12>>2];c[K+80>>2]=c[e>>2];c[K+80+4>>2]=c[e+4>>2];c[K+80+8>>2]=c[e+8>>2];c[K+80+12>>2]=c[e+12>>2];c[K+80+16>>2]=c[e+16>>2];c[K+80+16+4>>2]=c[e+16+4>>2];c[K+80+16+8>>2]=c[e+16+8>>2];c[K+80+16+12>>2]=c[e+16+12>>2];c[K+80+32>>2]=c[e+32>>2];c[K+80+32+4>>2]=c[e+32+4>>2];c[K+80+32+8>>2]=c[e+32+8>>2];c[K+80+32+12>>2]=c[e+32+12>>2];c[K+80+48>>2]=c[e+48>>2];c[K+80+48+4>>2]=c[e+48+4>>2];c[K+80+48+8>>2]=c[e+48+8>>2];c[K+80+48+12>>2]=c[e+48+12>>2];m=+g[K+80+52>>2]-+g[K+144+52>>2];O=+g[K+80+56>>2]-+g[K+144+56>>2];g[K+32>>2]=+g[K+80+48>>2]-+g[K+144+48>>2];g[K+32+4>>2]=m;g[K+32+8>>2]=O;g[K+32+12>>2]=0.0;Gf(K+144|0,K+80|0,K+224|0,K+208|0);O=+g[K+208>>2];m=O*+g[K+224+4>>2];L=O*+g[K+224+8>>2];g[K>>2]=+g[K+224>>2]*O;g[K+4>>2]=m;g[K+8>>2]=L;g[K+12>>2]=0.0;c[K+224+4>>2]=0;c[K+224+4+4>>2]=0;c[K+224+24>>2]=0;c[K+224+24+4>>2]=0;J=K+224+44|0;c[J>>2]=0;c[J+4>>2]=0;c[J+8>>2]=0;c[J+12>>2]=0;c[J+16>>2]=0;Wg(K+144|0,K+16|0);L=+g[K+16>>2];m=+g[K+16+4>>2];O=+g[K+16+8>>2];M=+g[K+16+12>>2];j=L*(2.0/(L*L+m*m+O*O+M*M));o=m*(2.0/(L*L+m*m+O*O+M*M));N=O*(2.0/(L*L+m*m+O*O+M*M));g[K+224>>2]=1.0-(m*o+O*N);g[K+224+4>>2]=L*o-M*N;g[K+224+8>>2]=L*N+M*o;g[K+224+12>>2]=0.0;g[K+224+16>>2]=L*o+M*N;g[K+224+20>>2]=1.0-(L*j+O*N);g[K+224+24>>2]=m*N-M*j;g[K+224+28>>2]=0.0;g[K+224+32>>2]=L*N-M*o;g[K+224+36>>2]=m*N+M*j;g[K+224+40>>2]=1.0-(L*j+m*o);g[J>>2]=0.0;rh(b,K+224|0,K+32|0,K,K+64|0,K+48|0);if((c[a+268>>2]|0)<=0){i=K;return}I=0;do{p=c[(c[a+276>>2]|0)+(I<<2)>>2]|0;if(Zb[c[(c[f>>2]|0)+8>>2]&31](f,c[p+188>>2]|0)|0?(C=c[p+192>>2]|0,mc[c[(c[C>>2]|0)+8>>2]&127](C,p+4|0,K+208|0,K+32|0),q=+g[K+208>>2]+ +g[K+64>>2],r=+g[K+208+4>>2]+ +g[K+64+4>>2],s=+g[K+208+8>>2]+ +g[K+64+8>>2],g[K+208>>2]=q,g[K+208+4>>2]=r,g[K+208+8>>2]=s,g[K+208+12>>2]=0.0,t=+g[K+32>>2]+ +g[K+48>>2],u=+g[K+32+4>>2]+ +g[K+48+4>>2],v=+g[K+32+8>>2]+ +g[K+48+8>>2],g[K+32>>2]=t,g[K+32+4>>2]=u,g[K+32+8>>2]=v,g[K+32+12>>2]=0.0,w=+g[d+48>>2]-(t+q)*.5,x=+g[d+52>>2]-(u+r)*.5,y=+g[d+56>>2]-(v+s)*.5,z=+g[e+48>>2]-(t+q)*.5,A=+g[e+52>>2]-(u+r)*.5,B=+g[e+56>>2]-(v+s)*.5,C=w<-((t-q)*.5)|(w>(t-q)*.5?8:0)|(x<-((u-r)*.5)?2:0)|(x>(u-r)*.5?16:0)|(y<-((v-s)*.5)?4:0)|(y>(v-s)*.5?32:0),D=z<-((t-q)*.5)|(z>(t-q)*.5?8:0)|(A<-((u-r)*.5)?2:0)|(A>(u-r)*.5?16:0)|(B<-((v-s)*.5)?4:0)|(B>(v-s)*.5?32:0),(C&D|0)==0):0){H=1;J=0;j=0.0;l=1065353216;o=1.0;while(1){if(!(H&C)){if((H&D|0)!=0?(E=(-w-o*(t-q)*.5)/(z-w),E<(c[k>>2]=l,+g[k>>2])):0)l=(g[k>>2]=E,c[k>>2]|0)}else{m=(-w-o*(t-q)*.5)/(z-w);if(j<=m)j=m}n=H<<1;if(!(n&C))if((n&D|0)!=0?(F=(-x-o*(u-r)*.5)/(A-x),F<(c[k>>2]=l,+g[k>>2])):0){m=j;l=(g[k>>2]=F,c[k>>2]|0)}else m=j;else{m=(-x-o*(u-r)*.5)/(A-x);if(!(j<=m))m=j}n=H<<2;if(!(n&C))if((n&D|0)!=0?(G=(-y-o*(v-s)*.5)/(B-y),G<(c[k>>2]=l,+g[k>>2])):0){j=m;l=(g[k>>2]=G,c[k>>2]|0)}else j=m;else{j=(-y-o*(v-s)*.5)/(B-y);if(!(m<=j))j=m}J=J+1|0;if((J|0)==2)break;else{H=H<<3;o=-1.0}}if(j<=(c[k>>2]=l,+g[k>>2])){J=c[p+192>>2]|0;c[K+224>>2]=0;c[K+224+4>>2]=J;c[K+224+8>>2]=p;c[K+224+12>>2]=p+4;c[K+224+16>>2]=-1;c[K+224+20>>2]=-1;Ic(b,K+144|0,K+80|0,K+224|0,f,h)}}I=I+1|0}while((I|0)<(c[a+268>>2]|0));i=K;return}function xd(d,e){d=d|0;e=e|0;var f=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;q=i;i=i+112|0;g[d+20>>2]=+h[e+32>>3];g[d+24>>2]=+h[e+40>>3];g[d+28>>2]=+h[e+48>>3];g[d+32>>2]=+h[e+56>>3];g[d+4>>2]=+h[e>>3];g[d+8>>2]=+h[e+8>>3];g[d+12>>2]=+h[e+16>>3];g[d+16>>2]=+h[e+24>>3];g[d+36>>2]=+h[e+64>>3];g[d+40>>2]=+h[e+72>>3];g[d+44>>2]=+h[e+80>>3];g[d+48>>2]=+h[e+88>>3];c[d+56>>2]=c[e+96>>2];a[d+60>>0]=(c[e+100>>2]|0)!=0&1;p=c[e+104>>2]|0;l=q+48|0;n=l+64|0;do{c[l>>2]=0;l=l+4|0}while((l|0)<(n|0));o=c[d+88>>2]|0;if((o|0)<(p|0)){if((c[d+92>>2]|0)<(p|0)){if(!p){f=0;j=o}else{c[6435]=(c[6435]|0)+1;f=yc(p<<6|19)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=c[d+88>>2]|0}if((j|0)>0){k=0;do{l=f+(k<<6)|0;m=(c[d+96>>2]|0)+(k<<6)|0;n=l+64|0;do{c[l>>2]=c[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));k=k+1|0}while((k|0)!=(j|0))}j=c[d+96>>2]|0;if(j|0){if(a[d+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[d+96>>2]=0}a[d+100>>0]=1;c[d+96>>2]=f;c[d+92>>2]=p;j=d+96|0}else j=d+96|0;f=o;do{l=(c[j>>2]|0)+(f<<6)|0;m=q+48|0;n=l+64|0;do{c[l>>2]=c[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));f=f+1|0}while((f|0)!=(p|0))}c[d+88>>2]=p;if((p|0)>0){f=c[d+96>>2]|0;j=0;k=c[e+112>>2]|0;while(1){g[f+(j<<6)+16>>2]=+h[k+32>>3];g[f+(j<<6)+20>>2]=+h[k+40>>3];g[f+(j<<6)+24>>2]=+h[k+48>>3];g[f+(j<<6)+28>>2]=+h[k+56>>3];g[f+(j<<6)>>2]=+h[k>>3];g[f+(j<<6)+4>>2]=+h[k+8>>3];g[f+(j<<6)+8>>2]=+h[k+16>>3];g[f+(j<<6)+12>>2]=+h[k+24>>3];c[f+(j<<6)+32>>2]=c[k+64>>2];c[f+(j<<6)+36>>2]=c[k+68>>2];c[f+(j<<6)+40>>2]=c[k+72>>2];j=j+1|0;if((j|0)==(p|0))break;else k=k+80|0}}m=c[e+108>>2]|0;c[q+32>>2]=0;c[q+32+4>>2]=0;c[q+32+8>>2]=0;c[q+32+12>>2]=0;l=c[d+128>>2]|0;if((l|0)<(m|0)){if((c[d+132>>2]|0)<(m|0)){if(!m){f=0;j=l}else{c[6435]=(c[6435]|0)+1;f=yc((m<<4|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=c[d+128>>2]|0}if((j|0)>0){k=0;do{p=f+(k<<4)|0;o=(c[d+136>>2]|0)+(k<<4)|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];k=k+1|0}while((k|0)!=(j|0))}j=c[d+136>>2]|0;if(j|0){if(a[d+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[d+136>>2]=0}a[d+140>>0]=1;c[d+136>>2]=f;c[d+132>>2]=m;j=d+136|0}else j=d+136|0;f=l;do{p=(c[j>>2]|0)+(f<<4)|0;c[p>>2]=c[q+32>>2];c[p+4>>2]=c[q+32+4>>2];c[p+8>>2]=c[q+32+8>>2];c[p+12>>2]=c[q+32+12>>2];f=f+1|0}while((f|0)!=(m|0))}c[d+128>>2]=m;if((m|0)>0){f=c[d+136>>2]|0;j=0;k=c[e+116>>2]|0;while(1){c[f+(j<<4)+12>>2]=c[k+12>>2];b[f+(j<<4)+6>>1]=b[k+6>>1]|0;b[f+(j<<4)+8>>1]=b[k+8>>1]|0;b[f+(j<<4)+10>>1]=b[k+10>>1]|0;b[f+(j<<4)>>1]=b[k>>1]|0;b[f+(j<<4)+2>>1]=b[k+2>>1]|0;b[f+(j<<4)+4>>1]=b[k+4>>1]|0;j=j+1|0;if((j|0)==(m|0))break;else k=k+16|0}}c[d+144>>2]=c[e+120>>2];m=c[e+124>>2]|0;l=c[d+152>>2]|0;if((l|0)<(m|0)){if((c[d+156>>2]|0)<(m|0)){if(!m){f=0;j=l}else{c[6435]=(c[6435]|0)+1;f=yc(m<<5|19)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=c[d+152>>2]|0}if((j|0)>0){k=0;do{p=f+(k<<5)|0;o=(c[d+160>>2]|0)+(k<<5)|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];c[p+16>>2]=c[o+16>>2];c[p+20>>2]=c[o+20>>2];c[p+24>>2]=c[o+24>>2];c[p+28>>2]=c[o+28>>2];k=k+1|0}while((k|0)!=(j|0))}j=c[d+160>>2]|0;if(j|0){if(a[d+164>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[d+160>>2]=0}a[d+164>>0]=1;c[d+160>>2]=f;c[d+156>>2]=m;j=d+160|0}else j=d+160|0;f=l;do{p=(c[j>>2]|0)+(f<<5)|0;c[p>>2]=c[q>>2];c[p+4>>2]=c[q+4>>2];c[p+8>>2]=c[q+8>>2];c[p+12>>2]=c[q+12>>2];c[p+16>>2]=c[q+16>>2];c[p+20>>2]=c[q+20>>2];c[p+24>>2]=c[q+24>>2];c[p+28>>2]=c[q+28>>2];f=f+1|0}while((f|0)!=(m|0))}c[d+152>>2]=m;if((m|0)<=0){i=q;return}j=c[d+160>>2]|0;k=0;f=c[e+128>>2]|0;while(1){b[j+(k<<5)+6>>1]=b[f+14>>1]|0;b[j+(k<<5)+8>>1]=b[f+16>>1]|0;b[j+(k<<5)+10>>1]=b[f+18>>1]|0;b[j+(k<<5)>>1]=b[f+8>>1]|0;b[j+(k<<5)+2>>1]=b[f+10>>1]|0;b[j+(k<<5)+4>>1]=b[f+12>>1]|0;c[j+(k<<5)+12>>2]=c[f>>2];c[j+(k<<5)+16>>2]=c[f+4>>2];k=k+1|0;if((k|0)==(m|0))break;else f=f+20|0}i=q;return}function yd(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0;n=i;i=i+16|0;m=c[a+372>>2]|0;a:do switch(c[m+32>>2]|0){case 1:{d=1;b=0;while(1){c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;g[n+(b<<2)>>2]=1.0;o=m+32|0;g[m+16+(d<<2)>>2]=0.0;d=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=d;c[m+(c[o>>2]<<2)>>2]=c[a+348+(d<<2)>>2];d=c[o>>2]|0;c[o>>2]=d+1;e=+g[n>>2];f=+g[n+4>>2];h=+g[n+8>>2];Nh(a,e,f,h,c[m+(d<<2)>>2]|0);if(yd(a)|0)break;m=c[a+372>>2]|0;o=(c[m+32>>2]|0)+-1|0;c[m+32>>2]=o;o=c[m+(o<<2)>>2]|0;m=c[a+364>>2]|0;c[a+364>>2]=m+1;c[a+348+(m<<2)>>2]=o;m=c[a+372>>2]|0;g[m+16+(c[m+32>>2]<<2)>>2]=0.0;o=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=o;c[m+(c[m+32>>2]<<2)>>2]=c[a+348+(o<<2)>>2];o=c[m+32>>2]|0;c[m+32>>2]=o+1;Nh(a,-e,-f,-h,c[m+(o<<2)>>2]|0);if(yd(a)|0)break;o=c[a+372>>2]|0;m=(c[o+32>>2]|0)+-1|0;c[o+32>>2]=m;m=c[o+(m<<2)>>2]|0;o=c[a+364>>2]|0;c[a+364>>2]=o+1;c[a+348+(o<<2)>>2]=m;b=b+1|0;if(b>>>0>=3)break a;m=c[a+372>>2]|0;d=c[m+32>>2]|0}o=1;i=n;return o|0}case 2:{o=c[m+4>>2]|0;b=c[m>>2]|0;e=+g[o+16>>2]-+g[b+16>>2];f=+g[o+20>>2]-+g[b+20>>2];h=+g[o+24>>2]-+g[b+24>>2];b=0;while(1){c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;g[n+(b<<2)>>2]=1.0;j=+g[n+8>>2];k=+g[n+4>>2];l=+g[n>>2];if((f*j-h*k)*(f*j-h*k)+(h*l-e*j)*(h*l-e*j)+(e*k-f*l)*(e*k-f*l)>0.0){m=c[a+372>>2]|0;g[m+16+(c[m+32>>2]<<2)>>2]=0.0;o=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=o;c[m+(c[m+32>>2]<<2)>>2]=c[a+348+(o<<2)>>2];o=c[m+32>>2]|0;c[m+32>>2]=o+1;Nh(a,f*j-h*k,h*l-e*j,e*k-f*l,c[m+(o<<2)>>2]|0);if(yd(a)|0)break;m=c[a+372>>2]|0;o=(c[m+32>>2]|0)+-1|0;c[m+32>>2]=o;o=c[m+(o<<2)>>2]|0;m=c[a+364>>2]|0;c[a+364>>2]=m+1;c[a+348+(m<<2)>>2]=o;m=c[a+372>>2]|0;g[m+16+(c[m+32>>2]<<2)>>2]=0.0;o=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=o;c[m+(c[m+32>>2]<<2)>>2]=c[a+348+(o<<2)>>2];o=c[m+32>>2]|0;c[m+32>>2]=o+1;Nh(a,-(f*j-h*k),-(h*l-e*j),-(e*k-f*l),c[m+(o<<2)>>2]|0);if(yd(a)|0)break;o=c[a+372>>2]|0;m=(c[o+32>>2]|0)+-1|0;c[o+32>>2]=m;m=c[o+(m<<2)>>2]|0;o=c[a+364>>2]|0;c[a+364>>2]=o+1;c[a+348+(o<<2)>>2]=m}b=b+1|0;if(b>>>0>=3)break a}o=1;i=n;return o|0}case 3:{o=c[m+4>>2]|0;d=c[m>>2]|0;j=+g[d+16>>2];e=+g[o+16>>2]-j;k=+g[d+20>>2];f=+g[o+20>>2]-k;l=+g[d+24>>2];h=+g[o+24>>2]-l;o=c[m+8>>2]|0;j=+g[o+16>>2]-j;k=+g[o+20>>2]-k;l=+g[o+24>>2]-l;if((f*l-h*k)*(f*l-h*k)+(h*j-e*l)*(h*j-e*l)+(e*k-f*j)*(e*k-f*j)>0.0){g[m+28>>2]=0.0;o=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=o;c[m+12>>2]=c[a+348+(o<<2)>>2];o=c[m+32>>2]|0;c[m+32>>2]=o+1;Nh(a,f*l-h*k,h*j-e*l,e*k-f*j,c[m+(o<<2)>>2]|0);if(yd(a)|0){o=1;i=n;return o|0}m=c[a+372>>2]|0;o=(c[m+32>>2]|0)+-1|0;c[m+32>>2]=o;o=c[m+(o<<2)>>2]|0;m=c[a+364>>2]|0;c[a+364>>2]=m+1;c[a+348+(m<<2)>>2]=o;m=c[a+372>>2]|0;g[m+16+(c[m+32>>2]<<2)>>2]=0.0;o=(c[a+364>>2]|0)+-1|0;c[a+364>>2]=o;c[m+(c[m+32>>2]<<2)>>2]=c[a+348+(o<<2)>>2];o=c[m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>2];e=c[X+12>>2]|0;N=+g[e+8>>2];P=+g[e+12>>2];Q=+g[e+16>>2];h=c[X+16>>2]|0;U=+g[h+8>>2];V=+g[h+12>>2];W=+g[h+16>>2];w=N-K-(R-K);D=P-L-(S-L);B=Q-M-(T-M);x=D*(W-M-(T-M))-B*(V-L-(S-L));E=B*(U-K-(R-K))-w*(W-M-(T-M));C=w*(V-L-(S-L))-D*(U-K-(R-K));do if(C*C+(x*x+E*E)>1.1920928955078125e-07?(G=1.0/+O(+(C*C+(x*x+E*E))),H=(T-M)*C*G+((R-K)*x*G+(S-L)*E*G),H*H<3402823466385288598117041.0e14):0){f=R-K-x*G*H;r=S-L-E*G*H;s=T-M-C*G*H;t=N-K-x*G*H;u=P-L-E*G*H;v=Q-M-C*G*H;if((C*(u*f-r*t)+(x*(r*v-s*u)+E*(s*t-v*f))>0.0?(y=U-K-x*G*H,z=V-L-E*G*H,A=W-M-C*G*H,C*(z*t-u*y)+(x*(u*A-v*z)+E*(v*y-A*t))>0.0):0)?C*(r*y-z*f)+(x*(z*s-A*r)+E*(A*f-s*y))>0.0:0){q=H*H;p=x*G*H;n=C*G*H;m=E*G*H;break}if(w*w+D*D+B*B>1.1920928955078125e-07?(F=-((R-K)*w+(S-L)*D+(T-M)*B)/(w*w+D*D+B*B),F=F<0.0?0.0:F>1.0?1.0:F,q=(T-M+B*F)*(T-M+B*F)+((R-K+w*F)*(R-K+w*F)+(S-L+D*F)*(S-L+D*F)),q<3402823466385288598117041.0e14):0){s=R-K+w*F;t=T-M+B*F;r=S-L+D*F}else{q=3402823466385288598117041.0e14;s=0.0;t=0.0;r=0.0}f=(U-K-(N-K))*(U-K-(N-K))+(V-L-(P-L))*(V-L-(P-L))+(W-M-(Q-M))*(W-M-(Q-M));if(f>1.1920928955078125e-07?(n=-((N-K)*(U-K-(N-K))+(P-L)*(V-L-(P-L))+(Q-M)*(W-M-(Q-M)))/f,n=n<0.0?0.0:n>1.0?1.0:n,p=N-K+(U-K-(N-K))*n,k=P-L+(V-L-(P-L))*n,n=Q-M+(W-M-(Q-M))*n,n*n+(p*p+k*k)1.1920928955078125e-07?(J=-((U-K)*(R-K-(U-K))+(V-L)*(S-L-(V-L))+(W-M)*(T-M-(W-M)))/f,J=J<0.0?0.0:J>1.0?1.0:J,I=U-K+(R-K-(U-K))*J,m=V-L+(S-L-(V-L))*J,J=W-M+(T-M-(W-M))*J,J*J+(I*I+m*m)>2];J=L-+g[Y+28>>2];u=M-+g[Y+32>>2];u=+g[b+12>>2]+ +O(+(I*I+J*J+u*u))*2.0;if(!(q>2];V=+g[d+88>>2];W=+g[e+88>>2];f=+g[h+88>>2];f=!(V<=0.0)&!(W<=0.0)&!(f<=0.0)?V*s*(1.0/(t+s+r))+W*r*(1.0/(t+s+r))+t*(1.0/(t+s+r))*f:0.0;if(!(k+f>0.0))return;W=1.0/-+O(+q);q=p*W;p=m*W;n=n*W;o=c[b+4>>2]|0;d=c[b+8>>2]|0;l=c[(+g[o+316>>2]>+g[d+316>>2]?o+316|0:d+316|0)>>2]|0;m=k/(k+f)*+g[o+332>>2];f=f/(k+f)*+g[d+332>>2];d=c[o+832>>2]|0;if((d|0)==(c[o+836>>2]|0)?(Z=d|0?d<<1:1,(d|0)<(Z|0)):0){if(!Z)j=0;else{c[6435]=(c[6435]|0)+1;d=yc((Z*56|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}j=d;d=c[o+832>>2]|0}if((d|0)>0){e=0;do{h=j+(e*56|0)|0;b=(c[o+840>>2]|0)+(e*56|0)|0;i=h+56|0;do{c[h>>2]=c[b>>2];h=h+4|0;b=b+4|0}while((h|0)<(i|0));e=e+1|0}while((e|0)!=(d|0))}d=c[o+840>>2]|0;if(d|0){if(a[o+844>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[o+840>>2]=0}a[o+844>>0]=1;c[o+840>>2]=j;c[o+836>>2]=Z;d=c[o+832>>2]|0}Z=c[o+840>>2]|0;c[Z+(d*56|0)>>2]=Y;c[Z+(d*56|0)+4>>2]=X;g[Z+(d*56|0)+8>>2]=s*(1.0/(t+s+r));g[Z+(d*56|0)+12>>2]=r*(1.0/(t+s+r));g[Z+(d*56|0)+16>>2]=t*(1.0/(t+s+r));g[Z+(d*56|0)+20>>2]=0.0;g[Z+(d*56|0)+24>>2]=q;g[Z+(d*56|0)+28>>2]=p;g[Z+(d*56|0)+32>>2]=n;g[Z+(d*56|0)+36>>2]=0.0;g[Z+(d*56|0)+40>>2]=u;c[Z+(d*56|0)+44>>2]=l;g[Z+(d*56|0)+48>>2]=m;g[Z+(d*56|0)+52>>2]=f;c[o+832>>2]=(c[o+832>>2]|0)+1;return}function Ad(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;o=i;i=i+112|0;c[d+20>>2]=c[e+16>>2];c[d+24>>2]=c[e+20>>2];c[d+28>>2]=c[e+24>>2];c[d+32>>2]=c[e+28>>2];c[d+4>>2]=c[e>>2];c[d+8>>2]=c[e+4>>2];c[d+12>>2]=c[e+8>>2];c[d+16>>2]=c[e+12>>2];c[d+36>>2]=c[e+32>>2];c[d+40>>2]=c[e+36>>2];c[d+44>>2]=c[e+40>>2];c[d+48>>2]=c[e+44>>2];c[d+56>>2]=c[e+48>>2];a[d+60>>0]=(c[e+52>>2]|0)!=0&1;n=c[e+56>>2]|0;j=o+48|0;l=j+64|0;do{c[j>>2]=0;j=j+4|0}while((j|0)<(l|0));m=c[d+88>>2]|0;if((m|0)<(n|0)){if((c[d+92>>2]|0)<(n|0)){if(!n){f=0;g=m}else{c[6435]=(c[6435]|0)+1;f=yc(n<<6|19)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}g=c[d+88>>2]|0}if((g|0)>0){h=0;do{j=f+(h<<6)|0;k=(c[d+96>>2]|0)+(h<<6)|0;l=j+64|0;do{c[j>>2]=c[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));h=h+1|0}while((h|0)!=(g|0))}g=c[d+96>>2]|0;if(g|0){if(a[d+100>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[d+96>>2]=0}a[d+100>>0]=1;c[d+96>>2]=f;c[d+92>>2]=n;g=d+96|0}else g=d+96|0;f=m;do{j=(c[g>>2]|0)+(f<<6)|0;k=o+48|0;l=j+64|0;do{c[j>>2]=c[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));f=f+1|0}while((f|0)!=(n|0))}c[d+88>>2]=n;if((n|0)>0){f=c[d+96>>2]|0;g=0;h=c[e+64>>2]|0;while(1){c[f+(g<<6)+16>>2]=c[h+16>>2];c[f+(g<<6)+20>>2]=c[h+20>>2];c[f+(g<<6)+24>>2]=c[h+24>>2];c[f+(g<<6)+28>>2]=c[h+28>>2];c[f+(g<<6)>>2]=c[h>>2];c[f+(g<<6)+4>>2]=c[h+4>>2];c[f+(g<<6)+8>>2]=c[h+8>>2];c[f+(g<<6)+12>>2]=c[h+12>>2];c[f+(g<<6)+32>>2]=c[h+32>>2];c[f+(g<<6)+36>>2]=c[h+36>>2];c[f+(g<<6)+40>>2]=c[h+40>>2];g=g+1|0;if((g|0)==(n|0))break;else h=h+48|0}}k=c[e+60>>2]|0;c[o+32>>2]=0;c[o+32+4>>2]=0;c[o+32+8>>2]=0;c[o+32+12>>2]=0;j=c[d+128>>2]|0;if((j|0)<(k|0)){if((c[d+132>>2]|0)<(k|0)){if(!k){f=0;g=j}else{c[6435]=(c[6435]|0)+1;f=yc((k<<4|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}g=c[d+128>>2]|0}if((g|0)>0){h=0;do{n=f+(h<<4)|0;m=(c[d+136>>2]|0)+(h<<4)|0;c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];c[n+8>>2]=c[m+8>>2];c[n+12>>2]=c[m+12>>2];h=h+1|0}while((h|0)!=(g|0))}g=c[d+136>>2]|0;if(g|0){if(a[d+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[d+136>>2]=0}a[d+140>>0]=1;c[d+136>>2]=f;c[d+132>>2]=k;g=d+136|0}else g=d+136|0;f=j;do{n=(c[g>>2]|0)+(f<<4)|0;c[n>>2]=c[o+32>>2];c[n+4>>2]=c[o+32+4>>2];c[n+8>>2]=c[o+32+8>>2];c[n+12>>2]=c[o+32+12>>2];f=f+1|0}while((f|0)!=(k|0))}c[d+128>>2]=k;if((k|0)>0){f=c[d+136>>2]|0;g=0;h=c[e+68>>2]|0;while(1){c[f+(g<<4)+12>>2]=c[h+12>>2];b[f+(g<<4)+6>>1]=b[h+6>>1]|0;b[f+(g<<4)+8>>1]=b[h+8>>1]|0;b[f+(g<<4)+10>>1]=b[h+10>>1]|0;b[f+(g<<4)>>1]=b[h>>1]|0;b[f+(g<<4)+2>>1]=b[h+2>>1]|0;b[f+(g<<4)+4>>1]=b[h+4>>1]|0;g=g+1|0;if((g|0)==(k|0))break;else h=h+16|0}}c[d+144>>2]=c[e+76>>2];k=c[e+80>>2]|0;j=c[d+152>>2]|0;if((j|0)<(k|0)){if((c[d+156>>2]|0)<(k|0)){if(!k){f=0;g=j}else{c[6435]=(c[6435]|0)+1;f=yc(k<<5|19)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}g=c[d+152>>2]|0}if((g|0)>0){h=0;do{n=f+(h<<5)|0;m=(c[d+160>>2]|0)+(h<<5)|0;c[n>>2]=c[m>>2];c[n+4>>2]=c[m+4>>2];c[n+8>>2]=c[m+8>>2];c[n+12>>2]=c[m+12>>2];c[n+16>>2]=c[m+16>>2];c[n+20>>2]=c[m+20>>2];c[n+24>>2]=c[m+24>>2];c[n+28>>2]=c[m+28>>2];h=h+1|0}while((h|0)!=(g|0))}g=c[d+160>>2]|0;if(g|0){if(a[d+164>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[d+160>>2]=0}a[d+164>>0]=1;c[d+160>>2]=f;c[d+156>>2]=k;g=d+160|0}else g=d+160|0;f=j;do{n=(c[g>>2]|0)+(f<<5)|0;c[n>>2]=c[o>>2];c[n+4>>2]=c[o+4>>2];c[n+8>>2]=c[o+8>>2];c[n+12>>2]=c[o+12>>2];c[n+16>>2]=c[o+16>>2];c[n+20>>2]=c[o+20>>2];c[n+24>>2]=c[o+24>>2];c[n+28>>2]=c[o+28>>2];f=f+1|0}while((f|0)!=(k|0))}c[d+152>>2]=k;if((k|0)<=0){i=o;return}g=c[d+160>>2]|0;h=0;f=c[e+72>>2]|0;while(1){b[g+(h<<5)+6>>1]=b[f+14>>1]|0;b[g+(h<<5)+8>>1]=b[f+16>>1]|0;b[g+(h<<5)+10>>1]=b[f+18>>1]|0;b[g+(h<<5)>>1]=b[f+8>>1]|0;b[g+(h<<5)+2>>1]=b[f+10>>1]|0;b[g+(h<<5)+4>>1]=b[f+12>>1]|0;c[g+(h<<5)+12>>2]=c[f>>2];c[g+(h<<5)+16>>2]=c[f+4>>2];h=h+1|0;if((h|0)==(k|0))break;else f=f+20|0}i=o;return}function Bd(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;c[b>>2]=3180;d=c[b+192>>2]|0;if(d|0)Ab[c[(c[d>>2]|0)+4>>2]&255](d);a:do if((c[b+1112>>2]|0)>0)do{h=c[c[b+1120>>2]>>2]|0;d=c[h+348>>2]|0;if(d|0){hh(b+1048|0,d)|0;e=c[b+1052>>2]|0;if(e|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+1052>>2]=d;c[b+1060>>2]=(c[b+1060>>2]|0)+-1}Fk(h);if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}d=c[b+1112>>2]|0;if((d|0)<=0)break a;g=c[b+1120>>2]|0;e=0;do{f=g+(e<<2)|0;if((c[f>>2]|0)==(h|0)){i=18;break}e=e+1|0}while((e|0)<(d|0));if((i|0)==18){i=0;if((e|0)<(d|0)){c[f>>2]=c[g+(d+-1<<2)>>2];c[(c[b+1120>>2]|0)+(d+-1<<2)>>2]=h;c[b+1112>>2]=d+-1;d=d+-1|0}}}while((d|0)>0);while(0);d=c[b+872>>2]|0;if((d|0)>0){f=0;do{e=c[(c[b+880>>2]|0)+(f<<2)>>2]|0;if(e){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[b+872>>2]|0}f=f+1|0}while((f|0)<(d|0))}d=c[b+852>>2]|0;if((d|0)>0){f=0;do{e=c[(c[b+860>>2]|0)+(f<<2)>>2]|0;if(e){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0);d=c[b+852>>2]|0}f=f+1|0}while((f|0)<(d|0))}d=c[b+1244>>2]|0;if(d|0){if(a[b+1248>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+1244>>2]=0}a[b+1248>>0]=1;c[b+1244>>2]=0;c[b+1236>>2]=0;c[b+1240>>2]=0;d=c[b+1140>>2]|0;if(d|0){if(a[b+1144>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+1140>>2]=0}a[b+1144>>0]=1;c[b+1140>>2]=0;c[b+1132>>2]=0;c[b+1136>>2]=0;d=c[b+1120>>2]|0;if(d|0){if(a[b+1124>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+1120>>2]=0}a[b+1124>>0]=1;c[b+1120>>2]=0;c[b+1112>>2]=0;c[b+1116>>2]=0;pi(b+1048|0);pi(b+988|0);pi(b+928|0);d=c[b+880>>2]|0;if(d|0){if(a[b+884>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+880>>2]=0}a[b+884>>0]=1;c[b+880>>2]=0;c[b+872>>2]=0;c[b+876>>2]=0;d=c[b+860>>2]|0;if(d|0){if(a[b+864>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+860>>2]=0}a[b+864>>0]=1;c[b+860>>2]=0;c[b+852>>2]=0;c[b+856>>2]=0;d=c[b+840>>2]|0;if(d|0){if(a[b+844>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+840>>2]=0}a[b+844>>0]=1;c[b+840>>2]=0;c[b+832>>2]=0;c[b+836>>2]=0;d=c[b+820>>2]|0;if(d|0){if(a[b+824>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+820>>2]=0}a[b+824>>0]=1;c[b+820>>2]=0;c[b+812>>2]=0;c[b+816>>2]=0;d=c[b+800>>2]|0;if(d|0){if(a[b+804>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+800>>2]=0}a[b+804>>0]=1;c[b+800>>2]=0;c[b+792>>2]=0;c[b+796>>2]=0;d=c[b+780>>2]|0;if(d|0){if(a[b+784>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+780>>2]=0}a[b+784>>0]=1;c[b+780>>2]=0;c[b+772>>2]=0;c[b+776>>2]=0;d=c[b+760>>2]|0;if(d|0){if(a[b+764>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+760>>2]=0}a[b+764>>0]=1;c[b+760>>2]=0;c[b+752>>2]=0;c[b+756>>2]=0;d=c[b+740>>2]|0;if(d|0){if(a[b+744>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+740>>2]=0}a[b+744>>0]=1;c[b+740>>2]=0;c[b+732>>2]=0;c[b+736>>2]=0;d=c[b+720>>2]|0;if(d|0){if(a[b+724>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+720>>2]=0}a[b+724>>0]=1;c[b+720>>2]=0;c[b+712>>2]=0;c[b+716>>2]=0;d=c[b+700>>2]|0;if(d|0){if(a[b+704>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+700>>2]=0}a[b+704>>0]=1;c[b+700>>2]=0;c[b+692>>2]=0;c[b+696>>2]=0;d=c[b+512>>2]|0;if(d|0){if(a[b+516>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+512>>2]=0}a[b+516>>0]=1;c[b+512>>2]=0;c[b+504>>2]=0;c[b+508>>2]=0;d=c[b+492>>2]|0;if(d|0){if(a[b+496>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+492>>2]=0}a[b+496>>0]=1;c[b+492>>2]=0;c[b+484>>2]=0;c[b+488>>2]=0;d=c[b+444>>2]|0;if(d|0){if(!((a[b+448>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+444>>2]=0}a[b+448>>0]=1;c[b+444>>2]=0;c[b+436>>2]=0;c[b+440>>2]=0;d=c[b+424>>2]|0;if(d|0){if(!((a[b+428>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+424>>2]=0}a[b+428>>0]=1;c[b+424>>2]=0;c[b+416>>2]=0;c[b+420>>2]=0;d=c[b+404>>2]|0;if(d|0){if(!((a[b+408>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+404>>2]=0}a[b+408>>0]=1;c[b+404>>2]=0;c[b+396>>2]=0;c[b+400>>2]=0;d=c[b+276>>2]|0;if(!d){a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;i=b+272|0;c[i>>2]=0;c[b>>2]=5008;return}if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+276>>2]=0;a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;i=b+272|0;c[i>>2]=0;c[b>>2]=5008;return}function Cd(a,d,f,h,j,k,l,m,n){a=a|0;d=d|0;f=f|0;h=h|0;j=j|0;k=k|0;l=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b[t>>1]=(b[t>>1]|0)+-1<<16>>16;o=e[r>>1]|e[r+2>>1]<<16;n=e[p>>1]|e[p+2>>1]<<16;b[r>>1]=n;b[r+2>>1]=n>>>16;b[p>>1]=o;b[p+2>>1]=o>>>16;o=r+-4|0;p=p+-4|0;n=b[p>>1]|0;if((e[o>>1]|0)>=(n&65535))break a;s=c[a+60>>2]|0;r=o}}while(0);o=c[a+72>>2]|0;q=e[u+((v&65535)<<6)+50>>1]|0;p=c[a+60>>2]|0;n=b[o+(q<<2)+-4>>1]|0;if((e[o+(q<<2)>>1]|0)<(n&65535)){s=p+((e[o+(q<<2)+2>>1]|0)<<6)+50|0;r=o+(q<<2)|0;q=o+(q<<2)+-4|0;while(1){o=e[r+-2>>1]|0;if(!(n&1)){t=p+(o<<6)+50|0;b[t>>1]=(b[t>>1]|0)+1<<16>>16}else{t=p+(o<<6)+56|0;b[t>>1]=(b[t>>1]|0)+1<<16>>16}b[s>>1]=(b[s>>1]|0)+-1<<16>>16;o=e[r>>1]|e[r+2>>1]<<16;n=e[q>>1]|e[q+2>>1]<<16;b[r>>1]=n;b[r+2>>1]=n>>>16;b[q>>1]=o;b[q+2>>1]=o>>>16;o=r+-4|0;q=q+-4|0;n=b[q>>1]|0;if((e[o>>1]|0)>=(n&65535))break;p=c[a+60>>2]|0;r=o}o=c[a+72>>2]|0}n=e[u+((v&65535)<<6)+56>>1]|0;q=o+(n<<2)|0;p=b[q+-4>>1]|0;b:do if((e[q>>1]|0)<(p&65535)){s=c[a+60>>2]|0;t=s+((e[o+(n<<2)+2>>1]|0)<<6)+56|0;n=p;r=q;p=q+-4|0;while(1){o=e[r+-2>>1]|0;if(!(n&1)){s=s+(o<<6)+50|0;b[s>>1]=(b[s>>1]|0)+1<<16>>16}else{s=s+(o<<6)+56|0;b[s>>1]=(b[s>>1]|0)+1<<16>>16}b[t>>1]=(b[t>>1]|0)+-1<<16>>16;o=e[r>>1]|e[r+2>>1]<<16;n=e[p>>1]|e[p+2>>1]<<16;b[r>>1]=n;b[r+2>>1]=n>>>16;b[p>>1]=o;b[p+2>>1]=o>>>16;o=r+-4|0;p=p+-4|0;n=b[p>>1]|0;if((e[o>>1]|0)>=(n&65535))break b;s=c[a+60>>2]|0;r=o}}while(0);wh(a,2,b[u+((v&65535)<<6)+52>>1]|0);uh(a,2,b[u+((v&65535)<<6)+58>>1]|0,m);o=c[a+60>>2]|0;n=c[a+108>>2]|0;if(!n){j=o+((v&65535)<<6)|0;i=w;return j|0}c[o+((v&65535)<<6)+60>>2]=gc[c[(c[n>>2]|0)+8>>2]&3](n,d,f,h,j,k,l,m,0)|0;j=o+((v&65535)<<6)|0;i=w;return j|0}function Dd(b,d,e,f,h,i,j,k,l,m,n,o,p){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;var q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0;A=_(c[l+24>>2]|0,m)|0;m=a[d+44>>0]|0;z=c[d+56>>2]|0;if(!(m<<24>>24!=0|(z|0)!=0)){A=0;return A|0}C=c[(o|0?l+12|0:l+8|0)>>2]|0;B=c[(o|0?l+20|0:l+16|0)>>2]|0;c[C+(A<<2)>>2]=c[n>>2];c[C+(A+1<<2)>>2]=c[n+4>>2];c[C+(A+2<<2)>>2]=c[n+8>>2];g[B+(A<<2)>>2]=-+g[n>>2];g[B+(A+1<<2)>>2]=-+g[n+4>>2];g[B+(A+2<<2)>>2]=-+g[n+8>>2];do if(!o){q=+g[b+1176>>2];if(!(a[b+1301>>0]|0)){t=q-+g[e+48>>2];w=+g[b+1180>>2]-+g[e+52>>2];x=+g[b+1184>>2]-+g[e+56>>2];v=+g[n+8>>2];s=+g[n+4>>2];u=+g[n>>2];C=c[l+12>>2]|0;g[C+(A<<2)>>2]=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+8>>2]=q;C=c[l+20>>2]|0;g[C+(A<<2)>>2]=-t;g[C+(A+1<<2)>>2]=-v;g[C+(A+2<<2)>>2]=-u}while(0);if(z|0?+g[d>>2]==+g[d+4>>2]:0){m=c[l+28>>2]|0;g[m+(A<<2)>>2]=0.0;q=0.0;e=l+28|0}else y=11;do if((y|0)==11){e=c[l+28>>2]|0;g[e+(A<<2)>>2]=0.0;if(!(m<<24>>24)){if(z|0){m=e;q=0.0;e=l+28|0;break}else m=1;return m|0}c[(c[l+32>>2]|0)+(A<<2)>>2]=c[d+28>>2];if(z|0){m=e;q=+g[e+(A<<2)>>2];e=l+28|0;break}v=+g[d+8>>2];q=o|0?v:-v;r=+g[d+52>>2];s=+g[d>>2];t=+g[d+4>>2];u=+g[l>>2]*+g[d+32>>2];do if(!(s>t))if(!(s==t)){if(q/u<0.0)if(r>=s?s-q/u>r:0){q=(s-r)/(q/u);break}else{q=r0.0)if(r<=t?t-q/ut?0.0:1.0;break}else q=0.0}else q=0.0;else q=1.0;while(0);g[e+(A<<2)>>2]=q*v+ +g[e+(A<<2)>>2];g[(c[l+36>>2]|0)+(A<<2)>>2]=-+g[d+12>>2];c[(c[l+40>>2]|0)+(A<<2)>>2]=c[d+12>>2];C=1;return C|0}while(0);K=+g[l>>2]*+g[d+32>>2]*+g[d+48>>2];g[m+(A<<2)>>2]=q+(o|0?-K:K);c[(c[l+32>>2]|0)+(A<<2)>>2]=c[d+36>>2];if(+g[d>>2]==+g[d+4>>2]){g[(c[l+36>>2]|0)+(A<<2)>>2]=-3402823466385288598117041.0e14;g[(c[l+40>>2]|0)+(A<<2)>>2]=3402823466385288598117041.0e14;C=1;return C|0}C=c[l+40>>2]|0;g[(c[l+36>>2]|0)+(A<<2)>>2]=(z|0)==1?0.0:-3402823466385288598117041.0e14;g[C+(A<<2)>>2]=(z|0)==1?3402823466385288598117041.0e14:0.0;r=+g[d+40>>2];if(!(r>0.0)){C=1;return C|0}if(o|0){J=+g[n>>2];K=+g[n+4>>2];q=+g[n+8>>2];q=+g[j>>2]*J+ +g[j+4>>2]*K+ +g[j+8>>2]*q-(J*+g[k>>2]+K*+g[k+4>>2]+q*+g[k+8>>2])}else{J=+g[n>>2];K=+g[n+4>>2];q=+g[n+8>>2];q=+g[h>>2]*J+ +g[h+4>>2]*K+ +g[h+8>>2]*q-(J*+g[i>>2]+K*+g[i+4>>2]+q*+g[i+8>>2])}if((z|0)==1){if(!(q<0.0)){C=1;return C|0}q=-(q*r);m=(c[e>>2]|0)+(A<<2)|0;if(!(+g[m>>2]>2]=q;C=1;return C|0}else{if(!(q>0.0)){C=1;return C|0}q=-(q*r);m=(c[e>>2]|0)+(A<<2)|0;if(!(+g[m>>2]>q)){C=1;return C|0}g[m>>2]=q;C=1;return C|0}return 0}function Ed(b,d,e,f,h,j){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0.0,m=0,n=0.0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0;u=i;i=i+288|0;q=c[b+4>>2]|0;a[q+312>>0]=0;c[q>>2]=0;a[q+356>>0]=1;c[q+292>>2]=1566444395;c[q+296>>2]=1566444395;c[q+300>>2]=1566444395;g[q+304>>2]=0.0;c[q+336>>2]=0;c[q+336+4>>2]=0;c[q+336+8>>2]=0;c[q+336+12>>2]=0;a[q+336+16>>0]=0;a[q+332>>0]=a[q+332>>0]&-16;r=+g[e+48>>2]-+g[d+48>>2]-(+g[h+48>>2]-+g[f+48>>2]);s=+g[e+52>>2]-+g[d+52>>2]-(+g[h+52>>2]-+g[f+52>>2]);t=+g[e+56>>2]-+g[d+56>>2]-(+g[h+56>>2]-+g[f+56>>2]);c[u+216>>2]=9160;g[u+216+36>>2]=999999984306749440.0;a[u+216+40>>0]=0;q=c[b+8>>2]|0;p=c[b+12>>2]|0;o=c[b+4>>2]|0;c[u+136>>2]=9208;c[u+136+4>>2]=0;c[u+136+8>>2]=1065353216;c[u+136+12>>2]=0;g[u+136+16>>2]=0.0;c[u+136+20>>2]=0;c[u+136+24>>2]=o;c[u+136+28>>2]=q;c[u+136+32>>2]=p;c[u+136+36>>2]=c[q+4>>2];c[u+136+40>>2]=c[p+4>>2];g[u+136+44>>2]=+Sb[c[(c[q>>2]|0)+48>>2]&15](q);g[u+136+48>>2]=+Sb[c[(c[p>>2]|0)+48>>2]&15](p);a[u+136+52>>0]=0;c[u+136+60>>2]=-1;c[u+136+72>>2]=1;c[u+136+76>>2]=1;g[u+128>>2]=999999984306749440.0;c[u>>2]=c[d>>2];c[u+4>>2]=c[d+4>>2];c[u+8>>2]=c[d+8>>2];c[u+12>>2]=c[d+12>>2];c[u+16>>2]=c[d+16>>2];c[u+16+4>>2]=c[d+16+4>>2];c[u+16+8>>2]=c[d+16+8>>2];c[u+16+12>>2]=c[d+16+12>>2];c[u+32>>2]=c[d+32>>2];c[u+32+4>>2]=c[d+32+4>>2];c[u+32+8>>2]=c[d+32+8>>2];c[u+32+12>>2]=c[d+32+12>>2];c[u+48>>2]=c[d+48>>2];c[u+48+4>>2]=c[d+48+4>>2];c[u+48+8>>2]=c[d+48+8>>2];c[u+48+12>>2]=c[d+48+12>>2];c[u+64>>2]=c[f>>2];c[u+64+4>>2]=c[f+4>>2];c[u+64+8>>2]=c[f+8>>2];c[u+64+12>>2]=c[f+12>>2];c[u+80>>2]=c[f+16>>2];c[u+80+4>>2]=c[f+16+4>>2];c[u+80+8>>2]=c[f+16+8>>2];c[u+80+12>>2]=c[f+16+12>>2];c[u+96>>2]=c[f+32>>2];c[u+96+4>>2]=c[f+32+4>>2];c[u+96+8>>2]=c[f+32+8>>2];c[u+96+12>>2]=c[f+32+12>>2];c[u+112>>2]=c[f+48>>2];c[u+112+4>>2]=c[f+48+4>>2];c[u+112+8>>2]=c[f+48+8>>2];c[u+112+12>>2]=c[f+48+12>>2];Vc(u+136|0,u,u+216|0,0,0);p=(a[u+216+40>>0]|0)==0;q=u+216+20|0;c[u+264>>2]=c[q>>2];c[u+264+4>>2]=c[q+4>>2];c[u+264+8>>2]=c[q+8>>2];c[u+264+12>>2]=c[q+12>>2];if(p){j=0;i=u;return j|0}n=+g[u+216+36>>2];l=+g[u+216+16>>2];b=c[u+216+12>>2]|0;m=c[u+216+8>>2]|0;o=c[u+216+4>>2]|0;do if(n>1.0000000474974513e-03){l=0.0;p=0;while(1){if((p|0)>31){b=0;p=13;break}w=r*(c[k>>2]=o,+g[k>>2]);w=s*(c[k>>2]=m,+g[k>>2])+w;v=l;l=l-n/(t*(c[k>>2]=b,+g[k>>2])+w);if(!(!(l<=v)&(!(l<0.0)&!(l>1.0)))){b=0;p=13;break}zb[c[c[j>>2]>>2]&31](j,l);w=1.0-l;g[u+48>>2]=w*+g[d+48>>2]+l*+g[e+48>>2];g[u+52>>2]=w*+g[d+52>>2]+l*+g[e+52>>2];g[u+56>>2]=w*+g[d+56>>2]+l*+g[e+56>>2];g[u+112>>2]=w*+g[f+48>>2]+l*+g[h+48>>2];g[u+116>>2]=w*+g[f+52>>2]+l*+g[h+52>>2];g[u+120>>2]=w*+g[f+56>>2]+l*+g[h+56>>2];Vc(u+136|0,u,u+216|0,0,0);if(!(a[u+216+40>>0]|0)){b=0;p=13;break}n=+g[u+216+36>>2];if(n<0.0){p=8;break}c[u+264>>2]=c[q>>2];c[u+264+4>>2]=c[q+4>>2];c[u+264+8>>2]=c[q+8>>2];c[u+264+12>>2]=c[q+12>>2];b=c[u+216+12>>2]|0;m=c[u+216+8>>2]|0;o=c[u+216+4>>2]|0;if(!(n>1.0000000474974513e-03)){p=10;break}else p=p+1|0}if((p|0)==8){g[j+164>>2]=l;f=c[u+216+8>>2]|0;e=c[u+216+12>>2]|0;h=c[u+216+16>>2]|0;c[j+132>>2]=c[u+216+4>>2];c[j+136>>2]=f;c[j+140>>2]=e;c[j+144>>2]=h;c[j+148>>2]=c[q>>2];c[j+148+4>>2]=c[q+4>>2];c[j+148+8>>2]=c[q+8>>2];c[j+148+12>>2]=c[q+12>>2];j=1;i=u;return j|0}else if((p|0)==10){n=l;l=+g[u+216+16>>2];break}else if((p|0)==13){i=u;return b|0}}else n=0.0;while(0);w=r*(c[k>>2]=o,+g[k>>2]);w=s*(c[k>>2]=m,+g[k>>2])+w;if(t*(c[k>>2]=b,+g[k>>2])+w>=-+g[j+172>>2]){j=0;i=u;return j|0}g[j+164>>2]=n;c[j+132>>2]=o;c[j+136>>2]=m;c[j+140>>2]=b;g[j+144>>2]=l;c[j+148>>2]=c[u+264>>2];c[j+148+4>>2]=c[u+264+4>>2];c[j+148+8>>2]=c[u+264+8>>2];c[j+148+12>>2]=c[u+264+12>>2];j=1;i=u;return j|0}function Fd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0;m=i;i=i+240|0;c[a+4>>2]=(c[a+4>>2]|0)+1;k=c[b+36>>2]|0;j=c[d+36>>2]|0;f=c[a+8>>2]|0;K=c[(c[f+4>>2]|0)+24>>2]|0;d=c[K+(k*80|0)+64>>2]|0;b=(c[(c[a+12>>2]|0)+4>>2]|0)+24|0;e=c[(c[b>>2]|0)+(j*80|0)+64>>2]|0;f=c[f+12>>2]|0;n=+g[f>>2];I=+g[f+4>>2];J=+g[f+8>>2];q=+g[f+16>>2];s=+g[f+20>>2];u=+g[f+24>>2];r=+g[f+32>>2];v=+g[f+36>>2];D=+g[f+40>>2];w=+g[K+(k*80|0)>>2];x=+g[K+(k*80|0)+16>>2];y=+g[K+(k*80|0)+32>>2];z=+g[K+(k*80|0)+4>>2];A=+g[K+(k*80|0)+20>>2];B=+g[K+(k*80|0)+36>>2];t=+g[K+(k*80|0)+8>>2];C=+g[K+(k*80|0)+24>>2];E=+g[K+(k*80|0)+40>>2];o=+g[K+(k*80|0)+48>>2];p=+g[K+(k*80|0)+52>>2];H=+g[K+(k*80|0)+56>>2];F=+g[f+48>>2]+(n*o+I*p+J*H);G=+g[f+52>>2]+(q*o+s*p+u*H);H=+g[f+56>>2]+(r*o+v*p+D*H);g[m+176>>2]=n*w+I*x+J*y;g[m+176+4>>2]=n*z+I*A+J*B;g[m+176+8>>2]=n*t+I*C+J*E;g[m+176+12>>2]=0.0;g[m+176+16>>2]=q*w+s*x+u*y;g[m+176+20>>2]=q*z+s*A+u*B;g[m+176+24>>2]=q*t+s*C+u*E;g[m+176+28>>2]=0.0;g[m+176+32>>2]=r*w+v*x+D*y;g[m+176+36>>2]=r*z+v*A+D*B;g[m+176+40>>2]=r*t+v*C+D*E;g[m+176+44>>2]=0.0;g[m+176+48>>2]=F;g[m+176+52>>2]=G;g[m+176+56>>2]=H;g[m+176+60>>2]=0.0;f=c[(c[a+12>>2]|0)+12>>2]|0;H=+g[f>>2];G=+g[f+4>>2];F=+g[f+8>>2];E=+g[f+16>>2];D=+g[f+20>>2];C=+g[f+24>>2];v=+g[f+32>>2];t=+g[f+36>>2];r=+g[f+40>>2];b=c[b>>2]|0;B=+g[b+(j*80|0)>>2];A=+g[b+(j*80|0)+16>>2];z=+g[b+(j*80|0)+32>>2];y=+g[b+(j*80|0)+4>>2];x=+g[b+(j*80|0)+20>>2];w=+g[b+(j*80|0)+36>>2];u=+g[b+(j*80|0)+8>>2];s=+g[b+(j*80|0)+24>>2];q=+g[b+(j*80|0)+40>>2];J=+g[b+(j*80|0)+48>>2];I=+g[b+(j*80|0)+52>>2];n=+g[b+(j*80|0)+56>>2];p=+g[f+48>>2]+(H*J+G*I+F*n);o=+g[f+52>>2]+(E*J+D*I+C*n);n=+g[f+56>>2]+(v*J+t*I+r*n);g[m+112>>2]=H*B+G*A+F*z;g[m+112+4>>2]=H*y+G*x+F*w;g[m+112+8>>2]=H*u+G*s+F*q;g[m+112+12>>2]=0.0;g[m+112+16>>2]=E*B+D*A+C*z;g[m+112+20>>2]=E*y+D*x+C*w;g[m+112+24>>2]=E*u+D*s+C*q;g[m+112+28>>2]=0.0;g[m+112+32>>2]=v*B+t*A+r*z;g[m+112+36>>2]=v*y+t*x+r*w;g[m+112+40>>2]=v*u+t*s+r*q;g[m+112+44>>2]=0.0;g[m+112+48>>2]=p;g[m+112+52>>2]=o;g[m+112+56>>2]=n;g[m+112+60>>2]=0.0;mc[c[(c[d>>2]|0)+8>>2]&127](d,m+176|0,m+96|0,m+80|0);mc[c[(c[e>>2]|0)+8>>2]&127](e,m+112|0,m+64|0,m+48|0);if(!(+g[m+96>>2]>+g[m+48>>2])?!(+g[m+80>>2]<+g[m+64>>2]):0)b=1;else b=0;if(!(!(+g[m+96+8>>2]>+g[m+48+8>>2])?!(+g[m+80+8>>2]<+g[m+64+8>>2]):0))b=0;if(+g[m+96+4>>2]>+g[m+48+4>>2]){i=m;return}if(+g[m+80+4>>2]<+g[m+64+4>>2]|b^1){i=m;return}f=c[a+8>>2]|0;b=c[f+8>>2]|0;c[m+24>>2]=f;c[m+24+4>>2]=d;c[m+24+8>>2]=b;c[m+24+12>>2]=m+176;c[m+24+16>>2]=-1;c[m+24+20>>2]=k;b=c[a+12>>2]|0;f=c[b+8>>2]|0;c[m>>2]=b;c[m+4>>2]=e;c[m+8>>2]=f;c[m+12>>2]=m+112;c[m+16>>2]=-1;c[m+20>>2]=j;f=c[a+28>>2]|0;c[6423]=(c[6423]|0)+1;b=((j<<16|k)+~((j<<16|k)<<15)>>10^(j<<16|k)+~((j<<16|k)<<15))*9|0;b=(c[f+12>>2]|0)+-1&((b>>6^b)+~((b>>6^b)<<11)>>16^(b>>6^b)+~((b>>6^b)<<11));a:do if((b|0)<(c[f+32>>2]|0)?(h=c[(c[f+40>>2]|0)+(b<<2)>>2]|0,(h|0)!=-1):0){e=c[f+16>>2]|0;b=h;while(1){d=e+(b*12|0)|0;if((c[d>>2]|0)==(k|0)?(c[e+(b*12|0)+4>>2]|0)==(j|0):0)break;b=c[(c[f+60>>2]|0)+(b<<2)>>2]|0;if((b|0)==-1){l=16;break a}}if(d)b=c[e+(b*12|0)+8>>2]|0;else l=16}else l=16;while(0);if((l|0)==16){b=c[a+16>>2]|0;b=Ib[c[(c[b>>2]|0)+8>>2]&31](b,m+24|0,m,c[a+32>>2]|0)|0;K=c[a+28>>2]|0;c[(Ob[c[(c[K>>2]|0)+12>>2]&63](K,k,j)|0)+8>>2]=b}K=c[a+24>>2]|0;h=c[K+8>>2]|0;l=c[K+12>>2]|0;c[K+8>>2]=m+24;c[K+12>>2]=m;ic[c[(c[K>>2]|0)+8>>2]&127](K,-1,k);K=c[a+24>>2]|0;ic[c[(c[K>>2]|0)+12>>2]&127](K,-1,j);yb[c[(c[b>>2]|0)+8>>2]&31](b,m+24|0,m,c[a+20>>2]|0,c[a+24>>2]|0);K=c[a+24>>2]|0;c[K+8>>2]=h;c[K+12>>2]=l;i=m;return}function Gd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,h=0.0,j=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0;z=i;i=i+48|0;switch(c[b+4>>2]|0){case 8:{c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;i=z;return}case 0:{w=+g[b+28>>2];x=+g[b+28+4>>2];x=+g[d+4>>2]>=0.0?x:-x;y=+g[b+28+8>>2];y=+g[d+8>>2]>=0.0?y:-y;g[a>>2]=+g[d>>2]>=0.0?w:-w;g[a+4>>2]=x;g[a+8>>2]=y;g[a+12>>2]=0.0;i=z;return}case 1:{u=+g[d>>2];v=+g[d+4>>2];y=+g[d+8>>2];x=u*+g[b+56>>2]+v*+g[b+56+4>>2]+y*+g[b+56+8>>2];w=u*+g[b+56+16>>2]+v*+g[b+56+20>>2]+y*+g[b+56+24>>2];y=u*+g[b+56+32>>2]+v*+g[b+56+36>>2]+y*+g[b+56+40>>2];d=x>2]|0;r=c[b+56+(d<<4)+8>>2]|0;c[a>>2]=c[b+56+(d<<4)>>2];c[a+4>>2]=o;c[a+8>>2]=r;g[a+12>>2]=0.0;i=z;return}case 13:{c[z+32>>2]=c[b+28>>2];c[z+32+4>>2]=c[b+28+4>>2];c[z+32+8>>2]=c[b+28+8>>2];c[z+32+12>>2]=c[b+28+12>>2];c[z+16>>2]=c[d>>2];f=c[d+4>>2]|0;c[z+16+4>>2]=f;r=c[d+8>>2]|0;c[z+16+8>>2]=r;g[z+16+12>>2]=0.0;d=c[b+52>>2]|0;e=(c[k>>2]=r,+g[k>>2]);switch(d|0){case 2:{e=(c[k>>2]=f,+g[k>>2]);f=0;b=2;o=1;break}case 1:{f=0;b=1;o=2;break}default:{f=1;b=0;o=2}}n=+g[z+32+(f<<2)>>2];l=+g[z+32+(d<<2)>>2];m=+g[z+16+(f<<2)>>2];h=+O(+(m*m+e*e));j=+g[z+16+(b<<2)>>2];if(h!=0.0){g[z+(f<<2)>>2]=m*(n/h);g[z+(b<<2)>>2]=j<0.0?-l:l;g[z+(o<<2)>>2]=n/h*e;c[a>>2]=c[z>>2];c[a+4>>2]=c[z+4>>2];c[a+8>>2]=c[z+8>>2]}else{g[z+(f<<2)>>2]=n;g[z+(b<<2)>>2]=j<0.0?-l:l;g[z+(o<<2)>>2]=0.0;c[a>>2]=c[z>>2];c[a+4>>2]=c[z+4>>2];c[a+8>>2]=c[z+8>>2]}g[a+12>>2]=0.0;i=z;return}case 10:{e=+g[d>>2];h=+g[d+4>>2];j=+g[d+8>>2];o=c[b+52>>2]|0;v=+g[b+28+(o<<2)>>2];l=+g[b+28+(((o+2|0)%3|0)<<2)>>2];if(e*e+h*h+j*j<9.999999747378752e-05){y=1.0;x=0.0;w=0.0}else{w=1.0/+O(+(e*e+h*h+j*j));y=e*w;x=h*w;w=j*w}c[z+32>>2]=0;c[z+32+4>>2]=0;c[z+32+8>>2]=0;c[z+32+12>>2]=0;g[z+32+(o<<2)>>2]=v;q=l*y;t=l*x;u=l*w;s=+g[b+44>>2];m=y*s;p=x*s;s=w*s;e=q+ +g[z+32>>2]-m;h=t+ +g[z+32+4>>2]-p;l=u+ +g[z+32+8>>2]-s;j=w*l+(y*e+x*h);if(j>-999999984306749440.0){b=(g[k>>2]=e,c[k>>2]|0);f=(g[k>>2]=h,c[k>>2]|0);n=j;d=(g[k>>2]=l,c[k>>2]|0)}else{n=-999999984306749440.0;b=0;d=0;f=0}c[z+32>>2]=0;c[z+32+4>>2]=0;c[z+32+8>>2]=0;c[z+32+12>>2]=0;g[z+32+(o<<2)>>2]=-v;j=q+ +g[z+32>>2]-m;h=t+ +g[z+32+4>>2]-p;e=u+ +g[z+32+8>>2]-s;if(w*e+(y*j+x*h)>n){b=(g[k>>2]=j,c[k>>2]|0);f=(g[k>>2]=h,c[k>>2]|0);d=(g[k>>2]=e,c[k>>2]|0)}c[a>>2]=b;c[a+4>>2]=f;c[a+8>>2]=d;g[a+12>>2]=0.0;i=z;return}case 5:{r=c[b+92>>2]|0;o=c[b+96>>2]|0;p=+g[b+12>>2];q=+g[b+16>>2];n=+g[b+20>>2];l=+g[d>>2]*p;m=+g[d+4>>2]*q;e=+g[d+8>>2]*n;if((o|0)>0){b=0;j=-3402823466385288598117041.0e14;f=-1;while(1){h=l*+g[r+(b<<4)>>2]+m*+g[r+(b<<4)+4>>2]+e*+g[r+(b<<4)+8>>2];d=h>j;f=d?b:f;b=b+1|0;if((b|0)==(o|0))break;else j=d?h:j}}else f=-1;x=q*+g[r+(f<<4)+4>>2];y=n*+g[r+(f<<4)+8>>2];g[a>>2]=p*+g[r+(f<<4)>>2];g[a+4>>2]=x;g[a+8>>2]=y;g[a+12>>2]=0.0;i=z;return}case 4:{r=c[b+104>>2]|0;o=c[b+96>>2]|0;p=+g[b+12>>2];q=+g[b+16>>2];n=+g[b+20>>2];l=+g[d>>2]*p;m=+g[d+4>>2]*q;e=+g[d+8>>2]*n;if((o|0)>0){b=0;j=-3402823466385288598117041.0e14;f=-1;while(1){h=l*+g[r+(b<<4)>>2]+m*+g[r+(b<<4)+4>>2]+e*+g[r+(b<<4)+8>>2];d=h>j;f=d?b:f;b=b+1|0;if((b|0)==(o|0))break;else j=d?h:j}}else f=-1;x=q*+g[r+(f<<4)+4>>2];y=n*+g[r+(f<<4)+8>>2];g[a>>2]=p*+g[r+(f<<4)>>2];g[a+4>>2]=x;g[a+8>>2]=y;g[a+12>>2]=0.0;i=z;return}default:{ic[c[(c[b>>2]|0)+68>>2]&127](a,b,d);i=z;return}}}function Hd(d,e,f,h){d=d|0;e=e|0;f=f|0;h=h|0;var i=0.0,j=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0,y=0.0,z=0,A=0.0,B=0.0;j=+g[e>>2];m=(g[k>>2]=j,c[k>>2]|0);r=j<999999984306749440.0?m:1566444395;i=+g[e+4>>2];o=(g[k>>2]=i,c[k>>2]|0);t=i<999999984306749440.0?o:1566444395;y=+g[e+8>>2];q=(g[k>>2]=y,c[k>>2]|0);z=y<999999984306749440.0?q:1566444395;m=j>-999999984306749440.0?m:-581039253;o=i>-999999984306749440.0?o:-581039253;q=y>-999999984306749440.0?q:-581039253;y=+g[e+16>>2];x=y<(c[k>>2]=r,+g[k>>2]);l=(g[k>>2]=y,c[k>>2]|0);r=x?l:r;i=+g[e+20>>2];x=i<(c[k>>2]=t,+g[k>>2]);n=(g[k>>2]=i,c[k>>2]|0);t=x?n:t;j=+g[e+24>>2];x=j<(c[k>>2]=z,+g[k>>2]);p=(g[k>>2]=j,c[k>>2]|0);z=x?p:z;x=(c[k>>2]=m,+g[k>>2])>2]=o,+g[k>>2])>2]=q,+g[k>>2])>2];m=y<(c[k>>2]=r,+g[k>>2]);o=(g[k>>2]=y,c[k>>2]|0);r=m?o:r;j=+g[e+36>>2];m=j<(c[k>>2]=t,+g[k>>2]);p=(g[k>>2]=j,c[k>>2]|0);m=m?p:t;i=+g[e+40>>2];l=i<(c[k>>2]=z,+g[k>>2]);n=(g[k>>2]=i,c[k>>2]|0);l=l?n:z;o=(c[k>>2]=x,+g[k>>2])>2]=s,+g[k>>2])>2]=q,+g[k>>2])>2]=o,+g[k>>2]);j=(c[k>>2]=r,+g[k>>2]);if(i-j<2.0000000949949026e-03){o=(g[k>>2]=i+1.0000000474974513e-03,c[k>>2]|0);n=(g[k>>2]=j+-1.0000000474974513e-03,c[k>>2]|0)}else n=r;i=(c[k>>2]=p,+g[k>>2]);j=(c[k>>2]=m,+g[k>>2]);if(i-j<2.0000000949949026e-03){p=(g[k>>2]=i+1.0000000474974513e-03,c[k>>2]|0);m=(g[k>>2]=j+-1.0000000474974513e-03,c[k>>2]|0)}i=(c[k>>2]=q,+g[k>>2]);j=(c[k>>2]=l,+g[k>>2]);if(i-j<2.0000000949949026e-03){q=(g[k>>2]=i+1.0000000474974513e-03,c[k>>2]|0);l=(g[k>>2]=j+-1.0000000474974513e-03,c[k>>2]|0)}r=c[d+8>>2]|0;j=+g[r+4>>2];y=(c[k>>2]=n,+g[k>>2])-j;i=+g[r+8>>2];u=(c[k>>2]=m,+g[k>>2])-i;B=+g[r+12>>2];v=+g[r+36>>2];w=+g[r+40>>2];A=+g[r+44>>2];r=~~(((c[k>>2]=l,+g[k>>2])-B)*A)&65534;j=(c[k>>2]=o,+g[k>>2])-j;i=(c[k>>2]=p,+g[k>>2])-i;q=(~~(((c[k>>2]=q,+g[k>>2])-B)*A+1.0)&65535|1)&65535;o=c[d+4>>2]|0;m=c[o+4>>2]|0;if((m|0)!=(c[o+8>>2]|0)){d=m;z=o+12|0;z=c[z>>2]|0;x=z+(d<<4)|0;b[x>>1]=~~(y*v)&65534;x=z+(d<<4)+2|0;b[x>>1]=~~(u*w)&65534;x=z+(d<<4)+4|0;b[x>>1]=r;x=z+(d<<4)+6|0;b[x>>1]=~~(j*v+1.0)&65535|1;x=z+(d<<4)+8|0;b[x>>1]=~~(i*w+1.0)&65535|1;x=z+(d<<4)+10|0;b[x>>1]=q;d=z+(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0));c[v+400>>2]=a;c[v+400+4>>2]=d;o=+g[e>>2];E=+g[b>>2];n=+g[e+16>>2];j=+g[b+16>>2];m=+g[e+32>>2];F=+g[b+32>>2];w=+g[b+4>>2];G=+g[b+20>>2];x=+g[b+36>>2];t=+g[b+8>>2];r=+g[b+24>>2];p=+g[b+40>>2];D=+g[e+4>>2];C=+g[e+20>>2];B=+g[e+36>>2];A=+g[e+8>>2];z=+g[e+24>>2];y=+g[e+40>>2];g[v+400+8>>2]=o*E+n*j+m*F;g[v+400+12>>2]=o*w+n*G+m*x;g[v+400+16>>2]=o*t+n*r+m*p;g[v+400+20>>2]=0.0;g[v+400+24>>2]=E*D+j*C+F*B;g[v+400+28>>2]=w*D+G*C+x*B;g[v+400+32>>2]=t*D+r*C+p*B;g[v+400+36>>2]=0.0;g[v+400+40>>2]=E*A+j*z+F*y;g[v+400+44>>2]=w*A+G*z+x*y;g[v+400+48>>2]=t*A+r*z+p*y;g[v+400+52>>2]=0.0;p=+g[e+48>>2]-+g[b+48>>2];r=+g[e+52>>2]-+g[b+52>>2];t=+g[e+56>>2]-+g[b+56>>2];x=+g[b>>2];G=+g[e>>2];w=+g[b+16>>2];F=+g[e+16>>2];j=+g[b+32>>2];E=+g[e+32>>2];m=+g[b+4>>2];n=+g[b+20>>2];o=+g[b+36>>2];q=+g[b+8>>2];s=+g[b+24>>2];u=+g[b+40>>2];g[v+400+56>>2]=x*G+w*F+j*E;g[v+400+60>>2]=x*D+w*C+j*B;g[v+400+64>>2]=x*A+w*z+j*y;g[v+400+68>>2]=0.0;g[v+400+72>>2]=G*m+F*n+E*o;g[v+400+76>>2]=D*m+C*n+B*o;g[v+400+80>>2]=A*m+z*n+y*o;g[v+400+84>>2]=0.0;g[v+400+88>>2]=G*q+F*s+E*u;g[v+400+92>>2]=D*q+C*s+B*u;g[v+400+96>>2]=A*q+z*s+y*u;g[v+400+100>>2]=0.0;g[v+400+104>>2]=p*x+r*w+t*j;g[v+400+108>>2]=p*m+r*n+t*o;g[v+400+112>>2]=p*q+r*s+t*u;g[v+400+116>>2]=0.0;c[v+400+120>>2]=80;c[v+400+124>>2]=0;c[v+16+364>>2]=0;c[v+16+128>>2]=0;c[v+16+128+4>>2]=0;c[v+16+128+8>>2]=0;c[v+16+128+12>>2]=0;c[v+16+376>>2]=2;c[v+16+368>>2]=0;g[v+16+144>>2]=0.0;f=Uc(v+16|0,v+400|0,f)|0;if(f|0){c[h>>2]=(f|0)==1?1:2;b=0;i=v;return b|0}f=c[v+16+372>>2]|0;if(!(c[f+32>>2]|0)){q=0.0;p=0.0;o=0.0;n=0.0;m=0.0;j=0.0}else{e=0;q=0.0;p=0.0;o=0.0;n=0.0;m=0.0;j=0.0;do{u=+g[f+16+(e<<2)>>2];a=c[v+400+120>>2]|0;l=c[v+400+124>>2]|0;d=(c[v+400>>2]|0)+(l>>1)|0;if(l&1)a=c[(c[d>>2]|0)+a>>2]|0;ic[a&127](v,d,c[f+(e<<2)>>2]|0);q=q+u*+g[v>>2];o=o+u*+g[v+4>>2];p=p+u*+g[v+8>>2];f=c[(c[v+16+372>>2]|0)+(e<<2)>>2]|0;r=-+g[f>>2];s=-+g[f+4>>2];t=-+g[f+8>>2];f=c[v+400+120>>2]|0;l=c[v+400+124>>2]|0;a=(c[v+400+4>>2]|0)+(l>>1)|0;if(l&1)f=c[(c[a>>2]|0)+f>>2]|0;F=+g[v+400+24>>2]*r+ +g[v+400+28>>2]*s+ +g[v+400+32>>2]*t;E=+g[v+400+40>>2]*r+ +g[v+400+44>>2]*s+ +g[v+400+48>>2]*t;g[v+528>>2]=+g[v+400+8>>2]*r+ +g[v+400+12>>2]*s+ +g[v+400+16>>2]*t;g[v+528+4>>2]=F;g[v+528+8>>2]=E;g[v+528+12>>2]=0.0;ic[f&127](v+544|0,a,v+528|0);E=+g[v+544>>2];F=+g[v+544+4>>2];G=+g[v+544+8>>2];n=n+u*(E*+g[v+400+56>>2]+F*+g[v+400+60>>2]+G*+g[v+400+64>>2]+ +g[v+400+104>>2]);j=j+u*(E*+g[v+400+72>>2]+F*+g[v+400+76>>2]+G*+g[v+400+80>>2]+ +g[v+400+108>>2]);m=m+u*(E*+g[v+400+88>>2]+F*+g[v+400+92>>2]+G*+g[v+400+96>>2]+ +g[v+400+112>>2]);e=e+1|0;f=c[v+16+372>>2]|0}while(e>>>0<(c[f+32>>2]|0)>>>0)}D=q*+g[b+16>>2]+o*+g[b+20>>2]+p*+g[b+24>>2]+ +g[b+52>>2];E=q*+g[b+32>>2]+o*+g[b+36>>2]+p*+g[b+40>>2]+ +g[b+56>>2];g[h+4>>2]=q*+g[b>>2]+o*+g[b+4>>2]+p*+g[b+8>>2]+ +g[b+48>>2];g[h+8>>2]=D;g[h+12>>2]=E;g[h+16>>2]=0.0;E=n*+g[b+16>>2]+j*+g[b+20>>2]+m*+g[b+24>>2]+ +g[b+52>>2];D=n*+g[b+32>>2]+j*+g[b+36>>2]+m*+g[b+40>>2]+ +g[b+56>>2];g[h+20>>2]=n*+g[b>>2]+j*+g[b+4>>2]+m*+g[b+8>>2]+ +g[b+48>>2];g[h+24>>2]=E;g[h+28>>2]=D;g[h+32>>2]=0.0;D=q-n;E=o-j;G=p-m;g[h+48>>2]=0.0;F=+O(+(D*D+E*E+G*G));g[h+52>>2]=F;F=F>9.999999747378752e-05?1.0/F:1.0;g[h+36>>2]=F*D;g[h+40>>2]=F*E;g[h+44>>2]=F*G;b=1;i=v;return b|0}function Kd(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=+h;var j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0.0;j=i;i=i+464|0;li(15711);c[j+128>>2]=c[d>>2];c[j+128+4>>2]=c[d+4>>2];c[j+128+8>>2]=c[d+8>>2];c[j+128+12>>2]=c[d+12>>2];c[j+128+16>>2]=c[d+16>>2];c[j+128+16+4>>2]=c[d+16+4>>2];c[j+128+16+8>>2]=c[d+16+8>>2];c[j+128+16+12>>2]=c[d+16+12>>2];c[j+128+32>>2]=c[d+32>>2];c[j+128+32+4>>2]=c[d+32+4>>2];c[j+128+32+8>>2]=c[d+32+8>>2];c[j+128+32+12>>2]=c[d+32+12>>2];l=j+128+48|0;c[l>>2]=c[d+48>>2];c[l+4>>2]=c[d+48+4>>2];c[l+8>>2]=c[d+48+8>>2];c[l+12>>2]=c[d+48+12>>2];c[j+64>>2]=c[e>>2];c[j+64+4>>2]=c[e+4>>2];c[j+64+8>>2]=c[e+8>>2];c[j+64+12>>2]=c[e+12>>2];c[j+64+16>>2]=c[e+16>>2];c[j+64+16+4>>2]=c[e+16+4>>2];c[j+64+16+8>>2]=c[e+16+8>>2];c[j+64+16+12>>2]=c[e+16+12>>2];c[j+64+32>>2]=c[e+32>>2];c[j+64+32+4>>2]=c[e+32+4>>2];c[j+64+32+8>>2]=c[e+32+8>>2];c[j+64+32+12>>2]=c[e+32+12>>2];k=j+64+48|0;c[k>>2]=c[e+48>>2];c[k+4>>2]=c[e+48+4>>2];c[k+8>>2]=c[e+48+8>>2];c[k+12>>2]=c[e+48+12>>2];Gf(j+128|0,j+64|0,j+256|0,j+192|0);t=+g[j+192>>2];m=t*+g[j+256+4>>2];r=t*+g[j+256+8>>2];g[j>>2]=+g[j+256>>2]*t;g[j+4>>2]=m;g[j+8>>2]=r;g[j+12>>2]=0.0;c[j+256>>2]=0;c[j+256+4>>2]=0;c[j+256+8>>2]=0;c[j+256+12>>2]=0;c[j+192+4>>2]=0;c[j+192+4+4>>2]=0;c[j+192+24>>2]=0;c[j+192+24+4>>2]=0;s=j+192+44|0;c[s>>2]=0;c[s+4>>2]=0;c[s+8>>2]=0;c[s+12>>2]=0;c[s+16>>2]=0;Wg(j+128|0,j+16|0);r=+g[j+16>>2];m=+g[j+16+4>>2];t=+g[j+16+8>>2];q=+g[j+16+12>>2];o=r*(2.0/(r*r+m*m+t*t+q*q));n=m*(2.0/(r*r+m*m+t*t+q*q));p=t*(2.0/(r*r+m*m+t*t+q*q));g[j+192>>2]=1.0-(m*n+t*p);g[j+192+4>>2]=r*n-q*p;g[j+192+8>>2]=r*p+q*n;g[j+192+12>>2]=0.0;g[j+192+16>>2]=r*n+q*p;g[j+192+20>>2]=1.0-(r*o+t*p);g[j+192+24>>2]=m*p-q*o;g[j+192+28>>2]=0.0;g[j+192+32>>2]=r*p-q*n;g[j+192+36>>2]=m*p+q*o;g[j+192+40>>2]=1.0-(r*o+m*n);g[s>>2]=0.0;rh(b,j+192|0,j+256|0,j,j+48|0,j+32|0);c[j+256>>2]=5936;c[j+256+36>>2]=c[d>>2];c[j+256+36+4>>2]=c[d+4>>2];c[j+256+36+8>>2]=c[d+8>>2];c[j+256+36+12>>2]=c[d+12>>2];c[j+256+52>>2]=c[d+16>>2];c[j+256+52+4>>2]=c[d+16+4>>2];c[j+256+52+8>>2]=c[d+16+8>>2];c[j+256+52+12>>2]=c[d+16+12>>2];c[j+256+68>>2]=c[d+32>>2];c[j+256+68+4>>2]=c[d+32+4>>2];c[j+256+68+8>>2]=c[d+32+8>>2];c[j+256+68+12>>2]=c[d+32+12>>2];s=j+256+84|0;c[s>>2]=c[d+48>>2];c[s+4>>2]=c[d+48+4>>2];c[s+8>>2]=c[d+48+8>>2];c[s+12>>2]=c[d+48+12>>2];c[j+256+100>>2]=c[e>>2];c[j+256+100+4>>2]=c[e+4>>2];c[j+256+100+8>>2]=c[e+8>>2];c[j+256+100+12>>2]=c[e+12>>2];c[j+256+116>>2]=c[e+16>>2];c[j+256+116+4>>2]=c[e+16+4>>2];c[j+256+116+8>>2]=c[e+16+8>>2];c[j+256+116+12>>2]=c[e+16+12>>2];c[j+256+132>>2]=c[e+32>>2];c[j+256+132+4>>2]=c[e+32+4>>2];c[j+256+132+8>>2]=c[e+32+8>>2];c[j+256+132+12>>2]=c[e+32+12>>2];d=j+256+148|0;c[d>>2]=c[e+48>>2];c[d+4>>2]=c[e+48+4>>2];c[d+8>>2]=c[e+48+8>>2];c[d+12>>2]=c[e+48+12>>2];c[j+256+180>>2]=a;c[j+256+184>>2]=f;g[j+256+188>>2]=h;c[j+256+192>>2]=b;n=+g[d>>2]-+g[s>>2];m=+g[j+256+152>>2]-+g[j+256+88>>2];o=+g[j+256+156>>2]-+g[j+256+92>>2];h=1.0/+O(+(n*n+m*m+o*o));r=n*h==0.0?999999984306749440.0:1.0/(n*h);g[j+256+4>>2]=r;q=m*h==0.0?999999984306749440.0:1.0/(m*h);g[j+256+8>>2]=q;p=o*h==0.0?999999984306749440.0:1.0/(o*h);g[j+256+12>>2]=p;c[j+256+20>>2]=r<0.0&1;c[j+256+24>>2]=q<0.0&1;c[j+256+28>>2]=p<0.0&1;g[j+256+32>>2]=o*o*h+(n*n*h+m*m*h);b=c[a+68>>2]|0;Qb[c[(c[b>>2]|0)+24>>2]&7](b,l,k,j+256|0,j+48|0,j+32|0);b=c[2357]|0;a=(c[b+16>>2]|0)+-1|0;c[b+16>>2]=a;if(a|0){i=j;return}do if(c[b+4>>2]|0){tb(j+256|0,0)|0;s=c[6434]|0;g[b+8>>2]=+g[b+8>>2]+ +(((c[j+256+4>>2]|0)-(c[s+4>>2]|0)+(((c[j+256>>2]|0)-(c[s>>2]|0)|0)*1e6|0)-(c[b+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[b+16>>2]|0)){b=c[2357]|0;break}else{i=j;return}}while(0);c[2357]=c[b+20>>2];i=j;return} +function xc(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,j=0.0,l=0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0,P=0.0,Q=0,R=0.0,S=0.0,T=0.0,U=0.0,V=0,X=0.0,Y=0,Z=0.0,_=0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0,ea=0,fa=0.0,ga=0,ha=0.0,ia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>2];ba=+g[Fa+48+32>>2];$=+g[E>>2];X=+g[Fa+48+20>>2];Z=+g[Fa+48+36>>2];fa=+g[Fa+48+8>>2];ha=+g[Fa+48+24>>2];na=+g[Fa+48+40>>2];g[Fa+484>>2]=(ia+ka)*2.0*.5;g[Fa+484+4>>2]=(ja+la)*2.0*.5;g[Fa+484+8>>2]=ma*.5;g[Fa+472>>2]=(qa+sa)*2.0*.5;g[Fa+472+4>>2]=(ra+pa)*2.0*.5;g[Fa+472+8>>2]=wa*.5;za=+g[Fa>>2];ta=+g[Fa+16>>2];va=+g[Fa+32>>2];ya=+g[Fa+4>>2];oa=+g[Fa+20>>2];ua=+g[Fa+36>>2];xa=+g[Fa+8>>2];Da=+g[Fa+24>>2];Ea=+g[Fa+40>>2];y=+N(+(ca*za+aa*ta+ba*va));A=+N(+(ca*ya+aa*oa+ba*ua));R=+N(+(ca*xa+aa*Da+ba*Ea));z=+N(+(za*$+ta*X+va*Z));B=+N(+(ya*$+oa*X+ua*Z));S=+N(+(xa*$+Da*X+Ea*Z));T=+N(+(za*fa+ta*ha+va*na));U=+N(+(ya*fa+oa*ha+ua*na));C=+N(+(xa*fa+Da*ha+Ea*na));h=+N(+(D*ca+M*aa+P*ba))-(wa*.5*R+((ia+ka)*2.0*.5+y*(qa+sa)*2.0*.5+A*(ra+pa)*2.0*.5));if(h>0.0){i=Fa;return}if(h>-3402823466385288598117041.0e14){n=1;l=D*ca+M*aa+P*ba<0.0&1;e=Fa+48|0}else{n=0;l=0;e=0;h=-3402823466385288598117041.0e14}j=+N(+(D*$+M*X+P*Z))-((ja+la)*2.0*.5+z*(qa+sa)*2.0*.5+B*(ra+pa)*2.0*.5+S*wa*.5);if(j>0.0){i=Fa;return}if(j>h){n=2;l=D*$+M*X+P*Z<0.0&1;e=E;h=j}j=+N(+(D*fa+M*ha+P*na))-(ma*.5+T*(qa+sa)*2.0*.5+U*(ra+pa)*2.0*.5+C*wa*.5);if(j>0.0){i=Fa;return}if(j>h){n=3;l=D*fa+M*ha+P*na<0.0&1;e=Fa+48+8|0;h=j}j=+N(+(D*za+M*ta+P*va))-((qa+sa)*2.0*.5+(y*(ia+ka)*2.0*.5+z*(ja+la)*2.0*.5+T*ma*.5));if(j>0.0){i=Fa;return}if(j>h){n=4;l=D*za+M*ta+P*va<0.0&1;e=Fa;h=j}j=+N(+(D*ya+M*oa+P*ua))-((ra+pa)*2.0*.5+(A*(ia+ka)*2.0*.5+B*(ja+la)*2.0*.5+U*ma*.5));if(j>0.0){i=Fa;return}if(j>h){n=5;l=D*ya+M*oa+P*ua<0.0&1;e=Fa+4|0}else j=h;h=+N(+(D*xa+M*Da+P*Ea))-(wa*.5+(R*(ia+ka)*2.0*.5+S*(ja+la)*2.0*.5+C*ma*.5));if(h>0.0){i=Fa;return}if(h>j){n=6;l=D*xa+M*Da+P*Ea<0.0&1;u=Fa+8|0}else{u=e;h=j}j=(D*fa+M*ha+P*na)*(za*$+ta*X+va*Z)-(D*$+M*X+P*Z)*(za*fa+ta*ha+va*na);m=+N(+j)-((T+9.999999747378752e-06)*(ja+la)*2.0*.5+(z+9.999999747378752e-06)*ma*.5+(R+9.999999747378752e-06)*(ra+pa)*2.0*.5+(A+9.999999747378752e-06)*wa*.5);if(m>1.1920928955078125e-07){i=Fa;return}p=(za*fa+ta*ha+va*na)*(za*fa+ta*ha+va*na)+0.0;v=(za*$+ta*X+va*Z)*(za*$+ta*X+va*Z);o=+O(+(v+p));if(o>1.1920928955078125e-07?m/o*1.0499999523162842>h:0){a=(g[k>>2]=0.0/o,c[k>>2]|0);f=(g[k>>2]=-(za*fa+ta*ha+va*na)/o,c[k>>2]|0);n=7;l=j<0.0&1;e=(g[k>>2]=(za*$+ta*X+va*Z)/o,c[k>>2]|0);u=0;h=m/o}else{a=0;f=0;e=0}j=(D*fa+M*ha+P*na)*(ya*$+oa*X+ua*Z)-(D*$+M*X+P*Z)*(ya*fa+oa*ha+ua*na);m=+N(+j)-((U+9.999999747378752e-06)*(ja+la)*2.0*.5+(B+9.999999747378752e-06)*ma*.5+(R+9.999999747378752e-06)*(qa+sa)*2.0*.5+(y+9.999999747378752e-06)*wa*.5);if(m>1.1920928955078125e-07){i=Fa;return}q=(ya*fa+oa*ha+ua*na)*(ya*fa+oa*ha+ua*na)+0.0;w=(ya*$+oa*X+ua*Z)*(ya*$+oa*X+ua*Z);o=+O(+(w+q));if(o>1.1920928955078125e-07?m/o*1.0499999523162842>h:0){a=(g[k>>2]=0.0/o,c[k>>2]|0);f=(g[k>>2]=-(ya*fa+oa*ha+ua*na)/o,c[k>>2]|0);n=8;l=j<0.0&1;e=(g[k>>2]=(ya*$+oa*X+ua*Z)/o,c[k>>2]|0);u=0;h=m/o}j=(D*fa+M*ha+P*na)*(xa*$+Da*X+Ea*Z)-(D*$+M*X+P*Z)*(xa*fa+Da*ha+Ea*na);m=+N(+j)-((C+9.999999747378752e-06)*(ja+la)*2.0*.5+(S+9.999999747378752e-06)*ma*.5+(A+9.999999747378752e-06)*(qa+sa)*2.0*.5+(y+9.999999747378752e-06)*(ra+pa)*2.0*.5);if(m>1.1920928955078125e-07){i=Fa;return}s=(xa*fa+Da*ha+Ea*na)*(xa*fa+Da*ha+Ea*na)+0.0;x=(xa*$+Da*X+Ea*Z)*(xa*$+Da*X+Ea*Z);o=+O(+(x+s));if(o>1.1920928955078125e-07?m/o*1.0499999523162842>h:0){a=(g[k>>2]=0.0/o,c[k>>2]|0);f=(g[k>>2]=-(xa*fa+Da*ha+Ea*na)/o,c[k>>2]|0);n=9;l=j<0.0&1;e=(g[k>>2]=(xa*$+Da*X+Ea*Z)/o,c[k>>2]|0);u=0;h=m/o}j=(D*ca+M*aa+P*ba)*(za*fa+ta*ha+va*na)-(D*fa+M*ha+P*na)*(ca*za+aa*ta+ba*va);o=+N(+j)-((T+9.999999747378752e-06)*(ia+ka)*2.0*.5+(y+9.999999747378752e-06)*ma*.5+(S+9.999999747378752e-06)*(ra+pa)*2.0*.5+(B+9.999999747378752e-06)*wa*.5);if(o>1.1920928955078125e-07){i=Fa;return}t=(ca*za+aa*ta+ba*va)*(ca*za+aa*ta+ba*va);m=+O(+(t+p));do if(m>1.1920928955078125e-07){if(!(o/m*1.0499999523162842>h))break;a=(g[k>>2]=(za*fa+ta*ha+va*na)/m,c[k>>2]|0);f=(g[k>>2]=0.0/m,c[k>>2]|0);n=10;l=j<0.0&1;e=(g[k>>2]=-(ca*za+aa*ta+ba*va)/m,c[k>>2]|0);u=0;h=o/m}while(0);j=(D*ca+M*aa+P*ba)*(ya*fa+oa*ha+ua*na)-(D*fa+M*ha+P*na)*(ca*ya+aa*oa+ba*ua);o=+N(+j)-((U+9.999999747378752e-06)*(ia+ka)*2.0*.5+(A+9.999999747378752e-06)*ma*.5+(S+9.999999747378752e-06)*(qa+sa)*2.0*.5+(z+9.999999747378752e-06)*wa*.5);if(o>1.1920928955078125e-07){i=Fa;return}r=(ca*ya+aa*oa+ba*ua)*(ca*ya+aa*oa+ba*ua);m=+O(+(r+q));do if(m>1.1920928955078125e-07){if(!(o/m*1.0499999523162842>h))break;a=(g[k>>2]=(ya*fa+oa*ha+ua*na)/m,c[k>>2]|0);f=(g[k>>2]=0.0/m,c[k>>2]|0);n=11;l=j<0.0&1;e=(g[k>>2]=-(ca*ya+aa*oa+ba*ua)/m,c[k>>2]|0);u=0;h=o/m}while(0);j=(D*ca+M*aa+P*ba)*(xa*fa+Da*ha+Ea*na)-(D*fa+M*ha+P*na)*(ca*xa+aa*Da+ba*Ea);o=+N(+j)-((C+9.999999747378752e-06)*(ia+ka)*2.0*.5+(R+9.999999747378752e-06)*ma*.5+(B+9.999999747378752e-06)*(qa+sa)*2.0*.5+(z+9.999999747378752e-06)*(ra+pa)*2.0*.5);if(o>1.1920928955078125e-07){i=Fa;return}p=(ca*xa+aa*Da+ba*Ea)*(ca*xa+aa*Da+ba*Ea);m=+O(+(p+s));do if(m>1.1920928955078125e-07){if(!(o/m*1.0499999523162842>h))break;a=(g[k>>2]=(xa*fa+Da*ha+Ea*na)/m,c[k>>2]|0);f=(g[k>>2]=0.0/m,c[k>>2]|0);n=12;l=j<0.0&1;e=(g[k>>2]=-(ca*xa+aa*Da+ba*Ea)/m,c[k>>2]|0);u=0;h=o/m}while(0);j=(D*$+M*X+P*Z)*(ca*za+aa*ta+ba*va)-(D*ca+M*aa+P*ba)*(za*$+ta*X+va*Z);o=+N(+j)-((z+9.999999747378752e-06)*(ia+ka)*2.0*.5+(y+9.999999747378752e-06)*(ja+la)*2.0*.5+(C+9.999999747378752e-06)*(ra+pa)*2.0*.5+(U+9.999999747378752e-06)*wa*.5);if(o>1.1920928955078125e-07){i=Fa;return}m=+O(+(t+v+0.0));do if(m>1.1920928955078125e-07){if(!(o/m*1.0499999523162842>h))break;a=(g[k>>2]=-(za*$+ta*X+va*Z)/m,c[k>>2]|0);f=(g[k>>2]=(ca*za+aa*ta+ba*va)/m,c[k>>2]|0);n=13;l=j<0.0&1;e=(g[k>>2]=0.0/m,c[k>>2]|0);u=0;h=o/m}while(0);j=(D*$+M*X+P*Z)*(ca*ya+aa*oa+ba*ua)-(D*ca+M*aa+P*ba)*(ya*$+oa*X+ua*Z);o=+N(+j)-((B+9.999999747378752e-06)*(ia+ka)*2.0*.5+(A+9.999999747378752e-06)*(ja+la)*2.0*.5+(C+9.999999747378752e-06)*(qa+sa)*2.0*.5+(T+9.999999747378752e-06)*wa*.5);if(o>1.1920928955078125e-07){i=Fa;return}m=+O(+(r+w+0.0));do if(m>1.1920928955078125e-07){if(!(o/m*1.0499999523162842>h))break;a=(g[k>>2]=-(ya*$+oa*X+ua*Z)/m,c[k>>2]|0);f=(g[k>>2]=(ca*ya+aa*oa+ba*ua)/m,c[k>>2]|0);n=14;l=j<0.0&1;e=(g[k>>2]=0.0/m,c[k>>2]|0);u=0;h=o/m}while(0);m=(D*$+M*X+P*Z)*(ca*xa+aa*Da+ba*Ea)-(D*ca+M*aa+P*ba)*(xa*$+Da*X+Ea*Z);o=+N(+m)-((S+9.999999747378752e-06)*(ia+ka)*2.0*.5+(R+9.999999747378752e-06)*(ja+la)*2.0*.5+(U+9.999999747378752e-06)*(qa+sa)*2.0*.5+(T+9.999999747378752e-06)*(ra+pa)*2.0*.5);if(o>1.1920928955078125e-07){i=Fa;return}j=+O(+(p+x+0.0));do if(j>1.1920928955078125e-07){if(!(o/j*1.0499999523162842>h)){Aa=55;break}a=(g[k>>2]=-(xa*$+Da*X+Ea*Z)/j,c[k>>2]|0);f=(g[k>>2]=(ca*xa+aa*Da+ba*Ea)/j,c[k>>2]|0);n=15;l=m<0.0&1;e=(g[k>>2]=0.0/j,c[k>>2]|0);h=o/j;Aa=58}else Aa=55;while(0);do if((Aa|0)==55){if(!n){i=Fa;return}if(!u){Aa=58;break}e=c[u>>2]|0;a=c[u+16>>2]|0;Ca=c[u+32>>2]|0;j=(c[k>>2]=e,+g[k>>2]);m=(c[k>>2]=a,+g[k>>2]);o=(c[k>>2]=Ca,+g[k>>2]);f=l;l=Ca;D=h}while(0);if((Aa|0)==58){ca=(c[k>>2]=a,+g[k>>2]);o=(c[k>>2]=f,+g[k>>2]);D=(c[k>>2]=e,+g[k>>2]);j=ca*+g[Fa+48>>2]+o*+g[E>>2]+D*fa;e=(g[k>>2]=j,c[k>>2]|0);m=ca*+g[Fa+48+16>>2]+o*+g[Fa+48+20>>2]+D*ha;a=(g[k>>2]=m,c[k>>2]|0);D=ca*+g[Fa+48+32>>2]+o*+g[Fa+48+36>>2]+D*na;o=D;f=l;l=(g[k>>2]=D,c[k>>2]|0);D=h}if(!f){Ba=a;Ca=l}else{e=(g[k>>2]=-j,c[k>>2]|0);Ba=(g[k>>2]=-m,c[k>>2]|0);Ca=(g[k>>2]=-o,c[k>>2]|0)}if((n|0)>6){C=(c[k>>2]=e,+g[k>>2]);B=(c[k>>2]=Ba,+g[k>>2]);A=(c[k>>2]=Ca,+g[k>>2]);j=+g[Fa+48>>2];t=+g[Fa+48+16>>2];w=+g[Fa+48+32>>2];v=(C*j+B*t+A*w>0.0?1.0:-1.0)*(ia+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;if(!u)break;else f=f+-1|0}e=(H|0)==(Fa+336|0)?Fa+528|0:Fa+336|0;if((a|0)<=0){f=0;break}E=a;f=0;b=H;a=e;while(1){l=b+(I<<2)|0;j=+g[l>>2];h=+g[F>>2];if(j>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];f=f+1|0;if(f&8|0)break a;h=+g[F>>2];j=+g[l>>2];a=a+8|0}u=(E|0)>1;n=b;b=b+8|0;l=u?b:H;m=+g[l+(I<<2)>>2];if(j>2];g[a+(G<<2)>>2]=Ea+(h-j)*((+g[l+(G<<2)>>2]-Ea)/(m-j));c[a+(I<<2)>>2]=c[F>>2];f=f+1|0;if(!(f&8))a=a+8|0;else break a}if(!u)break;else E=E+-1|0}}else{e=(H|0)==(Fa+336|0)?Fa+528|0:Fa+336|0;f=0}while(0);I=I+1|0;if((I|0)>=2)break;else{b=e;H=(e|0)==(Fa+336|0)?Fa+528|0:Fa+336|0}}if((e|0)!=(Fa+336|0))_m(Fa+336|0,e|0,f<<3|0)|0;if((f|0)>=1){v=1.0/((T*D+R*y+S*z)*(M*C+A*w+B*x)-(M*D+A*y+B*z)*(T*C+R*w+S*x));t=+g[Q+(K<<2)>>2];s=+g[J>>2];p=+g[L>>2];q=+g[_+((V|4)<<2)>>2];r=+g[_+((Y|4)<<2)>>2];o=+g[_+((V|8)<<2)>>2];m=+g[_+((Y|8)<<2)>>2];a=0;e=0;do{_=e<<1;h=+g[Fa+336+(_<<2)>>2];j=+g[Fa+336+((_|1)<<2)>>2];ya=(M*C+A*w+B*x)*v*(h-U)-(T*C+R*w+S*x)*v*(j-P);Ea=(T*D+R*y+S*z)*v*(j-P)-(M*D+A*y+B*z)*v*(h-U);_=a*3|0;za=$+ya*s+Ea*p;g[Fa+240+(_<<2)>>2]=za;Da=Z+ya*q+Ea*r;g[Fa+240+(_+1<<2)>>2]=Da;Ea=X+ya*o+Ea*m;g[Fa+240+(_+2<<2)>>2]=Ea;Ea=t-(ca*za+ba*Da+aa*Ea);g[Fa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l=e?f:l;f=f+1|0;if((f|0)==(a|0))break;else j=e?h:j}switch(a|0){case 1:{e=Fa+144|0;f=Fa+144|0;a=1;Aa=111;break c}case 2:{e=Fa+144|0;f=Fa+144|0;a=2;j=(+g[Fa+336>>2]+ +g[Fa+336+8>>2])*.5;h=(+g[Fa+336+4>>2]+ +g[Fa+336+12>>2])*.5;Aa=116;break c}default:{}}e=a+-1|0;h=0.0;j=0.0;r=0.0;f=0;do{_=f<<1;ya=+g[Fa+336+(_<<2)>>2];za=+g[Fa+336+(_+3<<2)>>2];Da=+g[Fa+336+(_+2<<2)>>2];Ea=+g[Fa+336+((_|1)<<2)>>2];h=h+(ya*za-Da*Ea);j=j+(ya+Da)*(ya*za-Da*Ea);r=r+(za+Ea)*(ya*za-Da*Ea);f=f+1|0}while((f|0)!=(e|0));_=a<<1;m=+g[Fa+336+(_+-2<<2)>>2];o=+g[Fa+336+4>>2];p=+g[Fa+336>>2];q=+g[Fa+336+(_+-1<<2)>>2];h=h+(m*o-p*q);if(+N(+h)>1.1920928955078125e-07)h=1.0/(h*3.0);else h=999999984306749440.0;if((a|0)>0){u=Fa+144|0;f=Fa+144|0;n=Fa+528|0;j=h*(j+(m*o-p*q)*(m+p));h=h*(r+(m*o-p*q)*(q+o));Aa=119;break}e=Fa+144|0;f=0;u=a}else{e=Fa+144|0;f=Fa+144|0;l=0;Aa=111}while(0);if((Aa|0)==111){j=+g[Fa+336>>2];h=+g[Fa+336+4>>2];Aa=116}if((Aa|0)==116){u=e;n=Fa+528|0;Aa=119}if((Aa|0)==119){e=0;do{Aa=e<<1;g[Fa+528+(e<<2)>>2]=+W(+(+g[Fa+336+((Aa|1)<<2)>>2]-h),+(+g[Fa+336+(Aa<<2)>>2]-j));e=e+1|0}while((e|0)!=(a|0));e=0;do{c[Fa+496+(e<<2)>>2]=1;e=e+1|0}while((e|0)!=(a|0));e=u;f=1;u=a}a=Fa+496+(l<<2)|0;c[a>>2]=0;c[e>>2]=l;d:do if((E|0)>1){o=+g[Fa+528+(l<<2)>>2];if(f){f=Fa+144+4|0;n=1}else{e=Fa+144+4|0;f=1;while(1){c[e>>2]=l;c[a>>2]=0;f=f+1|0;if((f|0)==(E|0))break d;else e=e+4|0}}while(1){m=6.2831854820251465/+(E|0)*+(n|0)+o;m=m>3.1415927410125732?m+-6.2831854820251465:m;c[f>>2]=l;e=l;a=0;j=1.0e9;while(1){do if(!(c[Fa+496+(a<<2)>>2]|0))h=j;else{h=+N(+(+g[Fa+528+(a<<2)>>2]-m));h=h>3.1415927410125732?6.2831854820251465-h:h;if(!(h>2]=a;e=a}while(0);a=a+1|0;if((a|0)==(u|0))break;else j=h}c[Fa+496+(e<<2)>>2]=0;n=n+1|0;if((n|0)==(E|0))break;else f=f+4|0}}while(0);if((E|0)>0){f=ga+8|0;j=(c[k>>2]=Ba,+g[k>>2]);h=(c[k>>2]=Ca,+g[k>>2]);if(da){e=0;do{Ca=c[Fa+144+(e<<2)>>2]|0;g[Fa+528>>2]=+g[Fa+240+(Ca*3<<2)>>2]+ +g[ga>>2];g[Fa+528+4>>2]=+g[Fa+240+((Ca*3|0)+1<<2)>>2]+ +g[ea>>2];g[Fa+528+8>>2]=+g[Fa+240+((Ca*3|0)+2<<2)>>2]+ +g[f>>2];Ba=c[(c[d>>2]|0)+16>>2]|0;g[Fa+128>>2]=-fa;g[Fa+128+4>>2]=-j;g[Fa+128+8>>2]=-h;g[Fa+128+12>>2]=0.0;hc[Ba&15](d,Fa+128|0,Fa+528|0,-+g[Fa+208+(Ca<<2)>>2]);e=e+1|0}while((e|0)<(E|0))}else{e=0;do{Ba=c[Fa+144+(e<<2)>>2]|0;ya=+g[Fa+240+(Ba*3<<2)>>2]+ +g[ga>>2];g[Fa+528>>2]=ya;za=+g[Fa+240+((Ba*3|0)+1<<2)>>2]+ +g[ea>>2];g[Fa+528+4>>2]=za;Da=+g[Fa+240+((Ba*3|0)+2<<2)>>2]+ +g[f>>2];g[Fa+528+8>>2]=Da;Ca=c[(c[d>>2]|0)+16>>2]|0;g[Fa+112>>2]=-fa;g[Fa+112+4>>2]=-j;g[Fa+112+8>>2]=-h;g[Fa+112+12>>2]=0.0;Ea=+g[Fa+208+(Ba<<2)>>2];g[Fa+96>>2]=ya-fa*Ea;g[Fa+96+4>>2]=za-Ea*j;g[Fa+96+8>>2]=Da-Ea*h;g[Fa+96+12>>2]=0.0;hc[Ca&15](d,Fa+112|0,Fa+96|0,-Ea);e=e+1|0}while((e|0)<(E|0))}}}while(0)}i=Fa;return}function yc(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;do if(a>>>0<245){n=a>>>0<11?16:a+11&-8;g=c[6438]|0;if(g>>>(n>>>3)&3|0){a=25792+((g>>>(n>>>3)&1^1)+(n>>>3)<<1<<2)|0;b=c[a+8>>2]|0;d=c[b+8>>2]|0;do if((a|0)!=(d|0)){if(d>>>0<(c[6442]|0)>>>0)Va();if((c[d+12>>2]|0)==(b|0)){c[d+12>>2]=a;c[a+8>>2]=d;break}else Va()}else c[6438]=g&~(1<<(g>>>(n>>>3)&1^1)+(n>>>3));while(0);D=(g>>>(n>>>3)&1^1)+(n>>>3)<<3;c[b+4>>2]=D|3;c[b+D+4>>2]=c[b+D+4>>2]|1;D=b+8|0;return D|0}b=c[6440]|0;if(n>>>0>b>>>0){if(g>>>(n>>>3)|0){a=g>>>(n>>>3)<<(n>>>3)&(2<<(n>>>3)|0-(2<<(n>>>3)));f=((a&0-a)+-1|0)>>>(((a&0-a)+-1|0)>>>12&16);e=f>>>(f>>>5&8)>>>(f>>>(f>>>5&8)>>>2&4);e=(f>>>5&8|((a&0-a)+-1|0)>>>12&16|f>>>(f>>>5&8)>>>2&4|e>>>1&2|e>>>(e>>>1&2)>>>1&1)+(e>>>(e>>>1&2)>>>(e>>>(e>>>1&2)>>>1&1))|0;f=c[25792+(e<<1<<2)+8>>2]|0;a=c[f+8>>2]|0;do if((25792+(e<<1<<2)|0)!=(a|0)){if(a>>>0<(c[6442]|0)>>>0)Va();if((c[a+12>>2]|0)==(f|0)){c[a+12>>2]=25792+(e<<1<<2);c[25792+(e<<1<<2)+8>>2]=a;h=c[6440]|0;break}else Va()}else{c[6438]=g&~(1<>2]=n|3;c[f+n+4>>2]=(e<<3)-n|1;c[f+n+((e<<3)-n)>>2]=(e<<3)-n;if(h|0){d=c[6443]|0;b=h>>>3;a=c[6438]|0;if(a&1<>2]|0;if(a>>>0<(c[6442]|0)>>>0)Va();else{i=25792+(b<<1<<2)+8|0;j=a}}else{c[6438]=a|1<>2]=d;c[j+12>>2]=d;c[d+8>>2]=j;c[d+12>>2]=25792+(b<<1<<2)}c[6440]=(e<<3)-n;c[6443]=f+n;D=f+8|0;return D|0}a=c[6439]|0;if(a){i=((a&0-a)+-1|0)>>>(((a&0-a)+-1|0)>>>12&16);j=i>>>(i>>>5&8)>>>(i>>>(i>>>5&8)>>>2&4);j=c[26056+((i>>>5&8|((a&0-a)+-1|0)>>>12&16|i>>>(i>>>5&8)>>>2&4|j>>>1&2|j>>>(j>>>1&2)>>>1&1)+(j>>>(j>>>1&2)>>>(j>>>(j>>>1&2)>>>1&1))<<2)>>2]|0;i=(c[j+4>>2]&-8)-n|0;b=j;while(1){a=c[b+16>>2]|0;if(!a){a=c[b+20>>2]|0;if(!a)break}b=(c[a+4>>2]&-8)-n|0;D=b>>>0>>0;i=D?b:i;b=a;j=D?a:j}f=c[6442]|0;if(j>>>0>>0)Va();h=j+n|0;if(j>>>0>=h>>>0)Va();g=c[j+24>>2]|0;a=c[j+12>>2]|0;do if((a|0)==(j|0)){b=j+20|0;a=c[b>>2]|0;if(!a){b=j+16|0;a=c[b>>2]|0;if(!a){k=0;break}}while(1){d=a+20|0;e=c[d>>2]|0;if(e|0){a=e;b=d;continue}d=a+16|0;e=c[d>>2]|0;if(!e)break;else{a=e;b=d}}if(b>>>0>>0)Va();else{c[b>>2]=0;k=a;break}}else{b=c[j+8>>2]|0;if(b>>>0>>0)Va();if((c[b+12>>2]|0)!=(j|0))Va();if((c[a+8>>2]|0)==(j|0)){c[b+12>>2]=a;c[a+8>>2]=b;k=a;break}else Va()}while(0);do if(g|0){a=c[j+28>>2]|0;if((j|0)==(c[26056+(a<<2)>>2]|0)){c[26056+(a<<2)>>2]=k;if(!k){c[6439]=c[6439]&~(1<>>0<(c[6442]|0)>>>0)Va();if((c[g+16>>2]|0)==(j|0))c[g+16>>2]=k;else c[g+20>>2]=k;if(!k)break}b=c[6442]|0;if(k>>>0>>0)Va();c[k+24>>2]=g;a=c[j+16>>2]|0;do if(a|0)if(a>>>0>>0)Va();else{c[k+16>>2]=a;c[a+24>>2]=k;break}while(0);a=c[j+20>>2]|0;if(a|0)if(a>>>0<(c[6442]|0)>>>0)Va();else{c[k+20>>2]=a;c[a+24>>2]=k;break}}while(0);if(i>>>0<16){D=i+n|0;c[j+4>>2]=D|3;D=j+D+4|0;c[D>>2]=c[D>>2]|1}else{c[j+4>>2]=n|3;c[h+4>>2]=i|1;c[h+i>>2]=i;b=c[6440]|0;if(b|0){d=c[6443]|0;a=c[6438]|0;if(a&1<<(b>>>3)){a=c[25792+(b>>>3<<1<<2)+8>>2]|0;if(a>>>0<(c[6442]|0)>>>0)Va();else{l=25792+(b>>>3<<1<<2)+8|0;m=a}}else{c[6438]=a|1<<(b>>>3);l=25792+(b>>>3<<1<<2)+8|0;m=25792+(b>>>3<<1<<2)|0}c[l>>2]=d;c[m+12>>2]=d;c[d+8>>2]=m;c[d+12>>2]=25792+(b>>>3<<1<<2)}c[6440]=i;c[6443]=h}D=j+8|0;return D|0}}}else if(a>>>0<=4294967231){n=a+11&-8;i=c[6439]|0;if(i){if((a+11|0)>>>8)if(n>>>0>16777215)h=31;else{h=(a+11|0)>>>8<<((((a+11|0)>>>8)+1048320|0)>>>16&8);h=14-((h+520192|0)>>>16&4|(((a+11|0)>>>8)+1048320|0)>>>16&8|((h<<((h+520192|0)>>>16&4))+245760|0)>>>16&2)+(h<<((h+520192|0)>>>16&4)<<(((h<<((h+520192|0)>>>16&4))+245760|0)>>>16&2)>>>15)|0;h=n>>>(h+7|0)&1|h<<1}else h=0;b=c[26056+(h<<2)>>2]|0;a:do if(!b){d=0-n|0;a=0;b=0;w=86}else{d=0-n|0;a=0;f=n<<((h|0)==31?0:25-(h>>>1)|0);g=b;b=0;while(1){e=c[g+4>>2]&-8;if((e-n|0)>>>0>>0)if((e|0)==(n|0)){d=e-n|0;a=g;b=g;w=90;break a}else{d=e-n|0;b=g}e=c[g+20>>2]|0;g=c[g+16+(f>>>31<<2)>>2]|0;a=(e|0)==0|(e|0)==(g|0)?a:e;e=(g|0)==0;if(e){w=86;break}else f=f<<(e&1^1)}}while(0);if((w|0)==86){if((a|0)==0&(b|0)==0){a=2<>>(l>>>12&16)>>>(l>>>(l>>>12&16)>>>5&8);a=m>>>(m>>>2&4)>>>(m>>>(m>>>2&4)>>>1&2);a=c[26056+((l>>>(l>>>12&16)>>>5&8|l>>>12&16|m>>>2&4|m>>>(m>>>2&4)>>>1&2|a>>>1&1)+(a>>>(a>>>1&1))<<2)>>2]|0}if(!a){i=d;j=b}else w=90}if((w|0)==90)while(1){w=0;m=(c[a+4>>2]&-8)-n|0;e=m>>>0>>0;d=e?m:d;b=e?a:b;e=c[a+16>>2]|0;if(e|0){a=e;w=90;continue}a=c[a+20>>2]|0;if(!a){i=d;j=b;break}else w=90}if((j|0)!=0?i>>>0<((c[6440]|0)-n|0)>>>0:0){f=c[6442]|0;if(j>>>0>>0)Va();h=j+n|0;if(j>>>0>=h>>>0)Va();g=c[j+24>>2]|0;a=c[j+12>>2]|0;do if((a|0)==(j|0)){b=j+20|0;a=c[b>>2]|0;if(!a){b=j+16|0;a=c[b>>2]|0;if(!a){p=0;break}}while(1){d=a+20|0;e=c[d>>2]|0;if(e|0){a=e;b=d;continue}d=a+16|0;e=c[d>>2]|0;if(!e)break;else{a=e;b=d}}if(b>>>0>>0)Va();else{c[b>>2]=0;p=a;break}}else{b=c[j+8>>2]|0;if(b>>>0>>0)Va();if((c[b+12>>2]|0)!=(j|0))Va();if((c[a+8>>2]|0)==(j|0)){c[b+12>>2]=a;c[a+8>>2]=b;p=a;break}else Va()}while(0);do if(g|0){a=c[j+28>>2]|0;if((j|0)==(c[26056+(a<<2)>>2]|0)){c[26056+(a<<2)>>2]=p;if(!p){c[6439]=c[6439]&~(1<>>0<(c[6442]|0)>>>0)Va();if((c[g+16>>2]|0)==(j|0))c[g+16>>2]=p;else c[g+20>>2]=p;if(!p)break}b=c[6442]|0;if(p>>>0>>0)Va();c[p+24>>2]=g;a=c[j+16>>2]|0;do if(a|0)if(a>>>0>>0)Va();else{c[p+16>>2]=a;c[a+24>>2]=p;break}while(0);a=c[j+20>>2]|0;if(a|0)if(a>>>0<(c[6442]|0)>>>0)Va();else{c[p+20>>2]=a;c[a+24>>2]=p;break}}while(0);do if(i>>>0>=16){c[j+4>>2]=n|3;c[h+4>>2]=i|1;c[h+i>>2]=i;b=i>>>3;if(i>>>0<256){a=c[6438]|0;if(a&1<>2]|0;if(a>>>0<(c[6442]|0)>>>0)Va();else{q=25792+(b<<1<<2)+8|0;r=a}}else{c[6438]=a|1<>2]=h;c[r+12>>2]=h;c[h+8>>2]=r;c[h+12>>2]=25792+(b<<1<<2);break}a=i>>>8;if(a)if(i>>>0>16777215)d=31;else{d=a<<((a+1048320|0)>>>16&8)<<(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4);d=14-(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4|(a+1048320|0)>>>16&8|(d+245760|0)>>>16&2)+(d<<((d+245760|0)>>>16&2)>>>15)|0;d=i>>>(d+7|0)&1|d<<1}else d=0;e=26056+(d<<2)|0;c[h+28>>2]=d;c[h+16+4>>2]=0;c[h+16>>2]=0;a=c[6439]|0;b=1<>2]=h;c[h+24>>2]=e;c[h+12>>2]=h;c[h+8>>2]=h;break}d=i<<((d|0)==31?0:25-(d>>>1)|0);e=c[e>>2]|0;while(1){if((c[e+4>>2]&-8|0)==(i|0)){w=148;break}b=e+16+(d>>>31<<2)|0;a=c[b>>2]|0;if(!a){w=145;break}else{d=d<<1;e=a}}if((w|0)==145)if(b>>>0<(c[6442]|0)>>>0)Va();else{c[b>>2]=h;c[h+24>>2]=e;c[h+12>>2]=h;c[h+8>>2]=h;break}else if((w|0)==148){a=e+8|0;b=c[a>>2]|0;D=c[6442]|0;if(b>>>0>=D>>>0&e>>>0>=D>>>0){c[b+12>>2]=h;c[a>>2]=h;c[h+8>>2]=b;c[h+12>>2]=e;c[h+24>>2]=0;break}else Va()}}else{D=i+n|0;c[j+4>>2]=D|3;D=j+D+4|0;c[D>>2]=c[D>>2]|1}while(0);D=j+8|0;return D|0}}}else n=-1;while(0);d=c[6440]|0;if(d>>>0>=n>>>0){a=d-n|0;b=c[6443]|0;if(a>>>0>15){D=b+n|0;c[6443]=D;c[6440]=a;c[D+4>>2]=a|1;c[D+a>>2]=a;c[b+4>>2]=n|3}else{c[6440]=0;c[6443]=0;c[b+4>>2]=d|3;c[b+d+4>>2]=c[b+d+4>>2]|1}D=b+8|0;return D|0}a=c[6441]|0;if(a>>>0>n>>>0){B=a-n|0;c[6441]=B;D=c[6444]|0;C=D+n|0;c[6444]=C;c[C+4>>2]=B|1;c[D+4>>2]=n|3;D=D+8|0;return D|0}do if(!(c[6556]|0)){a=gb(30)|0;if(!(a+-1&a)){c[6558]=a;c[6557]=a;c[6559]=-1;c[6560]=-1;c[6561]=0;c[6549]=0;c[6556]=(sb(0)|0)&-16^1431655768;break}else Va()}while(0);f=n+48|0;d=c[6558]|0;g=n+47|0;h=d+g&0-d;if(h>>>0<=n>>>0){D=0;return D|0}a=c[6548]|0;if(a|0?(r=c[6546]|0,(r+h|0)>>>0<=r>>>0|(r+h|0)>>>0>a>>>0):0){D=0;return D|0}b:do if(!(c[6549]&4)){b=c[6444]|0;c:do if(b){e=26200;while(1){a=c[e>>2]|0;if(a>>>0<=b>>>0?(o=e+4|0,(a+(c[o>>2]|0)|0)>>>0>b>>>0):0)break;a=c[e+8>>2]|0;if(!a){w=173;break c}else e=a}a=d+g-(c[6441]|0)&0-d;if(a>>>0<2147483647){b=ab(a|0)|0;if((b|0)==((c[e>>2]|0)+(c[o>>2]|0)|0)){if((b|0)!=(-1|0)){h=b;g=a;w=193;break b}}else w=183}}else w=173;while(0);do if((w|0)==173?(s=ab(0)|0,(s|0)!=(-1|0)):0){a=c[6557]|0;if(!(a+-1&s))a=h;else a=h-s+(a+-1+s&0-a)|0;b=c[6546]|0;d=b+a|0;if(a>>>0>n>>>0&a>>>0<2147483647){r=c[6548]|0;if(r|0?d>>>0<=b>>>0|d>>>0>r>>>0:0)break;b=ab(a|0)|0;if((b|0)==(s|0)){h=s;g=a;w=193;break b}else w=183}}while(0);d:do if((w|0)==183){d=0-a|0;do if(f>>>0>a>>>0&(a>>>0<2147483647&(b|0)!=(-1|0))?(t=c[6558]|0,t=g-a+t&0-t,t>>>0<2147483647):0)if((ab(t|0)|0)==(-1|0)){ab(d|0)|0;break d}else{a=t+a|0;break}while(0);if((b|0)!=(-1|0)){h=b;g=a;w=193;break b}}while(0);c[6549]=c[6549]|4;w=190}else w=190;while(0);if((((w|0)==190?h>>>0<2147483647:0)?(u=ab(h|0)|0,v=ab(0)|0,u>>>0>>0&((u|0)!=(-1|0)&(v|0)!=(-1|0))):0)?(v-u|0)>>>0>(n+40|0)>>>0:0){h=u;g=v-u|0;w=193}if((w|0)==193){a=(c[6546]|0)+g|0;c[6546]=a;if(a>>>0>(c[6547]|0)>>>0)c[6547]=a;k=c[6444]|0;do if(k){f=26200;while(1){a=c[f>>2]|0;b=f+4|0;d=c[b>>2]|0;if((h|0)==(a+d|0)){w=203;break}e=c[f+8>>2]|0;if(!e)break;else f=e}if(((w|0)==203?(c[f+12>>2]&8|0)==0:0)?k>>>0>>0&k>>>0>=a>>>0:0){c[b>>2]=d+g;C=(k+8&7|0)==0?0:0-(k+8)&7;D=g-C+(c[6441]|0)|0;c[6444]=k+C;c[6441]=D;c[k+C+4>>2]=D|1;c[k+C+D+4>>2]=40;c[6445]=c[6560];break}a=c[6442]|0;if(h>>>0>>0){c[6442]=h;j=h}else j=a;b=h+g|0;a=26200;while(1){if((c[a>>2]|0)==(b|0)){w=211;break}a=c[a+8>>2]|0;if(!a){b=26200;break}}if((w|0)==211)if(!(c[a+12>>2]&8)){c[a>>2]=h;m=a+4|0;c[m>>2]=(c[m>>2]|0)+g;m=h+8|0;m=h+((m&7|0)==0?0:0-m&7)|0;a=b+((b+8&7|0)==0?0:0-(b+8)&7)|0;l=m+n|0;i=a-m-n|0;c[m+4>>2]=n|3;do if((a|0)!=(k|0)){if((a|0)==(c[6443]|0)){D=(c[6440]|0)+i|0;c[6440]=D;c[6443]=l;c[l+4>>2]=D|1;c[l+D>>2]=D;break}h=c[a+4>>2]|0;if((h&3|0)==1){e:do if(h>>>0>=256){g=c[a+24>>2]|0;b=c[a+12>>2]|0;do if((b|0)==(a|0)){b=c[a+16+4>>2]|0;if(!b){b=c[a+16>>2]|0;if(!b){B=0;break}else f=a+16|0}else f=a+16+4|0;while(1){d=b+20|0;e=c[d>>2]|0;if(e|0){b=e;f=d;continue}d=b+16|0;e=c[d>>2]|0;if(!e)break;else{b=e;f=d}}if(f>>>0>>0)Va();else{c[f>>2]=0;B=b;break}}else{d=c[a+8>>2]|0;if(d>>>0>>0)Va();if((c[d+12>>2]|0)!=(a|0))Va();if((c[b+8>>2]|0)==(a|0)){c[d+12>>2]=b;c[b+8>>2]=d;B=b;break}else Va()}while(0);if(!g)break;b=c[a+28>>2]|0;do if((a|0)!=(c[26056+(b<<2)>>2]|0)){if(g>>>0<(c[6442]|0)>>>0)Va();if((c[g+16>>2]|0)==(a|0))c[g+16>>2]=B;else c[g+20>>2]=B;if(!B)break e}else{c[26056+(b<<2)>>2]=B;if(B|0)break;c[6439]=c[6439]&~(1<>>0>>0)Va();c[B+24>>2]=g;b=c[a+16>>2]|0;do if(b|0)if(b>>>0>>0)Va();else{c[B+16>>2]=b;c[b+24>>2]=B;break}while(0);b=c[a+16+4>>2]|0;if(!b)break;if(b>>>0<(c[6442]|0)>>>0)Va();else{c[B+20>>2]=b;c[b+24>>2]=B;break}}else{b=c[a+8>>2]|0;d=c[a+12>>2]|0;do if((b|0)!=(25792+(h>>>3<<1<<2)|0)){if(b>>>0>>0)Va();if((c[b+12>>2]|0)==(a|0))break;Va()}while(0);if((d|0)==(b|0)){c[6438]=c[6438]&~(1<<(h>>>3));break}do if((d|0)==(25792+(h>>>3<<1<<2)|0))z=d+8|0;else{if(d>>>0>>0)Va();if((c[d+8>>2]|0)==(a|0)){z=d+8|0;break}Va()}while(0);c[b+12>>2]=d;c[z>>2]=b}while(0);a=a+(h&-8)|0;f=(h&-8)+i|0}else f=i;b=a+4|0;c[b>>2]=c[b>>2]&-2;c[l+4>>2]=f|1;c[l+f>>2]=f;b=f>>>3;if(f>>>0<256){a=c[6438]|0;do if(!(a&1<>2]|0;if(a>>>0>=(c[6442]|0)>>>0){C=25792+(b<<1<<2)+8|0;D=a;break}Va()}while(0);c[C>>2]=l;c[D+12>>2]=l;c[l+8>>2]=D;c[l+12>>2]=25792+(b<<1<<2);break}a=f>>>8;do if(!a)d=0;else{if(f>>>0>16777215){d=31;break}d=a<<((a+1048320|0)>>>16&8)<<(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4);d=14-(((a<<((a+1048320|0)>>>16&8))+520192|0)>>>16&4|(a+1048320|0)>>>16&8|(d+245760|0)>>>16&2)+(d<<((d+245760|0)>>>16&2)>>>15)|0;d=f>>>(d+7|0)&1|d<<1}while(0);e=26056+(d<<2)|0;c[l+28>>2]=d;c[l+16+4>>2]=0;c[l+16>>2]=0;a=c[6439]|0;b=1<>2]=l;c[l+24>>2]=e;c[l+12>>2]=l;c[l+8>>2]=l;break}d=f<<((d|0)==31?0:25-(d>>>1)|0);e=c[e>>2]|0;while(1){if((c[e+4>>2]&-8|0)==(f|0)){w=281;break}b=e+16+(d>>>31<<2)|0;a=c[b>>2]|0;if(!a){w=278;break}else{d=d<<1;e=a}}if((w|0)==278)if(b>>>0<(c[6442]|0)>>>0)Va();else{c[b>>2]=l;c[l+24>>2]=e;c[l+12>>2]=l;c[l+8>>2]=l;break}else if((w|0)==281){a=e+8|0;b=c[a>>2]|0;D=c[6442]|0;if(b>>>0>=D>>>0&e>>>0>=D>>>0){c[b+12>>2]=l;c[a>>2]=l;c[l+8>>2]=b;c[l+12>>2]=e;c[l+24>>2]=0;break}else Va()}}else{D=(c[6441]|0)+i|0;c[6441]=D;c[6444]=l;c[l+4>>2]=D|1}while(0);D=m+8|0;return D|0}else b=26200;while(1){a=c[b>>2]|0;if(a>>>0<=k>>>0?(x=a+(c[b+4>>2]|0)|0,x>>>0>k>>>0):0)break;b=c[b+8>>2]|0}f=x+-47+((x+-47+8&7|0)==0?0:0-(x+-47+8)&7)|0;f=f>>>0<(k+16|0)>>>0?k:f;a=h+8|0;a=(a&7|0)==0?0:0-a&7;D=h+a|0;a=g+-40-a|0;c[6444]=D;c[6441]=a;c[D+4>>2]=a|1;c[D+a+4>>2]=40;c[6445]=c[6560];c[f+4>>2]=27;c[f+8>>2]=c[6550];c[f+8+4>>2]=c[6551];c[f+8+8>>2]=c[6552];c[f+8+12>>2]=c[6553];c[6550]=h;c[6551]=g;c[6553]=0;c[6552]=f+8;a=f+24|0;do{a=a+4|0;c[a>>2]=7}while((a+4|0)>>>0>>0);if((f|0)!=(k|0)){c[f+4>>2]=c[f+4>>2]&-2;c[k+4>>2]=f-k|1;c[f>>2]=f-k;if((f-k|0)>>>0<256){b=25792+((f-k|0)>>>3<<1<<2)|0;a=c[6438]|0;if(a&1<<((f-k|0)>>>3)){a=c[b+8>>2]|0;if(a>>>0<(c[6442]|0)>>>0)Va();else{y=b+8|0;A=a}}else{c[6438]=a|1<<((f-k|0)>>>3);y=b+8|0;A=b}c[y>>2]=k;c[A+12>>2]=k;c[k+8>>2]=A;c[k+12>>2]=b;break}if((f-k|0)>>>8)if((f-k|0)>>>0>16777215)d=31;else{d=(f-k|0)>>>8<<((((f-k|0)>>>8)+1048320|0)>>>16&8);d=14-((d+520192|0)>>>16&4|(((f-k|0)>>>8)+1048320|0)>>>16&8|((d<<((d+520192|0)>>>16&4))+245760|0)>>>16&2)+(d<<((d+520192|0)>>>16&4)<<(((d<<((d+520192|0)>>>16&4))+245760|0)>>>16&2)>>>15)|0;d=(f-k|0)>>>(d+7|0)&1|d<<1}else d=0;e=26056+(d<<2)|0;c[k+28>>2]=d;c[k+20>>2]=0;c[k+16>>2]=0;a=c[6439]|0;b=1<>2]=k;c[k+24>>2]=e;c[k+12>>2]=k;c[k+8>>2]=k;break}d=f-k<<((d|0)==31?0:25-(d>>>1)|0);e=c[e>>2]|0;while(1){if((c[e+4>>2]&-8|0)==(f-k|0)){w=307;break}b=e+16+(d>>>31<<2)|0;a=c[b>>2]|0;if(!a){w=304;break}else{d=d<<1;e=a}}if((w|0)==304)if(b>>>0<(c[6442]|0)>>>0)Va();else{c[b>>2]=k;c[k+24>>2]=e;c[k+12>>2]=k;c[k+8>>2]=k;break}else if((w|0)==307){a=e+8|0;b=c[a>>2]|0;D=c[6442]|0;if(b>>>0>=D>>>0&e>>>0>=D>>>0){c[b+12>>2]=k;c[a>>2]=k;c[k+8>>2]=b;c[k+12>>2]=e;c[k+24>>2]=0;break}else Va()}}}else{D=c[6442]|0;if((D|0)==0|h>>>0>>0)c[6442]=h;c[6550]=h;c[6551]=g;c[6553]=0;c[6447]=c[6556];c[6446]=-1;a=0;do{D=25792+(a<<1<<2)|0;c[D+12>>2]=D;c[D+8>>2]=D;a=a+1|0}while((a|0)!=32);D=h+8|0;D=(D&7|0)==0?0:0-D&7;C=h+D|0;D=g+-40-D|0;c[6444]=C;c[6441]=D;c[C+4>>2]=D|1;c[C+D+4>>2]=40;c[6445]=c[6560]}while(0);a=c[6441]|0;if(a>>>0>n>>>0){B=a-n|0;c[6441]=B;D=c[6444]|0;C=D+n|0;c[6444]=C;c[C+4>>2]=B|1;c[D+4>>2]=n|3;D=D+8|0;return D|0}}if(!0)a=25748;else a=c[(ib()|0)+64>>2]|0;c[a>>2]=12;D=0;return D|0}function zc(b,d,e,f){b=b|0;d=d|0;e=e|0;f=+f;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0.0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0;P=i;i=i+448|0;if(!(a[b+527>>0]|0)){i=P;return}N=c[b+28>>2]|0;x=+g[b+348>>2];w=+g[b+352>>2];D=+g[b+356>>2];y=+g[N+52>>2];z=x*+g[N+4>>2]+w*+g[N+8>>2]+D*+g[N+12>>2]+y;A=+g[N+56>>2];B=x*+g[N+20>>2]+w*+g[N+24>>2]+D*+g[N+28>>2]+A;C=+g[N+60>>2];D=x*+g[N+36>>2]+w*+g[N+40>>2]+D*+g[N+44>>2]+C;N=c[b+32>>2]|0;w=+g[b+412>>2];x=+g[b+416>>2];l=+g[b+420>>2];E=+g[N+52>>2];F=w*+g[N+4>>2]+x*+g[N+8>>2]+l*+g[N+12>>2]+E;G=+g[N+56>>2];H=w*+g[N+20>>2]+x*+g[N+24>>2]+l*+g[N+28>>2]+G;k=+g[N+60>>2];l=w*+g[N+36>>2]+x*+g[N+40>>2]+l*+g[N+44>>2]+k;if(!(a[b+524>>0]|0)){u=+g[d+192>>2]+ +g[d+80>>2];w=+g[d+196>>2]+ +g[d+84>>2];q=+g[d+200>>2]+ +g[d+88>>2];x=+g[e+192>>2]+ +g[e+80>>2];p=+g[e+196>>2]+ +g[e+84>>2];n=+g[e+200>>2]+ +g[e+88>>2];m=+g[d+176>>2]+ +g[d+64>>2]+((D-C)*w-(B-A)*q)-(+g[e+176>>2]+ +g[e+64>>2]+((l-k)*p-(H-G)*n));n=+g[d+180>>2]+ +g[d+68>>2]+((z-y)*q-(D-C)*u)-(+g[e+180>>2]+ +g[e+68>>2]+((F-E)*n-(l-k)*x));p=+g[d+184>>2]+ +g[d+72>>2]+((B-A)*u-(z-y)*w)-(+g[e+184>>2]+ +g[e+72>>2]+((H-G)*x-(F-E)*p));o=(c[d+240>>2]|0)==0;v=0;do{x=1.0/+g[b+48+(v*84|0)+80>>2];r=b+48+(v*84|0)|0;w=+g[r>>2];s=b+48+(v*84|0)+4|0;u=+g[s>>2];t=b+48+(v*84|0)+8|0;q=+g[t>>2];q=x*(((z-F)*w+(B-H)*u+(D-l)*q)*-.30000001192092896/f)-x*(m*w+n*u+p*q);g[b+36>>2]=+g[b+36>>2]+q;u=+g[t>>2];w=+g[s>>2];x=+g[r>>2];h=c[b+28>>2]|0;j=+g[h+344>>2];if(!o){S=((B-A)*u-(D-C)*w)*+g[h+296>>2]+((D-C)*x-(z-y)*u)*+g[h+300>>2]+((z-y)*w-(B-A)*x)*+g[h+304>>2];Q=((B-A)*u-(D-C)*w)*+g[h+280>>2]+((D-C)*x-(z-y)*u)*+g[h+284>>2]+((z-y)*w-(B-A)*x)*+g[h+288>>2];R=((B-A)*u-(D-C)*w)*+g[h+264>>2]+((D-C)*x-(z-y)*u)*+g[h+268>>2]+((z-y)*w-(B-A)*x)*+g[h+272>>2];U=q*w*j*+g[d+116>>2];T=q*u*j*+g[d+120>>2];g[d+64>>2]=q*x*j*+g[d+112>>2]+ +g[d+64>>2];g[d+68>>2]=U+ +g[d+68>>2];g[d+72>>2]=T+ +g[d+72>>2];Q=Q*q*+g[d+100>>2];j=S*q*+g[d+104>>2];g[d+80>>2]=R*q*+g[d+96>>2]+ +g[d+80>>2];g[d+84>>2]=Q+ +g[d+84>>2];g[d+88>>2]=j+ +g[d+88>>2]}h=c[b+32>>2]|0;j=+g[h+344>>2];if(c[e+240>>2]|0){U=((H-G)*u-(l-k)*w)*+g[h+296>>2]+((l-k)*x-(F-E)*u)*+g[h+300>>2]+((F-E)*w-(H-G)*x)*+g[h+304>>2];T=((H-G)*u-(l-k)*w)*+g[h+280>>2]+((l-k)*x-(F-E)*u)*+g[h+284>>2]+((F-E)*w-(H-G)*x)*+g[h+288>>2];S=((H-G)*u-(l-k)*w)*+g[h+264>>2]+((l-k)*x-(F-E)*u)*+g[h+268>>2]+((F-E)*w-(H-G)*x)*+g[h+272>>2];Q=j*+g[s>>2]*-q*+g[e+116>>2];R=j*+g[t>>2]*-q*+g[e+120>>2];g[e+64>>2]=+g[e+112>>2]*j*+g[r>>2]*-q+ +g[e+64>>2];g[e+68>>2]=Q+ +g[e+68>>2];g[e+72>>2]=R+ +g[e+72>>2];T=T*+g[e+100>>2]*-q;U=U*+g[e+104>>2]*-q;g[e+80>>2]=S*+g[e+96>>2]*-q+ +g[e+80>>2];g[e+84>>2]=T+ +g[e+84>>2];g[e+88>>2]=U+ +g[e+88>>2]}v=v+1|0}while((v|0)!=3)}do if(!(a[b+552>>0]|0)){j=+g[b+440>>2];if(!(j>1.1920928955078125e-07)){I=d+80|0;o=d+196|0;J=d+84|0;r=d+200|0;K=d+88|0;s=e+192|0;L=e+80|0;t=e+196|0;M=e+84|0;v=e+200|0;N=e+88|0;h=d+192|0;break}k=+g[e+192>>2]+ +g[e+80>>2]-(+g[d+192>>2]+ +g[d+80>>2]);l=+g[e+196>>2]+ +g[e+84>>2]-(+g[d+196>>2]+ +g[d+84>>2]);m=+g[e+200>>2]+ +g[e+88>>2]-(+g[d+200>>2]+ +g[d+88>>2]);if(k*k+l*l+m*m>1.1920928955078125e-07){C=1.0/+O(+(k*k+l*l+m*m));h=c[b+28>>2]|0;p=+g[h+264>>2];q=+g[h+280>>2];u=+g[h+296>>2];w=+g[h+268>>2];x=+g[h+284>>2];y=+g[h+300>>2];z=+g[h+272>>2];A=+g[h+288>>2];B=+g[h+304>>2];h=c[b+32>>2]|0;j=j*(1.0/(k*C*(p*k*C+l*C*q+m*C*u)+l*C*(k*C*w+l*C*x+m*C*y)+m*C*(k*C*z+l*C*A+m*C*B)+(k*C*(k*C*+g[h+264>>2]+l*C*+g[h+280>>2]+m*C*+g[h+296>>2])+l*C*(k*C*+g[h+268>>2]+l*C*+g[h+284>>2]+m*C*+g[h+300>>2])+m*C*(k*C*+g[h+272>>2]+l*C*+g[h+288>>2]+m*C*+g[h+304>>2]))));C=+O(+(m*j*m*j+(k*j*k*j+l*j*l*j)));n=1.0/C*k*j;k=1.0/C*l*j;j=1.0/C*m*j;if(c[d+240>>2]|0){U=C*0.0*+g[d+116>>2];T=C*0.0*+g[d+120>>2];g[d+64>>2]=C*0.0*+g[d+112>>2]+ +g[d+64>>2];g[d+68>>2]=U+ +g[d+68>>2];g[d+72>>2]=T+ +g[d+72>>2];T=(n*q+k*x+j*A)*C*+g[d+100>>2];U=(n*u+k*y+j*B)*C*+g[d+104>>2];g[d+80>>2]=(n*p+k*w+j*z)*C*+g[d+96>>2]+ +g[d+80>>2];g[d+84>>2]=T+ +g[d+84>>2];g[d+88>>2]=U+ +g[d+88>>2];h=c[b+32>>2]|0}if(c[e+240>>2]|0){U=n*+g[h+296>>2]+k*+g[h+300>>2]+j*+g[h+304>>2];T=n*+g[h+280>>2]+k*+g[h+284>>2]+j*+g[h+288>>2];S=n*+g[h+264>>2]+k*+g[h+268>>2]+j*+g[h+272>>2];Q=C*-0.0*+g[e+116>>2];R=C*-0.0*+g[e+120>>2];g[e+64>>2]=C*-0.0*+g[e+112>>2]+ +g[e+64>>2];g[e+68>>2]=Q+ +g[e+68>>2];g[e+72>>2]=R+ +g[e+72>>2];T=T*+g[e+100>>2]*-C;U=U*+g[e+104>>2]*-C;g[e+80>>2]=S*+g[e+96>>2]*-C+ +g[e+80>>2];g[e+84>>2]=T+ +g[e+84>>2];g[e+88>>2]=U+ +g[e+88>>2];I=d+80|0;o=d+196|0;J=d+84|0;r=d+200|0;K=d+88|0;s=e+192|0;L=e+80|0;t=e+196|0;M=e+84|0;v=e+200|0;N=e+88|0;h=d+192|0}else{I=d+80|0;o=d+196|0;J=d+84|0;r=d+200|0;K=d+88|0;s=e+192|0;L=e+80|0;t=e+196|0;M=e+84|0;v=e+200|0;N=e+88|0;h=d+192|0}}else{I=d+80|0;o=d+196|0;J=d+84|0;r=d+200|0;K=d+88|0;s=e+192|0;L=e+80|0;t=e+196|0;M=e+84|0;v=e+200|0;N=e+88|0;h=d+192|0}}else{M=c[b+28>>2]|0;c[P+352>>2]=c[M+4>>2];c[P+352+4>>2]=c[M+4+4>>2];c[P+352+8>>2]=c[M+4+8>>2];c[P+352+12>>2]=c[M+4+12>>2];c[P+352+16>>2]=c[M+20>>2];c[P+352+16+4>>2]=c[M+20+4>>2];c[P+352+16+8>>2]=c[M+20+8>>2];c[P+352+16+12>>2]=c[M+20+12>>2];c[P+352+32>>2]=c[M+36>>2];c[P+352+32+4>>2]=c[M+36+4>>2];c[P+352+32+8>>2]=c[M+36+8>>2];c[P+352+32+12>>2]=c[M+36+12>>2];c[P+352+48>>2]=c[M+52>>2];c[P+352+48+4>>2]=c[M+52+4>>2];c[P+352+48+8>>2]=c[M+52+8>>2];c[P+352+48+12>>2]=c[M+52+12>>2];M=c[b+32>>2]|0;c[P+288>>2]=c[M+4>>2];c[P+288+4>>2]=c[M+4+4>>2];c[P+288+8>>2]=c[M+4+8>>2];c[P+288+12>>2]=c[M+4+12>>2];c[P+288+16>>2]=c[M+20>>2];c[P+288+16+4>>2]=c[M+20+4>>2];c[P+288+16+8>>2]=c[M+20+8>>2];c[P+288+16+12>>2]=c[M+20+12>>2];c[P+288+32>>2]=c[M+36>>2];c[P+288+32+4>>2]=c[M+36+4>>2];c[P+288+32+8>>2]=c[M+36+8>>2];c[P+288+32+12>>2]=c[M+36+12>>2];c[P+288+48>>2]=c[M+52>>2];c[P+288+48+4>>2]=c[M+52+4>>2];c[P+288+48+8>>2]=c[M+52+8>>2];c[P+288+48+12>>2]=c[M+52+12>>2];S=+g[d+196>>2]+ +g[d+84>>2];u=+g[d+200>>2]+ +g[d+88>>2];g[P+272>>2]=+g[d+192>>2]+ +g[d+80>>2];g[P+272+4>>2]=S;g[P+272+8>>2]=u;g[P+272+12>>2]=0.0;u=+g[e+196>>2]+ +g[e+84>>2];S=+g[e+200>>2]+ +g[e+88>>2];g[P+256>>2]=+g[e+192>>2]+ +g[e+80>>2];g[P+256+4>>2]=u;g[P+256+8>>2]=S;g[P+256+12>>2]=0.0;c[P+192>>2]=1065353216;M=P+192+4|0;c[M>>2]=0;c[M+4>>2]=0;c[M+8>>2]=0;c[M+12>>2]=0;c[P+192+20>>2]=1065353216;N=P+192+24|0;c[N>>2]=0;c[N+4>>2]=0;c[N+8>>2]=0;c[N+12>>2]=0;c[P+192+40>>2]=1065353216;K=P+192+44|0;c[K>>2]=0;c[K+4>>2]=0;c[K+8>>2]=0;c[K+12>>2]=0;c[K+16>>2]=0;Zg(P+352|0,0.0,0.0,0.0,P+272|0,f,P+192|0);c[P+128>>2]=1065353216;K=P+128+4|0;c[K>>2]=0;c[K+4>>2]=0;c[K+8>>2]=0;c[K+12>>2]=0;c[P+128+20>>2]=1065353216;L=P+128+24|0;c[L>>2]=0;c[L+4>>2]=0;c[L+8>>2]=0;c[L+12>>2]=0;c[P+128+40>>2]=1065353216;J=P+128+44|0;c[J>>2]=0;c[J+4>>2]=0;c[J+8>>2]=0;c[J+12>>2]=0;c[J+16>>2]=0;Zg(P+288|0,0.0,0.0,0.0,P+256|0,f,P+128|0);S=+g[b+556>>2];u=+g[b+560>>2];T=+g[b+564>>2];w=+g[b+568>>2];F=S*(2.0/(S*S+u*u+T*T+w*w));A=u*(2.0/(S*S+u*u+T*T+w*w));G=T*(2.0/(S*S+u*u+T*T+w*w));W=+g[b+364>>2];V=+g[b+368>>2];Z=+g[b+372>>2];k=Z*(S*G-w*A)+(V*(S*A+w*G)+W*(1.0-(u*A+T*G)));l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]*x*q+z*q*+g[N+280>>2]+B*q*+g[N+296>>2])+z*q*(x*q*+g[N+268>>2]+z*q*+g[N+284>>2]+B*q*+g[N+300>>2])+B*q*(x*q*+g[N+272>>2]+z*q*+g[N+288>>2]+B*q*+g[N+304>>2])}else{j=0.0;l=0.0;n=0.0;q=0.0}if(y*y+A*A+C*C>1.1920928955078125e-07){u=1.0/+O(+(y*y+A*A+C*C));N=c[b+32>>2]|0;k=y*u;m=A*u;p=C*u;u=y*u*(+g[N+264>>2]*y*u+A*u*+g[N+280>>2]+C*u*+g[N+296>>2])+A*u*(y*u*+g[N+268>>2]+A*u*+g[N+284>>2]+C*u*+g[N+300>>2])+C*u*(y*u*+g[N+272>>2]+A*u*+g[N+288>>2]+C*u*+g[N+304>>2])}else{k=0.0;m=0.0;p=0.0;u=0.0}w=q*j+u*k;k=q*l+u*m;j=q*n+u*p;if(w*w+k*k+j*j>1.1920928955078125e-07){n=1.0/+O(+(w*w+k*k+j*j));o=c[b+28>>2]|0;l=w*n*(+g[o+264>>2]*w*n+k*n*+g[o+280>>2]+j*n*+g[o+296>>2])+k*n*(w*n*+g[o+268>>2]+k*n*+g[o+284>>2]+j*n*+g[o+300>>2])+j*n*(w*n*+g[o+272>>2]+k*n*+g[o+288>>2]+j*n*+g[o+304>>2]);h=c[b+32>>2]|0;n=w*n*(w*n*+g[h+264>>2]+k*n*+g[h+280>>2]+j*n*+g[h+296>>2])+k*n*(w*n*+g[h+268>>2]+k*n*+g[h+284>>2]+j*n*+g[h+300>>2])+j*n*(w*n*+g[h+272>>2]+k*n*+g[h+288>>2]+j*n*+g[h+304>>2]);k=(x*l-y*n)*(1.0/((l+n)*(l+n)));u=(z*l-A*n)*(1.0/((l+n)*(l+n)));n=(B*l-C*n)*(1.0/((l+n)*(l+n)));j=+g[b+572>>2];if(!(j>=0.0))j=u;else{l=(a[b+553>>0]|0)==0?j:j/l;m=+g[b+576>>2];p=+g[b+580>>2];q=+g[b+584>>2];j=+O(+((k+m)*(k+m)+(u+p)*(u+p)+(n+q)*(n+q)));if(j>l){k=l*(k+m)*(1.0/j)-m;n=l*(n+q)*(1.0/j)-q;j=l*(u+p)*(1.0/j)-p}else j=u;g[b+576>>2]=k+m;g[b+580>>2]=j+p;g[b+584>>2]=n+q}m=+O(+(k*k+j*j+n*n));l=k*(1.0/m);k=j*(1.0/m);j=n*(1.0/m);if(c[d+240>>2]|0){aa=l*+g[o+296>>2]+k*+g[o+300>>2]+j*+g[o+304>>2];$=l*+g[o+280>>2]+k*+g[o+284>>2]+j*+g[o+288>>2];_=l*+g[o+264>>2]+k*+g[o+268>>2]+j*+g[o+272>>2];Y=m*0.0*+g[d+116>>2];Z=m*0.0*+g[d+120>>2];g[d+64>>2]=m*0.0*+g[d+112>>2]+ +g[d+64>>2];g[d+68>>2]=Y+ +g[d+68>>2];g[d+72>>2]=Z+ +g[d+72>>2];$=$*m*+g[d+100>>2];aa=aa*m*+g[d+104>>2];g[d+80>>2]=_*m*+g[d+96>>2]+ +g[d+80>>2];g[d+84>>2]=$+ +g[d+84>>2];g[d+88>>2]=aa+ +g[d+88>>2];h=c[b+32>>2]|0}if(c[e+240>>2]|0){aa=l*+g[h+296>>2]+k*+g[h+300>>2]+j*+g[h+304>>2];$=l*+g[h+280>>2]+k*+g[h+284>>2]+j*+g[h+288>>2];_=l*+g[h+264>>2]+k*+g[h+268>>2]+j*+g[h+272>>2];Y=m*-0.0*+g[e+116>>2];Z=m*-0.0*+g[e+120>>2];g[e+64>>2]=m*-0.0*+g[e+112>>2]+ +g[e+64>>2];g[e+68>>2]=Y+ +g[e+68>>2];g[e+72>>2]=Z+ +g[e+72>>2];$=$*+g[e+100>>2]*-m;aa=aa*+g[e+104>>2]*-m;g[e+80>>2]=_*+g[e+96>>2]*-m+ +g[e+80>>2];g[e+84>>2]=$+ +g[e+84>>2];g[e+88>>2]=aa+ +g[e+88>>2]}}I=d+80|0;o=d+196|0;J=d+84|0;r=d+200|0;K=d+88|0;s=e+192|0;L=e+80|0;t=e+196|0;M=e+84|0;v=e+200|0;N=e+88|0;h=d+192|0}while(0);z=+g[h>>2]+ +g[I>>2];y=+g[o>>2]+ +g[J>>2];x=+g[r>>2]+ +g[K>>2];w=+g[s>>2]+ +g[L>>2];u=+g[t>>2]+ +g[M>>2];q=+g[v>>2]+ +g[N>>2];if(a[b+526>>0]|0){k=+g[b+528>>2];j=k*+g[b+504>>2]*+g[b+432>>2]/f;l=+g[b+460>>2];m=+g[b+464>>2];n=+g[b+468>>2];if((w-z)*l+(u-y)*m+(q-x)*n>0.0)j=j+k*((w-z)*l+(u-y)*m+(q-x)*n)*+g[b+436>>2];$=+g[b+516>>2];_=$+j*+g[b+492>>2];_=_>0.0?_:0.0;g[b+516>>2]=_;Z=+g[b+536>>2];k=+g[b+540>>2];aa=+g[b+544>>2];j=l*(_-$)*Z+m*(_-$)*k+(_-$)*n*aa;p=+O(+(((_-$)*n-aa*j)*((_-$)*n-aa*j)+((l*(_-$)-Z*j)*(l*(_-$)-Z*j)+(m*(_-$)-k*j)*(m*(_-$)-k*j))));l=1.0/p*(l*(_-$)-Z*j);k=1.0/p*(m*(_-$)-k*j);j=1.0/p*((_-$)*n-aa*j);h=c[b+28>>2]|0;if(c[d+240>>2]|0){aa=l*+g[h+296>>2]+k*+g[h+300>>2]+j*+g[h+304>>2];$=l*+g[h+280>>2]+k*+g[h+284>>2]+j*+g[h+288>>2];_=l*+g[h+264>>2]+k*+g[h+268>>2]+j*+g[h+272>>2];Y=p*0.0*+g[d+116>>2];Z=p*0.0*+g[d+120>>2];g[d+64>>2]=p*0.0*+g[d+112>>2]+ +g[d+64>>2];g[d+68>>2]=Y+ +g[d+68>>2];g[d+72>>2]=Z+ +g[d+72>>2];$=$*p*+g[d+100>>2];aa=aa*p*+g[d+104>>2];g[I>>2]=_*p*+g[d+96>>2]+ +g[I>>2];g[J>>2]=$+ +g[J>>2];g[K>>2]=aa+ +g[K>>2]}h=c[b+32>>2]|0;if(c[e+240>>2]|0){aa=l*+g[h+296>>2]+k*+g[h+300>>2]+j*+g[h+304>>2];$=l*+g[h+280>>2]+k*+g[h+284>>2]+j*+g[h+288>>2];_=l*+g[h+264>>2]+k*+g[h+268>>2]+j*+g[h+272>>2];Y=p*-0.0*+g[e+116>>2];Z=p*-0.0*+g[e+120>>2];g[e+64>>2]=p*-0.0*+g[e+112>>2]+ +g[e+64>>2];g[e+68>>2]=Y+ +g[e+68>>2];g[e+72>>2]=Z+ +g[e+72>>2];$=$*+g[e+100>>2]*-p;aa=aa*+g[e+104>>2]*-p;g[L>>2]=_*+g[e+96>>2]*-p+ +g[L>>2];g[M>>2]=$+ +g[M>>2];g[N>>2]=aa+ +g[N>>2]}}if(!(a[b+525>>0]|0)){i=P;return}n=+g[b+532>>2];m=n*+g[b+508>>2]*+g[b+432>>2]/f;l=+g[b+476>>2];k=+g[b+480>>2];j=+g[b+484>>2];if((w-z)*l+(u-y)*k+(q-x)*j>0.0)m=m+n*((w-z)*l+(u-y)*k+(q-x)*j)*+g[b+436>>2];n=+g[b+520>>2];m=n+m*+g[b+496>>2];m=m>0.0?m:0.0;g[b+520>>2]=m;h=c[b+28>>2]|0;if(c[d+240>>2]|0){aa=l*+g[h+296>>2]+k*+g[h+300>>2]+j*+g[h+304>>2];$=l*+g[h+280>>2]+k*+g[h+284>>2]+j*+g[h+288>>2];j=l*+g[h+264>>2]+k*+g[h+268>>2]+j*+g[h+272>>2];l=(m-n)*0.0*+g[d+116>>2];k=(m-n)*0.0*+g[d+120>>2];g[d+64>>2]=(m-n)*0.0*+g[d+112>>2]+ +g[d+64>>2];g[d+68>>2]=l+ +g[d+68>>2];g[d+72>>2]=k+ +g[d+72>>2];k=$*(m-n)*+g[d+100>>2];l=aa*(m-n)*+g[d+104>>2];g[I>>2]=j*(m-n)*+g[d+96>>2]+ +g[I>>2];g[J>>2]=k+ +g[J>>2];g[K>>2]=l+ +g[K>>2];l=+g[b+476>>2];k=+g[b+480>>2];j=+g[b+484>>2]}h=c[b+32>>2]|0;if(!(c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P|0;ja=vr(q|0,((q|0)<0)<<31>>31|0,Y|0,((Y|0)<0)<<31>>31|0)|0;ha=C;ia=vr(j|0,((j|0)<0)<<31>>31|0,Z|0,((Z|0)<0)<<31>>31|0)|0;ha=Kt(ia|0,C|0,ja|0,ha|0)|0;ja=C;ia=vr(g|0,((g|0)<0)<<31>>31|0,Q|0,R|0)|0;if(!((ha|0)==(ia|0)&(ja|0)==(C|0))){g=122;break}v=vr(q|0,((q|0)<0)<<31>>31|0,$|0,aa|0)|0;A=C;u=vr(j|0,((j|0)<0)<<31>>31|0,ba|0,ca|0)|0;A=Kt(u|0,C|0,v|0,A|0)|0;v=C;u=vr(g|0,((g|0)<0)<<31>>31|0,V|0,W|0)|0;u=Kt(A|0,v|0,u|0,C|0)|0;v=C;g=(_(j,ea)|0)+(_(q,da)|0)+(_(g,X)|0)|0;A=t-I|0;ia=s-H|0;z=r-G|0;A=vr(A|0,((A|0)<0)<<31>>31|0,$|0,aa|0)|0;ja=C;ia=vr(ia|0,((ia|0)<0)<<31>>31|0,ba|0,ca|0)|0;ja=Kt(ia|0,C|0,A|0,ja|0)|0;A=C;z=vr(z|0,((z|0)<0)<<31>>31|0,V|0,W|0)|0;z=Kt(ja|0,A|0,z|0,C|0)|0;A=C;if(!((A|0)>0|(A|0)==0&z>>>0>0)){g=122;break}if((u|0)==0&(v|0)==0){if((g|0)>=0){g=122;break}}else{if((v|0)>=0){g=122;break}if((g|0)>0){r=1;s=g;q=((g|0)<0)<<31>>31}else{s=Is(0,0,g|0,((g|0)<0)<<31>>31|0)|0;r=g>>31;s=(g|0)<0?s:0;q=(g|0)<0?C:0}y=0-r|0;w=Is(0,0,u|0,v|0)|0;x=C;if((E|0)>0){g=1;v=D;u=B}else{u=(E|0)<0;v=Is(0,0,D|0,B|0)|0;g=E>>31;v=u?v:0;u=u?C:0}do if((m|0)>0|(m|0)==0&l>>>0>0){j=g;g=m}else{if((m|0)>=0){j=g;l=0;g=0;break}l=Is(0,0,l|0,m|0)|0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b|0)<0)<<31>>31|0,ba|0,ca|0)|0;t=Kt(h|0,C|0,l|0,t|0)|0;l=C;h=vr(g|0,((g|0)<0)<<31>>31|0,V|0,W|0)|0;h=Kt(t|0,l|0,h|0,C|0)|0;l=C;g=(_(b,ea)|0)+(_(d,da)|0)+(_(g,X)|0)|0;t=E-k|0;ia=n-j|0;s=p-i|0;t=vr(t|0,((t|0)<0)<<31>>31|0,$|0,aa|0)|0;ja=C;ia=vr(ia|0,((ia|0)<0)<<31>>31|0,ba|0,ca|0)|0;ja=Kt(ia|0,C|0,t|0,ja|0)|0;t=C;s=vr(s|0,((s|0)<0)<<31>>31|0,V|0,W|0)|0;s=Kt(ja|0,t|0,s|0,C|0)|0;t=C;if((t|0)>=0){g=122;break c}if((h|0)==0&(l|0)==0){if((g|0)<=0){g=122;break c}}else{if((l|0)>=0){g=122;break c}if((g|0)>0){j=g;k=((g|0)<0)<<31>>31;i=1}else{j=Is(0,0,g|0,((g|0)<0)<<31>>31|0)|0;j=(g|0)<0?j:0;k=(g|0)<0?C:0;i=g>>31}r=0-i|0;o=Is(0,0,h|0,l|0)|0;q=C;if((A|0)>0){g=1;m=A;h=((A|0)<0)<<31>>31}else{m=Is(0,0,A|0,((A|0)<0)<<31>>31|0)|0;g=A>>31;m=(A|0)<0?m:0;h=(A|0)<0?C:0}do if((D|0)>0|(D|0)==0&B>>>0>0){d=g;b=B;g=D}else{if((D|0)>=0){d=g;b=0;g=0;break}b=Is(0,0,B|0,D|0)|0;d=0-g|0;g=C}while(0);if((d|0)==(r|0)){if(!i){g=122;break c}ja=vr(b|0,0,j|0,0)|0;i=C;d=vr(g|0,0,j|0,0)|0;U=C;b=vr(b|0,0,k|0,0)|0;l=C;g=vr(g|0,0,k|0,0)|0;j=C;k=Kt(d|0,0,b|0,0)|0;b=C;j=Kt(U|0,0,g|0,j|0)|0;l=Kt(j|0,C|0,l|0,0)|0;b=Kt(l|0,C|0,b|0,0)|0;l=C;i=Kt(0,k|0,ja|0,i|0)|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,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;O=i;i=i+624|0;K=O+536+40|0;M=O+588|0;N=O+576+12|0;L=O+588+9|0;m=0;n=0;r=0;w=f;a:while(1){do if((m|0)>-1){if((n|0)<=(2147483647-m|0)){m=n+m|0;break}if(!0)m=25748;else m=c[(ib()|0)+64>>2]|0;c[m>>2]=75;m=-1}while(0);f=a[w>>0]|0;if(!(f<<24>>24)){J=254;break}else n=w;b:while(1){switch(f<<24>>24){case 37:{f=n;J=11;break b}case 0:{f=n;break b}default:{}}I=n+1|0;f=a[I>>0]|0;n=I}c:do if((J|0)==11)while(1){J=0;if((a[f+1>>0]|0)!=37)break c;n=n+1|0;f=f+2|0;if((a[f>>0]|0)==37)J=11;else break}while(0);v=n-w|0;if(e|0?(c[e>>2]&32|0)==0:0)Ek(w,v,e);if((n|0)!=(w|0)){n=v;w=f;continue}o=f+1|0;n=a[o>>0]|0;if(((n<<24>>24)+-48|0)>>>0<10){I=(a[f+2>>0]|0)==36;o=I?f+3|0:o;q=a[o>>0]|0;u=I?(n<<24>>24)+-48|0:-1;r=I?1:r}else{q=n;u=-1}f=q<<24>>24;d:do if((f&-32|0)==32){n=q;q=0;do{if(!(1<>24)+-32|q;o=o+1|0;n=a[o>>0]|0;f=n<<24>>24}while((f&-32|0)==32)}else{n=q;q=0}while(0);do if(n<<24>>24==42){n=o+1|0;f=(a[n>>0]|0)+-48|0;if(f>>>0<10?(a[o+2>>0]|0)==36:0){c[l+(f<<2)>>2]=10;f=1;o=o+3|0;n=c[j+((a[n>>0]|0)+-48<<3)>>2]|0}else{if(r|0){m=-1;break a}if(!e){t=q;I=0;o=n;H=0;break}f=(c[g>>2]|0)+(4-1)&~(4-1);I=c[f>>2]|0;c[g>>2]=f+4;f=0;o=n;n=I}if((n|0)<0){t=q|8192;I=f;H=0-n|0}else{t=q;I=f;H=n}}else{f=(n<<24>>24)+-48|0;if(f>>>0<10){n=0;do{n=(n*10|0)+f|0;o=o+1|0;f=(a[o>>0]|0)+-48|0}while(f>>>0<10);if((n|0)<0){m=-1;break a}else{t=q;I=r;H=n}}else{t=q;I=r;H=0}}while(0);e:do if((a[o>>0]|0)==46){f=o+1|0;q=a[f>>0]|0;if(q<<24>>24!=42){if(((q<<24>>24)+-48|0)>>>0<10){n=0;o=(q<<24>>24)+-48|0}else{r=0;break}while(1){n=(n*10|0)+o|0;f=f+1|0;o=(a[f>>0]|0)+-48|0;if(o>>>0>=10){r=n;break e}}}f=o+2|0;n=(a[f>>0]|0)+-48|0;if(n>>>0<10?(a[o+3>>0]|0)==36:0){c[l+(n<<2)>>2]=10;r=c[j+((a[f>>0]|0)+-48<<3)>>2]|0;f=o+4|0;break}if(I|0){m=-1;break a}if(e|0){G=(c[g>>2]|0)+(4-1)&~(4-1);r=c[G>>2]|0;c[g>>2]=G+4}else r=0}else{r=-1;f=o}while(0);q=0;while(1){n=(a[f>>0]|0)+-65|0;if(n>>>0>57){m=-1;break a}G=f+1|0;n=a[19395+(q*58|0)+n>>0]|0;if(((n&255)+-1|0)>>>0<8){f=G;q=n&255}else break}if(!(n<<24>>24)){m=-1;break}o=(u|0)>-1;do if(n<<24>>24==19)if(o){m=-1;break a}else J=54;else{if(o){c[l+(u<<2)>>2]=n&255;F=j+(u<<3)|0;J=c[F+4>>2]|0;c[O>>2]=c[F>>2];c[O+4>>2]=J;J=54;break}if(!e){m=0;break a}Ug(O,n&255,g)}while(0);if((J|0)==54?(J=0,(e|0)==0):0){n=v;r=I;w=G;continue}E=a[f>>0]|0;E=(q|0)!=0&(E&15|0)==3?E&-33:E;o=t&-65537;F=(t&8192|0)==0?t:o;f:do switch(E|0){case 110:switch(q|0){case 0:{c[c[O>>2]>>2]=m;n=v;r=I;w=G;continue a}case 1:{c[c[O>>2]>>2]=m;n=v;r=I;w=G;continue a}case 2:{n=c[O>>2]|0;c[n>>2]=m;c[n+4>>2]=((m|0)<0)<<31>>31;n=v;r=I;w=G;continue a}case 3:{b[c[O>>2]>>1]=m;n=v;r=I;w=G;continue a}case 4:{a[c[O>>2]>>0]=m;n=v;r=I;w=G;continue a}case 6:{c[c[O>>2]>>2]=m;n=v;r=I;w=G;continue a}case 7:{n=c[O>>2]|0;c[n>>2]=m;c[n+4>>2]=((m|0)<0)<<31>>31;n=v;r=I;w=G;continue a}default:{n=v;r=I;w=G;continue a}}case 112:{t=F|8;r=r>>>0>8?r:8;u=120;J=66;break}case 88:case 120:{t=F;u=E;J=66;break}case 111:{n=c[O>>2]|0;o=c[O+4>>2]|0;if((n|0)==0&(o|0)==0)f=K;else{f=K;do{f=f+-1|0;a[f>>0]=n&7|48;n=us(n|0,o|0,3)|0;o=C}while(!((n|0)==0&(o|0)==0))}if(!(F&8)){n=F;t=0;q=19875;J=79}else{t=K-f|0;n=F;r=(r|0)>(t|0)?r:t+1|0;t=0;q=19875;J=79}break}case 105:case 100:{f=c[O>>2]|0;n=c[O+4>>2]|0;if((n|0)<0){f=Is(0,0,f|0,n|0)|0;n=C;c[O>>2]=f;c[O+4>>2]=n;o=1;q=19875;J=78;break f}if(!(F&2048)){o=F&1;q=(F&1|0)==0?19875:19877;J=78}else{o=1;q=19876;J=78}break}case 117:{f=c[O>>2]|0;n=c[O+4>>2]|0;o=0;q=19875;J=78;break}case 99:{a[O+536+39>>0]=c[O>>2];f=O+536+39|0;u=1;w=0;v=19875;n=K;break}case 109:{if(!0)f=25748;else f=c[(ib()|0)+64>>2]|0;n=c[f>>2]|0;f=0;while(1){if((d[19885+f>>0]|0)==(n|0)){J=85;break}f=f+1|0;if((f|0)==87){n=87;f=19973;break}}if((J|0)==85)if(!f){n=19973;J=92;break f}else{n=f;f=19973}do{do{J=f;f=f+1|0}while((a[J>>0]|0)!=0);n=n+-1|0}while((n|0)!=0);n=f;J=92;break}case 115:{n=c[O>>2]|0;n=n|0?n:21777;J=92;break}case 67:{c[O+8>>2]=c[O>>2];c[O+8+4>>2]=0;c[O>>2]=O+8;f=O+8|0;r=-1;J=96;break}case 83:{f=c[O>>2]|0;if(!r){Gl(e,32,H,0,F);f=0;J=107}else J=96;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{p=+h[O>>3];c[O+16>>2]=0;h[k>>3]=p;if((c[k+4>>2]|0)>=0)if(!(F&2048)){B=F&1;D=(F&1|0)==0?21785:21790}else{B=1;D=21787}else{p=-p;B=1;D=21784}h[k>>3]=p;A=c[k+4>>2]&2146435072;do if(A>>>0<2146435072|(A|0)==2146435072&0<0){p=+Gm(p,O+16|0)*2.0;if(p!=0.0)c[O+16>>2]=(c[O+16>>2]|0)+-1;if((E|32|0)==97){u=(E&32|0)==0?D:D+9|0;t=B|2;f=12-r|0;do if(!(r>>>0>11|(f|0)==0)){s=8.0;do{f=f+-1|0;s=s*16.0}while((f|0)!=0);if((a[u>>0]|0)==45){p=-(s+(-p-s));break}else{p=p+s-s;break}}while(0);n=c[O+16>>2]|0;f=(n|0)<0?0-n|0:n;f=Vm(f,((f|0)<0)<<31>>31,O+576+12|0)|0;if((f|0)==(O+576+12|0)){a[O+576+11>>0]=48;f=O+576+11|0}a[f+-1>>0]=(n>>31&2)+43;q=f+-2|0;a[q>>0]=E+15;o=(r|0)<1;f=O+588|0;while(1){D=~~p;n=f+1|0;a[f>>0]=d[19859+D>>0]|E&32;p=(p-+(D|0))*16.0;do if((n-M|0)==1){if((F&8|0)==0&(o&p==0.0))break;a[n>>0]=46;n=f+2|0}while(0);if(!(p!=0.0))break;else f=n}f=(r|0)!=0&(-2-M+n|0)<(r|0)?N+2+r-q|0:N-M-q+n|0;Gl(e,32,H,f+t|0,F);if(!(c[e>>2]&32))Ek(u,t,e);Gl(e,48,H,f+t|0,F^65536);if(!(c[e>>2]&32))Ek(O+588|0,n-M|0,e);Gl(e,48,f-(n-M+(N-q))|0,0,0);if(!(c[e>>2]&32))Ek(q,N-q|0,e);Gl(e,32,H,f+t|0,F^8192);f=(f+t|0)<(H|0)?H:f+t|0;break}f=(r|0)<0?6:r;if(p!=0.0){n=(c[O+16>>2]|0)+-28|0;c[O+16>>2]=n;p=p*268435456.0}else n=c[O+16>>2]|0;A=(n|0)<0?O+24|0:O+24+288|0;q=A;do{z=~~p>>>0;c[q>>2]=z;q=q+4|0;p=(p-+(z>>>0))*1.0e9}while(p!=0.0);n=c[O+16>>2]|0;if((n|0)>0){o=A;do{t=(n|0)>29?29:n;n=q+-4|0;do if(n>>>0>=o>>>0){r=0;do{y=is(c[n>>2]|0,0,t|0)|0;y=Kt(y|0,C|0,r|0,0)|0;z=C;x=lr(y|0,z|0,1e9,0)|0;c[n>>2]=x;r=Xv(y|0,z|0,1e9,0)|0;n=n+-4|0}while(n>>>0>=o>>>0);if(!r)break;o=o+-4|0;c[o>>2]=r}while(0);while(1){if(q>>>0<=o>>>0)break;n=q+-4|0;if(!(c[n>>2]|0))q=n;else break}n=(c[O+16>>2]|0)-t|0;c[O+16>>2]=n}while((n|0)>0)}else o=A;if((n|0)<0){do{t=0-n|0;t=(t|0)>9?9:t;do if(o>>>0>>0){r=0;n=o;do{z=c[n>>2]|0;c[n>>2]=(z>>>t)+r;r=_(z&(1<>>t)|0;n=n+4|0}while(n>>>0>>0);n=(c[o>>2]|0)==0?o+4|0:o;if(!r){o=n;n=q;break}c[q>>2]=r;o=n;n=q+4|0}else{o=(c[o>>2]|0)==0?o+4|0:o;n=q}while(0);q=(E|32|0)==102?A:o;q=(n-q>>2|0)>(((f+25|0)/9|0)+1|0)?q+(((f+25|0)/9|0)+1<<2)|0:n;n=(c[O+16>>2]|0)+t|0;c[O+16>>2]=n}while((n|0)<0);n=o}else n=o;do if(n>>>0>>0){o=(A-n>>2)*9|0;t=c[n>>2]|0;if(t>>>0<10)break;else r=10;do{r=r*10|0;o=o+1|0}while(t>>>0>=r>>>0)}else o=0;while(0);r=f-((E|32|0)!=102?o:0)+(((f|0)!=0&(E|32|0)==103)<<31>>31)|0;if((r|0)<(((q-A>>2)*9|0)+-9|0)){x=A+4+(((r+9216|0)/9|0)+-1024<<2)|0;if((((r+9216|0)%9|0)+1|0)<9){t=10;u=((r+9216|0)%9|0)+1|0;while(1){r=t*10|0;u=u+1|0;if((u|0)==9)break;else t=r}}else r=10;v=c[x>>2]|0;w=(v>>>0)%(r>>>0)|0;t=(x+4|0)==(q|0);do if(t&(w|0)==0)r=x;else{s=(((v>>>0)/(r>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;u=(r|0)/2|0;if(w>>>0>>0)p=.5;else p=t&(w|0)==(u|0)?1.0:1.5;do if(B){if((a[D>>0]|0)!=45)break;s=-s;p=-p}while(0);c[x>>2]=v-w;if(!(s+p!=s)){r=x;break}z=v-w+r|0;c[x>>2]=z;if(z>>>0>999999999){o=x;while(1){r=o+-4|0;c[o>>2]=0;if(r>>>0>>0){n=n+-4|0;c[n>>2]=0}z=(c[r>>2]|0)+1|0;c[r>>2]=z;if(z>>>0>999999999)o=r;else break}}else r=x;o=(A-n>>2)*9|0;u=c[n>>2]|0;if(u>>>0<10)break;else t=10;do{t=t*10|0;o=o+1|0}while(u>>>0>=t>>>0)}while(0);y=r+4|0;z=n;n=q>>>0>y>>>0?y:q}else{z=n;n=q}u=0-o|0;y=n;while(1){if(y>>>0<=z>>>0){w=0;break}n=y+-4|0;if(!(c[n>>2]|0))y=n;else{w=1;break}}do if((E|32|0)==103){if((((f|0)!=0^1)+f|0)>(o|0)&(o|0)>-5){t=E+-1|0;f=((f|0)!=0^1)+f+-1-o|0}else{t=E+-2|0;f=((f|0)!=0^1)+f+-1|0}if(F&8|0){r=F&8;break}do if(w){n=c[y+-4>>2]|0;if(!n){q=9;break}if(!((n>>>0)%10|0)){r=10;q=0}else{q=0;break}do{r=r*10|0;q=q+1|0}while(!((n>>>0)%(r>>>0)|0|0))}else q=9;while(0);n=((y-A>>2)*9|0)+-9|0;if((t|32|0)==102){r=n-q|0;r=(r|0)<0?0:r;f=(f|0)<(r|0)?f:r;r=0;break}else{r=n+o-q|0;r=(r|0)<0?0:r;f=(f|0)<(r|0)?f:r;r=0;break}}else{t=E;r=F&8}while(0);v=f|r;q=(t|32|0)==102;if(q){n=(o|0)>0?o:0;u=0}else{n=(o|0)<0?u:o;n=Vm(n,((n|0)<0)<<31>>31,O+576+12|0)|0;if((N-n|0)<2)do{n=n+-1|0;a[n>>0]=48}while((N-n|0)<2);a[n+-1>>0]=(o>>31&2)+43;u=n+-2|0;a[u>>0]=t;n=N-u|0}x=B+1+f+((v|0)!=0&1)+n|0;Gl(e,32,H,x,F);if(!(c[e>>2]&32))Ek(D,B,e);Gl(e,48,H,x,F^65536);do if(q){q=z>>>0>A>>>0?A:z;o=q;do{n=Vm(c[o>>2]|0,0,L)|0;do if((o|0)==(q|0)){if((n|0)!=(L|0))break;a[O+588+8>>0]=48;n=O+588+8|0}else{if(n>>>0<=(O+588|0)>>>0)break;Qn(O+588|0,48,n-M|0)|0;do n=n+-1|0;while(n>>>0>(O+588|0)>>>0)}while(0);if(!(c[e>>2]&32))Ek(n,L-n|0,e);o=o+4|0}while(o>>>0<=A>>>0);do if(v|0){if(c[e>>2]&32|0)break;Ek(21819,1,e)}while(0);if((f|0)>0&o>>>0>>0)while(1){n=Vm(c[o>>2]|0,0,L)|0;if(n>>>0>(O+588|0)>>>0){Qn(O+588|0,48,n-M|0)|0;do n=n+-1|0;while(n>>>0>(O+588|0)>>>0)}if(!(c[e>>2]&32))Ek(n,(f|0)>9?9:f,e);o=o+4|0;n=f+-9|0;if(!((f|0)>9&o>>>0>>0)){f=n;break}else f=n}Gl(e,48,f+9|0,9,0)}else{t=w?y:z+4|0;if((f|0)>-1){r=(r|0)==0;q=z;do{n=Vm(c[q>>2]|0,0,L)|0;if((n|0)==(L|0)){a[O+588+8>>0]=48;n=O+588+8|0}do if((q|0)==(z|0)){o=n+1|0;if(!(c[e>>2]&32))Ek(n,1,e);if(r&(f|0)<1){n=o;break}if(c[e>>2]&32|0){n=o;break}Ek(21819,1,e);n=o}else{if(n>>>0<=(O+588|0)>>>0)break;Qn(O+588|0,48,n+(0-M)|0)|0;do n=n+-1|0;while(n>>>0>(O+588|0)>>>0)}while(0);o=L-n|0;if(!(c[e>>2]&32))Ek(n,(f|0)>(o|0)?o:f,e);f=f-o|0;q=q+4|0}while(q>>>0>>0&(f|0)>-1)}Gl(e,48,f+18|0,18,0);if(c[e>>2]&32|0)break;Ek(u,N-u|0,e)}while(0);Gl(e,32,H,x,F^8192);f=(x|0)<(H|0)?H:x}else{q=p!=p|0.0!=0.0;n=q?0:B;Gl(e,32,H,n+3|0,o);f=c[e>>2]|0;if(!(f&32)){Ek(D,n,e);f=c[e>>2]|0}if(!(f&32))Ek(q?(E&32|0?21811:21815):E&32|0?21803:21807,3,e);Gl(e,32,H,n+3|0,F^8192);f=(n+3|0)<(H|0)?H:n+3|0}while(0);n=f;r=I;w=G;continue a}default:{f=w;o=F;u=r;w=0;v=19875;n=K}}while(0);g:do if((J|0)==66){n=c[O>>2]|0;o=c[O+4>>2]|0;q=u&32;if(!((n|0)==0&(o|0)==0)){f=K;do{f=f+-1|0;a[f>>0]=d[19859+(n&15)>>0]|q;n=us(n|0,o|0,4)|0;o=C}while(!((n|0)==0&(o|0)==0));if((t&8|0)==0|(c[O>>2]|0)==0&(c[O+4>>2]|0)==0){n=t;t=0;q=19875;J=79}else{n=t;t=2;q=19875+(u>>4)|0;J=79}}else{f=K;n=t;t=0;q=19875;J=79}}else if((J|0)==78){f=Vm(f,n,K)|0;n=F;t=o;J=79}else if((J|0)==92){J=0;F=lj(n,0,r)|0;f=n;u=(F|0)==0?r:F-n|0;w=0;v=19875;n=(F|0)==0?n+r|0:F}else if((J|0)==96){J=0;o=0;n=0;t=f;while(1){q=c[t>>2]|0;if(!q)break;n=wl(O+528|0,q)|0;if((n|0)<0|n>>>0>(r-o|0)>>>0)break;o=n+o|0;if(r>>>0>o>>>0)t=t+4|0;else break}if((n|0)<0){m=-1;break a}Gl(e,32,H,o,F);if(!o){f=0;J=107}else{q=0;while(1){n=c[f>>2]|0;if(!n){f=o;J=107;break g}n=wl(O+528|0,n)|0;q=n+q|0;if((q|0)>(o|0)){f=o;J=107;break g}if(!(c[e>>2]&32))Ek(O+528|0,n,e);if(q>>>0>=o>>>0){f=o;J=107;break}else f=f+4|0}}}while(0);if((J|0)==107){J=0;Gl(e,32,H,f,F^8192);n=(H|0)>(f|0)?H:f;r=I;w=G;continue}if((J|0)==79){J=0;o=(r|0)>-1?n&-65537:n;n=(c[O>>2]|0)!=0|(c[O+4>>2]|0)!=0;if((r|0)!=0|n){u=(n&1^1)+(K-f)|0;u=(r|0)>(u|0)?r:u;w=t;v=q;n=K}else{f=K;u=0;w=t;v=q;n=K}}t=n-f|0;q=(u|0)<(t|0)?t:u;r=w+q|0;n=(H|0)<(r|0)?r:H;Gl(e,32,n,r,o);if(!(c[e>>2]&32))Ek(v,w,e);Gl(e,48,n,r,o^65536);Gl(e,48,q,t,0);if(!(c[e>>2]&32))Ek(f,t,e);Gl(e,32,n,r,o^8192);r=I;w=G}h:do if((J|0)==254)if(!e)if(!r)m=0;else{m=1;while(1){f=c[l+(m<<2)>>2]|0;if(!f){f=0;break}Ug(j+(m<<3)|0,f,g);m=m+1|0;if((m|0)>=10){m=1;break h}}while(1){m=m+1|0;if(f|0){m=-1;break h}if((m|0)>=10){m=1;break h}f=c[l+(m<<2)>>2]|0}}while(0);i=O;return m|0}function Cc(b,d,e,f,h,j,l,m,n){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;l=l|0;m=m|0;n=n|0;var o=0,p=0,q=0,r=0.0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0;Y=i;i=i+304|0;c[b+188>>2]=-1;li(12870);c[b+184>>2]=0;if((e|0)>0){n=0;do{c[(c[d+(n<<2)>>2]|0)+212>>2]=-1;n=n+1|0}while((n|0)!=(e|0))}o=c[b+12>>2]|0;if((o|0)>(e|0))p=b+8|0;else{if((e+1|0)!=0?(c[6435]=(c[6435]|0)+1,p=yc(((e+1|0)*244|3)+16|0)|0,(p|0)!=0):0){c[(p+4+15&-16)+-4>>2]=p;p=p+4+15&-16}else p=0;n=c[b+8>>2]|0;if((n|0)>0){o=0;do{V=p+(o*244|0)|0;W=c[b+16>>2]|0;U=W+(o*244|0)|0;c[V>>2]=c[U>>2];c[V+4>>2]=c[U+4>>2];c[V+8>>2]=c[U+8>>2];c[V+12>>2]=c[U+12>>2];V=p+(o*244|0)+16|0;U=W+(o*244|0)+16|0;c[V>>2]=c[U>>2];c[V+4>>2]=c[U+4>>2];c[V+8>>2]=c[U+8>>2];c[V+12>>2]=c[U+12>>2];V=p+(o*244|0)+32|0;U=W+(o*244|0)+32|0;c[V>>2]=c[U>>2];c[V+4>>2]=c[U+4>>2];c[V+8>>2]=c[U+8>>2];c[V+12>>2]=c[U+12>>2];V=p+(o*244|0)+48|0;U=W+(o*244|0)+48|0;c[V>>2]=c[U>>2];c[V+4>>2]=c[U+4>>2];c[V+8>>2]=c[U+8>>2];c[V+12>>2]=c[U+12>>2];_m(p+(o*244|0)+64|0,W+(o*244|0)+64|0,180)|0;o=o+1|0}while((o|0)!=(n|0))}n=c[b+16>>2]|0;if(n|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=p;c[b+12>>2]=e+1;p=b+8|0;o=e+1|0}Qn(Y|0,0,244)|0;n=c[p>>2]|0;if((n|0)<0){if((o|0)<0){o=c[b+16>>2]|0;if(o|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[o+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=0;c[b+12>>2]=0}do{W=c[b+16>>2]|0;V=W+(n*244|0)|0;c[V>>2]=c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*w-v*A)*(y*w-v*A)+(v*z-x*w)*(v*z-x*w)+(x*A-y*z)*(x*A-y*z);if(r>t*t){r=1.0/+O(+r)*t;u=(y*w-v*A)*r;t=r*(v*z-x*w);r=r*(x*A-y*z)}else{u=y*w-v*A;t=v*z-x*w;r=x*A-y*z}ca=+g[m+12>>2];da=(u*+g[o+268>>2]+t*+g[o+284>>2]+r*+g[o+300>>2])*ca;ea=ca*(u*+g[o+272>>2]+t*+g[o+288>>2]+r*+g[o+304>>2]);g[q+(n*244|0)+224>>2]=+g[q+(n*244|0)+224>>2]-(u*+g[o+264>>2]+t*+g[o+280>>2]+r*+g[o+296>>2])*ca;g[q+(n*244|0)+228>>2]=+g[q+(n*244|0)+228>>2]-da;g[q+(n*244|0)+232>>2]=+g[q+(n*244|0)+232>>2]-ea}p=p+1|0}while((p|0)!=(e|0))}if((l|0)>0){n=0;do{W=c[j+(n<<2)>>2]|0;Ab[c[(c[W>>2]|0)+8>>2]&255](W);g[W+36>>2]=0.0;n=n+1|0}while((n|0)<(l|0))}o=c[b+168>>2]|0;if((o|0)<(l|0)?(c[b+172>>2]|0)<(l|0):0){if(!l)n=0;else{c[6435]=(c[6435]|0)+1;n=yc((l<<3|3)+16|0)|0;if(!n)n=0;else{c[(n+4+15&-16)+-4>>2]=n;n=n+4+15&-16}o=c[b+168>>2]|0}if((o|0)>0){p=0;do{U=(c[b+176>>2]|0)+(p<<3)|0;V=c[U+4>>2]|0;W=n+(p<<3)|0;c[W>>2]=c[U>>2];c[W+4>>2]=V;p=p+1|0}while((p|0)!=(o|0))}o=c[b+176>>2]|0;if(o|0){if(a[b+180>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[o+-4>>2]|0)}c[b+176>>2]=0}a[b+180>>0]=1;c[b+176>>2]=n;c[b+172>>2]=l}c[b+168>>2]=l;if((l|0)>0){s=0;n=0;do{d=c[b+176>>2]|0;e=d+(s<<3)|0;q=j+(s<<2)|0;o=c[q>>2]|0;p=c[o+44>>2]|0;if(p){o=p+64|0;do{c[p>>2]=0;p=p+4|0}while((p|0)<(o|0));o=c[q>>2]|0}if(!(a[o+20>>0]|0)){c[e>>2]=0;c[d+(s<<3)+4>>2]=0;o=0}else{Cb[c[(c[o>>2]|0)+16>>2]&127](o,e);o=c[e>>2]|0}n=o+n|0;s=s+1|0}while((s|0)<(l|0))}else n=0;p=c[b+48>>2]|0;if((p|0)<(n|0)?(c[b+52>>2]|0)<(n|0):0){if(!n)o=0;else{c[6435]=(c[6435]|0)+1;o=yc((n*152|3)+16|0)|0;if(!o)o=0;else{c[(o+4+15&-16)+-4>>2]=o;o=o+4+15&-16}p=c[b+48>>2]|0}if((p|0)>0){q=0;do{_m(o+(q*152|0)|0,(c[b+56>>2]|0)+(q*152|0)|0,152)|0;q=q+1|0}while((q|0)!=(p|0))}p=c[b+56>>2]|0;if(p|0){if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0)}c[b+56>>2]=0}a[b+60>>0]=1;c[b+56>>2]=o;c[b+52>>2]=n}c[b+48>>2]=n;if((l|0)>0){n=c[b+176>>2]|0;V=0;W=0;while(1){U=n+(W<<3)|0;if(!(c[U>>2]|0))o=0;else{n=c[b+56>>2]|0;K=n+(V*152|0)|0;L=j+(W<<2)|0;M=c[L>>2]|0;P=c[M+28>>2]|0;Q=c[M+32>>2]|0;R=bk(b,P,+g[m+12>>2])|0;S=bk(b,Q,+g[m+12>>2])|0;T=c[b+16>>2]|0;o=c[M+24>>2]|0;o=(o|0)>0?o:c[m+20>>2]|0;if((o|0)>(c[b+184>>2]|0))c[b+184>>2]=o;if((c[U>>2]|0)>0){p=0;do{Qn(K+(p*152|0)|0,0,152)|0;g[K+(p*152|0)+120>>2]=-3402823466385288598117041.0e14;g[K+(p*152|0)+124>>2]=3402823466385288598117041.0e14;g[K+(p*152|0)+100>>2]=0.0;g[K+(p*152|0)+96>>2]=0.0;c[K+(p*152|0)+144>>2]=R;c[K+(p*152|0)+148>>2]=S;c[K+(p*152|0)+136>>2]=o;p=p+1|0}while((p|0)<(c[U>>2]|0))}c[T+(R*244|0)+64>>2]=0;c[T+(R*244|0)+64+4>>2]=0;c[T+(R*244|0)+64+8>>2]=0;c[T+(R*244|0)+64+12>>2]=0;c[T+(R*244|0)+64+16>>2]=0;c[T+(R*244|0)+64+20>>2]=0;c[T+(R*244|0)+64+24>>2]=0;c[T+(R*244|0)+64+28>>2]=0;c[T+(R*244|0)+144>>2]=0;c[T+(R*244|0)+144+4>>2]=0;c[T+(R*244|0)+144+8>>2]=0;c[T+(R*244|0)+144+12>>2]=0;c[T+(R*244|0)+144+16>>2]=0;c[T+(R*244|0)+144+20>>2]=0;c[T+(R*244|0)+144+24>>2]=0;c[T+(R*244|0)+144+28>>2]=0;c[T+(S*244|0)+64>>2]=0;c[T+(S*244|0)+64+4>>2]=0;c[T+(S*244|0)+64+8>>2]=0;c[T+(S*244|0)+64+12>>2]=0;c[T+(S*244|0)+64+16>>2]=0;c[T+(S*244|0)+64+20>>2]=0;c[T+(S*244|0)+64+24>>2]=0;c[T+(S*244|0)+64+28>>2]=0;c[T+(S*244|0)+144>>2]=0;c[T+(S*244|0)+144+4>>2]=0;c[T+(S*244|0)+144+8>>2]=0;c[T+(S*244|0)+144+12>>2]=0;c[T+(S*244|0)+144+16>>2]=0;c[T+(S*244|0)+144+20>>2]=0;c[T+(S*244|0)+144+24>>2]=0;c[T+(S*244|0)+144+28>>2]=0;g[Y+248>>2]=1.0/+g[m+12>>2];c[Y+248+4>>2]=c[m+32>>2];c[Y+248+8>>2]=n+(V*152|0)+16;c[Y+248+12>>2]=K;c[Y+248+16>>2]=n+(V*152|0)+48;c[Y+248+20>>2]=n+(V*152|0)+32;c[Y+248+24>>2]=38;c[Y+248+28>>2]=n+(V*152|0)+112;J=n+(V*152|0)+116|0;c[J>>2]=c[m+40>>2];c[Y+248+52>>2]=c[m+4>>2];c[Y+248+32>>2]=J;c[Y+248+36>>2]=n+(V*152|0)+120;c[Y+248+40>>2]=n+(V*152|0)+124;c[Y+248+48>>2]=c[m+20>>2];J=c[L>>2]|0;Cb[c[(c[J>>2]|0)+20>>2]&127](J,Y+248|0);if((c[U>>2]|0)>0){J=0;do{n=K+(J*152|0)+124|0;r=+g[(c[L>>2]|0)+16>>2];if(+g[n>>2]>=r)g[n>>2]=r;n=K+(J*152|0)+120|0;if(+g[n>>2]<=-r)g[n>>2]=-r;c[K+(J*152|0)+132>>2]=M;I=K+(J*152|0)|0;n=K+(J*152|0)+64|0;o=c[M+28>>2]|0;da=+g[I>>2];ba=+g[I+4>>2];B=+g[I+8>>2];ca=(da*+g[o+280>>2]+ba*+g[o+284>>2]+B*+g[o+288>>2])*+g[o+548>>2];r=(da*+g[o+296>>2]+ba*+g[o+300>>2]+B*+g[o+304>>2])*+g[o+552>>2];g[n>>2]=(+g[o+264>>2]*da+ +g[o+268>>2]*ba+ +g[o+272>>2]*B)*+g[o+544>>2];g[n+4>>2]=ca;g[n+8>>2]=r;g[n+12>>2]=0.0;n=K+(J*152|0)+32|0;o=K+(J*152|0)+80|0;H=c[M+32>>2]|0;r=+g[n>>2];ca=+g[n+4>>2];B=+g[n+8>>2];ba=(r*+g[H+280>>2]+ca*+g[H+284>>2]+B*+g[H+288>>2])*+g[H+548>>2];da=(r*+g[H+296>>2]+ca*+g[H+300>>2]+B*+g[H+304>>2])*+g[H+552>>2];g[o>>2]=(+g[H+264>>2]*r+ +g[H+268>>2]*ca+ +g[H+272>>2]*B)*+g[H+544>>2];g[o+4>>2]=ba;g[o+8>>2]=da;g[o+12>>2]=0.0;o=K+(J*152|0)+16|0;da=+g[P+344>>2];ba=+g[o>>2];ca=+g[o+4>>2];r=+g[o+8>>2];t=+g[I>>2];u=+g[I+4>>2];v=+g[I+8>>2];I=K+(J*152|0)+48|0;ea=+g[Q+344>>2];w=+g[I>>2];x=+g[I+4>>2];y=+g[I+8>>2];z=+g[n>>2];A=+g[n+4>>2];B=ba*da*ba+ca*da*ca+r*da*r+(t*(+g[P+264>>2]*t+ +g[P+268>>2]*u+ +g[P+272>>2]*v)+u*(t*+g[P+280>>2]+u*+g[P+284>>2]+v*+g[P+288>>2])+v*(t*+g[P+296>>2]+u*+g[P+300>>2]+v*+g[P+304>>2]))+(w*ea*w+x*ea*x+y*ea*y)+(z*(+g[Q+264>>2]*z+ +g[Q+268>>2]*A+ +g[Q+272>>2]*B)+A*(z*+g[Q+280>>2]+A*+g[Q+284>>2]+B*+g[Q+288>>2])+B*(z*+g[Q+296>>2]+A*+g[Q+300>>2]+B*+g[Q+304>>2]));I=+N(+B)>1.1920928955078125e-07;B=I?1.0/B:0.0;g[K+(J*152|0)+108>>2]=B;if(!(c[T+(R*244|0)+240>>2]|0)){p=0;q=0;d=0;D=0;E=0;F=0}else{p=c[T+(R*244|0)+208>>2]|0;q=c[T+(R*244|0)+212>>2]|0;d=c[T+(R*244|0)+216>>2]|0;D=c[T+(R*244|0)+224>>2]|0;E=c[T+(R*244|0)+228>>2]|0;F=c[T+(R*244|0)+232>>2]|0}if(!(c[T+(S*244|0)+240>>2]|0)){e=0;s=0;C=0;G=0;H=0;I=0}else{e=c[T+(S*244|0)+208>>2]|0;s=c[T+(S*244|0)+212>>2]|0;C=c[T+(S*244|0)+216>>2]|0;G=c[T+(S*244|0)+224>>2]|0;H=c[T+(S*244|0)+228>>2]|0;I=c[T+(S*244|0)+232>>2]|0}da=(c[k>>2]=p,+g[k>>2])+ +g[P+312>>2];ca=(c[k>>2]=q,+g[k>>2])+ +g[P+316>>2];ca=da*+g[o>>2]+ca*+g[o+4>>2]+((c[k>>2]=d,+g[k>>2])+ +g[P+320>>2])*r;da=(c[k>>2]=D,+g[k>>2])+ +g[P+328>>2];ba=(c[k>>2]=E,+g[k>>2])+ +g[P+332>>2];ba=ca+(da*t+ba*u+((c[k>>2]=F,+g[k>>2])+ +g[P+336>>2])*v);da=(c[k>>2]=e,+g[k>>2])+ +g[Q+312>>2];ca=(c[k>>2]=s,+g[k>>2])+ +g[Q+316>>2];ca=da*w+ca*x+((c[k>>2]=C,+g[k>>2])+ +g[Q+320>>2])*y;da=(c[k>>2]=G,+g[k>>2])+ +g[Q+328>>2];ea=(c[k>>2]=H,+g[k>>2])+ +g[Q+332>>2];H=K+(J*152|0)+112|0;g[H>>2]=+g[H>>2]*B+B*(0.0-+g[Y+248+52>>2]*(ba+(ca+(da*z+ea*A+((c[k>>2]=I,+g[k>>2])+ +g[Q+336>>2])*+g[n+8>>2]))));g[K+(J*152|0)+100>>2]=0.0;J=J+1|0}while((J|0)<(c[U>>2]|0))}o=c[b+176>>2]|0;n=o;o=c[o+(W<<3)>>2]|0}W=W+1|0;if((W|0)>=(l|0))break;else V=o+V|0}}mc[c[(c[b>>2]|0)+28>>2]&127](b,f,h,m);d=c[b+48>>2]|0;e=c[b+28>>2]|0;s=c[b+68>>2]|0;o=c[b+128>>2]|0;if((o|0)<(d|0)?(c[b+132>>2]|0)<(d|0):0){if(!d)n=0;else{c[6435]=(c[6435]|0)+1;n=yc((d<<2|3)+16|0)|0;if(!n)n=0;else{c[(n+4+15&-16)+-4>>2]=n;n=n+4+15&-16}o=c[b+128>>2]|0}q=c[b+136>>2]|0;if((o|0)<=0)if(!q)o=b+140|0;else X=99;else{p=0;do{c[n+(p<<2)>>2]=c[q+(p<<2)>>2];p=p+1|0}while((p|0)!=(o|0));X=99}if((X|0)==99){if(a[b+140>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}c[b+136>>2]=0;o=b+140|0}a[o>>0]=1;c[b+136>>2]=n;c[b+132>>2]=d}c[b+128>>2]=d;if(!(c[m+64>>2]&16)){o=c[b+108>>2]|0;if((o|0)<(e|0)?(c[b+112>>2]|0)<(e|0):0){if(!e)n=0;else{c[6435]=(c[6435]|0)+1;n=yc((e<<2|3)+16|0)|0;if(!n)n=0;else{c[(n+4+15&-16)+-4>>2]=n;n=n+4+15&-16}o=c[b+108>>2]|0}q=c[b+116>>2]|0;if((o|0)<=0)if(!q)o=b+120|0;else X=129;else{p=0;do{c[n+(p<<2)>>2]=c[q+(p<<2)>>2];p=p+1|0}while((p|0)!=(o|0));X=129}if((X|0)==129){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}c[b+116>>2]=0;o=b+120|0}a[o>>0]=1;c[b+116>>2]=n;c[b+112>>2]=e}c[b+108>>2]=e}else{o=c[b+108>>2]|0;if((o|0)<(e<<1|0)?(c[b+112>>2]|0)<(e<<1|0):0){if(!e)n=0;else{c[6435]=(c[6435]|0)+1;n=yc((e<<3|3)+16|0)|0;if(!n)n=0;else{c[(n+4+15&-16)+-4>>2]=n;n=n+4+15&-16}o=c[b+108>>2]|0}q=c[b+116>>2]|0;if((o|0)<=0)if(!q)o=b+120|0;else X=114;else{p=0;do{c[n+(p<<2)>>2]=c[q+(p<<2)>>2];p=p+1|0}while((p|0)!=(o|0));X=114}if((X|0)==114){if(a[b+120>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}c[b+116>>2]=0;o=b+120|0}a[o>>0]=1;c[b+116>>2]=n;c[b+112>>2]=e<<1}c[b+108>>2]=e<<1}o=c[b+148>>2]|0;if((o|0)<(s|0)?(c[b+152>>2]|0)<(s|0):0){if(!s)n=0;else{c[6435]=(c[6435]|0)+1;n=yc((s<<2|3)+16|0)|0;if(!n)n=0;else{c[(n+4+15&-16)+-4>>2]=n;n=n+4+15&-16}o=c[b+148>>2]|0}q=c[b+156>>2]|0;if((o|0)<=0)if(!q)o=b+160|0;else X=144;else{p=0;do{c[n+(p<<2)>>2]=c[q+(p<<2)>>2];p=p+1|0}while((p|0)!=(o|0));X=144}if((X|0)==144){if(a[b+160>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[q+-4>>2]|0)}c[b+156>>2]=0;o=b+160|0}a[o>>0]=1;c[b+156>>2]=n;c[b+152>>2]=s}c[b+148>>2]=s;if((d|0)>0){n=c[b+136>>2]|0;o=0;do{c[n+(o<<2)>>2]=o;o=o+1|0}while((o|0)!=(d|0))}if((e|0)>0){n=c[b+116>>2]|0;o=0;do{c[n+(o<<2)>>2]=o;o=o+1|0}while((o|0)!=(e|0))}if((s|0)>0){n=c[b+156>>2]|0;o=0;do{c[n+(o<<2)>>2]=o;o=o+1|0}while((o|0)!=(s|0))}n=c[2357]|0;b=(c[n+16>>2]|0)+-1|0;c[n+16>>2]=b;if(b|0){i=Y;return 0.0}do if(c[n+4>>2]|0){tb(Y+248|0,0)|0;b=c[6434]|0;g[n+8>>2]=+g[n+8>>2]+ +(((c[Y+248+4>>2]|0)-(c[b+4>>2]|0)+(((c[Y+248>>2]|0)-(c[b>>2]|0)|0)*1e6|0)-(c[n+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[n+16>>2]|0)){n=c[2357]|0;break}else{i=Y;return 0.0}}while(0);c[2357]=c[n+20>>2];i=Y;return 0.0}function Dc(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0;J=i;i=i+240|0;if((e|0)<1){f=c[b+12>>2]|0;if(f|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;f=c[b+32>>2]|0;if(f|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;f=c[b+52>>2]|0;if(f|0){if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[b+52>>2]=0}a[b+56>>0]=1;c[b+52>>2]=0;c[b+44>>2]=0;c[b+48>>2]=0;i=J;return}c[J+24+32>>2]=0;c[J+24+36>>2]=0;c[J+24+40>>2]=0;c[J+24+44>>2]=256;c[J+24+48>>2]=0;c[J+24+52>>2]=0;c[J+24+56>>2]=0;c[J+24+60>>2]=256;c[J+24+64>>2]=0;c[J+24+68>>2]=0;c[J+24+72>>2]=0;c[J+24+76>>2]=256;a[J+24+96>>0]=1;F=J+24+92|0;c[F>>2]=0;c[J+24+84>>2]=0;c[J+24+88>>2]=0;m=0;n=-246811958;v=-246811958;s=-246811958;r=1900671690;z=1900671690;u=1900671690;o=d;while(1){E=+g[o>>2];j=+g[o+4>>2];p=+g[o+8>>2];G=E<(c[k>>2]=r,+g[k>>2]);f=(g[k>>2]=E,c[k>>2]|0);r=G?f:r;G=j<(c[k>>2]=u,+g[k>>2]);h=(g[k>>2]=j,c[k>>2]|0);u=G?h:u;G=p<(c[k>>2]=z,+g[k>>2]);l=(g[k>>2]=p,c[k>>2]|0);z=G?l:z;n=(c[k>>2]=n,+g[k>>2])>2]=s,+g[k>>2])>2]=v,+g[k>>2])>2]=n,+g[k>>2]);A=(c[k>>2]=r,+g[k>>2]);y=(c[k>>2]=s,+g[k>>2]);x=(c[k>>2]=u,+g[k>>2]);w=(c[k>>2]=v,+g[k>>2]);t=(c[k>>2]=z,+g[k>>2]);h=B-A>2]=h;f=B-A>>0)%3|0;c[J+24+104>>2]=f;G=(h^3)-f|0;c[J+24+108>>2]=G;if(((G+1|0)%3|0|0)==(h|0)){j=(B-A)*9.788566967472434e-05;p=(y-x)*9.788566967472434e-05;q=(w-t)*9.788566967472434e-05}else{j=-((B-A)*9.788566967472434e-05);p=-((y-x)*9.788566967472434e-05);q=-((w-t)*9.788566967472434e-05)}g[J+24>>2]=j;g[J+24+4>>2]=p;g[J+24+8>>2]=q;g[J+24+12>>2]=0.0;E=j!=0.0?1.0/j:j;D=p!=0.0?1.0/p:p;C=q!=0.0?1.0/q:q;g[J+24+16>>2]=(B+A)*.5;g[J+24+20>>2]=(y+x)*.5;g[J+24+24>>2]=(w+t)*.5;g[J+24+28>>2]=0.0;r=J+216+16|0;a[r>>0]=1;s=J+216+12|0;c[s>>2]=0;c[J+216+4>>2]=0;c[J+216+8>>2]=0;c[6435]=(c[6435]|0)+1;f=yc((e<<4|3)+16|0)|0;if(!f)m=0;else{c[(f+4+15&-16)+-4>>2]=f;m=f+4+15&-16}h=c[J+216+4>>2]|0;l=c[s>>2]|0;if((h|0)<=0){if(l|0)I=26}else{f=0;do{I=m+(f<<4)|0;G=l+(f<<4)|0;c[I>>2]=c[G>>2];c[I+4>>2]=c[G+4>>2];c[I+8>>2]=c[G+8>>2];c[I+12>>2]=c[G+12>>2];f=f+1|0}while((f|0)!=(h|0));I=26}if((I|0)==26){if(a[r>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[s>>2]=0}a[r>>0]=1;c[s>>2]=m;c[J+216+8>>2]=e;c[m>>2]=c[J+200>>2];c[m+4>>2]=c[J+200+4>>2];c[m+8>>2]=c[J+200+8>>2];c[m+12>>2]=c[J+200+12>>2];if((e|0)!=1){f=1;do{G=(c[s>>2]|0)+(f<<4)|0;c[G>>2]=c[J+200>>2];c[G+4>>2]=c[J+200+4>>2];c[G+8>>2]=c[J+200+8>>2];c[G+12>>2]=c[J+200+12>>2];f=f+1|0}while((f|0)!=(e|0))}c[J+216+4>>2]=e;h=J+184+(c[J+24+108>>2]<<2)|0;l=c[s>>2]|0;m=J+184+(c[J+24+112>>2]<<2)|0;n=J+184+(c[J+24+104>>2]<<2)|0;j=+g[J+24+16>>2];p=+g[J+24+20>>2];q=+g[J+24+24>>2];o=0;f=d;while(1){d=c[f>>2]|0;c[J+184>>2]=d;G=c[f+4>>2]|0;c[J+184+4>>2]=G;y=(c[k>>2]=d,+g[k>>2])-j;A=D*((c[k>>2]=G,+g[k>>2])-p);B=C*(+g[f+8>>2]-q);g[J+184>>2]=E*y;g[J+184+4>>2]=A;g[J+184+8>>2]=B;g[J+184+12>>2]=0.0;c[l+(o<<4)>>2]=~~+g[h>>2];c[l+(o<<4)+4>>2]=~~+g[m>>2];c[l+(o<<4)+8>>2]=~~+g[n>>2];c[l+(o<<4)+12>>2]=o;o=o+1|0;if((o|0)==(e|0))break;else f=f+16|0}if((e|0)>1)ch(J+216|0,0,e+-1|0);c[J+24+36>>2]=c[J+24+32>>2];c[J+24+40>>2]=0;c[J+24+44>>2]=e;f=c[J+24+84>>2]|0;if((f|0)<(e|0)){if((c[J+24+88>>2]|0)<(e|0)){if(!e){h=0;l=f}else{c[6435]=(c[6435]|0)+1;h=yc((e<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}l=c[J+24+84>>2]|0}if((l|0)>0){m=0;do{c[h+(m<<2)>>2]=c[(c[F>>2]|0)+(m<<2)>>2];m=m+1|0}while((m|0)!=(l|0))}l=c[F>>2]|0;if(l|0){if(a[J+24+96>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[F>>2]=0}a[J+24+96>>0]=1;c[F>>2]=h;c[J+24+88>>2]=e}do{c[(c[F>>2]|0)+(f<<2)>>2]=0;f=f+1|0}while((f|0)!=(e|0))}c[J+24+84>>2]=e;n=0;do{f=c[J+24+40>>2]|0;if(!f){f=c[J+24+36>>2]|0;if(!f){c[6435]=(c[6435]|0)+1;f=yc(31)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=c[J+24+44>>2]|0;c[f+4>>2]=h;l=f+8|0;c[l>>2]=0;c[6435]=(c[6435]|0)+1;h=yc((h*112|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[f>>2]=h;c[l>>2]=c[J+24+32>>2];c[J+24+32>>2]=f}else c[J+24+36>>2]=c[f+8>>2];m=c[f+4>>2]|0;f=c[f>>2]|0;if((m|0)>0){h=0;l=f;do{h=h+1|0;G=l;l=l+112|0;c[G>>2]=(h|0)<(m|0)?l:0}while((h|0)!=(m|0))}}c[J+24+40>>2]=c[f>>2];G=f+104|0;c[f>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[G>>2]=-1;c[f+8>>2]=0;d=f+88|0;z=(c[s>>2]|0)+(n<<4)|0;c[d>>2]=c[z>>2];c[d+4>>2]=c[z+4>>2];c[d+8>>2]=c[z+8>>2];c[d+12>>2]=c[z+12>>2];c[G>>2]=-1;c[(c[F>>2]|0)+(n<<2)>>2]=f;n=n+1|0}while((n|0)<(e|0));f=c[s>>2]|0;if(f|0){if(a[r>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[s>>2]=0}a[r>>0]=1;c[s>>2]=0;c[J+216+4>>2]=0;c[J+216+8>>2]=0;c[J+24+52>>2]=c[J+24+48>>2];c[J+24+56>>2]=0;c[J+24+60>>2]=e*6;c[J+24+116>>2]=0;c[J+24+120>>2]=0;c[J+24+100>>2]=-3;c[J+184>>2]=0;c[J+184+4>>2]=0;c[J+184+8>>2]=0;c[J+184+12>>2]=0;vc(J+24|0,0,e,J+184|0);c[J+24+124>>2]=c[J+184>>2];f=c[s>>2]|0;if(f|0){if(a[r>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[s>>2]=0}f=c[b+4>>2]|0;if((f|0)<0){if((c[b+8>>2]|0)<0){h=c[b+12>>2]|0;if(h|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=0;c[b+8>>2]=0}do{G=(c[b+12>>2]|0)+(f<<4)|0;c[G>>2]=c[J+168>>2];c[G+4>>2]=c[J+168+4>>2];c[G+8>>2]=c[J+168+8>>2];c[G+12>>2]=c[J+168+12>>2];f=f+1|0}while((f|0)!=0)}c[b+4>>2]=0;c[J+152>>2]=0;c[J+152+4>>2]=0;c[J+152+8>>2]=0;f=c[b+24>>2]|0;if((f|0)<0){if((c[b+28>>2]|0)<0){h=c[b+32>>2]|0;if(h|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+28>>2]=0}do{G=(c[b+32>>2]|0)+(f*12|0)|0;c[G>>2]=c[J+152>>2];c[G+4>>2]=c[J+152+4>>2];c[G+8>>2]=c[J+152+8>>2];f=f+1|0}while((f|0)!=0)}c[b+24>>2]=0;h=c[b+44>>2]|0;if((h|0)<0){f=c[b+52>>2]|0;do if((c[b+48>>2]|0)<0){if(!f){a[b+56>>0]=1;c[b+52>>2]=0;c[b+48>>2]=0;f=0;break}if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}a[b+56>>0]=1;c[b+52>>2]=0;c[b+48>>2]=0;f=0}while(0);Qn(f+(h<<2)|0,0,_(h,-4)|0)|0}c[b+44>>2]=0;f=c[J+24+124>>2]|0;if((c[f+104>>2]|0)<0){c[f+104>>2]=0;c[6435]=(c[6435]|0)+1;r=yc(23)|0;c[(r+4+15&-16)+-4>>2]=r;c[(r+4+15&-16)>>2]=f;G=0;m=1;l=1;r=r+4+15&-16;while(1){if((c[f+100>>2]|0)>-1){g[J+216+(c[J+24+108>>2]<<2)>>2]=+(c[f+88>>2]|0);g[J+216+(c[J+24+112>>2]<<2)>>2]=+(c[f+92>>2]|0);j=+(c[f+96>>2]|0)}else{e=f+24|0;d=f+32|0;j=+ln(c[e>>2]|0,c[e+4>>2]|0,c[d>>2]|0,c[d+4>>2]|0);d=f+72|0;e=f+80|0;F=c[e>>2]|0;e=c[e+4>>2]|0;j=j/+ln(c[d>>2]|0,c[d+4>>2]|0,F,e);g[J+216+(c[J+24+108>>2]<<2)>>2]=j;z=f+40|0;v=f+48|0;j=+ln(c[z>>2]|0,c[z+4>>2]|0,c[v>>2]|0,c[v+4>>2]|0);j=j/+ln(c[d>>2]|0,c[d+4>>2]|0,F,e);g[J+216+(c[J+24+112>>2]<<2)>>2]=j;v=f+56|0;z=f+64|0;j=+ln(c[v>>2]|0,c[v+4>>2]|0,c[z>>2]|0,c[z+4>>2]|0);j=j/+ln(c[d>>2]|0,c[d+4>>2]|0,F,e)}g[J+216+(c[J+24+104>>2]<<2)>>2]=j;j=+g[J+216>>2]*+g[J+24>>2]+ +g[J+24+16>>2];p=+g[J+216+4>>2]*+g[J+24+4>>2]+ +g[J+24+20>>2];q=+g[J+216+8>>2]*+g[J+24+8>>2]+ +g[J+24+24>>2];h=c[b+4>>2]|0;if((h|0)==(c[b+8>>2]|0)?(H=h|0?h<<1:1,(h|0)<(H|0)):0){if(!H)o=0;else{c[6435]=(c[6435]|0)+1;h=yc((H<<4|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}o=h;h=c[b+4>>2]|0}if((h|0)>0){n=0;do{e=o+(n<<4)|0;F=(c[b+12>>2]|0)+(n<<4)|0;c[e>>2]=c[F>>2];c[e+4>>2]=c[F+4>>2];c[e+8>>2]=c[F+8>>2];c[e+12>>2]=c[F+12>>2];n=n+1|0}while((n|0)!=(h|0))}h=c[b+12>>2]|0;if(h|0){if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;c[b+12>>2]=o;c[b+8>>2]=H;h=c[b+4>>2]|0}F=c[b+12>>2]|0;g[F+(h<<4)>>2]=j;g[F+(h<<4)+4>>2]=p;g[F+(h<<4)+8>>2]=q;g[F+(h<<4)+12>>2]=0.0;c[b+4>>2]=(c[b+4>>2]|0)+1;F=c[f+8>>2]|0;if(!F)n=r;else{e=F;f=-1;z=r;d=-1;while(1){v=e+20|0;h=c[v>>2]|0;if((h|0)<0){u=c[b+24>>2]|0;c[J+12>>2]=0;c[J+12+4>>2]=0;c[J+12+8>>2]=0;do if((u|0)==(c[b+28>>2]|0)){r=u|0?u<<1:1;if((u|0)>=(r|0)){h=u;break}if(!r){h=0;n=u}else{c[6435]=(c[6435]|0)+1;h=yc((r*12|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}n=c[b+24>>2]|0}if((n|0)>0){o=0;do{s=h+(o*12|0)|0;K=(c[b+32>>2]|0)+(o*12|0)|0;c[s>>2]=c[K>>2];c[s+4>>2]=c[K+4>>2];c[s+8>>2]=c[K+8>>2];o=o+1|0}while((o|0)!=(n|0))}n=c[b+32>>2]|0;if(n|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=h;c[b+28>>2]=r;h=c[b+24>>2]|0}else h=u;while(0);h=(c[b+32>>2]|0)+(h*12|0)|0;c[h>>2]=c[J+12>>2];c[h+4>>2]=c[J+12+4>>2];c[h+8>>2]=c[J+12+8>>2];h=(c[b+24>>2]|0)+1|0;c[b+24>>2]=h;c[J>>2]=0;c[J+4>>2]=0;c[J+8>>2]=0;do if((h|0)==(c[b+28>>2]|0)){r=h|0?h<<1:1;if((h|0)>=(r|0))break;if(!r)o=0;else{c[6435]=(c[6435]|0)+1;h=yc((r*12|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}o=h;h=c[b+24>>2]|0}if((h|0)>0){n=0;do{K=o+(n*12|0)|0;s=(c[b+32>>2]|0)+(n*12|0)|0;c[K>>2]=c[s>>2];c[K+4>>2]=c[s+4>>2];c[K+8>>2]=c[s+8>>2];n=n+1|0}while((n|0)!=(h|0))}h=c[b+32>>2]|0;if(h|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=o;c[b+28>>2]=r;h=c[b+24>>2]|0}while(0);s=(c[b+32>>2]|0)+(h*12|0)|0;c[s>>2]=c[J>>2];c[s+4>>2]=c[J+4>>2];c[s+8>>2]=c[J+8>>2];c[b+24>>2]=(c[b+24>>2]|0)+1;s=c[b+32>>2]|0;c[v>>2]=u;c[(c[e+8>>2]|0)+20>>2]=u+1;c[s+(u*12|0)+4>>2]=1;c[s+((u+1|0)*12|0)+4>>2]=-1;r=c[e+12>>2]|0;h=c[r+104>>2]|0;if((h|0)<0){c[r+104>>2]=l;do if((l|0)==(m|0)){o=m|0?m<<1:1;if((m|0)>=(o|0)){n=z;break}do if(!o)n=0;else{c[6435]=(c[6435]|0)+1;h=yc((o<<2|3)+16|0)|0;if(!h){n=0;break}c[(h+4+15&-16)+-4>>2]=h;n=h+4+15&-16}while(0);if((m|0)<=0){if(!z){m=o;break}}else{h=0;do{c[n+(h<<2)>>2]=c[z+(h<<2)>>2];h=h+1|0}while((h|0)!=(m|0))}c[6436]=(c[6436]|0)+1;hd(c[z+-4>>2]|0);m=o}else n=z;while(0);c[n+(l<<2)>>2]=r;h=l;l=l+1|0}else n=z;c[s+(u*12|0)+8>>2]=h;c[s+((u+1|0)*12|0)+8>>2]=G;h=c[v>>2]|0}else n=z;if((d|0)>-1)c[(c[b+32>>2]|0)+(h*12|0)>>2]=d-h;else f=h;e=c[e>>2]|0;if((e|0)==(F|0))break;else{z=n;d=h}}c[(c[b+32>>2]|0)+(f*12|0)>>2]=h-f}h=G+1|0;if((h|0)>=(l|0))break;f=c[n+(h<<2)>>2]|0;G=h;r=n}if((G|0)>-1){v=0;while(1){s=c[(c[n+(v<<2)>>2]|0)+8>>2]|0;if(s|0){u=s;do{r=u+20|0;f=c[r>>2]|0;if((f|0)>-1){h=c[b+44>>2]|0;do if((h|0)==(c[b+48>>2]|0)){o=h|0?h<<1:1;if((h|0)>=(o|0))break;if(!o)f=0;else{c[6435]=(c[6435]|0)+1;f=yc((o<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=c[b+44>>2]|0}m=c[b+52>>2]|0;if((h|0)<=0){if(m)I=173}else{l=0;do{c[f+(l<<2)>>2]=c[m+(l<<2)>>2];l=l+1|0}while((l|0)!=(h|0));I=173}if((I|0)==173){I=0;if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0)}c[b+52>>2]=0;h=c[b+44>>2]|0}a[b+56>>0]=1;c[b+52>>2]=f;c[b+48>>2]=o;f=c[r>>2]|0}while(0);c[(c[b+52>>2]|0)+(h<<2)>>2]=f;c[b+44>>2]=(c[b+44>>2]|0)+1;f=u;do{c[f+20>>2]=-1;f=c[(c[f+8>>2]|0)+4>>2]|0}while((f|0)!=(u|0))}u=c[u>>2]|0}while((u|0)!=(s|0))}if((v|0)==(G|0))break;else v=v+1|0}}if(n|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}}Zi(J+24|0);i=J;return}function Ec(b){b=b|0;var d=0,e=0.0,f=0.0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0;I=i;i=i+64|0;if(!(a[b+356>>0]|0)){b=a[b+312>>0]|0;b=b<<24>>24!=0;i=I;return b|0}c[b+336>>2]=0;c[b+336+4>>2]=0;c[b+336+8>>2]=0;c[b+336+12>>2]=0;a[b+336+16>>0]=0;h=a[b+332>>0]|0;a[b+332>>0]=h&-16;a[b+356>>0]=0;switch(c[b>>2]|0){case 0:{a[b+312>>0]=0;b=0;b=b<<24>>24!=0;i=I;return b|0}case 1:{c[b+244>>2]=c[b+84>>2];c[b+244+4>>2]=c[b+84+4>>2];c[b+244+8>>2]=c[b+84+8>>2];c[b+244+12>>2]=c[b+84+12>>2];c[b+260>>2]=c[b+164>>2];c[b+260+4>>2]=c[b+164+4>>2];c[b+260+8>>2]=c[b+164+8>>2];c[b+260+12>>2]=c[b+164+12>>2];E=+g[b+248>>2]-+g[b+264>>2];F=+g[b+252>>2]-+g[b+268>>2];g[b+276>>2]=+g[b+244>>2]-+g[b+260>>2];g[b+280>>2]=E;g[b+284>>2]=F;g[b+288>>2]=0.0;c[b+336>>2]=0;c[b+336+4>>2]=0;c[b+336+8>>2]=0;c[b+336+12>>2]=0;a[b+336+16>>0]=0;a[b+332>>0]=h&-16;g[b+336>>2]=1.0;g[b+340>>2]=0.0;g[b+344>>2]=0.0;g[b+348>>2]=0.0;a[b+312>>0]=1;b=1;b=b<<24>>24!=0;i=I;return b|0}case 2:{e=+g[b+4>>2];f=+g[b+8>>2];j=+g[b+12>>2];k=+g[b+20>>2]-e;l=+g[b+24>>2]-f;m=+g[b+28>>2]-j;do if((0.0-e)*k+(0.0-f)*l+(0.0-j)*m>0.0)if((0.0-e)*k+(0.0-f)*l+(0.0-j)*m>0]=h&-16|3;h=h&-16|3;f=((0.0-e)*k+(0.0-f)*l+(0.0-j)*m)/(k*k+l*l+m*m);break}else{a[b+332>>0]=h&-16|2;h=h&-16|2;f=1.0;break}else{a[b+332>>0]=h&-16|1;h=h&-16|1;f=0.0}while(0);e=1.0-f;g[b+336>>2]=e;g[b+340>>2]=f;g[b+344>>2]=0.0;g[b+348>>2]=0.0;A=+g[b+84>>2];C=+g[b+88>>2];E=+g[b+92>>2];A=A+f*(+g[b+100>>2]-A);C=C+f*(+g[b+104>>2]-C);E=E+f*(+g[b+108>>2]-E);g[b+244>>2]=A;g[b+248>>2]=C;g[b+252>>2]=E;g[b+256>>2]=0.0;B=+g[b+164>>2];D=+g[b+168>>2];F=+g[b+172>>2];B=B+f*(+g[b+180>>2]-B);D=D+f*(+g[b+184>>2]-D);F=F+f*(+g[b+188>>2]-F);g[b+260>>2]=B;g[b+264>>2]=D;g[b+268>>2]=F;g[b+272>>2]=0.0;g[b+276>>2]=A-B;g[b+280>>2]=C-D;g[b+284>>2]=E-F;g[b+288>>2]=0.0;if(!(h&2)){c[b>>2]=1;d=0}else d=1;if(!(h&1)){c[b>>2]=d;H=b+4+(d<<4)|0;c[b+4>>2]=c[H>>2];c[b+4+4>>2]=c[H+4>>2];c[b+4+8>>2]=c[H+8>>2];c[b+4+12>>2]=c[H+12>>2];H=b+84+(d<<4)|0;c[b+84>>2]=c[H>>2];c[b+84+4>>2]=c[H+4>>2];c[b+84+8>>2]=c[H+8>>2];c[b+84+12>>2]=c[H+12>>2];H=b+164+(d<<4)|0;c[b+164>>2]=c[H>>2];c[b+164+4>>2]=c[H+4>>2];c[b+164+8>>2]=c[H+8>>2];c[b+164+12>>2]=c[H+12>>2]}H=(!(e>=0.0)|!(f>=0.0))&1^1;a[b+312>>0]=H;b=H;b=b<<24>>24!=0;i=I;return b|0}case 3:{c[I+16>>2]=0;c[I+16+4>>2]=0;c[I+16+8>>2]=0;c[I+16+12>>2]=0;Ve(I+16|0,b+4|0,b+20|0,b+36|0,b+316|0);F=+g[b+336>>2];e=+g[b+340>>2];f=+g[b+344>>2];A=+g[b+84>>2]*F+ +g[b+100>>2]*e+ +g[b+116>>2]*f;C=F*+g[b+88>>2]+e*+g[b+104>>2]+f*+g[b+120>>2];E=F*+g[b+92>>2]+e*+g[b+108>>2]+f*+g[b+124>>2];g[b+244>>2]=A;g[b+248>>2]=C;g[b+252>>2]=E;g[b+256>>2]=0.0;B=+g[b+164>>2]*F+ +g[b+180>>2]*e+ +g[b+196>>2]*f;D=F*+g[b+168>>2]+e*+g[b+184>>2]+f*+g[b+200>>2];F=F*+g[b+172>>2]+e*+g[b+188>>2]+f*+g[b+204>>2];g[b+260>>2]=B;g[b+264>>2]=D;g[b+268>>2]=F;g[b+272>>2]=0.0;g[b+276>>2]=A-B;g[b+280>>2]=C-D;g[b+284>>2]=E-F;g[b+288>>2]=0.0;h=c[b>>2]|0;do if((h|0)>3){d=a[b+332>>0]|0;if(!(d&8)){c[b>>2]=h+-1;H=b+4+(h+-1<<4)|0;c[b+52>>2]=c[H>>2];c[b+52+4>>2]=c[H+4>>2];c[b+52+8>>2]=c[H+8>>2];c[b+52+12>>2]=c[H+12>>2];H=b+84+(h+-1<<4)|0;c[b+132>>2]=c[H>>2];c[b+132+4>>2]=c[H+4>>2];c[b+132+8>>2]=c[H+8>>2];c[b+132+12>>2]=c[H+12>>2];H=b+164+(h+-1<<4)|0;c[b+212>>2]=c[H>>2];c[b+212+4>>2]=c[H+4>>2];c[b+212+8>>2]=c[H+8>>2];c[b+212+12>>2]=c[H+12>>2];h=h+-1|0;H=21}else H=21}else{if((h|0)>2){d=a[b+332>>0]|0;h=3;H=21;break}if((h|0)>1){d=a[b+332>>0]|0;h=2;H=25;break}if((h|0)>0){o=a[b+332>>0]|0;n=1;H=29}}while(0);if((H|0)==21)if(!(d&4)){h=h+-1|0;c[b>>2]=h;c[b+36>>2]=c[b+4+(h<<4)>>2];c[b+36+4>>2]=c[b+4+(h<<4)+4>>2];c[b+36+8>>2]=c[b+4+(h<<4)+8>>2];c[b+36+12>>2]=c[b+4+(h<<4)+12>>2];c[b+116>>2]=c[b+84+(h<<4)>>2];c[b+116+4>>2]=c[b+84+(h<<4)+4>>2];c[b+116+8>>2]=c[b+84+(h<<4)+8>>2];c[b+116+12>>2]=c[b+84+(h<<4)+12>>2];c[b+196>>2]=c[b+164+(h<<4)>>2];c[b+196+4>>2]=c[b+164+(h<<4)+4>>2];c[b+196+8>>2]=c[b+164+(h<<4)+8>>2];c[b+196+12>>2]=c[b+164+(h<<4)+12>>2];H=25}else H=25;if((H|0)==25)if(!(d&2)){n=h+-1|0;c[b>>2]=n;c[b+20>>2]=c[b+4+(n<<4)>>2];c[b+20+4>>2]=c[b+4+(n<<4)+4>>2];c[b+20+8>>2]=c[b+4+(n<<4)+8>>2];c[b+20+12>>2]=c[b+4+(n<<4)+12>>2];c[b+100>>2]=c[b+84+(n<<4)>>2];c[b+100+4>>2]=c[b+84+(n<<4)+4>>2];c[b+100+8>>2]=c[b+84+(n<<4)+8>>2];c[b+100+12>>2]=c[b+84+(n<<4)+12>>2];c[b+180>>2]=c[b+164+(n<<4)>>2];c[b+180+4>>2]=c[b+164+(n<<4)+4>>2];c[b+180+8>>2]=c[b+164+(n<<4)+8>>2];c[b+180+12>>2]=c[b+164+(n<<4)+12>>2];o=d;H=29}else{o=d;n=h;H=29}if((H|0)==29?(o&1)==0:0){H=n+-1|0;c[b>>2]=H;c[b+4>>2]=c[b+4+(H<<4)>>2];c[b+4+4>>2]=c[b+4+(H<<4)+4>>2];c[b+4+8>>2]=c[b+4+(H<<4)+8>>2];c[b+4+12>>2]=c[b+4+(H<<4)+12>>2];c[b+84>>2]=c[b+84+(H<<4)>>2];c[b+84+4>>2]=c[b+84+(H<<4)+4>>2];c[b+84+8>>2]=c[b+84+(H<<4)+8>>2];c[b+84+12>>2]=c[b+84+(H<<4)+12>>2];c[b+164>>2]=c[b+164+(H<<4)>>2];c[b+164+4>>2]=c[b+164+(H<<4)+4>>2];c[b+164+8>>2]=c[b+164+(H<<4)+8>>2];c[b+164+12>>2]=c[b+164+(H<<4)+12>>2]}if((e>=0.0?!(+g[b+336>>2]>=0.0):1)|!(f>=0.0))d=0;else d=+g[b+348>>2]>=0.0&1;a[b+312>>0]=d;b=d;b=b<<24>>24!=0;i=I;return b|0}case 4:{c[I>>2]=0;c[I+4>>2]=0;c[I+8>>2]=0;c[I+12>>2]=0;q=I+16+16|0;a[q>>0]=0;c[b+316>>2]=0;c[b+316+4>>2]=0;c[b+316+8>>2]=0;c[b+316+12>>2]=0;a[b+332>>0]=h|15;K=+g[b+20>>2];T=+g[b+4>>2];Q=+g[b+24>>2];J=+g[b+8>>2];M=+g[b+28>>2];U=+g[b+12>>2];P=+g[b+36>>2];R=+g[b+40>>2];N=+g[b+44>>2];L=+g[b+52>>2];S=+g[b+56>>2];O=+g[b+60>>2];V=((Q-J)*(N-U)-(M-U)*(R-J))*(L-T)+((M-U)*(P-T)-(K-T)*(N-U))*(S-J)+((K-T)*(R-J)-(Q-J)*(P-T))*(O-U);h=V*V<9.99999905104687e-09?-1:((0.0-T)*((Q-J)*(N-U)-(M-U)*(R-J))+(0.0-J)*((M-U)*(P-T)-(K-T)*(N-U))+((K-T)*(R-J)-(Q-J)*(P-T))*(0.0-U))*V<0.0&1;V=(M-U)*((P-T)*(S-J)-(R-J)*(L-T))+((K-T)*((R-J)*(O-U)-(N-U)*(S-J))+(Q-J)*((N-U)*(L-T)-(P-T)*(O-U)));n=V*V<9.99999905104687e-09?-1:((0.0-U)*((P-T)*(S-J)-(R-J)*(L-T))+((0.0-T)*((R-J)*(O-U)-(N-U)*(S-J))+(0.0-J)*((N-U)*(L-T)-(P-T)*(O-U))))*V<0.0&1;V=(N-U)*((Q-J)*(L-T)-(K-T)*(S-J))+((P-T)*((M-U)*(S-J)-(Q-J)*(O-U))+(R-J)*((K-T)*(O-U)-(M-U)*(L-T)));o=V*V<9.99999905104687e-09?-1:((0.0-U)*((Q-J)*(L-T)-(K-T)*(S-J))+((0.0-T)*((M-U)*(S-J)-(Q-J)*(O-U))+(0.0-J)*((K-T)*(O-U)-(M-U)*(L-T))))*V<0.0&1;J=(U-M)*((R-Q)*(L-K)-(P-K)*(S-Q))+((T-K)*((N-M)*(S-Q)-(R-Q)*(O-M))+(J-Q)*((P-K)*(O-M)-(N-M)*(L-K)));p=J*J<9.99999905104687e-09?-1:((0.0-M)*((R-Q)*(L-K)-(P-K)*(S-Q))+((0.0-K)*((N-M)*(S-Q)-(R-Q)*(O-M))+(0.0-Q)*((P-K)*(O-M)-(N-M)*(L-K))))*J<0.0&1;do if((n|h|o|p|0)<0){a[b+352>>0]=1;d=b+312|0;H=70}else{if(!(n|h|o|p)){if(a[b+352>>0]|0){d=b+312|0;H=70;break}a[b+312>>0]=1;c[b+276>>2]=0;c[b+276+4>>2]=0;c[b+276+8>>2]=0;c[b+276+12>>2]=0;d=1;break}if((h|0)!=0?(Ve(I,b+4|0,b+20|0,b+36|0,I+16|0),e=+g[I+16>>2],f=+g[I+16+4>>2],j=+g[I+16+8>>2],k=e-+g[I>>2],l=f-+g[I+4>>2],m=j-+g[I+8>>2],k*k+l*l+m*m<3402823466385288598117041.0e14):0){W=c[I+16+12>>2]|0;g[b+316>>2]=e;g[b+320>>2]=f;g[b+324>>2]=j;c[b+328>>2]=W;W=a[q>>0]|0;a[b+332>>0]=W&1|a[b+332>>0]&-16|W&2|W&4;W=c[I+16+24>>2]|0;h=c[I+16+28>>2]|0;c[b+336>>2]=c[I+16+20>>2];c[b+340>>2]=W;c[b+344>>2]=h;g[b+348>>2]=0.0;e=k*k+l*l+m*m}else e=3402823466385288598117041.0e14;if((n|0)!=0?(Ve(I,b+4|0,b+36|0,b+52|0,I+16|0),r=+g[I+16>>2],s=+g[I+16+4>>2],t=+g[I+16+8>>2],u=r-+g[I>>2],v=s-+g[I+4>>2],w=t-+g[I+8>>2],u*u+v*v+w*w>2]|0;g[b+316>>2]=r;g[b+320>>2]=s;g[b+324>>2]=t;c[b+328>>2]=n;n=a[q>>0]|0;a[b+332>>0]=n<<1&8|(n&1|a[b+332>>0]&-16|n<<1&4);n=c[I+16+24>>2]|0;W=c[I+16+28>>2]|0;c[b+336>>2]=c[I+16+20>>2];g[b+340>>2]=0.0;c[b+344>>2]=n;c[b+348>>2]=W;e=u*u+v*v+w*w}if((o|0)!=0?(Ve(I,b+4|0,b+52|0,b+20|0,I+16|0),x=+g[I+16>>2],y=+g[I+16+4>>2],z=+g[I+16+8>>2],A=x-+g[I>>2],B=y-+g[I+4>>2],C=z-+g[I+8>>2],A*A+B*B+C*C>2]|0;g[b+316>>2]=x;g[b+320>>2]=y;g[b+324>>2]=z;c[b+328>>2]=o;o=a[q>>0]|0;a[b+332>>0]=o<<2&8|(o&1|a[b+332>>0]&-16|(o&255)>>>1&2);o=c[I+16+28>>2]|0;W=c[I+16+24>>2]|0;c[b+336>>2]=c[I+16+20>>2];c[b+340>>2]=o;g[b+344>>2]=0.0;c[b+348>>2]=W;e=A*A+B*B+C*C}if(p|0?(Ve(I,b+20|0,b+52|0,b+36|0,I+16|0),D=+g[I+16>>2],E=+g[I+16+4>>2],F=+g[I+16+8>>2],T=D-+g[I>>2],U=E-+g[I+4>>2],V=F-+g[I+8>>2],T*T+U*U+V*V>2]|0;g[b+316>>2]=D;g[b+320>>2]=E;g[b+324>>2]=F;c[b+328>>2]=p;p=a[q>>0]|0;a[b+332>>0]=p&4|a[b+332>>0]&-16|p<<1&2|p<<2&8;p=c[I+16+20>>2]|0;q=c[I+16+28>>2]|0;W=c[I+16+24>>2]|0;g[b+336>>2]=0.0;c[b+340>>2]=p;c[b+344>>2]=q;c[b+348>>2]=W}O=+g[b+336>>2];P=+g[b+340>>2];V=+g[b+344>>2];e=+g[b+348>>2];Q=+g[b+84>>2]*O+ +g[b+100>>2]*P+ +g[b+116>>2]*V+ +g[b+132>>2]*e;S=O*+g[b+88>>2]+P*+g[b+104>>2]+V*+g[b+120>>2]+e*+g[b+136>>2];U=O*+g[b+92>>2]+P*+g[b+108>>2]+V*+g[b+124>>2]+e*+g[b+140>>2];g[b+244>>2]=Q;g[b+248>>2]=S;g[b+252>>2]=U;g[b+256>>2]=0.0;R=+g[b+164>>2]*O+ +g[b+180>>2]*P+ +g[b+196>>2]*V+ +g[b+212>>2]*e;T=O*+g[b+168>>2]+P*+g[b+184>>2]+V*+g[b+200>>2]+e*+g[b+216>>2];V=O*+g[b+172>>2]+P*+g[b+188>>2]+V*+g[b+204>>2]+e*+g[b+220>>2];g[b+260>>2]=R;g[b+264>>2]=T;g[b+268>>2]=V;g[b+272>>2]=0.0;g[b+276>>2]=Q-R;g[b+280>>2]=S-T;g[b+284>>2]=U-V;g[b+288>>2]=0.0;h=c[b>>2]|0;do if((h|0)>3){d=a[b+332>>0]|0;if(!(d&8)){c[b>>2]=h+-1;H=b+4+(h+-1<<4)|0;c[b+52>>2]=c[H>>2];c[b+52+4>>2]=c[H+4>>2];c[b+52+8>>2]=c[H+8>>2];c[b+52+12>>2]=c[H+12>>2];H=b+84+(h+-1<<4)|0;c[b+132>>2]=c[H>>2];c[b+132+4>>2]=c[H+4>>2];c[b+132+8>>2]=c[H+8>>2];c[b+132+12>>2]=c[H+12>>2];H=b+164+(h+-1<<4)|0;c[b+212>>2]=c[H>>2];c[b+212+4>>2]=c[H+4>>2];c[b+212+8>>2]=c[H+8>>2];c[b+212+12>>2]=c[H+12>>2];h=h+-1|0;H=54}else H=54}else{if((h|0)>2){d=a[b+332>>0]|0;h=3;H=54;break}if((h|0)>1){d=a[b+332>>0]|0;h=2;H=58;break}if((h|0)>0){d=a[b+332>>0]|0;G=1;H=62}}while(0);if((H|0)==54)if(!(d&4)){h=h+-1|0;c[b>>2]=h;c[b+36>>2]=c[b+4+(h<<4)>>2];c[b+36+4>>2]=c[b+4+(h<<4)+4>>2];c[b+36+8>>2]=c[b+4+(h<<4)+8>>2];c[b+36+12>>2]=c[b+4+(h<<4)+12>>2];c[b+116>>2]=c[b+84+(h<<4)>>2];c[b+116+4>>2]=c[b+84+(h<<4)+4>>2];c[b+116+8>>2]=c[b+84+(h<<4)+8>>2];c[b+116+12>>2]=c[b+84+(h<<4)+12>>2];c[b+196>>2]=c[b+164+(h<<4)>>2];c[b+196+4>>2]=c[b+164+(h<<4)+4>>2];c[b+196+8>>2]=c[b+164+(h<<4)+8>>2];c[b+196+12>>2]=c[b+164+(h<<4)+12>>2];H=58}else H=58;if((H|0)==58)if(!(d&2)){G=h+-1|0;c[b>>2]=G;c[b+20>>2]=c[b+4+(G<<4)>>2];c[b+20+4>>2]=c[b+4+(G<<4)+4>>2];c[b+20+8>>2]=c[b+4+(G<<4)+8>>2];c[b+20+12>>2]=c[b+4+(G<<4)+12>>2];c[b+100>>2]=c[b+84+(G<<4)>>2];c[b+100+4>>2]=c[b+84+(G<<4)+4>>2];c[b+100+8>>2]=c[b+84+(G<<4)+8>>2];c[b+100+12>>2]=c[b+84+(G<<4)+12>>2];c[b+180>>2]=c[b+164+(G<<4)>>2];c[b+180+4>>2]=c[b+164+(G<<4)+4>>2];c[b+180+8>>2]=c[b+164+(G<<4)+8>>2];c[b+180+12>>2]=c[b+164+(G<<4)+12>>2];H=62}else{G=h;H=62}if((H|0)==62?(d&1)==0:0){W=G+-1|0;c[b>>2]=W;c[b+4>>2]=c[b+4+(W<<4)>>2];c[b+4+4>>2]=c[b+4+(W<<4)+4>>2];c[b+4+8>>2]=c[b+4+(W<<4)+8>>2];c[b+4+12>>2]=c[b+4+(W<<4)+12>>2];c[b+84>>2]=c[b+84+(W<<4)>>2];c[b+84+4>>2]=c[b+84+(W<<4)+4>>2];c[b+84+8>>2]=c[b+84+(W<<4)+8>>2];c[b+84+12>>2]=c[b+84+(W<<4)+12>>2];c[b+164>>2]=c[b+164+(W<<4)>>2];c[b+164+4>>2]=c[b+164+(W<<4)+4>>2];c[b+164+8>>2]=c[b+164+(W<<4)+8>>2];c[b+164+12>>2]=c[b+164+(W<<4)+12>>2]}if((+g[b+336>>2]>=0.0?+g[b+340>>2]>=0.0:0)?+g[b+344>>2]>=0.0:0)d=e>=0.0&1;else d=0;a[b+312>>0]=d}while(0);if((H|0)==70){a[d>>0]=0;d=0}W=d;W=W<<24>>24!=0;i=I;return W|0}default:{a[b+312>>0]=0;W=0;W=W<<24>>24!=0;i=I;return W|0}}return 0}function Fc(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0.0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,P=0,S=0.0,U=0.0,V=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0,fa=0.0,ga=0.0,ha=0.0,ia=0.0,ja=0.0,ka=0.0,la=0.0,ma=0.0,na=0.0,oa=0.0,pa=0.0,qa=0,ra=0.0,sa=0.0,ta=0.0,ua=0.0,va=0.0,wa=0.0;qa=i;i=i+144|0;g[b+504>>2]=0.0;g[b+500>>2]=0.0;a[b+525>>0]=0;a[b+526>>0]=0;if(a[b+552>>0]|0?(a[b+527>>0]|0)==0:0){wa=+g[b+556>>2];ua=+g[b+560>>2];pa=+g[b+564>>2];ta=+g[b+568>>2];ea=wa*(2.0/(wa*wa+ua*ua+pa*pa+ta*ta));va=ua*(2.0/(wa*wa+ua*ua+pa*pa+ta*ta));sa=pa*(2.0/(wa*wa+ua*ua+pa*pa+ta*ta));fa=+g[b+300>>2];X=+g[d>>2];ga=+g[b+316>>2];Y=+g[d+4>>2];ha=+g[b+332>>2];Z=+g[d+8>>2];ja=+g[b+304>>2];la=+g[b+320>>2];na=+g[b+336>>2];ba=+g[b+308>>2];ca=+g[b+324>>2];da=+g[b+340>>2];_=+g[d+16>>2];$=+g[d+20>>2];aa=+g[d+24>>2];ka=+g[d+32>>2];ma=+g[d+36>>2];oa=+g[d+40>>2];v=+g[b+348>>2];u=+g[b+352>>2];r=+g[b+356>>2];z=+g[b+364>>2];ra=+g[e>>2];A=+g[b+380>>2];n=+g[e+4>>2];B=+g[b+396>>2];m=+g[e+8>>2];C=+g[b+368>>2];D=+g[b+384>>2];E=+g[b+400>>2];w=+g[b+372>>2];x=+g[b+388>>2];y=+g[b+404>>2];o=+g[e+16>>2];q=+g[e+20>>2];l=+g[e+24>>2];F=+g[e+32>>2];H=+g[e+36>>2];J=+g[e+40>>2];G=+g[b+412>>2];I=+g[b+416>>2];j=+g[b+420>>2];L=(1.0-(ua*va+pa*sa))*(z*ra+A*n+B*m)+(wa*va+ta*sa)*(ra*C+n*D+m*E)+(wa*sa-ta*va)*(ra*w+n*x+m*y);M=(wa*va-ta*sa)*(z*ra+A*n+B*m)+(1.0-(wa*ea+pa*sa))*(ra*C+n*D+m*E)+(ua*sa+ta*ea)*(ra*w+n*x+m*y);K=(wa*sa+ta*va)*(z*ra+A*n+B*m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2]+va*+g[f+20>>2]+wa*+g[f+36>>2])+wa*(ua*+g[f+8>>2]+va*+g[f+24>>2]+wa*+g[f+40>>2])+(ua*(ua*+g[h>>2]+va*+g[h+16>>2]+wa*+g[h+32>>2])+va*(ua*+g[h+4>>2]+va*+g[h+20>>2]+wa*+g[h+36>>2])+wa*(ua*+g[h+8>>2]+va*+g[h+24>>2]+wa*+g[h+40>>2])))}}else P=20;a:do if((P|0)==20){C=+g[b+300>>2];D=+g[b+316>>2];E=+g[b+332>>2];F=+g[d>>2];G=+g[d+4>>2];H=+g[d+8>>2];I=+g[d+16>>2];J=+g[d+20>>2];K=+g[d+24>>2];L=+g[d+32>>2];M=+g[d+36>>2];u=+g[d+40>>2];v=+g[b+304>>2];w=+g[b+320>>2];x=+g[b+336>>2];y=+g[b+308>>2];z=+g[b+324>>2];A=+g[b+340>>2];l=+g[b+364>>2];o=+g[b+380>>2];q=+g[b+396>>2];B=l*+g[e>>2]+o*+g[e+4>>2]+q*+g[e+8>>2];r=l*+g[e+16>>2]+o*+g[e+20>>2]+q*+g[e+24>>2];q=l*+g[e+32>>2]+o*+g[e+36>>2]+q*+g[e+40>>2];o=(C*F+D*G+E*H)*B+(C*I+D*J+E*K)*r+(C*L+D*M+E*u)*q;l=(F*v+G*w+H*x)*B+(I*v+J*w+K*x)*r+(L*v+M*w+u*x)*q;j=(F*y+G*z+H*A)*B+(I*y+J*z+K*A)*r+(L*y+M*z+u*A)*q;n=+g[b+444>>2];m=+g[b+456>>2];do if(n>2];if(n>0]=1;g[b+460>>2]=-((C*L+D*M+E*u)*r-(C*I+D*J+E*K)*q);g[b+464>>2]=-((C*F+D*G+E*H)*q-(C*L+D*M+E*u)*B);g[b+468>>2]=-((C*I+D*J+E*K)*B-(C*F+D*G+E*H)*r);g[b+472>>2]=0.0;break a}if(+N(+o)<1.1920928955078125e-07?+N(+j)<1.1920928955078125e-07:0){m=o;break}a[b+526>>0]=1;if(n>=m){l=+W(+j,+o);if(l>n){m=+Q(+n);l=0.0;j=+R(+n);break}if(l<-n){m=+Q(+n);l=0.0;j=-+R(+n)}else{m=o;l=0.0}}else m=o}else{if(+N(+o)<1.1920928955078125e-07?+N(+l)<1.1920928955078125e-07:0){m=o;break}a[b+526>>0]=1;if(n>=m){j=+W(+l,+o);if(j>n){m=+Q(+n);l=+R(+n);j=0.0;break}if(j<-n){m=+Q(+n);l=-+R(+n);j=0.0}else{m=o;j=0.0}}else m=o}while(0);va=(F*y+G*z+H*A)*j+((F*v+G*w+H*x)*l+(C*F+D*G+E*H)*m);ta=(I*y+J*z+K*A)*j+((I*v+J*w+K*x)*l+(C*I+D*J+E*K)*m);sa=(L*y+M*z+u*A)*j+((L*v+M*w+u*x)*l+(C*L+D*M+E*u)*m);ua=1.0/+O(+(sa*sa+(va*va+ta*ta)));g[b+472>>2]=0.0;wa=+O(+((r*ua*sa-q*ua*ta)*(r*ua*sa-q*ua*ta)+(q*ua*va-B*ua*sa)*(q*ua*va-B*ua*sa)+(B*ua*ta-r*ua*va)*(B*ua*ta-r*ua*va)));g[b+504>>2]=wa;g[b+460>>2]=-((r*ua*sa-q*ua*ta)*(1.0/wa));g[b+464>>2]=-((q*ua*va-B*ua*sa)*(1.0/wa));g[b+468>>2]=-((B*ua*ta-r*ua*va)*(1.0/wa))}while(0);r=+g[b+452>>2];if(!(r>=0.0)){g[b+512>>2]=0.0;i=qa;return}j=U*S<-1.0?-1.0:U*S;j=+T(+(j>1.0?1.0:j))*2.0;if(j>3.1415927410125732){q=-(U*S)<-1.0?-1.0:-(U*S);q=+T(+(q>1.0?1.0:q))*2.0;l=-(U*V);m=-(U*X);j=-(U*Y)}else{q=j;l=U*V;m=U*X;j=U*Y}g[b+512>>2]=q;if(q>1.1920928955078125e-07){wa=1.0/+O(+(l*l+m*m+j*j));o=l*wa;n=j*wa;m=m*wa}else{o=l;n=j}j=+g[b+428>>2];if(q>r*j){a[b+525>>0]=1;l=q-r*j;if(q>2]=j;g[b+508>>2]=l;va=-o;ua=-m;sa=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==0?e+4|0:d+232|0)>>2];if(!(x<<24>>24==0|y&h)){if(U&1|0)c[(c[e+32>>2]|0)+(D<<2)>>2]=c[d+212>>2];o=+g[d+1100>>2];f=+g[d+1080>>2];j=+g[d+184>>2];m=+g[d+188>>2];n=p*+g[e>>2];do if(!(j>m))if(!(j==m)){if(o/n<0.0)if(f>=j?j-o/n>f:0){f=(j-f)/(o/n);break}else{f=f0.0)if(f<=m?m-o/nm?0.0:1.0;break}else f=0.0}else f=0.0;else f=1.0;while(0);g[V+(D<<2)>>2]=+g[V+(D<<2)>>2]-ea*f*o;g[l>>2]=+g[l>>2]-+g[d+1104>>2]*+g[e>>2];g[t>>2]=+g[d+1104>>2]*+g[e>>2]+ +g[t>>2]}if(y){g[V+(D<<2)>>2]=+g[V+(D<<2)>>2]+u*p*+g[e>>2];if(U&256|0)c[(c[e+32>>2]|0)+(D<<2)>>2]=c[d+244>>2];do if(!h)if((E|0)==1){g[l>>2]=-3402823466385288598117041.0e14;g[t>>2]=0.0;break}else{g[l>>2]=0.0;g[t>>2]=3402823466385288598117041.0e14;break}else{g[l>>2]=-3402823466385288598117041.0e14;g[t>>2]=3402823466385288598117041.0e14}while(0);ia=1.0-+g[d+240>>2];j=+N(+ia);do if(!(ia!=ia|0.0!=0.0|ia==0.0)){f=ea*(q*+g[da+312>>2]+r*+g[da+316>>2]+s*+g[da+320>>2]-(q*+g[fa+312>>2]+r*+g[fa+316>>2]+s*+g[fa+320>>2]));if((E|0)==1){if(!(f<0.0))break;if(!(+g[V+(D<<2)>>2]<-(j*f)))break;g[V+(D<<2)>>2]=-(j*f);break}else{if(!(f>0.0))break;if(!(+g[V+(D<<2)>>2]>-(j*f)))break;g[V+(D<<2)>>2]=-(j*f);break}}while(0);g[V+(D<<2)>>2]=+g[d+232>>2]*+g[V+(D<<2)>>2];h=5}else h=5}else h=4;if((H&65535)<256){y=0;v=0.0}else{v=+g[d+1088>>2];y=v>0.0?1:2}l=a[d+1112>>0]|0;t=(y|0)!=0;if(!(l&255|y)){i=ga;return}x=_(c[e+24>>2]|0,h)|0;fa=c[e+12>>2]|0;c[fa+(x<<2)>>2]=ca;c[fa+(x+1<<2)>>2]=z;c[fa+(x+2<<2)>>2]=A;w=(c[k>>2]=ca,+g[k>>2]);g[T+(x<<2)>>2]=-w;u=(c[k>>2]=z,+g[k>>2]);g[T+(x+1<<2)>>2]=-u;s=(c[k>>2]=A,+g[k>>2]);g[T+(x+2<<2)>>2]=-s;p=+g[d+192>>2];q=+g[d+196>>2];r=+g[((U&2048|0)==0?e+4|0:d+248|0)>>2];if(!(l<<24>>24==0|t&p==q)){if(!(U&4)){m=q;n=p}else{c[(c[e+32>>2]|0)+(x<<2)>>2]=c[d+228>>2];m=+g[d+196>>2];n=+g[d+192>>2]}f=+g[d+1084>>2];o=+g[d+1116>>2];j=r*+g[e>>2];do if(!(n>m))if(!(n==m)){if(o/j<0.0)if(f>=n?n-o/j>f:0){f=(n-f)/(o/j);break}else{f=f0.0)if(f<=m?m-o/jm?0.0:1.0;break}else f=0.0}else f=0.0;else f=1.0;while(0);g[V+(x<<2)>>2]=f*o;g[(c[e+36>>2]|0)+(x<<2)>>2]=-(+g[d+1120>>2]*+g[e>>2]);g[(c[e+40>>2]|0)+(x<<2)>>2]=+g[d+1120>>2]*+g[e>>2]}if(!t){i=ga;return}g[V+(x<<2)>>2]=+g[V+(x<<2)>>2]+v*r*+g[e>>2];if(U&1024|0)c[(c[e+32>>2]|0)+(x<<2)>>2]=c[d+260>>2];do if(!(p==q)){l=(c[e+36>>2]|0)+(x<<2)|0;h=c[e+40>>2]|0;if((y|0)==1){g[l>>2]=0.0;g[h+(x<<2)>>2]=3402823466385288598117041.0e14;break}else{g[l>>2]=-3402823466385288598117041.0e14;g[h+(x<<2)>>2]=0.0;break}}else{g[(c[e+36>>2]|0)+(x<<2)>>2]=-3402823466385288598117041.0e14;g[(c[e+40>>2]|0)+(x<<2)>>2]=3402823466385288598117041.0e14}while(0);ia=1.0-+g[d+256>>2];j=+N(+ia);do if(!(ia!=ia|0.0!=0.0|ia==0.0)){fa=c[d+28>>2]|0;e=c[d+32>>2]|0;f=w*+g[fa+328>>2]+u*+g[fa+332>>2]+s*+g[fa+336>>2]-(w*+g[e+328>>2]+u*+g[e+332>>2]+s*+g[e+336>>2]);if((y|0)==1){if(!(f<0.0))break;if(!(+g[V+(x<<2)>>2]<-(j*f)))break;g[V+(x<<2)>>2]=-(j*f);break}else{if(!(f>0.0))break;if(!(+g[V+(x<<2)>>2]>-(j*f)))break;g[V+(x<<2)>>2]=-(j*f);break}}while(0);g[V+(x<<2)>>2]=+g[d+248>>2]*+g[V+(x<<2)>>2];i=ga;return}function Hc(d,e){d=d|0;e=e|0;var f=0.0,h=0.0,i=0,j=0,k=0.0,l=0.0,m=0.0,n=0,o=0.0,p=0,q=0,r=0.0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0,fa=0.0,ga=0.0,ha=0.0,ia=0.0,ja=0.0,ka=0.0,la=0.0,ma=0.0,na=0.0,oa=0.0,pa=0,qa=0;pa=c[d+28>>2]|0;qa=c[d+32>>2]|0;q=c[e+24>>2]|0;if(!(a[d+739>>0]|0)){z=+g[d+552>>2];S=+g[pa+4>>2];A=+g[d+568>>2];T=+g[pa+8>>2];B=+g[d+584>>2];U=+g[pa+12>>2];C=+g[d+556>>2];D=+g[d+572>>2];E=+g[d+588>>2];V=+g[d+560>>2];W=+g[d+576>>2];X=+g[d+592>>2];Y=+g[pa+20>>2];Z=+g[pa+24>>2];_=+g[pa+28>>2];$=+g[pa+36>>2];aa=+g[pa+40>>2];ba=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>0]|0)){q=0;r=0.0}else{r=+g[d+708>>2]*+g[d+732>>2];q=r>0.0?1:2}p=(q|0)!=0;if(!((t&65535)>>>8&65535|q))return;g[j+(s*5<<2)>>2]=S*V+T*W+U*X;g[j+((s*5|0)+1<<2)>>2]=V*Y+W*Z+X*_;g[j+((s*5|0)+2<<2)>>2]=V*$+W*aa+X*ba;g[n+(s*5<<2)>>2]=-(S*V+T*W+U*X);g[n+((s*5|0)+1<<2)>>2]=-(V*Y+W*Z+X*_);g[n+((s*5|0)+2<<2)>>2]=-(V*$+W*aa+X*ba);h=+g[d+688>>2];k=+g[d+692>>2];f=+eh(h-k,6.2831854820251465);if(!(f<-3.1415927410125732))if(f>3.1415927410125732)o=f+-6.2831854820251465;else o=f;else o=f+6.2831854820251465;f=+eh(h+k,6.2831854820251465);if(!(f<-3.1415927410125732)){if(f>3.1415927410125732)f=f+-6.2831854820251465}else f=f+6.2831854820251465;j=o==f;n=i+(s*5<<2)|0;g[n>>2]=0.0;i=c[d+748>>2]|0;m=+g[((i&2|0)==0?e+4|0:d+760|0)>>2];if(!((t&65535)>>>8<<16>>16==0|p&j)){if(i&4|0)c[(c[e+32>>2]|0)+(s*5<<2)>>2]=c[d+752>>2];k=+g[d+728>>2];l=+g[d+680>>2];h=o>f?1.0:0.0;do if(!(o>=f)){h=l/(m*+g[e>>2]);if(h<0.0)if(k>=o&o-h>k){f=(o-k)/h;break}else{f=k0.0)if(k<=f&f-hf?0.0:1.0;break}else f=0.0}else f=h;while(0);g[n>>2]=f*l*+g[d+732>>2]+ +g[n>>2];g[(c[e+36>>2]|0)+(s*5<<2)>>2]=-+g[d+684>>2];c[(c[e+40>>2]|0)+(s*5<<2)>>2]=c[d+684>>2]}if(!p)return;g[n>>2]=+g[n>>2]+r*m*+g[e>>2];if(i&1|0)c[(c[e+32>>2]|0)+(s*5<<2)>>2]=c[d+756>>2];do if(!j){j=(c[e+36>>2]|0)+(s*5<<2)|0;i=c[e+40>>2]|0;if((q|0)==1){g[j>>2]=0.0;g[i+(s*5<<2)>>2]=3402823466385288598117041.0e14;break}else{g[j>>2]=-3402823466385288598117041.0e14;g[i+(s*5<<2)>>2]=0.0;break}}else{g[(c[e+36>>2]|0)+(s*5<<2)>>2]=-3402823466385288598117041.0e14;g[(c[e+40>>2]|0)+(s*5<<2)>>2]=3402823466385288598117041.0e14}while(0);h=+g[d+704>>2];do if(h>0.0){f=(S*V+T*W+U*X)*+g[pa+328>>2]+(V*Y+W*Z+X*_)*+g[pa+332>>2]+(V*$+W*aa+X*ba)*+g[pa+336>>2]-((S*V+T*W+U*X)*+g[qa+328>>2]+(V*Y+W*Z+X*_)*+g[qa+332>>2]+(V*$+W*aa+X*ba)*+g[qa+336>>2]);if((q|0)==1){if(!(f<0.0))break;if(!(+g[n>>2]<-(h*f)))break;g[n>>2]=-(h*f);break}else{if(!(f>0.0))break;if(!(+g[n>>2]>-(h*f)))break;g[n>>2]=-(h*f);break}}while(0);g[n>>2]=+g[d+700>>2]*+g[n>>2];return}W=+g[pa+4>>2];X=+g[pa+8>>2];Y=+g[pa+12>>2];u=+g[d+556>>2];x=+g[d+572>>2];z=+g[d+588>>2];Z=+g[d+560>>2];_=+g[d+576>>2];$=+g[d+592>>2];aa=+g[pa+20>>2];ba=+g[pa+24>>2];ca=+g[pa+28>>2];da=+g[pa+36>>2];ea=+g[pa+40>>2];fa=+g[pa+44>>2];ha=+g[d+600>>2];ga=+g[d+604>>2];o=+g[d+608>>2];h=+g[pa+52>>2]+(W*ha+X*ga+Y*o);w=aa*ha+ba*ga+ca*o+ +g[pa+56>>2];o=da*ha+ea*ga+fa*o+ +g[pa+60>>2];ga=+g[qa+4>>2];ha=+g[qa+8>>2];ia=+g[qa+12>>2];ja=+g[d+624>>2];ka=+g[d+640>>2];P=+g[d+656>>2];Q=+g[qa+20>>2];R=+g[qa+24>>2];S=+g[qa+28>>2];T=+g[qa+36>>2];U=+g[qa+40>>2];V=+g[qa+44>>2];r=+g[d+664>>2];y=+g[d+668>>2];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ma*oa*M-na*oa*w;u=na*oa*N-M*la*oa;v=w*la*oa-ma*oa*N;t=c[e+12>>2]|0;g[t>>2]=H*M-F*w;g[t+4>>2]=F*N-G*M;g[t+8>>2]=G*w-H*N;t=c[e+20>>2]|0;g[t>>2]=-(E*M-C*w);g[t+4>>2]=-(C*N-D*M);g[t+8>>2]=-(D*w-E*N);if(A<1.1920928955078125e-07|B<1.1920928955078125e-07?(a[d+716>>0]|0)!=0:0){f=(1.0-I)*(E*v-C*u);h=(1.0-I)*(C*r-D*v);k=(1.0-I)*(D*u-E*r);l=I*(H*v-F*u);m=I*(F*r-G*v);o=I*(G*u-H*r)}else{f=E*v-C*u;h=C*r-D*v;k=D*u-E*r;l=H*v-F*u;m=F*r-G*v;o=G*u-H*r}t=(c[e+12>>2]|0)+(q<<2)|0;g[t>>2]=l;g[t+4>>2]=m;g[t+8>>2]=o;t=c[e+20>>2]|0;g[t+(q<<2)>>2]=-f;g[t+(q+1<<2)>>2]=-h;g[t+(q+2<<2)>>2]=-k;if(A<1.1920928955078125e-07|B<1.1920928955078125e-07){o=(1.0-I)*(E*na*oa-C*ma*oa);m=(1.0-I)*(C*la*oa-D*na*oa);l=(1.0-I)*(D*ma*oa-E*la*oa);k=I*(H*na*oa-F*ma*oa);h=I*(F*la*oa-G*na*oa);f=I*(G*ma*oa-H*la*oa)}else{o=E*na*oa-C*ma*oa;m=C*la*oa-D*na*oa;l=D*ma*oa-E*la*oa;k=H*na*oa-F*ma*oa;h=F*la*oa-G*na*oa;f=G*ma*oa-H*la*oa}i=(c[e+12>>2]|0)+(q<<1<<2)|0;g[i>>2]=k;g[i+4>>2]=h;g[i+8>>2]=f;i=c[e+20>>2]|0;g[i+(q<<1<<2)>>2]=-o;g[i+((q<<1|1)<<2)>>2]=-m;g[i+((q<<1)+2<<2)>>2]=-l;f=+g[e>>2]*+g[e+4>>2];if(!(a[d+736>>0]|0)){p=c[e+8>>2]|0;g[p>>2]=N;g[p+4>>2]=w;g[p+8>>2]=M;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*ca)*(ga*ja+ha*ka+ia*P);g[p+(q*3<<2)>>2]=K*(L*N+fa*w+ka*M);g[p+(q<<2<<2)>>2]=K*(L*r+fa*u+ka*v);if(!(a[d+716>>0]|0)){t=0;r=0.0}else{r=+g[d+708>>2]*+g[d+732>>2];t=r>0.0?1:2}n=a[d+737>>0]|0;q=(t|0)!=0;if(!(n&255|t))return;s=(c[e+24>>2]|0)*5|0;g[j+(s<<2)>>2]=la*oa;g[j+(s+1<<2)>>2]=ma*oa;g[j+(s+2<<2)>>2]=na*oa;g[i+(s<<2)>>2]=-(la*oa);g[i+(s+1<<2)>>2]=-(ma*oa);g[i+(s+2<<2)>>2]=-(na*oa);h=+g[d+688>>2];k=+g[d+692>>2];f=+eh(h-k,6.2831854820251465);if(!(f<-3.1415927410125732))if(f>3.1415927410125732)o=f+-6.2831854820251465;else o=f;else o=f+6.2831854820251465;f=+eh(h+k,6.2831854820251465);if(!(f<-3.1415927410125732)){if(f>3.1415927410125732)f=f+-6.2831854820251465}else f=f+6.2831854820251465;j=o==f;p=p+(s<<2)|0;g[p>>2]=0.0;i=c[d+748>>2]|0;m=+g[((i&2|0)==0?e+4|0:d+760|0)>>2];if(!(n<<24>>24==0|q&j)){if(i&4|0)c[(c[e+32>>2]|0)+(s<<2)>>2]=c[d+752>>2];k=+g[d+728>>2];l=+g[d+680>>2];h=o>f?1.0:0.0;do if(!(o>=f)){h=l/(m*+g[e>>2]);if(h<0.0)if(k>=o&o-h>k){f=(o-k)/h;break}else{f=k0.0)if(k<=f&f-hf?0.0:1.0;break}else f=0.0}else f=h;while(0);g[p>>2]=f*l*+g[d+732>>2]+ +g[p>>2];g[(c[e+36>>2]|0)+(s<<2)>>2]=-+g[d+684>>2];c[(c[e+40>>2]|0)+(s<<2)>>2]=c[d+684>>2]}if(!q)return;g[p>>2]=+g[p>>2]+r*m*+g[e>>2];if(i&1|0)c[(c[e+32>>2]|0)+(s<<2)>>2]=c[d+756>>2];do if(!j){j=(c[e+36>>2]|0)+(s<<2)|0;i=c[e+40>>2]|0;if((t|0)==1){g[j>>2]=0.0;g[i+(s<<2)>>2]=3402823466385288598117041.0e14;break}else{g[j>>2]=-3402823466385288598117041.0e14;g[i+(s<<2)>>2]=0.0;break}}else{g[(c[e+36>>2]|0)+(s<<2)>>2]=-3402823466385288598117041.0e14;g[(c[e+40>>2]|0)+(s<<2)>>2]=3402823466385288598117041.0e14}while(0);h=+g[d+704>>2];do if(h>0.0){f=+g[pa+328>>2]*la*oa+ +g[pa+332>>2]*ma*oa+ +g[pa+336>>2]*na*oa-(la*oa*+g[qa+328>>2]+ma*oa*+g[qa+332>>2]+na*oa*+g[qa+336>>2]);if((t|0)==1){if(!(f<0.0))break;if(!(+g[p>>2]<-(h*f)))break;g[p>>2]=-(h*f);break}else{if(!(f>0.0))break;if(!(+g[p>>2]>-(h*f)))break;g[p>>2]=-(h*f);break}}while(0);g[p>>2]=+g[d+700>>2]*+g[p>>2];return}function Ic(d,e,f,h,j,k){d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=+k;var l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0,F=0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0;F=i;i=i+896|0;E=c[h+4>>2]|0;D=c[h+12>>2]|0;w=c[E+4>>2]|0;if((w|0)<20){c[F+712>>2]=3708;c[F+712+168>>2]=0;g[F+712+172>>2]=k;c[F+712+164>>2]=c[j+4>>2];g[F+352+308>>2]=9.999999747378752e-05;a[F+352+332>>0]=0;c[F+288>>2]=9120;c[F+64>>2]=9188;c[F+64+4>>2]=F+352;c[F+64+8>>2]=F+288;c[F+64+12>>2]=d;c[F+64+16>>2]=E;c[F+64+20>>2]=0;if((Xd(F+64|0,e,f,D,D,F+712|0)|0?(l=F+712+132|0,m=+g[l>>2],n=+g[F+712+136>>2],p=+g[F+712+140>>2],m*m+n*n+p*p>9.999999747378752e-05):0)?(t=+g[F+712+164>>2],t<+g[j+4>>2]):0){k=1.0/+O(+(m*m+n*n+p*p));g[l>>2]=m*k;g[F+712+136>>2]=n*k;g[F+712+140>>2]=p*k;c[F+16>>2]=c[h+8>>2];c[F+16+4>>2]=0;c[F+16+8>>2]=c[l>>2];c[F+16+8+4>>2]=c[l+4>>2];c[F+16+8+8>>2]=c[l+8>>2];c[F+16+8+12>>2]=c[l+12>>2];c[F+16+24>>2]=c[F+712+148>>2];c[F+16+24+4>>2]=c[F+712+148+4>>2];c[F+16+24+8>>2]=c[F+712+148+8>>2];c[F+16+24+12>>2]=c[F+712+148+12>>2];g[F+16+40>>2]=t;+_b[c[(c[j>>2]|0)+12>>2]&15](j,F+16|0,1)}i=F;return}if((w+-21|0)>>>0>=9){if((w|0)!=31){i=F;return}li(15534);if((c[E+16>>2]|0)>0){l=0;do{u=c[E+24>>2]|0;m=+g[u+(l*80|0)>>2];p=+g[u+(l*80|0)+4>>2];s=+g[u+(l*80|0)+8>>2];n=+g[u+(l*80|0)+16>>2];q=+g[u+(l*80|0)+20>>2];v=+g[u+(l*80|0)+24>>2];o=+g[u+(l*80|0)+32>>2];r=+g[u+(l*80|0)+36>>2];y=+g[u+(l*80|0)+40>>2];N=+g[u+(l*80|0)+48>>2];M=+g[u+(l*80|0)+52>>2];C=+g[u+(l*80|0)+56>>2];u=c[u+(l*80|0)+64>>2]|0;L=+g[D>>2];K=+g[D+4>>2];J=+g[D+8>>2];I=+g[D+16>>2];H=+g[D+20>>2];G=+g[D+24>>2];t=+g[D+32>>2];x=+g[D+36>>2];z=+g[D+40>>2];A=N*L+M*K+C*J+ +g[D+48>>2];B=N*I+M*H+C*G+ +g[D+52>>2];C=N*t+M*x+C*z+ +g[D+56>>2];g[F+712>>2]=m*L+n*K+o*J;g[F+712+4>>2]=p*L+q*K+r*J;g[F+712+8>>2]=s*L+v*K+y*J;g[F+712+12>>2]=0.0;g[F+712+16>>2]=m*I+n*H+o*G;g[F+712+20>>2]=p*I+q*H+r*G;g[F+712+24>>2]=s*I+v*H+y*G;g[F+712+28>>2]=0.0;g[F+712+32>>2]=m*t+n*x+o*z;g[F+712+36>>2]=p*t+q*x+r*z;g[F+712+40>>2]=s*t+v*x+y*z;g[F+712+44>>2]=0.0;g[F+712+48>>2]=A;g[F+712+52>>2]=B;g[F+712+56>>2]=C;g[F+712+60>>2]=0.0;b[F+352+8>>1]=1;b[F+352+10>>1]=-1;c[F+352>>2]=5912;c[F+352+12>>2]=j;c[F+352+16>>2]=l;c[F+352+4>>2]=c[j+4>>2];w=c[h+8>>2]|0;c[F+288>>2]=h;c[F+288+4>>2]=u;c[F+288+8>>2]=w;c[F+288+12>>2]=F+712;c[F+288+16>>2]=-1;c[F+288+20>>2]=l;Ic(d,e,f,F+288|0,F+352|0,k);l=l+1|0}while((l|0)<(c[E+16>>2]|0))}l=c[2357]|0;E=(c[l+16>>2]|0)+-1|0;c[l+16>>2]=E;if(E|0){i=F;return}do if(c[l+4>>2]|0){tb(F+712|0,0)|0;E=c[6434]|0;g[l+8>>2]=+g[l+8>>2]+ +(((c[F+712+4>>2]|0)-(c[E+4>>2]|0)+(((c[F+712>>2]|0)-(c[E>>2]|0)|0)*1e6|0)-(c[l+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[l+16>>2]|0)){l=c[2357]|0;break}else{i=F;return}}while(0);c[2357]=c[l+20>>2];i=F;return}switch(w|0){case 21:{p=+g[D>>2];q=+g[D+16>>2];r=+g[D+32>>2];s=+g[D+4>>2];t=+g[D+20>>2];v=+g[D+36>>2];x=+g[D+8>>2];y=+g[D+24>>2];z=+g[D+40>>2];A=-+g[D+48>>2];B=-+g[D+52>>2];C=-+g[D+56>>2];o=+g[e+48>>2];n=+g[e+52>>2];m=+g[e+56>>2];g[F+352>>2]=p*A+q*B+r*C+(p*o+q*n+r*m);g[F+352+4>>2]=s*A+t*B+v*C+(s*o+t*n+v*m);g[F+352+8>>2]=x*A+y*B+z*C+(x*o+y*n+z*m);g[F+352+12>>2]=0.0;m=+g[f+48>>2];n=+g[f+52>>2];o=+g[f+56>>2];P=+g[f>>2];G=+g[f+16>>2];H=+g[f+32>>2];I=+g[f+4>>2];J=+g[f+20>>2];K=+g[f+36>>2];L=+g[f+8>>2];M=+g[f+24>>2];N=+g[f+40>>2];g[F+288>>2]=p*P+q*G+r*H;g[F+288+4>>2]=p*I+q*J+r*K;g[F+288+8>>2]=p*L+q*M+r*N;g[F+288+12>>2]=0.0;g[F+288+16>>2]=s*P+t*G+v*H;g[F+288+20>>2]=s*I+t*J+v*K;g[F+288+24>>2]=s*L+t*M+v*N;g[F+288+28>>2]=0.0;g[F+288+32>>2]=x*P+y*G+z*H;g[F+288+36>>2]=x*I+y*J+z*K;g[F+288+40>>2]=x*L+y*M+z*N;l=F+288+44|0;c[l>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;c[l+16>>2]=0;l=c[h+8>>2]|0;N=+Sb[c[(c[E>>2]|0)+48>>2]&15](E);c[F+64>>2]=9048;c[F+64+4>>2]=d;c[F+64+8>>2]=c[e>>2];c[F+64+8+4>>2]=c[e+4>>2];c[F+64+8+8>>2]=c[e+8>>2];c[F+64+8+12>>2]=c[e+12>>2];c[F+64+24>>2]=c[e+16>>2];c[F+64+24+4>>2]=c[e+16+4>>2];c[F+64+24+8>>2]=c[e+16+8>>2];c[F+64+24+12>>2]=c[e+16+12>>2];c[F+64+40>>2]=c[e+32>>2];c[F+64+40+4>>2]=c[e+32+4>>2];c[F+64+40+8>>2]=c[e+32+8>>2];c[F+64+40+12>>2]=c[e+32+12>>2];c[F+64+56>>2]=c[e+48>>2];c[F+64+56+4>>2]=c[e+48+4>>2];c[F+64+56+8>>2]=c[e+48+8>>2];c[F+64+56+12>>2]=c[e+48+12>>2];c[F+64+72>>2]=c[f>>2];c[F+64+72+4>>2]=c[f+4>>2];c[F+64+72+8>>2]=c[f+8>>2];c[F+64+72+12>>2]=c[f+12>>2];c[F+64+88>>2]=c[f+16>>2];c[F+64+88+4>>2]=c[f+16+4>>2];c[F+64+88+8>>2]=c[f+16+8>>2];c[F+64+88+12>>2]=c[f+16+12>>2];c[F+64+104>>2]=c[f+32>>2];c[F+64+104+4>>2]=c[f+32+4>>2];c[F+64+104+8>>2]=c[f+32+8>>2];c[F+64+104+12>>2]=c[f+32+12>>2];c[F+64+120>>2]=c[f+48>>2];c[F+64+120+4>>2]=c[f+48+4>>2];c[F+64+120+8>>2]=c[f+48+8>>2];c[F+64+120+12>>2]=c[f+48+12>>2];c[F+64+136>>2]=c[D>>2];c[F+64+136+4>>2]=c[D+4>>2];c[F+64+136+8>>2]=c[D+8>>2];c[F+64+136+12>>2]=c[D+12>>2];c[F+64+152>>2]=c[D+16>>2];c[F+64+152+4>>2]=c[D+16+4>>2];c[F+64+152+8>>2]=c[D+16+8>>2];c[F+64+152+12>>2]=c[D+16+12>>2];c[F+64+168>>2]=c[D+32>>2];c[F+64+168+4>>2]=c[D+32+4>>2];c[F+64+168+8>>2]=c[D+32+8>>2];c[F+64+168+12>>2]=c[D+32+12>>2];c[F+64+184>>2]=c[D+48>>2];c[F+64+184+4>>2]=c[D+48+4>>2];c[F+64+184+8>>2]=c[D+48+8>>2];c[F+64+184+12>>2]=c[D+48+12>>2];g[F+64+204>>2]=N;c[F+64>>2]=5864;c[F+64+212>>2]=j;c[F+64+216>>2]=l;c[F+64+220>>2]=E;c[F+64+200>>2]=c[j+4>>2];g[F+64+208>>2]=k;mc[c[(c[d>>2]|0)+8>>2]&127](d,F+288|0,F+16|0,F);l=c[E+48>>2]|0;c[F+712>>2]=6904;c[F+712+4>>2]=l;c[F+712+8>>2]=F+64;l=c[E+52>>2]|0;if(!(a[l+60>>0]|0))Re(l,F+712|0,F+352|0,p*A+q*B+r*C+(p*m+q*n+r*o),s*A+t*B+v*C+(s*m+t*n+v*o),x*A+y*B+z*C+(x*m+y*n+z*o),F+16|0,F);else ze(l,F+712|0,F+352|0,p*A+q*B+r*C+(p*m+q*n+r*o),s*A+t*B+v*C+(s*m+t*n+v*o),x*A+y*B+z*C+(x*m+y*n+z*o),F+16|0,F,c[l+56>>2]|0);i=F;return}case 28:{c[F+712>>2]=3708;c[F+712+168>>2]=0;g[F+712+172>>2]=k;c[F+712+164>>2]=c[j+4>>2];c[F+352>>2]=9188;c[F+352+4>>2]=0;c[F+352+8>>2]=0;c[F+352+12>>2]=d;c[F+352+16>>2]=0;c[F+352+20>>2]=E;if((Xd(F+352|0,e,f,D,D,F+712|0)|0?(u=F+712+132|0,o=+g[u>>2],q=+g[F+712+136>>2],r=+g[F+712+140>>2],o*o+q*q+r*r>9.999999747378752e-05):0)?(s=+g[F+712+164>>2],s<+g[j+4>>2]):0){P=1.0/+O(+(o*o+q*q+r*r));g[u>>2]=o*P;g[F+712+136>>2]=q*P;g[F+712+140>>2]=r*P;c[F+288>>2]=c[h+8>>2];c[F+288+4>>2]=0;c[F+288+8>>2]=c[u>>2];c[F+288+8+4>>2]=c[u+4>>2];c[F+288+8+8>>2]=c[u+8>>2];c[F+288+8+12>>2]=c[u+12>>2];c[F+288+24>>2]=c[F+712+148>>2];c[F+288+24+4>>2]=c[F+712+148+4>>2];c[F+288+24+8>>2]=c[F+712+148+8>>2];c[F+288+24+12>>2]=c[F+712+148+12>>2];g[F+288+40>>2]=s;+_b[c[(c[j>>2]|0)+12>>2]&15](j,F+288|0,1)}i=F;return}default:{p=+g[D>>2];q=+g[D+16>>2];r=+g[D+32>>2];x=+g[D+4>>2];y=+g[D+20>>2];z=+g[D+36>>2];J=+g[D+8>>2];L=+g[D+24>>2];N=+g[D+40>>2];H=-+g[D+48>>2];G=-+g[D+52>>2];C=-+g[D+56>>2];A=+g[e+48>>2];B=+g[e+52>>2];m=+g[e+56>>2];o=p*H+q*G+r*C+(p*A+q*B+r*m);n=x*H+y*G+z*C+(x*A+y*B+z*m);m=J*H+L*G+N*C+(J*A+L*B+N*m);B=+g[f+48>>2];A=+g[f+52>>2];v=+g[f+56>>2];s=p*H+q*G+r*C+(p*B+q*A+r*v);t=x*H+y*G+z*C+(x*B+y*A+z*v);v=J*H+L*G+N*C+(J*B+L*A+N*v);A=+g[f>>2];B=+g[f+16>>2];C=+g[f+32>>2];G=+g[f+4>>2];H=+g[f+20>>2];I=+g[f+36>>2];K=+g[f+8>>2];M=+g[f+24>>2];P=+g[f+40>>2];g[F+712>>2]=p*A+q*B+r*C;g[F+712+4>>2]=p*G+q*H+r*I;g[F+712+8>>2]=p*K+q*M+r*P;g[F+712+12>>2]=0.0;g[F+712+16>>2]=x*A+y*B+z*C;g[F+712+20>>2]=x*G+y*H+z*I;g[F+712+24>>2]=x*K+y*M+z*P;g[F+712+28>>2]=0.0;g[F+712+32>>2]=J*A+L*B+N*C;g[F+712+36>>2]=J*G+L*H+N*I;g[F+712+40>>2]=J*K+L*M+N*P;w=F+712+44|0;c[w>>2]=0;c[w+4>>2]=0;c[w+8>>2]=0;c[w+12>>2]=0;c[w+16>>2]=0;h=c[h+8>>2]|0;P=+Sb[c[(c[E>>2]|0)+48>>2]&15](E);c[F+352>>2]=9048;c[F+352+4>>2]=d;c[F+352+8>>2]=c[e>>2];c[F+352+8+4>>2]=c[e+4>>2];c[F+352+8+8>>2]=c[e+8>>2];c[F+352+8+12>>2]=c[e+12>>2];c[F+352+24>>2]=c[e+16>>2];c[F+352+24+4>>2]=c[e+16+4>>2];c[F+352+24+8>>2]=c[e+16+8>>2];c[F+352+24+12>>2]=c[e+16+12>>2];c[F+352+40>>2]=c[e+32>>2];c[F+352+40+4>>2]=c[e+32+4>>2];c[F+352+40+8>>2]=c[e+32+8>>2];c[F+352+40+12>>2]=c[e+32+12>>2];c[F+352+56>>2]=c[e+48>>2];c[F+352+56+4>>2]=c[e+48+4>>2];c[F+352+56+8>>2]=c[e+48+8>>2];c[F+352+56+12>>2]=c[e+48+12>>2];c[F+352+72>>2]=c[f>>2];c[F+352+72+4>>2]=c[f+4>>2];c[F+352+72+8>>2]=c[f+8>>2];c[F+352+72+12>>2]=c[f+12>>2];c[F+352+88>>2]=c[f+16>>2];c[F+352+88+4>>2]=c[f+16+4>>2];c[F+352+88+8>>2]=c[f+16+8>>2];c[F+352+88+12>>2]=c[f+16+12>>2];c[F+352+104>>2]=c[f+32>>2];c[F+352+104+4>>2]=c[f+32+4>>2];c[F+352+104+8>>2]=c[f+32+8>>2];c[F+352+104+12>>2]=c[f+32+12>>2];c[F+352+120>>2]=c[f+48>>2];c[F+352+120+4>>2]=c[f+48+4>>2];c[F+352+120+8>>2]=c[f+48+8>>2];c[F+352+120+12>>2]=c[f+48+12>>2];c[F+352+136>>2]=c[D>>2];c[F+352+136+4>>2]=c[D+4>>2];c[F+352+136+8>>2]=c[D+8>>2];c[F+352+136+12>>2]=c[D+12>>2];c[F+352+152>>2]=c[D+16>>2];c[F+352+152+4>>2]=c[D+16+4>>2];c[F+352+152+8>>2]=c[D+16+8>>2];c[F+352+152+12>>2]=c[D+16+12>>2];c[F+352+168>>2]=c[D+32>>2];c[F+352+168+4>>2]=c[D+32+4>>2];c[F+352+168+8>>2]=c[D+32+8>>2];c[F+352+168+12>>2]=c[D+32+12>>2];c[F+352+184>>2]=c[D+48>>2];c[F+352+184+4>>2]=c[D+48+4>>2];c[F+352+184+8>>2]=c[D+48+8>>2];c[F+352+184+12>>2]=c[D+48+12>>2];g[F+352+204>>2]=P;c[F+352>>2]=5888;c[F+352+212>>2]=j;c[F+352+216>>2]=h;c[F+352+220>>2]=E;c[F+352+200>>2]=c[j+4>>2];g[F+352+208>>2]=k;mc[c[(c[d>>2]|0)+8>>2]&127](d,F+712|0,F+288|0,F+64|0);g[F+16>>2]=o;g[F+16+4>>2]=n;g[F+16+8>>2]=m;g[F+16+12>>2]=0.0;if(s>2]=s;p=s}else p=o;if(t>2]=t;q=t}else q=n;if(v>2]=v;r=v}else r=m;g[F>>2]=o;g[F+4>>2]=n;g[F+8>>2]=m;g[F+12>>2]=0.0;if(o>2]=s;o=s}if(n>2]=t;n=t}if(m>2]=v;m=v}g[F+16>>2]=+g[F+288>>2]+p;g[F+16+4>>2]=+g[F+288+4>>2]+q;g[F+16+8>>2]=+g[F+288+8>>2]+r;g[F>>2]=+g[F+64>>2]+o;g[F+4>>2]=+g[F+64+4>>2]+n;g[F+8>>2]=+g[F+64+8>>2]+m;mc[c[(c[E>>2]|0)+64>>2]&127](E,F+352|0,F+16|0,F);i=F;return}}}function Jc(d,e,f){d=d|0;e=e|0;f=+f;var h=0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0,u=0;t=i;i=i+528|0;if((a[d+171>>0]|0)==0?+g[d+172>>2]<=0.0:0){i=t;return}a[d+168>>0]=(Eb[c[(c[d>>2]|0)+48>>2]&127](d)|0)&1;j=+g[d+16>>2]-+g[d+44>>2]*f;g[d+16>>2]=j;if(j>0.0?(k=+g[d+28>>2],j>k):0){g[d+16>>2]=k;j=k}if(j<0.0?(r=+N(+j),m=+N(+(+g[d+24>>2])),r>m):0){g[d+16>>2]=-m;j=-m}g[d+20>>2]=j*f;h=c[d+8>>2]|0;c[t>>2]=c[h+4>>2];c[t+4>>2]=c[h+4+4>>2];c[t+8>>2]=c[h+4+8>>2];c[t+12>>2]=c[h+4+12>>2];c[t+16>>2]=c[h+20>>2];c[t+16+4>>2]=c[h+20+4>>2];c[t+16+8>>2]=c[h+20+8>>2];c[t+16+12>>2]=c[h+20+12>>2];c[t+32>>2]=c[h+36>>2];c[t+32+4>>2]=c[h+36+4>>2];c[t+32+8>>2]=c[h+36+8>>2];c[t+32+12>>2]=c[h+36+12>>2];c[t+48>>2]=c[h+52>>2];c[t+48+4>>2]=c[h+52+4>>2];c[t+48+8>>2]=c[h+52+8>>2];c[t+48+12>>2]=c[h+52+12>>2];h=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}m=+g[d+20>>2];m=+g[d+52>>2]+(m>0.0?m:0.0);q=+g[24504+(h<<4)+4>>2]*m+ +g[d+96>>2];r=m*+g[24504+(h<<4)+8>>2]+ +g[d+100>>2];g[d+112>>2]=+g[d+92>>2]+ +g[24504+(h<<4)>>2]*m;g[d+116>>2]=q;g[d+120>>2]=r;g[d+124>>2]=0.0;c[t+456>>2]=1065353216;c[t+456+4>>2]=0;c[t+456+4+4>>2]=0;c[t+456+4+8>>2]=0;c[t+456+4+12>>2]=0;c[t+456+20>>2]=1065353216;c[t+456+24>>2]=0;c[t+456+24+4>>2]=0;c[t+456+24+8>>2]=0;c[t+456+24+12>>2]=0;c[t+456+40>>2]=1065353216;h=t+456+44|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[h+16>>2]=0;c[t+392>>2]=1065353216;c[t+392+4>>2]=0;c[t+392+4+4>>2]=0;c[t+392+4+8>>2]=0;c[t+392+4+12>>2]=0;c[t+392+20>>2]=1065353216;c[t+392+24>>2]=0;c[t+392+24+4>>2]=0;c[t+392+24+8>>2]=0;c[t+392+24+12>>2]=0;c[t+392+40>>2]=1065353216;h=t+392+44|0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[h+16>>2]=0;h=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}l=c[d+12>>2]|0;m=+Sb[c[(c[l>>2]|0)+48>>2]&15](l);m=m+ +g[d+56>>2];q=m*+g[24504+(h<<4)+4>>2]+ +g[d+96>>2];r=m*+g[24504+(h<<4)+8>>2]+ +g[d+100>>2];g[t+456+48>>2]=+g[24504+(h<<4)>>2]*m+ +g[d+92>>2];g[t+456+52>>2]=q;g[t+456+56>>2]=r;g[t+456+60>>2]=0.0;c[t+392+48>>2]=c[d+112>>2];c[t+392+48+4>>2]=c[d+112+4>>2];c[t+392+48+8>>2]=c[d+112+8>>2];c[t+392+48+12>>2]=c[d+112+12>>2];h=c[d+8>>2]|0;l=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}m=-+g[24504+(l<<4)>>2];q=-+g[24504+(l<<4)+4>>2];r=-+g[24504+(l<<4)+8>>2];g[t+288+4>>2]=1.0;b[t+288+8>>1]=1;b[t+288+10>>1]=-1;p=t+288+12|0;c[t+288+76>>2]=0;c[p>>2]=0;c[p+4>>2]=0;c[p+8>>2]=0;c[p+12>>2]=0;c[p+16>>2]=0;c[p+20>>2]=0;c[p+24>>2]=0;c[p+28>>2]=0;c[t+288>>2]=4936;c[t+288+80>>2]=h;g[t+288+84>>2]=m;g[t+288+88>>2]=q;g[t+288+92>>2]=r;g[t+288+96>>2]=0.0;g[t+288+100>>2]=.707099974155426;h=c[d+8>>2]|0;p=c[(c[h+188>>2]|0)+4>>2]|0;b[t+288+8>>1]=p;b[t+288+10>>1]=p>>>16;if(!(a[d+170>>0]|0))Kd(e,c[d+12>>2]|0,t+456|0,t+392|0,t+288|0,0.0);else wd(h,c[d+12>>2]|0,t+456|0,t+392|0,t+288|0,+g[e+56>>2]);if(+g[t+288+4>>2]<1.0){h=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}do if(+g[t+288+44>>2]*+g[24504+(h<<4)>>2]+ +g[t+288+48>>2]*+g[24504+(h<<4)+4>>2]+ +g[t+288+52>>2]*+g[24504+(h<<4)+8>>2]>0.0){j=+g[t+288+4>>2];g[d+108>>2]=+g[d+52>>2]*j;if(!(a[d+180>>0]|0)){c[d+92>>2]=c[d+112>>2];c[d+92+4>>2]=c[d+112+4>>2];c[d+92+8>>2]=c[d+112+8>>2];c[d+92+12>>2]=c[d+112+12>>2];break}else{g[d+92>>2]=(1.0-j)*+g[d+92>>2]+j*+g[d+112>>2];g[d+96>>2]=(1.0-j)*+g[d+96>>2]+j*+g[d+116>>2];g[d+100>>2]=(1.0-j)*+g[d+100>>2]+j*+g[d+120>>2];break}}while(0);g[d+16>>2]=0.0;g[d+20>>2]=0.0}else{c[d+108>>2]=c[d+52>>2];c[d+92>>2]=c[d+112>>2];c[d+92+4>>2]=c[d+112+4>>2];c[d+92+8>>2]=c[d+112+8>>2];c[d+92+12>>2]=c[d+112+12>>2]}if(!(a[d+171>>0]|0)){q=+g[d+172>>2];r=q>f?f:q;g[d+172>>2]=q-f;he(d,e,r*+g[d+60>>2],r*+g[d+64>>2],r*+g[d+68>>2])}else he(d,e,+g[d+60>>2],+g[d+64>>2],+g[d+68>>2]);c[t+272>>2]=c[d+112>>2];c[t+272+4>>2]=c[d+112+4>>2];c[t+272+8>>2]=c[d+112+8>>2];c[t+272+12>>2]=c[d+112+12>>2];j=+g[d+16>>2];j=(j<0.0?-j:0.0)*f;if(j>0.0?(o=+g[d+24>>2],j>o):0){p=b[d+168>>1]|0;j=(p&255)<<24>>24!=0|(p&65535)<256?o:j}h=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}o=j+ +g[d+108>>2];q=+g[24504+(h<<4)>>2]*o;r=o*+g[24504+(h<<4)+4>>2];o=o*+g[24504+(h<<4)+8>>2];g[d+112>>2]=+g[d+112>>2]-q;g[d+116>>2]=+g[d+116>>2]-r;g[d+120>>2]=+g[d+120>>2]-o;h=c[d+8>>2]|0;l=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}n=c[d+40>>2]|0;p=t+168+4|0;g[p>>2]=1.0;b[t+168+8>>1]=1;b[t+168+10>>1]=-1;u=t+168+12|0;c[t+168+76>>2]=0;c[u>>2]=0;c[u+4>>2]=0;c[u+8>>2]=0;c[u+12>>2]=0;c[u+16>>2]=0;c[u+20>>2]=0;c[u+24>>2]=0;c[u+28>>2]=0;c[t+168>>2]=4936;c[t+168+80>>2]=h;c[t+168+84>>2]=c[24504+(l<<4)>>2];c[t+168+84+4>>2]=c[24504+(l<<4)+4>>2];c[t+168+84+8>>2]=c[24504+(l<<4)+8>>2];c[t+168+84+12>>2]=c[24504+(l<<4)+12>>2];c[t+168+100>>2]=n;h=c[d+8>>2]|0;l=c[(c[h+188>>2]|0)+4>>2]|0;b[t+168+8>>1]=l;b[t+168+10>>1]=l>>>16;l=c[d+176>>2]|0;if((a[22560]|0)==0?Wa(22560)|0:0){c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}u=c[d+40>>2]|0;g[t+64+4>>2]=1.0;b[t+64+8>>1]=1;b[t+64+10>>1]=-1;n=t+64+12|0;c[t+64+76>>2]=0;c[n>>2]=0;c[n+4>>2]=0;c[n+8>>2]=0;c[n+12>>2]=0;c[n+16>>2]=0;c[n+20>>2]=0;c[n+24>>2]=0;c[n+28>>2]=0;c[t+64>>2]=4936;c[t+64+80>>2]=h;c[t+64+84>>2]=c[24504+(l<<4)>>2];c[t+64+84+4>>2]=c[24504+(l<<4)+4>>2];c[t+64+84+8>>2]=c[24504+(l<<4)+8>>2];c[t+64+84+12>>2]=c[24504+(l<<4)+12>>2];c[t+64+100>>2]=u;h=c[(c[(c[d+8>>2]|0)+188>>2]|0)+4>>2]|0;b[t+64+8>>1]=h;b[t+64+10>>1]=h>>>16;j=+g[d+112>>2];k=+g[d+116>>2];m=+g[d+120>>2];h=0;while(1){c[t+456>>2]=1065353216;c[t+456+4>>2]=0;c[t+456+4+4>>2]=0;c[t+456+4+8>>2]=0;c[t+456+4+12>>2]=0;c[t+456+20>>2]=1065353216;c[t+456+24>>2]=0;c[t+456+24+4>>2]=0;c[t+456+24+8>>2]=0;c[t+456+24+12>>2]=0;c[t+456+40>>2]=1065353216;c[t+456+44>>2]=0;c[t+392>>2]=1065353216;c[t+392+4>>2]=0;c[t+392+4+4>>2]=0;c[t+392+4+8>>2]=0;c[t+392+4+12>>2]=0;c[t+392+20>>2]=1065353216;c[t+392+24>>2]=0;c[t+392+24+4>>2]=0;c[t+392+24+8>>2]=0;c[t+392+24+12>>2]=0;c[t+392+40>>2]=1065353216;c[t+392+44>>2]=0;c[t+288>>2]=1065353216;c[t+288+4>>2]=0;c[t+288+4+4>>2]=0;c[t+288+4+8>>2]=0;c[t+288+4+12>>2]=0;c[t+288+20>>2]=1065353216;c[t+288+24>>2]=0;c[t+288+24+4>>2]=0;c[t+288+24+8>>2]=0;c[t+288+24+12>>2]=0;c[t+288+40>>2]=1065353216;c[t+288+44>>2]=0;c[t+288+44+4>>2]=0;c[t+288+44+8>>2]=0;c[t+456+48>>2]=c[d+92>>2];c[t+456+48+4>>2]=c[d+92+4>>2];c[t+456+48+8>>2]=c[d+92+8>>2];c[t+456+48+12>>2]=c[d+92+12>>2];c[t+392+48>>2]=c[d+112>>2];c[t+392+48+4>>2]=c[d+112+4>>2];c[t+392+48+8>>2]=c[d+112+8>>2];c[t+392+48+12>>2]=c[d+112+12>>2];g[t+288+48>>2]=j-q;g[t+288+52>>2]=k-r;g[t+288+56>>2]=m-o;g[t+288+60>>2]=0.0;if(!(a[d+170>>0]|0)){Kd(e,c[d+12>>2]|0,t+456|0,t+392|0,t+168|0,+g[e+56>>2]);if(!(+g[p>>2]<1.0))Kd(e,c[d+12>>2]|0,t+456|0,t+288|0,t+64|0,+g[e+56>>2])}else{wd(c[d+8>>2]|0,c[d+12>>2]|0,t+456|0,t+392|0,t+168|0,+g[e+56>>2]);if(!(+g[p>>2]<1.0))wd(c[d+8>>2]|0,c[d+12>>2]|0,t+456|0,t+288|0,t+64|0,+g[e+56>>2])}k=+g[d+16>>2];k=(k<0.0?-k:0.0)*f;n=(a[d+182>>0]|0)==0;if(!n?+g[p>>2]<1.0:0)l=1;else l=+g[t+64+4>>2]<1.0;if(!(k>0.0))break;j=+g[d+52>>2];if(h|(!(k>1]|0;if(!((u&255)<<24>>24!=0|(u&65535)<256)){h=0;break}c[d+112>>2]=c[t+272>>2];c[d+112+4>>2]=c[t+272+4>>2];c[d+112+8>>2]=c[t+272+8>>2];c[d+112+12>>2]=c[t+272+12>>2];h=c[d+176>>2]|0;do if(!(a[22560]|0)){if(!(Wa(22560)|0))break;c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}while(0);j=j+ +g[d+108>>2];k=j*+g[24504+(h<<4)+4>>2];m=j*+g[24504+(h<<4)+8>>2];j=+g[d+112>>2]-+g[24504+(h<<4)>>2]*j;g[d+112>>2]=j;k=+g[d+116>>2]-k;g[d+116>>2]=k;m=+g[d+120>>2]-m;g[d+120>>2]=m;h=1}m=+g[p>>2];if(h|m<1.0){j=+g[d+96>>2];k=(j-+g[t+168+64>>2])*.5;do if(!n)if(!(a[d+181>>0]|0)){g[d+92>>2]=(1.0-k)*+g[d+92>>2]+k*+g[d+112>>2];g[d+96>>2]=(1.0-k)*j+k*+g[d+116>>2];g[d+100>>2]=(1.0-k)*+g[d+100>>2]+k*+g[d+120>>2];h=d+181|0;break}else{g[d+92>>2]=(1.0-m)*+g[d+92>>2]+m*+g[d+112>>2];g[d+96>>2]=(1.0-m)*j+m*+g[d+116>>2];g[d+100>>2]=(1.0-m)*+g[d+100>>2]+m*+g[d+120>>2];h=d+181|0;break}else{g[d+92>>2]=(1.0-m)*+g[d+92>>2]+m*+g[d+112>>2];g[d+96>>2]=(1.0-m)*j+m*+g[d+116>>2];g[d+100>>2]=(1.0-m)*+g[d+100>>2]+m*+g[d+120>>2];h=d+181|0}while(0);a[h>>0]=0;g[d+16>>2]=0.0;g[d+20>>2]=0.0;a[d+169>>0]=0}else{a[d+181>>0]=1;if((!n?(s=+g[d+24>>2],k>s):0)?(u=b[d+168>>1]|0,(u&255)<<24>>24!=0|(u&65535)<256):0){g[d+112>>2]=q+ +g[d+112>>2];g[d+116>>2]=r+ +g[d+116>>2];g[d+120>>2]=o+ +g[d+120>>2];h=c[d+176>>2]|0;do if(!(a[22560]|0)){if(!(Wa(22560)|0))break;c[6126]=1065353216;c[6127]=0;c[6128]=0;c[6129]=0;c[6130]=0;c[6131]=1065353216;c[6132]=0;c[6133]=0;c[6134]=0;c[6135]=0;c[6136]=1065353216;g[6137]=0.0;_a(22560)}while(0);r=s+ +g[d+108>>2];f=r*+g[24504+(h<<4)+4>>2];s=r*+g[24504+(h<<4)+8>>2];g[d+112>>2]=+g[d+112>>2]-+g[24504+(h<<4)>>2]*r;g[d+116>>2]=+g[d+116>>2]-f;g[d+120>>2]=+g[d+120>>2]-s}c[d+92>>2]=c[d+112>>2];c[d+92+4>>2]=c[d+112+4>>2];c[d+92+8>>2]=c[d+112+8>>2];c[d+92+12>>2]=c[d+112+12>>2]}c[t+48>>2]=c[d+92>>2];c[t+48+4>>2]=c[d+92+4>>2];c[t+48+8>>2]=c[d+92+8>>2];c[t+48+12>>2]=c[d+92+12>>2];u=c[d+8>>2]|0;c[u+260>>2]=(c[u+260>>2]|0)+1;c[u+4>>2]=c[t>>2];c[u+4+4>>2]=c[t+4>>2];c[u+4+8>>2]=c[t+8>>2];c[u+4+12>>2]=c[t+12>>2];c[u+20>>2]=c[t+16>>2];c[u+20+4>>2]=c[t+16+4>>2];c[u+20+8>>2]=c[t+16+8>>2];c[u+20+12>>2]=c[t+16+12>>2];c[u+36>>2]=c[t+32>>2];c[u+36+4>>2]=c[t+32+4>>2];c[u+36+8>>2]=c[t+32+8>>2];c[u+36+12>>2]=c[t+32+12>>2];c[u+52>>2]=c[t+48>>2];c[u+52+4>>2]=c[t+48+4>>2];c[u+52+8>>2]=c[t+48+8>>2];c[u+52+12>>2]=c[t+48+12>>2];i=t;return}function Kc(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,l=0,m=0,n=0.0,o=0,p=0.0,q=0.0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0;z=i;i=i+112|0;c[b+164>>2]=1065353216;c[b+168>>2]=1065353216;c[b+172>>2]=1065353216;g[b+176>>2]=0.0;c[b+180>>2]=0;g[b+184>>2]=999999984306749440.0;c[b+188>>2]=0;c[b+188+4>>2]=0;c[b+188+8>>2]=0;c[b+188+12>>2]=0;c[b+204>>2]=1;c[b+208>>2]=-1;c[b+212>>2]=-1;c[b+216>>2]=1;g[b+220>>2]=0.0;g[b+224>>2]=.5;g[b+228>>2]=0.0;g[b+232>>2]=0.0;c[b+236>>2]=1;c[b+240>>2]=0;g[b+244>>2]=1.0;c[b+248>>2]=0;c[b+248+4>>2]=0;c[b+248+8>>2]=0;c[b+248+12>>2]=0;c[b+4>>2]=1065353216;c[b+8>>2]=0;c[b+8+4>>2]=0;c[b+8+8>>2]=0;c[b+8+12>>2]=0;c[b+24>>2]=1065353216;c[b+28>>2]=0;c[b+28+4>>2]=0;c[b+28+8>>2]=0;c[b+28+12>>2]=0;c[b+44>>2]=1065353216;c[b+48>>2]=0;c[b+48+4>>2]=0;c[b+48+8>>2]=0;c[b+48+12>>2]=0;c[b+48+16>>2]=0;c[b>>2]=3180;a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;c[b+272>>2]=0;c[b+284>>2]=0;a[b+408>>0]=1;c[b+404>>2]=0;c[b+396>>2]=0;c[b+400>>2]=0;a[b+428>>0]=1;c[b+424>>2]=0;c[b+416>>2]=0;c[b+420>>2]=0;a[b+448>>0]=1;c[b+444>>2]=0;c[b+436>>2]=0;c[b+440>>2]=0;a[b+496>>0]=1;c[b+492>>2]=0;c[b+484>>2]=0;c[b+488>>2]=0;a[b+516>>0]=1;c[b+512>>2]=0;c[b+504>>2]=0;c[b+508>>2]=0;c[b+684>>2]=d;a[b+704>>0]=1;c[b+700>>2]=0;c[b+692>>2]=0;c[b+696>>2]=0;a[b+724>>0]=1;c[b+720>>2]=0;c[b+712>>2]=0;c[b+716>>2]=0;a[b+744>>0]=1;c[b+740>>2]=0;c[b+732>>2]=0;c[b+736>>2]=0;a[b+764>>0]=1;c[b+760>>2]=0;c[b+752>>2]=0;c[b+756>>2]=0;a[b+784>>0]=1;c[b+780>>2]=0;c[b+772>>2]=0;c[b+776>>2]=0;a[b+804>>0]=1;c[b+800>>2]=0;c[b+792>>2]=0;c[b+796>>2]=0;a[b+824>>0]=1;c[b+820>>2]=0;c[b+812>>2]=0;c[b+816>>2]=0;a[b+844>>0]=1;c[b+840>>2]=0;c[b+832>>2]=0;c[b+836>>2]=0;a[b+864>>0]=1;c[b+860>>2]=0;c[b+852>>2]=0;c[b+856>>2]=0;a[b+884>>0]=1;c[b+880>>2]=0;c[b+872>>2]=0;c[b+876>>2]=0;a[b+964>>0]=1;c[b+960>>2]=0;c[b+952>>2]=0;c[b+956>>2]=0;a[b+984>>0]=1;c[b+980>>2]=0;c[b+972>>2]=0;c[b+976>>2]=0;c[b+928>>2]=0;c[b+932>>2]=0;c[b+936>>2]=-1;c[b+940>>2]=0;c[b+944>>2]=0;a[b+1024>>0]=1;c[b+1020>>2]=0;c[b+1012>>2]=0;c[b+1016>>2]=0;a[b+1044>>0]=1;c[b+1040>>2]=0;c[b+1032>>2]=0;c[b+1036>>2]=0;c[b+988>>2]=0;c[b+992>>2]=0;c[b+996>>2]=-1;c[b+1e3>>2]=0;c[b+1004>>2]=0;a[b+1084>>0]=1;c[b+1080>>2]=0;c[b+1072>>2]=0;c[b+1076>>2]=0;a[b+1104>>0]=1;c[b+1100>>2]=0;c[b+1092>>2]=0;c[b+1096>>2]=0;c[b+1048>>2]=0;c[b+1052>>2]=0;c[b+1056>>2]=-1;c[b+1060>>2]=0;c[b+1064>>2]=0;a[b+1124>>0]=1;c[b+1120>>2]=0;c[b+1112>>2]=0;c[b+1116>>2]=0;a[b+1144>>0]=1;c[b+1140>>2]=0;c[b+1132>>2]=0;c[b+1136>>2]=0;a[b+1248>>0]=1;c[b+1244>>2]=0;c[b+1236>>2]=0;c[b+1240>>2]=0;c[b+236>>2]=8;c[b+288>>2]=0;g[b+292>>2]=1.0;c[b+296>>2]=0;c[b+296+4>>2]=0;c[b+296+8>>2]=0;c[b+296+12>>2]=0;c[b+296+16>>2]=0;g[b+316>>2]=.20000000298023224;g[b+320>>2]=0.0;g[b+324>>2]=1.0;g[b+328>>2]=.10000000149011612;g[b+332>>2]=1.0;g[b+336>>2]=.699999988079071;g[b+340>>2]=.10000000149011612;g[b+344>>2]=1.0;g[b+348>>2]=.5;g[b+352>>2]=.5;g[b+356>>2]=.5;g[b+360>>2]=.5;g[b+364>>2]=1.0;g[b+368>>2]=1.0;c[b+372>>2]=0;c[b+376>>2]=1;c[b+380>>2]=0;c[b+384>>2]=4;c[b+388>>2]=1;a[b+472>>0]=0;a[b+473>>0]=0;g[b+476>>2]=0.0;c[b+520>>2]=0;c[b+520+4>>2]=0;c[b+520+8>>2]=0;c[b+520+12>>2]=0;c[b+536>>2]=1065353216;c[b+540>>2]=0;c[b+540+4>>2]=0;c[b+540+8>>2]=0;c[b+540+12>>2]=0;c[b+556>>2]=1065353216;c[b+560>>2]=0;c[b+560+4>>2]=0;c[b+560+8>>2]=0;c[b+560+12>>2]=0;c[b+576>>2]=1065353216;g[b+580>>2]=0.0;c[b+584>>2]=1065353216;c[b+588>>2]=0;c[b+588+4>>2]=0;c[b+588+8>>2]=0;c[b+588+12>>2]=0;c[b+604>>2]=1065353216;c[b+608>>2]=0;c[b+608+4>>2]=0;c[b+608+8>>2]=0;c[b+608+12>>2]=0;c[b+624>>2]=1065353216;g[b+628>>2]=0.0;c[b+680>>2]=0;g[b+888>>2]=0.0;a[b+924>>0]=1;c[b+892>>2]=0;c[b+892+4>>2]=0;c[b+892+8>>2]=0;c[b+892+12>>2]=0;c[b+892+16>>2]=0;c[b+892+20>>2]=0;c[b+892+24>>2]=0;c[b+892+28>>2]=0;c[b+4>>2]=1065353216;c[b+8>>2]=0;c[b+8+4>>2]=0;c[b+8+8>>2]=0;c[b+8+12>>2]=0;c[b+24>>2]=1065353216;c[b+28>>2]=0;c[b+28+4>>2]=0;c[b+28+8>>2]=0;c[b+28+12>>2]=0;c[b+44>>2]=1065353216;c[b+48>>2]=0;c[b+48+4>>2]=0;c[b+48+8>>2]=0;c[b+48+12>>2]=0;c[b+48+16>>2]=0;d=c[b+404>>2]|0;if(d|0){if(a[b+408>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+404>>2]=0}a[b+408>>0]=1;c[b+404>>2]=0;c[b+396>>2]=0;c[b+400>>2]=0;d=c[b+424>>2]|0;if(d|0){if(a[b+428>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+424>>2]=0}a[b+428>>0]=1;c[b+424>>2]=0;c[b+416>>2]=0;c[b+420>>2]=0;d=c[b+444>>2]|0;do if(d)if(a[b+448>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);j=c[b+416>>2]|0;d=c[b+420>>2]|0;c[b+444>>2]=0;a[b+448>>0]=1;c[b+444>>2]=0;c[b+436>>2]=0;c[b+440>>2]=0;if((j|0)==(d|0)){s=14;break}else break}else{c[b+444>>2]=0;a[b+448>>0]=1;c[b+444>>2]=0;c[b+436>>2]=0;c[b+440>>2]=0;d=0;s=14;break}else{a[b+448>>0]=1;c[b+444>>2]=0;c[b+436>>2]=0;c[b+440>>2]=0;d=0;s=14}while(0);if((s|0)==14){o=d|0?d<<1:1;if((d|0)<(o|0)){if(!o)m=0;else{c[6435]=(c[6435]|0)+1;d=yc((o<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}m=d;d=c[b+416>>2]|0}l=c[b+424>>2]|0;if((d|0)<=0){if(l)s=22}else{j=0;do{c[m+(j<<2)>>2]=c[l+(j<<2)>>2];j=j+1|0}while((j|0)!=(d|0));s=22}if((s|0)==22){if(a[b+428>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);d=c[b+416>>2]|0}c[b+424>>2]=0}a[b+428>>0]=1;c[b+424>>2]=m;c[b+420>>2]=o;j=d;d=o}else j=d}c[(c[b+424>>2]|0)+(j<<2)>>2]=1;j=j+1|0;c[b+416>>2]=j;if((j|0)==(d|0)){o=d|0?d<<1:1;if((d|0)<(o|0)){if(!o)m=0;else{c[6435]=(c[6435]|0)+1;d=yc((o<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}m=d;d=c[b+416>>2]|0}l=c[b+424>>2]|0;if((d|0)<=0){if(l)s=35}else{j=0;do{c[m+(j<<2)>>2]=c[l+(j<<2)>>2];j=j+1|0}while((j|0)!=(d|0));s=35}if((s|0)==35){if(a[b+428>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);d=c[b+416>>2]|0}c[b+424>>2]=0}a[b+428>>0]=1;c[b+424>>2]=m;c[b+420>>2]=o;j=d;d=o}else j=d}c[(c[b+424>>2]|0)+(j<<2)>>2]=2;j=j+1|0;c[b+416>>2]=j;if((j|0)==(d|0)){o=d|0?d<<1:1;if((d|0)<(o|0)){if(!o)m=0;else{c[6435]=(c[6435]|0)+1;d=yc((o<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}m=d;d=c[b+416>>2]|0}l=c[b+424>>2]|0;if((d|0)<=0){if(l)s=48}else{j=0;do{c[m+(j<<2)>>2]=c[l+(j<<2)>>2];j=j+1|0}while((j|0)!=(d|0));s=48}if((s|0)==48){if(a[b+428>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);d=c[b+416>>2]|0}c[b+424>>2]=0}a[b+428>>0]=1;c[b+424>>2]=m;c[b+420>>2]=o;j=d;d=o}else j=d}c[(c[b+424>>2]|0)+(j<<2)>>2]=3;j=j+1|0;c[b+416>>2]=j;if((j|0)==(d|0)){o=d|0?d<<1:1;if((d|0)<(o|0)){if(!o)m=0;else{c[6435]=(c[6435]|0)+1;d=yc((o<<2|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}m=d;d=c[b+416>>2]|0}l=c[b+424>>2]|0;if((d|0)<=0){if(l)s=61}else{j=0;do{c[m+(j<<2)>>2]=c[l+(j<<2)>>2];j=j+1|0}while((j|0)!=(d|0));s=61}if((s|0)==61){if(a[b+428>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);d=c[b+416>>2]|0}c[b+424>>2]=0}a[b+428>>0]=1;c[b+424>>2]=m;c[b+420>>2]=o}}else d=j;c[(c[b+424>>2]|0)+(d<<2)>>2]=0;c[b+416>>2]=d+1;c[6435]=(c[6435]|0)+1;d=yc(39)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d>>2]=3288;c[d+4>>2]=32;c[d+16>>2]=b;c[b+192>>2]=d;g[d+12>>2]=.25;c[b+1148>>2]=1065353216;c[b+1152>>2]=0;c[b+1152+4>>2]=0;c[b+1152+8>>2]=0;c[b+1152+12>>2]=0;c[b+1168>>2]=1065353216;c[b+1172>>2]=0;c[b+1172+4>>2]=0;c[b+1172+8>>2]=0;c[b+1172+12>>2]=0;c[b+1188>>2]=1065353216;s=b+1192|0;t=s+36|0;do{c[s>>2]=0;s=s+4|0}while((s|0)<(t|0));g[b+1228>>2]=1.0;x=ph(b)|0;g[x+4>>2]=1.0;g[x+8>>2]=1.0;g[x+12>>2]=1.0;c[x+16>>2]=1;s=c[b+192>>2]|0;y=+Sb[c[(c[s>>2]|0)+48>>2]&15](s);s=z;t=s+100|0;do{c[s>>2]=0;s=s+4|0}while((s|0)<(t|0));o=c[b+712>>2]|0;if((o|0)<(e|0)){if((c[b+716>>2]|0)<(e|0)){if(!e){d=0;j=o}else{c[6435]=(c[6435]|0)+1;d=yc((e*104|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}j=c[b+712>>2]|0}if((j|0)>0){l=0;do{s=d+(l*104|0)|0;m=(c[b+720>>2]|0)+(l*104|0)|0;t=s+104|0;do{c[s>>2]=c[m>>2];s=s+4|0;m=m+4|0}while((s|0)<(t|0));l=l+1|0}while((l|0)!=(j|0))}j=c[b+720>>2]|0;if(j|0){if(a[b+724>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[b+720>>2]=0}a[b+724>>0]=1;c[b+720>>2]=d;c[b+716>>2]=e;d=o}else d=o;do{s=c[b+720>>2]|0;c[s+(d*104|0)>>2]=0;s=s+(d*104|0)+4|0;m=z;t=s+100|0;do{c[s>>2]=c[m>>2];s=s+4|0;m=m+4|0}while((s|0)<(t|0));d=d+1|0}while((d|0)!=(e|0))}c[b+712>>2]=e;if((e|0)>0){l=f;w=0;while(1){u=c[b+720>>2]|0;v=u+(w*104|0)|0;s=v;t=s+104|0;do{c[s>>2]=0;s=s+4|0}while((s|0)<(t|0));j=u+(w*104|0)+8|0;if(!l){f=0;d=0;m=0;o=0;n=0.0}else{f=l+16|0;d=c[l>>2]|0;m=c[l+4>>2]|0;o=c[l+8>>2]|0;n=+g[l+12>>2]}c[j>>2]=d;c[u+(w*104|0)+12>>2]=m;c[u+(w*104|0)+16>>2]=o;g[u+(w*104|0)+20>>2]=n;t=u+(w*104|0)+24|0;c[t>>2]=c[j>>2];c[t+4>>2]=c[j+4>>2];c[t+8>>2]=c[j+8>>2];c[t+12>>2]=c[j+12>>2];r=(c[k>>2]=d,+g[k>>2]);q=(c[k>>2]=m,+g[k>>2]);p=(c[k>>2]=o,+g[k>>2]);if(!h){j=0;n=1.0}else{j=h+4|0;n=+g[h>>2]}g[u+(w*104|0)+88>>2]=n>0.0?1.0/n:0.0;d=c[b+932>>2]|0;if(!d){c[6435]=(c[6435]|0)+1;d=yc(63)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}s=d;t=s+44|0;do{c[s>>2]=0;s=s+4|0}while((s|0)<(t|0))}else c[b+932>>2]=0;c[d+32>>2]=0;c[d+36>>2]=v;c[d+40>>2]=0;g[d>>2]=r-y;g[d+4>>2]=q-y;g[d+8>>2]=p-y;g[d+12>>2]=0.0;g[d+16>>2]=y+r;g[d+20>>2]=y+q;g[d+24>>2]=y+p;g[d+28>>2]=0.0;lf(b+928|0,c[b+928>>2]|0,d);c[b+940>>2]=(c[b+940>>2]|0)+1;c[u+(w*104|0)+96>>2]=d;c[u+(w*104|0)+4>>2]=x;w=w+1|0;if((w|0)==(e|0))break;else{h=j;l=f}}}d=c[b+928>>2]|0;if(!d){c[b+892>>2]=0;c[b+892+4>>2]=0;c[b+892+8>>2]=0;c[b+892+12>>2]=0;c[b+892+16>>2]=0;c[b+892+20>>2]=0;c[b+892+24>>2]=0;c[b+892+28>>2]=0;i=z;return}e=c[b+192>>2]|0;q=+Sb[c[(c[e>>2]|0)+48>>2]&15](e);y=+g[d+4>>2]-q;r=+g[d+8>>2]-q;g[b+892>>2]=+g[d>>2]-q;g[b+896>>2]=y;g[b+900>>2]=r;g[b+904>>2]=0.0;r=q+ +g[d+20>>2];y=q+ +g[d+24>>2];g[b+908>>2]=q+ +g[d+16>>2];g[b+912>>2]=r;g[b+916>>2]=y;g[b+920>>2]=0.0;d=c[b+188>>2]|0;if(!d){i=z;return}e=c[b+684>>2]|0;x=c[e+32>>2]|0;yb[c[(c[x>>2]|0)+16>>2]&31](x,d,b+892|0,b+908|0,c[e+36>>2]|0);i=z;return}function Lc(d,f,h){d=d|0;f=f|0;h=h|0;var j=0,k=0,l=0.0,m=0,n=0.0,o=0.0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0.0,y=0.0,z=0.0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0.0,M=0.0,N=0.0;K=i;i=i+112|0;H=c[d+56>>2]|0;if((h-f|0)==1){if(!(a[d+60>>0]|0)){p=(c[d+96>>2]|0)+(H<<6)|0;q=(c[d+76>>2]|0)+(f<<6)|0;r=p+64|0;do{c[p>>2]=c[q>>2];p=p+4|0;q=q+4|0}while((p|0)<(r|0))}else{J=(c[d+136>>2]|0)+(H<<4)|0;I=(c[d+116>>2]|0)+(f<<4)|0;c[J>>2]=c[I>>2];c[J+4>>2]=c[I+4>>2];c[J+8>>2]=c[I+8>>2];c[J+12>>2]=c[I+12>>2]}c[d+56>>2]=(c[d+56>>2]|0)+1;i=K;return}if((h|0)>(f|0)){m=(a[d+60>>0]|0)==0;if(m){j=c[d+76>>2]|0;k=f;n=0.0;o=0.0;l=0.0;do{n=n+(+g[j+(k<<6)+16>>2]+ +g[j+(k<<6)>>2])*.5;l=l+(+g[j+(k<<6)+20>>2]+ +g[j+(k<<6)+4>>2])*.5;o=o+(+g[j+(k<<6)+24>>2]+ +g[j+(k<<6)+8>>2])*.5;k=k+1|0}while((k|0)!=(h|0))}else{j=c[d+116>>2]|0;s=+g[d+36>>2];t=+g[d+40>>2];u=+g[d+44>>2];x=+g[d+4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G+(v<<4)+8>>1]|0)/t+s;t=+(e[G+(v<<4)+4>>1]|0)/N+u;u=+(e[G+(v<<4)+10>>1]|0)/N+u}g[K>>2]=(n+l)*.5;g[K+4>>2]=(s+o)*.5;g[K+8>>2]=(u+t)*.5;g[K+12>>2]=0.0;if(+g[K+(w<<2)>>2]>x){if(k){k=c[d+76>>2]|0;m=k+(v<<6)|0;p=K+48|0;q=m;r=p+64|0;do{c[p>>2]=c[q>>2];p=p+4|0;q=q+4|0}while((p|0)<(r|0));p=m;q=k+(j<<6)|0;r=p+64|0;do{c[p>>2]=c[q>>2];p=p+4|0;q=q+4|0}while((p|0)<(r|0));p=(c[d+76>>2]|0)+(j<<6)|0;q=K+48|0;r=p+64|0;do{c[p>>2]=c[q>>2];p=p+4|0;q=q+4|0}while((p|0)<(r|0))}else{F=c[d+116>>2]|0;G=F+(v<<4)|0;c[K+48>>2]=c[G>>2];c[K+48+4>>2]=c[G+4>>2];c[K+48+8>>2]=c[G+8>>2];c[K+48+12>>2]=c[G+12>>2];F=F+(j<<4)|0;c[G>>2]=c[F>>2];c[G+4>>2]=c[F+4>>2];c[G+8>>2]=c[F+8>>2];c[G+12>>2]=c[F+12>>2];G=(c[d+116>>2]|0)+(j<<4)|0;c[G>>2]=c[K+48>>2];c[G+4>>2]=c[K+48+4>>2];c[G+8>>2]=c[K+48+8>>2];c[G+12>>2]=c[K+48+12>>2]}j=j+1|0}v=v+1|0}while((v|0)!=(h|0))}else j=f;if(!((j|0)>(((h-f|0)/3|0)+f|0)?(j|0)<(h+-1-((h-f|0)/3|0)|0):0))j=(h-f>>1)+f|0;G=c[d+56>>2]|0;if(!(a[d+60>>0]|0)){F=(c[d+96>>2]|0)+(G<<6)|0;c[F>>2]=c[d+20>>2];c[F+4>>2]=c[d+20+4>>2];c[F+8>>2]=c[d+20+8>>2];c[F+12>>2]=c[d+20+12>>2]}else{F=c[d+136>>2]|0;M=(+g[d+24>>2]-+g[d+8>>2])*+g[d+40>>2];N=(+g[d+28>>2]-+g[d+12>>2])*+g[d+44>>2];b[F+(G<<4)>>1]=~~((+g[d+20>>2]-+g[d+4>>2])*+g[d+36>>2])&65534;b[F+(G<<4)+2>>1]=~~M&65534;b[F+(G<<4)+4>>1]=~~N&65534}k=c[d+56>>2]|0;if(!(a[d+60>>0]|0)){F=(c[d+96>>2]|0)+(k<<6)+16|0;c[F>>2]=c[d+4>>2];c[F+4>>2]=c[d+4+4>>2];c[F+8>>2]=c[d+4+8>>2];c[F+12>>2]=c[d+4+12>>2]}else{F=c[d+136>>2]|0;L=+g[d+4>>2];M=+g[d+8>>2];N=+g[d+12>>2];M=(M-M)*+g[d+40>>2];N=(N-N)*+g[d+44>>2];b[F+(k<<4)+6>>1]=~~((L-L)*+g[d+36>>2]+1.0)&65535|1;b[F+(k<<4)+8>>1]=~~(M+1.0)&65535|1;b[F+(k<<4)+10>>1]=~~(N+1.0)&65535|1}F=c[d+56>>2]|0;if((h|0)>(f|0)){A=a[d+60>>0]|0;B=f;do{if(!(A<<24>>24)){k=c[d+76>>2]|0;l=+g[k+(B<<6)>>2];n=+g[k+(B<<6)+4>>2];o=+g[k+(B<<6)+8>>2];s=+g[k+(B<<6)+12>>2];t=+g[k+(B<<6)+16>>2];u=+g[k+(B<<6)+20>>2];x=+g[k+(B<<6)+24>>2];y=+g[k+(B<<6)+28>>2];k=c[d+96>>2]|0;if(l<+g[k+(F<<6)>>2])g[k+(F<<6)>>2]=l;if(n<+g[k+(F<<6)+4>>2])g[k+(F<<6)+4>>2]=n;if(o<+g[k+(F<<6)+8>>2])g[k+(F<<6)+8>>2]=o;if(s<+g[k+(F<<6)+12>>2])g[k+(F<<6)+12>>2]=s;if(+g[k+(F<<6)+16>>2]>2]=t;if(+g[k+(F<<6)+20>>2]>2]=u;if(+g[k+(F<<6)+24>>2]>2]=x;if(+g[k+(F<<6)+28>>2]>2]=y}else{q=c[d+116>>2]|0;s=+g[d+36>>2];E=+g[d+40>>2];y=+g[d+44>>2];t=+g[d+4>>2];L=+g[d+8>>2];z=+g[d+12>>2];u=+g[d+4>>2];M=+g[d+8>>2];C=+g[d+12>>2];x=+g[d+36>>2];N=+g[d+40>>2];D=+g[d+44>>2];r=~~((+(e[q+(B<<4)>>1]|0)/s+t-u)*x)&65534;k=~~((+(e[q+(B<<4)+4>>1]|0)/y+z-C)*D)&65534;p=~~((+(e[q+(B<<4)+2>>1]|0)/E+L-M)*N)&65534;v=(~~((+(e[q+(B<<4)+6>>1]|0)/s+t-u)*x+1.0)&65535|1)&65535;m=(~~((+(e[q+(B<<4)+10>>1]|0)/y+z-C)*D+1.0)&65535|1)&65535;q=(~~((+(e[q+(B<<4)+8>>1]|0)/E+L-M)*N+1.0)&65535|1)&65535;w=c[d+136>>2]|0;if((e[w+(F<<4)>>1]|0)>(r&65535))b[w+(F<<4)>>1]=r;if((e[w+(F<<4)+6>>1]|0)<(v&65535))b[w+(F<<4)+6>>1]=v;if((e[w+(F<<4)+2>>1]|0)>(p&65535))b[w+(F<<4)+2>>1]=p;if((e[w+(F<<4)+8>>1]|0)<(q&65535))b[w+(F<<4)+8>>1]=q;if((e[w+(F<<4)+4>>1]|0)>(k&65535))b[w+(F<<4)+4>>1]=k;if((e[w+(F<<4)+10>>1]|0)<(m&65535))b[w+(F<<4)+10>>1]=m}B=B+1|0}while((B|0)!=(h|0))}c[d+56>>2]=F+1;Lc(d,f,j);A=c[d+56>>2]|0;Lc(d,j,h);w=(c[d+56>>2]|0)-H|0;j=a[d+60>>0]|0;if(j<<24>>24!=0&(w<<4|0)>2048){r=c[d+136>>2]|0;p=c[r+(F+1<<4)+12>>2]|0;p=(p|0)>-1?1:0-p|0;v=c[r+(A<<4)+12>>2]|0;v=(v|0)>-1?1:0-v|0;if((p<<4|0)<2049){q=c[d+152>>2]|0;if((q|0)==(c[d+156>>2]|0)?(I=q|0?q<<1:1,(q|0)<(I|0)):0){if(!I){j=0;k=q}else{c[6435]=(c[6435]|0)+1;j=yc(I<<5|19)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}k=c[d+152>>2]|0}if((k|0)>0){m=0;do{h=j+(m<<5)|0;H=(c[d+160>>2]|0)+(m<<5)|0;c[h>>2]=c[H>>2];c[h+4>>2]=c[H+4>>2];c[h+8>>2]=c[H+8>>2];c[h+12>>2]=c[H+12>>2];c[h+16>>2]=c[H+16>>2];c[h+20>>2]=c[H+20>>2];c[h+24>>2]=c[H+24>>2];c[h+28>>2]=c[H+28>>2];m=m+1|0}while((m|0)!=(k|0))}k=c[d+160>>2]|0;if(k|0){if(a[d+164>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[d+160>>2]=0}a[d+164>>0]=1;c[d+160>>2]=j;c[d+156>>2]=I;j=c[d+152>>2]|0}else j=q;c[d+152>>2]=j+1;I=(c[d+160>>2]|0)+(q<<5)|0;c[I>>2]=c[K+48>>2];c[I+4>>2]=c[K+48+4>>2];c[I+8>>2]=c[K+48+8>>2];c[I+12>>2]=c[K+48+12>>2];c[I+16>>2]=c[K+48+16>>2];c[I+20>>2]=c[K+48+20>>2];c[I+24>>2]=c[K+48+24>>2];c[I+28>>2]=c[K+48+28>>2];I=c[d+160>>2]|0;b[I+(q<<5)>>1]=b[r+(F+1<<4)>>1]|0;b[I+(q<<5)+2>>1]=b[r+(F+1<<4)+2>>1]|0;b[I+(q<<5)+4>>1]=b[r+(F+1<<4)+4>>1]|0;b[I+(q<<5)+6>>1]=b[r+(F+1<<4)+6>>1]|0;b[I+(q<<5)+8>>1]=b[r+(F+1<<4)+8>>1]|0;b[I+(q<<5)+10>>1]=b[r+(F+1<<4)+10>>1]|0;c[I+(q<<5)+12>>2]=F+1;c[I+(q<<5)+16>>2]=p}if((v<<4|0)<2049){p=c[d+152>>2]|0;if((p|0)==(c[d+156>>2]|0)?(J=p|0?p<<1:1,(p|0)<(J|0)):0){if(!J){j=0;k=p}else{c[6435]=(c[6435]|0)+1;j=yc(J<<5|19)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}k=c[d+152>>2]|0}if((k|0)>0){m=0;do{I=j+(m<<5)|0;h=(c[d+160>>2]|0)+(m<<5)|0;c[I>>2]=c[h>>2];c[I+4>>2]=c[h+4>>2];c[I+8>>2]=c[h+8>>2];c[I+12>>2]=c[h+12>>2];c[I+16>>2]=c[h+16>>2];c[I+20>>2]=c[h+20>>2];c[I+24>>2]=c[h+24>>2];c[I+28>>2]=c[h+28>>2];m=m+1|0}while((m|0)!=(k|0))}k=c[d+160>>2]|0;if(k|0){if(a[d+164>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[d+160>>2]=0}a[d+164>>0]=1;c[d+160>>2]=j;c[d+156>>2]=J;j=c[d+152>>2]|0}else j=p;c[d+152>>2]=j+1;J=(c[d+160>>2]|0)+(p<<5)|0;c[J>>2]=c[K+16>>2];c[J+4>>2]=c[K+16+4>>2];c[J+8>>2]=c[K+16+8>>2];c[J+12>>2]=c[K+16+12>>2];c[J+16>>2]=c[K+16+16>>2];c[J+20>>2]=c[K+16+20>>2];c[J+24>>2]=c[K+16+24>>2];c[J+28>>2]=c[K+16+28>>2];J=c[d+160>>2]|0;b[J+(p<<5)>>1]=b[r+(A<<4)>>1]|0;b[J+(p<<5)+2>>1]=b[r+(A<<4)+2>>1]|0;b[J+(p<<5)+4>>1]=b[r+(A<<4)+4>>1]|0;b[J+(p<<5)+6>>1]=b[r+(A<<4)+6>>1]|0;b[J+(p<<5)+8>>1]=b[r+(A<<4)+8>>1]|0;b[J+(p<<5)+10>>1]=b[r+(A<<4)+10>>1]|0;c[J+(p<<5)+12>>2]=A;c[J+(p<<5)+16>>2]=v}c[d+168>>2]=c[d+152>>2];j=a[d+60>>0]|0}if(!(j<<24>>24)){c[(c[d+96>>2]|0)+(G<<6)+32>>2]=w;i=K;return}else{c[(c[d+136>>2]|0)+(G<<4)+12>>2]=0-w;i=K;return}}function Mc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0;u=i;i=i+368|0;f=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;kc[c[(c[f>>2]|0)+56>>2]&7](f,b,1.0);f=c[d+4>>2]|0;switch(f|0){case 31:{f=c[d+16>>2]|0;if((f|0)<=0){i=u;return}do{t=f;f=f+-1|0;s=c[d+24>>2]|0;J=+g[s+(f*80|0)>>2];G=+g[s+(f*80|0)+4>>2];D=+g[s+(f*80|0)+8>>2];I=+g[s+(f*80|0)+16>>2];F=+g[s+(f*80|0)+20>>2];B=+g[s+(f*80|0)+24>>2];H=+g[s+(f*80|0)+32>>2];E=+g[s+(f*80|0)+36>>2];z=+g[s+(f*80|0)+40>>2];R=+g[s+(f*80|0)+48>>2];Q=+g[s+(f*80|0)+52>>2];v=+g[s+(f*80|0)+56>>2];s=c[s+(f*80|0)+64>>2]|0;r=c[(c[a>>2]|0)+28>>2]|0;P=+g[b>>2];O=+g[b+4>>2];N=+g[b+8>>2];M=+g[b+16>>2];L=+g[b+20>>2];K=+g[b+24>>2];C=+g[b+32>>2];A=+g[b+36>>2];y=+g[b+40>>2];x=R*P+Q*O+v*N+ +g[b+48>>2];w=R*M+Q*L+v*K+ +g[b+52>>2];v=R*C+Q*A+v*y+ +g[b+56>>2];g[u+288>>2]=J*P+I*O+H*N;g[u+288+4>>2]=G*P+F*O+E*N;g[u+288+8>>2]=D*P+B*O+z*N;g[u+288+12>>2]=0.0;g[u+288+16>>2]=J*M+I*L+H*K;g[u+288+20>>2]=G*M+F*L+E*K;g[u+288+24>>2]=D*M+B*L+z*K;g[u+288+28>>2]=0.0;g[u+288+32>>2]=J*C+I*A+H*y;g[u+288+36>>2]=G*C+F*A+E*y;g[u+288+40>>2]=D*C+B*A+z*y;g[u+288+44>>2]=0.0;g[u+288+48>>2]=x;g[u+288+52>>2]=w;g[u+288+56>>2]=v;g[u+288+60>>2]=0.0;mc[r&127](a,u+288|0,s,e)}while((t|0)>1);i=u;return}case 0:{c[u+352>>2]=c[d+28>>2];c[u+352+4>>2]=c[d+28+4>>2];c[u+352+8>>2]=c[d+28+8>>2];c[u+352+12>>2]=c[d+28+12>>2];P=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);Q=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);R=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);P=P+ +g[u+352>>2];g[u+352>>2]=P;Q=Q+ +g[u+352+4>>2];g[u+352+4>>2]=Q;R=R+ +g[u+352+8>>2];g[u+352+8>>2]=R;a=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;d=c[(c[a>>2]|0)+72>>2]|0;g[u+272>>2]=-P;g[u+272+4>>2]=-Q;g[u+272+8>>2]=-R;g[u+272+12>>2]=0.0;yb[d&31](a,u+272|0,u+352|0,b,e);i=u;return}case 8:{R=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);a=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;Hb[c[(c[a>>2]|0)+16>>2]&0](a,R,b,e);i=u;return}case 9:{f=c[d+92>>2]|0;if((f|0)<=0){i=u;return}do{t=f;f=f+-1|0;s=c[d+100>>2]|0;D=+g[s+(f<<4)>>2];E=+g[s+(f<<4)+4>>2];Q=+g[s+(f<<4)+8>>2];s=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;r=c[(c[s>>2]|0)+16>>2]|0;R=+g[(c[d+120>>2]|0)+(f<<2)>>2];G=+g[b>>2];H=+g[b+4>>2];F=+g[b+8>>2];J=+g[b+16>>2];K=+g[b+20>>2];I=+g[b+24>>2];M=+g[b+32>>2];N=+g[b+36>>2];L=+g[b+40>>2];O=D*G+E*H+Q*F+ +g[b+48>>2];P=D*J+E*K+Q*I+ +g[b+52>>2];Q=D*M+E*N+Q*L+ +g[b+56>>2];g[u+192>>2]=G+H*0.0+F*0.0;g[u+192+4>>2]=G*0.0+H+F*0.0;g[u+192+8>>2]=F+(G*0.0+H*0.0);g[u+192+12>>2]=0.0;g[u+192+16>>2]=J+K*0.0+I*0.0;g[u+192+20>>2]=J*0.0+K+I*0.0;g[u+192+24>>2]=I+(J*0.0+K*0.0);g[u+192+28>>2]=0.0;g[u+192+32>>2]=M+N*0.0+L*0.0;g[u+192+36>>2]=M*0.0+N+L*0.0;g[u+192+40>>2]=L+(M*0.0+N*0.0);g[u+192+44>>2]=0.0;g[u+192+48>>2]=O;g[u+192+52>>2]=P;g[u+192+56>>2]=Q;g[u+192+60>>2]=0.0;Hb[r&0](s,R,u+192|0,e)}while((t|0)>1);i=u;return}case 10:{t=c[d+52>>2]|0;Q=+g[d+28+(((t+2|0)%3|0)<<2)>>2];R=+g[d+28+(t<<2)>>2];a=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;Gb[c[(c[a>>2]|0)+76>>2]&0](a,Q,R,t,b,e);i=u;return}case 11:{Q=+g[d+56>>2];R=+g[d+60>>2];d=c[d+68>>2]|0;a=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;Gb[c[(c[a>>2]|0)+84>>2]&0](a,Q,R,d,b,e);i=u;return}case 13:{t=c[d+52>>2]|0;Q=+Sb[c[(c[d>>2]|0)+92>>2]&15](d);c[u+80>>2]=c[d+28>>2];c[u+80+4>>2]=c[d+28+4>>2];c[u+80+8>>2]=c[d+28+8>>2];c[u+80+12>>2]=c[d+28+12>>2];O=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);P=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);R=+Sb[c[(c[d>>2]|0)+48>>2]&15](d);g[u+80>>2]=O+ +g[u+80>>2];g[u+80+4>>2]=P+ +g[u+80+4>>2];g[u+80+8>>2]=R+ +g[u+80+8>>2];R=+g[u+80+(t<<2)>>2];a=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;Gb[c[(c[a>>2]|0)+80>>2]&0](a,Q,R,t,b,e);i=u;return}case 28:{R=+g[d+64>>2];a=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;Vb[c[(c[a>>2]|0)+88>>2]&0](a,d+48|0,R,b,e);i=u;return}default:{a:do if((f|0)<7){q=c[d+52>>2]|0;if(!q){if((Eb[c[(c[d>>2]|0)+100>>2]&127](d)|0)<=0)break;f=0;while(1){mc[c[(c[d>>2]|0)+104>>2]&127](d,f,u+352|0,u+256|0);P=+g[u+352>>2];D=+g[b>>2];N=+g[u+352+4>>2];E=+g[b+4>>2];L=+g[u+352+8>>2];F=+g[b+8>>2];H=+g[b+16>>2];I=+g[b+20>>2];J=+g[b+24>>2];M=+g[b+32>>2];O=+g[b+36>>2];Q=+g[b+40>>2];G=+g[b+48>>2];K=+g[b+52>>2];R=+g[b+56>>2];g[u+96>>2]=P*D+N*E+L*F+G;g[u+96+4>>2]=P*H+N*I+L*J+K;g[u+96+8>>2]=P*M+N*O+L*Q+R;g[u+96+12>>2]=0.0;L=+g[u+256>>2];N=+g[u+256+4>>2];P=+g[u+256+8>>2];g[u+64>>2]=L*D+N*E+P*F+G;g[u+64+4>>2]=L*H+N*I+P*J+K;g[u+64+8>>2]=L*M+N*O+P*Q+R;g[u+64+12>>2]=0.0;t=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;mc[c[(c[t>>2]|0)+8>>2]&127](t,u+96|0,u+64|0,e);f=f+1|0;if((f|0)>=(Eb[c[(c[d>>2]|0)+100>>2]&127](d)|0))break a}}if((c[q+28>>2]|0)>0){s=0;do{f=c[q+36>>2]|0;r=c[f+(s*36|0)+4>>2]|0;b:do if((r|0)!=0?(t=c[f+(s*36|0)+12>>2]|0,(r|0)>0):0){m=t;j=0;h=0;f=0;o=c[t+(r+-1<<2)>>2]|0;l=0;while(1){p=c[m+(l<<2)>>2]|0;n=c[q+16>>2]|0;j=(g[k>>2]=(c[k>>2]=j,+g[k>>2])+ +g[n+(p<<4)>>2],c[k>>2]|0);f=(g[k>>2]=(c[k>>2]=f,+g[k>>2])+ +g[n+(p<<4)+4>>2],c[k>>2]|0);h=(g[k>>2]=(c[k>>2]=h,+g[k>>2])+ +g[n+(p<<4)+8>>2],c[k>>2]|0);n=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;m=c[(c[n>>2]|0)+8>>2]|0;S=c[q+16>>2]|0;P=+g[S+(o<<4)>>2];D=+g[b>>2];N=+g[S+(o<<4)+4>>2];E=+g[b+4>>2];L=+g[S+(o<<4)+8>>2];F=+g[b+8>>2];H=+g[b+16>>2];I=+g[b+20>>2];J=+g[b+24>>2];M=+g[b+32>>2];O=+g[b+36>>2];Q=+g[b+40>>2];G=+g[b+48>>2];K=+g[b+52>>2];R=+g[b+56>>2];g[u+48>>2]=P*D+N*E+L*F+G;g[u+48+4>>2]=P*H+N*I+L*J+K;g[u+48+8>>2]=P*M+N*O+L*Q+R;g[u+48+12>>2]=0.0;L=+g[S+(p<<4)>>2];N=+g[S+(p<<4)+4>>2];P=+g[S+(p<<4)+8>>2];g[u+32>>2]=L*D+N*E+P*F+G;g[u+32+4>>2]=L*H+N*I+P*J+K;g[u+32+8>>2]=L*M+N*O+P*Q+R;g[u+32+12>>2]=0.0;mc[m&127](n,u+48|0,u+32|0,e);n=l+1|0;l=c[q+36>>2]|0;if((n|0)>=(c[l+(s*36|0)+4>>2]|0))break b;m=c[l+(s*36|0)+12>>2]|0;o=p;l=n}}else{j=0;h=0;f=0}while(0);S=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;if((Eb[c[(c[S>>2]|0)+48>>2]&127](S)|0)&16384|0){O=1.0/+(r|0)*(c[k>>2]=h,+g[k>>2]);L=1.0/+(r|0)*(c[k>>2]=f,+g[k>>2]);I=1.0/+(r|0)*(c[k>>2]=j,+g[k>>2]);c[u+352>>2]=1065353216;c[u+352+4>>2]=1065353216;c[u+352+8>>2]=0;g[u+352+12>>2]=0.0;S=c[q+36>>2]|0;J=+g[S+(s*36|0)+20>>2];M=+g[S+(s*36|0)+24>>2];P=+g[S+(s*36|0)+28>>2];S=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;r=c[(c[S>>2]|0)+8>>2]|0;A=+g[b>>2];B=+g[b+4>>2];C=+g[b+8>>2];E=+g[b+16>>2];F=+g[b+20>>2];G=+g[b+24>>2];K=+g[b+32>>2];N=+g[b+36>>2];Q=+g[b+40>>2];D=+g[b+48>>2];H=+g[b+52>>2];R=+g[b+56>>2];g[u+16>>2]=I*A+L*B+O*C+D;g[u+16+4>>2]=I*E+L*F+O*G+H;g[u+16+8>>2]=I*K+L*N+O*Q+R;g[u+16+12>>2]=0.0;g[u>>2]=(I+J)*A+(L+M)*B+(O+P)*C+D;g[u+4>>2]=(I+J)*E+(L+M)*F+(O+P)*G+H;g[u+8>>2]=(I+J)*K+(L+M)*N+(O+P)*Q+R;g[u+12>>2]=0.0;mc[r&127](S,u+16|0,u,u+352|0)}s=s+1|0}while((s|0)<(c[q+28>>2]|0))}}while(0);f=c[d+4>>2]|0;if((f+-21|0)>>>0<9){c[u+352>>2]=1566444395;c[u+352+4>>2]=1566444395;c[u+352+8>>2]=1566444395;g[u+352+12>>2]=0.0;c[u+256>>2]=-581039253;c[u+256+4>>2]=-581039253;c[u+256+8>>2]=-581039253;g[u+256+12>>2]=0.0;f=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;c[u+96>>2]=5692;c[u+96+4>>2]=5716;c[u+96+8>>2]=f;c[u+96+12>>2]=c[e>>2];c[u+96+12+4>>2]=c[e+4>>2];c[u+96+12+8>>2]=c[e+8>>2];c[u+96+12+12>>2]=c[e+12>>2];c[u+96+28>>2]=c[b>>2];c[u+96+28+4>>2]=c[b+4>>2];c[u+96+28+8>>2]=c[b+8>>2];c[u+96+28+12>>2]=c[b+12>>2];c[u+96+44>>2]=c[b+16>>2];c[u+96+44+4>>2]=c[b+16+4>>2];c[u+96+44+8>>2]=c[b+16+8>>2];c[u+96+44+12>>2]=c[b+16+12>>2];c[u+96+60>>2]=c[b+32>>2];c[u+96+60+4>>2]=c[b+32+4>>2];c[u+96+60+8>>2]=c[b+32+8>>2];c[u+96+60+12>>2]=c[b+32+12>>2];c[u+96+76>>2]=c[b+48>>2];c[u+96+76+4>>2]=c[b+48+4>>2];c[u+96+76+8>>2]=c[b+48+8>>2];c[u+96+76+12>>2]=c[b+48+12>>2];mc[c[(c[d>>2]|0)+64>>2]&127](d,u+96|0,u+256|0,u+352|0);f=c[d+4>>2]|0}if((f|0)!=3){i=u;return}c[u+352>>2]=1566444395;c[u+352+4>>2]=1566444395;c[u+352+8>>2]=1566444395;g[u+352+12>>2]=0.0;c[u+256>>2]=-581039253;c[u+256+4>>2]=-581039253;c[u+256+8>>2]=-581039253;g[u+256+12>>2]=0.0;S=Eb[c[(c[a>>2]|0)+20>>2]&127](a)|0;c[u+96>>2]=5692;c[u+96+4>>2]=5716;c[u+96+8>>2]=S;c[u+96+12>>2]=c[e>>2];c[u+96+12+4>>2]=c[e+4>>2];c[u+96+12+8>>2]=c[e+8>>2];c[u+96+12+12>>2]=c[e+12>>2];c[u+96+28>>2]=c[b>>2];c[u+96+28+4>>2]=c[b+4>>2];c[u+96+28+8>>2]=c[b+8>>2];c[u+96+28+12>>2]=c[b+12>>2];c[u+96+44>>2]=c[b+16>>2];c[u+96+44+4>>2]=c[b+16+4>>2];c[u+96+44+8>>2]=c[b+16+8>>2];c[u+96+44+12>>2]=c[b+16+12>>2];c[u+96+60>>2]=c[b+32>>2];c[u+96+60+4>>2]=c[b+32+4>>2];c[u+96+60+8>>2]=c[b+32+8>>2];c[u+96+60+12>>2]=c[b+32+12>>2];c[u+96+76>>2]=c[b+48>>2];c[u+96+76+4>>2]=c[b+48+4>>2];c[u+96+76+8>>2]=c[b+48+8>>2];c[u+96+76+12>>2]=c[b+48+12>>2];S=c[d+92>>2]|0;mc[c[(c[S>>2]|0)+8>>2]&127](S,u+96+4|0,u+256|0,u+352|0);i=u;return}}}function Nc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0;t=i;i=i+48|0;z=1.0/+g[a+108>>2];A=1.0/+g[a+112>>2];B=1.0/+g[a+116>>2];u=+g[a+48>>2];v=z*+g[d>>2]+u;o=+g[a+52>>2];k=A*+g[d+4>>2]+o;q=+g[a+56>>2];p=B*+g[d+8>>2]+q;u=z*+g[e>>2]+u;o=A*+g[e+4>>2]+o;q=B*+g[e+8>>2]+q;B=+g[a+16>>2];v=v>2];k=k>2];p=p>2];v=y>2];k=x>2];p=w>2]|0)+-1|0;d=(c[a+68>>2]|0)+-1|0;switch(c[a+104>>2]|0){case 0:{d=(e|0)<(d|0)?e:d;j=(h|0)<(j|0)?h:j;e=(l|0)>0?l:0;r=(n|0)>0?n:0;break}case 1:{d=(e|0)<(d|0)?e:d;j=(f|0)<(j|0)?f:j;e=(l|0)>0?l:0;r=(m|0)>0?m:0;break}case 2:{d=(h|0)<(d|0)?h:d;j=(f|0)<(j|0)?f:j;e=(n|0)>0?n:0;r=(m|0)>0?m:0;break}default:{e=0;r=0}}if((e|0)>=(d|0)){i=t;return}n=(r|0)<(j|0);m=e;while(1){if(n){l=(m&1|0)==0;e=m+1|0;q=+(m|0);h=r;while(1){f=c[a+100>>2]|0;do if(!((f&255)<<24>>24)){if(f&65280|0?(h+m&1|0)==0:0){s=16;break}if(!(l&(f&16711680|0)!=0)){k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,h,m);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(h|0)-+g[a+80>>2]*.5;p=q-+g[a+84>>2]*.5;g[t>>2]=k;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;break}case 1:{B=+(h|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=q-+g[a+84>>2]*.5;g[t>>2]=B;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;k=B;break}case 2:{B=+(h|0)-+g[a+80>>2]*.5;o=q-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t>>2]=B;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;k=B;break}default:{k=+g[t>>2];o=+g[t+4>>2];p=+g[t+8>>2]}}g[t>>2]=k*+g[a+108>>2];g[t+4>>2]=o*+g[a+112>>2];g[t+8>>2]=p*+g[a+116>>2];k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,h,e);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(h|0)-+g[a+80>>2]*.5;p=+(e|0)-+g[a+84>>2]*.5;g[t+16>>2]=k;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;break}case 1:{B=+(h|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=+(e|0)-+g[a+84>>2]*.5;g[t+16>>2]=B;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;k=B;break}case 2:{B=+(h|0)-+g[a+80>>2]*.5;o=+(e|0)-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+16>>2]=B;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;k=B;break}default:{k=+g[t+16>>2];o=+g[t+20>>2];p=+g[t+24>>2]}}g[t+16>>2]=k*+g[a+108>>2];g[t+20>>2]=o*+g[a+112>>2];g[t+24>>2]=p*+g[a+116>>2];f=h+1|0;k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,f,m);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(f|0)-+g[a+80>>2]*.5;p=q-+g[a+84>>2]*.5;g[t+32>>2]=k;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;break}case 1:{B=+(f|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=q-+g[a+84>>2]*.5;g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}case 2:{B=+(f|0)-+g[a+80>>2]*.5;o=q-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}default:{k=+g[t+32>>2];o=+g[t+36>>2];p=+g[t+40>>2]}}g[t+32>>2]=k*+g[a+108>>2];g[t+36>>2]=o*+g[a+112>>2];g[t+40>>2]=p*+g[a+116>>2];mc[c[(c[b>>2]|0)+8>>2]&127](b,t,h,m);k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,f,m);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(f|0)-+g[a+80>>2]*.5;p=q-+g[a+84>>2]*.5;g[t>>2]=k;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;break}case 1:{B=+(f|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=q-+g[a+84>>2]*.5;g[t>>2]=B;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;k=B;break}case 2:{B=+(f|0)-+g[a+80>>2]*.5;o=q-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t>>2]=B;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;k=B;break}default:{k=+g[t>>2];o=+g[t+4>>2];p=+g[t+8>>2]}}g[t>>2]=k*+g[a+108>>2];g[t+4>>2]=o*+g[a+112>>2];g[t+8>>2]=p*+g[a+116>>2];k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,f,e);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(f|0)-+g[a+80>>2]*.5;p=+(e|0)-+g[a+84>>2]*.5;g[t+32>>2]=k;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;break}case 1:{B=+(f|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=+(e|0)-+g[a+84>>2]*.5;g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}case 2:{B=+(f|0)-+g[a+80>>2]*.5;o=+(e|0)-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}default:{k=+g[t+32>>2];o=+g[t+36>>2];p=+g[t+40>>2]}}g[t+32>>2]=k*+g[a+108>>2];g[t+36>>2]=o*+g[a+112>>2];g[t+40>>2]=p*+g[a+116>>2];mc[c[(c[b>>2]|0)+8>>2]&127](b,t,h,m)}else s=16}else s=16;while(0);if((s|0)==16){s=0;k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,h,m);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(h|0)-+g[a+80>>2]*.5;p=q-+g[a+84>>2]*.5;g[t>>2]=k;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;break}case 1:{B=+(h|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=q-+g[a+84>>2]*.5;g[t>>2]=B;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;k=B;break}case 2:{B=+(h|0)-+g[a+80>>2]*.5;o=q-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t>>2]=B;g[t+4>>2]=o;g[t+8>>2]=p;g[t+12>>2]=0.0;k=B;break}default:{k=+g[t>>2];o=+g[t+4>>2];p=+g[t+8>>2]}}g[t>>2]=k*+g[a+108>>2];g[t+4>>2]=o*+g[a+112>>2];g[t+8>>2]=p*+g[a+116>>2];f=h+1|0;k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,f,m);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(f|0)-+g[a+80>>2]*.5;p=q-+g[a+84>>2]*.5;g[t+16>>2]=k;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;break}case 1:{B=+(f|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=q-+g[a+84>>2]*.5;g[t+16>>2]=B;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;k=B;break}case 2:{B=+(f|0)-+g[a+80>>2]*.5;o=q-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+16>>2]=B;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;k=B;break}default:{k=+g[t+16>>2];o=+g[t+20>>2];p=+g[t+24>>2]}}g[t+16>>2]=k*+g[a+108>>2];g[t+20>>2]=o*+g[a+112>>2];g[t+24>>2]=p*+g[a+116>>2];k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,f,e);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(f|0)-+g[a+80>>2]*.5;p=+(e|0)-+g[a+84>>2]*.5;g[t+32>>2]=k;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;break}case 1:{B=+(f|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=+(e|0)-+g[a+84>>2]*.5;g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}case 2:{B=+(f|0)-+g[a+80>>2]*.5;o=+(e|0)-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}default:{k=+g[t+32>>2];o=+g[t+36>>2];p=+g[t+40>>2]}}g[t+32>>2]=k*+g[a+108>>2];g[t+36>>2]=o*+g[a+112>>2];g[t+40>>2]=p*+g[a+116>>2];mc[c[(c[b>>2]|0)+8>>2]&127](b,t,h,m);k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,f,e);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(f|0)-+g[a+80>>2]*.5;p=+(e|0)-+g[a+84>>2]*.5;g[t+16>>2]=k;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;break}case 1:{B=+(f|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=+(e|0)-+g[a+84>>2]*.5;g[t+16>>2]=B;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;k=B;break}case 2:{B=+(f|0)-+g[a+80>>2]*.5;o=+(e|0)-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+16>>2]=B;g[t+20>>2]=o;g[t+24>>2]=p;g[t+28>>2]=0.0;k=B;break}default:{k=+g[t+16>>2];o=+g[t+20>>2];p=+g[t+24>>2]}}g[t+16>>2]=k*+g[a+108>>2];g[t+20>>2]=o*+g[a+112>>2];g[t+24>>2]=p*+g[a+116>>2];k=+_b[c[(c[a>>2]|0)+68>>2]&15](a,h,e);switch(c[a+104>>2]|0){case 0:{k=k-+g[a+48>>2];o=+(h|0)-+g[a+80>>2]*.5;p=+(e|0)-+g[a+84>>2]*.5;g[t+32>>2]=k;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;break}case 1:{B=+(h|0)-+g[a+80>>2]*.5;o=k-+g[a+52>>2];p=+(e|0)-+g[a+84>>2]*.5;g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}case 2:{B=+(h|0)-+g[a+80>>2]*.5;o=+(e|0)-+g[a+84>>2]*.5;p=k-+g[a+56>>2];g[t+32>>2]=B;g[t+36>>2]=o;g[t+40>>2]=p;g[t+44>>2]=0.0;k=B;break}default:{k=+g[t+32>>2];o=+g[t+36>>2];p=+g[t+40>>2]}}g[t+32>>2]=k*+g[a+108>>2];g[t+36>>2]=o*+g[a+112>>2];g[t+40>>2]=p*+g[a+116>>2];mc[c[(c[b>>2]|0)+8>>2]&127](b,t,h,m)}if((f|0)==(j|0))break;else h=f}}else e=m+1|0;if((e|0)==(d|0))break;else m=e}i=t;return}function Oc(b,d,e,f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|0))ef(m,j+4|0,l+4|0);else ef(m,l+4|0,k+4|0);c[h+4>>2]=0;j=c[da+128+4>>2]|0}n=n+1|0}while((n|0)<(j|0))}if((j|0)<0){if((c[da+128+8>>2]|0)<0){k=c[q>>2]|0;if(k|0){if(a[da+128+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[k+-4>>2]|0)}c[q>>2]=0}a[da+128+16>>0]=1;c[q>>2]=0;c[da+128+8>>2]=0}do{c[(c[q>>2]|0)+(j<<2)>>2]=0;j=j+1|0}while((j|0)!=0)}c[da+128+4>>2]=0;j=c[p+8>>2]|0}o=o+1|0}while((o|0)<(j|0));j=c[q>>2]|0;if(j|0){if(a[da+128+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[q>>2]=0}}k=c[aa+64>>2]|0;l=c[ba+64>>2]|0;p=c[b+4>>2]|0;q=c[$>>2]|0;r=c[b+32>>2]|0;c[da+128>>2]=6256;c[da+128+4>>2]=0;c[da+128+8>>2]=d;c[da+128+12>>2]=e;c[da+128+16>>2]=p;c[da+128+20>>2]=f;c[da+128+24>>2]=h;c[da+128+28>>2]=q;c[da+128+32>>2]=r;r=c[d+12>>2]|0;B=+g[r>>2];C=+g[r+16>>2];D=+g[r+32>>2];E=+g[r+4>>2];F=+g[r+20>>2];G=+g[r+36>>2];H=+g[r+8>>2];I=+g[r+24>>2];J=+g[r+40>>2];K=-+g[r+48>>2];L=-+g[r+52>>2];M=-+g[r+56>>2];r=c[e+12>>2]|0;O=+g[r>>2];P=+g[r+16>>2];Q=+g[r+32>>2];R=+g[r+4>>2];S=+g[r+20>>2];T=+g[r+36>>2];U=+g[r+8>>2];V=+g[r+24>>2];W=+g[r+40>>2];X=+g[r+48>>2];Y=+g[r+52>>2];Z=+g[r+56>>2];k=c[k>>2]|0;l=c[l>>2]|0;if((k|0)!=0&(l|0)!=0){c[6435]=(c[6435]|0)+1;j=yc(1043)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=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=(c[6435]|0)+1;k=yc((m<<4|3)+16|0)|0;if(!k)k=0;else{c[(k+4+15&-16)+-4>>2]=k;k=k+4+15&-16}if((m|0)>0)l=0;else{_=52;break}do{pa=j+(l<<3)|0;o=c[pa+4>>2]|0;p=k+(l<<3)|0;c[p>>2]=c[pa>>2];c[p+4>>2]=o;l=l+1|0}while((l|0)!=(m|0))}while(0);if((_|0)==52){_=0;if(!j){l=n;j=k;break}}c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);l=n;j=k}while(0);p=n;k=n+-4|0}else p=m;m=(c[h+40>>2]|0)!=0;if(!(c[f+40>>2]|0))if(m){n=c[h+36>>2]|0;c[j+(q<<3)>>2]=f;c[j+(q<<3)+4>>2]=n;n=c[h+40>>2]|0;c[j+(r<<3)>>2]=f;c[j+(r<<3)+4>>2]=n;n=r+1|0;m=p;break}else{ic[c[(c[da+128>>2]|0)+8>>2]&127](da+128|0,f,h);n=q;m=p;break}else{n=j+(q<<3)|0;o=c[f+36>>2]|0;if(m){m=c[h+36>>2]|0;c[n>>2]=o;c[j+(q<<3)+4>>2]=m;m=r+1|0;n=c[h+36>>2]|0;c[j+(r<<3)>>2]=c[f+40>>2];c[j+(r<<3)+4>>2]=n;n=r+2|0;pa=c[h+40>>2]|0;c[j+(m<<3)>>2]=c[f+36>>2];c[j+(m<<3)+4>>2]=pa;m=c[h+40>>2]|0;c[j+(n<<3)>>2]=c[f+40>>2];c[j+(n<<3)+4>>2]=m;n=r+3|0;m=p;break}else{c[n>>2]=o;c[j+(q<<3)+4>>2]=h;c[j+(r<<3)>>2]=c[f+40>>2];c[j+(r<<3)+4>>2]=h;n=r+1|0;m=p;break}}}else n=q;while(0);if(!n)break;else r=n}if(j|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}}o=c[$>>2]|0;if((c[o+8>>2]|0)>0){p=0;do{j=c[o+16>>2]|0;k=c[j+(p*12|0)+8>>2]|0;do if(k|0){pa=c[j+(p*12|0)>>2]|0;_=c[aa+24>>2]|0;r=c[_+(pa*80|0)+64>>2]|0;h=c[d+12>>2]|0;oa=+g[h>>2];P=+g[h+4>>2];O=+g[h+8>>2];la=+g[h+16>>2];ja=+g[h+20>>2];ha=+g[h+24>>2];ka=+g[h+32>>2];ga=+g[h+36>>2];U=+g[h+40>>2];fa=+g[_+(pa*80|0)>>2];ea=+g[_+(pa*80|0)+16>>2];Z=+g[_+(pa*80|0)+32>>2];Y=+g[_+(pa*80|0)+4>>2];X=+g[_+(pa*80|0)+20>>2];W=+g[_+(pa*80|0)+36>>2];ia=+g[_+(pa*80|0)+8>>2];V=+g[_+(pa*80|0)+24>>2];T=+g[_+(pa*80|0)+40>>2];na=+g[_+(pa*80|0)+48>>2];ma=+g[_+(pa*80|0)+52>>2];Q=+g[_+(pa*80|0)+56>>2];S=+g[h+48>>2]+(oa*na+P*ma+O*Q);R=+g[h+52>>2]+(la*na+ja*ma+ha*Q);Q=+g[h+56>>2]+(ka*na+ga*ma+U*Q);g[da>>2]=oa*fa+P*ea+O*Z;g[da+4>>2]=oa*Y+P*X+O*W;g[da+8>>2]=oa*ia+P*V+O*T;g[da+12>>2]=0.0;g[da+16>>2]=la*fa+ja*ea+ha*Z;g[da+20>>2]=la*Y+ja*X+ha*W;g[da+24>>2]=la*ia+ja*V+ha*T;g[da+28>>2]=0.0;g[da+32>>2]=ka*fa+ga*ea+U*Z;g[da+36>>2]=ka*Y+ga*X+U*W;g[da+40>>2]=ka*ia+ga*V+U*T;g[da+44>>2]=0.0;g[da+48>>2]=S;g[da+52>>2]=R;g[da+56>>2]=Q;g[da+60>>2]=0.0;mc[c[(c[r>>2]|0)+8>>2]&127](r,da,da+112|0,da+96|0);r=c[(c[o+16>>2]|0)+(p*12|0)+4>>2]|0;h=c[ba+24>>2]|0;pa=c[h+(r*80|0)+64>>2]|0;_=c[e+12>>2]|0;Q=+g[_>>2];R=+g[_+4>>2];S=+g[_+8>>2];T=+g[_+16>>2];U=+g[_+20>>2];V=+g[_+24>>2];ga=+g[_+32>>2];ia=+g[_+36>>2];ka=+g[_+40>>2];W=+g[h+(r*80|0)>>2];X=+g[h+(r*80|0)+16>>2];Y=+g[h+(r*80|0)+32>>2];Z=+g[h+(r*80|0)+4>>2];ea=+g[h+(r*80|0)+20>>2];fa=+g[h+(r*80|0)+36>>2];ha=+g[h+(r*80|0)+8>>2];ja=+g[h+(r*80|0)+24>>2];la=+g[h+(r*80|0)+40>>2];O=+g[h+(r*80|0)+48>>2];P=+g[h+(r*80|0)+52>>2];oa=+g[h+(r*80|0)+56>>2];ma=+g[_+48>>2]+(Q*O+R*P+S*oa);na=+g[_+52>>2]+(T*O+U*P+V*oa);oa=+g[_+56>>2]+(ga*O+ia*P+ka*oa);g[da>>2]=Q*W+R*X+S*Y;g[da+4>>2]=Q*Z+R*ea+S*fa;g[da+8>>2]=Q*ha+R*ja+S*la;g[da+12>>2]=0.0;g[da+16>>2]=T*W+U*X+V*Y;g[da+20>>2]=T*Z+U*ea+V*fa;g[da+24>>2]=T*ha+U*ja+V*la;g[da+28>>2]=0.0;g[da+32>>2]=ga*W+ia*X+ka*Y;g[da+36>>2]=ga*Z+ia*ea+ka*fa;g[da+40>>2]=ga*ha+ia*ja+ka*la;g[da+44>>2]=0.0;g[da+48>>2]=ma;g[da+52>>2]=na;g[da+56>>2]=oa;g[da+60>>2]=0.0;mc[c[(c[pa>>2]|0)+8>>2]&127](pa,da,da+80|0,da+64|0);if(!(+g[da+112>>2]>+g[da+64>>2])?!(+g[da+96>>2]<+g[da+80>>2]):0)j=1;else j=0;if(!(!(+g[da+112+8>>2]>+g[da+64+8>>2])?!(+g[da+96+8>>2]<+g[da+80+8>>2]):0))j=0;if(!(+g[da+112+4>>2]>+g[da+64+4>>2])?!(+g[da+96+4>>2]<+g[da+80+4>>2]|j^1):0)break;Ab[c[c[k>>2]>>2]&255](k);n=c[b+4>>2]|0;Cb[c[(c[n>>2]|0)+60>>2]&127](n,k);n=c[o+16>>2]|0;m=c[n+(p*12|0)>>2]|0;n=c[n+(p*12|0)+4>>2]|0;j=c[b+16>>2]|0;if((j|0)==(c[b+20>>2]|0)?(ca=j|0?j<<1:1,(j|0)<(ca|0)):0){if(!ca)l=0;else{c[6435]=(c[6435]|0)+1;j=yc((ca*12|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}l=j;j=c[b+16>>2]|0}if((j|0)>0){k=0;do{pa=l+(k*12|0)|0;_=(c[b+24>>2]|0)+(k*12|0)|0;c[pa>>2]=c[_>>2];c[pa+4>>2]=c[_+4>>2];c[pa+8>>2]=c[_+8>>2];k=k+1|0}while((k|0)!=(j|0))}j=c[b+24>>2]|0;if(j|0){if(a[b+28>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[b+24>>2]=0}a[b+28>>0]=1;c[b+24>>2]=l;c[b+20>>2]=ca;j=c[b+16>>2]|0}pa=c[b+24>>2]|0;c[pa+(j*12|0)>>2]=m;c[pa+(j*12|0)+4>>2]=n;c[pa+(j*12|0)+8>>2]=0;c[b+16>>2]=(c[b+16>>2]|0)+1}while(0);p=p+1|0}while((p|0)<(c[o+8>>2]|0));k=b+24|0;l=b+16|0}else{k=b+24|0;l=b+16|0}if((c[l>>2]|0)>0){j=0;do{e=c[$>>2]|0;pa=c[k>>2]|0;Ob[c[(c[e>>2]|0)+8>>2]&63](e,c[pa+(j*12|0)>>2]|0,c[pa+(j*12|0)+4>>2]|0)|0;j=j+1|0}while((j|0)<(c[l>>2]|0))}j=c[k>>2]|0;if(!j){a[b+28>>0]=1;c[k>>2]=0;c[l>>2]=0;pa=b+20|0;c[pa>>2]=0;i=da;return}if(a[b+28>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[k>>2]=0;a[b+28>>0]=1;c[k>>2]=0;c[l>>2]=0;pa=b+20|0;c[pa>>2]=0;i=da;return}function Pc(b,e,f,h,j,l,m){b=b|0;e=e|0;f=f|0;h=h|0;j=j|0;l=l|0;m=m|0;var n=0.0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0;B=i;i=i+9856|0;q=l;r=q+36|0;do{c[q>>2]=0;q=q+4|0}while((q|0)<(r|0));c[B+9712>>2]=b;c[B+9712+4>>2]=f;E=+g[h>>2];R=+g[e>>2];F=+g[h+16>>2];H=+g[e+16>>2];G=+g[h+32>>2];S=+g[e+32>>2];I=+g[e+4>>2];T=+g[e+20>>2];J=+g[e+36>>2];s=+g[e+8>>2];n=+g[e+24>>2];D=+g[e+40>>2];Q=+g[h+4>>2];P=+g[h+20>>2];N=+g[h+36>>2];M=+g[h+8>>2];L=+g[h+24>>2];K=+g[h+40>>2];g[B+9712+8>>2]=E*R+F*H+G*S;g[B+9712+12>>2]=E*I+F*T+G*J;g[B+9712+16>>2]=E*s+F*n+G*D;g[B+9712+20>>2]=0.0;g[B+9712+24>>2]=R*Q+H*P+S*N;g[B+9712+28>>2]=I*Q+T*P+J*N;g[B+9712+32>>2]=s*Q+n*P+D*N;g[B+9712+36>>2]=0.0;g[B+9712+40>>2]=R*M+H*L+S*K;g[B+9712+44>>2]=I*M+T*L+J*K;g[B+9712+48>>2]=s*M+n*L+D*K;g[B+9712+52>>2]=0.0;D=+g[h+48>>2]-+g[e+48>>2];n=+g[h+52>>2]-+g[e+52>>2];s=+g[h+56>>2]-+g[e+56>>2];J=+g[e>>2];T=+g[h>>2];I=+g[e+16>>2];S=+g[h+16>>2];H=+g[e+32>>2];R=+g[h+32>>2];G=+g[e+4>>2];F=+g[e+20>>2];E=+g[e+36>>2];C=+g[e+8>>2];o=+g[e+24>>2];p=+g[e+40>>2];g[B+9712+56>>2]=J*T+I*S+H*R;g[B+9712+60>>2]=J*Q+I*P+H*N;g[B+9712+64>>2]=J*M+I*L+H*K;g[B+9712+68>>2]=0.0;g[B+9712+72>>2]=T*G+S*F+R*E;g[B+9712+76>>2]=Q*G+P*F+N*E;g[B+9712+80>>2]=M*G+L*F+K*E;g[B+9712+84>>2]=0.0;g[B+9712+88>>2]=T*C+S*o+R*p;g[B+9712+92>>2]=Q*C+P*o+N*p;g[B+9712+96>>2]=M*C+L*o+K*p;g[B+9712+100>>2]=0.0;g[B+9712+104>>2]=D*J+n*I+s*H;g[B+9712+108>>2]=D*G+n*F+s*E;g[B+9712+112>>2]=D*C+n*o+s*p;g[B+9712+116>>2]=0.0;c[B+9712+120>>2]=m?81:80;c[B+9712+124>>2]=0;c[B+9328+364>>2]=0;c[B+9328+128>>2]=0;c[B+9328+128+4>>2]=0;c[B+9328+128+8>>2]=0;c[B+9328+128+12>>2]=0;c[B+9328+376>>2]=2;c[B+9328+368>>2]=0;g[B+9328+144>>2]=0.0;p=-+g[j+4>>2];s=-+g[j+8>>2];g[B+16>>2]=-+g[j>>2];g[B+16+4>>2]=p;g[B+16+8>>2]=s;g[B+16+12>>2]=0.0;switch(Uc(B+9328|0,B+9712|0,B+16|0)|0){case 1:{w=B+32+9280|0;x=B+32+9288|0;y=B+32+9292|0;c[w>>2]=0;c[w+4>>2]=0;c[w+8>>2]=0;c[w+12>>2]=0;c[B+32>>2]=9;A=B+32+40|0;c[B+32+9276>>2]=0;c[A>>2]=0;c[A+4>>2]=0;c[A+8>>2]=0;c[A+12>>2]=0;c[A+16>>2]=0;m=0;do{b=128-m+-1|0;c[B+32+2108+(b*56|0)+44>>2]=0;f=c[x>>2]|0;c[B+32+2108+(b*56|0)+48>>2]=f;if(f|0)c[f+44>>2]=B+32+2108+(b*56|0);c[x>>2]=B+32+2108+(b*56|0);c[y>>2]=(c[y>>2]|0)+1;m=m+1|0}while((m|0)!=128);p=+g[j>>2];s=+g[j+4>>2];o=+g[j+8>>2];t=c[B+9328+372>>2]|0;do if((c[t+32>>2]|0)>>>0>1?y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+8>>2];n=+g[b+12>>2];u=c[b+16>>2]|0;U=c[b+20>>2]|0;f=c[b+24>>2]|0;m=c[b+28>>2]|0;a[h+52>>0]=0;c[h+32>>2]=q;a[q+52>>0]=0;c[q+32>>2]=h;a[h+53>>0]=0;c[h+36>>2]=r;a[r+52>>0]=1;c[r+32>>2]=h;a[h+54>>0]=0;c[h+40>>2]=j;a[j+52>>0]=2;c[j+32>>2]=h;a[q+53>>0]=2;c[q+36>>2]=j;a[j+54>>0]=1;c[j+40>>2]=q;a[q+54>>0]=1;c[q+40>>2]=r;a[r+53>>0]=2;c[r+36>>2]=q;a[r+54>>0]=1;c[r+40>>2]=j;a[j+53>>0]=2;c[j+36>>2]=r;c[B+32>>2]=0;t=b;r=U;j=f;q=m;b=u;u=0;while(1){f=c[B+32+9276>>2]|0;if(f>>>0>=64){z=43;break}c[B+9840>>2]=0;c[B+9840+4>>2]=0;c[B+9840+8>>2]=0;c[B+32+9276>>2]=f+1;u=u+1|0;a[t+55>>0]=u;h=t+4|0;U=t+8|0;Nh(B+9328|0,+g[t>>2],+g[h>>2],+g[U>>2],B+32+60+(f<<5)|0);if(+g[t>>2]*+g[B+32+60+(f<<5)+16>>2]+ +g[h>>2]*+g[B+32+60+(f<<5)+20>>2]+ +g[U>>2]*+g[B+32+60+(f<<5)+24>>2]-+g[t+16>>2]>9.999999747378752e-05)h=0;else{f=7;z=42;break}do{m=zh(B+32|0,u,B+32+60+(f<<5)|0,c[t+32+(h<<2)>>2]|0,d[t+52+h>>0]|0,B+9840|0)|0;h=h+1|0}while(m&h>>>0<3);if(!(m&(c[B+9840+8>>2]|0)>>>0>2)){f=4;z=42;break}m=c[B+9840>>2]|0;b=c[B+9840+4>>2]|0;a[m+53>>0]=2;c[m+36>>2]=b;a[b+54>>0]=1;c[b+40>>2]=m;b=t+44|0;m=t+48|0;f=c[m>>2]|0;if(f|0)c[f+44>>2]=c[b>>2];b=c[b>>2]|0;if(b|0)c[b+48>>2]=c[m>>2];if((c[v>>2]|0)==(t|0))c[v>>2]=c[m>>2];c[B+32+9284>>2]=(c[B+32+9284>>2]|0)+-1;c[t+44>>2]=0;c[m>>2]=c[x>>2];b=c[x>>2]|0;if(b|0)c[b+44>>2]=t;c[x>>2]=t;c[y>>2]=(c[y>>2]|0)+1;f=c[w>>2]|0;n=+g[f+16>>2];b=c[f+48>>2]|0;if(b){o=n*n;while(1){n=+g[b+16>>2];m=n*n>2]|0;if(!b)break;else o=m?n*n:o}}s=+g[f>>2];p=+g[f+4>>2];o=+g[f+8>>2];n=+g[f+12>>2];b=c[f+16>>2]|0;m=c[f+20>>2]|0;h=c[f+24>>2]|0;q=c[f+28>>2]|0;if(u>>>0>=255){f=q;break}else{t=f;r=m;j=h}}if((z|0)==42){c[B+32>>2]=f;m=r;h=j;f=q}else if((z|0)==43){c[B+32>>2]=6;m=r;h=j;f=q}R=(c[k>>2]=b,+g[k>>2]);P=s*R;M=p*R;R=o*R;g[B+32+40>>2]=s;g[B+32+44>>2]=p;g[B+32+48>>2]=o;g[B+32+52>>2]=n;c[B+32+56>>2]=b;c[B+32+36>>2]=3;c[B+32+4>>2]=m;c[B+32+8>>2]=h;c[B+32+12>>2]=f;U=h;Q=+g[U+16>>2]-P;K=+g[U+20>>2]-M;N=+g[U+24>>2]-R;y=f;J=+g[y+16>>2]-P;L=+g[y+20>>2]-M;S=+g[y+24>>2]-R;S=+O(+((Q*L-K*J)*(Q*L-K*J)+((K*S-N*L)*(K*S-N*L)+(N*J-Q*S)*(N*J-Q*S))));g[B+32+20>>2]=S;Q=+g[y+16>>2]-P;J=+g[y+20>>2]-M;N=+g[y+24>>2]-R;y=m;L=+g[y+16>>2]-P;K=+g[y+20>>2]-M;T=+g[y+24>>2]-R;T=+O(+((Q*K-J*L)*(Q*K-J*L)+((J*T-N*K)*(J*T-N*K)+(N*L-Q*T)*(N*L-Q*T))));g[B+32+24>>2]=T;Q=+g[y+16>>2]-P;L=+g[y+20>>2]-M;N=+g[y+24>>2]-R;P=+g[U+16>>2]-P;M=+g[U+20>>2]-M;R=+g[U+24>>2]-R;R=+O(+((Q*M-L*P)*(Q*M-L*P)+((L*R-N*M)*(L*R-N*M)+(N*P-Q*R)*(N*P-Q*R))));g[B+32+20>>2]=S/(R+(S+T));g[B+32+24>>2]=T/(R+(S+T));g[B+32+28>>2]=R/(R+(S+T));if((c[B+32>>2]|0)!=9)if(!(c[B+32+36>>2]|0)){p=0.0;o=0.0;n=0.0;break}else{h=B+32+36|0;z=51;break}c[l>>2]=3;U=0;i=B;return U|0}else z=45}else z=45;while(0);if((z|0)==45){c[B+32>>2]=8;g[B+32+40>>2]=p;g[B+32+44>>2]=s;g[B+32+48>>2]=o;g[B+32+52>>2]=0.0;n=+O(+(p*p+s*s+o*o));if(n>0.0){g[B+32+40>>2]=1.0/n*p;g[B+32+44>>2]=1.0/n*s;g[B+32+48>>2]=1.0/n*o}else{c[A>>2]=1065353216;c[B+32+44>>2]=0;c[B+32+48>>2]=0}g[B+32+52>>2]=0.0;g[B+32+56>>2]=0.0;c[B+32+36>>2]=1;c[B+32+4>>2]=c[t>>2];g[B+32+20>>2]=1.0;h=B+32+36|0;z=51}if((z|0)==51){m=0;p=0.0;o=0.0;n=0.0;do{b=c[B+9712+120>>2]|0;U=c[B+9712+124>>2]|0;f=(c[B+9712>>2]|0)+(U>>1)|0;if(U&1)b=c[(c[f>>2]|0)+b>>2]|0;ic[b&127](B,f,c[B+32+4+(m<<2)>>2]|0);T=+g[B+32+20+(m<<2)>>2];p=p+ +g[B>>2]*T;n=n+T*+g[B+4>>2];o=o+T*+g[B+8>>2];m=m+1|0}while(m>>>0<(c[h>>2]|0)>>>0)}c[l>>2]=1;T=p*+g[e+16>>2]+n*+g[e+20>>2]+o*+g[e+24>>2]+ +g[e+52>>2];Q=p*+g[e+32>>2]+n*+g[e+36>>2]+o*+g[e+40>>2]+ +g[e+56>>2];g[l+4>>2]=p*+g[e>>2]+n*+g[e+4>>2]+o*+g[e+8>>2]+ +g[e+48>>2];g[l+8>>2]=T;g[l+12>>2]=Q;g[l+16>>2]=0.0;Q=+g[A>>2];T=+g[B+32+56>>2];R=+g[B+32+44>>2];S=+g[B+32+48>>2];K=p-Q*T;L=n-T*R;M=o-T*S;N=K*+g[e+16>>2]+L*+g[e+20>>2]+M*+g[e+24>>2]+ +g[e+52>>2];P=K*+g[e+32>>2]+L*+g[e+36>>2]+M*+g[e+40>>2]+ +g[e+56>>2];g[l+20>>2]=K*+g[e>>2]+L*+g[e+4>>2]+M*+g[e+8>>2]+ +g[e+48>>2];g[l+24>>2]=N;g[l+28>>2]=P;g[l+32>>2]=0.0;g[l+36>>2]=-Q;g[l+40>>2]=-R;g[l+44>>2]=-S;g[l+48>>2]=0.0;g[l+52>>2]=-T;U=1;i=B;return U|0}case 2:{c[l>>2]=2;U=0;i=B;return U|0}default:{U=0;i=B;return U|0}}return 0}function Qc(b,d){b=b|0;d=+d;var e=0,f=0.0,h=0,j=0,k=0,l=0.0,m=0.0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,P=0.0,Q=0.0,R=0.0;r=i;i=i+144|0;o=c[b+136>>2]|0;if(!o){i=r;return}k=c[b+8>>2]|0;if((k|0)<(o|0)){if((c[b+12>>2]|0)<(o|0)){c[6435]=(c[6435]|0)+1;e=yc((o<<4|3)+16|0)|0;if(!e)j=0;else{c[(e+4+15&-16)+-4>>2]=e;j=e+4+15&-16}e=c[b+8>>2]|0;if((e|0)>0){h=0;do{n=j+(h<<4)|0;s=(c[b+16>>2]|0)+(h<<4)|0;c[n>>2]=c[s>>2];c[n+4>>2]=c[s+4>>2];c[n+8>>2]=c[s+8>>2];c[n+12>>2]=c[s+12>>2];h=h+1|0}while((h|0)!=(e|0))}e=c[b+16>>2]|0;if(e|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=j;c[b+12>>2]=o;h=b+16|0}else h=b+16|0;e=k;do{s=(c[h>>2]|0)+(e<<4)|0;c[s>>2]=c[r+80>>2];c[s+4>>2]=c[r+80+4>>2];c[s+8>>2]=c[r+80+8>>2];c[s+12>>2]=c[r+80+12>>2];e=e+1|0}while((e|0)!=(o|0))}c[b+8>>2]=o;k=c[b+28>>2]|0;if((k|0)<(o|0)){if((c[b+32>>2]|0)<(o|0)){c[6435]=(c[6435]|0)+1;e=yc((o<<4|3)+16|0)|0;if(!e)j=0;else{c[(e+4+15&-16)+-4>>2]=e;j=e+4+15&-16}e=c[b+28>>2]|0;if((e|0)>0){h=0;do{s=j+(h<<4)|0;n=(c[b+36>>2]|0)+(h<<4)|0;c[s>>2]=c[n>>2];c[s+4>>2]=c[n+4>>2];c[s+8>>2]=c[n+8>>2];c[s+12>>2]=c[n+12>>2];h=h+1|0}while((h|0)!=(e|0))}e=c[b+36>>2]|0;if(e|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=j;c[b+32>>2]=o;h=b+36|0}else h=b+36|0;e=k;do{s=(c[h>>2]|0)+(e<<4)|0;c[s>>2]=c[r+64>>2];c[s+4>>2]=c[r+64+4>>2];c[s+8>>2]=c[r+64+8>>2];c[s+12>>2]=c[r+64+12>>2];e=e+1|0}while((e|0)!=(o|0))}c[b+28>>2]=o;n=c[b+48>>2]|0;if((n|0)<(o|0)){do if((c[b+52>>2]|0)<(o|0)){c[6435]=(c[6435]|0)+1;e=yc((o<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=c[b+48>>2]|0;j=c[b+56>>2]|0;if((h|0)<=0){if(!j){a[b+60>>0]=1;c[b+56>>2]=e;c[b+52>>2]=o;h=o<<2;break}}else{k=0;do{c[e+(k<<2)>>2]=c[j+(k<<2)>>2];k=k+1|0}while((k|0)!=(h|0))}if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}a[b+60>>0]=1;c[b+56>>2]=e;c[b+52>>2]=o;h=o<<2}else{h=o<<2;e=c[b+56>>2]|0}while(0);Qn(e+(n<<2)|0,0,h-(n<<2)|0)|0}c[b+48>>2]=o;n=c[b+68>>2]|0;if((n|0)<(o|0)){do if((c[b+72>>2]|0)<(o|0)){c[6435]=(c[6435]|0)+1;e=yc((o<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}h=c[b+68>>2]|0;j=c[b+76>>2]|0;if((h|0)<=0){if(!j){a[b+80>>0]=1;c[b+76>>2]=e;c[b+72>>2]=o;h=o<<2;break}}else{k=0;do{c[e+(k<<2)>>2]=c[j+(k<<2)>>2];k=k+1|0}while((k|0)!=(h|0))}if(a[b+80>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}a[b+80>>0]=1;c[b+76>>2]=e;c[b+72>>2]=o;h=o<<2}else{h=o<<2;e=c[b+76>>2]|0}while(0);Qn(e+(n<<2)|0,0,h-(n<<2)|0)|0}c[b+68>>2]=o;e=c[b+136>>2]|0;if((e|0)<=0){i=r;return}h=c[b+76>>2]|0;j=c[b+56>>2]|0;k=0;do{g[h+(k<<2)>>2]=0.0;g[j+(k<<2)>>2]=0.0;k=k+1|0}while((k|0)!=(e|0));k=0;do{h=c[b+144>>2]|0;j=c[h+(k*284|0)+88>>2]|0;if(j){e=h+(k*284|0)+92|0;c[r+96>>2]=c[e>>2];c[r+96+4>>2]=c[e+4>>2];c[r+96+8>>2]=c[e+8>>2];c[r+96+12>>2]=c[e+12>>2];e=h+(k*284|0)+108|0;c[r+96+16>>2]=c[e>>2];c[r+96+16+4>>2]=c[e+4>>2];c[r+96+16+8>>2]=c[e+8>>2];c[r+96+16+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];I=E-+g[e+56>>2];J=+g[h+(k*284|0)+24>>2];L=J-+g[e+60>>2];C=C-+g[j+52>>2];E=E-+g[j+56>>2];J=J-+g[j+60>>2];F=+g[e+332>>2];M=+g[e+336>>2];H=+g[e+328>>2];B=+g[j+332>>2];K=+g[j+336>>2];D=+g[j+328>>2];A=(m*I-l*L)*+g[e+4>>2]+(f*L-m*G)*+g[e+20>>2]+(l*G-f*I)*+g[e+36>>2];t=(m*I-l*L)*+g[e+8>>2]+(f*L-m*G)*+g[e+24>>2]+(l*G-f*I)*+g[e+40>>2];u=(m*I-l*L)*+g[e+12>>2]+(f*L-m*G)*+g[e+28>>2]+(l*G-f*I)*+g[e+44>>2];v=(E*-m-J*-l)*+g[j+4>>2]+(J*-f-C*-m)*+g[j+20>>2]+(C*-l-E*-f)*+g[j+36>>2];w=(E*-m-J*-l)*+g[j+8>>2]+(J*-f-C*-m)*+g[j+24>>2]+(C*-l-E*-f)*+g[j+40>>2];z=(E*-m-J*-l)*+g[j+12>>2]+(J*-f-C*-m)*+g[j+28>>2]+(C*-l-E*-f)*+g[j+44>>2];f=(f*(L*F-I*M+ +g[e+312>>2]-(J*B-E*K+ +g[j+312>>2]))+l*(+g[e+316>>2]+(G*M-L*H)-(+g[j+316>>2]+(C*K-J*D)))+m*(I*H-G*F+ +g[e+320>>2]-(E*D-C*B+ +g[j+320>>2])))*-.20000000298023224*(1.0/(+g[j+344>>2]+(+g[e+344>>2]+(A*A*+g[e+396>>2]+t*t*+g[e+400>>2]+u*u*+g[e+404>>2]))+(v*v*+g[j+396>>2]+w*w*+g[j+400>>2]+z*z*+g[j+404>>2])))}g[(c[b+76>>2]|0)+(k<<2)>>2]=f;e=c[b+136>>2]|0}k=k+1|0}while((k|0)<(e|0));if((e|0)<=0){i=r;return}h=c[b+144>>2]|0;j=0;o=0;while(1){e=c[h+(o*284|0)+88>>2]|0;if(e){f=+g[h+(o*284|0)+252>>2];if(f!=0.0){k=h;f=f*d}else{M=+g[h+(o*284|0)+256>>2];M=M==0.0?0.0:M;k=c[b+116>>2]|0;y=c[b+16>>2]|0;G=+g[h+(o*284|0)+16>>2];E=+g[h+(o*284|0)+20>>2];A=+g[h+(o*284|0)+24>>2];w=+g[y+(o<<4)>>2];D=+g[y+(o<<4)+4>>2];f=+g[y+(o<<4)+8>>2];P=G-+g[k+52>>2];Q=E-+g[k+56>>2];l=A-+g[k+60>>2];m=+g[k+264>>2]*(Q*f-l*D)+ +g[k+280>>2]*(l*w-P*f)+(P*D-Q*w)*+g[k+296>>2];R=(Q*f-l*D)*+g[k+268>>2]+(l*w-P*f)*+g[k+284>>2]+(P*D-Q*w)*+g[k+300>>2];N=(Q*f-l*D)*+g[k+272>>2]+(l*w-P*f)*+g[k+288>>2]+(P*D-Q*w)*+g[k+304>>2];K=G-+g[e+52>>2];I=E-+g[e+56>>2];C=A-+g[e+60>>2];v=(D*K-w*I)*+g[e+296>>2]+(+g[e+264>>2]*(f*I-D*C)+ +g[e+280>>2]*(w*C-f*K));t=(f*I-D*C)*+g[e+268>>2]+(w*C-f*K)*+g[e+284>>2]+(D*K-w*I)*+g[e+300>>2];u=(f*I-D*C)*+g[e+272>>2]+(w*C-f*K)*+g[e+288>>2]+(D*K-w*I)*+g[e+304>>2];G=G-+g[k+52>>2];E=E-+g[k+56>>2];A=A-+g[k+60>>2];H=+g[k+332>>2];z=+g[k+336>>2];F=+g[k+328>>2];L=+g[e+332>>2];B=+g[e+336>>2];J=+g[e+328>>2];f=-(1.0/(+g[k+344>>2]+(f*(Q*m-P*R)+(w*(l*R-Q*N)+D*(P*N-l*m)))+(+g[e+344>>2]+(f*(I*v-K*t)+(w*(C*t-I*u)+D*(K*u-C*v)))))*((A*H-E*z+ +g[k+312>>2]-(C*L-I*B+ +g[e+312>>2]))*w+(+g[k+316>>2]+(G*z-A*F)-(+g[e+316>>2]+(K*B-C*J)))*D+(E*F-G*H+ +g[k+320>>2]-(I*J-K*L+ +g[e+320>>2]))*f));f=M>2]|0;f=f<-M?-M:f}n=c[b+56>>2]|0;y=n+(o<<2)|0;g[y>>2]=0.0;e=k+(o*284|0)+280|0;g[e>>2]=1.0;m=+g[h+(o*284|0)+276>>2]*d*+g[h+(o*284|0)+228>>2];g[y>>2]=f;f=f*.5;l=+g[(c[b+76>>2]|0)+(o<<2)>>2];if(f*f+l*l>m*m){R=m/+O(+(f*f+l*l));g[e>>2]=R*+g[e>>2];e=1}else e=j}else{n=c[b+56>>2]|0;g[n+(o<<2)>>2]=0.0;g[h+(o*284|0)+280>>2]=1.0;k=h;e=j}o=o+1|0;j=c[b+136>>2]|0;if((o|0)>=(j|0))break;else{h=k;j=e}}if(e){if((j|0)<=0){i=r;return}e=c[b+76>>2]|0;h=0;do{if(+g[e+(h<<2)>>2]!=0.0?(p=k+(h*284|0)+280|0,q=+g[p>>2],q<1.0):0){y=n+(h<<2)|0;g[y>>2]=q*+g[y>>2];y=(c[b+76>>2]|0)+(h<<2)|0;g[y>>2]=+g[p>>2]*+g[y>>2]}h=h+1|0}while((h|0)!=(j|0))}if((j|0)<=0){i=r;return}j=n;e=0;while(1){h=c[b+116>>2]|0;n=k+(e*284|0)+16|0;l=+g[n>>2]-+g[h+52>>2];o=k+(e*284|0)+20|0;m=+g[o>>2]-+g[h+56>>2];p=k+(e*284|0)+24|0;d=+g[p>>2]-+g[h+60>>2];g[r+96>>2]=l;g[r+96+4>>2]=m;g[r+96+8>>2]=d;g[r+96+12>>2]=0.0;f=+g[j+(e<<2)>>2];if(f!=0.0){y=c[b+16>>2]|0;Q=f*+g[y+(e<<4)+4>>2];R=f*+g[y+(e<<4)+8>>2];g[r+16>>2]=f*+g[y+(e<<4)>>2];g[r+16+4>>2]=Q;g[r+16+8>>2]=R;g[r+16+12>>2]=0.0;gj(h,r+16|0,r+96|0)}f=+g[(c[b+76>>2]|0)+(e<<2)>>2];if(f!=0.0){y=c[(c[b+144>>2]|0)+(e*284|0)+88>>2]|0;Q=+g[o>>2]-+g[y+56>>2];P=+g[p>>2]-+g[y+60>>2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=z<0.0?~~(1.0-z):0;J=~~((z+ +(F|0)-+(~~(z+ +(F|0))|0))*3.0);r=(z+ +(F|0)-+(~~(z+ +(F|0))|0))*3.0-+(J|0);F=~~(z+ +(F|0))-F|0;z=A*(B*+g[L+4>>2]+o*+g[L+20>>2]+C*+g[L+36>>2])/3.0;D=z<0.0?~~(1.0-z):0;G=~~((z+ +(D|0)-+(~~(z+ +(D|0))|0))*3.0);n=(z+ +(D|0)-+(~~(z+ +(D|0))|0))*3.0-+(G|0);D=~~(z+ +(D|0))-D|0;C=A*(B*+g[L+8>>2]+o*+g[L+24>>2]+C*+g[L+40>>2])/3.0;E=C<0.0?~~(1.0-C):0;H=~~((C+ +(E|0)-+(~~(C+ +(E|0))|0))*3.0);o=(C+ +(E|0)-+(~~(C+ +(E|0))|0))*3.0-+(H|0);E=~~(C+ +(E|0))-E|0;p=(F>>>16<<11^(F&65535)+16^(F&65535)+16<<16)+(D&65535)+((F>>>16<<11^(F&65535)+16^(F&65535)+16<<16)>>>11)|0;p=(p^D>>>16<<11^p<<16)+(E&65535)+((p^D>>>16<<11^p<<16)>>>11)|0;p=(p^E>>>16<<11^p<<16)+(u&65535)+((p^E>>>16<<11^p<<16)>>>11)|0;p=((p^u>>>16<<11^p<<16)>>>11)+(p^u>>>16<<11^p<<16)|0;p=((p<<3^p)>>>5)+(p<<3^p)<<4^((p<<3^p)>>>5)+(p<<3^p);p=(((p>>>17)+p<<25^(p>>>17)+p)>>>6)+((p>>>17)+p<<25^(p>>>17)+p)|0;q=c[I+60>>2]|0;t=c[I+68>>2]|0;d=c[t+(((p>>>0)%(q>>>0)|0)<<2)>>2]|0;c[I+96>>2]=(c[I+96>>2]|0)+1;e=(c[I+92>>2]|0)+1|0;c[I+92>>2]=e;a:do if(!d)w=9;else while(1){if(((((c[d+272>>2]|0)==(p|0)?(c[d+256>>2]|0)==(F|0):0)?(c[d+260>>2]|0)==(D|0):0)?(c[d+264>>2]|0)==(E|0):0)?(c[d+276>>2]|0)==(u|0):0)break a;d=c[d+280>>2]|0;e=e+1|0;c[I+92>>2]=e;if(!d){w=9;break}}while(0);if((w|0)==9){f=c[I+84>>2]|0;c[I+84>>2]=f+1;if((f|0)>=(c[I+88>>2]|0)){c[5789]=(c[5789]|0)+1;b:do if((q|0)>0){e=t;f=0;while(1){e=e+(f<<2)|0;d=c[e>>2]|0;c[e>>2]=0;if(d|0)do{e=d;d=c[d+280>>2]|0;hd(e)}while((d|0)!=0);d=f+1|0;if((d|0)==(q|0))break b;e=c[I+68>>2]|0;f=d}}while(0);g[I+76>>2]=.25;c[I+80>>2]=0;c[I+84>>2]=0;c[I+92>>2]=1;c[I+96>>2]=1}while(1){d=yc(284)|0;if(d|0)break;d=c[6564]|0;c[6564]=d+0;if(!d){w=19;break}jc[d&3]()}if((w|0)==19){P=Ya(4)|0;c[P>>2]=9640;pb(P|0,2800,251)}Qn(d|0,0,284)|0;c[d+280>>2]=c[t+(((p>>>0)%(q>>>0)|0)<<2)>>2];c[t+(((p>>>0)%(q>>>0)|0)<<2)>>2]=d;c[d+276>>2]=u;c[d+272>>2]=p;c[d+256>>2]=F;c[d+260>>2]=D;c[d+264>>2]=E;l=+g[I+76>>2];q=P+168+4|0;t=P+168+24|0;u=P+168+44|0;h=l;e=0;while(1){k=l*+(E|0)*3.0+ +(e|0)*h;p=0;while(1){j=l*+(D|0)*3.0+ +(p|0)*h;g[P+96>>2]=+(F|0)*3.0*l+h*0.0;g[P+96+4>>2]=j;g[P+96+8>>2]=k;g[P+96+12>>2]=0.0;f=c[d+276>>2]|0;c[P+168>>2]=1065353216;c[q>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;c[P+168+20>>2]=1065353216;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;c[P+168+40>>2]=1065353216;c[u>>2]=0;c[u+4>>2]=0;c[u+8>>2]=0;c[u+12>>2]=0;c[u+16>>2]=0;if((c[f+4>>2]|0)<20)h=+ed(P+96|0,f,P+168|0,P+112|0);else h=0.0;g[d+(p<<4)+(e<<2)>>2]=h;g[P+96>>2]=+(F|0)*3.0*l+ +g[I+76>>2];g[P+96+4>>2]=j;g[P+96+8>>2]=k;g[P+96+12>>2]=0.0;f=c[d+276>>2]|0;c[P+168>>2]=1065353216;c[q>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;c[P+168+20>>2]=1065353216;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;c[P+168+40>>2]=1065353216;c[u>>2]=0;c[u+4>>2]=0;c[u+8>>2]=0;c[u+12>>2]=0;c[u+16>>2]=0;if((c[f+4>>2]|0)<20)h=+ed(P+96|0,f,P+168|0,P+112|0);else h=0.0;g[d+64+(p<<4)+(e<<2)>>2]=h;g[P+96>>2]=+(F|0)*3.0*l+ +g[I+76>>2]*2.0;g[P+96+4>>2]=j;g[P+96+8>>2]=k;g[P+96+12>>2]=0.0;f=c[d+276>>2]|0;c[P+168>>2]=1065353216;c[q>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;c[P+168+20>>2]=1065353216;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;c[P+168+40>>2]=1065353216;c[u>>2]=0;c[u+4>>2]=0;c[u+8>>2]=0;c[u+12>>2]=0;c[u+16>>2]=0;if((c[f+4>>2]|0)<20)h=+ed(P+96|0,f,P+168|0,P+112|0);else h=0.0;g[d+128+(p<<4)+(e<<2)>>2]=h;g[P+96>>2]=+(F|0)*3.0*l+ +g[I+76>>2]*3.0;g[P+96+4>>2]=j;g[P+96+8>>2]=k;g[P+96+12>>2]=0.0;f=c[d+276>>2]|0;c[P+168>>2]=1065353216;c[q>>2]=0;c[q+4>>2]=0;c[q+8>>2]=0;c[q+12>>2]=0;c[P+168+20>>2]=1065353216;c[t>>2]=0;c[t+4>>2]=0;c[t+8>>2]=0;c[t+12>>2]=0;c[P+168+40>>2]=1065353216;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0;if(!d)r=0.0;else r=+g[d+344>>2];if(!(s+r>0.0)){i=P;return}if(!d)d=c[(c[b+8>>2]|0)+8>>2]|0;if((a[22528]|0)==0?Wa(22528)|0:0){e=23160;f=e+48|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(f|0));_a(22528)}e=c[b+12>>2]|0;m=+g[M+8>>2];x=m-+g[d+52>>2];n=+g[M+12>>2];y=n-+g[d+56>>2];o=+g[M+16>>2];v=o-+g[d+60>>2];if(!e){L=c[b+4>>2]|0;d=L;h=+g[L+452>>2];j=0.0;k=0.0;l=0.0}else{Q=+g[e+332>>2];k=+g[e+336>>2];R=+g[e+328>>2];d=c[b+4>>2]|0;l=+g[d+452>>2];h=l;j=(Q*v-k*y+ +g[e+312>>2])*l;k=(+g[e+316>>2]+(k*x-v*R))*l;l=(y*R-Q*x+ +g[e+320>>2])*l}m=m-+g[M+24>>2]-j;Q=n-+g[M+28>>2]-k;R=o-+g[M+32>>2]-l;j=+g[d+316>>2]*+g[(c[(c[b+8>>2]|0)+8>>2]|0)+224>>2];Pf(P,h,s,r,(e|0)==0?23160:e+264|0,x,y,v);c[P+80>>2]=c[P>>2];c[P+80+4>>2]=c[P+4>>2];c[P+80+8>>2]=c[P+8>>2];c[P+80+12>>2]=c[P+12>>2];c[P+64>>2]=c[P+16>>2];c[P+64+4>>2]=c[P+16+4>>2];c[P+64+8>>2]=c[P+16+8>>2];c[P+64+12>>2]=c[P+16+12>>2];c[P+48>>2]=c[P+32>>2];c[P+48+4>>2]=c[P+32+4>>2];c[P+48+8>>2]=c[P+32+8>>2];c[P+48+12>>2]=c[P+32+12>>2];q=c[b+4>>2]|0;h=s*+g[q+452>>2];j=(R-A*(m*B+Q*C+R*A))*(R-A*(m*B+Q*C+R*A))+((m-B*(m*B+Q*C+R*A))*(m-B*(m*B+Q*C+R*A))+(Q-C*(m*B+Q*C+R*A))*(Q-C*(m*B+Q*C+R*A)))>2]|0)+8>>2]|0)+204>>2]&3|0?q+328|0:q+324|0)>>2]|0;d=c[q+812>>2]|0;if((d|0)==(c[q+816>>2]|0)?(N=d|0?d<<1:1,(d|0)<(N|0)):0){if(!N)f=0;else{c[6435]=(c[6435]|0)+1;d=yc((N*104|3)+16|0)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}f=d;d=c[q+812>>2]|0}if((d|0)>0){e=0;do{L=f+(e*104|0)|0;K=c[q+820>>2]|0;J=K+(e*104|0)|0;c[L>>2]=c[J>>2];c[L+4>>2]=c[J+4>>2];c[L+8>>2]=c[J+8>>2];c[L+12>>2]=c[J+12>>2];c[L+16>>2]=c[J+16>>2];c[L+20>>2]=c[J+20>>2];c[L+24>>2]=c[J+24>>2];L=f+(e*104|0)+28|0;J=K+(e*104|0)+28|0;c[L>>2]=c[J>>2];c[L+4>>2]=c[J+4>>2];c[L+8>>2]=c[J+8>>2];c[L+12>>2]=c[J+12>>2];L=f+(e*104|0)+44|0;J=K+(e*104|0)+44|0;c[L>>2]=c[J>>2];c[L+4>>2]=c[J+4>>2];c[L+8>>2]=c[J+8>>2];c[L+12>>2]=c[J+12>>2];L=f+(e*104|0)+60|0;J=K+(e*104|0)+60|0;c[L>>2]=c[J>>2];c[L+4>>2]=c[J+4>>2];c[L+8>>2]=c[J+8>>2];c[L+12>>2]=c[J+12>>2];L=f+(e*104|0)+76|0;K=K+(e*104|0)+76|0;c[L>>2]=c[K>>2];c[L+4>>2]=c[K+4>>2];c[L+8>>2]=c[K+8>>2];c[L+12>>2]=c[K+12>>2];c[L+16>>2]=c[K+16>>2];c[L+20>>2]=c[K+20>>2];c[L+24>>2]=c[K+24>>2];e=e+1|0}while((e|0)!=(d|0))}d=c[q+820>>2]|0;if(d|0){if(a[q+824>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[q+820>>2]=0}a[q+824>>0]=1;c[q+820>>2]=f;c[q+816>>2]=N;d=c[q+812>>2]|0}L=c[q+820>>2]|0;c[L+(d*104|0)>>2]=t;g[L+(d*104|0)+4>>2]=B;g[L+(d*104|0)+8>>2]=C;g[L+(d*104|0)+12>>2]=A;g[L+(d*104|0)+16>>2]=0.0;g[L+(d*104|0)+20>>2]=z;c[L+(d*104|0)+24>>2]=M;N=L+(d*104|0)+28|0;c[N>>2]=c[P+80>>2];c[N+4>>2]=c[P+80+4>>2];c[N+8>>2]=c[P+80+8>>2];c[N+12>>2]=c[P+80+12>>2];N=L+(d*104|0)+44|0;c[N>>2]=c[P+64>>2];c[N+4>>2]=c[P+64+4>>2];c[N+8>>2]=c[P+64+8>>2];c[N+12>>2]=c[P+64+12>>2];N=L+(d*104|0)+60|0;c[N>>2]=c[P+48>>2];c[N+4>>2]=c[P+48+4>>2];c[N+8>>2]=c[P+48+8>>2];c[N+12>>2]=c[P+48+12>>2];N=L+(d*104|0)+76|0;g[N>>2]=x;g[L+(d*104|0)+80>>2]=y;g[L+(d*104|0)+84>>2]=v;g[L+(d*104|0)+88>>2]=0.0;g[N+16>>2]=h;g[N+20>>2]=j;c[N+24>>2]=p;c[q+812>>2]=(c[q+812>>2]|0)+1;d=c[b+12>>2]|0;if(!d){i=P;return}if(c[d+204>>2]&3|0){i=P;return}if((c[d+216>>2]&-2|0)!=4)c[d+216>>2]=1;g[d+220>>2]=0.0;i=P;return} +function nc(d,f){d=d|0;f=f|0;var h=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0,H=0.0,I=0.0,J=0,K=0,L=0,M=0,P=0,Q=0,R=0,S=0,T=0,U=0.0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0.0,fa=0.0,ga=0,ha=0;da=i;i=i+288|0;h=c[d+52>>2]|0;if(h|0?(Ab[c[c[h>>2]>>2]&255](h),j=c[d+52>>2]|0,j|0):0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[6435]=(c[6435]|0)+1;h=yc(151)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[h>>2]=9352;a[h+20>>0]=1;c[h+16>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;a[h+40>>0]=1;c[h+36>>2]=0;c[h+28>>2]=0;c[h+32>>2]=0;a[h+60>>0]=1;c[h+56>>2]=0;c[h+48>>2]=0;c[h+52>>2]=0;c[d+52>>2]=h;o=0;n=0;ca=0;J=0;while(1){if((o|0)>=(Eb[c[(c[d>>2]|0)+96>>2]&127](d)|0))break;do if((J|0)==(n|0)){l=n|0?n<<1:1;if((n|0)<(l|0)){if((l|0)!=0?(c[6435]=(c[6435]|0)+1,p=yc((l<<4|3)+16|0)|0,(p|0)!=0):0){c[(p+4+15&-16)+-4>>2]=p;h=p+4+15&-16}else h=0;if((n|0)<=0){if(!ca){m=n;j=l;break}}else{j=0;do{ba=h+(j<<4)|0;aa=ca+(j<<4)|0;c[ba>>2]=c[aa>>2];c[ba+4>>2]=c[aa+4>>2];c[ba+8>>2]=c[aa+8>>2];c[ba+12>>2]=c[aa+12>>2];j=j+1|0}while((j|0)!=(n|0))}c[6436]=(c[6436]|0)+1;hd(c[ca+-4>>2]|0);m=n;j=l}else{m=n;j=n;h=ca}}else{m=J;j=n;h=ca}while(0);n=h+(J<<4)|0;c[n>>2]=c[da+192>>2];c[n+4>>2]=c[da+192+4>>2];c[n+8>>2]=c[da+192+8>>2];c[n+12>>2]=c[da+192+12>>2];ic[c[(c[d>>2]|0)+108>>2]&127](d,o,n);o=o+1|0;n=j;ca=h;J=m+1|0}a[da+128+16>>0]=1;ba=da+128+12|0;c[ba>>2]=0;c[da+128+4>>2]=0;c[da+128+8>>2]=0;a[da+128+36>>0]=1;aa=da+128+32|0;c[aa>>2]=0;c[da+128+24>>2]=0;c[da+128+28>>2]=0;a[da+128+56>>0]=1;$=da+128+52|0;c[$>>2]=0;c[da+128+44>>2]=0;c[da+128+48>>2]=0;if(f){if((J|0)>0){G=0;j=0;m=0;l=0;while(1){h=G;G=G+1|0;if((G|0)<(J|0)){C=ca+(h<<4)|0;D=ca+(h<<4)+4|0;A=ca+(h<<4)+8|0;B=G;h=l;do{l=B;B=B+1|0;if((B|0)<(J|0)){y=ca+(l<<4)|0;z=ca+(l<<4)+4|0;f=ca+(l<<4)+8|0;w=B;do{E=+g[C>>2];I=+g[y>>2]-E;F=+g[D>>2];v=+g[z>>2]-F;H=+g[A>>2];x=+g[f>>2]-H;E=+g[ca+(w<<4)>>2]-E;F=+g[ca+(w<<4)+4>>2]-F;H=+g[ca+(w<<4)+8>>2]-H;q=1.0;p=0;while(1){t=(v*H-x*F)*q;u=(x*E-I*H)*q;r=(I*F-v*E)*q;a:do if(r*r+(t*t+u*u)>9.999999747378752e-05){s=1.0/+O(+(r*r+(t*t+u*u)));if((h|0)>0){l=0;do{if(t*s*+g[m+(l<<4)>>2]+u*s*+g[m+(l<<4)+4>>2]+r*s*+g[m+(l<<4)+8>>2]>.9990000128746033)break a;l=l+1|0}while((l|0)<(h|0))}q=t*s*+g[C>>2]+u*s*+g[D>>2]+r*s*+g[A>>2];l=0;do{if(t*s*+g[ca+(l<<4)>>2]+u*s*+g[ca+(l<<4)+4>>2]+r*s*+g[ca+(l<<4)+8>>2]-q+-.009999999776482582>0.0)break a;l=l+1|0}while((l|0)<(J|0));do if((h|0)==(j|0)){o=j|0?j<<1:1;if((j|0)<(o|0)){do if(!o)n=0;else{c[6435]=(c[6435]|0)+1;l=yc((o<<4|3)+16|0)|0;if(!l){n=0;break}c[(l+4+15&-16)+-4>>2]=l;n=l+4+15&-16}while(0);if((j|0)<=0){if(!m){l=j;j=o;m=n;break}}else{l=0;do{Y=n+(l<<4)|0;X=m+(l<<4)|0;c[Y>>2]=c[X>>2];c[Y+4>>2]=c[X+4>>2];c[Y+8>>2]=c[X+8>>2];c[Y+12>>2]=c[X+12>>2];l=l+1|0}while((l|0)!=(j|0))}c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0);l=j;j=o;m=n}else l=j}else l=h;while(0);g[m+(l<<4)>>2]=t*s;g[m+(l<<4)+4>>2]=u*s;g[m+(l<<4)+8>>2]=r*s;g[m+(l<<4)+12>>2]=-q;h=h+1|0}while(0);p=p+1|0;if((p|0)==2)break;else q=-1.0}w=w+1|0}while((w|0)!=(J|0))}}while((B|0)!=(J|0))}else h=l;if((G|0)==(J|0))break;else l=h}if((h|0)>0){o=0;p=0;f=0;while(1){Y=m+(f<<4)|0;c[da+208>>2]=c[Y>>2];c[da+208+4>>2]=c[Y+4>>2];c[da+208+8>>2]=c[Y+8>>2];q=+g[m+(f<<4)+12>>2];q=q-+Sb[c[(c[d>>2]|0)+48>>2]&15](d);do if((f|0)==(o|0)){n=o|0?o<<1:1;if((o|0)<(n|0)){if((n|0)!=0?(c[6435]=(c[6435]|0)+1,K=yc((n<<4|3)+16|0)|0,(K|0)!=0):0){c[(K+4+15&-16)+-4>>2]=K;l=K+4+15&-16}else l=0;if((o|0)<=0){if(!p){j=o;break}}else{j=0;do{Y=l+(j<<4)|0;X=p+(j<<4)|0;c[Y>>2]=c[X>>2];c[Y+4>>2]=c[X+4>>2];c[Y+8>>2]=c[X+8>>2];c[Y+12>>2]=c[X+12>>2];j=j+1|0}while((j|0)!=(o|0))}c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0);j=o}else{j=o;n=o;l=p}}else{j=f;n=o;l=p}while(0);Y=l+(j<<4)|0;c[Y>>2]=c[da+208>>2];c[Y+4>>2]=c[da+208+4>>2];c[Y+8>>2]=c[da+208+8>>2];g[l+(j<<4)+12>>2]=q;f=f+1|0;if((f|0)<(h|0)){o=n;p=l}else break}if((f|0)>0){C=0;n=0;j=0;h=0;do{A=C;C=C+1|0;if((C|0)<(f|0)){B=C;do{y=B;B=B+1|0;if((B|0)<(f|0)){z=B;do{t=+g[l+(y<<4)+4>>2];q=+g[l+(z<<4)+8>>2];r=+g[l+(y<<4)+8>>2];u=+g[l+(z<<4)+4>>2];v=+g[l+(z<<4)>>2];x=+g[l+(y<<4)>>2];s=+g[l+(A<<4)+8>>2];E=+g[l+(A<<4)+4>>2];F=+g[l+(A<<4)>>2];b:do if((((u*x-t*v)*(u*x-t*v)+((t*q-r*u)*(t*q-r*u)+(r*v-q*x)*(r*v-q*x))>9.999999747378752e-05?(v*E-u*F)*(v*E-u*F)+((u*s-q*E)*(u*s-q*E)+(q*F-v*s)*(q*F-v*s))>9.999999747378752e-05:0)?(t*F-x*E)*(t*F-x*E)+((r*E-t*s)*(r*E-t*s)+(x*s-r*F)*(x*s-r*F))>9.999999747378752e-05:0)?(U=s*(u*x-t*v)+(E*(r*v-q*x)+(t*q-r*u)*F),+N(+U)>9.999999974752427e-07):0){ea=+g[l+(A<<4)+12>>2];I=+g[l+(y<<4)+12>>2];fa=+g[l+(z<<4)+12>>2];H=-1.0/U*((r*E-t*s)*fa+((t*q-r*u)*ea+(u*s-q*E)*I));r=-1.0/U*((x*s-r*F)*fa+((r*v-q*x)*ea+(q*F-v*s)*I));q=-1.0/U*((t*F-x*E)*fa+((u*x-t*v)*ea+(v*E-u*F)*I));o=0;do{if(+g[l+(o<<4)+12>>2]+(H*+g[l+(o<<4)>>2]+r*+g[l+(o<<4)+4>>2]+q*+g[l+(o<<4)+8>>2])+-.009999999776482582>0.0)break b;o=o+1|0}while((o|0)<(f|0));do if((h|0)==(n|0)){w=n|0?n<<1:1;if((n|0)>=(w|0)){o=n;break}do if(!w)p=0;else{c[6435]=(c[6435]|0)+1;o=yc((w<<4|3)+16|0)|0;if(!o){p=0;break}c[(o+4+15&-16)+-4>>2]=o;p=o+4+15&-16}while(0);if((n|0)<=0){if(!j){o=n;n=w;j=p;break}}else{o=0;do{Y=p+(o<<4)|0;X=j+(o<<4)|0;c[Y>>2]=c[X>>2];c[Y+4>>2]=c[X+4>>2];c[Y+8>>2]=c[X+8>>2];c[Y+12>>2]=c[X+12>>2];o=o+1|0}while((o|0)!=(n|0))}c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);o=n;n=w;j=p}else o=h;while(0);g[j+(o<<4)>>2]=H;g[j+(o<<4)+4>>2]=r;g[j+(o<<4)+8>>2]=q;g[j+(o<<4)+12>>2]=0.0;h=h+1|0}while(0);z=z+1|0}while((z|0)!=(f|0))}}while((B|0)!=(f|0))}}while((C|0)!=(f|0))}else{j=0;h=0}}else{l=0;j=0;h=0}}else{m=0;l=0;j=0;h=0}Dc(da+128|0,j,h);if(j|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}if(l|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}if(m|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0)}}else Dc(da+128|0,ca,J);G=c[da+128+44>>2]|0;if((G|0)>0){c[6435]=(c[6435]|0)+1;h=yc((G<<4|3)+16|0)|0;if(!h)j=0;else{c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}h=0;do{Y=j+(h<<4)|0;c[Y>>2]=c[da+112>>2];c[Y+4>>2]=c[da+112+4>>2];c[Y+8>>2]=c[da+112+8>>2];c[Y+12>>2]=c[da+112+12>>2];h=h+1|0}while((h|0)!=(G|0))}else j=0;a[da+92+16>>0]=1;Y=da+92+12|0;c[Y>>2]=0;X=da+92+4|0;c[X>>2]=0;c[da+92+8>>2]=0;m=da+256|0;o=m+19|0;do{a[m>>0]=0;m=m+1|0}while((m|0)<(o|0));if((G|0)<0)lb();if((G|0)>0){If(da+92|0,G);h=c[Y>>2]|0;l=0;do{m=h+(l*36|0)|0;a[m+16>>0]=1;c[m+4>>2]=0;c[m+4+4>>2]=0;c[m+4+8>>2]=0;m=m+20|0;n=da+256+3|0;o=m+16|0;do{a[m>>0]=a[n>>0]|0;m=m+1|0;n=n+1|0}while((m|0)<(o|0));l=l+1|0}while((l|0)!=(G|0))}c[X>>2]=G;p=c[da+128+4>>2]|0;o=c[d+52>>2]|0;n=c[o+8>>2]|0;if((n|0)<(p|0)){if((c[o+12>>2]|0)<(p|0)){if(!p){h=0;l=n}else{c[6435]=(c[6435]|0)+1;h=yc((p<<4|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}l=c[o+8>>2]|0}if((l|0)>0){m=0;do{W=h+(m<<4)|0;V=(c[o+16>>2]|0)+(m<<4)|0;c[W>>2]=c[V>>2];c[W+4>>2]=c[V+4>>2];c[W+8>>2]=c[V+8>>2];c[W+12>>2]=c[V+12>>2];m=m+1|0}while((m|0)!=(l|0))}l=c[o+16>>2]|0;if(l|0){if(a[o+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[o+16>>2]=0}a[o+20>>0]=1;c[o+16>>2]=h;c[o+12>>2]=p;l=o+16|0}else l=o+16|0;h=n;do{W=(c[l>>2]|0)+(h<<4)|0;c[W>>2]=c[da+56>>2];c[W+4>>2]=c[da+56+4>>2];c[W+8>>2]=c[da+56+8>>2];c[W+12>>2]=c[da+56+12>>2];h=h+1|0}while((h|0)!=(p|0))}c[o+8>>2]=p;if((p|0)>0){h=0;do{W=(c[(c[d+52>>2]|0)+16>>2]|0)+(h<<4)|0;V=(c[ba>>2]|0)+(h<<4)|0;c[W>>2]=c[V>>2];c[W+4>>2]=c[V+4>>2];c[W+8>>2]=c[V+8>>2];c[W+12>>2]=c[V+12>>2];h=h+1|0}while((h|0)!=(p|0))}if((G|0)>0){D=0;do{A=(c[aa>>2]|0)+((c[(c[$>>2]|0)+(D<<2)>>2]|0)*12|0)|0;C=A;l=0;do{B=C+4|0;z=c[C+((c[B>>2]|0)*12|0)+8>>2]|0;w=c[Y>>2]|0;y=w+(D*36|0)+4|0;h=c[y>>2]|0;f=w+(D*36|0)+8|0;if((h|0)==(c[f>>2]|0)?(L=h|0?h<<1:1,(h|0)<(L|0)):0){if(!L)p=0;else{c[6435]=(c[6435]|0)+1;h=yc((L<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}p=h;h=c[y>>2]|0}o=w+(D*36|0)+12|0;n=c[o>>2]|0;if((h|0)<=0)if(!n)m=w+(D*36|0)+16|0;else _=132;else{m=0;do{c[p+(m<<2)>>2]=c[n+(m<<2)>>2];m=m+1|0}while((m|0)!=(h|0));_=132}if((_|0)==132){_=0;h=w+(D*36|0)+16|0;if(a[h>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}c[o>>2]=0;m=h;h=c[y>>2]|0}a[m>>0]=1;c[o>>2]=p;c[f>>2]=L}c[(c[w+(D*36|0)+12>>2]|0)+(h<<2)>>2]=z;c[y>>2]=(c[y>>2]|0)+1;V=c[C+8>>2]|0;W=c[ba>>2]|0;s=+g[W+(V<<4)>>2]-+g[W+(z<<4)>>2];t=+g[W+(V<<4)+4>>2]-+g[W+(z<<4)+4>>2];q=+g[W+(V<<4)+8>>2]-+g[W+(z<<4)+8>>2];r=1.0/+O(+(s*s+t*t+q*q));if((l|0)<2){g[da+208+(l<<4)>>2]=s*r;g[da+208+(l<<4)+4>>2]=t*r;g[da+208+(l<<4)+8>>2]=q*r;g[da+208+(l<<4)+12>>2]=0.0;l=l+1|0}W=C+((c[B>>2]|0)*12|0)|0;C=W+((c[W>>2]|0)*12|0)|0}while((C|0)!=(A|0));h=j+(D<<4)|0;if((l|0)==2){H=+g[da+208+4>>2];I=+g[da+208+24>>2];U=+g[da+208+8>>2];ea=+g[da+208+20>>2];F=+g[da+208+16>>2];E=+g[da+208>>2];V=j+(D<<4)+4|0;W=j+(D<<4)+8|0;g[j+(D<<4)+12>>2]=0.0;fa=1.0/+O(+((H*I-U*ea)*(H*I-U*ea)+(U*F-I*E)*(U*F-I*E)+(ea*E-H*F)*(ea*E-H*F)));g[h>>2]=(H*I-U*ea)*fa;g[V>>2]=(U*F-I*E)*fa;g[W>>2]=(ea*E-H*F)*fa;o=c[Y>>2]|0;g[o+(D*36|0)+20>>2]=(H*I-U*ea)*fa;c[o+(D*36|0)+24>>2]=c[V>>2];c[o+(D*36|0)+28>>2]=c[W>>2];g[o+(D*36|0)+32>>2]=1000000015047466219876688.0e6}else{c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;o=c[Y>>2]|0}m=c[o+(D*36|0)+4>>2]|0;if((m|0)>0){n=c[(c[d+52>>2]|0)+16>>2]|0;r=+g[h>>2];s=+g[j+(D<<4)+4>>2];t=+g[j+(D<<4)+8>>2];h=c[o+(D*36|0)+12>>2]|0;q=1000000015047466219876688.0e6;l=0;do{W=c[h+(l<<2)>>2]|0;fa=+g[n+(W<<4)>>2]*r+ +g[n+(W<<4)+4>>2]*s+ +g[n+(W<<4)+8>>2]*t;q=q>fa?fa:q;l=l+1|0}while((l|0)!=(m|0))}else q=1000000015047466219876688.0e6;g[o+(D*36|0)+32>>2]=-q;D=D+1|0}while((D|0)!=(G|0))}if((c[X>>2]|0)>0){o=0;h=0;n=0;while(1){do if((o|0)==(h|0)){h=o|0?o<<1:1;if((o|0)<(h|0)){if((h|0)!=0?(c[6435]=(c[6435]|0)+1,M=yc((h<<2|3)+16|0)|0,(M|0)!=0):0){c[(M+4+15&-16)+-4>>2]=M;m=M+4+15&-16}else m=0;if((o|0)<=0){if(!n)break}else{l=0;do{c[m+(l<<2)>>2]=c[n+(l<<2)>>2];l=l+1|0}while((l|0)!=(o|0))}c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}else{h=o;m=n}}else m=n;while(0);c[m+(o<<2)>>2]=o;o=o+1|0;if((o|0)>=(c[X>>2]|0))break;else n=m}L=da+72+12|0;M=da+72+4|0;while(1){f=o+-1|0;l=c[m+(f<<2)>>2]|0;c[6435]=(c[6435]|0)+1;h=yc(23)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[h>>2]=l;W=c[Y>>2]|0;r=+g[W+(l*36|0)+20>>2];s=+g[W+(l*36|0)+24>>2];q=+g[W+(l*36|0)+28>>2];c:do if((o|0)>1){n=1;p=1;l=h;h=f;z=f;while(1){y=p;f=l;d:while(1){l=c[Y>>2]|0;do{W=h;h=h+-1|0;if((W|0)<=0){h=l;K=y;J=f;o=z;break c}w=c[m+(h<<2)>>2]|0}while(!(r*+g[l+(w*36|0)+20>>2]+s*+g[l+(w*36|0)+24>>2]+q*+g[l+(w*36|0)+28>>2]>.9990000128746033));do if((y|0)==(n|0)){n=y|0?y<<1:1;if((y|0)<(n|0)){do if(!n)o=0;else{c[6435]=(c[6435]|0)+1;l=yc((n<<2|3)+16|0)|0;if(!l){o=0;break}c[(l+4+15&-16)+-4>>2]=l;o=l+4+15&-16}while(0);if((y|0)<=0){if(!f){f=o;break}}else{l=0;do{c[o+(l<<2)>>2]=c[f+(l<<2)>>2];l=l+1|0}while((l|0)!=(y|0))}c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);f=o}else n=y}while(0);c[f+(y<<2)>>2]=w;y=y+1|0;l=0;while(1){p=m+(l<<2)|0;if((c[p>>2]|0)==(w|0))break;l=l+1|0;if((l|0)>=(z|0))continue d}if((l|0)<(z|0))break}o=z+-1|0;W=m+(o<<2)|0;c[p>>2]=c[W>>2];c[W>>2]=w;if((z|0)>1){p=y;l=f;z=o}else{p=y;l=f;_=161;break}}}else{n=1;p=1;l=h;h=f;o=f;_=161}while(0);e:do if((_|0)==161){_=0;y=p;w=l;while(1){l=c[Y>>2]|0;do{W=h;h=h+-1|0;if((W|0)<=0){h=l;K=y;J=w;break e}f=c[m+(h<<2)>>2]|0}while(!(r*+g[l+(f*36|0)+20>>2]+s*+g[l+(f*36|0)+24>>2]+q*+g[l+(f*36|0)+28>>2]>.9990000128746033));do if((y|0)==(n|0)){n=y|0?y<<1:1;if((y|0)<(n|0)){do if(!n)l=0;else{c[6435]=(c[6435]|0)+1;l=yc((n<<2|3)+16|0)|0;if(!l){l=0;break}c[(l+4+15&-16)+-4>>2]=l;l=l+4+15&-16}while(0);if((y|0)<=0){if(!w)break}else{p=0;do{c[l+(p<<2)>>2]=c[w+(p<<2)>>2];p=p+1|0}while((p|0)!=(y|0))}c[6436]=(c[6436]|0)+1;hd(c[w+-4>>2]|0)}else{n=y;l=w}}else l=w;while(0);c[l+(y<<2)>>2]=f;y=y+1|0;w=l}}while(0);if((K|0)>1){a[da+72+16>>0]=1;c[L>>2]=0;c[M>>2]=0;c[da+72+8>>2]=0;q=0.0;r=0.0;s=0.0;n=0;B=0;do{l=c[J+(B<<2)>>2]|0;q=+g[h+(l*36|0)+20>>2]+q;r=+g[h+(l*36|0)+24>>2]+r;s=+g[h+(l*36|0)+28>>2]+s;A=h+(l*36|0)+4|0;if((c[A>>2]|0)>0){z=h+(l*36|0)+12|0;h=n;y=0;while(1){w=c[(c[z>>2]|0)+(y<<2)>>2]|0;W=(c[(c[d+52>>2]|0)+16>>2]|0)+(w<<4)|0;c[da+208>>2]=c[W>>2];c[da+208+4>>2]=c[W+4>>2];c[da+208+8>>2]=c[W+8>>2];c[da+208+12>>2]=c[W+12>>2];f:do if((h|0)>0){l=c[L>>2]|0;n=0;while(1){if((c[l+(n*24|0)+20>>2]|0)==(w|0))break f;n=n+1|0;if((n|0)>=(h|0)){_=248;break}}}else _=248;while(0);if((_|0)==248){_=0;c[da>>2]=c[da+208>>2];c[da+4>>2]=c[da+208+4>>2];c[da+8>>2]=c[da+208+8>>2];c[da+12>>2]=c[da+208+12>>2];do if((h|0)==(c[da+72+8>>2]|0)){f=h|0?h<<1:1;if((h|0)>=(f|0))break;if(!f)p=0;else{c[6435]=(c[6435]|0)+1;h=yc((f*24|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}p=h;h=c[M>>2]|0}n=c[L>>2]|0;if((h|0)<=0){if(n)_=257}else{l=0;do{_=p+(l*24|0)|0;W=n+(l*24|0)|0;c[_>>2]=c[W>>2];c[_+4>>2]=c[W+4>>2];c[_+8>>2]=c[W+8>>2];c[_+12>>2]=c[W+12>>2];c[_+16>>2]=c[W+16>>2];c[_+20>>2]=c[W+20>>2];l=l+1|0}while((l|0)!=(h|0));_=257}if((_|0)==257){_=0;if(a[da+72+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0);h=c[M>>2]|0}c[L>>2]=0}a[da+72+16>>0]=1;c[L>>2]=p;c[da+72+8>>2]=f}while(0);W=c[L>>2]|0;V=W+(h*24|0)|0;c[V>>2]=c[da>>2];c[V+4>>2]=c[da+4>>2];c[V+8>>2]=c[da+8>>2];c[V+12>>2]=c[da+12>>2];c[V+16>>2]=c[da+16>>2];c[W+(h*24|0)+20>>2]=w;h=(c[M>>2]|0)+1|0;c[M>>2]=h}y=y+1|0;if((y|0)>=(c[A>>2]|0)){n=h;break}}}B=B+1|0;h=c[Y>>2]|0}while((B|0)<(K|0));a[da+20+16>>0]=1;c[da+20+12>>2]=0;c[da+20+4>>2]=0;c[da+20+8>>2]=0;W=h+20+((c[J>>2]|0)*9<<2)|0;c[da+20+20>>2]=c[W>>2];c[da+20+20+4>>2]=c[W+4>>2];c[da+20+20+8>>2]=c[W+8>>2];c[da+20+20+12>>2]=c[W+12>>2];u=1.0/+O(+(q*q+r*r+s*s));x=q*u;v=r*u;u=s*u;if(+N(+u)>.7071067690849304){t=1.0/+O(+(u*u+v*v));r=0.0;s=v*t;t=-(u*t)}else{t=1.0/+O(+(x*x+v*v));r=-(v*t);s=0.0;t=x*t}if((n|0)<2)if((n|0)>0){h=n;n=0;p=0;y=0;while(1){z=c[L>>2]|0;do if((n|0)==(p|0)){w=p|0?p<<1:1;if((p|0)>=(w|0)){f=p;l=y;break}do if(!w)l=0;else{c[6435]=(c[6435]|0)+1;h=yc((w*24|3)+16|0)|0;if(!h){l=0;p=n;break}c[(h+4+15&-16)+-4>>2]=h;l=h+4+15&-16;p=n}while(0);if((p|0)<=0){if(y|0)_=209}else{h=0;do{_=l+(h*24|0)|0;W=y+(h*24|0)|0;c[_>>2]=c[W>>2];c[_+4>>2]=c[W+4>>2];c[_+8>>2]=c[W+8>>2];c[_+12>>2]=c[W+12>>2];c[_+16>>2]=c[W+16>>2];c[_+20>>2]=c[W+20>>2];h=h+1|0}while((h|0)!=(p|0));_=209}if((_|0)==209){_=0;c[6436]=(c[6436]|0)+1;hd(c[y+-4>>2]|0)}f=n;h=c[M>>2]|0;p=w}else{f=n;l=y}while(0);W=l+(f*24|0)|0;c[W>>2]=c[z>>2];c[W+4>>2]=c[z+4>>2];c[W+8>>2]=c[z+8>>2];c[W+12>>2]=c[z+12>>2];c[W+16>>2]=c[z+16>>2];c[W+20>>2]=c[z+20>>2];n=n+1|0;if((n|0)<(h|0))y=l;else{_=263;break}}}else{h=0;l=0;_=292}else{h=c[L>>2]|0;l=n;p=0;do{if(r*+g[h+(p*24|0)>>2]+t*+g[h+(p*24|0)+4>>2]+s*+g[h+(p*24|0)+8>>2]>2]+t*+g[h+4>>2]+s*+g[h+8>>2]){c[da+208>>2]=c[h>>2];c[da+208+4>>2]=c[h+4>>2];c[da+208+8>>2]=c[h+8>>2];c[da+208+12>>2]=c[h+12>>2];c[da+208+16>>2]=c[h+16>>2];c[da+208+20>>2]=c[h+20>>2];l=h+(p*24|0)|0;c[h>>2]=c[l>>2];c[h+4>>2]=c[l+4>>2];c[h+8>>2]=c[l+8>>2];c[h+12>>2]=c[l+12>>2];c[h+16>>2]=c[l+16>>2];c[h+20>>2]=c[l+20>>2];l=h+(p*24|0)|0;c[l>>2]=c[da+208>>2];c[l+4>>2]=c[da+208+4>>2];c[l+8>>2]=c[da+208+8>>2];c[l+12>>2]=c[da+208+12>>2];c[l+16>>2]=c[da+208+16>>2];c[l+20>>2]=c[da+208+20>>2];l=n}p=p+1|0}while((p|0)<(l|0));g[h+16>>2]=-1000000015047466219876688.0e6;if((l|0)>1){h=c[L>>2]|0;l=c[M>>2]|0;q=+g[h+4>>2];n=1;do{U=+g[h+(n*24|0)>>2]-+g[h>>2];ea=+g[h+(n*24|0)+4>>2]-q;fa=+g[h+(n*24|0)+8>>2]-+g[h+8>>2];g[h+(n*24|0)+16>>2]=((r*ea-t*U)*u+(x*(t*fa-s*ea)+v*(s*U-r*fa)))/+O(+(U*U+ea*ea+fa*fa));n=n+1|0}while((n|0)<(l|0))}c[da+208>>2]=c[h>>2];c[da+208+4>>2]=c[h+4>>2];c[da+208+8>>2]=c[h+8>>2];c[da+208+12>>2]=c[h+12>>2];xf(da+72|0,da+208|0,1,(c[M>>2]|0)+-1|0);l=c[L>>2]|0;c[6435]=(c[6435]|0)+1;h=yc(43)|0;if(!h)p=0;else{c[(h+4+15&-16)+-4>>2]=h;p=h+4+15&-16}n=c[L>>2]|0;c[p>>2]=c[l>>2];c[p+4>>2]=c[l+4>>2];c[p+8>>2]=c[l+8>>2];c[p+12>>2]=c[l+12>>2];c[p+16>>2]=c[l+16>>2];c[p+20>>2]=c[l+20>>2];c[6435]=(c[6435]|0)+1;h=yc(67)|0;if(!h)l=0;else{c[(h+4+15&-16)+-4>>2]=h;l=h+4+15&-16}c[l>>2]=c[p>>2];c[l+4>>2]=c[p+4>>2];c[l+8>>2]=c[p+8>>2];c[l+12>>2]=c[p+12>>2];c[l+16>>2]=c[p+16>>2];c[l+20>>2]=c[p+20>>2];if(p|0){c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0)}h=l+24|0;c[h>>2]=c[n+24>>2];c[h+4>>2]=c[n+24+4>>2];c[h+8>>2]=c[n+24+8>>2];c[h+12>>2]=c[n+24+12>>2];c[h+16>>2]=c[n+24+16>>2];c[h+20>>2]=c[n+24+20>>2];h=c[M>>2]|0;if((h|0)==2){h=2;n=2}else{f=2;n=2;p=2;A=2;do{g:do if((f|0)>1){W=c[L>>2]|0;z=W+(A*24|0)|0;q=+g[z>>2];r=+g[W+(A*24|0)+4>>2];s=+g[W+(A*24|0)+8>>2];while(1){W=f+-2|0;w=f+-1|0;U=+g[l+(W*24|0)>>2];ea=U-+g[l+(w*24|0)>>2];H=+g[l+(W*24|0)+4>>2];F=H-+g[l+(w*24|0)+4>>2];fa=+g[l+(W*24|0)+8>>2];I=fa-+g[l+(w*24|0)+8>>2];if((ea*(H-r)-F*(U-q))*u+(x*(F*(fa-s)-I*(H-r))+v*(I*(U-q)-ea*(fa-s)))>0.0)break;if((w|0)>1){f=w;n=w}else{f=w;n=w;break g}}do if((f|0)==(p|0)){y=p<<1;if((p|0)>=(y|0)){f=p;w=p;break}if(p){c[6435]=(c[6435]|0)+1;h=yc((p*48|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}if((n|0)>0){p=h;f=n;_=230}else p=h}else{p=0;h=0;f=0;_=230}if((_|0)==230){_=0;w=0;do{W=h+(w*24|0)|0;V=l+(w*24|0)|0;c[W>>2]=c[V>>2];c[W+4>>2]=c[V+4>>2];c[W+8>>2]=c[V+8>>2];c[W+12>>2]=c[V+12>>2];c[W+16>>2]=c[V+16>>2];c[W+20>>2]=c[V+20>>2];w=w+1|0}while((w|0)!=(f|0))}c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);h=c[M>>2]|0;f=n;w=y;l=p}else w=p;while(0);f=l+(f*24|0)|0;c[f>>2]=c[z>>2];c[f+4>>2]=c[z+4>>2];c[f+8>>2]=c[z+8>>2];c[f+12>>2]=c[z+12>>2];c[f+16>>2]=c[z+16>>2];c[f+20>>2]=c[z+20>>2];n=n+1|0;f=n;p=w}while(0);A=A+1|0}while((A|0)!=(h|0))}_=263}h:do if((_|0)==263){_=0;if((n|0)>0){D=0;A=0;f=0;h=0;G=0;while(1){B=l+(G*24|0)+20|0;do if((D|0)==(A|0)){w=A|0?A<<1:1;if((A|0)>=(w|0)){C=f;break}do if(!w)p=0;else{c[6435]=(c[6435]|0)+1;h=yc((w<<2|3)+16|0)|0;if(!h){p=0;break}c[(h+4+15&-16)+-4>>2]=h;p=h+4+15&-16}while(0);if((A|0)<=0){if(f|0)_=284}else{h=0;do{c[p+(h<<2)>>2]=c[f+(h<<2)>>2];h=h+1|0}while((h|0)!=(A|0));_=284}if((_|0)==284){_=0;c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);c[da+20+12>>2]=0}a[da+20+16>>0]=1;c[da+20+12>>2]=p;c[da+20+8>>2]=w;C=p;h=p;A=w}else C=f;while(0);c[C+(D<<2)>>2]=c[B>>2];D=(c[da+20+4>>2]|0)+1|0;c[da+20+4>>2]=D;y=c[M>>2]|0;i:do if((y|0)>0){z=c[L>>2]|0;p=c[B>>2]|0;w=0;while(1){f=z+(w*24|0)+20|0;w=w+1|0;if((c[f>>2]|0)==(p|0))break;if((w|0)>=(y|0))break i}c[f>>2]=-1}while(0);G=G+1|0;if((G|0)>=(n|0)){D=y;break}else f=C}}else{D=h;h=0}if((D|0)<=0){_=292;break}w=c[L>>2]|0;y=c[X>>2]|0;z=c[Y>>2]|0;if((y|0)>0)B=0;else{_=292;break}while(1){A=c[w+(B*24|0)+20>>2]|0;if((A|0)!=-1){C=0;do{n=0;while(1){if((c[J+(n<<2)>>2]|0)==(C|0))break;n=n+1|0;if((n|0)>=(K|0)){_=270;break}}do if((_|0)==270){_=0;n=c[z+(C*36|0)+4>>2]|0;if((n|0)<=0)break;p=c[z+(C*36|0)+12>>2]|0;f=0;do{if((c[p+(f<<2)>>2]|0)==(A|0)){n=1;break h}f=f+1|0}while((f|0)<(n|0))}while(0);C=C+1|0}while((C|0)<(y|0))}B=B+1|0;if((B|0)>=(D|0)){_=292;break}}}while(0);if((_|0)==292){_=0;th((c[d+52>>2]|0)+24|0,da+20|0);n=0}if(l|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);c[da+20+12>>2]=0}h=c[L>>2]|0;if(h|0){if(a[da+72+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[L>>2]=0}if(n&(K|0)>0){y=0;_=302}}else if((K|0)>0){y=0;_=302}if((_|0)==302)while(1){_=0;f=c[J+(y<<2)>>2]|0;w=c[Y>>2]|0;a[da+208+16>>0]=1;c[da+208+12>>2]=0;c[da+208+4>>2]=0;c[da+208+8>>2]=0;p=c[w+(f*36|0)+4>>2]|0;if((p|0)>0){c[6435]=(c[6435]|0)+1;h=yc((p<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}a[da+208+16>>0]=1;c[da+208+12>>2]=h;c[da+208+8>>2]=p;Qn(h|0,0,p<<2|0)|0;l=c[w+(f*36|0)+12>>2]|0;c[da+208+4>>2]=p;n=0;do{c[h+(n<<2)>>2]=c[l+(n<<2)>>2];n=n+1|0}while((n|0)!=(p|0))}else{c[da+208+4>>2]=p;h=0}c[da+208+20>>2]=c[w+(f*36|0)+20>>2];c[da+208+20+4>>2]=c[w+(f*36|0)+20+4>>2];c[da+208+20+8>>2]=c[w+(f*36|0)+20+8>>2];c[da+208+20+12>>2]=c[w+(f*36|0)+20+12>>2];th((c[d+52>>2]|0)+24|0,da+208|0);if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);c[da+208+12>>2]=0}y=y+1|0;if((y|0)>=(K|0))break;else _=302}if(J|0){c[6436]=(c[6436]|0)+1;hd(c[J+-4>>2]|0)}if(!o)break}}else m=0;W=c[d+52>>2]|0;c[W+64>>2]=0;c[W+64+4>>2]=0;c[W+64+8>>2]=0;c[W+64+12>>2]=0;h=c[W+28>>2]|0;if((h|0)>0){z=0;l=0;n=0;D=0;B=0;w=0;o=0;C=0;y=0;p=0;A=0;G=0;V=0;while(1){f=c[W+36>>2]|0;T=c[f+(V*36|0)+4>>2]|0;if((T|0)>0){R=V&65535;S=V|-65536;P=w;L=y;K=G;h=0;while(1){Q=h+1|0;J=c[f+(V*36|0)+12>>2]|0;w=c[J+(h<<2)>>2]&65535;J=c[J+(((Q|0)==(T|0)?0:Q)<<2)>>2]&65535;M=J<<16>>16>w<<16>>16?w:J;d=J<<16>>16>w<<16>>16?J:w;f=J<<16>>16>w<<16>>16?w:J;w=J<<16>>16>w<<16>>16?J:w;J=L+-1|0;j:do if((((f&65535)<<16)+(w<<16>>16)&J)>>>0>>0?(Z=c[n+((((f&65535)<<16)+(w<<16>>16)&J)<<2)>>2]|0,(Z|0)!=-1):0){h=Z;while(1){if(w<<16>>16==(b[l+(h<<2)>>1]|0)?f<<16>>16==(b[l+(h<<2)+2>>1]|0):0)break;h=c[o+(h<<2)>>2]|0;if((h|0)==-1){G=0;break j}}G=p+(h<<2)|0}else G=0;while(0);h=c[W+16>>2]|0;u=+g[h+(f<<16>>16<<4)>>2]-+g[h+(w<<16>>16<<4)>>2];v=+g[h+(f<<16>>16<<4)+4>>2]-+g[h+(w<<16>>16<<4)+4>>2];s=+g[h+(f<<16>>16<<4)+8>>2]-+g[h+(w<<16>>16<<4)+8>>2];t=1.0/+O(+(u*u+v*v+s*s));h=c[W+48>>2]|0;k:do if((h|0)>0){f=c[W+56>>2]|0;w=0;while(1){q=+g[f+(w<<4)>>2];r=+g[f+(w<<4)+8>>2];do if(!(+N(+(q-u*t))>1.0e-06)){if(+N(+(+g[f+(w<<4)+4>>2]-v*t))>1.0e-06)break;if(!(+N(+(r-s*t))>1.0e-06))break k}while(0);do if(!(+N(+(u*t+q))>1.0e-06)){if(+N(+(v*t+ +g[f+(w<<4)+4>>2]))>1.0e-06)break;if(!(+N(+(s*t+r))>1.0e-06))break k}while(0);w=w+1|0;if((w|0)>=(h|0)){_=338;break}}}else _=338;while(0);if((_|0)==338){_=0;do if((h|0)==(c[W+52>>2]|0)){y=h|0?h<<1:1;if((h|0)>=(y|0))break;if(!y)w=0;else{c[6435]=(c[6435]|0)+1;h=yc((y<<4|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}w=h;h=c[W+48>>2]|0}if((h|0)>0){f=0;do{ga=w+(f<<4)|0;ha=(c[W+56>>2]|0)+(f<<4)|0;c[ga>>2]=c[ha>>2];c[ga+4>>2]=c[ha+4>>2];c[ga+8>>2]=c[ha+8>>2];c[ga+12>>2]=c[ha+12>>2];f=f+1|0}while((f|0)!=(h|0))}h=c[W+56>>2]|0;if(h|0){if(a[W+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[W+56>>2]=0}a[W+60>>0]=1;c[W+56>>2]=w;c[W+52>>2]=y;h=c[W+48>>2]|0}while(0);ha=c[W+56>>2]|0;g[ha+(h<<4)>>2]=u*t;g[ha+(h<<4)+4>>2]=v*t;g[ha+(h<<4)+8>>2]=s*t;g[ha+(h<<4)+12>>2]=0.0;c[W+48>>2]=(c[W+48>>2]|0)+1}l:do if(!G){h=((M&65535)<<16)+(d<<16>>16)&J;m:do if(h>>>0>>0){f=c[n+(h<<2)>>2]|0;if((f|0)==-1)break;while(1){if(d<<16>>16==(b[l+(f<<2)>>1]|0)?M<<16>>16==(b[l+(f<<2)+2>>1]|0):0)break;f=c[o+(f<<2)>>2]|0;if((f|0)==-1)break m}w=p+(f<<2)|0;b[w>>1]=S;b[w+2>>1]=S>>>16;w=P;y=L;G=K;break l}while(0);do if((C|0)==(L|0)){y=C|0?C<<1:1;if((C|0)>=(y|0)){y=C;break}do if(!y)w=0;else{c[6435]=(c[6435]|0)+1;f=yc((y<<2|3)+16|0)|0;if(!f){w=0;break}c[(f+4+15&-16)+-4>>2]=f;w=f+4+15&-16}while(0);if((C|0)<=0){if(!p){p=w;break}}else{f=0;do{ha=w+(f<<2)|0;ga=p+(f<<2)|0;ga=e[ga>>1]|e[ga+2>>1]<<16;b[ha>>1]=ga;b[ha+2>>1]=ga>>>16;f=f+1|0}while((f|0)!=(C|0))}c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0);p=w}else y=L;while(0);J=p+(C<<2)|0;b[J>>1]=S;b[J+2>>1]=S>>>16;J=C+1|0;do if((K|0)==(z|0)){z=K|0?K<<1:1;if((K|0)>=(z|0)){z=K;break}do if(!z)w=0;else{c[6435]=(c[6435]|0)+1;f=yc((z<<2|3)+16|0)|0;if(!f){w=0;break}c[(f+4+15&-16)+-4>>2]=f;w=f+4+15&-16}while(0);if((K|0)<=0){if(!l){l=w;break}}else{f=0;do{ha=w+(f<<2)|0;ga=l+(f<<2)|0;ga=e[ga>>1]|e[ga+2>>1]<<16;b[ha>>1]=ga;b[ha+2>>1]=ga>>>16;f=f+1|0}while((f|0)!=(K|0))}c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);l=w}while(0);G=l+(K<<2)|0;b[G>>1]=(M&65535)<<16|d&65535;b[G+2>>1]=((M&65535)<<16|d&65535)>>>16;G=K+1|0;if((L|0)<(y|0)){do if((y|0)>(D|0)){if((y|0)>=(D|0)){do if((A|0)<(y|0)){do if(!y)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((y<<2|3)+16|0)|0;if(!h){h=0;break}c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}while(0);if((D|0)<=0){if(!n){n=h;h=y;break}}else{f=0;do{c[h+(f<<2)>>2]=c[n+(f<<2)>>2];f=f+1|0}while((f|0)!=(D|0))}c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0);n=h;h=y}else h=A;while(0);Qn(n+(D<<2)|0,0,y-D<<2|0)|0;A=h}if((y|0)>(B|0)){do if((P|0)<(y|0)){do if(!y)f=0;else{c[6435]=(c[6435]|0)+1;h=yc((y<<2|3)+16|0)|0;if(!h){f=0;break}c[(h+4+15&-16)+-4>>2]=h;f=h+4+15&-16}while(0);if((B|0)<=0){if(!o){h=y;o=f;break}}else{h=0;do{c[f+(h<<2)>>2]=c[o+(h<<2)>>2];h=h+1|0}while((h|0)!=(B|0))}c[6436]=(c[6436]|0)+1;hd(c[o+-4>>2]|0);h=y;o=f}else h=P;while(0);Qn(o+(B<<2)|0,0,y-B<<2|0)|0;w=h}else w=P;if((y|0)>0){ha=y<<2;Qn(n|0,-1,ha|0)|0;Qn(o|0,-1,ha|0)|0}if((D|0)<=0){f=y;B=y;h=A;break}h=y+-1|0;f=0;do{ha=n+(((e[l+(f<<2)+2>>1]<<16)+(b[l+(f<<2)>>1]|0)&h)<<2)|0;c[o+(f<<2)>>2]=c[ha>>2];c[ha>>2]=f;f=f+1|0}while((f|0)!=(D|0));f=y;B=y;h=A}else{f=D;w=P;h=A}while(0);A=h;h=((M&65535)<<16)+(d<<16>>16)&y+-1}else{f=D;w=P}D=n+(h<<2)|0;c[o+(C<<2)>>2]=c[D>>2];c[D>>2]=C;D=f;C=J}else{b[G+2>>1]=R;w=P;y=L;G=K}while(0);if((Q|0)>=(T|0))break;f=c[W+36>>2]|0;P=w;L=y;K=G;h=Q}h=c[W+28>>2]|0;f=G}else f=G;V=V+1|0;if((V|0)>=(h|0))break;else G=f}if((h|0)>0){A=c[W+36>>2]|0;B=c[W+16>>2]|0;q=0.0;C=0;do{w=c[A+(C*36|0)+4>>2]|0;y=c[A+(C*36|0)+12>>2]|0;z=c[y>>2]|0;if((w+-2|0)>=1){r=+g[W+64>>2];s=+g[W+68>>2];t=+g[W+72>>2];f=1;do{ga=c[y+(f<<2)>>2]|0;f=f+1|0;ha=c[y+(((f|0)%(w|0)|0)<<2)>>2]|0;u=+g[B+(z<<4)>>2];v=+g[B+(ga<<4)>>2];E=+g[B+(z<<4)+4>>2];F=+g[B+(ga<<4)+4>>2];I=+g[B+(z<<4)+8>>2];U=+g[B+(ga<<4)+8>>2];x=+g[B+(ha<<4)>>2];H=+g[B+(ha<<4)+4>>2];ea=+g[B+(ha<<4)+8>>2];fa=+O(+(((u-v)*(E-H)-(E-F)*(u-x))*((u-v)*(E-H)-(E-F)*(u-x))+(((E-F)*(I-ea)-(I-U)*(E-H))*((E-F)*(I-ea)-(I-U)*(E-H))+((I-U)*(u-x)-(u-v)*(I-ea))*((I-U)*(u-x)-(u-v)*(I-ea)))))*.5;r=r+(u+v+x)*.3333333432674408*fa;g[W+64>>2]=r;s=(E+F+H)*.3333333432674408*fa+s;g[W+68>>2]=s;t=fa*(I+U+ea)*.3333333432674408+t;g[W+72>>2]=t;q=q+fa}while((f|0)!=(w+-1|0))}C=C+1|0}while((C|0)!=(h|0));f=W+64|0;w=1;z=l;y=n}else _=317}else{l=0;n=0;o=0;p=0;_=317}if((_|0)==317){f=W+64|0;w=0;q=0.0;z=l;y=n}t=1.0/q;u=t*+g[f>>2];g[f>>2]=u;s=t*+g[W+68>>2];g[W+68>>2]=s;t=t*+g[W+72>>2];g[W+72>>2]=t;g[W+96>>2]=3402823466385288598117041.0e14;if(w){l=c[W+36>>2]|0;r=3402823466385288598117041.0e14;n=0;while(1){q=+N(+(+g[l+(n*36|0)+32>>2]+(+g[l+(n*36|0)+20>>2]*u+ +g[l+(n*36|0)+24>>2]*s+ +g[l+(n*36|0)+28>>2]*t)));if(q>2]=q;else q=r;n=n+1|0;if((n|0)>=(h|0))break;else r=q}}else q=3402823466385288598117041.0e14;h=c[W+8>>2]|0;if((h|0)>0){l=c[W+16>>2]|0;x=-3402823466385288598117041.0e14;v=-3402823466385288598117041.0e14;u=-3402823466385288598117041.0e14;t=3402823466385288598117041.0e14;s=3402823466385288598117041.0e14;r=3402823466385288598117041.0e14;n=0;do{fa=+g[l+(n<<4)>>2];t=fax?fa:x;fa=+g[l+(n<<4)+4>>2];s=fav?fa:v;fa=+g[l+(n<<4)+8>>2];r=fau?fa:u;n=n+1|0}while((n|0)!=(h|0))}else{x=-3402823466385288598117041.0e14;v=-3402823466385288598117041.0e14;u=-3402823466385288598117041.0e14;t=3402823466385288598117041.0e14;s=3402823466385288598117041.0e14;r=3402823466385288598117041.0e14}g[W+100>>2]=x+t;g[W+104>>2]=s+v;g[W+108>>2]=r+u;g[W+112>>2]=0.0;fa=x-t;ea=v-s;r=u-r;g[W+116>>2]=fa;g[W+120>>2]=ea;g[W+124>>2]=r;g[W+128>>2]=0.0;s=q/1.7320507764816284;f=fa>2]*.5-s)*.0009765625;g[W+88>>2]=s;g[W+84>>2]=s;g[W+80>>2]=s;r=+g[W+116+(f<<2)>>2]*.5;g[W+80+(f<<2)>>2]=r;h=0;while(1){if(ih(W)|0){_=425;break}r=r-q;g[W+80+(f<<2)>>2]=r;h=h+1|0;if((h|0)>=1024){_=424;break}}n:do if((_|0)==424){g[W+88>>2]=s;g[W+84>>2]=s;g[W+80>>2]=s}else if((_|0)==425){q=(+g[W+96>>2]-s)*.0009765625;l=c[W+80+((1<<(1<>2]|0;n=0;while(1){h=c[W+80+((1<>2]|0;g[W+80+((1<>2]=q+(c[k>>2]=h,+g[k>>2]);r=q+ +g[W+80+((1<<(1<>2];g[W+80+((1<<(1<>2]=r;n=n+1|0;if(!(ih(W)|0))break;if((n|0)>=1024)break n;else l=(g[k>>2]=r,c[k>>2]|0)}c[W+80+((1<>2]=h;c[W+80+((1<<(1<>2]=l}while(0);if(z|0){c[6436]=(c[6436]|0)+1;hd(c[z+-4>>2]|0)}if(p|0){c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0)}if(o|0){c[6436]=(c[6436]|0)+1;hd(c[o+-4>>2]|0)}if(y|0){c[6436]=(c[6436]|0)+1;hd(c[y+-4>>2]|0)}if(m|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0)}p=c[X>>2]|0;f=c[Y>>2]|0;if((p|0)<=0){if(f|0)_=446}else{o=0;do{l=f+(o*36|0)+4|0;m=f+(o*36|0)+12|0;n=c[m>>2]|0;h=f+(o*36|0)+16|0;if(n|0){if(a[h>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[n+-4>>2]|0)}c[m>>2]=0}a[h>>0]=1;c[m>>2]=0;c[l>>2]=0;c[f+(o*36|0)+8>>2]=0;o=o+1|0}while((o|0)!=(p|0));_=446}if((_|0)==446){if(a[da+92+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[Y>>2]=0}if(j|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}h=c[$>>2]|0;if(h|0){if(a[da+128+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[$>>2]=0}a[da+128+56>>0]=1;c[$>>2]=0;c[da+128+44>>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>2];I=+g[ta+28+(((ua+2|0)%3|0)<<2)>>2];b=c[d+12>>2]|0;j=c[e+12>>2]|0;B=+g[b+(qa<<2)>>2];E=+g[b+16+(qa<<2)>>2];C=+g[b+32+(qa<<2)>>2];p=+g[j+(ua<<2)>>2];q=+g[j+16+(ua<<2)>>2];w=+g[j+32+(ua<<2)>>2];x=+g[j+48>>2]-+g[b+48>>2];y=+g[j+52>>2]-+g[b+52>>2];A=+g[j+56>>2]-+g[b+56>>2];n=1.0-(B*p+E*q+C*w)*(B*p+E*q+C*w);if(!(n==0.0)){n=(B*x+E*y+C*A-(B*p+E*q+C*w)*(p*x+q*y+w*A))/n;if(!(n<-r)){if(n>r)n=r}else n=-r}else n=0.0;o=(B*p+E*q+C*w)*n-(p*x+q*y+w*A);if(o<-s){n=(B*p+E*q+C*w)*-s+(B*x+E*y+C*A);if(!(n<-r))if(n>r){n=r;o=-s}else o=-s;else{n=-r;o=-s}}else if(o>s){n=s*(B*p+E*q+C*w)+(B*x+E*y+C*A);if(!(n<-r))if(n>r){n=r;o=s}else o=s;else{n=-r;o=s}}u=p*o;t=q*o;s=w*o;o=u+(x-B*n);q=t+(y-E*n);n=s+(A-C*n);r=+O(+(n*n+(o*o+q*q)));if(!(r-K-I>L)){do if(n*n+(o*o+q*q)<=1.4210854715202004e-14)if(+N(+C)>.7071067690849304){n=1.0/+O(+(E*E+C*C));g[va+280>>2]=0.0;g[va+280+4>>2]=-(C*n);g[va+280+8>>2]=E*n;p=0.0;o=-(C*n);n=E*n;break}else{o=1.0/+O(+(B*B+E*E));g[va+280>>2]=-(E*o);g[va+280+4>>2]=B*o;g[va+280+8>>2]=0.0;p=-(E*o);o=B*o;n=0.0;break}else{g[va+280>>2]=o*-(1.0/r);g[va+280+4>>2]=q*-(1.0/r);g[va+280+8>>2]=n*-(1.0/r);g[va+280+12>>2]=0.0;p=o*-(1.0/r);o=q*-(1.0/r);n=n*-(1.0/r)}while(0);pa=I*o+(t+ +g[j+52>>2]);ra=I*n+(s+ +g[j+56>>2]);g[va+264>>2]=I*p+(u+ +g[j+48>>2]);g[va+264+4>>2]=pa;g[va+264+8>>2]=ra;g[va+264+12>>2]=0.0}if(r-K-I>2]|0)+16>>2]&15](h,va+280|0,va+264|0,r-K-I);k=c[h+4>>2]|0}if(!(c[k+748>>2]|0)){i=va;return}l=c[k+740>>2]|0;m=c[(c[h+8>>2]|0)+8>>2]|0;j=c[(c[h+12>>2]|0)+8>>2]|0;if((l|0)==(m|0)){ef(k,l+4|0,j+4|0);i=va;return}else{ef(k,j+4|0,m+4|0);i=va;return}}g[va+128+128>>2]=999999984306749440.0;D=c[b+8>>2]|0;v=c[b+12>>2]|0;c[va+48>>2]=9208;c[va+48+4>>2]=0;c[va+48+8>>2]=1065353216;c[va+48+12>>2]=0;g[va+48+16>>2]=0.0;c[va+48+20>>2]=v;c[va+48+24>>2]=D;c[va+48+28>>2]=sa;c[va+48+32>>2]=ta;c[va+48+36>>2]=j;c[va+48+40>>2]=l;g[va+48+44>>2]=+Sb[c[(c[sa>>2]|0)+48>>2]&15](sa);g[va+48+48>>2]=+Sb[c[(c[ta>>2]|0)+48>>2]&15](ta);a[va+48+52>>0]=0;c[va+48+60>>2]=-1;c[va+48+72>>2]=1;c[va+48+76>>2]=1;c[va+48+28>>2]=sa;c[va+48+32>>2]=ta;pa=+Sb[c[(c[sa>>2]|0)+48>>2]&15](sa);ra=+Sb[c[(c[ta>>2]|0)+48>>2]&15](ta);ra=pa+ra+ +g[(c[b+20>>2]|0)+752>>2];g[va+128+128>>2]=ra*ra;D=c[d+12>>2]|0;c[va+128>>2]=c[D>>2];c[va+128+4>>2]=c[D+4>>2];c[va+128+8>>2]=c[D+8>>2];c[va+128+12>>2]=c[D+12>>2];l=va+128+16|0;c[l>>2]=c[D+16>>2];c[l+4>>2]=c[D+16+4>>2];c[l+8>>2]=c[D+16+8>>2];c[l+12>>2]=c[D+16+12>>2];v=va+128+32|0;c[v>>2]=c[D+32>>2];c[v+4>>2]=c[D+32+4>>2];c[v+8>>2]=c[D+32+8>>2];c[v+12>>2]=c[D+32+12>>2];z=va+128+48|0;c[z>>2]=c[D+48>>2];c[z+4>>2]=c[D+48+4>>2];c[z+8>>2]=c[D+48+8>>2];c[z+12>>2]=c[D+48+12>>2];D=va+128+64|0;j=c[e+12>>2]|0;c[D>>2]=c[j>>2];c[D+4>>2]=c[j+4>>2];c[D+8>>2]=c[j+8>>2];c[D+12>>2]=c[j+12>>2];F=va+128+80|0;c[F>>2]=c[j+16>>2];c[F+4>>2]=c[j+16+4>>2];c[F+8>>2]=c[j+16+8>>2];c[F+12>>2]=c[j+16+12>>2];G=va+128+96|0;c[G>>2]=c[j+32>>2];c[G+4>>2]=c[j+32+4>>2];c[G+8>>2]=c[j+32+8>>2];c[G+12>>2]=c[j+32+12>>2];H=va+128+112|0;c[H>>2]=c[j+48>>2];c[H+4>>2]=c[j+48+4>>2];c[H+8>>2]=c[j+48+8>>2];c[H+12>>2]=c[j+48+12>>2];j=c[sa+4>>2]|0;if((j|0)<7?(m=c[ta+4>>2]|0,(m|0)<7):0){c[va+40>>2]=6080;if(!j){j=m;o=0.0}else{o=+Sb[c[(c[sa>>2]|0)+48>>2]&15](sa);j=c[ta+4>>2]|0}if(!j)n=0.0;else n=+Sb[c[(c[ta>>2]|0)+48>>2]&15](ta);c[va>>2]=6108;c[va+4>>2]=h;g[va+24>>2]=o;g[va+28>>2]=n;a[va+36>>0]=0;U=c[sa+52>>2]|0;a:do if(U|0){ma=c[ta+52>>2]|0;do if(!ma){if((c[ta+4>>2]|0)!=1)break a;z=va+624+16|0;a[z>>0]=1;D=va+624+12|0;c[D>>2]=0;v=va+624+4|0;c[v>>2]=0;m=va+624+8|0;c[m>>2]=0;j=c[e+12>>2]|0;pa=+g[ta+56>>2];ra=+g[ta+56+4>>2];p=+g[ta+56+8>>2];n=pa*+g[j>>2]+ra*+g[j+4>>2]+p*+g[j+8>>2]+ +g[j+48>>2];o=pa*+g[j+16>>2]+ra*+g[j+20>>2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|0}ua=c[D>>2]|0;g[ua+(j<<4)>>2]=n;g[ua+(j<<4)+4>>2]=o;g[ua+(j<<4)+8>>2]=p;g[ua+(j<<4)+12>>2]=0.0;j=(c[v>>2]|0)+1|0;c[v>>2]=j;ua=c[e+12>>2]|0;pa=+g[ta+56+32>>2];ra=+g[ta+56+36>>2];p=+g[ta+56+40>>2];n=pa*+g[ua>>2]+ra*+g[ua+4>>2]+p*+g[ua+8>>2]+ +g[ua+48>>2];o=pa*+g[ua+16>>2]+ra*+g[ua+20>>2]+p*+g[ua+24>>2]+ +g[ua+52>>2];p=pa*+g[ua+32>>2]+ra*+g[ua+36>>2]+p*+g[ua+40>>2]+ +g[ua+56>>2];if((j|0)==(c[m>>2]|0)?(S=j|0?j<<1:1,(j|0)<(S|0)):0){if(!S)l=0;else{c[6435]=(c[6435]|0)+1;j=yc((S<<4|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}l=j;j=c[v>>2]|0}if((j|0)>0){k=0;do{ua=l+(k<<4)|0;e=(c[D>>2]|0)+(k<<4)|0;c[ua>>2]=c[e>>2];c[ua+4>>2]=c[e+4>>2];c[ua+8>>2]=c[e+8>>2];c[ua+12>>2]=c[e+12>>2];k=k+1|0}while((k|0)!=(j|0))}j=c[D>>2]|0;if(j|0){if(a[z>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[D>>2]=0}a[z>>0]=1;c[D>>2]=l;c[m>>2]=S;j=c[v>>2]|0}ua=c[D>>2]|0;g[ua+(j<<4)>>2]=n;g[ua+(j<<4)+4>>2]=o;g[ua+(j<<4)+8>>2]=p;g[ua+(j<<4)+12>>2]=0.0;c[v>>2]=(c[v>>2]|0)+1;q=+g[(c[b+20>>2]|0)+752>>2];Vc(va+48|0,va+128|0,va+40|0,c[f+20>>2]|0,0);n=+g[va+48+4>>2];o=+g[va+48+8>>2];p=+g[va+48+12>>2];if(n*n+o*o+p*p>1.1920928955078125e-07){pa=1.0/(n*n+o*o+p*p);g[va+384>>2]=n*pa;g[va+384+4>>2]=o*pa;g[va+384+8>>2]=p*pa;g[va+384+12>>2]=0.0;pa=+g[va+48+56>>2];ra=+Sb[c[(c[sa>>2]|0)+48>>2]&15](sa);ra=pa-ra-+Sb[c[(c[ta>>2]|0)+48>>2]&15](ta);Wc(va+384|0,c[sa+52>>2]|0,c[d+12>>2]|0,va+624|0,ra-q,q,h)}do if(a[b+16>>0]|0?(T=c[h+4>>2]|0,c[T+748>>2]|0):0){k=c[T+740>>2]|0;l=c[(c[h+8>>2]|0)+8>>2]|0;j=c[(c[h+12>>2]|0)+8>>2]|0;if((k|0)==(l|0)){ef(T,k+4|0,j+4|0);break}else{ef(T,j+4|0,l+4|0);break}}while(0);j=c[D>>2]|0;if(j|0){if(a[z>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[D>>2]=0}}else{ra=+g[(c[b+20>>2]|0)+752>>2];b:do if(!(a[f+24>>0]|0)){Vc(va+48|0,va+128|0,va,c[f+20>>2]|0,0);n=+g[va+32>>2];if(n<0.0&(a[va+36>>0]|0)!=0){p=+g[va+8>>2];q=+g[va+16>>2];j=c[va+20>>2]|0;o=+g[va+12>>2];qa=111}}else{z=c[d+12>>2]|0;D=c[e+12>>2]|0;c[6418]=(c[6418]|0)+1;ha=+g[U+64>>2];ia=+g[U+68>>2];n=+g[z+4>>2];ja=+g[U+72>>2];o=+g[z+8>>2];p=+g[z+16>>2];q=+g[z+20>>2];r=+g[z+24>>2];s=+g[z+32>>2];t=+g[z+36>>2];u=+g[z+40>>2];ka=+g[ma+64>>2];la=+g[ma+68>>2];pa=+g[ma+72>>2];na=ha*+g[z>>2]+ia*n+ja*o+ +g[z+48>>2]-(ka*+g[D>>2]+la*+g[D+4>>2]+pa*+g[D+8>>2]+ +g[D+48>>2]);oa=ha*p+ia*q+ja*r+ +g[z+52>>2]-(ka*+g[D+16>>2]+la*+g[D+20>>2]+pa*+g[D+24>>2]+ +g[D+52>>2]);pa=ha*s+ia*t+ja*u+ +g[z+56>>2]-(ka*+g[D+32>>2]+la*+g[D+36>>2]+pa*+g[D+40>>2]+ +g[D+56>>2]);l=c[U+28>>2]|0;c:do if((l|0)>0){A=o;B=p;y=q;C=0.0;E=3402823466385288598117041.0e14;k=0;p=0.0;q=0.0;o=0.0;while(1){f=c[U+36>>2]|0;ja=+g[f+(k*36|0)+20>>2];ka=+g[f+(k*36|0)+24>>2];la=+g[f+(k*36|0)+28>>2];w=ja*+g[z>>2]+ka*n+la*A;r=ja*B+ka*y+la*r;n=ja*s+ka*t+la*u;g[va+296>>2]=w;g[va+296+4>>2]=r;g[va+296+8>>2]=n;g[va+296+12>>2]=0.0;if(na*w+oa*r+pa*n<0.0){g[va+296>>2]=-w;g[va+296+4>>2]=-r;g[va+296+8>>2]=-n;x=-w;r=-r;n=-n}else x=w;c[6416]=(c[6416]|0)+1;if(Qi(z,D,na,oa,pa,x,r,n,U,ma,E)|0){c[6417]=(c[6417]|0)+1;gh(U,z,va+296|0,va+624|0,va+384|0,va+360|0,va+344|0);gh(ma,D,va+296|0,va+380|0,va+376|0,va+328|0,va+312|0);s=+g[va+384>>2];t=+g[va+380>>2];do if(s>2];w=+g[va+624>>2];if(u=(l|0)){n=w;break c}n=+g[z+4>>2];A=+g[z+8>>2];B=+g[z+16>>2];y=+g[z+20>>2];r=+g[z+24>>2];s=+g[z+32>>2];t=+g[z+36>>2];u=+g[z+40>>2];C=x;E=w;k=j}break b}else{n=3402823466385288598117041.0e14;p=0.0;q=0.0;o=0.0}while(0);l=c[ma+28>>2]|0;d:do if((l|0)>0){A=0.0;k=0;while(1){f=c[ma+36>>2]|0;ka=+g[f+(k*36|0)+20>>2];la=+g[f+(k*36|0)+24>>2];t=+g[f+(k*36|0)+28>>2];r=ka*+g[D>>2]+la*+g[D+4>>2]+t*+g[D+8>>2];s=ka*+g[D+16>>2]+la*+g[D+20>>2]+t*+g[D+24>>2];t=ka*+g[D+32>>2]+la*+g[D+36>>2]+t*+g[D+40>>2];g[va+296>>2]=r;g[va+296+4>>2]=s;g[va+296+8>>2]=t;g[va+296+12>>2]=0.0;if(na*r+oa*s+pa*t<0.0){g[va+296>>2]=-r;g[va+296+4>>2]=-s;g[va+296+8>>2]=-t;r=-r;s=-s;t=-t}c[6416]=(c[6416]|0)+1;if(Qi(z,D,na,oa,pa,r,s,t,U,ma,n)|0){c[6417]=(c[6417]|0)+1;gh(U,z,va+296|0,va+624|0,va+384|0,va+360|0,va+344|0);gh(ma,D,va+296|0,va+380|0,va+376|0,va+328|0,va+312|0);u=+g[va+384>>2];w=+g[va+380>>2];do if(u>2];y=+g[va+624>>2];if(x=(l|0))break d;else A=u}break b}while(0);j=c[U+48>>2]|0;e:do if((j|0)>0){l=c[ma+48>>2]|0;t=0.0;v=0;k=-1;m=-1;x=0.0;y=0.0;A=0.0;B=0.0;V=0.0;W=0.0;Y=0.0;r=0.0;s=0.0;P=0.0;M=0.0;L=0.0;E=0.0;I=0.0;K=0.0;u=0.0;w=0.0;C=0.0;f:while(1){f=c[U+56>>2]|0;ha=+g[f+(v<<4)>>2];ia=+g[f+(v<<4)+4>>2];la=+g[f+(v<<4)+8>>2];ja=ha*+g[z>>2]+ia*+g[z+4>>2]+la*+g[z+8>>2];ka=ha*+g[z+16>>2]+ia*+g[z+20>>2]+la*+g[z+24>>2];la=ha*+g[z+32>>2]+ia*+g[z+36>>2]+la*+g[z+40>>2];if((l|0)>0){X=t;l=0;ia=p;ha=q;ga=o;_=x;aa=y;ca=A;while(1){f=c[ma+56>>2]|0;ea=+g[f+(l<<4)>>2];fa=+g[f+(l<<4)+4>>2];ba=+g[f+(l<<4)+8>>2];Z=ea*+g[D>>2]+fa*+g[D+4>>2]+ba*+g[D+8>>2];$=ea*+g[D+16>>2]+fa*+g[D+20>>2]+ba*+g[D+24>>2];ba=ea*+g[D+32>>2]+fa*+g[D+36>>2]+ba*+g[D+40>>2];g[va+296>>2]=ka*ba-la*$;g[va+296+4>>2]=la*Z-ja*ba;g[va+296+8>>2]=ja*$-ka*Z;g[va+296+12>>2]=0.0;do if(!(+N(+(ka*ba-la*$))>1.0e-06)){if(+N(+(la*Z-ja*ba))>1.0e-06){qa=75;break}if(!(+N(+(ja*$-ka*Z))>1.0e-06)){p=ia;q=ha;o=ga;da=B;ea=V;fa=W}else qa=75}else qa=75;while(0);do if((qa|0)==75){qa=0;q=1.0/+O(+((ka*ba-la*$)*(ka*ba-la*$)+(la*Z-ja*ba)*(la*Z-ja*ba)+(ja*$-ka*Z)*(ja*$-ka*Z)));p=(ka*ba-la*$)*q;g[va+296>>2]=p;o=(la*Z-ja*ba)*q;g[va+296+4>>2]=o;q=(ja*$-ka*Z)*q;g[va+296+8>>2]=q;if(p*na+o*oa+pa*q<0.0){g[va+296>>2]=-p;g[va+296+4>>2]=-o;g[va+296+8>>2]=-q;p=-p;o=-o;q=-q}c[6416]=(c[6416]|0)+1;if(!(Qi(z,D,na,oa,pa,p,o,q,U,ma,n)|0)){p=ia;q=ha;o=ga;da=B;ea=V;fa=W;break}c[6417]=(c[6417]|0)+1;gh(U,z,va+296|0,va+624|0,va+384|0,va+360|0,va+344|0);gh(ma,D,va+296|0,va+380|0,va+376|0,va+328|0,va+312|0);t=+g[va+384>>2];x=+g[va+380>>2];do if(!(t>2];A=+g[va+624>>2];if(y>2];y=+g[va+344+4>>2];A=+g[va+344+8>>2];B=+g[va+328>>2];V=+g[va+328+4>>2];W=+g[va+328+8>>2];break}else{j=1;t=y-A;x=+g[va+360>>2];y=+g[va+360+4>>2];A=+g[va+360+8>>2];B=+g[va+312>>2];V=+g[va+312+4>>2];W=+g[va+312+8>>2];break}}else{j=0;t=X;x=_;y=aa;A=ca}while(0);if(!j)break f;if(!(t>2]|0;if((l|0)>=(j|0))break;else{ia=p;ha=q;ga=o;B=da;V=ea;W=fa}}l=j;j=c[U+48>>2]|0;t=X;x=_;y=aa;A=ca;B=da;V=ea;W=fa;X=Y}else X=Y;v=v+1|0;if((v|0)>=(j|0)){j=m;n=X;break e}else Y=X}break b}else{k=-1;j=-1;n=0.0;r=0.0;s=0.0;P=0.0;M=0.0;L=0.0;E=0.0;I=0.0;K=0.0;u=0.0;w=0.0;C=0.0}while(0);if((j|k|0)>-1){y=P-n;A=M-r;B=L-s;r=u*E+w*I+C*K;s=y*E+A*I+B*K;n=y*u+A*w+B*C;do if(1.0-r*r==0.0)t=0.0;else{if((s-n*r)/(1.0-r*r)<-1000000015047466219876688.0e6){t=-1000000015047466219876688.0e6;break}if(!((s-n*r)/(1.0-r*r)>1000000015047466219876688.0e6)){t=(s-n*r)/(1.0-r*r);break}t=1000000015047466219876688.0e6}while(0);n=r*t-n;do if(n<-1000000015047466219876688.0e6){if(s-r*1000000015047466219876688.0e6<-1000000015047466219876688.0e6){r=-1000000015047466219876688.0e6;n=-1000000015047466219876688.0e6;break}if(!(s-r*1000000015047466219876688.0e6>1000000015047466219876688.0e6)){r=s-r*1000000015047466219876688.0e6;n=-1000000015047466219876688.0e6;break}r=1000000015047466219876688.0e6;n=-1000000015047466219876688.0e6}else{if(!(n>1000000015047466219876688.0e6)){r=t;break}if(s+r*1000000015047466219876688.0e6<-1000000015047466219876688.0e6){r=-1000000015047466219876688.0e6;n=1000000015047466219876688.0e6;break}if(!(s+r*1000000015047466219876688.0e6>1000000015047466219876688.0e6)){r=s+r*1000000015047466219876688.0e6;n=1000000015047466219876688.0e6;break}r=1000000015047466219876688.0e6;n=1000000015047466219876688.0e6}while(0);x=u*n;w=w*n;u=C*n;t=x+(y-E*r);s=w+(A-I*r);n=u+(B-K*r);g[va+624>>2]=t;g[va+624+4>>2]=s;g[va+624+8>>2]=n;g[va+624+12>>2]=0.0;if(t*t+s*s+n*n>1.1920928955078125e-07){r=+O(+(t*t+s*s+n*n));g[va+624>>2]=t*(1.0/r);g[va+624+4>>2]=1.0/r*s;g[va+624+8>>2]=1.0/r*n;if(t*(1.0/r)*na+1.0/r*s*oa+1.0/r*n*pa<0.0){g[va+624>>2]=-(t*(1.0/r));g[va+624+4>>2]=-(1.0/r*s);g[va+624+8>>2]=-(1.0/r*n)}g[va+384>>2]=P+x;g[va+384+4>>2]=M+w;g[va+384+8>>2]=L+u;g[va+384+12>>2]=0.0;hc[c[(c[h>>2]|0)+16>>2]&15](h,va+624|0,va+384|0,-r)}}if(na*p+oa*o+pa*q<0.0){n=-1000000015047466219876688.0e6;p=-p;q=-q;j=0;o=-o;qa=111}else{n=-1000000015047466219876688.0e6;j=0;qa=111}}while(0);if((qa|0)==111){U=c[sa+52>>2]|0;f=c[ta+52>>2]|0;T=c[d+12>>2]|0;S=c[e+12>>2]|0;K=n-ra;C=1.0/+O(+(p*p+o*o+q*q));I=p*C;E=o*C;C=q*C;g[va+624>>2]=I;g[va+624+4>>2]=E;g[va+624+8>>2]=C;c[va+624+12>>2]=j;k=c[f+28>>2]|0;v=c[f+36>>2]|0;if((k|0)>0){n=+g[S>>2];o=+g[S+4>>2];p=+g[S+8>>2];q=+g[S+16>>2];r=+g[S+20>>2];s=+g[S+24>>2];t=+g[S+32>>2];u=+g[S+36>>2];w=+g[S+40>>2];j=-1;B=-3402823466385288598117041.0e14;m=0;while(1){x=+g[v+(m*36|0)+20>>2];y=+g[v+(m*36|0)+24>>2];A=+g[v+(m*36|0)+28>>2];l=(x*n+y*o+A*p)*I+(x*q+y*r+A*s)*E+(x*t+y*u+A*w)*C>B;j=l?m:j;m=m+1|0;if((m|0)==(k|0)){H=j;break}else B=l?(x*n+y*o+A*p)*I+(x*q+y*r+A*s)*E+(x*t+y*u+A*w)*C:B}}else H=-1;a[va+384+16>>0]=1;J=va+384+12|0;c[J>>2]=0;F=va+384+4|0;c[F>>2]=0;c[va+384+8>>2]=0;G=c[v+(H*36|0)+4>>2]|0;g:do if((G|0)>0){D=v+(H*36|0)+12|0;j=0;l=0;k=0;while(1){d=c[(c[D>>2]|0)+(k<<2)>>2]|0;e=c[f+16>>2]|0;oa=+g[e+(d<<4)>>2];pa=+g[e+(d<<4)+4>>2];p=+g[e+(d<<4)+8>>2];n=oa*+g[S>>2]+pa*+g[S+4>>2]+p*+g[S+8>>2]+ +g[S+48>>2];o=oa*+g[S+16>>2]+pa*+g[S+20>>2]+p*+g[S+24>>2]+ +g[S+52>>2];p=oa*+g[S+32>>2]+pa*+g[S+36>>2]+p*+g[S+40>>2]+ +g[S+56>>2];if((j|0)==(l|0)){z=l|0?l<<1:1;if((l|0)<(z|0)){if(!z){v=0;j=l}else{c[6435]=(c[6435]|0)+1;j=yc((z<<4|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}v=j;j=c[F>>2]|0}m=c[J>>2]|0;if((j|0)<=0){if(m)qa=126}else{l=0;do{d=v+(l<<4)|0;e=m+(l<<4)|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];l=l+1|0}while((l|0)!=(j|0));qa=126}if((qa|0)==126){qa=0;if(a[va+384+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0);j=c[F>>2]|0}c[J>>2]=0}a[va+384+16>>0]=1;c[J>>2]=v;c[va+384+8>>2]=z}else j=l}d=c[J>>2]|0;g[d+(j<<4)>>2]=n;g[d+(j<<4)+4>>2]=o;g[d+(j<<4)+8>>2]=p;g[d+(j<<4)+12>>2]=0.0;j=(c[F>>2]|0)+1|0;c[F>>2]=j;k=k+1|0;if((k|0)>=(G|0))break g;l=c[va+384+8>>2]|0}}while(0);if((H|0)>-1)Wc(va+624|0,U,T,va+384|0,K,ra,h);j=c[J>>2]|0;if(j|0){if(a[va+384+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[J>>2]=0}}if(a[b+16>>0]|0?(ua=c[h+4>>2]|0,c[ua+748>>2]|0):0){k=c[ua+740>>2]|0;l=c[(c[h+8>>2]|0)+8>>2]|0;j=c[(c[h+12>>2]|0)+8>>2]|0;if((k|0)==(l|0)){ef(ua,k+4|0,j+4|0);break}else{ef(ua,j+4|0,l+4|0);break}}}while(0);i=va;return}while(0)}Vc(va+48|0,va+128|0,h,c[f+20>>2]|0,0);if((c[b+28>>2]|0?(c[(c[h+4>>2]|0)+748>>2]|0)<(c[b+32>>2]|0):0)?(K=+g[va+48+4>>2],L=+g[va+48+8>>2],M=+g[va+48+12>>2],K*K+L*L+M*M>1.1920928955078125e-07):0){B=1.0/(K*K+L*L+M*M);if(+N(+(M*B))>.7071067690849304){I=1.0/+O(+(M*B*M*B+L*B*L*B));C=0.0;E=L*B*I;I=-(M*B*I)}else{I=1.0/+O(+(K*B*K*B+L*B*L*B));C=-(L*B*I);E=0.0;I=K*B*I}A=+Sb[c[(c[sa>>2]|0)+16>>2]&15](sa);x=+Sb[c[(c[ta>>2]|0)+16>>2]&15](ta);n=.019999999552965164/(A>2]=c[va+128>>2];c[va+624+4>>2]=c[va+128+4>>2];c[va+624+8>>2]=c[va+128+8>>2];c[va+624+12>>2]=c[va+128+12>>2];c[va+624+16>>2]=c[l>>2];c[va+624+16+4>>2]=c[l+4>>2];c[va+624+16+8>>2]=c[l+8>>2];c[va+624+16+12>>2]=c[l+12>>2];c[va+624+32>>2]=c[v>>2];c[va+624+32+4>>2]=c[v+4>>2];c[va+624+32+8>>2]=c[v+8>>2];c[va+624+32+12>>2]=c[v+12>>2];c[va+624+48>>2]=c[z>>2];c[va+624+48+4>>2]=c[z+4>>2];c[va+624+48+8>>2]=c[z+8>>2];c[va+624+48+12>>2]=c[z+12>>2]}else{c[va+624>>2]=c[D>>2];c[va+624+4>>2]=c[D+4>>2];c[va+624+8>>2]=c[D+8>>2];c[va+624+12>>2]=c[D+12>>2];c[va+624+16>>2]=c[F>>2];c[va+624+16+4>>2]=c[F+4>>2];c[va+624+16+8>>2]=c[F+8>>2];c[va+624+16+12>>2]=c[F+12>>2];c[va+624+32>>2]=c[G>>2];c[va+624+32+4>>2]=c[G+4>>2];c[va+624+32+8>>2]=c[G+8>>2];c[va+624+32+12>>2]=c[G+12>>2];c[va+624+48>>2]=c[H>>2];c[va+624+48+4>>2]=c[H+4>>2];c[va+624+48+8>>2]=c[H+8>>2];c[va+624+48+12>>2]=c[H+12>>2]}j=c[b+28>>2]|0;if((j|0)>0){y=C*C+I*I+E*E;w=(n>.39269909262657166?.39269909262657166:n)*.5;k=0;do{if(y>1.1920928955078125e-07){t=+R(+w)/+O(+y);r=C*t;s=I*t;t=E*t;u=+Q(+w);q=+(k|0)*(6.2831854820251465/+(j|0))*.5;p=+R(+q)/+O(+(M*B*M*B+(K*B*K*B+L*B*L*B)));n=K*B*p;o=L*B*p;p=M*B*p;q=+Q(+q);if(A>2]|0;ba=+g[ua>>2];ca=+g[ua+16>>2];da=+g[ua+32>>2];ea=+g[ua+4>>2];fa=+g[ua+20>>2];ga=+g[ua+36>>2];ha=+g[ua+8>>2];ka=+g[ua+24>>2];ra=+g[ua+40>>2];g[va+128>>2]=(1.0-(oa*pa+aa*ia))*ba+(la*pa-ja*ia)*ca+(la*ia+ja*pa)*da;g[va+128+4>>2]=(1.0-(oa*pa+aa*ia))*ea+(la*pa-ja*ia)*fa+(la*ia+ja*pa)*ga;g[va+128+8>>2]=(1.0-(oa*pa+aa*ia))*ha+(la*pa-ja*ia)*ka+(la*ia+ja*pa)*ra;g[va+128+12>>2]=0.0;g[va+128+16>>2]=(la*pa+ja*ia)*ba+(1.0-(la*na+aa*ia))*ca+(oa*ia-ja*na)*da;g[va+128+20>>2]=(la*pa+ja*ia)*ea+(1.0-(la*na+aa*ia))*fa+(oa*ia-ja*na)*ga;g[va+128+24>>2]=(la*pa+ja*ia)*ha+(1.0-(la*na+aa*ia))*ka+(oa*ia-ja*na)*ra;g[va+128+28>>2]=0.0;g[va+128+32>>2]=(la*ia-ja*pa)*ba+(oa*ia+ja*na)*ca+(1.0-(la*na+oa*pa))*da;g[va+128+36>>2]=(la*ia-ja*pa)*ea+(oa*ia+ja*na)*fa+(1.0-(la*na+oa*pa))*ga;g[va+128+40>>2]=(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+(t*q+u*-p)-r*-o))-n*(r*-p+(s*q+u*-o)-t*-n);ja=q*(u*q-r*-n-s*-o-t*-p)-n*(t*-o+(r*q+u*-n)-s*-p)-o*(r*-p+(s*q+u*-o)-t*-n)-p*(s*-n+(t*q+u*-p)-r*-o);na=la*(2.0/(ja*ja+(aa*aa+(la*la+oa*oa))));pa=oa*(2.0/(ja*ja+(aa*aa+(la*la+oa*oa))));ia=aa*(2.0/(ja*ja+(aa*aa+(la*la+oa*oa))));ua=c[e+12>>2]|0;ba=+g[ua>>2];ca=+g[ua+16>>2];da=+g[ua+32>>2];ea=+g[ua+4>>2];fa=+g[ua+20>>2];ga=+g[ua+36>>2];ha=+g[ua+8>>2];ka=+g[ua+24>>2];ra=+g[ua+40>>2];g[va+128+64>>2]=(1.0-(oa*pa+aa*ia))*ba+(la*pa-ja*ia)*ca+(la*ia+ja*pa)*da;g[va+128+68>>2]=(1.0-(oa*pa+aa*ia))*ea+(la*pa-ja*ia)*fa+(la*ia+ja*pa)*ga;g[va+128+72>>2]=(1.0-(oa*pa+aa*ia))*ha+(la*pa-ja*ia)*ka+(la*ia+ja*pa)*ra;g[va+128+76>>2]=0.0;g[va+128+80>>2]=(la*pa+ja*ia)*ba+(1.0-(la*na+aa*ia))*ca+(oa*ia-ja*na)*da;g[va+128+84>>2]=(la*pa+ja*ia)*ea+(1.0-(la*na+aa*ia))*fa+(oa*ia-ja*na)*ga;g[va+128+88>>2]=(la*pa+ja*ia)*ha+(1.0-(la*na+aa*ia))*ka+(oa*ia-ja*na)*ra;g[va+128+92>>2]=0.0;g[va+128+96>>2]=(la*ia-ja*pa)*ba+(oa*ia+ja*na)*ca+(1.0-(la*na+oa*pa))*da;g[va+128+100>>2]=(la*ia-ja*pa)*ea+(oa*ia+ja*na)*fa+(1.0-(la*na+oa*pa))*ga;g[va+128+104>>2]=(la*ia-ja*pa)*ha+(oa*ia+ja*na)*ka+(1.0-(la*na+oa*pa))*ra;g[va+128+108>>2]=0.0}j=c[f+20>>2]|0;c[va+384>>2]=6136;c[va+384+32>>2]=h;c[va+384+36>>2]=c[va+128>>2];c[va+384+36+4>>2]=c[va+128+4>>2];c[va+384+36+8>>2]=c[va+128+8>>2];c[va+384+36+12>>2]=c[va+128+12>>2];c[va+384+52>>2]=c[l>>2];c[va+384+52+4>>2]=c[l+4>>2];c[va+384+52+8>>2]=c[l+8>>2];c[va+384+52+12>>2]=c[l+12>>2];c[va+384+68>>2]=c[v>>2];c[va+384+68+4>>2]=c[v+4>>2];c[va+384+68+8>>2]=c[v+8>>2];c[va+384+68+12>>2]=c[v+12>>2];c[va+384+84>>2]=c[z>>2];c[va+384+84+4>>2]=c[z+4>>2];c[va+384+84+8>>2]=c[z+8>>2];c[va+384+84+12>>2]=c[z+12>>2];c[va+384+100>>2]=c[D>>2];c[va+384+100+4>>2]=c[D+4>>2];c[va+384+100+8>>2]=c[D+8>>2];c[va+384+100+12>>2]=c[D+12>>2];c[va+384+116>>2]=c[F>>2];c[va+384+116+4>>2]=c[F+4>>2];c[va+384+116+8>>2]=c[F+8>>2];c[va+384+116+12>>2]=c[F+12>>2];c[va+384+132>>2]=c[G>>2];c[va+384+132+4>>2]=c[G+4>>2];c[va+384+132+8>>2]=c[G+8>>2];c[va+384+132+12>>2]=c[G+12>>2];c[va+384+148>>2]=c[H>>2];c[va+384+148+4>>2]=c[H+4>>2];c[va+384+148+8>>2]=c[H+8>>2];c[va+384+148+12>>2]=c[H+12>>2];c[va+384+164>>2]=c[va+624>>2];c[va+384+164+4>>2]=c[va+624+4>>2];c[va+384+164+8>>2]=c[va+624+8>>2];c[va+384+164+12>>2]=c[va+624+12>>2];c[va+384+180>>2]=c[va+624+16>>2];c[va+384+180+4>>2]=c[va+624+16+4>>2];c[va+384+180+8>>2]=c[va+624+16+8>>2];c[va+384+180+12>>2]=c[va+624+16+12>>2];c[va+384+196>>2]=c[va+624+32>>2];c[va+384+196+4>>2]=c[va+624+32+4>>2];c[va+384+196+8>>2]=c[va+624+32+8>>2];c[va+384+196+12>>2]=c[va+624+32+12>>2];c[va+384+212>>2]=c[va+624+48>>2];c[va+384+212+4>>2]=c[va+624+48+4>>2];c[va+384+212+8>>2]=c[va+624+48+8>>2];c[va+384+212+12>>2]=c[va+624+48+12>>2];a[va+384+228>>0]=A>2]=j;Vc(va+48|0,va+128|0,va+384|0,j,0);j=c[b+28>>2]|0}k=k+1|0}while((k|0)<(j|0))}}if(!(a[b+16>>0]|0)){i=va;return}k=c[h+4>>2]|0;if(!(c[k+748>>2]|0)){i=va;return}l=c[k+740>>2]|0;m=c[(c[h+8>>2]|0)+8>>2]|0;j=c[(c[h+12>>2]|0)+8>>2]|0;if((l|0)==(m|0)){ef(k,l+4|0,j+4|0);i=va;return}else{ef(k,j+4|0,m+4|0);i=va;return}}function pc(d){d=d|0;var e=0,f=0,h=0,j=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0,M=0,N=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0,fa=0.0,ga=0.0,ha=0.0;X=i;i=i+1024|0;tc(d);if(!(Eb[c[(c[d>>2]|0)+20>>2]&127](d)|0)){i=X;return}if((c[d+328>>2]|0)<=0){i=X;return}Q=X+944+32|0;R=X+944+52|0;W=0;do{S=c[(c[d+336>>2]|0)+(W<<2)>>2]|0;if(Eb[c[(c[d>>2]|0)+20>>2]&127](d)|0?(M=Eb[c[(c[d>>2]|0)+20>>2]&127](d)|0,(Eb[c[(c[M>>2]|0)+48>>2]&127](M)|0)&1|0):0){e=c[d+72>>2]|0;if(!(a[S+473>>0]|0))M=e;else{c[X+864>>2]=c[S+520>>2];c[X+864+4>>2]=c[S+520+4>>2];c[X+864+8>>2]=c[S+520+8>>2];c[X+864+12>>2]=c[S+520+12>>2];j=+g[S+584>>2];l=+g[S+536>>2];m=+g[S+600>>2];u=+g[S+540>>2];v=+g[S+616>>2];w=+g[S+544>>2];x=+g[S+588>>2];y=+g[S+604>>2];z=+g[S+620>>2];A=+g[S+592>>2];B=+g[S+608>>2];D=+g[S+624>>2];E=+g[S+552>>2];F=+g[S+556>>2];G=+g[S+560>>2];H=+g[S+568>>2];I=+g[S+572>>2];J=+g[S+576>>2];ha=j*l+m*u+v*w+(l*x+u*y+w*z)*0.0+(l*A+u*B+w*D)*0.0;fa=(A*E+B*F+D*G)*0.0+(j*E+m*F+v*G+(x*E+y*F+z*G)*0.0);ea=(A*H+B*I+D*J)*0.0+(j*H+m*I+v*J+(x*H+y*I+z*J)*0.0);ga=1.0/+O(+(ha*ha+fa*fa+ea*ea));da=(j*l+m*u+v*w)*0.0+(l*x+u*y+w*z)+(l*A+u*B+w*D)*0.0;ba=(A*E+B*F+D*G)*0.0+(x*E+y*F+z*G+(j*E+m*F+v*G)*0.0);aa=(A*H+B*I+D*J)*0.0+(x*H+y*I+z*J+(j*H+m*I+v*J)*0.0);ca=1.0/+O(+(da*da+ba*ba+aa*aa));$=(j*l+m*u+v*w)*0.0+(l*x+u*y+w*z)*0.0+(l*A+u*B+w*D);Z=A*E+B*F+D*G+((j*E+m*F+v*G)*0.0+(x*E+y*F+z*G)*0.0);Y=A*H+B*I+D*J+((j*H+m*I+v*J)*0.0+(x*H+y*I+z*J)*0.0);_=1.0/+O(+($*$+Z*Z+Y*Y));M=c[(c[e>>2]|0)+8>>2]|0;fa=fa*ga*10.0+ +g[X+864+4>>2];ea=ga*ea*10.0+ +g[X+864+8>>2];g[X+848>>2]=ha*ga*10.0+ +g[X+864>>2];g[X+848+4>>2]=fa;g[X+848+8>>2]=ea;g[X+848+12>>2]=0.0;c[X+832>>2]=1065353216;c[X+832+4>>2]=0;c[X+832+8>>2]=0;g[X+832+12>>2]=0.0;mc[M&127](e,X+864|0,X+848|0,X+832|0);M=c[(c[e>>2]|0)+8>>2]|0;ba=ba*ca*10.0+ +g[X+864+4>>2];aa=ca*aa*10.0+ +g[X+864+8>>2];g[X+816>>2]=da*ca*10.0+ +g[X+864>>2];g[X+816+4>>2]=ba;g[X+816+8>>2]=aa;g[X+816+12>>2]=0.0;c[X+800>>2]=0;c[X+800+4>>2]=1065353216;c[X+800+8>>2]=0;g[X+800+12>>2]=0.0;mc[M&127](e,X+864|0,X+816|0,X+800|0);M=c[(c[e>>2]|0)+8>>2]|0;Z=Z*_*10.0+ +g[X+864+4>>2];Y=_*Y*10.0+ +g[X+864+8>>2];g[X+784>>2]=$*_*10.0+ +g[X+864>>2];g[X+784+4>>2]=Z;g[X+784+8>>2]=Y;g[X+784+12>>2]=0.0;c[X+768>>2]=0;c[X+768+4>>2]=0;c[X+768+8>>2]=1065353216;g[X+768+12>>2]=0.0;mc[M&127](e,X+864|0,X+784|0,X+768|0);if((c[S+484>>2]|0)>0){f=0;do{M=c[S+492>>2]|0;da=+g[M+(f<<4)>>2];ea=+g[M+(f<<4)+4>>2];ha=+g[M+(f<<4)+8>>2];fa=+g[X+864>>2]+((j*l+m*u+v*w)*da+(l*x+u*y+w*z)*ea+(l*A+u*B+w*D)*ha);ga=+g[X+864+4>>2]+((j*E+m*F+v*G)*da+(x*E+y*F+z*G)*ea+(A*E+B*F+D*G)*ha);ha=(j*H+m*I+v*J)*da+(x*H+y*I+z*J)*ea+(A*H+B*I+D*J)*ha+ +g[X+864+8>>2];c[X+752>>2]=1065353216;c[X+752+4>>2]=0;c[X+752+8>>2]=1065353216;g[X+752+12>>2]=0.0;M=c[(c[e>>2]|0)+8>>2]|0;g[X+1008>>2]=fa+-.10000000149011612;g[X+1008+4>>2]=ga;g[X+1008+8>>2]=ha;g[X+1008+12>>2]=0.0;g[X+944>>2]=fa+.10000000149011612;g[X+944+4>>2]=ga+0.0;g[X+944+8>>2]=ha+0.0;g[X+944+12>>2]=0.0;mc[M&127](e,X+1008|0,X+944|0,X+752|0);M=c[(c[e>>2]|0)+8>>2]|0;g[X+928>>2]=fa;g[X+928+4>>2]=ga+-.10000000149011612;g[X+928+8>>2]=ha;g[X+928+12>>2]=0.0;g[X+912>>2]=fa+0.0;g[X+912+4>>2]=ga+.10000000149011612;g[X+912+8>>2]=ha+0.0;g[X+912+12>>2]=0.0;mc[M&127](e,X+928|0,X+912|0,X+752|0);M=c[(c[e>>2]|0)+8>>2]|0;g[X+896>>2]=fa;g[X+896+4>>2]=ga;g[X+896+8>>2]=ha+-.10000000149011612;g[X+896+12>>2]=0.0;g[X+880>>2]=fa+0.0;g[X+880+4>>2]=ga+0.0;g[X+880+8>>2]=ha+.10000000149011612;g[X+880+12>>2]=0.0;mc[M&127](e,X+896|0,X+880|0,X+752|0);f=f+1|0}while((f|0)<(c[S+484>>2]|0))}M=c[d+72>>2]|0}L=c[d+344>>2]|0;c[X+864>>2]=0;c[X+864+4>>2]=0;c[X+864+8>>2]=0;c[X+864+12>>2]=0;c[X+848>>2]=1065353216;c[X+848+4>>2]=1065353216;c[X+848+8>>2]=1065353216;g[X+848+12>>2]=0.0;c[X+832>>2]=1065353216;c[X+832+4>>2]=0;c[X+832+8>>2]=0;g[X+832+12>>2]=0.0;if(!(L&256)){if(L&1|0?(T=c[S+712>>2]|0,(T|0)>0):0){e=T;h=0;do{f=c[S+720>>2]|0;if(c[(c[f+(h*104|0)+4>>2]|0)+16>>2]&1){e=c[(c[M>>2]|0)+8>>2]|0;K=f+(h*104|0)+8|0;s=f+(h*104|0)+12|0;q=c[s>>2]|0;t=f+(h*104|0)+16|0;r=c[t>>2]|0;g[X+800>>2]=+g[K>>2]+-.10000000149011612;c[X+800+4>>2]=q;c[X+800+8>>2]=r;g[X+800+12>>2]=0.0;ga=+g[s>>2]+0.0;ha=+g[t>>2]+0.0;g[X+784>>2]=+g[K>>2]+.10000000149011612;g[X+784+4>>2]=ga;g[X+784+8>>2]=ha;g[X+784+12>>2]=0.0;c[X+768>>2]=1065353216;c[X+768+4>>2]=0;c[X+768+8>>2]=0;g[X+768+12>>2]=0.0;mc[e&127](M,X+800|0,X+784|0,X+768|0);e=c[(c[M>>2]|0)+8>>2]|0;ha=+g[s>>2]+-.10000000149011612;r=c[t>>2]|0;c[X+752>>2]=c[K>>2];g[X+752+4>>2]=ha;c[X+752+8>>2]=r;g[X+752+12>>2]=0.0;ha=+g[s>>2]+.10000000149011612;ga=+g[t>>2]+0.0;g[X+736>>2]=+g[K>>2]+0.0;g[X+736+4>>2]=ha;g[X+736+8>>2]=ga;g[X+736+12>>2]=0.0;c[X+720>>2]=0;c[X+720+4>>2]=1065353216;c[X+720+8>>2]=0;g[X+720+12>>2]=0.0;mc[e&127](M,X+752|0,X+736|0,X+720|0);e=c[(c[M>>2]|0)+8>>2]|0;r=c[s>>2]|0;ga=+g[t>>2]+-.10000000149011612;c[X+704>>2]=c[K>>2];c[X+704+4>>2]=r;g[X+704+8>>2]=ga;g[X+704+12>>2]=0.0;ga=+g[s>>2]+0.0;ha=+g[t>>2]+.10000000149011612;g[X+688>>2]=+g[K>>2]+0.0;g[X+688+4>>2]=ga;g[X+688+8>>2]=ha;g[X+688+12>>2]=0.0;c[X+672>>2]=0;c[X+672+4>>2]=0;c[X+672+8>>2]=1065353216;g[X+672+12>>2]=0.0;mc[e&127](M,X+704|0,X+688|0,X+672|0);e=c[S+712>>2]|0}h=h+1|0}while((h|0)<(e|0))}if(L&2|0?(U=c[S+732>>2]|0,(U|0)>0):0){e=U;h=0;do{f=c[S+740>>2]|0;if(c[(c[f+(h*52|0)+4>>2]|0)+16>>2]&1){mc[c[(c[M>>2]|0)+8>>2]&127](M,(c[f+(h*52|0)+8>>2]|0)+8|0,(c[f+(h*52|0)+12>>2]|0)+8|0,X+864|0);e=c[S+732>>2]|0}h=h+1|0}while((h|0)<(e|0))}if(L&16|0?(V=c[S+712>>2]|0,(V|0)>0):0){e=V;h=0;do{f=c[S+720>>2]|0;if(c[(c[f+(h*104|0)+4>>2]|0)+16>>2]&1){fa=+g[f+(h*104|0)+72>>2]*.5;ha=+g[f+(h*104|0)+76>>2]*.5;ga=+g[f+(h*104|0)+80>>2]*.5;K=c[(c[M>>2]|0)+8>>2]|0;e=f+(h*104|0)+8|0;s=f+(h*104|0)+12|0;da=ha+ +g[s>>2];t=f+(h*104|0)+16|0;ea=ga+ +g[t>>2];g[X+656>>2]=fa+ +g[e>>2];g[X+656+4>>2]=da;g[X+656+8>>2]=ea;g[X+656+12>>2]=0.0;mc[K&127](M,e,X+656|0,X+848|0);K=c[(c[M>>2]|0)+8>>2]|0;ha=+g[s>>2]-ha;ga=+g[t>>2]-ga;g[X+640>>2]=+g[e>>2]-fa;g[X+640+4>>2]=ha;g[X+640+8>>2]=ga;g[X+640+12>>2]=0.0;ga=+g[X+848+4>>2]*.5;ha=+g[X+848+8>>2]*.5;g[X+624>>2]=+g[X+848>>2]*.5;g[X+624+4>>2]=ga;g[X+624+8>>2]=ha;g[X+624+12>>2]=0.0;mc[K&127](M,e,X+640|0,X+624|0);e=c[S+712>>2]|0}h=h+1|0}while((h|0)<(e|0))}if(L&32|0){if((a[22536]|0)==0?Wa(22536)|0:0){c[5803]=1065353216;c[5804]=0;c[5805]=0;c[5806]=0;c[5807]=0;c[5808]=1065353216;c[5809]=0;c[5810]=0;c[5811]=0;c[5812]=0;c[5813]=1065353216;g[5814]=0.0;_a(22536)}if((c[S+812>>2]|0)>0){e=0;do{K=c[S+820>>2]|0;s=c[K+(e*104|0)+24>>2]|0;E=+g[s+8>>2];t=K+(e*104|0)+4|0;F=+g[t>>2];I=+g[s+12>>2];r=K+(e*104|0)+8|0;J=+g[r>>2];ga=+g[s+16>>2];s=K+(e*104|0)+12|0;ea=+g[s>>2];ca=+g[K+(e*104|0)+20>>2]+(E*F+I*J+ga*ea);g[X+1008>>2]=E-F*ca;g[X+1008+4>>2]=I-J*ca;g[X+1008+8>>2]=ga-ea*ca;g[X+1008+12>>2]=0.0;Y=+g[t>>2];_=+g[r>>2];G=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X+528>>2]=1065353216;c[X+528+4>>2]=1065353216;c[X+528+8>>2]=0;g[X+528+12>>2]=0.0;mc[K&127](M,X+1008|0,X+544|0,X+528|0);e=e+1|0}while((e|0)<(c[S+812>>2]|0))}}if(L&4|0?(c[X+1008>>2]=0,c[X+1008+4>>2]=1060320051,c[X+1008+8>>2]=0,g[X+1008+12>>2]=0.0,N=c[S+752>>2]|0,(N|0)>0):0){e=N;h=0;do{f=c[S+760>>2]|0;if(c[(c[f+(h*44|0)+4>>2]|0)+16>>2]&1){e=c[f+(h*44|0)+8>>2]|0;$=+g[e+8>>2];ca=+g[e+12>>2];fa=+g[e+16>>2];e=c[f+(h*44|0)+12>>2]|0;aa=+g[e+8>>2];da=+g[e+12>>2];ga=+g[e+16>>2];e=c[f+(h*44|0)+16>>2]|0;ba=+g[e+8>>2];ea=+g[e+12>>2];ha=+g[e+16>>2];e=c[(c[M>>2]|0)+28>>2]|0;g[X+512>>2]=($+aa+ba)*.3333333432674408+($-($+aa+ba)*.3333333432674408)*.800000011920929;g[X+512+4>>2]=(ca+da+ea)*.3333333432674408+(ca-(ca+da+ea)*.3333333432674408)*.800000011920929;g[X+512+8>>2]=(fa+ga+ha)*.3333333432674408+(fa-(fa+ga+ha)*.3333333432674408)*.800000011920929;g[X+512+12>>2]=0.0;g[X+496>>2]=($+aa+ba)*.3333333432674408+(aa-($+aa+ba)*.3333333432674408)*.800000011920929;g[X+496+4>>2]=(ca+da+ea)*.3333333432674408+(da-(ca+da+ea)*.3333333432674408)*.800000011920929;g[X+496+8>>2]=(fa+ga+ha)*.3333333432674408+(ga-(fa+ga+ha)*.3333333432674408)*.800000011920929;g[X+496+12>>2]=0.0;g[X+480>>2]=($+aa+ba)*.3333333432674408+(ba-($+aa+ba)*.3333333432674408)*.800000011920929;g[X+480+4>>2]=(ca+da+ea)*.3333333432674408+(ea-(ca+da+ea)*.3333333432674408)*.800000011920929;g[X+480+8>>2]=(fa+ga+ha)*.3333333432674408+(ha-(fa+ga+ha)*.3333333432674408)*.800000011920929;g[X+480+12>>2]=0.0;Pb[e&0](M,X+512|0,X+496|0,X+480|0,X+1008|0,1.0);e=c[S+752>>2]|0}h=h+1|0}while((h|0)<(e|0))}if(L&8|0?(c[X+1008>>2]=1050253722,c[X+1008+4>>2]=1050253722,c[X+1008+8>>2]=1060320051,g[X+1008+12>>2]=0.0,P=c[S+772>>2]|0,(P|0)>0):0){e=P;h=0;do{f=c[S+780>>2]|0;if(c[(c[f+(h*104|0)+4>>2]|0)+16>>2]&1){e=c[f+(h*104|0)+8>>2]|0;A=+g[e+8>>2];E=+g[e+12>>2];H=+g[e+16>>2];e=c[f+(h*104|0)+12>>2]|0;B=+g[e+8>>2];F=+g[e+12>>2];I=+g[e+16>>2];e=c[f+(h*104|0)+16>>2]|0;D=+g[e+8>>2];G=+g[e+12>>2];J=+g[e+16>>2];e=c[f+(h*104|0)+20>>2]|0;fa=+g[e+8>>2];ga=+g[e+12>>2];ha=+g[e+16>>2];e=c[(c[M>>2]|0)+28>>2]|0;ca=(A+B+D+fa)*.25+(A-(A+B+D+fa)*.25)*.800000011920929;da=(E+F+G+ga)*.25+(E-(E+F+G+ga)*.25)*.800000011920929;ea=(H+I+J+ha)*.25+(H-(H+I+J+ha)*.25)*.800000011920929;g[X+464>>2]=ca;g[X+464+4>>2]=da;g[X+464+8>>2]=ea;g[X+464+12>>2]=0.0;Y=(A+B+D+fa)*.25+(B-(A+B+D+fa)*.25)*.800000011920929;Z=(E+F+G+ga)*.25+(F-(E+F+G+ga)*.25)*.800000011920929;_=(H+I+J+ha)*.25+(I-(H+I+J+ha)*.25)*.800000011920929;g[X+448>>2]=Y;g[X+448+4>>2]=Z;g[X+448+8>>2]=_;g[X+448+12>>2]=0.0;$=(A+B+D+fa)*.25+(D-(A+B+D+fa)*.25)*.800000011920929;aa=(E+F+G+ga)*.25+(G-(E+F+G+ga)*.25)*.800000011920929;ba=(H+I+J+ha)*.25+(J-(H+I+J+ha)*.25)*.800000011920929;g[X+432>>2]=$;g[X+432+4>>2]=aa;g[X+432+8>>2]=ba;g[X+432+12>>2]=0.0;Pb[e&0](M,X+464|0,X+448|0,X+432|0,X+1008|0,1.0);e=c[(c[M>>2]|0)+28>>2]|0;g[X+416>>2]=ca;g[X+416+4>>2]=da;g[X+416+8>>2]=ea;g[X+416+12>>2]=0.0;g[X+400>>2]=Y;g[X+400+4>>2]=Z;g[X+400+8>>2]=_;g[X+400+12>>2]=0.0;fa=(A+B+D+fa)*.25+(fa-(A+B+D+fa)*.25)*.800000011920929;ga=(E+F+G+ga)*.25+(ga-(E+F+G+ga)*.25)*.800000011920929;ha=(H+I+J+ha)*.25+(ha-(H+I+J+ha)*.25)*.800000011920929;g[X+384>>2]=fa;g[X+384+4>>2]=ga;g[X+384+8>>2]=ha;g[X+384+12>>2]=0.0;Pb[e&0](M,X+416|0,X+400|0,X+384|0,X+1008|0,1.0);e=c[(c[M>>2]|0)+28>>2]|0;g[X+368>>2]=Y;g[X+368+4>>2]=Z;g[X+368+8>>2]=_;g[X+368+12>>2]=0.0;g[X+352>>2]=$;g[X+352+4>>2]=aa;g[X+352+8>>2]=ba;g[X+352+12>>2]=0.0;g[X+336>>2]=fa;g[X+336+4>>2]=ga;g[X+336+8>>2]=ha;g[X+336+12>>2]=0.0;Pb[e&0](M,X+368|0,X+352|0,X+336|0,X+1008|0,1.0);e=c[(c[M>>2]|0)+28>>2]|0;g[X+320>>2]=$;g[X+320+4>>2]=aa;g[X+320+8>>2]=ba;g[X+320+12>>2]=0.0;g[X+304>>2]=ca;g[X+304+4>>2]=da;g[X+304+8>>2]=ea;g[X+304+12>>2]=0.0;g[X+288>>2]=fa;g[X+288+4>>2]=ga;g[X+288+8>>2]=ha;g[X+288+12>>2]=0.0;Pb[e&0](M,X+320|0,X+304|0,X+288|0,X+1008|0,1.0);e=c[S+772>>2]|0}h=h+1|0}while((h|0)<(e|0))}}else{c[5646]=1805;c[5647]=0;e=c[S+1112>>2]|0;if((e|0)>0){K=0;do{if(a[(c[(c[S+1120>>2]|0)+(K<<2)>>2]|0)+377>>0]|0){r=vr(c[5646]|0,c[5647]|0,1284865837,1481765933)|0;r=Kt(r|0,C|0,1,0)|0;h=C;s=us(r|0,h|0,33)|0;h=vr(r|0,h|0,1284865837,1481765933)|0;h=Kt(h|0,C|0,1,0)|0;r=C;t=us(h|0,r|0,33)|0;r=vr(h|0,r|0,1284865837,1481765933)|0;r=Kt(r|0,C|0,1,0)|0;h=C;c[5646]=r;c[5647]=h;h=us(r|0,h|0,33)|0;ha=1.0/+O(+(+(h|0)*4.656612873077393e-10*+(h|0)*4.656612873077393e-10+(+(s|0)*4.656612873077393e-10*+(s|0)*4.656612873077393e-10+ +(t|0)*4.656612873077393e-10*+(t|0)*4.656612873077393e-10)));g[X+1008>>2]=+(s|0)*4.656612873077393e-10*ha*.75;g[X+1008+4>>2]=+(t|0)*4.656612873077393e-10*ha*.75;g[X+1008+8>>2]=+(h|0)*4.656612873077393e-10*ha*.75;g[X+1008+12>>2]=0.0;h=c[(c[(c[S+1120>>2]|0)+(K<<2)>>2]|0)+24>>2]|0;if((h|0)>0){c[6435]=(c[6435]|0)+1;e=yc((h<<4|3)+16|0)|0;if(!e)f=0;else{c[(e+4+15&-16)+-4>>2]=e;f=e+4+15&-16}e=0;do{t=f+(e<<4)|0;c[t>>2]=c[X+816>>2];c[t+4>>2]=c[X+816+4>>2];c[t+8>>2]=c[X+816+8>>2];c[t+12>>2]=c[X+816+12>>2];e=e+1|0}while((e|0)!=(h|0));e=0;do{t=f+(e<<4)|0;s=(c[(c[(c[(c[S+1120>>2]|0)+(K<<2)>>2]|0)+32>>2]|0)+(e<<2)>>2]|0)+8|0;c[t>>2]=c[s>>2];c[t+4>>2]=c[s+4>>2];c[t+8>>2]=c[s+8>>2];c[t+12>>2]=c[s+12>>2];e=e+1|0}while((e|0)!=(h|0))}else f=0;a[X+944+16>>0]=1;c[X+944+12>>2]=0;c[X+944+4>>2]=0;c[X+944+8>>2]=0;a[X+944+36>>0]=1;c[Q>>2]=0;c[X+944+24>>2]=0;c[X+944+28>>2]=0;a[X+944+56>>0]=1;c[R>>2]=0;c[X+944+44>>2]=0;c[X+944+48>>2]=0;Dc(X+944|0,f,h);r=c[X+944+44>>2]|0;if((r|0)>0){p=c[Q>>2]|0;t=0;do{s=c[(c[R>>2]|0)+(t<<2)>>2]|0;h=c[p+(s*12|0)+4>>2]|0;e=p+(s*12|0)+(h*12|0)+((c[p+(s*12|0)+(h*12|0)>>2]|0)*12|0)|0;if((e|0)!=(p+(s*12|0)|0)){q=c[X+944+12>>2]|0;n=c[p+(s*12|0)+(h*12|0)+8>>2]|0;o=c[p+(s*12|0)+8>>2]|0;while(1){h=c[e+8>>2]|0;Pb[c[(c[M>>2]|0)+28>>2]&0](M,q+(n<<4)|0,q+(o<<4)|0,q+(h<<4)|0,X+1008|0,1.0);n=e+((c[e+4>>2]|0)*12|0)|0;e=n+((c[n>>2]|0)*12|0)|0;if((e|0)==(p+(s*12|0)|0))break;else{n=o;o=h}}}t=t+1|0}while((t|0)<(r|0))}e=c[R>>2]|0;if(e|0){if(a[X+944+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[R>>2]=0}a[X+944+56>>0]=1;c[R>>2]=0;c[X+944+44>>2]=0;c[X+944+48>>2]=0;e=c[Q>>2]|0;if(e|0){if(a[X+944+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[Q>>2]=0}a[X+944+36>>0]=1;c[Q>>2]=0;c[X+944+24>>2]=0;c[X+944+28>>2]=0;e=c[X+944+12>>2]|0;if(e|0){if(a[X+944+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[X+944+12>>2]=0}if(f|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}e=c[S+1112>>2]|0}K=K+1|0}while((K|0)<(e|0))}}if(L&64|0){if((c[S+792>>2]|0)>0){e=0;do{K=c[S+800>>2]|0;q=c[K+(e*96|0)+20>>2]|0;da=+g[K+(e*96|0)+4>>2];ea=+g[K+(e*96|0)+8>>2];fa=+g[K+(e*96|0)+12>>2];ga=da*+g[q+20>>2]+ea*+g[q+24>>2]+fa*+g[q+28>>2]+ +g[q+56>>2];ha=da*+g[q+36>>2]+ea*+g[q+40>>2]+fa*+g[q+44>>2]+ +g[q+60>>2];g[X+272>>2]=da*+g[q+4>>2]+ea*+g[q+8>>2]+fa*+g[q+12>>2]+ +g[q+52>>2];g[X+272+4>>2]=ga;g[X+272+8>>2]=ha;g[X+272+12>>2]=0.0;K=K+(e*96|0)|0;q=c[K>>2]|0;c[X+256>>2]=1065353216;c[X+256+4>>2]=0;c[X+256+8>>2]=0;g[X+256+12>>2]=0.0;t=c[(c[M>>2]|0)+8>>2]|0;ha=+g[q+8>>2];s=c[q+12>>2]|0;r=c[q+16>>2]|0;g[X+1008>>2]=ha+-.25;c[X+1008+4>>2]=s;c[X+1008+8>>2]=r;g[X+1008+12>>2]=0.0;ga=(c[k>>2]=s,+g[k>>2])+0.0;fa=(c[k>>2]=r,+g[k>>2])+0.0;g[X+944>>2]=ha+.25;g[X+944+4>>2]=ga;g[X+944+8>>2]=fa;g[X+944+12>>2]=0.0;mc[t&127](M,X+1008|0,X+944|0,X+256|0);t=c[(c[M>>2]|0)+8>>2]|0;r=c[q+8>>2]|0;fa=+g[q+12>>2];s=c[q+16>>2]|0;c[X+928>>2]=r;g[X+928+4>>2]=fa+-.25;c[X+928+8>>2]=s;g[X+928+12>>2]=0.0;ga=(c[k>>2]=r,+g[k>>2])+0.0;ha=(c[k>>2]=s,+g[k>>2])+0.0;g[X+912>>2]=ga;g[X+912+4>>2]=fa+.25;g[X+912+8>>2]=ha;g[X+912+12>>2]=0.0;mc[t&127](M,X+928|0,X+912|0,X+256|0);t=c[(c[M>>2]|0)+8>>2]|0;s=c[q+8>>2]|0;r=c[q+12>>2]|0;ha=+g[q+16>>2];c[X+896>>2]=s;c[X+896+4>>2]=r;g[X+896+8>>2]=ha+-.25;g[X+896+12>>2]=0.0;fa=(c[k>>2]=s,+g[k>>2])+0.0;ga=(c[k>>2]=r,+g[k>>2])+0.0;g[X+880>>2]=fa;g[X+880+4>>2]=ga;g[X+880+8>>2]=ha+.25;g[X+880+12>>2]=0.0;mc[t&127](M,X+896|0,X+880|0,X+256|0);c[X+240>>2]=0;c[X+240+4>>2]=1065353216;c[X+240+8>>2]=0;g[X+240+12>>2]=0.0;t=c[(c[M>>2]|0)+8>>2]|0;ha=+g[X+272>>2];r=c[X+272+4>>2]|0;s=c[X+272+8>>2]|0;g[X+1008>>2]=ha+-.25;c[X+1008+4>>2]=r;c[X+1008+8>>2]=s;g[X+1008+12>>2]=0.0;ga=(c[k>>2]=r,+g[k>>2])+0.0;fa=(c[k>>2]=s,+g[k>>2])+0.0;g[X+944>>2]=ha+.25;g[X+944+4>>2]=ga;g[X+944+8>>2]=fa;g[X+944+12>>2]=0.0;mc[t&127](M,X+1008|0,X+944|0,X+240|0);t=c[(c[M>>2]|0)+8>>2]|0;s=c[X+272>>2]|0;fa=+g[X+272+4>>2];r=c[X+272+8>>2]|0;c[X+928>>2]=s;g[X+928+4>>2]=fa+-.25;c[X+928+8>>2]=r;g[X+928+12>>2]=0.0;ga=(c[k>>2]=s,+g[k>>2])+0.0;ha=(c[k>>2]=r,+g[k>>2])+0.0;g[X+912>>2]=ga;g[X+912+4>>2]=fa+.25;g[X+912+8>>2]=ha;g[X+912+12>>2]=0.0;mc[t&127](M,X+928|0,X+912|0,X+240|0);t=c[(c[M>>2]|0)+8>>2]|0;r=c[X+272>>2]|0;s=c[X+272+4>>2]|0;ha=+g[X+272+8>>2];c[X+896>>2]=r;c[X+896+4>>2]=s;g[X+896+8>>2]=ha+-.25;g[X+896+12>>2]=0.0;fa=(c[k>>2]=r,+g[k>>2])+0.0;ga=(c[k>>2]=s,+g[k>>2])+0.0;g[X+880>>2]=fa;g[X+880+4>>2]=ga;g[X+880+8>>2]=ha+.25;g[X+880+12>>2]=0.0;mc[t&127](M,X+896|0,X+880|0,X+240|0);t=c[(c[M>>2]|0)+8>>2]|0;K=(c[K>>2]|0)+8|0;c[X+224>>2]=1065353216;c[X+224+4>>2]=1065353216;c[X+224+8>>2]=1065353216;g[X+224+12>>2]=0.0;mc[t&127](M,K,X+272|0,X+224|0);e=e+1|0}while((e|0)<(c[S+792>>2]|0))}e=c[S+712>>2]|0;if((e|0)>0){h=0;do{f=c[S+720>>2]|0;if((c[(c[f+(h*104|0)+4>>2]|0)+16>>2]&1|0)!=0?+g[f+(h*104|0)+88>>2]<=0.0:0){t=f+(h*104|0)+8|0;c[X+208>>2]=1065353216;c[X+208+4>>2]=0;c[X+208+8>>2]=0;g[X+208+12>>2]=0.0;e=c[(c[M>>2]|0)+8>>2]|0;ha=+g[t>>2];K=f+(h*104|0)+12|0;r=c[K>>2]|0;s=f+(h*104|0)+16|0;q=c[s>>2]|0;g[X+1008>>2]=ha+-.25;c[X+1008+4>>2]=r;c[X+1008+8>>2]=q;g[X+1008+12>>2]=0.0;ga=(c[k>>2]=r,+g[k>>2])+0.0;fa=(c[k>>2]=q,+g[k>>2])+0.0;g[X+944>>2]=ha+.25;g[X+944+4>>2]=ga;g[X+944+8>>2]=fa;g[X+944+12>>2]=0.0;mc[e&127](M,X+1008|0,X+944|0,X+208|0);e=c[(c[M>>2]|0)+8>>2]|0;q=c[t>>2]|0;fa=+g[K>>2];r=c[s>>2]|0;c[X+928>>2]=q;g[X+928+4>>2]=fa+-.25;c[X+928+8>>2]=r;g[X+928+12>>2]=0.0;ga=(c[k>>2]=q,+g[k>>2])+0.0;ha=(c[k>>2]=r,+g[k>>2])+0.0;g[X+912>>2]=ga;g[X+912+4>>2]=fa+.25;g[X+912+8>>2]=ha;g[X+912+12>>2]=0.0;mc[e&127](M,X+928|0,X+912|0,X+208|0);e=c[(c[M>>2]|0)+8>>2]|0;t=c[t>>2]|0;K=c[K>>2]|0;ha=+g[s>>2];c[X+896>>2]=t;c[X+896+4>>2]=K;g[X+896+8>>2]=ha+-.25;g[X+896+12>>2]=0.0;fa=(c[k>>2]=t,+g[k>>2])+0.0;ga=(c[k>>2]=K,+g[k>>2])+0.0;g[X+880>>2]=fa;g[X+880+4>>2]=ga;g[X+880+8>>2]=ha+.25;g[X+880+12>>2]=0.0;mc[e&127](M,X+896|0,X+880|0,X+208|0);e=c[S+712>>2]|0}h=h+1|0}while((h|0)<(e|0))}}if(L&128|0?(c[S+692>>2]|0)>0:0){h=0;do{e=c[S+700>>2]|0;f=e+(h*60|0)+8|0;c[X+1008>>2]=c[f>>2];c[X+1008+4>>2]=c[f+4>>2];c[X+1008+8>>2]=c[f+8>>2];c[X+1008+12>>2]=c[f+12>>2];f=c[e+(h*60|0)+24>>2]|0;if((f|0)>0){j=+g[X+1008>>2];l=+g[X+1008+4>>2];m=+g[X+1008+8>>2];n=0;do{K=c[e+(h*60|0)+28+(n<<2)>>2]|0;fa=+g[e+(h*60|0)+44+(n<<2)>>2];ga=fa*+g[K+12>>2];ha=fa*+g[K+16>>2];j=+g[K+8>>2]*fa+j;g[X+1008>>2]=j;l=ga+l;g[X+1008+4>>2]=l;m=ha+m;g[X+1008+8>>2]=m;n=n+1|0}while((n|0)!=(f|0))}ic[c[(c[M>>2]|0)+40>>2]&127](M,X+1008|0,c[e+(h*60|0)+4>>2]|0);h=h+1|0}while((h|0)<(c[S+692>>2]|0))}if(L&512|0){K=c[S+928>>2]|0;c[X+1008>>2]=1065353216;c[X+1008+4>>2]=0;c[X+1008+8>>2]=1065353216;g[X+1008+12>>2]=0.0;c[X+944>>2]=1065353216;c[X+944+4>>2]=1065353216;c[X+944+8>>2]=1065353216;g[X+944+12>>2]=0.0;Of(M,K,0,X+1008|0,X+944|0)}if(L&1024|0){K=c[S+988>>2]|0;c[X+1008>>2]=0;c[X+1008+4>>2]=1065353216;c[X+1008+8>>2]=0;g[X+1008+12>>2]=0.0;c[X+944>>2]=1065353216;c[X+944+4>>2]=0;c[X+944+8>>2]=0;g[X+944+12>>2]=0.0;Of(M,K,0,X+1008|0,X+944|0)}if(L&2048|0){K=c[S+1048>>2]|0;c[X+1008>>2]=0;c[X+1008+4>>2]=1065353216;c[X+1008+8>>2]=1065353216;g[X+1008+12>>2]=0.0;c[X+944>>2]=1065353216;c[X+944+4>>2]=0;c[X+944+8>>2]=0;g[X+944+12>>2]=0.0;Of(M,K,0,X+1008|0,X+944|0)}a:do if(L&4096|0?(c[S+852>>2]|0)>0:0){f=0;while(1){e=c[(c[S+860>>2]|0)+(f<<2)>>2]|0;switch(Eb[c[(c[e>>2]|0)+20>>2]&127](e)|0){case 0:{L=ri(e+4|0)|0;ha=+g[e+28>>2];ga=+g[e+32>>2];fa=+g[e+36>>2];ea=ha*+g[L+16>>2]+ga*+g[L+20>>2]+fa*+g[L+24>>2]+ +g[L+52>>2];da=ha*+g[L+32>>2]+ga*+g[L+36>>2]+fa*+g[L+40>>2]+ +g[L+56>>2];g[X+272>>2]=ha*+g[L>>2]+ga*+g[L+4>>2]+fa*+g[L+8>>2]+ +g[L+48>>2];g[X+272+4>>2]=ea;g[X+272+8>>2]=da;g[X+272+12>>2]=0.0;L=ri(e+16|0)|0;da=+g[e+44>>2];ea=+g[e+48>>2];fa=+g[e+52>>2];ga=da*+g[L+16>>2]+ea*+g[L+20>>2]+fa*+g[L+24>>2]+ +g[L+52>>2];ha=da*+g[L+32>>2]+ea*+g[L+36>>2]+fa*+g[L+40>>2]+ +g[L+56>>2];g[X+192>>2]=da*+g[L>>2]+ea*+g[L+4>>2]+fa*+g[L+8>>2]+ +g[L+48>>2];g[X+192+4>>2]=ga;g[X+192+8>>2]=ha;g[X+192+12>>2]=0.0;L=c[(c[M>>2]|0)+8>>2]|0;K=(ri(e+4|0)|0)+48|0;c[X+176>>2]=1065353216;c[X+176+4>>2]=1065353216;c[X+176+8>>2]=0;g[X+176+12>>2]=0.0;mc[L&127](M,K,X+272|0,X+176|0);K=c[(c[M>>2]|0)+8>>2]|0;L=(ri(e+16|0)|0)+48|0;c[X+160>>2]=0;c[X+160+4>>2]=1065353216;c[X+160+8>>2]=1065353216;g[X+160+12>>2]=0.0;mc[K&127](M,L,X+192|0,X+160|0);c[X+144>>2]=1065353216;c[X+144+4>>2]=1065353216;c[X+144+8>>2]=0;g[X+144+12>>2]=0.0;L=c[(c[M>>2]|0)+8>>2]|0;ha=+g[X+272>>2];K=c[X+272+4>>2]|0;t=c[X+272+8>>2]|0;g[X+1008>>2]=ha+-.25;c[X+1008+4>>2]=K;c[X+1008+8>>2]=t;g[X+1008+12>>2]=0.0;ga=(c[k>>2]=K,+g[k>>2])+0.0;fa=(c[k>>2]=t,+g[k>>2])+0.0;g[X+944>>2]=ha+.25;g[X+944+4>>2]=ga;g[X+944+8>>2]=fa;g[X+944+12>>2]=0.0;mc[L&127](M,X+1008|0,X+944|0,X+144|0);L=c[(c[M>>2]|0)+8>>2]|0;t=c[X+272>>2]|0;fa=+g[X+272+4>>2];K=c[X+272+8>>2]|0;c[X+928>>2]=t;g[X+928+4>>2]=fa+-.25;c[X+928+8>>2]=K;g[X+928+12>>2]=0.0;ga=(c[k>>2]=t,+g[k>>2])+0.0;ha=(c[k>>2]=K,+g[k>>2])+0.0;g[X+912>>2]=ga;g[X+912+4>>2]=fa+.25;g[X+912+8>>2]=ha;g[X+912+12>>2]=0.0;mc[L&127](M,X+928|0,X+912|0,X+144|0);L=c[(c[M>>2]|0)+8>>2]|0;K=c[X+272>>2]|0;t=c[X+272+4>>2]|0;ha=+g[X+272+8>>2];c[X+896>>2]=K;c[X+896+4>>2]=t;g[X+896+8>>2]=ha+-.25;g[X+896+12>>2]=0.0;fa=(c[k>>2]=K,+g[k>>2])+0.0;ga=(c[k>>2]=t,+g[k>>2])+0.0;g[X+880>>2]=fa;g[X+880+4>>2]=ga;g[X+880+8>>2]=ha+.25;g[X+880+12>>2]=0.0;mc[L&127](M,X+896|0,X+880|0,X+144|0);c[X+128>>2]=0;c[X+128+4>>2]=1065353216;c[X+128+8>>2]=1065353216;g[X+128+12>>2]=0.0;L=c[(c[M>>2]|0)+8>>2]|0;ha=+g[X+192>>2];t=c[X+192+4>>2]|0;K=c[X+192+8>>2]|0;g[X+1008>>2]=ha+-.25;c[X+1008+4>>2]=t;c[X+1008+8>>2]=K;g[X+1008+12>>2]=0.0;ga=(c[k>>2]=t,+g[k>>2])+0.0;fa=(c[k>>2]=K,+g[k>>2])+0.0;g[X+944>>2]=ha+.25;g[X+944+4>>2]=ga;g[X+944+8>>2]=fa;g[X+944+12>>2]=0.0;mc[L&127](M,X+1008|0,X+944|0,X+128|0);L=c[(c[M>>2]|0)+8>>2]|0;K=c[X+192>>2]|0;fa=+g[X+192+4>>2];t=c[X+192+8>>2]|0;c[X+928>>2]=K;g[X+928+4>>2]=fa+-.25;c[X+928+8>>2]=t;g[X+928+12>>2]=0.0;ga=(c[k>>2]=K,+g[k>>2])+0.0;ha=(c[k>>2]=t,+g[k>>2])+0.0;g[X+912>>2]=ga;g[X+912+4>>2]=fa+.25;g[X+912+8>>2]=ha;g[X+912+12>>2]=0.0;mc[L&127](M,X+928|0,X+912|0,X+128|0);L=c[(c[M>>2]|0)+8>>2]|0;t=c[X+192>>2]|0;K=c[X+192+4>>2]|0;ha=+g[X+192+8>>2];c[X+896>>2]=t;c[X+896+4>>2]=K;g[X+896+8>>2]=ha+-.25;g[X+896+12>>2]=0.0;fa=(c[k>>2]=t,+g[k>>2])+0.0;ga=(c[k>>2]=K,+g[k>>2])+0.0;g[X+880>>2]=fa;g[X+880+4>>2]=ga;g[X+880+8>>2]=ha+.25;g[X+880+12>>2]=0.0;mc[L&127](M,X+896|0,X+880|0,X+128|0);break}case 1:{L=(ri(e+4|0)|0)+48|0;c[X+1008>>2]=c[L>>2];c[X+1008+4>>2]=c[L+4>>2];c[X+1008+8>>2]=c[L+8>>2];c[X+1008+12>>2]=c[L+12>>2];L=(ri(e+16|0)|0)+48|0;c[X+944>>2]=c[L>>2];c[X+944+4>>2]=c[L+4>>2];c[X+944+8>>2]=c[L+8>>2];c[X+944+12>>2]=c[L+12>>2];L=ri(e+4|0)|0;ba=+g[e+28>>2];aa=+g[e+32>>2];ea=+g[e+36>>2];ca=+g[L>>2]*ba+ +g[L+4>>2]*aa+ +g[L+8>>2]*ea;da=ba*+g[L+16>>2]+aa*+g[L+20>>2]+ea*+g[L+24>>2];ea=ba*+g[L+32>>2]+aa*+g[L+36>>2]+ea*+g[L+40>>2];L=ri(e+16|0)|0;aa=+g[e+44>>2];ba=+g[e+48>>2];ha=+g[e+52>>2];fa=+g[L>>2]*aa+ +g[L+4>>2]*ba+ +g[L+8>>2]*ha;ga=aa*+g[L+16>>2]+ba*+g[L+20>>2]+ha*+g[L+24>>2];ha=aa*+g[L+32>>2]+ba*+g[L+36>>2]+ha*+g[L+40>>2];L=c[(c[M>>2]|0)+8>>2]|0;ba=da*10.0+ +g[X+1008+4>>2];aa=ea*10.0+ +g[X+1008+8>>2];g[X+112>>2]=ca*10.0+ +g[X+1008>>2];g[X+112+4>>2]=ba;g[X+112+8>>2]=aa;g[X+112+12>>2]=0.0;c[X+96>>2]=1065353216;c[X+96+4>>2]=1065353216;c[X+96+8>>2]=0;g[X+96+12>>2]=0.0;mc[L&127](M,X+1008|0,X+112|0,X+96|0);L=c[(c[M>>2]|0)+8>>2]|0;aa=ga*10.0+ +g[X+1008+4>>2];ba=ha*10.0+ +g[X+1008+8>>2];g[X+80>>2]=fa*10.0+ +g[X+1008>>2];g[X+80+4>>2]=aa;g[X+80+8>>2]=ba;g[X+80+12>>2]=0.0;c[X+64>>2]=1065353216;c[X+64+4>>2]=1065353216;c[X+64+8>>2]=0;g[X+64+12>>2]=0.0;mc[L&127](M,X+1008|0,X+80|0,X+64|0);L=c[(c[M>>2]|0)+8>>2]|0;da=da*10.0+ +g[X+944+4>>2];ea=ea*10.0+ +g[X+944+8>>2];g[X+48>>2]=ca*10.0+ +g[X+944>>2];g[X+48+4>>2]=da;g[X+48+8>>2]=ea;g[X+48+12>>2]=0.0;c[X+32>>2]=0;c[X+32+4>>2]=1065353216;c[X+32+8>>2]=1065353216;g[X+32+12>>2]=0.0;mc[L&127](M,X+944|0,X+48|0,X+32|0);L=c[(c[M>>2]|0)+8>>2]|0;ga=ga*10.0+ +g[X+944+4>>2];ha=ha*10.0+ +g[X+944+8>>2];g[X+16>>2]=fa*10.0+ +g[X+944>>2];g[X+16+4>>2]=ga;g[X+16+8>>2]=ha;g[X+16+12>>2]=0.0;c[X>>2]=0;c[X+4>>2]=1065353216;c[X+8>>2]=1065353216;g[X+12>>2]=0.0;mc[L&127](M,X+944|0,X+16|0,X);break}default:{}}f=f+1|0;if((f|0)>=(c[S+852>>2]|0))break a}}while(0)}e=c[d+72>>2]|0;if(e|0?(Eb[c[(c[e>>2]|0)+48>>2]&127](e)|0)&2|0:0){e=b[d+348>>1]|0;if(!((e&255)<<24>>24))e=(e&65535)>>>8&255;else{M=c[d+72>>2]|0;e=c[S+928>>2]|0;c[X+1008>>2]=1065353216;c[X+1008+4>>2]=0;c[X+1008+8>>2]=1065353216;g[X+1008+12>>2]=0.0;c[X+944>>2]=1065353216;c[X+944+4>>2]=1065353216;c[X+944+8>>2]=1065353216;g[X+944+12>>2]=0.0;Of(M,e,0,X+1008|0,X+944|0);e=a[d+349>>0]|0}if(e<<24>>24){L=c[d+72>>2]|0;M=c[S+988>>2]|0;c[X+1008>>2]=0;c[X+1008+4>>2]=1065353216;c[X+1008+8>>2]=0;g[X+1008+12>>2]=0.0;c[X+944>>2]=1065353216;c[X+944+4>>2]=0;c[X+944+8>>2]=0;g[X+944+12>>2]=0.0;Of(L,M,0,X+1008|0,X+944|0)}if(a[d+350>>0]|0){M=c[d+72>>2]|0;S=c[S+1048>>2]|0;c[X+1008>>2]=0;c[X+1008+4>>2]=1065353216;c[X+1008+8>>2]=1065353216;g[X+1008+12>>2]=0.0;c[X+944>>2]=1065353216;c[X+944+4>>2]=0;c[X+944+8>>2]=0;g[X+944+12>>2]=0.0;Of(M,S,0,X+1008|0,X+944|0)}}W=W+1|0}while((W|0)<(c[d+328>>2]|0));i=X;return}function qc(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,l=0,m=0.0,n=0.0,o=0,p=0.0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0.0,F=0.0,G=0,H=0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,P=0.0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0.0,ha=0.0,ia=0.0;fa=i;i=i+80|0;if((e|0)<=0){i=fa;return}ca=0;do{X=c[d+(ca<<2)>>2]|0;Y=c[X+740>>2]|0;Z=c[X+744>>2]|0;_=bk(b,Y,+g[f+12>>2])|0;$=bk(b,Z,+g[f+12>>2])|0;aa=c[b+16>>2]|0;if(!(((((+g[aa+(_*244|0)+128>>2]==0.0?+g[aa+(_*244|0)+132>>2]==0.0:0)?+g[aa+(_*244|0)+136>>2]==0.0:0)?+g[aa+($*244|0)+128>>2]==0.0:0)?+g[aa+($*244|0)+132>>2]==0.0:0)?+g[aa+($*244|0)+136>>2]==0.0:0))ea=9;if((ea|0)==9?(ea=0,ba=c[X+748>>2]|0,(ba|0)>0):0){j=ba;da=0;h=1;do{U=X+4+(da*184|0)|0;D=X+4+(da*184|0)+80|0;if(+g[D>>2]<=+g[X+756>>2]){V=c[b+28>>2]|0;if((V|0)==(c[b+32>>2]|0)?(W=V|0?V<<1:1,(V|0)<(W|0)):0){if(!W){j=0;l=V}else{c[6435]=(c[6435]|0)+1;j=yc((W*152|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}l=c[b+28>>2]|0}if((l|0)>0){o=0;do{_m(j+(o*152|0)|0,(c[b+36>>2]|0)+(o*152|0)|0,152)|0;o=o+1|0}while((o|0)!=(l|0))}l=c[b+36>>2]|0;if(l|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=j;c[b+32>>2]=W;j=c[b+28>>2]|0}else j=V;c[b+28>>2]=j+1;T=c[b+36>>2]|0;G=(c[Y+236>>2]&2|0)==0?0:Y;H=(c[Z+236>>2]&2|0)==0?0:Z;c[T+(V*152|0)+144>>2]=_;c[T+(V*152|0)+148>>2]=$;c[T+(V*152|0)+132>>2]=U;z=+g[X+4+(da*184|0)+48>>2]-+g[Y+52>>2];A=+g[X+4+(da*184|0)+52>>2]-+g[Y+56>>2];y=+g[X+4+(da*184|0)+56>>2]-+g[Y+60>>2];g[fa+64>>2]=z;g[fa+64+4>>2]=A;g[fa+64+8>>2]=y;g[fa+64+12>>2]=0.0;C=+g[X+4+(da*184|0)+32>>2]-+g[Z+52>>2];E=+g[X+4+(da*184|0)+36>>2]-+g[Z+56>>2];B=+g[X+4+(da*184|0)+40>>2]-+g[Z+60>>2];g[fa+48>>2]=C;g[fa+48+4>>2]=E;g[fa+48+8>>2]=B;g[fa+48+12>>2]=0.0;if(!(c[aa+(_*244|0)+240>>2]|0)){j=0;o=0;r=0}else{M=+g[aa+(_*244|0)+192>>2]+ +g[aa+(_*244|0)+224>>2];P=+g[aa+(_*244|0)+196>>2]+ +g[aa+(_*244|0)+228>>2];L=+g[aa+(_*244|0)+200>>2]+ +g[aa+(_*244|0)+232>>2];j=(g[k>>2]=+g[aa+(_*244|0)+176>>2]+ +g[aa+(_*244|0)+208>>2]+(P*y-L*A),c[k>>2]|0);o=(g[k>>2]=+g[aa+(_*244|0)+180>>2]+ +g[aa+(_*244|0)+212>>2]+(L*z-M*y),c[k>>2]|0);r=(g[k>>2]=+g[aa+(_*244|0)+184>>2]+ +g[aa+(_*244|0)+216>>2]+(M*A-P*z),c[k>>2]|0)}if(!(c[aa+($*244|0)+240>>2]|0)){l=0;q=0;s=0}else{M=+g[aa+($*244|0)+192>>2]+ +g[aa+($*244|0)+224>>2];P=+g[aa+($*244|0)+196>>2]+ +g[aa+($*244|0)+228>>2];L=+g[aa+($*244|0)+200>>2]+ +g[aa+($*244|0)+232>>2];l=(g[k>>2]=+g[aa+($*244|0)+176>>2]+ +g[aa+($*244|0)+208>>2]+(P*B-L*E),c[k>>2]|0);q=(g[k>>2]=+g[aa+($*244|0)+180>>2]+ +g[aa+($*244|0)+212>>2]+(L*C-M*B),c[k>>2]|0);s=(g[k>>2]=+g[aa+($*244|0)+184>>2]+ +g[aa+($*244|0)+216>>2]+(M*E-P*C),c[k>>2]|0)}P=(c[k>>2]=j,+g[k>>2]);P=P-(c[k>>2]=l,+g[k>>2]);M=(c[k>>2]=o,+g[k>>2]);M=M-(c[k>>2]=q,+g[k>>2]);I=(c[k>>2]=r,+g[k>>2]);I=I-(c[k>>2]=s,+g[k>>2]);Q=X+4+(da*184|0)+64|0;J=+g[Q>>2];R=X+4+(da*184|0)+68|0;K=+g[R>>2];S=X+4+(da*184|0)+72|0;L=+g[S>>2];s=c[b+16>>2]|0;q=c[s+(_*244|0)+240>>2]|0;r=c[s+($*244|0)+240>>2]|0;if(q|0){o=(g[k>>2]=((A*L-y*K)*+g[q+264>>2]+(y*J-L*z)*+g[q+268>>2]+(K*z-A*J)*+g[q+272>>2])*+g[q+544>>2],c[k>>2]|0);j=(g[k>>2]=((A*L-y*K)*+g[q+280>>2]+(y*J-L*z)*+g[q+284>>2]+(K*z-A*J)*+g[q+288>>2])*+g[q+548>>2],c[k>>2]|0);l=(g[k>>2]=((A*L-y*K)*+g[q+296>>2]+(y*J-L*z)*+g[q+300>>2]+(K*z-A*J)*+g[q+304>>2])*+g[q+552>>2],c[k>>2]|0)}else{o=0;j=0;l=0}c[T+(V*152|0)+64>>2]=o;c[T+(V*152|0)+68>>2]=j;c[T+(V*152|0)+72>>2]=l;g[T+(V*152|0)+76>>2]=0.0;v=+g[S>>2];w=+g[R>>2];x=+g[Q>>2];u=(c[k>>2]=j,+g[k>>2]);t=(c[k>>2]=l,+g[k>>2]);n=(c[k>>2]=o,+g[k>>2]);if(r|0){j=(g[k>>2]=(+g[r+264>>2]*-(E*v-B*w)+ +g[r+268>>2]*-(B*x-v*C)+ +g[r+272>>2]*-(w*C-E*x))*+g[r+544>>2],c[k>>2]|0);l=(g[k>>2]=(+g[r+280>>2]*-(E*v-B*w)+ +g[r+284>>2]*-(B*x-v*C)+ +g[r+288>>2]*-(w*C-E*x))*+g[r+548>>2],c[k>>2]|0);o=(g[k>>2]=(+g[r+296>>2]*-(E*v-B*w)+ +g[r+300>>2]*-(B*x-v*C)+ +g[r+304>>2]*-(w*C-E*x))*+g[r+552>>2],c[k>>2]|0)}else{j=0;l=0;o=0}c[T+(V*152|0)+80>>2]=j;c[T+(V*152|0)+84>>2]=l;c[T+(V*152|0)+88>>2]=o;g[T+(V*152|0)+92>>2]=0.0;p=(c[k>>2]=j,+g[k>>2]);m=(c[k>>2]=l,+g[k>>2]);if(q|0)n=+g[q+344>>2]+((u*y-t*A)*+g[Q>>2]+(t*z-y*n)*+g[R>>2]+(A*n-u*z)*+g[S>>2]);else n=0.0;if(r|0){F=-(c[k>>2]=o,+g[k>>2]);m=+g[r+344>>2]+((B*-m-E*F)*+g[Q>>2]+(C*F-B*-p)*+g[R>>2]+(E*-p-C*-m)*+g[S>>2])}else m=0.0;g[T+(V*152|0)+108>>2]=1.0/(n+m);if(q|0){c[T+(V*152|0)+16>>2]=c[Q>>2];c[T+(V*152|0)+16+4>>2]=c[Q+4>>2];c[T+(V*152|0)+16+8>>2]=c[Q+8>>2];c[T+(V*152|0)+16+12>>2]=c[Q+12>>2];g[T+(V*152|0)>>2]=A*L-y*K;g[T+(V*152|0)+4>>2]=y*J-L*z;g[T+(V*152|0)+8>>2]=K*z-A*J;g[T+(V*152|0)+12>>2]=0.0}else{c[T+(V*152|0)>>2]=0;c[T+(V*152|0)+4>>2]=0;c[T+(V*152|0)+8>>2]=0;c[T+(V*152|0)+12>>2]=0;c[T+(V*152|0)+16>>2]=0;c[T+(V*152|0)+20>>2]=0;c[T+(V*152|0)+24>>2]=0;c[T+(V*152|0)+28>>2]=0}if(r|0){u=-+g[R>>2];F=-+g[S>>2];g[T+(V*152|0)+48>>2]=-+g[Q>>2];g[T+(V*152|0)+52>>2]=u;g[T+(V*152|0)+56>>2]=F;g[T+(V*152|0)+60>>2]=0.0;g[T+(V*152|0)+32>>2]=-(E*v-B*w);g[T+(V*152|0)+36>>2]=-(B*x-v*C);g[T+(V*152|0)+40>>2]=-(w*C-E*x);g[T+(V*152|0)+44>>2]=0.0}else{c[T+(V*152|0)+32>>2]=0;c[T+(V*152|0)+32+4>>2]=0;c[T+(V*152|0)+32+8>>2]=0;c[T+(V*152|0)+32+12>>2]=0;c[T+(V*152|0)+32+16>>2]=0;c[T+(V*152|0)+32+20>>2]=0;c[T+(V*152|0)+32+24>>2]=0;c[T+(V*152|0)+32+28>>2]=0}F=+g[D>>2]+ +g[f+56>>2];if(q|0){t=+g[q+332>>2];u=+g[q+336>>2];x=+g[q+328>>2];v=t*y-u*A+ +g[q+312>>2];u=+g[q+316>>2]+(u*z-y*x);t=A*x-t*z+ +g[q+320>>2]}else{v=0.0;u=0.0;t=0.0}if(r|0){m=+g[r+332>>2];n=+g[r+336>>2];A=+g[r+328>>2];p=m*B-n*E+ +g[r+312>>2];n=+g[r+316>>2]+(n*C-B*A);m=E*A-m*C+ +g[r+320>>2]}else{p=0.0;n=0.0;m=0.0}C=(v-p)*+g[Q>>2]+(u-n)*+g[R>>2]+(t-m)*+g[S>>2];c[T+(V*152|0)+104>>2]=c[X+4+(da*184|0)+84>>2];C=-(C*+g[X+4+(da*184|0)+92>>2]);C=C<=0.0?0.0:C;do if(!(c[f+64>>2]&4))g[T+(V*152|0)+100>>2]=0.0;else{m=+g[X+4+(da*184|0)+120>>2]*+g[f+60>>2];g[T+(V*152|0)+100>>2]=m;do if(q|0){if(!(c[s+(_*244|0)+240>>2]|0))break;E=m*+g[T+(V*152|0)+20>>2]*+g[s+(_*244|0)+132>>2]*+g[q+352>>2]*+g[s+(_*244|0)+116>>2];B=m*+g[T+(V*152|0)+24>>2]*+g[s+(_*244|0)+136>>2]*+g[q+356>>2]*+g[s+(_*244|0)+120>>2];g[s+(_*244|0)+64>>2]=+g[s+(_*244|0)+112>>2]*m*+g[T+(V*152|0)+16>>2]*+g[s+(_*244|0)+128>>2]*+g[q+348>>2]+ +g[s+(_*244|0)+64>>2];g[s+(_*244|0)+68>>2]=E+ +g[s+(_*244|0)+68>>2];g[s+(_*244|0)+72>>2]=B+ +g[s+(_*244|0)+72>>2];B=m*+g[s+(_*244|0)+100>>2]*+g[T+(V*152|0)+68>>2];E=m*+g[s+(_*244|0)+104>>2]*+g[T+(V*152|0)+72>>2];g[s+(_*244|0)+80>>2]=m*+g[s+(_*244|0)+96>>2]*+g[T+(V*152|0)+64>>2]+ +g[s+(_*244|0)+80>>2];g[s+(_*244|0)+84>>2]=B+ +g[s+(_*244|0)+84>>2];g[s+(_*244|0)+88>>2]=E+ +g[s+(_*244|0)+88>>2]}while(0);if(!r)break;m=+g[T+(V*152|0)+100>>2];if(!(c[s+($*244|0)+240>>2]|0))break;E=+g[T+(V*152|0)+88>>2];B=+g[T+(V*152|0)+84>>2];A=+g[T+(V*152|0)+80>>2];y=m*+g[T+(V*152|0)+52>>2]*+g[s+($*244|0)+132>>2]*+g[r+352>>2]*+g[s+($*244|0)+116>>2];z=m*+g[T+(V*152|0)+56>>2]*+g[s+($*244|0)+136>>2]*+g[r+356>>2]*+g[s+($*244|0)+120>>2];g[s+($*244|0)+64>>2]=+g[s+($*244|0)+112>>2]*m*+g[T+(V*152|0)+48>>2]*+g[s+($*244|0)+128>>2]*+g[r+348>>2]+ +g[s+($*244|0)+64>>2];g[s+($*244|0)+68>>2]=y+ +g[s+($*244|0)+68>>2];g[s+($*244|0)+72>>2]=z+ +g[s+($*244|0)+72>>2];B=B*+g[s+($*244|0)+100>>2]*-m;E=E*+g[s+($*244|0)+104>>2]*-m;g[s+($*244|0)+80>>2]=+g[s+($*244|0)+80>>2]-A*+g[s+($*244|0)+96>>2]*-m;g[s+($*244|0)+84>>2]=+g[s+($*244|0)+84>>2]-B;g[s+($*244|0)+88>>2]=+g[s+($*244|0)+88>>2]-E}while(0);g[T+(V*152|0)+96>>2]=0.0;if(!(c[s+(_*244|0)+240>>2]|0)){m=0.0;n=0.0;p=0.0;w=0.0;x=0.0;y=0.0}else{m=+g[s+(_*244|0)+208>>2];n=+g[s+(_*244|0)+212>>2];p=+g[s+(_*244|0)+216>>2];w=+g[s+(_*244|0)+224>>2];x=+g[s+(_*244|0)+228>>2];y=+g[s+(_*244|0)+232>>2]}if(!(c[s+($*244|0)+240>>2]|0)){t=0.0;u=0.0;v=0.0;z=0.0;A=0.0;B=0.0}else{t=+g[s+($*244|0)+208>>2];u=+g[s+($*244|0)+212>>2];v=+g[s+($*244|0)+216>>2];z=+g[s+($*244|0)+224>>2];A=+g[s+($*244|0)+228>>2];B=+g[s+($*244|0)+232>>2]}m=C-((m+ +g[s+(_*244|0)+176>>2])*+g[T+(V*152|0)+16>>2]+(n+ +g[s+(_*244|0)+180>>2])*+g[T+(V*152|0)+20>>2]+(p+ +g[s+(_*244|0)+184>>2])*+g[T+(V*152|0)+24>>2]+((w+ +g[s+(_*244|0)+192>>2])*+g[T+(V*152|0)>>2]+(x+ +g[s+(_*244|0)+196>>2])*+g[T+(V*152|0)+4>>2]+(y+ +g[s+(_*244|0)+200>>2])*+g[T+(V*152|0)+8>>2])+((t+ +g[s+($*244|0)+176>>2])*+g[T+(V*152|0)+48>>2]+(u+ +g[s+($*244|0)+180>>2])*+g[T+(V*152|0)+52>>2]+(v+ +g[s+($*244|0)+184>>2])*+g[T+(V*152|0)+56>>2]+((z+ +g[s+($*244|0)+192>>2])*+g[T+(V*152|0)+32>>2]+(A+ +g[s+($*244|0)+196>>2])*+g[T+(V*152|0)+36>>2]+(B+ +g[s+($*244|0)+200>>2])*+g[T+(V*152|0)+40>>2])));j=(c[f+44>>2]|0)==0;n=+g[f+12>>2];if(F>0.0){p=0.0;m=m-F/n}else p=-(F*+g[(j|F>+g[f+48>>2]?f+32|0:f+36|0)>>2])/n;E=+g[T+(V*152|0)+108>>2];n=p*E;m=m*E;if(j|F>+g[f+48>>2]){g[T+(V*152|0)+112>>2]=n+m;g[T+(V*152|0)+128>>2]=0.0}else{g[T+(V*152|0)+112>>2]=m;g[T+(V*152|0)+128>>2]=n}g[T+(V*152|0)+116>>2]=0.0;g[T+(V*152|0)+120>>2]=0.0;g[T+(V*152|0)+124>>2]=1.0e10;c[T+(V*152|0)+140>>2]=c[b+68>>2];if(!G){l=0;r=0;s=0}else{l=c[G+328>>2]|0;r=c[G+332>>2]|0;s=c[G+336>>2]|0}if(!H){j=0;o=0;q=0}else{j=c[H+328>>2]|0;o=c[H+332>>2]|0;q=c[H+336>>2]|0}p=(c[k>>2]=j,+g[k>>2]);p=p-(c[k>>2]=l,+g[k>>2]);n=(c[k>>2]=o,+g[k>>2]);n=n-(c[k>>2]=r,+g[k>>2]);t=(c[k>>2]=q,+g[k>>2]);t=t-(c[k>>2]=s,+g[k>>2]);g[fa+32>>2]=p;g[fa+32+4>>2]=n;g[fa+32+8>>2]=t;g[fa+32+12>>2]=0.0;do if((h|0)>0?+g[X+4+(da*184|0)+88>>2]>0.0:0){h=h+-1|0;m=+O(+(p*p+n*n+t*t));if(m>+g[f+80>>2]){g[fa+32>>2]=p*(1.0/m);g[fa+32+4>>2]=n*(1.0/m);g[fa+32+8>>2]=t*(1.0/m);if(!(c[Y+180>>2]&2)){p=p*(1.0/m);n=n*(1.0/m);m=t*(1.0/m)}else{u=+g[Y+4>>2];x=+g[Y+20>>2];A=+g[Y+36>>2];v=+g[Y+8>>2];y=+g[Y+24>>2];C=+g[Y+40>>2];w=+g[Y+12>>2];z=+g[Y+28>>2];F=+g[Y+44>>2];B=(u*p*(1.0/m)+x*n*(1.0/m)+t*(1.0/m)*A)*+g[Y+164>>2];E=(p*(1.0/m)*v+n*(1.0/m)*y+t*(1.0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]=0.0;t=ia*E+x*ga+y*m;n=z*E+A*ga+B*m;m=C*E+F*ga+ha*m}if(!l){x=+g[Z+4>>2];A=+g[Z+20>>2];E=+g[Z+36>>2];y=+g[Z+8>>2];B=+g[Z+24>>2];ga=+g[Z+40>>2];z=+g[Z+12>>2];C=+g[Z+28>>2];ia=+g[Z+44>>2];F=(x*t+A*n+E*m)*+g[Z+164>>2];ha=(t*y+n*B+m*ga)*+g[Z+168>>2];m=(t*z+n*C+m*ia)*+g[Z+172>>2];g[fa>>2]=x*F+y*ha+z*m;g[fa+4>>2]=A*F+B*ha+C*m;g[fa+8>>2]=E*F+ga*ha+ia*m;g[fa+12>>2]=0.0;t=x*F+y*ha+z*m;n=A*F+B*ha+C*m;m=E*F+ga*ha+ia*m}if(+O(+(p*p+u*u+v*v))>.001)Nd(b,fa+16|0,_,$,V,U);if(+O(+(t*t+n*n+m*m))>.001)Nd(b,fa,_,$,V,U)}while(0);do if(!(c[f+64>>2]&32))ea=95;else{if(!(a[X+4+(da*184|0)+116>>0]|0)){ea=95;break}qd(b,X+4+(da*184|0)+152|0,_,$,V,U,fa+64|0,fa+48|0,1.0,+g[X+4+(da*184|0)+132>>2],+g[X+4+(da*184|0)+140>>2]);if(!(c[f+64>>2]&16))break;qd(b,X+4+(da*184|0)+168|0,_,$,V,U,fa+64|0,fa+48|0,1.0,+g[X+4+(da*184|0)+136>>2],+g[X+4+(da*184|0)+144>>2])}while(0);do if((ea|0)==95){ea=0;D=X+4+(da*184|0)+152|0;m=+g[Q>>2];x=+g[R>>2];w=+g[S>>2];n=P-(P*J+M*K+I*L)*m;u=M-(P*J+M*K+I*L)*x;t=I-(P*J+M*K+I*L)*w;g[X+4+(da*184|0)+152>>2]=n;r=X+4+(da*184|0)+156|0;g[r>>2]=u;s=X+4+(da*184|0)+160|0;g[s>>2]=t;j=X+4+(da*184|0)+164|0;g[j>>2]=0.0;if((c[f+64>>2]&64|0)==0?n*n+u*u+t*t>1.1920928955078125e-07:0){m=1.0/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=+g[Y+40>>2];F=+g[Y+12>>2];K=+g[Y+28>>2];ha=+g[Y+44>>2];M=(C*A+I*B+L*ia)*+g[Y+164>>2];ga=(A*E+B*J+ia*P)*+g[Y+168>>2];ia=(A*F+B*K+ia*ha)*+g[Y+172>>2];g[q>>2]=C*M+E*ga+F*ia;g[o>>2]=I*M+J*ga+K*ia;g[l>>2]=L*M+P*ga+ha*ia;g[X+4+(da*184|0)+180>>2]=0.0}while(0);do if(Z|0){if(!(c[Z+180>>2]&1))break;C=+g[Z+4>>2];A=+g[q>>2];I=+g[Z+20>>2];B=+g[o>>2];L=+g[Z+36>>2];ia=+g[l>>2];E=+g[Z+8>>2];J=+g[Z+24>>2];P=+g[Z+40>>2];F=+g[Z+12>>2];K=+g[Z+28>>2];ha=+g[Z+44>>2];M=(C*A+I*B+L*ia)*+g[Z+164>>2];ga=(A*E+B*J+ia*P)*+g[Z+168>>2];ia=(A*F+B*K+ia*ha)*+g[Z+172>>2];g[q>>2]=C*M+E*ga+F*ia;g[o>>2]=I*M+J*ga+K*ia;g[l>>2]=L*M+P*ga+ha*ia;g[X+4+(da*184|0)+180>>2]=0.0}while(0);qd(b,q,_,$,V,U,fa+64|0,fa+48|0,1.0,0.0,0.0);j=c[f+64>>2]|0}if((j&80|0)!=80)break;a[X+4+(da*184|0)+116>>0]=1}while(0);s=c[b+16>>2]|0;l=c[s+(_*244|0)+240>>2]|0;o=c[s+($*244|0)+240>>2]|0;q=c[T+(V*152|0)+140>>2]|0;r=c[b+76>>2]|0;j=c[f+64>>2]|0;do if(!(j&4))g[r+(q*152|0)+100>>2]=0.0;else{m=+g[X+4+(da*184|0)+124>>2]*+g[f+60>>2];g[r+(q*152|0)+100>>2]=m;if(l|0){ga=+g[l+344>>2];ia=m*ga*+g[r+(q*152|0)+20>>2]*+g[l+352>>2]*+g[s+(_*244|0)+116>>2];ha=m*ga*+g[r+(q*152|0)+24>>2]*+g[l+356>>2]*+g[s+(_*244|0)+120>>2];g[s+(_*244|0)+64>>2]=+g[s+(_*244|0)+112>>2]*m*ga*+g[r+(q*152|0)+16>>2]*+g[l+348>>2]+ +g[s+(_*244|0)+64>>2];g[s+(_*244|0)+68>>2]=ia+ +g[s+(_*244|0)+68>>2];g[s+(_*244|0)+72>>2]=ha+ +g[s+(_*244|0)+72>>2];ha=m*+g[s+(_*244|0)+100>>2]*+g[r+(q*152|0)+68>>2];ia=m*+g[s+(_*244|0)+104>>2]*+g[r+(q*152|0)+72>>2];g[s+(_*244|0)+80>>2]=m*+g[s+(_*244|0)+96>>2]*+g[r+(q*152|0)+64>>2]+ +g[s+(_*244|0)+80>>2];g[s+(_*244|0)+84>>2]=ha+ +g[s+(_*244|0)+84>>2];g[s+(_*244|0)+88>>2]=ia+ +g[s+(_*244|0)+88>>2]}if(!o)break;m=+g[o+344>>2];n=+g[r+(q*152|0)+100>>2];if(!(c[s+($*244|0)+240>>2]|0))break;ia=+g[r+(q*152|0)+88>>2];ha=+g[r+(q*152|0)+84>>2];ga=+g[r+(q*152|0)+80>>2];M=n*m*+g[r+(q*152|0)+52>>2]*+g[o+352>>2]*+g[s+($*244|0)+116>>2];P=n*m*+g[r+(q*152|0)+56>>2]*+g[o+356>>2]*+g[s+($*244|0)+120>>2];g[s+($*244|0)+64>>2]=+g[s+($*244|0)+112>>2]*n*m*+g[r+(q*152|0)+48>>2]*+g[o+348>>2]+ +g[s+($*244|0)+64>>2];g[s+($*244|0)+68>>2]=M+ +g[s+($*244|0)+68>>2];g[s+($*244|0)+72>>2]=P+ +g[s+($*244|0)+72>>2];ha=ha*+g[s+($*244|0)+100>>2]*-n;ia=ia*+g[s+($*244|0)+104>>2]*-n;g[s+($*244|0)+80>>2]=+g[s+($*244|0)+80>>2]-ga*+g[s+($*244|0)+96>>2]*-n;g[s+($*244|0)+84>>2]=+g[s+($*244|0)+84>>2]-ha;g[s+($*244|0)+88>>2]=+g[s+($*244|0)+88>>2]-ia}while(0);do if(j&16|0){if(!(j&4)){g[r+((q+1|0)*152|0)+100>>2]=0.0;break}n=+g[X+4+(da*184|0)+128>>2]*+g[f+60>>2];g[r+((q+1|0)*152|0)+100>>2]=n;do if(l|0){m=+g[l+344>>2];if(!(c[s+(_*244|0)+240>>2]|0))break;ia=n*m*+g[r+((q+1|0)*152|0)+20>>2]*+g[s+(_*244|0)+116>>2];ha=n*m*+g[r+((q+1|0)*152|0)+24>>2]*+g[s+(_*244|0)+120>>2];g[s+(_*244|0)+64>>2]=+g[s+(_*244|0)+112>>2]*n*m*+g[r+((q+1|0)*152|0)+16>>2]+ +g[s+(_*244|0)+64>>2];g[s+(_*244|0)+68>>2]=ia+ +g[s+(_*244|0)+68>>2];g[s+(_*244|0)+72>>2]=ha+ +g[s+(_*244|0)+72>>2];ha=n*+g[s+(_*244|0)+100>>2]*+g[r+((q+1|0)*152|0)+68>>2];ia=n*+g[s+(_*244|0)+104>>2]*+g[r+((q+1|0)*152|0)+72>>2];g[s+(_*244|0)+80>>2]=n*+g[s+(_*244|0)+96>>2]*+g[r+((q+1|0)*152|0)+64>>2]+ +g[s+(_*244|0)+80>>2];g[s+(_*244|0)+84>>2]=ha+ +g[s+(_*244|0)+84>>2];g[s+(_*244|0)+88>>2]=ia+ +g[s+(_*244|0)+88>>2]}while(0);if(!o)break;m=+g[o+344>>2];n=+g[r+((q+1|0)*152|0)+100>>2];if(!(c[s+($*244|0)+240>>2]|0))break;ia=+g[r+((q+1|0)*152|0)+88>>2];ha=+g[r+((q+1|0)*152|0)+84>>2];ga=+g[r+((q+1|0)*152|0)+80>>2];M=n*m*+g[r+((q+1|0)*152|0)+52>>2]*+g[s+($*244|0)+116>>2];P=n*m*+g[r+((q+1|0)*152|0)+56>>2]*+g[s+($*244|0)+120>>2];g[s+($*244|0)+64>>2]=+g[s+($*244|0)+112>>2]*n*m*+g[r+((q+1|0)*152|0)+48>>2]+ +g[s+($*244|0)+64>>2];g[s+($*244|0)+68>>2]=M+ +g[s+($*244|0)+68>>2];g[s+($*244|0)+72>>2]=P+ +g[s+($*244|0)+72>>2];ha=ha*+g[s+($*244|0)+100>>2]*-n;ia=ia*+g[s+($*244|0)+104>>2]*-n;g[s+($*244|0)+80>>2]=+g[s+($*244|0)+80>>2]-ga*+g[s+($*244|0)+96>>2]*-n;g[s+($*244|0)+84>>2]=+g[s+($*244|0)+84>>2]-ha;g[s+($*244|0)+88>>2]=+g[s+($*244|0)+88>>2]-ia}while(0);j=c[X+748>>2]|0}da=da+1|0}while((da|0)<(j|0))}ca=ca+1|0}while((ca|0)!=(e|0));i=fa;return}function rc(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,l=0,m=0,n=0,o=0,p=0.0,q=0,r=0.0,s=0.0,t=0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0,M=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0;X=i;i=i+160|0;c[X+40>>2]=0;a[X+16>>0]=1;c[X+12>>2]=0;c[X+4>>2]=0;c[X+8>>2]=0;a[X+36>>0]=1;c[X+32>>2]=0;c[X+24>>2]=0;c[X+28>>2]=0;l=e>>>0<8?8:e;if((l|0)>0){c[6435]=(c[6435]|0)+1;h=yc((l<<4|3)+16|0)|0;if(!h)j=0;else{c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}h=0;do{W=j+(h<<4)|0;c[W>>2]=c[X+80>>2];c[W+4>>2]=c[X+80+4>>2];c[W+8>>2]=c[X+80+8>>2];c[W+12>>2]=c[X+80+12>>2];h=h+1|0}while((h|0)!=(l|0));W=j}else W=0;do if(!e){h=0;q=0;j=0;n=0;o=0}else{j=c[X+24>>2]|0;if((j|0)<0){h=c[X+32>>2]|0;do if((c[X+28>>2]|0)<0){if(!h){a[X+36>>0]=1;c[X+32>>2]=0;c[X+28>>2]=0;h=0;break}if(a[X+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}a[X+36>>0]=1;c[X+32>>2]=0;c[X+28>>2]=0;h=0}while(0);Qn(h+(j<<2)|0,0,_(j,-4)|0)|0}c[X+24>>2]=0;w=3402823466385288598117041.0e14;p=-3402823466385288598117041.0e14;x=3402823466385288598117041.0e14;r=-3402823466385288598117041.0e14;y=3402823466385288598117041.0e14;v=-3402823466385288598117041.0e14;h=0;j=d;while(1){K=+g[j>>2];w=Kp?K:p;K=+g[j+4>>2];x=Kr?K:r;K=+g[j+8>>2];y=Kv?K:v;h=h+1|0;if((h|0)==(e|0))break;else j=j+16|0}s=p-w;r=r-x;p=v-y;E=w+s*.5;C=x+r*.5;B=y+p*.5;do if(e>>>0<3|(s<9.999999974752427e-07|r<9.999999974752427e-07|p<9.999999974752427e-07)){v=s>9.999999974752427e-07&s<3402823466385288598117041.0e14?s:3402823466385288598117041.0e14;v=r>9.999999974752427e-07&r9.999999974752427e-07&p>2]=K;g[W+4>>2]=I;g[W+8>>2]=H;g[W+16>>2]=J;g[W+20>>2]=I;g[W+24>>2]=H;g[W+32>>2]=J;g[W+36>>2]=r;g[W+40>>2]=H;g[W+48>>2]=K;g[W+52>>2]=r;g[W+56>>2]=H;g[W+64>>2]=K;g[W+68>>2]=I;g[W+72>>2]=s;g[W+80>>2]=J;g[W+84>>2]=I;g[W+88>>2]=s;g[W+96>>2]=J;g[W+100>>2]=r;g[W+104>>2]=s;g[W+112>>2]=K;g[W+116>>2]=r;g[W+120>>2]=s;T=8;s=1.0;r=1.0;p=1.0;V=53}else{j=0;q=0;h=0;o=d;do{y=1.0/s*+g[o>>2];z=1.0/r*+g[o+4>>2];A=1.0/p*+g[o+8>>2];o=o+16|0;a:do if(h){l=0;while(1){d=W+(l<<4)|0;v=+g[d>>2];m=W+(l<<4)+4|0;w=+g[m>>2];n=W+(l<<4)+8|0;x=+g[n>>2];if(+N(+(v-y))<1.0000000474974513e-03&+N(+(w-z))<1.0000000474974513e-03&+N(+(x-A))<1.0000000474974513e-03)break;l=l+1|0;if(l>>>0>=h>>>0){n=l;break a}}if((y-1.0/s*E)*(y-1.0/s*E)+(z-1.0/r*C)*(z-1.0/r*C)+(A-1.0/p*B)*(A-1.0/p*B)>(v-1.0/s*E)*(v-1.0/s*E)+(w-1.0/r*C)*(w-1.0/r*C)+(x-1.0/p*B)*(x-1.0/p*B)){g[d>>2]=y;g[m>>2]=z;g[n>>2]=A;n=l}else n=l}else n=0;while(0);if((n|0)==(h|0)){g[W+(h<<4)>>2]=y;g[W+(h<<4)+4>>2]=z;g[W+(h<<4)+8>>2]=A;h=h+1|0}if((j|0)==(c[X+28>>2]|0)?(t=j|0?j<<1:1,(j|0)<(t|0)):0){if((t|0)!=0?(c[6435]=(c[6435]|0)+1,u=yc((t<<2|3)+16|0)|0,(u|0)!=0):0){c[(u+4+15&-16)+-4>>2]=u;m=u+4+15&-16}else m=0;d=c[X+32>>2]|0;if((j|0)<=0){if(d)V=39}else{l=0;do{c[m+(l<<2)>>2]=c[d+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0));V=39}if((V|0)==39){V=0;if(a[X+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[X+32>>2]=0;j=c[X+24>>2]|0}a[X+36>>0]=1;c[X+32>>2]=m;c[X+28>>2]=t}c[(c[X+32>>2]|0)+(j<<2)>>2]=n;j=(c[X+24>>2]|0)+1|0;c[X+24>>2]=j;q=q+1|0}while((q|0)!=(e|0));if(!h){j=1;A=3402823466385288598117041.0e14;x=-3402823466385288598117041.0e14;z=3402823466385288598117041.0e14;w=-3402823466385288598117041.0e14;y=3402823466385288598117041.0e14;v=-3402823466385288598117041.0e14}else{C=3402823466385288598117041.0e14;A=3402823466385288598117041.0e14;E=-3402823466385288598117041.0e14;x=-3402823466385288598117041.0e14;G=3402823466385288598117041.0e14;z=3402823466385288598117041.0e14;H=-3402823466385288598117041.0e14;w=-3402823466385288598117041.0e14;J=3402823466385288598117041.0e14;y=3402823466385288598117041.0e14;K=-3402823466385288598117041.0e14;v=-3402823466385288598117041.0e14;q=0;while(1){B=+g[W+(q<<4)>>2];j=BE;x=l?B:x;F=+g[W+(q<<4)+4>>2];d=FH;w=m?F:w;I=+g[W+(q<<4)+8>>2];n=IK;v=o?I:v;q=q+1|0;if((q|0)==(h|0))break;else{C=j?B:C;E=l?B:E;G=d?F:G;H=m?F:H;J=n?I:J;K=o?I:K}}j=h>>>0<3}x=x-A;C=w-z;v=v-y;if(!(j|(x<9.999999974752427e-07|C<9.999999974752427e-07|v<9.999999974752427e-07))){if(h|0){T=h;V=53;break}break}B=A+x*.5;A=z+C*.5;z=y+v*.5;y=x>=9.999999974752427e-07&x<3402823466385288598117041.0e14?x:3402823466385288598117041.0e14;y=C>=9.999999974752427e-07&C=9.999999974752427e-07&v>2]=I;g[W+4>>2]=G;g[W+8>>2]=F;g[W+16>>2]=H;g[W+20>>2]=G;g[W+24>>2]=F;g[W+32>>2]=H;g[W+36>>2]=J;g[W+40>>2]=F;g[W+48>>2]=I;g[W+52>>2]=J;g[W+56>>2]=F;g[W+64>>2]=I;g[W+68>>2]=G;g[W+72>>2]=K;g[W+80>>2]=H;g[W+84>>2]=G;g[W+88>>2]=K;g[W+96>>2]=H;g[W+100>>2]=J;g[W+104>>2]=K;g[W+112>>2]=I;g[W+116>>2]=J;g[W+120>>2]=K;T=8;V=53}while(0);if((V|0)==53){h=0;do{U=W+(h<<4)|0;g[U>>2]=s*+g[U>>2];U=W+(h<<4)+4|0;g[U>>2]=r*+g[U>>2];U=W+(h<<4)+8|0;g[U>>2]=p*+g[U>>2];h=h+1|0}while(h>>>0>>0);if((T|0)>=4){p=+g[W>>2];r=+g[W+4>>2];v=+g[W+8>>2];U=T<<2;c[6435]=(c[6435]|0)+1;h=yc((U|3)+16|0)|0;if(!h)j=0;else{c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}a[X+100+16>>0]=1;Q=X+100+12|0;c[Q>>2]=0;c[X+100+4>>2]=0;c[X+100+8>>2]=0;c[6435]=(c[6435]|0)+1;h=yc((U|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}a[X+100+16>>0]=1;c[Q>>2]=h;c[X+100+8>>2]=T;o=0;q=T;y=p;z=r;s=v;w=p;x=r;h=T;m=j;n=0;while(1){if((o|0)==(q|0)?(D=q|0?q<<1:1,(q|0)<(D|0)):0){if((D|0)!=0?(c[6435]=(c[6435]|0)+1,L=yc((D<<2|3)+16|0)|0,(L|0)!=0):0){c[(L+4+15&-16)+-4>>2]=L;l=L+4+15&-16}else l=0;d=c[Q>>2]|0;if((q|0)<=0){if(d|0)V=68}else{j=0;do{c[l+(j<<2)>>2]=c[d+(j<<2)>>2];j=j+1|0}while((j|0)!=(q|0));V=68}if((V|0)==68){V=0;c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);c[Q>>2]=0}a[X+100+16>>0]=1;c[Q>>2]=l;c[X+100+8>>2]=D}c[(c[Q>>2]|0)+(o<<2)>>2]=1;c[X+100+4>>2]=o+1;do if((n|0)==(h|0)){h=n|0?n<<1:1;if((n|0)<(h|0)){if((h|0)!=0?(c[6435]=(c[6435]|0)+1,M=yc((h<<2|3)+16|0)|0,(M|0)!=0):0){c[(M+4+15&-16)+-4>>2]=M;l=M+4+15&-16}else l=0;if((n|0)<=0){if(!m){P=l;break}}else{j=0;do{c[l+(j<<2)>>2]=c[m+(j<<2)>>2];j=j+1|0}while((j|0)!=(n|0))}c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0);P=l}else{h=n;P=m}}else P=m;while(0);c[P+(n<<2)>>2]=0;j=n+1|0;p=+g[W+(n<<4)>>2];w=p>2];x=r>2];v=K=(T|0))break;o=c[X+100+4>>2]|0;q=c[X+100+8>>2]|0;y=p;z=r;m=P;n=j}H=+O(+((p-w)*(p-w)+(r-x)*(r-x)+(s-v)*(s-v)))*1.0000000474974513e-03;L=Qe(W,T,.009999999776482582,.019999999552965164,1.0,X+100|0)|0;M=Qe(W,T,-.009999999776482582,-.019999999552965164,-1.0,X+100|0)|0;n=W+(L<<4)|0;o=W+(M<<4)|0;w=+g[n>>2]-+g[o>>2];q=W+(L<<4)+4|0;t=W+(M<<4)+4|0;x=+g[q>>2]-+g[t>>2];u=W+(L<<4)+8|0;D=W+(M<<4)+8|0;y=+g[u>>2]-+g[D>>2];b:do if((L|0)!=(M|0)?!(y==0.0&x==0.0&w==0.0):0){p=+O(+((y*.019999999552965164-x*0.0)*(y*.019999999552965164-x*0.0)+(w*0.0-y)*(w*0.0-y)+(x-w*.019999999552965164)*(x-w*.019999999552965164)));r=+O(+((y-x*0.0)*(y-x*0.0)+(y*.019999999552965164+w*0.0)*(y*.019999999552965164+w*0.0)+(x*-.019999999552965164-w)*(x*-.019999999552965164-w)));if(p>r){s=(x-w*.019999999552965164)*(1.0/p);v=(y*.019999999552965164-x*0.0)*(1.0/p);p=(w*0.0-y)*(1.0/p)}else{s=(x*-.019999999552965164-w)*(1.0/r);v=(y-x*0.0)*(1.0/r);p=(y*.019999999552965164+w*0.0)*(1.0/r)}h=Qe(W,T,v,p,s,X+100|0)|0;if((h|0)==(L|0)|(h|0)==(M|0))m=Qe(W,T,-v,-p,-s,X+100|0)|0;else m=h;if(!((m|0)==(L|0)|(m|0)==(M|0))){j=W+(m<<4)|0;p=+g[j>>2]-+g[n>>2];l=W+(m<<4)+4|0;r=+g[l>>2]-+g[q>>2];d=W+(m<<4)+8|0;s=+g[d>>2]-+g[u>>2];v=1.0/+O(+((x*p-r*w)*(x*p-r*w)+((r*y-s*x)*(r*y-s*x)+(s*w-y*p)*(s*w-y*p))));h=Qe(W,T,(r*y-s*x)*v,(s*w-y*p)*v,(x*p-r*w)*v,X+100|0)|0;if((h|0)==(m|0)|((h|0)==(L|0)|(h|0)==(M|0)))h=Qe(W,T,-((r*y-s*x)*v),-((s*w-y*p)*v),-((x*p-r*w)*v),X+100|0)|0;if(!((h|0)==(m|0)|((h|0)==(L|0)|(h|0)==(M|0)))?(B=+g[n>>2],F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+O(+((s*x-v*w)*(s*x-v*w)+((v*r-p*x)*(v*r-p*x)+(p*w-s*r)*(p*w-s*r))));if(y==0.0){z=1.0;p=0.0;r=0.0;j=1065353216;l=0;h=0}else{j=(g[k>>2]=1.0/y*(v*r-p*x),c[k>>2]|0);l=(g[k>>2]=1.0/y*(p*w-s*r),c[k>>2]|0);z=1.0/y*(v*r-p*x);p=1.0/y*(p*w-s*r);r=1.0/y*(s*x-v*w);h=(g[k>>2]=1.0/y*(s*x-v*w),c[k>>2]|0)}J=(c[k>>2]=j,+g[k>>2]);K=(c[k>>2]=l,+g[k>>2]);S=Qe(W,T,J,K,(c[k>>2]=h,+g[k>>2]),X+100|0)|0;c[d+28>>2]=S;h=c[d>>2]|0;g[d+32>>2]=(+g[W+(S<<4)>>2]-+g[W+(h<<4)>>2])*z+(+g[W+(S<<4)+4>>2]-+g[W+(h<<4)+4>>2])*p+(+g[W+(S<<4)+8>>2]-+g[W+(h<<4)+8>>2])*r;n=n+1|0;h=c[X+4>>2]|0}while((n|0)<(h|0))}if((e+-4|0)>0){q=e+-4|0;while(1){d=c[X+12>>2]|0;m=0;l=0;while(1){j=c[d+(m<<2)>>2]|0;do if(l){if(!j){j=l;break}if(!(+g[l+32>>2]<+g[j+32>>2]))j=l;else V=104}else V=104;while(0);if((V|0)==104)V=0;m=m+1|0;if((m|0)>=(h|0))break;else l=j}if((j|0)==0?1:!(+g[j+32>>2]>H)){h=1;break b}o=c[j+28>>2]|0;c[P+(o<<2)>>2]=1;h=c[X+4>>2]|0;c:do if(!h)h=0;else{l=W+(o<<4)|0;d=W+(o<<4)+4|0;m=W+(o<<4)+8|0;do{h=h+-1|0;j=c[(c[X+12>>2]|0)+(h<<2)>>2]|0;do if(j|0){S=c[j>>2]|0;R=c[j+4>>2]|0;e=c[j+8>>2]|0;s=+g[W+(R<<4)>>2];z=+g[W+(S<<4)>>2];v=+g[W+(R<<4)+4>>2];A=+g[W+(S<<4)+4>>2];p=+g[W+(R<<4)+8>>2];B=+g[W+(S<<4)+8>>2];w=+g[W+(e<<4)>>2]-s;x=+g[W+(e<<4)+4>>2]-v;r=+g[W+(e<<4)+8>>2]-p;y=+O(+(((s-z)*x-(v-A)*w)*((s-z)*x-(v-A)*w)+(((v-A)*r-(p-B)*x)*((v-A)*r-(p-B)*x)+((p-B)*w-(s-z)*r)*((p-B)*w-(s-z)*r))));if(y==0.0){C=1.0;r=0.0;p=0.0}else{C=1.0/y*((v-A)*r-(p-B)*x);r=1.0/y*((p-B)*w-(s-z)*r);p=1.0/y*((s-z)*x-(v-A)*w)}if(!(C*(+g[l>>2]-z)+r*(+g[d>>2]-A)+p*(+g[m>>2]-B)>H*.009999999776482582))break;ue(X,j,o)}while(0)}while((h|0)!=0);h=c[X+4>>2]|0;if(!h){h=0;break}else j=h;d:do{j=j+-1|0;m=c[X+12>>2]|0;n=c[m+(j<<2)>>2]|0;do if(n){d=c[n>>2]|0;do if((d|0)!=(o|0)){l=c[n+4>>2]|0;if((l|0)==(o|0)){l=o;break}if((c[n+8>>2]|0)!=(o|0))break d}else l=c[n+4>>2]|0;while(0);e=c[n+8>>2]|0;z=+g[W+(l<<4)>>2];B=+g[W+(d<<4)>>2];A=+g[W+(l<<4)+4>>2];C=+g[W+(d<<4)+4>>2];r=+g[W+(l<<4)+8>>2];w=+g[W+(d<<4)+8>>2];s=+g[W+(e<<4)>>2]-z;v=+g[W+(e<<4)+4>>2]-A;p=+g[W+(e<<4)+8>>2]-r;x=+O(+(((z-B)*v-(A-C)*s)*((z-B)*v-(A-C)*s)+(((A-C)*p-(r-w)*v)*((A-C)*p-(r-w)*v)+((r-w)*s-(z-B)*p)*((r-w)*s-(z-B)*p))));if(x==0.0){y=1.0;r=0.0;p=0.0}else{y=1.0/x*((A-C)*p-(r-w)*v);r=1.0/x*((r-w)*s-(z-B)*p);p=1.0/x*((z-B)*v-(A-C)*s)}if(!(xH*.009999999776482582))break;ue(X,c[m+(c[n+12>>2]<<2)>>2]|0,o);j=c[X+4>>2]|0;h=j}while(0)}while((j|0)!=0);if(!h){h=0;break}n=c[X+12>>2]|0;m=h;do{m=m+-1|0;o=c[n+(m<<2)>>2]|0;do if(o|0){if((c[o+28>>2]|0)>-1)break c;S=c[o>>2]|0;R=c[o+4>>2]|0;e=c[o+8>>2]|0;w=+g[W+(R<<4)>>2];s=w-+g[W+(S<<4)>>2];x=+g[W+(R<<4)+4>>2];v=x-+g[W+(S<<4)+4>>2];r=+g[W+(R<<4)+8>>2];p=r-+g[W+(S<<4)+8>>2];w=+g[W+(e<<4)>>2]-w;x=+g[W+(e<<4)+4>>2]-x;r=+g[W+(e<<4)+8>>2]-r;y=+O(+((s*x-v*w)*(s*x-v*w)+((v*r-p*x)*(v*r-p*x)+(p*w-s*r)*(p*w-s*r))));if(y==0.0){z=1.0;p=0.0;r=0.0;l=1065353216;d=0;j=0}else{l=(g[k>>2]=1.0/y*(v*r-p*x),c[k>>2]|0);d=(g[k>>2]=1.0/y*(p*w-s*r),c[k>>2]|0);z=1.0/y*(v*r-p*x);p=1.0/y*(p*w-s*r);r=1.0/y*(s*x-v*w);j=(g[k>>2]=1.0/y*(s*x-v*w),c[k>>2]|0)}J=(c[k>>2]=l,+g[k>>2]);K=(c[k>>2]=d,+g[k>>2]);j=Qe(W,T,J,K,(c[k>>2]=j,+g[k>>2]),X+100|0)|0;c[o+28>>2]=j;if(!(c[P+(j<<2)>>2]|0)){e=c[o>>2]|0;g[o+32>>2]=(+g[W+(j<<4)>>2]-+g[W+(e<<4)>>2])*z+(+g[W+(j<<4)+4>>2]-+g[W+(e<<4)+4>>2])*p+(+g[W+(j<<4)+8>>2]-+g[W+(e<<4)+8>>2])*r;break}else{c[o+28>>2]=-1;break}}while(0)}while((m|0)!=0)}while(0);if((q|0)<=1){h=1;break b}q=q+-1|0}}else h=1}else h=0}else h=0}else h=0;while(0);j=c[Q>>2]|0;if(j|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);c[Q>>2]=0}if(P|0){c[6436]=(c[6436]|0)+1;hd(c[P+-4>>2]|0)}if(h){h=c[X+4>>2]|0;if((h|0)>0){j=c[X+12>>2]|0;t=0;o=0;l=0;d=0;while(1){n=c[j+(t<<2)>>2]|0;if(!n)m=o;else{do if((d|0)==(o|0)){m=o|0?o<<1:1;if((o|0)>=(m|0)){m=o;break}do if(!m)j=0;else{c[6435]=(c[6435]|0)+1;h=yc((m<<2|3)+16|0)|0;if(!h){j=0;break}c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}while(0);if((o|0)<=0){if(!l){l=j;break}}else{h=0;do{c[j+(h<<2)>>2]=c[l+(h<<2)>>2];h=h+1|0}while((h|0)!=(o|0))}c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);l=j}else m=o;while(0);c[l+(d<<2)>>2]=c[n>>2];o=d+1|0;q=(c[(c[X+12>>2]|0)+(t<<2)>>2]|0)+4|0;do if((o|0)==(m|0)){n=m|0?m<<1:1;if((m|0)>=(n|0))break;do if(!n)j=0;else{c[6435]=(c[6435]|0)+1;h=yc((n<<2|3)+16|0)|0;if(!h){j=0;break}c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}while(0);if((m|0)<=0){if(!l){m=n;l=j;break}}else{h=0;do{c[j+(h<<2)>>2]=c[l+(h<<2)>>2];h=h+1|0}while((h|0)!=(m|0))}c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);m=n;l=j}while(0);c[l+(o<<2)>>2]=c[q>>2];o=d+2|0;q=(c[(c[X+12>>2]|0)+(t<<2)>>2]|0)+8|0;do if((o|0)==(m|0)){n=m|0?m<<1:1;if((m|0)>=(n|0))break;do if(!n)j=0;else{c[6435]=(c[6435]|0)+1;h=yc((n<<2|3)+16|0)|0;if(!h){j=0;break}c[(h+4+15&-16)+-4>>2]=h;j=h+4+15&-16}while(0);if((m|0)<=0){if(!l){m=n;l=j;break}}else{h=0;do{c[j+(h<<2)>>2]=c[l+(h<<2)>>2];h=h+1|0}while((h|0)!=(m|0))}c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);m=n;l=j}while(0);c[l+(o<<2)>>2]=c[q>>2];j=c[X+12>>2]|0;h=c[j+(t<<2)>>2]|0;c[j+(c[h+24>>2]<<2)>>2]=0;if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}h=c[X+4>>2]|0;d=d+3|0}t=t+1|0;if((t|0)>=(h|0))break;else o=m}c[X+96>>2]=(d|0)/3|0;if((d|0)>0){c[6435]=(c[6435]|0)+1;h=yc((d<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}Qn(h|0,0,d<<2|0)|0;j=0;do{c[h+(j<<2)>>2]=c[l+(j<<2)>>2];j=j+1|0}while((j|0)!=(d|0));m=l;M=d}else{h=0;m=l;M=d}}else{c[X+96>>2]=0;h=0;m=0;M=0}l=c[X+4>>2]|0;if((l|0)<0){j=c[X+12>>2]|0;if((c[X+8>>2]|0)<0){if(j|0){if(a[X+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[X+12>>2]=0}a[X+16>>0]=1;c[X+12>>2]=0;c[X+8>>2]=0;j=0}do{c[j+(l<<2)>>2]=0;l=l+1|0}while((l|0)!=0)}c[X+4>>2]=0;if(m|0){c[6436]=(c[6436]|0)+1;hd(c[m+-4>>2]|0)}L=c[X+96>>2]|0;m=(T|0)>0;if(m){c[6435]=(c[6435]|0)+1;j=yc((T<<4|3)+16|0)|0;if(!j)l=0;else{c[(j+4+15&-16)+-4>>2]=j;l=j+4+15&-16}j=0;do{e=l+(j<<4)|0;c[e>>2]=c[X+64>>2];c[e+4>>2]=c[X+64+4>>2];c[e+8>>2]=c[X+64+8>>2];c[e+12>>2]=c[X+64+12>>2];j=j+1|0}while((j|0)!=(T|0));D=l}else D=0;l=c[X+24>>2]|0;do if((l|0)>0){c[6435]=(c[6435]|0)+1;j=yc((l<<2|3)+16|0)|0;if(!j)d=0;else{c[(j+4+15&-16)+-4>>2]=j;d=j+4+15&-16}Qn(d|0,0,l<<2|0)|0;if((c[X+24>>2]|0)<=0)break;j=c[X+32>>2]|0;l=0;do{c[d+(l<<2)>>2]=c[j+(l<<2)>>2];l=l+1|0}while((l|0)<(c[X+24>>2]|0))}else d=0;while(0);if(m){c[6435]=(c[6435]|0)+1;j=yc((U|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}Qn(j|0,0,U|0)|0}else j=0;Qn(j|0,0,U|0)|0;if((L|0)<=0)if(!j)q=0;else{l=0;V=222}else{t=c[X+32>>2]|0;u=0;l=0;do{m=h+(u<<2)|0;o=c[m>>2]|0;q=j+(o<<2)|0;n=c[q>>2]|0;if(!n){c[m>>2]=l;c[D+(l<<4)>>2]=c[W+(o<<4)>>2];c[D+(l<<4)+4>>2]=c[W+(o<<4)+4>>2];c[D+(l<<4)+8>>2]=c[W+(o<<4)+8>>2];m=c[X+24>>2]|0;if((m|0)>0){n=0;do{if((c[d+(n<<2)>>2]|0)==(o|0))c[t+(n<<2)>>2]=l;n=n+1|0}while((n|0)!=(m|0))}l=l+1|0;c[q>>2]=l}else c[m>>2]=n+-1;u=u+1|0}while((u|0)!=(L*3|0));V=222}if((V|0)==222){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);q=l}if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}if((q|0)>0){c[6435]=(c[6435]|0)+1;j=yc((q<<4|3)+16|0)|0;if(!j)j=0;else{c[(j+4+15&-16)+-4>>2]=j;j=j+4+15&-16}l=0;do{V=j+(l<<4)|0;c[V>>2]=c[X+48>>2];c[V+4>>2]=c[X+48+4>>2];c[V+8>>2]=c[X+48+8>>2];c[V+12>>2]=c[X+48+12>>2];l=l+1|0}while((l|0)!=(q|0))}else j=0;if((L|0)>0){c[6435]=(c[6435]|0)+1;l=yc((L*12|3)+16|0)|0;if(!l)l=0;else{c[(l+4+15&-16)+-4>>2]=l;l=l+4+15&-16}d=c[X+40>>2]|0;if(!d)c[X+40>>2]=l;else{c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);c[X+40>>2]=l}Qn(l|0,0,L*12|0)|0}_m(j|0,D|0,q<<4|0)|0;_m(c[X+40>>2]|0,h|0,L*12|0)|0;do if(M){if(!h){h=0;break}c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);h=0}while(0);if(!D){n=L;o=L*3|0;break}c[6436]=(c[6436]|0)+1;hd(c[D+-4>>2]|0);n=L;o=L*3|0;break}}}h=0;q=0;j=0;n=0;o=0}while(0);if(W|0){c[6436]=(c[6436]|0)+1;hd(c[W+-4>>2]|0)}if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[6435]=(c[6435]|0)+1;h=yc(1271)|0;if(!h)D=0;else{c[(h+4+15&-16)+-4>>2]=h;D=h+4+15&-16}Kc(D,b,q,j,0);if((n|0)>0){m=0;do{d=m*3|0;b=c[X+40>>2]|0;h=c[b+(d<<2)>>2]|0;l=c[b+(d+1<<2)>>2]|0;d=c[b+(d+2<<2)>>2]|0;if((h|0)<(l|0))Rf(D,h,l,0,0);if((l|0)<(d|0))Rf(D,l,d,0,0);if((d|0)<(h|0))Rf(D,d,h,0,0);Zf(D,h,l,d,0);m=m+1|0}while((m|0)!=(n|0))}if(q)if(!j)j=0;else{c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);j=0}if(o|0){h=c[X+40>>2]|0;if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);c[X+40>>2]=0}c[X+40>>2]=0}if(f){l=c[D+732>>2]|0;if((l|0)>0){d=D+740|0;o=0;h=243703;do{m=c[d>>2]|0;n=m+(o*52|0)|0;h=(_(h,1664525)|0)+1013904223|0;q=X+100|0;t=n;u=q+52|0;do{c[q>>2]=c[t>>2];q=q+4|0;t=t+4|0}while((q|0)<(u|0));q=n;t=m+(((h>>>0)%(l>>>0)|0)*52|0)|0;u=q+52|0;do{c[q>>2]=c[t>>2];q=q+4|0;t=t+4|0}while((q|0)<(u|0));q=m+(((h>>>0)%(l>>>0)|0)*52|0)|0;t=X+100|0;u=q+52|0;do{c[q>>2]=c[t>>2];q=q+4|0;t=t+4|0}while((q|0)<(u|0));o=o+1|0}while((o|0)!=(l|0))}else h=243703;m=c[D+752>>2]|0;if((m|0)>0){n=D+760|0;o=0;do{d=c[n>>2]|0;l=d+(o*44|0)|0;h=(_(h,1664525)|0)+1013904223|0;d=d+(((h>>>0)%(m>>>0)|0)*44|0)|0;q=X+100|0;t=l;u=q+44|0;do{c[q>>2]=c[t>>2];q=q+4|0;t=t+4|0}while((q|0)<(u|0));q=l;t=d;u=q+44|0;do{c[q>>2]=c[t>>2];q=q+4|0;t=t+4|0}while((q|0)<(u|0));q=d;t=X+100|0;u=q+44|0;do{c[q>>2]=c[t>>2];q=q+4|0;t=t+4|0}while((q|0)<(u|0));o=o+1|0}while((o|0)!=(m|0))}}h=c[X+32>>2]|0;if(h|0){if(a[X+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[X+32>>2]=0}a[X+36>>0]=1;c[X+32>>2]=0;c[X+24>>2]=0;c[X+28>>2]=0;h=c[X+12>>2]|0;if(h|0){if(a[X+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[X+12>>2]=0}h=c[X+40>>2]|0;if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);c[X+40>>2]=0}c[X+40>>2]=0;if(!j){i=X;return D|0}c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);i=X;return D|0}function sc(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,l=0,m=0.0,n=0.0,o=0.0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0.0,L=0.0,M=0.0,O=0.0;I=i;i=i+16|0;f=c[b+1112>>2]|0;a:do if((f|0)>0)while(1){p=c[c[b+1120>>2]>>2]|0;f=c[p+348>>2]|0;if(f|0){hh(b+1048|0,f)|0;h=c[b+1052>>2]|0;if(h|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+1052>>2]=f;c[b+1060>>2]=(c[b+1060>>2]|0)+-1}Fk(p);if(p|0){c[6436]=(c[6436]|0)+1;hd(c[p+-4>>2]|0)}f=c[b+1112>>2]|0;if((f|0)<=0){p=f;break a}l=c[b+1120>>2]|0;h=0;do{j=l+(h<<2)|0;if((c[j>>2]|0)==(p|0)){H=14;break}h=h+1|0}while((h|0)<(f|0));if((H|0)==14){H=0;if((h|0)<(f|0)){c[j>>2]=c[l+(f+-1<<2)>>2];c[(c[b+1120>>2]|0)+(f+-1<<2)>>2]=p;c[b+1112>>2]=f+-1;f=f+-1|0}}if((f|0)<=0){p=f;break}}else p=f;while(0);f=c[b+712>>2]|0;f=(f|0)>(d|0)?d:f;if((p|0)<(f|0)){if((c[b+1116>>2]|0)<(f|0)){if(f){c[6435]=(c[6435]|0)+1;h=yc((f<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[b+1112>>2]|0;if((j|0)>0){l=0;do{c[h+(l<<2)>>2]=c[(c[b+1120>>2]|0)+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0));j=b+1120|0}else j=b+1120|0}else{h=0;j=b+1120|0}l=c[j>>2]|0;if(l|0){if(a[b+1124>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0)}c[j>>2]=0}a[b+1124>>0]=1;c[j>>2]=h;c[b+1116>>2]=f}else j=b+1120|0;h=p;do{c[(c[j>>2]|0)+(h<<2)>>2]=0;h=h+1|0}while((h|0)!=(f|0))}c[b+1112>>2]=f;if((f|0)>0){h=0;do{c[6435]=(c[6435]|0)+1;f=yc(403)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}a[f+16>>0]=1;c[f+12>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;a[f+36>>0]=1;c[f+32>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;a[f+56>>0]=1;c[f+52>>2]=0;c[f+44>>2]=0;c[f+48>>2]=0;j=f+348|0;c[j>>2]=0;c[j+4>>2]=0;c[j+8>>2]=0;c[j+12>>2]=0;c[j+16>>2]=0;g[f+368>>2]=100.0;g[f+372>>2]=.009999999776482582;a[f+376>>0]=0;c[(c[b+1120>>2]|0)+(h<<2)>>2]=f;j=c[b+1120>>2]|0;a[(c[j+(h<<2)>>2]|0)+377>>0]=1;h=h+1|0;f=c[b+1112>>2]|0}while((h|0)<(f|0));if((f|0)>0){h=c[b+712>>2]|0;b:do if((h|0)>0){s=f;d=j;l=0;p=0;j=0;u=0;while(1){t=c[b+720>>2]|0;l=(g[k>>2]=(c[k>>2]=l,+g[k>>2])+ +g[t+(u*104|0)+8>>2],c[k>>2]|0);j=(g[k>>2]=(c[k>>2]=j,+g[k>>2])+ +g[t+(u*104|0)+12>>2],c[k>>2]|0);p=(g[k>>2]=(c[k>>2]=p,+g[k>>2])+ +g[t+(u*104|0)+16>>2],c[k>>2]|0);s=c[d+(((u*29873|0)%(s|0)|0)<<2)>>2]|0;t=t+(u*104|0)|0;d=c[s+24>>2]|0;if((d|0)==(c[s+28>>2]|0)?(v=d|0?d<<1:1,(d|0)<(v|0)):0){if(!v)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((v<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}d=c[s+24>>2]|0}if((d|0)>0){r=0;do{c[h+(r<<2)>>2]=c[(c[s+32>>2]|0)+(r<<2)>>2];r=r+1|0}while((r|0)!=(d|0))}r=c[s+32>>2]|0;if(r){if(a[s+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[r+-4>>2]|0);d=c[s+24>>2]|0}c[s+32>>2]=0}a[s+36>>0]=1;c[s+32>>2]=h;c[s+28>>2]=v;h=c[b+712>>2]|0}c[(c[s+32>>2]|0)+(d<<2)>>2]=t;c[s+24>>2]=d+1;r=u+1|0;if((r|0)>=(h|0))break b;s=c[b+1112>>2]|0;d=c[b+1120>>2]|0;u=r}}else{l=0;p=0;j=0}while(0);m=1.0/+(h|0);o=(c[k>>2]=l,+g[k>>2])*m;n=(c[k>>2]=j,+g[k>>2])*m;m=(c[k>>2]=p,+g[k>>2])*m;if((f|0)<0)E=0;else{if((f|0)!=0?(c[6435]=(c[6435]|0)+1,w=yc((f<<4|3)+16|0)|0,(w|0)!=0):0){c[(w+4+15&-16)+-4>>2]=w;h=w+4+15&-16}else h=0;j=0;do{g[h+(j<<4)>>2]=o;g[h+(j<<4)+4>>2]=n;g[h+(j<<4)+8>>2]=m;g[h+(j<<4)+12>>2]=0.0;j=j+1|0}while((j|0)!=(f|0));E=h}u=E+4|0;v=E+8|0;w=0;do{m=+(w|0)*.0625;m=2.0-(m>1.0?1.0:m);s=0;t=0;do{h=c[(c[b+1120>>2]|0)+(t<<2)>>2]|0;r=c[h+24>>2]|0;if((r|0)>0){p=c[h+32>>2]|0;l=0;j=0;h=0;d=0;do{J=c[p+(d<<2)>>2]|0;l=(g[k>>2]=(c[k>>2]=l,+g[k>>2])+ +g[J+8>>2],c[k>>2]|0);j=(g[k>>2]=(c[k>>2]=j,+g[k>>2])+ +g[J+12>>2],c[k>>2]|0);h=(g[k>>2]=(c[k>>2]=h,+g[k>>2])+ +g[J+16>>2],c[k>>2]|0);d=d+1|0}while((d|0)!=(r|0))}else{l=0;j=0;h=0}if(r){x=(c[k>>2]=l,+g[k>>2])*(1.0/+(r|0));z=(c[k>>2]=j,+g[k>>2])*(1.0/+(r|0));d=E+(t<<4)|0;y=+g[d>>2];J=E+(t<<4)+4|0;A=+g[J>>2];p=E+(t<<4)+8|0;q=+g[p>>2];B=q+m*((c[k>>2]=h,+g[k>>2])*(1.0/+(r|0))-q);l=s|(y+m*(x-y)-y)*(y+m*(x-y)-y)+(A+m*(z-A)-A)*(A+m*(z-A)-A)+(B-q)*(B-q)>1.1920928955078125e-07;g[d>>2]=y+m*(x-y);g[J>>2]=A+m*(z-A);g[p>>2]=B;g[E+(t<<4)+12>>2]=0.0;p=c[(c[b+1120>>2]|0)+(t<<2)>>2]|0;h=c[p+24>>2]|0;if((h|0)<0){if((c[p+28>>2]|0)<0){j=c[p+32>>2]|0;if(j|0){if(a[p+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[p+32>>2]=0}a[p+36>>0]=1;c[p+32>>2]=0;c[p+28>>2]=0}do{c[(c[p+32>>2]|0)+(h<<2)>>2]=0;h=h+1|0}while((h|0)!=0)}c[p+24>>2]=0;s=l}t=t+1|0}while((t|0)<(f|0));w=w+1|0;h=c[b+712>>2]|0;c:do if((h|0)>0){if((f|0)>1)t=0;else{r=0;while(1){p=c[c[b+1120>>2]>>2]|0;d=(c[b+720>>2]|0)+(r*104|0)|0;j=c[p+24>>2]|0;if((j|0)==(c[p+28>>2]|0)?(D=j|0?j<<1:1,(j|0)<(D|0)):0){if(!D)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((D<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[p+24>>2]|0}if((j|0)>0){l=0;do{c[h+(l<<2)>>2]=c[(c[p+32>>2]|0)+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0))}l=c[p+32>>2]|0;if(l){if(a[p+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);j=c[p+24>>2]|0}c[p+32>>2]=0}a[p+36>>0]=1;c[p+32>>2]=h;c[p+28>>2]=D;h=c[b+712>>2]|0}c[(c[p+32>>2]|0)+(j<<2)>>2]=d;c[p+24>>2]=j+1;r=r+1|0;if((r|0)>=(h|0))break c}}do{d=c[b+720>>2]|0;m=+g[d+(t*104|0)+8>>2];n=+g[d+(t*104|0)+12>>2];o=+g[d+(t*104|0)+16>>2];l=1;p=0;x=+N(+(+g[E>>2]-m))+ +N(+(+g[u>>2]-n))+ +N(+(+g[v>>2]-o));while(1){q=+N(+(+g[E+(l<<4)>>2]-m))+ +N(+(+g[E+(l<<4)+4>>2]-n))+ +N(+(+g[E+(l<<4)+8>>2]-o));j=q>2]|0)+(p<<2)>>2]|0;p=d+(t*104|0)|0;j=c[r+24>>2]|0;if((j|0)==(c[r+28>>2]|0)?(C=j|0?j<<1:1,(j|0)<(C|0)):0){if(!C)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((C<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[r+24>>2]|0}if((j|0)>0){l=0;do{c[h+(l<<2)>>2]=c[(c[r+32>>2]|0)+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0))}l=c[r+32>>2]|0;if(l){if(a[r+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[l+-4>>2]|0);j=c[r+24>>2]|0}c[r+32>>2]=0}a[r+36>>0]=1;c[r+32>>2]=h;c[r+28>>2]=C;h=c[b+712>>2]|0}c[(c[r+32>>2]|0)+(j<<2)>>2]=p;c[r+24>>2]=j+1;t=t+1|0}while((t|0)<(h|0))}while(0)}while((w|0)<(e|0)&s);if((h|0)>0){h=h<<2;c[6435]=(c[6435]|0)+1;f=yc((h|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}Qn(f|0,-1,h|0)|0;w=f}else w=0;f=c[b+1112>>2]|0;if((f|0)>0){d=c[b+1120>>2]|0;p=0;do{h=c[d+(p<<2)>>2]|0;if((c[h+24>>2]|0)>0){j=c[b+720>>2]|0;l=c[(c[b+1120>>2]|0)+(p<<2)>>2]|0;f=0;while(1){c[w+((((c[(c[h+32>>2]|0)+(f<<2)>>2]|0)-j|0)/104|0)<<2)>>2]=p;f=f+1|0;if((f|0)<(c[l+24>>2]|0))h=l;else break}f=c[b+1112>>2]|0}p=p+1|0}while((p|0)<(f|0))}if((c[b+752>>2]|0)>0){t=0;do{J=c[b+760>>2]|0;f=c[b+720>>2]|0;h=((c[J+(t*44|0)+8>>2]|0)-f|0)/104|0;c[I>>2]=h;c[I+4>>2]=((c[J+(t*44|0)+12>>2]|0)-f|0)/104|0;c[I+8>>2]=((c[J+(t*44|0)+16>>2]|0)-f|0)/104|0;f=0;while(1){d=c[w+(h<<2)>>2]|0;s=1;do{h=c[I+(((s+f|0)%3|0)<<2)>>2]|0;d:do if((c[w+(h<<2)>>2]|0)!=(d|0)){r=c[(c[b+1120>>2]|0)+(d<<2)>>2]|0;p=(c[b+720>>2]|0)+(h*104|0)|0;h=c[r+24>>2]|0;e:do if((h|0)>0){l=c[r+32>>2]|0;j=0;while(1){if((c[l+(j<<2)>>2]|0)==(p|0))break;j=j+1|0;if((j|0)>=(h|0))break e}if((j|0)!=(h|0))break d}while(0);if((h|0)==(c[r+28>>2]|0)?(F=h|0?h<<1:1,(h|0)<(F|0)):0){if(!F)l=0;else{c[6435]=(c[6435]|0)+1;h=yc((F<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}l=h;h=c[r+24>>2]|0}if((h|0)>0){j=0;do{c[l+(j<<2)>>2]=c[(c[r+32>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(h|0))}j=c[r+32>>2]|0;if(j){if(a[r+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);h=c[r+24>>2]|0}c[r+32>>2]=0}a[r+36>>0]=1;c[r+32>>2]=l;c[r+28>>2]=F}c[(c[r+32>>2]|0)+(h<<2)>>2]=p;c[r+24>>2]=h+1}while(0);s=s+1|0}while((s|0)!=3);f=f+1|0;if((f|0)>=3)break;h=c[I+(f<<2)>>2]|0}t=t+1|0}while((t|0)<(c[b+752>>2]|0));f=c[b+1112>>2]|0}if((f|0)>1){c[6435]=(c[6435]|0)+1;f=yc(403)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}a[f+16>>0]=1;c[f+12>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;r=f+36|0;a[r>>0]=1;s=f+32|0;c[s>>2]=0;t=f+24|0;c[t>>2]=0;u=f+28|0;c[u>>2]=0;a[f+56>>0]=1;c[f+52>>2]=0;c[f+44>>2]=0;c[f+48>>2]=0;v=f+348|0;c[v>>2]=0;c[v+4>>2]=0;c[v+8>>2]=0;c[v+12>>2]=0;c[v+16>>2]=0;g[f+368>>2]=100.0;g[f+372>>2]=.009999999776482582;a[f+376>>0]=0;v=f;a[f+377>>0]=0;l=c[b+712>>2]|0;if((l|0)>0){c[6435]=(c[6435]|0)+1;f=yc((l<<2|3)+16|0)|0;if(!f)j=0;else{c[(f+4+15&-16)+-4>>2]=f;j=f+4+15&-16}f=c[t>>2]|0;if((f|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[s>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}f=c[s>>2]|0;if(f|0){if(a[r>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[s>>2]=0}a[r>>0]=1;c[s>>2]=j;c[u>>2]=l;f=c[b+712>>2]|0;if((f|0)>0){j=c[t>>2]|0;h=l;d=0;while(1){p=(c[b+720>>2]|0)+(d*104|0)|0;do if((j|0)==(h|0)){l=h|0?h<<1:1;if((h|0)>=(l|0)){l=h;break}if(!l)f=0;else{c[6435]=(c[6435]|0)+1;f=yc((l<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=c[t>>2]|0}if((h|0)>0){j=0;do{c[f+(j<<2)>>2]=c[(c[s>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(h|0))}j=c[s>>2]|0;if(j){if(a[r>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0);h=c[t>>2]|0}c[s>>2]=0}a[r>>0]=1;c[s>>2]=f;c[u>>2]=l;f=c[b+712>>2]|0}else{l=h;h=j}while(0);c[(c[s>>2]|0)+(h<<2)>>2]=p;j=h+1|0;c[t>>2]=j;d=d+1|0;if((d|0)>=(f|0))break;else h=l}}}f=c[b+1112>>2]|0;if((f|0)==(c[b+1116>>2]|0)?(G=f|0?f<<1:1,(f|0)<(G|0)):0){if(!G)j=0;else{c[6435]=(c[6435]|0)+1;f=yc((G<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=f;f=c[b+1112>>2]|0}if((f|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[b+1120>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}h=c[b+1120>>2]|0;if(h){if(a[b+1124>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);f=c[b+1112>>2]|0}c[b+1120>>2]=0}a[b+1124>>0]=1;c[b+1120>>2]=j;c[b+1116>>2]=G}c[(c[b+1120>>2]|0)+(f<<2)>>2]=v;J=f+1|0;c[b+1112>>2]=J;F=c[b+1120>>2]|0;f=F+(f<<2)|0;G=c[F>>2]|0;c[F>>2]=c[f>>2];c[f>>2]=G;f=J}if((f|0)>0){h=0;do{d=c[(c[b+1120>>2]|0)+(h<<2)>>2]|0;f:do if(!(c[d+24>>2]|0)){h=h+-1|0;f=c[d+348>>2]|0;if(f|0){hh(b+1048|0,f)|0;j=c[b+1052>>2]|0;if(j|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[b+1052>>2]=f;c[b+1060>>2]=(c[b+1060>>2]|0)+-1}Fk(d);if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}f=c[b+1112>>2]|0;if((f|0)>0){p=c[b+1120>>2]|0;j=0;while(1){l=p+(j<<2)|0;if((c[l>>2]|0)==(d|0))break;j=j+1|0;if((j|0)>=(f|0))break f}if((j|0)<(f|0)){c[l>>2]=c[p+(f+-1<<2)>>2];c[(c[b+1120>>2]|0)+(f+-1<<2)>>2]=d;c[b+1112>>2]=f+-1;f=f+-1|0}}}while(0);h=h+1|0}while((h|0)<(f|0))}if(w|0){c[6436]=(c[6436]|0)+1;hd(c[w+-4>>2]|0)}if(E|0){c[6436]=(c[6436]|0)+1;hd(c[E+-4>>2]|0)}}else H=212}else H=212;g:do if((H|0)==212){p=c[b+772>>2]|0;if(p|0){if((f|0)<(p|0)){if((c[b+1116>>2]|0)<(p|0)){c[6435]=(c[6435]|0)+1;h=yc((p<<2|3)+16|0)|0;if(!h)l=0;else{c[(h+4+15&-16)+-4>>2]=h;l=h+4+15&-16}h=c[b+1112>>2]|0;if((h|0)>0){j=0;do{c[l+(j<<2)>>2]=c[(c[b+1120>>2]|0)+(j<<2)>>2];j=j+1|0}while((j|0)!=(h|0))}h=c[b+1120>>2]|0;if(h|0){if(a[b+1124>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[b+1120>>2]=0}a[b+1124>>0]=1;c[b+1120>>2]=l;c[b+1116>>2]=p;h=b+1120|0}else h=b+1120|0;do{c[(c[h>>2]|0)+(f<<2)>>2]=0;f=f+1|0}while((f|0)!=(p|0))}c[b+1112>>2]=p;if((p|0)>0){h=0;do{c[6435]=(c[6435]|0)+1;f=yc(403)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}a[f+16>>0]=1;c[f+12>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;a[f+36>>0]=1;c[f+32>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;a[f+56>>0]=1;c[f+52>>2]=0;c[f+44>>2]=0;c[f+48>>2]=0;J=f+348|0;c[J>>2]=0;c[J+4>>2]=0;c[J+8>>2]=0;c[J+12>>2]=0;c[J+16>>2]=0;g[f+368>>2]=100.0;g[f+372>>2]=.009999999776482582;a[f+376>>0]=0;c[(c[b+1120>>2]|0)+(h<<2)>>2]=f;a[(c[(c[b+1120>>2]|0)+(h<<2)>>2]|0)+377>>0]=1;h=h+1|0}while((h|0)<(c[b+1112>>2]|0))}if((c[b+772>>2]|0)<=0)break;d=0;while(1){r=0;do{l=c[(c[b+1120>>2]|0)+(d<<2)>>2]|0;p=(c[b+780>>2]|0)+(d*104|0)+8+(r<<2)|0;f=c[l+24>>2]|0;if((f|0)==(c[l+28>>2]|0)?(s=f|0?f<<1:1,(f|0)<(s|0)):0){if(!s)j=0;else{c[6435]=(c[6435]|0)+1;f=yc((s<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=f;f=c[l+24>>2]|0}if((f|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[l+32>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}h=c[l+32>>2]|0;if(h){if(a[l+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);f=c[l+24>>2]|0}c[l+32>>2]=0}a[l+36>>0]=1;c[l+32>>2]=j;c[l+28>>2]=s}c[(c[l+32>>2]|0)+(f<<2)>>2]=c[p>>2];c[l+24>>2]=f+1;r=r+1|0}while((r|0)!=4);d=d+1|0;if((d|0)>=(c[b+772>>2]|0))break g}}p=c[b+752>>2]|0;if((f|0)<(p|0)){if((c[b+1116>>2]|0)<(p|0)){if(p){c[6435]=(c[6435]|0)+1;h=yc((p<<2|3)+16|0)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}j=c[b+1112>>2]|0;if((j|0)>0){l=0;do{c[h+(l<<2)>>2]=c[(c[b+1120>>2]|0)+(l<<2)>>2];l=l+1|0}while((l|0)!=(j|0));l=b+1120|0}else l=b+1120|0}else{h=0;l=b+1120|0}j=c[l>>2]|0;if(j|0){if(a[b+1124>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[l>>2]=0}a[b+1124>>0]=1;c[l>>2]=h;c[b+1116>>2]=p}do{c[(c[b+1120>>2]|0)+(f<<2)>>2]=0;f=f+1|0}while((f|0)!=(p|0))}c[b+1112>>2]=p;if((p|0)>0){h=0;do{c[6435]=(c[6435]|0)+1;f=yc(403)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}a[f+16>>0]=1;c[f+12>>2]=0;c[f+4>>2]=0;c[f+8>>2]=0;a[f+36>>0]=1;c[f+32>>2]=0;c[f+24>>2]=0;c[f+28>>2]=0;a[f+56>>0]=1;c[f+52>>2]=0;c[f+44>>2]=0;c[f+48>>2]=0;J=f+348|0;c[J>>2]=0;c[J+4>>2]=0;c[J+8>>2]=0;c[J+12>>2]=0;c[J+16>>2]=0;g[f+368>>2]=100.0;g[f+372>>2]=.009999999776482582;a[f+376>>0]=0;c[(c[b+1120>>2]|0)+(h<<2)>>2]=f;a[(c[(c[b+1120>>2]|0)+(h<<2)>>2]|0)+377>>0]=1;h=h+1|0}while((h|0)<(c[b+1112>>2]|0))}if((c[b+752>>2]|0)>0){d=0;do{r=0;do{l=c[(c[b+1120>>2]|0)+(d<<2)>>2]|0;p=(c[b+760>>2]|0)+(d*44|0)+8+(r<<2)|0;f=c[l+24>>2]|0;if((f|0)==(c[l+28>>2]|0)?(t=f|0?f<<1:1,(f|0)<(t|0)):0){if(!t)j=0;else{c[6435]=(c[6435]|0)+1;f=yc((t<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}j=f;f=c[l+24>>2]|0}if((f|0)>0){h=0;do{c[j+(h<<2)>>2]=c[(c[l+32>>2]|0)+(h<<2)>>2];h=h+1|0}while((h|0)!=(f|0))}h=c[l+32>>2]|0;if(h){if(a[l+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0);f=c[l+24>>2]|0}c[l+32>>2]=0}a[l+36>>0]=1;c[l+32>>2]=j;c[l+28>>2]=t}c[(c[l+32>>2]|0)+(f<<2)>>2]=c[p>>2];c[l+24>>2]=f+1;r=r+1|0}while((r|0)!=3);d=d+1|0}while((d|0)<(c[b+752>>2]|0))}}while(0);f=c[b+1112>>2]|0;if(!f){J=0;i=I;return J|0}if((f|0)>0){t=0;do{s=c[(c[b+1120>>2]|0)+(t<<2)>>2]|0;g[s+128>>2]=0.0;d=c[s+24>>2]|0;p=c[s+4>>2]|0;if((d|0)>(p|0)){do if((c[s+8>>2]|0)<(d|0)){if(!d){f=0;h=p}else{c[6435]=(c[6435]|0)+1;f=yc((d<<2|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=c[s+4>>2]|0}j=c[s+12>>2]|0;if((h|0)<=0){if(!j){a[s+16>>0]=1;c[s+12>>2]=f;c[s+8>>2]=d;break}}else{l=0;do{c[f+(l<<2)>>2]=c[j+(l<<2)>>2];l=l+1|0}while((l|0)!=(h|0))}if(a[s+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}a[s+16>>0]=1;c[s+12>>2]=f;c[s+8>>2]=d}else f=c[s+12>>2]|0;while(0);Qn(f+(p<<2)|0,0,d-p<<2|0)|0;l=c[s+24>>2]|0}else l=d;c[s+4>>2]=d;if((l|0)>0){f=c[s+32>>2]|0;h=c[s+12>>2]|0;j=0;do{m=+g[(c[f+(j<<2)>>2]|0)+88>>2];if(m==0.0){a[s+376>>0]=1;m=999999984306749440.0}else m=1.0/m;g[h+(j<<2)>>2]=m;q=m+ +g[s+128>>2];g[s+128>>2]=q;j=j+1|0}while((j|0)!=(l|0));g[s+128>>2]=1.0/q;f=c[s+32>>2]|0;h=c[s+12>>2]|0;n=0.0;o=0.0;m=0.0;j=0;do{J=c[f+(j<<2)>>2]|0;B=+g[h+(j<<2)>>2];n=n+ +g[J+8>>2]*B;m=m+B*+g[J+12>>2];o=o+B*+g[J+16>>2];j=j+1|0}while((j|0)!=(l|0));q=1.0/q}else{q=1.0/+g[s+128>>2];g[s+128>>2]=q;n=0.0;o=0.0;m=0.0}z=n*q;x=m*q;o=o*q;g[s+228>>2]=z;g[s+232>>2]=x;g[s+236>>2]=o;g[s+240>>2]=0.0;f=s+316|0;h=f+36|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(h|0));f=s+132|0;h=f+48|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(h|0));f=c[s+24>>2]|0;if((f|0)>0){h=c[s+32>>2]|0;j=c[s+12>>2]|0;B=+g[s+132>>2];A=+g[s+152>>2];y=0.0;n=+g[s+136>>2];m=+g[s+140>>2];q=+g[s+156>>2];l=0;do{J=c[h+(l<<2)>>2]|0;O=+g[J+8>>2]-z;L=+g[J+12>>2]-x;M=+g[J+16>>2]-o;K=+g[j+(l<<2)>>2];B=B+K*(L*L+M*M);g[s+132>>2]=B;A=K*(O*O+M*M)+A;g[s+152>>2]=A;y=(O*O+L*L)*K+y;g[s+172>>2]=y;n=n-L*O*K;g[s+136>>2]=n;m=m-M*O*K;g[s+140>>2]=m;q=q-M*L*K;g[s+156>>2]=q;l=l+1|0}while((l|0)!=(f|0));j=(g[k>>2]=q,c[k>>2]|0);f=(g[k>>2]=m,c[k>>2]|0);l=s+136|0;p=s+140|0;d=s+156|0;r=s+152|0;x=A;h=(g[k>>2]=n,c[k>>2]|0);o=B}else{h=c[s+136>>2]|0;J=c[s+140>>2]|0;j=c[s+156>>2]|0;q=(c[k>>2]=j,+g[k>>2]);n=(c[k>>2]=h,+g[k>>2]);l=s+136|0;p=s+140|0;d=s+156|0;r=s+152|0;y=0.0;x=+g[s+152>>2];f=J;o=+g[s+132>>2];m=(c[k>>2]=J,+g[k>>2])}L=(c[k>>2]=j,+g[k>>2]);z=x*y-q*L;K=(c[k>>2]=f,+g[k>>2]);M=(c[k>>2]=h,+g[k>>2]);A=q*K-y*M;B=L*M-x*K;O=1.0/(z*o+n*A+B*m);g[s+132>>2]=z*O;g[l>>2]=(L*m-y*n)*O;g[p>>2]=(q*n-x*m)*O;g[s+144>>2]=0.0;g[s+148>>2]=A*O;g[r>>2]=(y*o-K*m)*O;g[d>>2]=(M*m-q*o)*O;g[s+160>>2]=0.0;g[s+164>>2]=B*O;g[s+168>>2]=(K*n-L*o)*O;g[s+172>>2]=(x*o-M*n)*O;g[s+176>>2]=0.0;c[s+60>>2]=1065353216;c[s+64>>2]=0;c[s+64+4>>2]=0;c[s+64+8>>2]=0;c[s+64+12>>2]=0;c[s+80>>2]=1065353216;c[s+84>>2]=0;c[s+84+4>>2]=0;c[s+84+8>>2]=0;c[s+84+12>>2]=0;c[s+100>>2]=1065353216;c[s+104>>2]=0;c[s+104+4>>2]=0;c[s+104+8>>2]=0;c[s+104+12>>2]=0;c[s+104+16>>2]=0;c[s+108>>2]=c[s+228>>2];c[s+108+4>>2]=c[s+228+4>>2];c[s+108+8>>2]=c[s+228+8>>2];c[s+108+12>>2]=c[s+228+12>>2];p=c[s+24>>2]|0;l=c[s+44>>2]|0;if((l|0)<(p|0)){if((c[s+48>>2]|0)<(p|0)){if(!p){f=0;h=l}else{c[6435]=(c[6435]|0)+1;f=yc((p<<4|3)+16|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=c[s+44>>2]|0}if((h|0)>0){j=0;do{J=f+(j<<4)|0;H=(c[s+52>>2]|0)+(j<<4)|0;c[J>>2]=c[H>>2];c[J+4>>2]=c[H+4>>2];c[J+8>>2]=c[H+8>>2];c[J+12>>2]=c[H+12>>2];j=j+1|0}while((j|0)!=(h|0))}h=c[s+52>>2]|0;if(h|0){if(a[s+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[h+-4>>2]|0)}c[s+52>>2]=0}a[s+56>>0]=1;c[s+52>>2]=f;c[s+48>>2]=p;h=s+52|0}else h=s+52|0;f=l;do{J=(c[h>>2]|0)+(f<<4)|0;c[J>>2]=c[I>>2];c[J+4>>2]=c[I+4>>2];c[J+8>>2]=c[I+8>>2];c[J+12>>2]=c[I+12>>2];f=f+1|0}while((f|0)!=(p|0))}c[s+44>>2]=p;if((p|0)>0){f=0;do{J=c[s+52>>2]|0;H=c[(c[s+32>>2]|0)+(f<<2)>>2]|0;M=+g[H+12>>2]-+g[s+232>>2];O=+g[H+16>>2]-+g[s+236>>2];g[J+(f<<4)>>2]=+g[H+8>>2]-+g[s+228>>2];g[J+(f<<4)+4>>2]=M;g[J+(f<<4)+8>>2]=O;g[J+(f<<4)+12>>2]=0.0;f=f+1|0}while((f|0)<(c[s+44>>2]|0))}t=t+1|0}while((t|0)<(c[b+1112>>2]|0))}$c(b);f=c[b+1112>>2]|0;d=_(f,f)|0;p=c[b+1132>>2]|0;if((d|0)>(p|0)){do if((c[b+1136>>2]|0)<(d|0)){if(!d){f=0;h=p}else{c[6435]=(c[6435]|0)+1;f=yc(d+19|0)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}h=c[b+1132>>2]|0}j=c[b+1140>>2]|0;if((h|0)<=0){if(!j){a[b+1144>>0]=1;c[b+1140>>2]=f;c[b+1136>>2]=d;break}}else{l=0;do{a[f+l>>0]=a[j+l>>0]|0;l=l+1|0}while((l|0)!=(h|0))}if(a[b+1144>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}a[b+1144>>0]=1;c[b+1140>>2]=f;c[b+1136>>2]=d}else f=c[b+1140>>2]|0;while(0);Qn(f+p|0,0,d-p|0)|0;f=c[b+1112>>2]|0}c[b+1132>>2]=d;if((f|0)<=0){J=f;i=I;return J|0}t=c[b+1120>>2]|0;v=0;do{u=c[t+(v<<2)>>2]|0;c[u+380>>2]=v;w=0;do{h=c[t+(w<<2)>>2]|0;j=c[u+24>>2]|0;h:do if((j|0)>0){l=c[h+24>>2]|0;r=0;while(1){if((l|0)>0){p=c[(c[u+32>>2]|0)+(r<<2)>>2]|0;d=c[h+32>>2]|0;s=0;do{if((p|0)==(c[d+(s<<2)>>2]|0)){h=1;break h}s=s+1|0}while((s|0)<(l|0))}r=r+1|0;if((r|0)>=(j|0)){h=0;break}}}else h=0;while(0);J=(_(f,w)|0)+v|0;a[(c[b+1140>>2]|0)+J>>0]=h;w=w+1|0}while((w|0)!=(f|0));v=v+1|0}while((v|0)!=(f|0));i=I;return f|0}function tc(b){b=b|0;var d=0,e=0.0,f=0.0,h=0.0,j=0.0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0,ca=0.0,da=0.0,ea=0.0,fa=0.0,ga=0.0,ha=0.0,ia=0,ja=0,ka=0;Y=i;i=i+320|0;li(11923);ae(b);a:do if(Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0?(X=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0,(Eb[c[(c[X>>2]|0)+48>>2]&127](X)|0)&6144|0):0){E=Y+256+44|0;F=Y+256+4|0;G=Y+256+8|0;H=Y+256+16|0;I=Y+256+20|0;J=Y+256+24|0;L=Y+256+32|0;M=Y+256+36|0;N=Y+256+40|0;O=Y+256+48|0;P=Y+256+52|0;S=Y+256+56|0;T=Y+256+48|0;U=Y+256+16|0;V=Y+256+32|0;W=Y+256+48|0;B=Y+256+16|0;C=Y+256+32|0;D=Y+256+48|0;d=Eb[c[(c[b>>2]|0)+104>>2]&127](b)|0;while(1){X=d+-1|0;if((d|0)<=0)break a;p=Zb[c[(c[b>>2]|0)+108>>2]&31](b,X)|0;d=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;d=(Eb[c[(c[d>>2]|0)+48>>2]&127](d)|0)>>>11;o=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;o=(Eb[c[(c[o>>2]|0)+48>>2]&127](o)|0)>>>12;A=+g[p+40>>2];b:do if(!(A<=0.0))switch(c[p+4>>2]|0){case 3:{c[Y+256>>2]=1065353216;c[Y+256+4>>2]=0;c[Y+256+4+4>>2]=0;c[Y+256+4+8>>2]=0;c[Y+256+4+12>>2]=0;c[Y+256+20>>2]=1065353216;c[Y+256+24>>2]=0;c[Y+256+24+4>>2]=0;c[Y+256+24+8>>2]=0;c[Y+256+24+12>>2]=0;c[Y+256+40>>2]=1065353216;c[E>>2]=0;c[E+4>>2]=0;c[E+8>>2]=0;c[E+12>>2]=0;c[E+16>>2]=0;z=+g[p+300>>2];y=+g[p+304>>2];x=+g[p+308>>2];o=c[p+28>>2]|0;w=z*+g[o+20>>2]+y*+g[o+24>>2]+x*+g[o+28>>2]+ +g[o+56>>2];v=z*+g[o+36>>2]+y*+g[o+40>>2]+x*+g[o+44>>2]+ +g[o+60>>2];g[Y+256+48>>2]=z*+g[o+4>>2]+y*+g[o+8>>2]+x*+g[o+12>>2]+ +g[o+52>>2];g[Y+256+52>>2]=w;g[Y+256+56>>2]=v;g[Y+256+60>>2]=0.0;o=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[o>>2]|0)+56>>2]&7](o,Y+256|0,A);v=+g[p+316>>2];w=+g[p+320>>2];x=+g[p+324>>2];p=c[p+32>>2]|0;y=v*+g[p+20>>2]+w*+g[p+24>>2]+x*+g[p+28>>2]+ +g[p+56>>2];z=v*+g[p+36>>2]+w*+g[p+40>>2]+x*+g[p+44>>2]+ +g[p+60>>2];g[Y+256+48>>2]=v*+g[p+4>>2]+w*+g[p+8>>2]+x*+g[p+12>>2]+ +g[p+52>>2];g[Y+256+52>>2]=y;g[Y+256+56>>2]=z;g[Y+256+60>>2]=0.0;if(d&1|0){p=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[p>>2]|0)+56>>2]&7](p,Y+256|0,A)}break b}case 4:{n=c[p+28>>2]|0;Z=+g[p+552>>2];da=+g[n+4>>2];e=+g[p+552+16>>2];ca=+g[n+8>>2];f=+g[p+552+32>>2];ba=+g[n+12>>2];h=+g[p+552+4>>2];j=+g[p+552+20>>2];q=+g[p+552+36>>2];r=+g[p+552+8>>2];t=+g[p+552+24>>2];v=+g[p+552+40>>2];aa=+g[n+20>>2];$=+g[n+24>>2];_=+g[n+28>>2];s=+g[n+36>>2];u=+g[n+40>>2];w=+g[n+44>>2];fa=+g[p+552+48>>2];ea=+g[p+552+52>>2];z=+g[p+552+56>>2];x=+g[n+52>>2]+(da*fa+ca*ea+ba*z);y=aa*fa+$*ea+_*z+ +g[n+56>>2];z=s*fa+u*ea+w*z+ +g[n+60>>2];g[Y+256>>2]=Z*da+e*ca+f*ba;g[Y+256+4>>2]=da*h+ca*j+ba*q;g[Y+256+8>>2]=da*r+ca*t+ba*v;g[Y+256+12>>2]=0.0;g[Y+256+16>>2]=Z*aa+e*$+f*_;g[Y+256+20>>2]=h*aa+j*$+q*_;g[Y+256+24>>2]=r*aa+t*$+v*_;g[Y+256+28>>2]=0.0;g[Y+256+32>>2]=Z*s+e*u+f*w;g[Y+256+36>>2]=h*s+j*u+q*w;g[Y+256+40>>2]=r*s+t*u+v*w;g[Y+256+44>>2]=0.0;g[Y+256+48>>2]=x;g[Y+256+52>>2]=y;g[Y+256+56>>2]=z;g[Y+256+60>>2]=0.0;if(!(d&1)){n=c[p+32>>2]|0;u=+g[p+616>>2];h=+g[n+4>>2];v=+g[p+616+16>>2];j=+g[n+8>>2];w=+g[p+616+32>>2];q=+g[n+12>>2];x=+g[p+616+4>>2];y=+g[p+616+20>>2];z=+g[p+616+36>>2];Z=+g[p+616+8>>2];$=+g[p+616+24>>2];ba=+g[p+616+40>>2];r=+g[n+20>>2];s=+g[n+24>>2];t=+g[n+28>>2];_=+g[n+36>>2];aa=+g[n+40>>2];ca=+g[n+44>>2];e=+g[p+616+48>>2];f=+g[p+616+52>>2];fa=+g[p+616+56>>2];da=+g[n+52>>2]+(h*e+j*f+q*fa);ea=r*e+s*f+t*fa+ +g[n+56>>2];fa=_*e+aa*f+ca*fa+ +g[n+60>>2];g[Y+256>>2]=u*h+v*j+w*q;g[Y+256+4>>2]=h*x+j*y+q*z;g[Y+256+8>>2]=h*Z+j*$+q*ba;g[Y+256+12>>2]=0.0;g[Y+256+16>>2]=u*r+v*s+w*t;g[Y+256+20>>2]=x*r+y*s+z*t;g[Y+256+24>>2]=Z*r+$*s+ba*t;g[Y+256+28>>2]=0.0;g[Y+256+32>>2]=u*_+v*aa+w*ca;g[Y+256+36>>2]=x*_+y*aa+z*ca;g[Y+256+40>>2]=Z*_+$*aa+ba*ca;g[Y+256+44>>2]=0.0;g[Y+256+48>>2]=da;g[Y+256+52>>2]=ea;g[Y+256+56>>2]=fa;g[Y+256+60>>2]=0.0}else{n=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[n>>2]|0)+56>>2]&7](n,Y+256|0,A);n=c[p+32>>2]|0;u=+g[p+616>>2];h=+g[n+4>>2];v=+g[p+616+16>>2];j=+g[n+8>>2];w=+g[p+616+32>>2];q=+g[n+12>>2];x=+g[p+616+4>>2];y=+g[p+616+20>>2];z=+g[p+616+36>>2];Z=+g[p+616+8>>2];$=+g[p+616+24>>2];ba=+g[p+616+40>>2];r=+g[n+20>>2];s=+g[n+24>>2];t=+g[n+28>>2];_=+g[n+36>>2];aa=+g[n+40>>2];ca=+g[n+44>>2];e=+g[p+616+48>>2];f=+g[p+616+52>>2];fa=+g[p+616+56>>2];da=+g[n+52>>2]+(h*e+j*f+q*fa);ea=r*e+s*f+t*fa+ +g[n+56>>2];fa=_*e+aa*f+ca*fa+ +g[n+60>>2];g[Y+256>>2]=u*h+v*j+w*q;g[Y+256+4>>2]=h*x+j*y+q*z;g[Y+256+8>>2]=h*Z+j*$+q*ba;g[Y+256+12>>2]=0.0;g[Y+256+16>>2]=u*r+v*s+w*t;g[Y+256+20>>2]=x*r+y*s+z*t;g[Y+256+24>>2]=Z*r+$*s+ba*t;g[Y+256+28>>2]=0.0;g[Y+256+32>>2]=u*_+v*aa+w*ca;g[Y+256+36>>2]=x*_+y*aa+z*ca;g[Y+256+40>>2]=Z*_+$*aa+ba*ca;g[Y+256+44>>2]=0.0;g[Y+256+48>>2]=da;g[Y+256+52>>2]=ea;g[Y+256+56>>2]=fa;g[Y+256+60>>2]=0.0;n=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[n>>2]|0)+56>>2]&7](n,Y+256|0,A)}j=+g[p+688>>2];f=+g[p+688+4>>2];e=+eh(j-f,6.2831854820251465);if(!(e<-3.1415927410125732))if(e>3.1415927410125732)h=e+-6.2831854820251465;else h=e;else h=e+6.2831854820251465;e=+eh(j+f,6.2831854820251465);if(!(e<-3.1415927410125732)){if(e>3.1415927410125732)e=e+-6.2831854820251465}else e=e+6.2831854820251465;if(!(h==e)?(K=h>e,o&1|0):0){c[Y+240>>2]=c[Y+256+8>>2];c[Y+240+4>>2]=c[Y+256+24>>2];c[Y+240+8>>2]=c[Y+256+40>>2];g[Y+240+12>>2]=0.0;c[Y+224>>2]=c[Y+256>>2];c[Y+224+4>>2]=c[Y+256+16>>2];c[Y+224+8>>2]=c[Y+256+32>>2];g[Y+224+12>>2]=0.0;p=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;o=c[(c[p>>2]|0)+60>>2]|0;c[Y+208>>2]=0;c[Y+208+4>>2]=0;c[Y+208+8>>2]=0;c[Y+208+12>>2]=0;Lb[o&0](p,Y+256+48|0,Y+240|0,Y+224|0,A,A,K?0.0:h,K?6.2831854820251465:e,Y+208|0,K^1,10.0)}break b}case 5:{n=c[p+28>>2]|0;u=+g[p+300>>2];h=+g[n+4>>2];v=+g[p+300+16>>2];j=+g[n+8>>2];w=+g[p+300+32>>2];q=+g[n+12>>2];x=+g[p+300+4>>2];y=+g[p+300+20>>2];z=+g[p+300+36>>2];Z=+g[p+300+8>>2];$=+g[p+300+24>>2];ba=+g[p+300+40>>2];r=+g[n+20>>2];s=+g[n+24>>2];t=+g[n+28>>2];_=+g[n+36>>2];aa=+g[n+40>>2];ca=+g[n+44>>2];e=+g[p+300+48>>2];f=+g[p+300+52>>2];fa=+g[p+300+56>>2];da=+g[n+52>>2]+(h*e+j*f+q*fa);ea=r*e+s*f+t*fa+ +g[n+56>>2];fa=_*e+aa*f+ca*fa+ +g[n+60>>2];g[Y+256>>2]=u*h+v*j+w*q;g[F>>2]=h*x+j*y+q*z;g[G>>2]=h*Z+j*$+q*ba;g[Y+256+12>>2]=0.0;g[H>>2]=u*r+v*s+w*t;g[I>>2]=x*r+y*s+z*t;g[J>>2]=Z*r+$*s+ba*t;g[Y+256+28>>2]=0.0;g[L>>2]=u*_+v*aa+w*ca;g[M>>2]=x*_+y*aa+z*ca;g[N>>2]=Z*_+$*aa+ba*ca;g[Y+256+44>>2]=0.0;g[O>>2]=da;g[P>>2]=ea;g[S>>2]=fa;g[Y+256+60>>2]=0.0;if(!(d&1)){n=c[p+32>>2]|0;u=+g[p+364>>2];h=+g[n+4>>2];v=+g[p+364+16>>2];j=+g[n+8>>2];w=+g[p+364+32>>2];q=+g[n+12>>2];x=+g[p+364+4>>2];y=+g[p+364+20>>2];z=+g[p+364+36>>2];Z=+g[p+364+8>>2];$=+g[p+364+24>>2];ba=+g[p+364+40>>2];r=+g[n+20>>2];s=+g[n+24>>2];t=+g[n+28>>2];_=+g[n+36>>2];aa=+g[n+40>>2];ca=+g[n+44>>2];e=+g[p+364+48>>2];f=+g[p+364+52>>2];fa=+g[p+364+56>>2];da=+g[n+52>>2]+(h*e+j*f+q*fa);ea=r*e+s*f+t*fa+ +g[n+56>>2];fa=_*e+aa*f+ca*fa+ +g[n+60>>2];g[Y+256>>2]=u*h+v*j+w*q;g[F>>2]=h*x+j*y+q*z;g[G>>2]=h*Z+j*$+q*ba;g[Y+256+12>>2]=0.0;g[H>>2]=u*r+v*s+w*t;g[I>>2]=x*r+y*s+z*t;g[J>>2]=Z*r+$*s+ba*t;g[Y+256+28>>2]=0.0;g[L>>2]=u*_+v*aa+w*ca;g[M>>2]=x*_+y*aa+z*ca;g[N>>2]=Z*_+$*aa+ba*ca;g[Y+256+44>>2]=0.0;g[O>>2]=da;g[P>>2]=ea;g[S>>2]=fa;g[Y+256+60>>2]=0.0}else{n=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[n>>2]|0)+56>>2]&7](n,Y+256|0,A);n=c[p+32>>2]|0;u=+g[p+364>>2];h=+g[n+4>>2];v=+g[p+364+16>>2];j=+g[n+8>>2];w=+g[p+364+32>>2];q=+g[n+12>>2];x=+g[p+364+4>>2];y=+g[p+364+20>>2];z=+g[p+364+36>>2];Z=+g[p+364+8>>2];$=+g[p+364+24>>2];ba=+g[p+364+40>>2];r=+g[n+20>>2];s=+g[n+24>>2];t=+g[n+28>>2];_=+g[n+36>>2];aa=+g[n+40>>2];ca=+g[n+44>>2];e=+g[p+364+48>>2];f=+g[p+364+52>>2];fa=+g[p+364+56>>2];da=+g[n+52>>2]+(h*e+j*f+q*fa);ea=r*e+s*f+t*fa+ +g[n+56>>2];fa=_*e+aa*f+ca*fa+ +g[n+60>>2];g[Y+256>>2]=u*h+v*j+w*q;g[F>>2]=h*x+j*y+q*z;g[G>>2]=h*Z+j*$+q*ba;g[Y+256+12>>2]=0.0;g[H>>2]=u*r+v*s+w*t;g[I>>2]=x*r+y*s+z*t;g[J>>2]=Z*r+$*s+ba*t;g[Y+256+28>>2]=0.0;g[L>>2]=u*_+v*aa+w*ca;g[M>>2]=x*_+y*aa+z*ca;g[N>>2]=Z*_+$*aa+ba*ca;g[Y+256+44>>2]=0.0;g[O>>2]=da;g[P>>2]=ea;g[S>>2]=fa;g[Y+256+60>>2]=0.0;n=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[n>>2]|0)+56>>2]&7](n,Y+256|0,A)}if(o&1|0){Ej(Y+240|0,p,6.0868353843688965,A);ba=+g[Y+240>>2];ca=+g[Y+240+4>>2];da=+g[Y+240+8>>2];ea=ba*+g[H>>2]+ca*+g[I>>2]+da*+g[J>>2]+ +g[P>>2];fa=ba*+g[L>>2]+ca*+g[M>>2]+da*+g[N>>2]+ +g[S>>2];g[Y+240>>2]=ba*+g[Y+256>>2]+ca*+g[F>>2]+da*+g[G>>2]+ +g[O>>2];g[Y+240+4>>2]=ea;g[Y+240+8>>2]=fa;g[Y+240+12>>2]=0.0;d=0;do{Ej(Y+224|0,p,+(d|0)*6.283185005187988*.03125,A);ba=+g[Y+224>>2];ca=+g[Y+224+4>>2];da=+g[Y+224+8>>2];ea=ba*+g[H>>2]+ca*+g[I>>2]+da*+g[J>>2]+ +g[P>>2];fa=ba*+g[L>>2]+ca*+g[M>>2]+da*+g[N>>2]+ +g[S>>2];g[Y+224>>2]=ba*+g[Y+256>>2]+ca*+g[F>>2]+da*+g[G>>2]+ +g[O>>2];g[Y+224+4>>2]=ea;g[Y+224+8>>2]=fa;g[Y+224+12>>2]=0.0;o=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;n=c[(c[o>>2]|0)+8>>2]|0;c[Y+192>>2]=0;c[Y+192+4>>2]=0;c[Y+192+8>>2]=0;c[Y+192+12>>2]=0;mc[n&127](o,Y+240|0,Y+224|0,Y+192|0);if(!(d&3)){o=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;n=c[(c[o>>2]|0)+8>>2]|0;c[Y+176>>2]=0;c[Y+176+4>>2]=0;c[Y+176+8>>2]=0;c[Y+176+12>>2]=0;mc[n&127](o,T,Y+224|0,Y+176|0)}c[Y+240>>2]=c[Y+224>>2];c[Y+240+4>>2]=c[Y+224+4>>2];c[Y+240+8>>2]=c[Y+224+8>>2];c[Y+240+12>>2]=c[Y+224+12>>2];d=d+1|0}while((d|0)!=32);y=+g[p+452>>2];z=+g[p+512>>2];d=c[p+32>>2]|0;if(+g[d+344>>2]>0.0){ba=+g[p+364>>2];ca=+g[d+4>>2];da=+g[p+364+16>>2];ea=+g[d+8>>2];fa=+g[p+364+32>>2];v=+g[d+12>>2];$=+g[p+364+4>>2];aa=+g[p+364+20>>2];u=+g[p+364+36>>2];Z=+g[p+364+8>>2];_=+g[p+364+24>>2];t=+g[p+364+40>>2];ha=+g[d+20>>2];ga=+g[d+24>>2];s=+g[d+28>>2];r=+g[d+36>>2];q=+g[d+40>>2];j=+g[d+44>>2];h=+g[p+364+48>>2];f=+g[p+364+52>>2];e=+g[p+364+56>>2];w=r*h+q*f+j*e+ +g[d+60>>2];x=ha*h+ga*f+s*e+ +g[d+56>>2];e=+g[d+52>>2]+(ca*h+ea*f+v*e);f=Z*r+_*q+t*j;h=$*r+aa*q+u*j;j=ba*r+da*q+fa*j;q=Z*ha+_*ga+t*s;r=$*ha+aa*ga+u*s;s=ba*ha+da*ga+fa*s;t=ca*Z+ea*_+v*t;u=ca*$+ea*aa+v*u;v=ba*ca+da*ea+fa*v}else{o=c[p+28>>2]|0;da=+g[p+300>>2];ea=+g[o+4>>2];fa=+g[p+300+16>>2];ga=+g[o+8>>2];ha=+g[p+300+32>>2];v=+g[o+12>>2];ba=+g[p+300+4>>2];ca=+g[p+300+20>>2];u=+g[p+300+36>>2];$=+g[p+300+8>>2];aa=+g[p+300+24>>2];t=+g[p+300+40>>2];Z=+g[o+20>>2];_=+g[o+24>>2];s=+g[o+28>>2];r=+g[o+36>>2];q=+g[o+40>>2];j=+g[o+44>>2];h=+g[p+300+48>>2];f=+g[p+300+52>>2];e=+g[p+300+56>>2];w=r*h+q*f+j*e+ +g[o+60>>2];x=Z*h+_*f+s*e+ +g[o+56>>2];e=+g[o+52>>2]+(ea*h+ga*f+v*e);f=$*r+aa*q+t*j;h=ba*r+ca*q+u*j;j=da*r+fa*q+ha*j;q=$*Z+aa*_+t*s;r=ba*Z+ca*_+u*s;s=da*Z+fa*_+ha*s;t=ea*$+ga*aa+v*t;u=ea*ba+ga*ca+v*u;v=da*ea+fa*ga+ha*v}g[Y+256>>2]=v;g[F>>2]=u;g[G>>2]=t;g[Y+256+12>>2]=0.0;g[H>>2]=s;g[I>>2]=r;g[J>>2]=q;g[Y+256+28>>2]=0.0;g[L>>2]=j;g[M>>2]=h;g[N>>2]=f;g[Y+256+44>>2]=0.0;g[O>>2]=e;g[P>>2]=x;g[S>>2]=w;g[Y+256+60>>2]=0.0;c[Y+224>>2]=c[T>>2];c[Y+224+4>>2]=c[T+4>>2];c[Y+224+8>>2]=c[T+8>>2];c[Y+224+12>>2]=c[T+12>>2];g[Y+160>>2]=v;g[Y+160+4>>2]=s;g[Y+160+8>>2]=j;g[Y+160+12>>2]=0.0;g[Y+144>>2]=u;g[Y+144+4>>2]=r;g[Y+144+8>>2]=h;g[Y+144+12>>2]=0.0;p=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;o=c[(c[p>>2]|0)+60>>2]|0;c[Y+128>>2]=0;c[Y+128+4>>2]=0;c[Y+128+8>>2]=0;c[Y+128+12>>2]=0;Lb[o&0](p,Y+224|0,Y+160|0,Y+144|0,A,A,-z-y,y-z,Y+128|0,1,10.0)}break b}case 6:case 9:{c[Y+256>>2]=c[p+1064>>2];c[Y+256+4>>2]=c[p+1064+4>>2];c[Y+256+8>>2]=c[p+1064+8>>2];c[Y+256+12>>2]=c[p+1064+12>>2];l=p+1064+16|0;c[U>>2]=c[l>>2];c[U+4>>2]=c[l+4>>2];c[U+8>>2]=c[l+8>>2];c[U+12>>2]=c[l+12>>2];m=p+1064+32|0;c[V>>2]=c[m>>2];c[V+4>>2]=c[m+4>>2];c[V+8>>2]=c[m+8>>2];c[V+12>>2]=c[m+12>>2];n=p+1064+48|0;c[W>>2]=c[n>>2];c[W+4>>2]=c[n+4>>2];c[W+8>>2]=c[n+8>>2];c[W+12>>2]=c[n+12>>2];if(!(d&1)){c[Y+256>>2]=c[p+1128>>2];c[Y+256+4>>2]=c[p+1128+4>>2];c[Y+256+8>>2]=c[p+1128+8>>2];c[Y+256+12>>2]=c[p+1128+12>>2];c[U>>2]=c[p+1128+16>>2];c[U+4>>2]=c[p+1128+16+4>>2];c[U+8>>2]=c[p+1128+16+8>>2];c[U+12>>2]=c[p+1128+16+12>>2];c[V>>2]=c[p+1128+32>>2];c[V+4>>2]=c[p+1128+32+4>>2];c[V+8>>2]=c[p+1128+32+8>>2];c[V+12>>2]=c[p+1128+32+12>>2];c[W>>2]=c[p+1128+48>>2];c[W+4>>2]=c[p+1128+48+4>>2];c[W+8>>2]=c[p+1128+48+8>>2];c[W+12>>2]=c[p+1128+48+12>>2]}else{d=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[d>>2]|0)+56>>2]&7](d,Y+256|0,A);c[Y+256>>2]=c[p+1128>>2];c[Y+256+4>>2]=c[p+1128+4>>2];c[Y+256+8>>2]=c[p+1128+8>>2];c[Y+256+12>>2]=c[p+1128+12>>2];c[U>>2]=c[p+1128+16>>2];c[U+4>>2]=c[p+1128+16+4>>2];c[U+8>>2]=c[p+1128+16+8>>2];c[U+12>>2]=c[p+1128+16+12>>2];c[V>>2]=c[p+1128+32>>2];c[V+4>>2]=c[p+1128+32+4>>2];c[V+8>>2]=c[p+1128+32+8>>2];c[V+12>>2]=c[p+1128+32+12>>2];c[W>>2]=c[p+1128+48>>2];c[W+4>>2]=c[p+1128+48+4>>2];c[W+8>>2]=c[p+1128+48+8>>2];c[W+12>>2]=c[p+1128+48+12>>2];d=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[d>>2]|0)+56>>2]&7](d,Y+256|0,A)}if(o&1|0){c[Y+256>>2]=c[p+1064>>2];c[Y+256+4>>2]=c[p+1064+4>>2];c[Y+256+8>>2]=c[p+1064+8>>2];c[Y+256+12>>2]=c[p+1064+12>>2];c[U>>2]=c[l>>2];c[U+4>>2]=c[l+4>>2];c[U+8>>2]=c[l+8>>2];c[U+12>>2]=c[l+12>>2];c[V>>2]=c[m>>2];c[V+4>>2]=c[m+4>>2];c[V+8>>2]=c[m+8>>2];c[V+12>>2]=c[m+12>>2];c[W>>2]=c[n>>2];c[W+4>>2]=c[n+4>>2];c[W+8>>2]=c[n+8>>2];c[W+12>>2]=c[n+12>>2];d=p+1128+48|0;c[Y+240>>2]=c[Y+256+8>>2];c[Y+240+4>>2]=c[Y+256+24>>2];c[Y+240+8>>2]=c[Y+256+40>>2];g[Y+240+12>>2]=0.0;c[Y+224>>2]=c[Y+256>>2];c[Y+224+4>>2]=c[Y+256+16>>2];c[Y+224+8>>2]=c[Y+256+32>>2];g[Y+224+12>>2]=0.0;da=+g[p+932>>2];e=+g[p+932+4>>2];ga=+g[p+996>>2];fa=+g[p+996+4>>2];ja=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;ia=c[(c[ja>>2]|0)+64>>2]|0;c[Y+112>>2]=0;c[Y+112+4>>2]=0;c[Y+112+8>>2]=0;c[Y+112+12>>2]=0;dc[ia&0](ja,d,Y+240|0,Y+224|0,A*.8999999761581421,da,e,ga,fa,Y+112|0,10.0,1);ja=c[Y+256+4>>2]|0;ia=c[Y+256+20>>2]|0;o=c[Y+256+36>>2]|0;c[Y+224>>2]=ja;c[Y+224+4>>2]=ia;c[Y+224+8>>2]=o;g[Y+224+12>>2]=0.0;fa=+g[p+1196>>2];ga=+g[p+1200>>2];e=+Q(+fa);fa=+R(+fa);da=+Q(+ga);ga=+R(+ga);ea=(c[k>>2]=ja,+g[k>>2]);ha=(c[k>>2]=ia,+g[k>>2]);f=(c[k>>2]=o,+g[k>>2]);g[Y+160>>2]=e*da*ea+e*ga*ha-fa*f;g[Y+160+4>>2]=da*ha-ga*ea;g[Y+160+8>>2]=fa*da*ea+fa*ga*ha+e*f;c[Y+256>>2]=c[p+1128>>2];c[Y+256+4>>2]=c[p+1128+4>>2];c[Y+256+8>>2]=c[p+1128+8>>2];c[Y+256+12>>2]=c[p+1128+12>>2];c[U>>2]=c[p+1128+16>>2];c[U+4>>2]=c[p+1128+16+4>>2];c[U+8>>2]=c[p+1128+16+8>>2];c[U+12>>2]=c[p+1128+16+12>>2];c[V>>2]=c[p+1128+32>>2];c[V+4>>2]=c[p+1128+32+4>>2];c[V+8>>2]=c[p+1128+32+8>>2];c[V+12>>2]=c[p+1128+32+12>>2];c[W>>2]=c[d>>2];c[W+4>>2]=c[d+4>>2];c[W+8>>2]=c[d+8>>2];c[W+12>>2]=c[d+12>>2];f=-+g[Y+256+16>>2];e=-+g[Y+256+32>>2];g[Y+144>>2]=-+g[Y+256>>2];g[Y+144+4>>2]=f;g[Y+144+8>>2]=e;g[Y+144+12>>2]=0.0;e=+g[p+868>>2];f=+g[p+868+4>>2];if(!(e>f)){if(e>2]|0)+20>>2]&127](b)|0;ia=c[(c[ja>>2]|0)+60>>2]|0;c[Y+80>>2]=0;c[Y+80+4>>2]=0;c[Y+80+8>>2]=0;c[Y+80+12>>2]=0;Lb[ia&0](ja,d,Y+144|0,Y+160|0,A,A,e,f,Y+80|0,1,10.0)}}else{ja=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;ia=c[(c[ja>>2]|0)+60>>2]|0;c[Y+96>>2]=0;c[Y+96+4>>2]=0;c[Y+96+8>>2]=0;c[Y+96+12>>2]=0;Lb[ia&0](ja,d,Y+144|0,Y+160|0,A,A,-3.1415927410125732,3.1415927410125732,Y+96|0,0,10.0)}c[Y+256>>2]=c[p+1064>>2];c[Y+256+4>>2]=c[p+1064+4>>2];c[Y+256+8>>2]=c[p+1064+8>>2];c[Y+256+12>>2]=c[p+1064+12>>2];c[U>>2]=c[l>>2];c[U+4>>2]=c[l+4>>2];c[U+8>>2]=c[l+8>>2];c[U+12>>2]=c[l+12>>2];c[V>>2]=c[m>>2];c[V+4>>2]=c[m+4>>2];c[V+8>>2]=c[m+8>>2];c[V+12>>2]=c[m+12>>2];c[W>>2]=c[n>>2];c[W+4>>2]=c[n+4>>2];c[W+8>>2]=c[n+8>>2];c[W+12>>2]=c[n+12>>2];c[Y+64>>2]=c[p+680>>2];c[Y+64+4>>2]=c[p+680+4>>2];c[Y+64+8>>2]=c[p+680+8>>2];c[Y+64+12>>2]=c[p+680+12>>2];c[Y+48>>2]=c[p+680+16>>2];c[Y+48+4>>2]=c[p+680+16+4>>2];c[Y+48+8>>2]=c[p+680+16+8>>2];c[Y+48+12>>2]=c[p+680+16+12>>2];ja=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;ia=c[(c[ja>>2]|0)+72>>2]|0;c[Y+32>>2]=0;c[Y+32+4>>2]=0;c[Y+32+8>>2]=0;c[Y+32+12>>2]=0;yb[ia&31](ja,Y+64|0,Y+48|0,Y+256|0,Y+32|0)}break b}case 7:{c[Y+256>>2]=c[p+824>>2];c[Y+256+4>>2]=c[p+824+4>>2];c[Y+256+8>>2]=c[p+824+8>>2];c[Y+256+12>>2]=c[p+824+12>>2];c[B>>2]=c[p+824+16>>2];c[B+4>>2]=c[p+824+16+4>>2];c[B+8>>2]=c[p+824+16+8>>2];c[B+12>>2]=c[p+824+16+12>>2];c[C>>2]=c[p+824+32>>2];c[C+4>>2]=c[p+824+32+4>>2];c[C+8>>2]=c[p+824+32+8>>2];c[C+12>>2]=c[p+824+32+12>>2];c[D>>2]=c[p+824+48>>2];c[D+4>>2]=c[p+824+48+4>>2];c[D+8>>2]=c[p+824+48+8>>2];c[D+12>>2]=c[p+824+48+12>>2];if(!(d&1)){c[Y+256>>2]=c[p+888>>2];c[Y+256+4>>2]=c[p+888+4>>2];c[Y+256+8>>2]=c[p+888+8>>2];c[Y+256+12>>2]=c[p+888+12>>2];c[B>>2]=c[p+888+16>>2];c[B+4>>2]=c[p+888+16+4>>2];c[B+8>>2]=c[p+888+16+8>>2];c[B+12>>2]=c[p+888+16+12>>2];c[C>>2]=c[p+888+32>>2];c[C+4>>2]=c[p+888+32+4>>2];c[C+8>>2]=c[p+888+32+8>>2];c[C+12>>2]=c[p+888+32+12>>2];c[D>>2]=c[p+888+48>>2];c[D+4>>2]=c[p+888+48+4>>2];c[D+8>>2]=c[p+888+48+8>>2];c[D+12>>2]=c[p+888+48+12>>2]}else{ja=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[ja>>2]|0)+56>>2]&7](ja,Y+256|0,A);c[Y+256>>2]=c[p+888>>2];c[Y+256+4>>2]=c[p+888+4>>2];c[Y+256+8>>2]=c[p+888+8>>2];c[Y+256+12>>2]=c[p+888+12>>2];c[B>>2]=c[p+888+16>>2];c[B+4>>2]=c[p+888+16+4>>2];c[B+8>>2]=c[p+888+16+8>>2];c[B+12>>2]=c[p+888+16+12>>2];c[C>>2]=c[p+888+32>>2];c[C+4>>2]=c[p+888+32+4>>2];c[C+8>>2]=c[p+888+32+8>>2];c[C+12>>2]=c[p+888+32+12>>2];c[D>>2]=c[p+888+48>>2];c[D+4>>2]=c[p+888+48+4>>2];c[D+8>>2]=c[p+888+48+8>>2];c[D+12>>2]=c[p+888+48+12>>2];ja=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;kc[c[(c[ja>>2]|0)+56>>2]&7](ja,Y+256|0,A)}if(o&1|0){d=a[p+180>>0]|0?p+824|0:p+888|0;l=c[d>>2]|0;o=c[d+4>>2]|0;m=c[d+16>>2]|0;ia=c[d+20>>2]|0;n=c[d+32>>2]|0;ja=c[d+36>>2]|0;y=+g[d+48>>2];$=+g[d+52>>2];da=+g[d+56>>2];ga=+g[p+184>>2];_=(c[k>>2]=l,+g[k>>2]);Z=(c[k>>2]=o,+g[k>>2])*0.0;z=+g[d+8>>2]*0.0;ca=(c[k>>2]=m,+g[k>>2]);ba=(c[k>>2]=ia,+g[k>>2])*0.0;aa=+g[d+24>>2]*0.0;ha=(c[k>>2]=n,+g[k>>2]);fa=(c[k>>2]=ja,+g[k>>2])*0.0;ea=+g[d+40>>2]*0.0;g[Y+240>>2]=y+(z+(Z+_*ga));g[Y+240+4>>2]=$+(aa+(ba+ca*ga));g[Y+240+8>>2]=da+(ea+(fa+ha*ga));g[Y+240+12>>2]=0.0;ga=+g[p+188>>2];g[Y+224>>2]=y+(z+(Z+_*ga));g[Y+224+4>>2]=$+(aa+(ba+ca*ga));g[Y+224+8>>2]=da+(ea+(fa+ha*ga));g[Y+224+12>>2]=0.0;d=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;ka=c[(c[d>>2]|0)+8>>2]|0;c[Y+16>>2]=0;c[Y+16+4>>2]=0;c[Y+16+8>>2]=0;c[Y+16+12>>2]=0;mc[ka&127](d,Y+240|0,Y+224|0,Y+16|0);c[Y+160>>2]=l;c[Y+160+4>>2]=m;c[Y+160+8>>2]=n;g[Y+160+12>>2]=0.0;c[Y+144>>2]=o;c[Y+144+4>>2]=ia;c[Y+144+8>>2]=ja;g[Y+144+12>>2]=0.0;ga=+g[p+192>>2];ha=+g[p+196>>2];ja=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0;ia=c[(c[ja>>2]|0)+60>>2]|0;c[Y>>2]=0;c[Y+4>>2]=0;c[Y+8>>2]=0;c[Y+12>>2]=0;Lb[ia&0](ja,p+888+48|0,Y+160|0,Y+144|0,A,A,ga,ha,Y,1,10.0)}break b}default:break b}while(0);d=X}}while(0);if((((Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0?(ka=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0,(Eb[c[(c[ka>>2]|0)+48>>2]&127](ka)|0)&16387|0):0)?Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0:0)?(ka=Eb[c[(c[b>>2]|0)+20>>2]&127](b)|0,Eb[c[(c[ka>>2]|0)+48>>2]&127](ka)|0):0)?(c[b+280>>2]|0)>0:0){d=0;do{ka=c[(c[b+288>>2]|0)+(d<<2)>>2]|0;Cb[c[(c[ka>>2]|0)+12>>2]&127](ka,c[b+72>>2]|0);d=d+1|0}while((d|0)<(c[b+280>>2]|0))}d=c[2357]|0;ka=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=ka;if(ka|0){i=Y;return}do if(c[d+4>>2]|0){tb(Y+256|0,0)|0;ka=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[Y+256+4>>2]|0)-(c[ka+4>>2]|0)+(((c[Y+256>>2]|0)-(c[ka>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=Y;return}}while(0);c[2357]=c[d+20>>2];i=Y;return}function uc(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;z=i;i=i+80|0;mf(b,e,f)|0;a[z+16>>0]=1;c[z+12>>2]=0;c[z+4>>2]=0;c[z+8>>2]=0;a[z+36>>0]=1;c[z+32>>2]=0;c[z+24>>2]=0;c[z+28>>2]=0;a[z+56>>0]=1;c[z+52>>2]=0;c[z+44>>2]=0;c[z+48>>2]=0;a[z+76>>0]=1;c[z+72>>2]=0;c[z+64>>2]=0;c[z+68>>2]=0;x=c[b+872>>2]|0;c[e+292>>2]=x;if(x){x=Zb[c[(c[f>>2]|0)+28>>2]&31](f,b+868|0)|0;c[e+260>>2]=x;if(x|0){h=c[e+292>>2]|0;n=Ob[c[(c[f>>2]|0)+16>>2]&63](f,4,h)|0;if((h|0)>0){l=0;m=c[n+8>>2]|0;while(1){j=c[(c[b+880>>2]|0)+(l<<2)>>2]|0;if(!j){g=0;k=0}else{g=j;k=Zb[c[(c[f>>2]|0)+28>>2]&31](f,j)|0}c[m>>2]=k;if(!(Zb[c[(c[f>>2]|0)+24>>2]&31](f,g)|0)){x=Ob[c[(c[f>>2]|0)+16>>2]&63](f,16,1)|0;s=c[x+8>>2]|0;c[s+12>>2]=c[j+16>>2];c[s+4>>2]=c[j+8>>2];c[s>>2]=c[j+4>>2];c[s+8>>2]=c[j+12>>2];yb[c[(c[f>>2]|0)+20>>2]&31](f,x,10691,1414349395,g)}l=l+1|0;if((l|0)>=(h|0)){g=f;break}else m=m+4|0}}else g=f;yb[c[(c[g>>2]|0)+20>>2]&31](f,n,10691,1497453121,b+868|0)}}else c[e+260>>2]=0;x=c[b+712>>2]|0;c[e+296>>2]=x;if(x){x=Zb[c[(c[f>>2]|0)+28>>2]&31](f,b+708|0)|0;c[e+264>>2]=x;if(x|0){p=c[e+296>>2]|0;q=Ob[c[(c[f>>2]|0)+16>>2]&63](f,100,p)|0;if((p|0)>0){r=0;s=c[q+8>>2]|0;while(1){h=c[b+720>>2]|0;c[s+52>>2]=c[h+(r*104|0)+56>>2];c[s+56>>2]=c[h+(r*104|0)+60>>2];c[s+60>>2]=c[h+(r*104|0)+64>>2];c[s+64>>2]=c[h+(r*104|0)+68>>2];c[s+88>>2]=c[h+(r*104|0)+92>>2];c[s+92>>2]=(a[h+(r*104|0)+100>>0]<<7&255)<<24>>24>>7<<24>>24;c[s+84>>2]=c[h+(r*104|0)+88>>2];g=c[h+(r*104|0)+4>>2]|0;if(!g){j=0;g=h}else{j=Zb[c[(c[f>>2]|0)+28>>2]&31](f,g)|0;g=c[b+720>>2]|0}c[s>>2]=j;c[s+68>>2]=c[g+(r*104|0)+72>>2];c[s+72>>2]=c[g+(r*104|0)+76>>2];c[s+76>>2]=c[g+(r*104|0)+80>>2];c[s+80>>2]=c[g+(r*104|0)+84>>2];c[s+4>>2]=c[g+(r*104|0)+8>>2];c[s+8>>2]=c[g+(r*104|0)+12>>2];c[s+12>>2]=c[g+(r*104|0)+16>>2];c[s+16>>2]=c[g+(r*104|0)+20>>2];c[s+20>>2]=c[g+(r*104|0)+24>>2];c[s+24>>2]=c[g+(r*104|0)+28>>2];c[s+28>>2]=c[g+(r*104|0)+32>>2];c[s+32>>2]=c[g+(r*104|0)+36>>2];c[s+36>>2]=c[g+(r*104|0)+40>>2];c[s+40>>2]=c[g+(r*104|0)+44>>2];c[s+44>>2]=c[g+(r*104|0)+48>>2];c[s+48>>2]=c[g+(r*104|0)+52>>2];l=(c[b+720>>2]|0)+(r*104|0)|0;o=(l+~(l<<15)>>10^l+~(l<<15))*9|0;o=(o>>6^o)+~((o>>6^o)<<11)>>16^(o>>6^o)+~((o>>6^o)<<11);m=c[z+48>>2]|0;a:do if((o&m+-1)>>>0<(c[z+4>>2]|0)>>>0?(w=c[(c[z+12>>2]|0)+((o&m+-1)<<2)>>2]|0,(w|0)!=-1):0){h=c[z+72>>2]|0;j=c[z+32>>2]|0;g=w;while(1){if((l|0)==(c[h+(g<<3)>>2]|0))break;g=c[j+(g<<2)>>2]|0;if((g|0)==-1){y=27;break a}}c[(c[z+52>>2]|0)+(g<<2)>>2]=r}else y=27;while(0);if((y|0)==27){y=0;n=c[z+44>>2]|0;if((n|0)==(m|0)){g=m|0?m<<1:1;if((m|0)<(g|0)){if((g|0)!=0?(c[6435]=(c[6435]|0)+1,t=yc((g<<2|3)+16|0)|0,(t|0)!=0):0){c[(t+4+15&-16)+-4>>2]=t;k=t+4+15&-16}else k=0;j=c[z+52>>2]|0;if((m|0)<=0)if(!j)h=m;else y=35;else{h=0;do{c[k+(h<<2)>>2]=c[j+(h<<2)>>2];h=h+1|0}while((h|0)!=(m|0));y=35}if((y|0)==35){y=0;if(a[z+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}c[z+52>>2]=0;h=c[z+44>>2]|0}a[z+56>>0]=1;c[z+52>>2]=k;c[z+48>>2]=g}else{g=m;h=m}}else{g=m;h=n}c[(c[z+52>>2]|0)+(h<<2)>>2]=r;c[z+44>>2]=h+1;h=c[z+64>>2]|0;if((h|0)==(c[z+68>>2]|0)?(u=h|0?h<<1:1,(h|0)<(u|0)):0){if((u|0)!=0?(c[6435]=(c[6435]|0)+1,v=yc((u<<3|3)+16|0)|0,(v|0)!=0):0){c[(v+4+15&-16)+-4>>2]=v;j=v+4+15&-16}else j=0;if((h|0)>0){g=0;do{A=(c[z+72>>2]|0)+(g<<3)|0;k=c[A+4>>2]|0;x=j+(g<<3)|0;c[x>>2]=c[A>>2];c[x+4>>2]=k;g=g+1|0}while((g|0)!=(h|0))}g=c[z+72>>2]|0;if(g|0){if(a[z+76>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[g+-4>>2]|0)}c[z+72>>2]=0}a[z+76>>0]=1;c[z+72>>2]=j;c[z+68>>2]=u;h=c[z+64>>2]|0;g=c[z+48>>2]|0}c[(c[z+72>>2]|0)+(h<<3)>>2]=l;c[z+64>>2]=h+1;if((m|0)<(g|0)){m=c[z+4>>2]|0;do if((g|0)>(m|0)){if((g|0)>=(m|0)){b:do if((c[z+8>>2]|0)<(g|0)){do if(!g)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((g<<2|3)+16|0)|0;if(!h){h=0;break}c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}while(0);j=c[z+12>>2]|0;do if((m|0)>0){k=0;do{c[h+(k<<2)>>2]=c[j+(k<<2)>>2];k=k+1|0}while((k|0)!=(m|0))}else{if(j|0)break;a[z+16>>0]=1;c[z+12>>2]=h;c[z+8>>2]=g;break b}while(0);if(a[z+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}a[z+16>>0]=1;c[z+12>>2]=h;c[z+8>>2]=g}else h=c[z+12>>2]|0;while(0);Qn(h+(m<<2)|0,0,g-m<<2|0)|0}c[z+4>>2]=g;l=c[z+24>>2]|0;if((g|0)>(l|0)){c:do if((c[z+28>>2]|0)<(g|0)){do if(!g)h=0;else{c[6435]=(c[6435]|0)+1;h=yc((g<<2|3)+16|0)|0;if(!h){h=0;break}c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}while(0);j=c[z+32>>2]|0;do if((l|0)>0){k=0;do{c[h+(k<<2)>>2]=c[j+(k<<2)>>2];k=k+1|0}while((k|0)!=(l|0))}else{if(j|0)break;a[z+36>>0]=1;c[z+32>>2]=h;c[z+28>>2]=g;break c}while(0);if(a[z+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[j+-4>>2]|0)}a[z+36>>0]=1;c[z+32>>2]=h;c[z+28>>2]=g}else h=c[z+32>>2]|0;while(0);Qn(h+(l<<2)|0,0,g-l<<2|0)|0}c[z+24>>2]=g;if((g|0)>0){A=g<<2;Qn(c[z+12>>2]|0,-1,A|0)|0;Qn(c[z+32>>2]|0,-1,A|0)|0}if((m|0)<=0){g=c[z+48>>2]|0;break}h=c[z+72>>2]|0;j=c[z+12>>2]|0;k=c[z+32>>2]|0;g=c[z+48>>2]|0;l=0;do{A=c[h+(l<<3)>>2]|0;A=(A+~(A<<15)>>10^A+~(A<<15))*9|0;A=j+((((A>>6^A)+~((A>>6^A)<<11)>>16^(A>>6^A)+~((A>>6^A)<<11))&g+-1)<<2)|0;c[k+(l<<2)>>2]=c[A>>2];c[A>>2]=l;l=l+1|0}while((l|0)!=(m|0))}while(0);g=o&g+-1}else g=o&m+-1;A=(c[z+12>>2]|0)+(g<<2)|0;c[(c[z+32>>2]|0)+(n<<2)>>2]=c[A>>2];c[A>>2]=n}r=r+1|0;if((r|0)>=(p|0))break;else s=s+100|0}}yb[c[(c[f>>2]|0)+20>>2]&31](f,q,10712,1145979475,b+708|0)}}else c[e+264>>2]=0;A=c[b+732>>2]|0;c[e+300>>2]=A;if(A){A=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[b+740>>2]|0)|0;c[e+268>>2]=A;if(A|0){k=c[e+300>>2]|0;n=Ob[c[(c[f>>2]|0)+16>>2]&63](f,20,k)|0;if((k|0)>0){j=c[b+740>>2]|0;g=j;l=0;m=c[n+8>>2]|0;while(1){c[m+16>>2]=(a[j+(l*52|0)+20>>0]<<7&255)<<24>>24>>7<<24>>24;h=c[j+(l*52|0)+4>>2]|0;if(!h)h=0;else{h=Zb[c[(c[f>>2]|0)+28>>2]&31](f,h)|0;j=c[b+740>>2]|0;g=j}c[m>>2]=h;h=c[j+(l*52|0)+8>>2]|0;if(!h)h=-1;else h=(h-(c[b+720>>2]|0)|0)/104|0;c[m+4>>2]=h;h=c[j+(l*52|0)+12>>2]|0;if(!h)h=-1;else h=(h-(c[b+720>>2]|0)|0)/104|0;c[m+8>>2]=h;c[m+12>>2]=c[j+(l*52|0)+16>>2];l=l+1|0;if((l|0)>=(k|0))break;else m=m+20|0}}else g=c[b+740>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,n,10729,1497453121,g)}}else c[e+268>>2]=0;A=c[b+752>>2]|0;c[e+304>>2]=A;if(A){A=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[b+760>>2]|0)|0;c[e+272>>2]=A;if(A|0){j=c[e+304>>2]|0;m=Ob[c[(c[f>>2]|0)+16>>2]&63](f,36,j)|0;if((j|0)>0){g=c[b+760>>2]|0;k=0;l=c[m+8>>2]|0;while(1){h=c[g+(k*44|0)+4>>2]|0;if(!h)h=0;else{h=Zb[c[(c[f>>2]|0)+28>>2]&31](f,h)|0;g=c[b+760>>2]|0}c[l+16>>2]=h;c[l>>2]=c[g+(k*44|0)+20>>2];c[l+4>>2]=c[g+(k*44|0)+24>>2];c[l+8>>2]=c[g+(k*44|0)+28>>2];c[l+12>>2]=c[g+(k*44|0)+32>>2];g=c[b+760>>2]|0;h=c[g+(k*44|0)+8>>2]|0;if(!h)h=-1;else h=(h-(c[b+720>>2]|0)|0)/104|0;c[l+20>>2]=h;h=c[g+(k*44|0)+12>>2]|0;if(!h)h=-1;else h=(h-(c[b+720>>2]|0)|0)/104|0;c[l+24>>2]=h;h=c[g+(k*44|0)+16>>2]|0;if(!h)h=-1;else h=(h-(c[b+720>>2]|0)|0)/104|0;c[l+28>>2]=h;c[l+32>>2]=c[g+(k*44|0)+36>>2];k=k+1|0;if((k|0)>=(j|0))break;else l=l+36|0}}else g=c[b+760>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,m,10746,1497453121,g)}}else c[e+272>>2]=0;A=c[b+772>>2]|0;c[e+308>>2]=A;if(A){A=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[b+780>>2]|0)|0;c[e+276>>2]=A;if(A|0){j=c[e+308>>2]|0;m=Ob[c[(c[f>>2]|0)+16>>2]&63](f,100,j)|0;if((j|0)>0){k=0;l=c[m+8>>2]|0;while(1){h=c[b+780>>2]|0;c[l>>2]=c[h+(k*104|0)+32>>2];c[l+4>>2]=c[h+(k*104|0)+36>>2];c[l+8>>2]=c[h+(k*104|0)+40>>2];c[l+12>>2]=c[h+(k*104|0)+44>>2];g=c[h+8>>2]|0;if(!g)g=-1;else g=(g-(c[b+720>>2]|0)|0)/104|0;c[l+68>>2]=g;c[l+16>>2]=c[h+(k*104|0)+48>>2];c[l+20>>2]=c[h+(k*104|0)+52>>2];c[l+24>>2]=c[h+(k*104|0)+56>>2];c[l+28>>2]=c[h+(k*104|0)+60>>2];g=c[h+116>>2]|0;if(!g)g=-1;else g=(g-(c[b+720>>2]|0)|0)/104|0;c[l+72>>2]=g;c[l+32>>2]=c[h+(k*104|0)+64>>2];c[l+36>>2]=c[h+(k*104|0)+68>>2];c[l+40>>2]=c[h+(k*104|0)+72>>2];c[l+44>>2]=c[h+(k*104|0)+76>>2];g=c[h+224>>2]|0;if(!g)g=-1;else g=(g-(c[b+720>>2]|0)|0)/104|0;c[l+76>>2]=g;c[l+48>>2]=c[h+(k*104|0)+80>>2];c[l+52>>2]=c[h+(k*104|0)+84>>2];c[l+56>>2]=c[h+(k*104|0)+88>>2];c[l+60>>2]=c[h+(k*104|0)+92>>2];g=c[h+332>>2]|0;if(!g)g=-1;else g=(g-(c[b+720>>2]|0)|0)/104|0;c[l+80>>2]=g;c[l+88>>2]=c[h+(k*104|0)+96>>2];g=c[b+780>>2]|0;c[l+92>>2]=c[g+(k*104|0)+100>>2];g=c[g+(k*104|0)+4>>2]|0;if(!g)g=0;else g=Zb[c[(c[f>>2]|0)+28>>2]&31](f,g)|0;c[l+64>>2]=g;g=c[b+780>>2]|0;c[l+84>>2]=c[g+(k*104|0)+24>>2];k=k+1|0;if((k|0)>=(j|0))break;else l=l+100|0}}else g=c[b+780>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,m,10763,1497453121,g)}}else c[e+276>>2]=0;A=c[b+792>>2]|0;c[e+312>>2]=A;if(A){A=Zb[c[(c[f>>2]|0)+28>>2]&31](f,c[b+800>>2]|0)|0;c[e+280>>2]=A;if(!A)x=f;else{j=c[e+312>>2]|0;k=Ob[c[(c[f>>2]|0)+16>>2]&63](f,92,j)|0;if((j|0)>0){l=0;m=c[k+8>>2]|0;while(1){h=c[b+800>>2]|0;c[m>>2]=c[h+(l*96|0)+28>>2];c[m+4>>2]=c[h+(l*96|0)+32>>2];c[m+8>>2]=c[h+(l*96|0)+36>>2];c[m+12>>2]=c[h+(l*96|0)+40>>2];c[m+16>>2]=c[h+(l*96|0)+44>>2];c[m+20>>2]=c[h+(l*96|0)+48>>2];c[m+24>>2]=c[h+(l*96|0)+52>>2];c[m+28>>2]=c[h+(l*96|0)+56>>2];c[m+32>>2]=c[h+(l*96|0)+60>>2];c[m+36>>2]=c[h+(l*96|0)+64>>2];c[m+40>>2]=c[h+(l*96|0)+68>>2];c[m+44>>2]=c[h+(l*96|0)+72>>2];c[m+48>>2]=c[h+(l*96|0)+76>>2];c[m+52>>2]=c[h+(l*96|0)+80>>2];c[m+56>>2]=c[h+(l*96|0)+84>>2];c[m+60>>2]=c[h+(l*96|0)+88>>2];c[m+88>>2]=c[h+(l*96|0)+92>>2];h=c[b+800>>2]|0;c[m+64>>2]=c[h+(l*96|0)+4>>2];c[m+68>>2]=c[h+(l*96|0)+8>>2];c[m+72>>2]=c[h+(l*96|0)+12>>2];c[m+76>>2]=c[h+(l*96|0)+16>>2];g=c[h+(l*96|0)>>2]|0;if(!g)g=-1;else g=(g-(c[b+720>>2]|0)|0)/104|0;c[m+84>>2]=g;g=c[h+(l*96|0)+20>>2]|0;if(!g)g=0;else g=Zb[c[(c[f>>2]|0)+28>>2]&31](f,g)|0;c[m+80>>2]=g;l=l+1|0;if((l|0)>=(j|0))break;else m=m+92|0}}yb[c[(c[f>>2]|0)+20>>2]&31](f,k,10781,1497453121,c[b+800>>2]|0);x=f}}else{c[e+280>>2]=0;x=f}c[e+352>>2]=c[b+316>>2];c[e+328>>2]=c[b+292>>2];c[e+344>>2]=c[b+308>>2];c[e+324>>2]=c[b+288>>2];c[e+340>>2]=c[b+304>>2];c[e+336>>2]=c[b+300>>2];c[e+412>>2]=c[b+376>>2];c[e+416>>2]=c[b+380>>2];c[e+420>>2]=c[b+384>>2];c[e+408>>2]=c[b+372>>2];n=c[b+364>>2]|0;c[e+332>>2]=c[b+296>>2];c[e+356>>2]=c[b+320>>2];c[e+424>>2]=c[b+388>>2];c[e+348>>2]=c[b+312>>2];c[e+360>>2]=c[b+324>>2];c[e+364>>2]=c[b+328>>2];c[e+368>>2]=c[b+332>>2];c[e+372>>2]=c[b+336>>2];c[e+404>>2]=c[b+368>>2];c[e+400>>2]=n;c[e+376>>2]=c[b+340>>2];c[e+380>>2]=c[b+344>>2];c[e+384>>2]=c[b+348>>2];c[e+388>>2]=c[b+352>>2];c[e+392>>2]=c[b+356>>2];c[e+396>>2]=c[b+360>>2];c[e+256>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,b+472|0)|0;n=Ob[c[(c[f>>2]|0)+16>>2]&63](f,192,1)|0;m=c[n+8>>2]|0;c[m+96>>2]=c[b+632>>2];c[m+100>>2]=c[b+636>>2];c[m+104>>2]=c[b+640>>2];c[m+108>>2]=c[b+644>>2];c[m+112>>2]=c[b+648>>2];c[m+116>>2]=c[b+652>>2];c[m+120>>2]=c[b+656>>2];c[m+124>>2]=c[b+660>>2];c[m+128>>2]=c[b+664>>2];c[m+132>>2]=c[b+668>>2];c[m+136>>2]=c[b+672>>2];c[m+140>>2]=c[b+676>>2];c[m+180>>2]=d[b+473>>0];c[m+176>>2]=d[b+472>>0];c[m+144>>2]=c[b+520>>2];c[m+148>>2]=c[b+524>>2];c[m+152>>2]=c[b+528>>2];c[m+156>>2]=c[b+532>>2];A=c[b+484>>2]|0;c[m+168>>2]=A;if(A){A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[b+492>>2]|0)|0;h=c[m+168>>2]|0;c[m+160>>2]=A;if(h|0){l=Ob[c[(c[f>>2]|0)+16>>2]&63](f,16,h)|0;if((h|0)>0){g=c[b+492>>2]|0;j=0;k=c[l+8>>2]|0;while(1){c[k>>2]=c[g+(j<<4)>>2];c[k+4>>2]=c[g+(j<<4)+4>>2];c[k+8>>2]=c[g+(j<<4)+8>>2];c[k+12>>2]=c[g+(j<<4)+12>>2];j=j+1|0;if((j|0)==(h|0))break;else k=k+16|0}}else g=c[b+492>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,l,19308,1497453121,g)}}else c[m+160>>2]=0;c[m+184>>2]=c[b+476>>2];c[m>>2]=c[b+536>>2];c[m+4>>2]=c[b+540>>2];c[m+8>>2]=c[b+544>>2];c[m+12>>2]=c[b+548>>2];c[m+16>>2]=c[b+552>>2];c[m+20>>2]=c[b+556>>2];c[m+24>>2]=c[b+560>>2];c[m+28>>2]=c[b+564>>2];c[m+32>>2]=c[b+568>>2];c[m+36>>2]=c[b+572>>2];c[m+40>>2]=c[b+576>>2];c[m+44>>2]=c[b+580>>2];c[m+48>>2]=c[b+584>>2];c[m+52>>2]=c[b+588>>2];c[m+56>>2]=c[b+592>>2];c[m+60>>2]=c[b+596>>2];c[m+64>>2]=c[b+600>>2];c[m+68>>2]=c[b+604>>2];c[m+72>>2]=c[b+608>>2];c[m+76>>2]=c[b+612>>2];c[m+80>>2]=c[b+616>>2];c[m+84>>2]=c[b+620>>2];c[m+88>>2]=c[b+624>>2];c[m+92>>2]=c[b+628>>2];A=c[b+504>>2]|0;c[m+172>>2]=A;if(A){A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[b+512>>2]|0)|0;k=c[m+172>>2]|0;c[m+164>>2]=A;if(!k)y=153;else{l=Ob[c[(c[f>>2]|0)+16>>2]&63](f,4,k)|0;if((k|0)>0){g=c[b+512>>2]|0;h=0;j=c[l+8>>2]|0;while(1){c[j>>2]=c[g+(h<<2)>>2];h=h+1|0;if((h|0)==(k|0))break;else j=j+4|0}}else g=c[b+512>>2]|0;yb[c[(c[f>>2]|0)+20>>2]&31](f,l,10801,1497453121,g);w=f}}else{c[m+164>>2]=0;y=153}if((y|0)==153)w=f;yb[c[(c[w>>2]|0)+20>>2]&31](f,n,10807,1497453121,b+472|0);A=c[b+1112>>2]|0;c[e+316>>2]=A;if(A){A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[c[b+1120>>2]>>2]|0)|0;q=c[e+316>>2]|0;c[e+284>>2]=A;if(q|0){r=Ob[c[(c[f>>2]|0)+16>>2]&63](f,348,q)|0;if((q|0)>0){s=c[z+12>>2]|0;t=c[z+52>>2]|0;u=0;v=c[r+8>>2]|0;while(1){h=c[(c[b+1120>>2]|0)+(u<<2)>>2]|0;A=v+320|0;c[A>>2]=c[h+360>>2];c[v+256>>2]=c[h+332>>2];c[v+260>>2]=c[h+336>>2];c[v+264>>2]=c[h+340>>2];c[v+268>>2]=c[h+344>>2];c[v+344>>2]=c[h+380>>2];c[v+340>>2]=d[h+377>>0];c[v+160>>2]=c[h+228>>2];c[v+164>>2]=c[h+232>>2];c[v+168>>2]=c[h+236>>2];c[v+172>>2]=c[h+240>>2];c[v+336>>2]=d[h+376>>0];c[v+208>>2]=c[h+276>>2];c[v+212>>2]=c[h+280>>2];c[v+216>>2]=c[h+284>>2];c[v+220>>2]=c[h+288>>2];c[v+224>>2]=c[h+292>>2];c[v+228>>2]=c[h+296>>2];c[v+232>>2]=c[h+300>>2];c[v+236>>2]=c[h+304>>2];h=c[(c[b+1120>>2]|0)+(u<<2)>>2]|0;c[v>>2]=c[h+60>>2];c[v+4>>2]=c[h+64>>2];c[v+8>>2]=c[h+68>>2];c[v+12>>2]=c[h+72>>2];c[v+16>>2]=c[h+76>>2];c[v+20>>2]=c[h+80>>2];c[v+24>>2]=c[h+84>>2];c[v+28>>2]=c[h+88>>2];c[v+32>>2]=c[h+92>>2];c[v+36>>2]=c[h+96>>2];c[v+40>>2]=c[h+100>>2];c[v+44>>2]=c[h+104>>2];c[v+48>>2]=c[h+108>>2];c[v+52>>2]=c[h+112>>2];c[v+56>>2]=c[h+116>>2];c[v+60>>2]=c[h+120>>2];c[v+296>>2]=c[h+124>>2];h=c[(c[b+1120>>2]|0)+(u<<2)>>2]|0;c[v+300>>2]=c[h+128>>2];c[v+112>>2]=c[h+180>>2];c[v+116>>2]=c[h+184>>2];c[v+120>>2]=c[h+188>>2];c[v+124>>2]=c[h+192>>2];c[v+128>>2]=c[h+196>>2];c[v+132>>2]=c[h+200>>2];c[v+136>>2]=c[h+204>>2];c[v+140>>2]=c[h+208>>2];c[v+144>>2]=c[h+212>>2];c[v+148>>2]=c[h+216>>2];c[v+152>>2]=c[h+220>>2];c[v+156>>2]=c[h+224>>2];g=v+316|0;c[g>>2]=c[h+356>>2];c[v+64>>2]=c[h+132>>2];c[v+68>>2]=c[h+136>>2];c[v+72>>2]=c[h+140>>2];c[v+76>>2]=c[h+144>>2];c[v+80>>2]=c[h+148>>2];c[v+84>>2]=c[h+152>>2];c[v+88>>2]=c[h+156>>2];c[v+92>>2]=c[h+160>>2];c[v+96>>2]=c[h+164>>2];c[v+100>>2]=c[h+168>>2];c[v+104>>2]=c[h+172>>2];c[v+108>>2]=c[h+176>>2];h=c[(c[b+1120>>2]|0)+(u<<2)>>2]|0;c[v+240>>2]=c[h+316>>2];c[v+244>>2]=c[h+320>>2];c[v+248>>2]=c[h+324>>2];c[v+252>>2]=c[h+328>>2];c[v+324>>2]=c[h+364>>2];c[v+328>>2]=c[h+368>>2];c[v+312>>2]=c[h+352>>2];c[g>>2]=c[h+356>>2];c[A>>2]=c[h+360>>2];c[v+332>>2]=c[h+372>>2];A=c[h+44>>2]|0;g=v+284|0;c[g>>2]=A;m=v+292|0;c[m>>2]=c[h+4>>2];n=v+288|0;c[n>>2]=c[h+24>>2];c[v+304>>2]=c[h+308>>2];c[v+176>>2]=c[h+244>>2];c[v+180>>2]=c[h+248>>2];c[v+184>>2]=c[h+252>>2];c[v+188>>2]=c[h+256>>2];c[v+192>>2]=c[h+260>>2];c[v+196>>2]=c[h+264>>2];c[v+200>>2]=c[h+268>>2];c[v+204>>2]=c[h+272>>2];h=c[(c[b+1120>>2]|0)+(u<<2)>>2]|0;c[v+308>>2]=c[h+312>>2];if(A){A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[h+52>>2]|0)|0;c[v+272>>2]=A;if(A|0){g=c[g>>2]|0;h=Ob[c[(c[f>>2]|0)+16>>2]&63](f,16,g)|0;if((g|0)>0){j=c[(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+52>>2]|0;k=0;l=c[h+8>>2]|0;while(1){c[l>>2]=c[j+(k<<4)>>2];c[l+4>>2]=c[j+(k<<4)+4>>2];c[l+8>>2]=c[j+(k<<4)+8>>2];c[l+12>>2]=c[j+(k<<4)+12>>2];k=k+1|0;if((k|0)==(g|0))break;else l=l+16|0}}yb[c[(c[w>>2]|0)+20>>2]&31](f,h,19308,1497453121,c[(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+52>>2]|0)}}else c[v+272>>2]=0;if(c[m>>2]|0){A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+12>>2]|0)|0;c[v+280>>2]=A;if(A|0){g=c[m>>2]|0;h=Ob[c[(c[f>>2]|0)+16>>2]&63](f,4,g)|0;if((g|0)>0){j=c[(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+12>>2]|0;k=0;l=c[h+8>>2]|0;while(1){c[l>>2]=c[j+(k<<2)>>2];k=k+1|0;if((k|0)==(g|0))break;else l=l+4|0}}yb[c[(c[w>>2]|0)+20>>2]&31](f,h,10801,1497453121,c[(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+12>>2]|0)}}else c[v+280>>2]=0;if(c[n>>2]|0){A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+20|0)|0;c[v+276>>2]=A;if(A|0){k=c[m>>2]|0;l=Ob[c[(c[f>>2]|0)+16>>2]&63](f,4,k)|0;if((k|0)>0){m=c[(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+32>>2]|0;n=c[z+32>>2]|0;o=0;p=c[l+8>>2]|0;while(1){h=c[m+(o<<2)>>2]|0;g=(h+~(h<<15)>>10^h+~(h<<15))*9|0;j=c[z+72>>2]|0;g=c[s+((((g>>6^g)+~((g>>6^g)<<11)>>16^(g>>6^g)+~((g>>6^g)<<11))&(c[z+48>>2]|0)+-1)<<2)>>2]|0;if((h|0)!=(c[j+(g<<3)>>2]|0))do g=c[n+(g<<2)>>2]|0;while((h|0)!=(c[j+(g<<3)>>2]|0));c[p>>2]=c[t+(g<<2)>>2];o=o+1|0;if((o|0)==(k|0))break;else p=p+4|0}}yb[c[(c[w>>2]|0)+20>>2]&31](f,l,10844,1497453121,(c[(c[b+1120>>2]|0)+(u<<2)>>2]|0)+20|0)}}else c[v+276>>2]=0;u=u+1|0;if((u|0)>=(q|0))break;else v=v+348|0}}yb[c[(c[w>>2]|0)+20>>2]&31](f,r,10824,1497453121,c[c[b+1120>>2]>>2]|0)}}else c[e+284>>2]=0;A=c[b+852>>2]|0;c[e+320>>2]=A;if(!A){c[e+288>>2]=0;pj(z);i=z;return 10868}A=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[b+860>>2]|0)|0;c[e+288>>2]=A;if(!A){pj(z);i=z;return 10868}j=c[b+852>>2]|0;k=Ob[c[(c[f>>2]|0)+16>>2]&63](f,104,j)|0;if((j|0)>0){m=0;n=c[k+8>>2]|0;while(1){g=c[(c[b+860>>2]|0)+(m<<2)>>2]|0;c[n+96>>2]=Eb[c[(c[g>>2]|0)+20>>2]&127](g)|0;g=(c[b+860>>2]|0)+(m<<2)|0;h=c[g>>2]|0;c[n+8>>2]=c[h+28>>2];c[n+12>>2]=c[h+32>>2];c[n+16>>2]=c[h+36>>2];c[n+20>>2]=c[h+40>>2];c[n+24>>2]=c[h+44>>2];c[n+28>>2]=c[h+48>>2];c[n+32>>2]=c[h+52>>2];c[n+36>>2]=c[h+56>>2];c[n+40>>2]=c[h+60>>2];c[n+44>>2]=c[h+64>>2];c[n+48>>2]=c[h+68>>2];c[n+52>>2]=d[h+152>>0];h=n+56|0;c[n>>2]=0;l=n+4|0;c[l>>2]=0;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;c[h+16>>2]=0;c[h+20>>2]=0;c[h+24>>2]=0;c[h+28>>2]=0;g=c[g>>2]|0;h=c[g+4>>2]|0;if(h){c[n+88>>2]=1;c[n>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,h)|0;g=c[(c[b+860>>2]|0)+(m<<2)>>2]|0}if(c[g+12>>2]|0){c[n+88>>2]=3;c[n>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,c[(c[(c[b+860>>2]|0)+(m<<2)>>2]|0)+12>>2]|0)|0}g=c[(c[b+860>>2]|0)+(m<<2)>>2]|0;h=c[g+8>>2]|0;if(h){c[n+88>>2]=2;c[n>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,h)|0;g=c[(c[b+860>>2]|0)+(m<<2)>>2]|0}h=c[g+16>>2]|0;if(h){c[n+92>>2]=1;c[l>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,h)|0;g=c[(c[b+860>>2]|0)+(m<<2)>>2]|0}h=c[g+24>>2]|0;if(h){c[n+92>>2]=3;c[l>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,h)|0;g=c[(c[b+860>>2]|0)+(m<<2)>>2]|0}g=c[g+20>>2]|0;if(g|0){c[n+92>>2]=2;c[l>>2]=Zb[c[(c[x>>2]|0)+28>>2]&31](f,g)|0}m=m+1|0;if((m|0)>=(j|0))break;else n=n+104|0}}yb[c[(c[w>>2]|0)+20>>2]&31](f,k,10848,1497453121,c[b+860>>2]|0);pj(z);i=z;return 10868}function vc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;K=i;i=i+144|0;a:do switch(d-b|0){case 0:{c[e>>2]=0;c[e+4>>2]=0;c[e+8>>2]=0;c[e+12>>2]=0;i=K;return}case 2:{f=c[(c[a+92>>2]|0)+(b<<2)>>2]|0;k=c[f+88>>2]|0;l=c[f+200>>2]|0;j=c[f+92>>2]|0;g=c[f+204>>2]|0;if((k|0)==(l|0)){if((j|0)==(g|0))if((c[f+96>>2]|0)==(c[f+208>>2]|0))break a;else g=j;if((j|0)==(g|0)){I=(c[f+96>>2]|0)>(c[f+208>>2]|0);g=I?f+112|0:f;c[g>>2]=g;c[g+4>>2]=g;c[e>>2]=g;c[e+4>>2]=g;c[e+8>>2]=g;c[e+12>>2]=g;f=I?f:f+112|0}else{h=g;g=0;J=9}}else{h=g;g=(j|0)==(g|0);J=9}do if((J|0)==9){c[f>>2]=f+112;c[f+4>>2]=f+112;c[f+112>>2]=f;c[f+116>>2]=f;J=(j|0)<(h|0);c[e>>2]=(k|0)<(l|0)|(k|0)==(l|0)&J?f:f+112|0;c[e+4>>2]=(k|0)<(l|0)|(k|0)==(l|0)&J?f+112|0:f;if(J|(k|0)<(l|0)&g){c[e+8>>2]=f;c[e+12>>2]=f+112;g=f;f=f+112|0;break}else{c[e+8>>2]=f+112;c[e+12>>2]=f;g=f;f=f+112|0;break}}while(0);a=dg(a,g,f)|0;c[a>>2]=a;c[a+4>>2]=a;c[g+8>>2]=a;a=c[a+8>>2]|0;c[a>>2]=a;c[a+4>>2]=a;c[f+8>>2]=a;i=K;return}case 1:{f=c[(c[a+92>>2]|0)+(b<<2)>>2]|0;break}default:{n=((d-b|0)/2|0)+b|0;h=c[a+92>>2]|0;m=c[h+(n+-1<<2)>>2]|0;j=c[m+88>>2]|0;k=c[m+92>>2]|0;m=c[m+96>>2]|0;b:do if((n|0)<(d|0)){f=n;do{g=c[h+(f<<2)>>2]|0;if((c[g+88>>2]|0)!=(j|0))break b;if((c[g+92>>2]|0)!=(k|0))break b;if((c[g+96>>2]|0)!=(m|0))break b;f=f+1|0}while((f|0)<(d|0))}else f=n;while(0);vc(a,b,n,e);c[K+96>>2]=0;c[K+96+4>>2]=0;c[K+96+8>>2]=0;c[K+96+12>>2]=0;vc(a,f,d,K+96|0);m=c[K+96+4>>2]|0;c:do if(m|0){A=c[e+4>>2]|0;if(!A){c[e>>2]=c[K+96>>2];c[e+4>>2]=c[K+96+4>>2];c[e+8>>2]=c[K+96+8>>2];c[e+12>>2]=c[K+96+12>>2];break}c[a+100>>2]=(c[a+100>>2]|0)+-1;h=c[e+12>>2]|0;k=c[K+96+8>>2]|0;j=c[h+88>>2]|0;d:do if((j|0)==(c[k+88>>2]|0)?(l=c[h+92>>2]|0,(l|0)==(c[k+92>>2]|0)):0){n=c[k+4>>2]|0;if((n|0)==(k|0)){f=c[k+8>>2]|0;if(f){k=c[f+12>>2]|0;l=c[k+92>>2]|0;j=c[k+88>>2]|0}g=h;G=k;f=k;n=j+1|0;d=c[k+96>>2]|0;break}h=c[k>>2]|0;c[n>>2]=h;c[h+4>>2]=n;e:do if((k|0)==(c[K+96>>2]|0)){f=c[h+88>>2]|0;g=c[n+88>>2]|0;do if((f|0)>=(g|0)){if((f|0)==(g|0)?(c[h+92>>2]|0)<(c[n+92>>2]|0):0)break;c[K+96>>2]=n;break e}while(0);c[K+96>>2]=h}while(0);if((k|0)==(m|0)){f=c[h+88>>2]|0;g=c[n+88>>2]|0;do if((f|0)<=(g|0)){if((f|0)==(g|0)?(c[h+92>>2]|0)>(c[n+92>>2]|0):0)break;c[K+96+4>>2]=n;h=n;J=39;break d}while(0);c[K+96+4>>2]=h;J=39}else{h=m;J=39}}else{h=m;J=39}while(0);if((J|0)==39){w=c[e>>2]|0;x=c[K+96>>2]|0;y=0;z=1;b=A;g=0;f=h;j=0;while(1){k=c[f+88>>2]|0;d=c[b+88>>2]|0;l=_(k-d|0,z)|0;f:do if((l|0)<=0){if((l|0)<0){v=(y|0)!=0;n=c[b+92>>2]|0;u=c[f+92>>2]|0;m=l;l=b;while(1){r=c[(v?f+4|0:f)>>2]|0;s=(r|0)==(f|0);t=f+88|0;q=m;while(1){m=l+88|0;o=u-n|0;if(!s?(B=c[r+88>>2]|0,D=_(B-k|0,z)|0,E=c[r+92>>2]|0,F=E-u|0,(F|0)>-1):0){if(!D)break;if((D|0)<0?(_(F,q)|0)<=(_(D,o)|0):0)break}p=c[(v?l+4|0:l)>>2]|0;if((p|0)==(l|0))break f;G=c[p+88>>2]|0;d=_(G-(c[m>>2]|0)|0,z)|0;b=c[p+92>>2]|0;m=b-n|0;k=c[t>>2]|0;n=q;q=_(k-G|0,z)|0;if(!((m|0)>0&(q|0)<0))break f;if(!d){n=b;l=p;continue}if((d|0)>=0)break f;if((_(m,n)|0)>=(_(d,o)|0))break f;else{n=b;l=p}}k=B;u=E;m=_(B-(c[m>>2]|0)|0,z)|0;f=r}}k=c[b+92>>2]|0;n=(y|0)!=0;g:do if(n){m=b;while(1){l=c[m>>2]|0;if((l|0)==(b|0))break g;if((c[l+88>>2]|0)!=(d|0))break g;G=k;k=c[l+92>>2]|0;if((k|0)>(G|0))break;else m=l}}else{m=b;while(1){l=c[m+4>>2]|0;if((l|0)==(b|0))break g;if((c[l+88>>2]|0)!=(d|0))break g;G=k;k=c[l+92>>2]|0;if((k|0)>(G|0))break;else m=l}}while(0);l=c[f+92>>2]|0;if(n){n=f;while(1){k=c[n+4>>2]|0;if((k|0)==(f|0)){l=m;f=n;break f}if((c[k+88>>2]|0)!=(d|0)){l=m;f=n;break f}G=l;l=c[k+92>>2]|0;if((l|0)<(G|0)){l=m;f=n;break}else n=k}}else{n=f;while(1){k=c[n>>2]|0;if((k|0)==(f|0)){l=m;f=n;break f}if((c[k+88>>2]|0)!=(d|0)){l=m;f=n;break f}G=l;l=c[k+92>>2]|0;if((l|0)<(G|0)){l=m;f=n;break}else n=k}}}else{u=(y|0)!=0;s=d;t=c[f+92>>2]|0;r=l;while(1){q=f+88|0;m=c[b+92>>2]|0;k=t-m|0;l=c[(u?b:b+4|0)>>2]|0;h:do if((l|0)!=(b|0))if(u){p=s;o=m;d=r;while(1){m=p;p=c[l+88>>2]|0;m=_(p-m|0,z)|0;n=o;o=c[l+92>>2]|0;n=o-n|0;if((n|0)>=1){o=k;l=b;break h}if(m|0){if((m|0)>=0){o=k;l=b;break h}if((_(n,d)|0)>(_(m,k)|0)){o=k;l=b;break h}}n=_((c[q>>2]|0)-p|0,z)|0;k=t-o|0;m=c[l>>2]|0;if((m|0)==(l|0)){o=k;d=n;break}else{b=l;l=m;d=n}}}else{p=s;o=m;d=r;while(1){m=p;p=c[l+88>>2]|0;m=_(p-m|0,z)|0;n=o;o=c[l+92>>2]|0;n=o-n|0;if((n|0)>=1){o=k;l=b;break h}if(m|0){if((m|0)>=0){o=k;l=b;break h}if((_(n,d)|0)>(_(m,k)|0)){o=k;l=b;break h}}n=_((c[q>>2]|0)-p|0,z)|0;k=t-o|0;m=c[l+4>>2]|0;if((m|0)==(l|0)){o=k;d=n;break}else{b=l;l=m;d=n}}}else{o=k;d=r;l=b}while(0);n=c[(u?f:f+4|0)>>2]|0;if((n|0)==(f|0))break f;r=c[n+88>>2]|0;k=_(r-(c[q>>2]|0)|0,z)|0;m=t;t=c[n+92>>2]|0;m=t-m|0;s=c[l+88>>2]|0;r=_(r-s|0,z)|0;if(!((m|0)<0&(r|0)>0))break f;if(!k){b=l;f=n;continue}if((k|0)>=0)break f;if((_(m,d)|0)>=(_(k,o)|0))break;else{b=l;f=n}}}while(0);k=(y|0)==0;j=k?f:j;g=k?l:g;f=k?x:f;b=k?w:l;y=y+1|0;if((y|0)==2)break;else z=k?-1:z}c[b+4>>2]=f;c[f>>2]=b;c[g>>2]=j;c[j+4>>2]=g;if((c[x+88>>2]|0)<(c[w+88>>2]|0))c[e>>2]=x;if((c[h+88>>2]|0)>=(c[A+88>>2]|0))c[e+4>>2]=h;c[e+12>>2]=c[K+96+12>>2];h=g;F=j;s=c[j+88>>2]|0;d=c[g+88>>2]|0;t=c[j+92>>2]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,((x|0)<0)<<31>>31|0)|0,M=Kt(G|0,L|0,M|0,C|0)|0,L=C,!((L|0)>0|(L|0)==0&M>>>0>0)):0)break}c[K+72>>2]=o;f=o}while(0);o=c[o>>2]|0}while((o|0)!=(n|0))}if((p|0)!=0|(f|0)!=0){Ac(a,g,j,K+120|0,K+72|0);f=c[K+120>>2]|0;if(f){h=c[f+12>>2]|0;g=h}f=c[K+72>>2]|0;if(!f)f=F;else{f=c[f+12>>2]|0;j=f}}else f=F;G=j;n=c[j+88>>2]|0;d=(c[j+96>>2]|0)+1|0;l=c[j+92>>2]|0}w=G;x=g;j=0;D=0;e=1;k=0;m=0;y=0;A=0;B=n;o=d;F=0;n=0;while(1){z=x+88|0;u=(c[w+88>>2]|0)-(c[z>>2]|0)|0;M=x+92|0;E=(c[w+92>>2]|0)-(c[M>>2]|0)|0;t=x+96|0;r=(c[w+96>>2]|0)-(c[t>>2]|0)|0;c[K+120>>2]=u;c[K+120+4>>2]=E;c[K+120+8>>2]=r;c[K+120+12>>2]=-1;z=B-(c[z>>2]|0)|0;M=l-(c[M>>2]|0)|0;t=o-(c[t>>2]|0)|0;s=(_(r,M)|0)-(_(E,t)|0)|0;t=(_(u,t)|0)-(_(r,z)|0)|0;M=(_(E,z)|0)-(_(u,M)|0)|0;c[K+72>>2]=s;c[K+72+4>>2]=((s|0)<0)<<31>>31;c[K+72+8>>2]=t;c[K+72+8+4>>2]=((t|0)<0)<<31>>31;c[K+72+16>>2]=M;c[K+72+16+4>>2]=((M|0)<0)<<31>>31;z=vr(E|0,((E|0)<0)<<31>>31|0,M|0,((M|0)<0)<<31>>31|0)|0;L=C;v=vr(r|0,((r|0)<0)<<31>>31|0,t|0,((t|0)<0)<<31>>31|0)|0;v=Is(z|0,L|0,v|0,C|0)|0;L=C;r=vr(s|0,((s|0)<0)<<31>>31|0,r|0,((r|0)<0)<<31>>31|0)|0;z=C;M=vr(u|0,((u|0)<0)<<31>>31|0,M|0,((M|0)<0)<<31>>31|0)|0;M=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C;N=vr(L|0,0,N|0,0)|0;L=C;t=Kt(M|0,0,t|0,0)|0;M=C;L=Kt(O|0,0,N|0,L|0)|0;u=Kt(L|0,C|0,u|0,0)|0;M=Kt(u|0,C|0,M|0,0)|0;u=C;r=Kt(0,t|0,s|0,r|0)|0;s=C;t=Kt(M|0,u|0,(s>>>0>>0|(s|0)==(t|0)&r>>>0<0)&1|0,0)|0;u=C;if(!(q>>>0>>0|(q|0)==(u|0)&p>>>0>>0))if(!(q>>>0>u>>>0|(q|0)==(u|0)&p>>>0>t>>>0))if(b>>>0>>0|(b|0)==(s|0)&d>>>0>>0)d=-1;else d=(b>>>0>s>>>0|(b|0)==(s|0)&d>>>0>r>>>0)&1;else d=1;else d=-1;u=_(d,v)|0}}else u=d;while(0);do if(!e)if((u|0)>-1)if((c[K+16>>2]|0)<0&((c[K+8>>2]|0)==0?(c[K+8+4>>2]|0)==0:0)){b=y;t=A;break}else{J=136;break}else if((c[K+24+16>>2]|0)<0&((c[K+24+8>>2]|0)==0?(c[K+24+8+4>>2]|0)==0:0)){b=y;t=A;break}else{J=136;break}else J=136;while(0);if((J|0)==136){J=0;b=dg(a,x,w)|0;if(!y)k=b;else c[y+4>>2]=b;c[b>>2]=y;d=c[b+8>>2]|0;if(!A)m=d;else c[A>>2]=d;c[d+4>>2]=A;t=d}c[K+116>>2]=E;c[K+112>>2]=z;if(!u){Ac(a,h,f,K+116|0,K+112|0);s=c[K+112>>2]|0}else s=z;if((u|0)>-1&(s|0)!=0){r=(n|0)!=0;if(r?(H=c[n>>2]|0,(H|0)!=(z|0)):0){p=H;do{q=p;p=c[p>>2]|0;o=c[q+8>>2]|0;d=c[o+12>>2]|0;if((p|0)==(q|0))l=0;else{c[p+4>>2]=c[q+4>>2];c[c[q+4>>2]>>2]=p;l=p}c[d+8>>2]=l;l=c[o>>2]|0;d=c[q+12>>2]|0;if((l|0)==(o|0))l=0;else{c[l+4>>2]=c[o+4>>2];c[c[o+4>>2]>>2]=l}c[d+8>>2]=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0,ra=0.0;ga=i;i=i+368|0;e=c[b+24>>2]|0;if((e|0)<=0){i=ga;return}K=ga+56+76|0;V=ga+272+16|0;W=ga+272+32|0;J=0;do{I=c[(c[b+32>>2]|0)+(J<<2)>>2]|0;switch(c[I+216>>2]|0){case 2:case 5:break;default:{if(a[I+924>>0]|0){a[I+924>>0]=0;h=c[I+732>>2]|0;if((h|0)>0){e=c[I+740>>2]|0;f=0;do{G=c[e+(f*52|0)+8>>2]|0;H=c[e+(f*52|0)+12>>2]|0;D=+g[G+8>>2]-+g[H+8>>2];E=+g[G+12>>2]-+g[H+12>>2];F=+g[G+16>>2]-+g[H+16>>2];F=+O(+(D*D+E*E+F*F));g[e+(f*52|0)+16>>2]=F;g[e+(f*52|0)+28>>2]=F*F;f=f+1|0}while((f|0)!=(h|0));e=c[I+740>>2]|0;f=0;do{g[e+(f*52|0)+24>>2]=(+g[(c[e+(f*52|0)+8>>2]|0)+88>>2]+ +g[(c[e+(f*52|0)+12>>2]|0)+88>>2])/+g[(c[e+(f*52|0)+4>>2]|0)+4>>2];f=f+1|0}while((f|0)!=(h|0))}eg(I);e=c[I+988>>2]|0;if(e|0)xn(I+988|0,e);e=c[I+992>>2]|0;if(e|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[I+992>>2]=0;c[I+996>>2]=-1;e=c[I+1020>>2]|0;if(e|0){if(a[I+1024>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[I+1020>>2]=0}a[I+1024>>0]=1;c[I+1020>>2]=0;c[I+1012>>2]=0;c[I+1016>>2]=0;c[I+1004>>2]=0;if(c[I+388>>2]&16|0)gg(I)}m=+g[I+368>>2]*d;g[I+452>>2]=m;g[I+456>>2]=1.0/m;g[I+460>>2]=m*3.0;e=c[I+192>>2]|0;m=+Sb[c[(c[e>>2]|0)+48>>2]&15](e);g[I+464>>2]=m;g[I+468>>2]=m*.25;e=c[I+684>>2]|0;m=+g[I+452>>2];j=+g[e+40>>2]*m;l=m*+g[e+44>>2];m=m*+g[e+48>>2];e=c[I+712>>2]|0;if((e|0)>0){f=c[I+720>>2]|0;h=0;do{if(+g[f+(h*104|0)+88>>2]>0.0){H=f+(h*104|0)+40|0;g[H>>2]=j+ +g[H>>2];H=f+(h*104|0)+44|0;g[H>>2]=l+ +g[H>>2];H=f+(h*104|0)+48|0;g[H>>2]=m+ +g[H>>2]}h=h+1|0}while((h|0)!=(e|0))}li(11033);E=+g[I+308>>2];F=+g[I+312>>2];n=+g[I+304>>2]>0.0?1:+g[I+300>>2]>0.0;y=c[I+712>>2]|0;if(E!=0.0|F>0.0){if((y|0)>0){e=c[I+720>>2]|0;l=+g[e+8>>2];m=+g[e+12>>2];o=+g[e+16>>2];e=c[I+752>>2]|0;if((e|0)>0){f=c[I+760>>2]|0;h=0;j=0.0;do{H=c[f+(h*44|0)+8>>2]|0;G=c[f+(h*44|0)+12>>2]|0;C=+g[G+8>>2]-l;x=+g[G+12>>2]-m;A=+g[G+16>>2]-o;G=c[f+(h*44|0)+16>>2]|0;B=+g[G+8>>2]-l;z=+g[G+12>>2]-m;D=+g[G+16>>2]-o;j=j+((+g[H+16>>2]-o)*(C*z-x*B)+((+g[H+8>>2]-l)*(x*D-A*z)+(+g[H+12>>2]-m)*(A*B-C*D)));h=h+1|0}while((h|0)!=(e|0))}else j=0.0;j=j/6.0}else j=0.0;D=E*(1.0/+N(+j));C=F*(+g[I+476>>2]-j)}else{C=0.0;D=0.0}a:do if((y|0)>0){if(!n){e=c[I+720>>2]|0;f=0;while(1){if(+g[e+(f*104|0)+88>>2]>0.0){if(E!=0.0){z=D*+g[e+(f*104|0)+92>>2];A=z*+g[e+(f*104|0)+76>>2];B=z*+g[e+(f*104|0)+80>>2];H=e+(f*104|0)+56|0;g[H>>2]=+g[e+(f*104|0)+72>>2]*z+ +g[H>>2];H=e+(f*104|0)+60|0;g[H>>2]=A+ +g[H>>2];H=e+(f*104|0)+64|0;g[H>>2]=B+ +g[H>>2]}if(F>0.0){z=C*+g[e+(f*104|0)+92>>2];A=z*+g[e+(f*104|0)+76>>2];B=z*+g[e+(f*104|0)+80>>2];H=e+(f*104|0)+56|0;g[H>>2]=+g[e+(f*104|0)+72>>2]*z+ +g[H>>2];H=e+(f*104|0)+60|0;g[H>>2]=A+ +g[H>>2];H=e+(f*104|0)+64|0;g[H>>2]=B+ +g[H>>2]}}f=f+1|0;if((f|0)==(y|0))break a}}f=c[I+720>>2]|0;h=0;do{x=+g[f+(h*104|0)+88>>2];if(x>0.0){z=+g[I+452>>2];q=+g[I+304>>2];o=+g[I+300>>2];b:do if((q>0.0|o>0.0?(L=c[c[I+684>>2]>>2]|0,(c[I+288>>2]|0)<4):0)?(M=+g[f+(h*104|0)+40>>2],P=M-+g[I+1212>>2],Q=+g[f+(h*104|0)+44>>2],R=Q-+g[I+1216>>2],S=+g[f+(h*104|0)+48>>2],T=S-+g[I+1220>>2],U=+O(+(P*P+R*R+T*T)),P*P+R*R+T*T>1.1920928955078125e-07):0){u=P*(1.0/U);A=R*(1.0/U);B=T*(1.0/U);s=+g[f+(h*104|0)+72>>2];t=+g[f+(h*104|0)+76>>2];v=+g[f+(h*104|0)+80>>2];switch(c[I+288>>2]|0){case 2:break;case 1:case 3:case 0:{j=P*s+R*t+T*v<0.0?-1.0:1.0;if(!(T*v*j+(P*s*j+R*t*j)>0.0))break b;w=-((c[k>>2]=L,+g[k>>2])*(P*P+R*R+T*T)*(T*v*j+(P*s*j+R*t*j))*+g[f+(h*104|0)+92>>2]*.5);m=u*o*w+(s*j*q*w+0.0);l=A*o*w+(t*j*q*w+0.0);j=B*o*w+(v*j*q*w+0.0);e=f+(h*104|0)+56|0;if(z*x*j*z*x*j+(z*x*m*z*x*m+z*x*l*z*x*l)>M*M+Q*Q+S*S){B=1.0/+O(+(j*j+(m*m+l*l)));g[e>>2]=+g[e>>2]-1.0/(z*x)*m*B*(S*j*B+(M*m*B+Q*l*B));H=f+(h*104|0)+60|0;g[H>>2]=+g[H>>2]-1.0/(z*x)*l*B*(S*j*B+(M*m*B+Q*l*B));H=f+(h*104|0)+64|0;g[H>>2]=+g[H>>2]-1.0/(z*x)*j*B*(S*j*B+(M*m*B+Q*l*B));break b}else{g[e>>2]=m+ +g[e>>2];H=f+(h*104|0)+60|0;g[H>>2]=l+ +g[H>>2];H=f+(h*104|0)+64|0;g[H>>2]=j+ +g[H>>2];break b}}default:break b}p=P*s+R*t+T*v<0.0?-1.0:1.0;j=B*v*p+(u*s*p+A*t*p);l=+g[f+(h*104|0)+92>>2]*.5;m=(c[k>>2]=L,+g[k>>2]);w=j*o*.5*m*(P*P+R*R+T*T)*l;if(j>0.0&j<.9847999811172485){o=q*.5*m*U*l*+O(+(1.0-j*j));q=(B*(u*v*p-B*s*p)-A*(A*s*p-u*t*p))*o;r=(u*(A*s*p-u*t*p)-B*(B*t*p-A*v*p))*o;o=(A*(B*t*p-A*v*p)-u*(u*v*p-B*s*p))*o}else{q=0.0;r=0.0;o=0.0}j=z*x*-(B*w)*z*x*-(B*w)+(x*-(u*w)*z*x*-(u*w)*z+z*x*-(A*w)*z*x*-(A*w));if(j>0.0?j>=M*M+Q*Q+S*S:0){j=+O(+(M*M+Q*Q+S*S))/+O(+j)*.800000011920929;m=j*-(u*w);l=j*-(B*w);j=j*-(A*w)}else{m=-(u*w);l=-(B*w);j=-(A*w)}n=f+(h*104|0)+56|0;G=f+(h*104|0)+60|0;A=j+ +g[G>>2];H=f+(h*104|0)+64|0;B=l+ +g[H>>2];g[n>>2]=q+(m+ +g[n>>2]);g[G>>2]=r+A;g[H>>2]=o+B}while(0);if(E!=0.0){z=D*+g[f+(h*104|0)+92>>2];A=z*+g[f+(h*104|0)+76>>2];B=z*+g[f+(h*104|0)+80>>2];H=f+(h*104|0)+56|0;g[H>>2]=+g[f+(h*104|0)+72>>2]*z+ +g[H>>2];H=f+(h*104|0)+60|0;g[H>>2]=A+ +g[H>>2];H=f+(h*104|0)+64|0;g[H>>2]=B+ +g[H>>2]}if(F>0.0){z=C*+g[f+(h*104|0)+92>>2];A=z*+g[f+(h*104|0)+76>>2];B=z*+g[f+(h*104|0)+80>>2];H=f+(h*104|0)+56|0;g[H>>2]=+g[f+(h*104|0)+72>>2]*z+ +g[H>>2];H=f+(h*104|0)+60|0;g[H>>2]=A+ +g[H>>2];H=f+(h*104|0)+64|0;g[H>>2]=B+ +g[H>>2]}}h=h+1|0}while((h|0)!=(y|0))}while(0);G=c[I+752>>2]|0;if((G|0)>0){H=0;do{w=+g[I+452>>2];q=+g[I+304>>2];p=+g[I+300>>2];c:do if((q>0.0|p>0.0?(X=c[I+288>>2]|0,(X|0)>3):0)?(Y=c[I+760>>2]|0,Z=c[Y+(H*44|0)+8>>2]|0,n=c[Y+(H*44|0)+12>>2]|0,_=+g[Z+40>>2],$=+g[Z+44>>2],aa=+g[Z+48>>2],y=c[Y+(H*44|0)+16>>2]|0,ba=c[c[I+684>>2]>>2]|0,ca=(_+ +g[n+40>>2]+ +g[y+40>>2])*.3333333432674408-+g[I+1212>>2],da=($+ +g[n+44>>2]+ +g[y+44>>2])*.3333333432674408-+g[I+1216>>2],ea=(aa+ +g[n+48>>2]+ +g[y+48>>2])*.3333333432674408-+g[I+1220>>2],fa=+O(+(ca*ca+da*da+ea*ea)),ca*ca+da*da+ea*ea>1.1920928955078125e-07):0){s=ca*(1.0/fa);u=da*(1.0/fa);x=ea*(1.0/fa);r=+g[Y+(H*44|0)+20>>2];t=+g[Y+(H*44|0)+24>>2];v=+g[Y+(H*44|0)+28>>2];switch(X|0){case 5:break;case 4:case 6:{j=ca*r+da*t+ea*v<0.0?-1.0:1.0;if(!(ea*v*j+(ca*r*j+da*t*j)>0.0))break c;l=-((c[k>>2]=ba,+g[k>>2])*(ca*ca+da*da+ea*ea)*(ea*v*j+(ca*r*j+da*t*j))*+g[Y+(H*44|0)+36>>2]);s=(s*p*l+(r*j*q*l+0.0))*.3333333432674408;r=(u*p*l+(t*j*q*l+0.0))*.3333333432674408;l=(x*p*l+(v*j*q*l+0.0))*.3333333432674408;h=Z;m=_;o=$;p=aa;e=0;while(1){j=w*+g[h+88>>2];f=h+56|0;if(l*j*l*j+(s*j*s*j+r*j*r*j)>m*m+o*o+p*p){E=1.0/+O(+(l*l+(s*s+r*r)));F=p*l*E+(m*s*E+o*r*E);g[f>>2]=+g[f>>2]-1.0/j*s*E*F;y=h+60|0;g[y>>2]=+g[y>>2]-1.0/j*r*E*F;y=h+64|0;g[y>>2]=+g[y>>2]-1.0/j*l*E*F}else{g[f>>2]=s+ +g[f>>2];y=h+60|0;g[y>>2]=r+ +g[y>>2];y=h+64|0;g[y>>2]=l+ +g[y>>2]}e=e+1|0;if((e|0)==3)break c;y=c[Y+(H*44|0)+8+(e<<2)>>2]|0;h=y;m=+g[y+40>>2];o=+g[y+44>>2];p=+g[y+48>>2]}}default:break c}o=ca*r+da*t+ea*v<0.0?-1.0:1.0;j=x*v*o+(s*r*o+u*t*o);l=+g[Y+(H*44|0)+36>>2]*.5;m=(c[k>>2]=ba,+g[k>>2]);p=j*(ca*ca+da*da+ea*ea)*p*.5*m*l;if(j>0.0&j<.9847999811172485){F=fa*q*.5*m*l*+O(+(1.0-j*j));w=(x*(s*v*o-x*r*o)-u*(u*r*o-s*t*o))*F*.3333333432674408;z=(u*(x*t*o-u*v*o)-s*(s*v*o-x*r*o))*F*.3333333432674408;t=(s*(u*r*o-s*t*o)-x*(x*t*o-u*v*o))*F*.3333333432674408}else{w=0.0;z=0.0;t=0.0}h=(g[k>>2]=s*p*-.3333333432674408,c[k>>2]|0);n=(g[k>>2]=u*p*-.3333333432674408,c[k>>2]|0);y=Z;e=(g[k>>2]=x*p*-.3333333432674408,c[k>>2]|0);f=0;while(1){j=+g[y+88>>2];if(j>0.0){p=(c[k>>2]=h,+g[k>>2]);q=(c[k>>2]=n,+g[k>>2]);r=(c[k>>2]=e,+g[k>>2]);l=+g[I+452>>2];j=r*j*l*r*j*l+(p*j*l*p*j*l+q*j*l*q*j*l);l=+g[y+40>>2];m=+g[y+44>>2];o=+g[y+48>>2];if(j>0.0?j>=l*l+m*m+o*o:0){F=+O(+(l*l+m*m+o*o))/+O(+j)*.800000011920929;h=(g[k>>2]=p*F,c[k>>2]|0);n=(g[k>>2]=q*F,c[k>>2]|0);e=(g[k>>2]=r*F,c[k>>2]|0)}ia=y+56|0;D=(c[k>>2]=h,+g[k>>2])+ +g[ia>>2];ha=y+60|0;E=(c[k>>2]=n,+g[k>>2])+ +g[ha>>2];y=y+64|0;F=(c[k>>2]=e,+g[k>>2])+ +g[y>>2];g[ia>>2]=w+D;g[ha>>2]=t+E;g[y>>2]=z+F}f=f+1|0;if((f|0)==3)break c;y=c[Y+(H*44|0)+8+(f<<2)>>2]|0}}while(0);H=H+1|0}while((H|0)!=(G|0))}e=c[2357]|0;ia=(c[e+16>>2]|0)+-1|0;c[e+16>>2]=ia;do if(!ia){if(c[e+4>>2]|0){tb(ga+320|0,0)|0;ia=c[6434]|0;g[e+8>>2]=+g[e+8>>2]+ +(((c[ga+320+4>>2]|0)-(c[ia+4>>2]|0)+(((c[ga+320>>2]|0)-(c[ia>>2]|0)|0)*1e6|0)-(c[e+12>>2]|0)|0)>>>0)/1.0e3;if(c[e+16>>2]|0)break;e=c[2357]|0}c[2357]=c[e+20>>2]}while(0);e=c[I+712>>2]|0;if((e|0)>0){f=0;do{ha=c[I+720>>2]|0;ia=ha+(f*104|0)+24|0;H=ha+(f*104|0)+8|0;c[ia>>2]=c[H>>2];c[ia+4>>2]=c[H+4>>2];c[ia+8>>2]=c[H+8>>2];c[ia+12>>2]=c[H+12>>2];ia=ha+(f*104|0)+56|0;E=+g[ha+(f*104|0)+88>>2];F=+g[I+452>>2];C=+g[ia>>2]*E*F;D=E*+g[ha+(f*104|0)+60>>2]*F;E=F*E*+g[ha+(f*104|0)+64>>2];F=+g[(c[I+684>>2]|0)+12>>2]/F;C=C>F?F:C;D=D>F?F:D;E=E>F?F:E;G=ha+(f*104|0)+40|0;C=(C<-F?-F:C)+ +g[G>>2];g[G>>2]=C;G=ha+(f*104|0)+44|0;D=(D<-F?-F:D)+ +g[G>>2];g[G>>2]=D;G=ha+(f*104|0)+48|0;E=(E<-F?-F:E)+ +g[G>>2];g[G>>2]=E;F=+g[I+452>>2];g[H>>2]=C*F+ +g[H>>2];H=ha+(f*104|0)+12|0;g[H>>2]=F*D+ +g[H>>2];ha=ha+(f*104|0)+16|0;g[ha>>2]=E*F+ +g[ha>>2];c[ia>>2]=0;c[ia+4>>2]=0;c[ia+8>>2]=0;c[ia+12>>2]=0;f=f+1|0}while((f|0)!=(e|0))}$c(I);e=c[I+928>>2]|0;if(e){ia=c[I+192>>2]|0;D=+Sb[c[(c[ia>>2]|0)+48>>2]&15](ia);F=+g[e+4>>2]-D;E=+g[e+8>>2]-D;g[I+892>>2]=+g[e>>2]-D;g[I+896>>2]=F;g[I+900>>2]=E;g[I+904>>2]=0.0;E=D+ +g[e+20>>2];F=D+ +g[e+24>>2];g[I+908>>2]=D+ +g[e+16>>2];g[I+912>>2]=E;g[I+916>>2]=F;g[I+920>>2]=0.0;e=c[I+188>>2]|0;if(e|0){ia=c[I+684>>2]|0;ha=c[ia+32>>2]|0;yb[c[(c[ha>>2]|0)+16>>2]&31](ha,e,I+892|0,I+908|0,c[ia+36>>2]|0)}}else{c[I+892>>2]=0;c[I+892+4>>2]=0;c[I+892+8>>2]=0;c[I+892+12>>2]=0;c[I+892+16>>2]=0;c[I+892+20>>2]=0;c[I+892+24>>2]=0;c[I+892+28>>2]=0}e=c[I+712>>2]|0;if((e|0)>0){f=0;do{ha=c[I+720>>2]|0;E=+g[I+464>>2];C=+g[ha+(f*104|0)+8>>2];F=+g[ha+(f*104|0)+12>>2];D=+g[ha+(f*104|0)+16>>2];g[ga+192>>2]=C-E;g[ga+192+4>>2]=F-E;g[ga+192+8>>2]=D-E;g[ga+192+12>>2]=0.0;g[ga+192+16>>2]=E+C;g[ga+192+20>>2]=E+F;g[ga+192+24>>2]=E+D;g[ga+192+28>>2]=0.0;ia=c[ha+(f*104|0)+96>>2]|0;D=+g[I+460>>2];E=D*+g[ha+(f*104|0)+44>>2];F=D*+g[ha+(f*104|0)+48>>2];g[ga+176>>2]=+g[ha+(f*104|0)+40>>2]*D;g[ga+176+4>>2]=E;g[ga+176+8>>2]=F;g[ga+176+12>>2]=0.0;jh(I+928|0,ia,ga+192|0,ga+176|0,+g[I+468>>2])|0;f=f+1|0}while((f|0)!=(e|0))}if(c[I+988>>2]|0?(c[I+752>>2]|0)>0:0){e=0;do{ia=c[I+760>>2]|0;G=c[ia+(e*44|0)+8>>2]|0;H=c[ia+(e*44|0)+12>>2]|0;ha=c[ia+(e*44|0)+16>>2]|0;C=(+g[G+40>>2]+ +g[H+40>>2]+ +g[ha+40>>2])*.3333333432674408;D=(+g[G+44>>2]+ +g[H+44>>2]+ +g[ha+44>>2])*.3333333432674408;E=(+g[G+48>>2]+ +g[H+48>>2]+ +g[ha+48>>2])*.3333333432674408;x=+g[I+464>>2];u=+g[G+8>>2];w=+g[G+12>>2];A=+g[G+16>>2];F=+g[G+20>>2];B=+g[H+8>>2];p=B>2];q=z>2];r=v>2];s=t>2];v=+g[ha+12>>2];z=+g[ha+16>>2];B=+g[ha+20>>2];g[ga+192>>2]=(t>2]=(v>2]=(z>2]=B>2]=x+(u>2]=x+(w>2]=x+(A>2]=F>2]|0;F=+g[I+460>>2];g[ga+160>>2]=C*F;g[ga+160+4>>2]=D*F;g[ga+160+8>>2]=E*F;g[ga+160+12>>2]=0.0;jh(I+988|0,ia,ga+192|0,ga+160|0,+g[I+468>>2])|0;e=e+1|0}while((e|0)<(c[I+752>>2]|0))}do if(a[I+473>>0]|0){y=c[I+712>>2]|0;if((y|0)>0){e=c[I+720>>2]|0;f=c[I+512>>2]|0;j=0.0;l=0.0;m=0.0;h=0;do{F=+g[f+(h<<2)>>2];j=j+ +g[e+(h*104|0)+8>>2]*F;l=l+F*+g[e+(h*104|0)+12>>2];m=m+F*+g[e+(h*104|0)+16>>2];h=h+1|0}while((h|0)!=(y|0))}else{j=0.0;l=0.0;m=0.0}g[I+520>>2]=j;g[I+524>>2]=l;g[I+528>>2]=m;g[I+532>>2]=0.0;h=ga+320|0;n=h+48|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(n|0));g[ga+320>>2]=1.1920928955078125e-07;g[ga+320+20>>2]=2.384185791015625e-07;g[ga+320+40>>2]=3.5762786865234375e-07;if((y|0)>0){e=c[I+512>>2]|0;f=c[I+720>>2]|0;h=c[I+492>>2]|0;o=1.1920928955078125e-07;p=+g[ga+320+4>>2];q=+g[ga+320+8>>2];r=+g[ga+320+16>>2];s=2.384185791015625e-07;t=+g[ga+320+24>>2];u=0.0;v=0.0;w=3.5762786865234375e-07;n=0;do{E=+g[e+(n<<2)>>2];A=(+g[f+(n*104|0)+8>>2]-j)*E;B=(+g[f+(n*104|0)+12>>2]-l)*E;E=E*(+g[f+(n*104|0)+16>>2]-m);C=+g[h+(n<<4)>>2];D=+g[h+(n<<4)+4>>2];F=+g[h+(n<<4)+8>>2];o=A*C+o;p=A*D+p;q=A*F+q;r=B*C+r;s=B*D+s;t=B*F+t;u=E*C+u;v=E*D+v;w=E*F+w;n=n+1|0}while((n|0)!=(y|0));g[ga+320>>2]=o;g[ga+320+4>>2]=p;g[ga+320+8>>2]=q;g[ga+320+16>>2]=r;g[ga+320+20>>2]=s;g[ga+320+24>>2]=t;g[ga+320+32>>2]=u;g[ga+320+36>>2]=v;g[ga+320+40>>2]=w}if((a[22520]|0)==0?Wa(22520)|0:0){g[5787]=9.999999747378752e-05;c[5788]=16;_a(22520)}md(ga+320|0,ga+272|0,ga+224|0);c[I+536>>2]=c[ga+272>>2];c[I+536+4>>2]=c[ga+272+4>>2];c[I+536+8>>2]=c[ga+272+8>>2];c[I+536+12>>2]=c[ga+272+12>>2];c[I+552>>2]=c[V>>2];c[I+552+4>>2]=c[V+4>>2];c[I+552+8>>2]=c[V+8>>2];c[I+552+12>>2]=c[V+12>>2];c[I+568>>2]=c[W>>2];c[I+568+4>>2]=c[W+4>>2];c[I+568+8>>2]=c[W+8>>2];c[I+568+12>>2]=c[W+12>>2];la=+g[ga+272>>2];w=+g[V>>2];B=+g[W>>2];ka=+g[ga+272+4>>2];x=+g[ga+272+20>>2];D=+g[ga+272+36>>2];ja=+g[ga+272+8>>2];z=+g[ga+272+24>>2];F=+g[ga+272+40>>2];p=+g[I+632>>2];o=+g[I+636>>2];m=+g[I+640>>2];ra=+g[I+648>>2];qa=+g[I+652>>2];q=+g[I+656>>2];C=+g[I+664>>2];E=+g[I+668>>2];u=+g[I+672>>2];pa=+g[ga+320>>2];oa=+g[ga+320+16>>2];r=+g[ga+320+32>>2];j=(la*p+ka*o+ja*m)*pa+(w*p+x*o+z*m)*oa+(B*p+D*o+F*m)*r;na=+g[ga+320+4>>2];ma=+g[ga+320+20>>2];s=+g[ga+320+36>>2];l=(la*p+ka*o+ja*m)*na+(w*p+x*o+z*m)*ma+(B*p+D*o+F*m)*s;v=+g[ga+320+8>>2];A=+g[ga+320+24>>2];t=+g[ga+320+40>>2];m=(la*p+ka*o+ja*m)*v+(w*p+x*o+z*m)*A+(B*p+D*o+F*m)*t;o=(la*ra+ka*qa+ja*q)*pa+(w*ra+x*qa+z*q)*oa+(B*ra+D*qa+F*q)*r;p=(la*ra+ka*qa+ja*q)*na+(w*ra+x*qa+z*q)*ma+(B*ra+D*qa+F*q)*s;q=(la*ra+ka*qa+ja*q)*v+(w*ra+x*qa+z*q)*A+(B*ra+D*qa+F*q)*t;r=pa*(la*C+ka*E+ja*u)+oa*(w*C+x*E+z*u)+(B*C+D*E+F*u)*r;s=(la*C+ka*E+ja*u)*na+(w*C+x*E+z*u)*ma+(B*C+D*E+F*u)*s;t=(la*C+ka*E+ja*u)*v+(w*C+x*E+z*u)*A+(B*C+D*E+F*u)*t;g[I+584>>2]=j;g[I+588>>2]=l;g[I+592>>2]=m;g[I+596>>2]=0.0;g[I+600>>2]=o;g[I+604>>2]=p;g[I+608>>2]=q;g[I+612>>2]=0.0;g[I+616>>2]=r;g[I+620>>2]=s;g[I+624>>2]=t;g[I+628>>2]=0.0;u=+g[I+364>>2];if(u>1.0){ra=1.0/(m*(s*o-p*r)+(j*(p*t-q*s)+l*(q*r-t*o)))<1.0?1.0:u<1.0/(m*(s*o-p*r)+(j*(p*t-q*s)+l*(q*r-t*o)))?u:1.0/(m*(s*o-p*r)+(j*(p*t-q*s)+l*(q*r-t*o)));g[I+584>>2]=j*ra;g[I+588>>2]=l*ra;g[I+592>>2]=m*ra;g[I+596>>2]=0.0;g[I+600>>2]=o*ra;g[I+604>>2]=p*ra;g[I+608>>2]=q*ra;g[I+612>>2]=0.0;g[I+616>>2]=r*ra;g[I+620>>2]=s*ra;g[I+624>>2]=ra*t;g[I+628>>2]=0.0}if(a[I+473>>0]|0){if(!(+g[I+320>>2]>0.0))break;j=+g[I+536>>2];l=+g[I+540>>2];m=+g[I+544>>2];o=+g[I+552>>2];p=+g[I+556>>2];q=+g[I+560>>2];r=+g[I+568>>2];s=+g[I+572>>2];t=+g[I+576>>2];e=c[I+712>>2]|0;if((e|0)<=0)break;h=0;do{f=c[I+720>>2]|0;if(+g[f+(h*104|0)+88>>2]>0.0){H=c[I+492>>2]|0;ma=+g[H+(h<<4)>>2];na=+g[H+(h<<4)+4>>2];oa=+g[H+(h<<4)+8>>2];la=+g[I+320>>2];H=f+(h*104|0)+8|0;pa=+g[H>>2];ha=f+(h*104|0)+12|0;qa=+g[ha>>2];ia=f+(h*104|0)+16|0;ra=+g[ia>>2];qa=qa+la*(o*ma+p*na+q*oa+ +g[I+524>>2]-qa);ra=ra+la*(r*ma+s*na+t*oa+ +g[I+528>>2]-ra);g[H>>2]=pa+la*(+g[I+520>>2]+(j*ma+l*na+m*oa)-pa);g[ha>>2]=qa;g[ia>>2]=ra;g[f+(h*104|0)+20>>2]=0.0}h=h+1|0}while((h|0)!=(e|0))}}while(0);h=ga+56|0;n=h+104|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(n|0));e=c[I+812>>2]|0;if((e|0)<0){if((c[I+816>>2]|0)<0){f=c[I+820>>2]|0;if(f|0){if(a[I+824>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[I+820>>2]=0}a[I+824>>0]=1;c[I+820>>2]=0;c[I+816>>2]=0}do{ia=c[I+820>>2]|0;ha=ia+(e*104|0)|0;c[ha>>2]=c[ga+56>>2];c[ha+4>>2]=c[ga+56+4>>2];c[ha+8>>2]=c[ga+56+8>>2];c[ha+12>>2]=c[ga+56+12>>2];c[ha+16>>2]=c[ga+56+16>>2];c[ha+20>>2]=c[ga+56+20>>2];c[ha+24>>2]=c[ga+56+24>>2];ha=ia+(e*104|0)+28|0;c[ha>>2]=c[ga+56+28>>2];c[ha+4>>2]=c[ga+56+28+4>>2];c[ha+8>>2]=c[ga+56+28+8>>2];c[ha+12>>2]=c[ga+56+28+12>>2];ha=ia+(e*104|0)+44|0;c[ha>>2]=c[ga+56+44>>2];c[ha+4>>2]=c[ga+56+44+4>>2];c[ha+8>>2]=c[ga+56+44+8>>2];c[ha+12>>2]=c[ga+56+44+12>>2];ha=ia+(e*104|0)+60|0;c[ha>>2]=c[ga+56+60>>2];c[ha+4>>2]=c[ga+56+60+4>>2];c[ha+8>>2]=c[ga+56+60+8>>2];c[ha+12>>2]=c[ga+56+60+12>>2];ia=ia+(e*104|0)+76|0;c[ia>>2]=c[K>>2];c[ia+4>>2]=c[K+4>>2];c[ia+8>>2]=c[K+8>>2];c[ia+12>>2]=c[K+12>>2];c[ia+16>>2]=c[K+16>>2];c[ia+20>>2]=c[K+20>>2];c[ia+24>>2]=c[K+24>>2];e=e+1|0}while((e|0)!=0)}c[I+812>>2]=0;h=ga;n=h+56|0;do{c[h>>2]=0;h=h+4|0}while((h|0)<(n|0));e=c[I+832>>2]|0;if((e|0)<0){if((c[I+836>>2]|0)<0){f=c[I+840>>2]|0;if(f|0){if(a[I+844>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0)}c[I+840>>2]=0}a[I+844>>0]=1;c[I+840>>2]=0;c[I+836>>2]=0}do{h=(c[I+840>>2]|0)+(e*56|0)|0;f=ga;n=h+56|0;do{c[h>>2]=c[f>>2];h=h+4|0;f=f+4|0}while((h|0)<(n|0));e=e+1|0}while((e|0)!=0)}c[I+832>>2]=0;ig(I+928|0,1);ig(I+988|0,1);ig(I+1048|0,1);e=c[b+24>>2]|0}}J=J+1|0}while((J|0)<(e|0));i=ga;return} +function Wj(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;d=c[d>>2]|0;c[b+4>>2]=d;c[b>>2]=3640;a[b+8>>0]=g&1;c[b+12>>2]=3668;c[b+60>>2]=d;c[b+64>>2]=0;a[b+88>>0]=1;c[b+84>>2]=0;c[b+76>>2]=0;c[b+80>>2]=0;a[b+108>>0]=1;c[b+104>>2]=0;c[b+96>>2]=0;c[b+100>>2]=0;a[b+128>>0]=1;c[b+124>>2]=0;c[b+116>>2]=0;c[b+120>>2]=0;a[b+148>>0]=1;c[b+144>>2]=0;c[b+136>>2]=0;c[b+140>>2]=0;if(g){c[b+16>>2]=c[f+8>>2];d=e;d=d+8|0;d=c[d>>2]|0;g=b+20|0;c[g>>2]=d;cg(b+12|0);return}else{c[b+16>>2]=c[e+8>>2];d=f;d=d+8|0;d=c[d>>2]|0;g=b+20|0;c[g>>2]=d;cg(b+12|0);return}}function Xj(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;n=+g[a+4>>2];h=+g[a+396>>2];m=+g[a+8>>2];e=+g[a+400>>2];l=+g[a+12>>2];c=+g[a+404>>2];k=+g[a+20>>2];j=+g[a+24>>2];i=+g[a+28>>2];f=+g[a+36>>2];d=+g[a+40>>2];b=+g[a+44>>2];g[a+264>>2]=n*h*n+m*e*m+l*c*l;g[a+268>>2]=n*h*k+m*e*j+l*c*i;g[a+272>>2]=n*h*f+m*e*d+l*c*b;g[a+276>>2]=0.0;g[a+280>>2]=h*k*n+e*j*m+c*i*l;g[a+284>>2]=h*k*k+e*j*j+c*i*i;g[a+288>>2]=h*k*f+e*j*d+c*i*b;g[a+292>>2]=0.0;g[a+296>>2]=h*f*n+e*d*m+c*b*l;g[a+300>>2]=h*f*k+e*d*j+c*b*i;g[a+304>>2]=h*f*f+e*d*d+c*b*b;g[a+308>>2]=0.0;return}function Yj(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0;if(a[b+738>>0]|0){c[d>>2]=0;c[d+4>>2]=0;return}c[d>>2]=5;c[d+4>>2]=1;e=+kj(b,(c[b+28>>2]|0)+4|0,(c[b+32>>2]|0)+4|0);g[b+728>>2]=e;g[b+708>>2]=0.0;g[b+712>>2]=0.0;a[b+716>>0]=0;f=+g[b+692>>2];do if(f>=0.0){e=+eh(e-+g[b+688>>2],6.2831854820251465);if(!(e<-3.1415927410125732)){if(e>3.1415927410125732)e=e+-6.2831854820251465}else e=e+6.2831854820251465;if(e<-f){a[b+716>>0]=1;g[b+708>>2]=-(e+f);g[b+712>>2]=1.0;break}if(e>f){a[b+716>>0]=1;g[b+708>>2]=f-e;g[b+712>>2]=-1.0}else h=12}else h=12;while(0);if((h|0)==12?(a[b+737>>0]|0)==0:0)return;c[d>>2]=6;c[d+4>>2]=0;return}function Zj(b,d,e){b=b|0;d=d|0;e=+e;var f=0,h=0;c[6435]=(c[6435]|0)+1;f=yc(203)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}c[f>>2]=4872;h=f+60|0;a[f+144>>0]=1;c[f+140>>2]=0;c[f+132>>2]=0;c[f+136>>2]=0;c[f+176>>2]=1;g[f+56>>2]=.019999999552965164;c[h>>2]=0;c[h+4>>2]=0;c[h+8>>2]=0;c[h+12>>2]=0;a[f+170>>0]=1;c[f+8>>2]=b;g[f+52>>2]=e;g[f+48>>2]=0.0;c[f+12>>2]=d;a[f+171>>0]=1;g[f+172>>2]=0.0;g[f+16>>2]=0.0;g[f+20>>2]=0.0;g[f+44>>2]=29.399999618530273;g[f+24>>2]=55.0;g[f+28>>2]=10.0;a[f+168>>0]=0;a[f+169>>0]=0;a[f+180>>0]=1;g[f+36>>2]=.7853981852531433;g[f+40>>2]=.7071067690849304;g[f+108>>2]=0.0;a[f+181>>0]=0;a[f+182>>0]=0;return f|0}function _j(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;c[b>>2]=5632;e=c[b+8>>2]|0;d=c[b+16>>2]|0;if((e|0)>0){h=0;do{f=(c[d+(h<<2)>>2]|0)+188|0;g=c[f>>2]|0;if(g){e=c[b+68>>2]|0;e=Eb[c[(c[e>>2]|0)+36>>2]&127](e)|0;ic[c[(c[e>>2]|0)+40>>2]&127](e,g,c[b+24>>2]|0);e=c[b+68>>2]|0;ic[c[(c[e>>2]|0)+12>>2]&127](e,g,c[b+24>>2]|0);c[f>>2]=0;e=c[b+8>>2]|0;d=c[b+16>>2]|0}h=h+1|0}while((h|0)<(e|0))}if(!d){a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}function $j(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0,h=0,i=0.0,j=0.0;c[a+248>>2]=c[b>>2];c[a+248+4>>2]=c[b+4>>2];c[a+248+8>>2]=c[b+8>>2];c[a+248+12>>2]=c[b+12>>2];d=c[a+232>>2]|0;if((d|0)<=0)return;h=0;do{f=c[(c[a+240>>2]|0)+(h<<2)>>2]|0;switch(c[f+216>>2]|0){case 2:case 5:break;default:if(!(c[f+504>>2]&1)){e=+g[f+344>>2];if(e!=0.0){j=1.0/e*+g[b+4>>2];i=1.0/e*+g[b+8>>2];g[f+364>>2]=1.0/e*+g[b>>2];g[f+368>>2]=j;g[f+372>>2]=i;g[f+376>>2]=0.0}c[f+380>>2]=c[b>>2];c[f+380+4>>2]=c[b+4>>2];c[f+380+8>>2]=c[b+8>>2];c[f+380+12>>2]=c[b+12>>2];d=c[a+232>>2]|0}}h=h+1|0}while((h|0)<(d|0));return}function ak(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0;c[6435]=(c[6435]|0)+1;h=yc(379)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}c[h+4>>2]=3;c[h+8>>2]=-1;c[h+12>>2]=-1;g[h+16>>2]=3402823466385288598117041.0e14;a[h+20>>0]=1;a[h+21>>0]=0;c[h+24>>2]=-1;c[h+28>>2]=b;c[h+32>>2]=d;g[h+36>>2]=0.0;g[h+40>>2]=.30000001192092896;c[h+44>>2]=0;c[h>>2]=4544;d=h+300|0;c[d>>2]=c[e>>2];c[d+4>>2]=c[e+4>>2];c[d+8>>2]=c[e+8>>2];c[d+12>>2]=c[e+12>>2];e=h+316|0;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];c[h+332>>2]=0;a[h+344>>0]=0;g[h+348>>2]=.30000001192092896;g[h+352>>2]=1.0;g[h+356>>2]=0.0;return h|0}function bk(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0,h=0;f=i;i=i+496|0;e=c[b+212>>2]|0;if((e|0)>-1){a=e;i=f;return a|0}h=(c[b+236>>2]&2|0)==0;e=h?0:b;do if(!h){if(!(+g[e+344>>2]!=0.0)?(c[e+204>>2]&2|0)==0:0)break;h=c[a+8>>2]|0;Qn(f+244|0,0,244)|0;Me(Ff(a+4|0,f+244|0)|0,b,d);c[b+212>>2]=h;i=f;return h|0}while(0);e=c[a+188>>2]|0;if((e|0)>=0){h=e;i=f;return h|0}c[a+188>>2]=c[a+8>>2];Qn(f|0,0,244)|0;Me(Ff(a+4|0,f)|0,0,d);h=c[a+188>>2]|0;i=f;return h|0}function ck(a,b,d){a=a|0;b=+b;d=d|0;var e=0,f=0,h=0.0,i=0.0,j=0.0;e=c[a+204>>2]|0;if(b==0.0){c[a+204>>2]=e|1;h=0.0}else{c[a+204>>2]=e&-2;h=1.0/b}g[a+344>>2]=h;j=+g[a+384>>2]*b;i=+g[a+388>>2]*b;g[a+364>>2]=+g[a+380>>2]*b;g[a+368>>2]=j;g[a+372>>2]=i;g[a+376>>2]=0.0;b=+g[d>>2];f=b!=0.0?(g[k>>2]=1.0/b,c[k>>2]|0):0;b=+g[d+4>>2];e=b!=0.0?(g[k>>2]=1.0/b,c[k>>2]|0):0;b=+g[d+8>>2];d=b!=0.0?(g[k>>2]=1.0/b,c[k>>2]|0):0;c[a+396>>2]=f;c[a+400>>2]=e;c[a+404>>2]=d;g[a+408>>2]=0.0;i=h*+g[a+352>>2];j=h*+g[a+356>>2];g[a+560>>2]=+g[a+348>>2]*h;g[a+564>>2]=i;g[a+568>>2]=j;g[a+572>>2]=0.0;return}function dk(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0;c[6435]=(c[6435]|0)+1;i=yc(1407)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}Le(i,b,d,e,f,h);c[i>>2]=4484;c[i+4>>2]=9;a[i+1309>>0]=0;g[i+1316>>2]=0.0;g[i+1340>>2]=0.0;g[i+1364>>2]=1.0;a[i+1310>>0]=0;g[i+1320>>2]=0.0;g[i+1344>>2]=0.0;g[i+1368>>2]=1.0;a[i+1311>>0]=0;g[i+1324>>2]=0.0;g[i+1348>>2]=0.0;g[i+1372>>2]=1.0;a[i+1312>>0]=0;g[i+1328>>2]=0.0;g[i+1352>>2]=0.0;g[i+1376>>2]=1.0;a[i+1313>>0]=0;g[i+1332>>2]=0.0;g[i+1356>>2]=0.0;g[i+1380>>2]=1.0;a[i+1314>>0]=0;g[i+1336>>2]=0.0;g[i+1360>>2]=0.0;g[i+1384>>2]=1.0;return i|0}function ek(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=c[b+280>>2]|0;if((e|0)==(c[b+284>>2]|0)?(h=e|0?e<<1:1,(e|0)<(h|0)):0){if(!h)g=0;else{c[6435]=(c[6435]|0)+1;e=yc((h<<2|3)+16|0)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}g=e;e=c[b+280>>2]|0}if((e|0)>0){f=0;do{c[g+(f<<2)>>2]=c[(c[b+288>>2]|0)+(f<<2)>>2];f=f+1|0}while((f|0)!=(e|0))}f=c[b+288>>2]|0;if(f){if(a[b+292>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[f+-4>>2]|0);e=c[b+280>>2]|0}c[b+288>>2]=0}a[b+292>>0]=1;c[b+288>>2]=g;c[b+284>>2]=h}c[(c[b+288>>2]|0)+(e<<2)>>2]=d;c[b+280>>2]=e+1;return}function fk(a,b,d){a=a|0;b=+b;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0;e=i;i=i+96|0;c[e+32>>2]=1065353216;c[e+32+4>>2]=0;c[e+32+4+4>>2]=0;c[e+32+4+8>>2]=0;c[e+32+4+12>>2]=0;c[e+32+20>>2]=1065353216;c[e+32+24>>2]=0;c[e+32+24+4>>2]=0;c[e+32+24+8>>2]=0;c[e+32+24+12>>2]=0;c[e+32+40>>2]=1065353216;k=e+32+44|0;c[k>>2]=0;c[k+4>>2]=0;c[k+8>>2]=0;c[k+12>>2]=0;c[k+16>>2]=0;mc[c[(c[a>>2]|0)+8>>2]&127](a,e+32|0,e+16|0,e);h=(+g[e>>2]-+g[e+16>>2])*.5*2.0;f=(+g[e+4>>2]-+g[e+16+4>>2])*.5*2.0;j=(+g[e+8>>2]-+g[e+16+8>>2])*.5*2.0;g[d>>2]=b/12.0*(f*f+j*j);g[d+4>>2]=b/12.0*(h*h+j*j);g[d+8>>2]=b/12.0*(h*h+f*f);i=e;return}function gk(){var a=0,b=0,d=0,e=0;e=i;i=i+48|0;if(kb(26248,3)|0)ej(21924,e);a=hb(c[6563]|0)|0;if(a|0?(d=c[a>>2]|0,d|0):0){a=c[d+48>>2]|0;b=c[d+48+4>>2]|0;if(!((a&-256|0)==1126902528&(b|0)==1129074247)){c[e+32>>2]=22103;ej(22198,e+32|0)}if((a|0)==1126902529&(b|0)==1129074247)a=c[d+44>>2]|0;else a=d+80|0;c[e+44>>2]=a;d=c[d>>2]|0;a=c[d+4>>2]|0;if(Ql(2736,d,e+44|0)|0){d=c[e+44>>2]|0;d=Eb[c[(c[d>>2]|0)+8>>2]&127](d)|0;c[e+8>>2]=22103;c[e+8+4>>2]=a;c[e+8+8>>2]=d;ej(22112,e+8|0)}else{c[e+24>>2]=22103;c[e+24+4>>2]=a;ej(22157,e+24|0)}}ej(22236,e+40|0)}function hk(b){b=b|0;var d=0,e=0,f=0;while(1){f=yc(5260)|0;if(f|0)break;d=c[6564]|0;c[6564]=d+0;if(!d){e=5;break}jc[d&3]()}if((e|0)==5){f=Ya(4)|0;c[f>>2]=9640;pb(f|0,2800,251)}c[f>>2]=5132;c[f+4>>2]=2;a[f+24>>0]=1;c[f+20>>2]=0;c[f+12>>2]=0;c[f+16>>2]=0;c[f+28>>2]=5604;c[f+5256>>2]=b;c[f+60>>2]=79;c[f+64>>2]=Eb[c[(c[b>>2]|0)+12>>2]&127](b)|0;c[f+68>>2]=Eb[c[(c[b>>2]|0)+8>>2]&127](b)|0;d=0;do{b=0;do{e=c[f+5256>>2]|0;c[f+72+(d*144|0)+(b<<2)>>2]=Ob[c[(c[e>>2]|0)+16>>2]&63](e,d,b)|0;b=b+1|0}while((b|0)<36);d=d+1|0}while((d|0)<36);return f|0}function ik(a,b,c){a=+a;b=+b;c=+c;var d=0.0,e=0.0,f=0;if(b>=c)return +a;if(a3.1415927410125732)d=d+-6.2831854820251465}else d=d+6.2831854820251465;e=+N(+d);d=+eh(c-a,6.2831854820251465);if(!(d<-3.1415927410125732)){if(d>3.1415927410125732)d=d+-6.2831854820251465}else d=d+6.2831854820251465;f=e<+N(+d);a=f?a:a+6.2831854820251465;return +a}if(!(a>c))return +a;d=+eh(a-c,6.2831854820251465);if(!(d<-3.1415927410125732)){if(d>3.1415927410125732)d=d+-6.2831854820251465}else d=d+6.2831854820251465;e=+N(+d);d=+eh(a-b,6.2831854820251465);if(!(d<-3.1415927410125732)){if(d>3.1415927410125732)d=d+-6.2831854820251465}else d=d+6.2831854820251465;f=+N(+d)>2]|0)+68>>2]&127](e,b,d);c[a>>2]=c[e>>2];c[a+4>>2]=c[e+4>>2];c[a+8>>2]=c[e+8>>2];c[a+12>>2]=c[e+12>>2];if(!(+Sb[c[(c[b>>2]|0)+48>>2]&15](b)!=0.0)){i=e;return}j=+g[d>>2];h=+g[d+4>>2];f=+g[d+8>>2];l=j*j+h*h+f*f<1.4210854715202004e-14?-1.0:j;k=j*j+h*h+f*f<1.4210854715202004e-14?-1.0:h;f=j*j+h*h+f*f<1.4210854715202004e-14?-1.0:f;h=1.0/+O(+(f*f+(l*l+k*k)));j=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);g[a>>2]=+g[a>>2]+j*h*l;g[a+4>>2]=j*h*k+ +g[a+4>>2];g[a+8>>2]=j*h*f+ +g[a+8>>2];i=e;return}function kk(a,b,d){a=a|0;b=+b;d=+d;var e=0.0,f=0.0,h=0.0;f=+g[a+692>>2];do if(f>0.0){h=+g[a+688>>2];e=+eh(b-h,6.2831854820251465);if(!(e<-3.1415927410125732)){if(e>3.1415927410125732)e=e+-6.2831854820251465}else e=e+6.2831854820251465;if(!(!(e<-f)&e<=f))if(e>0.0){b=+eh(f+h,6.2831854820251465);if(b<-3.1415927410125732){b=b+6.2831854820251465;break}if(!(b>3.1415927410125732))break;b=b+-6.2831854820251465;break}else{b=+eh(h-f,6.2831854820251465);if(b<-3.1415927410125732){b=b+6.2831854820251465;break}if(!(b>3.1415927410125732))break;b=b+-6.2831854820251465;break}}while(0);g[a+680>>2]=(b-+kj(a,(c[a+28>>2]|0)+4|0,(c[a+32>>2]|0)+4|0))/d;return}function lk(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0,h=0.0,i=0,j=0.0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0;k=c[b+96>>2]|0;if((k|0)<=0){c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;return}o=+g[b+12>>2];p=+g[d>>2]*o;l=+g[b+16>>2];m=+g[d+4>>2]*l;n=+g[b+20>>2];j=+g[d+8>>2]*n;d=c[b+104>>2]|0;f=0;h=-3402823466385288598117041.0e14;i=-1;while(1){e=p*+g[d+(f<<4)>>2]+m*+g[d+(f<<4)+4>>2]+j*+g[d+(f<<4)+8>>2];b=e>h;i=b?f:i;f=f+1|0;if((f|0)==(k|0))break;else h=b?e:h}m=+g[d+(i<<4)+4>>2]*l;p=+g[d+(i<<4)+8>>2]*n;g[a>>2]=+g[d+(i<<4)>>2]*o;g[a+4>>2]=m;g[a+8>>2]=p;g[a+12>>2]=0.0;return}function mk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;a:do switch(b|0){case 2:{if((c|0)<1){d=+g[a+232>>2];break a}if((c|0)<3){d=+g[a+264>>2];break a}if((c|0)==3){d=+g[a+248>>2];break a}if((c|0)<6)d=+g[a+280>>2];else d=3402823466385288598117041.0e14;break}case 3:{if((c|0)<1){d=+g[a+212>>2];break a}if((c|0)==3)d=+g[a+228>>2];else d=3402823466385288598117041.0e14;break}case 4:{if((c|0)<1){d=+g[a+244>>2];break a}if((c|0)<3){d=+g[a+276>>2];break a}if((c|0)==3){d=+g[a+260>>2];break a}if((c|0)<6)d=+g[a+292>>2];else d=3402823466385288598117041.0e14;break}default:d=3402823466385288598117041.0e14}while(0);return +d}function nk(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;a:do if((b|0)==(c[d+8>>2]|0)){g=c[d+16>>2]|0;if(!g){c[d+16>>2]=e;c[d+24>>2]=f;c[d+36>>2]=1;break}if((g|0)!=(e|0)){c[d+36>>2]=(c[d+36>>2]|0)+1;c[d+24>>2]=2;a[d+54>>0]=1;break}if((c[d+24>>2]|0)==2)c[d+24>>2]=f}else{g=c[b+12>>2]|0;no(b+16|0,d,e,f);if((g|0)>1){h=b+24|0;do{no(h,d,e,f);if(a[d+54>>0]|0)break a;h=h+8|0}while(h>>>0<(b+16+(g<<3)|0)>>>0)}}while(0);return}function ok(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;c[6166]=(c[6166]|0)+1;e=(c[b+12>>2]|0)>(c[d+12>>2]|0);f=c[(e?d:b)+12>>2]|0;e=c[(e?b:d)+12>>2]|0;b=((e<<16|f)+~((e<<16|f)<<15)>>10^(e<<16|f)+~((e<<16|f)<<15))*9|0;b=((b>>6^b)+~((b>>6^b)<<11)>>16^(b>>6^b)+~((b>>6^b)<<11))&(c[a+12>>2]|0)+-1;if((b|0)>=(c[a+36>>2]|0)){g=0;return g|0}b=c[(c[a+44>>2]|0)+(b<<2)>>2]|0;if((b|0)==-1){g=0;return g|0}d=c[a+16>>2]|0;while(1){if((c[(c[d+(b<<4)>>2]|0)+12>>2]|0)==(f|0)?(c[(c[d+(b<<4)+4>>2]|0)+12>>2]|0)==(e|0):0)break;b=c[(c[a+64>>2]|0)+(b<<2)>>2]|0;if((b|0)==-1){b=0;g=8;break}}if((g|0)==8)return b|0;g=d+(b<<4)|0;return g|0}function pk(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;c[6435]=(c[6435]|0)+1;f=yc(1407)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}qe(f,b,d,e);c[f>>2]=4484;c[f+4>>2]=9;a[f+1309>>0]=0;g[f+1316>>2]=0.0;g[f+1340>>2]=0.0;g[f+1364>>2]=1.0;a[f+1310>>0]=0;g[f+1320>>2]=0.0;g[f+1344>>2]=0.0;g[f+1368>>2]=1.0;a[f+1311>>0]=0;g[f+1324>>2]=0.0;g[f+1348>>2]=0.0;g[f+1372>>2]=1.0;a[f+1312>>0]=0;g[f+1328>>2]=0.0;g[f+1352>>2]=0.0;g[f+1376>>2]=1.0;a[f+1313>>0]=0;g[f+1332>>2]=0.0;g[f+1356>>2]=0.0;g[f+1380>>2]=1.0;a[f+1314>>0]=0;g[f+1336>>2]=0.0;g[f+1360>>2]=0.0;g[f+1384>>2]=1.0;return f|0}function qk(b){b=b|0;var d=0;c[b>>2]=3872;if(a[b+456>>0]|0?(d=c[b+452>>2]|0,Ab[c[c[d>>2]>>2]&255](d),d=c[b+452>>2]|0,d|0):0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}d=c[b+420>>2]|0;if(d|0){if(a[b+424>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+420>>2]=0}a[b+424>>0]=1;c[b+420>>2]=0;c[b+412>>2]=0;c[b+416>>2]=0;d=c[b+336>>2]|0;if(!d){a[b+340>>0]=1;c[b+336>>2]=0;c[b+328>>2]=0;d=b+332|0;c[d>>2]=0;Sg(b);return}if(a[b+340>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+336>>2]=0;a[b+340>>0]=1;c[b+336>>2]=0;c[b+328>>2]=0;d=b+332|0;c[d>>2]=0;Sg(b);return}function rk(a,b){a=a|0;b=+b;var d=0,e=0,f=0;e=i;i=i+16|0;li(12327);if((c[a+280>>2]|0)>0){d=0;do{f=c[(c[a+288>>2]|0)+(d<<2)>>2]|0;kc[c[(c[f>>2]|0)+8>>2]&7](f,a,b);d=d+1|0}while((d|0)<(c[a+280>>2]|0))}d=c[2357]|0;f=(c[d+16>>2]|0)+-1|0;c[d+16>>2]=f;if(f|0){i=e;return}do if(c[d+4>>2]|0){tb(e|0,0)|0;f=c[6434]|0;g[d+8>>2]=+g[d+8>>2]+ +(((c[e+4>>2]|0)-(c[f+4>>2]|0)+(((c[e>>2]|0)-(c[f>>2]|0)|0)*1e6|0)-(c[d+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[d+16>>2]|0)){d=c[2357]|0;break}else{i=e;return}}while(0);c[2357]=c[d+20>>2];i=e;return}function sk(a,b,d){a=a|0;b=b|0;d=d|0;do if(!((b|0)==8&(d|0)==8)){if((b|0)==8&(d|0)==1){b=a+76|0;break}if((b|0)==1&(d|0)==8){b=a+80|0;break}if(!(d|b)){b=a+72|0;break}if((b|0)<20&(d|0)==28){b=a+88|0;break}if((b|0)==28&(d|0)<20){b=a+84|0;break}if((b|0)<20){if((d|0)<20){b=a+32|0;break}if((d+-21|0)>>>0<9){b=a+36|0;break}}else{if((d|0)<20&(b+-21|0)>>>0<9){b=a+40|0;break}if((b|0)==31)if((d|0)==31){b=a+48|0;break}else{b=a+44|0;break}}if((d|0)==31){b=a+52|0;break}else{b=a+56|0;break}}else b=a+60|0;while(0);return c[b>>2]|0}function tk(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0;f=+g[a+28>>2];h=+g[a+32>>2];e=+g[a+36>>2];switch(d|0){case 0:{c[b>>2]=1065353216;c[b+4>>2]=0;c[b+8>>2]=0;g[b+12>>2]=-f;return}case 1:{c[b>>2]=-1082130432;c[b+4>>2]=0;c[b+8>>2]=0;g[b+12>>2]=-f;return}case 2:{c[b>>2]=0;c[b+4>>2]=1065353216;c[b+8>>2]=0;g[b+12>>2]=-h;return}case 3:{c[b>>2]=0;c[b+4>>2]=-1082130432;c[b+8>>2]=0;g[b+12>>2]=-h;return}case 4:{c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=1065353216;g[b+12>>2]=-e;return}case 5:{c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=-1082130432;g[b+12>>2]=-e;return}default:return}}function uk(a,b,d,e,f){a=a|0;b=b|0;d=+d;e=e|0;f=f|0;var h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;h=i;i=i+48|0;c[h+32>>2]=e;c[h+32+4>>2]=f;n=+g[b>>2];m=+g[b+4>>2];j=+g[b+8>>2];l=+g[a+56>>2]*n+ +g[a+60>>2]*m+ +g[a+64>>2]*j;k=n*+g[a+72>>2]+m*+g[a+76>>2]+j*+g[a+80>>2];j=n*+g[a+88>>2]+m*+g[a+92>>2]+j*+g[a+96>>2];c[h>>2]=c[a+48>>2];c[h+4>>2]=h+32;g[h+8>>2]=l;g[h+12>>2]=k;g[h+16>>2]=j;g[h+20>>2]=0.0;g[h+24>>2]=d;f=c[a+44>>2]|0;d=+_b[c[(c[f>>2]|0)+12>>2]&15](f,h,1);i=h;return +d}function vk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,j=0.0,l=0.0,m=0,n=0;f=i;i=i+48|0;ic[c[(c[a>>2]|0)+124>>2]&127](a,f+32|0,e);n=c[f+32>>2]|0;m=c[f+32+4>>2]|0;e=c[f+32+8>>2]|0;c[b>>2]=n;c[b+4>>2]=m;c[b+8>>2]=e;g[b+12>>2]=0.0;b=c[(c[a>>2]|0)+64>>2]|0;l=-(c[k>>2]=n,+g[k>>2]);j=-(c[k>>2]=m,+g[k>>2]);h=-(c[k>>2]=e,+g[k>>2]);g[f>>2]=l;g[f+4>>2]=j;g[f+8>>2]=h;g[f+12>>2]=0.0;ic[b&127](f+16|0,a,f);c[d>>2]=c[f+16>>2];c[d+4>>2]=c[f+16+4>>2];c[d+8>>2]=c[f+16+8>>2];c[d+12>>2]=c[f+16+12>>2];i=f;return}function wk(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;if(e>>>0<3)switch(b|0){case 2:{g[a+756+(e<<2)>>2]=d;c[a+1304>>2]=c[a+1304>>2]|4<>2]=d;c[a+1304>>2]=c[a+1304>>2]|2<>2]=d;c[a+1304>>2]=c[a+1304>>2]|1<>>0>=3)return;switch(b|0){case 2:{g[a+868+(e+-3<<6)+32>>2]=d;c[a+1304>>2]=c[a+1304>>2]|4<>2]=d;c[a+1304>>2]=c[a+1304>>2]|2<>2]=d;c[a+1304>>2]=c[a+1304>>2]|1<>2]=4356;d=c[b+80>>2]|0;if(d|0){if(a[b+84>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+80>>2]=0}a[b+84>>0]=1;c[b+80>>2]=0;c[b+72>>2]=0;c[b+76>>2]=0;d=c[b+60>>2]|0;if(d|0){if(a[b+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+60>>2]=0}a[b+64>>0]=1;c[b+60>>2]=0;c[b+52>>2]=0;c[b+56>>2]=0;d=c[b+40>>2]|0;if(!d){a[b+44>>0]=1;c[b+40>>2]=0;c[b+32>>2]=0;b=b+36|0;c[b>>2]=0;return}if(a[b+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+40>>2]=0;a[b+44>>0]=1;c[b+40>>2]=0;c[b+32>>2]=0;b=b+36|0;c[b>>2]=0;return}function yk(b){b=b|0;var d=0;c[b>>2]=8724;d=c[b+64>>2]|0;if(d|0){if(a[b+68>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+64>>2]=0}a[b+68>>0]=1;c[b+64>>2]=0;c[b+56>>2]=0;c[b+60>>2]=0;d=c[b+44>>2]|0;if(d|0){if(a[b+48>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+44>>2]=0}a[b+48>>0]=1;c[b+44>>2]=0;c[b+36>>2]=0;c[b+40>>2]=0;d=c[b+16>>2]|0;if(!d){a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}function zk(b){b=b|0;var d=0;c[b>>2]=5456;d=c[b+56>>2]|0;if(d|0){if(a[b+60>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+56>>2]=0}a[b+60>>0]=1;c[b+56>>2]=0;c[b+48>>2]=0;c[b+52>>2]=0;d=c[b+36>>2]|0;if(d|0){if(a[b+40>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+36>>2]=0}a[b+40>>0]=1;c[b+36>>2]=0;c[b+28>>2]=0;c[b+32>>2]=0;d=c[b+16>>2]|0;if(!d){d=b+12|0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[d>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;d=b+12|0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[d>>2]=0;return}function Ak(b){b=b|0;var d=0;c[b>>2]=9324;d=c[b+60>>2]|0;if(d|0){if(a[b+64>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+60>>2]=0}a[b+64>>0]=1;c[b+60>>2]=0;c[b+52>>2]=0;c[b+56>>2]=0;d=c[b+40>>2]|0;if(d|0){if(a[b+44>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+40>>2]=0}a[b+44>>0]=1;c[b+40>>2]=0;c[b+32>>2]=0;c[b+36>>2]=0;d=c[b+16>>2]|0;if(!d){a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0;a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;b=b+12|0;c[b>>2]=0;return}function Bk(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;h=h|0;var j=0;j=i;i=i+64|0;c[j+48>>2]=f;c[j+48+4>>2]=h;f=c[a+212>>2]|0;if(!(+g[f+4>>2]>=e)){i=j;return +e}c[j>>2]=c[a+216>>2];c[j+4>>2]=j+48;c[j+8>>2]=c[b>>2];c[j+8+4>>2]=c[b+4>>2];c[j+8+8>>2]=c[b+8>>2];c[j+8+12>>2]=c[b+12>>2];c[j+24>>2]=c[d>>2];c[j+24+4>>2]=c[d+4>>2];c[j+24+8>>2]=c[d+8>>2];c[j+24+12>>2]=c[d+12>>2];g[j+40>>2]=e;e=+_b[c[(c[f>>2]|0)+12>>2]&15](f,j,0);i=j;return +e}function Ck(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;h=h|0;var j=0;j=i;i=i+64|0;c[j+48>>2]=f;c[j+48+4>>2]=h;f=c[a+212>>2]|0;if(!(+g[f+4>>2]>=e)){i=j;return +e}c[j>>2]=c[a+216>>2];c[j+4>>2]=j+48;c[j+8>>2]=c[b>>2];c[j+8+4>>2]=c[b+4>>2];c[j+8+8>>2]=c[b+8>>2];c[j+8+12>>2]=c[b+12>>2];c[j+24>>2]=c[d>>2];c[j+24+4>>2]=c[d+4>>2];c[j+24+8>>2]=c[d+8>>2];c[j+24+12>>2]=c[d+12>>2];g[j+40>>2]=e;e=+_b[c[(c[f>>2]|0)+12>>2]&15](f,j,1);i=j;return +e}function Dk(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0,l=0;h=+g[b+60>>2]*.5;l=c[b+68>>2]|0;e=+g[d>>2];f=+g[d+4>>2];j=+g[d+8>>2];j=+O(+(e*e+f*f+j*j));i=c[b+64>>2]|0;if(+g[d+(l<<2)>>2]>j*+g[b+52>>2]){g[a+(i<<2)>>2]=0.0;g[a+(l<<2)>>2]=h;g[a+(c[b+72>>2]<<2)>>2]=0.0;return}j=+g[d+(i<<2)>>2];k=c[b+72>>2]|0;e=+g[d+(k<<2)>>2];f=+O(+(j*j+e*e));if(f>1.1920928955078125e-07){f=+g[b+56>>2]/f;g[a+(i<<2)>>2]=j*f;g[a+(l<<2)>>2]=-h;g[a+(k<<2)>>2]=e*f;return}else{g[a+(i<<2)>>2]=0.0;g[a+(l<<2)>>2]=-h;g[a+(k<<2)>>2]=0.0;return}}function Ek(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=c[e+16>>2]|0;if(!f){if(!(Fo(e)|0)){g=c[e+16>>2]|0;h=5}}else{g=f;h=5}a:do if((h|0)==5){f=c[e+20>>2]|0;if((g-f|0)>>>0>>0){Ob[c[e+36>>2]&63](e,b,d)|0;break}b:do if((a[e+75>>0]|0)>-1){h=d;while(1){if(!h){g=d;break b}g=h+-1|0;if((a[b+g>>0]|0)==10)break;else h=g}if((Ob[c[e+36>>2]&63](e,b,h)|0)>>>0>>0)break a;g=d-h|0;b=b+h|0;f=c[e+20>>2]|0}else g=d;while(0);_m(f|0,b|0,g|0)|0;c[e+20>>2]=(c[e+20>>2]|0)+g}while(0);return}function Fk(b){b=b|0;var d=0;d=c[b+52>>2]|0;if(d|0){if(a[b+56>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+52>>2]=0}a[b+56>>0]=1;c[b+52>>2]=0;c[b+44>>2]=0;c[b+48>>2]=0;d=c[b+32>>2]|0;if(d|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;d=c[b+12>>2]|0;if(!d){a[b+16>>0]=1;c[b+12>>2]=0;c[b+4>>2]=0;b=b+8|0;c[b>>2]=0;return}if(a[b+16>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+12>>2]=0;a[b+16>>0]=1;c[b+12>>2]=0;c[b+4>>2]=0;b=b+8|0;c[b>>2]=0;return}function Gk(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0.0,l=0.0;e=i;i=i+16|0;ic[c[(c[b>>2]|0)+68>>2]&127](e,b,d);c[a>>2]=c[e>>2];c[a+4>>2]=c[e+4>>2];c[a+8>>2]=c[e+8>>2];c[a+12>>2]=c[e+12>>2];j=+g[d>>2];h=+g[d+4>>2];f=+g[d+8>>2];l=j*j+h*h+f*f<1.4210854715202004e-14?-1.0:j;k=j*j+h*h+f*f<1.4210854715202004e-14?-1.0:h;f=j*j+h*h+f*f<1.4210854715202004e-14?-1.0:f;h=1.0/+O(+(f*f+(l*l+k*k)));j=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);g[a>>2]=+g[a>>2]+j*h*l;g[a+4>>2]=j*h*k+ +g[a+4>>2];g[a+8>>2]=j*h*f+ +g[a+8>>2];i=e;return}function Hk(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=c[b+188>>2]|0;if(d|0){g=c[a+68>>2]|0;g=Eb[c[(c[g>>2]|0)+36>>2]&127](g)|0;ic[c[(c[g>>2]|0)+40>>2]&127](g,d,c[a+24>>2]|0);g=c[a+68>>2]|0;ic[c[(c[g>>2]|0)+12>>2]&127](g,d,c[a+24>>2]|0);c[b+188>>2]=0}f=c[a+8>>2]|0;if((f|0)<=0)return;g=c[a+16>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0)){h=9;break}}if((h|0)==9)return;if((d|0)>=(f|0))return;c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+16>>2]|0)+(f+-1<<2)>>2]=b;c[a+8>>2]=f+-1;return}function Ik(b,d){b=b|0;d=d|0;var e=0,f=0,h=0;g[b+16>>2]=0.0;g[b+20>>2]=0.0;a[b+168>>0]=0;a[b+169>>0]=0;g[b+172>>2]=0.0;c[b+60>>2]=0;c[b+60+4>>2]=0;c[b+60+8>>2]=0;c[b+60+12>>2]=0;b=c[(c[b+8>>2]|0)+284>>2]|0;if((c[(Eb[c[(c[b>>2]|0)+28>>2]&127](b)|0)+4>>2]|0)<=0)return;do{f=c[b>>2]|0;h=c[f+12>>2]|0;f=c[c[(Eb[c[f+28>>2]&127](b)|0)+12>>2]>>2]|0;e=c[(c[(Eb[c[(c[b>>2]|0)+28>>2]&127](b)|0)+12>>2]|0)+4>>2]|0;Ib[h&31](b,f,e,c[d+24>>2]|0)|0}while((c[(Eb[c[(c[b>>2]|0)+28>>2]&127](b)|0)+4>>2]|0)>0);return}function Jk(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;c[6138]=(c[6138]|0)+-1;Cb[c[(c[a>>2]|0)+20>>2]&127](a,b);e=c[b+768>>2]|0;d=(c[a+12>>2]|0)+-1|0;g=c[a+20>>2]|0;f=c[g+(e<<2)>>2]|0;c[g+(e<<2)>>2]=c[g+(d<<2)>>2];c[(c[a+20>>2]|0)+(d<<2)>>2]=f;c[(c[(c[a+20>>2]|0)+(e<<2)>>2]|0)+768>>2]=e;c[a+12>>2]=d;a=c[a+68>>2]|0;if(!b)return;g=c[a+16>>2]|0;if(g>>>0<=b>>>0?(g+(_(c[a>>2]|0,c[a+4>>2]|0)|0)|0)>>>0>b>>>0:0){c[b>>2]=c[a+12>>2];c[a+12>>2]=b;c[a+8>>2]=(c[a+8>>2]|0)+1;return}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function Kk(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;k=c[b+8>>2]|0;if((k|0)<=0)return;i=c[b+16>>2]|0;j=0;b=0;do{h=c[i+(j<<2)>>2]|0;if(!(c[h+204>>2]&3)){g=c[a+16>>2]|0;e=g+(b<<3)|0;d=c[e>>2]|0;if((d|0)==(b|0))d=b;else{f=d;do{d=g+(f<<3)|0;c[e>>2]=c[d>>2];d=c[d>>2]|0;e=g+(d<<3)|0;f=c[e>>2]|0}while((d|0)!=(f|0))}c[h+208>>2]=d;c[g+(b<<3)+4>>2]=j;c[h+212>>2]=-1;b=b+1|0}else{c[h+208>>2]=-1;c[h+212>>2]=-2}j=j+1|0}while((j|0)!=(k|0));return}function Lk(a,b,d,f){a=a|0;b=b|0;d=d|0;f=f|0;var g=0,h=0,i=0;while(1){g=c[a+12>>2]|0;if(!(((e[f>>1]|0)>=(e[a>>1]|0)?(e[d>>1]|0)<=(e[a+6>>1]|0):0)&(e[d+4>>1]|0)<=(e[a+10>>1]|0)&(e[f+4>>1]|0)>=(e[a+4>>1]|0)&(e[d+2>>1]|0)<=(e[a+8>>1]|0)&(e[f+2>>1]|0)>=(e[a+2>>1]|0))){h=6;break}if((g|0)>-1)break;i=a+16|0;Lk(i,b,d,f);g=c[a+28>>2]|0;a=(g|0)>-1?a+32|0:i+(0-g<<4)|0}if((h|0)==6)return;ic[c[(c[b>>2]|0)+8>>2]&127](b,g>>21,g&2097151);return}function Mk(a,d){a=a|0;d=d|0;var e=0,f=0;while(1){e=yc(84)|0;if(e|0){f=6;break}e=c[6564]|0;c[6564]=e+0;if(!e){f=5;break}jc[e&3]()}if((f|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((f|0)==6){g[e+4>>2]=1.0;c[e+8>>2]=0;b[e+12>>1]=1;b[e+14>>1]=-1;c[e+16>>2]=0;c[e>>2]=2948;c[e+20>>2]=c[a>>2];c[e+20+4>>2]=c[a+4>>2];c[e+20+8>>2]=c[a+8>>2];c[e+20+12>>2]=c[a+12>>2];c[e+36>>2]=c[d>>2];c[e+36+4>>2]=c[d+4>>2];c[e+36+8>>2]=c[d+8>>2];c[e+36+12>>2]=c[d+12>>2];return e|0}return 0}function Nk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;if((e|0)<=0)return;f=0;do{n=+g[b+(f<<4)>>2];m=+g[b+(f<<4)+4>>2];j=+g[b+(f<<4)+8>>2];k=n*+g[a+56>>2]+m*+g[a+60>>2]+j*+g[a+64>>2];l=n*+g[a+72>>2]+m*+g[a+76>>2]+j*+g[a+80>>2];j=n*+g[a+88>>2]+m*+g[a+92>>2]+j*+g[a+96>>2];h=d+(f<<4)|0;i=a+56+((k>2]=c[i>>2];c[h+4>>2]=c[i+4>>2];c[h+8>>2]=c[i+8>>2];c[h+12>>2]=c[i+12>>2];f=f+1|0}while((f|0)!=(e|0));return}function Ok(a,b){a=a|0;b=+b;var d=0,e=0;d=i;i=i+16|0;hf(a,b);li(11758);a=c[a+452>>2]|0;zb[c[(c[a>>2]|0)+24>>2]&31](a,b);a=c[2357]|0;e=(c[a+16>>2]|0)+-1|0;c[a+16>>2]=e;if(e|0){i=d;return}do if(c[a+4>>2]|0){tb(d|0,0)|0;e=c[6434]|0;g[a+8>>2]=+g[a+8>>2]+ +(((c[d+4>>2]|0)-(c[e+4>>2]|0)+(((c[d>>2]|0)-(c[e>>2]|0)|0)*1e6|0)-(c[a+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[a+16>>2]|0)){a=c[2357]|0;break}else{i=d;return}}while(0);c[2357]=c[a+20>>2];i=d;return}function Pk(a,b,d){a=a|0;b=b|0;d=d|0;switch(b|0){case 0:{c[d>>2]=1065353216;c[d+4>>2]=0;c[d+8>>2]=0;g[d+12>>2]=0.0;return}case 1:{c[d>>2]=-1082130432;c[d+4>>2]=0;c[d+8>>2]=0;g[d+12>>2]=0.0;return}case 2:{c[d>>2]=0;c[d+4>>2]=1065353216;c[d+8>>2]=0;g[d+12>>2]=0.0;return}case 3:{c[d>>2]=0;c[d+4>>2]=-1082130432;c[d+8>>2]=0;g[d+12>>2]=0.0;return}case 4:{c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=1065353216;g[d+12>>2]=0.0;return}case 5:{c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=-1082130432;g[d+12>>2]=0.0;return}default:return}}function Qk(b,d){b=b|0;d=d|0;a[b+148>>0]=0;if((((ke(b,d)|0?(a[b+148>>0]=1,ke(b,d)|0):0)?(a[b+148>>0]=1,ke(b,d)|0):0)?(a[b+148>>0]=1,ke(b,d)|0):0)?(a[b+148>>0]=1,ke(b,d)|0):0)a[b+148>>0]=1;d=(c[b+8>>2]|0)+52|0;c[b+92>>2]=c[d>>2];c[b+92+4>>2]=c[d+4>>2];c[b+92+8>>2]=c[d+8>>2];c[b+92+12>>2]=c[d+12>>2];Bp(b+112|0,d|0,16)|0;return}function Rk(a,d){a=a|0;d=d|0;var e=0,f=0;while(1){e=yc(80)|0;if(e|0){f=6;break}e=c[6564]|0;c[6564]=e+0;if(!e){f=5;break}jc[e&3]()}if((f|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((f|0)==6){g[e+4>>2]=1.0;b[e+8>>1]=1;b[e+10>>1]=-1;c[e>>2]=2872;c[e+12>>2]=c[a>>2];c[e+12+4>>2]=c[a+4>>2];c[e+12+8>>2]=c[a+8>>2];c[e+12+12>>2]=c[a+12>>2];c[e+28>>2]=c[d>>2];c[e+28+4>>2]=c[d+4>>2];c[e+28+8>>2]=c[d+8>>2];c[e+28+12>>2]=c[d+12>>2];c[e+76>>2]=0;return e|0}return 0}function Sk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0;h=+g[a+56>>2];k=+g[a+72>>2]-h;j=+g[a+60>>2];i=+g[a+76>>2]-j;l=+g[a+64>>2];m=+g[a+80>>2]-l;h=+g[a+88>>2]-h;j=+g[a+92>>2]-j;l=+g[a+96>>2]-l;g[d+12>>2]=0.0;f=1.0/+O(+((k*j-i*h)*(k*j-i*h)+((i*l-m*j)*(i*l-m*j)+(m*h-k*l)*(m*h-k*l))));g[d>>2]=(i*l-m*j)*f;g[d+4>>2]=(m*h-k*l)*f;g[d+8>>2]=(k*j-i*h)*f;c[e>>2]=c[a+56>>2];c[e+4>>2]=c[a+56+4>>2];c[e+8>>2]=c[a+56+8>>2];c[e+12>>2]=c[a+56+12>>2];return}function Tk(a,b){a=a|0;b=b|0;var d=0;d=i;i=i+64|0;dh(d,b,a+68|0);c[a+4>>2]=c[d>>2];c[a+4+4>>2]=c[d+4>>2];c[a+4+8>>2]=c[d+8>>2];c[a+4+12>>2]=c[d+12>>2];c[a+20>>2]=c[d+16>>2];c[a+20+4>>2]=c[d+16+4>>2];c[a+20+8>>2]=c[d+16+8>>2];c[a+20+12>>2]=c[d+16+12>>2];c[a+36>>2]=c[d+32>>2];c[a+36+4>>2]=c[d+32+4>>2];c[a+36+8>>2]=c[d+32+8>>2];c[a+36+12>>2]=c[d+32+12>>2];c[a+52>>2]=c[d+48>>2];c[a+52+4>>2]=c[d+48+4>>2];c[a+52+8>>2]=c[d+48+8>>2];c[a+52+12>>2]=c[d+48+12>>2];i=d;return}function Uk(b){b=b|0;var d=0;if(!b)return;d=c[b+156>>2]|0;if(d|0){if(!((a[b+160>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+156>>2]=0}a[b+160>>0]=1;c[b+156>>2]=0;c[b+148>>2]=0;c[b+152>>2]=0;d=c[b+136>>2]|0;if(d|0){if(!((a[b+140>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+136>>2]=0}a[b+140>>0]=1;c[b+136>>2]=0;c[b+128>>2]=0;c[b+132>>2]=0;d=c[b+116>>2]|0;if(d|0){if(!((a[b+120>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+116>>2]=0}a[b+120>>0]=1;hd(b);return}function Vk(){var b=0,d=0;while(1){b=yc(100)|0;if(b|0){d=6;break}b=c[6564]|0;c[6564]=b+0;if(!b){d=5;break}jc[b&3]()}if((d|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((d|0)==6){g[b>>2]=1.2000000476837158;g[b+4>>2]=0.0;g[b+8>>2]=0.0;g[b+12>>2]=1.0e3;c[b+16>>2]=0;c[b+16+4>>2]=0;c[b+16+8>>2]=0;c[b+16+12>>2]=0;c[b+16+16>>2]=0;c[b+16+20>>2]=0;c[b+16+24>>2]=0;c[b+44>>2]=-1054867456;c[b+48>>2]=0;g[b+52>>2]=0.0;a[b+72>>0]=1;c[b+68>>2]=0;c[b+60>>2]=0;c[b+64>>2]=0;return b|0}return 0}function Wk(b){b=b|0;var d=0,e=0,f=0;c[b>>2]=6164;d=c[b+12>>2]|0;if((d|0)>0){f=0;do{e=c[(c[b+20>>2]|0)+(f<<2)>>2]|0;if(e|0){Ab[c[c[e>>2]>>2]&255](e);e=c[b+4>>2]|0;Cb[c[(c[e>>2]|0)+60>>2]&127](e,c[(c[b+20>>2]|0)+(f<<2)>>2]|0)}f=f+1|0}while((f|0)!=(d|0))}d=c[b+20>>2]|0;if(!d){a[b+24>>0]=1;c[b+20>>2]=0;c[b+12>>2]=0;b=b+16|0;c[b>>2]=0;return}if(a[b+24>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+20>>2]=0;a[b+24>>0]=1;c[b+20>>2]=0;c[b+12>>2]=0;b=b+16|0;c[b>>2]=0;return}function Xk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;h=+g[a+56>>2];j=+g[a+72>>2]-h;i=+g[a+60>>2];k=+g[a+76>>2]-i;d=+g[a+64>>2];f=+g[a+80>>2]-d;h=+g[a+88>>2]-h;i=+g[a+92>>2]-i;d=+g[a+96>>2]-d;g[c+12>>2]=0.0;e=1.0/+O(+((j*i-k*h)*(j*i-k*h)+((k*d-f*i)*(k*d-f*i)+(f*h-j*d)*(f*h-j*d))));g[c>>2]=(k*d-f*i)*e;g[c+4>>2]=(f*h-j*d)*e;g[c+8>>2]=(j*i-k*h)*e;if(!b)return;g[c>>2]=-((k*d-f*i)*e);g[c+4>>2]=-((f*h-j*d)*e);g[c+8>>2]=-((j*i-k*h)*e);return}function Yk(b,d){b=b|0;d=d|0;var e=0;c[6435]=(c[6435]|0)+1;e=yc(115)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}c[e+8>>2]=0;c[e+12>>2]=1065353216;c[e+16>>2]=1065353216;c[e+20>>2]=1065353216;g[e+24>>2]=0.0;g[e+44>>2]=.03999999910593033;c[e+52>>2]=0;c[e+56>>2]=1065353216;c[e+60>>2]=1065353216;c[e+64>>2]=1065353216;g[e+68>>2]=0.0;c[e+72>>2]=-1082130432;c[e+76>>2]=-1082130432;c[e+80>>2]=-1082130432;g[e+84>>2]=0.0;a[e+88>>0]=0;c[e>>2]=7692;c[e+92>>2]=b;c[e+4>>2]=3;if(!d)return e|0;vj(e);return e|0}function Zk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;g=c[a+720>>2]|0;h=c[a+752>>2]|0;if((h|0)<=0){e=0;return e|0}a=c[a+760>>2]|0;f=0;while(1){i=c[a+(f*44|0)+8>>2]|0;if(((i|0)==(g+(e*104|0)|0)|((i|0)==(g+(b*104|0)|0)|(i|0)==(g+(d*104|0)|0))?(i=c[a+(f*44|0)+12>>2]|0,(i|0)==(g+(e*104|0)|0)|((i|0)==(g+(b*104|0)|0)|(i|0)==(g+(d*104|0)|0))):0)?(i=c[a+(f*44|0)+16>>2]|0,(i|0)==(g+(e*104|0)|0)|((i|0)==(g+(b*104|0)|0)|(i|0)==(g+(d*104|0)|0))):0){a=1;f=7;break}f=f+1|0;if((f|0)>=(h|0)){a=0;f=7;break}}if((f|0)==7)return a|0;return 0}function _k(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;d=+g[a+348>>2];f=+g[a+352>>2];h=+g[b+4>>2]*f;i=+g[a+356>>2];j=+g[b+8>>2]*i;g[a+412>>2]=+g[a+412>>2]+ +g[b>>2]*d;g[a+416>>2]=+g[a+416>>2]+h;g[a+420>>2]=+g[a+420>>2]+j;d=+g[b>>2]*d;f=+g[b+4>>2]*f;i=+g[b+8>>2]*i;j=+g[c+4>>2];h=+g[c+8>>2];k=+g[c>>2];e=(h*d-k*i)*+g[a+548>>2];d=(k*f-j*d)*+g[a+552>>2];g[a+428>>2]=+g[a+428>>2]+(j*i-h*f)*+g[a+544>>2];g[a+432>>2]=+g[a+432>>2]+e;g[a+436>>2]=+g[a+436>>2]+d;return}function $k(a,b,c,d,e,f,h,i,j,k){a=+a;b=+b;c=+c;d=+d;e=+e;f=+f;h=+h;i=+i;j=+j;k=k|0;if(!(((h-d)*b-(i-e)*a)*f+(((i-e)*c-(j-f)*b)*d+((j-f)*a-(h-d)*c)*e)<0.0)){k=0;return k|0}if((h-d)*d+(i-e)*e+(j-f)*f>0.0){g[k>>2]=+O(+(d*d+e*e+f*f));k=1;return k|0}if((h-d)*h+(i-e)*i+(j-f)*j<0.0){g[k>>2]=+O(+(h*h+i*i+j*j));k=1;return k|0}else{c=((h*h+i*i+j*j)*(d*d+e*e+f*f)-(h*d+i*e+j*f)*(h*d+i*e+j*f))/((h-d)*(h-d)+(i-e)*(i-e)+(j-f)*(j-f));g[k>>2]=+O(+(c>0.0?c:0.0));k=1;return k|0}return 0}function al(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;var h=0,i=0;while(1){h=yc(44)|0;if(h|0){i=6;break}h=c[6564]|0;c[6564]=h+0;if(!h){i=5;break}jc[h&3]()}if((i|0)==5){e=Ya(4)|0;c[e>>2]=9640;pb(e|0,2800,251)}else if((i|0)==6){c[h>>2]=a;c[h+4>>2]=b;c[h+8>>2]=c[d>>2];c[h+8+4>>2]=c[d+4>>2];c[h+8+8>>2]=c[d+8>>2];c[h+8+12>>2]=c[d+12>>2];c[h+24>>2]=c[e>>2];c[h+24+4>>2]=c[e+4>>2];c[h+24+8>>2]=c[e+8>>2];c[h+24+12>>2]=c[e+12>>2];g[h+40>>2]=f;return h|0}return 0}function bl(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0,j=0;i=c[a+96>>2]|0;j=c[a+104>>2]|0;f=+g[j+(((b|0)%(i|0)|0)<<4)+4>>2]*+g[a+16>>2];h=+g[j+(((b|0)%(i|0)|0)<<4)+8>>2]*+g[a+20>>2];g[d>>2]=+g[j+(((b|0)%(i|0)|0)<<4)>>2]*+g[a+12>>2];g[d+4>>2]=f;g[d+8>>2]=h;g[d+12>>2]=0.0;d=c[a+104>>2]|0;h=+g[d+(((b+1|0)%(i|0)|0)<<4)+4>>2]*+g[a+16>>2];f=+g[d+(((b+1|0)%(i|0)|0)<<4)+8>>2]*+g[a+20>>2];g[e>>2]=+g[d+(((b+1|0)%(i|0)|0)<<4)>>2]*+g[a+12>>2];g[e+4>>2]=h;g[e+8>>2]=f;g[e+12>>2]=0.0;return}function cl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0,j=0;e=i;i=i+32|0;d=c[a+184>>2]|0;if(+g[d+4>>2]==0.0){a=0;i=e;return a|0}b=c[b>>2]|0;if(!(Zb[c[(c[d>>2]|0)+8>>2]&31](d,c[b+188>>2]|0)|0)){a=1;i=e;return a|0}h=c[a+192>>2]|0;j=c[b+192>>2]|0;d=c[a+184>>2]|0;f=+g[a+188>>2];c[e>>2]=0;c[e+4>>2]=j;c[e+8>>2]=b;c[e+12>>2]=b+4;c[e+16>>2]=-1;c[e+20>>2]=-1;Ic(h,a+36|0,a+100|0,e,d,f);a=1;i=e;return a|0}function dl(a,b){a=a|0;b=b|0;var d=0;d=i;i=i+16|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];a=c[a+8>>2]|0;c[a+260>>2]=(c[a+260>>2]|0)+1;c[a+4>>2]=1065353216;c[a+8>>2]=0;c[a+8+4>>2]=0;c[a+8+8>>2]=0;c[a+8+12>>2]=0;c[a+24>>2]=1065353216;c[a+28>>2]=0;c[a+28+4>>2]=0;c[a+28+8>>2]=0;c[a+28+12>>2]=0;c[a+44>>2]=1065353216;c[a+48>>2]=0;c[a+52>>2]=c[d>>2];c[a+52+4>>2]=c[d+4>>2];c[a+52+8>>2]=c[d+8>>2];c[a+52+12>>2]=c[d+12>>2];i=d;return}function el(b){b=b|0;var d=0,e=0;if((a[22480]|0)==0?Wa(22480)|0:0){g[5730]=.6000000238418579;g[5731]=1.0;g[5732]=.30000001192092896;g[5733]=.01666666753590107;g[5734]=0.0;g[5736]=20.0;c[5735]=10;g[5738]=.20000000298023224;g[5739]=.800000011920929;g[5740]=0.0;g[5737]=1.0;c[5741]=1;g[5742]=-.03999999910593033;g[5743]=.10000000149011612;g[5744]=0.0;g[5745]=.8500000238418579;c[5746]=260;c[5747]=2;c[5748]=128;g[5749]=100.0;g[5750]=1000000015047466219876688.0e6;_a(22480)}e=22920;b=b+92|0;d=e+84|0;do{c[e>>2]=c[b>>2];e=e+4|0;b=b+4|0}while((e|0)<(d|0));return 22920}function fl(b){b=b|0;var d=0,e=0;if((a[22440]|0)==0?Wa(22440)|0:0){g[5673]=.6000000238418579;g[5674]=1.0;g[5675]=.30000001192092896;g[5676]=.01666666753590107;g[5677]=0.0;g[5679]=20.0;c[5678]=10;g[5681]=.20000000298023224;g[5682]=.800000011920929;g[5683]=0.0;g[5680]=1.0;c[5684]=1;g[5685]=-.03999999910593033;g[5686]=.10000000149011612;g[5687]=0.0;g[5688]=.8500000238418579;c[5689]=260;c[5690]=2;c[5691]=128;g[5692]=100.0;g[5693]=1000000015047466219876688.0e6;_a(22440)}e=22692;b=b+92|0;d=e+84|0;do{c[e>>2]=c[b>>2];e=e+4|0;b=b+4|0}while((e|0)<(d|0));return 22692}function gl(a){a=a|0;var b=0,d=0;b=i;i=i+16|0;li(14499);d=c[a+68>>2]|0;Cb[c[(c[d>>2]|0)+32>>2]&127](d,c[a+24>>2]|0);a=c[2357]|0;d=(c[a+16>>2]|0)+-1|0;c[a+16>>2]=d;if(d|0){i=b;return}do if(c[a+4>>2]|0){tb(b|0,0)|0;d=c[6434]|0;g[a+8>>2]=+g[a+8>>2]+ +(((c[b+4>>2]|0)-(c[d+4>>2]|0)+(((c[b>>2]|0)-(c[d>>2]|0)|0)*1e6|0)-(c[a+12>>2]|0)|0)>>>0)/1.0e3;if(!(c[a+16>>2]|0)){a=c[2357]|0;break}else{i=b;return}}while(0);c[2357]=c[a+20>>2];i=b;return}function hl(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;do switch(b|0){case 0:{f=0;b=1;break}case 1:{f=0;b=2;break}case 2:{f=1;b=3;break}case 3:{f=2;break}case 4:{f=0;break}case 5:{f=1;break}case 6:{f=2;break}case 7:{f=3;break}case 8:{f=4;b=5;break}case 9:{f=4;b=6;break}case 10:{f=5;b=7;break}case 11:{f=6;b=7;break}default:{f=0;b=0}}while(0);ic[c[(c[a>>2]|0)+108>>2]&127](a,f,d);ic[c[(c[a>>2]|0)+108>>2]&127](a,b,e);return}function il(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0;k=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);d=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);m=(k+ +g[a+28>>2])/+g[a+12>>2];j=(h+ +g[a+32>>2])/+g[a+16>>2];f=(d+ +g[a+36>>2])/+g[a+20>>2];l=+N(+(+g[b>>2]));i=+N(+(+g[b+4>>2]));e=+N(+(+g[b+8>>2]));g[a+12>>2]=l;g[a+16>>2]=i;g[a+20>>2]=e;g[a+24>>2]=0.0;g[a+28>>2]=m*l-k;g[a+32>>2]=j*i-h;g[a+36>>2]=f*e-d;g[a+40>>2]=0.0;return}function jl(b){b=b|0;var d=0,e=0;if((a[22424]|0)==0?Wa(22424)|0:0){g[5648]=.6000000238418579;g[5649]=1.0;g[5650]=.30000001192092896;g[5651]=.01666666753590107;g[5652]=0.0;g[5654]=20.0;c[5653]=10;g[5656]=.20000000298023224;g[5657]=.800000011920929;g[5658]=0.0;g[5655]=1.0;c[5659]=1;g[5660]=-.03999999910593033;g[5661]=.10000000149011612;g[5662]=0.0;g[5663]=.8500000238418579;c[5664]=260;c[5665]=2;c[5666]=128;g[5667]=100.0;g[5668]=1000000015047466219876688.0e6;_a(22424)}e=22592;b=b+92|0;d=e+84|0;do{c[e>>2]=c[b>>2];e=e+4|0;b=b+4|0}while((e|0)<(d|0));return 22592}function kl(b,d){b=b|0;d=d|0;var e=0,f=0,h=0.0,i=0,j=0;if(a[b+527>>0]|0){c[d>>2]=0;c[d+4>>2]=0;return}c[d>>2]=3;c[d+4>>2]=3;j=c[b+28>>2]|0;i=c[b+32>>2]|0;Fc(b,j+4|0,i+4|0,j+264|0,i+264|0);if((a[b+526>>0]|0?(e=c[d>>2]|0,c[d>>2]=e+1,f=c[d+4>>2]|0,c[d+4>>2]=f+-1,h=+g[b+456>>2],+g[b+444>>2]>2]>2]=e+2;c[d+4>>2]=f+-2}if(!(a[b+525>>0]|0))return;c[d>>2]=(c[d>>2]|0)+1;c[d+4>>2]=(c[d+4>>2]|0)+-1;return}function ll(b){b=b|0;var d=0;c[6435]=(c[6435]|0)+1;d=yc(115)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;c[d+52>>2]=0;c[d+56>>2]=1065353216;c[d+60>>2]=1065353216;c[d+64>>2]=1065353216;g[d+68>>2]=0.0;c[d+72>>2]=-1082130432;c[d+76>>2]=-1082130432;c[d+80>>2]=-1082130432;g[d+84>>2]=0.0;a[d+88>>0]=0;c[d>>2]=7692;c[d+92>>2]=b;c[d+4>>2]=3;vj(d);return d|0}function ml(){if(a[22456]|0)return;if(!(Wa(22456)|0))return;if((a[22464]|0)==0?Wa(22464)|0:0){c[5698]=1065353216;c[5699]=0;c[5700]=0;c[5701]=0;c[5702]=0;c[5703]=1065353216;c[5704]=0;c[5705]=0;c[5706]=0;c[5707]=0;c[5708]=1065353216;g[5709]=0.0;_a(22464)}c[5710]=c[5698];c[5711]=c[5699];c[5712]=c[5700];c[5713]=c[5701];c[5714]=c[5702];c[5715]=c[5703];c[5716]=c[5704];c[5717]=c[5705];c[5718]=c[5706];c[5719]=c[5707];c[5720]=c[5708];c[5721]=c[5709];c[5722]=0;c[5723]=0;c[5724]=0;c[5725]=0;_a(22456);return}function nl(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0,h=0,i=0;b=c[b+36>>2]|0;i=c[b+8>>2]|0;h=c[b+12>>2]|0;f=c[b+16>>2]|0;e=+g[a+52>>2];d=+Mh(a+4|0,+g[a+36>>2],+g[a+40>>2],+g[a+44>>2],+g[i+8>>2],+g[i+12>>2],+g[i+16>>2],+g[h+8>>2],+g[h+12>>2],+g[h+16>>2],+g[f+8>>2],+g[f+12>>2],+g[f+16>>2],e);if(!(d>0.0&d>2]|0;h=h+1|0;c[i>>2]=h;return}g[a+52>>2]=d;c[a+56>>2]=b;i=a+60|0;h=c[i>>2]|0;h=h+1|0;c[i>>2]=h;return}function ol(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;a:do if(c>>>0>=3)if((c+-3|0)>>>0<3)switch(b|0){case 2:{d=+g[a+868+(c+-3<<6)+32>>2];break a}case 4:{d=+g[a+868+(c+-3<<6)+36>>2];break a}case 3:{d=+g[a+868+(c+-3<<6)+28>>2];break a}default:{d=0.0;break a}}else d=0.0;else switch(b|0){case 2:{d=+g[a+756+(c<<2)>>2];break a}case 4:{d=+g[a+772+(c<<2)>>2];break a}case 3:{d=+g[a+740+(c<<2)>>2];break a}default:{d=0.0;break a}}while(0);return +d}function pl(a,b){a=a|0;b=b|0;c[a+260>>2]=(c[a+260>>2]|0)+1;c[a+4>>2]=c[b>>2];c[a+4+4>>2]=c[b+4>>2];c[a+4+8>>2]=c[b+8>>2];c[a+4+12>>2]=c[b+12>>2];c[a+20>>2]=c[b+16>>2];c[a+20+4>>2]=c[b+16+4>>2];c[a+20+8>>2]=c[b+16+8>>2];c[a+20+12>>2]=c[b+16+12>>2];c[a+36>>2]=c[b+32>>2];c[a+36+4>>2]=c[b+32+4>>2];c[a+36+8>>2]=c[b+32+8>>2];c[a+36+12>>2]=c[b+32+12>>2];c[a+52>>2]=c[b+48>>2];c[a+52+4>>2]=c[b+48+4>>2];c[a+52+8>>2]=c[b+48+8>>2];c[a+52+12>>2]=c[b+48+12>>2];return}function ql(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;ic[c[(c[b>>2]|0)+68>>2]&127](a,b,d);if(!(+Sb[c[(c[b>>2]|0)+48>>2]&15](b)!=0.0))return;h=+g[d>>2];f=+g[d+4>>2];e=+g[d+8>>2];j=h*h+f*f+e*e<1.4210854715202004e-14?-1.0:h;i=h*h+f*f+e*e<1.4210854715202004e-14?-1.0:f;e=h*h+f*f+e*e<1.4210854715202004e-14?-1.0:e;f=1.0/+O(+(e*e+(j*j+i*i)));h=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);g[a>>2]=+g[a>>2]+h*f*j;g[a+4>>2]=h*f*i+ +g[a+4>>2];g[a+8>>2]=h*f*e+ +g[a+8>>2];return}function rl(b,d,e){b=b|0;d=d|0;e=+e;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;a[b+171>>0]=0;c[b+60>>2]=c[d>>2];c[b+60+4>>2]=c[d+4>>2];c[b+60+8>>2]=c[d+8>>2];c[b+60+12>>2]=c[d+12>>2];f=+g[b+60>>2];h=+g[b+64>>2];j=+g[b+68>>2];i=1.0/+O(+(f*f+h*h+j*j));if(+O(+(j*i*j*i+(f*i*f*i+h*i*h*i)))<1.1920928955078125e-07){k=0.0;h=0.0;f=0.0;d=0}else{k=f*i;h=h*i;f=j*i;d=c[b+72>>2]|0}g[b+76>>2]=k;g[b+80>>2]=h;g[b+84>>2]=f;c[b+88>>2]=d;g[b+172>>2]=+g[b+172>>2]+e;return}function sl(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;f=+g[b>>2];d=+g[b+4>>2];j=+g[b+8>>2];h=+g[b+12>>2];e=f*(2.0/(f*f+d*d+j*j+h*h));c=d*(2.0/(f*f+d*d+j*j+h*h));i=j*(2.0/(f*f+d*d+j*j+h*h));g[a>>2]=1.0-(d*c+j*i);g[a+4>>2]=f*c-h*i;g[a+8>>2]=f*i+h*c;g[a+12>>2]=0.0;g[a+16>>2]=f*c+h*i;g[a+20>>2]=1.0-(f*e+j*i);g[a+24>>2]=d*i-h*e;g[a+28>>2]=0.0;g[a+32>>2]=f*i-h*c;g[a+36>>2]=d*i+h*e;g[a+40>>2]=1.0-(f*e+d*c);g[a+44>>2]=0.0;return}function tl(a,b){a=a|0;b=+b;var d=0,e=0,f=0.0,h=0.0,i=0.0,j=0.0;c[6435]=(c[6435]|0)+1;d=yc(103)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}e=d+4|0;c[e>>2]=35;c[d+8>>2]=0;g[d+12>>2]=0.0;c[d>>2]=7048;j=+g[a>>2];i=+g[a+4>>2];h=+g[a+8>>2];a=c[a+12>>2]|0;f=1.0/+O(+(j*j+i*i+h*h));g[d+48>>2]=j*f;g[d+52>>2]=i*f;g[d+56>>2]=h*f;c[d+60>>2]=a;g[d+64>>2]=b;a=d+68|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;c[e>>2]=28;return d|0}function ul(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=f;if(f|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+28>>2]=c[a+28>>2];c[b+32>>2]=c[a+32>>2];c[b+36>>2]=c[a+36>>2];c[b+40>>2]=c[a+40>>2];c[b+12>>2]=c[a+12>>2];c[b+16>>2]=c[a+16>>2];c[b+20>>2]=c[a+20>>2];c[b+24>>2]=c[a+24>>2];c[b+44>>2]=c[a+44>>2];c[b+52>>2]=c[a+52>>2];return 17871}function vl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=f;if(f|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+28>>2]=c[a+28>>2];c[b+32>>2]=c[a+32>>2];c[b+36>>2]=c[a+36>>2];c[b+40>>2]=c[a+40>>2];c[b+12>>2]=c[a+12>>2];c[b+16>>2]=c[a+16>>2];c[b+20>>2]=c[a+20>>2];c[b+24>>2]=c[a+24>>2];c[b+44>>2]=c[a+44>>2];c[b+52>>2]=c[a+52>>2];return 17417}function wl(b,d){b=b|0;d=d|0;do if(!b)b=0;else{if(d>>>0<128){a[b>>0]=d;b=1;break}if(d>>>0<2048){a[b>>0]=d>>>6|192;a[b+1>>0]=d&63|128;b=2;break}if(d>>>0<55296|(d&-8192|0)==57344){a[b>>0]=d>>>12|224;a[b+1>>0]=d>>>6&63|128;a[b+2>>0]=d&63|128;b=3;break}if((d+-65536|0)>>>0<1048576){a[b>>0]=d>>>18|240;a[b+1>>0]=d>>>12&63|128;a[b+2>>0]=d>>>6&63|128;a[b+3>>0]=d&63|128;b=4;break}if(!0)b=25748;else b=c[(ib()|0)+64>>2]|0;c[b>>2]=84;b=-1}while(0);return b|0}function xl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=f;if(f|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+28>>2]=c[a+28>>2];c[b+32>>2]=c[a+32>>2];c[b+36>>2]=c[a+36>>2];c[b+40>>2]=c[a+40>>2];c[b+12>>2]=c[a+12>>2];c[b+16>>2]=c[a+16>>2];c[b+20>>2]=c[a+20>>2];c[b+24>>2]=c[a+24>>2];c[b+44>>2]=c[a+44>>2];c[b+52>>2]=c[a+68>>2];return 16426}function yl(a,b){a=a|0;b=b|0;c[a+4>>2]=c[b>>2];c[a+4+4>>2]=c[b+4>>2];c[a+4+8>>2]=c[b+8>>2];c[a+4+12>>2]=c[b+12>>2];c[a+20>>2]=c[b+16>>2];c[a+20+4>>2]=c[b+16+4>>2];c[a+20+8>>2]=c[b+16+8>>2];c[a+20+12>>2]=c[b+16+12>>2];c[a+36>>2]=c[b+32>>2];c[a+36+4>>2]=c[b+32+4>>2];c[a+36+8>>2]=c[b+32+8>>2];c[a+36+12>>2]=c[b+32+12>>2];c[a+52>>2]=c[b+48>>2];c[a+52+4>>2]=c[b+48+4>>2];c[a+52+8>>2]=c[b+48+8>>2];c[a+52+12>>2]=c[b+48+12>>2];return}function zl(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;a[b+53>>0]=1;do if((c[b+4>>2]|0)==(e|0)){a[b+52>>0]=1;e=c[b+16>>2]|0;if(!e){c[b+16>>2]=d;c[b+24>>2]=f;c[b+36>>2]=1;if(!((f|0)==1?(c[b+48>>2]|0)==1:0))break;a[b+54>>0]=1;break}if((e|0)!=(d|0)){c[b+36>>2]=(c[b+36>>2]|0)+1;a[b+54>>0]=1;break}e=c[b+24>>2]|0;if((e|0)==2){c[b+24>>2]=f;e=f}if((e|0)==1?(c[b+48>>2]|0)==1:0)a[b+54>>0]=1}while(0);return}function Al(a,b,d){a=a|0;b=+b;d=d|0;var e=0,f=0.0,h=0.0,j=0.0,k=0,l=0;e=i;i=i+16|0;k=c[a+52>>2]|0;l=c[a+28+(((k+2|0)%3|0)<<2)>>2]|0;c[e>>2]=l;c[e+4>>2]=l;c[e+8>>2]=l;g[e+12>>2]=0.0;g[e+(k<<2)>>2]=+g[a+28+(k<<2)>>2]+ +g[e+(k<<2)>>2];h=(+g[e>>2]+.03999999910593033)*2.0;f=(+g[e+4>>2]+.03999999910593033)*2.0;j=(+g[e+8>>2]+.03999999910593033)*2.0;g[d>>2]=b*.0833333283662796*(f*f+j*j);g[d+4>>2]=b*.0833333283662796*(h*h+j*j);g[d+8>>2]=b*.0833333283662796*(h*h+f*f);i=e;return}function Bl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0.0,l=0.0,m=0;if((d|0)<=0)return;m=0;do{e=+g[a+32>>2];h=+g[a+28>>2];i=b+(m<<4)|0;l=+g[b+(m<<4)+4>>2];f=+g[b+(m<<4)+8>>2];k=+O(+(l*l+f*f));if(k!=0.0){j=f*(e/k);f=+g[i>>2]<0.0?-h:h;e=l*(e/k)}else{j=0.0;f=+g[i>>2]<0.0?-h:h}g[c+(m<<4)>>2]=f;g[c+(m<<4)+4>>2]=e;g[c+(m<<4)+8>>2]=j;m=m+1|0}while((m|0)!=(d|0));return}function Cl(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;j=c[b>>2]|0;if(!e)e=c[a+188>>2]|0;h=c[a+268>>2]|0;if((h|0)<=0)return;i=c[a+276>>2]|0;f=0;while(1){g=i+(f<<2)|0;if((c[g>>2]|0)==(j|0))break;f=f+1|0;if((f|0)>=(h|0)){k=9;break}}if((k|0)==9)return;if((f|0)>=(h|0))return;c[g>>2]=c[i+(h+-1<<2)>>2];c[a+268>>2]=h+-1;k=c[a+284>>2]|0;Ib[c[(c[k>>2]|0)+12>>2]&31](k,e,b,d)|0;return}function Dl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;e=i;i=i+32|0;d=c[a+216>>2]|0;if(+g[d+4>>2]==0.0){a=0;i=e;return a|0}b=c[b>>2]|0;if(!(Zb[c[(c[d>>2]|0)+8>>2]&31](d,c[b+188>>2]|0)|0)){a=1;i=e;return a|0}f=c[b+192>>2]|0;d=c[a+216>>2]|0;c[e>>2]=0;c[e+4>>2]=f;c[e+8>>2]=b;c[e+12>>2]=b+4;c[e+16>>2]=-1;c[e+20>>2]=-1;bd(a+68|0,a+132|0,e,d);a=1;i=e;return a|0}function El(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=f;if(f|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+28>>2]=c[a+28>>2];c[b+32>>2]=c[a+32>>2];c[b+36>>2]=c[a+36>>2];c[b+40>>2]=c[a+40>>2];c[b+12>>2]=c[a+12>>2];c[b+16>>2]=c[a+16>>2];c[b+20>>2]=c[a+20>>2];c[b+24>>2]=c[a+24>>2];c[b+44>>2]=c[a+44>>2];return 11212}function Fl(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;do if((b|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)==(e|0)?(c[d+28>>2]|0)!=1:0)c[d+28>>2]=f}else if((b|0)==(c[d>>2]|0)){if((c[d+16>>2]|0)!=(e|0)?(c[d+20>>2]|0)!=(e|0):0){c[d+32>>2]=f;c[d+20>>2]=e;c[d+40>>2]=(c[d+40>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0)a[d+54>>0]=1;c[d+44>>2]=4;break}if((f|0)==1)c[d+32>>2]=1}while(0);return}function Gl(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;h=i;i=i+256|0;do if((d|0)>(e|0)&(f&73728|0)==0){Qn(h|0,b|0,((d-e|0)>>>0>256?256:d-e|0)|0)|0;f=c[a>>2]|0;if((d-e|0)>>>0>255){g=d-e|0;b=f;f=(f&32|0)==0;do{if(f){Ek(h,256,a);b=c[a>>2]|0}g=g+-256|0;f=(b&32|0)==0}while(g>>>0>255);if(f)b=d-e&255;else break}else if(!(f&32))b=d-e|0;else break;Ek(h,b,a)}while(0);i=h;return}function Hl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=f;if(f|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];c[b+12>>2]=c[a+68>>2];c[b+16>>2]=c[a+72>>2];c[b+20>>2]=c[a+76>>2];c[b+24>>2]=c[a+80>>2];c[b+28>>2]=c[a+48>>2];c[b+32>>2]=c[a+52>>2];c[b+36>>2]=c[a+56>>2];c[b+40>>2]=c[a+60>>2];c[b+44>>2]=c[a+64>>2];return 17117}function Il(){var b=0,d=0.0,e=0.0;b=i;i=i+16|0;if((a[22544]|0)==0?Wa(22544)|0:0){c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;og(23268,0.0,0,0,b);_a(22544)}c[5868]=c[5868]|1;g[5903]=0.0;d=+g[5913]*0.0;e=+g[5914]*0.0;g[5908]=+g[5912]*0.0;g[5909]=d;g[5910]=e;g[5911]=0.0;c[5916]=0;c[5917]=0;c[5918]=0;c[5919]=0;e=+g[5905]*0.0;d=+g[5906]*0.0;g[5957]=+g[5904]*0.0;g[5958]=e;g[5959]=d;g[5960]=0.0;i=b;return}function Jl(b,d){b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;a[b+171>>0]=1;c[b+60>>2]=c[d>>2];c[b+60+4>>2]=c[d+4>>2];c[b+60+8>>2]=c[d+8>>2];c[b+60+12>>2]=c[d+12>>2];e=+g[b+60>>2];f=+g[b+64>>2];i=+g[b+68>>2];h=1.0/+O(+(e*e+f*f+i*i));if(+O(+(i*h*i*h+(e*h*e*h+f*h*f*h)))<1.1920928955078125e-07){j=0.0;f=0.0;e=0.0;d=0}else{j=e*h;f=f*h;e=i*h;d=c[b+72>>2]|0}g[b+76>>2]=j;g[b+80>>2]=f;g[b+84>>2]=e;c[b+88>>2]=d;return}function Kl(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0,i=0,j=0;j=c[a+68>>2]|0;i=c[a+64>>2]|0;h=c[a+72>>2]|0;e=+g[a+60>>2]*(+g[b+(j<<2)>>2]/+g[a+12+(j<<2)>>2]);g[a+60>>2]=e;f=+g[a+56>>2]*(+g[b+(i<<2)>>2]/+g[a+12+(i<<2)>>2]+ +g[b+(h<<2)>>2]/+g[a+12+(h<<2)>>2])*.5;g[a+56>>2]=f;g[a+52>>2]=f/+O(+(e*e+f*f));f=+N(+(+g[b>>2]));e=+N(+(+g[b+4>>2]));d=+N(+(+g[b+8>>2]));g[a+12>>2]=f;g[a+16>>2]=e;g[a+20>>2]=d;g[a+24>>2]=0.0;return}function Ll(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0;if((d|0)<=0)return;m=0;do{e=+g[a+28>>2];i=+g[a+36>>2];l=+g[b+(m<<4)>>2];f=+g[b+(m<<4)+4>>2];k=+O(+(l*l+f*f));h=+g[b+(m<<4)+8>>2];if(k!=0.0){j=f*(e/k);f=h<0.0?-i:i;e=l*(e/k)}else{j=0.0;f=h<0.0?-i:i}g[c+(m<<4)>>2]=e;g[c+(m<<4)+4>>2]=j;g[c+(m<<4)+8>>2]=f;m=m+1|0}while((m|0)!=(d|0));return}function Ml(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0;if((d|0)<=0)return;m=0;do{e=+g[a+28>>2];i=+g[a+32>>2];l=+g[b+(m<<4)>>2];f=+g[b+(m<<4)+8>>2];k=+O(+(l*l+f*f));h=+g[b+(m<<4)+4>>2];if(k!=0.0){j=f*(e/k);f=h<0.0?-i:i;e=l*(e/k)}else{j=0.0;f=h<0.0?-i:i}g[c+(m<<4)>>2]=e;g[c+(m<<4)+4>>2]=f;g[c+(m<<4)+8>>2]=j;m=m+1|0}while((m|0)!=(d|0));return}function Nl(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;i=i+48|0;c[f+32>>2]=8976;c[f+32+4>>2]=e;c[f>>2]=c[b>>2];c[f+4>>2]=c[b+4>>2];c[f+8>>2]=c[b+8>>2];c[f+12>>2]=c[b+12>>2];c[f+16>>2]=c[d>>2];c[f+16+4>>2]=c[d+4>>2];c[f+16+8>>2]=c[d+8>>2];c[f+16+12>>2]=c[d+12>>2];bg(c[a+4>>2]|0,f,f+32|0);bg(c[a+64>>2]|0,f,f+32|0);i=f;return}function Ol(a,d,f,g,h,i){a=a|0;d=d|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0;j=c[a+108>>2]|0;if(j|0){Qb[c[(c[j>>2]|0)+24>>2]&7](j,d,f,g,h,i);return}j=b[a+56>>1]|0;if((j&65535)<<1>>>0<=1)return;d=1;h=1;do{i=c[a+68>>2]|0;if(b[i+(d<<2)>>1]&1){Zb[c[(c[g>>2]|0)+8>>2]&31](g,(c[a+60>>2]|0)+((e[i+(d<<2)+2>>1]|0)<<6)|0)|0;j=b[a+56>>1]|0}h=h+1<<16>>16;d=h&65535}while(d>>>0<((j&65535)<<1|1)>>>0);return}function Pl(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;b=c[d>>2]|0;b=Zb[c[(c[b>>2]|0)+56>>2]&31](b,80)|0;d=c[d>>2]|0;c[b+4>>2]=d;c[b>>2]=5508;a[b+8>>0]=1;c[b+12>>2]=5536;c[b+60>>2]=d;c[b+64>>2]=0;c[b+16>>2]=f;c[b+20>>2]=e;d=Ob[c[(c[d>>2]|0)+12>>2]&63](d,c[f+8>>2]|0,c[e+8>>2]|0)|0;c[b+76>>2]=d;f=c[b+60>>2]|0;Cb[c[(c[f>>2]|0)+20>>2]&127](f,d);return b|0}function Ql(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;g=i;i=i+64|0;if((a|0)!=(b|0))if((b|0)!=0?(f=wj(b,2744)|0,(f|0)!=0):0){b=g;e=b+56|0;do{c[b>>2]=0;b=b+4|0}while((b|0)<(e|0));c[g>>2]=f;c[g+8>>2]=a;c[g+12>>2]=-1;c[g+48>>2]=1;mc[c[(c[f>>2]|0)+28>>2]&127](f,g,c[d>>2]|0,1);if((c[g+24>>2]|0)==1){c[d>>2]=c[g+16>>2];b=1}else b=0}else b=0;else b=1;i=g;return b|0}function Rl(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;b=c[d>>2]|0;b=Zb[c[(c[b>>2]|0)+56>>2]&31](b,80)|0;d=c[d>>2]|0;c[b+4>>2]=d;c[b>>2]=5508;a[b+8>>0]=0;c[b+12>>2]=5536;c[b+60>>2]=d;c[b+64>>2]=0;c[b+16>>2]=e;c[b+20>>2]=f;d=Ob[c[(c[d>>2]|0)+12>>2]&63](d,c[e+8>>2]|0,c[f+8>>2]|0)|0;c[b+76>>2]=d;f=c[b+60>>2]|0;Cb[c[(c[f>>2]|0)+20>>2]&127](f,d);return b|0}function Sl(){var a=0,b=0,d=0;d=i;i=i+32|0;while(1){a=yc(112)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((b|0)==6){c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=4096;c[d+12>>2]=4096;c[d+16>>2]=0;c[d+20>>2]=1;qg(a,d);i=d;return a|0}return 0}function Tl(b){b=b|0;var d=0;c[b>>2]=5088;d=c[b+284>>2]|0;Ab[c[c[d>>2]>>2]&255](d);d=c[b+284>>2]|0;if(d|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b>>2]=5044;d=c[b+276>>2]|0;if(!d){a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;d=b+272|0;c[d>>2]=0;c[b>>2]=5008;return}if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+276>>2]=0;a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;d=b+272|0;c[d>>2]=0;c[b>>2]=5008;return}function Ul(a){a=a|0;var b=0,d=0,e=0,f=0.0,h=0.0;e=c[a+232>>2]|0;if((e|0)<=0)return;a=c[a+240>>2]|0;d=0;do{b=c[a+(d<<2)>>2]|0;switch(c[b+216>>2]|0){case 2:case 5:break;default:if(!(c[b+204>>2]&3)){h=+g[b+368>>2]*+g[b+352>>2];f=+g[b+372>>2]*+g[b+356>>2];g[b+412>>2]=+g[b+364>>2]*+g[b+348>>2]+ +g[b+412>>2];g[b+416>>2]=h+ +g[b+416>>2];g[b+420>>2]=f+ +g[b+420>>2]}}d=d+1|0}while((d|0)!=(e|0));return}function Vl(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;b=a[b+16>>0]|0;h=c[(b<<24>>24==0?d:e)+8>>2]|0;b=b<<24>>24?d:e;d=c[b+8>>2]|0;e=c[h+268>>2]|0;a:do if((e|0)>0){g=c[h+276>>2]|0;f=0;while(1){if((c[g+(f<<2)>>2]|0)==(d|0))break;f=f+1|0;if((f|0)>=(e|0))break a}if((f|0)!=(e|0))return}while(0);e=c[h+284>>2]|0;ic[c[(c[e>>2]|0)+36>>2]&127](e,h,b);return}function Wl(a,b){a=a|0;b=+b;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0;h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);e=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=h+ +g[a+28>>2];e=e+ +g[a+32>>2];i=i+ +g[a+36>>2];g[a+44>>2]=b;f=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);d=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);b=i-+Sb[c[(c[a>>2]|0)+48>>2]&15](a);g[a+28>>2]=h-f;g[a+32>>2]=e-d;g[a+36>>2]=b;g[a+40>>2]=0.0;return}function Xl(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;if((c[a+8>>2]|0)<=0)return;g=0;a:while(1){while(1){e=c[a+16>>2]|0;f=e+(g<<4)|0;if(!(Zb[c[(c[b>>2]|0)+8>>2]&31](b,f)|0))break;Ib[c[(c[a>>2]|0)+12>>2]&31](a,c[f>>2]|0,c[e+(g<<4)+4>>2]|0,d)|0;c[6163]=(c[6163]|0)+-1;if((g|0)>=(c[a+8>>2]|0)){e=7;break a}}g=g+1|0;if((g|0)>=(c[a+8>>2]|0)){e=7;break}}if((e|0)==7)return}function Yl(a,b){a=+a;b=+b;var d=0;c[6435]=(c[6435]|0)+1;d=yc(95)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;g[d+56>>2]=a;g[d+60>>2]=b;c[d+4>>2]=11;g[d+52>>2]=a/+O(+(a*a+b*b));c[d>>2]=6472;c[d+64>>2]=0;c[d+68>>2]=2;c[d+72>>2]=1;g[d+28>>2]=a;g[d+36>>2]=b;g[d+32>>2]=a;return d|0}function Zl(a,b){a=+a;b=+b;var d=0;c[6435]=(c[6435]|0)+1;d=yc(95)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;g[d+56>>2]=a;g[d+60>>2]=b;c[d+4>>2]=11;g[d+52>>2]=a/+O(+(a*a+b*b));c[d>>2]=6572;c[d+64>>2]=1;c[d+68>>2]=0;c[d+72>>2]=2;g[d+32>>2]=a;g[d+28>>2]=b;g[d+36>>2]=a;return d|0}function _l(a,b){a=+a;b=+b;var d=0;c[6435]=(c[6435]|0)+1;d=yc(95)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;c[d>>2]=6372;g[d+56>>2]=a;g[d+60>>2]=b;c[d+4>>2]=11;c[d+64>>2]=0;c[d+68>>2]=1;c[d+72>>2]=2;g[d+28>>2]=a;g[d+32>>2]=b;g[d+36>>2]=a;g[d+52>>2]=a/+O(+(a*a+b*b));return d|0}function $l(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;b=c[d>>2]|0;b=Zb[c[(c[b>>2]|0)+56>>2]&31](b,16)|0;d=c[d>>2]|0;c[b+4>>2]=d;c[b>>2]=5576;a[b+8>>0]=0;c[b+12>>2]=0;if(!(Ob[c[(c[d>>2]|0)+24>>2]&63](d,c[e+8>>2]|0,c[f+8>>2]|0)|0))return b|0;d=c[b+4>>2]|0;c[b+12>>2]=Ob[c[(c[d>>2]|0)+12>>2]&63](d,c[e+8>>2]|0,c[f+8>>2]|0)|0;a[b+8>>0]=1;return b|0}function am(){var a=0,b=0,d=0;d=i;i=i+32|0;while(1){a=yc(92)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((b|0)==6){c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=4096;c[d+12>>2]=4096;c[d+16>>2]=0;c[d+20>>2]=1;Zd(a,d);i=d;return a|0}return 0}function bm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);f=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);k=+g[b+52>>2]-h;j=+g[b+56>>2]-f;g[d>>2]=+g[b+48>>2]-i;g[d+4>>2]=k;g[d+8>>2]=j;g[d+12>>2]=0.0;h=h+ +g[b+52>>2];f=f+ +g[b+56>>2];g[e>>2]=i+ +g[b+48>>2];g[e+4>>2]=h;g[e+8>>2]=f;g[e+12>>2]=0.0;return}function cm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;g=c[a+720>>2]|0;h=c[a+732>>2]|0;if((h|0)<=0){d=0;return d|0}e=c[a+740>>2]|0;f=0;while(1){a=c[e+(f*52|0)+8>>2]|0;if((a|0)==(g+(b*104|0)|0)?(c[e+(f*52|0)+12>>2]|0)==(g+(d*104|0)|0):0){a=1;e=8;break}if((a|0)==(g+(d*104|0)|0)?(c[e+(f*52|0)+12>>2]|0)==(g+(b*104|0)|0):0){a=1;e=8;break}f=f+1|0;if((f|0)>=(h|0)){a=0;e=8;break}}if((e|0)==8)return a|0;return 0}function dm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;j=+g[d>>2];i=+g[d+4>>2];e=+g[d+8>>2];f=j*+g[b+56>>2]+i*+g[b+60>>2]+e*+g[b+64>>2];h=j*+g[b+72>>2]+i*+g[b+76>>2]+e*+g[b+80>>2];e=j*+g[b+88>>2]+i*+g[b+92>>2]+e*+g[b+96>>2];b=b+56+((f>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function em(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=c[d>>2]|0;g=Zb[c[(c[g>>2]|0)+56>>2]&31](g,20)|0;h=c[d+4>>2]|0;b=a[b+4>>0]|0;d=c[d>>2]|0;c[g+4>>2]=d;c[g>>2]=6004;a[g+8>>0]=0;c[g+12>>2]=h;a[g+16>>0]=b;if(h|0)return g|0;c[g+12>>2]=Ob[c[(c[d>>2]|0)+12>>2]&63](d,c[e+8>>2]|0,c[f+8>>2]|0)|0;a[g+8>>0]=1;return g|0}function fm(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;do if((b|0)==(c[d+8>>2]|0)){b=c[d+16>>2]|0;if(!b){c[d+16>>2]=e;c[d+24>>2]=f;c[d+36>>2]=1;break}if((b|0)!=(e|0)){c[d+36>>2]=(c[d+36>>2]|0)+1;c[d+24>>2]=2;a[d+54>>0]=1;break}if((c[d+24>>2]|0)==2)c[d+24>>2]=f}else{b=c[b+8>>2]|0;mc[c[(c[b>>2]|0)+28>>2]&127](b,d,e,f)}while(0);return}function gm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;i=i+48|0;c[f>>2]=7008;c[f+4>>2]=b;c[f+8>>2]=c[d>>2];c[f+8+4>>2]=c[d+4>>2];c[f+8+8>>2]=c[d+8>>2];c[f+8+12>>2]=c[d+12>>2];c[f+24>>2]=c[e>>2];c[f+24+4>>2]=c[e+4>>2];c[f+24+8>>2]=c[e+8>>2];c[f+24+12>>2]=c[e+12>>2];a=c[a+48>>2]|0;mc[c[(c[a>>2]|0)+8>>2]&127](a,f,d,e);i=f;return}function hm(a,b,d){a=a|0;b=+b;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;i=+g[a+28>>2];f=+g[a+32>>2];j=+g[a+36>>2];h=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);e=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);j=(j+ +Sb[c[(c[a>>2]|0)+48>>2]&15](a))*2.0;g[d>>2]=b/12.0*((f+e)*2.0*(f+e)*2.0+j*j);g[d+4>>2]=b/12.0*((i+h)*2.0*(i+h)*2.0+j*j);g[d+8>>2]=b/12.0*((i+h)*2.0*(i+h)*2.0+(f+e)*2.0*(f+e)*2.0);g[d+12>>2]=0.0;return}function im(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;f=c[d>>2]|0;f=Zb[c[(c[f>>2]|0)+56>>2]&31](f,36)|0;g=c[d+4>>2]|0;i=c[b+12>>2]|0;h=c[b+8>>2]|0;e=c[b+16>>2]|0;b=c[b+20>>2]|0;c[f+4>>2]=c[d>>2];c[f>>2]=6052;c[f+8>>2]=i;c[f+12>>2]=h;a[f+16>>0]=0;c[f+20>>2]=g;a[f+24>>0]=0;c[f+28>>2]=e;c[f+32>>2]=b;return f|0}function jm(a,b){a=a|0;b=b|0;var d=0;d=i;i=i+64|0;c[d>>2]=1065353216;c[d+4>>2]=0;c[d+4+4>>2]=0;c[d+4+8>>2]=0;c[d+4+12>>2]=0;c[d+20>>2]=1065353216;c[d+24>>2]=0;c[d+24+4>>2]=0;c[d+24+8>>2]=0;c[d+24+12>>2]=0;c[d+40>>2]=1065353216;c[d+44>>2]=0;c[d+48>>2]=c[b>>2];c[d+48+4>>2]=c[b+4>>2];c[d+48+8>>2]=c[b+8>>2];c[d+48+12>>2]=c[b+12>>2];Pd(a,d);i=d;return}function km(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,h=0.0;h=+g[b>>2];f=+g[b+4>>2];e=+g[b+8>>2];d=(+g[a+280>>2]*h+ +g[a+284>>2]*f+ +g[a+288>>2]*e)*+g[a+548>>2];c=(+g[a+296>>2]*h+ +g[a+300>>2]*f+ +g[a+304>>2]*e)*+g[a+552>>2];g[a+328>>2]=+g[a+328>>2]+(+g[a+264>>2]*h+ +g[a+268>>2]*f+ +g[a+272>>2]*e)*+g[a+544>>2];g[a+332>>2]=+g[a+332>>2]+d;g[a+336>>2]=+g[a+336>>2]+c;return}function lm(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;if((d|0)==0?1:(c[d+236>>2]&2|0)==0){d=1;return d|0}g=c[b+488>>2]|0;if((g|0)<=0){d=1;return d|0}b=c[b+496>>2]|0;f=0;while(1){e=c[b+(f<<2)>>2]|0;if(a[e+20>>0]|0){if((c[e+28>>2]|0)==(d|0)){b=0;e=8;break}if((c[e+32>>2]|0)==(d|0)){b=0;e=8;break}}f=f+1|0;if((f|0)>=(g|0)){b=1;e=8;break}}if((e|0)==8)return b|0;return 0}function mm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;j=+g[a+28>>2];h=+g[a+32>>2];e=+g[a+36>>2];i=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);f=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);e=e+ +Sb[c[(c[a>>2]|0)+48>>2]&15](a);g[d>>2]=+(b&1^1|0)*(j+i)-+(b&1|0)*(j+i);g[d+4>>2]=+(b>>>1&1^1|0)*(h+f)-+(b>>>1&1|0)*(h+f);g[d+8>>2]=+(b>>>2&1^1|0)*e-+(b>>>2&1|0)*e;g[d+12>>2]=0.0;return}function nm(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,h=0.0;h=+g[b>>2];f=+g[b+4>>2];e=+g[b+8>>2];d=(+g[a+20>>2]*h+ +g[a+24>>2]*f+ +g[a+28>>2]*e)*+g[a+352>>2];c=(+g[a+36>>2]*h+ +g[a+40>>2]*f+ +g[a+44>>2]*e)*+g[a+356>>2];g[a+412>>2]=+g[a+412>>2]+(+g[a+4>>2]*h+ +g[a+8>>2]*f+ +g[a+12>>2]*e)*+g[a+348>>2];g[a+416>>2]=+g[a+416>>2]+d;g[a+420>>2]=+g[a+420>>2]+c;return}function om(b,e){b=b|0;e=e|0;var f=0,g=0,h=0;h=i;i=i+16|0;a[h>>0]=e;f=c[b+16>>2]|0;if(!f)if(!(Fo(b)|0)){f=c[b+16>>2]|0;g=4}else f=-1;else g=4;do if((g|0)==4){g=c[b+20>>2]|0;if(g>>>0>>0?(e&255|0)!=(a[b+75>>0]|0):0){c[b+20>>2]=g+1;a[g>>0]=e;f=e&255;break}if((Ob[c[b+36>>2]&63](b,h,1)|0)==1)f=d[h>>0]|0;else f=-1}while(0);i=h;return f|0}function pm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;f=i;i=i+16|0;h=b>>31|((b|0)<0?-1:0)<<1;g=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;k=e>>31|((e|0)<0?-1:0)<<1;j=((e|0)<0?-1:0)>>31|((e|0)<0?-1:0)<<1;a=Is(h^a|0,g^b|0,h|0,g|0)|0;b=C;$e(a,b,Is(k^d|0,j^e|0,k|0,j|0)|0,C,f|0)|0;e=Is(c[f>>2]^h|0,c[f+4>>2]^g|0,h|0,g|0)|0;d=C;i=f;return (C=d,e)|0}function qm(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,h=0.0;h=+g[b>>2];f=+g[b+4>>2];e=+g[b+8>>2];d=(+g[a+20>>2]*h+ +g[a+24>>2]*f+ +g[a+28>>2]*e)*+g[a+548>>2];c=(+g[a+36>>2]*h+ +g[a+40>>2]*f+ +g[a+44>>2]*e)*+g[a+552>>2];g[a+428>>2]=+g[a+428>>2]+(+g[a+4>>2]*h+ +g[a+8>>2]*f+ +g[a+12>>2]*e)*+g[a+544>>2];g[a+432>>2]=+g[a+432>>2]+d;g[a+436>>2]=+g[a+436>>2]+c;return}function rm(a,b){a=a|0;b=b|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+16>>2];c[a+8>>2]=c[b+32>>2];g[a+12>>2]=0.0;c[a+16>>2]=c[b+4>>2];c[a+20>>2]=c[b+20>>2];c[a+24>>2]=c[b+36>>2];g[a+28>>2]=0.0;c[a+32>>2]=c[b+8>>2];c[a+36>>2]=c[b+24>>2];c[a+40>>2]=c[b+40>>2];g[a+44>>2]=0.0;c[a+48>>2]=c[b+48>>2];c[a+52>>2]=c[b+52>>2];c[a+56>>2]=c[b+56>>2];g[a+60>>2]=0.0;return}function sm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;i=+g[b+28>>2];j=+g[b+32>>2];e=+g[b+36>>2];h=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);f=+Sb[c[(c[b>>2]|0)+48>>2]&15](b);e=e+ +Sb[c[(c[b>>2]|0)+48>>2]&15](b);f=+g[d+4>>2]>=0.0?j+f:-(j+f);e=+g[d+8>>2]>=0.0?e:-e;g[a>>2]=+g[d>>2]>=0.0?i+h:-(i+h);g[a+4>>2]=f;g[a+8>>2]=e;g[a+12>>2]=0.0;return}function tm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0.0,h=0.0,i=0.0;if((d|0)<=0)return;e=0;do{i=+g[a+28>>2];h=+g[a+32>>2];h=+g[b+(e<<4)+4>>2]>=0.0?h:-h;f=+g[a+36>>2];f=+g[b+(e<<4)+8>>2]>=0.0?f:-f;g[c+(e<<4)>>2]=+g[b+(e<<4)>>2]>=0.0?i:-i;g[c+(e<<4)+4>>2]=h;g[c+(e<<4)+8>>2]=f;g[c+(e<<4)+12>>2]=0.0;e=e+1|0}while((e|0)!=(d|0));return}function um(a,b){a=a|0;b=b|0;var d=0,e=0;while(1){d=yc(64)|0;if(d|0){e=6;break}d=c[6564]|0;c[6564]=d+0;if(!d){e=5;break}jc[d&3]()}if((e|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((e|0)==6){sl(d,a);c[d+48>>2]=c[b>>2];c[d+48+4>>2]=c[b+4>>2];c[d+48+8>>2]=c[b+8>>2];c[d+48+12>>2]=c[b+12>>2];return d|0}return 0}function vm(b){b=b|0;var d=0,e=0;c[b>>2]=6292;d=c[b+64>>2]|0;if(d|0?(pi(d),e=c[b+64>>2]|0,e|0):0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}d=c[b+24>>2]|0;if(!d){a[b+28>>0]=1;c[b+24>>2]=0;c[b+16>>2]=0;b=b+20|0;c[b>>2]=0;return}if(a[b+28>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+24>>2]=0;a[b+28>>0]=1;c[b+24>>2]=0;c[b+16>>2]=0;b=b+20|0;c[b>>2]=0;return}function wm(a,b,d,e,f,g,h,i,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;a=c[a+32>>2]|0;c[d>>2]=c[a+(k<<5)+12>>2];c[b>>2]=c[a+(k<<5)+16>>2];c[e>>2]=c[a+(k<<5)+28>>2];c[f>>2]=c[a+(k<<5)+20>>2];c[i>>2]=c[a+(k<<5)>>2];c[g>>2]=c[a+(k<<5)+4>>2];c[h>>2]=c[a+(k<<5)+8>>2];c[j>>2]=c[a+(k<<5)+24>>2];return}function xm(a,e,f){a=a|0;e=e|0;f=f|0;var h=0.0;switch(c[a+96>>2]|0){case 0:{f=(_(c[a+64>>2]|0,f)|0)+e|0;h=+g[(c[a+92>>2]|0)+(f<<2)>>2];return +h}case 5:{h=+(d[(_(c[a+64>>2]|0,f)|0)+e+(c[a+92>>2]|0)>>0]|0)*+g[a+88>>2];return +h}case 3:{f=(_(c[a+64>>2]|0,f)|0)+e|0;h=+(b[(c[a+92>>2]|0)+(f<<1)>>1]|0)*+g[a+88>>2];return +h}default:{h=0.0;return +h}}return 0.0}function ym(b){b=b|0;var d=0,e=0;c[b>>2]=7256;d=c[b+104>>2]|0;if(d|0){if(a[b+108>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+104>>2]=0}a[b+108>>0]=1;c[b+104>>2]=0;c[b+96>>2]=0;c[b+100>>2]=0;c[b>>2]=7124;d=c[b+52>>2]|0;if(d|0?(Ab[c[c[d>>2]>>2]&255](d),e=c[b+52>>2]|0,e|0):0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function zm(){var b=0,d=0;while(1){b=yc(40)|0;if(b|0){d=6;break}b=c[6564]|0;c[6564]=b+0;if(!b){d=5;break}jc[b&3]()}if((d|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((d|0)==6){g[b+12>>2]=1.0;c[b+8>>2]=0;c[b+4>>2]=5;c[b>>2]=2996;a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;a[b+16>>0]=1;return b|0}return 0}function Am(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;var e=0.0,f=0.0,h=0.0;e=+Q(+b);f=+Q(+c);h=+Q(+d);b=+R(+b);c=+R(+c);d=+R(+d);g[a>>2]=f*h;g[a+4>>2]=c*b*h-e*d;g[a+8>>2]=c*e*h+b*d;g[a+12>>2]=0.0;g[a+16>>2]=f*d;g[a+20>>2]=c*b*d+e*h;g[a+24>>2]=c*e*d-b*h;g[a+28>>2]=0.0;g[a+32>>2]=-c;g[a+36>>2]=f*b;g[a+40>>2]=f*e;g[a+44>>2]=0.0;return}function Bm(b,d,e,f){b=b|0;d=d|0;e=e|0;f=+f;c[b+4>>2]=c[d>>2];c[b+4+4>>2]=c[d+4>>2];c[b+4+8>>2]=c[d+8>>2];c[b+4+12>>2]=c[d+12>>2];c[b+20>>2]=c[e>>2];c[b+20+4>>2]=c[e+4>>2];c[b+20+8>>2]=c[e+8>>2];c[b+20+12>>2]=c[e+12>>2];g[b+36>>2]=f;a[b+40>>0]=1;return}function Cm(){var a=0,b=0;while(1){a=yc(8)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6){c[6434]=a;tb(a|0,0)|0;c[6424]=19390;c[6425]=0;c[6426]=0;c[6427]=0;c[6428]=0;c[6429]=0;c[6430]=0;c[6431]=0;c[6432]=0;Vq(25696);return}}function Dm(a,b){a=+a;b=+b;var d=0;c[6435]=(c[6435]|0)+1;d=yc(75)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;c[d+4>>2]=10;c[d>>2]=7592;c[d+52>>2]=2;g[d+28>>2]=a;g[d+32>>2]=a;g[d+36>>2]=b*.5;g[d+40>>2]=0.0;return d|0}function Em(a,b){a=+a;b=+b;var d=0;c[6435]=(c[6435]|0)+1;d=yc(75)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;c[d+4>>2]=10;c[d>>2]=7492;c[d+52>>2]=0;g[d+28>>2]=b*.5;g[d+32>>2]=a;g[d+36>>2]=a;g[d+40>>2]=0.0;return d|0}function Fm(a,b){a=+a;b=+b;var d=0;c[6435]=(c[6435]|0)+1;d=yc(75)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}c[d+8>>2]=0;c[d+12>>2]=1065353216;c[d+16>>2]=1065353216;c[d+20>>2]=1065353216;g[d+24>>2]=0.0;g[d+44>>2]=.03999999910593033;c[d>>2]=7392;c[d+4>>2]=10;c[d+52>>2]=1;g[d+28>>2]=a;g[d+32>>2]=b*.5;g[d+36>>2]=a;g[d+40>>2]=0.0;return d|0}function Gm(a,b){a=+a;b=b|0;var d=0,e=0,f=0;h[k>>3]=a;d=c[k>>2]|0;e=c[k+4>>2]|0;f=us(d|0,e|0,52)|0;switch(f&2047|0){case 0:{if(a!=0.0){a=+Gm(a*18446744073709551616.0,b);d=(c[b>>2]|0)+-64|0}else d=0;c[b>>2]=d;break}case 2047:break;default:{c[b>>2]=(f&2047)+-1022;c[k>>2]=d;c[k+4>>2]=e&-2146435073|1071644672;a=+h[k>>3]}}return +a}function Hm(){var a=0,b=0;while(1){a=yc(24)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6){g[a>>2]=5.880000114440918;g[a+4>>2]=.8299999833106995;g[a+8>>2]=.8799999952316284;g[a+12>>2]=500.0;g[a+16>>2]=10.5;g[a+20>>2]=6.0e3;return a|0}return 0}function Im(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;d=i;i=i+16|0;c[d>>2]=8940;c[d+4>>2]=e;Be(a+4|0,c[a+4>>2]|0,b,e+4|0,e+20|0,+g[e+32>>2],f,h,d);Be(a+64|0,c[a+64>>2]|0,b,e+4|0,e+20|0,+g[e+32>>2],f,h,d);i=d;return}function Jm(b){b=b|0;var d=0;c[b>>2]=7256;d=c[b+104>>2]|0;if(d|0){if(a[b+108>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+104>>2]=0}a[b+108>>0]=1;c[b+104>>2]=0;c[b+96>>2]=0;c[b+100>>2]=0;c[b>>2]=7124;d=c[b+52>>2]|0;if(!d)return;Ab[c[c[d>>2]>>2]&255](d);d=c[b+52>>2]|0;if(!d)return;c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);return}function Km(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+32|0;c[f>>2]=c[a+60>>2];c[f+4>>2]=0;c[f+8>>2]=b;c[f+12>>2]=f+20;c[f+16>>2]=d;b=ub(140,f|0)|0;if(b>>>0<=4294963200)if((b|0)<0)e=7;else a=c[f+20>>2]|0;else{if(!0)a=25748;else a=c[(ib()|0)+64>>2]|0;c[a>>2]=0-b;e=7}if((e|0)==7){c[f+20>>2]=-1;a=-1}i=f;return a|0}function Lm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,g=0;e=i;i=i+16|0;c[e>>2]=-1;c[e+4>>2]=c[a+16>>2];if(!(c[b+4>>2]|0))c[b+4>>2]=e;g=c[a+12>>2]|0;f=+_b[c[(c[g>>2]|0)+12>>2]&15](g,b,d);c[a+4>>2]=c[(c[a+12>>2]|0)+4>>2];i=e;return +f}function Mm(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=c[a+268>>2]|0;if((g|0)<=0)return;b=c[b>>2]|0;f=c[a+276>>2]|0;d=0;while(1){e=f+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(g|0)){h=7;break}}if((h|0)==7)return;if((d|0)>=(g|0))return;c[e>>2]=c[f+(g+-1<<2)>>2];c[a+268>>2]=g+-1;return}function Nm(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;c[b+4>>2]=c[d>>2];c[b>>2]=6164;a[b+24>>0]=1;c[b+20>>2]=0;c[b+12>>2]=0;c[b+16>>2]=0;a[b+28>>0]=g&1;c[b+32>>2]=c[d+4>>2];a[b+36>>0]=0;c[b+40>>2]=c[(c[(g?f:e)+4>>2]|0)+68>>2];lh(b,e,f);return}function Om(){var a=0,b=0;while(1){a=yc(24)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6){c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=4096;c[a+12>>2]=4096;c[a+16>>2]=0;c[a+20>>2]=1;return a|0}return 0}function Pm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;f=c[a+280>>2]|0;if((f|0)<=0)return;g=c[a+288>>2]|0;d=0;while(1){e=g+(d<<2)|0;if((c[e>>2]|0)==(b|0))break;d=d+1|0;if((d|0)>=(f|0)){h=7;break}}if((h|0)==7)return;if((d|0)>=(f|0))return;c[e>>2]=c[g+(f+-1<<2)>>2];c[(c[a+288>>2]|0)+(f+-1<<2)>>2]=b;c[a+280>>2]=f+-1;return}function Qm(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0.0,g=0;e=i;i=i+16|0;c[e>>2]=-1;c[e+4>>2]=c[a+24>>2];if(!(c[b+4>>2]|0))c[b+4>>2]=e;g=c[a+20>>2]|0;f=+_b[c[(c[g>>2]|0)+12>>2]&15](g,b,d);c[a+4>>2]=c[(c[a+20>>2]|0)+4>>2];i=e;return +f}function Rm(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;do if((b|0)==(c[d+8>>2]|0)){b=c[d+16>>2]|0;if(!b){c[d+16>>2]=e;c[d+24>>2]=f;c[d+36>>2]=1;break}if((b|0)!=(e|0)){c[d+36>>2]=(c[d+36>>2]|0)+1;c[d+24>>2]=2;a[d+54>>0]=1;break}if((c[d+24>>2]|0)==2)c[d+24>>2]=f}while(0);return}function Sm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;a:do switch(b|0){case 2:case 1:{if(c>>>0<3){d=+g[a+600>>2];break a}if((c+-3|0)>>>0<3)d=+g[a+432>>2];else d=0.0;break}case 4:case 3:{if(c>>>0<3){d=+g[a+596>>2];break a}if((c+-3|0)>>>0<3)d=+g[a+604>>2];else d=0.0;break}default:d=0.0}while(0);return +d}function Tm(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;b=c[d>>2]|0;b=Zb[c[(c[b>>2]|0)+56>>2]&31](b,16)|0;d=c[d>>2]|0;c[b+4>>2]=d;c[b>>2]=9256;a[b+8>>0]=0;c[b+12>>2]=0;c[b+12>>2]=Ob[c[(c[d>>2]|0)+12>>2]&63](d,c[e+8>>2]|0,c[f+8>>2]|0)|0;a[b+8>>0]=1;return b|0}function Um(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+56>>2]|0;if(!d)return;e=Eb[c[(c[d>>2]|0)+8>>2]&127](d)|0;e=Ob[c[(c[b>>2]|0)+16>>2]&63](b,e,1)|0;d=c[a+56>>2]|0;d=Ob[c[(c[d>>2]|0)+12>>2]&63](d,c[e+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,e,d,1346456916,c[a+56>>2]|0);return}function Vm(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;if(c>>>0>0|(c|0)==0&b>>>0>4294967295)while(1){e=lr(b|0,c|0,10,0)|0;d=d+-1|0;a[d>>0]=e|48;e=b;b=Xv(b|0,c|0,10,0)|0;if(!(c>>>0>9|(c|0)==9&e>>>0>4294967295))break;else c=C}if(b)while(1){d=d+-1|0;a[d>>0]=(b>>>0)%10|0|48;if(b>>>0<10)break;else b=(b>>>0)/10|0}return d|0}function Wm(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;switch(b|0){case 2:case 1:if(e>>>0<3){g[a+600>>2]=d;c[a+592>>2]=c[a+592>>2]|2;return}else{g[a+432>>2]=d;return}case 4:case 3:if(e>>>0<3){g[a+596>>2]=d;c[a+592>>2]=c[a+592>>2]|1;return}else{g[a+604>>2]=d;c[a+592>>2]=c[a+592>>2]|4;return}default:return}}function Xm(a,d){a=a|0;d=d|0;var e=0,f=0,g=0;d=c[a+56>>2]|0;if((d&65535)<<16>>16)return;b[a+64>>1]=1;g=c[a+60>>2]|0;if((d>>>16&65535)>1){e=1;d=1;while(1){b[g+(e<<6)+48>>1]=e+1;f=d+1<<16>>16;d=b[a+58>>1]|0;if((f&65535)<(d&65535)){e=f&65535;d=f}else break}}else d=d>>>16&65535;b[g+((d&65535)+-1<<6)+48>>1]=0;return}function Ym(a){a=a|0;var b=0,d=0;while(1){b=yc(112)|0;if(b|0){d=6;break}b=c[6564]|0;c[6564]=b+0;if(!b){d=5;break}jc[b&3]()}if((d|0)==5){a=Ya(4)|0;c[a>>2]=9640;pb(a|0,2800,251)}else if((d|0)==6){qg(b,a);return b|0}return 0}function Zm(a,b,d,e){a=+a;b=+b;d=+d;e=+e;var f=0,h=0;while(1){f=yc(16)|0;if(f|0){h=6;break}f=c[6564]|0;c[6564]=f+0;if(!f){h=5;break}jc[f&3]()}if((h|0)==5){h=Ya(4)|0;c[h>>2]=9640;pb(h|0,2800,251)}else if((h|0)==6){g[f>>2]=a;g[f+4>>2]=b;g[f+8>>2]=d;g[f+12>>2]=e;return f|0}return 0}function _m(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)>=4096)return db(b|0,d|0,e|0)|0;f=b|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function $m(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+52>>2]|0;if(!d)return;e=Eb[c[(c[d>>2]|0)+12>>2]&127](d)|0;e=Ob[c[(c[b>>2]|0)+16>>2]&63](b,e,1)|0;d=c[a+52>>2]|0;d=Ob[c[(c[d>>2]|0)+16>>2]&63](d,c[e+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,e,d,1213612625,c[a+52>>2]|0);return}function an(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0;g=b>>31|((b|0)<0?-1:0)<<1;e=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;h=d>>31|((d|0)<0?-1:0)<<1;f=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;a=Is(g^a|0,e^b|0,g|0,e|0)|0;b=C;return Is(($e(a,b,Is(h^c|0,f^d|0,h|0,f|0)|0,C,0)|0)^(h^g)|0,C^(f^e)|0,h^g|0,f^e|0)|0}function bn(a){a=a|0;var b=0,d=0;d=i;i=i+32|0;cb(a|0)|0;if(kb(26248,3)|0)ej(21924,d);a=hb(c[6563]|0)|0;if((a|0?(b=c[a>>2]|0,b|0):0)?((c[b+48>>2]&-256|0)==1126902528?(c[b+48+4>>2]|0)==1129074247:0):0){jc[c[b+12>>2]&3]();ej(22248,d+8|0)}b=c[2387]|0;c[2387]=b+0;jc[b&3]();ej(22248,d+16|0)}function cn(){var a=0,d=0;while(1){a=yc(8)|0;if(a|0){d=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){d=5;break}jc[a&3]()}if((d|0)==5){d=Ya(4)|0;c[d>>2]=9640;pb(d|0,2800,251)}else if((d|0)==6){c[a>>2]=0;c[a+4>>2]=0;b[a+4>>1]=1;b[a+6>>1]=-1;c[a>>2]=2972;return a|0}return 0}function dn(a){a=a|0;var b=0.0,d=0.0,e=0.0,f=0.0;b=+g[(c[a+28>>2]|0)+344>>2];d=+g[(c[a+32>>2]|0)+344>>2];if(d==0.0)b=1.0;else b=b/(b+d);f=1.0-b;e=b*+g[a+1116>>2]+f*+g[a+1180>>2];d=b*+g[a+1120>>2]+f*+g[a+1184>>2];g[a+1284>>2]=b*+g[a+1112>>2]+f*+g[a+1176>>2];g[a+1288>>2]=e;g[a+1292>>2]=d;g[a+1296>>2]=0.0;return}function en(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0,f=0.0,h=0.0;e=+g[a+28>>2];f=+g[a+32>>2];h=+g[a+36>>2];d=+g[b>>2];if(!(d<=e+c)){b=0;return b|0}if(!(d>=-e-c)){b=0;return b|0}d=+g[b+4>>2];if(!(d<=f+c)){b=0;return b|0}if(!(d>=-f-c)){b=0;return b|0}d=+g[b+8>>2];if(!(d<=h+c)){b=0;return b|0}b=d>=-h-c;return b|0}function fn(b,d,e,f){b=b|0;d=d|0;e=e|0;f=+f;if(!(+g[b+36>>2]>f))return;a[b+40>>0]=1;c[b+4>>2]=c[d>>2];c[b+4+4>>2]=c[d+4>>2];c[b+4+8>>2]=c[d+8>>2];c[b+4+12>>2]=c[d+12>>2];c[b+20>>2]=c[e>>2];c[b+20+4>>2]=c[e+4>>2];c[b+20+8>>2]=c[e+8>>2];c[b+20+12>>2]=c[e+12>>2];g[b+36>>2]=f;return}function gn(a,d){a=a|0;d=d|0;var e=0,f=0;e=c[d>>2]|0;f=c[a+80>>2]|0;if((e|0)==(f|0)){a=0;return a|0}d=c[d+4>>2]|0;if(!((b[a+10>>1]&(d&65535))<<16>>16)){a=0;return a|0}if(!((b[a+8>>1]&(d>>>16&65535))<<16>>16)){a=0;return a|0}a=c[a+92>>2]|0;a=Ob[c[(c[a>>2]|0)+28>>2]&63](a,f,e)|0;return a|0}function hn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=+g[b+32>>2];f=+g[b+28>>2];j=+g[c+4>>2];e=+g[c+8>>2];i=+O(+(j*j+e*e));if(i!=0.0){h=e*(d/i);e=+g[c>>2]<0.0?-f:f;d=j*(d/i)}else{h=0.0;e=+g[c>>2]<0.0?-f:f}g[a+4>>2]=d;g[a>>2]=e;g[a+8>>2]=h;return}function jn(a,b){a=a|0;b=+b;var c=0,d=0.0;c=i;i=i+16|0;if(!(+g[a+68>>2]>0.0)){i=c;return}d=-+g[a+92>>2];b=-+g[a+96>>2];g[c>>2]=-+g[a+88>>2];g[c+4>>2]=d;g[c+8>>2]=b;g[c+12>>2]=0.0;jj(a+4|0,c,a+164|0);jj(a+16|0,a+88|0,a+180|0);i=c;return}function kn(a){a=a|0;var b=0,d=0;while(1){b=yc(92)|0;if(b|0){d=6;break}b=c[6564]|0;c[6564]=b+0;if(!b){d=5;break}jc[b&3]()}if((d|0)==5){a=Ya(4)|0;c[a>>2]=9640;pb(a|0,2800,251)}else if((d|0)==6){Zd(b,a);return b|0}return 0}function ln(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0,g=0;if((d|0)>-1|(d|0)==-1&c>>>0>4294967295){e=(+(c>>>0)+4294967296.0*+(d>>>0))*18446744073709551616.0+(+(a>>>0)+4294967296.0*+(b>>>0));return +e}else{g=Is(0,0,a|0,b|0)|0;f=C;d=Kt((a|0)==0&(b|0)==0&1|0,0,~c|0,~d|0)|0;e=-+ln(g,f,d,C);return +e}return 0.0}function mn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=+g[b+28>>2];h=+g[b+36>>2];j=+g[c>>2];f=+g[c+4>>2];i=+O(+(j*j+f*f));e=+g[c+8>>2];if(i!=0.0){f=f*(d/i);e=e<0.0?-h:h;d=j*(d/i)}else{f=0.0;e=e<0.0?-h:h}g[a>>2]=d;g[a+8>>2]=e;g[a+4>>2]=f;return}function nn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=+g[b+28>>2];h=+g[b+32>>2];j=+g[c>>2];f=+g[c+8>>2];i=+O(+(j*j+f*f));e=+g[c+4>>2];if(i!=0.0){f=f*(d/i);e=e<0.0?-h:h;d=j*(d/i)}else{f=0.0;e=e<0.0?-h:h}g[a>>2]=d;g[a+4>>2]=e;g[a+8>>2]=f;return}function on(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=c[a+8>>2]|0;a=c[f+8>>2]|0;if((a|0)<=0)return;e=0;do{d=c[(c[f+16>>2]|0)+(e*12|0)+8>>2]|0;if(d){Cb[c[(c[d>>2]|0)+16>>2]&127](d,b);a=c[f+8>>2]|0}e=e+1|0}while((e|0)<(a|0));return}function pn(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;switch(e|0){case 5:case -1:break;default:return}switch(b|0){case 2:{g[a+760>>2]=d;c[a+748>>2]=c[a+748>>2]|2;return}case 4:{g[a+756>>2]=d;c[a+748>>2]=c[a+748>>2]|1;return}case 3:{g[a+752>>2]=d;c[a+748>>2]=c[a+748>>2]|4;return}default:return}}function qn(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=i;i=i+48|0;f=c[b+192>>2]|0;mc[c[(c[f>>2]|0)+8>>2]&127](f,b+4|0,e+32|0,e+16|0);c[e>>2]=5956;c[e+4>>2]=b;c[e+8>>2]=a;c[e+12>>2]=d;a=c[a+68>>2]|0;mc[c[(c[a>>2]|0)+28>>2]&127](a,e+32|0,e+16|0,e);i=e;return}function rn(){var a=0,b=0;while(1){a=yc(12)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6){g[a>>2]=.30000001192092896;g[a+4>>2]=1.0;g[a+8>>2]=0.0;return a|0}return 0}function sn(a,b,d){a=a|0;b=b|0;d=d|0;si(a,b,d)|0;c[b+52>>2]=c[a+300>>2];c[b+56>>2]=c[a+304>>2];c[b+60>>2]=c[a+308>>2];c[b+64>>2]=c[a+312>>2];c[b+68>>2]=c[a+316>>2];c[b+72>>2]=c[a+320>>2];c[b+76>>2]=c[a+324>>2];c[b+80>>2]=c[a+328>>2];return 12599}function tn(a,b,d){a=a|0;b=b|0;d=d|0;a:do switch(c[b+216>>2]|0){case 2:case 5:{switch(c[d+216>>2]|0){case 2:case 5:{b=0;break}default:break a}return b|0}default:{}}while(0);if(!(c[b+256>>2]|0)){a=1;return a|0}a=Zb[c[c[b>>2]>>2]&31](b,d)|0;return a|0}function un(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0;c[a+348>>2]=c[b>>2];c[a+348+4>>2]=c[b+4>>2];c[a+348+8>>2]=c[b+8>>2];c[a+348+12>>2]=c[b+12>>2];f=+g[a+344>>2];e=+g[a+352>>2]*f;d=+g[a+356>>2]*f;g[a+560>>2]=+g[a+348>>2]*f;g[a+564>>2]=e;g[a+568>>2]=d;g[a+572>>2]=0.0;return}function vn(a){a=a|0;c[a>>2]=1065353216;c[a+4>>2]=0;c[a+4+4>>2]=0;c[a+4+8>>2]=0;c[a+4+12>>2]=0;c[a+20>>2]=1065353216;c[a+24>>2]=0;c[a+24+4>>2]=0;c[a+24+8>>2]=0;c[a+24+12>>2]=0;c[a+40>>2]=1065353216;c[a+44>>2]=0;c[a+44+4>>2]=0;c[a+44+8>>2]=0;c[a+44+12>>2]=0;c[a+44+16>>2]=0;return}function wn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=c[b>>2]|0;a=c[d>>2]|0;a=(c[a+236>>2]|0)==4?a:0;if(!((f|0)==0?1:(c[f+236>>2]|0)!=4))mc[c[(c[f>>2]|0)+32>>2]&127](f,d,e,b);if(!a)return 0;mc[c[(c[a>>2]|0)+32>>2]&127](a,b,e,d);return 0}function xn(a,b){a=a|0;b=b|0;var d=0;if(c[b+40>>2]|0){xn(a,c[b+36>>2]|0);xn(a,c[b+40>>2]|0)}if((c[a>>2]|0)==(b|0))c[a>>2]=0;d=c[a+4>>2]|0;if(!d){c[a+4>>2]=b;return}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);c[a+4>>2]=b;return}function yn(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;g=c[a+32>>2]|0;c[g>>2]=(c[g>>2]|0)+1;Hg(a,Sd(a,b,f)|0);Hg(a,Sd(a,d,f)|0);Hg(a,Sd(a,e,f)|0);return}function zn(a){a=a|0;var b=0,d=0;while(1){b=yc(8)|0;if(b|0){d=6;break}b=c[6564]|0;c[6564]=b+0;if(!b){d=5;break}jc[b&3]()}if((d|0)==5){a=Ya(4)|0;c[a>>2]=9640;pb(a|0,2800,251)}else if((d|0)==6){c[b>>2]=4852;c[b+4>>2]=a;return b|0}return 0}function An(a,b){a=a|0;b=b|0;var d=0,e=0;c[a+68>>2]=(c[a+68>>2]|0)+1;d=c[a+16>>2]|0;if((d|0)>0)do{e=d;d=d+-1|0;if((c[(c[a+24>>2]|0)+(d*80|0)+64>>2]|0)==(b|0))xe(a,d)}while((e|0)>1);Ab[c[(c[a>>2]|0)+68>>2]&255](a);return}function Bn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;a:do switch(c|0){case 5:case -1:switch(b|0){case 2:{d=+g[a+760>>2];break a}case 4:{d=+g[a+756>>2];break a}case 3:{d=+g[a+752>>2];break a}default:{d=0.0;break a}}default:d=0.0}while(0);return +d}function Cn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;i=i+16|0;c[f>>2]=a;c[f+4>>2]=e;a=c[a+72+((c[(c[b+4>>2]|0)+4>>2]|0)*144|0)+(c[(c[d+4>>2]|0)+4>>2]<<2)>>2]|0;a=Ib[c[(c[a>>2]|0)+8>>2]&31](a,f,b,d)|0;i=f;return a|0}function Dn(a,b){a=a|0;b=b|0;var d=0;a=c[a+64>>2]|0;if(!b)return;d=c[a+16>>2]|0;if(d>>>0<=b>>>0?(d+(_(c[a>>2]|0,c[a+4>>2]|0)|0)|0)>>>0>b>>>0:0){c[b>>2]=c[a+12>>2];c[a+12>>2]=b;c[a+8>>2]=(c[a+8>>2]|0)+1;return}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function En(a){a=a|0;var b=0,d=0;if((c[a+232>>2]|0)<=0)return;b=0;do{d=(c[(c[a+240>>2]|0)+(b<<2)>>2]|0)+412|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;c[d+16>>2]=0;c[d+20>>2]=0;c[d+24>>2]=0;c[d+28>>2]=0;b=b+1|0}while((b|0)<(c[a+232>>2]|0));return}function Fn(a){a=+a;var b=0;c[6435]=(c[6435]|0)+1;b=yc(71)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}c[b+8>>2]=0;c[b+12>>2]=1065353216;c[b+16>>2]=1065353216;c[b+20>>2]=1065353216;g[b+24>>2]=0.0;c[b>>2]=6672;c[b+4>>2]=8;g[b+28>>2]=a;g[b+44>>2]=a;return b|0}function Gn(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=c[a+12>>2]|0;if((d|0)<=0)return;f=0;do{e=c[(c[a+20>>2]|0)+(f<<2)>>2]|0;if(e){Cb[c[(c[e>>2]|0)+16>>2]&127](e,b);d=c[a+12>>2]|0}f=f+1|0}while((f|0)<(d|0));return}function Hn(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;var e=0.0,f=0.0,h=0.0;e=+Q(+(b*.5));b=+R(+(b*.5));f=+Q(+(c*.5));c=+R(+(c*.5));h=+Q(+(d*.5));d=+R(+(d*.5));g[a>>2]=d*f*e-h*c*b;g[a+4>>2]=h*c*e+d*f*b;g[a+8>>2]=h*f*b-d*c*e;g[a+12>>2]=h*f*e+d*c*b;return}function In(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=c[a+32>>2]|0;c[f>>2]=(c[f>>2]|0)+1;Hg(a,Sd(a,b,0)|0);Hg(a,Sd(a,d,0)|0);Hg(a,Sd(a,e,0)|0);return}function Jn(a,b,d){a=a|0;b=b|0;d=d|0;c[a+52>>2]=c[b>>2];c[a+52+4>>2]=c[b+4>>2];c[a+52+8>>2]=c[b+8>>2];c[a+52+12>>2]=c[b+12>>2];c[a+68>>2]=c[d>>2];c[a+68+4>>2]=c[d+4>>2];c[a+68+8>>2]=c[d+8>>2];c[a+68+12>>2]=c[d+12>>2];c[a+48>>2]=1;return}function Kn(a,b,d){a=a|0;b=+b;d=+d;var e=0;e=i;i=i+32|0;g[e+20>>2]=b;g[e+16>>2]=d;g[e+12>>2]=0.0;g[e+8>>2]=1.0;c[a+444>>2]=c[(b<0.0?e+12|0:b>1.0?e+8|0:e+20|0)>>2];g[e+4>>2]=0.0;g[e>>2]=1.0;c[a+448>>2]=c[(d<0.0?e+4|0:d>1.0?e:e+16|0)>>2];i=e;return}function Ln(){var a=0,b=0;while(1){a=yc(196)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6){Zh(a,0);return a|0}return 0}function Mn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;c[d>>2]=c[b+16>>2];c[d+4>>2]=c[b+16+4>>2];c[d+8>>2]=c[b+16+8>>2];c[d+12>>2]=c[b+16+12>>2];c[e>>2]=c[b+32>>2];c[e+4>>2]=c[b+32+4>>2];c[e+8>>2]=c[b+32+8>>2];c[e+12>>2]=c[b+32+12>>2];return}function Nn(a,b,c,d,e,f){a=a|0;b=+b;c=+c;d=+d;e=+e;f=+f;g[a+692>>2]=(c-b)*.5;b=+eh((c-b)*.5+b,6.2831854820251465);if(!(b<-3.1415927410125732)){if(b>3.1415927410125732)b=b+-6.2831854820251465}else b=b+6.2831854820251465;g[a+688>>2]=b;g[a+696>>2]=d;g[a+700>>2]=e;g[a+704>>2]=f;return}function On(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;h=c[a+4>>2]|0;if(!(h&1))i=h>>8;else i=c[(c[e>>2]|0)+(h>>8)>>2]|0;a=c[a>>2]|0;Qb[c[(c[a>>2]|0)+20>>2]&7](a,b,d,e+i|0,h&2|0?f:2,g);return}function Pn(a,b){a=a|0;b=b|0;var d=0;a=c[a+64>>2]|0;d=c[a+8>>2]|0;if(d|0){b=c[a+12>>2]|0;c[a+12>>2]=c[b>>2];c[a+8>>2]=d+-1;return b|0}c[6435]=(c[6435]|0)+1;a=yc(b+19|0)|0;if(!a){b=0;return b|0}c[(a+4+15&-16)+-4>>2]=a;b=a+4+15&-16;return b|0}function Qn(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=b+e|0;if((e|0)>=20){d=d&255;g=b&3;h=d|d<<8|d<<16|d<<24;if(g){g=b+4-g|0;while((b|0)<(g|0)){a[b>>0]=d;b=b+1|0}}while((b|0)<(f&~3|0)){c[b>>2]=h;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return b-e|0}function Rn(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=c[b>>2]|0;a=c[d>>2]|0;a=(c[a+236>>2]|0)==4?a:0;if(!((e|0)==0?1:(c[e+236>>2]|0)!=4))ic[c[(c[e>>2]|0)+28>>2]&127](e,d,b);if(!a)return 0;ic[c[(c[a>>2]|0)+28>>2]&127](a,b,d);return 0}function Sn(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if((a|0)==(c[b+8>>2]|0))zl(b,d,e,f);else{a=c[a+8>>2]|0;Qb[c[(c[a>>2]|0)+20>>2]&7](a,b,d,e,f,g)}return}function Tn(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[(c[b>>2]|0)+16>>2]|0;e=Eb[c[(c[a>>2]|0)+16>>2]&127](a)|0;e=Ob[d&63](b,e,1)|0;d=Ob[c[(c[a>>2]|0)+20>>2]&63](a,c[e+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,e,d,1497645650,a);return}function Un(a,b,c,d,e){a=a|0;b=+b;c=+c;d=+d;e=+e;g[a+692>>2]=(c-b)*.5;b=+eh((c-b)*.5+b,6.2831854820251465);if(!(b<-3.1415927410125732)){if(b>3.1415927410125732)b=b+-6.2831854820251465}else b=b+6.2831854820251465;g[a+688>>2]=b;g[a+696>>2]=d;g[a+700>>2]=e;g[a+704>>2]=1.0;return}function Vn(a,b,d){a=a|0;b=b|0;d=d|0;c[b>>2]=c[a+52>>2];c[b+4>>2]=c[a+52+4>>2];c[b+8>>2]=c[a+52+8>>2];c[b+12>>2]=c[a+52+12>>2];c[d>>2]=c[a+68>>2];c[d+4>>2]=c[a+68+4>>2];c[d+8>>2]=c[a+68+8>>2];c[d+12>>2]=c[a+68+12>>2];return}function Wn(a){a=a|0;var b=0,d=0,e=0;b=c[a+24>>2]|0;if((b|0)<=0)return;e=0;do{d=c[(c[a+32>>2]|0)+(e<<2)>>2]|0;switch(c[d+216>>2]|0){case 2:case 5:break;default:{Bg(d);b=c[a+24>>2]|0}}e=e+1|0}while((e|0)<(b|0));return}function Xn(a,b){a=a|0;b=b|0;var d=0,e=0;e=Eb[c[(c[a>>2]|0)+16>>2]&127](a)|0;e=Ob[c[(c[b>>2]|0)+16>>2]&63](b,e,1)|0;d=Ob[c[(c[a>>2]|0)+20>>2]&63](a,c[e+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,e,d,1245859651,a);return}function Yn(a,b,d){a=a|0;b=b|0;d=d|0;c[b>>2]=c[a+8>>2];c[b+4>>2]=c[a+8+4>>2];c[b+8>>2]=c[a+8+8>>2];c[b+12>>2]=c[a+8+12>>2];c[d>>2]=c[a+24>>2];c[d+4>>2]=c[a+24+4>>2];c[d+8>>2]=c[a+24+8>>2];c[d+12>>2]=c[a+24+12>>2];return}function Zn(a,b){a=a|0;b=b|0;var d=0,e=0;e=Eb[c[(c[a>>2]|0)+52>>2]&127](a)|0;e=Ob[c[(c[b>>2]|0)+16>>2]&63](b,e,1)|0;d=Ob[c[(c[a>>2]|0)+56>>2]&63](a,c[e+8>>2]|0,b)|0;yb[c[(c[b>>2]|0)+20>>2]&31](b,e,d,1346455635,a);return}function _n(){var a=0,b=0;while(1){a=yc(4)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6){c[a>>2]=2920;return a|0}return 0}function $n(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=c[a+4>>2]|0;if(!(g&1))h=g>>8;else h=c[(c[d>>2]|0)+(g>>8)>>2]|0;a=c[a>>2]|0;yb[c[(c[a>>2]|0)+24>>2]&31](a,b,d+h|0,g&2|0?e:2,f);return}function ao(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;a=Zb[c[(c[a>>2]|0)+56>>2]&31](a,156)|0;Wj(a,b,d,e,1);return a|0}function bo(b){b=b|0;var d=0;c[b>>2]=5044;d=c[b+276>>2]|0;if(d|0){if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+276>>2]=0}a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;c[b+272>>2]=0;c[b>>2]=5008;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function co(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0;e=+g[a+344>>2];d=+g[b+4>>2]*+g[a+352>>2]*e;c=+g[b+8>>2]*+g[a+356>>2]*e;g[a+312>>2]=+g[a+312>>2]+ +g[b>>2]*+g[a+348>>2]*e;g[a+316>>2]=+g[a+316>>2]+d;g[a+320>>2]=+g[a+320>>2]+c;return}function eo(b){b=b|0;var d=0;c[b>>2]=4108;d=c[b+496>>2]|0;if(d|0){if(a[b+500>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+496>>2]=0}a[b+500>>0]=1;c[b+496>>2]=0;c[b+488>>2]=0;c[b+492>>2]=0;c[b>>2]=5008;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function fo(a,b,d){a=a|0;b=b|0;d=d|0;c[b>>2]=c[a+892>>2];c[b+4>>2]=c[a+892+4>>2];c[b+8>>2]=c[a+892+8>>2];c[b+12>>2]=c[a+892+12>>2];c[d>>2]=c[a+908>>2];c[d+4>>2]=c[a+908+4>>2];c[d+8>>2]=c[a+908+8>>2];c[d+12>>2]=c[a+908+12>>2];return}function go(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0;c[6435]=(c[6435]|0)+1;i=yc(783)|0;if(!i)i=0;else{c[(i+4+15&-16)+-4>>2]=i;i=i+4+15&-16}ne(i,a,b,d,e,f,g,h);return i|0}function ho(a,b){a=a|0;b=b|0;var c=0.0,d=0;d=0;while(1){if((d|0)==3)break;c=+eh(+g[b+(d<<2)>>2],6.2831854820251465);if(!(c<-3.1415927410125732)){if(c>3.1415927410125732)c=c+-6.2831854820251465}else c=c+6.2831854820251465;g[a+868+(d<<6)+4>>2]=c;d=d+1|0}return}function io(b){b=b|0;var d=0;d=i;i=i+16|0;if((a[22472]|0)==0?Wa(22472)|0:0)_a(22472);Cb[c[(c[b>>2]|0)+76>>2]&127](d,b);c[5726]=c[d>>2];c[5727]=c[d+4>>2];c[5728]=c[d+8>>2];c[5729]=c[d+12>>2];i=d;return 22904}function jo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0;a:do if((c|0)==-1)switch(b|0){case 2:case 1:{d=+g[a+336>>2];break a}case 4:case 3:{d=+g[a+340>>2];break a}default:{d=3402823466385288598117041.0e14;break a}}else d=3402823466385288598117041.0e14;while(0);return +d}function ko(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;a=Zb[c[(c[a>>2]|0)+56>>2]&31](a,156)|0;Wj(a,b,d,e,0);return a|0}function lo(b){b=b|0;var d=0;d=i;i=i+16|0;if((a[22432]|0)==0?Wa(22432)|0:0)_a(22432);Cb[c[(c[b>>2]|0)+76>>2]&127](d,b);c[5669]=c[d>>2];c[5670]=c[d+4>>2];c[5671]=c[d+8>>2];c[5672]=c[d+12>>2];i=d;return 22676}function mo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0;f=+g[b+28>>2];e=+g[b+32>>2];e=+g[c+4>>2]>=0.0?e:-e;d=+g[b+36>>2];d=+g[c+8>>2]>=0.0?d:-d;g[a>>2]=+g[c>>2]>=0.0?f:-f;g[a+4>>2]=e;g[a+8>>2]=d;g[a+12>>2]=0.0;return}function no(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=c[a+4>>2]|0;if(!(f&1))g=f>>8;else g=c[(c[d>>2]|0)+(f>>8)>>2]|0;a=c[a>>2]|0;mc[c[(c[a>>2]|0)+28>>2]&127](a,b,d+g|0,f&2|0?e:2);return}function oo(b){b=b|0;var d=0;c[b>>2]=4872;d=c[b+140>>2]|0;if(d|0){if(a[b+144>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+140>>2]=0}a[b+144>>0]=1;c[b+140>>2]=0;c[b+132>>2]=0;c[b+136>>2]=0;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function po(a,b){a=a|0;b=b|0;var c=0.0,d=0;d=0;while(1){if((d|0)==3)break;c=+eh(+g[b+(d<<2)>>2],6.2831854820251465);if(!(c<-3.1415927410125732)){if(c>3.1415927410125732)c=c+-6.2831854820251465}else c=c+6.2831854820251465;g[a+868+(d<<6)>>2]=c;d=d+1|0}return}function qo(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;a=Zb[c[(c[a>>2]|0)+56>>2]&31](a,44)|0;Nm(a,b,d,e,1);return a|0}function ro(a,b){a=a|0;b=b|0;var d=0;d=c[a+4>>2]|0;if((c[b>>2]|0)!=(d|0)?(c[b+4>>2]|0)!=(d|0):0)return 0;d=c[a+8>>2]|0;ic[c[(c[d>>2]|0)+32>>2]&127](d,b,c[a+12>>2]|0);return 0}function so(b){b=b|0;var d=0;c[b>>2]=9368;d=c[b+32>>2]|0;if(d|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function to(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;c[6435]=(c[6435]|0)+1;e=yc(343)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}je(e,a,b,d);return e|0}function uo(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;a=Zb[c[(c[a>>2]|0)+56>>2]&31](a,44)|0;Nm(a,b,d,e,0);return a|0}function vo(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;c[6435]=(c[6435]|0)+1;h=yc(783)|0;if(!h)h=0;else{c[(h+4+15&-16)+-4>>2]=h;h=h+4+15&-16}ne(h,a,b,d,e,f,g,0);return h|0}function wo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=Zb[c[(c[d>>2]|0)+40>>2]&31](d,a)|0;f=Zb[c[(c[d>>2]|0)+28>>2]&31](d,e)|0;c[b>>2]=f;if(f|0)Cb[c[(c[d>>2]|0)+48>>2]&127](d,e);c[b+4>>2]=c[a+4>>2];return 17222}function xo(){var a=0,b=0;while(1){a=yc(1)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6)return a|0;return 0}function yo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0;h=c[a+104>>2]|0;f=+g[h+(b<<4)+4>>2]*+g[a+16>>2];e=+g[h+(b<<4)+8>>2]*+g[a+20>>2];g[d>>2]=+g[h+(b<<4)>>2]*+g[a+12>>2];g[d+4>>2]=f;g[d+8>>2]=e;g[d+12>>2]=0.0;return}function zo(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;f=c[d>>2]|0;f=Zb[c[(c[f>>2]|0)+56>>2]&31](f,20)|0;b=a[b+4>>0]|0;c[f+4>>2]=c[d>>2];c[f>>2]=3612;a[f+16>>0]=b;return f|0}function Ao(a,b,d){a=a|0;b=b|0;d=d|0;c[a+164>>2]=c[b>>2];c[a+164+4>>2]=c[b+4>>2];c[a+164+8>>2]=c[b+8>>2];c[a+164+12>>2]=c[b+12>>2];if((!(+g[b>>2]!=1.0)?!(+g[b+4>>2]!=1.0):0)?!(+g[b+8>>2]!=1.0):0)d=0;c[a+180>>2]=d;return}function Bo(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;c[6435]=(c[6435]|0)+1;g=yc(1331)|0;if(!g)g=0;else{c[(g+4+15&-16)+-4>>2]=g;g=g+4+15&-16}Le(g,a,b,d,e,f);return g|0}function Co(b){b=b|0;var d=0;d=i;i=i+16|0;if((a[22488]|0)==0?Wa(22488)|0:0)_a(22488);Wg(b,d);c[5751]=c[d>>2];c[5752]=c[d+4>>2];c[5753]=c[d+8>>2];c[5754]=c[d+12>>2];i=d;return 23004}function Do(){var a=0,b=0;while(1){a=yc(64)|0;if(a|0){b=6;break}a=c[6564]|0;c[6564]=a+0;if(!a){b=5;break}jc[a&3]()}if((b|0)==5){b=Ya(4)|0;c[b>>2]=9640;pb(b|0,2800,251)}else if((b|0)==6)return a|0;return 0}function Eo(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function Fo(b){b=b|0;var d=0;d=a[b+74>>0]|0;a[b+74>>0]=d+255|d;d=c[b>>2]|0;if(!(d&8)){c[b+8>>2]=0;c[b+4>>2]=0;d=c[b+44>>2]|0;c[b+28>>2]=d;c[b+20>>2]=d;c[b+16>>2]=d+(c[b+48>>2]|0);d=0}else{c[b>>2]=d|32;d=-1}return d|0}function Go(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;if((e|0)!=-1)return;switch(b|0){case 2:case 1:{g[a+336>>2]=d;c[a+332>>2]=c[a+332>>2]|1;return}case 4:case 3:{g[a+340>>2]=d;c[a+332>>2]=c[a+332>>2]|2;return}default:return}}function Ho(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0;c[6435]=(c[6435]|0)+1;g=yc(135)|0;if(!g)g=0;else{c[(g+4+15&-16)+-4>>2]=g;g=g+4+15&-16}pe(g,a,b,d&65535,e,f);return g|0}function Io(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;if((b|0)==(d|0))return;e=c[(c[a+4>>2]|0)+136>>2]|0;Ob[c[(c[e>>2]|0)+8>>2]&63](e,c[b+36>>2]|0,c[d+36>>2]|0)|0;a=(c[a+4>>2]|0)+160|0;c[a>>2]=(c[a>>2]|0)+1;return}function Jo(a){a=a|0;var b=0,d=0.0,e=0.0,f=0.0;b=i;i=i+32|0;ic[c[(c[a>>2]|0)+12>>2]&127](a,b+8|0,b);f=+g[b+8>>2];e=+g[b+8+4>>2];d=+g[b+8+8>>2];d=+O(+(f*f+e*e+d*d));i=b;return +(d+ +g[b>>2])}function Ko(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+g[b+4>>2]*+g[a+352>>2];c=+g[b+8>>2]*+g[a+356>>2];g[a+412>>2]=+g[a+412>>2]+ +g[b>>2]*+g[a+348>>2];g[a+416>>2]=+g[a+416>>2]+d;g[a+420>>2]=+g[a+420>>2]+c;return}function Lo(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;if((e|0)>0)a=0;else return;do{b=d+(a<<4)|0;a=a+1|0;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0}while((a|0)!=(e|0));return}function Mo(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;i=i+16|0;c[f>>2]=5204;c[f+4>>2]=d;c[f+8>>2]=a;ic[c[(c[b>>2]|0)+48>>2]&127](b,f,e);i=f;return}function No(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+g[b+4>>2]*+g[a+548>>2];c=+g[b+8>>2]*+g[a+552>>2];g[a+428>>2]=+g[a+428>>2]+ +g[b>>2]*+g[a+544>>2];g[a+432>>2]=+g[a+432>>2]+d;g[a+436>>2]=+g[a+436>>2]+c;return}function Oo(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0,f=0.0;f=+g[a>>2];e=+g[a+4>>2];d=+g[a+8>>2];c=+g[a+12>>2];b=1.0/+O(+(f*f+e*e+d*d+c*c));g[a>>2]=f*b;g[a+4>>2]=e*b;g[a+8>>2]=d*b;g[a+12>>2]=c*b;return}function Po(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;c[6435]=(c[6435]|0)+1;f=yc(135)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}pe(f,a,b,d&65535,e,0);return f|0}function Qo(a,b,d){a=a|0;b=b|0;d=d|0;a=c[b+8>>2]|0;if(!((d|0)!=0&(a|0)!=0))return;Ab[c[c[a>>2]>>2]&255](a);Cb[c[(c[d>>2]|0)+60>>2]&127](d,c[b+8>>2]|0);c[b+8>>2]=0;return}function Ro(b){b=b|0;var d=0;c[b>>2]=5044;d=c[b+276>>2]|0;if(d|0){if(a[b+280>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+276>>2]=0}a[b+280>>0]=1;c[b+276>>2]=0;c[b+268>>2]=0;c[b+272>>2]=0;c[b>>2]=5008;return}function So(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;i=i+16|0;c[e>>2]=8820;c[e+4>>2]=b;c[e+8>>2]=a;c[e+12>>2]=d;ic[c[(c[a>>2]|0)+48>>2]&127](a,e,d);i=e;return}function To(b){b=b|0;var d=0;c[b>>2]=6772;if(a[b+61>>0]|0?(d=c[b+52>>2]|0,Ab[c[c[d>>2]>>2]&255](d),d=c[b+52>>2]|0,d|0):0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function Uo(b){b=b|0;var d=0;c[b>>2]=4108;d=c[b+496>>2]|0;if(d|0){if(a[b+500>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+496>>2]=0}a[b+500>>0]=1;c[b+496>>2]=0;c[b+488>>2]=0;c[b+492>>2]=0;c[b>>2]=5008;return}function Vo(a){a=a|0;var b=0.0,d=0,e=0,f=0.0;e=c[a+712>>2]|0;if((e|0)<=0){b=0.0;return +b}a=c[a+720>>2]|0;d=0;b=0.0;do{f=+g[a+(d*104|0)+88>>2];b=b+(f>0.0?1.0/f:0.0);d=d+1|0}while((d|0)!=(e|0));return +b}function Wo(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;c[6435]=(c[6435]|0)+1;e=yc(1331)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}qe(e,a,b,d);return e|0}function Xo(b){b=b|0;var d=0;c[b>>2]=4872;d=c[b+140>>2]|0;if(d|0){if(a[b+144>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+140>>2]=0}a[b+144>>0]=1;c[b+140>>2]=0;c[b+132>>2]=0;c[b+136>>2]=0;return}function Yo(a){a=a|0;var b=0;c[a>>2]=5508;c[a+12>>2]=5536;b=c[a+60>>2]|0;Cb[c[(c[b>>2]|0)+20>>2]&127](b,c[a+76>>2]|0);b=c[a+60>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,c[a+76>>2]|0);hd(a);return}function Zo(a,b,d){a=a|0;b=+b;d=d|0;b=b*.4000000059604645*+Sb[c[(c[a>>2]|0)+48>>2]&15](a);b=b*+Sb[c[(c[a>>2]|0)+48>>2]&15](a);g[d>>2]=b;g[d+4>>2]=b;g[d+8>>2]=b;g[d+12>>2]=0.0;return}function _o(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;a=Zb[c[(c[a>>2]|0)+56>>2]&31](a,24)|0;c[a+4>>2]=c[b>>2];c[a>>2]=4080;return a|0}function $o(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;c[6435]=(c[6435]|0)+1;e=yc(95)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}Ze(e,a,b,d);return e|0}function ap(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;c[6435]=(c[6435]|0)+1;e=yc(135)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}pe(e,a,b,d&65535,0,0);return e|0}function bp(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;c[d>>2]=-581039253;c[d+4>>2]=-581039253;c[d+8>>2]=-581039253;g[d+12>>2]=0.0;c[e>>2]=1566444395;c[e+4>>2]=1566444395;c[e+8>>2]=1566444395;g[e+12>>2]=0.0;return}function cp(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;c[6435]=(c[6435]|0)+1;f=yc(1271)|0;if(!f)f=0;else{c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16}Kc(f,a,b,d,e);return f|0}function dp(b){b=b|0;var d=0;c[b>>2]=8840;if(a[b+192>>0]|0?(d=c[b+136>>2]|0,Ab[c[c[d>>2]>>2]&255](d),d=c[b+136>>2]|0,d|0):0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}pi(b+64|0);pi(b+4|0);return}function ep(b){b=b|0;var d=0;c[b>>2]=9368;d=c[b+32>>2]|0;if(d|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;return}function fp(a){a=a|0;var b=0;c[a>>2]=5508;c[a+12>>2]=5536;b=c[a+60>>2]|0;Cb[c[(c[b>>2]|0)+20>>2]&127](b,c[a+76>>2]|0);b=c[a+60>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,c[a+76>>2]|0);return}function gp(b){b=b|0;var d=0;c[b>>2]=2996;d=c[b+32>>2]|0;if(d|0){if(a[b+36>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+32>>2]=0}a[b+36>>0]=1;c[b+32>>2]=0;c[b+24>>2]=0;c[b+28>>2]=0;return}function hp(a){a=a|0;var b=0,d=0;c[a>>2]=7124;b=c[a+52>>2]|0;if(b|0?(Ab[c[c[b>>2]>>2]&255](b),d=c[a+52>>2]|0,d|0):0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function ip(a,b){a=a|0;b=b|0;var d=0;d=(c[a+92>>2]|0)+4|0;c[d>>2]=c[b>>2];c[d+4>>2]=c[b+4>>2];c[d+8>>2]=c[b+8>>2];c[d+12>>2]=c[b+12>>2];vj(a);return}function jp(b,d){b=b|0;d=d|0;var e=0;if(a[b+273>>0]|0?(e=c[b+200>>2]|0,e|0):0){c[6436]=(c[6436]|0)+1;hd(c[e+-4>>2]|0)}a[b+273>>0]=0;c[b+200>>2]=d;c[(c[b+196>>2]|0)+8>>2]=d;return}function kp(b){b=b|0;var d=0;c[b>>2]=5132;d=c[b+20>>2]|0;if(d|0){if(a[b+24>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+20>>2]=0}a[b+24>>0]=1;c[b+20>>2]=0;c[b+12>>2]=0;c[b+16>>2]=0;return}function lp(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;a=c[b>>2]|0;a=Zb[c[(c[a>>2]|0)+56>>2]&31](a,8)|0;c[a+4>>2]=c[b>>2];c[a>>2]=9228;return a|0}function mp(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;c[6435]=(c[6435]|0)+1;e=yc(783)|0;if(!e)e=0;else{c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16}Jf(e,a,b,d);return e|0}function np(b){b=b|0;var d=0;c[b>>2]=8584;d=c[b+16>>2]|0;if(d|0){if(a[b+20>>0]|0){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+16>>2]=0}a[b+20>>0]=1;c[b+16>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;return}function op(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;a=c[b+8>>2]|0;b=c[a+284>>2]|0;ic[c[(c[b>>2]|0)+40>>2]&127](b,a,c[d+8>>2]|0);return}function pp(a,b){a=a|0;b=b|0;var d=0;c[6435]=(c[6435]|0)+1;d=yc(95)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}Ze(d,a,b,1);return d|0}function qp(b,d){b=b|0;d=d|0;if((a[22448]|0)==0?Wa(22448)|0:0)_a(22448);c[5694]=c[b+(d<<4)>>2];c[5695]=c[b+(d<<4)+4>>2];c[5696]=c[b+(d<<4)+8>>2];c[5697]=c[b+(d<<4)+12>>2];return 22776}function rp(b){b=b|0;var d=0;if(!b)return;d=c[b+68>>2]|0;if(d|0){if(!((a[b+72>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+68>>2]=0}a[b+72>>0]=1;hd(b);return}function sp(b){b=b|0;var d=0;c[b>>2]=6772;if(!(a[b+61>>0]|0))return;d=c[b+52>>2]|0;Ab[c[c[d>>2]>>2]&255](d);b=c[b+52>>2]|0;if(!b)return;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function tp(a,b,d){a=a|0;b=b|0;d=d|0;a=c[b+204>>2]|0;if(a&4|0){d=0;return d|0}b=c[d+204>>2]|0;if(b&4|0){d=0;return d|0}if(!(a&3)){d=1;return d|0}d=(b&3|0)==0;return d|0}function up(a,b){a=a|0;b=b|0;var d=0;c[6435]=(c[6435]|0)+1;d=yc(135)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}pe(d,a,b,16384,0,0);return d|0}function vp(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;i=i+16|0;c[e>>2]=8800;c[e+4>>2]=b;ic[c[(c[a>>2]|0)+48>>2]&127](a,e,d);i=e;return}function wp(b){b=b|0;var d=0,e=0;c[b>>2]=6004;if(!(a[b+8>>0]|0)){hd(b);return}d=c[b+12>>2]|0;if(!d){hd(b);return}e=c[b+4>>2]|0;Cb[c[(c[e>>2]|0)+16>>2]&127](e,d);hd(b);return}function xp(a){a=a|0;var b=0;c[6435]=(c[6435]|0)+1;b=yc(75)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}hi(b,a);c[b>>2]=8348;c[b+52>>2]=2;return b|0}function yp(a){a=a|0;var b=0;c[6435]=(c[6435]|0)+1;b=yc(75)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}hi(b,a);c[b>>2]=8244;c[b+52>>2]=0;return b|0}function zp(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;c[d>>2]=c[a+60>>2];a=qb(6,d|0)|0;if(a>>>0>4294963200){if(!0)b=25748;else b=c[(ib()|0)+64>>2]|0;c[b>>2]=0-a;a=-1}i=d;return a|0}function Ap(b){b=b|0;var d=0,e=0;c[b>>2]=9256;if(!(a[b+8>>0]|0)){hd(b);return}d=c[b+12>>2]|0;if(!d){hd(b);return}e=c[b+4>>2]|0;Cb[c[(c[e>>2]|0)+16>>2]&127](e,d);hd(b);return}function Bp(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;if((c|0)<(b|0)&(b|0)<(c+d|0)){e=b;c=c+d|0;b=b+d|0;while((d|0)>0){b=b-1|0;c=c-1|0;d=d-1|0;a[b>>0]=a[c>>0]|0}b=e}else _m(b,c,d)|0;return b|0}function Cp(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=_(b&65535,a&65535)|0;e=(c>>>16)+(_(b&65535,a>>>16)|0)|0;d=_(b>>>16,a&65535)|0;return (C=(e>>>16)+(_(b>>>16,a>>>16)|0)+(((e&65535)+d|0)>>>16)|0,e+d<<16|c&65535|0)|0}function Dp(b){b=b|0;var d=0,e=0;c[b>>2]=5480;if(!(a[b+8>>0]|0)){hd(b);return}d=c[b+12>>2]|0;if(!d){hd(b);return}e=c[b+4>>2]|0;Cb[c[(c[e>>2]|0)+16>>2]&127](e,d);hd(b);return}function Ep(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if((a|0)==(c[b+8>>2]|0))zl(b,d,e,f);return}function Fp(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0;e=+N(+(+g[b>>2]));d=+N(+(+g[b+4>>2]));c=+N(+(+g[b+8>>2]));g[a+12>>2]=e;g[a+16>>2]=d;g[a+20>>2]=c;g[a+24>>2]=0.0;return}function Gp(a,b){a=a|0;b=b|0;var d=0;c[6435]=(c[6435]|0)+1;d=yc(783)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}Jf(d,a,b,0);return d|0}function Hp(a,b){a=a|0;b=b|0;Vf(a,c[b+36>>2]|0);return}function Ip(b){b=b|0;var d=0;if(!b)return;d=c[b+12>>2]|0;if(d|0){if(!((a[b+16>>0]&1)==0|(d|0)==0)){c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0)}c[b+12>>2]=0}a[b+16>>0]=1;hd(b);return}function Jp(b){b=b|0;var d=0,e=0;c[b>>2]=5576;if(!(a[b+8>>0]|0)){hd(b);return}d=c[b+12>>2]|0;if(!d){hd(b);return}e=c[b+4>>2]|0;Cb[c[(c[e>>2]|0)+16>>2]&127](e,d);hd(b);return}function Kp(a){a=a|0;var b=0;c[a>>2]=5536;b=c[a+48>>2]|0;Cb[c[(c[b>>2]|0)+20>>2]&127](b,c[a+64>>2]|0);b=c[a+48>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,c[a+64>>2]|0);hd(a);return}function Lp(a,b,c,d,e,f,g,h,i,j,k,l,m){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;g=+g;h=+h;i=+i;j=+j;k=k|0;l=+l;m=m|0;dc[a&0](b|0,c|0,d|0,e|0,+f,+g,+h,+i,+j,k|0,+l,m|0)}function Mp(b){b=b|0;var d=0,e=0;c[b>>2]=6052;if(!(a[b+16>>0]|0)){hd(b);return}d=c[b+20>>2]|0;if(!d){hd(b);return}e=c[b+4>>2]|0;Cb[c[(c[e>>2]|0)+16>>2]&127](e,d);hd(b);return}function Np(a,b,d,e){a=+a;b=+b;d=+d;e=+e;var f=0;c[6435]=(c[6435]|0)+1;f=yc(35)|0;c[(f+4+15&-16)+-4>>2]=f;f=f+4+15&-16;g[f>>2]=a;g[f+4>>2]=b;g[f+8>>2]=d;g[f+12>>2]=e;return f|0}function Op(a){a=a|0;var b=0;c[a>>2]=7124;b=c[a+52>>2]|0;if(!b)return;Ab[c[c[b>>2]>>2]&255](b);b=c[a+52>>2]|0;if(!b)return;c[6436]=(c[6436]|0)+1;hd(c[b+-4>>2]|0);return}function Pp(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;return +(+nb(0,a|0,b|0,c|0,d|0,e|0,f|0,g|0,h|0))}function Qp(a,b){a=a|0;b=b|0;if((b|0)==0?1:(c[b+236>>2]&2|0)==0){Hk(a,b);return}else{Cb[c[(c[a>>2]|0)+92>>2]&127](a,b);return}}function Rp(a){a=a|0;var b=0;c[a>>2]=5536;b=c[a+48>>2]|0;Cb[c[(c[b>>2]|0)+20>>2]&127](b,c[a+64>>2]|0);b=c[a+48>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,c[a+64>>2]|0);return}function Sp(b){b=b|0;var c=0;c=a[m+(b&255)>>0]|0;if((c|0)<8)return c|0;c=a[m+(b>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=a[m+(b>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (a[m+(b>>>24)>>0]|0)+24|0}function Tp(a,b,d){a=+a;b=+b;d=+d;var e=0;c[6435]=(c[6435]|0)+1;e=yc(35)|0;c[(e+4+15&-16)+-4>>2]=e;e=e+4+15&-16;g[e>>2]=a;g[e+4>>2]=b;g[e+8>>2]=d;g[e+12>>2]=0.0;return e|0}function Up(a,b){a=a|0;b=b|0;c[a+12>>2]=c[b>>2];c[a+12+4>>2]=c[b+4>>2];c[a+12+8>>2]=c[b+8>>2];c[a+12+12>>2]=c[b+12>>2];vj(a);return}function Vp(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;return Db[a&3](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0,j|0,k|0)|0}function Wp(a,b){a=a|0;b=b|0;a=c[a+12>>2]|0;return Zb[c[(c[a>>2]|0)+8>>2]&31](a,b)|0}function Xp(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;return +$b[a&3](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0,j|0,k|0)}function Yp(a,b){a=a|0;b=b|0;c[a+260>>2]=(c[a+260>>2]|0)+1;c[a+328>>2]=c[b>>2];c[a+328+4>>2]=c[b+4>>2];c[a+328+8>>2]=c[b+8>>2];c[a+328+12>>2]=c[b+12>>2];return}function Zp(a,b,d){a=a|0;b=b|0;d=d|0;c[d>>2]=c[a+56+(b<<4)>>2];c[d+4>>2]=c[a+56+(b<<4)+4>>2];c[d+8>>2]=c[a+56+(b<<4)+8>>2];c[d+12>>2]=c[a+56+(b<<4)+12>>2];return}function _p(a,b){a=a|0;b=b|0;c[a+260>>2]=(c[a+260>>2]|0)+1;c[a+312>>2]=c[b>>2];c[a+312+4>>2]=c[b+4>>2];c[a+312+8>>2]=c[b+8>>2];c[a+312+12>>2]=c[b+12>>2];return}function $p(a,b,c,d,e,f,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;g=+g;h=+h;i=+i;j=j|0;k=k|0;l=+l;Lb[a&0](b|0,c|0,d|0,e|0,+f,+g,+h,+i,j|0,k|0,+l)}function aq(a,b){a=a|0;b=b|0;c[a+260>>2]=(c[a+260>>2]|0)+1;c[a+544>>2]=c[b>>2];c[a+544+4>>2]=c[b+4>>2];c[a+544+8>>2]=c[b+8>>2];c[a+544+12>>2]=c[b+12>>2];return}function bq(a){a=a|0;var b=0.0,d=0.0;d=+g[a+32>>2];+Sb[c[(c[a>>2]|0)+48>>2]&15](a);b=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);+Sb[c[(c[a>>2]|0)+48>>2]&15](a);return +(d+b)}function cq(a){a=a|0;var b=0.0,d=0.0;d=+g[a+28>>2];b=+Sb[c[(c[a>>2]|0)+48>>2]&15](a);+Sb[c[(c[a>>2]|0)+48>>2]&15](a);+Sb[c[(c[a>>2]|0)+48>>2]&15](a);return +(d+b)}function dq(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;Yb[a&3](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0,j|0,k|0)}function eq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;i=i+16|0;c[e>>2]=c[d>>2];a=Ob[c[(c[a>>2]|0)+16>>2]&63](a,b,e)|0;if(a)c[d>>2]=c[e>>2];i=e;return a&1|0}function fq(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0;e=+g[a>>2];d=+g[a+4>>2];c=+g[a+8>>2];b=1.0/+O(+(e*e+d*d+c*c));g[a>>2]=e*b;g[a+4>>2]=d*b;g[a+8>>2]=c*b;return}function gq(a,b){a=a|0;b=b|0;var d=0;c[6435]=(c[6435]|0)+1;d=yc(191)|0;if(!d)d=0;else{c[(d+4+15&-16)+-4>>2]=d;d=d+4+15&-16}Yf(d,a,b);return d|0}function hq(b){b=b|0;var d=0;c[b>>2]=6004;if(!(a[b+8>>0]|0))return;d=c[b+12>>2]|0;if(!d)return;b=c[b+4>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,d);return}function iq(b){b=b|0;var d=0;c[b>>2]=9256;if(!(a[b+8>>0]|0))return;d=c[b+12>>2]|0;if(!d)return;b=c[b+4>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,d);return}function jq(a,b,c){a=a|0;b=b|0;c=+c;switch(b|0){case 3:{g[a+452>>2]=c;return}case 4:{g[a+448>>2]=c;return}case 5:{g[a+444>>2]=c;return}default:return}}function kq(b){b=b|0;var d=0;c[b>>2]=5480;if(!(a[b+8>>0]|0))return;d=c[b+12>>2]|0;if(!d)return;b=c[b+4>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,d);return}function lq(b){b=b|0;var d=0;c[b>>2]=2996;d=c[b+32>>2]|0;if(!d){hd(b);return}if(!(a[b+36>>0]|0)){hd(b);return}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);hd(b);return}function mq(a,b){a=a|0;b=b|0;a=c[a+4>>2]|0;return ((c[b>>2]|0)==(a|0)?1:(c[b+4>>2]|0)==(a|0))|0}function nq(b){b=b|0;if(a[22512]|0)return 23132;if(!(Wa(22512)|0))return 23132;c[5783]=1065353216;c[5784]=1065353216;c[5785]=1065353216;g[5786]=0.0;_a(22512);return 23132}function oq(a,b){a=a|0;b=b|0;a=c[a+20>>2]|0;return Zb[c[(c[a>>2]|0)+8>>2]&31](a,b)|0}function pq(b){b=b|0;var d=0;c[b>>2]=5132;d=c[b+20>>2]|0;if(!d){hd(b);return}if(!(a[b+24>>0]|0)){hd(b);return}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);hd(b);return}function qq(b){b=b|0;var d=0;c[b>>2]=5576;if(!(a[b+8>>0]|0))return;d=c[b+12>>2]|0;if(!d)return;b=c[b+4>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,d);return}function rq(a){a=a|0;var b=0;c[6435]=(c[6435]|0)+1;b=yc(75)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}hi(b,a);return b|0}function sq(a,d){a=a|0;d=d|0;d=c[d+4>>2]|0;if(!((d&65535&b[a+6>>1])<<16>>16)){a=0;return a|0}a=(b[a+4>>1]&(d>>>16&65535))<<16>>16!=0;return a|0}function tq(a,d){a=a|0;d=d|0;d=c[d+4>>2]|0;if(!((d&65535&b[a+10>>1])<<16>>16)){a=0;return a|0}a=(b[a+8>>1]&(d>>>16&65535))<<16>>16!=0;return a|0}function uq(b){b=b|0;var d=0;c[b>>2]=6052;if(!(a[b+16>>0]|0))return;d=c[b+20>>2]|0;if(!d)return;b=c[b+4>>2]|0;Cb[c[(c[b>>2]|0)+16>>2]&127](b,d);return}function vq(a,b){a=a|0;b=+b;b=+eh(b,6.2831854820251465);if(!(b<-3.1415927410125732)){if(b>3.1415927410125732)b=b+-6.2831854820251465}else b=b+6.2831854820251465;g[a+196>>2]=b;return}function wq(a,b){a=a|0;b=+b;b=+eh(b,6.2831854820251465);if(!(b<-3.1415927410125732)){if(b>3.1415927410125732)b=b+-6.2831854820251465}else b=b+6.2831854820251465;g[a+192>>2]=b;return}function xq(a,d){a=a|0;d=d|0;d=c[d+4>>2]|0;if(!((d&65535&b[a+14>>1])<<16>>16)){a=0;return a|0}a=(b[a+12>>1]&(d>>>16&65535))<<16>>16!=0;return a|0}function yq(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;return gc[a&3](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0,j|0)|0}function zq(b){b=b|0;var d=0;c[b>>2]=8584;d=c[b+16>>2]|0;if(!d){hd(b);return}if(!(a[b+20>>0]|0)){hd(b);return}c[6436]=(c[6436]|0)+1;hd(c[d+-4>>2]|0);hd(b);return}function Aq(a,b){a=a|0;b=b|0;b=c[b+36>>2]|0;Te(a,c[(c[(c[(c[a+4>>2]|0)+4>>2]|0)+24>>2]|0)+(b*80|0)+64>>2]|0,b);return}function Bq(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;return +bc[a&3](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0,j|0)}function Cq(a){a=a|0;var b=0;c[6435]=(c[6435]|0)+1;b=yc(191)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}Yf(b,a,1);return b|0}function Dq(a,b,d,e,f,g,h,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;return +(+Kb[c[(c[a>>2]|0)+12>>2]&1](a,b,d,e,f,g,h,i))}function Eq(){var a=0;c[6435]=(c[6435]|0)+1;a=yc(131)|0;if(!a)a=0;else{c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16}kg(a,0,0,16);return a|0}function Fq(a){a=a|0;var b=0;c[6435]=(c[6435]|0)+1;b=yc(111)|0;if(!b)b=0;else{c[(b+4+15&-16)+-4>>2]=b;b=b+4+15&-16}Sj(b,a);return b|0}function Gq(a,b){a=a|0;b=b|0;Ab[c[(c[b>>2]|0)+32>>2]&255](b);td(a,b);Ab[c[(c[b>>2]|0)+36>>2]&255](b);return}function Hq(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;Xb[a&1](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0,j|0)}function Iq(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;ic[c[(c[a>>2]|0)+108>>2]&127](a,b,d);ic[c[(c[a>>2]|0)+108>>2]&127](a,(b+1|0)%3|0,e);return}function Jq(a,b){a=a|0;b=b|0;c[a+12>>2]=c[b>>2];c[a+12+4>>2]=c[b+4>>2];c[a+12+8>>2]=c[b+8>>2];c[a+12+12>>2]=c[b+12>>2];return}function Kq(a,b){a=a|0;b=b|0;c[a+44>>2]=c[b>>2];c[a+44+4>>2]=c[b+4>>2];c[a+44+8>>2]=c[b+8>>2];c[a+44+12>>2]=c[b+12>>2];return}function Lq(a,b){a=a|0;b=b|0;c[a+696>>2]=c[b>>2];c[a+696+4>>2]=c[b+4>>2];c[a+696+8>>2]=c[b+8>>2];c[a+696+12>>2]=c[b+12>>2];return}function Mq(a,b){a=a|0;b=b|0;c[a+680>>2]=c[b>>2];c[a+680+4>>2]=c[b+4>>2];c[a+680+8>>2]=c[b+8>>2];c[a+680+12>>2]=c[b+12>>2];return}function Nq(a,b){a=a|0;b=b|0;c[a+60>>2]=c[b>>2];c[a+60+4>>2]=c[b+4>>2];c[a+60+8>>2]=c[b+8>>2];c[a+60+12>>2]=c[b+12>>2];return}function Oq(a,b){a=a|0;b=b|0;c[a+28>>2]=c[b>>2];c[a+28+4>>2]=c[b+4>>2];c[a+28+8>>2]=c[b+8>>2];c[a+28+12>>2]=c[b+12>>2];return}function Pq(a,b){a=a|0;b=b|0;c[a+156>>2]=c[b>>2];c[a+156+4>>2]=c[b+4>>2];c[a+156+8>>2]=c[b+8>>2];c[a+156+12>>2]=c[b+12>>2];return}function Qq(b,c,d){b=b|0;c=c|0;d=d|0;a[b+1309+c>>0]=d&1;if((c|0)<3){a[b+788+c>>0]=d&1;return}else{a[b+868+(c+-3<<6)+44>>0]=d&1;return}}function Rq(a,b){a=a|0;b=b|0;c[a+108>>2]=c[b>>2];c[a+108+4>>2]=c[b+4>>2];c[a+108+8>>2]=c[b+8>>2];c[a+108+12>>2]=c[b+12>>2];return}function Sq(){var a=0;c[6435]=(c[6435]|0)+1;a=yc(191)|0;if(!a)a=0;else{c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16}Yf(a,1,1);return a|0}function Tq(){var a=0;c[6435]=(c[6435]|0)+1;a=yc(111)|0;if(!a)a=0;else{c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16}Sj(a,1);return a|0}function Uq(a,b){a=a|0;b=b|0;c[a+20>>2]=c[b>>2];c[a+20+4>>2]=c[b+4>>2];c[a+20+8>>2]=c[b+8>>2];c[a+20+12>>2]=c[b+12>>2];return}function Vq(a){a=a|0;var b=0;do{c[a+4>>2]=0;g[a+8>>2]=0.0;b=c[a+24>>2]|0;if(b|0)Vq(b);a=c[a+28>>2]|0}while((a|0)!=0);return}function Wq(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;Kd(a,b,c,d,e,f);return}function Xq(a,b){a=a|0;b=b|0;c[a+32>>2]=c[b>>2];c[a+32+4>>2]=c[b+4>>2];c[a+32+8>>2]=c[b+8>>2];c[a+32+12>>2]=c[b+12>>2];return}function Yq(a,b){a=a|0;b=b|0;c[a+316>>2]=c[b>>2];c[a+316+4>>2]=c[b+4>>2];c[a+316+8>>2]=c[b+8>>2];c[a+316+12>>2]=c[b+12>>2];return}function Zq(a,b){a=a|0;b=b|0;c[a+300>>2]=c[b>>2];c[a+300+4>>2]=c[b+4>>2];c[a+300+8>>2]=c[b+8>>2];c[a+300+12>>2]=c[b+12>>2];return}function _q(a,b){a=a|0;b=b|0;c[a+24>>2]=c[b>>2];c[a+24+4>>2]=c[b+4>>2];c[a+24+8>>2]=c[b+8>>2];c[a+24+12>>2]=c[b+12>>2];return}function $q(a,b){a=a|0;b=b|0;c[a+64>>2]=c[b>>2];c[a+64+4>>2]=c[b+4>>2];c[a+64+8>>2]=c[b+8>>2];c[a+64+12>>2]=c[b+12>>2];return}function ar(a,b){a=a|0;b=b|0;g[a>>2]=+g[a>>2]-+g[b>>2];g[a+4>>2]=+g[a+4>>2]-+g[b+4>>2];g[a+8>>2]=+g[a+8>>2]-+g[b+8>>2];return a|0}function br(a,b){a=a|0;b=b|0;g[a>>2]=+g[a>>2]+ +g[b>>2];g[a+4>>2]=+g[a+4>>2]+ +g[b+4>>2];g[a+8>>2]=+g[a+8>>2]+ +g[b+8>>2];return a|0}function cr(a,b){a=a|0;b=b|0;c[a+52>>2]=c[b>>2];c[a+52+4>>2]=c[b+4>>2];c[a+52+8>>2]=c[b+8>>2];c[a+52+12>>2]=c[b+12>>2];return}function dr(a,b){a=a|0;b=b|0;c[a+40>>2]=c[b>>2];c[a+40+4>>2]=c[b+4>>2];c[a+40+8>>2]=c[b+8>>2];c[a+40+12>>2]=c[b+12>>2];return}function er(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;return +Kb[a&1](b|0,c|0,d|0,e|0,f|0,g|0,h|0,i|0)}function fr(a,b){a=a|0;b=b|0;c[a+16>>2]=c[b>>2];c[a+16+4>>2]=c[b+4>>2];c[a+16+8>>2]=c[b+8>>2];c[a+16+12>>2]=c[b+12>>2];return}function gr(a,b,d){a=a|0;b=b|0;d=+d;Cb[c[(c[a>>2]|0)+32>>2]&127](a,b);kc[c[(c[a>>2]|0)+36>>2]&7](a,b,d);return}function hr(a,b){a=a|0;b=b|0;c[a+68>>2]=c[b>>2];c[a+68+4>>2]=c[b+4>>2];c[a+68+8>>2]=c[b+8>>2];c[a+68+12>>2]=c[b+12>>2];return}function ir(a,b){a=a|0;b=b|0;c[a+36>>2]=c[b>>2];c[a+36+4>>2]=c[b+4>>2];c[a+36+8>>2]=c[b+8>>2];c[a+36+12>>2]=c[b+12>>2];return}function jr(a,b){a=a|0;b=b|0;c[a>>2]=c[b+248>>2];c[a+4>>2]=c[b+248+4>>2];c[a+8>>2]=c[b+248+8>>2];c[a+12>>2]=c[b+248+12>>2];return}function kr(a,b){a=a|0;b=b|0;c[a+48>>2]=c[b>>2];c[a+48+4>>2]=c[b+4>>2];c[a+48+8>>2]=c[b+8>>2];c[a+48+12>>2]=c[b+12>>2];return}function lr(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;i=i+16|0;$e(a,b,d,e,f|0)|0;i=f;return (C=c[f+4>>2]|0,c[f>>2]|0)|0}function mr(a,b){a=a|0;b=b|0;c[a>>2]=c[b>>2];c[a+4>>2]=c[b+4>>2];c[a+8>>2]=c[b+8>>2];c[a+12>>2]=c[b+12>>2];return}function nr(a,b){a=a|0;b=b|0;c[a+72>>2]=c[b>>2];c[a+72+4>>2]=c[b+4>>2];c[a+72+8>>2]=c[b+8>>2];c[a+72+12>>2]=c[b+12>>2];return}function or(a,b){a=a|0;b=b|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;g[a+(c[b+52>>2]<<2)>>2]=1.0;return}function pr(a){a=a|0;var b=0;b=i;i=i+16|0;hd(a);if(!(ob(c[6563]|0,0)|0)){i=b;return}else ej(21821,b)}function qr(a,b){a=a|0;b=b|0;c[a+8>>2]=c[b>>2];c[a+8+4>>2]=c[b+4>>2];c[a+8+8>>2]=c[b+8>>2];c[a+8+12>>2]=c[b+12>>2];return}function rr(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return rc(b,c,d,e)|0}function sr(){var a=0;c[6435]=(c[6435]|0)+1;a=yc(35)|0;if(!a){a=0;return a|0}c[(a+4+15&-16)+-4>>2]=a;a=a+4+15&-16;return a|0}function tr(a,b){a=a|0;b=b|0;if(!b?c[a+204>>2]&3|0:0)return;if((c[a+216>>2]&-2|0)!=4)c[a+216>>2]=1;g[a+220>>2]=0.0;return}function ur(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a+-4>>2]|0)+8>>2]&127](a+-4|0,b,d,e);return}function vr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=Cp(a,c)|0;f=C;return (C=(_(b,c)|0)+(_(d,a)|0)+f|f&0,e|0|0)|0}function wr(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;Wb[a&1](b|0,c|0,d|0,e|0,f|0,g|0,h|0)}function xr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return}function yr(a){a=a|0;c[a>>2]=3640;c[a+12>>2]=3668;cg(a+12|0);pj(a+72|0);hd(a);return}function zr(a,b){a=a|0;b=b|0;c[a+348>>2]=c[b>>2];c[a+348+4>>2]=c[b+4>>2];c[a+348+8>>2]=c[b+8>>2];return}function Ar(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Qj(a,b,c,d);return}function Br(a,b){a=a|0;b=b|0;c[a>>2]=1065353216;c[a+4>>2]=1065353216;c[a+8>>2]=1065353216;g[a+12>>2]=0.0;return}function Cr(b){b=b|0;if(!(Eb[c[(c[b>>2]|0)+40>>2]&127](b)|0))return;c[b+16>>2]=c[b+28>>2];a[b+169>>0]=1;return}function Dr(a,b){a=a|0;b=b|0;var d=0;d=c[a+8>>2]|0;ic[c[d+60>>2]&127](b,d,c[a+4>>2]|0);return 0}function Er(a,b){a=a|0;b=b|0;var d=0;d=a+92|0;do{c[a>>2]=c[b>>2];a=a+4|0;b=b+4|0}while((a|0)<(d|0));return}function Fr(a,b){a=a|0;b=b|0;c[a+480>>2]=b;if(!b)return;Cb[c[(c[b>>2]|0)+8>>2]&127](b,a+4|0);return}function Gr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Pg(a,b,c,d);return}function Hr(a,b,d){a=a|0;b=b|0;d=d|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=0;c[a+12>>2]=0;return}function Ir(a){a=a|0;c[a>>2]=3640;c[a+12>>2]=3668;cg(a+12|0);pj(a+72|0);return}function Jr(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function Kr(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Tb[a&3](b|0,c|0,d|0,e|0,f|0,g|0)|0}function Lr(a,b,c,d,e){a=a|0;b=+b;c=+c;d=+d;e=+e;g[a>>2]=b;g[a+4>>2]=c;g[a+8>>2]=d;g[a+12>>2]=e;return}function Mr(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){C=b>>c;return a>>>c|(b&(1<>c-32|0}function Nr(a){a=a|0;lg(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Or(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+8>>2]&127](a,b,d,e);return}function Pr(a,b){a=a|0;b=+b;g[a>>2]=+g[a>>2]*b;g[a+4>>2]=+g[a+4>>2]*b;g[a+8>>2]=+g[a+8>>2]*b;return a|0}function Qr(a,b,d){a=a|0;b=b|0;d=d|0;Ae(c[a+116>>2]|0,c[a+144>>2]|0,b,d);return}function Rr(a,b,d){a=a|0;b=b|0;d=d|0;ic[c[(c[b>>2]|0)+64>>2]&127](a,b,d);return}function Sr(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return 0.0}function Tr(a,b,d){a=a|0;b=+b;d=d|0;c[d>>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;return}function Ur(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+80>>2]&127](a,b,d,e);return}function Vr(){var a=0;a=i;i=i+16|0;if(!(mb(26252,255)|0)){i=a;return}else ej(21874,a)}function Wr(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;f=f|0;g=g|0;return +Ub[a&3](b|0,c|0,d|0,+e,f|0,g|0)}function Xr(a){a=a|0;if(c[a+204>>2]&3|0)return;if((c[a+216>>2]&-2|0)!=4)c[a+216>>2]=1;g[a+220>>2]=0.0;return}function Yr(a,b){a=a|0;b=b|0;a=c[a+4>>2]|0;Zb[c[(c[a>>2]|0)+8>>2]&31](a,c[b+36>>2]|0)|0;return}function Zr(a){a=a|0;var b=0.0,c=0.0,d=0.0;d=+g[a>>2];c=+g[a+4>>2];b=+g[a+8>>2];return +(+O(+(d*d+c*c+b*b)))}function _r(a,b){a=a|0;b=b|0;c[a+260>>2]=(c[a+260>>2]|0)+1;c[a+192>>2]=b;c[a+200>>2]=b;return}function $r(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;Qb[a&7](b|0,c|0,d|0,e|0,f|0,g|0)}function as(a,b,c,d,e,f,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;f=+f;g=+g;h=+h;i=+i;j=j|0;k=+k;l=l|0;ba(33)}function bs(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function cs(b,c,d,e){b=b|0;c=c|0;d=+d;e=+e;a[b+737>>0]=c&1;g[b+680>>2]=d;g[b+684>>2]=e;return}function ds(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+88>>2]&127](a,b,d,e);return}function es(a,b,d){a=a|0;b=b|0;d=d|0;ic[c[(c[b>>2]|0)+68>>2]&127](a,b,d);return}function fs(b,d){b=b|0;d=d|0;b=(a[b+344>>0]|0)==0?3:0;c[d>>2]=b;c[d+4>>2]=b;return}function gs(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+36>>2]&127](a,b,d,e);return}function hs(a,b,d){a=a|0;b=+b;d=d|0;return lc[c[(c[a>>2]|0)+52>>2]&1](a,b,d,.01666666753590107)|0}function is(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){C=b<>>32-c;return a<>2]=0;c[d+4>>2]=0;c[d+8>>2]=0;c[d+12>>2]=0;return}function ks(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;g[a>>2]=b;g[a+4>>2]=c;g[a+8>>2]=d;g[a+12>>2]=0.0;return}function ls(a,b,d,e){a=a|0;b=+b;d=d|0;e=+e;return lc[c[(c[a>>2]|0)+52>>2]&1](a,b,d,e)|0}function ms(a,b){a=a|0;b=b|0;c[a>>2]=0;c[a+4>>2]=0;c[a+8>>2]=1065353216;g[a+12>>2]=0.0;return}function ns(a,b){a=a|0;b=b|0;c[a>>2]=1065353216;c[a+4>>2]=0;c[a+8>>2]=0;g[a+12>>2]=0.0;return}function os(a,b){a=a|0;b=b|0;c[a>>2]=0;c[a+4>>2]=1065353216;c[a+8>>2]=0;g[a+12>>2]=0.0;return}function ps(a,b){a=a|0;b=b|0;ic[c[(c[a>>2]|0)+8>>2]&127](a,b,c[(c[a+8>>2]|0)+48>>2]|0);return}function qs(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=+g;Pb[a&0](b|0,c|0,d|0,e|0,f|0,+g)}function rs(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;f=f|0;g=g|0;Bb[a&0](b|0,c|0,d|0,+e,f|0,g|0)}function ss(b,d,e){b=b|0;d=d|0;e=+e;g[(c[b+720>>2]|0)+(d*104|0)+88>>2]=e>0.0?1.0/e:0.0;a[b+924>>0]=1;return}function ts(a,b,d){a=a|0;b=b|0;d=+d;kc[c[(c[a>>2]|0)+20>>2]&7](a,b,d);return}function us(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){C=b>>>c;return a>>>c|(b&(1<>>c-32|0}function vs(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+124>>2]&127](a,e,b,d);return}function ws(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;c[a+120>>2]=b;c[a+124>>2]=d;c[a+128>>2]=e;return}function xs(a,b){a=a|0;b=b|0;return +(+g[a>>2]*+g[b>>2]+ +g[a+4>>2]*+g[b+4>>2]+ +g[a+8>>2]*+g[b+8>>2])}function ys(a){a=a|0;qk(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function zs(a){a=a|0;Tl(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function As(a,b,c,d,e,f,g){a=a|0;b=b|0;c=+c;d=+d;e=e|0;f=f|0;g=g|0;Gb[a&0](b|0,+c,+d,e|0,f|0,g|0)}function Bs(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;ba(29);return 0.0}function Cs(a,b,d){a=a|0;b=b|0;d=d|0;mc[c[(c[a>>2]|0)+36>>2]&127](a,b,d,-3);return}function Ds(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return 1.0}function Es(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return}function Fs(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;mc[c[(c[a>>2]|0)+32>>2]&127](a,b,d,e);return}function Gs(a){a=a|0;Sg(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Hs(){}function Is(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return (C=d,a-c>>>0|0)|0}function Js(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Rf(a,b,c,d,e);return}function Ks(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Zf(a,b,c,d,e);return}function Ls(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;ba(5);return 0}function Ms(a,b){a=a|0;b=b|0;Yd(a,b);return}function Ns(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;f=+f;g=+g;h=+h;i=i|0;j=j|0;k=+k;ba(13)}function Os(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return +Mb[a&15](b|0,c|0,d|0,e|0,f|0)}function Ps(a,b,d){a=a|0;b=b|0;d=d|0;mc[c[(c[a>>2]|0)+36>>2]&127](a,b,d,-1);return}function Qs(a,b){a=a|0;b=+b;return lc[c[(c[a>>2]|0)+52>>2]&1](a,b,1,.01666666753590107)|0}function Rs(a,b,d){a=a|0;b=b|0;d=d|0;ic[c[(c[a>>2]|0)+56>>2]&127](a,b,d);return}function Ss(a){a=a|0;c[a>>2]=3668;cg(a);pj(a+60|0);hd(a);return}function Ts(a,b,d){a=a|0;b=b|0;d=+d;kc[c[(c[a>>2]|0)+36>>2]&7](a,b,d);return}function Us(a){a=a|0;wi(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Vs(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;ba(26)}function Ws(a){a=a|0;Cj(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Xs(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;f=f|0;return +ec[a&3](b|0,c|0,+d,e|0,f|0)}function Ys(a){a=a|0;c[a>>2]=8060;if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Zs(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;yb[a&31](b|0,c|0,d|0,e|0,f|0)}function _s(a){a=a|0;if(!(c[a+12>>2]|0)){a=0;return a|0}a=c[a+20>>2]|0;return a|0}function $s(a){a=a|0;vm(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function at(a,b,d){a=a|0;b=b|0;d=+d;zb[c[(c[a>>2]|0)+16>>2]&31](a,d);return}function bt(a,b){a=a|0;b=b|0;mc[c[(c[a>>2]|0)+36>>2]&127](a,b,2,-3);return}function ct(a,b,d){a=a|0;b=+b;d=d|0;Jb[c[(c[a>>2]|0)+32>>2]&15](a,b,d);return}function dt(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return}function et(a){a=a|0;xi(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function ft(a){a=a|0;Ai(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function gt(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;ba(31);return 0.0}function ht(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;ac[a&1](b|0,c|0,d|0,e|0,+f)}function it(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;f=f|0;Vb[a&0](b|0,c|0,+d,e|0,f|0)}function jt(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;ba(36);return 0}function kt(a){a=a|0;if(!(+g[a+16>>2]==0.0)){a=0;return a|0}a=+g[a+20>>2]==0.0;return a|0}function lt(a){a=a|0;c[a>>2]=3668;cg(a);pj(a+60|0);return}function mt(a){a=a|0;c[a>>2]=4432;if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function nt(a){a=a|0;c[a>>2]=5008;if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function ot(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+16>>2]&127](a,b);return}function pt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+40>>2]&127](a,b);return}function qt(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Zc(a,b,c,d)|0;return 1}function rt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+68>>2]&127](a,b);return}function st(a,b,d){a=a|0;b=+b;d=d|0;g[(c[a+144>>2]|0)+(d*284|0)+232>>2]=b;return}function tt(a,b,d){a=a|0;b=+b;d=d|0;g[(c[a+144>>2]|0)+(d*284|0)+252>>2]=b;return}function ut(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function vt(a,b){a=a|0;b=b|0;mc[c[(c[a>>2]|0)+36>>2]&127](a,b,1,-1);return}function wt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+64>>2]&127](a,b);return}function xt(a,b,c){a=a|0;b=b|0;c=c|0;bi(b,c);return}function yt(a){a=a|0;Bd(a);if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function zt(a,b){a=a|0;b=b|0;if((c[a+216>>2]&-2|0)==4)return;c[a+216>>2]=b;return}function At(a,b){a=a|0;b=b|0;ic[c[(c[a>>2]|0)+56>>2]&127](a,b,0);return}function Bt(a,b){a=a|0;b=b|0;return Zb[c[(c[a>>2]|0)+40>>2]&31](a,b)|0}function Ct(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+60>>2]&127](a,b);return}function Dt(a,b,d){a=a|0;b=b|0;d=+d;Cb[c[(c[a>>2]|0)+12>>2]&127](a,b);return}function Et(a){a=a|0;a=c[a+68>>2]|0;return Eb[c[(c[a>>2]|0)+36>>2]&127](a)|0}function Ft(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+92>>2]&127](a,b);return}function Gt(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Ib[a&31](b|0,c|0,d|0,e|0)|0}function Ht(a,b){a=a|0;b=+b;c[a+260>>2]=(c[a+260>>2]|0)+1;g[a+232>>2]=b;return}function It(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+32>>2]&127](a,b);return}function Jt(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;ba(25)}function Kt(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return (C=b+d+(a+c>>>0>>>0>>0|0)>>>0,a+c>>>0|0)|0}function Lt(a,b,d){a=a|0;b=+b;d=d|0;g[(c[a+144>>2]|0)+(d*284|0)+256>>2]=b;return}function Mt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+84>>2]&127](a,b);return}function Nt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+28>>2]&127](a,b);return}function Ot(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return +fc[a&1](b|0,c|0,d|0,e|0)}function Pt(a,b){a=a|0;b=+b;c[a+260>>2]=(c[a+260>>2]|0)+1;g[a+228>>2]=b;return}function Qt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+72>>2]&127](a,b);return}function Rt(a){a=a|0;if(!a)return;Ab[c[(c[a>>2]|0)+8>>2]&255](a);return}function St(a,b){a=a|0;b=+b;g[a+36>>2]=b;g[a+40>>2]=+Q(+b);return}function Tt(a){a=a|0;if(!a)return;Ab[c[(c[a>>2]|0)+4>>2]&255](a);return}function Ut(a,b){a=a|0;b=+b;return +(+Sb[c[(c[a>>2]|0)+16>>2]&15](a)*b)}function Vt(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;ba(12);return 0.0}function Wt(a,b){a=a|0;b=+b;c[a+260>>2]=(c[a+260>>2]|0)+1;g[a+224>>2]=b;return}function Xt(a,b){a=a|0;b=b|0;c[a+176>>2]=(b|0)<0?0:(b|0)>2?2:b;return}function Yt(a,b){a=a|0;b=b|0;Se(a,b);return}function Zt(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+8>>2]&127](a,b);return}function _t(a,b,c){a=a|0;b=+b;c=+c;g[a+472>>2]=b;g[a+476>>2]=c;return}function $t(a,b,c){a=a|0;b=b|0;c=c|0;Ii(a,b,c);return}function au(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;mc[a&127](b|0,c|0,d|0,e|0)}function bu(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+12>>2]&127](a,b);return}function cu(a,b,c){a=a|0;b=b|0;c=c|0;gj(a,b,c);return}function du(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+68>>2]&127](a,b);return}function eu(b,c){b=b|0;c=+c;g[b+572>>2]=c;a[b+553>>0]=1;return}function fu(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+24>>2]&127](a,b);return}function gu(a,b,d){a=a|0;b=b|0;d=d|0;c[a+20>>2]=b;c[a+28>>2]=d;return}function hu(a,b,d){a=a|0;b=b|0;d=d|0;c[a+16>>2]=b;c[a+24>>2]=d;return}function iu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return 0}function ju(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=+e;return lc[a&1](b|0,+c,d|0,+e)|0}function ku(a,b){a=a|0;b=b|0;Cb[c[(c[a>>2]|0)+64>>2]&127](a,b);return}function lu(a,b,c){a=a|0;b=b|0;c=+c;g[a+1340+(b<<2)>>2]=c;return}function mu(a,b,c){a=a|0;b=b|0;c=c|0;return sc(a,b,c)|0}function nu(a,b,c){a=a|0;b=b|0;c=+c;g[a+1364+(b<<2)>>2]=c;return}function ou(a,b){a=a|0;b=b|0;xe(a,b);return}function pu(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;hc[a&15](b|0,c|0,d|0,+e)}function qu(a,b){a=a|0;b=+b;g[a+132>>2]=b;return}function ru(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;Fb[a&7](b|0,c|0,+d,e|0)}function su(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;Hb[a&0](b|0,+c,d|0,e|0)}function tu(a,b){a=a|0;b=+b;g[a+128>>2]=b;return}function uu(a,b){a=a|0;b=b|0;c[a+24>>2]=b;return}function vu(a,b){a=a|0;b=b|0;g[a+48>>2]=+(b|0);return}function wu(b,c){b=b|0;c=+c;g[b+572>>2]=c;a[b+553>>0]=0;return}function xu(a,b){a=a|0;b=b|0;return c[(c[a+24>>2]|0)+(b*80|0)+64>>2]|0}function yu(a,b){a=a|0;b=b|0;return c[(c[a+20>>2]|0)+(b<<2)>>2]|0}function zu(a){a=a|0;return Eb[c[(c[a>>2]|0)+40>>2]&127](a)|0}function Au(a){a=a|0;if(!a)return;c[6436]=(c[6436]|0)+1;hd(c[a+-4>>2]|0);return}function Bu(a,b){a=a|0;b=+b;zb[c[(c[a>>2]|0)+44>>2]&31](a,b);return}function Cu(a,b){a=a|0;b=+b;g[a+136>>2]=b;return}function Du(a,b){a=a|0;b=b|0;return c[(c[a+276>>2]|0)+(b<<2)>>2]|0}function Eu(a,b){a=a|0;b=b|0;return (c[a+144>>2]|0)+(b*284|0)+92|0}function Fu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function Gu(a){a=a|0;Ab[c[(c[a>>2]|0)+44>>2]&255](a);return}function Hu(b,c){b=b|0;c=c|0;a[b+32>>0]=c&1;return}function Iu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ob[a&63](b|0,c|0,d|0)|0}function Ju(a,b){a=a|0;b=b|0;Ii(a,b,1);return}function Ku(a){a=a|0;if(!a)a=0;else a=(wj(a,2832)|0)!=0;return a&1|0}function Lu(a,b){a=a|0;b=+b;g[a+116>>2]=b;return}function Mu(a,b){a=a|0;b=+b;g[a+112>>2]=b;return}function Nu(a,b){a=a|0;b=+b;g[a+124>>2]=b;return}function Ou(a){a=a|0;Tj(a);hd(a);return}function Pu(a,b){a=a|0;b=b|0;return c[(c[a+220>>2]|0)+(b<<2)>>2]|0}function Qu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return +_b[a&15](b|0,c|0,d|0)}function Ru(a,b){a=a|0;b=b|0;return sc(a,b,8192)|0}function Su(b,c){b=b|0;c=c|0;a[b+120>>0]=c&1;return}function Tu(b,c){b=b|0;c=c|0;a[b+170>>0]=c&1;return}function Uu(a){a=a|0;return Eb[c[(c[a>>2]|0)+36>>2]&127](a)|0}function Vu(a){a=a|0;return Eb[c[(c[a>>2]|0)+48>>2]&127](a)|0}function Wu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return}function Xu(a,b){a=a|0;b=b|0;sl(a,b);return}function Yu(a,b){a=a|0;b=b|0;Wg(a,b);return}function Zu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return Rb[a&7](b|0,c|0,+d)|0}function _u(a){a=a|0;return +(+g[a+132>>2])}function $u(a){a=a|0;return +(+g[a+128>>2])}function av(a,b){a=a|0;b=b|0;return (c[a+144>>2]|0)+(b*284|0)|0}function bv(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;ba(24)}function cv(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ic[a&127](b|0,c|0,d|0)}function dv(a,b){a=a|0;b=+b;g[a+104>>2]=b;return}function ev(a,b){a=a|0;b=b|0;c[b+748>>2]=0;return}function fv(a,b){a=a|0;b=+b;g[a+96>>2]=b;return}function gv(a){a=a|0;return +(+Sb[c[(c[a>>2]|0)+48>>2]&15](a))}function hv(a,c){a=a|0;c=c|0;b[a+10>>1]=c;return}function iv(a,c){a=a|0;c=c|0;b[a+8>>1]=c;return}function jv(a){a=a|0;Lj(a);hd(a);return}function kv(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function lv(a,b){a=a|0;b=b|0;return c[(c[a+12>>2]|0)+(b<<2)>>2]|0}function mv(a,b){a=a|0;b=b|0;Pd(a,b);return}function nv(a,b){a=a|0;b=+b;g[a+92>>2]=b;return}function ov(a){a=a|0;return +(+g[a+136>>2])}function pv(b){b=b|0;return (a[b+32>>0]&1)!=0|0}function qv(a,b){a=a|0;b=+b;g[a+108>>2]=b;return}function rv(a,c){a=a|0;c=c|0;b[a+12>>1]=c;return}function sv(a,c){a=a|0;c=c|0;b[a+14>>1]=c;return}function tv(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ba(21);return 0}function uv(a,b){a=a|0;b=b|0;return ((c[b+236>>2]&2|0)==0?0:b)|0}function vv(a,b){a=a|0;b=b|0;c[a+44>>2]=b&1;return}function wv(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;Jb[a&15](b|0,+c,d|0)}function xv(a,b){a=a|0;b=+b;g[a+220>>2]=b;return}function yv(a,b){a=a|0;b=+b;g[a+100>>2]=b;return}function zv(b){b=b|0;return (a[b+120>>0]&1)!=0|0}function Av(b,c){b=b|0;c=c|0;a[b+24>>0]=c&1;return}function Bv(a){a=a|0;return ~~+g[a+48>>2]|0}function Cv(b,c){b=b|0;c=c|0;a[b+180>>0]=c&1;return}function Dv(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;kc[a&7](b|0,c|0,+d)}function Ev(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;f=f|0;ba(22);return 0.0}function Fv(a,b){a=a|0;b=+b;g[a+224>>2]=b;return}function Gv(a){a=a|0;a=c[a+216>>2]|0;return (a|0)!=5&(a|0)!=2|0}function Hv(b,c){b=b|0;c=c|0;a[b+524>>0]=c&1;return}function Iv(a){a=a|0;return +(+g[a+116>>2])}function Jv(b,c){b=b|0;c=c|0;a[b+16>>0]=c&1;return}function Kv(a,b){a=a|0;b=+b;g[a+276>>2]=b;return}function Lv(a,b){a=a|0;b=+b;g[a+204>>2]=b;return}function Mv(a,b){a=a|0;b=+b;g[a+208>>2]=b;return}function Nv(a){a=a|0;return +(+g[a+124>>2])}function Ov(a,b,c){a=a|0;b=+b;c=c|0;return}function Pv(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function Qv(a,b){a=a|0;b=b|0;return ((c[b+236>>2]|0)==8?b:0)|0}function Rv(b,c){b=b|0;c=c|0;a[b+552>>0]=c&1;return}function Sv(a,b){a=a|0;b=+b;g[a+216>>2]=b;return}function Tv(a,b){a=a|0;b=b|0;c[a+36>>2]=b;return}function Uv(a,b){a=a|0;b=b|0;c[a+32>>2]=b;return}function Vv(a,b){a=a|0;b=b|0;return a+4+(b*184|0)|0}function Wv(b,c){b=b|0;c=c|0;a[b+736>>0]=c&1;return}function Xv(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return $e(a,b,c,d,0)|0}function Yv(a){a=a|0;kf(a);hd(a);return}function Zv(b,c){b=b|0;c=c|0;a[b+260>>0]=c&1;return}function _v(b,c){b=b|0;c=c|0;a[b+21>>0]=c&1;return}function $v(a,b){a=a|0;b=+b;g[a+684>>2]=b;return}function aw(b,c){b=b|0;c=c|0;a[b+25>>0]=c&1;return}function bw(a,b,c){a=a|0;b=+b;c=c|0;return}function cw(a,b){a=a|0;b=b|0;c[a+72>>2]=b;return}function dw(a,b,c,d){a=a|0;b=b|0;c=+c;d=+d;Nb[a&7](b|0,+c,+d)}function ew(a,b){a=a|0;b=+b;g[a+188>>2]=b;return}function fw(a,b){a=a|0;b=+b;g[a+184>>2]=b;return}function gw(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function hw(a,b){a=a|0;b=b|0;return (c[a+12>>2]|0)+(b*104|0)|0}function iw(a,b){a=a|0;b=+b;g[a+248>>2]=b;return}function jw(b,c){b=b|0;c=c|0;a[b+737>>0]=c&1;return}function kw(a,b){a=a|0;b=b|0;c[a+216>>2]=b;return}function lw(b,c){b=b|0;c=c|0;a[b+26>>0]=c&1;return}function mw(b,c){b=b|0;c=c|0;a[b+84>>0]=c&1;return}function nw(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ba(18)}function ow(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function pw(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function qw(a,b){a=a|0;b=+b;g[a+440>>2]=b;return}function rw(a,b,c){a=a|0;b=b|0;c=c|0;return Zb[a&31](b|0,c|0)|0}function sw(a,b){a=a|0;b=+b;g[a+244>>2]=b;return}function tw(a){a=a|0;return +(+g[a+104>>2])}function uw(a){a=a|0;yk(a);hd(a);return}function vw(a){a=a|0;Wk(a);hd(a);return}function ww(a,b){a=a|0;b=+b;g[a+212>>2]=b;return}function xw(a,b){a=a|0;b=+b;g[a+228>>2]=b;return}function yw(a,b){a=a|0;b=b|0;c[a+204>>2]=b;return}function zw(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;ba(17)}function Aw(a,b){a=a|0;b=+b;g[a+252>>2]=b;return}function Bw(a){a=a|0;return +(+g[a+96>>2])}function Cw(a){a=a|0;return (c[a+44>>2]|0)!=0|0}function Dw(a){a=a|0;xk(a);hd(a);return}function Ew(a){a=a|0;return +(+g[a+92>>2])}function Fw(b){b=b|0;return (a[b+24>>0]&1)!=0|0}function Gw(a,b,c){a=a|0;b=b|0;c=c|0;return 0}function Hw(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;f=f|0;ba(3)}function Iw(a){a=a|0;return +(+g[a+108>>2])}function Jw(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ba(14);return 0.0}function Kw(a,b){a=a|0;b=+b;g[a+232>>2]=b;return}function Lw(b){b=b|0;return (a[b+16>>0]&1)!=0|0}function Mw(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function Nw(a){a=a|0;return b[a+10>>1]|0}function Ow(a){a=a|0;return b[a+8>>1]|0}function Pw(a,b){a=a|0;b=b|0;c[a+240>>2]=b;return}function Qw(a){a=a|0;zk(a);hd(a);return}function Rw(a,b,c,d,e,f){a=a|0;b=+b;c=+c;d=d|0;e=e|0;f=f|0;ba(8)}function Sw(a){a=a|0;return +(+g[a+220>>2])}function Tw(a){a=a|0;return (c[a+204>>2]&2|0)!=0|0}function Uw(a){a=a|0;return +(+g[a+100>>2])}function Vw(a){a=a|0;return b[a+12>>1]|0}function Ww(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ba(34);return 0.0}function Xw(a){a=a|0;return +(+g[a+224>>2])}function Yw(a){a=a|0;return ph(a)|0}function Zw(a){a=a|0;return b[a+14>>1]|0}function _w(a,b){a=a|0;b=b|0;c[a+84>>2]=b;return}function $w(a,b){a=a|0;b=b|0;c[a+88>>2]=b;return}function ax(a,b){a=a|0;b=b|0;c[a+92>>2]=b;return}function bx(a,b){a=a|0;b=b|0;c[a+100>>2]=b;return}function cx(a,b){a=a|0;b=b|0;c[a+96>>2]=b;return}function dx(a){a=a|0;return (c[a+48>>2]|0)==1|0}function ex(a,b){a=a|0;b=b|0;if(!n){n=a;o=b}}function fx(b){b=b|0;return (a[b+260>>0]&1)!=0|0}function gx(b){b=b|0;return (a[b+25>>0]&1)!=0|0}function hx(a){a=a|0;return (c[a+92>>2]|0)+4|0}function ix(a,b,c){a=a|0;b=b|0;c=c|0;Cb[a&127](b|0,c|0)}function jx(a,b,c){a=a|0;b=b|0;c=+c;return +cc[a&1](b|0,+c)}function kx(a){a=a|0;return +(+g[a+276>>2])}function lx(a){a=a|0;return +(+g[a+204>>2])}function mx(a){a=a|0;return +(+g[a+208>>2])}function nx(a,b){a=a|0;b=b|0;c[a+16>>2]=b;return}function ox(a,b){a=a|0;b=+b;g[a+64>>2]=b;return}function px(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function qx(a){a=a|0;Ak(a);hd(a);return}function rx(a){a=a|0;return +(+g[a+112>>2])}function sx(a){a=a|0;return +(+g[a+216>>2])}function tx(a){a=a|0;return c[a+268>>2]|0}function ux(b){b=b|0;return (a[b+26>>0]&1)!=0|0}function vx(b){b=b|0;return (a[b+84>>0]&1)!=0|0}function wx(a,b){a=a|0;b=+b;g[a+80>>2]=b;return}function xx(a,b){a=a|0;b=+b;g[a+76>>2]=b;return}function yx(a){a=a|0;return +(+g[a+28>>2]*+g[a+12>>2])}function zx(a,b,c){a=a|0;b=b|0;c=c|0;return}function Ax(a){a=a|0;return +(+g[a+248>>2])}function Bx(a){a=a|0;if(!a)return;hd(a);return}function Cx(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function Dx(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function Ex(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function Fx(a,b,c){a=a|0;b=b|0;c=+c;return 0}function Gx(a,b){a=a|0;b=b|0;return}function Hx(a){a=a|0;return c[a+36>>2]|0}function Ix(a){a=a|0;return c[a+32>>2]|0}function Jx(a){a=a|0;return c[a+748>>2]|0}function Kx(a){a=a|0;return (c[a+48>>2]|0)+4|0}function Lx(a){a=a|0;return +(+g[a+120>>2])}function Mx(a){a=a|0;return a+44|0}function Nx(a,b,c){a=a|0;b=b|0;c=+c;zb[a&31](b|0,+c)}function Ox(a){a=a|0;return c[a+8>>2]|0}function Px(a){a=a|0;return (c[a+8>>2]|0)!=0|0}function Qx(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function Rx(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function Sx(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function Tx(a){a=a|0;return a+60|0}function Ux(a){a=a|0;return c[a+200>>2]|0}function Vx(a){a=a|0;return +(+g[a+244>>2])}function Wx(a){a=a|0;return +g[a+4>>2]<1.0|0}function Xx(a,b){a=a|0;b=+b;g[a+24>>2]=b;return}function Yx(a,b){a=a|0;b=+b;g[a+20>>2]=b;return}function Zx(a,b){a=a|0;b=+b;g[a+32>>2]=b;return}function _x(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function $x(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function ay(a){a=a|0;return c[a+212>>2]|0}function by(a){a=a|0;c[a+192>>2]=0;return}function cy(a,b,c){a=a|0;b=b|0;c=c|0;return}function dy(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function ey(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ba(0)}function fy(a){a=a|0;return +(+g[a+212>>2])}function gy(a){a=a|0;return +(+g[a+228>>2])}function hy(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function iy(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function jy(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function ky(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;ba(30)}function ly(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;ba(23)}function my(a){a=a|0;return +(+g[a+252>>2])}function ny(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function oy(a){a=a|0;return a+156|0}function py(a){a=a|0;return c[a+116>>2]|0}function qy(a){a=a|0;return c[a+136>>2]|0}function ry(a){a=a|0;return c[a+744>>2]|0}function sy(a){a=a|0;return c[a+740>>2]|0}function ty(a){a=a|0;return a+20|0}function uy(a){a=a|0;return a+324|0}function vy(a){a=a|0;return c[a+192>>2]|0}function wy(a){a=a|0;return c[a+204>>2]|0}function xy(a){a=a|0;return c[a+24>>2]|0}function yy(a){a=a|0;return c[a+68>>2]|0}function zy(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ba(35);return 0.0}function Ay(a){a=a|0;return +(+g[a+232>>2])}function By(a,b){a=a|0;b=+b;g[a>>2]=b;return}function Cy(a){a=a|0;return 348}function Dy(a){a=a|0;return c[a+12>>2]|0}function Ey(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ba(10);return 0}function Fy(a){a=a|0;return c[a+480>>2]|0}function Gy(a){a=a|0;Ci(a);hd(a);return}function Hy(a){a=a|0;dp(a);hd(a);return}function Iy(a){a=a|0;_j(a);hd(a);return}function Jy(a){a=a|0;return a+352|0}function Ky(a){a=a|0;return a+348|0}function Ly(a){a=a|0;return c[a>>2]|0}function My(a,b){a=a|0;b=b|0;return Eb[a&127](b|0)|0}function Ny(a){a=a|0;return c[a+240>>2]|0}function Oy(a){a=a|0;return a+24|0}function Py(a){a=a|0;return a+316|0}function Qy(a){a=a|0;return a+300|0}function Ry(a){a=a|0;return a+64|0}function Sy(a){a=a|0;return +(+g[a+64>>2])}function Ty(a){a=a|0;return +(+g[a+68>>2])}function Uy(a){a=a|0;return a+32|0}function Vy(a){a=a|0;return c[a+84>>2]|0}function Wy(a){a=a|0;return c[a+88>>2]|0}function Xy(a){a=a|0;return c[a+92>>2]|0}function Yy(a){a=a|0;return c[a+100>>2]|0}function Zy(a){a=a|0;return 252}function _y(a,b,c,d){a=a|0;b=+b;c=c|0;d=+d;ba(41);return 0}function $y(a){a=a|0;return a+52|0}function az(a){a=a|0;return +(+g[a+80>>2])}function bz(a){a=a|0;return +(+g[a+76>>2])}function cz(a){a=a|0;return 28}function dz(a){a=a|0;return c[a+72>>2]|0}function ez(a,b){a=a|0;b=b|0;return +Sb[a&15](b|0)}function fz(a){a=a|0;return a+40|0}function gz(a){a=a|0;return c[a+16>>2]|0}function hz(a){a=a|0;return +(+g[a+60>>2])}function iz(a){a=a|0;return +(+g[a+52>>2])}function jz(a){a=a|0;return +(+g[a+56>>2])}function kz(a){a=a|0;return a+108|0}function lz(a){a=a|0;return 212}function mz(a){a=a|0;return c[a+96>>2]|0}function nz(a){a=a|0;return a+16|0}function oz(a,b){a=a|0;b=b|0;return 1}function pz(a){a=a|0;return a+328|0}function qz(a){a=a|0;return a+28|0}function rz(a,b){a=a|0;b=b|0;i=a;j=b}function sz(a){a=a|0;return a+312|0}function tz(a){a=a|0;return 204}function uz(a,b){a=a|0;b=b|0;return}function vz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ba(42)}function wz(a){a=a|0;return a+36|0}function xz(a){a=a|0;return +(+g[a+44>>2])}function yz(a){a=a|0;return +(+g[a+40>>2])}function zz(a){a=a|0;return +(+g[a+36>>2])}function Az(a){a=a|0;return +(+g[a+48>>2])}function Bz(a){a=a|0;return 220}function Cz(a){a=a|0;return 256}function Dz(a){a=a|0;return +(+g[a+72>>2])}function Ez(a){a=a|0;c[a>>2]=8060;return}function Fz(a){a=a|0;return +(+g[a+24>>2])}function Gz(a){a=a|0;return +(+g[a+20>>2])}function Hz(a){a=a|0;return +(+g[a+32>>2])}function Iz(a){a=a|0;return +(+g[a+16>>2])}function Jz(a){a=a|0;return +(+g[a+28>>2])}function Kz(a){a=a|0;return a+12|0}function Lz(a){a=a|0;return 52}function Mz(a){a=a|0;return 68}function Nz(a){a=a|0;return 84}function Oz(a){a=a|0;return c[a+4>>2]|0}function Pz(a){a=a|0;return a+868|0}function Qz(a){a=a|0;return a+4|0}function Rz(a,b){a=a|0;b=b|0;Ab[a&255](b|0)}function Sz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;ba(37)}function Tz(a){a=a|0;return 24}function Uz(a,b){a=a|0;b=+b;return}function Vz(a){a=a|0;return +(+g[a+12>>2])}function Wz(a){a=a|0;return a+68|0}function Xz(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;ba(9)}function Yz(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;ba(7)}function Zz(a){a=a|0;return +(+g[a+8>>2])}function _z(a){a=a|0;return +(+g[a+4>>2])}function $z(a){a=a|0;Ai(a);return}function aA(a,b,c){a=a|0;b=b|0;c=c|0;ba(28);return 0.0}function bA(a){a=a|0;return a+708|0}function cA(a){a=a|0;return 488}function dA(a,b,c){a=a|0;b=b|0;c=c|0;ba(16);return 0}function eA(a){a=a|0;hd(a+-4|0);return}function fA(a){a=a|0;return 32}function gA(a){a=a|0;return a+76|0}function hA(a){a=a|0;return 60}function iA(a){a=a|0;return 428}function jA(a){a=a|0;return a+48|0}function kA(a){a=a|0;return a+288|0}function lA(a){a=a|0;c[a>>2]=4432;return}function mA(a){a=a|0;c[a>>2]=5008;return}function nA(a){a=a|0;return +(+g[a>>2])}function oA(a,b,c){a=a|0;b=b|0;c=+c;ba(19);return 0}function pA(a){a=a|0;return 11200}function qA(a){a=a|0;return 4}function rA(a){a=a|0;return 17831}function sA(a){a=a|0;return 17518}function tA(a){a=a|0;return 11009}function uA(a){a=a|0;return a|0}function vA(a){a=a|0;return 16532}function wA(a){a=a|0;return a+72|0}function xA(a,b,c){a=a|0;b=b|0;c=c|0;ba(38)}function yA(a){a=a|0;return a+8|0}function zA(a){a=a|0;return 16945}function AA(a){a=a|0;return 0}function BA(a){a=a|0;return 17105}function CA(a){a=a|0;return 17303}function DA(a){a=a|0;return 1}function EA(a,b,c){a=a|0;b=b|0;c=+c;ba(40)}function FA(a,b,c){a=a|0;b=+b;c=c|0;ba(11)}function GA(a){a=a|0;return 17939}function HA(a){a=a|0;return 17910}function IA(a){a=a|0;return 3}function JA(a){a=a|0;return 11635}function KA(a){a=a|0;return 17861}function LA(a){a=a|0;return 16353}function MA(a){a=a|0;return 17481}function NA(a){a=a|0;return 17454}function OA(a){a=a|0;return 17404}function PA(a){a=a|0;return 8}function QA(a,b,c){a=a|0;b=+b;c=+c;ba(15)}function RA(a){a=a|0;return 16500}function SA(a,b){a=a|0;b=b|0;ba(27);return 0}function TA(a){a=a|0;return 16457}function UA(a){a=a|0;return 16478}function VA(a){a=a|0;return 6}function WA(a){a=a|0;return 12}function XA(){return 4}function YA(a){a=a|0;return 16421}function ZA(a,b){a=a|0;b=+b;ba(32);return 0.0}function _A(a){a=a|0;return 2}function $A(a){a=a|0;return 17591}function aB(a){a=a|0;hd(a);return}function bB(a){a=a|0;return 22301}function cB(a){a=a|0;jc[a&3]()}function dB(){return 2}function eB(){return 1}function fB(){return 5}function gB(){return 3}function hB(){return 0}function iB(){vb()}function jB(a,b){a=a|0;b=b|0;ba(4)}function kB(a){a=a|0;i=a}function lB(a,b){a=a|0;b=+b;ba(1)}function mB(a){a=a|0;C=a}function nB(a){a=a|0;ba(20);return 0.0}function oB(a){a=a|0;ba(6);return 0}function pB(){return C|0}function qB(a){a=a|0;return}function rB(){return i|0}function sB(a){a=a|0;ba(2)}function tB(){ba(39)} + +// EMSCRIPTEN_END_FUNCS +var yb=[ey,ah,Vl,jg,op,_c,df,ag,Xf,oc,ld,Oc,de,le,Vc,Es,Fg,xc,$d,Fl,Bi,sf,ey,ey,ey,ey,ey,ey,ey,ey,ey,ey];var zb=[lB,wc,fd,jn,jy,ny,Uz,ny,Ok,gd,_f,Fe,ug,rk,hf,ad,rd,Qc,dy,ny,Wl,Wl,Wl,qj,lB,lB,lB,lB,lB,lB,lB,lB];var Ab=[sB,qB,aB,qB,Au,qB,aB,qB,aB,qB,aB,gp,lq,Wn,Tj,Ou,qB,aB,aB,aB,aB,Bd,yt,qB,aB,qB,aB,qB,Au,aB,aB,qB,Au,aB,aB,qB,aB,Ir,yr,lt,Ss,qB,aB,qB,aB,Op,hp,qk,ys,Ge,gl,pc,Yh,hg,En,bf,Ul,qB,aB,qB,aB,Uo,eo,Sg,Gs,tc,qB,aB,xk,Dw,lA,mt,Td,dn,mt,qB,mt,mt,Pe,mt,mt,ve,mt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r,Bh,Mf,qc,ws,Mm,Cl,Mo,cf,Sf,Pg,Ke,Or,ur,$f,Eg,Dh,Ur,vi,bm,Lo,Ch,ie,gm,Jj,xj,bp,mg,Vg,Vh,Li,bl,Pv,Wh,Qg,Hi,Pv,Pv,uj,Aj,tm,hl,vk,Hd,Ce,Di,Nc,Aj,Ml,Bl,Ll,nd,Mn,Fj,Mn,Nl,Rm,fm,nk,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz,vz];return{_emscripten_bind_btCylinderShape___destroy___0:Tt,_emscripten_bind_btGeneric6DofConstraint_enableFeedback_1:_v,_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_3:gs,_emscripten_bind_btHingeConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_btDispatcherInfo_set_m_useContinuous_1:Jv,_emscripten_bind_btCollisionObject_isActive_0:Gv,_emscripten_bind_btVehicleTuning_set_m_frictionSlip_1:_x,_emscripten_bind_btDiscreteDynamicsWorld_btDiscreteDynamicsWorld_4:to,_emscripten_bind_btCapsuleShapeX_getMargin_0:gv,_emscripten_bind_Node_set_m_n_1:nr,_emscripten_bind_btCompoundShape_getMargin_0:gv,_emscripten_bind_RaycastInfo_set_m_wheelDirectionWS_1:cr,_emscripten_bind_btContactSolverInfo___destroy___0:Bx,_emscripten_bind_btWheelInfo_set_m_wheelsSuspensionForce_1:Kv,_emscripten_bind_ClosestRayResultCallback_get_m_hitPointWorld_0:Wz,_emscripten_bind_btPairCachingGhostObject_getCollisionFlags_0:wy,_emscripten_bind_btQuaternion_setX_1:By,_emscripten_bind_btCylinderShapeZ_getMargin_0:gv,_emscripten_bind_btDispatcherInfo_get_m_timeOfImpact_0:Vz,_emscripten_bind_btQuaternion_setZ_1:hy,_emscripten_bind_btCollisionObject_getUserIndex_0:Ny,_emscripten_bind_btCapsuleShapeZ_getMargin_0:gv,_emscripten_bind_btSoftBodyWorldInfo_set_water_density_1:iy,_emscripten_bind_btKinematicCharacterController_setMaxSlope_1:St,_emscripten_bind_btQuadWord_z_0:Zz,_emscripten_bind_btSoftBody_setCcdMotionThreshold_1:Aw,_emscripten_bind_Material___destroy___0:Bx,_emscripten_bind_btSoftBodyWorldInfo_get_m_maxDisplacement_0:Vz,_emscripten_bind_btSoftBody_rotate_1:Mj,_emscripten_bind_btWheelInfo_get_m_suspensionRestLength1_0:lx,_emscripten_bind_btWheelInfo_get_m_suspensionStiffness_0:sx,_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingThresholdSqr_1:qu,_emscripten_bind_btSoftRigidDynamicsWorld___destroy___0:Tt,_emscripten_bind_btSoftRigidDynamicsWorld_removeConstraint_1:Ct,_emscripten_bind_RaycastInfo_get_m_wheelAxleWS_0:Wz,_emscripten_bind_btRigidBodyConstructionInfo_get_m_angularDamping_0:Bw,_emscripten_bind_btCollisionDispatcher___destroy___0:Tt,_emscripten_bind_btRigidBody_applyCentralImpulse_1:co,_emscripten_bind_btConvexHullShape_getMargin_0:gv,_emscripten_bind_btDefaultMotionState_getWorldTransform_1:Zt,_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_1:Qs,_emscripten_bind_btRaycastVehicle_getNumWheels_0:qy,_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_3:ls,_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_2:hs,_emscripten_bind_btSoftRigidDynamicsWorld_addAction_1:ku,_emscripten_bind_btDynamicsWorld_rayTest_3:Fs,_emscripten_bind_Config_set_kSR_SPLT_CL_1:ox,_emscripten_bind_btQuadWord_x_0:nA,_emscripten_bind_Config_get_diterations_0:Xy,_emscripten_bind_btCollisionObject_isKinematicObject_0:Tw,_emscripten_bind_btSoftRigidDynamicsWorld_removeSoftBody_1:Wi,_emscripten_bind_ConvexResultCallback___destroy___0:Tt,_emscripten_bind_btGeneric6DofSpringConstraint_setLinearUpperLimit_1:Lq,_emscripten_bind_ClosestConvexResultCallback_set_m_hitNormalWorld_1:Kq,_emscripten_bind_btSoftBody_isKinematicObject_0:Tw,_emscripten_bind_btRigidBody_getCenterOfMassTransform_0:Qz,_emscripten_bind_btGhostObject_isKinematicObject_0:Tw,_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_5:dk,_emscripten_bind_btCapsuleShape___destroy___0:Tt,_emscripten_bind_btCollisionObject_activate_1:tr,_emscripten_bind_btCollisionObject_activate_0:Xr,_emscripten_bind_btKinematicCharacterController_setUpAxis_1:Xt,_emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_1:At,_emscripten_bind_btDispatcherInfo_set_m_timeOfImpact_1:jy,_emscripten_bind_btCollisionDispatcher_btCollisionDispatcher_1:hk,_emscripten_bind_btVector3_setX_1:By,_emscripten_bind_btCollisionConfiguration___destroy___0:Tt,_emscripten_bind_btCapsuleShapeZ_setMargin_1:Bu,_emscripten_bind_btHingeConstraint_enableFeedback_1:_v,_emscripten_bind_btSphereShape___destroy___0:Tt,_emscripten_bind_btHeightfieldTerrainShape_setLocalScaling_1:fu,_emscripten_bind_btGeneric6DofConstraint_setAngularLowerLimit_1:po,_emscripten_bind_btManifoldPoint_set_m_localPointB_1:fr,_emscripten_bind_btVector3_setZ_1:hy,_emscripten_bind_btKinematicCharacterController_setUseGhostSweepTest_1:Tu,_emscripten_bind_btQuaternion_setValue_4:Lr,_emscripten_bind_btDispatcherInfo_set_m_dispatchFunc_1:gw,_emscripten_bind_btSoftBody_transform_1:mv,_emscripten_bind_LocalShapeInfo___destroy___0:Bx,_emscripten_bind_btSoftBody_appendAnchor_4:_d,_emscripten_bind_btVehicleTuning_get_m_suspensionStiffness_0:nA,_emscripten_bind_btPoint2PointConstraint_get_m_setting_0:Ky,_emscripten_bind_btQuadWord_setY_1:iy,_emscripten_bind_btRigidBody_setUserPointer_1:Pw,_emscripten_bind_btRigidBodyConstructionInfo_set_m_restitution_1:qv,_emscripten_bind_btDefaultMotionState_get_m_graphicsWorldTrans_0:Qz,_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_3:ds,_emscripten_bind_btPairCachingGhostObject_btPairCachingGhostObject_0:Ph,_emscripten_bind_btDiscreteDynamicsWorld_getSolverInfo_0:fl,_emscripten_bind_btCylinderShape_setMargin_1:Bu,_emscripten_bind_btCollisionWorld___destroy___0:Tt,_emscripten_bind_btSoftBodyWorldInfo_get_m_broadphase_0:Ix,_emscripten_bind_LocalConvexResult_get_m_hitPointLocal_0:Oy,_emscripten_bind_btBoxShape_btBoxShape_1:Fh,_emscripten_bind_btPersistentManifold_getBody1_0:ry,_emscripten_bind_ClosestRayResultCallback_set_m_collisionObject_1:gw,_emscripten_bind_RaycastInfo_set_m_isInContact_1:mw,_emscripten_bind_btKinematicCharacterController_setGravity_1:ny,_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_5:Bo,_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_3:Wo,_emscripten_bind_btQuaternion_setY_1:iy,_emscripten_bind_btSoftRigidDynamicsWorld_removeAction_1:du,_emscripten_bind_btWheelInfo_get_m_rollInfluence_0:Vx,_emscripten_bind_btTypedConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_btBvhTriangleMeshShape_setLocalScaling_1:fu,_emscripten_bind_tNodeArray_size_0:Oz,_emscripten_bind_btPoint2PointConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_btRigidBody_getUserIndex_0:Ny,_emscripten_bind_btDynamicsWorld_getDispatchInfo_0:qz,_emscripten_bind_btCompoundShape_removeChildShapeByIndex_1:ou,_emscripten_bind_btSoftBody_appendFace_4:Ks,_emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_2:Yk,_emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_1:ll,_emscripten_bind_ClosestConvexResultCallback_set_m_hitPointWorld_1:Nq,_emscripten_bind_RayResultCallback_set_m_collisionFilterMask_1:sv,_emscripten_bind_btBoxShape_getMargin_0:gv,_emscripten_bind_btPairCachingGhostObject___destroy___0:Rt,_emscripten_bind_btPairCachingGhostObject_setUserPointer_1:Pw,_emscripten_bind_btPairCachingGhostObject_activate_0:Xr,_emscripten_bind_btPairCachingGhostObject_activate_1:tr,_emscripten_bind_btContactSolverInfo_get_m_splitImpulsePenetrationThreshold_0:Bv,_emscripten_bind_btSoftBody_setUserPointer_1:Pw,_emscripten_bind_btDynamicsWorld_getDispatcher_0:xy,_emscripten_bind_btSoftBody_setMass_2:ss,_emscripten_bind_btConeShape_btConeShape_2:_l,_emscripten_bind_btDynamicsWorld___destroy___0:Tt,_emscripten_bind_Config_get_kCHR_0:zz,_emscripten_bind_btPairCachingGhostObject_forceActivationState_1:kw,_emscripten_bind_btDefaultMotionState___destroy___0:Tt,_emscripten_bind_btDispatcherInfo_get_m_stepCount_0:Oz,_emscripten_bind_btRigidBodyConstructionInfo_set_m_angularDamping_1:fv,_emscripten_bind_btQuadWord_setW_1:jy,_emscripten_bind_btRigidBodyConstructionInfo_get_m_friction_0:Uw,_emscripten_bind_btCapsuleShapeX_btCapsuleShapeX_2:Em,_emscripten_bind_LocalShapeInfo_set_m_shapePart_1:Mw,_emscripten_bind_btRigidBody_setLinearFactor_1:un,_emscripten_bind_btDispatcherInfo_set_m_useConvexConservativeDistanceUtil_1:Hu,_emscripten_bind_btSoftRigidDynamicsWorld_setGravity_1:Qt,_emscripten_bind_btRaycastVehicle_getCurrentSpeedKmHour_0:rx,_emscripten_bind_btWheelInfo_get_m_engineForce_0:my,_emscripten_bind_Config_get_kSR_SPLT_CL_0:Sy,_emscripten_bind_btRaycastVehicle_setSteeringValue_2:st,_emscripten_bind_btPoint2PointConstraint___destroy___0:Tt,_emscripten_bind_btSoftBody_getUserPointer_0:Ny,_emscripten_bind_btCollisionShape_setMargin_1:Bu,_emscripten_bind_btGeneric6DofConstraint_setAngularUpperLimit_1:ho,_emscripten_bind_btDiscreteDynamicsWorld_addConstraint_2:Rs,_emscripten_bind_btDiscreteDynamicsWorld_addConstraint_1:At,_emscripten_bind_btRigidBodyConstructionInfo_set_m_angularSleepingThreshold_1:Lu,_emscripten_bind_Config_get_kVCF_0:_z,_emscripten_bind_btKinematicCharacterController_setJumpSpeed_1:$x,_malloc:yc,_emscripten_bind_btDispatcherInfo_get_m_useEpa_0:ux,_emscripten_bind_btTransform_btTransform_2:um,_emscripten_bind_btTransform_btTransform_0:Do,_emscripten_bind_btPairCachingGhostObject_getUserIndex_0:Ny,_emscripten_bind_Config_set_kVC_1:Xx,_emscripten_bind_btVector3_op_sub_1:ar,_emscripten_bind_btWheelInfo_set_m_wheelsRadius_1:ww,_emscripten_bind_btDispatcherInfo_set_m_enableSPU_1:aw,_emscripten_bind_btWheelInfo_set_m_wheelsDampingCompression_1:xv,_emscripten_bind_btSoftBody_appendNode_2:id,_emscripten_bind_btCollisionObject_setActivationState_1:zt,_emscripten_bind_btPersistentManifold___destroy___0:Au,_emscripten_bind_btConstraintSetting_get_m_impulseClamp_0:Zz,_emscripten_bind_btCylinderShapeZ___destroy___0:Tt,_emscripten_bind_btMatrix3x3___destroy___0:Bx,_emscripten_bind_ConvexResultCallback_hasHit_0:Wx,_emscripten_bind_btCollisionShape_calculateLocalInertia_2:ct,_emscripten_bind_btGeneric6DofSpringConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_Config_set_kPR_1:Yx,_emscripten_bind_btCollisionWorld_convexSweepTest_5:Wq,_emscripten_bind_btVector3_length_0:Zr,_emscripten_bind_btSoftBody_set_m_materials_1:Xi,_emscripten_enum_PHY_ScalarType_PHY_UCHAR:fB,_emscripten_bind_ClosestRayResultCallback_set_m_hitPointWorld_1:hr,_emscripten_bind_btCapsuleShapeX_calculateLocalInertia_2:ct,_emscripten_bind_btConstraintSetting_set_m_damping_1:iy,_emscripten_bind_btVehicleRaycaster___destroy___0:Tt,_emscripten_bind_btSoftBody_set_m_cfg_1:di,_emscripten_bind_btRigidBody_setCcdMotionThreshold_1:Aw,_emscripten_bind_btConvexHullShape_setMargin_1:Bu,_emscripten_bind_btRigidBody_applyForce_2:_k,_emscripten_bind_btConeShapeZ_calculateLocalInertia_2:ct,_emscripten_bind_btConstraintSetting_set_m_tau_1:By,_emscripten_bind_btConvexHullShape_calculateLocalInertia_2:ct,_emscripten_bind_RaycastInfo_get_m_contactPointWS_0:nz,_emscripten_bind_btSoftBody_setCollisionFlags_1:yw,_emscripten_bind_btSphereShape_calculateLocalInertia_2:ct,_emscripten_bind_btSoftBody_appendMaterial_0:Yw,_emscripten_bind_btVector4_normalize_0:fq,_emscripten_bind_btSoftRigidDynamicsWorld_getSolverInfo_0:el,_emscripten_bind_btCollisionDispatcher_getManifoldByIndexInternal_1:Bt,_emscripten_bind_btSoftBody_setTotalMass_2:oh,_emscripten_bind_LocalConvexResult_LocalConvexResult_5:al,_emscripten_bind_btGhostObject_setFriction_1:Wt,_emscripten_bind_btCollisionWorld_rayTest_3:Fs,_emscripten_bind_btRigidBody_setCcdSweptSphereRadius_1:iw,_emscripten_bind_btCylinderShapeZ_setMargin_1:Bu,_emscripten_bind_btRigidBody_setFriction_1:Wt,_emscripten_bind_LocalConvexResult_set_m_hitPointLocal_1:_q,_emscripten_bind_btGhostObject_setWorldTransform_1:pl,_emscripten_bind_tMaterialArray_size_0:Oz,_emscripten_bind_btManifoldPoint_getAppliedImpulse_0:Lx,_emscripten_bind_btDiscreteDynamicsWorld_removeRigidBody_1:Ft,_emscripten_bind_btConvexHullShape___destroy___0:Tt,_emscripten_bind_RaycastInfo_set_m_suspensionLength_1:Zx,_emscripten_bind_btDiscreteDynamicsWorld_getBroadphase_0:yy,_emscripten_bind_btSoftBodyWorldInfo_get_m_dispatcher_0:Hx,_emscripten_bind_btKinematicCharacterController_jump_0:Gu,_emscripten_bind_btCollisionObject_getUserPointer_0:Ny,_emscripten_bind_btWheelInfo_set_m_raycastInfo_1:Er,_emscripten_bind_btSoftBody_generateClusters_1:Ru,_emscripten_bind_btConeTwistConstraint_setMaxMotorImpulseNormalized_1:eu,_emscripten_bind_btConvexTriangleMeshShape_setLocalScaling_1:fu,_emscripten_bind_btRigidBody_upcast_1:uv,_emscripten_bind_btCollisionObject_getWorldTransform_0:Qz,_emscripten_bind_btVector4_setZ_1:hy,_emscripten_bind_btManifoldPoint_set_m_positionWorldOnB_1:Xq,___cxa_can_catch:eq,_emscripten_bind_btTransform_getBasis_0:uA,_emscripten_bind_btPairCachingGhostObject_setFriction_1:Wt,_emscripten_bind_Config_set_kSRHR_CL_1:Dx,_emscripten_bind_btCollisionDispatcher_getNumManifolds_0:Uu,_emscripten_bind_btWheelInfo_set_m_bIsFrontWheel_1:Zv,_emscripten_bind_ClosestRayResultCallback___destroy___0:Tt,_emscripten_bind_btGeneric6DofSpringConstraint_setStiffness_2:lu,_emscripten_bind_btCylinderShapeX_setMargin_1:Bu,_emscripten_bind_btQuadWord_w_0:Vz,_emscripten_bind_Node___destroy___0:Bx,_emscripten_bind_btDynamicsWorld_contactTest_2:qn,_emscripten_bind_btDiscreteDynamicsWorld_contactTest_2:qn,_emscripten_bind_btBvhTriangleMeshShape_calculateLocalInertia_2:ct,_emscripten_bind_btTransform_setOrigin_1:kr,_emscripten_bind_btCompoundShape_getNumChildShapes_0:gz,_emscripten_bind_btSoftBodyWorldInfo_set_m_broadphase_1:Uv,_emscripten_bind_btGhostObject_btGhostObject_0:Ki,_emscripten_bind_tNodeArray___destroy___0:Ip,_emscripten_bind_ClosestConvexResultCallback_ClosestConvexResultCallback_2:Rk,_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingFactor_1:Cu,_emscripten_bind_btManifoldPoint_set_m_localPointA_1:mr,_emscripten_bind_LocalConvexResult___destroy___0:Bx,_emscripten_bind_btVector3_dot_1:xs,_emscripten_bind_btVehicleTuning_get_m_maxSuspensionTravelCm_0:Vz,_emscripten_bind_btVector4_op_add_1:br,_emscripten_bind_btWheelInfo___destroy___0:Bx,_emscripten_bind_btSoftRigidDynamicsWorld_getSoftBodyArray_0:uy,_emscripten_bind_btTransform_setRotation_1:Xu,_emscripten_bind_Config_set_kSHR_1:ny,_emscripten_bind_btPoint2PointConstraint_enableFeedback_1:_v,_emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterGroup_1:rv,_emscripten_bind_btAxisSweep3_btAxisSweep3_2:up,_emscripten_bind_btAxisSweep3_btAxisSweep3_3:ap,_emscripten_bind_btConstraintSetting_set_m_impulseClamp_1:hy,_emscripten_bind_btVector3_setY_1:iy,_emscripten_bind_btAxisSweep3_btAxisSweep3_4:Po,_emscripten_bind_btAxisSweep3_btAxisSweep3_5:Ho,_emscripten_bind_btQuadWord_setX_1:By,_emscripten_bind_tMaterialArray___destroy___0:Ip,_emscripten_bind_btSoftBodyHelpers_CreateRope_5:qh,_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalLinearDampingThresholdSqr_0:$u,_emscripten_bind_Config_set_piterations_1:$w,_emscripten_bind_btOverlappingPairCache___destroy___0:Tt,_emscripten_bind_btRigidBody_setUserIndex_1:Pw,_emscripten_bind_Material_get_m_kAST_0:Zz,_emscripten_bind_btConstraintSetting___destroy___0:Bx,_emscripten_bind_RayResultCallback___destroy___0:Tt,_emscripten_bind_RaycastInfo_get_m_contactNormalWS_0:uA,_emscripten_bind_btSoftBodyWorldInfo_get_water_density_0:_z,_emscripten_bind_btPersistentManifold_getBody0_0:sy,_emscripten_bind_btConeShapeX_btConeShapeX_2:Zl,_emscripten_bind_btQuaternion_z_0:Zz,_emscripten_bind_btSoftBody_setCcdSweptSphereRadius_1:iw,_emscripten_bind_btConeTwistConstraint_enableFeedback_1:_v,_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_0:Sl,_emscripten_bind_btCapsuleShapeZ_setLocalScaling_1:fu,_emscripten_bind_ClosestConvexResultCallback_get_m_closestHitFraction_0:_z,_emscripten_bind_btSoftBody_translate_1:jm,_emscripten_bind_btSliderConstraint_setUpperLinLimit_1:ew,_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_2:pg,_emscripten_bind_btVector3_op_mul_1:Pr,_emscripten_bind_btConcaveShape___destroy___0:Tt,_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_4:rg,_emscripten_bind_btQuaternion_x_0:nA,_emscripten_bind_btSoftRigidDynamicsWorld_btSoftRigidDynamicsWorld_5:pf,_emscripten_bind_Config_set_timescale_1:wx,_emscripten_bind_LocalConvexResult_set_m_hitNormalLocal_1:qr,_emscripten_bind_btConcaveShape_setLocalScaling_1:fu,_emscripten_bind_btDiscreteDynamicsWorld_getDispatchInfo_0:qz,_emscripten_bind_btConeShapeX_setLocalScaling_1:fu,_emscripten_bind_btVehicleTuning_set_m_maxSuspensionForce_1:Yx,_emscripten_bind_btSoftBody_appendLink_4:Js,_emscripten_bind_btCylinderShapeZ_setLocalScaling_1:fu,_emscripten_bind_btConvexHullShape_btConvexHullShape_0:Eq,_emscripten_bind_btWheelInfo_set_m_maxSuspensionForce_1:iw,_emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterMask_1:sv,_emscripten_bind_btSoftBody_getTotalMass_0:Vo,_emscripten_bind_btSoftRigidDynamicsWorld_removeCollisionObject_1:pt,_emscripten_bind_Config_get_kLF_0:Iz,_emscripten_bind_btGhostObject___destroy___0:Rt,_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_2:Cs,_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_1:bt,_emscripten_bind_btGhostObject_setContactProcessingThreshold_1:fw,_emscripten_bind_btSoftBodyHelpers_CreateFromConvexHull_4:rr,_emscripten_bind_btCollisionWorld_getBroadphase_0:yy,_emscripten_bind_btRaycastVehicle_updateWheelTransform_2:Qr,_emscripten_bind_btQuaternion___destroy___0:Bx,_emscripten_bind_btStaticPlaneShape_calculateLocalInertia_2:ct,_emscripten_bind_btDefaultMotionState_btDefaultMotionState_2:Gg,_emscripten_bind_Material_set_m_flags_1:nx,_emscripten_bind_btDefaultMotionState_btDefaultMotionState_0:mh,_emscripten_bind_btDefaultMotionState_btDefaultMotionState_1:Lg,_emscripten_bind_Config_get_viterations_0:Vy,_emscripten_bind_btKinematicCharacterController_canJump_0:zu,_emscripten_bind_btSoftBodyArray_at_1:lv,_emscripten_bind_btVector4_length_0:Zr,_emscripten_bind_btPairCachingGhostObject_setUserIndex_1:Pw,_emscripten_bind_btRigidBody_isActive_0:Gv,_emscripten_bind_btRaycastVehicle_btRaycastVehicle_3:Nj,_emscripten_bind_btMotionState_setWorldTransform_1:bu,_emscripten_bind_btSoftRigidDynamicsWorld_getDispatcher_0:xy,_emscripten_bind_btCylinderShape_setLocalScaling_1:fu,_emscripten_bind_btPairCachingGhostObject_getWorldTransform_0:Qz,_emscripten_bind_btCompoundShape_calculateLocalInertia_2:ct,_emscripten_bind_btCollisionWorld_getDispatchInfo_0:qz,_emscripten_enum_PHY_ScalarType_PHY_DOUBLE:eB,_emscripten_bind_btRigidBody_setCollisionShape_1:bu,_emscripten_bind_btSoftBody_appendTetra_5:Qf,_emscripten_bind_btConeShapeX___destroy___0:Tt,_emscripten_bind_btCollisionObject_getCollisionFlags_0:wy,_emscripten_bind_btDispatcherInfo_set_m_enableSatConvex_1:Av,_emscripten_bind_btConeTwistConstraint_enableMotor_1:Rv,_emscripten_bind_btWheelInfo_set_m_chassisConnectionPointCS_1:Pq,_emscripten_bind_btSoftBody_checkLink_2:cm,_emscripten_bind_btRaycastVehicle_setCoordinateSystem_3:bs,_emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_4:Uj,_emscripten_bind_btVector3_normalize_0:fq,_emscripten_bind_btPairCachingGhostObject_setRestitution_1:Pt,_emscripten_bind_Config_set_kAHR_1:Sx,_emscripten_bind_btHeightfieldTerrainShape_getMargin_0:gv,_emscripten_bind_btBroadphaseInterface___destroy___0:Tt,_emscripten_bind_btSoftRigidDynamicsWorld_rayTest_3:Fs,_emscripten_bind_Config_get_kSRHR_CL_0:iz,_emscripten_bind_btSliderConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDampingFactor_1:Nu,_emscripten_bind_btCollisionObject_setContactProcessingThreshold_1:fw,_emscripten_bind_btCompoundShape___destroy___0:Tt,_emscripten_bind_btHingeConstraint_setMotorTarget_2:kk,_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingFactor_0:ov,_emscripten_bind_btCapsuleShapeX_setMargin_1:Bu,_emscripten_bind_btSequentialImpulseConstraintSolver___destroy___0:Tt,_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalLinearDampingThresholdSqr_1:tu,_emscripten_bind_btRigidBody_getCollisionFlags_0:wy,_emscripten_bind_btCollisionShape_setLocalScaling_1:fu,_emscripten_bind_Config_get_piterations_0:Wy,_emscripten_bind_LocalConvexResult_get_m_hitCollisionObject_0:Ly,_emscripten_bind_btMatrix3x3_setEulerZYX_3:Am,_emscripten_bind_btRigidBody_setRollingFriction_1:Ht,_emscripten_bind_btDispatcherInfo_get_m_convexConservativeDistanceThreshold_0:zz,_emscripten_bind_btRigidBody_getUserPointer_0:Ny,_emscripten_bind_Config_get_kSHR_0:xz,_emscripten_bind_btHeightfieldTerrainShape_calculateLocalInertia_2:ct,_emscripten_bind_btRigidBody_setMotionState_1:Fr,_emscripten_bind_RayResultCallback_get_m_collisionFilterMask_0:Zw,_emscripten_bind_btCollisionWorld_getDispatcher_0:xy,_emscripten_bind_btVector4_dot_1:xs,_emscripten_bind_btCollisionObject_setRollingFriction_1:Ht,_emscripten_bind_Config_set_kSK_SPLT_CL_1:px,_emscripten_bind_RayResultCallback_set_m_collisionFilterGroup_1:rv,_emscripten_bind_btTriangleMesh_btTriangleMesh_1:Cq,_i64Subtract:Is,_emscripten_bind_btCylinderShapeX_getMargin_0:gv,_emscripten_bind_btRigidBody_setDamping_2:Kn,_emscripten_bind_RayResultCallback_get_m_collisionFilterGroup_0:Vw,_emscripten_bind_btGhostObject_setCollisionFlags_1:yw,_emscripten_bind_btMatrix3x3_getRotation_1:Yu,_emscripten_bind_btWheelInfo_set_m_engineForce_1:Aw,_emscripten_bind_btConeTwistConstraint_setMaxMotorImpulse_1:wu,_emscripten_bind_btPersistentManifold_getNumContacts_0:Jx,_emscripten_bind_btCylinderShapeX_setLocalScaling_1:fu,_emscripten_bind_btDbvtBroadphase_btDbvtBroadphase_0:Ln,_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDamping_0:zv,_emscripten_bind_btCompoundShape_setLocalScaling_1:fu,_emscripten_bind_btOverlappingPairCallback___destroy___0:Tt,_emscripten_bind_btDynamicsWorld_convexSweepTest_5:Wq,_emscripten_bind_btCylinderShape_calculateLocalInertia_2:ct,_emscripten_bind_btPairCachingGhostObject_setCcdSweptSphereRadius_1:iw,_emscripten_bind_btRigidBody_getCollisionShape_0:vy,_emscripten_bind_btRigidBody_setContactProcessingThreshold_1:fw,_emscripten_bind_btRigidBody_getLinearVelocity_0:sz,_emscripten_bind_btRigidBody_applyImpulse_2:cu,_emscripten_bind_btConcaveShape_calculateLocalInertia_2:ct,_emscripten_bind_RaycastInfo_get_m_groundObject_0:Wy,_emscripten_bind_btRigidBody_setWorldTransform_1:pl,_emscripten_bind_btRigidBody_setAngularVelocity_1:Yp,_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_3:pk,_emscripten_bind_Config_get_kDP_0:Zz,_emscripten_bind_btConvexShape_setLocalScaling_1:fu,_emscripten_bind_Config_get_collisions_0:Yy,_emscripten_bind_btTriangleMeshShape_calculateLocalInertia_2:ct,_emscripten_bind_btVector4_setX_1:By,_emscripten_bind_btWheelInfo_get_m_chassisConnectionPointCS_0:oy,_emscripten_bind_btPairCachingGhostObject_setContactProcessingThreshold_1:fw,_emscripten_bind_btGeneric6DofConstraint_setLinearUpperLimit_1:Lq,_emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterMask_0:Zw,_emscripten_bind_RayResultCallback_hasHit_0:Px,_emscripten_bind_btSoftBody_isActive_0:Gv,_emscripten_bind_btRigidBody_applyLocalTorque_1:qm,_bitshift64Shl:is,_emscripten_bind_Config___destroy___0:Uk,_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingThresholdSqr_0:_u,_emscripten_bind_btVehicleTuning_get_m_suspensionDamping_0:Zz,_emscripten_bind_btRaycastVehicle_getWheelTransformWS_1:Eu,_emscripten_bind_btQuaternion_normalize_0:Oo,_emscripten_bind_ClosestConvexResultCallback_get_m_convexToWorld_0:qz,_emscripten_bind_btQuadWord_setZ_1:hy,_emscripten_bind_btConeShapeZ_setLocalScaling_1:fu,_emscripten_bind_Config_get_kPR_0:Gz,_emscripten_bind_btGeneric6DofSpringConstraint___destroy___0:Tt,_emscripten_bind_btConvexTriangleMeshShape___destroy___0:Tt,_emscripten_bind_btVehicleTuning_set_m_maxSuspensionTravelCm_1:jy,_emscripten_bind_Material_set_m_kAST_1:hy,_emscripten_bind_btGhostObject_setRollingFriction_1:Ht,_emscripten_bind_btCylinderShapeZ_btCylinderShapeZ_1:xp,_emscripten_bind_btRigidBody_getAngularVelocity_0:pz,_emscripten_bind_btCompoundShape_btCompoundShape_0:Tq,_emscripten_bind_btCompoundShape_btCompoundShape_1:Fq,_emscripten_bind_btOverlappingPairCache_setInternalGhostPairCallback_1:Ct,_emscripten_bind_btStaticPlaneShape_btStaticPlaneShape_2:tl,_emscripten_bind_btSphereShape_getMargin_0:gv,_emscripten_bind_btCollisionObject_setAnisotropicFriction_2:Ao,_emscripten_bind_btHingeConstraint_setAngularOnly_1:Wv,_emscripten_bind_btSoftRigidDynamicsWorld_contactTest_2:qn,_emscripten_bind_Config_get_kDG_0:Vz,_emscripten_bind_btPairCachingGhostObject_setAnisotropicFriction_2:Ao,_emscripten_bind_Node_get_m_x_0:yA,_emscripten_bind_btSoftBodyArray_size_0:Oz,_emscripten_bind_ClosestRayResultCallback_hasHit_0:Px,_emscripten_bind_btCompoundShape_addChildShape_2:Ud,_emscripten_bind_btDispatcher___destroy___0:Tt,_emscripten_bind_btVehicleTuning_get_m_suspensionCompression_0:_z,_emscripten_bind_btVehicleTuning_set_m_suspensionStiffness_1:By,_emscripten_bind_btDiscreteDynamicsWorld___destroy___0:Tt,_emscripten_bind_btConvexShape___destroy___0:Tt,_memmove:Bp,_emscripten_bind_btCapsuleShapeX_setLocalScaling_1:fu,_emscripten_bind_btPairCachingGhostObject_setCollisionFlags_1:yw,_emscripten_bind_btSoftBody_getCollisionFlags_0:wy,_emscripten_enum_PHY_ScalarType_PHY_INTEGER:dB,_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_1:Ym,_emscripten_bind_btCollisionObject_setRestitution_1:Pt,_emscripten_bind_btRigidBody_applyCentralForce_1:Ko,_emscripten_bind_btSoftBodyWorldInfo_set_m_gravity_1:dr,_emscripten_bind_LocalConvexResult_get_m_hitFraction_0:yz,_emscripten_bind_btDispatcherInfo_get_m_enableSPU_0:gx,_emscripten_bind_btQuaternion_w_0:Vz,_emscripten_bind_ConvexResultCallback_get_m_collisionFilterGroup_0:Ow,_emscripten_bind_btTransform_getRotation_0:Co,_emscripten_bind_Config_set_kSKHR_CL_1:Ex,_emscripten_bind_btHingeConstraint_btHingeConstraint_6:vo,_emscripten_bind_btHingeConstraint_btHingeConstraint_7:go,_emscripten_bind_LocalConvexResult_get_m_hitNormalLocal_0:yA,_emscripten_bind_btHingeConstraint_btHingeConstraint_5:xg,_emscripten_bind_btHingeConstraint_btHingeConstraint_2:Gp,_emscripten_bind_btHingeConstraint_btHingeConstraint_3:mp,_emscripten_bind_RaycastInfo___destroy___0:Bx,_emscripten_bind_btSoftBody_setWorldTransform_1:pl,_emscripten_bind_btBoxShape_setMargin_1:Bu,_emscripten_bind_ClosestConvexResultCallback_get_m_hitNormalWorld_0:Mx,_emscripten_bind_btVector4_y_0:_z,_emscripten_bind_Config_get_kSK_SPLT_CL_0:Ty,_emscripten_bind_btTypedConstraint___destroy___0:Tt,_emscripten_bind_btCylinderShapeX_btCylinderShapeX_1:yp,_emscripten_bind_btGeneric6DofSpringConstraint_setAngularUpperLimit_1:ho,_emscripten_bind_btConeTwistConstraint_setDamping_1:qw,_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_1:Mt,_emscripten_bind_Config_set_collisions_1:bx,_bitshift64Ashr:Mr,_emscripten_bind_btQuaternion_btQuaternion_4:Zm,_emscripten_bind_btSoftRigidDynamicsWorld_getBroadphase_0:yy,_emscripten_bind_btSoftBody_getCollisionShape_0:vy,_emscripten_bind_btSphereShape_btSphereShape_1:Fn,_emscripten_bind_btWheelInfo_get_m_wheelsSuspensionForce_0:kx,_emscripten_bind_btQuaternion_y_0:_z,_emscripten_bind_btCollisionWorld_addCollisionObject_1:vt,_emscripten_bind_btCollisionWorld_addCollisionObject_2:Ps,_emscripten_bind_btCollisionWorld_addCollisionObject_3:gs,_emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterGroup_1:iv,_emscripten_bind_btConeTwistConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_btSoftBodyHelpers_CreateEllipsoid_4:fh,_emscripten_bind_RaycastInfo_get_m_isInContact_0:vx,_emscripten_bind_Config_set_kKHR_1:Qx,_emscripten_bind_btHeightfieldTerrainShape_setMargin_1:Bu,_emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterGroup_0:Ow,_emscripten_bind_btCapsuleShape_setMargin_1:Bu,_emscripten_bind_btDefaultVehicleRaycaster_btDefaultVehicleRaycaster_1:zn,_emscripten_bind_ConcreteContactResultCallback_addSingleResult_7:Dq,_emscripten_bind_btCollisionObject_setUserPointer_1:Pw,_emscripten_bind_btSequentialImpulseConstraintSolver_btSequentialImpulseConstraintSolver_0:Oj,_emscripten_bind_btActionInterface___destroy___0:Tt,_emscripten_bind_btSoftBody_generateClusters_2:mu,_emscripten_bind_btDefaultMotionState_setWorldTransform_1:bu,_emscripten_bind_btCollisionWorld_contactTest_2:qn,_emscripten_bind_RayResultCallback_get_m_collisionObject_0:Ox,_emscripten_bind_btPoint2PointConstraint_getPivotInA_0:Qy,_emscripten_bind_Config_get_kAHR_0:Az,_emscripten_bind_ClosestConvexResultCallback_get_m_convexFromWorld_0:Kz,_emscripten_bind_btVector4_setY_1:iy,_emscripten_bind_btCompoundShape_setMargin_1:Bu,_emscripten_bind_btGhostObject_setRestitution_1:Pt,_emscripten_bind_btDynamicsWorld_addCollisionObject_1:vt,_emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterMask_0:Nw,_emscripten_bind_btDynamicsWorld_addCollisionObject_3:gs,_emscripten_bind_btDynamicsWorld_addCollisionObject_2:Ps,_emscripten_bind_btSoftRigidDynamicsWorld_getGravity_0:io,_emscripten_bind_btDiscreteDynamicsWorld_getDispatcher_0:xy,_emscripten_bind_btHeightfieldTerrainShape___destroy___0:Tt,_emscripten_bind_btManifoldPoint_get_m_positionWorldOnB_0:Uy,_emscripten_bind_btWheelInfo_get_m_maxSuspensionTravelCm_0:mx,_emscripten_bind_Config_get_kVC_0:Fz,_emscripten_bind_btVector4_op_mul_1:Pr,_emscripten_bind_btCylinderShape_btCylinderShape_1:rq,_emscripten_bind_btWheelInfo_set_m_suspensionStiffness_1:Sv,_emscripten_bind_Material_get_m_kVST_0:Vz,_emscripten_bind_Config_set_kVCF_1:iy,_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_3:ls,_emscripten_bind_btGhostObject_getUserIndex_0:Ny,_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_1:Qs,_emscripten_bind_btSoftBody_setRestitution_1:Pt,_emscripten_bind_btVector3___destroy___0:Au,_bitshift64Lshr:us,_emscripten_bind_btRigidBody_setAngularFactor_1:aq,_emscripten_bind_btCylinderShapeZ_calculateLocalInertia_2:ct,_emscripten_bind_btWheelInfo_set_m_steering_1:Kw,_emscripten_bind_btMotionState_getWorldTransform_1:Zt,_emscripten_bind_btDynamicsWorld_getSolverInfo_0:jl,_emscripten_bind_Config_get_kMT_0:Hz,_emscripten_bind_btDynamicsWorld_getBroadphase_0:yy,_emscripten_bind_btDispatcherInfo_set_m_convexConservativeDistanceThreshold_1:Rx,_emscripten_bind_Config_get_timescale_0:az,_emscripten_bind_btVector3_x_0:nA,___cxa_is_pointer_type:Ku,_emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_3:Fi,_emscripten_bind_btCollisionObject_getCollisionShape_0:vy,_emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_4:ti,_emscripten_bind_btManifoldPoint___destroy___0:Bx,_emscripten_bind_btRigidBodyConstructionInfo_set_m_rollingFriction_1:dv,_emscripten_bind_btVector3_z_0:Zz,_emscripten_bind_btGhostObject_setUserIndex_1:Pw,_emscripten_bind_btDefaultMotionState_set_m_graphicsWorldTrans_1:yl,_emscripten_bind_ClosestConvexResultCallback___destroy___0:Tt,_emscripten_bind_btDefaultCollisionConstructionInfo___destroy___0:Bx,_emscripten_bind_btCollisionObject_setFriction_1:Wt,_emscripten_bind_btQuadWord_y_0:_z,_emscripten_bind_btDefaultCollisionConfiguration___destroy___0:Tt,_emscripten_bind_btRigidBody_setMassProps_2:ck,_emscripten_bind_btVector3_setValue_3:ks,_emscripten_bind_btPairCachingGhostObject_setCcdMotionThreshold_1:Aw,_emscripten_bind_RaycastInfo_get_m_suspensionLength_0:Hz,_emscripten_bind_btGhostObject_getCollisionFlags_0:wy,_emscripten_bind_btCapsuleShapeX___destroy___0:Tt,_emscripten_bind_Config_set_kDG_1:jy,_emscripten_bind_btRigidBody_setActivationState_1:zt,_emscripten_bind_btRigidBody_updateInertiaTensor_0:Xj,_emscripten_bind_btHingeConstraint_setLimit_4:Un,_emscripten_bind_btHingeConstraint_setLimit_5:Nn,_emscripten_bind_btSoftBodyWorldInfo_btSoftBodyWorldInfo_0:Vk,_emscripten_bind_btWheelInfo_get_m_wheelsDampingRelaxation_0:Xw,_emscripten_bind_btWheelInfo_set_m_maxSuspensionTravelCm_1:Mv,_emscripten_bind_btConeShape_setLocalScaling_1:fu,_emscripten_bind_btSoftBody_scale_1:Xe,_emscripten_bind_Config_get_citerations_0:mz,_emscripten_bind_btTypedConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_btGhostObject_getCollisionShape_0:vy,_emscripten_bind_Config_get_kSSHR_CL_0:hz,_emscripten_bind_btBoxShape___destroy___0:Tt,_emscripten_bind_btWheelInfo_get_m_bIsFrontWheel_0:fx,_emscripten_bind_btPersistentManifold_getContactPoint_1:Vv,_emscripten_bind_btVector3_btVector3_0:sr,_emscripten_bind_btGeneric6DofSpringConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_btConeShapeX_calculateLocalInertia_2:ct,_emscripten_bind_RaycastInfo_set_m_groundObject_1:$w,_emscripten_bind_btGhostObject_activate_1:tr,_emscripten_bind_btGeneric6DofSpringConstraint_enableSpring_2:Qq,_emscripten_bind_btManifoldPoint_getPositionWorldOnB_0:Uy,_emscripten_bind_btManifoldPoint_get_m_positionWorldOnA_0:jA,_emscripten_bind_btDefaultSoftBodySolver_btDefaultSoftBodySolver_0:zm,_emscripten_bind_btSphereShape_setMargin_1:Bu,_emscripten_bind_btSoftBody_get_m_cfg_0:kA,_emscripten_bind_btCollisionObject_setUserIndex_1:Pw,_emscripten_bind_btContactSolverInfo_set_m_splitImpulsePenetrationThreshold_1:vu,_emscripten_bind_btSliderConstraint_setUpperAngLimit_1:vq,_emscripten_bind_btDynamicsWorld_contactPairTest_3:Ar,_emscripten_bind_btCollisionWorld_getPairCache_0:Et,_emscripten_bind_btConeTwistConstraint_setMotorTarget_1:oi,_emscripten_bind_ClosestConvexResultCallback_set_m_convexFromWorld_1:Jq,_emscripten_bind_btWheelInfo_set_m_rollInfluence_1:sw,_emscripten_bind_btRigidBody_getWorldTransform_0:Qz,_emscripten_bind_btDefaultCollisionConstructionInfo_btDefaultCollisionConstructionInfo_0:Om,_emscripten_bind_btGhostObject_forceActivationState_1:kw,_emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5:ye,_emscripten_bind_ConcreteContactResultCallback_ConcreteContactResultCallback_0:cn,_emscripten_bind_VoidPtr___destroy___0:Bx,_emscripten_bind_btSliderConstraint_setLowerAngLimit_1:wq,_emscripten_bind_btSoftBody_get_m_materials_0:Pz,_emscripten_bind_btVector4_op_sub_1:ar,_emscripten_bind_RaycastInfo_set_m_contactPointWS_1:fr,_emscripten_bind_RayResultCallback_set_m_collisionObject_1:gw,_emscripten_bind_ClosestRayResultCallback_get_m_rayFromWorld_0:ty,_emscripten_bind_btSoftBody_setContactProcessingThreshold_1:fw,_emscripten_bind_btPairCachingGhostObject_getNumOverlappingObjects_0:tx,_emscripten_bind_Config_get_kDF_0:Jz,_emscripten_bind_btWheelInfo_get_m_steering_0:Ay,_emscripten_bind_btConstraintSetting_get_m_tau_0:nA,_emscripten_bind_btSliderConstraint___destroy___0:Tt,_emscripten_bind_btCollisionObject_setCollisionShape_1:bu,_emscripten_bind_btCollisionShape___destroy___0:Tt,_emscripten_bind_btMatrix3x3_getRow_1:qp,_emscripten_bind_ConvexResultCallback_get_m_closestHitFraction_0:_z,_emscripten_bind_btTriangleMesh_addTriangle_4:yn,_emscripten_bind_btDispatcherInfo_get_m_dispatchFunc_0:Ox,_emscripten_bind_btRigidBodyConstructionInfo_get_m_rollingFriction_0:tw,_emscripten_bind_btSoftBody_getUserIndex_0:Ny,_emscripten_bind_btPairCachingGhostObject_setCollisionShape_1:bu,_emscripten_bind_btKinematicCharacterController_warp_1:Nt,_emscripten_bind_btAxisSweep3___destroy___0:Tt,_emscripten_bind_btSoftBody_getWorldTransform_0:Qz,_emscripten_bind_btTriangleMesh___destroy___0:Tt,_emscripten_bind_btKinematicCharacterController_preStep_1:It,_emscripten_bind_btRaycastVehicle_applyEngineForce_2:tt,_emscripten_bind_btRaycastVehicle_setBrake_2:Lt,_emscripten_bind_ConcreteContactResultCallback___destroy___0:Tt,_emscripten_bind_RaycastInfo_set_m_wheelAxleWS_1:hr,_emscripten_bind_btCollisionObject___destroy___0:Rt,_emscripten_bind_btVehicleTuning_set_m_suspensionDamping_1:hy,_emscripten_bind_btRigidBody_applyTorqueImpulse_1:km,_emscripten_bind_btTriangleMeshShape_setLocalScaling_1:fu,_emscripten_bind_btRigidBodyConstructionInfo_set_m_linearSleepingThreshold_1:Mu,_emscripten_bind_btConeTwistConstraint_setMotorTargetInConstraintSpace_1:Ms,_emscripten_bind_btDispatcherInfo_set_m_timeStep_1:By,_emscripten_bind_btVector3_btVector3_3:Tp,_emscripten_bind_RaycastInfo_set_m_contactNormalWS_1:mr,_emscripten_bind_btRigidBodyConstructionInfo_set_m_friction_1:yv,_emscripten_bind_btDiscreteDynamicsWorld_getGravity_0:lo,_emscripten_bind_ClosestConvexResultCallback_get_m_hitPointWorld_0:Tx,_emscripten_bind_btCollisionShape_getMargin_0:gv,_emscripten_bind_btSoftBodyWorldInfo_set_water_offset_1:hy,_emscripten_bind_btRigidBody_isKinematicObject_0:Tw,_emscripten_bind_RaycastInfo_get_m_hardPointWS_0:wz,_emscripten_bind_btConeTwistConstraint___destroy___0:Tt,_emscripten_bind_btQuadWord___destroy___0:Bx,_emscripten_bind_btSoftRigidDynamicsWorld_contactPairTest_3:Ar,_emscripten_bind_ClosestRayResultCallback_set_m_rayFromWorld_1:Uq,_emscripten_bind_btGeneric6DofSpringConstraint_setDamping_2:nu,_emscripten_bind_RaycastInfo_get_m_wheelDirectionWS_0:$y,_emscripten_bind_ClosestRayResultCallback_get_m_hitNormalWorld_0:$y,_emscripten_bind_btSoftBody_setUserIndex_1:Pw,_emscripten_bind_btSliderConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_btSoftBody_setCollisionShape_1:bu,_emscripten_bind_btGhostObject_setAnisotropicFriction_2:Ao,_emscripten_bind_btConstraintSolver___destroy___0:Tt,_emscripten_bind_btDbvtBroadphase___destroy___0:Tt,_emscripten_bind_btCapsuleShape_btCapsuleShape_2:Fm,_emscripten_bind_btTypedConstraint_enableFeedback_1:_v,_emscripten_bind_btSoftBody_setRollingFriction_1:Ht,_emscripten_bind_btGhostObject_activate_0:Xr,_emscripten_bind_btCapsuleShape_setLocalScaling_1:fu,_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDampingFactor_0:Nv,_emscripten_bind_btRigidBody_setAnisotropicFriction_2:Ao,_emscripten_bind_btSoftBody_btSoftBody_4:cp,_emscripten_bind_btSoftBody_activate_0:Xr,_emscripten_bind_btSoftBodyWorldInfo_set_air_density_1:By,_emscripten_bind_ConvexResultCallback_set_m_closestHitFraction_1:iy,_emscripten_bind_btVector3_op_add_1:br,_emscripten_bind_btPersistentManifold_btPersistentManifold_0:aj,_emscripten_bind_ConvexResultCallback_get_m_collisionFilterMask_0:Nw,_emscripten_bind_ClosestRayResultCallback_ClosestRayResultCallback_2:Mk,_emscripten_bind_btVector4___destroy___0:Au,_emscripten_bind_btPairCachingGhostObject_isKinematicObject_0:Tw,_emscripten_bind_btConstraintSetting_get_m_damping_0:_z,_emscripten_bind_tNodeArray_at_1:hw,_i64Add:Kt,_emscripten_bind_btContactSolverInfo_set_m_splitImpulse_1:vv,_emscripten_bind_btSoftBodyHelpers_CreatePatchUV_10:be,_emscripten_bind_btCollisionObject_setCcdMotionThreshold_1:Aw,_emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_0:am,_emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_1:kn,_emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_3:Zj,_emscripten_bind_btRigidBodyConstructionInfo_get_m_angularSleepingThreshold_0:Iv,_emscripten_bind_btPoint2PointConstraint_getPivotInB_0:Py,_emscripten_bind_btKinematicCharacterController_playerStep_2:Ts,_emscripten_bind_btDispatcherInfo___destroy___0:Bx,_emscripten_bind_btCapsuleShape_getMargin_0:gv,_emscripten_bind_btCylinderShape_getMargin_0:gv,_emscripten_bind_btStaticPlaneShape_setLocalScaling_1:fu,_emscripten_bind_btConvexTriangleMeshShape_calculateLocalInertia_2:ct,_emscripten_bind_btVector4_setValue_4:Lr,_emscripten_bind_ContactResultCallback_addSingleResult_7:Dq,_emscripten_bind_btGhostObject_getWorldTransform_0:Qz,_emscripten_bind_btDiscreteDynamicsWorld_getPairCache_0:Et,_emscripten_bind_LocalConvexResult_set_m_hitFraction_1:Qx,_emscripten_bind_btCapsuleShapeZ_calculateLocalInertia_2:ct,_emscripten_bind_btDispatcherInfo_get_m_timeStep_0:nA,_emscripten_bind_btConvexTriangleMeshShape_setMargin_1:Bu,_emscripten_bind_btWheelInfo_get_m_frictionSlip_0:gy,_emscripten_bind_btVehicleTuning_set_m_suspensionCompression_1:iy,_emscripten_bind_btBoxShape_calculateLocalInertia_2:ct,_emscripten_bind_btMotionState___destroy___0:Tt,_emscripten_bind_btCollisionObject_setCollisionFlags_1:yw,_emscripten_bind_btPairCachingGhostObject_setActivationState_1:zt,_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_1:bt,_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_2:Cs,_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_3:gs,_emscripten_bind_btGeneric6DofSpringConstraint_enableFeedback_1:_v,_emscripten_bind_Config_set_kSSHR_CL_1:Cx,_emscripten_bind_btDispatcher_getManifoldByIndexInternal_1:Bt,_emscripten_bind_btSoftBodyWorldInfo___destroy___0:rp,_emscripten_bind_btConvexTriangleMeshShape_getMargin_0:gv,_emscripten_bind_btSoftBodySolver___destroy___0:Tt,_emscripten_bind_Node_get_m_n_0:wA,_emscripten_bind_LocalShapeInfo_set_m_triangleIndex_1:pw,_emscripten_bind_btPairCachingGhostObject_setWorldTransform_1:pl,_emscripten_bind_btHingeConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_btConeTwistConstraint_setAngularOnly_1:Hv,_emscripten_bind_btGhostObject_setCcdSweptSphereRadius_1:iw,_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_4:ak,_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_2:Ei,_emscripten_bind_btGhostObject_getNumOverlappingObjects_0:tx,_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration___destroy___0:Tt,_emscripten_bind_ConvexResultCallback_set_m_collisionFilterGroup_1:iv,_emscripten_enum_PHY_ScalarType_PHY_FIXEDPOINT88:XA,_emscripten_bind_btPairCachingGhostObject_getOverlappingObject_1:Du,_emscripten_bind_btRigidBodyConstructionInfo___destroy___0:Bx,_emscripten_bind_btGeneric6DofConstraint_setBreakingImpulseThreshold_1:_x,_emscripten_bind_btPoint2PointConstraint_setPivotA_1:Zq,_emscripten_bind_ClosestConvexResultCallback_set_m_convexToWorld_1:Oq,_memcpy:_m,_emscripten_bind_Config_get_maxvolume_0:bz,_emscripten_bind_btCapsuleShape_calculateLocalInertia_2:ct,_emscripten_bind_btRigidBody___destroy___0:Rt,_emscripten_bind_btVector3_y_0:_z,_emscripten_bind_btDispatcherInfo_set_m_useEpa_1:lw,_emscripten_bind_btVehicleTuning_get_m_maxSuspensionForce_0:Gz,_emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_2:pp,_emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_3:$o,_emscripten_bind_LocalShapeInfo_get_m_triangleIndex_0:Oz,_emscripten_bind_Config_set_kDF_1:$x,_emscripten_bind_btHeightfieldTerrainShape_btHeightfieldTerrainShape_9:Ng,_emscripten_bind_btSoftBody_activate_1:tr,_emscripten_bind_btConeShapeZ_btConeShapeZ_2:Yl,_emscripten_bind_btGhostObject_setCollisionShape_1:bu,_emscripten_bind_btDispatcherInfo_set_m_allowedCcdPenetration_1:$x,_emscripten_bind_btQuaternion_setW_1:jy,_emscripten_bind_btPairCachingGhostObject_setRollingFriction_1:Ht,_emscripten_bind_btDiscreteDynamicsWorld_setGravity_1:Qt,_emscripten_bind_btGhostObject_isActive_0:Gv,_emscripten_bind_btVector4_z_0:Zz,_emscripten_bind_btCollisionObject_forceActivationState_1:kw,_emscripten_bind_btKinematicCharacterController_onGround_0:Vu,_emscripten_bind_btRaycastVehicle_getWheelInfo_1:av,_emscripten_bind_btGeneric6DofConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_btConeTwistConstraint_setLimit_2:jq,_emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterMask_1:hv,_emscripten_bind_btSoftBodyWorldInfo_get_water_normal_0:nz,_emscripten_bind_Node_set_m_x_1:qr,_emscripten_bind_btSoftBody_setFriction_1:Wt,_emscripten_bind_btRigidBody_setSleepingThresholds_2:_t,_emscripten_bind_btSoftBody_upcast_1:Qv,_emscripten_bind_btCollisionObject_setWorldTransform_1:pl,_emscripten_bind_LocalConvexResult_get_m_localShapeInfo_0:Oz,_emscripten_bind_btSoftBodyWorldInfo_set_m_dispatcher_1:Tv,_emscripten_bind_btStridingMeshInterface___destroy___0:Tt,_emscripten_bind_btSoftBody_setActivationState_1:zt,_emscripten_bind_btManifoldPoint_get_m_localPointA_0:uA,_emscripten_bind_btRigidBodyConstructionInfo_get_m_linearDamping_0:Ew,_emscripten_bind_btSoftBodyHelpers_CreatePatch_9:Ee,_emscripten_bind_btDispatcher_getNumManifolds_0:Uu,_emscripten_bind_btConvexShape_setMargin_1:Bu,_emscripten_bind_btSoftBody_get_m_nodes_0:bA,_emscripten_bind_btSoftBody___destroy___0:Rt,_emscripten_bind_btRigidBodyConstructionInfo_get_m_linearSleepingThreshold_0:rx,_emscripten_bind_btRigidBody_activate_1:tr,_emscripten_bind_btRigidBody_activate_0:Xr,_emscripten_bind_btRaycastVehicle___destroy___0:Tt,_emscripten_bind_btSoftBodyWorldInfo_get_m_gravity_0:fz,_emscripten_bind_btGhostObject_setActivationState_1:zt,_emscripten_bind_btSoftBodyArray___destroy___0:Ip,_emscripten_bind_Material_set_m_kLST_1:iy,_emscripten_bind_btCollisionWorld_contactPairTest_3:Ar,_emscripten_bind_btDispatcherInfo_get_m_useContinuous_0:Lw,_emscripten_bind_btHingeConstraint_setMaxMotorImpulse_1:$v,_emscripten_bind_Config_get_kSS_SPLT_CL_0:Dz,_emscripten_bind_btCylinderShapeX___destroy___0:Tt,_emscripten_bind_btSoftRigidDynamicsWorld_getWorldInfo_0:Jy,_emscripten_bind_btManifoldPoint_getPositionWorldOnA_0:jA,_emscripten_bind_ContactResultCallback___destroy___0:Tt,_emscripten_bind_btDispatcherInfo_get_m_useConvexConservativeDistanceUtil_0:pv,_emscripten_bind_btSoftBody_setAnisotropicFriction_2:Ao,_emscripten_bind_btConstraintSetting_btConstraintSetting_0:rn,_emscripten_bind_btRigidBody_getMotionState_0:Fy,_emscripten_bind_btKinematicCharacterController_getGhostObject_0:Ox,_emscripten_bind_btRigidBody_btRigidBody_1:zi,_emscripten_bind_btTriangleMeshShape___destroy___0:Tt,_emscripten_bind_btKinematicCharacterController_setWalkDirection_1:ot,_emscripten_bind_btDynamicsWorld_removeAction_1:du,_emscripten_bind_btRigidBody_applyTorque_1:No,_emscripten_bind_btRigidBodyConstructionInfo_get_m_restitution_0:Iw,_emscripten_bind_btTransform_setIdentity_0:vn,_emscripten_bind_btSoftBodyWorldInfo_get_air_density_0:nA,_emscripten_bind_btManifoldPoint_set_m_normalWorldOnB_1:$q,_emscripten_bind_btGhostObject_setUserPointer_1:Pw,_emscripten_bind_btKinematicCharacterController_getGravity_0:xz,_emscripten_enum_PHY_ScalarType_PHY_SHORT:gB,_emscripten_bind_btConeTwistConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_btDiscreteDynamicsWorld_addAction_1:ku,_emscripten_bind_btHingeConstraint_btHingeConstraint_4:Dg,_emscripten_bind_LocalShapeInfo_get_m_shapePart_0:Ly,_emscripten_bind_btConeShape_calculateLocalInertia_2:ct,_emscripten_bind_btCylinderShapeX_calculateLocalInertia_2:ct,_emscripten_bind_ConvexResultCallback_set_m_collisionFilterMask_1:hv,_llvm_bswap_i32:ow,_emscripten_bind_btSoftRigidDynamicsWorld_removeRigidBody_1:Ft,_emscripten_bind_btSphereShape_setLocalScaling_1:fu,_emscripten_bind_btRigidBody_applyCentralLocalForce_1:nm,_emscripten_bind_btVector4_w_0:Vz,_emscripten_bind_btManifoldPoint_get_m_normalWorldOnB_0:Ry,_emscripten_bind_btBvhTriangleMeshShape___destroy___0:Tt,_emscripten_bind_Config_set_citerations_1:cx,_emscripten_bind_btSoftBody_checkFace_3:Zk,_emscripten_bind_Config_get_kSKHR_CL_0:jz,_free:hd,_emscripten_bind_ClosestRayResultCallback_get_m_rayToWorld_0:wz,_emscripten_bind_ClosestConvexResultCallback_set_m_closestHitFraction_1:iy,_emscripten_bind_btDiscreteDynamicsWorld_removeConstraint_1:Ct,_emscripten_bind_btSoftBodyHelpers_btSoftBodyHelpers_0:xo,_emscripten_bind_Config_set_diterations_1:ax,_emscripten_bind_btGeneric6DofConstraint___destroy___0:Tt,_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_1:Mt,_emscripten_bind_btVector4_btVector4_4:Np,_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_3:ds,_emscripten_bind_btVector4_x_0:nA,_emscripten_bind_Config_set_kDP_1:hy,_emscripten_bind_btGhostObject_getUserPointer_0:Ny,_emscripten_bind_btConvexHullShape_addPoint_1:Ju,_emscripten_bind_btConvexHullShape_addPoint_2:$t,_emscripten_bind_btPoint2PointConstraint_getBreakingImpulseThreshold_0:Iz,_emscripten_bind_Config_set_kMT_1:Zx,_emscripten_bind_btTransform_getOrigin_0:jA,_emscripten_bind_Config_get_kKHR_0:yz,_emscripten_bind_Material_get_m_kLST_0:_z,_emscripten_bind_btHingeConstraint___destroy___0:Tt,_emscripten_bind_btPairCachingGhostObject_getUserPointer_0:Ny,_emscripten_bind_btSoftBody_set_m_nodes_1:sh,_emscripten_bind_Config_set_viterations_1:_w,_emscripten_bind_btConvexShape_calculateLocalInertia_2:ct,_memset:Qn,_emscripten_bind_btKinematicCharacterController___destroy___0:Tt,_emscripten_bind_btConvexHullShape_setLocalScaling_1:fu,_emscripten_bind_btTriangleMesh_btTriangleMesh_0:Sq,_emscripten_bind_btPairCachingGhostObject_getCollisionShape_0:vy,_emscripten_bind_btTriangleMesh_btTriangleMesh_2:gq,_emscripten_bind_btTransform___destroy___0:Bx,_emscripten_bind_btWheelInfo_set_m_frictionSlip_1:xw,_emscripten_bind_btSoftBodyHelpers___destroy___0:Bx,_emscripten_bind_btHingeConstraint_enableAngularMotor_3:cs,_emscripten_bind_btManifoldPoint_set_m_positionWorldOnA_1:kr,_emscripten_bind_btRigidBody_setCenterOfMassTransform_1:Yt,_emscripten_bind_btManifoldPoint_get_m_localPointB_0:nz,_emscripten_bind_btDiscreteDynamicsWorld_contactPairTest_3:Ar,_emscripten_bind_btSliderConstraint_setLowerLinLimit_1:fw,_emscripten_bind_btPoint2PointConstraint_set_m_setting_1:zr,_emscripten_bind_btCollisionObject_setCcdSweptSphereRadius_1:iw,_emscripten_bind_btWheelInfo_get_m_wheelsRadius_0:fy,_emscripten_bind_btRigidBody_setLinearVelocity_1:_p,_emscripten_bind_btVehicleTuning_btVehicleTuning_0:Hm,_emscripten_bind_Config_set_maxvolume_1:xx,_emscripten_bind_btDefaultSoftBodySolver___destroy___0:Tt,_emscripten_bind_ClosestRayResultCallback_set_m_rayToWorld_1:ir,_emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterGroup_0:Vw,_emscripten_bind_btWheelInfo_set_m_wheelsDampingRelaxation_1:Fv,_emscripten_bind_btDynamicsWorld_addAction_1:ku,_emscripten_bind_btDiscreteDynamicsWorld_removeAction_1:du,_emscripten_bind_btSoftBodyWorldInfo_set_m_maxDisplacement_1:jy,_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_2:hs,_emscripten_bind_btDefaultVehicleRaycaster___destroy___0:Tt,_emscripten_bind_btRigidBodyConstructionInfo_set_m_linearDamping_1:nv,_emscripten_bind_btQuaternion_setEulerZYX_3:Hn,_emscripten_bind_Config_set_kLF_1:_x,_emscripten_enum_PHY_ScalarType_PHY_FLOAT:hB,_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDamping_1:Su,_emscripten_bind_Config_set_kSS_SPLT_CL_1:dy,_emscripten_bind_btSoftBody_forceActivationState_1:kw,_emscripten_bind_btKinematicCharacterController_setFallSpeed_1:Xx,_emscripten_bind_Material_get_m_flags_0:gz,_emscripten_bind_btWheelInfo_get_m_wheelsDampingCompression_0:Sw,_emscripten_bind_ClosestConvexResultCallback_hasHit_0:Wx,_emscripten_bind_btCapsuleShapeZ___destroy___0:Tt,_emscripten_bind_btRaycastVehicle_getRigidBody_0:py,_emscripten_bind_btWheelInfo_get_m_maxSuspensionForce_0:Ax,_emscripten_bind_ClosestRayResultCallback_get_m_collisionObject_0:Ox,_emscripten_bind_btTriangleMesh_addTriangle_3:In,_emscripten_bind_btGhostObject_getOverlappingObject_1:Du,_emscripten_bind_btSoftRigidDynamicsWorld_getPairCache_0:Et,_emscripten_bind_btSoftRigidDynamicsWorld_getDispatchInfo_0:qz,_emscripten_bind_btSoftBodyWorldInfo_set_water_normal_1:fr,_emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_2:Rs,_emscripten_bind_btCompoundShape_getChildShape_1:xu,_emscripten_bind_btRigidBody_setCollisionFlags_1:yw,_emscripten_bind_btWheelInfo_set_m_suspensionRestLength1_1:Lv,_emscripten_bind_Config_set_kCHR_1:Rx,_emscripten_bind_btConeShape___destroy___0:Tt,_emscripten_bind_btCapsuleShapeZ_btCapsuleShapeZ_2:Dm,_emscripten_bind_btSoftRigidDynamicsWorld_addSoftBody_3:sj,_emscripten_bind_btSliderConstraint_btSliderConstraint_5:tf,_emscripten_bind_btSliderConstraint_btSliderConstraint_3:Je,_emscripten_bind_btDispatcherInfo_get_m_allowedCcdPenetration_0:Jz,_emscripten_bind_RaycastInfo_set_m_hardPointWS_1:ir,_emscripten_bind_btRigidBody_forceActivationState_1:kw,_emscripten_bind_btPoint2PointConstraint_setPivotB_1:Yq,_emscripten_bind_btManifoldPoint_getDistance_0:az,_emscripten_bind_btGhostPairCallback___destroy___0:Tt,_emscripten_bind_btTransform_setFromOpenGLMatrix_1:rm,_emscripten_bind_btKinematicCharacterController_getMaxSlope_0:zz,_emscripten_bind_btSliderConstraint_enableFeedback_1:_v,_emscripten_bind_btRaycastVehicle_addWheel_7:ce,_emscripten_bind_btPairCachingGhostObject_isActive_0:Gv,_emscripten_bind_LocalConvexResult_set_m_localShapeInfo_1:pw,_emscripten_bind_btStaticPlaneShape___destroy___0:Tt,_emscripten_bind_btHingeConstraint_enableMotor_1:jw,_emscripten_bind_btDispatcherInfo_set_m_stepCount_1:pw,_emscripten_bind_btBoxShape_setLocalScaling_1:fu,_emscripten_bind_btConeShapeZ___destroy___0:Tt,_emscripten_bind_btDynamicsWorld_getPairCache_0:Et,_emscripten_bind_btSoftRigidDynamicsWorld_convexSweepTest_5:Wq,_emscripten_bind_btDiscreteDynamicsWorld_convexSweepTest_5:Wq,_emscripten_bind_btKinematicCharacterController_setVelocityForTimeInterval_2:ts,_emscripten_bind_btRigidBody_setRestitution_1:Pt,_emscripten_bind_btVector4_btVector4_0:sr,_emscripten_bind_btDispatcherInfo_get_m_enableSatConvex_0:Fw,_emscripten_bind_btGhostObject_setCcdMotionThreshold_1:Aw,_emscripten_bind_btGeneric6DofConstraint_setLinearLowerLimit_1:Mq,_emscripten_bind_btGeneric6DofSpringConstraint_setLinearLowerLimit_1:Mq,_emscripten_bind_tMaterialArray_at_1:lv,_emscripten_bind_LocalConvexResult_set_m_hitCollisionObject_1:Mw,_emscripten_bind_Material_set_m_kVST_1:jy,_emscripten_bind_btGeneric6DofSpringConstraint_setAngularLowerLimit_1:po,_emscripten_bind_btSoftBodyWorldInfo_get_water_offset_0:Zz,_emscripten_bind_btDiscreteDynamicsWorld_rayTest_3:Fs,_emscripten_bind_btWheelInfo_get_m_raycastInfo_0:uA,_emscripten_bind_btContactSolverInfo_get_m_splitImpulse_0:Cw,_emscripten_bind_btConvexShape_getMargin_0:gv,_emscripten_bind_btGhostPairCallback_btGhostPairCallback_0:_n,_emscripten_bind_btKinematicCharacterController_setMaxJumpHeight_1:Zx,_emscripten_bind_ClosestRayResultCallback_set_m_hitNormalWorld_1:cr,_emscripten_bind_btVehicleTuning_get_m_frictionSlip_0:Iz,__GLOBAL__sub_I_btQuickprof_cpp:Cm,runPostSets:Hs,stackAlloc:kv,stackSave:rB,stackRestore:kB,establishStackSpace:rz,setThrew:ex,setTempRet0:mB,getTempRet0:pB,dynCall_viiiii:Zs,dynCall_vid:Nx,dynCall_vi:Rz,dynCall_viiidii:rs,dynCall_vii:ix,dynCall_iiiiiiiiiii:Vp,dynCall_ii:My,dynCall_viidi:ru,dynCall_viddiii:As,dynCall_vidii:su,dynCall_iiiii:Gt,dynCall_vidi:wv,dynCall_diiiiiiii:er,dynCall_viiiiddddiid:$p,dynCall_diiiii:Os,dynCall_vidd:dw,dynCall_iiii:Iu,dynCall_viiiiid:qs,dynCall_viiiiii:$r,dynCall_iiid:Zu,dynCall_di:ez,dynCall_iiiiiii:Kr,dynCall_diiidii:Wr,dynCall_viidii:it,dynCall_viiiiiii:wr,dynCall_viiiiiiiii:Hq,dynCall_viiiiiiiiii:dq,dynCall_iii:rw,dynCall_diii:Qu,dynCall_diiiiiiiiii:Xp,dynCall_viiiid:ht,dynCall_diiiiiiiii:Bq,dynCall_did:jx,dynCall_viiiidddddidi:Lp,dynCall_diidii:Xs,dynCall_diiii:Ot,dynCall_iiiiiiiiii:yq,dynCall_viiid:pu,dynCall_viii:cv,dynCall_v:cB,dynCall_viid:Dv,dynCall_iidid:ju,dynCall_viiii:au}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _emscripten_bind_btCylinderShape___destroy___0=Module["_emscripten_bind_btCylinderShape___destroy___0"]=asm["_emscripten_bind_btCylinderShape___destroy___0"];var _emscripten_bind_btGeneric6DofConstraint_enableFeedback_1=Module["_emscripten_bind_btGeneric6DofConstraint_enableFeedback_1"]=asm["_emscripten_bind_btGeneric6DofConstraint_enableFeedback_1"];var _emscripten_bind_btGhostObject___destroy___0=Module["_emscripten_bind_btGhostObject___destroy___0"]=asm["_emscripten_bind_btGhostObject___destroy___0"];var _emscripten_bind_btPoint2PointConstraint_set_m_setting_1=Module["_emscripten_bind_btPoint2PointConstraint_set_m_setting_1"]=asm["_emscripten_bind_btPoint2PointConstraint_set_m_setting_1"];var _emscripten_bind_btDispatcherInfo_get_m_enableSPU_0=Module["_emscripten_bind_btDispatcherInfo_get_m_enableSPU_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_enableSPU_0"];var _emscripten_bind_btDispatcherInfo_set_m_useContinuous_1=Module["_emscripten_bind_btDispatcherInfo_set_m_useContinuous_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_useContinuous_1"];var _emscripten_bind_btCollisionObject_isActive_0=Module["_emscripten_bind_btCollisionObject_isActive_0"]=asm["_emscripten_bind_btCollisionObject_isActive_0"];var _emscripten_bind_btVehicleTuning_set_m_frictionSlip_1=Module["_emscripten_bind_btVehicleTuning_set_m_frictionSlip_1"]=asm["_emscripten_bind_btVehicleTuning_set_m_frictionSlip_1"];var _emscripten_bind_btDiscreteDynamicsWorld_btDiscreteDynamicsWorld_4=Module["_emscripten_bind_btDiscreteDynamicsWorld_btDiscreteDynamicsWorld_4"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_btDiscreteDynamicsWorld_4"];var _emscripten_bind_btCapsuleShapeX_getMargin_0=Module["_emscripten_bind_btCapsuleShapeX_getMargin_0"]=asm["_emscripten_bind_btCapsuleShapeX_getMargin_0"];var _emscripten_bind_Node_set_m_n_1=Module["_emscripten_bind_Node_set_m_n_1"]=asm["_emscripten_bind_Node_set_m_n_1"];var _emscripten_bind_btCompoundShape_getMargin_0=Module["_emscripten_bind_btCompoundShape_getMargin_0"]=asm["_emscripten_bind_btCompoundShape_getMargin_0"];var _emscripten_bind_RaycastInfo_set_m_wheelDirectionWS_1=Module["_emscripten_bind_RaycastInfo_set_m_wheelDirectionWS_1"]=asm["_emscripten_bind_RaycastInfo_set_m_wheelDirectionWS_1"];var _emscripten_bind_btRigidBody_setUserPointer_1=Module["_emscripten_bind_btRigidBody_setUserPointer_1"]=asm["_emscripten_bind_btRigidBody_setUserPointer_1"];var _emscripten_bind_ClosestRayResultCallback_get_m_hitPointWorld_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_hitPointWorld_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_hitPointWorld_0"];var _emscripten_bind_btTypedConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btTypedConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btTypedConstraint_setBreakingImpulseThreshold_1"];var _emscripten_bind_btQuaternion_setX_1=Module["_emscripten_bind_btQuaternion_setX_1"]=asm["_emscripten_bind_btQuaternion_setX_1"];var _emscripten_bind_btCylinderShapeZ_getMargin_0=Module["_emscripten_bind_btCylinderShapeZ_getMargin_0"]=asm["_emscripten_bind_btCylinderShapeZ_getMargin_0"];var _emscripten_bind_btDispatcherInfo_get_m_timeOfImpact_0=Module["_emscripten_bind_btDispatcherInfo_get_m_timeOfImpact_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_timeOfImpact_0"];var _emscripten_bind_btQuaternion_setZ_1=Module["_emscripten_bind_btQuaternion_setZ_1"]=asm["_emscripten_bind_btQuaternion_setZ_1"];var _emscripten_bind_btCollisionObject_getUserIndex_0=Module["_emscripten_bind_btCollisionObject_getUserIndex_0"]=asm["_emscripten_bind_btCollisionObject_getUserIndex_0"];var _emscripten_bind_btDispatcherInfo_get_m_allowedCcdPenetration_0=Module["_emscripten_bind_btDispatcherInfo_get_m_allowedCcdPenetration_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_allowedCcdPenetration_0"];var _emscripten_bind_LocalConvexResult_get_m_hitNormalLocal_0=Module["_emscripten_bind_LocalConvexResult_get_m_hitNormalLocal_0"]=asm["_emscripten_bind_LocalConvexResult_get_m_hitNormalLocal_0"];var _emscripten_bind_btSoftBodyWorldInfo_set_water_density_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_water_density_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_water_density_1"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_restitution_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_restitution_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_restitution_0"];var _emscripten_bind_btKinematicCharacterController_setMaxSlope_1=Module["_emscripten_bind_btKinematicCharacterController_setMaxSlope_1"]=asm["_emscripten_bind_btKinematicCharacterController_setMaxSlope_1"];var _emscripten_bind_btQuadWord_z_0=Module["_emscripten_bind_btQuadWord_z_0"]=asm["_emscripten_bind_btQuadWord_z_0"];var _emscripten_bind_btSoftBody_setCcdMotionThreshold_1=Module["_emscripten_bind_btSoftBody_setCcdMotionThreshold_1"]=asm["_emscripten_bind_btSoftBody_setCcdMotionThreshold_1"];var _emscripten_bind_Material___destroy___0=Module["_emscripten_bind_Material___destroy___0"]=asm["_emscripten_bind_Material___destroy___0"];var _emscripten_bind_btHingeConstraint_btHingeConstraint_2=Module["_emscripten_bind_btHingeConstraint_btHingeConstraint_2"]=asm["_emscripten_bind_btHingeConstraint_btHingeConstraint_2"];var _emscripten_bind_btSoftBody_rotate_1=Module["_emscripten_bind_btSoftBody_rotate_1"]=asm["_emscripten_bind_btSoftBody_rotate_1"];var _emscripten_bind_btWheelInfo_get_m_suspensionRestLength1_0=Module["_emscripten_bind_btWheelInfo_get_m_suspensionRestLength1_0"]=asm["_emscripten_bind_btWheelInfo_get_m_suspensionRestLength1_0"];var _emscripten_bind_btWheelInfo_get_m_suspensionStiffness_0=Module["_emscripten_bind_btWheelInfo_get_m_suspensionStiffness_0"]=asm["_emscripten_bind_btWheelInfo_get_m_suspensionStiffness_0"];var _emscripten_bind_btVector4_setY_1=Module["_emscripten_bind_btVector4_setY_1"]=asm["_emscripten_bind_btVector4_setY_1"];var _emscripten_enum_PHY_ScalarType_PHY_UCHAR=Module["_emscripten_enum_PHY_ScalarType_PHY_UCHAR"]=asm["_emscripten_enum_PHY_ScalarType_PHY_UCHAR"];var _emscripten_bind_btQuaternion_setW_1=Module["_emscripten_bind_btQuaternion_setW_1"]=asm["_emscripten_bind_btQuaternion_setW_1"];var _emscripten_bind_btSoftRigidDynamicsWorld___destroy___0=Module["_emscripten_bind_btSoftRigidDynamicsWorld___destroy___0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld___destroy___0"];var _emscripten_bind_btSoftRigidDynamicsWorld_removeConstraint_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_removeConstraint_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_removeConstraint_1"];var _emscripten_bind_RaycastInfo_get_m_wheelAxleWS_0=Module["_emscripten_bind_RaycastInfo_get_m_wheelAxleWS_0"]=asm["_emscripten_bind_RaycastInfo_get_m_wheelAxleWS_0"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_angularDamping_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_angularDamping_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_angularDamping_0"];var _emscripten_bind_btCollisionDispatcher___destroy___0=Module["_emscripten_bind_btCollisionDispatcher___destroy___0"]=asm["_emscripten_bind_btCollisionDispatcher___destroy___0"];var _emscripten_bind_btRigidBody_applyCentralImpulse_1=Module["_emscripten_bind_btRigidBody_applyCentralImpulse_1"]=asm["_emscripten_bind_btRigidBody_applyCentralImpulse_1"];var _emscripten_bind_btConvexHullShape_getMargin_0=Module["_emscripten_bind_btConvexHullShape_getMargin_0"]=asm["_emscripten_bind_btConvexHullShape_getMargin_0"];var _emscripten_bind_btDefaultMotionState_getWorldTransform_1=Module["_emscripten_bind_btDefaultMotionState_getWorldTransform_1"]=asm["_emscripten_bind_btDefaultMotionState_getWorldTransform_1"];var _emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_1"];var _emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_3=Module["_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_3"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_3"];var _emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_2=Module["_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_2"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_2"];var _emscripten_bind_btSoftRigidDynamicsWorld_addAction_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addAction_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addAction_1"];var _emscripten_bind_btDynamicsWorld_rayTest_3=Module["_emscripten_bind_btDynamicsWorld_rayTest_3"]=asm["_emscripten_bind_btDynamicsWorld_rayTest_3"];var _emscripten_bind_Config_set_kSR_SPLT_CL_1=Module["_emscripten_bind_Config_set_kSR_SPLT_CL_1"]=asm["_emscripten_bind_Config_set_kSR_SPLT_CL_1"];var _emscripten_bind_btQuadWord_x_0=Module["_emscripten_bind_btQuadWord_x_0"]=asm["_emscripten_bind_btQuadWord_x_0"];var _emscripten_bind_Config_get_diterations_0=Module["_emscripten_bind_Config_get_diterations_0"]=asm["_emscripten_bind_Config_get_diterations_0"];var _emscripten_bind_btCollisionObject_isKinematicObject_0=Module["_emscripten_bind_btCollisionObject_isKinematicObject_0"]=asm["_emscripten_bind_btCollisionObject_isKinematicObject_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_removeSoftBody_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_removeSoftBody_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_removeSoftBody_1"];var _emscripten_bind_btSphereShape___destroy___0=Module["_emscripten_bind_btSphereShape___destroy___0"]=asm["_emscripten_bind_btSphereShape___destroy___0"];var _emscripten_bind_btGeneric6DofSpringConstraint_setLinearUpperLimit_1=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setLinearUpperLimit_1"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setLinearUpperLimit_1"];var _emscripten_bind_ClosestConvexResultCallback_set_m_hitNormalWorld_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_hitNormalWorld_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_hitNormalWorld_1"];var _emscripten_bind_btSoftBody_isKinematicObject_0=Module["_emscripten_bind_btSoftBody_isKinematicObject_0"]=asm["_emscripten_bind_btSoftBody_isKinematicObject_0"];var _emscripten_bind_btRigidBody_getCenterOfMassTransform_0=Module["_emscripten_bind_btRigidBody_getCenterOfMassTransform_0"]=asm["_emscripten_bind_btRigidBody_getCenterOfMassTransform_0"];var _emscripten_bind_btTransform_setIdentity_0=Module["_emscripten_bind_btTransform_setIdentity_0"]=asm["_emscripten_bind_btTransform_setIdentity_0"];var _emscripten_bind_btGhostObject_isKinematicObject_0=Module["_emscripten_bind_btGhostObject_isKinematicObject_0"]=asm["_emscripten_bind_btGhostObject_isKinematicObject_0"];var _emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_5=Module["_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_5"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_5"];var _emscripten_bind_btCapsuleShape___destroy___0=Module["_emscripten_bind_btCapsuleShape___destroy___0"]=asm["_emscripten_bind_btCapsuleShape___destroy___0"];var _emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_1=Module["_emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_1"]=asm["_emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_1"];var _emscripten_bind_btCollisionObject_activate_1=Module["_emscripten_bind_btCollisionObject_activate_1"]=asm["_emscripten_bind_btCollisionObject_activate_1"];var _emscripten_bind_btCollisionObject_activate_0=Module["_emscripten_bind_btCollisionObject_activate_0"]=asm["_emscripten_bind_btCollisionObject_activate_0"];var _emscripten_bind_btKinematicCharacterController_setUpAxis_1=Module["_emscripten_bind_btKinematicCharacterController_setUpAxis_1"]=asm["_emscripten_bind_btKinematicCharacterController_setUpAxis_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_1"];var _emscripten_bind_Config_set_kSSHR_CL_1=Module["_emscripten_bind_Config_set_kSSHR_CL_1"]=asm["_emscripten_bind_Config_set_kSSHR_CL_1"];var _emscripten_bind_btDispatcherInfo_set_m_timeOfImpact_1=Module["_emscripten_bind_btDispatcherInfo_set_m_timeOfImpact_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_timeOfImpact_1"];var _emscripten_bind_btCollisionDispatcher_btCollisionDispatcher_1=Module["_emscripten_bind_btCollisionDispatcher_btCollisionDispatcher_1"]=asm["_emscripten_bind_btCollisionDispatcher_btCollisionDispatcher_1"];var _emscripten_bind_btVector3_setX_1=Module["_emscripten_bind_btVector3_setX_1"]=asm["_emscripten_bind_btVector3_setX_1"];var _emscripten_bind_btCollisionConfiguration___destroy___0=Module["_emscripten_bind_btCollisionConfiguration___destroy___0"]=asm["_emscripten_bind_btCollisionConfiguration___destroy___0"];var _emscripten_bind_btCapsuleShapeZ_setMargin_1=Module["_emscripten_bind_btCapsuleShapeZ_setMargin_1"]=asm["_emscripten_bind_btCapsuleShapeZ_setMargin_1"];var _emscripten_bind_btHingeConstraint_enableFeedback_1=Module["_emscripten_bind_btHingeConstraint_enableFeedback_1"]=asm["_emscripten_bind_btHingeConstraint_enableFeedback_1"];var _emscripten_bind_btHeightfieldTerrainShape_setLocalScaling_1=Module["_emscripten_bind_btHeightfieldTerrainShape_setLocalScaling_1"]=asm["_emscripten_bind_btHeightfieldTerrainShape_setLocalScaling_1"];var _emscripten_bind_btManifoldPoint_set_m_positionWorldOnB_1=Module["_emscripten_bind_btManifoldPoint_set_m_positionWorldOnB_1"]=asm["_emscripten_bind_btManifoldPoint_set_m_positionWorldOnB_1"];var _emscripten_bind_Config_set_kMT_1=Module["_emscripten_bind_Config_set_kMT_1"]=asm["_emscripten_bind_Config_set_kMT_1"];var _emscripten_bind_btManifoldPoint_set_m_localPointB_1=Module["_emscripten_bind_btManifoldPoint_set_m_localPointB_1"]=asm["_emscripten_bind_btManifoldPoint_set_m_localPointB_1"];var _emscripten_bind_btVector3_setZ_1=Module["_emscripten_bind_btVector3_setZ_1"]=asm["_emscripten_bind_btVector3_setZ_1"];var _emscripten_bind_btKinematicCharacterController_setUseGhostSweepTest_1=Module["_emscripten_bind_btKinematicCharacterController_setUseGhostSweepTest_1"]=asm["_emscripten_bind_btKinematicCharacterController_setUseGhostSweepTest_1"];var _emscripten_bind_btQuaternion_setValue_4=Module["_emscripten_bind_btQuaternion_setValue_4"]=asm["_emscripten_bind_btQuaternion_setValue_4"];var _emscripten_bind_btDispatcherInfo_set_m_dispatchFunc_1=Module["_emscripten_bind_btDispatcherInfo_set_m_dispatchFunc_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_dispatchFunc_1"];var _emscripten_bind_btSoftBody_transform_1=Module["_emscripten_bind_btSoftBody_transform_1"]=asm["_emscripten_bind_btSoftBody_transform_1"];var _emscripten_bind_LocalShapeInfo___destroy___0=Module["_emscripten_bind_LocalShapeInfo___destroy___0"]=asm["_emscripten_bind_LocalShapeInfo___destroy___0"];var _emscripten_bind_btSoftBody_appendAnchor_4=Module["_emscripten_bind_btSoftBody_appendAnchor_4"]=asm["_emscripten_bind_btSoftBody_appendAnchor_4"];var _emscripten_bind_btWheelInfo_get_m_bIsFrontWheel_0=Module["_emscripten_bind_btWheelInfo_get_m_bIsFrontWheel_0"]=asm["_emscripten_bind_btWheelInfo_get_m_bIsFrontWheel_0"];var _emscripten_bind_btQuadWord_setY_1=Module["_emscripten_bind_btQuadWord_setY_1"]=asm["_emscripten_bind_btQuadWord_setY_1"];var _emscripten_bind_btRigidBody_isKinematicObject_0=Module["_emscripten_bind_btRigidBody_isKinematicObject_0"]=asm["_emscripten_bind_btRigidBody_isKinematicObject_0"];var _emscripten_bind_ContactResultCallback_addSingleResult_7=Module["_emscripten_bind_ContactResultCallback_addSingleResult_7"]=asm["_emscripten_bind_ContactResultCallback_addSingleResult_7"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_restitution_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_restitution_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_restitution_1"];var _emscripten_bind_btDefaultMotionState_get_m_graphicsWorldTrans_0=Module["_emscripten_bind_btDefaultMotionState_get_m_graphicsWorldTrans_0"]=asm["_emscripten_bind_btDefaultMotionState_get_m_graphicsWorldTrans_0"];var _emscripten_bind_btSliderConstraint_btSliderConstraint_5=Module["_emscripten_bind_btSliderConstraint_btSliderConstraint_5"]=asm["_emscripten_bind_btSliderConstraint_btSliderConstraint_5"];var _emscripten_bind_btConeTwistConstraint_setDamping_1=Module["_emscripten_bind_btConeTwistConstraint_setDamping_1"]=asm["_emscripten_bind_btConeTwistConstraint_setDamping_1"];var _emscripten_bind_btPairCachingGhostObject_btPairCachingGhostObject_0=Module["_emscripten_bind_btPairCachingGhostObject_btPairCachingGhostObject_0"]=asm["_emscripten_bind_btPairCachingGhostObject_btPairCachingGhostObject_0"];var _emscripten_bind_btDiscreteDynamicsWorld_getSolverInfo_0=Module["_emscripten_bind_btDiscreteDynamicsWorld_getSolverInfo_0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_getSolverInfo_0"];var _emscripten_bind_btCylinderShape_setMargin_1=Module["_emscripten_bind_btCylinderShape_setMargin_1"]=asm["_emscripten_bind_btCylinderShape_setMargin_1"];var _emscripten_bind_btCollisionWorld___destroy___0=Module["_emscripten_bind_btCollisionWorld___destroy___0"]=asm["_emscripten_bind_btCollisionWorld___destroy___0"];var _emscripten_bind_btSoftBodyWorldInfo_get_m_broadphase_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_m_broadphase_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_m_broadphase_0"];var _emscripten_bind_LocalConvexResult_get_m_hitPointLocal_0=Module["_emscripten_bind_LocalConvexResult_get_m_hitPointLocal_0"]=asm["_emscripten_bind_LocalConvexResult_get_m_hitPointLocal_0"];var _emscripten_bind_btBoxShape_btBoxShape_1=Module["_emscripten_bind_btBoxShape_btBoxShape_1"]=asm["_emscripten_bind_btBoxShape_btBoxShape_1"];var _emscripten_bind_btPersistentManifold_getBody1_0=Module["_emscripten_bind_btPersistentManifold_getBody1_0"]=asm["_emscripten_bind_btPersistentManifold_getBody1_0"];var _emscripten_bind_ClosestRayResultCallback_set_m_collisionObject_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_collisionObject_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_collisionObject_1"];var _emscripten_bind_RaycastInfo_set_m_isInContact_1=Module["_emscripten_bind_RaycastInfo_set_m_isInContact_1"]=asm["_emscripten_bind_RaycastInfo_set_m_isInContact_1"];var _emscripten_bind_btKinematicCharacterController_setGravity_1=Module["_emscripten_bind_btKinematicCharacterController_setGravity_1"]=asm["_emscripten_bind_btKinematicCharacterController_setGravity_1"];var _emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_5=Module["_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_5"]=asm["_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_5"];var _emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_3=Module["_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_3"]=asm["_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_3"];var _emscripten_bind_LocalShapeInfo_get_m_shapePart_0=Module["_emscripten_bind_LocalShapeInfo_get_m_shapePart_0"]=asm["_emscripten_bind_LocalShapeInfo_get_m_shapePart_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_removeAction_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_removeAction_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_removeAction_1"];var _emscripten_bind_btWheelInfo_get_m_rollInfluence_0=Module["_emscripten_bind_btWheelInfo_get_m_rollInfluence_0"]=asm["_emscripten_bind_btWheelInfo_get_m_rollInfluence_0"];var _emscripten_bind_btVector4_setValue_4=Module["_emscripten_bind_btVector4_setValue_4"]=asm["_emscripten_bind_btVector4_setValue_4"];var _emscripten_bind_btBvhTriangleMeshShape_setLocalScaling_1=Module["_emscripten_bind_btBvhTriangleMeshShape_setLocalScaling_1"]=asm["_emscripten_bind_btBvhTriangleMeshShape_setLocalScaling_1"];var _emscripten_bind_tNodeArray_size_0=Module["_emscripten_bind_tNodeArray_size_0"]=asm["_emscripten_bind_tNodeArray_size_0"];var _emscripten_bind_btPoint2PointConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btPoint2PointConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btPoint2PointConstraint_setBreakingImpulseThreshold_1"];var _emscripten_bind_btDynamicsWorld_getDispatchInfo_0=Module["_emscripten_bind_btDynamicsWorld_getDispatchInfo_0"]=asm["_emscripten_bind_btDynamicsWorld_getDispatchInfo_0"];var _emscripten_bind_btCompoundShape_removeChildShapeByIndex_1=Module["_emscripten_bind_btCompoundShape_removeChildShapeByIndex_1"]=asm["_emscripten_bind_btCompoundShape_removeChildShapeByIndex_1"];var _emscripten_bind_btVector3_length_0=Module["_emscripten_bind_btVector3_length_0"]=asm["_emscripten_bind_btVector3_length_0"];var _emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_2=Module["_emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_2"]=asm["_emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_2"];var _emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_1=Module["_emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_1"]=asm["_emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_1"];var _emscripten_bind_ClosestConvexResultCallback_set_m_hitPointWorld_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_hitPointWorld_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_hitPointWorld_1"];var _emscripten_bind_RayResultCallback_set_m_collisionFilterMask_1=Module["_emscripten_bind_RayResultCallback_set_m_collisionFilterMask_1"]=asm["_emscripten_bind_RayResultCallback_set_m_collisionFilterMask_1"];var _emscripten_bind_btBoxShape_getMargin_0=Module["_emscripten_bind_btBoxShape_getMargin_0"]=asm["_emscripten_bind_btBoxShape_getMargin_0"];var _emscripten_bind_btPairCachingGhostObject___destroy___0=Module["_emscripten_bind_btPairCachingGhostObject___destroy___0"]=asm["_emscripten_bind_btPairCachingGhostObject___destroy___0"];var _emscripten_bind_btPairCachingGhostObject_setUserPointer_1=Module["_emscripten_bind_btPairCachingGhostObject_setUserPointer_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setUserPointer_1"];var _emscripten_bind_btDynamicsWorld_addCollisionObject_3=Module["_emscripten_bind_btDynamicsWorld_addCollisionObject_3"]=asm["_emscripten_bind_btDynamicsWorld_addCollisionObject_3"];var _emscripten_bind_btPairCachingGhostObject_activate_0=Module["_emscripten_bind_btPairCachingGhostObject_activate_0"]=asm["_emscripten_bind_btPairCachingGhostObject_activate_0"];var _emscripten_bind_btPairCachingGhostObject_activate_1=Module["_emscripten_bind_btPairCachingGhostObject_activate_1"]=asm["_emscripten_bind_btPairCachingGhostObject_activate_1"];var _emscripten_bind_btContactSolverInfo_get_m_splitImpulsePenetrationThreshold_0=Module["_emscripten_bind_btContactSolverInfo_get_m_splitImpulsePenetrationThreshold_0"]=asm["_emscripten_bind_btContactSolverInfo_get_m_splitImpulsePenetrationThreshold_0"];var _emscripten_bind_btSoftBody_setUserPointer_1=Module["_emscripten_bind_btSoftBody_setUserPointer_1"]=asm["_emscripten_bind_btSoftBody_setUserPointer_1"];var _emscripten_bind_btSoftBody_setMass_2=Module["_emscripten_bind_btSoftBody_setMass_2"]=asm["_emscripten_bind_btSoftBody_setMass_2"];var _emscripten_bind_Config_get_kCHR_0=Module["_emscripten_bind_Config_get_kCHR_0"]=asm["_emscripten_bind_Config_get_kCHR_0"];var _emscripten_bind_btPairCachingGhostObject_forceActivationState_1=Module["_emscripten_bind_btPairCachingGhostObject_forceActivationState_1"]=asm["_emscripten_bind_btPairCachingGhostObject_forceActivationState_1"];var _emscripten_bind_btDefaultMotionState___destroy___0=Module["_emscripten_bind_btDefaultMotionState___destroy___0"]=asm["_emscripten_bind_btDefaultMotionState___destroy___0"];var _emscripten_bind_btDispatcherInfo_get_m_stepCount_0=Module["_emscripten_bind_btDispatcherInfo_get_m_stepCount_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_stepCount_0"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_angularDamping_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_angularDamping_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_angularDamping_1"];var _emscripten_bind_btQuadWord_setW_1=Module["_emscripten_bind_btQuadWord_setW_1"]=asm["_emscripten_bind_btQuadWord_setW_1"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_friction_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_friction_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_friction_0"];var _emscripten_bind_btCapsuleShapeX_btCapsuleShapeX_2=Module["_emscripten_bind_btCapsuleShapeX_btCapsuleShapeX_2"]=asm["_emscripten_bind_btCapsuleShapeX_btCapsuleShapeX_2"];var _emscripten_bind_LocalShapeInfo_set_m_shapePart_1=Module["_emscripten_bind_LocalShapeInfo_set_m_shapePart_1"]=asm["_emscripten_bind_LocalShapeInfo_set_m_shapePart_1"];var _emscripten_bind_btRigidBody_setLinearFactor_1=Module["_emscripten_bind_btRigidBody_setLinearFactor_1"]=asm["_emscripten_bind_btRigidBody_setLinearFactor_1"];var _emscripten_bind_btCompoundShape_getChildShape_1=Module["_emscripten_bind_btCompoundShape_getChildShape_1"]=asm["_emscripten_bind_btCompoundShape_getChildShape_1"];var _emscripten_bind_btDispatcherInfo_set_m_useConvexConservativeDistanceUtil_1=Module["_emscripten_bind_btDispatcherInfo_set_m_useConvexConservativeDistanceUtil_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_useConvexConservativeDistanceUtil_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_setGravity_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_setGravity_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_setGravity_1"];var _emscripten_bind_btRaycastVehicle_getCurrentSpeedKmHour_0=Module["_emscripten_bind_btRaycastVehicle_getCurrentSpeedKmHour_0"]=asm["_emscripten_bind_btRaycastVehicle_getCurrentSpeedKmHour_0"];var _emscripten_bind_btWheelInfo_get_m_engineForce_0=Module["_emscripten_bind_btWheelInfo_get_m_engineForce_0"]=asm["_emscripten_bind_btWheelInfo_get_m_engineForce_0"];var _emscripten_bind_Config_get_kSR_SPLT_CL_0=Module["_emscripten_bind_Config_get_kSR_SPLT_CL_0"]=asm["_emscripten_bind_Config_get_kSR_SPLT_CL_0"];var _emscripten_bind_btRaycastVehicle_setSteeringValue_2=Module["_emscripten_bind_btRaycastVehicle_setSteeringValue_2"]=asm["_emscripten_bind_btRaycastVehicle_setSteeringValue_2"];var _emscripten_bind_btPoint2PointConstraint___destroy___0=Module["_emscripten_bind_btPoint2PointConstraint___destroy___0"]=asm["_emscripten_bind_btPoint2PointConstraint___destroy___0"];var _emscripten_bind_btSoftBody_getUserPointer_0=Module["_emscripten_bind_btSoftBody_getUserPointer_0"]=asm["_emscripten_bind_btSoftBody_getUserPointer_0"];var _emscripten_bind_btCollisionShape_setMargin_1=Module["_emscripten_bind_btCollisionShape_setMargin_1"]=asm["_emscripten_bind_btCollisionShape_setMargin_1"];var _emscripten_bind_btGeneric6DofConstraint_setAngularUpperLimit_1=Module["_emscripten_bind_btGeneric6DofConstraint_setAngularUpperLimit_1"]=asm["_emscripten_bind_btGeneric6DofConstraint_setAngularUpperLimit_1"];var _emscripten_bind_btDiscreteDynamicsWorld_addConstraint_2=Module["_emscripten_bind_btDiscreteDynamicsWorld_addConstraint_2"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addConstraint_2"];var _emscripten_bind_btDiscreteDynamicsWorld_addConstraint_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_addConstraint_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addConstraint_1"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_angularSleepingThreshold_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_angularSleepingThreshold_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_angularSleepingThreshold_1"];var _emscripten_bind_Config_get_kVCF_0=Module["_emscripten_bind_Config_get_kVCF_0"]=asm["_emscripten_bind_Config_get_kVCF_0"];var _malloc=Module["_malloc"]=asm["_malloc"];var _emscripten_bind_btDispatcherInfo_get_m_useEpa_0=Module["_emscripten_bind_btDispatcherInfo_get_m_useEpa_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_useEpa_0"];var _emscripten_bind_btTransform_btTransform_2=Module["_emscripten_bind_btTransform_btTransform_2"]=asm["_emscripten_bind_btTransform_btTransform_2"];var _emscripten_bind_btTransform_btTransform_0=Module["_emscripten_bind_btTransform_btTransform_0"]=asm["_emscripten_bind_btTransform_btTransform_0"];var _emscripten_bind_btPairCachingGhostObject_getUserIndex_0=Module["_emscripten_bind_btPairCachingGhostObject_getUserIndex_0"]=asm["_emscripten_bind_btPairCachingGhostObject_getUserIndex_0"];var _emscripten_bind_Config_set_kVC_1=Module["_emscripten_bind_Config_set_kVC_1"]=asm["_emscripten_bind_Config_set_kVC_1"];var _emscripten_bind_btVector3_op_sub_1=Module["_emscripten_bind_btVector3_op_sub_1"]=asm["_emscripten_bind_btVector3_op_sub_1"];var _emscripten_bind_btWheelInfo_set_m_wheelsRadius_1=Module["_emscripten_bind_btWheelInfo_set_m_wheelsRadius_1"]=asm["_emscripten_bind_btWheelInfo_set_m_wheelsRadius_1"];var _emscripten_bind_RaycastInfo_set_m_hardPointWS_1=Module["_emscripten_bind_RaycastInfo_set_m_hardPointWS_1"]=asm["_emscripten_bind_RaycastInfo_set_m_hardPointWS_1"];var _emscripten_bind_btDispatcherInfo_set_m_enableSPU_1=Module["_emscripten_bind_btDispatcherInfo_set_m_enableSPU_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_enableSPU_1"];var _emscripten_bind_btWheelInfo_set_m_wheelsDampingCompression_1=Module["_emscripten_bind_btWheelInfo_set_m_wheelsDampingCompression_1"]=asm["_emscripten_bind_btWheelInfo_set_m_wheelsDampingCompression_1"];var _emscripten_bind_btSoftBody_appendNode_2=Module["_emscripten_bind_btSoftBody_appendNode_2"]=asm["_emscripten_bind_btSoftBody_appendNode_2"];var _emscripten_bind_btCollisionObject_setActivationState_1=Module["_emscripten_bind_btCollisionObject_setActivationState_1"]=asm["_emscripten_bind_btCollisionObject_setActivationState_1"];var _emscripten_bind_btPersistentManifold___destroy___0=Module["_emscripten_bind_btPersistentManifold___destroy___0"]=asm["_emscripten_bind_btPersistentManifold___destroy___0"];var _emscripten_bind_btConstraintSetting_get_m_impulseClamp_0=Module["_emscripten_bind_btConstraintSetting_get_m_impulseClamp_0"]=asm["_emscripten_bind_btConstraintSetting_get_m_impulseClamp_0"];var _emscripten_bind_btCylinderShapeZ___destroy___0=Module["_emscripten_bind_btCylinderShapeZ___destroy___0"]=asm["_emscripten_bind_btCylinderShapeZ___destroy___0"];var _emscripten_bind_btMatrix3x3___destroy___0=Module["_emscripten_bind_btMatrix3x3___destroy___0"]=asm["_emscripten_bind_btMatrix3x3___destroy___0"];var _emscripten_bind_ConvexResultCallback_hasHit_0=Module["_emscripten_bind_ConvexResultCallback_hasHit_0"]=asm["_emscripten_bind_ConvexResultCallback_hasHit_0"];var _emscripten_bind_btCollisionShape_calculateLocalInertia_2=Module["_emscripten_bind_btCollisionShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btCollisionShape_calculateLocalInertia_2"];var _emscripten_bind_btGeneric6DofSpringConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setBreakingImpulseThreshold_1"];var _emscripten_bind_Config_set_kPR_1=Module["_emscripten_bind_Config_set_kPR_1"]=asm["_emscripten_bind_Config_set_kPR_1"];var _emscripten_bind_btCollisionWorld_convexSweepTest_5=Module["_emscripten_bind_btCollisionWorld_convexSweepTest_5"]=asm["_emscripten_bind_btCollisionWorld_convexSweepTest_5"];var _emscripten_bind_btSoftBody_set_m_materials_1=Module["_emscripten_bind_btSoftBody_set_m_materials_1"]=asm["_emscripten_bind_btSoftBody_set_m_materials_1"];var _emscripten_bind_ClosestRayResultCallback_set_m_hitPointWorld_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_hitPointWorld_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_hitPointWorld_1"];var _emscripten_bind_btCapsuleShapeX_calculateLocalInertia_2=Module["_emscripten_bind_btCapsuleShapeX_calculateLocalInertia_2"]=asm["_emscripten_bind_btCapsuleShapeX_calculateLocalInertia_2"];var _emscripten_bind_btConstraintSetting_set_m_damping_1=Module["_emscripten_bind_btConstraintSetting_set_m_damping_1"]=asm["_emscripten_bind_btConstraintSetting_set_m_damping_1"];var _emscripten_bind_btWheelInfo_set_m_bIsFrontWheel_1=Module["_emscripten_bind_btWheelInfo_set_m_bIsFrontWheel_1"]=asm["_emscripten_bind_btWheelInfo_set_m_bIsFrontWheel_1"];var _emscripten_bind_btRigidBody_setCcdMotionThreshold_1=Module["_emscripten_bind_btRigidBody_setCcdMotionThreshold_1"]=asm["_emscripten_bind_btRigidBody_setCcdMotionThreshold_1"];var _emscripten_bind_btConvexHullShape_setMargin_1=Module["_emscripten_bind_btConvexHullShape_setMargin_1"]=asm["_emscripten_bind_btConvexHullShape_setMargin_1"];var _emscripten_bind_btRigidBody_applyForce_2=Module["_emscripten_bind_btRigidBody_applyForce_2"]=asm["_emscripten_bind_btRigidBody_applyForce_2"];var _emscripten_bind_btConeShapeZ_calculateLocalInertia_2=Module["_emscripten_bind_btConeShapeZ_calculateLocalInertia_2"]=asm["_emscripten_bind_btConeShapeZ_calculateLocalInertia_2"];var _emscripten_bind_btConstraintSetting_set_m_tau_1=Module["_emscripten_bind_btConstraintSetting_set_m_tau_1"]=asm["_emscripten_bind_btConstraintSetting_set_m_tau_1"];var _emscripten_bind_btConvexHullShape_calculateLocalInertia_2=Module["_emscripten_bind_btConvexHullShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btConvexHullShape_calculateLocalInertia_2"];var _emscripten_bind_RaycastInfo_get_m_contactPointWS_0=Module["_emscripten_bind_RaycastInfo_get_m_contactPointWS_0"]=asm["_emscripten_bind_RaycastInfo_get_m_contactPointWS_0"];var _emscripten_bind_btSoftBody_setCollisionFlags_1=Module["_emscripten_bind_btSoftBody_setCollisionFlags_1"]=asm["_emscripten_bind_btSoftBody_setCollisionFlags_1"];var _emscripten_bind_btSphereShape_calculateLocalInertia_2=Module["_emscripten_bind_btSphereShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btSphereShape_calculateLocalInertia_2"];var _emscripten_bind_Config_set_maxvolume_1=Module["_emscripten_bind_Config_set_maxvolume_1"]=asm["_emscripten_bind_Config_set_maxvolume_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_getSolverInfo_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getSolverInfo_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getSolverInfo_0"];var _emscripten_bind_btCollisionDispatcher_getManifoldByIndexInternal_1=Module["_emscripten_bind_btCollisionDispatcher_getManifoldByIndexInternal_1"]=asm["_emscripten_bind_btCollisionDispatcher_getManifoldByIndexInternal_1"];var _emscripten_bind_btSoftBody_setTotalMass_2=Module["_emscripten_bind_btSoftBody_setTotalMass_2"]=asm["_emscripten_bind_btSoftBody_setTotalMass_2"];var _emscripten_bind_ClosestRayResultCallback_get_m_rayToWorld_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_rayToWorld_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_rayToWorld_0"];var _emscripten_bind_btGhostObject_setFriction_1=Module["_emscripten_bind_btGhostObject_setFriction_1"]=asm["_emscripten_bind_btGhostObject_setFriction_1"];var _emscripten_bind_btPairCachingGhostObject_getWorldTransform_0=Module["_emscripten_bind_btPairCachingGhostObject_getWorldTransform_0"]=asm["_emscripten_bind_btPairCachingGhostObject_getWorldTransform_0"];var _emscripten_bind_btRigidBody_setCcdSweptSphereRadius_1=Module["_emscripten_bind_btRigidBody_setCcdSweptSphereRadius_1"]=asm["_emscripten_bind_btRigidBody_setCcdSweptSphereRadius_1"];var _emscripten_bind_btCylinderShapeZ_setMargin_1=Module["_emscripten_bind_btCylinderShapeZ_setMargin_1"]=asm["_emscripten_bind_btCylinderShapeZ_setMargin_1"];var _emscripten_bind_btRigidBody_setFriction_1=Module["_emscripten_bind_btRigidBody_setFriction_1"]=asm["_emscripten_bind_btRigidBody_setFriction_1"];var _emscripten_bind_LocalConvexResult_set_m_hitPointLocal_1=Module["_emscripten_bind_LocalConvexResult_set_m_hitPointLocal_1"]=asm["_emscripten_bind_LocalConvexResult_set_m_hitPointLocal_1"];var _emscripten_bind_btGhostObject_setWorldTransform_1=Module["_emscripten_bind_btGhostObject_setWorldTransform_1"]=asm["_emscripten_bind_btGhostObject_setWorldTransform_1"];var _emscripten_bind_tMaterialArray_size_0=Module["_emscripten_bind_tMaterialArray_size_0"]=asm["_emscripten_bind_tMaterialArray_size_0"];var _emscripten_bind_btManifoldPoint_getAppliedImpulse_0=Module["_emscripten_bind_btManifoldPoint_getAppliedImpulse_0"]=asm["_emscripten_bind_btManifoldPoint_getAppliedImpulse_0"];var _emscripten_bind_btDiscreteDynamicsWorld_removeRigidBody_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_removeRigidBody_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_removeRigidBody_1"];var _emscripten_bind_btConvexHullShape___destroy___0=Module["_emscripten_bind_btConvexHullShape___destroy___0"]=asm["_emscripten_bind_btConvexHullShape___destroy___0"];var _emscripten_bind_btDiscreteDynamicsWorld_getBroadphase_0=Module["_emscripten_bind_btDiscreteDynamicsWorld_getBroadphase_0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_getBroadphase_0"];var _emscripten_bind_btDiscreteDynamicsWorld_addAction_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_addAction_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addAction_1"];var _emscripten_bind_btVector4_setX_1=Module["_emscripten_bind_btVector4_setX_1"]=asm["_emscripten_bind_btVector4_setX_1"];var _emscripten_bind_btKinematicCharacterController_jump_0=Module["_emscripten_bind_btKinematicCharacterController_jump_0"]=asm["_emscripten_bind_btKinematicCharacterController_jump_0"];var _emscripten_bind_btCollisionObject_getUserPointer_0=Module["_emscripten_bind_btCollisionObject_getUserPointer_0"]=asm["_emscripten_bind_btCollisionObject_getUserPointer_0"];var _emscripten_bind_btWheelInfo_set_m_raycastInfo_1=Module["_emscripten_bind_btWheelInfo_set_m_raycastInfo_1"]=asm["_emscripten_bind_btWheelInfo_set_m_raycastInfo_1"];var _emscripten_bind_btCollisionWorld_contactTest_2=Module["_emscripten_bind_btCollisionWorld_contactTest_2"]=asm["_emscripten_bind_btCollisionWorld_contactTest_2"];var _emscripten_bind_btConeTwistConstraint_setMaxMotorImpulseNormalized_1=Module["_emscripten_bind_btConeTwistConstraint_setMaxMotorImpulseNormalized_1"]=asm["_emscripten_bind_btConeTwistConstraint_setMaxMotorImpulseNormalized_1"];var _emscripten_bind_btConvexTriangleMeshShape_setLocalScaling_1=Module["_emscripten_bind_btConvexTriangleMeshShape_setLocalScaling_1"]=asm["_emscripten_bind_btConvexTriangleMeshShape_setLocalScaling_1"];var _emscripten_bind_btRigidBody_upcast_1=Module["_emscripten_bind_btRigidBody_upcast_1"]=asm["_emscripten_bind_btRigidBody_upcast_1"];var _emscripten_bind_btTransform_setOrigin_1=Module["_emscripten_bind_btTransform_setOrigin_1"]=asm["_emscripten_bind_btTransform_setOrigin_1"];var _emscripten_bind_btVector4_setZ_1=Module["_emscripten_bind_btVector4_setZ_1"]=asm["_emscripten_bind_btVector4_setZ_1"];var _emscripten_bind_btQuadWord_y_0=Module["_emscripten_bind_btQuadWord_y_0"]=asm["_emscripten_bind_btQuadWord_y_0"];var _emscripten_bind_btTransform_getBasis_0=Module["_emscripten_bind_btTransform_getBasis_0"]=asm["_emscripten_bind_btTransform_getBasis_0"];var _emscripten_bind_btPairCachingGhostObject_setFriction_1=Module["_emscripten_bind_btPairCachingGhostObject_setFriction_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setFriction_1"];var _emscripten_bind_Config_set_kSRHR_CL_1=Module["_emscripten_bind_Config_set_kSRHR_CL_1"]=asm["_emscripten_bind_Config_set_kSRHR_CL_1"];var _emscripten_bind_btCollisionDispatcher_getNumManifolds_0=Module["_emscripten_bind_btCollisionDispatcher_getNumManifolds_0"]=asm["_emscripten_bind_btCollisionDispatcher_getNumManifolds_0"];var _emscripten_bind_btVehicleRaycaster___destroy___0=Module["_emscripten_bind_btVehicleRaycaster___destroy___0"]=asm["_emscripten_bind_btVehicleRaycaster___destroy___0"];var _emscripten_bind_ClosestRayResultCallback___destroy___0=Module["_emscripten_bind_ClosestRayResultCallback___destroy___0"]=asm["_emscripten_bind_ClosestRayResultCallback___destroy___0"];var _emscripten_bind_ClosestConvexResultCallback_get_m_convexFromWorld_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_convexFromWorld_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_convexFromWorld_0"];var _emscripten_bind_btCylinderShapeX_setMargin_1=Module["_emscripten_bind_btCylinderShapeX_setMargin_1"]=asm["_emscripten_bind_btCylinderShapeX_setMargin_1"];var _emscripten_bind_btQuadWord_w_0=Module["_emscripten_bind_btQuadWord_w_0"]=asm["_emscripten_bind_btQuadWord_w_0"];var _emscripten_bind_Node___destroy___0=Module["_emscripten_bind_Node___destroy___0"]=asm["_emscripten_bind_Node___destroy___0"];var _emscripten_bind_btDynamicsWorld_contactTest_2=Module["_emscripten_bind_btDynamicsWorld_contactTest_2"]=asm["_emscripten_bind_btDynamicsWorld_contactTest_2"];var _emscripten_bind_btDiscreteDynamicsWorld_contactTest_2=Module["_emscripten_bind_btDiscreteDynamicsWorld_contactTest_2"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_contactTest_2"];var _emscripten_bind_btBvhTriangleMeshShape_calculateLocalInertia_2=Module["_emscripten_bind_btBvhTriangleMeshShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btBvhTriangleMeshShape_calculateLocalInertia_2"];var _emscripten_bind_btCompoundShape_getNumChildShapes_0=Module["_emscripten_bind_btCompoundShape_getNumChildShapes_0"]=asm["_emscripten_bind_btCompoundShape_getNumChildShapes_0"];var _emscripten_bind_btSoftBodyWorldInfo_set_m_broadphase_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_m_broadphase_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_m_broadphase_1"];var _emscripten_bind_btGhostObject_btGhostObject_0=Module["_emscripten_bind_btGhostObject_btGhostObject_0"]=asm["_emscripten_bind_btGhostObject_btGhostObject_0"];var _emscripten_bind_btConeShape_btConeShape_2=Module["_emscripten_bind_btConeShape_btConeShape_2"]=asm["_emscripten_bind_btConeShape_btConeShape_2"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingFactor_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingFactor_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingFactor_1"];var _emscripten_bind_btManifoldPoint_set_m_localPointA_1=Module["_emscripten_bind_btManifoldPoint_set_m_localPointA_1"]=asm["_emscripten_bind_btManifoldPoint_set_m_localPointA_1"];var _emscripten_bind_btCapsuleShapeX_setMargin_1=Module["_emscripten_bind_btCapsuleShapeX_setMargin_1"]=asm["_emscripten_bind_btCapsuleShapeX_setMargin_1"];var _emscripten_bind_btVector3_dot_1=Module["_emscripten_bind_btVector3_dot_1"]=asm["_emscripten_bind_btVector3_dot_1"];var _emscripten_bind_btGhostObject_getUserPointer_0=Module["_emscripten_bind_btGhostObject_getUserPointer_0"]=asm["_emscripten_bind_btGhostObject_getUserPointer_0"];var _emscripten_bind_btVector4_op_add_1=Module["_emscripten_bind_btVector4_op_add_1"]=asm["_emscripten_bind_btVector4_op_add_1"];var _emscripten_bind_btWheelInfo___destroy___0=Module["_emscripten_bind_btWheelInfo___destroy___0"]=asm["_emscripten_bind_btWheelInfo___destroy___0"];var _emscripten_bind_btSoftRigidDynamicsWorld_getSoftBodyArray_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getSoftBodyArray_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getSoftBodyArray_0"];var _emscripten_bind_btHingeConstraint_btHingeConstraint_4=Module["_emscripten_bind_btHingeConstraint_btHingeConstraint_4"]=asm["_emscripten_bind_btHingeConstraint_btHingeConstraint_4"];var _emscripten_bind_btTransform_setRotation_1=Module["_emscripten_bind_btTransform_setRotation_1"]=asm["_emscripten_bind_btTransform_setRotation_1"];var _emscripten_bind_Config_set_kSHR_1=Module["_emscripten_bind_Config_set_kSHR_1"]=asm["_emscripten_bind_Config_set_kSHR_1"];var _emscripten_bind_btPoint2PointConstraint_enableFeedback_1=Module["_emscripten_bind_btPoint2PointConstraint_enableFeedback_1"]=asm["_emscripten_bind_btPoint2PointConstraint_enableFeedback_1"];var _emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterGroup_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterGroup_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterGroup_1"];var _emscripten_bind_btAxisSweep3_btAxisSweep3_2=Module["_emscripten_bind_btAxisSweep3_btAxisSweep3_2"]=asm["_emscripten_bind_btAxisSweep3_btAxisSweep3_2"];var _emscripten_bind_btAxisSweep3_btAxisSweep3_3=Module["_emscripten_bind_btAxisSweep3_btAxisSweep3_3"]=asm["_emscripten_bind_btAxisSweep3_btAxisSweep3_3"];var _emscripten_bind_btDynamicsWorld___destroy___0=Module["_emscripten_bind_btDynamicsWorld___destroy___0"]=asm["_emscripten_bind_btDynamicsWorld___destroy___0"];var _emscripten_bind_btVector3_setY_1=Module["_emscripten_bind_btVector3_setY_1"]=asm["_emscripten_bind_btVector3_setY_1"];var _emscripten_bind_btAxisSweep3_btAxisSweep3_4=Module["_emscripten_bind_btAxisSweep3_btAxisSweep3_4"]=asm["_emscripten_bind_btAxisSweep3_btAxisSweep3_4"];var _emscripten_bind_btAxisSweep3_btAxisSweep3_5=Module["_emscripten_bind_btAxisSweep3_btAxisSweep3_5"]=asm["_emscripten_bind_btAxisSweep3_btAxisSweep3_5"];var _emscripten_bind_btQuadWord_setX_1=Module["_emscripten_bind_btQuadWord_setX_1"]=asm["_emscripten_bind_btQuadWord_setX_1"];var _emscripten_bind_tMaterialArray___destroy___0=Module["_emscripten_bind_tMaterialArray___destroy___0"]=asm["_emscripten_bind_tMaterialArray___destroy___0"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalLinearDampingThresholdSqr_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalLinearDampingThresholdSqr_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalLinearDampingThresholdSqr_1"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalLinearDampingThresholdSqr_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalLinearDampingThresholdSqr_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalLinearDampingThresholdSqr_0"];var _emscripten_bind_Config_set_piterations_1=Module["_emscripten_bind_Config_set_piterations_1"]=asm["_emscripten_bind_Config_set_piterations_1"];var _emscripten_bind_btOverlappingPairCache___destroy___0=Module["_emscripten_bind_btOverlappingPairCache___destroy___0"]=asm["_emscripten_bind_btOverlappingPairCache___destroy___0"];var _emscripten_bind_btRigidBody_setUserIndex_1=Module["_emscripten_bind_btRigidBody_setUserIndex_1"]=asm["_emscripten_bind_btRigidBody_setUserIndex_1"];var _emscripten_bind_Material_get_m_kAST_0=Module["_emscripten_bind_Material_get_m_kAST_0"]=asm["_emscripten_bind_Material_get_m_kAST_0"];var _emscripten_bind_btConstraintSetting___destroy___0=Module["_emscripten_bind_btConstraintSetting___destroy___0"]=asm["_emscripten_bind_btConstraintSetting___destroy___0"];var _emscripten_bind_RayResultCallback___destroy___0=Module["_emscripten_bind_RayResultCallback___destroy___0"]=asm["_emscripten_bind_RayResultCallback___destroy___0"];var _emscripten_bind_RaycastInfo_get_m_contactNormalWS_0=Module["_emscripten_bind_RaycastInfo_get_m_contactNormalWS_0"]=asm["_emscripten_bind_RaycastInfo_get_m_contactNormalWS_0"];var _emscripten_bind_btSoftBodyWorldInfo_get_water_density_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_water_density_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_water_density_0"];var _emscripten_bind_btPersistentManifold_getBody0_0=Module["_emscripten_bind_btPersistentManifold_getBody0_0"]=asm["_emscripten_bind_btPersistentManifold_getBody0_0"];var _emscripten_bind_btConeShapeX_btConeShapeX_2=Module["_emscripten_bind_btConeShapeX_btConeShapeX_2"]=asm["_emscripten_bind_btConeShapeX_btConeShapeX_2"];var _emscripten_bind_btSoftBody_setCcdSweptSphereRadius_1=Module["_emscripten_bind_btSoftBody_setCcdSweptSphereRadius_1"]=asm["_emscripten_bind_btSoftBody_setCcdSweptSphereRadius_1"];var _emscripten_bind_btConeTwistConstraint_enableFeedback_1=Module["_emscripten_bind_btConeTwistConstraint_enableFeedback_1"]=asm["_emscripten_bind_btConeTwistConstraint_enableFeedback_1"];var _emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_0=Module["_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_0"]=asm["_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_0"];var _emscripten_bind_btCapsuleShapeZ_setLocalScaling_1=Module["_emscripten_bind_btCapsuleShapeZ_setLocalScaling_1"]=asm["_emscripten_bind_btCapsuleShapeZ_setLocalScaling_1"];var _emscripten_bind_Config_get_piterations_0=Module["_emscripten_bind_Config_get_piterations_0"]=asm["_emscripten_bind_Config_get_piterations_0"];var _emscripten_bind_btSoftBody_translate_1=Module["_emscripten_bind_btSoftBody_translate_1"]=asm["_emscripten_bind_btSoftBody_translate_1"];var _emscripten_bind_btSliderConstraint_setUpperLinLimit_1=Module["_emscripten_bind_btSliderConstraint_setUpperLinLimit_1"]=asm["_emscripten_bind_btSliderConstraint_setUpperLinLimit_1"];var _emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_2=Module["_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_2"]=asm["_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_2"];var _emscripten_bind_btVector3_op_mul_1=Module["_emscripten_bind_btVector3_op_mul_1"]=asm["_emscripten_bind_btVector3_op_mul_1"];var _emscripten_bind_btConcaveShape___destroy___0=Module["_emscripten_bind_btConcaveShape___destroy___0"]=asm["_emscripten_bind_btConcaveShape___destroy___0"];var _emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_4=Module["_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_4"]=asm["_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_4"];var _emscripten_bind_btQuaternion_x_0=Module["_emscripten_bind_btQuaternion_x_0"]=asm["_emscripten_bind_btQuaternion_x_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_btSoftRigidDynamicsWorld_5=Module["_emscripten_bind_btSoftRigidDynamicsWorld_btSoftRigidDynamicsWorld_5"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_btSoftRigidDynamicsWorld_5"];var _emscripten_bind_Config_set_timescale_1=Module["_emscripten_bind_Config_set_timescale_1"]=asm["_emscripten_bind_Config_set_timescale_1"];var _emscripten_bind_LocalConvexResult_set_m_hitNormalLocal_1=Module["_emscripten_bind_LocalConvexResult_set_m_hitNormalLocal_1"]=asm["_emscripten_bind_LocalConvexResult_set_m_hitNormalLocal_1"];var _emscripten_bind_btConcaveShape_setLocalScaling_1=Module["_emscripten_bind_btConcaveShape_setLocalScaling_1"]=asm["_emscripten_bind_btConcaveShape_setLocalScaling_1"];var _emscripten_bind_btDiscreteDynamicsWorld_getDispatchInfo_0=Module["_emscripten_bind_btDiscreteDynamicsWorld_getDispatchInfo_0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_getDispatchInfo_0"];var _emscripten_bind_btConeShapeX_setLocalScaling_1=Module["_emscripten_bind_btConeShapeX_setLocalScaling_1"]=asm["_emscripten_bind_btConeShapeX_setLocalScaling_1"];var _emscripten_bind_btSoftBody_appendLink_4=Module["_emscripten_bind_btSoftBody_appendLink_4"]=asm["_emscripten_bind_btSoftBody_appendLink_4"];var _emscripten_bind_btQuaternion_z_0=Module["_emscripten_bind_btQuaternion_z_0"]=asm["_emscripten_bind_btQuaternion_z_0"];var _emscripten_bind_btConvexHullShape_btConvexHullShape_0=Module["_emscripten_bind_btConvexHullShape_btConvexHullShape_0"]=asm["_emscripten_bind_btConvexHullShape_btConvexHullShape_0"];var _emscripten_bind_btWheelInfo_set_m_maxSuspensionForce_1=Module["_emscripten_bind_btWheelInfo_set_m_maxSuspensionForce_1"]=asm["_emscripten_bind_btWheelInfo_set_m_maxSuspensionForce_1"];var _emscripten_bind_btConstraintSetting_get_m_damping_0=Module["_emscripten_bind_btConstraintSetting_get_m_damping_0"]=asm["_emscripten_bind_btConstraintSetting_get_m_damping_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_removeCollisionObject_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_removeCollisionObject_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_removeCollisionObject_1"];var _emscripten_bind_Config_get_kLF_0=Module["_emscripten_bind_Config_get_kLF_0"]=asm["_emscripten_bind_Config_get_kLF_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_3=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_3"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_3"];var _emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_2=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_2"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_2"];var _emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_1"];var _emscripten_bind_btGhostObject_setContactProcessingThreshold_1=Module["_emscripten_bind_btGhostObject_setContactProcessingThreshold_1"]=asm["_emscripten_bind_btGhostObject_setContactProcessingThreshold_1"];var _emscripten_bind_btSoftBodyHelpers_CreateFromConvexHull_4=Module["_emscripten_bind_btSoftBodyHelpers_CreateFromConvexHull_4"]=asm["_emscripten_bind_btSoftBodyHelpers_CreateFromConvexHull_4"];var _emscripten_bind_btCollisionWorld_getBroadphase_0=Module["_emscripten_bind_btCollisionWorld_getBroadphase_0"]=asm["_emscripten_bind_btCollisionWorld_getBroadphase_0"];var _emscripten_bind_btRaycastVehicle_updateWheelTransform_2=Module["_emscripten_bind_btRaycastVehicle_updateWheelTransform_2"]=asm["_emscripten_bind_btRaycastVehicle_updateWheelTransform_2"];var _emscripten_bind_btDispatcherInfo_set_m_stepCount_1=Module["_emscripten_bind_btDispatcherInfo_set_m_stepCount_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_stepCount_1"];var _emscripten_bind_btContactSolverInfo_set_m_splitImpulse_1=Module["_emscripten_bind_btContactSolverInfo_set_m_splitImpulse_1"]=asm["_emscripten_bind_btContactSolverInfo_set_m_splitImpulse_1"];var _emscripten_bind_btDefaultMotionState_btDefaultMotionState_2=Module["_emscripten_bind_btDefaultMotionState_btDefaultMotionState_2"]=asm["_emscripten_bind_btDefaultMotionState_btDefaultMotionState_2"];var _emscripten_bind_Material_set_m_flags_1=Module["_emscripten_bind_Material_set_m_flags_1"]=asm["_emscripten_bind_Material_set_m_flags_1"];var _emscripten_bind_btDefaultMotionState_btDefaultMotionState_0=Module["_emscripten_bind_btDefaultMotionState_btDefaultMotionState_0"]=asm["_emscripten_bind_btDefaultMotionState_btDefaultMotionState_0"];var _emscripten_bind_btDefaultMotionState_btDefaultMotionState_1=Module["_emscripten_bind_btDefaultMotionState_btDefaultMotionState_1"]=asm["_emscripten_bind_btDefaultMotionState_btDefaultMotionState_1"];var _emscripten_bind_Config_get_viterations_0=Module["_emscripten_bind_Config_get_viterations_0"]=asm["_emscripten_bind_Config_get_viterations_0"];var _emscripten_bind_btKinematicCharacterController_canJump_0=Module["_emscripten_bind_btKinematicCharacterController_canJump_0"]=asm["_emscripten_bind_btKinematicCharacterController_canJump_0"];var _emscripten_bind_btSoftBodyArray_at_1=Module["_emscripten_bind_btSoftBodyArray_at_1"]=asm["_emscripten_bind_btSoftBodyArray_at_1"];var _emscripten_bind_btPairCachingGhostObject_setUserIndex_1=Module["_emscripten_bind_btPairCachingGhostObject_setUserIndex_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setUserIndex_1"];var _emscripten_bind_btRigidBody_isActive_0=Module["_emscripten_bind_btRigidBody_isActive_0"]=asm["_emscripten_bind_btRigidBody_isActive_0"];var _emscripten_bind_btRaycastVehicle_btRaycastVehicle_3=Module["_emscripten_bind_btRaycastVehicle_btRaycastVehicle_3"]=asm["_emscripten_bind_btRaycastVehicle_btRaycastVehicle_3"];var _emscripten_bind_btMotionState_setWorldTransform_1=Module["_emscripten_bind_btMotionState_setWorldTransform_1"]=asm["_emscripten_bind_btMotionState_setWorldTransform_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_getDispatcher_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getDispatcher_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getDispatcher_0"];var _emscripten_bind_btCylinderShape_setLocalScaling_1=Module["_emscripten_bind_btCylinderShape_setLocalScaling_1"]=asm["_emscripten_bind_btCylinderShape_setLocalScaling_1"];var _emscripten_bind_btCollisionWorld_rayTest_3=Module["_emscripten_bind_btCollisionWorld_rayTest_3"]=asm["_emscripten_bind_btCollisionWorld_rayTest_3"];var _emscripten_bind_btCompoundShape_calculateLocalInertia_2=Module["_emscripten_bind_btCompoundShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btCompoundShape_calculateLocalInertia_2"];var _emscripten_bind_btCollisionWorld_getDispatchInfo_0=Module["_emscripten_bind_btCollisionWorld_getDispatchInfo_0"]=asm["_emscripten_bind_btCollisionWorld_getDispatchInfo_0"];var _emscripten_bind_btRigidBody_setCollisionShape_1=Module["_emscripten_bind_btRigidBody_setCollisionShape_1"]=asm["_emscripten_bind_btRigidBody_setCollisionShape_1"];var _emscripten_bind_btSoftBody_appendTetra_5=Module["_emscripten_bind_btSoftBody_appendTetra_5"]=asm["_emscripten_bind_btSoftBody_appendTetra_5"];var _emscripten_bind_btConeShapeX___destroy___0=Module["_emscripten_bind_btConeShapeX___destroy___0"]=asm["_emscripten_bind_btConeShapeX___destroy___0"];var _emscripten_bind_btCollisionObject_getCollisionFlags_0=Module["_emscripten_bind_btCollisionObject_getCollisionFlags_0"]=asm["_emscripten_bind_btCollisionObject_getCollisionFlags_0"];var _emscripten_bind_btDispatcherInfo_set_m_enableSatConvex_1=Module["_emscripten_bind_btDispatcherInfo_set_m_enableSatConvex_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_enableSatConvex_1"];var _emscripten_bind_btConeTwistConstraint_enableMotor_1=Module["_emscripten_bind_btConeTwistConstraint_enableMotor_1"]=asm["_emscripten_bind_btConeTwistConstraint_enableMotor_1"];var _emscripten_bind_btWheelInfo_set_m_chassisConnectionPointCS_1=Module["_emscripten_bind_btWheelInfo_set_m_chassisConnectionPointCS_1"]=asm["_emscripten_bind_btWheelInfo_set_m_chassisConnectionPointCS_1"];var _emscripten_bind_btRaycastVehicle_setCoordinateSystem_3=Module["_emscripten_bind_btRaycastVehicle_setCoordinateSystem_3"]=asm["_emscripten_bind_btRaycastVehicle_setCoordinateSystem_3"];var _emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_0=Module["_emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_0"]=asm["_emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_0"];var _emscripten_bind_btPairCachingGhostObject_setRestitution_1=Module["_emscripten_bind_btPairCachingGhostObject_setRestitution_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setRestitution_1"];var _emscripten_bind_Config_set_kAHR_1=Module["_emscripten_bind_Config_set_kAHR_1"]=asm["_emscripten_bind_Config_set_kAHR_1"];var _emscripten_bind_btSoftBody_set_m_cfg_1=Module["_emscripten_bind_btSoftBody_set_m_cfg_1"]=asm["_emscripten_bind_btSoftBody_set_m_cfg_1"];var _emscripten_bind_ConvexResultCallback___destroy___0=Module["_emscripten_bind_ConvexResultCallback___destroy___0"]=asm["_emscripten_bind_ConvexResultCallback___destroy___0"];var _emscripten_bind_btSoftRigidDynamicsWorld_rayTest_3=Module["_emscripten_bind_btSoftRigidDynamicsWorld_rayTest_3"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_rayTest_3"];var _emscripten_bind_Config_get_kSRHR_CL_0=Module["_emscripten_bind_Config_get_kSRHR_CL_0"]=asm["_emscripten_bind_Config_get_kSRHR_CL_0"];var _emscripten_bind_btSliderConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btSliderConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btSliderConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDampingFactor_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDampingFactor_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDampingFactor_1"];var _emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_3=Module["_emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_3"]=asm["_emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_3"];var _emscripten_bind_btCollisionObject_setContactProcessingThreshold_1=Module["_emscripten_bind_btCollisionObject_setContactProcessingThreshold_1"]=asm["_emscripten_bind_btCollisionObject_setContactProcessingThreshold_1"];var _emscripten_bind_btCompoundShape___destroy___0=Module["_emscripten_bind_btCompoundShape___destroy___0"]=asm["_emscripten_bind_btCompoundShape___destroy___0"];var _emscripten_bind_btHingeConstraint_setMotorTarget_2=Module["_emscripten_bind_btHingeConstraint_setMotorTarget_2"]=asm["_emscripten_bind_btHingeConstraint_setMotorTarget_2"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingFactor_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingFactor_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingFactor_0"];var _emscripten_bind_LocalConvexResult___destroy___0=Module["_emscripten_bind_LocalConvexResult___destroy___0"]=asm["_emscripten_bind_LocalConvexResult___destroy___0"];var _emscripten_bind_btSequentialImpulseConstraintSolver___destroy___0=Module["_emscripten_bind_btSequentialImpulseConstraintSolver___destroy___0"]=asm["_emscripten_bind_btSequentialImpulseConstraintSolver___destroy___0"];var _emscripten_bind_btSoftBodyHelpers_CreateRope_5=Module["_emscripten_bind_btSoftBodyHelpers_CreateRope_5"]=asm["_emscripten_bind_btSoftBodyHelpers_CreateRope_5"];var _emscripten_bind_btRigidBody_getCollisionFlags_0=Module["_emscripten_bind_btRigidBody_getCollisionFlags_0"]=asm["_emscripten_bind_btRigidBody_getCollisionFlags_0"];var _emscripten_bind_btCollisionShape_setLocalScaling_1=Module["_emscripten_bind_btCollisionShape_setLocalScaling_1"]=asm["_emscripten_bind_btCollisionShape_setLocalScaling_1"];var _emscripten_bind_ClosestConvexResultCallback_get_m_closestHitFraction_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_closestHitFraction_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_closestHitFraction_0"];var _emscripten_bind_LocalConvexResult_get_m_hitCollisionObject_0=Module["_emscripten_bind_LocalConvexResult_get_m_hitCollisionObject_0"]=asm["_emscripten_bind_LocalConvexResult_get_m_hitCollisionObject_0"];var _emscripten_bind_btMatrix3x3_setEulerZYX_3=Module["_emscripten_bind_btMatrix3x3_setEulerZYX_3"]=asm["_emscripten_bind_btMatrix3x3_setEulerZYX_3"];var _emscripten_bind_btSoftBody_getTotalMass_0=Module["_emscripten_bind_btSoftBody_getTotalMass_0"]=asm["_emscripten_bind_btSoftBody_getTotalMass_0"];var _emscripten_bind_btDispatcherInfo_get_m_convexConservativeDistanceThreshold_0=Module["_emscripten_bind_btDispatcherInfo_get_m_convexConservativeDistanceThreshold_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_convexConservativeDistanceThreshold_0"];var _emscripten_bind_btRigidBody_getUserPointer_0=Module["_emscripten_bind_btRigidBody_getUserPointer_0"]=asm["_emscripten_bind_btRigidBody_getUserPointer_0"];var _emscripten_bind_Config_get_kSHR_0=Module["_emscripten_bind_Config_get_kSHR_0"]=asm["_emscripten_bind_Config_get_kSHR_0"];var _emscripten_bind_btHeightfieldTerrainShape_calculateLocalInertia_2=Module["_emscripten_bind_btHeightfieldTerrainShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btHeightfieldTerrainShape_calculateLocalInertia_2"];var _emscripten_bind_btRigidBody_setMotionState_1=Module["_emscripten_bind_btRigidBody_setMotionState_1"]=asm["_emscripten_bind_btRigidBody_setMotionState_1"];var _emscripten_bind_RayResultCallback_get_m_collisionFilterMask_0=Module["_emscripten_bind_RayResultCallback_get_m_collisionFilterMask_0"]=asm["_emscripten_bind_RayResultCallback_get_m_collisionFilterMask_0"];var _emscripten_bind_btCollisionWorld_getDispatcher_0=Module["_emscripten_bind_btCollisionWorld_getDispatcher_0"]=asm["_emscripten_bind_btCollisionWorld_getDispatcher_0"];var _emscripten_bind_btVector4_dot_1=Module["_emscripten_bind_btVector4_dot_1"]=asm["_emscripten_bind_btVector4_dot_1"];var _emscripten_bind_btSoftBody_forceActivationState_1=Module["_emscripten_bind_btSoftBody_forceActivationState_1"]=asm["_emscripten_bind_btSoftBody_forceActivationState_1"];var _emscripten_bind_btCollisionObject_setRollingFriction_1=Module["_emscripten_bind_btCollisionObject_setRollingFriction_1"]=asm["_emscripten_bind_btCollisionObject_setRollingFriction_1"];var _emscripten_bind_Config_set_kSK_SPLT_CL_1=Module["_emscripten_bind_Config_set_kSK_SPLT_CL_1"]=asm["_emscripten_bind_Config_set_kSK_SPLT_CL_1"];var _emscripten_bind_RayResultCallback_set_m_collisionFilterGroup_1=Module["_emscripten_bind_RayResultCallback_set_m_collisionFilterGroup_1"]=asm["_emscripten_bind_RayResultCallback_set_m_collisionFilterGroup_1"];var _emscripten_bind_btPairCachingGhostObject_getCollisionShape_0=Module["_emscripten_bind_btPairCachingGhostObject_getCollisionShape_0"]=asm["_emscripten_bind_btPairCachingGhostObject_getCollisionShape_0"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _emscripten_bind_btCylinderShapeX_getMargin_0=Module["_emscripten_bind_btCylinderShapeX_getMargin_0"]=asm["_emscripten_bind_btCylinderShapeX_getMargin_0"];var _emscripten_bind_btRigidBody_setDamping_2=Module["_emscripten_bind_btRigidBody_setDamping_2"]=asm["_emscripten_bind_btRigidBody_setDamping_2"];var _emscripten_bind_btDynamicsWorld_getDispatcher_0=Module["_emscripten_bind_btDynamicsWorld_getDispatcher_0"]=asm["_emscripten_bind_btDynamicsWorld_getDispatcher_0"];var _emscripten_bind_btGhostObject_setCollisionFlags_1=Module["_emscripten_bind_btGhostObject_setCollisionFlags_1"]=asm["_emscripten_bind_btGhostObject_setCollisionFlags_1"];var _emscripten_bind_btMatrix3x3_getRotation_1=Module["_emscripten_bind_btMatrix3x3_getRotation_1"]=asm["_emscripten_bind_btMatrix3x3_getRotation_1"];var _emscripten_bind_btWheelInfo_set_m_engineForce_1=Module["_emscripten_bind_btWheelInfo_set_m_engineForce_1"]=asm["_emscripten_bind_btWheelInfo_set_m_engineForce_1"];var _emscripten_bind_btConeTwistConstraint_setMaxMotorImpulse_1=Module["_emscripten_bind_btConeTwistConstraint_setMaxMotorImpulse_1"]=asm["_emscripten_bind_btConeTwistConstraint_setMaxMotorImpulse_1"];var _emscripten_bind_btPersistentManifold_getNumContacts_0=Module["_emscripten_bind_btPersistentManifold_getNumContacts_0"]=asm["_emscripten_bind_btPersistentManifold_getNumContacts_0"];var _emscripten_bind_btCylinderShapeX_setLocalScaling_1=Module["_emscripten_bind_btCylinderShapeX_setLocalScaling_1"]=asm["_emscripten_bind_btCylinderShapeX_setLocalScaling_1"];var _emscripten_bind_btDbvtBroadphase_btDbvtBroadphase_0=Module["_emscripten_bind_btDbvtBroadphase_btDbvtBroadphase_0"]=asm["_emscripten_bind_btDbvtBroadphase_btDbvtBroadphase_0"];var _emscripten_bind_btSoftBodyHelpers_btSoftBodyHelpers_0=Module["_emscripten_bind_btSoftBodyHelpers_btSoftBodyHelpers_0"]=asm["_emscripten_bind_btSoftBodyHelpers_btSoftBodyHelpers_0"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDamping_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDamping_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDamping_0"];var _emscripten_bind_btCompoundShape_setLocalScaling_1=Module["_emscripten_bind_btCompoundShape_setLocalScaling_1"]=asm["_emscripten_bind_btCompoundShape_setLocalScaling_1"];var _emscripten_bind_btOverlappingPairCallback___destroy___0=Module["_emscripten_bind_btOverlappingPairCallback___destroy___0"]=asm["_emscripten_bind_btOverlappingPairCallback___destroy___0"];var _emscripten_bind_btManifoldPoint_get_m_positionWorldOnB_0=Module["_emscripten_bind_btManifoldPoint_get_m_positionWorldOnB_0"]=asm["_emscripten_bind_btManifoldPoint_get_m_positionWorldOnB_0"];var _emscripten_bind_tNodeArray___destroy___0=Module["_emscripten_bind_tNodeArray___destroy___0"]=asm["_emscripten_bind_tNodeArray___destroy___0"];var _emscripten_bind_btPairCachingGhostObject_setCcdSweptSphereRadius_1=Module["_emscripten_bind_btPairCachingGhostObject_setCcdSweptSphereRadius_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setCcdSweptSphereRadius_1"];var _emscripten_bind_btHingeConstraint_enableAngularMotor_3=Module["_emscripten_bind_btHingeConstraint_enableAngularMotor_3"]=asm["_emscripten_bind_btHingeConstraint_enableAngularMotor_3"];var _emscripten_bind_btRigidBody_setContactProcessingThreshold_1=Module["_emscripten_bind_btRigidBody_setContactProcessingThreshold_1"]=asm["_emscripten_bind_btRigidBody_setContactProcessingThreshold_1"];var _emscripten_bind_btRigidBody_getLinearVelocity_0=Module["_emscripten_bind_btRigidBody_getLinearVelocity_0"]=asm["_emscripten_bind_btRigidBody_getLinearVelocity_0"];var _emscripten_bind_btRigidBody_applyImpulse_2=Module["_emscripten_bind_btRigidBody_applyImpulse_2"]=asm["_emscripten_bind_btRigidBody_applyImpulse_2"];var _emscripten_bind_btConcaveShape_calculateLocalInertia_2=Module["_emscripten_bind_btConcaveShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btConcaveShape_calculateLocalInertia_2"];var _emscripten_bind_RaycastInfo_get_m_groundObject_0=Module["_emscripten_bind_RaycastInfo_get_m_groundObject_0"]=asm["_emscripten_bind_RaycastInfo_get_m_groundObject_0"];var _emscripten_bind_btRigidBody_setWorldTransform_1=Module["_emscripten_bind_btRigidBody_setWorldTransform_1"]=asm["_emscripten_bind_btRigidBody_setWorldTransform_1"];var _emscripten_bind_btRigidBody_setAngularVelocity_1=Module["_emscripten_bind_btRigidBody_setAngularVelocity_1"]=asm["_emscripten_bind_btRigidBody_setAngularVelocity_1"];var _emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_3=Module["_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_3"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_3"];var _emscripten_bind_Config_get_kDP_0=Module["_emscripten_bind_Config_get_kDP_0"]=asm["_emscripten_bind_Config_get_kDP_0"];var _emscripten_bind_btConvexShape_setLocalScaling_1=Module["_emscripten_bind_btConvexShape_setLocalScaling_1"]=asm["_emscripten_bind_btConvexShape_setLocalScaling_1"];var _emscripten_bind_Config_get_collisions_0=Module["_emscripten_bind_Config_get_collisions_0"]=asm["_emscripten_bind_Config_get_collisions_0"];var _emscripten_bind_Node_get_m_n_0=Module["_emscripten_bind_Node_get_m_n_0"]=asm["_emscripten_bind_Node_get_m_n_0"];var _emscripten_bind_btTriangleMeshShape_calculateLocalInertia_2=Module["_emscripten_bind_btTriangleMeshShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btTriangleMeshShape_calculateLocalInertia_2"];var _free=Module["_free"]=asm["_free"];var _emscripten_bind_btPairCachingGhostObject_setContactProcessingThreshold_1=Module["_emscripten_bind_btPairCachingGhostObject_setContactProcessingThreshold_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setContactProcessingThreshold_1"];var _emscripten_bind_btGeneric6DofConstraint_setLinearUpperLimit_1=Module["_emscripten_bind_btGeneric6DofConstraint_setLinearUpperLimit_1"]=asm["_emscripten_bind_btGeneric6DofConstraint_setLinearUpperLimit_1"];var _emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterMask_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterMask_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterMask_0"];var _emscripten_bind_RayResultCallback_hasHit_0=Module["_emscripten_bind_RayResultCallback_hasHit_0"]=asm["_emscripten_bind_RayResultCallback_hasHit_0"];var _emscripten_bind_btRigidBody_applyLocalTorque_1=Module["_emscripten_bind_btRigidBody_applyLocalTorque_1"]=asm["_emscripten_bind_btRigidBody_applyLocalTorque_1"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _emscripten_bind_Config___destroy___0=Module["_emscripten_bind_Config___destroy___0"]=asm["_emscripten_bind_Config___destroy___0"];var _emscripten_bind_btVehicleTuning_set_m_maxSuspensionForce_1=Module["_emscripten_bind_btVehicleTuning_set_m_maxSuspensionForce_1"]=asm["_emscripten_bind_btVehicleTuning_set_m_maxSuspensionForce_1"];var _emscripten_bind_btRaycastVehicle_getWheelTransformWS_1=Module["_emscripten_bind_btRaycastVehicle_getWheelTransformWS_1"]=asm["_emscripten_bind_btRaycastVehicle_getWheelTransformWS_1"];var _emscripten_bind_btQuaternion_normalize_0=Module["_emscripten_bind_btQuaternion_normalize_0"]=asm["_emscripten_bind_btQuaternion_normalize_0"];var _emscripten_bind_btQuaternion___destroy___0=Module["_emscripten_bind_btQuaternion___destroy___0"]=asm["_emscripten_bind_btQuaternion___destroy___0"];var _emscripten_bind_btWheelInfo_get_m_frictionSlip_0=Module["_emscripten_bind_btWheelInfo_get_m_frictionSlip_0"]=asm["_emscripten_bind_btWheelInfo_get_m_frictionSlip_0"];var _emscripten_bind_btConeShapeZ_setLocalScaling_1=Module["_emscripten_bind_btConeShapeZ_setLocalScaling_1"]=asm["_emscripten_bind_btConeShapeZ_setLocalScaling_1"];var _emscripten_bind_btSoftBodyWorldInfo_get_m_dispatcher_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_m_dispatcher_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_m_dispatcher_0"];var _emscripten_bind_btGeneric6DofSpringConstraint___destroy___0=Module["_emscripten_bind_btGeneric6DofSpringConstraint___destroy___0"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint___destroy___0"];var _emscripten_bind_btRaycastVehicle_getNumWheels_0=Module["_emscripten_bind_btRaycastVehicle_getNumWheels_0"]=asm["_emscripten_bind_btRaycastVehicle_getNumWheels_0"];var _emscripten_bind_btVehicleTuning_set_m_maxSuspensionTravelCm_1=Module["_emscripten_bind_btVehicleTuning_set_m_maxSuspensionTravelCm_1"]=asm["_emscripten_bind_btVehicleTuning_set_m_maxSuspensionTravelCm_1"];var _emscripten_bind_Material_set_m_kAST_1=Module["_emscripten_bind_Material_set_m_kAST_1"]=asm["_emscripten_bind_Material_set_m_kAST_1"];var _emscripten_bind_btGhostObject_setRollingFriction_1=Module["_emscripten_bind_btGhostObject_setRollingFriction_1"]=asm["_emscripten_bind_btGhostObject_setRollingFriction_1"];var _emscripten_bind_btCylinderShapeZ_btCylinderShapeZ_1=Module["_emscripten_bind_btCylinderShapeZ_btCylinderShapeZ_1"]=asm["_emscripten_bind_btCylinderShapeZ_btCylinderShapeZ_1"];var _emscripten_bind_btSoftBodyArray___destroy___0=Module["_emscripten_bind_btSoftBodyArray___destroy___0"]=asm["_emscripten_bind_btSoftBodyArray___destroy___0"];var _emscripten_bind_btCompoundShape_btCompoundShape_0=Module["_emscripten_bind_btCompoundShape_btCompoundShape_0"]=asm["_emscripten_bind_btCompoundShape_btCompoundShape_0"];var _emscripten_bind_btCompoundShape_btCompoundShape_1=Module["_emscripten_bind_btCompoundShape_btCompoundShape_1"]=asm["_emscripten_bind_btCompoundShape_btCompoundShape_1"];var _emscripten_bind_btOverlappingPairCache_setInternalGhostPairCallback_1=Module["_emscripten_bind_btOverlappingPairCache_setInternalGhostPairCallback_1"]=asm["_emscripten_bind_btOverlappingPairCache_setInternalGhostPairCallback_1"];var _emscripten_bind_btStaticPlaneShape_btStaticPlaneShape_2=Module["_emscripten_bind_btStaticPlaneShape_btStaticPlaneShape_2"]=asm["_emscripten_bind_btStaticPlaneShape_btStaticPlaneShape_2"];var __GLOBAL__sub_I_btQuickprof_cpp=Module["__GLOBAL__sub_I_btQuickprof_cpp"]=asm["__GLOBAL__sub_I_btQuickprof_cpp"];var _emscripten_bind_btDispatcherInfo_set_m_convexConservativeDistanceThreshold_1=Module["_emscripten_bind_btDispatcherInfo_set_m_convexConservativeDistanceThreshold_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_convexConservativeDistanceThreshold_1"];var _emscripten_bind_btSoftBody_checkLink_2=Module["_emscripten_bind_btSoftBody_checkLink_2"]=asm["_emscripten_bind_btSoftBody_checkLink_2"];var _emscripten_bind_btSoftBody_getCollisionShape_0=Module["_emscripten_bind_btSoftBody_getCollisionShape_0"]=asm["_emscripten_bind_btSoftBody_getCollisionShape_0"];var _emscripten_bind_Config_get_kDG_0=Module["_emscripten_bind_Config_get_kDG_0"]=asm["_emscripten_bind_Config_get_kDG_0"];var _emscripten_bind_btPairCachingGhostObject_setAnisotropicFriction_2=Module["_emscripten_bind_btPairCachingGhostObject_setAnisotropicFriction_2"]=asm["_emscripten_bind_btPairCachingGhostObject_setAnisotropicFriction_2"];var _emscripten_bind_Node_get_m_x_0=Module["_emscripten_bind_Node_get_m_x_0"]=asm["_emscripten_bind_Node_get_m_x_0"];var _emscripten_bind_btCollisionObject_getWorldTransform_0=Module["_emscripten_bind_btCollisionObject_getWorldTransform_0"]=asm["_emscripten_bind_btCollisionObject_getWorldTransform_0"];var _emscripten_bind_ClosestRayResultCallback_hasHit_0=Module["_emscripten_bind_ClosestRayResultCallback_hasHit_0"]=asm["_emscripten_bind_ClosestRayResultCallback_hasHit_0"];var _emscripten_bind_btCompoundShape_addChildShape_2=Module["_emscripten_bind_btCompoundShape_addChildShape_2"]=asm["_emscripten_bind_btCompoundShape_addChildShape_2"];var _emscripten_bind_btDispatcher___destroy___0=Module["_emscripten_bind_btDispatcher___destroy___0"]=asm["_emscripten_bind_btDispatcher___destroy___0"];var _emscripten_bind_btVehicleTuning_get_m_suspensionCompression_0=Module["_emscripten_bind_btVehicleTuning_get_m_suspensionCompression_0"]=asm["_emscripten_bind_btVehicleTuning_get_m_suspensionCompression_0"];var _emscripten_bind_btDiscreteDynamicsWorld___destroy___0=Module["_emscripten_bind_btDiscreteDynamicsWorld___destroy___0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld___destroy___0"];var _emscripten_bind_btConvexShape___destroy___0=Module["_emscripten_bind_btConvexShape___destroy___0"]=asm["_emscripten_bind_btConvexShape___destroy___0"];var _memmove=Module["_memmove"]=asm["_memmove"];var _emscripten_bind_btCapsuleShapeX_setLocalScaling_1=Module["_emscripten_bind_btCapsuleShapeX_setLocalScaling_1"]=asm["_emscripten_bind_btCapsuleShapeX_setLocalScaling_1"];var _emscripten_bind_btSoftBody_getCollisionFlags_0=Module["_emscripten_bind_btSoftBody_getCollisionFlags_0"]=asm["_emscripten_bind_btSoftBody_getCollisionFlags_0"];var _emscripten_bind_btCollisionObject_setRestitution_1=Module["_emscripten_bind_btCollisionObject_setRestitution_1"]=asm["_emscripten_bind_btCollisionObject_setRestitution_1"];var _emscripten_bind_btRigidBody_applyCentralForce_1=Module["_emscripten_bind_btRigidBody_applyCentralForce_1"]=asm["_emscripten_bind_btRigidBody_applyCentralForce_1"];var _emscripten_bind_btSoftBodyWorldInfo_set_m_gravity_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_m_gravity_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_m_gravity_1"];var _emscripten_bind_LocalConvexResult_get_m_hitFraction_0=Module["_emscripten_bind_LocalConvexResult_get_m_hitFraction_0"]=asm["_emscripten_bind_LocalConvexResult_get_m_hitFraction_0"];var _emscripten_bind_btHingeConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btHingeConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btHingeConstraint_setBreakingImpulseThreshold_1"];var _emscripten_bind_btQuaternion_w_0=Module["_emscripten_bind_btQuaternion_w_0"]=asm["_emscripten_bind_btQuaternion_w_0"];var _emscripten_bind_ConvexResultCallback_get_m_collisionFilterGroup_0=Module["_emscripten_bind_ConvexResultCallback_get_m_collisionFilterGroup_0"]=asm["_emscripten_bind_ConvexResultCallback_get_m_collisionFilterGroup_0"];var _emscripten_bind_btTransform_getRotation_0=Module["_emscripten_bind_btTransform_getRotation_0"]=asm["_emscripten_bind_btTransform_getRotation_0"];var _emscripten_bind_Config_set_kSKHR_CL_1=Module["_emscripten_bind_Config_set_kSKHR_CL_1"]=asm["_emscripten_bind_Config_set_kSKHR_CL_1"];var _emscripten_bind_btHingeConstraint_btHingeConstraint_6=Module["_emscripten_bind_btHingeConstraint_btHingeConstraint_6"]=asm["_emscripten_bind_btHingeConstraint_btHingeConstraint_6"];var _emscripten_bind_btHingeConstraint_btHingeConstraint_7=Module["_emscripten_bind_btHingeConstraint_btHingeConstraint_7"]=asm["_emscripten_bind_btHingeConstraint_btHingeConstraint_7"];var _emscripten_bind_btCapsuleShapeZ_getMargin_0=Module["_emscripten_bind_btCapsuleShapeZ_getMargin_0"]=asm["_emscripten_bind_btCapsuleShapeZ_getMargin_0"];var _emscripten_bind_btHingeConstraint_btHingeConstraint_5=Module["_emscripten_bind_btHingeConstraint_btHingeConstraint_5"]=asm["_emscripten_bind_btHingeConstraint_btHingeConstraint_5"];var _emscripten_bind_btSoftBodyWorldInfo_get_m_maxDisplacement_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_m_maxDisplacement_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_m_maxDisplacement_0"];var _emscripten_bind_btHingeConstraint_btHingeConstraint_3=Module["_emscripten_bind_btHingeConstraint_btHingeConstraint_3"]=asm["_emscripten_bind_btHingeConstraint_btHingeConstraint_3"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingThresholdSqr_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingThresholdSqr_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingThresholdSqr_1"];var _emscripten_bind_btSoftBody_setWorldTransform_1=Module["_emscripten_bind_btSoftBody_setWorldTransform_1"]=asm["_emscripten_bind_btSoftBody_setWorldTransform_1"];var _emscripten_bind_btBoxShape_setMargin_1=Module["_emscripten_bind_btBoxShape_setMargin_1"]=asm["_emscripten_bind_btBoxShape_setMargin_1"];var _emscripten_bind_ClosestConvexResultCallback_get_m_hitNormalWorld_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_hitNormalWorld_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_hitNormalWorld_0"];var _emscripten_bind_Config_get_kSK_SPLT_CL_0=Module["_emscripten_bind_Config_get_kSK_SPLT_CL_0"]=asm["_emscripten_bind_Config_get_kSK_SPLT_CL_0"];var _emscripten_bind_btTypedConstraint___destroy___0=Module["_emscripten_bind_btTypedConstraint___destroy___0"]=asm["_emscripten_bind_btTypedConstraint___destroy___0"];var _emscripten_bind_btCylinderShapeX_btCylinderShapeX_1=Module["_emscripten_bind_btCylinderShapeX_btCylinderShapeX_1"]=asm["_emscripten_bind_btCylinderShapeX_btCylinderShapeX_1"];var _emscripten_bind_btGeneric6DofSpringConstraint_setAngularUpperLimit_1=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setAngularUpperLimit_1"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setAngularUpperLimit_1"];var _emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_3=Module["_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_3"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_3"];var _emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_1"];var _emscripten_bind_Config_set_collisions_1=Module["_emscripten_bind_Config_set_collisions_1"]=asm["_emscripten_bind_Config_set_collisions_1"];var _bitshift64Ashr=Module["_bitshift64Ashr"]=asm["_bitshift64Ashr"];var _emscripten_bind_btQuaternion_btQuaternion_4=Module["_emscripten_bind_btQuaternion_btQuaternion_4"]=asm["_emscripten_bind_btQuaternion_btQuaternion_4"];var _emscripten_bind_btSoftRigidDynamicsWorld_getBroadphase_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getBroadphase_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getBroadphase_0"];var _emscripten_bind_btDiscreteDynamicsWorld_removeAction_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_removeAction_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_removeAction_1"];var _emscripten_bind_btSphereShape_btSphereShape_1=Module["_emscripten_bind_btSphereShape_btSphereShape_1"]=asm["_emscripten_bind_btSphereShape_btSphereShape_1"];var _emscripten_bind_btWheelInfo_get_m_wheelsSuspensionForce_0=Module["_emscripten_bind_btWheelInfo_get_m_wheelsSuspensionForce_0"]=asm["_emscripten_bind_btWheelInfo_get_m_wheelsSuspensionForce_0"];var _emscripten_bind_btQuaternion_y_0=Module["_emscripten_bind_btQuaternion_y_0"]=asm["_emscripten_bind_btQuaternion_y_0"];var _emscripten_bind_btCollisionWorld_addCollisionObject_1=Module["_emscripten_bind_btCollisionWorld_addCollisionObject_1"]=asm["_emscripten_bind_btCollisionWorld_addCollisionObject_1"];var _emscripten_bind_btCollisionWorld_addCollisionObject_2=Module["_emscripten_bind_btCollisionWorld_addCollisionObject_2"]=asm["_emscripten_bind_btCollisionWorld_addCollisionObject_2"];var _emscripten_bind_btCollisionWorld_addCollisionObject_3=Module["_emscripten_bind_btCollisionWorld_addCollisionObject_3"]=asm["_emscripten_bind_btCollisionWorld_addCollisionObject_3"];var _emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterGroup_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterGroup_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterGroup_1"];var _emscripten_bind_btConeTwistConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btConeTwistConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btConeTwistConstraint_setBreakingImpulseThreshold_1"];var _emscripten_bind_btSoftBodyHelpers_CreateEllipsoid_4=Module["_emscripten_bind_btSoftBodyHelpers_CreateEllipsoid_4"]=asm["_emscripten_bind_btSoftBodyHelpers_CreateEllipsoid_4"];var _emscripten_bind_RaycastInfo_get_m_isInContact_0=Module["_emscripten_bind_RaycastInfo_get_m_isInContact_0"]=asm["_emscripten_bind_RaycastInfo_get_m_isInContact_0"];var _emscripten_bind_Config_set_kKHR_1=Module["_emscripten_bind_Config_set_kKHR_1"]=asm["_emscripten_bind_Config_set_kKHR_1"];var _emscripten_bind_btHeightfieldTerrainShape_setMargin_1=Module["_emscripten_bind_btHeightfieldTerrainShape_setMargin_1"]=asm["_emscripten_bind_btHeightfieldTerrainShape_setMargin_1"];var _emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterGroup_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterGroup_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterGroup_0"];var _emscripten_bind_btCapsuleShape_setMargin_1=Module["_emscripten_bind_btCapsuleShape_setMargin_1"]=asm["_emscripten_bind_btCapsuleShape_setMargin_1"];var _emscripten_bind_btDefaultVehicleRaycaster_btDefaultVehicleRaycaster_1=Module["_emscripten_bind_btDefaultVehicleRaycaster_btDefaultVehicleRaycaster_1"]=asm["_emscripten_bind_btDefaultVehicleRaycaster_btDefaultVehicleRaycaster_1"];var _emscripten_bind_btPoint2PointConstraint_get_m_setting_0=Module["_emscripten_bind_btPoint2PointConstraint_get_m_setting_0"]=asm["_emscripten_bind_btPoint2PointConstraint_get_m_setting_0"];var _emscripten_bind_btCollisionObject_setUserPointer_1=Module["_emscripten_bind_btCollisionObject_setUserPointer_1"]=asm["_emscripten_bind_btCollisionObject_setUserPointer_1"];var _emscripten_bind_btSequentialImpulseConstraintSolver_btSequentialImpulseConstraintSolver_0=Module["_emscripten_bind_btSequentialImpulseConstraintSolver_btSequentialImpulseConstraintSolver_0"]=asm["_emscripten_bind_btSequentialImpulseConstraintSolver_btSequentialImpulseConstraintSolver_0"];var _emscripten_bind_btActionInterface___destroy___0=Module["_emscripten_bind_btActionInterface___destroy___0"]=asm["_emscripten_bind_btActionInterface___destroy___0"];var _emscripten_bind_btSoftBody_generateClusters_2=Module["_emscripten_bind_btSoftBody_generateClusters_2"]=asm["_emscripten_bind_btSoftBody_generateClusters_2"];var _emscripten_bind_btDefaultMotionState_setWorldTransform_1=Module["_emscripten_bind_btDefaultMotionState_setWorldTransform_1"]=asm["_emscripten_bind_btDefaultMotionState_setWorldTransform_1"];var _emscripten_bind_btSoftBody_generateClusters_1=Module["_emscripten_bind_btSoftBody_generateClusters_1"]=asm["_emscripten_bind_btSoftBody_generateClusters_1"];var _emscripten_bind_RayResultCallback_get_m_collisionObject_0=Module["_emscripten_bind_RayResultCallback_get_m_collisionObject_0"]=asm["_emscripten_bind_RayResultCallback_get_m_collisionObject_0"];var _emscripten_bind_btPoint2PointConstraint_getPivotInA_0=Module["_emscripten_bind_btPoint2PointConstraint_getPivotInA_0"]=asm["_emscripten_bind_btPoint2PointConstraint_getPivotInA_0"];var _emscripten_bind_Config_get_kAHR_0=Module["_emscripten_bind_Config_get_kAHR_0"]=asm["_emscripten_bind_Config_get_kAHR_0"];var _emscripten_bind_btGeneric6DofSpringConstraint_setStiffness_2=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setStiffness_2"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setStiffness_2"];var _emscripten_bind_btCylinderShape_calculateLocalInertia_2=Module["_emscripten_bind_btCylinderShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btCylinderShape_calculateLocalInertia_2"];var _emscripten_bind_btCompoundShape_setMargin_1=Module["_emscripten_bind_btCompoundShape_setMargin_1"]=asm["_emscripten_bind_btCompoundShape_setMargin_1"];var _emscripten_bind_ClosestConvexResultCallback___destroy___0=Module["_emscripten_bind_ClosestConvexResultCallback___destroy___0"]=asm["_emscripten_bind_ClosestConvexResultCallback___destroy___0"];var _emscripten_bind_btDynamicsWorld_addCollisionObject_1=Module["_emscripten_bind_btDynamicsWorld_addCollisionObject_1"]=asm["_emscripten_bind_btDynamicsWorld_addCollisionObject_1"];var _emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterMask_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterMask_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterMask_0"];var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var _emscripten_bind_btDynamicsWorld_addCollisionObject_2=Module["_emscripten_bind_btDynamicsWorld_addCollisionObject_2"]=asm["_emscripten_bind_btDynamicsWorld_addCollisionObject_2"];var _emscripten_bind_btDiscreteDynamicsWorld_getDispatcher_0=Module["_emscripten_bind_btDiscreteDynamicsWorld_getDispatcher_0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_getDispatcher_0"];var _emscripten_bind_btGeneric6DofSpringConstraint_enableFeedback_1=Module["_emscripten_bind_btGeneric6DofSpringConstraint_enableFeedback_1"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_enableFeedback_1"];var _emscripten_bind_btHeightfieldTerrainShape___destroy___0=Module["_emscripten_bind_btHeightfieldTerrainShape___destroy___0"]=asm["_emscripten_bind_btHeightfieldTerrainShape___destroy___0"];var _emscripten_bind_btWheelInfo_get_m_maxSuspensionTravelCm_0=Module["_emscripten_bind_btWheelInfo_get_m_maxSuspensionTravelCm_0"]=asm["_emscripten_bind_btWheelInfo_get_m_maxSuspensionTravelCm_0"];var _emscripten_bind_Config_get_kVC_0=Module["_emscripten_bind_Config_get_kVC_0"]=asm["_emscripten_bind_Config_get_kVC_0"];var _emscripten_bind_btVector4_op_mul_1=Module["_emscripten_bind_btVector4_op_mul_1"]=asm["_emscripten_bind_btVector4_op_mul_1"];var _emscripten_bind_btCylinderShape_btCylinderShape_1=Module["_emscripten_bind_btCylinderShape_btCylinderShape_1"]=asm["_emscripten_bind_btCylinderShape_btCylinderShape_1"];var _emscripten_bind_btPairCachingGhostObject_setActivationState_1=Module["_emscripten_bind_btPairCachingGhostObject_setActivationState_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setActivationState_1"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_linearDamping_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_linearDamping_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_linearDamping_1"];var _emscripten_bind_Material_get_m_kVST_0=Module["_emscripten_bind_Material_get_m_kVST_0"]=asm["_emscripten_bind_Material_get_m_kVST_0"];var _emscripten_bind_Config_set_kVCF_1=Module["_emscripten_bind_Config_set_kVCF_1"]=asm["_emscripten_bind_Config_set_kVCF_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_3=Module["_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_3"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_3"];var _emscripten_bind_btGhostObject_getUserIndex_0=Module["_emscripten_bind_btGhostObject_getUserIndex_0"]=asm["_emscripten_bind_btGhostObject_getUserIndex_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_1"];var _emscripten_bind_btVector3___destroy___0=Module["_emscripten_bind_btVector3___destroy___0"]=asm["_emscripten_bind_btVector3___destroy___0"];var _emscripten_bind_RaycastInfo___destroy___0=Module["_emscripten_bind_RaycastInfo___destroy___0"]=asm["_emscripten_bind_RaycastInfo___destroy___0"];var _emscripten_bind_btRigidBody_setAngularFactor_1=Module["_emscripten_bind_btRigidBody_setAngularFactor_1"]=asm["_emscripten_bind_btRigidBody_setAngularFactor_1"];var _emscripten_bind_btCylinderShapeZ_calculateLocalInertia_2=Module["_emscripten_bind_btCylinderShapeZ_calculateLocalInertia_2"]=asm["_emscripten_bind_btCylinderShapeZ_calculateLocalInertia_2"];var _emscripten_bind_btConeShapeZ_btConeShapeZ_2=Module["_emscripten_bind_btConeShapeZ_btConeShapeZ_2"]=asm["_emscripten_bind_btConeShapeZ_btConeShapeZ_2"];var _emscripten_bind_LocalShapeInfo_set_m_triangleIndex_1=Module["_emscripten_bind_LocalShapeInfo_set_m_triangleIndex_1"]=asm["_emscripten_bind_LocalShapeInfo_set_m_triangleIndex_1"];var _emscripten_bind_btMotionState_getWorldTransform_1=Module["_emscripten_bind_btMotionState_getWorldTransform_1"]=asm["_emscripten_bind_btMotionState_getWorldTransform_1"];var _emscripten_bind_btDynamicsWorld_getSolverInfo_0=Module["_emscripten_bind_btDynamicsWorld_getSolverInfo_0"]=asm["_emscripten_bind_btDynamicsWorld_getSolverInfo_0"];var _emscripten_bind_Config_get_kMT_0=Module["_emscripten_bind_Config_get_kMT_0"]=asm["_emscripten_bind_Config_get_kMT_0"];var _emscripten_bind_btDynamicsWorld_getBroadphase_0=Module["_emscripten_bind_btDynamicsWorld_getBroadphase_0"]=asm["_emscripten_bind_btDynamicsWorld_getBroadphase_0"];var _emscripten_bind_btSphereShape_getMargin_0=Module["_emscripten_bind_btSphereShape_getMargin_0"]=asm["_emscripten_bind_btSphereShape_getMargin_0"];var _emscripten_bind_Config_get_timescale_0=Module["_emscripten_bind_Config_get_timescale_0"]=asm["_emscripten_bind_Config_get_timescale_0"];var _emscripten_bind_btVector3_x_0=Module["_emscripten_bind_btVector3_x_0"]=asm["_emscripten_bind_btVector3_x_0"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var _emscripten_bind_btConvexTriangleMeshShape___destroy___0=Module["_emscripten_bind_btConvexTriangleMeshShape___destroy___0"]=asm["_emscripten_bind_btConvexTriangleMeshShape___destroy___0"];var _emscripten_bind_btCollisionObject_getCollisionShape_0=Module["_emscripten_bind_btCollisionObject_getCollisionShape_0"]=asm["_emscripten_bind_btCollisionObject_getCollisionShape_0"];var _emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_4=Module["_emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_4"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_4"];var _emscripten_bind_btManifoldPoint___destroy___0=Module["_emscripten_bind_btManifoldPoint___destroy___0"]=asm["_emscripten_bind_btManifoldPoint___destroy___0"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_rollingFriction_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_rollingFriction_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_rollingFriction_1"];var _emscripten_bind_btVector4_length_0=Module["_emscripten_bind_btVector4_length_0"]=asm["_emscripten_bind_btVector4_length_0"];var _emscripten_bind_btGhostObject_setUserIndex_1=Module["_emscripten_bind_btGhostObject_setUserIndex_1"]=asm["_emscripten_bind_btGhostObject_setUserIndex_1"];var _emscripten_bind_btDefaultMotionState_set_m_graphicsWorldTrans_1=Module["_emscripten_bind_btDefaultMotionState_set_m_graphicsWorldTrans_1"]=asm["_emscripten_bind_btDefaultMotionState_set_m_graphicsWorldTrans_1"];var _emscripten_bind_btGhostObject_setRestitution_1=Module["_emscripten_bind_btGhostObject_setRestitution_1"]=asm["_emscripten_bind_btGhostObject_setRestitution_1"];var _emscripten_bind_btConeTwistConstraint_setAngularOnly_1=Module["_emscripten_bind_btConeTwistConstraint_setAngularOnly_1"]=asm["_emscripten_bind_btConeTwistConstraint_setAngularOnly_1"];var _emscripten_bind_btCollisionObject_setFriction_1=Module["_emscripten_bind_btCollisionObject_setFriction_1"]=asm["_emscripten_bind_btCollisionObject_setFriction_1"];var _emscripten_bind_btDefaultCollisionConfiguration___destroy___0=Module["_emscripten_bind_btDefaultCollisionConfiguration___destroy___0"]=asm["_emscripten_bind_btDefaultCollisionConfiguration___destroy___0"];var _emscripten_bind_btRigidBody_setMassProps_2=Module["_emscripten_bind_btRigidBody_setMassProps_2"]=asm["_emscripten_bind_btRigidBody_setMassProps_2"];var _emscripten_bind_btVector3_setValue_3=Module["_emscripten_bind_btVector3_setValue_3"]=asm["_emscripten_bind_btVector3_setValue_3"];var _emscripten_bind_btPairCachingGhostObject_setCcdMotionThreshold_1=Module["_emscripten_bind_btPairCachingGhostObject_setCcdMotionThreshold_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setCcdMotionThreshold_1"];var _emscripten_bind_RaycastInfo_get_m_suspensionLength_0=Module["_emscripten_bind_RaycastInfo_get_m_suspensionLength_0"]=asm["_emscripten_bind_RaycastInfo_get_m_suspensionLength_0"];var _emscripten_bind_btGhostObject_getCollisionFlags_0=Module["_emscripten_bind_btGhostObject_getCollisionFlags_0"]=asm["_emscripten_bind_btGhostObject_getCollisionFlags_0"];var _emscripten_bind_btCapsuleShapeX___destroy___0=Module["_emscripten_bind_btCapsuleShapeX___destroy___0"]=asm["_emscripten_bind_btCapsuleShapeX___destroy___0"];var _emscripten_bind_btAxisSweep3___destroy___0=Module["_emscripten_bind_btAxisSweep3___destroy___0"]=asm["_emscripten_bind_btAxisSweep3___destroy___0"];var _emscripten_bind_Config_set_kDG_1=Module["_emscripten_bind_Config_set_kDG_1"]=asm["_emscripten_bind_Config_set_kDG_1"];var _emscripten_bind_Material_get_m_flags_0=Module["_emscripten_bind_Material_get_m_flags_0"]=asm["_emscripten_bind_Material_get_m_flags_0"];var _emscripten_bind_btHingeConstraint_setLimit_4=Module["_emscripten_bind_btHingeConstraint_setLimit_4"]=asm["_emscripten_bind_btHingeConstraint_setLimit_4"];var _emscripten_bind_btHingeConstraint_setLimit_5=Module["_emscripten_bind_btHingeConstraint_setLimit_5"]=asm["_emscripten_bind_btHingeConstraint_setLimit_5"];var _emscripten_bind_btSoftBodyWorldInfo_btSoftBodyWorldInfo_0=Module["_emscripten_bind_btSoftBodyWorldInfo_btSoftBodyWorldInfo_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_btSoftBodyWorldInfo_0"];var _emscripten_bind_btDefaultVehicleRaycaster___destroy___0=Module["_emscripten_bind_btDefaultVehicleRaycaster___destroy___0"]=asm["_emscripten_bind_btDefaultVehicleRaycaster___destroy___0"];var _emscripten_bind_btWheelInfo_set_m_maxSuspensionTravelCm_1=Module["_emscripten_bind_btWheelInfo_set_m_maxSuspensionTravelCm_1"]=asm["_emscripten_bind_btWheelInfo_set_m_maxSuspensionTravelCm_1"];var _emscripten_bind_btWheelInfo_set_m_wheelsSuspensionForce_1=Module["_emscripten_bind_btWheelInfo_set_m_wheelsSuspensionForce_1"]=asm["_emscripten_bind_btWheelInfo_set_m_wheelsSuspensionForce_1"];var _emscripten_bind_btSoftBody_scale_1=Module["_emscripten_bind_btSoftBody_scale_1"]=asm["_emscripten_bind_btSoftBody_scale_1"];var _emscripten_bind_Config_get_citerations_0=Module["_emscripten_bind_Config_get_citerations_0"]=asm["_emscripten_bind_Config_get_citerations_0"];var _emscripten_bind_btTypedConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btTypedConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btTypedConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_btGhostObject_getCollisionShape_0=Module["_emscripten_bind_btGhostObject_getCollisionShape_0"]=asm["_emscripten_bind_btGhostObject_getCollisionShape_0"];var _emscripten_bind_btCollisionObject_setAnisotropicFriction_2=Module["_emscripten_bind_btCollisionObject_setAnisotropicFriction_2"]=asm["_emscripten_bind_btCollisionObject_setAnisotropicFriction_2"];var _emscripten_bind_btBoxShape___destroy___0=Module["_emscripten_bind_btBoxShape___destroy___0"]=asm["_emscripten_bind_btBoxShape___destroy___0"];var _emscripten_bind_btPersistentManifold_getContactPoint_1=Module["_emscripten_bind_btPersistentManifold_getContactPoint_1"]=asm["_emscripten_bind_btPersistentManifold_getContactPoint_1"];var _emscripten_bind_btGeneric6DofSpringConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btGeneric6DofSpringConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_ConvexResultCallback_set_m_collisionFilterGroup_1=Module["_emscripten_bind_ConvexResultCallback_set_m_collisionFilterGroup_1"]=asm["_emscripten_bind_ConvexResultCallback_set_m_collisionFilterGroup_1"];var _emscripten_bind_RaycastInfo_set_m_groundObject_1=Module["_emscripten_bind_RaycastInfo_set_m_groundObject_1"]=asm["_emscripten_bind_RaycastInfo_set_m_groundObject_1"];var _emscripten_bind_btGhostObject_activate_1=Module["_emscripten_bind_btGhostObject_activate_1"]=asm["_emscripten_bind_btGhostObject_activate_1"];var _emscripten_bind_btGeneric6DofSpringConstraint_enableSpring_2=Module["_emscripten_bind_btGeneric6DofSpringConstraint_enableSpring_2"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_enableSpring_2"];var _emscripten_bind_btManifoldPoint_getPositionWorldOnB_0=Module["_emscripten_bind_btManifoldPoint_getPositionWorldOnB_0"]=asm["_emscripten_bind_btManifoldPoint_getPositionWorldOnB_0"];var _emscripten_bind_btManifoldPoint_get_m_positionWorldOnA_0=Module["_emscripten_bind_btManifoldPoint_get_m_positionWorldOnA_0"]=asm["_emscripten_bind_btManifoldPoint_get_m_positionWorldOnA_0"];var _emscripten_bind_btDefaultSoftBodySolver_btDefaultSoftBodySolver_0=Module["_emscripten_bind_btDefaultSoftBodySolver_btDefaultSoftBodySolver_0"]=asm["_emscripten_bind_btDefaultSoftBodySolver_btDefaultSoftBodySolver_0"];var _emscripten_bind_btSphereShape_setMargin_1=Module["_emscripten_bind_btSphereShape_setMargin_1"]=asm["_emscripten_bind_btSphereShape_setMargin_1"];var _emscripten_bind_btSoftBody_get_m_cfg_0=Module["_emscripten_bind_btSoftBody_get_m_cfg_0"]=asm["_emscripten_bind_btSoftBody_get_m_cfg_0"];var _emscripten_bind_btCollisionObject_setUserIndex_1=Module["_emscripten_bind_btCollisionObject_setUserIndex_1"]=asm["_emscripten_bind_btCollisionObject_setUserIndex_1"];var _emscripten_bind_btContactSolverInfo_set_m_splitImpulsePenetrationThreshold_1=Module["_emscripten_bind_btContactSolverInfo_set_m_splitImpulsePenetrationThreshold_1"]=asm["_emscripten_bind_btContactSolverInfo_set_m_splitImpulsePenetrationThreshold_1"];var _emscripten_bind_btSliderConstraint_setUpperAngLimit_1=Module["_emscripten_bind_btSliderConstraint_setUpperAngLimit_1"]=asm["_emscripten_bind_btSliderConstraint_setUpperAngLimit_1"];var _emscripten_bind_btDynamicsWorld_contactPairTest_3=Module["_emscripten_bind_btDynamicsWorld_contactPairTest_3"]=asm["_emscripten_bind_btDynamicsWorld_contactPairTest_3"];var _emscripten_bind_btCollisionWorld_getPairCache_0=Module["_emscripten_bind_btCollisionWorld_getPairCache_0"]=asm["_emscripten_bind_btCollisionWorld_getPairCache_0"];var _emscripten_bind_btConeTwistConstraint_setMotorTarget_1=Module["_emscripten_bind_btConeTwistConstraint_setMotorTarget_1"]=asm["_emscripten_bind_btConeTwistConstraint_setMotorTarget_1"];var _emscripten_bind_ClosestConvexResultCallback_set_m_convexFromWorld_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_convexFromWorld_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_convexFromWorld_1"];var _emscripten_bind_btWheelInfo_set_m_rollInfluence_1=Module["_emscripten_bind_btWheelInfo_set_m_rollInfluence_1"]=asm["_emscripten_bind_btWheelInfo_set_m_rollInfluence_1"];var _emscripten_bind_btGhostObject_setCcdMotionThreshold_1=Module["_emscripten_bind_btGhostObject_setCcdMotionThreshold_1"]=asm["_emscripten_bind_btGhostObject_setCcdMotionThreshold_1"];var _emscripten_bind_btGeneric6DofConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btGeneric6DofConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btGeneric6DofConstraint_setBreakingImpulseThreshold_1"];var _emscripten_enum_PHY_ScalarType_PHY_INTEGER=Module["_emscripten_enum_PHY_ScalarType_PHY_INTEGER"]=asm["_emscripten_enum_PHY_ScalarType_PHY_INTEGER"];var _emscripten_bind_btSoftBodyHelpers_CreatePatchUV_10=Module["_emscripten_bind_btSoftBodyHelpers_CreatePatchUV_10"]=asm["_emscripten_bind_btSoftBodyHelpers_CreatePatchUV_10"];var _emscripten_bind_btGhostObject_forceActivationState_1=Module["_emscripten_bind_btGhostObject_forceActivationState_1"]=asm["_emscripten_bind_btGhostObject_forceActivationState_1"];var _emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5=Module["_emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5"]=asm["_emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5"];var _emscripten_bind_btVector4_y_0=Module["_emscripten_bind_btVector4_y_0"]=asm["_emscripten_bind_btVector4_y_0"];var _emscripten_bind_VoidPtr___destroy___0=Module["_emscripten_bind_VoidPtr___destroy___0"]=asm["_emscripten_bind_VoidPtr___destroy___0"];var _emscripten_bind_RaycastInfo_set_m_contactNormalWS_1=Module["_emscripten_bind_RaycastInfo_set_m_contactNormalWS_1"]=asm["_emscripten_bind_RaycastInfo_set_m_contactNormalWS_1"];var _emscripten_bind_btSliderConstraint_setLowerAngLimit_1=Module["_emscripten_bind_btSliderConstraint_setLowerAngLimit_1"]=asm["_emscripten_bind_btSliderConstraint_setLowerAngLimit_1"];var _emscripten_bind_ClosestRayResultCallback_get_m_collisionObject_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_collisionObject_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_collisionObject_0"];var _emscripten_bind_RaycastInfo_set_m_contactPointWS_1=Module["_emscripten_bind_RaycastInfo_set_m_contactPointWS_1"]=asm["_emscripten_bind_RaycastInfo_set_m_contactPointWS_1"];var _emscripten_bind_ClosestConvexResultCallback_ClosestConvexResultCallback_2=Module["_emscripten_bind_ClosestConvexResultCallback_ClosestConvexResultCallback_2"]=asm["_emscripten_bind_ClosestConvexResultCallback_ClosestConvexResultCallback_2"];var _emscripten_bind_ClosestRayResultCallback_get_m_rayFromWorld_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_rayFromWorld_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_rayFromWorld_0"];var _emscripten_bind_btSoftBody_setContactProcessingThreshold_1=Module["_emscripten_bind_btSoftBody_setContactProcessingThreshold_1"]=asm["_emscripten_bind_btSoftBody_setContactProcessingThreshold_1"];var _emscripten_bind_btPairCachingGhostObject_getNumOverlappingObjects_0=Module["_emscripten_bind_btPairCachingGhostObject_getNumOverlappingObjects_0"]=asm["_emscripten_bind_btPairCachingGhostObject_getNumOverlappingObjects_0"];var _emscripten_bind_btSliderConstraint_enableFeedback_1=Module["_emscripten_bind_btSliderConstraint_enableFeedback_1"]=asm["_emscripten_bind_btSliderConstraint_enableFeedback_1"];var _emscripten_bind_RayResultCallback_get_m_collisionFilterGroup_0=Module["_emscripten_bind_RayResultCallback_get_m_collisionFilterGroup_0"]=asm["_emscripten_bind_RayResultCallback_get_m_collisionFilterGroup_0"];var _emscripten_enum_PHY_ScalarType_PHY_DOUBLE=Module["_emscripten_enum_PHY_ScalarType_PHY_DOUBLE"]=asm["_emscripten_enum_PHY_ScalarType_PHY_DOUBLE"];var _emscripten_bind_btConstraintSetting_get_m_tau_0=Module["_emscripten_bind_btConstraintSetting_get_m_tau_0"]=asm["_emscripten_bind_btConstraintSetting_get_m_tau_0"];var _emscripten_bind_btConeShape_setLocalScaling_1=Module["_emscripten_bind_btConeShape_setLocalScaling_1"]=asm["_emscripten_bind_btConeShape_setLocalScaling_1"];var _emscripten_bind_btCollisionObject_setCollisionShape_1=Module["_emscripten_bind_btCollisionObject_setCollisionShape_1"]=asm["_emscripten_bind_btCollisionObject_setCollisionShape_1"];var _emscripten_bind_btCollisionShape___destroy___0=Module["_emscripten_bind_btCollisionShape___destroy___0"]=asm["_emscripten_bind_btCollisionShape___destroy___0"];var _emscripten_bind_btMatrix3x3_getRow_1=Module["_emscripten_bind_btMatrix3x3_getRow_1"]=asm["_emscripten_bind_btMatrix3x3_getRow_1"];var _emscripten_bind_ConvexResultCallback_get_m_closestHitFraction_0=Module["_emscripten_bind_ConvexResultCallback_get_m_closestHitFraction_0"]=asm["_emscripten_bind_ConvexResultCallback_get_m_closestHitFraction_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_getPairCache_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getPairCache_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getPairCache_0"];var _emscripten_bind_btDispatcherInfo_get_m_dispatchFunc_0=Module["_emscripten_bind_btDispatcherInfo_get_m_dispatchFunc_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_dispatchFunc_0"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_rollingFriction_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_rollingFriction_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_rollingFriction_0"];var _emscripten_bind_btSoftBody_getUserIndex_0=Module["_emscripten_bind_btSoftBody_getUserIndex_0"]=asm["_emscripten_bind_btSoftBody_getUserIndex_0"];var _emscripten_bind_btPairCachingGhostObject_setCollisionShape_1=Module["_emscripten_bind_btPairCachingGhostObject_setCollisionShape_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setCollisionShape_1"];var _emscripten_bind_btKinematicCharacterController_warp_1=Module["_emscripten_bind_btKinematicCharacterController_warp_1"]=asm["_emscripten_bind_btKinematicCharacterController_warp_1"];var _emscripten_bind_btContactSolverInfo___destroy___0=Module["_emscripten_bind_btContactSolverInfo___destroy___0"]=asm["_emscripten_bind_btContactSolverInfo___destroy___0"];var _emscripten_bind_btSoftBody_getWorldTransform_0=Module["_emscripten_bind_btSoftBody_getWorldTransform_0"]=asm["_emscripten_bind_btSoftBody_getWorldTransform_0"];var _emscripten_bind_btTriangleMesh___destroy___0=Module["_emscripten_bind_btTriangleMesh___destroy___0"]=asm["_emscripten_bind_btTriangleMesh___destroy___0"];var _emscripten_bind_btKinematicCharacterController_preStep_1=Module["_emscripten_bind_btKinematicCharacterController_preStep_1"]=asm["_emscripten_bind_btKinematicCharacterController_preStep_1"];var _emscripten_bind_btRaycastVehicle_applyEngineForce_2=Module["_emscripten_bind_btRaycastVehicle_applyEngineForce_2"]=asm["_emscripten_bind_btRaycastVehicle_applyEngineForce_2"];var _emscripten_bind_btBoxShape_calculateLocalInertia_2=Module["_emscripten_bind_btBoxShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btBoxShape_calculateLocalInertia_2"];var _emscripten_bind_btRaycastVehicle_setBrake_2=Module["_emscripten_bind_btRaycastVehicle_setBrake_2"]=asm["_emscripten_bind_btRaycastVehicle_setBrake_2"];var _emscripten_bind_ConcreteContactResultCallback___destroy___0=Module["_emscripten_bind_ConcreteContactResultCallback___destroy___0"]=asm["_emscripten_bind_ConcreteContactResultCallback___destroy___0"];var _emscripten_bind_RaycastInfo_set_m_wheelAxleWS_1=Module["_emscripten_bind_RaycastInfo_set_m_wheelAxleWS_1"]=asm["_emscripten_bind_RaycastInfo_set_m_wheelAxleWS_1"];var _emscripten_bind_btCollisionObject___destroy___0=Module["_emscripten_bind_btCollisionObject___destroy___0"]=asm["_emscripten_bind_btCollisionObject___destroy___0"];var _emscripten_bind_btVehicleTuning_set_m_suspensionDamping_1=Module["_emscripten_bind_btVehicleTuning_set_m_suspensionDamping_1"]=asm["_emscripten_bind_btVehicleTuning_set_m_suspensionDamping_1"];var _emscripten_bind_btConvexTriangleMeshShape_setMargin_1=Module["_emscripten_bind_btConvexTriangleMeshShape_setMargin_1"]=asm["_emscripten_bind_btConvexTriangleMeshShape_setMargin_1"];var _emscripten_bind_Config_get_kSSHR_CL_0=Module["_emscripten_bind_Config_get_kSSHR_CL_0"]=asm["_emscripten_bind_Config_get_kSSHR_CL_0"];var _emscripten_bind_btConeTwistConstraint_setMotorTargetInConstraintSpace_1=Module["_emscripten_bind_btConeTwistConstraint_setMotorTargetInConstraintSpace_1"]=asm["_emscripten_bind_btConeTwistConstraint_setMotorTargetInConstraintSpace_1"];var _emscripten_bind_btDispatcherInfo_set_m_timeStep_1=Module["_emscripten_bind_btDispatcherInfo_set_m_timeStep_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_timeStep_1"];var _emscripten_bind_btVector3_btVector3_3=Module["_emscripten_bind_btVector3_btVector3_3"]=asm["_emscripten_bind_btVector3_btVector3_3"];var _emscripten_bind_btVector3_btVector3_0=Module["_emscripten_bind_btVector3_btVector3_0"]=asm["_emscripten_bind_btVector3_btVector3_0"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_friction_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_friction_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_friction_1"];var _emscripten_bind_btDiscreteDynamicsWorld_getGravity_0=Module["_emscripten_bind_btDiscreteDynamicsWorld_getGravity_0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_getGravity_0"];var _emscripten_bind_btVector3_z_0=Module["_emscripten_bind_btVector3_z_0"]=asm["_emscripten_bind_btVector3_z_0"];var _emscripten_bind_ClosestConvexResultCallback_get_m_hitPointWorld_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_hitPointWorld_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_hitPointWorld_0"];var _emscripten_bind_btCollisionShape_getMargin_0=Module["_emscripten_bind_btCollisionShape_getMargin_0"]=asm["_emscripten_bind_btCollisionShape_getMargin_0"];var _emscripten_bind_btSoftBodyWorldInfo_set_water_offset_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_water_offset_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_water_offset_1"];var _emscripten_bind_btBroadphaseInterface___destroy___0=Module["_emscripten_bind_btBroadphaseInterface___destroy___0"]=asm["_emscripten_bind_btBroadphaseInterface___destroy___0"];var _emscripten_bind_btVehicleTuning_get_m_suspensionDamping_0=Module["_emscripten_bind_btVehicleTuning_get_m_suspensionDamping_0"]=asm["_emscripten_bind_btVehicleTuning_get_m_suspensionDamping_0"];var _emscripten_bind_ConcreteContactResultCallback_addSingleResult_7=Module["_emscripten_bind_ConcreteContactResultCallback_addSingleResult_7"]=asm["_emscripten_bind_ConcreteContactResultCallback_addSingleResult_7"];var _emscripten_bind_RaycastInfo_get_m_hardPointWS_0=Module["_emscripten_bind_RaycastInfo_get_m_hardPointWS_0"]=asm["_emscripten_bind_RaycastInfo_get_m_hardPointWS_0"];var _emscripten_bind_btConeTwistConstraint___destroy___0=Module["_emscripten_bind_btConeTwistConstraint___destroy___0"]=asm["_emscripten_bind_btConeTwistConstraint___destroy___0"];var _emscripten_bind_btQuadWord___destroy___0=Module["_emscripten_bind_btQuadWord___destroy___0"]=asm["_emscripten_bind_btQuadWord___destroy___0"];var _emscripten_bind_btSoftRigidDynamicsWorld_contactPairTest_3=Module["_emscripten_bind_btSoftRigidDynamicsWorld_contactPairTest_3"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_contactPairTest_3"];var _emscripten_bind_btQuaternion_setEulerZYX_3=Module["_emscripten_bind_btQuaternion_setEulerZYX_3"]=asm["_emscripten_bind_btQuaternion_setEulerZYX_3"];var _emscripten_bind_ClosestRayResultCallback_set_m_rayFromWorld_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_rayFromWorld_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_rayFromWorld_1"];var _emscripten_bind_btGeneric6DofSpringConstraint_setDamping_2=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setDamping_2"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setDamping_2"];var _emscripten_bind_RaycastInfo_get_m_wheelDirectionWS_0=Module["_emscripten_bind_RaycastInfo_get_m_wheelDirectionWS_0"]=asm["_emscripten_bind_RaycastInfo_get_m_wheelDirectionWS_0"];var _emscripten_bind_btRigidBody_setCenterOfMassTransform_1=Module["_emscripten_bind_btRigidBody_setCenterOfMassTransform_1"]=asm["_emscripten_bind_btRigidBody_setCenterOfMassTransform_1"];var _emscripten_bind_btSoftBody_setUserIndex_1=Module["_emscripten_bind_btSoftBody_setUserIndex_1"]=asm["_emscripten_bind_btSoftBody_setUserIndex_1"];var _emscripten_bind_btWheelInfo_get_m_chassisConnectionPointCS_0=Module["_emscripten_bind_btWheelInfo_get_m_chassisConnectionPointCS_0"]=asm["_emscripten_bind_btWheelInfo_get_m_chassisConnectionPointCS_0"];var _emscripten_bind_btSoftBody_setCollisionShape_1=Module["_emscripten_bind_btSoftBody_setCollisionShape_1"]=asm["_emscripten_bind_btSoftBody_setCollisionShape_1"];var _emscripten_bind_btGhostObject_setAnisotropicFriction_2=Module["_emscripten_bind_btGhostObject_setAnisotropicFriction_2"]=asm["_emscripten_bind_btGhostObject_setAnisotropicFriction_2"];var _emscripten_bind_btConstraintSolver___destroy___0=Module["_emscripten_bind_btConstraintSolver___destroy___0"]=asm["_emscripten_bind_btConstraintSolver___destroy___0"];var _emscripten_bind_btSoftBody_isActive_0=Module["_emscripten_bind_btSoftBody_isActive_0"]=asm["_emscripten_bind_btSoftBody_isActive_0"];var _emscripten_bind_btCapsuleShape_btCapsuleShape_2=Module["_emscripten_bind_btCapsuleShape_btCapsuleShape_2"]=asm["_emscripten_bind_btCapsuleShape_btCapsuleShape_2"];var _emscripten_bind_btTypedConstraint_enableFeedback_1=Module["_emscripten_bind_btTypedConstraint_enableFeedback_1"]=asm["_emscripten_bind_btTypedConstraint_enableFeedback_1"];var _emscripten_bind_btSoftBody_setRollingFriction_1=Module["_emscripten_bind_btSoftBody_setRollingFriction_1"]=asm["_emscripten_bind_btSoftBody_setRollingFriction_1"];var _emscripten_bind_btGhostObject_activate_0=Module["_emscripten_bind_btGhostObject_activate_0"]=asm["_emscripten_bind_btGhostObject_activate_0"];var _emscripten_bind_btConstraintSetting_btConstraintSetting_0=Module["_emscripten_bind_btConstraintSetting_btConstraintSetting_0"]=asm["_emscripten_bind_btConstraintSetting_btConstraintSetting_0"];var _emscripten_bind_btCapsuleShape_setLocalScaling_1=Module["_emscripten_bind_btCapsuleShape_setLocalScaling_1"]=asm["_emscripten_bind_btCapsuleShape_setLocalScaling_1"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDampingFactor_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDampingFactor_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDampingFactor_0"];var _emscripten_bind_btRigidBody_setAnisotropicFriction_2=Module["_emscripten_bind_btRigidBody_setAnisotropicFriction_2"]=asm["_emscripten_bind_btRigidBody_setAnisotropicFriction_2"];var _emscripten_bind_btSoftBody_btSoftBody_4=Module["_emscripten_bind_btSoftBody_btSoftBody_4"]=asm["_emscripten_bind_btSoftBody_btSoftBody_4"];var _emscripten_bind_btTriangleMeshShape_setLocalScaling_1=Module["_emscripten_bind_btTriangleMeshShape_setLocalScaling_1"]=asm["_emscripten_bind_btTriangleMeshShape_setLocalScaling_1"];var _emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_3=Module["_emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_3"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_3"];var _emscripten_bind_ConvexResultCallback_set_m_closestHitFraction_1=Module["_emscripten_bind_ConvexResultCallback_set_m_closestHitFraction_1"]=asm["_emscripten_bind_ConvexResultCallback_set_m_closestHitFraction_1"];var _emscripten_bind_btVector3_op_add_1=Module["_emscripten_bind_btVector3_op_add_1"]=asm["_emscripten_bind_btVector3_op_add_1"];var _emscripten_bind_btPersistentManifold_btPersistentManifold_0=Module["_emscripten_bind_btPersistentManifold_btPersistentManifold_0"]=asm["_emscripten_bind_btPersistentManifold_btPersistentManifold_0"];var _emscripten_bind_ConvexResultCallback_get_m_collisionFilterMask_0=Module["_emscripten_bind_ConvexResultCallback_get_m_collisionFilterMask_0"]=asm["_emscripten_bind_ConvexResultCallback_get_m_collisionFilterMask_0"];var _emscripten_bind_ClosestRayResultCallback_ClosestRayResultCallback_2=Module["_emscripten_bind_ClosestRayResultCallback_ClosestRayResultCallback_2"]=asm["_emscripten_bind_ClosestRayResultCallback_ClosestRayResultCallback_2"];var _emscripten_bind_btVector4___destroy___0=Module["_emscripten_bind_btVector4___destroy___0"]=asm["_emscripten_bind_btVector4___destroy___0"];var _emscripten_bind_btPairCachingGhostObject_isKinematicObject_0=Module["_emscripten_bind_btPairCachingGhostObject_isKinematicObject_0"]=asm["_emscripten_bind_btPairCachingGhostObject_isKinematicObject_0"];var _emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterMask_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterMask_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterMask_1"];var _emscripten_bind_tNodeArray_at_1=Module["_emscripten_bind_tNodeArray_at_1"]=asm["_emscripten_bind_tNodeArray_at_1"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _emscripten_bind_btStaticPlaneShape_calculateLocalInertia_2=Module["_emscripten_bind_btStaticPlaneShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btStaticPlaneShape_calculateLocalInertia_2"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingThresholdSqr_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingThresholdSqr_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingThresholdSqr_0"];var _emscripten_bind_btCollisionObject_setCcdMotionThreshold_1=Module["_emscripten_bind_btCollisionObject_setCcdMotionThreshold_1"]=asm["_emscripten_bind_btCollisionObject_setCcdMotionThreshold_1"];var _emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_4=Module["_emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_4"]=asm["_emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_4"];var _emscripten_bind_btHeightfieldTerrainShape_getMargin_0=Module["_emscripten_bind_btHeightfieldTerrainShape_getMargin_0"]=asm["_emscripten_bind_btHeightfieldTerrainShape_getMargin_0"];var _emscripten_bind_btQuadWord_setZ_1=Module["_emscripten_bind_btQuadWord_setZ_1"]=asm["_emscripten_bind_btQuadWord_setZ_1"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_angularSleepingThreshold_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_angularSleepingThreshold_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_angularSleepingThreshold_0"];var _emscripten_bind_btPoint2PointConstraint_getPivotInB_0=Module["_emscripten_bind_btPoint2PointConstraint_getPivotInB_0"]=asm["_emscripten_bind_btPoint2PointConstraint_getPivotInB_0"];var _emscripten_bind_btKinematicCharacterController_playerStep_2=Module["_emscripten_bind_btKinematicCharacterController_playerStep_2"]=asm["_emscripten_bind_btKinematicCharacterController_playerStep_2"];var _emscripten_bind_btDispatcherInfo___destroy___0=Module["_emscripten_bind_btDispatcherInfo___destroy___0"]=asm["_emscripten_bind_btDispatcherInfo___destroy___0"];var _emscripten_bind_btCapsuleShape_getMargin_0=Module["_emscripten_bind_btCapsuleShape_getMargin_0"]=asm["_emscripten_bind_btCapsuleShape_getMargin_0"];var _emscripten_bind_btCylinderShape_getMargin_0=Module["_emscripten_bind_btCylinderShape_getMargin_0"]=asm["_emscripten_bind_btCylinderShape_getMargin_0"];var _emscripten_bind_btSoftBodyArray_size_0=Module["_emscripten_bind_btSoftBodyArray_size_0"]=asm["_emscripten_bind_btSoftBodyArray_size_0"];var _emscripten_bind_btStaticPlaneShape_setLocalScaling_1=Module["_emscripten_bind_btStaticPlaneShape_setLocalScaling_1"]=asm["_emscripten_bind_btStaticPlaneShape_setLocalScaling_1"];var _emscripten_bind_btConvexTriangleMeshShape_calculateLocalInertia_2=Module["_emscripten_bind_btConvexTriangleMeshShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btConvexTriangleMeshShape_calculateLocalInertia_2"];var _emscripten_bind_ClosestConvexResultCallback_get_m_convexToWorld_0=Module["_emscripten_bind_ClosestConvexResultCallback_get_m_convexToWorld_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_get_m_convexToWorld_0"];var _emscripten_bind_btGhostObject_getWorldTransform_0=Module["_emscripten_bind_btGhostObject_getWorldTransform_0"]=asm["_emscripten_bind_btGhostObject_getWorldTransform_0"];var _emscripten_bind_btDiscreteDynamicsWorld_getPairCache_0=Module["_emscripten_bind_btDiscreteDynamicsWorld_getPairCache_0"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_getPairCache_0"];var _emscripten_bind_LocalConvexResult_set_m_hitFraction_1=Module["_emscripten_bind_LocalConvexResult_set_m_hitFraction_1"]=asm["_emscripten_bind_LocalConvexResult_set_m_hitFraction_1"];var _emscripten_bind_btCapsuleShapeZ_calculateLocalInertia_2=Module["_emscripten_bind_btCapsuleShapeZ_calculateLocalInertia_2"]=asm["_emscripten_bind_btCapsuleShapeZ_calculateLocalInertia_2"];var _emscripten_bind_btDispatcherInfo_get_m_timeStep_0=Module["_emscripten_bind_btDispatcherInfo_get_m_timeStep_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_timeStep_0"];var _emscripten_bind_btHingeConstraint_setAngularOnly_1=Module["_emscripten_bind_btHingeConstraint_setAngularOnly_1"]=asm["_emscripten_bind_btHingeConstraint_setAngularOnly_1"];var _emscripten_bind_btVehicleTuning_set_m_suspensionCompression_1=Module["_emscripten_bind_btVehicleTuning_set_m_suspensionCompression_1"]=asm["_emscripten_bind_btVehicleTuning_set_m_suspensionCompression_1"];var _emscripten_bind_btConstraintSetting_set_m_impulseClamp_1=Module["_emscripten_bind_btConstraintSetting_set_m_impulseClamp_1"]=asm["_emscripten_bind_btConstraintSetting_set_m_impulseClamp_1"];var _emscripten_bind_btMotionState___destroy___0=Module["_emscripten_bind_btMotionState___destroy___0"]=asm["_emscripten_bind_btMotionState___destroy___0"];var _emscripten_bind_btCollisionObject_setCollisionFlags_1=Module["_emscripten_bind_btCollisionObject_setCollisionFlags_1"]=asm["_emscripten_bind_btCollisionObject_setCollisionFlags_1"];var _emscripten_bind_Config_get_kPR_0=Module["_emscripten_bind_Config_get_kPR_0"]=asm["_emscripten_bind_Config_get_kPR_0"];var _emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_1"];var _emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_2=Module["_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_2"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_2"];var _emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_3=Module["_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_3"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_3"];var _emscripten_bind_btWheelInfo_set_m_suspensionStiffness_1=Module["_emscripten_bind_btWheelInfo_set_m_suspensionStiffness_1"]=asm["_emscripten_bind_btWheelInfo_set_m_suspensionStiffness_1"];var _emscripten_bind_RaycastInfo_set_m_suspensionLength_1=Module["_emscripten_bind_RaycastInfo_set_m_suspensionLength_1"]=asm["_emscripten_bind_RaycastInfo_set_m_suspensionLength_1"];var _emscripten_bind_btDispatcher_getManifoldByIndexInternal_1=Module["_emscripten_bind_btDispatcher_getManifoldByIndexInternal_1"]=asm["_emscripten_bind_btDispatcher_getManifoldByIndexInternal_1"];var _emscripten_bind_btSliderConstraint_setBreakingImpulseThreshold_1=Module["_emscripten_bind_btSliderConstraint_setBreakingImpulseThreshold_1"]=asm["_emscripten_bind_btSliderConstraint_setBreakingImpulseThreshold_1"];var _emscripten_bind_btSoftBodyWorldInfo___destroy___0=Module["_emscripten_bind_btSoftBodyWorldInfo___destroy___0"]=asm["_emscripten_bind_btSoftBodyWorldInfo___destroy___0"];var _emscripten_bind_btConvexTriangleMeshShape_getMargin_0=Module["_emscripten_bind_btConvexTriangleMeshShape_getMargin_0"]=asm["_emscripten_bind_btConvexTriangleMeshShape_getMargin_0"];var _emscripten_bind_btSoftBodySolver___destroy___0=Module["_emscripten_bind_btSoftBodySolver___destroy___0"]=asm["_emscripten_bind_btSoftBodySolver___destroy___0"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _emscripten_bind_btWheelInfo_set_m_steering_1=Module["_emscripten_bind_btWheelInfo_set_m_steering_1"]=asm["_emscripten_bind_btWheelInfo_set_m_steering_1"];var _emscripten_bind_Node_set_m_x_1=Module["_emscripten_bind_Node_set_m_x_1"]=asm["_emscripten_bind_Node_set_m_x_1"];var _emscripten_bind_btPairCachingGhostObject_setWorldTransform_1=Module["_emscripten_bind_btPairCachingGhostObject_setWorldTransform_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setWorldTransform_1"];var _emscripten_bind_btHingeConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btHingeConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btHingeConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_btDefaultCollisionConstructionInfo___destroy___0=Module["_emscripten_bind_btDefaultCollisionConstructionInfo___destroy___0"]=asm["_emscripten_bind_btDefaultCollisionConstructionInfo___destroy___0"];var _emscripten_bind_btConeShape___destroy___0=Module["_emscripten_bind_btConeShape___destroy___0"]=asm["_emscripten_bind_btConeShape___destroy___0"];var _emscripten_bind_btGhostObject_setCcdSweptSphereRadius_1=Module["_emscripten_bind_btGhostObject_setCcdSweptSphereRadius_1"]=asm["_emscripten_bind_btGhostObject_setCcdSweptSphereRadius_1"];var _emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_4=Module["_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_4"]=asm["_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_4"];var _emscripten_bind_btConeTwistConstraint_setLimit_2=Module["_emscripten_bind_btConeTwistConstraint_setLimit_2"]=asm["_emscripten_bind_btConeTwistConstraint_setLimit_2"];var _emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_2=Module["_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_2"]=asm["_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_2"];var _emscripten_bind_btKinematicCharacterController_setJumpSpeed_1=Module["_emscripten_bind_btKinematicCharacterController_setJumpSpeed_1"]=asm["_emscripten_bind_btKinematicCharacterController_setJumpSpeed_1"];var _emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration___destroy___0=Module["_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration___destroy___0"]=asm["_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration___destroy___0"];var _emscripten_bind_btConeShapeX_calculateLocalInertia_2=Module["_emscripten_bind_btConeShapeX_calculateLocalInertia_2"]=asm["_emscripten_bind_btConeShapeX_calculateLocalInertia_2"];var _emscripten_enum_PHY_ScalarType_PHY_FIXEDPOINT88=Module["_emscripten_enum_PHY_ScalarType_PHY_FIXEDPOINT88"]=asm["_emscripten_enum_PHY_ScalarType_PHY_FIXEDPOINT88"];var _emscripten_bind_btPairCachingGhostObject_getOverlappingObject_1=Module["_emscripten_bind_btPairCachingGhostObject_getOverlappingObject_1"]=asm["_emscripten_bind_btPairCachingGhostObject_getOverlappingObject_1"];var _emscripten_bind_btGhostObject_getNumOverlappingObjects_0=Module["_emscripten_bind_btGhostObject_getNumOverlappingObjects_0"]=asm["_emscripten_bind_btGhostObject_getNumOverlappingObjects_0"];var _emscripten_bind_btRigidBodyConstructionInfo___destroy___0=Module["_emscripten_bind_btRigidBodyConstructionInfo___destroy___0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo___destroy___0"];var _emscripten_bind_btRigidBody_getWorldTransform_0=Module["_emscripten_bind_btRigidBody_getWorldTransform_0"]=asm["_emscripten_bind_btRigidBody_getWorldTransform_0"];var _emscripten_bind_btPoint2PointConstraint_setPivotA_1=Module["_emscripten_bind_btPoint2PointConstraint_setPivotA_1"]=asm["_emscripten_bind_btPoint2PointConstraint_setPivotA_1"];var _emscripten_bind_ClosestConvexResultCallback_set_m_convexToWorld_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_convexToWorld_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_convexToWorld_1"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _emscripten_bind_Config_get_maxvolume_0=Module["_emscripten_bind_Config_get_maxvolume_0"]=asm["_emscripten_bind_Config_get_maxvolume_0"];var _emscripten_bind_btCapsuleShape_calculateLocalInertia_2=Module["_emscripten_bind_btCapsuleShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btCapsuleShape_calculateLocalInertia_2"];var _emscripten_bind_btSoftRigidDynamicsWorld_getGravity_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getGravity_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getGravity_0"];var _emscripten_bind_btVector3_y_0=Module["_emscripten_bind_btVector3_y_0"]=asm["_emscripten_bind_btVector3_y_0"];var _emscripten_bind_btDispatcherInfo_set_m_useEpa_1=Module["_emscripten_bind_btDispatcherInfo_set_m_useEpa_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_useEpa_1"];var _emscripten_bind_btVehicleTuning_get_m_maxSuspensionForce_0=Module["_emscripten_bind_btVehicleTuning_get_m_maxSuspensionForce_0"]=asm["_emscripten_bind_btVehicleTuning_get_m_maxSuspensionForce_0"];var _emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_2=Module["_emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_2"]=asm["_emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_2"];var _emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_3=Module["_emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_3"]=asm["_emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_3"];var _emscripten_bind_LocalShapeInfo_get_m_triangleIndex_0=Module["_emscripten_bind_LocalShapeInfo_get_m_triangleIndex_0"]=asm["_emscripten_bind_LocalShapeInfo_get_m_triangleIndex_0"];var _emscripten_bind_Config_set_kDF_1=Module["_emscripten_bind_Config_set_kDF_1"]=asm["_emscripten_bind_Config_set_kDF_1"];var _emscripten_bind_btHeightfieldTerrainShape_btHeightfieldTerrainShape_9=Module["_emscripten_bind_btHeightfieldTerrainShape_btHeightfieldTerrainShape_9"]=asm["_emscripten_bind_btHeightfieldTerrainShape_btHeightfieldTerrainShape_9"];var _emscripten_bind_btSoftBody_activate_1=Module["_emscripten_bind_btSoftBody_activate_1"]=asm["_emscripten_bind_btSoftBody_activate_1"];var _emscripten_bind_btSoftBody_activate_0=Module["_emscripten_bind_btSoftBody_activate_0"]=asm["_emscripten_bind_btSoftBody_activate_0"];var _emscripten_bind_btGhostObject_setCollisionShape_1=Module["_emscripten_bind_btGhostObject_setCollisionShape_1"]=asm["_emscripten_bind_btGhostObject_setCollisionShape_1"];var _emscripten_bind_btDispatcherInfo_set_m_allowedCcdPenetration_1=Module["_emscripten_bind_btDispatcherInfo_set_m_allowedCcdPenetration_1"]=asm["_emscripten_bind_btDispatcherInfo_set_m_allowedCcdPenetration_1"];var _emscripten_bind_btRigidBody_setRollingFriction_1=Module["_emscripten_bind_btRigidBody_setRollingFriction_1"]=asm["_emscripten_bind_btRigidBody_setRollingFriction_1"];var _emscripten_bind_btPairCachingGhostObject_setRollingFriction_1=Module["_emscripten_bind_btPairCachingGhostObject_setRollingFriction_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setRollingFriction_1"];var _emscripten_bind_btDiscreteDynamicsWorld_setGravity_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_setGravity_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_setGravity_1"];var _emscripten_bind_btVehicleTuning_set_m_suspensionStiffness_1=Module["_emscripten_bind_btVehicleTuning_set_m_suspensionStiffness_1"]=asm["_emscripten_bind_btVehicleTuning_set_m_suspensionStiffness_1"];var _emscripten_bind_btVector4_z_0=Module["_emscripten_bind_btVector4_z_0"]=asm["_emscripten_bind_btVector4_z_0"];var _emscripten_bind_btCollisionObject_forceActivationState_1=Module["_emscripten_bind_btCollisionObject_forceActivationState_1"]=asm["_emscripten_bind_btCollisionObject_forceActivationState_1"];var _emscripten_bind_btKinematicCharacterController_onGround_0=Module["_emscripten_bind_btKinematicCharacterController_onGround_0"]=asm["_emscripten_bind_btKinematicCharacterController_onGround_0"];var _emscripten_bind_btRaycastVehicle_getWheelInfo_1=Module["_emscripten_bind_btRaycastVehicle_getWheelInfo_1"]=asm["_emscripten_bind_btRaycastVehicle_getWheelInfo_1"];var _emscripten_bind_btGeneric6DofConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btGeneric6DofConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btGeneric6DofConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_btSoftBody_appendFace_4=Module["_emscripten_bind_btSoftBody_appendFace_4"]=asm["_emscripten_bind_btSoftBody_appendFace_4"];var _emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterMask_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterMask_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterMask_1"];var _emscripten_bind_btSoftBodyWorldInfo_get_water_normal_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_water_normal_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_water_normal_0"];var _emscripten_bind_btVector3_normalize_0=Module["_emscripten_bind_btVector3_normalize_0"]=asm["_emscripten_bind_btVector3_normalize_0"];var _emscripten_bind_btSoftBody_setFriction_1=Module["_emscripten_bind_btSoftBody_setFriction_1"]=asm["_emscripten_bind_btSoftBody_setFriction_1"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _emscripten_bind_btRigidBody_setSleepingThresholds_2=Module["_emscripten_bind_btRigidBody_setSleepingThresholds_2"]=asm["_emscripten_bind_btRigidBody_setSleepingThresholds_2"];var _emscripten_bind_btSoftBody_upcast_1=Module["_emscripten_bind_btSoftBody_upcast_1"]=asm["_emscripten_bind_btSoftBody_upcast_1"];var _emscripten_bind_btCollisionObject_setWorldTransform_1=Module["_emscripten_bind_btCollisionObject_setWorldTransform_1"]=asm["_emscripten_bind_btCollisionObject_setWorldTransform_1"];var _emscripten_bind_LocalConvexResult_get_m_localShapeInfo_0=Module["_emscripten_bind_LocalConvexResult_get_m_localShapeInfo_0"]=asm["_emscripten_bind_LocalConvexResult_get_m_localShapeInfo_0"];var _emscripten_bind_btSoftBodyWorldInfo_set_m_dispatcher_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_m_dispatcher_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_m_dispatcher_1"];var _emscripten_bind_btConvexHullShape_setLocalScaling_1=Module["_emscripten_bind_btConvexHullShape_setLocalScaling_1"]=asm["_emscripten_bind_btConvexHullShape_setLocalScaling_1"];var _emscripten_bind_btStridingMeshInterface___destroy___0=Module["_emscripten_bind_btStridingMeshInterface___destroy___0"]=asm["_emscripten_bind_btStridingMeshInterface___destroy___0"];var _emscripten_bind_btSoftBody_setActivationState_1=Module["_emscripten_bind_btSoftBody_setActivationState_1"]=asm["_emscripten_bind_btSoftBody_setActivationState_1"];var _emscripten_bind_btRigidBody_getUserIndex_0=Module["_emscripten_bind_btRigidBody_getUserIndex_0"]=asm["_emscripten_bind_btRigidBody_getUserIndex_0"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_linearDamping_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_linearDamping_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_linearDamping_0"];var _emscripten_bind_btSoftBodyHelpers_CreatePatch_9=Module["_emscripten_bind_btSoftBodyHelpers_CreatePatch_9"]=asm["_emscripten_bind_btSoftBodyHelpers_CreatePatch_9"];var _emscripten_bind_btDispatcher_getNumManifolds_0=Module["_emscripten_bind_btDispatcher_getNumManifolds_0"]=asm["_emscripten_bind_btDispatcher_getNumManifolds_0"];var _emscripten_bind_btConvexShape_setMargin_1=Module["_emscripten_bind_btConvexShape_setMargin_1"]=asm["_emscripten_bind_btConvexShape_setMargin_1"];var _emscripten_bind_btSoftBody_get_m_nodes_0=Module["_emscripten_bind_btSoftBody_get_m_nodes_0"]=asm["_emscripten_bind_btSoftBody_get_m_nodes_0"];var _emscripten_bind_btSoftBody___destroy___0=Module["_emscripten_bind_btSoftBody___destroy___0"]=asm["_emscripten_bind_btSoftBody___destroy___0"];var _emscripten_bind_btRigidBodyConstructionInfo_get_m_linearSleepingThreshold_0=Module["_emscripten_bind_btRigidBodyConstructionInfo_get_m_linearSleepingThreshold_0"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_get_m_linearSleepingThreshold_0"];var _emscripten_bind_btRigidBody_activate_1=Module["_emscripten_bind_btRigidBody_activate_1"]=asm["_emscripten_bind_btRigidBody_activate_1"];var _emscripten_bind_btRigidBody_activate_0=Module["_emscripten_bind_btRigidBody_activate_0"]=asm["_emscripten_bind_btRigidBody_activate_0"];var _emscripten_bind_btRaycastVehicle___destroy___0=Module["_emscripten_bind_btRaycastVehicle___destroy___0"]=asm["_emscripten_bind_btRaycastVehicle___destroy___0"];var _emscripten_bind_btSoftBodyWorldInfo_get_m_gravity_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_m_gravity_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_m_gravity_0"];var _emscripten_bind_Material_set_m_kVST_1=Module["_emscripten_bind_Material_set_m_kVST_1"]=asm["_emscripten_bind_Material_set_m_kVST_1"];var _emscripten_bind_btGhostObject_setActivationState_1=Module["_emscripten_bind_btGhostObject_setActivationState_1"]=asm["_emscripten_bind_btGhostObject_setActivationState_1"];var _emscripten_bind_Material_set_m_kLST_1=Module["_emscripten_bind_Material_set_m_kLST_1"]=asm["_emscripten_bind_Material_set_m_kLST_1"];var _emscripten_bind_btCollisionWorld_contactPairTest_3=Module["_emscripten_bind_btCollisionWorld_contactPairTest_3"]=asm["_emscripten_bind_btCollisionWorld_contactPairTest_3"];var _emscripten_bind_btDispatcherInfo_get_m_useContinuous_0=Module["_emscripten_bind_btDispatcherInfo_get_m_useContinuous_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_useContinuous_0"];var _emscripten_bind_btHingeConstraint_setMaxMotorImpulse_1=Module["_emscripten_bind_btHingeConstraint_setMaxMotorImpulse_1"]=asm["_emscripten_bind_btHingeConstraint_setMaxMotorImpulse_1"];var _emscripten_bind_Config_get_kSS_SPLT_CL_0=Module["_emscripten_bind_Config_get_kSS_SPLT_CL_0"]=asm["_emscripten_bind_Config_get_kSS_SPLT_CL_0"];var _emscripten_bind_btCylinderShapeX___destroy___0=Module["_emscripten_bind_btCylinderShapeX___destroy___0"]=asm["_emscripten_bind_btCylinderShapeX___destroy___0"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_linearSleepingThreshold_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_linearSleepingThreshold_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_linearSleepingThreshold_1"];var _emscripten_bind_btRigidBody_updateInertiaTensor_0=Module["_emscripten_bind_btRigidBody_updateInertiaTensor_0"]=asm["_emscripten_bind_btRigidBody_updateInertiaTensor_0"];var _emscripten_bind_ContactResultCallback___destroy___0=Module["_emscripten_bind_ContactResultCallback___destroy___0"]=asm["_emscripten_bind_ContactResultCallback___destroy___0"];var _emscripten_bind_btDispatcherInfo_get_m_useConvexConservativeDistanceUtil_0=Module["_emscripten_bind_btDispatcherInfo_get_m_useConvexConservativeDistanceUtil_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_useConvexConservativeDistanceUtil_0"];var _emscripten_bind_btSoftBody_setAnisotropicFriction_2=Module["_emscripten_bind_btSoftBody_setAnisotropicFriction_2"]=asm["_emscripten_bind_btSoftBody_setAnisotropicFriction_2"];var _emscripten_bind_btPairCachingGhostObject_setCollisionFlags_1=Module["_emscripten_bind_btPairCachingGhostObject_setCollisionFlags_1"]=asm["_emscripten_bind_btPairCachingGhostObject_setCollisionFlags_1"];var _emscripten_bind_btRigidBody_getMotionState_0=Module["_emscripten_bind_btRigidBody_getMotionState_0"]=asm["_emscripten_bind_btRigidBody_getMotionState_0"];var _emscripten_bind_btKinematicCharacterController_getGhostObject_0=Module["_emscripten_bind_btKinematicCharacterController_getGhostObject_0"]=asm["_emscripten_bind_btKinematicCharacterController_getGhostObject_0"];var _emscripten_bind_btRigidBody_btRigidBody_1=Module["_emscripten_bind_btRigidBody_btRigidBody_1"]=asm["_emscripten_bind_btRigidBody_btRigidBody_1"];var _emscripten_bind_btTriangleMeshShape___destroy___0=Module["_emscripten_bind_btTriangleMeshShape___destroy___0"]=asm["_emscripten_bind_btTriangleMeshShape___destroy___0"];var _emscripten_bind_btKinematicCharacterController_setWalkDirection_1=Module["_emscripten_bind_btKinematicCharacterController_setWalkDirection_1"]=asm["_emscripten_bind_btKinematicCharacterController_setWalkDirection_1"];var _emscripten_bind_btDynamicsWorld_removeAction_1=Module["_emscripten_bind_btDynamicsWorld_removeAction_1"]=asm["_emscripten_bind_btDynamicsWorld_removeAction_1"];var _emscripten_bind_btRigidBody_applyTorque_1=Module["_emscripten_bind_btRigidBody_applyTorque_1"]=asm["_emscripten_bind_btRigidBody_applyTorque_1"];var _emscripten_bind_btManifoldPoint_get_m_localPointA_0=Module["_emscripten_bind_btManifoldPoint_get_m_localPointA_0"]=asm["_emscripten_bind_btManifoldPoint_get_m_localPointA_0"];var _emscripten_bind_btDefaultCollisionConstructionInfo_btDefaultCollisionConstructionInfo_0=Module["_emscripten_bind_btDefaultCollisionConstructionInfo_btDefaultCollisionConstructionInfo_0"]=asm["_emscripten_bind_btDefaultCollisionConstructionInfo_btDefaultCollisionConstructionInfo_0"];var _emscripten_bind_btVehicleTuning_get_m_suspensionStiffness_0=Module["_emscripten_bind_btVehicleTuning_get_m_suspensionStiffness_0"]=asm["_emscripten_bind_btVehicleTuning_get_m_suspensionStiffness_0"];var _emscripten_bind_btManifoldPoint_set_m_normalWorldOnB_1=Module["_emscripten_bind_btManifoldPoint_set_m_normalWorldOnB_1"]=asm["_emscripten_bind_btManifoldPoint_set_m_normalWorldOnB_1"];var _emscripten_bind_btGhostObject_setUserPointer_1=Module["_emscripten_bind_btGhostObject_setUserPointer_1"]=asm["_emscripten_bind_btGhostObject_setUserPointer_1"];var _emscripten_bind_btKinematicCharacterController_getGravity_0=Module["_emscripten_bind_btKinematicCharacterController_getGravity_0"]=asm["_emscripten_bind_btKinematicCharacterController_getGravity_0"];var _emscripten_enum_PHY_ScalarType_PHY_SHORT=Module["_emscripten_enum_PHY_ScalarType_PHY_SHORT"]=asm["_emscripten_enum_PHY_ScalarType_PHY_SHORT"];var _emscripten_bind_btConeTwistConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btConeTwistConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btConeTwistConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_btGeneric6DofConstraint_setAngularLowerLimit_1=Module["_emscripten_bind_btGeneric6DofConstraint_setAngularLowerLimit_1"]=asm["_emscripten_bind_btGeneric6DofConstraint_setAngularLowerLimit_1"];var _emscripten_bind_btVector4_normalize_0=Module["_emscripten_bind_btVector4_normalize_0"]=asm["_emscripten_bind_btVector4_normalize_0"];var _emscripten_bind_btQuaternion_setY_1=Module["_emscripten_bind_btQuaternion_setY_1"]=asm["_emscripten_bind_btQuaternion_setY_1"];var _emscripten_bind_btConeShape_calculateLocalInertia_2=Module["_emscripten_bind_btConeShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btConeShape_calculateLocalInertia_2"];var _emscripten_bind_btCylinderShapeX_calculateLocalInertia_2=Module["_emscripten_bind_btCylinderShapeX_calculateLocalInertia_2"]=asm["_emscripten_bind_btCylinderShapeX_calculateLocalInertia_2"];var _emscripten_bind_ConvexResultCallback_set_m_collisionFilterMask_1=Module["_emscripten_bind_ConvexResultCallback_set_m_collisionFilterMask_1"]=asm["_emscripten_bind_ConvexResultCallback_set_m_collisionFilterMask_1"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _emscripten_bind_btKinematicCharacterController_setVelocityForTimeInterval_2=Module["_emscripten_bind_btKinematicCharacterController_setVelocityForTimeInterval_2"]=asm["_emscripten_bind_btKinematicCharacterController_setVelocityForTimeInterval_2"];var _emscripten_bind_btSphereShape_setLocalScaling_1=Module["_emscripten_bind_btSphereShape_setLocalScaling_1"]=asm["_emscripten_bind_btSphereShape_setLocalScaling_1"];var _emscripten_bind_btRigidBody_applyCentralLocalForce_1=Module["_emscripten_bind_btRigidBody_applyCentralLocalForce_1"]=asm["_emscripten_bind_btRigidBody_applyCentralLocalForce_1"];var _emscripten_bind_btVector4_w_0=Module["_emscripten_bind_btVector4_w_0"]=asm["_emscripten_bind_btVector4_w_0"];var _emscripten_bind_btManifoldPoint_get_m_normalWorldOnB_0=Module["_emscripten_bind_btManifoldPoint_get_m_normalWorldOnB_0"]=asm["_emscripten_bind_btManifoldPoint_get_m_normalWorldOnB_0"];var _emscripten_bind_btBvhTriangleMeshShape___destroy___0=Module["_emscripten_bind_btBvhTriangleMeshShape___destroy___0"]=asm["_emscripten_bind_btBvhTriangleMeshShape___destroy___0"];var _emscripten_bind_Config_set_citerations_1=Module["_emscripten_bind_Config_set_citerations_1"]=asm["_emscripten_bind_Config_set_citerations_1"];var _emscripten_bind_btSoftBody_checkFace_3=Module["_emscripten_bind_btSoftBody_checkFace_3"]=asm["_emscripten_bind_btSoftBody_checkFace_3"];var _emscripten_bind_Config_get_kSKHR_CL_0=Module["_emscripten_bind_Config_get_kSKHR_CL_0"]=asm["_emscripten_bind_Config_get_kSKHR_CL_0"];var _emscripten_bind_btDispatcherInfo_get_m_enableSatConvex_0=Module["_emscripten_bind_btDispatcherInfo_get_m_enableSatConvex_0"]=asm["_emscripten_bind_btDispatcherInfo_get_m_enableSatConvex_0"];var _emscripten_bind_LocalConvexResult_LocalConvexResult_5=Module["_emscripten_bind_LocalConvexResult_LocalConvexResult_5"]=asm["_emscripten_bind_LocalConvexResult_LocalConvexResult_5"];var _emscripten_bind_ClosestConvexResultCallback_set_m_closestHitFraction_1=Module["_emscripten_bind_ClosestConvexResultCallback_set_m_closestHitFraction_1"]=asm["_emscripten_bind_ClosestConvexResultCallback_set_m_closestHitFraction_1"];var _emscripten_bind_btDiscreteDynamicsWorld_removeConstraint_1=Module["_emscripten_bind_btDiscreteDynamicsWorld_removeConstraint_1"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_removeConstraint_1"];var _emscripten_bind_ConcreteContactResultCallback_ConcreteContactResultCallback_0=Module["_emscripten_bind_ConcreteContactResultCallback_ConcreteContactResultCallback_0"]=asm["_emscripten_bind_ConcreteContactResultCallback_ConcreteContactResultCallback_0"];var _emscripten_bind_Config_set_diterations_1=Module["_emscripten_bind_Config_set_diterations_1"]=asm["_emscripten_bind_Config_set_diterations_1"];var _emscripten_bind_btGeneric6DofConstraint___destroy___0=Module["_emscripten_bind_btGeneric6DofConstraint___destroy___0"]=asm["_emscripten_bind_btGeneric6DofConstraint___destroy___0"];var _emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_3=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_3"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_3"];var _emscripten_bind_Config_set_kDP_1=Module["_emscripten_bind_Config_set_kDP_1"]=asm["_emscripten_bind_Config_set_kDP_1"];var _emscripten_bind_btVehicleTuning_get_m_maxSuspensionTravelCm_0=Module["_emscripten_bind_btVehicleTuning_get_m_maxSuspensionTravelCm_0"]=asm["_emscripten_bind_btVehicleTuning_get_m_maxSuspensionTravelCm_0"];var _emscripten_bind_btConvexHullShape_addPoint_1=Module["_emscripten_bind_btConvexHullShape_addPoint_1"]=asm["_emscripten_bind_btConvexHullShape_addPoint_1"];var _emscripten_bind_btConvexHullShape_addPoint_2=Module["_emscripten_bind_btConvexHullShape_addPoint_2"]=asm["_emscripten_bind_btConvexHullShape_addPoint_2"];var _emscripten_bind_btPoint2PointConstraint_getBreakingImpulseThreshold_0=Module["_emscripten_bind_btPoint2PointConstraint_getBreakingImpulseThreshold_0"]=asm["_emscripten_bind_btPoint2PointConstraint_getBreakingImpulseThreshold_0"];var _emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_1=Module["_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_1"]=asm["_emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_1"];var _emscripten_bind_btTransform_getOrigin_0=Module["_emscripten_bind_btTransform_getOrigin_0"]=asm["_emscripten_bind_btTransform_getOrigin_0"];var _emscripten_bind_Config_get_kKHR_0=Module["_emscripten_bind_Config_get_kKHR_0"]=asm["_emscripten_bind_Config_get_kKHR_0"];var _emscripten_bind_Material_get_m_kLST_0=Module["_emscripten_bind_Material_get_m_kLST_0"]=asm["_emscripten_bind_Material_get_m_kLST_0"];var _emscripten_bind_btHingeConstraint___destroy___0=Module["_emscripten_bind_btHingeConstraint___destroy___0"]=asm["_emscripten_bind_btHingeConstraint___destroy___0"];var _emscripten_bind_btPairCachingGhostObject_getUserPointer_0=Module["_emscripten_bind_btPairCachingGhostObject_getUserPointer_0"]=asm["_emscripten_bind_btPairCachingGhostObject_getUserPointer_0"];var _emscripten_bind_btSoftBody_set_m_nodes_1=Module["_emscripten_bind_btSoftBody_set_m_nodes_1"]=asm["_emscripten_bind_btSoftBody_set_m_nodes_1"];var _emscripten_bind_btSoftBodyWorldInfo_set_air_density_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_air_density_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_air_density_1"];var _emscripten_bind_btDbvtBroadphase___destroy___0=Module["_emscripten_bind_btDbvtBroadphase___destroy___0"]=asm["_emscripten_bind_btDbvtBroadphase___destroy___0"];var _emscripten_bind_Config_set_viterations_1=Module["_emscripten_bind_Config_set_viterations_1"]=asm["_emscripten_bind_Config_set_viterations_1"];var _emscripten_bind_btConvexShape_calculateLocalInertia_2=Module["_emscripten_bind_btConvexShape_calculateLocalInertia_2"]=asm["_emscripten_bind_btConvexShape_calculateLocalInertia_2"];var _memset=Module["_memset"]=asm["_memset"];var _emscripten_bind_btGeneric6DofConstraint_setLinearLowerLimit_1=Module["_emscripten_bind_btGeneric6DofConstraint_setLinearLowerLimit_1"]=asm["_emscripten_bind_btGeneric6DofConstraint_setLinearLowerLimit_1"];var _emscripten_bind_ClosestRayResultCallback_get_m_hitNormalWorld_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_hitNormalWorld_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_hitNormalWorld_0"];var _emscripten_bind_btTriangleMesh_btTriangleMesh_0=Module["_emscripten_bind_btTriangleMesh_btTriangleMesh_0"]=asm["_emscripten_bind_btTriangleMesh_btTriangleMesh_0"];var _emscripten_bind_btTriangleMesh_btTriangleMesh_1=Module["_emscripten_bind_btTriangleMesh_btTriangleMesh_1"]=asm["_emscripten_bind_btTriangleMesh_btTriangleMesh_1"];var _emscripten_bind_btTriangleMesh_btTriangleMesh_2=Module["_emscripten_bind_btTriangleMesh_btTriangleMesh_2"]=asm["_emscripten_bind_btTriangleMesh_btTriangleMesh_2"];var _emscripten_bind_btWheelInfo_set_m_frictionSlip_1=Module["_emscripten_bind_btWheelInfo_set_m_frictionSlip_1"]=asm["_emscripten_bind_btWheelInfo_set_m_frictionSlip_1"];var _emscripten_bind_btSoftBodyHelpers___destroy___0=Module["_emscripten_bind_btSoftBodyHelpers___destroy___0"]=asm["_emscripten_bind_btSoftBodyHelpers___destroy___0"];var _emscripten_bind_btRigidBody_getCollisionShape_0=Module["_emscripten_bind_btRigidBody_getCollisionShape_0"]=asm["_emscripten_bind_btRigidBody_getCollisionShape_0"];var _emscripten_bind_btManifoldPoint_set_m_positionWorldOnA_1=Module["_emscripten_bind_btManifoldPoint_set_m_positionWorldOnA_1"]=asm["_emscripten_bind_btManifoldPoint_set_m_positionWorldOnA_1"];var _emscripten_bind_btWheelInfo_get_m_wheelsDampingRelaxation_0=Module["_emscripten_bind_btWheelInfo_get_m_wheelsDampingRelaxation_0"]=asm["_emscripten_bind_btWheelInfo_get_m_wheelsDampingRelaxation_0"];var _emscripten_bind_btManifoldPoint_get_m_localPointB_0=Module["_emscripten_bind_btManifoldPoint_get_m_localPointB_0"]=asm["_emscripten_bind_btManifoldPoint_get_m_localPointB_0"];var _emscripten_bind_btDiscreteDynamicsWorld_contactPairTest_3=Module["_emscripten_bind_btDiscreteDynamicsWorld_contactPairTest_3"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_contactPairTest_3"];var _emscripten_bind_btSliderConstraint_setLowerLinLimit_1=Module["_emscripten_bind_btSliderConstraint_setLowerLinLimit_1"]=asm["_emscripten_bind_btSliderConstraint_setLowerLinLimit_1"];var _emscripten_bind_btRigidBody_getAngularVelocity_0=Module["_emscripten_bind_btRigidBody_getAngularVelocity_0"]=asm["_emscripten_bind_btRigidBody_getAngularVelocity_0"];var _emscripten_bind_btCollisionObject_setCcdSweptSphereRadius_1=Module["_emscripten_bind_btCollisionObject_setCcdSweptSphereRadius_1"]=asm["_emscripten_bind_btCollisionObject_setCcdSweptSphereRadius_1"];var _emscripten_bind_btWheelInfo_get_m_wheelsRadius_0=Module["_emscripten_bind_btWheelInfo_get_m_wheelsRadius_0"]=asm["_emscripten_bind_btWheelInfo_get_m_wheelsRadius_0"];var _emscripten_bind_btRigidBody_setLinearVelocity_1=Module["_emscripten_bind_btRigidBody_setLinearVelocity_1"]=asm["_emscripten_bind_btRigidBody_setLinearVelocity_1"];var _emscripten_bind_btVehicleTuning_btVehicleTuning_0=Module["_emscripten_bind_btVehicleTuning_btVehicleTuning_0"]=asm["_emscripten_bind_btVehicleTuning_btVehicleTuning_0"];var _emscripten_bind_RayResultCallback_set_m_collisionObject_1=Module["_emscripten_bind_RayResultCallback_set_m_collisionObject_1"]=asm["_emscripten_bind_RayResultCallback_set_m_collisionObject_1"];var _emscripten_bind_btDefaultSoftBodySolver___destroy___0=Module["_emscripten_bind_btDefaultSoftBodySolver___destroy___0"]=asm["_emscripten_bind_btDefaultSoftBodySolver___destroy___0"];var _emscripten_bind_ClosestRayResultCallback_set_m_rayToWorld_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_rayToWorld_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_rayToWorld_1"];var _emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterGroup_0=Module["_emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterGroup_0"]=asm["_emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterGroup_0"];var _emscripten_bind_btWheelInfo_set_m_wheelsDampingRelaxation_1=Module["_emscripten_bind_btWheelInfo_set_m_wheelsDampingRelaxation_1"]=asm["_emscripten_bind_btWheelInfo_set_m_wheelsDampingRelaxation_1"];var _emscripten_bind_btDynamicsWorld_addAction_1=Module["_emscripten_bind_btDynamicsWorld_addAction_1"]=asm["_emscripten_bind_btDynamicsWorld_addAction_1"];var _emscripten_bind_btSoftBody_appendMaterial_0=Module["_emscripten_bind_btSoftBody_appendMaterial_0"]=asm["_emscripten_bind_btSoftBody_appendMaterial_0"];var _emscripten_bind_btSoftBodyWorldInfo_set_m_maxDisplacement_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_m_maxDisplacement_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_m_maxDisplacement_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_2=Module["_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_2"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_2"];var _emscripten_bind_btPairCachingGhostObject_getCollisionFlags_0=Module["_emscripten_bind_btPairCachingGhostObject_getCollisionFlags_0"]=asm["_emscripten_bind_btPairCachingGhostObject_getCollisionFlags_0"];var _emscripten_bind_btSoftBodyWorldInfo_get_air_density_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_air_density_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_air_density_0"];var _emscripten_bind_btSoftBody_setRestitution_1=Module["_emscripten_bind_btSoftBody_setRestitution_1"]=asm["_emscripten_bind_btSoftBody_setRestitution_1"];var _emscripten_bind_Config_set_kLF_1=Module["_emscripten_bind_Config_set_kLF_1"]=asm["_emscripten_bind_Config_set_kLF_1"];var _emscripten_enum_PHY_ScalarType_PHY_FLOAT=Module["_emscripten_enum_PHY_ScalarType_PHY_FLOAT"]=asm["_emscripten_enum_PHY_ScalarType_PHY_FLOAT"];var _emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDamping_1=Module["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDamping_1"]=asm["_emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDamping_1"];var _emscripten_bind_Config_set_kSS_SPLT_CL_1=Module["_emscripten_bind_Config_set_kSS_SPLT_CL_1"]=asm["_emscripten_bind_Config_set_kSS_SPLT_CL_1"];var _emscripten_bind_btGhostObject_isActive_0=Module["_emscripten_bind_btGhostObject_isActive_0"]=asm["_emscripten_bind_btGhostObject_isActive_0"];var _emscripten_bind_btKinematicCharacterController_setFallSpeed_1=Module["_emscripten_bind_btKinematicCharacterController_setFallSpeed_1"]=asm["_emscripten_bind_btKinematicCharacterController_setFallSpeed_1"];var _emscripten_bind_btRigidBody_setActivationState_1=Module["_emscripten_bind_btRigidBody_setActivationState_1"]=asm["_emscripten_bind_btRigidBody_setActivationState_1"];var _emscripten_bind_btWheelInfo_get_m_wheelsDampingCompression_0=Module["_emscripten_bind_btWheelInfo_get_m_wheelsDampingCompression_0"]=asm["_emscripten_bind_btWheelInfo_get_m_wheelsDampingCompression_0"];var _emscripten_bind_ClosestConvexResultCallback_hasHit_0=Module["_emscripten_bind_ClosestConvexResultCallback_hasHit_0"]=asm["_emscripten_bind_ClosestConvexResultCallback_hasHit_0"];var _emscripten_bind_btCapsuleShapeZ___destroy___0=Module["_emscripten_bind_btCapsuleShapeZ___destroy___0"]=asm["_emscripten_bind_btCapsuleShapeZ___destroy___0"];var _emscripten_bind_btRaycastVehicle_getRigidBody_0=Module["_emscripten_bind_btRaycastVehicle_getRigidBody_0"]=asm["_emscripten_bind_btRaycastVehicle_getRigidBody_0"];var _emscripten_bind_btWheelInfo_get_m_maxSuspensionForce_0=Module["_emscripten_bind_btWheelInfo_get_m_maxSuspensionForce_0"]=asm["_emscripten_bind_btWheelInfo_get_m_maxSuspensionForce_0"];var _emscripten_bind_btSoftBody_get_m_materials_0=Module["_emscripten_bind_btSoftBody_get_m_materials_0"]=asm["_emscripten_bind_btSoftBody_get_m_materials_0"];var _emscripten_bind_btTriangleMesh_addTriangle_3=Module["_emscripten_bind_btTriangleMesh_addTriangle_3"]=asm["_emscripten_bind_btTriangleMesh_addTriangle_3"];var _emscripten_bind_btGhostObject_getOverlappingObject_1=Module["_emscripten_bind_btGhostObject_getOverlappingObject_1"]=asm["_emscripten_bind_btGhostObject_getOverlappingObject_1"];var _emscripten_bind_btTriangleMesh_addTriangle_4=Module["_emscripten_bind_btTriangleMesh_addTriangle_4"]=asm["_emscripten_bind_btTriangleMesh_addTriangle_4"];var _emscripten_bind_btSoftRigidDynamicsWorld_getDispatchInfo_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getDispatchInfo_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getDispatchInfo_0"];var _emscripten_bind_btSoftBodyWorldInfo_set_water_normal_1=Module["_emscripten_bind_btSoftBodyWorldInfo_set_water_normal_1"]=asm["_emscripten_bind_btSoftBodyWorldInfo_set_water_normal_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_2=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_2"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_2"];var _emscripten_bind_Config_get_kDF_0=Module["_emscripten_bind_Config_get_kDF_0"]=asm["_emscripten_bind_Config_get_kDF_0"];var _emscripten_bind_btRigidBody_applyTorqueImpulse_1=Module["_emscripten_bind_btRigidBody_applyTorqueImpulse_1"]=asm["_emscripten_bind_btRigidBody_applyTorqueImpulse_1"];var _emscripten_bind_btRigidBody_setCollisionFlags_1=Module["_emscripten_bind_btRigidBody_setCollisionFlags_1"]=asm["_emscripten_bind_btRigidBody_setCollisionFlags_1"];var _emscripten_bind_btWheelInfo_get_m_steering_0=Module["_emscripten_bind_btWheelInfo_get_m_steering_0"]=asm["_emscripten_bind_btWheelInfo_get_m_steering_0"];var _emscripten_bind_btRigidBody___destroy___0=Module["_emscripten_bind_btRigidBody___destroy___0"]=asm["_emscripten_bind_btRigidBody___destroy___0"];var _emscripten_bind_btWheelInfo_set_m_suspensionRestLength1_1=Module["_emscripten_bind_btWheelInfo_set_m_suspensionRestLength1_1"]=asm["_emscripten_bind_btWheelInfo_set_m_suspensionRestLength1_1"];var _emscripten_bind_Config_set_kCHR_1=Module["_emscripten_bind_Config_set_kCHR_1"]=asm["_emscripten_bind_Config_set_kCHR_1"];var _emscripten_bind_btSoftRigidDynamicsWorld_contactTest_2=Module["_emscripten_bind_btSoftRigidDynamicsWorld_contactTest_2"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_contactTest_2"];var _emscripten_bind_btCapsuleShapeZ_btCapsuleShapeZ_2=Module["_emscripten_bind_btCapsuleShapeZ_btCapsuleShapeZ_2"]=asm["_emscripten_bind_btCapsuleShapeZ_btCapsuleShapeZ_2"];var _emscripten_bind_btSoftRigidDynamicsWorld_addSoftBody_3=Module["_emscripten_bind_btSoftRigidDynamicsWorld_addSoftBody_3"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_addSoftBody_3"];var _emscripten_bind_btSoftRigidDynamicsWorld_getWorldInfo_0=Module["_emscripten_bind_btSoftRigidDynamicsWorld_getWorldInfo_0"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_getWorldInfo_0"];var _emscripten_bind_btSliderConstraint_btSliderConstraint_3=Module["_emscripten_bind_btSliderConstraint_btSliderConstraint_3"]=asm["_emscripten_bind_btSliderConstraint_btSliderConstraint_3"];var _emscripten_bind_btTransform___destroy___0=Module["_emscripten_bind_btTransform___destroy___0"]=asm["_emscripten_bind_btTransform___destroy___0"];var _emscripten_bind_btDynamicsWorld_convexSweepTest_5=Module["_emscripten_bind_btDynamicsWorld_convexSweepTest_5"]=asm["_emscripten_bind_btDynamicsWorld_convexSweepTest_5"];var _emscripten_bind_btSliderConstraint___destroy___0=Module["_emscripten_bind_btSliderConstraint___destroy___0"]=asm["_emscripten_bind_btSliderConstraint___destroy___0"];var _emscripten_bind_btRigidBody_forceActivationState_1=Module["_emscripten_bind_btRigidBody_forceActivationState_1"]=asm["_emscripten_bind_btRigidBody_forceActivationState_1"];var _emscripten_bind_btPoint2PointConstraint_setPivotB_1=Module["_emscripten_bind_btPoint2PointConstraint_setPivotB_1"]=asm["_emscripten_bind_btPoint2PointConstraint_setPivotB_1"];var _emscripten_bind_btManifoldPoint_getDistance_0=Module["_emscripten_bind_btManifoldPoint_getDistance_0"]=asm["_emscripten_bind_btManifoldPoint_getDistance_0"];var _emscripten_bind_btGhostPairCallback___destroy___0=Module["_emscripten_bind_btGhostPairCallback___destroy___0"]=asm["_emscripten_bind_btGhostPairCallback___destroy___0"];var _emscripten_bind_btTransform_setFromOpenGLMatrix_1=Module["_emscripten_bind_btTransform_setFromOpenGLMatrix_1"]=asm["_emscripten_bind_btTransform_setFromOpenGLMatrix_1"];var _emscripten_bind_btKinematicCharacterController_getMaxSlope_0=Module["_emscripten_bind_btKinematicCharacterController_getMaxSlope_0"]=asm["_emscripten_bind_btKinematicCharacterController_getMaxSlope_0"];var _emscripten_bind_btManifoldPoint_getPositionWorldOnA_0=Module["_emscripten_bind_btManifoldPoint_getPositionWorldOnA_0"]=asm["_emscripten_bind_btManifoldPoint_getPositionWorldOnA_0"];var _emscripten_bind_btRaycastVehicle_addWheel_7=Module["_emscripten_bind_btRaycastVehicle_addWheel_7"]=asm["_emscripten_bind_btRaycastVehicle_addWheel_7"];var _emscripten_bind_ClosestRayResultCallback_set_m_hitNormalWorld_1=Module["_emscripten_bind_ClosestRayResultCallback_set_m_hitNormalWorld_1"]=asm["_emscripten_bind_ClosestRayResultCallback_set_m_hitNormalWorld_1"];var _emscripten_bind_LocalConvexResult_set_m_localShapeInfo_1=Module["_emscripten_bind_LocalConvexResult_set_m_localShapeInfo_1"]=asm["_emscripten_bind_LocalConvexResult_set_m_localShapeInfo_1"];var _emscripten_bind_btStaticPlaneShape___destroy___0=Module["_emscripten_bind_btStaticPlaneShape___destroy___0"]=asm["_emscripten_bind_btStaticPlaneShape___destroy___0"];var _emscripten_bind_btHingeConstraint_enableMotor_1=Module["_emscripten_bind_btHingeConstraint_enableMotor_1"]=asm["_emscripten_bind_btHingeConstraint_enableMotor_1"];var _emscripten_bind_btCylinderShapeZ_setLocalScaling_1=Module["_emscripten_bind_btCylinderShapeZ_setLocalScaling_1"]=asm["_emscripten_bind_btCylinderShapeZ_setLocalScaling_1"];var _emscripten_bind_btBoxShape_setLocalScaling_1=Module["_emscripten_bind_btBoxShape_setLocalScaling_1"]=asm["_emscripten_bind_btBoxShape_setLocalScaling_1"];var _emscripten_bind_btConeShapeZ___destroy___0=Module["_emscripten_bind_btConeShapeZ___destroy___0"]=asm["_emscripten_bind_btConeShapeZ___destroy___0"];var _emscripten_bind_btDynamicsWorld_getPairCache_0=Module["_emscripten_bind_btDynamicsWorld_getPairCache_0"]=asm["_emscripten_bind_btDynamicsWorld_getPairCache_0"];var _emscripten_bind_btSoftRigidDynamicsWorld_convexSweepTest_5=Module["_emscripten_bind_btSoftRigidDynamicsWorld_convexSweepTest_5"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_convexSweepTest_5"];var _emscripten_bind_btDiscreteDynamicsWorld_convexSweepTest_5=Module["_emscripten_bind_btDiscreteDynamicsWorld_convexSweepTest_5"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_convexSweepTest_5"];var _emscripten_bind_btSoftRigidDynamicsWorld_removeRigidBody_1=Module["_emscripten_bind_btSoftRigidDynamicsWorld_removeRigidBody_1"]=asm["_emscripten_bind_btSoftRigidDynamicsWorld_removeRigidBody_1"];var _emscripten_bind_btRigidBody_setRestitution_1=Module["_emscripten_bind_btRigidBody_setRestitution_1"]=asm["_emscripten_bind_btRigidBody_setRestitution_1"];var _emscripten_bind_btVector4_btVector4_0=Module["_emscripten_bind_btVector4_btVector4_0"]=asm["_emscripten_bind_btVector4_btVector4_0"];var _emscripten_bind_btVector4_x_0=Module["_emscripten_bind_btVector4_x_0"]=asm["_emscripten_bind_btVector4_x_0"];var _emscripten_bind_btVector4_btVector4_4=Module["_emscripten_bind_btVector4_btVector4_4"]=asm["_emscripten_bind_btVector4_btVector4_4"];var _emscripten_bind_btKinematicCharacterController___destroy___0=Module["_emscripten_bind_btKinematicCharacterController___destroy___0"]=asm["_emscripten_bind_btKinematicCharacterController___destroy___0"];var _emscripten_bind_btGeneric6DofSpringConstraint_setLinearLowerLimit_1=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setLinearLowerLimit_1"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setLinearLowerLimit_1"];var _emscripten_bind_tMaterialArray_at_1=Module["_emscripten_bind_tMaterialArray_at_1"]=asm["_emscripten_bind_tMaterialArray_at_1"];var _emscripten_bind_LocalConvexResult_set_m_hitCollisionObject_1=Module["_emscripten_bind_LocalConvexResult_set_m_hitCollisionObject_1"]=asm["_emscripten_bind_LocalConvexResult_set_m_hitCollisionObject_1"];var _emscripten_bind_btVector4_op_sub_1=Module["_emscripten_bind_btVector4_op_sub_1"]=asm["_emscripten_bind_btVector4_op_sub_1"];var _emscripten_bind_btGeneric6DofSpringConstraint_setAngularLowerLimit_1=Module["_emscripten_bind_btGeneric6DofSpringConstraint_setAngularLowerLimit_1"]=asm["_emscripten_bind_btGeneric6DofSpringConstraint_setAngularLowerLimit_1"];var _emscripten_bind_btSoftBodyWorldInfo_get_water_offset_0=Module["_emscripten_bind_btSoftBodyWorldInfo_get_water_offset_0"]=asm["_emscripten_bind_btSoftBodyWorldInfo_get_water_offset_0"];var _emscripten_bind_btDiscreteDynamicsWorld_rayTest_3=Module["_emscripten_bind_btDiscreteDynamicsWorld_rayTest_3"]=asm["_emscripten_bind_btDiscreteDynamicsWorld_rayTest_3"];var _emscripten_bind_btWheelInfo_get_m_raycastInfo_0=Module["_emscripten_bind_btWheelInfo_get_m_raycastInfo_0"]=asm["_emscripten_bind_btWheelInfo_get_m_raycastInfo_0"];var _emscripten_bind_btContactSolverInfo_get_m_splitImpulse_0=Module["_emscripten_bind_btContactSolverInfo_get_m_splitImpulse_0"]=asm["_emscripten_bind_btContactSolverInfo_get_m_splitImpulse_0"];var _emscripten_bind_btConvexShape_getMargin_0=Module["_emscripten_bind_btConvexShape_getMargin_0"]=asm["_emscripten_bind_btConvexShape_getMargin_0"];var _emscripten_bind_btGhostPairCallback_btGhostPairCallback_0=Module["_emscripten_bind_btGhostPairCallback_btGhostPairCallback_0"]=asm["_emscripten_bind_btGhostPairCallback_btGhostPairCallback_0"];var _emscripten_bind_btKinematicCharacterController_setMaxJumpHeight_1=Module["_emscripten_bind_btKinematicCharacterController_setMaxJumpHeight_1"]=asm["_emscripten_bind_btKinematicCharacterController_setMaxJumpHeight_1"];var _emscripten_bind_btPairCachingGhostObject_isActive_0=Module["_emscripten_bind_btPairCachingGhostObject_isActive_0"]=asm["_emscripten_bind_btPairCachingGhostObject_isActive_0"];var _emscripten_bind_btVehicleTuning_get_m_frictionSlip_0=Module["_emscripten_bind_btVehicleTuning_get_m_frictionSlip_0"]=asm["_emscripten_bind_btVehicleTuning_get_m_frictionSlip_0"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_vid=Module["dynCall_vid"]=asm["dynCall_vid"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_viiidii=Module["dynCall_viiidii"]=asm["dynCall_viiidii"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_iiiiiiiiiii=Module["dynCall_iiiiiiiiiii"]=asm["dynCall_iiiiiiiiiii"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_viidi=Module["dynCall_viidi"]=asm["dynCall_viidi"];var dynCall_viddiii=Module["dynCall_viddiii"]=asm["dynCall_viddiii"];var dynCall_vidii=Module["dynCall_vidii"]=asm["dynCall_vidii"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_vidi=Module["dynCall_vidi"]=asm["dynCall_vidi"];var dynCall_diiiiiiii=Module["dynCall_diiiiiiii"]=asm["dynCall_diiiiiiii"];var dynCall_viiiiddddiid=Module["dynCall_viiiiddddiid"]=asm["dynCall_viiiiddddiid"];var dynCall_diiiii=Module["dynCall_diiiii"]=asm["dynCall_diiiii"];var dynCall_vidd=Module["dynCall_vidd"]=asm["dynCall_vidd"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_viiiiid=Module["dynCall_viiiiid"]=asm["dynCall_viiiiid"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];var dynCall_iiid=Module["dynCall_iiid"]=asm["dynCall_iiid"];var dynCall_di=Module["dynCall_di"]=asm["dynCall_di"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_diiidii=Module["dynCall_diiidii"]=asm["dynCall_diiidii"];var dynCall_viidii=Module["dynCall_viidii"]=asm["dynCall_viidii"];var dynCall_viiiiiii=Module["dynCall_viiiiiii"]=asm["dynCall_viiiiiii"];var dynCall_viiiiiiiii=Module["dynCall_viiiiiiiii"]=asm["dynCall_viiiiiiiii"];var dynCall_viiiiiiiiii=Module["dynCall_viiiiiiiiii"]=asm["dynCall_viiiiiiiiii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_diii=Module["dynCall_diii"]=asm["dynCall_diii"];var dynCall_diiiiiiiiii=Module["dynCall_diiiiiiiiii"]=asm["dynCall_diiiiiiiiii"];var dynCall_viiiid=Module["dynCall_viiiid"]=asm["dynCall_viiiid"];var dynCall_diiiiiiiii=Module["dynCall_diiiiiiiii"]=asm["dynCall_diiiiiiiii"];var dynCall_did=Module["dynCall_did"]=asm["dynCall_did"];var dynCall_viiiidddddidi=Module["dynCall_viiiidddddidi"]=asm["dynCall_viiiidddddidi"];var dynCall_diidii=Module["dynCall_diidii"]=asm["dynCall_diidii"];var dynCall_diiii=Module["dynCall_diiii"]=asm["dynCall_diiii"];var dynCall_iiiiiiiiii=Module["dynCall_iiiiiiiiii"]=asm["dynCall_iiiiiiiiii"];var dynCall_viiid=Module["dynCall_viiid"]=asm["dynCall_viiid"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_viid=Module["dynCall_viid"]=asm["dynCall_viid"];var dynCall_iidid=Module["dynCall_iidid"]=asm["dynCall_iidid"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}else if(ENVIRONMENT_IS_SHELL&&typeof quit==="function"){quit(status)}throw new ExitStatus(status)}Module["exit"]=Module.exit=exit;var abortDecorators=[];function abort(what){if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach((function(decorator){output=decorator(output,what)}))}throw output}Module["abort"]=Module.abort=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"]){shouldRunNow=false}Module["noExitRuntime"]=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:(function(){if(this.needed){for(var i=0;i=this.size){assert(len>0);this.needed+=len;ret=Module["_malloc"](len);this.temps.push(ret)}else{ret=this.buffer+this.pos;this.pos+=len}var retShifted=ret;switch(bytes){case 2:retShifted>>=1;break;case 4:retShifted>>=2;break;case 8:retShifted>>=3;break}for(var i=0;i1?l["default"].toArray(arguments):arguments[0];return l["default"].each(s,function(t){if(t.litmus(e))return l["default"].each(t.conversions,function(t,n){if(u=t.read(e),d===!1&&u!==!1)return d=u,u.conversionName=n,u.conversion=t,l["default"].BREAK}),l["default"].BREAK}),d};t["default"]=c},function(e,t){"use strict";t.__esModule=!0,t["default"]=function(e,t){var n=e.__state.conversionName.toString(),o=Math.round(e.r),i=Math.round(e.g),r=Math.round(e.b),a=e.a,l=Math.round(e.h),s=e.s.toFixed(1),u=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var d=e.hex.toString(16);d.length<6;)d="0"+d;return"#"+d}return"CSS_RGB"===n?"rgb("+o+","+i+","+r+")":"CSS_RGBA"===n?"rgba("+o+","+i+","+r+","+a+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+o+","+i+","+r+"]":"RGBA_ARRAY"===n?"["+o+","+i+","+r+","+a+"]":"RGB_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+"}":"RGBA_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+",a:"+a+"}":"HSV_OBJ"===n?"{h:"+l+",s:"+s+",v:"+u+"}":"HSVA_OBJ"===n?"{h:"+l+",s:"+s+",v:"+u+",a:"+a+"}":"unknown format"}},function(e,t){"use strict";t.__esModule=!0;var n=Array.prototype.forEach,o=Array.prototype.slice,i={BREAK:{},extend:function(e){return this.each(o.call(arguments,1),function(t){var n=this.isObject(t)?Object.keys(t):[];n.forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))},this),e},defaults:function(e){return this.each(o.call(arguments,1),function(t){var n=this.isObject(t)?Object.keys(t):[];n.forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))},this),e},compose:function(){var e=o.call(arguments);return function(){for(var t=o.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,o){if(e)if(n&&e.forEach&&e.forEach===n)e.forEach(t,o);else if(e.length===e.length+0){var i=void 0,r=void 0;for(i=0,r=e.length;i>8*t&255},hex_with_component:function(e,t,o){return o<<(n=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}t.__esModule=!0;var s=n(7),u=o(s),d=n(5),c=o(d),f=function(e){function t(n,o,a){i(this,t);var s=r(this,e.call(this,n,o)),u=a||{};return s.__min=u.min,s.__max=u.max,s.__step=u.step,c["default"].isUndefined(s.__step)?0===s.initialValue?s.__impliedStep=1:s.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(s.initialValue))/Math.LN10))/10:s.__impliedStep=s.__step,s.__precision=l(s.__impliedStep),s}return a(t,e),t.prototype.setValue=function(t){var n=t;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!==0&&(n=Math.round(n/this.__step)*this.__step),e.prototype.setValue.call(this,n)},t.prototype.min=function(e){return this.__min=e,this},t.prototype.max=function(e){return this.__max=e,this},t.prototype.step=function(e){return this.__step=e,this.__impliedStep=e,this.__precision=l(e),this},t}(u["default"]);t["default"]=f},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}t.__esModule=!0;var s=n(12),u=o(s),d=n(9),c=o(d),f=n(5),_=o(f),p=function(e){function t(n,o,a){function l(){var e=parseFloat(m.__input.value);_["default"].isNaN(e)||m.setValue(e)}function s(){m.__onFinishChange&&m.__onFinishChange.call(m,m.getValue())}function u(){s()}function d(e){var t=b-e.clientY;m.setValue(m.getValue()+t*m.__impliedStep),b=e.clientY}function f(){c["default"].unbind(window,"mousemove",d),c["default"].unbind(window,"mouseup",f),s()}function p(e){c["default"].bind(window,"mousemove",d),c["default"].bind(window,"mouseup",f),b=e.clientY}i(this,t);var h=r(this,e.call(this,n,o,a));h.__truncationSuspended=!1;var m=h,b=void 0;return h.__input=document.createElement("input"),h.__input.setAttribute("type","text"),c["default"].bind(h.__input,"change",l),c["default"].bind(h.__input,"blur",u),c["default"].bind(h.__input,"mousedown",p),c["default"].bind(h.__input,"keydown",function(e){13===e.keyCode&&(m.__truncationSuspended=!0,this.blur(),m.__truncationSuspended=!1,s())}),h.updateDisplay(),h.domElement.appendChild(h.__input),h}return a(t,e),t.prototype.updateDisplay=function(){return this.__input.value=this.__truncationSuspended?this.getValue():l(this.getValue(),this.__precision),e.prototype.updateDisplay.call(this)},t}(u["default"]);t["default"]=p},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t,n,o,i){return o+(i-o)*((e-t)/(n-t))}t.__esModule=!0;var s=n(12),u=o(s),d=n(9),c=o(d),f=function(e){function t(n,o,a,s,u){function d(e){document.activeElement.blur(),c["default"].bind(window,"mousemove",f),c["default"].bind(window,"mouseup",_),f(e)}function f(e){e.preventDefault();var t=h.__background.getBoundingClientRect();return h.setValue(l(e.clientX,t.left,t.right,h.__min,h.__max)),!1}function _(){c["default"].unbind(window,"mousemove",f),c["default"].unbind(window,"mouseup",_),h.__onFinishChange&&h.__onFinishChange.call(h,h.getValue())}i(this,t);var p=r(this,e.call(this,n,o,{min:a,max:s,step:u})),h=p;return p.__background=document.createElement("div"),p.__foreground=document.createElement("div"),c["default"].bind(p.__background,"mousedown",d),c["default"].addClass(p.__background,"slider"),c["default"].addClass(p.__foreground,"slider-fg"),p.updateDisplay(),p.__background.appendChild(p.__foreground),p.domElement.appendChild(p.__background),p}return a(t,e),t.prototype.updateDisplay=function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",e.prototype.updateDisplay.call(this)},t}(u["default"]);t["default"]=f},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var l=n(7),s=o(l),u=n(9),d=o(u),c=function(e){function t(n,o,a){i(this,t);var l=r(this,e.call(this,n,o)),s=l;return l.__button=document.createElement("div"),l.__button.innerHTML=void 0===a?"Fire":a,d["default"].bind(l.__button,"click",function(e){return e.preventDefault(),s.fire(),!1}),d["default"].addClass(l.__button,"button"),l.domElement.appendChild(l.__button),l}return a(t,e),t.prototype.fire=function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())},t}(s["default"]);t["default"]=c},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t,n,o){e.style.background="",g["default"].each(y,function(i){e.style.cssText+="background: "+i+"linear-gradient("+t+", "+n+" 0%, "+o+" 100%); "})}function s(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}t.__esModule=!0;var u=n(7),d=o(u),c=n(9),f=o(c),_=n(2),p=o(_),h=n(3),m=o(h),b=n(5),g=o(b),v=function(e){function t(n,o){function a(e){h(e),f["default"].bind(window,"mousemove",h),f["default"].bind(window,"mouseup",u)}function u(){f["default"].unbind(window,"mousemove",h),f["default"].unbind(window,"mouseup",u),_()}function d(){var e=(0,m["default"])(this.value);e!==!1?(y.__color.__state=e,y.setValue(y.__color.toOriginal())):this.value=y.__color.toString()}function c(){f["default"].unbind(window,"mousemove",b),f["default"].unbind(window,"mouseup",c),_()}function _(){y.__onFinishChange&&y.__onFinishChange.call(y,y.__color.toOriginal())}function h(e){e.preventDefault();var t=y.__saturation_field.getBoundingClientRect(),n=(e.clientX-t.left)/(t.right-t.left),o=1-(e.clientY-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),n>1?n=1:n<0&&(n=0),y.__color.v=o,y.__color.s=n,y.setValue(y.__color.toOriginal()),!1}function b(e){e.preventDefault();var t=y.__hue_field.getBoundingClientRect(),n=1-(e.clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),y.__color.h=360*n,y.setValue(y.__color.toOriginal()),!1}i(this,t);var v=r(this,e.call(this,n,o));v.__color=new p["default"](v.getValue()),v.__temp=new p["default"](0);var y=v;v.domElement=document.createElement("div"),f["default"].makeSelectable(v.domElement,!1),v.__selector=document.createElement("div"),v.__selector.className="selector",v.__saturation_field=document.createElement("div"),v.__saturation_field.className="saturation-field",v.__field_knob=document.createElement("div"),v.__field_knob.className="field-knob",v.__field_knob_border="2px solid ",v.__hue_knob=document.createElement("div"),v.__hue_knob.className="hue-knob",v.__hue_field=document.createElement("div"),v.__hue_field.className="hue-field",v.__input=document.createElement("input"),v.__input.type="text",v.__input_textShadow="0 1px 1px ",f["default"].bind(v.__input,"keydown",function(e){13===e.keyCode&&d.call(this)}),f["default"].bind(v.__input,"blur",d),f["default"].bind(v.__selector,"mousedown",function(){f["default"].addClass(this,"drag").bind(window,"mouseup",function(){f["default"].removeClass(y.__selector,"drag")})});var w=document.createElement("div");return g["default"].extend(v.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),g["default"].extend(v.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:v.__field_knob_border+(v.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),g["default"].extend(v.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),g["default"].extend(v.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),g["default"].extend(w.style,{width:"100%",height:"100%",background:"none"}),l(w,"top","rgba(0,0,0,0)","#000"),g["default"].extend(v.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),s(v.__hue_field),g["default"].extend(v.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:v.__input_textShadow+"rgba(0,0,0,0.7)"}),f["default"].bind(v.__saturation_field,"mousedown",a),f["default"].bind(v.__field_knob,"mousedown",a),f["default"].bind(v.__hue_field,"mousedown",function(e){b(e),f["default"].bind(window,"mousemove",b),f["default"].bind(window,"mouseup",c)}),v.__saturation_field.appendChild(w),v.__selector.appendChild(v.__field_knob),v.__selector.appendChild(v.__saturation_field),v.__selector.appendChild(v.__hue_field),v.__hue_field.appendChild(v.__hue_knob),v.domElement.appendChild(v.__input),v.domElement.appendChild(v.__selector),v.updateDisplay(),v}return a(t,e),t.prototype.updateDisplay=function(){var e=(0,m["default"])(this.getValue());if(e!==!1){var t=!1;g["default"].each(p["default"].COMPONENTS,function(n){if(!g["default"].isUndefined(e[n])&&!g["default"].isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}},this),t&&g["default"].extend(this.__color.__state,e)}g["default"].extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,o=255-n;g["default"].extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,l(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),g["default"].extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+o+","+o+","+o+",.7)"})},t}(d["default"]),y=["-moz-","-o-","-webkit-","-ms-",""];t["default"]=v},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t,n){var o=document.createElement("li");return t&&o.appendChild(t),n?e.__ul.insertBefore(o,n):e.__ul.appendChild(o),e.onResize(),o}function r(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];t?n.innerHTML=n.value+"*":n.innerHTML=n.value}function a(e,t,n){if(n.__li=t,n.__gui=e,U["default"].extend(n,{options:function(t){if(arguments.length>1){var o=n.__li.nextElementSibling;return n.remove(),s(e,n.object,n.property,{before:o,factoryArgs:[U["default"].toArray(arguments)]})}if(U["default"].isArray(t)||U["default"].isObject(t)){var i=n.__li.nextElementSibling;return n.remove(),s(e,n.object,n.property,{before:i,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){ +return n.__gui.remove(n),n}}),n instanceof B["default"])!function(){var e=new N["default"](n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});U["default"].each(["updateDisplay","onChange","onFinishChange","step"],function(t){var o=n[t],i=e[t];n[t]=e[t]=function(){var t=Array.prototype.slice.call(arguments);return i.apply(e,t),o.apply(n,t)}}),z["default"].addClass(t,"has-slider"),n.domElement.insertBefore(e.domElement,n.domElement.firstElementChild)}();else if(n instanceof N["default"]){var o=function(t){if(U["default"].isNumber(n.__min)&&U["default"].isNumber(n.__max)){var o=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var r=s(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return r.name(o),i&&r.listen(),r}return t};n.min=U["default"].compose(o,n.min),n.max=U["default"].compose(o,n.max)}else n instanceof O["default"]?(z["default"].bind(t,"click",function(){z["default"].fakeEvent(n.__checkbox,"click")}),z["default"].bind(n.__checkbox,"click",function(e){e.stopPropagation()})):n instanceof R["default"]?(z["default"].bind(t,"click",function(){z["default"].fakeEvent(n.__button,"click")}),z["default"].bind(t,"mouseover",function(){z["default"].addClass(n.__button,"hover")}),z["default"].bind(t,"mouseout",function(){z["default"].removeClass(n.__button,"hover")})):n instanceof j["default"]&&(z["default"].addClass(t,"color"),n.updateDisplay=U["default"].compose(function(e){return t.style.borderLeftColor=n.__color.toString(),e},n.updateDisplay),n.updateDisplay());n.setValue=U["default"].compose(function(t){return e.getRoot().__preset_select&&n.isModified()&&r(e.getRoot(),!0),t},n.setValue)}function l(e,t){var n=e.getRoot(),o=n.__rememberedObjects.indexOf(t.object);if(o!==-1){var i=n.__rememberedObjectIndecesToControllers[o];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[o]=i),i[t.property]=t,n.load&&n.load.remembered){var r=n.load.remembered,a=void 0;if(r[e.preset])a=r[e.preset];else{if(!r[Q])return;a=r[Q]}if(a[o]&&void 0!==a[o][t.property]){var l=a[o][t.property];t.initialValue=l,t.setValue(l)}}}}function s(e,t,n,o){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var r=void 0;if(o.color)r=new j["default"](t,n);else{var s=[t,n].concat(o.factoryArgs);r=C["default"].apply(e,s)}o.before instanceof S["default"]&&(o.before=o.before.__li),l(e,r),z["default"].addClass(r.domElement,"c");var u=document.createElement("span");z["default"].addClass(u,"property-name"),u.innerHTML=r.property;var d=document.createElement("div");d.appendChild(u),d.appendChild(r.domElement);var c=i(e,d,o.before);return z["default"].addClass(c,oe.CLASS_CONTROLLER_ROW),r instanceof j["default"]?z["default"].addClass(c,"color"):z["default"].addClass(c,g(r.getValue())),a(e,c,r),e.__controllers.push(r),r}function u(e,t){return document.location.href+"."+t}function d(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function c(e,t){t.style.display=e.useLocalStorage?"block":"none"}function f(e){var t=e.__save_row=document.createElement("li");z["default"].addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),z["default"].addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",z["default"].addClass(n,"button gears");var o=document.createElement("span");o.innerHTML="Save",z["default"].addClass(o,"button"),z["default"].addClass(o,"save");var i=document.createElement("span");i.innerHTML="New",z["default"].addClass(i,"button"),z["default"].addClass(i,"save-as");var r=document.createElement("span");r.innerHTML="Revert",z["default"].addClass(r,"button"),z["default"].addClass(r,"revert");var a=e.__preset_select=document.createElement("select");e.load&&e.load.remembered?U["default"].each(e.load.remembered,function(t,n){d(e,n,n===e.preset)}):d(e,Q,!1),z["default"].bind(a,"change",function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=h(this)),e.folders={},U["default"].each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=h(this),r(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[Q]=h(this,!0)),this.load.remembered[e]=h(this),this.preset=e,d(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){U["default"].each(this.__controllers,function(t){this.getRoot().load.remembered?l(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),U["default"].each(this.__folders,function(e){e.revert(e)}),e||r(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&b(this.__listening)},updateDisplay:function(){U["default"].each(this.__controllers,function(e){e.updateDisplay()}),U["default"].each(this.__folders,function(e){e.updateDisplay()})}}),e.exports=oe},function(e,t){"use strict";e.exports={load:function(e,t){var n=t||document,o=n.createElement("link");o.type="text/css",o.rel="stylesheet",o.href=e,n.getElementsByTagName("head")[0].appendChild(o)},inject:function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(o)}catch(r){}}}},function(e,t){e.exports="

"},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var i=n(10),r=o(i),a=n(13),l=o(a),s=n(14),u=o(s),d=n(11),c=o(d),f=n(15),_=o(f),p=n(8),h=o(p),m=n(5),b=o(m),g=function(e,t){var n=e[t];return b["default"].isArray(arguments[2])||b["default"].isObject(arguments[2])?new r["default"](e,t,arguments[2]):b["default"].isNumber(n)?b["default"].isNumber(arguments[2])&&b["default"].isNumber(arguments[3])?b["default"].isNumber(arguments[4])?new u["default"](e,t,arguments[2],arguments[3],arguments[4]):new u["default"](e,t,arguments[2],arguments[3]):b["default"].isNumber(arguments[4])?new l["default"](e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new l["default"](e,t,{min:arguments[2],max:arguments[3]}):b["default"].isString(n)?new c["default"](e,t):b["default"].isFunction(n)?new _["default"](e,t,""):b["default"].isBoolean(n)?new h["default"](e,t):null};t["default"]=g},function(e,t){"use strict";function n(e){setTimeout(e,1e3/60)}t.__esModule=!0,t["default"]=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=n(9),a=o(r),l=n(5),s=o(l),u=function(){function e(){i(this,e),this.backgroundElement=document.createElement("div"),s["default"].extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),a["default"].makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),s["default"].extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;a["default"].bind(this.backgroundElement,"click",function(){t.hide()})}return e.prototype.show=function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),s["default"].defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})},e.prototype.hide=function t(){var e=this,t=function n(){e.domElement.style.display="none",e.backgroundElement.style.display="none",a["default"].unbind(e.domElement,"webkitTransitionEnd",n),a["default"].unbind(e.domElement,"transitionend",n),a["default"].unbind(e.domElement,"oTransitionEnd",n)};a["default"].bind(this.domElement,"webkitTransitionEnd",t),a["default"].bind(this.domElement,"transitionend",t),a["default"].bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"},e.prototype.layout=function(){this.domElement.style.left=window.innerWidth/2-a["default"].getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-a["default"].getHeight(this.domElement)/2+"px"},e}();t["default"]=u},function(e,t,n){t=e.exports=n(24)(),t.push([e.id,".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1!important}.dg.main .close-button.drag,.dg.main:hover .close-button{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;transition:opacity .1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save>ul{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height .1s ease-out;transition:height .1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid transparent}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.boolean,.dg .cr.boolean *,.dg .cr.function,.dg .cr.function *,.dg .cr.function .property-name{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco,monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px Lucida Grande,sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid hsla(0,0%,100%,.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.boolean:hover,.dg .cr.function:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var Module;if(!Module)Module=(typeof DracoDecoderModule!=="undefined"?DracoDecoderModule:null)||{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=console.log;if(!Module["printErr"])Module["printErr"]=console.warn;var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}else{Module["read"]=function shell_read(){throw"no read() available"}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function shell_print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function shell_printErr(x){console.warn(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw new Error("Unknown runtime environment. Where are we?")}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}if(!Module["quit"]){Module["quit"]=(function(status,toThrow){throw toThrow})}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var Runtime={setTempRet0:(function(value){tempRet0=value;return value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,prepVararg:(function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr}),getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[],addFunction:(function(func){for(var i=0;i>2];var end=(ret+size+15|0)&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}),alignMemory:(function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret}),makeBigInt:(function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret}),GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){Runtime.stackSave()}),"stackRestore":(function(){Runtime.stackRestore()}),"arrayToC":(function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=Runtime.stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var ALLOC_STATIC=2;var ALLOC_NONE=4;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[typeof _malloc==="function"?_malloc:Runtime.staticAlloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){var js=jsStackTrace();if(Module["extraStackTrace"])js+="\n"+Module["extraStackTrace"]();return demangleAll(js)}var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var HEAP,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{if(ArrayBuffer.transfer){ret=ArrayBuffer.transfer(buffer,size)}else{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}assert(Math["imul"]&&Math["fround"]&&Math["clz32"]&&Math["trunc"],"this is a legacy browser, build with LEGACY_VM_SUPPORT");var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_round=Math.round;var Math_min=Math.min;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[];STATIC_BASE=Runtime.GLOBAL_BASE;STATICTOP=STATIC_BASE+18080;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,UBIAAJgSAAAYAAAAAAAAACgSAAC/EgAAUBIAANwSAAAYAAAAAAAAAFASAAAFEwAAQAAAAAAAAAAoEgAAIRMAAFASAAC1EwAAMAAAAAAAAAAoEgAA1xMAAFASAAD8EwAAMAAAAAAAAABQEgAAkSAAAFgAAAAAAAAAUBIAACwUAACQAAAAAAAAAFASAACFFAAAoAAAAAAAAABQEgAA2RQAALAAAAAAAAAAUBIAAA0VAADAAAAAAAAAACgSAAA4FQAAUBIAAFwVAADYAAAAAAAAACgSAAD6FQAAUBIAAJgWAADwAAAAAAAAAFASAAAwFwAAkAAAAAAAAABQEgAAuRcAAPAAAAAAAAAAUBIAAFMYAADwAAAAAAAAAFASAADlGAAA8AAAAAAAAABQEgAAixkAAPAAAAAAAAAAUBIAACYaAADwAAAAAAAAAFASAAC8GgAAYAEAAAAAAAAoEgAAZxsAAFASAAASHAAAeAEAAAAAAABQEgAAtxwAAJAAAAAAAAAAUBIAAE0dAAB4AQAAAAAAAFASAAD0HQAAeAEAAAAAAABQEgAAkx4AAHgBAAAAAAAAUBIAAEYfAAB4AQAAAAAAAFASAADuHwAAeAEAAAAAAABQEgAAUS0AAHAAAAAAAAAAUBIAAL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Byb2dyZXNzAFN0YWxlIGZpbGUgaGFuZGxlAFJlbW90ZSBJL08gZXJyb3IAUXVvdGEgZXhjZWVkZWQATm8gbWVkaXVtIGZvdW5kAFdyb25nIG1lZGl1bSB0eXBlAE5vIGVycm9yIGluZm9ybWF0aW9uAAAlZAB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzOiAlcwB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzAHRlcm1pbmF0aW5nIHdpdGggJXMgZm9yZWlnbiBleGNlcHRpb24AdGVybWluYXRpbmcAdW5jYXVnaHQAU3Q5ZXhjZXB0aW9uAE4xMF9fY3h4YWJpdjExNl9fc2hpbV90eXBlX2luZm9FAFN0OXR5cGVfaW5mbwBOMTBfX2N4eGFiaXYxMjBfX3NpX2NsYXNzX3R5cGVfaW5mb0UATjEwX19jeHhhYml2MTE3X19jbGFzc190eXBlX2luZm9FAHB0aHJlYWRfb25jZSBmYWlsdXJlIGluIF9fY3hhX2dldF9nbG9iYWxzX2Zhc3QoKQBjYW5ub3QgY3JlYXRlIHB0aHJlYWQga2V5IGZvciBfX2N4YV9nZXRfZ2xvYmFscygpAGNhbm5vdCB6ZXJvIG91dCB0aHJlYWQgdmFsdWUgZm9yIF9fY3hhX2dldF9nbG9iYWxzKCkAdGVybWluYXRlX2hhbmRsZXIgdW5leHBlY3RlZGx5IHJldHVybmVkAFN0MTFsb2dpY19lcnJvcgBTdDEybGVuZ3RoX2Vycm9yAE4xMF9fY3h4YWJpdjExOV9fcG9pbnRlcl90eXBlX2luZm9FAE4xMF9fY3h4YWJpdjExN19fcGJhc2VfdHlwZV9pbmZvRQ==";var tempDoublePtr=STATICTOP;STATICTOP+=16;function ___cxa_allocate_exception(size){return _malloc(size)}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0&&!info.rethrown){if(info.destructor){Module["dynCall_vi"](info.destructor,ptr)}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___cxa_begin_catch(ptr){var info=EXCEPTIONS.infos[ptr];if(info&&!info.caught){info.caught=true;__ZSt18uncaught_exceptionv.uncaught_exception--}if(info)info.rethrown=false;EXCEPTIONS.caught.push(ptr);EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));return ptr}function ___cxa_pure_virtual(){ABORT=true;throw"Pure virtual function called!"}function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(Runtime.setTempRet0(0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(Runtime.setTempRet0(0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(Runtime.setTempRet0(typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(Runtime.setTempRet0(throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC);function ___gxx_personality_v0(){}var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffer){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=PTHREAD_SPECIFIC_NEXT_KEY;PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0;PTHREAD_SPECIFIC_NEXT_KEY++;return 0}function _pthread_once(ptr,func){if(!_pthread_once.seen)_pthread_once.seen={};if(ptr in _pthread_once.seen)return;Module["dynCall_v"](func);_pthread_once.seen[ptr]=1}function _pthread_setspecific(key,value){if(!(key in PTHREAD_SPECIFIC)){return ERRNO_CODES.EINVAL}PTHREAD_SPECIFIC[key]=value;return 0}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}__ATEXIT__.push((function(){var fflush=Module["_fflush"];if(fflush)fflush(0);var printChar=___syscall146.printChar;if(!printChar)return;var buffers=___syscall146.buffers;if(buffers[1].length)printChar(1,10);if(buffers[2].length)printChar(2,10)}));DYNAMICTOP_PTR=Runtime.staticAlloc(4);STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=Runtime.alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var decodeBase64=typeof atob==="function"?atob:(function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i2147483648)return false;b=new a(newBuffer);d=new c(newBuffer);f=new e(newBuffer);h=new g(newBuffer);j=new i(newBuffer);l=new k(newBuffer);n=new m(newBuffer);p=new o(newBuffer);buffer=newBuffer;return true} +// EMSCRIPTEN_START_FUNCS +function wc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=g+(e+4)|0;l=c;m=d-e|0}else{k=g;l=i;m=i}switch(m|0){case 3:{n=h[k+2>>0]<<16^l;o=6;break}case 2:{n=l;o=6;break}case 1:{p=l;o=7;break}default:q=l}if((o|0)==6){p=h[k+1>>0]<<8^n;o=7}if((o|0)==7)q=X(h[k>>0]^p,1540483477)|0;p=X(q>>>13^q,1540483477)|0;q=p>>>15^p;p=f[a+4>>2]|0;if(!p){r=0;return r|0}k=p+-1|0;n=(k&p|0)==0;if(!n)if(q>>>0

>>0)s=q;else s=(q>>>0)%(p>>>0)|0;else s=q&k;l=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!l){r=0;return r|0}a=f[l>>2]|0;if(!a){r=0;return r|0}l=(i|0)==0;if(n){n=a;a:while(1){m=f[n+4>>2]|0;e=(m|0)==(q|0);if(!(e|(m&k|0)==(s|0))){r=0;o=41;break}do if(e?(m=n+8|0,d=b[m+11>>0]|0,c=d<<24>>24<0,j=d&255,((c?f[n+12>>2]|0:j)|0)==(i|0)):0){d=f[m>>2]|0;t=c?d:m;if(c){if(l){r=n;o=41;break a}if(!(dj(t,g,i)|0)){r=n;o=41;break a}else break}if(l){r=n;o=41;break a}if((d&255)<<24>>24==(b[g>>0]|0)){d=j;j=m;m=g;do{d=d+-1|0;j=j+1|0;if(!d){r=n;o=41;break a}m=m+1|0}while((b[j>>0]|0)==(b[m>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=41;break}}if((o|0)==41)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;n=(a|0)==(q|0);if(!n){if(a>>>0

>>0)v=a;else v=(a>>>0)%(p>>>0)|0;if((v|0)!=(s|0)){r=0;o=41;break}if(n)o=33}else o=33;do if((o|0)==33?(o=0,n=u+8|0,a=b[n+11>>0]|0,k=a<<24>>24<0,e=a&255,((k?f[u+12>>2]|0:e)|0)==(i|0)):0){a=f[n>>2]|0;m=k?a:n;if(k){if(l){r=u;o=41;break b}if(!(dj(m,g,i)|0)){r=u;o=41;break b}else break}if(l){r=u;o=41;break b}if((a&255)<<24>>24==(b[g>>0]|0)){a=e;e=n;n=g;do{a=a+-1|0;e=e+1|0;if(!a){r=u;o=41;break b}n=n+1|0}while((b[e>>0]|0)==(b[n>>0]|0))}}while(0);u=f[u>>2]|0;if(!u){r=0;o=41;break}}if((o|0)==41)return r|0;return 0}function xc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;h=a+4|0;i=f[c>>2]|0;c=i;do if((i|0)!=(h|0)){j=i+16|0;k=b[j+11>>0]|0;l=k<<24>>24<0;m=l?f[i+20>>2]|0:k&255;k=b[g+11>>0]|0;n=k<<24>>24<0;o=n?f[g+4>>2]|0:k&255;k=m>>>0>>0;p=k?m:o;if((p|0)!=0?(q=dj(n?f[g>>2]|0:g,l?f[j>>2]|0:j,p)|0,(q|0)!=0):0){if((q|0)<0)break}else r=4;if((r|0)==4?o>>>0>>0:0)break;q=o>>>0>>0?o:m;if((q|0)!=0?(m=dj(l?f[j>>2]|0:j,n?f[g>>2]|0:g,q)|0,(m|0)!=0):0){if((m|0)>=0)r=36}else r=20;if((r|0)==20?!k:0)r=36;if((r|0)==36){f[d>>2]=c;f[e>>2]=c;s=e;return s|0}k=i+4|0;m=f[k>>2]|0;if(!m){q=i+8|0;j=f[q>>2]|0;if((f[j>>2]|0)==(i|0))t=j;else{j=q;do{q=f[j>>2]|0;j=q+8|0;l=f[j>>2]|0}while((f[l>>2]|0)!=(q|0));t=l}}else{j=m;while(1){l=f[j>>2]|0;if(!l)break;else j=l}t=j}do if((t|0)!=(h|0)){m=t+16|0;l=b[m+11>>0]|0;q=l<<24>>24<0;p=q?f[t+20>>2]|0:l&255;l=p>>>0>>0?p:o;if((l|0)!=0?(u=dj(n?f[g>>2]|0:g,q?f[m>>2]|0:m,l)|0,(u|0)!=0):0){if((u|0)<0)break}else r=30;if((r|0)==30?o>>>0

>>0:0)break;s=_e(a,d,g)|0;return s|0}while(0);if(!(f[i+4>>2]|0)){f[d>>2]=c;s=k;return s|0}else{f[d>>2]=t;s=t;return s|0}}while(0);t=f[i>>2]|0;do if((i|0)==(f[a>>2]|0))v=c;else{if(!t){h=i;while(1){e=f[h+8>>2]|0;if((f[e>>2]|0)==(h|0))h=e;else{w=e;break}}}else{h=t;while(1){k=f[h+4>>2]|0;if(!k){w=h;break}else h=k}}h=w;k=w+16|0;e=b[g+11>>0]|0;o=e<<24>>24<0;n=o?f[g+4>>2]|0:e&255;e=b[k+11>>0]|0;j=e<<24>>24<0;p=j?f[w+20>>2]|0:e&255;e=n>>>0

>>0?n:p;if((e|0)!=0?(u=dj(j?f[k>>2]|0:k,o?f[g>>2]|0:g,e)|0,(u|0)!=0):0){if((u|0)<0){v=h;break}}else r=12;if((r|0)==12?p>>>0>>0:0){v=h;break}s=_e(a,d,g)|0;return s|0}while(0);if(!t){f[d>>2]=i;s=i;return s|0}else{i=v;f[d>>2]=i;s=i+4|0;return s|0}return 0}function yc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;g=u;u=u+64|0;i=g;j=i;k=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Oc(i,d)|0?od(i,d)|0:0){j=(a|0)==0;if(!j){if(!(f[i+12>>2]|0)){l=0;break}Af(d,0,0)|0;if(!j){j=i+44|0;k=i+48|0;m=i+40|0;n=i+16|0;o=i+28|0;p=(c|0)>0;q=d+36|0;r=d+32|0;s=d+24|0;t=d+28|0;v=f[k>>2]|0;w=0;x=0;while(1){b:do if(v>>>0<16384){y=f[j>>2]|0;z=v;while(1){if((y|0)<=0){A=z;break b}B=f[m>>2]|0;y=y+-1|0;f[j>>2]=y;C=h[B+y>>0]|z<<8;f[k>>2]=C;if(C>>>0>=16384){A=C;break}else z=C}}else A=v;while(0);z=A&4095;y=f[(f[n>>2]|0)+(z<<2)>>2]|0;C=f[o>>2]|0;v=(X(f[C+(y<<3)>>2]|0,A>>>12)|0)+z-(f[C+(y<<3)+4>>2]|0)|0;f[k>>2]=v;c:do if(p){if((y|0)>0){D=0;E=x}else{C=(b[q>>0]|0)==0;z=0;B=x;while(1){if(C){l=0;break a}F=B+1|0;f[e+(B<<2)>>2]=0;z=z+1|0;if((z|0)>=(c|0)){G=F;break c}else B=F}}while(1){if(!(b[q>>0]|0)){l=0;break a}B=f[s>>2]|0;z=f[t>>2]|0;C=f[r>>2]|0;F=0;H=0;while(1){I=B+(C>>>3)|0;if(I>>>0>>0){J=(h[I>>0]|0)>>>(C&7)&1;I=C+1|0;f[r>>2]=I;K=I;L=J}else{K=C;L=0}H=L<>2]=H;D=D+1|0;if((D|0)>=(c|0)){G=C;break}else E=C}}else G=x;while(0);w=w+c|0;if(w>>>0>=a>>>0)break;else x=G}}}else Af(d,0,0)|0;_j(d);l=1}else l=0;while(0);d=f[i+28>>2]|0;if(d|0){G=i+32|0;a=f[G>>2]|0;if((a|0)!=(d|0))f[G>>2]=a+(~((a+-8-d|0)>>>3)<<3);lp(d)}d=f[i+16>>2]|0;if(d|0){a=i+20|0;G=f[a>>2]|0;if((G|0)!=(d|0))f[a>>2]=G+(~((G+-4-d|0)>>>2)<<2);lp(d)}d=f[i>>2]|0;if(!d){u=g;return l|0}G=i+4|0;i=f[G>>2]|0;if((i|0)!=(d|0))f[G>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d);u=g;return l|0}function zc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a;h=b;i=h;j=c;k=d;l=k;if(!i){m=(e|0)!=0;if(!l){if(m){f[e>>2]=(g>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(g>>>0)/(j>>>0)>>>0;return (I=n,o)|0}else{if(!m){n=0;o=0;return (I=n,o)|0}f[e>>2]=a|0;f[e+4>>2]=b&0;n=0;o=0;return (I=n,o)|0}}m=(l|0)==0;do if(j){if(!m){p=(_(l|0)|0)-(_(i|0)|0)|0;if(p>>>0<=31){q=p+1|0;r=31-p|0;s=p-31>>31;t=q;u=g>>>(q>>>0)&s|i<>>(q>>>0)&s;w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}r=j-1|0;if(r&j|0){s=(_(j|0)|0)+33-(_(i|0)|0)|0;q=64-s|0;p=32-s|0;y=p>>31;z=s-32|0;A=z>>31;t=s;u=p-1>>31&i>>>(z>>>0)|(i<>>(s>>>0))&A;v=A&i>>>(s>>>0);w=g<>>(z>>>0))&y|g<>31;break}if(e|0){f[e>>2]=r&g;f[e+4>>2]=0}if((j|0)==1){n=h|b&0;o=a|0|0;return (I=n,o)|0}else{r=uk(j|0)|0;n=i>>>(r>>>0)|0;o=i<<32-r|g>>>(r>>>0)|0;return (I=n,o)|0}}else{if(m){if(e|0){f[e>>2]=(i>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(i>>>0)/(j>>>0)>>>0;return (I=n,o)|0}if(!g){if(e|0){f[e>>2]=0;f[e+4>>2]=(i>>>0)%(l>>>0)}n=0;o=(i>>>0)/(l>>>0)>>>0;return (I=n,o)|0}r=l-1|0;if(!(r&l)){if(e|0){f[e>>2]=a|0;f[e+4>>2]=r&i|b&0}n=0;o=i>>>((uk(l|0)|0)>>>0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k,o)|0;r=X(k,p)|0;k=(h<<1)-q|0;f[c>>2]=k;h=(j<<1)-r|0;f[i>>2]=h;if((X(o,p)|0)>-1){p=0-h|0;f[c>>2]=p;s=0-k|0;t=p}else{f[c>>2]=h;s=k;t=h}h=(t+q|0)/2|0;f[c>>2]=h;q=(s+r|0)/2|0;f[i>>2]=q;m=h;n=q}if(!m)u=(n|0)==0;else u=(m|0)<0&(n|0)<1;if(!m)v=(n|0)==0?0:(n|0)>0?3:1;else v=(m|0)>0?(n>>31)+2|0:(n|0)<1?0:3;if(u){w=m;x=n;y=1}else{switch(v|0){case 1:{z=n;A=0-m|0;break}case 2:{z=0-m|0;A=0-n|0;break}case 3:{z=0-n|0;A=m;break}default:{z=m;A=n}}n=c;f[n>>2]=z;f[n+4>>2]=A;w=z;x=A;y=0}A=(f[d>>2]|0)+w|0;f[a>>2]=A;w=(f[d+4>>2]|0)+x|0;x=a+4|0;f[x>>2]=w;d=f[e>>2]|0;if((d|0)>=(A|0))if((A|0)<(0-d|0))B=(f[b+4>>2]|0)+A|0;else B=A;else B=A-(f[b+4>>2]|0)|0;f[a>>2]=B;if((d|0)>=(w|0))if((w|0)<(0-d|0))C=(f[b+4>>2]|0)+w|0;else C=w;else C=w-(f[b+4>>2]|0)|0;f[x>>2]=C;if(y){D=B;E=C}else{switch((4-v|0)%4|0|0){case 1:{F=C;G=0-B|0;break}case 2:{F=0-B|0;G=0-C|0;break}case 3:{F=0-C|0;G=B;break}default:{F=B;G=C}}C=a;f[C>>2]=F;f[C+4>>2]=G;D=F;E=G}if(l){H=D;I=E;J=H+g|0;K=I+g|0;L=a;M=L;f[M>>2]=J;N=L+4|0;O=N;f[O>>2]=K;return}if((E|D|0)>-1){P=1;Q=1}else{l=(D|0)<1&(E|0)<1;P=l?-1:(D|0)>0?1:-1;Q=l?-1:(E|0)>0?1:-1}l=X(d,P)|0;G=X(d,Q)|0;d=(D<<1)-l|0;f[a>>2]=d;D=(E<<1)-G|0;f[x>>2]=D;if((X(P,Q)|0)>-1){Q=0-D|0;f[a>>2]=Q;R=0-d|0;S=Q}else{f[a>>2]=D;R=d;S=D}D=(S+l|0)/2|0;f[a>>2]=D;l=(R+G|0)/2|0;f[x>>2]=l;H=D;I=l;J=H+g|0;K=I+g|0;L=a;M=L;f[M>>2]=J;N=L+4|0;O=N;f[O>>2]=K;return}function Bc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)lp(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}d=Yk(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)lp(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=e;k=c;l=i;m=e}a:while(1){b:do if(h){e=j;i=k;c=m;while(1){d=i;while(1){n=f[d+4>>2]&g;if((n|0)==(l|0))break;o=(f[a>>2]|0)+(n<<2)|0;if(!(f[o>>2]|0)){p=d;q=c;r=o;s=n;break b}o=d+8|0;t=d;while(1){u=f[t>>2]|0;if(!u)break;if((f[o>>2]|0)==(f[u+8>>2]|0))t=u;else break}f[c>>2]=u;f[t>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;o=f[e>>2]|0;if(!o){v=37;break a}else d=o}i=f[d>>2]|0;if(!i){v=37;break a}else{e=d;c=d}}}else{c=j;e=k;i=m;while(1){o=e;while(1){w=f[o+4>>2]|0;if(w>>>0>>0)x=w;else x=(w>>>0)%(b>>>0)|0;if((x|0)==(l|0))break;w=(f[a>>2]|0)+(x<<2)|0;if(!(f[w>>2]|0)){p=o;q=i;r=w;s=x;break b}w=o+8|0;y=o;while(1){z=f[y>>2]|0;if(!z)break;if((f[w>>2]|0)==(f[z+8>>2]|0))y=z;else break}f[i>>2]=z;f[y>>2]=f[f[(f[a>>2]|0)+(x<<2)>>2]>>2];f[f[(f[a>>2]|0)+(x<<2)>>2]>>2]=o;w=f[c>>2]|0;if(!w){v=37;break a}else o=w}e=f[o>>2]|0;if(!e){v=37;break a}else{c=o;i=o}}}while(0);f[r>>2]=q;k=f[p>>2]|0;if(!k){v=37;break}else{j=p;l=s;m=p}}if((v|0)==37)return}function Cc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;d=u;u=u+32|0;e=d+24|0;g=d+20|0;h=d+8|0;i=d+4|0;j=d;f[e>>2]=0;Ph(e,f[a>>2]|0)|0;a:do if(f[e>>2]|0){k=0;while(1){k=k+1|0;if(!(Rc(a,c)|0)){l=0;break}if(k>>>0>=(f[e>>2]|0)>>>0)break a}u=d;return l|0}while(0);f[g>>2]=0;Ph(g,f[a>>2]|0)|0;b:do if(!(f[g>>2]|0))m=1;else{e=h+11|0;k=0;while(1){f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;o=f[a>>2]|0;p=o+8|0;q=f[p+4>>2]|0;r=o+16|0;s=r;t=f[s>>2]|0;v=f[s+4>>2]|0;do if((q|0)>(v|0)|((q|0)==(v|0)?(f[p>>2]|0)>>>0>t>>>0:0)){s=b[(f[o>>2]|0)+t>>0]|0;w=Ul(t|0,v|0,1,0)|0;x=r;f[x>>2]=w;f[x+4>>2]=I;x=s&255;Th(h,x,0);if(s<<24>>24){w=f[a>>2]|0;y=Fj(h,0)|0;z=w+8|0;A=f[z>>2]|0;B=f[z+4>>2]|0;z=w+16|0;C=z;D=f[C>>2]|0;E=s&255;s=Ul(D|0,f[C+4>>2]|0,E|0,0)|0;C=I;if((B|0)<(C|0)|(B|0)==(C|0)&A>>>0>>0){F=1;break}Ff(y|0,(f[w>>2]|0)+D|0,x|0)|0;x=z;D=Ul(f[x>>2]|0,f[x+4>>2]|0,E|0,0)|0;E=z;f[E>>2]=D;f[E+4>>2]=I}E=Yk(40)|0;f[E>>2]=0;f[E+4>>2]=0;f[E+8>>2]=0;f[E+12>>2]=0;n[E+16>>2]=$(1.0);D=E+20|0;f[D>>2]=0;f[D+4>>2]=0;f[D+8>>2]=0;f[D+12>>2]=0;n[E+36>>2]=$(1.0);f[i>>2]=E;if(Cc(a,E)|0){E=f[i>>2]|0;f[i>>2]=0;f[j>>2]=E;lf(c,h,j)|0;$g(j);G=0}else G=1;$g(i);F=G}else F=1;while(0);if((b[e>>0]|0)<0)lp(f[h>>2]|0);k=k+1|0;if(F|0){m=0;break b}if(k>>>0>=(f[g>>2]|0)>>>0){m=1;break}}}while(0);l=m;u=d;return l|0}function Dc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+176|0;g=e+136|0;h=e+64|0;i=e;j=e+32|0;k=f[(f[c+4>>2]|0)+44>>2]|0;l=Yk(88)|0;f[l+4>>2]=0;f[l>>2]=3216;m=l+12|0;f[m>>2]=3196;n=l+64|0;f[n>>2]=0;f[l+68>>2]=0;f[l+72>>2]=0;o=l+16|0;p=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));f[l+76>>2]=k;f[l+80>>2]=d;f[l+84>>2]=0;q=l;r=h+4|0;f[r>>2]=3196;s=h+56|0;f[s>>2]=0;t=h+60|0;f[t>>2]=0;f[h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>2]=e;h=a+32|0;i=a+36|0;j=f[i>>2]|0;k=f[h>>2]|0;l=j-k>>2;m=k;k=j;if(l>>>0>=e>>>0)if(l>>>0>e>>>0?(j=m+(e<<2)|0,(k|0)!=(j|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=e}else n=e;else{Og(h,e-l|0);n=f[g>>2]|0}l=e>>>0>1073741823?-1:e<<2;h=ip(l)|0;Dh(h|0,0,l|0)|0;if((n|0)>0){l=a+16|0;j=a+32|0;k=a+12|0;i=0;do{m=f[h+(i<<2)>>2]|0;o=f[l>>2]|0;if((m|0)>(o|0)){p=f[j>>2]|0;f[p+(i<<2)>>2]=o;q=p}else{p=f[k>>2]|0;o=f[j>>2]|0;f[o+(i<<2)>>2]=(m|0)<(p|0)?p:m;q=o}i=i+1|0;r=f[g>>2]|0}while((i|0)<(r|0));if((r|0)>0){i=a+20|0;j=0;do{o=(f[b+(j<<2)>>2]|0)+(f[q+(j<<2)>>2]|0)|0;m=c+(j<<2)|0;f[m>>2]=o;if((o|0)<=(f[l>>2]|0)){if((o|0)<(f[k>>2]|0)){s=(f[i>>2]|0)+o|0;t=18}}else{s=o-(f[i>>2]|0)|0;t=18}if((t|0)==18){t=0;f[m>>2]=s}j=j+1|0;m=f[g>>2]|0}while((j|0)<(m|0));u=m}else u=r}else u=n;if((e|0)>=(d|0)){jp(h);return 1}n=0-e|0;r=a+16|0;j=a+32|0;s=a+12|0;i=a+20|0;a=u;u=e;while(1){k=c+(u<<2)|0;l=k+(n<<2)|0;q=b+(u<<2)|0;if((a|0)>0){m=0;do{o=f[l+(m<<2)>>2]|0;p=f[r>>2]|0;if((o|0)>(p|0)){v=f[j>>2]|0;f[v+(m<<2)>>2]=p;w=v}else{v=f[s>>2]|0;p=f[j>>2]|0;f[p+(m<<2)>>2]=(o|0)<(v|0)?v:o;w=p}m=m+1|0;x=f[g>>2]|0}while((m|0)<(x|0));if((x|0)>0){m=0;do{l=(f[q+(m<<2)>>2]|0)+(f[w+(m<<2)>>2]|0)|0;p=k+(m<<2)|0;f[p>>2]=l;if((l|0)<=(f[r>>2]|0)){if((l|0)<(f[s>>2]|0)){y=(f[i>>2]|0)+l|0;t=33}}else{y=l-(f[i>>2]|0)|0;t=33}if((t|0)==33){t=0;f[p>>2]=y}m=m+1|0;p=f[g>>2]|0}while((m|0)<(p|0));z=p}else z=x}else z=a;u=u+e|0;if((u|0)>=(d|0))break;else a=z}jp(h);return 1}function Fc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+16|0;e=d;g=a+68|0;f[g>>2]=(f[g>>2]|0)+1;g=(f[a+8+(b*12|0)+4>>2]|0)-(f[a+8+(b*12|0)>>2]|0)|0;h=g>>2;if((g|0)<=0){u=d;return}g=a+4|0;i=a+56|0;j=a+72|0;k=f[c>>2]|0;c=k+4|0;l=k+8|0;m=a+76|0;n=f[a+44+(b<<2)>>2]|0;b=0;while(1){o=(n|0)==-1;p=o?-1:(n>>>0)/3|0;q=(f[i>>2]|0)+(p>>>5<<2)|0;f[q>>2]=f[q>>2]|1<<(p&31);f[j>>2]=(f[j>>2]|0)+1;do if(b){if(o)r=-1;else r=f[(f[(f[a>>2]|0)+96>>2]|0)+(((n|0)/3|0)*12|0)+(((n|0)%3|0)<<2)>>2]|0;f[m>>2]=r;f[e>>2]=r;p=f[c>>2]|0;if(p>>>0<(f[l>>2]|0)>>>0){f[p>>2]=r;f[c>>2]=p+4}else dh(k,e);if(!(b&1)){p=n+1|0;if(o){s=-1;break}t=((p>>>0)%3|0|0)==0?n+-2|0:p;v=35;break}if(!o)if(!((n>>>0)%3|0)){t=n+2|0;v=35;break}else{t=n+-1|0;v=35;break}else s=-1}else{if(o)w=-1;else w=f[(f[(f[a>>2]|0)+96>>2]|0)+(((n|0)/3|0)*12|0)+(((n|0)%3|0)<<2)>>2]|0;f[e>>2]=w;p=f[c>>2]|0;if(p>>>0<(f[l>>2]|0)>>>0){f[p>>2]=w;f[c>>2]=p+4}else dh(k,e);p=n+1|0;if(!o?(q=((p>>>0)%3|0|0)==0?n+-2|0:p,(q|0)!=-1):0)x=f[(f[(f[a>>2]|0)+96>>2]|0)+(((q|0)/3|0)*12|0)+(((q|0)%3|0)<<2)>>2]|0;else x=-1;f[e>>2]=x;q=f[c>>2]|0;if(q>>>0<(f[l>>2]|0)>>>0){f[q>>2]=x;f[c>>2]=q+4}else dh(k,e);if(!o?(q=(((n>>>0)%3|0|0)==0?2:-1)+n|0,(q|0)!=-1):0)y=f[(f[(f[a>>2]|0)+96>>2]|0)+(((q|0)/3|0)*12|0)+(((q|0)%3|0)<<2)>>2]|0;else y=-1;f[m>>2]=y;f[e>>2]=y;q=f[c>>2]|0;if(q>>>0<(f[l>>2]|0)>>>0){f[q>>2]=y;f[c>>2]=q+4}else dh(k,e);t=n;v=35}while(0);if((v|0)==35){v=0;if((t|0)==-1)s=-1;else s=f[(f[(f[g>>2]|0)+12>>2]|0)+(t<<2)>>2]|0}b=b+1|0;if((b|0)>=(h|0))break;else n=s}u=d;return}function Gc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;c=a+148|0;d=f[b>>2]|0;b=(d|0)==-1;e=d+1|0;do if(!b){g=((e>>>0)%3|0|0)==0?d+-2|0:e;if(!((d>>>0)%3|0)){h=g;i=d+2|0;break}else{h=g;i=d+-1|0;break}}else{h=-1;i=-1}while(0);g=a+184|0;j=f[g>>2]|0;switch(j|0){case 1:case 0:{if((h|0)==-1)k=-1;else k=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;l=f[a+156>>2]|0;m=l+(k<<2)|0;f[m>>2]=(f[m>>2]|0)+1;if((i|0)==-1){n=1;o=l;p=-1;q=28}else{n=1;o=l;p=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;q=28}break}case 5:{if(b)r=-1;else r=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;l=f[a+156>>2]|0;m=l+(r<<2)|0;f[m>>2]=(f[m>>2]|0)+1;if((h|0)==-1)s=-1;else s=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;m=l+(s<<2)|0;f[m>>2]=(f[m>>2]|0)+1;if((i|0)==-1){n=2;o=l;p=-1;q=28}else{n=2;o=l;p=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;q=28}break}case 3:{if(b)t=-1;else t=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;l=f[a+156>>2]|0;m=l+(t<<2)|0;f[m>>2]=(f[m>>2]|0)+1;if((h|0)==-1)u=-1;else u=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;m=l+(u<<2)|0;f[m>>2]=(f[m>>2]|0)+2;if((i|0)==-1){n=1;o=l;p=-1;q=28}else{n=1;o=l;p=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;q=28}break}case 7:{if(b)v=-1;else v=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;l=f[a+156>>2]|0;m=l+(v<<2)|0;f[m>>2]=(f[m>>2]|0)+2;if((h|0)==-1)w=-1;else w=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;h=l+(w<<2)|0;f[h>>2]=(f[h>>2]|0)+2;if((i|0)==-1){n=2;o=l;p=-1;q=28}else{n=2;o=l;p=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;q=28}break}default:x=j}if((q|0)==28){q=o+(p<<2)|0;f[q>>2]=(f[q>>2]|0)+n;x=f[g>>2]|0}switch(x|0){case 5:case 0:break;default:{f[a+188>>2]=-1;return}}x=f[c>>2]|0;if(!b?(b=((e>>>0)%3|0|0)==0?d+-2|0:e,(b|0)!=-1):0)y=f[(f[x>>2]|0)+(b<<2)>>2]|0;else y=-1;f[a+188>>2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y>>2]|0)+2|0;f[y>>2]=E;if(E&1|0){f[e>>2]=F;E=f[c>>2]|0;if(E>>>0<(f[x>>2]|0)>>>0){f[E>>2]=F;f[c>>2]=E+4}else dh(w,e);f[y>>2]=(f[y>>2]|0)+1}}f[h>>2]=z;f[e>>2]=f[h>>2];Fc(a,B,e);G=f[j>>2]|0;H=f[k>>2]|0}else{G=A;H=l}b=b+1|0;if(b>>>0>=((H-G|0)/12|0)>>>0){i=1;break}else{A=G;l=H}}u=d;return i|0}function Ic(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Qf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Jc(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Sf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Kc(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Tf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Lc(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Vf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Mc(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Wf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Nc(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Yf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Oc(a,c){a=a|0;c=c|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=d[c+38>>1]|0;if(!(e<<16>>16)){g=0;return g|0}i=a+12|0;do if((e&65535)<512){j=c+8|0;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,4,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){g=0;return g|0}else{o=(f[c>>2]|0)+n|0;n=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;b[i>>0]=n;b[i+1>>0]=n>>8;b[i+2>>0]=n>>16;b[i+3>>0]=n>>24;o=j;k=Ul(f[o>>2]|0,f[o+4>>2]|0,4,0)|0;o=j;f[o>>2]=k;f[o+4>>2]=I;p=n;break}}else if(Ph(i,c)|0){p=f[i>>2]|0;break}else{g=0;return g|0}while(0);e=a+4|0;n=f[e>>2]|0;o=f[a>>2]|0;k=n-o>>2;j=o;o=n;if(p>>>0<=k>>>0)if(p>>>0>>0?(n=j+(p<<2)|0,(o|0)!=(n|0)):0){f[e>>2]=o+(~((o+-4-n|0)>>>2)<<2);q=p}else q=p;else{Og(a,p-k|0);q=f[i>>2]|0}if(!q){g=1;return g|0}k=c+8|0;p=c+16|0;n=q;q=0;a:while(1){o=k;e=f[o>>2]|0;j=f[o+4>>2]|0;o=p;m=f[o>>2]|0;l=f[o+4>>2]|0;if(!((j|0)>(l|0)|(j|0)==(l|0)&e>>>0>m>>>0)){g=0;r=23;break}o=f[c>>2]|0;s=b[o+m>>0]|0;t=Ul(m|0,l|0,1,0)|0;l=I;m=p;f[m>>2]=t;f[m+4>>2]=l;m=s&255;u=m&3;v=m>>>2;switch(s&3){case 3:{s=v+q|0;if(s>>>0>=n>>>0){g=0;r=23;break a}Dh((f[a>>2]|0)+(q<<2)|0,0,(v<<2)+4|0)|0;w=s;break}case 0:{x=v;r=20;break}default:{s=l;l=t;t=0;m=v;while(1){if(!((j|0)>(s|0)|(j|0)==(s|0)&e>>>0>l>>>0)){g=0;r=23;break a}v=b[o+l>>0]|0;l=Ul(l|0,s|0,1,0)|0;s=I;y=p;f[y>>2]=l;f[y+4>>2]=s;y=(v&255)<<(t<<3|6)|m;t=t+1|0;if((t|0)>=(u|0)){x=y;r=20;break}else m=y}}}if((r|0)==20){r=0;f[(f[a>>2]|0)+(q<<2)>>2]=x;w=q}q=w+1|0;n=f[i>>2]|0;if(q>>>0>=n>>>0){r=22;break}}if((r|0)==22){g=Zf(a+16|0,f[a>>2]|0,n)|0;return g|0}else if((r|0)==23)return g|0;return 0}function Pc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;c=a+148|0;d=f[b>>2]|0;b=(d|0)==-1;e=d+1|0;do if(!b){g=((e>>>0)%3|0|0)==0?d+-2|0:e;if(!((d>>>0)%3|0)){h=g;i=d+2|0;break}else{h=g;i=d+-1|0;break}}else{h=-1;i=-1}while(0);switch(f[a+168>>2]|0){case 1:case 0:{if((h|0)==-1)j=-1;else j=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;e=f[a+156>>2]|0;g=e+(j<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((i|0)==-1){k=1;l=e;m=-1;n=28}else{k=1;l=e;m=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;n=28}break}case 5:{if(b)o=-1;else o=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;e=f[a+156>>2]|0;g=e+(o<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((h|0)==-1)p=-1;else p=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;g=e+(p<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((i|0)==-1){k=2;l=e;m=-1;n=28}else{k=2;l=e;m=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;n=28}break}case 3:{if(b)q=-1;else q=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;e=f[a+156>>2]|0;g=e+(q<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((h|0)==-1)r=-1;else r=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;g=e+(r<<2)|0;f[g>>2]=(f[g>>2]|0)+2;if((i|0)==-1){k=1;l=e;m=-1;n=28}else{k=1;l=e;m=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;n=28}break}case 7:{if(b)s=-1;else s=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;d=f[a+156>>2]|0;b=d+(s<<2)|0;f[b>>2]=(f[b>>2]|0)+2;if((h|0)==-1)t=-1;else t=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;b=d+(t<<2)|0;f[b>>2]=(f[b>>2]|0)+2;if((i|0)==-1){k=2;l=d;m=-1;n=28}else{k=2;l=d;m=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;n=28}break}default:{}}if((n|0)==28){n=l+(m<<2)|0;f[n>>2]=(f[n>>2]|0)+k}if((h|0)==-1)u=-1;else u=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;h=f[(f[a+156>>2]|0)+(u<<2)>>2]|0;u=f[a+176>>2]|0;if((h|0)<(u|0)){v=u;w=v-u|0;x=a+172|0;f[x>>2]=w;return}c=f[a+180>>2]|0;v=(h|0)>(c|0)?c:h;w=v-u|0;x=a+172|0;f[x>>2]=w;return}function Qc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+16|0;h=d+4|0;i=d;f[a+72>>2]=e;f[a+64>>2]=g;g=ip(e>>>0>1073741823?-1:e<<2)|0;j=a+68|0;k=f[j>>2]|0;f[j>>2]=g;if(k|0)jp(k);k=a+8|0;f[k>>2]=e;g=a+32|0;l=a+36|0;m=f[l>>2]|0;n=f[g>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=e>>>0){if(o>>>0>e>>>0?(m=p+(e<<2)|0,(n|0)!=(m|0)):0)f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2)}else Og(g,e-o|0);o=a+56|0;g=f[o>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;l=m-n|0;p=l>>2;if((l|0)<=0){u=d;return 1}l=a+16|0;q=a+32|0;r=a+12|0;s=a+20|0;if((m|0)==(n|0)){t=g;Eo(t)}else{v=n;w=0}while(1){f[i>>2]=f[v+(w<<2)>>2];f[h>>2]=f[i>>2];ec(a,h,c,w);n=X(w,e)|0;g=f[j>>2]|0;m=b+(n<<2)|0;x=c+(n<<2)|0;if((f[k>>2]|0)>0){n=0;do{y=f[g+(n<<2)>>2]|0;z=f[l>>2]|0;if((y|0)>(z|0)){A=f[q>>2]|0;f[A+(n<<2)>>2]=z;B=A}else{A=f[r>>2]|0;z=f[q>>2]|0;f[z+(n<<2)>>2]=(y|0)<(A|0)?A:y;B=z}n=n+1|0;C=f[k>>2]|0}while((n|0)<(C|0));if((C|0)>0){n=0;do{g=(f[m+(n<<2)>>2]|0)+(f[B+(n<<2)>>2]|0)|0;z=x+(n<<2)|0;f[z>>2]=g;if((g|0)<=(f[l>>2]|0)){if((g|0)<(f[r>>2]|0)){D=(f[s>>2]|0)+g|0;E=22}}else{D=g-(f[s>>2]|0)|0;E=22}if((E|0)==22){E=0;f[z>>2]=D}n=n+1|0}while((n|0)<(f[k>>2]|0))}}w=w+1|0;if((w|0)>=(p|0)){E=10;break}n=f[o>>2]|0;v=f[n>>2]|0;if((f[n+4>>2]|0)-v>>2>>>0<=w>>>0){t=n;E=11;break}}if((E|0)==10){u=d;return 1}else if((E|0)==11)Eo(t);return 0}function Rc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;d=u;u=u+32|0;e=d+16|0;g=d+12|0;h=d;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;i=f[a>>2]|0;j=i+8|0;k=f[j+4>>2]|0;l=i+16|0;m=l;n=f[m>>2]|0;o=f[m+4>>2]|0;do if((k|0)>(o|0)|((k|0)==(o|0)?(f[j>>2]|0)>>>0>n>>>0:0)){m=b[(f[i>>2]|0)+n>>0]|0;p=Ul(n|0,o|0,1,0)|0;q=l;f[q>>2]=p;f[q+4>>2]=I;q=m&255;Th(e,q,0);if(m<<24>>24){p=f[a>>2]|0;r=Fj(e,0)|0;s=p+8|0;t=f[s>>2]|0;v=f[s+4>>2]|0;s=p+16|0;w=s;x=f[w>>2]|0;y=m&255;m=Ul(x|0,f[w+4>>2]|0,y|0,0)|0;w=I;if((v|0)<(w|0)|(v|0)==(w|0)&t>>>0>>0){z=0;break}Ff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]|0;n=f[g>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=e>>>0){if(o>>>0>e>>>0?(m=p+(e<<2)|0,(n|0)!=(m|0)):0)f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2)}else Og(g,e-o|0);o=a+56|0;g=f[o>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;l=m-n|0;p=l>>2;if((l|0)<=0){u=d;return 1}l=a+16|0;q=a+32|0;r=a+12|0;s=a+20|0;if((m|0)==(n|0)){t=g;Eo(t)}else{v=n;w=0}while(1){f[i>>2]=f[v+(w<<2)>>2];f[h>>2]=f[i>>2];dc(a,h,c,w);n=X(w,e)|0;g=f[j>>2]|0;m=b+(n<<2)|0;x=c+(n<<2)|0;if((f[k>>2]|0)>0){n=0;do{y=f[g+(n<<2)>>2]|0;z=f[l>>2]|0;if((y|0)>(z|0)){A=f[q>>2]|0;f[A+(n<<2)>>2]=z;B=A}else{A=f[r>>2]|0;z=f[q>>2]|0;f[z+(n<<2)>>2]=(y|0)<(A|0)?A:y;B=z}n=n+1|0;C=f[k>>2]|0}while((n|0)<(C|0));if((C|0)>0){n=0;do{g=(f[m+(n<<2)>>2]|0)+(f[B+(n<<2)>>2]|0)|0;z=x+(n<<2)|0;f[z>>2]=g;if((g|0)<=(f[l>>2]|0)){if((g|0)<(f[r>>2]|0)){D=(f[s>>2]|0)+g|0;E=22}}else{D=g-(f[s>>2]|0)|0;E=22}if((E|0)==22){E=0;f[z>>2]=D}n=n+1|0}while((n|0)<(f[k>>2]|0))}}w=w+1|0;if((w|0)>=(p|0)){E=10;break}n=f[o>>2]|0;v=f[n>>2]|0;if((f[n+4>>2]|0)-v>>2>>>0<=w>>>0){t=n;E=11;break}}if((E|0)==10){u=d;return 1}else if((E|0)==11)Eo(t);return 0}function Tc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=Ka,t=Ka,u=Ka,v=0,w=0,x=0,y=0,z=0;c=f[b>>2]|0;b=a+4|0;d=f[b>>2]|0;e=(d|0)==0;a:do if(!e){g=d+-1|0;h=(g&d|0)==0;if(!h)if(c>>>0>>0)i=c;else i=(c>>>0)%(d>>>0)|0;else i=g&c;j=f[(f[a>>2]|0)+(i<<2)>>2]|0;if(!j)k=i;else{if(h){h=j;while(1){l=f[h>>2]|0;if(!l){k=i;break a}m=f[l+4>>2]|0;if(!((m|0)==(c|0)|(m&g|0)==(i|0))){k=i;break a}if((f[l+8>>2]|0)==(c|0)){o=l;break}else h=l}p=o+12|0;return p|0}else q=j;while(1){h=f[q>>2]|0;if(!h){k=i;break a}g=f[h+4>>2]|0;if((g|0)!=(c|0)){if(g>>>0>>0)r=g;else r=(g>>>0)%(d>>>0)|0;if((r|0)!=(i|0)){k=i;break a}}if((f[h+8>>2]|0)==(c|0)){o=h;break}else q=h}p=o+12|0;return p|0}}else k=0;while(0);q=Yk(16)|0;f[q+8>>2]=c;f[q+12>>2]=0;f[q+4>>2]=c;f[q>>2]=0;i=a+12|0;s=$(((f[i>>2]|0)+1|0)>>>0);t=$(d>>>0);u=$(n[a+16>>2]);do if(e|s>$(t*u)){r=(d>>>0<3|(d+-1&d|0)!=0)&1|d<<1;j=~~$(W($(s/u)))>>>0;xg(a,r>>>0>>0?j:r);r=f[b>>2]|0;j=r+-1|0;if(!(j&r)){v=r;w=j&c;break}if(c>>>0>>0){v=r;w=c}else{v=r;w=(c>>>0)%(r>>>0)|0}}else{v=d;w=k}while(0);k=(f[a>>2]|0)+(w<<2)|0;w=f[k>>2]|0;if(!w){d=a+8|0;f[q>>2]=f[d>>2];f[d>>2]=q;f[k>>2]=d;d=f[q>>2]|0;if(d|0){k=f[d+4>>2]|0;d=v+-1|0;if(d&v)if(k>>>0>>0)x=k;else x=(k>>>0)%(v>>>0)|0;else x=k&d;y=(f[a>>2]|0)+(x<<2)|0;z=30}}else{f[q>>2]=f[w>>2];y=w;z=30}if((z|0)==30)f[y>>2]=q;f[i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c+92|0;f[g>>2]=f[d>>2];g=c+96|0;f[a+96>>2]=f[g>>2];f[g>>2]=0;f[d>>2]=0;f[e>>2]=0;b[a+100>>0]=b[c+100>>0]|0;e=a+104|0;d=c+104|0;f[e>>2]=0;g=a+108|0;f[g>>2]=0;f[a+112>>2]=0;f[e>>2]=f[d>>2];e=c+108|0;f[g>>2]=f[e>>2];g=c+112|0;f[a+112>>2]=f[g>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;d=a+116|0;e=c+116|0;f[d>>2]=0;g=a+120|0;f[g>>2]=0;f[a+124>>2]=0;f[d>>2]=f[e>>2];d=c+120|0;f[g>>2]=f[d>>2];g=c+124|0;f[a+124>>2]=f[g>>2];f[g>>2]=0;f[d>>2]=0;f[e>>2]=0;f[a+128>>2]=f[c+128>>2];e=a+132|0;d=c+132|0;f[e>>2]=0;g=a+136|0;f[g>>2]=0;f[a+140>>2]=0;f[e>>2]=f[d>>2];e=c+136|0;f[g>>2]=f[e>>2];g=c+140|0;f[a+140>>2]=f[g>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;return}function Vc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+32|0;g=e+8|0;i=e;switch(d|0){case 2:{d=f[b+12>>2]|0;j=f[b+4>>2]|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;a:do if((c|0)==-2){k=0;l=8}else{m=f[(f[(f[j+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((Ma[f[(f[j>>2]|0)+8>>2]&127](j)|0)==1){Cd(i,j,c,d,g,((h[j+36>>0]|0)<<8|(h[j+37>>0]|0))&65535);n=f[i>>2]|0;if(!n){f[i>>2]=0;break}else{o=n;p=i;break a}}while(0);n=Yk(24)|0;f[n+4>>2]=m;q=n+8|0;f[q>>2]=f[g>>2];f[q+4>>2]=f[g+4>>2];f[q+8>>2]=f[g+8>>2];f[q+12>>2]=f[g+12>>2];f[n>>2]=2436;k=n;l=8}while(0);if((l|0)==8){f[i>>2]=k;o=k;p=i}f[a>>2]=o;f[p>>2]=0;u=e;return}case 3:{p=f[b+12>>2]|0;o=f[b+4>>2]|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;b:do if((c|0)==-2){r=0;l=16}else{b=f[(f[(f[o+4>>2]|0)+8>>2]|0)+(p<<2)>>2]|0;do if((Ma[f[(f[o>>2]|0)+8>>2]&127](o)|0)==1){Bd(i,o,c,p,g,((h[o+36>>0]|0)<<8|(h[o+37>>0]|0))&65535);k=f[i>>2]|0;if(!k){f[i>>2]=0;break}else{s=k;t=i;break b}}while(0);m=Yk(24)|0;f[m+4>>2]=b;k=m+8|0;f[k>>2]=f[g>>2];f[k+4>>2]=f[g+4>>2];f[k+8>>2]=f[g+8>>2];f[k+12>>2]=f[g+12>>2];f[m>>2]=2492;r=m;l=16}while(0);if((l|0)==16){f[i>>2]=r;s=r;t=i}f[a>>2]=s;f[t>>2]=0;u=e;return}default:{f[a>>2]=0;u=e;return}}}function Wc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+16|0;h=d+4|0;i=d;j=a+60|0;f[a+64>>2]=g;g=a+8|0;f[g>>2]=e;k=a+32|0;l=a+36|0;m=f[l>>2]|0;n=f[k>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=e>>>0){if(o>>>0>e>>>0?(m=p+(e<<2)|0,(n|0)!=(m|0)):0)f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2)}else Og(k,e-o|0);o=a+56|0;k=f[o>>2]|0;m=f[k+4>>2]|0;n=f[k>>2]|0;l=m-n|0;p=l>>2;if((l|0)<=0){q=1;u=d;return q|0}l=a+16|0;r=a+32|0;s=a+12|0;t=a+20|0;if((m|0)==(n|0)){v=k;Eo(v)}else{w=n;x=0}while(1){f[i>>2]=f[w+(x<<2)>>2];f[h>>2]=f[i>>2];if(!(Lb(j,h,c,x)|0)){q=0;y=24;break}n=X(x,e)|0;k=b+(n<<2)|0;m=c+(n<<2)|0;if((f[g>>2]|0)>0){n=0;do{z=f[a+68+(n<<2)>>2]|0;A=f[l>>2]|0;if((z|0)>(A|0)){B=f[r>>2]|0;f[B+(n<<2)>>2]=A;C=B}else{B=f[s>>2]|0;A=f[r>>2]|0;f[A+(n<<2)>>2]=(z|0)<(B|0)?B:z;C=A}n=n+1|0;D=f[g>>2]|0}while((n|0)<(D|0));if((D|0)>0){n=0;do{A=(f[k+(n<<2)>>2]|0)+(f[C+(n<<2)>>2]|0)|0;z=m+(n<<2)|0;f[z>>2]=A;if((A|0)<=(f[l>>2]|0)){if((A|0)<(f[s>>2]|0)){E=(f[t>>2]|0)+A|0;y=20}}else{E=A-(f[t>>2]|0)|0;y=20}if((y|0)==20){y=0;f[z>>2]=E}n=n+1|0}while((n|0)<(f[g>>2]|0))}}x=x+1|0;if((x|0)>=(p|0)){q=1;y=24;break}n=f[o>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=x>>>0){v=n;y=8;break}}if((y|0)==8)Eo(v);else if((y|0)==24){u=d;return q|0}return 0}function Xc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+16|0;h=d+4|0;i=d;j=a+60|0;f[a+64>>2]=g;g=a+8|0;f[g>>2]=e;k=a+32|0;l=a+36|0;m=f[l>>2]|0;n=f[k>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=e>>>0){if(o>>>0>e>>>0?(m=p+(e<<2)|0,(n|0)!=(m|0)):0)f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2)}else Og(k,e-o|0);o=a+56|0;k=f[o>>2]|0;m=f[k+4>>2]|0;n=f[k>>2]|0;l=m-n|0;p=l>>2;if((l|0)<=0){q=1;u=d;return q|0}l=a+16|0;r=a+32|0;s=a+12|0;t=a+20|0;if((m|0)==(n|0)){v=k;Eo(v)}else{w=n;x=0}while(1){f[i>>2]=f[w+(x<<2)>>2];f[h>>2]=f[i>>2];if(!(Kb(j,h,c,x)|0)){q=0;y=24;break}n=X(x,e)|0;k=b+(n<<2)|0;m=c+(n<<2)|0;if((f[g>>2]|0)>0){n=0;do{z=f[a+68+(n<<2)>>2]|0;A=f[l>>2]|0;if((z|0)>(A|0)){B=f[r>>2]|0;f[B+(n<<2)>>2]=A;C=B}else{B=f[s>>2]|0;A=f[r>>2]|0;f[A+(n<<2)>>2]=(z|0)<(B|0)?B:z;C=A}n=n+1|0;D=f[g>>2]|0}while((n|0)<(D|0));if((D|0)>0){n=0;do{A=(f[k+(n<<2)>>2]|0)+(f[C+(n<<2)>>2]|0)|0;z=m+(n<<2)|0;f[z>>2]=A;if((A|0)<=(f[l>>2]|0)){if((A|0)<(f[s>>2]|0)){E=(f[t>>2]|0)+A|0;y=20}}else{E=A-(f[t>>2]|0)|0;y=20}if((y|0)==20){y=0;f[z>>2]=E}n=n+1|0}while((n|0)<(f[g>>2]|0))}}x=x+1|0;if((x|0)>=(p|0)){q=1;y=24;break}n=f[o>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=x>>>0){v=n;y=8;break}}if((y|0)==8)Eo(v);else if((y|0)==24){u=d;return q|0}return 0}function Yc(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;i=u;u=u+32|0;j=i+16|0;k=i+12|0;l=i;m=c+24|0;n=b[m>>0]|0;o=n<<24>>24;p=f[a+80>>2]|0;a=X(p,o)|0;q=f[c+28>>2]|0;if((q|0)==(e|0)|(q|0)==(g|0)?b[c+84>>0]|0:0){g=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;Me(h,g,g+(a<<1)|0);r=1;u=i;return r|0}f[l>>2]=0;g=l+4|0;f[g>>2]=0;f[l+8>>2]=0;do if(n<<24>>24)if(n<<24>>24<0)Eo(l);else{q=o<<1;e=Yk(q)|0;f[l>>2]=e;s=e+(o<<1)|0;f[l+8>>2]=s;Dh(e|0,0,q|0)|0;f[g>>2]=s;break}while(0);Me(h,0,0+(a<<1)|0);a:do if(!p)t=1;else{a=c+84|0;s=c+68|0;if(n<<24>>24>0){v=0;w=0}else{q=0;while(1){if(!(b[a>>0]|0))x=f[(f[s>>2]|0)+(q<<2)>>2]|0;else x=q;e=f[l>>2]|0;f[k>>2]=x;y=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(Cb(c,j,y,e)|0)){t=0;break a}q=q+1|0;if(q>>>0>=p>>>0){t=1;break a}}}while(1){if(!(b[a>>0]|0))z=f[(f[s>>2]|0)+(w<<2)>>2]|0;else z=w;q=f[l>>2]|0;f[k>>2]=z;e=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(Cb(c,j,e,q)|0)){t=0;break a}q=f[l>>2]|0;e=f[h>>2]|0;y=v;A=0;while(1){d[e+(y<<1)>>1]=d[q+(A<<1)>>1]|0;A=A+1|0;if((A|0)==(o|0))break;else y=y+1|0}w=w+1|0;if(w>>>0>=p>>>0){t=1;break}else v=o+v|0}}while(0);v=f[l>>2]|0;if(v|0){l=f[g>>2]|0;if((l|0)!=(v|0))f[g>>2]=l+(~((l+-2-v|0)>>>1)<<1);lp(v)}r=t;u=i;return r|0}function Zc(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;i=u;u=u+32|0;j=i+16|0;k=i+12|0;l=i;m=c+24|0;n=b[m>>0]|0;o=n<<24>>24;p=f[a+80>>2]|0;a=X(p,o)|0;q=f[c+28>>2]|0;if((q|0)==(e|0)|(q|0)==(g|0)?b[c+84>>0]|0:0){g=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;Me(h,g,g+(a<<1)|0);r=1;u=i;return r|0}f[l>>2]=0;g=l+4|0;f[g>>2]=0;f[l+8>>2]=0;do if(n<<24>>24)if(n<<24>>24<0)Eo(l);else{q=o<<1;e=Yk(q)|0;f[l>>2]=e;s=e+(o<<1)|0;f[l+8>>2]=s;Dh(e|0,0,q|0)|0;f[g>>2]=s;break}while(0);Me(h,0,0+(a<<1)|0);a:do if(!p)t=1;else{a=c+84|0;s=c+68|0;if(n<<24>>24>0){v=0;w=0}else{q=0;while(1){if(!(b[a>>0]|0))x=f[(f[s>>2]|0)+(q<<2)>>2]|0;else x=q;e=f[l>>2]|0;f[k>>2]=x;y=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(Db(c,j,y,e)|0)){t=0;break a}q=q+1|0;if(q>>>0>=p>>>0){t=1;break a}}}while(1){if(!(b[a>>0]|0))z=f[(f[s>>2]|0)+(w<<2)>>2]|0;else z=w;q=f[l>>2]|0;f[k>>2]=z;e=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(Db(c,j,e,q)|0)){t=0;break a}q=f[l>>2]|0;e=f[h>>2]|0;y=v;A=0;while(1){d[e+(y<<1)>>1]=d[q+(A<<1)>>1]|0;A=A+1|0;if((A|0)==(o|0))break;else y=y+1|0}w=w+1|0;if(w>>>0>=p>>>0){t=1;break}else v=o+v|0}}while(0);v=f[l>>2]|0;if(v|0){l=f[g>>2]|0;if((l|0)!=(v|0))f[g>>2]=l+(~((l+-2-v|0)>>>1)<<1);lp(v)}r=t;u=i;return r|0}function _c(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;Ne(g,e,e+(a<<2)|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;do if(m<<24>>24)if(m<<24>>24<0)Eo(k);else{p=n<<2;d=Yk(p)|0;f[k>>2]=d;r=d+(n<<2)|0;f[k+8>>2]=r;Dh(d|0,0,p|0)|0;f[e>>2]=r;break}while(0);Ne(g,0,0+(a<<2)|0);a:do if(!o)s=1;else{a=c+84|0;r=c+68|0;if(m<<24>>24>0){t=0;v=0}else{p=0;while(1){if(!(b[a>>0]|0))w=f[(f[r>>2]|0)+(p<<2)>>2]|0;else w=p;d=f[k>>2]|0;f[j>>2]=w;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(Eb(c,i,x,d)|0)){s=0;break a}p=p+1|0;if(p>>>0>=o>>>0){s=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[r>>2]|0)+(v<<2)>>2]|0;else y=v;p=f[k>>2]|0;f[j>>2]=y;d=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(Eb(c,i,d,p)|0)){s=0;break a}p=f[k>>2]|0;d=f[g>>2]|0;x=t;z=0;while(1){f[d+(x<<2)>>2]=f[p+(z<<2)>>2];z=z+1|0;if((z|0)==(n|0))break;else x=x+1|0}v=v+1|0;if(v>>>0>=o>>>0){s=1;break}else t=n+t|0}}while(0);t=f[k>>2]|0;if(t|0){k=f[e>>2]|0;if((k|0)!=(t|0))f[e>>2]=k+(~((k+-4-t|0)>>>2)<<2);lp(t)}q=s;u=h;return q|0}function $c(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;Ne(g,e,e+(a<<2)|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;do if(m<<24>>24)if(m<<24>>24<0)Eo(k);else{p=n<<2;d=Yk(p)|0;f[k>>2]=d;r=d+(n<<2)|0;f[k+8>>2]=r;Dh(d|0,0,p|0)|0;f[e>>2]=r;break}while(0);Ne(g,0,0+(a<<2)|0);a:do if(!o)s=1;else{a=c+84|0;r=c+68|0;if(m<<24>>24>0){t=0;v=0}else{p=0;while(1){if(!(b[a>>0]|0))w=f[(f[r>>2]|0)+(p<<2)>>2]|0;else w=p;d=f[k>>2]|0;f[j>>2]=w;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(Fb(c,i,x,d)|0)){s=0;break a}p=p+1|0;if(p>>>0>=o>>>0){s=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[r>>2]|0)+(v<<2)>>2]|0;else y=v;p=f[k>>2]|0;f[j>>2]=y;d=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(Fb(c,i,d,p)|0)){s=0;break a}p=f[k>>2]|0;d=f[g>>2]|0;x=t;z=0;while(1){f[d+(x<<2)>>2]=f[p+(z<<2)>>2];z=z+1|0;if((z|0)==(n|0))break;else x=x+1|0}v=v+1|0;if(v>>>0>=o>>>0){s=1;break}else t=n+t|0}}while(0);t=f[k>>2]|0;if(t|0){k=f[e>>2]|0;if((k|0)!=(t|0))f[e>>2]=k+(~((k+-4-t|0)>>>2)<<2);lp(t)}q=s;u=h;return q|0}function ad(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;e=c+8|0;g=f[e+4>>2]|0;h=c+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if(!((g|0)>(k|0)|((g|0)==(k|0)?(f[e>>2]|0)>>>0>j>>>0:0))){l=0;return l|0}e=b[(f[c>>2]|0)+j>>0]|0;g=Ul(j|0,k|0,1,0)|0;k=h;f[k>>2]=g;f[k+4>>2]=I;do switch(e<<24>>24){case 1:{l=me(a,c,d)|0;return l|0}case 2:{l=me(a,c,d)|0;return l|0}case 3:{l=me(a,c,d)|0;return l|0}case 4:{l=me(a,c,d)|0;return l|0}case 5:{l=me(a,c,d)|0;return l|0}case 6:{l=me(a,c,d)|0;return l|0}case 7:{l=me(a,c,d)|0;return l|0}case 8:{l=me(a,c,d)|0;return l|0}case 9:{l=le(a,c,d)|0;return l|0}case 10:{l=ke(a,c,d)|0;return l|0}case 11:{l=je(a,c,d)|0;return l|0}case 12:{l=ie(a,c,d)|0;return l|0}case 13:{l=he(a,c,d)|0;return l|0}case 14:{l=ge(a,c,d)|0;return l|0}case 15:{l=ge(a,c,d)|0;return l|0}case 16:{l=ge(a,c,d)|0;return l|0}case 17:{l=ge(a,c,d)|0;return l|0}case 18:{l=ge(a,c,d)|0;return l|0}default:{l=0;return l|0}}while(0);return 0}function bd(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;df(g,e,e+a|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;if(m<<24>>24){if(m<<24>>24<0)Eo(k);p=Yk(n)|0;f[e>>2]=p;f[k>>2]=p;f[k+8>>2]=p+n;d=p;p=n;do{b[d>>0]=0;d=(f[e>>2]|0)+1|0;f[e>>2]=d;p=p+-1|0}while((p|0)!=0)}df(g,0,0+a|0);a:do if(!o)r=1;else{a=c+84|0;p=c+68|0;if(m<<24>>24>0){s=0;t=0}else{d=0;while(1){if(!(b[a>>0]|0))v=f[(f[p>>2]|0)+(d<<2)>>2]|0;else v=d;w=f[k>>2]|0;f[j>>2]=v;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(Hb(c,i,x,w)|0)){r=0;break a}d=d+1|0;if(d>>>0>=o>>>0){r=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[p>>2]|0)+(t<<2)>>2]|0;else y=t;d=f[k>>2]|0;f[j>>2]=y;w=b[l>>0]|0;f[i>>2]=f[j>>2];if(Hb(c,i,w,d)|0){z=s;A=0}else{r=0;break a}while(1){b[(f[g>>2]|0)+z>>0]=b[(f[k>>2]|0)+A>>0]|0;A=A+1|0;if((A|0)==(n|0))break;else z=z+1|0}t=t+1|0;if(t>>>0>=o>>>0){r=1;break}else s=n+s|0}}while(0);s=f[k>>2]|0;if(s|0){if((f[e>>2]|0)!=(s|0))f[e>>2]=s;lp(s)}q=r;u=h;return q|0}function cd(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;df(g,e,e+a|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;if(m<<24>>24){if(m<<24>>24<0)Eo(k);p=Yk(n)|0;f[e>>2]=p;f[k>>2]=p;f[k+8>>2]=p+n;d=p;p=n;do{b[d>>0]=0;d=(f[e>>2]|0)+1|0;f[e>>2]=d;p=p+-1|0}while((p|0)!=0)}df(g,0,0+a|0);a:do if(!o)r=1;else{a=c+84|0;p=c+68|0;if(m<<24>>24>0){s=0;t=0}else{d=0;while(1){if(!(b[a>>0]|0))v=f[(f[p>>2]|0)+(d<<2)>>2]|0;else v=d;w=f[k>>2]|0;f[j>>2]=v;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(Ib(c,i,x,w)|0)){r=0;break a}d=d+1|0;if(d>>>0>=o>>>0){r=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[p>>2]|0)+(t<<2)>>2]|0;else y=t;d=f[k>>2]|0;f[j>>2]=y;w=b[l>>0]|0;f[i>>2]=f[j>>2];if(Ib(c,i,w,d)|0){z=s;A=0}else{r=0;break a}while(1){b[(f[g>>2]|0)+z>>0]=b[(f[k>>2]|0)+A>>0]|0;A=A+1|0;if((A|0)==(n|0))break;else z=z+1|0}t=t+1|0;if(t>>>0>=o>>>0){r=1;break}else s=n+s|0}}while(0);s=f[k>>2]|0;if(s|0){if((f[e>>2]|0)!=(s|0))f[e>>2]=s;lp(s)}q=r;u=h;return q|0}function dd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+32|0;e=d+16|0;g=d;if((j[c+38>>1]|0)<514){i=c+8|0;k=f[i+4>>2]|0;l=c+16|0;m=l;n=f[m>>2]|0;o=f[m+4>>2]|0;if(!((k|0)>(o|0)|((k|0)==(o|0)?(f[i>>2]|0)>>>0>n>>>0:0))){p=0;u=d;return p|0}i=b[(f[c>>2]|0)+n>>0]|0;k=Ul(n|0,o|0,1,0)|0;o=l;f[o>>2]=k;f[o+4>>2]=I;if(i<<24>>24){p=0;u=d;return p|0}}i=0;do{Ph(e,c)|0;o=f[e>>2]|0;if(o|0){k=a+60+(i*12|0)|0;gd(k,o,0);Ym(g);if(!(ud(g,c)|0)){q=12;break}if(f[e>>2]|0){o=0;do{l=Pi(g)|0;n=(f[k>>2]|0)+(o>>>5<<2)|0;m=1<<(o&31);r=f[n>>2]|0;f[n>>2]=l?r|m:r&~m;o=o+1|0}while(o>>>0<(f[e>>2]|0)>>>0)}qp(g)}i=i+1|0}while((i|0)<4);if((q|0)==12){qp(g);p=0;u=d;return p|0}g=c+8|0;q=f[g>>2]|0;i=f[g+4>>2]|0;g=c+16|0;e=g;o=f[e>>2]|0;k=f[e+4>>2]|0;e=Ul(o|0,k|0,4,0)|0;m=I;if((i|0)<(m|0)|(i|0)==(m|0)&q>>>0>>0){p=0;u=d;return p|0}r=f[c>>2]|0;c=r+o|0;l=h[c>>0]|h[c+1>>0]<<8|h[c+2>>0]<<16|h[c+3>>0]<<24;c=g;f[c>>2]=e;f[c+4>>2]=m;m=Ul(o|0,k|0,8,0)|0;k=I;if((i|0)<(k|0)|(i|0)==(k|0)&q>>>0>>0){p=0;u=d;return p|0}q=r+e|0;e=h[q>>0]|h[q+1>>0]<<8|h[q+2>>0]<<16|h[q+3>>0]<<24;q=g;f[q>>2]=m;f[q+4>>2]=k;if((l|0)>(e|0)){p=0;u=d;return p|0}f[a+12>>2]=l;f[a+16>>2]=e;k=Wl(e|0,((e|0)<0)<<31>>31|0,l|0,((l|0)<0)<<31>>31|0)|0;l=I;if(!(l>>>0<0|(l|0)==0&k>>>0<2147483647)){p=0;u=d;return p|0}l=k+1|0;f[a+20>>2]=l;k=(l|0)/2|0;e=a+24|0;f[e>>2]=k;f[a+28>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l=f[i>>2]|0;f[k>>2]=l;return}p=f[y>>2]&-1>>>(32-z|0);y=(q|0)<(z|0)?q:z;n=f[d>>2]|0;w=f[n>>2]&~(-1<>2]&-1>>>(q-y|0));f[n>>2]=w;f[n>>2]=w|p<>2];w=(f[o>>2]|0)+y|0;q=n+(w>>>5<<2)|0;f[d>>2]=q;f[o>>2]=w&31;w=z-y|0;if((w|0)<=0){i=o;j=f[d>>2]|0;f[a>>2]=j;k=a+4|0;l=f[i>>2]|0;f[k>>2]=l;return}f[q>>2]=f[q>>2]&~(-1>>>(32-w|0))|p>>>y;f[o>>2]=w;i=o;j=f[d>>2]|0;f[a>>2]=j;k=a+4|0;l=f[i>>2]|0;f[k>>2]=l;return}function fd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+32|0;d=c+16|0;e=c;f[d>>2]=0;do if((j[b+38>>1]|0)<514){g=b+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=b+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,4,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=c;return o|0}else{i=(f[b>>2]|0)+m|0;m=h[i>>0]|h[i+1>>0]<<8|h[i+2>>0]<<16|h[i+3>>0]<<24;f[d>>2]=m;i=g;f[i>>2]=n;f[i+4>>2]=l;p=m;break}}else if(Ph(d,b)|0){p=f[d>>2]|0;break}else{o=0;u=c;return o|0}while(0);if(!p){o=0;u=c;return o|0}m=a+76|0;gd(m,p,0);Ym(e);if(ud(e,b)|0){if(f[d>>2]|0){p=0;l=1;do{l=l^((Pi(e)|0)^1);i=(f[m>>2]|0)+(p>>>5<<2)|0;n=1<<(p&31);g=f[i>>2]|0;f[i>>2]=l?g|n:g&~n;p=p+1|0}while(p>>>0<(f[d>>2]|0)>>>0)}d=b+8|0;p=f[d>>2]|0;l=f[d+4>>2]|0;d=b+16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;f[p>>2]=c;j=p;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}function id(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+4194304|0;f[a+48>>2]=x;o=x>>>0<1073741824;u=d;return o|0}function jd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+2097152|0;f[a+48>>2]=x;o=x>>>0<536870912;u=d;return o|0}function kd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+1048576|0;f[a+48>>2]=x;o=x>>>0<268435456;u=d;return o|0}function ld(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+262144|0;f[a+48>>2]=x;o=x>>>0<67108864;u=d;return o|0}function md(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+131072|0;f[a+48>>2]=x;o=x>>>0<33554432;u=d;return o|0}function nd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+32768|0;f[a+48>>2]=x;o=x>>>0<8388608;u=d;return o|0}function od(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d;do if((j[c+38>>1]|0)<512){g=c+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=c+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+4>>2]|0,8,0)|0;l=I;if((k|0)<(l|0)|(k|0)==(l|0)&i>>>0>>0){o=0;u=d;return o|0}else{p=(f[c>>2]|0)+m|0;m=p;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=p+4|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=e;f[m>>2]=q;f[m+4>>2]=p;m=g;f[m>>2]=n;f[m+4>>2]=l;r=i;s=k;t=n;v=l;w=p;x=q;y=g;break}}else if(nh(e,c)|0){g=e;q=c+8|0;p=c+16|0;l=p;r=f[q>>2]|0;s=f[q+4>>2]|0;t=f[l>>2]|0;v=f[l+4>>2]|0;w=f[g+4>>2]|0;x=f[g>>2]|0;y=p;break}else{o=0;u=d;return o|0}while(0);e=Wl(r|0,s|0,t|0,v|0)|0;s=I;if(w>>>0>s>>>0|(w|0)==(s|0)&x>>>0>e>>>0){o=0;u=d;return o|0}e=(f[c>>2]|0)+t|0;c=Ul(t|0,v|0,x|0,w|0)|0;w=y;f[w>>2]=c;f[w+4>>2]=I;if((x|0)<1){o=0;u=d;return o|0}f[a+40>>2]=e;w=x+-1|0;c=e+w|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=w;z=b[c>>0]&63;break}case 1:{if((x|0)<2){o=0;u=d;return o|0}else{f[a+44>>2]=x+-2;y=e+x+-2|0;z=(h[y+1>>0]|0)<<8&16128|(h[y>>0]|0);break a}break}case 2:{if((x|0)<3){o=0;u=d;return o|0}else{f[a+44>>2]=x+-3;y=e+x+-3|0;z=(h[y+1>>0]|0)<<8|(h[y>>0]|0)|(h[y+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=x+-4;y=e+x+-4|0;z=(h[y+2>>0]|0)<<16|(h[y+3>>0]|0)<<24&1056964608|(h[y+1>>0]|0)<<8|(h[y>>0]|0);break}default:{}}while(0);x=z+16384|0;f[a+48>>2]=x;o=x>>>0<4194304;u=d;return o|0}function pd(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c=a+32|0;d=f[c>>2]|0;e=d+8|0;g=f[e+4>>2]|0;h=d+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if(!((g|0)>(k|0)|((g|0)==(k|0)?(f[e>>2]|0)>>>0>j>>>0:0))){l=0;return l|0}e=b[(f[d>>2]|0)+j>>0]|0;d=Ul(j|0,k|0,1,0)|0;k=h;f[k>>2]=d;f[k+4>>2]=I;k=e&255;d=e<<24>>24==0;a:do if(!d){e=0;while(1){if(!(Na[f[(f[a>>2]|0)+16>>2]&127](a,e)|0)){l=0;break}e=e+1|0;if((e|0)>=(k|0))break a}return l|0}while(0);e=a+8|0;h=f[e>>2]|0;j=f[a+12>>2]|0;b:do if((h|0)!=(j|0)){g=a+4|0;i=h;while(1){m=f[i>>2]|0;i=i+4|0;if(!(Oa[f[(f[m>>2]|0)+8>>2]&31](m,a,f[g>>2]|0)|0)){l=0;break}if((i|0)==(j|0))break b}return l|0}while(0);if(!d){j=0;do{h=f[(f[e>>2]|0)+(j<<2)>>2]|0;j=j+1|0;if(!(Na[f[(f[h>>2]|0)+12>>2]&127](h,f[c>>2]|0)|0)){l=0;n=26;break}}while((j|0)<(k|0));if((n|0)==26)return l|0;if(!d){d=a+20|0;n=a+24|0;j=0;do{c=f[(f[e>>2]|0)+(j<<2)>>2]|0;h=Ma[f[(f[c>>2]|0)+24>>2]&127](c)|0;if((h|0)>0){c=0;do{i=f[(f[e>>2]|0)+(j<<2)>>2]|0;g=Na[f[(f[i>>2]|0)+20>>2]&127](i,c)|0;i=f[n>>2]|0;m=f[d>>2]|0;o=i-m>>2;p=m;do if(g>>>0>=o>>>0){m=g+1|0;q=i;if(m>>>0>o>>>0){Og(d,m-o|0);r=f[d>>2]|0;break}if(m>>>0>>0?(s=p+(m<<2)|0,(q|0)!=(s|0)):0){f[n>>2]=q+(~((q+-4-s|0)>>>2)<<2);r=p}else r=p}else r=p;while(0);f[r+(g<<2)>>2]=j;c=c+1|0}while((c|0)!=(h|0))}j=j+1|0}while((j|0)!=(k|0))}}if(!(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)){l=0;return l|0}l=Ma[f[(f[a>>2]|0)+32>>2]&127](a)|0;return l|0}function qd(a){a=a|0;var b=0,c=0,d=0,e=0;f[a>>2]=3072;b=a+368|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+-4|0;d=f[b>>2]|0;if(d|0){e=c+(d<<4)|0;do{e=e+-16|0;qp(e)}while((e|0)!=(c|0))}jp(b)}qp(a+352|0);qp(a+312|0);qp(a+296|0);qp(a+256|0);Pg(a+216|0);b=f[a+196>>2]|0;if(b|0){c=a+200|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);lp(b)}b=f[a+184>>2]|0;if(b|0){e=a+188|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+172>>2]|0;if(b|0){c=a+176|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);lp(b)}b=f[a+160>>2]|0;if(b|0){e=a+164|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+144>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;lp(b)}while((c|0)!=0)}c=a+136|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)lp(b);b=f[a+120>>2]|0;if(b|0)lp(b);b=f[a+108>>2]|0;if(b|0)lp(b);b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);lp(b)}b=f[a+60>>2]|0;if(b|0)lp(b);b=f[a+48>>2]|0;if(b|0){e=a+52|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+36>>2]|0;if(b|0){c=a+40|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~(((e+-12-b|0)>>>0)/12|0)*12|0);lp(b)}b=f[a+24>>2]|0;if(b|0){e=a+28|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+12>>2]|0;if(b|0){c=a+16|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);lp(b)}b=a+8|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Vg(a);lp(a);return}function rd(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;c=u;u=u+16|0;d=c;e=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;if((e|0)<=0){g=1;u=c;return g|0}h=a+36|0;i=a+48|0;j=d+8|0;k=d+4|0;l=d+11|0;m=0;while(1){n=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+40|0;if((f[n>>2]|0)!=0?(n=f[(f[h>>2]|0)+(m<<2)>>2]|0,o=f[n+8>>2]|0,p=kg(n)|0,(p|0)!=0):0){n=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+40|0;q=f[n>>2]|0;n=f[o+56>>2]|0;o=Yk(32)|0;f[d>>2]=o;f[j>>2]=-2147483616;f[k>>2]=24;r=o;s=11771;t=r+24|0;do{b[r>>0]=b[s>>0]|0;r=r+1|0;s=s+1|0}while((r|0)<(t|0));b[o+24>>0]=0;s=q+16|0;r=f[s>>2]|0;if(r){t=s;v=r;a:while(1){r=v;while(1){if((f[r+16>>2]|0)>=(n|0))break;w=f[r+4>>2]|0;if(!w){x=t;break a}else r=w}v=f[r>>2]|0;if(!v){x=r;break}else t=r}if(((x|0)!=(s|0)?(n|0)>=(f[x+16>>2]|0):0)?(t=x+20|0,(hg(t,d)|0)!=0):0)y=hi(t,d,0)|0;else z=14}else z=14;if((z|0)==14){z=0;y=hi(q,d,0)|0}if((b[l>>0]|0)<0)lp(f[d>>2]|0);if(y)Zd(f[(f[(f[h>>2]|0)+(m<<2)>>2]|0)+8>>2]|0,p);else z=19}else z=19;if((z|0)==19?(z=0,t=f[(f[h>>2]|0)+(m<<2)>>2]|0,!(Na[f[(f[t>>2]|0)+24>>2]&127](t,i)|0)):0){g=0;z=21;break}m=m+1|0;if((m|0)>=(e|0)){g=1;z=21;break}}if((z|0)==21){u=c;return g|0}return 0}function sd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;e=u;u=u+32|0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|0==(g|0)&x>>>0>e>>>0)?(e=(f[c>>2]|0)+v|0,(x|0)>=1):0){f[a>>2]=e;g=x+-1|0;n=e+g|0;switch((h[n>>0]|0)>>>6&3){case 0:{f[a+4>>2]=g;z=b[n>>0]&63;break}case 1:{if((x|0)<2){r=0;break a}f[a+4>>2]=x+-2;n=e+x+-2|0;z=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((x|0)<3){r=0;break a}f[a+4>>2]=x+-3;n=e+x+-3|0;z=(h[n+1>>0]|0)<<8|(h[n>>0]|0)|(h[n+2>>0]|0)<<16&4128768;break}default:{r=0;break a}}n=z+4096|0;f[a+8>>2]=n;if(n>>>0<=1048575){n=Ul(v|0,w|0,x|0,0)|0;e=l;f[e>>2]=n;f[e+4>>2]=I;r=1}else r=0}else r=0}while(0);p=r;u=d;return p|0}function vd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+32|0;e=d;g=a+8|0;h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;if(((h-j|0)/144|0)>>>0>=c>>>0){k=j;l=c;do{f[k>>2]=-1;Ti(k+4|0);b[k+100>>0]=1;m=k+104|0;n=m+40|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(n|0));k=(f[i>>2]|0)+144|0;f[i>>2]=k;l=l+-1|0}while((l|0)!=0);u=d;return}l=f[a>>2]|0;k=(j-l|0)/144|0;j=k+c|0;if(j>>>0>29826161)Eo(a);o=(h-l|0)/144|0;l=o<<1;h=o>>>0<14913080?(l>>>0>>0?j:l):29826161;f[e+12>>2]=0;f[e+16>>2]=a+8;do if(h)if(h>>>0>29826161){l=ra(8)|0;cn(l,13392);f[l>>2]=4748;va(l|0,1128,101)}else{p=Yk(h*144|0)|0;break}else p=0;while(0);f[e>>2]=p;l=p+(k*144|0)|0;k=e+8|0;f[k>>2]=l;j=e+4|0;f[j>>2]=l;o=e+12|0;f[o>>2]=p+(h*144|0);h=l;l=c;do{f[h>>2]=-1;Ti(h+4|0);b[h+100>>0]=1;m=h+104|0;n=m+40|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(n|0));h=(f[k>>2]|0)+144|0;f[k>>2]=h;l=l+-1|0}while((l|0)!=0);l=f[a>>2]|0;h=f[i>>2]|0;if((h|0)==(l|0)){q=j;r=f[j>>2]|0;s=l;t=h}else{m=f[j>>2]|0;n=h;do{m=m+-144|0;n=n+-144|0;Uc(m,n)}while((n|0)!=(l|0));f[j>>2]=m;q=j;r=m;s=f[a>>2]|0;t=f[i>>2]|0}f[a>>2]=r;f[q>>2]=s;f[i>>2]=f[k>>2];f[k>>2]=t;t=f[g>>2]|0;f[g>>2]=f[o>>2];f[o>>2]=t;f[e>>2]=f[q>>2];Ug(e);u=d;return}function wd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=(c|0)==(a|0);b[c+12>>0]=d&1;if(d)return;else e=c;while(1){g=f[e+8>>2]|0;c=g+12|0;if(b[c>>0]|0){h=23;break}i=g+8|0;j=f[i>>2]|0;d=f[j>>2]|0;if((d|0)==(g|0)){k=f[j+4>>2]|0;if(!k){h=7;break}l=k+12|0;if(!(b[l>>0]|0))m=l;else{h=7;break}}else{if(!d){h=16;break}l=d+12|0;if(!(b[l>>0]|0))m=l;else{h=16;break}}b[c>>0]=1;c=(j|0)==(a|0);b[j+12>>0]=c&1;b[m>>0]=1;if(c){h=23;break}else e=j}if((h|0)==7){if((f[g>>2]|0)==(e|0)){n=g;o=j}else{m=g+4|0;a=f[m>>2]|0;c=f[a>>2]|0;f[m>>2]=c;if(!c)p=j;else{f[c+8>>2]=g;p=f[i>>2]|0}f[a+8>>2]=p;p=f[i>>2]|0;f[((f[p>>2]|0)==(g|0)?p:p+4|0)>>2]=a;f[a>>2]=g;f[i>>2]=a;n=a;o=f[a+8>>2]|0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=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;s=0;do{if(!(ud(a+16+(s<<4)|0,c)|0)){r=0;t=17;break}s=s+1|0}while((s|0)<32);if((t|0)==17)return r|0;if(!(ud(a+528|0,c)|0)){r=0;return r|0}if(!(ze(a+544|0,c)|0)){r=0;return r|0}if(!(ze(a+564|0,c)|0)){r=0;return r|0}if(ze(a+584|0,c)|0)return mb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function yd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=c+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;s=0;do{if(!(ud(a+16+(s<<4)|0,c)|0)){r=0;t=17;break}s=s+1|0}while((s|0)<32);if((t|0)==17)return r|0;if(!(ud(a+528|0,c)|0)){r=0;return r|0}if(!(ze(a+544|0,c)|0)){r=0;return r|0}if(!(ze(a+564|0,c)|0)){r=0;return r|0}if(ze(a+584|0,c)|0)return ob(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function zd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=c+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;s=0;do{if(!(ud(a+16+(s<<4)|0,c)|0)){r=0;t=17;break}s=s+1|0}while((s|0)<32);if((t|0)==17)return r|0;if(!(ud(a+528|0,c)|0)){r=0;return r|0}if(!(ze(a+544|0,c)|0)){r=0;return r|0}if(!(ze(a+564|0,c)|0)){r=0;return r|0}if(ze(a+584|0,c)|0)return nb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function Ad(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=u;u=u+16|0;d=c;e=b+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=b+16|0;k=g;l=f[k>>2]|0;m=Ul(l|0,f[k+4>>2]|0,4,0)|0;k=I;if((j|0)<(k|0)|(j|0)==(k|0)&i>>>0>>0){n=0;u=c;return n|0}i=(f[b>>2]|0)+l|0;l=h[i>>0]|h[i+1>>0]<<8|h[i+2>>0]<<16|h[i+3>>0]<<24;i=g;f[i>>2]=m;f[i+4>>2]=k;if((l|0)<0){n=0;u=c;return n|0}gd(a+76|0,l,0);Ym(d);if(ud(d,b)|0){if((l|0)>0){k=a+76|0;i=0;m=1;do{m=m^((Pi(d)|0)^1);j=(f[k>>2]|0)+(i>>>5<<2)|0;o=1<<(i&31);p=f[j>>2]|0;f[j>>2]=m?p|o:p&~o;i=i+1|0}while((i|0)<(l|0))}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2];f[m+4>>2]=f[e+4>>2];f[m+8>>2]=f[e+8>>2];f[m+12>>2]=f[e+12>>2];f[c+24>>2]=d;f[c+28>>2]=i;f[c+32>>2]=b;f[c+36>>2]=j;f[c>>2]=2632;f[c+44>>2]=0;f[c+48>>2]=0;f[c+52>>2]=d;f[c+56>>2]=i;f[c+60>>2]=b;f[c+64>>2]=j;f[c+40>>2]=2688;f[c+68>>2]=1;i=c+72|0;f[i>>2]=-1;f[i+4>>2]=-1;f[i+8>>2]=-1;f[i+12>>2]=-1;Ym(c+88|0);h=c;f[a>>2]=h;return}}else if(l){l=Yk(104)|0;f[l+4>>2]=g;g=l+8|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[g+12>>2]=f[e+12>>2];f[l+24>>2]=d;f[l+28>>2]=k;f[l+32>>2]=b;f[l+36>>2]=j;f[l>>2]=2548;f[l+44>>2]=0;f[l+48>>2]=0;f[l+52>>2]=d;f[l+56>>2]=k;f[l+60>>2]=b;f[l+64>>2]=j;f[l+40>>2]=2604;f[l+68>>2]=1;j=l+72|0;f[j>>2]=-1;f[j+4>>2]=-1;f[j+8>>2]=-1;f[j+12>>2]=-1;Ym(l+88|0);h=l;f[a>>2]=h;return}f[a>>2]=0;f[a>>2]=0;h=0;f[a>>2]=h;return}function Cd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0;g=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;if(!((c+-1|0)>>>0<6&(Ma[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1)){h=0;f[a>>2]=h;return}i=Ma[f[(f[b>>2]|0)+36>>2]&127](b)|0;j=Na[f[(f[b>>2]|0)+44>>2]&127](b,d)|0;if((i|0)==0|(j|0)==0){h=0;f[a>>2]=h;return}k=Na[f[(f[b>>2]|0)+40>>2]&127](b,d)|0;d=f[b+44>>2]|0;b=j+12|0;l=(c|0)==6;if(!k){if(l){c=Yk(104)|0;f[c+4>>2]=g;m=c+8|0;f[m>>2]=f[e>>2];f[m+4>>2]=f[e+4>>2];f[m+8>>2]=f[e+8>>2];f[m+12>>2]=f[e+12>>2];f[c+24>>2]=d;f[c+28>>2]=i;f[c+32>>2]=b;f[c+36>>2]=j;f[c>>2]=2800;f[c+44>>2]=0;f[c+48>>2]=0;f[c+52>>2]=d;f[c+56>>2]=i;f[c+60>>2]=b;f[c+64>>2]=j;f[c+40>>2]=2856;f[c+68>>2]=1;i=c+72|0;f[i>>2]=-1;f[i+4>>2]=-1;f[i+8>>2]=-1;f[i+12>>2]=-1;Ym(c+88|0);h=c;f[a>>2]=h;return}}else if(l){l=Yk(104)|0;f[l+4>>2]=g;g=l+8|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[g+12>>2]=f[e+12>>2];f[l+24>>2]=d;f[l+28>>2]=k;f[l+32>>2]=b;f[l+36>>2]=j;f[l>>2]=2716;f[l+44>>2]=0;f[l+48>>2]=0;f[l+52>>2]=d;f[l+56>>2]=k;f[l+60>>2]=b;f[l+64>>2]=j;f[l+40>>2]=2772;f[l+68>>2]=1;j=l+72|0;f[j>>2]=-1;f[j+4>>2]=-1;f[j+8>>2]=-1;f[j+12>>2]=-1;Ym(l+88|0);h=l;f[a>>2]=h;return}f[a>>2]=0;f[a>>2]=0;h=0;f[a>>2]=h;return}function Dd(a,c,e){a=a|0;c=c|0;e=e|0;var g=0,h=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;g=u;u=u+32|0;h=g+12|0;i=g;k=c+24|0;l=b[k>>0]|0;m=l<<24>>24;f[h>>2]=0;n=h+4|0;f[n>>2]=0;f[h+8>>2]=0;o=l<<24>>24==0;do if(!o)if(l<<24>>24<0)Eo(h);else{p=m<<1;q=Yk(p)|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g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;s=0;do{if(!(ud(a+16+(s<<4)|0,c)|0)){r=0;t=17;break}s=s+1|0}while((s|0)<32);if((t|0)==17)return r|0;if(!(ud(a+528|0,c)|0)){r=0;return r|0}if(!(ze(a+544|0,c)|0)){r=0;return r|0}if(!(ze(a+564|0,c)|0)){r=0;return r|0}if(ze(a+584|0,c)|0)return fb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function Gd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=c+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;s=0;do{if(!(ud(a+16+(s<<4)|0,c)|0)){r=0;t=17;break}s=s+1|0}while((s|0)<32);if((t|0)==17)return r|0;if(!(ud(a+528|0,c)|0)){r=0;return r|0}if(!(ze(a+544|0,c)|0)){r=0;return r|0}if(!(ze(a+564|0,c)|0)){r=0;return r|0}if(ze(a+584|0,c)|0)return hb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function Hd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=c+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;s=0;do{if(!(ud(a+16+(s<<4)|0,c)|0)){r=0;t=17;break}s=s+1|0}while((s|0)<32);if((t|0)==17)return r|0;if(!(ud(a+528|0,c)|0)){r=0;return r|0}if(!(ze(a+544|0,c)|0)){r=0;return r|0}if(!(ze(a+564|0,c)|0)){r=0;return r|0}if(ze(a+584|0,c)|0)return gb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function Id(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3240;ii(a+232|0);Pg(a+216|0);b=f[a+196>>2]|0;if(b|0){c=a+200|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+184>>2]|0;if(b|0){d=a+188|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+172>>2]|0;if(b|0){c=a+176|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+160>>2]|0;if(b|0){d=a+164|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+144>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;lp(b)}while((c|0)!=0)}c=a+136|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)lp(b);b=f[a+120>>2]|0;if(b|0)lp(b);b=f[a+108>>2]|0;if(b|0)lp(b);b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+60>>2]|0;if(b|0)lp(b);b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+36>>2]|0;if(b|0){c=a+40|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);lp(b)}b=f[a+24>>2]|0;if(b|0){d=a+28|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+12>>2]|0;if(b|0){c=a+16|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+8|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Vg(a);lp(a);return}function Jd(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3288;rf(a+232|0);Pg(a+216|0);b=f[a+196>>2]|0;if(b|0){c=a+200|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+184>>2]|0;if(b|0){d=a+188|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+172>>2]|0;if(b|0){c=a+176|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+160>>2]|0;if(b|0){d=a+164|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+144>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;lp(b)}while((c|0)!=0)}c=a+136|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)lp(b);b=f[a+120>>2]|0;if(b|0)lp(b);b=f[a+108>>2]|0;if(b|0)lp(b);b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+60>>2]|0;if(b|0)lp(b);b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+36>>2]|0;if(b|0){c=a+40|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);lp(b)}b=f[a+24>>2]|0;if(b|0){d=a+28|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+12>>2]|0;if(b|0){c=a+16|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+8|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Vg(a);lp(a);return}function Kd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+16|0;d=c;e=a+40|0;g=e;h=a;i=g+40|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));if(Af(e,1,d)|0){g=a;h=e;i=g+40|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));e=d;k=f[e>>2]|0;l=f[e+4>>2]|0;e=a+8|0;m=e;n=a+16|0;o=n;p=f[o>>2]|0;q=f[o+4>>2]|0;o=Wl(f[m>>2]|0,f[m+4>>2]|0,p|0,q|0)|0;m=I;if(!(l>>>0>m>>>0|(l|0)==(m|0)&k>>>0>o>>>0)){o=Ul(p|0,q|0,k|0,l|0)|0;l=n;f[l>>2]=o;f[l+4>>2]=I;do if((j[a+38>>1]|0)>=514){if(!(ud(a+80|0,a)|0)){r=0;u=c;return r|0}}else{l=a+96|0;g=l;h=a;i=g+40|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));if(Af(l,1,d)|0){g=a;h=l;i=g+40|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));l=d;o=f[l>>2]|0;k=f[l+4>>2]|0;l=e;q=n;p=f[q>>2]|0;m=f[q+4>>2]|0;q=Wl(f[l>>2]|0,f[l+4>>2]|0,p|0,m|0)|0;l=I;if(!(k>>>0>l>>>0|(k|0)==(l|0)&o>>>0>q>>>0)){q=Ul(p|0,m|0,o|0,k|0)|0;k=n;f[k>>2]=q;f[k+4>>2]=I;break}}r=0;u=c;return r|0}while(0);if(!(Zg(a)|0)){r=0;u=c;return r|0}g=b;h=a;i=g+40|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));r=1;u=c;return r|0}}r=0;u=c;return r|0}function Ld(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d;if(!(bc(a,c)|0)){g=0;u=d;return g|0}h=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;i=a+36|0;j=a+40|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0){if(h>>>0>>0?(k=n+(h<<2)|0,(l|0)!=(k|0)):0){n=l;do{l=n+-4|0;f[j>>2]=l;o=f[l>>2]|0;f[l>>2]=0;if(o|0)Ra[f[(f[o>>2]|0)+4>>2]&127](o);n=f[j>>2]|0}while((n|0)!=(k|0))}}else ef(i,h-m|0);m=c+8|0;if((h|0)<=0){g=1;u=d;return g|0}k=c+16|0;n=0;while(1){j=m;o=f[j+4>>2]|0;l=k;p=f[l>>2]|0;q=f[l+4>>2]|0;if(!((o|0)>(q|0)|((o|0)==(q|0)?(f[j>>2]|0)>>>0>p>>>0:0))){g=0;r=19;break}j=b[(f[c>>2]|0)+p>>0]|0;o=Ul(p|0,q|0,1,0)|0;q=k;f[q>>2]=o;f[q+4>>2]=I;Ta[f[(f[a>>2]|0)+48>>2]&15](e,a,j);j=(f[i>>2]|0)+(n<<2)|0;q=f[e>>2]|0;f[e>>2]=0;o=f[j>>2]|0;f[j>>2]=q;if(o|0)Ra[f[(f[o>>2]|0)+4>>2]&127](o);o=f[e>>2]|0;f[e>>2]=0;if(o|0)Ra[f[(f[o>>2]|0)+4>>2]&127](o);o=f[(f[i>>2]|0)+(n<<2)>>2]|0;if(!o){g=0;r=19;break}q=f[(f[o>>2]|0)+8>>2]|0;j=Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0;p=Na[f[(f[a>>2]|0)+20>>2]&127](a,n)|0;n=n+1|0;if(!(Oa[q&31](o,j,p)|0)){g=0;r=19;break}if((n|0)>=(h|0)){g=1;r=19;break}}if((r|0)==19){u=d;return g|0}return 0}function Md(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0;d=u;u=u+16|0;e=d+12|0;g=d;h=Yk(52)|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;n[h+16>>2]=$(1.0);i=h+20|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[h+36>>2]=$(1.0);f[h+40>>2]=0;f[h+44>>2]=0;f[h+48>>2]=0;No(e);if(Cf(e,f[c+32>>2]|0,h)|0){e=(f[c+4>>2]|0)+4|0;c=f[e>>2]|0;f[e>>2]=h;if(c|0){e=c+40|0;i=f[e>>2]|0;if(i|0){j=c+44|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k;do{k=m+-4|0;f[j>>2]=k;o=f[k>>2]|0;f[k>>2]=0;if(o|0){jh(o);lp(o)}m=f[j>>2]|0}while((m|0)!=(i|0));l=f[e>>2]|0}lp(l)}jh(c);lp(c)}f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=d;return}else{f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;c=Yk(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=26;l=c;e=12999;i=l+26|0;do{b[l>>0]=b[e>>0]|0;l=l+1|0;e=e+1|0}while((l|0)<(i|0));b[c+26>>0]=0;f[a>>2]=-1;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);g=h+40|0;a=f[g>>2]|0;if(a|0){c=h+44|0;e=f[c>>2]|0;if((e|0)==(a|0))p=a;else{l=e;do{e=l+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){jh(i);lp(i)}l=f[c>>2]|0}while((l|0)!=(a|0));p=f[g>>2]|0}lp(p)}jh(h);lp(h);u=d;return}}function Nd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+16|0;d=c+4|0;e=c;g=f[b>>2]|0;f[d>>2]=g;b=a+8|0;h=(g|0)==-1;i=g+1|0;do if(!h){f[d+4>>2]=((i>>>0)%3|0|0)==0?g+-2|0:i;if(!((g>>>0)%3|0)){j=g+2|0;break}else{j=g+-1|0;break}}else{f[d+4>>2]=-1;j=-1}while(0);f[d+8>>2]=j;j=h?-1:(g>>>0)/3|0;h=a+216|0;i=a+220|0;k=a+368|0;a=g;g=0;while(1){if((a|0)!=-1?(l=f[(f[(f[b>>2]|0)+12>>2]|0)+(a<<2)>>2]|0,(l|0)!=-1):0){if(((l>>>0)/3|0)>>>0>=j>>>0?(f[i>>2]|0)!=(f[h>>2]|0):0){l=0;do{if(Pi((f[k>>2]|0)+(l<<4)|0)|0){m=f[h>>2]|0;f[e>>2]=a;n=m+(l*144|0)+136|0;o=f[n>>2]|0;if(o>>>0<(f[m+(l*144|0)+140>>2]|0)>>>0){f[o>>2]=a;f[n>>2]=o+4}else dh(m+(l*144|0)+132|0,e)}l=l+1|0}while(l>>>0<(((f[i>>2]|0)-(f[h>>2]|0)|0)/144|0)>>>0)}}else p=10;if((p|0)==10?(p=0,l=f[i>>2]|0,m=f[h>>2]|0,(l|0)!=(m|0)):0){o=l;l=m;m=0;while(1){n=l;f[e>>2]=a;q=n+(m*144|0)+136|0;r=f[q>>2]|0;if(r>>>0<(f[n+(m*144|0)+140>>2]|0)>>>0){f[r>>2]=a;f[q>>2]=r+4;s=l;t=o}else{dh(n+(m*144|0)+132|0,e);s=f[h>>2]|0;t=f[i>>2]|0}m=m+1|0;if(m>>>0>=((t-s|0)/144|0)>>>0)break;else{o=t;l=s}}}l=g+1|0;if((l|0)==3)break;a=f[d+(l<<2)>>2]|0;g=l}u=c;return 1}function Od(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r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[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;if(!(ud(a+16|0,c)|0)){r=0;return r|0}if(!(ze(a+32|0,c)|0)){r=0;return r|0}if(!(ze(a+52|0,c)|0)){r=0;return r|0}if(ze(a+72|0,c)|0)return pb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function Sd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;e=u;u=u+32|0;g=e+8|0;i=e+4|0;j=e;f[g>>2]=0;k=g+4|0;f[k>>2]=0;f[g+8>>2]=0;l=c+8|0;m=f[l>>2]|0;n=f[l+4>>2]|0;l=c+16|0;o=l;p=f[o>>2]|0;q=f[o+4>>2]|0;o=Ul(p|0,q|0,4,0)|0;r=I;a:do if((n|0)<(r|0)|(n|0)==(r|0)&m>>>0>>0)s=0;else{t=f[c>>2]|0;v=t+p|0;w=h[v>>0]|h[v+1>>0]<<8|h[v+2>>0]<<16|h[v+3>>0]<<24;v=l;f[v>>2]=o;f[v+4>>2]=r;b:do switch(w|0){case 3:{if(!((n|0)>(r|0)|(n|0)==(r|0)&m>>>0>o>>>0)){s=0;break a}v=b[t+o>>0]|0;x=Ul(p|0,q|0,5,0)|0;y=l;f[y>>2]=x;f[y+4>>2]=I;f[a+8>>2]=v<<24>>24;if(v<<24>>24==1)if($b(a,c,g)|0)break b;else{s=0;break a}else{oj(4996,23,1,f[906]|0)|0;s=0;break a}break}case 2:{if(!($b(a,c,g)|0)){s=0;break a}break}default:{oj(5020,24,1,f[906]|0)|0;s=0;break a}}while(0);f[i>>2]=f[g>>2];f[j>>2]=f[k>>2];oe(i,j,a,d);s=1}while(0);d=f[g>>2]|0;if(!d){u=e;return s|0}g=f[k>>2]|0;if((g|0)!=(d|0))f[k>>2]=g+(~(((g+-12-d|0)>>>0)/12|0)*12|0);lp(d);u=e;return s|0}function Td(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;f[a>>2]=e;break a;break}case 10:{e=(f[c>>2]|0)+(4-1)&~(4-1);d=f[e>>2]|0;f[c>>2]=e+4;e=a;f[e>>2]=d;f[e+4>>2]=((d|0)<0)<<31>>31;break a;break}case 11:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;d=a;f[d>>2]=e;f[d+4>>2]=0;break a;break}case 12:{d=(f[c>>2]|0)+(8-1)&~(8-1);e=d;g=f[e>>2]|0;h=f[e+4>>2]|0;f[c>>2]=d+8;d=a;f[d>>2]=g;f[d+4>>2]=h;break a;break}case 13:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&65535)<<16>>16;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 14:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&65535;f[h+4>>2]=0;break a;break}case 15:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&255)<<24>>24;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 16:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&255;f[h+4>>2]=0;break a;break}case 17:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}case 18:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}default:break a}while(0);while(0);return}function Ud(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+144|0;g=e+136|0;h=e+32|0;i=e;j=f[(f[c+4>>2]|0)+44>>2]|0;k=Yk(124)|0;f[k+4>>2]=0;f[k>>2]=3172;f[k+12>>2]=3196;f[k+100>>2]=0;f[k+104>>2]=0;f[k+108>>2]=0;l=k+16|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));f[k+112>>2]=j;f[k+116>>2]=d;f[k+120>>2]=0;n=k;f[h+4>>2]=3196;f[h+92>>2]=0;f[h+96>>2]=0;f[h+100>>2]=0;l=h+8|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));l=f[c+8>>2]|0;f[i>>2]=3196;c=i+4|0;m=c+4|0;f[m>>2]=0;f[m+4>>2]=0;f[m+8>>2]=0;f[m+12>>2]=0;f[m+16>>2]=0;f[m+20>>2]=0;m=l;f[c>>2]=m;o=((f[m+4>>2]|0)-(f[l>>2]|0)>>2>>>0)/3|0;b[g>>0]=0;Hf(i+8|0,o,g);Ra[f[(f[i>>2]|0)+8>>2]&127](i);f[h>>2]=f[c>>2];Qe(h+4|0,i)|0;f[h+36>>2]=l;f[h+40>>2]=d;f[h+44>>2]=j;f[h+48>>2]=k;tf(k,h);f[a>>2]=n;f[i>>2]=3196;n=f[i+20>>2]|0;if(n|0)lp(n);n=f[i+8>>2]|0;if(!n){bh(h);u=e;return}lp(n);bh(h);u=e;return}function Vd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;e=u;u=u+16|0;g=e;h=f[a+40>>2]|0;i=f[a+44>>2]|0;if((h|0)==(i|0)){j=2;k=0;l=(j|0)==2;m=l?0:k;u=e;return m|0}a=g+11|0;n=g+4|0;o=d+11|0;p=d+4|0;q=h;h=0;a:while(1){f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;r=Ah(f[q>>2]|0,c,g)|0;s=b[a>>0]|0;b:do if(r){t=s<<24>>24<0;v=s&255;w=t?f[n>>2]|0:v;x=b[o>>0]|0;y=x<<24>>24<0;if((w|0)==((y?f[p>>2]|0:x&255)|0)){x=f[g>>2]|0;z=t?x:g;A=y?f[d>>2]|0:d;y=(w|0)==0;c:do if(t){if(!y?dj(z,A,w)|0:0){B=0;C=h;break b}}else if(!y){if((x&255)<<24>>24==(b[A>>0]|0)){D=v;E=g;F=A}else{B=0;C=h;break b}while(1){D=D+-1|0;E=E+1|0;if(!D)break c;F=F+1|0;if((b[E>>0]|0)!=(b[F>>0]|0)){B=0;C=h;break b}}}while(0);B=1;C=f[q>>2]|0}else{B=0;C=h}}else{B=3;C=h}while(0);if(s<<24>>24<0)lp(f[g>>2]|0);switch(B&3){case 3:case 0:break;default:{j=B;k=C;G=17;break a}}q=q+4|0;if((q|0)==(i|0)){j=2;k=C;G=17;break}else h=C}if((G|0)==17){l=(j|0)==2;m=l?0:k;u=e;return m|0}return 0}function Wd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;c=u;u=u+32|0;d=c;e=a+4|0;g=f[a>>2]|0;h=(f[e>>2]|0)-g>>2;i=h+1|0;if(i>>>0>1073741823)Eo(a);j=a+8|0;k=(f[j>>2]|0)-g|0;g=k>>1;l=k>>2>>>0<536870911?(g>>>0>>0?i:g):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(l)if(l>>>0>1073741823){g=ra(8)|0;cn(g,13392);f[g>>2]=4748;va(g|0,1128,101)}else{m=Yk(l<<2)|0;break}else m=0;while(0);f[d>>2]=m;g=m+(h<<2)|0;h=d+8|0;i=d+4|0;f[i>>2]=g;k=d+12|0;f[k>>2]=m+(l<<2);l=f[b>>2]|0;f[b>>2]=0;f[g>>2]=l;f[h>>2]=g+4;g=f[a>>2]|0;l=f[e>>2]|0;if((l|0)==(g|0)){n=i;o=f[i>>2]|0;p=g;q=l;f[a>>2]=o;f[n>>2]=p;r=f[h>>2]|0;f[e>>2]=r;f[h>>2]=q;s=f[j>>2]|0;t=f[k>>2]|0;f[j>>2]=t;f[k>>2]=s;v=f[n>>2]|0;f[d>>2]=v;ug(d);u=c;return}b=f[i>>2]|0;m=l;do{m=m+-4|0;l=f[m>>2]|0;f[m>>2]=0;f[b+-4>>2]=l;b=(f[i>>2]|0)+-4|0;f[i>>2]=b}while((m|0)!=(g|0));n=i;o=b;p=f[a>>2]|0;q=f[e>>2]|0;f[a>>2]=o;f[n>>2]=p;r=f[h>>2]|0;f[e>>2]=r;f[h>>2]=q;s=f[j>>2]|0;t=f[k>>2]|0;f[j>>2]=t;f[k>>2]=s;v=f[n>>2]|0;f[d>>2]=v;ug(d);u=c;return}function Xd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c=u;u=u+16|0;d=c+4|0;e=c;g=f[b>>2]|0;f[d>>2]=g;b=a+8|0;h=g+1|0;do if((g|0)!=-1){f[d+4>>2]=((h>>>0)%3|0|0)==0?g+-2|0:h;if(!((g>>>0)%3|0)){i=g+2|0;break}else{i=g+-1|0;break}}else{f[d+4>>2]=-1;i=-1}while(0);f[d+8>>2]=i;i=a+216|0;h=a+220|0;j=a+368|0;a=g;g=0;while(1){if((a|0)!=-1?(f[(f[(f[b>>2]|0)+12>>2]|0)+(a<<2)>>2]|0)!=-1:0){if((f[h>>2]|0)!=(f[i>>2]|0)){k=0;do{if(Pi((f[j>>2]|0)+(k<<4)|0)|0){l=f[i>>2]|0;f[e>>2]=a;m=l+(k*144|0)+136|0;n=f[m>>2]|0;if(n>>>0<(f[l+(k*144|0)+140>>2]|0)>>>0){f[n>>2]=a;f[m>>2]=n+4}else dh(l+(k*144|0)+132|0,e)}k=k+1|0}while(k>>>0<(((f[h>>2]|0)-(f[i>>2]|0)|0)/144|0)>>>0)}}else o=11;if((o|0)==11?(o=0,k=f[h>>2]|0,l=f[i>>2]|0,(k|0)!=(l|0)):0){n=l;l=k;k=0;while(1){m=n;f[e>>2]=a;p=m+(k*144|0)+136|0;q=f[p>>2]|0;if(q>>>0<(f[m+(k*144|0)+140>>2]|0)>>>0){f[q>>2]=a;f[p>>2]=q+4;r=n;s=l}else{dh(m+(k*144|0)+132|0,e);r=f[i>>2]|0;s=f[h>>2]|0}k=k+1|0;if(k>>>0>=((s-r|0)/144|0)>>>0)break;else{n=r;l=s}}}l=g+1|0;if((l|0)==3)break;a=f[d+(l<<2)>>2]|0;g=l}u=c;return 1}function Yd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=u;u=u+32|0;e=d+12|0;g=d;h=wj(c,0)|0;if(!h){f[a>>2]=0;u=d;return}i=f[c+100>>2]|0;j=f[c+96>>2]|0;c=i-j|0;k=(c|0)/12|0;f[e>>2]=0;l=e+4|0;f[l>>2]=0;f[e+8>>2]=0;m=j;do if(c)if(k>>>0>357913941)Eo(e);else{n=Yk(c)|0;f[e>>2]=n;f[e+8>>2]=n+(k*12|0);Dh(n|0,0,c|0)|0;f[l>>2]=n+c;o=n;break}else o=0;while(0);f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;a:do if((i|0)!=(j|0)){c=g+4|0;n=g+8|0;if(b[h+84>>0]|0){p=0;while(1){q=m+(p*12|0)|0;f[g>>2]=f[q>>2];f[g+4>>2]=f[q+4>>2];f[g+8>>2]=f[q+8>>2];f[o+(p*12|0)>>2]=f[g>>2];f[o+(p*12|0)+4>>2]=f[c>>2];f[o+(p*12|0)+8>>2]=f[n>>2];p=p+1|0;if(p>>>0>=k>>>0)break a}}p=f[h+68>>2]|0;q=0;do{r=f[p+(f[m+(q*12|0)>>2]<<2)>>2]|0;f[g>>2]=r;f[c>>2]=f[p+(f[m+(q*12|0)+4>>2]<<2)>>2];s=f[p+(f[m+(q*12|0)+8>>2]<<2)>>2]|0;f[n>>2]=s;f[o+(q*12|0)>>2]=r;f[o+(q*12|0)+4>>2]=f[c>>2];f[o+(q*12|0)+8>>2]=s;q=q+1|0}while(q>>>0>>0)}while(0);Wh(a,e);a=f[e>>2]|0;if(a|0){e=f[l>>2]|0;if((e|0)!=(a|0))f[l>>2]=e+(~(((e+-12-a|0)>>>0)/12|0)*12|0);lp(a)}u=d;return}function Zd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;if(!(f[a+64>>2]|0)){d=Yk(32)|0;ql(d);e=a+64|0;g=f[e>>2]|0;f[e>>2]=d;if(!g)h=d;else{d=f[g>>2]|0;if(d|0){i=g+4|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;lp(d)}lp(g);h=f[e>>2]|0}Oi(a,h,0,0,0,0);j=a}else j=a;if(!(vh(j,c)|0))return;b[a+84>>0]=b[c+84>>0]|0;f[a+80>>2]=f[c+80>>2];if((a|0)!=(c|0))Te(a+68|0,f[c+68>>2]|0,f[c+72>>2]|0);j=f[c+88>>2]|0;if(!j){c=a+88|0;h=f[c>>2]|0;f[c>>2]=0;if(!h)return;c=f[h+8>>2]|0;if(c|0){e=h+12|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;lp(c)}lp(h);return}h=Yk(40)|0;f[h>>2]=f[j>>2];c=h+8|0;e=j+8|0;f[c>>2]=0;g=h+12|0;f[g>>2]=0;d=h+16|0;f[d>>2]=0;i=j+12|0;k=(f[i>>2]|0)-(f[e>>2]|0)|0;if(k|0){if((k|0)<0)Eo(c);l=Yk(k)|0;f[g>>2]=l;f[c>>2]=l;f[d>>2]=l+k;k=f[e>>2]|0;e=(f[i>>2]|0)-k|0;if((e|0)>0){Ff(l|0,k|0,e|0)|0;f[g>>2]=l+e}}e=h+24|0;l=j+24|0;f[e>>2]=f[l>>2];f[e+4>>2]=f[l+4>>2];f[e+8>>2]=f[l+8>>2];f[e+12>>2]=f[l+12>>2];l=a+88|0;a=f[l>>2]|0;f[l>>2]=h;if(!a)return;h=f[a+8>>2]|0;if(h|0){l=a+12|0;if((f[l>>2]|0)!=(h|0))f[l>>2]=h;lp(h)}lp(a);return}function _d(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;fi(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+100|0;h=f[e>>2]|0;i=(f[h+28>>2]|0)-(f[h+24>>2]|0)>>2;f[c>>2]=0;h=a+104|0;j=f[h>>2]|0;k=f[g>>2]|0;l=j-k>>2;m=k;k=j;if(i>>>0<=l>>>0){if(i>>>0>>0?(j=m+(i<<2)|0,(k|0)!=(j|0)):0)f[h>>2]=k+(~((k+-4-j|0)>>>2)<<2)}else ag(g,i-l|0,c);l=a+120|0;a=f[l>>2]|0;if(!a){i=f[e>>2]|0;g=(f[i+4>>2]|0)-(f[i>>2]|0)>>2;i=(g>>>0)/3|0;if(g>>>0<=2){n=1;u=b;return n|0}g=0;while(1){f[d>>2]=g*3;f[c>>2]=f[d>>2];g=g+1|0;if(!(Bb(e,c)|0)){n=0;o=15;break}if((g|0)>=(i|0)){n=1;o=15;break}}if((o|0)==15){u=b;return n|0}}else{i=f[a>>2]|0;if((f[a+4>>2]|0)==(i|0)){n=1;u=b;return n|0}a=i;i=0;while(1){f[d>>2]=f[a+(i<<2)>>2];f[c>>2]=f[d>>2];i=i+1|0;if(!(Bb(e,c)|0)){n=0;o=15;break}g=f[l>>2]|0;a=f[g>>2]|0;if(i>>>0>=(f[g+4>>2]|0)-a>>2>>>0){n=1;o=15;break}}if((o|0)==15){u=b;return n|0}}return 0}function $d(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;e=u;u=u+32|0;g=e+20|0;h=e+16|0;i=e;j=c+24|0;k=b[j>>0]|0;l=k<<24>>24;m=f[a+80>>2]|0;a=X(m,l)|0;f[i>>2]=f[294];f[i+4>>2]=f[295];f[i+8>>2]=f[296];f[i+12>>2]=f[297];n=d+4|0;o=f[n>>2]|0;p=f[d>>2]|0;q=o-p>>2;r=p;p=o;if(a>>>0<=q>>>0){if(a>>>0>>0?(o=r+(a<<2)|0,(p|0)!=(o|0)):0)f[n>>2]=p+(~((p+-4-o|0)>>>2)<<2)}else Og(d,a-q|0);if(!m){s=1;u=e;return s|0}q=c+84|0;a=c+68|0;if(k<<24>>24<=0){k=0;while(1){if(!(b[q>>0]|0))t=f[(f[a>>2]|0)+(k<<2)>>2]|0;else t=k;f[h>>2]=t;o=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(rb(c,g,o,i)|0)){s=0;v=18;break}k=k+1|0;if(k>>>0>=m>>>0){s=1;v=18;break}}if((v|0)==18){u=e;return s|0}}else{w=0;x=0}while(1){if(!(b[q>>0]|0))y=f[(f[a>>2]|0)+(x<<2)>>2]|0;else y=x;f[h>>2]=y;k=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(rb(c,g,k,i)|0)){s=0;v=18;break}k=f[d>>2]|0;t=w;o=0;while(1){f[k+(t<<2)>>2]=f[i+(o<<2)>>2];o=o+1|0;if((o|0)==(l|0))break;else t=t+1|0}x=x+1|0;if(x>>>0>=m>>>0){s=1;v=18;break}else w=l+w|0}if((v|0)==18){u=e;return s|0}return 0}function ae(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;e=c+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;if(!(ze(a+16|0,c)|0)){r=0;return r|0}if(!(ze(a+36|0,c)|0)){r=0;return r|0}if(!(ze(a+56|0,c)|0)){r=0;return r|0}if(ze(a+76|0,c)|0)return eb(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function be(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;e=c+8|0;g=e;i=f[g>>2]|0;j=f[g+4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;if(!(ze(a+16|0,c)|0)){r=0;return r|0}if(!(ze(a+36|0,c)|0)){r=0;return r|0}if(!(ze(a+56|0,c)|0)){r=0;return r|0}if(ze(a+76|0,c)|0)return db(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function ce(a,c,d){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4>>2]|0;g=c+16|0;k=g;l=f[k>>2]|0;m=f[k+4>>2]|0;k=Ul(l|0,m|0,4,0)|0;n=I;if((j|0)<(n|0)|(j|0)==(n|0)&i>>>0>>0){o=f[a>>2]|0;p=l;q=m}else{m=(f[c>>2]|0)+l|0;l=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[a>>0]=l;b[a+1>>0]=l>>8;b[a+2>>0]=l>>16;b[a+3>>0]=l>>24;m=g;k=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=I;i=g;f[i>>2]=k;f[i+4>>2]=m;o=l;p=k;q=m}if(o>>>0>32){r=0;return r|0}o=a+4|0;m=e;e=f[m>>2]|0;k=f[m+4>>2]|0;m=Ul(p|0,q|0,4,0)|0;q=I;if((k|0)<(q|0)|(k|0)==(q|0)&e>>>0>>0)s=f[o>>2]|0;else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;b[o>>0]=p;b[o+1>>0]=p>>8;b[o+2>>0]=p>>16;b[o+3>>0]=p>>24;m=g;e=Ul(f[m>>2]|0,f[m+4>>2]|0,4,0)|0;m=g;f[m>>2]=e;f[m+4>>2]=I;s=p}if(!s){r=1;return r|0}f[a+8>>2]=0;if(!(ud(a+16|0,c)|0)){r=0;return r|0}if(!(ze(a+32|0,c)|0)){r=0;return r|0}if(!(ze(a+52|0,c)|0)){r=0;return r|0}if(ze(a+72|0,c)|0)return ib(a,f[o>>2]|0,d)|0;else{r=0;return r|0}return 0}function ee(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(l|0)!=(k|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{ag(i,h-m|0,3160);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+80|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1){q=0;r=12;break}i=f[d>>2]|0;g=f[i+(h<<2)>>2]|0;if((g|0)==-1){q=0;r=12;break}k=f[(f[m>>2]|0)+12>>2]|0;l=f[k+(g<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=12;break}g=f[a>>2]|0;f[g+(f[c+(o*12|0)>>2]<<2)>>2]=l;l=h+1|0;if((l|0)==-1){q=0;r=12;break}j=f[i+(l<<2)>>2]|0;if((j|0)==-1){q=0;r=12;break}l=f[k+(j<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=12;break}f[g+(f[c+(o*12|0)+4>>2]<<2)>>2]=l;l=h+2|0;if((l|0)==-1){q=0;r=12;break}h=f[i+(l<<2)>>2]|0;if((h|0)==-1){q=0;r=12;break}l=f[k+(h<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=12;break}f[g+(f[c+(o*12|0)+8>>2]<<2)>>2]=l;o=o+1|0;if(o>>>0>=e>>>0){q=1;r=12;break}}if((r|0)==12)return q|0;return 0}function fe(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+112|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(l|0)!=(k|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{ag(i,h-m|0,3160);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+116|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1){q=0;r=12;break}i=f[d>>2]|0;g=f[i+(h<<2)>>2]|0;if((g|0)==-1){q=0;r=12;break}k=f[(f[m>>2]|0)+12>>2]|0;l=f[k+(g<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=12;break}g=f[a>>2]|0;f[g+(f[c+(o*12|0)>>2]<<2)>>2]=l;l=h+1|0;if((l|0)==-1){q=0;r=12;break}j=f[i+(l<<2)>>2]|0;if((j|0)==-1){q=0;r=12;break}l=f[k+(j<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=12;break}f[g+(f[c+(o*12|0)+4>>2]<<2)>>2]=l;l=h+2|0;if((l|0)==-1){q=0;r=12;break}h=f[i+(l<<2)>>2]|0;if((h|0)==-1){q=0;r=12;break}l=f[k+(h<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=12;break}f[g+(f[c+(o*12|0)+8>>2]<<2)>>2]=l;o=o+1|0;if(o>>>0>=e>>>0){q=1;r=12;break}}if((r|0)==12)return q|0;return 0}function ge(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Ic(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=id(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<4194304){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=4194304){r=t;break}else q=t}}else r=n;while(0);q=r&1048575;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>20)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function he(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Jc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=jd(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<2097152){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=2097152){r=t;break}else q=t}}else r=n;while(0);q=r&524287;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>19)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function ie(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Kc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=kd(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<1048576){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=1048576){r=t;break}else q=t}}else r=n;while(0);q=r&262143;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>18)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function je(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Lc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=ld(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<262144){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=262144){r=t;break}else q=t}}else r=n;while(0);q=r&65535;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>16)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function ke(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Mc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=md(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<131072){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=131072){r=t;break}else q=t}}else r=n;while(0);q=r&32767;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>15)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function le(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Nc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=nd(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<32768){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=32768){r=t;break}else q=t}}else r=n;while(0);q=r&8191;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>13)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function me(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+52|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Oc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=od(e,b)|0;if(g|i^1)j=i;else{i=e+44|0;g=e+48|0;k=e+40|0;l=e+16|0;m=e+28|0;n=f[g>>2]|0;o=0;while(1){a:do if(n>>>0<16384){p=f[i>>2]|0;q=n;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[i>>2]=p;t=h[s+p>>0]|0|q<<8;f[g>>2]=t;if(t>>>0>=16384){r=t;break}else q=t}}else r=n;while(0);q=r&4095;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;n=(X(f[t+(p<<3)>>2]|0,r>>>12)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[g>>2]=n;f[c+(o<<2)>>2]=p;o=o+1|0;if((o|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);lp(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a);u=d;return j|0}function ne(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=f[c>>2]|0;c=f[d>>2]|0;e=f[a+4>>2]|0;g=f[d+4>>2]|0;h=e+-1|0;i=(h&e|0)==0;if(!i)if(g>>>0>>0)j=g;else j=(g>>>0)%(e>>>0)|0;else j=h&g;g=(f[a>>2]|0)+(j<<2)|0;k=f[g>>2]|0;while(1){l=f[k>>2]|0;if((l|0)==(d|0))break;else k=l}if((k|0)!=(a+8|0)){l=f[k+4>>2]|0;if(!i)if(l>>>0>>0)m=l;else m=(l>>>0)%(e>>>0)|0;else m=l&h;if((m|0)==(j|0)){n=c;o=21}else o=13}else o=13;do if((o|0)==13){if(c|0){m=f[c+4>>2]|0;if(!i)if(m>>>0>>0)p=m;else p=(m>>>0)%(e>>>0)|0;else p=m&h;if((p|0)==(j|0)){q=c;r=c;o=22;break}}f[g>>2]=0;n=f[d>>2]|0;o=21}while(0);if((o|0)==21){g=n;if(!n)s=g;else{q=n;r=g;o=22}}if((o|0)==22){o=f[q+4>>2]|0;if(!i)if(o>>>0>>0)t=o;else t=(o>>>0)%(e>>>0)|0;else t=o&h;if((t|0)==(j|0))s=r;else{f[(f[a>>2]|0)+(t<<2)>>2]=k;s=f[d>>2]|0}}f[k>>2]=s;f[d>>2]=0;s=a+12|0;f[s>>2]=(f[s>>2]|0)+-1;if(!d)return c|0;s=d+8|0;a=f[d+20>>2]|0;if(a|0){k=d+24|0;if((f[k>>2]|0)!=(a|0))f[k>>2]=a;lp(a)}if((b[s+11>>0]|0)<0)lp(f[s>>2]|0);lp(d);return c|0}function oe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=Ka,k=0,l=0,m=0,o=0,p=0,q=Ka,r=Ka,s=0,t=Ka,v=Ka,w=0,x=0,y=0,z=0;g=u;u=u+32|0;h=g+16|0;i=g;j=$(n[d+4>>2]);k=(1<>2])+-1|0;Gn(h);Sk(h,j,k)|0;d=f[a>>2]|0;if((d|0)==(f[c>>2]|0)){u=g;return}a=h+4|0;l=i+4|0;m=i+8|0;o=e+16|0;p=e+28|0;e=d;do{d=(f[e>>2]|0)-k|0;j=$(n[a>>2]);q=$(n[h>>2]);if((d|0)>-1)r=$(q*$(j*$(d|0)));else{s=Wl(0,0,d|0,((d|0)<0)<<31>>31|0)|0;r=$(-$(q*$(j*$(+(s>>>0)+4294967296.0*+(I|0)))))}s=(f[e+4>>2]|0)-k|0;if((s|0)>-1)t=$(q*$(j*$(s|0)));else{d=Wl(0,0,s|0,((s|0)<0)<<31>>31|0)|0;t=$(-$(q*$(j*$(+(d>>>0)+4294967296.0*+(I|0)))))}d=(f[e+8>>2]|0)-k|0;if((d|0)>-1)v=$(q*$(j*$(d|0)));else{s=Wl(0,0,d|0,((d|0)<0)<<31>>31|0)|0;v=$(-$(q*$(j*$(+(s>>>0)+4294967296.0*+(I|0)))))}n[i>>2]=r;n[l>>2]=t;n[m>>2]=v;s=f[o>>2]|0;d=f[s>>2]|0;w=f[p>>2]|0;if(!(b[d+84>>0]|0))x=f[(f[d+68>>2]|0)+(w<<2)>>2]|0;else x=w;w=i+(f[s+4>>2]<<2)|0;s=d+40|0;y=f[s>>2]|0;z=fl(y|0,f[s+4>>2]|0,x|0,0)|0;Ff((f[f[d+64>>2]>>2]|0)+z|0,w|0,y|0)|0;f[p>>2]=(f[p>>2]|0)+1;e=e+12|0}while((e|0)!=(f[c>>2]|0));u=g;return}function pe(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;b=a+640|0;c=f[b>>2]|0;if(c|0){d=a+644|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);lp(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}lp(g)}g=a+628|0;b=f[g>>2]|0;if(b|0){j=a+632|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}lp(l)}l=f[a+616>>2]|0;if(l|0){g=a+620|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);lp(l)}l=f[a+604>>2]|0;if(!l){n=a+584|0;lj(n);o=a+564|0;lj(o);p=a+544|0;lj(p);q=a+528|0;qp(q);r=a+16|0;Ch(r);return}m=a+608|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);lp(l);n=a+584|0;lj(n);o=a+564|0;lj(o);p=a+544|0;lj(p);q=a+528|0;qp(q);r=a+16|0;Ch(r);return}function qe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;g=u;u=u+80|0;h=g;i=g+60|0;j=g+40|0;k=h;l=d;m=k+40|0;do{f[k>>2]=f[l>>2];k=k+4|0;l=l+4|0}while((k|0)<(m|0));ac(a,h,i);if(f[a>>2]|0){n=h+24|0;qp(n);u=g;return}o=a+4|0;p=o+11|0;if((b[p>>0]|0)<0)lp(f[o>>2]|0);if(b[i+7>>0]|0){f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;q=Yk(32)|0;f[j>>2]=q;f[j+8>>2]=-2147483616;f[j+4>>2]=27;k=q;l=11743;m=k+27|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[q+27>>0]=0;f[a>>2]=-1;zh(o,j);if((b[j+11>>0]|0)<0)lp(f[j>>2]|0);n=h+24|0;qp(n);u=g;return}Df(j,b[i+8>>0]|0);i=f[j>>2]|0;if(!i){q=j+16|0;l=f[q>>2]|0;f[q>>2]=0;tc(a,l,c,d,e);if(!(f[a>>2]|0)){if((b[p>>0]|0)<0)lp(f[o>>2]|0);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0}if(l|0)Ra[f[(f[l>>2]|0)+4>>2]&127](l)}else{f[a>>2]=i;zh(o,j+4|0)}o=j+16|0;i=f[o>>2]|0;f[o>>2]=0;if(i|0)Ra[f[(f[i>>2]|0)+4>>2]&127](i);i=j+4|0;if((b[i+11>>0]|0)<0)lp(f[i>>2]|0);n=h+24|0;qp(n);u=g;return}function re(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;g=u;u=u+80|0;h=g;i=g+60|0;j=g+40|0;k=h;l=d;m=k+40|0;do{f[k>>2]=f[l>>2];k=k+4|0;l=l+4|0}while((k|0)<(m|0));ac(a,h,i);if(f[a>>2]|0){n=h+24|0;qp(n);u=g;return}o=a+4|0;p=o+11|0;if((b[p>>0]|0)<0)lp(f[o>>2]|0);if((b[i+7>>0]|0)!=1){f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;q=Yk(32)|0;f[j>>2]=q;f[j+8>>2]=-2147483616;f[j+4>>2]=20;k=q;l=11722;m=k+20|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[q+20>>0]=0;f[a>>2]=-1;zh(o,j);if((b[j+11>>0]|0)<0)lp(f[j>>2]|0);n=h+24|0;qp(n);u=g;return}og(j,b[i+8>>0]|0);i=f[j>>2]|0;if(!i){q=j+16|0;l=f[q>>2]|0;f[q>>2]=0;kk(a,l,c,d,e);if(!(f[a>>2]|0)){if((b[p>>0]|0)<0)lp(f[o>>2]|0);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0}if(l|0)Ra[f[(f[l>>2]|0)+4>>2]&127](l)}else{f[a>>2]=i;zh(o,j+4|0)}o=j+16|0;i=f[o>>2]|0;f[o>>2]=0;if(i|0)Ra[f[(f[i>>2]|0)+4>>2]&127](i);i=j+4|0;if((b[i+11>>0]|0)<0)lp(f[i>>2]|0);n=h+24|0;qp(n);u=g;return}function se(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=b;lg(a+16|0);Ym(a+528|0);tm(a+544|0);tm(a+564|0);tm(a+584|0);e=a+604|0;f[e>>2]=0;g=a+608|0;f[g>>2]=0;f[a+612>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)Eo(e);else{i=b<<2;j=Yk(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+612>>2]=k;Dh(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+616|0;f[g>>2]=0;e=a+620|0;f[e>>2]=0;f[a+624>>2]=0;if(!h){k=b<<2;i=Yk(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+624>>2]=g;Dh(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=Yk(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;Dh(i|0,0,k|0)|0;f[e>>2]=j}ui(a+628|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);lp(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=Yk(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;Dh(k|0,0,h|0)|0;f[j>>2]=e}ui(a+640|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);lp(g);u=c;return}function te(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+32|0;d=c+12|0;e=c;g=b*3|0;f[d>>2]=0;h=d+4|0;f[h>>2]=0;f[d+8>>2]=0;do if(g)if(g>>>0>1073741823)Eo(d);else{i=b*12|0;j=Yk(i)|0;f[d>>2]=j;k=j+(g<<2)|0;f[d+8>>2]=k;Dh(j|0,0,i|0)|0;f[h>>2]=k;l=j;break}else l=0;while(0);if(yh(g,1,f[a+32>>2]|0,l)|0)if(!b)m=1;else{l=a+44|0;a=e+4|0;g=e+8|0;j=0;k=0;i=0;while(1){f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;n=f[d>>2]|0;o=f[n+(i<<2)>>2]|0;p=o>>>1;q=((o&1|0)==0?p:0-p|0)+k|0;f[e>>2]=q;p=f[n+(i+1<<2)>>2]|0;o=p>>>1;r=((p&1|0)==0?o:0-o|0)+q|0;f[a>>2]=r;q=f[n+(i+2<<2)>>2]|0;n=q>>>1;k=((q&1|0)==0?n:0-n|0)+r|0;f[g>>2]=k;r=f[l>>2]|0;n=r+100|0;q=f[n>>2]|0;if((q|0)==(f[r+104>>2]|0))Lg(r+96|0,e);else{f[q>>2]=f[e>>2];f[q+4>>2]=f[e+4>>2];f[q+8>>2]=f[e+8>>2];f[n>>2]=(f[n>>2]|0)+12}j=j+1|0;if(j>>>0>=b>>>0){m=1;break}else i=i+3|0}}else m=0;i=f[d>>2]|0;if(!i){u=c;return m|0}d=f[h>>2]|0;if((d|0)!=(i|0))f[h>>2]=d+(~((d+-4-i|0)>>>2)<<2);lp(i);u=c;return m|0}function ue(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=b;tm(a+16|0);tm(a+36|0);tm(a+56|0);tm(a+76|0);e=a+96|0;f[e>>2]=0;g=a+100|0;f[g>>2]=0;f[a+104>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)Eo(e);else{i=b<<2;j=Yk(i)|0;f[e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0)==(r|0)&j>>>0>s>>>0){j=b[(f[d>>2]|0)+s>>0]|0;k=Ul(s|0,r|0,1,0)|0;r=i;f[r>>2]=k;f[r+4>>2]=I;w=j}else w=0;Ua[f[(f[a>>2]|0)+40>>2]&7](g,a,t<<24>>24,w<<24>>24);w=a+20|0;t=f[g>>2]|0;f[g>>2]=0;j=f[w>>2]|0;f[w>>2]=t;if(j){Ra[f[(f[j>>2]|0)+4>>2]&127](j);j=f[g>>2]|0;f[g>>2]=0;if(j|0)Ra[f[(f[j>>2]|0)+4>>2]&127](j)}else f[g>>2]=0}g=f[a+20>>2]|0;if(g|0?!(Na[f[(f[a>>2]|0)+28>>2]&127](a,g)|0):0){x=0;u=e;return x|0}if(!(Oa[f[(f[a>>2]|0)+36>>2]&31](a,c,d)|0)){x=0;u=e;return x|0}d=(f[c+4>>2]|0)-(f[c>>2]|0)>>2;c=f[a+4>>2]|0;if((c|0?((h[c+36>>0]|0)<<8&65535)<512:0)?!(Na[f[(f[a>>2]|0)+48>>2]&127](a,d)|0):0){x=0;u=e;return x|0}x=1;u=e;return x|0}function we(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=b;Ym(a+16|0);tm(a+32|0);tm(a+52|0);tm(a+72|0);e=a+92|0;f[e>>2]=0;g=a+96|0;f[g>>2]=0;f[a+100>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)Eo(e);else{i=b<<2;j=Yk(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+100>>2]=k;Dh(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+104|0;f[g>>2]=0;e=a+108|0;f[e>>2]=0;f[a+112>>2]=0;if(!h){k=b<<2;i=Yk(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+112>>2]=g;Dh(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=Yk(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;Dh(i|0,0,k|0)|0;f[e>>2]=j}ui(a+116|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);lp(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=Yk(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;Dh(k|0,0,h|0)|0;f[j>>2]=e}ui(a+128|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);lp(g);u=c;return}function xe(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+132|0;c=f[b>>2]|0;if(c|0){d=a+136|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);lp(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}lp(g)}g=a+120|0;b=f[g>>2]|0;if(b|0){j=a+124|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}lp(l)}l=f[a+108>>2]|0;if(l|0){g=a+112|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);lp(l)}l=f[a+96>>2]|0;if(!l){n=a+76|0;lj(n);o=a+56|0;lj(o);p=a+36|0;lj(p);q=a+16|0;lj(q);return}m=a+100|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);lp(l);n=a+76|0;lj(n);o=a+56|0;lj(o);p=a+36|0;lj(p);q=a+16|0;lj(q);return}function ye(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(l|0)!=(k|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{ag(i,h-m|0,3160);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+80|0;a=c+68|0;c=f[o+96>>2]|0;o=f[d+28>>2]|0;d=0;while(1){h=d*3|0;i=f[o+(h<<2)>>2]|0;if((i|0)==-1){q=0;r=11;break}g=f[(f[m>>2]|0)+12>>2]|0;k=f[g+(i<<2)>>2]|0;if(k>>>0>=p>>>0){q=0;r=11;break}i=f[a>>2]|0;f[i+(f[c+(d*12|0)>>2]<<2)>>2]=k;k=f[o+(h+1<<2)>>2]|0;if((k|0)==-1){q=0;r=11;break}l=f[g+(k<<2)>>2]|0;if(l>>>0>=p>>>0){q=0;r=11;break}f[i+(f[c+(d*12|0)+4>>2]<<2)>>2]=l;l=f[o+(h+2<<2)>>2]|0;if((l|0)==-1){q=0;r=11;break}h=f[g+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[u>>2]|0,f[u+4>>2]|0,p|0,0)|0;p=l;f[p>>2]=b;f[p+4>>2]=I;f[e>>2]=f[a>>2];f[i>>2]=0;r=1;return r|0}function Ae(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=a+4|0;d=f[a>>2]|0;e=((f[c>>2]|0)-d|0)/24|0;g=e+1|0;if(g>>>0>178956970)Eo(a);h=a+8|0;i=((f[h>>2]|0)-d|0)/24|0;d=i<<1;j=i>>>0<89478485?(d>>>0>>0?g:d):178956970;do if(j)if(j>>>0>178956970){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}else{k=Yk(j*24|0)|0;break}else k=0;while(0);d=k+(e*24|0)|0;g=d;i=k+(j*24|0)|0;f[d>>2]=1228;f[k+(e*24|0)+4>>2]=f[b+4>>2];pi(k+(e*24|0)+8|0,b+8|0);f[k+(e*24|0)+20>>2]=f[b+20>>2];b=d+24|0;e=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(e|0)){l=g;m=e;n=e}else{j=d;d=k;k=g;do{f[j+-24>>2]=1228;f[j+-20>>2]=f[d+-20>>2];g=j+-16|0;o=d+-16|0;f[g>>2]=0;p=j+-12|0;f[p>>2]=0;f[j+-8>>2]=0;f[g>>2]=f[o>>2];g=d+-12|0;f[p>>2]=f[g>>2];p=d+-8|0;f[j+-8>>2]=f[p>>2];f[p>>2]=0;f[g>>2]=0;f[o>>2]=0;f[j+-4>>2]=f[d+-4>>2];d=d+-24|0;j=k+-24|0;k=j}while((d|0)!=(e|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=b;f[h>>2]=i;i=m;if((n|0)!=(i|0)){h=n;do{h=h+-24|0;Ra[f[f[h>>2]>>2]&127](h)}while((h|0)!=(i|0))}if(!m)return;lp(m);return}function Be(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=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o<<2)|0;f[i>>2]=p;f[k>>2]=0;f[l>>2]=o;o=f[j>>2]|0;f[g>>2]=o;f[g+4>>2]=0;p=f[m>>2]|0;f[h>>2]=o+(p>>>5<<2);f[h+4>>2]=p&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];He(i,e,d);break}while(0);i=a+20|0;f[i>>2]=0;m=a+24|0;f[m>>2]=0;j=a+28|0;f[j>>2]=0;a=b+24|0;l=f[a>>2]|0;if(!l){u=c;return}if((l|0)<0)Eo(i);k=((l+-1|0)>>>5)+1|0;l=Yk(k<<2)|0;f[i>>2]=l;f[m>>2]=0;f[j>>2]=k;k=f[b+20>>2]|0;f[g>>2]=k;f[g+4>>2]=0;b=f[a>>2]|0;f[h>>2]=k+(b>>>5<<2);f[h+4>>2]=b&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];He(i,e,d);u=c;return}function De(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+128|0;c=f[b>>2]|0;if(c|0){d=a+132|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);lp(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}lp(g)}g=a+116|0;b=f[g>>2]|0;if(b|0){j=a+120|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}lp(l)}l=f[a+104>>2]|0;if(l|0){g=a+108|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);lp(l)}l=f[a+92>>2]|0;if(!l){n=a+72|0;lj(n);o=a+52|0;lj(o);p=a+32|0;lj(p);q=a+16|0;qp(q);return}m=a+96|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);lp(l);n=a+72|0;lj(n);o=a+52|0;lj(o);p=a+32|0;lj(p);q=a+16|0;qp(q);return}function Ee(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Ka,v=Ka,w=0,x=0,y=Ka,z=0,A=Ka;d=u;u=u+16|0;e=d;g=f[a+24>>2]|0;h=a+8|0;i=b[(f[h>>2]|0)+24>>0]|0;j=i<<24>>24;k=j<<2;l=ip(j>>>0>1073741823?-1:j<<2)|0;Gn(e);if(!(Sk(e,$(n[a+32>>2]),(1<>2]|0;if(!(f[g+80>>2]|0))o=0;else o=(f[f[g>>2]>>2]|0)+(f[g+48>>2]|0)|0;if(!c){m=1;jp(l);u=d;return m|0}g=e+4|0;p=a+28|0;if(i<<24>>24>0){q=0;r=0;s=0}else{i=0;a=0;while(1){Ff((f[f[(f[h>>2]|0)+64>>2]>>2]|0)+a|0,l|0,k|0)|0;i=i+1|0;if((i|0)==(c|0)){m=1;break}else a=a+k|0}jp(l);u=d;return m|0}while(1){a=f[p>>2]|0;t=$(n[g>>2]);v=$(n[e>>2]);i=0;w=s;while(1){x=f[o+(w<<2)>>2]|0;if((x|0)>-1)y=$($($(x|0)*t)*v);else{z=Wl(0,0,x|0,((x|0)<0)<<31>>31|0)|0;y=$(-$(v*$(t*$(+(z>>>0)+4294967296.0*+(I|0)))))}A=$(y+$(n[a+(i<<2)>>2]));n[l+(i<<2)>>2]=A;i=i+1|0;if((i|0)==(j|0))break;else w=w+1|0}Ff((f[f[(f[h>>2]|0)+64>>2]>>2]|0)+r|0,l|0,k|0)|0;q=q+1|0;if((q|0)==(c|0)){m=1;break}else{r=r+k|0;s=j+s|0}}jp(l);u=d;return m|0}function Fe(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(((d-g|0)/12|0)>>>0>=b>>>0){Dh(g|0,0,b*12|0)|0;f[e>>2]=h+(b*12|0);return}i=f[a>>2]|0;j=(g-i|0)/12|0;g=j+b|0;k=i;if(g>>>0>357913941)Eo(a);l=(d-i|0)/12|0;d=l<<1;m=l>>>0<178956970?(d>>>0>>0?g:d):357913941;do if(m)if(m>>>0>357913941){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}else{n=Yk(m*12|0)|0;break}else n=0;while(0);d=n+(j*12|0)|0;j=d;g=n+(m*12|0)|0;Dh(d|0,0,b*12|0)|0;m=d+(b*12|0)|0;if((h|0)==(k|0)){o=j;p=i;q=h}else{i=d;d=h;h=j;do{j=i+-12|0;b=d;d=d+-12|0;f[j>>2]=0;n=i+-8|0;f[n>>2]=0;f[i+-4>>2]=0;f[j>>2]=f[d>>2];j=b+-8|0;f[n>>2]=f[j>>2];n=b+-4|0;f[i+-4>>2]=f[n>>2];f[n>>2]=0;f[j>>2]=0;f[d>>2]=0;i=h+-12|0;h=i}while((d|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=g;g=p;if((q|0)!=(g|0)){c=q;do{q=c;c=c+-12|0;m=f[c>>2]|0;if(m|0){e=q+-8|0;q=f[e>>2]|0;if((q|0)!=(m|0))f[e>>2]=q+(~((q+-4-m|0)>>>2)<<2);lp(m)}}while((c|0)!=(g|0))}if(!p)return;lp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h>>2]=i+(b<<2);u=c;return}j=f[a>>2]|0;k=i-j>>2;i=k+b|0;if(i>>>0>1073741823)Eo(a);l=g-j|0;j=l>>1;g=l>>2>>>0<536870911?(j>>>0>>0?i:j):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(g)if(g>>>0>1073741823){j=ra(8)|0;cn(j,13392);f[j>>2]=4748;va(j|0,1128,101)}else{m=Yk(g<<2)|0;break}else m=0;while(0);f[d>>2]=m;j=m+(k<<2)|0;k=d+8|0;i=d+4|0;f[i>>2]=j;l=d+12|0;f[l>>2]=m+(g<<2);Dh(j|0,0,b<<2|0)|0;f[k>>2]=j+(b<<2);b=f[a>>2]|0;j=f[h>>2]|0;if((j|0)==(b|0)){n=i;o=f[i>>2]|0;p=b;q=j}else{g=f[i>>2]|0;m=j;do{m=m+-4|0;j=f[m>>2]|0;f[m>>2]=0;f[g+-4>>2]=j;g=(f[i>>2]|0)+-4|0;f[i>>2]=g}while((m|0)!=(b|0));n=i;o=g;p=f[a>>2]|0;q=f[h>>2]|0}f[a>>2]=o;f[n>>2]=p;f[h>>2]=f[k>>2];f[k>>2]=q;q=f[e>>2]|0;f[e>>2]=f[l>>2];f[l>>2]=q;f[d>>2]=f[n>>2];ug(d);u=c;return}function Je(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)ok(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=((c+-4-o|0)>>>2)+1|0;o=l;m=n;while(1){f[o>>2]=f[m>>2];m=m+4|0;if((m|0)==(c|0))break;else o=o+4|0}f[k>>2]=l+(p<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);lp(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)Eo(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)Eo(a);h=Yk(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=((c+-4-d|0)>>>2)+1|0;d=h;g=b;while(1){f[d>>2]=f[g>>2];g=g+4|0;if((g|0)==(c|0))break;else d=d+4|0}f[e>>2]=h+(p<<2);return}function Ke(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=c+8|0;e=f[d>>2]|0;g=f[d+4>>2]|0;d=c+16|0;i=d;k=f[i>>2]|0;l=f[i+4>>2]|0;i=Ul(k|0,l|0,4,0)|0;m=I;if((g|0)<(m|0)|(g|0)==(m|0)&e>>>0>>0){n=0;return n|0}o=f[c>>2]|0;p=o+k|0;q=h[p>>0]|h[p+1>>0]<<8|h[p+2>>0]<<16|h[p+3>>0]<<24;p=d;f[p>>2]=i;f[p+4>>2]=m;m=Ul(k|0,l|0,8,0)|0;p=I;if((g|0)<(p|0)|(g|0)==(p|0)&e>>>0>>0){n=0;return n|0}r=o+i|0;i=h[r>>0]|h[r+1>>0]<<8|h[r+2>>0]<<16|h[r+3>>0]<<24;r=d;f[r>>2]=m;f[r+4>>2]=p;if((q|0)>(i|0)){n=0;return n|0}f[a+12>>2]=q;f[a+16>>2]=i;r=Wl(i|0,((i|0)<0)<<31>>31|0,q|0,((q|0)<0)<<31>>31|0)|0;q=I;if(!(q>>>0<0|(q|0)==0&r>>>0<2147483647)){n=0;return n|0}q=r+1|0;f[a+20>>2]=q;r=(q|0)/2|0;i=a+24|0;f[i>>2]=r;f[a+28>>2]=0-r;if(!(q&1))f[i>>2]=r+-1;do if((j[c+38>>1]|0)<514){if(!((g|0)>(p|0)|(g|0)==(p|0)&e>>>0>m>>>0)){n=0;return n|0}r=b[o+m>>0]|0;i=Ul(k|0,l|0,9,0)|0;q=d;f[q>>2]=i;f[q+4>>2]=I;if((r&255)<2){f[a+88>>2]=r&255;break}else{n=0;return n|0}}while(0);n=ud(a+108|0,c)|0;return n|0}function Le(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>2>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>2;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=h;o=m;while(1){f[j>>2]=f[c>>2];o=o+-1|0;if(!o)break;else j=j+4|0}}if(!l){j=h+(b<<2)|0;if((n|0)==(j|0))return;else{p=i;q=n+(~((n+-4-j|0)>>>2)<<2)|0;break}}else{j=b-k|0;o=n;m=j;while(1){f[o>>2]=f[c>>2];m=m+-1|0;if(!m)break;else o=o+4|0}p=i;q=n+(j<<2)|0;break}}else{o=g;if(!g)r=e;else{m=a+4|0;k=f[m>>2]|0;if((k|0)!=(h|0))f[m>>2]=k+(~((k+-4-g|0)>>>2)<<2);lp(o);f[d>>2]=0;f[m>>2]=0;f[a>>2]=0;r=0}if(b>>>0>1073741823)Eo(a);m=r>>1;o=r>>2>>>0<536870911?(m>>>0>>0?b:m):1073741823;if(o>>>0>1073741823)Eo(a);m=Yk(o<<2)|0;k=a+4|0;f[k>>2]=m;f[a>>2]=m;f[d>>2]=m+(o<<2);o=m;l=b;while(1){f[o>>2]=f[c>>2];l=l+-1|0;if(!l)break;else o=o+4|0}p=k;q=m+(b<<2)|0}while(0);f[p>>2]=q;return}function Me(a,b,c){a=a|0;b=b|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=b;g=c-e|0;h=g>>1;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>1>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>1;o=h>>>0>n>>>0;p=b+(n<<1)|0;n=o?p:c;q=n;r=q-e|0;s=r>>1;if(s|0)ok(k|0,b|0,r|0)|0;r=l+(s<<1)|0;if(!o){o=f[m>>2]|0;if((o|0)==(r|0))return;f[m>>2]=o+(~((o+-2-r|0)>>>1)<<1);return}if((n|0)==(c|0))return;n=f[m>>2]|0;r=c+-2-q|0;q=n;o=p;while(1){d[q>>1]=d[o>>1]|0;o=o+2|0;if((o|0)==(c|0))break;else q=q+2|0}f[m>>2]=n+((r>>>1)+1<<1);return}r=k;if(!k)t=j;else{j=a+4|0;n=f[j>>2]|0;if((n|0)!=(l|0))f[j>>2]=n+(~((n+-2-k|0)>>>1)<<1);lp(r);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;t=0}if((g|0)<0)Eo(a);g=t>>1>>>0<1073741823?(t>>>0>>0?h:t):2147483647;if((g|0)<0)Eo(a);t=Yk(g<<1)|0;h=a+4|0;f[h>>2]=t;f[a>>2]=t;f[i>>2]=t+(g<<1);if((b|0)==(c|0))return;g=c+-2-e|0;e=t;i=b;while(1){d[e>>1]=d[i>>1]|0;i=i+2|0;if((i|0)==(c|0))break;else e=e+2|0}f[h>>2]=t+((g>>>1)+1<<1);return}function Ne(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)ok(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=c+-4-o|0;o=l;m=n;while(1){f[o>>2]=f[m>>2];m=m+4|0;if((m|0)==(c|0))break;else o=o+4|0}f[k>>2]=l+((p>>>2)+1<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);lp(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)Eo(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)Eo(a);h=Yk(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=c+-4-d|0;d=h;g=b;while(1){f[d>>2]=f[g>>2];g=g+4|0;if((g|0)==(c|0))break;else d=d+4|0}f[e>>2]=h+((p>>>2)+1<<2);return}function Oe(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h+16|0;j=h;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Ma[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Ma[f[(f[b>>2]|0)+36>>2]&127](b)|0;m=Na[f[(f[b>>2]|0)+44>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Na[f[(f[b>>2]|0)+40>>2]&127](b,d)|0;if(!n){f[j>>2]=f[b+44>>2];f[j+4>>2]=l;f[j+12>>2]=m;f[j+8>>2]=m+12;kc(a,i,c,k,e,j,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[j>>2]=f[b+44>>2];f[j+4>>2]=n;f[j+12>>2]=m;f[j+8>>2]=m+12;jc(a,i,c,k,e,j,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function Pe(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c=u;u=u+16|0;d=c;e=a+76|0;g=f[e>>2]|0;h=a+80|0;i=f[h>>2]|0;if((i|0)!=(g|0))f[h>>2]=i+(~((i+-4-g|0)>>>2)<<2);f[e>>2]=0;f[h>>2]=0;f[a+84>>2]=0;if(g|0)lp(g);g=a+64|0;h=f[g>>2]|0;e=a+68|0;if((f[e>>2]|0)!=(h|0))f[e>>2]=h;f[g>>2]=0;f[e>>2]=0;f[a+72>>2]=0;if(h|0)lp(h);h=b+4|0;e=f[h>>2]|0;g=f[b>>2]|0;i=((e-g|0)/12|0)*3|0;j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=k-l>>2;n=l;l=k;k=g;if(i>>>0<=m>>>0)if(i>>>0>>0?(o=n+(i<<2)|0,(l|0)!=(o|0)):0){f[j>>2]=l+(~((l+-4-o|0)>>>2)<<2);p=e;q=g;r=k}else{p=e;q=g;r=k}else{Og(a,i-m|0);m=f[b>>2]|0;p=f[h>>2]|0;q=m;r=m}if((p|0)!=(q|0)){q=f[a>>2]|0;m=(p-r|0)/12|0;p=0;do{h=p*3|0;f[q+(h<<2)>>2]=f[r+(p*12|0)>>2];f[q+(h+1<<2)>>2]=f[r+(p*12|0)+4>>2];f[q+(h+2<<2)>>2]=f[r+(p*12|0)+8>>2];p=p+1|0}while(p>>>0>>0)}f[d>>2]=-1;if(!(Sb(a,d)|0)){s=0;u=c;return s|0}zb(a,f[d>>2]|0)|0;s=1;u=c;return s|0}function Qe(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f[a+4>>2]=f[b+4>>2];c=a+8|0;d=b+8|0;if((a|0)==(b|0))return a|0;e=b+12|0;g=f[e>>2]|0;if(!g)h=0;else{i=a+16|0;do if(g>>>0>f[i>>2]<<5>>>0){j=f[c>>2]|0;if(!j)k=g;else{lp(j);f[c>>2]=0;f[i>>2]=0;f[a+12>>2]=0;k=f[e>>2]|0}if((k|0)<0)Eo(c);else{j=((k+-1|0)>>>5)+1|0;l=Yk(j<<2)|0;f[c>>2]=l;f[a+12>>2]=0;f[i>>2]=j;m=f[e>>2]|0;n=l;break}}else{m=g;n=f[c>>2]|0}while(0);ok(n|0,f[d>>2]|0,((m+-1|0)>>>5<<2)+4|0)|0;h=f[e>>2]|0}f[a+12>>2]=h;h=a+20|0;e=b+20|0;m=b+24|0;b=f[m>>2]|0;if(!b)o=0;else{d=a+28|0;do if(b>>>0>f[d>>2]<<5>>>0){n=f[h>>2]|0;if(!n)p=b;else{lp(n);f[h>>2]=0;f[d>>2]=0;f[a+24>>2]=0;p=f[m>>2]|0}if((p|0)<0)Eo(h);else{n=((p+-1|0)>>>5)+1|0;c=Yk(n<<2)|0;f[h>>2]=c;f[a+24>>2]=0;f[d>>2]=n;q=f[m>>2]|0;r=c;break}}else{q=b;r=f[h>>2]|0}while(0);ok(r|0,f[e>>2]|0,((q+-1|0)>>>5<<2)+4|0)|0;o=f[m>>2]|0}f[a+24>>2]=o;return a|0}function Re(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;f[c>>2]=1;d=a+4|0;e=c+8|0;g=c+12|0;c=f[e>>2]|0;i=(f[g>>2]|0)-c|0;if(i>>>0<4294967292){Qi(e,i+4|0,0);j=f[e>>2]|0}else j=c;c=j+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>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;k=10;break}}if((k|0)==10){u=b;return j|0}}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){j=1;u=b;return j|0}a=h;h=0;while(1){f[d>>2]=f[a+(h<<2)>>2];f[c>>2]=f[d>>2];h=h+1|0;if(!(Gb(e,c)|0)){j=0;k=10;break}i=f[g>>2]|0;a=f[i>>2]|0;if(h>>>0>=(f[i+4>>2]|0)-a>>2>>>0){j=1;k=10;break}}if((k|0)==10){u=b;return j|0}}return 0}function Te(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0>j-k>>2>>>0){m=k;if(!k)n=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);lp(m);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;n=0}if(h>>>0>1073741823)Eo(a);j=n>>1;m=n>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(m>>>0>1073741823)Eo(a);j=Yk(m<<2)|0;n=a+4|0;f[n>>2]=j;f[a>>2]=j;f[i>>2]=j+(m<<2);if((g|0)<=0)return;Ff(j|0,b|0,g|0)|0;f[n>>2]=j+(g>>>2<<2);return}g=a+4|0;a=f[g>>2]|0;j=a-k>>2;k=h>>>0>j>>>0;h=k?b+(j<<2)|0:c;c=a;j=a;if((h|0)==(b|0))p=l;else{a=h+-4-e|0;e=b;b=l;while(1){f[b>>2]=f[e>>2];e=e+4|0;if((e|0)==(h|0))break;else b=b+4|0}p=l+((a>>>2)+1<<2)|0}if(k){k=d-h|0;if((k|0)<=0)return;Ff(j|0,h|0,k|0)|0;f[g>>2]=(f[g>>2]|0)+(k>>>2<<2);return}else{if((c|0)==(p|0))return;f[g>>2]=c+(~((c+-4-p|0)>>>2)<<2);return}}function Ue(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=c+8|0;e=f[d>>2]|0;g=f[d+4>>2]|0;d=c+16|0;i=d;k=f[i>>2]|0;l=f[i+4>>2]|0;i=Ul(k|0,l|0,4,0)|0;m=I;if((g|0)<(m|0)|(g|0)==(m|0)&e>>>0>>0){n=0;return n|0}o=f[c>>2]|0;p=o+k|0;q=h[p>>0]|h[p+1>>0]<<8|h[p+2>>0]<<16|h[p+3>>0]<<24;p=d;f[p>>2]=i;f[p+4>>2]=m;p=(j[c+38>>1]|0)<514;do if(p){r=Ul(k|0,l|0,8,0)|0;s=I;if((g|0)<(s|0)|(g|0)==(s|0)&e>>>0>>0){n=0;return n|0}else{t=d;f[t>>2]=r;f[t+4>>2]=s;u=s;v=r;break}}else{u=m;v=i}while(0);if(!(q&1)){n=0;return n|0}i=(_(q|0)|0)^31;if((i+-1|0)>>>0>28){n=0;return n|0}f[a+8>>2]=i+1;q=2<>2]=q+-1;i=q+-2|0;f[a+16>>2]=i;f[a+20>>2]=(i|0)/2|0;do if(p){if(!((g|0)>(u|0)|(g|0)==(u|0)&e>>>0>v>>>0)){n=0;return n|0}i=b[o+v>>0]|0;q=Ul(v|0,u|0,1,0)|0;m=d;f[m>>2]=q;f[m+4>>2]=I;if((i&255)<2){f[a+68>>2]=i&255;break}else{n=0;return n|0}}while(0);n=ud(a+88|0,c)|0;return n|0}function Ve(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;fi(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[e>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){j=1;u=b;return j|0}i=0;while(1){f[d>>2]=i*3;f[c>>2]=f[d>>2];i=i+1|0;if(!(Jb(e,c)|0)){j=0;k=10;break}if((i|0)>=(h|0)){j=1;k=10;break}}if((k|0)==10){u=b;return j|0}}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){j=1;u=b;return j|0}a=h;h=0;while(1){f[d>>2]=f[a+(h<<2)>>2];f[c>>2]=f[d>>2];h=h+1|0;if(!(Jb(e,c)|0)){j=0;k=10;break}i=f[g>>2]|0;a=f[i>>2]|0;if(h>>>0>=(f[i+4>>2]|0)-a>>2>>>0){j=1;k=10;break}}if((k|0)==10){u=b;return j|0}}return 0}function We(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+112|0;d=c+96|0;e=c+16|0;g=c+4|0;h=c;i=e+76|0;j=e;k=j+76|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));f[i>>2]=-1;f[g>>2]=0;i=g+4|0;f[i>>2]=0;f[g+8>>2]=0;f[h>>2]=g;f[d>>2]=f[h>>2];if(Hc(e,a,d)|0){d=f[g>>2]|0;Ne(b,d,d+((f[i>>2]|0)-d>>2<<2)|0);l=f[e+68>>2]|0}else l=0;d=f[g>>2]|0;if(d|0){g=f[i>>2]|0;if((g|0)!=(d|0))f[i>>2]=g+(~((g+-4-d|0)>>>2)<<2);lp(d)}d=f[e+56>>2]|0;if(d|0)lp(d);d=f[e+32>>2]|0;if(d|0){g=e+36|0;i=f[g>>2]|0;if((i|0)!=(d|0))f[g>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d)}d=f[e+20>>2]|0;if(d|0){i=e+24|0;g=f[i>>2]|0;if((g|0)!=(d|0))f[i>>2]=g+(~((g+-4-d|0)>>>2)<<2);lp(d)}d=f[e+8>>2]|0;if(d|0){g=e+12|0;i=f[g>>2]|0;if((i|0)!=(d|0))f[g>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d)}d=e+4|0;e=f[d>>2]|0;f[d>>2]=0;if(!e){u=c;return l|0}Vg(e);lp(e);u=c;return l|0}function Xe(a,b,c,d){a=a|0;b=$(b);c=$(c);d=d|0;var e=Ka,f=Ka,g=Ka,h=Ka,i=Ka,j=Ka,k=Ka,l=Ka,m=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=Ka,u=Ka,v=0,w=0;e=$(b+c);f=$(b-c);if(!(f<=$(.5))|(!(f>=$(-.5))|(!(e>=$(.5))|!(e<=$(1.5))))){do if(!(e<=$(.5))){if(e>=$(1.5)){g=$($(1.5)-c);h=$($(1.5)-b);break}if(!(f<=$(-.5))){g=$(c+$(.5));h=$(b+$(-.5));break}else{g=$(c+$(-.5));h=$(b+$(.5));break}}else{g=$($(.5)-c);h=$($(.5)-b)}while(0);i=g;j=$(g-h);k=$(h+g);l=h;m=-1.0}else{i=b;j=f;k=e;l=c;m=1.0}c=$(+i*2.0+-1.0);i=$(+l*2.0+-1.0);o=+k*2.0;p=o+-1.0;q=3.0-o;o=+j*2.0;r=o+1.0;s=1.0-o;o=s>2]=$(0.0);t=$(0.0);u=$(0.0);v=d+4|0;n[v>>2]=t;w=d+8|0;n[w>>2]=u;return}else{l=$($(1.0)/$(L($(k))));k=$(j*l);n[d>>2]=k;t=$(c*l);u=$(i*l);v=d+4|0;n[v>>2]=t;w=d+8|0;n[w>>2]=u;return}}function Ye(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=c&255;g=(d|0)!=0;a:do if(g&(a&3|0)!=0){h=c&255;i=d;j=a;while(1){if((b[j>>0]|0)==h<<24>>24){k=i;l=j;m=6;break a}n=j+1|0;o=i+-1|0;p=(o|0)!=0;if(p&(n&3|0)!=0){i=o;j=n}else{q=o;r=n;s=p;m=5;break}}}else{q=d;r=a;s=g;m=5}while(0);if((m|0)==5)if(s){k=q;l=r;m=6}else{t=0;u=r}b:do if((m|0)==6){r=c&255;if((b[l>>0]|0)==r<<24>>24){t=k;u=l}else{q=X(e,16843009)|0;c:do if(k>>>0>3){s=k;g=l;while(1){a=f[g>>2]^q;if((a&-2139062144^-2139062144)&a+-16843009|0)break;a=g+4|0;d=s+-4|0;if(d>>>0>3){s=d;g=a}else{v=d;w=a;m=11;break c}}x=s;y=g}else{v=k;w=l;m=11}while(0);if((m|0)==11)if(!v){t=0;u=w;break}else{x=v;y=w}while(1){if((b[y>>0]|0)==r<<24>>24){t=x;u=y;break b}q=y+1|0;x=x+-1|0;if(!x){t=0;u=q;break}else y=q}}}while(0);return (t|0?u:0)|0}function Ze(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=e;do if((d|0)==(e|0)){h=a+8|0;i=f[h>>2]|0;j=a+12|0;k=f[j>>2]|0;l=k;if(i>>>0>>0){k=i;m=((l-k>>2)+1|0)/2|0;n=i+(m<<2)|0;o=k-d|0;k=o>>2;p=n+(0-k<<2)|0;if(!k){q=i;r=n}else{ok(p|0,d|0,o|0)|0;q=f[h>>2]|0;r=p}f[c>>2]=r;f[h>>2]=q+(m<<2);s=r;break}m=l-g>>1;l=(m|0)==0?1:m;if(l>>>0>1073741823){m=ra(8)|0;cn(m,13392);f[m>>2]=4748;va(m|0,1128,101)}m=Yk(l<<2)|0;p=m;o=m+((l+3|0)>>>2<<2)|0;n=o;k=m+(l<<2)|0;if((d|0)==(i|0)){t=d;u=n}else{l=o;m=d;v=n;do{f[l>>2]=f[m>>2];l=v+4|0;v=l;m=m+4|0}while((m|0)!=(i|0));t=f[a>>2]|0;u=v}f[a>>2]=p;f[c>>2]=n;f[h>>2]=u;f[j>>2]=k;if(!t)s=o;else{lp(t);s=f[c>>2]|0}}else s=d;while(0);f[s+-4>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+-4;return}function _e(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=a+4|0;g=f[e>>2]|0;if(!g){f[c>>2]=e;h=e;return h|0}e=b[d+11>>0]|0;i=e<<24>>24<0;j=i?f[d+4>>2]|0:e&255;e=i?f[d>>2]|0:d;d=g;g=a+4|0;while(1){a=d+16|0;i=b[a+11>>0]|0;k=i<<24>>24<0;l=k?f[d+20>>2]|0:i&255;i=l>>>0>>0;m=i?l:j;if((m|0)!=0?(n=dj(e,k?f[a>>2]|0:a,m)|0,(n|0)!=0):0)if((n|0)<0)o=8;else o=10;else if(j>>>0>>0)o=8;else o=10;if((o|0)==8){o=0;n=f[d>>2]|0;if(!n){o=9;break}else{p=n;q=d}}else if((o|0)==10){o=0;n=j>>>0>>0?j:l;if((n|0)!=0?(l=dj(k?f[a>>2]|0:a,e,n)|0,(l|0)!=0):0){if((l|0)>=0){o=16;break}}else o=12;if((o|0)==12?(o=0,!i):0){o=16;break}r=d+4|0;i=f[r>>2]|0;if(!i){o=15;break}else{p=i;q=r}}d=p;g=q}if((o|0)==9){f[c>>2]=d;h=d;return h|0}else if((o|0)==15){f[c>>2]=d;h=r;return h|0}else if((o|0)==16){f[c>>2]=d;h=g;return h|0}return 0}function $e(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;d=u;u=u+32|0;e=d+24|0;g=d+16|0;h=d+8|0;i=d;j=a+4|0;k=f[j>>2]|0;l=f[b>>2]|0;m=f[b+4>>2]|0;b=f[c>>2]|0;n=f[c+4>>2]|0;c=b-l<<3;f[j>>2]=k-m+n+c;j=(f[a>>2]|0)+(k>>>5<<2)|0;a=k&31;k=j;if((m|0)!=(a|0)){f[e>>2]=l;f[e+4>>2]=m;f[g>>2]=b;f[g+4>>2]=n;f[h>>2]=k;f[h+4>>2]=a;hd(i,e,g,h);u=d;return}h=n-m+c|0;c=l;if((h|0)>0){if(!m){o=l;p=c;q=h;r=j;s=0}else{l=32-m|0;n=(h|0)<(l|0)?h:l;g=-1>>>(l-n|0)&-1<>2]=f[j>>2]&~g|f[c>>2]&g;g=n+m|0;l=c+4|0;o=l;p=l;q=h-n|0;r=j+(g>>>5<<2)|0;s=g&31}g=(q|0)/32|0;ok(r|0,o|0,g<<2|0)|0;o=q-(g<<5)|0;q=r+(g<<2)|0;r=q;if((o|0)>0){j=-1>>>(32-o|0);f[q>>2]=f[q>>2]&~j|f[p+(g<<2)>>2]&j;t=r;v=o}else{t=r;v=s}}else{t=k;v=m}f[i>>2]=t;f[i+4>>2]=v;u=d;return}function af(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=f[a+32>>2]|0;d=c+8|0;e=f[d+4>>2]|0;g=c+16|0;h=g;i=f[h>>2]|0;j=f[h+4>>2]|0;if(!((e|0)>(j|0)|((e|0)==(j|0)?(f[d>>2]|0)>>>0>i>>>0:0))){k=0;return k|0}d=b[(f[c>>2]|0)+i>>0]|0;c=Ul(i|0,j|0,1,0)|0;j=g;f[j>>2]=c;f[j+4>>2]=I;j=a+48|0;c=f[j>>2]|0;f[j>>2]=0;if(c|0)Ra[f[(f[c>>2]|0)+4>>2]&127](c);switch(d<<24>>24){case 0:{d=Yk(384)|0;$h(d);c=f[j>>2]|0;f[j>>2]=d;if(!c)l=d;else{Ra[f[(f[c>>2]|0)+4>>2]&127](c);m=11}break}case 1:{c=Yk(424)|0;mh(c);d=f[j>>2]|0;f[j>>2]=c;if(!d)l=c;else{Ra[f[(f[d>>2]|0)+4>>2]&127](d);m=11}break}case 2:{d=Yk(440)|0;Sg(d);c=f[j>>2]|0;f[j>>2]=d;if(!c)l=d;else{Ra[f[(f[c>>2]|0)+4>>2]&127](c);m=11}break}default:m=11}if((m|0)==11){m=f[j>>2]|0;if(!m){k=0;return k|0}else l=m}k=Na[f[(f[l>>2]|0)+8>>2]&127](l,a)|0;return k|0}function bf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;e=u;u=u+32|0;g=e+12|0;h=e;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Rh(c)|0;if(i>>>0>4294967279)Eo(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=6}}else{m=i+16&-16;n=Yk(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=6}if((l|0)==6){Ff(k|0,c|0,i|0)|0;j=k}b[j+i>>0]=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=Rh(d)|0;if(i>>>0>4294967279)Eo(h);if(i>>>0<11){b[h+11>>0]=i;if(!i)o=h;else{p=h;l=12}}else{j=i+16&-16;k=Yk(j)|0;f[h>>2]=k;f[h+8>>2]=j|-2147483648;f[h+4>>2]=i;p=k;l=12}if((l|0)==12){Ff(p|0,d|0,i|0)|0;o=p}b[o+i>>0]=0;i=f[a+4>>2]|0;if((i|0)!=0?(o=Vd(i,g,h)|0,(o|0)!=0):0)q=cj(a,f[o+40>>2]|0)|0;else q=-1;if((b[h+11>>0]|0)<0)lp(f[h>>2]|0);if((b[g+11>>0]|0)>=0){u=e;return q|0}lp(f[g>>2]|0);u=e;return q|0}function cf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;c=a+8|0;d=f[c>>2]|0;e=a+12|0;g=f[e>>2]|0;h=g;i=d;do if((d|0)==(g|0)){j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=l;if(k>>>0>l>>>0){n=k;o=((n-m>>2)+1|0)/-2|0;p=k+(o<<2)|0;q=i-n|0;n=q>>2;if(!n)r=k;else{ok(p|0,k|0,q|0)|0;r=f[j>>2]|0}q=p+(n<<2)|0;f[c>>2]=q;f[j>>2]=r+(o<<2);s=q;break}q=h-m>>1;m=(q|0)==0?1:q;if(m>>>0>1073741823){q=ra(8)|0;cn(q,13392);f[q>>2]=4748;va(q|0,1128,101)}q=Yk(m<<2)|0;o=q;n=q+(m>>>2<<2)|0;p=n;t=q+(m<<2)|0;if((k|0)==(d|0)){u=l;v=p}else{l=n;n=k;k=p;do{f[l>>2]=f[n>>2];l=k+4|0;k=l;n=n+4|0}while((n|0)!=(d|0));u=f[a>>2]|0;v=k}f[a>>2]=o;f[j>>2]=p;f[c>>2]=v;f[e>>2]=t;if(!u)s=v;else{lp(u);s=f[c>>2]|0}}else s=d;while(0);f[s>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+4;return}function df(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;lp(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)Eo(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)Eo(a);i=Yk(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=i;o=c}do{b[n>>0]=b[o>>0]|0;o=o+1|0;n=(f[l>>2]|0)+1|0;f[l>>2]=n}while((o|0)!=(d|0));return}else{o=a+4|0;a=(f[o>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;n=a-e|0;if(n|0)ok(k|0,c|0,n|0)|0;c=k+n|0;if(!j){if((f[o>>2]|0)==(c|0))return;f[o>>2]=c;return}if((a|0)==(d|0))return;a=f[o>>2]|0;c=g;do{b[a>>0]=b[c>>0]|0;c=c+1|0;a=(f[o>>2]|0)+1|0;f[o>>2]=a}while((c|0)!=(d|0));return}}function ef(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){Dh(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}i=f[a>>2]|0;j=g-i>>2;g=j+b|0;k=i;if(g>>>0>1073741823)Eo(a);l=d-i|0;d=l>>1;m=l>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(m)if(m>>>0>1073741823){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}else{n=Yk(m<<2)|0;break}else n=0;while(0);d=n+(j<<2)|0;Dh(d|0,0,b<<2|0)|0;b=d;j=n+(m<<2)|0;m=n+(g<<2)|0;if((h|0)==(k|0)){o=b;p=i;q=h}else{i=d;d=h;h=b;do{d=d+-4|0;b=f[d>>2]|0;f[d>>2]=0;f[i+-4>>2]=b;i=h+-4|0;h=i}while((d|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=j;j=p;if((q|0)!=(j|0)){c=q;do{c=c+-4|0;q=f[c>>2]|0;f[c>>2]=0;if(q|0)Ra[f[(f[q>>2]|0)+4>>2]&127](q)}while((c|0)!=(j|0))}if(!p)return;lp(p);return}function ff(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+4|0;e=f[a>>2]|0;g=((f[d>>2]|0)-e|0)/12|0;h=g+1|0;if(h>>>0>357913941)Eo(a);i=a+8|0;j=((f[i>>2]|0)-e|0)/12|0;e=j<<1;k=j>>>0<178956970?(e>>>0>>0?h:e):357913941;do if(k)if(k>>>0>357913941){e=ra(8)|0;cn(e,13392);f[e>>2]=4748;va(e|0,1128,101)}else{l=Yk(k*12|0)|0;break}else l=0;while(0);e=l+(g*12|0)|0;g=e;h=l+(k*12|0)|0;zh(e,c);c=e+12|0;k=f[a>>2]|0;l=f[d>>2]|0;if((l|0)==(k|0)){m=g;n=k;o=k}else{j=e;e=l;l=g;do{g=j+-12|0;e=e+-12|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;j=l+-12|0;l=j}while((e|0)!=(k|0));m=l;n=f[a>>2]|0;o=f[d>>2]|0}f[a>>2]=m;f[d>>2]=c;f[i>>2]=h;h=n;if((o|0)!=(h|0)){i=o;do{i=i+-12|0;if((b[i+11>>0]|0)<0)lp(f[i>>2]|0)}while((i|0)!=(h|0))}if(!n)return;lp(n);return}function gf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>2>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>2;o=h>>>0>n>>>0;p=o?b+(n<<2)|0:c;c=p;n=c-e|0;e=n>>2;if(e|0)ok(k|0,b|0,n|0)|0;n=l+(e<<2)|0;if(o){o=d-c|0;if((o|0)<=0)return;Ff(f[m>>2]|0,p|0,o|0)|0;f[m>>2]=(f[m>>2]|0)+(o>>>2<<2);return}else{o=f[m>>2]|0;if((o|0)==(n|0))return;f[m>>2]=o+(~((o+-4-n|0)>>>2)<<2);return}}n=k;if(!k)q=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);lp(n);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;q=0}if(h>>>0>1073741823)Eo(a);j=q>>1;n=q>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(n>>>0>1073741823)Eo(a);j=Yk(n<<2)|0;h=a+4|0;f[h>>2]=j;f[a>>2]=j;f[i>>2]=j+(n<<2);if((g|0)<=0)return;Ff(j|0,b|0,g|0)|0;f[h>>2]=j+(g>>>2<<2);return}function hf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=c+8|0;e=f[d>>2]|0;g=f[d+4>>2]|0;d=c+16|0;i=d;k=f[i>>2]|0;l=f[i+4>>2]|0;i=Ul(k|0,l|0,4,0)|0;m=I;if((g|0)<(m|0)|(g|0)==(m|0)&e>>>0>>0){n=0;return n|0}o=f[c>>2]|0;p=o+k|0;q=h[p>>0]|h[p+1>>0]<<8|h[p+2>>0]<<16|h[p+3>>0]<<24;p=d;f[p>>2]=i;f[p+4>>2]=m;m=Ul(k|0,l|0,8,0)|0;p=I;if((g|0)<(p|0)|(g|0)==(p|0)&e>>>0>>0){n=0;return n|0}i=d;f[i>>2]=m;f[i+4>>2]=p;if(!(q&1)){n=0;return n|0}i=(_(q|0)|0)^31;if((i+-1|0)>>>0>28){n=0;return n|0}f[a+8>>2]=i+1;q=2<>2]=q+-1;i=q+-2|0;f[a+16>>2]=i;f[a+20>>2]=(i|0)/2|0;do if((j[c+38>>1]|0)<514){if(!((g|0)>(p|0)|(g|0)==(p|0)&e>>>0>m>>>0)){n=0;return n|0}i=b[o+m>>0]|0;q=Ul(k|0,l|0,9,0)|0;r=d;f[r>>2]=q;f[r+4>>2]=I;if((i&255)<2){f[a+68>>2]=i&255;break}else{n=0;return n|0}}while(0);n=ud(a+88|0,c)|0;return n|0}function jf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;e=Yk(64)|0;g=Yk(12)|0;h=f[(f[a+4>>2]|0)+80>>2]|0;f[g+4>>2]=0;f[g>>2]=3416;f[g+8>>2]=h;f[d>>2]=g;yj(e,d);g=e;if((b|0)>=0){h=a+8|0;i=a+12|0;a=f[i>>2]|0;j=f[h>>2]|0;k=a-j>>2;do if((k|0)<=(b|0)){l=b+1|0;m=a;if(l>>>0>k>>>0){ef(h,l-k|0);break}if(l>>>0>>0?(n=j+(l<<2)|0,(m|0)!=(n|0)):0){l=m;do{m=l+-4|0;f[i>>2]=m;o=f[m>>2]|0;f[m>>2]=0;if(o|0)Ra[f[(f[o>>2]|0)+4>>2]&127](o);l=f[i>>2]|0}while((l|0)!=(n|0))}}while(0);i=(f[h>>2]|0)+(b<<2)|0;b=f[i>>2]|0;f[i>>2]=g;if(!b)p=1;else{Ra[f[(f[b>>2]|0)+4>>2]&127](b);p=1}}else{Ra[f[(f[e>>2]|0)+4>>2]&127](e);p=0}e=f[d>>2]|0;f[d>>2]=0;if(!e){u=c;return p|0}Ra[f[(f[e>>2]|0)+4>>2]&127](e);u=c;return p|0}function kf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=f[b>>2]|0;do if((c|0)!=-1){b=f[(f[(f[a+4>>2]|0)+12>>2]|0)+(c<<2)>>2]|0;d=c+1|0;e=((d>>>0)%3|0|0)==0?c+-2|0:d;if((e|0)==-1)g=-1;else g=f[(f[(f[a>>2]|0)+96>>2]|0)+(((e|0)/3|0)*12|0)+(((e|0)%3|0)<<2)>>2]|0;if((b|0)!=-1){e=(((b>>>0)%3|0|0)==0?2:-1)+b|0;if((e|0)==-1){h=0;i=-1;j=b}else{h=0;i=f[(f[(f[a>>2]|0)+96>>2]|0)+(((e|0)/3|0)*12|0)+(((e|0)%3|0)<<2)>>2]|0;j=b}}else{h=1;i=-1;j=-1}if((g|0)!=(i|0)){k=-1;return k|0}b=(((c>>>0)%3|0|0)==0?2:-1)+c|0;if((b|0)==-1)if(h){l=-1;m=-1;n=j;break}else o=-1;else{e=f[(f[(f[a>>2]|0)+96>>2]|0)+(((b|0)/3|0)*12|0)+(((b|0)%3|0)<<2)>>2]|0;if(h){l=-1;m=e;n=j;break}else o=e}e=j+1|0;b=((e>>>0)%3|0|0)==0?j+-2|0:e;if((b|0)==-1){l=-1;m=o;n=j}else{l=f[(f[(f[a>>2]|0)+96>>2]|0)+(((b|0)/3|0)*12|0)+(((b|0)%3|0)<<2)>>2]|0;m=o;n=j}}else{l=-1;m=-1;n=-1}while(0);k=(m|0)!=(l|0)?-1:n;return k|0}function lf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+20|0;if(wc(e,c)|0){g=0;return g|0}a=Yb(e,c)|0;c=f[d>>2]|0;f[d>>2]=0;d=f[a>>2]|0;f[a>>2]=c;if(!d){g=1;return g|0}c=f[d+28>>2]|0;if(c|0){a=c;do{c=a;a=f[a>>2]|0;Bg(c+8|0);lp(c)}while((a|0)!=0)}a=d+20|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0)lp(c);c=f[d+8>>2]|0;if(c|0){a=c;do{c=a;a=f[a>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;lp(h)}if((b[e+11>>0]|0)<0)lp(f[e>>2]|0);lp(c)}while((a|0)!=0)}a=f[d>>2]|0;f[d>>2]=0;if(a|0)lp(a);lp(d);g=1;return g|0}function mf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;f[e>>2]=b;g=a+8|0;if(((f[a+12>>2]|0)-(f[g>>2]|0)>>2|0)<=(b|0))$f(g,b+1|0);h=f[(f[c>>2]|0)+56>>2]|0;do if((h|0)<5){i=a+20+(h*12|0)+4|0;j=f[i>>2]|0;if((j|0)==(f[a+20+(h*12|0)+8>>2]|0)){dh(a+20+(h*12|0)|0,e);break}else{f[j>>2]=b;f[i>>2]=j+4;break}}while(0);b=f[c>>2]|0;h=f[e>>2]|0;f[b+60>>2]=h;e=(f[g>>2]|0)+(h<<2)|0;f[c>>2]=0;c=f[e>>2]|0;f[e>>2]=b;if(!c){u=d;return}b=c+88|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0){b=f[e+8>>2]|0;if(b|0){h=e+12|0;if((f[h>>2]|0)!=(b|0))f[h>>2]=b;lp(b)}lp(e)}e=f[c+68>>2]|0;if(e|0){b=c+72|0;h=f[b>>2]|0;if((h|0)!=(e|0))f[b>>2]=h+(~((h+-4-e|0)>>>2)<<2);lp(e)}e=c+64|0;h=f[e>>2]|0;f[e>>2]=0;if(h|0){e=f[h>>2]|0;if(e|0){b=h+4|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;lp(e)}lp(h)}lp(c);u=d;return}function nf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=3608;b=f[a+68>>2]|0;if(b|0){c=a+72|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+56>>2]|0;if(b|0){d=a+60|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+44>>2]|0;if(b|0){c=a+48|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+32>>2]|0;if(b|0){d=a+36|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}sg(a+8|0);b=a+4|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+40|0;d=f[b>>2]|0;if(d|0){c=a+44|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){jh(i);lp(i)}h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}lp(g)}jh(a);lp(a);return}function of(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if(((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(f[(f[d>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0)==0:0)?(j=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if(((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(f[(f[d>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)==0:0)?(k=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if((((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(f[(f[d>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0:0)?(h=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function pf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;d=u;u=u+48|0;e=d+16|0;g=d;h=d+32|0;i=a+28|0;j=f[i>>2]|0;f[h>>2]=j;k=a+20|0;l=(f[k>>2]|0)-j|0;f[h+4>>2]=l;f[h+8>>2]=b;f[h+12>>2]=c;b=l+c|0;l=a+60|0;f[g>>2]=f[l>>2];f[g+4>>2]=h;f[g+8>>2]=2;j=lm(Aa(146,g|0)|0)|0;a:do if((b|0)!=(j|0)){g=j;m=h;n=2;o=b;while(1){if((g|0)<0)break;o=o-g|0;p=f[m+4>>2]|0;q=g>>>0>p>>>0;r=q?m+8|0:m;s=(q<<31>>31)+n|0;t=g-(q?p:0)|0;f[r>>2]=(f[r>>2]|0)+t;p=r+4|0;f[p>>2]=(f[p>>2]|0)-t;f[e>>2]=f[l>>2];f[e+4>>2]=r;f[e+8>>2]=s;g=lm(Aa(146,e|0)|0)|0;if((o|0)==(g|0)){v=3;break a}else{m=r;n=s}}f[a+16>>2]=0;f[i>>2]=0;f[k>>2]=0;f[a>>2]=f[a>>2]|32;if((n|0)==2)w=0;else w=c-(f[m+4>>2]|0)|0}else v=3;while(0);if((v|0)==3){v=f[a+44>>2]|0;f[a+16>>2]=v+(f[a+48>>2]|0);f[i>>2]=v;f[k>>2]=v;w=c}u=d;return w|0}function qf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+4|0;a=f[d>>2]|0;do if(a|0){e=b[c+11>>0]|0;g=e<<24>>24<0;h=g?f[c+4>>2]|0:e&255;e=g?f[c>>2]|0:c;g=d;i=a;a:while(1){j=i;while(1){k=j+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[j+20>>2]|0:l&255;l=h>>>0>>0?h:n;if((l|0)!=0?(o=dj(m?f[k>>2]|0:k,e,l)|0,(o|0)!=0):0){if((o|0)>=0)break}else p=6;if((p|0)==6?(p=0,n>>>0>=h>>>0):0)break;n=f[j+4>>2]|0;if(!n){q=g;break a}else j=n}i=f[j>>2]|0;if(!i){q=j;break}else g=j}if((q|0)!=(d|0)){g=q+16|0;i=b[g+11>>0]|0;n=i<<24>>24<0;o=n?f[q+20>>2]|0:i&255;i=o>>>0>>0?o:h;if(i|0?(l=dj(e,n?f[g>>2]|0:g,i)|0,l|0):0){if((l|0)<0)break;else r=q;return r|0}if(h>>>0>=o>>>0){r=q;return r|0}}}while(0);r=d;return r|0}function rf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;b=f[a+196>>2]|0;if(b|0){c=a+200|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+184|0;d=f[b>>2]|0;if(d|0){c=a+188|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;while(1){e=h+-12|0;f[c>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);lp(i);j=f[c>>2]|0}if((j|0)==(d|0))break;else h=j}g=f[b>>2]|0}lp(g)}g=f[a+156>>2]|0;if(g|0){b=a+160|0;j=f[b>>2]|0;if((j|0)!=(g|0))f[b>>2]=j+(~((j+-4-g|0)>>>2)<<2);lp(g)}g=a+136|0;j=f[g>>2]|0;f[g>>2]=0;if(!j){l=a+120|0;qp(l);m=a+80|0;qp(m);n=a+64|0;qp(n);o=a+24|0;qp(o);return}g=j+-4|0;b=f[g>>2]|0;if(b|0){h=j+(b<<4)|0;do{h=h+-16|0;qp(h)}while((h|0)!=(j|0))}jp(g);l=a+120|0;qp(l);m=a+80|0;qp(m);n=a+64|0;qp(n);o=a+24|0;qp(o);return}function sf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/12|0)>>>0>=b>>>0){i=h;j=b;do{f[i>>2]=f[c>>2];f[i+4>>2]=f[c+4>>2];f[i+8>>2]=f[c+8>>2];i=(f[g>>2]|0)+12|0;f[g>>2]=i;j=j+-1|0}while((j|0)!=0);return}j=f[a>>2]|0;i=(h-j|0)/12|0;h=i+b|0;if(h>>>0>357913941)Eo(a);k=(e-j|0)/12|0;j=k<<1;e=k>>>0<178956970?(j>>>0>>0?h:j):357913941;do if(e)if(e>>>0>357913941){j=ra(8)|0;cn(j,13392);f[j>>2]=4748;va(j|0,1128,101)}else{l=Yk(e*12|0)|0;break}else l=0;while(0);j=l+(i*12|0)|0;i=l+(e*12|0)|0;e=j;l=b;b=j;do{f[e>>2]=f[c>>2];f[e+4>>2]=f[c+4>>2];f[e+8>>2]=f[c+8>>2];e=b+12|0;b=e;l=l+-1|0}while((l|0)!=0);l=f[a>>2]|0;e=(f[g>>2]|0)-l|0;c=j+(((e|0)/-12|0)*12|0)|0;if((e|0)>0)Ff(c|0,l|0,e|0)|0;f[a>>2]=c;f[g>>2]=b;f[d>>2]=i;if(!l)return;lp(l);return}function tf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=a+8|0;f[c>>2]=f[b>>2];Qe(a+12|0,b+4|0)|0;d=a+44|0;e=b+36|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];if((c|0)==(b|0)){f[a+96>>2]=f[b+88>>2];return}else{Te(a+60|0,f[b+52>>2]|0,f[b+56>>2]|0);Te(a+72|0,f[b+64>>2]|0,f[b+68>>2]|0);Te(a+84|0,f[b+76>>2]|0,f[b+80>>2]|0);f[a+96>>2]=f[b+88>>2];gf(a+100|0,f[b+92>>2]|0,f[b+96>>2]|0);return}}function uf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)Eo(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}else{k=Yk(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=d;d=k;k=e;do{d=d+-4|0;e=f[d>>2]|0;f[d>>2]=0;f[i+-4>>2]=e;i=k+-4|0;k=i}while((d|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0){jh(n);lp(n)}}while((h|0)!=(g|0))}if(!m)return;lp(m);return}function vf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+80|0;g=e;h=e+64|0;Oj(g);i=f[(f[a+8>>2]|0)+56>>2]|0;j=X(Zj(5)|0,d)|0;Vh(g,i,0,d&255,5,0,j,((j|0)<0)<<31>>31,0,0);j=Yk(96)|0;zj(j,g);b[j+84>>0]=1;g=f[j+68>>2]|0;d=j+72|0;i=f[d>>2]|0;if((i|0)!=(g|0))f[d>>2]=i+(~((i+-4-g|0)>>>2)<<2);Lh(j,c)|0;f[h>>2]=j;sh(a,h);a=f[h>>2]|0;f[h>>2]=0;if(!a){u=e;return}h=a+88|0;j=f[h>>2]|0;f[h>>2]=0;if(j|0){h=f[j+8>>2]|0;if(h|0){c=j+12|0;if((f[c>>2]|0)!=(h|0))f[c>>2]=h;lp(h)}lp(j)}j=f[a+68>>2]|0;if(j|0){h=a+72|0;c=f[h>>2]|0;if((c|0)!=(j|0))f[h>>2]=c+(~((c+-4-j|0)>>>2)<<2);lp(j)}j=a+64|0;c=f[j>>2]|0;f[j>>2]=0;if(c|0){j=f[c>>2]|0;if(j|0){h=c+4|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;lp(j)}lp(c)}lp(a);u=e;return}function wf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=f[c>>2]|0;c=f[a>>2]|0;e=c+(d>>>5<<2)|0;f[e>>2]=f[e>>2]|1<<(d&31);e=f[a+64>>2]|0;g=(d|0)==-1;h=d+1|0;if(!g?(i=((h>>>0)%3|0|0)==0?d+-2|0:h,(i|0)!=-1):0)j=f[(f[e>>2]|0)+(i<<2)>>2]|0;else j=-1;i=a+12|0;h=(f[i>>2]|0)+(j>>>5<<2)|0;f[h>>2]=f[h>>2]|1<<(j&31);if(g){j=(f[i>>2]|0)+536870908|0;f[j>>2]=f[j>>2]|-2147483648;return}j=(((d>>>0)%3|0|0)==0?2:-1)+d|0;if((j|0)==-1)k=-1;else k=f[(f[e>>2]|0)+(j<<2)>>2]|0;j=(f[i>>2]|0)+(k>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(k&31);if(g)return;g=f[(f[e+12>>2]|0)+(d<<2)>>2]|0;if((g|0)==-1)return;b[a+24>>0]=0;a=c+(g>>>5<<2)|0;f[a>>2]=f[a>>2]|1<<(g&31);a=g+1|0;c=((a>>>0)%3|0|0)==0?g+-2|0:a;if((c|0)==-1)l=-1;else l=f[(f[e>>2]|0)+(c<<2)>>2]|0;c=(f[i>>2]|0)+(l>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(l&31);l=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((l|0)==-1)m=-1;else m=f[(f[e>>2]|0)+(l<<2)>>2]|0;l=(f[i>>2]|0)+(m>>>5<<2)|0;f[l>>2]=f[l>>2]|1<<(m&31);return}function xf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g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>>2]|0;e=a-c>>2;if((e|0)>(b|0)){u=d;return}i=b+1|0;b=a;if(i>>>0>e>>>0){gg(g,i-e|0);u=d;return}if(i>>>0>=e>>>0){u=d;return}e=c+(i<<2)|0;if((b|0)==(e|0)){u=d;return}f[h>>2]=b+(~((b+-4-e|0)>>>2)<<2);u=d;return}function zf(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=a+172|0;d=f[c>>2]|0;do if((d|0)==-1){e=f[a+144>>2]|0;g=Ma[f[(f[e>>2]|0)+32>>2]&127](e)|0;if(((h[g+36>>0]<<8|h[g+37>>0])&65535)<514)if(b[a+76>>0]|0){g=a+72|0;e=f[g>>2]|0;i=f[a+64>>2]|0;j=f[a+68>>2]|0;k=i+(e>>>3)|0;if(k>>>0>>0?(l=h[k>>0]|0,k=e+1|0,f[g>>2]=k,(l&1<<(e&7)|0)!=0):0){l=i+(k>>>3)|0;if(l>>>0>>0){m=(h[l>>0]|0)>>>(k&7)&1;l=e+2|0;f[g>>2]=l;n=l;o=m}else{n=k;o=0}k=i+(n>>>3)|0;if(k>>>0>>0){j=(h[k>>0]|0)>>>(n&7);f[g>>2]=n+1;p=j<<1&2}else p=0;q=(p|o)<<1|1}else q=0}else q=1;else q=7}else{j=(f[a+196>>2]|0)+(d<<2)|0;g=f[j>>2]|0;k=g+-1|0;f[j>>2]=k;if((g|0)<1){r=9;return r|0}else{q=f[3328+(f[(f[(f[a+184>>2]|0)+((f[c>>2]|0)*12|0)>>2]|0)+(k<<2)>>2]<<2)>>2]|0;break}}while(0);f[a+168>>2]=q;r=q;return r|0}function Af(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,k=0,l=0,m=0,n=0;do if(c){if((j[a+38>>1]|0)>=514){if(nh(d,a)|0)break;else e=0;return e|0}g=a+8|0;i=f[g>>2]|0;k=f[g+4>>2]|0;g=a+16|0;l=g;m=f[l>>2]|0;n=Ul(m|0,f[l+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=f[s>>2];f[a>>2]=r;f[j>>2]=t;f[n>>2]=v;td(i,k,j,h);f[q>>2]=f[i>>2];f[q+4>>2]=f[o>>2];p=p+e|0}while((p|0)<(d|0));jp(l);u=g;return 1}function Cf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=u;u=u+16|0;e=d+8|0;g=d+4|0;h=d;if(!c){i=0;u=d;return i|0}f[a>>2]=b;f[e>>2]=0;Ph(e,b)|0;a:do if(!(f[e>>2]|0))j=8;else{b=0;while(1){Ph(g,f[a>>2]|0)|0;k=Yk(44)|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;n[k+16>>2]=$(1.0);l=k+20|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;f[l+12>>2]=0;n[k+36>>2]=$(1.0);f[k+40>>2]=f[g>>2];if(!(Cc(a,k)|0))break;f[h>>2]=k;vi(c,h)|0;l=f[h>>2]|0;f[h>>2]=0;if(l|0){jh(l);lp(l)}b=b+1|0;if(b>>>0>=(f[e>>2]|0)>>>0){j=8;break a}}jh(k);lp(k);m=0}while(0);if((j|0)==8)m=Cc(a,c)|0;i=m;u=d;return i|0}function Df(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+32|0;e=d+16|0;g=d;switch(c<<24>>24){case 0:{c=Yk(44)|0;h=c;i=h+44|0;do{f[h>>2]=0;h=h+4|0}while((h|0)<(i|0));nk(c);f[c>>2]=3528;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=c;u=d;return}case 1:{c=Yk(44)|0;h=c;i=h+44|0;do{f[h>>2]=0;h=h+4|0}while((h|0)<(i|0));nk(c);f[c>>2]=3484;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=c;u=d;return}default:{c=Yk(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=28;h=c;j=11693;i=h+28|0;do{b[h>>0]=b[j>>0]|0;h=h+1|0;j=j+1|0}while((h|0)<(i|0));b[c+28>>0]=0;f[e>>2]=-1;c=e+4|0;zh(c,g);f[a>>2]=f[e>>2];zh(a+4|0,c);f[a+16>>2]=0;if((b[c+11>>0]|0)<0)lp(f[c>>2]|0);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=d;return}}}function Ef(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;do if(!(Hn(a,f[c+8>>2]|0,g)|0)){h=a+8|0;if(!(Hn(a,f[c>>2]|0,g)|0)){i=f[h>>2]|0;Va[f[(f[i>>2]|0)+24>>2]&3](i,c,d,e,g);break}i=c+32|0;if((f[c+16>>2]|0)!=(d|0)?(j=c+20|0,(f[j>>2]|0)!=(d|0)):0){f[i>>2]=e;k=c+44|0;if((f[k>>2]|0)==4)break;l=c+52|0;b[l>>0]=0;m=c+53|0;b[m>>0]=0;n=f[h>>2]|0;Wa[f[(f[n>>2]|0)+20>>2]&3](n,c,d,d,1,g);if(b[m>>0]|0)if(!(b[l>>0]|0)){o=3;p=11}else q=3;else{o=4;p=11}if((p|0)==11){f[j>>2]=d;j=c+40|0;f[j>>2]=(f[j>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0){b[c+54>>0]=1;q=o}else q=o}f[k>>2]=q;break}if((e|0)==1)f[i>>2]=1}else Pk(0,c,d,e);while(0);return}function Ff(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;if((d|0)>=8192)return Ea(a|0,c|0,d|0)|0;e=a|0;g=a+d|0;if((a&3)==(c&3)){while(a&3){if(!d)return e|0;b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0;d=d-1|0}h=g&-4|0;d=h-64|0;while((a|0)<=(d|0)){f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];f[a+12>>2]=f[c+12>>2];f[a+16>>2]=f[c+16>>2];f[a+20>>2]=f[c+20>>2];f[a+24>>2]=f[c+24>>2];f[a+28>>2]=f[c+28>>2];f[a+32>>2]=f[c+32>>2];f[a+36>>2]=f[c+36>>2];f[a+40>>2]=f[c+40>>2];f[a+44>>2]=f[c+44>>2];f[a+48>>2]=f[c+48>>2];f[a+52>>2]=f[c+52>>2];f[a+56>>2]=f[c+56>>2];f[a+60>>2]=f[c+60>>2];a=a+64|0;c=c+64|0}while((a|0)<(h|0)){f[a>>2]=f[c>>2];a=a+4|0;c=c+4|0}}else{h=g-4|0;while((a|0)<(h|0)){b[a>>0]=b[c>>0]|0;b[a+1>>0]=b[c+1>>0]|0;b[a+2>>0]=b[c+2>>0]|0;b[a+3>>0]=b[c+3>>0]|0;a=a+4|0;c=c+4|0}}while((a|0)<(g|0)){b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}return e|0}function Gf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=f[c+88>>2]|0;if(!d){e=0;return e|0}if((f[d>>2]|0)!=1){e=0;return e|0}g=d+8|0;d=f[g>>2]|0;f[a+4>>2]=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;i=a+8|0;j=c+24|0;c=b[j>>0]|0;k=c<<24>>24;l=a+12|0;m=f[l>>2]|0;n=f[i>>2]|0;o=m-n>>2;p=n;n=m;if(k>>>0<=o>>>0)if(k>>>0>>0?(m=p+(k<<2)|0,(n|0)!=(m|0)):0){f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2);q=c;r=d}else{q=c;r=d}else{Og(i,k-o|0);q=b[j>>0]|0;r=f[g>>2]|0}g=r+4|0;j=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;if(q<<24>>24>0){g=f[i>>2]|0;i=q<<24>>24;q=4;o=0;k=j;while(1){f[g+(o<<2)>>2]=k;q=q+4|0;o=o+1|0;d=r+q|0;c=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;if((o|0)>=(i|0)){s=c;break}else k=c}}else s=j;f[a+20>>2]=s;e=1;return e|0}function Hf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=a+4|0;f[h>>2]=0;if(!c){u=e;return}i=a+8|0;j=f[i>>2]|0;k=j<<5;if(k>>>0>>0){f[g>>2]=0;l=g+4|0;f[l>>2]=0;m=g+8|0;f[m>>2]=0;if((c|0)<0)Eo(a);n=j<<6;j=c+31&-32;Jg(g,k>>>0<1073741823?(n>>>0>>0?j:n):2147483647);n=f[a>>2]|0;f[a>>2]=f[g>>2];f[g>>2]=n;g=f[h>>2]|0;f[h>>2]=c;f[l>>2]=g;g=f[i>>2]|0;f[i>>2]=f[m>>2];f[m>>2]=g;if(n|0)lp(n);o=a}else{f[h>>2]=c;o=a}a=f[o>>2]|0;o=a;h=a;a=c>>>5;n=a<<2;if(!(b[d>>0]|0)){Dh(h|0,0,n|0)|0;d=c-(a<<5)|0;g=o+(a<<2)|0;if(!d){u=e;return}f[g>>2]=f[g>>2]&~(-1>>>(32-d|0));u=e;return}else{Dh(h|0,-1,n|0)|0;n=c-(a<<5)|0;c=o+(a<<2)|0;if(!n){u=e;return}f[c>>2]=f[c>>2]|-1>>>(32-n|0);u=e;return}}function If(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e+12|0;h=e+8|0;i=e;f[i>>2]=f[b>>2];f[g>>2]=f[i>>2];i=xc(a,g,h,e+4|0,c)|0;c=f[i>>2]|0;if(c|0){j=c;u=e;return j|0}c=Yk(40)|0;zh(c+16|0,d);zh(c+28|0,d+12|0);d=f[h>>2]|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=d;f[i>>2]=c;d=f[f[a>>2]>>2]|0;if(!d)k=c;else{f[a>>2]=d;k=f[i>>2]|0}wd(f[a+4>>2]|0,k);k=a+8|0;f[k>>2]=(f[k>>2]|0)+1;j=c;u=e;return j|0}function Jf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;j=f[g+4>>2]|0;g=Ul(i|0,j|0,4,0)|0;k=I;if((e|0)<(k|0)|(e|0)==(k|0)&d>>>0>>0){l=0;return l|0}m=f[b>>2]|0;b=m+i|0;n=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;b=c;f[b>>2]=g;f[b+4>>2]=k;k=Ul(i|0,j|0,8,0)|0;j=I;if((e|0)<(j|0)|(e|0)==(j|0)&d>>>0>>0){l=0;return l|0}d=m+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=c;f[d>>2]=k;f[d+4>>2]=j;if((n|0)>(g|0)){l=0;return l|0}f[a+12>>2]=n;f[a+16>>2]=g;j=Wl(g|0,((g|0)<0)<<31>>31|0,n|0,((n|0)<0)<<31>>31|0)|0;n=I;if(!(n>>>0<0|(n|0)==0&j>>>0<2147483647)){l=0;return l|0}n=j+1|0;f[a+20>>2]=n;j=(n|0)/2|0;g=a+24|0;f[g>>2]=j;f[a+28>>2]=0-j;if(n&1|0){l=1;return l|0}f[g>>2]=j+-1;l=1;return l|0}function Kf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=(d-e|0)/12|0;h=g+1|0;i=e;j=d;if(h>>>0>357913941)Eo(a);d=a+8|0;k=((f[d>>2]|0)-e|0)/12|0;l=k<<1;m=k>>>0<178956970?(l>>>0>>0?h:l):357913941;do if(m)if(m>>>0>357913941){l=ra(8)|0;cn(l,13392);f[l>>2]=4748;va(l|0,1128,101)}else{n=Yk(m*12|0)|0;break}else n=0;while(0);l=n+(g*12|0)|0;h=n+(m*12|0)|0;f[l>>2]=f[b>>2];f[n+(g*12|0)+4>>2]=f[b+4>>2];f[n+(g*12|0)+8>>2]=f[b+8>>2];b=l+12|0;if((j|0)==(i|0))o=l;else{g=l;l=j;while(1){j=l;l=l+-12|0;f[g+-12>>2]=f[l>>2];f[g+-8>>2]=f[j+-8>>2];f[g+-4>>2]=f[j+-4>>2];j=g+-12|0;if((l|0)==(i|0)){o=j;break}else g=j}}f[a>>2]=o;f[c>>2]=b;f[d>>2]=h;if(!e)return;lp(e);return}function Lf(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;g=Yk(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;h=g+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0;o=l;p=m-o|0;Ff(n|0,l|0,p|0)|0;b[c>>0]=1;q=f[a>>2]|0;r=q+4|0;f[r>>2]=d;f[q>>2]=0;return}Rg(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0;o=l;p=m-o|0;Ff(n|0,l|0,p|0)|0;b[c>>0]=1;q=f[a>>2]|0;r=q+4|0;f[r>>2]=d;f[q>>2]=0;return}function Mf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(c>>>0>4294967279)Eo(a);d=a+11|0;e=b[d>>0]|0;g=e<<24>>24<0;if(g){h=f[a+4>>2]|0;i=(f[a+8>>2]&2147483647)+-1|0}else{h=e&255;i=10}j=h>>>0>c>>>0?h:c;c=j>>>0<11;k=c?10:(j+16&-16)+-1|0;do if((k|0)!=(i|0)){do if(c){j=f[a>>2]|0;if(g){l=a;m=0;n=j;o=13}else{Tm(a,j,(e&255)+1|0)|0;lp(j);o=15}}else{j=Yk(k+1|0)|0;if(g){l=j;m=1;n=f[a>>2]|0;o=13;break}else{Tm(j,a,(e&255)+1|0)|0;p=j;o=14;break}}while(0);if((o|0)==13){Tm(l,n,(f[a+4>>2]|0)+1|0)|0;lp(n);if(m){p=l;o=14}else o=15}if((o|0)==14){f[a+8>>2]=k+1|-2147483648;f[a+4>>2]=h;f[a>>2]=p;break}else if((o|0)==15){b[d>>0]=h;break}}while(0);return}function Nf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=a+12|0;a:do if((f[e>>2]|0)!=(c|0)){g=f[a>>2]|0;h=a+4|0;i=f[h>>2]|0;if((i|0)!=(g|0)){j=i;while(1){i=j+-12|0;f[h>>2]=i;if((b[i+11>>0]|0)<0){lp(f[i>>2]|0);k=f[h>>2]|0}else k=i;if((k|0)==(g|0))break;else j=k}}f[e>>2]=c;j=f[c+8>>2]|0;if(j|0){i=a+8|0;l=g;m=j;while(1){j=m+8|0;if((l|0)==(f[i>>2]|0))ff(a,j);else{zh(l,j);f[h>>2]=(f[h>>2]|0)+12}j=f[m>>2]|0;if(!j)break a;l=f[h>>2]|0;m=j}}}while(0);if((d|0)<0){n=0;return n|0}c=f[a>>2]|0;if((((f[a+4>>2]|0)-c|0)/12|0)>>>0<=d>>>0){n=0;return n|0}a=c+(d*12|0)|0;if((b[a+11>>0]|0)<0){n=f[a>>2]|0;return n|0}else{n=a;return n|0}return 0}function Of(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=u;u=u+16|0;d=c;e=f[(f[a>>2]|0)+8>>2]|0;g=a+8|0;h=a+12|0;i=(f[h>>2]|0)-(f[g>>2]|0)>>2;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;Ta[e&15](a,i,d);i=f[d>>2]|0;f[d>>2]=0;if(!i){k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}d=i+88|0;a=f[d>>2]|0;f[d>>2]=0;if(a|0){d=f[a+8>>2]|0;if(d|0){e=a+12|0;if((f[e>>2]|0)!=(d|0))f[e>>2]=d;lp(d)}lp(a)}a=f[i+68>>2]|0;if(a|0){d=i+72|0;e=f[d>>2]|0;if((e|0)!=(a|0))f[d>>2]=e+(~((e+-4-a|0)>>>2)<<2);lp(a)}a=i+64|0;e=f[a>>2]|0;f[a>>2]=0;if(e|0){a=f[e>>2]|0;if(a|0){d=e+4|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;lp(a)}lp(e)}lp(i);k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}function Pf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>3>>>0>=b>>>0){h=g;i=b;do{j=h;f[j>>2]=0;f[j+4>>2]=0;h=(f[e>>2]|0)+8|0;f[e>>2]=h;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;h=g-i>>3;g=h+b|0;if(g>>>0>536870911)Eo(a);j=d-i|0;i=j>>2;d=j>>3>>>0<268435455?(i>>>0>>0?g:i):536870911;do if(d)if(d>>>0>536870911){i=ra(8)|0;cn(i,13392);f[i>>2]=4748;va(i|0,1128,101)}else{k=Yk(d<<3)|0;break}else k=0;while(0);i=k+(h<<3)|0;h=k+(d<<3)|0;d=i;k=b;b=i;do{g=d;f[g>>2]=0;f[g+4>>2]=0;d=b+8|0;b=d;k=k+-1|0}while((k|0)!=0);k=f[a>>2]|0;d=(f[e>>2]|0)-k|0;g=i+(0-(d>>3)<<3)|0;if((d|0)>0)Ff(g|0,k|0,d|0)|0;f[a>>2]=g;f[e>>2]=b;f[c>>2]=h;if(!k)return;lp(k);return}function Qf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=1048576){if((h|0)!=1048576?(e=i+4194304|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,1048576-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>1048576){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==1048576;return k|0}function Rf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c;if(!(Kd(a,b)|0)){e=0;u=c;return e|0}g=b+8|0;i=f[g>>2]|0;j=f[g+4>>2]|0;g=b+16|0;k=g;l=f[k>>2]|0;m=Ul(l|0,f[k+4>>2]|0,4,0)|0;k=I;if((j|0)<(k|0)|(j|0)==(k|0)&i>>>0>>0){e=0;u=c;return e|0}i=(f[b>>2]|0)+l|0;l=h[i>>0]|h[i+1>>0]<<8|h[i+2>>0]<<16|h[i+3>>0]<<24;i=g;f[i>>2]=m;f[i+4>>2]=k;if((l|0)<0){e=0;u=c;return e|0}k=f[a+152>>2]|0;if((l|0)>=(k|0)){e=0;u=c;return e|0}l=a+156|0;f[d>>2]=0;i=a+160|0;m=f[i>>2]|0;g=f[l>>2]|0;j=m-g>>2;n=g;g=m;if(k>>>0<=j>>>0){if(k>>>0>>0?(m=n+(k<<2)|0,(g|0)!=(m|0)):0)f[i>>2]=g+(~((g+-4-m|0)>>>2)<<2)}else ag(l,k-j|0,d);e=ud(a+168|0,b)|0;u=c;return e|0}function Sf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=524288){if((h|0)!=524288?(e=i+2097152|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,524288-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>524288){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==524288;return k|0}function Tf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=262144){if((h|0)!=262144?(e=i+1048576|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,262144-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>262144){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==262144;return k|0}function Uf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(!c){g=0;u=d;return g|0}h=a+84|0;i=f[h>>2]|0;j=a+88|0;k=f[j>>2]|0;if((k|0)!=(i|0))f[j>>2]=k+(~((k+-4-i|0)>>>2)<<2);f[h>>2]=0;f[j>>2]=0;f[a+92>>2]=0;if(i|0)lp(i);i=a+72|0;j=f[i>>2]|0;h=a+76|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;f[i>>2]=0;f[h>>2]=0;f[a+80>>2]=0;if(j|0)lp(j);j=c+4|0;h=(f[j>>2]|0)-(f[c>>2]|0)>>2;b[e>>0]=0;Hf(a,h,e);h=c+24|0;i=c+28|0;k=(f[i>>2]|0)-(f[h>>2]|0)>>2;b[e>>0]=0;Hf(a+12|0,k,e);Le(a+28|0,(f[j>>2]|0)-(f[c>>2]|0)>>2,3596);fi(a+52|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);fi(a+40|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);f[a+64>>2]=c;b[a+24>>0]=1;g=1;u=d;return g|0}function Vf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=65536){if((h|0)!=65536?(e=i+262144|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,65536-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>65536){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==65536;return k|0}function Wf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=32768){if((h|0)!=32768?(e=i+131072|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,32768-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>32768){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==32768;return k|0} +function tb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0;g=u;u=u+64|0;d=g+16|0;h=g;i=a+8|0;f[i>>2]=e;j=a+32|0;k=a+36|0;l=f[k>>2]|0;m=f[j>>2]|0;n=l-m>>2;o=m;m=l;if(n>>>0>=e>>>0){if(n>>>0>e>>>0?(l=o+(e<<2)|0,(m|0)!=(l|0)):0)f[k>>2]=m+(~((m+-4-l|0)>>>2)<<2)}else Og(j,e-n|0);n=d;j=n+48|0;do{f[n>>2]=0;n=n+4|0}while((n|0)<(j|0));f[h>>2]=0;if(!e){p=0;q=0}else{ag(d,e,h);p=f[d+12>>2]|0;q=f[d+16>>2]|0}f[h>>2]=0;n=d+16|0;j=q-p>>2;l=p;p=q;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0?Q+-2|0:Z;if(((U|0)!=-1?(f[(f[j>>2]|0)+(U>>>5<<2)>>2]&1<<(U&31)|0)==0:0)?(Z=f[(f[(f[o>>2]|0)+12>>2]|0)+(U<<2)>>2]|0,U=Z+1|0,(Z|0)!=-1):0)ba=((U>>>0)%3|0|0)==0?Z+-2|0:U;else ba=-1}else{U=(((Q>>>0)%3|0|0)==0?2:-1)+Q|0;if(((U|0)!=-1?(f[(f[j>>2]|0)+(U>>>5<<2)>>2]&1<<(U&31)|0)==0:0)?(Z=f[(f[(f[o>>2]|0)+12>>2]|0)+(U<<2)>>2]|0,(Z|0)!=-1):0)if(!((Z>>>0)%3|0)){ba=Z+2|0;break}else{ba=Z+-1|0;break}else ba=-1}while(0);if((ba|0)==(H|0)){S=aa;v=58;break b}if((ba|0)!=-1|P){Q=ba;R=aa}else break}if(L){M=-1;N=0;O=aa;continue}if(f[(f[j>>2]|0)+(J<<2)>>2]&K|0){M=-1;N=0;O=aa;continue}R=f[(f[(f[o>>2]|0)+12>>2]|0)+(I<<2)>>2]|0;if((R|0)==-1){M=-1;N=0;O=aa;continue}if(!((R>>>0)%3|0)){M=R+2|0;N=0;O=aa;continue}else{M=R+-1|0;N=0;O=aa;continue}}if((v|0)==58){v=0;if((S|0)>0){$=S;v=38}else{ca=X(F,e)|0;v=72}}if((v|0)==38){v=0;if(y){Dh(f[h>>2]|0,0,D|0)|0;O=$+-1|0;N=s+(O<<2)|0;M=a+60+(O*12|0)+4|0;I=a+60+(O*12|0)|0;O=f[h>>2]|0;K=0;J=0;while(1){L=f[N>>2]|0;f[N>>2]=L+1;if((f[M>>2]|0)>>>0<=L>>>0){da=O;ea=0;break a}if(!(f[(f[I>>2]|0)+(L>>>5<<2)>>2]&1<<(L&31))){L=f[d+(K*12|0)>>2]|0;H=0;do{R=O+(H<<2)|0;f[R>>2]=(f[R>>2]|0)+(f[L+(H<<2)>>2]|0);H=H+1|0}while((H|0)!=(e|0));fa=J+1|0}else fa=J;K=K+1|0;if((K|0)>=($|0)){ga=fa;break}else J=fa}}else{J=$+-1|0;K=s+(J<<2)|0;O=a+60+(J*12|0)|0;I=f[h>>2]|0;M=f[a+60+(J*12|0)+4>>2]|0;J=f[K>>2]|0;N=0;H=0;while(1){L=J;J=J+1|0;f[K>>2]=J;if(M>>>0<=L>>>0){da=I;ea=0;break a}R=H+((f[(f[O>>2]|0)+(L>>>5<<2)>>2]&1<<(L&31)|0)==0&1)|0;N=N+1|0;if((N|0)>=($|0)){ga=R;break}else H=R}}H=X(F,e)|0;if(ga){N=f[h>>2]|0;if(y){O=0;do{I=N+(O<<2)|0;f[I>>2]=(f[I>>2]|0)/(ga|0)|0;O=O+1|0}while((O|0)!=(e|0))}O=b+(H<<2)|0;I=c+(H<<2)|0;if((f[i>>2]|0)>0){M=0;do{J=f[N+(M<<2)>>2]|0;K=f[z>>2]|0;if((J|0)>(K|0)){R=f[A>>2]|0;f[R+(M<<2)>>2]=K;ha=R}else{R=f[B>>2]|0;K=f[A>>2]|0;f[K+(M<<2)>>2]=(J|0)<(R|0)?R:J;ha=K}M=M+1|0;ia=f[i>>2]|0}while((M|0)<(ia|0));if((ia|0)>0){M=0;do{N=(f[O+(M<<2)>>2]|0)+(f[ha+(M<<2)>>2]|0)|0;K=I+(M<<2)|0;f[K>>2]=N;do if((N|0)>(f[z>>2]|0)){ja=N-(f[C>>2]|0)|0;v=94}else{if((N|0)>=(f[B>>2]|0))break;ja=(f[C>>2]|0)+N|0;v=94}while(0);if((v|0)==94){v=0;f[K>>2]=ja}M=M+1|0}while((M|0)<(f[i>>2]|0))}}}else{ca=H;v=72}}if((v|0)==72?(v=0,M=c+((X(F+-1|0,e)|0)<<2)|0,I=b+(ca<<2)|0,O=c+(ca<<2)|0,(f[i>>2]|0)>0):0){N=0;do{J=f[M+(N<<2)>>2]|0;R=f[z>>2]|0;if((J|0)>(R|0)){L=f[A>>2]|0;f[L+(N<<2)>>2]=R;ka=L}else{L=f[B>>2]|0;R=f[A>>2]|0;f[R+(N<<2)>>2]=(J|0)<(L|0)?L:J;ka=R}N=N+1|0;la=f[i>>2]|0}while((N|0)<(la|0));if((la|0)>0){N=0;do{M=(f[I+(N<<2)>>2]|0)+(f[ka+(N<<2)>>2]|0)|0;H=O+(N<<2)|0;f[H>>2]=M;if((M|0)<=(f[z>>2]|0)){if((M|0)<(f[B>>2]|0)){ma=(f[C>>2]|0)+M|0;v=82}}else{ma=M-(f[C>>2]|0)|0;v=82}if((v|0)==82){v=0;f[H>>2]=ma}N=N+1|0}while((N|0)<(f[i>>2]|0))}}F=F+1|0;if((F|0)>=(m|0)){v=99;break}N=f[r>>2]|0;E=f[N>>2]|0;if((f[N+4>>2]|0)-E>>2>>>0<=F>>>0){G=N;v=28;break}}if((v|0)==28)Eo(G);else if((v|0)==99){da=f[h>>2]|0;ea=1;break}}else{da=w;ea=1}while(0);if(da|0){w=f[n>>2]|0;if((w|0)!=(da|0))f[n>>2]=w+(~((w+-4-da|0)>>>2)<<2);lp(da)}lp(s);s=f[d+36>>2]|0;if(s|0){da=d+40|0;w=f[da>>2]|0;if((w|0)!=(s|0))f[da>>2]=w+(~((w+-4-s|0)>>>2)<<2);lp(s)}s=f[d+24>>2]|0;if(s|0){w=d+28|0;da=f[w>>2]|0;if((da|0)!=(s|0))f[w>>2]=da+(~((da+-4-s|0)>>>2)<<2);lp(s)}s=f[d+12>>2]|0;if(s|0){da=d+16|0;w=f[da>>2]|0;if((w|0)!=(s|0))f[da>>2]=w+(~((w+-4-s|0)>>>2)<<2);lp(s)}s=f[d>>2]|0;if(!s){u=g;return ea|0}w=d+4|0;d=f[w>>2]|0;if((d|0)!=(s|0))f[w>>2]=d+(~((d+-4-s|0)>>>2)<<2);lp(s);u=g;return ea|0}function ub(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D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2]|0;k=f[l>>2]|0;if((m|0)>(k|0)){o=f[p>>2]|0;f[o+(j<<2)>>2]=k;r=o}else{o=f[n>>2]|0;k=f[p>>2]|0;f[k+(j<<2)>>2]=(m|0)<(o|0)?o:m;r=k}j=j+1|0;s=f[i>>2]|0}while((j|0)<(s|0));if((s|0)>0){s=a+20|0;j=0;do{p=(f[b+(j<<2)>>2]|0)+(f[r+(j<<2)>>2]|0)|0;q=c+(j<<2)|0;f[q>>2]=p;if((p|0)<=(f[l>>2]|0)){if((p|0)<(f[n>>2]|0)){t=(f[s>>2]|0)+p|0;v=18}}else{t=p-(f[s>>2]|0)|0;v=18}if((v|0)==18){v=0;f[q>>2]=t}j=j+1|0}while((j|0)<(f[i>>2]|0))}}j=f[a+48>>2]|0;t=f[a+52>>2]|0;s=Yk(16)|0;f[s>>2]=0;f[s+4>>2]=0;f[s+8>>2]=0;f[s+12>>2]=0;f[h>>2]=0;n=h+4|0;f[n>>2]=0;f[h+8>>2]=0;do if(e)if(e>>>0>1073741823)Eo(h);else{l=e<<2;r=Yk(l)|0;f[h>>2]=r;q=r+(e<<2)|0;f[h+8>>2]=q;Dh(r|0,0,l|0)|0;f[n>>2]=q;w=r;break}else w=0;while(0);r=a+56|0;q=f[r>>2]|0;l=f[q+4>>2]|0;p=f[q>>2]|0;k=l-p|0;m=k>>2;a:do if((k|0)>4){o=j+12|0;x=(e|0)>0;y=a+16|0;z=a+32|0;A=a+12|0;B=a+20|0;C=e<<2;if(l-p>>2>>>0>1){D=p;E=1}else{F=q;Eo(F)}while(1){G=f[D+(E<<2)>>2]|0;H=(((G>>>0)%3|0|0)==0?2:-1)+G|0;I=(G|0)==-1|(H|0)==-1;J=G;K=1;L=0;b:while(1){M=K^1;N=J;O=L;while(1){if((N|0)==-1){P=O;v=58;break b}Q=f[d+(O*12|0)>>2]|0;R=f[o>>2]|0;S=f[R+(N<<2)>>2]|0;if((S|0)!=-1){T=f[j>>2]|0;U=f[t>>2]|0;V=f[U+(f[T+(S<<2)>>2]<<2)>>2]|0;W=S+1|0;Y=((W>>>0)%3|0|0)==0?S+-2|0:W;if((Y|0)==-1)Z=-1;else Z=f[T+(Y<<2)>>2]|0;Y=f[U+(Z<<2)>>2]|0;W=(((S>>>0)%3|0|0)==0?2:-1)+S|0;if((W|0)==-1)_=-1;else _=f[T+(W<<2)>>2]|0;W=f[U+(_<<2)>>2]|0;if((V|0)<(E|0)&(Y|0)<(E|0)&(W|0)<(E|0)){U=X(V,e)|0;V=X(Y,e)|0;Y=X(W,e)|0;if(x){W=0;do{f[Q+(W<<2)>>2]=(f[c+(W+Y<<2)>>2]|0)+(f[c+(W+V<<2)>>2]|0)-(f[c+(W+U<<2)>>2]|0);W=W+1|0}while((W|0)!=(e|0))}W=O+1|0;if((W|0)==4){$=4;v=41;break b}else aa=W}else aa=O}else aa=O;do if(K){W=N+1|0;U=((W>>>0)%3|0|0)==0?N+-2|0:W;if((U|0)!=-1?(W=f[R+(U<<2)>>2]|0,U=W+1|0,(W|0)!=-1):0)ba=((U>>>0)%3|0|0)==0?W+-2|0:U;else ba=-1}else{U=(((N>>>0)%3|0|0)==0?2:-1)+N|0;if((U|0)!=-1?(W=f[R+(U<<2)>>2]|0,(W|0)!=-1):0)if(!((W>>>0)%3|0)){ba=W+2|0;break}else{ba=W+-1|0;break}else ba=-1}while(0);if((ba|0)==(G|0)){P=aa;v=58;break b}if((ba|0)!=-1|M){N=ba;O=aa}else break}if(I){J=-1;K=0;L=aa;continue}O=f[R+(H<<2)>>2]|0;if((O|0)==-1){J=-1;K=0;L=aa;continue}if(!((O>>>0)%3|0)){J=O+2|0;K=0;L=aa;continue}else{J=O+-1|0;K=0;L=aa;continue}}if((v|0)==58){v=0;if((P|0)>0){$=P;v=41}else{ca=X(E,e)|0;v=72}}if((v|0)==41){v=0;if(x){Dh(f[h>>2]|0,0,C|0)|0;L=$+-1|0;K=s+(L<<2)|0;J=a+60+(L*12|0)+4|0;H=a+60+(L*12|0)|0;L=f[h>>2]|0;I=0;G=0;while(1){O=f[K>>2]|0;f[K>>2]=O+1;if((f[J>>2]|0)>>>0<=O>>>0){da=L;ea=0;break a}if(!(f[(f[H>>2]|0)+(O>>>5<<2)>>2]&1<<(O&31))){O=f[d+(I*12|0)>>2]|0;N=0;do{M=L+(N<<2)|0;f[M>>2]=(f[M>>2]|0)+(f[O+(N<<2)>>2]|0);N=N+1|0}while((N|0)!=(e|0));fa=G+1|0}else fa=G;I=I+1|0;if((I|0)>=($|0)){ga=fa;break}else G=fa}}else{G=$+-1|0;I=s+(G<<2)|0;L=a+60+(G*12|0)|0;H=f[h>>2]|0;J=f[a+60+(G*12|0)+4>>2]|0;G=f[I>>2]|0;K=0;N=0;while(1){O=G;G=G+1|0;f[I>>2]=G;if(J>>>0<=O>>>0){da=H;ea=0;break a}M=N+((f[(f[L>>2]|0)+(O>>>5<<2)>>2]&1<<(O&31)|0)==0&1)|0;K=K+1|0;if((K|0)>=($|0)){ga=M;break}else N=M}}N=X(E,e)|0;if(ga){K=f[h>>2]|0;if(x){L=0;do{H=K+(L<<2)|0;f[H>>2]=(f[H>>2]|0)/(ga|0)|0;L=L+1|0}while((L|0)!=(e|0))}L=b+(N<<2)|0;H=c+(N<<2)|0;if((f[i>>2]|0)>0){J=0;do{G=f[K+(J<<2)>>2]|0;I=f[y>>2]|0;if((G|0)>(I|0)){M=f[z>>2]|0;f[M+(J<<2)>>2]=I;ha=M}else{M=f[A>>2]|0;I=f[z>>2]|0;f[I+(J<<2)>>2]=(G|0)<(M|0)?M:G;ha=I}J=J+1|0;ia=f[i>>2]|0}while((J|0)<(ia|0));if((ia|0)>0){J=0;do{K=(f[L+(J<<2)>>2]|0)+(f[ha+(J<<2)>>2]|0)|0;I=H+(J<<2)|0;f[I>>2]=K;do if((K|0)>(f[y>>2]|0)){ja=K-(f[B>>2]|0)|0;v=94}else{if((K|0)>=(f[A>>2]|0))break;ja=(f[B>>2]|0)+K|0;v=94}while(0);if((v|0)==94){v=0;f[I>>2]=ja}J=J+1|0}while((J|0)<(f[i>>2]|0))}}}else{ca=N;v=72}}if((v|0)==72?(v=0,J=c+((X(E+-1|0,e)|0)<<2)|0,H=b+(ca<<2)|0,L=c+(ca<<2)|0,(f[i>>2]|0)>0):0){K=0;do{G=f[J+(K<<2)>>2]|0;M=f[y>>2]|0;if((G|0)>(M|0)){O=f[z>>2]|0;f[O+(K<<2)>>2]=M;ka=O}else{O=f[A>>2]|0;M=f[z>>2]|0;f[M+(K<<2)>>2]=(G|0)<(O|0)?O:G;ka=M}K=K+1|0;la=f[i>>2]|0}while((K|0)<(la|0));if((la|0)>0){K=0;do{J=(f[H+(K<<2)>>2]|0)+(f[ka+(K<<2)>>2]|0)|0;N=L+(K<<2)|0;f[N>>2]=J;if((J|0)<=(f[y>>2]|0)){if((J|0)<(f[A>>2]|0)){ma=(f[B>>2]|0)+J|0;v=82}}else{ma=J-(f[B>>2]|0)|0;v=82}if((v|0)==82){v=0;f[N>>2]=ma}K=K+1|0}while((K|0)<(f[i>>2]|0))}}E=E+1|0;if((E|0)>=(m|0)){v=99;break}K=f[r>>2]|0;D=f[K>>2]|0;if((f[K+4>>2]|0)-D>>2>>>0<=E>>>0){F=K;v=28;break}}if((v|0)==28)Eo(F);else if((v|0)==99){da=f[h>>2]|0;ea=1;break}}else{da=w;ea=1}while(0);if(da|0){w=f[n>>2]|0;if((w|0)!=(da|0))f[n>>2]=w+(~((w+-4-da|0)>>>2)<<2);lp(da)}lp(s);s=f[d+36>>2]|0;if(s|0){da=d+40|0;w=f[da>>2]|0;if((w|0)!=(s|0))f[da>>2]=w+(~((w+-4-s|0)>>>2)<<2);lp(s)}s=f[d+24>>2]|0;if(s|0){w=d+28|0;da=f[w>>2]|0;if((da|0)!=(s|0))f[w>>2]=da+(~((da+-4-s|0)>>>2)<<2);lp(s)}s=f[d+12>>2]|0;if(s|0){da=d+16|0;w=f[da>>2]|0;if((w|0)!=(s|0))f[da>>2]=w+(~((w+-4-s|0)>>>2)<<2);lp(s)}s=f[d>>2]|0;if(!s){u=g;return ea|0}w=d+4|0;d=f[w>>2]|0;if((d|0)!=(s|0))f[w>>2]=d+(~((d+-4-s|0)>>>2)<<2);lp(s);u=g;return ea|0}function vb(a,c,d,e,g,i){a=a|0;c=+c;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0,F=0,G=0,H=0.0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0.0,fa=0.0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0;j=u;u=u+560|0;k=j+8|0;l=j;m=j+524|0;n=m;o=j+512|0;f[l>>2]=0;p=o+12|0;Dm(c)|0;if((I|0)<0){q=1;r=13941;s=-c}else{q=(g&2049|0)!=0&1;r=(g&2048|0)==0?((g&1|0)==0?13942:13947):13944;s=c}Dm(s)|0;t=I&2146435072;do if(t>>>0<2146435072|(t|0)==2146435072&0<0){c=+So(s,l)*2.0;v=c!=0.0;if(v)f[l>>2]=(f[l>>2]|0)+-1;w=i|32;if((w|0)==97){x=i&32;y=(x|0)==0?r:r+9|0;z=q|2;A=12-e|0;do if(!(e>>>0>11|(A|0)==0)){B=A;C=8.0;do{B=B+-1|0;C=C*16.0}while((B|0)!=0);if((b[y>>0]|0)==45){D=-(C+(-c-C));break}else{D=c+C-C;break}}else D=c;while(0);A=f[l>>2]|0;B=(A|0)<0?0-A|0:A;E=bi(B,((B|0)<0)<<31>>31,p)|0;if((E|0)==(p|0)){B=o+11|0;b[B>>0]=48;F=B}else F=E;b[F+-1>>0]=(A>>31&2)+43;A=F+-2|0;b[A>>0]=i+15;E=(e|0)<1;B=(g&8|0)==0;G=m;H=D;while(1){J=~~H;K=G+1|0;b[G>>0]=h[13976+J>>0]|x;H=(H-+(J|0))*16.0;if((K-n|0)==1?!(B&(E&H==0.0)):0){b[K>>0]=46;L=G+2|0}else L=K;if(!(H!=0.0))break;else G=L}G=L-n|0;E=p-A|0;B=(e|0)!=0&(G+-2|0)<(e|0)?e+2|0:G;x=E+z+B|0;Yi(a,32,d,x,g);qn(a,y,z);Yi(a,48,d,x,g^65536);qn(a,m,G);Yi(a,48,B-G|0,0,0);qn(a,A,E);Yi(a,32,d,x,g^8192);M=x;break}x=(e|0)<0?6:e;if(v){E=(f[l>>2]|0)+-28|0;f[l>>2]=E;N=E;O=c*268435456.0}else{N=f[l>>2]|0;O=c}E=(N|0)<0?k:k+288|0;H=O;G=E;do{B=~~H>>>0;f[G>>2]=B;G=G+4|0;H=(H-+(B>>>0))*1.0e9}while(H!=0.0);if((N|0)>0){v=N;A=E;z=G;while(1){y=(v|0)<29?v:29;B=z+-4|0;if(B>>>0>=A>>>0){K=0;J=B;do{B=Rl(f[J>>2]|0,0,y|0)|0;P=Ul(B|0,I|0,K|0,0)|0;B=I;Q=Wk(P|0,B|0,1e9,0)|0;f[J>>2]=Q;K=Nn(P|0,B|0,1e9,0)|0;J=J+-4|0}while(J>>>0>=A>>>0);if(K){J=A+-4|0;f[J>>2]=K;R=J}else R=A}else R=A;J=z;while(1){if(J>>>0<=R>>>0)break;B=J+-4|0;if(!(f[B>>2]|0))J=B;else break}K=(f[l>>2]|0)-y|0;f[l>>2]=K;if((K|0)>0){v=K;A=R;z=J}else{S=K;T=R;U=J;break}}}else{S=N;T=E;U=G}if((S|0)<0){z=((x+25|0)/9|0)+1|0;A=(w|0)==102;v=S;K=T;B=U;while(1){P=0-v|0;Q=(P|0)<9?P:9;if(K>>>0>>0){P=(1<>>Q;W=0;Y=K;do{Z=f[Y>>2]|0;f[Y>>2]=(Z>>>Q)+W;W=X(Z&P,V)|0;Y=Y+4|0}while(Y>>>0>>0);Y=(f[K>>2]|0)==0?K+4|0:K;if(!W){_=Y;$=B}else{f[B>>2]=W;_=Y;$=B+4|0}}else{_=(f[K>>2]|0)==0?K+4|0:K;$=B}Y=A?E:_;V=($-Y>>2|0)>(z|0)?Y+(z<<2)|0:$;v=(f[l>>2]|0)+Q|0;f[l>>2]=v;if((v|0)>=0){aa=_;ba=V;break}else{K=_;B=V}}}else{aa=T;ba=U}B=E;if(aa>>>0>>0){K=(B-aa>>2)*9|0;v=f[aa>>2]|0;if(v>>>0<10)ca=K;else{z=K;K=10;while(1){K=K*10|0;A=z+1|0;if(v>>>0>>0){ca=A;break}else z=A}}}else ca=0;z=(w|0)==103;K=(x|0)!=0;v=x-((w|0)!=102?ca:0)+((K&z)<<31>>31)|0;if((v|0)<(((ba-B>>2)*9|0)+-9|0)){A=v+9216|0;v=E+4+(((A|0)/9|0)+-1024<<2)|0;G=((A|0)%9|0)+1|0;if((G|0)<9){A=10;V=G;while(1){G=A*10|0;V=V+1|0;if((V|0)==9){da=G;break}else A=G}}else da=10;A=f[v>>2]|0;V=(A>>>0)%(da>>>0)|0;w=(v+4|0)==(ba|0);if(!(w&(V|0)==0)){C=(((A>>>0)/(da>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;G=(da|0)/2|0;H=V>>>0>>0?.5:w&(V|0)==(G|0)?1.0:1.5;if(!q){ea=C;fa=H}else{G=(b[r>>0]|0)==45;ea=G?-C:C;fa=G?-H:H}G=A-V|0;f[v>>2]=G;if(ea+fa!=ea){V=G+da|0;f[v>>2]=V;if(V>>>0>999999999){V=aa;G=v;while(1){A=G+-4|0;f[G>>2]=0;if(A>>>0>>0){w=V+-4|0;f[w>>2]=0;ga=w}else ga=V;w=(f[A>>2]|0)+1|0;f[A>>2]=w;if(w>>>0>999999999){V=ga;G=A}else{ha=ga;ia=A;break}}}else{ha=aa;ia=v}G=(B-ha>>2)*9|0;V=f[ha>>2]|0;if(V>>>0<10){ja=ha;ka=ia;la=G}else{A=G;G=10;while(1){G=G*10|0;w=A+1|0;if(V>>>0>>0){ja=ha;ka=ia;la=w;break}else A=w}}}else{ja=aa;ka=v;la=ca}}else{ja=aa;ka=v;la=ca}A=ka+4|0;ma=ja;na=la;oa=ba>>>0>A>>>0?A:ba}else{ma=aa;na=ca;oa=ba}A=oa;while(1){if(A>>>0<=ma>>>0){pa=0;break}G=A+-4|0;if(!(f[G>>2]|0))A=G;else{pa=1;break}}v=0-na|0;do if(z){G=((K^1)&1)+x|0;if((G|0)>(na|0)&(na|0)>-5){qa=G+-1-na|0;ra=i+-1|0}else{qa=G+-1|0;ra=i+-2|0}G=g&8;if(!G){if(pa?(V=f[A+-4>>2]|0,(V|0)!=0):0)if(!((V>>>0)%10|0)){w=10;Y=0;while(1){w=w*10|0;P=Y+1|0;if((V>>>0)%(w>>>0)|0|0){sa=P;break}else Y=P}}else sa=0;else sa=9;Y=((A-B>>2)*9|0)+-9|0;if((ra|32|0)==102){w=Y-sa|0;V=(w|0)>0?w:0;ta=0;ua=(qa|0)<(V|0)?qa:V;va=ra;break}else{V=Y+na-sa|0;Y=(V|0)>0?V:0;ta=0;ua=(qa|0)<(Y|0)?qa:Y;va=ra;break}}else{ta=G;ua=qa;va=ra}}else{ta=g&8;ua=x;va=i}while(0);x=ua|ta;B=(x|0)!=0&1;K=(va|32|0)==102;if(K){wa=0;xa=(na|0)>0?na:0}else{z=(na|0)<0?v:na;Y=bi(z,((z|0)<0)<<31>>31,p)|0;z=p;if((z-Y|0)<2){V=Y;while(1){w=V+-1|0;b[w>>0]=48;if((z-w|0)<2)V=w;else{ya=w;break}}}else ya=Y;b[ya+-1>>0]=(na>>31&2)+43;V=ya+-2|0;b[V>>0]=va;wa=V;xa=z-V|0}V=q+1+ua+B+xa|0;Yi(a,32,d,V,g);qn(a,r,q);Yi(a,48,d,V,g^65536);if(K){v=ma>>>0>E>>>0?E:ma;w=m+9|0;Q=w;W=m+8|0;P=v;do{J=bi(f[P>>2]|0,0,w)|0;if((P|0)==(v|0))if((J|0)==(w|0)){b[W>>0]=48;za=W}else za=J;else if(J>>>0>m>>>0){Dh(m|0,48,J-n|0)|0;y=J;while(1){Z=y+-1|0;if(Z>>>0>m>>>0)y=Z;else{za=Z;break}}}else za=J;qn(a,za,Q-za|0);P=P+4|0}while(P>>>0<=E>>>0);if(x|0)qn(a,13992,1);if(P>>>0>>0&(ua|0)>0){E=P;Q=ua;while(1){W=bi(f[E>>2]|0,0,w)|0;if(W>>>0>m>>>0){Dh(m|0,48,W-n|0)|0;v=W;while(1){K=v+-1|0;if(K>>>0>m>>>0)v=K;else{Aa=K;break}}}else Aa=W;qn(a,Aa,(Q|0)<9?Q:9);E=E+4|0;v=Q+-9|0;if(!(E>>>0>>0&(Q|0)>9)){Ba=v;break}else Q=v}}else Ba=ua;Yi(a,48,Ba+9|0,9,0)}else{Q=pa?A:ma+4|0;if((ua|0)>-1){E=m+9|0;w=(ta|0)==0;P=E;x=0-n|0;v=m+8|0;J=ma;K=ua;while(1){B=bi(f[J>>2]|0,0,E)|0;if((B|0)==(E|0)){b[v>>0]=48;Ca=v}else Ca=B;do if((J|0)==(ma|0)){B=Ca+1|0;qn(a,Ca,1);if(w&(K|0)<1){Da=B;break}qn(a,13992,1);Da=B}else{if(Ca>>>0<=m>>>0){Da=Ca;break}Dh(m|0,48,Ca+x|0)|0;B=Ca;while(1){z=B+-1|0;if(z>>>0>m>>>0)B=z;else{Da=z;break}}}while(0);W=P-Da|0;qn(a,Da,(K|0)>(W|0)?W:K);B=K-W|0;J=J+4|0;if(!(J>>>0>>0&(B|0)>-1)){Ea=B;break}else K=B}}else Ea=ua;Yi(a,48,Ea+18|0,18,0);qn(a,wa,p-wa|0)}Yi(a,32,d,V,g^8192);M=V}else{K=(i&32|0)!=0;Q=q+3|0;Yi(a,32,d,Q,g&-65537);qn(a,r,q);qn(a,s!=s|0.0!=0.0?(K?13968:13972):K?13960:13964,3);Yi(a,32,d,Q,g^8192);M=Q}while(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f[k>>2]>>2]|0)+(D<<2)>>2];y=w+2|0;if((y|0)==-1){E=C;F=-1}else{z=C;A=y;B=92}}if((B|0)==92){B=0;E=z;F=f[(f[f[k>>2]>>2]|0)+(A<<2)>>2]|0}f[s>>2]=F;y=t+96|0;w=t+100|0;x=(l-j|0)/12|0;G=j;H=o;o=o+1|0;if(H>>>0>>0){I=n;J=t;K=v;L=G;M=j;N=l}else{O=l;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;if(o>>>0<=x>>>0)if(o>>>0>>0?(P=G+(o*12|0)|0,(O|0)!=(P|0)):0){Q=O+(~(((O+-12-P|0)>>>0)/12|0)*12|0)|0;f[w>>2]=Q;R=G;S=v;T=t;U=Q;V=j}else{R=G;S=v;T=t;U=l;V=j}else{sf(y,o-x|0,d);x=f[i>>2]|0;G=f[x+44>>2]|0;R=f[y>>2]|0;S=x;T=G;U=f[G+100>>2]|0;V=f[G+96>>2]|0}I=S;J=T;K=S;L=R;M=V;N=U}f[L+(H*12|0)>>2]=E;f[L+(H*12|0)+4>>2]=f[q>>2];f[L+(H*12|0)+8>>2]=f[s>>2];if(o>>>0>=((N-M|0)/12|0)>>>0){r=I;break}else{t=J;j=M;n=I;v=K;l=N}}}f[(f[r+4>>2]|0)+80>>2]=b;W=1;u=c;return W|0}f[e>>2]=0;b=e+4|0;f[b>>2]=0;f[e+8>>2]=0;r=f[k>>2]|0;N=(f[r+4>>2]|0)-(f[r>>2]|0)|0;l=N>>2;f[g>>2]=0;K=g+4|0;f[K>>2]=0;f[g+8>>2]=0;do if(l|0)if(l>>>0>1073741823)Eo(g);else{v=Yk(N)|0;f[g>>2]=v;I=v+(l<<2)|0;f[g+8>>2]=I;Dh(v|0,0,N|0)|0;f[K>>2]=I;break}while(0);a:do if(((f[r+28>>2]|0)-(f[r+24>>2]|0)|0)>0){N=a+120|0;l=e+8|0;I=r;v=0;while(1){n=f[(f[I+24>>2]|0)+(v<<2)>>2]|0;b:do if((n|0)!=-1){c:do if((f[(f[N>>2]|0)+(v>>>5<<2)>>2]&1<<(v&31)|0)==0?(M=f[m>>2]|0,j=f[p>>2]|0,J=j,(M|0)!=(j|0)):0){t=(((n>>>0)%3|0|0)==0?2:-1)+n|0;o=(M-j|0)/144|0;if((t|0)==-1){j=0;while(1){M=f[(f[f[J+(j*144|0)+68>>2]>>2]|0)+(n<<2)>>2]|0;if(1<<(M&31)&f[(f[J+(j*144|0)+16>>2]|0)+(M>>>5<<2)>>2]|0){X=0;break a}j=j+1|0;if(j>>>0>=o>>>0){Y=n;break c}}}j=I+12|0;M=0;while(1){s=f[(f[f[J+(M*144|0)+68>>2]>>2]|0)+(n<<2)>>2]|0;if(1<<(s&31)&f[(f[J+(M*144|0)+16>>2]|0)+(s>>>5<<2)>>2]|0){s=f[J+(M*144|0)+32>>2]|0;L=f[s+(n<<2)>>2]|0;q=f[j>>2]|0;E=f[q+(t<<2)>>2]|0;do if((E|0)!=-1)if(!((E>>>0)%3|0)){Z=E+2|0;break}else{Z=E+-1|0;break}else Z=-1;while(0);if((Z|0)!=(n|0)){E=Z;while(1){if((E|0)==-1){X=0;break a}if((f[s+(E<<2)>>2]|0)!=(L|0)){Y=E;break c}U=(((E>>>0)%3|0|0)==0?2:-1)+E|0;do if((U|0)!=-1){V=f[q+(U<<2)>>2]|0;if((V|0)==-1){_=-1;break}if(!((V>>>0)%3|0)){_=V+2|0;break}else{_=V+-1|0;break}}else _=-1;while(0);if((_|0)==(n|0))break;else E=_}}}M=M+1|0;if(M>>>0>=o>>>0){Y=n;break}}}else Y=n;while(0);o=f[b>>2]|0;f[(f[g>>2]|0)+(Y<<2)>>2]=o-(f[e>>2]|0)>>2;f[d>>2]=Y;M=o;if(M>>>0<(f[l>>2]|0)>>>0){f[M>>2]=Y;f[b>>2]=M+4;$=I}else{dh(e,d);$=f[k>>2]|0}if((((Y|0)!=-1?(M=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0,(M|0)!=-1):0)?(o=f[(f[$+12>>2]|0)+(M<<2)>>2]|0,(o|0)!=-1):0)?(M=o+(((o>>>0)%3|0|0)==0?2:-1)|0,(M|0)!=-1&(M|0)!=(Y|0)):0){o=$;t=M;M=Y;while(1){j=f[m>>2]|0;J=f[p>>2]|0;E=J;d:do if((j|0)==(J|0))B=66;else{q=(j-J|0)/144|0;L=0;while(1){s=f[E+(L*144|0)+32>>2]|0;L=L+1|0;if((f[s+(t<<2)>>2]|0)!=(f[s+(M<<2)>>2]|0))break;if(L>>>0>=q>>>0){B=66;break d}}q=f[b>>2]|0;f[(f[g>>2]|0)+(t<<2)>>2]=q-(f[e>>2]|0)>>2;f[d>>2]=t;L=q;if(L>>>0<(f[l>>2]|0)>>>0){f[L>>2]=t;f[b>>2]=L+4;aa=o}else{dh(e,d);aa=f[k>>2]|0}ba=aa}while(0);if((B|0)==66){B=0;E=f[g>>2]|0;f[E+(t<<2)>>2]=f[E+(M<<2)>>2];ba=o}if((t|0)==-1){ca=ba;break b}E=(((t>>>0)%3|0|0)==0?2:-1)+t|0;if((E|0)==-1){ca=ba;break b}J=f[(f[ba+12>>2]|0)+(E<<2)>>2]|0;if((J|0)==-1){ca=ba;break b}E=J+(((J>>>0)%3|0|0)==0?2:-1)|0;if((E|0)!=-1&(E|0)!=(Y|0)){J=t;o=ba;t=E;M=J}else{ca=ba;break}}}else ca=$}else ca=I;while(0);v=v+1|0;if((v|0)>=((f[ca+28>>2]|0)-(f[ca+24>>2]|0)>>2|0)){B=27;break}else I=ca}}else B=27;while(0);if((B|0)==27){B=f[i>>2]|0;ca=f[B+44>>2]|0;$=f[ca+100>>2]|0;ba=f[ca+96>>2]|0;if(($|0)==(ba|0))da=B;else{Y=h+4|0;aa=h+8|0;k=B;p=B;B=ca;ca=ba;ba=$;$=0;while(1){f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;m=(f[g>>2]|0)+($*3<<2)|0;f[h>>2]=f[m>>2];f[h+4>>2]=f[m+4>>2];f[h+8>>2]=f[m+8>>2];m=B+96|0;_=B+100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ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0;i=u;u=u+64|0;j=i+16|0;k=i;l=i+24|0;m=i+8|0;n=i+20|0;f[j>>2]=c;o=(a|0)!=0;q=l+40|0;r=q;s=l+39|0;l=m+4|0;t=c;c=0;v=0;w=0;a:while(1){do if((c|0)>-1)if((v|0)>(2147483647-c|0)){x=_o()|0;f[x>>2]=75;y=-1;break}else{y=v+c|0;break}else y=c;while(0);x=b[t>>0]|0;if(!(x<<24>>24)){z=87;break}else{A=x;B=t}b:while(1){switch(A<<24>>24){case 37:{C=B;D=B;z=9;break b;break}case 0:{E=B;F=B;break b;break}default:{}}x=B+1|0;f[j>>2]=x;A=b[x>>0]|0;B=x}c:do if((z|0)==9)while(1){z=0;if((b[C+1>>0]|0)!=37){E=C;F=D;break c}x=D+1|0;G=C+2|0;f[j>>2]=G;if((b[G>>0]|0)==37){C=G;D=x;z=9}else{E=G;F=x;break}}while(0);x=F-t|0;if(o)qn(a,t,x);if(x|0){t=E;c=y;v=x;continue}x=E+1|0;G=(b[x>>0]|0)+-48|0;if(G>>>0<10){H=(b[E+2>>0]|0)==36;J=H?G:-1;K=H?1:w;L=H?E+3|0:x}else{J=-1;K=w;L=x}f[j>>2]=L;x=b[L>>0]|0;H=(x<<24>>24)+-32|0;d:do if(H>>>0<32){G=x;M=0;N=L;O=H;while(1){P=1<>2]=P;U=b[P>>0]|0;O=(U<<24>>24)+-32|0;if(O>>>0>=32){Q=U;R=P;S=T;break}else{G=U;M=T;N=P}}}else{Q=x;R=L;S=0}while(0);if(Q<<24>>24==42){x=R+1|0;H=(b[x>>0]|0)+-48|0;if(H>>>0<10?(b[R+2>>0]|0)==36:0){f[h+(H<<2)>>2]=10;V=1;W=R+3|0;X=f[g+((b[x>>0]|0)+-48<<3)>>2]|0}else{if(K|0){Y=-1;break}if(o){H=(f[e>>2]|0)+(4-1)&~(4-1);N=f[H>>2]|0;f[e>>2]=H+4;V=0;W=x;X=N}else{V=0;W=x;X=0}}f[j>>2]=W;x=(X|0)<0;Z=W;_=x?S|8192:S;$=V;aa=x?0-X|0:X}else{x=Nj(j)|0;if((x|0)<0){Y=-1;break}Z=f[j>>2]|0;_=S;$=K;aa=x}do if((b[Z>>0]|0)==46){if((b[Z+1>>0]|0)!=42){f[j>>2]=Z+1;x=Nj(j)|0;ba=f[j>>2]|0;ca=x;break}x=Z+2|0;N=(b[x>>0]|0)+-48|0;if(N>>>0<10?(b[Z+3>>0]|0)==36:0){f[h+(N<<2)>>2]=10;N=f[g+((b[x>>0]|0)+-48<<3)>>2]|0;H=Z+4|0;f[j>>2]=H;ba=H;ca=N;break}if($|0){Y=-1;break a}if(o){N=(f[e>>2]|0)+(4-1)&~(4-1);H=f[N>>2]|0;f[e>>2]=N+4;da=H}else da=0;f[j>>2]=x;ba=x;ca=da}else{ba=Z;ca=-1}while(0);x=ba;H=0;while(1){if(((b[x>>0]|0)+-65|0)>>>0>57){Y=-1;break a}ea=x+1|0;f[j>>2]=ea;fa=b[(b[x>>0]|0)+-65+(13460+(H*58|0))>>0]|0;ga=fa&255;if((ga+-1|0)>>>0<8){x=ea;H=ga}else break}if(!(fa<<24>>24)){Y=-1;break}N=(J|0)>-1;do if(fa<<24>>24==19)if(N){Y=-1;break a}else z=49;else{if(N){f[h+(J<<2)>>2]=ga;M=g+(J<<3)|0;G=f[M+4>>2]|0;O=k;f[O>>2]=f[M>>2];f[O+4>>2]=G;z=49;break}if(!o){Y=0;break a}Td(k,ga,e)}while(0);if((z|0)==49?(z=0,!o):0){t=ea;c=y;v=0;w=$;continue}N=b[x>>0]|0;G=(H|0)!=0&(N&15|0)==3?N&-33:N;N=_&-65537;O=(_&8192|0)==0?_:N;e:do switch(G|0){case 110:{switch((H&255)<<24>>24){case 0:{f[f[k>>2]>>2]=y;t=ea;c=y;v=0;w=$;continue a;break}case 1:{f[f[k>>2]>>2]=y;t=ea;c=y;v=0;w=$;continue a;break}case 2:{M=f[k>>2]|0;f[M>>2]=y;f[M+4>>2]=((y|0)<0)<<31>>31;t=ea;c=y;v=0;w=$;continue a;break}case 3:{d[f[k>>2]>>1]=y;t=ea;c=y;v=0;w=$;continue a;break}case 4:{b[f[k>>2]>>0]=y;t=ea;c=y;v=0;w=$;continue a;break}case 6:{f[f[k>>2]>>2]=y;t=ea;c=y;v=0;w=$;continue a;break}case 7:{M=f[k>>2]|0;f[M>>2]=y;f[M+4>>2]=((y|0)<0)<<31>>31;t=ea;c=y;v=0;w=$;continue a;break}default:{t=ea;c=y;v=0;w=$;continue a}}break}case 112:{ha=O|8;ia=ca>>>0>8?ca:8;ja=120;z=61;break}case 88:case 120:{ha=O;ia=ca;ja=G;z=61;break}case 111:{M=k;P=f[M>>2]|0;T=f[M+4>>2]|0;M=Tj(P,T,q)|0;U=r-M|0;ka=P;la=T;ma=M;na=O;oa=(O&8|0)==0|(ca|0)>(U|0)?ca:U+1|0;pa=0;qa=13924;z=67;break}case 105:case 100:{U=k;M=f[U>>2]|0;T=f[U+4>>2]|0;if((T|0)<0){U=Wl(0,0,M|0,T|0)|0;P=I;ra=k;f[ra>>2]=U;f[ra+4>>2]=P;sa=U;ta=P;ua=1;va=13924;z=66;break e}else{sa=M;ta=T;ua=(O&2049|0)!=0&1;va=(O&2048|0)==0?((O&1|0)==0?13924:13926):13925;z=66;break e}break}case 117:{T=k;sa=f[T>>2]|0;ta=f[T+4>>2]|0;ua=0;va=13924;z=66;break}case 99:{b[s>>0]=f[k>>2];wa=s;xa=N;ya=1;za=0;Aa=13924;Ba=q;break}case 109:{T=_o()|0;Ca=wn(f[T>>2]|0)|0;z=71;break}case 115:{T=f[k>>2]|0;Ca=T|0?T:13934;z=71;break}case 67:{f[m>>2]=f[k>>2];f[l>>2]=0;f[k>>2]=m;Da=m;Ea=-1;z=75;break}case 83:{T=f[k>>2]|0;if(!ca){Yi(a,32,aa,0,O);Fa=0;z=84}else{Da=T;Ea=ca;z=75}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{t=ea;c=y;v=vb(a,+p[k>>3],aa,ca,O,G)|0;w=$;continue a;break}default:{wa=t;xa=O;ya=ca;za=0;Aa=13924;Ba=q}}while(0);f:do if((z|0)==61){z=0;G=k;H=f[G>>2]|0;x=f[G+4>>2]|0;G=Aj(H,x,q,ja&32)|0;T=(ha&8|0)==0|(H|0)==0&(x|0)==0;ka=H;la=x;ma=G;na=ha;oa=ia;pa=T?0:2;qa=T?13924:13924+(ja>>4)|0;z=67}else if((z|0)==66){z=0;ka=sa;la=ta;ma=bi(sa,ta,q)|0;na=O;oa=ca;pa=ua;qa=va;z=67}else if((z|0)==71){z=0;T=Ye(Ca,0,ca)|0;G=(T|0)==0;wa=Ca;xa=N;ya=G?ca:T-Ca|0;za=0;Aa=13924;Ba=G?Ca+ca|0:T}else if((z|0)==75){z=0;T=0;G=0;x=Da;while(1){H=f[x>>2]|0;if(!H){Ga=T;Ha=G;break}M=en(n,H)|0;if((M|0)<0|M>>>0>(Ea-T|0)>>>0){Ga=T;Ha=M;break}H=M+T|0;if(Ea>>>0>H>>>0){T=H;G=M;x=x+4|0}else{Ga=H;Ha=M;break}}if((Ha|0)<0){Y=-1;break a}Yi(a,32,aa,Ga,O);if(!Ga){Fa=0;z=84}else{x=0;G=Da;while(1){T=f[G>>2]|0;if(!T){Fa=Ga;z=84;break f}M=en(n,T)|0;x=M+x|0;if((x|0)>(Ga|0)){Fa=Ga;z=84;break f}qn(a,n,M);if(x>>>0>=Ga>>>0){Fa=Ga;z=84;break}else G=G+4|0}}}while(0);if((z|0)==67){z=0;N=(ka|0)!=0|(la|0)!=0;G=(oa|0)!=0|N;x=((N^1)&1)+(r-ma)|0;wa=G?ma:q;xa=(oa|0)>-1?na&-65537:na;ya=G?((oa|0)>(x|0)?oa:x):oa;za=pa;Aa=qa;Ba=q}else if((z|0)==84){z=0;Yi(a,32,aa,Fa,O^8192);t=ea;c=y;v=(aa|0)>(Fa|0)?aa:Fa;w=$;continue}x=Ba-wa|0;G=(ya|0)<(x|0)?x:ya;N=G+za|0;M=(aa|0)<(N|0)?N:aa;Yi(a,32,M,N,xa);qn(a,Aa,za);Yi(a,48,M,N,xa^65536);Yi(a,48,G,x,0);qn(a,wa,x);Yi(a,32,M,N,xa^8192);t=ea;c=y;v=M;w=$}g:do if((z|0)==87)if(!a)if(!w)Y=0;else{$=1;while(1){v=f[h+($<<2)>>2]|0;if(!v){Ia=$;break}Td(g+($<<3)|0,v,e);$=$+1|0;if(($|0)>=10){Y=1;break g}}while(1){if(f[h+(Ia<<2)>>2]|0){Y=-1;break g}Ia=Ia+1|0;if((Ia|0)>=10){Y=1;break}}}else Y=y;while(0);u=i;return Y|0}function yb(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0;c=u;u=u+32|0;d=c+20|0;e=c+16|0;g=c+4|0;i=c;j=a+36|0;k=a+37|0;l=a+32|0;m=f[l>>2]|0;do if((((h[j>>0]|0)<<8|(h[k>>0]|0))&65535)<514){n=m+8|0;o=f[n>>2]|0;p=f[n+4>>2]|0;n=m+16|0;q=n;r=f[q>>2]|0;s=f[q+4>>2]|0;q=Ul(r|0,s|0,4,0)|0;t=I;if((p|0)<(t|0)|(p|0)==(t|0)&o>>>0>>0){v=0;u=c;return v|0}w=(f[m>>2]|0)+r|0;x=h[w>>0]|h[w+1>>0]<<8|h[w+2>>0]<<16|h[w+3>>0]<<24;f[d>>2]=x;w=n;f[w>>2]=q;f[w+4>>2]=t;t=Ul(r|0,s|0,8,0)|0;s=I;if((p|0)<(s|0)|(p|0)==(s|0)&o>>>0>>0){v=0;u=c;return v|0}else{o=(f[m>>2]|0)+q|0;f[e>>2]=h[o>>0]|h[o+1>>0]<<8|h[o+2>>0]<<16|h[o+3>>0]<<24;o=n;f[o>>2]=t;f[o+4>>2]=s;y=x;break}}else{if(!(Ph(d,m)|0)){v=0;u=c;return v|0}if(Ph(e,f[l>>2]|0)|0){y=f[d>>2]|0;break}else{v=0;u=c;return v|0}}while(0);if(y>>>0>1431655765){v=0;u=c;return v|0}m=f[e>>2]|0;x=fl(y|0,0,3,0)|0;s=I;if(0>s>>>0|0==(s|0)&m>>>0>x>>>0){v=0;u=c;return v|0}x=f[l>>2]|0;s=x+8|0;o=f[s+4>>2]|0;t=x+16|0;n=t;q=f[n>>2]|0;p=f[n+4>>2]|0;if(!((o|0)>(p|0)|((o|0)==(p|0)?(f[s>>2]|0)>>>0>q>>>0:0))){v=0;u=c;return v|0}s=b[(f[x>>2]|0)+q>>0]|0;o=Ul(q|0,p|0,1,0)|0;n=I;r=t;f[r>>2]=o;f[r+4>>2]=n;a:do if(!(s<<24>>24)){if(!(te(a,y)|0)){v=0;u=c;return v|0}}else{if(m>>>0<256){if(!y)break;r=a+44|0;t=g+4|0;w=g+8|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;z=x+8|0;A=f[z>>2]|0;B=f[z+4>>2]|0;b:do if((B|0)>(n|0)|(B|0)==(n|0)&A>>>0>o>>>0){z=x;C=A;D=y;E=o;F=n;G=B;H=0;while(1){J=z+16|0;K=f[z>>2]|0;L=b[K+E>>0]|0;M=Ul(E|0,F|0,1,0)|0;N=I;O=J;f[O>>2]=M;f[O+4>>2]=N;f[g>>2]=L&255;if(!((G|0)>(N|0)|(G|0)==(N|0)&C>>>0>M>>>0))break b;N=b[K+M>>0]|0;M=Ul(E|0,F|0,2,0)|0;L=I;O=J;f[O>>2]=M;f[O+4>>2]=L;f[t>>2]=N&255;if(!((G|0)>(L|0)|(G|0)==(L|0)&C>>>0>M>>>0))break b;L=b[K+M>>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R+100|0;S=f[Q>>2]|0;if((S|0)==(f[R+104>>2]|0)){Lg(R+96|0,g);U=f[d>>2]|0}else{f[S>>2]=f[g>>2];f[S+4>>2]=f[g+4>>2];f[S+8>>2]=f[g+8>>2];f[Q>>2]=(f[Q>>2]|0)+12;U=L}J=J+1|0;if(J>>>0>=U>>>0)break a;C=f[l>>2]|0;Q=C+16|0;F=f[Q>>2]|0;H=f[Q+4>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;Q=C+8|0;M=f[Q>>2]|0;K=f[Q+4>>2]|0;G=Ul(F|0,H|0,2,0)|0;z=I;if((K|0)<(z|0)|(K|0)==(z|0)&M>>>0>>0)break;else L=U}}while(0);v=0;u=c;return v|0}r=a+44|0;if((f[(f[r>>2]|0)+80>>2]|0)>>>0<2097152?(((h[j>>0]|0)<<8|(h[k>>0]|0))&65535)>513:0){if(!y)break;t=g+4|0;w=g+8|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;d:do if(Ph(i,x)|0){A=0;do{f[g>>2]=f[i>>2];if(!(Ph(i,f[l>>2]|0)|0))break d;f[t>>2]=f[i>>2];if(!(Ph(i,f[l>>2]|0)|0))break d;f[w>>2]=f[i>>2];D=f[r>>2]|0;E=D+100|0;B=f[E>>2]|0;if((B|0)==(f[D+104>>2]|0))Lg(D+96|0,g);else{f[B>>2]=f[g>>2];f[B+4>>2]=f[g+4>>2];f[B+8>>2]=f[g+8>>2];f[E>>2]=(f[E>>2]|0)+12}A=A+1|0;if(A>>>0>=(f[d>>2]|0)>>>0)break a;E=f[l>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0}while(Ph(i,E)|0)}while(0);v=0;u=c;return v|0}if(y|0){w=g+4|0;t=g+8|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;A=x+8|0;E=f[A>>2]|0;B=f[A+4>>2]|0;A=Ul(q|0,p|0,5,0)|0;D=I;e:do if(!((B|0)<(D|0)|(B|0)==(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<<2)>>2]|0;I=G+1|0;J=((I>>>0)%3|0|0)==0?G+-2|0:I;if((J|0)==-1)K=-1;else K=f[F+(J<<2)>>2]|0;J=(((G>>>0)%3|0|0)==0?2:-1)+G|0;if((J|0)==-1)L=-1;else L=f[F+(J<<2)>>2]|0;if((H|0)!=(K|0)?!((H|0)==(L|0)|(K|0)==(L|0)):0){H=C;J=B;F=0;I=E;while(1){M=F+G|0;if(!(f[(f[e>>2]|0)+(M>>>5<<2)>>2]&1<<(M&31))){N=f[(f[a>>2]|0)+(M<<2)>>2]|0;f[g>>2]=N;if(!(f[H+(N>>>5<<2)>>2]&1<<(N&31))){O=N;P=0;Q=I}else{N=f[i>>2]|0;if((N|0)==(f[y>>2]|0))dh(h,3564);else{f[N>>2]=-1;f[i>>2]=N+4}N=f[v>>2]|0;if((N|0)==(f[w>>2]|0))dh(z,g);else{f[N>>2]=f[g>>2];f[v>>2]=N+4}N=f[l>>2]|0;R=f[j>>2]|0;if((N|0)==(R<<5|0)){if((N+1|0)<0){S=52;break a}T=R<<6;R=N+32&-32;Jg(d,N>>>0<1073741823?(T>>>0>>0?R:T):2147483647);U=f[l>>2]|0}else U=N;f[l>>2]=U+1;N=(f[d>>2]|0)+(U>>>5<<2)|0;f[N>>2]=f[N>>2]&~(1<<(U&31));f[g>>2]=I;O=I;P=1;Q=I+1|0}N=f[d>>2]|0;T=N+(O>>>5<<2)|0;f[T>>2]=f[T>>2]|1<<(O&31);T=N;b:do if(P){R=M;while(1){if((R|0)==-1){S=66;break b}V=(f[e>>2]|0)+(R>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(R&31);V=f[g>>2]|0;f[(f[h>>2]|0)+(V<<2)>>2]=R;f[(f[a>>2]|0)+(R<<2)>>2]=V;V=R+1|0;W=((V>>>0)%3|0|0)==0?R+-2|0:V;do if((W|0)==-1)X=-1;else{V=f[(f[x>>2]|0)+(W<<2)>>2]|0;Y=V+1|0;if((V|0)==-1){X=-1;break}X=((Y>>>0)%3|0|0)==0?V+-2|0:Y}while(0);if((X|0)==(M|0))break;else R=X}}else{R=M;while(1){if((R|0)==-1){S=66;break b}W=(f[e>>2]|0)+(R>>>5<<2)|0;f[W>>2]=f[W>>2]|1<<(R&31);f[(f[h>>2]|0)+(f[g>>2]<<2)>>2]=R;W=R+1|0;Y=((W>>>0)%3|0|0)==0?R+-2|0:W;do if((Y|0)==-1)Z=-1;else{W=f[(f[x>>2]|0)+(Y<<2)>>2]|0;V=W+1|0;if((W|0)==-1){Z=-1;break}Z=((V>>>0)%3|0|0)==0?W+-2|0:V}while(0);if((Z|0)==(M|0))break;else R=Z}}while(0);c:do if((S|0)==66){S=0;if((M|0)==-1)break;R=(((M>>>0)%3|0|0)==0?2:-1)+M|0;if((R|0)==-1)break;Y=f[(f[x>>2]|0)+(R<<2)>>2]|0;if((Y|0)==-1)break;R=Y+(((Y>>>0)%3|0|0)==0?2:-1)|0;if((R|0)==-1)break;if(!P){Y=R;while(1){V=(f[e>>2]|0)+(Y>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(Y&31);V=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((V|0)==-1)break c;W=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((W|0)==-1)break c;Y=W+(((W>>>0)%3|0|0)==0?2:-1)|0;if((Y|0)==-1)break c}}Y=f[a>>2]|0;W=R;do{V=(f[e>>2]|0)+(W>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(W&31);f[Y+(W<<2)>>2]=f[g>>2];V=(((W>>>0)%3|0|0)==0?2:-1)+W|0;if((V|0)==-1)break c;_=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((_|0)==-1)break c;W=_+(((_>>>0)%3|0|0)==0?2:-1)|0}while((W|0)!=-1)}while(0);$=T;aa=N;ba=Q}else{$=J;aa=H;ba=I}F=F+1|0;if((F|0)>=3){ca=$;da=aa;ea=ba;break}else{H=aa;J=$;I=ba}}}else{ca=B;da=C;ea=E}}else{ca=B;da=C;ea=E}D=D+1|0;A=f[a>>2]|0;if(D>>>0>=(((f[m>>2]|0)-A>>2>>>0)/3|0)>>>0){S=18;break}else{B=ca;C=da;E=ea}}if((S|0)==18){fa=ca;ga=f[l>>2]|0;break}else if((S|0)==52)Eo(d)}else{fa=q;ga=p}}else{fa=q;ga=p}while(0);p=a+44|0;f[p>>2]=0;a=fa;fa=ga>>>5;q=a+(fa<<2)|0;S=ga&31;ga=(fa|0)!=0;d:do if(fa|S|0){if(!S){l=a;ca=0;ea=ga;while(1){e:do if(ea){da=ca;m=0;while(1){if(!(f[l>>2]&1<>2]=ba;ha=ba}else ha=da;if((m|0)==31){ia=ha;break}else{da=ha;m=m+1|0}}}else{m=ca;da=0;while(1){if(!(f[l>>2]&1<>2]=N;ja=N}else ja=m;if((da|0)==31){ia=ja;break e}da=da+1|0;if(!da)break d;else m=ja}}while(0);l=l+4|0;if((l|0)==(q|0))break d;else{ca=ia;ea=1}}}if(ga){ea=a;ca=0;l=0;while(1){m=l;da=ca;N=0;while(1){if(!(f[ea>>2]&1<>2]=T;ka=T;la=T}else{ka=da;la=m}if((N|0)==31)break;else{m=la;da=ka;N=N+1|0}}N=ea+4|0;if((N|0)==(q|0)){ma=N;na=ka;break}else{ea=N;ca=ka;l=la}}}else{ma=a;na=0}l=na;ca=0;while(1){if(!(f[ma>>2]&1<>2]=ea;oa=ea}else oa=l;ca=ca+1|0;if((ca|0)==(S|0))break;else l=oa}}while(0);oa=f[e>>2]|0;if(oa|0)lp(oa);oa=f[d>>2]|0;if(!oa){u=c;return 1}lp(oa);u=c;return 1}function Ab(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=Ka,D=0,E=0.0,F=0,G=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Ul(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;q=m+r|0;while(1){r=b[q>>0]|0;m=g+(o<<3)|0;f[m>>2]=r;f[m+4>>2]=((r|0)<0)<<31>>31;o=o+1|0;r=b[k>>0]|0;if((o|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){s=r;break}else q=q+1|0}}else s=l;q=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 2:{q=a+24|0;o=b[q>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){k=f[f[a>>2]>>2]|0;r=a+40|0;m=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;t=Ul(m|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;m=k+t|0;while(1){t=g+(r<<3)|0;f[t>>2]=h[m>>0];f[t+4>>2]=0;r=r+1|0;t=b[q>>0]|0;if((r|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){u=t;break}else m=m+1|0}}else u=o;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 3:{m=a+24|0;r=b[m>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){q=f[f[a>>2]>>2]|0;l=a+40|0;t=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;k=Ul(t|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;t=q+k|0;while(1){k=d[t>>1]|0;q=g+(l<<3)|0;f[q>>2]=k;f[q+4>>2]=((k|0)<0)<<31>>31;l=l+1|0;k=b[m>>0]|0;if((l|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){v=k;break}else t=t+2|0}}else v=r;t=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}case 4:{t=a+24|0;l=b[t>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;k=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Ul(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;k=m+q|0;while(1){q=g+(o<<3)|0;f[q>>2]=j[k>>1];f[q+4>>2]=0;o=o+1|0;q=b[t>>0]|0;if((o|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else k=k+2|0}}else w=l;k=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(k<<3)|0,0,(e<<24>>24)-k<<3|0)|0;i=1;return i|0}case 5:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){t=f[f[a>>2]>>2]|0;r=a+40|0;q=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;m=Ul(q|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;q=t+m|0;while(1){m=f[q>>2]|0;t=g+(r<<3)|0;f[t>>2]=m;f[t+4>>2]=((m|0)<0)<<31>>31;r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){x=m;break}else q=q+4|0}}else x=o;q=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 6:{q=a+24|0;r=b[q>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;t=Ul(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;m=k+t|0;while(1){t=g+(l<<3)|0;f[t>>2]=f[m>>2];f[t+4>>2]=0;l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){y=t;break}else m=m+4|0}}else y=r;m=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 7:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;k=Ul(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;t=q+k|0;while(1){k=t;q=f[k+4>>2]|0;z=g+(o<<3)|0;f[z>>2]=f[k>>2];f[z+4>>2]=q;o=o+1|0;q=b[m>>0]|0;if((o|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else t=t+8|0}}else A=l;t=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}case 8:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;q=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;z=Ul(q|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;q=m+z|0;while(1){z=q;m=f[z+4>>2]|0;k=g+(r<<3)|0;f[k>>2]=f[z>>2];f[k+4>>2]=m;r=r+1|0;m=b[t>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){B=m;break}else q=q+8|0}}else B=o;q=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 9:{q=a+24|0;r=b[q>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){t=f[f[a>>2]>>2]|0;l=a+40|0;m=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;k=Ul(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;m=t+k|0;while(1){C=$(n[m>>2]);k=+K(+C)>=1.0?(+C>0.0?~~+Y(+J(+C/4294967296.0),4294967295.0)>>>0:~~+W((+C-+(~~+C>>>0))/4294967296.0)>>>0):0;t=g+(l<<3)|0;f[t>>2]=~~+C>>>0;f[t+4>>2]=k;l=l+1|0;k=b[q>>0]|0;if((l|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else m=m+4|0}}else D=r;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 10:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;k=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;t=Ul(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;k=q+t|0;while(1){E=+p[k>>3];t=+K(E)>=1.0?(E>0.0?~~+Y(+J(E/4294967296.0),4294967295.0)>>>0:~~+W((E-+(~~E>>>0))/4294967296.0)>>>0):0;q=g+(o<<3)|0;f[q>>2]=~~E>>>0;f[q+4>>2]=t;o=o+1|0;t=b[m>>0]|0;if((o|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){F=t;break}else k=k+8|0}}else F=l;k=F<<24>>24;if(F<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(k<<3)|0,0,(e<<24>>24)-k<<3|0)|0;i=1;return i|0}case 11:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;t=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;q=Ul(t|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;t=m+q|0;while(1){q=g+(r<<3)|0;f[q>>2]=h[t>>0];f[q+4>>2]=0;r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){G=q;break}else t=t+1|0}}else G=o;t=G<<24>>24;if(G<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Bb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;c=u;u=u+16|0;d=c+8|0;e=c;if((f[a+96>>2]|0)==(f[a+92>>2]|0)){u=c;return 1}g=a+56|0;h=f[g>>2]|0;if((h|0)==(f[a+60>>2]|0)){dh(a+52|0,b);i=b}else{f[h>>2]=f[b>>2];f[g>>2]=h+4;i=b}b=a+88|0;f[b>>2]=0;h=f[a>>2]|0;g=f[i>>2]|0;j=g+1|0;if((g|0)!=-1){k=((j>>>0)%3|0|0)==0?g+-2|0:j;if((k|0)==-1)l=-1;else l=f[(f[h>>2]|0)+(k<<2)>>2]|0;k=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((k|0)==-1){m=-1;n=l}else{m=f[(f[h>>2]|0)+(k<<2)>>2]|0;n=l}}else{m=-1;n=-1}l=a+24|0;k=f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[i>>2]|0;if((r|0)==-1)t=-1;else t=f[(f[f[a>>2]>>2]|0)+(r<<2)>>2]|0;r=(f[l>>2]|0)+(t>>>5<<2)|0;m=1<<(t&31);s=f[r>>2]|0;if(!(m&s)){f[r>>2]=s|m;m=f[i>>2]|0;f[e>>2]=m;s=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((m>>>0)/3|0)*12|0)+(((m>>>0)%3|0)<<2)>>2]|0;m=f[a+48>>2]|0;f[d>>2]=s;r=f[m+4>>2]|0;m=r+4|0;o=f[m>>2]|0;if((o|0)==(f[r+8>>2]|0))dh(r,d);else{f[o>>2]=s;f[m>>2]=o+4}o=a+40|0;m=f[o>>2]|0;s=m+4|0;r=f[s>>2]|0;if((r|0)==(f[m+8>>2]|0)){dh(m,e);v=f[o>>2]|0}else{f[r>>2]=f[e>>2];f[s>>2]=r+4;v=m}m=v+24|0;f[(f[v+12>>2]|0)+(t<<2)>>2]=f[m>>2];f[m>>2]=(f[m>>2]|0)+1}m=f[b>>2]|0;a:do if((m|0)<3){t=a+12|0;v=a+44|0;r=a+48|0;s=a+40|0;o=a+92|0;q=m;while(1){k=q;while(1){w=a+52+(k*12|0)+4|0;x=f[w>>2]|0;if((f[a+52+(k*12|0)>>2]|0)!=(x|0))break;n=k+1|0;if((n|0)<3)k=n;else break a}n=x+-4|0;p=f[n>>2]|0;f[w>>2]=n;f[b>>2]=k;f[i>>2]=p;if((p|0)==-1)break;n=(p>>>0)/3|0;g=f[t>>2]|0;do if(!(f[g+(n>>>5<<2)>>2]&1<<(n&31))){j=p;h=g;b:while(1){y=(j>>>0)/3|0;z=h+(y>>>5<<2)|0;f[z>>2]=1<<(y&31)|f[z>>2];z=f[i>>2]|0;if((z|0)==-1)A=-1;else A=f[(f[f[a>>2]>>2]|0)+(z<<2)>>2]|0;y=(f[l>>2]|0)+(A>>>5<<2)|0;B=1<<(A&31);C=f[y>>2]|0;if(!(B&C)){f[y>>2]=C|B;B=f[i>>2]|0;f[e>>2]=B;C=f[(f[(f[v>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=C;y=f[B+4>>2]|0;B=y+4|0;D=f[B>>2]|0;if((D|0)==(f[y+8>>2]|0))dh(y,d);else{f[D>>2]=C;f[B>>2]=D+4}D=f[s>>2]|0;B=D+4|0;C=f[B>>2]|0;if((C|0)==(f[D+8>>2]|0)){dh(D,e);E=f[s>>2]|0}else{f[C>>2]=f[e>>2];f[B>>2]=C+4;E=D}D=E+24|0;f[(f[E+12>>2]|0)+(A<<2)>>2]=f[D>>2];f[D>>2]=(f[D>>2]|0)+1;F=f[i>>2]|0}else F=z;z=f[a>>2]|0;if((F|0)==-1){G=93;break}D=F+1|0;C=((D>>>0)%3|0|0)==0?F+-2|0:D;if((C|0)==-1)H=-1;else H=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((C|0)==-1)I=-1;else I=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(H|0)==-1;D=C?-1:(H>>>0)/3|0;B=(I|0)==-1;y=B?-1:(I>>>0)/3|0;if(C)J=1;else J=(f[(f[t>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)|0)!=0;do if(B)if(J){G=93;break b}else G=82;else{if(f[(f[t>>2]|0)+(y>>>5<<2)>>2]&1<<(y&31)|0)if(J){G=93;break b}else{G=82;break}D=f[(f[z>>2]|0)+(I<<2)>>2]|0;if(!(1<<(D&31)&f[(f[l>>2]|0)+(D>>>5<<2)>>2])){K=(f[o>>2]|0)+(D<<2)|0;D=f[K>>2]|0;f[K>>2]=D+1;L=(D|0)>0?1:2}else L=0;if(J?(L|0)<=(f[b>>2]|0):0){M=I;break}f[d>>2]=I;D=a+52+(L*12|0)+4|0;K=f[D>>2]|0;if((K|0)==(f[a+52+(L*12|0)+8>>2]|0))dh(a+52+(L*12|0)|0,d);else{f[K>>2]=I;f[D>>2]=K+4}if((f[b>>2]|0)>(L|0))f[b>>2]=L;if(J){G=93;break b}else G=82}while(0);if((G|0)==82){G=0;if(C)N=-1;else N=f[(f[f[a>>2]>>2]|0)+(H<<2)>>2]|0;if(!(1<<(N&31)&f[(f[l>>2]|0)+(N>>>5<<2)>>2])){z=(f[o>>2]|0)+(N<<2)|0;y=f[z>>2]|0;f[z>>2]=y+1;O=(y|0)>0?1:2}else O=0;if((O|0)>(f[b>>2]|0))break;else M=H}f[i>>2]=M;j=M;h=f[t>>2]|0}if((G|0)==93){G=0;P=f[b>>2]|0;break}f[d>>2]=H;h=a+52+(O*12|0)+4|0;j=f[h>>2]|0;if((j|0)==(f[a+52+(O*12|0)+8>>2]|0))dh(a+52+(O*12|0)|0,d);else{f[j>>2]=H;f[h>>2]=j+4}j=f[b>>2]|0;if((j|0)>(O|0)){f[b>>2]=O;Q=O}else Q=j;P=Q}else P=k;while(0);if((P|0)<3)q=P;else break a}u=c;return 1}while(0);f[i>>2]=-1;u=c;return 1}function Cb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{j=a+24|0;k=b[j>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;m=a+40|0;o=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;q=Ul(o|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;o=l+q|0;while(1){d[g+(m<<1)>>1]=b[o>>0]|0;m=m+1|0;q=b[j>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){r=q;break}else o=o+1|0}}else r=k;o=r<<24>>24;if(r<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 2:{o=a+24|0;m=b[o>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){j=f[f[a>>2]>>2]|0;q=a+40|0;l=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;s=Ul(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;l=j+s|0;while(1){d[g+(q<<1)>>1]=h[l>>0]|0;q=q+1|0;s=b[o>>0]|0;if((q|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){t=s;break}else l=l+1|0}}else t=m;l=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 3:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){o=f[f[a>>2]>>2]|0;k=a+40|0;s=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;j=Ul(s|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;s=o+j|0;while(1){d[g+(k<<1)>>1]=d[s>>1]|0;k=k+1|0;j=b[l>>0]|0;if((k|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){u=j;break}else s=s+2|0}}else u=q;s=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}case 4:{s=a+24|0;k=b[s>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;m=a+40|0;j=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;o=Ul(j|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;j=l+o|0;while(1){d[g+(m<<1)>>1]=d[j>>1]|0;m=m+1|0;o=b[s>>0]|0;if((m|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else j=j+2|0}}else v=k;j=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(j<<1)|0,0,(e<<24>>24)-j<<1|0)|0;i=1;return i|0}case 5:{j=a+24|0;m=b[j>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){s=f[f[a>>2]>>2]|0;q=a+40|0;o=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;l=Ul(o|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;o=s+l|0;while(1){d[g+(q<<1)>>1]=f[o>>2];q=q+1|0;l=b[j>>0]|0;if((q|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){w=l;break}else o=o+4|0}}else w=m;o=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 6:{o=a+24|0;q=b[o>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){j=f[f[a>>2]>>2]|0;k=a+40|0;l=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;s=Ul(l|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;l=j+s|0;while(1){d[g+(k<<1)>>1]=f[l>>2];k=k+1|0;s=b[o>>0]|0;if((k|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){x=s;break}else l=l+4|0}}else x=q;l=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 7:{l=a+24|0;k=b[l>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){o=f[f[a>>2]>>2]|0;m=a+40|0;s=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;j=Ul(s|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;s=o+j|0;while(1){d[g+(m<<1)>>1]=f[s>>2];m=m+1|0;j=b[l>>0]|0;if((m|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){y=j;break}else s=s+8|0}}else y=k;s=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}case 8:{s=a+24|0;m=b[s>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){l=f[f[a>>2]>>2]|0;q=a+40|0;j=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;o=Ul(j|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;j=l+o|0;while(1){d[g+(q<<1)>>1]=f[j>>2];q=q+1|0;o=b[s>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){z=o;break}else j=j+8|0}}else z=m;j=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(j<<1)|0,0,(e<<24>>24)-j<<1|0)|0;i=1;return i|0}case 9:{j=a+24|0;q=b[j>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){s=f[f[a>>2]>>2]|0;k=a+40|0;o=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Ul(o|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;o=s+l|0;while(1){l=~~$(n[o>>2])&65535;d[g+(k<<1)>>1]=l;k=k+1|0;l=b[j>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){A=l;break}else o=o+4|0}}else A=q;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 10:{o=a+24|0;k=b[o>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){j=f[f[a>>2]>>2]|0;m=a+40|0;l=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;s=Ul(l|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;l=j+s|0;while(1){d[g+(m<<1)>>1]=~~+p[l>>3];m=m+1|0;s=b[o>>0]|0;if((m|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){B=s;break}else l=l+8|0}}else B=k;l=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 11:{l=a+24|0;m=b[l>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){o=f[f[a>>2]>>2]|0;q=a+40|0;s=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;j=Ul(s|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;s=o+j|0;while(1){d[g+(q<<1)>>1]=h[s>>0]|0;q=q+1|0;j=b[l>>0]|0;if((q|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){C=j;break}else s=s+1|0}}else C=m;s=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Db(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{j=a+24|0;k=b[j>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;m=a+40|0;o=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;q=Ul(o|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;o=l+q|0;while(1){d[g+(m<<1)>>1]=b[o>>0]|0;m=m+1|0;q=b[j>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){r=q;break}else o=o+1|0}}else r=k;o=r<<24>>24;if(r<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 2:{o=a+24|0;m=b[o>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){j=f[f[a>>2]>>2]|0;q=a+40|0;l=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;s=Ul(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;l=j+s|0;while(1){d[g+(q<<1)>>1]=h[l>>0]|0;q=q+1|0;s=b[o>>0]|0;if((q|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){t=s;break}else l=l+1|0}}else t=m;l=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 3:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){o=f[f[a>>2]>>2]|0;k=a+40|0;s=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;j=Ul(s|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;s=o+j|0;while(1){d[g+(k<<1)>>1]=d[s>>1]|0;k=k+1|0;j=b[l>>0]|0;if((k|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){u=j;break}else s=s+2|0}}else u=q;s=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}case 4:{s=a+24|0;k=b[s>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;m=a+40|0;j=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;o=Ul(j|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;j=l+o|0;while(1){d[g+(m<<1)>>1]=d[j>>1]|0;m=m+1|0;o=b[s>>0]|0;if((m|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else j=j+2|0}}else v=k;j=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(j<<1)|0,0,(e<<24>>24)-j<<1|0)|0;i=1;return i|0}case 5:{j=a+24|0;m=b[j>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){s=f[f[a>>2]>>2]|0;q=a+40|0;o=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;l=Ul(o|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;o=s+l|0;while(1){d[g+(q<<1)>>1]=f[o>>2];q=q+1|0;l=b[j>>0]|0;if((q|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){w=l;break}else o=o+4|0}}else w=m;o=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 6:{o=a+24|0;q=b[o>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){j=f[f[a>>2]>>2]|0;k=a+40|0;l=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;s=Ul(l|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;l=j+s|0;while(1){d[g+(k<<1)>>1]=f[l>>2];k=k+1|0;s=b[o>>0]|0;if((k|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){x=s;break}else l=l+4|0}}else x=q;l=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 7:{l=a+24|0;k=b[l>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){o=f[f[a>>2]>>2]|0;m=a+40|0;s=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;j=Ul(s|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;s=o+j|0;while(1){d[g+(m<<1)>>1]=f[s>>2];m=m+1|0;j=b[l>>0]|0;if((m|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){y=j;break}else s=s+8|0}}else y=k;s=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}case 8:{s=a+24|0;m=b[s>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){l=f[f[a>>2]>>2]|0;q=a+40|0;j=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;o=Ul(j|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;j=l+o|0;while(1){d[g+(q<<1)>>1]=f[j>>2];q=q+1|0;o=b[s>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){z=o;break}else j=j+8|0}}else z=m;j=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(j<<1)|0,0,(e<<24>>24)-j<<1|0)|0;i=1;return i|0}case 9:{j=a+24|0;q=b[j>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){s=f[f[a>>2]>>2]|0;k=a+40|0;o=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Ul(o|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;o=s+l|0;while(1){l=~~$(n[o>>2]);d[g+(k<<1)>>1]=l;k=k+1|0;l=b[j>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){A=l;break}else o=o+4|0}}else A=q;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 10:{o=a+24|0;k=b[o>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){j=f[f[a>>2]>>2]|0;m=a+40|0;l=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;s=Ul(l|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;l=j+s|0;while(1){d[g+(m<<1)>>1]=~~+p[l>>3];m=m+1|0;s=b[o>>0]|0;if((m|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){B=s;break}else l=l+8|0}}else B=k;l=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 11:{l=a+24|0;m=b[l>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){o=f[f[a>>2]>>2]|0;q=a+40|0;s=fl(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;j=Ul(s|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=0;s=o+j|0;while(1){d[g+(q<<1)>>1]=h[s>>0]|0;q=q+1|0;j=b[l>>0]|0;if((q|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){C=j;break}else s=s+1|0}}else C=m;s=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Eb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Ul(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;q=m+r|0;while(1){f[g+(o<<2)>>2]=b[q>>0];o=o+1|0;r=b[k>>0]|0;if((o|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){s=r;break}else q=q+1|0}}else s=l;q=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 2:{q=a+24|0;o=b[q>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){k=f[f[a>>2]>>2]|0;r=a+40|0;m=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;t=Ul(m|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;m=k+t|0;while(1){f[g+(r<<2)>>2]=h[m>>0];r=r+1|0;t=b[q>>0]|0;if((r|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){u=t;break}else m=m+1|0}}else u=o;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;r=b[m>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){q=f[f[a>>2]>>2]|0;l=a+40|0;t=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;k=Ul(t|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;t=q+k|0;while(1){f[g+(l<<2)>>2]=d[t>>1];l=l+1|0;k=b[m>>0]|0;if((l|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){v=k;break}else t=t+2|0}}else v=r;t=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 4:{t=a+24|0;l=b[t>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;k=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Ul(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;k=m+q|0;while(1){f[g+(o<<2)>>2]=j[k>>1];o=o+1|0;q=b[t>>0]|0;if((o|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else k=k+2|0}}else w=l;k=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 5:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){t=f[f[a>>2]>>2]|0;r=a+40|0;q=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;m=Ul(q|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;q=t+m|0;while(1){f[g+(r<<2)>>2]=f[q>>2];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){x=m;break}else q=q+4|0}}else x=o;q=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 6:{q=a+24|0;r=b[q>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;t=Ul(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;m=k+t|0;while(1){f[g+(l<<2)>>2]=f[m>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){y=t;break}else m=m+4|0}}else y=r;m=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 7:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;k=Ul(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;t=q+k|0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;k=b[m>>0]|0;if((o|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){z=k;break}else t=t+8|0}}else z=l;t=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 8:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;k=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;q=Ul(k|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;k=m+q|0;while(1){f[g+(r<<2)>>2]=f[k>>2];r=r+1|0;q=b[t>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else k=k+8|0}}else A=o;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 9:{k=a+24|0;r=b[k>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){t=f[f[a>>2]>>2]|0;l=a+40|0;q=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;m=Ul(q|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;q=t+m|0;while(1){m=~~$(n[q>>2])>>>0;f[g+(l<<2)>>2]=m;l=l+1|0;m=b[k>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){B=m;break}else q=q+4|0}}else B=r;q=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 10:{q=a+24|0;l=b[q>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;m=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;t=Ul(m|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;m=k+t|0;while(1){f[g+(o<<2)>>2]=~~+p[m>>3]>>>0;o=o+1|0;t=b[q>>0]|0;if((o|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){C=t;break}else m=m+8|0}}else C=l;m=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 11:{m=a+24|0;o=b[m>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){q=f[f[a>>2]>>2]|0;r=a+40|0;t=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Ul(t|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;t=q+k|0;while(1){f[g+(r<<2)>>2]=h[t>>0];r=r+1|0;k=b[m>>0]|0;if((r|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else t=t+1|0}}else D=o;t=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Fb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Ul(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;q=m+r|0;while(1){f[g+(o<<2)>>2]=b[q>>0];o=o+1|0;r=b[k>>0]|0;if((o|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){s=r;break}else q=q+1|0}}else s=l;q=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 2:{q=a+24|0;o=b[q>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){k=f[f[a>>2]>>2]|0;r=a+40|0;m=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;t=Ul(m|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;m=k+t|0;while(1){f[g+(r<<2)>>2]=h[m>>0];r=r+1|0;t=b[q>>0]|0;if((r|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){u=t;break}else m=m+1|0}}else u=o;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;r=b[m>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){q=f[f[a>>2]>>2]|0;l=a+40|0;t=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;k=Ul(t|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;t=q+k|0;while(1){f[g+(l<<2)>>2]=d[t>>1];l=l+1|0;k=b[m>>0]|0;if((l|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){v=k;break}else t=t+2|0}}else v=r;t=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 4:{t=a+24|0;l=b[t>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;k=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Ul(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;k=m+q|0;while(1){f[g+(o<<2)>>2]=j[k>>1];o=o+1|0;q=b[t>>0]|0;if((o|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else k=k+2|0}}else w=l;k=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 5:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){t=f[f[a>>2]>>2]|0;r=a+40|0;q=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;m=Ul(q|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;q=t+m|0;while(1){f[g+(r<<2)>>2]=f[q>>2];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){x=m;break}else q=q+4|0}}else x=o;q=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 6:{q=a+24|0;r=b[q>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;t=Ul(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;m=k+t|0;while(1){f[g+(l<<2)>>2]=f[m>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){y=t;break}else m=m+4|0}}else y=r;m=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 7:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;k=Ul(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;t=q+k|0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;k=b[m>>0]|0;if((o|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){z=k;break}else t=t+8|0}}else z=l;t=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 8:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;k=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;q=Ul(k|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;k=m+q|0;while(1){f[g+(r<<2)>>2]=f[k>>2];r=r+1|0;q=b[t>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else k=k+8|0}}else A=o;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 9:{k=a+24|0;r=b[k>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){t=f[f[a>>2]>>2]|0;l=a+40|0;q=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;m=Ul(q|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;q=t+m|0;while(1){m=~~$(n[q>>2]);f[g+(l<<2)>>2]=m;l=l+1|0;m=b[k>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){B=m;break}else q=q+4|0}}else B=r;q=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 10:{q=a+24|0;l=b[q>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;m=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;t=Ul(m|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;m=k+t|0;while(1){f[g+(o<<2)>>2]=~~+p[m>>3];o=o+1|0;t=b[q>>0]|0;if((o|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){C=t;break}else m=m+8|0}}else C=l;m=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 11:{m=a+24|0;o=b[m>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){q=f[f[a>>2]>>2]|0;r=a+40|0;t=fl(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Ul(t|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=0;t=q+k|0;while(1){f[g+(r<<2)>>2]=h[t>>0];r=r+1|0;k=b[m>>0]|0;if((r|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else t=t+1|0}}else D=o;t=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Gb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){h=1;u=c;return h|0}i=(g>>>0)/3|0;j=a+12|0;if(f[(f[j>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0){h=1;u=c;return h|0}i=a+56|0;k=f[i>>2]|0;l=a+60|0;m=f[l>>2]|0;if((m|0)==(k|0))n=k;else{o=m+(~((m+-4-k|0)>>>2)<<2)|0;f[l>>2]=o;n=o}o=a+64|0;if((n|0)==(f[o>>2]|0))dh(i,b);else{f[n>>2]=g;f[l>>2]=n+4}n=f[a>>2]|0;g=f[b>>2]|0;k=g+1|0;do if((g|0)!=-1){m=f[n+28>>2]|0;p=f[m+((((k>>>0)%3|0|0)==0?g+-2|0:k)<<2)>>2]|0;if(!((g>>>0)%3|0)){q=m;r=p;s=g+2|0;break}else{q=m;r=p;s=g+-1|0;break}}else{p=f[n+28>>2]|0;q=p;r=f[p+-4>>2]|0;s=-1}while(0);n=f[q+(s<<2)>>2]|0;if((r|0)==-1|(n|0)==-1){h=0;u=c;return h|0}s=a+24|0;q=f[s>>2]|0;g=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f[l>>2]|0;if((x|0)==(n|0)){h=1;u=c;return h|0}y=a+44|0;t=a+48|0;w=a+40|0;q=x;x=n;a:while(1){n=f[x+-4>>2]|0;f[b>>2]=n;r=(n>>>0)/3|0;if((n|0)!=-1?(n=(f[j>>2]|0)+(r>>>5<<2)|0,v=1<<(r&31),r=f[n>>2]|0,(r&v|0)==0):0){f[n>>2]=r|v;v=f[a>>2]|0;r=f[b>>2]|0;n=f[(f[v+28>>2]|0)+(r<<2)>>2]|0;if((n|0)==-1){h=0;z=79;break}else{A=r;B=v;C=n}b:while(1){n=(f[s>>2]|0)+(C>>>5<<2)|0;v=1<<(C&31);r=f[n>>2]|0;do if(!(r&v)){k=f[(f[B+40>>2]|0)+(C<<2)>>2]|0;if((k|0)==-1)D=1;else{p=f[(f[f[B+64>>2]>>2]|0)+(k<<2)>>2]|0;D=(1<<(p&31)&f[(f[B+12>>2]|0)+(p>>>5<<2)>>2]|0)!=0}f[n>>2]=r|v;p=f[b>>2]|0;f[e>>2]=p;k=f[(f[(f[y>>2]|0)+96>>2]|0)+(((p>>>0)/3|0)*12|0)+(((p>>>0)%3|0)<<2)>>2]|0;p=f[t>>2]|0;f[d>>2]=k;g=f[p+4>>2]|0;p=g+4|0;m=f[p>>2]|0;if((m|0)==(f[g+8>>2]|0))dh(g,d);else{f[m>>2]=k;f[p>>2]=m+4}m=f[w>>2]|0;p=m+4|0;k=f[p>>2]|0;if((k|0)==(f[m+8>>2]|0)){dh(m,e);E=f[w>>2]|0}else{f[k>>2]=f[e>>2];f[p>>2]=k+4;E=m}m=E+24|0;f[(f[E+12>>2]|0)+(C<<2)>>2]=f[m>>2];f[m>>2]=(f[m>>2]|0)+1;m=f[a>>2]|0;k=f[b>>2]|0;if(D){F=k;G=m;z=59;break}p=k+1|0;do if((k|0)==-1)H=-1;else{g=((p>>>0)%3|0|0)==0?k+-2|0:p;if((g|0)==-1){H=-1;break}if(f[(f[m>>2]|0)+(g>>>5<<2)>>2]&1<<(g&31)|0){H=-1;break}H=f[(f[(f[m+64>>2]|0)+12>>2]|0)+(g<<2)>>2]|0}while(0);f[b>>2]=H;I=m;J=(H>>>0)/3|0}else{F=A;G=B;z=59}while(0);if((z|0)==59){z=0;v=F+1|0;if((F|0)==-1){z=63;break}r=((v>>>0)%3|0|0)==0?F+-2|0:v;do if((r|0)==-1)K=-1;else{if(f[(f[G>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)|0){K=-1;break}K=f[(f[(f[G+64>>2]|0)+12>>2]|0)+(r<<2)>>2]|0}while(0);f[d>>2]=K;r=(((F>>>0)%3|0|0)==0?2:-1)+F|0;do if((r|0)==-1)L=-1;else{if(f[(f[G>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)|0){L=-1;break}L=f[(f[(f[G+64>>2]|0)+12>>2]|0)+(r<<2)>>2]|0}while(0);r=(K|0)==-1;v=(K>>>0)/3|0;n=r?-1:v;p=(L|0)==-1;k=(L>>>0)/3|0;g=p?-1:k;do if(!r){M=f[j>>2]|0;if(f[M+(n>>>5<<2)>>2]&1<<(n&31)|0){z=69;break}if(p){N=K;O=v;break}if(!(f[M+(g>>>5<<2)>>2]&1<<(g&31))){z=74;break b}else{N=K;O=v}}else z=69;while(0);if((z|0)==69){z=0;if(p){z=71;break}if(!(f[(f[j>>2]|0)+(g>>>5<<2)>>2]&1<<(g&31))){N=L;O=k}else{z=71;break}}f[b>>2]=N;I=G;J=O}v=(f[j>>2]|0)+(J>>>5<<2)|0;f[v>>2]=f[v>>2]|1<<(J&31);A=f[b>>2]|0;C=f[(f[I+28>>2]|0)+(A<<2)>>2]|0;if((C|0)==-1){h=0;z=79;break a}else B=I}do if((z|0)==63){z=0;f[d>>2]=-1;z=71}else if((z|0)==74){z=0;v=f[l>>2]|0;f[v+-4>>2]=L;if((v|0)==(f[o>>2]|0)){dh(i,d);P=f[l>>2]|0;break}else{f[v>>2]=f[d>>2];n=v+4|0;f[l>>2]=n;P=n;break}}while(0);if((z|0)==71){z=0;n=(f[l>>2]|0)+-4|0;f[l>>2]=n;P=n}Q=f[i>>2]|0;R=P}else{n=x+-4|0;f[l>>2]=n;Q=q;R=n}if((Q|0)==(R|0)){h=1;z=79;break}else{q=Q;x=R}}if((z|0)==79){u=c;return h|0}return 0}function Hb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;if(!g){h=0;return h|0}do switch(f[a+28>>2]|0){case 1:{i=a+24|0;j=b[i>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;o=Ul(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;m=k+o|0;while(1){b[g+l>>0]=b[m>>0]|0;l=l+1|0;o=b[i>>0]|0;if((l|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){q=o;break}else m=m+1|0}}else q=j;m=q<<24>>24;if(q<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 2:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){i=f[f[a>>2]>>2]|0;o=a+40|0;k=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Ul(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;k=i+r|0;while(1){b[g+o>>0]=b[k>>0]|0;o=o+1|0;r=b[m>>0]|0;if((o|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){s=r;break}else k=k+1|0}}else s=l;k=s<<24>>24;if(s<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 3:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){m=f[f[a>>2]>>2]|0;j=a+40|0;r=fl(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;i=Ul(r|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=0;r=m+i|0;while(1){b[g+j>>0]=d[r>>1];j=j+1|0;i=b[k>>0]|0;if((j|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){t=i;break}else r=r+2|0}}else t=o;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}case 4:{r=a+24|0;j=b[r>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;i=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;m=Ul(i|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;i=k+m|0;while(1){b[g+l>>0]=d[i>>1];l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){u=m;break}else i=i+2|0}}else u=j;i=u<<24>>24;if(u<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+i|0,0,(e<<24>>24)-i|0)|0;h=1;return h|0}case 5:{i=a+24|0;l=b[i>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;m=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;k=Ul(m|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;m=r+k|0;while(1){b[g+o>>0]=f[m>>2];o=o+1|0;k=b[i>>0]|0;if((o|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){v=k;break}else m=m+4|0}}else v=l;m=v<<24>>24;if(v<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 6:{m=a+24|0;o=b[m>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){i=f[f[a>>2]>>2]|0;j=a+40|0;k=fl(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;r=Ul(k|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=0;k=i+r|0;while(1){b[g+j>>0]=f[k>>2];j=j+1|0;r=b[m>>0]|0;if((j|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){w=r;break}else k=k+4|0}}else w=o;k=w<<24>>24;if(w<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 7:{k=a+24|0;j=b[k>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){m=f[f[a>>2]>>2]|0;l=a+40|0;r=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;i=Ul(r|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;r=m+i|0;while(1){b[g+l>>0]=f[r>>2];l=l+1|0;i=b[k>>0]|0;if((l|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){x=i;break}else r=r+8|0}}else x=j;r=x<<24>>24;if(x<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}case 8:{r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;i=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;m=Ul(i|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;i=k+m|0;while(1){b[g+o>>0]=f[i>>2];o=o+1|0;m=b[r>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){y=m;break}else i=i+8|0}}else y=l;i=y<<24>>24;if(y<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+i|0,0,(e<<24>>24)-i|0)|0;h=1;return h|0}case 9:{i=a+24|0;o=b[i>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;j=a+40|0;m=fl(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;k=Ul(m|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=0;m=r+k|0;while(1){k=~~$(n[m>>2])&255;b[g+j>>0]=k;j=j+1|0;k=b[i>>0]|0;if((j|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){z=k;break}else m=m+4|0}}else z=o;m=z<<24>>24;if(z<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 10:{m=a+24|0;j=b[m>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){i=f[f[a>>2]>>2]|0;l=a+40|0;k=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;r=Ul(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;k=i+r|0;while(1){b[g+l>>0]=~~+p[k>>3];l=l+1|0;r=b[m>>0]|0;if((l|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){A=r;break}else k=k+8|0}}else A=j;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 11:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;r=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;i=Ul(r|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;r=m+i|0;while(1){b[g+o>>0]=b[r>>0]|0;o=o+1|0;i=b[k>>0]|0;if((o|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){B=i;break}else r=r+1|0}}else B=l;r=B<<24>>24;if(B<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}default:{h=0;return h|0}}while(0);return 0}function Ib(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;if(!g){h=0;return h|0}do switch(f[a+28>>2]|0){case 1:{i=a+24|0;j=b[i>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;o=Ul(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;m=k+o|0;while(1){b[g+l>>0]=b[m>>0]|0;l=l+1|0;o=b[i>>0]|0;if((l|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){q=o;break}else m=m+1|0}}else q=j;m=q<<24>>24;if(q<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 2:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){i=f[f[a>>2]>>2]|0;o=a+40|0;k=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Ul(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;k=i+r|0;while(1){b[g+o>>0]=b[k>>0]|0;o=o+1|0;r=b[m>>0]|0;if((o|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){s=r;break}else k=k+1|0}}else s=l;k=s<<24>>24;if(s<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 3:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){m=f[f[a>>2]>>2]|0;j=a+40|0;r=fl(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;i=Ul(r|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=0;r=m+i|0;while(1){b[g+j>>0]=d[r>>1];j=j+1|0;i=b[k>>0]|0;if((j|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){t=i;break}else r=r+2|0}}else t=o;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}case 4:{r=a+24|0;j=b[r>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;i=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;m=Ul(i|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;i=k+m|0;while(1){b[g+l>>0]=d[i>>1];l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){u=m;break}else i=i+2|0}}else u=j;i=u<<24>>24;if(u<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+i|0,0,(e<<24>>24)-i|0)|0;h=1;return h|0}case 5:{i=a+24|0;l=b[i>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;m=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;k=Ul(m|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;m=r+k|0;while(1){b[g+o>>0]=f[m>>2];o=o+1|0;k=b[i>>0]|0;if((o|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){v=k;break}else m=m+4|0}}else v=l;m=v<<24>>24;if(v<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 6:{m=a+24|0;o=b[m>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){i=f[f[a>>2]>>2]|0;j=a+40|0;k=fl(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;r=Ul(k|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=0;k=i+r|0;while(1){b[g+j>>0]=f[k>>2];j=j+1|0;r=b[m>>0]|0;if((j|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){w=r;break}else k=k+4|0}}else w=o;k=w<<24>>24;if(w<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 7:{k=a+24|0;j=b[k>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){m=f[f[a>>2]>>2]|0;l=a+40|0;r=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;i=Ul(r|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;r=m+i|0;while(1){b[g+l>>0]=f[r>>2];l=l+1|0;i=b[k>>0]|0;if((l|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){x=i;break}else r=r+8|0}}else x=j;r=x<<24>>24;if(x<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}case 8:{r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;i=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;m=Ul(i|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;i=k+m|0;while(1){b[g+o>>0]=f[i>>2];o=o+1|0;m=b[r>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){y=m;break}else i=i+8|0}}else y=l;i=y<<24>>24;if(y<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+i|0,0,(e<<24>>24)-i|0)|0;h=1;return h|0}case 9:{i=a+24|0;o=b[i>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;j=a+40|0;m=fl(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;k=Ul(m|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=0;m=r+k|0;while(1){k=~~$(n[m>>2]);b[g+j>>0]=k;j=j+1|0;k=b[i>>0]|0;if((j|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){z=k;break}else m=m+4|0}}else z=o;m=z<<24>>24;if(z<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 10:{m=a+24|0;j=b[m>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){i=f[f[a>>2]>>2]|0;l=a+40|0;k=fl(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;r=Ul(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=0;k=i+r|0;while(1){b[g+l>>0]=~~+p[k>>3];l=l+1|0;r=b[m>>0]|0;if((l|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){A=r;break}else k=k+8|0}}else A=j;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 11:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;r=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;i=Ul(r|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;r=m+i|0;while(1){b[g+o>>0]=b[r>>0]|0;o=o+1|0;i=b[k>>0]|0;if((o|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){B=i;break}else r=r+1|0}}else B=l;r=B<<24>>24;if(B<<24>>24>=e<<24>>24){h=1;return h|0}Dh(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}default:{h=0;return h|0}}while(0);return 0}function Jb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){h=1;u=c;return h|0}i=(g>>>0)/3|0;j=a+12|0;if(f[(f[j>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0){h=1;u=c;return h|0}i=a+56|0;k=f[i>>2]|0;l=a+60|0;m=f[l>>2]|0;if((m|0)==(k|0))n=k;else{o=m+(~((m+-4-k|0)>>>2)<<2)|0;f[l>>2]=o;n=o}o=a+64|0;if((n|0)==(f[o>>2]|0))dh(i,b);else{f[n>>2]=g;f[l>>2]=n+4}n=f[a>>2]|0;g=f[b>>2]|0;k=g+1|0;if((g|0)==-1){h=0;u=c;return h|0}m=((k>>>0)%3|0|0)==0?g+-2|0:k;if((m|0)==-1)p=-1;else p=f[(f[n>>2]|0)+(m<<2)>>2]|0;m=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((m|0)==-1){h=0;u=c;return h|0}g=f[(f[n>>2]|0)+(m<<2)>>2]|0;if((p|0)==-1|(g|0)==-1){h=0;u=c;return h|0}m=a+24|0;n=f[m>>2]|0;k=n+(p>>>5<<2)|0;q=1<<(p&31);r=f[k>>2]|0;if(!(r&q)){f[k>>2]=r|q;q=f[b>>2]|0;r=q+1|0;if((q|0)==-1)s=-1;else s=((r>>>0)%3|0|0)==0?q+-2|0:r;f[e>>2]=s;r=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((s>>>0)/3|0)*12|0)+(((s>>>0)%3|0)<<2)>>2]|0;s=f[a+48>>2]|0;f[d>>2]=r;q=f[s+4>>2]|0;s=q+4|0;k=f[s>>2]|0;if((k|0)==(f[q+8>>2]|0))dh(q,d);else{f[k>>2]=r;f[s>>2]=k+4}k=a+40|0;s=f[k>>2]|0;r=s+4|0;q=f[r>>2]|0;if((q|0)==(f[s+8>>2]|0)){dh(s,e);t=f[k>>2]|0}else{f[q>>2]=f[e>>2];f[r>>2]=q+4;t=s}s=t+24|0;f[(f[t+12>>2]|0)+(p<<2)>>2]=f[s>>2];f[s>>2]=(f[s>>2]|0)+1;v=f[m>>2]|0}else v=n;n=v+(g>>>5<<2)|0;v=1<<(g&31);s=f[n>>2]|0;if(!(s&v)){f[n>>2]=s|v;v=f[b>>2]|0;do if((v|0)!=-1)if(!((v>>>0)%3|0)){w=v+2|0;break}else{w=v+-1|0;break}else w=-1;while(0);f[e>>2]=w;v=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((w>>>0)/3|0)*12|0)+(((w>>>0)%3|0)<<2)>>2]|0;w=f[a+48>>2]|0;f[d>>2]=v;s=f[w+4>>2]|0;w=s+4|0;n=f[w>>2]|0;if((n|0)==(f[s+8>>2]|0))dh(s,d);else{f[n>>2]=v;f[w>>2]=n+4}n=a+40|0;w=f[n>>2]|0;v=w+4|0;s=f[v>>2]|0;if((s|0)==(f[w+8>>2]|0)){dh(w,e);x=f[n>>2]|0}else{f[s>>2]=f[e>>2];f[v>>2]=s+4;x=w}w=x+24|0;f[(f[x+12>>2]|0)+(g<<2)>>2]=f[w>>2];f[w>>2]=(f[w>>2]|0)+1}w=f[i>>2]|0;g=f[l>>2]|0;if((w|0)==(g|0)){h=1;u=c;return h|0}x=a+44|0;s=a+48|0;v=a+40|0;n=g;g=w;a:while(1){w=f[n+-4>>2]|0;f[b>>2]=w;p=(w>>>0)/3|0;if((w|0)!=-1?(w=(f[j>>2]|0)+(p>>>5<<2)|0,t=1<<(p&31),p=f[w>>2]|0,(p&t|0)==0):0){f[w>>2]=p|t;t=f[b>>2]|0;if((t|0)==-1){h=0;y=80;break}p=f[a>>2]|0;w=t;b:while(1){t=f[(f[p>>2]|0)+(w<<2)>>2]|0;if((t|0)==-1){h=0;y=80;break a}q=(f[m>>2]|0)+(t>>>5<<2)|0;r=1<<(t&31);k=f[q>>2]|0;do if(!(k&r)){z=f[(f[p+24>>2]|0)+(t<<2)>>2]|0;A=z+1|0;do if((z|0)==-1)B=1;else{C=((A>>>0)%3|0|0)==0?z+-2|0:A;if((C|0)==-1){B=1;break}D=f[(f[p+12>>2]|0)+(C<<2)>>2]|0;C=D+1|0;if((D|0)==-1){B=1;break}B=((((C>>>0)%3|0|0)==0?D+-2|0:C)|0)==-1}while(0);f[q>>2]=k|r;A=f[b>>2]|0;f[e>>2]=A;z=f[(f[(f[x>>2]|0)+96>>2]|0)+(((A>>>0)/3|0)*12|0)+(((A>>>0)%3|0)<<2)>>2]|0;A=f[s>>2]|0;f[d>>2]=z;C=f[A+4>>2]|0;A=C+4|0;D=f[A>>2]|0;if((D|0)==(f[C+8>>2]|0))dh(C,d);else{f[D>>2]=z;f[A>>2]=D+4}D=f[v>>2]|0;A=D+4|0;z=f[A>>2]|0;if((z|0)==(f[D+8>>2]|0)){dh(D,e);E=f[v>>2]|0}else{f[z>>2]=f[e>>2];f[A>>2]=z+4;E=D}D=E+24|0;f[(f[E+12>>2]|0)+(t<<2)>>2]=f[D>>2];f[D>>2]=(f[D>>2]|0)+1;D=f[a>>2]|0;z=f[b>>2]|0;if(B)if((z|0)==-1){y=63;break b}else{F=z;G=D;y=64;break}do if((z|0)==-1)H=-1;else{A=z+1|0;C=((A>>>0)%3|0|0)==0?z+-2|0:A;if((C|0)==-1){H=-1;break}H=f[(f[D+12>>2]|0)+(C<<2)>>2]|0}while(0);f[b>>2]=H;I=D;J=(H>>>0)/3|0}else{F=w;G=p;y=64}while(0);if((y|0)==64){y=0;t=F+1|0;r=((t>>>0)%3|0|0)==0?F+-2|0:t;if((r|0)==-1)K=-1;else K=f[(f[G+12>>2]|0)+(r<<2)>>2]|0;f[d>>2]=K;r=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((r|0)==-1)L=-1;else L=f[(f[G+12>>2]|0)+(r<<2)>>2]|0;r=(K|0)==-1;t=(K>>>0)/3|0;k=r?-1:t;q=(L|0)==-1;z=(L>>>0)/3|0;C=q?-1:z;do if(!r){A=f[j>>2]|0;if(f[A+(k>>>5<<2)>>2]&1<<(k&31)|0){y=70;break}if(q){M=K;N=t;break}if(!(f[A+(C>>>5<<2)>>2]&1<<(C&31))){y=75;break b}else{M=K;N=t}}else y=70;while(0);if((y|0)==70){y=0;if(q){y=72;break}if(!(f[(f[j>>2]|0)+(C>>>5<<2)>>2]&1<<(C&31))){M=L;N=z}else{y=72;break}}f[b>>2]=M;I=G;J=N}t=(f[j>>2]|0)+(J>>>5<<2)|0;f[t>>2]=f[t>>2]|1<<(J&31);w=f[b>>2]|0;if((w|0)==-1){h=0;y=80;break a}else p=I}do if((y|0)==63){y=0;f[d>>2]=-1;y=72}else if((y|0)==75){y=0;p=f[l>>2]|0;f[p+-4>>2]=L;if((p|0)==(f[o>>2]|0)){dh(i,d);O=f[l>>2]|0;break}else{f[p>>2]=f[d>>2];w=p+4|0;f[l>>2]=w;O=w;break}}while(0);if((y|0)==72){y=0;w=(f[l>>2]|0)+-4|0;f[l>>2]=w;O=w}P=f[i>>2]|0;Q=O}else{w=n+-4|0;f[l>>2]=w;P=g;Q=w}if((P|0)==(Q|0)){h=1;y=80;break}else{n=Q;g=P}}if((y|0)==80){u=c;return h|0}return 0}function Kb(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,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[i+12>>0]=1;p=(o|0)==-1;if(p)q=-1;else q=f[(f[n>>2]|0)+(o<<2)>>2]|0;n=a+20|0;r=f[n>>2]|0;s=f[r>>2]|0;if((f[r+4>>2]|0)-s>>2>>>0<=q>>>0)Eo(r);r=a+8|0;t=f[(f[r>>2]|0)+(f[s+(q<<2)>>2]<<2)>>2]|0;q=a+4|0;s=f[q>>2]|0;if(!(b[s+84>>0]|0))v=f[(f[s+68>>2]|0)+(t<<2)>>2]|0;else v=t;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;f[j+16>>2]=0;f[j+20>>2]=0;f[h>>2]=v;v=b[s+24>>0]|0;f[g>>2]=f[h>>2];Ab(s,g,v,j)|0;v=a+28|0;a=(f[v>>2]|0)==0;a:do if(!p){s=k+8|0;t=j+8|0;w=k+16|0;x=j+16|0;y=l+8|0;z=l+16|0;A=o;B=0;C=0;D=0;E=0;F=0;G=0;H=o;J=a;K=o;while(1){do if(J){L=H+1|0;if((H|0)==-1){M=A;N=-1;O=-1;P=-1;break}Q=((L>>>0)%3|0|0)==0?H+-2|0:L;if((A|0)!=-1)if(!((A>>>0)%3|0)){R=A;S=A;T=Q;U=A+2|0;V=19;break}else{R=A;S=A;T=Q;U=A+-1|0;V=19;break}else{R=-1;S=-1;T=Q;U=-1;V=19}}else{Q=K+1|0;L=((Q>>>0)%3|0|0)==0?K+-2|0:Q;if(!((K>>>0)%3|0)){R=A;S=H;T=L;U=K+2|0;V=19;break}else{R=A;S=H;T=L;U=K+-1|0;V=19;break}}while(0);if((V|0)==19){V=0;if((T|0)==-1){M=R;N=S;O=U;P=-1}else{M=R;N=S;O=U;P=f[(f[f[m>>2]>>2]|0)+(T<<2)>>2]|0}}W=f[n>>2]|0;L=f[W>>2]|0;if((f[W+4>>2]|0)-L>>2>>>0<=P>>>0){V=22;break}Q=f[(f[r>>2]|0)+(f[L+(P<<2)>>2]<<2)>>2]|0;L=f[q>>2]|0;if(!(b[L+84>>0]|0))X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483477)|0);o=o+-4|0;if(o>>>0<=3)break;else q=q+4|0}q=d+-4|0;o=q&-4;t=c+(o+4)|0;v=r;w=q-o|0}else{t=c;v=d;w=d}switch(w|0){case 3:{x=h[t+2>>0]<<16^v;y=12;break}case 2:{x=v;y=12;break}case 1:{z=v;y=13;break}default:A=v}if((y|0)==12){z=h[t+1>>0]<<8^x;y=13}if((y|0)==13)A=X(h[t>>0]^z,1540483477)|0;z=X(A>>>13^A,1540483477)|0;A=z>>>15^z;z=a+4|0;t=f[z>>2]|0;x=(t|0)==0;a:do if(!x){v=t+-1|0;w=(v&t|0)==0;if(!w)if(A>>>0>>0)B=A;else B=(A>>>0)%(t>>>0)|0;else B=A&v;o=f[(f[a>>2]|0)+(B<<2)>>2]|0;if((o|0)!=0?(q=f[o>>2]|0,(q|0)!=0):0){o=(d|0)==0;if(w){if(o){w=q;while(1){r=f[w+4>>2]|0;if(!((r|0)==(A|0)|(r&v|0)==(B|0))){C=B;y=54;break a}r=b[w+8+11>>0]|0;if(!((r<<24>>24<0?f[w+12>>2]|0:r&255)|0))break a;w=f[w>>2]|0;if(!w){C=B;y=54;break a}}}else D=q;while(1){w=f[D+4>>2]|0;if(!((w|0)==(A|0)|(w&v|0)==(B|0))){C=B;y=54;break a}w=D+8|0;r=b[w+11>>0]|0;p=r<<24>>24<0;l=r&255;do if(((p?f[D+12>>2]|0:l)|0)==(d|0)){r=f[w>>2]|0;if(p)if(!(dj(r,c,d)|0))break a;else break;if((r&255)<<24>>24==(b[c>>0]|0)){r=l;E=w;F=c;do{r=r+-1|0;E=E+1|0;if(!r)break a;F=F+1|0}while((b[E>>0]|0)==(b[F>>0]|0))}}while(0);D=f[D>>2]|0;if(!D){C=B;y=54;break a}}}if(o){v=q;while(1){w=f[v+4>>2]|0;if((w|0)!=(A|0)){if(w>>>0>>0)G=w;else G=(w>>>0)%(t>>>0)|0;if((G|0)!=(B|0)){C=B;y=54;break a}}w=b[v+8+11>>0]|0;if(!((w<<24>>24<0?f[v+12>>2]|0:w&255)|0))break a;v=f[v>>2]|0;if(!v){C=B;y=54;break a}}}else H=q;while(1){v=f[H+4>>2]|0;if((v|0)!=(A|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(t>>>0)|0;if((I|0)!=(B|0)){C=B;y=54;break a}}v=H+8|0;o=b[v+11>>0]|0;w=o<<24>>24<0;l=o&255;do if(((w?f[H+12>>2]|0:l)|0)==(d|0)){o=f[v>>2]|0;if(w)if(!(dj(o,c,d)|0))break a;else break;if((o&255)<<24>>24==(b[c>>0]|0)){o=l;p=v;F=c;do{o=o+-1|0;p=p+1|0;if(!o)break a;F=F+1|0}while((b[p>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){C=B;y=54;break}}}else{C=B;y=54}}else{C=0;y=54}while(0);if((y|0)==54){Lf(g,a,A,i);y=a+12|0;J=$(((f[y>>2]|0)+1|0)>>>0);K=$(t>>>0);L=$(n[a+16>>2]);do if(x|J>$(K*L)){B=(t>>>0<3|(t+-1&t|0)!=0)&1|t<<1;H=~~$(W($(J/L)))>>>0;qg(a,B>>>0>>0?H:B);B=f[z>>2]|0;H=B+-1|0;if(!(H&B)){M=B;N=H&A;break}if(A>>>0>>0){M=B;N=A}else{M=B;N=(A>>>0)%(B>>>0)|0}}else{M=t;N=C}while(0);C=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!C){t=a+8|0;f[f[g>>2]>>2]=f[t>>2];f[t>>2]=f[g>>2];f[(f[a>>2]|0)+(N<<2)>>2]=t;t=f[g>>2]|0;N=f[t>>2]|0;if(!N)O=g;else{A=f[N+4>>2]|0;N=M+-1|0;if(N&M)if(A>>>0>>0)P=A;else P=(A>>>0)%(M>>>0)|0;else P=A&N;f[(f[a>>2]|0)+(P<<2)>>2]=t;O=g}}else{f[f[g>>2]>>2]=f[C>>2];f[C>>2]=f[g>>2];O=g}f[y>>2]=(f[y>>2]|0)+1;f[O>>2]=0}O=f[i+12>>2]|0;if(O|0){if((f[m>>2]|0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0)==(o|0)&m>>>0>>0){r=-1;u=d;return r|0}else{m=(f[c>>2]|0)+p|0;p=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;f[e>>2]=p;m=l;f[m>>2]=q;f[m+4>>2]=o;s=p;break}}else if(Ph(e,c)|0){s=f[e>>2]|0;break}else{r=-1;u=d;return r|0}while(0);a:do if(s|0){p=f[a+8>>2]|0;if(s>>>0>(((f[p+4>>2]|0)-(f[p>>2]|0)>>2>>>0)/3|0)>>>0){r=-1;u=d;return r|0}p=f[k>>2]|0;if(((h[p+36>>0]<<8|h[p+37>>0])&65535)<258){p=c+8|0;o=c+16|0;m=g+4|0;q=g+8|0;l=a+40|0;n=a+44|0;t=a+36|0;v=s;w=0;while(1){x=p;y=f[x>>2]|0;z=f[x+4>>2]|0;x=o;A=f[x>>2]|0;B=f[x+4>>2]|0;x=Ul(A|0,B|0,4,0)|0;C=I;if((z|0)<(C|0)|(z|0)==(C|0)&y>>>0>>0)break;D=f[c>>2]|0;E=D+A|0;f[g>>2]=h[E>>0]|h[E+1>>0]<<8|h[E+2>>0]<<16|h[E+3>>0]<<24;E=o;f[E>>2]=x;f[E+4>>2]=C;C=Ul(A|0,B|0,8,0)|0;E=I;if((z|0)<(E|0)|(z|0)==(E|0)&y>>>0>>0)break;C=D+x|0;f[m>>2]=h[C>>0]|h[C+1>>0]<<8|h[C+2>>0]<<16|h[C+3>>0]<<24;C=Ul(A|0,B|0,8,0)|0;x=I;E=o;f[E>>2]=C;f[E+4>>2]=x;if(!((z|0)>(x|0)|(z|0)==(x|0)&y>>>0>C>>>0))break;y=b[D+C>>0]|0;C=Ul(A|0,B|0,9,0)|0;B=o;f[B>>2]=C;f[B+4>>2]=I;b[q>>0]=b[q>>0]&-2|y&1;y=f[l>>2]|0;if((y|0)==(f[n>>2]|0)){Lg(t,g);F=f[e>>2]|0}else{f[y>>2]=f[g>>2];f[y+4>>2]=f[g+4>>2];f[y+8>>2]=f[g+8>>2];f[l>>2]=(f[l>>2]|0)+12;F=v}w=w+1|0;if(w>>>0>=F>>>0)break a;else v=F}r=-1;u=d;return r|0}v=g+4|0;w=a+40|0;l=a+44|0;t=a+36|0;n=0;q=0;do{Ph(i,c)|0;f[v>>2]=(f[i>>2]|0)+q;Ph(i,c)|0;o=f[i>>2]|0;q=f[v>>2]|0;if(q>>>0>>0){G=36;break}f[g>>2]=q-o;o=f[w>>2]|0;if((o|0)==(f[l>>2]|0))Lg(t,g);else{f[o>>2]=f[g>>2];f[o+4>>2]=f[g+4>>2];f[o+8>>2]=f[g+8>>2];f[w>>2]=(f[w>>2]|0)+12}n=n+1|0}while(n>>>0<(f[e>>2]|0)>>>0);if((G|0)==36){r=-1;u=d;return r|0}Af(c,0,0)|0;n=f[e>>2]|0;if(n|0){w=c+36|0;t=c+32|0;l=c+24|0;q=c+28|0;v=a+36|0;o=0;m=0;while(1){p=f[k>>2]|0;y=(b[w>>0]|0)==0;if(((h[p+36>>0]<<8|h[p+37>>0])&65535)<514)if(!y){p=f[t>>2]|0;B=f[l>>2]|0;C=f[q>>2]|0;A=B+(p>>>3)|0;if(A>>>0>>0){D=(h[A>>0]|0)>>>(p&7)&1;A=p+1|0;f[t>>2]=A;H=A;J=D}else{H=p;J=0}if((B+(H>>>3)|0)>>>0>>0){f[t>>2]=H+1;K=J}else K=J}else K=o;else if(!y){y=f[t>>2]|0;C=(f[l>>2]|0)+(y>>>3)|0;if(C>>>0<(f[q>>2]|0)>>>0){B=(h[C>>0]|0)>>>(y&7)&1;f[t>>2]=y+1;K=B}else K=0}else K=o;B=(f[v>>2]|0)+(m*12|0)+8|0;b[B>>0]=b[B>>0]&-2|K&1;m=m+1|0;if(m>>>0>=n>>>0)break;else o=K}}_j(c)}while(0);f[g>>2]=0;K=f[k>>2]|0;J=(h[K+36>>0]<<8|h[K+37>>0])&65535;if((J&65535)<512){K=c+8|0;H=f[K>>2]|0;e=f[K+4>>2]|0;K=c+16|0;F=K;s=f[F>>2]|0;o=Ul(s|0,f[F+4>>2]|0,4,0)|0;F=I;if((e|0)<(F|0)|(e|0)==(F|0)&H>>>0>>0)L=-1;else{H=(f[c>>2]|0)+s|0;s=h[H>>0]|h[H+1>>0]<<8|h[H+2>>0]<<16|h[H+3>>0]<<24;f[g>>2]=s;H=K;f[H>>2]=o;f[H+4>>2]=F;M=s;G=43}}else if(J<<16>>16==512)if(Ph(g,c)|0){M=f[g>>2]|0;G=43}else L=-1;else G=57;b:do if((G|0)==43)if(!M)G=57;else{J=f[k>>2]|0;if(((h[J+36>>0]<<8|h[J+37>>0])&65535)>=258){J=a+52|0;s=a+56|0;F=a+48|0;H=0;o=0;while(1){f[i>>2]=0;Ph(j,c)|0;o=(f[j>>2]|0)+o|0;f[i>>2]=o;K=f[J>>2]|0;if((K|0)==(f[s>>2]|0))dh(F,i);else{f[K>>2]=o;f[J>>2]=K+4}H=H+1|0;if(H>>>0>=(f[g>>2]|0)>>>0){G=57;break b}}}H=c+8|0;J=c+16|0;o=a+52|0;F=a+56|0;s=a+48|0;K=0;while(1){f[i>>2]=0;e=H;n=f[e>>2]|0;m=f[e+4>>2]|0;e=J;v=f[e>>2]|0;t=Ul(v|0,f[e+4>>2]|0,4,0)|0;e=I;if((m|0)<(e|0)|(m|0)==(e|0)&n>>>0>>0)break;n=(f[c>>2]|0)+v|0;v=h[n>>0]|h[n+1>>0]<<8|h[n+2>>0]<<16|h[n+3>>0]<<24;f[i>>2]=v;n=J;f[n>>2]=t;f[n+4>>2]=e;e=f[o>>2]|0;if((e|0)==(f[F>>2]|0))dh(s,i);else{f[e>>2]=v;f[o>>2]=e+4}K=K+1|0;if(K>>>0>=(f[g>>2]|0)>>>0){G=57;break b}}L=-1}while(0);if((G|0)==57)L=f[c+16>>2]|0;r=L;u=d;return r|0}function Qb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;d=u;u=u+736|0;e=d+716|0;g=d;h=d+64|0;if((j[c+38>>1]|0)<515){i=1;u=d;return i|0}k=c+8|0;l=f[k+4>>2]|0;m=c+16|0;n=m;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((l|0)>(p|0)|((l|0)==(p|0)?(f[k>>2]|0)>>>0>o>>>0:0))){i=0;u=d;return i|0}k=b[(f[c>>2]|0)+o>>0]|0;l=Ul(o|0,p|0,1,0)|0;p=m;f[p>>2]=l;f[p+4>>2]=I;p=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;l=f[(f[p>>2]|0)+80>>2]|0;p=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;f[e>>2]=0;m=e+4|0;f[m>>2]=0;f[e+8>>2]=0;do if(p|0)if(p>>>0>214748364)Eo(e);else{o=p*20|0;n=Yk(o)|0;f[e>>2]=n;f[e+8>>2]=n+(p*20|0);Dh(n|0,0,o|0)|0;f[m>>2]=n+o;break}while(0);p=a+64|0;o=a+68|0;n=a+60|0;q=a+52|0;r=a+56|0;s=a+48|0;t=0;v=0;a:while(1){if((t|0)>=(Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0)){w=44;break}x=Na[f[(f[a>>2]|0)+20>>2]&127](a,t)|0;y=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;z=f[(f[(f[y>>2]|0)+8>>2]|0)+(x<<2)>>2]|0;Lh(z,l)|0;b[z+84>>0]=1;x=f[z+68>>2]|0;y=z+72|0;A=f[y>>2]|0;if((A|0)!=(x|0))f[y>>2]=A+(~((A+-4-x|0)>>>2)<<2);switch(f[z+28>>2]|0){case 2:case 4:case 6:{B=z;break}case 1:case 3:case 5:{x=z+24|0;A=b[x>>0]|0;if(A<<24>>24>0){y=A;A=0;while(1){f[g>>2]=0;C=f[q>>2]|0;if(C>>>0<(f[r>>2]|0)>>>0){f[C>>2]=0;f[q>>2]=C+4;D=y}else{dh(s,g);D=b[x>>0]|0}A=A+1|0;if((A|0)>=(D<<24>>24|0))break;else y=D}}B=z;break}case 9:{y=b[z+24>>0]|0;Oj(g);A=f[z+56>>2]|0;x=X(Zj(6)|0,y<<24>>24)|0;Vh(g,A,0,y,6,0,x,((x|0)<0)<<31>>31,0,0);x=Yk(96)|0;zj(x,g);f[h>>2]=x;b[x+84>>0]=1;y=f[x+68>>2]|0;A=x+72|0;C=f[A>>2]|0;if((C|0)!=(y|0))f[A>>2]=C+(~((C+-4-y|0)>>>2)<<2);Lh(x,l)|0;x=f[p>>2]|0;if(x>>>0<(f[o>>2]|0)>>>0){y=f[h>>2]|0;f[h>>2]=0;f[x>>2]=y;y=x+4|0;f[p>>2]=y;E=y}else{Wd(n,h);E=f[p>>2]|0}y=f[E+-4>>2]|0;x=f[h>>2]|0;f[h>>2]=0;if(x|0){C=x+88|0;A=f[C>>2]|0;f[C>>2]=0;if(A|0){C=f[A+8>>2]|0;if(C|0){F=A+12|0;if((f[F>>2]|0)!=(C|0))f[F>>2]=C;lp(C)}lp(A)}A=f[x+68>>2]|0;if(A|0){C=x+72|0;F=f[C>>2]|0;if((F|0)!=(A|0))f[C>>2]=F+(~((F+-4-A|0)>>>2)<<2);lp(A)}A=x+64|0;F=f[A>>2]|0;f[A>>2]=0;if(F|0){A=f[F>>2]|0;if(A|0){C=F+4|0;if((f[C>>2]|0)!=(A|0))f[C>>2]=A;lp(A)}lp(F)}lp(x)}B=y;break}default:{G=0;break a}}y=B;x=f[y+28>>2]|0;F=Zj(x)|0;A=b[y+24>>0]|0;y=f[e>>2]|0;f[y+(t*20|0)>>2]=B;f[y+(t*20|0)+4>>2]=v;f[y+(t*20|0)+8>>2]=x;f[y+(t*20|0)+12>>2]=(F|0)>0?F:0;f[y+(t*20|0)+16>>2]=A;t=t+1|0;v=A+v|0}if((w|0)==44){Xf(g,e);switch(k<<24>>24){case 0:{ue(h,v);k=be(h,c,g)|0;xe(h);if(k)w=52;else H=0;break}case 1:{ue(h,v);k=ae(h,c,g)|0;xe(h);if(k)w=52;else H=0;break}case 2:{we(h,v);k=de(h,c,g)|0;De(h);if(k)w=52;else H=0;break}case 3:{we(h,v);k=ce(h,c,g)|0;De(h);if(k)w=52;else H=0;break}case 4:{se(h,v);k=Hd(h,c,g)|0;pe(h);if(k)w=52;else H=0;break}case 5:{se(h,v);k=Gd(h,c,g)|0;pe(h);if(k)w=52;else H=0;break}case 6:{se(h,v);v=Fd(h,c,g)|0;pe(h);if(v)w=52;else H=0;break}default:H=0}if((w|0)==52)H=1;w=f[g+16>>2]|0;if(w|0){v=g+20|0;h=f[v>>2]|0;if((h|0)!=(w|0))f[v>>2]=h+(~(((h+-20-w|0)>>>0)/20|0)*20|0);lp(w)}w=f[g>>2]|0;if(w|0){h=g+4|0;if((f[h>>2]|0)!=(w|0))f[h>>2]=w;lp(w)}G=H}H=f[e>>2]|0;if(H|0){e=f[m>>2]|0;if((e|0)!=(H|0))f[m>>2]=e+(~(((e+-20-H|0)>>>0)/20|0)*20|0);lp(H)}i=G;u=d;return i|0}function Rb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=Ka,ea=Ka,fa=0,ga=Ka,ha=0,ia=Ka;c=u;u=u+32|0;d=c+12|0;e=c;g=a+60|0;if((f[g>>2]|0)==(f[a+64>>2]|0)?(f[a+48>>2]|0)==(f[a+52>>2]|0):0){h=1;u=c;return h|0}a:do if((Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0)>0){i=d+4|0;j=d+8|0;k=e+4|0;l=e+8|0;m=e+8|0;o=d+8|0;p=a+36|0;q=d+8|0;r=d+4|0;s=d+11|0;t=d+4|0;v=0;w=0;x=0;b:while(1){y=Na[f[(f[a>>2]|0)+20>>2]&127](a,v)|0;z=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;A=f[(f[(f[z>>2]|0)+8>>2]|0)+(y<<2)>>2]|0;y=A+28|0;c:do switch(f[y>>2]|0){case 1:case 3:case 5:{z=A+24|0;B=b[z>>0]|0;C=B<<24>>24;f[d>>2]=0;f[i>>2]=0;f[j>>2]=0;if(!(B<<24>>24))D=0;else{if(B<<24>>24<0){E=8;break b}B=C<<2;F=Yk(B)|0;f[d>>2]=F;G=F+(C<<2)|0;f[o>>2]=G;Dh(F|0,0,B|0)|0;f[i>>2]=G;D=b[z>>0]|0}G=D<<24>>24;f[e>>2]=0;f[k>>2]=0;f[l>>2]=0;if(D<<24>>24){if(D<<24>>24<0){E=12;break b}B=G<<2;F=Yk(B)|0;f[e>>2]=F;C=F+(G<<2)|0;f[m>>2]=C;Dh(F|0,0,B|0)|0;f[k>>2]=C}switch(f[y>>2]|0){case 5:{if(Ed(a,A,x)|0)E=18;else{H=1;J=x}break}case 3:{if(Dd(a,A,x)|0)E=18;else{H=1;J=x}break}case 1:{if(sd(a,A,x)|0)E=18;else{H=1;J=x}break}default:E=18}if((E|0)==18){E=0;H=0;J=(b[z>>0]|0)+x|0}z=f[e>>2]|0;if(z|0){C=f[k>>2]|0;if((C|0)!=(z|0))f[k>>2]=C+(~((C+-4-z|0)>>>2)<<2);lp(z)}z=f[d>>2]|0;if(z|0){C=f[i>>2]|0;if((C|0)!=(z|0))f[i>>2]=C+(~((C+-4-z|0)>>>2)<<2);lp(z)}if(!H){K=w;L=J}else{M=H;break a}break}case 9:{z=f[(f[g>>2]|0)+(w<<2)>>2]|0;C=f[p>>2]|0;B=w+1|0;F=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+40|0;G=f[F>>2]|0;F=f[A+56>>2]|0;N=Yk(32)|0;f[d>>2]=N;f[q>>2]=-2147483616;f[r>>2]=24;O=N;P=11771;Q=O+24|0;do{b[O>>0]=b[P>>0]|0;O=O+1|0;P=P+1|0}while((O|0)<(Q|0));b[N+24>>0]=0;P=G+16|0;O=f[P>>2]|0;if(O){Q=P;R=O;d:while(1){O=R;while(1){if((f[O+16>>2]|0)>=(F|0))break;S=f[O+4>>2]|0;if(!S){T=Q;break d}else O=S}R=f[O>>2]|0;if(!R){T=O;break}else Q=O}if(((T|0)!=(P|0)?(F|0)>=(f[T+16>>2]|0):0)?(Q=T+20|0,(hg(Q,d)|0)!=0):0)U=hi(Q,d,0)|0;else E=37}else E=37;if((E|0)==37){E=0;U=hi(G,d,0)|0}if((b[s>>0]|0)<0)lp(f[d>>2]|0);if(U){Zd(A,z);K=B;L=x;break c}Q=f[C+(w*24|0)+4>>2]|0;R=b[A+24>>0]|0;N=R<<24>>24;S=N<<2;V=ip(N>>>0>1073741823?-1:N<<2)|0;Gn(d);if(!(Sk(d,$(n[C+(w*24|0)+20>>2]),(1<>2]>>2]|0)+(f[z+48>>2]|0)|0;W=z+80|0;e:do if(f[W>>2]|0){X=A+64|0;Y=C+(w*24|0)+8|0;if(R<<24>>24>0){Z=0;_=0;aa=0}else{ba=0;ca=0;while(1){Ff((f[f[X>>2]>>2]|0)+ca|0,V|0,S|0)|0;ba=ba+1|0;if(ba>>>0>=(f[W>>2]|0)>>>0)break e;else ca=ca+S|0}}while(1){ca=f[Y>>2]|0;da=$(n[t>>2]);ea=$(n[d>>2]);ba=0;O=aa;while(1){fa=f[Q+(O<<2)>>2]|0;if((fa|0)>-1)ga=$($($(fa|0)*da)*ea);else{ha=Wl(0,0,fa|0,((fa|0)<0)<<31>>31|0)|0;ga=$(-$(ea*$(da*$(+(ha>>>0)+4294967296.0*+(I|0)))))}ia=$(ga+$(n[ca+(ba<<2)>>2]));n[V+(ba<<2)>>2]=ia;ba=ba+1|0;if((ba|0)==(N|0))break;else O=O+1|0}Ff((f[f[X>>2]>>2]|0)+_|0,V|0,S|0)|0;Z=Z+1|0;if(Z>>>0>=(f[W>>2]|0)>>>0)break;else{_=_+S|0;aa=N+aa|0}}}while(0);jp(V);K=B;L=x;break}default:{K=w;L=x}}while(0);v=v+1|0;if((v|0)>=(Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0)){M=2;break a}else{w=K;x=L}}if((E|0)==8)Eo(d);else if((E|0)==12)Eo(e);else if((E|0)==54){jp(V);M=1;break}}else M=2;while(0);h=(M|0)==2;u=c;return h|0}function Sb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0;c=u;u=u+48|0;d=c+24|0;e=c+12|0;g=c;if(!b){h=0;u=c;return h|0}i=a+12|0;j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=k-l>>2;n=a+16|0;o=f[n>>2]|0;p=f[i>>2]|0;q=o-p>>2;r=p;p=o;if(m>>>0<=q>>>0)if(m>>>0>>0?(o=r+(m<<2)|0,(p|0)!=(o|0)):0){f[n>>2]=p+(~((p+-4-o|0)>>>2)<<2);s=l;t=k}else{s=l;t=k}else{ag(i,m-q|0,3564);s=f[a>>2]|0;t=f[j>>2]|0}f[d>>2]=0;q=d+4|0;f[q>>2]=0;f[d+8>>2]=0;fi(d,t-s>>2);s=f[j>>2]|0;t=f[a>>2]|0;if((s|0)==(t|0)){v=s;w=s}else{m=f[d>>2]|0;k=m;l=k;o=t;t=m;m=s;s=k;k=0;while(1){p=f[o+(k<<2)>>2]|0;n=f[q>>2]|0;if(p>>>0>2>>>0){x=l;y=s;z=o;A=m}else{r=p+1|0;f[e>>2]=0;B=n-t>>2;C=t;D=n;if(r>>>0<=B>>>0)if(r>>>0>>0?(n=C+(r<<2)|0,(D|0)!=(n|0)):0){f[q>>2]=D+(~((D+-4-n|0)>>>2)<<2);E=l;F=m;G=o}else{E=l;F=m;G=o}else{ag(d,r-B|0,e);E=f[d>>2]|0;F=f[j>>2]|0;G=f[a>>2]|0}x=E;y=E;z=G;A=F}B=y+(p<<2)|0;f[B>>2]=(f[B>>2]|0)+1;k=k+1|0;if(k>>>0>=A-z>>2>>>0){v=z;w=A;break}else{l=x;o=z;t=y;m=A;s=y}}}y=w-v|0;v=y>>2;f[e>>2]=0;w=e+4|0;f[w>>2]=0;f[e+8>>2]=0;if(!v){H=0;I=0}else{if(v>>>0>536870911)Eo(e);s=Yk(y<<1)|0;f[w>>2]=s;f[e>>2]=s;f[e+8>>2]=s+(v<<3);y=s;A=v;m=s;while(1){t=y;f[t>>2]=-1;f[t+4>>2]=-1;t=m+8|0;z=A+-1|0;if(!z)break;else{y=t;A=z;m=t}}f[w>>2]=s+(v<<3);H=s;I=s}s=f[q>>2]|0;v=f[d>>2]|0;m=s-v|0;A=m>>2;f[g>>2]=0;y=g+4|0;f[y>>2]=0;f[g+8>>2]=0;t=v;do if(A)if(A>>>0>1073741823)Eo(g);else{z=Yk(m)|0;f[g>>2]=z;o=z+(A<<2)|0;f[g+8>>2]=o;Dh(z|0,0,m|0)|0;f[y>>2]=o;J=z;K=o;L=z;break}else{J=0;K=0;L=0}while(0);if((s|0)!=(v|0)){v=0;s=0;do{f[J+(v<<2)>>2]=s;s=(f[t+(v<<2)>>2]|0)+s|0;v=v+1|0}while(v>>>0>>0)}v=f[j>>2]|0;j=f[a>>2]|0;s=j;if((v|0)!=(j|0)){m=a+40|0;a=v-j>>2;j=J;v=0;g=H;z=H;o=H;x=H;l=H;k=H;while(1){F=f[s+(v<<2)>>2]|0;G=v+1|0;E=((G>>>0)%3|0|0)==0?v+-2|0:G;if((E|0)==-1)M=-1;else M=f[s+(E<<2)>>2]|0;E=((v>>>0)%3|0|0)==0;G=(E?2:-1)+v|0;if((G|0)==-1)N=-1;else N=f[s+(G<<2)>>2]|0;if(E?(M|0)==(N|0)|((F|0)==(M|0)|(F|0)==(N|0)):0){f[m>>2]=(f[m>>2]|0)+1;O=j;P=v+2|0;Q=g;R=z;S=o;T=x;U=l;V=k}else W=51;a:do if((W|0)==51){W=0;E=f[t+(N<<2)>>2]|0;b:do if((E|0)>0){G=0;B=f[j+(N<<2)>>2]|0;while(1){p=f[l+(B<<3)>>2]|0;if((p|0)==-1){X=g;Y=z;Z=x;_=l;break b}if((p|0)==(M|0)){p=f[l+(B<<3)+4>>2]|0;if((p|0)==-1)$=-1;else $=f[s+(p<<2)>>2]|0;if((F|0)!=($|0))break}p=G+1|0;if((p|0)<(E|0)){G=p;B=B+1|0}else{X=g;Y=z;Z=x;_=l;break b}}p=f[x+(B<<3)+4>>2]|0;r=G;n=B;D=z;while(1){r=r+1|0;if((r|0)>=(E|0))break;C=n+1|0;f[D+(n<<3)>>2]=f[D+(C<<3)>>2];f[D+(n<<3)+4>>2]=f[D+(C<<3)+4>>2];if((f[g+(n<<3)>>2]|0)==-1)break;else{n=C;D=g}}f[o+(n<<3)>>2]=-1;if((p|0)==-1){X=o;Y=o;Z=o;_=o}else{D=f[i>>2]|0;f[D+(v<<2)>>2]=p;f[D+(p<<2)>>2]=v;O=j;P=v;Q=o;R=o;S=o;T=o;U=o;V=k;break a}}else{X=g;Y=z;Z=x;_=l}while(0);E=f[t+(M<<2)>>2]|0;if((E|0)>0){D=0;r=f[J+(M<<2)>>2]|0;while(1){aa=k+(r<<3)|0;if((f[aa>>2]|0)==-1)break;D=D+1|0;if((D|0)>=(E|0)){O=J;P=v;Q=k;R=k;S=k;T=k;U=k;V=k;break a}else r=r+1|0}f[aa>>2]=N;f[H+(r<<3)+4>>2]=v;O=J;P=v;Q=H;R=H;S=H;T=H;U=H;V=H}else{O=j;P=v;Q=X;R=Y;S=o;T=Z;U=_;V=k}}while(0);v=P+1|0;if(v>>>0>=a>>>0)break;else{j=O;g=Q;z=R;o=S;x=T;l=U;k=V}}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|0;f[n>>2]=o;if((o|0)<=(f[j>>2]|0)){if((o|0)<(f[l>>2]|0)){s=(f[m>>2]|0)+o|0;t=18}}else{s=o-(f[m>>2]|0)|0;t=18}if((t|0)==18){t=0;f[n>>2]=s}h=h+1|0;n=f[g>>2]|0}while((h|0)<(n|0));u=n}else u=r}else u=k;k=f[a+48>>2]|0;r=f[a+56>>2]|0;h=r+4|0;s=f[h>>2]|0;m=f[r>>2]|0;l=s-m|0;j=l>>2;if((l|0)<=4){jp(i);jp(d);return 1}l=f[a+52>>2]|0;q=(e|0)>0;n=a+16|0;o=a+32|0;p=a+12|0;v=a+20|0;a=k+12|0;w=e<<2;if(s-m>>2>>>0>1){x=m;y=u;z=1}else Eo(r);while(1){u=f[x+(z<<2)>>2]|0;if(q)Dh(d|0,0,w|0)|0;if((u|0)!=-1){m=f[a>>2]|0;s=u;A=0;while(1){B=f[m+(s<<2)>>2]|0;if((B|0)!=-1){C=f[k>>2]|0;D=f[l>>2]|0;E=f[D+(f[C+(B<<2)>>2]<<2)>>2]|0;F=B+1|0;G=((F>>>0)%3|0|0)==0?B+-2|0:F;if((G|0)==-1)H=-1;else H=f[C+(G<<2)>>2]|0;G=f[D+(H<<2)>>2]|0;F=(((B>>>0)%3|0|0)==0?2:-1)+B|0;if((F|0)==-1)I=-1;else I=f[C+(F<<2)>>2]|0;F=f[D+(I<<2)>>2]|0;if((E|0)<(z|0)&(G|0)<(z|0)&(F|0)<(z|0)){D=X(E,e)|0;E=X(G,e)|0;G=X(F,e)|0;if(q){F=0;do{f[i+(F<<2)>>2]=(f[c+(F+G<<2)>>2]|0)+(f[c+(F+E<<2)>>2]|0)-(f[c+(F+D<<2)>>2]|0);F=F+1|0}while((F|0)!=(e|0));if(q){F=0;do{D=d+(F<<2)|0;f[D>>2]=(f[D>>2]|0)+(f[i+(F<<2)>>2]|0);F=F+1|0}while((F|0)!=(e|0))}}J=A+1|0}else J=A}else J=A;F=(((s>>>0)%3|0|0)==0?2:-1)+s|0;do if((F|0)!=-1?(D=f[m+(F<<2)>>2]|0,(D|0)!=-1):0)if(!((D>>>0)%3|0)){K=D+2|0;break}else{K=D+-1|0;break}else K=-1;while(0);s=(K|0)==(u|0)?-1:K;if((s|0)==-1)break;else A=J}A=X(z,e)|0;if(J){if(q){s=0;do{u=d+(s<<2)|0;f[u>>2]=(f[u>>2]|0)/(J|0)|0;s=s+1|0}while((s|0)!=(e|0))}s=b+(A<<2)|0;u=c+(A<<2)|0;if((y|0)>0){m=0;do{F=f[d+(m<<2)>>2]|0;D=f[n>>2]|0;if((F|0)>(D|0)){E=f[o>>2]|0;f[E+(m<<2)>>2]=D;L=E}else{E=f[p>>2]|0;D=f[o>>2]|0;f[D+(m<<2)>>2]=(F|0)<(E|0)?E:F;L=D}m=m+1|0;M=f[g>>2]|0}while((m|0)<(M|0));if((M|0)>0){m=0;do{D=(f[s+(m<<2)>>2]|0)+(f[L+(m<<2)>>2]|0)|0;F=u+(m<<2)|0;f[F>>2]=D;if((D|0)<=(f[n>>2]|0)){if((D|0)<(f[p>>2]|0)){N=(f[v>>2]|0)+D|0;t=70}}else{N=D-(f[v>>2]|0)|0;t=70}if((t|0)==70){t=0;f[F>>2]=N}m=m+1|0;F=f[g>>2]|0}while((m|0)<(F|0));O=F}else O=M}else O=y}else{P=A;t=48}}else{P=X(z,e)|0;t=48}if((t|0)==48){t=0;m=c+((X(z+-1|0,e)|0)<<2)|0;u=b+(P<<2)|0;s=c+(P<<2)|0;if((y|0)>0){F=0;do{D=f[m+(F<<2)>>2]|0;E=f[n>>2]|0;if((D|0)>(E|0)){G=f[o>>2]|0;f[G+(F<<2)>>2]=E;Q=G}else{G=f[p>>2]|0;E=f[o>>2]|0;f[E+(F<<2)>>2]=(D|0)<(G|0)?G:D;Q=E}F=F+1|0;R=f[g>>2]|0}while((F|0)<(R|0));if((R|0)>0){F=0;do{m=(f[u+(F<<2)>>2]|0)+(f[Q+(F<<2)>>2]|0)|0;A=s+(F<<2)|0;f[A>>2]=m;if((m|0)<=(f[n>>2]|0)){if((m|0)<(f[p>>2]|0)){S=(f[v>>2]|0)+m|0;t=58}}else{S=m-(f[v>>2]|0)|0;t=58}if((t|0)==58){t=0;f[A>>2]=S}F=F+1|0;A=f[g>>2]|0}while((F|0)<(A|0));O=A}else O=R}else O=y}z=z+1|0;if((z|0)>=(j|0)){t=22;break}x=f[r>>2]|0;if((f[h>>2]|0)-x>>2>>>0<=z>>>0){t=23;break}else y=O}if((t|0)==22){jp(i);jp(d);return 1}else if((t|0)==23)Eo(r);return 0}function Ub(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;g=a+8|0;f[g>>2]=e;d=a+32|0;h=a+36|0;i=f[h>>2]|0;j=f[d>>2]|0;k=i-j>>2;l=j;j=i;if(k>>>0>=e>>>0){if(k>>>0>e>>>0?(i=l+(e<<2)|0,(j|0)!=(i|0)):0)f[h>>2]=j+(~((j+-4-i|0)>>>2)<<2)}else Og(d,e-k|0);k=e>>>0>1073741823?-1:e<<2;d=ip(k)|0;Dh(d|0,0,k|0)|0;i=ip(k)|0;Dh(i|0,0,k|0)|0;k=f[g>>2]|0;if((k|0)>0){j=a+16|0;h=a+32|0;l=a+12|0;m=0;do{n=f[d+(m<<2)>>2]|0;o=f[j>>2]|0;if((n|0)>(o|0)){p=f[h>>2]|0;f[p+(m<<2)>>2]=o;q=p}else{p=f[l>>2]|0;o=f[h>>2]|0;f[o+(m<<2)>>2]=(n|0)<(p|0)?p:n;q=o}m=m+1|0;r=f[g>>2]|0}while((m|0)<(r|0));if((r|0)>0){m=a+20|0;h=0;do{o=(f[b+(h<<2)>>2]|0)+(f[q+(h<<2)>>2]|0)|0;n=c+(h<<2)|0;f[n>>2]=o;if((o|0)<=(f[j>>2]|0)){if((o|0)<(f[l>>2]|0)){s=(f[m>>2]|0)+o|0;t=18}}else{s=o-(f[m>>2]|0)|0;t=18}if((t|0)==18){t=0;f[n>>2]=s}h=h+1|0;n=f[g>>2]|0}while((h|0)<(n|0));u=n}else u=r}else u=k;k=f[a+48>>2]|0;r=f[a+56>>2]|0;h=r+4|0;s=f[h>>2]|0;m=f[r>>2]|0;l=s-m|0;j=l>>2;if((l|0)<=4){jp(i);jp(d);return 1}l=f[a+52>>2]|0;q=(e|0)>0;n=a+16|0;o=a+32|0;p=a+12|0;v=a+20|0;a=k+64|0;w=k+28|0;x=e<<2;if(s-m>>2>>>0>1){y=m;z=u;A=1}else Eo(r);while(1){u=f[y+(A<<2)>>2]|0;if(q)Dh(d|0,0,x|0)|0;if((u|0)!=-1){m=f[k>>2]|0;s=u;B=0;while(1){if(((f[m+(s>>>5<<2)>>2]&1<<(s&31)|0)==0?(C=f[(f[(f[a>>2]|0)+12>>2]|0)+(s<<2)>>2]|0,(C|0)!=-1):0)?(D=f[w>>2]|0,E=f[l>>2]|0,F=f[E+(f[D+(C<<2)>>2]<<2)>>2]|0,G=C+1|0,H=f[E+(f[D+((((G>>>0)%3|0|0)==0?C+-2|0:G)<<2)>>2]<<2)>>2]|0,G=f[E+(f[D+((((C>>>0)%3|0|0)==0?2:-1)+C<<2)>>2]<<2)>>2]|0,(F|0)<(A|0)&(H|0)<(A|0)&(G|0)<(A|0)):0){C=X(F,e)|0;F=X(H,e)|0;H=X(G,e)|0;if(q){G=0;do{f[i+(G<<2)>>2]=(f[c+(G+H<<2)>>2]|0)+(f[c+(G+F<<2)>>2]|0)-(f[c+(G+C<<2)>>2]|0);G=G+1|0}while((G|0)!=(e|0));if(q){G=0;do{C=d+(G<<2)|0;f[C>>2]=(f[C>>2]|0)+(f[i+(G<<2)>>2]|0);G=G+1|0}while((G|0)!=(e|0))}}I=B+1|0}else I=B;G=(((s>>>0)%3|0|0)==0?2:-1)+s|0;do if(((G|0)!=-1?(f[m+(G>>>5<<2)>>2]&1<<(G&31)|0)==0:0)?(C=f[(f[(f[a>>2]|0)+12>>2]|0)+(G<<2)>>2]|0,(C|0)!=-1):0)if(!((C>>>0)%3|0)){J=C+2|0;break}else{J=C+-1|0;break}else J=-1;while(0);s=(J|0)==(u|0)?-1:J;if((s|0)==-1)break;else B=I}B=X(A,e)|0;if(I){if(q){s=0;do{u=d+(s<<2)|0;f[u>>2]=(f[u>>2]|0)/(I|0)|0;s=s+1|0}while((s|0)!=(e|0))}s=b+(B<<2)|0;u=c+(B<<2)|0;if((z|0)>0){m=0;do{G=f[d+(m<<2)>>2]|0;C=f[n>>2]|0;if((G|0)>(C|0)){F=f[o>>2]|0;f[F+(m<<2)>>2]=C;K=F}else{F=f[p>>2]|0;C=f[o>>2]|0;f[C+(m<<2)>>2]=(G|0)<(F|0)?F:G;K=C}m=m+1|0;L=f[g>>2]|0}while((m|0)<(L|0));if((L|0)>0){m=0;do{C=(f[s+(m<<2)>>2]|0)+(f[K+(m<<2)>>2]|0)|0;G=u+(m<<2)|0;f[G>>2]=C;if((C|0)<=(f[n>>2]|0)){if((C|0)<(f[p>>2]|0)){M=(f[v>>2]|0)+C|0;t=68}}else{M=C-(f[v>>2]|0)|0;t=68}if((t|0)==68){t=0;f[G>>2]=M}m=m+1|0;G=f[g>>2]|0}while((m|0)<(G|0));N=G}else N=L}else N=z}else{O=B;t=46}}else{O=X(A,e)|0;t=46}if((t|0)==46){t=0;m=c+((X(A+-1|0,e)|0)<<2)|0;u=b+(O<<2)|0;s=c+(O<<2)|0;if((z|0)>0){G=0;do{C=f[m+(G<<2)>>2]|0;F=f[n>>2]|0;if((C|0)>(F|0)){H=f[o>>2]|0;f[H+(G<<2)>>2]=F;P=H}else{H=f[p>>2]|0;F=f[o>>2]|0;f[F+(G<<2)>>2]=(C|0)<(H|0)?H:C;P=F}G=G+1|0;Q=f[g>>2]|0}while((G|0)<(Q|0));if((Q|0)>0){G=0;do{m=(f[u+(G<<2)>>2]|0)+(f[P+(G<<2)>>2]|0)|0;B=s+(G<<2)|0;f[B>>2]=m;if((m|0)<=(f[n>>2]|0)){if((m|0)<(f[p>>2]|0)){R=(f[v>>2]|0)+m|0;t=56}}else{R=m-(f[v>>2]|0)|0;t=56}if((t|0)==56){t=0;f[B>>2]=R}G=G+1|0;B=f[g>>2]|0}while((G|0)<(B|0));N=B}else N=Q}else N=z}A=A+1|0;if((A|0)>=(j|0)){t=22;break}y=f[r>>2]|0;if((f[h>>2]|0)-y>>2>>>0<=A>>>0){t=23;break}else z=N}if((t|0)==22){jp(i);jp(d);return 1}else if((t|0)==23)Eo(r);return 0}function Vb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;d=u;u=u+176|0;e=d+136|0;g=d+32|0;i=d;j=d+104|0;k=d+100|0;l=a+4|0;m=f[l>>2]|0;n=f[m+32>>2]|0;o=n+8|0;p=f[o>>2]|0;q=f[o+4>>2]|0;o=n+16|0;r=o;s=f[r>>2]|0;t=f[r+4>>2]|0;if(!((q|0)>(t|0)|(q|0)==(t|0)&p>>>0>s>>>0)){v=0;u=d;return v|0}r=f[n>>2]|0;n=b[r+s>>0]|0;w=Ul(s|0,t|0,1,0)|0;x=I;y=o;f[y>>2]=w;f[y+4>>2]=x;if(!((q|0)>(x|0)|(q|0)==(x|0)&p>>>0>w>>>0)){v=0;u=d;return v|0}x=b[r+w>>0]|0;w=Ul(s|0,t|0,2,0)|0;y=I;z=o;f[z>>2]=w;f[z+4>>2]=y;if(n<<24>>24>-1){z=n<<24>>24;A=f[a+216>>2]|0;if(z>>>0>=(((f[a+220>>2]|0)-A|0)/144|0)>>>0){v=0;u=d;return v|0}B=A+(z*144|0)|0;if((f[B>>2]|0)>-1){v=0;u=d;return v|0}else C=B}else{B=a+212|0;if((f[B>>2]|0)>-1){v=0;u=d;return v|0}else C=B}f[C>>2]=c;do if((((h[m+36>>0]|0)<<8|(h[m+37>>0]|0))&65535)>257)if((q|0)>(y|0)|(q|0)==(y|0)&p>>>0>w>>>0){C=b[r+w>>0]|0;B=Ul(s|0,t|0,3,0)|0;z=o;f[z>>2]=B;f[z+4>>2]=I;D=C&255;break}else{v=0;u=d;return v|0}else D=0;while(0);o=f[m+44>>2]|0;if(!(x<<24>>24)){if(n<<24>>24<0)E=a+184|0;else{x=n<<24>>24;m=f[a+216>>2]|0;b[m+(x*144|0)+100>>0]=0;E=m+(x*144|0)+104|0}switch((D&255)<<24>>24){case 0:{Dc(e,a,E);F=f[e>>2]|0;break}case 1:{Ud(e,a,E);F=f[e>>2]|0;break}default:{v=0;u=d;return v|0}}if(!F){v=0;u=d;return v|0}else G=F}else{if(D|0){v=0;u=d;return v|0}D=n<<24>>24;if(n<<24>>24<0){v=0;u=d;return v|0}n=Yk(88)|0;F=f[a+216>>2]|0;a=F+(D*144|0)+104|0;f[n+4>>2]=0;f[n>>2]=3124;E=n+12|0;f[E>>2]=3148;x=n+64|0;f[x>>2]=0;f[n+68>>2]=0;f[n+72>>2]=0;m=n+16|0;t=m+44|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(t|0));f[n+76>>2]=o;f[n+80>>2]=a;f[n+84>>2]=0;s=g+4|0;f[s>>2]=3148;w=g+56|0;f[w>>2]=0;r=g+60|0;f[r>>2]=0;f[g+64>>2]=0;m=g+8|0;t=m+44|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(t|0));m=F+(D*144|0)+4|0;f[i>>2]=3148;t=i+4|0;p=t+4|0;f[p>>2]=0;f[p+4>>2]=0;f[p+8>>2]=0;f[p+12>>2]=0;f[p+16>>2]=0;f[p+20>>2]=0;f[t>>2]=m;t=f[F+(D*144|0)+68>>2]|0;D=((f[t+4>>2]|0)-(f[t>>2]|0)>>2>>>0)/3|0;b[e>>0]=0;Hf(i+8|0,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}}while(0);l=(f[x>>2]|0)+(c<<2)|0;c=f[l>>2]|0;f[l>>2]=G;if(!c){v=1;u=d;return v|0}Ra[f[(f[c>>2]|0)+4>>2]&127](c);v=1;u=d;return v|0}function Wb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;d=u;u=u+16|0;e=d;g=a+144|0;i=f[g>>2]|0;k=Ma[f[(f[i>>2]|0)+32>>2]&127](i)|0;do if((((h[k+36>>0]|0)<<8|(h[k+37>>0]|0))&65535)<514){i=a+40|0;l=i;m=a;n=l+40|0;do{f[l>>2]=f[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));if(Af(i,1,e)|0){l=a;m=i;n=l+40|0;do{f[l>>2]=f[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));i=e;o=f[i>>2]|0;p=f[i+4>>2]|0;i=a+8|0;q=a+16|0;r=q;s=f[r>>2]|0;t=f[r+4>>2]|0;r=Wl(f[i>>2]|0,f[i+4>>2]|0,s|0,t|0)|0;i=I;if(!(p>>>0>i>>>0|(p|0)==(i|0)&o>>>0>r>>>0)){r=Ul(s|0,t|0,o|0,p|0)|0;p=q;f[p>>2]=r;f[p+4>>2]=I;break}}v=0;u=d;return v|0}while(0);do if((j[a+38>>1]|0)>=514){if(!(ud(a+80|0,a)|0)){v=0;u=d;return v|0}}else{k=a+96|0;l=k;m=a;n=l+40|0;do{f[l>>2]=f[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));if(Af(k,1,e)|0){l=a;m=k;n=l+40|0;do{f[l>>2]=f[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));k=e;p=f[k>>2]|0;r=f[k+4>>2]|0;k=a+8|0;q=a+16|0;o=q;t=f[o>>2]|0;s=f[o+4>>2]|0;o=Wl(f[k>>2]|0,f[k+4>>2]|0,t|0,s|0)|0;k=I;if(!(r>>>0>k>>>0|(r|0)==(k|0)&p>>>0>o>>>0)){o=Ul(t|0,s|0,p|0,r|0)|0;r=q;f[r>>2]=o;f[r+4>>2]=I;break}}v=0;u=d;return v|0}while(0);if(!(Zg(a)|0)){v=0;u=d;return v|0}l=c;m=a;n=l+40|0;do{f[l>>2]=f[m>>2];l=l+4|0;m=m+4|0}while((l|0)<(n|0));m=f[g>>2]|0;l=Ma[f[(f[m>>2]|0)+32>>2]&127](m)|0;do if((((h[l+36>>0]|0)<<8|(h[l+37>>0]|0))&65535)<514){m=f[g>>2]|0;n=(Ma[f[(f[m>>2]|0)+32>>2]&127](m)|0)+36|0;if(((h[n>>0]|0)<<8&65535)<512){n=c+8|0;m=f[n>>2]|0;r=f[n+4>>2]|0;n=c+16|0;o=n;q=f[o>>2]|0;p=Ul(q|0,f[o+4>>2]|0,4,0)|0;o=I;if(!((r|0)<(o|0)|(r|0)==(o|0)&m>>>0

>>0)){m=(f[c>>2]|0)+q|0;q=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;f[e>>2]=q;m=n;f[m>>2]=p;f[m+4>>2]=o;w=q;x=19}}else if(Ph(e,c)|0){w=f[e>>2]|0;x=19}if((((x|0)==19?(q=f[a+152>>2]|0,w>>>0>>0):0)?(o=c+8|0,m=f[o+4>>2]|0,p=c+16|0,n=p,r=f[n>>2]|0,s=f[n+4>>2]|0,(m|0)>(s|0)|((m|0)==(s|0)?(f[o>>2]|0)>>>0>r>>>0:0)):0)?(o=b[(f[c>>2]|0)+r>>0]|0,m=Ul(r|0,s|0,1,0)|0,s=p,f[s>>2]=m,f[s+4>>2]=I,o<<24>>24==0):0){f[a+176>>2]=2;f[a+180>>2]=7;y=q;break}v=0;u=d;return v|0}else{f[a+176>>2]=2;f[a+180>>2]=7;y=f[a+152>>2]|0}while(0);if((y|0)<0){v=0;u=d;return v|0}w=a+156|0;f[e>>2]=0;x=a+160|0;g=f[x>>2]|0;l=f[w>>2]|0;q=g-l>>2;o=l;l=g;if(y>>>0<=q>>>0)if(y>>>0>>0?(g=o+(y<<2)|0,(l|0)!=(g|0)):0){f[x>>2]=l+(~((l+-4-g|0)>>>2)<<2);z=2;A=7}else{z=2;A=7}else{ag(w,y-q|0,e);z=f[a+176>>2]|0;A=f[a+180>>2]|0}q=A-z+1|0;z=a+184|0;A=a+188|0;y=f[A>>2]|0;w=f[z>>2]|0;g=(y-w|0)/12|0;l=w;w=y;if(q>>>0<=g>>>0)if(q>>>0>>0?(x=l+(q*12|0)|0,(w|0)!=(x|0)):0){l=w;while(1){w=l+-12|0;f[A>>2]=w;o=f[w>>2]|0;if(!o)B=w;else{w=l+-8|0;s=f[w>>2]|0;if((s|0)!=(o|0))f[w>>2]=s+(~((s+-4-o|0)>>>2)<<2);lp(o);B=f[A>>2]|0}if((B|0)==(x|0))break;else l=B}C=B}else C=y;else{Fe(z,q-g|0);C=f[A>>2]|0}g=a+196|0;q=f[z>>2]|0;y=(C-q|0)/12|0;B=a+200|0;a=f[B>>2]|0;l=f[g>>2]|0;x=a-l>>2;o=l;l=a;if(y>>>0<=x>>>0)if(y>>>0>>0?(a=o+(y<<2)|0,(l|0)!=(a|0)):0){f[B>>2]=l+(~((l+-4-a|0)>>>2)<<2);D=C;E=q}else{D=C;E=q}else{Og(g,y-x|0);D=f[A>>2]|0;E=f[z>>2]|0}if((D|0)==(E|0)){v=1;u=d;return v|0}E=0;do{Ph(e,c)|0;D=f[e>>2]|0;if(D|0){x=f[z>>2]|0;y=x+(E*12|0)|0;q=x+(E*12|0)+4|0;C=f[q>>2]|0;a=f[y>>2]|0;l=C-a>>2;B=a;a=C;if(D>>>0<=l>>>0)if(D>>>0>>0?(C=B+(D<<2)|0,(a|0)!=(C|0)):0){f[q>>2]=a+(~((a+-4-C|0)>>>2)<<2);F=x;G=D}else{F=x;G=D}else{Og(y,D-l|0);F=f[z>>2]|0;G=f[e>>2]|0}yh(G,1,c,f[F+(E*12|0)>>2]|0)|0;f[(f[g>>2]|0)+(E<<2)>>2]=f[e>>2]}E=E+1|0}while(E>>>0<(((f[A>>2]|0)-(f[z>>2]|0)|0)/12|0)>>>0);v=1;u=d;return v|0}function Xb(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!a)return;b=a+-8|0;c=f[4120]|0;d=f[a+-4>>2]|0;a=d&-8;e=b+a|0;do if(!(d&1)){g=f[b>>2]|0;if(!(d&3))return;h=b+(0-g)|0;i=g+a|0;if(h>>>0>>0)return;if((h|0)==(f[4121]|0)){j=e+4|0;k=f[j>>2]|0;if((k&3|0)!=3){l=h;m=h;n=i;break}f[4118]=i;f[j>>2]=k&-2;f[h+4>>2]=i|1;f[h+i>>2]=i;return}k=g>>>3;if(g>>>0<256){g=f[h+8>>2]|0;j=f[h+12>>2]|0;if((j|0)==(g|0)){f[4116]=f[4116]&~(1<>2]=j;f[j+8>>2]=g;l=h;m=h;n=i;break}}g=f[h+24>>2]|0;j=f[h+12>>2]|0;do if((j|0)==(h|0)){k=h+16|0;o=k+4|0;p=f[o>>2]|0;if(!p){q=f[k>>2]|0;if(!q){r=0;break}else{s=q;t=k}}else{s=p;t=o}while(1){o=s+20|0;p=f[o>>2]|0;if(p|0){s=p;t=o;continue}o=s+16|0;p=f[o>>2]|0;if(!p)break;else{s=p;t=o}}f[t>>2]=0;r=s}else{o=f[h+8>>2]|0;f[o+12>>2]=j;f[j+8>>2]=o;r=j}while(0);if(g){j=f[h+28>>2]|0;o=16768+(j<<2)|0;if((h|0)==(f[o>>2]|0)){f[o>>2]=r;if(!r){f[4117]=f[4117]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=r;if(!r){l=h;m=h;n=i;break}}f[r+24>>2]=g;j=h+16|0;o=f[j>>2]|0;if(o|0){f[r+16>>2]=o;f[o+24>>2]=r}o=f[j+4>>2]|0;if(o){f[r+20>>2]=o;f[o+24>>2]=r;l=h;m=h;n=i}else{l=h;m=h;n=i}}else{l=h;m=h;n=i}}else{l=b;m=b;n=a}while(0);if(l>>>0>=e>>>0)return;a=e+4|0;b=f[a>>2]|0;if(!(b&1))return;if(!(b&2)){r=f[4121]|0;if((e|0)==(f[4122]|0)){s=(f[4119]|0)+n|0;f[4119]=s;f[4122]=m;f[m+4>>2]=s|1;if((m|0)!=(r|0))return;f[4121]=0;f[4118]=0;return}if((e|0)==(r|0)){r=(f[4118]|0)+n|0;f[4118]=r;f[4121]=l;f[m+4>>2]=r|1;f[l+r>>2]=r;return}r=(b&-8)+n|0;s=b>>>3;do if(b>>>0<256){t=f[e+8>>2]|0;c=f[e+12>>2]|0;if((c|0)==(t|0)){f[4116]=f[4116]&~(1<>2]=c;f[c+8>>2]=t;break}}else{t=f[e+24>>2]|0;c=f[e+12>>2]|0;do if((c|0)==(e|0)){d=e+16|0;o=d+4|0;j=f[o>>2]|0;if(!j){p=f[d>>2]|0;if(!p){u=0;break}else{v=p;w=d}}else{v=j;w=o}while(1){o=v+20|0;j=f[o>>2]|0;if(j|0){v=j;w=o;continue}o=v+16|0;j=f[o>>2]|0;if(!j)break;else{v=j;w=o}}f[w>>2]=0;u=v}else{o=f[e+8>>2]|0;f[o+12>>2]=c;f[c+8>>2]=o;u=c}while(0);if(t|0){c=f[e+28>>2]|0;i=16768+(c<<2)|0;if((e|0)==(f[i>>2]|0)){f[i>>2]=u;if(!u){f[4117]=f[4117]&~(1<>2]|0)!=(e|0)&1)<<2)>>2]=u;if(!u)break}f[u+24>>2]=t;c=e+16|0;i=f[c>>2]|0;if(i|0){f[u+16>>2]=i;f[i+24>>2]=u}i=f[c+4>>2]|0;if(i|0){f[u+20>>2]=i;f[i+24>>2]=u}}}while(0);f[m+4>>2]=r|1;f[l+r>>2]=r;if((m|0)==(f[4121]|0)){f[4118]=r;return}else x=r}else{f[a>>2]=b&-2;f[m+4>>2]=n|1;f[l+n>>2]=n;x=n}n=x>>>3;if(x>>>0<256){l=16504+(n<<1<<2)|0;b=f[4116]|0;a=1<>2]|0}f[y>>2]=m;f[z+12>>2]=m;f[m+8>>2]=z;f[m+12>>2]=l;return}l=x>>>8;if(l)if(x>>>0>16777215)A=31;else{z=(l+1048320|0)>>>16&8;y=l<>>16&4;a=y<>>16&2;b=14-(l|z|y)+(a<>>15)|0;A=x>>>(b+7|0)&1|b<<1}else A=0;b=16768+(A<<2)|0;f[m+28>>2]=A;f[m+20>>2]=0;f[m+16>>2]=0;y=f[4117]|0;a=1<>>1)|0);l=f[b>>2]|0;while(1){if((f[l+4>>2]&-8|0)==(x|0)){B=73;break}C=l+16+(z>>>31<<2)|0;n=f[C>>2]|0;if(!n){B=72;break}else{z=z<<1;l=n}}if((B|0)==72){f[C>>2]=m;f[m+24>>2]=l;f[m+12>>2]=m;f[m+8>>2]=m;break}else if((B|0)==73){z=l+8|0;t=f[z>>2]|0;f[t+12>>2]=m;f[z>>2]=m;f[m+8>>2]=t;f[m+12>>2]=l;f[m+24>>2]=0;break}}else{f[4117]=y|a;f[b>>2]=m;f[m+24>>2]=b;f[m+12>>2]=m;f[m+8>>2]=m}while(0);m=(f[4124]|0)+-1|0;f[4124]=m;if(!m)D=16920;else return;while(1){m=f[D>>2]|0;if(!m)break;else D=m+8|0}f[4124]=-1;return}function Yb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=Ka,F=Ka,G=Ka,H=0,I=0,J=0,K=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;e=i;j=i;while(1){k=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;e=(X(k>>>24^k,1540483477)|0)^(X(e,1540483477)|0);j=j+-4|0;if(j>>>0<=3)break;else d=d+4|0}d=i+-4|0;j=d&-4;l=g+(j+4)|0;m=e;o=d-j|0}else{l=g;m=i;o=i}switch(o|0){case 3:{p=h[l+2>>0]<<16^m;q=6;break}case 2:{p=m;q=6;break}case 1:{r=m;q=7;break}default:s=m}if((q|0)==6){r=h[l+1>>0]<<8^p;q=7}if((q|0)==7)s=X(h[l>>0]^r,1540483477)|0;r=X(s>>>13^s,1540483477)|0;s=r>>>15^r;r=a+4|0;l=f[r>>2]|0;p=(l|0)==0;a:do if(!p){m=l+-1|0;o=(m&l|0)==0;if(!o)if(s>>>0>>0)t=s;else t=(s>>>0)%(l>>>0)|0;else t=s&m;j=f[(f[a>>2]|0)+(t<<2)>>2]|0;if((j|0)!=0?(d=f[j>>2]|0,(d|0)!=0):0){j=(i|0)==0;if(o){if(j){o=d;while(1){e=f[o+4>>2]|0;if(!((e|0)==(s|0)|(e&m|0)==(t|0))){u=t;break a}e=b[o+8+11>>0]|0;if(!((e<<24>>24<0?f[o+12>>2]|0:e&255)|0)){v=o;break}o=f[o>>2]|0;if(!o){u=t;break a}}w=v+20|0;return w|0}else x=d;b:while(1){o=f[x+4>>2]|0;if(!((o|0)==(s|0)|(o&m|0)==(t|0))){u=t;break a}o=x+8|0;e=b[o+11>>0]|0;k=e<<24>>24<0;y=e&255;do if(((k?f[x+12>>2]|0:y)|0)==(i|0)){e=f[o>>2]|0;if(k)if(!(dj(e,g,i)|0)){v=x;q=63;break b}else break;if((e&255)<<24>>24==(b[g>>0]|0)){e=y;z=o;A=g;do{e=e+-1|0;z=z+1|0;if(!e){v=x;q=63;break b}A=A+1|0}while((b[z>>0]|0)==(b[A>>0]|0))}}while(0);x=f[x>>2]|0;if(!x){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}if(j){m=d;while(1){o=f[m+4>>2]|0;if((o|0)!=(s|0)){if(o>>>0>>0)B=o;else B=(o>>>0)%(l>>>0)|0;if((B|0)!=(t|0)){u=t;break a}}o=b[m+8+11>>0]|0;if(!((o<<24>>24<0?f[m+12>>2]|0:o&255)|0)){v=m;break}m=f[m>>2]|0;if(!m){u=t;break a}}w=v+20|0;return w|0}else C=d;c:while(1){m=f[C+4>>2]|0;if((m|0)!=(s|0)){if(m>>>0>>0)D=m;else D=(m>>>0)%(l>>>0)|0;if((D|0)!=(t|0)){u=t;break a}}m=C+8|0;j=b[m+11>>0]|0;o=j<<24>>24<0;y=j&255;do if(((o?f[C+12>>2]|0:y)|0)==(i|0)){j=f[m>>2]|0;if(o)if(!(dj(j,g,i)|0)){v=C;q=63;break c}else break;if((j&255)<<24>>24==(b[g>>0]|0)){j=y;k=m;A=g;do{j=j+-1|0;k=k+1|0;if(!j){v=C;q=63;break c}A=A+1|0}while((b[k>>0]|0)==(b[A>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}else u=t}else u=0;while(0);t=Yk(24)|0;zh(t+8|0,c);f[t+20>>2]=0;f[t+4>>2]=s;f[t>>2]=0;c=a+12|0;E=$(((f[c>>2]|0)+1|0)>>>0);F=$(l>>>0);G=$(n[a+16>>2]);do if(p|E>$(F*G)){C=(l>>>0<3|(l+-1&l|0)!=0)&1|l<<1;g=~~$(W($(E/G)))>>>0;qg(a,C>>>0>>0?g:C);C=f[r>>2]|0;g=C+-1|0;if(!(g&C)){H=C;I=g&s;break}if(s>>>0>>0){H=C;I=s}else{H=C;I=(s>>>0)%(C>>>0)|0}}else{H=l;I=u}while(0);u=(f[a>>2]|0)+(I<<2)|0;I=f[u>>2]|0;if(!I){l=a+8|0;f[t>>2]=f[l>>2];f[l>>2]=t;f[u>>2]=l;l=f[t>>2]|0;if(l|0){u=f[l+4>>2]|0;l=H+-1|0;if(l&H)if(u>>>0>>0)J=u;else J=(u>>>0)%(H>>>0)|0;else J=u&l;K=(f[a>>2]|0)+(J<<2)|0;q=61}}else{f[t>>2]=f[I>>2];K=I;q=61}if((q|0)==61)f[K>>2]=t;f[c>>2]=(f[c>>2]|0)+1;v=t;w=v+20|0;return w|0}function Zb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;g=a+8|0;f[g>>2]=e;d=a+32|0;h=a+36|0;i=f[h>>2]|0;j=f[d>>2]|0;k=i-j>>2;l=j;j=i;if(k>>>0>=e>>>0)if(k>>>0>e>>>0?(i=l+(e<<2)|0,(j|0)!=(i|0)):0){f[h>>2]=j+(~((j+-4-i|0)>>>2)<<2);m=e}else m=e;else{Og(d,e-k|0);m=f[g>>2]|0}k=f[a+48>>2]|0;d=f[a+52>>2]|0;i=e>>>0>1073741823?-1:e<<2;j=ip(i)|0;Dh(j|0,0,i|0)|0;if((m|0)>0){i=a+16|0;h=a+32|0;l=a+12|0;n=0;do{o=f[j+(n<<2)>>2]|0;p=f[i>>2]|0;if((o|0)>(p|0)){q=f[h>>2]|0;f[q+(n<<2)>>2]=p;r=q}else{q=f[l>>2]|0;p=f[h>>2]|0;f[p+(n<<2)>>2]=(o|0)<(q|0)?q:o;r=p}n=n+1|0;s=f[g>>2]|0}while((n|0)<(s|0));if((s|0)>0){n=a+20|0;h=0;do{p=(f[b+(h<<2)>>2]|0)+(f[r+(h<<2)>>2]|0)|0;o=c+(h<<2)|0;f[o>>2]=p;if((p|0)<=(f[i>>2]|0)){if((p|0)<(f[l>>2]|0)){t=(f[n>>2]|0)+p|0;u=18}}else{t=p-(f[n>>2]|0)|0;u=18}if((u|0)==18){u=0;f[o>>2]=t}h=h+1|0;o=f[g>>2]|0}while((h|0)<(o|0));v=o}else v=s}else v=m;m=f[a+56>>2]|0;s=f[m>>2]|0;h=(f[m+4>>2]|0)-s|0;t=h>>2;if((h|0)<=4){jp(j);return 1}h=a+16|0;n=a+32|0;l=a+12|0;i=a+20|0;a=k+12|0;r=(e|0)>0;o=s;s=v;v=1;while(1){if(t>>>0<=v>>>0){u=24;break}p=f[o+(v<<2)>>2]|0;q=X(v,e)|0;if((p|0)!=-1?(w=f[(f[a>>2]|0)+(p<<2)>>2]|0,(w|0)!=-1):0){p=f[k>>2]|0;x=f[d>>2]|0;y=f[x+(f[p+(w<<2)>>2]<<2)>>2]|0;z=w+1|0;A=((z>>>0)%3|0|0)==0?w+-2|0:z;if((A|0)==-1)B=-1;else B=f[p+(A<<2)>>2]|0;A=f[x+(B<<2)>>2]|0;z=(((w>>>0)%3|0|0)==0?2:-1)+w|0;if((z|0)==-1)C=-1;else C=f[p+(z<<2)>>2]|0;z=f[x+(C<<2)>>2]|0;if((y|0)<(v|0)&(A|0)<(v|0)&(z|0)<(v|0)){x=X(y,e)|0;y=X(A,e)|0;A=X(z,e)|0;if(r){z=0;do{f[j+(z<<2)>>2]=(f[c+(z+A<<2)>>2]|0)+(f[c+(z+y<<2)>>2]|0)-(f[c+(z+x<<2)>>2]|0);z=z+1|0}while((z|0)!=(e|0))}z=b+(q<<2)|0;x=c+(q<<2)|0;if((s|0)>0){y=0;do{A=f[j+(y<<2)>>2]|0;p=f[h>>2]|0;if((A|0)>(p|0)){w=f[n>>2]|0;f[w+(y<<2)>>2]=p;D=w}else{w=f[l>>2]|0;p=f[n>>2]|0;f[p+(y<<2)>>2]=(A|0)<(w|0)?w:A;D=p}y=y+1|0;E=f[g>>2]|0}while((y|0)<(E|0));if((E|0)>0){y=0;do{p=(f[z+(y<<2)>>2]|0)+(f[D+(y<<2)>>2]|0)|0;A=x+(y<<2)|0;f[A>>2]=p;if((p|0)<=(f[h>>2]|0)){if((p|0)<(f[l>>2]|0)){F=(f[i>>2]|0)+p|0;u=56}}else{F=p-(f[i>>2]|0)|0;u=56}if((u|0)==56){u=0;f[A>>2]=F}y=y+1|0;A=f[g>>2]|0}while((y|0)<(A|0));G=A}else G=E}else G=s}else u=34}else u=34;if((u|0)==34){u=0;y=c+((X(v+-1|0,e)|0)<<2)|0;x=b+(q<<2)|0;z=c+(q<<2)|0;if((s|0)>0){A=0;do{p=f[y+(A<<2)>>2]|0;w=f[h>>2]|0;if((p|0)>(w|0)){H=f[n>>2]|0;f[H+(A<<2)>>2]=w;I=H}else{H=f[l>>2]|0;w=f[n>>2]|0;f[w+(A<<2)>>2]=(p|0)<(H|0)?H:p;I=w}A=A+1|0;J=f[g>>2]|0}while((A|0)<(J|0));if((J|0)>0){A=0;do{y=(f[x+(A<<2)>>2]|0)+(f[I+(A<<2)>>2]|0)|0;q=z+(A<<2)|0;f[q>>2]=y;if((y|0)<=(f[h>>2]|0)){if((y|0)<(f[l>>2]|0)){K=(f[i>>2]|0)+y|0;u=44}}else{K=y-(f[i>>2]|0)|0;u=44}if((u|0)==44){u=0;f[q>>2]=K}A=A+1|0;q=f[g>>2]|0}while((A|0)<(q|0));G=q}else G=J}else G=s}v=v+1|0;if((v|0)>=(t|0)){u=22;break}else s=G}if((u|0)==22){jp(j);return 1}else if((u|0)==24)Eo(m);return 0}function _b(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;g=a+8|0;f[g>>2]=e;d=a+32|0;h=a+36|0;i=f[h>>2]|0;j=f[d>>2]|0;k=i-j>>2;l=j;j=i;if(k>>>0>=e>>>0)if(k>>>0>e>>>0?(i=l+(e<<2)|0,(j|0)!=(i|0)):0){f[h>>2]=j+(~((j+-4-i|0)>>>2)<<2);m=e}else m=e;else{Og(d,e-k|0);m=f[g>>2]|0}k=f[a+48>>2]|0;d=f[a+52>>2]|0;i=e>>>0>1073741823?-1:e<<2;j=ip(i)|0;Dh(j|0,0,i|0)|0;if((m|0)>0){i=a+16|0;h=a+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<<2)>>2]|0)+(f[c+(A+z<<2)>>2]|0)-(f[c+(A+x<<2)>>2]|0);A=A+1|0}while((A|0)!=(e|0))}A=b+(w<<2)|0;x=c+(w<<2)|0;if((s|0)>0){z=0;do{B=f[j+(z<<2)>>2]|0;q=f[h>>2]|0;if((B|0)>(q|0)){y=f[n>>2]|0;f[y+(z<<2)>>2]=q;C=y}else{y=f[l>>2]|0;q=f[n>>2]|0;f[q+(z<<2)>>2]=(B|0)<(y|0)?y:B;C=q}z=z+1|0;D=f[g>>2]|0}while((z|0)<(D|0));if((D|0)>0){z=0;do{q=(f[A+(z<<2)>>2]|0)+(f[C+(z<<2)>>2]|0)|0;B=x+(z<<2)|0;f[B>>2]=q;if((q|0)<=(f[h>>2]|0)){if((q|0)<(f[l>>2]|0)){E=(f[i>>2]|0)+q|0;u=53}}else{E=q-(f[i>>2]|0)|0;u=53}if((u|0)==53){u=0;f[B>>2]=E}z=z+1|0;B=f[g>>2]|0}while((z|0)<(B|0));F=B}else F=D}else F=s}else{z=c+((X(v+-1|0,e)|0)<<2)|0;x=b+(w<<2)|0;A=c+(w<<2)|0;if((s|0)>0){B=0;do{q=f[z+(B<<2)>>2]|0;y=f[h>>2]|0;if((q|0)>(y|0)){G=f[n>>2]|0;f[G+(B<<2)>>2]=y;H=G}else{G=f[l>>2]|0;y=f[n>>2]|0;f[y+(B<<2)>>2]=(q|0)<(G|0)?G:q;H=y}B=B+1|0;I=f[g>>2]|0}while((B|0)<(I|0));if((I|0)>0){B=0;do{z=(f[x+(B<<2)>>2]|0)+(f[H+(B<<2)>>2]|0)|0;w=A+(B<<2)|0;f[w>>2]=z;if((z|0)<=(f[h>>2]|0)){if((z|0)<(f[l>>2]|0)){J=(f[i>>2]|0)+z|0;u=41}}else{J=z-(f[i>>2]|0)|0;u=41}if((u|0)==41){u=0;f[w>>2]=J}B=B+1|0;w=f[g>>2]|0}while((B|0)<(w|0));F=w}else F=I}else F=s}v=v+1|0;if((v|0)>=(t|0)){u=22;break}else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]=q;b[o+1>>0]=q>>8;b[o+2>>0]=q>>16;b[o+3>>0]=q>>24;s=l;m=f[s>>2]|0;n=f[s+4>>2]|0;s=Ul(m|0,n|0,4,0)|0;t=l;f[t>>2]=s;f[t+4>>2]=I;t=a+16|0;a=k;k=f[a>>2]|0;p=f[a+4>>2]|0;a=Ul(m|0,n|0,8,0)|0;n=I;if((p|0)<(n|0)|(p|0)==(n|0)&k>>>0>>0){r=0;u=e;return r|0}a=(f[c>>2]|0)+s|0;s=h[a>>0]|h[a+1>>0]<<8|h[a+2>>0]<<16|h[a+3>>0]<<24;b[t>>0]=s;b[t+1>>0]=s>>8;b[t+2>>0]=s>>16;b[t+3>>0]=s>>24;a=l;k=Ul(f[a>>2]|0,f[a+4>>2]|0,4,0)|0;a=l;f[a>>2]=k;f[a+4>>2]=I;if(s>>>0>6){f[g>>2]=s;Ml(13331,g)|0;r=0;u=e;return r|0}f[i>>2]=d;a:do if(!q)v=17;else{ih(d,q);switch(f[t>>2]|0){case 0:{ue(j,3);Pd(j,c,i)|0;xe(j);v=17;break a;break}case 1:{ue(j,3);Od(j,c,i)|0;xe(j);v=17;break a;break}case 2:{we(j,3);Rd(j,c,i)|0;De(j);v=17;break a;break}case 3:{we(j,3);Qd(j,c,i)|0;De(j);v=17;break a;break}case 4:{se(j,3);zd(j,c,i)|0;pe(j);v=17;break a;break}case 5:{se(j,3);yd(j,c,i)|0;pe(j);v=17;break a;break}case 6:{se(j,3);xd(j,c,i)|0;pe(j);v=17;break a;break}default:{w=0;break a}}}while(0);if((v|0)==17)w=(((f[d+4>>2]|0)-(f[d>>2]|0)|0)/12|0|0)==(f[o>>2]|0);r=w;u=e;return r|0}function ac(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=u;u=u+16|0;g=e;i=c+8|0;j=i;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Ul(n|0,f[m+4>>2]|0,5,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){o=Yk(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=o;q=12945;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+29>>0]=0;f[a>>2]=-2;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}o=(f[c>>2]|0)+n|0;b[d>>0]=b[o>>0]|0;b[d+1>>0]=b[o+1>>0]|0;b[d+2>>0]=b[o+2>>0]|0;b[d+3>>0]=b[o+3>>0]|0;b[d+4>>0]=b[o+4>>0]|0;o=j;n=Ul(f[o>>2]|0,f[o+4>>2]|0,5,0)|0;o=I;k=j;f[k>>2]=n;f[k+4>>2]=o;if(dj(d,12975,5)|0){k=Yk(32)|0;f[g>>2]=k;f[g+8>>2]=-2147483616;f[g+4>>2]=17;p=k;q=12981;r=p+17|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[k+17>>0]=0;f[a>>2]=-1;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}k=i;m=f[k+4>>2]|0;if(!((m|0)>(o|0)|((m|0)==(o|0)?(f[k>>2]|0)>>>0>n>>>0:0))){k=Yk(32)|0;f[g>>2]=k;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=k;q=12945;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[k+29>>0]=0;f[a>>2]=-2;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}b[d+5>>0]=b[(f[c>>2]|0)+n>>0]|0;n=j;k=Ul(f[n>>2]|0,f[n+4>>2]|0,1,0)|0;n=I;o=j;f[o>>2]=k;f[o+4>>2]=n;o=i;m=f[o+4>>2]|0;if(!((m|0)>(n|0)|((m|0)==(n|0)?(f[o>>2]|0)>>>0>k>>>0:0))){o=Yk(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=o;q=12945;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+29>>0]=0;f[a>>2]=-2;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}b[d+6>>0]=b[(f[c>>2]|0)+k>>0]|0;k=j;o=Ul(f[k>>2]|0,f[k+4>>2]|0,1,0)|0;k=I;n=j;f[n>>2]=o;f[n+4>>2]=k;n=i;m=f[n+4>>2]|0;if(!((m|0)>(k|0)|((m|0)==(k|0)?(f[n>>2]|0)>>>0>o>>>0:0))){n=Yk(32)|0;f[g>>2]=n;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=n;q=12945;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[n+29>>0]=0;f[a>>2]=-2;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}b[d+7>>0]=b[(f[c>>2]|0)+o>>0]|0;o=j;n=Ul(f[o>>2]|0,f[o+4>>2]|0,1,0)|0;o=I;k=j;f[k>>2]=n;f[k+4>>2]=o;k=i;m=f[k+4>>2]|0;if(!((m|0)>(o|0)|((m|0)==(o|0)?(f[k>>2]|0)>>>0>n>>>0:0))){k=Yk(32)|0;f[g>>2]=k;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=k;q=12945;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[k+29>>0]=0;f[a>>2]=-2;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}b[d+8>>0]=b[(f[c>>2]|0)+n>>0]|0;n=j;k=f[n>>2]|0;o=f[n+4>>2]|0;n=Ul(k|0,o|0,1,0)|0;m=j;f[m>>2]=n;f[m+4>>2]=I;m=i;i=f[m>>2]|0;l=f[m+4>>2]|0;m=Ul(k|0,o|0,3,0)|0;o=I;if(!((l|0)<(o|0)|(l|0)==(o|0)&i>>>0>>0)){m=d+10|0;d=(f[c>>2]|0)+n|0;n=h[d>>0]|h[d+1>>0]<<8;b[m>>0]=n;b[m+1>>0]=n>>8;n=j;m=Ul(f[n>>2]|0,f[n+4>>2]|0,2,0)|0;n=j;f[n>>2]=m;f[n+4>>2]=I;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=e;return}n=Yk(32)|0;f[g>>2]=n;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=n;q=12945;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[n+29>>0]=0;f[a>>2]=-2;zh(a+4|0,g);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=e;return}function bc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0;d=u;u=u+80|0;e=d+76|0;g=d;i=d+72|0;j=d+64|0;k=d+68|0;l=a+28|0;do if(((h[(f[l>>2]|0)+36>>0]|0)<<8&65535)<512){m=c+8|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=c+16|0;p=m;q=f[p>>2]|0;r=Ul(q|0,f[p+4>>2]|0,4,0)|0;p=I;if((o|0)<(p|0)|(o|0)==(p|0)&n>>>0>>0){s=0;u=d;return s|0}else{n=(f[c>>2]|0)+q|0;q=h[n>>0]|h[n+1>>0]<<8|h[n+2>>0]<<16|h[n+3>>0]<<24;f[e>>2]=q;n=m;f[n>>2]=r;f[n+4>>2]=p;t=q;break}}else if(Ph(e,c)|0){t=f[e>>2]|0;break}else{s=0;u=d;return s|0}while(0);if(!t){s=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if((A|0)<(E|0)|(A|0)==(E|0)&x>>>0>>0){B=47;break}x=(f[c>>2]|0)+F|0;F=h[x>>0]|h[x+1>>0]<<8;x=p;f[x>>2]=C;f[x+4>>2]=E;E=F&65535;f[i>>2]=E;J=E}else{Ph(i,c)|0;J=f[i>>2]|0}f[t>>2]=J;E=Yk(96)|0;zj(E,g);f[j>>2]=E;E=Of(m,j)|0;F=f[j>>2]|0;f[j>>2]=0;if(F|0){x=F+88|0;C=f[x>>2]|0;f[x>>2]=0;if(C|0){x=f[C+8>>2]|0;if(x|0){A=C+12|0;if((f[A>>2]|0)!=(x|0))f[A>>2]=x;lp(x)}lp(C)}C=f[F+68>>2]|0;if(C|0){x=F+72|0;A=f[x>>2]|0;if((A|0)!=(C|0))f[x>>2]=A+(~((A+-4-C|0)>>>2)<<2);lp(C)}C=F+64|0;A=f[C>>2]|0;f[C>>2]=0;if(A|0){C=f[A>>2]|0;if(C|0){x=A+4|0;if((f[x>>2]|0)!=(C|0))f[x>>2]=C;lp(C)}lp(A)}lp(F)}f[(f[(f[o>>2]|0)+(E<<2)>>2]|0)+60>>2]=f[i>>2];f[(f[q>>2]|0)+(a<<2)>>2]=E;F=f[v>>2]|0;A=f[n>>2]|0;C=F-A>>2;x=A;if((E|0)<(C|0))K=x;else{A=E+1|0;f[k>>2]=-1;D=F;if(A>>>0<=C>>>0)if(A>>>0>>0?(F=x+(A<<2)|0,(D|0)!=(F|0)):0){f[v>>2]=D+(~((D+-4-F|0)>>>2)<<2);L=x}else L=x;else{ag(n,A-C|0,k);L=f[n>>2]|0}K=L}f[K+(E<<2)>>2]=a;a=a+1|0;if(a>>>0>=(f[e>>2]|0)>>>0){s=1;B=49;break}}if((B|0)==47){s=0;u=d;return s|0}else if((B|0)==49){u=d;return s|0}return 0}function cc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;if((b|0)<0)return;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=f[q>>2]|0;e=f[p+40>>2]|0;while(1){if((e|0)==(c|0))break a;r=e+4|0;if((f[(f[e>>2]|0)+40>>2]|0)==(i|0))break;else e=r}if((r|0)!=(c|0)){g=r;h=e;do{o=f[g>>2]|0;f[g>>2]=0;j=f[h>>2]|0;f[h>>2]=o;if(j|0){jh(j);lp(j)}g=g+4|0;h=h+4|0}while((g|0)!=(c|0));g=f[q>>2]|0;if((g|0)==(h|0))break;else{s=g;t=h}}else{s=c;t=e}g=s;do{j=g+-4|0;f[q>>2]=j;o=f[j>>2]|0;f[j>>2]=0;if(o|0){jh(o);lp(o)}g=f[q>>2]|0}while((g|0)!=(t|0))}while(0);b:do if((d|0)<5){t=f[a+20+(d*12|0)>>2]|0;s=a+20+(d*12|0)+4|0;r=f[s>>2]|0;i=r;c:do if((t|0)==(r|0))u=t;else{p=t;while(1){if((f[p>>2]|0)==(b|0)){u=p;break c}p=p+4|0;if((p|0)==(r|0))break b}}while(0);if((u|0)!=(r|0)){t=u+4|0;p=i-t|0;g=p>>2;if(!g)v=r;else{ok(u|0,t|0,p|0)|0;v=f[s>>2]|0}p=u+(g<<2)|0;if((v|0)!=(p|0))f[s>>2]=v+(~((v+-4-p|0)>>>2)<<2)}}while(0);v=f[a+24>>2]|0;u=f[a+20>>2]|0;d=u;if((v|0)!=(u|0)){p=v-u>>2;u=0;do{v=d+(u<<2)|0;g=f[v>>2]|0;if((g|0)>(b|0))f[v>>2]=g+-1;u=u+1|0}while(u>>>0

>>0)}p=f[a+36>>2]|0;u=f[a+32>>2]|0;d=u;if((p|0)!=(u|0)){g=p-u>>2;u=0;do{p=d+(u<<2)|0;v=f[p>>2]|0;if((v|0)>(b|0))f[p>>2]=v+-1;u=u+1|0}while(u>>>0>>0)}g=f[a+48>>2]|0;u=f[a+44>>2]|0;d=u;if((g|0)!=(u|0)){v=g-u>>2;u=0;do{g=d+(u<<2)|0;p=f[g>>2]|0;if((p|0)>(b|0))f[g>>2]=p+-1;u=u+1|0}while(u>>>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[j+8>>2])-I);I=$($($($(F*F)+$(0.0))+$(H*H))+$(K*K));if(I>$(0.0)?1:(f[a+88>>2]|0)<258){M=$($($($($(F*D)+$(0.0))+$(H*E))+$(K*G))/I);N=$(D-$(F*M));F=$(E-$(H*M));H=$(G-$(K*M));O=M;P=$(L($($($(H*H)+$($(F*F)+$($(N*N)+$(0.0))))/I)))}else{O=$(0.0);P=$(0.0)}I=$(y-w);y=$(z-x);z=$(w+$(I*O));w=$(I*P);I=$(x+$(y*O));O=$(y*P);j=a+80|0;k=(f[j>>2]|0)+-1|0;l=(1<<(k&31)&f[(f[a+76>>2]|0)+(k>>>5<<2)>>2]|0)==0;f[j>>2]=k;P=$(-w);y=$(I+(l?P:w));w=$(-O);P=$(z+(l?O:w));if(((n[s>>2]=P,f[s>>2]|0)&2147483647)>>>0>2139095040)Q=-2147483648;else Q=~~+J(+(+P+.5));l=f[a+68>>2]|0;f[l>>2]=Q;if(((n[s>>2]=y,f[s>>2]|0)&2147483647)>>>0>2139095040)R=-2147483648;else R=~~+J(+(+y+.5));f[l+4>>2]=R;u=g;return}function ec(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,t=0,v=Ka,w=Ka,x=Ka,y=Ka,z=0,A=0,B=0,C=Ka,D=Ka,E=Ka,F=Ka,G=Ka,H=Ka,I=Ka,K=Ka,M=Ka,N=Ka,O=Ka,P=0,Q=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=p;r=o+2|0;break}else{q=p;r=o+-1|0;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(q<<2)>>2]|0;q=f[o+(r<<2)>>2]|0;r=f[a+52>>2]|0;o=f[r>>2]|0;c=(f[r+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)Eo(r);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=q>>>0)Eo(r);r=f[p+(q<<2)>>2]|0;q=(o|0)<(e|0);if(!(q&(r|0)<(e|0))){do if(q)t=o;else{if((e|0)>0){t=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+68>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}while(0);q=a+72|0;p=f[q>>2]|0;m=X(p,t)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;t=0;do{f[p+(t<<2)>>2]=f[d+(t+m<<2)>>2];t=t+1|0}while((t|0)<(f[q>>2]|0));u=g;return}q=f[a+72>>2]|0;t=X(q,o)|0;v=$(f[d+(t<<2)>>2]|0);w=$(f[d+(t+1<<2)>>2]|0);t=X(q,r)|0;x=$(f[d+(t<<2)>>2]|0);y=$(f[d+(t+1<<2)>>2]|0);if(!(x!=v|y!=w)){t=f[a+68>>2]|0;f[t>>2]=~~x;f[t+4>>2]=~~y;u=g;return}t=a+64|0;d=f[(f[t>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;e=a+60|0;q=f[e>>2]|0;if(!(b[q+84>>0]|0))z=f[(f[q+68>>2]|0)+(d<<2)>>2]|0;else z=d;f[i>>2]=z;z=b[q+24>>0]|0;f[h>>2]=f[i>>2];rb(q,h,z,j)|0;z=f[(f[t>>2]|0)+(o<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;o=f[e>>2]|0;if(!(b[o+84>>0]|0))A=f[(f[o+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[o+24>>0]|0;f[h>>2]=f[i>>2];rb(o,h,A,k)|0;A=f[(f[t>>2]|0)+(r<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;r=f[e>>2]|0;if(!(b[r+84>>0]|0))B=f[(f[r+68>>2]|0)+(A<<2)>>2]|0;else B=A;f[i>>2]=B;B=b[r+24>>0]|0;f[h>>2]=f[i>>2];rb(r,h,B,l)|0;C=$(n[l>>2]);D=$(n[k>>2]);E=$(C-D);C=$(n[l+4>>2]);F=$(n[k+4>>2]);G=$(C-F);C=$(n[l+8>>2]);H=$(n[k+8>>2]);I=$(C-H);C=$($(n[j>>2])-D);D=$($(n[j+4>>2])-F);F=$($(n[j+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)?1:(f[a+88>>2]|0)<258){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$(v+$(H*N));v=$(H*O);H=$(w+$(x*N));N=$(x*O);j=a+80|0;k=(f[j>>2]|0)+-1|0;l=(1<<(k&31)&f[(f[a+76>>2]|0)+(k>>>5<<2)>>2]|0)==0;f[j>>2]=k;O=$(-v);x=$(H+(l?O:v));v=$(-N);O=$(y+(l?N:v));if(((n[s>>2]=O,f[s>>2]|0)&2147483647)>>>0>2139095040)P=-2147483648;else P=~~+J(+(+O+.5));l=f[a+68>>2]|0;f[l>>2]=P;if(((n[s>>2]=x,f[s>>2]|0)&2147483647)>>>0>2139095040)Q=-2147483648;else Q=~~+J(+(+x+.5));f[l+4>>2]=Q;u=g;return}function fc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;e=u;u=u+16|0;g=e+8|0;h=e+4|0;i=e;j=a+64|0;k=f[j>>2]|0;if((f[k+28>>2]|0)==(f[k+24>>2]|0)){u=e;return}l=c+96|0;c=a+52|0;m=d+84|0;n=d+68|0;d=a+56|0;o=a+60|0;p=a+12|0;q=a+28|0;r=a+40|0;s=a+44|0;t=a+48|0;v=k;k=0;w=0;while(1){x=f[(f[v+24>>2]|0)+(w<<2)>>2]|0;if((x|0)==-1){y=v;z=k}else{A=k+1|0;B=f[(f[l>>2]|0)+(((x|0)/3|0)*12|0)+(((x|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))C=f[(f[n>>2]|0)+(B<<2)>>2]|0;else C=B;f[g>>2]=C;B=f[d>>2]|0;if(B>>>0<(f[o>>2]|0)>>>0){f[B>>2]=C;f[d>>2]=B+4}else dh(c,g);f[g>>2]=x;f[h>>2]=0;a:do if(!(f[(f[p>>2]|0)+(w>>>5<<2)>>2]&1<<(w&31)))D=x;else{B=x+1|0;E=((B>>>0)%3|0|0)==0?x+-2|0:B;if(((E|0)!=-1?(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)==0:0)?(B=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0,E=B+1|0,(B|0)!=-1):0){F=((E>>>0)%3|0|0)==0?B+-2|0:E;f[h>>2]=F;if((F|0)==-1){D=x;break}else G=F;while(1){f[g>>2]=G;F=G+1|0;E=((F>>>0)%3|0|0)==0?G+-2|0:F;if((E|0)==-1)break;if(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)break;F=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0;E=F+1|0;if((F|0)==-1)break;B=((E>>>0)%3|0|0)==0?F+-2|0:E;f[h>>2]=B;if((B|0)==-1){D=G;break a}else G=B}f[h>>2]=-1;D=G;break}f[h>>2]=-1;D=x}while(0);f[(f[q>>2]|0)+(D<<2)>>2]=k;x=f[s>>2]|0;if((x|0)==(f[t>>2]|0))dh(r,g);else{f[x>>2]=f[g>>2];f[s>>2]=x+4}x=f[j>>2]|0;B=f[g>>2]|0;b:do if(((B|0)!=-1?(E=(((B>>>0)%3|0|0)==0?2:-1)+B|0,(E|0)!=-1):0)?(F=f[(f[x+12>>2]|0)+(E<<2)>>2]|0,(F|0)!=-1):0){E=F+(((F>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=E;if((E|0)!=-1&(E|0)!=(B|0)){F=E;E=k;H=A;while(1){I=F+1|0;J=((I>>>0)%3|0|0)==0?F+-2|0:I;do if(f[(f[a>>2]|0)+(J>>>5<<2)>>2]&1<<(J&31)){I=H+1|0;K=f[(f[l>>2]|0)+(((F|0)/3|0)*12|0)+(((F|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))L=f[(f[n>>2]|0)+(K<<2)>>2]|0;else L=K;f[i>>2]=L;K=f[d>>2]|0;if(K>>>0<(f[o>>2]|0)>>>0){f[K>>2]=L;f[d>>2]=K+4}else dh(c,i);K=f[s>>2]|0;if((K|0)==(f[t>>2]|0)){dh(r,h);M=H;N=I;break}else{f[K>>2]=f[h>>2];f[s>>2]=K+4;M=H;N=I;break}}else{M=E;N=H}while(0);f[(f[q>>2]|0)+(f[h>>2]<<2)>>2]=M;O=f[j>>2]|0;J=f[h>>2]|0;if((J|0)==-1)break;I=(((J>>>0)%3|0|0)==0?2:-1)+J|0;if((I|0)==-1)break;J=f[(f[O+12>>2]|0)+(I<<2)>>2]|0;if((J|0)==-1)break;F=J+(((J>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=F;if(!((F|0)!=-1?(F|0)!=(f[g>>2]|0):0)){P=O;Q=N;break b}else{E=M;H=N}}f[h>>2]=-1;P=O;Q=N}else{P=x;Q=A}}else R=28;while(0);if((R|0)==28){R=0;f[h>>2]=-1;P=x;Q=A}y=P;z=Q}w=w+1|0;if(w>>>0>=(f[y+28>>2]|0)-(f[y+24>>2]|0)>>2>>>0)break;else{v=y;k=z}}u=e;return}function gc(a,b,c,d,e,g){a=a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=40}if((W|0)==40){W=0;f[E>>2]=V}F=F+1|0}while((F|0)<(f[t>>2]|0))}}B=B+1|0;if((B|0)>=(n|0)){W=3;break}F=f[g>>2]|0;A=f[F>>2]|0;if((f[F+4>>2]|0)-A>>2>>>0<=B>>>0){z=F;W=4;break}}if((W|0)==3){u=e;return 1}else if((W|0)==4)Eo(z);return 0}function hc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0;e=u;u=u+32|0;d=e+28|0;h=e+16|0;i=e+8|0;j=e;k=a+60|0;f[a+68>>2]=g;g=a+56|0;l=f[g>>2]|0;m=(f[l+4>>2]|0)-(f[l>>2]|0)|0;n=m>>2;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;if((m|0)<=0){u=e;return 1}m=h+4|0;o=h+8|0;p=a+104|0;q=a+108|0;r=i+4|0;s=a+100|0;t=a+8|0;v=a+16|0;w=a+32|0;x=a+12|0;y=a+20|0;a=f[l>>2]|0;if((f[l+4>>2]|0)==(a|0)){z=l;Eo(z)}else{A=a;B=0}while(1){f[j>>2]=f[A+(B<<2)>>2];f[d>>2]=f[j>>2];Mb(k,d,h);a=f[h>>2]|0;l=(a|0)>-1?a:0-a|0;C=f[m>>2]|0;D=(C|0)>-1?C:0-C|0;E=Ul(D|0,((D|0)<0)<<31>>31|0,l|0,((l|0)<0)<<31>>31|0)|0;l=f[o>>2]|0;D=(l|0)>-1;F=D?l:0-l|0;l=Ul(E|0,I|0,F|0,((F|0)<0)<<31>>31|0)|0;F=I;E=f[p>>2]|0;if((l|0)==0&(F|0)==0){G=h;H=E}else{J=((E|0)<0)<<31>>31;K=fl(E|0,J|0,a|0,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|0;if((E|0)>=(U|0))break;C=f[i+(E<<2)>>2]|0;F=E}if((U|0)>0){F=0;do{C=(f[a+(F<<2)>>2]|0)+(f[T+(F<<2)>>2]|0)|0;E=D+(F<<2)|0;f[E>>2]=C;if((C|0)<=(f[v>>2]|0)){if((C|0)<(f[x>>2]|0)){V=(f[y>>2]|0)+C|0;W=40}}else{V=C-(f[y>>2]|0)|0;W=40}if((W|0)==40){W=0;f[E>>2]=V}F=F+1|0}while((F|0)<(f[t>>2]|0))}}B=B+1|0;if((B|0)>=(n|0)){W=3;break}F=f[g>>2]|0;A=f[F>>2]|0;if((f[F+4>>2]|0)-A>>2>>>0<=B>>>0){z=F;W=4;break}}if((W|0)==3){u=e;return 1}else if((W|0)==4)Eo(z);return 0}function ic(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;b=u;u=u+32|0;c=b+4|0;d=b;e=a+16|0;g=f[e>>2]|0;if(g>>>0>340){f[e>>2]=g+-341;g=a+4|0;e=f[g>>2]|0;h=f[e>>2]|0;i=e+4|0;f[g>>2]=i;e=a+8|0;j=f[e>>2]|0;k=a+12|0;l=f[k>>2]|0;m=l;n=j;do if((j|0)==(l|0)){o=f[a>>2]|0;p=o;if(i>>>0>o>>>0){q=i;r=((q-p>>2)+1|0)/-2|0;s=i+(r<<2)|0;t=n-q|0;q=t>>2;if(!q)v=i;else{ok(s|0,i|0,t|0)|0;v=f[g>>2]|0}t=s+(q<<2)|0;f[e>>2]=t;f[g>>2]=v+(r<<2);w=t;break}t=m-p>>1;p=(t|0)==0?1:t;if(p>>>0>1073741823){t=ra(8)|0;cn(t,13392);f[t>>2]=4748;va(t|0,1128,101)}t=Yk(p<<2)|0;r=t;q=t+(p>>>2<<2)|0;s=q;x=t+(p<<2)|0;if((i|0)==(j|0)){y=o;z=s}else{o=q;q=i;p=s;do{f[o>>2]=f[q>>2];o=p+4|0;p=o;q=q+4|0}while((q|0)!=(j|0));y=f[a>>2]|0;z=p}f[a>>2]=r;f[g>>2]=s;f[e>>2]=z;f[k>>2]=x;if(!y)w=z;else{lp(y);w=f[e>>2]|0}}else w=j;while(0);f[w>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}e=a+8|0;h=f[e>>2]|0;w=a+4|0;j=h-(f[w>>2]|0)|0;y=a+12|0;z=f[y>>2]|0;k=z-(f[a>>2]|0)|0;if(j>>>0>=k>>>0){g=k>>1;k=(g|0)==0?1:g;f[c+12>>2]=0;f[c+16>>2]=a+12;if(k>>>0>1073741823){g=ra(8)|0;cn(g,13392);f[g>>2]=4748;va(g|0,1128,101)}g=Yk(k<<2)|0;f[c>>2]=g;i=g+(j>>2<<2)|0;j=c+8|0;f[j>>2]=i;m=c+4|0;f[m>>2]=i;i=c+12|0;f[i>>2]=g+(k<<2);k=Yk(4092)|0;f[d>>2]=k;cf(c,d);d=f[e>>2]|0;while(1){A=f[w>>2]|0;if((d|0)==(A|0))break;k=d+-4|0;Ze(c,k);d=k}k=A;A=f[a>>2]|0;f[a>>2]=f[c>>2];f[c>>2]=A;f[w>>2]=f[m>>2];f[m>>2]=k;m=f[e>>2]|0;f[e>>2]=f[j>>2];f[j>>2]=m;g=f[y>>2]|0;f[y>>2]=f[i>>2];f[i>>2]=g;g=m;if((g|0)!=(d|0))f[j>>2]=g+(~((g+-4-k|0)>>>2)<<2);if(A|0)lp(A);u=b;return}if((z|0)!=(h|0)){h=Yk(4092)|0;f[c>>2]=h;cf(a,c);u=b;return}h=Yk(4092)|0;f[c>>2]=h;Ze(a,c);c=f[w>>2]|0;h=f[c>>2]|0;z=c+4|0;f[w>>2]=z;c=f[e>>2]|0;A=f[y>>2]|0;k=A;g=c;do if((c|0)==(A|0)){j=f[a>>2]|0;d=j;if(z>>>0>j>>>0){m=z;i=((m-d>>2)+1|0)/-2|0;v=z+(i<<2)|0;n=g-m|0;m=n>>2;if(!m)B=z;else{ok(v|0,z|0,n|0)|0;B=f[w>>2]|0}n=v+(m<<2)|0;f[e>>2]=n;f[w>>2]=B+(i<<2);C=n;break}n=k-d>>1;d=(n|0)==0?1:n;if(d>>>0>1073741823){n=ra(8)|0;cn(n,13392);f[n>>2]=4748;va(n|0,1128,101)}n=Yk(d<<2)|0;i=n;m=n+(d>>>2<<2)|0;v=m;l=n+(d<<2)|0;if((z|0)==(c|0)){D=j;E=v}else{j=m;m=z;d=v;do{f[j>>2]=f[m>>2];j=d+4|0;d=j;m=m+4|0}while((m|0)!=(c|0));D=f[a>>2]|0;E=d}f[a>>2]=i;f[w>>2]=v;f[e>>2]=E;f[y>>2]=l;if(!D)C=E;else{lp(D);C=f[e>>2]|0}}else C=c;while(0);f[C>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}function jc(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=Yk(60)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=2012;i=c;f[a>>2]=i;return}case 2:{c=Yk(60)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=2068;i=c;f[a>>2]=i;return}case 4:{c=Yk(112)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=2124;b=c+60|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));i=c;f[a>>2]=i;return}case 3:{c=Yk(92)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=2180;b=c+60|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;f[b+24>>2]=0;f[c+88>>2]=h&65535;i=c;f[a>>2]=i;return}case 5:{c=Yk(104)|0;f[c>>2]=1536;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2236;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=Yk(124)|0;f[c>>2]=1536;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=2292;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=2348;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;Ym(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function kc(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=Yk(60)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=1648;i=c;f[a>>2]=i;return}case 2:{c=Yk(60)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=1704;i=c;f[a>>2]=i;return}case 4:{c=Yk(112)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=1760;b=c+60|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));i=c;f[a>>2]=i;return}case 3:{c=Yk(92)|0;f[c>>2]=1536;f[c+4>>2]=d;b=c+8|0;f[b>>2]=f[e>>2];f[b+4>>2]=f[e+4>>2];f[b+8>>2]=f[e+8>>2];f[b+12>>2]=f[e+12>>2];f[b+16>>2]=f[e+16>>2];f[b+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);b=c+44|0;f[b>>2]=f[g>>2];f[b+4>>2]=f[g+4>>2];f[b+8>>2]=f[g+8>>2];f[b+12>>2]=f[g+12>>2];f[c>>2]=1816;b=c+60|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;f[b+24>>2]=0;f[c+88>>2]=h&65535;i=c;f[a>>2]=i;return}case 5:{c=Yk(104)|0;f[c>>2]=1536;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1872;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=Yk(124)|0;f[c>>2]=1536;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];pi(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=1928;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=1984;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;Ym(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function lc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=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;f[o>>2]=B;f[q>>2]=x;K=E;L=B;M=x}else{K=C;L=f[o>>2]|0;M=f[q>>2]|0}if((K|0)<=-1){C=(M|0)>-1?M:0-M|0;if((L|0)<0)N=C;else N=(f[t>>2]|0)-C|0;C=(L|0)>-1?L:0-L|0;if((M|0)<0){O=N;P=C}else{O=N;P=(f[t>>2]|0)-C|0}}else{C=f[r>>2]|0;O=C+L|0;P=C+M|0}C=(O|0)==0;x=(P|0)==0;B=f[t>>2]|0;do if((P|O|0)!=0?(E=(B|0)==(P|0),D=(B|0)==(O|0),!(C&E|x&D)):0){if(C?(n=f[r>>2]|0,(n|0)<(P|0)):0){Q=0;R=(n<<1)-P|0;break}if(D?(D=f[r>>2]|0,(D|0)>(P|0)):0){Q=O;R=(D<<1)-P|0;break}if(E?(E=f[r>>2]|0,(E|0)>(O|0)):0){Q=(E<<1)-O|0;R=P;break}if(x){E=f[r>>2]|0;Q=(E|0)<(O|0)?(E<<1)-O|0:O;R=0}else{Q=O;R=P}}else{Q=B;R=B}while(0);B=A<<1;x=b+(B<<2)|0;C=c+(B<<2)|0;B=f[x>>2]|0;E=f[x+4>>2]|0;f[h>>2]=Q;f[a>>2]=R;f[i>>2]=B;f[v>>2]=E;Ac(d,l,h,i);f[C>>2]=f[d>>2];f[C+4>>2]=f[w>>2];A=A+1|0;if((A|0)>=(p|0)){S=5;break}C=f[g>>2]|0;z=f[C>>2]|0;if((f[C+4>>2]|0)-z>>2>>>0<=A>>>0){y=C;S=6;break}}if((S|0)==5){u=e;return 1}else if((S|0)==6)Eo(y);return 0}function mc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;c=u;u=u+16|0;b=c+8|0;d=c+4|0;e=c;g=a+64|0;h=f[g>>2]|0;if((f[h+28>>2]|0)==(f[h+24>>2]|0)){u=c;return}i=a+52|0;j=a+56|0;k=a+60|0;l=a+12|0;m=a+28|0;n=a+40|0;o=a+44|0;p=a+48|0;q=h;h=0;r=0;while(1){s=f[(f[q+24>>2]|0)+(r<<2)>>2]|0;if((s|0)==-1){t=q;v=h}else{w=h+1|0;f[b>>2]=h;x=f[j>>2]|0;if((x|0)==(f[k>>2]|0))dh(i,b);else{f[x>>2]=h;f[j>>2]=x+4}f[d>>2]=s;f[e>>2]=0;a:do if(!(f[(f[l>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)))y=s;else{x=s+1|0;z=((x>>>0)%3|0|0)==0?s+-2|0:x;if(((z|0)!=-1?(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)==0:0)?(x=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0,z=x+1|0,(x|0)!=-1):0){A=((z>>>0)%3|0|0)==0?x+-2|0:z;f[e>>2]=A;if((A|0)==-1){y=s;break}else B=A;while(1){f[d>>2]=B;A=B+1|0;z=((A>>>0)%3|0|0)==0?B+-2|0:A;if((z|0)==-1)break;if(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)break;A=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0;z=A+1|0;if((A|0)==-1)break;x=((z>>>0)%3|0|0)==0?A+-2|0:z;f[e>>2]=x;if((x|0)==-1){y=B;break a}else B=x}f[e>>2]=-1;y=B;break}f[e>>2]=-1;y=s}while(0);f[(f[m>>2]|0)+(y<<2)>>2]=f[b>>2];s=f[o>>2]|0;if((s|0)==(f[p>>2]|0))dh(n,d);else{f[s>>2]=f[d>>2];f[o>>2]=s+4}s=f[g>>2]|0;x=f[d>>2]|0;b:do if(((x|0)!=-1?(z=(((x>>>0)%3|0|0)==0?2:-1)+x|0,(z|0)!=-1):0)?(A=f[(f[s+12>>2]|0)+(z<<2)>>2]|0,(A|0)!=-1):0){z=A+(((A>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=z;if((z|0)!=-1&(z|0)!=(x|0)){A=w;C=z;while(1){z=C+1|0;D=((z>>>0)%3|0|0)==0?C+-2|0:z;do if(f[(f[a>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)){z=A+1|0;f[b>>2]=A;E=f[j>>2]|0;if((E|0)==(f[k>>2]|0))dh(i,b);else{f[E>>2]=A;f[j>>2]=E+4}E=f[o>>2]|0;if((E|0)==(f[p>>2]|0)){dh(n,e);F=z;break}else{f[E>>2]=f[e>>2];f[o>>2]=E+4;F=z;break}}else F=A;while(0);f[(f[m>>2]|0)+(f[e>>2]<<2)>>2]=f[b>>2];G=f[g>>2]|0;D=f[e>>2]|0;if((D|0)==-1)break;z=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((z|0)==-1)break;D=f[(f[G+12>>2]|0)+(z<<2)>>2]|0;if((D|0)==-1)break;C=D+(((D>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=C;if(!((C|0)!=-1?(C|0)!=(f[d>>2]|0):0)){H=G;I=F;break b}else A=F}f[e>>2]=-1;H=G;I=F}else{H=s;I=w}}else J=26;while(0);if((J|0)==26){J=0;f[e>>2]=-1;H=s;I=w}t=H;v=I}r=r+1|0;if(r>>>0>=(f[t+28>>2]|0)-(f[t+24>>2]|0)>>2>>>0)break;else{q=t;h=v}}u=c;return}function nc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;e=u;u=u+48|0;d=e+32|0;h=e+24|0;i=e+16|0;j=e;k=e+12|0;l=a+8|0;m=f[l>>2]|0;if((m+-2|0)>>>0<=28){f[a+72>>2]=m;n=1<>2]=n+-1;m=n+-2|0;f[a+80>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=N;P=(f[t>>2]|0)-C|0}}else{C=f[r>>2]|0;O=C+L|0;P=C+M|0}C=(O|0)==0;x=(P|0)==0;B=f[t>>2]|0;do if((P|O|0)!=0?(E=(B|0)==(P|0),D=(B|0)==(O|0),!(C&E|x&D)):0){if(C?(n=f[r>>2]|0,(n|0)<(P|0)):0){Q=0;R=(n<<1)-P|0;break}if(D?(D=f[r>>2]|0,(D|0)>(P|0)):0){Q=O;R=(D<<1)-P|0;break}if(E?(E=f[r>>2]|0,(E|0)>(O|0)):0){Q=(E<<1)-O|0;R=P;break}if(x){E=f[r>>2]|0;Q=(E|0)<(O|0)?(E<<1)-O|0:O;R=0}else{Q=O;R=P}}else{Q=B;R=B}while(0);B=A<<1;x=b+(B<<2)|0;C=c+(B<<2)|0;B=f[x>>2]|0;E=f[x+4>>2]|0;f[h>>2]=Q;f[a>>2]=R;f[i>>2]=B;f[v>>2]=E;Ac(d,l,h,i);f[C>>2]=f[d>>2];f[C+4>>2]=f[w>>2];A=A+1|0;if((A|0)>=(p|0)){S=5;break}C=f[g>>2]|0;z=f[C>>2]|0;if((f[C+4>>2]|0)-z>>2>>>0<=A>>>0){y=C;S=6;break}}if((S|0)==5){u=e;return 1}else if((S|0)==6)Eo(y);return 0}function oc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;e=u;u=u+48|0;d=e+32|0;h=e+24|0;i=e+16|0;j=e;k=e+12|0;l=a+8|0;m=f[l>>2]|0;if((m+-2|0)>>>0<=28){f[a+72>>2]=m;n=1<>2]=n+-1;m=n+-2|0;f[a+80>>2]=m;f[a+84>>2]=(m|0)/2|0}m=a+40|0;f[a+48>>2]=g;g=a+36|0;n=f[g>>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;x=(P|0)==0;B=f[t>>2]|0;do if((P|O|0)!=0?(E=(B|0)==(P|0),D=(B|0)==(O|0),!(C&E|x&D)):0){if(C?(n=f[r>>2]|0,(n|0)<(P|0)):0){Q=0;R=(n<<1)-P|0;break}if(D?(D=f[r>>2]|0,(D|0)>(P|0)):0){Q=O;R=(D<<1)-P|0;break}if(E?(E=f[r>>2]|0,(E|0)>(O|0)):0){Q=(E<<1)-O|0;R=P;break}if(x){E=f[r>>2]|0;Q=(E|0)<(O|0)?(E<<1)-O|0:O;R=0}else{Q=O;R=P}}else{Q=B;R=B}while(0);B=A<<1;x=b+(B<<2)|0;C=c+(B<<2)|0;B=f[x+4>>2]|0;f[d>>2]=f[x>>2];f[a>>2]=B;f[i>>2]=Q;f[v>>2]=R;td(h,l,i,d);f[C>>2]=f[h>>2];f[C+4>>2]=f[w>>2];A=A+1|0;if((A|0)>=(p|0)){S=5;break}C=f[g>>2]|0;z=f[C>>2]|0;if((f[C+4>>2]|0)-z>>2>>>0<=A>>>0){y=C;S=6;break}}if((S|0)==5){u=e;return 1}else if((S|0)==6)Eo(y);return 0}function pc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;e=u;u=u+48|0;d=e+32|0;h=e+24|0;i=e+16|0;j=e;k=e+12|0;l=a+8|0;m=f[l>>2]|0;if((m+-2|0)>>>0<=28){f[a+72>>2]=m;n=1<>2]=n+-1;m=n+-2|0;f[a+80>>2]=m;f[a+84>>2]=(m|0)/2|0}m=a+40|0;f[a+48>>2]=g;g=a+36|0;n=f[g>>2]|0;o=(f[n+4>>2]|0)-(f[n>>2]|0)|0;p=o>>2;f[j>>2]=0;f[j+4>>2]=0;f[j+8>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&D)):0){if(C?(n=f[r>>2]|0,(n|0)<(P|0)):0){Q=0;R=(n<<1)-P|0;break}if(D?(D=f[r>>2]|0,(D|0)>(P|0)):0){Q=O;R=(D<<1)-P|0;break}if(E?(E=f[r>>2]|0,(E|0)>(O|0)):0){Q=(E<<1)-O|0;R=P;break}if(x){E=f[r>>2]|0;Q=(E|0)<(O|0)?(E<<1)-O|0:O;R=0}else{Q=O;R=P}}else{Q=B;R=B}while(0);B=A<<1;x=b+(B<<2)|0;C=c+(B<<2)|0;B=f[x+4>>2]|0;f[d>>2]=f[x>>2];f[a>>2]=B;f[i>>2]=Q;f[v>>2]=R;td(h,l,i,d);f[C>>2]=f[h>>2];f[C+4>>2]=f[w>>2];A=A+1|0;if((A|0)>=(p|0)){S=5;break}C=f[g>>2]|0;z=f[C>>2]|0;if((f[C+4>>2]|0)-z>>2>>>0<=A>>>0){y=C;S=6;break}}if((S|0)==5){u=e;return 1}else if((S|0)==6)Eo(y);return 0}function qc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0;e=Ma[f[(f[a>>2]|0)+44>>2]&127](a)|0;if((e|0)<1){g=0;return g|0}h=(f[c+4>>2]|0)-(f[c>>2]|0)>>2;i=X(h,e)|0;vf(a,h,e);h=a+16|0;j=f[h>>2]|0;if(!(f[j+80>>2]|0)){g=0;return g|0}k=(f[f[j>>2]>>2]|0)+(f[j+48>>2]|0)|0;if(!k){g=0;return g|0}j=d+8|0;l=j;m=f[l>>2]|0;n=f[l+4>>2]|0;l=d+16|0;o=l;p=f[o>>2]|0;q=f[o+4>>2]|0;if(!((n|0)>(q|0)|(n|0)==(q|0)&m>>>0>p>>>0)){g=0;return g|0}o=f[d>>2]|0;r=b[o+p>>0]|0;s=Ul(p|0,q|0,1,0)|0;t=I;u=l;f[u>>2]=s;f[u+4>>2]=t;a:do if(!(r<<24>>24)){if(!((n|0)>(t|0)|(n|0)==(t|0)&m>>>0>s>>>0)){g=0;return g|0}u=b[o+s>>0]|0;v=Ul(p|0,q|0,2,0)|0;w=l;f[w>>2]=v;f[w+4>>2]=I;w=u&255;v=(w|0)==(Zj(5)|0);x=f[(f[h>>2]|0)+64>>2]|0;y=(f[x+4>>2]|0)-(f[x>>2]|0)|0;if(v){v=i<<2;if(y>>>0>>0){g=0;return g|0}x=j;z=f[x>>2]|0;A=f[x+4>>2]|0;x=l;B=f[x>>2]|0;C=Ul(B|0,f[x+4>>2]|0,v|0,0)|0;x=I;if((A|0)<(x|0)|(A|0)==(x|0)&z>>>0>>0){g=0;return g|0}else{Ff(k|0,(f[d>>2]|0)+B|0,v|0)|0;B=l;C=Ul(f[B>>2]|0,f[B+4>>2]|0,v|0,0)|0;v=l;f[v>>2]=C;f[v+4>>2]=I;D=20;break}}v=X(w,i)|0;if(y>>>0>>0){g=0;return g|0}y=j;C=f[y>>2]|0;B=f[y+4>>2]|0;y=l;z=f[y>>2]|0;x=f[y+4>>2]|0;y=Wl(C|0,B|0,z|0,x|0)|0;A=I;if((A|0)<0|(A|0)==0&y>>>0>>0){g=0;return g|0}if(!i)D=21;else{v=u&255;u=z;z=x;x=B;B=C;C=0;while(1){y=Ul(u|0,z|0,v|0,0)|0;A=I;if((x|0)<(A|0)|(x|0)==(A|0)&B>>>0>>0){E=u;F=z}else{Ff(k+(C<<2)|0,(f[d>>2]|0)+u|0,w|0)|0;y=l;A=Ul(f[y>>2]|0,f[y+4>>2]|0,v|0,0)|0;y=I;G=l;f[G>>2]=A;f[G+4>>2]=y;E=A;F=y}y=C+1|0;if((y|0)==(i|0)){D=20;break a}A=j;u=E;z=F;x=f[A+4>>2]|0;B=f[A>>2]|0;C=y}}}else if(yh(i,e,d,k)|0)D=20;else{g=0;return g|0}while(0);do if((D|0)==20)if(!i)D=21;else{F=a+20|0;E=f[F>>2]|0;if(E|0?Ma[f[(f[E>>2]|0)+32>>2]&127](E)|0:0){H=F;J=1;break}sk(k,i,k);H=F;J=1}while(0);if((D|0)==21){H=a+20|0;J=0}a=f[H>>2]|0;if(a|0){if(!(Na[f[(f[a>>2]|0)+40>>2]&127](a,d)|0)){g=0;return g|0}if(J?(J=f[H>>2]|0,!(Pa[f[(f[J>>2]|0)+44>>2]&31](J,k,k,i,e,f[c>>2]|0)|0)):0){g=0;return g|0}}g=1;return g|0}function rc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)lp(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;cn(e,13392);f[e>>2]=4748;va(e|0,1128,101)}e=Yk(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)lp(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=g;l=d;m=j;n=g}a:while(1){g=k;j=l;d=n;b:while(1){o=j;while(1){e=f[o+4>>2]|0;if(!i)if(e>>>0>>0)p=e;else p=(e>>>0)%(c>>>0)|0;else p=e&h;if((p|0)==(m|0))break;q=(f[a>>2]|0)+(p<<2)|0;if(!(f[q>>2]|0))break b;e=f[o>>2]|0;c:do if(!e)r=o;else{s=o+8|0;t=b[s+11>>0]|0;u=t<<24>>24<0;v=t&255;t=u?f[o+12>>2]|0:v;w=(t|0)==0;if(u){u=e;x=o;while(1){y=u+8|0;z=b[y+11>>0]|0;A=z<<24>>24<0;if((t|0)!=((A?f[u+12>>2]|0:z&255)|0)){r=x;break c}if(!w?dj(f[s>>2]|0,A?f[y>>2]|0:y,t)|0:0){r=x;break c}y=f[u>>2]|0;if(!y){r=u;break c}else{A=u;u=y;x=A}}}if(w){x=e;u=o;while(1){A=b[x+8+11>>0]|0;if((A<<24>>24<0?f[x+12>>2]|0:A&255)|0){r=u;break c}A=f[x>>2]|0;if(!A){r=x;break c}else{y=x;x=A;u=y}}}u=e;x=o;while(1){w=u+8|0;y=b[w+11>>0]|0;A=y<<24>>24<0;if((t|0)!=((A?f[u+12>>2]|0:y&255)|0)){r=x;break c}y=A?f[w>>2]|0:w;if((f[s>>2]&255)<<24>>24==(b[y>>0]|0)){B=v;C=s;D=y}else{r=x;break c}while(1){B=B+-1|0;C=C+1|0;if(!B)break;D=D+1|0;if((b[C>>0]|0)!=(b[D>>0]|0)){r=x;break c}}y=f[u>>2]|0;if(!y){r=u;break}else{w=u;u=y;x=w}}}while(0);f[d>>2]=f[r>>2];f[r>>2]=f[f[(f[a>>2]|0)+(p<<2)>>2]>>2];f[f[(f[a>>2]|0)+(p<<2)>>2]>>2]=o;e=f[g>>2]|0;if(!e){E=43;break a}else o=e}j=f[o>>2]|0;if(!j){E=43;break a}else{g=o;d=o}}f[q>>2]=d;l=f[o>>2]|0;if(!l){E=43;break}else{k=o;m=p;n=o}}if((E|0)==43)return}function sc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;d=u;u=u+16|0;e=d+12|0;g=d+4|0;h=d+8|0;i=d;j=a+8+(b*12|0)|0;k=f[j>>2]|0;l=a+8+(b*12|0)+4|0;m=f[l>>2]|0;if((m|0)!=(k|0))f[l>>2]=m+(~((m+-4-k|0)>>>2)<<2);k=f[c>>2]|0;m=a+4|0;f[g>>2]=(k|0)==-1?-1:(k>>>0)/3|0;n=a+56|0;o=a+8+(b*12|0)+8|0;p=k;q=0;r=k;while(1){k=(q|0)==1;if(k){s=(r|0)==-1;do if(!s)if(!((r>>>0)%3|0)){t=r+2|0;break}else{t=r+-1|0;break}else t=-1;while(0);f[h>>2]=t;f[e>>2]=f[h>>2];if((kf(a,e)|0)==-1){v=r;break}w=r+1|0;if(s){x=12;break}y=((w>>>0)%3|0|0)==0?r+-2|0:w;f[c>>2]=y;w=y+1|0;if((y|0)==-1){z=r;x=16;break}A=((w>>>0)%3|0|0)==0?y+-2|0:w;if((A|0)==-1){z=r;x=16;break}w=f[(f[(f[m>>2]|0)+12>>2]|0)+(A<<2)>>2]|0;A=w+1|0;if((w|0)==-1){z=r;x=16;break}y=((A>>>0)%3|0|0)==0?w+-2|0:A;f[c>>2]=y;if((y|0)==-1){v=r;break}else{B=0;C=r;D=y;x=18}}else{E=f[g>>2]|0;F=p;G=0;H=r}while(1){if((x|0)==18){x=0;y=(D>>>0)/3|0;f[g>>2]=y;E=y;F=D;G=B;H=C}y=(f[n>>2]|0)+(E>>>5<<2)|0;A=1<<(E&31);w=f[y>>2]|0;if(A&w|0){I=F;J=G;K=H;break}f[y>>2]=w|A;A=f[l>>2]|0;if((A|0)==(f[o>>2]|0))dh(j,g);else{f[A>>2]=f[g>>2];f[l>>2]=A+4}A=G+1|0;if((G|0)>0){do if(!(A&1)){w=k?F:H;if((F|0)!=-1)if(!((F>>>0)%3|0)){L=F+2|0;M=w;break}else{L=F+-1|0;M=w;break}else{L=-1;M=w}}else{w=F+1|0;if((F|0)==-1){L=-1;M=H}else{L=((w>>>0)%3|0|0)==0?F+-2|0:w;M=H}}while(0);f[c>>2]=L;N=L;O=M}else{N=F;O=H}f[i>>2]=N;f[e>>2]=f[i>>2];D=kf(a,e)|0;f[c>>2]=D;if((D|0)==-1){I=-1;J=A;K=O;break}else{B=A;C=O;x=18}}if(!((J&1|0)==0|k^1)){s=f[l>>2]|0;w=f[s+-4>>2]|0;y=(f[n>>2]|0)+(w>>>5<<2)|0;f[y>>2]=f[y>>2]&~(1<<(w&31));f[l>>2]=s+-4}q=q+1|0;if((q|0)>=2){v=K;break}else{p=I;r=K}}if((x|0)==12){f[c>>2]=-1;z=-1;x=16}if((x|0)==16){f[c>>2]=-1;v=z}f[a+44+(b<<2)>>2]=v;v=f[l>>2]|0;l=f[j>>2]|0;j=l;if((v|0)==(l|0)){u=d;return}b=f[n>>2]|0;n=v-l>>2;l=0;do{v=f[j+(l<<2)>>2]|0;a=b+(v>>>5<<2)|0;f[a>>2]=f[a>>2]&~(1<<(v&31));l=l+1|0}while(l>>>0>>0);u=d;return}function tc(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;i=u;u=u+32|0;j=i+12|0;k=i;f[c+40>>2]=e;e=c+32|0;f[e>>2]=g;f[c+4>>2]=h;ac(a,g,j);if(f[a>>2]|0){u=i;return}g=a+4|0;h=g+11|0;if((b[h>>0]|0)<0)lp(f[g>>2]|0);l=b[j+7>>0]|0;if((l&255|0)!=(Ma[f[(f[c>>2]|0)+8>>2]&127](c)|0)){m=Yk(64)|0;f[k>>2]=m;f[k+8>>2]=-2147483584;f[k+4>>2]=50;n=m;o=13026;p=n+50|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[m+50>>0]=0;f[a>>2]=-1;zh(g,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);u=i;return}m=b[j+5>>0]|0;b[c+36>>0]=m;q=b[j+6>>0]|0;b[c+37>>0]=q;if((m+-1&255)>1){r=Yk(32)|0;f[k>>2]=r;f[k+8>>2]=-2147483616;f[k+4>>2]=22;n=r;o=13077;p=n+22|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[r+22>>0]=0;f[a>>2]=-5;zh(g,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);u=i;return}r=q&255;if(m<<24>>24==2&r>>>0>(l<<24>>24==0?3:2)>>>0){l=Yk(32)|0;f[k>>2]=l;f[k+8>>2]=-2147483616;f[k+4>>2]=22;n=l;o=13100;p=n+22|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[l+22>>0]=0;f[a>>2]=-5;zh(g,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);u=i;return}l=(r|(m&255)<<8)&65535;d[(f[e>>2]|0)+38>>1]=l;if((l&65535)>258?(d[j+10>>1]|0)<0:0){Md(a,c);if(f[a>>2]|0){u=i;return}if((b[h>>0]|0)<0)lp(f[g>>2]|0)}if(!(Ma[f[(f[c>>2]|0)+12>>2]&127](c)|0)){h=Yk(48)|0;f[k>>2]=h;f[k+8>>2]=-2147483600;f[k+4>>2]=33;n=h;o=13123;p=n+33|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[h+33>>0]=0;f[a>>2]=-1;zh(g,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);u=i;return}if(!(Ma[f[(f[c>>2]|0)+20>>2]&127](c)|0)){h=Yk(32)|0;f[k>>2]=h;f[k+8>>2]=-2147483616;f[k+4>>2]=31;n=h;o=13157;p=n+31|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[h+31>>0]=0;f[a>>2]=-1;zh(g,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);u=i;return}if(Ma[f[(f[c>>2]|0)+24>>2]&127](c)|0){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=i;return}c=Yk(48)|0;f[k>>2]=c;f[k+8>>2]=-2147483600;f[k+4>>2]=34;n=c;o=13189;p=n+34|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[c+34>>0]=0;f[a>>2]=-1;zh(g,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);u=i;return}function uc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=u;u=u+48|0;d=c+32|0;e=c+28|0;g=c+16|0;h=c;i=a+16|0;j=f[i>>2]|0;if(j|0){k=f[b>>2]|0;l=i;m=j;a:while(1){j=m;while(1){if((f[j+16>>2]|0)>=(k|0))break;n=f[j+4>>2]|0;if(!n){o=l;break a}else j=n}m=f[j>>2]|0;if(!m){o=j;break}else l=j}if((o|0)!=(i|0)?(k|0)>=(f[o+16>>2]|0):0){p=o;q=p+20|0;u=c;return q|0}}On(g);f[h>>2]=f[b>>2];b=h+4|0;f[h+8>>2]=0;o=h+12|0;f[o>>2]=0;k=h+8|0;f[b>>2]=k;l=f[g>>2]|0;m=g+4|0;if((l|0)!=(m|0)){n=k;r=l;while(1){l=r+16|0;f[e>>2]=n;f[d>>2]=f[e>>2];If(b,d,l,l)|0;l=f[r+4>>2]|0;if(!l){s=r+8|0;t=f[s>>2]|0;if((f[t>>2]|0)==(r|0))v=t;else{t=s;do{s=f[t>>2]|0;t=s+8|0;w=f[t>>2]|0}while((f[w>>2]|0)!=(s|0));v=w}}else{t=l;while(1){j=f[t>>2]|0;if(!j)break;else t=j}v=t}if((v|0)==(m|0))break;else r=v}}v=a+12|0;r=f[i>>2]|0;do if(r){d=f[h>>2]|0;e=r;n=a+16|0;while(1){l=f[e+16>>2]|0;if((d|0)<(l|0)){j=f[e>>2]|0;if(!j){x=23;break}else{y=j;z=e}}else{if((l|0)>=(d|0)){x=27;break}A=e+4|0;l=f[A>>2]|0;if(!l){x=26;break}else{y=l;z=A}}e=y;n=z}if((x|0)==23){B=e;C=e;break}else if((x|0)==26){B=e;C=A;break}else if((x|0)==27){B=e;C=n;break}}else{B=i;C=i}while(0);i=f[C>>2]|0;if(!i){x=Yk(32)|0;f[x+16>>2]=f[h>>2];A=x+20|0;f[A>>2]=f[b>>2];z=x+24|0;y=f[h+8>>2]|0;f[z>>2]=y;r=f[o>>2]|0;f[x+28>>2]=r;if(!r)f[A>>2]=z;else{f[y+8>>2]=z;f[b>>2]=k;f[k>>2]=0;f[o>>2]=0}f[x>>2]=0;f[x+4>>2]=0;f[x+8>>2]=B;f[C>>2]=x;B=f[f[v>>2]>>2]|0;if(!B)D=x;else{f[v>>2]=B;D=f[C>>2]|0}wd(f[a+16>>2]|0,D);D=a+20|0;f[D>>2]=(f[D>>2]|0)+1;E=x}else E=i;Qh(h+4|0,f[k>>2]|0);Qh(g,f[m>>2]|0);p=E;q=p+20|0;u=c;return q|0}function vc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=g+(e+4)|0;l=c;m=d-e|0}else{k=g;l=i;m=i}switch(m|0){case 3:{n=h[k+2>>0]<<16^l;o=6;break}case 2:{n=l;o=6;break}case 1:{p=l;o=7;break}default:q=l}if((o|0)==6){p=h[k+1>>0]<<8^n;o=7}if((o|0)==7)q=X(h[k>>0]^p,1540483477)|0;p=X(q>>>13^q,1540483477)|0;q=p>>>15^p;p=f[a+4>>2]|0;if(!p){r=0;return r|0}k=p+-1|0;n=(k&p|0)==0;if(!n)if(q>>>0

>>0)s=q;else s=(q>>>0)%(p>>>0)|0;else s=q&k;l=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!l){r=0;return r|0}a=f[l>>2]|0;if(!a){r=0;return r|0}l=(i|0)==0;if(n){n=a;a:while(1){m=f[n+4>>2]|0;e=(q|0)==(m|0);if(!(e|(m&k|0)==(s|0))){r=0;o=41;break}do if(e?(m=n+8|0,d=b[m+11>>0]|0,c=d<<24>>24<0,j=d&255,((c?f[n+12>>2]|0:j)|0)==(i|0)):0){d=f[m>>2]|0;t=c?d:m;if(c){if(l){r=n;o=41;break a}if(!(dj(t,g,i)|0)){r=n;o=41;break a}else break}if(l){r=n;o=41;break a}if((d&255)<<24>>24==(b[g>>0]|0)){d=j;j=m;m=g;do{d=d+-1|0;j=j+1|0;if(!d){r=n;o=41;break a}m=m+1|0}while((b[j>>0]|0)==(b[m>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=41;break}}if((o|0)==41)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;n=(q|0)==(a|0);if(!n){if(a>>>0

>>0)v=a;else v=(a>>>0)%(p>>>0)|0;if((v|0)!=(s|0)){r=0;o=41;break}if(n)o=33}else o=33;do if((o|0)==33?(o=0,n=u+8|0,a=b[n+11>>0]|0,k=a<<24>>24<0,e=a&255,((k?f[u+12>>2]|0:e)|0)==(i|0)):0){a=f[n>>2]|0;m=k?a:n;if(k){if(l){r=u;o=41;break b}if(!(dj(m,g,i)|0)){r=u;o=41;break b}else break}if(l){r=u;o=41;break b}if((a&255)<<24>>24==(b[g>>0]|0)){a=e;e=n;n=g;do{a=a+-1|0;e=e+1|0;if(!a){r=u;o=41;break b}n=n+1|0}while((b[e>>0]|0)==(b[n>>0]|0))}}while(0);u=f[u>>2]|0;if(!u){r=0;o=41;break}}if((o|0)==41)return r|0;return 0} +function Xa(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r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h=i>>>1&2;k=i>>>h;i=k>>>1&1;s=f[16768+((j|n|l|h|i)+(k>>>i)<<2)>>2]|0;i=(f[s+4>>2]&-8)-d|0;k=f[s+16+(((f[s+16>>2]|0)==0&1)<<2)>>2]|0;if(!k){t=i;v=s}else{h=k;k=i;i=s;while(1){s=(f[h+4>>2]&-8)-d|0;l=s>>>0>>0;n=l?s:k;s=l?h:i;h=f[h+16+(((f[h+16>>2]|0)==0&1)<<2)>>2]|0;if(!h){t=n;v=s;break}else{k=n;i=s}}}i=v+d|0;if(v>>>0>>0){k=f[v+24>>2]|0;h=f[v+12>>2]|0;do if((h|0)==(v|0)){s=v+20|0;n=f[s>>2]|0;if(!n){l=v+16|0;j=f[l>>2]|0;if(!j){w=0;break}else{x=j;y=l}}else{x=n;y=s}while(1){s=x+20|0;n=f[s>>2]|0;if(n|0){x=n;y=s;continue}s=x+16|0;n=f[s>>2]|0;if(!n)break;else{x=n;y=s}}f[y>>2]=0;w=x}else{s=f[v+8>>2]|0;f[s+12>>2]=h;f[h+8>>2]=s;w=h}while(0);do if(k|0){h=f[v+28>>2]|0;s=16768+(h<<2)|0;if((v|0)==(f[s>>2]|0)){f[s>>2]=w;if(!w){f[4117]=e&~(1<>2]|0)!=(v|0)&1)<<2)>>2]=w;if(!w)break}f[w+24>>2]=k;h=f[v+16>>2]|0;if(h|0){f[w+16>>2]=h;f[h+24>>2]=w}h=f[v+20>>2]|0;if(h|0){f[w+20>>2]=h;f[h+24>>2]=w}}while(0);if(t>>>0<16){k=t+d|0;f[v+4>>2]=k|3;e=v+k+4|0;f[e>>2]=f[e>>2]|1}else{f[v+4>>2]=d|3;f[i+4>>2]=t|1;f[i+t>>2]=t;if(m|0){e=f[4121]|0;k=m>>>3;h=16504+(k<<1<<2)|0;s=1<>2]|0}f[z>>2]=e;f[A+12>>2]=e;f[e+8>>2]=A;f[e+12>>2]=h}f[4118]=t;f[4121]=i}o=v+8|0;u=b;return o|0}else B=d}else B=d}else B=d}else if(a>>>0<=4294967231){h=a+11|0;e=h&-8;s=f[4117]|0;if(s){k=0-e|0;n=h>>>8;if(n)if(e>>>0>16777215)C=31;else{h=(n+1048320|0)>>>16&8;l=n<>>16&4;j=l<>>16&2;D=14-(n|h|l)+(j<>>15)|0;C=e>>>(D+7|0)&1|D<<1}else C=0;D=f[16768+(C<<2)>>2]|0;a:do if(!D){E=k;F=0;G=0;H=57}else{l=k;j=0;h=e<<((C|0)==31?0:25-(C>>>1)|0);n=D;I=0;while(1){J=(f[n+4>>2]&-8)-e|0;if(J>>>0>>0)if(!J){K=0;L=n;M=n;H=61;break a}else{N=J;O=n}else{N=l;O=I}J=f[n+20>>2]|0;n=f[n+16+(h>>>31<<2)>>2]|0;P=(J|0)==0|(J|0)==(n|0)?j:J;J=(n|0)==0;if(J){E=N;F=P;G=O;H=57;break}else{l=N;j=P;h=h<<((J^1)&1);I=O}}}while(0);if((H|0)==57){if((F|0)==0&(G|0)==0){D=2<>>12&16;d=D>>>k;D=d>>>5&8;i=d>>>D;d=i>>>2&4;g=i>>>d;i=g>>>1&2;m=g>>>i;g=m>>>1&1;Q=f[16768+((D|k|d|i|g)+(m>>>g)<<2)>>2]|0;R=0}else{Q=F;R=G}if(!Q){S=E;T=R}else{K=E;L=Q;M=R;H=61}}if((H|0)==61)while(1){H=0;g=(f[L+4>>2]&-8)-e|0;m=g>>>0>>0;i=m?g:K;g=m?L:M;L=f[L+16+(((f[L+16>>2]|0)==0&1)<<2)>>2]|0;if(!L){S=i;T=g;break}else{K=i;M=g;H=61}}if((T|0)!=0?S>>>0<((f[4118]|0)-e|0)>>>0:0){g=T+e|0;if(T>>>0>=g>>>0){o=0;u=b;return o|0}i=f[T+24>>2]|0;m=f[T+12>>2]|0;do if((m|0)==(T|0)){d=T+20|0;k=f[d>>2]|0;if(!k){D=T+16|0;I=f[D>>2]|0;if(!I){U=0;break}else{V=I;W=D}}else{V=k;W=d}while(1){d=V+20|0;k=f[d>>2]|0;if(k|0){V=k;W=d;continue}d=V+16|0;k=f[d>>2]|0;if(!k)break;else{V=k;W=d}}f[W>>2]=0;U=V}else{d=f[T+8>>2]|0;f[d+12>>2]=m;f[m+8>>2]=d;U=m}while(0);do if(i){m=f[T+28>>2]|0;d=16768+(m<<2)|0;if((T|0)==(f[d>>2]|0)){f[d>>2]=U;if(!U){d=s&~(1<>2]|0)!=(T|0)&1)<<2)>>2]=U;if(!U){X=s;break}}f[U+24>>2]=i;d=f[T+16>>2]|0;if(d|0){f[U+16>>2]=d;f[d+24>>2]=U}d=f[T+20>>2]|0;if(d){f[U+20>>2]=d;f[d+24>>2]=U;X=s}else X=s}else X=s;while(0);do if(S>>>0>=16){f[T+4>>2]=e|3;f[g+4>>2]=S|1;f[g+S>>2]=S;s=S>>>3;if(S>>>0<256){i=16504+(s<<1<<2)|0;d=f[4116]|0;m=1<>2]|0}f[Y>>2]=g;f[Z+12>>2]=g;f[g+8>>2]=Z;f[g+12>>2]=i;break}i=S>>>8;if(i)if(S>>>0>16777215)_=31;else{m=(i+1048320|0)>>>16&8;d=i<>>16&4;s=d<>>16&2;k=14-(i|m|d)+(s<>>15)|0;_=S>>>(k+7|0)&1|k<<1}else _=0;k=16768+(_<<2)|0;f[g+28>>2]=_;d=g+16|0;f[d+4>>2]=0;f[d>>2]=0;d=1<<_;if(!(X&d)){f[4117]=X|d;f[k>>2]=g;f[g+24>>2]=k;f[g+12>>2]=g;f[g+8>>2]=g;break}d=S<<((_|0)==31?0:25-(_>>>1)|0);s=f[k>>2]|0;while(1){if((f[s+4>>2]&-8|0)==(S|0)){H=97;break}$=s+16+(d>>>31<<2)|0;k=f[$>>2]|0;if(!k){H=96;break}else{d=d<<1;s=k}}if((H|0)==96){f[$>>2]=g;f[g+24>>2]=s;f[g+12>>2]=g;f[g+8>>2]=g;break}else if((H|0)==97){d=s+8|0;k=f[d>>2]|0;f[k+12>>2]=g;f[d>>2]=g;f[g+8>>2]=k;f[g+12>>2]=s;f[g+24>>2]=0;break}}else{k=S+e|0;f[T+4>>2]=k|3;d=T+k+4|0;f[d>>2]=f[d>>2]|1}while(0);o=T+8|0;u=b;return o|0}else B=e}else B=e}else B=-1;while(0);T=f[4118]|0;if(T>>>0>=B>>>0){S=T-B|0;$=f[4121]|0;if(S>>>0>15){_=$+B|0;f[4121]=_;f[4118]=S;f[_+4>>2]=S|1;f[_+S>>2]=S;f[$+4>>2]=B|3}else{f[4118]=0;f[4121]=0;f[$+4>>2]=T|3;S=$+T+4|0;f[S>>2]=f[S>>2]|1}o=$+8|0;u=b;return o|0}$=f[4119]|0;if($>>>0>B>>>0){S=$-B|0;f[4119]=S;T=f[4122]|0;_=T+B|0;f[4122]=_;f[_+4>>2]=S|1;f[T+4>>2]=B|3;o=T+8|0;u=b;return o|0}if(!(f[4234]|0)){f[4236]=4096;f[4235]=4096;f[4237]=-1;f[4238]=-1;f[4239]=0;f[4227]=0;T=c&-16^1431655768;f[c>>2]=T;f[4234]=T;aa=4096}else aa=f[4236]|0;T=B+48|0;c=B+47|0;S=aa+c|0;_=0-aa|0;aa=S&_;if(aa>>>0<=B>>>0){o=0;u=b;return o|0}X=f[4226]|0;if(X|0?(Z=f[4224]|0,Y=Z+aa|0,Y>>>0<=Z>>>0|Y>>>0>X>>>0):0){o=0;u=b;return o|0}b:do if(!(f[4227]&4)){X=f[4122]|0;c:do if(X){Y=16912;while(1){Z=f[Y>>2]|0;if(Z>>>0<=X>>>0?(ba=Y+4|0,(Z+(f[ba>>2]|0)|0)>>>0>X>>>0):0)break;Z=f[Y+8>>2]|0;if(!Z){H=118;break c}else Y=Z}s=S-$&_;if(s>>>0<2147483647){Z=Kj(s|0)|0;if((Z|0)==((f[Y>>2]|0)+(f[ba>>2]|0)|0))if((Z|0)==(-1|0))ca=s;else{da=Z;ea=s;H=135;break b}else{fa=Z;ga=s;H=126}}else ca=0}else H=118;while(0);do if((H|0)==118){X=Kj(0)|0;if((X|0)!=(-1|0)?(e=X,s=f[4235]|0,Z=s+-1|0,U=((Z&e|0)==0?0:(Z+e&0-s)-e|0)+aa|0,e=f[4224]|0,s=U+e|0,U>>>0>B>>>0&U>>>0<2147483647):0){Z=f[4226]|0;if(Z|0?s>>>0<=e>>>0|s>>>0>Z>>>0:0){ca=0;break}Z=Kj(U|0)|0;if((Z|0)==(X|0)){da=X;ea=U;H=135;break b}else{fa=Z;ga=U;H=126}}else ca=0}while(0);do if((H|0)==126){U=0-ga|0;if(!(T>>>0>ga>>>0&(ga>>>0<2147483647&(fa|0)!=(-1|0))))if((fa|0)==(-1|0)){ca=0;break}else{da=fa;ea=ga;H=135;break b}Z=f[4236]|0;X=c-ga+Z&0-Z;if(X>>>0>=2147483647){da=fa;ea=ga;H=135;break b}if((Kj(X|0)|0)==(-1|0)){Kj(U|0)|0;ca=0;break}else{da=fa;ea=X+ga|0;H=135;break b}}while(0);f[4227]=f[4227]|4;ha=ca;H=133}else{ha=0;H=133}while(0);if(((H|0)==133?aa>>>0<2147483647:0)?(ca=Kj(aa|0)|0,aa=Kj(0)|0,ga=aa-ca|0,fa=ga>>>0>(B+40|0)>>>0,!((ca|0)==(-1|0)|fa^1|ca>>>0>>0&((ca|0)!=(-1|0)&(aa|0)!=(-1|0))^1)):0){da=ca;ea=fa?ga:ha;H=135}if((H|0)==135){ha=(f[4224]|0)+ea|0;f[4224]=ha;if(ha>>>0>(f[4225]|0)>>>0)f[4225]=ha;ha=f[4122]|0;do if(ha){ga=16912;while(1){ia=f[ga>>2]|0;ja=ga+4|0;ka=f[ja>>2]|0;if((da|0)==(ia+ka|0)){H=145;break}fa=f[ga+8>>2]|0;if(!fa)break;else ga=fa}if(((H|0)==145?(f[ga+12>>2]&8|0)==0:0)?ha>>>0>>0&ha>>>0>=ia>>>0:0){f[ja>>2]=ka+ea;fa=ha+8|0;ca=(fa&7|0)==0?0:0-fa&7;fa=ha+ca|0;aa=(f[4119]|0)+(ea-ca)|0;f[4122]=fa;f[4119]=aa;f[fa+4>>2]=aa|1;f[fa+aa+4>>2]=40;f[4123]=f[4238];break}if(da>>>0<(f[4120]|0)>>>0)f[4120]=da;aa=da+ea|0;fa=16912;while(1){if((f[fa>>2]|0)==(aa|0)){H=153;break}ca=f[fa+8>>2]|0;if(!ca)break;else fa=ca}if((H|0)==153?(f[fa+12>>2]&8|0)==0:0){f[fa>>2]=da;ga=fa+4|0;f[ga>>2]=(f[ga>>2]|0)+ea;ga=da+8|0;ca=da+((ga&7|0)==0?0:0-ga&7)|0;ga=aa+8|0;c=aa+((ga&7|0)==0?0:0-ga&7)|0;ga=ca+B|0;T=c-ca-B|0;f[ca+4>>2]=B|3;do if((c|0)!=(ha|0)){if((c|0)==(f[4121]|0)){ba=(f[4118]|0)+T|0;f[4118]=ba;f[4121]=ga;f[ga+4>>2]=ba|1;f[ga+ba>>2]=ba;break}ba=f[c+4>>2]|0;if((ba&3|0)==1){_=ba&-8;$=ba>>>3;d:do if(ba>>>0<256){S=f[c+8>>2]|0;X=f[c+12>>2]|0;if((X|0)==(S|0)){f[4116]=f[4116]&~(1<<$);break}else{f[S+12>>2]=X;f[X+8>>2]=S;break}}else{S=f[c+24>>2]|0;X=f[c+12>>2]|0;do if((X|0)==(c|0)){U=c+16|0;Z=U+4|0;s=f[Z>>2]|0;if(!s){e=f[U>>2]|0;if(!e){la=0;break}else{ma=e;na=U}}else{ma=s;na=Z}while(1){Z=ma+20|0;s=f[Z>>2]|0;if(s|0){ma=s;na=Z;continue}Z=ma+16|0;s=f[Z>>2]|0;if(!s)break;else{ma=s;na=Z}}f[na>>2]=0;la=ma}else{Z=f[c+8>>2]|0;f[Z+12>>2]=X;f[X+8>>2]=Z;la=X}while(0);if(!S)break;X=f[c+28>>2]|0;Z=16768+(X<<2)|0;do if((c|0)!=(f[Z>>2]|0)){f[S+16+(((f[S+16>>2]|0)!=(c|0)&1)<<2)>>2]=la;if(!la)break d}else{f[Z>>2]=la;if(la|0)break;f[4117]=f[4117]&~(1<>2]=S;X=c+16|0;Z=f[X>>2]|0;if(Z|0){f[la+16>>2]=Z;f[Z+24>>2]=la}Z=f[X+4>>2]|0;if(!Z)break;f[la+20>>2]=Z;f[Z+24>>2]=la}while(0);oa=c+_|0;pa=_+T|0}else{oa=c;pa=T}$=oa+4|0;f[$>>2]=f[$>>2]&-2;f[ga+4>>2]=pa|1;f[ga+pa>>2]=pa;$=pa>>>3;if(pa>>>0<256){ba=16504+($<<1<<2)|0;Y=f[4116]|0;Z=1<<$;if(!(Y&Z)){f[4116]=Y|Z;qa=ba+8|0;ra=ba}else{Z=ba+8|0;qa=Z;ra=f[Z>>2]|0}f[qa>>2]=ga;f[ra+12>>2]=ga;f[ga+8>>2]=ra;f[ga+12>>2]=ba;break}ba=pa>>>8;do if(!ba)sa=0;else{if(pa>>>0>16777215){sa=31;break}Z=(ba+1048320|0)>>>16&8;Y=ba<>>16&4;X=Y<<$;Y=(X+245760|0)>>>16&2;s=14-($|Z|Y)+(X<>>15)|0;sa=pa>>>(s+7|0)&1|s<<1}while(0);ba=16768+(sa<<2)|0;f[ga+28>>2]=sa;_=ga+16|0;f[_+4>>2]=0;f[_>>2]=0;_=f[4117]|0;s=1<>2]=ga;f[ga+24>>2]=ba;f[ga+12>>2]=ga;f[ga+8>>2]=ga;break}s=pa<<((sa|0)==31?0:25-(sa>>>1)|0);_=f[ba>>2]|0;while(1){if((f[_+4>>2]&-8|0)==(pa|0)){H=194;break}ta=_+16+(s>>>31<<2)|0;ba=f[ta>>2]|0;if(!ba){H=193;break}else{s=s<<1;_=ba}}if((H|0)==193){f[ta>>2]=ga;f[ga+24>>2]=_;f[ga+12>>2]=ga;f[ga+8>>2]=ga;break}else if((H|0)==194){s=_+8|0;ba=f[s>>2]|0;f[ba+12>>2]=ga;f[s>>2]=ga;f[ga+8>>2]=ba;f[ga+12>>2]=_;f[ga+24>>2]=0;break}}else{ba=(f[4119]|0)+T|0;f[4119]=ba;f[4122]=ga;f[ga+4>>2]=ba|1}while(0);o=ca+8|0;u=b;return o|0}ga=16912;while(1){T=f[ga>>2]|0;if(T>>>0<=ha>>>0?(ua=T+(f[ga+4>>2]|0)|0,ua>>>0>ha>>>0):0)break;ga=f[ga+8>>2]|0}ga=ua+-47|0;ca=ga+8|0;T=ga+((ca&7|0)==0?0:0-ca&7)|0;ca=ha+16|0;ga=T>>>0>>0?ha:T;T=ga+8|0;c=da+8|0;aa=(c&7|0)==0?0:0-c&7;c=da+aa|0;fa=ea+-40-aa|0;f[4122]=c;f[4119]=fa;f[c+4>>2]=fa|1;f[c+fa+4>>2]=40;f[4123]=f[4238];fa=ga+4|0;f[fa>>2]=27;f[T>>2]=f[4228];f[T+4>>2]=f[4229];f[T+8>>2]=f[4230];f[T+12>>2]=f[4231];f[4228]=da;f[4229]=ea;f[4231]=0;f[4230]=T;T=ga+24|0;do{c=T;T=T+4|0;f[T>>2]=7}while((c+8|0)>>>0>>0);if((ga|0)!=(ha|0)){T=ga-ha|0;f[fa>>2]=f[fa>>2]&-2;f[ha+4>>2]=T|1;f[ga>>2]=T;c=T>>>3;if(T>>>0<256){aa=16504+(c<<1<<2)|0;ba=f[4116]|0;s=1<>2]|0}f[va>>2]=ha;f[wa+12>>2]=ha;f[ha+8>>2]=wa;f[ha+12>>2]=aa;break}aa=T>>>8;if(aa)if(T>>>0>16777215)xa=31;else{s=(aa+1048320|0)>>>16&8;ba=aa<>>16&4;c=ba<>>16&2;Y=14-(aa|s|ba)+(c<>>15)|0;xa=T>>>(Y+7|0)&1|Y<<1}else xa=0;Y=16768+(xa<<2)|0;f[ha+28>>2]=xa;f[ha+20>>2]=0;f[ca>>2]=0;ba=f[4117]|0;c=1<>2]=ha;f[ha+24>>2]=Y;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}c=T<<((xa|0)==31?0:25-(xa>>>1)|0);ba=f[Y>>2]|0;while(1){if((f[ba+4>>2]&-8|0)==(T|0)){H=216;break}ya=ba+16+(c>>>31<<2)|0;Y=f[ya>>2]|0;if(!Y){H=215;break}else{c=c<<1;ba=Y}}if((H|0)==215){f[ya>>2]=ha;f[ha+24>>2]=ba;f[ha+12>>2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=u+80|0;e=d+56|0;g=d+40|0;i=d+16|0;k=d+4|0;l=d+36|0;m=d;f[g>>2]=0;o=g+4|0;f[o>>2]=0;f[g+8>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[i+16>>2]=$(1.0);f[k>>2]=0;p=k+4|0;f[p>>2]=0;f[k+8>>2]=0;q=(f[a+216>>2]|0)==(f[a+220>>2]|0);r=a+120|0;s=f[a+124>>2]|0;a:do if((c|0)>0){t=a+232|0;v=a+420|0;w=a+308|0;x=a+416|0;y=a+304|0;z=a+296|0;A=a+300|0;B=a+8|0;C=i+4|0;D=a+388|0;E=k+8|0;F=g+8|0;G=a+36|0;H=a+40|0;I=c+-1|0;J=a+400|0;K=0;b:while(1){L=K+1|0;if((f[v>>2]|0)!=-1?Pi(J)|0:0){M=f[v>>2]|0;f[x>>2]=M;if(!M)N=17;else{O=M;N=32}}else N=6;c:do if((N|0)==6){N=0;do if(!(b[w>>0]|0))P=1;else{M=f[y>>2]|0;Q=f[z>>2]|0;R=f[A>>2]|0;S=Q+(M>>>3)|0;if(S>>>0>>0?(T=h[S>>0]|0,S=M+1|0,f[y>>2]=S,T&1<<(M&7)|0):0){T=Q+(S>>>3)|0;if(T>>>0>>0){U=(h[T>>0]|0)>>>(S&7)&1;T=M+2|0;f[y>>2]=T;V=T;W=U}else{V=S;W=0}S=Q+(V>>>3)|0;if(S>>>0>>0){R=(h[S>>0]|0)>>>(V&7);f[y>>2]=V+1;X=R<<1&2}else X=0;P=(X|W)<<1|1;break}f[x>>2]=0;N=17;break c}while(0);f[x>>2]=P;O=P;N=32}while(0);d:do if((N|0)==17){N=0;R=f[o>>2]|0;if((f[g>>2]|0)==(R|0)){Y=-1;N=189;break a}S=R+-4|0;Q=f[S>>2]|0;U=f[B>>2]|0;T=(Q|0)==-1;M=Q+1|0;if(!T?(Z=((M>>>0)%3|0|0)==0?Q+-2|0:M,(Z|0)!=-1):0)_=f[(f[U>>2]|0)+(Z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-M>>2|0)>(s|0)){Y=-1;N=189;break a}M=f[T>>2]|0;f[M+(Q<<2)>>2]=Z;if(R|0)f[ea+(Z<<2)>>2]=Q;if((S|0)!=-1){Q=(((S>>>0)%3|0|0)==0?2:-1)+S|0;if((Q|0)!=-1){Z=f[M+(Q<<2)>>2]|0;f[M+(da<<2)>>2]=Z;if((Z|0)!=-1)f[ea+(Z<<2)>>2]=da}else f[M+(da<<2)>>2]=-1;Z=S+1|0;ea=((Z>>>0)%3|0|0)==0?S+-2|0:Z;if((ea|0)==-1)ha=-1;else ha=f[M+(ea<<2)>>2]|0}else{f[M+(da<<2)>>2]=-1;ha=-1}f[M+(ca<<2)>>2]=ha;ca=f[o>>2]|0;f[ca+-4>>2]=aa;ia=ca;break}case 1:{ca=f[g>>2]|0;aa=f[o>>2]|0;if((ca|0)==(aa|0)){Y=-1;N=189;break a}M=aa+-4|0;da=f[M>>2]|0;f[o>>2]=M;ea=f[C>>2]|0;e:do if(ea){Z=ea+-1|0;S=(Z&ea|0)==0;if(!S)if(K>>>0>>0)ja=K;else ja=(K>>>0)%(ea>>>0)|0;else ja=Z&K;Q=f[(f[i>>2]|0)+(ja<<2)>>2]|0;if((Q|0)!=0?(R=f[Q>>2]|0,(R|0)!=0):0){f:do if(S){Q=R;while(1){T=f[Q+4>>2]|0;U=(T|0)==(K|0);if(!(U|(T&Z|0)==(ja|0))){ka=ca;la=M;break e}if(U?(f[Q+8>>2]|0)==(K|0):0){ma=Q;break f}Q=f[Q>>2]|0;if(!Q){ka=ca;la=M;break e}}}else{Q=R;while(1){U=f[Q+4>>2]|0;if((U|0)==(K|0)){if((f[Q+8>>2]|0)==(K|0)){ma=Q;break f}}else{if(U>>>0>>0)na=U;else na=(U>>>0)%(ea>>>0)|0;if((na|0)!=(ja|0)){ka=ca;la=M;break e}}Q=f[Q>>2]|0;if(!Q){ka=ca;la=M;break e}}}while(0);R=ma+12|0;if((M|0)==(f[F>>2]|0)){dh(g,R);ka=f[g>>2]|0;la=f[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a>>2]|0)+(f[S+(ua<<2)>>2]|0);S=f[ea+24>>2]|0;if((sa|0)!=-1)f[S+(sa<<2)>>2]=f[S+(f[e>>2]<<2)>>2];g:do if((ta|0)!=-1){ea=f[qa>>2]|0;aa=ta;do{f[ea+(aa<<2)>>2]=sa;Q=aa+1|0;T=((Q>>>0)%3|0|0)==0?aa+-2|0:Q;if((T|0)==-1)break g;Q=f[R+(T<<2)>>2]|0;T=Q+1|0;if((Q|0)==-1)break g;aa=((T>>>0)%3|0|0)==0?Q+-2|0:T}while((aa|0)!=-1)}while(0);f[S+(f[e>>2]<<2)>>2]=-1;do if(q){R=f[p>>2]|0;if((R|0)==(f[E>>2]|0)){dh(k,e);va=f[o>>2]|0;break}else{f[R>>2]=f[e>>2];f[p>>2]=R+4;va=la;break}}else va=la;while(0);f[va+-4>>2]=Z;f[l>>2]=f[va+-4>>2];f[e>>2]=f[l>>2];Gc(t,e);break d;break}case 7:{f[e>>2]=K*3;S=f[B>>2]|0;R=S+24|0;da=S+28|0;aa=f[da>>2]|0;if((aa|0)==(f[S+32>>2]|0)){dh(R,3112);wa=f[da>>2]|0}else{f[aa>>2]=-1;S=aa+4|0;f[da>>2]=S;wa=S}S=wa-(f[R>>2]|0)>>2;R=S+-1|0;da=f[B>>2]|0;aa=f[e>>2]|0;ea=f[da>>2]|0;f[ea+(aa<<2)>>2]=R;T=da+24|0;Q=da+28|0;ca=f[Q>>2]|0;if((ca|0)==(f[da+32>>2]|0)){dh(T,3112);xa=f[Q>>2]|0;ya=f[da>>2]|0}else{f[ca>>2]=-1;da=ca+4|0;f[Q>>2]=da;xa=da;ya=ea}f[ya+(aa+1<<2)>>2]=(xa-(f[T>>2]|0)>>2)+-1;T=f[B>>2]|0;aa=(f[e>>2]|0)+2|0;ea=T+24|0;da=T+28|0;Q=f[da>>2]|0;if((Q|0)==(f[T+32>>2]|0)){dh(ea,3112);za=f[da>>2]|0}else{f[Q>>2]=-1;ca=Q+4|0;f[da>>2]=ca;za=ca}f[(f[T>>2]|0)+(aa<<2)>>2]=(za-(f[ea>>2]|0)>>2)+-1;ea=f[B>>2]|0;aa=f[ea+24>>2]|0;T=aa;if(((f[ea+28>>2]|0)-aa>>2|0)>(s|0))break b;aa=f[e>>2]|0;if(S){f[T+(R<<2)>>2]=aa;if((S|0)!=-1){f[T+(S<<2)>>2]=(f[e>>2]|0)+1;R=S+1|0;if((R|0)!=-1){Aa=R;N=116}}else{Aa=0;N=116}}else{f[T+(S<<2)>>2]=aa+1;Aa=1;N=116}if((N|0)==116){N=0;f[T+(Aa<<2)>>2]=(f[e>>2]|0)+2}T=f[o>>2]|0;if((T|0)==(f[F>>2]|0)){dh(g,e);Ba=f[o>>2]|0}else{f[T>>2]=f[e>>2];aa=T+4|0;f[o>>2]=aa;Ba=aa}ia=Ba;break}default:{Y=-1;N=189;break a}}f[l>>2]=f[ia+-4>>2];f[e>>2]=f[l>>2];Gc(t,e);aa=c-K+-1|0;T=f[H>>2]|0;if((T|0)!=(f[G>>2]|0)){S=T;do{T=S;R=f[T+-8>>2]|0;if(R>>>0>aa>>>0){Y=-1;N=189;break a}if((R|0)!=(aa|0))break d;R=b[T+-4>>0]|0;ea=f[T+-12>>2]|0;f[H>>2]=T+-12;if((ea|0)<0){Y=-1;N=189;break a}T=f[(f[o>>2]|0)+-4>>2]|0;ca=(T|0)==-1;do if(!(R&1))if(!ca)if(!((T>>>0)%3|0)){Ca=T+2|0;break}else{Ca=T+-1|0;break}else Ca=-1;else{da=T+1|0;if(ca)Ca=-1;else Ca=((da>>>0)%3|0|0)==0?T+-2|0:da}while(0);f[e>>2]=I-ea;T=Tc(i,e)|0;f[T>>2]=Ca;S=f[H>>2]|0}while((S|0)!=(f[G>>2]|0))}}while(0);if((L|0)<(c|0))K=L;else{Da=B;Ea=L;N=135;break a}}Y=-1;N=189}else{Da=a+8|0;Ea=0;N=135}while(0);h:do if((N|0)==135){c=f[Da>>2]|0;if(((f[c+28>>2]|0)-(f[c+24>>2]|0)>>2|0)<=(s|0)){Ca=f[o>>2]|0;do if((Ca|0)!=(f[g>>2]|0)){l=a+270|0;ia=a+364|0;Ba=a+360|0;Aa=a+352|0;za=a+356|0;xa=a+60|0;ya=a+64|0;wa=a+68|0;va=a+76|0;la=a+80|0;q=a+72|0;sa=a+312|0;ta=Ca;qa=Ea;i:while(1){ua=ta;f[e>>2]=f[ua+-4>>2];f[o>>2]=ua+-4;if((j[l>>1]|0)<514)if(b[ia>>0]|0){ua=f[Ba>>2]|0;pa=(f[Aa>>2]|0)+(ua>>>3)|0;if(pa>>>0<(f[za>>2]|0)>>>0){ra=(h[pa>>0]|0)>>>(ua&7)&1;f[Ba>>2]=ua+1;Fa=ra;N=143}else N=166}else N=144;else{Fa=(Pi(sa)|0)&1;N=143}if((N|0)==143){N=0;if(!Fa)N=166;else N=144}do if((N|0)==144){N=0;ra=f[Da>>2]|0;ua=f[ra>>2]|0;pa=ua;if((qa|0)>=(((f[ra+4>>2]|0)-ua>>2>>>0)/3|0|0)){N=174;break i}ua=f[e>>2]|0;oa=ua+1|0;if((ua|0)!=-1?(ka=((oa>>>0)%3|0|0)==0?ua+-2|0:oa,(ka|0)!=-1):0)Ga=f[pa+(ka<<2)>>2]|0;else Ga=-1;ka=f[ra+24>>2]|0;oa=f[ka+(Ga<<2)>>2]|0;ma=oa+1|0;if((oa|0)!=-1?(ja=((ma>>>0)%3|0|0)==0?oa+-2|0:ma,ma=ja+1|0,(ja|0)!=-1):0){oa=((ma>>>0)%3|0|0)==0?ja+-2|0:ma;if((oa|0)==-1){Ha=ja;Ia=-1}else{Ha=ja;Ia=f[pa+(oa<<2)>>2]|0}}else{Ha=-1;Ia=-1}oa=f[ka+(Ia<<2)>>2]|0;ka=oa+1|0;if((oa|0)!=-1?(ja=((ka>>>0)%3|0|0)==0?oa+-2|0:ka,ka=ja+1|0,(ja|0)!=-1):0){oa=((ka>>>0)%3|0|0)==0?ja+-2|0:ka;if((oa|0)==-1){Ja=ja;Ka=-1}else{Ja=ja;Ka=f[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ja<<6;ja=oa+32&-32;Jg(xa,oa>>>0<1073741823?(ua>>>0>>0?ja:ua):2147483647);Qa=f[ya>>2]|0}else Qa=oa;f[ya>>2]=Qa+1;oa=(f[xa>>2]|0)+(Qa>>>5<<2)|0;f[oa>>2]=f[oa>>2]&~(1<<(Qa&31));oa=f[va>>2]|0;if((oa|0)==(f[la>>2]|0)){dh(q,e);Pa=qa;break}else{f[oa>>2]=f[e>>2];f[va>>2]=oa+4;Pa=qa;break}}while(0);ta=f[o>>2]|0;if((ta|0)==(f[g>>2]|0)){N=175;break}else qa=Pa}if((N|0)==158)Eo(xa);else if((N|0)==168)Eo(xa);else if((N|0)==174){Y=-1;N=189;break h}else if((N|0)==175){Ra=f[Da>>2]|0;Sa=Pa;break}}else{Ra=c;Sa=Ea}while(0);if((Sa|0)==(((f[Ra+4>>2]|0)-(f[Ra>>2]|0)>>2>>>0)/3|0|0)){c=(f[Ra+28>>2]|0)-(f[Ra+24>>2]|0)>>2;Ca=f[k>>2]|0;qa=f[p>>2]|0;if((Ca|0)==(qa|0)){Ta=Ca;Ua=c}else{ta=e+4|0;va=e+8|0;q=e+12|0;la=Ra;ya=Ca;Ca=c;while(1){c=f[ya>>2]|0;wa=Ca+-1|0;sa=f[la+24>>2]|0;if((f[sa+(wa<<2)>>2]|0)==-1){Ba=Ca;while(1){za=Ba+-1|0;Aa=Ba+-2|0;if((f[sa+(Aa<<2)>>2]|0)==-1)Ba=za;else{Va=za;Wa=Aa;break}}}else{Va=Ca;Wa=wa}if(Wa>>>0>>0){Xa=la;Ya=Va}else{f[e>>2]=la;Ba=f[sa+(Wa<<2)>>2]|0;f[ta>>2]=Ba;f[va>>2]=Ba;b[q>>0]=1;if((Ba|0)==-1)Za=la;else{xa=la;Aa=Ba;while(1){f[(f[xa>>2]|0)+(Aa<<2)>>2]=c;fg(e);Aa=f[va>>2]|0;Ba=f[Da>>2]|0;if((Aa|0)==-1){Za=Ba;break}else xa=Ba}}xa=f[Za+24>>2]|0;if((c|0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q+(L<<2)>>2]=-1;O=K+1|0;S=((O>>>0)%3|0|0)==0?K+-2|0:O;if((S|0)==-1)T=-1;else T=f[Q+(S<<2)>>2]|0}else{f[Q+(L<<2)>>2]=-1;T=-1}f[Q+(M<<2)>>2]=T;M=f[o>>2]|0;f[M+-4>>2]=H;U=M;break}case 1:{M=f[g>>2]|0;H=f[o>>2]|0;if((M|0)==(H|0)){I=-1;J=177;break a}Q=H+-4|0;L=f[Q>>2]|0;f[o>>2]=Q;S=f[z>>2]|0;d:do if(S){O=S+-1|0;K=(O&S|0)==0;if(!K)if(D>>>0>>0)V=D;else V=(D>>>0)%(S>>>0)|0;else V=O&D;N=f[(f[i>>2]|0)+(V<<2)>>2]|0;if((N|0)!=0?(G=f[N>>2]|0,(G|0)!=0):0){e:do if(K){N=G;while(1){P=f[N+4>>2]|0;W=(P|0)==(D|0);if(!(W|(P&O|0)==(V|0))){X=M;Y=Q;break d}if(W?(f[N+8>>2]|0)==(D|0):0){Z=N;break e}N=f[N>>2]|0;if(!N){X=M;Y=Q;break d}}}else{N=G;while(1){W=f[N+4>>2]|0;if((W|0)==(D|0)){if((f[N+8>>2]|0)==(D|0)){Z=N;break e}}else{if(W>>>0>>0)_=W;else _=(W>>>0)%(S>>>0)|0;if((_|0)!=(V|0)){X=M;Y=Q;break d}}N=f[N>>2]|0;if(!N){X=M;Y=Q;break d}}}while(0);G=Z+12|0;if((Q|0)==(f[C>>2]|0)){dh(g,G);X=f[g>>2]|0;Y=f[o>>2]|0;break}else{f[Q>>2]=f[G>>2];f[o>>2]=H;X=M;Y=H;break}}else{X=M;Y=Q}}else{X=M;Y=Q}while(0);if((X|0)==(Y|0)){I=-1;J=177;break a}Q=f[Y+-4>>2]|0;M=(Q|0)==-1;if(!M?(f[(f[(f[v>>2]|0)+12>>2]|0)+(Q<<2)>>2]|0)!=-1:0){I=-1;J=177;break a}H=(L|0)==-1;S=f[v>>2]|0;G=f[S+12>>2]|0;if(!H?(f[G+(L<<2)>>2]|0)!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[p>>2]|0;if((G|0)==(f[B>>2]|0)){dh(k,e);ha=f[o>>2]|0;break}else{f[G>>2]=f[e>>2];f[p>>2]=G+4;ha=Y;break}}else ha=Y;while(0);f[ha+-4>>2]=O;f[l>>2]=f[ha+-4>>2];f[e>>2]=f[l>>2];Pc(t,e);break c;break}case 7:{f[e>>2]=D*3;K=f[v>>2]|0;G=K+24|0;L=K+28|0;H=f[L>>2]|0;if((H|0)==(f[K+32>>2]|0)){dh(G,3112);ia=f[L>>2]|0}else{f[H>>2]=-1;K=H+4|0;f[L>>2]=K;ia=K}K=ia-(f[G>>2]|0)>>2;G=K+-1|0;L=f[v>>2]|0;H=f[e>>2]|0;S=f[L>>2]|0;f[S+(H<<2)>>2]=G;P=L+24|0;N=L+28|0;M=f[N>>2]|0;if((M|0)==(f[L+32>>2]|0)){dh(P,3112);ja=f[N>>2]|0;ka=f[L>>2]|0}else{f[M>>2]=-1;L=M+4|0;f[N>>2]=L;ja=L;ka=S}f[ka+(H+1<<2)>>2]=(ja-(f[P>>2]|0)>>2)+-1;P=f[v>>2]|0;H=(f[e>>2]|0)+2|0;S=P+24|0;L=P+28|0;N=f[L>>2]|0;if((N|0)==(f[P+32>>2]|0)){dh(S,3112);la=f[L>>2]|0}else{f[N>>2]=-1;M=N+4|0;f[L>>2]=M;la=M}f[(f[P>>2]|0)+(H<<2)>>2]=(la-(f[S>>2]|0)>>2)+-1;S=f[v>>2]|0;H=f[S+24>>2]|0;P=H;if(((f[S+28>>2]|0)-H>>2|0)>(s|0))break b;H=f[e>>2]|0;if(K){f[P+(G<<2)>>2]=H;if((K|0)!=-1){f[P+(K<<2)>>2]=(f[e>>2]|0)+1;G=K+1|0;if((G|0)!=-1){ma=G;J=104}}else{ma=0;J=104}}else{f[P+(K<<2)>>2]=H+1;ma=1;J=104}if((J|0)==104){J=0;f[P+(ma<<2)>>2]=(f[e>>2]|0)+2}P=f[o>>2]|0;if((P|0)==(f[C>>2]|0)){dh(g,e);na=f[o>>2]|0}else{f[P>>2]=f[e>>2];H=P+4|0;f[o>>2]=H;na=H}U=na;break}default:{I=-1;J=177;break a}}f[l>>2]=f[U+-4>>2];f[e>>2]=f[l>>2];Pc(t,e);H=c-D+-1|0;P=f[x>>2]|0;if((P|0)!=(f[w>>2]|0)){K=P;do{P=K;G=f[P+-8>>2]|0;if(G>>>0>H>>>0){I=-1;J=177;break a}if((G|0)!=(H|0))break c;G=b[P+-4>>0]|0;S=f[P+-12>>2]|0;f[x>>2]=P+-12;if((S|0)<0){I=-1;J=177;break a}P=f[(f[o>>2]|0)+-4>>2]|0;M=(P|0)==-1;do if(!(G&1))if(!M)if(!((P>>>0)%3|0)){oa=P+2|0;break}else{oa=P+-1|0;break}else oa=-1;else{L=P+1|0;if(M)oa=-1;else oa=((L>>>0)%3|0|0)==0?P+-2|0:L}while(0);f[e>>2]=y-S;P=Tc(i,e)|0;f[P>>2]=oa;K=f[x>>2]|0}while((K|0)!=(f[w>>2]|0))}}else{K=f[o>>2]|0;if((f[g>>2]|0)==(K|0)){I=-1;J=177;break a}H=K+-4|0;O=f[H>>2]|0;P=f[v>>2]|0;M=(O|0)==-1;G=O+1|0;if(!M?(L=((G>>>0)%3|0|0)==0?O+-2|0:G,(L|0)!=-1):0)pa=f[(f[P>>2]|0)+(L<<2)>>2]|0;else pa=-1;L=f[P+24>>2]|0;G=f[L+(pa<<2)>>2]|0;N=G+1|0;if((G|0)==-1)qa=-1;else qa=((N>>>0)%3|0|0)==0?G+-2|0:N;N=D*3|0;G=N+1|0;W=f[P+12>>2]|0;f[W+(O<<2)>>2]=G;f[W+(G<<2)>>2]=O;Q=N+2|0;f[W+(qa<<2)>>2]=Q;f[W+(Q<<2)>>2]=qa;W=f[P>>2]|0;f[W+(N<<2)>>2]=pa;P=qa+1|0;if((qa|0)!=-1?(ra=((P>>>0)%3|0|0)==0?qa+-2|0:P,(ra|0)!=-1):0)sa=f[W+(ra<<2)>>2]|0;else sa=-1;f[W+(G<<2)>>2]=sa;if(!M?(M=(((O>>>0)%3|0|0)==0?2:-1)+O|0,(M|0)!=-1):0){O=f[W+(M<<2)>>2]|0;f[W+(Q<<2)>>2]=O;if((O|0)!=-1)f[L+(O<<2)>>2]=Q}else f[W+(Q<<2)>>2]=-1;Q=(f[r>>2]|0)+(pa>>>5<<2)|0;f[Q>>2]=f[Q>>2]&~(1<<(pa&31));f[H>>2]=N;f[l>>2]=f[K+-4>>2];f[e>>2]=f[l>>2];Pc(t,e)}while(0);if((E|0)<(c|0))D=E;else{ta=v;ua=E;J=123;break a}}I=-1;J=177}else{ta=a+8|0;ua=0;J=123}while(0);g:do if((J|0)==123){c=f[ta>>2]|0;if(((f[c+28>>2]|0)-(f[c+24>>2]|0)>>2|0)<=(s|0)){l=f[o>>2]|0;do if((l|0)!=(f[g>>2]|0)){pa=a+270|0;sa=a+364|0;qa=a+360|0;oa=a+352|0;U=a+356|0;na=a+60|0;ma=a+64|0;la=a+68|0;ja=a+76|0;ka=a+80|0;ia=a+72|0;ha=a+312|0;Y=l;q=ua;h:while(1){ea=Y;f[e>>2]=f[ea+-4>>2];f[o>>2]=ea+-4;if((j[pa>>1]|0)<514)if(b[sa>>0]|0){ea=f[qa>>2]|0;fa=(f[oa>>2]|0)+(ea>>>3)|0;if(fa>>>0<(f[U>>2]|0)>>>0){ca=(h[fa>>0]|0)>>>(ea&7)&1;f[qa>>2]=ea+1;va=ca;J=131}else J=154}else J=132;else{va=(Pi(ha)|0)&1;J=131}if((J|0)==131){J=0;if(!va)J=154;else J=132}do if((J|0)==132){J=0;ca=f[ta>>2]|0;ea=f[ca>>2]|0;fa=ea;if((q|0)>=(((f[ca+4>>2]|0)-ea>>2>>>0)/3|0|0)){J=162;break h}ea=f[e>>2]|0;ga=ea+1|0;if((ea|0)!=-1?(ba=((ga>>>0)%3|0|0)==0?ea+-2|0:ga,(ba|0)!=-1):0)wa=f[fa+(ba<<2)>>2]|0;else wa=-1;ba=f[ca+24>>2]|0;ga=f[ba+(wa<<2)>>2]|0;da=ga+1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)<0){J=146;break h}ea=fa<<6;fa=aa+32&-32;Jg(na,aa>>>0<1073741823?(ea>>>0>>0?fa:ea):2147483647);Ea=f[ma>>2]|0}else Ea=aa;f[ma>>2]=Ea+1;aa=(f[na>>2]|0)+(Ea>>>5<<2)|0;f[aa>>2]=f[aa>>2]|1<<(Ea&31);aa=f[ja>>2]|0;if((aa|0)==(f[ka>>2]|0))dh(ia,m);else{f[aa>>2]=f[m>>2];f[ja>>2]=aa+4}Fa=ga}else if((J|0)==154){J=0;ga=f[ma>>2]|0;aa=f[la>>2]|0;if((ga|0)==(aa<<5|0)){if((ga+1|0)<0){J=156;break h}ea=aa<<6;aa=ga+32&-32;Jg(na,ga>>>0<1073741823?(ea>>>0>>0?aa:ea):2147483647);Ga=f[ma>>2]|0}else Ga=ga;f[ma>>2]=Ga+1;ga=(f[na>>2]|0)+(Ga>>>5<<2)|0;f[ga>>2]=f[ga>>2]&~(1<<(Ga&31));ga=f[ja>>2]|0;if((ga|0)==(f[ka>>2]|0)){dh(ia,e);Fa=q;break}else{f[ga>>2]=f[e>>2];f[ja>>2]=ga+4;Fa=q;break}}while(0);Y=f[o>>2]|0;if((Y|0)==(f[g>>2]|0)){J=163;break}else q=Fa}if((J|0)==146)Eo(na);else if((J|0)==156)Eo(na);else if((J|0)==162){I=-1;J=177;break g}else if((J|0)==163){Ha=f[ta>>2]|0;Ia=Fa;break}}else{Ha=c;Ia=ua}while(0);if((Ia|0)==(((f[Ha+4>>2]|0)-(f[Ha>>2]|0)>>2>>>0)/3|0|0)){c=(f[Ha+28>>2]|0)-(f[Ha+24>>2]|0)>>2;l=f[k>>2]|0;q=f[p>>2]|0;if((l|0)==(q|0)){Ja=l;Ka=c}else{Y=e+4|0;ja=e+8|0;ia=e+12|0;ka=Ha;ma=l;l=c;while(1){c=f[ma>>2]|0;la=l+-1|0;ha=f[ka+24>>2]|0;if((f[ha+(la<<2)>>2]|0)==-1){qa=l;while(1){U=qa+-1|0;oa=qa+-2|0;if((f[ha+(oa<<2)>>2]|0)==-1)qa=U;else{La=U;Ma=oa;break}}}else{La=l;Ma=la}if(Ma>>>0>>0){Na=ka;Oa=La}else{f[e>>2]=ka;qa=f[ha+(Ma<<2)>>2]|0;f[Y>>2]=qa;f[ja>>2]=qa;b[ia>>0]=1;if((qa|0)==-1)Pa=ka;else{na=ka;oa=qa;while(1){f[(f[na>>2]|0)+(oa<<2)>>2]=c;fg(e);oa=f[ja>>2]|0;qa=f[ta>>2]|0;if((oa|0)==-1){Pa=qa;break}else na=qa}}na=f[Pa+24>>2]|0;if((c|0)==-1)Qa=na+(Ma<<2)|0;else{oa=na+(Ma<<2)|0;f[na+(c<<2)>>2]=f[oa>>2];Qa=oa}f[Qa>>2]=-1;oa=f[r>>2]|0;na=oa+(Ma>>>5<<2)|0;ha=1<<(Ma&31);la=oa+(c>>>5<<2)|0;oa=1<<(c&31);qa=f[la>>2]|0;f[la>>2]=f[na>>2]&ha|0?qa|oa:qa&~oa;f[na>>2]=f[na>>2]&~ha;Na=Pa;Oa=La+-1|0}ma=ma+4|0;if((ma|0)==(q|0)){I=Oa;J=177;break}else{ka=Na;l=Oa}}}}else{I=-1;J=177}}else{I=-1;J=177}}while(0);if((J|0)==177){Ja=f[k>>2]|0;Ka=I}if(Ja|0){I=f[p>>2]|0;if((I|0)!=(Ja|0))f[p>>2]=I+(~((I+-4-Ja|0)>>>2)<<2);lp(Ja)}Ja=f[i+8>>2]|0;if(Ja|0){I=Ja;do{Ja=I;I=f[I>>2]|0;lp(Ja)}while((I|0)!=0)}I=f[i>>2]|0;f[i>>2]=0;if(I|0)lp(I);I=f[g>>2]|0;if(!I){u=d;return Ka|0}g=f[o>>2]|0;if((g|0)!=(I|0))f[o>>2]=g+(~((g+-4-I|0)>>>2)<<2);lp(I);u=d;return Ka|0}function _a(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C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c;break}case 3:case 5:{J=f[m>>2]|0;if((f[e>>2]|0)==(J|0)){Q=-1;G=184;break a}I=f[J+-4>>2]|0;J=E*3|0;M=K?J:J+2|0;L=(K&1)+J|0;H=(K?2:1)+J|0;K=f[v>>2]|0;R=f[K+12>>2]|0;f[R+(H<<2)>>2]=I;f[R+(I<<2)>>2]=H;R=K+24|0;S=K+28|0;T=f[S>>2]|0;if((T|0)==(f[K+32>>2]|0)){dh(R,3112);U=f[S>>2]|0}else{f[T>>2]=-1;K=T+4|0;f[S>>2]=K;U=K}K=U-(f[R>>2]|0)>>2;R=K+-1|0;S=f[v>>2]|0;T=f[S+24>>2]|0;V=T;if(((f[S+28>>2]|0)-T>>2|0)>(r|0)){Q=-1;G=184;break a}T=f[S>>2]|0;f[T+(H<<2)>>2]=R;if(K|0)f[V+(R<<2)>>2]=H;if((I|0)!=-1){H=(((I>>>0)%3|0|0)==0?2:-1)+I|0;if((H|0)!=-1){R=f[T+(H<<2)>>2]|0;f[T+(M<<2)>>2]=R;if((R|0)!=-1)f[V+(R<<2)>>2]=M}else f[T+(M<<2)>>2]=-1;R=I+1|0;V=((R>>>0)%3|0|0)==0?I+-2|0:R;if((V|0)==-1)W=-1;else W=f[T+(V<<2)>>2]|0}else{f[T+(M<<2)>>2]=-1;W=-1}f[T+(L<<2)>>2]=W;f[(f[m>>2]|0)+-4>>2]=J;break}case 7:{f[k>>2]=E*3;J=f[v>>2]|0;L=J+24|0;T=J+28|0;M=f[T>>2]|0;if((M|0)==(f[J+32>>2]|0)){dh(L,3112);X=f[T>>2]|0}else{f[M>>2]=-1;J=M+4|0;f[T>>2]=J;X=J}J=X-(f[L>>2]|0)>>2;L=J+-1|0;T=f[v>>2]|0;M=f[k>>2]|0;V=f[T>>2]|0;f[V+(M<<2)>>2]=L;R=T+24|0;I=T+28|0;H=f[I>>2]|0;if((H|0)==(f[T+32>>2]|0)){dh(R,3112);Y=f[I>>2]|0;Z=f[T>>2]|0}else{f[H>>2]=-1;T=H+4|0;f[I>>2]=T;Y=T;Z=V}f[Z+(M+1<<2)>>2]=(Y-(f[R>>2]|0)>>2)+-1;R=f[v>>2]|0;M=(f[k>>2]|0)+2|0;V=R+24|0;T=R+28|0;I=f[T>>2]|0;if((I|0)==(f[R+32>>2]|0)){dh(V,3112);_=f[T>>2]|0}else{f[I>>2]=-1;H=I+4|0;f[T>>2]=H;_=H}f[(f[R>>2]|0)+(M<<2)>>2]=(_-(f[V>>2]|0)>>2)+-1;V=f[v>>2]|0;M=f[V+24>>2]|0;R=M;if(((f[V+28>>2]|0)-M>>2|0)>(r|0)){G=114;break b}M=f[k>>2]|0;if(J){f[R+(L<<2)>>2]=M;if((J|0)!=-1){f[R+(J<<2)>>2]=(f[k>>2]|0)+1;L=J+1|0;if((L|0)!=-1){aa=L;G=109}}else{aa=0;G=109}}else{f[R+(J<<2)>>2]=M+1;aa=1;G=109}if((G|0)==109){G=0;f[R+(aa<<2)>>2]=(f[k>>2]|0)+2}R=f[m>>2]|0;if((R|0)==(f[x>>2]|0))dh(e,k);else{f[R>>2]=f[k>>2];f[m>>2]=R+4}break}default:{G=183;break b}}R=c-E+-1|0;M=f[C>>2]|0;if((M|0)==(f[B>>2]|0))break;else ba=M;while(1){M=ba;J=f[M+-8>>2]|0;if(J>>>0>R>>>0){Q=-1;G=184;break a}if((J|0)!=(R|0))break c;J=b[M+-4>>0]|0;L=f[M+-12>>2]|0;f[C>>2]=M+-12;if((L|0)<0){Q=-1;G=184;break a}M=f[(f[m>>2]|0)+-4>>2]|0;V=(M|0)==-1;do if(!(J&1))if(!V)if(!((M>>>0)%3|0)){ca=M+2|0;break}else{ca=M+-1|0;break}else ca=-1;else{H=M+1|0;if(V)ca=-1;else ca=((H>>>0)%3|0|0)==0?M+-2|0:H}while(0);f[k>>2]=D-L;M=Tc(g,k)|0;f[M>>2]=ca;ba=f[C>>2]|0;if((ba|0)==(f[B>>2]|0))break c}}R=f[m>>2]|0;if((f[e>>2]|0)==(R|0)){Q=-1;G=184;break a}M=R+-4|0;R=f[M>>2]|0;V=f[v>>2]|0;J=(R|0)==-1;H=R+1|0;if(!J?(T=((H>>>0)%3|0|0)==0?R+-2|0:H,(T|0)!=-1):0)da=f[(f[V>>2]|0)+(T<<2)>>2]|0;else da=-1;T=f[V+24>>2]|0;H=f[T+(da<<2)>>2]|0;I=H+1|0;if((H|0)==-1)ea=-1;else ea=((I>>>0)%3|0|0)==0?H+-2|0:I;I=E*3|0;H=I+1|0;K=f[V+12>>2]|0;f[K+(R<<2)>>2]=H;f[K+(H<<2)>>2]=R;S=I+2|0;f[K+(ea<<2)>>2]=S;f[K+(S<<2)>>2]=ea;K=f[V>>2]|0;f[K+(I<<2)>>2]=da;V=ea+1|0;if((ea|0)!=-1?(fa=((V>>>0)%3|0|0)==0?ea+-2|0:V,(fa|0)!=-1):0)ga=f[K+(fa<<2)>>2]|0;else ga=-1;f[K+(H<<2)>>2]=ga;if(!J?(J=(((R>>>0)%3|0|0)==0?2:-1)+R|0,(J|0)!=-1):0){R=f[K+(J<<2)>>2]|0;f[K+(S<<2)>>2]=R;if((R|0)!=-1)f[T+(R<<2)>>2]=S}else f[K+(S<<2)>>2]=-1;S=(f[q>>2]|0)+(da>>>5<<2)|0;f[S>>2]=f[S>>2]&~(1<<(da&31));f[M>>2]=I}while(0);if((G|0)==43){G=0;I=f[e>>2]|0;M=f[m>>2]|0;if((I|0)==(M|0)){Q=-1;G=184;break a}S=M+-4|0;K=f[S>>2]|0;f[m>>2]=S;R=f[t>>2]|0;d:do if(R){T=R+-1|0;J=(T&R|0)==0;if(!J)if(E>>>0>>0)ha=E;else ha=(E>>>0)%(R>>>0)|0;else ha=T&E;H=f[(f[g>>2]|0)+(ha<<2)>>2]|0;if((H|0)!=0?(fa=f[H>>2]|0,(fa|0)!=0):0){e:do if(J){H=fa;while(1){V=f[H+4>>2]|0;ia=(V|0)==(E|0);if(!(ia|(V&T|0)==(ha|0))){ja=I;ka=S;break d}if(ia?(f[H+8>>2]|0)==(E|0):0){la=H;break e}H=f[H>>2]|0;if(!H){ja=I;ka=S;break d}}}else{H=fa;while(1){L=f[H+4>>2]|0;if((L|0)==(E|0)){if((f[H+8>>2]|0)==(E|0)){la=H;break e}}else{if(L>>>0>>0)ma=L;else ma=(L>>>0)%(R>>>0)|0;if((ma|0)!=(ha|0)){ja=I;ka=S;break d}}H=f[H>>2]|0;if(!H){ja=I;ka=S;break d}}}while(0);fa=la+12|0;if((S|0)==(f[x>>2]|0)){dh(e,fa);ja=f[e>>2]|0;ka=f[m>>2]|0;break}else{f[S>>2]=f[fa>>2];f[m>>2]=M;ja=I;ka=M;break}}else{ja=I;ka=S}}else{ja=I;ka=S}while(0);if((ja|0)==(ka|0)){Q=-1;G=184;break a}S=f[ka+-4>>2]|0;I=(S|0)==-1;if(!I?(f[(f[(f[v>>2]|0)+12>>2]|0)+(S<<2)>>2]|0)!=-1:0){Q=-1;G=184;break a}M=(K|0)==-1;R=f[v>>2]|0;fa=f[R+12>>2]|0;if(!M?(f[fa+(K<<2)>>2]|0)!=-1:0){Q=-1;G=184;break a}T=E*3|0;J=T+2|0;f[fa+(S<<2)>>2]=J;f[fa+(J<<2)>>2]=S;H=T+1|0;f[fa+(K<<2)>>2]=H;f[fa+(H<<2)>>2]=K;if(!I){I=(((S>>>0)%3|0|0)==0?2:-1)+S|0;if((I|0)==-1)na=-1;else na=f[(f[R>>2]|0)+(I<<2)>>2]|0;I=f[R>>2]|0;f[I+(T<<2)>>2]=na;L=S+1|0;ia=((L>>>0)%3|0|0)==0?S+-2|0:L;if((ia|0)==-1){oa=I;pa=R;qa=-1;ra=na}else{oa=I;pa=R;qa=f[I+(ia<<2)>>2]|0;ra=na}}else{ia=f[R>>2]|0;f[ia+(T<<2)>>2]=-1;oa=ia;pa=R;qa=-1;ra=-1}f[oa+(H<<2)>>2]=qa;if(!M){M=(((K>>>0)%3|0|0)==0?2:-1)+K|0;if((M|0)!=-1){H=f[oa+(M<<2)>>2]|0;f[oa+(J<<2)>>2]=H;if((H|0)!=-1)f[(f[R+24>>2]|0)+(H<<2)>>2]=J}else f[oa+(J<<2)>>2]=-1;H=K+1|0;M=((H>>>0)%3|0|0)==0?K+-2|0:H;if((M|0)==-1){sa=-1;ta=-1}else{sa=M;ta=f[oa+(M<<2)>>2]|0}}else{f[oa+(J<<2)>>2]=-1;sa=-1;ta=-1}f[k>>2]=ta;J=f[R+24>>2]|0;if((ra|0)!=-1)f[J+(ra<<2)>>2]=f[J+(ta<<2)>>2];f:do if((sa|0)!=-1){R=f[pa>>2]|0;M=sa;do{f[R+(M<<2)>>2]=ra;H=M+1|0;ia=((H>>>0)%3|0|0)==0?M+-2|0:H;if((ia|0)==-1)break f;H=f[fa+(ia<<2)>>2]|0;ia=H+1|0;if((H|0)==-1)break f;M=((ia>>>0)%3|0|0)==0?H+-2|0:ia}while((M|0)!=-1)}while(0);f[J+(f[k>>2]<<2)>>2]=-1;do if(p){fa=f[o>>2]|0;if((fa|0)==(f[w>>2]|0)){dh(i,k);ua=f[m>>2]|0;break}else{f[fa>>2]=f[k>>2];f[o>>2]=fa+4;ua=ka;break}}else ua=ka;while(0);f[ua+-4>>2]=T}if((F|0)<(c|0))E=F;else{va=v;wa=F;G=129;break a}}if((G|0)==114){Q=-1;G=184;break}}else{va=a+8|0;wa=0;G=129}while(0);g:do if((G|0)==129){c=f[va>>2]|0;if(((f[c+28>>2]|0)-(f[c+24>>2]|0)>>2|0)<=(r|0)){ua=f[m>>2]|0;do if((ua|0)!=(f[e>>2]|0)){ka=a+270|0;p=a+364|0;ra=a+360|0;sa=a+352|0;pa=a+356|0;ta=a+60|0;oa=a+64|0;qa=a+68|0;na=a+76|0;ja=a+80|0;la=a+72|0;ha=a+312|0;ma=ua;da=wa;h:while(1){ga=ma;f[k>>2]=f[ga+-4>>2];f[m>>2]=ga+-4;if((j[ka>>1]|0)<514)if(b[p>>0]|0){ga=f[ra>>2]|0;ea=(f[sa>>2]|0)+(ga>>>3)|0;if(ea>>>0<(f[pa>>2]|0)>>>0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==-1)Da=-1;else Da=f[Y>>2]|0;Y=f[q>>2]|0;ca=Y+(Da>>>5<<2)|0;f[ca>>2]=f[ca>>2]&~(1<<(Da&31));ca=(f[l>>2]|0)+1|0;if((ca|0)==-1)Ea=-1;else Ea=f[ea+(ca<<2)>>2]|0;ca=Y+(Ea>>>5<<2)|0;f[ca>>2]=f[ca>>2]&~(1<<(Ea&31));ca=(f[l>>2]|0)+2|0;if((ca|0)==-1)Fa=-1;else Fa=f[ea+(ca<<2)>>2]|0;ca=Y+(Fa>>>5<<2)|0;f[ca>>2]=f[ca>>2]&~(1<<(Fa&31));ca=da+1|0;Y=f[oa>>2]|0;ea=f[qa>>2]|0;if((Y|0)==(ea<<5|0)){if((Y+1|0)<0){G=152;break h}ga=ea<<6;ea=Y+32&-32;Jg(ta,Y>>>0<1073741823?(ga>>>0>>0?ea:ga):2147483647);Ga=f[oa>>2]|0}else Ga=Y;f[oa>>2]=Ga+1;Y=(f[ta>>2]|0)+(Ga>>>5<<2)|0;f[Y>>2]=f[Y>>2]|1<<(Ga&31);Y=f[na>>2]|0;if((Y|0)==(f[ja>>2]|0))dh(la,l);else{f[Y>>2]=f[l>>2];f[na>>2]=Y+4}Ha=ca}else if((G|0)==160){G=0;ca=f[oa>>2]|0;Y=f[qa>>2]|0;if((ca|0)==(Y<<5|0)){if((ca+1|0)<0){G=162;break h}ga=Y<<6;Y=ca+32&-32;Jg(ta,ca>>>0<1073741823?(ga>>>0>>0?Y:ga):2147483647);Ia=f[oa>>2]|0}else Ia=ca;f[oa>>2]=Ia+1;ca=(f[ta>>2]|0)+(Ia>>>5<<2)|0;f[ca>>2]=f[ca>>2]&~(1<<(Ia&31));ca=f[na>>2]|0;if((ca|0)==(f[ja>>2]|0)){dh(la,k);Ha=da;break}else{f[ca>>2]=f[k>>2];f[na>>2]=ca+4;Ha=da;break}}while(0);ma=f[m>>2]|0;if((ma|0)==(f[e>>2]|0)){G=169;break}else da=Ha}if((G|0)==152)Eo(ta);else if((G|0)==162)Eo(ta);else if((G|0)==168){Q=-1;G=184;break g}else if((G|0)==169){Ja=f[va>>2]|0;Ka=Ha;break}}else{Ja=c;Ka=wa}while(0);if((Ka|0)==(((f[Ja+4>>2]|0)-(f[Ja>>2]|0)>>2>>>0)/3|0|0)){c=(f[Ja+28>>2]|0)-(f[Ja+24>>2]|0)>>2;ua=f[i>>2]|0;da=f[o>>2]|0;if((ua|0)==(da|0)){La=ua;Ma=c}else{ma=k+4|0;na=k+8|0;la=k+12|0;ja=Ja;oa=ua;ua=c;while(1){c=f[oa>>2]|0;qa=ua+-1|0;ha=f[ja+24>>2]|0;if((f[ha+(qa<<2)>>2]|0)==-1){ra=ua;while(1){pa=ra+-1|0;sa=ra+-2|0;if((f[ha+(sa<<2)>>2]|0)==-1)ra=pa;else{Na=pa;Oa=sa;break}}}else{Na=ua;Oa=qa}if(Oa>>>0>>0){Pa=ja;Qa=Na}else{f[k>>2]=ja;ra=f[ha+(Oa<<2)>>2]|0;f[ma>>2]=ra;f[na>>2]=ra;b[la>>0]=1;if((ra|0)==-1)Ra=ja;else{ta=ja;sa=ra;while(1){f[(f[ta>>2]|0)+(sa<<2)>>2]=c;fg(k);sa=f[na>>2]|0;ra=f[va>>2]|0;if((sa|0)==-1){Ra=ra;break}else ta=ra}}ta=f[Ra+24>>2]|0;if((c|0)==-1)Sa=ta+(Oa<<2)|0;else{sa=ta+(Oa<<2)|0;f[ta+(c<<2)>>2]=f[sa>>2];Sa=sa}f[Sa>>2]=-1;sa=f[q>>2]|0;ta=sa+(Oa>>>5<<2)|0;ha=1<<(Oa&31);qa=sa+(c>>>5<<2)|0;sa=1<<(c&31);ra=f[qa>>2]|0;f[qa>>2]=f[ta>>2]&ha|0?ra|sa:ra&~sa;f[ta>>2]=f[ta>>2]&~ha;Pa=Ra;Qa=Na+-1|0}oa=oa+4|0;if((oa|0)==(da|0)){Q=Qa;G=184;break}else{ja=Pa;ua=Qa}}}}else{Q=-1;G=184}}else{Q=-1;G=184}}while(0);if((G|0)==184){La=f[i>>2]|0;Ma=Q}if(La|0){Q=f[o>>2]|0;if((Q|0)!=(La|0))f[o>>2]=Q+(~((Q+-4-La|0)>>>2)<<2);lp(La)}La=f[g+8>>2]|0;if(La|0){Q=La;do{La=Q;Q=f[Q>>2]|0;lp(La)}while((Q|0)!=0)}Q=f[g>>2]|0;f[g>>2]=0;if(Q|0)lp(Q);Q=f[e>>2]|0;if(!Q){u=d;return Ma|0}e=f[m>>2]|0;if((e|0)!=(Q|0))f[m>>2]=e+(~((e+-4-Q|0)>>>2)<<2);lp(Q);u=d;return Ma|0}function $a(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;b=u;u=u+16|0;c=b;d=b+8|0;e=b+4|0;f[d>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;h=g*210|0;f[e>>2]=a-h;i=(Lj(4440,4632,e,c)|0)-4440>>2;j=g;g=h;h=0;a:while(1){k=(f[4440+(i<<2)>>2]|0)+g|0;l=5;while(1){if(l>>>0>=47){m=211;n=h;o=8;break}p=f[4248+(l<<2)>>2]|0;q=(k>>>0)/(p>>>0)|0;if(q>>>0

>>0){o=106;break a}if((k|0)==(X(q,p)|0)){r=h;break}else l=l+1|0}b:do if((o|0)==8){c:while(1){o=0;l=(k>>>0)/(m>>>0)|0;do if(l>>>0>=m>>>0)if((k|0)!=(X(l,m)|0)){p=m+10|0;q=(k>>>0)/(p>>>0)|0;if(q>>>0>=p>>>0)if((k|0)!=(X(q,p)|0)){q=m+12|0;s=(k>>>0)/(q>>>0)|0;if(s>>>0>=q>>>0)if((k|0)!=(X(s,q)|0)){s=m+16|0;t=(k>>>0)/(s>>>0)|0;if(t>>>0>=s>>>0)if((k|0)!=(X(t,s)|0)){t=m+18|0;v=(k>>>0)/(t>>>0)|0;if(v>>>0>=t>>>0)if((k|0)!=(X(v,t)|0)){v=m+22|0;w=(k>>>0)/(v>>>0)|0;if(w>>>0>=v>>>0)if((k|0)!=(X(w,v)|0)){w=m+28|0;x=(k>>>0)/(w>>>0)|0;if(x>>>0>=w>>>0)if((k|0)==(X(x,w)|0)){y=9;z=w;A=n}else{x=m+30|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+36|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+40|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+42|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+46|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+52|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+58|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+60|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+66|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+70|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+72|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+78|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+82|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+88|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+96|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+100|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+102|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+106|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+108|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+112|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+120|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+126|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+130|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+136|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+138|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+142|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+148|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+150|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+156|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+162|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+166|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+168|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+172|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+178|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+180|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+186|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+190|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+192|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+196|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+198|0;B=(k>>>0)/(x>>>0)|0;if(B>>>0>>0){y=1;z=x;A=k;break}if((k|0)==(X(B,x)|0)){y=9;z=x;A=n;break}x=m+208|0;B=(k>>>0)/(x>>>0)|0;C=B>>>0>>0;D=(k|0)==(X(B,x)|0);y=C?1:D?9:0;z=C|D?x:m+210|0;A=C?k:n}else{y=1;z=w;A=k}}else{y=9;z=v;A=n}else{y=1;z=v;A=k}}else{y=9;z=t;A=n}else{y=1;z=t;A=k}}else{y=9;z=s;A=n}else{y=1;z=s;A=k}}else{y=9;z=q;A=n}else{y=1;z=q;A=k}}else{y=9;z=p;A=n}else{y=1;z=p;A=k}}else{y=9;z=m;A=n}else{y=1;z=m;A=k}while(0);switch(y&15){case 9:{r=A;break b;break}case 0:{m=z;n=A;o=8;break}default:break c}}if(!y)r=A;else{o=107;break a}}while(0);l=i+1|0;p=(l|0)==48;q=(p&1)+j|0;i=p?0:l;j=q;g=q*210|0;h=r}if((o|0)==106){f[d>>2]=k;E=k;break}else if((o|0)==107){f[d>>2]=k;E=A;break}}else{h=Lj(4248,4440,d,c)|0;E=f[h>>2]|0}while(0);u=b;return E|0}function ab(a){a=a|0;var c=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0;c=u;u=u+80|0;e=c+68|0;g=c+64|0;i=c+60|0;k=c+52|0;l=c+44|0;m=c;n=c+56|0;o=c+48|0;p=c+40|0;q=a+132|0;f[q>>2]=0;r=a+148|0;if(f[r>>2]|0){s=a+144|0;t=f[s>>2]|0;if(t|0){v=t;do{t=v;v=f[v>>2]|0;lp(t)}while((v|0)!=0)}f[s>>2]=0;s=f[a+140>>2]|0;if(s|0){v=a+136|0;t=0;do{f[(f[v>>2]|0)+(t<<2)>>2]=0;t=t+1|0}while((t|0)!=(s|0))}f[r>>2]=0}r=a+4|0;s=f[r>>2]|0;t=b[s+36>>0]|0;v=(t&255)<<8;do if(((v|h[s+37>>0])&65535)<514){w=f[s+32>>2]|0;if((v&65535)<512){x=w+8|0;y=f[x>>2]|0;z=f[x+4>>2]|0;x=w+16|0;A=x;B=f[A>>2]|0;C=Ul(B|0,f[A+4>>2]|0,4,0)|0;A=I;if(!((z|0)<(A|0)|(z|0)==(A|0)&y>>>0>>0)){y=(f[w>>2]|0)+B|0;B=h[y>>0]|h[y+1>>0]<<8|h[y+2>>0]<<16|h[y+3>>0]<<24;f[e>>2]=B;y=x;f[y>>2]=C;f[y+4>>2]=A;D=s;E=t;F=B;G=14}}else if(Ph(e,w)|0){w=f[r>>2]|0;D=w;E=b[w+36>>0]|0;F=f[e>>2]|0;G=14}if((G|0)==14){f[q>>2]=F;H=E;J=D;break}K=0;u=c;return K|0}else{H=t;J=s}while(0);s=f[J+32>>2]|0;if(((H&255)<<8&65535)<512){J=s+8|0;t=f[J>>2]|0;D=f[J+4>>2]|0;J=s+16|0;E=J;F=f[E>>2]|0;q=Ul(F|0,f[E+4>>2]|0,4,0)|0;E=I;if((D|0)<(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){S=f[i>>2]|0;T=f[k>>2]|0;G=34}else R=0;if((G|0)==34)if(S>>>0>=T>>>0?S>>>0<=(((T>>>0)/3|0)+T|0)>>>0:0){S=f[r>>2]|0;F=f[S+32>>2]|0;if((h[S+36>>0]<<8&65535)<512){S=F+8|0;J=f[S>>2]|0;Q=f[S+4>>2]|0;S=F+16|0;t=S;M=f[t>>2]|0;O=Ul(M|0,f[t+4>>2]|0,4,0)|0;t=I;if((Q|0)<(t|0)|(Q|0)==(t|0)&J>>>0>>0)U=0;else{J=(f[F>>2]|0)+M|0;M=h[J>>0]|h[J+1>>0]<<8|h[J+2>>0]<<16|h[J+3>>0]<<24;f[l>>2]=M;J=S;f[J>>2]=O;f[J+4>>2]=t;V=M;W=T;G=41}}else if(Ph(l,F)|0){V=f[l>>2]|0;W=f[k>>2]|0;G=41}else U=0;a:do if((G|0)==41)if(V>>>0>W>>>0)U=0;else{F=f[a+24>>2]|0;T=a+28|0;M=f[T>>2]|0;if((M|0)!=(F|0))f[T>>2]=M+(~((M+-4-F|0)>>>2)<<2);F=Yk(88)|0;ak(F);M=a+8|0;T=f[M>>2]|0;f[M>>2]=F;if(T|0?(Vg(T),lp(T),(f[M>>2]|0)==0):0){U=0;break}T=a+160|0;F=f[T>>2]|0;t=a+164|0;J=f[t>>2]|0;if((J|0)!=(F|0))f[t>>2]=J+(~((J+-4-F|0)>>>2)<<2);fi(T,f[i>>2]|0);T=a+172|0;F=f[T>>2]|0;J=a+176|0;t=f[J>>2]|0;if((t|0)!=(F|0))f[J>>2]=t+(~((t+-4-F|0)>>>2)<<2);fi(T,f[i>>2]|0);T=f[a+36>>2]|0;F=a+40|0;t=f[F>>2]|0;if((t|0)!=(T|0))f[F>>2]=t+(~(((t+-12-T|0)>>>0)/12|0)*12|0);T=f[a+48>>2]|0;t=a+52|0;F=f[t>>2]|0;if((F|0)!=(T|0))f[t>>2]=F+(~((F+-4-T|0)>>>2)<<2);f[a+64>>2]=0;T=f[a+72>>2]|0;F=a+76|0;t=f[F>>2]|0;if((t|0)!=(T|0))f[F>>2]=t+(~((t+-4-T|0)>>>2)<<2);f[a+84>>2]=-1;f[a+92>>2]=-1;f[a+88>>2]=-1;T=a+216|0;t=f[T>>2]|0;F=a+220|0;J=f[F>>2]|0;if((J|0)!=(t|0)){O=J;do{f[F>>2]=O+-144;J=f[O+-12>>2]|0;if(J|0){S=O+-8|0;Q=f[S>>2]|0;if((Q|0)!=(J|0))f[S>>2]=Q+(~((Q+-4-J|0)>>>2)<<2);lp(J)}J=f[O+-28>>2]|0;if(J|0){Q=O+-24|0;S=f[Q>>2]|0;if((S|0)!=(J|0))f[Q>>2]=S+(~((S+-4-J|0)>>>2)<<2);lp(J)}J=f[O+-40>>2]|0;if(J|0){S=O+-36|0;Q=f[S>>2]|0;if((Q|0)!=(J|0))f[S>>2]=Q+(~((Q+-4-J|0)>>>2)<<2);lp(J)}ah(O+-140|0);O=f[F>>2]|0}while((O|0)!=(t|0))}t=q&255;pg(T,t);if(!(ph(f[M>>2]|0,f[i>>2]|0,(f[l>>2]|0)+(f[s>>2]|0)|0)|0)){U=0;break}O=(f[l>>2]|0)+(f[s>>2]|0)|0;b[e>>0]=1;Hf(a+120|0,O,e);O=f[r>>2]|0;J=h[O+36>>0]<<8;b:do if(((J|h[O+37>>0])&65535)>=514)if((Pb(a,f[O+32>>2]|0)|0)==-1){U=0;break a}else X=-1;else{Q=f[O+32>>2]|0;do if((J&65535)<512){S=Q+8|0;H=f[S>>2]|0;N=f[S+4>>2]|0;S=Q+16|0;E=S;g=f[E>>2]|0;D=Ul(g|0,f[E+4>>2]|0,4,0)|0;E=I;if((N|0)<(E|0)|(N|0)==(E|0)&H>>>0>>0)break;H=(f[Q>>2]|0)+g|0;g=h[H>>0]|h[H+1>>0]<<8|h[H+2>>0]<<16|h[H+3>>0]<<24;f[e>>2]=g;H=S;f[H>>2]=D;f[H+4>>2]=E;Y=g;G=77}else{if(!(Ph(e,Q)|0))break;Y=f[e>>2]|0;G=77}while(0);do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])&65535;if((g&65535)<514){H=(f[E+32>>2]|0)+16|0;E=H;O=Ul(f[E>>2]|0,f[E+4>>2]|0,X|0,((X|0)<0)<<31>>31|0)|0;E=H;f[E>>2]=O;f[E+4>>2]=I}do if((f[F>>2]|0)!=(f[T>>2]|0)){E=f[M>>2]|0;O=(f[E+4>>2]|0)!=(f[E>>2]|0);if((g&65535)<513){if(!O)break;E=0;do{f[n>>2]=E;f[e>>2]=f[n>>2];E=E+3|0;if(!(Xd(a,e)|0)){Z=0;break c}H=f[M>>2]|0}while(E>>>0<(f[H+4>>2]|0)-(f[H>>2]|0)>>2>>>0)}else{if(!O)break;E=0;do{f[o>>2]=E;f[e>>2]=f[o>>2];E=E+3|0;if(!(Nd(a,e)|0)){Z=0;break c}H=f[M>>2]|0}while(E>>>0<(f[H+4>>2]|0)-(f[H>>2]|0)>>2>>>0)}}while(0);if(b[a+308>>0]|0)_j(a+272|0);if((j[a+270>>1]|0)<514)_j(a+328|0);g=f[T>>2]|0;if((f[F>>2]|0)!=(g|0)){E=g;g=0;do{Uf(E+(g*144|0)+4|0,f[M>>2]|0)|0;O=f[T>>2]|0;H=f[O+(g*144|0)+132>>2]|0;Q=f[O+(g*144|0)+136>>2]|0;if((H|0)==(Q|0))_=O;else{N=O;O=H;while(1){f[p>>2]=f[O>>2];f[e>>2]=f[p>>2];wf(N+(g*144|0)+4|0,e);O=O+4|0;H=f[T>>2]|0;if((O|0)==(Q|0)){_=H;break}else N=H}}Hj(_+(g*144|0)+4|0,0,0);g=g+1|0;E=f[T>>2]|0}while(g>>>0<(((f[F>>2]|0)-E|0)/144|0)>>>0)}E=f[M>>2]|0;g=(f[E+28>>2]|0)-(f[E+24>>2]|0)>>2;E=a+196|0;N=a+200|0;Q=f[N>>2]|0;O=f[E>>2]|0;H=Q-O>>2;S=O;O=Q;do if(g>>>0>H>>>0)Og(E,g-H|0);else{if(g>>>0>=H>>>0)break;Q=S+(g<<2)|0;if((O|0)==(Q|0))break;f[N>>2]=O+(~((O+-4-Q|0)>>>2)<<2)}while(0);fi(a+184|0,g);O=f[T>>2]|0;if((f[F>>2]|0)!=(O|0)){N=O;O=0;do{S=N;H=(f[S+(O*144|0)+60>>2]|0)-(f[S+(O*144|0)+56>>2]|0)>>2;E=f[M>>2]|0;Q=(f[E+28>>2]|0)-(f[E+24>>2]|0)>>2;E=(H|0)<(Q|0)?Q:H;H=S+(O*144|0)+116|0;Q=S+(O*144|0)+120|0;v=f[Q>>2]|0;w=f[H>>2]|0;B=v-w>>2;A=w;w=v;do if(E>>>0>B>>>0)Og(H,E-B|0);else{if(E>>>0>=B>>>0)break;v=A+(E<<2)|0;if((w|0)==(v|0))break;f[Q>>2]=w+(~((w+-4-v|0)>>>2)<<2)}while(0);fi(S+(O*144|0)+104|0,E);O=O+1|0;N=f[T>>2]|0}while(O>>>0<(((f[F>>2]|0)-N|0)/144|0)>>>0)}Z=wb(a,D)|0}else Z=0;while(0);qp(m+24|0);U=Z}while(0);R=U}else R=0;P=R}else P=0;L=P}K=L;u=c;return K|0}function bb(a){a=a|0;var c=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0;c=u;u=u+80|0;e=c+68|0;g=c+64|0;i=c+60|0;k=c+52|0;l=c+44|0;m=c;n=c+56|0;o=c+48|0;p=c+40|0;q=a+132|0;f[q>>2]=0;r=a+148|0;if(f[r>>2]|0){s=a+144|0;t=f[s>>2]|0;if(t|0){v=t;do{t=v;v=f[v>>2]|0;lp(t)}while((v|0)!=0)}f[s>>2]=0;s=f[a+140>>2]|0;if(s|0){v=a+136|0;t=0;do{f[(f[v>>2]|0)+(t<<2)>>2]=0;t=t+1|0}while((t|0)!=(s|0))}f[r>>2]=0}r=a+4|0;s=f[r>>2]|0;t=b[s+36>>0]|0;v=(t&255)<<8;do if(((v|h[s+37>>0])&65535)<514){w=f[s+32>>2]|0;if((v&65535)<512){x=w+8|0;y=f[x>>2]|0;z=f[x+4>>2]|0;x=w+16|0;A=x;B=f[A>>2]|0;C=Ul(B|0,f[A+4>>2]|0,4,0)|0;A=I;if(!((z|0)<(A|0)|(z|0)==(A|0)&y>>>0>>0)){y=(f[w>>2]|0)+B|0;B=h[y>>0]|h[y+1>>0]<<8|h[y+2>>0]<<16|h[y+3>>0]<<24;f[e>>2]=B;y=x;f[y>>2]=C;f[y+4>>2]=A;D=s;E=t;F=B;G=14}}else if(Ph(e,w)|0){w=f[r>>2]|0;D=w;E=b[w+36>>0]|0;F=f[e>>2]|0;G=14}if((G|0)==14){f[q>>2]=F;H=E;J=D;break}K=0;u=c;return K|0}else{H=t;J=s}while(0);s=f[J+32>>2]|0;if(((H&255)<<8&65535)<512){J=s+8|0;t=f[J>>2]|0;D=f[J+4>>2]|0;J=s+16|0;E=J;F=f[E>>2]|0;q=Ul(F|0,f[E+4>>2]|0,4,0)|0;E=I;if((D|0)<(E|0)|(D|0)==(E|0)&t>>>0>>0)L=0;else{t=(f[s>>2]|0)+F|0;F=h[t>>0]|h[t+1>>0]<<8|h[t+2>>0]<<16|h[t+3>>0]<<24;f[g>>2]=F;t=J;f[t>>2]=q;f[t+4>>2]=E;M=F;N=H;O=s;G=21}}else if(Ph(g,s)|0){s=f[r>>2]|0;M=f[g>>2]|0;N=b[s+36>>0]|0;O=f[s+32>>2]|0;G=21}else L=0;if((G|0)==21){s=a+156|0;f[s>>2]=M;if(((N&255)<<8&65535)<512){N=O+8|0;M=f[N>>2]|0;g=f[N+4>>2]|0;N=O+16|0;H=N;F=f[H>>2]|0;E=Ul(F|0,f[H+4>>2]|0,4,0)|0;H=I;if((g|0)<(H|0)|(g|0)==(H|0)&M>>>0>>0)P=0;else{M=(f[O>>2]|0)+F|0;F=h[M>>0]|h[M+1>>0]<<8|h[M+2>>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lp(J)}ah(O+-140|0);O=f[F>>2]|0}while((O|0)!=(t|0))}t=q&255;pg(T,t);if(!(ph(f[M>>2]|0,f[i>>2]|0,(f[l>>2]|0)+(f[s>>2]|0)|0)|0)){U=0;break}O=(f[l>>2]|0)+(f[s>>2]|0)|0;b[e>>0]=1;Hf(a+120|0,O,e);O=f[r>>2]|0;J=h[O+36>>0]<<8;b:do if(((J|h[O+37>>0])&65535)>=514)if((Pb(a,f[O+32>>2]|0)|0)==-1){U=0;break a}else X=-1;else{Q=f[O+32>>2]|0;do if((J&65535)<512){S=Q+8|0;H=f[S>>2]|0;N=f[S+4>>2]|0;S=Q+16|0;E=S;g=f[E>>2]|0;D=Ul(g|0,f[E+4>>2]|0,4,0)|0;E=I;if((N|0)<(E|0)|(N|0)==(E|0)&H>>>0>>0)break;H=(f[Q>>2]|0)+g|0;g=h[H>>0]|h[H+1>>0]<<8|h[H+2>>0]<<16|h[H+3>>0]<<24;f[e>>2]=g;H=S;f[H>>2]=D;f[H+4>>2]=E;Y=g;G=77}else{if(!(Ph(e,Q)|0))break;Y=f[e>>2]|0;G=77}while(0);do if((G|0)==77){if(!Y)break;Q=f[(f[r>>2]|0)+32>>2]|0;g=Q+8|0;E=Q+16|0;Q=Wl(f[g>>2]|0,f[g+4>>2]|0,f[E>>2]|0,f[E+4>>2]|0)|0;E=I;if(0>(E|0)|0==(E|0)&Y>>>0>Q>>>0)break;zk(m);Q=f[(f[r>>2]|0)+32>>2]|0;E=Q+16|0;g=f[E>>2]|0;H=f[e>>2]|0;D=(f[Q>>2]|0)+g+H|0;S=Q+8|0;N=Wl(f[S>>2]|0,f[S+4>>2]|0,g|0,f[E+4>>2]|0)|0;E=Wl(N|0,I|0,H|0,0)|0;Rk(m,D,E,d[Q+38>>1]|0);Q=Pb(a,m)|0;qp(m+24|0);if((Q|0)==-1)break;X=Q;break b}while(0);U=0;break a}while(0);J=a+232|0;f[a+376>>2]=a;O=(Ma[f[(f[a>>2]|0)+32>>2]&127](a)|0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b[a+308>>0]|0)_j(a+272|0);if((j[a+270>>1]|0)<514)_j(a+328|0);g=f[T>>2]|0;if((f[F>>2]|0)!=(g|0)){E=g;g=0;do{Uf(E+(g*144|0)+4|0,f[M>>2]|0)|0;O=f[T>>2]|0;H=f[O+(g*144|0)+132>>2]|0;Q=f[O+(g*144|0)+136>>2]|0;if((H|0)==(Q|0))_=O;else{N=O;O=H;while(1){f[p>>2]=f[O>>2];f[e>>2]=f[p>>2];wf(N+(g*144|0)+4|0,e);O=O+4|0;H=f[T>>2]|0;if((O|0)==(Q|0)){_=H;break}else N=H}}Hj(_+(g*144|0)+4|0,0,0);g=g+1|0;E=f[T>>2]|0}while(g>>>0<(((f[F>>2]|0)-E|0)/144|0)>>>0)}E=f[M>>2]|0;g=(f[E+28>>2]|0)-(f[E+24>>2]|0)>>2;E=a+196|0;N=a+200|0;Q=f[N>>2]|0;O=f[E>>2]|0;H=Q-O>>2;S=O;O=Q;do if(g>>>0>H>>>0)Og(E,g-H|0);else{if(g>>>0>=H>>>0)break;Q=S+(g<<2)|0;if((O|0)==(Q|0))break;f[N>>2]=O+(~((O+-4-Q|0)>>>2)<<2)}while(0);fi(a+184|0,g);O=f[T>>2]|0;if((f[F>>2]|0)!=(O|0)){N=O;O=0;do{S=N;H=(f[S+(O*144|0)+60>>2]|0)-(f[S+(O*144|0)+56>>2]|0)>>2;E=f[M>>2]|0;Q=(f[E+28>>2]|0)-(f[E+24>>2]|0)>>2;E=(H|0)<(Q|0)?Q:H;H=S+(O*144|0)+116|0;Q=S+(O*144|0)+120|0;v=f[Q>>2]|0;w=f[H>>2]|0;B=v-w>>2;A=w;w=v;do if(E>>>0>B>>>0)Og(H,E-B|0);else{if(E>>>0>=B>>>0)break;v=A+(E<<2)|0;if((w|0)==(v|0))break;f[Q>>2]=w+(~((w+-4-v|0)>>>2)<<2)}while(0);fi(S+(O*144|0)+104|0,E);O=O+1|0;N=f[T>>2]|0}while(O>>>0<(((f[F>>2]|0)-N|0)/144|0)>>>0)}Z=wb(a,D)|0}else Z=0;while(0);qp(m+24|0);U=Z}while(0);R=U}else R=0;P=R}else P=0;L=P}K=L;u=c;return K|0}function cb(a){a=a|0;var c=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0;c=u;u=u+80|0;e=c+68|0;g=c+64|0;i=c+60|0;k=c+52|0;l=c+44|0;m=c;n=c+56|0;o=c+48|0;p=c+40|0;q=a+132|0;f[q>>2]=0;r=a+148|0;if(f[r>>2]|0){s=a+144|0;t=f[s>>2]|0;if(t|0){v=t;do{t=v;v=f[v>>2]|0;lp(t)}while((v|0)!=0)}f[s>>2]=0;s=f[a+140>>2]|0;if(s|0){v=a+136|0;t=0;do{f[(f[v>>2]|0)+(t<<2)>>2]=0;t=t+1|0}while((t|0)!=(s|0))}f[r>>2]=0}r=a+4|0;s=f[r>>2]|0;t=b[s+36>>0]|0;v=(t&255)<<8;do if(((v|h[s+37>>0])&65535)<514){w=f[s+32>>2]|0;if((v&65535)<512){x=w+8|0;y=f[x>>2]|0;z=f[x+4>>2]|0;x=w+16|0;A=x;B=f[A>>2]|0;C=Ul(B|0,f[A+4>>2]|0,4,0)|0;A=I;if(!((z|0)<(A|0)|(z|0)==(A|0)&y>>>0>>0)){y=(f[w>>2]|0)+B|0;B=h[y>>0]|h[y+1>>0]<<8|h[y+2>>0]<<16|h[y+3>>0]<<24;f[e>>2]=B;y=x;f[y>>2]=C;f[y+4>>2]=A;D=s;E=t;F=B;G=14}}else if(Ph(e,w)|0){w=f[r>>2]|0;D=w;E=b[w+36>>0]|0;F=f[e>>2]|0;G=14}if((G|0)==14){f[q>>2]=F;H=E;J=D;break}K=0;u=c;return K|0}else{H=t;J=s}while(0);s=f[J+32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0)/12|0)*12|0);T=f[a+48>>2]|0;t=a+52|0;F=f[t>>2]|0;if((F|0)!=(T|0))f[t>>2]=F+(~((F+-4-T|0)>>>2)<<2);f[a+64>>2]=0;T=f[a+72>>2]|0;F=a+76|0;t=f[F>>2]|0;if((t|0)!=(T|0))f[F>>2]=t+(~((t+-4-T|0)>>>2)<<2);f[a+84>>2]=-1;f[a+92>>2]=-1;f[a+88>>2]=-1;T=a+216|0;t=f[T>>2]|0;F=a+220|0;J=f[F>>2]|0;if((J|0)!=(t|0)){O=J;do{f[F>>2]=O+-144;J=f[O+-12>>2]|0;if(J|0){S=O+-8|0;Q=f[S>>2]|0;if((Q|0)!=(J|0))f[S>>2]=Q+(~((Q+-4-J|0)>>>2)<<2);lp(J)}J=f[O+-28>>2]|0;if(J|0){Q=O+-24|0;S=f[Q>>2]|0;if((S|0)!=(J|0))f[Q>>2]=S+(~((S+-4-J|0)>>>2)<<2);lp(J)}J=f[O+-40>>2]|0;if(J|0){S=O+-36|0;Q=f[S>>2]|0;if((Q|0)!=(J|0))f[S>>2]=Q+(~((Q+-4-J|0)>>>2)<<2);lp(J)}ah(O+-140|0);O=f[F>>2]|0}while((O|0)!=(t|0))}t=q&255;pg(T,t);if(!(ph(f[M>>2]|0,f[i>>2]|0,(f[l>>2]|0)+(f[s>>2]|0)|0)|0)){U=0;break}O=(f[l>>2]|0)+(f[s>>2]|0)|0;b[e>>0]=1;Hf(a+120|0,O,e);O=f[r>>2]|0;J=h[O+36>>0]<<8;b:do if(((J|h[O+37>>0])&65535)>=514)if((Pb(a,f[O+32>>2]|0)|0)==-1){U=0;break a}else X=-1;else{Q=f[O+32>>2]|0;do if((J&65535)<512){S=Q+8|0;H=f[S>>2]|0;N=f[S+4>>2]|0;S=Q+16|0;E=S;g=f[E>>2]|0;D=Ul(g|0,f[E+4>>2]|0,4,0)|0;E=I;if((N|0)<(E|0)|(N|0)==(E|0)&H>>>0>>0)break;H=(f[Q>>2]|0)+g|0;g=h[H>>0]|h[H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38>>1]|0);E=f[r>>2]|0;g=(h[E+36>>0]<<8|h[E+37>>0])&65535;if((g&65535)<514){H=(f[E+32>>2]|0)+16|0;E=H;O=Ul(f[E>>2]|0,f[E+4>>2]|0,X|0,((X|0)<0)<<31>>31|0)|0;E=H;f[E>>2]=O;f[E+4>>2]=I}do if((f[F>>2]|0)!=(f[T>>2]|0)){E=f[M>>2]|0;O=(f[E+4>>2]|0)!=(f[E>>2]|0);if((g&65535)<513){if(!O)break;E=0;do{f[n>>2]=E;f[e>>2]=f[n>>2];E=E+3|0;if(!(Xd(a,e)|0)){Z=0;break c}H=f[M>>2]|0}while(E>>>0<(f[H+4>>2]|0)-(f[H>>2]|0)>>2>>>0)}else{if(!O)break;E=0;do{f[o>>2]=E;f[e>>2]=f[o>>2];E=E+3|0;if(!(Nd(a,e)|0)){Z=0;break c}H=f[M>>2]|0}while(E>>>0<(f[H+4>>2]|0)-(f[H>>2]|0)>>2>>>0)}}while(0);if(b[a+308>>0]|0)_j(a+272|0);if((j[a+270>>1]|0)<514)_j(a+328|0);g=f[T>>2]|0;if((f[F>>2]|0)!=(g|0)){E=g;g=0;do{Uf(E+(g*144|0)+4|0,f[M>>2]|0)|0;O=f[T>>2]|0;H=f[O+(g*144|0)+132>>2]|0;Q=f[O+(g*144|0)+136>>2]|0;if((H|0)==(Q|0))_=O;else{N=O;O=H;while(1){f[p>>2]=f[O>>2];f[e>>2]=f[p>>2];wf(N+(g*144|0)+4|0,e);O=O+4|0;H=f[T>>2]|0;if((O|0)==(Q|0)){_=H;break}else N=H}}Hj(_+(g*144|0)+4|0,0,0);g=g+1|0;E=f[T>>2]|0}while(g>>>0<(((f[F>>2]|0)-E|0)/144|0)>>>0)}E=f[M>>2]|0;g=(f[E+28>>2]|0)-(f[E+24>>2]|0)>>2;E=a+196|0;N=a+200|0;Q=f[N>>2]|0;O=f[E>>2]|0;H=Q-O>>2;S=O;O=Q;do if(g>>>0>H>>>0)Og(E,g-H|0);else{if(g>>>0>=H>>>0)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<2)>>2]|0)+(((q>>>0)%341|0)*12|0)|0;f[A>>2]=c;f[A+4>>2]=0;f[A+8>>2]=0;A=(f[x>>2]|0)+1|0;f[x>>2]=A;a:do if(!A)B=1;else{q=a+108|0;p=d+16|0;t=d+20|0;v=d+28|0;w=a+8|0;m=d+12|0;k=a+96|0;j=a+52|0;i=a+48|0;n=a+40|0;o=a+4|0;C=a+32|0;D=a+28|0;E=a+20|0;F=a+92|0;G=a+80|0;H=a+88|0;I=A;while(1){J=f[r>>2]|0;K=I+-1|0;L=J+K|0;M=f[y>>2]|0;N=f[M+(((L>>>0)/341|0)<<2)>>2]|0;O=(L>>>0)%341|0;L=f[N+(O*12|0)>>2]|0;P=f[N+(O*12|0)+4>>2]|0;Q=f[N+(O*12|0)+8>>2]|0;f[x>>2]=K;K=f[z>>2]|0;O=K-M>>2;if((1-I-J+((O|0)==0?0:(O*341|0)+-1|0)|0)>>>0>681){lp(f[K+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}K=f[l>>2]|0;O=K+(Q*12|0)|0;J=(f[s>>2]|0)+(Q*12|0)|0;if(L>>>0>c>>>0){B=0;break a}M=vl(a,L,J,P)|0;if(M>>>0>=(f[h>>2]|0)>>>0){B=0;break a}P=(f[a>>2]|0)-(f[(f[J>>2]|0)+(M<<2)>>2]|0)|0;b:do if(!P)if(!L)R=23;else{N=0;while(1){S=f[p>>2]|0;c:do if((f[t>>2]|0)!=(S|0)){T=S;U=0;do{V=T;W=f[V+(U*20|0)>>2]|0;X=V+(U*20|0)+12|0;Y=V+(U*20|0)+16|0;Z=(f[O>>2]|0)+(f[V+(U*20|0)+4>>2]<<2)|0;V=f[X>>2]|0;do if((V|0)==4)$=Z;else{aa=f[m>>2]|0;if(!(f[Y>>2]|0)){$=aa;break}else{ba=V;ca=aa;da=0}while(1){Ff(ca|0,Z+(da<<2)|0,ba|0)|0;da=da+1|0;aa=f[X>>2]|0;if(da>>>0>=(f[Y>>2]|0)>>>0)break;else{ba=aa;ca=ca+aa|0}}$=f[m>>2]|0}while(0);Y=f[v>>2]|0;if(!(b[W+84>>0]|0))ea=f[(f[W+68>>2]|0)+(Y<<2)>>2]|0;else ea=Y;if(ea>>>0>=(f[W+80>>2]|0)>>>0)break c;Y=W+40|0;X=f[Y>>2]|0;Z=fl(X|0,f[Y+4>>2]|0,ea|0,0)|0;Ff((f[f[W+64>>2]>>2]|0)+Z|0,$|0,X|0)|0;U=U+1|0;T=f[p>>2]|0}while(U>>>0<(((f[t>>2]|0)-T|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;N=N+1|0;if((N|0)==(L|0)){R=23;break}}}else if(L>>>0<3){N=f[q>>2]|0;f[N>>2]=M;S=f[h>>2]|0;if(S>>>0>1){T=S;U=M;X=1;while(1){U=(U|0)==(T+-1|0)?0:U+1|0;f[N+(X<<2)>>2]=U;X=X+1|0;Z=f[h>>2]|0;if(X>>>0>=Z>>>0){fa=Z;break}else T=Z}}else fa=S;if(!L){R=23;break}T=fa;X=0;while(1){if(T|0){U=f[q>>2]|0;N=f[k>>2]|0;Z=f[J>>2]|0;Y=0;do{V=U+(Y<<2)|0;f[N+(f[V>>2]<<2)>>2]=0;aa=f[V>>2]|0;ga=(f[a>>2]|0)-(f[Z+(aa<<2)>>2]|0)|0;do if(ga|0){ha=N+(aa<<2)|0;ia=f[j>>2]|0;ja=32-ia|0;if((ga|0)>(ja|0)){ka=f[i>>2]|0;la=ka+4|0;if((la|0)==(f[n>>2]|0)){f[ha>>2]=0;break}else{ma=f[ka>>2]<>2]=ka;f[i>>2]=la;na=32-ka|0;f[ha>>2]=(f[la>>2]|0)>>>na|ma>>>(na-ja|0);break}}ja=f[i>>2]|0;if((ja|0)==(f[n>>2]|0)){f[ha>>2]=0;break}f[ha>>2]=f[ja>>2]<>>(32-ga|0);ia=(f[j>>2]|0)+ga|0;f[j>>2]=ia;if((ia|0)!=32)break;f[i>>2]=ja+4;f[j>>2]=0}while(0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+(1<>2]|0;Y=32-T|0;do if((S|0)>(Y|0)){N=f[D>>2]|0;Z=N+4|0;if((Z|0)==(f[E>>2]|0))ua=0;else{V=f[N>>2]<>2]=N;f[D>>2]=Z;aa=32-N|0;ua=(f[Z>>2]|0)>>>aa|V>>>(aa-Y|0)}}else{aa=f[D>>2]|0;if((aa|0)==(f[E>>2]|0))ua=0;else{V=f[aa>>2]<>>(32-S|0);Z=T+S|0;f[C>>2]=Z;if((Z|0)!=32){ua=V;break}f[D>>2]=aa+4;f[C>>2]=0;ua=V}}while(0);S=(L>>>1)-ua|0;T=L-S|0;e:do if((S|0)==(T|0)){va=S;wa=S}else{Y=f[F>>2]|0;V=f[H>>2]|0;do if((V|0)!=(f[G>>2]|0)){aa=(f[V>>2]&1<<31-Y|0)!=0;Z=Y+1|0;f[F>>2]=Z;if((Z|0)==32){f[H>>2]=V+4;f[F>>2]=0;if(aa){va=S;wa=T;break e}else break}else if(aa){va=S;wa=T;break e}else break}while(0);va=T;wa=S}while(0);S=f[s>>2]|0;T=f[S+(Q*12|0)>>2]|0;V=T+(M<<2)|0;f[V>>2]=(f[V>>2]|0)+1;gf(S+(X*12|0)|0,T,f[S+(Q*12|0)+4>>2]|0);if(va|0){S=f[z>>2]|0;T=f[y>>2]|0;V=S-T>>2;Y=f[r>>2]|0;aa=f[x>>2]|0;if((((V|0)==0?0:(V*341|0)+-1|0)|0)==(aa+Y|0)){ic(g);xa=f[r>>2]|0;ya=f[x>>2]|0;za=f[z>>2]|0;Aa=f[y>>2]|0}else{xa=Y;ya=aa;za=S;Aa=T}T=ya+xa|0;if((za|0)==(Aa|0))Ba=0;else Ba=(f[Aa+(((T>>>0)/341|0)<<2)>>2]|0)+(((T>>>0)%341|0)*12|0)|0;f[Ba>>2]=va;f[Ba+4>>2]=M;f[Ba+8>>2]=Q;f[x>>2]=(f[x>>2]|0)+1}if(!wa){R=23;break}T=f[z>>2]|0;S=f[y>>2]|0;aa=T-S>>2;Y=f[r>>2]|0;V=f[x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)+-1|0)|0)>>>0>681){lp(f[K+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}K=f[l>>2]|0;O=K+(Q*12|0)|0;if(L>>>0>c>>>0){B=0;break a}J=f[h>>2]|0;M=(J+-1|0)==(P|0)?0:P+1|0;if(M>>>0>=J>>>0){B=0;break a}J=(f[s>>2]|0)+(Q*12|0)|0;P=(f[a>>2]|0)-(f[(f[J>>2]|0)+(M<<2)>>2]|0)|0;b:do if(!P)if(!L)R=23;else{N=0;while(1){S=f[p>>2]|0;c:do if((f[t>>2]|0)!=(S|0)){T=S;U=0;do{V=T;W=f[V+(U*20|0)>>2]|0;X=V+(U*20|0)+12|0;Y=V+(U*20|0)+16|0;Z=(f[O>>2]|0)+(f[V+(U*20|0)+4>>2]<<2)|0;V=f[X>>2]|0;do if((V|0)==4)$=Z;else{aa=f[m>>2]|0;if(!(f[Y>>2]|0)){$=aa;break}else{ba=V;ca=aa;da=0}while(1){Ff(ca|0,Z+(da<<2)|0,ba|0)|0;da=da+1|0;aa=f[X>>2]|0;if(da>>>0>=(f[Y>>2]|0)>>>0)break;else{ba=aa;ca=ca+aa|0}}$=f[m>>2]|0}while(0);Y=f[v>>2]|0;if(!(b[W+84>>0]|0))ea=f[(f[W+68>>2]|0)+(Y<<2)>>2]|0;else ea=Y;if(ea>>>0>=(f[W+80>>2]|0)>>>0)break c;Y=W+40|0;X=f[Y>>2]|0;Z=fl(X|0,f[Y+4>>2]|0,ea|0,0)|0;Ff((f[f[W+64>>2]>>2]|0)+Z|0,$|0,X|0)|0;U=U+1|0;T=f[p>>2]|0}while(U>>>0<(((f[t>>2]|0)-T|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;N=N+1|0;if((N|0)==(L|0)){R=23;break}}}else{if(L>>>0>=3){if((f[w>>2]|0)>>>0>(f[o>>2]|0)>>>0){B=0;break a}N=Q+1|0;gf(K+(N*12|0)|0,f[O>>2]|0,f[K+(Q*12|0)+4>>2]|0);S=(f[(f[l>>2]|0)+(N*12|0)>>2]|0)+(M<<2)|0;f[S>>2]=(f[S>>2]|0)+(1<>2]|0;U=32-T|0;if((S|0)>(U|0)){X=f[D>>2]|0;Z=X+4|0;if((Z|0)==(f[E>>2]|0))fa=0;else{Y=f[X>>2]<>2]=X;f[D>>2]=Z;V=32-X|0;fa=(f[Z>>2]|0)>>>V|Y>>>(V-U|0)}}else{U=f[D>>2]|0;if((U|0)!=(f[E>>2]|0)){V=f[U>>2]<>>(32-S|0);Y=T+S|0;f[C>>2]=Y;if((Y|0)==32){f[D>>2]=U+4;f[C>>2]=0;fa=V}else fa=V}else fa=0}V=(L>>>1)-fa|0;U=L-V|0;d:do if((V|0)==(U|0)){ga=V;ha=V}else{Y=f[F>>2]|0;S=f[H>>2]|0;do if((S|0)!=(f[G>>2]|0)){T=(f[S>>2]&1<<31-Y|0)!=0;Z=Y+1|0;f[F>>2]=Z;if((Z|0)==32){f[H>>2]=S+4;f[F>>2]=0;if(T){ga=V;ha=U;break d}else break}else if(T){ga=V;ha=U;break d}else break}while(0);ga=U;ha=V}while(0);V=f[s>>2]|0;U=f[V+(Q*12|0)>>2]|0;S=U+(M<<2)|0;f[S>>2]=(f[S>>2]|0)+1;gf(V+(N*12|0)|0,U,f[V+(Q*12|0)+4>>2]|0);if(ga|0){V=f[z>>2]|0;U=f[y>>2]|0;S=V-U>>2;Y=f[r>>2]|0;T=f[x>>2]|0;if((((S|0)==0?0:(S*341|0)+-1|0)|0)==(T+Y|0)){ic(g);ia=f[r>>2]|0;ja=f[x>>2]|0;ka=f[z>>2]|0;la=f[y>>2]|0}else{ia=Y;ja=T;ka=V;la=U}U=ja+ia|0;if((ka|0)==(la|0))ma=0;else ma=(f[la+(((U>>>0)/341|0)<<2)>>2]|0)+(((U>>>0)%341|0)*12|0)|0;f[ma>>2]=ga;f[ma+4>>2]=M;f[ma+8>>2]=Q;f[x>>2]=(f[x>>2]|0)+1}if(!ha){R=23;break}U=f[z>>2]|0;V=f[y>>2]|0;T=U-V>>2;Y=f[r>>2]|0;S=f[x>>2]|0;if((((T|0)==0?0:(T*341|0)+-1|0)|0)==(S+Y|0)){ic(g);na=f[r>>2]|0;oa=f[x>>2]|0;pa=f[z>>2]|0;qa=f[y>>2]|0}else{na=Y;oa=S;pa=U;qa=V}V=oa+na|0;if((pa|0)==(qa|0))ra=0;else ra=(f[qa+(((V>>>0)/341|0)<<2)>>2]|0)+(((V>>>0)%341|0)*12|0)|0;f[ra>>2]=ha;f[ra+4>>2]=M;f[ra+8>>2]=N;V=(f[x>>2]|0)+1|0;f[x>>2]=V;sa=V;break}V=f[q>>2]|0;f[V>>2]=M;U=f[h>>2]|0;if(U>>>0>1){S=U;Y=M;T=1;while(1){Y=(Y|0)==(S+-1|0)?0:Y+1|0;f[V+(T<<2)>>2]=Y;T=T+1|0;Z=f[h>>2]|0;if(T>>>0>=Z>>>0){ta=Z;break}else S=Z}}else ta=U;if(!L)R=23;else{S=ta;T=0;while(1){if(S|0){Y=f[q>>2]|0;V=f[k>>2]|0;N=f[J>>2]|0;Z=0;do{X=Y+(Z<<2)|0;f[V+(f[X>>2]<<2)>>2]=0;aa=f[X>>2]|0;ua=(f[a>>2]|0)-(f[N+(aa<<2)>>2]|0)|0;do if(ua|0){va=V+(aa<<2)|0;wa=f[j>>2]|0;xa=32-wa|0;if((ua|0)>(xa|0)){ya=f[i>>2]|0;za=ya+4|0;if((za|0)==(f[n>>2]|0)){f[va>>2]=0;break}else{Aa=f[ya>>2]<>2]=ya;f[i>>2]=za;Ba=32-ya|0;f[va>>2]=(f[za>>2]|0)>>>Ba|Aa>>>(Ba-xa|0);break}}xa=f[i>>2]|0;if((xa|0)==(f[n>>2]|0)){f[va>>2]=0;break}f[va>>2]=f[xa>>2]<>>(32-ua|0);wa=(f[j>>2]|0)+ua|0;f[j>>2]=wa;if((wa|0)!=32)break;f[i>>2]=xa+4;f[j>>2]=0}while(0);ua=f[X>>2]|0;aa=V+(ua<<2)|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))A=0;else A=(f[p+(((q>>>0)/341|0)<<2)>>2]|0)+(((q>>>0)%341|0)*12|0)|0;f[A>>2]=c;f[A+4>>2]=0;f[A+8>>2]=0;A=(f[x>>2]|0)+1|0;f[x>>2]=A;a:do if(!A)B=1;else{q=a+616|0;p=d+16|0;t=d+20|0;v=d+28|0;w=a+8|0;m=d+12|0;k=a+604|0;j=a+560|0;i=a+556|0;n=a+548|0;o=a+4|0;C=a+600|0;D=a+588|0;E=a+596|0;F=A;while(1){G=f[r>>2]|0;H=F+-1|0;I=G+H|0;J=f[y>>2]|0;K=f[J+(((I>>>0)/341|0)<<2)>>2]|0;L=(I>>>0)%341|0;I=f[K+(L*12|0)>>2]|0;M=f[K+(L*12|0)+4>>2]|0;N=f[K+(L*12|0)+8>>2]|0;f[x>>2]=H;H=f[z>>2]|0;L=H-J>>2;if((1-F-G+((L|0)==0?0:(L*341|0)+-1|0)|0)>>>0>681){lp(f[H+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}H=f[l>>2]|0;L=H+(N*12|0)|0;G=(f[s>>2]|0)+(N*12|0)|0;if(I>>>0>c>>>0){B=0;break a}J=Gg(a,I,G,M)|0;if(J>>>0>=(f[h>>2]|0)>>>0){B=0;break a}M=(f[a>>2]|0)-(f[(f[G>>2]|0)+(J<<2)>>2]|0)|0;b:do if(!M)if(!I)O=23;else{K=0;while(1){P=f[p>>2]|0;c:do if((f[t>>2]|0)!=(P|0)){Q=P;R=0;do{S=Q;T=f[S+(R*20|0)>>2]|0;U=S+(R*20|0)+12|0;V=S+(R*20|0)+16|0;W=(f[L>>2]|0)+(f[S+(R*20|0)+4>>2]<<2)|0;S=f[U>>2]|0;do if((S|0)==4)X=W;else{Y=f[m>>2]|0;if(!(f[V>>2]|0)){X=Y;break}else{Z=S;$=Y;aa=0}while(1){Ff($|0,W+(aa<<2)|0,Z|0)|0;aa=aa+1|0;Y=f[U>>2]|0;if(aa>>>0>=(f[V>>2]|0)>>>0)break;else{Z=Y;$=$+Y|0}}X=f[m>>2]|0}while(0);V=f[v>>2]|0;if(!(b[T+84>>0]|0))ba=f[(f[T+68>>2]|0)+(V<<2)>>2]|0;else ba=V;if(ba>>>0>=(f[T+80>>2]|0)>>>0)break c;V=T+40|0;U=f[V>>2]|0;W=fl(U|0,f[V+4>>2]|0,ba|0,0)|0;Ff((f[f[T+64>>2]>>2]|0)+W|0,X|0,U|0)|0;R=R+1|0;Q=f[p>>2]|0}while(R>>>0<(((f[t>>2]|0)-Q|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;K=K+1|0;if((K|0)==(I|0)){O=23;break}}}else{if(I>>>0>=3){if((f[w>>2]|0)>>>0>(f[o>>2]|0)>>>0){B=0;break a}K=N+1|0;P=f[l>>2]|0;Q=P+(K*12|0)|0;if((Q|0)==(L|0))ca=P;else{gf(Q,f[L>>2]|0,f[H+(N*12|0)+4>>2]|0);ca=f[l>>2]|0}Q=(f[ca+(K*12|0)>>2]|0)+(J<<2)|0;f[Q>>2]=(f[Q>>2]|0)+(1<>>1)-da|0;Q=I-R|0;d:do if((R|0)==(Q|0)){ea=R;fa=R}else{P=f[C>>2]|0;U=f[E>>2]|0;do if((U|0)!=(f[D>>2]|0)){W=(f[U>>2]&1<<31-P|0)!=0;V=P+1|0;f[C>>2]=V;if((V|0)==32){f[E>>2]=U+4;f[C>>2]=0;if(W){ea=R;fa=Q;break d}else break}else if(W){ea=R;fa=Q;break d}else break}while(0);ea=Q;fa=R}while(0);R=f[s>>2]|0;Q=f[R+(N*12|0)>>2]|0;U=Q+(J<<2)|0;f[U>>2]=(f[U>>2]|0)+1;gf(R+(K*12|0)|0,Q,f[R+(N*12|0)+4>>2]|0);if(ea|0){R=f[z>>2]|0;Q=f[y>>2]|0;U=R-Q>>2;P=f[r>>2]|0;W=f[x>>2]|0;if((((U|0)==0?0:(U*341|0)+-1|0)|0)==(W+P|0)){ic(g);ga=f[r>>2]|0;ha=f[x>>2]|0;ia=f[z>>2]|0;ja=f[y>>2]|0}else{ga=P;ha=W;ia=R;ja=Q}Q=ha+ga|0;if((ia|0)==(ja|0))ka=0;else ka=(f[ja+(((Q>>>0)/341|0)<<2)>>2]|0)+(((Q>>>0)%341|0)*12|0)|0;f[ka>>2]=ea;f[ka+4>>2]=J;f[ka+8>>2]=N;f[x>>2]=(f[x>>2]|0)+1}if(!fa){O=23;break}Q=f[z>>2]|0;R=f[y>>2]|0;W=Q-R>>2;P=f[r>>2]|0;U=f[x>>2]|0;if((((W|0)==0?0:(W*341|0)+-1|0)|0)==(U+P|0)){ic(g);la=f[r>>2]|0;ma=f[x>>2]|0;na=f[z>>2]|0;oa=f[y>>2]|0}else{la=P;ma=U;na=Q;oa=R}R=ma+la|0;if((na|0)==(oa|0))pa=0;else pa=(f[oa+(((R>>>0)/341|0)<<2)>>2]|0)+(((R>>>0)%341|0)*12|0)|0;f[pa>>2]=fa;f[pa+4>>2]=J;f[pa+8>>2]=K;R=(f[x>>2]|0)+1|0;f[x>>2]=R;qa=R;break}R=f[q>>2]|0;f[R>>2]=J;Q=f[h>>2]|0;if(Q>>>0>1){U=Q;P=J;W=1;while(1){P=(P|0)==(U+-1|0)?0:P+1|0;f[R+(W<<2)>>2]=P;W=W+1|0;V=f[h>>2]|0;if(W>>>0>=V>>>0){ra=V;break}else U=V}}else ra=Q;if(!I)O=23;else{U=ra;W=0;while(1){if(U|0){P=f[q>>2]|0;R=f[k>>2]|0;K=f[G>>2]|0;V=0;do{S=P+(V<<2)|0;f[R+(f[S>>2]<<2)>>2]=0;Y=f[S>>2]|0;sa=(f[a>>2]|0)-(f[K+(Y<<2)>>2]|0)|0;do if(sa|0){ta=R+(Y<<2)|0;ua=f[j>>2]|0;va=32-ua|0;if((sa|0)>(va|0)){wa=f[i>>2]|0;xa=wa+4|0;if((xa|0)==(f[n>>2]|0)){f[ta>>2]=0;break}else{ya=f[wa>>2]<>2]=wa;f[i>>2]=xa;za=32-wa|0;f[ta>>2]=(f[xa>>2]|0)>>>za|ya>>>(za-va|0);break}}va=f[i>>2]|0;if((va|0)==(f[n>>2]|0)){f[ta>>2]=0;break}f[ta>>2]=f[va>>2]<>>(32-sa|0);ua=(f[j>>2]|0)+sa|0;f[j>>2]=ua;if((ua|0)!=32)break;f[i>>2]=va+4;f[j>>2]=0}while(0);sa=f[S>>2]|0;Y=R+(sa<<2)|0;f[Y>>2]=f[Y>>2]|f[(f[L>>2]|0)+(sa<<2)>>2];V=V+1|0}while(V>>>0<(f[h>>2]|0)>>>0)}V=f[p>>2]|0;e:do if((f[t>>2]|0)!=(V|0)){R=V;K=0;do{P=R;sa=f[P+(K*20|0)>>2]|0;Y=P+(K*20|0)+12|0;va=P+(K*20|0)+16|0;ua=(f[k>>2]|0)+(f[P+(K*20|0)+4>>2]<<2)|0;P=f[Y>>2]|0;do if((P|0)==4)Aa=ua;else{ta=f[m>>2]|0;if(!(f[va>>2]|0)){Aa=ta;break}else{Ba=P;Ca=ta;Da=0}while(1){Ff(Ca|0,ua+(Da<<2)|0,Ba|0)|0;Da=Da+1|0;ta=f[Y>>2]|0;if(Da>>>0>=(f[va>>2]|0)>>>0)break;else{Ba=ta;Ca=Ca+ta|0}}Aa=f[m>>2]|0}while(0);va=f[v>>2]|0;if(!(b[sa+84>>0]|0))Ea=f[(f[sa+68>>2]|0)+(va<<2)>>2]|0;else Ea=va;if(Ea>>>0>=(f[sa+80>>2]|0)>>>0)break e;va=sa+40|0;Y=f[va>>2]|0;ua=fl(Y|0,f[va+4>>2]|0,Ea|0,0)|0;Ff((f[f[sa+64>>2]>>2]|0)+ua|0,Aa|0,Y|0)|0;K=K+1|0;R=f[p>>2]|0}while(K>>>0<(((f[t>>2]|0)-R|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;V=W+1|0;if((V|0)==(I|0)){O=23;break b}U=f[h>>2]|0;W=V}}}while(0);if((O|0)==23){O=0;qa=f[x>>2]|0}if(!qa){B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f[z>>2]=f[g+8>>2];f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;f[g+16>>2]=0;f[g+20>>2]=0;z=g+8|0;y=g+4|0;r=g+16|0;x=g+20|0;ic(g);p=f[y>>2]|0;q=(f[x>>2]|0)+(f[r>>2]|0)|0;if((f[z>>2]|0)==(p|0))A=0;else A=(f[p+(((q>>>0)/341|0)<<2)>>2]|0)+(((q>>>0)%341|0)*12|0)|0;f[A>>2]=c;f[A+4>>2]=0;f[A+8>>2]=0;A=(f[x>>2]|0)+1|0;f[x>>2]=A;a:do if(!A)B=1;else{q=a+616|0;p=d+16|0;t=d+20|0;v=d+28|0;w=a+8|0;m=d+12|0;k=a+604|0;j=a+560|0;i=a+556|0;n=a+548|0;o=a+4|0;C=a+600|0;D=a+588|0;E=a+596|0;F=A;while(1){G=f[r>>2]|0;H=F+-1|0;I=G+H|0;J=f[y>>2]|0;K=f[J+(((I>>>0)/341|0)<<2)>>2]|0;L=(I>>>0)%341|0;I=f[K+(L*12|0)>>2]|0;M=f[K+(L*12|0)+4>>2]|0;N=f[K+(L*12|0)+8>>2]|0;f[x>>2]=H;H=f[z>>2]|0;L=H-J>>2;if((1-F-G+((L|0)==0?0:(L*341|0)+-1|0)|0)>>>0>681){lp(f[H+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}H=f[l>>2]|0;L=H+(N*12|0)|0;G=(f[s>>2]|0)+(N*12|0)|0;if(I>>>0>c>>>0){B=0;break a}J=vl(a,I,G,M)|0;if(J>>>0>=(f[h>>2]|0)>>>0){B=0;break a}M=(f[a>>2]|0)-(f[(f[G>>2]|0)+(J<<2)>>2]|0)|0;b:do if(!M)if(!I)O=23;else{K=0;while(1){P=f[p>>2]|0;c:do if((f[t>>2]|0)!=(P|0)){Q=P;R=0;do{S=Q;T=f[S+(R*20|0)>>2]|0;U=S+(R*20|0)+12|0;V=S+(R*20|0)+16|0;W=(f[L>>2]|0)+(f[S+(R*20|0)+4>>2]<<2)|0;S=f[U>>2]|0;do if((S|0)==4)X=W;else{Y=f[m>>2]|0;if(!(f[V>>2]|0)){X=Y;break}else{Z=S;$=Y;aa=0}while(1){Ff($|0,W+(aa<<2)|0,Z|0)|0;aa=aa+1|0;Y=f[U>>2]|0;if(aa>>>0>=(f[V>>2]|0)>>>0)break;else{Z=Y;$=$+Y|0}}X=f[m>>2]|0}while(0);V=f[v>>2]|0;if(!(b[T+84>>0]|0))ba=f[(f[T+68>>2]|0)+(V<<2)>>2]|0;else ba=V;if(ba>>>0>=(f[T+80>>2]|0)>>>0)break c;V=T+40|0;U=f[V>>2]|0;W=fl(U|0,f[V+4>>2]|0,ba|0,0)|0;Ff((f[f[T+64>>2]>>2]|0)+W|0,X|0,U|0)|0;R=R+1|0;Q=f[p>>2]|0}while(R>>>0<(((f[t>>2]|0)-Q|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;K=K+1|0;if((K|0)==(I|0)){O=23;break}}}else{if(I>>>0>=3){if((f[w>>2]|0)>>>0>(f[o>>2]|0)>>>0){B=0;break a}K=N+1|0;P=f[l>>2]|0;Q=P+(K*12|0)|0;if((Q|0)==(L|0))ca=P;else{gf(Q,f[L>>2]|0,f[H+(N*12|0)+4>>2]|0);ca=f[l>>2]|0}Q=(f[ca+(K*12|0)>>2]|0)+(J<<2)|0;f[Q>>2]=(f[Q>>2]|0)+(1<>>1)-da|0;Q=I-R|0;d:do if((R|0)==(Q|0)){ea=R;fa=R}else{P=f[C>>2]|0;U=f[E>>2]|0;do if((U|0)!=(f[D>>2]|0)){W=(f[U>>2]&1<<31-P|0)!=0;V=P+1|0;f[C>>2]=V;if((V|0)==32){f[E>>2]=U+4;f[C>>2]=0;if(W){ea=R;fa=Q;break d}else break}else if(W){ea=R;fa=Q;break d}else break}while(0);ea=Q;fa=R}while(0);R=f[s>>2]|0;Q=f[R+(N*12|0)>>2]|0;U=Q+(J<<2)|0;f[U>>2]=(f[U>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2)>>2]|0)|0;do if(sa|0){ta=R+(Y<<2)|0;ua=f[j>>2]|0;va=32-ua|0;if((sa|0)>(va|0)){wa=f[i>>2]|0;xa=wa+4|0;if((xa|0)==(f[n>>2]|0)){f[ta>>2]=0;break}else{ya=f[wa>>2]<>2]=wa;f[i>>2]=xa;za=32-wa|0;f[ta>>2]=(f[xa>>2]|0)>>>za|ya>>>(za-va|0);break}}va=f[i>>2]|0;if((va|0)==(f[n>>2]|0)){f[ta>>2]=0;break}f[ta>>2]=f[va>>2]<>>(32-sa|0);ua=(f[j>>2]|0)+sa|0;f[j>>2]=ua;if((ua|0)!=32)break;f[i>>2]=va+4;f[j>>2]=0}while(0);sa=f[S>>2]|0;Y=R+(sa<<2)|0;f[Y>>2]=f[Y>>2]|f[(f[L>>2]|0)+(sa<<2)>>2];V=V+1|0}while(V>>>0<(f[h>>2]|0)>>>0)}V=f[p>>2]|0;e:do if((f[t>>2]|0)!=(V|0)){R=V;K=0;do{P=R;sa=f[P+(K*20|0)>>2]|0;Y=P+(K*20|0)+12|0;va=P+(K*20|0)+16|0;ua=(f[k>>2]|0)+(f[P+(K*20|0)+4>>2]<<2)|0;P=f[Y>>2]|0;do if((P|0)==4)Aa=ua;else{ta=f[m>>2]|0;if(!(f[va>>2]|0)){Aa=ta;break}else{Ba=P;Ca=ta;Da=0}while(1){Ff(Ca|0,ua+(Da<<2)|0,Ba|0)|0;Da=Da+1|0;ta=f[Y>>2]|0;if(Da>>>0>=(f[va>>2]|0)>>>0)break;else{Ba=ta;Ca=Ca+ta|0}}Aa=f[m>>2]|0}while(0);va=f[v>>2]|0;if(!(b[sa+84>>0]|0))Ea=f[(f[sa+68>>2]|0)+(va<<2)>>2]|0;else Ea=va;if(Ea>>>0>=(f[sa+80>>2]|0)>>>0)break e;va=sa+40|0;Y=f[va>>2]|0;ua=fl(Y|0,f[va+4>>2]|0,Ea|0,0)|0;Ff((f[f[sa+64>>2]>>2]|0)+ua|0,Aa|0,Y|0)|0;K=K+1|0;R=f[p>>2]|0}while(K>>>0<(((f[t>>2]|0)-R|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;V=W+1|0;if((V|0)==(I|0)){O=23;break b}U=f[h>>2]|0;W=V}}}while(0);if((O|0)==23){O=0;qa=f[x>>2]|0}if(!qa){B=1;break}else F=qa}}while(0);qa=f[y>>2]|0;h=f[r>>2]|0;Aa=qa+(((h>>>0)/341|0)<<2)|0;Ea=f[z>>2]|0;Ca=Ea;Ba=qa;if((Ea|0)==(qa|0)){Fa=0;Ga=0}else{Da=(f[x>>2]|0)+h|0;Fa=(f[qa+(((Da>>>0)/341|0)<<2)>>2]|0)+(((Da>>>0)%341|0)*12|0)|0;Ga=(f[Aa>>2]|0)+(((h>>>0)%341|0)*12|0)|0}h=Aa;Aa=Ga;f:while(1){Ga=Aa;do{Da=Ga;if((Da|0)==(Fa|0))break f;Ga=Da+12|0}while((Ga-(f[h>>2]|0)|0)!=4092);Ga=h+4|0;h=Ga;Aa=f[Ga>>2]|0}f[x>>2]=0;x=Ca-Ba>>2;if(x>>>0>2){Ba=qa;do{lp(f[Ba>>2]|0);Ba=(f[y>>2]|0)+4|0;f[y>>2]=Ba;Ha=f[z>>2]|0;Ia=Ha-Ba>>2}while(Ia>>>0>2);Ja=Ba;Ka=Ha;La=Ia}else{Ja=qa;Ka=Ea;La=x}switch(La|0){case 1:{Ma=170;O=105;break}case 2:{Ma=341;O=105;break}default:{}}if((O|0)==105)f[r>>2]=Ma;if((Ja|0)!=(Ka|0)){Ma=Ja;do{lp(f[Ma>>2]|0);Ma=Ma+4|0}while((Ma|0)!=(Ka|0));Ka=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(Ka|0))f[z>>2]=y+(~((y+-4-Ka|0)>>>2)<<2)}Ka=f[g>>2]|0;if(!Ka){u=e;return B|0}lp(Ka);u=e;return B|0}function hb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,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]|0)+(J<<2)>>2]|0)|0;b:do if(!M)if(!I)O=23;else{K=0;while(1){P=f[p>>2]|0;c:do if((f[t>>2]|0)!=(P|0)){Q=P;R=0;do{S=Q;T=f[S+(R*20|0)>>2]|0;U=S+(R*20|0)+12|0;V=S+(R*20|0)+16|0;W=(f[L>>2]|0)+(f[S+(R*20|0)+4>>2]<<2)|0;S=f[U>>2]|0;do if((S|0)==4)X=W;else{Y=f[m>>2]|0;if(!(f[V>>2]|0)){X=Y;break}else{Z=S;$=Y;aa=0}while(1){Ff($|0,W+(aa<<2)|0,Z|0)|0;aa=aa+1|0;Y=f[U>>2]|0;if(aa>>>0>=(f[V>>2]|0)>>>0)break;else{Z=Y;$=$+Y|0}}X=f[m>>2]|0}while(0);V=f[v>>2]|0;if(!(b[T+84>>0]|0))ba=f[(f[T+68>>2]|0)+(V<<2)>>2]|0;else ba=V;if(ba>>>0>=(f[T+80>>2]|0)>>>0)break c;V=T+40|0;U=f[V>>2]|0;W=fl(U|0,f[V+4>>2]|0,ba|0,0)|0;Ff((f[f[T+64>>2]>>2]|0)+W|0,X|0,U|0)|0;R=R+1|0;Q=f[p>>2]|0}while(R>>>0<(((f[t>>2]|0)-Q|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;K=K+1|0;if((K|0)==(I|0)){O=23;break}}}else{if(I>>>0>=3){if((f[w>>2]|0)>>>0>(f[o>>2]|0)>>>0){B=0;break a}K=N+1|0;gf(H+(K*12|0)|0,f[L>>2]|0,f[H+(N*12|0)+4>>2]|0);P=(f[(f[l>>2]|0)+(K*12|0)>>2]|0)+(J<<2)|0;f[P>>2]=(f[P>>2]|0)+(1<>>1)-ca|0;P=I-R|0;d:do if((R|0)==(P|0)){da=R;ea=R}else{Q=f[C>>2]|0;U=f[E>>2]|0;do if((U|0)!=(f[D>>2]|0)){W=(f[U>>2]&1<<31-Q|0)!=0;V=Q+1|0;f[C>>2]=V;if((V|0)==32){f[E>>2]=U+4;f[C>>2]=0;if(W){da=R;ea=P;break d}else break}else if(W){da=R;ea=P;break d}else break}while(0);da=P;ea=R}while(0);R=f[s>>2]|0;P=f[R+(N*12|0)>>2]|0;U=P+(J<<2)|0;f[U>>2]=(f[U>>2]|0)+1;gf(R+(K*12|0)|0,P,f[R+(N*12|0)+4>>2]|0);if(da|0){R=f[z>>2]|0;P=f[y>>2]|0;U=R-P>>2;Q=f[r>>2]|0;W=f[x>>2]|0;if((((U|0)==0?0:(U*341|0)+-1|0)|0)==(W+Q|0)){ic(g);fa=f[r>>2]|0;ga=f[x>>2]|0;ha=f[z>>2]|0;ia=f[y>>2]|0}else{fa=Q;ga=W;ha=R;ia=P}P=ga+fa|0;if((ha|0)==(ia|0))ja=0;else ja=(f[ia+(((P>>>0)/341|0)<<2)>>2]|0)+(((P>>>0)%341|0)*12|0)|0;f[ja>>2]=da;f[ja+4>>2]=J;f[ja+8>>2]=N;f[x>>2]=(f[x>>2]|0)+1}if(!ea){O=23;break}P=f[z>>2]|0;R=f[y>>2]|0;W=P-R>>2;Q=f[r>>2]|0;U=f[x>>2]|0;if((((W|0)==0?0:(W*341|0)+-1|0)|0)==(U+Q|0)){ic(g);ka=f[r>>2]|0;la=f[x>>2]|0;ma=f[z>>2]|0;na=f[y>>2]|0}else{ka=Q;la=U;ma=P;na=R}R=la+ka|0;if((ma|0)==(na|0))oa=0;else oa=(f[na+(((R>>>0)/341|0)<<2)>>2]|0)+(((R>>>0)%341|0)*12|0)|0;f[oa>>2]=ea;f[oa+4>>2]=J;f[oa+8>>2]=K;R=(f[x>>2]|0)+1|0;f[x>>2]=R;pa=R;break}R=f[q>>2]|0;f[R>>2]=J;P=f[h>>2]|0;if(P>>>0>1){U=P;Q=J;W=1;while(1){Q=(Q|0)==(U+-1|0)?0:Q+1|0;f[R+(W<<2)>>2]=Q;W=W+1|0;V=f[h>>2]|0;if(W>>>0>=V>>>0){qa=V;break}else U=V}}else qa=P;if(!I)O=23;else{U=qa;W=0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Da=ua;if(Da>>>0>=(f[ra+80>>2]|0)>>>0)break e;ua=ra+40|0;Y=f[ua>>2]|0;ta=fl(Y|0,f[ua+4>>2]|0,Da|0,0)|0;Ff((f[f[ra+64>>2]>>2]|0)+ta|0,za|0,Y|0)|0;K=K+1|0;R=f[p>>2]|0}while(K>>>0<(((f[t>>2]|0)-R|0)/20|0)>>>0)}while(0);f[v>>2]=(f[v>>2]|0)+1;f[w>>2]=(f[w>>2]|0)+1;V=W+1|0;if((V|0)==(I|0)){O=23;break b}U=f[h>>2]|0;W=V}}}while(0);if((O|0)==23){O=0;pa=f[x>>2]|0}if(!pa){B=1;break}else F=pa}}while(0);pa=f[y>>2]|0;h=f[r>>2]|0;za=pa+(((h>>>0)/341|0)<<2)|0;Da=f[z>>2]|0;Ba=Da;Aa=pa;if((Da|0)==(pa|0)){Ea=0;Fa=0}else{Ca=(f[x>>2]|0)+h|0;Ea=(f[pa+(((Ca>>>0)/341|0)<<2)>>2]|0)+(((Ca>>>0)%341|0)*12|0)|0;Fa=(f[za>>2]|0)+(((h>>>0)%341|0)*12|0)|0}h=za;za=Fa;f:while(1){Fa=za;do{Ca=Fa;if((Ca|0)==(Ea|0))break f;Fa=Ca+12|0}while((Fa-(f[h>>2]|0)|0)!=4092);Fa=h+4|0;h=Fa;za=f[Fa>>2]|0}f[x>>2]=0;x=Ba-Aa>>2;if(x>>>0>2){Aa=pa;do{lp(f[Aa>>2]|0);Aa=(f[y>>2]|0)+4|0;f[y>>2]=Aa;Ga=f[z>>2]|0;Ha=Ga-Aa>>2}while(Ha>>>0>2);Ia=Aa;Ja=Ga;Ka=Ha}else{Ia=pa;Ja=Da;Ka=x}switch(Ka|0){case 1:{La=170;O=103;break}case 2:{La=341;O=103;break}default:{}}if((O|0)==103)f[r>>2]=La;if((Ia|0)!=(Ja|0)){La=Ia;do{lp(f[La>>2]|0);La=La+4|0}while((La|0)!=(Ja|0));Ja=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(Ja|0))f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]|0;N=J+(P*12|0)|0;I=(f[t>>2]|0)+(P*12|0)|0;if(K>>>0>c>>>0){C=0;break a}L=vl(a,K,I,O)|0;if(L>>>0>=(f[i>>2]|0)>>>0){C=0;break a}O=(f[a>>2]|0)-(f[(f[I>>2]|0)+(L<<2)>>2]|0)|0;b:do if(!O){if(K|0){M=0;do{Q=f[q>>2]|0;c:do if((f[v>>2]|0)!=(Q|0)){R=Q;S=0;do{T=R;U=f[T+(S*20|0)>>2]|0;V=T+(S*20|0)+12|0;W=T+(S*20|0)+16|0;X=(f[N>>2]|0)+(f[T+(S*20|0)+4>>2]<<2)|0;T=f[V>>2]|0;do if((T|0)==4)Y=X;else{Z=f[n>>2]|0;if(!(f[W>>2]|0)){Y=Z;break}else{$=T;aa=Z;ba=0}while(1){Ff(aa|0,X+(ba<<2)|0,$|0)|0;ba=ba+1|0;Z=f[V>>2]|0;if(ba>>>0>=(f[W>>2]|0)>>>0)break;else{$=Z;aa=aa+Z|0}}Y=f[n>>2]|0}while(0);W=f[w>>2]|0;if(!(b[U+84>>0]|0))ca=f[(f[U+68>>2]|0)+(W<<2)>>2]|0;else ca=W;if(ca>>>0>=(f[U+80>>2]|0)>>>0)break c;W=U+40|0;V=f[W>>2]|0;X=fl(V|0,f[W+4>>2]|0,ca|0,0)|0;Ff((f[f[U+64>>2]>>2]|0)+X|0,Y|0,V|0)|0;S=S+1|0;R=f[q>>2]|0}while(S>>>0<(((f[v>>2]|0)-R|0)/20|0)>>>0)}while(0);f[w>>2]=(f[w>>2]|0)+1;f[x>>2]=(f[x>>2]|0)+1;M=M+1|0}while((M|0)!=(K|0))}}else{if(K>>>0>=3){if((f[x>>2]|0)>>>0>(f[p>>2]|0)>>>0){C=0;break a}M=P+1|0;Q=f[m>>2]|0;R=Q+(M*12|0)|0;if((R|0)==(N|0))da=Q;else{gf(R,f[N>>2]|0,f[J+(P*12|0)+4>>2]|0);da=f[m>>2]|0}R=(f[da+(M*12|0)>>2]|0)+(L<<2)|0;f[R>>2]=(f[R>>2]|0)+(1<>2]=0;Eh(D,R,h);R=(K>>>1)-(f[h>>2]|0)|0;Q=K-R|0;d:do if((R|0)==(Q|0)){ea=R;fa=R}else{S=f[E>>2]|0;V=f[G>>2]|0;do if((V|0)!=(f[F>>2]|0)){X=(f[V>>2]&1<<31-S|0)!=0;W=S+1|0;f[E>>2]=W;if((W|0)==32){f[G>>2]=V+4;f[E>>2]=0;if(X){ea=R;fa=Q;break d}else break}else if(X){ea=R;fa=Q;break d}else break}while(0);ea=Q;fa=R}while(0);R=f[t>>2]|0;Q=f[R+(P*12|0)>>2]|0;V=Q+(L<<2)|0;f[V>>2]=(f[V>>2]|0)+1;gf(R+(M*12|0)|0,Q,f[R+(P*12|0)+4>>2]|0);if(ea|0){R=f[A>>2]|0;Q=f[z>>2]|0;V=R-Q>>2;S=f[s>>2]|0;X=f[y>>2]|0;if((((V|0)==0?0:(V*341|0)+-1|0)|0)==(X+S|0)){ic(g);ga=f[s>>2]|0;ha=f[y>>2]|0;ia=f[A>>2]|0;ja=f[z>>2]|0}else{ga=S;ha=X;ia=R;ja=Q}Q=ha+ga|0;if((ia|0)==(ja|0))ka=0;else ka=(f[ja+(((Q>>>0)/341|0)<<2)>>2]|0)+(((Q>>>0)%341|0)*12|0)|0;f[ka>>2]=ea;f[ka+4>>2]=L;f[ka+8>>2]=P;f[y>>2]=(f[y>>2]|0)+1}if(fa|0){Q=f[A>>2]|0;R=f[z>>2]|0;X=Q-R>>2;S=f[s>>2]|0;V=f[y>>2]|0;if((((X|0)==0?0:(X*341|0)+-1|0)|0)==(V+S|0)){ic(g);la=f[s>>2]|0;ma=f[y>>2]|0;na=f[A>>2]|0;oa=f[z>>2]|0}else{la=S;ma=V;na=Q;oa=R}R=ma+la|0;if((na|0)==(oa|0))pa=0;else pa=(f[oa+(((R>>>0)/341|0)<<2)>>2]|0)+(((R>>>0)%341|0)*12|0)|0;f[pa>>2]=fa;f[pa+4>>2]=L;f[pa+8>>2]=M;f[y>>2]=(f[y>>2]|0)+1}break}R=f[r>>2]|0;f[R>>2]=L;Q=f[i>>2]|0;if(Q>>>0>1){V=Q;S=L;X=1;while(1){S=(S|0)==(V+-1|0)?0:S+1|0;f[R+(X<<2)>>2]=S;X=X+1|0;W=f[i>>2]|0;if(X>>>0>=W>>>0){qa=W;break}else V=W}}else qa=Q;if(K|0){V=qa;X=0;while(1){if(V|0){S=f[r>>2]|0;R=f[l>>2]|0;M=f[I>>2]|0;W=0;do{T=S+(W<<2)|0;f[R+(f[T>>2]<<2)>>2]=0;Z=f[T>>2]|0;ra=(f[a>>2]|0)-(f[M+(Z<<2)>>2]|0)|0;do if(ra|0){sa=R+(Z<<2)|0;ta=f[k>>2]|0;ua=32-ta|0;if((ra|0)>(ua|0)){va=f[j>>2]|0;wa=va+4|0;if((wa|0)==(f[o>>2]|0)){f[sa>>2]=0;break}else{xa=f[va>>2]<>2]=va;f[j>>2]=wa;ya=32-va|0;f[sa>>2]=(f[wa>>2]|0)>>>ya|xa>>>(ya-ua|0);break}}ua=f[j>>2]|0;if((ua|0)==(f[o>>2]|0)){f[sa>>2]=0;break}f[sa>>2]=f[ua>>2]<>>(32-ra|0);ta=(f[k>>2]|0)+ra|0;f[k>>2]=ta;if((ta|0)!=32)break;f[j>>2]=ua+4;f[k>>2]=0}while(0);ra=f[T>>2]|0;Z=R+(ra<<2)|0;f[Z>>2]=f[Z>>2]|f[(f[N>>2]|0)+(ra<<2)>>2];W=W+1|0}while(W>>>0<(f[i>>2]|0)>>>0)}W=f[q>>2]|0;e:do if((f[v>>2]|0)!=(W|0)){R=W;M=0;do{S=R;ra=f[S+(M*20|0)>>2]|0;Z=S+(M*20|0)+12|0;ua=S+(M*20|0)+16|0;ta=(f[l>>2]|0)+(f[S+(M*20|0)+4>>2]<<2)|0;S=f[Z>>2]|0;do if((S|0)==4)za=ta;else{sa=f[n>>2]|0;if(!(f[ua>>2]|0)){za=sa;break}else{Aa=S;Ba=sa;Ca=0}while(1){Ff(Ba|0,ta+(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]|0;P=f[M+(N*12|0)+8>>2]|0;f[y>>2]=J;J=f[A>>2]|0;N=J-L>>2;if((1-H-I+((N|0)==0?0:(N*341|0)+-1|0)|0)>>>0>681){lp(f[J+-4>>2]|0);f[A>>2]=(f[A>>2]|0)+-4}J=f[m>>2]|0;N=J+(P*12|0)|0;if(K>>>0>c>>>0){C=0;break a}I=f[i>>2]|0;L=(I+-1|0)==(O|0)?0:O+1|0;if(L>>>0>=I>>>0){C=0;break a}I=(f[t>>2]|0)+(P*12|0)|0;O=(f[a>>2]|0)-(f[(f[I>>2]|0)+(L<<2)>>2]|0)|0;b:do if(!O){if(K|0){M=0;do{Q=f[q>>2]|0;c:do if((f[v>>2]|0)!=(Q|0)){R=Q;S=0;do{T=R;U=f[T+(S*20|0)>>2]|0;V=T+(S*20|0)+12|0;W=T+(S*20|0)+16|0;X=(f[N>>2]|0)+(f[T+(S*20|0)+4>>2]<<2)|0;T=f[V>>2]|0;do if((T|0)==4)Y=X;else{Z=f[n>>2]|0;if(!(f[W>>2]|0)){Y=Z;break}else{$=T;aa=Z;ba=0}while(1){Ff(aa|0,X+(ba<<2)|0,$|0)|0;ba=ba+1|0;Z=f[V>>2]|0;if(ba>>>0>=(f[W>>2]|0)>>>0)break;else{$=Z;aa=aa+Z|0}}Y=f[n>>2]|0}while(0);W=f[w>>2]|0;if(!(b[U+84>>0]|0))ca=f[(f[U+68>>2]|0)+(W<<2)>>2]|0;else ca=W;if(ca>>>0>=(f[U+80>>2]|0)>>>0)break c;W=U+40|0;V=f[W>>2]|0;X=fl(V|0,f[W+4>>2]|0,ca|0,0)|0;Ff((f[f[U+64>>2]>>2]|0)+X|0,Y|0,V|0)|0;S=S+1|0;R=f[q>>2]|0}while(S>>>0<(((f[v>>2]|0)-R|0)/20|0)>>>0)}while(0);f[w>>2]=(f[w>>2]|0)+1;f[x>>2]=(f[x>>2]|0)+1;M=M+1|0}while((M|0)!=(K|0))}}else{if(K>>>0>=3){if((f[x>>2]|0)>>>0>(f[p>>2]|0)>>>0){C=0;break a}M=P+1|0;gf(J+(M*12|0)|0,f[N>>2]|0,f[J+(P*12|0)+4>>2]|0);Q=(f[(f[m>>2]|0)+(M*12|0)>>2]|0)+(L<<2)|0;f[Q>>2]=(f[Q>>2]|0)+(1<>2]=0;Eh(D,Q,h);Q=(K>>>1)-(f[h>>2]|0)|0;R=K-Q|0;d:do if((Q|0)==(R|0)){da=Q;ea=Q}else{S=f[E>>2]|0;V=f[G>>2]|0;do if((V|0)!=(f[F>>2]|0)){X=(f[V>>2]&1<<31-S|0)!=0;W=S+1|0;f[E>>2]=W;if((W|0)==32){f[G>>2]=V+4;f[E>>2]=0;if(X){da=Q;ea=R;break d}else break}else if(X){da=Q;ea=R;break d}else break}while(0);da=R;ea=Q}while(0);Q=f[t>>2]|0;R=f[Q+(P*12|0)>>2]|0;V=R+(L<<2)|0;f[V>>2]=(f[V>>2]|0)+1;gf(Q+(M*12|0)|0,R,f[Q+(P*12|0)+4>>2]|0);if(da|0){Q=f[A>>2]|0;R=f[z>>2]|0;V=Q-R>>2;S=f[s>>2]|0;X=f[y>>2]|0;if((((V|0)==0?0:(V*341|0)+-1|0)|0)==(X+S|0)){ic(g);fa=f[s>>2]|0;ga=f[y>>2]|0;ha=f[A>>2]|0;ia=f[z>>2]|0}else{fa=S;ga=X;ha=Q;ia=R}R=ga+fa|0;if((ha|0)==(ia|0))ja=0;else ja=(f[ia+(((R>>>0)/341|0)<<2)>>2]|0)+(((R>>>0)%341|0)*12|0)|0;f[ja>>2]=da;f[ja+4>>2]=L;f[ja+8>>2]=P;f[y>>2]=(f[y>>2]|0)+1}if(ea|0){R=f[A>>2]|0;Q=f[z>>2]|0;X=R-Q>>2;S=f[s>>2]|0;V=f[y>>2]|0;if((((X|0)==0?0:(X*341|0)+-1|0)|0)==(V+S|0)){ic(g);ka=f[s>>2]|0;la=f[y>>2]|0;ma=f[A>>2]|0;na=f[z>>2]|0}else{ka=S;la=V;ma=R;na=Q}Q=la+ka|0;if((ma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I=A;while(1){J=f[r>>2]|0;K=I+-1|0;L=J+K|0;M=f[y>>2]|0;N=f[M+(((L>>>0)/341|0)<<2)>>2]|0;O=(L>>>0)%341|0;L=f[N+(O*12|0)>>2]|0;P=f[N+(O*12|0)+4>>2]|0;Q=f[N+(O*12|0)+8>>2]|0;f[x>>2]=K;K=f[z>>2]|0;O=K-M>>2;if((1-I-J+((O|0)==0?0:(O*341|0)+-1|0)|0)>>>0>681){lp(f[K+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}K=f[l>>2]|0;O=K+(Q*12|0)|0;J=(f[s>>2]|0)+(Q*12|0)|0;if(L>>>0>b>>>0){B=0;break a}M=vl(a,L,J,P)|0;if(M>>>0>=(f[h>>2]|0)>>>0){B=0;break a}P=(f[a>>2]|0)-(f[(f[J>>2]|0)+(M<<2)>>2]|0)|0;b:do if(!P)if(!L)R=23;else{N=0;do{S=f[O>>2]|0;T=f[S>>2]|0;f[e>>2]=T;f[G>>2]=f[S+4>>2];f[H>>2]=f[S+8>>2];S=f[c>>2]|0;U=S+4|0;V=f[U>>2]|0;if(V>>>0<(f[S+8>>2]|0)>>>0){f[V>>2]=T;f[V+4>>2]=f[G>>2];f[V+8>>2]=f[H>>2];f[U>>2]=V+12}else Kf(S,e);f[v>>2]=(f[v>>2]|0)+1;N=N+1|0}while(N>>>0>>0);R=23}else{if(L>>>0<3){N=f[q>>2]|0;f[N>>2]=M;S=f[h>>2]|0;if(S>>>0>1){V=S;U=M;T=1;while(1){U=(U|0)==(V+-1|0)?0:U+1|0;f[N+(T<<2)>>2]=U;T=T+1|0;W=f[h>>2]|0;if(T>>>0>=W>>>0){X=W;break}else V=W}}else X=S;if(!L){R=23;break}V=X;T=0;while(1){if(!V)Y=f[w>>2]|0;else{U=f[q>>2]|0;N=f[w>>2]|0;W=f[J>>2]|0;Z=0;do{$=U+(Z<<2)|0;f[N+(f[$>>2]<<2)>>2]=0;aa=f[$>>2]|0;ba=(f[a>>2]|0)-(f[W+(aa<<2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32-U|0;ka=(f[W>>2]|0)>>>ba|N>>>(ba-Z|0)}}else{Z=f[o>>2]|0;if((Z|0)!=(f[C>>2]|0)){ba=f[Z>>2]<>>(32-S|0);N=V+S|0;f[n>>2]=N;if((N|0)==32){f[o>>2]=Z+4;f[n>>2]=0;ka=ba}else ka=ba}else ka=0}ba=(L>>>1)-ka|0;Z=L-ba|0;c:do if((ba|0)==(Z|0)){la=ba;ma=ba}else{N=f[D>>2]|0;S=f[F>>2]|0;do if((S|0)!=(f[E>>2]|0)){V=(f[S>>2]&1<<31-N|0)!=0;W=N+1|0;f[D>>2]=W;if((W|0)==32){f[F>>2]=S+4;f[D>>2]=0;if(V){la=ba;ma=Z;break c}else break}else if(V){la=ba;ma=Z;break c}else break}while(0);la=Z;ma=ba}while(0);ba=f[s>>2]|0;Z=f[ba+(Q*12|0)>>2]|0;S=Z+(M<<2)|0;f[S>>2]=(f[S>>2]|0)+1;gf(ba+(T*12|0)|0,Z,f[ba+(Q*12|0)+4>>2]|0);if(la|0){ba=f[z>>2]|0;Z=f[y>>2]|0;S=ba-Z>>2;N=f[r>>2]|0;V=f[x>>2]|0;if((((S|0)==0?0:(S*341|0)+-1|0)|0)==(V+N|0)){ic(g);na=f[r>>2]|0;oa=f[x>>2]|0;pa=f[z>>2]|0;qa=f[y>>2]|0}else{na=N;oa=V;pa=ba;qa=Z}Z=oa+na|0;if((pa|0)==(qa|0))ra=0;else ra=(f[qa+(((Z>>>0)/341|0)<<2)>>2]|0)+(((Z>>>0)%341|0)*12|0)|0;f[ra>>2]=la;f[ra+4>>2]=M;f[ra+8>>2]=Q;f[x>>2]=(f[x>>2]|0)+1}if(!ma)R=23;else{Z=f[z>>2]|0;ba=f[y>>2]|0;V=Z-ba>>2;N=f[r>>2]|0;S=f[x>>2]|0;if((((V|0)==0?0:(V*341|0)+-1|0)|0)==(S+N|0)){ic(g);sa=f[r>>2]|0;ta=f[x>>2]|0;ua=f[z>>2]|0;va=f[y>>2]|0}else{sa=N;ta=S;ua=Z;va=ba}ba=ta+sa|0;if((ua|0)==(va|0))wa=0;else wa=(f[va+(((ba>>>0)/341|0)<<2)>>2]|0)+(((ba>>>0)%341|0)*12|0)|0;f[wa>>2]=ma;f[wa+4>>2]=M;f[wa+8>>2]=T;ba=(f[x>>2]|0)+1|0;f[x>>2]=ba;xa=ba}}while(0);if((R|0)==23){R=0;xa=f[x>>2]|0}if(!xa){B=1;break}else I=xa}}while(0);xa=f[y>>2]|0;wa=f[r>>2]|0;ma=xa+(((wa>>>0)/341|0)<<2)|0;va=f[z>>2]|0;ua=va;sa=xa;if((va|0)==(xa|0)){ya=0;za=0}else{ta=(f[x>>2]|0)+wa|0;ya=(f[xa+(((ta>>>0)/341|0)<<2)>>2]|0)+(((ta>>>0)%341|0)*12|0)|0;za=(f[ma>>2]|0)+(((wa>>>0)%341|0)*12|0)|0}wa=ma;ma=za;d:while(1){za=ma;do{ta=za;if((ta|0)==(ya|0))break d;za=ta+12|0}while((za-(f[wa>>2]|0)|0)!=4092);za=wa+4|0;wa=za;ma=f[za>>2]|0}f[x>>2]=0;x=ua-sa>>2;if(x>>>0>2){sa=xa;do{lp(f[sa>>2]|0);sa=(f[y>>2]|0)+4|0;f[y>>2]=sa;Aa=f[z>>2]|0;Ba=Aa-sa>>2}while(Ba>>>0>2);Ca=sa;Da=Aa;Ea=Ba}else{Ca=xa;Da=va;Ea=x}switch(Ea|0){case 1:{Fa=170;R=98;break}case 2:{Fa=341;R=98;break}default:{}}if((R|0)==98)f[r>>2]=Fa;if((Ca|0)!=(Da|0)){Fa=Ca;do{lp(f[Fa>>2]|0);Fa=Fa+4|0}while((Fa|0)!=(Da|0));Da=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(Da|0))f[z>>2]=y+(~((y+-4-Da|0)>>>2)<<2)}Da=f[g>>2]|0;if(!Da){u=d;return B|0}lp(Da);u=d;return B|0}function lb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l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]|0)|0;b:do if(!P)if(!L)R=23;else{N=0;do{S=f[O>>2]|0;T=f[S>>2]|0;f[e>>2]=T;f[G>>2]=f[S+4>>2];f[H>>2]=f[S+8>>2];S=f[c>>2]|0;U=S+4|0;V=f[U>>2]|0;if(V>>>0<(f[S+8>>2]|0)>>>0){f[V>>2]=T;f[V+4>>2]=f[G>>2];f[V+8>>2]=f[H>>2];f[U>>2]=V+12}else Kf(S,e);f[v>>2]=(f[v>>2]|0)+1;N=N+1|0}while(N>>>0>>0);R=23}else{if(L>>>0<3){N=f[q>>2]|0;f[N>>2]=M;S=f[h>>2]|0;if(S>>>0>1){V=S;U=M;T=1;while(1){U=(U|0)==(V+-1|0)?0:U+1|0;f[N+(T<<2)>>2]=U;T=T+1|0;W=f[h>>2]|0;if(T>>>0>=W>>>0){X=W;break}else V=W}}else X=S;if(!L){R=23;break}V=X;T=0;while(1){if(!V)Y=f[w>>2]|0;else{U=f[q>>2]|0;N=f[w>>2]|0;W=f[J>>2]|0;Z=0;do{$=U+(Z<<2)|0;f[N+(f[$>>2]<<2)>>2]=0;aa=f[$>>2]|0;ba=(f[a>>2]|0)-(f[W+(aa<<2)>>2]|0)|0;do if(ba|0){ca=N+(aa<<2)|0;da=f[m>>2]|0;ea=32-da|0;if((ba|0)>(ea|0)){fa=f[k>>2]|0;ga=fa+4|0;if((ga|0)==(f[j>>2]|0)){f[ca>>2]=0;break}else{ha=f[fa>>2]<>2]=fa;f[k>>2]=ga;ia=32-fa|0;f[ca>>2]=(f[ga>>2]|0)>>>ia|ha>>>(ia-ea|0);break}}ea=f[k>>2]|0;if((ea|0)==(f[j>>2]|0)){f[ca>>2]=0;break}f[ca>>2]=f[ea>>2]<>>(32-ba|0);da=(f[m>>2]|0)+ba|0;f[m>>2]=da;if((da|0)!=32)break;f[k>>2]=ea+4;f[m>>2]=0}while(0);ba=f[$>>2]|0;aa=N+(ba<<2)|0;f[aa>>2]=f[aa>>2]|f[(f[O>>2]|0)+(ba<<2)>>2];Z=Z+1|0}while(Z>>>0<(f[h>>2]|0)>>>0);Y=N}N=f[Y>>2]|0;f[e>>2]=N;f[p>>2]=f[Y+4>>2];f[t>>2]=f[Y+8>>2];Z=f[c>>2]|0;W=Z+4|0;U=f[W>>2]|0;if(U>>>0<(f[Z+8>>2]|0)>>>0){f[U>>2]=N;f[U+4>>2]=f[p>>2];f[U+8>>2]=f[t>>2];f[W>>2]=U+12}else Kf(Z,e);f[v>>2]=(f[v>>2]|0)+1;Z=T+1|0;if(Z>>>0>=L>>>0){R=23;break b}V=f[h>>2]|0;T=Z}}if((f[v>>2]|0)>>>0>(f[i>>2]|0)>>>0){B=0;break a}T=Q+1|0;gf(K+(T*12|0)|0,f[O>>2]|0,f[K+(Q*12|0)+4>>2]|0);V=(f[(f[l>>2]|0)+(T*12|0)>>2]|0)+(M<<2)|0;f[V>>2]=(f[V>>2]|0)+(1<>2]|0;Z=32-S|0;if((V|0)>(Z|0)){U=f[o>>2]|0;W=U+4|0;if((W|0)==(f[C>>2]|0))ja=0;else{N=f[U>>2]<>2]=U;f[o>>2]=W;ba=32-U|0;ja=(f[W>>2]|0)>>>ba|N>>>(ba-Z|0)}}else{Z=f[o>>2]|0;if((Z|0)!=(f[C>>2]|0)){ba=f[Z>>2]<>>(32-V|0);N=S+V|0;f[n>>2]=N;if((N|0)==32){f[o>>2]=Z+4;f[n>>2]=0;ja=ba}else ja=ba}else ja=0}ba=(L>>>1)-ja|0;Z=L-ba|0;c:do if((ba|0)==(Z|0)){ka=ba;la=ba}else{N=f[D>>2]|0;V=f[F>>2]|0;do if((V|0)!=(f[E>>2]|0)){S=(f[V>>2]&1<<31-N|0)!=0;W=N+1|0;f[D>>2]=W;if((W|0)==32){f[F>>2]=V+4;f[D>>2]=0;if(S){ka=ba;la=Z;break c}else break}else if(S){ka=ba;la=Z;break c}else break}while(0);ka=Z;la=ba}while(0);ba=f[s>>2]|0;Z=f[ba+(Q*12|0)>>2]|0;V=Z+(M<<2)|0;f[V>>2]=(f[V>>2]|0)+1;gf(ba+(T*12|0)|0,Z,f[ba+(Q*12|0)+4>>2]|0);if(ka|0){ba=f[z>>2]|0;Z=f[y>>2]|0;V=ba-Z>>2;N=f[r>>2]|0;S=f[x>>2]|0;if((((V|0)==0?0:(V*341|0)+-1|0)|0)==(S+N|0)){ic(g);ma=f[r>>2]|0;na=f[x>>2]|0;oa=f[z>>2]|0;pa=f[y>>2]|0}else{ma=N;na=S;oa=ba;pa=Z}Z=na+ma|0;if((oa|0)==(pa|0))qa=0;else qa=(f[pa+(((Z>>>0)/341|0)<<2)>>2]|0)+(((Z>>>0)%341|0)*12|0)|0;f[qa>>2]=ka;f[qa+4>>2]=M;f[qa+8>>2]=Q;f[x>>2]=(f[x>>2]|0)+1}if(!la)R=23;else{Z=f[z>>2]|0;ba=f[y>>2]|0;S=Z-ba>>2;N=f[r>>2]|0;V=f[x>>2]|0;if((((S|0)==0?0:(S*341|0)+-1|0)|0)==(V+N|0)){ic(g);ra=f[r>>2]|0;sa=f[x>>2]|0;ta=f[z>>2]|0;ua=f[y>>2]|0}else{ra=N;sa=V;ta=Z;ua=ba}ba=sa+ra|0;if((ta|0)==(ua|0))va=0;else va=(f[ua+(((ba>>>0)/341|0)<<2)>>2]|0)+(((ba>>>0)%341|0)*12|0)|0;f[va>>2]=la;f[va+4>>2]=M;f[va+8>>2]=T;ba=(f[x>>2]|0)+1|0;f[x>>2]=ba;wa=ba}}while(0);if((R|0)==23){R=0;wa=f[x>>2]|0}if(!wa){B=1;break}else I=wa}}while(0);wa=f[y>>2]|0;va=f[r>>2]|0;la=wa+(((va>>>0)/341|0)<<2)|0;ua=f[z>>2]|0;ta=ua;ra=wa;if((ua|0)==(wa|0)){xa=0;ya=0}else{sa=(f[x>>2]|0)+va|0;xa=(f[wa+(((sa>>>0)/341|0)<<2)>>2]|0)+(((sa>>>0)%341|0)*12|0)|0;ya=(f[la>>2]|0)+(((va>>>0)%341|0)*12|0)|0}va=la;la=ya;d:while(1){ya=la;do{sa=ya;if((sa|0)==(xa|0))break d;ya=sa+12|0}while((ya-(f[va>>2]|0)|0)!=4092);ya=va+4|0;va=ya;la=f[ya>>2]|0}f[x>>2]=0;x=ta-ra>>2;if(x>>>0>2){ra=wa;do{lp(f[ra>>2]|0);ra=(f[y>>2]|0)+4|0;f[y>>2]=ra;za=f[z>>2]|0;Aa=za-ra>>2}while(Aa>>>0>2);Ba=ra;Ca=za;Da=Aa}else{Ba=wa;Ca=ua;Da=x}switch(Da|0){case 1:{Ea=170;R=96;break}case 2:{Ea=341;R=96;break}default:{}}if((R|0)==96)f[r>>2]=Ea;if((Ba|0)!=(Ca|0)){Ea=Ba;do{lp(f[Ea>>2]|0);Ea=Ea+4|0}while((Ea|0)!=(Ca|0));Ca=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(Ca|0))f[z>>2]=y+(~((y+-4-Ca|0)>>>2)<<2)}Ca=f[g>>2]|0;if(!Ca){u=d;return B|0}lp(Ca);u=d;return B|0}function mb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0;d=u;u=u+48|0;e=d+24|0;g=d;h=a+12|0;i=f[h>>2]|0;f[e>>2]=0;j=e+4|0;f[j>>2]=0;f[e+8>>2]=0;do if(i)if(i>>>0>1073741823)Eo(e);else{k=i<<2;l=Yk(k)|0;f[e>>2]=l;m=l+(i<<2)|0;f[e+8>>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|0;w=a+604|0;m=a+560|0;k=a+556|0;j=a+548|0;i=a+4|0;n=a+600|0;o=a+588|0;C=a+596|0;D=e+4|0;E=e+8|0;F=A;while(1){G=f[r>>2]|0;H=F+-1|0;I=G+H|0;J=f[y>>2]|0;K=f[J+(((I>>>0)/341|0)<<2)>>2]|0;L=(I>>>0)%341|0;I=f[K+(L*12|0)>>2]|0;M=f[K+(L*12|0)+4>>2]|0;N=f[K+(L*12|0)+8>>2]|0;f[x>>2]=H;H=f[z>>2]|0;L=H-J>>2;if((1-F-G+((L|0)==0?0:(L*341|0)+-1|0)|0)>>>0>681){lp(f[H+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}H=f[l>>2]|0;L=H+(N*12|0)|0;G=(f[s>>2]|0)+(N*12|0)|0;if(I>>>0>b>>>0){B=0;break a}J=Gg(a,I,G,M)|0;if(J>>>0>=(f[h>>2]|0)>>>0){B=0;break a}M=(f[a>>2]|0)-(f[(f[G>>2]|0)+(J<<2)>>2]|0)|0;b:do if(!M)if(!I)O=23;else{K=0;do{P=f[L>>2]|0;Q=f[P>>2]|0;f[e>>2]=Q;f[D>>2]=f[P+4>>2];f[E>>2]=f[P+8>>2];P=f[c>>2]|0;R=P+4|0;S=f[R>>2]|0;if(S>>>0<(f[P+8>>2]|0)>>>0){f[S>>2]=Q;f[S+4>>2]=f[D>>2];f[S+8>>2]=f[E>>2];f[R>>2]=S+12}else Kf(P,e);f[v>>2]=(f[v>>2]|0)+1;K=K+1|0}while(K>>>0>>0);O=23}else{if(I>>>0<3){K=f[q>>2]|0;f[K>>2]=J;P=f[h>>2]|0;if(P>>>0>1){S=P;R=J;Q=1;while(1){R=(R|0)==(S+-1|0)?0:R+1|0;f[K+(Q<<2)>>2]=R;Q=Q+1|0;T=f[h>>2]|0;if(Q>>>0>=T>>>0){U=T;break}else S=T}}else U=P;if(!I){O=23;break}S=U;Q=0;while(1){if(!S)V=f[w>>2]|0;else{R=f[q>>2]|0;K=f[w>>2]|0;T=f[G>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0)){ia=W;ja=W}else{S=f[n>>2]|0;R=f[C>>2]|0;do if((R|0)!=(f[o>>2]|0)){T=(f[R>>2]&1<<31-S|0)!=0;K=S+1|0;f[n>>2]=K;if((K|0)==32){f[C>>2]=R+4;f[n>>2]=0;if(T){ia=W;ja=P;break c}else break}else if(T){ia=W;ja=P;break c}else break}while(0);ia=P;ja=W}while(0);W=f[s>>2]|0;P=f[W+(N*12|0)>>2]|0;R=P+(J<<2)|0;f[R>>2]=(f[R>>2]|0)+1;gf(W+(Q*12|0)|0,P,f[W+(N*12|0)+4>>2]|0);if(ia|0){W=f[z>>2]|0;P=f[y>>2]|0;R=W-P>>2;S=f[r>>2]|0;T=f[x>>2]|0;if((((R|0)==0?0:(R*341|0)+-1|0)|0)==(T+S|0)){ic(g);ka=f[r>>2]|0;la=f[x>>2]|0;ma=f[z>>2]|0;na=f[y>>2]|0}else{ka=S;la=T;ma=W;na=P}P=la+ka|0;if((ma|0)==(na|0))oa=0;else oa=(f[na+(((P>>>0)/341|0)<<2)>>2]|0)+(((P>>>0)%341|0)*12|0)|0;f[oa>>2]=ia;f[oa+4>>2]=J;f[oa+8>>2]=N;f[x>>2]=(f[x>>2]|0)+1}if(!ja)O=23;else{P=f[z>>2]|0;W=f[y>>2]|0;T=P-W>>2;S=f[r>>2]|0;R=f[x>>2]|0;if((((T|0)==0?0:(T*341|0)+-1|0)|0)==(R+S|0)){ic(g);pa=f[r>>2]|0;qa=f[x>>2]|0;ra=f[z>>2]|0;sa=f[y>>2]|0}else{pa=S;qa=R;ra=P;sa=W}W=qa+pa|0;if((ra|0)==(sa|0))ta=0;else ta=(f[sa+(((W>>>0)/341|0)<<2)>>2]|0)+(((W>>>0)%341|0)*12|0)|0;f[ta>>2]=ja;f[ta+4>>2]=J;f[ta+8>>2]=Q;W=(f[x>>2]|0)+1|0;f[x>>2]=W;ua=W}}while(0);if((O|0)==23){O=0;ua=f[x>>2]|0}if(!ua){B=1;break}else F=ua}}while(0);ua=f[y>>2]|0;ta=f[r>>2]|0;ja=ua+(((ta>>>0)/341|0)<<2)|0;sa=f[z>>2]|0;ra=sa;pa=ua;if((sa|0)==(ua|0)){va=0;wa=0}else{qa=(f[x>>2]|0)+ta|0;va=(f[ua+(((qa>>>0)/341|0)<<2)>>2]|0)+(((qa>>>0)%341|0)*12|0)|0;wa=(f[ja>>2]|0)+(((ta>>>0)%341|0)*12|0)|0}ta=ja;ja=wa;d:while(1){wa=ja;do{qa=wa;if((qa|0)==(va|0))break d;wa=qa+12|0}while((wa-(f[ta>>2]|0)|0)!=4092);wa=ta+4|0;ta=wa;ja=f[wa>>2]|0}f[x>>2]=0;x=ra-pa>>2;if(x>>>0>2){pa=ua;do{lp(f[pa>>2]|0);pa=(f[y>>2]|0)+4|0;f[y>>2]=pa;xa=f[z>>2]|0;ya=xa-pa>>2}while(ya>>>0>2);za=pa;Aa=xa;Ba=ya}else{za=ua;Aa=sa;Ba=x}switch(Ba|0){case 1:{Ca=170;O=94;break}case 2:{Ca=341;O=94;break}default:{}}if((O|0)==94)f[r>>2]=Ca;if((za|0)!=(Aa|0)){Ca=za;do{lp(f[Ca>>2]|0);Ca=Ca+4|0}while((Ca|0)!=(Aa|0));Aa=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(Aa|0))f[z>>2]=y+(~((y+-4-Aa|0)>>>2)<<2)}Aa=f[g>>2]|0;if(!Aa){u=d;return B|0}lp(Aa);u=d;return B|0}function nb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0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;x=g+20|0;ic(g);p=f[y>>2]|0;q=(f[x>>2]|0)+(f[r>>2]|0)|0;if((f[z>>2]|0)==(p|0))A=0;else A=(f[p+(((q>>>0)/341|0)<<2)>>2]|0)+(((q>>>0)%341|0)*12|0)|0;f[A>>2]=b;f[A+4>>2]=0;f[A+8>>2]=0;A=(f[x>>2]|0)+1|0;f[x>>2]=A;a:do if(!A)B=1;else{q=a+616|0;p=e+4|0;t=e+8|0;v=a+8|0;w=a+604|0;m=a+560|0;k=a+556|0;j=a+548|0;i=a+4|0;n=a+600|0;o=a+588|0;C=a+596|0;D=e+4|0;E=e+8|0;F=A;while(1){G=f[r>>2]|0;H=F+-1|0;I=G+H|0;J=f[y>>2]|0;K=f[J+(((I>>>0)/341|0)<<2)>>2]|0;L=(I>>>0)%341|0;I=f[K+(L*12|0)>>2]|0;M=f[K+(L*12|0)+4>>2]|0;N=f[K+(L*12|0)+8>>2]|0;f[x>>2]=H;H=f[z>>2]|0;L=H-J>>2;if((1-F-G+((L|0)==0?0:(L*341|0)+-1|0)|0)>>>0>681){lp(f[H+-4>>2]|0);f[z>>2]=(f[z>>2]|0)+-4}H=f[l>>2]|0;L=H+(N*12|0)|0;G=(f[s>>2]|0)+(N*12|0)|0;if(I>>>0>b>>>0){B=0;break a}J=vl(a,I,G,M)|0;if(J>>>0>=(f[h>>2]|0)>>>0){B=0;break a}M=(f[a>>2]|0)-(f[(f[G>>2]|0)+(J<<2)>>2]|0)|0;b:do if(!M)if(!I)O=23;else{K=0;do{P=f[L>>2]|0;Q=f[P>>2]|0;f[e>>2]=Q;f[D>>2]=f[P+4>>2];f[E>>2]=f[P+8>>2];P=f[c>>2]|0;R=P+4|0;S=f[R>>2]|0;if(S>>>0<(f[P+8>>2]|0)>>>0){f[S>>2]=Q;f[S+4>>2]=f[D>>2];f[S+8>>2]=f[E>>2];f[R>>2]=S+12}else Kf(P,e);f[v>>2]=(f[v>>2]|0)+1;K=K+1|0}while(K>>>0>>0);O=23}else{if(I>>>0<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=W}}if((f[v>>2]|0)>>>0>(f[i>>2]|0)>>>0){B=0;break a}Q=N+1|0;S=f[l>>2]|0;P=S+(Q*12|0)|0;if((P|0)==(L|0))ga=S;else{gf(P,f[L>>2]|0,f[H+(N*12|0)+4>>2]|0);ga=f[l>>2]|0}P=(f[ga+(Q*12|0)>>2]|0)+(J<<2)|0;f[P>>2]=(f[P>>2]|0)+(1<>>1)-ha|0;P=I-W|0;c:do if((W|0)==(P|0)){ia=W;ja=W}else{S=f[n>>2]|0;R=f[C>>2]|0;do if((R|0)!=(f[o>>2]|0)){T=(f[R>>2]&1<<31-S|0)!=0;K=S+1|0;f[n>>2]=K;if((K|0)==32){f[C>>2]=R+4;f[n>>2]=0;if(T){ia=W;ja=P;break c}else break}else if(T){ia=W;ja=P;break c}else break}while(0);ia=P;ja=W}while(0);W=f[s>>2]|0;P=f[W+(N*12|0)>>2]|0;R=P+(J<<2)|0;f[R>>2]=(f[R>>2]|0)+1;gf(W+(Q*12|0)|0,P,f[W+(N*12|0)+4>>2]|0);if(ia|0){W=f[z>>2]|0;P=f[y>>2]|0;R=W-P>>2;S=f[r>>2]|0;T=f[x>>2]|0;if((((R|0)==0?0:(R*341|0)+-1|0)|0)==(T+S|0)){ic(g);ka=f[r>>2]|0;la=f[x>>2]|0;ma=f[z>>2]|0;na=f[y>>2]|0}else{ka=S;la=T;ma=W;na=P}P=la+ka|0;if((ma|0)==(na|0))oa=0;else oa=(f[na+(((P>>>0)/341|0)<<2)>>2]|0)+(((P>>>0)%341|0)*12|0)|0;f[oa>>2]=ia;f[oa+4>>2]=J;f[oa+8>>2]=N;f[x>>2]=(f[x>>2]|0)+1}if(!ja)O=23;else{P=f[z>>2]|0;W=f[y>>2]|0;T=P-W>>2;S=f[r>>2]|0;R=f[x>>2]|0;if((((T|0)==0?0:(T*341|0)+-1|0)|0)==(R+S|0)){ic(g);pa=f[r>>2]|0;qa=f[x>>2]|0;ra=f[z>>2]|0;sa=f[y>>2]|0}else{pa=S;qa=R;ra=P;sa=W}W=qa+pa|0;if((ra|0)==(sa|0))ta=0;else ta=(f[sa+(((W>>>0)/341|0)<<2)>>2]|0)+(((W>>>0)%341|0)*12|0)|0;f[ta>>2]=ja;f[ta+4>>2]=J;f[ta+8>>2]=Q;W=(f[x>>2]|0)+1|0;f[x>>2]=W;ua=W}}while(0);if((O|0)==23){O=0;ua=f[x>>2]|0}if(!ua){B=1;break}else F=ua}}while(0);ua=f[y>>2]|0;ta=f[r>>2]|0;ja=ua+(((ta>>>0)/341|0)<<2)|0;sa=f[z>>2]|0;ra=sa;pa=ua;if((sa|0)==(ua|0)){va=0;wa=0}else{qa=(f[x>>2]|0)+ta|0;va=(f[ua+(((qa>>>0)/341|0)<<2)>>2]|0)+(((qa>>>0)%341|0)*12|0)|0;wa=(f[ja>>2]|0)+(((ta>>>0)%341|0)*12|0)|0}ta=ja;ja=wa;d:while(1){wa=ja;do{qa=wa;if((qa|0)==(va|0))break d;wa=qa+12|0}while((wa-(f[ta>>2]|0)|0)!=4092);wa=ta+4|0;ta=wa;ja=f[wa>>2]|0}f[x>>2]=0;x=ra-pa>>2;if(x>>>0>2){pa=ua;do{lp(f[pa>>2]|0);pa=(f[y>>2]|0)+4|0;f[y>>2]=pa;xa=f[z>>2]|0;ya=xa-pa>>2}while(ya>>>0>2);za=pa;Aa=xa;Ba=ya}else{za=ua;Aa=sa;Ba=x}switch(Ba|0){case 1:{Ca=170;O=94;break}case 2:{Ca=341;O=94;break}default:{}}if((O|0)==94)f[r>>2]=Ca;if((za|0)!=(Aa|0)){Ca=za;do{lp(f[Ca>>2]|0);Ca=Ca+4|0}while((Ca|0)!=(Aa|0));Aa=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(Aa|0))f[z>>2]=y+(~((y+-4-Aa|0)>>>2)<<2)}Aa=f[g>>2]|0;if(!Aa){u=d;return B|0}lp(Aa);u=d;return B|0}function ob(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0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0;Q=f[P>>2]|0;f[e>>2]=Q;f[D>>2]=f[P+4>>2];f[E>>2]=f[P+8>>2];P=f[c>>2]|0;R=P+4|0;S=f[R>>2]|0;if(S>>>0<(f[P+8>>2]|0)>>>0){f[S>>2]=Q;f[S+4>>2]=f[D>>2];f[S+8>>2]=f[E>>2];f[R>>2]=S+12}else Kf(P,e);f[v>>2]=(f[v>>2]|0)+1;K=K+1|0}while(K>>>0>>0);O=23}else{if(I>>>0>=3){if((f[v>>2]|0)>>>0>(f[i>>2]|0)>>>0){B=0;break a}K=N+1|0;gf(H+(K*12|0)|0,f[L>>2]|0,f[H+(N*12|0)+4>>2]|0);P=(f[(f[l>>2]|0)+(K*12|0)>>2]|0)+(J<<2)|0;f[P>>2]=(f[P>>2]|0)+(1<>>1)-T|0;P=I-R|0;c:do if((R|0)==(P|0)){U=R;V=R}else{S=f[n>>2]|0;Q=f[C>>2]|0;do if((Q|0)!=(f[o>>2]|0)){W=(f[Q>>2]&1<<31-S|0)!=0;X=S+1|0;f[n>>2]=X;if((X|0)==32){f[C>>2]=Q+4;f[n>>2]=0;if(W){U=R;V=P;break c}else break}else if(W){U=R;V=P;break c}else break}while(0);U=P;V=R}while(0);R=f[s>>2]|0;P=f[R+(N*12|0)>>2]|0;Q=P+(J<<2)|0;f[Q>>2]=(f[Q>>2]|0)+1;gf(R+(K*12|0)|0,P,f[R+(N*12|0)+4>>2]|0);if(U|0){R=f[z>>2]|0;P=f[y>>2]|0;Q=R-P>>2;S=f[r>>2]|0;W=f[x>>2]|0;if((((Q|0)==0?0:(Q*341|0)+-1|0)|0)==(W+S|0)){ic(g);Y=f[r>>2]|0;Z=f[x>>2]|0;$=f[z>>2]|0;aa=f[y>>2]|0}else{Y=S;Z=W;$=R;aa=P}P=Z+Y|0;if(($|0)==(aa|0))ba=0;else ba=(f[aa+(((P>>>0)/341|0)<<2)>>2]|0)+(((P>>>0)%341|0)*12|0)|0;f[ba>>2]=U;f[ba+4>>2]=J;f[ba+8>>2]=N;f[x>>2]=(f[x>>2]|0)+1}if(!V){O=23;break}P=f[z>>2]|0;R=f[y>>2]|0;W=P-R>>2;S=f[r>>2]|0;Q=f[x>>2]|0;if((((W|0)==0?0:(W*341|0)+-1|0)|0)==(Q+S|0)){ic(g);ca=f[r>>2]|0;da=f[x>>2]|0;ea=f[z>>2]|0;fa=f[y>>2]|0}else{ca=S;da=Q;ea=P;fa=R}R=da+ca|0;if((ea|0)==(fa|0))ga=0;else ga=(f[fa+(((R>>>0)/341|0)<<2)>>2]|0)+(((R>>>0)%341|0)*12|0)|0;f[ga>>2]=V;f[ga+4>>2]=J;f[ga+8>>2]=K;R=(f[x>>2]|0)+1|0;f[x>>2]=R;ha=R;break}R=f[q>>2]|0;f[R>>2]=J;P=f[h>>2]|0;if(P>>>0>1){Q=P;S=J;W=1;while(1){S=(S|0)==(Q+-1|0)?0:S+1|0;f[R+(W<<2)>>2]=S;W=W+1|0;X=f[h>>2]|0;if(W>>>0>=X>>>0){ia=X;break}else Q=X}}else ia=P;if(!I)O=23;else{Q=ia;W=0;while(1){if(!Q)ja=f[w>>2]|0;else{S=f[q>>2]|0;R=f[w>>2]|0;K=f[G>>2]|0;X=0;do{ka=S+(X<<2)|0;f[R+(f[ka>>2]<<2)>>2]=0;la=f[ka>>2]|0;ma=(f[a>>2]|0)-(f[K+(la<<2)>>2]|0)|0;do if(ma|0){na=R+(la<<2)|0;oa=f[m>>2]|0;pa=32-oa|0;if((ma|0)>(pa|0)){qa=f[k>>2]|0;ra=qa+4|0;if((ra|0)==(f[j>>2]|0)){f[na>>2]=0;break}else{sa=f[qa>>2]<>2]=qa;f[k>>2]=ra;ta=32-qa|0;f[na>>2]=(f[ra>>2]|0)>>>ta|sa>>>(ta-pa|0);break}}pa=f[k>>2]|0;if((pa|0)==(f[j>>2]|0)){f[na>>2]=0;break}f[na>>2]=f[pa>>2]<>>(32-ma|0);oa=(f[m>>2]|0)+ma|0;f[m>>2]=oa;if((oa|0)!=32)break;f[k>>2]=pa+4;f[m>>2]=0}while(0);ma=f[ka>>2]|0;la=R+(ma<<2)|0;f[la>>2]=f[la>>2]|f[(f[L>>2]|0)+(ma<<2)>>2];X=X+1|0}while(X>>>0<(f[h>>2]|0)>>>0);ja=R}R=f[ja>>2]|0;f[e>>2]=R;f[p>>2]=f[ja+4>>2];f[t>>2]=f[ja+8>>2];X=f[c>>2]|0;K=X+4|0;S=f[K>>2]|0;if(S>>>0<(f[X+8>>2]|0)>>>0){f[S>>2]=R;f[S+4>>2]=f[p>>2];f[S+8>>2]=f[t>>2];f[K>>2]=S+12}else Kf(X,e);f[v>>2]=(f[v>>2]|0)+1;X=W+1|0;if(X>>>0>=I>>>0){O=23;break b}Q=f[h>>2]|0;W=X}}}while(0);if((O|0)==23){O=0;ha=f[x>>2]|0}if(!ha){B=1;break}else F=ha}}while(0);ha=f[y>>2]|0;h=f[r>>2]|0;e=ha+(((h>>>0)/341|0)<<2)|0;c=f[z>>2]|0;ja=c;a=ha;if((c|0)==(ha|0)){ua=0;va=0}else{ia=(f[x>>2]|0)+h|0;ua=(f[ha+(((ia>>>0)/341|0)<<2)>>2]|0)+(((ia>>>0)%341|0)*12|0)|0;va=(f[e>>2]|0)+(((h>>>0)%341|0)*12|0)|0}h=e;e=va;d:while(1){va=e;do{ia=va;if((ia|0)==(ua|0))break d;va=ia+12|0}while((va-(f[h>>2]|0)|0)!=4092);va=h+4|0;h=va;e=f[va>>2]|0}f[x>>2]=0;x=ja-a>>2;if(x>>>0>2){a=ha;do{lp(f[a>>2]|0);a=(f[y>>2]|0)+4|0;f[y>>2]=a;wa=f[z>>2]|0;xa=wa-a>>2}while(xa>>>0>2);ya=a;za=wa;Aa=xa}else{ya=ha;za=c;Aa=x}switch(Aa|0){case 1:{Ba=170;O=92;break}case 2:{Ba=341;O=92;break}default:{}}if((O|0)==92)f[r>>2]=Ba;if((ya|0)!=(za|0)){Ba=ya;do{lp(f[Ba>>2]|0);Ba=Ba+4|0}while((Ba|0)!=(za|0));za=f[y>>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|0)|0;if(J>>>0>b>>>0){B=0;break a}K=vl(a,J,H,N)|0;if(K>>>0>=(f[h>>2]|0)>>>0){B=0;break a}N=(f[a>>2]|0)-(f[(f[H>>2]|0)+(K<<2)>>2]|0)|0;b:do if(!N){if(J|0){L=0;do{P=f[M>>2]|0;Q=f[P>>2]|0;f[e>>2]=Q;f[E>>2]=f[P+4>>2];f[F>>2]=f[P+8>>2];P=f[c>>2]|0;R=P+4|0;S=f[R>>2]|0;if(S>>>0<(f[P+8>>2]|0)>>>0){f[S>>2]=Q;f[S+4>>2]=f[E>>2];f[S+8>>2]=f[F>>2];f[R>>2]=S+12}else Kf(P,e);f[v>>2]=(f[v>>2]|0)+1;L=L+1|0}while(L>>>0>>0)}}else if(J>>>0<3){L=f[q>>2]|0;f[L>>2]=K;P=f[h>>2]|0;if(P>>>0>1){S=P;R=K;Q=1;while(1){R=(R|0)==(S+-1|0)?0:R+1|0;f[L+(Q<<2)>>2]=R;Q=Q+1|0;T=f[h>>2]|0;if(Q>>>0>=T>>>0){U=T;break}else S=T}}else U=P;if(!J)break;S=U;Q=0;while(1){if(!S)V=f[w>>2]|0;else{R=f[q>>2]|0;L=f[w>>2]|0;T=f[H>>2]|0;W=0;do{X=R+(W<<2)|0;f[L+(f[X>>2]<<2)>>2]=0;Y=f[X>>2]|0;Z=(f[a>>2]|0)-(f[T+(Y<<2)>>2]|0)|0;do if(Z|0){$=L+(Y<<2)|0;aa=f[m>>2]|0;ba=32-aa|0;if((Z|0)>(ba|0)){ca=f[k>>2]|0;da=ca+4|0;if((da|0)==(f[j>>2]|0)){f[$>>2]=0;break}else{ea=f[ca>>2]<>2]=ca;f[k>>2]=da;fa=32-ca|0;f[$>>2]=(f[da>>2]|0)>>>fa|ea>>>(fa-ba|0);break}}ba=f[k>>2]|0;if((ba|0)==(f[j>>2]|0)){f[$>>2]=0;break}f[$>>2]=f[ba>>2]<>>(32-Z|0);aa=(f[m>>2]|0)+Z|0;f[m>>2]=aa;if((aa|0)!=32)break;f[k>>2]=ba+4;f[m>>2]=0}while(0);Z=f[X>>2]|0;Y=L+(Z<<2)|0;f[Y>>2]=f[Y>>2]|f[(f[M>>2]|0)+(Z<<2)>>2];W=W+1|0}while(W>>>0<(f[h>>2]|0)>>>0);V=L}L=f[V>>2]|0;f[e>>2]=L;f[p>>2]=f[V+4>>2];f[t>>2]=f[V+8>>2];W=f[c>>2]|0;T=W+4|0;R=f[T>>2]|0;if(R>>>0<(f[W+8>>2]|0)>>>0){f[R>>2]=L;f[R+4>>2]=f[p>>2];f[R+8>>2]=f[t>>2];f[T>>2]=R+12}else Kf(W,e);f[v>>2]=(f[v>>2]|0)+1;W=Q+1|0;if(W>>>0>=J>>>0)break b;S=f[h>>2]|0;Q=W}}else{if((f[v>>2]|0)>>>0>(f[i>>2]|0)>>>0){B=0;break a}Q=O+1|0;S=f[l>>2]|0;P=S+(Q*12|0)|0;if((P|0)==(M|0))ga=S;else{gf(P,f[M>>2]|0,f[I+(O*12|0)+4>>2]|0);ga=f[l>>2]|0}P=(f[ga+(Q*12|0)>>2]|0)+(K<<2)|0;f[P>>2]=(f[P>>2]|0)+(1<>2]=0;Eh(n,P,e);P=(J>>>1)-(f[e>>2]|0)|0;S=J-P|0;c:do if((P|0)==(S|0)){ha=P;ia=P}else{W=f[o>>2]|0;R=f[D>>2]|0;do if((R|0)!=(f[C>>2]|0)){T=(f[R>>2]&1<<31-W|0)!=0;L=W+1|0;f[o>>2]=L;if((L|0)==32){f[D>>2]=R+4;f[o>>2]=0;if(T){ha=P;ia=S;break c}else break}else if(T){ha=P;ia=S;break c}else break}while(0);ha=S;ia=P}while(0);P=f[s>>2]|0;S=f[P+(O*12|0)>>2]|0;R=S+(K<<2)|0;f[R>>2]=(f[R>>2]|0)+1;gf(P+(Q*12|0)|0,S,f[P+(O*12|0)+4>>2]|0);if(ha|0){P=f[z>>2]|0;S=f[y>>2]|0;R=P-S>>2;W=f[r>>2]|0;T=f[x>>2]|0;if((((R|0)==0?0:(R*341|0)+-1|0)|0)==(T+W|0)){ic(g);ja=f[r>>2]|0;ka=f[x>>2]|0;la=f[z>>2]|0;ma=f[y>>2]|0}else{ja=W;ka=T;la=P;ma=S}S=ka+ja|0;if((la|0)==(ma|0))na=0;else na=(f[ma+(((S>>>0)/341|0)<<2)>>2]|0)+(((S>>>0)%341|0)*12|0)|0;f[na>>2]=ha;f[na+4>>2]=K;f[na+8>>2]=O;f[x>>2]=(f[x>>2]|0)+1}if(ia|0){S=f[z>>2]|0;P=f[y>>2]|0;T=S-P>>2;W=f[r>>2]|0;R=f[x>>2]|0;if((((T|0)==0?0:(T*341|0)+-1|0)|0)==(R+W|0)){ic(g);oa=f[r>>2]|0;pa=f[x>>2]|0;qa=f[z>>2]|0;ra=f[y>>2]|0}else{oa=W;pa=R;qa=S;ra=P}P=pa+oa|0;if((qa|0)==(ra|0))sa=0;else sa=(f[ra+(((P>>>0)/341|0)<<2)>>2]|0)+(((P>>>0)%341|0)*12|0)|0;f[sa>>2]=ia;f[sa+4>>2]=K;f[sa+8>>2]=Q;f[x>>2]=(f[x>>2]|0)+1}break}while(0);G=f[x>>2]|0;if(!G){B=1;break}}}while(0);sa=f[y>>2]|0;ia=f[r>>2]|0;ra=sa+(((ia>>>0)/341|0)<<2)|0;qa=f[z>>2]|0;oa=qa;pa=sa;if((qa|0)==(sa|0)){ta=0;ua=0}else{na=(f[x>>2]|0)+ia|0;ta=(f[sa+(((na>>>0)/341|0)<<2)>>2]|0)+(((na>>>0)%341|0)*12|0)|0;ua=(f[ra>>2]|0)+(((ia>>>0)%341|0)*12|0)|0}ia=ra;ra=ua;d:while(1){ua=ra;do{na=ua;if((na|0)==(ta|0))break d;ua=na+12|0}while((ua-(f[ia>>2]|0)|0)!=4092);ua=ia+4|0;ia=ua;ra=f[ua>>2]|0}f[x>>2]=0;x=oa-pa>>2;if(x>>>0>2){pa=sa;do{lp(f[pa>>2]|0);pa=(f[y>>2]|0)+4|0;f[y>>2]=pa;va=f[z>>2]|0;wa=va-pa>>2}while(wa>>>0>2);xa=pa;ya=va;za=wa}else{xa=sa;ya=qa;za=x}switch(za|0){case 1:{Aa=170;Ba=92;break}case 2:{Aa=341;Ba=92;break}default:{}}if((Ba|0)==92)f[r>>2]=Aa;if((xa|0)!=(ya|0)){Aa=xa;do{lp(f[Aa>>2]|0);Aa=Aa+4|0}while((Aa|0)!=(ya|0));ya=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(ya|0))f[z>>2]=y+(~((y+-4-ya|0)>>>2)<<2)}ya=f[g>>2]|0;if(!ya){u=d;return B|0}lp(ya);u=d;return B|0}function qb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=Ka,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0;d=u;u=u+720|0;e=d;g=d+688|0;i=d+656|0;k=d+4|0;if((j[c+38>>1]|0)>514){f[i>>2]=0;l=i+4|0;f[l>>2]=0;f[i+8>>2]=0;m=c+8|0;o=c+16|0;p=g+4|0;q=g+8|0;r=a+36|0;t=a+40|0;v=a+60|0;w=a+44|0;x=g+8|0;y=g+12|0;z=g+20|0;A=0;a:while(1){if((A|0)>=(Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0)){B=4;break}C=Na[f[(f[a>>2]|0)+20>>2]&127](a,A)|0;D=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;E=f[(f[(f[D>>2]|0)+8>>2]|0)+(C<<2)>>2]|0;if((f[E+28>>2]|0)==9){C=b[E+24>>0]|0;E=f[l>>2]|0;D=f[i>>2]|0;F=E-D>>2;G=D;D=E;if(C>>>0<=F>>>0){if(C>>>0>>0?(E=G+(C<<2)|0,(D|0)!=(E|0)):0)f[l>>2]=D+(~((D+-4-E|0)>>>2)<<2)}else Og(i,C-F|0);F=C<<2;E=m;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>2]=J+(F>>>2<<2)}}f[C+20>>2]=f[z>>2];f[t>>2]=(f[t>>2]|0)+24;O=0}else O=1;while(0);f[g>>2]=1228;C=f[q>>2]|0;if(C|0){F=f[y>>2]|0;if((F|0)!=(C|0))f[y>>2]=F+(~((F+-4-C|0)>>>2)<<2);lp(C)}if(O|0){K=0;break}}A=A+1|0}if((B|0)==20)Eo(P);if((B|0)==4){P=a+48|0;A=a+52|0;if((f[A>>2]|0)==(f[P>>2]|0))K=1;else{O=0;y=0;while(1){if(Ph(g,c)|0){q=f[g>>2]|0;Q=q<<31>>31^q>>>1}else Q=y;q=f[P>>2]|0;f[q+(O<<2)>>2]=Q;O=O+1|0;if(O>>>0>=(f[A>>2]|0)-q>>2>>>0){K=1;break}else y=Q}}}Q=f[i>>2]|0;if(Q|0){y=f[l>>2]|0;if((y|0)!=(Q|0))f[l>>2]=y+(~((y+-4-Q|0)>>>2)<<2);lp(Q)}R=K;u=d;return R|0}K=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;f[g>>2]=0;Q=g+4|0;f[Q>>2]=0;f[g+8>>2]=0;y=(K|0)==0;if(y){S=f[(f[a>>2]|0)+20>>2]|0;T=a;U=0}else{if(K>>>0>214748364)Eo(g);l=K*20|0;A=Yk(l)|0;f[g>>2]=A;f[g+8>>2]=A+(K*20|0);Dh(A|0,0,l|0)|0;f[Q>>2]=A+l;l=f[(f[a>>2]|0)+20>>2]|0;A=0;O=0;while(1){P=Na[l&127](a,A)|0;q=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;t=f[(f[(f[q>>2]|0)+8>>2]|0)+(P<<2)>>2]|0;P=f[t+28>>2]|0;q=Zj(P)|0;z=b[t+24>>0]|0;x=f[g>>2]|0;f[x+(A*20|0)>>2]=t;f[x+(A*20|0)+4>>2]=O;f[x+(A*20|0)+8>>2]=P;f[x+(A*20|0)+12>>2]=(q|0)>0?q:0;f[x+(A*20|0)+16>>2]=z;x=z+O|0;A=A+1|0;z=f[(f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6){f[e>>2]=p&255;Ml(4934,e)|0;V=0;break b}P=Ul(z|0,q|0,6,0)|0;w=I;if((S|0)<(w|0)|(S|0)==(w|0)&A>>>0

>>0){V=0;break b}r=x+t|0;t=h[r>>0]|h[r+1>>0]<<8|h[r+2>>0]<<16|h[r+3>>0]<<24;r=O;f[r>>2]=P;f[r+4>>2]=w;if(!y){w=0;do{r=Na[f[(f[T>>2]|0)+20>>2]&127](a,w)|0;P=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;x=f[(f[(f[P>>2]|0)+8>>2]|0)+(r<<2)>>2]|0;Lh(x,t)|0;b[x+84>>0]=1;r=f[x+68>>2]|0;P=x+72|0;x=f[P>>2]|0;if((x|0)!=(r|0))f[P>>2]=x+(~((x+-4-r|0)>>>2)<<2);w=w+1|0}while(w>>>0>>0)}Xf(i,g);switch(p<<24>>24){case 0:{ue(k,U);w=be(k,c,i)|0;xe(k);if(w)B=77;else W=1;break}case 1:{ue(k,U);w=ae(k,c,i)|0;xe(k);if(w)B=77;else W=1;break}case 2:{we(k,U);w=de(k,c,i)|0;De(k);if(w)B=77;else W=1;break}case 3:{we(k,U);w=ce(k,c,i)|0;De(k);if(w)B=77;else W=1;break}case 4:{se(k,U);w=Hd(k,c,i)|0;pe(k);if(w)B=77;else W=1;break}case 5:{se(k,U);w=Gd(k,c,i)|0;pe(k);if(w)B=77;else W=1;break}case 6:{se(k,U);w=Fd(k,c,i)|0;pe(k);if(w)B=77;else W=1;break}default:W=1}if((B|0)==77)W=0;w=f[i+16>>2]|0;if(w|0){t=i+20|0;r=f[t>>2]|0;if((r|0)!=(w|0))f[t>>2]=r+(~(((r+-20-w|0)>>>0)/20|0)*20|0);lp(w)}w=f[i>>2]|0;if(w|0){r=i+4|0;if((f[r>>2]|0)!=(w|0))f[r>>2]=w;lp(w)}if(W|0){V=0;break b}break}default:{V=0;break b}}V=1}else V=0;while(0);W=f[g>>2]|0;if(W|0){g=f[Q>>2]|0;if((g|0)!=(W|0))f[Q>>2]=g+(~(((g+-20-W|0)>>>0)/20|0)*20|0);lp(W)}R=V;u=d;return R|0}function rb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=Ka,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Ul(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;if(!(b[a+32>>0]|0)){r=0;m=o;while(1){s=$(b[m>>0]|0);n[g+(r<<2)>>2]=s;r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else m=m+1|0}}else{m=0;r=o;while(1){s=$($(b[r>>0]|0)/$(127.0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}}else t=l;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 2:{r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;q=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;u=Ul(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+u|0;if(!(b[a+32>>0]|0)){u=0;k=o;while(1){s=$(h[k>>0]|0);n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){v=q;break}else k=k+1|0}}else{k=0;u=o;while(1){s=$($(h[u>>0]|0)/$(255.0));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else u=u+1|0}}}else v=m;u=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 3:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Ul(fl(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=0;l=o;while(1){s=$(d[l>>1]|0);n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else l=l+2|0}}else{l=0;u=o;while(1){s=$($(d[u>>1]|0)/$(32767.0));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else u=u+2|0}}else w=k;u=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 4:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Ul(fl(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=0;m=o;while(1){s=$(j[m>>1]|0);n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else m=m+2|0}}else{m=0;u=o;while(1){s=$($(j[u>>1]|0)/$(65535.0));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){x=k;break}else u=u+2|0}}else x=l;u=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 5:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Ul(fl(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=0;k=o;while(1){s=$(f[k>>2]|0);n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){y=q;break}else k=k+4|0}}else{k=0;u=o;while(1){s=$($(f[u>>2]|0)*$(4.65661287e-10));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){y=l;break}else u=u+4|0}}else y=m;u=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 6:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Ul(fl(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=0;l=o;while(1){s=$((f[l>>2]|0)>>>0);n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){z=q;break}else l=l+4|0}}else{l=0;u=o;while(1){s=$($((f[u>>2]|0)>>>0)*$(2.32830644e-10));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){z=m;break}else u=u+4|0}}else z=k;u=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 7:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Ul(fl(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=0;m=o;while(1){q=m;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+(f[q+4>>2]|0));n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else m=m+8|0}}else{m=0;u=o;while(1){k=u;s=$($(+((f[k>>2]|0)>>>0)+4294967296.0*+(f[k+4>>2]|0))*$(1.08420217e-19));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){A=k;break}else u=u+8|0}}else A=l;u=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 8:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Ul(fl(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=0;k=o;while(1){q=k;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+((f[q+4>>2]|0)>>>0));n[g+(u<<2)>>2]=s;u=u+1|0;q=b[r>>0]|0;if((u|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){B=q;break}else k=k+8|0}}else{k=0;u=o;while(1){l=u;s=$($(+((f[l>>2]|0)>>>0)+4294967296.0*+((f[l+4>>2]|0)>>>0))*$(5.42101086e-20));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){B=l;break}else u=u+8|0}}else B=m;u=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 9:{u=a+24|0;k=b[u>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;l=fl(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Ul(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=0;l=r+q|0;while(1){f[g+(o<<2)>>2]=f[l>>2];o=o+1|0;q=b[u>>0]|0;if((o|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){C=q;break}else l=l+4|0}}else C=k;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 10:{l=a+24|0;o=b[l>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){u=f[f[a>>2]>>2]|0;m=a+40|0;q=fl(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;r=Ul(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=0;q=u+r|0;while(1){s=$(+p[q>>3]);n[g+(m<<2)>>2]=s;m=m+1|0;r=b[l>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){D=r;break}else q=q+8|0}}else D=o;q=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 11:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){l=f[f[a>>2]>>2]|0;k=a+40|0;r=fl(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;u=Ul(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=0;r=l+u|0;while(1){s=$((b[r>>0]|0)!=0&1);n[g+(k<<2)>>2]=s;k=k+1|0;u=b[q>>0]|0;if((k|0)>=((u<<24>>24>e<<24>>24?e:u)<<24>>24|0)){E=u;break}else r=r+1|0}}else E=m;r=E<<24>>24;if(E<<24>>24>=e<<24>>24){i=1;return i|0}Dh(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function sb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=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|0;gf(I+(L*12|0)|0,f[M>>2]|0,f[I+(O*12|0)+4>>2]|0);P=(f[(f[l>>2]|0)+(L*12|0)>>2]|0)+(K<<2)|0;f[P>>2]=(f[P>>2]|0)+(1<>2]=0;Eh(n,P,e);P=(J>>>1)-(f[e>>2]|0)|0;S=J-P|0;c:do if((P|0)==(S|0)){T=P;U=P}else{R=f[o>>2]|0;Q=f[D>>2]|0;do if((Q|0)!=(f[C>>2]|0)){V=(f[Q>>2]&1<<31-R|0)!=0;W=R+1|0;f[o>>2]=W;if((W|0)==32){f[D>>2]=Q+4;f[o>>2]=0;if(V){T=P;U=S;break c}else break}else if(V){T=P;U=S;break c}else break}while(0);T=S;U=P}while(0);P=f[s>>2]|0;S=f[P+(O*12|0)>>2]|0;Q=S+(K<<2)|0;f[Q>>2]=(f[Q>>2]|0)+1;gf(P+(L*12|0)|0,S,f[P+(O*12|0)+4>>2]|0);if(T|0){P=f[z>>2]|0;S=f[y>>2]|0;Q=P-S>>2;R=f[r>>2]|0;V=f[x>>2]|0;if((((Q|0)==0?0:(Q*341|0)+-1|0)|0)==(V+R|0)){ic(g);X=f[r>>2]|0;Y=f[x>>2]|0;Z=f[z>>2]|0;$=f[y>>2]|0}else{X=R;Y=V;Z=P;$=S}S=Y+X|0;if((Z|0)==($|0))aa=0;else aa=(f[$+(((S>>>0)/341|0)<<2)>>2]|0)+(((S>>>0)%341|0)*12|0)|0;f[aa>>2]=T;f[aa+4>>2]=K;f[aa+8>>2]=O;f[x>>2]=(f[x>>2]|0)+1}if(U|0){S=f[z>>2]|0;P=f[y>>2]|0;V=S-P>>2;R=f[r>>2]|0;Q=f[x>>2]|0;if((((V|0)==0?0:(V*341|0)+-1|0)|0)==(Q+R|0)){ic(g);ba=f[r>>2]|0;ca=f[x>>2]|0;da=f[z>>2]|0;ea=f[y>>2]|0}else{ba=R;ca=Q;da=S;ea=P}P=ca+ba|0;if((da|0)==(ea|0))fa=0;else fa=(f[ea+(((P>>>0)/341|0)<<2)>>2]|0)+(((P>>>0)%341|0)*12|0)|0;f[fa>>2]=U;f[fa+4>>2]=K;f[fa+8>>2]=L;f[x>>2]=(f[x>>2]|0)+1}break}P=f[q>>2]|0;f[P>>2]=K;S=f[h>>2]|0;if(S>>>0>1){Q=S;R=K;V=1;while(1){R=(R|0)==(Q+-1|0)?0:R+1|0;f[P+(V<<2)>>2]=R;V=V+1|0;W=f[h>>2]|0;if(V>>>0>=W>>>0){ga=W;break}else Q=W}}else ga=S;if(J|0){Q=ga;V=0;while(1){if(!Q)ha=f[w>>2]|0;else{R=f[q>>2]|0;P=f[w>>2]|0;L=f[H>>2]|0;W=0;do{ia=R+(W<<2)|0;f[P+(f[ia>>2]<<2)>>2]=0;ja=f[ia>>2]|0;ka=(f[a>>2]|0)-(f[L+(ja<<2)>>2]|0)|0;do if(ka|0){la=P+(ja<<2)|0;ma=f[m>>2]|0;na=32-ma|0;if((ka|0)>(na|0)){oa=f[k>>2]|0;pa=oa+4|0;if((pa|0)==(f[j>>2]|0)){f[la>>2]=0;break}else{qa=f[oa>>2]<>2]=oa;f[k>>2]=pa;ra=32-oa|0;f[la>>2]=(f[pa>>2]|0)>>>ra|qa>>>(ra-na|0);break}}na=f[k>>2]|0;if((na|0)==(f[j>>2]|0)){f[la>>2]=0;break}f[la>>2]=f[na>>2]<>>(32-ka|0);ma=(f[m>>2]|0)+ka|0;f[m>>2]=ma;if((ma|0)!=32)break;f[k>>2]=na+4;f[m>>2]=0}while(0);ka=f[ia>>2]|0;ja=P+(ka<<2)|0;f[ja>>2]=f[ja>>2]|f[(f[M>>2]|0)+(ka<<2)>>2];W=W+1|0}while(W>>>0<(f[h>>2]|0)>>>0);ha=P}P=f[ha>>2]|0;f[e>>2]=P;f[p>>2]=f[ha+4>>2];f[t>>2]=f[ha+8>>2];W=f[c>>2]|0;L=W+4|0;R=f[L>>2]|0;if(R>>>0<(f[W+8>>2]|0)>>>0){f[R>>2]=P;f[R+4>>2]=f[p>>2];f[R+8>>2]=f[t>>2];f[L>>2]=R+12}else Kf(W,e);f[v>>2]=(f[v>>2]|0)+1;W=V+1|0;if(W>>>0>=J>>>0)break b;Q=f[h>>2]|0;V=W}}}while(0);G=f[x>>2]|0;if(!G){B=1;break}}}while(0);h=f[y>>2]|0;e=f[r>>2]|0;c=h+(((e>>>0)/341|0)<<2)|0;ha=f[z>>2]|0;a=ha;ga=h;if((ha|0)==(h|0)){sa=0;ta=0}else{fa=(f[x>>2]|0)+e|0;sa=(f[h+(((fa>>>0)/341|0)<<2)>>2]|0)+(((fa>>>0)%341|0)*12|0)|0;ta=(f[c>>2]|0)+(((e>>>0)%341|0)*12|0)|0}e=c;c=ta;d:while(1){ta=c;do{fa=ta;if((fa|0)==(sa|0))break d;ta=fa+12|0}while((ta-(f[e>>2]|0)|0)!=4092);ta=e+4|0;e=ta;c=f[ta>>2]|0}f[x>>2]=0;x=a-ga>>2;if(x>>>0>2){ga=h;do{lp(f[ga>>2]|0);ga=(f[y>>2]|0)+4|0;f[y>>2]=ga;ua=f[z>>2]|0;va=ua-ga>>2}while(va>>>0>2);wa=ga;xa=ua;ya=va}else{wa=h;xa=ha;ya=x}switch(ya|0){case 1:{za=170;Aa=90;break}case 2:{za=341;Aa=90;break}default:{}}if((Aa|0)==90)f[r>>2]=za;if((wa|0)!=(xa|0)){za=wa;do{lp(f[za>>2]|0);za=za+4|0}while((za|0)!=(xa|0));xa=f[y>>2]|0;y=f[z>>2]|0;if((y|0)!=(xa|0))f[z>>2]=y+(~((y+-4-xa|0)>>>2)<<2)}xa=f[g>>2]|0;if(!xa){u=d;return B|0}lp(xa);u=d;return B|0} +function Xf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=a+16|0;ci(d,b);f[a+28>>2]=0;b=f[a+20>>2]|0;e=f[d>>2]|0;d=e;if((b|0)!=(e|0)){g=(b-e|0)/20|0;e=0;b=0;do{h=X(f[d+(e*20|0)+16>>2]|0,f[d+(e*20|0)+12>>2]|0)|0;b=b>>>0>>0?h:b;e=e+1|0}while(e>>>0>>0);g=f[c>>2]|0;e=f[a>>2]|0;d=g-e|0;if(b>>>0>d>>>0){Rg(a,b-d|0);i=f[a>>2]|0;j=a+12|0;f[j>>2]=i;return}else{k=g;l=e;m=b;n=d}}else{d=f[c>>2]|0;b=f[a>>2]|0;k=d;l=b;m=0;n=d-b|0}if(m>>>0>=n>>>0){i=l;j=a+12|0;f[j>>2]=i;return}n=l+m|0;if((k|0)==(n|0)){i=l;j=a+12|0;f[j>>2]=i;return}f[c>>2]=n;i=l;j=a+12|0;f[j>>2]=i;return}function Yf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=8192){if((h|0)!=8192?(e=i+32768|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,8192-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>8192){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==8192;return k|0}function Zf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=4096){if((h|0)!=4096?(e=i+16384|0,(g|0)!=(e|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else Og(a,4096-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(d|0)!=(g|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else Pf(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(g<<2)|0;f[i+(g<<3)>>2]=f[d>>2];f[i+(g<<3)+4>>2]=h;e=h;h=(f[d>>2]|0)+h|0;if(h>>>0>4096){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=g;j=j+1|0}while((j|0)!=(h|0))}g=g+1|0}while(g>>>0>>0);if((l|0)==19)return k|0;k=(h|0)==4096;return k|0}function _f(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+224|0;g=e+120|0;h=e+80|0;i=e;j=e+136|0;k=h;l=k+40|0;do{f[k>>2]=0;k=k+4|0}while((k|0)<(l|0));f[g>>2]=f[d>>2];if((xb(0,c,g,i,h)|0)<0)m=-1;else{if((f[a+76>>2]|0)>-1)n=rp(a)|0;else n=0;d=f[a>>2]|0;k=d&32;if((b[a+74>>0]|0)<1)f[a>>2]=d&-33;d=a+48|0;if(!(f[d>>2]|0)){l=a+44|0;o=f[l>>2]|0;f[l>>2]=j;p=a+28|0;f[p>>2]=j;q=a+20|0;f[q>>2]=j;f[d>>2]=80;r=a+16|0;f[r>>2]=j+80;j=xb(a,c,g,i,h)|0;if(!o)s=j;else{Oa[f[a+36>>2]&31](a,0,0)|0;t=(f[q>>2]|0)==0?-1:j;f[l>>2]=o;f[d>>2]=0;f[r>>2]=0;f[p>>2]=0;f[q>>2]=0;s=t}}else s=xb(a,c,g,i,h)|0;h=f[a>>2]|0;f[a>>2]=h|k;if(n|0)qp(a);m=(h&32|0)==0?s:-1}u=e;return m|0}function $f(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e>>2;h=d;if(g>>>0>>0){Ie(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b<<2)|0;if((h|0)==(g|0))return;else i=h;do{h=i+-4|0;f[c>>2]=h;b=f[h>>2]|0;f[h>>2]=0;if(b|0){h=b+88|0;e=f[h>>2]|0;f[h>>2]=0;if(e|0){h=f[e+8>>2]|0;if(h|0){a=e+12|0;if((f[a>>2]|0)!=(h|0))f[a>>2]=h;lp(h)}lp(e)}e=f[b+68>>2]|0;if(e|0){h=b+72|0;a=f[h>>2]|0;if((a|0)!=(e|0))f[h>>2]=a+(~((a+-4-e|0)>>>2)<<2);lp(e)}e=b+64|0;a=f[e>>2]|0;f[e>>2]=0;if(a|0){e=f[a>>2]|0;if(e|0){h=a+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;lp(e)}lp(a)}lp(b)}i=f[c>>2]|0}while((i|0)!=(g|0));return}function ag(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;i=h;if(e-h>>2>>>0>=b>>>0){j=i;k=b;while(1){f[j>>2]=f[c>>2];k=k+-1|0;if(!k)break;else j=j+4|0}f[g>>2]=i+(b<<2);return}i=f[a>>2]|0;j=h-i|0;h=j>>2;k=h+b|0;if(k>>>0>1073741823)Eo(a);l=e-i|0;e=l>>1;m=l>>2>>>0<536870911?(e>>>0>>0?k:e):1073741823;do if(m)if(m>>>0>1073741823){e=ra(8)|0;cn(e,13392);f[e>>2]=4748;va(e|0,1128,101)}else{n=Yk(m<<2)|0;break}else n=0;while(0);e=n+(h<<2)|0;k=n+(m<<2)|0;m=e;n=b;while(1){f[m>>2]=f[c>>2];n=n+-1|0;if(!n)break;else m=m+4|0}m=e+(0-h<<2)|0;if((j|0)>0)Ff(m|0,i|0,j|0)|0;f[a>>2]=m;f[g>>2]=e+(b<<2);f[d>>2]=k;if(!i)return;lp(i);return}function bg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=(f[a>>2]|0)+1794895138|0;g=In(f[a+8>>2]|0,e)|0;h=In(f[a+12>>2]|0,e)|0;i=In(f[a+16>>2]|0,e)|0;a:do if((g>>>0>>2>>>0?(j=c-(g<<2)|0,h>>>0>>0&i>>>0>>0):0)?((i|h)&3|0)==0:0){j=h>>>2;k=i>>>2;l=0;m=g;while(1){n=m>>>1;o=l+n|0;p=o<<1;q=p+j|0;r=In(f[a+(q<<2)>>2]|0,e)|0;s=In(f[a+(q+1<<2)>>2]|0,e)|0;if(!(s>>>0>>0&r>>>0<(c-s|0)>>>0)){t=0;break a}if(b[a+(s+r)>>0]|0){t=0;break a}r=qj(d,a+s|0)|0;if(!r)break;s=(r|0)<0;if((m|0)==1){t=0;break a}else{l=s?l:o;m=s?n:m-n|0}}m=p+k|0;l=In(f[a+(m<<2)>>2]|0,e)|0;j=In(f[a+(m+1<<2)>>2]|0,e)|0;if(j>>>0>>0&l>>>0<(c-j|0)>>>0)t=(b[a+(j+l)>>0]|0)==0?a+j|0:0;else t=0}else t=0;while(0);return t|0}function cg(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h=u;u=u+64|0;i=h;j=f[a>>2]|0;k=a+(f[j+-8>>2]|0)|0;l=f[j+-4>>2]|0;f[i>>2]=e;f[i+4>>2]=a;f[i+8>>2]=c;f[i+12>>2]=g;g=i+16|0;c=i+20|0;a=i+24|0;j=i+28|0;m=i+32|0;n=i+40|0;o=g;p=o+36|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));d[g+36>>1]=0;b[g+38>>0]=0;a:do if(Hn(l,e,0)|0){f[i+48>>2]=1;Wa[f[(f[l>>2]|0)+20>>2]&3](l,i,k,k,1,0);q=(f[a>>2]|0)==1?k:0}else{Va[f[(f[l>>2]|0)+24>>2]&3](l,i,k,1,0);switch(f[i+36>>2]|0){case 0:{q=(f[n>>2]|0)==1&(f[j>>2]|0)==1&(f[m>>2]|0)==1?f[c>>2]|0:0;break a;break}case 1:break;default:{q=0;break a}}if((f[a>>2]|0)!=1?!((f[n>>2]|0)==0&(f[j>>2]|0)==1&(f[m>>2]|0)==1):0){q=0;break}q=f[g>>2]|0}while(0);u=h;return q|0}function dg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=Ka,q=0;d=u;u=u+32|0;e=d+16|0;g=d;h=a+8|0;i=b[(f[h>>2]|0)+24>>0]<<2;j=f[a+16>>2]|0;if(!(f[j+80>>2]|0))k=0;else k=(f[f[j>>2]>>2]|0)+(f[j+48>>2]|0)|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;j=f[a+24>>2]|0;if((j+-2|0)>>>0>28){l=0;u=d;return l|0}f[g>>2]=j;a=1<>2]=a+-1;j=a+-2|0;a=g+8|0;f[a>>2]=j;f[g+12>>2]=(j|0)/2|0;if(!c){l=1;u=d;return l|0}m=j;j=0;n=0;o=0;while(1){p=$($(1.0)/$(m|0));Xe(g,$($(f[k+(o<<2)>>2]|0)*p),$($(f[k+((o|1)<<2)>>2]|0)*p),e);Ff((f[f[(f[h>>2]|0)+64>>2]>>2]|0)+n|0,e|0,i|0)|0;q=j+1|0;if((q|0)==(c|0)){l=1;break}m=f[a>>2]|0;j=q;n=n+i|0;o=o+2|0}u=d;return l|0}function eg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=vc(a,c)|0;if(!e){g=0;return g|0}c=f[e+20>>2]|0;if(((f[e+24>>2]|0)-c|0)!=8){g=0;return g|0}e=c;b[s>>0]=b[e>>0];b[s+1>>0]=b[e+1>>0];b[s+2>>0]=b[e+2>>0];b[s+3>>0]=b[e+3>>0];b[s+4>>0]=b[e+4>>0];b[s+5>>0]=b[e+5>>0];b[s+6>>0]=b[e+6>>0];b[s+7>>0]=b[e+7>>0];p[s>>3]=+p[s>>3];b[d>>0]=b[s>>0];b[d+1>>0]=b[s+1>>0];b[d+2>>0]=b[s+2>>0];b[d+3>>0]=b[s+3>>0];b[d+4>>0]=b[s+4>>0];b[d+5>>0]=b[s+5>>0];b[d+6>>0]=b[s+6>>0];b[d+7>>0]=b[s+7>>0];g=1;return g|0}function fg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(j=f[(f[d+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(k=f[(f[d+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if(((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(h=f[(f[d+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function gg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){i=h;j=b;while(1){f[i>>2]=1;j=j+-1|0;if(!j)break;else i=i+4|0}f[e>>2]=h+(b<<2);return}h=f[a>>2]|0;i=g-h|0;g=i>>2;j=g+b|0;if(j>>>0>1073741823)Eo(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?j:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}else{m=Yk(l<<2)|0;break}else m=0;while(0);d=m+(g<<2)|0;j=m+(l<<2)|0;l=d;m=b;while(1){f[l>>2]=1;m=m+-1|0;if(!m)break;else l=l+4|0}l=d+(0-g<<2)|0;if((i|0)>0)Ff(l|0,h|0,i|0)|0;f[a>>2]=l;f[e>>2]=d+(b<<2);f[c>>2]=j;if(!h)return;lp(h);return}function hg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=f[a+4>>2]|0;if(!d){e=0;return e|0}a=b[c+11>>0]|0;g=a<<24>>24<0;h=g?f[c+4>>2]|0:a&255;a=g?f[c>>2]|0:c;c=d;while(1){d=c+16|0;g=b[d+11>>0]|0;i=g<<24>>24<0;j=i?f[c+20>>2]|0:g&255;g=j>>>0>>0;k=g?j:h;if((k|0)!=0?(l=dj(a,i?f[d>>2]|0:d,k)|0,(l|0)!=0):0)if((l|0)<0)m=7;else m=8;else if(h>>>0>>0)m=7;else m=8;if((m|0)==7){m=0;n=c}else if((m|0)==8){m=0;l=h>>>0>>0?h:j;if((l|0)!=0?(j=dj(i?f[d>>2]|0:d,a,l)|0,(j|0)!=0):0){if((j|0)>=0){e=1;m=14;break}}else m=10;if((m|0)==10?(m=0,!g):0){e=1;m=14;break}n=c+4|0}c=f[n>>2]|0;if(!c){e=0;m=14;break}}if((m|0)==14)return e|0;return 0}function ig(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+32|0;e=d+12|0;g=d;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=Rh(c)|0;if(h>>>0>4294967279)Eo(e);if(h>>>0<11){b[e+11>>0]=h;if(!h)i=e;else{j=e;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[e>>2]=m;f[e+8>>2]=l|-2147483648;f[e+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,c|0,h|0)|0;i=j}b[i+h>>0]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=g+11|0;b[h>>0]=4;f[g>>2]=1701667182;b[g+4>>0]=0;i=f[a+4>>2]|0;if((i|0)!=0?(j=Vd(i,g,e)|0,(j|0)!=0):0)n=cj(a,f[j+40>>2]|0)|0;else n=-1;if((b[h>>0]|0)<0)lp(f[g>>2]|0);if((b[e+11>>0]|0)>=0){u=d;return n|0}lp(f[e>>2]|0);u=d;return n|0}function jg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,i=0;if((b|0)==-2)g=0;else{i=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;do if((Ma[f[(f[d>>2]|0)+8>>2]&127](d)|0)==1){Oe(a,d,b,c,e,((h[d+36>>0]|0)<<8|(h[d+37>>0]|0))&65535);if(!(f[a>>2]|0)){f[a>>2]=0;break}else return}while(0);d=Yk(44)|0;f[d>>2]=1536;f[d+4>>2]=i;i=d+8|0;f[i>>2]=f[e>>2];f[i+4>>2]=f[e+4>>2];f[i+8>>2]=f[e+8>>2];f[i+12>>2]=f[e+12>>2];f[i+16>>2]=f[e+16>>2];f[i+20>>2]=f[e+20>>2];pi(d+32|0,e+24|0);f[d>>2]=1592;g=d}f[a>>2]=g;return}function kg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+16|0;if(b[d+84>>0]|0){g=f[e>>2]|0;return g|0}a=f[e>>2]|0;if(!a){g=f[e>>2]|0;return g|0}h=a+84|0;if(!(b[h>>0]|0)){g=f[e>>2]|0;return g|0}i=(f[d+72>>2]|0)-(f[d+68>>2]|0)>>2;b[h>>0]=0;h=a+68|0;j=a+72|0;a=f[j>>2]|0;k=f[h>>2]|0;l=a-k>>2;m=k;k=a;if(i>>>0<=l>>>0)if(i>>>0>>0?(a=m+(i<<2)|0,(k|0)!=(a|0)):0){f[j>>2]=k+(~((k+-4-a|0)>>>2)<<2);n=d}else n=d;else{ag(h,i-l|0,1404);n=f[c>>2]|0}if(b[n+84>>0]|0){g=f[e>>2]|0;return g|0}c=f[n+68>>2]|0;l=c;i=(f[n+72>>2]|0)-c>>2;if(!i){g=f[e>>2]|0;return g|0}c=f[(f[e>>2]|0)+68>>2]|0;n=0;do{f[c+(n<<2)>>2]=f[l+(n<<2)>>2];n=n+1|0}while(n>>>0>>0);g=f[e>>2]|0;return g|0}function lg(a){a=a|0;Ym(a);Ym(a+16|0);Ym(a+32|0);Ym(a+48|0);Ym(a+64|0);Ym(a+80|0);Ym(a+96|0);Ym(a+112|0);Ym(a+128|0);Ym(a+144|0);Ym(a+160|0);Ym(a+176|0);Ym(a+192|0);Ym(a+208|0);Ym(a+224|0);Ym(a+240|0);Ym(a+256|0);Ym(a+272|0);Ym(a+288|0);Ym(a+304|0);Ym(a+320|0);Ym(a+336|0);Ym(a+352|0);Ym(a+368|0);Ym(a+384|0);Ym(a+400|0);Ym(a+416|0);Ym(a+432|0);Ym(a+448|0);Ym(a+464|0);Ym(a+480|0);Ym(a+496|0);return}function mg(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;e=a+8|0;g=f[e>>2]|0;h=b[g+24>>0]|0;i=h<<24>>24;j=i<<1;k=ip(i>>>0>2147483647?-1:i<<1)|0;l=f[a+16>>2]|0;if(!(f[l+80>>2]|0))m=0;else m=(f[f[l>>2]>>2]|0)+(f[l+48>>2]|0)|0;if(!c){jp(k);return}if(h<<24>>24>0){h=0;l=0;a=0;while(1){n=0;o=a;while(1){d[k+(n<<1)>>1]=f[m+(o<<2)>>2];n=n+1|0;if((n|0)==(i|0))break;else o=o+1|0}Ff((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+l|0,k|0,j|0)|0;h=h+1|0;if((h|0)==(c|0))break;else{l=l+j|0;a=i+a|0}}jp(k);return}else{Ff(f[f[g+64>>2]>>2]|0,k|0,j|0)|0;if((c|0)==1){jp(k);return}else{p=1;q=0}do{q=q+j|0;Ff((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+q|0,k|0,j|0)|0;p=p+1|0}while((p|0)!=(c|0));jp(k);return}}function ng(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=a+8|0;e=f[d>>2]|0;g=b[e+24>>0]|0;h=g<<24>>24;i=h<<2;j=ip(h>>>0>1073741823?-1:h<<2)|0;k=f[a+16>>2]|0;if(!(f[k+80>>2]|0))l=0;else l=(f[f[k>>2]>>2]|0)+(f[k+48>>2]|0)|0;if(!c){jp(j);return}if(g<<24>>24>0){g=0;k=0;a=0;while(1){m=0;n=a;while(1){f[j+(m<<2)>>2]=f[l+(n<<2)>>2];m=m+1|0;if((m|0)==(h|0))break;else n=n+1|0}Ff((f[f[(f[d>>2]|0)+64>>2]>>2]|0)+k|0,j|0,i|0)|0;g=g+1|0;if((g|0)==(c|0))break;else{k=k+i|0;a=h+a|0}}jp(j);return}else{Ff(f[f[e+64>>2]>>2]|0,j|0,i|0)|0;if((c|0)==1){jp(j);return}else{o=1;p=0}do{p=p+i|0;Ff((f[f[(f[d>>2]|0)+64>>2]>>2]|0)+p|0,j|0,i|0)|0;o=o+1|0}while((o|0)!=(c|0));jp(j);return}}function og(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+32|0;e=d+16|0;g=d;switch(c<<24>>24){case 0:{c=Yk(48)|0;Zn(c);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=c;u=d;return}case 1:{c=Yk(52)|0;$m(c);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=c;u=d;return}default:{c=Yk(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=28;h=c;i=11693;j=h+28|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[c+28>>0]=0;f[e>>2]=-1;c=e+4|0;zh(c,g);f[a>>2]=f[e>>2];zh(a+4|0,c);f[a+16>>2]=0;if((b[c+11>>0]|0)<0)lp(f[c>>2]|0);if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);u=d;return}}}function pg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=(d-e|0)/144|0;h=d;if(g>>>0>>0){vd(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b*144|0)|0;if((h|0)==(g|0))return;else i=h;do{f[c>>2]=i+-144;h=f[i+-12>>2]|0;if(h|0){b=i+-8|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);lp(h)}h=f[i+-28>>2]|0;if(h|0){e=i+-24|0;b=f[e>>2]|0;if((b|0)!=(h|0))f[e>>2]=b+(~((b+-4-h|0)>>>2)<<2);lp(h)}h=f[i+-40>>2]|0;if(h|0){b=i+-36|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);lp(h)}ah(i+-140|0);i=f[c>>2]|0}while((i|0)!=(g|0));return}function qg(a,b){a=a|0;b=b|0;var c=0,d=Ka,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=$a(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){rc(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=$a(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;rc(a,e);return}function rg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=1416;b=a+60|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Ra[f[(f[c>>2]|0)+4>>2]&127](c);c=f[a+48>>2]|0;if(c|0){b=a+52|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c)}c=a+36|0;d=f[c>>2]|0;if(d|0){b=a+40|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Ra[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}lp(g)}f[a>>2]=1256;g=f[a+16>>2]|0;if(g|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(g|0))f[c>>2]=d+(~((d+-4-g|0)>>>2)<<2);lp(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);lp(g);return}function sg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{d=g+-4|0;f[c>>2]=d;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=h+88|0;i=f[d>>2]|0;f[d>>2]=0;if(i|0){d=f[i+8>>2]|0;if(d|0){j=i+12|0;if((f[j>>2]|0)!=(d|0))f[j>>2]=d;lp(d)}lp(i)}i=f[h+68>>2]|0;if(i|0){d=h+72|0;j=f[d>>2]|0;if((j|0)!=(i|0))f[d>>2]=j+(~((j+-4-i|0)>>>2)<<2);lp(i)}i=h+64|0;j=f[i>>2]|0;f[i>>2]=0;if(j|0){i=f[j>>2]|0;if(i|0){d=j+4|0;if((f[d>>2]|0)!=(i|0))f[d>>2]=i;lp(i)}lp(j)}lp(h)}g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}lp(e);return}function tg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,k=0,l=0,m=0,n=0,o=0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;k=f[g+4>>2]|0;g=Ul(i|0,k|0,4,0)|0;l=I;if((e|0)<(l|0)|(e|0)==(l|0)&d>>>0>>0){m=0;return m|0}n=(f[b>>2]|0)+i|0;o=h[n>>0]|h[n+1>>0]<<8|h[n+2>>0]<<16|h[n+3>>0]<<24;n=c;f[n>>2]=g;f[n+4>>2]=l;do if((j[b+38>>1]|0)<514){l=Ul(i|0,k|0,8,0)|0;n=I;if((e|0)<(n|0)|(e|0)==(n|0)&d>>>0>>0){m=0;return m|0}else{g=c;f[g>>2]=l;f[g+4>>2]=n;break}}while(0);if(!(o&1)){m=0;return m|0}c=(_(o|0)|0)^31;if((c+-1|0)>>>0>28){m=0;return m|0}f[a+8>>2]=c+1;o=2<>2]=o+-1;c=o+-2|0;f[a+16>>2]=c;f[a+20>>2]=(c|0)/2|0;m=1;return m|0}function ug(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{d=e+-4|0;f[c>>2]=d;g=f[d>>2]|0;f[d>>2]=0;if(g|0){d=g+88|0;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=f[h+8>>2]|0;if(d|0){i=h+12|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;lp(d)}lp(h)}h=f[g+68>>2]|0;if(h|0){d=g+72|0;i=f[d>>2]|0;if((i|0)!=(h|0))f[d>>2]=i+(~((i+-4-h|0)>>>2)<<2);lp(h)}h=g+64|0;i=f[h>>2]|0;f[h>>2]=0;if(i|0){h=f[i>>2]|0;if(h|0){d=i+4|0;if((f[d>>2]|0)!=(h|0))f[d>>2]=h;lp(h)}lp(i)}lp(g)}e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;lp(b);return}function vg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=a+8|0;e=f[d>>2]|0;g=b[e+24>>0]|0;h=g<<24>>24;i=ip((h|0)>-1?h:-1)|0;j=f[a+16>>2]|0;if(!(f[j+80>>2]|0))k=0;else k=(f[f[j>>2]>>2]|0)+(f[j+48>>2]|0)|0;if(!c){jp(i);return}if(g<<24>>24>0){g=0;j=0;while(1){a=0;l=j;while(1){b[i+a>>0]=f[k+(l<<2)>>2];a=a+1|0;if((a|0)==(h|0))break;else l=l+1|0}Ff((f[f[(f[d>>2]|0)+64>>2]>>2]|0)+j|0,i|0,h|0)|0;g=g+1|0;if((g|0)==(c|0))break;else j=j+h|0}jp(i);return}else{Ff(f[f[e+64>>2]>>2]|0,i|0,h|0)|0;if((c|0)==1){jp(i);return}else{m=1;n=0}do{n=n+h|0;Ff((f[f[(f[d>>2]|0)+64>>2]>>2]|0)+n|0,i|0,h|0)|0;m=m+1|0}while((m|0)!=(c|0));jp(i);return}}function wg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=Yk(72)|0;nl(c);d=c;if((b|0)<0){Ra[f[(f[c>>2]|0)+4>>2]&127](c);e=0;return e|0}c=a+8|0;g=a+12|0;a=f[g>>2]|0;h=f[c>>2]|0;i=a-h>>2;do if((i|0)<=(b|0)){j=b+1|0;k=a;if(j>>>0>i>>>0){ef(c,j-i|0);break}if(j>>>0>>0?(l=h+(j<<2)|0,(k|0)!=(l|0)):0){j=k;do{k=j+-4|0;f[g>>2]=k;m=f[k>>2]|0;f[k>>2]=0;if(m|0)Ra[f[(f[m>>2]|0)+4>>2]&127](m);j=f[g>>2]|0}while((j|0)!=(l|0))}}while(0);g=(f[c>>2]|0)+(b<<2)|0;b=f[g>>2]|0;f[g>>2]=d;if(!b){e=1;return e|0}Ra[f[(f[b>>2]|0)+4>>2]&127](b);e=1;return e|0}function xg(a,b){a=a|0;b=b|0;var c=0,d=Ka,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=$a(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Bc(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=$a(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Bc(a,e);return}function yg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+60|0;d=f[c>>2]|0;if(!d){e=0;return e|0}f[d+4>>2]=a+48;if(!(Ma[f[(f[d>>2]|0)+12>>2]&127](d)|0)){e=0;return e|0}d=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;a:do if((d|0)>0){g=0;while(1){h=(Ma[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;i=f[h>>2]|0;h=Na[f[(f[a>>2]|0)+20>>2]&127](a,g)|0;j=f[c>>2]|0;g=g+1|0;if(!(Na[f[(f[j>>2]|0)+8>>2]&127](j,f[(f[i+8>>2]|0)+(h<<2)>>2]|0)|0)){e=0;break}if((g|0)>=(d|0))break a}return e|0}while(0);if(!(Na[f[(f[a>>2]|0)+36>>2]&127](a,b)|0)){e=0;return e|0}if(!(Na[f[(f[a>>2]|0)+40>>2]&127](a,b)|0)){e=0;return e|0}e=Ma[f[(f[a>>2]|0)+44>>2]&127](a)|0;return e|0}function zg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+32|0;e=a+12|0;g=a;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Rh(d)|0;if(h>>>0>4294967279)Eo(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;Ah(c,g,e)|0;c=e+11|0;h=b[c>>0]|0;i=h<<24>>24<0?f[e>>2]|0:e;if((b[g+11>>0]|0)<0){lp(f[g>>2]|0);n=b[c>>0]|0}else n=h;if(n<<24>>24>=0){u=a;return i|0}lp(f[e>>2]|0);u=a;return i|0}function Ag(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=d+16|0;g=f[e>>2]|0;if(!g)if(!(Bj(d)|0)){h=f[e>>2]|0;i=5}else j=0;else{h=g;i=5}a:do if((i|0)==5){g=d+20|0;e=f[g>>2]|0;k=e;if((h-e|0)>>>0>>0){j=Oa[f[d+36>>2]&31](d,a,c)|0;break}b:do if((b[d+75>>0]|0)>-1){e=c;while(1){if(!e){l=k;m=0;n=c;o=a;break b}p=e+-1|0;if((b[a+p>>0]|0)==10)break;else e=p}p=Oa[f[d+36>>2]&31](d,a,e)|0;if(p>>>0>>0){j=p;break a}l=f[g>>2]|0;m=e;n=c-e|0;o=a+e|0}else{l=k;m=0;n=c;o=a}while(0);Ff(l|0,o|0,n|0)|0;f[g>>2]=(f[g>>2]|0)+n;j=m+n|0}while(0);return j|0}function Bg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+12|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d+28>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;Bg(c+8|0);lp(c)}while((e|0)!=0)}e=d+20|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0)lp(c);c=f[d+8>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;g=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;lp(h)}if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);lp(c)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(e|0)lp(e);lp(d)}if((b[a+11>>0]|0)>=0)return;lp(f[a>>2]|0);return}function Cg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0;c=a+4|0;if((Ma[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){d=1;return d|0}a=0;while(1){e=f[(f[c>>2]|0)+4>>2]|0;g=ik(e,Na[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;if((g|0)==-1){d=0;i=9;break}e=f[c>>2]|0;if(((h[e+36>>0]|0)<<8&65535)<512){if(!(Na[f[(f[b>>2]|0)+28>>2]&127](b,f[(f[(f[e+4>>2]|0)+8>>2]|0)+(g<<2)>>2]|0)|0)){d=0;i=9;break}}else{j=pj(e,g)|0;if(!j){d=0;i=9;break}if(!(Na[f[(f[b>>2]|0)+28>>2]&127](b,j)|0)){d=0;i=9;break}}a=a+1|0;if((a|0)>=(Ma[f[(f[b>>2]|0)+20>>2]&127](b)|0)){d=1;i=9;break}}if((i|0)==9)return d|0;return 0}function Dg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=(f[b+4>>2]|0)-(f[b>>2]|0)|0;b=d>>2;e=a+8|0;a=f[(f[e>>2]|0)+40>>2]|0;g=ip((a|0)>-1?a:-1)|0;h=c+8|0;if((d|0)<=0){i=1;jp(g);return i|0}d=c+16|0;j=0;k=0;while(1){l=h;m=f[l>>2]|0;n=f[l+4>>2]|0;l=d;o=f[l>>2]|0;p=Ul(o|0,f[l+4>>2]|0,a|0,0)|0;l=I;if((n|0)<(l|0)|(n|0)==(l|0)&m>>>0

>>0){i=0;q=5;break}Ff(g|0,(f[c>>2]|0)+o|0,a|0)|0;o=d;f[o>>2]=p;f[o+4>>2]=l;Ff((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+k|0,g|0,a|0)|0;j=j+1|0;if((j|0)>=(b|0)){i=1;q=5;break}else k=k+a|0}if((q|0)==5){jp(g);return i|0}return 0}function Eg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=a+216|0;e=a+220|0;g=f[d>>2]|0;if((f[e>>2]|0)==(g|0)){h=0;return h|0}i=a+4|0;a=g;g=0;a:while(1){j=f[a+(g*144|0)>>2]|0;if(((j|0)>=0?(k=f[i>>2]|0,l=f[k+8>>2]|0,(j|0)<((f[k+12>>2]|0)-l>>2|0)):0)?(k=f[l+(j<<2)>>2]|0,(Ma[f[(f[k>>2]|0)+24>>2]&127](k)|0)>0):0){j=0;do{if((Na[f[(f[k>>2]|0)+20>>2]&127](k,j)|0)==(c|0))break a;j=j+1|0}while((j|0)<(Ma[f[(f[k>>2]|0)+24>>2]&127](k)|0))}k=g+1|0;a=f[d>>2]|0;if(k>>>0>=(((f[e>>2]|0)-a|0)/144|0)>>>0){h=0;m=11;break}else g=k}if((m|0)==11)return h|0;m=f[d>>2]|0;h=(b[m+(g*144|0)+100>>0]|0)==0?0:m+(g*144|0)+4|0;return h|0}function Fg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;j=f[g+4>>2]|0;g=Ul(i|0,j|0,4,0)|0;k=I;if((e|0)<(k|0)|(e|0)==(k|0)&d>>>0>>0){l=0;return l|0}m=(f[b>>2]|0)+i|0;b=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=c;f[m>>2]=g;f[m+4>>2]=k;k=Ul(i|0,j|0,8,0)|0;j=I;if((e|0)<(j|0)|(e|0)==(j|0)&d>>>0>>0){l=0;return l|0}d=c;f[d>>2]=k;f[d+4>>2]=j;if(!(b&1)){l=0;return l|0}j=(_(b|0)|0)^31;if((j+-1|0)>>>0>28){l=0;return l|0}f[a+8>>2]=j+1;b=2<>2]=b+-1;j=b+-2|0;f[a+16>>2]=j;f[a+20>>2]=(j|0)/2|0;l=1;return l|0}function Gg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;if(b>>>0<64){b=f[a+12>>2]|0;if(b>>>0<=1){e=0;return e|0}d=f[c>>2]|0;c=1;g=0;while(1){h=(f[d+(g<<2)>>2]|0)>>>0>(f[d+(c<<2)>>2]|0)>>>0?c:g;c=c+1|0;if(c>>>0>=b>>>0){e=h;break}else g=h}return e|0}g=a+580|0;b=f[g>>2]|0;c=32-b|0;d=a+576|0;if((c|0)<4){h=f[d>>2]|0;i=h+4|0;if((i|0)==(f[a+568>>2]|0)){e=0;return e|0}j=f[h>>2]<>2]=h;f[d>>2]=i;k=32-h|0;e=(f[i>>2]|0)>>>k|j>>>(k-c|0);return e|0}c=f[d>>2]|0;if((c|0)==(f[a+568>>2]|0)){e=0;return e|0}a=f[c>>2]<>>28;k=b+4|0;f[g>>2]=k;if((k|0)!=32){e=a;return e|0}f[d>>2]=c+4;f[g>>2]=0;e=a;return e|0}function Hg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+216|0;d=a+220|0;e=f[c>>2]|0;a:do if((f[d>>2]|0)!=(e|0)){g=a+4|0;h=e;i=0;b:while(1){j=f[h+(i*144|0)>>2]|0;if(((j|0)>=0?(k=f[g>>2]|0,l=f[k+8>>2]|0,(j|0)<((f[k+12>>2]|0)-l>>2|0)):0)?(k=f[l+(j<<2)>>2]|0,(Ma[f[(f[k>>2]|0)+24>>2]&127](k)|0)>0):0){j=0;do{if((Na[f[(f[k>>2]|0)+20>>2]&127](k,j)|0)==(b|0))break b;j=j+1|0}while((j|0)<(Ma[f[(f[k>>2]|0)+24>>2]&127](k)|0))}k=i+1|0;h=f[c>>2]|0;if(k>>>0>=(((f[d>>2]|0)-h|0)/144|0)>>>0)break a;else i=k}m=(f[c>>2]|0)+(i*144|0)+104|0;return m|0}while(0);m=a+184|0;return m|0}function Ig(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=1312;sg(a+60|0);b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+36|0;d=f[b>>2]|0;if(d|0){c=a+40|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-24|0;f[c>>2]=e;Ra[f[f[e>>2]>>2]&127](e);h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}lp(g)}f[a>>2]=1256;g=f[a+16>>2]|0;if(g|0){b=a+20|0;d=f[b>>2]|0;if((d|0)!=(g|0))f[b>>2]=d+(~((d+-4-g|0)>>>2)<<2);lp(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);lp(g);return}function Jg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+32|0;d=c+16|0;e=c+8|0;g=c;h=a+8|0;if(f[h>>2]<<5>>>0>=b>>>0){u=c;return}f[d>>2]=0;i=d+4|0;f[i>>2]=0;j=d+8|0;f[j>>2]=0;if((b|0)<0)Eo(d);k=((b+-1|0)>>>5)+1|0;b=Yk(k<<2)|0;f[d>>2]=b;f[i>>2]=0;f[j>>2]=k;k=f[a>>2]|0;f[e>>2]=k;f[e+4>>2]=0;b=a+4|0;l=f[b>>2]|0;f[g>>2]=k+(l>>>5<<2);f[g+4>>2]=l&31;$e(d,e,g);g=f[a>>2]|0;f[a>>2]=f[d>>2];f[d>>2]=g;d=f[b>>2]|0;f[b>>2]=f[i>>2];f[i>>2]=d;d=f[h>>2]|0;f[h>>2]=f[j>>2];f[j>>2]=d;if(g|0)lp(g);u=c;return}function Kg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=u;u=u+16|0;e=c;do if(((h[(f[a+4>>2]|0)+36>>0]|0)<<8&65535)>511){g=d+8|0;i=f[g+4>>2]|0;j=d+16|0;k=j;l=f[k>>2]|0;m=f[k+4>>2]|0;if((i|0)>(m|0)|((i|0)==(m|0)?(f[g>>2]|0)>>>0>l>>>0:0)){g=b[(f[d>>2]|0)+l>>0]|0;i=Ul(l|0,m|0,1,0)|0;m=j;f[m>>2]=i;f[m+4>>2]=I;m=g&255;f[a+24>>2]=m;n=m;break}else{o=0;u=c;return o|0}}else n=f[a+24>>2]|0;while(0);f[e>>2]=1200;f[e+4>>2]=-1;Mn(e,n);o=$i(e,f[a+16>>2]|0)|0;u=c;return o|0}function Lg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=(e|0)/12|0;h=g+1|0;if(h>>>0>357913941)Eo(a);i=a+8|0;j=((f[i>>2]|0)-d|0)/12|0;k=j<<1;l=j>>>0<178956970?(k>>>0>>0?h:k):357913941;do if(l)if(l>>>0>357913941){k=ra(8)|0;cn(k,13392);f[k>>2]=4748;va(k|0,1128,101)}else{m=Yk(l*12|0)|0;break}else m=0;while(0);k=m+(g*12|0)|0;f[k>>2]=f[b>>2];f[k+4>>2]=f[b+4>>2];f[k+8>>2]=f[b+8>>2];b=k+(((e|0)/-12|0)*12|0)|0;if((e|0)>0)Ff(b|0,d|0,e|0)|0;f[a>>2]=b;f[c>>2]=k+12;f[i>>2]=m+(l*12|0);if(!d)return;lp(d);return}function Mg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=u;u=u+16|0;d=c;e=_e(a,d,b)|0;g=f[e>>2]|0;if(g|0){h=g;i=h+28|0;u=c;return i|0}g=Yk(40)|0;zh(g+16|0,b);b=g+28|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;b=f[d>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=b;f[e>>2]=g;b=f[f[a>>2]>>2]|0;if(!b)j=g;else{f[a>>2]=b;j=f[e>>2]|0}wd(f[a+4>>2]|0,j);j=a+8|0;f[j>>2]=(f[j>>2]|0)+1;h=g;i=h+28|0;u=c;return i|0}function Ng(a,c,d,e,g,h,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0;k=u;u=u+16|0;l=k;if((-18-c|0)>>>0>>0)Eo(a);if((b[a+11>>0]|0)<0)m=f[a>>2]|0;else m=a;if(c>>>0<2147483623){n=d+c|0;d=c<<1;o=n>>>0>>0?d:n;p=o>>>0<11?11:o+16&-16}else p=-17;o=Yk(p)|0;if(g|0)Tm(o,m,g)|0;if(i|0)Tm(o+g|0,j,i)|0;j=e-h|0;e=j-g|0;if(e|0)Tm(o+g+i|0,m+g+h|0,e)|0;if((c|0)!=10)lp(m);f[a>>2]=o;f[a+8>>2]=p|-2147483648;p=j+i|0;f[a+4>>2]=p;b[l>>0]=0;_n(o+p|0,l);u=k;return}function Og(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>2>>>0>=b>>>0){Dh(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}h=f[a>>2]|0;i=g-h|0;g=i>>2;j=g+b|0;if(j>>>0>1073741823)Eo(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?j:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;cn(d,13392);f[d>>2]=4748;va(d|0,1128,101)}else{m=Yk(l<<2)|0;break}else m=0;while(0);d=m+(g<<2)|0;Dh(d|0,0,b<<2|0)|0;j=d+(0-g<<2)|0;if((i|0)>0)Ff(j|0,h|0,i|0)|0;f[a>>2]=j;f[e>>2]=d+(b<<2);f[c>>2]=m+(l<<2);if(!h)return;lp(h);return}function Pg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{f[c>>2]=g+-144;d=f[g+-12>>2]|0;if(d|0){h=g+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d)}d=f[g+-28>>2]|0;if(d|0){i=g+-24|0;h=f[i>>2]|0;if((h|0)!=(d|0))f[i>>2]=h+(~((h+-4-d|0)>>>2)<<2);lp(d)}d=f[g+-40>>2]|0;if(d|0){h=g+-36|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);lp(d)}ah(g+-140|0);g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}lp(e);return}function Qg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;a=u;u=u+16|0;e=a;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;g=Rh(d)|0;if(g>>>0>4294967279)Eo(e);if(g>>>0<11){b[e+11>>0]=g;if(!g)h=e;else{i=e;j=6}}else{k=g+16&-16;l=Yk(k)|0;f[e>>2]=l;f[e+8>>2]=k|-2147483648;f[e+4>>2]=g;i=l;j=6}if((j|0)==6){Ff(i|0,d|0,g|0)|0;h=i}b[h+g>>0]=0;g=(vc(c,e)|0)!=0;if((b[e+11>>0]|0)>=0){u=a;return g|0}lp(f[e>>2]|0);u=a;return g|0}function Rg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if((e-h|0)>>>0>=c>>>0){i=h;j=c;do{b[i>>0]=0;i=(f[g>>2]|0)+1|0;f[g>>2]=i;j=j+-1|0}while((j|0)!=0);return}j=f[a>>2]|0;i=h-j|0;h=i+c|0;if((h|0)<0)Eo(a);k=e-j|0;j=k<<1;e=k>>>0<1073741823?(j>>>0>>0?h:j):2147483647;if(!e)l=0;else l=Yk(e)|0;j=l+i|0;i=l+e|0;e=j;l=c;c=j;do{b[e>>0]=0;e=c+1|0;c=e;l=l+-1|0}while((l|0)!=0);l=f[a>>2]|0;e=(f[g>>2]|0)-l|0;h=j+(0-e)|0;if((e|0)>0)Ff(h|0,l|0,e|0)|0;f[a>>2]=h;f[g>>2]=c;f[d>>2]=i;if(!l)return;lp(l);return}function Sg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3288;b=a+84|0;c=a+4|0;d=c+80|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+88>>2]=-1;f[a+92>>2]=-1;b=a+152|0;c=a+96|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));n[b>>2]=$(1.0);b=a+212|0;c=a+156|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+216>>2]=0;f[a+220>>2]=0;f[a+224>>2]=0;Ck(a+232|0);b=a+380|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[a+400>>2]=-1;f[a+404>>2]=-1;f[a+408>>2]=2;f[a+412>>2]=7;b=a+416|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function Tg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0;d=u;u=u+32|0;c=d;if((h[(f[a+4>>2]|0)+36>>0]<<8&65535)>511?!(Ma[f[(f[a>>2]|0)+52>>2]&127](a)|0):0){e=0;u=d;return e|0}f[c>>2]=1228;f[c+4>>2]=-1;g=c+8|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;Ij(c,f[a+24>>2]|0,f[a+28>>2]|0,b[(f[a+8>>2]|0)+24>>0]|0,$(n[a+32>>2]));i=$i(c,f[a+16>>2]|0)|0;f[c>>2]=1228;a=f[g>>2]|0;if(a|0){g=c+12|0;c=f[g>>2]|0;if((c|0)!=(a|0))f[g>>2]=c+(~((c+-4-a|0)>>>2)<<2);lp(a)}e=i;u=d;return e|0}function Ug(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{f[c>>2]=e+-144;d=f[e+-12>>2]|0;if(d|0){g=e+-8|0;h=f[g>>2]|0;if((h|0)!=(d|0))f[g>>2]=h+(~((h+-4-d|0)>>>2)<<2);lp(d)}d=f[e+-28>>2]|0;if(d|0){h=e+-24|0;g=f[h>>2]|0;if((g|0)!=(d|0))f[h>>2]=g+(~((g+-4-d|0)>>>2)<<2);lp(d)}d=f[e+-40>>2]|0;if(d|0){g=e+-36|0;h=f[g>>2]|0;if((h|0)!=(d|0))f[g>>2]=h+(~((h+-4-d|0)>>>2)<<2);lp(d)}ah(e+-140|0);e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;lp(b);return}function Vg(a){a=a|0;var b=0,c=0,d=0;b=f[a+76>>2]|0;if(b|0){c=a+80|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+64>>2]|0;if(b|0){d=a+68|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;lp(b)}b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+24>>2]|0;if(b|0){c=a+28|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+12>>2]|0;if(b|0){d=a+16|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function Wg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+32|0;e=a+12|0;g=a;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Rh(d)|0;if(h>>>0>4294967279)Eo(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;h=Ah(c,g,e)|0;if((b[g+11>>0]|0)<0)lp(f[g>>2]|0);if((b[e+11>>0]|0)>=0){u=a;return h|0}lp(f[e>>2]|0);u=a;return h|0}function Xg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=i;i=j;while(1){if(k<<24>>24<0)l=f[c>>2]|0;else l=c;f[g>>2]=d;m=wl(l,i+1|0,15886,g)|0;if((m|0)>-1)if(m>>>0>i>>>0)n=m;else break;else n=i<<1|1;Th(c,n,0);k=b[h>>0]|0;i=n}Th(c,m,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Yg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a+8|0;c=f[b>>2]|0;if((c|0)<0){d=0;return d|0}e=a+4|0;a=f[e>>2]|0;g=a+4|0;h=f[g>>2]|0;i=f[a>>2]|0;j=h-i>>2;k=i;i=h;if(c>>>0<=j>>>0)if(c>>>0>>0?(h=k+(c<<2)|0,(i|0)!=(h|0)):0){f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2);l=c}else l=c;else{Og(a,c-j|0);l=f[b>>2]|0}if((l|0)<=0){d=1;return d|0}b=f[e>>2]|0;e=f[b>>2]|0;j=(f[b+4>>2]|0)-e>>2;c=e;e=0;while(1){if(j>>>0<=e>>>0){m=10;break}f[c+(e<<2)>>2]=e;e=e+1|0;if((e|0)>=(l|0)){d=1;m=12;break}}if((m|0)==10)Eo(b);else if((m|0)==12)return d|0;return 0}function Zg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=a+140|0;c=f[b>>2]|0;if((c|0)<=0){d=1;return d|0}e=c<<4;g=ip(c>>>0>268435455|e>>>0>4294967291?-1:e+4|0)|0;f[g>>2]=c;e=g+4|0;g=e+(c<<4)|0;c=e;do{Ym(c);c=c+16|0}while((c|0)!=(g|0));g=a+136|0;c=f[g>>2]|0;f[g>>2]=e;if(c|0){e=c+-4|0;h=f[e>>2]|0;if(h|0){i=c+(h<<4)|0;do{i=i+-16|0;qp(i)}while((i|0)!=(c|0))}jp(e)}if((f[b>>2]|0)<=0){d=1;return d|0}e=0;while(1){if(!(ud((f[g>>2]|0)+(e<<4)|0,a)|0)){d=0;j=13;break}e=e+1|0;if((e|0)>=(f[b>>2]|0)){d=1;j=13;break}}if((j|0)==13)return d|0;return 0}function _g(){var a=0,b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+48|0;b=a+32|0;c=a+24|0;d=a+16|0;e=a;g=a+36|0;a=dl()|0;if(a|0?(h=f[a>>2]|0,h|0):0){a=h+48|0;i=f[a>>2]|0;j=f[a+4>>2]|0;if(!((i&-256|0)==1126902528&(j|0)==1129074247)){f[c>>2]=f[1159];Bl(15975,c)}if((i|0)==1126902529&(j|0)==1129074247)k=f[h+44>>2]|0;else k=h+80|0;f[g>>2]=k;k=f[h>>2]|0;h=f[k+4>>2]|0;j=Oa[f[(f[262]|0)+16>>2]&31](1048,k,g)|0;k=f[1159]|0;if(j){j=f[g>>2]|0;g=Ma[f[(f[j>>2]|0)+8>>2]&127](j)|0;f[e>>2]=k;f[e+4>>2]=h;f[e+8>>2]=g;Bl(15889,e)}else{f[d>>2]=k;f[d+4>>2]=h;Bl(15934,d)}}Bl(16013,b)}function $g(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a>>2]|0;f[a>>2]=0;if(!c)return;a=f[c+28>>2]|0;if(a|0){d=a;do{a=d;d=f[d>>2]|0;e=a+8|0;$g(a+20|0);if((b[e+11>>0]|0)<0)lp(f[e>>2]|0);lp(a)}while((d|0)!=0)}d=c+20|0;a=f[d>>2]|0;f[d>>2]=0;if(a|0)lp(a);a=f[c+8>>2]|0;if(a|0){d=a;do{a=d;d=f[d>>2]|0;e=a+8|0;g=f[a+20>>2]|0;if(g|0){h=a+24|0;if((f[h>>2]|0)!=(g|0))f[h>>2]=g;lp(g)}if((b[e+11>>0]|0)<0)lp(f[e>>2]|0);lp(a)}while((d|0)!=0)}d=f[c>>2]|0;f[c>>2]=0;if(d|0)lp(d);lp(c);return}function ah(a){a=a|0;var b=0,c=0,d=0;b=f[a+84>>2]|0;if(b|0){c=a+88|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+72>>2]|0;if(b|0){d=a+76|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;lp(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+28>>2]|0;if(b|0){d=a+32|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+12>>2]|0;if(b|0)lp(b);b=f[a>>2]|0;if(!b)return;lp(b);return}function bh(a){a=a|0;var b=0,c=0,d=0;b=f[a+92>>2]|0;if(b|0){c=a+96|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+76>>2]|0;if(b|0){d=a+80|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b)}f[a+4>>2]=3196;b=f[a+24>>2]|0;if(b|0)lp(b);b=f[a+12>>2]|0;if(!b)return;lp(b);return}function ch(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;do if(a){if(c>>>0<128){b[a>>0]=c;e=1;break}d=(hp()|0)+188|0;if(!(f[f[d>>2]>>2]|0))if((c&-128|0)==57216){b[a>>0]=c;e=1;break}else{d=_o()|0;f[d>>2]=84;e=-1;break}if(c>>>0<2048){b[a>>0]=c>>>6|192;b[a+1>>0]=c&63|128;e=2;break}if(c>>>0<55296|(c&-8192|0)==57344){b[a>>0]=c>>>12|224;b[a+1>>0]=c>>>6&63|128;b[a+2>>0]=c&63|128;e=3;break}if((c+-65536|0)>>>0<1048576){b[a>>0]=c>>>18|240;b[a+1>>0]=c>>>12&63|128;b[a+2>>0]=c>>>6&63|128;b[a+3>>0]=c&63|128;e=4;break}else{d=_o()|0;f[d>>2]=84;e=-1;break}}else e=1;while(0);return e|0}function dh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=e>>2;h=g+1|0;if(h>>>0>1073741823)Eo(a);i=a+8|0;j=(f[i>>2]|0)-d|0;k=j>>1;l=j>>2>>>0<536870911?(k>>>0>>0?h:k):1073741823;do if(l)if(l>>>0>1073741823){k=ra(8)|0;cn(k,13392);f[k>>2]=4748;va(k|0,1128,101)}else{m=Yk(l<<2)|0;break}else m=0;while(0);k=m+(g<<2)|0;f[k>>2]=f[b>>2];b=k+(0-g<<2)|0;if((e|0)>0)Ff(b|0,d|0,e|0)|0;f[a>>2]=b;f[c>>2]=k+4;f[i>>2]=m+(l<<2);if(!d)return;lp(d);return}function eh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0.0;a=u;u=u+32|0;e=a;g=a+8|0;p[e>>3]=0.0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Rh(d)|0;if(h>>>0>4294967279)Eo(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;eg(c,g,e)|0;n=+p[e>>3];if((b[g+11>>0]|0)>=0){u=a;return +n}lp(f[g>>2]|0);u=a;return +n}function fh(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=u;u=u+128|0;h=g+124|0;i=g;j=i;k=4124;l=j+124|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));if((c+-1|0)>>>0>2147483646)if(!c){m=1;n=h;o=4}else{h=_o()|0;f[h>>2]=75;p=-1}else{m=c;n=a;o=4}if((o|0)==4){o=-2-n|0;a=m>>>0>o>>>0?o:m;f[i+48>>2]=a;m=i+20|0;f[m>>2]=n;f[i+44>>2]=n;o=n+a|0;n=i+16|0;f[n>>2]=o;f[i+28>>2]=o;o=_f(i,d,e)|0;if(!a)p=o;else{a=f[m>>2]|0;b[a+(((a|0)==(f[n>>2]|0))<<31>>31)>>0]=0;p=o}}u=g;return p|0}function gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0;d=u;u=u+80|0;e=d;g=d+56|0;i=d+40|0;j=e;k=c;c=j+40|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(c|0));ac(i,e,g);k=f[i>>2]|0;if(!k){j=i+4|0;if((b[j+11>>0]|0)<0)lp(f[j>>2]|0);j=h[g+7>>0]|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=j;l=e+24|0;qp(l);u=d;return}else{f[a>>2]=k;k=i+4|0;zh(a+4|0,k);if((b[k+11>>0]|0)<0)lp(f[k>>2]|0);l=e+24|0;qp(l);u=d;return}}function hh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+16|0;e=a+12|0;g=a;f[e>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Rh(d)|0;if(h>>>0>4294967279)Eo(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;Oh(c,g,e)|0;c=f[e>>2]|0;if((b[g+11>>0]|0)>=0){u=a;return c|0}lp(f[g>>2]|0);u=a;return c|0}function ih(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+8|0;d=f[a>>2]|0;e=d;if((((f[c>>2]|0)-d|0)/12|0)>>>0>=b>>>0)return;g=a+4|0;if(b>>>0>357913941){h=ra(8)|0;cn(h,13392);f[h>>2]=4748;va(h|0,1128,101)}h=f[g>>2]|0;i=Yk(b*12|0)|0;j=i+(((h-d|0)/12|0)*12|0)|0;k=j;l=i+(b*12|0)|0;b=h;if((b|0)==(e|0))m=k;else{h=j;j=b;do{b=j;j=j+-12|0;f[h+-12>>2]=f[j>>2];f[h+-8>>2]=f[b+-8>>2];f[h+-4>>2]=f[b+-4>>2];h=h+-12|0}while((j|0)!=(e|0));m=h}f[a>>2]=m;f[g>>2]=k;f[c>>2]=l;if(!d)return;lp(d);return}function jh(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+28>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;g=c+20|0;h=f[g>>2]|0;f[g>>2]=0;if(h|0){jh(h);lp(h)}if((b[e+11>>0]|0)<0)lp(f[e>>2]|0);lp(c)}while((d|0)!=0)}d=a+20|0;c=f[d>>2]|0;f[d>>2]=0;if(c|0)lp(c);c=f[a+8>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){g=c+24|0;if((f[g>>2]|0)!=(h|0))f[g>>2]=h;lp(h)}if((b[e+11>>0]|0)<0)lp(f[e>>2]|0);lp(c)}while((d|0)!=0)}d=f[a>>2]|0;f[a>>2]=0;if(!d)return;lp(d);return}function kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+32|0;e=a;g=a+8|0;p[e>>3]=0.0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Rh(d)|0;if(h>>>0>4294967279)Eo(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;h=eg(c,g,e)|0;if((b[g+11>>0]|0)>=0){u=a;return h|0}lp(f[g>>2]|0);u=a;return h|0}function lh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+16|0;e=a+12|0;g=a;f[e>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Rh(d)|0;if(h>>>0>4294967279)Eo(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=Yk(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){Ff(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;h=Oh(c,g,e)|0;if((b[g+11>>0]|0)>=0){u=a;return h|0}lp(f[g>>2]|0);u=a;return h|0}function mh(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3240;b=a+84|0;c=a+4|0;d=c+80|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+88>>2]=-1;f[a+92>>2]=-1;b=a+152|0;c=a+96|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));n[b>>2]=$(1.0);b=a+212|0;c=a+156|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+216>>2]=0;f[a+220>>2]=0;f[a+224>>2]=0;Ck(a+232|0);b=a+380|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;Ym(a+400|0);f[a+416>>2]=-1;f[a+420>>2]=-1;return}function nh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=c+8|0;e=f[d+4>>2]|0;g=c+16|0;h=g;i=f[h>>2]|0;j=f[h+4>>2]|0;if(!((e|0)>(j|0)|((e|0)==(j|0)?(f[d>>2]|0)>>>0>i>>>0:0))){k=0;return k|0}d=b[(f[c>>2]|0)+i>>0]|0;e=Ul(i|0,j|0,1,0)|0;j=g;f[j>>2]=e;f[j+4>>2]=I;do if(d<<24>>24<0)if(nh(a,c)|0){j=a;e=Rl(f[j>>2]|0,f[j+4>>2]|0,7)|0;j=I;g=a;f[g>>2]=e;f[g+4>>2]=j;l=e|d&127;m=j;break}else{k=0;return k|0}else{l=d&255;m=0}while(0);d=a;f[d>>2]=l;f[d+4>>2]=m;k=1;return k|0}function oh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0;do if(((h[(f[a+4>>2]|0)+36>>0]|0)<<8&65535)<512){e=d+8|0;g=f[e+4>>2]|0;i=d+16|0;j=i;k=f[j>>2]|0;l=f[j+4>>2]|0;if((g|0)>(l|0)|((g|0)==(l|0)?(f[e>>2]|0)>>>0>k>>>0:0)){e=b[(f[d>>2]|0)+k>>0]|0;g=Ul(k|0,l|0,1,0)|0;l=i;f[l>>2]=g;f[l+4>>2]=I;f[a+24>>2]=e&255;break}else{m=0;return m|0}}while(0);m=qc(a,c,d)|0;return m|0}function ph(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;if(b>>>0>1431655765|(c|b|0)<0){d=0;return d|0}e=b*3|0;Le(a,e,3568);Le(a+12|0,e,3564);fi(a+24|0,c);c=a+76|0;e=f[c>>2]|0;b=a+80|0;g=f[b>>2]|0;if((g|0)!=(e|0))f[b>>2]=g+(~((g+-4-e|0)>>>2)<<2);f[c>>2]=0;f[b>>2]=0;f[a+84>>2]=0;if(e|0)lp(e);e=a+64|0;b=f[e>>2]|0;c=a+68|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;f[e>>2]=0;f[c>>2]=0;f[a+72>>2]=0;if(!b){d=1;return d|0}lp(b);d=1;return d|0}function qh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+48|0;g=e+4|0;h=e;if((d|0)!=1){f[a>>2]=0;u=e;return}d=f[b+12>>2]|0;i=f[b+4>>2]|0;b=g;j=b+36|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));jg(h,c,d,i,g);i=f[g+24>>2]|0;if(i|0){d=g+28|0;g=f[d>>2]|0;if((g|0)!=(i|0))f[d>>2]=g+(~((g+-4-i|0)>>>2)<<2);lp(i)}f[a>>2]=f[h>>2];u=e;return}function rh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e;if(c|0){h=a+11|0;i=b[h>>0]|0;if(i<<24>>24<0){j=f[a+4>>2]|0;k=(f[a+8>>2]&2147483647)+-1|0}else{j=i&255;k=10}l=j+c|0;if((k-j|0)>>>0>>0){Jh(a,k,l-k|0,j,j,0,0);m=b[h>>0]|0}else m=i;if(m<<24>>24<0)n=f[a>>2]|0;else n=a;Pl(n+j|0,c,d)|0;if((b[h>>0]|0)<0)f[a+4>>2]=l;else b[h>>0]=l;b[g>>0]=0;_n(n+l|0,g)}u=e;return a|0}function sh(a,b){a=a|0;b=b|0;var c=0,d=0;c=a+16|0;a=f[b>>2]|0;f[b>>2]=0;b=f[c>>2]|0;f[c>>2]=a;if(!b)return;a=b+88|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0){a=f[c+8>>2]|0;if(a|0){d=c+12|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;lp(a)}lp(c)}c=f[b+68>>2]|0;if(c|0){a=b+72|0;d=f[a>>2]|0;if((d|0)!=(c|0))f[a>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c)}c=b+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){a=d+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;lp(c)}lp(d)}lp(b);return}function th(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=(f[a+8>>2]&2147483647)+-1|0;else k=10;do if(k>>>0>=d>>>0){if(j)l=f[a>>2]|0;else l=a;Rm(l,c,d)|0;b[g>>0]=0;_n(l+d|0,g);if((b[h>>0]|0)<0){f[a+4>>2]=d;break}else{b[h>>0]=d;break}}else{if(j)m=f[a+4>>2]|0;else m=i&255;Ng(a,k,d-k|0,m,0,m,d,c)}while(0);u=e;return a|0}function uh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=3012;b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Ra[f[(f[c>>2]|0)+4>>2]&127](c);f[a>>2]=3440;c=f[a+20>>2]|0;if(c|0){b=a+24|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c)}c=a+8|0;d=f[c>>2]|0;if(!d){lp(a);return}b=a+12|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Ra[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}lp(g);lp(a);return}function vh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=f[a>>2]|0;if(!d){e=0;return e|0}g=f[c>>2]|0;if(!g){e=0;return e|0}h=f[g>>2]|0;Hh(d,h,(f[g+4>>2]|0)-h|0,0)|0;b[a+24>>0]=b[c+24>>0]|0;f[a+28>>2]=f[c+28>>2];b[a+32>>0]=b[c+32>>0]|0;h=c+40|0;g=f[h+4>>2]|0;d=a+40|0;f[d>>2]=f[h>>2];f[d+4>>2]=g;g=c+48|0;d=f[g+4>>2]|0;h=a+48|0;f[h>>2]=f[g>>2];f[h+4>>2]=d;f[a+56>>2]=f[c+56>>2];d=c+8|0;c=a+8|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];e=1;return e|0}function wh(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0;b[c+53>>0]=1;do if((f[c+4>>2]|0)==(e|0)){b[c+52>>0]=1;a=c+16|0;h=f[a>>2]|0;i=c+54|0;j=c+48|0;k=c+24|0;l=c+36|0;if(!h){f[a>>2]=d;f[k>>2]=g;f[l>>2]=1;if(!((f[j>>2]|0)==1&(g|0)==1))break;b[i>>0]=1;break}if((h|0)!=(d|0)){f[l>>2]=(f[l>>2]|0)+1;b[i>>0]=1;break}l=f[k>>2]|0;if((l|0)==2){f[k>>2]=g;m=g}else m=l;if((f[j>>2]|0)==1&(m|0)==1)b[i>>0]=1}while(0);return}function xh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=3012;b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Ra[f[(f[c>>2]|0)+4>>2]&127](c);f[a>>2]=3440;c=f[a+20>>2]|0;if(c|0){b=a+24|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c)}c=a+8|0;d=f[c>>2]|0;if(!d)return;b=a+12|0;a=f[b>>2]|0;if((a|0)==(d|0))e=d;else{g=a;do{a=g+-4|0;f[b>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Ra[f[(f[h>>2]|0)+4>>2]&127](h);g=f[b>>2]|0}while((g|0)!=(d|0));e=f[c>>2]|0}lp(e);return}function yh(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(!a){g=1;return g|0}h=d+8|0;i=f[h+4>>2]|0;j=d+16|0;k=j;l=f[k>>2]|0;m=f[k+4>>2]|0;if(!((i|0)>(m|0)|((i|0)==(m|0)?(f[h>>2]|0)>>>0>l>>>0:0))){g=0;return g|0}h=b[(f[d>>2]|0)+l>>0]|0;i=Ul(l|0,m|0,1,0)|0;m=j;f[m>>2]=i;f[m+4>>2]=I;switch(h<<24>>24){case 0:{g=yc(a,c,d,e)|0;return g|0}case 1:{g=ad(a,d,e)|0;return g|0}default:{g=0;return g|0}}return 0}function zh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;if((b[c+11>>0]|0)<0){g=f[c>>2]|0;h=f[c+4>>2]|0;if(h>>>0>4294967279)Eo(a);if(h>>>0<11){b[a+11>>0]=h;i=a}else{j=h+16&-16;k=Yk(j)|0;f[a>>2]=k;f[a+8>>2]=j|-2147483648;f[a+4>>2]=h;i=k}Tm(i,g,h)|0;b[e>>0]=0;_n(i+h|0,e)}else{f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2]}u=d;return}function Ah(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=vc(a,b)|0;if(!d){e=0;return e|0}b=d+20|0;a=f[b>>2]|0;g=d+24|0;d=f[g>>2]|0;if((a|0)==(d|0)){e=0;return e|0}Th(c,d-a|0,0);a=Fj(c,0)|0;c=f[b>>2]|0;Ff(a|0,c|0,(f[g>>2]|0)-c|0)|0;e=1;return e|0}function Bh(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;do if(!(Hn(a,f[c+8>>2]|0,g)|0)){if(Hn(a,f[c>>2]|0,g)|0){h=c+32|0;if((f[c+16>>2]|0)!=(d|0)?(i=c+20|0,(f[i>>2]|0)!=(d|0)):0){f[h>>2]=e;f[i>>2]=d;i=c+40|0;f[i>>2]=(f[i>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0)b[c+54>>0]=1;f[c+44>>2]=4;break}if((e|0)==1)f[h>>2]=1}}else Pk(0,c,d,e);while(0);return}function Ch(a){a=a|0;qp(a+496|0);qp(a+480|0);qp(a+464|0);qp(a+448|0);qp(a+432|0);qp(a+416|0);qp(a+400|0);qp(a+384|0);qp(a+368|0);qp(a+352|0);qp(a+336|0);qp(a+320|0);qp(a+304|0);qp(a+288|0);qp(a+272|0);qp(a+256|0);qp(a+240|0);qp(a+224|0);qp(a+208|0);qp(a+192|0);qp(a+176|0);qp(a+160|0);qp(a+144|0);qp(a+128|0);qp(a+112|0);qp(a+96|0);qp(a+80|0);qp(a+64|0);qp(a+48|0);qp(a+32|0);qp(a+16|0);qp(a);return}function Dh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+d|0;c=c&255;if((d|0)>=67){while(a&3){b[a>>0]=c;a=a+1|0}g=e&-4|0;h=g-64|0;i=c|c<<8|c<<16|c<<24;while((a|0)<=(h|0)){f[a>>2]=i;f[a+4>>2]=i;f[a+8>>2]=i;f[a+12>>2]=i;f[a+16>>2]=i;f[a+20>>2]=i;f[a+24>>2]=i;f[a+28>>2]=i;f[a+32>>2]=i;f[a+36>>2]=i;f[a+40>>2]=i;f[a+44>>2]=i;f[a+48>>2]=i;f[a+52>>2]=i;f[a+56>>2]=i;f[a+60>>2]=i;a=a+64|0}while((a|0)<(g|0)){f[a>>2]=i;a=a+4|0}}while((a|0)<(e|0)){b[a>>0]=c;a=a+1|0}return e-d|0}function Eh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(!b){d=0;f[c>>2]=d;return}e=a+8|0;g=a+4|0;i=0-(h[a+12>>0]|0)&255;j=f[e>>2]|0;k=b;b=0;while(1){l=b<<1;if(j>>>0<4096?(m=f[g>>2]|0,(m|0)>0):0){n=f[a>>2]|0;o=m+-1|0;f[g>>2]=o;m=h[n+o>>0]|0|j<<8;f[e>>2]=m;p=m}else p=j;m=p&255;o=X(p>>>8,i)|0;n=m>>>0>>0;j=n?o+m|0:p-i-o|0;f[e>>2]=j;o=n&1|l;k=k+-1|0;if(!k){d=o;break}else b=o}f[c>>2]=d;return}function Fh(a,b){a=a|0;b=b|0;var c=0;switch(f[(f[a+8>>2]|0)+28>>2]|0){case 2:{vg(a,b);c=1;return c|0}case 1:{vg(a,b);c=1;return c|0}case 4:{mg(a,b);c=1;return c|0}case 3:{mg(a,b);c=1;return c|0}case 6:{ng(a,b);c=1;return c|0}case 5:{ng(a,b);c=1;return c|0}default:{c=0;return c|0}}return 0}function Gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;f[a>>2]=c;f[a+68>>2]=0;f[a+72>>2]=0;Yd(e,c);g=a+4|0;h=f[e>>2]|0;f[e>>2]=0;i=f[g>>2]|0;f[g>>2]=h;if(i){Vg(i);lp(i);i=f[e>>2]|0;f[e>>2]=0;if(i|0){Vg(i);lp(i)}}else f[e>>2]=0;if(!(f[g>>2]|0)){j=0;u=d;return j|0}g=((f[c+100>>2]|0)-(f[c+96>>2]|0)|0)/12|0;b[e>>0]=0;Hf(a+56|0,g,e);j=1;u=d;return j|0}function Hh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;if((d|0)<0){e=0;return e|0}do if(!b){d=a+4|0;g=f[d>>2]|0;h=f[a>>2]|0;i=g-h|0;if(c>>>0>i>>>0){Rg(a,c-i|0);break}if(c>>>0>>0?(i=h+c|0,(g|0)!=(i|0)):0)f[d>>2]=i}else df(a,b,b+c|0);while(0);c=a+24|0;a=c;b=Ul(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=c;f[a>>2]=b;f[a+4>>2]=I;e=1;return e|0}function Ih(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1368;b=a+16|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;lp(b)}lp(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;lp(c)}lp(d)}lp(a);return}function Jh(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;if((-17-c|0)>>>0>>0)Eo(a);if((b[a+11>>0]|0)<0)j=f[a>>2]|0;else j=a;if(c>>>0<2147483623){k=d+c|0;d=c<<1;l=k>>>0>>0?d:k;m=l>>>0<11?11:l+16&-16}else m=-17;l=Yk(m)|0;if(g|0)Tm(l,j,g)|0;k=e-h-g|0;if(k|0)Tm(l+g+i|0,j+g+h|0,k)|0;if((c|0)!=10)lp(j);f[a>>2]=l;f[a+8>>2]=m|-2147483648;return}function Kh(a,b){a=a|0;b=b|0;if(!b)return;else{Kh(a,f[b>>2]|0);Kh(a,f[b+4>>2]|0);Qh(b+20|0,f[b+24>>2]|0);lp(b);return}}function Lh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=a+64|0;if((f[d>>2]|0)==0?(e=Yk(32)|0,ql(e),g=f[d>>2]|0,f[d>>2]=e,g|0):0){e=f[g>>2]|0;if(e|0){h=g+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;lp(e)}lp(g)}g=Zj(f[a+28>>2]|0)|0;e=X(b[a+24>>0]|0,g)|0;g=((e|0)<0)<<31>>31;h=f[d>>2]|0;i=fl(e|0,g|0,c|0,0)|0;if(!(Hh(h,0,i,I)|0)){j=0;return j|0}Oi(a,f[d>>2]|0,e,g,0,0);f[a+80>>2]=c;j=1;return j|0}function Mh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+32|0;g=e+20|0;h=e+16|0;i=e;j=b[a+24>>0]|0;f[i>>2]=f[294];f[i+4>>2]=f[295];f[i+8>>2]=f[296];f[i+12>>2]=f[297];f[h>>2]=c;f[g>>2]=f[h>>2];if(!(rb(a,g,j,i)|0)){k=0;u=e;return k|0}Je(d,i,i+(j<<24>>24<<2)|0);k=1;u=e;return k|0}function Nh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+64|0;e=d;if(!(Hn(a,b,0)|0))if((b|0)!=0?(g=cg(b,1072,1056,0)|0,(g|0)!=0):0){b=e+4|0;h=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(h|0));f[e>>2]=g;f[e+8>>2]=a;f[e+12>>2]=-1;f[e+48>>2]=1;Ua[f[(f[g>>2]|0)+28>>2]&7](g,e,f[c>>2]|0,1);if((f[e+24>>2]|0)==1){f[c>>2]=f[e+16>>2];i=1}else i=0;j=i}else j=0;else j=1;u=d;return j|0}function Oh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=vc(a,c)|0;if(!e){g=0;return g|0}c=f[e+20>>2]|0;if(((f[e+24>>2]|0)-c|0)!=4){g=0;return g|0}e=c;c=h[e>>0]|h[e+1>>0]<<8|h[e+2>>0]<<16|h[e+3>>0]<<24;b[d>>0]=c;b[d+1>>0]=c>>8;b[d+2>>0]=c>>16;b[d+3>>0]=c>>24;g=1;return g|0}function Ph(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=c+8|0;e=f[d+4>>2]|0;g=c+16|0;h=g;i=f[h>>2]|0;j=f[h+4>>2]|0;if(!((e|0)>(j|0)|((e|0)==(j|0)?(f[d>>2]|0)>>>0>i>>>0:0))){k=0;return k|0}d=b[(f[c>>2]|0)+i>>0]|0;e=Ul(i|0,j|0,1,0)|0;j=g;f[j>>2]=e;f[j+4>>2]=I;j=d&255;do if(j&128)if(Ph(a,c)|0){e=f[a>>2]<<7;f[a>>2]=e;l=e|d&127;break}else{k=0;return k|0}else l=j;while(0);f[a>>2]=l;k=1;return k|0}function Qh(a,c){a=a|0;c=c|0;var d=0;if(!c)return;Qh(a,f[c>>2]|0);Qh(a,f[c+4>>2]|0);a=c+16|0;d=c+28|0;if((b[d+11>>0]|0)<0)lp(f[d>>2]|0);if((b[a+11>>0]|0)<0)lp(f[a>>2]|0);lp(c);return}function Rh(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a;a:do if(!(c&3)){d=a;e=4}else{g=c;h=a;while(1){if(!(b[h>>0]|0)){i=g;break a}j=h+1|0;g=j;if(!(g&3)){d=j;e=4;break}else h=j}}while(0);if((e|0)==4){e=d;while(1){k=f[e>>2]|0;if(!((k&-2139062144^-2139062144)&k+-16843009))e=e+4|0;else break}if(!((k&255)<<24>>24))l=e;else{k=e;while(1){e=k+1|0;if(!(b[e>>0]|0)){l=e;break}else k=e}}i=l}return i-c|0}function Sh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=3440;b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+8|0;d=f[b>>2]|0;if(!d){lp(a);return}c=a+12|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Ra[f[(f[i>>2]|0)+4>>2]&127](i);h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}lp(g);lp(a);return}function Th(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=f[a+4>>2]|0;else k=i&255;do if(k>>>0>=c>>>0)if(j){i=(f[a>>2]|0)+c|0;b[g>>0]=0;_n(i,g);f[a+4>>2]=c;break}else{b[g>>0]=0;_n(a+c|0,g);b[h>>0]=c;break}else rh(a,c-k|0,d)|0;while(0);u=e;return}function Uh(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;lp(b)}lp(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;lp(c)}lp(d)}lp(a);return}function Vh(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;f[a>>2]=d;if(d|0){m=d+16|0;n=f[m+4>>2]|0;o=a+8|0;f[o>>2]=f[m>>2];f[o+4>>2]=n;n=d+24|0;d=f[n+4>>2]|0;o=a+16|0;f[o>>2]=f[n>>2];f[o+4>>2]=d}b[a+24>>0]=e;f[a+28>>2]=g;b[a+32>>0]=h&1;h=a+40|0;f[h>>2]=i;f[h+4>>2]=j;j=a+48|0;f[j>>2]=k;f[j+4>>2]=l;f[a+56>>2]=c;return}function Wh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=Yk(88)|0;d=c+60|0;e=c;g=e+60|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=c;d=c+64|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;d=Pe(c,b)|0;f[a>>2]=d?c:0;a=d?0:c;if(d)return;Vg(a);lp(a);return}function Xh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+16|0;e=d;g=c&255;b[e>>0]=g;i=a+16|0;j=f[i>>2]|0;if(!j)if(!(Bj(a)|0)){k=f[i>>2]|0;l=4}else m=-1;else{k=j;l=4}do if((l|0)==4){j=a+20|0;i=f[j>>2]|0;if(i>>>0>>0?(n=c&255,(n|0)!=(b[a+75>>0]|0)):0){f[j>>2]=i+1;b[i>>0]=g;m=n;break}if((Oa[f[a+36>>2]&31](a,e,1)|0)==1)m=h[e>>0]|0;else m=-1}while(0);u=d;return m|0}function Yh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;g=d+4|0;f[e>>2]=c;c=Yk(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=24;h=c;i=11771;j=h+24|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[c+24>>0]=0;ei(uc(a,e)|0,g,1);if((b[g+11>>0]|0)>=0){u=d;return}lp(f[g>>2]|0);u=d;return}function Zh(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a;while(1){d=b[c>>0]|0;e=d<<24>>24;f=c+1|0;if(!(Go(e)|0))break;else c=f}switch(e|0){case 45:{g=1;h=5;break}case 43:{g=0;h=5;break}default:{i=d;j=0;k=c}}if((h|0)==5){i=b[f>>0]|0;j=g;k=f}f=(i<<24>>24)+-48|0;if(f>>>0<10){i=f;f=0;g=k;while(1){g=g+1|0;k=(f*10|0)-i|0;i=(b[g>>0]|0)+-48|0;if(i>>>0>=10){l=k;break}else f=k}}else l=0;return (j|0?l:0-l|0)|0}function _h(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=3440;b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+8|0;d=f[b>>2]|0;if(!d)return;c=a+12|0;a=f[c>>2]|0;if((a|0)==(d|0))e=d;else{g=a;do{a=g+-4|0;f[c>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Ra[f[(f[h>>2]|0)+4>>2]&127](h);g=f[c>>2]|0}while((g|0)!=(d|0));e=f[b>>2]|0}lp(e);return}function $h(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3072;b=a+84|0;c=a+4|0;d=c+80|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+88>>2]=-1;f[a+92>>2]=-1;b=a+152|0;c=a+96|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));n[b>>2]=$(1.0);b=a+212|0;c=a+156|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+216>>2]=0;f[a+220>>2]=0;f[a+224>>2]=0;Ck(a+232|0);return}function ai(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=a&255;e=a&255;if((f[c+76>>2]|0)>=0?(rp(c)|0)!=0:0){if((e|0)!=(b[c+75>>0]|0)?(g=c+20|0,h=f[g>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[g>>2]=h+1;b[h>>0]=d;i=e}else i=Xh(c,a)|0;qp(c);j=i}else k=3;do if((k|0)==3){if((e|0)!=(b[c+75>>0]|0)?(i=c+20|0,h=f[i>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[i>>2]=h+1;b[h>>0]=d;j=e;break}j=Xh(c,a)|0}while(0);return j|0}function bi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if(c>>>0>0|(c|0)==0&a>>>0>4294967295){e=a;f=c;c=d;while(1){g=Wk(e|0,f|0,10,0)|0;c=c+-1|0;b[c>>0]=g&255|48;g=e;e=Nn(e|0,f|0,10,0)|0;if(!(f>>>0>9|(f|0)==9&g>>>0>4294967295))break;else f=I}h=c;i=e}else{h=d;i=a}if(!i)j=h;else{a=h;h=i;while(1){i=a+-1|0;b[i>>0]=(h>>>0)%10|0|48;if(h>>>0<10){j=i;break}else{a=i;h=(h>>>0)/10|0}}}return j|0}function ci(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=b+4|0;e=(f[d>>2]|0)-(f[b>>2]|0)|0;g=(e|0)/20|0;if(!e)return;if(g>>>0>214748364)Eo(a);h=Yk(e)|0;f[c>>2]=h;f[a>>2]=h;f[a+8>>2]=h+(g*20|0);g=f[b>>2]|0;b=(f[d>>2]|0)-g|0;if((b|0)<=0)return;Ff(h|0,g|0,b|0)|0;f[c>>2]=h+(((b>>>0)/20|0)*20|0);return}function di(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,i=0,j=0,k=0;b=f[a+32>>2]|0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;j=Ul(i|0,f[g+4>>2]|0,4,0)|0;g=I;if((e|0)<(g|0)|(e|0)==(g|0)&d>>>0>>0){k=0;return k|0}d=(f[b>>2]|0)+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=c;f[d>>2]=j;f[d+4>>2]=g;if((i|0)<0){k=0;return k|0}f[(f[a+4>>2]|0)+80>>2]=i;k=1;return k|0}function ei(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;sj(g,d&1);d=Mg(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}Mf(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function fi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=a+8|0;d=f[a>>2]|0;if((f[c>>2]|0)-d>>2>>>0>=b>>>0)return;e=a+4|0;if(b>>>0>1073741823){g=ra(8)|0;cn(g,13392);f[g>>2]=4748;va(g|0,1128,101)}g=(f[e>>2]|0)-d|0;h=g>>2;i=Yk(b<<2)|0;j=i+(h<<2)|0;k=j+(0-h<<2)|0;if((g|0)>0)Ff(k|0,d|0,g|0)|0;f[a>>2]=k;f[e>>2]=j;f[c>>2]=i+(b<<2);if(!d)return;lp(d);return}function gi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2124;b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+84>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0)lp(b);b=f[a+60>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function hi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=qf(a,c)|0;if((e|0)==(a+4|0)){g=-1;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}a=e+28|0;if((b[a+11>>0]|0)<0)k=f[a>>2]|0;else k=a;g=Zh(k)|0;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}function ii(a){a=a|0;var b=0,c=0,d=0,e=0;qp(a+168|0);b=f[a+156>>2]|0;if(b|0){c=a+160|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=a+136|0;d=f[b>>2]|0;f[b>>2]=0;if(d|0){b=d+-4|0;c=f[b>>2]|0;if(c|0){e=d+(c<<4)|0;do{e=e+-16|0;qp(e)}while((e|0)!=(d|0))}jp(b)}qp(a+120|0);qp(a+80|0);qp(a+64|0);qp(a+24|0);return}function ji(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1760;b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+84>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0)lp(b);b=f[a+60>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function ki(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0;d=0;while(1){if((h[13994+d>>0]|0)==(a|0)){e=2;break}g=d+1|0;if((g|0)==87){i=87;j=14082;e=5;break}else d=g}if((e|0)==2)if(!d)k=14082;else{i=d;j=14082;e=5}if((e|0)==5)while(1){e=0;d=j;do{a=d;d=d+1|0}while((b[a>>0]|0)!=0);i=i+-1|0;if(!i){k=d;break}else{j=d;e=5}}return Lo(k,f[c+20>>2]|0)|0}function li(a,b){a=+a;b=b|0;var c=0,d=0,e=0,g=0.0,h=0,i=0.0,j=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;e=Xl(c|0,d|0,52)|0;switch(e&2047){case 0:{if(a!=0.0){g=+li(a*18446744073709551616.0,b);h=(f[b>>2]|0)+-64|0;i=g}else{h=0;i=a}f[b>>2]=h;j=i;break}case 2047:{j=a;break}default:{f[b>>2]=(e&2047)+-1022;f[s>>2]=c;f[s+4>>2]=d&-2146435073|1071644672;j=+p[s>>3]}}return +j}function mi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,i=0,j=0,k=0;b=f[a+32>>2]|0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;j=Ul(i|0,f[g+4>>2]|0,4,0)|0;g=I;if((e|0)<(g|0)|(e|0)==(g|0)&d>>>0>>0){k=0;return k|0}d=(f[b>>2]|0)+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=c;f[d>>2]=j;f[d+4>>2]=g;f[(f[a+4>>2]|0)+80>>2]=i;k=1;return k|0}function ni(a){a=a|0;var b=0,c=0;f[a>>2]=2124;b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+84>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0)lp(b);b=f[a+60>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function oi(a){a=a|0;var b=0,c=0;f[a>>2]=1760;b=f[a+96>>2]|0;if(b|0)lp(b);b=f[a+84>>2]|0;if(b|0)lp(b);b=f[a+72>>2]|0;if(b|0)lp(b);b=f[a+60>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function pi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=b+4|0;e=(f[d>>2]|0)-(f[b>>2]|0)|0;g=e>>2;if(!g)return;if(g>>>0>1073741823)Eo(a);h=Yk(e)|0;f[c>>2]=h;f[a>>2]=h;f[a+8>>2]=h+(g<<2);g=f[b>>2]|0;b=(f[d>>2]|0)-g|0;if((b|0)<=0)return;Ff(h|0,g|0,b|0)|0;f[c>>2]=h+(b>>>2<<2);return}function qi(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;a=f[b+4>>2]|0;if(!a){d=0;return d|0}e=f[(f[(f[b+8>>2]|0)+(c<<2)>>2]|0)+60>>2]|0;c=f[a+40>>2]|0;b=f[a+44>>2]|0;if((c|0)==(b|0)){d=0;return d|0}else g=c;while(1){c=f[g>>2]|0;g=g+4|0;if((f[c+40>>2]|0)==(e|0)){d=c;h=5;break}if((g|0)==(b|0)){d=0;h=5;break}}if((h|0)==5)return d|0;return 0}function ri(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;if((c|0)<=0){d=1;return d|0}e=a+36|0;g=a+48|0;a=0;while(1){h=f[(f[e>>2]|0)+(a<<2)>>2]|0;a=a+1|0;if(!(Oa[f[(f[h>>2]|0)+20>>2]&31](h,g,b)|0)){d=0;i=5;break}if((a|0)>=(c|0)){d=1;i=5;break}}if((i|0)==5)return d|0;return 0}function si(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;switch(c<<24>>24){case 0:{c=Yk(20)|0;gm(c);d=c;break}case 1:{c=Yk(24)|0;Im(c);d=c;break}case 2:{c=Yk(36)|0;rl(c);d=c;break}case 3:{c=Yk(28)|0;zm(c);d=c;break}default:d=0}f[a>>2]=d;return}function ti(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=Ma[f[(f[a>>2]|0)+24>>2]&127](a)|0;if((c|0)<=0){d=1;return d|0}e=a+36|0;g=a+48|0;a=0;while(1){h=f[(f[e>>2]|0)+(a<<2)>>2]|0;a=a+1|0;if(!(Oa[f[(f[h>>2]|0)+16>>2]&31](h,g,b)|0)){d=0;i=5;break}if((a|0)>=(c|0)){d=1;i=5;break}}if((i|0)==5)return d|0;return 0}function ui(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;f[a>>2]=0;d=a+4|0;f[d>>2]=0;f[a+8>>2]=0;if(!b)return;if(b>>>0>357913941)Eo(a);e=Yk(b*12|0)|0;f[d>>2]=e;f[a>>2]=e;f[a+8>>2]=e+(b*12|0);a=e;e=b;do{pi(a,c);a=(f[d>>2]|0)+12|0;f[d>>2]=a;e=e+-1|0}while((e|0)!=0);return}function vi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=f[b>>2]|0;if(!c){d=0;return d|0}e=a+44|0;g=f[e>>2]|0;if(g>>>0<(f[a+48>>2]|0)>>>0){f[b>>2]=0;f[g>>2]=c;f[e>>2]=(f[e>>2]|0)+4;d=1;return d|0}else{uf(a+40|0,b);d=1;return d|0}return 0}function wi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3124;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}f[a+12>>2]=3148;b=f[a+32>>2]|0;if(b|0)lp(b);b=f[a+20>>2]|0;if(!b){lp(a);return}lp(b);lp(a);return}function xi(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+24>>2]|0)){b=0;return b|0}if(!(f[a+28>>2]|0)){b=0;return b|0}if(!(f[a+32>>2]|0)){b=0;return b|0}if(!(f[a+36>>2]|0)){b=0;return b|0}b=(f[a+72>>2]|0)!=-1;return b|0}function yi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0;f[c>>2]=2;d=a+4|0;a=c+8|0;e=f[a>>2]|0;g=(f[c+12>>2]|0)-e|0;if(g>>>0<4294967292){Qi(a,g+4|0,0);i=f[a>>2]|0}else i=e;e=i+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[e>>0]=g;b[e+1>>0]=g>>8;b[e+2>>0]=g>>16;b[e+3>>0]=g>>24;return}function zi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3216;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}f[a+12>>2]=3196;b=f[a+32>>2]|0;if(b|0)lp(b);b=f[a+20>>2]|0;if(!b){lp(a);return}lp(b);lp(a);return}function Ai(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2180;b=f[a+76>>2]|0;if(b|0)lp(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)jp(c);f[a>>2]=1536;c=f[a+32>>2]|0;if(!c){lp(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c);lp(a);return}function Bi(a){a=a|0;var b=0;if(!(f[a+64>>2]|0)){b=0;return b|0}if(!(f[a+68>>2]|0)){b=0;return b|0}if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}if(!(f[a+56>>2]|0)){b=0;return b|0}b=(f[a+92>>2]|0)!=-1;return b|0}function Ci(a){a=a|0;var c=0;if(!a)return;c=a+28|0;if((b[c+11>>0]|0)<0)lp(f[c>>2]|0);Kh(a+12|0,f[a+16>>2]|0);Qh(a,f[a+4>>2]|0);lp(a);return}function Di(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3124;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}f[a+12>>2]=3148;b=f[a+32>>2]|0;if(b|0)lp(b);b=f[a+20>>2]|0;if(!b)return;lp(b);return}function Ei(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1816;b=f[a+76>>2]|0;if(b|0)lp(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)jp(c);f[a>>2]=1536;c=f[a+32>>2]|0;if(!c){lp(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);lp(c);lp(a);return}function Fi(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;if(!a)return;c=f[a>>2]|0;if(c|0){d=a+4|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;if((b[e+11>>0]|0)<0){lp(f[e>>2]|0);i=f[d>>2]|0}else i=e;if((i|0)==(c|0))break;else h=i}g=f[a>>2]|0}lp(g)}lp(a);return}function Gi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;cc(a,b);if((b|0)<=-1)return;c=a+88|0;d=f[c>>2]|0;e=f[a+84>>2]|0;if((d-e>>2|0)<=(b|0))return;a=e+(b<<2)|0;b=a+4|0;e=d-b|0;g=e>>2;if(!g)h=d;else{ok(a|0,b|0,e|0)|0;h=f[c>>2]|0}e=a+(g<<2)|0;if((h|0)==(e|0))return;f[c>>2]=h+(~((h+-4-e|0)>>>2)<<2);return}function Hi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3216;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}f[a+12>>2]=3196;b=f[a+32>>2]|0;if(b|0)lp(b);b=f[a+20>>2]|0;if(!b)return;lp(b);return}function Ii(a){a=a|0;var b=0,c=0;f[a>>2]=2180;b=f[a+76>>2]|0;if(b|0)lp(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)jp(c);f[a>>2]=1536;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);lp(c);return}function Ji(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3580;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);lp(b)}b=f[a+84>>2]|0;if(!b){nf(a);lp(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b);nf(a);lp(a);return}function Ki(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(((h[(f[a+4>>2]|0)+36>>0]|0)<<8&65535)<512?!(Ma[f[(f[a>>2]|0)+52>>2]&127](a)|0):0){d=0;return d|0}d=qc(a,b,c)|0;return d|0}function Li(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;g=d>>31|((d|0)<0?-1:0)<<1;h=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;i=Wl(e^a|0,f^b|0,e|0,f|0)|0;b=I;a=g^e;e=h^f;return Wl((zc(i,b,Wl(g^c|0,h^d|0,g|0,h|0)|0,I,0)|0)^a|0,I^e|0,a|0,e|0)|0}function Mi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0;a=c+16|0;g=f[a>>2]|0;h=c+36|0;i=c+24|0;do if(g){if((g|0)!=(d|0)){f[h>>2]=(f[h>>2]|0)+1;f[i>>2]=2;b[c+54>>0]=1;break}if((f[i>>2]|0)==2)f[i>>2]=e}else{f[a>>2]=d;f[i>>2]=e;f[h>>2]=1}while(0);return}function Ni(a){a=a|0;var b=0,c=0;f[a>>2]=1816;b=f[a+76>>2]|0;if(b|0)lp(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)jp(c);f[a>>2]=1536;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);lp(c);return}function Oi(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;f[a>>2]=b;h=b+16|0;i=f[h+4>>2]|0;j=a+8|0;f[j>>2]=f[h>>2];f[j+4>>2]=i;i=b+24|0;b=f[i+4>>2]|0;j=a+16|0;f[j>>2]=f[i>>2];f[j+4>>2]=b;b=a+40|0;f[b>>2]=c;f[b+4>>2]=d;d=a+48|0;f[d>>2]=e;f[d+4>>2]=g;return}function Pi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,i=0,j=0;b=h[a+12>>0]|0;c=a+8|0;d=f[c>>2]|0;if(d>>>0<4096?(e=a+4|0,g=f[e>>2]|0,(g|0)>0):0){i=f[a>>2]|0;a=g+-1|0;f[e>>2]=a;e=h[i+a>>0]|0|d<<8;f[c>>2]=e;j=e}else j=d;d=j&255;e=0-b&255;b=X(j>>>8,e)|0;a=d>>>0>>0;f[c>>2]=a?b+d|0:j-e-b|0;return a|0}function Qi(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;h=e;e=d;if(b>>>0<=g>>>0){if(b>>>0>>0?(d=h+b|0,(e|0)!=(d|0)):0)f[c>>2]=d}else Rg(a,b-g|0);g=a+24|0;a=g;b=Ul(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=g;f[a>>2]=b;f[a+4>>2]=I;return}function Ri(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;qe(g,a,c,d);d=a+24|0;f[d>>2]=f[g>>2];c=g+4|0;ek(a+28|0,c)|0;if((b[c+11>>0]|0)>=0){u=e;return d|0}lp(f[c>>2]|0);u=e;return d|0}function Si(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3580;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);lp(b)}b=f[a+84>>2]|0;if(!b){nf(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b);nf(a);return}function Ti(a){a=a|0;var c=0,d=0,e=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=1;c=a+68|0;d=a+28|0;e=d+40|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(e|0));f[c>>2]=a;c=a+72|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;return}function Ui(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;re(g,a,c,d);d=a+24|0;f[d>>2]=f[g>>2];c=g+4|0;ek(a+28|0,c)|0;if((b[c+11>>0]|0)>=0){u=e;return d|0}lp(f[c>>2]|0);u=e;return d|0}function Vi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2236;b=f[a+76>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function Wi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0;b=f[a+8>>2]|0;c=f[a+12>>2]|0;if((b|0)==(c|0)){d=1;return d|0}e=a+32|0;a=b;while(1){b=f[a>>2]|0;a=a+4|0;if(!(Na[f[(f[b>>2]|0)+16>>2]&127](b,f[e>>2]|0)|0)){d=0;g=5;break}if((a|0)==(c|0)){d=1;g=5;break}}if((g|0)==5)return d|0;return 0}function Xi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=f[a+8>>2]|0;if((b[e+24>>0]|0)<1){g=0;return g|0}if(!(Lh(e,(f[c+4>>2]|0)-(f[c>>2]|0)>>2)|0)){g=0;return g|0}g=Oa[f[(f[a>>2]|0)+32>>2]&31](a,c,d)|0;return g|0}function Yi(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=u;u=u+256|0;g=f;if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;Dh(g|0,b|0,(e>>>0<256?e:256)|0)|0;if(e>>>0>255){b=c-d|0;d=e;do{qn(a,g,256);d=d+-256|0}while(d>>>0>255);h=b&255}else h=e;qn(a,g,h)}u=f;return}function Zi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1872;b=f[a+76>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function _i(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;if(Hn(a,f[b+8>>2]|0,g)|0)wh(0,b,c,d,e);else{h=f[a+8>>2]|0;Wa[f[(f[h>>2]|0)+20>>2]&3](h,b,c,d,e,g)}return}function $i(a,b){a=a|0;b=b|0;var c=0;c=Yk(40)|0;f[c>>2]=-1;ql(c+8|0);Sa[f[(f[a>>2]|0)+16>>2]&7](a,c);a=b+88|0;b=f[a>>2]|0;f[a>>2]=c;if(!b)return 1;c=f[b+8>>2]|0;if(c|0){a=b+12|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;lp(c)}lp(b);return 1}function aj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+12>>2]|0;d=f[a+8>>2]|0;a=d;if((c|0)==(d|0)){e=0;return e|0}g=c-d>>2;d=0;while(1){c=f[a+(d<<2)>>2]|0;if((f[c+60>>2]|0)==(b|0)){e=c;h=5;break}d=d+1|0;if(d>>>0>=g>>>0){e=0;h=5;break}}if((h|0)==5)return e|0;return 0}function bj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1256;b=f[a+16>>2]|0;if(b|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+4>>2]|0;if(!b){lp(a);return}d=a+8|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function cj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+12>>2]|0;d=f[a+8>>2]|0;a=d;if((c|0)==(d|0)){e=-1;return e|0}g=c-d>>2;d=0;while(1){if((f[(f[a+(d<<2)>>2]|0)+60>>2]|0)==(b|0)){e=d;h=5;break}d=d+1|0;if(d>>>0>=g>>>0){e=-1;h=5;break}}if((h|0)==5)return e|0;return 0}function dj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;a:do if(!d)e=0;else{f=a;g=d;h=c;while(1){i=b[f>>0]|0;j=b[h>>0]|0;if(i<<24>>24!=j<<24>>24)break;g=g+-1|0;if(!g){e=0;break a}else{f=f+1|0;h=h+1|0}}e=(i&255)-(j&255)|0}while(0);return e|0}function ej(a){a=a|0;var b=0,c=0;f[a>>2]=2236;b=f[a+76>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function fj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2292;qp(a+108|0);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function gj(a){a=a|0;var b=0,c=0;f[a>>2]=2884;b=a+28|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)jp(c);f[a>>2]=1476;c=a+20|0;b=f[c>>2]|0;f[c>>2]=0;if(!b){Ih(a);lp(a);return}Ra[f[(f[b>>2]|0)+4>>2]&127](b);Ih(a);lp(a);return}function hj(a){a=a|0;var c=0,d=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;c=0;while(1){if((c|0)==3)break;f[a+(c<<2)>>2]=0;c=c+1|0}if((b[a+11>>0]|0)<0)d=(f[a+8>>2]&2147483647)+-1|0;else d=10;Th(a,d,0);return}function ij(a){a=a|0;var b=0,c=0;f[a>>2]=1872;b=f[a+76>>2]|0;if(b|0)lp(b);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function jj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1928;qp(a+108|0);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function kj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1256;b=f[a+16>>2]|0;if(b|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}b=f[a+4>>2]|0;if(!b)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(b|0))f[d>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function lj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;e=b;g=d+(~((d+-4-e|0)>>>2)<<2)|0;if((d|0)==(b|0))h=b;else{f[c>>2]=g;h=g}f[a+16>>2]=0;f[a+12>>2]=h;if(!b)return;if((h|0)!=(b|0))f[c>>2]=h+(~((h+-4-e|0)>>>2)<<2);lp(b);return}function mj(a){a=a|0;var b=0,c=0;f[a>>2]=2884;b=a+28|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)jp(c);f[a>>2]=1476;c=a+20|0;b=f[c>>2]|0;f[c>>2]=0;if(!b){Ih(a);return}Ra[f[(f[b>>2]|0)+4>>2]&127](b);Ih(a);return}function nj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(Hn(a,f[b+8>>2]|0,0)|0)Mi(0,b,c,d);else{e=f[a+8>>2]|0;Ua[f[(f[e>>2]|0)+28>>2]&7](e,b,c,d)}return}function oj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=X(c,b)|0;g=(b|0)==0?0:c;if((f[d+76>>2]|0)>-1){c=(rp(d)|0)==0;h=Ag(a,e,d)|0;if(c)i=h;else{qp(d);i=h}}else i=Ag(a,e,d)|0;if((i|0)==(e|0))j=g;else j=(i>>>0)/(b>>>0)|0;return j|0}function pj(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Na[f[(f[d>>2]|0)+32>>2]&127](d,b)|0;return c|0}function qj(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0;d=b[a>>0]|0;e=b[c>>0]|0;if(d<<24>>24==0?1:d<<24>>24!=e<<24>>24){f=e;g=d}else{d=a;a=c;do{d=d+1|0;a=a+1|0;c=b[d>>0]|0;e=b[a>>0]|0}while(!(c<<24>>24==0?1:c<<24>>24!=e<<24>>24));f=e;g=c}return (g&255)-(f&255)|0}function rj(a){a=a|0;var b=0,c=0;f[a>>2]=2292;qp(a+108|0);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function sj(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;hj(d);Xg(a,d,b);Nm(d);u=c;return}function tj(a){a=a|0;var b=0,c=0;f[a>>2]=1928;qp(a+108|0);f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function uj(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[a+4>>2]|0;if(c|0?((h[c+36>>0]|0)<<8&65535)<512:0){d=1;return d|0}d=Na[f[(f[a>>2]|0)+48>>2]&127](a,(f[b+4>>2]|0)-(f[b>>2]|0)>>2)|0;return d|0}function vj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;d=u;u=u+32|0;e=d;g=d+20|0;f[e>>2]=f[a+60>>2];f[e+4>>2]=0;f[e+8>>2]=b;f[e+12>>2]=g;f[e+16>>2]=c;if((lm(za(140,e|0)|0)|0)<0){f[g>>2]=-1;h=-1}else h=f[g>>2]|0;u=d;return h|0}function wj(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=0;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=0;return c|0}b=f[d>>2]|0;if((b|0)==-1){c=0;return c|0}c=f[(f[a+8>>2]|0)+(b<<2)>>2]|0;return c|0}function xj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}d=kg(f[(f[a+36>>2]|0)+(e<<2)>>2]|0)|0;return d|0}function yj(a,b){a=a|0;b=b|0;var c=0;Fk(a);f[a>>2]=1416;c=a+36|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;c=f[b>>2]|0;f[b>>2]=0;f[a+60>>2]=c;return}function zj(a,c){a=a|0;c=c|0;var d=0,e=0;d=a;e=c;c=d+64|0;do{f[d>>2]=f[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(c|0));e=a+64|0;f[a+88>>2]=0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[e+12>>2]=0;f[e+16>>2]=0;b[e+20>>0]=0;return}function Aj(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;if((a|0)==0&(c|0)==0)f=d;else{g=a;a=c;c=d;while(1){d=c+-1|0;b[d>>0]=h[13976+(g&15)>>0]|0|e;g=Xl(g|0,a|0,4)|0;a=I;if((g|0)==0&(a|0)==0){f=d;break}else c=d}}return f|0}function Bj(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=f[a>>2]|0;if(!(d&8)){f[a+8>>2]=0;f[a+4>>2]=0;c=f[a+44>>2]|0;f[a+28>>2]=c;f[a+20>>2]=c;f[a+16>>2]=c+(f[a+48>>2]|0);e=0}else{f[a>>2]=d|32;e=-1}return e|0}function Cj(a){a=a|0;if(!(f[a+60>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function Dj(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[b+88>>2]|0;if(!c){d=0;return d|0}if((f[c>>2]|0)!=2){d=0;return d|0}b=f[c+8>>2]|0;f[a+4>>2]=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;d=1;return d|0}function Ej(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}b=(f[a+56>>2]|0)!=0;return b|0}function Fj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=b[a+11>>0]|0;e=d<<24>>24<0;if(e)g=f[a+4>>2]|0;else g=d&255;if(g>>>0<=c>>>0)Eo(a);if(e)h=f[a>>2]|0;else h=a;return h+c|0}function Gj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+32|0;g=e;f[a+36>>2]=15;if((f[a>>2]&64|0)==0?(f[g>>2]=f[a+60>>2],f[g+4>>2]=21523,f[g+8>>2]=e+16,Ba(54,g|0)|0):0)b[a+75>>0]=-1;g=pf(a,c,d)|0;u=e;return g|0}function Hj(a,b,c){a=a|0;b=b|0;c=c|0;if((b|0)!=0&(c|0)!=0){fc(a,b,c);return}else{mc(a,0,0);return}}function Ij(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=$(e);f[a+4>>2]=b;Je(a+8|0,c,c+(d<<2)|0);n[a+20>>2]=e;return}function Jj(a,b){a=a|0;b=b|0;var c=0;if(!(Na[f[(f[a>>2]|0)+36>>2]&127](a,b)|0)){c=0;return c|0}if(!(Na[f[(f[a>>2]|0)+40>>2]&127](a,b)|0)){c=0;return c|0}c=Ma[f[(f[a>>2]|0)+44>>2]&127](a)|0;return c|0}function Kj(a){a=a|0;var b=0,c=0;a=a+15&-16|0;b=f[r>>2]|0;c=b+a|0;if((a|0)>0&(c|0)<(b|0)|(c|0)<0){ea()|0;ya(12);return -1}f[r>>2]=c;if((c|0)>(da()|0)?(ca()|0)==0:0){f[r>>2]=b;ya(12);return -1}return b|0}function Lj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;d=f[c>>2]|0;c=a;e=b-a>>2;while(1){if(!e)break;a=(e|0)/2|0;b=c+(a<<2)|0;g=(f[b>>2]|0)>>>0>>0;c=g?b+4|0:c;e=g?e+-1-a|0:a}return c|0}function Mj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if(!(zl(a,c,d)|0)){e=0;return e|0}d=f[a+8>>2]|0;if((b[d+24>>0]|0)!=3){e=0;return e|0}e=(f[d+28>>2]|0)==9;return e|0}function Nj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a>>2]|0;d=(b[c>>0]|0)+-48|0;if(d>>>0<10){e=c;c=0;g=d;while(1){d=g+(c*10|0)|0;e=e+1|0;f[a>>2]=e;g=(b[e>>0]|0)+-48|0;if(g>>>0>=10){h=d;break}else c=d}}else h=0;return h|0}function Oj(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;b[a+24>>0]=1;f[a+28>>2]=9;c=a+40|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[a+56>>2]=-1;f[a+60>>2]=0;return}function Pj(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+44>>2]=c;d=1;return d|0}function Qj(a,c){a=a|0;c=c|0;var d=0,e=0;a=u;u=u+32|0;d=a;gh(d,c);c=f[d+16>>2]|0;e=d+4|0;if((b[e+11>>0]|0)>=0){u=a;return c|0}lp(f[e>>2]|0);u=a;return c|0}function Rj(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+64>>2]=c;d=1;return d|0}function Sj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(!(zl(a,b,c)|0)){d=0;return d|0}d=(f[(f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0)+28>>2]|0)==9;return d|0}function Tj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;if((a|0)==0&(c|0)==0)e=d;else{f=a;a=c;c=d;while(1){d=c+-1|0;b[d>>0]=f&7|48;f=Xl(f|0,a|0,3)|0;a=I;if((f|0)==0&(a|0)==0){e=d;break}else c=d}}return e|0}function Uj(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;if(Hn(a,f[b+8>>2]|0,g)|0)wh(0,b,c,d,e);return}function Vj(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+20|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Ih(a);lp(a);return}Ra[f[(f[c>>2]|0)+4>>2]&127](c);Ih(a);lp(a);return}function Wj(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+56>>2]|0)-(f[e+52>>2]|0)>>2;b[d>>0]=0;Hf(a+20|0,g,d);u=c;return}function Xj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1536;b=f[a+32>>2]|0;if(!b){lp(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function Yj(a,c){a=a|0;c=c|0;var d=0;if(((c|0)!=0?(f[c+56>>2]|0)==0:0)?(b[c+24>>0]|0)==3:0){f[a+60>>2]=c;d=1}else d=0;return d|0}function Zj(a){a=a|0;var b=0;switch(a|0){case 11:case 2:case 1:{b=1;break}case 4:case 3:{b=2;break}case 6:case 5:{b=4;break}case 8:case 7:{b=8;break}case 9:{b=4;break}case 10:{b=8;break}default:b=-1}return b|0}function _j(a){a=a|0;var c=0,d=0,e=0;b[a+36>>0]=0;c=Ul(f[a+32>>2]|0,0,7,0)|0;d=Xl(c|0,I|0,3)|0;c=a+16|0;a=c;e=Ul(d|0,I|0,f[a>>2]|0,f[a+4>>2]|0)|0;a=c;f[a>>2]=e;f[a+4>>2]=I;return}function $j(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+28>>2]|0)-(f[e+24>>2]|0)>>2;b[d>>0]=0;Hf(a+20|0,g,d);u=c;return}function ak(a){a=a|0;var b=0,c=0,d=0;b=a+60|0;c=a;d=c+60|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=a;b=a+64|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function bk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=(f[a+96>>2]|0)+(b*12|0)|0;Ne(c,d,d+12|0);return 1}function ck(){var a=0,b=0;a=Yk(40)|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[a+16>>2]=$(1.0);b=a+20|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;n[a+36>>2]=$(1.0);return a|0}function dk(a){a=a|0;f[a>>2]=3172;bh(a+8|0);lp(a);return}function ek(a,c){a=a|0;c=c|0;var d=0,e=0;if((a|0)!=(c|0)){d=b[c+11>>0]|0;e=d<<24>>24<0;th(a,e?f[c>>2]|0:c,e?f[c+4>>2]|0:d&255)|0}return a|0}function fk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=a&65535;d=b&65535;e=X(d,c)|0;f=a>>>16;a=(e>>>16)+(X(d,f)|0)|0;d=b>>>16;b=X(d,c)|0;return (I=(a>>>16)+(X(d,f)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|e&65535|0)|0}function gk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=Rh(b)|0;d=Yk(c+13|0)|0;f[d>>2]=c;f[d+4>>2]=c;f[d+8>>2]=0;e=ho(d)|0;Ff(e|0,b|0,c+1|0)|0;f[a>>2]=e;return}function hk(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+20|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Ih(a);return}Ra[f[(f[c>>2]|0)+4>>2]&127](c);Ih(a);return}function ik(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=-1;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=-1;return c|0}c=f[d>>2]|0;return c|0}function jk(a){a=a|0;f[a>>2]=3172;bh(a+8|0);return}function kk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f[b+44>>2]=e;tc(a,b,c,d,e);return}function lk(a){a=a|0;var b=0,c=0;f[a>>2]=1536;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function mk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(Hn(a,f[b+8>>2]|0,0)|0)Mi(0,b,c,d);return}function nk(a){a=a|0;var b=0;f[a>>2]=3440;b=a+4|0;f[a+40>>2]=0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;f[b+24>>2]=0;f[b+28>>2]=0;d[b+32>>1]=0;return}function ok(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if((c|0)<(a|0)&(a|0)<(c+d|0)){e=a;c=c+d|0;a=a+d|0;while((d|0)>0){a=a-1|0;c=c-1|0;d=d-1|0;b[a>>0]=b[c>>0]|0}a=e}else Ff(a,c,d)|0;return a|0}function pk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1228;b=f[a+8>>2]|0;if(!b){lp(a);return}c=a+12|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b);lp(a);return}function qk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=u;u=u+16|0;e=d;f[e>>2]=f[c>>2];g=Oa[f[(f[a>>2]|0)+16>>2]&31](a,b,e)|0;if(g)f[c>>2]=f[e>>2];u=d;return g&1|0}function rk(a,b){a=a|0;b=b|0;var c=0;if(b>>>0>=2){c=0;return c|0}f[a+28>>2]=b;c=1;return c|0}function sk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if((b|0)>0)d=0;else return;do{e=f[a+(d<<2)>>2]|0;f[c+(d<<2)>>2]=e<<31>>31^e>>>1;d=d+1|0}while((d|0)!=(b|0));return}function tk(){var a=0,b=0;a=dl()|0;if((a|0?(b=f[a>>2]|0,b|0):0)?(a=b+48|0,(f[a>>2]&-256|0)==1126902528?(f[a+4>>2]|0)==1129074247:0):0)Wm(f[b+12>>2]|0);Wm(so()|0)}function uk(a){a=a|0;var c=0;c=b[w+(a&255)>>0]|0;if((c|0)<8)return c|0;c=b[w+(a>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=b[w+(a>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (b[w+(a>>>24)>>0]|0)+24|0}function vk(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);lp(b)}lp(a);return}function wk(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-2-b|0)>>>1)<<1);lp(b)}lp(a);return}function xk(a,c){a=a|0;c=c|0;var d=0;b[c+84>>0]=1;a=f[c+68>>2]|0;d=c+72|0;c=f[d>>2]|0;if((c|0)==(a|0))return 1;f[d>>2]=c+(~((c+-4-a|0)>>>2)<<2);return 1}function yk(a){a=a|0;var b=0,c=0;if(Ro(a)|0?(b=no(f[a>>2]|0)|0,a=b+8|0,c=f[a>>2]|0,f[a>>2]=c+-1,(c+-1|0)<0):0)lp(b);return}function zk(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;d[a+38>>1]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;f[c+24>>2]=0;b[c+28>>0]=0;return}function Ak(a){a=a|0;var b=0,c=0;f[a>>2]=1228;b=f[a+8>>2]|0;if(!b)return;c=a+12|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);lp(b);return}function Bk(a,b,c){a=a|0;b=b|0;c=c|0;Nb(a,b,c);return}function Ck(a){a=a|0;zk(a);zk(a+40|0);Ym(a+80|0);zk(a+96|0);f[a+136>>2]=0;f[a+140>>2]=0;f[a+144>>2]=0;return}function Dk(a,b,c){a=a|0;b=b|0;c=c|0;return _c(a,b,5,6,c)|0}function Ek(a,b,c){a=a|0;b=b|0;c=c|0;return Yc(a,b,3,4,c)|0}function Fk(a){a=a|0;var b=0;f[a>>2]=1256;b=a+4|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;f[b+24>>2]=0;f[b+28>>2]=0;return}function Gk(a,b,c){a=a|0;b=b|0;c=c|0;return bd(a,b,1,2,c)|0}function Hk(a,b,c){a=a|0;b=b|0;c=c|0;return Zc(a,b,3,4,c)|0}function Ik(a,b,c){a=a|0;b=b|0;c=c|0;return $c(a,b,5,6,c)|0}function Jk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=a+20|0;e=f[d>>2]|0;g=(f[a+16>>2]|0)-e|0;a=g>>>0>c>>>0?c:g;Ff(e|0,b|0,a|0)|0;f[d>>2]=(f[d>>2]|0)+a;return c|0}function Kk(a,b,c){a=a|0;b=b|0;c=c|0;return cd(a,b,1,2,c)|0}function Lk(a){a=a|0;var b=0;f[a>>2]=3148;b=f[a+20>>2]|0;if(b|0)lp(b);b=f[a+8>>2]|0;if(!b){lp(a);return}lp(b);lp(a);return}function Mk(){var a=0,b=0;a=Yk(24)|0;f[a>>2]=1228;f[a+4>>2]=-1;b=a+8|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return a|0}function Nk(a){a=a|0;var c=0;Oj(a);c=a+64|0;f[a+88>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;b[c+20>>0]=0;return}function Ok(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a+8>>2]|0;if(b|0){c=a+12|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;lp(b)}lp(a);return}function Pk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((f[b+4>>2]|0)==(c|0)?(c=b+28|0,(f[c>>2]|0)!=1):0)f[c>>2]=d;return}function Qk(a){a=a|0;var b=0;f[a>>2]=3196;b=f[a+20>>2]|0;if(b|0)lp(b);b=f[a+8>>2]|0;if(!b){lp(a);return}lp(b);lp(a);return}function Rk(a,b,c,e){a=a|0;b=b|0;c=c|0;e=e|0;f[a>>2]=b;b=a+8|0;f[b>>2]=c;f[b+4>>2]=0;d[a+38>>1]=e;e=a+16|0;f[e>>2]=0;f[e+4>>2]=0;return}function Sk(a,b,c){a=a|0;b=$(b);c=c|0;var d=0,e=Ka;if((c|0)<1){d=0;return d|0}e=$($(1.0)/$(c|0));n[a+4>>2]=e;n[a>>2]=b;d=1;return d|0}function Tk(a,b,c){a=a|0;b=b|0;c=c|0;f[a+4>>2]=b;f[a+8>>2]=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2];f[a+12>>2]=c;return 1}function Uk(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;lp(b)}lp(a);return}function Vk(a){a=a|0;var b=0;On(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;b=a+24|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function Wk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e|0;zc(a,b,c,d,g)|0;u=e;return (I=f[g+4>>2]|0,f[g>>2]|0)|0}function Xk(a){a=a|0;var b=0;$l(a);f[a>>2]=3580;b=a+84|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function Yk(a){a=a|0;var b=0,c=0;b=(a|0)==0?1:a;while(1){a=Xa(b)|0;if(a|0){c=a;break}a=po()|0;if(!a){c=0;break}Qa[a&3]()}return c|0}function Zk(a){a=a|0;f[a>>2]=2548;qp(a+88|0);lp(a);return}function _k(a){a=a|0;var b=0;f[a>>2]=3148;b=f[a+20>>2]|0;if(b|0)lp(b);b=f[a+8>>2]|0;if(!b)return;lp(b);return}function $k(a){a=a|0;f[a>>2]=2632;qp(a+88|0);lp(a);return}function al(a){a=a|0;f[a>>2]=2716;qp(a+88|0);lp(a);return}function bl(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;d=op(f[a+60>>2]|0)|0;f[c>>2]=d;d=lm(Ca(6,c|0)|0)|0;u=b;return d|0}function cl(a){a=a|0;f[a>>2]=2548;qp(a+88|0);return}function dl(){var a=0,b=0;a=u;u=u+16|0;if(!(Ha(17024,3)|0)){b=Fa(f[4257]|0)|0;u=a;return b|0}else Bl(16164,a);return 0}function el(a){a=a|0;var b=0;f[a>>2]=3196;b=f[a+20>>2]|0;if(b|0)lp(b);b=f[a+8>>2]|0;if(!b)return;lp(b);return}function fl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;a=c;c=fk(e,a)|0;f=I;return (I=(X(b,a)|0)+(X(d,e)|0)+f|f&0,c|0|0)|0}function gl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Dk(b,c,d)|0}function hl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ek(b,c,d)|0}function il(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return $d(b,c,d)|0}function jl(a){a=a|0;f[a>>2]=2800;qp(a+88|0);lp(a);return}function kl(a){a=a|0;var b=0;b=u;u=u+16|0;Xb(a);if(!(Ia(f[4257]|0,0)|0)){u=b;return}else Bl(16263,b)}function ll(a){a=a|0;f[a>>2]=2632;qp(a+88|0);return}function ml(a){a=a|0;f[a>>2]=2716;qp(a+88|0);return}function nl(a){a=a|0;var b=0;Fk(a);f[a>>2]=1312;b=a+36|0;a=b+36|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function ol(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Gk(b,c,d)|0}function pl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Hk(b,c,d)|0}function ql(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function rl(a){a=a|0;Im(a);f[a>>2]=2884;f[a+24>>2]=-1;f[a+28>>2]=0;n[a+32>>2]=$(0.0);return}function sl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Kk(b,c,d)|0}function tl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ik(b,c,d)|0}function ul(a,b,c){a=a|0;b=b|0;c=c|0;f[a>>2]=b;b=a+8|0;f[b>>2]=c;f[b+4>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;return}function vl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return (((f[a+12>>2]|0)+-1|0)==(d|0)?0:d+1|0)|0}function wl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;f[g>>2]=d;d=fh(a,b,c,g)|0;u=e;return d|0}function xl(a){a=a|0;f[a>>2]=2800;qp(a+88|0);return}function yl(a,b,c){a=a|0;b=b|0;c=c|0;return 1}function zl(a,b,c){a=a|0;b=b|0;c=c|0;return Tk(a,b,c)|0}function Al(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Pa[a&31](b|0,c|0,d|0,e|0,f|0,g|0)|0}function Bl(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;f[d>>2]=b;b=f[906]|0;_f(b,a,d)|0;ai(10,b)|0;Da()}function Cl(a,b){a=a|0;b=b|0;var c=0;c=f[a+48>>2]|0;return Na[f[(f[c>>2]|0)+16>>2]&127](c,b)|0}function Dl(a,b,c){a=a|0;b=b|0;c=c|0;return ik(b,c)|0}function El(a,b){a=a|0;b=b|0;var c=0;c=f[a+48>>2]|0;return Na[f[(f[c>>2]|0)+12>>2]&127](c,b)|0}function Fl(a){a=a|0;Id(a);lp(a);return}function Gl(a,b){a=a|0;b=b|0;var c=0;c=f[a+48>>2]|0;return Na[f[(f[c>>2]|0)+20>>2]&127](c,b)|0}function Hl(a){a=a|0;var c=0,d=0;c=a+4|0;if((b[c+11>>0]|0)<0){d=f[c>>2]|0;return d|0}else{d=c;return d|0}return 0}function Il(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return bf(b,c,d)|0}function Jl(){var a=0;a=u;u=u+16|0;if(!(Ga(17028,104)|0)){u=a;return}else Bl(16213,a)}function Kl(a){a=a|0;Jd(a);lp(a);return}function Ll(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;Wa[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Ml(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;f[d>>2]=b;b=_f(f[999]|0,a,d)|0;u=c;return b|0}function Nl(a){a=a|0;if(!(f[a+44>>2]|0))return 0;else return Ma[f[(f[a>>2]|0)+48>>2]&127](a)|0;return 0}function Ol(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Mh(b,c,d)|0}function Pl(a,b,c){a=a|0;b=b|0;c=c|0;if(b|0)Dh(a|0,(Mo(c)|0)&255|0,b|0)|0;return a|0}function Ql(a){a=a|0;return 4}function Rl(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b<>>32-c;return a<>0]|0)<0)lp(f[c>>2]|0);lp(a);return}function Tl(){}function Ul(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=a+c>>>0;return (I=b+d+(e>>>0>>0|0)>>>0,e|0)|0}function Vl(a,b){a=a|0;b=b|0;var c=0;if(!b)c=0;else c=bg(f[b>>2]|0,f[b+4>>2]|0,a)|0;return (c|0?c:a)|0}function Wl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=b-d>>>0;e=b-d-(c>>>0>a>>>0|0)>>>0;return (I=e,a-c>>>0|0)|0}function Xl(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b>>>c;return a>>>c|(b&(1<>>c-32|0}function Yl(a,b,c){a=a|0;b=b|0;c=c|0;return Ri(a,b,c)|0}function Zl(a){a=a|0;qd(a);lp(a);return}function _l(a){a=a|0;return 5}function $l(a){a=a|0;var b=0;f[a>>2]=3608;b=a+4|0;a=b+80|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function am(a){a=a|0;return 6}function bm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return bk(b,c,d)|0}function cm(a,b,c){a=a|0;b=b|0;c=c|0;f[a+28>>2]=b;f[a+32>>2]=c;return 1}function dm(a,b,c){a=a|0;b=b|0;c=c|0;return Dl(a,b,c)|0}function em(a){a=a|0;var b=0;b=f[a+48>>2]|0;return Ma[f[(f[b>>2]|0)+28>>2]&127](b)|0}function fm(a,b,c){a=a|0;b=b|0;c=c|0;return We(b,c)|0}function gm(a){a=a|0;f[a>>2]=1368;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=-1;f[a+16>>2]=0;return}function hm(a){a=a|0;var b=0;b=f[a+48>>2]|0;return Ma[f[(f[b>>2]|0)+24>>2]&127](b)|0}function im(a,b){a=a|0;b=b|0;Yh(a,b);return}function jm(a){a=a|0;var b=0;b=f[a+48>>2]|0;return Ma[f[(f[b>>2]|0)+36>>2]&127](b)|0}function km(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Va[a&3](b|0,c|0,d|0,e|0,f|0)}function lm(a){a=a|0;var b=0,c=0;if(a>>>0>4294963200){b=_o()|0;f[b>>2]=0-a;c=-1}else c=a;return c|0}function mm(a,b,c){a=a|0;b=b|0;c=c|0;return Ui(a,b,c)|0}function nm(a,b,c){a=a|0;b=b|0;c=c|0;return Wg(a,b,c)|0}function om(a,b,c){a=a|0;b=b|0;c=c|0;return kh(a,b,c)|0}function pm(a,b,c){a=a|0;b=b|0;c=c|0;return zg(a,b,c)|0}function qm(a,b,c){a=a|0;b=b|0;c=c|0;return +(+eh(a,b,c))}function rm(a,b){a=a|0;b=b|0;return Na[f[(f[a>>2]|0)+12>>2]&127](a,b)|0}function sm(a,b){a=a|0;b=b|0;return Na[f[(f[a>>2]|0)+56>>2]&127](a,b)|0}function tm(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;return}function um(a,b,c){a=a|0;b=b|0;c=c|0;return qi(a,b,c)|0}function vm(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return 1}function wm(a,b,c){a=a|0;b=b|0;c=c|0;return Pm(b,c)|0}function xm(a,b,c){a=a|0;b=b|0;c=c|0;return lh(a,b,c)|0}function ym(a,b,c){a=a|0;b=b|0;c=c|0;return hh(a,b,c)|0}function zm(a){a=a|0;Im(a);f[a>>2]=2376;f[a+24>>2]=-1;return}function Am(a,b){a=a|0;b=b|0;f[a+8>>2]=b;f[a+12>>2]=-1;return 1}function Bm(a,b,c){a=a|0;b=b|0;c=c|0;return Nf(a,b,c)|0}function Cm(a,b,c){a=a|0;b=b|0;c=c|0;return ig(b,c)|0}function Dm(a){a=+a;var b=0;p[s>>3]=a;b=f[s>>2]|0;I=f[s+4>>2]|0;return b|0}function Em(a){a=a|0;f[a+12>>2]=0;f[a+16>>2]=0;f[a>>2]=0;n[a+4>>2]=$(0.0);return}function Fm(){var a=0;a=Yk(40)|0;f[a>>2]=-1;ql(a+8|0);return a|0}function Gm(){var a=0;a=Yk(8)|0;f[a>>2]=1200;f[a+4>>2]=-1;return a|0}function Hm(a,b,c){a=a|0;b=b|0;c=c|0;return Qg(a,b,c)|0}function Im(a){a=a|0;gm(a);f[a>>2]=1476;f[a+20>>2]=0;return}function Jm(a,b){a=a|0;b=b|0;im(a,b);return}function Km(a){a=a|0;var b=0;if(!a)b=0;else b=(cg(a,1072,1160,0)|0)!=0;return b&1|0}function Lm(a,b){a=a|0;b=b|0;return $(n[(f[a+8>>2]|0)+(b<<2)>>2])}function Mm(a,b){a=a|0;b=b|0;return Qj(a,b)|0}function Nm(a){a=a|0;if((b[a+11>>0]|0)<0)lp(f[a>>2]|0);return}function Om(a){a=a|0;if(!a)return;Ra[f[(f[a>>2]|0)+4>>2]&127](a);return}function Pm(a,b){a=a|0;b=b|0;return aj(a,b)|0}function Qm(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Ua[a&7](b|0,c|0,d|0,e|0)}function Rm(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)ok(a|0,b|0,c|0)|0;return a|0}function Sm(a,b,c){a=a|0;b=b|0;c=c|0;return dn(b,c)|0}function Tm(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)Ff(a|0,b|0,c|0)|0;return a|0}function Um(a,b){a=a|0;b=b|0;return -1}function Vm(a){a=a|0;return 3}function Wm(a){a=a|0;var b=0;b=u;u=u+16|0;Qa[a&3]();Bl(16316,b)}function Xm(a,b){a=a|0;b=b|0;return Vn(a,b)|0}function Ym(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b[a+12>>0]=0;return}function Zm(a){a=a|0;rg(a);lp(a);return}function _m(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;return}function $m(a){a=a|0;ln(a);f[a>>2]=3012;f[a+48>>2]=0;return}function an(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Oa[a&31](b|0,c|0,d|0)|0}function bn(a,b,c){a=a|0;b=b|0;c=c|0;ul(a,b,c);return}function cn(a,b){a=a|0;b=b|0;f[a>>2]=4728;gk(a+4|0,b);return}function dn(a,b){a=a|0;b=b|0;return f[(f[a+8>>2]|0)+(b<<2)>>2]|0}function en(a,b){a=a|0;b=b|0;var c=0;if(!a)c=0;else c=ch(a,b,0)|0;return c|0}function fn(a){a=a|0;if(!a)return;qp(a+24|0);lp(a);return}function gn(a,b){a=a|0;b=b|0;return f[(f[a+4>>2]|0)+(b<<2)>>2]|0}function hn(){var a=0;a=Yk(64)|0;Oj(a);return a|0}function jn(a,b){a=a|0;b=b|0;return $(pn(a,b))}function kn(a){a=a|0;return f[a+8>>2]|0}function ln(a){a=a|0;nk(a);f[a>>2]=2952;f[a+44>>2]=0;return}function mn(a){a=a|0;if(!a)return;jh(a);lp(a);return}function nn(a,b){a=a|0;b=b|0;return bo(a,b)|0}function on(a){a=a|0;return b[(f[a+8>>2]|0)+24>>0]|0}function pn(a,b){a=a|0;b=b|0;return $(n[(f[a>>2]|0)+(b<<2)>>2])}function qn(a,b,c){a=a|0;b=b|0;c=c|0;if(!(f[a>>2]&32))Ag(b,c,a)|0;return}function rn(a){a=a|0;return (f[a+8>>2]|0)-(f[a+4>>2]|0)>>2|0}function sn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ta[a&15](b|0,c|0,d|0)}function tn(){var a=0;a=Yk(96)|0;Nk(a);return a|0}function un(a){a=a|0;var b=0;b=u;u=u+a|0;u=u+15&-16;return b|0}function vn(a){a=a|0;return ((f[a+100>>2]|0)-(f[a+96>>2]|0)|0)/12|0|0}function wn(a){a=a|0;var b=0;b=(hp()|0)+188|0;return ki(a,f[b>>2]|0)|0}function xn(){var a=0;a=Yk(16)|0;_m(a);return a|0}function yn(){var a=0;a=Yk(40)|0;zk(a);return a|0}function zn(a,b){a=a|0;b=b|0;return 1}function An(a,b){a=a|0;b=b|0;return Kn(a,b)|0}function Bn(a,b){a=a|0;b=b|0;return Ln(a,b)|0}function Cn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(3);return 0}function Dn(a,b){a=a|0;b=b|0;return $n(a,b)|0}function En(){var a=0;a=Yk(12)|0;Tn(a);return a|0}function Fn(a){a=a|0;Ih(a);lp(a);return}function Gn(a){a=a|0;n[a>>2]=$(1.0);n[a+4>>2]=$(1.0);return}function Hn(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function In(a,b){a=a|0;b=b|0;var c=0;c=Yn(a|0)|0;return ((b|0)==0?a:c)|0}function Jn(a){a=a|0;return (f[a+12>>2]|0)-(f[a+8>>2]|0)>>2|0}function Kn(a,b){a=a|0;b=b|0;return f[(f[a>>2]|0)+(b<<2)>>2]|0}function Ln(a,b){a=a|0;b=b|0;return d[(f[a>>2]|0)+(b<<1)>>1]|0}function Mn(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return}function Nn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return zc(a,b,c,d,0)|0}function On(a){a=a|0;f[a+4>>2]=0;f[a+8>>2]=0;f[a>>2]=a+4;return}function Pn(){var a=0;a=Yk(84)|0;$l(a);return a|0}function Qn(a){a=a|0;Ig(a);lp(a);return}function Rn(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)>>2|0}function Sn(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)>>1|0}function Tn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;return}function Un(a){a=a|0;f[a>>2]=4728;yk(a+4|0);return}function Vn(a,b){a=a|0;b=b|0;return f[b+12>>2]|0}function Wn(a,b,c){a=a|0;b=b|0;c=c|0;return Na[a&127](b|0,c|0)|0}function Xn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(10)}function Yn(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function Zn(a){a=a|0;ln(a);f[a>>2]=3356;return}function _n(a,c){a=a|0;c=c|0;b[a>>0]=b[c>>0]|0;return}function $n(a,c){a=a|0;c=c|0;return b[(f[a>>2]|0)+c>>0]|0}function ao(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)|0}function bo(a,b){a=a|0;b=b|0;return f[b+4>>2]|0}function co(a){a=a|0;return $(n[a+20>>2])}function eo(a){a=a|0;return f[a+4>>2]|0}function fo(a){a=a|0;if(!a)return;lp(a);return}function go(a,b){a=a|0;b=b|0;if(!x){x=a;y=b}}function ho(a){a=a|0;return a+12|0}function io(a){a=a|0;return f[a+88>>2]|0}function jo(a,b,c){a=a|0;b=b|0;c=c|0;Sa[a&7](b|0,c|0)}function ko(){var a=0;a=Yk(40)|0;Vk(a);return a|0}function lo(){var a=0;a=Yk(108)|0;Xk(a);return a|0}function mo(a){a=a|0;return (b[a+32>>0]|0)!=0|0}function no(a){a=a|0;return a+-12|0}function oo(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(9)}function po(){var a=0;a=f[4258]|0;f[4258]=a+0;return a|0}function qo(a){a=a|0;return Po(a+4|0)|0}function ro(a){a=a|0;return f[a+56>>2]|0}function so(){var a=0;a=f[1158]|0;f[1158]=a+0;return a|0}function to(a){a=a|0;nf(a);lp(a);return}function uo(a){a=a|0;qp(a);lp(a);return}function vo(a){a=a|0;return b[a+24>>0]|0}function wo(a,b){a=a|0;b=b|0;return 0}function xo(a){a=a|0;return f[a+40>>2]|0}function yo(a){a=a|0;return f[a+48>>2]|0}function zo(a,b){a=a|0;b=b|0;return Ma[a&127](b|0)|0}function Ao(a){a=a|0;return f[a+60>>2]|0}function Bo(a){a=a|0;return f[a+28>>2]|0}function Co(a){a=a|0;sa(a|0)|0;tk()}function Do(a){a=a|0;Un(a);lp(a);return}function Eo(a){a=a|0;Da()}function Fo(a,b){a=a|0;b=b|0;u=a;v=b}function Go(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function Ho(a){a=a|0;return (f[a>>2]|0)==0|0}function Io(a){a=a|0;return f[a+80>>2]|0}function Jo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(8)}function Ko(a,b){a=a|0;b=b|0;Ra[a&127](b|0)}function Lo(a,b){a=a|0;b=b|0;return Vl(a,b)|0}function Mo(a){a=a|0;return a&255|0}function No(a){a=a|0;f[a>>2]=0;return}function Oo(a,b,c){a=a|0;b=b|0;c=c|0;aa(2);return 0}function Po(a){a=a|0;return f[a>>2]|0}function Qo(a){a=a|0;return 2}function Ro(a){a=a|0;return 1}function So(a,b){a=+a;b=b|0;return +(+li(a,b))}function To(){return 3}function Uo(a,b,c){a=a|0;b=b|0;c=c|0;aa(7)}function Vo(){return -4}function Wo(){return 4}function Xo(){return -3}function Yo(){return 1}function Zo(){return 2}function _o(){return (hp()|0)+64|0}function $o(){return -5}function ap(a,b){a=a|0;b=b|0;aa(1);return 0}function bp(a){a=a|0;Qa[a&3]()}function cp(){return -2}function dp(){ua()}function ep(){return -1}function fp(a,b){a=a|0;b=b|0;aa(6)}function gp(){return 0}function hp(){return vp()|0}function ip(a){a=a|0;return Yk(a)|0}function jp(a){a=a|0;lp(a);return}function kp(a){a=a|0;u=a}function lp(a){a=a|0;Xb(a);return}function mp(a){a=a|0;I=a}function np(){return 16960}function op(a){a=a|0;return a|0}function pp(a){a=a|0;aa(0);return 0}function qp(a){a=a|0;return}function rp(a){a=a|0;return 0}function sp(){return I|0}function tp(){return u|0}function up(a){a=a|0;aa(5)}function vp(){return 3752}function wp(){aa(4)} + +// EMSCRIPTEN_END_FUNCS +var Ma=[pp,Qo,Ro,rn,Bo,Ro,Rb,rd,on,eo,rp,rp,Ro,rp,Ro,Ro,Ej,Qo,Ej,Ql,Ej,Vm,Cj,Ro,_l,Cj,Ro,am,Bi,Ro,Bo,Ro,Ej,Qo,Ej,Ql,Ej,Vm,Cj,Ro,_l,Cj,Ro,am,Bi,Ro,Bo,Qo,rp,eo,Ro,rp,Ro,Qo,rp,eo,Ro,rp,Ro,Vm,am,xi,Ro,Bo,am,xi,Ro,Bo,am,xi,Ro,Bo,am,xi,Ro,Bo,Ge,Ro,Ro,Nl,pd,Wi,Ro,rp,af,em,jm,hm,cb,Ro,eo,kn,Se,_d,Ve,ab,Ro,eo,kn,bb,Ro,eo,kn,yb,Yg,rp,Ro,di,mi,bl,qo,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp,pp];var Na=[ap,Dj,Gf,bc,Jj,gn,wo,zn,Qb,qb,Am,zn,Cg,Ld,yg,xj,ti,ri,uj,Fh,Um,wo,Jf,dd,wo,Yj,fd,wo,Yj,Ad,wo,Rj,Ke,rk,dd,wo,Yj,fd,wo,Yj,Ad,wo,Rj,Ke,rk,dg,Um,wo,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ua=[Jo,qh,Vc,mk,nj,Jo,Jo,Jo];var Va=[oo,Bh,Ef,oo];var Wa=[Xn,Uj,_i,Xn];return{___cxa_can_catch:qk,___cxa_is_pointer_type:Km,___divdi3:Li,___muldi3:fl,___udivdi3:Nn,___uremdi3:Wk,_bitshift64Lshr:Xl,_bitshift64Shl:Rl,_emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0:Gm,_emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1:rm,_emscripten_bind_AttributeOctahedronTransform___destroy___0:Om,_emscripten_bind_AttributeOctahedronTransform_quantization_bits_0:eo,_emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0:Mk,_emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1:rm,_emscripten_bind_AttributeQuantizationTransform___destroy___0:Om,_emscripten_bind_AttributeQuantizationTransform_min_value_1:Lm,_emscripten_bind_AttributeQuantizationTransform_quantization_bits_0:eo,_emscripten_bind_AttributeQuantizationTransform_range_0:co,_emscripten_bind_AttributeTransformData_AttributeTransformData_0:Fm,_emscripten_bind_AttributeTransformData___destroy___0:Ok,_emscripten_bind_AttributeTransformData_transform_type_0:Po,_emscripten_bind_DecoderBuffer_DecoderBuffer_0:yn,_emscripten_bind_DecoderBuffer_Init_2:bn,_emscripten_bind_DecoderBuffer___destroy___0:fn,_emscripten_bind_Decoder_DecodeBufferToMesh_2:mm,_emscripten_bind_Decoder_DecodeBufferToPointCloud_2:Yl,_emscripten_bind_Decoder_Decoder_0:ko,_emscripten_bind_Decoder_GetAttributeByUniqueId_2:wm,_emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3:il,_emscripten_bind_Decoder_GetAttributeFloat_3:Ol,_emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3:Il,_emscripten_bind_Decoder_GetAttributeIdByName_2:Cm,_emscripten_bind_Decoder_GetAttributeId_2:dm,_emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3:pl,_emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3:tl,_emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3:sl,_emscripten_bind_Decoder_GetAttributeIntForAllPoints_3:tl,_emscripten_bind_Decoder_GetAttributeMetadata_2:um,_emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3:hl,_emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3:gl,_emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3:ol,_emscripten_bind_Decoder_GetAttribute_2:Sm,_emscripten_bind_Decoder_GetEncodedGeometryType_1:Mm,_emscripten_bind_Decoder_GetFaceFromMesh_3:bm,_emscripten_bind_Decoder_GetMetadata_1:nn,_emscripten_bind_Decoder_GetTriangleStripsFromMesh_2:fm,_emscripten_bind_Decoder_SkipAttributeTransform_1:Jm,_emscripten_bind_Decoder___destroy___0:Ci,_emscripten_bind_DracoFloat32Array_DracoFloat32Array_0:En,_emscripten_bind_DracoFloat32Array_GetValue_1:jn,_emscripten_bind_DracoFloat32Array___destroy___0:vk,_emscripten_bind_DracoFloat32Array_size_0:Rn,_emscripten_bind_DracoInt16Array_DracoInt16Array_0:En,_emscripten_bind_DracoInt16Array_GetValue_1:Bn,_emscripten_bind_DracoInt16Array___destroy___0:wk,_emscripten_bind_DracoInt16Array_size_0:Sn,_emscripten_bind_DracoInt32Array_DracoInt32Array_0:En,_emscripten_bind_DracoInt32Array_GetValue_1:An,_emscripten_bind_DracoInt32Array___destroy___0:vk,_emscripten_bind_DracoInt32Array_size_0:Rn,_emscripten_bind_DracoInt8Array_DracoInt8Array_0:En,_emscripten_bind_DracoInt8Array_GetValue_1:Dn,_emscripten_bind_DracoInt8Array___destroy___0:Uk,_emscripten_bind_DracoInt8Array_size_0:ao,_emscripten_bind_DracoUInt16Array_DracoUInt16Array_0:En,_emscripten_bind_DracoUInt16Array_GetValue_1:Bn,_emscripten_bind_DracoUInt16Array___destroy___0:wk,_emscripten_bind_DracoUInt16Array_size_0:Sn,_emscripten_bind_DracoUInt32Array_DracoUInt32Array_0:En,_emscripten_bind_DracoUInt32Array_GetValue_1:An,_emscripten_bind_DracoUInt32Array___destroy___0:vk,_emscripten_bind_DracoUInt32Array_size_0:Rn,_emscripten_bind_DracoUInt8Array_DracoUInt8Array_0:En,_emscripten_bind_DracoUInt8Array_GetValue_1:Dn,_emscripten_bind_DracoUInt8Array___destroy___0:Uk,_emscripten_bind_DracoUInt8Array_size_0:ao,_emscripten_bind_GeometryAttribute_GeometryAttribute_0:hn,_emscripten_bind_GeometryAttribute___destroy___0:fo,_emscripten_bind_Mesh_Mesh_0:lo,_emscripten_bind_Mesh___destroy___0:Om,_emscripten_bind_Mesh_num_attributes_0:Jn,_emscripten_bind_Mesh_num_faces_0:vn,_emscripten_bind_Mesh_num_points_0:Io,_emscripten_bind_MetadataQuerier_GetDoubleEntry_2:qm,_emscripten_bind_MetadataQuerier_GetEntryName_2:Bm,_emscripten_bind_MetadataQuerier_GetIntEntry_2:ym,_emscripten_bind_MetadataQuerier_GetStringEntry_2:pm,_emscripten_bind_MetadataQuerier_HasDoubleEntry_2:om,_emscripten_bind_MetadataQuerier_HasEntry_2:Hm,_emscripten_bind_MetadataQuerier_HasIntEntry_2:xm,_emscripten_bind_MetadataQuerier_HasStringEntry_2:nm,_emscripten_bind_MetadataQuerier_MetadataQuerier_0:xn,_emscripten_bind_MetadataQuerier_NumEntries_1:Xm,_emscripten_bind_MetadataQuerier___destroy___0:Fi,_emscripten_bind_Metadata_Metadata_0:ck,_emscripten_bind_Metadata___destroy___0:mn,_emscripten_bind_PointAttribute_GetAttributeTransformData_0:io,_emscripten_bind_PointAttribute_PointAttribute_0:tn,_emscripten_bind_PointAttribute___destroy___0:Uh,_emscripten_bind_PointAttribute_attribute_type_0:ro,_emscripten_bind_PointAttribute_byte_offset_0:yo,_emscripten_bind_PointAttribute_byte_stride_0:xo,_emscripten_bind_PointAttribute_data_type_0:Bo,_emscripten_bind_PointAttribute_normalized_0:mo,_emscripten_bind_PointAttribute_num_components_0:vo,_emscripten_bind_PointAttribute_size_0:Io,_emscripten_bind_PointAttribute_unique_id_0:Ao,_emscripten_bind_PointCloud_PointCloud_0:Pn,_emscripten_bind_PointCloud___destroy___0:Om,_emscripten_bind_PointCloud_num_attributes_0:Jn,_emscripten_bind_PointCloud_num_points_0:Io,_emscripten_bind_Status___destroy___0:Sl,_emscripten_bind_Status_code_0:Po,_emscripten_bind_Status_error_msg_0:Hl,_emscripten_bind_Status_ok_0:Ho,_emscripten_bind_VoidPtr___destroy___0:fo,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM:ep,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM:gp,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM:Zo,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM:Yo,_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE:ep,_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD:gp,_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH:Yo,_emscripten_enum_draco_GeometryAttribute_Type_COLOR:Zo,_emscripten_enum_draco_GeometryAttribute_Type_GENERIC:Wo,_emscripten_enum_draco_GeometryAttribute_Type_INVALID:ep,_emscripten_enum_draco_GeometryAttribute_Type_NORMAL:Yo,_emscripten_enum_draco_GeometryAttribute_Type_POSITION:gp,_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD:To,_emscripten_enum_draco_StatusCode_ERROR:ep,_emscripten_enum_draco_StatusCode_INVALID_PARAMETER:Xo,_emscripten_enum_draco_StatusCode_IO_ERROR:cp,_emscripten_enum_draco_StatusCode_OK:gp,_emscripten_enum_draco_StatusCode_UNKNOWN_VERSION:$o,_emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION:Vo,_emscripten_get_global_libc:np,_emscripten_replace_memory:La,_free:Xb,_i64Add:Ul,_i64Subtract:Wl,_llvm_bswap_i32:Yn,_malloc:Xa,_memcpy:Ff,_memmove:ok,_memset:Dh,_sbrk:Kj,dynCall_ii:zo,dynCall_iii:Wn,dynCall_iiii:an,dynCall_iiiiiii:Al,dynCall_v:bp,dynCall_vi:Ko,dynCall_vii:jo,dynCall_viii:sn,dynCall_viiii:Qm,dynCall_viiiii:km,dynCall_viiiiii:Ll,establishStackSpace:Fo,getTempRet0:sp,runPostSets:Tl,setTempRet0:mp,setThrew:go,stackAlloc:un,stackRestore:kp,stackSave:tp}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var ___divdi3=Module["___divdi3"]=asm["___divdi3"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=Module["_emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0"]=asm["_emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0"];var _emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=Module["_emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1"]=asm["_emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1"];var _emscripten_bind_AttributeOctahedronTransform___destroy___0=Module["_emscripten_bind_AttributeOctahedronTransform___destroy___0"]=asm["_emscripten_bind_AttributeOctahedronTransform___destroy___0"];var _emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=Module["_emscripten_bind_AttributeOctahedronTransform_quantization_bits_0"]=asm["_emscripten_bind_AttributeOctahedronTransform_quantization_bits_0"];var _emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=Module["_emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0"]=asm["_emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0"];var _emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=Module["_emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1"]=asm["_emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1"];var _emscripten_bind_AttributeQuantizationTransform___destroy___0=Module["_emscripten_bind_AttributeQuantizationTransform___destroy___0"]=asm["_emscripten_bind_AttributeQuantizationTransform___destroy___0"];var _emscripten_bind_AttributeQuantizationTransform_min_value_1=Module["_emscripten_bind_AttributeQuantizationTransform_min_value_1"]=asm["_emscripten_bind_AttributeQuantizationTransform_min_value_1"];var _emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=Module["_emscripten_bind_AttributeQuantizationTransform_quantization_bits_0"]=asm["_emscripten_bind_AttributeQuantizationTransform_quantization_bits_0"];var _emscripten_bind_AttributeQuantizationTransform_range_0=Module["_emscripten_bind_AttributeQuantizationTransform_range_0"]=asm["_emscripten_bind_AttributeQuantizationTransform_range_0"];var _emscripten_bind_AttributeTransformData_AttributeTransformData_0=Module["_emscripten_bind_AttributeTransformData_AttributeTransformData_0"]=asm["_emscripten_bind_AttributeTransformData_AttributeTransformData_0"];var _emscripten_bind_AttributeTransformData___destroy___0=Module["_emscripten_bind_AttributeTransformData___destroy___0"]=asm["_emscripten_bind_AttributeTransformData___destroy___0"];var _emscripten_bind_AttributeTransformData_transform_type_0=Module["_emscripten_bind_AttributeTransformData_transform_type_0"]=asm["_emscripten_bind_AttributeTransformData_transform_type_0"];var _emscripten_bind_DecoderBuffer_DecoderBuffer_0=Module["_emscripten_bind_DecoderBuffer_DecoderBuffer_0"]=asm["_emscripten_bind_DecoderBuffer_DecoderBuffer_0"];var _emscripten_bind_DecoderBuffer_Init_2=Module["_emscripten_bind_DecoderBuffer_Init_2"]=asm["_emscripten_bind_DecoderBuffer_Init_2"];var _emscripten_bind_DecoderBuffer___destroy___0=Module["_emscripten_bind_DecoderBuffer___destroy___0"]=asm["_emscripten_bind_DecoderBuffer___destroy___0"];var _emscripten_bind_Decoder_DecodeBufferToMesh_2=Module["_emscripten_bind_Decoder_DecodeBufferToMesh_2"]=asm["_emscripten_bind_Decoder_DecodeBufferToMesh_2"];var _emscripten_bind_Decoder_DecodeBufferToPointCloud_2=Module["_emscripten_bind_Decoder_DecodeBufferToPointCloud_2"]=asm["_emscripten_bind_Decoder_DecodeBufferToPointCloud_2"];var _emscripten_bind_Decoder_Decoder_0=Module["_emscripten_bind_Decoder_Decoder_0"]=asm["_emscripten_bind_Decoder_Decoder_0"];var _emscripten_bind_Decoder_GetAttributeByUniqueId_2=Module["_emscripten_bind_Decoder_GetAttributeByUniqueId_2"]=asm["_emscripten_bind_Decoder_GetAttributeByUniqueId_2"];var _emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeFloat_3=Module["_emscripten_bind_Decoder_GetAttributeFloat_3"]=asm["_emscripten_bind_Decoder_GetAttributeFloat_3"];var _emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=Module["_emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3"]=asm["_emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3"];var _emscripten_bind_Decoder_GetAttributeIdByName_2=Module["_emscripten_bind_Decoder_GetAttributeIdByName_2"]=asm["_emscripten_bind_Decoder_GetAttributeIdByName_2"];var _emscripten_bind_Decoder_GetAttributeId_2=Module["_emscripten_bind_Decoder_GetAttributeId_2"]=asm["_emscripten_bind_Decoder_GetAttributeId_2"];var _emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeIntForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeIntForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeMetadata_2=Module["_emscripten_bind_Decoder_GetAttributeMetadata_2"]=asm["_emscripten_bind_Decoder_GetAttributeMetadata_2"];var _emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttribute_2=Module["_emscripten_bind_Decoder_GetAttribute_2"]=asm["_emscripten_bind_Decoder_GetAttribute_2"];var _emscripten_bind_Decoder_GetEncodedGeometryType_1=Module["_emscripten_bind_Decoder_GetEncodedGeometryType_1"]=asm["_emscripten_bind_Decoder_GetEncodedGeometryType_1"];var _emscripten_bind_Decoder_GetFaceFromMesh_3=Module["_emscripten_bind_Decoder_GetFaceFromMesh_3"]=asm["_emscripten_bind_Decoder_GetFaceFromMesh_3"];var _emscripten_bind_Decoder_GetMetadata_1=Module["_emscripten_bind_Decoder_GetMetadata_1"]=asm["_emscripten_bind_Decoder_GetMetadata_1"];var _emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=Module["_emscripten_bind_Decoder_GetTriangleStripsFromMesh_2"]=asm["_emscripten_bind_Decoder_GetTriangleStripsFromMesh_2"];var _emscripten_bind_Decoder_SkipAttributeTransform_1=Module["_emscripten_bind_Decoder_SkipAttributeTransform_1"]=asm["_emscripten_bind_Decoder_SkipAttributeTransform_1"];var _emscripten_bind_Decoder___destroy___0=Module["_emscripten_bind_Decoder___destroy___0"]=asm["_emscripten_bind_Decoder___destroy___0"];var _emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=Module["_emscripten_bind_DracoFloat32Array_DracoFloat32Array_0"]=asm["_emscripten_bind_DracoFloat32Array_DracoFloat32Array_0"];var _emscripten_bind_DracoFloat32Array_GetValue_1=Module["_emscripten_bind_DracoFloat32Array_GetValue_1"]=asm["_emscripten_bind_DracoFloat32Array_GetValue_1"];var _emscripten_bind_DracoFloat32Array___destroy___0=Module["_emscripten_bind_DracoFloat32Array___destroy___0"]=asm["_emscripten_bind_DracoFloat32Array___destroy___0"];var _emscripten_bind_DracoFloat32Array_size_0=Module["_emscripten_bind_DracoFloat32Array_size_0"]=asm["_emscripten_bind_DracoFloat32Array_size_0"];var _emscripten_bind_DracoInt16Array_DracoInt16Array_0=Module["_emscripten_bind_DracoInt16Array_DracoInt16Array_0"]=asm["_emscripten_bind_DracoInt16Array_DracoInt16Array_0"];var _emscripten_bind_DracoInt16Array_GetValue_1=Module["_emscripten_bind_DracoInt16Array_GetValue_1"]=asm["_emscripten_bind_DracoInt16Array_GetValue_1"];var _emscripten_bind_DracoInt16Array___destroy___0=Module["_emscripten_bind_DracoInt16Array___destroy___0"]=asm["_emscripten_bind_DracoInt16Array___destroy___0"];var _emscripten_bind_DracoInt16Array_size_0=Module["_emscripten_bind_DracoInt16Array_size_0"]=asm["_emscripten_bind_DracoInt16Array_size_0"];var _emscripten_bind_DracoInt32Array_DracoInt32Array_0=Module["_emscripten_bind_DracoInt32Array_DracoInt32Array_0"]=asm["_emscripten_bind_DracoInt32Array_DracoInt32Array_0"];var _emscripten_bind_DracoInt32Array_GetValue_1=Module["_emscripten_bind_DracoInt32Array_GetValue_1"]=asm["_emscripten_bind_DracoInt32Array_GetValue_1"];var _emscripten_bind_DracoInt32Array___destroy___0=Module["_emscripten_bind_DracoInt32Array___destroy___0"]=asm["_emscripten_bind_DracoInt32Array___destroy___0"];var _emscripten_bind_DracoInt32Array_size_0=Module["_emscripten_bind_DracoInt32Array_size_0"]=asm["_emscripten_bind_DracoInt32Array_size_0"];var _emscripten_bind_DracoInt8Array_DracoInt8Array_0=Module["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"]=asm["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"];var _emscripten_bind_DracoInt8Array_GetValue_1=Module["_emscripten_bind_DracoInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoInt8Array_GetValue_1"];var _emscripten_bind_DracoInt8Array___destroy___0=Module["_emscripten_bind_DracoInt8Array___destroy___0"]=asm["_emscripten_bind_DracoInt8Array___destroy___0"];var _emscripten_bind_DracoInt8Array_size_0=Module["_emscripten_bind_DracoInt8Array_size_0"]=asm["_emscripten_bind_DracoInt8Array_size_0"];var _emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=Module["_emscripten_bind_DracoUInt16Array_DracoUInt16Array_0"]=asm["_emscripten_bind_DracoUInt16Array_DracoUInt16Array_0"];var _emscripten_bind_DracoUInt16Array_GetValue_1=Module["_emscripten_bind_DracoUInt16Array_GetValue_1"]=asm["_emscripten_bind_DracoUInt16Array_GetValue_1"];var _emscripten_bind_DracoUInt16Array___destroy___0=Module["_emscripten_bind_DracoUInt16Array___destroy___0"]=asm["_emscripten_bind_DracoUInt16Array___destroy___0"];var _emscripten_bind_DracoUInt16Array_size_0=Module["_emscripten_bind_DracoUInt16Array_size_0"]=asm["_emscripten_bind_DracoUInt16Array_size_0"];var _emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=Module["_emscripten_bind_DracoUInt32Array_DracoUInt32Array_0"]=asm["_emscripten_bind_DracoUInt32Array_DracoUInt32Array_0"];var _emscripten_bind_DracoUInt32Array_GetValue_1=Module["_emscripten_bind_DracoUInt32Array_GetValue_1"]=asm["_emscripten_bind_DracoUInt32Array_GetValue_1"];var _emscripten_bind_DracoUInt32Array___destroy___0=Module["_emscripten_bind_DracoUInt32Array___destroy___0"]=asm["_emscripten_bind_DracoUInt32Array___destroy___0"];var _emscripten_bind_DracoUInt32Array_size_0=Module["_emscripten_bind_DracoUInt32Array_size_0"]=asm["_emscripten_bind_DracoUInt32Array_size_0"];var _emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=Module["_emscripten_bind_DracoUInt8Array_DracoUInt8Array_0"]=asm["_emscripten_bind_DracoUInt8Array_DracoUInt8Array_0"];var _emscripten_bind_DracoUInt8Array_GetValue_1=Module["_emscripten_bind_DracoUInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoUInt8Array_GetValue_1"];var _emscripten_bind_DracoUInt8Array___destroy___0=Module["_emscripten_bind_DracoUInt8Array___destroy___0"]=asm["_emscripten_bind_DracoUInt8Array___destroy___0"];var _emscripten_bind_DracoUInt8Array_size_0=Module["_emscripten_bind_DracoUInt8Array_size_0"]=asm["_emscripten_bind_DracoUInt8Array_size_0"];var _emscripten_bind_GeometryAttribute_GeometryAttribute_0=Module["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"]=asm["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"];var _emscripten_bind_GeometryAttribute___destroy___0=Module["_emscripten_bind_GeometryAttribute___destroy___0"]=asm["_emscripten_bind_GeometryAttribute___destroy___0"];var _emscripten_bind_Mesh_Mesh_0=Module["_emscripten_bind_Mesh_Mesh_0"]=asm["_emscripten_bind_Mesh_Mesh_0"];var _emscripten_bind_Mesh___destroy___0=Module["_emscripten_bind_Mesh___destroy___0"]=asm["_emscripten_bind_Mesh___destroy___0"];var _emscripten_bind_Mesh_num_attributes_0=Module["_emscripten_bind_Mesh_num_attributes_0"]=asm["_emscripten_bind_Mesh_num_attributes_0"];var _emscripten_bind_Mesh_num_faces_0=Module["_emscripten_bind_Mesh_num_faces_0"]=asm["_emscripten_bind_Mesh_num_faces_0"];var _emscripten_bind_Mesh_num_points_0=Module["_emscripten_bind_Mesh_num_points_0"]=asm["_emscripten_bind_Mesh_num_points_0"];var _emscripten_bind_MetadataQuerier_GetDoubleEntry_2=Module["_emscripten_bind_MetadataQuerier_GetDoubleEntry_2"]=asm["_emscripten_bind_MetadataQuerier_GetDoubleEntry_2"];var _emscripten_bind_MetadataQuerier_GetEntryName_2=Module["_emscripten_bind_MetadataQuerier_GetEntryName_2"]=asm["_emscripten_bind_MetadataQuerier_GetEntryName_2"];var _emscripten_bind_MetadataQuerier_GetIntEntry_2=Module["_emscripten_bind_MetadataQuerier_GetIntEntry_2"]=asm["_emscripten_bind_MetadataQuerier_GetIntEntry_2"];var _emscripten_bind_MetadataQuerier_GetStringEntry_2=Module["_emscripten_bind_MetadataQuerier_GetStringEntry_2"]=asm["_emscripten_bind_MetadataQuerier_GetStringEntry_2"];var _emscripten_bind_MetadataQuerier_HasDoubleEntry_2=Module["_emscripten_bind_MetadataQuerier_HasDoubleEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasDoubleEntry_2"];var _emscripten_bind_MetadataQuerier_HasEntry_2=Module["_emscripten_bind_MetadataQuerier_HasEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasEntry_2"];var _emscripten_bind_MetadataQuerier_HasIntEntry_2=Module["_emscripten_bind_MetadataQuerier_HasIntEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasIntEntry_2"];var _emscripten_bind_MetadataQuerier_HasStringEntry_2=Module["_emscripten_bind_MetadataQuerier_HasStringEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasStringEntry_2"];var _emscripten_bind_MetadataQuerier_MetadataQuerier_0=Module["_emscripten_bind_MetadataQuerier_MetadataQuerier_0"]=asm["_emscripten_bind_MetadataQuerier_MetadataQuerier_0"];var _emscripten_bind_MetadataQuerier_NumEntries_1=Module["_emscripten_bind_MetadataQuerier_NumEntries_1"]=asm["_emscripten_bind_MetadataQuerier_NumEntries_1"];var _emscripten_bind_MetadataQuerier___destroy___0=Module["_emscripten_bind_MetadataQuerier___destroy___0"]=asm["_emscripten_bind_MetadataQuerier___destroy___0"];var _emscripten_bind_Metadata_Metadata_0=Module["_emscripten_bind_Metadata_Metadata_0"]=asm["_emscripten_bind_Metadata_Metadata_0"];var _emscripten_bind_Metadata___destroy___0=Module["_emscripten_bind_Metadata___destroy___0"]=asm["_emscripten_bind_Metadata___destroy___0"];var _emscripten_bind_PointAttribute_GetAttributeTransformData_0=Module["_emscripten_bind_PointAttribute_GetAttributeTransformData_0"]=asm["_emscripten_bind_PointAttribute_GetAttributeTransformData_0"];var _emscripten_bind_PointAttribute_PointAttribute_0=Module["_emscripten_bind_PointAttribute_PointAttribute_0"]=asm["_emscripten_bind_PointAttribute_PointAttribute_0"];var _emscripten_bind_PointAttribute___destroy___0=Module["_emscripten_bind_PointAttribute___destroy___0"]=asm["_emscripten_bind_PointAttribute___destroy___0"];var _emscripten_bind_PointAttribute_attribute_type_0=Module["_emscripten_bind_PointAttribute_attribute_type_0"]=asm["_emscripten_bind_PointAttribute_attribute_type_0"];var _emscripten_bind_PointAttribute_byte_offset_0=Module["_emscripten_bind_PointAttribute_byte_offset_0"]=asm["_emscripten_bind_PointAttribute_byte_offset_0"];var _emscripten_bind_PointAttribute_byte_stride_0=Module["_emscripten_bind_PointAttribute_byte_stride_0"]=asm["_emscripten_bind_PointAttribute_byte_stride_0"];var _emscripten_bind_PointAttribute_data_type_0=Module["_emscripten_bind_PointAttribute_data_type_0"]=asm["_emscripten_bind_PointAttribute_data_type_0"];var _emscripten_bind_PointAttribute_normalized_0=Module["_emscripten_bind_PointAttribute_normalized_0"]=asm["_emscripten_bind_PointAttribute_normalized_0"];var _emscripten_bind_PointAttribute_num_components_0=Module["_emscripten_bind_PointAttribute_num_components_0"]=asm["_emscripten_bind_PointAttribute_num_components_0"];var _emscripten_bind_PointAttribute_size_0=Module["_emscripten_bind_PointAttribute_size_0"]=asm["_emscripten_bind_PointAttribute_size_0"];var _emscripten_bind_PointAttribute_unique_id_0=Module["_emscripten_bind_PointAttribute_unique_id_0"]=asm["_emscripten_bind_PointAttribute_unique_id_0"];var _emscripten_bind_PointCloud_PointCloud_0=Module["_emscripten_bind_PointCloud_PointCloud_0"]=asm["_emscripten_bind_PointCloud_PointCloud_0"];var _emscripten_bind_PointCloud___destroy___0=Module["_emscripten_bind_PointCloud___destroy___0"]=asm["_emscripten_bind_PointCloud___destroy___0"];var _emscripten_bind_PointCloud_num_attributes_0=Module["_emscripten_bind_PointCloud_num_attributes_0"]=asm["_emscripten_bind_PointCloud_num_attributes_0"];var _emscripten_bind_PointCloud_num_points_0=Module["_emscripten_bind_PointCloud_num_points_0"]=asm["_emscripten_bind_PointCloud_num_points_0"];var _emscripten_bind_Status___destroy___0=Module["_emscripten_bind_Status___destroy___0"]=asm["_emscripten_bind_Status___destroy___0"];var _emscripten_bind_Status_code_0=Module["_emscripten_bind_Status_code_0"]=asm["_emscripten_bind_Status_code_0"];var _emscripten_bind_Status_error_msg_0=Module["_emscripten_bind_Status_error_msg_0"]=asm["_emscripten_bind_Status_error_msg_0"];var _emscripten_bind_Status_ok_0=Module["_emscripten_bind_Status_ok_0"]=asm["_emscripten_bind_Status_ok_0"];var _emscripten_bind_VoidPtr___destroy___0=Module["_emscripten_bind_VoidPtr___destroy___0"]=asm["_emscripten_bind_VoidPtr___destroy___0"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM"];var _emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=Module["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"]=asm["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"];var _emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=Module["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"]=asm["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"];var _emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=Module["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"]=asm["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"];var _emscripten_enum_draco_GeometryAttribute_Type_COLOR=Module["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"];var _emscripten_enum_draco_GeometryAttribute_Type_GENERIC=Module["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"];var _emscripten_enum_draco_GeometryAttribute_Type_INVALID=Module["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"];var _emscripten_enum_draco_GeometryAttribute_Type_NORMAL=Module["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"];var _emscripten_enum_draco_GeometryAttribute_Type_POSITION=Module["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"];var _emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=Module["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"];var _emscripten_enum_draco_StatusCode_ERROR=Module["_emscripten_enum_draco_StatusCode_ERROR"]=asm["_emscripten_enum_draco_StatusCode_ERROR"];var _emscripten_enum_draco_StatusCode_INVALID_PARAMETER=Module["_emscripten_enum_draco_StatusCode_INVALID_PARAMETER"]=asm["_emscripten_enum_draco_StatusCode_INVALID_PARAMETER"];var _emscripten_enum_draco_StatusCode_IO_ERROR=Module["_emscripten_enum_draco_StatusCode_IO_ERROR"]=asm["_emscripten_enum_draco_StatusCode_IO_ERROR"];var _emscripten_enum_draco_StatusCode_OK=Module["_emscripten_enum_draco_StatusCode_OK"]=asm["_emscripten_enum_draco_StatusCode_OK"];var _emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=Module["_emscripten_enum_draco_StatusCode_UNKNOWN_VERSION"]=asm["_emscripten_enum_draco_StatusCode_UNKNOWN_VERSION"];var _emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=Module["_emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION"]=asm["_emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION"];var _emscripten_get_global_libc=Module["_emscripten_get_global_libc"]=asm["_emscripten_get_global_libc"];var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=asm["_emscripten_replace_memory"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];Runtime.stackAlloc=Module["stackAlloc"];Runtime.stackSave=Module["stackSave"];Runtime.stackRestore=Module["stackRestore"];Runtime.establishStackSpace=Module["establishStackSpace"];Runtime.setTempRet0=Module["setTempRet0"];Runtime.getTempRet0=Module["getTempRet0"];Module["asm"]=asm;if(memoryInitializer){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,Runtime.GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,Runtime.GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(preloadStartTime===null)preloadStartTime=Date.now();if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=exit;var abortDecorators=[];function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach((function(decorator){output=decorator(output,what)}))}throw output}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:(function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret}),copy:(function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;ieoq=bUF>W@1+Bk0Maamh&c95x|6h!bWA#eGyeabCMlrz zt-2*nlFqOwD$Xzv6bHnB&IDN$S=`a6C@4{b5Jd!xf;(c|7Z{n(_xC&Zz58Chs;=sE zLTJ*Jyt|$CcYf!$o!|MLXy=iAaTG=I-^RTglHSC{>{zG&_!(K)=L{+X^!YiIFBUjaMs|vo=zug+$(6(&HZ@bNk*QMoetiD@s5F1{tc?S|x*&|U3i|b=N(s-&krveJ6~|%@O%_2@$}sO zy*m%TXzr@HeFqNT9OYK*i{|FHADG{{xBl{M%d~C(WjpupKQMpA;RD}Z|9Z}j9XoD( z$<7@+_wGG#;c#>2Y~&d=@Nv2SkQjR$Yu@q%41iZV51&5naKYi{RFJAlZMgL60Tdf~1c zs}5D4_RQV9<3&N8>`Ud8aA+6pYF zs@Y7UnFMgEF%+z-LbK8|i4$vI)Sy)Mv6yTi+cPdaN*jtsNK6yGyO@YBA zFVpy}v*TvQ7{rvC#cLZHCjS>PO8h_aA2m@!!16lIS~8rd4U z)@bK|cVe=cHJg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2~&!VeCN5`ke;*=zn zC`FHvXGW2E-J*gyWfl60HDvTR28kGM-!U^!;WLL0&3A%_yQ46m;>zHM83s7(LKKG+ z<1_PfF@4+?v-EJ*p;3l^hUQ@3{Inw^Y#fK*YA5=^>gdiKnwj$bFN}H!9mD6nBf34v=Q&{pIHX|Afzx&uKUj5 z6UiE!_f1ykI|x-gV$C-R;!Ddu3wwDxdtPT&UhuGi;0jTO{EI-$pR(+SM~_K{^rlUD zv)@M(1RhO6ny?qP2io0t%ycGYTN?YP&qem{Cts#rzM?o8J!nCX>ga>>hYv#zb0$l3 zMEDj{*C8je=tloeP~|U~u(MXSr(u)B$XDNA@!Zk*uECj)3Zqky*VyCg8xe$Bn{0w7((_vDo9~(!FIXp8zJr;bwbvvR|uhJ32 z#x|;V;s_~B#PV1G(8r9jpp$oucaO$b&RMy$Ca2*cW#{E>T+2?}HzD=5$B!_^qIp^A z#Z&3|xtSE;k7peOZC za?Xt(I5agnH&@KjlW51y6u&UVZ1c9-bCO*tCINy+>u zFif{k&N8I7$Kbb4yE{*OC8XNjv4haD@k0lkI>Yl$45uUAqy9xN3T{1cz;yj~=Zt8Y LJxJVTA;o_O^!4_c literal 0 HcmV?d00001 diff --git a/three/jsutil/libs/draco/draco_wasm_wrapper.js b/three/jsutil/libs/draco/draco_wasm_wrapper.js new file mode 100644 index 000000000..d31d270a4 --- /dev/null +++ b/three/jsutil/libs/draco/draco_wasm_wrapper.js @@ -0,0 +1,129 @@ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,f,n){d!=Array.prototype&&d!=Object.prototype&&(d[f]=n.value)};$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this); +$jscomp.polyfill=function(d,f,n,w){if(f){n=$jscomp.global;d=d.split(".");for(w=0;w>>16&65535)*g+n*(d>>>16&65535)<<16>>>0)|0}},"es6","es3"); +$jscomp.polyfill("Math.clz32",function(d){return d?d:function(f){f=Number(f)>>>0;if(0===f)return 32;var d=0;0===(f&4294901760)&&(f<<=16,d+=16);0===(f&4278190080)&&(f<<=8,d+=8);0===(f&4026531840)&&(f<<=4,d+=4);0===(f&3221225472)&&(f<<=2,d+=2);0===(f&2147483648)&&d++;return d}},"es6","es3");$jscomp.polyfill("Math.trunc",function(d){return d?d:function(d){d=Number(d);if(isNaN(d)||Infinity===d||-Infinity===d||0===d)return d;var f=Math.floor(Math.abs(d));return 0>d?-f:f}},"es6","es3"); +$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(d){return $jscomp.SYMBOL_PREFIX+(d||"")+$jscomp.symbolCounter_++}; +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var d=$jscomp.global.Symbol.iterator;d||(d=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[d]&&$jscomp.defineProperty(Array.prototype,d,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(d){var f=0;return $jscomp.iteratorPrototype(function(){return f>0];c|=l;if(0==l&&!b)break;d++;if(b&&d==b)break}b||(b=d);l="";if(128>c){for(;0>2]>b)return!1;var c=y;for(y=Math.max(y,ib);y>2];)y=536870912>=y?ma(2*y,e):Math.min(ma((3*y+2147483648)/4,e),b);e=a.reallocBuffer(y);if(!e||e.byteLength!=y)return y=c,!1;a.buffer=F=e;D();return!0}function u(e){for(;0>2]=e;e=qa.buffer;for(var d=0;d> +2],b.adjusted=e,(m.setTempRet0(l[d]),e)|0;e=x[e>>2];return(m.setTempRet0(c),e)|0}function Q(e,b){v.varargs=b;try{var c=v.get(),l=v.get(),d=v.get();e=0;Q.buffer||(Q.buffers=[null,[],[]],Q.printChar=function(b,c){var e=Q.buffers[b];f(e);if(0===c||10===c){b=1===b?a.print:a.printErr;a:{for(var l=c=0;e[l];)++l;if(16d?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else l+=String.fromCharCode(d)}}b(c);e.length=0}else e.push(c)});for(b=0;b>2],g=x[l+(8*b+4)>>2],k=0;k=e&&(e=65536+((e&1023)<<10)|a.charCodeAt(++c)&1023);127>=e?++b:b=2047>=e?b+2:65535>=e?b+3:2097151>=e?b+4:67108863>=e?b+5:b+6}b=Array(b+1);c=0;e=b.length;if(0=f&&(f=65536+((f&1023)<<10)|a.charCodeAt(++d)&1023);if(127>=f){if(c>=e)break;b[c++]=f}else{if(2047>=f){if(c+1>=e)break;b[c++]=192|f>>6}else{if(65535>=f){if(c+2>=e)break;b[c++]=224|f>>12}else{if(2097151>=f){if(c+3>=e)break;b[c++]=240|f>>18}else{if(67108863>=f){if(c+4>=e)break;b[c++]=248|f>>24}else{if(c+5>=e)break;b[c++]=252|f>>30;b[c++]=128|f>>24&63}b[c++]=128|f>>18&63}b[c++]=128|f>>12&63}b[c++]=128|f>>6&63}b[c++]=128|f&63}}b[c]=0}a=k.alloc(b,fa);k.copy(b,fa,a)}return a} +function B(){throw"cannot construct a Status, no constructor in IDL";}function G(){this.ptr=lb();t(G)[this.ptr]=this}function H(){this.ptr=mb();t(H)[this.ptr]=this}function I(){this.ptr=nb();t(I)[this.ptr]=this}function J(){this.ptr=ob();t(J)[this.ptr]=this}function K(){this.ptr=pb();t(K)[this.ptr]=this}function q(){this.ptr=qb();t(q)[this.ptr]=this}function P(){this.ptr=rb();t(P)[this.ptr]=this}function z(){this.ptr=sb();t(z)[this.ptr]=this}function L(){this.ptr=tb();t(L)[this.ptr]=this}function r(){this.ptr= +ub();t(r)[this.ptr]=this}function M(){this.ptr=vb();t(M)[this.ptr]=this}function N(){this.ptr=wb();t(N)[this.ptr]=this}function Z(){this.ptr=xb();t(Z)[this.ptr]=this}function R(){this.ptr=yb();t(R)[this.ptr]=this}function h(){this.ptr=zb();t(h)[this.ptr]=this}function C(){this.ptr=Ab();t(C)[this.ptr]=this}function ca(){throw"cannot construct a VoidPtr, no constructor in IDL";}function O(){this.ptr=Bb();t(O)[this.ptr]=this}function S(){this.ptr=Cb();t(S)[this.ptr]=this}var a=d=d||{},bb=!1,cb=!1;a.onRuntimeInitialized= +function(){bb=!0;if(cb&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.onModuleParsed=function(){cb=!0;if(bb&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.isVersionSupported=function(a){if("string"!==typeof a)return!1;a=a.split(".");return 2>a.length||3=a[1]?!0:0!=a[0]||10>2];a=(b+a+15|0)&-16;x[ba>>2]=a;return a>=y&&!Ma()?(x[ba>>2]=b,0):b},alignMemory:function(a,b){return Math.ceil(a/(b?b:16))*(b?b:16)},makeBigInt:function(a,b,c){return c?+(a>>>0)+4294967296*+(b>>>0):+(a>>>0)+4294967296*+(b|0)},GLOBAL_BASE:1024,QUANTUM_SIZE:4,__dummy__:0},ua=0,Ua="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;"undefined"!==typeof TextDecoder&&new TextDecoder("utf-16le");var Aa=65536,Sa=16777216,ib=16777216,fa,T,za, +Oa,x,Pa,Qa,Ra,aa,Ga,U,xa,Ha,ba;var Ia=aa=Ga=U=xa=Ha=ba=0;a.reallocBuffer||(a.reallocBuffer=function(a){try{if(ArrayBuffer.transfer)var b=ArrayBuffer.transfer(F,a);else{var c=fa;b=new ArrayBuffer(a);(new Int8Array(b)).set(c)}}catch(l){return!1}return Db(b)?b:!1});try{var Ja=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);Ja(new ArrayBuffer(4))}catch(e){Ja=function(a){return a.byteLength}}var Ka=a.TOTAL_STACK||5242880,y=a.TOTAL_MEMORY||16777216; +y>2]},getStr:function(){return n(v.get())},get64:function(){var a=v.get(),b=v.get();0<=a? +f(0===b):f(-1===b);return a},getZero:function(){f(0===v.get())}},ya={},La=1;db.push(function(){var e=a._fflush;e&&e(0);if(e=Q.printChar){var b=Q.buffers;b[1].length&&e(1,10);b[2].length&&e(2,10)}});ba=m.staticAlloc(4);Ga=U=m.alignMemory(aa);xa=Ga+Ka;Ha=m.alignMemory(xa);x[ba>>2]=Ha;a.wasmTableSize=492;a.wasmMaxTableSize=492;a.asmGlobalArg={Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array, +Float64Array:Float64Array,NaN:NaN,Infinity:Infinity,byteLength:Ja};a.asmLibraryArg={abort:W,assert:f,enlargeMemory:Ma,getTotalMemory:function(){return y},abortOnCannotGrowMemory:function(){W("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+y+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}, +invoke_ii:function(e,b){try{return a.dynCall_ii(e,b)}catch(c){if("number"!==typeof c&&"longjmp"!==c)throw c;a.setThrew(1,0)}},invoke_iii:function(e,b,c){try{return a.dynCall_iii(e,b,c)}catch(l){if("number"!==typeof l&&"longjmp"!==l)throw l;a.setThrew(1,0)}},invoke_iiii:function(e,b,c,d){try{return a.dynCall_iiii(e,b,c,d)}catch(E){if("number"!==typeof E&&"longjmp"!==E)throw E;a.setThrew(1,0)}},invoke_iiiiiii:function(e,b,c,d,f,g,h){try{return a.dynCall_iiiiiii(e,b,c,d,f,g,h)}catch(ja){if("number"!== +typeof ja&&"longjmp"!==ja)throw ja;a.setThrew(1,0)}},invoke_v:function(e){try{a.dynCall_v(e)}catch(b){if("number"!==typeof b&&"longjmp"!==b)throw b;a.setThrew(1,0)}},invoke_vi:function(e,b){try{a.dynCall_vi(e,b)}catch(c){if("number"!==typeof c&&"longjmp"!==c)throw c;a.setThrew(1,0)}},invoke_vii:function(e,b,c){try{a.dynCall_vii(e,b,c)}catch(l){if("number"!==typeof l&&"longjmp"!==l)throw l;a.setThrew(1,0)}},invoke_viii:function(e,b,c,d){try{a.dynCall_viii(e,b,c,d)}catch(E){if("number"!==typeof E&& +"longjmp"!==E)throw E;a.setThrew(1,0)}},invoke_viiii:function(e,b,c,d,f){try{a.dynCall_viiii(e,b,c,d,f)}catch(ta){if("number"!==typeof ta&&"longjmp"!==ta)throw ta;a.setThrew(1,0)}},invoke_viiiii:function(e,b,c,d,f,g){try{a.dynCall_viiiii(e,b,c,d,f,g)}catch(ia){if("number"!==typeof ia&&"longjmp"!==ia)throw ia;a.setThrew(1,0)}},invoke_viiiiii:function(e,b,c,d,f,g,h){try{a.dynCall_viiiiii(e,b,c,d,f,g,h)}catch(ja){if("number"!==typeof ja&&"longjmp"!==ja)throw ja;a.setThrew(1,0)}},__ZSt18uncaught_exceptionv:na, +___cxa_allocate_exception:function(a){return Ta(a)},___cxa_begin_catch:function(a){var b=A.infos[a];b&&!b.caught&&(b.caught=!0,na.uncaught_exception--);b&&(b.rethrown=!1);A.caught.push(a);A.addRef(A.deAdjust(a));return a},___cxa_find_matching_catch:qa,___cxa_pure_virtual:function(){ua=!0;throw"Pure virtual function called!";},___cxa_throw:function(a,b,c){A.infos[a]={ptr:a,adjusted:a,type:b,destructor:c,refcount:0,caught:!1,rethrown:!1};A.last=a;"uncaught_exception"in na?na.uncaught_exception++:na.uncaught_exception= +1;throw a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";},___gxx_personality_v0:function(){},___resumeException:function(a){A.last||(A.last=a);throw a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";},___setErrNo:function(e){a.___errno_location&&(x[a.___errno_location()>>2]=e);return e}, +___syscall140:function(a,b){v.varargs=b;try{var c=v.getStreamFromFD();v.get();var e=v.get(),d=v.get(),f=v.get();FS.llseek(c,e,f);x[d>>2]=c.position;c.getdents&&0===e&&0===f&&(c.getdents=null);return 0}catch(ia){return"undefined"!==typeof FS&&ia instanceof FS.ErrnoError||W(ia),-ia.errno}},___syscall146:Q,___syscall54:function(a,b){v.varargs=b;return 0},___syscall6:function(a,b){v.varargs=b;try{var c=v.getStreamFromFD();FS.close(c);return 0}catch(l){return"undefined"!==typeof FS&&l instanceof FS.ErrnoError|| +W(l),-l.errno}},_abort:function(){a.abort()},_emscripten_memcpy_big:function(a,b,c){T.set(T.subarray(b,b+c),a);return a},_pthread_getspecific:function(a){return ya[a]||0},_pthread_key_create:function(a,b){if(0==a)return 22;x[a>>2]=La;ya[La]=0;La++;return 0},_pthread_once:ra,_pthread_setspecific:function(a,b){if(!(a in ya))return 22;ya[a]=b;return 0},DYNAMICTOP_PTR:ba,tempDoublePtr:Eb,ABORT:ua,STACKTOP:U,STACK_MAX:xa};var eb=a.asm(a.asmGlobalArg,a.asmLibraryArg,F);a.asm=eb;a.___cxa_can_catch=function(){return a.asm.___cxa_can_catch.apply(null, +arguments)};a.___cxa_is_pointer_type=function(){return a.asm.___cxa_is_pointer_type.apply(null,arguments)};var pb=a._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0.apply(null,arguments)},Fb=a._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1.apply(null,arguments)}, +Gb=a._emscripten_bind_AttributeOctahedronTransform___destroy___0=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform___destroy___0.apply(null,arguments)},Hb=a._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0.apply(null,arguments)},sb=a._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0.apply(null, +arguments)},Ib=a._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1.apply(null,arguments)},Jb=a._emscripten_bind_AttributeQuantizationTransform___destroy___0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform___destroy___0.apply(null,arguments)},Kb=a._emscripten_bind_AttributeQuantizationTransform_min_value_1=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_min_value_1.apply(null, +arguments)},Lb=a._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0.apply(null,arguments)},Mb=a._emscripten_bind_AttributeQuantizationTransform_range_0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_range_0.apply(null,arguments)},rb=a._emscripten_bind_AttributeTransformData_AttributeTransformData_0=function(){return a.asm._emscripten_bind_AttributeTransformData_AttributeTransformData_0.apply(null, +arguments)},Nb=a._emscripten_bind_AttributeTransformData___destroy___0=function(){return a.asm._emscripten_bind_AttributeTransformData___destroy___0.apply(null,arguments)},Ob=a._emscripten_bind_AttributeTransformData_transform_type_0=function(){return a.asm._emscripten_bind_AttributeTransformData_transform_type_0.apply(null,arguments)},yb=a._emscripten_bind_DecoderBuffer_DecoderBuffer_0=function(){return a.asm._emscripten_bind_DecoderBuffer_DecoderBuffer_0.apply(null,arguments)},Pb=a._emscripten_bind_DecoderBuffer_Init_2= +function(){return a.asm._emscripten_bind_DecoderBuffer_Init_2.apply(null,arguments)},Qb=a._emscripten_bind_DecoderBuffer___destroy___0=function(){return a.asm._emscripten_bind_DecoderBuffer___destroy___0.apply(null,arguments)},Rb=a._emscripten_bind_Decoder_DecodeBufferToMesh_2=function(){return a.asm._emscripten_bind_Decoder_DecodeBufferToMesh_2.apply(null,arguments)},Sb=a._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=function(){return a.asm._emscripten_bind_Decoder_DecodeBufferToPointCloud_2.apply(null, +arguments)},zb=a._emscripten_bind_Decoder_Decoder_0=function(){return a.asm._emscripten_bind_Decoder_Decoder_0.apply(null,arguments)},Tb=a._emscripten_bind_Decoder_GetAttributeByUniqueId_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeByUniqueId_2.apply(null,arguments)},Ub=a._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3.apply(null,arguments)},Vb=a._emscripten_bind_Decoder_GetAttributeFloat_3= +function(){return a.asm._emscripten_bind_Decoder_GetAttributeFloat_3.apply(null,arguments)},Wb=a._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3.apply(null,arguments)},Xb=a._emscripten_bind_Decoder_GetAttributeIdByName_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeIdByName_2.apply(null,arguments)},Yb=a._emscripten_bind_Decoder_GetAttributeId_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeId_2.apply(null, +arguments)},Zb=a._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3.apply(null,arguments)},$b=a._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3.apply(null,arguments)},ac=a._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3.apply(null,arguments)}, +bc=a._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3.apply(null,arguments)},cc=a._emscripten_bind_Decoder_GetAttributeMetadata_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeMetadata_2.apply(null,arguments)},dc=a._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3.apply(null,arguments)},ec=a._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3= +function(){return a.asm._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3.apply(null,arguments)},fc=a._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3.apply(null,arguments)},gc=a._emscripten_bind_Decoder_GetAttribute_2=function(){return a.asm._emscripten_bind_Decoder_GetAttribute_2.apply(null,arguments)},hc=a._emscripten_bind_Decoder_GetEncodedGeometryType_1=function(){return a.asm._emscripten_bind_Decoder_GetEncodedGeometryType_1.apply(null, +arguments)},ic=a._emscripten_bind_Decoder_GetFaceFromMesh_3=function(){return a.asm._emscripten_bind_Decoder_GetFaceFromMesh_3.apply(null,arguments)},jc=a._emscripten_bind_Decoder_GetMetadata_1=function(){return a.asm._emscripten_bind_Decoder_GetMetadata_1.apply(null,arguments)},kc=a._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=function(){return a.asm._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2.apply(null,arguments)},lc=a._emscripten_bind_Decoder_SkipAttributeTransform_1=function(){return a.asm._emscripten_bind_Decoder_SkipAttributeTransform_1.apply(null, +arguments)},mc=a._emscripten_bind_Decoder___destroy___0=function(){return a.asm._emscripten_bind_Decoder___destroy___0.apply(null,arguments)},wb=a._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=function(){return a.asm._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0.apply(null,arguments)},nc=a._emscripten_bind_DracoFloat32Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoFloat32Array_GetValue_1.apply(null,arguments)},oc=a._emscripten_bind_DracoFloat32Array___destroy___0= +function(){return a.asm._emscripten_bind_DracoFloat32Array___destroy___0.apply(null,arguments)},pc=a._emscripten_bind_DracoFloat32Array_size_0=function(){return a.asm._emscripten_bind_DracoFloat32Array_size_0.apply(null,arguments)},vb=a._emscripten_bind_DracoInt16Array_DracoInt16Array_0=function(){return a.asm._emscripten_bind_DracoInt16Array_DracoInt16Array_0.apply(null,arguments)},qc=a._emscripten_bind_DracoInt16Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoInt16Array_GetValue_1.apply(null, +arguments)},rc=a._emscripten_bind_DracoInt16Array___destroy___0=function(){return a.asm._emscripten_bind_DracoInt16Array___destroy___0.apply(null,arguments)},sc=a._emscripten_bind_DracoInt16Array_size_0=function(){return a.asm._emscripten_bind_DracoInt16Array_size_0.apply(null,arguments)},Bb=a._emscripten_bind_DracoInt32Array_DracoInt32Array_0=function(){return a.asm._emscripten_bind_DracoInt32Array_DracoInt32Array_0.apply(null,arguments)},tc=a._emscripten_bind_DracoInt32Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoInt32Array_GetValue_1.apply(null, +arguments)},uc=a._emscripten_bind_DracoInt32Array___destroy___0=function(){return a.asm._emscripten_bind_DracoInt32Array___destroy___0.apply(null,arguments)},vc=a._emscripten_bind_DracoInt32Array_size_0=function(){return a.asm._emscripten_bind_DracoInt32Array_size_0.apply(null,arguments)},tb=a._emscripten_bind_DracoInt8Array_DracoInt8Array_0=function(){return a.asm._emscripten_bind_DracoInt8Array_DracoInt8Array_0.apply(null,arguments)},wc=a._emscripten_bind_DracoInt8Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoInt8Array_GetValue_1.apply(null, +arguments)},xc=a._emscripten_bind_DracoInt8Array___destroy___0=function(){return a.asm._emscripten_bind_DracoInt8Array___destroy___0.apply(null,arguments)},yc=a._emscripten_bind_DracoInt8Array_size_0=function(){return a.asm._emscripten_bind_DracoInt8Array_size_0.apply(null,arguments)},lb=a._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=function(){return a.asm._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0.apply(null,arguments)},zc=a._emscripten_bind_DracoUInt16Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoUInt16Array_GetValue_1.apply(null, +arguments)},Ac=a._emscripten_bind_DracoUInt16Array___destroy___0=function(){return a.asm._emscripten_bind_DracoUInt16Array___destroy___0.apply(null,arguments)},Bc=a._emscripten_bind_DracoUInt16Array_size_0=function(){return a.asm._emscripten_bind_DracoUInt16Array_size_0.apply(null,arguments)},ob=a._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=function(){return a.asm._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0.apply(null,arguments)},Cc=a._emscripten_bind_DracoUInt32Array_GetValue_1= +function(){return a.asm._emscripten_bind_DracoUInt32Array_GetValue_1.apply(null,arguments)},Dc=a._emscripten_bind_DracoUInt32Array___destroy___0=function(){return a.asm._emscripten_bind_DracoUInt32Array___destroy___0.apply(null,arguments)},Ec=a._emscripten_bind_DracoUInt32Array_size_0=function(){return a.asm._emscripten_bind_DracoUInt32Array_size_0.apply(null,arguments)},nb=a._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=function(){return a.asm._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0.apply(null, +arguments)},Fc=a._emscripten_bind_DracoUInt8Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoUInt8Array_GetValue_1.apply(null,arguments)},Gc=a._emscripten_bind_DracoUInt8Array___destroy___0=function(){return a.asm._emscripten_bind_DracoUInt8Array___destroy___0.apply(null,arguments)},Hc=a._emscripten_bind_DracoUInt8Array_size_0=function(){return a.asm._emscripten_bind_DracoUInt8Array_size_0.apply(null,arguments)},xb=a._emscripten_bind_GeometryAttribute_GeometryAttribute_0=function(){return a.asm._emscripten_bind_GeometryAttribute_GeometryAttribute_0.apply(null, +arguments)},Ic=a._emscripten_bind_GeometryAttribute___destroy___0=function(){return a.asm._emscripten_bind_GeometryAttribute___destroy___0.apply(null,arguments)},Ab=a._emscripten_bind_Mesh_Mesh_0=function(){return a.asm._emscripten_bind_Mesh_Mesh_0.apply(null,arguments)},Jc=a._emscripten_bind_Mesh___destroy___0=function(){return a.asm._emscripten_bind_Mesh___destroy___0.apply(null,arguments)},Kc=a._emscripten_bind_Mesh_num_attributes_0=function(){return a.asm._emscripten_bind_Mesh_num_attributes_0.apply(null, +arguments)},Lc=a._emscripten_bind_Mesh_num_faces_0=function(){return a.asm._emscripten_bind_Mesh_num_faces_0.apply(null,arguments)},Mc=a._emscripten_bind_Mesh_num_points_0=function(){return a.asm._emscripten_bind_Mesh_num_points_0.apply(null,arguments)},Nc=a._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetDoubleEntry_2.apply(null,arguments)},Oc=a._emscripten_bind_MetadataQuerier_GetEntryName_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetEntryName_2.apply(null, +arguments)},Pc=a._emscripten_bind_MetadataQuerier_GetIntEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetIntEntry_2.apply(null,arguments)},Qc=a._emscripten_bind_MetadataQuerier_GetStringEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetStringEntry_2.apply(null,arguments)},Rc=a._emscripten_bind_MetadataQuerier_HasDoubleEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_HasDoubleEntry_2.apply(null,arguments)},Sc=a._emscripten_bind_MetadataQuerier_HasEntry_2= +function(){return a.asm._emscripten_bind_MetadataQuerier_HasEntry_2.apply(null,arguments)},Tc=a._emscripten_bind_MetadataQuerier_HasIntEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_HasIntEntry_2.apply(null,arguments)},Uc=a._emscripten_bind_MetadataQuerier_HasStringEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_HasStringEntry_2.apply(null,arguments)},ub=a._emscripten_bind_MetadataQuerier_MetadataQuerier_0=function(){return a.asm._emscripten_bind_MetadataQuerier_MetadataQuerier_0.apply(null, +arguments)},Vc=a._emscripten_bind_MetadataQuerier_NumEntries_1=function(){return a.asm._emscripten_bind_MetadataQuerier_NumEntries_1.apply(null,arguments)},Wc=a._emscripten_bind_MetadataQuerier___destroy___0=function(){return a.asm._emscripten_bind_MetadataQuerier___destroy___0.apply(null,arguments)},Cb=a._emscripten_bind_Metadata_Metadata_0=function(){return a.asm._emscripten_bind_Metadata_Metadata_0.apply(null,arguments)},Xc=a._emscripten_bind_Metadata___destroy___0=function(){return a.asm._emscripten_bind_Metadata___destroy___0.apply(null, +arguments)},Yc=a._emscripten_bind_PointAttribute_GetAttributeTransformData_0=function(){return a.asm._emscripten_bind_PointAttribute_GetAttributeTransformData_0.apply(null,arguments)},qb=a._emscripten_bind_PointAttribute_PointAttribute_0=function(){return a.asm._emscripten_bind_PointAttribute_PointAttribute_0.apply(null,arguments)},Zc=a._emscripten_bind_PointAttribute___destroy___0=function(){return a.asm._emscripten_bind_PointAttribute___destroy___0.apply(null,arguments)},$c=a._emscripten_bind_PointAttribute_attribute_type_0= +function(){return a.asm._emscripten_bind_PointAttribute_attribute_type_0.apply(null,arguments)},ad=a._emscripten_bind_PointAttribute_byte_offset_0=function(){return a.asm._emscripten_bind_PointAttribute_byte_offset_0.apply(null,arguments)},bd=a._emscripten_bind_PointAttribute_byte_stride_0=function(){return a.asm._emscripten_bind_PointAttribute_byte_stride_0.apply(null,arguments)},cd=a._emscripten_bind_PointAttribute_data_type_0=function(){return a.asm._emscripten_bind_PointAttribute_data_type_0.apply(null, +arguments)},dd=a._emscripten_bind_PointAttribute_normalized_0=function(){return a.asm._emscripten_bind_PointAttribute_normalized_0.apply(null,arguments)},ed=a._emscripten_bind_PointAttribute_num_components_0=function(){return a.asm._emscripten_bind_PointAttribute_num_components_0.apply(null,arguments)},fd=a._emscripten_bind_PointAttribute_size_0=function(){return a.asm._emscripten_bind_PointAttribute_size_0.apply(null,arguments)},gd=a._emscripten_bind_PointAttribute_unique_id_0=function(){return a.asm._emscripten_bind_PointAttribute_unique_id_0.apply(null, +arguments)},mb=a._emscripten_bind_PointCloud_PointCloud_0=function(){return a.asm._emscripten_bind_PointCloud_PointCloud_0.apply(null,arguments)},hd=a._emscripten_bind_PointCloud___destroy___0=function(){return a.asm._emscripten_bind_PointCloud___destroy___0.apply(null,arguments)},id=a._emscripten_bind_PointCloud_num_attributes_0=function(){return a.asm._emscripten_bind_PointCloud_num_attributes_0.apply(null,arguments)},jd=a._emscripten_bind_PointCloud_num_points_0=function(){return a.asm._emscripten_bind_PointCloud_num_points_0.apply(null, +arguments)},kd=a._emscripten_bind_Status___destroy___0=function(){return a.asm._emscripten_bind_Status___destroy___0.apply(null,arguments)},ld=a._emscripten_bind_Status_code_0=function(){return a.asm._emscripten_bind_Status_code_0.apply(null,arguments)},md=a._emscripten_bind_Status_error_msg_0=function(){return a.asm._emscripten_bind_Status_error_msg_0.apply(null,arguments)},nd=a._emscripten_bind_Status_ok_0=function(){return a.asm._emscripten_bind_Status_ok_0.apply(null,arguments)},od=a._emscripten_bind_VoidPtr___destroy___0= +function(){return a.asm._emscripten_bind_VoidPtr___destroy___0.apply(null,arguments)},pd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM.apply(null,arguments)},qd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM.apply(null,arguments)},rd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM= +function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM.apply(null,arguments)},sd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM.apply(null,arguments)},td=a._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=function(){return a.asm._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE.apply(null, +arguments)},ud=a._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=function(){return a.asm._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD.apply(null,arguments)},vd=a._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=function(){return a.asm._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH.apply(null,arguments)},wd=a._emscripten_enum_draco_GeometryAttribute_Type_COLOR=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_COLOR.apply(null,arguments)},xd= +a._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_GENERIC.apply(null,arguments)},yd=a._emscripten_enum_draco_GeometryAttribute_Type_INVALID=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_INVALID.apply(null,arguments)},zd=a._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_NORMAL.apply(null,arguments)},Ad=a._emscripten_enum_draco_GeometryAttribute_Type_POSITION= +function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_POSITION.apply(null,arguments)},Bd=a._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD.apply(null,arguments)},Cd=a._emscripten_enum_draco_StatusCode_ERROR=function(){return a.asm._emscripten_enum_draco_StatusCode_ERROR.apply(null,arguments)},Dd=a._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=function(){return a.asm._emscripten_enum_draco_StatusCode_INVALID_PARAMETER.apply(null, +arguments)},Ed=a._emscripten_enum_draco_StatusCode_IO_ERROR=function(){return a.asm._emscripten_enum_draco_StatusCode_IO_ERROR.apply(null,arguments)},Fd=a._emscripten_enum_draco_StatusCode_OK=function(){return a.asm._emscripten_enum_draco_StatusCode_OK.apply(null,arguments)},Gd=a._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=function(){return a.asm._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION.apply(null,arguments)},Hd=a._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=function(){return a.asm._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION.apply(null, +arguments)};a._emscripten_get_global_libc=function(){return a.asm._emscripten_get_global_libc.apply(null,arguments)};var Db=a._emscripten_replace_memory=function(){return a.asm._emscripten_replace_memory.apply(null,arguments)};a._free=function(){return a.asm._free.apply(null,arguments)};a._llvm_bswap_i32=function(){return a.asm._llvm_bswap_i32.apply(null,arguments)};var Ta=a._malloc=function(){return a.asm._malloc.apply(null,arguments)};a._memcpy=function(){return a.asm._memcpy.apply(null,arguments)}; +a._memmove=function(){return a.asm._memmove.apply(null,arguments)};a._memset=function(){return a.asm._memset.apply(null,arguments)};a._sbrk=function(){return a.asm._sbrk.apply(null,arguments)};a.establishStackSpace=function(){return a.asm.establishStackSpace.apply(null,arguments)};a.getTempRet0=function(){return a.asm.getTempRet0.apply(null,arguments)};a.runPostSets=function(){return a.asm.runPostSets.apply(null,arguments)};a.setTempRet0=function(){return a.asm.setTempRet0.apply(null,arguments)}; +a.setThrew=function(){return a.asm.setThrew.apply(null,arguments)};a.stackAlloc=function(){return a.asm.stackAlloc.apply(null,arguments)};a.stackRestore=function(){return a.asm.stackRestore.apply(null,arguments)};a.stackSave=function(){return a.asm.stackSave.apply(null,arguments)};a.dynCall_ii=function(){return a.asm.dynCall_ii.apply(null,arguments)};a.dynCall_iii=function(){return a.asm.dynCall_iii.apply(null,arguments)};a.dynCall_iiii=function(){return a.asm.dynCall_iiii.apply(null,arguments)}; +a.dynCall_iiiiiii=function(){return a.asm.dynCall_iiiiiii.apply(null,arguments)};a.dynCall_v=function(){return a.asm.dynCall_v.apply(null,arguments)};a.dynCall_vi=function(){return a.asm.dynCall_vi.apply(null,arguments)};a.dynCall_vii=function(){return a.asm.dynCall_vii.apply(null,arguments)};a.dynCall_viii=function(){return a.asm.dynCall_viii.apply(null,arguments)};a.dynCall_viiii=function(){return a.asm.dynCall_viiii.apply(null,arguments)};a.dynCall_viiiii=function(){return a.asm.dynCall_viiiii.apply(null, +arguments)};a.dynCall_viiiiii=function(){return a.asm.dynCall_viiiiii.apply(null,arguments)};m.stackAlloc=a.stackAlloc;m.stackSave=a.stackSave;m.stackRestore=a.stackRestore;m.establishStackSpace=a.establishStackSpace;m.setTempRet0=a.setTempRet0;m.getTempRet0=a.getTempRet0;a.asm=eb;if(V)if("function"===typeof a.locateFile?V=a.locateFile(V):a.memoryInitializerPrefixURL&&(V=a.memoryInitializerPrefixURL+V),pa||wa){var Id=a.readBinary(V);T.set(Id,m.GLOBAL_BASE)}else{var gb=function(){a.readAsync(V,fb, +function(){throw"could not load memory initializer "+V;})};la("memory initializer");var fb=function(d){d.byteLength&&(d=new Uint8Array(d));T.set(d,m.GLOBAL_BASE);a.memoryInitializerRequest&&delete a.memoryInitializerRequest.response;Na("memory initializer")};if(a.memoryInitializerRequest){var hb=function(){var d=a.memoryInitializerRequest,b=d.response;200!==d.status&&0!==d.status?(console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+d.status+", retrying "+ +V),gb()):fb(b)};a.memoryInitializerRequest.response?setTimeout(hb,0):a.memoryInitializerRequest.addEventListener("load",hb)}else gb()}a.then=function(d){if(a.calledRun)d(a);else{var b=a.onRuntimeInitialized;a.onRuntimeInitialized=function(){b&&b();d(a)}}return a};ea.prototype=Error();ea.prototype.constructor=ea;var Za=null;sa=function b(){a.calledRun||Da();a.calledRun||(sa=b)};a.run=Da;a.exit=function(b,c){if(!c||!a.noExitRuntime){if(!a.noExitRuntime&&(ua=!0,U=void 0,u(db),a.onExit))a.onExit(b);pa&& +process.exit(b);a.quit(b,new ea(b))}};var ab=[];a.abort=W;if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0=k.size?(f(0>=1;break;case 4:d>>=2;break;case 8:d>>=3}for(var b=0;b3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",(function(reason,p){process["exit"](1)}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}Module["print"]=typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null;Module["printErr"]=typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||Module["print"];Module.print=Module["print"];Module.printErr=Module["printErr"];for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){assert(!staticSealed);var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){assert(DYNAMICTOP_PTR);var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;Module.printErr(text)}}var jsCallStartIndex=1;var functionPointers=new Array(0);var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var GLOBAL_BASE=8;var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){stackSave()}),"stackRestore":(function(){stackRestore()}),"arrayToC":(function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var ALLOC_STATIC=2;var ALLOC_NONE=4;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[typeof _malloc==="function"?_malloc:staticAlloc,stackAlloc,staticAlloc,dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{if(ArrayBuffer.transfer){ret=ArrayBuffer.transfer(buffer,size)}else{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_round=Math.round;var Math_min=Math.min;var Math_max=Math.max;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+13472;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,PA4AAIQOAAAYAAAAAAAAABQOAACrDgAAPA4AAMgOAAAYAAAAAAAAADwOAADxDgAAQAAAAAAAAAAUDgAADQ8AABQOAAAyDwAAPA4AAFcPAAAwAAAAAAAAADwOAAB4GQAASAAAAA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GUgaGFuZGxlAFJlbW90ZSBJL08gZXJyb3IAUXVvdGEgZXhjZWVkZWQATm8gbWVkaXVtIGZvdW5kAFdyb25nIG1lZGl1bSB0eXBlAE5vIGVycm9yIGluZm9ybWF0aW9uAAAlZAB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzOiAlcwB0ZXJtaW5hdGluZyB3aXRoICVzIGV4Y2VwdGlvbiBvZiB0eXBlICVzAHRlcm1pbmF0aW5nIHdpdGggJXMgZm9yZWlnbiBleGNlcHRpb24AdGVybWluYXRpbmcAdW5jYXVnaHQAU3Q5ZXhjZXB0aW9uAE4xMF9fY3h4YWJpdjExNl9fc2hpbV90eXBlX2luZm9FAFN0OXR5cGVfaW5mbwBOMTBfX2N4eGFiaXYxMjBfX3NpX2NsYXNzX3R5cGVfaW5mb0UATjEwX19jeHhhYml2MTE3X19jbGFzc190eXBlX2luZm9FAHB0aHJlYWRfb25jZSBmYWlsdXJlIGluIF9fY3hhX2dldF9nbG9iYWxzX2Zhc3QoKQBjYW5ub3QgY3JlYXRlIHB0aHJlYWQga2V5IGZvciBfX2N4YV9nZXRfZ2xvYmFscygpAGNhbm5vdCB6ZXJvIG91dCB0aHJlYWQgdmFsdWUgZm9yIF9fY3hhX2dldF9nbG9iYWxzKCkAdGVybWluYXRlX2hhbmRsZXIgdW5leHBlY3RlZGx5IHJldHVybmVkAFN0MTFsb2dpY19lcnJvcgBTdDEybGVuZ3RoX2Vycm9yAE4xMF9fY3h4YWJpdjExOV9fcG9pbnRlcl90eXBlX2luZm9FAE4xMF9fY3h4YWJpdjExN19fcGJhc2VfdHlwZV9pbmZvRQ==";var tempDoublePtr=STATICTOP;STATICTOP+=16;function ___cxa_allocate_exception(size){return _malloc(size)}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0&&!info.rethrown){if(info.destructor){Module["dynCall_vi"](info.destructor,ptr)}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___cxa_begin_catch(ptr){var info=EXCEPTIONS.infos[ptr];if(info&&!info.caught){info.caught=true;__ZSt18uncaught_exceptionv.uncaught_exception--}if(info)info.rethrown=false;EXCEPTIONS.caught.push(ptr);EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));return ptr}function ___cxa_pure_virtual(){ABORT=true;throw"Pure virtual function called!"}function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(setTempRet0(0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(setTempRet0(0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(setTempRet0(typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(setTempRet0(throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC);function ___gxx_personality_v0(){}var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function flush_NO_FILESYSTEM(){var fflush=Module["_fflush"];if(fflush)fflush(0);var printChar=___syscall146.printChar;if(!printChar)return;var buffers=___syscall146.buffers;if(buffers[1].length)printChar(1,10);if(buffers[2].length)printChar(2,10)}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffers){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=PTHREAD_SPECIFIC_NEXT_KEY;PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0;PTHREAD_SPECIFIC_NEXT_KEY++;return 0}function _pthread_once(ptr,func){if(!_pthread_once.seen)_pthread_once.seen={};if(ptr in _pthread_once.seen)return;Module["dynCall_v"](func);_pthread_once.seen[ptr]=1}function _pthread_setspecific(key,value){if(!(key in PTHREAD_SPECIFIC)){return ERRNO_CODES.EINVAL}PTHREAD_SPECIFIC[key]=value;return 0}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i2147483648)return false;b=new a(newBuffer);d=new c(newBuffer);f=new e(newBuffer);h=new g(newBuffer);j=new i(newBuffer);l=new k(newBuffer);n=new m(newBuffer);p=new o(newBuffer);buffer=newBuffer;return true} +// EMSCRIPTEN_START_FUNCS +function Ib(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;if((b|0)<0)return;c=a+12|0;d=f[c>>2]|0;e=f[a+8>>2]|0;g=e;h=d;if(d-e>>2>>>0<=b>>>0)return;e=g+(b<<2)|0;d=f[(f[e>>2]|0)+56>>2]|0;i=f[(f[g+(b<<2)>>2]|0)+60>>2]|0;g=e+4|0;if((g|0)!=(h|0)){j=g;g=e;do{k=f[j>>2]|0;f[j>>2]=0;l=f[g>>2]|0;f[g>>2]=k;if(l|0){k=l+88|0;m=f[k>>2]|0;f[k>>2]=0;if(m|0){k=f[m+8>>2]|0;if(k|0){n=m+12|0;if((f[n>>2]|0)!=(k|0))f[n>>2]=k;dn(k)}dn(m)}m=f[l+68>>2]|0;if(m|0){k=l+72|0;n=f[k>>2]|0;if((n|0)!=(m|0))f[k>>2]=n+(~((n+-4-m|0)>>>2)<<2);dn(m)}m=l+64|0;n=f[m>>2]|0;f[m>>2]=0;if(n|0){m=f[n>>2]|0;if(m|0){k=n+4|0;if((f[k>>2]|0)!=(m|0))f[k>>2]=m;dn(m)}dn(n)}dn(l)}j=j+4|0;g=g+4|0}while((j|0)!=(h|0));j=f[c>>2]|0;if((j|0)!=(g|0)){o=g;p=j;q=24}}else{o=e;p=h;q=24}if((q|0)==24){q=p;do{p=q+-4|0;f[c>>2]=p;h=f[p>>2]|0;f[p>>2]=0;if(h|0){p=h+88|0;e=f[p>>2]|0;f[p>>2]=0;if(e|0){p=f[e+8>>2]|0;if(p|0){j=e+12|0;if((f[j>>2]|0)!=(p|0))f[j>>2]=p;dn(p)}dn(e)}e=f[h+68>>2]|0;if(e|0){p=h+72|0;j=f[p>>2]|0;if((j|0)!=(e|0))f[p>>2]=j+(~((j+-4-e|0)>>>2)<<2);dn(e)}e=h+64|0;j=f[e>>2]|0;f[e>>2]=0;if(j|0){e=f[j>>2]|0;if(e|0){p=j+4|0;if((f[p>>2]|0)!=(e|0))f[p>>2]=e;dn(e)}dn(j)}dn(h)}q=f[c>>2]|0}while((q|0)!=(o|0))}o=f[a+4>>2]|0;a:do if(o|0){q=o+44|0;c=f[q>>2]|0;h=f[o+40>>2]|0;while(1){if((h|0)==(c|0))break a;r=h+4|0;if((f[(f[h>>2]|0)+40>>2]|0)==(i|0))break;else h=r}if((r|0)!=(c|0)){j=r;e=h;do{p=f[j>>2]|0;f[j>>2]=0;g=f[e>>2]|0;f[e>>2]=p;if(g|0){Cf(g);dn(g)}j=j+4|0;e=e+4|0}while((j|0)!=(c|0));j=f[q>>2]|0;if((j|0)==(e|0))break;else{s=e;t=j}}else{s=h;t=c}j=t;do{g=j+-4|0;f[q>>2]=g;p=f[g>>2]|0;f[g>>2]=0;if(p|0){Cf(p);dn(p)}j=f[q>>2]|0}while((j|0)!=(s|0))}while(0);b:do if((d|0)<5){s=f[a+20+(d*12|0)>>2]|0;t=a+20+(d*12|0)+4|0;r=f[t>>2]|0;i=r;c:do if((s|0)==(r|0))u=s;else{o=s;while(1){if((f[o>>2]|0)==(b|0)){u=o;break c}o=o+4|0;if((o|0)==(r|0))break b}}while(0);if((u|0)!=(r|0)){s=u+4|0;o=i-s|0;j=o>>2;if(!j)v=r;else{qi(u|0,s|0,o|0)|0;v=f[t>>2]|0}o=u+(j<<2)|0;if((v|0)!=(o|0))f[t>>2]=v+(~((v+-4-o|0)>>>2)<<2)}}while(0);v=f[a+24>>2]|0;u=f[a+20>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+36>>2]|0;u=f[a+32>>2]|0;d=u;if((o|0)!=(u|0)){j=o-u>>2;u=0;do{o=d+(u<<2)|0;v=f[o>>2]|0;if((v|0)>(b|0))f[o>>2]=v+-1;u=u+1|0}while(u>>>0>>0)}j=f[a+48>>2]|0;u=f[a+44>>2]|0;d=u;if((j|0)!=(u|0)){v=j-u>>2;u=0;do{j=d+(u<<2)|0;o=f[j>>2]|0;if((o|0)>(b|0))f[j>>2]=o+-1;u=u+1|0}while(u>>>0>>0)}v=f[a+60>>2]|0;u=f[a+56>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}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=(a|0)<(l|0)?l:a;T=E}E=F+1|0;U=f[t>>2]|0;if((E|0)>=(U|0))break;F=E;a=f[i+(E<<2)>>2]|0}if((U|0)>0){a=0;do{F=(f[C+(a<<2)>>2]|0)+(f[T+(a<<2)>>2]|0)|0;E=D+(a<<2)|0;f[E>>2]=F;if((F|0)<=(f[v>>2]|0)){if((F|0)<(f[x>>2]|0)){V=(f[y>>2]|0)+F|0;W=44}}else{V=F-(f[y>>2]|0)|0;W=44}if((W|0)==44){W=0;f[E>>2]=V}a=a+1|0}while((a|0)<(f[t>>2]|0))}}A=A+1|0;if((A|0)>=(n|0)){W=3;break}a=f[g>>2]|0;B=f[a>>2]|0;if((f[a+4>>2]|0)-B>>2>>>0<=A>>>0){z=a;W=4;break}}if((W|0)==3){u=e;return 1}else if((W|0)==4)um(z);return 0}function Kb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0;e=u;u=u+32|0;d=e+28|0;h=e+16|0;i=e+8|0;j=e;k=a+60|0;f[a+68>>2]=g;g=a+56|0;l=f[g>>2]|0;m=(f[l+4>>2]|0)-(f[l>>2]|0)|0;n=m>>2;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;if((m|0)<=0){u=e;return 1}m=h+4|0;o=h+8|0;p=a+104|0;q=a+108|0;r=i+4|0;s=a+100|0;t=a+8|0;v=a+16|0;w=a+32|0;x=a+12|0;y=a+20|0;a=f[l>>2]|0;if((f[l+4>>2]|0)==(a|0)){z=l;um(z)}else{A=0;B=a}while(1){f[j>>2]=f[B+(A<<2)>>2];f[d>>2]=f[j>>2];vb(k,d,h);a=f[h>>2]|0;l=(a|0)>-1?a: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<1)-Q|0;S=P;break}if(C){a=f[p>>2]|0;R=(a|0)<(Q|0)?(a<<1)-Q|0:Q;S=0}else{R=Q;S=P}}else{R=Q;S=Q}}else{R=P;S=P}}else{R=F;S=F}while(0);f[i>>2]=R;f[r>>2]=S;F=A<<1;C=b+(F<<2)|0;D=c+(F<<2)|0;if((f[t>>2]|0)>0){F=0;a=R;while(1){E=f[v>>2]|0;if((a|0)>(E|0)){l=f[w>>2]|0;f[l+(F<<2)>>2]=E;T=l}else{l=f[x>>2]|0;E=f[w>>2]|0;f[E+(F<<2)>>2]=(a|0)<(l|0)?l:a;T=E}E=F+1|0;U=f[t>>2]|0;if((E|0)>=(U|0))break;F=E;a=f[i+(E<<2)>>2]|0}if((U|0)>0){a=0;do{F=(f[C+(a<<2)>>2]|0)+(f[T+(a<<2)>>2]|0)|0;E=D+(a<<2)|0;f[E>>2]=F;if((F|0)<=(f[v>>2]|0)){if((F|0)<(f[x>>2]|0)){V=(f[y>>2]|0)+F|0;W=44}}else{V=F-(f[y>>2]|0)|0;W=44}if((W|0)==44){W=0;f[E>>2]=V}a=a+1|0}while((a|0)<(f[t>>2]|0))}}A=A+1|0;if((A|0)>=(n|0)){W=3;break}a=f[g>>2]|0;B=f[a>>2]|0;if((f[a+4>>2]|0)-B>>2>>>0<=A>>>0){z=a;W=4;break}}if((W|0)==3){u=e;return 1}else if((W|0)==4)um(z);return 0}function Lb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;e=u;u=u+16|0;g=e+8|0;h=e+4|0;i=e;j=a+64|0;k=f[j>>2]|0;if((f[k+28>>2]|0)==(f[k+24>>2]|0)){u=e;return}l=c+96|0;c=a+52|0;m=d+84|0;n=d+68|0;d=a+56|0;o=a+60|0;p=a+12|0;q=a+28|0;r=a+40|0;s=a+44|0;t=a+48|0;v=0;w=0;x=k;while(1){k=f[(f[x+24>>2]|0)+(w<<2)>>2]|0;if((k|0)==-1){y=v;z=x}else{A=v+1|0;B=f[(f[l>>2]|0)+(((k|0)/3|0)*12|0)+(((k|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))C=f[(f[n>>2]|0)+(B<<2)>>2]|0;else C=B;f[g>>2]=C;B=f[d>>2]|0;if(B>>>0<(f[o>>2]|0)>>>0){f[B>>2]=C;f[d>>2]=B+4}else xf(c,g);f[g>>2]=k;f[h>>2]=0;a:do if(!(f[(f[p>>2]|0)+(w>>>5<<2)>>2]&1<<(w&31)))D=k;else{B=k+1|0;E=((B>>>0)%3|0|0)==0?k+-2|0:B;if(((E|0)!=-1?(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)==0:0)?(B=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0,E=B+1|0,(B|0)!=-1):0){F=((E>>>0)%3|0|0)==0?B+-2|0:E;f[h>>2]=F;if((F|0)==-1){D=k;break}else G=F;while(1){f[g>>2]=G;F=G+1|0;E=((F>>>0)%3|0|0)==0?G+-2|0:F;if((E|0)==-1)break;if(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)break;F=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0;E=F+1|0;if((F|0)==-1)break;B=((E>>>0)%3|0|0)==0?F+-2|0:E;f[h>>2]=B;if((B|0)==-1){D=G;break a}else G=B}f[h>>2]=-1;D=G;break}f[h>>2]=-1;D=k}while(0);f[(f[q>>2]|0)+(D<<2)>>2]=v;k=f[s>>2]|0;if((k|0)==(f[t>>2]|0))xf(r,g);else{f[k>>2]=f[g>>2];f[s>>2]=k+4}k=f[j>>2]|0;B=f[g>>2]|0;b:do if(((B|0)!=-1?(E=(((B>>>0)%3|0|0)==0?2:-1)+B|0,(E|0)!=-1):0)?(F=f[(f[k+12>>2]|0)+(E<<2)>>2]|0,(F|0)!=-1):0){E=F+(((F>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=E;if((E|0)!=-1&(E|0)!=(B|0)){F=A;H=v;I=E;while(1){E=I+1|0;J=((E>>>0)%3|0|0)==0?I+-2|0:E;do if(f[(f[a>>2]|0)+(J>>>5<<2)>>2]&1<<(J&31)){E=F+1|0;K=f[(f[l>>2]|0)+(((I|0)/3|0)*12|0)+(((I|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))L=f[(f[n>>2]|0)+(K<<2)>>2]|0;else L=K;f[i>>2]=L;K=f[d>>2]|0;if(K>>>0<(f[o>>2]|0)>>>0){f[K>>2]=L;f[d>>2]=K+4}else xf(c,i);K=f[s>>2]|0;if((K|0)==(f[t>>2]|0)){xf(r,h);M=E;N=F;break}else{f[K>>2]=f[h>>2];f[s>>2]=K+4;M=E;N=F;break}}else{M=F;N=H}while(0);f[(f[q>>2]|0)+(f[h>>2]<<2)>>2]=N;O=f[j>>2]|0;J=f[h>>2]|0;if((J|0)==-1)break;E=(((J>>>0)%3|0|0)==0?2:-1)+J|0;if((E|0)==-1)break;J=f[(f[O+12>>2]|0)+(E<<2)>>2]|0;if((J|0)==-1)break;I=J+(((J>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=I;if(!((I|0)!=-1?(I|0)!=(f[g>>2]|0):0)){P=M;Q=O;break b}else{F=M;H=N}}f[h>>2]=-1;P=M;Q=O}else{P=A;Q=k}}else R=28;while(0);if((R|0)==28){R=0;f[h>>2]=-1;P=A;Q=k}y=P;z=Q}w=w+1|0;if(w>>>0>=(f[z+28>>2]|0)-(f[z+24>>2]|0)>>2>>>0)break;else{v=y;x=z}}u=e;return}function Mb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0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;B=0-(f[o>>2]|0)|0;x=0-(f[q>>2]|0)|0;f[j>>2]=E;f[o>>2]=B;f[q>>2]=x;K=E;L=B}else{K=C;L=f[o>>2]|0}do if((K|0)<=-1){if((L|0)<0){C=f[q>>2]|0;M=(C|0)>-1?C:0-C|0;N=C}else{C=f[q>>2]|0;M=(f[t>>2]|0)-((C|0)>-1?C:0-C|0)|0;N=C}if((N|0)<0){O=(L|0)>-1?L:0-L|0;P=M;break}else{O=(f[t>>2]|0)-((L|0)>-1?L:0-L|0)|0;P=M;break}}else{C=f[r>>2]|0;O=(f[q>>2]|0)+C|0;P=C+L|0}while(0);C=(P|0)==0;B=(O|0)==0;E=f[t>>2]|0;do if(O|P){x=(E|0)==(O|0);if(!(C&x)){D=(E|0)==(P|0);if(!(B&D)){if(C?(n=f[r>>2]|0,(n|0)<(O|0)):0){Q=0;R=(n<<1)-O|0;break}if(D?(D=f[r>>2]|0,(D|0)>(O|0)):0){Q=P;R=(D<<1)-O|0;break}if(x?(x=f[r>>2]|0,(x|0)>(P|0)):0){Q=(x<<1)-P|0;R=O;break}if(B){x=f[r>>2]|0;Q=(x|0)<(P|0)?(x<<1)-P|0:P;R=0}else{Q=P;R=O}}else{Q=P;R=P}}else{Q=O;R=O}}else{Q=E;R=E}while(0);E=z<<1;B=b+(E<<2)|0;C=c+(E<<2)|0;E=f[B>>2]|0;x=f[B+4>>2]|0;f[h>>2]=Q;f[a>>2]=R;f[i>>2]=E;f[v>>2]=x;ec(d,l,h,i);f[C>>2]=f[d>>2];f[C+4>>2]=f[w>>2];z=z+1|0;if((z|0)>=(p|0)){S=5;break}C=f[g>>2]|0;A=f[C>>2]|0;if((f[C+4>>2]|0)-A>>2>>>0<=z>>>0){y=C;S=6;break}}if((S|0)==5){u=e;return 1}else if((S|0)==6)um(y);return 0}function Nb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r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|0;C=f[j>>2]|0;if(E){E=0-C|0;B=0-(f[o>>2]|0)|0;x=0-(f[q>>2]|0)|0;f[j>>2]=E;f[o>>2]=B;f[q>>2]=x;K=E;L=B}else{K=C;L=f[o>>2]|0}do if((K|0)<=-1){if((L|0)<0){C=f[q>>2]|0;M=(C|0)>-1?C:0-C|0;N=C}else{C=f[q>>2]|0;M=(f[t>>2]|0)-((C|0)>-1?C:0-C|0)|0;N=C}if((N|0)<0){O=(L|0)>-1?L:0-L|0;P=M;break}else{O=(f[t>>2]|0)-((L|0)>-1?L:0-L|0)|0;P=M;break}}else{C=f[r>>2]|0;O=(f[q>>2]|0)+C|0;P=C+L|0}while(0);C=(P|0)==0;B=(O|0)==0;E=f[t>>2]|0;do if(O|P){x=(E|0)==(O|0);if(!(C&x)){D=(E|0)==(P|0);if(!(B&D)){if(C?(n=f[r>>2]|0,(n|0)<(O|0)):0){Q=0;R=(n<<1)-O|0;break}if(D?(D=f[r>>2]|0,(D|0)>(O|0)):0){Q=P;R=(D<<1)-O|0;break}if(x?(x=f[r>>2]|0,(x|0)>(P|0)):0){Q=(x<<1)-P|0;R=O;break}if(B){x=f[r>>2]|0;Q=(x|0)<(P|0)?(x<<1)-P|0:P;R=0}else{Q=P;R=O}}else{Q=P;R=P}}else{Q=O;R=O}}else{Q=E;R=E}while(0);E=z<<1;B=b+(E<<2)|0;C=c+(E<<2)|0;E=f[B>>2]|0;x=f[B+4>>2]|0;f[h>>2]=Q;f[a>>2]=R;f[i>>2]=E;f[v>>2]=x;ec(d,l,h,i);f[C>>2]=f[d>>2];f[C+4>>2]=f[w>>2];z=z+1|0;if((z|0)>=(p|0)){S=5;break}C=f[g>>2]|0;A=f[C>>2]|0;if((f[C+4>>2]|0)-A>>2>>>0<=z>>>0){y=C;S=6;break}}if((S|0)==5){u=e;return 1}else if((S|0)==6)um(y);return 0}function Ob(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;d=u;u=u+16|0;e=d+12|0;g=d;h=d+8|0;i=d+4|0;j=a+8+(b*12|0)|0;k=f[j>>2]|0;l=a+8+(b*12|0)+4|0;m=f[l>>2]|0;if((m|0)!=(k|0))f[l>>2]=m+(~((m+-4-k|0)>>>2)<<2);k=f[c>>2]|0;m=a+4|0;f[g>>2]=(k|0)==-1?-1:(k>>>0)/3|0;n=a+56|0;o=a+8+(b*12|0)+8|0;p=0;q=f[g>>2]|0;r=k;while(1){s=(f[n>>2]|0)+(q>>>5<<2)|0;t=1<<(q&31);v=f[s>>2]|0;if(t&v|0)break;f[s>>2]=v|t;t=f[l>>2]|0;if((t|0)==(f[o>>2]|0))xf(j,g);else{f[t>>2]=f[g>>2];f[l>>2]=t+4}t=p+1|0;if((p|0)>0){v=(r|0)==-1;do if(!(t&1))if(!v)if(!((r>>>0)%3|0)){w=r+2|0;break}else{w=r+-1|0;break}else w=-1;else{s=r+1|0;if(v)w=-1;else w=((s>>>0)%3|0|0)==0?r+-2|0:s}while(0);f[c>>2]=w;x=w}else x=r;f[i>>2]=x;f[e>>2]=f[i>>2];v=Od(a,e)|0;f[c>>2]=v;if((v|0)==-1)break;s=(v>>>0)/3|0;f[g>>2]=s;p=t;q=s;r=v}r=(k|0)==-1;do if(!r)if(!((k>>>0)%3|0)){y=k+2|0;break}else{y=k+-1|0;break}else y=-1;while(0);f[h>>2]=y;f[e>>2]=f[h>>2];do if((Od(a,e)|0)==-1)z=k;else{h=k+1|0;if(!r){y=((h>>>0)%3|0|0)==0?k+-2|0:h;f[c>>2]=y;h=f[m>>2]|0;q=y+1|0;if(((y|0)!=-1?(p=((q>>>0)%3|0|0)==0?y+-2|0:q,(p|0)!=-1):0)?(q=f[(f[h+12>>2]|0)+(p<<2)>>2]|0,p=q+1|0,(q|0)!=-1):0){h=((p>>>0)%3|0|0)==0?q+-2|0:p;f[c>>2]=h;if((h|0)==-1){z=k;break}else{A=h;B=0;C=k}while(1){h=(A>>>0)/3|0;f[g>>2]=h;p=(f[n>>2]|0)+(h>>>5<<2)|0;q=1<<(h&31);h=f[p>>2]|0;if(q&h|0){D=B;E=C;break}f[p>>2]=h|q;q=f[l>>2]|0;if((q|0)==(f[o>>2]|0))xf(j,g);else{f[q>>2]=f[g>>2];f[l>>2]=q+4}q=B+1|0;if((B|0)>0){h=(A|0)==-1;do if(!(q&1))if(!h)if(!((A>>>0)%3|0)){F=A+2|0;G=A;break}else{F=A+-1|0;G=A;break}else{F=-1;G=A}else{p=A+1|0;if(h){F=-1;G=C}else{F=((p>>>0)%3|0|0)==0?A+-2|0:p;G=C}}while(0);f[c>>2]=F;H=G;I=F}else{H=C;I=A}f[i>>2]=I;f[e>>2]=f[i>>2];A=Od(a,e)|0;f[c>>2]=A;if((A|0)==-1){D=q;E=H;break}else{B=q;C=H}}if(!(D&1)){z=E;break}t=f[l>>2]|0;h=f[t+-4>>2]|0;p=(f[n>>2]|0)+(h>>>5<<2)|0;f[p>>2]=f[p>>2]&~(1<<(h&31));f[l>>2]=t+-4;z=E;break}else J=k}else{f[c>>2]=-1;J=-1}f[c>>2]=-1;z=J}while(0);f[a+44+(b<<2)>>2]=z;z=f[l>>2]|0;l=f[j>>2]|0;j=l;if((z|0)==(l|0)){u=d;return}b=f[n>>2]|0;n=z-l>>2;l=0;do{z=f[j+(l<<2)>>2]|0;a=b+(z>>>5<<2)|0;f[a>>2]=f[a>>2]&~(1<<(z&31));l=l+1|0}while(l>>>0>>0);u=d;return}function Pb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;c=u;u=u+16|0;b=c+8|0;d=c+4|0;e=c;g=a+64|0;h=f[g>>2]|0;if((f[h+28>>2]|0)==(f[h+24>>2]|0)){u=c;return}i=a+52|0;j=a+56|0;k=a+60|0;l=a+12|0;m=a+28|0;n=a+40|0;o=a+44|0;p=a+48|0;q=0;r=0;s=h;while(1){h=f[(f[s+24>>2]|0)+(r<<2)>>2]|0;if((h|0)==-1){t=q;v=s}else{w=q+1|0;f[b>>2]=q;x=f[j>>2]|0;if((x|0)==(f[k>>2]|0))xf(i,b);else{f[x>>2]=q;f[j>>2]=x+4}f[d>>2]=h;f[e>>2]=0;a:do if(!(f[(f[l>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)))y=h;else{x=h+1|0;z=((x>>>0)%3|0|0)==0?h+-2|0:x;if(((z|0)!=-1?(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)==0:0)?(x=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0,z=x+1|0,(x|0)!=-1):0){A=((z>>>0)%3|0|0)==0?x+-2|0:z;f[e>>2]=A;if((A|0)==-1){y=h;break}else B=A;while(1){f[d>>2]=B;A=B+1|0;z=((A>>>0)%3|0|0)==0?B+-2|0:A;if((z|0)==-1)break;if(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)break;A=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0;z=A+1|0;if((A|0)==-1)break;x=((z>>>0)%3|0|0)==0?A+-2|0:z;f[e>>2]=x;if((x|0)==-1){y=B;break a}else B=x}f[e>>2]=-1;y=B;break}f[e>>2]=-1;y=h}while(0);f[(f[m>>2]|0)+(y<<2)>>2]=f[b>>2];h=f[o>>2]|0;if((h|0)==(f[p>>2]|0))xf(n,d);else{f[h>>2]=f[d>>2];f[o>>2]=h+4}h=f[g>>2]|0;x=f[d>>2]|0;b:do if(((x|0)!=-1?(z=(((x>>>0)%3|0|0)==0?2:-1)+x|0,(z|0)!=-1):0)?(A=f[(f[h+12>>2]|0)+(z<<2)>>2]|0,(A|0)!=-1):0){z=A+(((A>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=z;if((z|0)!=-1&(z|0)!=(x|0)){A=w;C=z;while(1){z=C+1|0;D=((z>>>0)%3|0|0)==0?C+-2|0:z;do if(f[(f[a>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)){z=A+1|0;f[b>>2]=A;E=f[j>>2]|0;if((E|0)==(f[k>>2]|0))xf(i,b);else{f[E>>2]=A;f[j>>2]=E+4}E=f[o>>2]|0;if((E|0)==(f[p>>2]|0)){xf(n,e);F=z;break}else{f[E>>2]=f[e>>2];f[o>>2]=E+4;F=z;break}}else F=A;while(0);f[(f[m>>2]|0)+(f[e>>2]<<2)>>2]=f[b>>2];G=f[g>>2]|0;D=f[e>>2]|0;if((D|0)==-1)break;z=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((z|0)==-1)break;D=f[(f[G+12>>2]|0)+(z<<2)>>2]|0;if((D|0)==-1)break;C=D+(((D>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=C;if(!((C|0)!=-1?(C|0)!=(f[d>>2]|0):0)){H=F;I=G;break b}else A=F}f[e>>2]=-1;H=F;I=G}else{H=w;I=h}}else J=26;while(0);if((J|0)==26){J=0;f[e>>2]=-1;H=w;I=h}t=H;v=I}r=r+1|0;if(r>>>0>=(f[v+28>>2]|0)-(f[v+24>>2]|0)>>2>>>0)break;else{q=t;s=v}}u=c;return}function Qb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;d=u;u=u+80|0;e=d+76|0;g=d;h=d+72|0;i=d+64|0;j=d+68|0;if(!(dg(e,c)|0)){k=0;u=d;return k|0}l=f[e>>2]|0;if(!l){k=0;u=d;return k|0}m=a+4|0;n=a+8|0;o=f[n>>2]|0;p=f[m>>2]|0;q=o-p>>2;r=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(D)}D=f[v+68>>2]|0;if(D|0){y=v+72|0;A=f[y>>2]|0;if((A|0)!=(D|0))f[y>>2]=A+(~((A+-4-D|0)>>>2)<<2);dn(D)}D=v+64|0;A=f[D>>2]|0;f[D>>2]=0;if(A|0){D=f[A>>2]|0;if(D|0){y=A+4|0;if((f[y>>2]|0)!=(D|0))f[y>>2]=D;dn(D)}dn(A)}dn(v)}f[(f[(f[r>>2]|0)+(C<<2)>>2]|0)+60>>2]=f[h>>2];f[(f[m>>2]|0)+(a<<2)>>2]=C;v=f[s>>2]|0;A=f[o>>2]|0;D=v-A>>2;y=A;if((C|0)<(D|0))G=y;else{A=C+1|0;f[j>>2]=-1;B=v;if(A>>>0<=D>>>0)if(A>>>0>>0?(v=y+(A<<2)|0,(v|0)!=(B|0)):0){f[s>>2]=B+(~((B+-4-v|0)>>>2)<<2);H=y}else H=y;else{Ae(o,A-D|0,j);H=f[o>>2]|0}G=H}f[G+(C<<2)>>2]=a;a=a+1|0;if(a>>>0>=(f[e>>2]|0)>>>0){k=1;z=40;break}}if((z|0)==40){u=d;return k|0}return 0}function Rb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)dn(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Yk(e,9789);f[e>>2]=3704;va(e|0,856,80)}e=bj(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)dn(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){o=d;while(1){e=f[o+4>>2]|0;if(!i)if(e>>>0>>0)p=e;else p=(e>>>0)%(c>>>0)|0;else p=e&h;if((p|0)==(k|0))break;q=(f[a>>2]|0)+(p<<2)|0;if(!(f[q>>2]|0))break b;e=f[o>>2]|0;c:do if(!e)r=o;else{s=o+8|0;t=b[s+11>>0]|0;u=t<<24>>24<0;v=t&255;t=u?f[o+12>>2]|0:v;w=(t|0)==0;if(u){u=o;x=e;while(1){y=x+8|0;z=b[y+11>>0]|0;A=z<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:z&255)|0)){r=u;break c}if(!w?jh(f[s>>2]|0,A?f[y>>2]|0:y,t)|0:0){r=u;break c}y=f[x>>2]|0;if(!y){r=x;break c}else{A=x;x=y;u=A}}}if(w){u=o;x=e;while(1){A=b[x+8+11>>0]|0;if((A<<24>>24<0?f[x+12>>2]|0:A&255)|0){r=u;break c}A=f[x>>2]|0;if(!A){r=x;break c}else{y=x;x=A;u=y}}}u=o;x=e;while(1){w=x+8|0;y=b[w+11>>0]|0;A=y<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:y&255)|0)){r=u;break c}y=A?f[w>>2]|0:w;if((b[y>>0]|0)==(f[s>>2]&255)<<24>>24){B=s;C=v;D=y}else{r=u;break c}while(1){C=C+-1|0;B=B+1|0;if(!C)break;D=D+1|0;if((b[B>>0]|0)!=(b[D>>0]|0)){r=u;break c}}y=f[x>>2]|0;if(!y){r=x;break}else{w=x;x=y;u=w}}}while(0);f[j>>2]=f[r>>2];f[r>>2]=f[f[(f[a>>2]|0)+(p<<2)>>2]>>2];f[f[(f[a>>2]|0)+(p<<2)>>2]>>2]=o;e=f[g>>2]|0;if(!e){E=43;break a}else o=e}d=f[o>>2]|0;if(!d){E=43;break a}else{g=o;j=o}}f[q>>2]=j;m=f[o>>2]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if(y>>>0>>0){g=0;return g|0}y=j;C=f[y>>2]|0;B=f[y+4>>2]|0;y=l;z=f[y>>2]|0;x=f[y+4>>2]|0;y=Tj(C|0,B|0,z|0,x|0)|0;A=I;if((A|0)<0|(A|0)==0&y>>>0>>0){g=0;return g|0}if(!i)D=19;else{v=u&255;u=0;y=z;z=x;x=B;B=C;while(1){C=Rj(y|0,z|0,v|0,0)|0;A=I;if((x|0)<(A|0)|(x|0)==(A|0)&B>>>0>>0){E=y;F=z}else{ge(k+(u<<2)|0,(f[d>>2]|0)+y|0,w|0)|0;C=l;A=Rj(f[C>>2]|0,f[C+4>>2]|0,v|0,0)|0;C=I;G=l;f[G>>2]=A;f[G+4>>2]=C;E=A;F=C}C=u+1|0;if((C|0)==(i|0)){D=18;break a}A=j;u=C;y=E;z=F;x=f[A+4>>2]|0;B=f[A>>2]|0}}}else if(Qf(i,e,d,k)|0)D=18;else{g=0;return g|0}while(0);do if((D|0)==18)if(!i)D=19;else{F=a+20|0;E=f[F>>2]|0;if(E|0?Na[f[(f[E>>2]|0)+32>>2]&127](E)|0:0){H=F;J=1;break}ui(k,i,k);H=F;J=1}while(0);if((D|0)==19){H=a+20|0;J=0}a=f[H>>2]|0;if(a|0){if(!(Oa[f[(f[a>>2]|0)+40>>2]&127](a,d)|0)){g=0;return g|0}if(J?(J=f[H>>2]|0,!(Qa[f[(f[J>>2]|0)+44>>2]&15](J,k,k,i,e,f[c>>2]|0)|0)):0){g=0;return g|0}}g=1;return g|0}function Tb(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;i=u;u=u+32|0;j=i+12|0;k=i;f[c+40>>2]=e;e=c+32|0;f[e>>2]=g;f[c+4>>2]=h;Hb(a,g,j);if(f[a>>2]|0){u=i;return}g=a+4|0;h=g+11|0;if((b[h>>0]|0)<0)dn(f[g>>2]|0);l=b[j+7>>0]|0;if((Na[f[(f[c>>2]|0)+8>>2]&127](c)|0)!=(l&255|0)){m=bj(64)|0;f[k>>2]=m;f[k+8>>2]=-2147483584;f[k+4>>2]=50;n=m;o=9577;p=n+50|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[m+50>>0]=0;f[a>>2]=-1;Rf(g,k);if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);u=i;return}m=b[j+5>>0]|0;b[c+36>>0]=m;q=b[j+6>>0]|0;b[c+37>>0]=q;if((m+-1&255)>1){r=bj(32)|0;f[k>>2]=r;f[k+8>>2]=-2147483616;f[k+4>>2]=22;n=r;o=9628;p=n+22|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[r+22>>0]=0;f[a>>2]=-5;Rf(g,k);if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);u=i;return}r=q&255;if(m<<24>>24==2&(l<<24>>24==0?3:2)>>>0>>0){l=bj(32)|0;f[k>>2]=l;f[k+8>>2]=-2147483616;f[k+4>>2]=22;n=l;o=9651;p=n+22|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[l+22>>0]=0;f[a>>2]=-5;Rf(g,k);if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);u=i;return}l=((m&255)<<8|r)&65535;d[(f[e>>2]|0)+38>>1]=l;if((l&65535)>258?(d[j+10>>1]|0)<0:0){Yc(a,c);if(f[a>>2]|0){u=i;return}if((b[h>>0]|0)<0)dn(f[g>>2]|0)}if(!(Na[f[(f[c>>2]|0)+12>>2]&127](c)|0)){h=bj(48)|0;f[k>>2]=h;f[k+8>>2]=-2147483600;f[k+4>>2]=33;n=h;o=9674;p=n+33|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[h+33>>0]=0;f[a>>2]=-1;Rf(g,k);if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);u=i;return}if(!(Na[f[(f[c>>2]|0)+20>>2]&127](c)|0)){h=bj(32)|0;f[k>>2]=h;f[k+8>>2]=-2147483616;f[k+4>>2]=31;n=h;o=9708;p=n+31|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[h+31>>0]=0;f[a>>2]=-1;Rf(g,k);if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);u=i;return}if(Na[f[(f[c>>2]|0)+24>>2]&127](c)|0){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=i;return}c=bj(48)|0;f[k>>2]=c;f[k+8>>2]=-2147483600;f[k+4>>2]=34;n=c;o=9740;p=n+34|0;do{b[n>>0]=b[o>>0]|0;n=n+1|0;o=o+1|0}while((n|0)<(p|0));b[c+34>>0]=0;f[a>>2]=-1;Rf(g,k);if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);u=i;return}function Ub(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=u;u=u+48|0;d=c+32|0;e=c+28|0;g=c+16|0;h=c;i=a+16|0;j=f[i>>2]|0;if(j|0){k=f[b>>2]|0;l=i;m=j;a:while(1){j=m;while(1){if((f[j+16>>2]|0)>=(k|0))break;n=f[j+4>>2]|0;if(!n){o=l;break a}else j=n}m=f[j>>2]|0;if(!m){o=j;break}else l=j}if((o|0)!=(i|0)?(k|0)>=(f[o+16>>2]|0):0){p=o;q=p+20|0;u=c;return q|0}}Gl(g);f[h>>2]=f[b>>2];b=h+4|0;f[h+8>>2]=0;o=h+12|0;f[o>>2]=0;k=h+8|0;f[b>>2]=k;l=f[g>>2]|0;m=g+4|0;if((l|0)!=(m|0)){n=k;r=l;while(1){l=r+16|0;f[e>>2]=n;f[d>>2]=f[e>>2];ke(b,d,l,l)|0;l=f[r+4>>2]|0;if(!l){s=r+8|0;t=f[s>>2]|0;if((f[t>>2]|0)==(r|0))v=t;else{t=s;do{s=f[t>>2]|0;t=s+8|0;w=f[t>>2]|0}while((f[w>>2]|0)!=(s|0));v=w}}else{t=l;while(1){j=f[t>>2]|0;if(!j)break;else t=j}v=t}if((v|0)==(m|0))break;else r=v}}v=a+12|0;r=f[i>>2]|0;do if(r){d=f[h>>2]|0;e=a+16|0;n=r;while(1){l=f[n+16>>2]|0;if((d|0)<(l|0)){j=f[n>>2]|0;if(!j){x=23;break}else{y=n;z=j}}else{if((l|0)>=(d|0)){x=27;break}A=n+4|0;l=f[A>>2]|0;if(!l){x=26;break}else{y=A;z=l}}e=y;n=z}if((x|0)==23){B=n;C=n;break}else if((x|0)==26){B=n;C=A;break}else if((x|0)==27){B=n;C=e;break}}else{B=i;C=i}while(0);i=f[C>>2]|0;if(!i){x=bj(32)|0;f[x+16>>2]=f[h>>2];A=x+20|0;f[A>>2]=f[b>>2];z=x+24|0;y=f[h+8>>2]|0;f[z>>2]=y;r=f[o>>2]|0;f[x+28>>2]=r;if(!r)f[A>>2]=z;else{f[y+8>>2]=z;f[b>>2]=k;f[k>>2]=0;f[o>>2]=0}f[x>>2]=0;f[x+4>>2]=0;f[x+8>>2]=B;f[C>>2]=x;B=f[f[v>>2]>>2]|0;if(!B)D=x;else{f[v>>2]=B;D=f[C>>2]|0}Lc(f[a+16>>2]|0,D);D=a+20|0;f[D>>2]=(f[D>>2]|0)+1;E=x}else E=i;eg(h+4|0,f[k>>2]|0);eg(g,f[m>>2]|0);p=E;q=p+20|0;u=c;return q|0}function Vb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Qc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+4194304|0;f[n>>2]=k;o=k>>>0>1073741823;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<4194304){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<4194304){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&1048575;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>20)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function Wb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Rc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+2097152|0;f[n>>2]=k;o=k>>>0>536870911;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<2097152){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<2097152){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&524287;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>19)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function Xb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Sc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+1048576|0;f[n>>2]=k;o=k>>>0>268435455;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<1048576){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<1048576){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&262143;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>18)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function Yb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Tc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+262144|0;f[n>>2]=k;o=k>>>0>67108863;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<262144){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<262144){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&65535;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>16)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function Zb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Uc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+131072|0;f[n>>2]=k;o=k>>>0>33554431;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<131072){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<131072){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&32767;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>15)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function _b(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=u;u=u+32|0;d=c+16|0;e=c;dg(d,b)|0;g=f[d>>2]|0;if(g|0?(i=a+60|0,Gc(i,g,0),Cm(e),td(e,b)|0,f[d>>2]|0):0){g=0;do{j=Wg(e)|0;k=(f[i>>2]|0)+(g>>>5<<2)|0;l=1<<(g&31);if(j)m=f[k>>2]|l;else m=f[k>>2]&~l;f[k>>2]=m;g=g+1|0}while(g>>>0<(f[d>>2]|0)>>>0)}dg(d,b)|0;g=f[d>>2]|0;if(g|0?(m=a+72|0,Gc(m,g,0),Cm(e),td(e,b)|0,f[d>>2]|0):0){g=0;do{i=W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>>0<0|(m|0)==0&k>>>0<2147483647)){q=0;u=c;return q|0}m=k+1|0;f[a+20>>2]=m;k=(m|0)/2|0;o=a+24|0;f[o>>2]=k;f[a+28>>2]=0-k;if(m&1|0){q=1;u=c;return q|0}f[o>>2]=k+-1;q=1;u=c;return q|0}function $b(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=d-e|0;l=g+(e+4)|0;m=c}else{k=i;l=g;m=i}switch(k|0){case 3:{n=h[l+2>>0]<<16^m;o=6;break}case 2:{n=m;o=6;break}case 1:{p=m;o=7;break}default:q=m}if((o|0)==6){p=h[l+1>>0]<<8^n;o=7}if((o|0)==7)q=X(p^h[l>>0],1540483477)|0;l=X(q>>>13^q,1540483477)|0;q=l>>>15^l;l=f[a+4>>2]|0;if(!l){r=0;return r|0}p=l+-1|0;n=(p&l|0)==0;if(!n)if(q>>>0>>0)s=q;else s=(q>>>0)%(l>>>0)|0;else s=q&p;m=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!m){r=0;return r|0}a=f[m>>2]|0;if(!a){r=0;return r|0}m=(i|0)==0;if(n){n=a;a:while(1){k=f[n+4>>2]|0;c=(q|0)==(k|0);if(!(c|(k&p|0)==(s|0))){r=0;o=40;break}do if(c?(k=n+8|0,e=b[k+11>>0]|0,d=e<<24>>24<0,j=e&255,((d?f[n+12>>2]|0:j)|0)==(i|0)):0){e=f[k>>2]|0;t=d?e:k;if(d){if(m){r=n;o=40;break a}if(!(jh(t,g,i)|0)){r=n;o=40;break a}else break}if(m){r=n;o=40;break a}if((b[g>>0]|0)==(e&255)<<24>>24){e=k;k=j;j=g;do{k=k+-1|0;e=e+1|0;if(!k){r=n;o=40;break a}j=j+1|0}while((b[e>>0]|0)==(b[j>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=40;break}}if((o|0)==40)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;do if((q|0)==(a|0)){n=u+8|0;p=b[n+11>>0]|0;c=p<<24>>24<0;j=p&255;if(((c?f[u+12>>2]|0:j)|0)==(i|0)){p=f[n>>2]|0;e=c?p:n;if(c){if(m){r=u;o=40;break b}if(!(jh(e,g,i)|0)){r=u;o=40;break b}else break}if(m){r=u;o=40;break b}if((b[g>>0]|0)==(p&255)<<24>>24){p=n;n=j;j=g;do{n=n+-1|0;p=p+1|0;if(!n){r=u;o=40;break b}j=j+1|0}while((b[p>>0]|0)==(b[j>>0]|0))}}}else{if(a>>>0>>0)v=a;else v=(a>>>0)%(l>>>0)|0;if((v|0)!=(s|0)){r=0;o=40;break b}}while(0);u=f[u>>2]|0;if(!u){r=0;o=40;break}}if((o|0)==40)return r|0;return 0}function ac(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Vc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+32768|0;f[n>>2]=k;o=k>>>0>8388607;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<32768){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<32768){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&8191;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>13)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function bc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=u;u=u+64|0;g=e;i=e+8|0;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Wc(i,c)|0){j=(a|0)==0;if(!j?(f[i+12>>2]|0)==0:0){l=0;break}if(Ff(g,c)|0?(k=g,m=f[k>>2]|0,n=f[k+4>>2]|0,k=c+8|0,o=c+16|0,p=o,q=f[p>>2]|0,r=f[p+4>>2]|0,p=Tj(f[k>>2]|0,f[k+4>>2]|0,q|0,r|0)|0,k=I,!(n>>>0>k>>>0|(n|0)==(k|0)&m>>>0>p>>>0)):0){p=(f[c>>2]|0)+q|0;k=Rj(q|0,r|0,m|0,n|0)|0;n=o;f[n>>2]=k;f[n+4>>2]=I;b:do if((m|0)>=1){f[i+40>>2]=p;n=m+-1|0;k=p+n|0;switch((h[k>>0]|0)>>>6&3){case 0:{f[i+44>>2]=n;s=n;t=b[k>>0]&63;break}case 1:{if((m|0)<2)break b;k=m+-2|0;f[i+44>>2]=k;n=p+m+-2|0;s=k;t=(h[n+1>>0]|0)<<8&16128|(h[n>>0]|0);break}case 2:{if((m|0)<3)break b;n=m+-3|0;f[i+44>>2]=n;k=p+m+-3|0;s=n;t=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break}case 3:{k=m+-4|0;f[i+44>>2]=k;n=p+m+-4|0;s=k;t=(h[n+2>>0]|0)<<16|(h[n+3>>0]|0)<<24&1056964608|(h[n+1>>0]|0)<<8|(h[n>>0]|0);break}default:{}}n=i+48|0;k=t+16384|0;f[n>>2]=k;o=k>>>0>4194303;if(o|j){l=o^1;break a}o=i+44|0;r=i+16|0;q=i+28|0;v=0;w=s;x=k;while(1){c:do if(x>>>0<16384){k=w;y=x;while(1){if((k|0)<=0){z=k;A=y;break c}B=k+-1|0;f[o>>2]=B;C=y<<8|(h[p+B>>0]|0);f[n>>2]=C;if(C>>>0<16384){k=B;y=C}else{z=B;A=C;break}}}else{z=w;A=x}while(0);y=A&4095;k=f[(f[r>>2]|0)+(y<<2)>>2]|0;C=f[q>>2]|0;x=(X(f[C+(k<<3)>>2]|0,A>>>12)|0)+y-(f[C+(k<<3)+4>>2]|0)|0;f[n>>2]=x;f[d+(v<<2)>>2]=k;v=v+1|0;if((v|0)==(a|0)){l=1;break a}else w=z}}while(0);l=0;break}l=0}else l=0;while(0);z=f[i+28>>2]|0;if(z|0){a=i+32|0;d=f[a>>2]|0;if((d|0)!=(z|0))f[a>>2]=d+(~((d+-8-z|0)>>>3)<<3);dn(z)}z=f[i+16>>2]|0;if(z|0){d=i+20|0;a=f[d>>2]|0;if((a|0)!=(z|0))f[d>>2]=a+(~((a+-4-z|0)>>>2)<<2);dn(z)}z=f[i>>2]|0;if(!z){u=e;return l|0}a=i+4|0;i=f[a>>2]|0;if((i|0)!=(z|0))f[a>>2]=i+(~((i+-4-z|0)>>>2)<<2);dn(z);u=e;return l|0}function cc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=d-e|0;l=g+(e+4)|0;m=c}else{k=i;l=g;m=i}switch(k|0){case 3:{n=h[l+2>>0]<<16^m;o=6;break}case 2:{n=m;o=6;break}case 1:{p=m;o=7;break}default:q=m}if((o|0)==6){p=h[l+1>>0]<<8^n;o=7}if((o|0)==7)q=X(p^h[l>>0],1540483477)|0;l=X(q>>>13^q,1540483477)|0;q=l>>>15^l;l=f[a+4>>2]|0;if(!l){r=0;return r|0}p=l+-1|0;n=(p&l|0)==0;if(!n)if(q>>>0>>0)s=q;else s=(q>>>0)%(l>>>0)|0;else s=q&p;m=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!m){r=0;return r|0}a=f[m>>2]|0;if(!a){r=0;return r|0}m=(i|0)==0;if(n){n=a;a:while(1){k=f[n+4>>2]|0;c=(k|0)==(q|0);if(!(c|(k&p|0)==(s|0))){r=0;o=40;break}do if(c?(k=n+8|0,e=b[k+11>>0]|0,d=e<<24>>24<0,j=e&255,((d?f[n+12>>2]|0:j)|0)==(i|0)):0){e=f[k>>2]|0;t=d?e:k;if(d){if(m){r=n;o=40;break a}if(!(jh(t,g,i)|0)){r=n;o=40;break a}else break}if(m){r=n;o=40;break a}if((b[g>>0]|0)==(e&255)<<24>>24){e=k;k=j;j=g;do{k=k+-1|0;e=e+1|0;if(!k){r=n;o=40;break a}j=j+1|0}while((b[e>>0]|0)==(b[j>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=40;break}}if((o|0)==40)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;do if((a|0)==(q|0)){n=u+8|0;p=b[n+11>>0]|0;c=p<<24>>24<0;j=p&255;if(((c?f[u+12>>2]|0:j)|0)==(i|0)){p=f[n>>2]|0;e=c?p:n;if(c){if(m){r=u;o=40;break b}if(!(jh(e,g,i)|0)){r=u;o=40;break b}else break}if(m){r=u;o=40;break b}if((b[g>>0]|0)==(p&255)<<24>>24){p=n;n=j;j=g;do{n=n+-1|0;p=p+1|0;if(!n){r=u;o=40;break b}j=j+1|0}while((b[p>>0]|0)==(b[j>>0]|0))}}}else{if(a>>>0>>0)v=a;else v=(a>>>0)%(l>>>0)|0;if((v|0)!=(s|0)){r=0;o=40;break b}}while(0);u=f[u>>2]|0;if(!u){r=0;o=40;break}}if((o|0)==40)return r|0;return 0}function dc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;h=a+4|0;i=f[c>>2]|0;c=i;do if((i|0)!=(h|0)){j=i+16|0;k=b[j+11>>0]|0;l=k<<24>>24<0;m=l?f[i+20>>2]|0:k&255;k=b[g+11>>0]|0;n=k<<24>>24<0;o=n?f[g+4>>2]|0:k&255;k=m>>>0>>0;p=k?m:o;if((p|0)!=0?(q=jh(n?f[g>>2]|0:g,l?f[j>>2]|0:j,p)|0,(q|0)!=0):0){if((q|0)<0)break}else r=4;if((r|0)==4?o>>>0>>0:0)break;q=o>>>0>>0?o:m;if((q|0)!=0?(m=jh(l?f[j>>2]|0:j,n?f[g>>2]|0:g,q)|0,(m|0)!=0):0){if((m|0)>=0)r=37}else r=21;if((r|0)==21?!k:0)r=37;if((r|0)==37){f[d>>2]=c;f[e>>2]=c;s=e;return s|0}k=f[i+4>>2]|0;m=(k|0)==0;if(m){q=i+8|0;j=f[q>>2]|0;if((f[j>>2]|0)==(i|0))t=j;else{j=q;do{q=f[j>>2]|0;j=q+8|0;l=f[j>>2]|0}while((f[l>>2]|0)!=(q|0));t=l}}else{j=k;while(1){l=f[j>>2]|0;if(!l)break;else j=l}t=j}do if((t|0)!=(h|0)){k=t+16|0;l=b[k+11>>0]|0;q=l<<24>>24<0;p=q?f[t+20>>2]|0:l&255;l=p>>>0>>0?p:o;if((l|0)!=0?(u=jh(n?f[g>>2]|0:g,q?f[k>>2]|0:k,l)|0,(u|0)!=0):0){if((u|0)<0)break}else r=31;if((r|0)==31?o>>>0

>>0:0)break;s=Gd(a,d,g)|0;return s|0}while(0);if(m){f[d>>2]=c;s=i+4|0;return s|0}else{f[d>>2]=t;s=t;return s|0}}while(0);t=f[i>>2]|0;do if((f[a>>2]|0)==(i|0))v=c;else{if(!t){h=i;while(1){e=f[h+8>>2]|0;if((f[e>>2]|0)==(h|0))h=e;else{w=e;break}}}else{h=t;while(1){m=f[h+4>>2]|0;if(!m){w=h;break}else h=m}}h=w;m=w+16|0;e=b[g+11>>0]|0;o=e<<24>>24<0;n=o?f[g+4>>2]|0:e&255;e=b[m+11>>0]|0;j=e<<24>>24<0;p=j?f[w+20>>2]|0:e&255;e=n>>>0

>>0?n:p;if((e|0)!=0?(u=jh(j?f[m>>2]|0:m,o?f[g>>2]|0:g,e)|0,(u|0)!=0):0){if((u|0)<0){v=h;break}}else r=13;if((r|0)==13?p>>>0>>0:0){v=h;break}s=Gd(a,d,g)|0;return s|0}while(0);if(!t){f[d>>2]=i;s=i;return s|0}else{f[d>>2]=v;s=v+4|0;return s|0}return 0}function ec(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0;e=b+12|0;g=f[e>>2]|0;h=(f[c>>2]|0)-g|0;i=c+4|0;j=(f[i>>2]|0)-g|0;k=c;f[k>>2]=h;f[k+4>>2]=j;k=(h|0)>-1;l=(j|0)>-1;m=f[e>>2]|0;n=((l?j:0-j|0)+(k?h:0-h|0)|0)<=(m|0);if(n){o=h;p=j}else{if(k)if(!l)if((h|0)<1){q=-1;r=-1}else s=6;else{q=1;r=1}else if((j|0)<1){q=-1;r=-1}else s=6;if((s|0)==6){q=(h|0)>0?1:-1;r=(j|0)>0?1:-1}l=X(m,q)|0;k=X(m,r)|0;m=(h<<1)-l|0;f[c>>2]=m;h=(j<<1)-k|0;f[i>>2]=h;if((X(q,r)|0)>-1){r=0-h|0;f[c>>2]=r;t=0-m|0;u=r}else{f[c>>2]=h;t=m;u=h}h=(u+l|0)/2|0;f[c>>2]=h;l=(t+k|0)/2|0;f[i>>2]=l;o=h;p=l}if(!o)v=(p|0)==0;else v=(o|0)<0&(p|0)<1;if(!o)w=(p|0)==0?0:(p|0)>0?3:1;else w=(o|0)>0?(p>>31)+2|0:(p|0)<1?0:3;if(v){x=1;y=o;z=p}else{switch(w|0){case 1:{A=p;B=0-o|0;break}case 2:{A=0-o|0;B=0-p|0;break}case 3:{A=0-p|0;B=o;break}default:{A=o;B=p}}p=c;f[p>>2]=A;f[p+4>>2]=B;x=0;y=A;z=B}B=(f[d>>2]|0)+y|0;f[a>>2]=B;y=(f[d+4>>2]|0)+z|0;z=a+4|0;f[z>>2]=y;d=f[e>>2]|0;if((d|0)>=(B|0))if((B|0)<(0-d|0))C=(f[b+4>>2]|0)+B|0;else C=B;else C=B-(f[b+4>>2]|0)|0;f[a>>2]=C;if((d|0)>=(y|0))if((y|0)<(0-d|0))D=(f[b+4>>2]|0)+y|0;else D=y;else D=y-(f[b+4>>2]|0)|0;f[z>>2]=D;if(x){E=C;F=D}else{switch((4-w|0)%4|0|0){case 1:{G=D;H=0-C|0;break}case 2:{G=0-C|0;H=0-D|0;break}case 3:{G=0-D|0;H=C;break}default:{G=C;H=D}}D=a;f[D>>2]=G;f[D+4>>2]=H;E=G;F=H}if(n){I=E;J=F;K=I+g|0;L=J+g|0;M=a;N=M;f[N>>2]=K;O=M+4|0;P=O;f[P>>2]=L;return}if((E|0)>-1)if((F|0)<=-1)if((E|0)<1){Q=-1;R=-1}else s=42;else{Q=1;R=1}else if((F|0)<1){Q=-1;R=-1}else s=42;if((s|0)==42){Q=(E|0)>0?1:-1;R=(F|0)>0?1:-1}s=X(d,Q)|0;n=X(d,R)|0;d=(E<<1)-s|0;f[a>>2]=d;E=(F<<1)-n|0;f[z>>2]=E;if((X(Q,R)|0)>-1){R=0-E|0;f[a>>2]=R;S=0-d|0;T=R}else{f[a>>2]=E;S=d;T=E}E=(T+s|0)/2|0;f[a>>2]=E;s=(S+n|0)/2|0;f[z>>2]=s;I=E;J=s;K=I+g|0;L=J+g|0;M=a;N=M;f[N>>2]=K;O=M+4|0;P=O;f[P>>2]=L;return}function fc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;g=u;u=u+64|0;i=g;j=i;k=j+40|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));a:do if(Wc(i,d)|0?Bd(i,d)|0:0){j=(a|0)==0;if(!j){if(!(f[i+12>>2]|0)){l=0;break}ah(d,0,0)|0;if(!j){j=i+48|0;k=i+44|0;m=i+40|0;n=i+16|0;o=i+28|0;p=(c|0)>0;q=d+36|0;r=d+32|0;s=d+24|0;t=d+28|0;v=0;w=0;x=f[j>>2]|0;while(1){b:do if(x>>>0<16384){y=f[k>>2]|0;z=x;while(1){if((y|0)<=0){A=z;break b}B=f[m>>2]|0;y=y+-1|0;f[k>>2]=y;C=z<<8|h[B+y>>0];f[j>>2]=C;if(C>>>0>=16384){A=C;break}else z=C}}else A=x;while(0);z=A&4095;y=f[(f[n>>2]|0)+(z<<2)>>2]|0;C=f[o>>2]|0;x=(X(f[C+(y<<3)>>2]|0,A>>>12)|0)+z-(f[C+(y<<3)+4>>2]|0)|0;f[j>>2]=x;c:do if(p){if((y|0)>0){D=0;E=w}else{C=(b[q>>0]|0)==0;z=0;B=w;while(1){if(C){l=0;break a}F=B+1|0;f[e+(B<<2)>>2]=0;z=z+1|0;if((z|0)>=(c|0)){G=F;break c}else B=F}}while(1){if(!(b[q>>0]|0)){l=0;break a}B=f[s>>2]|0;z=f[t>>2]|0;C=0;F=0;H=f[r>>2]|0;while(1){I=B+(H>>>3)|0;if(I>>>0>>0){J=(h[I>>0]|0)>>>(H&7)&1;I=H+1|0;f[r>>2]=I;K=J;L=I}else{K=0;L=H}C=K<>2]=C;D=D+1|0;if((D|0)>=(c|0)){G=H;break}else E=H}}else G=w;while(0);v=v+c|0;if(v>>>0>=a>>>0)break;else w=G}}}else ah(d,0,0)|0;bi(d);l=1}else l=0;while(0);d=f[i+28>>2]|0;if(d|0){G=i+32|0;a=f[G>>2]|0;if((a|0)!=(d|0))f[G>>2]=a+(~((a+-8-d|0)>>>3)<<3);dn(d)}d=f[i+16>>2]|0;if(d|0){a=i+20|0;G=f[a>>2]|0;if((G|0)!=(d|0))f[a>>2]=G+(~((G+-4-d|0)>>>2)<<2);dn(d)}d=f[i>>2]|0;if(!d){u=g;return l|0}G=i+4|0;i=f[G>>2]|0;if((i|0)!=(d|0))f[G>>2]=i+(~((i+-4-d|0)>>>2)<<2);dn(d);u=g;return l|0}function gc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a;h=b;i=h;j=c;k=d;l=k;if(!i){m=(e|0)!=0;if(!l){if(m){f[e>>2]=(g>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(g>>>0)/(j>>>0)>>>0;return (I=n,o)|0}else{if(!m){n=0;o=0;return (I=n,o)|0}f[e>>2]=a|0;f[e+4>>2]=b&0;n=0;o=0;return (I=n,o)|0}}m=(l|0)==0;do if(j){if(!m){p=(_(l|0)|0)-(_(i|0)|0)|0;if(p>>>0<=31){q=p+1|0;r=31-p|0;s=p-31>>31;t=q;u=g>>>(q>>>0)&s|i<>>(q>>>0)&s;w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}r=j-1|0;if(r&j|0){s=(_(j|0)|0)+33-(_(i|0)|0)|0;q=64-s|0;p=32-s|0;y=p>>31;z=s-32|0;A=z>>31;t=s;u=p-1>>31&i>>>(z>>>0)|(i<>>(s>>>0))&A;v=A&i>>>(s>>>0);w=g<>>(z>>>0))&y|g<>31;break}if(e|0){f[e>>2]=r&g;f[e+4>>2]=0}if((j|0)==1){n=h|b&0;o=a|0|0;return (I=n,o)|0}else{r=wi(j|0)|0;n=i>>>(r>>>0)|0;o=i<<32-r|g>>>(r>>>0)|0;return (I=n,o)|0}}else{if(m){if(e|0){f[e>>2]=(i>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(i>>>0)/(j>>>0)>>>0;return (I=n,o)|0}if(!g){if(e|0){f[e>>2]=0;f[e+4>>2]=(i>>>0)%(l>>>0)}n=0;o=(i>>>0)/(l>>>0)>>>0;return (I=n,o)|0}r=l-1|0;if(!(r&l)){if(e|0){f[e>>2]=a|0;f[e+4>>2]=r&i|b&0}n=0;o=i>>>((wi(l|0)|0)>>>0);return (I=n,o)|0}r=(_(l|0)|0)-(_(i|0)|0)|0;if(r>>>0<=30){s=r+1|0;p=31-r|0;t=s;u=i<>>(s>>>0);v=i>>>(s>>>0);w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}while(0);if(!t){B=x;C=w;D=v;E=u;F=0;G=0}else{b=c|0|0;c=k|d&0;d=Rj(b|0,c|0,-1,-1)|0;k=I;h=x;x=w;w=v;v=u;u=t;t=0;do{a=h;h=x>>>31|h<<1;x=t|x<<1;g=v<<1|a>>>31|0;a=v>>>31|w<<1|0;Tj(d|0,k|0,g|0,a|0)|0;i=I;l=i>>31|((i|0)<0?-1:0)<<1;t=l&1;v=Tj(g|0,a|0,l&b|0,(((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1)&c|0)|0;w=I;u=u-1|0}while((u|0)!=0);B=h;C=x;D=w;E=v;F=0;G=t}t=C;C=0;if(e|0){f[e>>2]=E;f[e+4>>2]=D}n=(t|0)>>>31|(B|C)<<1|(C<<1|t>>>31)&0|F;o=(t<<1|0>>>31)&-2|G;return (I=n,o)|0}function hc(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0;switch(c|0){case 1:{c=bj(60)|0;f[c>>2]=1208;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1572;i=c;f[a>>2]=i;return}case 4:{c=bj(112)|0;f[c>>2]=1208;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1628;h=c+60|0;b=h+52|0;do{f[h>>2]=0;h=h+4|0}while((h|0)<(b|0));i=c;f[a>>2]=i;return}case 5:{c=bj(104)|0;f[c>>2]=1208;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1684;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=bj(124)|0;f[c>>2]=1208;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=1740;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=1796;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;Cm(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function ic(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0;switch(c|0){case 1:{c=bj(60)|0;f[c>>2]=1208;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1320;i=c;f[a>>2]=i;return}case 4:{c=bj(112)|0;f[c>>2]=1208;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1376;h=c+60|0;b=h+52|0;do{f[h>>2]=0;h=h+4|0}while((h|0)<(b|0));i=c;f[a>>2]=i;return}case 5:{c=bj(104)|0;f[c>>2]=1208;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1432;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=bj(124)|0;f[c>>2]=1208;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];Bg(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=1488;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=1544;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;Cm(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function jc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)dn(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Yk(d,9789);f[d>>2]=3704;va(d|0,856,80)}d=bj(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)dn(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){b:do if(h){e=k;c=l;i=m;while(1){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0))break;o=(f[a>>2]|0)+(n<<2)|0;if(!(f[o>>2]|0)){p=d;q=i;r=n;s=o;break b}o=d+8|0;t=d;while(1){u=f[t>>2]|0;if(!u)break;if((f[o>>2]|0)==(f[u+8>>2]|0))t=u;else break}f[i>>2]=u;f[t>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;o=f[e>>2]|0;if(!o){v=37;break a}else d=o}c=f[d>>2]|0;if(!c){v=37;break a}else{e=d;i=d}}}else{i=k;e=l;c=m;while(1){o=e;while(1){w=f[o+4>>2]|0;if(w>>>0>>0)x=w;else x=(w>>>0)%(b>>>0)|0;if((x|0)==(j|0))break;w=(f[a>>2]|0)+(x<<2)|0;if(!(f[w>>2]|0)){p=o;q=c;r=x;s=w;break b}w=o+8|0;y=o;while(1){z=f[y>>2]|0;if(!z)break;if((f[w>>2]|0)==(f[z+8>>2]|0))y=z;else break}f[c>>2]=z;f[y>>2]=f[f[(f[a>>2]|0)+(x<<2)>>2]>>2];f[f[(f[a>>2]|0)+(x<<2)>>2]>>2]=o;w=f[i>>2]|0;if(!w){v=37;break a}else o=w}e=f[o>>2]|0;if(!e){v=37;break a}else{i=o;c=o}}}while(0);f[s>>2]=q;l=f[p>>2]|0;if(!l){v=37;break}else{j=r;k=p;m=p}}if((v|0)==37)return}function kc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;c=u;u=u+16|0;d=c;td(a+80|0,a)|0;if(!(qf(a)|0)){e=0;u=c;return e|0}g=b;h=a;i=g+40|0;do{f[g>>2]=f[h>>2];g=g+4|0;h=h+4|0}while((g|0)<(i|0));h=a+176|0;f[h>>2]=2;g=a+180|0;f[g>>2]=7;i=f[a+152>>2]|0;if((i|0)<0){e=0;u=c;return e|0}j=a+156|0;f[d>>2]=0;k=a+160|0;l=f[k>>2]|0;m=f[j>>2]|0;n=l-m>>2;o=m;m=l;if(i>>>0<=n>>>0)if(i>>>0>>0?(l=o+(i<<2)|0,(l|0)!=(m|0)):0){f[k>>2]=m+(~((m+-4-l|0)>>>2)<<2);p=2;q=7}else{p=2;q=7}else{Ae(j,i-n|0,d);p=f[h>>2]|0;q=f[g>>2]|0}g=q-p+1|0;p=a+184|0;q=a+188|0;h=f[q>>2]|0;n=f[p>>2]|0;i=(h-n|0)/12|0;j=n;n=h;if(g>>>0<=i>>>0)if(g>>>0>>0?(l=j+(g*12|0)|0,(l|0)!=(n|0)):0){j=n;while(1){n=j+-12|0;f[q>>2]=n;m=f[n>>2]|0;if(!m)r=n;else{n=j+-8|0;k=f[n>>2]|0;if((k|0)!=(m|0))f[n>>2]=k+(~((k+-4-m|0)>>>2)<<2);dn(m);r=f[q>>2]|0}if((r|0)==(l|0))break;else j=r}s=r}else s=h;else{ld(p,g-i|0);s=f[q>>2]|0}i=a+196|0;g=f[p>>2]|0;h=(s-g|0)/12|0;r=a+200|0;a=f[r>>2]|0;j=f[i>>2]|0;l=a-j>>2;m=j;j=a;if(h>>>0<=l>>>0)if(h>>>0>>0?(a=m+(h<<2)|0,(a|0)!=(j|0)):0){f[r>>2]=j+(~((j+-4-a|0)>>>2)<<2);t=s;v=g}else{t=s;v=g}else{ff(i,h-l|0);t=f[q>>2]|0;v=f[p>>2]|0}if((t|0)==(v|0)){e=1;u=c;return e|0}v=0;do{dg(d,b)|0;t=f[d>>2]|0;if(t|0){l=f[p>>2]|0;h=l+(v*12|0)|0;g=l+(v*12|0)+4|0;s=f[g>>2]|0;a=f[h>>2]|0;j=s-a>>2;r=a;a=s;if(t>>>0<=j>>>0)if(t>>>0>>0?(s=r+(t<<2)|0,(s|0)!=(a|0)):0){f[g>>2]=a+(~((a+-4-s|0)>>>2)<<2);w=l;x=t}else{w=l;x=t}else{ff(h,t-j|0);w=f[p>>2]|0;x=f[d>>2]|0}Qf(x,1,b,f[w+(v*12|0)>>2]|0)|0;f[(f[i>>2]|0)+(v<<2)>>2]=f[d>>2]}v=v+1|0}while(v>>>0<(((f[q>>2]|0)-(f[p>>2]|0)|0)/12|0)>>>0);e=1;u=c;return e|0}function lc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,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>>0]|0)<0)dn(f[h>>2]|0);k=k+1|0;if(F|0){m=0;break b}if(k>>>0>=(f[g>>2]|0)>>>0){m=1;break}}}while(0);l=m;u=d;return l|0}function mc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+176|0;g=e+136|0;h=e+64|0;i=e;j=e+32|0;k=f[(f[c+4>>2]|0)+44>>2]|0;l=bj(88)|0;f[l+4>>2]=0;f[l>>2]=2440;m=l+12|0;f[m>>2]=2420;n=l+64|0;f[n>>2]=0;f[l+68>>2]=0;f[l+72>>2]=0;o=l+16|0;p=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));f[l+76>>2]=k;f[l+80>>2]=d;f[l+84>>2]=0;q=l;r=h+4|0;f[r>>2]=2420;s=h+56|0;f[s>>2]=0;t=h+60|0;f[t>>2]=0;f[h+64>>2]=0;o=h+8|0;p=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));o=f[c+8>>2]|0;f[i>>2]=2420;c=i+4|0;p=c+4|0;f[p>>2]=0;f[p+4>>2]=0;f[p+8>>2]=0;f[p+12>>2]=0;f[p+16>>2]=0;f[p+20>>2]=0;p=o;f[c>>2]=p;c=((f[p+4>>2]|0)-(f[o>>2]|0)>>2>>>0)/3|0;b[g>>0]=0;le(i+8|0,c,g);Sa[f[(f[i>>2]|0)+8>>2]&127](i);jd(j,i);jd(g,j);f[h>>2]=f[g+4>>2];c=h+4|0;wd(c,g)|0;f[g>>2]=2420;p=f[g+20>>2]|0;if(p|0)dn(p);p=f[g+8>>2]|0;if(p|0)dn(p);f[h+36>>2]=o;f[h+40>>2]=d;f[h+44>>2]=k;f[h+48>>2]=l;f[j>>2]=2420;k=f[j+20>>2]|0;if(k|0)dn(k);k=f[j+8>>2]|0;if(k|0)dn(k);f[l+8>>2]=f[h>>2];wd(m,c)|0;c=l+44|0;l=h+36|0;f[c>>2]=f[l>>2];f[c+4>>2]=f[l+4>>2];f[c+8>>2]=f[l+8>>2];f[c+12>>2]=f[l+12>>2];b[c+16>>0]=b[l+16>>0]|0;zd(n,f[s>>2]|0,f[t>>2]|0);f[a>>2]=q;f[i>>2]=2420;q=f[i+20>>2]|0;if(q|0)dn(q);q=f[i+8>>2]|0;if(q|0)dn(q);q=f[s>>2]|0;if(q|0){s=f[t>>2]|0;if((s|0)!=(q|0))f[t>>2]=s+(~((s+-4-q|0)>>>2)<<2);dn(q)}f[r>>2]=2420;r=f[h+24>>2]|0;if(r|0)dn(r);r=f[h+12>>2]|0;if(!r){u=e;return}dn(r);u=e;return}function nc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;g=a+8|0;f[g>>2]=e;h=a+32|0;i=a+36|0;j=f[i>>2]|0;k=f[h>>2]|0;l=j-k>>2;m=k;k=j;if(l>>>0>=e>>>0)if(l>>>0>e>>>0?(j=m+(e<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=e}else n=e;else{ff(h,e-l|0);n=f[g>>2]|0}l=e>>>0>1073741823?-1:e<<2;h=an(l)|0;Vf(h|0,0,l|0)|0;if((n|0)>0){l=a+16|0;j=a+32|0;k=a+12|0;i=0;do{m=f[h+(i<<2)>>2]|0;o=f[l>>2]|0;if((m|0)>(o|0)){p=f[j>>2]|0;f[p+(i<<2)>>2]=o;q=p}else{p=f[k>>2]|0;o=f[j>>2]|0;f[o+(i<<2)>>2]=(m|0)<(p|0)?p:m;q=o}i=i+1|0;r=f[g>>2]|0}while((i|0)<(r|0));if((r|0)>0){i=a+20|0;j=0;do{o=(f[b+(j<<2)>>2]|0)+(f[q+(j<<2)>>2]|0)|0;m=c+(j<<2)|0;f[m>>2]=o;if((o|0)<=(f[l>>2]|0)){if((o|0)<(f[k>>2]|0)){s=(f[i>>2]|0)+o|0;t=18}}else{s=o-(f[i>>2]|0)|0;t=18}if((t|0)==18){t=0;f[m>>2]=s}j=j+1|0;m=f[g>>2]|0}while((j|0)<(m|0));u=m}else u=r}else u=n;if((e|0)>=(d|0)){bn(h);return 1}n=0-e|0;r=a+16|0;j=a+32|0;s=a+12|0;i=a+20|0;a=e;k=u;while(1){u=c+(a<<2)|0;l=u+(n<<2)|0;q=b+(a<<2)|0;if((k|0)>0){m=0;do{o=f[l+(m<<2)>>2]|0;p=f[r>>2]|0;if((o|0)>(p|0)){v=f[j>>2]|0;f[v+(m<<2)>>2]=p;w=v}else{v=f[s>>2]|0;p=f[j>>2]|0;f[p+(m<<2)>>2]=(o|0)<(v|0)?v:o;w=p}m=m+1|0;x=f[g>>2]|0}while((m|0)<(x|0));if((x|0)>0){m=0;do{l=(f[q+(m<<2)>>2]|0)+(f[w+(m<<2)>>2]|0)|0;p=u+(m<<2)|0;f[p>>2]=l;if((l|0)<=(f[r>>2]|0)){if((l|0)<(f[s>>2]|0)){y=(f[i>>2]|0)+l|0;t=33}}else{y=l-(f[i>>2]|0)|0;t=33}if((t|0)==33){t=0;f[p>>2]=y}m=m+1|0;p=f[g>>2]|0}while((m|0)<(p|0));z=p}else z=x}else z=k;a=a+e|0;if((a|0)>=(d|0))break;else k=z}bn(h);return 1}function oc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+16|0;e=d;g=a+68|0;f[g>>2]=(f[g>>2]|0)+1;g=(f[a+8+(b*12|0)+4>>2]|0)-(f[a+8+(b*12|0)>>2]|0)|0;h=g>>2;if((g|0)<=0){u=d;return}g=a+4|0;i=a+56|0;j=a+72|0;k=f[c>>2]|0;c=k+4|0;l=k+8|0;m=a+76|0;n=0;o=f[a+44+(b<<2)>>2]|0;while(1){b=(o|0)==-1;p=b?-1:(o>>>0)/3|0;q=(f[i>>2]|0)+(p>>>5<<2)|0;f[q>>2]=f[q>>2]|1<<(p&31);f[j>>2]=(f[j>>2]|0)+1;do if(n){if(b)r=-1;else r=f[(f[(f[a>>2]|0)+96>>2]|0)+(((o|0)/3|0)*12|0)+(((o|0)%3|0)<<2)>>2]|0;f[m>>2]=r;f[e>>2]=r;p=f[c>>2]|0;if(p>>>0<(f[l>>2]|0)>>>0){f[p>>2]=r;f[c>>2]=p+4}else xf(k,e);if(!(n&1)){p=o+1|0;if(b){s=-1;break}t=((p>>>0)%3|0|0)==0?o+-2|0:p;v=35;break}if(!b)if(!((o>>>0)%3|0)){t=o+2|0;v=35;break}else{t=o+-1|0;v=35;break}else s=-1}else{if(b)w=-1;else w=f[(f[(f[a>>2]|0)+96>>2]|0)+(((o|0)/3|0)*12|0)+(((o|0)%3|0)<<2)>>2]|0;f[e>>2]=w;p=f[c>>2]|0;if(p>>>0<(f[l>>2]|0)>>>0){f[p>>2]=w;f[c>>2]=p+4}else xf(k,e);p=o+1|0;if(!b?(q=((p>>>0)%3|0|0)==0?o+-2|0:p,(q|0)!=-1):0)x=f[(f[(f[a>>2]|0)+96>>2]|0)+(((q|0)/3|0)*12|0)+(((q|0)%3|0)<<2)>>2]|0;else x=-1;f[e>>2]=x;q=f[c>>2]|0;if(q>>>0<(f[l>>2]|0)>>>0){f[q>>2]=x;f[c>>2]=q+4}else xf(k,e);if(!b?(q=(((o>>>0)%3|0|0)==0?2:-1)+o|0,(q|0)!=-1):0)y=f[(f[(f[a>>2]|0)+96>>2]|0)+(((q|0)/3|0)*12|0)+(((q|0)%3|0)<<2)>>2]|0;else y=-1;f[m>>2]=y;f[e>>2]=y;q=f[c>>2]|0;if(q>>>0<(f[l>>2]|0)>>>0){f[q>>2]=y;f[c>>2]=q+4}else xf(k,e);t=o;v=35}while(0);if((v|0)==35){v=0;if((t|0)==-1)s=-1;else s=f[(f[(f[g>>2]|0)+12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+4}else xf(w,e);E=(f[y>>2]|0)+2|0;f[y>>2]=E;if(E&1|0){f[e>>2]=F;E=f[c>>2]|0;if(E>>>0<(f[x>>2]|0)>>>0){f[E>>2]=F;f[c>>2]=E+4}else xf(w,e);f[y>>2]=(f[y>>2]|0)+1}}f[h>>2]=z;f[e>>2]=f[h>>2];oc(a,b,e);G=f[j>>2]|0;H=f[k>>2]|0}else{G=B;H=l}A=A+1|0;if(A>>>0>=((H-G|0)/12|0)>>>0){i=1;break}else{B=G;l=H}}u=d;return i|0}function qc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;c=a+148|0;d=f[b>>2]|0;b=(d|0)==-1;e=d+1|0;do if(!b){g=((e>>>0)%3|0|0)==0?d+-2|0:e;if(!((d>>>0)%3|0)){h=d+2|0;i=g;break}else{h=d+-1|0;i=g;break}}else{h=-1;i=-1}while(0);switch(f[a+168>>2]|0){case 1:case 0:{if((i|0)==-1)j=-1;else j=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;e=f[a+156>>2]|0;g=e+(j<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((h|0)==-1){k=1;l=-1;m=e;n=28}else{k=1;l=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;m=e;n=28}break}case 5:{if(b)o=-1;else o=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;e=f[a+156>>2]|0;g=e+(o<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((i|0)==-1)p=-1;else p=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;g=e+(p<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((h|0)==-1){k=2;l=-1;m=e;n=28}else{k=2;l=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;m=e;n=28}break}case 3:{if(b)q=-1;else q=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;e=f[a+156>>2]|0;g=e+(q<<2)|0;f[g>>2]=(f[g>>2]|0)+1;if((i|0)==-1)r=-1;else r=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;g=e+(r<<2)|0;f[g>>2]=(f[g>>2]|0)+2;if((h|0)==-1){k=1;l=-1;m=e;n=28}else{k=1;l=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;m=e;n=28}break}case 7:{if(b)s=-1;else s=f[(f[f[c>>2]>>2]|0)+(d<<2)>>2]|0;d=f[a+156>>2]|0;b=d+(s<<2)|0;f[b>>2]=(f[b>>2]|0)+2;if((i|0)==-1)t=-1;else t=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;b=d+(t<<2)|0;f[b>>2]=(f[b>>2]|0)+2;if((h|0)==-1){k=2;l=-1;m=d;n=28}else{k=2;l=f[(f[f[c>>2]>>2]|0)+(h<<2)>>2]|0;m=d;n=28}break}default:{}}if((n|0)==28){n=m+(l<<2)|0;f[n>>2]=(f[n>>2]|0)+k}if((i|0)==-1)u=-1;else u=f[(f[f[c>>2]>>2]|0)+(i<<2)>>2]|0;i=f[(f[a+156>>2]|0)+(u<<2)>>2]|0;u=f[a+176>>2]|0;if((i|0)<(u|0)){v=u;w=v-u|0;x=a+172|0;f[x>>2]=w;return}c=f[a+180>>2]|0;v=(i|0)>(c|0)?c:i;w=v-u|0;x=a+172|0;f[x>>2]=w;return}function rc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;d=u;u=u+32|0;e=d+16|0;g=d+12|0;h=d;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;i=f[a>>2]|0;j=i+8|0;k=f[j+4>>2]|0;l=i+16|0;m=l;n=f[m>>2]|0;o=f[m+4>>2]|0;do if((k|0)>(o|0)|((k|0)==(o|0)?(f[j>>2]|0)>>>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,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=La,t=La,u=La,v=0,w=0,x=0,y=0,z=0;c=f[b>>2]|0;b=a+4|0;d=f[b>>2]|0;e=(d|0)==0;a:do if(!e){g=d+-1|0;h=(g&d|0)==0;if(!h)if(c>>>0>>0)i=c;else i=(c>>>0)%(d>>>0)|0;else i=g&c;j=f[(f[a>>2]|0)+(i<<2)>>2]|0;if(!j)k=i;else{if(h){h=j;while(1){l=f[h>>2]|0;if(!l){k=i;break a}m=f[l+4>>2]|0;if(!((m|0)==(c|0)|(m&g|0)==(i|0))){k=i;break a}if((f[l+8>>2]|0)==(c|0)){o=l;break}else h=l}p=o+12|0;return p|0}else q=j;while(1){h=f[q>>2]|0;if(!h){k=i;break a}g=f[h+4>>2]|0;if((g|0)!=(c|0)){if(g>>>0>>0)r=g;else r=(g>>>0)%(d>>>0)|0;if((r|0)!=(i|0)){k=i;break a}}if((f[h+8>>2]|0)==(c|0)){o=h;break}else q=h}p=o+12|0;return p|0}}else k=0;while(0);q=bj(16)|0;f[q+8>>2]=c;f[q+12>>2]=0;f[q+4>>2]=c;f[q>>2]=0;i=a+12|0;s=$(((f[i>>2]|0)+1|0)>>>0);t=$(d>>>0);u=$(n[a+16>>2]);do if(e|$(u*t)>>0<3|(d+-1&d|0)!=0)&1;j=~~$(W($(s/u)))>>>0;Te(a,r>>>0>>0?j:r);r=f[b>>2]|0;j=r+-1|0;if(!(j&r)){v=r;w=j&c;break}if(c>>>0>>0){v=r;w=c}else{v=r;w=(c>>>0)%(r>>>0)|0}}else{v=d;w=k}while(0);k=(f[a>>2]|0)+(w<<2)|0;w=f[k>>2]|0;if(!w){d=a+8|0;f[q>>2]=f[d>>2];f[d>>2]=q;f[k>>2]=d;d=f[q>>2]|0;if(d|0){k=f[d+4>>2]|0;d=v+-1|0;if(d&v)if(k>>>0>>0)x=k;else x=(k>>>0)%(v>>>0)|0;else x=k&d;y=(f[a>>2]|0)+(x<<2)|0;z=30}}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=a+92|0;f[g>>2]=0;f[a+96>>2]=0;f[d>>2]=f[e>>2];d=c+92|0;f[g>>2]=f[d>>2];g=c+96|0;f[a+96>>2]=f[g>>2];f[g>>2]=0;f[d>>2]=0;f[e>>2]=0;b[a+100>>0]=b[c+100>>0]|0;e=a+104|0;d=c+104|0;f[e>>2]=0;g=a+108|0;f[g>>2]=0;f[a+112>>2]=0;f[e>>2]=f[d>>2];e=c+108|0;f[g>>2]=f[e>>2];g=c+112|0;f[a+112>>2]=f[g>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;d=a+116|0;e=c+116|0;f[d>>2]=0;g=a+120|0;f[g>>2]=0;f[a+124>>2]=0;f[d>>2]=f[e>>2];d=c+120|0;f[g>>2]=f[d>>2];g=c+124|0;f[a+124>>2]=f[g>>2];f[g>>2]=0;f[d>>2]=0;f[e>>2]=0;f[a+128>>2]=f[c+128>>2];e=a+132|0;d=c+132|0;f[e>>2]=0;g=a+136|0;f[g>>2]=0;f[a+140>>2]=0;f[e>>2]=f[d>>2];e=c+136|0;f[g>>2]=f[e>>2];g=c+140|0;f[a+140>>2]=f[g>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;return}function uc(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;i=u;u=u+32|0;j=i+16|0;k=i+12|0;l=i;m=c+24|0;n=b[m>>0]|0;o=n<<24>>24;p=f[a+80>>2]|0;a=X(p,o)|0;q=f[c+28>>2]|0;if((q|0)==(e|0)|(q|0)==(g|0)?b[c+84>>0]|0:0){g=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;qd(h,g,g+(a<<1)|0);r=1;u=i;return r|0}f[l>>2]=0;g=l+4|0;f[g>>2]=0;f[l+8>>2]=0;do if(n<<24>>24)if(n<<24>>24<0)um(l);else{q=o<<1;e=bj(q)|0;f[l>>2]=e;s=e+(o<<1)|0;f[l+8>>2]=s;Vf(e|0,0,q|0)|0;f[g>>2]=s;break}while(0);qd(h,0,0+(a<<1)|0);a:do if(!p)t=1;else{a=c+84|0;s=c+68|0;if(n<<24>>24>0){v=0;w=0}else{q=0;while(1){if(!(b[a>>0]|0))x=f[(f[s>>2]|0)+(q<<2)>>2]|0;else x=q;e=f[l>>2]|0;f[k>>2]=x;y=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(mb(c,j,y,e)|0)){t=0;break a}q=q+1|0;if(q>>>0>=p>>>0){t=1;break a}}}while(1){if(!(b[a>>0]|0))z=f[(f[s>>2]|0)+(w<<2)>>2]|0;else z=w;q=f[l>>2]|0;f[k>>2]=z;e=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(mb(c,j,e,q)|0)){t=0;break a}q=f[l>>2]|0;e=f[h>>2]|0;y=0;A=v;while(1){d[e+(A<<1)>>1]=d[q+(y<<1)>>1]|0;y=y+1|0;if((y|0)==(o|0))break;else A=A+1|0}w=w+1|0;if(w>>>0>=p>>>0){t=1;break}else v=v+o|0}}while(0);o=f[l>>2]|0;if(o|0){l=f[g>>2]|0;if((l|0)!=(o|0))f[g>>2]=l+(~((l+-2-o|0)>>>1)<<1);dn(o)}r=t;u=i;return r|0}function vc(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;i=u;u=u+32|0;j=i+16|0;k=i+12|0;l=i;m=c+24|0;n=b[m>>0]|0;o=n<<24>>24;p=f[a+80>>2]|0;a=X(p,o)|0;q=f[c+28>>2]|0;if((q|0)==(e|0)|(q|0)==(g|0)?b[c+84>>0]|0:0){g=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;qd(h,g,g+(a<<1)|0);r=1;u=i;return r|0}f[l>>2]=0;g=l+4|0;f[g>>2]=0;f[l+8>>2]=0;do if(n<<24>>24)if(n<<24>>24<0)um(l);else{q=o<<1;e=bj(q)|0;f[l>>2]=e;s=e+(o<<1)|0;f[l+8>>2]=s;Vf(e|0,0,q|0)|0;f[g>>2]=s;break}while(0);qd(h,0,0+(a<<1)|0);a:do if(!p)t=1;else{a=c+84|0;s=c+68|0;if(n<<24>>24>0){v=0;w=0}else{q=0;while(1){if(!(b[a>>0]|0))x=f[(f[s>>2]|0)+(q<<2)>>2]|0;else x=q;e=f[l>>2]|0;f[k>>2]=x;y=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(nb(c,j,y,e)|0)){t=0;break a}q=q+1|0;if(q>>>0>=p>>>0){t=1;break a}}}while(1){if(!(b[a>>0]|0))z=f[(f[s>>2]|0)+(w<<2)>>2]|0;else z=w;q=f[l>>2]|0;f[k>>2]=z;e=b[m>>0]|0;f[j>>2]=f[k>>2];if(!(nb(c,j,e,q)|0)){t=0;break a}q=f[l>>2]|0;e=f[h>>2]|0;y=0;A=v;while(1){d[e+(A<<1)>>1]=d[q+(y<<1)>>1]|0;y=y+1|0;if((y|0)==(o|0))break;else A=A+1|0}w=w+1|0;if(w>>>0>=p>>>0){t=1;break}else v=v+o|0}}while(0);o=f[l>>2]|0;if(o|0){l=f[g>>2]|0;if((l|0)!=(o|0))f[g>>2]=l+(~((l+-2-o|0)>>>1)<<1);dn(o)}r=t;u=i;return r|0}function wc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;rd(g,e,e+(a<<2)|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;do if(m<<24>>24)if(m<<24>>24<0)um(k);else{p=n<<2;d=bj(p)|0;f[k>>2]=d;r=d+(n<<2)|0;f[k+8>>2]=r;Vf(d|0,0,p|0)|0;f[e>>2]=r;break}while(0);rd(g,0,0+(a<<2)|0);a:do if(!o)s=1;else{a=c+84|0;r=c+68|0;if(m<<24>>24>0){t=0;v=0}else{p=0;while(1){if(!(b[a>>0]|0))w=f[(f[r>>2]|0)+(p<<2)>>2]|0;else w=p;d=f[k>>2]|0;f[j>>2]=w;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(ob(c,i,x,d)|0)){s=0;break a}p=p+1|0;if(p>>>0>=o>>>0){s=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[r>>2]|0)+(v<<2)>>2]|0;else y=v;p=f[k>>2]|0;f[j>>2]=y;d=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(ob(c,i,d,p)|0)){s=0;break a}p=f[k>>2]|0;d=f[g>>2]|0;x=0;z=t;while(1){f[d+(z<<2)>>2]=f[p+(x<<2)>>2];x=x+1|0;if((x|0)==(n|0))break;else z=z+1|0}v=v+1|0;if(v>>>0>=o>>>0){s=1;break}else t=t+n|0}}while(0);n=f[k>>2]|0;if(n|0){k=f[e>>2]|0;if((k|0)!=(n|0))f[e>>2]=k+(~((k+-4-n|0)>>>2)<<2);dn(n)}q=s;u=h;return q|0}function xc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;rd(g,e,e+(a<<2)|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;do if(m<<24>>24)if(m<<24>>24<0)um(k);else{p=n<<2;d=bj(p)|0;f[k>>2]=d;r=d+(n<<2)|0;f[k+8>>2]=r;Vf(d|0,0,p|0)|0;f[e>>2]=r;break}while(0);rd(g,0,0+(a<<2)|0);a:do if(!o)s=1;else{a=c+84|0;r=c+68|0;if(m<<24>>24>0){t=0;v=0}else{p=0;while(1){if(!(b[a>>0]|0))w=f[(f[r>>2]|0)+(p<<2)>>2]|0;else w=p;d=f[k>>2]|0;f[j>>2]=w;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(pb(c,i,x,d)|0)){s=0;break a}p=p+1|0;if(p>>>0>=o>>>0){s=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[r>>2]|0)+(v<<2)>>2]|0;else y=v;p=f[k>>2]|0;f[j>>2]=y;d=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(pb(c,i,d,p)|0)){s=0;break a}p=f[k>>2]|0;d=f[g>>2]|0;x=0;z=t;while(1){f[d+(z<<2)>>2]=f[p+(x<<2)>>2];x=x+1|0;if((x|0)==(n|0))break;else z=z+1|0}v=v+1|0;if(v>>>0>=o>>>0){s=1;break}else t=t+n|0}}while(0);n=f[k>>2]|0;if(n|0){k=f[e>>2]|0;if((k|0)!=(n|0))f[e>>2]=k+(~((k+-4-n|0)>>>2)<<2);dn(n)}q=s;u=h;return q|0}function yc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;e=c+8|0;g=f[e+4>>2]|0;h=c+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if(!((g|0)>(k|0)|((g|0)==(k|0)?(f[e>>2]|0)>>>0>j>>>0:0))){l=0;return l|0}e=b[(f[c>>2]|0)+j>>0]|0;g=Rj(j|0,k|0,1,0)|0;k=h;f[k>>2]=g;f[k+4>>2]=I;do switch(e<<24>>24){case 1:{l=bc(a,c,d)|0;return l|0}case 2:{l=bc(a,c,d)|0;return l|0}case 3:{l=bc(a,c,d)|0;return l|0}case 4:{l=bc(a,c,d)|0;return l|0}case 5:{l=cd(a,c,d)|0;return l|0}case 6:{l=bc(a,c,d)|0;return l|0}case 7:{l=bc(a,c,d)|0;return l|0}case 8:{l=bc(a,c,d)|0;return l|0}case 9:{l=ac(a,c,d)|0;return l|0}case 10:{l=Zb(a,c,d)|0;return l|0}case 11:{l=Yb(a,c,d)|0;return l|0}case 12:{l=Xb(a,c,d)|0;return l|0}case 13:{l=Wb(a,c,d)|0;return l|0}case 14:{l=Vb(a,c,d)|0;return l|0}case 15:{l=Vb(a,c,d)|0;return l|0}case 16:{l=Vb(a,c,d)|0;return l|0}case 17:{l=Vb(a,c,d)|0;return l|0}case 18:{l=Vb(a,c,d)|0;return l|0}default:{l=0;return l|0}}while(0);return 0}function zc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;Jd(g,e,e+a|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;if(m<<24>>24){if(m<<24>>24<0)um(k);p=bj(n)|0;f[e>>2]=p;f[k>>2]=p;f[k+8>>2]=p+n;d=n;r=p;do{b[r>>0]=0;r=(f[e>>2]|0)+1|0;f[e>>2]=r;d=d+-1|0}while((d|0)!=0)}Jd(g,0,0+a|0);a:do if(!o)s=1;else{a=c+84|0;d=c+68|0;if(m<<24>>24>0){t=0;v=0}else{r=0;while(1){if(!(b[a>>0]|0))w=f[(f[d>>2]|0)+(r<<2)>>2]|0;else w=r;p=f[k>>2]|0;f[j>>2]=w;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(qb(c,i,x,p)|0)){s=0;break a}r=r+1|0;if(r>>>0>=o>>>0){s=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[d>>2]|0)+(v<<2)>>2]|0;else y=v;r=f[k>>2]|0;f[j>>2]=y;p=b[l>>0]|0;f[i>>2]=f[j>>2];if(qb(c,i,p,r)|0){z=0;A=t}else{s=0;break a}while(1){b[(f[g>>2]|0)+A>>0]=b[(f[k>>2]|0)+z>>0]|0;z=z+1|0;if((z|0)==(n|0))break;else A=A+1|0}v=v+1|0;if(v>>>0>=o>>>0){s=1;break}else t=t+n|0}}while(0);n=f[k>>2]|0;if(n|0){if((f[e>>2]|0)!=(n|0))f[e>>2]=n;dn(n)}q=s;u=h;return q|0}function Ac(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;h=u;u=u+32|0;i=h+16|0;j=h+12|0;k=h;l=c+24|0;m=b[l>>0]|0;n=m<<24>>24;o=f[a+80>>2]|0;a=X(o,n)|0;p=f[c+28>>2]|0;if((p|0)==(d|0)|(p|0)==(e|0)?b[c+84>>0]|0:0){e=(f[f[c>>2]>>2]|0)+(f[c+48>>2]|0)|0;Jd(g,e,e+a|0);q=1;u=h;return q|0}f[k>>2]=0;e=k+4|0;f[e>>2]=0;f[k+8>>2]=0;if(m<<24>>24){if(m<<24>>24<0)um(k);p=bj(n)|0;f[e>>2]=p;f[k>>2]=p;f[k+8>>2]=p+n;d=n;r=p;do{b[r>>0]=0;r=(f[e>>2]|0)+1|0;f[e>>2]=r;d=d+-1|0}while((d|0)!=0)}Jd(g,0,0+a|0);a:do if(!o)s=1;else{a=c+84|0;d=c+68|0;if(m<<24>>24>0){t=0;v=0}else{r=0;while(1){if(!(b[a>>0]|0))w=f[(f[d>>2]|0)+(r<<2)>>2]|0;else w=r;p=f[k>>2]|0;f[j>>2]=w;x=b[l>>0]|0;f[i>>2]=f[j>>2];if(!(rb(c,i,x,p)|0)){s=0;break a}r=r+1|0;if(r>>>0>=o>>>0){s=1;break a}}}while(1){if(!(b[a>>0]|0))y=f[(f[d>>2]|0)+(v<<2)>>2]|0;else y=v;r=f[k>>2]|0;f[j>>2]=y;p=b[l>>0]|0;f[i>>2]=f[j>>2];if(rb(c,i,p,r)|0){z=0;A=t}else{s=0;break a}while(1){b[(f[g>>2]|0)+A>>0]=b[(f[k>>2]|0)+z>>0]|0;z=z+1|0;if((z|0)==(n|0))break;else A=A+1|0}v=v+1|0;if(v>>>0>=o>>>0){s=1;break}else t=t+n|0}}while(0);n=f[k>>2]|0;if(n|0){if((f[e>>2]|0)!=(n|0))f[e>>2]=n;dn(n)}q=s;u=h;return q|0}function Bc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;d=u;u=u+16|0;h=d+4|0;i=d;j=a+60|0;f[a+64>>2]=g;g=a+8|0;f[g>>2]=e;k=a+32|0;l=a+36|0;m=f[l>>2]|0;n=f[k>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=e>>>0){if(o>>>0>e>>>0?(m=p+(e<<2)|0,(m|0)!=(n|0)):0)f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2)}else ff(k,e-o|0);o=a+56|0;k=f[o>>2]|0;m=f[k+4>>2]|0;n=f[k>>2]|0;l=m-n|0;p=l>>2;if((l|0)<=0){u=d;return 1}l=a+16|0;q=a+32|0;r=a+12|0;s=a+20|0;if((m|0)==(n|0)){t=k;um(t)}else{v=0;w=n}while(1){f[i>>2]=f[w+(v<<2)>>2];f[h>>2]=f[i>>2];ub(j,h,c,v);n=X(v,e)|0;k=b+(n<<2)|0;m=c+(n<<2)|0;if((f[g>>2]|0)>0){n=0;do{x=f[a+68+(n<<2)>>2]|0;y=f[l>>2]|0;if((x|0)>(y|0)){z=f[q>>2]|0;f[z+(n<<2)>>2]=y;A=z}else{z=f[r>>2]|0;y=f[q>>2]|0;f[y+(n<<2)>>2]=(x|0)<(z|0)?z:x;A=y}n=n+1|0;B=f[g>>2]|0}while((n|0)<(B|0));if((B|0)>0){n=0;do{y=(f[k+(n<<2)>>2]|0)+(f[A+(n<<2)>>2]|0)|0;x=m+(n<<2)|0;f[x>>2]=y;if((y|0)<=(f[l>>2]|0)){if((y|0)<(f[r>>2]|0)){C=(f[s>>2]|0)+y|0;D=20}}else{C=y-(f[s>>2]|0)|0;D=20}if((D|0)==20){D=0;f[x>>2]=C}n=n+1|0}while((n|0)<(f[g>>2]|0))}}v=v+1|0;if((v|0)>=(p|0)){D=8;break}n=f[o>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){t=n;D=9;break}}if((D|0)==8){u=d;return 1}else if((D|0)==9)um(t);return 0}function Cc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;e=f[b>>2]|0;g=f[b+4>>2]|0;h=((f[c>>2]|0)-e<<3)+(f[c+4>>2]|0)-g|0;c=e;if((h|0)<=0){i=d+4|0;j=f[d>>2]|0;f[a>>2]=j;k=a+4|0;l=f[i>>2]|0;f[k>>2]=l;return}if(!g){e=d+4|0;m=h;n=e;o=f[e>>2]|0;p=c}else{e=32-g|0;q=(h|0)<(e|0)?h:e;r=-1>>>(e-q|0)&-1<>2];e=d+4|0;s=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}else{x=n;y=p}if((x|0)<=0){j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}p=f[y>>2]&-1>>>(32-x|0);y=(w|0)<(x|0)?w:x;n=f[d>>2]|0;i=f[n>>2]&~(-1<>2]&-1>>>(w-y|0));f[n>>2]=i;f[n>>2]=i|p<>2];i=(f[o>>2]|0)+y|0;w=n+(i>>>5<<2)|0;f[d>>2]=w;f[o>>2]=i&31;i=x-y|0;if((i|0)<=0){j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}f[w>>2]=f[w>>2]&~(-1>>>(32-i|0))|p>>>y;f[o>>2]=i;j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}function Fc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+32|0;e=d+16|0;g=d+4|0;i=d;if(!(dg(e,c)|0)){j=-1;u=d;return j|0}k=f[e>>2]|0;if(k|0){l=f[a+8>>2]|0;if(k>>>0>(((f[l+4>>2]|0)-(f[l>>2]|0)>>2>>>0)/3|0)>>>0){j=-1;u=d;return j|0}l=g+4|0;k=a+40|0;m=a+44|0;n=a+36|0;o=0;p=0;do{dg(i,c)|0;f[l>>2]=(f[i>>2]|0)+p;dg(i,c)|0;q=f[i>>2]|0;p=f[l>>2]|0;if(p>>>0>>0){r=22;break}f[g>>2]=p-q;q=f[k>>2]|0;if((q|0)==(f[m>>2]|0))cf(n,g);else{f[q>>2]=f[g>>2];f[q+4>>2]=f[g+4>>2];f[q+8>>2]=f[g+8>>2];f[k>>2]=(f[k>>2]|0)+12}o=o+1|0}while(o>>>0<(f[e>>2]|0)>>>0);if((r|0)==22){j=-1;u=d;return j|0}ah(c,0,0)|0;r=f[e>>2]|0;if(r|0){e=a+4|0;o=c+36|0;k=c+32|0;g=c+24|0;n=c+28|0;m=a+36|0;a=0;p=0;while(1){l=f[e>>2]|0;i=(b[o>>0]|0)==0;if(((h[l+36>>0]<<8|h[l+37>>0])&65535)<514)if(!i){l=f[k>>2]|0;q=f[g>>2]|0;s=f[n>>2]|0;t=q+(l>>>3)|0;if(t>>>0>>0){v=(h[t>>0]|0)>>>(l&7)&1;t=l+1|0;f[k>>2]=t;w=v;x=t}else{w=0;x=l}if((q+(x>>>3)|0)>>>0>>0){f[k>>2]=x+1;y=w}else y=w}else y=p;else if(!i){i=f[k>>2]|0;s=(f[g>>2]|0)+(i>>>3)|0;if(s>>>0<(f[n>>2]|0)>>>0){q=(h[s>>0]|0)>>>(i&7)&1;f[k>>2]=i+1;y=q}else y=0}else y=p;q=(f[m>>2]|0)+(a*12|0)+8|0;b[q>>0]=b[q>>0]&-2|y&1;a=a+1|0;if(a>>>0>=r>>>0)break;else p=y}}bi(c)}j=f[c+16>>2]|0;u=d;return j|0}function Gc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+32|0;e=d+8|0;g=d;h=a+4|0;i=f[h>>2]|0;if(i>>>0>=b>>>0){f[h>>2]=b;u=d;return}j=a+8|0;k=f[j>>2]|0;l=k<<5;m=b-i|0;if(l>>>0>>0|i>>>0>(l-m|0)>>>0){f[e>>2]=0;n=e+4|0;f[n>>2]=0;o=e+8|0;f[o>>2]=0;if((b|0)<0)um(a);p=k<<6;k=b+31&-32;af(e,l>>>0<1073741823?(p>>>0>>0?k:p):2147483647);p=f[h>>2]|0;f[n>>2]=p+m;k=f[a>>2]|0;l=k;q=f[e>>2]|0;r=(l+(p>>>5<<2)-k<<3)+(p&31)|0;if((r|0)>0){p=r>>>5;qi(q|0,k|0,p<<2|0)|0;k=r&31;r=q+(p<<2)|0;s=r;if(!k){t=0;v=s}else{w=-1>>>(32-k|0);f[r>>2]=f[r>>2]&~w|f[l+(p<<2)>>2]&w;t=k;v=s}}else{t=0;v=q}f[g>>2]=v;f[g+4>>2]=t;t=g;g=f[t>>2]|0;v=f[t+4>>2]|0;t=f[a>>2]|0;f[a>>2]=f[e>>2];f[e>>2]=t;e=f[h>>2]|0;f[h>>2]=f[n>>2];f[n>>2]=e;e=f[j>>2]|0;f[j>>2]=f[o>>2];f[o>>2]=e;if(t|0)dn(t);x=g;y=v}else{v=(f[a>>2]|0)+(i>>>5<<2)|0;f[h>>2]=b;x=v;y=i&31}if(!m){u=d;return}i=(y|0)==0;v=x;if(c){if(i){z=m;A=x;B=v}else{c=32-y|0;b=c>>>0>m>>>0?m:c;f[v>>2]=f[v>>2]|-1>>>(c-b|0)&-1<>>5;Vf(A|0,-1,c<<2|0)|0;A=z&31;z=B+(c<<2)|0;if(!A){u=d;return}f[z>>2]=f[z>>2]|-1>>>(32-A|0);u=d;return}else{if(i){C=m;D=x;E=v}else{x=32-y|0;i=x>>>0>m>>>0?m:x;f[v>>2]=f[v>>2]&~(-1>>>(x-i|0)&-1<>>5;Vf(D|0,0,y<<2|0)|0;D=C&31;C=E+(y<<2)|0;if(!D){u=d;return}f[C>>2]=f[C>>2]&~(-1>>>(32-D|0));u=d;return}}function Hc(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c=a+32|0;d=f[c>>2]|0;e=d+8|0;g=f[e+4>>2]|0;h=d+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if(!((g|0)>(k|0)|((g|0)==(k|0)?(f[e>>2]|0)>>>0>j>>>0:0))){l=0;return l|0}e=b[(f[d>>2]|0)+j>>0]|0;d=Rj(j|0,k|0,1,0)|0;k=h;f[k>>2]=d;f[k+4>>2]=I;k=e&255;d=e<<24>>24==0;a:do if(!d){e=0;while(1){if(!(Oa[f[(f[a>>2]|0)+16>>2]&127](a,e)|0)){l=0;break}e=e+1|0;if((e|0)>=(k|0))break a}return l|0}while(0);e=a+8|0;h=f[e>>2]|0;j=f[a+12>>2]|0;b:do if((h|0)!=(j|0)){g=a+4|0;i=h;while(1){m=f[i>>2]|0;i=i+4|0;if(!(Pa[f[(f[m>>2]|0)+8>>2]&31](m,a,f[g>>2]|0)|0)){l=0;break}if((i|0)==(j|0))break b}return l|0}while(0);if(!d){j=0;do{h=f[(f[e>>2]|0)+(j<<2)>>2]|0;j=j+1|0;if(!(Oa[f[(f[h>>2]|0)+12>>2]&127](h,f[c>>2]|0)|0)){l=0;n=26;break}}while((j|0)<(k|0));if((n|0)==26)return l|0;if(!d){d=a+20|0;n=a+24|0;j=0;do{c=f[(f[e>>2]|0)+(j<<2)>>2]|0;h=Na[f[(f[c>>2]|0)+24>>2]&127](c)|0;if((h|0)>0){c=0;do{i=f[(f[e>>2]|0)+(j<<2)>>2]|0;g=Oa[f[(f[i>>2]|0)+20>>2]&127](i,c)|0;i=f[n>>2]|0;m=f[d>>2]|0;o=i-m>>2;p=m;do if(g>>>0>=o>>>0){m=g+1|0;q=i;if(m>>>0>o>>>0){ff(d,m-o|0);r=f[d>>2]|0;break}if(m>>>0>>0?(s=p+(m<<2)|0,(s|0)!=(q|0)):0){f[n>>2]=q+(~((q+-4-s|0)>>>2)<<2);r=p}else r=p}else r=p;while(0);f[r+(g<<2)>>2]=j;c=c+1|0}while((c|0)!=(h|0))}j=j+1|0}while((j|0)!=(k|0))}}if(!(Na[f[(f[a>>2]|0)+28>>2]&127](a)|0)){l=0;return l|0}l=Na[f[(f[a>>2]|0)+32>>2]&127](a)|0;return l|0}function Ic(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+16|0;d=c;e=Na[f[(f[a>>2]|0)+24>>2]&127](a)|0;if((e|0)<=0){g=1;u=c;return g|0}h=a+36|0;i=a+48|0;j=d+8|0;k=d+4|0;l=d+11|0;m=0;while(1){n=(Na[f[(f[a>>2]|0)+28>>2]&127](a)|0)+40|0;if(f[n>>2]|0){n=f[(f[(f[h>>2]|0)+(m<<2)>>2]|0)+8>>2]|0;o=(Na[f[(f[a>>2]|0)+28>>2]&127](a)|0)+40|0;p=f[o>>2]|0;o=f[n+56>>2]|0;n=bj(32)|0;f[d>>2]=n;f[j>>2]=-2147483616;f[k>>2]=24;q=n;r=8408;s=q+24|0;do{b[q>>0]=b[r>>0]|0;q=q+1|0;r=r+1|0}while((q|0)<(s|0));b[n+24>>0]=0;r=p+16|0;q=f[r>>2]|0;if(q){s=r;t=q;a:while(1){q=t;while(1){if((f[q+16>>2]|0)>=(o|0))break;v=f[q+4>>2]|0;if(!v){w=s;break a}else q=v}t=f[q>>2]|0;if(!t){w=q;break}else s=q}if(((w|0)!=(r|0)?(o|0)>=(f[w+16>>2]|0):0)?(s=w+20|0,(Ge(s,d)|0)!=0):0)x=tg(s,d,0)|0;else y=13}else y=13;if((y|0)==13){y=0;x=tg(p,d,0)|0}if((b[l>>0]|0)<0)dn(f[d>>2]|0);if(x){s=f[(f[h>>2]|0)+(m<<2)>>2]|0;t=f[s+8>>2]|0;ad(t,Je(s)|0)}else y=18}else y=18;if((y|0)==18?(y=0,s=f[(f[h>>2]|0)+(m<<2)>>2]|0,!(Oa[f[(f[s>>2]|0)+24>>2]&127](s,i)|0)):0){g=0;y=20;break}m=m+1|0;if((m|0)>=(e|0)){g=1;y=20;break}}if((y|0)==20){u=c;return g|0}return 0}function Jc(a){a=a|0;var b=0,c=0,d=0,e=0;f[a>>2]=2296;b=a+360|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+-4|0;d=f[b>>2]|0;if(d|0){e=c+(d<<4)|0;do e=e+-16|0;while((e|0)!=(c|0))}bn(b)}gf(a+212|0);b=f[a+196>>2]|0;if(b|0){c=a+200|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);dn(b)}b=f[a+184>>2]|0;if(b|0){e=a+188|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+172>>2]|0;if(b|0){c=a+176|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);dn(b)}b=f[a+160>>2]|0;if(b|0){e=a+164|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+144>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;dn(b)}while((c|0)!=0)}c=a+136|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)dn(b);b=f[a+120>>2]|0;if(b|0)dn(b);b=f[a+108>>2]|0;if(b|0)dn(b);b=f[a+96>>2]|0;if(b|0)dn(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);dn(b)}b=f[a+60>>2]|0;if(b|0)dn(b);b=f[a+48>>2]|0;if(b|0){e=a+52|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+36>>2]|0;if(b|0){c=a+40|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~(((e+-12-b|0)>>>0)/12|0)*12|0);dn(b)}b=f[a+24>>2]|0;if(b|0){e=a+28|0;c=f[e>>2]|0;if((c|0)!=(b|0))f[e>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+12>>2]|0;if(b|0){c=a+16|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);dn(b)}b=a+8|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;mf(a);dn(a);return}function Kc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+32|0;e=d;g=a+8|0;h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;if(((h-j|0)/144|0)>>>0>=c>>>0){k=c;l=j;do{f[l>>2]=-1;_g(l+4|0);b[l+100>>0]=1;m=l+104|0;n=m+40|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(n|0));l=(f[i>>2]|0)+144|0;f[i>>2]=l;k=k+-1|0}while((k|0)!=0);u=d;return}k=f[a>>2]|0;l=(j-k|0)/144|0;j=l+c|0;if(j>>>0>29826161)um(a);o=(h-k|0)/144|0;k=o<<1;h=o>>>0<14913080?(k>>>0>>0?j:k):29826161;f[e+12>>2]=0;f[e+16>>2]=a+8;do if(h)if(h>>>0>29826161){k=ra(8)|0;Yk(k,9789);f[k>>2]=3704;va(k|0,856,80)}else{p=bj(h*144|0)|0;break}else p=0;while(0);f[e>>2]=p;k=p+(l*144|0)|0;l=e+8|0;f[l>>2]=k;j=e+4|0;f[j>>2]=k;o=e+12|0;f[o>>2]=p+(h*144|0);h=c;c=k;do{f[c>>2]=-1;_g(c+4|0);b[c+100>>0]=1;m=c+104|0;n=m+40|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(n|0));c=(f[l>>2]|0)+144|0;f[l>>2]=c;h=h+-1|0}while((h|0)!=0);h=c;c=f[a>>2]|0;m=f[i>>2]|0;if((m|0)==(c|0)){q=j;r=f[j>>2]|0;s=c;t=m}else{n=m;m=f[j>>2]|0;do{m=m+-144|0;n=n+-144|0;tc(m,n)}while((n|0)!=(c|0));f[j>>2]=m;q=j;r=m;s=f[a>>2]|0;t=f[i>>2]|0}f[a>>2]=r;f[q>>2]=s;f[i>>2]=h;f[l>>2]=t;t=f[g>>2]|0;f[g>>2]=f[o>>2];f[o>>2]=t;f[e>>2]=s;lf(e);u=d;return}function Lc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=(c|0)==(a|0);b[c+12>>0]=d&1;if(d)return;else e=c;while(1){g=e+8|0;h=f[g>>2]|0;c=h+12|0;if(b[c>>0]|0){i=23;break}j=h+8|0;k=f[j>>2]|0;d=f[k>>2]|0;if((d|0)==(h|0)){l=f[k+4>>2]|0;if(!l){i=7;break}m=l+12|0;if(!(b[m>>0]|0))n=m;else{i=7;break}}else{if(!d){i=16;break}m=d+12|0;if(!(b[m>>0]|0))n=m;else{i=16;break}}b[c>>0]=1;c=(k|0)==(a|0);b[k+12>>0]=c&1;b[n>>0]=1;if(c){i=23;break}else e=k}if((i|0)==7){if((f[h>>2]|0)==(e|0)){o=h;p=k}else{n=h+4|0;a=f[n>>2]|0;c=f[a>>2]|0;f[n>>2]=c;if(!c)q=k;else{f[c+8>>2]=h;q=f[j>>2]|0}f[a+8>>2]=q;q=f[j>>2]|0;f[((f[q>>2]|0)==(h|0)?q:q+4|0)>>2]=a;f[a>>2]=h;f[j>>2]=a;o=a;p=f[a+8>>2]|0}b[o+12>>0]=1;b[p+12>>0]=0;o=f[p>>2]|0;a=o+4|0;q=f[a>>2]|0;f[p>>2]=q;if(q|0)f[q+8>>2]=p;q=p+8|0;f[o+8>>2]=f[q>>2];c=f[q>>2]|0;f[((f[c>>2]|0)==(p|0)?c:c+4|0)>>2]=o;f[a>>2]=p;f[q>>2]=o;return}else if((i|0)==16){if((f[h>>2]|0)==(e|0)){o=e+4|0;q=f[o>>2]|0;f[h>>2]=q;if(!q)r=k;else{f[q+8>>2]=h;r=f[j>>2]|0}f[g>>2]=r;r=f[j>>2]|0;f[((f[r>>2]|0)==(h|0)?r:r+4|0)>>2]=e;f[o>>2]=h;f[j>>2]=e;s=e;t=f[e+8>>2]|0}else{s=h;t=k}b[s+12>>0]=1;b[t+12>>0]=0;s=t+4|0;k=f[s>>2]|0;h=f[k>>2]|0;f[s>>2]=h;if(h|0)f[h+8>>2]=t;h=t+8|0;f[k+8>>2]=f[h>>2];s=f[h>>2]|0;f[((f[s>>2]|0)==(t|0)?s:s+4|0)>>2]=k;f[k>>2]=t;f[h>>2]=k;return}else if((i|0)==23)return}function Mc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;e=u;u=u+16|0;g=e;h=f[a+40>>2]|0;i=f[a+44>>2]|0;if((h|0)==(i|0)){j=0;k=2;l=(k|0)==2;m=l?0:j;u=e;return m|0}a=g+11|0;n=g+4|0;o=d+11|0;p=d+4|0;q=0;r=h;a:while(1){f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=Sf(f[r>>2]|0,c,g)|0;s=b[a>>0]|0;b:do if(h){t=s<<24>>24<0;v=s&255;w=t?f[n>>2]|0:v;x=b[o>>0]|0;y=x<<24>>24<0;if((w|0)==((y?f[p>>2]|0:x&255)|0)){x=f[g>>2]|0;z=t?x:g;A=y?f[d>>2]|0:d;y=(w|0)==0;c:do if(t){if(!y?jh(z,A,w)|0:0){B=0;C=q;D=14;break b}}else if(!y){if((b[A>>0]|0)==(x&255)<<24>>24){E=g;F=v;G=A}else{H=0;I=q;D=13;break b}while(1){F=F+-1|0;E=E+1|0;if(!F)break c;G=G+1|0;if((b[E>>0]|0)!=(b[G>>0]|0)){H=0;I=q;D=13;break b}}}while(0);H=1;I=f[r>>2]|0;D=13}else{H=0;I=q;D=13}}else{H=3;I=q;D=13}while(0);if((D|0)==13){D=0;if(s<<24>>24<0){B=H;C=I;D=14}else{J=H;K=I}}if((D|0)==14){D=0;dn(f[g>>2]|0);J=B;K=C}switch(J&3){case 3:case 0:break;default:{j=K;k=J;D=17;break a}}r=r+4|0;if((r|0)==(i|0)){j=K;k=2;D=17;break}else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I,j>>>0<0|(j|0)==0&i>>>0<2147483647):0){j=i+1|0;f[a+20>>2]=j;i=(j|0)/2|0;l=a+24|0;f[l>>2]=i;f[a+28>>2]=0-i;if(!(j&1)){f[l>>2]=i+-1;q=1}else q=1}else q=0}else q=0;n=q;u=c;return n|0}function Oc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0;g=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;if(!((c+-1|0)>>>0<6&(Na[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1)){h=0;f[a>>2]=h;return}i=Na[f[(f[b>>2]|0)+36>>2]&127](b)|0;j=Oa[f[(f[b>>2]|0)+44>>2]&127](b,d)|0;if((i|0)==0|(j|0)==0){h=0;f[a>>2]=h;return}k=Oa[f[(f[b>>2]|0)+40>>2]&127](b,d)|0;d=f[b+44>>2]|0;b=j+12|0;l=(c|0)==6;if(!k){if(l){c=bj(104)|0;f[c+4>>2]=g;m=c+8|0;f[m>>2]=f[e>>2];f[m+4>>2]=f[e+4>>2];f[m+8>>2]=f[e+8>>2];f[m+12>>2]=f[e+12>>2];f[c+24>>2]=d;f[c+28>>2]=i;f[c+32>>2]=b;f[c+36>>2]=j;f[c>>2]=2024;f[c+44>>2]=0;f[c+48>>2]=0;f[c+52>>2]=d;f[c+56>>2]=i;f[c+60>>2]=b;f[c+64>>2]=j;f[c+40>>2]=2080;f[c+68>>2]=1;i=c+72|0;f[i>>2]=-1;f[i+4>>2]=-1;f[i+8>>2]=-1;f[i+12>>2]=-1;Cm(c+88|0);h=c;f[a>>2]=h;return}}else if(l){l=bj(104)|0;f[l+4>>2]=g;g=l+8|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[g+12>>2]=f[e+12>>2];f[l+24>>2]=d;f[l+28>>2]=k;f[l+32>>2]=b;f[l+36>>2]=j;f[l>>2]=1940;f[l+44>>2]=0;f[l+48>>2]=0;f[l+52>>2]=d;f[l+56>>2]=k;f[l+60>>2]=b;f[l+64>>2]=j;f[l+40>>2]=1996;f[l+68>>2]=1;j=l+72|0;f[j>>2]=-1;f[j+4>>2]=-1;f[j+8>>2]=-1;f[j+12>>2]=-1;Cm(l+88|0);h=l;f[a>>2]=h;return}f[a>>2]=0;f[a>>2]=0;h=0;f[a>>2]=h;return}function Pc(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2464;Le(a+224|0);gf(a+212|0);b=f[a+196>>2]|0;if(b|0){c=a+200|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+184>>2]|0;if(b|0){d=a+188|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+172>>2]|0;if(b|0){c=a+176|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+160>>2]|0;if(b|0){d=a+164|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+144>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;dn(b)}while((c|0)!=0)}c=a+136|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)dn(b);b=f[a+120>>2]|0;if(b|0)dn(b);b=f[a+108>>2]|0;if(b|0)dn(b);b=f[a+96>>2]|0;if(b|0)dn(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+60>>2]|0;if(b|0)dn(b);b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+36>>2]|0;if(b|0){c=a+40|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);dn(b)}b=f[a+24>>2]|0;if(b|0){d=a+28|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+12>>2]|0;if(b|0){c=a+16|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=a+8|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;mf(a);dn(a);return}function Qc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=pe(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Rc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=re(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Sc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=se(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Tc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=ue(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Uc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=ve(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Vc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=we(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Wc(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;if(!(d[c+38>>1]|0)){e=0;return e|0}g=a+12|0;if(!(dg(g,c)|0)){e=0;return e|0}h=f[g>>2]|0;i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0)if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){f[i>>2]=k+(~((k+-4-j|0)>>>2)<<2);n=h}else n=h;else{ff(a,h-l|0);n=f[g>>2]|0}if(!n){e=1;return e|0}l=c+8|0;h=c+16|0;j=0;k=n;a:while(1){n=l;i=f[n>>2]|0;m=f[n+4>>2]|0;n=h;o=f[n>>2]|0;p=f[n+4>>2]|0;if(!((m|0)>(p|0)|(m|0)==(p|0)&i>>>0>o>>>0)){e=0;q=19;break}n=f[c>>2]|0;r=b[n+o>>0]|0;s=Rj(o|0,p|0,1,0)|0;p=I;o=h;f[o>>2]=s;f[o+4>>2]=p;o=r&255;t=o&3;u=o>>>2;switch(r&3){case 3:{r=u+j|0;if(r>>>0>=k>>>0){e=0;q=19;break a}Vf((f[a>>2]|0)+(j<<2)|0,0,(o&252)+4|0)|0;v=r;break}case 0:{w=u;q=16;break}default:{r=u;u=0;o=p;p=s;while(1){if(!((m|0)>(o|0)|(m|0)==(o|0)&i>>>0>p>>>0)){e=0;q=19;break a}s=b[n+p>>0]|0;p=Rj(p|0,o|0,1,0)|0;o=I;x=h;f[x>>2]=p;f[x+4>>2]=o;x=(s&255)<<(u<<3|6)|r;u=u+1|0;if((u|0)>=(t|0)){w=x;q=16;break}else r=x}}}if((q|0)==16){q=0;f[(f[a>>2]|0)+(j<<2)>>2]=w;v=j}j=v+1|0;k=f[g>>2]|0;if(j>>>0>=k>>>0){q=18;break}}if((q|0)==18){e=xe(a+16|0,f[a>>2]|0,k)|0;return e|0}else if((q|0)==19)return e|0;return 0}function Xc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d;if(!(Qb(a,c)|0)){g=0;u=d;return g|0}h=Na[f[(f[a>>2]|0)+24>>2]&127](a)|0;i=a+36|0;j=a+40|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0){if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){n=l;do{l=n+-4|0;f[j>>2]=l;o=f[l>>2]|0;f[l>>2]=0;if(o|0)Sa[f[(f[o>>2]|0)+4>>2]&127](o);n=f[j>>2]|0}while((n|0)!=(k|0))}}else Kd(i,h-m|0);m=c+8|0;if((h|0)<=0){g=1;u=d;return g|0}k=c+16|0;n=0;while(1){j=m;o=f[j+4>>2]|0;l=k;p=f[l>>2]|0;q=f[l+4>>2]|0;if(!((o|0)>(q|0)|((o|0)==(q|0)?(f[j>>2]|0)>>>0>p>>>0:0))){g=0;r=19;break}j=b[(f[c>>2]|0)+p>>0]|0;o=Rj(p|0,q|0,1,0)|0;q=k;f[q>>2]=o;f[q+4>>2]=I;Ua[f[(f[a>>2]|0)+48>>2]&7](e,a,j);j=(f[i>>2]|0)+(n<<2)|0;q=f[e>>2]|0;f[e>>2]=0;o=f[j>>2]|0;f[j>>2]=q;if(o|0)Sa[f[(f[o>>2]|0)+4>>2]&127](o);o=f[e>>2]|0;f[e>>2]=0;if(o|0)Sa[f[(f[o>>2]|0)+4>>2]&127](o);o=f[(f[i>>2]|0)+(n<<2)>>2]|0;if(!o){g=0;r=19;break}q=f[(f[o>>2]|0)+8>>2]|0;j=Na[f[(f[a>>2]|0)+28>>2]&127](a)|0;p=Oa[f[(f[a>>2]|0)+20>>2]&127](a,n)|0;n=n+1|0;if(!(Pa[q&31](o,j,p)|0)){g=0;r=19;break}if((n|0)>=(h|0)){g=1;r=19;break}}if((r|0)==19){u=d;return g|0}return 0}function Yc(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0;d=u;u=u+16|0;e=d+12|0;g=d;h=bj(52)|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;n[h+16>>2]=$(1.0);i=h+20|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[h+36>>2]=$(1.0);f[h+40>>2]=0;f[h+44>>2]=0;f[h+48>>2]=0;Em(e);if(ee(e,f[c+32>>2]|0,h)|0){e=(f[c+4>>2]|0)+4|0;c=f[e>>2]|0;f[e>>2]=h;if(c|0){e=c+40|0;i=f[e>>2]|0;if(i|0){j=c+44|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k;do{k=m+-4|0;f[j>>2]=k;o=f[k>>2]|0;f[k>>2]=0;if(o|0){Cf(o);dn(o)}m=f[j>>2]|0}while((m|0)!=(i|0));l=f[e>>2]|0}dn(l)}Cf(c);dn(c)}f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=d;return}else{f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;c=bj(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=26;l=c;e=9550;i=l+26|0;do{b[l>>0]=b[e>>0]|0;l=l+1|0;e=e+1|0}while((l|0)<(i|0));b[c+26>>0]=0;f[a>>2]=-1;Rf(a+4|0,g);if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);g=h+40|0;a=f[g>>2]|0;if(a|0){c=h+44|0;e=f[c>>2]|0;if((e|0)==(a|0))p=a;else{l=e;do{e=l+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){Cf(i);dn(i)}l=f[c>>2]|0}while((l|0)!=(a|0));p=f[g>>2]|0}dn(p)}Cf(h);dn(h);u=d;return}}function Zc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;f[a>>2]=e;break a;break}case 10:{e=(f[c>>2]|0)+(4-1)&~(4-1);d=f[e>>2]|0;f[c>>2]=e+4;e=a;f[e>>2]=d;f[e+4>>2]=((d|0)<0)<<31>>31;break a;break}case 11:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;d=a;f[d>>2]=e;f[d+4>>2]=0;break a;break}case 12:{d=(f[c>>2]|0)+(8-1)&~(8-1);e=d;g=f[e>>2]|0;h=f[e+4>>2]|0;f[c>>2]=d+8;d=a;f[d>>2]=g;f[d+4>>2]=h;break a;break}case 13:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&65535)<<16>>16;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 14:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&65535;f[h+4>>2]=0;break a;break}case 15:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&255)<<24>>24;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 16:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&255;f[h+4>>2]=0;break a;break}case 17:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}case 18:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}default:break a}while(0);while(0);return}function _c(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+144|0;g=e+136|0;h=e+32|0;i=e;j=f[(f[c+4>>2]|0)+44>>2]|0;k=bj(124)|0;f[k+4>>2]=0;f[k>>2]=2396;f[k+12>>2]=2420;f[k+100>>2]=0;f[k+104>>2]=0;f[k+108>>2]=0;l=k+16|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));f[k+112>>2]=j;f[k+116>>2]=d;f[k+120>>2]=0;n=k;f[h+4>>2]=2420;f[h+92>>2]=0;f[h+96>>2]=0;f[h+100>>2]=0;l=h+8|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));l=f[c+8>>2]|0;f[i>>2]=2420;c=i+4|0;m=c+4|0;f[m>>2]=0;f[m+4>>2]=0;f[m+8>>2]=0;f[m+12>>2]=0;f[m+16>>2]=0;f[m+20>>2]=0;m=l;f[c>>2]=m;o=((f[m+4>>2]|0)-(f[l>>2]|0)>>2>>>0)/3|0;b[g>>0]=0;le(i+8|0,o,g);Sa[f[(f[i>>2]|0)+8>>2]&127](i);f[h>>2]=f[c>>2];wd(h+4|0,i)|0;f[h+36>>2]=l;f[h+40>>2]=d;f[h+44>>2]=j;f[h+48>>2]=k;Wd(k,h);f[a>>2]=n;f[i>>2]=2420;n=f[i+20>>2]|0;if(n|0)dn(n);n=f[i+8>>2]|0;if(!n){wf(h);u=e;return}dn(n);wf(h);u=e;return}function $c(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+32|0;e=d+12|0;g=d;h=xh(c,0)|0;if(!h){f[a>>2]=0;u=d;return}i=f[c+100>>2]|0;j=f[c+96>>2]|0;c=i-j|0;k=(c|0)/12|0;f[e>>2]=0;l=e+4|0;f[l>>2]=0;f[e+8>>2]=0;m=j;do if(c)if(k>>>0>357913941)um(e);else{n=bj(c)|0;f[e>>2]=n;f[e+8>>2]=n+(k*12|0);Vf(n|0,0,c|0)|0;f[l>>2]=n+c;o=n;break}else o=0;while(0);f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;a:do if((i|0)!=(j|0)){c=g+4|0;n=g+8|0;if(b[h+84>>0]|0){p=0;while(1){q=m+(p*12|0)|0;f[g>>2]=f[q>>2];f[g+4>>2]=f[q+4>>2];f[g+8>>2]=f[q+8>>2];f[o+(p*12|0)>>2]=f[g>>2];f[o+(p*12|0)+4>>2]=f[c>>2];f[o+(p*12|0)+8>>2]=f[n>>2];p=p+1|0;if(p>>>0>=k>>>0)break a}}p=f[h+68>>2]|0;q=0;do{r=f[p+(f[m+(q*12|0)>>2]<<2)>>2]|0;f[g>>2]=r;s=f[p+(f[m+(q*12|0)+4>>2]<<2)>>2]|0;f[c>>2]=s;t=f[p+(f[m+(q*12|0)+8>>2]<<2)>>2]|0;f[n>>2]=t;f[o+(q*12|0)>>2]=r;f[o+(q*12|0)+4>>2]=s;f[o+(q*12|0)+8>>2]=t;q=q+1|0}while(q>>>0>>0)}while(0);kg(a,e);a=f[e>>2]|0;if(a|0){e=f[l>>2]|0;if((e|0)!=(a|0))f[l>>2]=e+(~(((e+-12-a|0)>>>0)/12|0)*12|0);dn(a)}u=d;return}function ad(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;if(!(f[a+64>>2]|0)){d=bj(32)|0;oj(d);e=a+64|0;g=f[e>>2]|0;f[e>>2]=d;if(!g)h=d;else{d=f[g>>2]|0;if(d|0){i=g+4|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;dn(d)}dn(g);h=f[e>>2]|0}Vg(a,h,0,0,0,0);j=a}else j=a;if(!(Nf(j,c)|0))return;b[a+84>>0]=b[c+84>>0]|0;f[a+80>>2]=f[c+80>>2];if((a|0)!=(c|0))zd(a+68|0,f[c+68>>2]|0,f[c+72>>2]|0);j=f[c+88>>2]|0;if(!j){c=a+88|0;h=f[c>>2]|0;f[c>>2]=0;if(!h)return;c=f[h+8>>2]|0;if(c|0){e=h+12|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;dn(c)}dn(h);return}h=bj(40)|0;f[h>>2]=f[j>>2];c=h+8|0;e=j+8|0;f[c>>2]=0;g=h+12|0;f[g>>2]=0;d=h+16|0;f[d>>2]=0;i=j+12|0;k=(f[i>>2]|0)-(f[e>>2]|0)|0;if(k|0){if((k|0)<0)um(c);l=bj(k)|0;f[g>>2]=l;f[c>>2]=l;f[d>>2]=l+k;k=f[e>>2]|0;e=(f[i>>2]|0)-k|0;if((e|0)>0){ge(l|0,k|0,e|0)|0;f[g>>2]=l+e}}e=h+24|0;l=j+24|0;f[e>>2]=f[l>>2];f[e+4>>2]=f[l+4>>2];f[e+8>>2]=f[l+8>>2];f[e+12>>2]=f[l+12>>2];l=a+88|0;a=f[l>>2]|0;f[l>>2]=h;if(!a)return;h=f[a+8>>2]|0;if(h|0){l=a+12|0;if((f[l>>2]|0)!=(h|0))f[l>>2]=h;dn(h)}dn(a);return}function bd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;e=u;u=u+32|0;g=e+20|0;h=e+16|0;i=e;j=c+24|0;k=b[j>>0]|0;l=k<<24>>24;m=f[a+80>>2]|0;a=X(m,l)|0;f[i>>2]=f[226];f[i+4>>2]=f[227];f[i+8>>2]=f[228];f[i+12>>2]=f[229];n=d+4|0;o=f[n>>2]|0;p=f[d>>2]|0;q=o-p>>2;r=p;p=o;if(a>>>0<=q>>>0){if(a>>>0>>0?(o=r+(a<<2)|0,(o|0)!=(p|0)):0)f[n>>2]=p+(~((p+-4-o|0)>>>2)<<2)}else ff(d,a-q|0);if(!m){s=1;u=e;return s|0}q=c+84|0;a=c+68|0;if(k<<24>>24<=0){k=0;while(1){if(!(b[q>>0]|0))t=f[(f[a>>2]|0)+(k<<2)>>2]|0;else t=k;f[h>>2]=t;o=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(bb(c,g,o,i)|0)){s=0;v=18;break}k=k+1|0;if(k>>>0>=m>>>0){s=1;v=18;break}}if((v|0)==18){u=e;return s|0}}else{w=0;x=0}while(1){if(!(b[q>>0]|0))y=f[(f[a>>2]|0)+(x<<2)>>2]|0;else y=x;f[h>>2]=y;k=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(bb(c,g,k,i)|0)){s=0;v=18;break}k=f[d>>2]|0;t=0;o=w;while(1){f[k+(o<<2)>>2]=f[i+(t<<2)>>2];t=t+1|0;if((t|0)==(l|0))break;else o=o+1|0}x=x+1|0;if(x>>>0>=m>>>0){s=1;v=18;break}else w=w+l|0}if((v|0)==18){u=e;return s|0}return 0}function cd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+64|0;e=d;g=e;i=g+40|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(i|0));do if(Wc(e,b)|0){g=(a|0)==0;if(!g?(f[e+12>>2]|0)==0:0){j=0;break}i=Bd(e,b)|0;if(g|i^1)j=i;else{i=e+48|0;g=e+44|0;k=e+40|0;l=e+16|0;m=e+28|0;n=0;o=f[i>>2]|0;while(1){a:do if(o>>>0<16384){p=f[g>>2]|0;q=o;while(1){if((p|0)<=0){r=q;break a}s=f[k>>2]|0;p=p+-1|0;f[g>>2]=p;t=q<<8|(h[s+p>>0]|0);f[i>>2]=t;if(t>>>0>=16384){r=t;break}else q=t}}else r=o;while(0);q=r&4095;p=f[(f[l>>2]|0)+(q<<2)>>2]|0;t=f[m>>2]|0;o=(X(f[t+(p<<3)>>2]|0,r>>>12)|0)+q-(f[t+(p<<3)+4>>2]|0)|0;f[i>>2]=o;f[c+(n<<2)>>2]=p;n=n+1|0;if((n|0)==(a|0)){j=1;break}}}}else j=0;while(0);a=f[e+28>>2]|0;if(a|0){c=e+32|0;r=f[c>>2]|0;if((r|0)!=(a|0))f[c>>2]=r+(~((r+-8-a|0)>>>3)<<3);dn(a)}a=f[e+16>>2]|0;if(a|0){r=e+20|0;c=f[r>>2]|0;if((c|0)!=(a|0))f[r>>2]=c+(~((c+-4-a|0)>>>2)<<2);dn(a)}a=f[e>>2]|0;if(!a){u=d;return j|0}c=e+4|0;e=f[c>>2]|0;if((e|0)!=(a|0))f[c>>2]=e+(~((e+-4-a|0)>>>2)<<2);dn(a);u=d;return j|0}function dd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=f[c>>2]|0;c=f[d>>2]|0;e=f[a+4>>2]|0;g=f[d+4>>2]|0;h=e+-1|0;i=(h&e|0)==0;if(!i)if(g>>>0>>0)j=g;else j=(g>>>0)%(e>>>0)|0;else j=h&g;g=(f[a>>2]|0)+(j<<2)|0;k=f[g>>2]|0;while(1){l=f[k>>2]|0;if((l|0)==(d|0))break;else k=l}if((k|0)!=(a+8|0)){l=f[k+4>>2]|0;if(!i)if(l>>>0>>0)m=l;else m=(l>>>0)%(e>>>0)|0;else m=l&h;if((m|0)==(j|0)){n=c;o=21}else o=13}else o=13;do if((o|0)==13){if(c|0){m=f[c+4>>2]|0;if(!i)if(m>>>0>>0)p=m;else p=(m>>>0)%(e>>>0)|0;else p=m&h;if((p|0)==(j|0)){q=c;r=c;o=22;break}}f[g>>2]=0;n=f[d>>2]|0;o=21}while(0);if((o|0)==21){g=n;if(!n)s=g;else{q=n;r=g;o=22}}if((o|0)==22){o=f[q+4>>2]|0;if(!i)if(o>>>0>>0)t=o;else t=(o>>>0)%(e>>>0)|0;else t=o&h;if((t|0)==(j|0))s=r;else{f[(f[a>>2]|0)+(t<<2)>>2]=k;s=f[d>>2]|0}}f[k>>2]=s;f[d>>2]=0;s=a+12|0;f[s>>2]=(f[s>>2]|0)+-1;if(!d)return c|0;s=d+8|0;a=f[d+20>>2]|0;if(a|0){k=d+24|0;if((f[k>>2]|0)!=(a|0))f[k>>2]=a;dn(a)}if((b[s+11>>0]|0)<0)dn(f[s>>2]|0);dn(d);return c|0}function ed(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+32|0;d=c+12|0;e=c;g=b*3|0;f[d>>2]=0;h=d+4|0;f[h>>2]=0;f[d+8>>2]=0;do if(g)if(g>>>0>1073741823)um(d);else{i=b*12|0;j=bj(i)|0;f[d>>2]=j;k=j+(g<<2)|0;f[d+8>>2]=k;Vf(j|0,0,i|0)|0;f[h>>2]=k;l=j;break}else l=0;while(0);if(Qf(g,1,f[a+32>>2]|0,l)|0)if(!b)m=1;else{l=a+44|0;a=e+4|0;g=e+8|0;j=0;k=0;i=0;while(1){f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;n=f[d>>2]|0;o=f[n+(k<<2)>>2]|0;p=o>>>1;q=((o&1|0)==0?p:0-p|0)+i|0;f[e>>2]=q;p=f[n+(k+1<<2)>>2]|0;o=p>>>1;r=((p&1|0)==0?o:0-o|0)+q|0;f[a>>2]=r;q=f[n+(k+2<<2)>>2]|0;n=q>>>1;i=((q&1|0)==0?n:0-n|0)+r|0;f[g>>2]=i;r=f[l>>2]|0;n=r+100|0;q=f[n>>2]|0;if((q|0)==(f[r+104>>2]|0))cf(r+96|0,e);else{f[q>>2]=f[e>>2];f[q+4>>2]=f[e+4>>2];f[q+8>>2]=f[e+8>>2];f[n>>2]=(f[n>>2]|0)+12}j=j+1|0;if(j>>>0>=b>>>0){m=1;break}else k=k+3|0}}else m=0;k=f[d>>2]|0;if(!k){u=c;return m|0}d=f[h>>2]|0;if((d|0)!=(k|0))f[h>>2]=d+(~((d+-4-k|0)>>>2)<<2);dn(k);u=c;return m|0}function fd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ae(i,h-m|0,2384);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+80|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function gd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;c=u;u=u+32|0;d=c;e=a+8|0;g=f[e>>2]|0;h=a+4|0;i=f[h>>2]|0;j=i;if(g-i>>2>>>0>=b>>>0){Vf(i|0,0,b<<2|0)|0;f[h>>2]=i+(b<<2);u=c;return}k=f[a>>2]|0;l=i-k>>2;m=l+b|0;n=k;if(m>>>0>1073741823)um(a);o=g-k|0;p=o>>1;q=o>>2>>>0<536870911?(p>>>0>>0?m:p):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(q)if(q>>>0>1073741823){p=ra(8)|0;Yk(p,9789);f[p>>2]=3704;va(p|0,856,80)}else{r=bj(q<<2)|0;break}else r=0;while(0);f[d>>2]=r;p=r+(l<<2)|0;l=d+8|0;m=d+4|0;f[m>>2]=p;o=r+(q<<2)|0;q=d+12|0;f[q>>2]=o;r=p+(b<<2)|0;Vf(p|0,0,b<<2|0)|0;f[l>>2]=r;if((j|0)==(n|0)){s=p;t=q;v=l;w=k;x=r;y=i;z=o;A=g}else{g=j;j=p;do{g=g+-4|0;p=f[g>>2]|0;f[g>>2]=0;f[j+-4>>2]=p;j=(f[m>>2]|0)+-4|0;f[m>>2]=j}while((g|0)!=(n|0));s=j;t=q;v=l;w=f[a>>2]|0;x=f[l>>2]|0;y=f[h>>2]|0;z=f[q>>2]|0;A=f[e>>2]|0}f[a>>2]=s;f[m>>2]=w;f[h>>2]=x;f[v>>2]=y;f[e>>2]=z;f[t>>2]=A;f[d>>2]=w;Se(d);u=c;return}function hd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+112|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ae(i,h-m|0,2384);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+116|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function id(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g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]|0;d=g+16|0;e=d;n=f[e>>2]|0;j=Rj(n|0,f[e+4>>2]|0,4,0)|0;e=I;if((m|0)<(e|0)|(m|0)==(e|0)&c>>>0>>0){o=0;return o|0}j=a+32|0;c=(f[g>>2]|0)+n|0;n=h[c>>0]|h[c+1>>0]<<8|h[c+2>>0]<<16|h[c+3>>0]<<24;b[j>>0]=n;b[j+1>>0]=n>>8;b[j+2>>0]=n>>16;b[j+3>>0]=n>>24;n=d;j=Rj(f[n>>2]|0,f[n+4>>2]|0,4,0)|0;n=d;f[n>>2]=j;f[n+4>>2]=I;n=f[i>>2]|0;i=n+8|0;j=f[i+4>>2]|0;d=n+16|0;c=d;g=f[c>>2]|0;e=f[c+4>>2]|0;if(!((j|0)>(e|0)|((j|0)==(e|0)?(f[i>>2]|0)>>>0>g>>>0:0))){o=0;return o|0}i=b[(f[n>>2]|0)+g>>0]|0;n=Rj(g|0,e|0,1,0)|0;e=d;f[e>>2]=n;f[e+4>>2]=I;if((i&255)>31){o=0;return o|0}f[a+24>>2]=i&255;o=1;return o|0}function ld(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(((d-g|0)/12|0)>>>0>=b>>>0){Vf(g|0,0,b*12|0)|0;f[e>>2]=h+(b*12|0);return}i=f[a>>2]|0;j=(g-i|0)/12|0;g=j+b|0;k=i;if(g>>>0>357913941)um(a);l=(d-i|0)/12|0;d=l<<1;m=l>>>0<178956970?(d>>>0>>0?g:d):357913941;do if(m)if(m>>>0>357913941){d=ra(8)|0;Yk(d,9789);f[d>>2]=3704;va(d|0,856,80)}else{n=bj(m*12|0)|0;break}else n=0;while(0);d=n+(j*12|0)|0;j=d;g=n+(m*12|0)|0;Vf(d|0,0,b*12|0)|0;m=d+(b*12|0)|0;if((h|0)==(k|0)){o=j;p=i;q=h}else{i=h;h=j;j=d;do{d=j+-12|0;b=i;i=i+-12|0;f[d>>2]=0;n=j+-8|0;f[n>>2]=0;f[j+-4>>2]=0;f[d>>2]=f[i>>2];d=b+-8|0;f[n>>2]=f[d>>2];n=b+-4|0;f[j+-4>>2]=f[n>>2];f[n>>2]=0;f[d>>2]=0;f[i>>2]=0;j=h+-12|0;h=j}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=g;g=p;if((q|0)!=(g|0)){c=q;do{q=c;c=c+-12|0;m=f[c>>2]|0;if(m|0){e=q+-8|0;q=f[e>>2]|0;if((q|0)!=(m|0))f[e>>2]=q+(~((q+-4-m|0)>>>2)<<2);dn(m)}}while((c|0)!=(g|0))}if(!p)return;dn(p);return}function md(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;g=u;u=u+80|0;h=g;i=g+60|0;j=g+40|0;k=h;l=d;m=k+40|0;do{f[k>>2]=f[l>>2];k=k+4|0;l=l+4|0}while((k|0)<(m|0));Hb(a,h,i);if(f[a>>2]|0){u=g;return}h=a+4|0;n=h+11|0;if((b[n>>0]|0)<0)dn(f[h>>2]|0);if((b[i+7>>0]|0)!=1){f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;o=bj(32)|0;f[j>>2]=o;f[j+8>>2]=-2147483616;f[j+4>>2]=20;k=o;l=8387;m=k+20|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[o+20>>0]=0;f[a>>2]=-1;Rf(h,j);if((b[j+11>>0]|0)<0)dn(f[j>>2]|0);u=g;return}Me(j,b[i+8>>0]|0);i=f[j>>2]|0;if(!i){o=j+16|0;l=f[o>>2]|0;f[o>>2]=0;mi(a,l,c,d,e);if(!(f[a>>2]|0)){if((b[n>>0]|0)<0)dn(f[h>>2]|0);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0}if(l|0)Sa[f[(f[l>>2]|0)+4>>2]&127](l)}else{f[a>>2]=i;Rf(h,j+4|0)}h=j+16|0;i=f[h>>2]|0;f[h>>2]=0;if(i|0)Sa[f[(f[i>>2]|0)+4>>2]&127](i);i=j+4|0;if((b[i+11>>0]|0)<0)dn(f[i>>2]|0);u=g;return}function nd(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;Eg(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+100|0;h=f[e>>2]|0;i=(f[h+28>>2]|0)-(f[h+24>>2]|0)>>2;f[c>>2]=0;h=a+104|0;j=f[h>>2]|0;k=f[g>>2]|0;l=j-k>>2;m=k;k=j;if(i>>>0<=l>>>0){if(i>>>0>>0?(j=m+(i<<2)|0,(j|0)!=(k|0)):0)f[h>>2]=k+(~((k+-4-j|0)>>>2)<<2)}else Ae(g,i-l|0,c);l=a+120|0;a=f[l>>2]|0;if(!a){i=f[e>>2]|0;g=(f[i+4>>2]|0)-(f[i>>2]|0)>>2;i=(g>>>0)/3|0;if(g>>>0<=2){u=b;return 1}g=0;do{f[d>>2]=g*3;f[c>>2]=f[d>>2];lb(e,c);g=g+1|0}while((g|0)<(i|0));u=b;return 1}else{i=f[a>>2]|0;if((f[a+4>>2]|0)==(i|0)){u=b;return 1}a=0;g=i;do{f[d>>2]=f[g+(a<<2)>>2];f[c>>2]=f[d>>2];lb(e,c);a=a+1|0;i=f[l>>2]|0;g=f[i>>2]|0}while(a>>>0<(f[i+4>>2]|0)-g>>2>>>0);u=b;return 1}return 0}function od(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+48|0;e=d+40|0;g=d+32|0;h=d+8|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);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=((c+-4-o|0)>>>2)+1|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+(p<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);dn(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)um(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)um(a);h=bj(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=((c+-4-d|0)>>>2)+1|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+(p<<2);return}function qd(a,b,c){a=a|0;b=b|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=b;g=c-e|0;h=g>>1;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>1>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>1;o=h>>>0>n>>>0;p=b+(n<<1)|0;n=o?p:c;q=n;r=q-e|0;s=r>>1;if(s|0)qi(k|0,b|0,r|0)|0;r=l+(s<<1)|0;if(!o){o=f[m>>2]|0;if((o|0)==(r|0))return;f[m>>2]=o+(~((o+-2-r|0)>>>1)<<1);return}if((n|0)==(c|0))return;n=f[m>>2]|0;r=c+-2-q|0;q=p;p=n;while(1){d[p>>1]=d[q>>1]|0;q=q+2|0;if((q|0)==(c|0))break;else p=p+2|0}f[m>>2]=n+((r>>>1)+1<<1);return}r=k;if(!k)t=j;else{j=a+4|0;n=f[j>>2]|0;if((n|0)!=(l|0))f[j>>2]=n+(~((n+-2-k|0)>>>1)<<1);dn(r);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;t=0}if((g|0)<0)um(a);g=t>>1>>>0<1073741823?(t>>>0>>0?h:t):2147483647;if((g|0)<0)um(a);t=bj(g<<1)|0;h=a+4|0;f[h>>2]=t;f[a>>2]=t;f[i>>2]=t+(g<<1);if((b|0)==(c|0))return;g=c+-2-e|0;e=b;b=t;while(1){d[b>>1]=d[e>>1]|0;e=e+2|0;if((e|0)==(c|0))break;else b=b+2|0}f[h>>2]=t+((g>>>1)+1<<1);return}function rd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)qi(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=c+-4-o|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+((p>>>2)+1<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);dn(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)um(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)um(a);h=bj(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=c+-4-d|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+((p>>>2)+1<<2);return}function sd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>2>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>2;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){f[m>>2]=f[c>>2];j=j+-1|0;if(!j)break;else m=m+4|0}}if(!l){m=h+(b<<2)|0;if((m|0)==(n|0))return;else{o=i;p=n+(~((n+-4-m|0)>>>2)<<2)|0;break}}else{m=b-k|0;j=m;q=n;while(1){f[q>>2]=f[c>>2];j=j+-1|0;if(!j)break;else q=q+4|0}o=i;p=n+(m<<2)|0;break}}else{q=g;if(!g)r=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-4-g|0)>>>2)<<2);dn(q);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;r=0}if(b>>>0>1073741823)um(a);j=r>>1;q=r>>2>>>0<536870911?(j>>>0>>0?b:j):1073741823;if(q>>>0>1073741823)um(a);j=bj(q<<2)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(q<<2);q=b;l=j;while(1){f[l>>2]=f[c>>2];q=q+-1|0;if(!q)break;else l=l+4|0}o=k;p=j+(b<<2)|0}while(0);f[o>>2]=p;return}function td(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d;g=c+8|0;i=g;j=f[i+4>>2]|0;k=c+16|0;l=k;m=f[l>>2]|0;n=f[l+4>>2]|0;if(!((j|0)>(n|0)|((j|0)==(n|0)?(f[i>>2]|0)>>>0>m>>>0:0))){o=0;u=d;return o|0}b[a+12>>0]=b[(f[c>>2]|0)+m>>0]|0;m=k;i=Rj(f[m>>2]|0,f[m+4>>2]|0,1,0)|0;m=k;f[m>>2]=i;f[m+4>>2]=I;a:do if((dg(e,c)|0?(m=f[e>>2]|0,i=g,n=k,j=f[n>>2]|0,l=f[n+4>>2]|0,n=Tj(f[i>>2]|0,f[i+4>>2]|0,j|0,l|0)|0,i=I,!((i|0)<0|(i|0)==0&n>>>0>>0)):0)?(n=(f[c>>2]|0)+j|0,(m|0)>=1):0){f[a>>2]=n;i=m+-1|0;p=n+i|0;switch((h[p>>0]|0)>>>6&3){case 0:{f[a+4>>2]=i;q=b[p>>0]&63;break}case 1:{if((m|0)<2){r=0;break a}f[a+4>>2]=m+-2;p=n+m+-2|0;q=(h[p+1>>0]|0)<<8&16128|(h[p>>0]|0);break}case 2:{if((m|0)<3){r=0;break a}f[a+4>>2]=m+-3;p=n+m+-3|0;q=(h[p+1>>0]|0)<<8|(h[p>>0]|0)|(h[p+2>>0]|0)<<16&4128768;break}default:{r=0;break a}}p=q+4096|0;f[a+8>>2]=p;if(p>>>0<1048576){p=Rj(j|0,l|0,m|0,0)|0;m=k;f[m>>2]=p;f[m+4>>2]=I;r=1}else r=0}else r=0;while(0);o=r;u=d;return o|0}function ud(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h+16|0;j=h;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Na[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Na[f[(f[b>>2]|0)+36>>2]&127](b)|0;m=Oa[f[(f[b>>2]|0)+44>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Oa[f[(f[b>>2]|0)+40>>2]&127](b,d)|0;if(!n){f[j>>2]=f[b+44>>2];f[j+4>>2]=l;f[j+12>>2]=m;f[j+8>>2]=m+12;ic(a,i,c,k,e,j,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[j>>2]=f[b+44>>2];f[j+4>>2]=n;f[j+12>>2]=m;f[j+8>>2]=m+12;hc(a,i,c,k,e,j,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function vd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c=u;u=u+16|0;d=c;e=a+76|0;g=f[e>>2]|0;h=a+80|0;i=f[h>>2]|0;if((i|0)!=(g|0))f[h>>2]=i+(~((i+-4-g|0)>>>2)<<2);f[e>>2]=0;f[h>>2]=0;f[a+84>>2]=0;if(g|0)dn(g);g=a+64|0;h=f[g>>2]|0;e=a+68|0;if((f[e>>2]|0)!=(h|0))f[e>>2]=h;f[g>>2]=0;f[e>>2]=0;f[a+72>>2]=0;if(h|0)dn(h);h=b+4|0;e=f[h>>2]|0;g=f[b>>2]|0;i=((e-g|0)/12|0)*3|0;j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=k-l>>2;n=l;l=k;k=g;if(i>>>0<=m>>>0)if(i>>>0>>0?(o=n+(i<<2)|0,(o|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-o|0)>>>2)<<2);p=e;q=g;r=k}else{p=e;q=g;r=k}else{ff(a,i-m|0);m=f[b>>2]|0;p=f[h>>2]|0;q=m;r=m}if((p|0)!=(q|0)){q=f[a>>2]|0;m=(p-r|0)/12|0;p=0;do{h=p*3|0;f[q+(h<<2)>>2]=f[r+(p*12|0)>>2];f[q+(h+1<<2)>>2]=f[r+(p*12|0)+4>>2];f[q+(h+2<<2)>>2]=f[r+(p*12|0)+8>>2];p=p+1|0}while(p>>>0>>0)}f[d>>2]=-1;if(!(zb(a,d)|0)){s=0;u=c;return s|0}ab(a,f[d>>2]|0)|0;s=1;u=c;return s|0}function wd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f[a+4>>2]=f[b+4>>2];c=a+8|0;d=b+8|0;if((a|0)==(b|0))return a|0;e=b+12|0;g=f[e>>2]|0;if(!g)h=0;else{i=a+16|0;do if(g>>>0>f[i>>2]<<5>>>0){j=f[c>>2]|0;if(!j)k=g;else{dn(j);f[c>>2]=0;f[i>>2]=0;f[a+12>>2]=0;k=f[e>>2]|0}if((k|0)<0)um(c);else{j=((k+-1|0)>>>5)+1|0;l=bj(j<<2)|0;f[c>>2]=l;f[a+12>>2]=0;f[i>>2]=j;m=f[e>>2]|0;n=l;break}}else{m=g;n=f[c>>2]|0}while(0);qi(n|0,f[d>>2]|0,((m+-1|0)>>>5<<2)+4|0)|0;h=f[e>>2]|0}f[a+12>>2]=h;h=a+20|0;e=b+20|0;m=b+24|0;b=f[m>>2]|0;if(!b)o=0;else{d=a+28|0;do if(b>>>0>f[d>>2]<<5>>>0){n=f[h>>2]|0;if(!n)p=b;else{dn(n);f[h>>2]=0;f[d>>2]=0;f[a+24>>2]=0;p=f[m>>2]|0}if((p|0)<0)um(h);else{n=((p+-1|0)>>>5)+1|0;c=bj(n<<2)|0;f[h>>2]=c;f[a+24>>2]=0;f[d>>2]=n;q=f[m>>2]|0;r=c;break}}else{q=b;r=f[h>>2]|0}while(0);qi(r|0,f[e>>2]|0,((q+-1|0)>>>5<<2)+4|0)|0;o=f[m>>2]|0}f[a+24>>2]=o;return a|0}function xd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;f[c>>2]=1;d=a+4|0;e=c+8|0;g=c+12|0;c=f[e>>2]|0;i=(f[g>>2]|0)-c|0;if(i>>>0<4294967292){Xg(e,i+4|0,0);j=f[e>>2]|0}else j=c;c=j+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[c>>0]=i;b[c+1>>0]=i>>8;b[c+2>>0]=i>>16;b[c+3>>0]=i>>24;i=a+8|0;c=a+12|0;d=f[i>>2]|0;if((f[c>>2]|0)!=(d|0)){j=0;k=d;do{d=k+(j<<2)|0;l=f[e>>2]|0;m=(f[g>>2]|0)-l|0;if(m>>>0<4294967292){Xg(e,m+4|0,0);n=f[e>>2]|0}else n=l;l=n+m|0;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[l>>0]=m;b[l+1>>0]=m>>8;b[l+2>>0]=m>>16;b[l+3>>0]=m>>24;j=j+1|0;k=f[i>>2]|0}while(j>>>0<(f[c>>2]|0)-k>>2>>>0)}k=a+20|0;a=f[e>>2]|0;c=(f[g>>2]|0)-a|0;if(c>>>0<4294967292){Xg(e,c+4|0,0);o=f[e>>2]|0;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}else{o=a;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}}function yd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=La,v=La,w=0,x=0,y=0,z=La,A=La,B=La;d=u;u=u+16|0;e=d;g=f[a+24>>2]|0;h=a+8|0;i=b[(f[h>>2]|0)+24>>0]|0;j=i<<24>>24;k=j<<2;l=an(j>>>0>1073741823?-1:j<<2)|0;yl(e);if(!(Xi(e,$(n[a+32>>2]),(1<>2]|0;o=(f[f[g>>2]>>2]|0)+(f[g+48>>2]|0)|0;if(!c){m=1;bn(l);u=d;return m|0}g=e+4|0;p=a+28|0;if(i<<24>>24>0){q=0;r=0;s=0}else{i=0;a=0;while(1){ge((f[f[(f[h>>2]|0)+64>>2]>>2]|0)+a|0,l|0,k|0)|0;i=i+1|0;if((i|0)==(c|0)){m=1;break}else a=a+k|0}bn(l);u=d;return m|0}while(1){a=f[p>>2]|0;t=$(n[g>>2]);v=$(n[e>>2]);i=0;w=r;while(1){x=f[o+(w<<2)>>2]|0;y=(x|0)<0;z=$(t*$((y?0-x|0:x)|0));A=$(-z);B=$(v*(y?A:z));z=$($(n[a+(i<<2)>>2])+B);n[l+(i<<2)>>2]=z;i=i+1|0;if((i|0)==(j|0))break;else w=w+1|0}ge((f[f[(f[h>>2]|0)+64>>2]>>2]|0)+s|0,l|0,k|0)|0;q=q+1|0;if((q|0)==(c|0)){m=1;break}else{r=r+j|0;s=s+k|0}}bn(l);u=d;return m|0}function zd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0>j-k>>2>>>0){m=k;if(!k)n=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);dn(m);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;n=0}if(h>>>0>1073741823)um(a);j=n>>1;m=n>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(m>>>0>1073741823)um(a);j=bj(m<<2)|0;n=a+4|0;f[n>>2]=j;f[a>>2]=j;f[i>>2]=j+(m<<2);if((g|0)<=0)return;ge(j|0,b|0,g|0)|0;f[n>>2]=j+(g>>>2<<2);return}g=a+4|0;a=f[g>>2]|0;j=a-k>>2;k=h>>>0>j>>>0;h=k?b+(j<<2)|0:c;c=a;j=a;if((h|0)==(b|0))p=l;else{a=h+-4-e|0;e=b;b=l;while(1){f[b>>2]=f[e>>2];e=e+4|0;if((e|0)==(h|0))break;else b=b+4|0}p=l+((a>>>2)+1<<2)|0}if(k){k=d-h|0;if((k|0)<=0)return;ge(j|0,h|0,k|0)|0;f[g>>2]=(f[g>>2]|0)+(k>>>2<<2);return}else{if((p|0)==(c|0))return;f[g>>2]=c+(~((c+-4-p|0)>>>2)<<2);return}}function Ad(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ae(i,h-m|0,2384);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=c+68|0;c=f[o+96>>2]|0;o=f[d+28>>2]|0;d=f[(f[a+80>>2]|0)+12>>2]|0;a=0;while(1){h=a*3|0;i=f[d+(f[o+(h<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}g=f[m>>2]|0;f[g+(f[c+(a*12|0)>>2]<<2)>>2]=i;i=f[d+(f[o+(h+1<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+4>>2]<<2)>>2]=i;i=f[d+(f[o+(h+2<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+8>>2]<<2)>>2]=i;a=a+1|0;if(a>>>0>=e>>>0){q=1;r=10;break}}if((r|0)==10)return q|0;return 0}function Bd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+16|0;e=d;if(!(Ff(e,c)|0)){g=0;u=d;return g|0}i=e;e=f[i>>2]|0;j=f[i+4>>2]|0;i=c+8|0;k=c+16|0;l=k;m=f[l>>2]|0;n=f[l+4>>2]|0;l=Tj(f[i>>2]|0,f[i+4>>2]|0,m|0,n|0)|0;i=I;if(j>>>0>i>>>0|(j|0)==(i|0)&e>>>0>l>>>0){g=0;u=d;return g|0}l=(f[c>>2]|0)+m|0;c=Rj(m|0,n|0,e|0,j|0)|0;j=k;f[j>>2]=c;f[j+4>>2]=I;if((e|0)<1){g=0;u=d;return g|0}f[a+40>>2]=l;j=e+-1|0;c=l+j|0;a:do switch((h[c>>0]|0)>>>6&3){case 0:{f[a+44>>2]=j;o=b[c>>0]&63;break}case 1:{if((e|0)<2){g=0;u=d;return g|0}else{f[a+44>>2]=e+-2;k=l+e+-2|0;o=(h[k+1>>0]|0)<<8&16128|(h[k>>0]|0);break a}break}case 2:{if((e|0)<3){g=0;u=d;return g|0}else{f[a+44>>2]=e+-3;k=l+e+-3|0;o=(h[k+1>>0]|0)<<8|(h[k>>0]|0)|(h[k+2>>0]|0)<<16&4128768;break a}break}case 3:{f[a+44>>2]=e+-4;k=l+e+-4|0;o=(h[k+2>>0]|0)<<16|(h[k+3>>0]|0)<<24&1056964608|(h[k+1>>0]|0)<<8|(h[k>>0]|0);break}default:{}}while(0);e=o+16384|0;f[a+48>>2]=e;g=e>>>0<4194304;u=d;return g|0}function Cd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+112|0;d=c+96|0;e=c+16|0;g=c+4|0;h=c;i=e+76|0;j=e;k=j+76|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(k|0));f[i>>2]=-1;f[g>>2]=0;i=g+4|0;f[i>>2]=0;f[g+8>>2]=0;f[h>>2]=g;f[d>>2]=f[h>>2];if(pc(e,a,d)|0){d=f[g>>2]|0;rd(b,d,d+((f[i>>2]|0)-d>>2<<2)|0);l=f[e+68>>2]|0}else l=0;d=f[g>>2]|0;if(d|0){g=f[i>>2]|0;if((g|0)!=(d|0))f[i>>2]=g+(~((g+-4-d|0)>>>2)<<2);dn(d)}d=f[e+56>>2]|0;if(d|0)dn(d);d=f[e+32>>2]|0;if(d|0){g=e+36|0;i=f[g>>2]|0;if((i|0)!=(d|0))f[g>>2]=i+(~((i+-4-d|0)>>>2)<<2);dn(d)}d=f[e+20>>2]|0;if(d|0){i=e+24|0;g=f[i>>2]|0;if((g|0)!=(d|0))f[i>>2]=g+(~((g+-4-d|0)>>>2)<<2);dn(d)}d=f[e+8>>2]|0;if(d|0){g=e+12|0;i=f[g>>2]|0;if((i|0)!=(d|0))f[g>>2]=i+(~((i+-4-d|0)>>>2)<<2);dn(d)}d=e+4|0;e=f[d>>2]|0;f[d>>2]=0;if(!e){u=c;return l|0}mf(e);dn(e);u=c;return l|0}function Dd(a,b,c,d){a=a|0;b=$(b);c=$(c);d=d|0;var e=La,f=La,g=La,h=La,i=La,j=La,k=0.0,l=La,m=La,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=La,u=La,v=0,w=0;e=$(b+c);f=$(b-c);if(!(f<=$(.5))|(!(f>=$(-.5))|(!(e>=$(.5))|!(e<=$(1.5))))){do if(!(e<=$(.5))){if(e>=$(1.5)){g=$($(1.5)-c);h=$($(1.5)-b);break}if(!(f<=$(-.5))){g=$(c+$(.5));h=$(b+$(-.5));break}else{g=$(c+$(-.5));h=$(b+$(.5));break}}else{g=$($(.5)-c);h=$($(.5)-b)}while(0);i=$(h+g);j=$(g-h);k=-1.0;l=g;m=h}else{i=e;j=f;k=1.0;l=b;m=c}c=$(+l*2.0+-1.0);l=$(+m*2.0+-1.0);o=+i*2.0;p=o+-1.0;q=3.0-o;o=+j*2.0;r=o+1.0;s=1.0-o;o=s>2]=$(0.0);t=$(0.0);u=$(0.0);v=d+4|0;n[v>>2]=u;w=d+8|0;n[w>>2]=t;return}else{m=$($(1.0)/$(L($(i))));i=$(m*j);n[d>>2]=i;t=$(m*l);u=$(m*c);v=d+4|0;n[v>>2]=u;w=d+8|0;n[w>>2]=t;return}}function Ed(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=c&255;g=(d|0)!=0;a:do if(g&(a&3|0)!=0){h=c&255;i=a;j=d;while(1){if((b[i>>0]|0)==h<<24>>24){k=i;l=j;m=6;break a}n=i+1|0;o=j+-1|0;p=(o|0)!=0;if(p&(n&3|0)!=0){i=n;j=o}else{q=n;r=o;s=p;m=5;break}}}else{q=a;r=d;s=g;m=5}while(0);if((m|0)==5)if(s){k=q;l=r;m=6}else{t=q;u=0}b:do if((m|0)==6){q=c&255;if((b[k>>0]|0)==q<<24>>24){t=k;u=l}else{r=X(e,16843009)|0;c:do if(l>>>0>3){s=k;g=l;while(1){d=f[s>>2]^r;if((d&-2139062144^-2139062144)&d+-16843009|0)break;d=s+4|0;a=g+-4|0;if(a>>>0>3){s=d;g=a}else{v=d;w=a;m=11;break c}}x=s;y=g}else{v=k;w=l;m=11}while(0);if((m|0)==11)if(!w){t=v;u=0;break}else{x=v;y=w}while(1){if((b[x>>0]|0)==q<<24>>24){t=x;u=y;break b}r=x+1|0;y=y+-1|0;if(!y){t=r;u=0;break}else x=r}}}while(0);return (u|0?t:0)|0}function Fd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;e=u;u=u+16|0;g=e;h=d+8|0;i=f[h>>2]|0;j=f[h+4>>2]|0;h=d+16|0;k=h;l=f[k>>2]|0;m=f[k+4>>2]|0;if((j|0)>(m|0)|(j|0)==(m|0)&i>>>0>l>>>0){k=b[(f[d>>2]|0)+l>>0]|0;n=Rj(l|0,m|0,1,0)|0;o=I;p=h;f[p>>2]=n;f[p+4>>2]=o;if(k<<24>>24!=-2){q=k;r=o;s=n;t=3}}else{q=0;r=m;s=l;t=3}if((t|0)==3){if((j|0)>(r|0)|(j|0)==(r|0)&i>>>0>s>>>0){i=b[(f[d>>2]|0)+s>>0]|0;j=Rj(s|0,r|0,1,0)|0;r=h;f[r>>2]=j;f[r+4>>2]=I;v=i}else v=0;Va[f[(f[a>>2]|0)+40>>2]&7](g,a,q<<24>>24,v<<24>>24);v=a+20|0;q=f[g>>2]|0;f[g>>2]=0;i=f[v>>2]|0;f[v>>2]=q;if(i){Sa[f[(f[i>>2]|0)+4>>2]&127](i);i=f[g>>2]|0;f[g>>2]=0;if(i|0)Sa[f[(f[i>>2]|0)+4>>2]&127](i)}else f[g>>2]=0}g=f[a+20>>2]|0;if(g|0?!(Oa[f[(f[a>>2]|0)+28>>2]&127](a,g)|0):0){w=0;u=e;return w|0}w=Pa[f[(f[a>>2]|0)+36>>2]&31](a,c,d)|0;u=e;return w|0}function Gd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=a+4|0;g=f[e>>2]|0;if(!g){f[c>>2]=e;h=e;return h|0}e=b[d+11>>0]|0;i=e<<24>>24<0;j=i?f[d+4>>2]|0:e&255;e=i?f[d>>2]|0:d;d=a+4|0;a=g;while(1){g=a+16|0;i=b[g+11>>0]|0;k=i<<24>>24<0;l=k?f[a+20>>2]|0:i&255;i=l>>>0>>0;m=i?l:j;if((m|0)!=0?(n=jh(e,k?f[g>>2]|0:g,m)|0,(n|0)!=0):0)if((n|0)<0)o=8;else o=10;else if(j>>>0>>0)o=8;else o=10;if((o|0)==8){o=0;n=f[a>>2]|0;if(!n){o=9;break}else{p=a;q=n}}else if((o|0)==10){o=0;n=j>>>0>>0?j:l;if((n|0)!=0?(l=jh(k?f[g>>2]|0:g,e,n)|0,(l|0)!=0):0){if((l|0)>=0){o=16;break}}else o=12;if((o|0)==12?(o=0,!i):0){o=16;break}r=a+4|0;i=f[r>>2]|0;if(!i){o=15;break}else{p=r;q=i}}d=p;a=q}if((o|0)==9){f[c>>2]=a;h=a;return h|0}else if((o|0)==15){f[c>>2]=a;h=r;return h|0}else if((o|0)==16){f[c>>2]=a;h=d;return h|0}return 0}function Hd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;d=u;u=u+32|0;e=d+24|0;g=d+16|0;h=d+8|0;i=d;j=a+4|0;k=f[j>>2]|0;l=f[b>>2]|0;m=f[b+4>>2]|0;b=f[c>>2]|0;n=f[c+4>>2]|0;c=b-l<<3;f[j>>2]=k-m+n+c;j=(f[a>>2]|0)+(k>>>5<<2)|0;a=k&31;k=j;if((m|0)!=(a|0)){f[e>>2]=l;f[e+4>>2]=m;f[g>>2]=b;f[g+4>>2]=n;f[h>>2]=k;f[h+4>>2]=a;Ec(i,e,g,h);u=d;return}h=n-m+c|0;c=l;if((h|0)>0){if(!m){o=h;p=j;q=0;r=l;s=c}else{l=32-m|0;n=(h|0)<(l|0)?h:l;g=-1>>>(l-n|0)&-1<>2]=f[j>>2]&~g|f[c>>2]&g;g=n+m|0;l=c+4|0;o=h-n|0;p=j+(g>>>5<<2)|0;q=g&31;r=l;s=l}l=(o|0)/32|0;qi(p|0,r|0,l<<2|0)|0;r=o-(l<<5)|0;o=p+(l<<2)|0;p=o;if((r|0)>0){g=-1>>>(32-r|0);f[o>>2]=f[o>>2]&~g|f[s+(l<<2)>>2]&g;t=r;v=p}else{t=q;v=p}}else{t=m;v=k}f[i>>2]=v;f[i+4>>2]=t;u=d;return}function Id(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;e=u;u=u+32|0;g=e+12|0;h=e;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=gg(c)|0;if(i>>>0>4294967279)um(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=6}}else{m=i+16&-16;n=bj(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=6}if((l|0)==6){ge(k|0,c|0,i|0)|0;j=k}b[j+i>>0]=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=gg(d)|0;if(i>>>0>4294967279)um(h);if(i>>>0<11){b[h+11>>0]=i;if(!i)o=h;else{p=h;l=12}}else{j=i+16&-16;k=bj(j)|0;f[h>>2]=k;f[h+8>>2]=j|-2147483648;f[h+4>>2]=i;p=k;l=12}if((l|0)==12){ge(p|0,d|0,i|0)|0;o=p}b[o+i>>0]=0;i=f[a+4>>2]|0;if((i|0)!=0?(o=Mc(i,g,h)|0,(o|0)!=0):0)q=ih(a,f[o+40>>2]|0)|0;else q=-1;if((b[h+11>>0]|0)<0)dn(f[h>>2]|0);if((b[g+11>>0]|0)>=0){u=e;return q|0}dn(f[g>>2]|0);u=e;return q|0}function Jd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;dn(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)um(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)um(a);i=bj(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=c;o=i}do{b[o>>0]=b[n>>0]|0;n=n+1|0;o=(f[l>>2]|0)+1|0;f[l>>2]=o}while((n|0)!=(d|0));return}else{n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;o=a-e|0;if(o|0)qi(k|0,c|0,o|0)|0;c=k+o|0;if(!j){if((f[n>>2]|0)==(c|0))return;f[n>>2]=c;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}}function Kd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){Vf(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}i=f[a>>2]|0;j=g-i>>2;g=j+b|0;k=i;if(g>>>0>1073741823)um(a);l=d-i|0;d=l>>1;m=l>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(m)if(m>>>0>1073741823){d=ra(8)|0;Yk(d,9789);f[d>>2]=3704;va(d|0,856,80)}else{n=bj(m<<2)|0;break}else n=0;while(0);d=n+(j<<2)|0;Vf(d|0,0,b<<2|0)|0;b=d;j=n+(m<<2)|0;m=n+(g<<2)|0;if((h|0)==(k|0)){o=b;p=i;q=h}else{i=h;h=b;b=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[b+-4>>2]=d;b=h+-4|0;h=b}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=j;j=p;if((q|0)!=(j|0)){c=q;do{c=c+-4|0;q=f[c>>2]|0;f[c>>2]=0;if(q|0)Sa[f[(f[q>>2]|0)+4>>2]&127](q)}while((c|0)!=(j|0))}if(!p)return;dn(p);return}function Ld(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+4|0;e=f[a>>2]|0;g=((f[d>>2]|0)-e|0)/12|0;h=g+1|0;if(h>>>0>357913941)um(a);i=a+8|0;j=((f[i>>2]|0)-e|0)/12|0;e=j<<1;k=j>>>0<178956970?(e>>>0>>0?h:e):357913941;do if(k)if(k>>>0>357913941){e=ra(8)|0;Yk(e,9789);f[e>>2]=3704;va(e|0,856,80)}else{l=bj(k*12|0)|0;break}else l=0;while(0);e=l+(g*12|0)|0;g=e;h=l+(k*12|0)|0;Rf(e,c);c=e+12|0;k=f[a>>2]|0;l=f[d>>2]|0;if((l|0)==(k|0)){m=g;n=k;o=k}else{j=l;l=g;g=e;do{e=g+-12|0;j=j+-12|0;f[e>>2]=f[j>>2];f[e+4>>2]=f[j+4>>2];f[e+8>>2]=f[j+8>>2];f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;g=l+-12|0;l=g}while((j|0)!=(k|0));m=l;n=f[a>>2]|0;o=f[d>>2]|0}f[a>>2]=m;f[d>>2]=c;f[i>>2]=h;h=n;if((o|0)!=(h|0)){i=o;do{i=i+-12|0;if((b[i+11>>0]|0)<0)dn(f[i>>2]|0)}while((i|0)!=(h|0))}if(!n)return;dn(n);return}function Md(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>2>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>2;o=h>>>0>n>>>0;p=o?b+(n<<2)|0:c;c=p;n=c-e|0;e=n>>2;if(e|0)qi(k|0,b|0,n|0)|0;n=l+(e<<2)|0;if(o){o=d-c|0;if((o|0)<=0)return;ge(f[m>>2]|0,p|0,o|0)|0;f[m>>2]=(f[m>>2]|0)+(o>>>2<<2);return}else{o=f[m>>2]|0;if((o|0)==(n|0))return;f[m>>2]=o+(~((o+-4-n|0)>>>2)<<2);return}}n=k;if(!k)q=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);dn(n);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;q=0}if(h>>>0>1073741823)um(a);j=q>>1;n=q>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(n>>>0>1073741823)um(a);j=bj(n<<2)|0;h=a+4|0;f[h>>2]=j;f[a>>2]=j;f[i>>2]=j+(n<<2);if((g|0)<=0)return;ge(j|0,b|0,g|0)|0;f[h>>2]=j+(g>>>2<<2);return}function Nd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;e=bj(64)|0;g=bj(12)|0;h=f[(f[a+4>>2]|0)+80>>2]|0;f[g+4>>2]=0;f[g>>2]=2592;f[g+8>>2]=h;f[d>>2]=g;Ah(e,d);g=e;if((b|0)>=0){h=a+8|0;i=a+12|0;a=f[i>>2]|0;j=f[h>>2]|0;k=a-j>>2;do if((k|0)<=(b|0)){l=b+1|0;m=a;if(l>>>0>k>>>0){Kd(h,l-k|0);break}if(l>>>0>>0?(n=j+(l<<2)|0,(n|0)!=(m|0)):0){l=m;do{m=l+-4|0;f[i>>2]=m;o=f[m>>2]|0;f[m>>2]=0;if(o|0)Sa[f[(f[o>>2]|0)+4>>2]&127](o);l=f[i>>2]|0}while((l|0)!=(n|0))}}while(0);i=(f[h>>2]|0)+(b<<2)|0;b=f[i>>2]|0;f[i>>2]=g;if(!b)p=1;else{Sa[f[(f[b>>2]|0)+4>>2]&127](b);p=1}}else{Sa[f[(f[e>>2]|0)+4>>2]&127](e);p=0}e=f[d>>2]|0;f[d>>2]=0;if(!e){u=c;return p|0}Sa[f[(f[e>>2]|0)+4>>2]&127](e);u=c;return p|0}function Od(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=f[b>>2]|0;do if((c|0)!=-1){b=f[(f[(f[a+4>>2]|0)+12>>2]|0)+(c<<2)>>2]|0;d=c+1|0;e=((d>>>0)%3|0|0)==0?c+-2|0:d;if((e|0)==-1)g=-1;else g=f[(f[(f[a>>2]|0)+96>>2]|0)+(((e|0)/3|0)*12|0)+(((e|0)%3|0)<<2)>>2]|0;if((b|0)!=-1){e=(((b>>>0)%3|0|0)==0?2:-1)+b|0;if((e|0)==-1){h=-1;i=b;j=0}else{h=f[(f[(f[a>>2]|0)+96>>2]|0)+(((e|0)/3|0)*12|0)+(((e|0)%3|0)<<2)>>2]|0;i=b;j=0}}else{h=-1;i=-1;j=1}if((g|0)!=(h|0)){k=-1;return k|0}b=(((c>>>0)%3|0|0)==0?2:-1)+c|0;if((b|0)==-1)if(j){l=-1;m=-1;n=i;break}else o=-1;else{e=f[(f[(f[a>>2]|0)+96>>2]|0)+(((b|0)/3|0)*12|0)+(((b|0)%3|0)<<2)>>2]|0;if(j){l=-1;m=e;n=i;break}else o=e}e=i+1|0;b=((e>>>0)%3|0|0)==0?i+-2|0:e;if((b|0)==-1){l=-1;m=o;n=i}else{l=f[(f[(f[a>>2]|0)+96>>2]|0)+(((b|0)/3|0)*12|0)+(((b|0)%3|0)<<2)>>2]|0;m=o;n=i}}else{l=-1;m=-1;n=-1}while(0);k=(m|0)!=(l|0)?-1:n;return k|0}function Pd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+20|0;if(cc(e,c)|0){g=0;return g|0}a=Db(e,c)|0;c=f[d>>2]|0;f[d>>2]=0;d=f[a>>2]|0;f[a>>2]=c;if(!d){g=1;return g|0}c=f[d+28>>2]|0;if(c|0){a=c;do{c=a;a=f[a>>2]|0;Ye(c+8|0);dn(c)}while((a|0)!=0)}a=d+20|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0)dn(c);c=f[d+8>>2]|0;if(c|0){a=c;do{c=a;a=f[a>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;dn(h)}if((b[e+11>>0]|0)<0)dn(f[e>>2]|0);dn(c)}while((a|0)!=0)}a=f[d>>2]|0;f[d>>2]=0;if(a|0)dn(a);dn(d);g=1;return g|0}function Qd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;f[e>>2]=b;g=a+8|0;if(((f[a+12>>2]|0)-(f[g>>2]|0)>>2|0)<=(b|0))ze(g,b+1|0);h=f[(f[c>>2]|0)+56>>2]|0;do if((h|0)<5){i=a+20+(h*12|0)+4|0;j=f[i>>2]|0;if((j|0)==(f[a+20+(h*12|0)+8>>2]|0)){xf(a+20+(h*12|0)|0,e);break}else{f[j>>2]=b;f[i>>2]=j+4;break}}while(0);b=f[c>>2]|0;h=f[e>>2]|0;f[b+60>>2]=h;e=(f[g>>2]|0)+(h<<2)|0;f[c>>2]=0;c=f[e>>2]|0;f[e>>2]=b;if(!c){u=d;return}b=c+88|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0){b=f[e+8>>2]|0;if(b|0){h=e+12|0;if((f[h>>2]|0)!=(b|0))f[h>>2]=b;dn(b)}dn(e)}e=f[c+68>>2]|0;if(e|0){b=c+72|0;h=f[b>>2]|0;if((h|0)!=(e|0))f[b>>2]=h+(~((h+-4-e|0)>>>2)<<2);dn(e)}e=c+64|0;h=f[e>>2]|0;f[e>>2]=0;if(h|0){e=f[h>>2]|0;if(e|0){b=h+4|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;dn(e)}dn(h)}dn(c);u=d;return}function Rd(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;Eg(f[a+4>>2]|0,(f[g+56>>2]|0)-(f[g+52>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[(f[e>>2]|0)+64>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];tb(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];tb(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Sd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;d=u;u=u+48|0;e=d+16|0;g=d;h=d+32|0;i=a+28|0;j=f[i>>2]|0;f[h>>2]=j;k=a+20|0;l=(f[k>>2]|0)-j|0;f[h+4>>2]=l;f[h+8>>2]=b;f[h+12>>2]=c;b=l+c|0;l=a+60|0;f[g>>2]=f[l>>2];f[g+4>>2]=h;f[g+8>>2]=2;j=ik(Aa(146,g|0)|0)|0;a:do if((b|0)!=(j|0)){g=2;m=b;n=h;o=j;while(1){if((o|0)<0)break;m=m-o|0;p=f[n+4>>2]|0;q=o>>>0>p>>>0;r=q?n+8|0:n;s=g+(q<<31>>31)|0;t=o-(q?p:0)|0;f[r>>2]=(f[r>>2]|0)+t;p=r+4|0;f[p>>2]=(f[p>>2]|0)-t;f[e>>2]=f[l>>2];f[e+4>>2]=r;f[e+8>>2]=s;o=ik(Aa(146,e|0)|0)|0;if((m|0)==(o|0)){v=3;break a}else{g=s;n=r}}f[a+16>>2]=0;f[i>>2]=0;f[k>>2]=0;f[a>>2]=f[a>>2]|32;if((g|0)==2)w=0;else w=c-(f[n+4>>2]|0)|0}else v=3;while(0);if((v|0)==3){v=f[a+44>>2]|0;f[a+16>>2]=v+(f[a+48>>2]|0);a=v;f[i>>2]=a;f[k>>2]=a;w=c}u=d;return w|0}function Td(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=2696;b=f[a+68>>2]|0;if(b|0){c=a+72|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+56>>2]|0;if(b|0){d=a+60|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+44>>2]|0;if(b|0){c=a+48|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+32>>2]|0;if(b|0){d=a+36|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}Qe(a+8|0);b=a+4|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+40|0;d=f[b>>2]|0;if(d|0){c=a+44|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){Cf(i);dn(i)}h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}dn(g)}Cf(a);dn(a);return}function Ud(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if(((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(f[(f[d>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0)==0:0)?(j=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if(((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(f[(f[d>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)==0:0)?(k=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if((((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(f[(f[d>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0:0)?(h=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Vd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+4|0;a=f[d>>2]|0;do if(a|0){e=b[c+11>>0]|0;g=e<<24>>24<0;h=g?f[c+4>>2]|0:e&255;e=g?f[c>>2]|0:c;g=d;i=a;a:while(1){j=i;while(1){k=j+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[j+20>>2]|0:l&255;l=h>>>0>>0?h:n;if((l|0)!=0?(o=jh(m?f[k>>2]|0:k,e,l)|0,(o|0)!=0):0){if((o|0)>=0)break}else p=6;if((p|0)==6?(p=0,n>>>0>=h>>>0):0)break;n=f[j+4>>2]|0;if(!n){q=g;break a}else j=n}i=f[j>>2]|0;if(!i){q=j;break}else g=j}if((q|0)!=(d|0)){g=q+16|0;i=b[g+11>>0]|0;n=i<<24>>24<0;o=n?f[q+20>>2]|0:i&255;i=o>>>0>>0?o:h;if(i|0?(l=jh(e,n?f[g>>2]|0:g,i)|0,l|0):0){if((l|0)<0)break;else r=q;return r|0}if(h>>>0>=o>>>0){r=q;return r|0}}}while(0);r=d;return r|0}function Wd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=a+8|0;f[c>>2]=f[b>>2];wd(a+12|0,b+4|0)|0;d=a+44|0;e=b+36|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];if((c|0)==(b|0)){f[a+96>>2]=f[b+88>>2];return}else{zd(a+60|0,f[b+52>>2]|0,f[b+56>>2]|0);zd(a+72|0,f[b+64>>2]|0,f[b+68>>2]|0);zd(a+84|0,f[b+76>>2]|0,f[b+80>>2]|0);f[a+96>>2]=f[b+88>>2];Md(a+100|0,f[b+92>>2]|0,f[b+96>>2]|0);return}}function Xd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=u;u=u+32|0;g=e+8|0;i=e;if((d|0)!=3){f[a>>2]=0;u=e;return}d=f[b+12>>2]|0;j=f[b+4>>2]|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;a:do if((c|0)==-2){k=0;l=8}else{b=f[(f[(f[j+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((Na[f[(f[j>>2]|0)+8>>2]&127](j)|0)==1){Oc(i,j,c,d,g,((h[j+36>>0]|0)<<8|(h[j+37>>0]|0))&65535);m=f[i>>2]|0;if(!m){f[i>>2]=0;break}else{n=i;o=m;break a}}while(0);m=bj(24)|0;f[m+4>>2]=b;p=m+8|0;f[p>>2]=f[g>>2];f[p+4>>2]=f[g+4>>2];f[p+8>>2]=f[g+8>>2];f[p+12>>2]=f[g+12>>2];f[m>>2]=1884;k=m;l=8}while(0);if((l|0)==8){f[i>>2]=k;n=i;o=k}f[a>>2]=o;f[n>>2]=0;u=e;return}function Yd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/12|0)>>>0>=b>>>0){i=b;j=h;do{f[j>>2]=f[c>>2];f[j+4>>2]=f[c+4>>2];f[j+8>>2]=f[c+8>>2];j=(f[g>>2]|0)+12|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/12|0;h=j+b|0;if(h>>>0>357913941)um(a);k=(e-i|0)/12|0;i=k<<1;e=k>>>0<178956970?(i>>>0>>0?h:i):357913941;do if(e)if(e>>>0>357913941){i=ra(8)|0;Yk(i,9789);f[i>>2]=3704;va(i|0,856,80)}else{l=bj(e*12|0)|0;break}else l=0;while(0);i=l+(j*12|0)|0;j=l+(e*12|0)|0;e=b;b=i;l=i;do{f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];b=l+12|0;l=b;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;b=(f[g>>2]|0)-e|0;c=i+(((b|0)/-12|0)*12|0)|0;if((b|0)>0)ge(c|0,e|0,b|0)|0;f[a>>2]=c;f[g>>2]=l;f[d>>2]=j;if(!e)return;dn(e);return}function Zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)um(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Yk(d,9789);f[d>>2]=3704;va(d|0,856,80)}else{k=bj(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0){Cf(n);dn(n)}}while((h|0)!=(g|0))}if(!m)return;dn(m);return}function _d(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+80|0;g=e;h=e+64|0;Qh(g);i=f[(f[a+8>>2]|0)+56>>2]|0;j=X(ai(5)|0,d)|0;jg(g,i,0,d&255,5,0,j,((j|0)<0)<<31>>31,0,0);j=bj(96)|0;Eh(j,g);b[j+84>>0]=1;g=f[j+68>>2]|0;d=j+72|0;i=f[d>>2]|0;if((i|0)!=(g|0))f[d>>2]=i+(~((i+-4-g|0)>>>2)<<2);$f(j,c)|0;f[h>>2]=j;If(a,h);a=f[h>>2]|0;f[h>>2]=0;if(!a){u=e;return}h=a+88|0;j=f[h>>2]|0;f[h>>2]=0;if(j|0){h=f[j+8>>2]|0;if(h|0){c=j+12|0;if((f[c>>2]|0)!=(h|0))f[c>>2]=h;dn(h)}dn(j)}j=f[a+68>>2]|0;if(j|0){h=a+72|0;c=f[h>>2]|0;if((c|0)!=(j|0))f[h>>2]=c+(~((c+-4-j|0)>>>2)<<2);dn(j)}j=a+64|0;c=f[j>>2]|0;f[j>>2]=0;if(c|0){j=f[c>>2]|0;if(j|0){h=c+4|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;dn(j)}dn(c)}dn(a);u=e;return}function $d(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=f[c>>2]|0;c=f[a>>2]|0;e=c+(d>>>5<<2)|0;f[e>>2]=f[e>>2]|1<<(d&31);e=f[a+64>>2]|0;g=(d|0)==-1;h=d+1|0;if(!g?(i=((h>>>0)%3|0|0)==0?d+-2|0:h,(i|0)!=-1):0)j=f[(f[e>>2]|0)+(i<<2)>>2]|0;else j=-1;i=a+12|0;h=(f[i>>2]|0)+(j>>>5<<2)|0;f[h>>2]=f[h>>2]|1<<(j&31);if(g){j=(f[i>>2]|0)+536870908|0;f[j>>2]=f[j>>2]|-2147483648;return}j=(((d>>>0)%3|0|0)==0?2:-1)+d|0;if((j|0)==-1)k=-1;else k=f[(f[e>>2]|0)+(j<<2)>>2]|0;j=(f[i>>2]|0)+(k>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(k&31);if(g)return;g=f[(f[e+12>>2]|0)+(d<<2)>>2]|0;if((g|0)==-1)return;b[a+24>>0]=0;a=c+(g>>>5<<2)|0;f[a>>2]=f[a>>2]|1<<(g&31);a=g+1|0;c=((a>>>0)%3|0|0)==0?g+-2|0:a;if((c|0)==-1)l=-1;else l=f[(f[e>>2]|0)+(c<<2)>>2]|0;c=(f[i>>2]|0)+(l>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(l&31);l=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((l|0)==-1)m=-1;else m=f[(f[e>>2]|0)+(l<<2)>>2]|0;l=(f[i>>2]|0)+(m>>>5<<2)|0;f[l>>2]=f[l>>2]|1<<(m&31);return}function ae(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;Eg(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[e>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];wb(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];wb(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function be(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+32|0;h=g+16|0;i=g+8|0;j=g;k=e>>>0>1073741823?-1:e<<2;l=an(k)|0;Vf(l|0,0,k|0)|0;k=a+8|0;a=f[l+4>>2]|0;m=f[b>>2]|0;n=f[b+4>>2]|0;f[i>>2]=f[l>>2];f[i+4>>2]=a;f[j>>2]=m;f[j+4>>2]=n;ec(h,k,i,j);f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];if((e|0)>=(d|0)){bn(l);u=g;return 1}n=0-e|0;m=i+4|0;a=j+4|0;o=h+4|0;p=e;do{q=c+(p<<2)|0;r=q+(n<<2)|0;s=b+(p<<2)|0;t=f[r+4>>2]|0;v=f[s>>2]|0;w=f[s+4>>2]|0;f[i>>2]=f[r>>2];f[m>>2]=t;f[j>>2]=v;f[a>>2]=w;ec(h,k,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[o>>2];p=p+e|0}while((p|0)<(d|0));bn(l);u=g;return 1}function ce(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[c>>2]|0;f[c>>2]=0;f[e>>2]=g;Qd(a,b,e);g=f[e>>2]|0;f[e>>2]=0;if(g|0){e=g+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){h=c+12|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;dn(e)}dn(c)}c=f[g+68>>2]|0;if(c|0){e=g+72|0;h=f[e>>2]|0;if((h|0)!=(c|0))f[e>>2]=h+(~((h+-4-c|0)>>>2)<<2);dn(c)}c=g+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){e=h+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;dn(c)}dn(h)}dn(g)}g=a+84|0;h=a+88|0;a=f[h>>2]|0;c=f[g>>2]|0;e=a-c>>2;if((e|0)>(b|0)){u=d;return}i=b+1|0;b=a;if(i>>>0>e>>>0){Ee(g,i-e|0);u=d;return}if(i>>>0>=e>>>0){u=d;return}e=c+(i<<2)|0;if((e|0)==(b|0)){u=d;return}f[h>>2]=b+(~((b+-4-e|0)>>>2)<<2);u=d;return}function de(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;j=f[g+4>>2]|0;g=Rj(i|0,j|0,4,0)|0;k=I;if((e|0)<(k|0)|(e|0)==(k|0)&d>>>0>>0){l=0;return l|0}m=f[b>>2]|0;n=m+i|0;o=h[n>>0]|h[n+1>>0]<<8|h[n+2>>0]<<16|h[n+3>>0]<<24;n=c;f[n>>2]=g;f[n+4>>2]=k;k=Rj(i|0,j|0,8,0)|0;j=I;if((e|0)<(j|0)|(e|0)==(j|0)&d>>>0>>0){l=0;return l|0}d=m+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=c;f[d>>2]=k;f[d+4>>2]=j;if((o|0)>(g|0)){l=0;return l|0}f[a+12>>2]=o;f[a+16>>2]=g;j=Tj(g|0,((g|0)<0)<<31>>31|0,o|0,((o|0)<0)<<31>>31|0)|0;o=I;if(!(o>>>0<0|(o|0)==0&j>>>0<2147483647)){l=0;return l|0}o=j+1|0;f[a+20>>2]=o;j=(o|0)/2|0;g=a+24|0;f[g>>2]=j;f[a+28>>2]=0-j;if(!(o&1))f[g>>2]=j+-1;l=td(a+108|0,b)|0;return l|0}function ee(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=u;u=u+16|0;e=d+8|0;g=d+4|0;h=d;if(!c){i=0;u=d;return i|0}f[a>>2]=b;f[e>>2]=0;dg(e,b)|0;a:do if(!(f[e>>2]|0))j=8;else{b=0;while(1){dg(g,f[a>>2]|0)|0;k=bj(44)|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;n[k+16>>2]=$(1.0);l=k+20|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;f[l+12>>2]=0;n[k+36>>2]=$(1.0);f[k+40>>2]=f[g>>2];if(!(lc(a,k)|0))break;f[h>>2]=k;Hg(c,h)|0;l=f[h>>2]|0;f[h>>2]=0;if(l|0){Cf(l);dn(l)}b=b+1|0;if(b>>>0>=(f[e>>2]|0)>>>0){j=8;break a}}Cf(k);dn(k);m=0}while(0);if((j|0)==8)m=lc(a,c)|0;i=m;u=d;return i|0}function fe(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;if(c>>>0>4294967279)um(a);d=a+11|0;e=b[d>>0]|0;g=e<<24>>24<0;if(g){h=f[a+4>>2]|0;i=(f[a+8>>2]&2147483647)+-1|0}else{h=e&255;i=10}j=h>>>0>c>>>0?h:c;c=j>>>0<11;k=c?10:(j+16&-16)+-1|0;do if((k|0)!=(i|0)){do if(c){j=f[a>>2]|0;if(g){l=0;m=j;n=a;o=13}else{Ok(a,j,(e&255)+1|0)|0;dn(j);o=16}}else{j=k+1|0;p=bj(j)|0;if(g){l=1;m=f[a>>2]|0;n=p;o=13;break}else{Ok(p,a,(e&255)+1|0)|0;q=p;r=j;s=a+4|0;o=15;break}}while(0);if((o|0)==13){j=a+4|0;Ok(n,m,(f[j>>2]|0)+1|0)|0;dn(m);if(l){q=n;r=k+1|0;s=j;o=15}else o=16}if((o|0)==15){f[a+8>>2]=r|-2147483648;f[s>>2]=h;f[a>>2]=q;break}else if((o|0)==16){b[d>>0]=h;break}}while(0);return}function ge(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;if((d|0)>=8192)return Da(a|0,c|0,d|0)|0;e=a|0;g=a+d|0;if((a&3)==(c&3)){while(a&3){if(!d)return e|0;b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0;d=d-1|0}h=g&-4|0;d=h-64|0;while((a|0)<=(d|0)){f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];f[a+12>>2]=f[c+12>>2];f[a+16>>2]=f[c+16>>2];f[a+20>>2]=f[c+20>>2];f[a+24>>2]=f[c+24>>2];f[a+28>>2]=f[c+28>>2];f[a+32>>2]=f[c+32>>2];f[a+36>>2]=f[c+36>>2];f[a+40>>2]=f[c+40>>2];f[a+44>>2]=f[c+44>>2];f[a+48>>2]=f[c+48>>2];f[a+52>>2]=f[c+52>>2];f[a+56>>2]=f[c+56>>2];f[a+60>>2]=f[c+60>>2];a=a+64|0;c=c+64|0}while((a|0)<(h|0)){f[a>>2]=f[c>>2];a=a+4|0;c=c+4|0}}else{h=g-4|0;while((a|0)<(h|0)){b[a>>0]=b[c>>0]|0;b[a+1>>0]=b[c+1>>0]|0;b[a+2>>0]=b[c+2>>0]|0;b[a+3>>0]=b[c+3>>0]|0;a=a+4|0;c=c+4|0}}while((a|0)<(g|0)){b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}return e|0}function he(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=f[c+88>>2]|0;if(!d){e=0;return e|0}if((f[d>>2]|0)!=1){e=0;return e|0}g=d+8|0;d=f[g>>2]|0;f[a+4>>2]=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;i=a+8|0;j=c+24|0;c=b[j>>0]|0;k=c<<24>>24;l=a+12|0;m=f[l>>2]|0;n=f[i>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=k>>>0)if(o>>>0>k>>>0?(m=p+(k<<2)|0,(m|0)!=(n|0)):0){f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2);q=c;r=d}else{q=c;r=d}else{ff(i,k-o|0);q=b[j>>0]|0;r=f[g>>2]|0}g=r+4|0;j=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;if(q<<24>>24>0){g=f[i>>2]|0;i=q<<24>>24;q=j;o=4;k=0;while(1){f[g+(k<<2)>>2]=q;o=o+4|0;k=k+1|0;d=r+o|0;c=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;if((k|0)>=(i|0)){s=c;break}else q=c}}else s=j;f[a+20>>2]=s;e=1;return e|0}function ie(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;do if(!(zl(a,f[c+8>>2]|0,g)|0)){if(!(zl(a,f[c>>2]|0,g)|0)){h=f[a+8>>2]|0;Wa[f[(f[h>>2]|0)+24>>2]&3](h,c,d,e,g);break}if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;i=c+44|0;if((f[i>>2]|0)==4)break;j=c+52|0;b[j>>0]=0;k=c+53|0;b[k>>0]=0;l=f[a+8>>2]|0;Xa[f[(f[l>>2]|0)+20>>2]&3](l,c,d,d,1,g);if(b[k>>0]|0)if(!(b[j>>0]|0)){m=3;n=11}else o=3;else{m=4;n=11}if((n|0)==11){f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0){b[c+54>>0]=1;o=m}else o=m}f[i>>2]=o;break}if((e|0)==1)f[c+32>>2]=1}else Ui(0,c,d,e);while(0);return}function je(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=f[a+32>>2]|0;d=c+8|0;e=f[d+4>>2]|0;g=c+16|0;h=g;i=f[h>>2]|0;j=f[h+4>>2]|0;if(!((e|0)>(j|0)|((e|0)==(j|0)?(f[d>>2]|0)>>>0>i>>>0:0))){k=0;return k|0}d=b[(f[c>>2]|0)+i>>0]|0;c=Rj(i|0,j|0,1,0)|0;j=g;f[j>>2]=c;f[j+4>>2]=I;j=a+48|0;c=f[j>>2]|0;f[j>>2]=0;if(c|0)Sa[f[(f[c>>2]|0)+4>>2]&127](c);switch(d<<24>>24){case 0:{d=bj(376)|0;Ag(d);c=f[j>>2]|0;f[j>>2]=d;if(!c)l=d;else{Sa[f[(f[c>>2]|0)+4>>2]&127](c);m=9}break}case 2:{c=bj(432)|0;yf(c);d=f[j>>2]|0;f[j>>2]=c;if(!d)l=c;else{Sa[f[(f[d>>2]|0)+4>>2]&127](d);m=9}break}default:m=9}if((m|0)==9){m=f[j>>2]|0;if(!m){k=0;return k|0}else l=m}k=Oa[f[(f[l>>2]|0)+8>>2]&127](l,a)|0;return k|0}function ke(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e+12|0;h=e+8|0;i=e;f[i>>2]=f[b>>2];f[g>>2]=f[i>>2];i=dc(a,g,h,e+4|0,c)|0;c=f[i>>2]|0;if(c|0){j=c;u=e;return j|0}c=bj(40)|0;Rf(c+16|0,d);Rf(c+28|0,d+12|0);d=f[h>>2]|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=d;f[i>>2]=c;d=f[f[a>>2]>>2]|0;if(!d)k=c;else{f[a>>2]=d;k=f[i>>2]|0}Lc(f[a+4>>2]|0,k);k=a+8|0;f[k>>2]=(f[k>>2]|0)+1;j=c;u=e;return j|0}function le(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=a+4|0;f[h>>2]=0;if(!c){u=e;return}i=a+8|0;j=f[i>>2]|0;k=j<<5;if(k>>>0>>0){f[g>>2]=0;l=g+4|0;f[l>>2]=0;m=g+8|0;f[m>>2]=0;if((c|0)<0)um(a);n=j<<6;j=c+31&-32;af(g,k>>>0<1073741823?(n>>>0>>0?j:n):2147483647);n=f[a>>2]|0;f[a>>2]=f[g>>2];f[g>>2]=n;g=f[h>>2]|0;f[h>>2]=c;f[l>>2]=g;g=f[i>>2]|0;f[i>>2]=f[m>>2];f[m>>2]=g;if(n|0)dn(n);o=a}else{f[h>>2]=c;o=a}a=f[o>>2]|0;o=a;h=a;a=c>>>5;n=a<<2;if(!(b[d>>0]|0)){Vf(h|0,0,n|0)|0;d=c&31;g=o+(a<<2)|0;if(!d){u=e;return}f[g>>2]=f[g>>2]&~(-1>>>(32-d|0));u=e;return}else{Vf(h|0,-1,n|0)|0;n=c&31;c=o+(a<<2)|0;if(!n){u=e;return}f[c>>2]=f[c>>2]|-1>>>(32-n|0);u=e;return}}function me(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;c=b+8|0;d=f[c>>2]|0;e=f[c+4>>2]|0;c=b+16|0;g=c;i=f[g>>2]|0;j=f[g+4>>2]|0;g=Rj(i|0,j|0,4,0)|0;k=I;if((e|0)<(k|0)|(e|0)==(k|0)&d>>>0>>0){l=0;return l|0}m=f[b>>2]|0;b=m+i|0;n=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;b=c;f[b>>2]=g;f[b+4>>2]=k;k=Rj(i|0,j|0,8,0)|0;j=I;if((e|0)<(j|0)|(e|0)==(j|0)&d>>>0>>0){l=0;return l|0}d=m+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=c;f[d>>2]=k;f[d+4>>2]=j;if((n|0)>(g|0)){l=0;return l|0}f[a+12>>2]=n;f[a+16>>2]=g;j=Tj(g|0,((g|0)<0)<<31>>31|0,n|0,((n|0)<0)<<31>>31|0)|0;n=I;if(!(n>>>0<0|(n|0)==0&j>>>0<2147483647)){l=0;return l|0}n=j+1|0;f[a+20>>2]=n;j=(n|0)/2|0;g=a+24|0;f[g>>2]=j;f[a+28>>2]=0-j;if(n&1|0){l=1;return l|0}f[g>>2]=j+-1;l=1;return l|0}function ne(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=a+12|0;a:do if((f[e>>2]|0)!=(c|0)){g=f[a>>2]|0;h=a+4|0;i=f[h>>2]|0;if((i|0)!=(g|0)){j=i;while(1){i=j+-12|0;f[h>>2]=i;if((b[i+11>>0]|0)<0){dn(f[i>>2]|0);k=f[h>>2]|0}else k=i;if((k|0)==(g|0))break;else j=k}}f[e>>2]=c;j=f[c+8>>2]|0;if(j|0){i=a+8|0;l=j;j=g;while(1){m=l+8|0;if((j|0)==(f[i>>2]|0))Ld(a,m);else{Rf(j,m);f[h>>2]=(f[h>>2]|0)+12}m=f[l>>2]|0;if(!m)break a;l=m;j=f[h>>2]|0}}}while(0);if((d|0)<0){n=0;return n|0}c=f[a>>2]|0;if((((f[a+4>>2]|0)-c|0)/12|0)>>>0<=d>>>0){n=0;return n|0}a=c+(d*12|0)|0;if((b[a+11>>0]|0)<0){n=f[a>>2]|0;return n|0}else{n=a;return n|0}return 0}function oe(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=u;u=u+16|0;d=c;e=f[(f[a>>2]|0)+8>>2]|0;g=a+8|0;h=a+12|0;i=(f[h>>2]|0)-(f[g>>2]|0)>>2;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;Ua[e&7](a,i,d);i=f[d>>2]|0;f[d>>2]=0;if(!i){k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}d=i+88|0;a=f[d>>2]|0;f[d>>2]=0;if(a|0){d=f[a+8>>2]|0;if(d|0){e=a+12|0;if((f[e>>2]|0)!=(d|0))f[e>>2]=d;dn(d)}dn(a)}a=f[i+68>>2]|0;if(a|0){d=i+72|0;e=f[d>>2]|0;if((e|0)!=(a|0))f[d>>2]=e+(~((e+-4-a|0)>>>2)<<2);dn(a)}a=i+64|0;e=f[a>>2]|0;f[a>>2]=0;if(e|0){a=f[e>>2]|0;if(a|0){d=e+4|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;dn(a)}dn(e)}dn(i);k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}function pe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=1048576){if((h|0)!=1048576?(e=i+4194304|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,1048576-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>1048576){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==1048576;return k|0}function qe(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>3>>>0>=b>>>0){h=b;i=g;do{j=i;f[j>>2]=0;f[j+4>>2]=0;i=(f[e>>2]|0)+8|0;f[e>>2]=i;h=h+-1|0}while((h|0)!=0);return}h=f[a>>2]|0;i=g-h>>3;g=i+b|0;if(g>>>0>536870911)um(a);j=d-h|0;h=j>>2;d=j>>3>>>0<268435455?(h>>>0>>0?g:h):536870911;do if(d)if(d>>>0>536870911){h=ra(8)|0;Yk(h,9789);f[h>>2]=3704;va(h|0,856,80)}else{k=bj(d<<3)|0;break}else k=0;while(0);h=k+(i<<3)|0;i=k+(d<<3)|0;d=b;b=h;k=h;do{g=b;f[g>>2]=0;f[g+4>>2]=0;b=k+8|0;k=b;d=d+-1|0}while((d|0)!=0);d=f[a>>2]|0;b=(f[e>>2]|0)-d|0;g=h+(0-(b>>3)<<3)|0;if((b|0)>0)ge(g|0,d|0,b|0)|0;f[a>>2]=g;f[e>>2]=k;f[c>>2]=i;if(!d)return;dn(d);return}function re(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=524288){if((h|0)!=524288?(e=i+2097152|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,524288-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>524288){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==524288;return k|0}function se(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=262144){if((h|0)!=262144?(e=i+1048576|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,262144-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>262144){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==262144;return k|0}function te(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(!c){g=0;u=d;return g|0}h=a+84|0;i=f[h>>2]|0;j=a+88|0;k=f[j>>2]|0;if((k|0)!=(i|0))f[j>>2]=k+(~((k+-4-i|0)>>>2)<<2);f[h>>2]=0;f[j>>2]=0;f[a+92>>2]=0;if(i|0)dn(i);i=a+72|0;j=f[i>>2]|0;h=a+76|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;f[i>>2]=0;f[h>>2]=0;f[a+80>>2]=0;if(j|0)dn(j);j=c+4|0;h=(f[j>>2]|0)-(f[c>>2]|0)>>2;b[e>>0]=0;le(a,h,e);h=c+24|0;i=c+28|0;k=(f[i>>2]|0)-(f[h>>2]|0)>>2;b[e>>0]=0;le(a+12|0,k,e);sd(a+28|0,(f[j>>2]|0)-(f[c>>2]|0)>>2,2684);Eg(a+52|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);Eg(a+40|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);f[a+64>>2]=c;b[a+24>>0]=1;g=1;u=d;return g|0}function ue(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=65536){if((h|0)!=65536?(e=i+262144|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,65536-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>65536){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==65536;return k|0}function ve(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=32768){if((h|0)!=32768?(e=i+131072|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,32768-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>32768){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==32768;return k|0}function we(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=8192){if((h|0)!=8192?(e=i+32768|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,8192-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>8192){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==8192;return k|0}function xe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=e-g>>2;i=g;g=e;if(h>>>0>=4096){if((h|0)!=4096?(e=i+16384|0,(e|0)!=(g|0)):0)f[d>>2]=g+(~((g+-4-e|0)>>>2)<<2)}else ff(a,4096-h|0);h=a+12|0;e=a+16|0;g=f[e>>2]|0;d=f[h>>2]|0;i=g-d>>3;j=d;d=g;if(i>>>0>=c>>>0){if(i>>>0>c>>>0?(g=j+(c<<3)|0,(g|0)!=(d|0)):0)f[e>>2]=d+(~((d+-8-g|0)>>>3)<<3);if(!c){k=0;return k|0}}else qe(h,c-i|0);i=f[h>>2]|0;h=0;g=0;do{d=b+(h<<2)|0;f[i+(h<<3)>>2]=f[d>>2];f[i+(h<<3)+4>>2]=g;e=g;g=(f[d>>2]|0)+g|0;if(g>>>0>4096){k=0;l=19;break}if(e>>>0>>0){d=f[a>>2]|0;j=e;do{f[d+(j<<2)>>2]=h;j=j+1|0}while((j|0)!=(g|0))}h=h+1|0}while(h>>>0>>0);if((l|0)==19)return k|0;k=(g|0)==4096;return k|0}function ye(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+224|0;g=e+120|0;h=e+80|0;i=e;j=e+136|0;k=h;l=k+40|0;do{f[k>>2]=0;k=k+4|0}while((k|0)<(l|0));f[g>>2]=f[d>>2];if((gb(0,c,g,i,h)|0)<0)m=-1;else{if((f[a+76>>2]|0)>-1)n=jn(a)|0;else n=0;d=f[a>>2]|0;k=d&32;if((b[a+74>>0]|0)<1)f[a>>2]=d&-33;d=a+48|0;if(!(f[d>>2]|0)){l=a+44|0;o=f[l>>2]|0;f[l>>2]=j;p=a+28|0;f[p>>2]=j;q=a+20|0;f[q>>2]=j;f[d>>2]=80;r=a+16|0;f[r>>2]=j+80;j=gb(a,c,g,i,h)|0;if(!o)s=j;else{Pa[f[a+36>>2]&31](a,0,0)|0;t=(f[q>>2]|0)==0?-1:j;f[l>>2]=o;f[d>>2]=0;f[r>>2]=0;f[p>>2]=0;f[q>>2]=0;s=t}}else s=gb(a,c,g,i,h)|0;h=f[a>>2]|0;f[a>>2]=h|k;if(n|0)hn(a);m=(h&32|0)==0?s:-1}u=e;return m|0}function ze(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e>>2;h=d;if(g>>>0>>0){gd(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b<<2)|0;if((g|0)==(h|0))return;else i=h;do{h=i+-4|0;f[c>>2]=h;b=f[h>>2]|0;f[h>>2]=0;if(b|0){h=b+88|0;e=f[h>>2]|0;f[h>>2]=0;if(e|0){h=f[e+8>>2]|0;if(h|0){a=e+12|0;if((f[a>>2]|0)!=(h|0))f[a>>2]=h;dn(h)}dn(e)}e=f[b+68>>2]|0;if(e|0){h=b+72|0;a=f[h>>2]|0;if((a|0)!=(e|0))f[h>>2]=a+(~((a+-4-e|0)>>>2)<<2);dn(e)}e=b+64|0;a=f[e>>2]|0;f[e>>2]=0;if(a|0){e=f[a>>2]|0;if(e|0){h=a+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;dn(e)}dn(a)}dn(b)}i=f[c>>2]|0}while((i|0)!=(g|0));return}function Ae(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;i=h;if(e-h>>2>>>0>=b>>>0){j=b;k=i;while(1){f[k>>2]=f[c>>2];j=j+-1|0;if(!j)break;else k=k+4|0}f[g>>2]=i+(b<<2);return}i=f[a>>2]|0;k=h-i|0;h=k>>2;j=h+b|0;if(j>>>0>1073741823)um(a);l=e-i|0;e=l>>1;m=l>>2>>>0<536870911?(e>>>0>>0?j:e):1073741823;do if(m)if(m>>>0>1073741823){e=ra(8)|0;Yk(e,9789);f[e>>2]=3704;va(e|0,856,80)}else{e=bj(m<<2)|0;n=e;o=e;break}else{n=0;o=0}while(0);e=n+(h<<2)|0;h=n+(m<<2)|0;m=b;j=e;while(1){f[j>>2]=f[c>>2];m=m+-1|0;if(!m)break;else j=j+4|0}if((k|0)>0)ge(o|0,i|0,k|0)|0;f[a>>2]=n;f[g>>2]=e+(b<<2);f[d>>2]=h;if(!i)return;dn(i);return}function Be(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=a+8|0;d=b+8|0;e=f[d>>2]|0;g=f[d+4>>2]|0;d=b+16|0;i=d;j=f[i>>2]|0;k=f[i+4>>2]|0;i=Rj(j|0,k|0,4,0)|0;l=I;if((g|0)<(l|0)|(g|0)==(l|0)&e>>>0>>0){m=0;return m|0}n=(f[b>>2]|0)+j|0;o=h[n>>0]|h[n+1>>0]<<8|h[n+2>>0]<<16|h[n+3>>0]<<24;n=d;f[n>>2]=i;f[n+4>>2]=l;l=Rj(j|0,k|0,8,0)|0;k=I;if((g|0)<(k|0)|(g|0)==(k|0)&e>>>0>>0){m=0;return m|0}e=d;f[e>>2]=l;f[e+4>>2]=k;k=(_(o|0)|0)^31;if((k+-1|0)>>>0>28)p=f[c>>2]|0;else{o=k+1|0;f[c>>2]=o;c=2<>2]=c+-1;k=c+-2|0;f[a+16>>2]=k;f[a+20>>2]=(k|0)/2|0;p=o}if((p+-2|0)>>>0>=29){m=0;return m|0}m=td(a+88|0,b)|0;return m|0}function Ce(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=(f[a>>2]|0)+1794895138|0;g=Al(f[a+8>>2]|0,e)|0;h=Al(f[a+12>>2]|0,e)|0;i=Al(f[a+16>>2]|0,e)|0;a:do if((g>>>0>>2>>>0?(j=c-(g<<2)|0,h>>>0>>0&i>>>0>>0):0)?((i|h)&3|0)==0:0){j=h>>>2;k=i>>>2;l=0;m=g;while(1){n=m>>>1;o=l+n|0;p=o<<1;q=p+j|0;r=Al(f[a+(q<<2)>>2]|0,e)|0;s=Al(f[a+(q+1<<2)>>2]|0,e)|0;if(!(s>>>0>>0&r>>>0<(c-s|0)>>>0)){t=0;break a}if(b[a+(s+r)>>0]|0){t=0;break a}r=th(d,a+s|0)|0;if(!r)break;s=(r|0)<0;if((m|0)==1){t=0;break a}else{l=s?l:o;m=s?n:m-n|0}}m=p+k|0;l=Al(f[a+(m<<2)>>2]|0,e)|0;j=Al(f[a+(m+1<<2)>>2]|0,e)|0;if(j>>>0>>0&l>>>0<(c-j|0)>>>0)t=(b[a+(j+l)>>0]|0)==0?a+j|0:0;else t=0}else t=0;while(0);return t|0}function De(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h=u;u=u+64|0;i=h;j=f[a>>2]|0;k=a+(f[j+-8>>2]|0)|0;l=f[j+-4>>2]|0;f[i>>2]=e;f[i+4>>2]=a;f[i+8>>2]=c;f[i+12>>2]=g;g=i+16|0;c=i+20|0;a=i+24|0;j=i+28|0;m=i+32|0;n=i+40|0;o=g;p=o+36|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));d[g+36>>1]=0;b[g+38>>0]=0;a:do if(zl(l,e,0)|0){f[i+48>>2]=1;Xa[f[(f[l>>2]|0)+20>>2]&3](l,i,k,k,1,0);q=(f[a>>2]|0)==1?k:0}else{Wa[f[(f[l>>2]|0)+24>>2]&3](l,i,k,1,0);switch(f[i+36>>2]|0){case 0:{q=(f[n>>2]|0)==1&(f[j>>2]|0)==1&(f[m>>2]|0)==1?f[c>>2]|0:0;break a;break}case 1:break;default:{q=0;break a}}if((f[a>>2]|0)!=1?!((f[n>>2]|0)==0&(f[j>>2]|0)==1&(f[m>>2]|0)==1):0){q=0;break}q=f[g>>2]|0}while(0);u=h;return q|0}function Ee(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){i=b;j=h;while(1){f[j>>2]=1;i=i+-1|0;if(!i)break;else j=j+4|0}f[e>>2]=h+(b<<2);return}h=f[a>>2]|0;j=g-h|0;g=j>>2;i=g+b|0;if(i>>>0>1073741823)um(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?i:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Yk(d,9789);f[d>>2]=3704;va(d|0,856,80)}else{d=bj(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;g=m+(l<<2)|0;l=b;i=d;while(1){f[i>>2]=1;l=l+-1|0;if(!l)break;else i=i+4|0}if((j|0)>0)ge(n|0,h|0,j|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=g;if(!h)return;dn(h);return}function Fe(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(j=f[(f[d+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(k=f[(f[d+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if(((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(h=f[(f[d+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Ge(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=f[a+4>>2]|0;if(!d){e=0;return e|0}a=b[c+11>>0]|0;g=a<<24>>24<0;h=g?f[c+4>>2]|0:a&255;a=g?f[c>>2]|0:c;c=d;while(1){d=c+16|0;g=b[d+11>>0]|0;i=g<<24>>24<0;j=i?f[c+20>>2]|0:g&255;g=j>>>0>>0;k=g?j:h;if((k|0)!=0?(l=jh(a,i?f[d>>2]|0:d,k)|0,(l|0)!=0):0)if((l|0)<0)m=7;else m=8;else if(h>>>0>>0)m=7;else m=8;if((m|0)==7){m=0;n=c}else if((m|0)==8){m=0;l=h>>>0>>0?h:j;if((l|0)!=0?(j=jh(i?f[d>>2]|0:d,a,l)|0,(j|0)!=0):0){if((j|0)>=0){e=1;m=14;break}}else m=10;if((m|0)==10?(m=0,!g):0){e=1;m=14;break}n=c+4|0}c=f[n>>2]|0;if(!c){e=0;m=14;break}}if((m|0)==14)return e|0;return 0}function He(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+32|0;e=d+12|0;g=d;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=gg(c)|0;if(h>>>0>4294967279)um(e);if(h>>>0<11){b[e+11>>0]=h;if(!h)i=e;else{j=e;k=6}}else{l=h+16&-16;m=bj(l)|0;f[e>>2]=m;f[e+8>>2]=l|-2147483648;f[e+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,c|0,h|0)|0;i=j}b[i+h>>0]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=g+11|0;b[h>>0]=4;f[g>>2]=1701667182;b[g+4>>0]=0;i=f[a+4>>2]|0;if((i|0)!=0?(j=Mc(i,g,e)|0,(j|0)!=0):0)n=ih(a,f[j+40>>2]|0)|0;else n=-1;if((b[h>>0]|0)<0)dn(f[g>>2]|0);if((b[e+11>>0]|0)>=0){u=d;return n|0}dn(f[e>>2]|0);u=d;return n|0}function Ie(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,i=0;if((b|0)==-2)g=0;else{i=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;do if((Na[f[(f[d>>2]|0)+8>>2]&127](d)|0)==1){ud(a,d,b,c,e,((h[d+36>>0]|0)<<8|(h[d+37>>0]|0))&65535);if(!(f[a>>2]|0)){f[a>>2]=0;break}else return}while(0);d=bj(44)|0;f[d>>2]=1208;f[d+4>>2]=i;i=d+8|0;f[i>>2]=f[e>>2];f[i+4>>2]=f[e+4>>2];f[i+8>>2]=f[e+8>>2];f[i+12>>2]=f[e+12>>2];f[i+16>>2]=f[e+16>>2];f[i+20>>2]=f[e+20>>2];Bg(d+32|0,e+24|0);f[d>>2]=1264;g=d}f[a>>2]=g;return}function Je(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+16|0;if(b[d+84>>0]|0){g=f[e>>2]|0;return g|0}a=f[e>>2]|0;if(!a){g=f[e>>2]|0;return g|0}h=a+84|0;if(!(b[h>>0]|0)){g=f[e>>2]|0;return g|0}i=(f[d+72>>2]|0)-(f[d+68>>2]|0)>>2;b[h>>0]=0;h=a+68|0;j=a+72|0;a=f[j>>2]|0;k=f[h>>2]|0;l=a-k>>2;m=k;k=a;if(i>>>0<=l>>>0)if(i>>>0>>0?(a=m+(i<<2)|0,(a|0)!=(k|0)):0){f[j>>2]=k+(~((k+-4-a|0)>>>2)<<2);n=d}else n=d;else{Ae(h,i-l|0,1076);n=f[c>>2]|0}if(b[n+84>>0]|0){g=f[e>>2]|0;return g|0}c=f[n+68>>2]|0;l=c;i=(f[n+72>>2]|0)-c>>2;if(!i){g=f[e>>2]|0;return g|0}c=f[(f[e>>2]|0)+68>>2]|0;n=0;do{f[c+(n<<2)>>2]=f[l+(n<<2)>>2];n=n+1|0}while(n>>>0>>0);g=f[e>>2]|0;return g|0}function Ke(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=La;d=u;u=u+32|0;e=d+16|0;g=d;h=a+8|0;i=b[(f[h>>2]|0)+24>>0]<<2;j=f[a+16>>2]|0;k=(f[f[j>>2]>>2]|0)+(f[j+48>>2]|0)|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;j=f[a+24>>2]|0;if((j+-2|0)>>>0>28){l=0;u=d;return l|0}f[g>>2]=j;a=1<>2]=a+-1;j=a+-2|0;a=g+8|0;f[a>>2]=j;f[g+12>>2]=(j|0)/2|0;if(!c){l=1;u=d;return l|0}m=0;n=0;o=0;p=j;while(1){q=$($(1.0)/$(p|0));Dd(g,$(q*$(f[k+(m<<2)>>2]|0)),$(q*$(f[k+((m|1)<<2)>>2]|0)),e);ge((f[f[(f[h>>2]|0)+64>>2]>>2]|0)+o|0,e|0,i|0)|0;j=n+1|0;if((j|0)==(c|0)){l=1;break}m=m+2|0;n=j;o=o+i|0;p=f[a>>2]|0}u=d;return l|0}function Le(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=f[a+196>>2]|0;if(b|0){c=a+200|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=a+184|0;d=f[b>>2]|0;if(d|0){c=a+188|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;while(1){e=h+-12|0;f[c>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);dn(i);j=f[c>>2]|0}if((j|0)==(d|0))break;else h=j}g=f[b>>2]|0}dn(g)}g=f[a+156>>2]|0;if(g|0){b=a+160|0;j=f[b>>2]|0;if((j|0)!=(g|0))f[b>>2]=j+(~((j+-4-g|0)>>>2)<<2);dn(g)}g=a+136|0;a=f[g>>2]|0;f[g>>2]=0;if(!a)return;g=a+-4|0;j=f[g>>2]|0;if(j|0){b=a+(j<<4)|0;do b=b+-16|0;while((b|0)!=(a|0))}bn(g);return}function Me(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+32|0;e=d+16|0;g=d;switch(c<<24>>24){case 0:{c=bj(48)|0;Ql(c);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=c;u=d;return}case 1:{c=bj(52)|0;Vk(c);f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=c;u=d;return}default:{c=bj(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=28;h=c;i=8331;j=h+28|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[c+28>>0]=0;f[e>>2]=-1;c=e+4|0;Rf(c,g);f[a>>2]=f[e>>2];Rf(a+4|0,c);f[a+16>>2]=0;if((b[c+11>>0]|0)<0)dn(f[c>>2]|0);if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);u=d;return}}}function Ne(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=(d-e|0)/144|0;h=d;if(g>>>0>>0){Kc(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b*144|0)|0;if((g|0)==(h|0))return;else i=h;do{f[c>>2]=i+-144;h=f[i+-12>>2]|0;if(h|0){b=i+-8|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);dn(h)}h=f[i+-28>>2]|0;if(h|0){e=i+-24|0;b=f[e>>2]|0;if((b|0)!=(h|0))f[e>>2]=b+(~((b+-4-h|0)>>>2)<<2);dn(h)}h=f[i+-40>>2]|0;if(h|0){b=i+-36|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);dn(h)}tf(i+-140|0);i=f[c>>2]|0}while((i|0)!=(g|0));return}function Oe(a,b){a=a|0;b=b|0;var c=0,d=La,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=$a(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Rb(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=$a(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Rb(a,e);return}function Pe(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=1088;b=a+60|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Sa[f[(f[c>>2]|0)+4>>2]&127](c);c=f[a+48>>2]|0;if(c|0){b=a+52|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);dn(c)}c=a+36|0;d=f[c>>2]|0;if(d|0){b=a+40|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Sa[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}dn(g)}f[a>>2]=984;g=f[a+16>>2]|0;if(g|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(g|0))f[c>>2]=d+(~((d+-4-g|0)>>>2)<<2);dn(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);dn(g);return}function Qe(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{d=g+-4|0;f[c>>2]=d;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=h+88|0;i=f[d>>2]|0;f[d>>2]=0;if(i|0){d=f[i+8>>2]|0;if(d|0){j=i+12|0;if((f[j>>2]|0)!=(d|0))f[j>>2]=d;dn(d)}dn(i)}i=f[h+68>>2]|0;if(i|0){d=h+72|0;j=f[d>>2]|0;if((j|0)!=(i|0))f[d>>2]=j+(~((j+-4-i|0)>>>2)<<2);dn(i)}i=h+64|0;j=f[i>>2]|0;f[i>>2]=0;if(j|0){i=f[j>>2]|0;if(i|0){d=j+4|0;if((f[d>>2]|0)!=(i|0))f[d>>2]=i;dn(i)}dn(j)}dn(h)}g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}dn(e);return}function Re(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=a+8|0;d=b+8|0;e=f[d>>2]|0;g=f[d+4>>2]|0;d=b+16|0;i=d;j=f[i>>2]|0;k=f[i+4>>2]|0;i=Rj(j|0,k|0,4,0)|0;l=I;if((g|0)<(l|0)|(g|0)==(l|0)&e>>>0>>0)return 0;m=(f[b>>2]|0)+j|0;b=h[m>>0]|h[m+1>>0]<<8|h[m+2>>0]<<16|h[m+3>>0]<<24;m=d;f[m>>2]=i;f[m+4>>2]=l;l=Rj(j|0,k|0,8,0)|0;k=I;if((g|0)<(k|0)|(g|0)==(k|0)&e>>>0>>0)return 0;e=d;f[e>>2]=l;f[e+4>>2]=k;k=(_(b|0)|0)^31;if((k+-1|0)>>>0>28){n=f[c>>2]|0;o=n+-2|0;p=o>>>0<29;return p|0}else{b=k+1|0;f[c>>2]=b;c=2<>2]=c+-1;k=c+-2|0;f[a+16>>2]=k;f[a+20>>2]=(k|0)/2|0;n=b;o=n+-2|0;p=o>>>0<29;return p|0}return 0}function Se(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{d=e+-4|0;f[c>>2]=d;g=f[d>>2]|0;f[d>>2]=0;if(g|0){d=g+88|0;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=f[h+8>>2]|0;if(d|0){i=h+12|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;dn(d)}dn(h)}h=f[g+68>>2]|0;if(h|0){d=g+72|0;i=f[d>>2]|0;if((i|0)!=(h|0))f[d>>2]=i+(~((i+-4-h|0)>>>2)<<2);dn(h)}h=g+64|0;i=f[h>>2]|0;f[h>>2]=0;if(i|0){h=f[i>>2]|0;if(h|0){d=i+4|0;if((f[d>>2]|0)!=(h|0))f[d>>2]=h;dn(h)}dn(i)}dn(g)}e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;dn(b);return}function Te(a,b){a=a|0;b=b|0;var c=0,d=La,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=$a(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){jc(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=$a(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;jc(a,e);return}function Ue(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=bj(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;h=g+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{jf(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}ge(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function Ve(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+60|0;d=f[c>>2]|0;if(!d){e=0;return e|0}f[d+4>>2]=a+48;if(!(Na[f[(f[d>>2]|0)+12>>2]&127](d)|0)){e=0;return e|0}d=Na[f[(f[a>>2]|0)+24>>2]&127](a)|0;a:do if((d|0)>0){g=0;while(1){h=(Na[f[(f[a>>2]|0)+28>>2]&127](a)|0)+4|0;i=f[h>>2]|0;h=Oa[f[(f[a>>2]|0)+20>>2]&127](a,g)|0;j=f[c>>2]|0;g=g+1|0;if(!(Oa[f[(f[j>>2]|0)+8>>2]&127](j,f[(f[i+8>>2]|0)+(h<<2)>>2]|0)|0)){e=0;break}if((g|0)>=(d|0))break a}return e|0}while(0);if(!(Oa[f[(f[a>>2]|0)+36>>2]&127](a,b)|0)){e=0;return e|0}if(!(Oa[f[(f[a>>2]|0)+40>>2]&127](a,b)|0)){e=0;return e|0}e=Na[f[(f[a>>2]|0)+44>>2]&127](a)|0;return e|0}function We(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+32|0;e=a+12|0;g=a;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=gg(d)|0;if(h>>>0>4294967279)um(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=bj(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;Sf(c,g,e)|0;c=e+11|0;h=b[c>>0]|0;i=h<<24>>24<0?f[e>>2]|0:e;if((b[g+11>>0]|0)<0){dn(f[g>>2]|0);n=b[c>>0]|0}else n=h;if(n<<24>>24>=0){u=a;return i|0}dn(f[e>>2]|0);u=a;return i|0}function Xe(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=d+16|0;g=f[e>>2]|0;if(!g)if(!(Gh(d)|0)){h=f[e>>2]|0;i=5}else j=0;else{h=g;i=5}a:do if((i|0)==5){g=d+20|0;e=f[g>>2]|0;k=e;if((h-e|0)>>>0>>0){j=Pa[f[d+36>>2]&31](d,a,c)|0;break}b:do if((b[d+75>>0]|0)>-1){e=c;while(1){if(!e){l=0;m=a;n=c;o=k;break b}p=e+-1|0;if((b[a+p>>0]|0)==10)break;else e=p}p=Pa[f[d+36>>2]&31](d,a,e)|0;if(p>>>0>>0){j=p;break a}l=e;m=a+e|0;n=c-e|0;o=f[g>>2]|0}else{l=0;m=a;n=c;o=k}while(0);ge(o|0,m|0,n|0)|0;f[g>>2]=(f[g>>2]|0)+n;j=l+n|0}while(0);return j|0}function Ye(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+12|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d+28>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;Ye(c+8|0);dn(c)}while((e|0)!=0)}e=d+20|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0)dn(c);c=f[d+8>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;g=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;dn(h)}if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);dn(c)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(e|0)dn(e);dn(d)}if((b[a+11>>0]|0)>=0)return;dn(f[a>>2]|0);return}function Ze(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=(f[b+4>>2]|0)-(f[b>>2]|0)|0;b=d>>2;e=a+8|0;a=f[(f[e>>2]|0)+40>>2]|0;g=an((a|0)>-1?a:-1)|0;h=c+8|0;if((d|0)<=0){i=1;bn(g);return i|0}d=c+16|0;j=0;k=0;while(1){l=h;m=f[l>>2]|0;n=f[l+4>>2]|0;l=d;o=f[l>>2]|0;p=Rj(o|0,f[l+4>>2]|0,a|0,0)|0;l=I;if((n|0)<(l|0)|(n|0)==(l|0)&m>>>0

>>0){i=0;q=5;break}ge(g|0,(f[c>>2]|0)+o|0,a|0)|0;o=d;f[o>>2]=p;f[o+4>>2]=l;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+j|0,g|0,a|0)|0;k=k+1|0;if((k|0)>=(b|0)){i=1;q=5;break}else j=j+a|0}if((q|0)==5){bn(g);return i|0}return 0}function _e(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=a+212|0;e=a+216|0;g=f[d>>2]|0;if((f[e>>2]|0)==(g|0)){h=0;return h|0}i=a+4|0;a=0;j=g;a:while(1){g=f[j+(a*144|0)>>2]|0;if(((g|0)>=0?(k=f[i>>2]|0,l=f[k+8>>2]|0,(g|0)<((f[k+12>>2]|0)-l>>2|0)):0)?(k=f[l+(g<<2)>>2]|0,(Na[f[(f[k>>2]|0)+24>>2]&127](k)|0)>0):0){g=0;do{if((Oa[f[(f[k>>2]|0)+20>>2]&127](k,g)|0)==(c|0))break a;g=g+1|0}while((g|0)<(Na[f[(f[k>>2]|0)+24>>2]&127](k)|0))}k=a+1|0;j=f[d>>2]|0;if(k>>>0>=(((f[e>>2]|0)-j|0)/144|0)>>>0){h=0;m=11;break}else a=k}if((m|0)==11)return h|0;m=f[d>>2]|0;h=(b[m+(a*144|0)+100>>0]|0)==0?0:m+(a*144|0)+4|0;return h|0}function $e(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+212|0;d=a+216|0;e=f[c>>2]|0;a:do if((f[d>>2]|0)!=(e|0)){g=a+4|0;h=0;i=e;b:while(1){j=f[i+(h*144|0)>>2]|0;if(((j|0)>=0?(k=f[g>>2]|0,l=f[k+8>>2]|0,(j|0)<((f[k+12>>2]|0)-l>>2|0)):0)?(k=f[l+(j<<2)>>2]|0,(Na[f[(f[k>>2]|0)+24>>2]&127](k)|0)>0):0){j=0;do{if((Oa[f[(f[k>>2]|0)+20>>2]&127](k,j)|0)==(b|0))break b;j=j+1|0}while((j|0)<(Na[f[(f[k>>2]|0)+24>>2]&127](k)|0))}k=h+1|0;i=f[c>>2]|0;if(k>>>0>=(((f[d>>2]|0)-i|0)/144|0)>>>0)break a;else h=k}m=(f[c>>2]|0)+(h*144|0)+104|0;return m|0}while(0);m=a+184|0;return m|0}function af(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+32|0;d=c+16|0;e=c+8|0;g=c;h=a+8|0;if(f[h>>2]<<5>>>0>=b>>>0){u=c;return}f[d>>2]=0;i=d+4|0;f[i>>2]=0;j=d+8|0;f[j>>2]=0;if((b|0)<0)um(d);k=((b+-1|0)>>>5)+1|0;b=bj(k<<2)|0;f[d>>2]=b;f[i>>2]=0;f[j>>2]=k;k=f[a>>2]|0;f[e>>2]=k;f[e+4>>2]=0;b=a+4|0;l=f[b>>2]|0;f[g>>2]=k+(l>>>5<<2);f[g+4>>2]=l&31;Hd(d,e,g);g=f[a>>2]|0;f[a>>2]=f[d>>2];f[d>>2]=g;d=f[b>>2]|0;f[b>>2]=f[i>>2];f[i>>2]=d;d=f[h>>2]|0;f[h>>2]=f[j>>2];f[j>>2]=d;if(g|0)dn(g);u=c;return}function bf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=u;u=u+16|0;e=c;do if(((h[(f[a+4>>2]|0)+36>>0]|0)<<8&65535)>511){g=d+8|0;i=f[g+4>>2]|0;j=d+16|0;k=j;l=f[k>>2]|0;m=f[k+4>>2]|0;if((i|0)>(m|0)|((i|0)==(m|0)?(f[g>>2]|0)>>>0>l>>>0:0)){g=b[(f[d>>2]|0)+l>>0]|0;i=Rj(l|0,m|0,1,0)|0;m=j;f[m>>2]=i;f[m+4>>2]=I;m=g&255;f[a+24>>2]=m;n=m;break}else{o=0;u=c;return o|0}}else n=f[a+24>>2]|0;while(0);f[e>>2]=928;f[e+4>>2]=-1;El(e,n);o=gh(e,f[a+16>>2]|0)|0;u=c;return o|0}function cf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=(e|0)/12|0;h=g+1|0;if(h>>>0>357913941)um(a);i=a+8|0;j=((f[i>>2]|0)-d|0)/12|0;k=j<<1;l=j>>>0<178956970?(k>>>0>>0?h:k):357913941;do if(l)if(l>>>0>357913941){k=ra(8)|0;Yk(k,9789);f[k>>2]=3704;va(k|0,856,80)}else{m=bj(l*12|0)|0;break}else m=0;while(0);k=m+(g*12|0)|0;f[k>>2]=f[b>>2];f[k+4>>2]=f[b+4>>2];f[k+8>>2]=f[b+8>>2];b=k+(((e|0)/-12|0)*12|0)|0;if((e|0)>0)ge(b|0,d|0,e|0)|0;f[a>>2]=b;f[c>>2]=k+12;f[i>>2]=m+(l*12|0);if(!d)return;dn(d);return} +function Ya(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0;b=u;u=u+16|0;c=b;do if(a>>>0<245){d=a>>>0<11?16:a+11&-8;e=d>>>3;g=f[3220]|0;h=g>>>e;if(h&3|0){i=(h&1^1)+e|0;j=12920+(i<<1<<2)|0;k=j+8|0;l=f[k>>2]|0;m=l+8|0;n=f[m>>2]|0;if((n|0)==(j|0))f[3220]=g&~(1<>2]=j;f[k>>2]=n}n=i<<3;f[l+4>>2]=n|3;i=l+n+4|0;f[i>>2]=f[i>>2]|1;o=m;u=b;return o|0}m=f[3222]|0;if(d>>>0>m>>>0){if(h|0){i=2<>>12&16;e=i>>>n;i=e>>>5&8;h=e>>>i;e=h>>>2&4;l=h>>>e;h=l>>>1&2;k=l>>>h;l=k>>>1&1;j=(i|n|e|h|l)+(k>>>l)|0;l=12920+(j<<1<<2)|0;k=l+8|0;h=f[k>>2]|0;e=h+8|0;n=f[e>>2]|0;if((n|0)==(l|0)){i=g&~(1<>2]=l;f[k>>2]=n;p=g}n=j<<3;j=n-d|0;f[h+4>>2]=d|3;k=h+d|0;f[k+4>>2]=j|1;f[h+n>>2]=j;if(m|0){n=f[3225]|0;h=m>>>3;l=12920+(h<<1<<2)|0;i=1<>2]|0;r=i}f[r>>2]=n;f[q+12>>2]=n;f[n+8>>2]=q;f[n+12>>2]=l}f[3222]=j;f[3225]=k;o=e;u=b;return o|0}e=f[3221]|0;if(e){k=(e&0-e)+-1|0;j=k>>>12&16;l=k>>>j;k=l>>>5&8;n=l>>>k;l=n>>>2&4;i=n>>>l;n=i>>>1&2;h=i>>>n;i=h>>>1&1;s=f[13184+((k|j|l|n|i)+(h>>>i)<<2)>>2]|0;i=(f[s+4>>2]&-8)-d|0;h=f[s+16+(((f[s+16>>2]|0)==0&1)<<2)>>2]|0;if(!h){t=s;v=i}else{n=s;s=i;i=h;while(1){h=(f[i+4>>2]&-8)-d|0;l=h>>>0>>0;j=l?h:s;h=l?i:n;i=f[i+16+(((f[i+16>>2]|0)==0&1)<<2)>>2]|0;if(!i){t=h;v=j;break}else{n=h;s=j}}}s=t+d|0;if(s>>>0>t>>>0){n=f[t+24>>2]|0;i=f[t+12>>2]|0;do if((i|0)==(t|0)){j=t+20|0;h=f[j>>2]|0;if(!h){l=t+16|0;k=f[l>>2]|0;if(!k){w=0;break}else{x=k;y=l}}else{x=h;y=j}while(1){j=x+20|0;h=f[j>>2]|0;if(h|0){x=h;y=j;continue}j=x+16|0;h=f[j>>2]|0;if(!h)break;else{x=h;y=j}}f[y>>2]=0;w=x}else{j=f[t+8>>2]|0;f[j+12>>2]=i;f[i+8>>2]=j;w=i}while(0);do if(n|0){i=f[t+28>>2]|0;j=13184+(i<<2)|0;if((t|0)==(f[j>>2]|0)){f[j>>2]=w;if(!w){f[3221]=e&~(1<>2]|0)!=(t|0)&1)<<2)>>2]=w;if(!w)break}f[w+24>>2]=n;i=f[t+16>>2]|0;if(i|0){f[w+16>>2]=i;f[i+24>>2]=w}i=f[t+20>>2]|0;if(i|0){f[w+20>>2]=i;f[i+24>>2]=w}}while(0);if(v>>>0<16){n=v+d|0;f[t+4>>2]=n|3;e=t+n+4|0;f[e>>2]=f[e>>2]|1}else{f[t+4>>2]=d|3;f[s+4>>2]=v|1;f[s+v>>2]=v;if(m|0){e=f[3225]|0;n=m>>>3;i=12920+(n<<1<<2)|0;j=1<>2]|0;A=j}f[A>>2]=e;f[z+12>>2]=e;f[e+8>>2]=z;f[e+12>>2]=i}f[3222]=v;f[3225]=s}o=t+8|0;u=b;return o|0}else B=d}else B=d}else B=d}else if(a>>>0<=4294967231){i=a+11|0;e=i&-8;j=f[3221]|0;if(j){n=0-e|0;h=i>>>8;if(h)if(e>>>0>16777215)C=31;else{i=(h+1048320|0)>>>16&8;l=h<>>16&4;k=l<>>16&2;D=14-(h|i|l)+(k<>>15)|0;C=e>>>(D+7|0)&1|D<<1}else C=0;D=f[13184+(C<<2)>>2]|0;a:do if(!D){E=0;F=0;G=n;H=57}else{l=0;k=n;i=D;h=e<<((C|0)==31?0:25-(C>>>1)|0);I=0;while(1){J=(f[i+4>>2]&-8)-e|0;if(J>>>0>>0)if(!J){K=0;L=i;M=i;H=61;break a}else{N=i;O=J}else{N=l;O=k}J=f[i+20>>2]|0;i=f[i+16+(h>>>31<<2)>>2]|0;P=(J|0)==0|(J|0)==(i|0)?I:J;J=(i|0)==0;if(J){E=P;F=N;G=O;H=57;break}else{l=N;k=O;h=h<<((J^1)&1);I=P}}}while(0);if((H|0)==57){if((E|0)==0&(F|0)==0){D=2<>>12&16;d=D>>>n;D=d>>>5&8;s=d>>>D;d=s>>>2&4;g=s>>>d;s=g>>>1&2;m=g>>>s;g=m>>>1&1;Q=0;R=f[13184+((D|n|d|s|g)+(m>>>g)<<2)>>2]|0}else{Q=F;R=E}if(!R){S=Q;T=G}else{K=G;L=R;M=Q;H=61}}if((H|0)==61)while(1){H=0;g=(f[L+4>>2]&-8)-e|0;m=g>>>0>>0;s=m?g:K;g=m?L:M;L=f[L+16+(((f[L+16>>2]|0)==0&1)<<2)>>2]|0;if(!L){S=g;T=s;break}else{K=s;M=g;H=61}}if((S|0)!=0?T>>>0<((f[3222]|0)-e|0)>>>0:0){g=S+e|0;if(g>>>0<=S>>>0){o=0;u=b;return o|0}s=f[S+24>>2]|0;m=f[S+12>>2]|0;do if((m|0)==(S|0)){d=S+20|0;n=f[d>>2]|0;if(!n){D=S+16|0;I=f[D>>2]|0;if(!I){U=0;break}else{V=I;W=D}}else{V=n;W=d}while(1){d=V+20|0;n=f[d>>2]|0;if(n|0){V=n;W=d;continue}d=V+16|0;n=f[d>>2]|0;if(!n)break;else{V=n;W=d}}f[W>>2]=0;U=V}else{d=f[S+8>>2]|0;f[d+12>>2]=m;f[m+8>>2]=d;U=m}while(0);do if(s){m=f[S+28>>2]|0;d=13184+(m<<2)|0;if((S|0)==(f[d>>2]|0)){f[d>>2]=U;if(!U){d=j&~(1<>2]|0)!=(S|0)&1)<<2)>>2]=U;if(!U){X=j;break}}f[U+24>>2]=s;d=f[S+16>>2]|0;if(d|0){f[U+16>>2]=d;f[d+24>>2]=U}d=f[S+20>>2]|0;if(d){f[U+20>>2]=d;f[d+24>>2]=U;X=j}else X=j}else X=j;while(0);do if(T>>>0>=16){f[S+4>>2]=e|3;f[g+4>>2]=T|1;f[g+T>>2]=T;j=T>>>3;if(T>>>0<256){s=12920+(j<<1<<2)|0;d=f[3220]|0;m=1<>2]|0;Z=m}f[Z>>2]=g;f[Y+12>>2]=g;f[g+8>>2]=Y;f[g+12>>2]=s;break}s=T>>>8;if(s)if(T>>>0>16777215)_=31;else{m=(s+1048320|0)>>>16&8;d=s<>>16&4;j=d<>>16&2;n=14-(s|m|d)+(j<>>15)|0;_=T>>>(n+7|0)&1|n<<1}else _=0;n=13184+(_<<2)|0;f[g+28>>2]=_;d=g+16|0;f[d+4>>2]=0;f[d>>2]=0;d=1<<_;if(!(X&d)){f[3221]=X|d;f[n>>2]=g;f[g+24>>2]=n;f[g+12>>2]=g;f[g+8>>2]=g;break}d=T<<((_|0)==31?0:25-(_>>>1)|0);j=f[n>>2]|0;while(1){if((f[j+4>>2]&-8|0)==(T|0)){H=97;break}$=j+16+(d>>>31<<2)|0;n=f[$>>2]|0;if(!n){H=96;break}else{d=d<<1;j=n}}if((H|0)==96){f[$>>2]=g;f[g+24>>2]=j;f[g+12>>2]=g;f[g+8>>2]=g;break}else if((H|0)==97){d=j+8|0;n=f[d>>2]|0;f[n+12>>2]=g;f[d>>2]=g;f[g+8>>2]=n;f[g+12>>2]=j;f[g+24>>2]=0;break}}else{n=T+e|0;f[S+4>>2]=n|3;d=S+n+4|0;f[d>>2]=f[d>>2]|1}while(0);o=S+8|0;u=b;return o|0}else B=e}else B=e}else B=-1;while(0);S=f[3222]|0;if(S>>>0>=B>>>0){T=S-B|0;$=f[3225]|0;if(T>>>0>15){_=$+B|0;f[3225]=_;f[3222]=T;f[_+4>>2]=T|1;f[$+S>>2]=T;f[$+4>>2]=B|3}else{f[3222]=0;f[3225]=0;f[$+4>>2]=S|3;T=$+S+4|0;f[T>>2]=f[T>>2]|1}o=$+8|0;u=b;return o|0}$=f[3223]|0;if($>>>0>B>>>0){T=$-B|0;f[3223]=T;S=f[3226]|0;_=S+B|0;f[3226]=_;f[_+4>>2]=T|1;f[S+4>>2]=B|3;o=S+8|0;u=b;return o|0}if(!(f[3338]|0)){f[3340]=4096;f[3339]=4096;f[3341]=-1;f[3342]=-1;f[3343]=0;f[3331]=0;f[3338]=c&-16^1431655768;aa=4096}else aa=f[3340]|0;c=B+48|0;S=B+47|0;T=aa+S|0;_=0-aa|0;aa=T&_;if(aa>>>0<=B>>>0){o=0;u=b;return o|0}X=f[3330]|0;if(X|0?(Y=f[3328]|0,Z=Y+aa|0,Z>>>0<=Y>>>0|Z>>>0>X>>>0):0){o=0;u=b;return o|0}b:do if(!(f[3331]&4)){X=f[3226]|0;c:do if(X){Z=13328;while(1){Y=f[Z>>2]|0;if(Y>>>0<=X>>>0?(ba=Z+4|0,(Y+(f[ba>>2]|0)|0)>>>0>X>>>0):0)break;Y=f[Z+8>>2]|0;if(!Y){H=118;break c}else Z=Y}j=T-$&_;if(j>>>0<2147483647){Y=Vh(j|0)|0;if((Y|0)==((f[Z>>2]|0)+(f[ba>>2]|0)|0))if((Y|0)==(-1|0))ca=j;else{da=j;ea=Y;H=135;break b}else{fa=Y;ga=j;H=126}}else ca=0}else H=118;while(0);do if((H|0)==118){X=Vh(0)|0;if((X|0)!=(-1|0)?(e=X,j=f[3339]|0,Y=j+-1|0,U=((Y&e|0)==0?0:(Y+e&0-j)-e|0)+aa|0,e=f[3328]|0,j=U+e|0,U>>>0>B>>>0&U>>>0<2147483647):0){Y=f[3330]|0;if(Y|0?j>>>0<=e>>>0|j>>>0>Y>>>0:0){ca=0;break}Y=Vh(U|0)|0;if((Y|0)==(X|0)){da=U;ea=X;H=135;break b}else{fa=Y;ga=U;H=126}}else ca=0}while(0);do if((H|0)==126){U=0-ga|0;if(!(c>>>0>ga>>>0&(ga>>>0<2147483647&(fa|0)!=(-1|0))))if((fa|0)==(-1|0)){ca=0;break}else{da=ga;ea=fa;H=135;break b}Y=f[3340]|0;X=S-ga+Y&0-Y;if(X>>>0>=2147483647){da=ga;ea=fa;H=135;break b}if((Vh(X|0)|0)==(-1|0)){Vh(U|0)|0;ca=0;break}else{da=X+ga|0;ea=fa;H=135;break b}}while(0);f[3331]=f[3331]|4;ha=ca;H=133}else{ha=0;H=133}while(0);if(((H|0)==133?aa>>>0<2147483647:0)?(ca=Vh(aa|0)|0,aa=Vh(0)|0,fa=aa-ca|0,ga=fa>>>0>(B+40|0)>>>0,!((ca|0)==(-1|0)|ga^1|ca>>>0>>0&((ca|0)!=(-1|0)&(aa|0)!=(-1|0))^1)):0){da=ga?fa:ha;ea=ca;H=135}if((H|0)==135){ca=(f[3328]|0)+da|0;f[3328]=ca;if(ca>>>0>(f[3329]|0)>>>0)f[3329]=ca;ca=f[3226]|0;do if(ca){ha=13328;while(1){ia=f[ha>>2]|0;ja=ha+4|0;ka=f[ja>>2]|0;if((ea|0)==(ia+ka|0)){H=143;break}fa=f[ha+8>>2]|0;if(!fa)break;else ha=fa}if(((H|0)==143?(f[ha+12>>2]&8|0)==0:0)?ea>>>0>ca>>>0&ia>>>0<=ca>>>0:0){f[ja>>2]=ka+da;fa=(f[3223]|0)+da|0;ga=ca+8|0;aa=(ga&7|0)==0?0:0-ga&7;ga=ca+aa|0;S=fa-aa|0;f[3226]=ga;f[3223]=S;f[ga+4>>2]=S|1;f[ca+fa+4>>2]=40;f[3227]=f[3342];break}if(ea>>>0<(f[3224]|0)>>>0)f[3224]=ea;fa=ea+da|0;S=13328;while(1){if((f[S>>2]|0)==(fa|0)){H=151;break}ga=f[S+8>>2]|0;if(!ga){la=13328;break}else S=ga}if((H|0)==151)if(!(f[S+12>>2]&8)){f[S>>2]=ea;ha=S+4|0;f[ha>>2]=(f[ha>>2]|0)+da;ha=ea+8|0;ga=ea+((ha&7|0)==0?0:0-ha&7)|0;ha=fa+8|0;aa=fa+((ha&7|0)==0?0:0-ha&7)|0;ha=ga+B|0;c=aa-ga-B|0;f[ga+4>>2]=B|3;do if((ca|0)!=(aa|0)){if((f[3225]|0)==(aa|0)){ba=(f[3222]|0)+c|0;f[3222]=ba;f[3225]=ha;f[ha+4>>2]=ba|1;f[ha+ba>>2]=ba;break}ba=f[aa+4>>2]|0;if((ba&3|0)==1){_=ba&-8;$=ba>>>3;d:do if(ba>>>0<256){T=f[aa+8>>2]|0;X=f[aa+12>>2]|0;if((X|0)==(T|0)){f[3220]=f[3220]&~(1<<$);break}else{f[T+12>>2]=X;f[X+8>>2]=T;break}}else{T=f[aa+24>>2]|0;X=f[aa+12>>2]|0;do if((X|0)==(aa|0)){U=aa+16|0;Y=U+4|0;j=f[Y>>2]|0;if(!j){e=f[U>>2]|0;if(!e){ma=0;break}else{na=e;oa=U}}else{na=j;oa=Y}while(1){Y=na+20|0;j=f[Y>>2]|0;if(j|0){na=j;oa=Y;continue}Y=na+16|0;j=f[Y>>2]|0;if(!j)break;else{na=j;oa=Y}}f[oa>>2]=0;ma=na}else{Y=f[aa+8>>2]|0;f[Y+12>>2]=X;f[X+8>>2]=Y;ma=X}while(0);if(!T)break;X=f[aa+28>>2]|0;Y=13184+(X<<2)|0;do if((f[Y>>2]|0)!=(aa|0)){f[T+16+(((f[T+16>>2]|0)!=(aa|0)&1)<<2)>>2]=ma;if(!ma)break d}else{f[Y>>2]=ma;if(ma|0)break;f[3221]=f[3221]&~(1<>2]=T;X=aa+16|0;Y=f[X>>2]|0;if(Y|0){f[ma+16>>2]=Y;f[Y+24>>2]=ma}Y=f[X+4>>2]|0;if(!Y)break;f[ma+20>>2]=Y;f[Y+24>>2]=ma}while(0);pa=aa+_|0;qa=_+c|0}else{pa=aa;qa=c}$=pa+4|0;f[$>>2]=f[$>>2]&-2;f[ha+4>>2]=qa|1;f[ha+qa>>2]=qa;$=qa>>>3;if(qa>>>0<256){ba=12920+($<<1<<2)|0;Z=f[3220]|0;Y=1<<$;if(!(Z&Y)){f[3220]=Z|Y;ra=ba;sa=ba+8|0}else{Y=ba+8|0;ra=f[Y>>2]|0;sa=Y}f[sa>>2]=ha;f[ra+12>>2]=ha;f[ha+8>>2]=ra;f[ha+12>>2]=ba;break}ba=qa>>>8;do if(!ba)ta=0;else{if(qa>>>0>16777215){ta=31;break}Y=(ba+1048320|0)>>>16&8;Z=ba<>>16&4;X=Z<<$;Z=(X+245760|0)>>>16&2;j=14-($|Y|Z)+(X<>>15)|0;ta=qa>>>(j+7|0)&1|j<<1}while(0);ba=13184+(ta<<2)|0;f[ha+28>>2]=ta;_=ha+16|0;f[_+4>>2]=0;f[_>>2]=0;_=f[3221]|0;j=1<>2]=ha;f[ha+24>>2]=ba;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}j=qa<<((ta|0)==31?0:25-(ta>>>1)|0);_=f[ba>>2]|0;while(1){if((f[_+4>>2]&-8|0)==(qa|0)){H=192;break}ua=_+16+(j>>>31<<2)|0;ba=f[ua>>2]|0;if(!ba){H=191;break}else{j=j<<1;_=ba}}if((H|0)==191){f[ua>>2]=ha;f[ha+24>>2]=_;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}else if((H|0)==192){j=_+8|0;ba=f[j>>2]|0;f[ba+12>>2]=ha;f[j>>2]=ha;f[ha+8>>2]=ba;f[ha+12>>2]=_;f[ha+24>>2]=0;break}}else{ba=(f[3223]|0)+c|0;f[3223]=ba;f[3226]=ha;f[ha+4>>2]=ba|1}while(0);o=ga+8|0;u=b;return o|0}else la=13328;while(1){ha=f[la>>2]|0;if(ha>>>0<=ca>>>0?(va=ha+(f[la+4>>2]|0)|0,va>>>0>ca>>>0):0)break;la=f[la+8>>2]|0}ga=va+-47|0;ha=ga+8|0;c=ga+((ha&7|0)==0?0:0-ha&7)|0;ha=ca+16|0;ga=c>>>0>>0?ca:c;c=ga+8|0;aa=da+-40|0;fa=ea+8|0;S=(fa&7|0)==0?0:0-fa&7;fa=ea+S|0;ba=aa-S|0;f[3226]=fa;f[3223]=ba;f[fa+4>>2]=ba|1;f[ea+aa+4>>2]=40;f[3227]=f[3342];aa=ga+4|0;f[aa>>2]=27;f[c>>2]=f[3332];f[c+4>>2]=f[3333];f[c+8>>2]=f[3334];f[c+12>>2]=f[3335];f[3332]=ea;f[3333]=da;f[3335]=0;f[3334]=c;c=ga+24|0;do{ba=c;c=c+4|0;f[c>>2]=7}while((ba+8|0)>>>0>>0);if((ga|0)!=(ca|0)){c=ga-ca|0;f[aa>>2]=f[aa>>2]&-2;f[ca+4>>2]=c|1;f[ga>>2]=c;ba=c>>>3;if(c>>>0<256){fa=12920+(ba<<1<<2)|0;S=f[3220]|0;j=1<>2]|0;xa=j}f[xa>>2]=ca;f[wa+12>>2]=ca;f[ca+8>>2]=wa;f[ca+12>>2]=fa;break}fa=c>>>8;if(fa)if(c>>>0>16777215)ya=31;else{j=(fa+1048320|0)>>>16&8;S=fa<>>16&4;ba=S<>>16&2;Z=14-(fa|j|S)+(ba<>>15)|0;ya=c>>>(Z+7|0)&1|Z<<1}else ya=0;Z=13184+(ya<<2)|0;f[ca+28>>2]=ya;f[ca+20>>2]=0;f[ha>>2]=0;S=f[3221]|0;ba=1<>2]=ca;f[ca+24>>2]=Z;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}ba=c<<((ya|0)==31?0:25-(ya>>>1)|0);S=f[Z>>2]|0;while(1){if((f[S+4>>2]&-8|0)==(c|0)){H=213;break}za=S+16+(ba>>>31<<2)|0;Z=f[za>>2]|0;if(!Z){H=212;break}else{ba=ba<<1;S=Z}}if((H|0)==212){f[za>>2]=ca;f[ca+24>>2]=S;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}else if((H|0)==213){ba=S+8|0;c=f[ba>>2]|0;f[c+12>>2]=ca;f[ba>>2]=ca;f[ca+8>>2]=c;f[ca+12>>2]=S;f[ca+24>>2]=0;break}}}else{c=f[3224]|0;if((c|0)==0|ea>>>0>>0)f[3224]=ea;f[3332]=ea;f[3333]=da;f[3335]=0;f[3229]=f[3338];f[3228]=-1;f[3233]=12920;f[3232]=12920;f[3235]=12928;f[3234]=12928;f[3237]=12936;f[3236]=12936;f[3239]=12944;f[3238]=12944;f[3241]=12952;f[3240]=12952;f[3243]=12960;f[3242]=12960;f[3245]=12968;f[3244]=12968;f[3247]=12976;f[3246]=12976;f[3249]=12984;f[3248]=12984;f[3251]=12992;f[3250]=12992;f[3253]=13e3;f[3252]=13e3;f[3255]=13008;f[3254]=13008;f[3257]=13016;f[3256]=13016;f[3259]=13024;f[3258]=13024;f[3261]=13032;f[3260]=13032;f[3263]=13040;f[3262]=13040;f[3265]=13048;f[3264]=13048;f[3267]=13056;f[3266]=13056;f[3269]=13064;f[3268]=13064;f[3271]=13072;f[3270]=13072;f[3273]=13080;f[3272]=13080;f[3275]=13088;f[3274]=13088;f[3277]=13096;f[3276]=13096;f[3279]=13104;f[3278]=13104;f[3281]=13112;f[3280]=13112;f[3283]=13120;f[3282]=13120;f[3285]=13128;f[3284]=13128;f[3287]=13136;f[3286]=13136;f[3289]=13144;f[3288]=13144;f[3291]=13152;f[3290]=13152;f[3293]=13160;f[3292]=13160;f[3295]=13168;f[3294]=13168;c=da+-40|0;ba=ea+8|0;ha=(ba&7|0)==0?0:0-ba&7;ba=ea+ha|0;ga=c-ha|0;f[3226]=ba;f[3223]=ga;f[ba+4>>2]=ga|1;f[ea+c+4>>2]=40;f[3227]=f[3342]}while(0);ea=f[3223]|0;if(ea>>>0>B>>>0){da=ea-B|0;f[3223]=da;ea=f[3226]|0;ca=ea+B|0;f[3226]=ca;f[ca+4>>2]=da|1;f[ea+4>>2]=B|3;o=ea+8|0;u=b;return o|0}}ea=ln()|0;f[ea>>2]=12;o=0;u=b;return o|0}function Za(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0,Ua=0,Va=0,Wa=0;d=u;u=u+80|0;e=d+56|0;g=d+40|0;h=d+16|0;i=d+4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f[j>>2];qc(r,e);I=108;break b;break}case 1:break;default:{M=-1;I=174;break a}}N=f[g>>2]|0;L=f[l>>2]|0;if((N|0)==(L|0)){M=-1;I=174;break a}X=L+-4|0;U=f[X>>2]|0;f[l>>2]=X;Y=f[C>>2]|0;c:do if(Y){P=Y+-1|0;K=(P&Y|0)==0;if(!K)if(F>>>0>>0)ea=F;else ea=(F>>>0)%(Y>>>0)|0;else ea=P&F;V=f[(f[h>>2]|0)+(ea<<2)>>2]|0;if((V|0)!=0?(J=f[V>>2]|0,(J|0)!=0):0){d:do if(K){V=J;while(1){O=f[V+4>>2]|0;S=(O|0)==(F|0);if(!(S|(O&P|0)==(ea|0))){fa=N;ga=X;break c}if(S?(f[V+8>>2]|0)==(F|0):0){ha=V;break d}V=f[V>>2]|0;if(!V){fa=N;ga=X;break c}}}else{V=J;while(1){S=f[V+4>>2]|0;if((S|0)==(F|0)){if((f[V+8>>2]|0)==(F|0)){ha=V;break d}}else{if(S>>>0>>0)ia=S;else ia=(S>>>0)%(Y>>>0)|0;if((ia|0)!=(ea|0)){fa=N;ga=X;break c}}V=f[V>>2]|0;if(!V){fa=N;ga=X;break c}}}while(0);J=ha+12|0;if((X|0)==(f[w>>2]|0)){xf(g,J);fa=f[g>>2]|0;ga=f[l>>2]|0;break}else{f[X>>2]=f[J>>2];f[l>>2]=L;fa=N;ga=L;break}}else{fa=N;ga=X}}else{fa=N;ga=X}while(0);if((fa|0)==(ga|0)){M=-1;I=174;break a}X=f[ga+-4>>2]|0;N=F*3|0;L=N+2|0;Y=f[v>>2]|0;J=f[Y+12>>2]|0;f[J+(X<<2)>>2]=L;f[J+(L<<2)>>2]=X;P=N+1|0;f[J+(U<<2)>>2]=P;f[J+(P<<2)>>2]=U;if((X|0)!=-1){K=(((X>>>0)%3|0|0)==0?2:-1)+X|0;if((K|0)==-1)ja=-1;else ja=f[(f[Y>>2]|0)+(K<<2)>>2]|0;K=f[Y>>2]|0;f[K+(N<<2)>>2]=ja;V=X+1|0;S=((V>>>0)%3|0|0)==0?X+-2|0:V;if((S|0)==-1){ka=-1;la=ja;ma=K;na=Y}else{ka=f[K+(S<<2)>>2]|0;la=ja;ma=K;na=Y}}else{K=f[Y>>2]|0;f[K+(N<<2)>>2]=-1;ka=-1;la=-1;ma=K;na=Y}f[ma+(P<<2)>>2]=ka;if((U|0)!=-1){P=(((U>>>0)%3|0|0)==0?2:-1)+U|0;if((P|0)!=-1){K=f[ma+(P<<2)>>2]|0;f[ma+(L<<2)>>2]=K;if((K|0)!=-1)f[(f[Y+24>>2]|0)+(K<<2)>>2]=L}else f[ma+(L<<2)>>2]=-1;K=U+1|0;P=((K>>>0)%3|0|0)==0?U+-2|0:K;if((P|0)==-1){oa=-1;pa=-1}else{oa=f[ma+(P<<2)>>2]|0;pa=P}}else{f[ma+(L<<2)>>2]=-1;oa=-1;pa=-1}f[e>>2]=oa;L=f[D>>2]|0;P=L+(la<<2)|0;f[P>>2]=(f[P>>2]|0)+(f[L+(oa<<2)>>2]|0);L=f[Y+24>>2]|0;if((la|0)!=-1)f[L+(la<<2)>>2]=f[L+(f[e>>2]<<2)>>2];e:do if((pa|0)!=-1){Y=f[na>>2]|0;P=pa;do{f[Y+(P<<2)>>2]=la;K=P+1|0;S=((K>>>0)%3|0|0)==0?P+-2|0:K;if((S|0)==-1)break e;K=f[J+(S<<2)>>2]|0;S=K+1|0;if((K|0)==-1)break e;P=((S>>>0)%3|0|0)==0?K+-2|0:S}while((P|0)!=-1)}while(0);f[L+(f[e>>2]<<2)>>2]=-1;do if(o){J=f[m>>2]|0;if((J|0)==(f[E>>2]|0)){xf(i,e);qa=f[l>>2]|0;break}else{f[J>>2]=f[e>>2];f[m>>2]=J+4;qa=ga;break}}else qa=ga;while(0);f[qa+-4>>2]=N;ba=qa}f[j>>2]=f[ba+-4>>2];f[e>>2]=f[j>>2];qc(r,e)}while(0);if((I|0)==89){I=0;f[e>>2]=F*3;H=f[v>>2]|0;L=H+24|0;J=H+28|0;U=f[J>>2]|0;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2]=U+-12;if((Y|0)<0){M=-1;I=174;break a}U=f[(f[l>>2]|0)+-4>>2]|0;K=(U|0)==-1;do if(!(L&1))if(!K)if(!((U>>>0)%3|0)){xa=U+2|0;break}else{xa=U+-1|0;break}else xa=-1;else{J=U+1|0;if(K)xa=-1;else xa=((J>>>0)%3|0|0)==0?U+-2|0:J}while(0);f[e>>2]=z-Y;U=sc(h,e)|0;f[U>>2]=xa;H=f[y>>2]|0}while((H|0)!=(f[x>>2]|0))}while(0);if((G|0)<(c|0))F=G;else{ya=G;za=v;I=121;break}}}else{ya=0;za=a+8|0;I=121}while(0);g:do if((I|0)==121){c=f[za>>2]|0;if(((f[c+28>>2]|0)-(f[c+24>>2]|0)>>2|0)<=(q|0)){xa=f[l>>2]|0;do if((xa|0)!=(f[g>>2]|0)){j=a+304|0;wa=a+60|0;va=a+64|0;ua=a+68|0;sa=a+76|0;ta=a+80|0;ra=a+72|0;ba=ya;qa=xa;h:while(1){ga=qa;f[e>>2]=f[ga+-4>>2];f[l>>2]=ga+-4;do if(!(Wg(j)|0)){ga=f[va>>2]|0;o=f[ua>>2]|0;if((ga|0)==(o<<5|0)){if((ga+1|0)<0){I=149;break h}la=o<<6;o=ga+32&-32;af(wa,ga>>>0<1073741823?(la>>>0>>0?o:la):2147483647);Aa=f[va>>2]|0}else Aa=ga;f[va>>2]=Aa+1;ga=(f[wa>>2]|0)+(Aa>>>5<<2)|0;f[ga>>2]=f[ga>>2]&~(1<<(Aa&31));ga=f[sa>>2]|0;if((ga|0)==(f[ta>>2]|0)){xf(ra,e);Ba=ba;break}else{f[ga>>2]=f[e>>2];f[sa>>2]=ga+4;Ba=ba;break}}else{ga=f[za>>2]|0;la=f[ga>>2]|0;o=la;if((ba|0)>=(((f[ga+4>>2]|0)-la>>2>>>0)/3|0|0)){I=155;break h}la=f[e>>2]|0;pa=la+1|0;if((la|0)!=-1?(na=((pa>>>0)%3|0|0)==0?la+-2|0:pa,(na|0)!=-1):0)Ca=f[o+(na<<2)>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Ja&31));pa=ba+1|0;ma=f[va>>2]|0;o=f[ua>>2]|0;if((ma|0)==(o<<5|0)){if((ma+1|0)<0){I=139;break h}la=o<<6;o=ma+32&-32;af(wa,ma>>>0<1073741823?(la>>>0>>0?o:la):2147483647);Ka=f[va>>2]|0}else Ka=ma;f[va>>2]=Ka+1;ma=(f[wa>>2]|0)+(Ka>>>5<<2)|0;f[ma>>2]=f[ma>>2]|1<<(Ka&31);ma=f[sa>>2]|0;if((ma|0)==(f[ta>>2]|0))xf(ra,k);else{f[ma>>2]=f[k>>2];f[sa>>2]=ma+4}Ba=pa}while(0);qa=f[l>>2]|0;if((qa|0)==(f[g>>2]|0)){I=156;break}else ba=Ba}if((I|0)==139)um(wa);else if((I|0)==149)um(wa);else if((I|0)==155){M=-1;I=174;break g}else if((I|0)==156){La=Ba;Ma=f[za>>2]|0;break}}else{La=ya;Ma=c}while(0);if((La|0)==(((f[Ma+4>>2]|0)-(f[Ma>>2]|0)>>2>>>0)/3|0|0)){c=(f[Ma+28>>2]|0)-(f[Ma+24>>2]|0)>>2;xa=f[i>>2]|0;ba=f[m>>2]|0;if((xa|0)==(ba|0)){Na=c;Oa=xa}else{qa=e+4|0;sa=e+8|0;ra=e+12|0;ta=c;c=xa;xa=Ma;while(1){va=f[c>>2]|0;ua=ta+-1|0;j=f[xa+24>>2]|0;if((f[j+(ua<<2)>>2]|0)==-1){G=ta;while(1){pa=G+-1|0;ma=G+-2|0;if((f[j+(ma<<2)>>2]|0)==-1)G=pa;else{Pa=pa;Qa=ma;break}}}else{Pa=ta;Qa=ua}if(Qa>>>0>>0){Ra=Pa;Sa=xa}else{f[e>>2]=xa;G=f[j+(Qa<<2)>>2]|0;f[qa>>2]=G;f[sa>>2]=G;b[ra>>0]=1;if((G|0)==-1){Ta=j;Ua=xa}else{wa=xa;ma=G;do{f[(f[wa>>2]|0)+(ma<<2)>>2]=va;Fe(e);ma=f[sa>>2]|0;wa=f[za>>2]|0}while((ma|0)!=-1);Ta=f[wa+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t>>2]|0)+24>>2]|0;if(I){f[K+(L<<2)>>2]=R;if((I|0)!=-1){f[K+(I<<2)>>2]=(f[j>>2]|0)+1;L=I+1|0;if((L|0)!=-1){Z=L;F=103}}else{Z=0;F=103}}else{f[K+(I<<2)>>2]=R+1;Z=1;F=103}if((F|0)==103){F=0;f[K+(Z<<2)>>2]=(f[j>>2]|0)+2}K=f[l>>2]|0;if((K|0)==(f[w>>2]|0))xf(e,j);else{f[K>>2]=f[j>>2];f[l>>2]=K+4}break}default:break b}K=c-D+-1|0;R=f[B>>2]|0;if((R|0)==(f[A>>2]|0))break;else _=R;while(1){R=_;I=f[R+-8>>2]|0;if(I>>>0>K>>>0){P=-1;F=177;break a}if((I|0)!=(K|0))break c;I=b[R+-4>>0]|0;L=f[R+-12>>2]|0;f[B>>2]=R+-12;if((L|0)<0){P=-1;F=177;break a}R=f[(f[l>>2]|0)+-4>>2]|0;Q=(R|0)==-1;do if(!(I&1))if(!Q)if(!((R>>>0)%3|0)){aa=R+2|0;break}else{aa=R+-1|0;break}else aa=-1;else{G=R+1|0;if(Q)aa=-1;else aa=((G>>>0)%3|0|0)==0?R+-2|0:G}while(0);f[j>>2]=C-L;R=sc(g,j)|0;f[R>>2]=aa;_=f[B>>2]|0;if((_|0)==(f[A>>2]|0))break c}}K=f[l>>2]|0;if((f[e>>2]|0)==(K|0)){P=-1;F=177;break a}R=K+-4|0;K=f[R>>2]|0;Q=f[t>>2]|0;I=(K|0)==-1;G=K+1|0;if(!I?(S=((G>>>0)%3|0|0)==0?K+-2|0:G,(S|0)!=-1):0)ba=f[(f[Q>>2]|0)+(S<<2)>>2]|0;else ba=-1;S=f[Q+24>>2]|0;G=f[S+(ba<<2)>>2]|0;H=G+1|0;J=S;if((G|0)==-1)ca=-1;else ca=((H>>>0)%3|0|0)==0?G+-2|0:H;H=D*3|0;G=H+1|0;da=f[Q+12>>2]|0;f[da+(K<<2)>>2]=G;f[da+(G<<2)>>2]=K;ea=H+2|0;f[da+(ca<<2)>>2]=ea;f[da+(ea<<2)>>2]=ca;da=f[Q>>2]|0;f[da+(H<<2)>>2]=ba;fa=ca+1|0;if((ca|0)!=-1?(ga=((fa>>>0)%3|0|0)==0?ca+-2|0:fa,(ga|0)!=-1):0)ha=f[da+(ga<<2)>>2]|0;else ha=-1;f[da+(G<<2)>>2]=ha;if(!I?(I=(((K>>>0)%3|0|0)==0?2:-1)+K|0,(I|0)!=-1):0){K=f[da+(I<<2)>>2]|0;f[da+(ea<<2)>>2]=K;if((K|0)!=-1)f[S+(K<<2)>>2]=ea}else f[da+(ea<<2)>>2]=-1;if(((f[Q+28>>2]|0)-J>>2|0)>(q|0)){P=-1;F=177;break a}J=(f[p>>2]|0)+(ba>>>5<<2)|0;f[J>>2]=f[J>>2]&~(1<<(ba&31));f[R>>2]=H}while(0);if((F|0)==42){F=0;H=f[e>>2]|0;R=f[l>>2]|0;if((H|0)==(R|0)){P=-1;F=177;break a}J=R+-4|0;Q=f[J>>2]|0;f[l>>2]=J;ea=f[s>>2]|0;d:do if(ea){da=ea+-1|0;K=(da&ea|0)==0;if(!K)if(D>>>0>>0)ia=D;else ia=(D>>>0)%(ea>>>0)|0;else ia=da&D;S=f[(f[g>>2]|0)+(ia<<2)>>2]|0;if((S|0)!=0?(I=f[S>>2]|0,(I|0)!=0):0){e:do if(K){S=I;while(1){G=f[S+4>>2]|0;ga=(G|0)==(D|0);if(!(ga|(G&da|0)==(ia|0))){ja=H;ka=J;break d}if(ga?(f[S+8>>2]|0)==(D|0):0){la=S;break e}S=f[S>>2]|0;if(!S){ja=H;ka=J;break d}}}else{S=I;while(1){L=f[S+4>>2]|0;if((L|0)==(D|0)){if((f[S+8>>2]|0)==(D|0)){la=S;break e}}else{if(L>>>0>>0)ma=L;else ma=(L>>>0)%(ea>>>0)|0;if((ma|0)!=(ia|0)){ja=H;ka=J;break d}}S=f[S>>2]|0;if(!S){ja=H;ka=J;break d}}}while(0);I=la+12|0;if((J|0)==(f[w>>2]|0)){xf(e,I);ja=f[e>>2]|0;ka=f[l>>2]|0;break}else{f[J>>2]=f[I>>2];f[l>>2]=R;ja=H;ka=R;break}}else{ja=H;ka=J}}else{ja=H;ka=J}while(0);if((ja|0)==(ka|0)){P=-1;F=177;break a}J=f[ka+-4>>2]|0;H=D*3|0;R=H+2|0;ea=f[t>>2]|0;I=f[ea+12>>2]|0;f[I+(J<<2)>>2]=R;f[I+(R<<2)>>2]=J;da=H+1|0;f[I+(Q<<2)>>2]=da;f[I+(da<<2)>>2]=Q;if((J|0)!=-1){K=(((J>>>0)%3|0|0)==0?2:-1)+J|0;if((K|0)==-1)na=-1;else na=f[(f[ea>>2]|0)+(K<<2)>>2]|0;K=f[ea>>2]|0;f[K+(H<<2)>>2]=na;S=J+1|0;L=((S>>>0)%3|0|0)==0?J+-2|0:S;if((L|0)==-1){oa=-1;pa=na;qa=K;ra=ea}else{oa=f[K+(L<<2)>>2]|0;pa=na;qa=K;ra=ea}}else{K=f[ea>>2]|0;f[K+(H<<2)>>2]=-1;oa=-1;pa=-1;qa=K;ra=ea}f[qa+(da<<2)>>2]=oa;if((Q|0)!=-1){da=(((Q>>>0)%3|0|0)==0?2:-1)+Q|0;if((da|0)!=-1){K=f[qa+(da<<2)>>2]|0;f[qa+(R<<2)>>2]=K;if((K|0)!=-1)f[(f[ea+24>>2]|0)+(K<<2)>>2]=R}else f[qa+(R<<2)>>2]=-1;K=Q+1|0;da=((K>>>0)%3|0|0)==0?Q+-2|0:K;if((da|0)==-1){sa=-1;ta=-1}else{sa=f[qa+(da<<2)>>2]|0;ta=da}}else{f[qa+(R<<2)>>2]=-1;sa=-1;ta=-1}f[j>>2]=sa;R=f[ea+24>>2]|0;if((pa|0)!=-1)f[R+(pa<<2)>>2]=f[R+(sa<<2)>>2];f:do if((ta|0)!=-1){ea=f[ra>>2]|0;da=ta;do{f[ea+(da<<2)>>2]=pa;K=da+1|0;L=((K>>>0)%3|0|0)==0?da+-2|0:K;if((L|0)==-1)break f;K=f[I+(L<<2)>>2]|0;L=K+1|0;if((K|0)==-1)break f;da=((L>>>0)%3|0|0)==0?K+-2|0:L}while((da|0)!=-1)}while(0);f[R+(f[j>>2]<<2)>>2]=-1;do if(o){I=f[m>>2]|0;if((I|0)==(f[v>>2]|0)){xf(i,j);ua=f[l>>2]|0;break}else{f[I>>2]=f[j>>2];f[m>>2]=I+4;ua=ka;break}}else ua=ka;while(0);f[ua+-4>>2]=H}if((E|0)<(c|0))D=E;else{va=E;wa=t;F=123;break a}}}else{va=0;wa=a+8|0;F=123}while(0);g:do if((F|0)==123){c=f[wa>>2]|0;if(((f[c+28>>2]|0)-(f[c+24>>2]|0)>>2|0)<=(q|0)){ua=f[l>>2]|0;do if((ua|0)!=(f[e>>2]|0)){ka=a+304|0;o=a+60|0;pa=a+64|0;ta=a+68|0;ra=a+76|0;sa=a+80|0;qa=a+72|0;oa=va;na=ua;h:while(1){ja=na;f[j>>2]=f[ja+-4>>2];f[l>>2]=ja+-4;do if(!(Wg(ka)|0)){ja=f[pa>>2]|0;la=f[ta>>2]|0;if((ja|0)==(la<<5|0)){if((ja+1|0)<0){F=151;break h}ia=la<<6;la=ja+32&-32;af(o,ja>>>0<1073741823?(ia>>>0>>0?la:ia):2147483647);xa=f[pa>>2]|0}else xa=ja;f[pa>>2]=xa+1;ja=(f[o>>2]|0)+(xa>>>5<<2)|0;f[ja>>2]=f[ja>>2]&~(1<<(xa&31));ja=f[ra>>2]|0;if((ja|0)==(f[sa>>2]|0)){xf(qa,j);ya=oa;break}else{f[ja>>2]=f[j>>2];f[ra>>2]=ja+4;ya=oa;break}}else{ja=f[wa>>2]|0;ia=f[ja>>2]|0;la=ia;if((oa|0)>=(((f[ja+4>>2]|0)-ia>>2>>>0)/3|0|0)){F=157;break h}ia=f[j>>2]|0;ma=ia+1|0;if((ia|0)!=-1?(ba=((ma>>>0)%3|0|0)==0?ia+-2|0:ma,(ba|0)!=-1):0)za=f[la+(ba<<2)>>2]|0;else za=-1;ba=f[ja+24>>2]|0;ma=f[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;la=f[ta>>2]|0;if((ca|0)==(la<<5|0)){if((ca+1|0)<0){F=141;break h}ia=la<<6;la=ca+32&-32;af(o,ca>>>0<1073741823?(ia>>>0>>0?la:ia):2147483647);Ha=f[pa>>2]|0}else Ha=ca;f[pa>>2]=Ha+1;ca=(f[o>>2]|0)+(Ha>>>5<<2)|0;f[ca>>2]=f[ca>>2]|1<<(Ha&31);ca=f[ra>>2]|0;if((ca|0)==(f[sa>>2]|0))xf(qa,k);else{f[ca>>2]=f[k>>2];f[ra>>2]=ca+4}ya=ma}while(0);na=f[l>>2]|0;if((na|0)==(f[e>>2]|0)){F=158;break}else oa=ya}if((F|0)==141)um(o);else if((F|0)==151)um(o);else if((F|0)==157){P=-1;F=177;break g}else if((F|0)==158){Ia=ya;Ja=f[wa>>2]|0;break}}else{Ia=va;Ja=c}while(0);if((Ia|0)==(((f[Ja+4>>2]|0)-(f[Ja>>2]|0)>>2>>>0)/3|0|0)){c=(f[Ja+28>>2]|0)-(f[Ja+24>>2]|0)>>2;ua=f[i>>2]|0;oa=f[m>>2]|0;if((ua|0)==(oa|0)){Ka=c;La=ua}else{na=j+4|0;ra=j+8|0;qa=j+12|0;sa=c;c=ua;ua=Ja;while(1){pa=f[c>>2]|0;ta=sa+-1|0;ka=f[ua+24>>2]|0;if((f[ka+(ta<<2)>>2]|0)==-1){E=sa;while(1){H=E+-1|0;ma=E+-2|0;if((f[ka+(ma<<2)>>2]|0)==-1)E=H;else{Ma=H;Na=ma;break}}}else{Ma=sa;Na=ta}if(Na>>>0>>0){Oa=Ma;Pa=ua}else{f[j>>2]=ua;E=f[ka+(Na<<2)>>2]|0;f[na>>2]=E;f[ra>>2]=E;b[qa>>0]=1;if((E|0)==-1){Qa=ka;Ra=ua}else{o=ua;ma=E;do{f[(f[o>>2]|0)+(ma<<2)>>2]=pa;Fe(j);ma=f[ra>>2]|0;o=f[wa>>2]|0}while((ma|0)!=-1);Qa=f[o+24>>2]|0;Ra=o}if((pa|0)==-1)Sa=Qa+(Na<<2)|0;else{ma=Qa+(Na<<2)|0;f[Qa+(pa<<2)>>2]=f[ma>>2];Sa=ma}f[Sa>>2]=-1;ma=f[p>>2]|0;ka=ma+(Na>>>5<<2)|0;ta=1<<(Na&31);E=ma+(pa>>>5<<2)|0;ma=1<<(pa&31);if(!(f[ka>>2]&ta))Ta=f[E>>2]&~ma;else Ta=f[E>>2]|ma;f[E>>2]=Ta;f[ka>>2]=f[ka>>2]&~ta;Oa=Ma+-1|0;Pa=Ra}c=c+4|0;if((c|0)==(oa|0)){P=Oa;F=177;break}else{sa=Oa;ua=Pa}}}}else{P=-1;F=177}}else{P=-1;F=177}}while(0);if((F|0)==177){Ka=P;La=f[i>>2]|0}if(La|0){i=f[m>>2]|0;if((i|0)!=(La|0))f[m>>2]=i+(~((i+-4-La|0)>>>2)<<2);dn(La)}La=f[g+8>>2]|0;if(La|0){i=La;do{La=i;i=f[i>>2]|0;dn(La)}while((i|0)!=0)}i=f[g>>2]|0;f[g>>2]=0;if(i|0)dn(i);i=f[e>>2]|0;if(!i){u=d;return Ka|0}e=f[l>>2]|0;if((e|0)!=(i|0))f[l>>2]=e+(~((e+-4-i|0)>>>2)<<2);dn(i);u=d;return Ka|0}function $a(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;b=u;u=u+16|0;c=b;d=b+8|0;e=b+4|0;f[d>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;h=g*210|0;f[e>>2]=a-h;i=0;j=g;g=(Oh(3400,3592,e,c)|0)-3400>>2;k=h;a:while(1){l=(f[3400+(g<<2)>>2]|0)+k|0;h=5;while(1){if(h>>>0>=47){m=211;n=i;o=8;break}p=f[3208+(h<<2)>>2]|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0

>>0){o=106;break a}if((l|0)==(X(q,p)|0)){r=i;break}else h=h+1|0}b:do if((o|0)==8){c:while(1){o=0;h=(l>>>0)/(m>>>0)|0;do if(h>>>0>=m>>>0)if((l|0)!=(X(h,m)|0)){p=m+10|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0>=p>>>0)if((l|0)!=(X(q,p)|0)){q=m+12|0;s=(l>>>0)/(q>>>0)|0;if(s>>>0>=q>>>0)if((l|0)!=(X(s,q)|0)){s=m+16|0;t=(l>>>0)/(s>>>0)|0;if(t>>>0>=s>>>0)if((l|0)!=(X(t,s)|0)){t=m+18|0;v=(l>>>0)/(t>>>0)|0;if(v>>>0>=t>>>0)if((l|0)!=(X(v,t)|0)){v=m+22|0;w=(l>>>0)/(v>>>0)|0;if(w>>>0>=v>>>0)if((l|0)!=(X(w,v)|0)){w=m+28|0;x=(l>>>0)/(w>>>0)|0;if(x>>>0>=w>>>0)if((l|0)==(X(x,w)|0)){y=w;z=9;A=n}else{x=m+30|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+36|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+40|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+42|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+46|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+52|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+58|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+60|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+66|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+70|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+72|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+78|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+82|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+88|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+96|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+100|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+102|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+106|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+108|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+112|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+120|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+126|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+130|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+136|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+138|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+142|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+148|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+150|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+156|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+162|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+166|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+168|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+172|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+178|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+180|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+186|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+190|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+192|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+196|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+198|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+208|0;B=(l>>>0)/(x>>>0)|0;C=B>>>0>>0;D=(l|0)==(X(B,x)|0);y=C|D?x:m+210|0;z=C?1:D?9:0;A=C?l:n}else{y=w;z=1;A=l}}else{y=v;z=9;A=n}else{y=v;z=1;A=l}}else{y=t;z=9;A=n}else{y=t;z=1;A=l}}else{y=s;z=9;A=n}else{y=s;z=1;A=l}}else{y=q;z=9;A=n}else{y=q;z=1;A=l}}else{y=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|0)!=(K|0)?!((H|0)==(L|0)|(K|0)==(L|0)):0){H=0;J=A;F=E;I=D;while(1){M=H+G|0;if(!(f[(f[e>>2]|0)+(M>>>5<<2)>>2]&1<<(M&31))){N=f[(f[a>>2]|0)+(M<<2)>>2]|0;f[g>>2]=N;if(!(f[F+(N>>>5<<2)>>2]&1<<(N&31))){O=0;P=J;Q=N}else{N=f[i>>2]|0;if((N|0)==(f[y>>2]|0))xf(h,2652);else{f[N>>2]=-1;f[i>>2]=N+4}N=f[v>>2]|0;if((N|0)==(f[w>>2]|0))xf(z,g);else{f[N>>2]=f[g>>2];f[v>>2]=N+4}N=f[l>>2]|0;R=f[j>>2]|0;if((N|0)==(R<<5|0)){if((N+1|0)<0){S=50;break a}T=R<<6;R=N+32&-32;af(d,N>>>0<1073741823?(T>>>0>>0?R:T):2147483647);U=f[l>>2]|0}else U=N;f[l>>2]=U+1;N=(f[d>>2]|0)+(U>>>5<<2)|0;f[N>>2]=f[N>>2]&~(1<<(U&31));f[g>>2]=J;O=1;P=J+1|0;Q=J}N=f[d>>2]|0;T=N+(Q>>>5<<2)|0;f[T>>2]=f[T>>2]|1<<(Q&31);T=N;b:do if(O){R=M;while(1){if((R|0)==-1){S=64;break b}V=(f[e>>2]|0)+(R>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(R&31);V=f[g>>2]|0;f[(f[h>>2]|0)+(V<<2)>>2]=R;f[(f[a>>2]|0)+(R<<2)>>2]=V;V=R+1|0;W=((V>>>0)%3|0|0)==0?R+-2|0:V;do if((W|0)==-1)X=-1;else{V=f[(f[x>>2]|0)+(W<<2)>>2]|0;Y=V+1|0;if((V|0)==-1){X=-1;break}X=((Y>>>0)%3|0|0)==0?V+-2|0:Y}while(0);if((X|0)==(M|0))break;else R=X}}else{R=M;while(1){if((R|0)==-1){S=64;break b}W=(f[e>>2]|0)+(R>>>5<<2)|0;f[W>>2]=f[W>>2]|1<<(R&31);f[(f[h>>2]|0)+(f[g>>2]<<2)>>2]=R;W=R+1|0;Y=((W>>>0)%3|0|0)==0?R+-2|0:W;do if((Y|0)==-1)Z=-1;else{W=f[(f[x>>2]|0)+(Y<<2)>>2]|0;V=W+1|0;if((W|0)==-1){Z=-1;break}Z=((V>>>0)%3|0|0)==0?W+-2|0:V}while(0);if((Z|0)==(M|0))break;else R=Z}}while(0);c:do if((S|0)==64){S=0;if((M|0)==-1)break;R=(((M>>>0)%3|0|0)==0?2:-1)+M|0;if((R|0)==-1)break;Y=f[(f[x>>2]|0)+(R<<2)>>2]|0;if((Y|0)==-1)break;R=Y+(((Y>>>0)%3|0|0)==0?2:-1)|0;if((R|0)==-1)break;if(!O){Y=R;while(1){V=(f[e>>2]|0)+(Y>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(Y&31);V=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((V|0)==-1)break c;W=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((W|0)==-1)break c;Y=W+(((W>>>0)%3|0|0)==0?2:-1)|0;if((Y|0)==-1)break c}}Y=f[a>>2]|0;W=R;do{V=(f[e>>2]|0)+(W>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(W&31);f[Y+(W<<2)>>2]=f[g>>2];V=(((W>>>0)%3|0|0)==0?2:-1)+W|0;if((V|0)==-1)break c;_=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((_|0)==-1)break c;W=_+(((_>>>0)%3|0|0)==0?2:-1)|0}while((W|0)!=-1)}while(0);$=P;aa=T;ba=N}else{$=J;aa=I;ba=F}if((H|0)<2){H=H+1|0;J=$;F=ba;I=aa}else{ca=$;da=aa;ea=ba;break}}}else{ca=A;da=D;ea=E}}else{ca=A;da=D;ea=E}C=C+1|0;B=f[a>>2]|0;if(C>>>0>=(((f[m>>2]|0)-B>>2>>>0)/3|0)>>>0){S=18;break}else{A=ca;D=da;E=ea}}if((S|0)==18){fa=da;ga=f[l>>2]|0;break}else if((S|0)==50)um(d)}else{fa=q;ga=p}}else{fa=q;ga=p}while(0);p=a+44|0;f[p>>2]=0;a=fa;fa=ga>>>5;q=a+(fa<<2)|0;S=ga&31;ga=(fa|0)!=0;d:do if(fa|S|0)if(!S){l=a;da=0;ea=ga;while(1){e:do if(ea){if(!(f[l>>2]&1)){ca=da+1|0;f[p>>2]=ca;ha=ca}else ha=da;if(!(f[l>>2]&2)){ca=ha+1|0;f[p>>2]=ca;ia=ca}else ia=ha;if(!(f[l>>2]&4)){ca=ia+1|0;f[p>>2]=ca;ja=ca}else ja=ia;if(!(f[l>>2]&8)){ca=ja+1|0;f[p>>2]=ca;ka=ca}else ka=ja;if(!(f[l>>2]&16)){ca=ka+1|0;f[p>>2]=ca;la=ca}else la=ka;if(!(f[l>>2]&32)){ca=la+1|0;f[p>>2]=ca;ma=ca}else ma=la;if(!(f[l>>2]&64)){ca=ma+1|0;f[p>>2]=ca;na=ca}else na=ma;if(!(f[l>>2]&128)){ca=na+1|0;f[p>>2]=ca;oa=ca}else oa=na;if(!(f[l>>2]&256)){ca=oa+1|0;f[p>>2]=ca;pa=ca}else pa=oa;if(!(f[l>>2]&512)){ca=pa+1|0;f[p>>2]=ca;qa=ca}else qa=pa;if(!(f[l>>2]&1024)){ca=qa+1|0;f[p>>2]=ca;ra=ca}else ra=qa;if(!(f[l>>2]&2048)){ca=ra+1|0;f[p>>2]=ca;sa=ca}else sa=ra;if(!(f[l>>2]&4096)){ca=sa+1|0;f[p>>2]=ca;ta=ca}else ta=sa;if(!(f[l>>2]&8192)){ca=ta+1|0;f[p>>2]=ca;ua=ca}else ua=ta;if(!(f[l>>2]&16384)){ca=ua+1|0;f[p>>2]=ca;va=ca}else va=ua;if(!(f[l>>2]&32768)){ca=va+1|0;f[p>>2]=ca;wa=ca}else wa=va;if(!(f[l>>2]&65536)){ca=wa+1|0;f[p>>2]=ca;xa=ca}else xa=wa;if(!(f[l>>2]&131072)){ca=xa+1|0;f[p>>2]=ca;ya=ca}else ya=xa;if(!(f[l>>2]&262144)){ca=ya+1|0;f[p>>2]=ca;za=ca}else za=ya;if(!(f[l>>2]&524288)){ca=za+1|0;f[p>>2]=ca;Aa=ca}else Aa=za;if(!(f[l>>2]&1048576)){ca=Aa+1|0;f[p>>2]=ca;Ba=ca}else Ba=Aa;if(!(f[l>>2]&2097152)){ca=Ba+1|0;f[p>>2]=ca;Ca=ca}else Ca=Ba;if(!(f[l>>2]&4194304)){ca=Ca+1|0;f[p>>2]=ca;Da=ca}else Da=Ca;if(!(f[l>>2]&8388608)){ca=Da+1|0;f[p>>2]=ca;Ea=ca}else Ea=Da;if(!(f[l>>2]&16777216)){ca=Ea+1|0;f[p>>2]=ca;Fa=ca}else Fa=Ea;if(!(f[l>>2]&33554432)){ca=Fa+1|0;f[p>>2]=ca;Ga=ca}else Ga=Fa;if(!(f[l>>2]&67108864)){ca=Ga+1|0;f[p>>2]=ca;Ha=ca}else Ha=Ga;if(!(f[l>>2]&134217728)){ca=Ha+1|0;f[p>>2]=ca;Ia=ca}else Ia=Ha;if(!(f[l>>2]&268435456)){ca=Ia+1|0;f[p>>2]=ca;Ja=ca}else Ja=Ia;if(!(f[l>>2]&536870912)){ca=Ja+1|0;f[p>>2]=ca;Ka=ca}else Ka=Ja;if(!(f[l>>2]&1073741824)){ca=Ka+1|0;f[p>>2]=ca;La=ca}else La=Ka;if((f[l>>2]|0)<=-1){Ma=La;break}ca=La+1|0;f[p>>2]=ca;Ma=ca}else{ca=0;m=da;while(1){if(!(f[l>>2]&1<>2]=ba;Na=ba}else Na=m;if((ca|0)==31){Ma=Na;break e}ca=ca+1|0;if(!ca)break d;else m=Na}}while(0);l=l+4|0;if((q|0)==(l|0))break;else{da=Ma;ea=1}}}else{if(ga){ea=0;da=a;l=0;while(1){if(!(f[da>>2]&1)){m=l+1|0;f[p>>2]=m;Oa=m;Pa=m}else{Oa=l;Pa=ea}if(!(f[da>>2]&2)){m=Oa+1|0;f[p>>2]=m;Qa=m;Ra=m}else{Qa=Oa;Ra=Pa}if(!(f[da>>2]&4)){m=Qa+1|0;f[p>>2]=m;Sa=m;Ta=m}else{Sa=Qa;Ta=Ra}if(!(f[da>>2]&8)){m=Sa+1|0;f[p>>2]=m;Ua=m;Va=m}else{Ua=Sa;Va=Ta}if(!(f[da>>2]&16)){m=Ua+1|0;f[p>>2]=m;Wa=m;Xa=m}else{Wa=Ua;Xa=Va}if(!(f[da>>2]&32)){m=Wa+1|0;f[p>>2]=m;Ya=m;Za=m}else{Ya=Wa;Za=Xa}if(!(f[da>>2]&64)){m=Ya+1|0;f[p>>2]=m;_a=m;$a=m}else{_a=Ya;$a=Za}if(!(f[da>>2]&128)){m=_a+1|0;f[p>>2]=m;ab=m;bb=m}else{ab=_a;bb=$a}if(!(f[da>>2]&256)){m=ab+1|0;f[p>>2]=m;cb=m;db=m}else{cb=ab;db=bb}if(!(f[da>>2]&512)){m=cb+1|0;f[p>>2]=m;eb=m;fb=m}else{eb=cb;fb=db}if(!(f[da>>2]&1024)){m=eb+1|0;f[p>>2]=m;gb=m;hb=m}else{gb=eb;hb=fb}if(!(f[da>>2]&2048)){m=gb+1|0;f[p>>2]=m;ib=m;jb=m}else{ib=gb;jb=hb}if(!(f[da>>2]&4096)){m=ib+1|0;f[p>>2]=m;kb=m;lb=m}else{kb=ib;lb=jb}if(!(f[da>>2]&8192)){m=kb+1|0;f[p>>2]=m;mb=m;nb=m}else{mb=kb;nb=lb}if(!(f[da>>2]&16384)){m=mb+1|0;f[p>>2]=m;ob=m;pb=m}else{ob=mb;pb=nb}if(!(f[da>>2]&32768)){m=ob+1|0;f[p>>2]=m;qb=m;rb=m}else{qb=ob;rb=pb}if(!(f[da>>2]&65536)){m=qb+1|0;f[p>>2]=m;sb=m;tb=m}else{sb=qb;tb=rb}if(!(f[da>>2]&131072)){m=sb+1|0;f[p>>2]=m;ub=m;vb=m}else{ub=sb;vb=tb}if(!(f[da>>2]&262144)){m=ub+1|0;f[p>>2]=m;wb=m;xb=m}else{wb=ub;xb=vb}if(!(f[da>>2]&524288)){m=wb+1|0;f[p>>2]=m;yb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 1}dn(_b);u=c;return 1}function bb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=La,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Rj(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;if(!(b[a+32>>0]|0)){r=o;m=0;while(1){s=$(b[r>>0]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}else{r=o;m=0;while(1){s=$($(b[r>>0]|0)/$(127.0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}}else t=l;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 2:{r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;q=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;u=Rj(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+u|0;if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(h[u>>0]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){v=q;break}else u=u+1|0}}else{u=o;k=0;while(1){s=$($(h[u>>0]|0)/$(255.0));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else u=u+1|0}}}else v=m;u=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 3:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Rj(gj(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$(d[u>>1]|0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else u=u+2|0}}else{u=o;l=0;while(1){s=$($(d[u>>1]|0)/$(32767.0));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else u=u+2|0}}else w=k;u=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 4:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Rj(gj(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){s=$(j[u>>1]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else u=u+2|0}}else{u=o;m=0;while(1){s=$($(j[u>>1]|0)/$(65535.0));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){x=k;break}else u=u+2|0}}else x=l;u=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 5:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Rj(gj(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(f[u>>2]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){y=q;break}else u=u+4|0}}else{u=o;k=0;while(1){s=$($(f[u>>2]|0)*$(4.65661287e-10));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){y=l;break}else u=u+4|0}}else y=m;u=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 6:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Rj(gj(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$((f[u>>2]|0)>>>0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){z=q;break}else u=u+4|0}}else{u=o;l=0;while(1){s=$($((f[u>>2]|0)>>>0)*$(2.32830644e-10));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){z=m;break}else u=u+4|0}}else z=k;u=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 7:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Rj(gj(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+(f[q+4>>2]|0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else u=u+8|0}}else{u=o;m=0;while(1){k=u;s=$($(+((f[k>>2]|0)>>>0)+4294967296.0*+(f[k+4>>2]|0))*$(1.08420217e-19));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){A=k;break}else u=u+8|0}}else A=l;u=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 8:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Rj(gj(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+((f[q+4>>2]|0)>>>0));n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){B=q;break}else u=u+8|0}}else{u=o;k=0;while(1){l=u;s=$($(+((f[l>>2]|0)>>>0)+4294967296.0*+((f[l+4>>2]|0)>>>0))*$(5.42101086e-20));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){B=l;break}else u=u+8|0}}else B=m;u=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 9:{u=a+24|0;k=b[u>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;l=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Rj(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=r+q|0;q=0;while(1){f[g+(q<<2)>>2]=f[o>>2];q=q+1|0;r=b[u>>0]|0;if((q|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){C=r;break}else o=o+4|0}}else C=k;o=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 10:{o=a+24|0;q=b[o>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){u=f[f[a>>2]>>2]|0;m=a+40|0;r=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;l=Rj(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=u+l|0;l=0;while(1){s=$(+p[m>>3]);n[g+(l<<2)>>2]=s;l=l+1|0;u=b[o>>0]|0;if((l|0)>=((u<<24>>24>e<<24>>24?e:u)<<24>>24|0)){D=u;break}else m=m+8|0}}else D=q;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 11:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){o=f[f[a>>2]>>2]|0;k=a+40|0;u=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Rj(u|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=o+r|0;r=0;while(1){s=$((b[k>>0]|0)!=0&1);n[g+(r<<2)>>2]=s;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){E=o;break}else k=k+1|0}}else E=l;k=E<<24>>24;if(E<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function cb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0;g=u;u=u+64|0;d=g+16|0;h=g;i=a+8|0;f[i>>2]=e;j=a+32|0;k=a+36|0;l=f[k>>2]|0;m=f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)|0;f[q>>2]=p;if((p|0)<=(f[l>>2]|0)){if((p|0)<(f[n>>2]|0)){t=(f[s>>2]|0)+p|0;v=18}}else{t=p-(f[s>>2]|0)|0;v=18}if((v|0)==18){v=0;f[q>>2]=t}j=j+1|0}while((j|0)<(f[i>>2]|0))}}j=f[a+48>>2]|0;t=f[a+52>>2]|0;s=bj(16)|0;f[s>>2]=0;f[s+4>>2]=0;f[s+8>>2]=0;f[s+12>>2]=0;f[h>>2]=0;n=h+4|0;f[n>>2]=0;f[h+8>>2]=0;do if(e)if(e>>>0>1073741823)um(h);else{l=e<<2;r=bj(l)|0;f[h>>2]=r;q=r+(e<<2)|0;f[h+8>>2]=q;Vf(r|0,0,l|0)|0;f[n>>2]=q;w=r;x=r;break}else{w=0;x=0}while(0);r=a+56|0;q=f[r>>2]|0;l=f[q+4>>2]|0;p=f[q>>2]|0;k=l-p|0;m=k>>2;do if((k|0)>4){o=j+64|0;y=j+28|0;z=(e|0)>0;A=a+16|0;B=a+32|0;C=a+12|0;D=a+20|0;E=e<<2;F=(e|0)==1;if(l-p>>2>>>0>1){G=1;H=p}else{I=q;um(I)}while(1){J=f[H+(G<<2)>>2]|0;K=(((J>>>0)%3|0|0)==0?2:-1)+J|0;L=K>>>5;M=1<<(K&31);N=(J|0)==-1|(K|0)==-1;O=1;P=0;Q=J;a:while(1){R=O^1;S=P;T=Q;while(1){if((T|0)==-1){U=S;v=64;break a}V=f[d+(S*12|0)>>2]|0;if(((f[(f[j>>2]|0)+(T>>>5<<2)>>2]&1<<(T&31)|0)==0?(W=f[(f[(f[o>>2]|0)+12>>2]|0)+(T<<2)>>2]|0,(W|0)!=-1):0)?(Y=f[y>>2]|0,Z=f[t>>2]|0,_=f[Z+(f[Y+(W<<2)>>2]<<2)>>2]|0,$=W+1|0,aa=f[Z+(f[Y+(((($>>>0)%3|0|0)==0?W+-2|0:$)<<2)>>2]<<2)>>2]|0,$=f[Z+(f[Y+((((W>>>0)%3|0|0)==0?2:-1)+W<<2)>>2]<<2)>>2]|0,(_|0)<(G|0)&(aa|0)<(G|0)&($|0)<(G|0)):0){W=X(_,e)|0;_=X(aa,e)|0;aa=X($,e)|0;if(z){$=0;do{f[V+($<<2)>>2]=(f[c+($+aa<<2)>>2]|0)+(f[c+($+_<<2)>>2]|0)-(f[c+($+W<<2)>>2]|0);$=$+1|0}while(($|0)!=(e|0))}$=S+1|0;if(($|0)==4){ba=4;v=44;break a}else ca=$}else ca=S;do if(O){$=T+1|0;W=(($>>>0)%3|0|0)==0?T+-2|0:$;if(((W|0)!=-1?(f[(f[j>>2]|0)+(W>>>5<<2)>>2]&1<<(W&31)|0)==0:0)?($=f[(f[(f[o>>2]|0)+12>>2]|0)+(W<<2)>>2]|0,W=$+1|0,($|0)!=-1):0)da=((W>>>0)%3|0|0)==0?$+-2|0:W;else da=-1}else{W=(((T>>>0)%3|0|0)==0?2:-1)+T|0;if(((W|0)!=-1?(f[(f[j>>2]|0)+(W>>>5<<2)>>2]&1<<(W&31)|0)==0:0)?($=f[(f[(f[o>>2]|0)+12>>2]|0)+(W<<2)>>2]|0,($|0)!=-1):0)if(!(($>>>0)%3|0)){da=$+2|0;break}else{da=$+-1|0;break}else da=-1}while(0);if((da|0)==(J|0)){U=ca;v=64;break a}if((da|0)!=-1|R){S=ca;T=da}else break}if(N){O=0;P=ca;Q=-1;continue}if(f[(f[j>>2]|0)+(L<<2)>>2]&M|0){O=0;P=ca;Q=-1;continue}T=f[(f[(f[o>>2]|0)+12>>2]|0)+(K<<2)>>2]|0;if((T|0)==-1){O=0;P=ca;Q=-1;continue}if(!((T>>>0)%3|0)){O=0;P=ca;Q=T+2|0;continue}else{O=0;P=ca;Q=T+-1|0;continue}}if((v|0)==64){v=0;if((U|0)>0){ba=U;v=44}else{ea=X(G,e)|0;v=77}}if((v|0)==44){v=0;if(z){Vf(f[h>>2]|0,0,E|0)|0;Q=ba+-1|0;P=s+(Q<<2)|0;O=f[a+60+(Q*12|0)>>2]|0;Q=f[h>>2]|0;K=0;M=0;while(1){L=f[P>>2]|0;f[P>>2]=L+1;if(!(f[O+(L>>>5<<2)>>2]&1<<(L&31))){L=f[d+(K*12|0)>>2]|0;N=0;do{J=Q+(N<<2)|0;f[J>>2]=(f[J>>2]|0)+(f[L+(N<<2)>>2]|0);N=N+1|0}while((N|0)!=(e|0));fa=M+1|0}else fa=M;K=K+1|0;if((K|0)==(ba|0)){ga=fa;break}else M=fa}}else{M=ba+-1|0;K=s+(M<<2)|0;Q=f[a+60+(M*12|0)>>2]|0;M=0;O=0;P=f[K>>2]|0;while(1){N=P;P=P+1|0;f[K>>2]=P;L=O+((f[Q+(N>>>5<<2)>>2]&1<<(N&31)|0)==0&1)|0;M=M+1|0;if((M|0)==(ba|0)){ga=L;break}else O=L}}O=X(G,e)|0;if(ga){M=f[h>>2]|0;if(z?(f[M>>2]=(f[M>>2]|0)/(ga|0)|0,!F):0){Q=1;do{P=M+(Q<<2)|0;f[P>>2]=(f[P>>2]|0)/(ga|0)|0;Q=Q+1|0}while((Q|0)!=(e|0))}Q=b+(O<<2)|0;P=c+(O<<2)|0;if((f[i>>2]|0)>0){K=0;do{L=f[M+(K<<2)>>2]|0;N=f[A>>2]|0;if((L|0)>(N|0)){J=f[B>>2]|0;f[J+(K<<2)>>2]=N;ha=J}else{J=f[C>>2]|0;N=f[B>>2]|0;f[N+(K<<2)>>2]=(L|0)<(J|0)?J:L;ha=N}K=K+1|0;ia=f[i>>2]|0}while((K|0)<(ia|0));if((ia|0)>0){K=0;do{M=(f[Q+(K<<2)>>2]|0)+(f[ha+(K<<2)>>2]|0)|0;N=P+(K<<2)|0;f[N>>2]=M;do if((M|0)>(f[A>>2]|0)){ja=M-(f[D>>2]|0)|0;v=99}else{if((M|0)>=(f[C>>2]|0))break;ja=(f[D>>2]|0)+M|0;v=99}while(0);if((v|0)==99){v=0;f[N>>2]=ja}K=K+1|0}while((K|0)<(f[i>>2]|0))}}}else{ea=O;v=77}}if((v|0)==77?(v=0,K=c+((X(G+-1|0,e)|0)<<2)|0,P=b+(ea<<2)|0,Q=c+(ea<<2)|0,(f[i>>2]|0)>0):0){M=0;do{L=f[K+(M<<2)>>2]|0;J=f[A>>2]|0;if((L|0)>(J|0)){T=f[B>>2]|0;f[T+(M<<2)>>2]=J;ka=T}else{T=f[C>>2]|0;J=f[B>>2]|0;f[J+(M<<2)>>2]=(L|0)<(T|0)?T:L;ka=J}M=M+1|0;la=f[i>>2]|0}while((M|0)<(la|0));if((la|0)>0){M=0;do{K=(f[P+(M<<2)>>2]|0)+(f[ka+(M<<2)>>2]|0)|0;O=Q+(M<<2)|0;f[O>>2]=K;if((K|0)<=(f[A>>2]|0)){if((K|0)<(f[C>>2]|0)){ma=(f[D>>2]|0)+K|0;v=87}}else{ma=K-(f[D>>2]|0)|0;v=87}if((v|0)==87){v=0;f[O>>2]=ma}M=M+1|0}while((M|0)<(f[i>>2]|0))}}G=G+1|0;if((G|0)>=(m|0)){v=28;break}M=f[r>>2]|0;H=f[M>>2]|0;if((f[M+4>>2]|0)-H>>2>>>0<=G>>>0){I=M;v=34;break}}if((v|0)==28){D=f[h>>2]|0;na=D;oa=D;break}else if((v|0)==34)um(I)}else{na=x;oa=w}while(0);if(na|0){w=f[n>>2]|0;if((w|0)!=(na|0))f[n>>2]=w+(~((w+-4-na|0)>>>2)<<2);dn(oa)}dn(s);s=f[d+36>>2]|0;if(s|0){oa=d+40|0;na=f[oa>>2]|0;if((na|0)!=(s|0))f[oa>>2]=na+(~((na+-4-s|0)>>>2)<<2);dn(s)}s=f[d+24>>2]|0;if(s|0){na=d+28|0;oa=f[na>>2]|0;if((oa|0)!=(s|0))f[na>>2]=oa+(~((oa+-4-s|0)>>>2)<<2);dn(s)}s=f[d+12>>2]|0;if(s|0){oa=d+16|0;na=f[oa>>2]|0;if((na|0)!=(s|0))f[oa>>2]=na+(~((na+-4-s|0)>>>2)<<2);dn(s)}s=f[d>>2]|0;if(!s){u=g;return 1}na=d+4|0;d=f[na>>2]|0;if((d|0)!=(s|0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0;q=p-n>>2;m=n;n=p;if(q>>>0>=e>>>0){if(q>>>0>e>>>0?(p=m+(e<<2)|0,(p|0)!=(n|0)):0)f[j>>2]=n+(~((n+-4-p|0)>>>2)<<2)}else Ae(l,e-q|0,h);q=f[d>>2]|0;if((f[i>>2]|0)>0){l=a+16|0;p=a+32|0;n=a+12|0;j=0;do{m=f[q+(j<<2)>>2]|0;k=f[l>>2]|0;if((m|0)>(k|0)){o=f[p>>2]|0;f[o+(j<<2)>>2]=k;r=o}else{o=f[n>>2]|0;k=f[p>>2]|0;f[k+(j<<2)>>2]=(m|0)<(o|0)?o:m;r=k}j=j+1|0;s=f[i>>2]|0}while((j|0)<(s|0));if((s|0)>0){s=a+20|0;j=0;do{p=(f[b+(j<<2)>>2]|0)+(f[r+(j<<2)>>2]|0)|0;q=c+(j<<2)|0;f[q>>2]=p;if((p|0)<=(f[l>>2]|0)){if((p|0)<(f[n>>2]|0)){t=(f[s>>2]|0)+p|0;v=18}}else{t=p-(f[s>>2]|0)|0;v=18}if((v|0)==18){v=0;f[q>>2]=t}j=j+1|0}while((j|0)<(f[i>>2]|0))}}j=f[a+48>>2]|0;t=f[a+52>>2]|0;s=bj(16)|0;f[s>>2]=0;f[s+4>>2]=0;f[s+8>>2]=0;f[s+12>>2]=0;f[h>>2]=0;n=h+4|0;f[n>>2]=0;f[h+8>>2]=0;do if(e)if(e>>>0>1073741823)um(h);else{l=e<<2;r=bj(l)|0;f[h>>2]=r;q=r+(e<<2)|0;f[h+8>>2]=q;Vf(r|0,0,l|0)|0;f[n>>2]=q;w=r;x=r;break}else{w=0;x=0}while(0);r=a+56|0;q=f[r>>2]|0;l=f[q+4>>2]|0;p=f[q>>2]|0;k=l-p|0;m=k>>2;do if((k|0)>4){o=j+12|0;y=(e|0)>0;z=a+16|0;A=a+32|0;B=a+12|0;C=a+20|0;D=e<<2;E=(e|0)==1;if(l-p>>2>>>0>1){F=1;G=p}else{H=q;um(H)}while(1){I=f[G+(F<<2)>>2]|0;J=(((I>>>0)%3|0|0)==0?2:-1)+I|0;K=(I|0)==-1|(J|0)==-1;L=1;M=0;N=I;a:while(1){O=L^1;P=M;Q=N;while(1){if((Q|0)==-1){R=P;v=64;break a}S=f[d+(P*12|0)>>2]|0;T=f[o>>2]|0;U=f[T+(Q<<2)>>2]|0;if((U|0)!=-1){V=f[j>>2]|0;W=f[t>>2]|0;Y=f[W+(f[V+(U<<2)>>2]<<2)>>2]|0;Z=U+1|0;_=((Z>>>0)%3|0|0)==0?U+-2|0:Z;if((_|0)==-1)$=-1;else $=f[V+(_<<2)>>2]|0;_=f[W+($<<2)>>2]|0;Z=(((U>>>0)%3|0|0)==0?2:-1)+U|0;if((Z|0)==-1)aa=-1;else aa=f[V+(Z<<2)>>2]|0;Z=f[W+(aa<<2)>>2]|0;if((Y|0)<(F|0)&(_|0)<(F|0)&(Z|0)<(F|0)){W=X(Y,e)|0;Y=X(_,e)|0;_=X(Z,e)|0;if(y){Z=0;do{f[S+(Z<<2)>>2]=(f[c+(Z+_<<2)>>2]|0)+(f[c+(Z+Y<<2)>>2]|0)-(f[c+(Z+W<<2)>>2]|0);Z=Z+1|0}while((Z|0)!=(e|0))}Z=P+1|0;if((Z|0)==4){ba=4;v=47;break a}else ca=Z}else ca=P}else ca=P;do if(L){Z=Q+1|0;W=((Z>>>0)%3|0|0)==0?Q+-2|0:Z;if((W|0)!=-1?(Z=f[T+(W<<2)>>2]|0,W=Z+1|0,(Z|0)!=-1):0)da=((W>>>0)%3|0|0)==0?Z+-2|0:W;else da=-1}else{W=(((Q>>>0)%3|0|0)==0?2:-1)+Q|0;if((W|0)!=-1?(Z=f[T+(W<<2)>>2]|0,(Z|0)!=-1):0)if(!((Z>>>0)%3|0)){da=Z+2|0;break}else{da=Z+-1|0;break}else da=-1}while(0);if((da|0)==(I|0)){R=ca;v=64;break a}if((da|0)!=-1|O){P=ca;Q=da}else break}if(K){L=0;M=ca;N=-1;continue}Q=f[T+(J<<2)>>2]|0;if((Q|0)==-1){L=0;M=ca;N=-1;continue}if(!((Q>>>0)%3|0)){L=0;M=ca;N=Q+2|0;continue}else{L=0;M=ca;N=Q+-1|0;continue}}if((v|0)==64){v=0;if((R|0)>0){ba=R;v=47}else{ea=X(F,e)|0;v=77}}if((v|0)==47){v=0;if(y){Vf(f[h>>2]|0,0,D|0)|0;N=ba+-1|0;M=s+(N<<2)|0;L=f[a+60+(N*12|0)>>2]|0;N=f[h>>2]|0;J=0;K=0;while(1){I=f[M>>2]|0;f[M>>2]=I+1;if(!(f[L+(I>>>5<<2)>>2]&1<<(I&31))){I=f[d+(J*12|0)>>2]|0;Q=0;do{P=N+(Q<<2)|0;f[P>>2]=(f[P>>2]|0)+(f[I+(Q<<2)>>2]|0);Q=Q+1|0}while((Q|0)!=(e|0));fa=K+1|0}else fa=K;J=J+1|0;if((J|0)==(ba|0)){ga=fa;break}else K=fa}}else{K=ba+-1|0;J=s+(K<<2)|0;N=f[a+60+(K*12|0)>>2]|0;K=0;L=0;M=f[J>>2]|0;while(1){Q=M;M=M+1|0;f[J>>2]=M;I=L+((f[N+(Q>>>5<<2)>>2]&1<<(Q&31)|0)==0&1)|0;K=K+1|0;if((K|0)==(ba|0)){ga=I;break}else L=I}}L=X(F,e)|0;if(ga){K=f[h>>2]|0;if(y?(f[K>>2]=(f[K>>2]|0)/(ga|0)|0,!E):0){N=1;do{M=K+(N<<2)|0;f[M>>2]=(f[M>>2]|0)/(ga|0)|0;N=N+1|0}while((N|0)!=(e|0))}N=b+(L<<2)|0;M=c+(L<<2)|0;if((f[i>>2]|0)>0){J=0;do{I=f[K+(J<<2)>>2]|0;Q=f[z>>2]|0;if((I|0)>(Q|0)){P=f[A>>2]|0;f[P+(J<<2)>>2]=Q;ha=P}else{P=f[B>>2]|0;Q=f[A>>2]|0;f[Q+(J<<2)>>2]=(I|0)<(P|0)?P:I;ha=Q}J=J+1|0;ia=f[i>>2]|0}while((J|0)<(ia|0));if((ia|0)>0){J=0;do{K=(f[N+(J<<2)>>2]|0)+(f[ha+(J<<2)>>2]|0)|0;Q=M+(J<<2)|0;f[Q>>2]=K;do if((K|0)>(f[z>>2]|0)){ja=K-(f[C>>2]|0)|0;v=99}else{if((K|0)>=(f[B>>2]|0))break;ja=(f[C>>2]|0)+K|0;v=99}while(0);if((v|0)==99){v=0;f[Q>>2]=ja}J=J+1|0}while((J|0)<(f[i>>2]|0))}}}else{ea=L;v=77}}if((v|0)==77?(v=0,J=c+((X(F+-1|0,e)|0)<<2)|0,M=b+(ea<<2)|0,N=c+(ea<<2)|0,(f[i>>2]|0)>0):0){K=0;do{I=f[J+(K<<2)>>2]|0;P=f[z>>2]|0;if((I|0)>(P|0)){O=f[A>>2]|0;f[O+(K<<2)>>2]=P;ka=O}else{O=f[B>>2]|0;P=f[A>>2]|0;f[P+(K<<2)>>2]=(I|0)<(O|0)?O:I;ka=P}K=K+1|0;la=f[i>>2]|0}while((K|0)<(la|0));if((la|0)>0){K=0;do{J=(f[M+(K<<2)>>2]|0)+(f[ka+(K<<2)>>2]|0)|0;L=N+(K<<2)|0;f[L>>2]=J;if((J|0)<=(f[z>>2]|0)){if((J|0)<(f[B>>2]|0)){ma=(f[C>>2]|0)+J|0;v=87}}else{ma=J-(f[C>>2]|0)|0;v=87}if((v|0)==87){v=0;f[L>>2]=ma}K=K+1|0}while((K|0)<(f[i>>2]|0))}}F=F+1|0;if((F|0)>=(m|0)){v=28;break}K=f[r>>2]|0;G=f[K>>2]|0;if((f[K+4>>2]|0)-G>>2>>>0<=F>>>0){H=K;v=34;break}}if((v|0)==28){C=f[h>>2]|0;na=C;oa=C;break}else if((v|0)==34)um(H)}else{na=x;oa=w}while(0);if(na|0){w=f[n>>2]|0;if((w|0)!=(na|0))f[n>>2]=w+(~((w+-4-na|0)>>>2)<<2);dn(oa)}dn(s);s=f[d+36>>2]|0;if(s|0){oa=d+40|0;na=f[oa>>2]|0;if((na|0)!=(s|0))f[oa>>2]=na+(~((na+-4-s|0)>>>2)<<2);dn(s)}s=f[d+24>>2]|0;if(s|0){na=d+28|0;oa=f[na>>2]|0;if((oa|0)!=(s|0))f[na>>2]=oa+(~((oa+-4-s|0)>>>2)<<2);dn(s)}s=f[d+12>>2]|0;if(s|0){oa=d+16|0;na=f[oa>>2]|0;if((na|0)!=(s|0))f[oa>>2]=na+(~((na+-4-s|0)>>>2)<<2);dn(s)}s=f[d>>2]|0;if(!s){u=g;return 1}na=d+4|0;d=f[na>>2]|0;if((d|0)!=(s|0))f[na>>2]=d+(~((d+-4-s|0)>>>2)<<2);dn(s);u=g;return 1}function eb(a,c,d,e,g,i){a=a|0;c=+c;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0,D=0.0,E=0,F=0,G=0,H=0.0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0.0,ga=0.0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0;j=u;u=u+560|0;k=j+8|0;l=j;m=j+524|0;n=m;o=j+512|0;f[l>>2]=0;p=o+12|0;zk(c)|0;if((I|0)<0){q=-c;r=1;s=10359}else{q=c;r=(g&2049|0)!=0&1;s=(g&2048|0)==0?((g&1|0)==0?10360:10365):10362}zk(q)|0;do if(0==0&(I&2146435072|0)==2146435072){t=(i&32|0)!=0;v=r+3|0;ch(a,32,d,v,g&-65537);il(a,s,r);il(a,q!=q|0.0!=0.0?(t?10386:10390):t?10378:10382,3);ch(a,32,d,v,g^8192);w=v}else{c=+Jm(q,l)*2.0;v=c!=0.0;if(v)f[l>>2]=(f[l>>2]|0)+-1;t=i|32;if((t|0)==97){x=i&32;y=(x|0)==0?s:s+9|0;z=r|2;A=12-e|0;do if(!(e>>>0>11|(A|0)==0)){B=8.0;C=A;do{C=C+-1|0;B=B*16.0}while((C|0)!=0);if((b[y>>0]|0)==45){D=-(B+(-c-B));break}else{D=c+B-B;break}}else D=c;while(0);A=f[l>>2]|0;C=(A|0)<0?0-A|0:A;E=pg(C,((C|0)<0)<<31>>31,p)|0;if((E|0)==(p|0)){C=o+11|0;b[C>>0]=48;F=C}else F=E;b[F+-1>>0]=(A>>31&2)+43;A=F+-2|0;b[A>>0]=i+15;E=(e|0)<1;C=(g&8|0)==0;G=m;H=D;while(1){J=~~H;K=G+1|0;b[G>>0]=x|h[10394+J>>0];H=(H-+(J|0))*16.0;if((K-n|0)==1?!(C&(E&H==0.0)):0){b[K>>0]=46;L=G+2|0}else L=K;if(!(H!=0.0))break;else G=L}G=L;if((e|0)!=0?(-2-n+G|0)<(e|0):0){M=G-n|0;N=e+2|0}else{E=G-n|0;M=E;N=E}E=p-A|0;G=E+z+N|0;ch(a,32,d,G,g);il(a,y,z);ch(a,48,d,G,g^65536);il(a,m,M);ch(a,48,N-M|0,0,0);il(a,A,E);ch(a,32,d,G,g^8192);w=G;break}G=(e|0)<0?6:e;if(v){E=(f[l>>2]|0)+-28|0;f[l>>2]=E;O=c*268435456.0;P=E}else{O=c;P=f[l>>2]|0}E=(P|0)<0?k:k+288|0;C=E;H=O;do{x=~~H>>>0;f[C>>2]=x;C=C+4|0;H=(H-+(x>>>0))*1.0e9}while(H!=0.0);if((P|0)>0){v=E;A=C;z=P;while(1){y=(z|0)<29?z:29;x=A+-4|0;if(x>>>0>=v>>>0){K=x;x=0;do{J=Oj(f[K>>2]|0,0,y|0)|0;Q=Rj(J|0,I|0,x|0,0)|0;J=I;R=$i(Q|0,J|0,1e9,0)|0;f[K>>2]=R;x=Fl(Q|0,J|0,1e9,0)|0;K=K+-4|0}while(K>>>0>=v>>>0);if(x){K=v+-4|0;f[K>>2]=x;S=K}else S=v}else S=v;K=A;while(1){if(K>>>0<=S>>>0)break;J=K+-4|0;if(!(f[J>>2]|0))K=J;else break}x=(f[l>>2]|0)-y|0;f[l>>2]=x;if((x|0)>0){v=S;A=K;z=x}else{T=S;U=K;V=x;break}}}else{T=E;U=C;V=P}if((V|0)<0){z=((G+25|0)/9|0)+1|0;A=(t|0)==102;v=T;x=U;J=V;while(1){Q=0-J|0;R=(Q|0)<9?Q:9;if(v>>>0>>0){Q=(1<>>R;Y=0;Z=v;do{_=f[Z>>2]|0;f[Z>>2]=(_>>>R)+Y;Y=X(_&Q,W)|0;Z=Z+4|0}while(Z>>>0>>0);Z=(f[v>>2]|0)==0?v+4|0:v;if(!Y){$=Z;aa=x}else{f[x>>2]=Y;$=Z;aa=x+4|0}}else{$=(f[v>>2]|0)==0?v+4|0:v;aa=x}Z=A?E:$;W=(aa-Z>>2|0)>(z|0)?Z+(z<<2)|0:aa;J=(f[l>>2]|0)+R|0;f[l>>2]=J;if((J|0)>=0){ba=$;ca=W;break}else{v=$;x=W}}}else{ba=T;ca=U}x=E;if(ba>>>0>>0){v=(x-ba>>2)*9|0;J=f[ba>>2]|0;if(J>>>0<10)da=v;else{z=v;v=10;while(1){v=v*10|0;A=z+1|0;if(J>>>0>>0){da=A;break}else z=A}}}else da=0;z=(t|0)==103;v=(G|0)!=0;J=G-((t|0)!=102?da:0)+((v&z)<<31>>31)|0;if((J|0)<(((ca-x>>2)*9|0)+-9|0)){A=J+9216|0;J=E+4+(((A|0)/9|0)+-1024<<2)|0;C=(A|0)%9|0;if((C|0)<8){A=C;C=10;while(1){W=C*10|0;if((A|0)<7){A=A+1|0;C=W}else{ea=W;break}}}else ea=10;C=f[J>>2]|0;A=(C>>>0)%(ea>>>0)|0;t=(J+4|0)==(ca|0);if(!(t&(A|0)==0)){B=(((C>>>0)/(ea>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;W=(ea|0)/2|0;H=A>>>0>>0?.5:t&(A|0)==(W|0)?1.0:1.5;if(!r){fa=H;ga=B}else{W=(b[s>>0]|0)==45;fa=W?-H:H;ga=W?-B:B}W=C-A|0;f[J>>2]=W;if(ga+fa!=ga){A=W+ea|0;f[J>>2]=A;if(A>>>0>999999999){A=ba;W=J;while(1){C=W+-4|0;f[W>>2]=0;if(C>>>0>>0){t=A+-4|0;f[t>>2]=0;ha=t}else ha=A;t=(f[C>>2]|0)+1|0;f[C>>2]=t;if(t>>>0>999999999){A=ha;W=C}else{ia=ha;ja=C;break}}}else{ia=ba;ja=J}W=(x-ia>>2)*9|0;A=f[ia>>2]|0;if(A>>>0<10){ka=ja;la=W;ma=ia}else{C=W;W=10;while(1){W=W*10|0;t=C+1|0;if(A>>>0>>0){ka=ja;la=t;ma=ia;break}else C=t}}}else{ka=J;la=da;ma=ba}}else{ka=J;la=da;ma=ba}C=ka+4|0;na=la;oa=ca>>>0>C>>>0?C:ca;pa=ma}else{na=da;oa=ca;pa=ba}C=oa;while(1){if(C>>>0<=pa>>>0){qa=0;break}W=C+-4|0;if(!(f[W>>2]|0))C=W;else{qa=1;break}}J=0-na|0;do if(z){W=G+((v^1)&1)|0;if((W|0)>(na|0)&(na|0)>-5){ra=i+-1|0;sa=W+-1-na|0}else{ra=i+-2|0;sa=W+-1|0}W=g&8;if(!W){if(qa?(A=f[C+-4>>2]|0,(A|0)!=0):0)if(!((A>>>0)%10|0)){t=0;Z=10;while(1){Z=Z*10|0;Q=t+1|0;if((A>>>0)%(Z>>>0)|0|0){ta=Q;break}else t=Q}}else ta=0;else ta=9;t=((C-x>>2)*9|0)+-9|0;if((ra|32|0)==102){Z=t-ta|0;A=(Z|0)>0?Z:0;ua=ra;va=(sa|0)<(A|0)?sa:A;wa=0;break}else{A=t+na-ta|0;t=(A|0)>0?A:0;ua=ra;va=(sa|0)<(t|0)?sa:t;wa=0;break}}else{ua=ra;va=sa;wa=W}}else{ua=i;va=G;wa=g&8}while(0);G=va|wa;x=(G|0)!=0&1;v=(ua|32|0)==102;if(v){xa=0;ya=(na|0)>0?na:0}else{z=(na|0)<0?J:na;t=pg(z,((z|0)<0)<<31>>31,p)|0;z=p;if((z-t|0)<2){A=t;while(1){Z=A+-1|0;b[Z>>0]=48;if((z-Z|0)<2)A=Z;else{za=Z;break}}}else za=t;b[za+-1>>0]=(na>>31&2)+43;A=za+-2|0;b[A>>0]=ua;xa=A;ya=z-A|0}A=r+1+va+x+ya|0;ch(a,32,d,A,g);il(a,s,r);ch(a,48,d,A,g^65536);if(v){J=pa>>>0>E>>>0?E:pa;Z=m+9|0;R=Z;Y=m+8|0;Q=J;do{K=pg(f[Q>>2]|0,0,Z)|0;if((Q|0)==(J|0))if((K|0)==(Z|0)){b[Y>>0]=48;Aa=Y}else Aa=K;else if(K>>>0>m>>>0){Vf(m|0,48,K-n|0)|0;y=K;while(1){_=y+-1|0;if(_>>>0>m>>>0)y=_;else{Aa=_;break}}}else Aa=K;il(a,Aa,R-Aa|0);Q=Q+4|0}while(Q>>>0<=E>>>0);if(G|0)il(a,10410,1);if(Q>>>0>>0&(va|0)>0){E=va;R=Q;while(1){Y=pg(f[R>>2]|0,0,Z)|0;if(Y>>>0>m>>>0){Vf(m|0,48,Y-n|0)|0;J=Y;while(1){v=J+-1|0;if(v>>>0>m>>>0)J=v;else{Ba=v;break}}}else Ba=Y;il(a,Ba,(E|0)<9?E:9);R=R+4|0;J=E+-9|0;if(!(R>>>0>>0&(E|0)>9)){Ca=J;break}else E=J}}else Ca=va;ch(a,48,Ca+9|0,9,0)}else{E=qa?C:pa+4|0;if((va|0)>-1){R=m+9|0;Z=(wa|0)==0;Q=R;G=0-n|0;J=m+8|0;K=va;v=pa;while(1){x=pg(f[v>>2]|0,0,R)|0;if((x|0)==(R|0)){b[J>>0]=48;Da=J}else Da=x;do if((v|0)==(pa|0)){x=Da+1|0;il(a,Da,1);if(Z&(K|0)<1){Ea=x;break}il(a,10410,1);Ea=x}else{if(Da>>>0<=m>>>0){Ea=Da;break}Vf(m|0,48,Da+G|0)|0;x=Da;while(1){z=x+-1|0;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w;I=w+(l<<2)|0;f[g+8>>2]=I;Vf(w|0,0,N|0)|0;f[K>>2]=I;break}while(0);if(((f[r+28>>2]|0)-(f[r+24>>2]|0)|0)>0){N=a+120|0;a=e+8|0;l=0;I=r;while(1){r=f[(f[I+24>>2]|0)+(l<<2)>>2]|0;a:do if((r|0)!=-1){b:do if((f[(f[N>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0?(w=f[m>>2]|0,n=f[p>>2]|0,M=n,(w|0)!=(n|0)):0){j=(((r>>>0)%3|0|0)==0?2:-1)+r|0;J=(w-n|0)/144|0;if((j|0)==-1){n=(r|0)==-1;w=0;while(1){v=f[(f[f[M+(w*144|0)+68>>2]>>2]|0)+(r<<2)>>2]|0;if(1<<(v&31)&f[(f[M+(w*144|0)+16>>2]|0)+(v>>>5<<2)>>2]|0){v=f[M+(w*144|0)+32>>2]|0;t=(f[v+-4>>2]|0)==(f[v+(r<<2)>>2]|0);do if(!t){W=-1;break b}while(!n)}w=w+1|0;if(w>>>0>=J>>>0){W=r;break b}}}w=I+12|0;n=0;while(1){t=f[(f[f[M+(n*144|0)+68>>2]>>2]|0)+(r<<2)>>2]|0;if(1<<(t&31)&f[(f[M+(n*144|0)+16>>2]|0)+(t>>>5<<2)>>2]|0){t=f[M+(n*144|0)+32>>2]|0;v=f[t+(r<<2)>>2]|0;s=f[w>>2]|0;L=f[s+(j<<2)>>2]|0;do if((L|0)!=-1)if(!((L>>>0)%3|0)){X=L+2|0;break}else{X=L+-1|0;break}else X=-1;while(0);if((X|0)!=(r|0)){L=X;while(1){if((f[t+(L<<2)>>2]|0)!=(v|0)){W=L;break b}do if((L|0)!=-1){q=(((L>>>0)%3|0|0)==0?2:-1)+L|0;if((q|0)==-1){Y=-1;break}F=f[s+(q<<2)>>2]|0;if((F|0)==-1){Y=-1;break}if(!((F>>>0)%3|0)){Y=F+2|0;break}else{Y=F+-1|0;break}}else Y=-1;while(0);if((Y|0)==(r|0))break;else L=Y}}}n=n+1|0;if(n>>>0>=J>>>0){W=r;break}}}else W=r;while(0);J=f[b>>2]|0;f[(f[g>>2]|0)+(W<<2)>>2]=J-(f[e>>2]|0)>>2;f[d>>2]=W;n=J;if((f[a>>2]|0)>>>0>n>>>0){f[n>>2]=W;f[b>>2]=n+4;Z=I}else{xf(e,d);Z=f[k>>2]|0}if((((W|0)!=-1?(n=(((W>>>0)%3|0|0)==0?2:-1)+W|0,(n|0)!=-1):0)?(J=f[(f[Z+12>>2]|0)+(n<<2)>>2]|0,(J|0)!=-1):0)?(n=J+(((J>>>0)%3|0|0)==0?2:-1)|0,(n|0)!=-1&(n|0)!=(W|0)):0){J=W;j=n;n=Z;while(1){w=f[m>>2]|0;M=f[p>>2]|0;L=M;c:do if((w|0)==(M|0))B=70;else{s=(w-M|0)/144|0;v=0;while(1){t=f[L+(v*144|0)+32>>2]|0;v=v+1|0;if((f[t+(j<<2)>>2]|0)!=(f[t+(J<<2)>>2]|0))break;if(v>>>0>=s>>>0){B=70;break c}}s=f[b>>2]|0;f[(f[g>>2]|0)+(j<<2)>>2]=s-(f[e>>2]|0)>>2;f[d>>2]=j;v=s;if((f[a>>2]|0)>>>0>v>>>0){f[v>>2]=j;f[b>>2]=v+4;_=n}else{xf(e,d);_=f[k>>2]|0}$=_}while(0);if((B|0)==70){B=0;L=f[g>>2]|0;f[L+(j<<2)>>2]=f[L+(J<<2)>>2];$=n}if((j|0)==-1){aa=$;break a}L=(((j>>>0)%3|0|0)==0?2:-1)+j|0;if((L|0)==-1){aa=$;break a}M=f[(f[$+12>>2]|0)+(L<<2)>>2]|0;if((M|0)==-1){aa=$;break a}L=M+(((M>>>0)%3|0|0)==0?2:-1)|0;if((L|0)!=-1&(L|0)!=(W|0)){M=j;j=L;n=$;J=M}else{aa=$;break}}}else aa=Z}else aa=I;while(0);l=l+1|0;if((l|0)>=((f[aa+28>>2]|0)-(f[aa+24>>2]|0)>>2|0))break;else I=aa}}aa=f[i>>2]|0;I=f[aa+44>>2]|0;l=f[I+100>>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0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0;i=u;u=u+64|0;j=i+16|0;k=i;l=i+24|0;m=i+8|0;n=i+20|0;f[j>>2]=c;c=(a|0)!=0;o=l+40|0;q=o;r=l+39|0;l=m+4|0;s=0;t=0;v=0;a:while(1){do if((t|0)>-1)if((s|0)>(2147483647-t|0)){w=ln()|0;f[w>>2]=75;x=-1;break}else{x=s+t|0;break}else x=t;while(0);w=f[j>>2]|0;y=b[w>>0]|0;if(!(y<<24>>24)){z=88;break}else{A=y;B=w}b:while(1){switch(A<<24>>24){case 37:{C=B;D=B;z=9;break b;break}case 0:{E=B;break b;break}default:{}}y=B+1|0;f[j>>2]=y;A=b[y>>0]|0;B=y}c:do if((z|0)==9)while(1){z=0;if((b[D+1>>0]|0)!=37){E=C;break c}y=C+1|0;D=D+2|0;f[j>>2]=D;if((b[D>>0]|0)!=37){E=y;break}else{C=y;z=9}}while(0);y=E-w|0;if(c)il(a,w,y);if(y|0){s=y;t=x;continue}y=(Om(b[(f[j>>2]|0)+1>>0]|0)|0)==0;F=f[j>>2]|0;if(!y?(b[F+2>>0]|0)==36:0){G=(b[F+1>>0]|0)+-48|0;H=1;J=3}else{G=-1;H=v;J=1}y=F+J|0;f[j>>2]=y;F=b[y>>0]|0;K=(F<<24>>24)+-32|0;if(K>>>0>31|(1<>24)+-32|K;P=F+1|0;f[j>>2]=P;Q=b[P>>0]|0;R=(Q<<24>>24)+-32|0;if(R>>>0>31|(1<>24==42){if((Om(b[N+1>>0]|0)|0)!=0?(F=f[j>>2]|0,(b[F+2>>0]|0)==36):0){O=F+1|0;f[h+((b[O>>0]|0)+-48<<2)>>2]=10;S=f[g+((b[O>>0]|0)+-48<<3)>>2]|0;T=1;U=F+3|0}else{if(H|0){V=-1;break}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);O=f[F>>2]|0;f[e>>2]=F+4;W=O}else W=0;S=W;T=0;U=(f[j>>2]|0)+1|0}f[j>>2]=U;O=(S|0)<0;X=O?0-S|0:S;Y=O?L|8192:L;Z=T;_=U}else{O=Sh(j)|0;if((O|0)<0){V=-1;break}X=O;Y=L;Z=H;_=f[j>>2]|0}do if((b[_>>0]|0)==46){if((b[_+1>>0]|0)!=42){f[j>>2]=_+1;O=Sh(j)|0;$=O;aa=f[j>>2]|0;break}if(Om(b[_+2>>0]|0)|0?(O=f[j>>2]|0,(b[O+3>>0]|0)==36):0){F=O+2|0;f[h+((b[F>>0]|0)+-48<<2)>>2]=10;K=f[g+((b[F>>0]|0)+-48<<3)>>2]|0;F=O+4|0;f[j>>2]=F;$=K;aa=F;break}if(Z|0){V=-1;break a}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);K=f[F>>2]|0;f[e>>2]=F+4;ba=K}else ba=0;K=(f[j>>2]|0)+2|0;f[j>>2]=K;$=ba;aa=K}else{$=-1;aa=_}while(0);K=0;F=aa;while(1){if(((b[F>>0]|0)+-65|0)>>>0>57){V=-1;break a}O=F;F=F+1|0;f[j>>2]=F;ca=b[(b[O>>0]|0)+-65+(9878+(K*58|0))>>0]|0;da=ca&255;if((da+-1|0)>>>0>=8)break;else K=da}if(!(ca<<24>>24)){V=-1;break}O=(G|0)>-1;do if(ca<<24>>24==19)if(O){V=-1;break a}else z=50;else{if(O){f[h+(G<<2)>>2]=da;P=g+(G<<3)|0;Q=f[P+4>>2]|0;y=k;f[y>>2]=f[P>>2];f[y+4>>2]=Q;z=50;break}if(!c){V=0;break a}Zc(k,da,e);ea=f[j>>2]|0}while(0);if((z|0)==50){z=0;if(c)ea=F;else{s=0;t=x;v=Z;continue}}O=b[ea+-1>>0]|0;Q=(K|0)!=0&(O&15|0)==3?O&-33:O;O=Y&-65537;y=(Y&8192|0)==0?Y:O;d:do switch(Q|0){case 110:{switch((K&255)<<24>>24){case 0:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 1:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 2:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}case 3:{d[f[k>>2]>>1]=x;s=0;t=x;v=Z;continue a;break}case 4:{b[f[k>>2]>>0]=x;s=0;t=x;v=Z;continue a;break}case 6:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 7:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}default:{s=0;t=x;v=Z;continue a}}break}case 112:{fa=120;ga=$>>>0>8?$:8;ha=y|8;z=62;break}case 88:case 120:{fa=Q;ga=$;ha=y;z=62;break}case 111:{P=k;R=f[P>>2]|0;ia=f[P+4>>2]|0;P=Wh(R,ia,o)|0;ja=q-P|0;ka=P;la=0;ma=10342;na=(y&8|0)==0|($|0)>(ja|0)?$:ja+1|0;oa=y;pa=R;qa=ia;z=68;break}case 105:case 100:{ia=k;R=f[ia>>2]|0;ja=f[ia+4>>2]|0;if((ja|0)<0){ia=Tj(0,0,R|0,ja|0)|0;P=I;ra=k;f[ra>>2]=ia;f[ra+4>>2]=P;sa=1;ta=10342;ua=ia;va=P;z=67;break d}else{sa=(y&2049|0)!=0&1;ta=(y&2048|0)==0?((y&1|0)==0?10342:10344):10343;ua=R;va=ja;z=67;break d}break}case 117:{ja=k;sa=0;ta=10342;ua=f[ja>>2]|0;va=f[ja+4>>2]|0;z=67;break}case 99:{b[r>>0]=f[k>>2];wa=r;xa=0;ya=10342;za=o;Aa=1;Ba=O;break}case 109:{ja=ln()|0;Ca=nl(f[ja>>2]|0)|0;z=72;break}case 115:{ja=f[k>>2]|0;Ca=ja|0?ja:10352;z=72;break}case 67:{f[m>>2]=f[k>>2];f[l>>2]=0;f[k>>2]=m;Da=-1;Ea=m;z=76;break}case 83:{ja=f[k>>2]|0;if(!$){ch(a,32,X,0,y);Fa=0;z=85}else{Da=$;Ea=ja;z=76}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{s=eb(a,+p[k>>3],X,$,y,Q)|0;t=x;v=Z;continue a;break}default:{wa=w;xa=0;ya=10342;za=o;Aa=$;Ba=y}}while(0);e:do if((z|0)==62){z=0;w=k;Q=f[w>>2]|0;K=f[w+4>>2]|0;w=Fh(Q,K,o,fa&32)|0;F=(ha&8|0)==0|(Q|0)==0&(K|0)==0;ka=w;la=F?0:2;ma=F?10342:10342+(fa>>4)|0;na=ga;oa=ha;pa=Q;qa=K;z=68}else if((z|0)==67){z=0;ka=pg(ua,va,o)|0;la=sa;ma=ta;na=$;oa=y;pa=ua;qa=va;z=68}else if((z|0)==72){z=0;K=Ed(Ca,0,$)|0;Q=(K|0)==0;wa=Ca;xa=0;ya=10342;za=Q?Ca+$|0:K;Aa=Q?$:K-Ca|0;Ba=O}else if((z|0)==76){z=0;K=Ea;Q=0;F=0;while(1){w=f[K>>2]|0;if(!w){Ga=Q;Ha=F;break}ja=_k(n,w)|0;if((ja|0)<0|ja>>>0>(Da-Q|0)>>>0){Ga=Q;Ha=ja;break}w=ja+Q|0;if(Da>>>0>w>>>0){K=K+4|0;Q=w;F=ja}else{Ga=w;Ha=ja;break}}if((Ha|0)<0){V=-1;break a}ch(a,32,X,Ga,y);if(!Ga){Fa=0;z=85}else{F=Ea;Q=0;while(1){K=f[F>>2]|0;if(!K){Fa=Ga;z=85;break e}ja=_k(n,K)|0;Q=ja+Q|0;if((Q|0)>(Ga|0)){Fa=Ga;z=85;break e}il(a,n,ja);if(Q>>>0>=Ga>>>0){Fa=Ga;z=85;break}else F=F+4|0}}}while(0);if((z|0)==68){z=0;O=(pa|0)!=0|(qa|0)!=0;F=(na|0)!=0|O;Q=q-ka+((O^1)&1)|0;wa=F?ka:o;xa=la;ya=ma;za=o;Aa=F?((na|0)>(Q|0)?na:Q):na;Ba=(na|0)>-1?oa&-65537:oa}else if((z|0)==85){z=0;ch(a,32,X,Fa,y^8192);s=(X|0)>(Fa|0)?X:Fa;t=x;v=Z;continue}Q=za-wa|0;F=(Aa|0)<(Q|0)?Q:Aa;O=F+xa|0;ja=(X|0)<(O|0)?O:X;ch(a,32,ja,O,Ba);il(a,ya,xa);ch(a,48,ja,O,Ba^65536);ch(a,48,F,Q,0);il(a,wa,Q);ch(a,32,ja,O,Ba^8192);s=ja;t=x;v=Z}f:do if((z|0)==88)if(!a)if(v){Z=1;while(1){t=f[h+(Z<<2)>>2]|0;if(!t){Ia=Z;break}Zc(g+(Z<<3)|0,t,e);t=Z+1|0;if((Z|0)<9)Z=t;else{Ia=t;break}}if((Ia|0)<10){Z=Ia;while(1){if(f[h+(Z<<2)>>2]|0){V=-1;break f}if((Z|0)<9)Z=Z+1|0;else{V=1;break}}}else V=1}else V=0;else V=x;while(0);u=i;return V|0}function hb(a){a=a|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;c=u;u=u+80|0;e=c+40|0;g=c+68|0;h=c+64|0;i=c+60|0;j=c+52|0;k=c;l=c+56|0;m=c+48|0;f[a+132>>2]=0;n=a+148|0;if(f[n>>2]|0){o=a+144|0;p=f[o>>2]|0;if(p|0){q=p;do{p=q;q=f[q>>2]|0;dn(p)}while((q|0)!=0)}f[o>>2]=0;o=f[a+140>>2]|0;if(o|0){q=a+136|0;p=0;do{f[(f[q>>2]|0)+(p<<2)>>2]=0;p=p+1|0}while((p|0)!=(o|0))}f[n>>2]=0}n=a+4|0;if(!(dg(g,f[(f[n>>2]|0)+32>>2]|0)|0)){r=0;u=c;return r|0}o=a+156|0;f[o>>2]=f[g>>2];g=(dg(h,f[(f[n>>2]|0)+32>>2]|0)|0)^1;do if(!((f[h>>2]|0)>>>0>1431655765|g)){p=f[a+24>>2]|0;q=a+28|0;s=f[q>>2]|0;if((s|0)!=(p|0))f[q>>2]=s+(~((s+-4-p|0)>>>2)<<2);p=bj(88)|0;di(p);s=a+8|0;q=f[s>>2]|0;f[s>>2]=p;if(q|0?(mf(q),dn(q),(f[s>>2]|0)==0):0){t=0;break}q=a+160|0;p=f[q>>2]|0;v=a+164|0;w=f[v>>2]|0;if((w|0)!=(p|0))f[v>>2]=w+(~((w+-4-p|0)>>>2)<<2);Eg(q,f[h>>2]|0);q=a+172|0;p=f[q>>2]|0;w=a+176|0;v=f[w>>2]|0;if((v|0)!=(p|0))f[w>>2]=v+(~((v+-4-p|0)>>>2)<<2);Eg(q,f[h>>2]|0);q=f[a+36>>2]|0;p=a+40|0;v=f[p>>2]|0;if((v|0)!=(q|0))f[p>>2]=v+(~(((v+-12-q|0)>>>0)/12|0)*12|0);q=f[a+48>>2]|0;v=a+52|0;p=f[v>>2]|0;if((p|0)!=(q|0))f[v>>2]=p+(~((p+-4-q|0)>>>2)<<2);f[a+64>>2]=0;q=f[a+72>>2]|0;p=a+76|0;v=f[p>>2]|0;if((v|0)!=(q|0))f[p>>2]=v+(~((v+-4-q|0)>>>2)<<2);f[a+84>>2]=-1;f[a+92>>2]=-1;f[a+88>>2]=-1;q=f[(f[n>>2]|0)+32>>2]|0;v=q+8|0;p=f[v+4>>2]|0;w=q+16|0;x=w;y=f[x>>2]|0;z=f[x+4>>2]|0;if((p|0)>(z|0)|((p|0)==(z|0)?(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]|0);f[a+364>>2]=q;Bi(k);q=a+264|0;B=q;x=p;y=B+40|0;do{f[B>>2]=f[x>>2];B=B+4|0;x=x+4|0}while((B|0)<(y|0));a:do if(ah(q,1,e)|0){B=p;x=q;y=B+40|0;do{f[B>>2]=f[x>>2];B=B+4|0;x=x+4|0}while((B|0)<(y|0));v=e;A=f[v>>2]|0;C=f[v+4>>2]|0;v=a+232|0;D=a+240|0;E=D;F=f[E>>2]|0;G=f[E+4>>2]|0;E=Tj(f[v>>2]|0,f[v+4>>2]|0,F|0,G|0)|0;v=I;if(C>>>0>v>>>0|(C|0)==(v|0)&A>>>0>E>>>0){H=46;break}E=Rj(F|0,G|0,A|0,C|0)|0;C=D;f[C>>2]=E;f[C+4>>2]=I;td(a+304|0,p)|0;if(!(qf(p)|0)){J=0;break}B=k;x=p;y=B+40|0;do{f[B>>2]=f[x>>2];B=B+4|0;x=x+4|0}while((B|0)<(y|0));C=_a(a,f[i>>2]|0)|0;if((C|0)==-1){J=0;break}E=f[(f[n>>2]|0)+32>>2]|0;D=k+16|0;A=f[D>>2]|0;G=(f[k>>2]|0)+A|0;F=k+8|0;v=Tj(f[F>>2]|0,f[F+4>>2]|0,A|0,f[D+4>>2]|0)|0;Wi(E,G,v,d[E+38>>1]|0);do if((f[w>>2]|0)!=(f[z>>2]|0)){E=f[s>>2]|0;if((f[E+4>>2]|0)==(f[E>>2]|0))break;E=0;do{f[l>>2]=E;f[e>>2]=f[l>>2];E=E+3|0;if(!(Gb(a,e)|0)){J=0;break a}v=f[s>>2]|0}while(E>>>0<(f[v+4>>2]|0)-(f[v>>2]|0)>>2>>>0)}while(0);if(b[a+300>>0]|0)bi(q);E=f[z>>2]|0;if((f[w>>2]|0)!=(E|0)){v=0;G=E;do{te(G+(v*144|0)+4|0,f[s>>2]|0)|0;E=f[z>>2]|0;D=f[E+(v*144|0)+132>>2]|0;A=f[E+(v*144|0)+136>>2]|0;if((D|0)==(A|0))K=E;else{F=D;D=E;while(1){f[m>>2]=f[F>>2];f[e>>2]=f[m>>2];$d(D+(v*144|0)+4|0,e);F=F+4|0;E=f[z>>2]|0;if((F|0)==(A|0)){K=E;break}else D=E}}Lh(K+(v*144|0)+4|0,0,0);v=v+1|0;G=f[z>>2]|0}while(v>>>0<(((f[w>>2]|0)-G|0)/144|0)>>>0)}G=f[s>>2]|0;v=(f[G+28>>2]|0)-(f[G+24>>2]|0)>>2;G=a+196|0;D=a+200|0;A=f[D>>2]|0;F=f[G>>2]|0;E=A-F>>2;L=F;F=A;do if(v>>>0>E>>>0)ff(G,v-E|0);else{if(v>>>0>=E>>>0)break;A=L+(v<<2)|0;if((A|0)==(F|0))break;f[D>>2]=F+(~((F+-4-A|0)>>>2)<<2)}while(0);Eg(a+184|0,v);F=f[z>>2]|0;if((f[w>>2]|0)!=(F|0)){D=0;L=F;do{F=L;E=(f[F+(D*144|0)+60>>2]|0)-(f[F+(D*144|0)+56>>2]|0)>>2;G=f[s>>2]|0;A=(f[G+28>>2]|0)-(f[G+24>>2]|0)>>2;G=(E|0)<(A|0)?A:E;E=F+(D*144|0)+116|0;A=F+(D*144|0)+120|0;M=f[A>>2]|0;N=f[E>>2]|0;O=M-N>>2;P=N;N=M;do if(G>>>0>O>>>0)ff(E,G-O|0);else{if(G>>>0>=O>>>0)break;M=P+(G<<2)|0;if((M|0)==(N|0))break;f[A>>2]=N+(~((N+-4-M|0)>>>2)<<2)}while(0);Eg(F+(D*144|0)+104|0,G);D=D+1|0;L=f[z>>2]|0}while(D>>>0<(((f[w>>2]|0)-L|0)/144|0)>>>0)}J=fb(a,C)|0}else H=46;while(0);if((H|0)==46)J=0;Q=J}else Q=0;R=Q}else R=0;t=R}else t=0}else t=0;while(0);r=t;u=c;return r|0}function ib(a){a=a|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0;c=u;u=u+80|0;e=c+64|0;g=c+60|0;h=c+56|0;i=c+52|0;j=c+48|0;k=c;l=c+44|0;m=c+40|0;f[a+132>>2]=0;n=a+148|0;if(f[n>>2]|0){o=a+144|0;p=f[o>>2]|0;if(p|0){q=p;do{p=q;q=f[q>>2]|0;dn(p)}while((q|0)!=0)}f[o>>2]=0;o=f[a+140>>2]|0;if(o|0){q=a+136|0;p=0;do{f[(f[q>>2]|0)+(p<<2)>>2]=0;p=p+1|0}while((p|0)!=(o|0))}f[n>>2]=0}n=a+4|0;if(!(dg(g,f[(f[n>>2]|0)+32>>2]|0)|0)){r=0;u=c;return r|0}o=a+156|0;f[o>>2]=f[g>>2];g=(dg(h,f[(f[n>>2]|0)+32>>2]|0)|0)^1;do if(!((f[h>>2]|0)>>>0>1431655765|g)){p=f[a+24>>2]|0;q=a+28|0;s=f[q>>2]|0;if((s|0)!=(p|0))f[q>>2]=s+(~((s+-4-p|0)>>>2)<<2);p=bj(88)|0;di(p);s=a+8|0;q=f[s>>2]|0;f[s>>2]=p;if(q|0?(mf(q),dn(q),(f[s>>2]|0)==0):0){t=0;break}q=a+160|0;p=f[q>>2]|0;v=a+164|0;w=f[v>>2]|0;if((w|0)!=(p|0))f[v>>2]=w+(~((w+-4-p|0)>>>2)<<2);Eg(q,f[h>>2]|0);q=a+172|0;p=f[q>>2]|0;w=a+176|0;v=f[w>>2]|0;if((v|0)!=(p|0))f[w>>2]=v+(~((v+-4-p|0)>>>2)<<2);Eg(q,f[h>>2]|0);q=f[a+36>>2]|0;p=a+40|0;v=f[p>>2]|0;if((v|0)!=(q|0))f[p>>2]=v+(~(((v+-12-q|0)>>>0)/12|0)*12|0);q=f[a+48>>2]|0;v=a+52|0;p=f[v>>2]|0;if((p|0)!=(q|0))f[v>>2]=p+(~((p+-4-q|0)>>>2)<<2);f[a+64>>2]=0;q=f[a+72>>2]|0;p=a+76|0;v=f[p>>2]|0;if((v|0)!=(q|0))f[p>>2]=v+(~((v+-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>>2]&127](a)|0)+32|0;x=f[A>>2]|0;A=x+8|0;B=x+16|0;x=Tj(f[A>>2]|0,f[A+4>>2]|0,f[B>>2]|0,f[B+4>>2]|0)|0;B=(Na[f[(f[a>>2]|0)+32>>2]&127](a)|0)+32|0;Wi(p,y,x,d[(f[B>>2]|0)+38>>1]|0);B=Na[f[(f[a>>2]|0)+36>>2]&127](a)|0;f[a+372>>2]=B;f[a+376>>2]=(f[j>>2]|0)+(f[o>>2]|0);f[a+364>>2]=q;Bi(k);a:do if(kc(p,k)|0){q=Za(a,f[i>>2]|0)|0;if((q|0)==-1){C=0;break}B=f[(f[n>>2]|0)+32>>2]|0;x=k+16|0;y=f[x>>2]|0;A=(f[k>>2]|0)+y|0;D=k+8|0;E=Tj(f[D>>2]|0,f[D+4>>2]|0,y|0,f[x+4>>2]|0)|0;Wi(B,A,E,d[B+38>>1]|0);do if((f[w>>2]|0)!=(f[z>>2]|0)){B=f[s>>2]|0;if((f[B+4>>2]|0)==(f[B>>2]|0))break;B=0;do{f[l>>2]=B;f[e>>2]=f[l>>2];B=B+3|0;if(!(Gb(a,e)|0)){C=0;break a}E=f[s>>2]|0}while(B>>>0<(f[E+4>>2]|0)-(f[E>>2]|0)>>2>>>0)}while(0);if(b[a+300>>0]|0)bi(a+264|0);B=f[z>>2]|0;if((f[w>>2]|0)!=(B|0)){E=0;A=B;do{te(A+(E*144|0)+4|0,f[s>>2]|0)|0;B=f[z>>2]|0;x=f[B+(E*144|0)+132>>2]|0;y=f[B+(E*144|0)+136>>2]|0;if((x|0)==(y|0))F=B;else{D=x;x=B;while(1){f[m>>2]=f[D>>2];f[e>>2]=f[m>>2];$d(x+(E*144|0)+4|0,e);D=D+4|0;B=f[z>>2]|0;if((D|0)==(y|0)){F=B;break}else x=B}}Lh(F+(E*144|0)+4|0,0,0);E=E+1|0;A=f[z>>2]|0}while(E>>>0<(((f[w>>2]|0)-A|0)/144|0)>>>0)}A=f[s>>2]|0;E=(f[A+28>>2]|0)-(f[A+24>>2]|0)>>2;A=a+196|0;x=a+200|0;y=f[x>>2]|0;D=f[A>>2]|0;B=y-D>>2;G=D;D=y;do if(E>>>0>B>>>0)ff(A,E-B|0);else{if(E>>>0>=B>>>0)break;y=G+(E<<2)|0;if((y|0)==(D|0))break;f[x>>2]=D+(~((D+-4-y|0)>>>2)<<2)}while(0);Eg(a+184|0,E);D=f[z>>2]|0;if((f[w>>2]|0)!=(D|0)){x=0;G=D;do{D=G;B=(f[D+(x*144|0)+60>>2]|0)-(f[D+(x*144|0)+56>>2]|0)>>2;A=f[s>>2]|0;y=(f[A+28>>2]|0)-(f[A+24>>2]|0)>>2;A=(B|0)<(y|0)?y:B;B=D+(x*144|0)+116|0;y=D+(x*144|0)+120|0;H=f[y>>2]|0;J=f[B>>2]|0;K=H-J>>2;L=J;J=H;do if(A>>>0>K>>>0)ff(B,A-K|0);else{if(A>>>0>=K>>>0)break;H=L+(A<<2)|0;if((H|0)==(J|0))break;f[y>>2]=J+(~((J+-4-H|0)>>>2)<<2)}while(0);Eg(D+(x*144|0)+104|0,A);x=x+1|0;G=f[z>>2]|0}while(x>>>0<(((f[w>>2]|0)-G|0)/144|0)>>>0)}C=fb(a,q)|0}else C=0;while(0);M=C}else M=0;N=M}else N=0;t=N}else t=0}else t=0;while(0);r=t;u=c;return r|0}function jb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=La,D=0,E=0.0,F=0,G=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Rj(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){m=b[o>>0]|0;q=g+(r<<3)|0;f[q>>2]=m;f[q+4>>2]=((m|0)<0)<<31>>31;r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Rj(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=g+(t<<3)|0;f[k>>2]=h[m>>0];f[k+4>>2]=0;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Rj(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){o=d[l>>1]|0;k=g+(q<<3)|0;f[k>>2]=o;f[k+4>>2]=((o|0)<0)<<31>>31;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Rj(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=j[r>>1];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(r<<3)|0,0,(e<<24>>24)-r<<3|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=gj(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Rj(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){l=f[t>>2]|0;m=g+(o<<3)|0;f[m>>2]=l;f[m+4>>2]=((l|0)<0)<<31>>31;o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Rj(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){r=g+(m<<3)|0;f[r>>2]=f[q>>2];f[r+4>>2]=0;m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Rj(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){t=k;r=f[t+4>>2]|0;z=g+(l<<3)|0;f[z>>2]=f[t>>2];f[z+4>>2]=r;l=l+1|0;r=b[q>>0]|0;if((l|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){A=r;break}else k=k+8|0}}else A=m;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<3)|0,0,(e<<24>>24)-k<<3|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;r=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;z=Rj(r|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+z|0;z=0;while(1){q=o;r=f[q+4>>2]|0;t=g+(z<<3)|0;f[t>>2]=f[q>>2];f[t+4>>2]=r;z=z+1|0;r=b[k>>0]|0;if((z|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){B=r;break}else o=o+8|0}}else B=l;o=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 9:{o=a+24|0;z=b[o>>0]|0;if((z<<24>>24>e<<24>>24?e:z)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;r=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Rj(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){C=$(n[m>>2]);k=+K(+C)>=1.0?(+C>0.0?~~+Y(+J(+C/4294967296.0),4294967295.0)>>>0:~~+W((+C-+(~~+C>>>0))/4294967296.0)>>>0):0;r=g+(t<<3)|0;f[r>>2]=~~+C>>>0;f[r+4>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else m=m+4|0}}else D=z;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;r=Rj(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+r|0;r=0;while(1){E=+p[l>>3];o=+K(E)>=1.0?(E>0.0?~~+Y(+J(E/4294967296.0),4294967295.0)>>>0:~~+W((E-+(~~E>>>0))/4294967296.0)>>>0):0;k=g+(r<<3)|0;f[k>>2]=~~E>>>0;f[k+4>>2]=o;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){F=o;break}else l=l+8|0}}else F=t;l=F<<24>>24;if(F<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 11:{l=a+24|0;r=b[l>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){m=f[f[a>>2]>>2]|0;z=a+40|0;o=gj(f[z>>2]|0,f[z+4>>2]|0,f[c>>2]|0,0)|0;z=a+48|0;k=Rj(o|0,I|0,f[z>>2]|0,f[z+4>>2]|0)|0;z=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=h[z>>0];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){G=m;break}else z=z+1|0}}else G=r;z=G<<24>>24;if(G<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(z<<3)|0,0,(e<<24>>24)-z<<3|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function kb(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0;c=u;u=u+32|0;d=c+20|0;e=c+16|0;g=c+4|0;i=c;j=a+32|0;if(!(dg(d,f[j>>2]|0)|0)){k=0;u=c;return k|0}if(!(dg(e,f[j>>2]|0)|0)){k=0;u=c;return k|0}l=f[d>>2]|0;if(l>>>0>1431655765){k=0;u=c;return k|0}m=f[e>>2]|0;n=gj(l|0,0,3,0)|0;o=I;if(o>>>0<0|(o|0)==0&n>>>0>>0){k=0;u=c;return k|0}n=f[j>>2]|0;o=n+8|0;p=f[o+4>>2]|0;q=n+16|0;r=q;s=f[r>>2]|0;t=f[r+4>>2]|0;if(!((p|0)>(t|0)|((p|0)==(t|0)?(f[o>>2]|0)>>>0>s>>>0:0))){k=0;u=c;return k|0}o=b[(f[n>>2]|0)+s>>0]|0;p=Rj(s|0,t|0,1,0)|0;r=I;v=q;f[v>>2]=p;f[v+4>>2]=r;a:do if(!(o<<24>>24)){if(!(ed(a,l)|0)){k=0;u=c;return k|0}}else{if(m>>>0<256){if(!l)break;v=a+44|0;q=g+4|0;w=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=(f[P>>2]|0)+12;T=F}G=G+1|0;if(G>>>0>=T>>>0)break a;A=f[j>>2]|0;P=A+16|0;J=f[P>>2]|0;H=f[P+4>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;P=A+8|0;D=f[P>>2]|0;E=f[P+4>>2]|0;x=Rj(J|0,H|0,4,0)|0;K=I;if((E|0)<(K|0)|(E|0)==(K|0)&D>>>0>>0)break;else F=T}}while(0);k=0;u=c;return k|0}}while(0);f[(f[a+4>>2]|0)+80>>2]=f[e>>2];k=1;u=c;return k|0}function lb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;c=u;u=u+16|0;d=c+8|0;e=c;if((f[a+96>>2]|0)==(f[a+92>>2]|0)){u=c;return}g=a+56|0;h=f[g>>2]|0;if((h|0)==(f[a+60>>2]|0)){xf(a+52|0,b);i=b}else{f[h>>2]=f[b>>2];f[g>>2]=h+4;i=b}b=a+88|0;f[b>>2]=0;h=f[a>>2]|0;g=f[i>>2]|0;j=g+1|0;if((g|0)!=-1){k=((j>>>0)%3|0|0)==0?g+-2|0:j;if((k|0)==-1)l=-1;else l=f[(f[h>>2]|0)+(k<<2)>>2]|0;k=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((k|0)==-1){m=l;n=-1}else{m=l;n=f[(f[h>>2]|0)+(k<<2)>>2]|0}}else{m=-1;n=-1}k=a+24|0;h=f[k>>2]|0;l=h+(m>>>5<<2)|0;g=1<<(m&31);j=f[l>>2]|0;if(!(j&g)){f[l>>2]=j|g;g=f[i>>2]|0;j=g+1|0;if((g|0)==-1)o=-1;else o=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=o;j=f[(f[(f[a+44>>2]|0)+96>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>2]|0)+96>>2]|0)+(((n>>>0)/3|0)*12|0)+(((n>>>0)%3|0)<<2)>>2]|0;n=f[a+48>>2]|0;f[d>>2]=s;r=f[n+4>>2]|0;n=r+4|0;o=f[n>>2]|0;if((o|0)==(f[r+8>>2]|0))xf(r,d);else{f[o>>2]=s;f[n>>2]=o+4}o=a+40|0;n=f[o>>2]|0;s=n+4|0;r=f[s>>2]|0;if((r|0)==(f[n+8>>2]|0)){xf(n,e);v=f[o>>2]|0}else{f[r>>2]=f[e>>2];f[s>>2]=r+4;v=n}n=v+24|0;f[(f[v+12>>2]|0)+(t<<2)>>2]=f[n>>2];f[n>>2]=(f[n>>2]|0)+1}n=f[b>>2]|0;a:do if((n|0)<3){t=a+12|0;v=a+44|0;r=a+48|0;s=a+40|0;o=a+92|0;q=n;while(1){h=q;while(1){w=a+52+(h*12|0)+4|0;x=f[w>>2]|0;if((f[a+52+(h*12|0)>>2]|0)!=(x|0))break;if((h|0)<2)h=h+1|0;else break a}m=x+-4|0;p=f[m>>2]|0;f[w>>2]=m;f[b>>2]=h;f[i>>2]=p;if((p|0)==-1)break;m=(p>>>0)/3|0;g=f[t>>2]|0;do if(!(f[g+(m>>>5<<2)>>2]&1<<(m&31))){j=p;l=g;b:while(1){y=(j>>>0)/3|0;z=l+(y>>>5<<2)|0;f[z>>2]=1<<(y&31)|f[z>>2];z=f[i>>2]|0;if((z|0)==-1)A=-1;else A=f[(f[f[a>>2]>>2]|0)+(z<<2)>>2]|0;y=(f[k>>2]|0)+(A>>>5<<2)|0;B=1<<(A&31);C=f[y>>2]|0;if(!(B&C)){f[y>>2]=C|B;B=f[i>>2]|0;f[e>>2]=B;C=f[(f[(f[v>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=C;y=f[B+4>>2]|0;B=y+4|0;D=f[B>>2]|0;if((D|0)==(f[y+8>>2]|0))xf(y,d);else{f[D>>2]=C;f[B>>2]=D+4}D=f[s>>2]|0;B=D+4|0;C=f[B>>2]|0;if((C|0)==(f[D+8>>2]|0)){xf(D,e);E=f[s>>2]|0}else{f[C>>2]=f[e>>2];f[B>>2]=C+4;E=D}D=E+24|0;f[(f[E+12>>2]|0)+(A<<2)>>2]=f[D>>2];f[D>>2]=(f[D>>2]|0)+1;F=f[i>>2]|0}else F=z;z=f[a>>2]|0;if((F|0)==-1){G=93;break}D=F+1|0;C=((D>>>0)%3|0|0)==0?F+-2|0:D;if((C|0)==-1)H=-1;else H=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((C|0)==-1)I=-1;else I=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(H|0)==-1;D=C?-1:(H>>>0)/3|0;B=(I|0)==-1;y=B?-1:(I>>>0)/3|0;if(C)J=1;else J=(f[(f[t>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)|0)!=0;do if(B)if(J){G=93;break b}else G=82;else{if(f[(f[t>>2]|0)+(y>>>5<<2)>>2]&1<<(y&31)|0)if(J){G=93;break b}else{G=82;break}D=f[(f[z>>2]|0)+(I<<2)>>2]|0;if(!(1<<(D&31)&f[(f[k>>2]|0)+(D>>>5<<2)>>2])){K=(f[o>>2]|0)+(D<<2)|0;D=f[K>>2]|0;f[K>>2]=D+1;L=(D|0)>0?1:2}else L=0;if(J?(L|0)<=(f[b>>2]|0):0){M=I;break}f[d>>2]=I;D=a+52+(L*12|0)+4|0;K=f[D>>2]|0;if((K|0)==(f[a+52+(L*12|0)+8>>2]|0))xf(a+52+(L*12|0)|0,d);else{f[K>>2]=I;f[D>>2]=K+4}if((f[b>>2]|0)>(L|0))f[b>>2]=L;if(J){G=93;break b}else G=82}while(0);if((G|0)==82){G=0;if(C)N=-1;else N=f[(f[f[a>>2]>>2]|0)+(H<<2)>>2]|0;if(!(1<<(N&31)&f[(f[k>>2]|0)+(N>>>5<<2)>>2])){z=(f[o>>2]|0)+(N<<2)|0;y=f[z>>2]|0;f[z>>2]=y+1;O=(y|0)>0?1:2}else O=0;if((O|0)>(f[b>>2]|0))break;else M=H}f[i>>2]=M;j=M;l=f[t>>2]|0}if((G|0)==93){G=0;P=f[b>>2]|0;break}f[d>>2]=H;l=a+52+(O*12|0)+4|0;j=f[l>>2]|0;if((j|0)==(f[a+52+(O*12|0)+8>>2]|0))xf(a+52+(O*12|0)|0,d);else{f[j>>2]=H;f[l>>2]=j+4}j=f[b>>2]|0;if((j|0)>(O|0)){f[b>>2]=O;Q=O}else Q=j;P=Q}else P=h;while(0);if((P|0)<3)q=P;else break a}u=c;return}while(0);f[i>>2]=-1;u=c;return}function mb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{j=a+24|0;k=b[j>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;m=a+40|0;o=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;q=Rj(o|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=l+q|0;q=0;while(1){d[g+(q<<1)>>1]=b[m>>0]|0;q=q+1|0;l=b[j>>0]|0;if((q|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){r=l;break}else m=m+1|0}}else r=k;m=r<<24>>24;if(r<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<1)|0,0,(e<<24>>24)-m<<1|0)|0;i=1;return i|0}case 2:{m=a+24|0;q=b[m>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){j=f[f[a>>2]>>2]|0;l=a+40|0;o=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;s=Rj(o|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=j+s|0;s=0;while(1){d[g+(s<<1)>>1]=h[l>>0]|0;s=s+1|0;j=b[m>>0]|0;if((s|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){t=j;break}else l=l+1|0}}else t=q;l=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 3:{l=a+24|0;s=b[l>>0]|0;if((s<<24>>24>e<<24>>24?e:s)<<24>>24>0){m=f[f[a>>2]>>2]|0;k=a+40|0;j=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;o=Rj(j|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=m+o|0;o=0;while(1){d[g+(o<<1)>>1]=d[k>>1]|0;o=o+1|0;m=b[l>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){u=m;break}else k=k+2|0}}else u=s;k=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<1)|0,0,(e<<24>>24)-k<<1|0)|0;i=1;return i|0}case 4:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){l=f[f[a>>2]>>2]|0;q=a+40|0;m=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;j=Rj(m|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=l+j|0;j=0;while(1){d[g+(j<<1)>>1]=d[q>>1]|0;j=j+1|0;l=b[k>>0]|0;if((j|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else q=q+2|0}}else v=o;q=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<1)|0,0,(e<<24>>24)-q<<1|0)|0;i=1;return i|0}case 5:{q=a+24|0;j=b[q>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;s=a+40|0;l=gj(f[s>>2]|0,f[s+4>>2]|0,f[c>>2]|0,0)|0;s=a+48|0;m=Rj(l|0,I|0,f[s>>2]|0,f[s+4>>2]|0)|0;s=k+m|0;m=0;while(1){d[g+(m<<1)>>1]=f[s>>2];m=m+1|0;k=b[q>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){w=k;break}else s=s+4|0}}else w=j;s=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}case 6:{s=a+24|0;m=b[s>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;k=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;l=Rj(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+l|0;l=0;while(1){d[g+(l<<1)>>1]=f[o>>2];l=l+1|0;q=b[s>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else o=o+4|0}}else x=m;o=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 7:{o=a+24|0;l=b[o>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){s=f[f[a>>2]>>2]|0;j=a+40|0;q=gj(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;k=Rj(q|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=s+k|0;k=0;while(1){d[g+(k<<1)>>1]=f[j>>2];k=k+1|0;s=b[o>>0]|0;if((k|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){y=s;break}else j=j+8|0}}else y=l;j=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(j<<1)|0,0,(e<<24>>24)-j<<1|0)|0;i=1;return i|0}case 8:{j=a+24|0;k=b[j>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){o=f[f[a>>2]>>2]|0;m=a+40|0;s=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;q=Rj(s|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=o+q|0;q=0;while(1){d[g+(q<<1)>>1]=f[m>>2];q=q+1|0;o=b[j>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){z=o;break}else m=m+8|0}}else z=k;m=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<1)|0,0,(e<<24>>24)-m<<1|0)|0;i=1;return i|0}case 9:{m=a+24|0;q=b[m>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){j=f[f[a>>2]>>2]|0;l=a+40|0;o=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;s=Rj(o|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=j+s|0;s=0;while(1){j=~~$(n[l>>2])&65535;d[g+(s<<1)>>1]=j;s=s+1|0;j=b[m>>0]|0;if((s|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){A=j;break}else l=l+4|0}}else A=q;l=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 10:{l=a+24|0;s=b[l>>0]|0;if((s<<24>>24>e<<24>>24?e:s)<<24>>24>0){m=f[f[a>>2]>>2]|0;k=a+40|0;j=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;o=Rj(j|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=m+o|0;o=0;while(1){d[g+(o<<1)>>1]=~~+p[k>>3];o=o+1|0;m=b[l>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){B=m;break}else k=k+8|0}}else B=s;k=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<1)|0,0,(e<<24>>24)-k<<1|0)|0;i=1;return i|0}case 11:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){l=f[f[a>>2]>>2]|0;q=a+40|0;m=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;j=Rj(m|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=l+j|0;j=0;while(1){d[g+(j<<1)>>1]=h[q>>0]|0;j=j+1|0;l=b[k>>0]|0;if((j|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){C=l;break}else q=q+1|0}}else C=o;q=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<1)|0,0,(e<<24>>24)-q<<1|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function nb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{j=a+24|0;k=b[j>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;m=a+40|0;o=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;q=Rj(o|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=l+q|0;q=0;while(1){d[g+(q<<1)>>1]=b[m>>0]|0;q=q+1|0;l=b[j>>0]|0;if((q|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){r=l;break}else m=m+1|0}}else r=k;m=r<<24>>24;if(r<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<1)|0,0,(e<<24>>24)-m<<1|0)|0;i=1;return i|0}case 2:{m=a+24|0;q=b[m>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){j=f[f[a>>2]>>2]|0;l=a+40|0;o=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;s=Rj(o|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=j+s|0;s=0;while(1){d[g+(s<<1)>>1]=h[l>>0]|0;s=s+1|0;j=b[m>>0]|0;if((s|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){t=j;break}else l=l+1|0}}else t=q;l=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 3:{l=a+24|0;s=b[l>>0]|0;if((s<<24>>24>e<<24>>24?e:s)<<24>>24>0){m=f[f[a>>2]>>2]|0;k=a+40|0;j=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;o=Rj(j|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=m+o|0;o=0;while(1){d[g+(o<<1)>>1]=d[k>>1]|0;o=o+1|0;m=b[l>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){u=m;break}else k=k+2|0}}else u=s;k=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<1)|0,0,(e<<24>>24)-k<<1|0)|0;i=1;return i|0}case 4:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){l=f[f[a>>2]>>2]|0;q=a+40|0;m=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;j=Rj(m|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=l+j|0;j=0;while(1){d[g+(j<<1)>>1]=d[q>>1]|0;j=j+1|0;l=b[k>>0]|0;if((j|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else q=q+2|0}}else v=o;q=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<1)|0,0,(e<<24>>24)-q<<1|0)|0;i=1;return i|0}case 5:{q=a+24|0;j=b[q>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;s=a+40|0;l=gj(f[s>>2]|0,f[s+4>>2]|0,f[c>>2]|0,0)|0;s=a+48|0;m=Rj(l|0,I|0,f[s>>2]|0,f[s+4>>2]|0)|0;s=k+m|0;m=0;while(1){d[g+(m<<1)>>1]=f[s>>2];m=m+1|0;k=b[q>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){w=k;break}else s=s+4|0}}else w=j;s=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(s<<1)|0,0,(e<<24>>24)-s<<1|0)|0;i=1;return i|0}case 6:{s=a+24|0;m=b[s>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;k=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;l=Rj(k|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+l|0;l=0;while(1){d[g+(l<<1)>>1]=f[o>>2];l=l+1|0;q=b[s>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else o=o+4|0}}else x=m;o=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<1)|0,0,(e<<24>>24)-o<<1|0)|0;i=1;return i|0}case 7:{o=a+24|0;l=b[o>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){s=f[f[a>>2]>>2]|0;j=a+40|0;q=gj(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;k=Rj(q|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=s+k|0;k=0;while(1){d[g+(k<<1)>>1]=f[j>>2];k=k+1|0;s=b[o>>0]|0;if((k|0)>=((s<<24>>24>e<<24>>24?e:s)<<24>>24|0)){y=s;break}else j=j+8|0}}else y=l;j=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(j<<1)|0,0,(e<<24>>24)-j<<1|0)|0;i=1;return i|0}case 8:{j=a+24|0;k=b[j>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){o=f[f[a>>2]>>2]|0;m=a+40|0;s=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;q=Rj(s|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=o+q|0;q=0;while(1){d[g+(q<<1)>>1]=f[m>>2];q=q+1|0;o=b[j>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){z=o;break}else m=m+8|0}}else z=k;m=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<1)|0,0,(e<<24>>24)-m<<1|0)|0;i=1;return i|0}case 9:{m=a+24|0;q=b[m>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){j=f[f[a>>2]>>2]|0;l=a+40|0;o=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;s=Rj(o|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=j+s|0;s=0;while(1){j=~~$(n[l>>2]);d[g+(s<<1)>>1]=j;s=s+1|0;j=b[m>>0]|0;if((s|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){A=j;break}else l=l+4|0}}else A=q;l=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<1)|0,0,(e<<24>>24)-l<<1|0)|0;i=1;return i|0}case 10:{l=a+24|0;s=b[l>>0]|0;if((s<<24>>24>e<<24>>24?e:s)<<24>>24>0){m=f[f[a>>2]>>2]|0;k=a+40|0;j=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;o=Rj(j|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=m+o|0;o=0;while(1){d[g+(o<<1)>>1]=~~+p[k>>3];o=o+1|0;m=b[l>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){B=m;break}else k=k+8|0}}else B=s;k=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<1)|0,0,(e<<24>>24)-k<<1|0)|0;i=1;return i|0}case 11:{k=a+24|0;o=b[k>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){l=f[f[a>>2]>>2]|0;q=a+40|0;m=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;j=Rj(m|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=l+j|0;j=0;while(1){d[g+(j<<1)>>1]=h[q>>0]|0;j=j+1|0;l=b[k>>0]|0;if((j|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){C=l;break}else q=q+1|0}}else C=o;q=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<1)|0,0,(e<<24>>24)-q<<1|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function ob(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Rj(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Rj(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Rj(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Rj(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=gj(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Rj(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Rj(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Rj(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Rj(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Rj(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2])>>>0;f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Rj(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3]>>>0;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Rj(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function pb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Rj(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Rj(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Rj(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Rj(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=gj(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Rj(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=gj(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Rj(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Rj(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Rj(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Rj(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2]);f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Rj(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Rj(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}Vf(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function qb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;if(!g){h=0;return h|0}do switch(f[a+28>>2]|0){case 1:{i=a+24|0;j=b[i>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;o=Rj(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=k+o|0;o=0;while(1){b[g+o>>0]=b[l>>0]|0;o=o+1|0;k=b[i>>0]|0;if((o|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){q=k;break}else l=l+1|0}}else q=j;l=q<<24>>24;if(q<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+l|0,0,(e<<24>>24)-l|0)|0;h=1;return h|0}case 2:{l=a+24|0;o=b[l>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){i=f[f[a>>2]>>2]|0;k=a+40|0;m=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Rj(m|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=i+r|0;r=0;while(1){b[g+r>>0]=b[k>>0]|0;r=r+1|0;i=b[l>>0]|0;if((r|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){s=i;break}else k=k+1|0}}else s=o;k=s<<24>>24;if(s<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 3:{k=a+24|0;r=b[k>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){l=f[f[a>>2]>>2]|0;j=a+40|0;i=gj(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;m=Rj(i|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=l+m|0;m=0;while(1){b[g+m>>0]=d[j>>1];m=m+1|0;l=b[k>>0]|0;if((m|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){t=l;break}else j=j+2|0}}else t=r;j=t<<24>>24;if(t<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+j|0,0,(e<<24>>24)-j|0)|0;h=1;return h|0}case 4:{j=a+24|0;m=b[j>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;l=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;i=Rj(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+i|0;i=0;while(1){b[g+i>>0]=d[o>>1];i=i+1|0;k=b[j>>0]|0;if((i|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else o=o+2|0}}else u=m;o=u<<24>>24;if(u<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+o|0,0,(e<<24>>24)-o|0)|0;h=1;return h|0}case 5:{o=a+24|0;i=b[o>>0]|0;if((i<<24>>24>e<<24>>24?e:i)<<24>>24>0){j=f[f[a>>2]>>2]|0;r=a+40|0;k=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;l=Rj(k|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=j+l|0;l=0;while(1){b[g+l>>0]=f[r>>2];l=l+1|0;j=b[o>>0]|0;if((l|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){v=j;break}else r=r+4|0}}else v=i;r=v<<24>>24;if(v<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}case 6:{r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){o=f[f[a>>2]>>2]|0;m=a+40|0;j=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;k=Rj(j|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=o+k|0;k=0;while(1){b[g+k>>0]=f[m>>2];k=k+1|0;o=b[r>>0]|0;if((k|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){w=o;break}else m=m+4|0}}else w=l;m=w<<24>>24;if(w<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 7:{m=a+24|0;k=b[m>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;i=a+40|0;o=gj(f[i>>2]|0,f[i+4>>2]|0,f[c>>2]|0,0)|0;i=a+48|0;j=Rj(o|0,I|0,f[i>>2]|0,f[i+4>>2]|0)|0;i=r+j|0;j=0;while(1){b[g+j>>0]=f[i>>2];j=j+1|0;r=b[m>>0]|0;if((j|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){x=r;break}else i=i+8|0}}else x=k;i=x<<24>>24;if(x<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+i|0,0,(e<<24>>24)-i|0)|0;h=1;return h|0}case 8:{i=a+24|0;j=b[i>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){m=f[f[a>>2]>>2]|0;l=a+40|0;r=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;o=Rj(r|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=m+o|0;o=0;while(1){b[g+o>>0]=f[l>>2];o=o+1|0;m=b[i>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){y=m;break}else l=l+8|0}}else y=j;l=y<<24>>24;if(y<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+l|0,0,(e<<24>>24)-l|0)|0;h=1;return h|0}case 9:{l=a+24|0;o=b[l>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){i=f[f[a>>2]>>2]|0;k=a+40|0;m=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Rj(m|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=i+r|0;r=0;while(1){i=~~$(n[k>>2])&255;b[g+r>>0]=i;r=r+1|0;i=b[l>>0]|0;if((r|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){z=i;break}else k=k+4|0}}else z=o;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 10:{k=a+24|0;r=b[k>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){l=f[f[a>>2]>>2]|0;j=a+40|0;i=gj(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;m=Rj(i|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=l+m|0;m=0;while(1){b[g+m>>0]=~~+p[j>>3];m=m+1|0;l=b[k>>0]|0;if((m|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){A=l;break}else j=j+8|0}}else A=r;j=A<<24>>24;if(A<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+j|0,0,(e<<24>>24)-j|0)|0;h=1;return h|0}case 11:{j=a+24|0;m=b[j>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;l=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;i=Rj(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+i|0;i=0;while(1){b[g+i>>0]=b[o>>0]|0;i=i+1|0;k=b[j>>0]|0;if((i|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else o=o+1|0}}else B=m;o=B<<24>>24;if(B<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+o|0,0,(e<<24>>24)-o|0)|0;h=1;return h|0}default:{h=0;return h|0}}while(0);return 0}function rb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;if(!g){h=0;return h|0}do switch(f[a+28>>2]|0){case 1:{i=a+24|0;j=b[i>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){k=f[f[a>>2]>>2]|0;l=a+40|0;m=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;o=Rj(m|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=k+o|0;o=0;while(1){b[g+o>>0]=b[l>>0]|0;o=o+1|0;k=b[i>>0]|0;if((o|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){q=k;break}else l=l+1|0}}else q=j;l=q<<24>>24;if(q<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+l|0,0,(e<<24>>24)-l|0)|0;h=1;return h|0}case 2:{l=a+24|0;o=b[l>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){i=f[f[a>>2]>>2]|0;k=a+40|0;m=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Rj(m|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=i+r|0;r=0;while(1){b[g+r>>0]=b[k>>0]|0;r=r+1|0;i=b[l>>0]|0;if((r|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){s=i;break}else k=k+1|0}}else s=o;k=s<<24>>24;if(s<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 3:{k=a+24|0;r=b[k>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){l=f[f[a>>2]>>2]|0;j=a+40|0;i=gj(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;m=Rj(i|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=l+m|0;m=0;while(1){b[g+m>>0]=d[j>>1];m=m+1|0;l=b[k>>0]|0;if((m|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){t=l;break}else j=j+2|0}}else t=r;j=t<<24>>24;if(t<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+j|0,0,(e<<24>>24)-j|0)|0;h=1;return h|0}case 4:{j=a+24|0;m=b[j>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;l=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;i=Rj(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+i|0;i=0;while(1){b[g+i>>0]=d[o>>1];i=i+1|0;k=b[j>>0]|0;if((i|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else o=o+2|0}}else u=m;o=u<<24>>24;if(u<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+o|0,0,(e<<24>>24)-o|0)|0;h=1;return h|0}case 5:{o=a+24|0;i=b[o>>0]|0;if((i<<24>>24>e<<24>>24?e:i)<<24>>24>0){j=f[f[a>>2]>>2]|0;r=a+40|0;k=gj(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;l=Rj(k|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=j+l|0;l=0;while(1){b[g+l>>0]=f[r>>2];l=l+1|0;j=b[o>>0]|0;if((l|0)>=((j<<24>>24>e<<24>>24?e:j)<<24>>24|0)){v=j;break}else r=r+4|0}}else v=i;r=v<<24>>24;if(v<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+r|0,0,(e<<24>>24)-r|0)|0;h=1;return h|0}case 6:{r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){o=f[f[a>>2]>>2]|0;m=a+40|0;j=gj(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;k=Rj(j|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=o+k|0;k=0;while(1){b[g+k>>0]=f[m>>2];k=k+1|0;o=b[r>>0]|0;if((k|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){w=o;break}else m=m+4|0}}else w=l;m=w<<24>>24;if(w<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+m|0,0,(e<<24>>24)-m|0)|0;h=1;return h|0}case 7:{m=a+24|0;k=b[m>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;i=a+40|0;o=gj(f[i>>2]|0,f[i+4>>2]|0,f[c>>2]|0,0)|0;i=a+48|0;j=Rj(o|0,I|0,f[i>>2]|0,f[i+4>>2]|0)|0;i=r+j|0;j=0;while(1){b[g+j>>0]=f[i>>2];j=j+1|0;r=b[m>>0]|0;if((j|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){x=r;break}else i=i+8|0}}else x=k;i=x<<24>>24;if(x<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+i|0,0,(e<<24>>24)-i|0)|0;h=1;return h|0}case 8:{i=a+24|0;j=b[i>>0]|0;if((j<<24>>24>e<<24>>24?e:j)<<24>>24>0){m=f[f[a>>2]>>2]|0;l=a+40|0;r=gj(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;o=Rj(r|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=m+o|0;o=0;while(1){b[g+o>>0]=f[l>>2];o=o+1|0;m=b[i>>0]|0;if((o|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){y=m;break}else l=l+8|0}}else y=j;l=y<<24>>24;if(y<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+l|0,0,(e<<24>>24)-l|0)|0;h=1;return h|0}case 9:{l=a+24|0;o=b[l>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){i=f[f[a>>2]>>2]|0;k=a+40|0;m=gj(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Rj(m|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=i+r|0;r=0;while(1){i=~~$(n[k>>2]);b[g+r>>0]=i;r=r+1|0;i=b[l>>0]|0;if((r|0)>=((i<<24>>24>e<<24>>24?e:i)<<24>>24|0)){z=i;break}else k=k+4|0}}else z=o;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+k|0,0,(e<<24>>24)-k|0)|0;h=1;return h|0}case 10:{k=a+24|0;r=b[k>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){l=f[f[a>>2]>>2]|0;j=a+40|0;i=gj(f[j>>2]|0,f[j+4>>2]|0,f[c>>2]|0,0)|0;j=a+48|0;m=Rj(i|0,I|0,f[j>>2]|0,f[j+4>>2]|0)|0;j=l+m|0;m=0;while(1){b[g+m>>0]=~~+p[j>>3];m=m+1|0;l=b[k>>0]|0;if((m|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){A=l;break}else j=j+8|0}}else A=r;j=A<<24>>24;if(A<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+j|0,0,(e<<24>>24)-j|0)|0;h=1;return h|0}case 11:{j=a+24|0;m=b[j>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;l=gj(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;i=Rj(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+i|0;i=0;while(1){b[g+i>>0]=b[o>>0]|0;i=i+1|0;k=b[j>>0]|0;if((i|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else o=o+1|0}}else B=m;o=B<<24>>24;if(B<<24>>24>=e<<24>>24){h=1;return h|0}Vf(g+o|0,0,(e<<24>>24)-o|0)|0;h=1;return h|0}default:{h=0;return h|0}}while(0);return 0}function sb(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0;g=u;u=u+80|0;h=g+76|0;i=g+72|0;j=g+48|0;k=g+24|0;l=g;m=a+32|0;n=f[c>>2]|0;c=n+1|0;if((n|0)!=-1){o=((c>>>0)%3|0|0)==0?n+-2|0:c;c=(((n>>>0)%3|0|0)==0?2:-1)+n|0;if((o|0)==-1)p=-1;else p=f[(f[f[m>>2]>>2]|0)+(o<<2)>>2]|0;if((c|0)==-1){q=p;r=-1}else{q=p;r=f[(f[f[m>>2]>>2]|0)+(c<<2)>>2]|0}}else{q=-1;r=-1}c=f[a+36>>2]|0;m=f[c>>2]|0;p=(f[c+4>>2]|0)-m>>2;if(p>>>0<=q>>>0)um(c);o=m;m=f[o+(q<<2)>>2]|0;if(p>>>0<=r>>>0)um(c);c=f[o+(r<<2)>>2]|0;r=(m|0)<(e|0);do if(r&(c|0)<(e|0)){o=m<<1;p=f[d+(o<<2)>>2]|0;q=((p|0)<0)<<31>>31;n=f[d+((o|1)<<2)>>2]|0;o=((n|0)<0)<<31>>31;s=c<<1;t=f[d+(s<<2)>>2]|0;v=f[d+((s|1)<<2)>>2]|0;if(!((t|0)!=(p|0)|(v|0)!=(n|0))){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(G|0,s|0,N|0,L|0)|0;s=I;switch(E|0){case 0:{if(!s){W=0;X=0}else{Y=1;Z=0;_=E;$=s;aa=23}break}case 1:{if(!s){ba=1;ca=0;aa=24}else{Y=1;Z=0;_=E;$=s;aa=23}break}default:{Y=1;Z=0;_=E;$=s;aa=23}}if((aa|0)==23)while(1){aa=0;G=Oj(Y|0,Z|0,1)|0;C=I;p=_;_=Uj(_|0,$|0,2)|0;if(!($>>>0>0|($|0)==0&p>>>0>7)){ba=G;ca=C;aa=24;break}else{Y=G;Z=C;$=I;aa=23}}if((aa|0)==24)while(1){aa=0;C=Fl(E|0,s|0,ba|0,ca|0)|0;G=Rj(C|0,I|0,ba|0,ca|0)|0;C=Uj(G|0,I|0,1)|0;G=I;p=gj(C|0,G|0,C|0,G|0)|0;D=I;if(D>>>0>s>>>0|(D|0)==(s|0)&p>>>0>E>>>0){ba=C;ca=G;aa=24}else{W=C;X=G;break}}E=gj(W|0,X|0,Q|0,v|0)|0;s=I;G=gj(W|0,X|0,w|0,t|0)|0;C=I;p=a+20|0;D=(f[p>>2]|0)+-1|0;H=(1<<(D&31)&f[(f[a+16>>2]|0)+(D>>>5<<2)>>2]|0)!=0;f[p>>2]=D;D=Tj(0,0,E|0,s|0)|0;p=Rj(V|0,q|0,(H?E:D)|0,(H?s:I)|0)|0;s=I;D=Tj(0,0,G|0,C|0)|0;E=Rj(R|0,o|0,(H?G:D)|0,(H?C:I)|0)|0;C=I;H=Ug(p|0,s|0,N|0,L|0)|0;s=Ug(E|0,C|0,N|0,L|0)|0;f[a+8>>2]=H;f[a+12>>2]=s;u=g;return}while(0);do if(r)da=m<<1;else{if((e|0)>0){da=(e<<1)+-2|0;break}X=a+8|0;f[X>>2]=0;f[X+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+(da<<2)>>2];f[a+12>>2]=f[d+(da+1<<2)>>2];u=g;return}function tb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0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e);t=f[g>>2]|0}else{f[j>>2]=f[e>>2];f[l>>2]=j+4;t=s}s=t+24|0;f[(f[t+12>>2]|0)+(p<<2)>>2]=f[s>>2];f[s>>2]=(f[s>>2]|0)+1;v=f[q>>2]|0}else v=r;r=v+(m>>>5<<2)|0;v=1<<(m&31);s=f[r>>2]|0;if(!(s&v)){f[r>>2]=s|v;v=f[b>>2]|0;do if((v|0)!=-1)if(!((v>>>0)%3|0)){w=v+2|0;break}else{w=v+-1|0;break}else w=-1;while(0);f[e>>2]=w;v=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((w>>>0)/3|0)*12|0)+(((w>>>0)%3|0)<<2)>>2]|0;w=f[a+48>>2]|0;f[d>>2]=v;s=f[w+4>>2]|0;w=s+4|0;r=f[w>>2]|0;if((r|0)==(f[s+8>>2]|0))xf(s,d);else{f[r>>2]=v;f[w>>2]=r+4}r=a+40|0;w=f[r>>2]|0;v=w+4|0;s=f[v>>2]|0;if((s|0)==(f[w+8>>2]|0)){xf(w,e);x=f[r>>2]|0}else{f[s>>2]=f[e>>2];f[v>>2]=s+4;x=w}w=x+24|0;f[(f[x+12>>2]|0)+(m<<2)>>2]=f[w>>2];f[w>>2]=(f[w>>2]|0)+1}w=f[h>>2]|0;m=f[k>>2]|0;if((w|0)==(m|0)){u=c;return}x=a+44|0;s=a+48|0;v=a+40|0;r=m;m=w;while(1){w=f[r+-4>>2]|0;f[b>>2]=w;p=(w>>>0)/3|0;if((w|0)!=-1?(w=f[i>>2]|0,(f[w+(p>>>5<<2)>>2]&1<<(p&31)|0)==0):0){t=p;p=w;w=f[a>>2]|0;a:while(1){j=p+(t>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(t&31);j=f[b>>2]|0;l=f[(f[w+28>>2]|0)+(j<<2)>>2]|0;g=(f[q>>2]|0)+(l>>>5<<2)|0;o=1<<(l&31);y=f[g>>2]|0;if(!(o&y)){z=f[(f[w+40>>2]|0)+(l<<2)>>2]|0;if((z|0)==-1)A=1;else{B=f[(f[f[w+64>>2]>>2]|0)+(z<<2)>>2]|0;A=(1<<(B&31)&f[(f[w+12>>2]|0)+(B>>>5<<2)>>2]|0)!=0}f[g>>2]=y|o;o=f[b>>2]|0;f[e>>2]=o;y=f[(f[(f[x>>2]|0)+96>>2]|0)+(((o>>>0)/3|0)*12|0)+(((o>>>0)%3|0)<<2)>>2]|0;o=f[s>>2]|0;f[d>>2]=y;g=f[o+4>>2]|0;o=g+4|0;B=f[o>>2]|0;if((B|0)==(f[g+8>>2]|0))xf(g,d);else{f[B>>2]=y;f[o>>2]=B+4}B=f[v>>2]|0;o=B+4|0;y=f[o>>2]|0;if((y|0)==(f[B+8>>2]|0)){xf(B,e);C=f[v>>2]|0}else{f[y>>2]=f[e>>2];f[o>>2]=y+4;C=B}B=C+24|0;f[(f[C+12>>2]|0)+(l<<2)>>2]=f[B>>2];f[B>>2]=(f[B>>2]|0)+1;B=f[a>>2]|0;l=f[b>>2]|0;if(A){D=l;E=B;F=57}else{y=l+1|0;do if((l|0)==-1)G=-1;else{o=((y>>>0)%3|0|0)==0?l+-2|0:y;if((o|0)==-1){G=-1;break}if(f[(f[B>>2]|0)+(o>>>5<<2)>>2]&1<<(o&31)|0){G=-1;break}G=f[(f[(f[B+64>>2]|0)+12>>2]|0)+(o<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0;I=B}}else{D=j;E=w;F=57}if((F|0)==57){F=0;y=D+1|0;if((D|0)==-1){F=58;break}l=((y>>>0)%3|0|0)==0?D+-2|0:y;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)J=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else J=-1;f[d>>2]=J;l=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)K=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else K=-1;l=(J|0)==-1;y=(J>>>0)/3|0;o=l?-1:y;g=(K|0)==-1;z=(K>>>0)/3|0;L=g?-1:z;do if(!l){M=f[i>>2]|0;if(f[M+(o>>>5<<2)>>2]&1<<(o&31)|0){F=67;break}if(g){N=J;O=y;break}if(!(f[M+(L>>>5<<2)>>2]&1<<(L&31))){F=72;break a}else{N=J;O=y}}else F=67;while(0);if((F|0)==67){F=0;if(g){F=69;break}if(!(f[(f[i>>2]|0)+(L>>>5<<2)>>2]&1<<(L&31))){N=K;O=z}else{F=69;break}}f[b>>2]=N;H=O;I=E}t=H;p=f[i>>2]|0;w=I}do if((F|0)==58){F=0;f[d>>2]=-1;F=69}else if((F|0)==72){F=0;w=f[k>>2]|0;f[w+-4>>2]=K;if((w|0)==(f[n>>2]|0)){xf(h,d);P=f[k>>2]|0;break}else{f[w>>2]=f[d>>2];p=w+4|0;f[k>>2]=p;P=p;break}}while(0);if((F|0)==69){F=0;p=(f[k>>2]|0)+-4|0;f[k>>2]=p;P=p}Q=f[h>>2]|0;R=P}else{p=r+-4|0;f[k>>2]=p;Q=m;R=p}if((Q|0)==(R|0))break;else{r=R;m=Q}}u=c;return}function ub(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0;g=u;u=u+80|0;h=g+76|0;i=g+72|0;j=g+48|0;k=g+24|0;l=g;m=a+32|0;n=f[c>>2]|0;c=n+1|0;do if((n|0)!=-1){o=((c>>>0)%3|0|0)==0?n+-2|0:c;if(!((n>>>0)%3|0)){p=n+2|0;q=o;break}else{p=n+-1|0;q=o;break}}else{p=-1;q=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>2]|0)+(t<<2)>>2]|0;else v=t;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;f[j+16>>2]=0;f[j+20>>2]=0;f[h>>2]=v;v=b[s+24>>0]|0;f[g>>2]=f[h>>2];jb(s,g,v,j)|0;v=a+28|0;a=(f[v>>2]|0)==0;a:do if(!p){s=k+8|0;t=j+8|0;w=k+16|0;x=j+16|0;y=l+8|0;z=l+16|0;A=o;B=o;C=0;D=0;E=0;F=0;G=0;H=0;J=a;K=o;while(1){do if(J){L=K+1|0;if((K|0)==-1){M=A;N=-1;O=-1;P=-1;break}Q=((L>>>0)%3|0|0)==0?K+-2|0:L;if((A|0)!=-1)if(!((A>>>0)%3|0)){R=A;S=A+2|0;T=Q;U=A;V=19;break}else{R=A;S=A+-1|0;T=Q;U=A;V=19;break}else{R=-1;S=-1;T=Q;U=-1;V=19}}else{Q=B+1|0;L=((Q>>>0)%3|0|0)==0?B+-2|0:Q;if(!((B>>>0)%3|0)){R=A;S=B+2|0;T=L;U=K;V=19;break}else{R=A;S=B+-1|0;T=L;U=K;V=19;break}}while(0);if((V|0)==19){V=0;if((T|0)==-1){M=R;N=-1;O=S;P=U}else{M=R;N=f[(f[f[m>>2]>>2]|0)+(T<<2)>>2]|0;O=S;P=U}}W=f[n>>2]|0;L=f[W>>2]|0;if((f[W+4>>2]|0)-L>>2>>>0<=N>>>0){V=22;break}Q=f[(f[r>>2]|0)+(f[L+(N<<2)>>2]<<2)>>2]|0;L=f[q>>2]|0;if(!(b[L+84>>0]|0))X=f[(f[L+68>>2]|0)+(Q<<2)>>2]|0;else X=Q;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[h>>2]=X;Q=b[L+24>>0]|0;f[g>>2]=f[h>>2];jb(L,g,Q,k)|0;if((O|0)==-1)Y=-1;else Y=f[(f[f[m>>2]>>2]|0)+(O<<2)>>2]|0;Z=f[n>>2]|0;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va;ya=d+4|0;f[ya>>2]=wa;za=d+8|0;f[za>>2]=xa;u=e;return}}function wb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))xf(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;if((g|0)!=-1){l=((j>>>0)%3|0|0)==0?g+-2|0:j;if((l|0)==-1)o=-1;else o=f[(f[m>>2]|0)+(l<<2)>>2]|0;l=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((l|0)==-1){p=o;q=-1}else{p=o;q=f[(f[m>>2]|0)+(l<<2)>>2]|0}}else{p=-1;q=-1}l=a+24|0;m=f[l>>2]|0;o=m+(p>>>5<<2)|0;g=1<<(p&31);j=f[o>>2]|0;if(!(j&g)){f[o>>2]=j|g;g=f[b>>2]|0;j=g+1|0;if((g|0)==-1)r=-1;else r=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=r;j=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((r>>>0)/3|0)*12|0)+(((r>>>0)%3|0)<<2)>>2]|0;r=f[a+48>>2]|0;f[d>>2]=j;g=f[r+4>>2]|0;r=g+4|0;o=f[r>>2]|0;if((o|0)==(f[g+8>>2]|0))xf(g,d);else{f[o>>2]=j;f[r>>2]=o+4}o=a+40|0;r=f[o>>2]|0;j=r+4|0;g=f[j>>2]|0;if((g|0)==(f[r+8>>2]|0)){xf(r,e);s=f[o>>2]|0}else{f[g>>2]=f[e>>2];f[j>>2]=g+4;s=r}r=s+24|0;f[(f[s+12>>2]|0)+(p<<2)>>2]=f[r>>2];f[r>>2]=(f[r>>2]|0)+1;t=f[l>>2]|0}else t=m;m=t+(q>>>5<<2)|0;t=1<<(q&31);r=f[m>>2]|0;if(!(r&t)){f[m>>2]=r|t;t=f[b>>2]|0;do if((t|0)!=-1)if(!((t>>>0)%3|0)){v=t+2|0;break}else{v=t+-1|0;break}else v=-1;while(0);f[e>>2]=v;t=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((v>>>0)/3|0)*12|0)+(((v>>>0)%3|0)<<2)>>2]|0;v=f[a+48>>2]|0;f[d>>2]=t;r=f[v+4>>2]|0;v=r+4|0;m=f[v>>2]|0;if((m|0)==(f[r+8>>2]|0))xf(r,d);else{f[m>>2]=t;f[v>>2]=m+4}m=a+40|0;v=f[m>>2]|0;t=v+4|0;r=f[t>>2]|0;if((r|0)==(f[v+8>>2]|0)){xf(v,e);w=f[m>>2]|0}else{f[r>>2]=f[e>>2];f[t>>2]=r+4;w=v}v=w+24|0;f[(f[w+12>>2]|0)+(q<<2)>>2]=f[v>>2];f[v>>2]=(f[v>>2]|0)+1}v=f[h>>2]|0;q=f[k>>2]|0;if((v|0)==(q|0)){u=c;return}w=a+44|0;r=a+48|0;t=a+40|0;m=q;q=v;while(1){v=f[m+-4>>2]|0;f[b>>2]=v;p=(v>>>0)/3|0;if((v|0)!=-1?(v=f[i>>2]|0,(f[v+(p>>>5<<2)>>2]&1<<(p&31)|0)==0):0){s=p;p=v;a:while(1){v=p+(s>>>5<<2)|0;f[v>>2]=f[v>>2]|1<<(s&31);v=f[b>>2]|0;if((v|0)==-1)x=-1;else x=f[(f[f[a>>2]>>2]|0)+(v<<2)>>2]|0;g=(f[l>>2]|0)+(x>>>5<<2)|0;j=1<<(x&31);o=f[g>>2]|0;do if(!(j&o)){y=f[a>>2]|0;z=f[(f[y+24>>2]|0)+(x<<2)>>2]|0;A=z+1|0;if(((z|0)!=-1?(B=((A>>>0)%3|0|0)==0?z+-2|0:A,(B|0)!=-1):0)?(A=f[(f[y+12>>2]|0)+(B<<2)>>2]|0,B=A+1|0,(A|0)!=-1):0)C=((((B>>>0)%3|0|0)==0?A+-2|0:B)|0)==-1;else C=1;f[g>>2]=o|j;B=f[b>>2]|0;f[e>>2]=B;A=f[(f[(f[w>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=A;y=f[B+4>>2]|0;B=y+4|0;z=f[B>>2]|0;if((z|0)==(f[y+8>>2]|0))xf(y,d);else{f[z>>2]=A;f[B>>2]=z+4}z=f[t>>2]|0;B=z+4|0;A=f[B>>2]|0;if((A|0)==(f[z+8>>2]|0)){xf(z,e);D=f[t>>2]|0}else{f[A>>2]=f[e>>2];f[B>>2]=A+4;D=z}z=D+24|0;f[(f[D+12>>2]|0)+(x<<2)>>2]=f[z>>2];f[z>>2]=(f[z>>2]|0)+1;if(C){E=f[b>>2]|0;F=60;break}z=f[a>>2]|0;A=f[b>>2]|0;do if((A|0)==-1)G=-1;else{B=A+1|0;y=((B>>>0)%3|0|0)==0?A+-2|0:B;if((y|0)==-1){G=-1;break}G=f[(f[z+12>>2]|0)+(y<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0}else{E=v;F=60}while(0);if((F|0)==60){F=0;v=f[a>>2]|0;if((E|0)==-1){F=61;break}j=E+1|0;o=((j>>>0)%3|0|0)==0?E+-2|0:j;if((o|0)==-1)I=-1;else I=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;f[d>>2]=I;o=(((E>>>0)%3|0|0)==0?2:-1)+E|0;if((o|0)==-1)J=-1;else J=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;o=(I|0)==-1;v=(I>>>0)/3|0;j=o?-1:v;g=(J|0)==-1;z=(J>>>0)/3|0;A=g?-1:z;do if(!o){y=f[i>>2]|0;if(f[y+(j>>>5<<2)>>2]&1<<(j&31)|0){F=68;break}if(g){K=I;L=v;break}if(!(f[y+(A>>>5<<2)>>2]&1<<(A&31))){F=73;break a}else{K=I;L=v}}else F=68;while(0);if((F|0)==68){F=0;if(g){F=70;break}if(!(f[(f[i>>2]|0)+(A>>>5<<2)>>2]&1<<(A&31))){K=J;L=z}else{F=70;break}}f[b>>2]=K;H=L}s=H;p=f[i>>2]|0}do if((F|0)==61){F=0;f[d>>2]=-1;F=70}else if((F|0)==73){F=0;p=f[k>>2]|0;f[p+-4>>2]=J;if((p|0)==(f[n>>2]|0)){xf(h,d);M=f[k>>2]|0;break}else{f[p>>2]=f[d>>2];s=p+4|0;f[k>>2]=s;M=s;break}}while(0);if((F|0)==70){F=0;s=(f[k>>2]|0)+-4|0;f[k>>2]=s;M=s}N=f[h>>2]|0;O=M}else{s=m+-4|0;f[k>>2]=s;N=q;O=s}if((N|0)==(O|0))break;else{m=O;q=N}}u=c;return}function xb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=La,K=La,L=La,M=0,N=0,O=0,P=0;e=u;u=u+64|0;g=e+40|0;i=e+16|0;j=e;k=cc(a,c)|0;if(k|0){f[i>>2]=k;f[g>>2]=f[i>>2];dd(a,g)|0}f[j>>2]=0;k=j+4|0;f[k>>2]=0;f[j+8>>2]=0;l=f[d>>2]|0;m=(f[d+4>>2]|0)-l|0;if(!m){o=0;p=l}else{jf(j,m);o=f[j>>2]|0;p=f[d>>2]|0}ge(o|0,p|0,m|0)|0;Rf(i,c);c=i+12|0;f[c>>2]=0;m=i+16|0;f[m>>2]=0;f[i+20>>2]=0;p=f[k>>2]|0;o=f[j>>2]|0;d=p-o|0;if(!d){q=o;r=p;s=0}else{jf(c,d);q=f[j>>2]|0;r=f[k>>2]|0;s=f[c>>2]|0}ge(s|0,q|0,r-q|0)|0;q=i+11|0;r=b[q>>0]|0;s=r<<24>>24<0;c=s?f[i>>2]|0:i;d=s?f[i+4>>2]|0:r&255;if(d>>>0>3){r=c;s=d;p=d;while(1){o=X(h[r>>0]|h[r+1>>0]<<8|h[r+2>>0]<<16|h[r+3>>0]<<24,1540483477)|0;s=(X(o>>>24^o,1540483477)|0)^(X(s,1540483477)|0);p=p+-4|0;if(p>>>0<=3)break;else r=r+4|0}r=d+-4|0;p=r&-4;t=r-p|0;v=c+(p+4)|0;w=s}else{t=d;v=c;w=d}switch(t|0){case 3:{x=h[v+2>>0]<<16^w;y=12;break}case 2:{x=w;y=12;break}case 1:{z=w;y=13;break}default:A=w}if((y|0)==12){z=h[v+1>>0]<<8^x;y=13}if((y|0)==13)A=X(z^h[v>>0],1540483477)|0;v=X(A>>>13^A,1540483477)|0;A=v>>>15^v;v=a+4|0;z=f[v>>2]|0;x=(z|0)==0;a:do if(!x){w=z+-1|0;t=(w&z|0)==0;if(!t)if(A>>>0>>0)B=A;else B=(A>>>0)%(z>>>0)|0;else B=A&w;s=f[(f[a>>2]|0)+(B<<2)>>2]|0;if((s|0)!=0?(p=f[s>>2]|0,(p|0)!=0):0){s=(d|0)==0;if(t){if(s){t=p;while(1){r=f[t+4>>2]|0;if(!((r|0)==(A|0)|(r&w|0)==(B|0))){C=B;y=54;break a}r=b[t+8+11>>0]|0;if(!((r<<24>>24<0?f[t+12>>2]|0:r&255)|0))break a;t=f[t>>2]|0;if(!t){C=B;y=54;break a}}}else D=p;while(1){t=f[D+4>>2]|0;if(!((t|0)==(A|0)|(t&w|0)==(B|0))){C=B;y=54;break a}t=D+8|0;r=b[t+11>>0]|0;o=r<<24>>24<0;l=r&255;do if(((o?f[D+12>>2]|0:l)|0)==(d|0)){r=f[t>>2]|0;if(o)if(!(jh(r,c,d)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=t;E=l;F=c;do{E=E+-1|0;r=r+1|0;if(!E)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);D=f[D>>2]|0;if(!D){C=B;y=54;break a}}}if(s){w=p;while(1){l=f[w+4>>2]|0;if((l|0)!=(A|0)){if(l>>>0>>0)G=l;else G=(l>>>0)%(z>>>0)|0;if((G|0)!=(B|0)){C=B;y=54;break a}}l=b[w+8+11>>0]|0;if(!((l<<24>>24<0?f[w+12>>2]|0:l&255)|0))break a;w=f[w>>2]|0;if(!w){C=B;y=54;break a}}}else H=p;while(1){w=f[H+4>>2]|0;if((w|0)!=(A|0)){if(w>>>0>>0)I=w;else I=(w>>>0)%(z>>>0)|0;if((I|0)!=(B|0)){C=B;y=54;break a}}w=H+8|0;s=b[w+11>>0]|0;l=s<<24>>24<0;t=s&255;do if(((l?f[H+12>>2]|0:t)|0)==(d|0)){s=f[w>>2]|0;if(l)if(!(jh(s,c,d)|0))break a;else break;if((b[c>>0]|0)==(s&255)<<24>>24){s=w;o=t;F=c;do{o=o+-1|0;s=s+1|0;if(!o)break a;F=F+1|0}while((b[s>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){C=B;y=54;break}}}else{C=B;y=54}}else{C=0;y=54}while(0);if((y|0)==54){Ue(g,a,A,i);y=a+12|0;J=$(((f[y>>2]|0)+1|0)>>>0);K=$(z>>>0);L=$(n[a+16>>2]);do if(x|$(L*K)>>0<3|(z+-1&z|0)!=0)&1;H=~~$(W($(J/L)))>>>0;Oe(a,B>>>0>>0?H:B);B=f[v>>2]|0;H=B+-1|0;if(!(H&B)){M=B;N=H&A;break}if(A>>>0>>0){M=B;N=A}else{M=B;N=(A>>>0)%(B>>>0)|0}}else{M=z;N=C}while(0);C=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!C){z=a+8|0;f[f[g>>2]>>2]=f[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>>2]|0;if(!(b[r+84>>0]|0))t=f[(f[r+68>>2]|0)+(s<<2)>>2]|0;else t=s;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;f[j+16>>2]=0;f[j+20>>2]=0;f[h>>2]=t;t=b[r+24>>0]|0;f[g>>2]=f[h>>2];jb(r,g,t,j)|0;t=a+28|0;a=(f[t>>2]|0)==0;a:do if((o|0)!=-1){r=k+8|0;s=j+8|0;v=k+16|0;w=j+16|0;x=l+8|0;y=l+16|0;z=o;A=o;B=0;C=0;D=0;E=0;F=0;G=0;H=a;J=o;while(1){do if(H){K=J+1|0;if((J|0)!=-1){L=((K>>>0)%3|0|0)==0?J+-2|0:K;if((z|0)!=-1)if(!((z>>>0)%3|0)){M=z;N=z+2|0;O=L;P=z;break}else{M=z;N=z+-1|0;O=L;P=z;break}else{M=-1;N=-1;O=L;P=-1}}else{M=z;N=-1;O=-1;P=-1}}else{L=A+1|0;K=((L>>>0)%3|0|0)==0?A+-2|0:L;if(!((A>>>0)%3|0)){M=z;N=A+2|0;O=K;P=J;break}else{M=z;N=A+-1|0;O=K;P=J;break}}while(0);K=f[(f[(f[m>>2]|0)+28>>2]|0)+(O<<2)>>2]|0;Q=f[n>>2]|0;L=f[Q>>2]|0;if((f[Q+4>>2]|0)-L>>2>>>0<=K>>>0){R=17;break}S=f[(f[q>>2]|0)+(f[L+(K<<2)>>2]<<2)>>2]|0;K=f[p>>2]|0;if(!(b[K+84>>0]|0))T=f[(f[K+68>>2]|0)+(S<<2)>>2]|0;else T=S;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[h>>2]=T;S=b[K+24>>0]|0;f[g>>2]=f[h>>2];jb(K,g,S,k)|0;S=f[(f[(f[m>>2]|0)+28>>2]|0)+(N<<2)>>2]|0;U=f[n>>2]|0;K=f[U>>2]|0;if((f[U+4>>2]|0)-K>>2>>>0<=S>>>0){R=21;break}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==-1){ia=K;ja=Z;ka=ga;la=ca;ma=$;na=L;oa=X;break a}else{z=M;B=ga;C=Z;D=$;E=ca;F=X;G=L;H=K;J=P}}if((R|0)==17)um(Q);else if((R|0)==21)um(U)}else{ia=a;ja=0;ka=0;la=0;ma=0;na=0;oa=0}while(0);a=(ja|0)>-1|(ja|0)==-1&ka>>>0>4294967295;U=Tj(0,0,ka|0,ja|0)|0;R=a?ja:I;Q=(la|0)>-1|(la|0)==-1&ma>>>0>4294967295;P=Tj(0,0,ma|0,la|0)|0;M=Q?la:I;t=(na|0)>-1|(na|0)==-1&oa>>>0>4294967295;c=Tj(0,0,oa|0,na|0)|0;i=Rj((Q?ma:P)|0,M|0,(t?oa:c)|0,(t?na:I)|0)|0;t=Rj(i|0,I|0,(a?ka:U)|0,R|0)|0;R=I;if(ia){if((t|0)<=536870912){pa=ka;qa=ma;ra=oa;f[d>>2]=pa;sa=d+4|0;f[sa>>2]=qa;ta=d+8|0;f[ta>>2]=ra;u=e;return}ia=Uj(t|0,R|0,29)|0;U=ia&7;ia=Ug(ka|0,ja|0,U|0,0)|0;a=Ug(ma|0,la|0,U|0,0)|0;i=Ug(oa|0,na|0,U|0,0)|0;pa=ia;qa=a;ra=i;f[d>>2]=pa;sa=d+4|0;f[sa>>2]=qa;ta=d+8|0;f[ta>>2]=ra;u=e;return}else{if(!((R|0)>0|(R|0)==0&t>>>0>536870912)){pa=ka;qa=ma;ra=oa;f[d>>2]=pa;sa=d+4|0;f[sa>>2]=qa;ta=d+8|0;f[ta>>2]=ra;u=e;return}i=Uj(t|0,R|0,29)|0;R=I;t=Ug(ka|0,ja|0,i|0,R|0)|0;ja=Ug(ma|0,la|0,i|0,R|0)|0;la=Ug(oa|0,na|0,i|0,R|0)|0;pa=t;qa=ja;ra=la;f[d>>2]=pa;sa=d+4|0;f[sa>>2]=qa;ta=d+8|0;f[ta>>2]=ra;u=e;return}}function zb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0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]=0;w=e+4|0;f[w>>2]=0;f[e+8>>2]=0;if(!v){H=0;I=0}else{if(v>>>0>536870911)um(e);t=bj(y<<1)|0;f[w>>2]=t;f[e>>2]=t;y=t+(v<<3)|0;f[e+8>>2]=y;z=v;v=t;k=t;while(1){s=v;f[s>>2]=-1;f[s+4>>2]=-1;s=k+8|0;A=z+-1|0;if(!A)break;else{z=A;v=s;k=s}}f[w>>2]=y;H=t;I=t}t=f[q>>2]|0;y=f[d>>2]|0;k=t-y|0;v=k>>2;f[g>>2]=0;z=g+4|0;f[z>>2]=0;f[g+8>>2]=0;s=y;do if(v)if(v>>>0>1073741823)um(g);else{A=bj(k)|0;f[g>>2]=A;p=A+(v<<2)|0;f[g+8>>2]=p;Vf(A|0,0,k|0)|0;f[z>>2]=p;J=A;K=p;L=A;break}else{J=0;K=0;L=0}while(0);if((t|0)!=(y|0)){y=0;t=0;while(1){f[J+(t<<2)>>2]=y;k=t+1|0;if(k>>>0>>0){y=(f[s+(t<<2)>>2]|0)+y|0;t=k}else break}}t=f[j>>2]|0;j=f[a>>2]|0;y=j;if((t|0)!=(j|0)){k=a+40|0;a=t-j>>2;j=H;t=H;g=H;A=H;p=H;x=H;l=0;o=J;while(1){F=f[y+(l<<2)>>2]|0;G=l+1|0;E=((G>>>0)%3|0|0)==0?l+-2|0:G;if((E|0)==-1)M=-1;else M=f[y+(E<<2)>>2]|0;E=((l>>>0)%3|0|0)==0;G=(E?2:-1)+l|0;if((G|0)==-1)N=-1;else N=f[y+(G<<2)>>2]|0;if(E?(M|0)==(N|0)|((F|0)==(M|0)|(F|0)==(N|0)):0){f[k>>2]=(f[k>>2]|0)+1;O=j;P=t;Q=g;R=A;S=p;T=x;U=l+2|0;V=o}else W=51;a:do if((W|0)==51){W=0;E=f[s+(N<<2)>>2]|0;b:do if((E|0)>0){G=0;B=f[o+(N<<2)>>2]|0;while(1){m=f[p+(B<<3)>>2]|0;if((m|0)==-1){X=j;Y=t;Z=A;_=p;break b}if((m|0)==(M|0)){m=f[p+(B<<3)+4>>2]|0;if((m|0)==-1)$=-1;else $=f[y+(m<<2)>>2]|0;if((F|0)!=($|0))break}m=G+1|0;if((m|0)<(E|0)){G=m;B=B+1|0}else{X=j;Y=t;Z=A;_=p;break b}}m=f[A+(B<<3)+4>>2]|0;r=G;n=B;D=t;while(1){r=r+1|0;if((r|0)>=(E|0))break;C=n+1|0;f[D+(n<<3)>>2]=f[D+(C<<3)>>2];f[D+(n<<3)+4>>2]=f[D+(C<<3)+4>>2];if((f[j+(n<<3)>>2]|0)==-1)break;else{n=C;D=j}}f[g+(n<<3)>>2]=-1;if((m|0)==-1){X=g;Y=g;Z=g;_=g}else{D=f[i>>2]|0;f[D+(l<<2)>>2]=m;f[D+(m<<2)>>2]=l;O=g;P=g;Q=g;R=g;S=g;T=x;U=l;V=o;break a}}else{X=j;Y=t;Z=A;_=p}while(0);E=f[s+(M<<2)>>2]|0;if((E|0)>0){D=0;r=f[J+(M<<2)>>2]|0;while(1){aa=x+(r<<3)|0;if((f[aa>>2]|0)==-1)break;D=D+1|0;if((D|0)>=(E|0)){O=x;P=x;Q=x;R=x;S=x;T=x;U=l;V=J;break a}else r=r+1|0}f[aa>>2]=N;f[H+(r<<3)+4>>2]=l;O=H;P=H;Q=H;R=H;S=H;T=H;U=l;V=J}else{O=X;P=Y;Q=g;R=Z;S=_;T=x;U=l;V=o}}while(0);l=U+1|0;if(l>>>0>=a>>>0)break;else{j=O;t=P;g=Q;A=R;p=S;x=T;o=V}}}f[b>>2]=v;if(!J){ba=H;ca=I}else{if((K|0)!=(J|0))f[z>>2]=K+(~((K+-4-J|0)>>>2)<<2);dn(L);L=f[e>>2]|0;ba=L;ca=L}if(ba|0){L=f[w>>2]|0;if((L|0)!=(ba|0))f[w>>2]=L+(~((L+-8-ba|0)>>>3)<<3);dn(ca)}ca=f[d>>2]|0;if(ca|0){d=f[q>>2]|0;if((d|0)!=(ca|0))f[q>>2]=d+(~((d+-4-ca|0)>>>2)<<2);dn(ca)}h=1;u=c;return h|0}function Ab(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0;e=a+8|0;g=f[e>>2]|0;switch(f[g+28>>2]|0){case 2:{h=b[g+24>>0]|0;i=h<<24>>24;j=an((i|0)>-1?i:-1)|0;k=f[a+16>>2]|0;l=(f[f[k>>2]>>2]|0)+(f[k+48>>2]|0)|0;a:do if(c|0){if(h<<24>>24>0){m=0;n=0}else{ge(f[f[g+64>>2]>>2]|0,j|0,i|0)|0;if((c|0)==1)break;else{o=0;p=1}while(1){o=o+i|0;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+o|0,j|0,i|0)|0;p=p+1|0;if((p|0)==(c|0))break a}}while(1){k=0;q=n;while(1){b[j+k>>0]=f[l+(q<<2)>>2];k=k+1|0;if((k|0)==(i|0))break;else q=q+1|0}ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+n|0,j|0,i|0)|0;m=m+1|0;if((m|0)==(c|0))break;else n=n+i|0}}while(0);bn(j);r=1;return r|0}case 1:{j=b[g+24>>0]|0;i=j<<24>>24;n=an((i|0)>-1?i:-1)|0;m=f[a+16>>2]|0;l=(f[f[m>>2]>>2]|0)+(f[m+48>>2]|0)|0;b:do if(c|0){if(j<<24>>24>0){s=0;t=0}else{ge(f[f[g+64>>2]>>2]|0,n|0,i|0)|0;if((c|0)==1)break;else{u=0;v=1}while(1){u=u+i|0;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+u|0,n|0,i|0)|0;v=v+1|0;if((v|0)==(c|0))break b}}while(1){m=0;p=t;while(1){b[n+m>>0]=f[l+(p<<2)>>2];m=m+1|0;if((m|0)==(i|0))break;else p=p+1|0}ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+t|0,n|0,i|0)|0;s=s+1|0;if((s|0)==(c|0))break;else t=t+i|0}}while(0);bn(n);r=1;return r|0}case 4:{n=b[g+24>>0]|0;i=n<<24>>24;t=i<<1;s=an(i>>>0>2147483647?-1:i<<1)|0;l=f[a+16>>2]|0;v=(f[f[l>>2]>>2]|0)+(f[l+48>>2]|0)|0;c:do if(c|0){if(n<<24>>24>0){w=0;x=0;y=0}else{ge(f[f[g+64>>2]>>2]|0,s|0,t|0)|0;if((c|0)==1)break;else{z=0;A=1}while(1){z=z+t|0;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+z|0,s|0,t|0)|0;A=A+1|0;if((A|0)==(c|0))break c}}while(1){l=0;u=y;while(1){d[s+(l<<1)>>1]=f[v+(u<<2)>>2];l=l+1|0;if((l|0)==(i|0))break;else u=u+1|0}ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+x|0,s|0,t|0)|0;w=w+1|0;if((w|0)==(c|0))break;else{x=x+t|0;y=y+i|0}}}while(0);bn(s);r=1;return r|0}case 3:{s=b[g+24>>0]|0;i=s<<24>>24;y=i<<1;t=an(i>>>0>2147483647?-1:i<<1)|0;x=f[a+16>>2]|0;w=(f[f[x>>2]>>2]|0)+(f[x+48>>2]|0)|0;d:do if(c|0){if(s<<24>>24>0){B=0;C=0;D=0}else{ge(f[f[g+64>>2]>>2]|0,t|0,y|0)|0;if((c|0)==1)break;else{E=0;F=1}while(1){E=E+y|0;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+E|0,t|0,y|0)|0;F=F+1|0;if((F|0)==(c|0))break d}}while(1){x=0;v=D;while(1){d[t+(x<<1)>>1]=f[w+(v<<2)>>2];x=x+1|0;if((x|0)==(i|0))break;else v=v+1|0}ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+C|0,t|0,y|0)|0;B=B+1|0;if((B|0)==(c|0))break;else{C=C+y|0;D=D+i|0}}}while(0);bn(t);r=1;return r|0}case 6:{t=b[g+24>>0]|0;i=t<<24>>24;D=i<<2;y=an(i>>>0>1073741823?-1:i<<2)|0;C=f[a+16>>2]|0;B=(f[f[C>>2]>>2]|0)+(f[C+48>>2]|0)|0;e:do if(c|0){if(t<<24>>24>0){G=0;H=0;I=0}else{ge(f[f[g+64>>2]>>2]|0,y|0,D|0)|0;if((c|0)==1)break;else{J=0;K=1}while(1){J=J+D|0;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+J|0,y|0,D|0)|0;K=K+1|0;if((K|0)==(c|0))break e}}while(1){C=0;w=I;while(1){f[y+(C<<2)>>2]=f[B+(w<<2)>>2];C=C+1|0;if((C|0)==(i|0))break;else w=w+1|0}ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+H|0,y|0,D|0)|0;G=G+1|0;if((G|0)==(c|0))break;else{H=H+D|0;I=I+i|0}}}while(0);bn(y);r=1;return r|0}case 5:{y=b[g+24>>0]|0;i=y<<24>>24;I=i<<2;D=an(i>>>0>1073741823?-1:i<<2)|0;H=f[a+16>>2]|0;a=(f[f[H>>2]>>2]|0)+(f[H+48>>2]|0)|0;f:do if(c|0){if(y<<24>>24>0){L=0;M=0;N=0}else{ge(f[f[g+64>>2]>>2]|0,D|0,I|0)|0;if((c|0)==1)break;else{O=0;P=1}while(1){O=O+I|0;ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+O|0,D|0,I|0)|0;P=P+1|0;if((P|0)==(c|0))break f}}while(1){H=0;G=N;while(1){f[D+(H<<2)>>2]=f[a+(G<<2)>>2];H=H+1|0;if((H|0)==(i|0))break;else G=G+1|0}ge((f[f[(f[e>>2]|0)+64>>2]>>2]|0)+M|0,D|0,I|0)|0;L=L+1|0;if((L|0)==(c|0))break;else{M=M+I|0;N=N+i|0}}}while(0);bn(D);r=1;return r|0}default:{r=0;return r|0}}return 0}function Bb(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;d=u;u=u+176|0;e=d+136|0;g=d+32|0;i=d;j=d+104|0;k=d+100|0;l=a+4|0;m=f[l>>2]|0;n=f[m+32>>2]|0;o=n+8|0;p=f[o>>2]|0;q=f[o+4>>2]|0;o=n+16|0;r=o;s=f[r>>2]|0;t=f[r+4>>2]|0;if(!((q|0)>(t|0)|(q|0)==(t|0)&p>>>0>s>>>0)){v=0;u=d;return v|0}r=f[n>>2]|0;n=b[r+s>>0]|0;w=Rj(s|0,t|0,1,0)|0;x=I;y=o;f[y>>2]=w;f[y+4>>2]=x;if(!((q|0)>(x|0)|(q|0)==(x|0)&p>>>0>w>>>0)){v=0;u=d;return v|0}x=b[r+w>>0]|0;w=Rj(s|0,t|0,2,0)|0;y=I;z=o;f[z>>2]=w;f[z+4>>2]=y;do if(n<<24>>24>-1){z=n<<24>>24;A=f[a+212>>2]|0;if((((f[a+216>>2]|0)-A|0)/144|0)>>>0>z>>>0){f[A+(z*144|0)>>2]=c;break}else{v=0;u=d;return v|0}}while(0);do if((((h[m+36>>0]|0)<<8|(h[m+37>>0]|0))&65535)>257)if((q|0)>(y|0)|(q|0)==(y|0)&p>>>0>w>>>0){z=b[r+w>>0]|0;A=Rj(s|0,t|0,3,0)|0;B=o;f[B>>2]=A;f[B+4>>2]=I;C=z&255;break}else{v=0;u=d;return v|0}else C=0;while(0);o=f[m+44>>2]|0;if(!(x<<24>>24)){if(n<<24>>24<0)D=a+184|0;else{x=n<<24>>24;m=f[a+212>>2]|0;b[m+(x*144|0)+100>>0]=0;D=m+(x*144|0)+104|0}switch((C&255)<<24>>24){case 0:{mc(e,a,D);E=f[e>>2]|0;break}case 1:{_c(e,a,D);E=f[e>>2]|0;break}default:{v=0;u=d;return v|0}}if(!E){v=0;u=d;return v|0}else F=E}else{if(n<<24>>24<0|(C|0)!=0){v=0;u=d;return v|0}C=bj(88)|0;E=n<<24>>24;n=f[a+212>>2]|0;a=n+(E*144|0)+104|0;f[C+4>>2]=0;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dn(C)}f[s>>2]=2372;s=f[g+24>>2]|0;if(s|0)dn(s);s=f[g+12>>2]|0;if(s|0)dn(s);F=x}x=bj(64)|0;f[k>>2]=F;Ah(x,k);F=x;s=f[k>>2]|0;f[k>>2]=0;if(s|0)Sa[f[(f[s>>2]|0)+4>>2]&127](s);s=f[l>>2]|0;if((c|0)<0){Sa[f[(f[x>>2]|0)+4>>2]&127](x);v=0;u=d;return v|0}x=s+8|0;l=s+12|0;s=f[l>>2]|0;k=f[x>>2]|0;g=s-k>>2;do if((g|0)<=(c|0)){C=c+1|0;w=s;if(C>>>0>g>>>0){Kd(x,C-g|0);break}if(C>>>0>>0?(r=k+(C<<2)|0,(r|0)!=(w|0)):0){C=w;do{w=C+-4|0;f[l>>2]=w;i=f[w>>2]|0;f[w>>2]=0;if(i|0)Sa[f[(f[i>>2]|0)+4>>2]&127](i);C=f[l>>2]|0}while((C|0)!=(r|0))}}while(0);l=(f[x>>2]|0)+(c<<2)|0;c=f[l>>2]|0;f[l>>2]=F;if(!c){v=1;u=d;return v|0}Sa[f[(f[c>>2]|0)+4>>2]&127](c);v=1;u=d;return v|0}function Cb(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!a)return;b=a+-8|0;c=f[3224]|0;d=f[a+-4>>2]|0;a=d&-8;e=b+a|0;do if(!(d&1)){g=f[b>>2]|0;if(!(d&3))return;h=b+(0-g)|0;i=g+a|0;if(h>>>0>>0)return;if((f[3225]|0)==(h|0)){j=e+4|0;k=f[j>>2]|0;if((k&3|0)!=3){l=h;m=i;n=h;break}f[3222]=i;f[j>>2]=k&-2;f[h+4>>2]=i|1;f[h+i>>2]=i;return}k=g>>>3;if(g>>>0<256){g=f[h+8>>2]|0;j=f[h+12>>2]|0;if((j|0)==(g|0)){f[3220]=f[3220]&~(1<>2]=j;f[j+8>>2]=g;l=h;m=i;n=h;break}}g=f[h+24>>2]|0;j=f[h+12>>2]|0;do if((j|0)==(h|0)){k=h+16|0;o=k+4|0;p=f[o>>2]|0;if(!p){q=f[k>>2]|0;if(!q){r=0;break}else{s=q;t=k}}else{s=p;t=o}while(1){o=s+20|0;p=f[o>>2]|0;if(p|0){s=p;t=o;continue}o=s+16|0;p=f[o>>2]|0;if(!p)break;else{s=p;t=o}}f[t>>2]=0;r=s}else{o=f[h+8>>2]|0;f[o+12>>2]=j;f[j+8>>2]=o;r=j}while(0);if(g){j=f[h+28>>2]|0;o=13184+(j<<2)|0;if((f[o>>2]|0)==(h|0)){f[o>>2]=r;if(!r){f[3221]=f[3221]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=r;if(!r){l=h;m=i;n=h;break}}f[r+24>>2]=g;j=h+16|0;o=f[j>>2]|0;if(o|0){f[r+16>>2]=o;f[o+24>>2]=r}o=f[j+4>>2]|0;if(o){f[r+20>>2]=o;f[o+24>>2]=r;l=h;m=i;n=h}else{l=h;m=i;n=h}}else{l=h;m=i;n=h}}else{l=b;m=a;n=b}while(0);if(n>>>0>=e>>>0)return;b=e+4|0;a=f[b>>2]|0;if(!(a&1))return;if(!(a&2)){if((f[3226]|0)==(e|0)){r=(f[3223]|0)+m|0;f[3223]=r;f[3226]=l;f[l+4>>2]=r|1;if((l|0)!=(f[3225]|0))return;f[3225]=0;f[3222]=0;return}if((f[3225]|0)==(e|0)){r=(f[3222]|0)+m|0;f[3222]=r;f[3225]=n;f[l+4>>2]=r|1;f[n+r>>2]=r;return}r=(a&-8)+m|0;s=a>>>3;do if(a>>>0<256){t=f[e+8>>2]|0;c=f[e+12>>2]|0;if((c|0)==(t|0)){f[3220]=f[3220]&~(1<>2]=c;f[c+8>>2]=t;break}}else{t=f[e+24>>2]|0;c=f[e+12>>2]|0;do if((c|0)==(e|0)){d=e+16|0;o=d+4|0;j=f[o>>2]|0;if(!j){p=f[d>>2]|0;if(!p){u=0;break}else{v=p;w=d}}else{v=j;w=o}while(1){o=v+20|0;j=f[o>>2]|0;if(j|0){v=j;w=o;continue}o=v+16|0;j=f[o>>2]|0;if(!j)break;else{v=j;w=o}}f[w>>2]=0;u=v}else{o=f[e+8>>2]|0;f[o+12>>2]=c;f[c+8>>2]=o;u=c}while(0);if(t|0){c=f[e+28>>2]|0;h=13184+(c<<2)|0;if((f[h>>2]|0)==(e|0)){f[h>>2]=u;if(!u){f[3221]=f[3221]&~(1<>2]|0)!=(e|0)&1)<<2)>>2]=u;if(!u)break}f[u+24>>2]=t;c=e+16|0;h=f[c>>2]|0;if(h|0){f[u+16>>2]=h;f[h+24>>2]=u}h=f[c+4>>2]|0;if(h|0){f[u+20>>2]=h;f[h+24>>2]=u}}}while(0);f[l+4>>2]=r|1;f[n+r>>2]=r;if((l|0)==(f[3225]|0)){f[3222]=r;return}else x=r}else{f[b>>2]=a&-2;f[l+4>>2]=m|1;f[n+m>>2]=m;x=m}m=x>>>3;if(x>>>0<256){n=12920+(m<<1<<2)|0;a=f[3220]|0;b=1<>2]|0;z=b}f[z>>2]=l;f[y+12>>2]=l;f[l+8>>2]=y;f[l+12>>2]=n;return}n=x>>>8;if(n)if(x>>>0>16777215)A=31;else{y=(n+1048320|0)>>>16&8;z=n<>>16&4;b=z<>>16&2;a=14-(n|y|z)+(b<>>15)|0;A=x>>>(a+7|0)&1|a<<1}else A=0;a=13184+(A<<2)|0;f[l+28>>2]=A;f[l+20>>2]=0;f[l+16>>2]=0;z=f[3221]|0;b=1<>>1)|0);n=f[a>>2]|0;while(1){if((f[n+4>>2]&-8|0)==(x|0)){B=73;break}C=n+16+(y>>>31<<2)|0;m=f[C>>2]|0;if(!m){B=72;break}else{y=y<<1;n=m}}if((B|0)==72){f[C>>2]=l;f[l+24>>2]=n;f[l+12>>2]=l;f[l+8>>2]=l;break}else if((B|0)==73){y=n+8|0;t=f[y>>2]|0;f[t+12>>2]=l;f[y>>2]=l;f[l+8>>2]=t;f[l+12>>2]=n;f[l+24>>2]=0;break}}else{f[3221]=z|b;f[a>>2]=l;f[l+24>>2]=a;f[l+12>>2]=l;f[l+8>>2]=l}while(0);l=(f[3228]|0)+-1|0;f[3228]=l;if(!l)D=13336;else return;while(1){l=f[D>>2]|0;if(!l)break;else D=l+8|0}f[3228]=-1;return}function Db(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=La,F=La,G=La,H=0,I=0,J=0,K=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;e=i;j=i;while(1){k=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;e=(X(k>>>24^k,1540483477)|0)^(X(e,1540483477)|0);j=j+-4|0;if(j>>>0<=3)break;else d=d+4|0}d=i+-4|0;j=d&-4;l=d-j|0;m=g+(j+4)|0;o=e}else{l=i;m=g;o=i}switch(l|0){case 3:{p=h[m+2>>0]<<16^o;q=6;break}case 2:{p=o;q=6;break}case 1:{r=o;q=7;break}default:s=o}if((q|0)==6){r=h[m+1>>0]<<8^p;q=7}if((q|0)==7)s=X(r^h[m>>0],1540483477)|0;m=X(s>>>13^s,1540483477)|0;s=m>>>15^m;m=a+4|0;r=f[m>>2]|0;p=(r|0)==0;a:do if(!p){o=r+-1|0;l=(o&r|0)==0;if(!l)if(s>>>0>>0)t=s;else t=(s>>>0)%(r>>>0)|0;else t=s&o;e=f[(f[a>>2]|0)+(t<<2)>>2]|0;if((e|0)!=0?(j=f[e>>2]|0,(j|0)!=0):0){e=(i|0)==0;if(l){if(e){l=j;while(1){d=f[l+4>>2]|0;if(!((d|0)==(s|0)|(d&o|0)==(t|0))){u=t;break a}d=b[l+8+11>>0]|0;if(!((d<<24>>24<0?f[l+12>>2]|0:d&255)|0)){v=l;break}l=f[l>>2]|0;if(!l){u=t;break a}}w=v+20|0;return w|0}else x=j;b:while(1){l=f[x+4>>2]|0;if(!((l|0)==(s|0)|(l&o|0)==(t|0))){u=t;break a}l=x+8|0;d=b[l+11>>0]|0;k=d<<24>>24<0;y=d&255;do if(((k?f[x+12>>2]|0:y)|0)==(i|0)){d=f[l>>2]|0;if(k)if(!(jh(d,g,i)|0)){v=x;q=63;break b}else break;if((b[g>>0]|0)==(d&255)<<24>>24){d=l;z=y;A=g;do{z=z+-1|0;d=d+1|0;if(!z){v=x;q=63;break b}A=A+1|0}while((b[d>>0]|0)==(b[A>>0]|0))}}while(0);x=f[x>>2]|0;if(!x){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}if(e){o=j;while(1){y=f[o+4>>2]|0;if((y|0)!=(s|0)){if(y>>>0>>0)B=y;else B=(y>>>0)%(r>>>0)|0;if((B|0)!=(t|0)){u=t;break a}}y=b[o+8+11>>0]|0;if(!((y<<24>>24<0?f[o+12>>2]|0:y&255)|0)){v=o;break}o=f[o>>2]|0;if(!o){u=t;break a}}w=v+20|0;return w|0}else C=j;c:while(1){o=f[C+4>>2]|0;if((o|0)!=(s|0)){if(o>>>0>>0)D=o;else D=(o>>>0)%(r>>>0)|0;if((D|0)!=(t|0)){u=t;break a}}o=C+8|0;e=b[o+11>>0]|0;y=e<<24>>24<0;l=e&255;do if(((y?f[C+12>>2]|0:l)|0)==(i|0)){e=f[o>>2]|0;if(y)if(!(jh(e,g,i)|0)){v=C;q=63;break c}else break;if((b[g>>0]|0)==(e&255)<<24>>24){e=o;k=l;A=g;do{k=k+-1|0;e=e+1|0;if(!k){v=C;q=63;break c}A=A+1|0}while((b[e>>0]|0)==(b[A>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}else u=t}else u=0;while(0);t=bj(24)|0;Rf(t+8|0,c);f[t+20>>2]=0;f[t+4>>2]=s;f[t>>2]=0;c=a+12|0;E=$(((f[c>>2]|0)+1|0)>>>0);F=$(r>>>0);G=$(n[a+16>>2]);do if(p|$(G*F)>>0<3|(r+-1&r|0)!=0)&1;g=~~$(W($(E/G)))>>>0;Oe(a,C>>>0>>0?g:C);C=f[m>>2]|0;g=C+-1|0;if(!(g&C)){H=C;I=g&s;break}if(s>>>0>>0){H=C;I=s}else{H=C;I=(s>>>0)%(C>>>0)|0}}else{H=r;I=u}while(0);u=(f[a>>2]|0)+(I<<2)|0;I=f[u>>2]|0;if(!I){r=a+8|0;f[t>>2]=f[r>>2];f[r>>2]=t;f[u>>2]=r;r=f[t>>2]|0;if(r|0){u=f[r+4>>2]|0;r=H+-1|0;if(r&H)if(u>>>0>>0)J=u;else J=(u>>>0)%(H>>>0)|0;else J=u&r;K=(f[a>>2]|0)+(J<<2)|0;q=61}}else{f[t>>2]=f[I>>2];K=I;q=61}if((q|0)==61)f[K>>2]=t;f[c>>2]=(f[c>>2]|0)+1;v=t;w=v+20|0;return w|0}function Eb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;g=a+8|0;f[g>>2]=e;d=a+32|0;h=a+36|0;i=f[h>>2]|0;j=f[d>>2]|0;k=i-j>>2;l=j;j=i;if(k>>>0>=e>>>0)if(k>>>0>e>>>0?(i=l+(e<<2)|0,(i|0)!=(j|0)):0){f[h>>2]=j+(~((j+-4-i|0)>>>2)<<2);m=e}else m=e;else{ff(d,e-k|0);m=f[g>>2]|0}k=f[a+48>>2]|0;d=f[a+52>>2]|0;i=e>>>0>1073741823?-1:e<<2;j=an(i)|0;Vf(j|0,0,i|0)|0;if((m|0)>0){i=a+16|0;h=a+32|0;l=a+12|0;n=0;do{o=f[j+(n<<2)>>2]|0;p=f[i>>2]|0;if((o|0)>(p|0)){q=f[h>>2]|0;f[q+(n<<2)>>2]=p;r=q}else{q=f[l>>2]|0;p=f[h>>2]|0;f[p+(n<<2)>>2]=(o|0)<(q|0)?q:o;r=p}n=n+1|0;s=f[g>>2]|0}while((n|0)<(s|0));if((s|0)>0){n=a+20|0;h=0;do{p=(f[b+(h<<2)>>2]|0)+(f[r+(h<<2)>>2]|0)|0;o=c+(h<<2)|0;f[o>>2]=p;if((p|0)<=(f[i>>2]|0)){if((p|0)<(f[l>>2]|0)){t=(f[n>>2]|0)+p|0;u=18}}else{t=p-(f[n>>2]|0)|0;u=18}if((u|0)==18){u=0;f[o>>2]=t}h=h+1|0;o=f[g>>2]|0}while((h|0)<(o|0));v=o}else v=s}else v=m;m=f[a+56>>2]|0;s=f[m>>2]|0;h=(f[m+4>>2]|0)-s|0;t=h>>2;if((h|0)<=4){bn(j);return 1}h=a+16|0;n=a+32|0;l=a+12|0;i=a+20|0;a=k+12|0;r=(e|0)>0;o=s;s=1;p=v;while(1){if(t>>>0<=s>>>0){u=24;break}v=f[o+(s<<2)>>2]|0;q=X(s,e)|0;if((v|0)!=-1?(w=f[(f[a>>2]|0)+(v<<2)>>2]|0,(w|0)!=-1):0){v=f[k>>2]|0;x=f[d>>2]|0;y=f[x+(f[v+(w<<2)>>2]<<2)>>2]|0;z=w+1|0;A=((z>>>0)%3|0|0)==0?w+-2|0:z;if((A|0)==-1)B=-1;else B=f[v+(A<<2)>>2]|0;A=f[x+(B<<2)>>2]|0;z=(((w>>>0)%3|0|0)==0?2:-1)+w|0;if((z|0)==-1)C=-1;else C=f[v+(z<<2)>>2]|0;z=f[x+(C<<2)>>2]|0;if((y|0)<(s|0)&(A|0)<(s|0)&(z|0)<(s|0)){x=X(y,e)|0;y=X(A,e)|0;A=X(z,e)|0;if(r){z=0;do{f[j+(z<<2)>>2]=(f[c+(z+A<<2)>>2]|0)+(f[c+(z+y<<2)>>2]|0)-(f[c+(z+x<<2)>>2]|0);z=z+1|0}while((z|0)!=(e|0))}z=b+(q<<2)|0;x=c+(q<<2)|0;if((p|0)>0){y=0;do{A=f[j+(y<<2)>>2]|0;v=f[h>>2]|0;if((A|0)>(v|0)){w=f[n>>2]|0;f[w+(y<<2)>>2]=v;D=w}else{w=f[l>>2]|0;v=f[n>>2]|0;f[v+(y<<2)>>2]=(A|0)<(w|0)?w:A;D=v}y=y+1|0;E=f[g>>2]|0}while((y|0)<(E|0));if((E|0)>0){y=0;do{v=(f[z+(y<<2)>>2]|0)+(f[D+(y<<2)>>2]|0)|0;A=x+(y<<2)|0;f[A>>2]=v;if((v|0)<=(f[h>>2]|0)){if((v|0)<(f[l>>2]|0)){F=(f[i>>2]|0)+v|0;u=56}}else{F=v-(f[i>>2]|0)|0;u=56}if((u|0)==56){u=0;f[A>>2]=F}y=y+1|0;A=f[g>>2]|0}while((y|0)<(A|0));G=A}else G=E}else G=p}else u=34}else u=34;if((u|0)==34){u=0;y=c+((X(s+-1|0,e)|0)<<2)|0;x=b+(q<<2)|0;z=c+(q<<2)|0;if((p|0)>0){A=0;do{v=f[y+(A<<2)>>2]|0;w=f[h>>2]|0;if((v|0)>(w|0)){H=f[n>>2]|0;f[H+(A<<2)>>2]=w;I=H}else{H=f[l>>2]|0;w=f[n>>2]|0;f[w+(A<<2)>>2]=(v|0)<(H|0)?H:v;I=w}A=A+1|0;J=f[g>>2]|0}while((A|0)<(J|0));if((J|0)>0){A=0;do{y=(f[x+(A<<2)>>2]|0)+(f[I+(A<<2)>>2]|0)|0;q=z+(A<<2)|0;f[q>>2]=y;if((y|0)<=(f[h>>2]|0)){if((y|0)<(f[l>>2]|0)){K=(f[i>>2]|0)+y|0;u=44}}else{K=y-(f[i>>2]|0)|0;u=44}if((u|0)==44){u=0;f[q>>2]=K}A=A+1|0;q=f[g>>2]|0}while((A|0)<(q|0));G=q}else G=J}else G=p}s=s+1|0;if((s|0)>=(t|0)){u=22;break}else p=G}if((u|0)==22){bn(j);return 1}else if((u|0)==24)um(m);return 0}function Fb(a,b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<<2)|0;if((q|0)>0){B=0;do{v=f[z+(B<<2)>>2]|0;y=f[h>>2]|0;if((v|0)>(y|0)){G=f[n>>2]|0;f[G+(B<<2)>>2]=y;H=G}else{G=f[l>>2]|0;y=f[n>>2]|0;f[y+(B<<2)>>2]=(v|0)<(G|0)?G:v;H=y}B=B+1|0;I=f[g>>2]|0}while((B|0)<(I|0));if((I|0)>0){B=0;do{z=(f[x+(B<<2)>>2]|0)+(f[H+(B<<2)>>2]|0)|0;w=A+(B<<2)|0;f[w>>2]=z;if((z|0)<=(f[h>>2]|0)){if((z|0)<(f[l>>2]|0)){J=(f[i>>2]|0)+z|0;u=41}}else{J=z-(f[i>>2]|0)|0;u=41}if((u|0)==41){u=0;f[w>>2]=J}B=B+1|0;w=f[g>>2]|0}while((B|0)<(w|0));F=w}else F=I}else F=q}s=s+1|0;if((s|0)>=(t|0)){u=22;break}else q=F}if((u|0)==22){bn(j);return 1}else if((u|0)==24)um(m);return 0}function Gb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0;c=u;u=u+16|0;d=c;e=f[b>>2]|0;b=a+8|0;g=e+1|0;if((e|0)!=-1){h=((g>>>0)%3|0|0)==0?e+-2|0:g;g=e+(((e>>>0)%3|0|0)==0?2:-1)|0;i=(e>>>0)/3|0;j=a+212|0;k=a+216|0;l=a+360|0;m=f[(f[(f[b>>2]|0)+12>>2]|0)+(e<<2)>>2]|0;if((m|0)!=-1)if(((m>>>0)/3|0)>>>0>=i>>>0?(f[k>>2]|0)!=(f[j>>2]|0):0){m=0;do{if(Wg((f[l>>2]|0)+(m<<4)|0)|0){n=f[j>>2]|0;f[d>>2]=e;o=n+(m*144|0)+136|0;p=f[o>>2]|0;if(p>>>0<(f[n+(m*144|0)+140>>2]|0)>>>0){f[p>>2]=e;f[o>>2]=p+4}else xf(n+(m*144|0)+132|0,d)}m=m+1|0}while(m>>>0<(((f[k>>2]|0)-(f[j>>2]|0)|0)/144|0)>>>0);q=i;r=g;s=d;t=d;v=h;w=k;x=j;y=l;z=j}else{q=i;r=g;s=d;t=d;v=h;w=k;x=j;y=l;z=j}else{A=i;B=d;C=d;D=j;E=l;F=g;G=h;H=k;I=j;J=4}}else{j=a+212|0;A=-1;B=d;C=d;D=j;E=a+360|0;F=-1;G=-1;H=a+216|0;I=j;J=4}if((J|0)==4){j=f[H>>2]|0;a=f[I>>2]|0;if((j|0)==(a|0)){q=A;r=F;s=B;t=C;v=G;w=H;x=I;y=E;z=D}else{k=0;h=j;j=a;while(1){a=j;f[d>>2]=e;g=a+(k*144|0)+136|0;l=f[g>>2]|0;if(l>>>0<(f[a+(k*144|0)+140>>2]|0)>>>0){f[l>>2]=e;f[g>>2]=l+4;K=j;L=h}else{xf(a+(k*144|0)+132|0,d);K=f[I>>2]|0;L=f[H>>2]|0}k=k+1|0;if(k>>>0>=((L-K|0)/144|0)>>>0){q=A;r=F;s=B;t=C;v=G;w=H;x=I;y=E;z=D;break}else{h=L;j=K}}}}if((v|0)!=-1?(K=f[(f[(f[b>>2]|0)+12>>2]|0)+(v<<2)>>2]|0,(K|0)!=-1):0){if(((K>>>0)/3|0)>>>0>=q>>>0?(f[w>>2]|0)!=(f[x>>2]|0):0){K=0;do{if(Wg((f[y>>2]|0)+(K<<4)|0)|0){j=f[z>>2]|0;f[d>>2]=v;L=j+(K*144|0)+136|0;h=f[L>>2]|0;if(h>>>0<(f[j+(K*144|0)+140>>2]|0)>>>0){f[h>>2]=v;f[L>>2]=h+4}else xf(j+(K*144|0)+132|0,d)}K=K+1|0}while(K>>>0<(((f[w>>2]|0)-(f[x>>2]|0)|0)/144|0)>>>0)}}else J=27;if((J|0)==27?(J=f[w>>2]|0,K=f[x>>2]|0,(J|0)!=(K|0)):0){j=0;h=K;K=J;while(1){J=h;f[d>>2]=v;L=J+(j*144|0)+136|0;D=f[L>>2]|0;if(D>>>0<(f[J+(j*144|0)+140>>2]|0)>>>0){f[D>>2]=v;f[L>>2]=D+4;M=h;N=K}else{xf(J+(j*144|0)+132|0,d);M=f[x>>2]|0;N=f[w>>2]|0}j=j+1|0;if(j>>>0>=((N-M|0)/144|0)>>>0)break;else{h=M;K=N}}}if((r|0)!=-1?(N=f[(f[(f[b>>2]|0)+12>>2]|0)+(r<<2)>>2]|0,(N|0)!=-1):0){if(((N>>>0)/3|0)>>>0>>0){u=c;return 1}if((f[w>>2]|0)==(f[x>>2]|0)){u=c;return 1}else O=0;do{if(Wg((f[y>>2]|0)+(O<<4)|0)|0){q=f[z>>2]|0;f[d>>2]=r;N=q+(O*144|0)+136|0;b=f[N>>2]|0;if(b>>>0<(f[q+(O*144|0)+140>>2]|0)>>>0){f[b>>2]=r;f[N>>2]=b+4}else xf(q+(O*144|0)+132|0,d)}O=O+1|0}while(O>>>0<(((f[w>>2]|0)-(f[x>>2]|0)|0)/144|0)>>>0);u=c;return 1}O=f[w>>2]|0;z=f[x>>2]|0;if((O|0)==(z|0)){u=c;return 1}else{P=0;Q=z;R=O}while(1){O=Q;f[d>>2]=r;z=O+(P*144|0)+136|0;y=f[z>>2]|0;if(y>>>0<(f[O+(P*144|0)+140>>2]|0)>>>0){f[y>>2]=r;f[z>>2]=y+4;S=Q;T=R}else{xf(O+(P*144|0)+132|0,d);S=f[x>>2]|0;T=f[w>>2]|0}P=P+1|0;if(P>>>0>=((T-S|0)/144|0)>>>0)break;else{Q=S;R=T}}u=c;return 1}function Hb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=u;u=u+16|0;g=e;i=c+8|0;j=i;k=f[j>>2]|0;l=f[j+4>>2]|0;j=c+16|0;m=j;n=f[m>>2]|0;o=Rj(n|0,f[m+4>>2]|0,5,0)|0;m=I;if((l|0)<(m|0)|(l|0)==(m|0)&k>>>0>>0){o=bj(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=o;q=9496;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+29>>0]=0;f[a>>2]=-2;Rf(a+4|0,g);if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);u=e;return}o=(f[c>>2]|0)+n|0;b[d>>0]=b[o>>0]|0;b[d+1>>0]=b[o+1>>0]|0;b[d+2>>0]=b[o+2>>0]|0;b[d+3>>0]=b[o+3>>0]|0;b[d+4>>0]=b[o+4>>0]|0;o=j;n=Rj(f[o>>2]|0,f[o+4>>2]|0,5,0)|0;o=I;k=j;f[k>>2]=n;f[k+4>>2]=o;if(jh(d,9526,5)|0){k=bj(32)|0;f[g>>2]=k;f[g+8>>2]=-2147483616;f[g+4>>2]=17;p=k;q=9532;r=p+17|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[k+17>>0]=0;f[a>>2]=-1;Rf(a+4|0,g);if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);u=e;return}k=i;m=f[k+4>>2]|0;if(!((m|0)>(o|0)|((m|0)==(o|0)?(f[k>>2]|0)>>>0>n>>>0:0))){k=bj(32)|0;f[g>>2]=k;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=k;q=9496;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[k+29>>0]=0;f[a>>2]=-2;Rf(a+4|0,g);if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);u=e;return}b[d+5>>0]=b[(f[c>>2]|0)+n>>0]|0;n=j;k=Rj(f[n>>2]|0,f[n+4>>2]|0,1,0)|0;n=I;o=j;f[o>>2]=k;f[o+4>>2]=n;o=i;m=f[o+4>>2]|0;if(!((m|0)>(n|0)|((m|0)==(n|0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>2]=I;m=i;i=f[m>>2]|0;l=f[m+4>>2]|0;m=Rj(k|0,o|0,3,0)|0;o=I;if(!((l|0)<(o|0)|(l|0)==(o|0)&i>>>0>>0)){m=d+10|0;d=(f[c>>2]|0)+n|0;n=h[d>>0]|h[d+1>>0]<<8;b[m>>0]=n;b[m+1>>0]=n>>8;n=j;m=Rj(f[n>>2]|0,f[n+4>>2]|0,2,0)|0;n=j;f[n>>2]=m;f[n+4>>2]=I;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=e;return}n=bj(32)|0;f[g>>2]=n;f[g+8>>2]=-2147483616;f[g+4>>2]=29;p=n;q=9496;r=p+29|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[n+29>>0]=0;f[a>>2]=-2;Rf(a+4|0,g);if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);u=e;return} +function df(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=u;u=u+16|0;d=c;e=Gd(a,d,b)|0;g=f[e>>2]|0;if(g|0){h=g;i=h+28|0;u=c;return i|0}g=bj(40)|0;Rf(g+16|0,b);b=g+28|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;b=f[d>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=b;f[e>>2]=g;b=f[f[a>>2]>>2]|0;if(!b)j=g;else{f[a>>2]=b;j=f[e>>2]|0}Lc(f[a+4>>2]|0,j);j=a+8|0;f[j>>2]=(f[j>>2]|0)+1;h=g;i=h+28|0;u=c;return i|0}function ef(a,c,d,e,g,h,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0;k=u;u=u+16|0;l=k;if((-18-c|0)>>>0>>0)um(a);if((b[a+11>>0]|0)<0)m=f[a>>2]|0;else m=a;if(c>>>0<2147483623){n=d+c|0;d=c<<1;o=n>>>0>>0?d:n;p=o>>>0<11?11:o+16&-16}else p=-17;o=bj(p)|0;if(g|0)Ok(o,m,g)|0;if(i|0)Ok(o+g|0,j,i)|0;j=e-h|0;e=j-g|0;if(e|0)Ok(o+g+i|0,m+g+h|0,e)|0;if((c|0)!=10)dn(m);f[a>>2]=o;f[a+8>>2]=p|-2147483648;p=j+i|0;f[a+4>>2]=p;b[l>>0]=0;Rl(o+p|0,l);u=k;return}function ff(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>2>>>0>=b>>>0){Vf(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}h=f[a>>2]|0;i=g-h|0;g=i>>2;j=g+b|0;if(j>>>0>1073741823)um(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?j:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Yk(d,9789);f[d>>2]=3704;va(d|0,856,80)}else{d=bj(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;Vf(d|0,0,b<<2|0)|0;if((i|0)>0)ge(n|0,h|0,i|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=m+(l<<2);if(!h)return;dn(h);return}function gf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{f[c>>2]=g+-144;d=f[g+-12>>2]|0;if(d|0){h=g+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);dn(d)}d=f[g+-28>>2]|0;if(d|0){i=g+-24|0;h=f[i>>2]|0;if((h|0)!=(d|0))f[i>>2]=h+(~((h+-4-d|0)>>>2)<<2);dn(d)}d=f[g+-40>>2]|0;if(d|0){h=g+-36|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);dn(d)}tf(g+-140|0);g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}dn(e);return}function hf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;a=u;u=u+16|0;e=a;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;g=gg(d)|0;if(g>>>0>4294967279)um(e);if(g>>>0<11){b[e+11>>0]=g;if(!g)h=e;else{i=e;j=6}}else{k=g+16&-16;l=bj(k)|0;f[e>>2]=l;f[e+8>>2]=k|-2147483648;f[e+4>>2]=g;i=l;j=6}if((j|0)==6){ge(i|0,d|0,g|0)|0;h=i}b[h+g>>0]=0;g=($b(c,e)|0)!=0;if((b[e+11>>0]|0)>=0){u=a;return g|0}dn(f[e>>2]|0);u=a;return g|0}function jf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if((e-h|0)>>>0>=c>>>0){i=c;j=h;do{b[j>>0]=0;j=(f[g>>2]|0)+1|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=h-i|0;h=j+c|0;if((h|0)<0)um(a);k=e-i|0;i=k<<1;e=k>>>0<1073741823?(i>>>0>>0?h:i):2147483647;if(!e)l=0;else l=bj(e)|0;i=l+j|0;j=l+e|0;e=c;c=i;l=i;do{b[l>>0]=0;l=c+1|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=(f[g>>2]|0)-e|0;h=i+(0-l)|0;if((l|0)>0)ge(h|0,e|0,l|0)|0;f[a>>2]=h;f[g>>2]=c;f[d>>2]=j;if(!e)return;dn(e);return}function kf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0;d=u;u=u+32|0;c=d;if((h[(f[a+4>>2]|0)+36>>0]<<8&65535)>511?!(Na[f[(f[a>>2]|0)+52>>2]&127](a)|0):0){e=0;u=d;return e|0}f[c>>2]=956;f[c+4>>2]=-1;g=c+8|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;Mh(c,f[a+24>>2]|0,f[a+28>>2]|0,b[(f[a+8>>2]|0)+24>>0]|0,$(n[a+32>>2]));i=gh(c,f[a+16>>2]|0)|0;f[c>>2]=956;a=f[g>>2]|0;if(a|0){g=c+12|0;c=f[g>>2]|0;if((c|0)!=(a|0))f[g>>2]=c+(~((c+-4-a|0)>>>2)<<2);dn(a)}e=i;u=d;return e|0}function lf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{f[c>>2]=e+-144;d=f[e+-12>>2]|0;if(d|0){g=e+-8|0;h=f[g>>2]|0;if((h|0)!=(d|0))f[g>>2]=h+(~((h+-4-d|0)>>>2)<<2);dn(d)}d=f[e+-28>>2]|0;if(d|0){h=e+-24|0;g=f[h>>2]|0;if((g|0)!=(d|0))f[h>>2]=g+(~((g+-4-d|0)>>>2)<<2);dn(d)}d=f[e+-40>>2]|0;if(d|0){g=e+-36|0;h=f[g>>2]|0;if((h|0)!=(d|0))f[g>>2]=h+(~((h+-4-d|0)>>>2)<<2);dn(d)}tf(e+-140|0);e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;dn(b);return}function mf(a){a=a|0;var b=0,c=0,d=0;b=f[a+76>>2]|0;if(b|0){c=a+80|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+64>>2]|0;if(b|0){d=a+68|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;dn(b)}b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+24>>2]|0;if(b|0){c=a+28|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+12>>2]|0;if(b|0){d=a+16|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function nf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+32|0;e=a+12|0;g=a;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=gg(d)|0;if(h>>>0>4294967279)um(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=bj(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;h=Sf(c,g,e)|0;if((b[g+11>>0]|0)<0)dn(f[g>>2]|0);if((b[e+11>>0]|0)>=0){u=a;return h|0}dn(f[e>>2]|0);u=a;return h|0}function of(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=j;j=i;while(1){if(j<<24>>24<0)l=f[c>>2]|0;else l=c;f[g>>2]=d;m=tj(l,k+1|0,12304,g)|0;if((m|0)>-1)if(m>>>0>k>>>0)n=m;else break;else n=k<<1|1;hg(c,n,0);k=n;j=b[h>>0]|0}hg(c,m,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function pf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a+8|0;c=f[b>>2]|0;if((c|0)<0){d=0;return d|0}e=a+4|0;a=f[e>>2]|0;g=a+4|0;h=f[g>>2]|0;i=f[a>>2]|0;j=h-i>>2;k=i;i=h;if(c>>>0<=j>>>0)if(c>>>0>>0?(h=k+(c<<2)|0,(h|0)!=(i|0)):0){f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2);l=c}else l=c;else{ff(a,c-j|0);l=f[b>>2]|0}if((l|0)<=0){d=1;return d|0}b=f[e>>2]|0;e=f[b>>2]|0;j=(f[b+4>>2]|0)-e>>2;c=e;e=0;while(1){if(j>>>0<=e>>>0){m=10;break}f[c+(e<<2)>>2]=e;e=e+1|0;if((e|0)>=(l|0)){d=1;m=12;break}}if((m|0)==10)um(b);else if((m|0)==12)return d|0;return 0}function qf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=a+140|0;c=f[b>>2]|0;if((c|0)<=0){d=1;return d|0}e=c<<4;g=an(c>>>0>268435455|e>>>0>4294967291?-1:e+4|0)|0;f[g>>2]=c;e=g+4|0;g=e+(c<<4)|0;c=e;do{Cm(c);c=c+16|0}while((c|0)!=(g|0));g=a+136|0;c=f[g>>2]|0;f[g>>2]=e;if(c|0){e=c+-4|0;h=f[e>>2]|0;if(h|0){i=c+(h<<4)|0;do i=i+-16|0;while((i|0)!=(c|0))}bn(e)}if((f[b>>2]|0)<=0){d=1;return d|0}e=0;while(1){if(!(td((f[g>>2]|0)+(e<<4)|0,a)|0)){d=0;j=13;break}e=e+1|0;if((e|0)>=(f[b>>2]|0)){d=1;j=13;break}}if((j|0)==13)return d|0;return 0}function rf(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a>>2]|0;f[a>>2]=0;if(!c)return;a=f[c+28>>2]|0;if(a|0){d=a;do{a=d;d=f[d>>2]|0;e=a+8|0;rf(a+20|0);if((b[e+11>>0]|0)<0)dn(f[e>>2]|0);dn(a)}while((d|0)!=0)}d=c+20|0;a=f[d>>2]|0;f[d>>2]=0;if(a|0)dn(a);a=f[c+8>>2]|0;if(a|0){d=a;do{a=d;d=f[d>>2]|0;e=a+8|0;g=f[a+20>>2]|0;if(g|0){h=a+24|0;if((f[h>>2]|0)!=(g|0))f[h>>2]=g;dn(g)}if((b[e+11>>0]|0)<0)dn(f[e>>2]|0);dn(a)}while((d|0)!=0)}d=f[c>>2]|0;f[c>>2]=0;if(d|0)dn(d);dn(c);return}function sf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=$b(a,c)|0;if(!e){g=0;return g|0}c=f[e+20>>2]|0;if(((f[e+24>>2]|0)-c|0)!=8){g=0;return g|0}e=c;c=e;a=h[c>>0]|h[c+1>>0]<<8|h[c+2>>0]<<16|h[c+3>>0]<<24;c=e+4|0;e=h[c>>0]|h[c+1>>0]<<8|h[c+2>>0]<<16|h[c+3>>0]<<24;c=d;d=c;b[d>>0]=a;b[d+1>>0]=a>>8;b[d+2>>0]=a>>16;b[d+3>>0]=a>>24;a=c+4|0;b[a>>0]=e;b[a+1>>0]=e>>8;b[a+2>>0]=e>>16;b[a+3>>0]=e>>24;g=1;return g|0}function tf(a){a=a|0;var b=0,c=0,d=0;b=f[a+84>>2]|0;if(b|0){c=a+88|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+72>>2]|0;if(b|0){d=a+76|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;dn(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+28>>2]|0;if(b|0){d=a+32|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+12>>2]|0;if(b|0)dn(b);b=f[a>>2]|0;if(!b)return;dn(b);return}function uf(){var a=0,b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+48|0;b=a+32|0;c=a+24|0;d=a+16|0;e=a;g=a+36|0;a=ej()|0;if(a|0?(h=f[a>>2]|0,h|0):0){a=h+48|0;i=f[a>>2]|0;j=f[a+4>>2]|0;if(!((i&-256|0)==1126902528&(j|0)==1129074247)){f[c>>2]=12443;zj(12393,c)}if((i|0)==1126902529&(j|0)==1129074247)k=f[h+44>>2]|0;else k=h+80|0;f[g>>2]=k;k=f[h>>2]|0;h=f[k+4>>2]|0;if(Pa[f[(f[194]|0)+16>>2]&31](776,k,g)|0){k=f[g>>2]|0;g=Na[f[(f[k>>2]|0)+8>>2]&127](k)|0;f[e>>2]=12443;f[e+4>>2]=h;f[e+8>>2]=g;zj(12307,e)}else{f[d>>2]=12443;f[d+4>>2]=h;zj(12352,d)}}zj(12431,b)}function vf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;do if(a){if(c>>>0<128){b[a>>0]=c;e=1;break}d=(Zm()|0)+188|0;if(!(f[f[d>>2]>>2]|0))if((c&-128|0)==57216){b[a>>0]=c;e=1;break}else{d=ln()|0;f[d>>2]=84;e=-1;break}if(c>>>0<2048){b[a>>0]=c>>>6|192;b[a+1>>0]=c&63|128;e=2;break}if(c>>>0<55296|(c&-8192|0)==57344){b[a>>0]=c>>>12|224;b[a+1>>0]=c>>>6&63|128;b[a+2>>0]=c&63|128;e=3;break}if((c+-65536|0)>>>0<1048576){b[a>>0]=c>>>18|240;b[a+1>>0]=c>>>12&63|128;b[a+2>>0]=c>>>6&63|128;b[a+3>>0]=c&63|128;e=4;break}else{d=ln()|0;f[d>>2]=84;e=-1;break}}else e=1;while(0);return e|0}function wf(a){a=a|0;var b=0,c=0,d=0;b=f[a+92>>2]|0;if(b|0){c=a+96|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+76>>2]|0;if(b|0){d=a+80|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b)}f[a+4>>2]=2420;b=f[a+24>>2]|0;if(b|0)dn(b);b=f[a+12>>2]|0;if(!b)return;dn(b);return}function xf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=e>>2;h=g+1|0;if(h>>>0>1073741823)um(a);i=a+8|0;j=(f[i>>2]|0)-d|0;k=j>>1;l=j>>2>>>0<536870911?(k>>>0>>0?h:k):1073741823;do if(l)if(l>>>0>1073741823){k=ra(8)|0;Yk(k,9789);f[k>>2]=3704;va(k|0,856,80)}else{k=bj(l<<2)|0;m=k;n=k;break}else{m=0;n=0}while(0);k=m+(g<<2)|0;f[k>>2]=f[b>>2];if((e|0)>0)ge(n|0,d|0,e|0)|0;f[a>>2]=m;f[c>>2]=k+4;f[i>>2]=m+(l<<2);if(!d)return;dn(d);return}function yf(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2464;b=a+84|0;c=a+4|0;d=c+80|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+88>>2]=-1;f[a+92>>2]=-1;b=a+152|0;c=a+96|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));n[b>>2]=$(1.0);b=a+224|0;c=a+156|0;d=c+68|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));Gi(b);b=a+372|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[a+392>>2]=-1;f[a+396>>2]=-1;f[a+400>>2]=2;f[a+404>>2]=7;b=a+408|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function zf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0.0;a=u;u=u+32|0;e=a;g=a+8|0;p[e>>3]=0.0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=gg(d)|0;if(h>>>0>4294967279)um(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=bj(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;sf(c,g,e)|0;n=+p[e>>3];if((b[g+11>>0]|0)>=0){u=a;return +n}dn(f[g>>2]|0);u=a;return +n}function Af(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=u;u=u+128|0;h=g+124|0;i=g;j=i;k=3084;l=j+124|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));if((c+-1|0)>>>0>2147483646)if(!c){m=h;n=1;o=4}else{h=ln()|0;f[h>>2]=75;p=-1}else{m=a;n=c;o=4}if((o|0)==4){o=-2-m|0;c=n>>>0>o>>>0?o:n;f[i+48>>2]=c;n=i+20|0;f[n>>2]=m;f[i+44>>2]=m;o=m+c|0;m=i+16|0;f[m>>2]=o;f[i+28>>2]=o;o=ye(i,d,e)|0;if(!c)p=o;else{c=f[n>>2]|0;b[c+(((c|0)==(f[m>>2]|0))<<31>>31)>>0]=0;p=o}}u=g;return p|0}function Bf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+16|0;e=a+12|0;g=a;f[e>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=gg(d)|0;if(h>>>0>4294967279)um(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=bj(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;cg(c,g,e)|0;c=f[e>>2]|0;if((b[g+11>>0]|0)>=0){u=a;return c|0}dn(f[g>>2]|0);u=a;return c|0}function Cf(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+28>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;g=c+20|0;h=f[g>>2]|0;f[g>>2]=0;if(h|0){Cf(h);dn(h)}if((b[e+11>>0]|0)<0)dn(f[e>>2]|0);dn(c)}while((d|0)!=0)}d=a+20|0;c=f[d>>2]|0;f[d>>2]=0;if(c|0)dn(c);c=f[a+8>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){g=c+24|0;if((f[g>>2]|0)!=(h|0))f[g>>2]=h;dn(h)}if((b[e+11>>0]|0)<0)dn(f[e>>2]|0);dn(c)}while((d|0)!=0)}d=f[a>>2]|0;f[a>>2]=0;if(!d)return;dn(d);return}function Df(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+32|0;e=a;g=a+8|0;p[e>>3]=0.0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=gg(d)|0;if(h>>>0>4294967279)um(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=bj(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;h=sf(c,g,e)|0;if((b[g+11>>0]|0)>=0){u=a;return h|0}dn(f[g>>2]|0);u=a;return h|0}function Ef(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a=u;u=u+16|0;e=a+12|0;g=a;f[e>>2]=0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;h=gg(d)|0;if(h>>>0>4294967279)um(g);if(h>>>0<11){b[g+11>>0]=h;if(!h)i=g;else{j=g;k=6}}else{l=h+16&-16;m=bj(l)|0;f[g>>2]=m;f[g+8>>2]=l|-2147483648;f[g+4>>2]=h;j=m;k=6}if((k|0)==6){ge(j|0,d|0,h|0)|0;i=j}b[i+h>>0]=0;h=cg(c,g,e)|0;if((b[g+11>>0]|0)>=0){u=a;return h|0}dn(f[g>>2]|0);u=a;return h|0}function Ff(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=c+8|0;e=f[d+4>>2]|0;g=c+16|0;h=g;i=f[h>>2]|0;j=f[h+4>>2]|0;if(!((e|0)>(j|0)|((e|0)==(j|0)?(f[d>>2]|0)>>>0>i>>>0:0))){k=0;return k|0}d=b[(f[c>>2]|0)+i>>0]|0;e=Rj(i|0,j|0,1,0)|0;j=g;f[j>>2]=e;f[j+4>>2]=I;do if(d<<24>>24<0)if(Ff(a,c)|0){j=a;e=Oj(f[j>>2]|0,f[j+4>>2]|0,7)|0;j=I;g=a;f[g>>2]=e;f[g+4>>2]=j;l=e|d&127;m=j;break}else{k=0;return k|0}else{l=d&255;m=0}while(0);d=a;f[d>>2]=l;f[d+4>>2]=m;k=1;return k|0}function Gf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;if(b>>>0>1431655765|(c|b|0)<0){d=0;return d|0}e=b*3|0;sd(a,e,2656);sd(a+12|0,e,2652);Eg(a+24|0,c);c=a+76|0;e=f[c>>2]|0;b=a+80|0;g=f[b>>2]|0;if((g|0)!=(e|0))f[b>>2]=g+(~((g+-4-e|0)>>>2)<<2);f[c>>2]=0;f[b>>2]=0;f[a+84>>2]=0;if(e|0)dn(e);e=a+64|0;b=f[e>>2]|0;c=a+68|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;f[e>>2]=0;f[c>>2]=0;f[a+72>>2]=0;if(!b){d=1;return d|0}dn(b);d=1;return d|0}function Hf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+48|0;g=e+4|0;h=e;if((d|0)!=1){f[a>>2]=0;u=e;return}d=f[b+12>>2]|0;i=f[b+4>>2]|0;b=g;j=b+36|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Ie(h,c,d,i,g);i=f[g+24>>2]|0;if(i|0){d=g+28|0;g=f[d>>2]|0;if((g|0)!=(i|0))f[d>>2]=g+(~((g+-4-i|0)>>>2)<<2);dn(i)}f[a>>2]=f[h>>2];u=e;return}function If(a,b){a=a|0;b=b|0;var c=0,d=0;c=a+16|0;a=f[b>>2]|0;f[b>>2]=0;b=f[c>>2]|0;f[c>>2]=a;if(!b)return;a=b+88|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0){a=f[c+8>>2]|0;if(a|0){d=c+12|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;dn(a)}dn(c)}c=f[b+68>>2]|0;if(c|0){a=b+72|0;d=f[a>>2]|0;if((d|0)!=(c|0))f[a>>2]=d+(~((d+-4-c|0)>>>2)<<2);dn(c)}c=b+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){a=d+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;dn(c)}dn(d)}dn(b);return}function Jf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;if(c|0){h=a+11|0;i=b[h>>0]|0;if(i<<24>>24<0){j=f[a+4>>2]|0;k=(f[a+8>>2]&2147483647)+-1|0}else{j=i&255;k=10}if((k-j|0)>>>0>>0){Zf(a,k,c-k+j|0,j,j,0,0);l=b[h>>0]|0}else l=i;if(l<<24>>24<0)m=f[a>>2]|0;else m=a;Mj(m+j|0,c,d)|0;d=j+c|0;if((b[h>>0]|0)<0)f[a+4>>2]=d;else b[h>>0]=d;b[g>>0]=0;Rl(m+d|0,g)}u=e;return a|0}function Kf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=(f[a+8>>2]&2147483647)+-1|0;else k=10;do if(k>>>0>=d>>>0){if(j)l=f[a>>2]|0;else l=a;Mk(l,c,d)|0;b[g>>0]=0;Rl(l+d|0,g);if((b[h>>0]|0)<0){f[a+4>>2]=d;break}else{b[h>>0]=d;break}}else{if(j)m=f[a+4>>2]|0;else m=i&255;ef(a,k,d-k|0,m,0,m,d,c)}while(0);u=e;return a|0}function Lf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=2236;b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Sa[f[(f[c>>2]|0)+4>>2]&127](c);f[a>>2]=2616;c=f[a+20>>2]|0;if(c|0){b=a+24|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);dn(c)}c=a+8|0;d=f[c>>2]|0;if(!d){dn(a);return}b=a+12|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Sa[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}dn(g);dn(a);return}function Mf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0;d=u;u=u+80|0;e=d;g=d+56|0;i=d+40|0;j=e;k=c;c=j+40|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(c|0));Hb(i,e,g);e=f[i>>2]|0;if(!e){k=i+4|0;if((b[k+11>>0]|0)<0)dn(f[k>>2]|0);k=h[g+7>>0]|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=k;u=d;return}else{f[a>>2]=e;e=i+4|0;Rf(a+4|0,e);if((b[e+11>>0]|0)<0)dn(f[e>>2]|0);u=d;return}}function Nf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=f[a>>2]|0;if(!d){e=0;return e|0}g=f[c>>2]|0;if(!g){e=0;return e|0}h=f[g>>2]|0;Xf(d,h,(f[g+4>>2]|0)-h|0,0)|0;b[a+24>>0]=b[c+24>>0]|0;f[a+28>>2]=f[c+28>>2];b[a+32>>0]=b[c+32>>0]|0;h=c+40|0;g=f[h+4>>2]|0;d=a+40|0;f[d>>2]=f[h>>2];f[d+4>>2]=g;g=c+48|0;d=f[g+4>>2]|0;h=a+48|0;f[h>>2]=f[g>>2];f[h+4>>2]=d;f[a+56>>2]=f[c+56>>2];d=c+8|0;c=a+8|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];e=1;return e|0}function Of(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;if((Na[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){d=1;return d|0}a=0;while(1){e=f[(f[c>>2]|0)+4>>2]|0;g=ki(e,Oa[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;if((g|0)==-1){d=0;h=6;break}e=f[(f[b>>2]|0)+28>>2]|0;i=sh(f[c>>2]|0,g)|0;a=a+1|0;if(!(Oa[e&127](b,i)|0)){d=0;h=6;break}if((a|0)>=(Na[f[(f[b>>2]|0)+20>>2]&127](b)|0)){d=1;h=6;break}}if((h|0)==6)return d|0;return 0}function Pf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=2236;b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Sa[f[(f[c>>2]|0)+4>>2]&127](c);f[a>>2]=2616;c=f[a+20>>2]|0;if(c|0){b=a+24|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);dn(c)}c=a+8|0;d=f[c>>2]|0;if(!d)return;b=a+12|0;a=f[b>>2]|0;if((a|0)==(d|0))e=d;else{g=a;do{a=g+-4|0;f[b>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Sa[f[(f[h>>2]|0)+4>>2]&127](h);g=f[b>>2]|0}while((g|0)!=(d|0));e=f[c>>2]|0}dn(e);return}function Qf(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(!a){g=1;return g|0}h=d+8|0;i=f[h+4>>2]|0;j=d+16|0;k=j;l=f[k>>2]|0;m=f[k+4>>2]|0;if(!((i|0)>(m|0)|((i|0)==(m|0)?(f[h>>2]|0)>>>0>l>>>0:0))){g=0;return g|0}h=b[(f[d>>2]|0)+l>>0]|0;i=Rj(l|0,m|0,1,0)|0;m=j;f[m>>2]=i;f[m+4>>2]=I;switch(h<<24>>24){case 0:{g=fc(a,c,d,e)|0;return g|0}case 1:{g=yc(a,d,e)|0;return g|0}default:{g=0;return g|0}}return 0}function Rf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;if((b[c+11>>0]|0)<0){g=f[c>>2]|0;h=f[c+4>>2]|0;if(h>>>0>4294967279)um(a);if(h>>>0<11){b[a+11>>0]=h;i=a}else{j=h+16&-16;k=bj(j)|0;f[a>>2]=k;f[a+8>>2]=j|-2147483648;f[a+4>>2]=h;i=k}Ok(i,g,h)|0;b[e>>0]=0;Rl(i+h|0,e)}else{f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2]}u=d;return}function Sf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=$b(a,b)|0;if(!d){e=0;return e|0}b=d+20|0;a=f[b>>2]|0;g=d+24|0;d=f[g>>2]|0;if((a|0)==(d|0)){e=0;return e|0}hg(c,d-a|0,0);a=Jh(c,0)|0;c=f[b>>2]|0;ge(a|0,c|0,(f[g>>2]|0)-c|0)|0;e=1;return e|0}function Tf(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;b[c+53>>0]=1;do if((f[c+4>>2]|0)==(e|0)){b[c+52>>0]=1;a=c+16|0;h=f[a>>2]|0;if(!h){f[a>>2]=d;f[c+24>>2]=g;f[c+36>>2]=1;if(!((g|0)==1?(f[c+48>>2]|0)==1:0))break;b[c+54>>0]=1;break}if((h|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;b[c+54>>0]=1;break}h=c+24|0;a=f[h>>2]|0;if((a|0)==2){f[h>>2]=g;i=g}else i=a;if((i|0)==1?(f[c+48>>2]|0)==1:0)b[c+54>>0]=1}while(0);return}function Uf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;f[a>>2]=c;f[a+68>>2]=0;f[a+72>>2]=0;$c(e,c);g=a+4|0;h=f[e>>2]|0;f[e>>2]=0;i=f[g>>2]|0;f[g>>2]=h;if(!i){f[e>>2]=0;j=h}else{mf(i);dn(i);i=f[e>>2]|0;f[e>>2]=0;if(i|0){mf(i);dn(i)}j=f[g>>2]|0}if(!j){k=0;u=d;return k|0}j=((f[c+100>>2]|0)-(f[c+96>>2]|0)|0)/12|0;b[e>>0]=0;le(a+56|0,j,e);k=1;u=d;return k|0}function Vf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+d|0;c=c&255;if((d|0)>=67){while(a&3){b[a>>0]=c;a=a+1|0}g=e&-4|0;h=g-64|0;i=c|c<<8|c<<16|c<<24;while((a|0)<=(h|0)){f[a>>2]=i;f[a+4>>2]=i;f[a+8>>2]=i;f[a+12>>2]=i;f[a+16>>2]=i;f[a+20>>2]=i;f[a+24>>2]=i;f[a+28>>2]=i;f[a+32>>2]=i;f[a+36>>2]=i;f[a+40>>2]=i;f[a+44>>2]=i;f[a+48>>2]=i;f[a+52>>2]=i;f[a+56>>2]=i;f[a+60>>2]=i;a=a+64|0}while((a|0)<(g|0)){f[a>>2]=i;a=a+4|0}}while((a|0)<(e|0)){b[a>>0]=c;a=a+1|0}return e-d|0}function Wf(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;do if(!(zl(a,f[c+8>>2]|0,g)|0)){if(zl(a,f[c>>2]|0,g)|0){if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0)b[c+54>>0]=1;f[c+44>>2]=4;break}if((e|0)==1)f[c+32>>2]=1}}else Ui(0,c,d,e);while(0);return}function Xf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;if((d|0)<0){e=0;return e|0}do if(!b){d=a+4|0;g=f[d>>2]|0;h=f[a>>2]|0;i=g-h|0;if(i>>>0>>0){jf(a,c-i|0);break}if(i>>>0>c>>>0?(i=h+c|0,(i|0)!=(g|0)):0)f[d>>2]=i}else Jd(a,b,b+c|0);while(0);c=a+24|0;a=c;b=Rj(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=c;f[a>>2]=b;f[a+4>>2]=I;e=1;return e|0}function Yf(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1040;b=a+16|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;dn(b)}dn(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);dn(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;dn(c)}dn(d)}dn(a);return}function Zf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;if((-17-c|0)>>>0>>0)um(a);if((b[a+11>>0]|0)<0)j=f[a>>2]|0;else j=a;if(c>>>0<2147483623){k=d+c|0;d=c<<1;l=k>>>0>>0?d:k;m=l>>>0<11?11:l+16&-16}else m=-17;l=bj(m)|0;if(g|0)Ok(l,j,g)|0;k=e-h-g|0;if(k|0)Ok(l+g+i|0,j+g+h|0,k)|0;if((c|0)!=10)dn(j);f[a>>2]=l;f[a+8>>2]=m|-2147483648;return}function _f(a,b){a=a|0;b=b|0;if(!b)return;else{_f(a,f[b>>2]|0);_f(a,f[b+4>>2]|0);eg(b+20|0,f[b+24>>2]|0);dn(b);return}}function $f(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=a+64|0;if((f[d>>2]|0)==0?(e=bj(32)|0,oj(e),g=f[d>>2]|0,f[d>>2]=e,g|0):0){e=f[g>>2]|0;if(e|0){h=g+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;dn(e)}dn(g)}g=ai(f[a+28>>2]|0)|0;e=X(g,b[a+24>>0]|0)|0;g=((e|0)<0)<<31>>31;h=f[d>>2]|0;i=gj(e|0,g|0,c|0,0)|0;if(!(Xf(h,0,i,I)|0)){j=0;return j|0}Vg(a,f[d>>2]|0,e,g,0,0);f[a+80>>2]=c;j=1;return j|0}function ag(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+32|0;g=e+20|0;h=e+16|0;i=e;j=b[a+24>>0]|0;f[i>>2]=f[226];f[i+4>>2]=f[227];f[i+8>>2]=f[228];f[i+12>>2]=f[229];f[h>>2]=c;f[g>>2]=f[h>>2];if(!(bb(a,g,j,i)|0)){k=0;u=e;return k|0}pd(d,i,i+(j<<24>>24<<2)|0);k=1;u=e;return k|0}function bg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+64|0;e=d;if(!(zl(a,b,0)|0))if((b|0)!=0?(g=De(b,800,784,0)|0,(g|0)!=0):0){b=e+4|0;h=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(h|0));f[e>>2]=g;f[e+8>>2]=a;f[e+12>>2]=-1;f[e+48>>2]=1;Va[f[(f[g>>2]|0)+28>>2]&7](g,e,f[c>>2]|0,1);if((f[e+24>>2]|0)==1){f[c>>2]=f[e+16>>2];i=1}else i=0;j=i}else j=0;else j=1;u=d;return j|0}function cg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=$b(a,c)|0;if(!e){g=0;return g|0}c=f[e+20>>2]|0;if(((f[e+24>>2]|0)-c|0)!=4){g=0;return g|0}e=c;c=h[e>>0]|h[e+1>>0]<<8|h[e+2>>0]<<16|h[e+3>>0]<<24;b[d>>0]=c;b[d+1>>0]=c>>8;b[d+2>>0]=c>>16;b[d+3>>0]=c>>24;g=1;return g|0}function dg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=c+8|0;e=f[d+4>>2]|0;g=c+16|0;h=g;i=f[h>>2]|0;j=f[h+4>>2]|0;if(!((e|0)>(j|0)|((e|0)==(j|0)?(f[d>>2]|0)>>>0>i>>>0:0))){k=0;return k|0}d=b[(f[c>>2]|0)+i>>0]|0;e=Rj(i|0,j|0,1,0)|0;j=g;f[j>>2]=e;f[j+4>>2]=I;j=d&255;do if(j&128)if(dg(a,c)|0){e=f[a>>2]<<7;f[a>>2]=e;l=e|d&127;break}else{k=0;return k|0}else l=j;while(0);f[a>>2]=l;k=1;return k|0}function eg(a,c){a=a|0;c=c|0;var d=0;if(!c)return;eg(a,f[c>>2]|0);eg(a,f[c+4>>2]|0);a=c+16|0;d=c+28|0;if((b[d+11>>0]|0)<0)dn(f[d>>2]|0);if((b[a+11>>0]|0)<0)dn(f[a>>2]|0);dn(c);return}function fg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=2616;b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=a+8|0;d=f[b>>2]|0;if(!d){dn(a);return}c=a+12|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Sa[f[(f[i>>2]|0)+4>>2]&127](i);h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}dn(g);dn(a);return}function gg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a;a:do if(!(c&3)){d=a;e=4}else{g=a;h=c;while(1){if(!(b[g>>0]|0)){i=h;break a}j=g+1|0;h=j;if(!(h&3)){d=j;e=4;break}else g=j}}while(0);if((e|0)==4){e=d;while(1){k=f[e>>2]|0;if(!((k&-2139062144^-2139062144)&k+-16843009))e=e+4|0;else break}if(!((k&255)<<24>>24))l=e;else{k=e;while(1){e=k+1|0;if(!(b[e>>0]|0)){l=e;break}else k=e}}i=l}return i-c|0}function hg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=f[a+4>>2]|0;else k=i&255;do if(k>>>0>=c>>>0)if(j){i=(f[a>>2]|0)+c|0;b[g>>0]=0;Rl(i,g);f[a+4>>2]=c;break}else{b[g>>0]=0;Rl(a+c|0,g);b[h>>0]=c;break}else Jf(a,c-k|0,d)|0;while(0);u=e;return}function ig(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;dn(b)}dn(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);dn(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;dn(c)}dn(d)}dn(a);return}function jg(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;f[a>>2]=d;if(d|0){m=d+16|0;n=f[m+4>>2]|0;o=a+8|0;f[o>>2]=f[m>>2];f[o+4>>2]=n;n=d+24|0;d=f[n+4>>2]|0;o=a+16|0;f[o>>2]=f[n>>2];f[o+4>>2]=d}b[a+24>>0]=e;f[a+28>>2]=g;b[a+32>>0]=h&1;h=a+40|0;f[h>>2]=i;f[h+4>>2]=j;j=a+48|0;f[j>>2]=k;f[j+4>>2]=l;f[a+56>>2]=c;return}function kg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=bj(88)|0;d=c+60|0;e=c;g=e+60|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=c;d=c+64|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;d=vd(c,b)|0;f[a>>2]=d?c:0;a=d?0:c;if(d)return;mf(a);dn(a);return}function lg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;if((f[c+76>>2]|0)>=0?(jn(c)|0)!=0:0){d=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(g=c+20|0,h=f[g>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[g>>2]=h+1;b[h>>0]=d;i=e}else i=mg(c,a)|0;hn(c);j=i}else k=3;do if((k|0)==3){i=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(d=c+20|0,h=f[d>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[d>>2]=h+1;b[h>>0]=i;j=e;break}j=mg(c,a)|0}while(0);return j|0}function mg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+16|0;e=d;g=c&255;b[e>>0]=g;i=a+16|0;j=f[i>>2]|0;if(!j)if(!(Gh(a)|0)){k=f[i>>2]|0;l=4}else m=-1;else{k=j;l=4}do if((l|0)==4){j=a+20|0;i=f[j>>2]|0;if(i>>>0>>0?(n=c&255,(n|0)!=(b[a+75>>0]|0)):0){f[j>>2]=i+1;b[i>>0]=g;m=n;break}if((Pa[f[a+36>>2]&31](a,e,1)|0)==1)m=h[e>>0]|0;else m=-1}while(0);u=d;return m|0}function ng(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;g=d+4|0;f[e>>2]=c;c=bj(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=24;h=c;i=8408;j=h+24|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[c+24>>0]=0;rg(Ub(a,e)|0,g,1);if((b[g+11>>0]|0)>=0){u=d;return}dn(f[g>>2]|0);u=d;return}function og(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=2616;b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=a+8|0;d=f[b>>2]|0;if(!d)return;c=a+12|0;a=f[c>>2]|0;if((a|0)==(d|0))e=d;else{g=a;do{a=g+-4|0;f[c>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Sa[f[(f[h>>2]|0)+4>>2]&127](h);g=f[c>>2]|0}while((g|0)!=(d|0));e=f[b>>2]|0}dn(e);return}function pg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if(c>>>0>0|(c|0)==0&a>>>0>4294967295){e=d;f=a;g=c;while(1){c=$i(f|0,g|0,10,0)|0;e=e+-1|0;b[e>>0]=c&255|48;c=f;f=Fl(f|0,g|0,10,0)|0;if(!(g>>>0>9|(g|0)==9&c>>>0>4294967295))break;else g=I}h=f;i=e}else{h=a;i=d}if(!h)j=i;else{d=h;h=i;while(1){i=h+-1|0;b[i>>0]=(d>>>0)%10|0|48;if(d>>>0<10){j=i;break}else{d=(d>>>0)/10|0;h=i}}}return j|0}function qg(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=a;while(1){d=c+1|0;if(!(wm(b[c>>0]|0)|0))break;else c=d}a=b[c>>0]|0;switch(a<<24>>24|0){case 45:{e=1;f=5;break}case 43:{e=0;f=5;break}default:{g=0;h=c;i=a}}if((f|0)==5){g=e;h=d;i=b[d>>0]|0}if(!(Om(i<<24>>24)|0))j=0;else{i=0;d=h;while(1){h=(i*10|0)+48-(b[d>>0]|0)|0;d=d+1|0;if(!(Om(b[d>>0]|0)|0)){j=h;break}else i=h}}return (g|0?j:0-j|0)|0}function rg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;vh(g,d&1);d=df(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}fe(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function sg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1628;b=f[a+96>>2]|0;if(b|0)dn(b);b=f[a+84>>2]|0;if(b|0)dn(b);b=f[a+72>>2]|0;if(b|0)dn(b);b=f[a+60>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function tg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=Vd(a,c)|0;if((e|0)==(a+4|0)){g=-1;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}a=e+28|0;if((b[a+11>>0]|0)<0)k=f[a>>2]|0;else k=a;g=qg(k)|0;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}function ug(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1376;b=f[a+96>>2]|0;if(b|0)dn(b);b=f[a+84>>2]|0;if(b|0)dn(b);b=f[a+72>>2]|0;if(b|0)dn(b);b=f[a+60>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function vg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0;d=0;while(1){if((h[10412+d>>0]|0)==(a|0)){e=2;break}g=d+1|0;if((g|0)==87){i=10500;j=87;e=5;break}else d=g}if((e|0)==2)if(!d)k=10500;else{i=10500;j=d;e=5}if((e|0)==5)while(1){e=0;d=i;do{a=d;d=d+1|0}while((b[a>>0]|0)!=0);j=j+-1|0;if(!j){k=d;break}else{i=d;e=5}}return Bm(k,f[c+20>>2]|0)|0}function wg(a,b){a=+a;b=b|0;var c=0,d=0,e=0,g=0.0,h=0.0,i=0,j=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;e=Uj(c|0,d|0,52)|0;switch(e&2047){case 0:{if(a!=0.0){g=+wg(a*18446744073709551616.0,b);h=g;i=(f[b>>2]|0)+-64|0}else{h=a;i=0}f[b>>2]=i;j=h;break}case 2047:{j=a;break}default:{f[b>>2]=(e&2047)+-1022;f[s>>2]=c;f[s+4>>2]=d&-2146435073|1071644672;j=+p[s>>3]}}return +j}function xg(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0;e=u;u=u+16|0;d=e;c=bj(32)|0;f[d>>2]=c;f[d+8>>2]=-2147483616;f[d+4>>2]=26;g=c;h=8360;i=g+26|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[c+26>>0]=0;f[a>>2]=-1;Rf(a+4|0,d);if((b[d+11>>0]|0)>=0){u=e;return}dn(f[d>>2]|0);u=e;return}function yg(a){a=a|0;var b=0,c=0;f[a>>2]=1628;b=f[a+96>>2]|0;if(b|0)dn(b);b=f[a+84>>2]|0;if(b|0)dn(b);b=f[a+72>>2]|0;if(b|0)dn(b);b=f[a+60>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function zg(a){a=a|0;var b=0,c=0;f[a>>2]=1376;b=f[a+96>>2]|0;if(b|0)dn(b);b=f[a+84>>2]|0;if(b|0)dn(b);b=f[a+72>>2]|0;if(b|0)dn(b);b=f[a+60>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function Ag(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2296;b=a+84|0;c=a+4|0;d=c+80|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=-1;f[a+88>>2]=-1;f[a+92>>2]=-1;b=a+152|0;c=a+96|0;d=c+56|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));n[b>>2]=$(1.0);b=a+224|0;c=a+156|0;d=c+68|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));Gi(b);return}function Bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=b+4|0;e=(f[d>>2]|0)-(f[b>>2]|0)|0;g=e>>2;if(!g)return;if(g>>>0>1073741823)um(a);h=bj(e)|0;f[c>>2]=h;f[a>>2]=h;f[a+8>>2]=h+(g<<2);g=f[b>>2]|0;b=(f[d>>2]|0)-g|0;if((b|0)<=0)return;ge(h|0,g|0,b|0)|0;f[c>>2]=h+(b>>>2<<2);return}function Cg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;a=f[b+4>>2]|0;if(!a){d=0;return d|0}e=f[(f[(f[b+8>>2]|0)+(c<<2)>>2]|0)+60>>2]|0;c=f[a+40>>2]|0;b=f[a+44>>2]|0;if((c|0)==(b|0)){d=0;return d|0}else g=c;while(1){c=f[g>>2]|0;g=g+4|0;if((f[c+40>>2]|0)==(e|0)){d=c;h=5;break}if((g|0)==(b|0)){d=0;h=5;break}}if((h|0)==5)return d|0;return 0}function Dg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=Na[f[(f[a>>2]|0)+24>>2]&127](a)|0;if((c|0)<=0){d=1;return d|0}e=a+36|0;g=a+48|0;a=0;while(1){h=f[(f[e>>2]|0)+(a<<2)>>2]|0;a=a+1|0;if(!(Pa[f[(f[h>>2]|0)+20>>2]&31](h,g,b)|0)){d=0;i=5;break}if((a|0)>=(c|0)){d=1;i=5;break}}if((i|0)==5)return d|0;return 0}function Eg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=a+8|0;d=f[a>>2]|0;if((f[c>>2]|0)-d>>2>>>0>=b>>>0)return;e=a+4|0;if(b>>>0>1073741823){g=ra(8)|0;Yk(g,9789);f[g>>2]=3704;va(g|0,856,80)}g=(f[e>>2]|0)-d|0;h=bj(b<<2)|0;if((g|0)>0)ge(h|0,d|0,g|0)|0;f[a>>2]=h;f[e>>2]=h+(g>>2<<2);f[c>>2]=h+(b<<2);if(!d)return;dn(d);return}function Fg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;switch(c<<24>>24){case 0:{c=bj(20)|0;dk(c);d=c;break}case 1:{c=bj(24)|0;Dk(c);d=c;break}case 2:{c=bj(36)|0;pj(c);d=c;break}case 3:{c=bj(28)|0;vk(c);d=c;break}default:d=0}f[a>>2]=d;return}function Gg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=Na[f[(f[a>>2]|0)+24>>2]&127](a)|0;if((c|0)<=0){d=1;return d|0}e=a+36|0;g=a+48|0;a=0;while(1){h=f[(f[e>>2]|0)+(a<<2)>>2]|0;a=a+1|0;if(!(Pa[f[(f[h>>2]|0)+16>>2]&31](h,g,b)|0)){d=0;i=5;break}if((a|0)>=(c|0)){d=1;i=5;break}}if((i|0)==5)return d|0;return 0}function Hg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=f[b>>2]|0;if(!c){d=0;return d|0}e=a+44|0;g=f[e>>2]|0;if(g>>>0<(f[a+48>>2]|0)>>>0){f[b>>2]=0;f[g>>2]=c;f[e>>2]=(f[e>>2]|0)+4;d=1;return d|0}else{Zd(a+40|0,b);d=1;return d|0}return 0}function Ig(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+24>>2]|0)){b=0;return b|0}if(!(f[a+28>>2]|0)){b=0;return b|0}if(!(f[a+32>>2]|0)){b=0;return b|0}if(!(f[a+36>>2]|0)){b=0;return b|0}b=(f[a+72>>2]|0)!=-1;return b|0}function Jg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2348;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}f[a+12>>2]=2372;b=f[a+32>>2]|0;if(b|0)dn(b);b=f[a+20>>2]|0;if(!b){dn(a);return}dn(b);dn(a);return}function Kg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0;f[c>>2]=2;d=a+4|0;a=c+8|0;e=f[a>>2]|0;g=(f[c+12>>2]|0)-e|0;if(g>>>0<4294967292){Xg(a,g+4|0,0);i=f[a>>2]|0}else i=e;e=i+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[e>>0]=g;b[e+1>>0]=g>>8;b[e+2>>0]=g>>16;b[e+3>>0]=g>>24;return}function Lg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2440;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}f[a+12>>2]=2420;b=f[a+32>>2]|0;if(b|0)dn(b);b=f[a+20>>2]|0;if(!b){dn(a);return}dn(b);dn(a);return}function Mg(a){a=a|0;var b=0;if(!(f[a+64>>2]|0)){b=0;return b|0}if(!(f[a+68>>2]|0)){b=0;return b|0}if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}if(!(f[a+56>>2]|0)){b=0;return b|0}b=(f[a+92>>2]|0)!=-1;return b|0}function Ng(a){a=a|0;var c=0;if(!a)return;c=a+28|0;if((b[c+11>>0]|0)<0)dn(f[c>>2]|0);_f(a+12|0,f[a+16>>2]|0);eg(a,f[a+4>>2]|0);dn(a);return}function Og(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2348;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}f[a+12>>2]=2372;b=f[a+32>>2]|0;if(b|0)dn(b);b=f[a+20>>2]|0;if(!b)return;dn(b);return}function Pg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;if(!a)return;c=f[a>>2]|0;if(c|0){d=a+4|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;if((b[e+11>>0]|0)<0){dn(f[e>>2]|0);i=f[d>>2]|0}else i=e;if((i|0)==(c|0))break;else h=i}g=f[a>>2]|0}dn(g)}dn(a);return}function Qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;Ib(a,b);if((b|0)<=-1)return;c=a+88|0;d=f[c>>2]|0;e=f[a+84>>2]|0;if((d-e>>2|0)<=(b|0))return;a=e+(b<<2)|0;b=a+4|0;e=d-b|0;g=e>>2;if(!g)h=d;else{qi(a|0,b|0,e|0)|0;h=f[c>>2]|0}e=a+(g<<2)|0;if((h|0)==(e|0))return;f[c>>2]=h+(~((h+-4-e|0)>>>2)<<2);return}function Rg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2440;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}f[a+12>>2]=2420;b=f[a+32>>2]|0;if(b|0)dn(b);b=f[a+20>>2]|0;if(!b)return;dn(b);return}function Sg(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0;a=c+16|0;g=f[a>>2]|0;do if(g){if((g|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;f[c+24>>2]=2;b[c+54>>0]=1;break}h=c+24|0;if((f[h>>2]|0)==2)f[h>>2]=e}else{f[a>>2]=d;f[c+24>>2]=e;f[c+36>>2]=1}while(0);return}function Tg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2668;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);dn(b)}b=f[a+84>>2]|0;if(!b){Td(a);dn(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b);Td(a);dn(a);return}function Ug(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;g=d>>31|((d|0)<0?-1:0)<<1;h=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;i=Tj(e^a|0,f^b|0,e|0,f|0)|0;b=I;a=g^e;e=h^f;return Tj((gc(i,b,Tj(g^c|0,h^d|0,g|0,h|0)|0,I,0)|0)^a|0,I^e|0,a|0,e|0)|0}function Vg(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;f[a>>2]=b;h=b+16|0;i=f[h+4>>2]|0;j=a+8|0;f[j>>2]=f[h>>2];f[j+4>>2]=i;i=b+24|0;b=f[i+4>>2]|0;j=a+16|0;f[j>>2]=f[i>>2];f[j+4>>2]=b;b=a+40|0;f[b>>2]=c;f[b+4>>2]=d;d=a+48|0;f[d>>2]=e;f[d+4>>2]=g;return}function Wg(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0;c=b[a+12>>0]|0;d=a+8|0;e=f[d>>2]|0;if(e>>>0<4096?(g=a+4|0,i=f[g>>2]|0,(i|0)>0):0){j=f[a>>2]|0;a=i+-1|0;f[g>>2]=a;g=e<<8|(h[j+a>>0]|0);f[d>>2]=g;k=g}else k=e;e=k&255;g=0-c&255;c=X(k>>>8,g)|0;a=e>>>0>>0;f[d>>2]=a?c+e|0:k-g-c|0;return a|0}function Xg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;h=e;e=d;if(g>>>0>=b>>>0){if(g>>>0>b>>>0?(d=h+b|0,(d|0)!=(e|0)):0)f[c>>2]=d}else jf(a,b-g|0);g=a+24|0;a=g;b=Rj(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=g;f[a>>2]=b;f[a+4>>2]=I;return}function Yg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;xg(g,a,c,d);d=a+24|0;f[d>>2]=f[g>>2];c=g+4|0;hi(a+28|0,c)|0;if((b[c+11>>0]|0)>=0){u=e;return d|0}dn(f[c>>2]|0);u=e;return d|0}function Zg(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2668;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);dn(b)}b=f[a+84>>2]|0;if(!b){Td(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);dn(b);Td(a);return}function _g(a){a=a|0;var c=0,d=0,e=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=1;c=a+68|0;d=a+28|0;e=d+40|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(e|0));f[c>>2]=a;c=a+72|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;return}function $g(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;md(g,a,c,d);d=a+24|0;f[d>>2]=f[g>>2];c=g+4|0;hi(a+28|0,c)|0;if((b[c+11>>0]|0)>=0){u=e;return d|0}dn(f[c>>2]|0);u=e;return d|0}function ah(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;if(c?!(Ff(d,a)|0):0){e=0;return e|0}b[a+36>>0]=1;d=a+16|0;c=f[d>>2]|0;g=(f[a>>2]|0)+c|0;h=a+8|0;i=Tj(f[h>>2]|0,f[h+4>>2]|0,c|0,f[d+4>>2]|0)|0;f[a+32>>2]=0;f[a+24>>2]=g;f[a+28>>2]=g+i;e=1;return e|0}function bh(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1684;b=f[a+76>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function ch(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=u;u=u+256|0;g=f;if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;Vf(g|0,b<<24>>24|0,(e>>>0<256?e:256)|0)|0;if(e>>>0>255){b=c-d|0;d=e;do{il(a,g,256);d=d+-256|0}while(d>>>0>255);h=b&255}else h=e;il(a,g,h)}u=f;return}function dh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0;b=f[a+8>>2]|0;c=f[a+12>>2]|0;if((b|0)==(c|0)){d=1;return d|0}e=a+32|0;a=b;while(1){b=f[a>>2]|0;a=a+4|0;if(!(Oa[f[(f[b>>2]|0)+16>>2]&127](b,f[e>>2]|0)|0)){d=0;g=5;break}if((a|0)==(c|0)){d=1;g=5;break}}if((g|0)==5)return d|0;return 0}function eh(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1432;b=f[a+76>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function fh(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;if(zl(a,f[b+8>>2]|0,g)|0)Tf(0,b,c,d,e);else{h=f[a+8>>2]|0;Xa[f[(f[h>>2]|0)+20>>2]&3](h,b,c,d,e,g)}return}function gh(a,b){a=a|0;b=b|0;var c=0;c=bj(40)|0;f[c>>2]=-1;oj(c+8|0);Ta[f[(f[a>>2]|0)+16>>2]&7](a,c);a=b+88|0;b=f[a>>2]|0;f[a>>2]=c;if(!b)return 1;c=f[b+8>>2]|0;if(c|0){a=b+12|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;dn(c)}dn(b);return 1}function hh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+12>>2]|0;d=f[a+8>>2]|0;a=d;if((c|0)==(d|0)){e=0;return e|0}g=c-d>>2;d=0;while(1){c=f[a+(d<<2)>>2]|0;if((f[c+60>>2]|0)==(b|0)){e=c;h=5;break}d=d+1|0;if(d>>>0>=g>>>0){e=0;h=5;break}}if((h|0)==5)return e|0;return 0}function ih(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+12>>2]|0;d=f[a+8>>2]|0;a=d;if((c|0)==(d|0)){e=-1;return e|0}g=c-d>>2;d=0;while(1){if((f[(f[a+(d<<2)>>2]|0)+60>>2]|0)==(b|0)){e=d;h=5;break}d=d+1|0;if(d>>>0>=g>>>0){e=-1;h=5;break}}if((h|0)==5)return e|0;return 0}function jh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;a:do if(!d)e=0;else{f=a;g=d;h=c;while(1){i=b[f>>0]|0;j=b[h>>0]|0;if(i<<24>>24!=j<<24>>24)break;g=g+-1|0;if(!g){e=0;break a}else{f=f+1|0;h=h+1|0}}e=(i&255)-(j&255)|0}while(0);return e|0}function kh(a){a=a|0;var b=0,c=0;f[a>>2]=1684;b=f[a+76>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function lh(a){a=a|0;var b=0,c=0;f[a>>2]=2108;b=a+28|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)bn(c);f[a>>2]=1148;c=a+20|0;b=f[c>>2]|0;f[c>>2]=0;if(!b){Yf(a);dn(a);return}Sa[f[(f[b>>2]|0)+4>>2]&127](b);Yf(a);dn(a);return}function mh(a){a=a|0;var c=0,d=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;c=0;while(1){if((c|0)==3)break;f[a+(c<<2)>>2]=0;c=c+1|0}if((b[a+11>>0]|0)<0)d=(f[a+8>>2]&2147483647)+-1|0;else d=10;hg(a,d,0);return}function nh(a){a=a|0;var b=0,c=0;f[a>>2]=1432;b=f[a+76>>2]|0;if(b|0)dn(b);f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function oh(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=984;b=f[a+16>>2]|0;if(b|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}b=f[a+4>>2]|0;if(!b)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(b|0))f[d>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function ph(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1740;f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function qh(a){a=a|0;var b=0,c=0;f[a>>2]=2108;b=a+28|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)bn(c);f[a>>2]=1148;c=a+20|0;b=f[c>>2]|0;f[c>>2]=0;if(!b){Yf(a);return}Sa[f[(f[b>>2]|0)+4>>2]&127](b);Yf(a);return}function rh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(zl(a,f[b+8>>2]|0,0)|0)Sg(0,b,c,d);else{e=f[a+8>>2]|0;Va[f[(f[e>>2]|0)+28>>2]&7](e,b,c,d)}return}function sh(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Oa[f[(f[d>>2]|0)+32>>2]&127](d,b)|0;return c|0}function th(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0;d=b[a>>0]|0;e=b[c>>0]|0;if(d<<24>>24==0?1:d<<24>>24!=e<<24>>24){f=e;g=d}else{d=c;c=a;do{c=c+1|0;d=d+1|0;a=b[c>>0]|0;e=b[d>>0]|0}while(!(a<<24>>24==0?1:a<<24>>24!=e<<24>>24));f=e;g=a}return (g&255)-(f&255)|0}function uh(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1488;f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function vh(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;mh(d);of(a,d,b);Ik(d);u=c;return}function wh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;d=u;u=u+32|0;e=d;g=d+20|0;f[e>>2]=f[a+60>>2];f[e+4>>2]=0;f[e+8>>2]=b;f[e+12>>2]=g;f[e+16>>2]=c;if((ik(za(140,e|0)|0)|0)<0){f[g>>2]=-1;h=-1}else h=f[g>>2]|0;u=d;return h|0}function xh(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=0;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=0;return c|0}b=f[d>>2]|0;if((b|0)==-1){c=0;return c|0}c=f[(f[a+8>>2]|0)+(b<<2)>>2]|0;return c|0}function yh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}d=Je(f[(f[a+36>>2]|0)+(e<<2)>>2]|0)|0;return d|0}function zh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(!($f(f[a+8>>2]|0,(f[b+4>>2]|0)-(f[b>>2]|0)>>2)|0)){d=0;return d|0}d=Pa[f[(f[a>>2]|0)+32>>2]&31](a,b,c)|0;return d|0}function Ah(a,b){a=a|0;b=b|0;var c=0;Ki(a);f[a>>2]=1088;c=a+36|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;c=f[b>>2]|0;f[b>>2]=0;f[a+60>>2]=c;return}function Bh(a){a=a|0;var b=0,c=0;f[a>>2]=1740;f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function Ch(a){a=a|0;if(!(f[a+60>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function Dh(a){a=a|0;var b=0,c=0;f[a>>2]=1488;f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function Eh(a,c){a=a|0;c=c|0;var d=0,e=0;d=a;e=c;c=d+64|0;do{f[d>>2]=f[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(c|0));e=a+64|0;f[a+88>>2]=0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[e+12>>2]=0;f[e+16>>2]=0;b[e+20>>0]=0;return}function Fh(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;if((a|0)==0&(c|0)==0)f=d;else{g=d;d=c;c=a;while(1){a=g+-1|0;b[a>>0]=h[10394+(c&15)>>0]|0|e;c=Uj(c|0,d|0,4)|0;d=I;if((c|0)==0&(d|0)==0){f=a;break}else g=a}}return f|0}function Gh(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=f[a>>2]|0;if(!(d&8)){f[a+8>>2]=0;f[a+4>>2]=0;c=f[a+44>>2]|0;f[a+28>>2]=c;f[a+20>>2]=c;f[a+16>>2]=c+(f[a+48>>2]|0);e=0}else{f[a>>2]=d|32;e=-1}return e|0}function Hh(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[b+88>>2]|0;if(!c){d=0;return d|0}if((f[c>>2]|0)!=2){d=0;return d|0}b=f[c+8>>2]|0;f[a+4>>2]=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;d=1;return d|0}function Ih(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}b=(f[a+56>>2]|0)!=0;return b|0}function Jh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=b[a+11>>0]|0;e=d<<24>>24<0;if(e)g=f[a+4>>2]|0;else g=d&255;if(g>>>0<=c>>>0)um(a);if(e)h=f[a>>2]|0;else h=a;return h+c|0}function Kh(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+44>>2]=c;d=1;return d|0}function Lh(a,b,c){a=a|0;b=b|0;c=c|0;if((b|0)!=0&(c|0)!=0){Lb(a,b,c);return}else{Pb(a,0,0);return}}function Mh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=$(e);f[a+4>>2]=b;pd(a+8|0,c,c+(d<<2)|0);n[a+20>>2]=e;return}function Nh(a,b){a=a|0;b=b|0;var c=0;if(!(Oa[f[(f[a>>2]|0)+36>>2]&127](a,b)|0)){c=0;return c|0}if(!(Oa[f[(f[a>>2]|0)+40>>2]&127](a,b)|0)){c=0;return c|0}c=Na[f[(f[a>>2]|0)+44>>2]&127](a)|0;return c|0}function Oh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;d=f[c>>2]|0;c=a;e=b-a>>2;while(1){if(!e)break;a=(e|0)/2|0;b=c+(a<<2)|0;g=(f[b>>2]|0)>>>0>>0;c=g?b+4|0:c;e=g?e+-1-a|0:a}return c|0}function Ph(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if(!(xj(a,c,d)|0)){e=0;return e|0}d=f[a+8>>2]|0;if((b[d+24>>0]|0)!=3){e=0;return e|0}e=(f[d+28>>2]|0)==9;return e|0}function Qh(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;b[a+24>>0]=1;f[a+28>>2]=9;c=a+40|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[a+56>>2]=-1;f[a+60>>2]=0;return}function Rh(a,c){a=a|0;c=c|0;var d=0,e=0;a=u;u=u+32|0;d=a;Mf(d,c);c=f[d+16>>2]|0;e=d+4|0;if((b[e+11>>0]|0)>=0){u=a;return c|0}dn(f[e>>2]|0);u=a;return c|0}function Sh(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;if(!(Om(b[f[a>>2]>>0]|0)|0))c=0;else{d=0;while(1){e=f[a>>2]|0;g=(d*10|0)+-48+(b[e>>0]|0)|0;h=e+1|0;f[a>>2]=h;if(!(Om(b[h>>0]|0)|0)){c=g;break}else d=g}}return c|0}function Th(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+64>>2]=c;d=1;return d|0}function Uh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if(!(xj(a,b,c)|0)){d=0;return d|0}d=(f[(f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0)+28>>2]|0)==9;return d|0}function Vh(a){a=a|0;var b=0,c=0;b=f[r>>2]|0;c=b+a|0;if((a|0)>0&(c|0)<(b|0)|(c|0)<0){ea()|0;ya(12);return -1}f[r>>2]=c;if((c|0)>(da()|0)?(ca()|0)==0:0){f[r>>2]=b;ya(12);return -1}return b|0}function Wh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;if((a|0)==0&(c|0)==0)e=d;else{f=d;d=c;c=a;while(1){a=f+-1|0;b[a>>0]=c&7|48;c=Uj(c|0,d|0,3)|0;d=I;if((c|0)==0&(d|0)==0){e=a;break}else f=a}}return e|0}function Xh(a,c){a=a|0;c=c|0;var d=0;if(((c|0)!=0?(f[c+56>>2]|0)==0:0)?(b[c+24>>0]|0)==3:0){f[a+60>>2]=c;d=1}else d=0;return d|0}function Yh(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1208;b=f[a+32>>2]|0;if(!b){dn(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function Zh(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;if(zl(a,f[b+8>>2]|0,g)|0)Tf(0,b,c,d,e);return}function _h(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+56>>2]|0)-(f[e+52>>2]|0)>>2;b[d>>0]=0;le(a+20|0,g,d);u=c;return}function $h(a,b,c){a=a|0;b=b|0;c=c|0;return Sb(a,b,c)|0}function ai(a){a=a|0;var b=0;switch(a|0){case 11:case 2:case 1:{b=1;break}case 4:case 3:{b=2;break}case 6:case 5:{b=4;break}case 8:case 7:{b=8;break}case 9:{b=4;break}case 10:{b=8;break}default:b=-1}return b|0}function bi(a){a=a|0;var c=0,d=0,e=0;b[a+36>>0]=0;c=Rj(f[a+32>>2]|0,0,7,0)|0;d=Uj(c|0,I|0,3)|0;c=a+16|0;a=c;e=Rj(d|0,I|0,f[a>>2]|0,f[a+4>>2]|0)|0;a=c;f[a>>2]=e;f[a+4>>2]=I;return}function ci(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+28>>2]|0)-(f[e+24>>2]|0)>>2;b[d>>0]=0;le(a+20|0,g,d);u=c;return}function di(a){a=a|0;var b=0,c=0,d=0;b=a+60|0;c=a;d=c+60|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(d|0));f[b>>2]=a;b=a+64|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function ei(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=(f[a+96>>2]|0)+(b*12|0)|0;rd(c,d,d+12|0);return 1}function fi(){var a=0,b=0;a=bj(40)|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[a+16>>2]=$(1.0);b=a+20|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;n[a+36>>2]=$(1.0);return a|0}function gi(a){a=a|0;f[a>>2]=2396;wf(a+8|0);dn(a);return}function hi(a,c){a=a|0;c=c|0;var d=0,e=0;if((a|0)!=(c|0)){d=b[c+11>>0]|0;e=d<<24>>24<0;Kf(a,e?f[c>>2]|0:c,e?f[c+4>>2]|0:d&255)|0}return a|0}function ii(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=a&65535;d=b&65535;e=X(d,c)|0;f=a>>>16;a=(e>>>16)+(X(d,f)|0)|0;d=b>>>16;b=X(d,c)|0;return (I=(a>>>16)+(X(d,f)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|e&65535|0)|0}function ji(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=gg(b)|0;d=bj(c+13|0)|0;f[d>>2]=c;f[d+4>>2]=c;f[d+8>>2]=0;e=Zl(d)|0;ge(e|0,b|0,c+1|0)|0;f[a>>2]=e;return}function ki(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=-1;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=-1;return c|0}c=f[d>>2]|0;return c|0}function li(a){a=a|0;f[a>>2]=2396;wf(a+8|0);return}function mi(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f[b+44>>2]=e;Tb(a,b,c,d,e);return}function ni(a){a=a|0;var b=0,c=0;f[a>>2]=1208;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function oi(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(zl(a,f[b+8>>2]|0,0)|0)Sg(0,b,c,d);return}function pi(a){a=a|0;var b=0;f[a>>2]=2616;b=a+4|0;f[a+40>>2]=0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;f[b+24>>2]=0;f[b+28>>2]=0;d[b+32>>1]=0;return}function qi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if((c|0)<(a|0)&(a|0)<(c+d|0)){e=a;c=c+d|0;a=a+d|0;while((d|0)>0){a=a-1|0;c=c-1|0;d=d-1|0;b[a>>0]=b[c>>0]|0}a=e}else ge(a,c,d)|0;return a|0}function ri(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=956;b=f[a+8>>2]|0;if(!b){dn(a);return}c=a+12|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b);dn(a);return}function si(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=u;u=u+16|0;e=d;f[e>>2]=f[c>>2];g=Pa[f[(f[a>>2]|0)+16>>2]&31](a,b,e)|0;if(g)f[c>>2]=f[e>>2];u=d;return g&1|0}function ti(a,b){a=a|0;b=b|0;var c=0;if(b>>>0>=2){c=0;return c|0}f[a+28>>2]=b;c=1;return c|0}function ui(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if((b|0)>0)d=0;else return;do{e=f[a+(d<<2)>>2]|0;f[c+(d<<2)>>2]=e<<31>>31^e>>>1;d=d+1|0}while((d|0)!=(b|0));return}function vi(){var a=0,b=0;a=ej()|0;if((a|0?(b=f[a>>2]|0,b|0):0)?(a=b+48|0,(f[a>>2]&-256|0)==1126902528?(f[a+4>>2]|0)==1129074247:0):0)Rk(f[b+12>>2]|0);Rk(lm()|0)}function wi(a){a=a|0;var c=0;c=b[w+(a&255)>>0]|0;if((c|0)<8)return c|0;c=b[w+(a>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=b[w+(a>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (b[w+(a>>>24)>>0]|0)+24|0}function xi(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);dn(b)}dn(a);return}function yi(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-2-b|0)>>>1)<<1);dn(b)}dn(a);return}function zi(a,c){a=a|0;c=c|0;var d=0;b[c+84>>0]=1;a=f[c+68>>2]|0;d=c+72|0;c=f[d>>2]|0;if((c|0)==(a|0))return 1;f[d>>2]=c+(~((c+-4-a|0)>>>2)<<2);return 1}function Ai(a){a=a|0;var b=0,c=0;if(Im(a)|0?(b=dm(f[a>>2]|0)|0,a=b+8|0,c=f[a>>2]|0,f[a>>2]=c+-1,(c+-1|0)<0):0)dn(b);return}function Bi(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;d[a+38>>1]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;f[c+24>>2]=0;b[c+28>>0]=0;return}function Ci(a){a=a|0;var b=0,c=0;f[a>>2]=1148;b=a+20|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Sa[f[(f[c>>2]|0)+4>>2]&127](c);Yf(a);dn(a);return}function Di(a,b){a=a|0;b=b|0;return Oa[f[(f[a>>2]|0)+48>>2]&127](a,(f[b+4>>2]|0)-(f[b>>2]|0)>>2)|0}function Ei(a){a=a|0;var b=0,c=0;f[a>>2]=956;b=f[a+8>>2]|0;if(!b)return;c=a+12|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);dn(b);return}function Fi(a,b,c){a=a|0;b=b|0;c=c|0;xb(a,b,c);return}function Gi(a){a=a|0;Bi(a);Bi(a+40|0);Cm(a+80|0);Bi(a+96|0);f[a+136>>2]=0;f[a+140>>2]=0;f[a+144>>2]=0;return}function Hi(a){a=a|0;var b=0,c=0;f[a>>2]=1148;b=a+20|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Sa[f[(f[c>>2]|0)+4>>2]&127](c);Yf(a);return}function Ii(a,b,c){a=a|0;b=b|0;c=c|0;return wc(a,b,5,6,c)|0}function Ji(a,b,c){a=a|0;b=b|0;c=c|0;return uc(a,b,3,4,c)|0}function Ki(a){a=a|0;var b=0;f[a>>2]=984;b=a+4|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;f[b+24>>2]=0;f[b+28>>2]=0;return}function Li(a,b,c){a=a|0;b=b|0;c=c|0;return zc(a,b,1,2,c)|0}function Mi(a,b,c){a=a|0;b=b|0;c=c|0;return vc(a,b,3,4,c)|0}function Ni(a,b,c){a=a|0;b=b|0;c=c|0;return xc(a,b,5,6,c)|0}function Oi(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=a+20|0;e=f[d>>2]|0;g=(f[a+16>>2]|0)-e|0;a=g>>>0>c>>>0?c:g;ge(e|0,b|0,a|0)|0;f[d>>2]=(f[d>>2]|0)+a;return c|0}function Pi(a,b,c){a=a|0;b=b|0;c=c|0;return Ac(a,b,1,2,c)|0}function Qi(a){a=a|0;var b=0;f[a>>2]=2372;b=f[a+20>>2]|0;if(b|0)dn(b);b=f[a+8>>2]|0;if(!b){dn(a);return}dn(b);dn(a);return}function Ri(){var a=0,b=0;a=bj(24)|0;f[a>>2]=956;f[a+4>>2]=-1;b=a+8|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return a|0}function Si(a){a=a|0;var c=0;Qh(a);c=a+64|0;f[a+88>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;b[c+20>>0]=0;return}function Ti(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a+8>>2]|0;if(b|0){c=a+12|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;dn(b)}dn(a);return}function Ui(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((f[b+4>>2]|0)==(c|0)?(c=b+28|0,(f[c>>2]|0)!=1):0)f[c>>2]=d;return}function Vi(a){a=a|0;var b=0;f[a>>2]=2420;b=f[a+20>>2]|0;if(b|0)dn(b);b=f[a+8>>2]|0;if(!b){dn(a);return}dn(b);dn(a);return}function Wi(a,b,c,e){a=a|0;b=b|0;c=c|0;e=e|0;f[a>>2]=b;b=a+8|0;f[b>>2]=c;f[b+4>>2]=0;d[a+38>>1]=e;e=a+16|0;f[e>>2]=0;f[e+4>>2]=0;return}function Xi(a,b,c){a=a|0;b=$(b);c=c|0;var d=0,e=La;if((c|0)<1){d=0;return d|0}e=$($(1.0)/$(c|0));n[a+4>>2]=e;n[a>>2]=b;d=1;return d|0}function Yi(a,b,c){a=a|0;b=b|0;c=c|0;f[a+4>>2]=b;f[a+8>>2]=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2];f[a+12>>2]=c;return 1}function Zi(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;dn(b)}dn(a);return}function _i(a){a=a|0;var b=0;Gl(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;b=a+24|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function $i(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e|0;gc(a,b,c,d,g)|0;u=e;return (I=f[g+4>>2]|0,f[g>>2]|0)|0}function aj(a){a=a|0;var b=0;Yj(a);f[a>>2]=2668;b=a+84|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function bj(a){a=a|0;var b=0,c=0;b=(a|0)==0?1:a;while(1){a=Ya(b)|0;if(a|0){c=a;break}a=fm()|0;if(!a){c=0;break}Ra[a&3]()}return c|0}function cj(a){a=a|0;var b=0;f[a>>2]=2372;b=f[a+20>>2]|0;if(b|0)dn(b);b=f[a+8>>2]|0;if(!b)return;dn(b);return}function dj(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;d=fn(f[a+60>>2]|0)|0;f[c>>2]=d;d=ik(Ba(6,c|0)|0)|0;u=b;return d|0}function ej(){var a=0,b=0;a=u;u=u+16|0;if(!(Ha(13444,3)|0)){b=Fa(f[3362]|0)|0;u=a;return b|0}else zj(12582,a);return 0}function fj(a){a=a|0;var b=0;f[a>>2]=2420;b=f[a+20>>2]|0;if(b|0)dn(b);b=f[a+8>>2]|0;if(!b)return;dn(b);return}function gj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;a=c;c=ii(e,a)|0;f=I;return (I=(X(b,a)|0)+(X(d,e)|0)+f|f&0,c|0|0)|0}function hj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ii(b,c,d)|0}function ij(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ji(b,c,d)|0}function jj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return bd(b,c,d)|0}function kj(a){a=a|0;var b=0;b=u;u=u+16|0;Cb(a);if(!(Ia(f[3362]|0,0)|0)){u=b;return}else zj(12681,b)}function lj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Li(b,c,d)|0}function mj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Mi(b,c,d)|0}function nj(a){a=a|0;f[a>>2]=1940;dn(a);return}function oj(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function pj(a){a=a|0;Dk(a);f[a>>2]=2108;f[a+24>>2]=-1;f[a+28>>2]=0;n[a+32>>2]=$(0.0);return}function qj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Pi(b,c,d)|0}function rj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ni(b,c,d)|0}function sj(a,b,c){a=a|0;b=b|0;c=c|0;f[a>>2]=b;b=a+8|0;f[b>>2]=c;f[b+4>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;return}function tj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;f[g>>2]=d;d=Af(a,b,c,g)|0;u=e;return d|0}function uj(a){a=a|0;f[a>>2]=2024;dn(a);return}function vj(a){a=a|0;f[a>>2]=1940;return}function wj(a,b,c){a=a|0;b=b|0;c=c|0;return 1}function xj(a,b,c){a=a|0;b=b|0;c=c|0;return Yi(a,b,c)|0}function yj(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Qa[a&15](b|0,c|0,d|0,e|0,f|0,g|0)|0}function zj(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;f[d>>2]=b;b=f[678]|0;ye(b,a,d)|0;lg(10,b)|0;Ca()}function Aj(a){a=a|0;f[a>>2]=2024;return}function Bj(a,b){a=a|0;b=b|0;var c=0;c=f[a+48>>2]|0;return Oa[f[(f[c>>2]|0)+16>>2]&127](c,b)|0}function Cj(a,b,c){a=a|0;b=b|0;c=c|0;return ki(b,c)|0}function Dj(a,b){a=a|0;b=b|0;var c=0;c=f[a+48>>2]|0;return Oa[f[(f[c>>2]|0)+12>>2]&127](c,b)|0}function Ej(a,b){a=a|0;b=b|0;var c=0;c=f[a+48>>2]|0;return Oa[f[(f[c>>2]|0)+20>>2]&127](c,b)|0}function Fj(a){a=a|0;var c=0,d=0;c=a+4|0;if((b[c+11>>0]|0)<0){d=f[c>>2]|0;return d|0}else{d=c;return d|0}return 0}function Gj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Id(b,c,d)|0}function Hj(){var a=0;a=u;u=u+16|0;if(!(Ga(13448,83)|0)){u=a;return}else zj(12631,a)}function Ij(a){a=a|0;Pc(a);dn(a);return}function Jj(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;Xa[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Kj(a){a=a|0;if(!(f[a+44>>2]|0))return 0;else return Na[f[(f[a>>2]|0)+48>>2]&127](a)|0;return 0}function Lj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(b,c,d)|0}function Mj(a,b,c){a=a|0;b=b|0;c=c|0;if(b|0)Vf(a|0,(Dm(c)|0)&255|0,b|0)|0;return a|0}function Nj(a){a=a|0;return 4}function Oj(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b<>>32-c;return a<>0]|0)<0)dn(f[c>>2]|0);dn(a);return}function Qj(){}function Rj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=a+c>>>0;return (I=b+d+(e>>>0>>0|0)>>>0,e|0)|0}function Sj(a,b){a=a|0;b=b|0;var c=0;if(!b)c=0;else c=Ce(f[b>>2]|0,f[b+4>>2]|0,a)|0;return (c|0?c:a)|0}function Tj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=b-d>>>0;e=b-d-(c>>>0>a>>>0|0)>>>0;return (I=e,a-c>>>0|0)|0}function Uj(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b>>>c;return a>>>c|(b&(1<>>c-32|0}function Vj(a,b,c){a=a|0;b=b|0;c=c|0;return Yg(a,b,c)|0}function Wj(a){a=a|0;Jc(a);dn(a);return}function Xj(a){a=a|0;return 5}function Yj(a){a=a|0;var b=0;f[a>>2]=2696;b=a+4|0;a=b+80|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function Zj(a){a=a|0;return 6}function _j(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ei(b,c,d)|0}function $j(a,b,c){a=a|0;b=b|0;c=c|0;f[a+28>>2]=b;f[a+32>>2]=c;return 1}function ak(a,b,c){a=a|0;b=b|0;c=c|0;return Cj(a,b,c)|0}function bk(a){a=a|0;var b=0;b=f[a+48>>2]|0;return Na[f[(f[b>>2]|0)+28>>2]&127](b)|0}function ck(a,b,c){a=a|0;b=b|0;c=c|0;return Cd(b,c)|0}function dk(a){a=a|0;f[a>>2]=1040;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=-1;f[a+16>>2]=0;return}function ek(a){a=a|0;var b=0;b=f[a+48>>2]|0;return Na[f[(f[b>>2]|0)+24>>2]&127](b)|0}function fk(a,b){a=a|0;b=b|0;ng(a,b);return}function gk(a){a=a|0;var b=0;b=f[a+48>>2]|0;return Na[f[(f[b>>2]|0)+36>>2]&127](b)|0}function hk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Wa[a&3](b|0,c|0,d|0,e|0,f|0)}function ik(a){a=a|0;var b=0,c=0;if(a>>>0>4294963200){b=ln()|0;f[b>>2]=0-a;c=-1}else c=a;return c|0}function jk(a,b,c){a=a|0;b=b|0;c=c|0;return $g(a,b,c)|0}function kk(a,b,c){a=a|0;b=b|0;c=c|0;return nf(a,b,c)|0}function lk(a,b,c){a=a|0;b=b|0;c=c|0;return Df(a,b,c)|0}function mk(a,b,c){a=a|0;b=b|0;c=c|0;return We(a,b,c)|0}function nk(a,b,c){a=a|0;b=b|0;c=c|0;return +(+zf(a,b,c))}function ok(a,b){a=a|0;b=b|0;return Oa[f[(f[a>>2]|0)+12>>2]&127](a,b)|0}function pk(a,b){a=a|0;b=b|0;return Oa[f[(f[a>>2]|0)+56>>2]&127](a,b)|0}function qk(a,b,c){a=a|0;b=b|0;c=c|0;return Cg(a,b,c)|0}function rk(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return 1}function sk(a,b,c){a=a|0;b=b|0;c=c|0;return Kk(b,c)|0}function tk(a,b,c){a=a|0;b=b|0;c=c|0;return Ef(a,b,c)|0}function uk(a,b,c){a=a|0;b=b|0;c=c|0;return Bf(a,b,c)|0}function vk(a){a=a|0;Dk(a);f[a>>2]=1824;f[a+24>>2]=-1;return}function wk(a,b){a=a|0;b=b|0;f[a+8>>2]=b;f[a+12>>2]=-1;return 1}function xk(a,b,c){a=a|0;b=b|0;c=c|0;return ne(a,b,c)|0}function yk(a,b,c){a=a|0;b=b|0;c=c|0;return He(b,c)|0}function zk(a){a=+a;var b=0;p[s>>3]=a;b=f[s>>2]|0;I=f[s+4>>2]|0;return b|0}function Ak(){var a=0;a=bj(40)|0;f[a>>2]=-1;oj(a+8|0);return a|0}function Bk(){var a=0;a=bj(8)|0;f[a>>2]=928;f[a+4>>2]=-1;return a|0}function Ck(a,b,c){a=a|0;b=b|0;c=c|0;return hf(a,b,c)|0}function Dk(a){a=a|0;dk(a);f[a>>2]=1148;f[a+20>>2]=0;return}function Ek(a,b){a=a|0;b=b|0;fk(a,b);return}function Fk(a){a=a|0;var b=0;if(!a)b=0;else b=(De(a,800,888,0)|0)!=0&1;return b|0}function Gk(a,b){a=a|0;b=b|0;return $(n[(f[a+8>>2]|0)+(b<<2)>>2])}function Hk(a,b){a=a|0;b=b|0;return Rh(a,b)|0}function Ik(a){a=a|0;if((b[a+11>>0]|0)<0)dn(f[a>>2]|0);return}function Jk(a){a=a|0;if(!a)return;Sa[f[(f[a>>2]|0)+4>>2]&127](a);return}function Kk(a,b){a=a|0;b=b|0;return hh(a,b)|0}function Lk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Va[a&7](b|0,c|0,d|0,e|0)}function Mk(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)qi(a|0,b|0,c|0)|0;return a|0}function Nk(a,b,c){a=a|0;b=b|0;c=c|0;return Zk(b,c)|0}function Ok(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)ge(a|0,b|0,c|0)|0;return a|0}function Pk(a,b){a=a|0;b=b|0;return -1}function Qk(a){a=a|0;return 3}function Rk(a){a=a|0;var b=0;b=u;u=u+16|0;Ra[a&3]();zj(12734,b)}function Sk(a,b){a=a|0;b=b|0;return Ml(a,b)|0}function Tk(a){a=a|0;Pe(a);dn(a);return}function Uk(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;return}function Vk(a){a=a|0;dl(a);f[a>>2]=2236;f[a+48>>2]=0;return}function Wk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Pa[a&31](b|0,c|0,d|0)|0}function Xk(a,b,c){a=a|0;b=b|0;c=c|0;sj(a,b,c);return}function Yk(a,b){a=a|0;b=b|0;f[a>>2]=3684;ji(a+4|0,b);return}function Zk(a,b){a=a|0;b=b|0;return f[(f[a+8>>2]|0)+(b<<2)>>2]|0}function _k(a,b){a=a|0;b=b|0;var c=0;if(!a)c=0;else c=vf(a,b,0)|0;return c|0}function $k(a,b){a=a|0;b=b|0;return f[(f[a+4>>2]|0)+(b<<2)>>2]|0}function al(){var a=0;a=bj(64)|0;Qh(a);return a|0}function bl(a,b){a=a|0;b=b|0;return $(hl(a,b))}function cl(a){a=a|0;return f[a+8>>2]|0}function dl(a){a=a|0;pi(a);f[a>>2]=2176;f[a+44>>2]=0;return}function el(a){a=a|0;if(!a)return;Cf(a);dn(a);return}function fl(a,b){a=a|0;b=b|0;return Ul(a,b)|0}function gl(a){a=a|0;return b[(f[a+8>>2]|0)+24>>0]|0}function hl(a,b){a=a|0;b=b|0;return $(n[(f[a>>2]|0)+(b<<2)>>2])}function il(a,b,c){a=a|0;b=b|0;c=c|0;if(!(f[a>>2]&32))Xe(b,c,a)|0;return}function jl(a){a=a|0;return (f[a+8>>2]|0)-(f[a+4>>2]|0)>>2|0}function kl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ua[a&7](b|0,c|0,d|0)}function ll(){var a=0;a=bj(96)|0;Si(a);return a|0}function ml(a){a=a|0;var b=0;b=u;u=u+a|0;u=u+15&-16;return b|0}function nl(a){a=a|0;var b=0;b=(Zm()|0)+188|0;return vg(a,f[b>>2]|0)|0}function ol(a){a=a|0;return ((f[a+100>>2]|0)-(f[a+96>>2]|0)|0)/12|0|0}function pl(){var a=0;a=bj(16)|0;Uk(a);return a|0}function ql(){var a=0;a=bj(40)|0;Bi(a);return a|0}function rl(a,b){a=a|0;b=b|0;return 1}function sl(a,b){a=a|0;b=b|0;return Cl(a,b)|0}function tl(a,b){a=a|0;b=b|0;return Dl(a,b)|0}function ul(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(3);return 0}function vl(a,b){a=a|0;b=b|0;return Sl(a,b)|0}function wl(){var a=0;a=bj(12)|0;Kl(a);return a|0}function xl(a){a=a|0;Yf(a);dn(a);return}function yl(a){a=a|0;n[a>>2]=$(1.0);n[a+4>>2]=$(1.0);return}function zl(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function Al(a,b){a=a|0;b=b|0;var c=0;c=Pl(a|0)|0;return ((b|0)==0?a:c)|0}function Bl(a){a=a|0;return (f[a+12>>2]|0)-(f[a+8>>2]|0)>>2|0}function Cl(a,b){a=a|0;b=b|0;return f[(f[a>>2]|0)+(b<<2)>>2]|0}function Dl(a,b){a=a|0;b=b|0;return d[(f[a>>2]|0)+(b<<1)>>1]|0}function El(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return}function Fl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return gc(a,b,c,d,0)|0}function Gl(a){a=a|0;f[a+4>>2]=0;f[a+8>>2]=0;f[a>>2]=a+4;return}function Hl(){var a=0;a=bj(84)|0;Yj(a);return a|0}function Il(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)>>2|0}function Jl(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)>>1|0}function Kl(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;return}function Ll(a){a=a|0;f[a>>2]=3684;Ai(a+4|0);return}function Ml(a,b){a=a|0;b=b|0;return f[b+12>>2]|0}function Nl(a,b,c){a=a|0;b=b|0;c=c|0;return Oa[a&127](b|0,c|0)|0}function Ol(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(10)}function Pl(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function Ql(a){a=a|0;dl(a);f[a>>2]=2532;return}function Rl(a,c){a=a|0;c=c|0;b[a>>0]=b[c>>0]|0;return}function Sl(a,c){a=a|0;c=c|0;return b[(f[a>>2]|0)+c>>0]|0}function Tl(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)|0}function Ul(a,b){a=a|0;b=b|0;return f[b+4>>2]|0}function Vl(a){a=a|0;return $(n[a+20>>2])}function Wl(a){a=a|0;return f[a+4>>2]|0}function Xl(a){a=a|0;if(!a)return;dn(a);return}function Yl(a,b){a=a|0;b=b|0;if(!x){x=a;y=b}}function Zl(a){a=a|0;return a+12|0}function _l(a){a=a|0;return f[a+88>>2]|0}function $l(a,b,c){a=a|0;b=b|0;c=c|0;Ta[a&7](b|0,c|0)}function am(){var a=0;a=bj(40)|0;_i(a);return a|0}function bm(){var a=0;a=bj(108)|0;aj(a);return a|0}function cm(a){a=a|0;return (b[a+32>>0]|0)!=0|0}function dm(a){a=a|0;return a+-12|0}function em(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(9)}function fm(){var a=0;a=f[3363]|0;f[3363]=a+0;return a|0}function gm(a){a=a|0;return Gm(a+4|0)|0}function hm(a){a=a|0;return f[a+56>>2]|0}function im(a){a=a|0;Td(a);dn(a);return}function jm(a){a=a|0;hn(a);dn(a);return}function km(a){a=a|0;return b[a+24>>0]|0}function lm(){var a=0;a=f[898]|0;f[898]=a+0;return a|0}function mm(a,b){a=a|0;b=b|0;return 0}function nm(a){a=a|0;return f[a+40>>2]|0}function om(a){a=a|0;return f[a+48>>2]|0}function pm(a,b){a=a|0;b=b|0;return Na[a&127](b|0)|0}function qm(a){a=a|0;return f[a+60>>2]|0}function rm(a){a=a|0;return f[a+28>>2]|0}function sm(a){a=a|0;sa(a|0)|0;vi()}function tm(a){a=a|0;Ll(a);dn(a);return}function um(a){a=a|0;Ca()}function vm(a,b){a=a|0;b=b|0;u=a;v=b}function wm(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function xm(a){a=a|0;return (f[a>>2]|0)==0|0}function ym(a){a=a|0;return f[a+80>>2]|0}function zm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(8)}function Am(a,b){a=a|0;b=b|0;Sa[a&127](b|0)}function Bm(a,b){a=a|0;b=b|0;return Sj(a,b)|0}function Cm(a){a=a|0;b[a+12>>0]=0;return}function Dm(a){a=a|0;return a&255|0}function Em(a){a=a|0;f[a>>2]=0;return}function Fm(a,b,c){a=a|0;b=b|0;c=c|0;aa(2);return 0}function Gm(a){a=a|0;return f[a>>2]|0}function Hm(a){a=a|0;return 2}function Im(a){a=a|0;return 1}function Jm(a,b){a=+a;b=b|0;return +(+wg(a,b))}function Km(){return 3}function Lm(a,b,c){a=a|0;b=b|0;c=c|0;aa(7)}function Mm(){return -4}function Nm(){return 4}function Om(a){a=a|0;return (a+-48|0)>>>0<10|0}function Pm(){return -3}function Qm(){return 1}function Rm(){return 2}function Sm(){return -5}function Tm(a,b){a=a|0;b=b|0;aa(1);return 0}function Um(a){a=a|0;Ea()}function Vm(a){a=a|0;Ra[a&3]()}function Wm(){return -2}function Xm(){ua()}function Ym(){return -1}function Zm(){return on()|0}function _m(a,b){a=a|0;b=b|0;aa(6)}function $m(){return 0}function an(a){a=a|0;return bj(a)|0}function bn(a){a=a|0;dn(a);return}function cn(a){a=a|0;u=a}function dn(a){a=a|0;Cb(a);return}function en(a){a=a|0;I=a}function fn(a){a=a|0;return a|0}function gn(a){a=a|0;aa(0);return 0}function hn(a){a=a|0;return}function jn(a){a=a|0;return 0}function kn(){return I|0}function ln(){return 13376}function mn(){return u|0}function nn(a){a=a|0;aa(5)}function on(){return 2840}function pn(){aa(4)} + +// EMSCRIPTEN_END_FUNCS +var Na=[gn,Hm,Im,jl,rm,Im,Ic,gl,Wl,jn,jn,Im,jn,Im,Im,Ih,Nj,Ih,Xj,Ch,Im,Zj,Mg,Im,rm,Im,Ih,Nj,Ih,Xj,Ch,Im,Zj,Mg,Im,rm,Hm,jn,Wl,Im,jn,Im,Qk,Zj,Ig,Im,rm,Zj,Ig,Im,rm,kd,Im,Im,Kj,Hc,dh,Im,jn,je,bk,gk,ek,hb,Im,Wl,cl,Rd,nd,ae,ib,Im,Wl,cl,kb,pf,jn,Im,dj,gm,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn,gn];var Oa=[Tm,Hh,he,Qb,Nh,$k,mm,rl,wk,rl,Of,Xc,Ve,yh,Gg,Dg,Di,Ab,Pk,mm,me,_b,mm,Xh,Nc,mm,Th,de,ti,_b,mm,Xh,Nc,mm,Th,de,ti,Ke,Pk,mm,Re,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,Xd,oi,rh,zm,zm,zm];var Wa=[em,Wf,ie,em];var Xa=[Ol,Zh,fh,Ol];return{___cxa_can_catch:si,___cxa_is_pointer_type:Fk,___divdi3:Ug,___muldi3:gj,___udivdi3:Fl,___uremdi3:$i,_bitshift64Lshr:Uj,_bitshift64Shl:Oj,_emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0:Bk,_emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1:ok,_emscripten_bind_AttributeOctahedronTransform___destroy___0:Jk,_emscripten_bind_AttributeOctahedronTransform_quantization_bits_0:Wl,_emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0:Ri,_emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1:ok,_emscripten_bind_AttributeQuantizationTransform___destroy___0:Jk,_emscripten_bind_AttributeQuantizationTransform_min_value_1:Gk,_emscripten_bind_AttributeQuantizationTransform_quantization_bits_0:Wl,_emscripten_bind_AttributeQuantizationTransform_range_0:Vl,_emscripten_bind_AttributeTransformData_AttributeTransformData_0:Ak,_emscripten_bind_AttributeTransformData___destroy___0:Ti,_emscripten_bind_AttributeTransformData_transform_type_0:Gm,_emscripten_bind_DecoderBuffer_DecoderBuffer_0:ql,_emscripten_bind_DecoderBuffer_Init_2:Xk,_emscripten_bind_DecoderBuffer___destroy___0:Xl,_emscripten_bind_Decoder_DecodeBufferToMesh_2:jk,_emscripten_bind_Decoder_DecodeBufferToPointCloud_2:Vj,_emscripten_bind_Decoder_Decoder_0:am,_emscripten_bind_Decoder_GetAttributeByUniqueId_2:sk,_emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3:jj,_emscripten_bind_Decoder_GetAttributeFloat_3:Lj,_emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3:Gj,_emscripten_bind_Decoder_GetAttributeIdByName_2:yk,_emscripten_bind_Decoder_GetAttributeId_2:ak,_emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3:mj,_emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3:rj,_emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3:qj,_emscripten_bind_Decoder_GetAttributeIntForAllPoints_3:rj,_emscripten_bind_Decoder_GetAttributeMetadata_2:qk,_emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3:ij,_emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3:hj,_emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3:lj,_emscripten_bind_Decoder_GetAttribute_2:Nk,_emscripten_bind_Decoder_GetEncodedGeometryType_1:Hk,_emscripten_bind_Decoder_GetFaceFromMesh_3:_j,_emscripten_bind_Decoder_GetMetadata_1:fl,_emscripten_bind_Decoder_GetTriangleStripsFromMesh_2:ck,_emscripten_bind_Decoder_SkipAttributeTransform_1:Ek,_emscripten_bind_Decoder___destroy___0:Ng,_emscripten_bind_DracoFloat32Array_DracoFloat32Array_0:wl,_emscripten_bind_DracoFloat32Array_GetValue_1:bl,_emscripten_bind_DracoFloat32Array___destroy___0:xi,_emscripten_bind_DracoFloat32Array_size_0:Il,_emscripten_bind_DracoInt16Array_DracoInt16Array_0:wl,_emscripten_bind_DracoInt16Array_GetValue_1:tl,_emscripten_bind_DracoInt16Array___destroy___0:yi,_emscripten_bind_DracoInt16Array_size_0:Jl,_emscripten_bind_DracoInt32Array_DracoInt32Array_0:wl,_emscripten_bind_DracoInt32Array_GetValue_1:sl,_emscripten_bind_DracoInt32Array___destroy___0:xi,_emscripten_bind_DracoInt32Array_size_0:Il,_emscripten_bind_DracoInt8Array_DracoInt8Array_0:wl,_emscripten_bind_DracoInt8Array_GetValue_1:vl,_emscripten_bind_DracoInt8Array___destroy___0:Zi,_emscripten_bind_DracoInt8Array_size_0:Tl,_emscripten_bind_DracoUInt16Array_DracoUInt16Array_0:wl,_emscripten_bind_DracoUInt16Array_GetValue_1:tl,_emscripten_bind_DracoUInt16Array___destroy___0:yi,_emscripten_bind_DracoUInt16Array_size_0:Jl,_emscripten_bind_DracoUInt32Array_DracoUInt32Array_0:wl,_emscripten_bind_DracoUInt32Array_GetValue_1:sl,_emscripten_bind_DracoUInt32Array___destroy___0:xi,_emscripten_bind_DracoUInt32Array_size_0:Il,_emscripten_bind_DracoUInt8Array_DracoUInt8Array_0:wl,_emscripten_bind_DracoUInt8Array_GetValue_1:vl,_emscripten_bind_DracoUInt8Array___destroy___0:Zi,_emscripten_bind_DracoUInt8Array_size_0:Tl,_emscripten_bind_GeometryAttribute_GeometryAttribute_0:al,_emscripten_bind_GeometryAttribute___destroy___0:Xl,_emscripten_bind_Mesh_Mesh_0:bm,_emscripten_bind_Mesh___destroy___0:Jk,_emscripten_bind_Mesh_num_attributes_0:Bl,_emscripten_bind_Mesh_num_faces_0:ol,_emscripten_bind_Mesh_num_points_0:ym,_emscripten_bind_MetadataQuerier_GetDoubleEntry_2:nk,_emscripten_bind_MetadataQuerier_GetEntryName_2:xk,_emscripten_bind_MetadataQuerier_GetIntEntry_2:uk,_emscripten_bind_MetadataQuerier_GetStringEntry_2:mk,_emscripten_bind_MetadataQuerier_HasDoubleEntry_2:lk,_emscripten_bind_MetadataQuerier_HasEntry_2:Ck,_emscripten_bind_MetadataQuerier_HasIntEntry_2:tk,_emscripten_bind_MetadataQuerier_HasStringEntry_2:kk,_emscripten_bind_MetadataQuerier_MetadataQuerier_0:pl,_emscripten_bind_MetadataQuerier_NumEntries_1:Sk,_emscripten_bind_MetadataQuerier___destroy___0:Pg,_emscripten_bind_Metadata_Metadata_0:fi,_emscripten_bind_Metadata___destroy___0:el,_emscripten_bind_PointAttribute_GetAttributeTransformData_0:_l,_emscripten_bind_PointAttribute_PointAttribute_0:ll,_emscripten_bind_PointAttribute___destroy___0:ig,_emscripten_bind_PointAttribute_attribute_type_0:hm,_emscripten_bind_PointAttribute_byte_offset_0:om,_emscripten_bind_PointAttribute_byte_stride_0:nm,_emscripten_bind_PointAttribute_data_type_0:rm,_emscripten_bind_PointAttribute_normalized_0:cm,_emscripten_bind_PointAttribute_num_components_0:km,_emscripten_bind_PointAttribute_size_0:ym,_emscripten_bind_PointAttribute_unique_id_0:qm,_emscripten_bind_PointCloud_PointCloud_0:Hl,_emscripten_bind_PointCloud___destroy___0:Jk,_emscripten_bind_PointCloud_num_attributes_0:Bl,_emscripten_bind_PointCloud_num_points_0:ym,_emscripten_bind_Status___destroy___0:Pj,_emscripten_bind_Status_code_0:Gm,_emscripten_bind_Status_error_msg_0:Fj,_emscripten_bind_Status_ok_0:xm,_emscripten_bind_VoidPtr___destroy___0:Xl,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM:Ym,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM:$m,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM:Rm,_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM:Qm,_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE:Ym,_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD:$m,_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH:Qm,_emscripten_enum_draco_GeometryAttribute_Type_COLOR:Rm,_emscripten_enum_draco_GeometryAttribute_Type_GENERIC:Nm,_emscripten_enum_draco_GeometryAttribute_Type_INVALID:Ym,_emscripten_enum_draco_GeometryAttribute_Type_NORMAL:Qm,_emscripten_enum_draco_GeometryAttribute_Type_POSITION:$m,_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD:Km,_emscripten_enum_draco_StatusCode_ERROR:Ym,_emscripten_enum_draco_StatusCode_INVALID_PARAMETER:Pm,_emscripten_enum_draco_StatusCode_IO_ERROR:Wm,_emscripten_enum_draco_StatusCode_OK:$m,_emscripten_enum_draco_StatusCode_UNKNOWN_VERSION:Sm,_emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION:Mm,_emscripten_replace_memory:Ma,_free:Cb,_i64Add:Rj,_i64Subtract:Tj,_llvm_bswap_i32:Pl,_malloc:Ya,_memcpy:ge,_memmove:qi,_memset:Vf,_sbrk:Vh,dynCall_ii:pm,dynCall_iii:Nl,dynCall_iiii:Wk,dynCall_iiiiiii:yj,dynCall_v:Vm,dynCall_vi:Am,dynCall_vii:$l,dynCall_viii:kl,dynCall_viiii:Lk,dynCall_viiiii:hk,dynCall_viiiiii:Jj,establishStackSpace:vm,getTempRet0:kn,runPostSets:Qj,setTempRet0:en,setThrew:Yl,stackAlloc:ml,stackRestore:cn,stackSave:mn}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var ___divdi3=Module["___divdi3"]=asm["___divdi3"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=Module["_emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0"]=asm["_emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0"];var _emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=Module["_emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1"]=asm["_emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1"];var _emscripten_bind_AttributeOctahedronTransform___destroy___0=Module["_emscripten_bind_AttributeOctahedronTransform___destroy___0"]=asm["_emscripten_bind_AttributeOctahedronTransform___destroy___0"];var _emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=Module["_emscripten_bind_AttributeOctahedronTransform_quantization_bits_0"]=asm["_emscripten_bind_AttributeOctahedronTransform_quantization_bits_0"];var _emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=Module["_emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0"]=asm["_emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0"];var _emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=Module["_emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1"]=asm["_emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1"];var _emscripten_bind_AttributeQuantizationTransform___destroy___0=Module["_emscripten_bind_AttributeQuantizationTransform___destroy___0"]=asm["_emscripten_bind_AttributeQuantizationTransform___destroy___0"];var _emscripten_bind_AttributeQuantizationTransform_min_value_1=Module["_emscripten_bind_AttributeQuantizationTransform_min_value_1"]=asm["_emscripten_bind_AttributeQuantizationTransform_min_value_1"];var _emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=Module["_emscripten_bind_AttributeQuantizationTransform_quantization_bits_0"]=asm["_emscripten_bind_AttributeQuantizationTransform_quantization_bits_0"];var _emscripten_bind_AttributeQuantizationTransform_range_0=Module["_emscripten_bind_AttributeQuantizationTransform_range_0"]=asm["_emscripten_bind_AttributeQuantizationTransform_range_0"];var _emscripten_bind_AttributeTransformData_AttributeTransformData_0=Module["_emscripten_bind_AttributeTransformData_AttributeTransformData_0"]=asm["_emscripten_bind_AttributeTransformData_AttributeTransformData_0"];var _emscripten_bind_AttributeTransformData___destroy___0=Module["_emscripten_bind_AttributeTransformData___destroy___0"]=asm["_emscripten_bind_AttributeTransformData___destroy___0"];var _emscripten_bind_AttributeTransformData_transform_type_0=Module["_emscripten_bind_AttributeTransformData_transform_type_0"]=asm["_emscripten_bind_AttributeTransformData_transform_type_0"];var _emscripten_bind_DecoderBuffer_DecoderBuffer_0=Module["_emscripten_bind_DecoderBuffer_DecoderBuffer_0"]=asm["_emscripten_bind_DecoderBuffer_DecoderBuffer_0"];var _emscripten_bind_DecoderBuffer_Init_2=Module["_emscripten_bind_DecoderBuffer_Init_2"]=asm["_emscripten_bind_DecoderBuffer_Init_2"];var _emscripten_bind_DecoderBuffer___destroy___0=Module["_emscripten_bind_DecoderBuffer___destroy___0"]=asm["_emscripten_bind_DecoderBuffer___destroy___0"];var _emscripten_bind_Decoder_DecodeBufferToMesh_2=Module["_emscripten_bind_Decoder_DecodeBufferToMesh_2"]=asm["_emscripten_bind_Decoder_DecodeBufferToMesh_2"];var _emscripten_bind_Decoder_DecodeBufferToPointCloud_2=Module["_emscripten_bind_Decoder_DecodeBufferToPointCloud_2"]=asm["_emscripten_bind_Decoder_DecodeBufferToPointCloud_2"];var _emscripten_bind_Decoder_Decoder_0=Module["_emscripten_bind_Decoder_Decoder_0"]=asm["_emscripten_bind_Decoder_Decoder_0"];var _emscripten_bind_Decoder_GetAttributeByUniqueId_2=Module["_emscripten_bind_Decoder_GetAttributeByUniqueId_2"]=asm["_emscripten_bind_Decoder_GetAttributeByUniqueId_2"];var _emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeFloat_3=Module["_emscripten_bind_Decoder_GetAttributeFloat_3"]=asm["_emscripten_bind_Decoder_GetAttributeFloat_3"];var _emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=Module["_emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3"]=asm["_emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3"];var _emscripten_bind_Decoder_GetAttributeIdByName_2=Module["_emscripten_bind_Decoder_GetAttributeIdByName_2"]=asm["_emscripten_bind_Decoder_GetAttributeIdByName_2"];var _emscripten_bind_Decoder_GetAttributeId_2=Module["_emscripten_bind_Decoder_GetAttributeId_2"]=asm["_emscripten_bind_Decoder_GetAttributeId_2"];var _emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeIntForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeIntForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeMetadata_2=Module["_emscripten_bind_Decoder_GetAttributeMetadata_2"]=asm["_emscripten_bind_Decoder_GetAttributeMetadata_2"];var _emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=Module["_emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3"]=asm["_emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3"];var _emscripten_bind_Decoder_GetAttribute_2=Module["_emscripten_bind_Decoder_GetAttribute_2"]=asm["_emscripten_bind_Decoder_GetAttribute_2"];var _emscripten_bind_Decoder_GetEncodedGeometryType_1=Module["_emscripten_bind_Decoder_GetEncodedGeometryType_1"]=asm["_emscripten_bind_Decoder_GetEncodedGeometryType_1"];var _emscripten_bind_Decoder_GetFaceFromMesh_3=Module["_emscripten_bind_Decoder_GetFaceFromMesh_3"]=asm["_emscripten_bind_Decoder_GetFaceFromMesh_3"];var _emscripten_bind_Decoder_GetMetadata_1=Module["_emscripten_bind_Decoder_GetMetadata_1"]=asm["_emscripten_bind_Decoder_GetMetadata_1"];var _emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=Module["_emscripten_bind_Decoder_GetTriangleStripsFromMesh_2"]=asm["_emscripten_bind_Decoder_GetTriangleStripsFromMesh_2"];var _emscripten_bind_Decoder_SkipAttributeTransform_1=Module["_emscripten_bind_Decoder_SkipAttributeTransform_1"]=asm["_emscripten_bind_Decoder_SkipAttributeTransform_1"];var _emscripten_bind_Decoder___destroy___0=Module["_emscripten_bind_Decoder___destroy___0"]=asm["_emscripten_bind_Decoder___destroy___0"];var _emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=Module["_emscripten_bind_DracoFloat32Array_DracoFloat32Array_0"]=asm["_emscripten_bind_DracoFloat32Array_DracoFloat32Array_0"];var _emscripten_bind_DracoFloat32Array_GetValue_1=Module["_emscripten_bind_DracoFloat32Array_GetValue_1"]=asm["_emscripten_bind_DracoFloat32Array_GetValue_1"];var _emscripten_bind_DracoFloat32Array___destroy___0=Module["_emscripten_bind_DracoFloat32Array___destroy___0"]=asm["_emscripten_bind_DracoFloat32Array___destroy___0"];var _emscripten_bind_DracoFloat32Array_size_0=Module["_emscripten_bind_DracoFloat32Array_size_0"]=asm["_emscripten_bind_DracoFloat32Array_size_0"];var _emscripten_bind_DracoInt16Array_DracoInt16Array_0=Module["_emscripten_bind_DracoInt16Array_DracoInt16Array_0"]=asm["_emscripten_bind_DracoInt16Array_DracoInt16Array_0"];var _emscripten_bind_DracoInt16Array_GetValue_1=Module["_emscripten_bind_DracoInt16Array_GetValue_1"]=asm["_emscripten_bind_DracoInt16Array_GetValue_1"];var _emscripten_bind_DracoInt16Array___destroy___0=Module["_emscripten_bind_DracoInt16Array___destroy___0"]=asm["_emscripten_bind_DracoInt16Array___destroy___0"];var _emscripten_bind_DracoInt16Array_size_0=Module["_emscripten_bind_DracoInt16Array_size_0"]=asm["_emscripten_bind_DracoInt16Array_size_0"];var _emscripten_bind_DracoInt32Array_DracoInt32Array_0=Module["_emscripten_bind_DracoInt32Array_DracoInt32Array_0"]=asm["_emscripten_bind_DracoInt32Array_DracoInt32Array_0"];var _emscripten_bind_DracoInt32Array_GetValue_1=Module["_emscripten_bind_DracoInt32Array_GetValue_1"]=asm["_emscripten_bind_DracoInt32Array_GetValue_1"];var _emscripten_bind_DracoInt32Array___destroy___0=Module["_emscripten_bind_DracoInt32Array___destroy___0"]=asm["_emscripten_bind_DracoInt32Array___destroy___0"];var _emscripten_bind_DracoInt32Array_size_0=Module["_emscripten_bind_DracoInt32Array_size_0"]=asm["_emscripten_bind_DracoInt32Array_size_0"];var _emscripten_bind_DracoInt8Array_DracoInt8Array_0=Module["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"]=asm["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"];var _emscripten_bind_DracoInt8Array_GetValue_1=Module["_emscripten_bind_DracoInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoInt8Array_GetValue_1"];var _emscripten_bind_DracoInt8Array___destroy___0=Module["_emscripten_bind_DracoInt8Array___destroy___0"]=asm["_emscripten_bind_DracoInt8Array___destroy___0"];var _emscripten_bind_DracoInt8Array_size_0=Module["_emscripten_bind_DracoInt8Array_size_0"]=asm["_emscripten_bind_DracoInt8Array_size_0"];var _emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=Module["_emscripten_bind_DracoUInt16Array_DracoUInt16Array_0"]=asm["_emscripten_bind_DracoUInt16Array_DracoUInt16Array_0"];var _emscripten_bind_DracoUInt16Array_GetValue_1=Module["_emscripten_bind_DracoUInt16Array_GetValue_1"]=asm["_emscripten_bind_DracoUInt16Array_GetValue_1"];var _emscripten_bind_DracoUInt16Array___destroy___0=Module["_emscripten_bind_DracoUInt16Array___destroy___0"]=asm["_emscripten_bind_DracoUInt16Array___destroy___0"];var _emscripten_bind_DracoUInt16Array_size_0=Module["_emscripten_bind_DracoUInt16Array_size_0"]=asm["_emscripten_bind_DracoUInt16Array_size_0"];var _emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=Module["_emscripten_bind_DracoUInt32Array_DracoUInt32Array_0"]=asm["_emscripten_bind_DracoUInt32Array_DracoUInt32Array_0"];var _emscripten_bind_DracoUInt32Array_GetValue_1=Module["_emscripten_bind_DracoUInt32Array_GetValue_1"]=asm["_emscripten_bind_DracoUInt32Array_GetValue_1"];var _emscripten_bind_DracoUInt32Array___destroy___0=Module["_emscripten_bind_DracoUInt32Array___destroy___0"]=asm["_emscripten_bind_DracoUInt32Array___destroy___0"];var _emscripten_bind_DracoUInt32Array_size_0=Module["_emscripten_bind_DracoUInt32Array_size_0"]=asm["_emscripten_bind_DracoUInt32Array_size_0"];var _emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=Module["_emscripten_bind_DracoUInt8Array_DracoUInt8Array_0"]=asm["_emscripten_bind_DracoUInt8Array_DracoUInt8Array_0"];var _emscripten_bind_DracoUInt8Array_GetValue_1=Module["_emscripten_bind_DracoUInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoUInt8Array_GetValue_1"];var _emscripten_bind_DracoUInt8Array___destroy___0=Module["_emscripten_bind_DracoUInt8Array___destroy___0"]=asm["_emscripten_bind_DracoUInt8Array___destroy___0"];var _emscripten_bind_DracoUInt8Array_size_0=Module["_emscripten_bind_DracoUInt8Array_size_0"]=asm["_emscripten_bind_DracoUInt8Array_size_0"];var _emscripten_bind_GeometryAttribute_GeometryAttribute_0=Module["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"]=asm["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"];var _emscripten_bind_GeometryAttribute___destroy___0=Module["_emscripten_bind_GeometryAttribute___destroy___0"]=asm["_emscripten_bind_GeometryAttribute___destroy___0"];var _emscripten_bind_Mesh_Mesh_0=Module["_emscripten_bind_Mesh_Mesh_0"]=asm["_emscripten_bind_Mesh_Mesh_0"];var _emscripten_bind_Mesh___destroy___0=Module["_emscripten_bind_Mesh___destroy___0"]=asm["_emscripten_bind_Mesh___destroy___0"];var _emscripten_bind_Mesh_num_attributes_0=Module["_emscripten_bind_Mesh_num_attributes_0"]=asm["_emscripten_bind_Mesh_num_attributes_0"];var _emscripten_bind_Mesh_num_faces_0=Module["_emscripten_bind_Mesh_num_faces_0"]=asm["_emscripten_bind_Mesh_num_faces_0"];var _emscripten_bind_Mesh_num_points_0=Module["_emscripten_bind_Mesh_num_points_0"]=asm["_emscripten_bind_Mesh_num_points_0"];var _emscripten_bind_MetadataQuerier_GetDoubleEntry_2=Module["_emscripten_bind_MetadataQuerier_GetDoubleEntry_2"]=asm["_emscripten_bind_MetadataQuerier_GetDoubleEntry_2"];var _emscripten_bind_MetadataQuerier_GetEntryName_2=Module["_emscripten_bind_MetadataQuerier_GetEntryName_2"]=asm["_emscripten_bind_MetadataQuerier_GetEntryName_2"];var _emscripten_bind_MetadataQuerier_GetIntEntry_2=Module["_emscripten_bind_MetadataQuerier_GetIntEntry_2"]=asm["_emscripten_bind_MetadataQuerier_GetIntEntry_2"];var _emscripten_bind_MetadataQuerier_GetStringEntry_2=Module["_emscripten_bind_MetadataQuerier_GetStringEntry_2"]=asm["_emscripten_bind_MetadataQuerier_GetStringEntry_2"];var _emscripten_bind_MetadataQuerier_HasDoubleEntry_2=Module["_emscripten_bind_MetadataQuerier_HasDoubleEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasDoubleEntry_2"];var _emscripten_bind_MetadataQuerier_HasEntry_2=Module["_emscripten_bind_MetadataQuerier_HasEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasEntry_2"];var _emscripten_bind_MetadataQuerier_HasIntEntry_2=Module["_emscripten_bind_MetadataQuerier_HasIntEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasIntEntry_2"];var _emscripten_bind_MetadataQuerier_HasStringEntry_2=Module["_emscripten_bind_MetadataQuerier_HasStringEntry_2"]=asm["_emscripten_bind_MetadataQuerier_HasStringEntry_2"];var _emscripten_bind_MetadataQuerier_MetadataQuerier_0=Module["_emscripten_bind_MetadataQuerier_MetadataQuerier_0"]=asm["_emscripten_bind_MetadataQuerier_MetadataQuerier_0"];var _emscripten_bind_MetadataQuerier_NumEntries_1=Module["_emscripten_bind_MetadataQuerier_NumEntries_1"]=asm["_emscripten_bind_MetadataQuerier_NumEntries_1"];var _emscripten_bind_MetadataQuerier___destroy___0=Module["_emscripten_bind_MetadataQuerier___destroy___0"]=asm["_emscripten_bind_MetadataQuerier___destroy___0"];var _emscripten_bind_Metadata_Metadata_0=Module["_emscripten_bind_Metadata_Metadata_0"]=asm["_emscripten_bind_Metadata_Metadata_0"];var _emscripten_bind_Metadata___destroy___0=Module["_emscripten_bind_Metadata___destroy___0"]=asm["_emscripten_bind_Metadata___destroy___0"];var _emscripten_bind_PointAttribute_GetAttributeTransformData_0=Module["_emscripten_bind_PointAttribute_GetAttributeTransformData_0"]=asm["_emscripten_bind_PointAttribute_GetAttributeTransformData_0"];var _emscripten_bind_PointAttribute_PointAttribute_0=Module["_emscripten_bind_PointAttribute_PointAttribute_0"]=asm["_emscripten_bind_PointAttribute_PointAttribute_0"];var _emscripten_bind_PointAttribute___destroy___0=Module["_emscripten_bind_PointAttribute___destroy___0"]=asm["_emscripten_bind_PointAttribute___destroy___0"];var _emscripten_bind_PointAttribute_attribute_type_0=Module["_emscripten_bind_PointAttribute_attribute_type_0"]=asm["_emscripten_bind_PointAttribute_attribute_type_0"];var _emscripten_bind_PointAttribute_byte_offset_0=Module["_emscripten_bind_PointAttribute_byte_offset_0"]=asm["_emscripten_bind_PointAttribute_byte_offset_0"];var _emscripten_bind_PointAttribute_byte_stride_0=Module["_emscripten_bind_PointAttribute_byte_stride_0"]=asm["_emscripten_bind_PointAttribute_byte_stride_0"];var _emscripten_bind_PointAttribute_data_type_0=Module["_emscripten_bind_PointAttribute_data_type_0"]=asm["_emscripten_bind_PointAttribute_data_type_0"];var _emscripten_bind_PointAttribute_normalized_0=Module["_emscripten_bind_PointAttribute_normalized_0"]=asm["_emscripten_bind_PointAttribute_normalized_0"];var _emscripten_bind_PointAttribute_num_components_0=Module["_emscripten_bind_PointAttribute_num_components_0"]=asm["_emscripten_bind_PointAttribute_num_components_0"];var _emscripten_bind_PointAttribute_size_0=Module["_emscripten_bind_PointAttribute_size_0"]=asm["_emscripten_bind_PointAttribute_size_0"];var _emscripten_bind_PointAttribute_unique_id_0=Module["_emscripten_bind_PointAttribute_unique_id_0"]=asm["_emscripten_bind_PointAttribute_unique_id_0"];var _emscripten_bind_PointCloud_PointCloud_0=Module["_emscripten_bind_PointCloud_PointCloud_0"]=asm["_emscripten_bind_PointCloud_PointCloud_0"];var _emscripten_bind_PointCloud___destroy___0=Module["_emscripten_bind_PointCloud___destroy___0"]=asm["_emscripten_bind_PointCloud___destroy___0"];var _emscripten_bind_PointCloud_num_attributes_0=Module["_emscripten_bind_PointCloud_num_attributes_0"]=asm["_emscripten_bind_PointCloud_num_attributes_0"];var _emscripten_bind_PointCloud_num_points_0=Module["_emscripten_bind_PointCloud_num_points_0"]=asm["_emscripten_bind_PointCloud_num_points_0"];var _emscripten_bind_Status___destroy___0=Module["_emscripten_bind_Status___destroy___0"]=asm["_emscripten_bind_Status___destroy___0"];var _emscripten_bind_Status_code_0=Module["_emscripten_bind_Status_code_0"]=asm["_emscripten_bind_Status_code_0"];var _emscripten_bind_Status_error_msg_0=Module["_emscripten_bind_Status_error_msg_0"]=asm["_emscripten_bind_Status_error_msg_0"];var _emscripten_bind_Status_ok_0=Module["_emscripten_bind_Status_ok_0"]=asm["_emscripten_bind_Status_ok_0"];var _emscripten_bind_VoidPtr___destroy___0=Module["_emscripten_bind_VoidPtr___destroy___0"]=asm["_emscripten_bind_VoidPtr___destroy___0"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM"];var _emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=Module["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM"]=asm["_emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM"];var _emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=Module["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"]=asm["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"];var _emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=Module["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"]=asm["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"];var _emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=Module["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"]=asm["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"];var _emscripten_enum_draco_GeometryAttribute_Type_COLOR=Module["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"];var _emscripten_enum_draco_GeometryAttribute_Type_GENERIC=Module["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"];var _emscripten_enum_draco_GeometryAttribute_Type_INVALID=Module["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"];var _emscripten_enum_draco_GeometryAttribute_Type_NORMAL=Module["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"];var _emscripten_enum_draco_GeometryAttribute_Type_POSITION=Module["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"];var _emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=Module["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"];var _emscripten_enum_draco_StatusCode_ERROR=Module["_emscripten_enum_draco_StatusCode_ERROR"]=asm["_emscripten_enum_draco_StatusCode_ERROR"];var _emscripten_enum_draco_StatusCode_INVALID_PARAMETER=Module["_emscripten_enum_draco_StatusCode_INVALID_PARAMETER"]=asm["_emscripten_enum_draco_StatusCode_INVALID_PARAMETER"];var _emscripten_enum_draco_StatusCode_IO_ERROR=Module["_emscripten_enum_draco_StatusCode_IO_ERROR"]=asm["_emscripten_enum_draco_StatusCode_IO_ERROR"];var _emscripten_enum_draco_StatusCode_OK=Module["_emscripten_enum_draco_StatusCode_OK"]=asm["_emscripten_enum_draco_StatusCode_OK"];var _emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=Module["_emscripten_enum_draco_StatusCode_UNKNOWN_VERSION"]=asm["_emscripten_enum_draco_StatusCode_UNKNOWN_VERSION"];var _emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=Module["_emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION"]=asm["_emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION"];var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=asm["_emscripten_replace_memory"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];Module["asm"]=asm;if(memoryInitializer){if(!isDataURI(memoryInitializer)){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]&&status===0){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=exit;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:(function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret}),copy:(function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;iJhx+^}Wl@q-^WmwoNVTsl%d+bmJvkM9CLW8Yj@(l}Jazc!?7dNNU!=#{-2Rsy znhKAFAB{g6>qX06Y~O!kDxMGYV#SUxzooc&&kg(b-a2{fzT5oU=I#568(zda|J<_Y z$(xIp_!qVPFFiUt7lbNebn3{V{j)Edy4k7@QY-dlQ*--{&h0-`eYwFh?LBhC{v$_@ z&fPeB^ed}hFPog4Jn)MBllu=HI(lIL+|=aMD-KK@n>%>)NMKE0s&!=Y(4l({PtMKmKjvDtcJdgF zn%aNYB=9(KZ0f+lyAK{HyHkFenYwrK0Eyx0!W^WufM$gJs9ix4#-ZjW zUuw#!m-RRpX;}e5WA*Bwwt~bl85{mmuh~tb!8PP%qt5?EEus@iJy_F<1HEw>_)IOd zC#u(@U_}HFsF05;&{rMDQ5advYNX>Q1V%xPGWZE%J@;?*f+upTx%?<2PzY<$ND!`F z7uFNt6$Z5+Szi-C{SWZeNc4WmN2NiKsBG&xBg3`EJ2jb+()T*qYl#v>9!z1J@EZq= zR5DtNYa7PKMuN*Ow~}N2(zO*yM60Rqil~;X2HLe|8YQifdQz{Ctl-+D&NxisW=!!a zYGVjejI>sB-)Oq~O;>KJZ?4aWSA{8mBK?W^Qv{Vijo-iS^crga(R=CR*5JnTY{Bu9`;W{W{HpyTa!`@E6O^(0)}>qUrIqxHfMxN|TZ26} zoNtkfg62!kx0D6IISXhPZ~5VaM<(ytf9T{C1M?@zd3Rz_=sx#+I|25+Y>ILD(_~`l zti8e5v43uVA5RBgZw+4fpO#z1An0DSZMpg8dXq&{jAq~Tg+p0)OdU9S*VO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R^nn_96JK(_TJC7yzWYeD&3=xlSG2@8%58*Dz-}ynG}i45Hwr`}dof R-R_(gO$!GI59rJB{{cN^_yGU_ literal 0 HcmV?d00001 diff --git a/three/jsutil/libs/draco/gltf/draco_encoder.js b/three/jsutil/libs/draco/gltf/draco_encoder.js new file mode 100644 index 000000000..a67cdf206 --- /dev/null +++ b/three/jsutil/libs/draco/gltf/draco_encoder.js @@ -0,0 +1,33 @@ +var DracoEncoderModule = function(DracoEncoderModule) { + DracoEncoderModule = DracoEncoderModule || {}; + +var Module=typeof DracoEncoderModule!=="undefined"?DracoEncoderModule:{};var isRuntimeInitialized=false;var isModuleParsed=false;Module["onRuntimeInitialized"]=(function(){isRuntimeInitialized=true;if(isModuleParsed){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}});Module["onModuleParsed"]=(function(){isModuleParsed=true;if(isRuntimeInitialized){if(typeof Module["onModuleLoaded"]==="function"){Module["onModuleLoaded"](Module)}}});function isVersionSupported(versionString){if(typeof versionString!=="string")return false;const version=versionString.split(".");if(version.length<2||version.length>3)return false;if(version[0]==1&&version[1]>=0&&version[1]<=3)return true;if(version[0]!=0||version[1]>10)return false;return true}Module["isVersionSupported"]=isVersionSupported;var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",(function(reason,p){process["exit"](1)}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}Module["print"]=typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null;Module["printErr"]=typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||Module["print"];Module.print=Module["print"];Module.printErr=Module["printErr"];for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){assert(!staticSealed);var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){assert(DYNAMICTOP_PTR);var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;Module.printErr(text)}}var jsCallStartIndex=1;var functionPointers=new Array(0);var funcWrappers={};function dynCall(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}var GLOBAL_BASE=8;var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}var JSfuncs={"stackSave":(function(){stackSave()}),"stackRestore":(function(){stackRestore()}),"arrayToC":(function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};function ccall(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var ALLOC_STATIC=2;var ALLOC_NONE=4;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[typeof _malloc==="function"?_malloc:staticAlloc,stackAlloc,staticAlloc,dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var stop;ptr=ret;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return UTF8ToString(ptr)}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}var WASM_PAGE_SIZE=65536;var ASMJS_PAGE_SIZE=16777216;var MIN_TOTAL_MEMORY=16777216;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBuffer(buf){Module["buffer"]=buffer=buf}function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}if(!Module["reallocBuffer"])Module["reallocBuffer"]=(function(size){var ret;try{if(ArrayBuffer.transfer){ret=ArrayBuffer.transfer(buffer,size)}else{var oldHEAP8=HEAP8;ret=new ArrayBuffer(size);var temp=new Int8Array(ret);temp.set(oldHEAP8)}}catch(e){return false}var success=_emscripten_replace_memory(ret);if(!success)return false;return ret});function enlargeMemory(){var PAGE_MULTIPLE=Module["usingWasm"]?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE;var LIMIT=2147483648-PAGE_MULTIPLE;if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){return false}var OLD_TOTAL_MEMORY=TOTAL_MEMORY;TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);while(TOTAL_MEMORY>2]){if(TOTAL_MEMORY<=536870912){TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE)}else{TOTAL_MEMORY=Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,PAGE_MULTIPLE),LIMIT)}}var replacement=Module["reallocBuffer"](TOTAL_MEMORY);if(!replacement||replacement.byteLength!=TOTAL_MEMORY){TOTAL_MEMORY=OLD_TOTAL_MEMORY;return false}updateGlobalBuffer(replacement);updateGlobalBufferViews();return true}var byteLength;try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get);byteLength(new ArrayBuffer(4))}catch(e){byteLength=(function(buffer){return buffer.byteLength})}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_round=Math.round;var Math_min=Math.min;var Math_max=Math.max;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}STATIC_BASE=GLOBAL_BASE;STATICTOP=STATIC_BASE+19728;__ATINIT__.push();memoryInitializer="data:application/octet-stream;base64,HBwAAGQcAAAYAAAAAAAAAPQbAACLHAAAHBwAAKgcAAAYAAAAAAAAAPQbAADRHAAAHBwAAO0cAAAwAAAAAAAAAPQbAAAPHQAAHBwAADQdAAAwAAAAAAAAABwcAADsKQAASAAAAAAAAAAcHAAAZB0AAIAAAAAAAAAAHBwAAL0dAACQAAAAAAAAABwcAAARHgAAoAAAAAAAAAAcHAAARR4AALAAAAAAAAAA9BsAAHAeAAAcHAAAlB4AAMgAAAAAAAAA9BsAADIfAAAcHAAA0B8AAOAAAAAAAAAAHBwAAGggAACAAAAAAAAAABwcAADxIAAA4AAAAAAAAAAcHAAAiyEAAOAAAAAAAAAAHBwAAB0iAADgAAAAAAAAABwcAADDIgAA4AAAAAAAAAAcHAAAXiMAAOAAAAAAAAAAHBwAAPQjAABQAQAAAAAAAPQbAACfJAAAHBwAAEolAABoAQAAAAAAABwcAADvJQAAgAAAAAAAAAAcHAAAhSYAAGgBAAAAAAAAHBwAACwnAABoAQAAAAAAABwcAADLJwAAaAEAAAAAAAAcHAAAfigAAGgBAAAAAAAAHBwAACYpAABoAQAAAAAAABwcAADaNwAAYAAAAAAAAAAcHAAAGCoAAOgBAAAAAAAAHBwAAIkqAACQAAAAAAAAABwcAAD1KgAACAIAAAAAAAD0GwAAqysAABwcAABhLAAAIAIAAAAAAAAcHAAAES0AAOgBAAAAAAAAHBwAALItAAAgAgAAAAAAABwcAABkLgAAIAIAAAAAAAAcHAAADi8AACACAAAAAAAAHBwAAMw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a_allocate_exception(size){return _malloc(size)}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0&&!info.rethrown){if(info.destructor){Module["dynCall_vi"](info.destructor,ptr)}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___cxa_begin_catch(ptr){var info=EXCEPTIONS.infos[ptr];if(info&&!info.caught){info.caught=true;__ZSt18uncaught_exceptionv.uncaught_exception--}if(info)info.rethrown=false;EXCEPTIONS.caught.push(ptr);EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(ptr));return ptr}function ___cxa_pure_virtual(){ABORT=true;throw"Pure virtual function called!"}function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(setTempRet0(0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(setTempRet0(0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(setTempRet0(typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(setTempRet0(throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0,caught:false,rethrown:false};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC);function ___gxx_personality_v0(){}var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function flush_NO_FILESYSTEM(){var fflush=Module["_fflush"];if(fflush)fflush(0);var printChar=___syscall146.printChar;if(!printChar)return;var buffers=___syscall146.buffers;if(buffers[1].length)printChar(1,10);if(buffers[2].length)printChar(2,10)}function ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffers){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=PTHREAD_SPECIFIC_NEXT_KEY;PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0;PTHREAD_SPECIFIC_NEXT_KEY++;return 0}function _pthread_once(ptr,func){if(!_pthread_once.seen)_pthread_once.seen={};if(ptr in _pthread_once.seen)return;Module["dynCall_v"](func);_pthread_once.seen[ptr]=1}function _pthread_setspecific(key,value){if(!(key in PTHREAD_SPECIFIC)){return ERRNO_CODES.EINVAL}PTHREAD_SPECIFIC[key]=value;return 0}function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}DYNAMICTOP_PTR=staticAlloc(4);STACK_BASE=STACKTOP=alignMemory(STATICTOP);STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=alignMemory(STACK_MAX);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;staticSealed=true;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:(function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i2147483648)return false;b=new a(newBuffer);d=new c(newBuffer);f=new e(newBuffer);h=new g(newBuffer);j=new i(newBuffer);l=new k(newBuffer);n=new m(newBuffer);p=new o(newBuffer);buffer=newBuffer;return true} +// EMSCRIPTEN_START_FUNCS +function be(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;f[a+72>>2]=e;f[a+64>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;k=a+68|0;l=f[k>>2]|0;f[k>>2]=g;if(l|0)Mq(l);l=a+8|0;Mh(l,b,d,e);d=a+56|0;g=f[d>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+16|0;q=a+32|0;r=a+12|0;s=a+28|0;t=a+20|0;v=a+24|0;if(m-n>>2>>>0>p>>>0){w=p;x=n}else{y=g;aq(y)}while(1){f[j>>2]=f[x+(w<<2)>>2];f[i>>2]=f[j>>2];Cc(a,i,b,w);g=X(w,e)|0;n=b+(g<<2)|0;p=c+(g<<2)|0;g=f[l>>2]|0;if((g|0)>0){m=0;z=f[k>>2]|0;A=g;while(1){if((A|0)>0){g=0;do{B=f[z+(g<<2)>>2]|0;C=f[o>>2]|0;if((B|0)>(C|0)){D=f[q>>2]|0;f[D+(g<<2)>>2]=C;E=D}else{D=f[r>>2]|0;C=f[q>>2]|0;f[C+(g<<2)>>2]=(B|0)<(D|0)?D:B;E=C}g=g+1|0}while((g|0)<(f[l>>2]|0));F=E}else F=f[q>>2]|0;g=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=g;if((g|0)>=(f[s>>2]|0)){if((g|0)>(f[v>>2]|0)){G=g-(f[t>>2]|0)|0;H=21}}else{G=(f[t>>2]|0)+g|0;H=21}if((H|0)==21){H=0;f[C>>2]=G}m=m+1|0;A=f[l>>2]|0;if((m|0)>=(A|0))break;else z=F}}w=w+-1|0;if((w|0)<=-1){H=5;break}z=f[d>>2]|0;x=f[z>>2]|0;if((f[z+4>>2]|0)-x>>2>>>0<=w>>>0){y=z;H=6;break}}if((H|0)==5){u=h;return 1}else if((H|0)==6)aq(y);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|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=4194304;if(d){d=c;c=4194304;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<20)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Mf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function ee(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}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0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<20)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Mf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function he(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;Zc(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|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 1}function je(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=Oa,t=Oa,u=Oa,v=0,w=0,x=0,y=0,z=0;c=f[b>>2]|0;b=a+4|0;d=f[b>>2]|0;e=(d|0)==0;a:do if(!e){g=d+-1|0;h=(g&d|0)==0;if(!h)if(c>>>0>>0)i=c;else i=(c>>>0)%(d>>>0)|0;else i=g&c;j=f[(f[a>>2]|0)+(i<<2)>>2]|0;if(!j)k=i;else{if(h){h=j;while(1){l=f[h>>2]|0;if(!l){k=i;break a}m=f[l+4>>2]|0;if(!((m|0)==(c|0)|(m&g|0)==(i|0))){k=i;break a}if((f[l+8>>2]|0)==(c|0)){o=l;break}else h=l}p=o+12|0;return p|0}else q=j;while(1){h=f[q>>2]|0;if(!h){k=i;break a}g=f[h+4>>2]|0;if((g|0)!=(c|0)){if(g>>>0>>0)r=g;else r=(g>>>0)%(d>>>0)|0;if((r|0)!=(i|0)){k=i;break a}}if((f[h+8>>2]|0)==(c|0)){o=h;break}else q=h}p=o+12|0;return p|0}}else k=0;while(0);q=ln(16)|0;f[q+8>>2]=c;f[q+12>>2]=0;f[q+4>>2]=c;f[q>>2]=0;i=a+12|0;s=$(((f[i>>2]|0)+1|0)>>>0);t=$(d>>>0);u=$(n[a+16>>2]);do if(e|$(u*t)>>0<3|(d+-1&d|0)!=0)&1;j=~~$(W($(s/u)))>>>0;Hi(a,r>>>0>>0?j:r);r=f[b>>2]|0;j=r+-1|0;if(!(j&r)){v=r;w=j&c;break}if(c>>>0>>0){v=r;w=c}else{v=r;w=(c>>>0)%(r>>>0)|0}}else{v=d;w=k}while(0);k=(f[a>>2]|0)+(w<<2)|0;w=f[k>>2]|0;if(!w){d=a+8|0;f[q>>2]=f[d>>2];f[d>>2]=q;f[k>>2]=d;d=f[q>>2]|0;if(d|0){k=f[d+4>>2]|0;d=v+-1|0;if(d&v)if(k>>>0>>0)x=k;else x=(k>>>0)%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>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<16)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Rf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function le(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;ad(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|0,f[n+4>>2]|0,1)|0;n=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=131072;if(d){d=c;c=131072;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<15)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}Sf(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function me(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=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]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function pe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>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s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function se(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)|0;l=m;p=Vn(f[l>>2]|0,f[l+4>>2]|0,1,0)|0;l=m;f[l>>2]=p;f[l+4>>2]=I;j=j+1|0}while((j|0)!=(c|0))}j=i+40|0;l=j;f[l>>2]=0;f[l+4>>2]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;f[i+16>>2]=0;f[i+20>>2]=0;hd(i,n,o-n>>3,e)|0;n=i+16|0;o=Tn(f[n>>2]|0,f[n+4>>2]|0,1)|0;n=(f[e+4>>2]|0)-(f[e>>2]|0)|0;l=j;f[l>>2]=n;f[l+4>>2]=0;l=Vn(o|0,I|0,39,0)|0;o=Yn(l|0,I|0,3)|0;l=Vn(o|0,I|0,8,0)|0;o=Vn(l|0,I|0,n|0,0)|0;Cl(e,o,I);o=i+24|0;f[o>>2]=(f[e>>2]|0)+(f[j>>2]|0);j=i+28|0;f[j>>2]=0;n=i+32|0;f[n>>2]=16384;if(d){d=c;c=16384;do{l=d;d=d+-1|0;p=f[a+(d<<2)>>2]|0;m=f[i>>2]|0;q=f[m+(p<<3)>>2]|0;r=q<<10;if(c>>>0>>0)s=c;else{t=c;while(1){v=f[o>>2]|0;w=f[j>>2]|0;f[j>>2]=w+1;b[v+w>>0]=t;w=(f[n>>2]|0)>>>8;f[n>>2]=w;if(w>>>0>>0){s=w;break}else t=w}}c=(((s>>>0)/(q>>>0)|0)<<12)+((s>>>0)%(q>>>0)|0)+(f[m+(p<<3)+4>>2]|0)|0;f[n>>2]=c}while((l|0)>1)}_f(i,e);e=f[i>>2]|0;if(e|0){c=i+4|0;i=f[c>>2]|0;if((i|0)!=(e|0))f[c>>2]=i+(~((i+-8-e|0)>>>3)<<3);Oq(e)}e=f[h>>2]|0;if(!e){u=g;return 1}h=f[k>>2]|0;if((h|0)!=(e|0))f[k>>2]=h+(~((h+-8-e|0)>>>3)<<3);Oq(e);u=g;return 1}function te(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;g=u;u=u+64|0;h=g+48|0;i=g;j=d+1|0;f[h>>2]=0;k=h+4|0;f[k>>2]=0;f[h+8>>2]=0;do if(j)if(j>>>0>536870911)aq(h);else{l=ln(j<<3)|0;f[h>>2]=l;m=l+(j<<3)|0;f[h+8>>2]=m;sj(l|0,0,(d<<3)+8|0)|0;f[k>>2]=m;n=l;o=m;break}else{n=0;o=0}while(0);d=(c|0)>0;if(d){j=0;do{m=n+(f[a+(j<<2)>>2]<<3)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=j}else{t=s;v=j}else{Ci(i,d-k|0);k=f[b>>2]|0;t=k;v=f[k>>2]|0}k=f[t+4>>2]|0;if((k|0)!=(v|0)){v=f[i>>2]|0;i=f[t>>2]|0;t=k-i>>2;k=0;do{f[v+(k<<2)>>2]=f[i+(k<<2)>>2];k=k+1|0}while(k>>>0>>0)}t=(f[h>>2]|0)-(f[g>>2]|0)+1|0;g=a+136|0;h=a+140|0;a=f[h>>2]|0;k=f[g>>2]|0;i=(a-k|0)/12|0;v=a;if(t>>>0>i>>>0){Kf(g,t-i|0);u=c;return 1}if(t>>>0>=i>>>0){u=c;return 1}i=k+(t*12|0)|0;if((i|0)==(v|0)){u=c;return 1}else w=v;while(1){v=w+-12|0;f[h>>2]=v;t=f[v>>2]|0;if(!t)x=v;else{v=w+-8|0;k=f[v>>2]|0;if((k|0)!=(t|0))f[v>>2]=k+(~((k+-4-t|0)>>>2)<<2);Oq(t);x=f[h>>2]|0}if((x|0)==(i|0))break;else w=x}u=c;return 1}function we(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;e=f[b>>2]|0;g=f[b+4>>2]|0;h=((f[c>>2]|0)-e<<3)+(f[c+4>>2]|0)-g|0;c=e;if((h|0)<=0){i=d+4|0;j=f[d>>2]|0;f[a>>2]=j;k=a+4|0;l=f[i>>2]|0;f[k>>2]=l;return}if(!g){e=d+4|0;m=h;n=e;o=f[e>>2]|0;p=c}else{e=32-g|0;q=(h|0)<(e|0)?h:e;r=-1>>>(e-q|0)&-1<>2];e=d+4|0;s=f[e>>2]|0;t=32-s|0;u=t>>>0>>0?t:q;v=f[d>>2]|0;w=f[v>>2]&~(-1>>>(t-u|0)&-1<>2]=w;s=f[e>>2]|0;f[v>>2]=(s>>>0>g>>>0?r<>>(g-s|0))|w;w=(f[e>>2]|0)+u|0;s=v+(w>>>5<<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=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}f[w>>2]=f[w>>2]&~(-1>>>(32-i|0))|p>>>y;f[o>>2]=i;j=o;k=f[d>>2]|0;f[a>>2]=k;l=a+4|0;m=f[j>>2]|0;f[l>>2]=m;return}function ye(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+9|0;i=d+8|0;j=f[(f[a+184>>2]|0)+(c<<2)>>2]&255;b[h>>0]=j;c=a+4|0;k=f[(f[c>>2]|0)+44>>2]|0;l=k+16|0;m=f[l+4>>2]|0;if((m|0)>0|(m|0)==0&(f[l>>2]|0)>>>0>0)n=j;else{f[g>>2]=f[k+4>>2];f[e>>2]=f[g>>2];Me(k,e,h,h+1|0)|0;n=b[h>>0]|0}a:do if(n<<24>>24>-1){k=a+172|0;j=f[(f[k>>2]|0)+((n<<24>>24)*136|0)>>2]|0;l=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+52|0;m=b[h>>0]|0;o=f[k>>2]|0;k=f[o+(m*136|0)+132>>2]|0;switch(f[(f[(f[l>>2]|0)+84>>2]|0)+(j<<2)>>2]|0){case 0:{p=k;q=7;break a;break}case 1:{if(b[o+(m*136|0)+28>>0]|0){p=k;q=7;break a}break}default:{}}m=f[(f[c>>2]|0)+44>>2]|0;b[i>>0]=1;o=m+16|0;j=f[o+4>>2]|0;if(!((j|0)>0|(j|0)==0&(f[o>>2]|0)>>>0>0)){f[g>>2]=f[m+4>>2];f[e>>2]=f[g>>2];Me(m,e,i,i+1|0)|0}r=k}else{p=f[a+68>>2]|0;q=7}while(0);if((q|0)==7){q=f[(f[c>>2]|0)+44>>2]|0;b[i>>0]=0;a=q+16|0;h=f[a+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[a>>2]|0)>>>0>0)){f[g>>2]=f[q+4>>2];f[e>>2]=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>2]|0)|0;H=18}}else{G=(f[v>>2]|0)+l|0;H=18}if((H|0)==18){H=0;f[C>>2]=G}m=m+1|0;A=f[g>>2]|0;if((m|0)>=(A|0))break;else a=F}}x=x+-1|0;if((x|0)<=-1){H=3;break}a=f[d>>2]|0;y=f[a>>2]|0;if((f[a+4>>2]|0)-y>>2>>>0<=x>>>0){z=a;H=4;break}}if((H|0)==3){u=h;return 1}else if((H|0)==4)aq(z);return 0}function Ae(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;k=a+60|0;f[a+64>>2]=g;g=a+8|0;Mh(g,b,d,e);d=a+56|0;l=f[d>>2]|0;m=f[l+4>>2]|0;n=f[l>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+68|0;q=a+16|0;r=a+32|0;s=a+12|0;t=a+28|0;v=a+20|0;w=a+24|0;if(m-n>>2>>>0>p>>>0){x=p;y=n}else{z=l;aq(z)}while(1){f[j>>2]=f[y+(x<<2)>>2];f[i>>2]=f[j>>2];tb(k,i,b,x);l=X(x,e)|0;n=b+(l<<2)|0;p=c+(l<<2)|0;l=f[g>>2]|0;if((l|0)>0){m=0;a=o;A=l;while(1){if((A|0)>0){l=0;do{B=f[a+(l<<2)>>2]|0;C=f[q>>2]|0;if((B|0)>(C|0)){D=f[r>>2]|0;f[D+(l<<2)>>2]=C;E=D}else{D=f[s>>2]|0;C=f[r>>2]|0;f[C+(l<<2)>>2]=(B|0)<(D|0)?D:B;E=C}l=l+1|0}while((l|0)<(f[g>>2]|0));F=E}else F=f[r>>2]|0;l=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=l;if((l|0)>=(f[t>>2]|0)){if((l|0)>(f[w>>2]|0)){G=l-(f[v>>2]|0)|0;H=18}}else{G=(f[v>>2]|0)+l|0;H=18}if((H|0)==18){H=0;f[C>>2]=G}m=m+1|0;A=f[g>>2]|0;if((m|0)>=(A|0))break;else a=F}}x=x+-1|0;if((x|0)<=-1){H=3;break}a=f[d>>2]|0;y=f[a>>2]|0;if((f[a+4>>2]|0)-y>>2>>>0<=x>>>0){z=a;H=4;break}}if((H|0)==3){u=h;return 1}else if((H|0)==4)aq(z);return 0}function Be(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+12|0;g=f[e>>2]|0;h=(f[g+4>>2]|0)-(f[g>>2]|0)>>2;if(!h){u=b;return 1}i=a+152|0;j=a+140|0;k=a+144|0;l=a+148|0;a=0;m=g;while(1){f[d>>2]=(a>>>0)/3|0;f[c>>2]=f[d>>2];if(!(_j(m,c)|0)?(g=f[e>>2]|0,(f[(f[g+12>>2]|0)+(a<<2)>>2]|0)==-1):0){n=a+1|0;o=((n>>>0)%3|0|0)==0?a+-2|0:n;if((o|0)==-1)p=-1;else p=f[(f[g>>2]|0)+(o<<2)>>2]|0;o=f[i>>2]|0;if((f[o+(p<<2)>>2]|0)==-1){g=f[k>>2]|0;n=f[l>>2]|0;if((g|0)==(n<<5|0)){if((g+1|0)<0){q=11;break}r=n<<6;n=g+32&-32;vi(j,g>>>0<1073741823?(r>>>0>>0?n:r):2147483647);s=f[k>>2]|0;t=f[i>>2]|0}else{s=g;t=o}f[k>>2]=s+1;o=(f[j>>2]|0)+(s>>>5<<2)|0;f[o>>2]=f[o>>2]&~(1<<(s&31));o=t+(p<<2)|0;if((f[o>>2]|0)==-1){r=a;n=o;while(1){f[n>>2]=g;o=r+1|0;a:do if((r|0)!=-1?(v=((o>>>0)%3|0|0)==0?r+-2|0:o,(v|0)!=-1):0){w=f[e>>2]|0;x=f[w+12>>2]|0;y=v;while(1){v=f[x+(y<<2)>>2]|0;if((v|0)==-1)break;z=v+1|0;A=((z>>>0)%3|0|0)==0?v+-2|0:z;if((A|0)==-1){B=-1;C=-1;break a}else y=A}x=y+1|0;A=((x>>>0)%3|0|0)==0?y+-2|0:x;if((A|0)==-1){B=y;C=-1}else{B=y;C=f[(f[w>>2]|0)+(A<<2)>>2]|0}}else{B=-1;C=-1}while(0);n=t+(C<<2)|0;if((f[n>>2]|0)!=-1)break;else r=B}}}}r=a+1|0;if(r>>>0>=h>>>0){q=3;break}a=r;m=f[e>>2]|0}if((q|0)==3){u=b;return 1}else if((q|0)==11)aq(j);return 0}function Ce(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=u;u=u+32|0;e=d+8|0;g=d;h=a+4|0;i=f[h>>2]|0;if(i>>>0>=b>>>0){f[h>>2]=b;u=d;return}j=a+8|0;k=f[j>>2]|0;l=k<<5;m=b-i|0;if(l>>>0>>0|i>>>0>(l-m|0)>>>0){f[e>>2]=0;n=e+4|0;f[n>>2]=0;o=e+8|0;f[o>>2]=0;if((b|0)<0)aq(a);p=k<<6;k=b+31&-32;vi(e,l>>>0<1073741823?(p>>>0>>0?k:p):2147483647);p=f[h>>2]|0;f[n>>2]=p+m;k=f[a>>2]|0;l=k;q=f[e>>2]|0;r=(l+(p>>>5<<2)-k<<3)+(p&31)|0;if((r|0)>0){p=r>>>5;im(q|0,k|0,p<<2|0)|0;k=r&31;r=q+(p<<2)|0;s=r;if(!k){t=0;v=s}else{w=-1>>>(32-k|0);f[r>>2]=f[r>>2]&~w|f[l+(p<<2)>>2]&w;t=k;v=s}}else{t=0;v=q}f[g>>2]=v;f[g+4>>2]=t;t=g;g=f[t>>2]|0;v=f[t+4>>2]|0;t=f[a>>2]|0;f[a>>2]=f[e>>2];f[e>>2]=t;e=f[h>>2]|0;f[h>>2]=f[n>>2];f[n>>2]=e;e=f[j>>2]|0;f[j>>2]=f[o>>2];f[o>>2]=e;if(t|0)Oq(t);x=g;y=v}else{v=(f[a>>2]|0)+(i>>>5<<2)|0;f[h>>2]=b;x=v;y=i&31}if(!m){u=d;return}i=(y|0)==0;v=x;if(c){if(i){z=m;A=x;B=v}else{c=32-y|0;b=c>>>0>m>>>0?m:c;f[v>>2]=f[v>>2]|-1>>>(c-b|0)&-1<>>5;sj(A|0,-1,c<<2|0)|0;A=z&31;z=B+(c<<2)|0;if(!A){u=d;return}f[z>>2]=f[z>>2]|-1>>>(32-A|0);u=d;return}else{if(i){C=m;D=x;E=v}else{x=32-y|0;i=x>>>0>m>>>0?m:x;f[v>>2]=f[v>>2]&~(-1>>>(x-i|0)&-1<>>5;sj(D|0,0,y<<2|0)|0;D=C&31;C=E+(y<<2)|0;if(!D){u=d;return}f[C>>2]=f[C>>2]&~(-1>>>(32-D|0));u=d;return}}function De(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;a=u;u=u+48|0;g=a+36|0;h=a+24|0;i=a+12|0;j=a;if(!c){k=0;u=a;return k|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;l=Gj(d)|0;if(l>>>0>4294967279)aq(g);if(l>>>0<11){b[g+11>>0]=l;if(!l)m=g;else{n=g;o=7}}else{p=l+16&-16;q=ln(p)|0;f[g>>2]=q;f[g+8>>2]=p|-2147483648;f[g+4>>2]=l;n=q;o=7}if((o|0)==7){kh(n|0,d|0,l|0)|0;m=n}b[m+l>>0]=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;l=Gj(e)|0;if(l>>>0>4294967279)aq(h);if(l>>>0<11){b[h+11>>0]=l;if(!l)r=h;else{s=h;o=13}}else{m=l+16&-16;n=ln(m)|0;f[h>>2]=n;f[h+8>>2]=m|-2147483648;f[h+4>>2]=l;s=n;o=13}if((o|0)==13){kh(s|0,e|0,l|0)|0;r=s}b[r+l>>0]=0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;l=Gj(d)|0;if(l>>>0>4294967279)aq(i);if(l>>>0<11){b[i+11>>0]=l;if(!l)t=i;else{v=i;o=19}}else{r=l+16&-16;s=ln(r)|0;f[i>>2]=s;f[i+8>>2]=r|-2147483648;f[i+4>>2]=l;v=s;o=19}if((o|0)==19){kh(v|0,d|0,l|0)|0;t=v}b[t+l>>0]=0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;l=Gj(e)|0;if(l>>>0>4294967279)aq(j);if(l>>>0<11){b[j+11>>0]=l;if(!l)w=j;else{x=j;o=25}}else{t=l+16&-16;v=ln(t)|0;f[j>>2]=v;f[j+8>>2]=t|-2147483648;f[j+4>>2]=l;x=v;o=25}if((o|0)==25){kh(x|0,e|0,l|0)|0;w=x}b[w+l>>0]=0;mn(c,i,j);if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);k=1;u=a;return k|0}function Ee(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;f[a>>2]=f[c>>2];d=c+4|0;f[a+4>>2]=f[d>>2];e=c+8|0;f[a+8>>2]=f[e>>2];g=c+12|0;f[a+12>>2]=f[g>>2];f[d>>2]=0;f[e>>2]=0;f[g>>2]=0;g=c+16|0;f[a+16>>2]=f[g>>2];e=c+20|0;f[a+20>>2]=f[e>>2];d=c+24|0;f[a+24>>2]=f[d>>2];f[g>>2]=0;f[e>>2]=0;f[d>>2]=0;b[a+28>>0]=b[c+28>>0]|0;d=a+32|0;e=c+32|0;f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2]=0;if(a|0){i=f[a+8>>2]|0;if(i|0){q=a+12|0;if((f[q>>2]|0)!=(i|0))f[q>>2]=i;Oq(i)}Oq(a)}a=f[g+68>>2]|0;if(a|0){i=g+72|0;q=f[i>>2]|0;if((q|0)!=(a|0))f[i>>2]=q+(~((q+-4-a|0)>>>2)<<2);Oq(a)}a=g+64|0;q=f[a>>2]|0;f[a>>2]=0;if(q|0){a=f[q>>2]|0;if(a|0){i=q+4|0;if((f[i>>2]|0)!=(a|0))f[i>>2]=a;Oq(a)}Oq(q)}Oq(g);u=h;return}function Ge(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/136|0)>>>0>=c>>>0){i=c;j=h;do{f[j>>2]=-1;Ok(j+4|0);b[j+100>>0]=1;k=j+104|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[k+24>>2]=0;j=(f[g>>2]|0)+136|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/136|0;h=j+c|0;if(h>>>0>31580641)aq(a);k=(e-i|0)/136|0;i=k<<1;e=k>>>0<15790320?(i>>>0>>0?h:i):31580641;do if(e)if(e>>>0>31580641){i=ra(8)|0;Oo(i,16035);f[i>>2]=7256;va(i|0,1112,110)}else{l=ln(e*136|0)|0;break}else l=0;while(0);i=l+(j*136|0)|0;j=i;h=l+(e*136|0)|0;e=c;c=j;l=i;do{f[l>>2]=-1;Ok(l+4|0);b[l+100>>0]=1;k=l+104|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[k+24>>2]=0;l=c+136|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=f[g>>2]|0;if((l|0)==(e|0)){m=j;n=e;o=e}else{k=l;l=j;j=i;do{k=k+-136|0;Ee(j+-136|0,k);j=l+-136|0;l=j}while((k|0)!=(e|0));m=l;n=f[a>>2]|0;o=f[g>>2]|0}f[a>>2]=m;f[g>>2]=c;f[d>>2]=h;h=n;if((o|0)!=(h|0)){d=o;do{o=f[d+-20>>2]|0;if(o|0){c=d+-16|0;g=f[c>>2]|0;if((g|0)!=(o|0))f[c>>2]=g+(~((g+-4-o|0)>>>2)<<2);Oq(o)}o=f[d+-32>>2]|0;if(o|0){g=d+-28|0;c=f[g>>2]|0;if((c|0)!=(o|0))f[g>>2]=c+(~((c+-4-o|0)>>>2)<<2);Oq(o)}Mi(d+-132|0);d=d+-136|0}while((d|0)!=(h|0))}if(!n)return;Oq(n);return}function He(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=f[b>>2]|0;b=a+12|0;d=(c|0)==-1;e=c+1|0;do if(!d){g=((e>>>0)%3|0|0)==0?c+-2|0:e;if(!((c>>>0)%3|0)){h=g;i=c+2|0;break}else{h=g;i=c+-1|0;break}}else{h=-1;i=-1}while(0);e=d?-1:(c>>>0)/3|0;g=a+28|0;j=(f[g>>2]|0)+(e>>>5<<2)|0;f[j>>2]=1<<(e&31)|f[j>>2];j=a+172|0;e=a+176|0;k=a+280|0;if(((!d?(d=f[(f[(f[b>>2]|0)+12>>2]|0)+(c<<2)>>2]|0,(d|0)!=-1):0)?(a=(d>>>0)/3|0,(f[(f[g>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0):0)?(a=f[j>>2]|0,(f[e>>2]|0)!=(a|0)):0){d=c>>>5;l=1<<(c&31);c=0;m=a;do{a=(f[k>>2]|0)+(c<<5)|0;if(!(l&f[(f[m+(c*136|0)+4>>2]|0)+(d<<2)>>2]))fj(a,0);else fj(a,1);c=c+1|0;m=f[j>>2]|0}while(c>>>0<(((f[e>>2]|0)-m|0)/136|0)>>>0)}if((((h|0)!=-1?(m=f[(f[(f[b>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,(m|0)!=-1):0)?(c=(m>>>0)/3|0,(f[(f[g>>2]|0)+(c>>>5<<2)>>2]&1<<(c&31)|0)==0):0)?(c=f[j>>2]|0,(f[e>>2]|0)!=(c|0)):0){m=h>>>5;d=1<<(h&31);h=0;l=c;do{c=(f[k>>2]|0)+(h<<5)|0;if(!(d&f[(f[l+(h*136|0)+4>>2]|0)+(m<<2)>>2]))fj(c,0);else fj(c,1);h=h+1|0;l=f[j>>2]|0}while(h>>>0<(((f[e>>2]|0)-l|0)/136|0)>>>0)}if((i|0)==-1)return 1;l=f[(f[(f[b>>2]|0)+12>>2]|0)+(i<<2)>>2]|0;if((l|0)==-1)return 1;b=(l>>>0)/3|0;if(f[(f[g>>2]|0)+(b>>>5<<2)>>2]&1<<(b&31)|0)return 1;b=f[j>>2]|0;if((f[e>>2]|0)==(b|0))return 1;g=i>>>5;l=1<<(i&31);i=0;h=b;do{b=(f[k>>2]|0)+(i<<5)|0;if(!(l&f[(f[h+(i*136|0)+4>>2]|0)+(g<<2)>>2]))fj(b,0);else fj(b,1);i=i+1|0;h=f[j>>2]|0}while(i>>>0<(((f[e>>2]|0)-h|0)/136|0)>>>0);return 1}function Ie(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+4|0;j=a+8|0;ci((f[j>>2]|0)-(f[i>>2]|0)>>2,c)|0;k=f[i>>2]|0;if((f[j>>2]|0)==(k|0)){u=d;return 1}l=a+32|0;a=c+16|0;m=c+4|0;n=h+1|0;o=h+1|0;p=h+1|0;q=h+1|0;r=0;s=k;do{k=f[(f[(f[l>>2]|0)+8>>2]|0)+(f[s+(r<<2)>>2]<<2)>>2]|0;b[h>>0]=f[k+56>>2];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>>2;if(k<<24>>24>0){v=0;w=0}else{k=0;do{j=f[e+(k<<2)>>2]|0;if(s)x=f[(f[o>>2]|0)+(j<<2)>>2]|0;else x=j;j=p;m=f[j>>2]|0;y=f[j+4>>2]|0;j=q;z=f[j>>2]|0;A=un(z|0,f[j+4>>2]|0,x|0,0)|0;j=Vn(A|0,I|0,m|0,y|0)|0;kh(g|0,(f[f[d>>2]>>2]|0)+j|0,z|0)|0;k=k+1|0}while(k>>>0>>0);Mq(g);u=h;return}while(1){k=f[e+(v<<2)>>2]|0;if(s)B=f[(f[o>>2]|0)+(k<<2)>>2]|0;else B=k;k=p;x=f[k>>2]|0;z=f[k+4>>2]|0;k=q;j=f[k>>2]|0;y=un(j|0,f[k+4>>2]|0,B|0,0)|0;k=Vn(y|0,I|0,x|0,z|0)|0;kh(g|0,(f[f[d>>2]>>2]|0)+k|0,j|0)|0;j=f[r>>2]|0;C=$(n[i>>2]);k=0;z=w;while(1){D=$(n[g+(k<<2)>>2]);E=$(D-$(n[j+(k<<2)>>2]));x=E<$(0.0);D=$(-E);F=$((x?D:E)/C);y=~~$(J($($(F*$(f[c>>2]|0))+$(.5))));f[a+(z<<2)>>2]=x?0-y|0:y;k=k+1|0;if((k|0)==(l|0))break;else z=z+1|0}v=v+1|0;if(v>>>0>=t>>>0)break;else w=w+l|0}Mq(g);u=h;return}function Ke(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0;d=u;u=u+32|0;e=d+16|0;g=d+12|0;h=d+8|0;i=d+4|0;j=d;lp(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;k=a+24|0;lp(k);if((a|0)!=(b|0)){f[h>>2]=f[b>>2];f[i>>2]=b+4;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(a,g,e)}l=b+24|0;if((k|0)!=(l|0)){f[h>>2]=f[l>>2];f[i>>2]=b+28;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(k,g,e)}f[j>>2]=0;k=c+8|0;l=c+12|0;c=f[l>>2]|0;m=f[k>>2]|0;if((c-m|0)<=0){u=d;return}n=b+16|0;b=m;m=c;c=0;while(1){o=f[(f[b+(c<<2)>>2]|0)+56>>2]|0;p=f[n>>2]|0;if(p){q=n;r=p;a:while(1){p=r;while(1){if((f[p+16>>2]|0)>=(o|0))break;s=f[p+4>>2]|0;if(!s){t=q;break a}else p=s}r=f[p>>2]|0;if(!r){t=p;break}else q=p}if((t|0)!=(n|0)?(o|0)>=(f[t+16>>2]|0):0){q=t+20|0;r=Hd(a,j)|0;if((r|0)!=(q|0)){f[h>>2]=f[q>>2];f[i>>2]=t+24;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(r,g,e)}v=f[j>>2]|0;w=f[k>>2]|0;x=f[l>>2]|0}else{v=c;w=b;x=m}}else{v=c;w=b;x=m}c=v+1|0;f[j>>2]=c;if((c|0)>=(x-w>>2|0))break;else{b=w;m=x}}u=d;return}function Le(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+12|0;ci(f[i>>2]|0,c)|0;if(!(f[i>>2]|0)){j=1;u=d;return j|0}k=c+16|0;l=c+4|0;m=h+1|0;n=h+1|0;o=h+1|0;p=0;while(1){q=f[a>>2]|0;r=f[q+(p<<3)>>2]|0;if(r>>>0>63)if(r>>>0>16383)if(r>>>0>4194303){j=0;s=20;break}else{t=2;s=13}else{t=1;s=13}else if(!r){v=p+1|0;w=0;while(1){if(f[q+(v+w<<3)>>2]|0){x=w;break}y=w+1|0;if(y>>>0<63)w=y;else{x=y;break}}b[h>>0]=x<<2|3;w=k;v=f[w+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[w>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,o)|0}z=x+p|0}else{t=0;s=13}if((s|0)==13){s=0;b[h>>0]=t|r<<2;w=k;v=f[w+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[w>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,n)|0}if(!t)z=p;else{w=0;do{w=w+1|0;b[h>>0]=r>>>((w<<3)+-2|0);v=k;q=f[v+4>>2]|0;if(!((q|0)>0|(q|0)==0&(f[v>>2]|0)>>>0>0)){f[g>>2]=f[l>>2];f[e>>2]=f[g>>2];Me(c,e,h,m)|0}}while((w|0)<(t|0));z=p}}p=z+1|0;if(p>>>0>=(f[i>>2]|0)>>>0){j=1;s=20;break}}if((s|0)==20){u=d;return j|0}return 0}function Me(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;g=f[a>>2]|0;h=g;i=(f[c>>2]|0)-h|0;c=g+i|0;j=e-d|0;if((j|0)<=0){k=c;return k|0}l=a+8|0;m=f[l>>2]|0;n=a+4|0;o=f[n>>2]|0;p=o;if((j|0)<=(m-p|0)){q=p-c|0;if((j|0)>(q|0)){r=d+q|0;if((r|0)==(e|0))s=o;else{t=r;u=o;while(1){b[u>>0]=b[t>>0]|0;t=t+1|0;v=(f[n>>2]|0)+1|0;f[n>>2]=v;if((t|0)==(e|0)){s=v;break}else u=v}}if((q|0)>0){w=r;x=s}else{k=c;return k|0}}else{w=e;x=o}s=x-(c+j)|0;r=c+s|0;if(r>>>0>>0){q=r;r=x;do{b[r>>0]=b[q>>0]|0;q=q+1|0;r=(f[n>>2]|0)+1|0;f[n>>2]=r}while((q|0)!=(o|0))}if(s|0)im(x+(0-s)|0,c|0,s|0)|0;if((w|0)==(d|0)){k=c;return k|0}else{y=d;z=c}while(1){b[z>>0]=b[y>>0]|0;y=y+1|0;if((y|0)==(w|0)){k=c;break}else z=z+1|0}return k|0}z=p-h+j|0;if((z|0)<0)aq(a);j=m-h|0;h=j<<1;m=j>>>0<1073741823?(h>>>0>>0?z:h):2147483647;h=c;if(!m)A=0;else A=ln(m)|0;z=A+i|0;i=z;j=A+m|0;if((d|0)==(e|0)){B=i;C=g}else{g=d;d=i;i=z;do{b[i>>0]=b[g>>0]|0;i=d+1|0;d=i;g=g+1|0}while((g|0)!=(e|0));B=d;C=f[a>>2]|0}d=h-C|0;e=z+(0-d)|0;if((d|0)>0)kh(e|0,C|0,d|0)|0;d=(f[n>>2]|0)-h|0;if((d|0)>0){h=B;kh(h|0,c|0,d|0)|0;D=h+d|0;E=f[a>>2]|0}else{D=B;E=C}f[a>>2]=e;f[n>>2]=D;f[l>>2]=j;if(!E){k=z;return k|0}Oq(E);k=z;return k|0}function Ne(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+16|0;g=e;h=f[(f[c+4>>2]|0)+(d<<2)>>2]|0;d=f[c+28>>2]|0;c=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(h<<2)>>2]|0;switch(f[c+28>>2]|0){case 5:case 6:case 3:case 4:case 1:case 2:{i=ln(40)|0;zo(i);j=i;k=j;f[a>>2]=k;u=e;return}case 9:{l=3;break}default:{}}if((l|0)==3){i=f[d+48>>2]|0;d=ln(32)|0;f[g>>2]=d;f[g+8>>2]=-2147483616;f[g+4>>2]=17;m=d;n=14495;o=m+17|0;do{b[m>>0]=b[n>>0]|0;m=m+1|0;n=n+1|0}while((m|0)<(o|0));b[d+17>>0]=0;d=i+16|0;n=f[d>>2]|0;if(n){p=d;q=n;a:while(1){n=q;while(1){if((f[n+16>>2]|0)>=(h|0))break;r=f[n+4>>2]|0;if(!r){s=p;break a}else n=r}q=f[n>>2]|0;if(!q){s=n;break}else p=n}if(((s|0)!=(d|0)?(h|0)>=(f[s+16>>2]|0):0)?(h=s+20|0,(Jh(h,g)|0)!=0):0)t=Hk(h,g,-1)|0;else l=12}else l=12;if((l|0)==12)t=Hk(i,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((t|0)>0)if((f[c+56>>2]|0)==1){c=ln(48)|0;m=c;o=m+48|0;do{f[m>>2]=0;m=m+4|0}while((m|0)<(o|0));zo(c);f[c>>2]=2496;f[c+40>>2]=1168;f[c+44>>2]=-1;j=c;k=j;f[a>>2]=k;u=e;return}else{c=ln(64)|0;ym(c);j=c;k=j;f[a>>2]=k;u=e;return}}c=ln(36)|0;Hm(c);j=c;k=j;f[a>>2]=k;u=e;return}function Oe(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=(c|0)==(a|0);b[c+12>>0]=d&1;if(d)return;else e=c;while(1){g=e+8|0;h=f[g>>2]|0;c=h+12|0;if(b[c>>0]|0){i=23;break}j=h+8|0;k=f[j>>2]|0;d=f[k>>2]|0;if((d|0)==(h|0)){l=f[k+4>>2]|0;if(!l){i=7;break}m=l+12|0;if(!(b[m>>0]|0))n=m;else{i=7;break}}else{if(!d){i=16;break}m=d+12|0;if(!(b[m>>0]|0))n=m;else{i=16;break}}b[c>>0]=1;c=(k|0)==(a|0);b[k+12>>0]=c&1;b[n>>0]=1;if(c){i=23;break}else e=k}if((i|0)==7){if((f[h>>2]|0)==(e|0)){o=h;p=k}else{n=h+4|0;a=f[n>>2]|0;c=f[a>>2]|0;f[n>>2]=c;if(!c)q=k;else{f[c+8>>2]=h;q=f[j>>2]|0}f[a+8>>2]=q;q=f[j>>2]|0;f[((f[q>>2]|0)==(h|0)?q:q+4|0)>>2]=a;f[a>>2]=h;f[j>>2]=a;o=a;p=f[a+8>>2]|0}b[o+12>>0]=1;b[p+12>>0]=0;o=f[p>>2]|0;a=o+4|0;q=f[a>>2]|0;f[p>>2]=q;if(q|0)f[q+8>>2]=p;q=p+8|0;f[o+8>>2]=f[q>>2];c=f[q>>2]|0;f[((f[c>>2]|0)==(p|0)?c:c+4|0)>>2]=o;f[a>>2]=p;f[q>>2]=o;return}else if((i|0)==16){if((f[h>>2]|0)==(e|0)){o=e+4|0;q=f[o>>2]|0;f[h>>2]=q;if(!q)r=k;else{f[q+8>>2]=h;r=f[j>>2]|0}f[g>>2]=r;r=f[j>>2]|0;f[((f[r>>2]|0)==(h|0)?r:r+4|0)>>2]=e;f[o>>2]=h;f[j>>2]=e;s=e;t=f[e+8>>2]|0}else{s=h;t=k}b[s+12>>0]=1;b[t+12>>0]=0;s=t+4|0;k=f[s>>2]|0;h=f[k>>2]|0;f[s>>2]=h;if(h|0)f[h+8>>2]=t;h=t+8|0;f[k+8>>2]=f[h>>2];s=f[h>>2]|0;f[((f[s>>2]|0)==(t|0)?s:s+4|0)>>2]=k;f[k>>2]=t;f[h>>2]=k;return}else if((i|0)==23)return}function Pe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;d=f[b>>2]|0;b=a+12|0;e=(d|0)==-1;do if(e){g=1;h=-1;i=-1}else{j=d+(((d>>>0)%3|0|0)==0?2:-1)|0;if((j|0)!=-1){k=f[(f[b>>2]|0)+12>>2]|0;l=j;while(1){j=f[k+(l<<2)>>2]|0;if((j|0)==-1){m=0;n=l;break}o=j+1|0;l=((o>>>0)%3|0|0)==0?j+-2|0:o;if((l|0)==-1){m=1;n=-1;break}}if(e){g=m;h=-1;i=n;break}else{p=m;q=n}}else{p=1;q=-1}g=p;h=f[(f[f[b>>2]>>2]|0)+(d<<2)>>2]|0;i=q}while(0);if(c){c=(f[a+84>>2]|0)+(h>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(h&31);r=1}else r=0;c=f[(f[a+152>>2]|0)+(h<<2)>>2]|0;q=(f[a+140>>2]|0)+(c>>>5<<2)|0;f[q>>2]=f[q>>2]|1<<(c&31);if(!g){g=(((i>>>0)%3|0|0)==0?2:-1)+i|0;if((g|0)==-1){s=-1;t=i}else{s=f[(f[f[b>>2]>>2]|0)+(g<<2)>>2]|0;t=i}}else{s=-1;t=-1}if((s|0)==(h|0)){u=r;return u|0}i=f[a+84>>2]|0;a=r;r=s;s=t;while(1){t=i+(r>>>5<<2)|0;f[t>>2]=f[t>>2]|1<<(r&31);t=a+1|0;g=s+1|0;a:do if((s|0)!=-1?(c=((g>>>0)%3|0|0)==0?s+-2|0:g,(c|0)!=-1):0){q=f[b>>2]|0;d=f[q+12>>2]|0;p=c;while(1){c=f[d+(p<<2)>>2]|0;if((c|0)==-1)break;n=c+1|0;m=((n>>>0)%3|0|0)==0?c+-2|0:n;if((m|0)==-1){v=-1;w=-1;break a}else p=m}d=(((p>>>0)%3|0|0)==0?2:-1)+p|0;if((d|0)==-1){v=-1;w=p}else{v=f[(f[q>>2]|0)+(d<<2)>>2]|0;w=p}}else{v=-1;w=-1}while(0);if((v|0)==(h|0)){u=t;break}else{a=t;r=v;s=w}}return u|0}function Qe(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa;g=u;u=u+16|0;h=g;i=b[d+24>>0]|0;j=i<<24>>24;Rh(a,c,e,j,0,d,1);k=f[a>>2]|0;a=(f[f[k>>2]>>2]|0)+(f[k+48>>2]|0)|0;k=f[c+4>>2]|0;Ap(h);Ko(h,$(n[c+20>>2]),(1<>>0>1073741823?-1:j<<2)|0;if(!e){Mq(k);u=g;return}l=d+68|0;m=d+48|0;o=d+40|0;p=c+8|0;c=h+4|0;q=(b[d+84>>0]|0)==0;if(i<<24>>24>0){r=0;s=0}else{i=0;do{if(q)t=f[(f[l>>2]|0)+(i<<2)>>2]|0;else t=i;v=m;w=f[v>>2]|0;x=f[v+4>>2]|0;v=o;y=f[v>>2]|0;z=un(y|0,f[v+4>>2]|0,t|0,0)|0;v=Vn(z|0,I|0,w|0,x|0)|0;kh(k|0,(f[f[d>>2]>>2]|0)+v|0,y|0)|0;i=i+1|0}while((i|0)!=(e|0));Mq(k);u=g;return}while(1){if(q)A=f[(f[l>>2]|0)+(s<<2)>>2]|0;else A=s;i=m;t=f[i>>2]|0;y=f[i+4>>2]|0;i=o;v=f[i>>2]|0;x=un(v|0,f[i+4>>2]|0,A|0,0)|0;i=Vn(x|0,I|0,t|0,y|0)|0;kh(k|0,(f[f[d>>2]>>2]|0)+i|0,v|0)|0;v=f[p>>2]|0;B=$(n[h>>2]);i=0;y=r;while(1){C=$(n[k+(i<<2)>>2]);D=$(C-$(n[v+(i<<2)>>2]));t=D<$(0.0);C=$(-D);E=$((t?C:D)/B);x=~~$(J($($(E*$(f[c>>2]|0))+$(.5))));f[a+(y<<2)>>2]=t?0-x|0:x;i=i+1|0;if((i|0)==(j|0))break;else y=y+1|0}s=s+1|0;if((s|0)==(e|0))break;else r=r+j|0}Mq(k);u=g;return}function Re(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;c=a+4|0;d=f[c>>2]|0;e=a+100|0;if(d>>>0<(f[e>>2]|0)>>>0){f[c>>2]=d+1;g=h[d>>0]|0}else g=Si(a)|0;switch(g|0){case 43:case 45:{d=(g|0)==45&1;i=f[c>>2]|0;if(i>>>0<(f[e>>2]|0)>>>0){f[c>>2]=i+1;j=h[i>>0]|0}else j=Si(a)|0;if((b|0)!=0&(j+-48|0)>>>0>9?(f[e>>2]|0)!=0:0){f[c>>2]=(f[c>>2]|0)+-1;k=d;l=j}else{k=d;l=j}break}default:{k=0;l=g}}if((l+-48|0)>>>0>9)if(!(f[e>>2]|0)){m=-2147483648;n=0}else{f[c>>2]=(f[c>>2]|0)+-1;m=-2147483648;n=0}else{g=0;j=l;while(1){g=j+-48+(g*10|0)|0;l=f[c>>2]|0;if(l>>>0<(f[e>>2]|0)>>>0){f[c>>2]=l+1;o=h[l>>0]|0}else o=Si(a)|0;if(!((o+-48|0)>>>0<10&(g|0)<214748364))break;else j=o}j=((g|0)<0)<<31>>31;if((o+-48|0)>>>0<10){l=o;d=g;b=j;while(1){i=un(d|0,b|0,10,0)|0;p=I;q=Vn(l|0,((l|0)<0)<<31>>31|0,-48,-1)|0;r=Vn(q|0,I|0,i|0,p|0)|0;p=I;i=f[c>>2]|0;if(i>>>0<(f[e>>2]|0)>>>0){f[c>>2]=i+1;s=h[i>>0]|0}else s=Si(a)|0;if((s+-48|0)>>>0<10&((p|0)<21474836|(p|0)==21474836&r>>>0<2061584302)){l=s;d=r;b=p}else{t=s;u=r;v=p;break}}}else{t=o;u=g;v=j}if((t+-48|0)>>>0<10)do{t=f[c>>2]|0;if(t>>>0<(f[e>>2]|0)>>>0){f[c>>2]=t+1;w=h[t>>0]|0}else w=Si(a)|0}while((w+-48|0)>>>0<10);if(f[e>>2]|0)f[c>>2]=(f[c>>2]|0)+-1;c=(k|0)!=0;k=Xn(0,0,u|0,v|0)|0;m=c?I:v;n=c?k:u}I=m;return n|0}function Se(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;b=a+1176|0;c=f[b>>2]|0;if(c|0){d=a+1180|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+1164|0;b=f[g>>2]|0;if(b|0){j=a+1168|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+1152>>2]|0;if(l|0){g=a+1156|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+1140>>2]|0;if(l|0){m=a+1144|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+1128>>2]|0;if(!l){n=a+1108|0;jl(n);o=a+1088|0;jl(o);p=a+1068|0;jl(p);q=a+1036|0;Fj(q);r=a+12|0;Nh(r);return}g=a+1132|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+1108|0;jl(n);o=a+1088|0;jl(o);p=a+1068|0;jl(p);q=a+1036|0;Fj(q);r=a+12|0;Nh(r);return}function Te(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=u;u=u+16|0;e=d;g=a+4|0;h=f[g>>2]|0;i=f[(f[a>>2]|0)+52>>2]|0;if(!h){if(!(Sa[i&31](a,c,0)|0)){j=0;u=d;return j|0}}else if(!(Sa[i&31](a,c,f[(f[h+4>>2]|0)+80>>2]|0)|0)){j=0;u=d;return j|0}if(!(b[a+28>>0]|0)){j=1;u=d;return j|0}h=f[a+8>>2]|0;i=f[a+32>>2]|0;a=f[h+80>>2]|0;f[e>>2]=0;k=e+4|0;f[k>>2]=0;f[e+8>>2]=0;do if(a)if(a>>>0>1073741823)aq(e);else{l=a<<2;m=ln(l)|0;f[e>>2]=m;n=m+(a<<2)|0;f[e+8>>2]=n;sj(m|0,0,l|0)|0;f[k>>2]=n;o=m;p=n;q=m;break}else{o=0;p=0;q=0}while(0);e=f[c+4>>2]|0;a=f[c>>2]|0;c=a;a:do if((e|0)!=(a|0)){m=e-a>>2;if(b[h+84>>0]|0){n=0;while(1){f[o+(f[c+(n<<2)>>2]<<2)>>2]=n;n=n+1|0;if(n>>>0>=m>>>0)break a}}n=f[h+68>>2]|0;l=0;do{f[o+(f[n+(f[c+(l<<2)>>2]<<2)>>2]<<2)>>2]=l;l=l+1|0}while(l>>>0>>0)}while(0);c=f[(f[(f[g>>2]|0)+4>>2]|0)+80>>2]|0;b:do if(c|0){g=f[i+68>>2]|0;if(b[h+84>>0]|0){a=0;while(1){f[g+(a<<2)>>2]=f[o+(a<<2)>>2];a=a+1|0;if(a>>>0>=c>>>0)break b}}a=f[h+68>>2]|0;e=0;do{f[g+(e<<2)>>2]=f[o+(f[a+(e<<2)>>2]<<2)>>2];e=e+1|0}while(e>>>0>>0)}while(0);if(o|0){if((p|0)!=(o|0))f[k>>2]=p+(~((p+-4-o|0)>>>2)<<2);Oq(q)}j=1;u=d;return j|0}function Ue(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;Oh(a+12|0);wn(a+1036|0);vo(a+1068|0);vo(a+1088|0);vo(a+1108|0);e=a+1128|0;f[e>>2]=0;g=a+1132|0;f[g>>2]=0;f[a+1136>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+1136>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+1140|0;f[g>>2]=0;e=a+1144|0;f[e>>2]=0;f[a+1148>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>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o;while(1){o=f[c+(q<<2)>>2]|0;t=f[k>>2]|0;if(t-s>>2>>>0>o>>>0){v=r;w=n}else{x=o+1|0;f[h>>2]=0;y=t-s>>2;z=s;A=t;if(x>>>0<=y>>>0)if(x>>>0>>0?(t=z+(x<<2)|0,(t|0)!=(A|0)):0){f[k>>2]=A+(~((A+-4-t|0)>>>2)<<2);B=r}else B=r;else{Ch(b,x-y|0,h);B=f[b>>2]|0}v=B;w=B}y=w+(o<<2)|0;x=f[y>>2]|0;s=w;if((x|0)<=1)if((x|0)==0?(f[l>>2]=(f[l>>2]|0)+1,o>>>0>(f[m>>2]|0)>>>0):0){f[m>>2]=o;C=0.0}else C=0.0;else{D=+(x|0);C=+Zg(D)*D}x=(f[y>>2]|0)+1|0;f[y>>2]=x;D=+(x|0);E=+Zg(D)*D-C;p[a>>3]=+p[a>>3]+E;q=q+1|0;if((q|0)==(d|0))break;else{r=v;n=w}}}if(e){f[i>>2]=f[a>>2];f[i+4>>2]=f[a+4>>2];f[i+8>>2]=f[a+8>>2];f[i+12>>2]=f[a+12>>2];f[i+16>>2]=f[a+16>>2];u=g;return}if(!j){u=g;return}j=f[b>>2]|0;b=0;do{a=j+(f[c+(b<<2)>>2]<<2)|0;f[a>>2]=(f[a>>2]|0)+-1;b=b+1|0}while((b|0)!=(d|0));u=g;return}function We(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;a:do if(b>>>0<=20)do switch(b|0){case 9:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;f[a>>2]=e;break a;break}case 10:{e=(f[c>>2]|0)+(4-1)&~(4-1);d=f[e>>2]|0;f[c>>2]=e+4;e=a;f[e>>2]=d;f[e+4>>2]=((d|0)<0)<<31>>31;break a;break}case 11:{d=(f[c>>2]|0)+(4-1)&~(4-1);e=f[d>>2]|0;f[c>>2]=d+4;d=a;f[d>>2]=e;f[d+4>>2]=0;break a;break}case 12:{d=(f[c>>2]|0)+(8-1)&~(8-1);e=d;g=f[e>>2]|0;h=f[e+4>>2]|0;f[c>>2]=d+8;d=a;f[d>>2]=g;f[d+4>>2]=h;break a;break}case 13:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&65535)<<16>>16;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 14:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&65535;f[h+4>>2]=0;break a;break}case 15:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=(d&255)<<24>>24;d=a;f[d>>2]=h;f[d+4>>2]=((h|0)<0)<<31>>31;break a;break}case 16:{h=(f[c>>2]|0)+(4-1)&~(4-1);d=f[h>>2]|0;f[c>>2]=h+4;h=a;f[h>>2]=d&255;f[h+4>>2]=0;break a;break}case 17:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}case 18:{h=(f[c>>2]|0)+(8-1)&~(8-1);i=+p[h>>3];f[c>>2]=h+8;p[a>>3]=i;break a;break}default:break a}while(0);while(0);return}function Xe(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+16|0;d=c+4|0;e=c;g=c+8|0;if(!(Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0)){h=0;u=c;return h|0}i=a+44|0;j=f[i>>2]|0;k=a+8|0;l=a+12|0;m=f[l>>2]|0;n=f[k>>2]|0;b[g>>0]=(m-n|0)>>>2;o=j+16|0;p=f[o+4>>2]|0;if((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0){q=k;r=n;s=m}else{f[e>>2]=f[j+4>>2];f[d>>2]=f[e>>2];Me(j,d,g,g+1|0)|0;q=k;r=f[k>>2]|0;s=f[l>>2]|0}a:do if((r|0)!=(s|0)){l=a+4|0;k=r;while(1){g=f[k>>2]|0;k=k+4|0;if(!(Sa[f[(f[g>>2]|0)+8>>2]&31](g,a,f[l>>2]|0)|0)){h=0;break}if((k|0)==(s|0))break a}u=c;return h|0}while(0);if(!(xc(a)|0)){h=0;u=c;return h|0}s=a+32|0;r=f[s>>2]|0;k=a+36|0;l=f[k>>2]|0;b:do if((r|0)!=(l|0)){g=r;do{if(!(Ra[f[(f[a>>2]|0)+40>>2]&127](a,f[g>>2]|0)|0)){h=0;t=18;break}g=g+4|0}while((g|0)!=(l|0));if((t|0)==18){u=c;return h|0}g=f[s>>2]|0;d=f[k>>2]|0;if((g|0)!=(d|0)){j=g;while(1){g=f[(f[q>>2]|0)+(f[j>>2]<<2)>>2]|0;j=j+4|0;if(!(Ra[f[(f[g>>2]|0)+12>>2]&127](g,f[i>>2]|0)|0)){h=0;break}if((j|0)==(d|0))break b}u=c;return h|0}}while(0);h=Qa[f[(f[a>>2]|0)+44>>2]&127](a)|0;u=c;return h|0}function Ye(a,b){a=a|0;b=b|0;ld(a,b);ld(a+32|0,b);ld(a+64|0,b);ld(a+96|0,b);ld(a+128|0,b);ld(a+160|0,b);ld(a+192|0,b);ld(a+224|0,b);ld(a+256|0,b);ld(a+288|0,b);ld(a+320|0,b);ld(a+352|0,b);ld(a+384|0,b);ld(a+416|0,b);ld(a+448|0,b);ld(a+480|0,b);ld(a+512|0,b);ld(a+544|0,b);ld(a+576|0,b);ld(a+608|0,b);ld(a+640|0,b);ld(a+672|0,b);ld(a+704|0,b);ld(a+736|0,b);ld(a+768|0,b);ld(a+800|0,b);ld(a+832|0,b);ld(a+864|0,b);ld(a+896|0,b);ld(a+928|0,b);ld(a+960|0,b);ld(a+992|0,b);ld(a+1024|0,b);return}function Ze(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0;c=u;u=u+32|0;d=c;e=a+4|0;g=f[a>>2]|0;h=(f[e>>2]|0)-g>>2;i=h+1|0;if(i>>>0>1073741823)aq(a);j=a+8|0;k=(f[j>>2]|0)-g|0;g=k>>1;l=k>>2>>>0<536870911?(g>>>0>>0?i:g):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(l)if(l>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}else{m=ln(l<<2)|0;break}else m=0;while(0);f[d>>2]=m;g=m+(h<<2)|0;h=d+8|0;i=d+4|0;f[i>>2]=g;k=m+(l<<2)|0;l=d+12|0;f[l>>2]=k;m=f[b>>2]|0;f[b>>2]=0;f[g>>2]=m;m=g+4|0;f[h>>2]=m;b=f[a>>2]|0;n=f[e>>2]|0;if((n|0)==(b|0)){o=g;p=l;q=h;r=b;s=m;t=n;v=k;w=o;f[a>>2]=w;f[i>>2]=r;f[e>>2]=s;f[q>>2]=t;x=f[j>>2]|0;f[j>>2]=v;f[p>>2]=x;f[d>>2]=r;ki(d);u=c;return}else{y=n;z=g}do{y=y+-4|0;g=f[y>>2]|0;f[y>>2]=0;f[z+-4>>2]=g;z=(f[i>>2]|0)+-4|0;f[i>>2]=z}while((y|0)!=(b|0));o=z;p=l;q=h;r=f[a>>2]|0;s=f[h>>2]|0;t=f[e>>2]|0;v=f[l>>2]|0;w=o;f[a>>2]=w;f[i>>2]=r;f[e>>2]=s;f[q>>2]=t;x=f[j>>2]|0;f[j>>2]=v;f[p>>2]=x;f[d>>2]=r;ki(d);u=c;return}function _e(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+32|0;e=d+12|0;g=d;h=nl(c,0)|0;if(!h){f[a>>2]=0;u=d;return}i=f[c+100>>2]|0;j=f[c+96>>2]|0;c=i-j|0;k=(c|0)/12|0;f[e>>2]=0;l=e+4|0;f[l>>2]=0;f[e+8>>2]=0;m=j;do if(c)if(k>>>0>357913941)aq(e);else{n=ln(c)|0;f[e>>2]=n;f[e+8>>2]=n+(k*12|0);sj(n|0,0,c|0)|0;f[l>>2]=n+c;o=n;break}else o=0;while(0);f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;a:do if((i|0)!=(j|0)){c=g+4|0;n=g+8|0;if(b[h+84>>0]|0){p=0;while(1){q=m+(p*12|0)|0;f[g>>2]=f[q>>2];f[g+4>>2]=f[q+4>>2];f[g+8>>2]=f[q+8>>2];f[o+(p*12|0)>>2]=f[g>>2];f[o+(p*12|0)+4>>2]=f[c>>2];f[o+(p*12|0)+8>>2]=f[n>>2];p=p+1|0;if(p>>>0>=k>>>0)break a}}p=f[h+68>>2]|0;q=0;do{r=f[p+(f[m+(q*12|0)>>2]<<2)>>2]|0;f[g>>2]=r;s=f[p+(f[m+(q*12|0)+4>>2]<<2)>>2]|0;f[c>>2]=s;t=f[p+(f[m+(q*12|0)+8>>2]<<2)>>2]|0;f[n>>2]=t;f[o+(q*12|0)>>2]=r;f[o+(q*12|0)+4>>2]=s;f[o+(q*12|0)+8>>2]=t;q=q+1|0}while(q>>>0>>0)}while(0);Kj(a,e);a=f[e>>2]|0;if(a|0){e=f[l>>2]|0;if((e|0)!=(a|0))f[l>>2]=e+(~(((e+-12-a|0)>>>0)/12|0)*12|0);Oq(a)}u=d;return}function $e(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;wn(a+12|0);vo(a+44|0);vo(a+64|0);vo(a+84|0);e=a+104|0;f[e>>2]=0;g=a+108|0;f[g>>2]=0;f[a+112>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+112>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+116|0;f[g>>2]=0;e=a+120|0;f[e>>2]=0;f[a+124>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+124>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=a+128|0;f[g>>2]=0;e=a+132|0;f[e>>2]=0;f[a+136>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[g>>2]=i;g=i+(b<<2)|0;f[a+136>>2]=g;sj(i|0,0,k|0)|0;f[e>>2]=g}g=b<<5|1;f[d>>2]=0;e=d+4|0;f[e>>2]=0;f[d+8>>2]=0;if(!h){k=b<<2;i=ln(k)|0;f[d>>2]=i;j=i+(b<<2)|0;f[d+8>>2]=j;sj(i|0,0,k|0)|0;f[e>>2]=j}lk(a+140|0,g,d);j=f[d>>2]|0;if(j|0){k=f[e>>2]|0;if((k|0)!=(j|0))f[e>>2]=k+(~((k+-4-j|0)>>>2)<<2);Oq(j)}f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;if(!h){h=b<<2;k=ln(h)|0;f[d>>2]=k;e=k+(b<<2)|0;f[d+8>>2]=e;sj(k|0,0,h|0)|0;f[j>>2]=e}lk(a+152|0,g,d);g=f[d>>2]|0;if(!g){u=c;return}d=f[j>>2]|0;if((d|0)!=(g|0))f[j>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g);u=c;return}function af(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=u;u=u+16|0;d=c;f[a>>2]=0;f[a+8>>2]=b;vo(a+12|0);vo(a+32|0);vo(a+52|0);vo(a+72|0);e=a+92|0;f[e>>2]=0;g=a+96|0;f[g>>2]=0;f[a+100>>2]=0;h=(b|0)==0;do if(!h)if(b>>>0>1073741823)aq(e);else{i=b<<2;j=ln(i)|0;f[e>>2]=j;k=j+(b<<2)|0;f[a+100>>2]=k;sj(j|0,0,i|0)|0;f[g>>2]=k;break}while(0);g=a+104|0;f[g>>2]=0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Vk(h,m?f[k>>2]|0:k,l)|0,(o|0)!=0):0)if((o|0)<0)p=7;else p=9;else if(j>>>0>>0)p=7;else p=9;if((p|0)==7){p=0;n=f[i>>2]|0;if(!n){p=8;break}else q=n}else if((p|0)==9){p=0;r=i+4|0;n=f[r>>2]|0;if(!n){p=11;break}else q=n}i=q}if((p|0)==8){s=i;t=i;break}else if((p|0)==11){s=i;t=r;break}}else{s=c;t=c}while(0);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=s;f[t>>2]=d;s=f[f[a>>2]>>2]|0;if(!s){u=d;v=a+4|0;w=f[v>>2]|0;Oe(w,u);x=a+8|0;y=f[x>>2]|0;z=y+1|0;f[x>>2]=z;return d|0}f[a>>2]=s;u=f[t>>2]|0;v=a+4|0;w=f[v>>2]|0;Oe(w,u);x=a+8|0;y=f[x>>2]|0;z=y+1|0;f[x>>2]=z;return d|0}function cf(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3680;wi(a+200|0);b=f[a+184>>2]|0;if(b|0){c=a+188|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}kj(a+172|0);b=f[a+152>>2]|0;if(b|0){d=a+156|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+140>>2]|0;if(b|0)Oq(b);b=f[a+128>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;Oq(b)}while((c|0)!=0)}c=a+120|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)Oq(b);b=f[a+108>>2]|0;if(b|0){c=a+112|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0)Oq(b);b=f[a+16>>2]|0;if(b|0){d=a+20|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+12|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Ii(a);Oq(a);return}function df(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+140|0;c=f[b>>2]|0;if(c|0){d=a+144|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+128|0;b=f[g>>2]|0;if(b|0){j=a+132|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+116>>2]|0;if(l|0){g=a+120|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+104>>2]|0;if(l|0){m=a+108|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+92>>2]|0;if(!l){n=a+72|0;jl(n);o=a+52|0;jl(o);p=a+32|0;jl(p);q=a+12|0;jl(q);return}g=a+96|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+72|0;jl(n);o=a+52|0;jl(o);p=a+32|0;jl(p);q=a+12|0;jl(q);return}function ef(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=a+152|0;c=f[b>>2]|0;if(c|0){d=a+156|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=a+140|0;b=f[g>>2]|0;if(b|0){j=a+144|0;h=f[j>>2]|0;if((h|0)==(b|0))l=b;else{c=h;while(1){h=c+-12|0;f[j>>2]=h;d=f[h>>2]|0;if(!d)m=h;else{h=c+-8|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d);m=f[j>>2]|0}if((m|0)==(b|0))break;else c=m}l=f[g>>2]|0}Oq(l)}l=f[a+128>>2]|0;if(l|0){g=a+132|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+116>>2]|0;if(l|0){m=a+120|0;g=f[m>>2]|0;if((g|0)!=(l|0))f[m>>2]=g+(~((g+-4-l|0)>>>2)<<2);Oq(l)}l=f[a+104>>2]|0;if(!l){n=a+84|0;jl(n);o=a+64|0;jl(o);p=a+44|0;jl(p);q=a+12|0;Fj(q);return}g=a+108|0;m=f[g>>2]|0;if((m|0)!=(l|0))f[g>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(l);n=a+84|0;jl(n);o=a+64|0;jl(o);p=a+44|0;jl(p);q=a+12|0;Fj(q);return}function ff(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3480;uj(a+200|0);b=f[a+184>>2]|0;if(b|0){c=a+188|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}kj(a+172|0);b=f[a+152>>2]|0;if(b|0){d=a+156|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+140>>2]|0;if(b|0)Oq(b);b=f[a+128>>2]|0;if(b|0){c=b;do{b=c;c=f[c>>2]|0;Oq(b)}while((c|0)!=0)}c=a+120|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0)Oq(b);b=f[a+108>>2]|0;if(b|0){c=a+112|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0){c=a+76|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0)Oq(b);b=f[a+16>>2]|0;if(b|0){d=a+20|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+12|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Ii(a);Oq(a);return}function gf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;e=u;u=u+144|0;g=e+136|0;h=e+104|0;i=e;j=ln(124)|0;k=f[c+8>>2]|0;f[j+4>>2]=0;f[j>>2]=3656;f[j+12>>2]=3636;f[j+100>>2]=0;f[j+104>>2]=0;f[j+108>>2]=0;l=j+16|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));f[j+112>>2]=k;f[j+116>>2]=d;n=j+120|0;f[n>>2]=0;o=j;f[h>>2]=3636;p=h+4|0;q=p+4|0;f[q>>2]=0;f[q+4>>2]=0;f[q+8>>2]=0;f[q+12>>2]=0;f[q+16>>2]=0;f[q+20>>2]=0;q=f[c+12>>2]|0;f[i+4>>2]=3636;f[i+92>>2]=0;f[i+96>>2]=0;f[i+100>>2]=0;l=i+8|0;m=l+80|0;do{f[l>>2]=0;l=l+4|0}while((l|0)<(m|0));l=q;f[p>>2]=l;m=((f[l+4>>2]|0)-(f[q>>2]|0)>>2>>>0)/3|0;b[g>>0]=0;qh(h+8|0,m,g);Va[f[(f[h>>2]|0)+8>>2]&127](h);f[i>>2]=f[p>>2];fg(i+4|0,h)|0;f[i+36>>2]=q;f[i+40>>2]=d;f[i+44>>2]=k;f[i+48>>2]=j;f[n>>2]=c+72;Sg(j,i);f[a>>2]=o;Qi(i);f[h>>2]=3636;i=f[h+20>>2]|0;if(i|0)Oq(i);i=f[h+8>>2]|0;if(!i){u=e;return}Oq(i);u=e;return}function hf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+48|0;d=c+44|0;e=c+40|0;g=c+36|0;h=c+32|0;i=c;f[h>>2]=f[a+60>>2];j=b+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)){f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,h,h+4|0)|0}wn(i);tk(i);if((f[h>>2]|0)>0){k=a+56|0;l=1;m=0;do{n=l;l=(f[(f[k>>2]|0)+(m>>>5<<2)>>2]&1<<(m&31)|0)!=0;fj(i,n^l^1);m=m+1|0}while((m|0)<(f[h>>2]|0))}ld(i,b);f[g>>2]=f[a+12>>2];h=j;m=f[h>>2]|0;l=f[h+4>>2]|0;if((l|0)>0|(l|0)==0&m>>>0>0){o=l;p=m}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;m=j;o=f[m+4>>2]|0;p=f[m>>2]|0}f[g>>2]=f[a+20>>2];if((o|0)>0|(o|0)==0&p>>>0>0){Fj(i);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(i);u=c;return 1}function jf(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;g=u;u=u+16|0;h=g;if((f[c+56>>2]|0)==-1){i=-1;u=g;return i|0}j=ln(96)|0;tl(j,c);f[h>>2]=j;j=vh(a,h)|0;c=f[h>>2]|0;f[h>>2]=0;if(c|0){h=c+88|0;k=f[h>>2]|0;f[h>>2]=0;if(k|0){h=f[k+8>>2]|0;if(h|0){l=k+12|0;if((f[l>>2]|0)!=(h|0))f[l>>2]=h;Oq(h)}Oq(k)}k=f[c+68>>2]|0;if(k|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}else{x=g;aq(x)}while(1){f[k>>2]=f[w+(v<<2)>>2];f[h>>2]=f[k>>2];Bc(a,h,b,v);g=X(v,e)|0;o=b+(g<<2)|0;q=f[l>>2]|0;n=c+(g<<2)|0;g=f[o+4>>2]|0;y=f[q>>2]|0;z=f[q+4>>2]|0;f[i>>2]=f[o>>2];f[r>>2]=g;f[j>>2]=y;f[s>>2]=z;Od(h,p,i,j);f[n>>2]=f[h>>2];f[n+4>>2]=f[t>>2];v=v+-1|0;if((v|0)<=-1){A=5;break}n=f[m>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){x=n;A=6;break}}if((A|0)==5){u=d;return 1}else if((A|0)==6)aq(x);return 0}function lf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=f[c>>2]|0;c=f[d>>2]|0;e=f[a+4>>2]|0;g=f[d+4>>2]|0;h=e+-1|0;i=(h&e|0)==0;if(!i)if(g>>>0>>0)j=g;else j=(g>>>0)%(e>>>0)|0;else j=h&g;g=(f[a>>2]|0)+(j<<2)|0;k=f[g>>2]|0;while(1){l=f[k>>2]|0;if((l|0)==(d|0))break;else k=l}if((k|0)!=(a+8|0)){l=f[k+4>>2]|0;if(!i)if(l>>>0>>0)m=l;else m=(l>>>0)%(e>>>0)|0;else m=l&h;if((m|0)==(j|0)){n=c;o=21}else o=13}else o=13;do if((o|0)==13){if(c|0){m=f[c+4>>2]|0;if(!i)if(m>>>0>>0)p=m;else p=(m>>>0)%(e>>>0)|0;else p=m&h;if((p|0)==(j|0)){q=c;r=c;o=22;break}}f[g>>2]=0;n=f[d>>2]|0;o=21}while(0);if((o|0)==21){g=n;if(!n)s=g;else{q=n;r=g;o=22}}if((o|0)==22){o=f[q+4>>2]|0;if(!i)if(o>>>0>>0)t=o;else t=(o>>>0)%(e>>>0)|0;else t=o&h;if((t|0)==(j|0))s=r;else{f[(f[a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f[a+44>>2]|0)|0;a=f[c>>2]|0;if(!a){u=b;return 1}c=f[e>>2]|0;if((c|0)!=(a|0))f[e>>2]=c+(~((c+-4-a|0)>>>2)<<2);Oq(a);u=b;return 1}function nf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+48|0;d=c+44|0;e=c+40|0;g=c+36|0;h=c+32|0;i=c;f[h>>2]=f[a+80>>2];j=b+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)){f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,h,h+4|0)|0}wn(i);tk(i);if((f[h>>2]|0)>0){k=a+76|0;l=1;m=0;do{n=l;l=(f[(f[k>>2]|0)+(m>>>5<<2)>>2]&1<<(m&31)|0)!=0;fj(i,n^l^1);m=m+1|0}while((m|0)<(f[h>>2]|0))}ld(i,b);f[g>>2]=f[a+12>>2];h=j;m=f[h>>2]|0;l=f[h+4>>2]|0;if((l|0)>0|(l|0)==0&m>>>0>0){o=l;p=m}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;m=j;o=f[m+4>>2]|0;p=f[m>>2]|0}f[g>>2]=f[a+16>>2];if((o|0)>0|(o|0)==0&p>>>0>0){Fj(i);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(i);u=c;return 1}function of(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+16|0;d=c+12|0;e=c+8|0;g=c+4|0;h=c;if(!b){i=ln(76)|0;j=ln(12)|0;k=f[(f[a+4>>2]|0)+80>>2]|0;f[j+4>>2]=0;f[j>>2]=3908;f[j+8>>2]=k;f[h>>2]=j;rl(i,h,0);j=i;f[g>>2]=j;i=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t=h+4|0;if(n-o>>2>>>0>q>>>0){v=q;w=o}else{x=g;aq(x)}while(1){f[k>>2]=f[w+(v<<2)>>2];f[h>>2]=f[k>>2];Ac(a,h,b,v);g=X(v,e)|0;o=b+(g<<2)|0;q=f[l>>2]|0;n=c+(g<<2)|0;g=f[o+4>>2]|0;y=f[q>>2]|0;z=f[q+4>>2]|0;f[i>>2]=f[o>>2];f[r>>2]=g;f[j>>2]=y;f[s>>2]=z;Od(h,p,i,j);f[n>>2]=f[h>>2];f[n+4>>2]=f[t>>2];v=v+-1|0;if((v|0)<=-1){A=5;break}n=f[m>>2]|0;w=f[n>>2]|0;if((f[n+4>>2]|0)-w>>2>>>0<=v>>>0){x=n;A=6;break}}if((A|0)==5){u=d;return 1}else if((A|0)==6)aq(x);return 0}function qf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>3>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>3;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){o=c;p=f[o+4>>2]|0;q=m;f[q>>2]=f[o>>2];f[q+4>>2]=p;j=j+-1|0;if(!j)break;else m=m+8|0}}if(!l){m=h+(b<<3)|0;if((m|0)==(n|0))return;else{r=i;s=n+(~((n+-8-m|0)>>>3)<<3)|0;break}}else{m=b-k|0;j=m;p=n;while(1){q=c;o=f[q+4>>2]|0;t=p;f[t>>2]=f[q>>2];f[t+4>>2]=o;j=j+-1|0;if(!j)break;else p=p+8|0}r=i;s=n+(m<<3)|0;break}}else{p=g;if(!g)u=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-8-g|0)>>>3)<<3);Oq(p);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;u=0}if(b>>>0>536870911)aq(a);j=u>>2;p=u>>3>>>0<268435455?(j>>>0>>0?b:j):536870911;if(p>>>0>536870911)aq(a);j=ln(p<<3)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(p<<3);p=b;l=j;while(1){o=c;t=f[o+4>>2]|0;q=l;f[q>>2]=f[o>>2];f[q+4>>2]=t;p=p+-1|0;if(!p)break;else l=l+8|0}r=k;s=j+(b<<3)|0}while(0);f[r>>2]=s;return}function rf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,g=0.0,h=0.0,i=0.0,j=0.0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;e=+$(n[b>>2]);g=+K(+e);h=+$(n[b+4>>2]);i=g+ +K(+h);g=+$(n[b+8>>2]);j=i+ +K(+g);b=j>1.0e-06;i=1.0/j;k=f[a+12>>2]|0;j=+(k|0);l=~~+J(+((b?i*e:1.0)*j+.5));m=~~+J(+((b?i*h:0.0)*j+.5));o=(l|0)>-1;p=k-(o?l:0-l|0)-((m|0)>-1?m:0-m|0)|0;l=(p|0)<0;q=(l?((m|0)>0?p:0-p|0):0)+m|0;m=l?0:p;p=(b?i*g:0.0)<0.0?0-m|0:m;do if(!o){if((q|0)<0)r=(p|0)>-1?p:0-p|0;else r=(f[a+8>>2]|0)-((p|0)>-1?p:0-p|0)|0;if((p|0)<0){s=(q|0)>-1?q:0-q|0;t=r;break}else{s=(f[a+8>>2]|0)-((q|0)>-1?q:0-q|0)|0;t=r;break}}else{s=k+p|0;t=k+q|0}while(0);q=(t|0)==0;p=(s|0)==0;r=f[a+8>>2]|0;if(!(s|t)){u=r;v=r;f[c>>2]=u;f[d>>2]=v;return}a=(r|0)==(s|0);if(q&a){u=s;v=s;f[c>>2]=u;f[d>>2]=v;return}o=(r|0)==(t|0);if(p&o){u=t;v=t;f[c>>2]=u;f[d>>2]=v;return}if(q&(k|0)<(s|0)){u=0;v=(k<<1)-s|0;f[c>>2]=u;f[d>>2]=v;return}if(o&(k|0)>(s|0)){u=t;v=(k<<1)-s|0;f[c>>2]=u;f[d>>2]=v;return}if(a&(k|0)>(t|0)){u=(k<<1)-t|0;v=s;f[c>>2]=u;f[d>>2]=v;return}if(!p){u=t;v=s;f[c>>2]=u;f[d>>2]=v;return}u=(k|0)<(t|0)?(k<<1)-t|0:t;v=0;f[c>>2]=u;f[d>>2]=v;return}function sf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[a>>2]=f[d>>2];d=a+4|0;f[d>>2]=(f[c>>2]|0)-(f[b>>2]|0);j=e+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)?(k=e+4|0,f[i>>2]=f[k>>2],f[h>>2]=f[i>>2],Me(e,h,a,a+4|0)|0,l=j,j=f[l+4>>2]|0,!((j|0)>0|(j|0)==0&(f[l>>2]|0)>>>0>0)):0){f[i>>2]=f[k>>2];f[h>>2]=f[i>>2];Me(e,h,d,d+4|0)|0;m=i}else m=i;if(!(f[d>>2]|0)){u=g;return 1}d=a+12|0;Gg(d);m=a+1068|0;Mm(m);k=a+1088|0;Mm(k);l=a+1108|0;Mm(l);f[i>>2]=f[b>>2];f[i+4>>2]=f[b+4>>2];f[i+8>>2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4>>2];f[h+8>>2]=f[c+8>>2];ib(a,i,h);Ye(d,e);Bg(m,e);Bg(k,e);Bg(l,e);u=g;return 1}function tf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[a>>2]=f[d>>2];d=a+4|0;f[d>>2]=(f[c>>2]|0)-(f[b>>2]|0);j=e+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)?(k=e+4|0,f[i>>2]=f[k>>2],f[h>>2]=f[i>>2],Me(e,h,a,a+4|0)|0,l=j,j=f[l+4>>2]|0,!((j|0)>0|(j|0)==0&(f[l>>2]|0)>>>0>0)):0){f[i>>2]=f[k>>2];f[h>>2]=f[i>>2];Me(e,h,d,d+4|0)|0;m=i}else m=i;if(!(f[d>>2]|0)){u=g;return 1}d=a+12|0;Gg(d);m=a+1068|0;Mm(m);k=a+1088|0;Mm(k);l=a+1108|0;Mm(l);f[i>>2]=f[b>>2];f[i+4>>2]=f[b+4>>2];f[i+8>>2]=f[b+8>>2];f[h>>2]=f[c>>2];f[h+4>>2]=f[c+4>>2];f[h+8>>2]=f[c+8>>2];kb(a,i,h);Ye(d,e);Bg(m,e);Bg(k,e);Bg(l,e);u=g;return 1}function uf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;c=u;u=u+32|0;d=c;e=a+8|0;g=f[e>>2]|0;h=a+4|0;i=f[h>>2]|0;j=i;if(g-i>>2>>>0>=b>>>0){sj(i|0,0,b<<2|0)|0;f[h>>2]=i+(b<<2);u=c;return}k=f[a>>2]|0;l=i-k>>2;m=l+b|0;n=k;if(m>>>0>1073741823)aq(a);o=g-k|0;p=o>>1;q=o>>2>>>0<536870911?(p>>>0>>0?m:p):1073741823;f[d+12>>2]=0;f[d+16>>2]=a+8;do if(q)if(q>>>0>1073741823){p=ra(8)|0;Oo(p,16035);f[p>>2]=7256;va(p|0,1112,110)}else{r=ln(q<<2)|0;break}else r=0;while(0);f[d>>2]=r;p=r+(l<<2)|0;l=d+8|0;m=d+4|0;f[m>>2]=p;o=r+(q<<2)|0;q=d+12|0;f[q>>2]=o;r=p+(b<<2)|0;sj(p|0,0,b<<2|0)|0;f[l>>2]=r;if((j|0)==(n|0)){s=p;t=q;v=l;w=k;x=r;y=i;z=o;A=g}else{g=j;j=p;do{g=g+-4|0;p=f[g>>2]|0;f[g>>2]=0;f[j+-4>>2]=p;j=(f[m>>2]|0)+-4|0;f[m>>2]=j}while((g|0)!=(n|0));s=j;t=q;v=l;w=f[a>>2]|0;x=f[l>>2]|0;y=f[h>>2]|0;z=f[q>>2]|0;A=f[e>>2]|0}f[a>>2]=s;f[m>>2]=w;f[h>>2]=x;f[v>>2]=y;f[e>>2]=z;f[t>>2]=A;f[d>>2]=w;ki(d);u=c;return}function vf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+80|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function wf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=f[a+8>>2]|0;e=a+112|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=a+116|0;a=c+68|0;c=f[o+96>>2]|0;o=0;while(1){h=o*3|0;if((h|0)==-1)r=-1;else r=f[(f[d>>2]|0)+(h<<2)>>2]|0;i=f[(f[m>>2]|0)+12>>2]|0;g=f[i+(r<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}k=f[a>>2]|0;f[k+(f[c+(o*12|0)>>2]<<2)>>2]=g;g=h+1|0;if((g|0)==-1)t=-1;else t=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(t<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+4>>2]<<2)>>2]=g;g=h+2|0;if((g|0)==-1)u=-1;else u=f[(f[d>>2]|0)+(g<<2)>>2]|0;g=f[i+(u<<2)>>2]|0;if(g>>>0>=p>>>0){q=0;s=12;break}f[k+(f[c+(o*12|0)+8>>2]<<2)>>2]=g;o=o+1|0;if(o>>>0>=e>>>0){q=1;s=12;break}}if((s|0)==12)return q|0;return 0}function xf(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=u;u=u+16|0;h=d;i=f[a+124>>2]|0;if(!i){u=d;return}j=i+-1|0;k=(j&i|0)==0;if(!k)if(i>>>0>g>>>0)l=g;else l=(g>>>0)%(i>>>0)|0;else l=j&g;m=f[(f[a+120>>2]|0)+(l<<2)>>2]|0;if(!m){u=d;return}n=f[m>>2]|0;if(!n){u=d;return}a:do if(k){m=n;while(1){o=f[m+4>>2]|0;p=(o|0)==(g|0);if(!(p|(o&j|0)==(l|0))){q=24;break}if(p?(f[m+8>>2]|0)==(g|0):0){r=m;break a}m=f[m>>2]|0;if(!m){q=24;break}}if((q|0)==24){u=d;return}}else{m=n;while(1){p=f[m+4>>2]|0;if((p|0)==(g|0)){if((f[m+8>>2]|0)==(g|0)){r=m;break a}}else{if(p>>>0>>0)s=p;else s=(p>>>0)%(i>>>0)|0;if((s|0)!=(l|0)){q=24;break}}m=f[m>>2]|0;if(!m){q=24;break}}if((q|0)==24){u=d;return}}while(0);q=f[r+12>>2]|0;if((q|0)==-1){u=d;return}f[h>>2]=q;f[h+4>>2]=c;b[h+8>>0]=e&1;e=a+112|0;c=f[e>>2]|0;if((c|0)==(f[a+116>>2]|0))yi(a+108|0,h);else{f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];f[c+8>>2]=f[h+8>>2];f[e>>2]=(f[e>>2]|0)+12}u=d;return}function yf(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=d[b>>1]|0;e=d[b+2>>1]|0;g=d[b+4>>1]|0;h=d[b+6>>1]|0;b=((((c^318)&65535)+239^e&65535)+239^g&65535)+239^h&65535;i=f[a+4>>2]|0;if(!i){j=0;return j|0}k=i+-1|0;l=(k&i|0)==0;if(!l)if(b>>>0>>0)m=b;else m=(b>>>0)%(i>>>0)|0;else m=b&k;n=f[(f[a>>2]|0)+(m<<2)>>2]|0;if(!n){j=0;return j|0}a=f[n>>2]|0;if(!a){j=0;return j|0}if(l){l=a;while(1){n=f[l+4>>2]|0;o=(n|0)==(b|0);if(!(o|(n&k|0)==(m|0))){j=0;p=25;break}if((((o?(o=l+8|0,(d[o>>1]|0)==c<<16>>16):0)?(d[o+2>>1]|0)==e<<16>>16:0)?(d[l+12>>1]|0)==g<<16>>16:0)?(d[o+6>>1]|0)==h<<16>>16:0){j=l;p=25;break}l=f[l>>2]|0;if(!l){j=0;p=25;break}}if((p|0)==25)return j|0}else q=a;while(1){a=f[q+4>>2]|0;if((a|0)==(b|0)){l=q+8|0;if((((d[l>>1]|0)==c<<16>>16?(d[l+2>>1]|0)==e<<16>>16:0)?(d[q+12>>1]|0)==g<<16>>16:0)?(d[l+6>>1]|0)==h<<16>>16:0){j=q;p=25;break}}else{if(a>>>0>>0)r=a;else r=(a>>>0)%(i>>>0)|0;if((r|0)!=(m|0)){j=0;p=25;break}}q=f[q>>2]|0;if(!q){j=0;p=25;break}}if((p|0)==25)return j|0;return 0}function zf(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+32|0;h=g+12|0;i=g;f[a>>2]=f[d>>2];d=a+4|0;f[d>>2]=(f[c>>2]|0)-(f[b>>2]|0);j=e+16|0;k=j;l=f[k+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0)?(k=e+4|0,f[i>>2]=f[k>>2],f[h>>2]=f[i>>2],Me(e,h,a,a+4|0)|0,l=j,j=f[l+4>>2]|0,!((j|0)>0|(j|0)==0&(f[l>>2]|0)>>>0>0)):0){f[i>>2]=f[k>>2];f[h>>2]=f[i>>2];Me(e,h,d,d+4|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(k){l=f[d+4>>2]|0;if(l>>>0>255){m=0;u=a;return m|0}else n=l}else n=j&255;if(!n){b[h>>0]=0;n=c+16|0;l=f[n+4>>2]|0;if(!((l|0)>0|(l|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}m=1;u=a;return m|0}n=d+4|0;l=f[n>>2]|0;b[h>>0]=k?l:j&255;k=c+16|0;o=k;p=f[o>>2]|0;q=f[o+4>>2]|0;if((q|0)>0|(q|0)==0&p>>>0>0){r=j;s=q;t=p;v=l}else{f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;h=k;r=b[i>>0]|0;s=f[h+4>>2]|0;t=f[h>>2]|0;v=f[n>>2]|0}n=r<<24>>24<0;h=n?f[d>>2]|0:d;if(!((s|0)>0|(s|0)==0&t>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+(n?v:r&255)|0)|0}m=1;u=a;return m|0}function Cf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=a+4|0;d=f[a>>2]|0;e=((f[c>>2]|0)-d|0)/24|0;g=e+1|0;if(g>>>0>178956970)aq(a);h=a+8|0;i=((f[h>>2]|0)-d|0)/24|0;d=i<<1;j=i>>>0<89478485?(d>>>0>>0?g:d):178956970;do if(j)if(j>>>0>178956970){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j*24|0)|0;break}else k=0;while(0);d=k+(e*24|0)|0;g=d;i=k+(j*24|0)|0;f[d>>2]=1196;f[k+(e*24|0)+4>>2]=f[b+4>>2];fk(k+(e*24|0)+8|0,b+8|0);f[k+(e*24|0)+20>>2]=f[b+20>>2];b=d+24|0;e=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(e|0)){l=g;m=e;n=e}else{j=k;k=g;g=d;do{f[g+-24>>2]=1196;f[g+-20>>2]=f[j+-20>>2];d=g+-16|0;o=j+-16|0;f[d>>2]=0;p=g+-12|0;f[p>>2]=0;f[g+-8>>2]=0;f[d>>2]=f[o>>2];d=j+-12|0;f[p>>2]=f[d>>2];p=j+-8|0;f[g+-8>>2]=f[p>>2];f[p>>2]=0;f[d>>2]=0;f[o>>2]=0;f[g+-4>>2]=f[j+-4>>2];j=j+-24|0;g=k+-24|0;k=g}while((j|0)!=(e|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=b;f[h>>2]=i;i=m;if((n|0)!=(i|0)){h=n;do{h=h+-24|0;Va[f[f[h>>2]>>2]&127](h)}while((h|0)!=(i|0))}if(!m)return;Oq(m);return}function Df(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+32|0;d=c+24|0;e=c+16|0;g=c+8|0;h=c;f[a>>2]=3588;f[a+4>>2]=f[b+4>>2];i=a+8|0;j=b+8|0;f[i>>2]=0;k=a+12|0;f[k>>2]=0;l=a+16|0;f[l>>2]=0;m=b+12|0;n=f[m>>2]|0;do if(n|0)if((n|0)<0)aq(i);else{o=((n+-1|0)>>>5)+1|0;p=ln(o<<2)|0;f[i>>2]=p;f[k>>2]=0;f[l>>2]=o;o=f[j>>2]|0;f[g>>2]=o;f[g+4>>2]=0;p=f[m>>2]|0;f[h>>2]=o+(p>>>5<<2);f[h+4>>2]=p&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);break}while(0);i=a+20|0;f[i>>2]=0;m=a+24|0;f[m>>2]=0;j=a+28|0;f[j>>2]=0;a=b+24|0;l=f[a>>2]|0;if(!l){u=c;return}if((l|0)<0)aq(i);k=((l+-1|0)>>>5)+1|0;l=ln(k<<2)|0;f[i>>2]=l;f[m>>2]=0;f[j>>2]=k;k=f[b+20>>2]|0;f[g>>2]=k;f[g+4>>2]=0;b=f[a>>2]|0;f[h>>2]=k+(b>>>5<<2);f[h+4>>2]=b&31;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[d>>2]=f[h>>2];f[d+4>>2]=f[h+4>>2];Tf(i,e,d);u=c;return}function Ef(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b[c>>0]|0;e=b[c+1>>0]|0;g=b[c+2>>0]|0;h=b[c+3>>0]|0;c=(((d&255^318)+239^e&255)+239^g&255)+239^h&255;i=f[a+4>>2]|0;if(!i){j=0;return j|0}k=i+-1|0;l=(k&i|0)==0;if(!l)if(c>>>0>>0)m=c;else m=(c>>>0)%(i>>>0)|0;else m=c&k;n=f[(f[a>>2]|0)+(m<<2)>>2]|0;if(!n){j=0;return j|0}a=f[n>>2]|0;if(!a){j=0;return j|0}if(l){l=a;while(1){n=f[l+4>>2]|0;o=(n|0)==(c|0);if(!(o|(n&k|0)==(m|0))){j=0;p=25;break}if((((o?(o=l+8|0,(b[o>>0]|0)==d<<24>>24):0)?(b[o+1>>0]|0)==e<<24>>24:0)?(b[o+2>>0]|0)==g<<24>>24:0)?(b[o+3>>0]|0)==h<<24>>24:0){j=l;p=25;break}l=f[l>>2]|0;if(!l){j=0;p=25;break}}if((p|0)==25)return j|0}else q=a;while(1){a=f[q+4>>2]|0;if((a|0)==(c|0)){l=q+8|0;if((((b[l>>0]|0)==d<<24>>24?(b[l+1>>0]|0)==e<<24>>24:0)?(b[l+2>>0]|0)==g<<24>>24:0)?(b[l+3>>0]|0)==h<<24>>24:0){j=q;p=25;break}}else{if(a>>>0>>0)r=a;else r=(a>>>0)%(i>>>0)|0;if((r|0)!=(m|0)){j=0;p=25;break}}q=f[q>>2]|0;if(!q){j=0;p=25;break}}if((p|0)==25)return j|0;return 0}function Ff(a,b){a=a|0;b=b|0;var c=0,d=0,e=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0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=a+48|0;s=a+52|0;a=i+4|0;t=j+4|0;v=h+4|0;if(n-o>>2>>>0>q>>>0){w=q;x=o}else{y=m;aq(y)}while(1){f[k>>2]=f[x+(w<<2)>>2];f[h>>2]=f[k>>2];ub(l,h,b,w);m=X(w,e)|0;o=b+(m<<2)|0;q=c+(m<<2)|0;m=f[o+4>>2]|0;n=f[r>>2]|0;z=f[s>>2]|0;f[i>>2]=f[o>>2];f[a>>2]=m;f[j>>2]=n;f[t>>2]=z;Od(h,p,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[v>>2];w=w+-1|0;if((w|0)<=-1){A=3;break}q=f[g>>2]|0;x=f[q>>2]|0;if((f[q+4>>2]|0)-x>>2>>>0<=w>>>0){y=q;A=4;break}}if((A|0)==3){u=d;return 1}else if((A|0)==4)aq(y);return 0}function Hf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h;j=h+16|0;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Qa[f[(f[b>>2]|0)+48>>2]&127](b)|0;m=Ra[f[(f[b>>2]|0)+56>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Ra[f[(f[b>>2]|0)+52>>2]&127](b,d)|0;if(!n){f[i>>2]=f[b+52>>2];f[i+4>>2]=l;f[i+12>>2]=m;f[i+8>>2]=m+12;Cd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[i>>2]=f[b+52>>2];f[i+4>>2]=n;f[i+12>>2]=m;f[i+8>>2]=m+12;Ad(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function If(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;d=u;u=u+32|0;h=d+24|0;i=d+16|0;j=d;k=d+8|0;l=a+40|0;f[a+44>>2]=g;g=a+36|0;m=f[g>>2]|0;n=f[m+4>>2]|0;o=f[m>>2]|0;p=n-o|0;if((p|0)<=0){u=d;return 1}q=(p>>>2)+-1|0;p=a+8|0;r=a+48|0;s=a+52|0;a=i+4|0;t=j+4|0;v=h+4|0;if(n-o>>2>>>0>q>>>0){w=q;x=o}else{y=m;aq(y)}while(1){f[k>>2]=f[x+(w<<2)>>2];f[h>>2]=f[k>>2];tb(l,h,b,w);m=X(w,e)|0;o=b+(m<<2)|0;q=c+(m<<2)|0;m=f[o+4>>2]|0;n=f[r>>2]|0;z=f[s>>2]|0;f[i>>2]=f[o>>2];f[a>>2]=m;f[j>>2]=n;f[t>>2]=z;Od(h,p,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[v>>2];w=w+-1|0;if((w|0)<=-1){A=3;break}q=f[g>>2]|0;x=f[q>>2]|0;if((f[q+4>>2]|0)-x>>2>>>0<=w>>>0){y=q;A=4;break}}if((A|0)==3){u=d;return 1}else if((A|0)==4)aq(y);return 0}function Jf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=f[b>>2]|0;b=f[c>>2]|0;e=b-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;k=b;if(e>>>0<=h-i>>2>>>0){l=a+4|0;m=(f[l>>2]|0)-i>>2;n=e>>>0>m>>>0;o=n?d+(m<<2)|0:b;b=o-d|0;m=b>>2;if(m|0)im(i|0,d|0,b|0)|0;b=j+(m<<2)|0;if(!n){n=f[l>>2]|0;if((n|0)==(b|0))return;f[l>>2]=n+(~((n+-4-b|0)>>>2)<<2);return}b=f[c>>2]|0;c=o;if((b|0)==(c|0))return;n=f[l>>2]|0;m=b+-4-o|0;o=c;c=n;while(1){f[c>>2]=f[o>>2];o=o+4|0;if((o|0)==(b|0))break;else c=c+4|0}f[l>>2]=n+((m>>>2)+1<<2);return}m=i;if(!i)p=h;else{h=a+4|0;n=f[h>>2]|0;if((n|0)!=(j|0))f[h>>2]=n+(~((n+-4-i|0)>>>2)<<2);Oq(m);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;p=0}if(e>>>0>1073741823)aq(a);h=p>>1;m=p>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(m>>>0>1073741823)aq(a);h=ln(m<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(m<<2);m=d;if((k|0)==(m|0))return;g=k+-4-d|0;d=m;m=h;while(1){f[m>>2]=f[d>>2];d=d+4|0;if((d|0)==(k|0))break;else m=m+4|0}f[e>>2]=h+((g>>>2)+1<<2);return}function Kf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(((d-g|0)/12|0)>>>0>=b>>>0){sj(g|0,0,b*12|0)|0;f[e>>2]=h+(b*12|0);return}i=f[a>>2]|0;j=(g-i|0)/12|0;g=j+b|0;k=i;if(g>>>0>357913941)aq(a);l=(d-i|0)/12|0;d=l<<1;m=l>>>0<178956970?(d>>>0>>0?g:d):357913941;do if(m)if(m>>>0>357913941){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{n=ln(m*12|0)|0;break}else n=0;while(0);d=n+(j*12|0)|0;j=d;g=n+(m*12|0)|0;sj(d|0,0,b*12|0)|0;m=d+(b*12|0)|0;if((h|0)==(k|0)){o=j;p=i;q=h}else{i=h;h=j;j=d;do{d=j+-12|0;b=i;i=i+-12|0;f[d>>2]=0;n=j+-8|0;f[n>>2]=0;f[j+-4>>2]=0;f[d>>2]=f[i>>2];d=b+-8|0;f[n>>2]=f[d>>2];n=b+-4|0;f[j+-4>>2]=f[n>>2];f[n>>2]=0;f[d>>2]=0;f[i>>2]=0;j=h+-12|0;h=j}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=g;g=p;if((q|0)!=(g|0)){c=q;do{q=c;c=c+-12|0;m=f[c>>2]|0;if(m|0){e=q+-8|0;q=f[e>>2]|0;if((q|0)!=(m|0))f[e>>2]=q+(~((q+-4-m|0)>>>2)<<2);Oq(m)}}while((c|0)!=(g|0))}if(!p)return;Oq(p);return}function Lf(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+100|0;h=f[e>>2]|0;i=(f[h+28>>2]|0)-(f[h+24>>2]|0)>>2;f[c>>2]=0;h=a+104|0;j=f[h>>2]|0;k=f[g>>2]|0;l=j-k>>2;m=k;k=j;if(i>>>0<=l>>>0){if(i>>>0>>0?(j=m+(i<<2)|0,(j|0)!=(k|0)):0)f[h>>2]=k+(~((k+-4-j|0)>>>2)<<2)}else Ch(g,i-l|0,c);l=a+120|0;a=f[l>>2]|0;if(!a){i=f[e>>2]|0;g=(f[i+4>>2]|0)-(f[i>>2]|0)>>2;i=(g>>>0)/3|0;if(g>>>0<=2){u=b;return 1}g=0;do{f[d>>2]=g*3;f[c>>2]=f[d>>2];wb(e,c);g=g+1|0}while((g|0)<(i|0));u=b;return 1}else{i=f[a>>2]|0;if((f[a+4>>2]|0)==(i|0)){u=b;return 1}a=0;g=i;do{f[d>>2]=f[g+(a<<2)>>2];f[c>>2]=f[d>>2];wb(e,c);a=a+1|0;i=f[l>>2]|0;g=f[i>>2]|0}while(a>>>0<(f[i+4>>2]|0)-g>>2>>>0);u=b;return 1}return 0}function Mf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-4194304|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-4177920|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+4194304|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1077936128|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Nf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-2097152|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-2080768|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+6291456|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1075838976|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Of(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-1048576|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1032192|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+7340032|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1074790400|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Pf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g<<1,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+((X(d,g)|0)<<1)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Qf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g<<2,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+((X(d,g)|0)<<2)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Rf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-262144|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-245760|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8126464|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1074003968|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Sf(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-131072|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-114688|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8257536|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1073872896|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2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=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-32768|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-16384|0;b[m>>0]=n;b[m+1>>0]=n>>>8;o=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;n=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+8355840|0;b[n>>0]=m;b[n+1>>0]=m>>>8;b[n+2>>0]=m>>>16;o=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;n=j+-1073774592|0;b[m>>0]=n;b[m+1>>0]=n>>>8;b[m+2>>0]=n>>>16;b[m+3>>0]=n>>>24;o=(f[l>>2]|0)+4|0;break}else{o=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;o=(f[l>>2]|0)+1|0}while(0);k=((o|0)<0)<<31>>31;Gn(e);yh(o,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,o|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,o|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function Vf(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=f[b>>2]|0;d=f[b+4>>2]|0;e=f[b+8>>2]|0;g=f[b+12>>2]|0;b=(((c^318)+239^d)+239^e)+239^g;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(b>>>0>>0)l=b;else l=(b>>>0)%(h>>>0)|0;else l=b&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(b|0);if(!(n|(m&j|0)==(l|0))){i=0;o=25;break}if((((n?(f[k+8>>2]|0)==(c|0):0)?(f[k+12>>2]|0)==(d|0):0)?(f[k+16>>2]|0)==(e|0):0)?(f[k+20>>2]|0)==(g|0):0){i=k;o=25;break}k=f[k>>2]|0;if(!k){i=0;o=25;break}}if((o|0)==25)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(b|0)){if((((f[p+8>>2]|0)==(c|0)?(f[p+12>>2]|0)==(d|0):0)?(f[p+16>>2]|0)==(e|0):0)?(f[p+20>>2]|0)==(g|0):0){i=p;o=25;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=25;break}}p=f[p>>2]|0;if(!p){i=0;o=25;break}}if((o|0)==25)return i|0;return 0}function Wf(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;a=u;u=u+96|0;j=a;if(!c){k=-1;u=a;return k|0}Tm(j);Jj(j,d,0,g&255,i,0,g,0,0,0);i=jf(c,j,1,e)|0;d=f[(f[c+8>>2]|0)+(i<<2)>>2]|0;if(e|0){l=d+84|0;m=d+68|0;n=d+40|0;o=d+64|0;d=0;do{if(!(b[l>>0]|0))p=f[(f[m>>2]|0)+(d<<2)>>2]|0;else p=d;q=h+(X(d,g)|0)|0;r=n;s=f[r>>2]|0;t=un(s|0,f[r+4>>2]|0,p|0,0)|0;kh((f[f[o>>2]>>2]|0)+t|0,q|0,s|0)|0;d=d+1|0}while((d|0)!=(e|0))}d=c+80|0;c=f[d>>2]|0;if(c)if((c|0)==(e|0))v=10;else w=-1;else{f[d>>2]=e;v=10}if((v|0)==10)w=i;i=j+88|0;v=f[i>>2]|0;f[i>>2]=0;if(v|0){i=f[v+8>>2]|0;if(i|0){e=v+12|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}Oq(v)}v=f[j+68>>2]|0;if(v|0){i=j+72|0;e=f[i>>2]|0;if((e|0)!=(v|0))f[i>>2]=e+(~((e+-4-v|0)>>>2)<<2);Oq(v)}v=j+64|0;j=f[v>>2]|0;f[v>>2]=0;if(j|0){v=f[j>>2]|0;if(v|0){e=j+4|0;if((f[e>>2]|0)!=(v|0))f[e>>2]=v;Oq(v)}Oq(j)}k=w;u=a;return k|0}function Xf(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=u;u=u+32|0;i=h;j=h+16|0;k=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;do if((c+-1|0)>>>0<6&(Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)==1){l=Qa[f[(f[b>>2]|0)+48>>2]&127](b)|0;m=Ra[f[(f[b>>2]|0)+56>>2]&127](b,d)|0;if((l|0)==0|(m|0)==0){f[a>>2]=0;u=h;return}n=Ra[f[(f[b>>2]|0)+52>>2]&127](b,d)|0;if(!n){f[i>>2]=f[b+52>>2];f[i+4>>2]=l;f[i+12>>2]=m;f[i+8>>2]=m+12;qd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}else{f[i>>2]=f[b+52>>2];f[i+4>>2]=n;f[i+12>>2]=m;f[i+8>>2]=m+12;pd(a,j,c,k,e,i,g);if(!(f[a>>2]|0)){f[a>>2]=0;break}u=h;return}}while(0);f[a>>2]=0;u=h;return}function Yf(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=f[d>>2]|0;g=f[d+4>>2]|0;if((e|0)==(g|0)){h=0;i=a+12|0;j=a+8|0}else{d=f[c>>2]|0;c=a+8|0;k=a+12|0;a=0;l=e;while(1){e=f[l>>2]|0;m=f[d+(e<<2)>>2]|0;if(m>>>0>>0)n=a;else{o=f[c>>2]|0;p=(f[k>>2]|0)-o|0;q=o;if((p|0)>0){o=p>>>2;p=0;do{r=f[q+(p<<2)>>2]|0;s=f[r+68>>2]|0;if(!(b[r+84>>0]|0))t=f[s+(e<<2)>>2]|0;else t=e;f[s+(m<<2)>>2]=t;p=p+1|0}while((p|0)<(o|0))}n=m+1|0}l=l+4|0;if((l|0)==(g|0)){h=n;i=k;j=c;break}else a=n}}n=f[i>>2]|0;a=f[j>>2]|0;if((n-a|0)>0){u=0;v=a;w=n}else return;while(1){n=f[v+(u<<2)>>2]|0;b[n+84>>0]=0;a=n+68|0;c=n+72|0;n=f[c>>2]|0;k=f[a>>2]|0;g=n-k>>2;l=k;k=n;if(h>>>0<=g>>>0)if(h>>>0>>0?(n=l+(h<<2)|0,(n|0)!=(k|0)):0){f[c>>2]=k+(~((k+-4-n|0)>>>2)<<2);x=v;y=w}else{x=v;y=w}else{Ch(a,h-g|0,6220);x=f[j>>2]|0;y=f[i>>2]|0}u=u+1|0;if((u|0)>=(y-x>>2|0))break;else{v=x;w=y}}return}function Zf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)im(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=((c+-4-o|0)>>>2)+1|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+(p<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);Oq(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)aq(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)aq(a);h=ln(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=((c+-4-d|0)>>>2)+1|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+(p<<2);return}function _f(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=u;u=u+32|0;e=d;g=a+40|0;h=(f[c>>2]|0)+(f[g>>2]|0)|0;i=a+24|0;j=f[a+32>>2]|0;k=j+-16384|0;do if(k>>>0>=64){if(k>>>0<16384){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;b[m>>0]=j;b[m+1>>0]=j>>>8;n=(f[l>>2]|0)+2|0;break}if(k>>>0<4194304){l=a+28|0;m=(f[i>>2]|0)+(f[l>>2]|0)|0;o=j+8372224|0;b[m>>0]=o;b[m+1>>0]=o>>>8;b[m+2>>0]=o>>>16;n=(f[l>>2]|0)+3|0;break}if(k>>>0<1073741824){l=a+28|0;o=(f[i>>2]|0)+(f[l>>2]|0)|0;m=j+-1073758208|0;b[o>>0]=m;b[o+1>>0]=m>>>8;b[o+2>>0]=m>>>16;b[o+3>>0]=m>>>24;n=(f[l>>2]|0)+4|0;break}else{n=f[a+28>>2]|0;break}}else{l=a+28|0;b[(f[i>>2]|0)+(f[l>>2]|0)>>0]=k;n=(f[l>>2]|0)+1|0}while(0);k=((n|0)<0)<<31>>31;Gn(e);yh(n,k,e)|0;i=e+4|0;a=(f[i>>2]|0)-(f[e>>2]|0)|0;im(h+a|0,h|0,n|0)|0;kh(h|0,f[e>>2]|0,a|0)|0;h=g;g=f[h>>2]|0;j=f[h+4>>2]|0;h=Vn(a|0,0,n|0,k|0)|0;k=Vn(h|0,I|0,g|0,j|0)|0;Cl(c,k,I);k=e+12|0;c=f[k>>2]|0;f[k>>2]=0;if(c|0)Oq(c);c=f[e>>2]|0;if(!c){u=d;return}if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c);u=d;return}function $f(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=b;e=c-d>>2;g=a+8|0;h=f[g>>2]|0;i=f[a>>2]|0;j=i;if(e>>>0<=h-i>>2>>>0){k=a+4|0;l=(f[k>>2]|0)-i>>2;m=e>>>0>l>>>0;n=b+(l<<2)|0;l=m?n:c;o=l;p=o-d|0;q=p>>2;if(q|0)im(i|0,b|0,p|0)|0;p=j+(q<<2)|0;if(!m){m=f[k>>2]|0;if((m|0)==(p|0))return;f[k>>2]=m+(~((m+-4-p|0)>>>2)<<2);return}if((l|0)==(c|0))return;l=f[k>>2]|0;p=c+-4-o|0;o=n;n=l;while(1){f[n>>2]=f[o>>2];o=o+4|0;if((o|0)==(c|0))break;else n=n+4|0}f[k>>2]=l+((p>>>2)+1<<2);return}p=i;if(!i)r=h;else{h=a+4|0;l=f[h>>2]|0;if((l|0)!=(j|0))f[h>>2]=l+(~((l+-4-i|0)>>>2)<<2);Oq(p);f[g>>2]=0;f[h>>2]=0;f[a>>2]=0;r=0}if(e>>>0>1073741823)aq(a);h=r>>1;p=r>>2>>>0<536870911?(h>>>0>>0?e:h):1073741823;if(p>>>0>1073741823)aq(a);h=ln(p<<2)|0;e=a+4|0;f[e>>2]=h;f[a>>2]=h;f[g>>2]=h+(p<<2);if((b|0)==(c|0))return;p=c+-4-d|0;d=b;b=h;while(1){f[b>>2]=f[d>>2];d=d+4|0;if((d|0)==(c|0))break;else b=b+4|0}f[e>>2]=h+((p>>>2)+1<<2);return}function ag(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0;g=u;u=u+80|0;h=g;i=g+64|0;Il(h);j=f[(f[a+8>>2]|0)+56>>2]|0;k=X(Vl(5)|0,d)|0;Jj(h,j,0,d&255,5,0,k,((k|0)<0)<<31>>31,0,0);k=ln(96)|0;tl(k,h);Bj(k,c)|0;f[i>>2]=k;gj(a,i);k=f[i>>2]|0;f[i>>2]=0;if(k|0){i=k+88|0;c=f[i>>2]|0;f[i>>2]=0;if(c|0){i=f[c+8>>2]|0;if(i|0){h=c+12|0;if((f[h>>2]|0)!=(i|0))f[h>>2]=i;Oq(i)}Oq(c)}c=f[k+68>>2]|0;if(c|0){i=k+72|0;h=f[i>>2]|0;if((h|0)!=(c|0))f[i>>2]=h+(~((h+-4-c|0)>>>2)<<2);Oq(c)}c=k+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){i=h+4|0;if((f[i>>2]|0)!=(c|0))f[i>>2]=c;Oq(c)}Oq(h)}Oq(k)}if(!e){u=g;return}k=f[a+32>>2]|0;b[k+84>>0]=0;a=k+68|0;h=k+72|0;k=f[h>>2]|0;c=f[a>>2]|0;i=k-c>>2;d=k;if(i>>>0>>0){Ch(a,e-i|0,1532);u=g;return}if(i>>>0<=e>>>0){u=g;return}i=c+(e<<2)|0;if((i|0)==(d|0)){u=g;return}f[h>>2]=d+(~((d+-4-i|0)>>>2)<<2);u=g;return}function bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0;c=u;u=u+16|0;d=c+4|0;e=c;g=a+4|0;h=f[g>>2]|0;i=a+8|0;j=f[i>>2]|0;if((j|0)==(h|0))k=h;else{l=j+(~((j+-4-h|0)>>>2)<<2)|0;f[i>>2]=l;k=l}l=a+16|0;h=f[l>>2]|0;j=a+20|0;m=f[j>>2]|0;n=h;if((m|0)!=(h|0))f[j>>2]=m+(~((m+-4-n|0)>>>2)<<2);m=f[b>>2]|0;h=f[b+4>>2]|0;if((m|0)==(h|0)){u=c;return}b=a+12|0;a=m;m=k;k=n;while(1){n=f[a>>2]|0;f[d>>2]=n;if((m|0)==(f[b>>2]|0)){Ri(g,d);o=f[l>>2]|0}else{f[m>>2]=n;f[i>>2]=m+4;o=k}n=f[d>>2]|0;p=f[j>>2]|0;q=p-o>>2;r=o;if((n|0)<(q|0)){s=r;t=n;v=o}else{w=n+1|0;f[e>>2]=-1;x=p;if(w>>>0<=q>>>0)if(w>>>0>>0?(p=r+(w<<2)|0,(p|0)!=(x|0)):0){f[j>>2]=x+(~((x+-4-p|0)>>>2)<<2);y=n;z=r;A=o}else{y=n;z=r;A=o}else{Ch(l,w-q|0,e);q=f[l>>2]|0;y=f[d>>2]|0;z=q;A=q}s=z;t=y;v=A}m=f[i>>2]|0;f[s+(t<<2)>>2]=(m-(f[g>>2]|0)>>2)+-1;a=a+4|0;if((a|0)==(h|0))break;else k=v}u=c;return}function cg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;c=u;u=u+16|0;d=c;e=a+76|0;g=f[e>>2]|0;h=a+80|0;i=f[h>>2]|0;if((i|0)!=(g|0))f[h>>2]=i+(~((i+-4-g|0)>>>2)<<2);f[e>>2]=0;f[h>>2]=0;f[a+84>>2]=0;if(g|0)Oq(g);g=a+64|0;h=f[g>>2]|0;e=a+68|0;if((f[e>>2]|0)!=(h|0))f[e>>2]=h;f[g>>2]=0;f[e>>2]=0;f[a+72>>2]=0;if(h|0)Oq(h);h=b+4|0;e=f[h>>2]|0;g=f[b>>2]|0;i=((e-g|0)/12|0)*3|0;j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=k-l>>2;n=l;l=k;k=g;if(i>>>0<=m>>>0)if(i>>>0>>0?(o=n+(i<<2)|0,(o|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-o|0)>>>2)<<2);p=e;q=g;r=k}else{p=e;q=g;r=k}else{Ci(a,i-m|0);m=f[b>>2]|0;p=f[h>>2]|0;q=m;r=m}if((p|0)!=(q|0)){q=f[a>>2]|0;m=(p-r|0)/12|0;p=0;do{h=p*3|0;f[q+(h<<2)>>2]=f[r+(p*12|0)>>2];f[q+(h+1<<2)>>2]=f[r+(p*12|0)+4>>2];f[q+(h+2<<2)>>2]=f[r+(p*12|0)+8>>2];p=p+1|0}while(p>>>0>>0)}f[d>>2]=-1;if(!(rc(a,d)|0)){s=0;u=c;return s|0}eb(a,f[d>>2]|0)|0;s=1;u=c;return s|0}function dg(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=d[b>>1]|0;e=d[b+2>>1]|0;g=d[b+4>>1]|0;b=(((c^318)&65535)+239^e&65535)+239^g&65535;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(b>>>0>>0)l=b;else l=(b>>>0)%(h>>>0)|0;else l=b&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(b|0);if(!(n|(m&j|0)==(l|0))){i=0;o=23;break}if(((n?(n=k+8|0,(d[n>>1]|0)==c<<16>>16):0)?(d[n+2>>1]|0)==e<<16>>16:0)?(d[k+12>>1]|0)==g<<16>>16:0){i=k;o=23;break}k=f[k>>2]|0;if(!k){i=0;o=23;break}}if((o|0)==23)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(b|0)){k=p+8|0;if(((d[k>>1]|0)==c<<16>>16?(d[k+2>>1]|0)==e<<16>>16:0)?(d[p+12>>1]|0)==g<<16>>16:0){i=p;o=23;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=23;break}}p=f[p>>2]|0;if(!p){i=0;o=23;break}}if((o|0)==23)return i|0;return 0}function eg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=u;u=u+32|0;d=c;e=a+16|0;g=e;h=f[g>>2]|0;i=f[g+4>>2]|0;if(!((i|0)>0|(i|0)==0&h>>>0>0)){u=c;return}g=Vn(f[(f[a+12>>2]|0)+4>>2]|0,0,7,0)|0;j=Yn(g|0,I|0,3)|0;g=I;if(!(b[a+24>>0]|0)){k=a+4|0;l=k;m=k;n=h;o=i}else{k=f[a>>2]|0;p=a+4|0;q=k+((f[p>>2]|0)-k)|0;k=Vn(h|0,i|0,8,0)|0;i=q+(0-k)|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;b[d+24>>0]=0;yh(j,g,d)|0;k=d+4|0;q=(f[k>>2]|0)-(f[d>>2]|0)|0;im(i+q|0,i+8|0,j|0)|0;kh(i|0,f[d>>2]|0,q|0)|0;i=e;h=Vn(f[i>>2]|0,f[i+4>>2]|0,8-q|0,0)|0;q=e;f[q>>2]=h;f[q+4>>2]=I;q=d+12|0;h=f[q>>2]|0;f[q>>2]=0;if(h|0)Oq(h);h=f[d>>2]|0;if(h|0){if((f[k>>2]|0)!=(h|0))f[k>>2]=h;Oq(h)}h=e;l=p;m=p;n=f[h>>2]|0;o=f[h+4>>2]|0}h=f[l>>2]|0;l=f[a>>2]|0;p=h-l|0;k=Xn(j|0,g|0,n|0,o|0)|0;o=Vn(k|0,I|0,p|0,0)|0;k=l;l=h;if(p>>>0>=o>>>0){if(p>>>0>o>>>0?(h=k+o|0,(h|0)!=(l|0)):0)f[m>>2]=h}else Fi(a,o-p|0);p=e;f[p>>2]=0;f[p+4>>2]=0;u=c;return}function fg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f[a+4>>2]=f[b+4>>2];c=a+8|0;d=b+8|0;if((a|0)==(b|0))return a|0;e=b+12|0;g=f[e>>2]|0;if(!g)h=0;else{i=a+16|0;do if(g>>>0>f[i>>2]<<5>>>0){j=f[c>>2]|0;if(!j)k=g;else{Oq(j);f[c>>2]=0;f[i>>2]=0;f[a+12>>2]=0;k=f[e>>2]|0}if((k|0)<0)aq(c);else{j=((k+-1|0)>>>5)+1|0;l=ln(j<<2)|0;f[c>>2]=l;f[a+12>>2]=0;f[i>>2]=j;m=f[e>>2]|0;n=l;break}}else{m=g;n=f[c>>2]|0}while(0);im(n|0,f[d>>2]|0,((m+-1|0)>>>5<<2)+4|0)|0;h=f[e>>2]|0}f[a+12>>2]=h;h=a+20|0;e=b+20|0;m=b+24|0;b=f[m>>2]|0;if(!b)o=0;else{d=a+28|0;do if(b>>>0>f[d>>2]<<5>>>0){n=f[h>>2]|0;if(!n)p=b;else{Oq(n);f[h>>2]=0;f[d>>2]=0;f[a+24>>2]=0;p=f[m>>2]|0}if((p|0)<0)aq(h);else{n=((p+-1|0)>>>5)+1|0;c=ln(n<<2)|0;f[h>>2]=c;f[a+24>>2]=0;f[d>>2]=n;q=f[m>>2]|0;r=c;break}}else{q=b;r=f[h>>2]|0}while(0);im(r|0,f[e>>2]|0,((q+-1|0)>>>5<<2)+4|0)|0;o=f[m>>2]|0}f[a+24>>2]=o;return a|0}function gg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;f[c>>2]=1;d=a+4|0;e=c+8|0;g=c+12|0;c=f[e>>2]|0;i=(f[g>>2]|0)-c|0;if(i>>>0<4294967292){Lk(e,i+4|0,0);j=f[e>>2]|0}else j=c;c=j+i|0;i=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[c>>0]=i;b[c+1>>0]=i>>8;b[c+2>>0]=i>>16;b[c+3>>0]=i>>24;i=a+8|0;c=a+12|0;d=f[i>>2]|0;if((f[c>>2]|0)!=(d|0)){j=0;k=d;do{d=k+(j<<2)|0;l=f[e>>2]|0;m=(f[g>>2]|0)-l|0;if(m>>>0<4294967292){Lk(e,m+4|0,0);n=f[e>>2]|0}else n=l;l=n+m|0;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[l>>0]=m;b[l+1>>0]=m>>8;b[l+2>>0]=m>>16;b[l+3>>0]=m>>24;j=j+1|0;k=f[i>>2]|0}while(j>>>0<(f[c>>2]|0)-k>>2>>>0)}k=a+20|0;a=f[e>>2]|0;c=(f[g>>2]|0)-a|0;if(c>>>0<4294967292){Lk(e,c+4|0,0);o=f[e>>2]|0;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}else{o=a;p=o+c|0;q=h[k>>0]|h[k+1>>0]<<8|h[k+2>>0]<<16|h[k+3>>0]<<24;b[p>>0]=q;b[p+1>>0]=q>>8;b[p+2>>0]=q>>16;b[p+3>>0]=q>>24;return}}function hg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+8|0;e=f[d>>2]|0;g=f[a>>2]|0;h=g;do if(e-g>>2>>>0>=b>>>0){i=a+4|0;j=f[i>>2]|0;k=j-g>>2;l=k>>>0>>0;m=l?k:b;n=j;if(m|0){j=m;m=h;while(1){f[m>>2]=f[c>>2];j=j+-1|0;if(!j)break;else m=m+4|0}}if(!l){m=h+(b<<2)|0;if((m|0)==(n|0))return;else{o=i;p=n+(~((n+-4-m|0)>>>2)<<2)|0;break}}else{m=b-k|0;j=m;q=n;while(1){f[q>>2]=f[c>>2];j=j+-1|0;if(!j)break;else q=q+4|0}o=i;p=n+(m<<2)|0;break}}else{q=g;if(!g)r=e;else{j=a+4|0;k=f[j>>2]|0;if((k|0)!=(h|0))f[j>>2]=k+(~((k+-4-g|0)>>>2)<<2);Oq(q);f[d>>2]=0;f[j>>2]=0;f[a>>2]=0;r=0}if(b>>>0>1073741823)aq(a);j=r>>1;q=r>>2>>>0<536870911?(j>>>0>>0?b:j):1073741823;if(q>>>0>1073741823)aq(a);j=ln(q<<2)|0;k=a+4|0;f[k>>2]=j;f[a>>2]=j;f[d>>2]=j+(q<<2);q=b;l=j;while(1){f[l>>2]=f[c>>2];q=q+-1|0;if(!q)break;else l=l+4|0}o=k;p=j+(b<<2)|0}while(0);f[o>>2]=p;return}function ig(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=jh(a,b,c,d,g)|0;i=f[e>>2]|0;j=f[d>>2]|0;k=f[g>>2]|0;g=f[k>>2]|0;l=(f[k+4>>2]|0)-g>>3;if(l>>>0<=i>>>0)aq(k);m=g;if(l>>>0<=j>>>0)aq(k);if((f[m+(i<<3)>>2]|0)>>>0>=(f[m+(j<<3)>>2]|0)>>>0){n=h;return n|0}f[d>>2]=i;f[e>>2]=j;j=f[d>>2]|0;e=f[c>>2]|0;if(l>>>0<=j>>>0)aq(k);if(l>>>0<=e>>>0)aq(k);if((f[m+(j<<3)>>2]|0)>>>0>=(f[m+(e<<3)>>2]|0)>>>0){n=h+1|0;return n|0}f[c>>2]=j;f[d>>2]=e;e=f[c>>2]|0;d=f[b>>2]|0;if(l>>>0<=e>>>0)aq(k);if(l>>>0<=d>>>0)aq(k);if((f[m+(e<<3)>>2]|0)>>>0>=(f[m+(d<<3)>>2]|0)>>>0){n=h+2|0;return n|0}f[b>>2]=e;f[c>>2]=d;d=f[b>>2]|0;c=f[a>>2]|0;if(l>>>0<=d>>>0)aq(k);if(l>>>0<=c>>>0)aq(k);if((f[m+(d<<3)>>2]|0)>>>0>=(f[m+(c<<3)>>2]|0)>>>0){n=h+3|0;return n|0}f[a>>2]=d;f[b>>2]=c;n=h+4|0;return n|0}function jg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=b[c>>0]|0;e=b[c+1>>0]|0;g=b[c+2>>0]|0;c=((d&255^318)+239^e&255)+239^g&255;h=f[a+4>>2]|0;if(!h){i=0;return i|0}j=h+-1|0;k=(j&h|0)==0;if(!k)if(c>>>0>>0)l=c;else l=(c>>>0)%(h>>>0)|0;else l=c&j;m=f[(f[a>>2]|0)+(l<<2)>>2]|0;if(!m){i=0;return i|0}a=f[m>>2]|0;if(!a){i=0;return i|0}if(k){k=a;while(1){m=f[k+4>>2]|0;n=(m|0)==(c|0);if(!(n|(m&j|0)==(l|0))){i=0;o=23;break}if(((n?(n=k+8|0,(b[n>>0]|0)==d<<24>>24):0)?(b[n+1>>0]|0)==e<<24>>24:0)?(b[n+2>>0]|0)==g<<24>>24:0){i=k;o=23;break}k=f[k>>2]|0;if(!k){i=0;o=23;break}}if((o|0)==23)return i|0}else p=a;while(1){a=f[p+4>>2]|0;if((a|0)==(c|0)){k=p+8|0;if(((b[k>>0]|0)==d<<24>>24?(b[k+1>>0]|0)==e<<24>>24:0)?(b[k+2>>0]|0)==g<<24>>24:0){i=p;o=23;break}}else{if(a>>>0>>0)q=a;else q=(a>>>0)%(h>>>0)|0;if((q|0)!=(l|0)){i=0;o=23;break}}p=f[p>>2]|0;if(!p){i=0;o=23;break}}if((o|0)==23)return i|0;return 0}function kg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;b=u;u=u+16|0;c=b;d=a+36|0;e=a+4|0;g=a+8|0;h=(f[g>>2]|0)-(f[e>>2]|0)>>2;i=a+40|0;j=f[i>>2]|0;k=f[d>>2]|0;l=j-k>>2;m=k;k=j;if(h>>>0<=l>>>0){if(h>>>0>>0?(j=m+(h<<2)|0,(j|0)!=(k|0)):0){m=k;do{k=m+-4|0;f[i>>2]=k;n=f[k>>2]|0;f[k>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);m=f[i>>2]|0}while((m|0)!=(j|0))}}else Eg(d,h-l|0);if((f[g>>2]|0)==(f[e>>2]|0)){o=1;u=b;return o|0}l=a+52|0;h=a+48|0;j=0;while(1){Xa[f[(f[a>>2]|0)+56>>2]&15](c,a,j);m=(f[d>>2]|0)+(j<<2)|0;i=f[c>>2]|0;f[c>>2]=0;n=f[m>>2]|0;f[m>>2]=i;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);n=f[c>>2]|0;f[c>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n);n=f[(f[d>>2]|0)+(j<<2)>>2]|0;if(!n){o=0;p=19;break}if(j>>>0<(f[l>>2]|0)>>>0?f[(f[h>>2]|0)+(j>>>5<<2)>>2]&1<<(j&31)|0:0)Bp(n);j=j+1|0;if(j>>>0>=(f[g>>2]|0)-(f[e>>2]|0)>>2>>>0){o=1;p=19;break}}if((p|0)==19){u=b;return o|0}return 0}function lg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d+4|0;g=d;ci(f[c+12>>2]|0,b)|0;h=f[c+8>>2]|0;a:do if(h|0){i=b+16|0;j=b+4|0;k=h;while(1){l=k;if(!(Bf(0,b,l+8|0)|0)){m=0;break}n=l+20|0;o=(f[l+24>>2]|0)-(f[n>>2]|0)|0;ci(o,b)|0;l=f[n>>2]|0;n=i;p=f[n+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[j>>2];f[e>>2]=f[g>>2];Me(b,e,l,l+o|0)|0}k=f[k>>2]|0;if(!k)break a}u=d;return m|0}while(0);ci(f[c+32>>2]|0,b)|0;e=f[c+28>>2]|0;if(!e){m=1;u=d;return m|0}else q=e;while(1){e=q;if(!(Bf(0,b,e+8|0)|0)){m=0;r=10;break}lg(a,b,f[e+20>>2]|0)|0;q=f[q>>2]|0;if(!q){m=1;r=10;break}}if((r|0)==10){u=d;return m|0}return 0}function mg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+8|0;i=a+12|0;j=f[h>>2]|0;if((f[i>>2]|0)==(j|0)){k=ln(76)|0;vn(k,b);l=k;f[g>>2]=l;k=f[i>>2]|0;if(k>>>0<(f[a+16>>2]|0)>>>0){f[g>>2]=0;f[k>>2]=l;f[i>>2]=k+4;m=g}else{Qg(h,g);m=g}g=f[m>>2]|0;f[m>>2]=0;if(!g){u=c;return 1}Va[f[(f[g>>2]|0)+4>>2]&127](g);u=c;return 1}g=f[j>>2]|0;f[d>>2]=b;j=g+4|0;m=g+8|0;h=f[m>>2]|0;if((h|0)==(f[g+12>>2]|0))Ri(j,d);else{f[h>>2]=b;f[m>>2]=h+4}h=f[d>>2]|0;b=g+16|0;k=g+20|0;g=f[k>>2]|0;i=f[b>>2]|0;l=g-i>>2;a=i;if((h|0)<(l|0)){n=a;o=h}else{i=h+1|0;f[e>>2]=-1;p=g;if(i>>>0<=l>>>0)if(i>>>0>>0?(g=a+(i<<2)|0,(g|0)!=(p|0)):0){f[k>>2]=p+(~((p+-4-g|0)>>>2)<<2);q=h;r=a}else{q=h;r=a}else{Ch(b,i-l|0,e);q=f[d>>2]|0;r=f[b>>2]|0}n=r;o=q}f[n+(o<<2)>>2]=((f[m>>2]|0)-(f[j>>2]|0)>>2)+-1;u=c;return 1}function ng(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0>j-k>>2>>>0){m=k;if(!k)n=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);Oq(m);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;n=0}if(h>>>0>1073741823)aq(a);j=n>>1;m=n>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(m>>>0>1073741823)aq(a);j=ln(m<<2)|0;n=a+4|0;f[n>>2]=j;f[a>>2]=j;f[i>>2]=j+(m<<2);if((g|0)<=0)return;kh(j|0,b|0,g|0)|0;f[n>>2]=j+(g>>>2<<2);return}g=a+4|0;a=f[g>>2]|0;j=a-k>>2;k=h>>>0>j>>>0;h=k?b+(j<<2)|0:c;c=a;j=a;if((h|0)==(b|0))p=l;else{a=h+-4-e|0;e=b;b=l;while(1){f[b>>2]=f[e>>2];e=e+4|0;if((e|0)==(h|0))break;else b=b+4|0}p=l+((a>>>2)+1<<2)|0}if(k){k=d-h|0;if((k|0)<=0)return;kh(j|0,h|0,k|0)|0;f[g>>2]=(f[g>>2]|0)+(k>>>2<<2);return}else{if((p|0)==(c|0))return;f[g>>2]=c+(~((c+-4-p|0)>>>2)<<2);return}}function og(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=f[a+8>>2]|0;e=a+76|0;g=f[e>>2]|0;h=f[g+80>>2]|0;b[c+84>>0]=0;i=c+68|0;j=c+72|0;k=f[j>>2]|0;l=f[i>>2]|0;m=k-l>>2;n=l;l=k;if(h>>>0<=m>>>0)if(h>>>0>>0?(k=n+(h<<2)|0,(k|0)!=(l|0)):0){f[j>>2]=l+(~((l+-4-k|0)>>>2)<<2);o=g;p=h}else{o=g;p=h}else{Ch(i,h-m|0,3600);m=f[e>>2]|0;o=m;p=f[m+80>>2]|0}m=(f[o+100>>2]|0)-(f[o+96>>2]|0)|0;e=(m|0)/12|0;if(!m){q=1;return q|0}m=c+68|0;c=f[o+96>>2]|0;o=f[d+28>>2]|0;d=f[(f[a+80>>2]|0)+12>>2]|0;a=0;while(1){h=a*3|0;i=f[d+(f[o+(h<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}g=f[m>>2]|0;f[g+(f[c+(a*12|0)>>2]<<2)>>2]=i;i=f[d+(f[o+(h+1<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+4>>2]<<2)>>2]=i;i=f[d+(f[o+(h+2<<2)>>2]<<2)>>2]|0;if(i>>>0>=p>>>0){q=0;r=10;break}f[g+(f[c+(a*12|0)+8>>2]<<2)>>2]=i;a=a+1|0;if(a>>>0>=e>>>0){q=1;r=10;break}}if((r|0)==10)return q|0;return 0}function pg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=u;u=u+16|0;g=e;if(!(xh(a,c,d)|0)){h=0;u=e;return h|0}if((b[(f[a+8>>2]|0)+24>>0]|0)!=3){h=0;u=e;return h|0}i=f[c+48>>2]|0;c=ln(32)|0;f[g>>2]=c;f[g+8>>2]=-2147483616;f[g+4>>2]=17;j=c;k=14495;l=j+17|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[c+17>>0]=0;c=i+16|0;k=f[c>>2]|0;if(k){j=c;l=k;a:while(1){k=l;while(1){if((f[k+16>>2]|0)>=(d|0))break;m=f[k+4>>2]|0;if(!m){n=j;break a}else k=m}l=f[k>>2]|0;if(!l){n=k;break}else j=k}if(((n|0)!=(c|0)?(f[n+16>>2]|0)<=(d|0):0)?(d=n+20|0,(Jh(d,g)|0)!=0):0)o=Hk(d,g,-1)|0;else p=12}else p=12;if((p|0)==12)o=Hk(i,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((o|0)<1){h=0;u=e;return h|0}ip(a+40|0,o);h=1;u=e;return h|0}function qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=f[b>>2]|0;d=f[b+4>>2]|0;e=f[b+8>>2]|0;b=((c^318)+239^d)+239^e;g=f[a+4>>2]|0;if(!g){h=0;return h|0}i=g+-1|0;j=(i&g|0)==0;if(!j)if(b>>>0>>0)k=b;else k=(b>>>0)%(g>>>0)|0;else k=b&i;l=f[(f[a>>2]|0)+(k<<2)>>2]|0;if(!l){h=0;return h|0}a=f[l>>2]|0;if(!a){h=0;return h|0}if(j){j=a;while(1){l=f[j+4>>2]|0;m=(l|0)==(b|0);if(!(m|(l&i|0)==(k|0))){h=0;n=23;break}if(((m?(f[j+8>>2]|0)==(c|0):0)?(f[j+12>>2]|0)==(d|0):0)?(f[j+16>>2]|0)==(e|0):0){h=j;n=23;break}j=f[j>>2]|0;if(!j){h=0;n=23;break}}if((n|0)==23)return h|0}else o=a;while(1){a=f[o+4>>2]|0;if((a|0)==(b|0)){if(((f[o+8>>2]|0)==(c|0)?(f[o+12>>2]|0)==(d|0):0)?(f[o+16>>2]|0)==(e|0):0){h=o;n=23;break}}else{if(a>>>0>>0)p=a;else p=(a>>>0)%(g>>>0)|0;if((p|0)!=(k|0)){h=0;n=23;break}}o=f[o>>2]|0;if(!o){h=0;n=23;break}}if((n|0)==23)return h|0;return 0}function rg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=c;g=d-e|0;h=a+8|0;i=f[h>>2]|0;j=f[a>>2]|0;k=j;if(g>>>0>(i-j|0)>>>0){if(!j)l=i;else{i=a+4|0;if((f[i>>2]|0)!=(k|0))f[i>>2]=k;Oq(k);f[h>>2]=0;f[i>>2]=0;f[a>>2]=0;l=0}if((g|0)<0)aq(a);i=l<<1;m=l>>>0<1073741823?(i>>>0>>0?g:i):2147483647;if((m|0)<0)aq(a);i=ln(m)|0;l=a+4|0;f[l>>2]=i;f[a>>2]=i;f[h>>2]=i+m;if((c|0)==(d|0))return;else{n=c;o=i}do{b[o>>0]=b[n>>0]|0;n=n+1|0;o=(f[l>>2]|0)+1|0;f[l>>2]=o}while((n|0)!=(d|0));return}n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;if((a|0)==(c|0))p=k;else{o=c;c=k;while(1){b[c>>0]=b[o>>0]|0;o=o+1|0;if((o|0)==(a|0))break;else c=c+1|0}p=k+(a-e)|0}if(!j){if((f[n>>2]|0)==(p|0))return;f[n>>2]=p;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}function sg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=c>>>1&1431655765|c<<1&-1431655766;c=d>>>2&858993459|d<<2&-858993460;d=c>>>4&252645135|c<<4&-252645136;c=d>>>8&16711935|d<<8&-16711936;d=32-b|0;e=(c>>>16|c<<16)>>>d;c=e-(e>>>1&1431655765)|0;g=(c>>>2&858993459)+(c&858993459)|0;c=(X((g>>>4)+g&252645135,16843009)|0)>>>24;g=b-c|0;h=f[a>>2]|0;i=h;j=Vn(f[i>>2]|0,f[i+4>>2]|0,g|0,((g|0)<0)<<31>>31|0)|0;g=h;f[g>>2]=j;f[g+4>>2]=I;g=h+8|0;h=g;j=Vn(f[h>>2]|0,f[h+4>>2]|0,c|0,0)|0;c=g;f[c>>2]=j;f[c+4>>2]=I;c=a+28|0;j=f[c>>2]|0;g=32-j|0;h=a+24|0;do if((g|0)>=(b|0)){i=-1>>>d<>2]&~i|i&e<>2]=k;i=j+b|0;f[c>>2]=i;if((i|0)!=32)return;i=a+16|0;l=f[i>>2]|0;if((l|0)==(f[a+20>>2]|0)){Ri(a+12|0,h);m=0;n=0;break}else{f[l>>2]=k;f[i>>2]=l+4;m=0;n=0;break}}else{l=-1>>>j<>2]&~l|l&e<>2]=i;l=a+16|0;k=f[l>>2]|0;if((k|0)==(f[a+20>>2]|0))Ri(a+12|0,h);else{f[k>>2]=i;f[l>>2]=k+4}k=b-g|0;m=k;n=-1>>>(32-k|0)&e>>>g}while(0);f[h>>2]=n;f[c>>2]=m;return}function tg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=c&255;g=(d|0)!=0;a:do if(g&(a&3|0)!=0){h=c&255;i=a;j=d;while(1){if((b[i>>0]|0)==h<<24>>24){k=i;l=j;m=6;break a}n=i+1|0;o=j+-1|0;p=(o|0)!=0;if(p&(n&3|0)!=0){i=n;j=o}else{q=n;r=o;s=p;m=5;break}}}else{q=a;r=d;s=g;m=5}while(0);if((m|0)==5)if(s){k=q;l=r;m=6}else{t=q;u=0}b:do if((m|0)==6){q=c&255;if((b[k>>0]|0)==q<<24>>24){t=k;u=l}else{r=X(e,16843009)|0;c:do if(l>>>0>3){s=k;g=l;while(1){d=f[s>>2]^r;if((d&-2139062144^-2139062144)&d+-16843009|0)break;d=s+4|0;a=g+-4|0;if(a>>>0>3){s=d;g=a}else{v=d;w=a;m=11;break c}}x=s;y=g}else{v=k;w=l;m=11}while(0);if((m|0)==11)if(!w){t=v;u=0;break}else{x=v;y=w}while(1){if((b[x>>0]|0)==q<<24>>24){t=x;u=y;break b}r=x+1|0;y=y+-1|0;if(!y){t=r;u=0;break}else x=r}}}while(0);return (u|0?t:0)|0}function ug(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=e;do if((d|0)==(e|0)){h=a+8|0;i=f[h>>2]|0;j=a+12|0;k=f[j>>2]|0;l=k;if(i>>>0>>0){k=i;m=((l-k>>2)+1|0)/2|0;n=i+(m<<2)|0;o=k-d|0;k=o>>2;p=n+(0-k<<2)|0;if(!k){q=n;r=i}else{im(p|0,d|0,o|0)|0;q=p;r=f[h>>2]|0}f[c>>2]=q;f[h>>2]=r+(m<<2);s=q;break}m=l-g>>1;l=(m|0)==0?1:m;if(l>>>0>1073741823){m=ra(8)|0;Oo(m,16035);f[m>>2]=7256;va(m|0,1112,110)}m=ln(l<<2)|0;p=m;o=m+((l+3|0)>>>2<<2)|0;n=o;k=m+(l<<2)|0;if((d|0)==(i|0)){t=n;u=d}else{l=o;m=n;v=d;do{f[l>>2]=f[v>>2];l=m+4|0;m=l;v=v+4|0}while((v|0)!=(i|0));t=m;u=f[a>>2]|0}f[a>>2]=p;f[c>>2]=n;f[h>>2]=t;f[j>>2]=k;if(!u)s=o;else{Oq(u);s=f[c>>2]|0}}else s=d;while(0);f[s+-4>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+-4;return}function vg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=a+4|0;if((f[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>0>0){z=r;A=a}else{f[h>>2]=f[p>>2];f[g>>2]=f[h>>2];Me(d,g,k,q)|0;z=f[c>>2]|0;A=f[l>>2]|0}x=j+1|0;if(x>>>0>=A-z>>2>>>0)break;m=f[i>>2]|0;j=x;r=z;n=m;s=m;a=A}Mq(k);u=e;return 1}function xg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=(f[b>>2]|0)*3|0;if((d|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}b=f[a+12>>2]|0;h=f[b+12>>2]|0;if((f[h+(d<<2)>>2]|0)==-1){e=0;g=d;f[c>>2]=g;return e|0}i=f[b>>2]|0;b=f[a+152>>2]|0;if((f[b+(f[i+(d<<2)>>2]<<2)>>2]|0)==-1){a=d+1|0;j=((a>>>0)%3|0|0)==0?d+-2|0:a;if((j|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}if((f[h+(j<<2)>>2]|0)==-1){e=0;g=j;f[c>>2]=g;return e|0}if((f[b+(f[i+(j<<2)>>2]<<2)>>2]|0)==-1){a=j+1|0;k=((a>>>0)%3|0|0)==0?j+-2|0:a;if((k|0)==-1){e=0;g=-1;f[c>>2]=g;return e|0}if((f[h+(k<<2)>>2]|0)==-1){e=0;g=k;f[c>>2]=g;return e|0}if((f[b+(f[i+(k<<2)>>2]<<2)>>2]|0)==-1){i=k+1|0;e=1;g=((i>>>0)%3|0|0)==0?k+-2|0:i;f[c>>2]=g;return e|0}else l=k}else l=j}else l=d;while(1){d=(((l>>>0)%3|0|0)==0?2:-1)+l|0;if((d|0)==-1)break;j=f[h+(d<<2)>>2]|0;if((j|0)==-1)break;d=j+(((j>>>0)%3|0|0)==0?2:-1)|0;if((d|0)==-1)break;else l=d}e=0;g=(((l>>>0)%3|0|0)==0?2:-1)+l|0;f[c>>2]=g;return e|0}function yg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=a+4|0;g=f[e>>2]|0;if(!g){f[c>>2]=e;h=e;return h|0}e=b[d+11>>0]|0;i=e<<24>>24<0;j=i?f[d+4>>2]|0:e&255;e=i?f[d>>2]|0:d;d=a+4|0;a=g;while(1){g=a+16|0;i=b[g+11>>0]|0;k=i<<24>>24<0;l=k?f[a+20>>2]|0:i&255;i=l>>>0>>0;m=i?l:j;if((m|0)!=0?(n=Vk(e,k?f[g>>2]|0:g,m)|0,(n|0)!=0):0)if((n|0)<0)o=8;else o=10;else if(j>>>0>>0)o=8;else o=10;if((o|0)==8){o=0;n=f[a>>2]|0;if(!n){o=9;break}else{p=a;q=n}}else if((o|0)==10){o=0;n=j>>>0>>0?j:l;if((n|0)!=0?(l=Vk(k?f[g>>2]|0:g,e,n)|0,(l|0)!=0):0){if((l|0)>=0){o=16;break}}else o=12;if((o|0)==12?(o=0,!i):0){o=16;break}r=a+4|0;i=f[r>>2]|0;if(!i){o=15;break}else{p=r;q=i}}d=p;a=q}if((o|0)==9){f[c>>2]=a;h=a;return h|0}else if((o|0)==15){f[c>>2]=a;h=r;return h|0}else if((o|0)==16){f[c>>2]=a;h=d;return h|0}return 0}function zg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;d=u;u=u+32|0;e=d+24|0;g=d+16|0;h=d+8|0;i=d;j=a+4|0;k=f[j>>2]|0;l=f[b>>2]|0;m=f[b+4>>2]|0;b=f[c>>2]|0;n=f[c+4>>2]|0;c=b-l<<3;f[j>>2]=k-m+n+c;j=(f[a>>2]|0)+(k>>>5<<2)|0;a=k&31;k=j;if((m|0)!=(a|0)){f[e>>2]=l;f[e+4>>2]=m;f[g>>2]=b;f[g+4>>2]=n;f[h>>2]=k;f[h+4>>2]=a;xe(i,e,g,h);u=d;return}h=n-m+c|0;c=l;if((h|0)>0){if(!m){o=h;p=j;q=0;r=l;s=c}else{l=32-m|0;n=(h|0)<(l|0)?h:l;g=-1>>>(l-n|0)&-1<>2]=f[j>>2]&~g|f[c>>2]&g;g=n+m|0;l=c+4|0;o=h-n|0;p=j+(g>>>5<<2)|0;q=g&31;r=l;s=l}l=(o|0)/32|0;im(p|0,r|0,l<<2|0)|0;r=o-(l<<5)|0;o=p+(l<<2)|0;p=o;if((r|0)>0){g=-1>>>(32-r|0);f[o>>2]=f[o>>2]&~g|f[s+(l<<2)>>2]&g;t=r;v=p}else{t=q;v=p}}else{t=m;v=k}f[i>>2]=v;f[i+4>>2]=t;u=d;return}function Ag(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;c=a+8|0;d=f[c>>2]|0;e=a+12|0;g=f[e>>2]|0;h=g;do if((d|0)==(g|0)){i=a+4|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(j>>>0>k>>>0){m=j;n=((m-l>>2)+1|0)/-2|0;o=j+(n<<2)|0;p=d-m|0;m=p>>2;if(!m)q=j;else{im(o|0,j|0,p|0)|0;q=f[i>>2]|0}p=o+(m<<2)|0;f[c>>2]=p;f[i>>2]=q+(n<<2);r=p;break}p=h-l>>1;l=(p|0)==0?1:p;if(l>>>0>1073741823){p=ra(8)|0;Oo(p,16035);f[p>>2]=7256;va(p|0,1112,110)}p=ln(l<<2)|0;n=p;m=p+(l>>>2<<2)|0;o=m;s=p+(l<<2)|0;if((j|0)==(d|0)){t=o;u=k}else{k=m;m=o;l=j;do{f[k>>2]=f[l>>2];k=m+4|0;m=k;l=l+4|0}while((l|0)!=(d|0));t=m;u=f[a>>2]|0}f[a>>2]=n;f[i>>2]=o;f[c>>2]=t;f[e>>2]=s;if(!u)r=t;else{Oq(u);r=f[c>>2]|0}}else r=d;while(0);f[r>>2]=f[b>>2];f[c>>2]=(f[c>>2]|0)+4;return}function Bg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0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>2]=o}while((n|0)!=(d|0));return}else{n=a+4|0;a=(f[n>>2]|0)-j|0;j=g>>>0>a>>>0;g=c+a|0;a=j?g:d;o=a-e|0;if(o|0)im(k|0,c|0,o|0)|0;c=k+o|0;if(!j){if((f[n>>2]|0)==(c|0))return;f[n>>2]=c;return}if((a|0)==(d|0))return;a=g;g=f[n>>2]|0;do{b[g>>0]=b[a>>0]|0;a=a+1|0;g=(f[n>>2]|0)+1|0;f[n>>2]=g}while((a|0)!=(d|0));return}}function Dg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;if(b[a+352>>0]|0){u=c;return 1}e=a+8|0;g=f[e>>2]|0;h=(f[g+12>>2]|0)-(f[g+8>>2]|0)|0;g=h>>2;i=a+172|0;Gi(i,g+-1|0);if(!((g|0)!=1&(h|0)>0)){u=c;return 1}h=a+12|0;a=0;j=0;while(1){k=f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0;if(!(f[k+56>>2]|0))l=j;else{m=f[i>>2]|0;f[m+(j*136|0)>>2]=a;n=f[m+(j*136|0)+104>>2]|0;o=m+(j*136|0)+108|0;p=f[o>>2]|0;if((p|0)!=(n|0))f[o>>2]=p+(~((p+-4-n|0)>>>2)<<2);n=f[h>>2]|0;gk(m+(j*136|0)+104|0,(f[n+4>>2]|0)-(f[n>>2]|0)>>2);n=(f[i>>2]|0)+(j*136|0)+116|0;m=f[h>>2]|0;p=(f[m+4>>2]|0)-(f[m>>2]|0)>>2;f[d>>2]=-1;hg(n,p,d);p=f[i>>2]|0;f[p+(j*136|0)+128>>2]=0;Gc(p+(j*136|0)+4|0,f[e>>2]|0,f[h>>2]|0,k)|0;l=j+1|0}a=a+1|0;if((a|0)>=(g|0))break;else j=l}u=c;return 1}function Eg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){sj(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}i=f[a>>2]|0;j=g-i>>2;g=j+b|0;k=i;if(g>>>0>1073741823)aq(a);l=d-i|0;d=l>>1;m=l>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(m)if(m>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{n=ln(m<<2)|0;break}else n=0;while(0);d=n+(j<<2)|0;sj(d|0,0,b<<2|0)|0;b=d;j=n+(m<<2)|0;m=n+(g<<2)|0;if((h|0)==(k|0)){o=b;p=i;q=h}else{i=h;h=b;b=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[b+-4>>2]=d;b=h+-4|0;h=b}while((i|0)!=(k|0));o=h;p=f[a>>2]|0;q=f[e>>2]|0}f[a>>2]=o;f[e>>2]=m;f[c>>2]=j;j=p;if((q|0)!=(j|0)){c=q;do{c=c+-4|0;q=f[c>>2]|0;f[c>>2]=0;if(q|0)Va[f[(f[q>>2]|0)+4>>2]&127](q)}while((c|0)!=(j|0))}if(!p)return;Oq(p);return}function Fg(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=$(h);var i=0,j=0,k=0,l=0,m=0,n=0;i=u;u=u+16|0;j=i;k=i+4|0;f[j>>2]=c;c=ln(32)|0;f[k>>2]=c;f[k+8>>2]=-2147483616;f[k+4>>2]=17;l=c;m=14495;n=l+17|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[c+17>>0]=0;Xj(Hd(a,j)|0,k,d);if((b[k+11>>0]|0)<0)Oq(f[k>>2]|0);d=ln(32)|0;f[k>>2]=d;f[k+8>>2]=-2147483616;f[k+4>>2]=19;l=d;m=14438;n=l+19|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[d+19>>0]=0;si(Hd(a,j)|0,k,g,e);if((b[k+11>>0]|0)<0)Oq(f[k>>2]|0);e=ln(32)|0;f[k>>2]=e;f[k+8>>2]=-2147483616;f[k+4>>2]=18;l=e;m=14458;n=l+18|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[e+18>>0]=0;Tj(Hd(a,j)|0,k,h);if((b[k+11>>0]|0)>=0){u=i;return}Oq(f[k>>2]|0);u=i;return}function Gg(a){a=a|0;tk(a);tk(a+32|0);tk(a+64|0);tk(a+96|0);tk(a+128|0);tk(a+160|0);tk(a+192|0);tk(a+224|0);tk(a+256|0);tk(a+288|0);tk(a+320|0);tk(a+352|0);tk(a+384|0);tk(a+416|0);tk(a+448|0);tk(a+480|0);tk(a+512|0);tk(a+544|0);tk(a+576|0);tk(a+608|0);tk(a+640|0);tk(a+672|0);tk(a+704|0);tk(a+736|0);tk(a+768|0);tk(a+800|0);tk(a+832|0);tk(a+864|0);tk(a+896|0);tk(a+928|0);tk(a+960|0);tk(a+992|0);tk(a+1024|0);return}function Hg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;c=u;u=u+16|0;d=c;if(b[a+288>>0]|0){u=c;return 1}e=a+8|0;g=f[e>>2]|0;h=(f[g+12>>2]|0)-(f[g+8>>2]|0)|0;g=h>>2;i=a+172|0;Gi(i,g+-1|0);if(!((g|0)!=1&(h|0)>0)){u=c;return 1}h=a+12|0;a=0;j=0;while(1){k=f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0;if(!(f[k+56>>2]|0))l=j;else{m=f[i>>2]|0;f[m+(j*136|0)>>2]=a;n=f[m+(j*136|0)+104>>2]|0;o=m+(j*136|0)+108|0;p=f[o>>2]|0;if((p|0)!=(n|0))f[o>>2]=p+(~((p+-4-n|0)>>>2)<<2);n=f[h>>2]|0;gk(m+(j*136|0)+104|0,(f[n+4>>2]|0)-(f[n>>2]|0)>>2);n=(f[i>>2]|0)+(j*136|0)+116|0;m=f[h>>2]|0;p=(f[m+4>>2]|0)-(f[m>>2]|0)>>2;f[d>>2]=-1;hg(n,p,d);p=f[i>>2]|0;f[p+(j*136|0)+128>>2]=0;Gc(p+(j*136|0)+4|0,f[e>>2]|0,f[h>>2]|0,k)|0;l=j+1|0}a=a+1|0;if((a|0)>=(g|0))break;else j=l}u=c;return 1}function Ig(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=c;e=b;g=d-e|0;h=g>>2;i=a+8|0;j=f[i>>2]|0;k=f[a>>2]|0;l=k;if(h>>>0<=j-k>>2>>>0){m=a+4|0;n=(f[m>>2]|0)-k>>2;o=h>>>0>n>>>0;p=o?b+(n<<2)|0:c;c=p;n=c-e|0;e=n>>2;if(e|0)im(k|0,b|0,n|0)|0;n=l+(e<<2)|0;if(o){o=d-c|0;if((o|0)<=0)return;kh(f[m>>2]|0,p|0,o|0)|0;f[m>>2]=(f[m>>2]|0)+(o>>>2<<2);return}else{o=f[m>>2]|0;if((o|0)==(n|0))return;f[m>>2]=o+(~((o+-4-n|0)>>>2)<<2);return}}n=k;if(!k)q=j;else{j=a+4|0;o=f[j>>2]|0;if((o|0)!=(l|0))f[j>>2]=o+(~((o+-4-k|0)>>>2)<<2);Oq(n);f[i>>2]=0;f[j>>2]=0;f[a>>2]=0;q=0}if(h>>>0>1073741823)aq(a);j=q>>1;n=q>>2>>>0<536870911?(j>>>0>>0?h:j):1073741823;if(n>>>0>1073741823)aq(a);j=ln(n<<2)|0;h=a+4|0;f[h>>2]=j;f[a>>2]=j;f[i>>2]=j+(n<<2);if((g|0)<=0)return;kh(j|0,b|0,g|0)|0;f[h>>2]=j+(g>>>2<<2);return}function Jg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0,q=0.0,r=0.0,s=0.0,t=0,v=0.0;e=u;u=u+16|0;g=e;h=c+1|0;f[g>>2]=0;i=g+4|0;f[i>>2]=0;f[g+8>>2]=0;do if(h)if(h>>>0>1073741823)aq(g);else{j=ln(h<<2)|0;f[g>>2]=j;k=j+(h<<2)|0;f[g+8>>2]=k;sj(j|0,0,(c<<2)+4|0)|0;f[i>>2]=k;l=j;m=k;n=j;break}else{l=0;m=0;n=0}while(0);if((b|0)>0){g=0;do{j=l+(f[a+(g<<2)>>2]<<2)|0;f[j>>2]=(f[j>>2]|0)+1;g=g+1|0}while((g|0)!=(b|0))}o=+(b|0);if((c|0)<0){p=0;q=0.0}else{c=0;r=0.0;b=0;while(1){g=f[l+(b<<2)>>2]|0;s=+(g|0);if((g|0)>0){t=c+1|0;v=r+ +Zg(s/o)*s}else{t=c;v=r}b=b+1|0;if((b|0)==(h|0)){p=t;q=v;break}else{c=t;r=v}}}if(d|0)f[d>>2]=p;v=-q;p=~~v>>>0;d=+K(v)>=1.0?(v>0.0?~~+Y(+J(v/4294967296.0),4294967295.0)>>>0:~~+W((v-+(~~v>>>0))/4294967296.0)>>>0):0;if(!l){I=d;u=e;return p|0}if((m|0)!=(l|0))f[i>>2]=m+(~((m+-4-l|0)>>>2)<<2);Oq(n);I=d;u=e;return p|0}function Kg(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e+4|0;h=e;i=ln(32)|0;f[a>>2]=i;f[a+4>>2]=c+4;c=a+8|0;b[c>>0]=0;f[i+16>>2]=f[d>>2];a=i+20|0;f[i+24>>2]=0;f[i+28>>2]=0;j=i+24|0;f[a>>2]=j;i=f[d+4>>2]|0;k=d+8|0;if((i|0)==(k|0)){b[c>>0]=1;u=e;return}d=j;j=i;while(1){i=j+16|0;f[h>>2]=d;f[g>>2]=f[h>>2];ph(a,g,i,i)|0;i=f[j+4>>2]|0;if(!i){l=j+8|0;m=f[l>>2]|0;if((f[m>>2]|0)==(j|0))n=m;else{m=l;do{l=f[m>>2]|0;m=l+8|0;o=f[m>>2]|0}while((f[o>>2]|0)!=(l|0));n=o}}else{m=i;while(1){o=f[m>>2]|0;if(!o)break;else m=o}n=m}if((n|0)==(k|0))break;else j=n}b[c>>0]=1;u=e;return}function Lg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;f[e>>2]=b;g=a+8|0;if(((f[a+12>>2]|0)-(f[g>>2]|0)>>2|0)<=(b|0))Bh(g,b+1|0);h=f[(f[c>>2]|0)+56>>2]|0;do if((h|0)<5){i=a+20+(h*12|0)+4|0;j=f[i>>2]|0;if((j|0)==(f[a+20+(h*12|0)+8>>2]|0)){Ri(a+20+(h*12|0)|0,e);break}else{f[j>>2]=b;f[i>>2]=j+4;break}}while(0);b=f[c>>2]|0;h=f[e>>2]|0;f[b+60>>2]=h;e=(f[g>>2]|0)+(h<<2)|0;f[c>>2]=0;c=f[e>>2]|0;f[e>>2]=b;if(!c){u=d;return}b=c+88|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0){b=f[e+8>>2]|0;if(b|0){h=e+12|0;if((f[h>>2]|0)!=(b|0))f[h>>2]=b;Oq(b)}Oq(e)}e=f[c+68>>2]|0;if(e|0){b=c+72|0;h=f[b>>2]|0;if((h|0)!=(e|0))f[b>>2]=h+(~((h+-4-e|0)>>>2)<<2);Oq(e)}e=c+64|0;h=f[e>>2]|0;f[e>>2]=0;if(h|0){e=f[h>>2]|0;if(e|0){b=h+4|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(h)}Oq(c);u=d;return}function Mg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+56>>2]|0)-(f[g+52>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[(f[e>>2]|0)+64>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];Zb(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];Zb(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Ng(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0;d=u;u=u+48|0;e=d+16|0;g=d;h=d+32|0;i=a+28|0;j=f[i>>2]|0;f[h>>2]=j;k=a+20|0;l=(f[k>>2]|0)-j|0;f[h+4>>2]=l;f[h+8>>2]=b;f[h+12>>2]=c;b=l+c|0;l=a+60|0;f[g>>2]=f[l>>2];f[g+4>>2]=h;f[g+8>>2]=2;j=to(Aa(146,g|0)|0)|0;a:do if((b|0)!=(j|0)){g=2;m=b;n=h;o=j;while(1){if((o|0)<0)break;m=m-o|0;p=f[n+4>>2]|0;q=o>>>0>p>>>0;r=q?n+8|0:n;s=g+(q<<31>>31)|0;t=o-(q?p:0)|0;f[r>>2]=(f[r>>2]|0)+t;p=r+4|0;f[p>>2]=(f[p>>2]|0)-t;f[e>>2]=f[l>>2];f[e+4>>2]=r;f[e+8>>2]=s;o=to(Aa(146,e|0)|0)|0;if((m|0)==(o|0)){v=3;break a}else{g=s;n=r}}f[a+16>>2]=0;f[i>>2]=0;f[k>>2]=0;f[a>>2]=f[a>>2]|32;if((g|0)==2)w=0;else w=c-(f[n+4>>2]|0)|0}else v=3;while(0);if((v|0)==3){v=f[a+44>>2]|0;f[a+16>>2]=v+(f[a+48>>2]|0);a=v;f[i>>2]=a;f[k>>2]=a;w=c}u=d;return w|0}function Og(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=6192;b=f[a+68>>2]|0;if(b|0){c=a+72|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+56>>2]|0;if(b|0){d=a+60|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+44>>2]|0;if(b|0){c=a+48|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+32>>2]|0;if(b|0){d=a+36|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+20>>2]|0;if(b|0){c=a+24|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}hi(a+8|0);b=a+4|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;b=a+40|0;d=f[b>>2]|0;if(d|0){c=a+44|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[c>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0){bj(i);Oq(i)}h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}Oq(g)}bj(a);Oq(a);return}function Pg(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if(((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(f[(f[d>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0)==0:0)?(j=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if(((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(f[(f[d>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)==0:0)?(k=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if((((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(f[(f[d>>2]|0)+(a>>>5<<2)>>2]&1<<(a&31)|0)==0:0)?(h=f[(f[(f[d+64>>2]|0)+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Qg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)aq(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0)Va[f[(f[n>>2]|0)+4>>2]&127](n)}while((h|0)!=(g|0))}if(!m)return;Oq(m);return}function Rg(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+4|0;a=f[d>>2]|0;do if(a|0){e=b[c+11>>0]|0;g=e<<24>>24<0;h=g?f[c+4>>2]|0:e&255;e=g?f[c>>2]|0:c;g=d;i=a;a:while(1){j=i;while(1){k=j+16|0;l=b[k+11>>0]|0;m=l<<24>>24<0;n=m?f[j+20>>2]|0:l&255;l=h>>>0>>0?h:n;if((l|0)!=0?(o=Vk(m?f[k>>2]|0:k,e,l)|0,(o|0)!=0):0){if((o|0)>=0)break}else p=6;if((p|0)==6?(p=0,n>>>0>=h>>>0):0)break;n=f[j+4>>2]|0;if(!n){q=g;break a}else j=n}i=f[j>>2]|0;if(!i){q=j;break}else g=j}if((q|0)!=(d|0)){g=q+16|0;i=b[g+11>>0]|0;n=i<<24>>24<0;o=n?f[q+20>>2]|0:i&255;i=o>>>0>>0?o:h;if(i|0?(l=Vk(e,n?f[g>>2]|0:g,i)|0,l|0):0){if((l|0)<0)break;else r=q;return r|0}if(h>>>0>=o>>>0){r=q;return r|0}}}while(0);r=d;return r|0}function Sg(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=a+8|0;f[c>>2]=f[b>>2];fg(a+12|0,b+4|0)|0;d=a+44|0;e=b+36|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];if((c|0)==(b|0)){f[a+96>>2]=f[b+88>>2];return}else{ng(a+60|0,f[b+52>>2]|0,f[b+56>>2]|0);ng(a+72|0,f[b+64>>2]|0,f[b+68>>2]|0);ng(a+84|0,f[b+76>>2]|0,f[b+80>>2]|0);f[a+96>>2]=f[b+88>>2];Ig(a+100|0,f[b+92>>2]|0,f[b+96>>2]|0);return}}function Tg(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if(((e-h|0)/12|0)>>>0>=b>>>0){i=b;j=h;do{f[j>>2]=f[c>>2];f[j+4>>2]=f[c+4>>2];f[j+8>>2]=f[c+8>>2];j=(f[g>>2]|0)+12|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=(h-i|0)/12|0;h=j+b|0;if(h>>>0>357913941)aq(a);k=(e-i|0)/12|0;i=k<<1;e=k>>>0<178956970?(i>>>0>>0?h:i):357913941;do if(e)if(e>>>0>357913941){i=ra(8)|0;Oo(i,16035);f[i>>2]=7256;va(i|0,1112,110)}else{l=ln(e*12|0)|0;break}else l=0;while(0);i=l+(j*12|0)|0;j=l+(e*12|0)|0;e=b;b=i;l=i;do{f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];b=l+12|0;l=b;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;b=(f[g>>2]|0)-e|0;c=i+(((b|0)/-12|0)*12|0)|0;if((b|0)>0)kh(c|0,e|0,b|0)|0;f[a>>2]=c;f[g>>2]=l;f[d>>2]=j;if(!e)return;Oq(e);return}function Ug(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d>>2;g=e+1|0;if(g>>>0>1073741823)aq(a);h=a+8|0;i=(f[h>>2]|0)-d|0;d=i>>1;j=i>>2>>>0<536870911?(d>>>0>>0?g:d):1073741823;do if(j)if(j>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{k=ln(j<<2)|0;break}else k=0;while(0);d=k+(e<<2)|0;e=d;g=k+(j<<2)|0;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;j=d+4|0;b=f[a>>2]|0;k=f[c>>2]|0;if((k|0)==(b|0)){l=e;m=b;n=b}else{i=k;k=e;e=d;do{i=i+-4|0;d=f[i>>2]|0;f[i>>2]=0;f[e+-4>>2]=d;e=k+-4|0;k=e}while((i|0)!=(b|0));l=k;m=f[a>>2]|0;n=f[c>>2]|0}f[a>>2]=l;f[c>>2]=j;f[h>>2]=g;g=m;if((n|0)!=(g|0)){h=n;do{h=h+-4|0;n=f[h>>2]|0;f[h>>2]=0;if(n|0){bj(n);Oq(n)}}while((h|0)!=(g|0))}if(!m)return;Oq(m);return}function Vg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=f[b>>2]|0;g=f[a>>2]|0;h=f[d>>2]|0;d=f[h>>2]|0;i=(f[h+4>>2]|0)-d>>3;if(i>>>0<=e>>>0)aq(h);j=d;if(i>>>0<=g>>>0)aq(h);d=f[j+(e<<3)>>2]|0;k=f[c>>2]|0;if(i>>>0<=k>>>0)aq(h);l=j+(g<<3)|0;m=(f[j+(k<<3)>>2]|0)>>>0>>0;if(d>>>0<(f[l>>2]|0)>>>0){if(m){f[a>>2]=k;f[c>>2]=g;n=1;return n|0}f[a>>2]=e;f[b>>2]=g;d=f[c>>2]|0;if(i>>>0<=d>>>0)aq(h);if((f[j+(d<<3)>>2]|0)>>>0>=(f[l>>2]|0)>>>0){n=1;return n|0}f[b>>2]=d;f[c>>2]=g;n=2;return n|0}if(!m){n=0;return n|0}f[b>>2]=k;f[c>>2]=e;e=f[b>>2]|0;c=f[a>>2]|0;if(i>>>0<=e>>>0)aq(h);if(i>>>0<=c>>>0)aq(h);if((f[j+(e<<3)>>2]|0)>>>0>=(f[j+(c<<3)>>2]|0)>>>0){n=1;return n|0}f[a>>2]=e;f[b>>2]=c;n=2;return n|0}function Wg(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=u;u=u+16|0;c=b+4|0;d=b;e=a+8|0;g=f[e>>2]|0;gk(f[a+4>>2]|0,(f[g+28>>2]|0)-(f[g+24>>2]|0)>>2);g=a+84|0;a=f[g>>2]|0;if(!a){h=f[e>>2]|0;i=(f[h+4>>2]|0)-(f[h>>2]|0)>>2;h=(i>>>0)/3|0;if(i>>>0<=2){u=b;return 1}i=0;do{f[d>>2]=i*3;f[c>>2]=f[d>>2];dc(e,c);i=i+1|0}while((i|0)<(h|0));u=b;return 1}else{h=f[a>>2]|0;if((f[a+4>>2]|0)==(h|0)){u=b;return 1}a=0;i=h;do{f[d>>2]=f[i+(a<<2)>>2];f[c>>2]=f[d>>2];dc(e,c);a=a+1|0;h=f[g>>2]|0;i=f[h>>2]|0}while(a>>>0<(f[h+4>>2]|0)-i>>2>>>0);u=b;return 1}return 0}function Xg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;a=u;u=u+16|0;e=a;if(!b){g=0;u=a;return g|0}h=b+96|0;i=b+100|0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;b=f[i>>2]|0;j=f[h>>2]|0;k=(b-j|0)/12|0;l=j;j=b;if(k>>>0>=c>>>0){if(k>>>0>c>>>0?(b=l+(c*12|0)|0,(b|0)!=(j|0)):0)f[i>>2]=j+(~(((j+-12-b|0)>>>0)/12|0)*12|0);if(!c){g=1;u=a;return g|0}}else Tg(h,c-k|0,e);k=0;b=f[h>>2]|0;while(1){j=k*3|0;l=f[d+(j<<2)>>2]|0;m=f[d+(j+1<<2)>>2]|0;n=f[d+(j+2<<2)>>2]|0;j=((f[i>>2]|0)-b|0)/12|0;o=k;k=k+1|0;if(o>>>0>>0){p=b;q=b}else{f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;Tg(h,k-j|0,e);j=f[h>>2]|0;p=j;q=j}f[p+(o*12|0)>>2]=l;f[p+(o*12|0)+4>>2]=m;f[p+(o*12|0)+8>>2]=n;if((k|0)==(c|0)){g=1;break}else b=q}u=a;return g|0}function Yg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=u;u=u+80|0;g=e+36|0;h=e;ao(g,c);Ke(h,b,c);Ph(g,h);Ej(h+24|0,f[h+28>>2]|0);Oj(h+12|0,f[h+16>>2]|0);Ej(h,f[h+4>>2]|0);cj(a,g,d);Ej(g+24|0,f[g+28>>2]|0);Oj(g+12|0,f[g+16>>2]|0);Ej(g,f[g+4>>2]|0);u=e;return}function Zg(a){a=+a;var b=0,c=0,d=0,e=0.0,g=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,q=0.0,r=0.0,t=0.0;p[s>>3]=a;b=f[s>>2]|0;c=f[s+4>>2]|0;d=(c|0)<0;do if(d|c>>>0<1048576){if((b|0)==0&(c&2147483647|0)==0){e=-1.0/(a*a);break}if(d){e=(a-a)/0.0;break}else{p[s>>3]=a*18014398509481984.0;g=f[s+4>>2]|0;h=-1077;i=g;j=f[s>>2]|0;k=g;l=9;break}}else if(c>>>0<=2146435071)if((b|0)==0&0==0&(c|0)==1072693248)e=0.0;else{h=-1023;i=c;j=b;k=c;l=9}else e=a;while(0);if((l|0)==9){l=i+614242|0;f[s>>2]=j;f[s+4>>2]=(l&1048575)+1072079006;a=+p[s>>3]+-1.0;m=a*a*.5;n=a/(a+2.0);o=n*n;q=o*o;p[s>>3]=a-m;j=f[s+4>>2]|0;f[s>>2]=0;f[s+4>>2]=j;r=+p[s>>3];t=a-r-m+n*(m+(q*(q*(q*.15313837699209373+.22222198432149784)+.3999999999940942)+o*(q*(q*(q*.14798198605116586+.1818357216161805)+.2857142874366239)+.6666666666666735)));q=r*1.4426950407214463;o=+(h+(l>>>20)|0);m=q+o;e=m+(q+(o-m)+(t*1.4426950407214463+(t+r)*1.6751713164886512e-10))}return +e}function _g(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=u;u=u+16|0;e=d;g=ln(32)|0;f[e>>2]=g;f[e+8>>2]=-2147483616;f[e+4>>2]=17;h=g;i=14390;j=h+17|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[g+17>>0]=0;g=c+16|0;i=f[g>>2]|0;if(i){h=g;j=i;a:while(1){i=j;while(1){if((f[i+16>>2]|0)>=(a|0))break;k=f[i+4>>2]|0;if(!k){l=h;break a}else i=k}j=f[i>>2]|0;if(!j){l=i;break}else h=i}if(((l|0)!=(g|0)?(f[l+16>>2]|0)<=(a|0):0)?(a=l+20|0,(Jh(a,e)|0)!=0):0)m=a;else n=10}else n=10;if((n|0)==10)m=c;c=Hk(m,e,-1)|0;if((b[e+11>>0]|0)>=0){o=(c|0)==-1;p=c>>>0>6;q=p?-2:c;r=o?-1:q;u=d;return r|0}Oq(f[e>>2]|0);o=(c|0)==-1;p=c>>>0>6;q=p?-2:c;r=o?-1:q;u=d;return r|0}function $g(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[c>>2]|0;f[c>>2]=0;f[e>>2]=g;Lg(a,b,e);g=f[e>>2]|0;f[e>>2]=0;if(g|0){e=g+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){h=c+12|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(c)}c=f[g+68>>2]|0;if(c|0){e=g+72|0;h=f[e>>2]|0;if((h|0)!=(c|0))f[e>>2]=h+(~((h+-4-c|0)>>>2)<<2);Oq(c)}c=g+64|0;h=f[c>>2]|0;f[c>>2]=0;if(h|0){c=f[h>>2]|0;if(c|0){e=h+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(h)}Oq(g)}g=a+84|0;h=a+88|0;a=f[h>>2]|0;c=f[g>>2]|0;e=a-c>>2;if((e|0)>(b|0)){u=d;return}i=b+1|0;b=a;if(i>>>0>e>>>0){Fh(g,i-e|0);u=d;return}if(i>>>0>=e>>>0){u=d;return}e=c+(i<<2)|0;if((e|0)==(b|0)){u=d;return}f[h>>2]=b+(~((b+-4-e|0)>>>2)<<2);u=d;return}function ah(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;g=a+4|0;f[g>>2]=c;f[a+8>>2]=f[c+52>>2];h=f[a+184>>2]|0;i=a+188|0;j=f[i>>2]|0;if((j|0)!=(h|0))f[i>>2]=j+(~((j+-4-h|0)>>>2)<<2);h=f[c+48>>2]|0;c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Jh(h,e)|0)==0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);h=f[(f[g>>2]|0)+48>>2]|0;if(c){c=(mi(h)|0)>5&1;b[a+352>>0]=c;u=d;return 1}c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Yj(h,e,0)|0)&1;b[a+352>>0]=c;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);u=d;return 1}function bh(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0;c=a+108|0;d=(f[a+112>>2]|0)-(f[c>>2]|0)|0;e=(d|0)/12|0;g=a+4|0;ci(e,f[(f[g>>2]|0)+44>>2]|0)|0;if(!d)return 1;d=0;a=0;while(1){i=f[c>>2]|0;j=i+(d*12|0)+4|0;ci((f[j>>2]|0)-a|0,f[(f[g>>2]|0)+44>>2]|0)|0;ci((f[j>>2]|0)-(f[i+(d*12|0)>>2]|0)|0,f[(f[g>>2]|0)+44>>2]|0)|0;d=d+1|0;if(d>>>0>=e>>>0)break;else a=f[j>>2]|0}zi(f[(f[g>>2]|0)+44>>2]|0,e,0,0)|0;a=0;do{d=f[(f[g>>2]|0)+44>>2]|0;j=d+16|0;i=f[j+4>>2]|0;if((i|0)>0|(i|0)==0&(f[j>>2]|0)>>>0>0){j=f[d+12>>2]|0;d=j+4|0;i=f[d>>2]|0;k=b[(f[c>>2]|0)+(a*12|0)+8>>0]&1;l=i>>>3;m=i&7;i=(f[j>>2]|0)+l|0;b[i>>0]=(1<>0]|0);i=(f[j>>2]|0)+l|0;b[i>>0]=k<>0]|0);f[d>>2]=(f[d>>2]|0)+1}a=a+1|0}while(a>>>0>>0);eg(f[(f[g>>2]|0)+44>>2]|0);return 1}function ch(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=u;u=u+80|0;g=e+36|0;h=e;io(g,c);Ke(h,b,c);Ph(g,h);Ej(h+24|0,f[h+28>>2]|0);Oj(h+12|0,f[h+16>>2]|0);Ej(h,f[h+4>>2]|0);cj(a,g,d);Ej(g+24|0,f[g+28>>2]|0);Oj(g+12|0,f[g+16>>2]|0);Ej(g,f[g+4>>2]|0);u=e;return}function dh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;g=a+4|0;f[g>>2]=c;f[a+8>>2]=f[c+52>>2];h=f[a+184>>2]|0;i=a+188|0;j=f[i>>2]|0;if((j|0)!=(h|0))f[i>>2]=j+(~((j+-4-h|0)>>>2)<<2);h=f[c+48>>2]|0;c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Jh(h,e)|0)==0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);h=f[(f[g>>2]|0)+48>>2]|0;if(c){c=(mi(h)|0)>5&1;b[a+288>>0]=c;u=d;return 1}c=ln(32)|0;f[e>>2]=c;f[e+8>>2]=-2147483616;f[e+4>>2]=19;j=c;i=15351;k=j+19|0;do{b[j>>0]=b[i>>0]|0;j=j+1|0;i=i+1|0}while((j|0)<(k|0));b[c+19>>0]=0;c=(Yj(h,e,0)|0)&1;b[a+288>>0]=c;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);u=d;return 1}function eh(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;g=u;u=u+32|0;h=g+16|0;i=g+8|0;j=g;k=d-e|0;d=a+8|0;if((k|0)>0){a=0-e|0;l=i+4|0;m=j+4|0;n=h+4|0;o=k;do{k=b+(o<<2)|0;p=k+(a<<2)|0;q=c+(o<<2)|0;r=f[k+4>>2]|0;s=f[p>>2]|0;t=f[p+4>>2]|0;f[i>>2]=f[k>>2];f[l>>2]=r;f[j>>2]=s;f[m>>2]=t;Od(h,d,i,j);f[q>>2]=f[h>>2];f[q+4>>2]=f[n>>2];o=o-e|0}while((o|0)>0)}o=e>>>0>1073741823?-1:e<<2;e=Lq(o)|0;sj(e|0,0,o|0)|0;o=f[b+4>>2]|0;n=f[e>>2]|0;m=f[e+4>>2]|0;f[i>>2]=f[b>>2];f[i+4>>2]=o;f[j>>2]=n;f[j+4>>2]=m;Od(h,d,i,j);f[c>>2]=f[h>>2];f[c+4>>2]=f[h+4>>2];Mq(e);u=g;return 1}function fh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+32|0;d=c+12|0;e=c;g=f[b+100>>2]|0;h=f[b+96>>2]|0;b=g-h|0;i=(b|0)/12|0;f[d>>2]=0;j=d+4|0;f[j>>2]=0;f[d+8>>2]=0;k=h;do if(b)if(i>>>0>357913941)aq(d);else{l=ln(b)|0;f[d>>2]=l;f[d+8>>2]=l+(i*12|0);sj(l|0,0,b|0)|0;f[j>>2]=l+b;m=l;break}else m=0;while(0);f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;if((g|0)!=(h|0)){h=e+4|0;g=e+8|0;b=0;do{l=k+(b*12|0)|0;f[e>>2]=f[l>>2];f[e+4>>2]=f[l+4>>2];f[e+8>>2]=f[l+8>>2];f[m+(b*12|0)>>2]=f[e>>2];f[m+(b*12|0)+4>>2]=f[h>>2];f[m+(b*12|0)+8>>2]=f[g>>2];b=b+1|0}while(b>>>0>>0)}Kj(a,d);a=f[d>>2]|0;if(!a){u=c;return}d=f[j>>2]|0;if((d|0)!=(a|0))f[j>>2]=d+(~(((d+-12-a|0)>>>0)/12|0)*12|0);Oq(a);u=c;return}function gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;if(c>>>0>4294967279)aq(a);d=a+11|0;e=b[d>>0]|0;g=e<<24>>24<0;if(g){h=f[a+4>>2]|0;i=(f[a+8>>2]&2147483647)+-1|0}else{h=e&255;i=10}j=h>>>0>c>>>0?h:c;c=j>>>0<11;k=c?10:(j+16&-16)+-1|0;do if((k|0)!=(i|0)){do if(c){j=f[a>>2]|0;if(g){l=0;m=j;n=a;o=13}else{Fo(a,j,(e&255)+1|0)|0;Oq(j);o=16}}else{j=k+1|0;p=ln(j)|0;if(g){l=1;m=f[a>>2]|0;n=p;o=13;break}else{Fo(p,a,(e&255)+1|0)|0;q=p;r=j;s=a+4|0;o=15;break}}while(0);if((o|0)==13){j=a+4|0;Fo(n,m,(f[j>>2]|0)+1|0)|0;Oq(m);if(l){q=n;r=k+1|0;s=j;o=15}else o=16}if((o|0)==15){f[a+8>>2]=r|-2147483648;f[s>>2]=h;f[a>>2]=q;break}else if((o|0)==16){b[d>>0]=h;break}}while(0);return}function hh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=f[b>>2]|0;if((c|0)==-1){d=-1;return d|0}b=f[(f[a+24>>2]|0)+(c<<2)>>2]|0;if((b|0)==-1){d=0;return d|0}c=a+12|0;a=0;e=0;g=b;a:while(1){b:do if(e){h=a+1|0;i=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((i|0)==-1){d=h;j=15;break a}k=f[(f[c>>2]|0)+(i<<2)>>2]|0;if((k|0)==-1){d=h;j=15;break a}if(!((k>>>0)%3|0)){l=k+2|0;m=h;break}else{l=k+-1|0;m=h;break}}else{h=a;k=g;while(1){i=h+1|0;n=k+1|0;o=((n>>>0)%3|0|0)==0?k+-2|0:n;if((o|0)==-1){l=b;m=i;break b}n=f[(f[c>>2]|0)+(o<<2)>>2]|0;o=n+1|0;if((n|0)==-1){l=b;m=i;break b}k=((o>>>0)%3|0|0)==0?n+-2|0:o;if((k|0)==-1){l=b;m=i;break b}if((k|0)==(b|0)){d=i;j=15;break a}else h=i}}while(0);if((l|0)==-1){d=m;j=15;break}else{a=m;e=1;g=l}}if((j|0)==15)return d|0;return 0}function ih(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=a+8|0;Vg(a,a+4|0,d,c)|0;e=a+12|0;if((e|0)==(b|0))return;g=f[c>>2]|0;c=f[g>>2]|0;h=(f[g+4>>2]|0)-c>>3;i=c;c=e;e=d;a:while(1){d=f[c>>2]|0;j=f[e>>2]|0;if(h>>>0<=d>>>0){k=5;break}if(h>>>0<=j>>>0){k=7;break}l=i+(d<<3)|0;if((f[l>>2]|0)>>>0<(f[i+(j<<3)>>2]|0)>>>0){m=e;n=c;o=j;while(1){f[n>>2]=o;if((m|0)==(a|0)){p=a;break}j=m+-4|0;o=f[j>>2]|0;if(h>>>0<=o>>>0){k=11;break a}if((f[l>>2]|0)>>>0>=(f[i+(o<<3)>>2]|0)>>>0){p=m;break}else{q=m;m=j;n=q}}f[p>>2]=d}n=c+4|0;if((n|0)==(b|0)){k=3;break}else{m=c;c=n;e=m}}if((k|0)==3)return;else if((k|0)==5)aq(g);else if((k|0)==7)aq(g);else if((k|0)==11)aq(g)}function jh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=Vg(a,b,c,e)|0;h=f[d>>2]|0;i=f[c>>2]|0;j=f[e>>2]|0;e=f[j>>2]|0;k=(f[j+4>>2]|0)-e>>3;if(k>>>0<=h>>>0)aq(j);l=e;if(k>>>0<=i>>>0)aq(j);if((f[l+(h<<3)>>2]|0)>>>0>=(f[l+(i<<3)>>2]|0)>>>0){m=g;return m|0}f[c>>2]=h;f[d>>2]=i;i=f[c>>2]|0;d=f[b>>2]|0;if(k>>>0<=i>>>0)aq(j);if(k>>>0<=d>>>0)aq(j);if((f[l+(i<<3)>>2]|0)>>>0>=(f[l+(d<<3)>>2]|0)>>>0){m=g+1|0;return m|0}f[b>>2]=i;f[c>>2]=d;d=f[b>>2]|0;c=f[a>>2]|0;if(k>>>0<=d>>>0)aq(j);if(k>>>0<=c>>>0)aq(j);if((f[l+(d<<3)>>2]|0)>>>0>=(f[l+(c<<3)>>2]|0)>>>0){m=g+2|0;return m|0}f[a>>2]=d;f[b>>2]=c;m=g+3|0;return m|0}function kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;if((d|0)>=8192)return Da(a|0,c|0,d|0)|0;e=a|0;g=a+d|0;if((a&3)==(c&3)){while(a&3){if(!d)return e|0;b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0;d=d-1|0}h=g&-4|0;d=h-64|0;while((a|0)<=(d|0)){f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];f[a+12>>2]=f[c+12>>2];f[a+16>>2]=f[c+16>>2];f[a+20>>2]=f[c+20>>2];f[a+24>>2]=f[c+24>>2];f[a+28>>2]=f[c+28>>2];f[a+32>>2]=f[c+32>>2];f[a+36>>2]=f[c+36>>2];f[a+40>>2]=f[c+40>>2];f[a+44>>2]=f[c+44>>2];f[a+48>>2]=f[c+48>>2];f[a+52>>2]=f[c+52>>2];f[a+56>>2]=f[c+56>>2];f[a+60>>2]=f[c+60>>2];a=a+64|0;c=c+64|0}while((a|0)<(h|0)){f[a>>2]=f[c>>2];a=a+4|0;c=c+4|0}}else{h=g-4|0;while((a|0)<(h|0)){b[a>>0]=b[c>>0]|0;b[a+1>>0]=b[c+1>>0]|0;b[a+2>>0]=b[c+2>>0]|0;b[a+3>>0]=b[c+3>>0]|0;a=a+4|0;c=c+4|0}}while((a|0)<(g|0)){b[a>>0]=b[c>>0]|0;a=a+1|0;c=c+1|0}return e|0}function lh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+16|0;d=c+4|0;e=c;f[a>>2]=1232;g=a+4|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;f[g+16>>2]=0;f[g+20>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;f[d>>2]=b;b=a+4|0;g=a+8|0;Ri(b,d);h=f[d>>2]|0;i=a+20|0;j=f[i>>2]|0;k=a+16|0;a=f[k>>2]|0;l=j-a>>2;m=a;if((h|0)<(l|0)){n=m;o=h;p=f[g>>2]|0;q=f[b>>2]|0;r=p-q|0;s=r>>2;t=s+-1|0;v=n+(o<<2)|0;f[v>>2]=t;u=c;return}a=h+1|0;f[e>>2]=-1;w=j;if(a>>>0<=l>>>0)if(a>>>0>>0?(j=m+(a<<2)|0,(j|0)!=(w|0)):0){f[i>>2]=w+(~((w+-4-j|0)>>>2)<<2);x=h;y=m}else{x=h;y=m}else{Ch(k,a-l|0,e);x=f[d>>2]|0;y=f[k>>2]|0}n=y;o=x;p=f[g>>2]|0;q=f[b>>2]|0;r=p-q|0;s=r>>2;t=s+-1|0;v=n+(o<<2)|0;f[v>>2]=t;u=c;return}function mh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=a+4|0;c=f[b>>2]|0;d=(f[c+12>>2]|0)-(f[c+8>>2]|0)|0;c=d>>2;a:do if((d|0)>0){e=0;while(1){if(!(Ra[f[(f[a>>2]|0)+36>>2]&127](a,e)|0)){g=0;break}e=e+1|0;h=f[b>>2]|0;i=(f[h+12>>2]|0)-(f[h+8>>2]|0)>>2;if((e|0)>=(i|0)){j=i;break a}}return g|0}else j=c;while(0);c=a+20|0;b=a+24|0;d=f[b>>2]|0;e=f[c>>2]|0;i=d-e>>2;h=e;e=d;if(j>>>0<=i>>>0){if(j>>>0>>0?(d=h+(j<<2)|0,(d|0)!=(e|0)):0)f[b>>2]=e+(~((e+-4-d|0)>>>2)<<2)}else Ci(c,j-i|0);i=f[a+12>>2]|0;j=f[a+8>>2]|0;a=j;if((i|0)==(j|0)){g=1;return g|0}d=i-j>>2;j=0;do{i=f[a+(j<<2)>>2]|0;e=f[i+8>>2]|0;b=f[i+4>>2]|0;i=b;if((e|0)!=(b|0)?(h=f[c>>2]|0,k=e-b>>2,f[h+(f[i>>2]<<2)>>2]=j,k>>>0>1):0){b=1;do{f[h+(f[i+(b<<2)>>2]<<2)>>2]=j;b=b+1|0}while(b>>>0>>0)}j=j+1|0}while(j>>>0>>0);g=1;return g|0}function nh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=f[c+88>>2]|0;if(!d){e=0;return e|0}if((f[d>>2]|0)!=1){e=0;return e|0}g=d+8|0;d=f[g>>2]|0;f[a+4>>2]=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;i=a+8|0;j=c+24|0;c=b[j>>0]|0;k=c<<24>>24;l=a+12|0;m=f[l>>2]|0;n=f[i>>2]|0;o=m-n>>2;p=n;n=m;if(o>>>0>=k>>>0)if(o>>>0>k>>>0?(m=p+(k<<2)|0,(m|0)!=(n|0)):0){f[l>>2]=n+(~((n+-4-m|0)>>>2)<<2);q=c;r=d}else{q=c;r=d}else{Ci(i,k-o|0);q=b[j>>0]|0;r=f[g>>2]|0}g=r+4|0;j=h[g>>0]|h[g+1>>0]<<8|h[g+2>>0]<<16|h[g+3>>0]<<24;if(q<<24>>24>0){g=f[i>>2]|0;i=q<<24>>24;q=j;o=4;k=0;while(1){f[g+(k<<2)>>2]=q;o=o+4|0;k=k+1|0;d=r+o|0;c=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;if((k|0)>=(i|0)){s=c;break}else q=c}}else s=j;f[a+20>>2]=s;e=1;return e|0}function oh(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;do if(!(fp(a,f[c+8>>2]|0,g)|0)){if(!(fp(a,f[c>>2]|0,g)|0)){h=f[a+8>>2]|0;Za[f[(f[h>>2]|0)+24>>2]&3](h,c,d,e,g);break}if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;i=c+44|0;if((f[i>>2]|0)==4)break;j=c+52|0;b[j>>0]=0;k=c+53|0;b[k>>0]=0;l=f[a+8>>2]|0;_a[f[(f[l>>2]|0)+20>>2]&3](l,c,d,d,1,g);if(b[k>>0]|0)if(!(b[j>>0]|0)){m=3;n=11}else o=3;else{m=4;n=11}if((n|0)==11){f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0){b[c+54>>0]=1;o=m}else o=m}f[i>>2]=o;break}if((e|0)==1)f[c+32>>2]=1}else Vm(0,c,d,e);while(0);return}function ph(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e+12|0;h=e+8|0;i=e;f[i>>2]=f[b>>2];f[g>>2]=f[i>>2];i=Kd(a,g,h,e+4|0,c)|0;c=f[i>>2]|0;if(c|0){j=c;u=e;return j|0}c=ln(40)|0;pj(c+16|0,d);pj(c+28|0,d+12|0);d=f[h>>2]|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=d;f[i>>2]=c;d=f[f[a>>2]>>2]|0;if(!d)k=c;else{f[a>>2]=d;k=f[i>>2]|0}Oe(f[a+4>>2]|0,k);k=a+8|0;f[k>>2]=(f[k>>2]|0)+1;j=c;u=e;return j|0}function qh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=a+4|0;f[h>>2]=0;if(!c){u=e;return}i=a+8|0;j=f[i>>2]|0;k=j<<5;if(k>>>0>>0){f[g>>2]=0;l=g+4|0;f[l>>2]=0;m=g+8|0;f[m>>2]=0;if((c|0)<0)aq(a);n=j<<6;j=c+31&-32;vi(g,k>>>0<1073741823?(n>>>0>>0?j:n):2147483647);n=f[a>>2]|0;f[a>>2]=f[g>>2];f[g>>2]=n;g=f[h>>2]|0;f[h>>2]=c;f[l>>2]=g;g=f[i>>2]|0;f[i>>2]=f[m>>2];f[m>>2]=g;if(n|0)Oq(n);o=a}else{f[h>>2]=c;o=a}a=f[o>>2]|0;o=a;h=a;a=c>>>5;n=a<<2;if(!(b[d>>0]|0)){sj(h|0,0,n|0)|0;d=c&31;g=o+(a<<2)|0;if(!d){u=e;return}f[g>>2]=f[g>>2]&~(-1>>>(32-d|0));u=e;return}else{sj(h|0,-1,n|0)|0;n=c&31;c=o+(a<<2)|0;if(!n){u=e;return}f[c>>2]=f[c>>2]|-1>>>(32-n|0);u=e;return}}function rh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+20>>2];if((l|0)>0|(l|0)==0&m>>>0>0){n=a+88|0;ld(n,b);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;n=a+88|0;ld(n,b);u=c;return 1}function sh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){n=a+108|0;ld(n,b);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;n=a+108|0;ld(n,b);u=c;return 1}function th(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;c=a+32|0;d=f[a+64>>2]|0;e=(Qa[f[(f[d>>2]|0)+40>>2]&127](d)|0)+52|0;d=f[e>>2]|0;zi(c,(((f[d+100>>2]|0)-(f[d+96>>2]|0)|0)/12|0)*3|0,0,1)|0;d=a+68|0;e=f[d>>2]|0;g=(f[a+72>>2]|0)-e|0;if((g|0)<=0){eg(c);return}i=a+48|0;j=a+44|0;a=(g>>>2)+-1|0;g=e;while(1){e=f[g+(a<<2)>>2]|0;k=f[3524+(e<<2)>>2]|0;l=i;m=f[l+4>>2]|0;if((m|0)>0|(m|0)==0&(f[l>>2]|0)>>>0>0?(l=f[j>>2]|0,171>>>e&1|0):0){m=l+4|0;n=0;o=f[m>>2]|0;do{p=o>>>3;q=o&7;r=(f[l>>2]|0)+p|0;b[r>>0]=(1<>0]|0);r=(f[l>>2]|0)+p|0;b[r>>0]=(e>>>n&1)<>0]|0);o=(f[m>>2]|0)+1|0;f[m>>2]=o;n=n+1|0}while((n|0)!=(k|0))}k=a+-1|0;if((k|0)<=-1)break;a=k;g=f[d>>2]|0}eg(c);return}function uh(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=u;u=u+48|0;h=g;i=g+32|0;if(!c){j=0;u=g;return j|0}Gn(h);do if((dm(c,0)|0)!=-1){if(d){if(!(Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0)){k=0;break}Va[f[(f[c>>2]|0)+20>>2]&127](c)}Yg(i,a,c,h);l=(f[i>>2]|0)==0;m=i+4|0;if((b[m+11>>0]|0)<0)Oq(f[m>>2]|0);if(l){l=f[h>>2]|0;m=h+4|0;rg(e,l,l+((f[m>>2]|0)-l)|0);k=(f[m>>2]|0)-(f[h>>2]|0)|0}else k=0}else k=0;while(0);e=h+12|0;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Oq(i);i=f[h>>2]|0;if(i|0){e=h+4|0;if((f[e>>2]|0)!=(i|0))f[e>>2]=i;Oq(i)}j=k;u=g;return j|0}function vh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=u;u=u+16|0;d=c;e=f[(f[a>>2]|0)+8>>2]|0;g=a+8|0;h=a+12|0;i=(f[h>>2]|0)-(f[g>>2]|0)>>2;j=f[b>>2]|0;f[b>>2]=0;f[d>>2]=j;Xa[e&15](a,i,d);i=f[d>>2]|0;f[d>>2]=0;if(!i){k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}d=i+88|0;a=f[d>>2]|0;f[d>>2]=0;if(a|0){d=f[a+8>>2]|0;if(d|0){e=a+12|0;if((f[e>>2]|0)!=(d|0))f[e>>2]=d;Oq(d)}Oq(a)}a=f[i+68>>2]|0;if(a|0){d=i+72|0;e=f[d>>2]|0;if((e|0)!=(a|0))f[d>>2]=e+(~((e+-4-a|0)>>>2)<<2);Oq(a)}a=i+64|0;e=f[a>>2]|0;f[a>>2]=0;if(e|0){a=f[e>>2]|0;if(a|0){d=e+4|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;Oq(a)}Oq(e)}Oq(i);k=f[h>>2]|0;l=f[g>>2]|0;m=k-l|0;n=m>>2;o=n+-1|0;u=c;return o|0}function wh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>3>>>0>=b>>>0){h=b;i=g;do{j=i;f[j>>2]=0;f[j+4>>2]=0;i=(f[e>>2]|0)+8|0;f[e>>2]=i;h=h+-1|0}while((h|0)!=0);return}h=f[a>>2]|0;i=g-h>>3;g=i+b|0;if(g>>>0>536870911)aq(a);j=d-h|0;h=j>>2;d=j>>3>>>0<268435455?(h>>>0>>0?g:h):536870911;do if(d)if(d>>>0>536870911){h=ra(8)|0;Oo(h,16035);f[h>>2]=7256;va(h|0,1112,110)}else{k=ln(d<<3)|0;break}else k=0;while(0);h=k+(i<<3)|0;i=k+(d<<3)|0;d=b;b=h;k=h;do{g=b;f[g>>2]=0;f[g+4>>2]=0;b=k+8|0;k=b;d=d+-1|0}while((d|0)!=0);d=f[a>>2]|0;b=(f[e>>2]|0)-d|0;g=h+(0-(b>>3)<<3)|0;if((b|0)>0)kh(g|0,d|0,b|0)|0;f[a>>2]=g;f[e>>2]=k;f[c>>2]=i;if(!d)return;Oq(d);return}function xh(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;if(!(bn(a,b,c)|0)){g=0;u=d;return g|0}if((Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0)<<24>>24==1?((f[(f[a+8>>2]|0)+28>>2]|0)+-1|0)>>>0>=6:0){g=0;u=d;return g|0}h=_g(c,f[b+48>>2]|0)|0;Xa[f[(f[a>>2]|0)+48>>2]&15](e,a,h);h=a+36|0;b=f[e>>2]|0;f[e>>2]=0;c=f[h>>2]|0;f[h>>2]=b;if(!c){f[e>>2]=0;i=b}else{Va[f[(f[c>>2]|0)+4>>2]&127](c);c=f[e>>2]|0;f[e>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);i=f[h>>2]|0}if(!i){g=1;u=d;return g|0}if(Ra[f[(f[a>>2]|0)+36>>2]&127](a,i)|0){g=1;u=d;return g|0}i=f[h>>2]|0;f[h>>2]=0;if(!i){g=1;u=d;return g|0}Va[f[(f[i>>2]|0)+4>>2]&127](i);g=1;u=d;return g|0}function yh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e+4|0;h=e;i=e+8|0;j=a&255;b[i>>0]=j&127;do if(c>>>0>0|(c|0)==0&a>>>0>127){b[i>>0]=j|-128;k=d+16|0;l=f[k+4>>2]|0;if((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0){m=0;break}else{f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0;k=Yn(a|0,c|0,7)|0;m=yh(k,I,d)|0;break}}else{k=d+16|0;l=f[k+4>>2]|0;if((l|0)>0|(l|0)==0&(f[k>>2]|0)>>>0>0){m=0;break}f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0;n=1;u=e;return n|0}while(0);n=m;u=e;return n|0}function zh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0;g=f[(f[(f[d+4>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;if((b|0)==-1)h=Xi(c,d)|0;else h=b;if((h|0)==-2)i=0;else{do if((Qa[f[(f[d>>2]|0)+8>>2]&127](d)|0)==1){Xf(a,d,h,c,e,514);if(!(f[a>>2]|0)){f[a>>2]=0;break}else return}while(0);c=ln(44)|0;f[c>>2]=1544;f[c+4>>2]=g;g=c+8|0;f[g>>2]=f[e>>2];f[g+4>>2]=f[e+4>>2];f[g+8>>2]=f[e+8>>2];f[g+12>>2]=f[e+12>>2];f[g+16>>2]=f[e+16>>2];f[g+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);f[c>>2]=1600;i=c}f[a>>2]=i;return}function Ah(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=u;u=u+224|0;g=e+120|0;h=e+80|0;i=e;j=e+136|0;k=h;l=k+40|0;do{f[k>>2]=0;k=k+4|0}while((k|0)<(l|0));f[g>>2]=f[d>>2];if((qb(0,c,g,i,h)|0)<0)m=-1;else{if((f[a+76>>2]|0)>-1)n=Tq(a)|0;else n=0;d=f[a>>2]|0;k=d&32;if((b[a+74>>0]|0)<1)f[a>>2]=d&-33;d=a+48|0;if(!(f[d>>2]|0)){l=a+44|0;o=f[l>>2]|0;f[l>>2]=j;p=a+28|0;f[p>>2]=j;q=a+20|0;f[q>>2]=j;f[d>>2]=80;r=a+16|0;f[r>>2]=j+80;j=qb(a,c,g,i,h)|0;if(!o)s=j;else{Sa[f[a+36>>2]&31](a,0,0)|0;t=(f[q>>2]|0)==0?-1:j;f[l>>2]=o;f[d>>2]=0;f[r>>2]=0;f[p>>2]=0;f[q>>2]=0;s=t}}else s=qb(a,c,g,i,h)|0;h=f[a>>2]|0;f[a>>2]=h|k;if(n|0)Sq(a);m=(h&32|0)==0?s:-1}u=e;return m|0}function Bh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e>>2;h=d;if(g>>>0>>0){uf(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b<<2)|0;if((g|0)==(h|0))return;else i=h;do{h=i+-4|0;f[c>>2]=h;b=f[h>>2]|0;f[h>>2]=0;if(b|0){h=b+88|0;e=f[h>>2]|0;f[h>>2]=0;if(e|0){h=f[e+8>>2]|0;if(h|0){a=e+12|0;if((f[a>>2]|0)!=(h|0))f[a>>2]=h;Oq(h)}Oq(e)}e=f[b+68>>2]|0;if(e|0){h=b+72|0;a=f[h>>2]|0;if((a|0)!=(e|0))f[h>>2]=a+(~((a+-4-e|0)>>>2)<<2);Oq(e)}e=b+64|0;a=f[e>>2]|0;f[e>>2]=0;if(a|0){e=f[a>>2]|0;if(e|0){h=a+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(a)}Oq(b)}i=f[c>>2]|0}while((i|0)!=(g|0));return}function Ch(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;i=h;if(e-h>>2>>>0>=b>>>0){j=b;k=i;while(1){f[k>>2]=f[c>>2];j=j+-1|0;if(!j)break;else k=k+4|0}f[g>>2]=i+(b<<2);return}i=f[a>>2]|0;k=h-i|0;h=k>>2;j=h+b|0;if(j>>>0>1073741823)aq(a);l=e-i|0;e=l>>1;m=l>>2>>>0<536870911?(e>>>0>>0?j:e):1073741823;do if(m)if(m>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}else{e=ln(m<<2)|0;n=e;o=e;break}else{n=0;o=0}while(0);e=n+(h<<2)|0;h=n+(m<<2)|0;m=b;j=e;while(1){f[j>>2]=f[c>>2];m=m+-1|0;if(!m)break;else j=j+4|0}if((k|0)>0)kh(o|0,i|0,k|0)|0;f[a>>2]=n;f[g>>2]=e+(b<<2);f[d>>2]=h;if(!i)return;Oq(i);return}function Dh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=(f[a>>2]|0)+1794895138|0;g=gp(f[a+8>>2]|0,e)|0;h=gp(f[a+12>>2]|0,e)|0;i=gp(f[a+16>>2]|0,e)|0;a:do if((g>>>0>>2>>>0?(j=c-(g<<2)|0,h>>>0>>0&i>>>0>>0):0)?((i|h)&3|0)==0:0){j=h>>>2;k=i>>>2;l=0;m=g;while(1){n=m>>>1;o=l+n|0;p=o<<1;q=p+j|0;r=gp(f[a+(q<<2)>>2]|0,e)|0;s=gp(f[a+(q+1<<2)>>2]|0,e)|0;if(!(s>>>0>>0&r>>>0<(c-s|0)>>>0)){t=0;break a}if(b[a+(s+r)>>0]|0){t=0;break a}r=hl(d,a+s|0)|0;if(!r)break;s=(r|0)<0;if((m|0)==1){t=0;break a}else{l=s?l:o;m=s?n:m-n|0}}m=p+k|0;l=gp(f[a+(m<<2)>>2]|0,e)|0;j=gp(f[a+(m+1<<2)>>2]|0,e)|0;if(j>>>0>>0&l>>>0<(c-j|0)>>>0)t=(b[a+(j+l)>>0]|0)==0?a+j|0:0;else t=0}else t=0;while(0);return t|0}function Eh(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h=u;u=u+64|0;i=h;j=f[a>>2]|0;k=a+(f[j+-8>>2]|0)|0;l=f[j+-4>>2]|0;f[i>>2]=e;f[i+4>>2]=a;f[i+8>>2]=c;f[i+12>>2]=g;g=i+16|0;c=i+20|0;a=i+24|0;j=i+28|0;m=i+32|0;n=i+40|0;o=g;p=o+36|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(p|0));d[g+36>>1]=0;b[g+38>>0]=0;a:do if(fp(l,e,0)|0){f[i+48>>2]=1;_a[f[(f[l>>2]|0)+20>>2]&3](l,i,k,k,1,0);q=(f[a>>2]|0)==1?k:0}else{Za[f[(f[l>>2]|0)+24>>2]&3](l,i,k,1,0);switch(f[i+36>>2]|0){case 0:{q=(f[n>>2]|0)==1&(f[j>>2]|0)==1&(f[m>>2]|0)==1?f[c>>2]|0:0;break a;break}case 1:break;default:{q=0;break a}}if((f[a>>2]|0)!=1?!((f[n>>2]|0)==0&(f[j>>2]|0)==1&(f[m>>2]|0)==1):0){q=0;break}q=f[g>>2]|0}while(0);u=h;return q|0}function Fh(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;h=g;if(d-g>>2>>>0>=b>>>0){i=b;j=h;while(1){f[j>>2]=1;i=i+-1|0;if(!i)break;else j=j+4|0}f[e>>2]=h+(b<<2);return}h=f[a>>2]|0;j=g-h|0;g=j>>2;i=g+b|0;if(i>>>0>1073741823)aq(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?i:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{d=ln(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;g=m+(l<<2)|0;l=b;i=d;while(1){f[i>>2]=1;l=l+-1|0;if(!l)break;else i=i+4|0}if((j|0)>0)kh(n|0,h|0,j|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=g;if(!h)return;Oq(h);return}function Gh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(!c){g=0;u=d;return g|0}h=a+84|0;i=f[h>>2]|0;j=a+88|0;k=f[j>>2]|0;if((k|0)!=(i|0))f[j>>2]=k+(~((k+-4-i|0)>>>2)<<2);f[h>>2]=0;f[j>>2]=0;f[a+92>>2]=0;if(i|0)Oq(i);i=a+72|0;j=f[i>>2]|0;h=a+76|0;if((f[h>>2]|0)!=(j|0))f[h>>2]=j;f[i>>2]=0;f[h>>2]=0;f[a+80>>2]=0;if(j|0)Oq(j);j=c+4|0;h=(f[j>>2]|0)-(f[c>>2]|0)>>2;b[e>>0]=0;qh(a,h,e);h=c+24|0;i=c+28|0;k=(f[i>>2]|0)-(f[h>>2]|0)>>2;b[e>>0]=0;qh(a+12|0,k,e);hg(a+28|0,(f[j>>2]|0)-(f[c>>2]|0)>>2,6180);gk(a+52|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);gk(a+40|0,(f[i>>2]|0)-(f[h>>2]|0)>>2);f[a+64>>2]=c;b[a+24>>0]=1;g=1;u=d;return g|0}function Hh(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a+12|0;d=f[a>>2]|0;e=a+8|0;g=f[e>>2]|0;h=(g|0)==-1;if(!(b[c>>0]|0)){do if((!h?(i=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(i|0)!=-1):0)?(j=f[(f[d+12>>2]|0)+(i<<2)>>2]|0,(j|0)!=-1):0)if(!((j>>>0)%3|0)){k=j+2|0;break}else{k=j+-1|0;break}else k=-1;while(0);f[e>>2]=k;return}k=g+1|0;if((!h?(h=((k>>>0)%3|0|0)==0?g+-2|0:k,(h|0)!=-1):0)?(k=f[(f[d+12>>2]|0)+(h<<2)>>2]|0,h=k+1|0,(k|0)!=-1):0){g=((h>>>0)%3|0|0)==0?k+-2|0:h;f[e>>2]=g;if((g|0)!=-1){if((g|0)!=(f[a+4>>2]|0))return;f[e>>2]=-1;return}}else f[e>>2]=-1;g=f[a+4>>2]|0;do if(((g|0)!=-1?(a=(((g>>>0)%3|0|0)==0?2:-1)+g|0,(a|0)!=-1):0)?(h=f[(f[d+12>>2]|0)+(a<<2)>>2]|0,(h|0)!=-1):0)if(!((h>>>0)%3|0)){l=h+2|0;break}else{l=h+-1|0;break}else l=-1;while(0);f[e>>2]=l;b[c>>0]=0;return}function Ih(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Td(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+20>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Td(a,e);return}function Jh(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=f[a+4>>2]|0;if(!d){e=0;return e|0}a=b[c+11>>0]|0;g=a<<24>>24<0;h=g?f[c+4>>2]|0:a&255;a=g?f[c>>2]|0:c;c=d;while(1){d=c+16|0;g=b[d+11>>0]|0;i=g<<24>>24<0;j=i?f[c+20>>2]|0:g&255;g=j>>>0>>0;k=g?j:h;if((k|0)!=0?(l=Vk(a,i?f[d>>2]|0:d,k)|0,(l|0)!=0):0)if((l|0)<0)m=7;else m=8;else if(h>>>0>>0)m=7;else m=8;if((m|0)==7){m=0;n=c}else if((m|0)==8){m=0;l=h>>>0>>0?h:j;if((l|0)!=0?(j=Vk(i?f[d>>2]|0:d,a,l)|0,(j|0)!=0):0){if((j|0)>=0){e=1;m=14;break}}else m=10;if((m|0)==10?(m=0,!g):0){e=1;m=14;break}n=c+4|0}c=f[n>>2]|0;if(!c){e=0;m=14;break}}if((m|0)==14)return e|0;return 0}function Kh(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=u;u=u+16|0;g=e+4|0;h=e;i=f[a+8>>2]|0;j=i+24|0;k=b[j>>0]|0;l=c+4|0;ag(a,(f[l>>2]|0)-(f[c>>2]|0)>>2,k,d);d=f[a+32>>2]|0;a=(f[f[d>>2]>>2]|0)+(f[d+48>>2]|0)|0;d=f[c>>2]|0;c=f[l>>2]|0;if((d|0)==(c|0)){m=1;u=e;return m|0}l=i+84|0;n=i+68|0;o=0;p=d;while(1){d=f[p>>2]|0;if(!(b[l>>0]|0))q=f[(f[n>>2]|0)+(d<<2)>>2]|0;else q=d;f[h>>2]=q;d=b[j>>0]|0;f[g>>2]=f[h>>2];if(!(Qb(i,g,d,a+(o<<2)|0)|0)){m=0;r=7;break}p=p+4|0;if((p|0)==(c|0)){m=1;r=7;break}else o=o+k|0}if((r|0)==7){u=e;return m|0}return 0}function Lh(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;f[a>>2]=1408;b=a+72|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);c=f[a+60>>2]|0;if(c|0){b=a+64|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=f[a+48>>2]|0;if(c|0)Oq(c);c=a+36|0;d=f[c>>2]|0;if(d|0){b=a+40|0;e=f[b>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-4|0;f[b>>2]=e;i=f[e>>2]|0;f[e>>2]=0;if(i|0)Va[f[(f[i>>2]|0)+4>>2]&127](i);h=f[b>>2]|0}while((h|0)!=(d|0));g=f[c>>2]|0}Oq(g)}f[a>>2]=1232;g=f[a+16>>2]|0;if(g|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(g|0))f[c>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);Oq(g);return}function Mh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f[a>>2]=d;e=a+24|0;g=a+28|0;h=f[g>>2]|0;i=f[e>>2]|0;j=h-i>>2;k=i;i=h;if(j>>>0>=d>>>0){if(j>>>0>d>>>0?(h=k+(d<<2)|0,(h|0)!=(i|0)):0)f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2)}else Ci(e,d-j|0);if(!c)return;j=f[b>>2]|0;if((c|0)>1){d=j;e=j;h=1;while(1){i=f[b+(h<<2)>>2]|0;g=(i|0)<(e|0);k=g?i:e;l=g?d:(i|0)>(d|0)?i:d;h=h+1|0;if((h|0)==(c|0)){m=l;n=k;break}else{d=l;e=k}}}else{m=j;n=j}f[a+4>>2]=n;f[a+8>>2]=m;j=Xn(m|0,((m|0)<0)<<31>>31|0,n|0,((n|0)<0)<<31>>31|0)|0;n=I;if(!(n>>>0<0|(n|0)==0&j>>>0<2147483647))return;n=j+1|0;f[a+12>>2]=n;j=(n|0)/2|0;m=a+16|0;f[m>>2]=j;f[a+20>>2]=0-j;if(n&1|0)return;f[m>>2]=j+-1;return}function Nh(a){a=a|0;Fj(a+992|0);Fj(a+960|0);Fj(a+928|0);Fj(a+896|0);Fj(a+864|0);Fj(a+832|0);Fj(a+800|0);Fj(a+768|0);Fj(a+736|0);Fj(a+704|0);Fj(a+672|0);Fj(a+640|0);Fj(a+608|0);Fj(a+576|0);Fj(a+544|0);Fj(a+512|0);Fj(a+480|0);Fj(a+448|0);Fj(a+416|0);Fj(a+384|0);Fj(a+352|0);Fj(a+320|0);Fj(a+288|0);Fj(a+256|0);Fj(a+224|0);Fj(a+192|0);Fj(a+160|0);Fj(a+128|0);Fj(a+96|0);Fj(a+64|0);Fj(a+32|0);Fj(a);return}function Oh(a){a=a|0;wn(a);wn(a+32|0);wn(a+64|0);wn(a+96|0);wn(a+128|0);wn(a+160|0);wn(a+192|0);wn(a+224|0);wn(a+256|0);wn(a+288|0);wn(a+320|0);wn(a+352|0);wn(a+384|0);wn(a+416|0);wn(a+448|0);wn(a+480|0);wn(a+512|0);wn(a+544|0);wn(a+576|0);wn(a+608|0);wn(a+640|0);wn(a+672|0);wn(a+704|0);wn(a+736|0);wn(a+768|0);wn(a+800|0);wn(a+832|0);wn(a+864|0);wn(a+896|0);wn(a+928|0);wn(a+960|0);wn(a+992|0);return}function Ph(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=u;u=u+16|0;d=c+12|0;e=c+8|0;g=c+4|0;h=c;i=(a|0)==(b|0);if(!i){f[g>>2]=f[b>>2];f[h>>2]=b+4;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Oc(a,e,d)}if(!i){f[g>>2]=f[b+12>>2];f[h>>2]=b+16;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Hc(a+12|0,e,d)}if(i){u=c;return}f[g>>2]=f[b+24>>2];f[h>>2]=b+28;f[e>>2]=f[g>>2];f[d>>2]=f[h>>2];Oc(a+24|0,e,d);u=c;return}function Qh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+16|0;e=a;if((c|0)<0|((b|0)==0|(d|0)==0)){g=0;u=a;return g|0}h=f[b+8>>2]|0;if(((f[b+12>>2]|0)-h>>2|0)<=(c|0)){g=0;u=a;return g|0}i=b+4|0;if(!(f[i>>2]|0)){j=ln(52)|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;n[j+16>>2]=$(1.0);k=j+20|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;n[j+36>>2]=$(1.0);f[j+40>>2]=0;f[j+44>>2]=0;f[j+48>>2]=0;f[b+4>>2]=j}j=f[(f[h+(c<<2)>>2]|0)+60>>2]|0;c=ln(44)|0;Ub(c,d);f[c+40>>2]=j;j=f[i>>2]|0;f[e>>2]=c;mk(j,e)|0;j=f[e>>2]|0;f[e>>2]=0;if(!j){g=1;u=a;return g|0}bj(j);Oq(j);g=1;u=a;return g|0}function Rh(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0;c=u;u=u+64|0;j=c;k=i?6:5;Il(j);i=f[h+56>>2]|0;h=X(Vl(k)|0,e)|0;Jj(j,i,0,e&255,k,0,h,((h|0)<0)<<31>>31,0,0);h=ln(96)|0;tl(h,j);f[a>>2]=h;Bj(h,d)|0;d=h+84|0;if(!g){b[d>>0]=1;a=f[h+68>>2]|0;j=h+72|0;k=f[j>>2]|0;if((k|0)==(a|0)){u=c;return}f[j>>2]=k+(~((k+-4-a|0)>>>2)<<2);u=c;return}b[d>>0]=0;d=h+68|0;a=h+72|0;h=f[a>>2]|0;k=f[d>>2]|0;j=h-k>>2;e=h;if(j>>>0>>0){Ch(d,g-j|0,1216);u=c;return}if(j>>>0<=g>>>0){u=c;return}j=k+(g<<2)|0;if((j|0)==(e|0)){u=c;return}f[a>>2]=e+(~((e+-4-j|0)>>>2)<<2);u=c;return}function Sh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){rd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;rd(a,e);return}function Th(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){vd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;vd(a,e);return}function Uh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Fd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Fd(a,e);return}function Vh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Pd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Pd(a,e);return}function Wh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){ud(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;ud(a,e);return}function Xh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){zd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;zd(a,e);return}function Yh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Jd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Jd(a,e);return}function Zh(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){sd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;sd(a,e);return}function _h(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){wd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;wd(a,e);return}function $h(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Gd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Gd(a,e);return}function ai(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Qd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Qd(a,e);return}function bi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=u;u=u+16|0;h=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=ln(16)|0;f[h>>2]=i;f[h+8>>2]=-2147483632;f[h+4>>2]=15;j=i;k=14479;l=j+15|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+15>>0]=0;i=Hk(c,h,-1)|0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);switch(i|0){case -1:{if((mi(c)|0)==10)m=6;else m=5;break}case 1:{m=5;break}default:m=6}if((m|0)==5){i=ln(60)|0;Lo(i);n=i}else if((m|0)==6){m=ln(56)|0;tp(m);n=m}xo(n,d);Md(a,n,c,e);Va[f[(f[n>>2]|0)+4>>2]&127](n);u=g;return}function ci(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;b[h>>0]=a&127;do if(a>>>0>127){b[h>>0]=a|128;i=c+16|0;j=f[i+4>>2]|0;if((j|0)>0|(j|0)==0&(f[i>>2]|0)>>>0>0){k=0;break}else{f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;k=ci(a>>>7,c)|0;break}}else{i=c+16|0;j=f[i+4>>2]|0;if((j|0)>0|(j|0)==0&(f[i>>2]|0)>>>0>0){k=0;break}f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0;l=1;u=d;return l|0}while(0);l=k;u=d;return l|0} +function vc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;e=u;u=u+32|0;g=e+16|0;h=e+12|0;i=e+8|0;j=e+4|0;k=e;switch(f[c+28>>2]|0){case 9:{l=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=l;f[g>>2]=f[h>>2];m=hc(a,c,g)|0;break}case 2:{f[i>>2]=l;f[g>>2]=f[i>>2];m=Wb(a,c,g)|0;break}case 3:{f[j>>2]=l;f[g>>2]=f[j>>2];m=uc(a,c,g)|0;break}case 4:{f[k>>2]=l;f[g>>2]=f[k>>2];m=mc(a,c,g)|0;break}default:m=0}n=m;break}case 1:{m=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=m;f[g>>2]=f[h>>2];o=gc(a,c,g)|0;break}case 2:{f[i>>2]=m;f[g>>2]=f[i>>2];o=Xb(a,c,g)|0;break}case 3:{f[j>>2]=m;f[g>>2]=f[j>>2];o=sc(a,c,g)|0;break}case 4:{f[k>>2]=m;f[g>>2]=f[k>>2];o=lc(a,c,g)|0;break}default:o=0}n=o;break}case 11:case 2:{o=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=o;f[g>>2]=f[h>>2];p=gc(a,c,g)|0;break}case 2:{f[i>>2]=o;f[g>>2]=f[i>>2];p=Xb(a,c,g)|0;break}case 3:{f[j>>2]=o;f[g>>2]=f[j>>2];p=sc(a,c,g)|0;break}case 4:{f[k>>2]=o;f[g>>2]=f[k>>2];p=lc(a,c,g)|0;break}default:p=0}n=p;break}case 4:{p=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=p;f[g>>2]=f[h>>2];q=ec(a,c,g)|0;break}case 2:{f[i>>2]=p;f[g>>2]=f[i>>2];q=Vb(a,c,g)|0;break}case 3:{f[j>>2]=p;f[g>>2]=f[j>>2];q=nc(a,c,g)|0;break}case 4:{f[k>>2]=p;f[g>>2]=f[k>>2];q=jc(a,c,g)|0;break}default:q=0}n=q;break}case 3:{q=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=q;f[g>>2]=f[h>>2];r=ec(a,c,g)|0;break}case 2:{f[i>>2]=q;f[g>>2]=f[i>>2];r=Vb(a,c,g)|0;break}case 3:{f[j>>2]=q;f[g>>2]=f[j>>2];r=nc(a,c,g)|0;break}case 4:{f[k>>2]=q;f[g>>2]=f[k>>2];r=jc(a,c,g)|0;break}default:r=0}n=r;break}case 6:{r=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=r;f[g>>2]=f[h>>2];s=hc(a,c,g)|0;break}case 2:{f[i>>2]=r;f[g>>2]=f[i>>2];s=Wb(a,c,g)|0;break}case 3:{f[j>>2]=r;f[g>>2]=f[j>>2];s=uc(a,c,g)|0;break}case 4:{f[k>>2]=r;f[g>>2]=f[k>>2];s=mc(a,c,g)|0;break}default:s=0}n=s;break}case 5:{s=f[d>>2]|0;switch(b[c+24>>0]|0){case 1:{f[h>>2]=s;f[g>>2]=f[h>>2];t=hc(a,c,g)|0;break}case 2:{f[i>>2]=s;f[g>>2]=f[i>>2];t=Wb(a,c,g)|0;break}case 3:{f[j>>2]=s;f[g>>2]=f[j>>2];t=uc(a,c,g)|0;break}case 4:{f[k>>2]=s;f[g>>2]=f[k>>2];t=mc(a,c,g)|0;break}default:t=0}n=t;break}default:{v=-1;u=e;return v|0}}v=(n|0)==0?-1:n;u=e;return v|0}function wc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;e=u;u=u+32|0;g=e+16|0;h=e+12|0;i=e+29|0;j=e;k=e+28|0;if(!(f[(f[a+8>>2]|0)+80>>2]|0)){l=1;u=e;return l|0}b[i>>0]=-2;m=a+36|0;n=f[m>>2]|0;if(n)if(Ra[f[(f[a>>2]|0)+40>>2]&127](a,n)|0){n=f[m>>2]|0;o=(Qa[f[(f[n>>2]|0)+8>>2]&127](n)|0)&255;b[i>>0]=o;p=5}else q=0;else p=5;if((p|0)==5){o=d+16|0;n=o;r=f[n+4>>2]|0;if(!((r|0)>0|(r|0)==0&(f[n>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,i,i+1|0)|0}i=f[m>>2]|0;if(i|0?(n=(Qa[f[(f[i>>2]|0)+36>>2]&127](i)|0)&255,b[j>>0]=n,n=o,i=f[n+4>>2]|0,!((i|0)>0|(i|0)==0&(f[n>>2]|0)>>>0>0)):0){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,j,j+1|0)|0}n=f[a+32>>2]|0;i=b[n+24>>0]|0;r=X(f[n+80>>2]|0,i)|0;s=(f[f[n>>2]>>2]|0)+(f[n+48>>2]|0)|0;f[j>>2]=0;n=j+4|0;f[n>>2]=0;f[j+8>>2]=0;t=(r|0)==0;do if(!t)if(r>>>0>1073741823)aq(j);else{v=r<<2;w=ln(v)|0;f[j>>2]=w;x=w+(r<<2)|0;f[j+8>>2]=x;sj(w|0,0,v|0)|0;f[n>>2]=x;y=w;break}else y=0;while(0);w=f[m>>2]|0;do if(w){Ta[f[(f[w>>2]|0)+44>>2]&31](w,s,y,r,i,f[c>>2]|0)|0;x=f[m>>2]|0;if(!x){z=s;A=f[j>>2]|0;p=20;break}if(!(Qa[f[(f[x>>2]|0)+32>>2]&127](x)|0)){x=f[j>>2]|0;z=f[m>>2]|0?x:s;A=x;p=20}}else{z=s;A=y;p=20}while(0);if((p|0)==20)xm(z,r,A);A=a+4|0;a=f[A>>2]|0;do if(a){z=f[a+48>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;y=ln(48)|0;f[g>>2]=y;f[g+8>>2]=-2147483600;f[g+4>>2]=34;s=y;w=10697;x=s+34|0;do{b[s>>0]=b[w>>0]|0;s=s+1|0;w=w+1|0}while((s|0)<(x|0));b[y+34>>0]=0;w=Yj(z,g,1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if(!w){if(!t){w=f[j>>2]|0;s=0;x=0;do{x=f[w+(s<<2)>>2]|x;s=s+1|0}while((s|0)!=(r|0));if(x)B=((_(x|0)|0)>>>3^3)+1|0;else B=1}else B=1;b[k>>0]=0;s=o;w=f[s>>2]|0;z=f[s+4>>2]|0;if((z|0)>0|(z|0)==0&w>>>0>0){C=z;D=w}else{f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0;w=o;C=f[w+4>>2]|0;D=f[w>>2]|0}b[k>>0]=B;if(!((C|0)>0|(C|0)==0&D>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0}if((B|0)==(Vl(5)|0)){w=f[j>>2]|0;z=o;s=f[z+4>>2]|0;if(!((s|0)>0|(s|0)==0&(f[z>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,w,w+(r<<2)|0)|0}p=48;break}if(t)p=48;else{w=d+4|0;z=0;do{s=(f[j>>2]|0)+(z<<2)|0;y=o;v=f[y+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[y>>2]|0)>>>0>0)){f[h>>2]=f[w>>2];f[g>>2]=f[h>>2];Me(d,g,s,s+B|0)|0}z=z+1|0}while(z>>>0>>0);p=48}}else p=27}else p=27;while(0);if((p|0)==27){b[k>>0]=1;r=o;o=f[r+4>>2]|0;if(!((o|0)>0|(o|0)==0&(f[r>>2]|0)>>>0>0)){f[h>>2]=f[d+4>>2];f[g>>2]=f[h>>2];Me(d,g,k,k+1|0)|0}lp(g);k=f[A>>2]|0;if(k|0)Zj(g,10-(mi(f[k+48>>2]|0)|0)|0)|0;k=Mc(f[j>>2]|0,X((f[c+4>>2]|0)-(f[c>>2]|0)>>2,i)|0,i,g,d)|0;Ej(g,f[g+4>>2]|0);if(k)p=48;else E=0}if((p|0)==48){p=f[m>>2]|0;if(!p)E=1;else{Ra[f[(f[p>>2]|0)+40>>2]&127](p,d)|0;E=1}}d=f[j>>2]|0;if(d|0){j=f[n>>2]|0;if((j|0)!=(d|0))f[n>>2]=j+(~((j+-4-d|0)>>>2)<<2);Oq(d)}q=E}l=q;u=e;return l|0}function xc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0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m=f[h>>2]|0;q=f[m+(x<<2)>>2]|0;if(r>>>0>=(f[q+8>>2]|0)-(f[q+4>>2]|0)>>2>>>0)break;else o=F}o=m;if(F)H=o;else{I=w;J=y;K=o;break}}else H=z;f[(f[g>>2]|0)+(y<<2)>>2]=x;o=(f[c>>2]|0)+(v<<2)|0;f[o>>2]=f[o>>2]|n;I=1;J=y+1|0;K=H}else{I=w;J=y;K=z}while(0);x=x+1|0;L=f[i>>2]|0;M=L-K>>2;A=K;if(x>>>0>=M>>>0)break;else{w=I;y=J;z=K}}if(J>>>0>>0&(I^1)){N=0;break}else{l=J;j=A;s=K;t=L}}if((B|0)==25){f[d>>2]=0;B=d+4|0;f[B>>2]=0;f[d+8>>2]=0;L=f[a+4>>2]|0;a=(f[L+12>>2]|0)-(f[L+8>>2]|0)|0;L=a>>2;f[e>>2]=0;K=e+4|0;f[K>>2]=0;A=e+8|0;f[A>>2]=0;if(L|0){if((a|0)<0)aq(e);a=((L+-1|0)>>>5)+1|0;J=ln(a<<2)|0;f[e>>2]=J;f[A>>2]=a;f[K>>2]=L;K=L>>>5;sj(J|0,0,K<<2|0)|0;a=L&31;L=J+(K<<2)|0;if(a|0)f[L>>2]=f[L>>2]&~(-1>>>(32-a|0))}a:do if((t|0)==(s|0))O=1;else{a=0;L=j;K=s;J=t;while(1){A=f[(f[g>>2]|0)+(a<<2)>>2]|0;l=f[L+(A<<2)>>2]|0;I=(f[l+8>>2]|0)-(f[l+4>>2]|0)|0;l=I>>2;if((I|0)<8){P=K;Q=J}else{I=f[B>>2]|0;M=f[d>>2]|0;z=I-M>>2;y=M;M=I;if(l>>>0<=z>>>0)if(l>>>0>>0?(I=y+(l<<2)|0,(I|0)!=(M|0)):0){f[B>>2]=M+(~((M+-4-I|0)>>>2)<<2);R=0}else R=0;else{Ci(d,l-z|0);R=0}while(1){if((R|0)<(l|0)){S=0;T=0;U=R}else break;while(1){z=f[(f[h>>2]|0)+(A<<2)>>2]|0;I=f[(f[z+4>>2]|0)+(S<<2)>>2]|0;M=S>>>5;y=1<<(S&31);if(!(f[(f[e>>2]|0)+(M<<2)>>2]&y)){w=0;x=1;H=z;while(1){if((w|0)>=(Ra[f[(f[H>>2]|0)+24>>2]&127](H,I)|0)){V=x;break}z=f[(f[h>>2]|0)+(A<<2)>>2]|0;F=Sa[f[(f[z>>2]|0)+28>>2]&31](z,I,w)|0;z=(f[(f[e>>2]|0)+(F>>>5<<2)>>2]&1<<(F&31)|0)!=0;F=x&z;if(!z){V=F;break}w=w+1|0;x=F;H=f[(f[h>>2]|0)+(A<<2)>>2]|0}if(V){f[(f[d>>2]|0)+(U<<2)>>2]=S;H=(f[e>>2]|0)+(M<<2)|0;f[H>>2]=f[H>>2]|y;W=1;X=U+1|0}else{W=T;X=U}}else{W=T;X=U}S=S+1|0;if((S|0)>=(l|0))break;else{T=W;U=X}}if(W|(X|0)>=(l|0))R=X;else{O=0;break a}}bg(f[(f[h>>2]|0)+(A<<2)>>2]|0,d);P=f[h>>2]|0;Q=f[i>>2]|0}a=a+1|0;if(a>>>0>=Q-P>>2>>>0){O=1;break}else{L=P;K=P;J=Q}}}while(0);Q=f[e>>2]|0;if(Q|0)Oq(Q);Q=f[d>>2]|0;if(Q|0){d=f[B>>2]|0;if((d|0)!=(Q|0))f[B>>2]=d+(~((d+-4-Q|0)>>>2)<<2);Oq(Q)}N=O}O=f[c>>2]|0;if(!O){u=b;return N|0}Oq(O);u=b;return N|0}function yc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!a)return;b=a+-8|0;c=f[4788]|0;d=f[a+-4>>2]|0;a=d&-8;e=b+a|0;do if(!(d&1)){g=f[b>>2]|0;if(!(d&3))return;h=b+(0-g)|0;i=g+a|0;if(h>>>0>>0)return;if((f[4789]|0)==(h|0)){j=e+4|0;k=f[j>>2]|0;if((k&3|0)!=3){l=h;m=i;n=h;break}f[4786]=i;f[j>>2]=k&-2;f[h+4>>2]=i|1;f[h+i>>2]=i;return}k=g>>>3;if(g>>>0<256){g=f[h+8>>2]|0;j=f[h+12>>2]|0;if((j|0)==(g|0)){f[4784]=f[4784]&~(1<>2]=j;f[j+8>>2]=g;l=h;m=i;n=h;break}}g=f[h+24>>2]|0;j=f[h+12>>2]|0;do if((j|0)==(h|0)){k=h+16|0;o=k+4|0;p=f[o>>2]|0;if(!p){q=f[k>>2]|0;if(!q){r=0;break}else{s=q;t=k}}else{s=p;t=o}while(1){o=s+20|0;p=f[o>>2]|0;if(p|0){s=p;t=o;continue}o=s+16|0;p=f[o>>2]|0;if(!p)break;else{s=p;t=o}}f[t>>2]=0;r=s}else{o=f[h+8>>2]|0;f[o+12>>2]=j;f[j+8>>2]=o;r=j}while(0);if(g){j=f[h+28>>2]|0;o=19440+(j<<2)|0;if((f[o>>2]|0)==(h|0)){f[o>>2]=r;if(!r){f[4785]=f[4785]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=r;if(!r){l=h;m=i;n=h;break}}f[r+24>>2]=g;j=h+16|0;o=f[j>>2]|0;if(o|0){f[r+16>>2]=o;f[o+24>>2]=r}o=f[j+4>>2]|0;if(o){f[r+20>>2]=o;f[o+24>>2]=r;l=h;m=i;n=h}else{l=h;m=i;n=h}}else{l=h;m=i;n=h}}else{l=b;m=a;n=b}while(0);if(n>>>0>=e>>>0)return;b=e+4|0;a=f[b>>2]|0;if(!(a&1))return;if(!(a&2)){if((f[4790]|0)==(e|0)){r=(f[4787]|0)+m|0;f[4787]=r;f[4790]=l;f[l+4>>2]=r|1;if((l|0)!=(f[4789]|0))return;f[4789]=0;f[4786]=0;return}if((f[4789]|0)==(e|0)){r=(f[4786]|0)+m|0;f[4786]=r;f[4789]=n;f[l+4>>2]=r|1;f[n+r>>2]=r;return}r=(a&-8)+m|0;s=a>>>3;do if(a>>>0<256){t=f[e+8>>2]|0;c=f[e+12>>2]|0;if((c|0)==(t|0)){f[4784]=f[4784]&~(1<>2]=c;f[c+8>>2]=t;break}}else{t=f[e+24>>2]|0;c=f[e+12>>2]|0;do if((c|0)==(e|0)){d=e+16|0;o=d+4|0;j=f[o>>2]|0;if(!j){p=f[d>>2]|0;if(!p){u=0;break}else{v=p;w=d}}else{v=j;w=o}while(1){o=v+20|0;j=f[o>>2]|0;if(j|0){v=j;w=o;continue}o=v+16|0;j=f[o>>2]|0;if(!j)break;else{v=j;w=o}}f[w>>2]=0;u=v}else{o=f[e+8>>2]|0;f[o+12>>2]=c;f[c+8>>2]=o;u=c}while(0);if(t|0){c=f[e+28>>2]|0;h=19440+(c<<2)|0;if((f[h>>2]|0)==(e|0)){f[h>>2]=u;if(!u){f[4785]=f[4785]&~(1<>2]|0)!=(e|0)&1)<<2)>>2]=u;if(!u)break}f[u+24>>2]=t;c=e+16|0;h=f[c>>2]|0;if(h|0){f[u+16>>2]=h;f[h+24>>2]=u}h=f[c+4>>2]|0;if(h|0){f[u+20>>2]=h;f[h+24>>2]=u}}}while(0);f[l+4>>2]=r|1;f[n+r>>2]=r;if((l|0)==(f[4789]|0)){f[4786]=r;return}else x=r}else{f[b>>2]=a&-2;f[l+4>>2]=m|1;f[n+m>>2]=m;x=m}m=x>>>3;if(x>>>0<256){n=19176+(m<<1<<2)|0;a=f[4784]|0;b=1<>2]|0;z=b}f[z>>2]=l;f[y+12>>2]=l;f[l+8>>2]=y;f[l+12>>2]=n;return}n=x>>>8;if(n)if(x>>>0>16777215)A=31;else{y=(n+1048320|0)>>>16&8;z=n<>>16&4;b=z<>>16&2;a=14-(n|y|z)+(b<>>15)|0;A=x>>>(a+7|0)&1|a<<1}else A=0;a=19440+(A<<2)|0;f[l+28>>2]=A;f[l+20>>2]=0;f[l+16>>2]=0;z=f[4785]|0;b=1<>>1)|0);n=f[a>>2]|0;while(1){if((f[n+4>>2]&-8|0)==(x|0)){B=73;break}C=n+16+(y>>>31<<2)|0;m=f[C>>2]|0;if(!m){B=72;break}else{y=y<<1;n=m}}if((B|0)==72){f[C>>2]=l;f[l+24>>2]=n;f[l+12>>2]=l;f[l+8>>2]=l;break}else if((B|0)==73){y=n+8|0;t=f[y>>2]|0;f[t+12>>2]=l;f[y>>2]=l;f[l+8>>2]=t;f[l+12>>2]=n;f[l+24>>2]=0;break}}else{f[4785]=z|b;f[a>>2]=l;f[l+24>>2]=a;f[l+12>>2]=l;f[l+8>>2]=l}while(0);l=(f[4792]|0)+-1|0;f[4792]=l;if(!l)D=19592;else return;while(1){l=f[D>>2]|0;if(!l)break;else D=l+8|0}f[4792]=-1;return}function zc(a){a=a|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;c=u;u=u+32|0;e=c+4|0;g=c;h=c+16|0;i=a+52|0;j=f[i>>2]|0;k=(f[j+100>>2]|0)-(f[j+96>>2]|0)|0;j=(k|0)/12|0;l=a+44|0;ci(j,f[l>>2]|0)|0;ci(f[(f[i>>2]|0)+80>>2]|0,f[l>>2]|0)|0;m=f[a+48>>2]|0;n=ln(32)|0;f[e>>2]=n;f[e+8>>2]=-2147483616;f[e+4>>2]=21;o=n;p=15598;q=o+21|0;do{b[o>>0]=b[p>>0]|0;o=o+1|0;p=p+1|0}while((o|0)<(q|0));b[n+21>>0]=0;n=Yj(m,e,0)|0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);m=f[l>>2]|0;if(n){b[h>>0]=0;n=m+16|0;p=f[n+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[n>>2]|0)>>>0>0)){f[g>>2]=f[m+4>>2];f[e>>2]=f[g>>2];Me(m,e,h,h+1|0)|0}mf(a)|0;u=c;return 1}b[h>>0]=1;a=m+16|0;n=f[a+4>>2]|0;if(!((n|0)>0|(n|0)==0&(f[a>>2]|0)>>>0>0)){f[g>>2]=f[m+4>>2];f[e>>2]=f[g>>2];Me(m,e,h,h+1|0)|0}m=f[i>>2]|0;a=f[m+80>>2]|0;if(a>>>0<256){if(!k){u=c;return 1}n=h+1|0;p=h+1|0;o=h+1|0;q=0;r=m;while(1){s=f[r+96>>2]|0;t=f[l>>2]|0;b[h>>0]=f[s+(q*12|0)>>2];v=t+16|0;w=f[v>>2]|0;x=f[v+4>>2]|0;if((x|0)>0|(x|0)==0&w>>>0>0){y=w;z=t;A=x}else{f[g>>2]=f[t+4>>2];f[e>>2]=f[g>>2];Me(t,e,h,o)|0;t=f[l>>2]|0;x=t+16|0;y=f[x>>2]|0;z=t;A=f[x+4>>2]|0}b[h>>0]=f[s+(q*12|0)+4>>2];if((A|0)>0|(A|0)==0&y>>>0>0){B=A;C=y;D=z}else{f[g>>2]=f[z+4>>2];f[e>>2]=f[g>>2];Me(z,e,h,p)|0;x=f[l>>2]|0;t=x+16|0;B=f[t+4>>2]|0;C=f[t>>2]|0;D=x}b[h>>0]=f[s+(q*12|0)+8>>2];if(!((B|0)>0|(B|0)==0&C>>>0>0)){f[g>>2]=f[D+4>>2];f[e>>2]=f[g>>2];Me(D,e,h,n)|0}s=q+1|0;if(s>>>0>=j>>>0)break;q=s;r=f[i>>2]|0}u=c;return 1}if(a>>>0<65536){if(!k){u=c;return 1}r=h+2|0;q=h+2|0;n=h+2|0;D=0;C=m;while(1){B=f[C+96>>2]|0;p=f[l>>2]|0;d[h>>1]=f[B+(D*12|0)>>2];z=p+16|0;y=f[z>>2]|0;A=f[z+4>>2]|0;if((A|0)>0|(A|0)==0&y>>>0>0){E=A;F=y;G=p}else{f[g>>2]=f[p+4>>2];f[e>>2]=f[g>>2];Me(p,e,h,n)|0;p=f[l>>2]|0;y=p+16|0;E=f[y+4>>2]|0;F=f[y>>2]|0;G=p}d[h>>1]=f[B+(D*12|0)+4>>2];if((E|0)>0|(E|0)==0&F>>>0>0){H=E;I=F;J=G}else{f[g>>2]=f[G+4>>2];f[e>>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0)==-1)q=-1;else q=f[(f[f[m>>2]>>2]|0)+(p<<2)>>2]|0;if((c|0)==-1){r=-1;s=q}else{r=f[(f[f[m>>2]>>2]|0)+(c<<2)>>2]|0;s=q}}else{r=-1;s=-1}q=f[a+32>>2]|0;c=f[q>>2]|0;m=(f[q+4>>2]|0)-c>>2;if(m>>>0<=s>>>0)aq(q);p=c;c=f[p+(s<<2)>>2]|0;if(m>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(c|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)t=c;else{if((e|0)>0){t=e+-1|0;break}p=a+52|0;if((f[p>>2]|0)<=0){u=g;return}m=f[a+48>>2]|0;s=0;do{f[m+(s<<2)>>2]=0;s=s+1|0}while((s|0)<(f[p>>2]|0));u=g;return}while(0);r=a+52|0;p=f[r>>2]|0;s=X(p,t)|0;if((p|0)<=0){u=g;return}p=f[a+48>>2]|0;t=0;do{f[p+(t<<2)>>2]=f[d+(t+s<<2)>>2];t=t+1|0}while((t|0)<(f[r>>2]|0));u=g;return}r=a+52|0;t=f[r>>2]|0;s=X(t,c)|0;v=$(f[d+(s<<2)>>2]|0);w=$(f[d+(s+1<<2)>>2]|0);s=X(t,q)|0;x=$(f[d+(s<<2)>>2]|0);y=$(f[d+(s+1<<2)>>2]|0);if(!(x!=v|y!=w)){s=f[a+48>>2]|0;f[s>>2]=~~x;f[s+4>>2]=~~y;u=g;return}s=a+44|0;t=f[(f[s>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;p=a+40|0;m=f[p>>2]|0;if(!(b[m+84>>0]|0))z=f[(f[m+68>>2]|0)+(t<<2)>>2]|0;else z=t;f[i>>2]=z;z=b[m+24>>0]|0;f[h>>2]=f[i>>2];mb(m,h,z,j)|0;z=f[(f[s>>2]|0)+(c<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;c=f[p>>2]|0;if(!(b[c+84>>0]|0))A=f[(f[c+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[c+24>>0]|0;f[h>>2]=f[i>>2];mb(c,h,A,k)|0;A=f[(f[s>>2]|0)+(q<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;q=f[p>>2]|0;if(!(b[q+84>>0]|0))B=f[(f[q+68>>2]|0)+(A<<2)>>2]|0;else B=A;f[i>>2]=B;B=b[q+24>>0]|0;f[h>>2]=f[i>>2];mb(q,h,B,l)|0;C=$(n[l>>2]);D=$(n[k>>2]);E=$(C-D);C=$(n[l+4>>2]);F=$(n[k+4>>2]);G=$(C-F);C=$(n[l+8>>2]);H=$(n[k+8>>2]);I=$(C-H);C=$($(n[j>>2])-D);D=$($(n[j+4>>2])-F);F=$($(n[j+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$($(H*N)+v);v=$(H*O);H=$($(x*N)+w);w=$(x*O);O=$(y-w);x=$(H+v);N=$(y+w);w=$(H-v);j=X(f[r>>2]|0,e)|0;v=$(f[d+(j<<2)>>2]|0);H=$(f[d+(j+1<<2)>>2]|0);y=$(v-O);M=$(H-x);E=$(v-N);v=$(H-w);j=$($($(y*y)+$(0.0))+$(M*M))<$($($(E*E)+$(0.0))+$(v*v));d=a+56|0;e=a+60|0;r=f[e>>2]|0;k=f[a+64>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;B=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?B:j):2147483647);P=f[e>>2]|0;break}else P=r;while(0);f[e>>2]=P+1;j=(f[d>>2]|0)+(P>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(P&31);Q=O;R=x}else{do if(l)if((r+1|0)<0)aq(d);else{P=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(P>>>0>>0?j:P):2147483647);S=f[e>>2]|0;break}else S=r;while(0);f[e>>2]=S+1;e=(f[d>>2]|0)+(S>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(S&31));Q=N;R=w}S=~~+J(+(+Q+.5));e=f[a+48>>2]|0;f[e>>2]=S;S=~~+J(+(+R+.5));f[e+4>>2]=S;u=g;return}function Bc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Oa,v=Oa,w=Oa,x=Oa,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=0,P=Oa,Q=Oa,R=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+28|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=o+2|0;r=p;break}else{q=o+-1|0;r=p;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(r<<2)>>2]|0;r=f[o+(q<<2)>>2]|0;q=f[a+32>>2]|0;o=f[q>>2]|0;c=(f[q+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)aq(q);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(o|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)s=o;else{if((e|0)>0){s=e+-1|0;break}p=a+52|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+48>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}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j+8>>2])-G);G=$($($($(D*D)+$(0.0))+$(F*F))+$(H*H));if(G>$(0.0)){I=$($($($($(D*B)+$(0.0))+$(F*C))+$(H*E))/G);K=$(B-$(D*I));D=$(C-$(F*I));F=$(E-$(H*I));M=I;N=$(L($($($(F*F)+$($(D*D)+$($(K*K)+$(0.0))))/G)))}else{M=$(0.0);N=$(0.0)}G=$(w-t);w=$(x-v);x=$($(G*M)+t);t=$(G*N);G=$($(w*M)+v);v=$(w*N);N=$(x-v);w=$(G+t);M=$(x+v);v=$(G-t);j=X(f[r>>2]|0,e)|0;t=$(f[d+(j<<2)>>2]|0);G=$(f[d+(j+1<<2)>>2]|0);x=$(t-N);K=$(G-w);D=$(t-M);t=$(G-v);j=$($($(x*x)+$(0.0))+$(K*K))<$($($(D*D)+$(0.0))+$(t*t));d=a+56|0;e=a+60|0;r=f[e>>2]|0;k=f[a+64>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;A=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?A:j):2147483647);O=f[e>>2]|0;break}else O=r;while(0);f[e>>2]=O+1;j=(f[d>>2]|0)+(O>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(O&31);P=N;Q=w}else{do if(l)if((r+1|0)<0)aq(d);else{O=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(O>>>0>>0?j:O):2147483647);R=f[e>>2]|0;break}else R=r;while(0);f[e>>2]=R+1;e=(f[d>>2]|0)+(R>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(R&31));P=M;Q=v}R=~~+J(+(+P+.5));e=f[a+48>>2]|0;f[e>>2]=R;R=~~+J(+(+Q+.5));f[e+4>>2]=R;u=g;return}function Cc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=Oa,w=Oa,x=Oa,y=Oa,z=0,A=0,B=0,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=Oa,P=0,Q=Oa,R=Oa,S=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;c=o+(((o>>>0)%3|0|0)==0?2:-1)|0;if((p|0)==-1)q=-1;else q=f[(f[f[m>>2]>>2]|0)+(p<<2)>>2]|0;if((c|0)==-1){r=-1;s=q}else{r=f[(f[f[m>>2]>>2]|0)+(c<<2)>>2]|0;s=q}}else{r=-1;s=-1}q=f[a+52>>2]|0;c=f[q>>2]|0;m=(f[q+4>>2]|0)-c>>2;if(m>>>0<=s>>>0)aq(q);p=c;c=f[p+(s<<2)>>2]|0;if(m>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(c|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)t=c;else{if((e|0)>0){t=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}m=f[a+68>>2]|0;s=0;do{f[m+(s<<2)>>2]=0;s=s+1|0}while((s|0)<(f[p>>2]|0));u=g;return}while(0);r=a+72|0;p=f[r>>2]|0;s=X(p,t)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;t=0;do{f[p+(t<<2)>>2]=f[d+(t+s<<2)>>2];t=t+1|0}while((t|0)<(f[r>>2]|0));u=g;return}r=a+72|0;t=f[r>>2]|0;s=X(t,c)|0;v=$(f[d+(s<<2)>>2]|0);w=$(f[d+(s+1<<2)>>2]|0);s=X(t,q)|0;x=$(f[d+(s<<2)>>2]|0);y=$(f[d+(s+1<<2)>>2]|0);if(!(x!=v|y!=w)){s=f[a+68>>2]|0;f[s>>2]=~~x;f[s+4>>2]=~~y;u=g;return}s=a+64|0;t=f[(f[s>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;p=a+60|0;m=f[p>>2]|0;if(!(b[m+84>>0]|0))z=f[(f[m+68>>2]|0)+(t<<2)>>2]|0;else z=t;f[i>>2]=z;z=b[m+24>>0]|0;f[h>>2]=f[i>>2];mb(m,h,z,j)|0;z=f[(f[s>>2]|0)+(c<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;c=f[p>>2]|0;if(!(b[c+84>>0]|0))A=f[(f[c+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[c+24>>0]|0;f[h>>2]=f[i>>2];mb(c,h,A,k)|0;A=f[(f[s>>2]|0)+(q<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;q=f[p>>2]|0;if(!(b[q+84>>0]|0))B=f[(f[q+68>>2]|0)+(A<<2)>>2]|0;else B=A;f[i>>2]=B;B=b[q+24>>0]|0;f[h>>2]=f[i>>2];mb(q,h,B,l)|0;C=$(n[l>>2]);D=$(n[k>>2]);E=$(C-D);C=$(n[l+4>>2]);F=$(n[k+4>>2]);G=$(C-F);C=$(n[l+8>>2]);H=$(n[k+8>>2]);I=$(C-H);C=$($(n[j>>2])-D);D=$($(n[j+4>>2])-F);F=$($(n[j+8>>2])-H);H=$($($($(E*E)+$(0.0))+$(G*G))+$(I*I));if(H>$(0.0)){K=$($($($($(E*C)+$(0.0))+$(G*D))+$(I*F))/H);M=$(C-$(E*K));E=$(D-$(G*K));G=$(F-$(I*K));N=K;O=$(L($($($(G*G)+$($(E*E)+$($(M*M)+$(0.0))))/H)))}else{N=$(0.0);O=$(0.0)}H=$(x-v);x=$(y-w);y=$($(H*N)+v);v=$(H*O);H=$($(x*N)+w);w=$(x*O);O=$(y-w);x=$(H+v);N=$(y+w);w=$(H-v);j=X(f[r>>2]|0,e)|0;v=$(f[d+(j<<2)>>2]|0);H=$(f[d+(j+1<<2)>>2]|0);y=$(v-O);M=$(H-x);E=$(v-N);v=$(H-w);j=$($($(y*y)+$(0.0))+$(M*M))<$($($(E*E)+$(0.0))+$(v*v));d=a+76|0;e=a+80|0;r=f[e>>2]|0;k=f[a+84>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;B=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?B:j):2147483647);P=f[e>>2]|0;break}else P=r;while(0);f[e>>2]=P+1;j=(f[d>>2]|0)+(P>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(P&31);Q=O;R=x}else{do if(l)if((r+1|0)<0)aq(d);else{P=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(P>>>0>>0?j:P):2147483647);S=f[e>>2]|0;break}else S=r;while(0);f[e>>2]=S+1;e=(f[d>>2]|0)+(S>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(S&31));Q=N;R=w}S=~~+J(+(+Q+.5));e=f[a+68>>2]|0;f[e>>2]=S;S=~~+J(+(+R+.5));f[e+4>>2]=S;u=g;return}function Dc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=Oa,v=Oa,w=Oa,x=Oa,y=0,z=0,A=0,B=Oa,C=Oa,D=Oa,E=Oa,F=Oa,G=Oa,H=Oa,I=Oa,K=Oa,M=Oa,N=Oa,O=0,P=Oa,Q=Oa,R=0;g=u;u=u+48|0;h=g+40|0;i=g+36|0;j=g+24|0;k=g+12|0;l=g;m=a+48|0;o=f[c>>2]|0;c=o+1|0;do if((o|0)!=-1){p=((c>>>0)%3|0|0)==0?o+-2|0:c;if(!((o>>>0)%3|0)){q=o+2|0;r=p;break}else{q=o+-1|0;r=p;break}}else{q=-1;r=-1}while(0);o=f[(f[m>>2]|0)+28>>2]|0;m=f[o+(r<<2)>>2]|0;r=f[o+(q<<2)>>2]|0;q=f[a+52>>2]|0;o=f[q>>2]|0;c=(f[q+4>>2]|0)-o>>2;if(c>>>0<=m>>>0)aq(q);p=o;o=f[p+(m<<2)>>2]|0;if(c>>>0<=r>>>0)aq(q);q=f[p+(r<<2)>>2]|0;r=(o|0)<(e|0);if(!(r&(q|0)<(e|0))){do if(r)s=o;else{if((e|0)>0){s=e+-1|0;break}p=a+72|0;if((f[p>>2]|0)<=0){u=g;return}c=f[a+68>>2]|0;m=0;do{f[c+(m<<2)>>2]=0;m=m+1|0}while((m|0)<(f[p>>2]|0));u=g;return}while(0);r=a+72|0;p=f[r>>2]|0;m=X(p,s)|0;if((p|0)<=0){u=g;return}p=f[a+68>>2]|0;s=0;do{f[p+(s<<2)>>2]=f[d+(s+m<<2)>>2];s=s+1|0}while((s|0)<(f[r>>2]|0));u=g;return}r=a+72|0;s=f[r>>2]|0;m=X(s,o)|0;t=$(f[d+(m<<2)>>2]|0);v=$(f[d+(m+1<<2)>>2]|0);m=X(s,q)|0;w=$(f[d+(m<<2)>>2]|0);x=$(f[d+(m+1<<2)>>2]|0);if(!(w!=t|x!=v)){m=f[a+68>>2]|0;f[m>>2]=~~w;f[m+4>>2]=~~x;u=g;return}m=a+64|0;s=f[(f[m>>2]|0)+(e<<2)>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;p=a+60|0;c=f[p>>2]|0;if(!(b[c+84>>0]|0))y=f[(f[c+68>>2]|0)+(s<<2)>>2]|0;else y=s;f[i>>2]=y;y=b[c+24>>0]|0;f[h>>2]=f[i>>2];mb(c,h,y,j)|0;y=f[(f[m>>2]|0)+(o<<2)>>2]|0;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;o=f[p>>2]|0;if(!(b[o+84>>0]|0))z=f[(f[o+68>>2]|0)+(y<<2)>>2]|0;else z=y;f[i>>2]=z;z=b[o+24>>0]|0;f[h>>2]=f[i>>2];mb(o,h,z,k)|0;z=f[(f[m>>2]|0)+(q<<2)>>2]|0;f[l>>2]=0;f[l+4>>2]=0;f[l+8>>2]=0;q=f[p>>2]|0;if(!(b[q+84>>0]|0))A=f[(f[q+68>>2]|0)+(z<<2)>>2]|0;else A=z;f[i>>2]=A;A=b[q+24>>0]|0;f[h>>2]=f[i>>2];mb(q,h,A,l)|0;B=$(n[l>>2]);C=$(n[k>>2]);D=$(B-C);B=$(n[l+4>>2]);E=$(n[k+4>>2]);F=$(B-E);B=$(n[l+8>>2]);G=$(n[k+8>>2]);H=$(B-G);B=$($(n[j>>2])-C);C=$($(n[j+4>>2])-E);E=$($(n[j+8>>2])-G);G=$($($($(D*D)+$(0.0))+$(F*F))+$(H*H));if(G>$(0.0)){I=$($($($($(D*B)+$(0.0))+$(F*C))+$(H*E))/G);K=$(B-$(D*I));D=$(C-$(F*I));F=$(E-$(H*I));M=I;N=$(L($($($(F*F)+$($(D*D)+$($(K*K)+$(0.0))))/G)))}else{M=$(0.0);N=$(0.0)}G=$(w-t);w=$(x-v);x=$($(G*M)+t);t=$(G*N);G=$($(w*M)+v);v=$(w*N);N=$(x-v);w=$(G+t);M=$(x+v);v=$(G-t);j=X(f[r>>2]|0,e)|0;t=$(f[d+(j<<2)>>2]|0);G=$(f[d+(j+1<<2)>>2]|0);x=$(t-N);K=$(G-w);D=$(t-M);t=$(G-v);j=$($($(x*x)+$(0.0))+$(K*K))<$($($(D*D)+$(0.0))+$(t*t));d=a+76|0;e=a+80|0;r=f[e>>2]|0;k=f[a+84>>2]|0;l=(r|0)==(k<<5|0);if(j){do if(l)if((r+1|0)<0)aq(d);else{j=k<<6;A=r+32&-32;vi(d,r>>>0<1073741823?(j>>>0>>0?A:j):2147483647);O=f[e>>2]|0;break}else O=r;while(0);f[e>>2]=O+1;j=(f[d>>2]|0)+(O>>>5<<2)|0;f[j>>2]=f[j>>2]|1<<(O&31);P=N;Q=w}else{do if(l)if((r+1|0)<0)aq(d);else{O=k<<6;j=r+32&-32;vi(d,r>>>0<1073741823?(O>>>0>>0?j:O):2147483647);R=f[e>>2]|0;break}else R=r;while(0);f[e>>2]=R+1;e=(f[d>>2]|0)+(R>>>5<<2)|0;f[e>>2]=f[e>>2]&~(1<<(R&31));P=M;Q=v}R=~~+J(+(+P+.5));e=f[a+68>>2]|0;f[e>>2]=R;R=~~+J(+(+Q+.5));f[e+4>>2]=R;u=g;return}function Ec(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=Oa,F=Oa,G=Oa,H=0,I=0,J=0,K=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;e=i;j=i;while(1){k=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;e=(X(k>>>24^k,1540483477)|0)^(X(e,1540483477)|0);j=j+-4|0;if(j>>>0<=3)break;else d=d+4|0}d=i+-4|0;j=d&-4;l=d-j|0;m=g+(j+4)|0;o=e}else{l=i;m=g;o=i}switch(l|0){case 3:{p=h[m+2>>0]<<16^o;q=6;break}case 2:{p=o;q=6;break}case 1:{r=o;q=7;break}default:s=o}if((q|0)==6){r=h[m+1>>0]<<8^p;q=7}if((q|0)==7)s=X(r^h[m>>0],1540483477)|0;m=X(s>>>13^s,1540483477)|0;s=m>>>15^m;m=a+4|0;r=f[m>>2]|0;p=(r|0)==0;a:do if(!p){o=r+-1|0;l=(o&r|0)==0;if(!l)if(s>>>0>>0)t=s;else t=(s>>>0)%(r>>>0)|0;else t=s&o;e=f[(f[a>>2]|0)+(t<<2)>>2]|0;if((e|0)!=0?(j=f[e>>2]|0,(j|0)!=0):0){e=(i|0)==0;if(l){if(e){l=j;while(1){d=f[l+4>>2]|0;if(!((d|0)==(s|0)|(d&o|0)==(t|0))){u=t;break a}d=b[l+8+11>>0]|0;if(!((d<<24>>24<0?f[l+12>>2]|0:d&255)|0)){v=l;break}l=f[l>>2]|0;if(!l){u=t;break a}}w=v+20|0;return w|0}else x=j;b:while(1){l=f[x+4>>2]|0;if(!((l|0)==(s|0)|(l&o|0)==(t|0))){u=t;break a}l=x+8|0;d=b[l+11>>0]|0;k=d<<24>>24<0;y=d&255;do if(((k?f[x+12>>2]|0:y)|0)==(i|0)){d=f[l>>2]|0;if(k)if(!(Vk(d,g,i)|0)){v=x;q=63;break b}else break;if((b[g>>0]|0)==(d&255)<<24>>24){d=l;z=y;A=g;do{z=z+-1|0;d=d+1|0;if(!z){v=x;q=63;break b}A=A+1|0}while((b[d>>0]|0)==(b[A>>0]|0))}}while(0);x=f[x>>2]|0;if(!x){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}if(e){o=j;while(1){y=f[o+4>>2]|0;if((y|0)!=(s|0)){if(y>>>0>>0)B=y;else B=(y>>>0)%(r>>>0)|0;if((B|0)!=(t|0)){u=t;break a}}y=b[o+8+11>>0]|0;if(!((y<<24>>24<0?f[o+12>>2]|0:y&255)|0)){v=o;break}o=f[o>>2]|0;if(!o){u=t;break a}}w=v+20|0;return w|0}else C=j;c:while(1){o=f[C+4>>2]|0;if((o|0)!=(s|0)){if(o>>>0>>0)D=o;else D=(o>>>0)%(r>>>0)|0;if((D|0)!=(t|0)){u=t;break a}}o=C+8|0;e=b[o+11>>0]|0;y=e<<24>>24<0;l=e&255;do if(((y?f[C+12>>2]|0:l)|0)==(i|0)){e=f[o>>2]|0;if(y)if(!(Vk(e,g,i)|0)){v=C;q=63;break c}else break;if((b[g>>0]|0)==(e&255)<<24>>24){e=o;k=l;A=g;do{k=k+-1|0;e=e+1|0;if(!k){v=C;q=63;break c}A=A+1|0}while((b[e>>0]|0)==(b[A>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){u=t;break a}}if((q|0)==63){w=v+20|0;return w|0}}else u=t}else u=0;while(0);t=ln(24)|0;pj(t+8|0,c);f[t+20>>2]=0;f[t+4>>2]=s;f[t>>2]=0;c=a+12|0;E=$(((f[c>>2]|0)+1|0)>>>0);F=$(r>>>0);G=$(n[a+16>>2]);do if(p|$(G*F)>>0<3|(r+-1&r|0)!=0)&1;g=~~$(W($(E/G)))>>>0;ei(a,C>>>0>>0?g:C);C=f[m>>2]|0;g=C+-1|0;if(!(g&C)){H=C;I=g&s;break}if(s>>>0>>0){H=C;I=s}else{H=C;I=(s>>>0)%(C>>>0)|0}}else{H=r;I=u}while(0);u=(f[a>>2]|0)+(I<<2)|0;I=f[u>>2]|0;if(!I){r=a+8|0;f[t>>2]=f[r>>2];f[r>>2]=t;f[u>>2]=r;r=f[t>>2]|0;if(r|0){u=f[r+4>>2]|0;r=H+-1|0;if(r&H)if(u>>>0>>0)J=u;else J=(u>>>0)%(H>>>0)|0;else J=u&r;K=(f[a>>2]|0)+(J<<2)|0;q=61}}else{f[t>>2]=f[I>>2];K=I;q=61}if((q|0)==61)f[K>>2]=t;f[c>>2]=(f[c>>2]|0)+1;v=t;w=v+20|0;return w|0}function Fc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0.0,H=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0.0,R=0.0,S=0,T=0.0,U=0,V=0,W=0,X=0.0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0.0,da=0,ea=0.0;g=a+4|0;i=f[g>>2]|0;j=a+100|0;if(i>>>0<(f[j>>2]|0)>>>0){f[g>>2]=i+1;k=h[i>>0]|0;l=0}else{k=Si(a)|0;l=0}a:while(1){switch(k|0){case 46:{m=8;break a;break}case 48:break;default:{n=0;o=0;p=1.0;q=0.0;r=0;s=k;t=l;u=0;v=0;w=0;x=0;break a}}i=f[g>>2]|0;if(i>>>0<(f[j>>2]|0)>>>0){f[g>>2]=i+1;k=h[i>>0]|0;l=1;continue}else{k=Si(a)|0;l=1;continue}}if((m|0)==8){k=f[g>>2]|0;if(k>>>0<(f[j>>2]|0)>>>0){f[g>>2]=k+1;y=h[k>>0]|0}else y=Si(a)|0;if((y|0)==48){k=0;i=0;while(1){z=f[g>>2]|0;if(z>>>0<(f[j>>2]|0)>>>0){f[g>>2]=z+1;A=h[z>>0]|0}else A=Si(a)|0;z=Vn(k|0,i|0,-1,-1)|0;B=I;if((A|0)==48){k=z;i=B}else{n=1;o=0;p=1.0;q=0.0;r=0;s=A;t=1;u=0;v=0;w=z;x=B;break}}}else{n=1;o=0;p=1.0;q=0.0;r=0;s=y;t=l;u=0;v=0;w=0;x=0}}while(1){l=s+-48|0;y=s|32;if(l>>>0>=10){A=(s|0)==46;if(!(A|(y+-97|0)>>>0<6)){C=s;break}if(A)if(!n){D=1;E=o;F=p;G=q;H=r;J=t;K=v;L=u;M=v;N=u}else{C=46;break}else m=20}else m=20;if((m|0)==20){m=0;A=(s|0)>57?y+-87|0:l;do if(!((u|0)<0|(u|0)==0&v>>>0<8))if((u|0)<0|(u|0)==0&v>>>0<14){O=p*.0625;P=o;Q=O;R=q+O*+(A|0);S=r;break}else{l=(o|0)!=0|(A|0)==0;P=l?o:1;Q=p;R=l?q:q+p*.5;S=r;break}else{P=o;Q=p;R=q;S=A+(r<<4)|0}while(0);A=Vn(v|0,u|0,1,0)|0;D=n;E=P;F=Q;G=R;H=S;J=1;K=w;L=x;M=A;N=I}A=f[g>>2]|0;if(A>>>0<(f[j>>2]|0)>>>0){f[g>>2]=A+1;n=D;o=E;p=F;q=G;r=H;s=h[A>>0]|0;t=J;u=N;v=M;w=K;x=L;continue}else{n=D;o=E;p=F;q=G;r=H;s=Si(a)|0;t=J;u=N;v=M;w=K;x=L;continue}}do if(!t){L=(f[j>>2]|0)==0;if(!L)f[g>>2]=(f[g>>2]|0)+-1;if(e){if(!L)f[g>>2]=(f[g>>2]|0)+-1;if(!((n|0)==0|L))f[g>>2]=(f[g>>2]|0)+-1}else Ym(a,0);T=+(d|0)*0.0}else{L=(n|0)==0;K=L?v:w;M=L?u:x;if((u|0)<0|(u|0)==0&v>>>0<8){L=r;N=v;J=u;while(1){s=L<<4;H=N;N=Vn(N|0,J|0,1,0)|0;if(!((J|0)<0|(J|0)==0&H>>>0<7)){U=s;break}else{L=s;J=I}}}else U=r;if((C|32|0)==112){J=Re(a,e)|0;L=I;if((J|0)==0&(L|0)==-2147483648){if(!e){Ym(a,0);T=0.0;break}if(!(f[j>>2]|0)){V=0;W=0}else{f[g>>2]=(f[g>>2]|0)+-1;V=0;W=0}}else{V=J;W=L}}else if(!(f[j>>2]|0)){V=0;W=0}else{f[g>>2]=(f[g>>2]|0)+-1;V=0;W=0}L=Tn(K|0,M|0,2)|0;J=Vn(L|0,I|0,-32,-1)|0;L=Vn(J|0,I|0,V|0,W|0)|0;J=I;if(!U){T=+(d|0)*0.0;break}N=0-c|0;s=((N|0)<0)<<31>>31;if((J|0)>(s|0)|(J|0)==(s|0)&L>>>0>N>>>0){N=Vq()|0;f[N>>2]=34;T=+(d|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}N=c+-106|0;s=((N|0)<0)<<31>>31;if((J|0)<(s|0)|(J|0)==(s|0)&L>>>0>>0){N=Vq()|0;f[N>>2]=34;T=+(d|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if((U|0)>-1){G=q;N=U;s=L;H=J;while(1){E=!(G>=.5);o=N<<1|(E^1)&1;F=G+(E?G:G+-1.0);E=Vn(s|0,H|0,-1,-1)|0;D=I;if((o|0)>-1){G=F;N=o;s=E;H=D}else{X=F;Y=o;Z=E;_=D;break}}}else{X=q;Y=U;Z=L;_=J}H=((b|0)<0)<<31>>31;s=Xn(32,0,c|0,((c|0)<0)<<31>>31|0)|0;N=Vn(s|0,I|0,Z|0,_|0)|0;s=I;if((s|0)<(H|0)|(s|0)==(H|0)&N>>>0>>0)if((N|0)>0){$=N;m=59}else{aa=0;ba=84;m=61}else{$=b;m=59}if((m|0)==59)if(($|0)<53){aa=$;ba=84-$|0;m=61}else{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)|0;f[v>>2]=f[v>>2]|1<<(w&31);v=(((q>>>0)%3|0|0)==0?2:-1)+q|0;if((v|0)==-1)x=-1;else x=f[(f[r>>2]|0)+(v<<2)>>2]|0;v=(f[k>>2]|0)+(x>>>5<<2)|0;f[v>>2]=f[v>>2]|1<<(x&31);break}if(s>>>0>=q>>>0){v=q+1|0;t=((v>>>0)%3|0|0)==0?q+-2|0:v;y=s+(((s>>>0)%3|0|0)==0?2:-1)|0;z=(t|0)==-1;if(!(b[m>>0]|0)){if(z)A=-1;else A=f[(f[o>>2]|0)+(((t|0)/3|0)*12|0)+(((t|0)%3|0)<<2)>>2]|0;B=(y|0)==-1;if(B)C=-1;else C=f[(f[o>>2]|0)+(((y|0)/3|0)*12|0)+(((y|0)%3|0)<<2)>>2]|0;D=f[n>>2]|0;if((f[D+(A<<2)>>2]|0)==(f[D+(C<<2)>>2]|0)){E=t+1|0;if(z)F=-1;else F=((E>>>0)%3|0|0)==0?t+-2|0:E;do if(!B)if(!((y>>>0)%3|0)){G=y+2|0;break}else{G=y+-1|0;break}else G=-1;while(0);if((F|0)==-1)H=-1;else H=f[(f[o>>2]|0)+(((F|0)/3|0)*12|0)+(((F|0)%3|0)<<2)>>2]|0;if((G|0)==-1)I=-1;else I=f[(f[o>>2]|0)+(((G|0)/3|0)*12|0)+(((G|0)%3|0)<<2)>>2]|0;if((f[D+(H<<2)>>2]|0)==(f[D+(I<<2)>>2]|0))break}}else{if(z)J=-1;else J=f[(f[o>>2]|0)+(((t|0)/3|0)*12|0)+(((t|0)%3|0)<<2)>>2]|0;B=(y|0)==-1;if(B)K=-1;else K=f[(f[o>>2]|0)+(((y|0)/3|0)*12|0)+(((y|0)%3|0)<<2)>>2]|0;if((J|0)==(K|0)){E=t+1|0;if(z)L=-1;else L=((E>>>0)%3|0|0)==0?t+-2|0:E;do if(!B)if(!((y>>>0)%3|0)){M=y+2|0;break}else{M=y+-1|0;break}else M=-1;while(0);if((L|0)==-1)N=-1;else N=f[(f[o>>2]|0)+(((L|0)/3|0)*12|0)+(((L|0)%3|0)<<2)>>2]|0;if((M|0)==-1)O=-1;else O=f[(f[o>>2]|0)+(((M|0)/3|0)*12|0)+(((M|0)%3|0)<<2)>>2]|0;if((N|0)==(O|0))break}}b[p>>0]=0;y=f[a>>2]|0;B=y+(q>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(q&31);B=y+(s>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(s&31);B=((v>>>0)%3|0|0)==0?q+-2|0:v;if((B|0)==-1)P=-1;else P=f[(f[r>>2]|0)+(B<<2)>>2]|0;B=(f[k>>2]|0)+(P>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(P&31);B=(((q>>>0)%3|0|0)==0?2:-1)+q|0;if((B|0)==-1)Q=-1;else Q=f[(f[r>>2]|0)+(B<<2)>>2]|0;B=(f[k>>2]|0)+(Q>>>5<<2)|0;f[B>>2]=f[B>>2]|1<<(Q&31);B=s+1|0;y=((B>>>0)%3|0|0)==0?s+-2|0:B;if((y|0)==-1)R=-1;else R=f[(f[r>>2]|0)+(y<<2)>>2]|0;y=(f[k>>2]|0)+(R>>>5<<2)|0;f[y>>2]=f[y>>2]|1<<(R&31);y=(((s>>>0)%3|0|0)==0?2:-1)+s|0;if((y|0)==-1)S=-1;else S=f[(f[r>>2]|0)+(y<<2)>>2]|0;y=(f[k>>2]|0)+(S>>>5<<2)|0;f[y>>2]=f[y>>2]|1<<(S&31)}}while(0);q=q+1|0}while(q>>>0<(f[r+4>>2]|0)-(f[r>>2]|0)>>2>>>0)}if((c|0)!=0&(e|0)!=0){Qc(a,c,e);j=1;u=g;return j|0}else{md(a,0,0);j=1;u=g;return j|0}return 0}function Hc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;d=u;u=u+32|0;e=d+12|0;g=d+8|0;h=d+4|0;i=d;j=a+8|0;a:do if(f[j>>2]|0?(k=f[a>>2]|0,l=a+4|0,f[a>>2]=l,f[(f[l>>2]|0)+8>>2]=0,f[l>>2]=0,f[j>>2]=0,m=f[k+4>>2]|0,n=(m|0)==0?k:m,n|0):0){m=a+4|0;k=n;n=f[b>>2]|0;while(1){if((n|0)==(f[c>>2]|0))break;o=k+16|0;f[o>>2]=f[n+16>>2];if((k|0)!=(n|0)){f[h>>2]=f[n+20>>2];f[i>>2]=n+24;f[g>>2]=f[h>>2];f[e>>2]=f[i>>2];Oc(k+20|0,g,e)}p=k+8|0;q=f[p>>2]|0;do if(q){r=f[q>>2]|0;if((r|0)==(k|0)){f[q>>2]=0;s=f[q+4>>2]|0;if(!s){t=q;break}else v=s;while(1){s=f[v>>2]|0;if(s|0){v=s;continue}s=f[v+4>>2]|0;if(!s)break;else v=s}t=v;break}else{f[q+4>>2]=0;if(!r){t=q;break}else w=r;while(1){s=f[w>>2]|0;if(s|0){w=s;continue}s=f[w+4>>2]|0;if(!s)break;else w=s}t=w;break}}else t=0;while(0);q=f[l>>2]|0;do if(q){r=f[o>>2]|0;s=q;while(1){if((r|0)<(f[s+16>>2]|0)){x=f[s>>2]|0;if(!x){y=22;break}else z=x}else{A=s+4|0;x=f[A>>2]|0;if(!x){y=25;break}else z=x}s=z}if((y|0)==22){y=0;B=s;C=s;break}else if((y|0)==25){y=0;B=s;C=A;break}}else{B=l;C=l}while(0);f[k>>2]=0;f[k+4>>2]=0;f[p>>2]=B;f[C>>2]=k;q=f[f[a>>2]>>2]|0;if(!q)D=k;else{f[a>>2]=q;D=f[C>>2]|0}Oe(f[m>>2]|0,D);f[j>>2]=(f[j>>2]|0)+1;q=f[n+4>>2]|0;if(!q){o=n+8|0;r=f[o>>2]|0;if((f[r>>2]|0)==(n|0))E=r;else{r=o;do{o=f[r>>2]|0;r=o+8|0;x=f[r>>2]|0}while((f[x>>2]|0)!=(o|0));E=x}}else{r=q;while(1){p=f[r>>2]|0;if(!p)break;else r=p}E=r}f[b>>2]=E;if(!t)break a;else{k=t;n=E}}n=f[k+8>>2]|0;if(!n)F=k;else{m=n;while(1){n=f[m+8>>2]|0;if(!n)break;else m=n}F=m}Oj(a,F)}while(0);F=f[b>>2]|0;E=f[c>>2]|0;if((F|0)==(E|0)){u=d;return}c=a+4|0;t=a+4|0;D=F;while(1){Kg(e,a,D+16|0);F=f[c>>2]|0;do if(F){C=f[e>>2]|0;B=f[C+16>>2]|0;A=F;while(1){if((B|0)<(f[A+16>>2]|0)){z=f[A>>2]|0;if(!z){y=43;break}else G=z}else{H=A+4|0;z=f[H>>2]|0;if(!z){y=46;break}else G=z}A=G}if((y|0)==43){y=0;I=A;J=A;K=C;break}else if((y|0)==46){y=0;I=A;J=H;K=C;break}}else{I=c;J=c;K=f[e>>2]|0}while(0);f[K>>2]=0;f[K+4>>2]=0;f[K+8>>2]=I;f[J>>2]=K;F=f[f[a>>2]>>2]|0;if(!F)L=K;else{f[a>>2]=F;L=f[J>>2]|0}Oe(f[t>>2]|0,L);f[j>>2]=(f[j>>2]|0)+1;F=f[D+4>>2]|0;if(!F){m=D+8|0;B=f[m>>2]|0;if((f[B>>2]|0)==(D|0))M=B;else{B=m;do{m=f[B>>2]|0;B=m+8|0;r=f[B>>2]|0}while((f[r>>2]|0)!=(m|0));M=r}}else{B=F;while(1){r=f[B>>2]|0;if(!r)break;else B=r}M=B}f[b>>2]=M;if((M|0)==(E|0))break;else D=M}u=d;return}function Ic(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0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>2]|0;D=f[B+(G<<2)>>2]|0;if((C|0)<(w|0)&(E|0)<(w|0)&(D|0)<(w|0)){B=X(C,e)|0;C=X(E,e)|0;E=X(D,e)|0;if(u){D=0;do{f[h+(D<<2)>>2]=(f[b+(D+E<<2)>>2]|0)+(f[b+(D+C<<2)>>2]|0)-(f[b+(D+B<<2)>>2]|0);D=D+1|0}while((D|0)!=(e|0))}D=b+(z<<2)|0;B=c+(z<<2)|0;C=f[g>>2]|0;if((C|0)>0){E=0;y=h;A=C;while(1){if((A|0)>0){C=0;do{H=f[y+(C<<2)>>2]|0;I=f[n>>2]|0;if((H|0)>(I|0)){J=f[o>>2]|0;f[J+(C<<2)>>2]=I;K=J}else{J=f[p>>2]|0;I=f[o>>2]|0;f[I+(C<<2)>>2]=(H|0)<(J|0)?J:H;K=I}C=C+1|0}while((C|0)<(f[g>>2]|0));L=K}else L=f[o>>2]|0;C=(f[D+(E<<2)>>2]|0)-(f[L+(E<<2)>>2]|0)|0;I=B+(E<<2)|0;f[I>>2]=C;if((C|0)>=(f[q>>2]|0)){if((C|0)>(f[s>>2]|0)){M=C-(f[r>>2]|0)|0;N=42}}else{M=(f[r>>2]|0)+C|0;N=42}if((N|0)==42){N=0;f[I>>2]=M}E=E+1|0;A=f[g>>2]|0;if((E|0)>=(A|0))break;else y=L}}}else N=16}else N=16;if((N|0)==16?(N=0,y=b+(z<<2)|0,A=c+(z<<2)|0,E=f[g>>2]|0,(E|0)>0):0){B=0;D=b+((X(x+-2|0,e)|0)<<2)|0;I=E;while(1){if((I|0)>0){E=0;do{C=f[D+(E<<2)>>2]|0;H=f[n>>2]|0;if((C|0)>(H|0)){J=f[o>>2]|0;f[J+(E<<2)>>2]=H;O=J}else{J=f[p>>2]|0;H=f[o>>2]|0;f[H+(E<<2)>>2]=(C|0)<(J|0)?J:C;O=H}E=E+1|0}while((E|0)<(f[g>>2]|0));P=O}else P=f[o>>2]|0;E=(f[y+(B<<2)>>2]|0)-(f[P+(B<<2)>>2]|0)|0;H=A+(B<<2)|0;f[H>>2]=E;if((E|0)>=(f[q>>2]|0)){if((E|0)>(f[s>>2]|0)){Q=E-(f[r>>2]|0)|0;N=29}}else{Q=(f[r>>2]|0)+E|0;N=29}if((N|0)==29){N=0;f[H>>2]=Q}B=B+1|0;I=f[g>>2]|0;if((B|0)>=(I|0))break;else D=P}}if((x|0)<=2)break a}aq(i)}while(0);if((e|0)>0)sj(h|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(h);return 1}i=a+16|0;P=a+32|0;Q=a+12|0;O=a+28|0;L=a+20|0;M=a+24|0;a=0;K=h;G=e;while(1){if((G|0)>0){e=0;do{F=f[K+(e<<2)>>2]|0;d=f[i>>2]|0;if((F|0)>(d|0)){l=f[P>>2]|0;f[l+(e<<2)>>2]=d;R=l}else{l=f[Q>>2]|0;d=f[P>>2]|0;f[d+(e<<2)>>2]=(F|0)<(l|0)?l:F;R=d}e=e+1|0}while((e|0)<(f[g>>2]|0));S=R}else S=f[P>>2]|0;e=(f[b+(a<<2)>>2]|0)-(f[S+(a<<2)>>2]|0)|0;d=c+(a<<2)|0;f[d>>2]=e;if((e|0)>=(f[O>>2]|0)){if((e|0)>(f[M>>2]|0)){T=e-(f[L>>2]|0)|0;N=56}}else{T=(f[L>>2]|0)+e|0;N=56}if((N|0)==56){N=0;f[d>>2]=T}a=a+1|0;G=f[g>>2]|0;if((a|0)>=(G|0))break;else K=S}Mq(h);return 1}function Kc(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,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:-1)+B<<2)>>2]<<2)>>2]|0,(D|0)<(x|0)&(F|0)<(x|0)&(E|0)<(x|0)):0){B=X(D,e)|0;D=X(F,e)|0;F=X(E,e)|0;if(v){E=0;do{f[h+(E<<2)>>2]=(f[b+(E+F<<2)>>2]|0)+(f[b+(E+D<<2)>>2]|0)-(f[b+(E+B<<2)>>2]|0);E=E+1|0}while((E|0)!=(e|0))}E=b+(A<<2)|0;B=c+(A<<2)|0;D=f[g>>2]|0;if((D|0)>0){F=0;z=h;C=D;while(1){if((C|0)>0){D=0;do{G=f[z+(D<<2)>>2]|0;H=f[n>>2]|0;if((G|0)>(H|0)){I=f[o>>2]|0;f[I+(D<<2)>>2]=H;J=I}else{I=f[p>>2]|0;H=f[o>>2]|0;f[H+(D<<2)>>2]=(G|0)<(I|0)?I:G;J=H}D=D+1|0}while((D|0)<(f[g>>2]|0));K=J}else K=f[o>>2]|0;D=(f[E+(F<<2)>>2]|0)-(f[K+(F<<2)>>2]|0)|0;H=B+(F<<2)|0;f[H>>2]=D;if((D|0)>=(f[q>>2]|0)){if((D|0)>(f[s>>2]|0)){L=D-(f[r>>2]|0)|0;M=39}}else{L=(f[r>>2]|0)+D|0;M=39}if((M|0)==39){M=0;f[H>>2]=L}F=F+1|0;C=f[g>>2]|0;if((F|0)>=(C|0))break;else z=K}}}else M=13;if((M|0)==13?(M=0,z=b+(A<<2)|0,C=c+(A<<2)|0,F=f[g>>2]|0,(F|0)>0):0){B=0;E=b+((X(y+-2|0,e)|0)<<2)|0;H=F;while(1){if((H|0)>0){F=0;do{D=f[E+(F<<2)>>2]|0;G=f[n>>2]|0;if((D|0)>(G|0)){I=f[o>>2]|0;f[I+(F<<2)>>2]=G;N=I}else{I=f[p>>2]|0;G=f[o>>2]|0;f[G+(F<<2)>>2]=(D|0)<(I|0)?I:D;N=G}F=F+1|0}while((F|0)<(f[g>>2]|0));O=N}else O=f[o>>2]|0;F=(f[z+(B<<2)>>2]|0)-(f[O+(B<<2)>>2]|0)|0;G=C+(B<<2)|0;f[G>>2]=F;if((F|0)>=(f[q>>2]|0)){if((F|0)>(f[s>>2]|0)){P=F-(f[r>>2]|0)|0;M=26}}else{P=(f[r>>2]|0)+F|0;M=26}if((M|0)==26){M=0;f[G>>2]=P}B=B+1|0;H=f[g>>2]|0;if((B|0)>=(H|0))break;else E=O}}if((y|0)<=2)break a}aq(i)}while(0);if((e|0)>0)sj(h|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(h);return 1}i=a+16|0;O=a+32|0;P=a+12|0;N=a+28|0;K=a+20|0;L=a+24|0;a=0;J=h;d=e;while(1){if((d|0)>0){e=0;do{l=f[J+(e<<2)>>2]|0;j=f[i>>2]|0;if((l|0)>(j|0)){k=f[O>>2]|0;f[k+(e<<2)>>2]=j;Q=k}else{k=f[P>>2]|0;j=f[O>>2]|0;f[j+(e<<2)>>2]=(l|0)<(k|0)?k:l;Q=j}e=e+1|0}while((e|0)<(f[g>>2]|0));R=Q}else R=f[O>>2]|0;e=(f[b+(a<<2)>>2]|0)-(f[R+(a<<2)>>2]|0)|0;j=c+(a<<2)|0;f[j>>2]=e;if((e|0)>=(f[N>>2]|0)){if((e|0)>(f[L>>2]|0)){S=e-(f[K>>2]|0)|0;M=53}}else{S=(f[K>>2]|0)+e|0;M=53}if((M|0)==53){M=0;f[j>>2]=S}a=a+1|0;d=f[g>>2]|0;if((a|0)>=(d|0))break;else J=R}Mq(h);return 1}function Mc(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0;h=u;u=u+48|0;i=h+28|0;j=h+24|0;k=h;l=h+12|0;m=h+40|0;if((c|0)<0){n=0;u=h;return n|0}if(!c){n=1;u=h;return n|0}o=(d|0)>1;p=o?d:1;f[k>>2]=0;d=k+4|0;f[d>>2]=0;f[k+8>>2]=0;gk(k,c);q=k+8|0;if(o){o=0;r=0;while(1){s=1;t=f[a+(r<<2)>>2]|0;do{v=f[a+(s+r<<2)>>2]|0;t=t>>>0>>0?v:t;s=s+1|0}while((s|0)!=(p|0));s=(_(t|0)|0)^31;v=t>>>0>o>>>0?t:o;w=(t|0)==0?1:s+1|0;f[i>>2]=w;s=f[d>>2]|0;if(s>>>0<(f[q>>2]|0)>>>0){f[s>>2]=w;f[d>>2]=s+4}else Ri(k,i);r=r+p|0;if((r|0)>=(c|0)){x=v;break}else o=v}}else{o=0;r=0;while(1){v=f[a+(o<<2)>>2]|0;s=(_(v|0)|0)^31;w=v>>>0>r>>>0?v:r;y=(v|0)==0?1:s+1|0;f[i>>2]=y;s=f[d>>2]|0;if(s>>>0<(f[q>>2]|0)>>>0){f[s>>2]=y;f[d>>2]=s+4}else Ri(k,i);o=o+p|0;if((o|0)>=(c|0)){x=w;break}else r=w}}f[l>>2]=0;r=l+4|0;f[r>>2]=0;f[l+8>>2]=0;o=f[k>>2]|0;q=(f[d>>2]|0)-o|0;w=q>>2;if(w){if(w>>>0>1073741823)aq(l);s=ln(q)|0;f[r>>2]=s;f[l>>2]=s;f[l+8>>2]=s+(w<<2);w=s;if((q|0)>0){y=s+(q>>>2<<2)|0;kh(s|0,o|0,q|0)|0;f[r>>2]=y;q=y-w>>2;if((y|0)==(s|0)){z=q;A=s;B=0;C=0}else{y=0;o=0;v=0;while(1){D=Vn(o|0,v|0,f[s+(y<<2)>>2]|0,0)|0;E=I;y=y+1|0;if(y>>>0>=q>>>0){z=q;A=s;B=D;C=E;break}else{o=D;v=E}}}}else{F=w;G=18}}else{F=0;G=18}if((G|0)==18){z=0;A=F;B=0;C=0}F=Jg(A,z,32,i)|0;z=I;A=f[i>>2]<<3;w=Tn(A|0,((A|0)<0)<<31>>31|0,1)|0;A=I;v=un(B|0,C|0,p|0,0)|0;C=Vn(F|0,z|0,v|0,I|0)|0;v=Vn(C|0,I|0,w|0,A|0)|0;A=I;w=f[l>>2]|0;if(w|0){l=f[r>>2]|0;if((l|0)!=(w|0))f[r>>2]=l+(~((l+-4-w|0)>>>2)<<2);Oq(w)}w=Jg(a,c,x,i)|0;l=f[i>>2]|0;r=((x-l|0)/64|0)+l<<3;C=l<<3;z=Vn(w|0,I|0,C|0,((C|0)<0)<<31>>31|0)|0;C=Vn(z|0,I|0,r|0,((r|0)<0)<<31>>31|0)|0;r=I;z=(_((x>>>0>1?x:1)|0)|0)^30;if(e){f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;w=ln(32)|0;f[i>>2]=w;f[i+8>>2]=-2147483616;f[i+4>>2]=22;F=w;B=15964;o=F+22|0;do{b[F>>0]=b[B>>0]|0;F=F+1|0;B=B+1|0}while((F|0)<(o|0));b[w+22>>0]=0;w=(Jh(e,i)|0)==0;if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);if(!w){f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;w=ln(32)|0;f[i>>2]=w;f[i+8>>2]=-2147483616;f[i+4>>2]=22;F=w;B=15964;o=F+22|0;do{b[F>>0]=b[B>>0]|0;F=F+1|0;B=B+1|0}while((F|0)<(o|0));b[w+22>>0]=0;w=Mk(e,i)|0;if((b[i+11>>0]|0)<0)Oq(f[i>>2]|0);H=w}else G=32}else G=32;if((G|0)==32)H=z>>>0<18&((A|0)>(r|0)|(A|0)==(r|0)&v>>>0>=C>>>0)&1;b[m>>0]=H;C=g+16|0;v=f[C+4>>2]|0;if(!((v|0)>0|(v|0)==0&(f[C>>2]|0)>>>0>0)){f[j>>2]=f[g+4>>2];f[i>>2]=f[j>>2];Me(g,i,m,m+1|0)|0}switch(H|0){case 0:{J=td(a,c,p,k,g)|0;break}case 1:{J=Tc(a,c,x,l,e,g)|0;break}default:J=0}g=f[k>>2]|0;if(g|0){k=f[d>>2]|0;if((k|0)!=(g|0))f[d>>2]=k+(~((k+-4-g|0)>>>2)<<2);Oq(g)}n=J;u=h;return n|0}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(e|0){p=j+4|0;if((f[p>>2]|0)!=(e|0))f[p>>2]=e;Oq(e)}Oq(j)}Oq(h)}q=f[c>>2]|0}while((q|0)!=(o|0))}o=f[a+4>>2]|0;a:do if(o|0){q=o+44|0;c=f[q>>2]|0;h=f[o+40>>2]|0;while(1){if((h|0)==(c|0))break a;r=h+4|0;if((f[(f[h>>2]|0)+40>>2]|0)==(i|0))break;else h=r}if((r|0)!=(c|0)){j=r;e=h;do{p=f[j>>2]|0;f[j>>2]=0;g=f[e>>2]|0;f[e>>2]=p;if(g|0){bj(g);Oq(g)}j=j+4|0;e=e+4|0}while((j|0)!=(c|0));j=f[q>>2]|0;if((j|0)==(e|0))break;else{s=e;t=j}}else{s=h;t=c}j=t;do{g=j+-4|0;f[q>>2]=g;p=f[g>>2]|0;f[g>>2]=0;if(p|0){bj(p);Oq(p)}j=f[q>>2]|0}while((j|0)!=(s|0))}while(0);b:do if((d|0)<5){s=f[a+20+(d*12|0)>>2]|0;t=a+20+(d*12|0)+4|0;r=f[t>>2]|0;i=r;c:do if((s|0)==(r|0))u=s;else{o=s;while(1){if((f[o>>2]|0)==(b|0)){u=o;break c}o=o+4|0;if((o|0)==(r|0))break b}}while(0);if((u|0)!=(r|0)){s=u+4|0;o=i-s|0;j=o>>2;if(!j)v=r;else{im(u|0,s|0,o|0)|0;v=f[t>>2]|0}o=u+(j<<2)|0;if((v|0)!=(o|0))f[t>>2]=v+(~((v+-4-o|0)>>>2)<<2)}}while(0);v=f[a+24>>2]|0;u=f[a+20>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+36>>2]|0;u=f[a+32>>2]|0;d=u;if((o|0)!=(u|0)){j=o-u>>2;u=0;do{o=d+(u<<2)|0;v=f[o>>2]|0;if((v|0)>(b|0))f[o>>2]=v+-1;u=u+1|0}while(u>>>0>>0)}j=f[a+48>>2]|0;u=f[a+44>>2]|0;d=u;if((j|0)!=(u|0)){v=j-u>>2;u=0;do{j=d+(u<<2)|0;o=f[j>>2]|0;if((o|0)>(b|0))f[j>>2]=o+-1;u=u+1|0}while(u>>>0>>0)}v=f[a+60>>2]|0;u=f[a+56>>2]|0;d=u;if((v|0)!=(u|0)){o=v-u>>2;u=0;do{v=d+(u<<2)|0;j=f[v>>2]|0;if((j|0)>(b|0))f[v>>2]=j+-1;u=u+1|0}while(u>>>0>>0)}o=f[a+72>>2]|0;u=f[a+68>>2]|0;a=u;if((o|0)==(u|0))return;d=o-u>>2;u=0;do{o=a+(u<<2)|0;j=f[o>>2]|0;if((j|0)>(b|0))f[o>>2]=j+-1;u=u+1|0}while(u>>>0>>0);return}function Oc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;e=a+8|0;a:do if(f[e>>2]|0?(g=f[a>>2]|0,h=a+4|0,f[a>>2]=h,f[(f[h>>2]|0)+8>>2]=0,f[h>>2]=0,f[e>>2]=0,i=f[g+4>>2]|0,j=(i|0)==0?g:i,j|0):0){i=a+4|0;g=j;j=f[c>>2]|0;while(1){if((j|0)==(f[d>>2]|0))break;k=g+16|0;am(k,j+16|0)|0;am(g+28|0,j+28|0)|0;l=g+8|0;m=f[l>>2]|0;do if(m){n=f[m>>2]|0;if((n|0)==(g|0)){f[m>>2]=0;o=f[m+4>>2]|0;if(!o){p=m;break}else q=o;while(1){o=f[q>>2]|0;if(o|0){q=o;continue}o=f[q+4>>2]|0;if(!o)break;else q=o}p=q;break}else{f[m+4>>2]=0;if(!n){p=m;break}else r=n;while(1){o=f[r>>2]|0;if(o|0){r=o;continue}o=f[r+4>>2]|0;if(!o)break;else r=o}p=r;break}}else p=0;while(0);m=f[h>>2]|0;do if(m){n=b[k+11>>0]|0;o=n<<24>>24<0;s=o?f[g+20>>2]|0:n&255;n=o?f[k>>2]|0:k;o=m;while(1){t=o+16|0;u=b[t+11>>0]|0;v=u<<24>>24<0;w=v?f[o+20>>2]|0:u&255;u=w>>>0>>0?w:s;if((u|0)!=0?(x=Vk(n,v?f[t>>2]|0:t,u)|0,(x|0)!=0):0)if((x|0)<0)y=22;else y=24;else if(s>>>0>>0)y=22;else y=24;if((y|0)==22){y=0;w=f[o>>2]|0;if(!w){y=23;break}else z=w}else if((y|0)==24){y=0;A=o+4|0;w=f[A>>2]|0;if(!w){y=26;break}else z=w}o=z}if((y|0)==23){y=0;B=o;C=o;break}else if((y|0)==26){y=0;B=A;C=o;break}}else{B=h;C=h}while(0);f[g>>2]=0;f[g+4>>2]=0;f[l>>2]=C;f[B>>2]=g;m=f[f[a>>2]>>2]|0;if(!m)D=g;else{f[a>>2]=m;D=f[B>>2]|0}Oe(f[i>>2]|0,D);f[e>>2]=(f[e>>2]|0)+1;m=f[j+4>>2]|0;if(!m){k=j+8|0;s=f[k>>2]|0;if((f[s>>2]|0)==(j|0))E=s;else{s=k;do{k=f[s>>2]|0;s=k+8|0;n=f[s>>2]|0}while((f[n>>2]|0)!=(k|0));E=n}}else{s=m;while(1){l=f[s>>2]|0;if(!l)break;else s=l}E=s}f[c>>2]=E;if(!p)break a;else{g=p;j=E}}j=f[g+8>>2]|0;if(!j)F=g;else{i=j;while(1){j=f[i+8>>2]|0;if(!j)break;else i=j}F=i}Ej(a,F)}while(0);F=f[c>>2]|0;E=f[d>>2]|0;if((F|0)==(E|0))return;else G=F;while(1){bf(a,G+16|0)|0;F=f[G+4>>2]|0;if(!F){d=G+8|0;p=f[d>>2]|0;if((f[p>>2]|0)==(G|0))H=p;else{p=d;do{d=f[p>>2]|0;p=d+8|0;e=f[p>>2]|0}while((f[e>>2]|0)!=(d|0));H=e}}else{p=F;while(1){i=f[p>>2]|0;if(!i)break;else p=i}H=p}f[c>>2]=H;if((H|0)==(E|0))break;else G=H}return}function Pc(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;b=u;u=u+32|0;c=b+4|0;d=b;e=a+16|0;g=f[e>>2]|0;if(g>>>0>112){f[e>>2]=g+-113;g=a+4|0;e=f[g>>2]|0;h=f[e>>2]|0;i=e+4|0;f[g>>2]=i;e=a+8|0;j=f[e>>2]|0;k=a+12|0;l=f[k>>2]|0;m=l;do if((j|0)==(l|0)){n=f[a>>2]|0;o=n;if(i>>>0>n>>>0){p=i;q=((p-o>>2)+1|0)/-2|0;r=i+(q<<2)|0;s=j-p|0;p=s>>2;if(!p)t=i;else{im(r|0,i|0,s|0)|0;t=f[g>>2]|0}s=r+(p<<2)|0;f[e>>2]=s;f[g>>2]=t+(q<<2);v=s;break}s=m-o>>1;o=(s|0)==0?1:s;if(o>>>0>1073741823){s=ra(8)|0;Oo(s,16035);f[s>>2]=7256;va(s|0,1112,110)}s=ln(o<<2)|0;q=s;p=s+(o>>>2<<2)|0;r=p;w=s+(o<<2)|0;if((i|0)==(j|0)){x=r;y=n}else{n=p;p=r;o=i;do{f[n>>2]=f[o>>2];n=p+4|0;p=n;o=o+4|0}while((o|0)!=(j|0));x=p;y=f[a>>2]|0}f[a>>2]=q;f[g>>2]=r;f[e>>2]=x;f[k>>2]=w;if(!y)v=x;else{Oq(y);v=f[e>>2]|0}}else v=j;while(0);f[v>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}e=a+8|0;h=f[e>>2]|0;v=a+4|0;j=h-(f[v>>2]|0)|0;y=a+12|0;x=f[y>>2]|0;k=x-(f[a>>2]|0)|0;if(j>>>0>=k>>>0){g=k>>1;k=(g|0)==0?1:g;f[c+12>>2]=0;f[c+16>>2]=a+12;if(k>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}g=ln(k<<2)|0;f[c>>2]=g;i=g+(j>>2<<2)|0;j=c+8|0;f[j>>2]=i;m=c+4|0;f[m>>2]=i;i=c+12|0;f[i>>2]=g+(k<<2);k=ln(4068)|0;f[d>>2]=k;Ag(c,d);d=f[e>>2]|0;while(1){z=f[v>>2]|0;if((d|0)==(z|0))break;k=d+-4|0;ug(c,k);d=k}k=z;z=f[a>>2]|0;f[a>>2]=f[c>>2];f[c>>2]=z;f[v>>2]=f[m>>2];f[m>>2]=k;m=f[e>>2]|0;f[e>>2]=f[j>>2];f[j>>2]=m;g=f[y>>2]|0;f[y>>2]=f[i>>2];f[i>>2]=g;g=m;if((d|0)!=(g|0))f[j>>2]=g+(~((g+-4-k|0)>>>2)<<2);if(z|0)Oq(z);u=b;return}if((x|0)!=(h|0)){h=ln(4068)|0;f[c>>2]=h;Ag(a,c);u=b;return}h=ln(4068)|0;f[c>>2]=h;ug(a,c);c=f[v>>2]|0;h=f[c>>2]|0;x=c+4|0;f[v>>2]=x;c=f[e>>2]|0;z=f[y>>2]|0;k=z;do if((c|0)==(z|0)){g=f[a>>2]|0;j=g;if(x>>>0>g>>>0){d=x;m=((d-j>>2)+1|0)/-2|0;i=x+(m<<2)|0;t=c-d|0;d=t>>2;if(!d)A=x;else{im(i|0,x|0,t|0)|0;A=f[v>>2]|0}t=i+(d<<2)|0;f[e>>2]=t;f[v>>2]=A+(m<<2);B=t;break}t=k-j>>1;j=(t|0)==0?1:t;if(j>>>0>1073741823){t=ra(8)|0;Oo(t,16035);f[t>>2]=7256;va(t|0,1112,110)}t=ln(j<<2)|0;m=t;d=t+(j>>>2<<2)|0;i=d;l=t+(j<<2)|0;if((x|0)==(c|0)){C=i;D=g}else{g=d;d=i;j=x;do{f[g>>2]=f[j>>2];g=d+4|0;d=g;j=j+4|0}while((j|0)!=(c|0));C=d;D=f[a>>2]|0}f[a>>2]=m;f[v>>2]=i;f[e>>2]=C;f[y>>2]=l;if(!D)B=C;else{Oq(D);B=f[e>>2]|0}}else B=c;while(0);f[B>>2]=h;f[e>>2]=(f[e>>2]|0)+4;u=b;return}function Qc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;e=u;u=u+16|0;g=e+8|0;h=e+4|0;i=e;j=a+64|0;k=f[j>>2]|0;if((f[k+28>>2]|0)==(f[k+24>>2]|0)){u=e;return}l=c+96|0;c=a+52|0;m=d+84|0;n=d+68|0;d=a+56|0;o=a+60|0;p=a+12|0;q=a+28|0;r=a+40|0;s=a+44|0;t=a+48|0;v=0;w=0;x=k;while(1){k=f[(f[x+24>>2]|0)+(w<<2)>>2]|0;if((k|0)==-1){y=v;z=x}else{A=v+1|0;B=f[(f[l>>2]|0)+(((k|0)/3|0)*12|0)+(((k|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))C=f[(f[n>>2]|0)+(B<<2)>>2]|0;else C=B;f[g>>2]=C;B=f[d>>2]|0;if(B>>>0<(f[o>>2]|0)>>>0){f[B>>2]=C;f[d>>2]=B+4}else Ri(c,g);f[g>>2]=k;f[h>>2]=0;a:do if(!(f[(f[p>>2]|0)+(w>>>5<<2)>>2]&1<<(w&31)))D=k;else{B=k+1|0;E=((B>>>0)%3|0|0)==0?k+-2|0:B;if(((E|0)!=-1?(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)==0:0)?(B=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0,E=B+1|0,(B|0)!=-1):0){F=((E>>>0)%3|0|0)==0?B+-2|0:E;f[h>>2]=F;if((F|0)==-1){D=k;break}else G=F;while(1){f[g>>2]=G;F=G+1|0;E=((F>>>0)%3|0|0)==0?G+-2|0:F;if((E|0)==-1)break;if(f[(f[a>>2]|0)+(E>>>5<<2)>>2]&1<<(E&31)|0)break;F=f[(f[(f[j>>2]|0)+12>>2]|0)+(E<<2)>>2]|0;E=F+1|0;if((F|0)==-1)break;B=((E>>>0)%3|0|0)==0?F+-2|0:E;f[h>>2]=B;if((B|0)==-1){D=G;break a}else G=B}f[h>>2]=-1;D=G;break}f[h>>2]=-1;D=k}while(0);f[(f[q>>2]|0)+(D<<2)>>2]=v;k=f[s>>2]|0;if((k|0)==(f[t>>2]|0))Ri(r,g);else{f[k>>2]=f[g>>2];f[s>>2]=k+4}k=f[j>>2]|0;B=f[g>>2]|0;b:do if(((B|0)!=-1?(E=(((B>>>0)%3|0|0)==0?2:-1)+B|0,(E|0)!=-1):0)?(F=f[(f[k+12>>2]|0)+(E<<2)>>2]|0,(F|0)!=-1):0){E=F+(((F>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=E;if((E|0)!=-1&(E|0)!=(B|0)){F=A;H=v;I=E;while(1){E=I+1|0;J=((E>>>0)%3|0|0)==0?I+-2|0:E;do if(f[(f[a>>2]|0)+(J>>>5<<2)>>2]&1<<(J&31)){E=F+1|0;K=f[(f[l>>2]|0)+(((I|0)/3|0)*12|0)+(((I|0)%3|0)<<2)>>2]|0;if(!(b[m>>0]|0))L=f[(f[n>>2]|0)+(K<<2)>>2]|0;else L=K;f[i>>2]=L;K=f[d>>2]|0;if(K>>>0<(f[o>>2]|0)>>>0){f[K>>2]=L;f[d>>2]=K+4}else Ri(c,i);K=f[s>>2]|0;if((K|0)==(f[t>>2]|0)){Ri(r,h);M=E;N=F;break}else{f[K>>2]=f[h>>2];f[s>>2]=K+4;M=E;N=F;break}}else{M=F;N=H}while(0);f[(f[q>>2]|0)+(f[h>>2]<<2)>>2]=N;O=f[j>>2]|0;J=f[h>>2]|0;if((J|0)==-1)break;E=(((J>>>0)%3|0|0)==0?2:-1)+J|0;if((E|0)==-1)break;J=f[(f[O+12>>2]|0)+(E<<2)>>2]|0;if((J|0)==-1)break;I=J+(((J>>>0)%3|0|0)==0?2:-1)|0;f[h>>2]=I;if(!((I|0)!=-1?(I|0)!=(f[g>>2]|0):0)){P=M;Q=O;break b}else{F=M;H=N}}f[h>>2]=-1;P=M;Q=O}else{P=A;Q=k}}else R=28;while(0);if((R|0)==28){R=0;f[h>>2]=-1;P=A;Q=k}y=P;z=Q}w=w+1|0;if(w>>>0>=(f[z+28>>2]|0)-(f[z+24>>2]|0)>>2>>>0)break;else{v=y;x=z}}u=e;return}function Rc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,D=0,E=0,F=0;switch(c|0){case 0:{e=-149;g=24;i=4;break}case 1:{e=-1074;g=53;i=4;break}case 2:{e=-1074;g=53;i=4;break}default:j=0.0}a:do if((i|0)==4){c=a+4|0;k=a+100|0;do{l=f[c>>2]|0;if(l>>>0<(f[k>>2]|0)>>>0){f[c>>2]=l+1;m=h[l>>0]|0}else m=Si(a)|0}while((eq(m)|0)!=0);b:do switch(m|0){case 43:case 45:{l=1-(((m|0)==45&1)<<1)|0;n=f[c>>2]|0;if(n>>>0<(f[k>>2]|0)>>>0){f[c>>2]=n+1;o=h[n>>0]|0;p=l;break b}else{o=Si(a)|0;p=l;break b}break}default:{o=m;p=1}}while(0);l=0;n=o;while(1){if((n|32|0)!=(b[18546+l>>0]|0)){q=l;r=n;break}do if(l>>>0<7){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;t=h[s>>0]|0;break}else{t=Si(a)|0;break}}else t=n;while(0);s=l+1|0;if(s>>>0<8){l=s;n=t}else{q=s;r=t;break}}c:do switch(q|0){case 8:break;case 3:{i=23;break}default:{n=(d|0)!=0;if(n&q>>>0>3)if((q|0)==8)break c;else{i=23;break c}d:do if(!q){l=0;s=r;while(1){if((s|32|0)!=(b[18555+l>>0]|0)){u=l;v=s;break d}do if(l>>>0<2){w=f[c>>2]|0;if(w>>>0<(f[k>>2]|0)>>>0){f[c>>2]=w+1;x=h[w>>0]|0;break}else{x=Si(a)|0;break}}else x=s;while(0);w=l+1|0;if(w>>>0<3){l=w;s=x}else{u=w;v=x;break}}}else{u=q;v=r}while(0);switch(u|0){case 3:{s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;y=h[s>>0]|0}else y=Si(a)|0;if((y|0)==40)z=1;else{if(!(f[k>>2]|0)){j=B;break a}f[c>>2]=(f[c>>2]|0)+-1;j=B;break a}while(1){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;A=h[s>>0]|0}else A=Si(a)|0;if(!((A+-48|0)>>>0<10|(A+-65|0)>>>0<26)?!((A|0)==95|(A+-97|0)>>>0<26):0)break;z=z+1|0}if((A|0)==41){j=B;break a}s=(f[k>>2]|0)==0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if(!n){l=Vq()|0;f[l>>2]=22;Ym(a,0);j=0.0;break a}if(!z){j=B;break a}else D=z;while(1){D=D+-1|0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if(!D){j=B;break a}}break}case 0:{if((v|0)==48){s=f[c>>2]|0;if(s>>>0<(f[k>>2]|0)>>>0){f[c>>2]=s+1;E=h[s>>0]|0}else E=Si(a)|0;if((E|32|0)==120){j=+Fc(a,g,e,p,d);break a}if(!(f[k>>2]|0))F=48;else{f[c>>2]=(f[c>>2]|0)+-1;F=48}}else F=v;j=+nb(a,F,g,e,p,d);break a;break}default:{if(f[k>>2]|0)f[c>>2]=(f[c>>2]|0)+-1;s=Vq()|0;f[s>>2]=22;Ym(a,0);j=0.0;break a}}}}while(0);if((i|0)==23){s=(f[k>>2]|0)==0;if(!s)f[c>>2]=(f[c>>2]|0)+-1;if((d|0)!=0&q>>>0>3){n=q;do{if(!s)f[c>>2]=(f[c>>2]|0)+-1;n=n+-1|0}while(n>>>0>3)}}j=+$($(p|0)*$(C))}while(0);return +j}function Sc(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;g=u;u=u+16|0;h=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;i=ln(16)|0;f[h>>2]=i;f[h+8>>2]=-2147483632;f[h+4>>2]=15;j=i;k=14479;l=j+15|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+15>>0]=0;i=Hk(c,h,-1)|0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);switch(i|0){case 0:{m=ln(52)|0;j=m;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(m);n=4044;o=m;break}case -1:{if((mi(c)|0)==10){m=ln(52)|0;j=m;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(m);n=4044;o=m}else p=6;break}default:p=6}a:do if((p|0)==6){m=d+8|0;q=d+12|0;r=f[q>>2]|0;s=f[m>>2]|0;b:do if((r-s|0)>0){t=h+8|0;v=h+4|0;w=c+16|0;x=h+11|0;y=0;z=s;A=r;c:while(1){B=f[(f[z+(y<<2)>>2]|0)+28>>2]|0;switch(B|0){case 9:{p=12;break}case 6:case 5:case 4:case 2:{C=z;D=A;break}default:{if((B|2|0)!=3)break c;if((B|0)==9)p=12;else{C=z;D=A}}}if((p|0)==12){p=0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;B=ln(32)|0;f[h>>2]=B;f[t>>2]=-2147483616;f[v>>2]=17;j=B;k=14495;l=j+17|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[B+17>>0]=0;E=f[w>>2]|0;if(E){F=w;G=E;d:while(1){E=G;while(1){if((f[E+16>>2]|0)>=0)break;H=f[E+4>>2]|0;if(!H){I=F;break d}else E=H}G=f[E>>2]|0;if(!G){I=E;break}else F=E}if(((I|0)!=(w|0)?(f[I+16>>2]|0)<=0:0)?(F=I+20|0,(Jh(F,h)|0)!=0):0)J=Hk(F,h,-1)|0;else p=21}else p=21;if((p|0)==21){p=0;J=Hk(c,h,-1)|0}if((b[x>>0]|0)<0)Oq(f[h>>2]|0);if((J|0)<1)break;C=f[m>>2]|0;D=f[q>>2]|0}y=y+1|0;if((y|0)>=(D-C>>2|0))break b;else{z=C;A=D}}if((i|0)!=1){A=ln(52)|0;j=A;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(A);n=4044;o=A;break a}f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;z=ln(32)|0;f[h>>2]=z;f[h+8>>2]=-2147483616;f[h+4>>2]=24;j=z;k=14513;l=j+24|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[z+24>>0]=0;f[a>>2]=-1;pj(a+4|0,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}while(0);q=ln(52)|0;j=q;l=j+52|0;do{f[j>>2]=0;j=j+4|0}while((j|0)<(l|0));Zn(q);n=3988;o=q}while(0);f[o>>2]=n;ip(o,d);Md(a,o,c,e);Va[f[(f[o>>2]|0)+4>>2]&127](o);u=g;return}function Tc(a,c,d,e,g,h){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;i=u;u=u+32|0;j=i+4|0;k=i;l=i+16|0;m=(_(e|0)|0)^31;if((e|0)>0)if(m>>>0>17){n=0;u=i;return n|0}else o=m+1|0;else o=1;do if(g){m=ln(48)|0;f[j>>2]=m;f[j+8>>2]=-2147483600;f[j+4>>2]=33;e=m;p=15987;q=e+33|0;do{b[e>>0]=b[p>>0]|0;e=e+1|0;p=p+1|0}while((e|0)<(q|0));b[m+33>>0]=0;r=(Jh(g,j)|0)==0;if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if(!r){r=ln(48)|0;f[j>>2]=r;f[j+8>>2]=-2147483600;f[j+4>>2]=33;e=r;p=15987;q=e+33|0;do{b[e>>0]=b[p>>0]|0;e=e+1|0;p=p+1|0}while((e|0)<(q|0));b[r+33>>0]=0;p=Mk(g,j)|0;if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);if((p|0)<4){s=o+-2|0;break}if((p|0)<6){s=o+-1|0;break}if((p|0)>9){s=o+2|0;break}else{s=o+((p|0)>7&1)|0;break}}else s=o}else s=o;while(0);o=(s|0)>1?s:1;s=(o|0)<18?o:18;b[l>>0]=s;o=h+16|0;g=f[o+4>>2]|0;if(!((g|0)>0|(g|0)==0&(f[o>>2]|0)>>>0>0)){f[k>>2]=f[h+4>>2];f[j>>2]=f[k>>2];Me(h,j,l,l+1|0)|0}do switch(s&31){case 1:case 0:{n=ue(a,c,d,h)|0;u=i;return n|0}case 2:{n=te(a,c,d,h)|0;u=i;return n|0}case 3:{n=se(a,c,d,h)|0;u=i;return n|0}case 4:{n=re(a,c,d,h)|0;u=i;return n|0}case 5:{n=qe(a,c,d,h)|0;u=i;return n|0}case 6:{n=pe(a,c,d,h)|0;u=i;return n|0}case 7:{n=oe(a,c,d,h)|0;u=i;return n|0}case 8:{n=ne(a,c,d,h)|0;u=i;return n|0}case 9:{n=me(a,c,d,h)|0;u=i;return n|0}case 10:{n=le(a,c,d,h)|0;u=i;return n|0}case 11:{n=ke(a,c,d,h)|0;u=i;return n|0}case 12:{n=ie(a,c,d,h)|0;u=i;return n|0}case 13:{n=he(a,c,d,h)|0;u=i;return n|0}case 14:{n=ge(a,c,d,h)|0;u=i;return n|0}case 15:{n=fe(a,c,d,h)|0;u=i;return n|0}case 16:{n=ee(a,c,d,h)|0;u=i;return n|0}case 17:{n=de(a,c,d,h)|0;u=i;return n|0}case 18:{n=ce(a,c,d,h)|0;u=i;return n|0}default:{n=0;u=i;return n|0}}while(0);return 0}function Uc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;xb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Vc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;yb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Wc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;zb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Xc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ab(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Yc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*1048576.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==1048576){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Fb(z,A,g);a:do if((x|0)<1048576){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=1048576-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>1048576;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-1048576|0;m=x;while(1){v=1048576.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==1048576){C=p;D=1048576;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=1048576){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*9.5367431640625e-07)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function Zc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*524288.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==524288){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Bb(z,A,g);a:do if((x|0)<524288){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=524288-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>524288;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-524288|0;m=x;while(1){v=524288.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==524288){C=p;D=524288;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=524288){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*1.9073486328125e-06)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function _c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*262144.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==262144){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Cb(z,A,g);a:do if((x|0)<262144){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=262144-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>262144;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-262144|0;m=x;while(1){v=262144.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==262144){C=p;D=262144;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=262144){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*3.814697265625e-06)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function $c(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*65536.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==65536){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Db(z,A,g);a:do if((x|0)<65536){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=65536-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>65536;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-65536|0;m=x;while(1){v=65536.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==65536){C=p;D=65536;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=65536){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.0000152587890625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function ad(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*32768.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==32768){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Eb(z,A,g);a:do if((x|0)<32768){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=32768-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>32768;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-32768|0;m=x;while(1){v=32768.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==32768){C=p;D=32768;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=32768){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000030517578125)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function bd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*8192.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==8192){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Gb(z,A,g);a:do if((x|0)<8192){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=8192-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>8192;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-8192|0;m=x;while(1){v=8192.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==8192){C=p;D=8192;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=8192){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.0001220703125)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function cd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Hb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function dd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ib(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function ed(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Jb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function fd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Kb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function gd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Lb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function hd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Mb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function id(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Nb(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function jd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0;e=u;u=u+16|0;g=e;h=e+4|0;if((c|0)>0){i=0;j=0;k=0;l=0;while(1){m=b+(j<<3)|0;n=f[m>>2]|0;o=f[m+4>>2]|0;m=Vn(n|0,o|0,k|0,l|0)|0;p=I;q=(n|0)==0&(o|0)==0?i:j;j=j+1|0;if((j|0)==(c|0)){r=q;s=p;t=m;break}else{i=q;k=m;l=p}}}else{r=0;s=0;t=0}l=r+1|0;f[a+12>>2]=l;k=a+4|0;i=f[k>>2]|0;c=f[a>>2]|0;j=i-c>>3;p=c;c=i;if(l>>>0<=j>>>0){if(l>>>0>>0?(i=p+(l<<3)|0,(i|0)!=(c|0)):0)f[k>>2]=c+(~((c+-8-i|0)>>>3)<<3)}else wh(a,l-j|0);v=+(t>>>0)+4294967296.0*+(s>>>0);s=(r|0)<0;if(!s){t=f[a>>2]|0;j=0;i=0;do{c=b+(i<<3)|0;k=f[c>>2]|0;p=f[c+4>>2]|0;c=~~((+(k>>>0)+4294967296.0*+(p>>>0))/v*4096.0+.5)>>>0;m=((k|0)!=0|(p|0)!=0)&(c|0)==0?1:c;f[t+(i<<3)>>2]=m;j=m+j|0;i=i+1|0}while((i|0)!=(l|0));if((j|0)==4096){if(s){w=0;u=e;return w|0}}else{x=j;y=12}}else{x=0;y=12}if((y|0)==12){f[h>>2]=0;j=h+4|0;f[j>>2]=0;f[h+8>>2]=0;do if(l)if(l>>>0>1073741823)aq(h);else{i=l<<2;t=ln(i)|0;f[h>>2]=t;m=t+(l<<2)|0;f[h+8>>2]=m;sj(t|0,0,i|0)|0;f[j>>2]=m;z=t;A=m;break}else{z=0;A=0}while(0);if(!s?(f[z>>2]=0,r|0):0){m=1;do{f[z+(m<<2)>>2]=m;m=m+1|0}while((m|0)!=(l|0))}f[g>>2]=a;Ob(z,A,g);a:do if((x|0)<4096){g=(f[a>>2]|0)+(f[(f[j>>2]|0)+-4>>2]<<3)|0;f[g>>2]=4096-x+(f[g>>2]|0);B=0}else{g=f[h>>2]|0;if((r|0)<=0){A=(x|0)>4096;while(1)if(!A){B=0;break a}}A=f[a>>2]|0;z=x+-4096|0;m=x;while(1){v=4096.0/+(m|0);t=r;i=z;c=m;while(1){p=A+(f[g+(t<<2)>>2]<<3)|0;k=f[p>>2]|0;if(k>>>0<2){y=28;break}q=k-~~+J(+(v*+(k>>>0)))|0;o=(q|0)==0?1:q;q=(o|0)<(k|0)?o:k+-1|0;o=(q|0)>(i|0)?i:q;f[p>>2]=k-o;k=c-o|0;p=i-o|0;if((k|0)==4096){C=p;D=4096;break}if((t|0)>1){t=t+-1|0;i=p;c=k}else{C=p;D=k;break}}if((y|0)==28){y=0;if((t|0)==(r|0)){B=1;break a}else{C=i;D=c}}if((C|0)>0){z=C;m=D}else{B=0;break}}}while(0);D=f[h>>2]|0;if(D|0){h=f[j>>2]|0;if((h|0)!=(D|0))f[j>>2]=h+(~((h+-4-D|0)>>>2)<<2);Oq(D)}if((B|0)!=0|s){w=0;u=e;return w|0}}B=f[a>>2]|0;D=0;h=0;do{f[B+(D<<3)+4>>2]=h;h=(f[B+(D<<3)>>2]|0)+h|0;D=D+1|0}while((D|0)!=(l|0));if((h|0)!=4096){w=0;u=e;return w|0}if(s)E=0.0;else{s=f[a>>2]|0;h=0;v=0.0;while(1){D=f[s+(h<<3)>>2]|0;if(!D)F=v;else{B=b+(h<<3)|0;G=+((f[B>>2]|0)>>>0)+4294967296.0*+((f[B+4>>2]|0)>>>0);F=v+ +Zg(+(D>>>0)*.000244140625)*G}h=h+1|0;if((h|0)==(l|0)){E=F;break}else v=F}}F=+W(+-E);l=+K(F)>=1.0?(F>0.0?~~+Y(+J(F/4294967296.0),4294967295.0)>>>0:~~+W((F-+(~~F>>>0))/4294967296.0)>>>0):0;h=a+16|0;f[h>>2]=~~F>>>0;f[h+4>>2]=l;w=Le(a,d)|0;u=e;return w|0}function kd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0;g=u;u=u+32|0;d=g+16|0;h=g+8|0;i=g;j=e>>>0>1073741823?-1:e<<2;k=Lq(j)|0;sj(k|0,0,j|0)|0;j=f[a+28>>2]|0;l=a+36|0;m=f[l>>2]|0;n=f[m+4>>2]|0;o=f[m>>2]|0;p=n-o|0;a:do if((p|0)>4){q=p>>2;r=f[a+32>>2]|0;s=a+8|0;t=h+4|0;v=i+4|0;w=d+4|0;x=j+12|0;y=(e|0)>0;z=k+4|0;A=h+4|0;B=i+4|0;C=d+4|0;D=q+-1|0;if(n-o>>2>>>0>D>>>0){E=q;F=D;G=o}else{H=m;aq(H)}while(1){D=f[G+(F<<2)>>2]|0;q=X(F,e)|0;if((D|0)!=-1?(I=f[(f[x>>2]|0)+(D<<2)>>2]|0,(I|0)!=-1):0){D=f[j>>2]|0;J=f[r>>2]|0;K=f[J+(f[D+(I<<2)>>2]<<2)>>2]|0;L=I+1|0;M=((L>>>0)%3|0|0)==0?I+-2|0:L;if((M|0)==-1)N=-1;else N=f[D+(M<<2)>>2]|0;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)|0;A=z+(w?0:0-v&255)+(X((z+I|0)>>>(f[4092+(x<<3)+4>>2]|0),256-x|0)|0)|0;x=r+-1|0;if((x|0)<=-1){B=A;C=y;break a}r=x;s=A;t=y;v=b[h>>0]|0}}else{B=4096;C=0}while(0);y=f[m>>2]|0;if((f[n>>2]|0)==(y|0)){D=B;E=C}else{z=B;B=C;C=y;while(1){C=C+-4|0;y=f[C>>2]|0;k=31;j=z;v=B;while(1){t=b[h>>0]|0;s=(1<>>0>>0){F=v;G=j}else{b[o+v>>0]=j;F=v+1|0;G=j>>>8}un(f[4092+(r<<3)>>2]|0,0,G|0,0)|0;j=G+(s?0:0-t&255)+(X((G+I|0)>>>(f[4092+(r<<3)+4>>2]|0),256-r|0)|0)|0;if((k|0)<=0)break;else{k=k+-1|0;v=F}}if((f[n>>2]|0)==(C|0)){D=j;E=F;break}else{z=j;B=F}}}F=D+-4096|0;do if(F>>>0>=64){if(F>>>0<16384){B=o+E|0;z=D+12288|0;b[B>>0]=z;H=2;J=z>>>8;K=B+1|0;L=25;break}if(F>>>0<4194304){B=o+E|0;z=D+8384512|0;b[B>>0]=z;b[B+1>>0]=z>>>8;H=3;J=z>>>16;K=B+2|0;L=25}else M=E}else{H=1;J=F;K=o+E|0;L=25}while(0);if((L|0)==25){b[K>>0]=J;M=H+E|0}E=c+16|0;H=E;J=f[H+4>>2]|0;if(!((J|0)>0|(J|0)==0&(f[H>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}ci(M,c)|0;h=f[i>>2]|0;H=E;E=f[H+4>>2]|0;if(!((E|0)>0|(E|0)==0&(f[H>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+M|0)|0}M=e;f[M>>2]=0;f[M+4>>2]=0;qf(a,2,e);e=f[a+12>>2]|0;M=f[m>>2]|0;if((M|0)!=(e|0))f[m>>2]=M+(~((M+-4-e|0)>>>2)<<2);f[a+24>>2]=0;f[q>>2]=0;q=f[i>>2]|0;if(!q){u=d;return}if((f[l>>2]|0)!=(q|0))f[l>>2]=q;Oq(q);u=d;return}function md(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;c=u;u=u+16|0;b=c+8|0;d=c+4|0;e=c;g=a+64|0;h=f[g>>2]|0;if((f[h+28>>2]|0)==(f[h+24>>2]|0)){u=c;return}i=a+52|0;j=a+56|0;k=a+60|0;l=a+12|0;m=a+28|0;n=a+40|0;o=a+44|0;p=a+48|0;q=0;r=0;s=h;while(1){h=f[(f[s+24>>2]|0)+(r<<2)>>2]|0;if((h|0)==-1){t=q;v=s}else{w=q+1|0;f[b>>2]=q;x=f[j>>2]|0;if((x|0)==(f[k>>2]|0))Ri(i,b);else{f[x>>2]=q;f[j>>2]=x+4}f[d>>2]=h;f[e>>2]=0;a:do if(!(f[(f[l>>2]|0)+(r>>>5<<2)>>2]&1<<(r&31)))y=h;else{x=h+1|0;z=((x>>>0)%3|0|0)==0?h+-2|0:x;if(((z|0)!=-1?(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)==0:0)?(x=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0,z=x+1|0,(x|0)!=-1):0){A=((z>>>0)%3|0|0)==0?x+-2|0:z;f[e>>2]=A;if((A|0)==-1){y=h;break}else B=A;while(1){f[d>>2]=B;A=B+1|0;z=((A>>>0)%3|0|0)==0?B+-2|0:A;if((z|0)==-1)break;if(f[(f[a>>2]|0)+(z>>>5<<2)>>2]&1<<(z&31)|0)break;A=f[(f[(f[g>>2]|0)+12>>2]|0)+(z<<2)>>2]|0;z=A+1|0;if((A|0)==-1)break;x=((z>>>0)%3|0|0)==0?A+-2|0:z;f[e>>2]=x;if((x|0)==-1){y=B;break a}else B=x}f[e>>2]=-1;y=B;break}f[e>>2]=-1;y=h}while(0);f[(f[m>>2]|0)+(y<<2)>>2]=f[b>>2];h=f[o>>2]|0;if((h|0)==(f[p>>2]|0))Ri(n,d);else{f[h>>2]=f[d>>2];f[o>>2]=h+4}h=f[g>>2]|0;x=f[d>>2]|0;b:do if(((x|0)!=-1?(z=(((x>>>0)%3|0|0)==0?2:-1)+x|0,(z|0)!=-1):0)?(A=f[(f[h+12>>2]|0)+(z<<2)>>2]|0,(A|0)!=-1):0){z=A+(((A>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=z;if((z|0)!=-1&(z|0)!=(x|0)){A=w;C=z;while(1){z=C+1|0;D=((z>>>0)%3|0|0)==0?C+-2|0:z;do if(f[(f[a>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)){z=A+1|0;f[b>>2]=A;E=f[j>>2]|0;if((E|0)==(f[k>>2]|0))Ri(i,b);else{f[E>>2]=A;f[j>>2]=E+4}E=f[o>>2]|0;if((E|0)==(f[p>>2]|0)){Ri(n,e);F=z;break}else{f[E>>2]=f[e>>2];f[o>>2]=E+4;F=z;break}}else F=A;while(0);f[(f[m>>2]|0)+(f[e>>2]<<2)>>2]=f[b>>2];G=f[g>>2]|0;D=f[e>>2]|0;if((D|0)==-1)break;z=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((z|0)==-1)break;D=f[(f[G+12>>2]|0)+(z<<2)>>2]|0;if((D|0)==-1)break;C=D+(((D>>>0)%3|0|0)==0?2:-1)|0;f[e>>2]=C;if(!((C|0)!=-1?(C|0)!=(f[d>>2]|0):0)){H=F;I=G;break b}else A=F}f[e>>2]=-1;H=F;I=G}else{H=w;I=h}}else J=26;while(0);if((J|0)==26){J=0;f[e>>2]=-1;H=w;I=h}t=H;v=I}r=r+1|0;if(r>>>0>=(f[v+28>>2]|0)-(f[v+24>>2]|0)>>2>>>0)break;else{q=t;s=v}}u=c;return}function nd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;h=a+124|0;f[h>>2]=(f[h>>2]|0)+1;h=a+88|0;i=a+120|0;j=f[i>>2]|0;k=j+1|0;do if((j|0)!=-1){l=((k>>>0)%3|0|0)==0?j+-2|0:k;if(!((j>>>0)%3|0)){m=j+2|0;n=l;break}else{m=j+-1|0;n=l;break}}else{m=-1;n=-1}while(0);k=a+104|0;l=a+92|0;o=f[l>>2]|0;p=o+(n<<2)|0;q=f[k>>2]|0;r=q+(f[p>>2]<<2)|0;s=f[r>>2]|0;switch(b|0){case 1:case 0:{f[r>>2]=s+-1;r=q+(f[o+(m<<2)>>2]<<2)|0;f[r>>2]=(f[r>>2]|0)+-1;if((b|0)==1){if((m|0)!=-1?(r=f[(f[(f[h>>2]|0)+12>>2]|0)+(m<<2)>>2]|0,(r|0)!=-1):0){t=a+64|0;v=1;w=r;while(1){r=f[t>>2]|0;x=f[(f[r>>2]|0)+36>>2]|0;f[e>>2]=(w>>>0)/3|0;f[d>>2]=f[e>>2];if(Ra[x&127](r,d)|0){y=v;break}r=w+1|0;x=((r>>>0)%3|0|0)==0?w+-2|0:r;if((x|0)==-1){z=12;break}w=f[(f[(f[h>>2]|0)+12>>2]|0)+(x<<2)>>2]|0;x=v+1|0;if((w|0)==-1){y=x;break}else v=x}if((z|0)==12)y=v+1|0;A=y;B=f[k>>2]|0;C=f[l>>2]|0}else{A=1;B=q;C=o}f[B+(f[C+(f[i>>2]<<2)>>2]<<2)>>2]=A;A=a+108|0;i=f[A>>2]|0;C=i-B>>2;B=i;if((n|0)!=-1?(i=f[(f[(f[h>>2]|0)+12>>2]|0)+(n<<2)>>2]|0,(i|0)!=-1):0){n=a+64|0;y=1;v=i;while(1){i=f[n>>2]|0;w=f[(f[i>>2]|0)+36>>2]|0;f[g>>2]=(v>>>0)/3|0;f[d>>2]=f[g>>2];if(Ra[w&127](i,d)|0){D=y;break}i=v+1|0;f[(f[l>>2]|0)+((((i>>>0)%3|0|0)==0?v+-2|0:i)<<2)>>2]=C;i=(((v>>>0)%3|0|0)==0?2:-1)+v|0;if((i|0)==-1){z=20;break}v=f[(f[(f[h>>2]|0)+12>>2]|0)+(i<<2)>>2]|0;i=y+1|0;if((v|0)==-1){D=i;break}else y=i}if((z|0)==20)D=y+1|0;E=D;F=f[A>>2]|0}else{E=1;F=B}f[d>>2]=E;if(F>>>0<(f[a+112>>2]|0)>>>0){f[F>>2]=E;f[A>>2]=F+4}else Ri(k,d)}break}case 5:{k=q+(f[o+(j<<2)>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-1;k=q+(f[p>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-1;k=q+(f[o+(m<<2)>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-2;break}case 3:{k=q+(f[o+(j<<2)>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-1;k=q+(f[p>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-2;k=q+(f[o+(m<<2)>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-1;break}case 7:{k=q+(f[o+(j<<2)>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-2;k=q+(f[p>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-2;k=q+(f[o+(m<<2)>>2]<<2)|0;f[k>>2]=(f[k>>2]|0)+-2;break}default:{}}k=a+116|0;m=f[k>>2]|0;if((m|0)==-1){f[k>>2]=b;u=c;return}o=f[a+128>>2]|0;if((s|0)<(o|0))G=o;else{q=f[a+132>>2]|0;G=(s|0)>(q|0)?q:s}s=G-o|0;o=f[a+136>>2]|0;a=f[3724+(m<<2)>>2]|0;f[d>>2]=a;m=o+(s*12|0)+4|0;G=f[m>>2]|0;if(G>>>0<(f[o+(s*12|0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d(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0;switch(c|0){case 1:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2076;i=c;f[a>>2]=i;return}case 2:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2132;i=c;f[a>>2]=i;return}case 4:{c=ln(168)|0;Ti(c,d,e,g);i=c;f[a>>2]=i;return}case 3:{c=ln(88)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2188;h=c+60|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(104)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2244;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(140)|0;f[c>>2]=1544;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=2300;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=2356;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function qd(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0;switch(c|0){case 1:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1656;i=c;f[a>>2]=i;return}case 2:{c=ln(60)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1712;i=c;f[a>>2]=i;return}case 4:{c=ln(168)|0;Ui(c,d,e,g);i=c;f[a>>2]=i;return}case 3:{c=ln(88)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1768;h=c+60|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(104)|0;f[c>>2]=1544;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[h+16>>2]=f[e+16>>2];f[h+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);h=c+44|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=1824;f[c+60>>2]=0;f[c+64>>2]=0;f[c+76>>2]=0;f[c+80>>2]=0;f[c+84>>2]=0;h=c+88|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(140)|0;f[c>>2]=1544;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];f[d+16>>2]=f[e+16>>2];f[d+20>>2]=f[e+20>>2];fk(c+32|0,e+24|0);e=c+44|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=1880;f[c+64>>2]=0;f[c+68>>2]=0;e=c+72|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+60>>2]=1936;f[c+88>>2]=1;g=c+92|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+108|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function rd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+2|0;v=e+12|0;w=q+6|0;x=f[e>>2]|0;d:do if(!x)y=e;else{z=d[q>>1]|0;A=e;B=x;while(1){C=B+8|0;if(z<<16>>16!=(d[C>>1]|0)){y=A;break d}if((d[u>>1]|0)!=(d[C+2>>1]|0)){y=A;break d}if((d[v>>1]|0)!=(d[B+12>>1]|0)){y=A;break d}if((d[w>>1]|0)!=(d[C+6>>1]|0)){y=A;break d}C=f[B>>2]|0;if(!C){y=B;break}else{D=B;B=C;A=D}}}while(0);f[j>>2]=f[y>>2];f[y>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}else{e=c;while(1){w=f[e+4>>2]|0;if(w>>>0>>0)F=w;else F=(w>>>0)%(b>>>0)|0;if((F|0)==(k|0)){p=e;break c}w=(f[a>>2]|0)+(F<<2)|0;if(!(f[w>>2]|0)){r=e;s=F;t=w;break b}w=e+8|0;v=w+2|0;u=e+12|0;x=w+6|0;q=f[e>>2]|0;e:do if(!q)G=e;else{A=d[w>>1]|0;B=e;z=q;while(1){D=z+8|0;if(A<<16>>16!=(d[D>>1]|0)){G=B;break e}if((d[v>>1]|0)!=(d[D+2>>1]|0)){G=B;break e}if((d[u>>1]|0)!=(d[z+12>>1]|0)){G=B;break e}if((d[x>>1]|0)!=(d[D+6>>1]|0)){G=B;break e}D=f[z>>2]|0;if(!D){G=z;break}else{C=z;z=D;B=C}}}while(0);f[j>>2]=f[G>>2];f[G>>2]=f[f[(f[a>>2]|0)+(F<<2)>>2]>>2];f[f[(f[a>>2]|0)+(F<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}while(0);c=f[p>>2]|0;if(!c){E=43;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){E=43;break}else{k=s;l=r;n=r}}if((E|0)==43)return}function sd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+1|0;v=q+2|0;w=q+3|0;x=f[e>>2]|0;d:do if(!x)y=e;else{z=b[q>>0]|0;A=e;B=x;while(1){C=B+8|0;if(z<<24>>24!=(b[C>>0]|0)){y=A;break d}if((b[u>>0]|0)!=(b[C+1>>0]|0)){y=A;break d}if((b[v>>0]|0)!=(b[C+2>>0]|0)){y=A;break d}if((b[w>>0]|0)!=(b[C+3>>0]|0)){y=A;break d}C=f[B>>2]|0;if(!C){y=B;break}else{D=B;B=C;A=D}}}while(0);f[j>>2]=f[y>>2];f[y>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}else{e=d;while(1){w=f[e+4>>2]|0;if(w>>>0>>0)F=w;else F=(w>>>0)%(c>>>0)|0;if((F|0)==(k|0)){p=e;break c}w=(f[a>>2]|0)+(F<<2)|0;if(!(f[w>>2]|0)){r=e;s=F;t=w;break b}w=e+8|0;v=w+1|0;u=w+2|0;x=w+3|0;q=f[e>>2]|0;e:do if(!q)G=e;else{A=b[w>>0]|0;B=e;z=q;while(1){D=z+8|0;if(A<<24>>24!=(b[D>>0]|0)){G=B;break e}if((b[v>>0]|0)!=(b[D+1>>0]|0)){G=B;break e}if((b[u>>0]|0)!=(b[D+2>>0]|0)){G=B;break e}if((b[x>>0]|0)!=(b[D+3>>0]|0)){G=B;break e}D=f[z>>2]|0;if(!D){G=z;break}else{C=z;z=D;B=C}}}while(0);f[j>>2]=f[G>>2];f[G>>2]=f[f[(f[a>>2]|0)+(F<<2)>>2]>>2];f[f[(f[a>>2]|0)+(F<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){E=43;break a}}}while(0);d=f[p>>2]|0;if(!d){E=43;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]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0,z=0,A=0,B=0,C=0,D=0,E=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=d+16|0;u=d+20|0;v=f[d>>2]|0;d:do if(!v)w=d;else{x=f[d+8>>2]|0;y=d;z=v;while(1){if((x|0)!=(f[z+8>>2]|0)){w=y;break d}if((f[p>>2]|0)!=(f[z+12>>2]|0)){w=y;break d}if((f[t>>2]|0)!=(f[z+16>>2]|0)){w=y;break d}if((f[u>>2]|0)!=(f[z+20>>2]|0)){w=y;break d}A=f[z>>2]|0;if(!A){w=z;break}else{B=z;z=A;y=B}}}while(0);f[i>>2]=f[w>>2];f[w>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){C=43;break a}}}else{d=c;while(1){u=f[d+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(b>>>0)|0;if((D|0)==(j|0)){o=d;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){q=d;r=D;s=u;break b}u=d+12|0;t=d+16|0;p=d+20|0;v=f[d>>2]|0;e:do if(!v)E=d;else{y=f[d+8>>2]|0;z=d;x=v;while(1){if((y|0)!=(f[x+8>>2]|0)){E=z;break e}if((f[u>>2]|0)!=(f[x+12>>2]|0)){E=z;break e}if((f[t>>2]|0)!=(f[x+16>>2]|0)){E=z;break e}if((f[p>>2]|0)!=(f[x+20>>2]|0)){E=z;break e}B=f[x>>2]|0;if(!B){E=x;break}else{A=x;x=B;z=A}}}while(0);f[i>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){C=43;break a}}}while(0);c=f[o>>2]|0;if(!c){C=43;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){C=43;break}else{j=r;k=q;m=q}}if((C|0)==43)return}function vd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=e+12|0;v=f[e>>2]|0;d:do if(!v)w=e;else{x=d[q>>1]|0;y=q+2|0;z=e;A=v;while(1){B=A+8|0;if(x<<16>>16!=(d[B>>1]|0)){w=z;break d}if((d[y>>1]|0)!=(d[B+2>>1]|0)){w=z;break d}if((d[u>>1]|0)!=(d[A+12>>1]|0)){w=z;break d}B=f[A>>2]|0;if(!B){w=A;break}else{C=A;A=B;z=C}}}while(0);f[j>>2]=f[w>>2];f[w>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}else{e=c;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)E=u;else E=(u>>>0)%(b>>>0)|0;if((E|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(E<<2)|0;if(!(f[u>>2]|0)){r=e;s=E;t=u;break b}u=e+8|0;v=e+12|0;q=f[e>>2]|0;e:do if(!q)F=e;else{z=d[u>>1]|0;A=u+2|0;y=e;x=q;while(1){C=x+8|0;if(z<<16>>16!=(d[C>>1]|0)){F=y;break e}if((d[A>>1]|0)!=(d[C+2>>1]|0)){F=y;break e}if((d[v>>1]|0)!=(d[x+12>>1]|0)){F=y;break e}C=f[x>>2]|0;if(!C){F=x;break}else{B=x;x=C;y=B}}}while(0);f[j>>2]=f[F>>2];f[F>>2]=f[f[(f[a>>2]|0)+(E<<2)>>2]>>2];f[f[(f[a>>2]|0)+(E<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}while(0);c=f[p>>2]|0;if(!c){D=41;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){D=41;break}else{k=s;l=r;n=r}}if((D|0)==41)return}function wd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=q+1|0;v=q+2|0;w=f[e>>2]|0;d:do if(!w)x=e;else{y=b[q>>0]|0;z=e;A=w;while(1){B=A+8|0;if(y<<24>>24!=(b[B>>0]|0)){x=z;break d}if((b[u>>0]|0)!=(b[B+1>>0]|0)){x=z;break d}if((b[v>>0]|0)!=(b[B+2>>0]|0)){x=z;break d}B=f[A>>2]|0;if(!B){x=A;break}else{C=A;A=B;z=C}}}while(0);f[j>>2]=f[x>>2];f[x>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}else{e=d;while(1){v=f[e+4>>2]|0;if(v>>>0>>0)E=v;else E=(v>>>0)%(c>>>0)|0;if((E|0)==(k|0)){p=e;break c}v=(f[a>>2]|0)+(E<<2)|0;if(!(f[v>>2]|0)){r=e;s=E;t=v;break b}v=e+8|0;u=v+1|0;w=v+2|0;q=f[e>>2]|0;e:do if(!q)F=e;else{z=b[v>>0]|0;A=e;y=q;while(1){C=y+8|0;if(z<<24>>24!=(b[C>>0]|0)){F=A;break e}if((b[u>>0]|0)!=(b[C+1>>0]|0)){F=A;break e}if((b[w>>0]|0)!=(b[C+2>>0]|0)){F=A;break e}C=f[y>>2]|0;if(!C){F=y;break}else{B=y;y=C;A=B}}}while(0);f[j>>2]=f[F>>2];f[F>>2]=f[f[(f[a>>2]|0)+(E<<2)>>2]>>2];f[f[(f[a>>2]|0)+(E<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){D=41;break a}}}while(0);d=f[p>>2]|0;if(!d){D=41;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){D=41;break}else{k=s;l=r;n=r}}if((D|0)==41)return}function xd(a,b){a=+a;b=+b;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0.0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;p[s>>3]=b;e=f[s>>2]|0;g=f[s+4>>2]|0;h=Yn(c|0,d|0,52)|0;i=h&2047;h=Yn(e|0,g|0,52)|0;j=h&2047;h=d&-2147483648;k=Tn(e|0,g|0,1)|0;l=I;a:do if(!((k|0)==0&(l|0)==0)?(m=yo(b)|0,n=I&2147483647,!((i|0)==2047|(n>>>0>2146435072|(n|0)==2146435072&m>>>0>0))):0){m=Tn(c|0,d|0,1)|0;n=I;if(!(n>>>0>l>>>0|(n|0)==(l|0)&m>>>0>k>>>0))return +((m|0)==(k|0)&(n|0)==(l|0)?a*0.0:a);if(!i){n=Tn(c|0,d|0,12)|0;m=I;if((m|0)>-1|(m|0)==-1&n>>>0>4294967295){o=0;q=n;n=m;while(1){m=o+-1|0;q=Tn(q|0,n|0,1)|0;n=I;if(!((n|0)>-1|(n|0)==-1&q>>>0>4294967295)){r=m;break}else o=m}}else r=0;o=Tn(c|0,d|0,1-r|0)|0;t=r;u=o;v=I}else{t=i;u=c;v=d&1048575|1048576}if(!j){o=Tn(e|0,g|0,12)|0;q=I;if((q|0)>-1|(q|0)==-1&o>>>0>4294967295){n=0;m=o;o=q;while(1){q=n+-1|0;m=Tn(m|0,o|0,1)|0;o=I;if(!((o|0)>-1|(o|0)==-1&m>>>0>4294967295)){w=q;break}else n=q}}else w=0;n=Tn(e|0,g|0,1-w|0)|0;x=w;y=n;z=I}else{x=j;y=e;z=g&1048575|1048576}n=Xn(u|0,v|0,y|0,z|0)|0;m=I;o=(m|0)>-1|(m|0)==-1&n>>>0>4294967295;b:do if((t|0)>(x|0)){q=t;A=m;B=o;C=u;D=v;E=n;while(1){if(B)if((E|0)==0&(A|0)==0)break;else{F=E;G=A}else{F=C;G=D}H=Tn(F|0,G|0,1)|0;J=I;K=q+-1|0;L=Xn(H|0,J|0,y|0,z|0)|0;M=I;N=(M|0)>-1|(M|0)==-1&L>>>0>4294967295;if((K|0)>(x|0)){q=K;A=M;B=N;C=H;D=J;E=L}else{O=K;P=N;Q=L;R=M;S=H;T=J;break b}}U=a*0.0;break a}else{O=t;P=o;Q=n;R=m;S=u;T=v}while(0);if(P)if((Q|0)==0&(R|0)==0){U=a*0.0;break}else{V=R;W=Q}else{V=T;W=S}if(V>>>0<1048576|(V|0)==1048576&W>>>0<0){m=O;n=W;o=V;while(1){E=Tn(n|0,o|0,1)|0;D=I;C=m+-1|0;if(D>>>0<1048576|(D|0)==1048576&E>>>0<0){m=C;n=E;o=D}else{X=C;Y=E;Z=D;break}}}else{X=O;Y=W;Z=V}if((X|0)>0){o=Vn(Y|0,Z|0,0,-1048576)|0;n=I;m=Tn(X|0,0,52)|0;_=n|I;$=o|m}else{m=Yn(Y|0,Z|0,1-X|0)|0;_=I;$=m}f[s>>2]=$;f[s+4>>2]=_|h;U=+p[s>>3]}else aa=3;while(0);if((aa|0)==3){ba=a*b;U=ba/ba}return +U}function yd(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;d=u;u=u+32|0;e=d+8|0;g=d;h=c+4|0;i=f[(f[h>>2]|0)+48>>2]|0;j=c+12|0;c=f[j>>2]|0;k=ln(32)|0;f[e>>2]=k;f[e+8>>2]=-2147483616;f[e+4>>2]=17;l=k;m=14495;n=l+17|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[k+17>>0]=0;k=i+16|0;m=f[k>>2]|0;if(m){l=k;n=m;a:while(1){m=n;while(1){if((f[m+16>>2]|0)>=(c|0))break;o=f[m+4>>2]|0;if(!o){p=l;break a}else m=o}n=f[m>>2]|0;if(!n){p=m;break}else l=m}if(((p|0)!=(k|0)?(c|0)>=(f[p+16>>2]|0):0)?(c=p+20|0,(Jh(c,e)|0)!=0):0)q=Hk(c,e,-1)|0;else r=10}else r=10;if((r|0)==10)q=Hk(i,e,-1)|0;if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);f[e>>2]=-1;f[e+4>>2]=-1;f[e+8>>2]=-1;f[e+12>>2]=-1;i=(_((1<>>0<=28){f[e>>2]=i+1;q=2<>2]=q+-1;i=q+-2|0;f[e+8>>2]=i;f[e+12>>2]=(i|0)/2|0}switch(Xi(f[j>>2]|0,f[h>>2]|0)|0){case 6:{i=f[j>>2]|0;q=f[h>>2]|0;c=f[(f[(f[q+4>>2]|0)+8>>2]|0)+(i<<2)>>2]|0;do if((Qa[f[(f[q>>2]|0)+8>>2]&127](q)|0)==1){Hf(g,q,6,i,e,514);p=f[g>>2]|0;if(!p){f[g>>2]=0;s=g;r=21;break}else{t=g;v=p;break}}else{s=g;r=21}while(0);if((r|0)==21){i=ln(24)|0;f[i+4>>2]=c;c=i+8|0;f[c>>2]=f[e>>2];f[c+4>>2]=f[e+4>>2];f[c+8>>2]=f[e+8>>2];f[c+12>>2]=f[e+12>>2];f[i>>2]=2560;c=i;f[g>>2]=c;t=s;v=c}f[a>>2]=v;f[t>>2]=0;u=d;return}case 0:{t=f[j>>2]|0;j=f[h>>2]|0;h=f[(f[(f[j+4>>2]|0)+8>>2]|0)+(t<<2)>>2]|0;do if((Qa[f[(f[j>>2]|0)+8>>2]&127](j)|0)==1){Hf(g,j,0,t,e,514);v=f[g>>2]|0;if(!v){f[g>>2]=0;w=g;r=28;break}else{x=g;y=v;break}}else{w=g;r=28}while(0);if((r|0)==28){r=ln(24)|0;f[r+4>>2]=h;h=r+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];f[r>>2]=2560;e=r;f[g>>2]=e;x=w;y=e}f[a>>2]=y;f[x>>2]=0;u=d;return}default:{f[a>>2]=0;u=d;return}}}function zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=d+16|0;u=f[d>>2]|0;d:do if(!u)v=d;else{w=f[d+8>>2]|0;x=d;y=u;while(1){if((w|0)!=(f[y+8>>2]|0)){v=x;break d}if((f[p>>2]|0)!=(f[y+12>>2]|0)){v=x;break d}if((f[t>>2]|0)!=(f[y+16>>2]|0)){v=x;break d}z=f[y>>2]|0;if(!z){v=y;break}else{A=y;y=z;x=A}}}while(0);f[i>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){B=41;break a}}}else{d=c;while(1){t=f[d+4>>2]|0;if(t>>>0>>0)C=t;else C=(t>>>0)%(b>>>0)|0;if((C|0)==(j|0)){o=d;break c}t=(f[a>>2]|0)+(C<<2)|0;if(!(f[t>>2]|0)){q=d;r=C;s=t;break b}t=d+12|0;p=d+16|0;u=f[d>>2]|0;e:do if(!u)D=d;else{x=f[d+8>>2]|0;y=d;w=u;while(1){if((x|0)!=(f[w+8>>2]|0)){D=y;break e}if((f[t>>2]|0)!=(f[w+12>>2]|0)){D=y;break e}if((f[p>>2]|0)!=(f[w+16>>2]|0)){D=y;break e}A=f[w>>2]|0;if(!A){D=w;break}else{z=w;w=A;y=z}}}while(0);f[i>>2]=f[D>>2];f[D>>2]=f[f[(f[a>>2]|0)+(C<<2)>>2]>>2];f[f[(f[a>>2]|0)+(C<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){B=41;break a}}}while(0);c=f[o>>2]|0;if(!c){B=41;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){B=41;break}else{j=r;k=q;m=q}}if((B|0)==41)return}function Ad(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2980;i=c;f[a>>2]=i;return}case 2:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3036;i=c;f[a>>2]=i;return}case 4:{c=ln(152)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3092;h=c+96|0;b=c+40|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Zm(h);f[c+136>>2]=0;f[c+140>>2]=0;f[c+144>>2]=0;i=c;f[a>>2]=i;return}case 3:{c=ln(68)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3148;h=c+40|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(84)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=3204;f[c+40>>2]=0;f[c+44>>2]=0;f[c+56>>2]=0;f[c+60>>2]=0;f[c+64>>2]=0;h=c+68|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(120)|0;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];e=c+24|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=3260;f[c+44>>2]=0;f[c+48>>2]=0;e=c+52|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+40>>2]=3316;f[c+68>>2]=1;g=c+72|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+88|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function Bd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){o=d;while(1){e=f[o+4>>2]|0;if(!i)if(e>>>0>>0)p=e;else p=(e>>>0)%(c>>>0)|0;else p=e&h;if((p|0)==(k|0))break;q=(f[a>>2]|0)+(p<<2)|0;if(!(f[q>>2]|0))break b;e=f[o>>2]|0;c:do if(!e)r=o;else{s=o+8|0;t=b[s+11>>0]|0;u=t<<24>>24<0;v=t&255;t=u?f[o+12>>2]|0:v;w=(t|0)==0;if(u){u=o;x=e;while(1){y=x+8|0;z=b[y+11>>0]|0;A=z<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:z&255)|0)){r=u;break c}if(!w?Vk(f[s>>2]|0,A?f[y>>2]|0:y,t)|0:0){r=u;break c}y=f[x>>2]|0;if(!y){r=x;break c}else{A=x;x=y;u=A}}}if(w){u=o;x=e;while(1){A=b[x+8+11>>0]|0;if((A<<24>>24<0?f[x+12>>2]|0:A&255)|0){r=u;break c}A=f[x>>2]|0;if(!A){r=x;break c}else{y=x;x=A;u=y}}}u=o;x=e;while(1){w=x+8|0;y=b[w+11>>0]|0;A=y<<24>>24<0;if((t|0)!=((A?f[x+12>>2]|0:y&255)|0)){r=u;break c}y=A?f[w>>2]|0:w;if((b[y>>0]|0)==(f[s>>2]&255)<<24>>24){B=s;C=v;D=y}else{r=u;break c}while(1){C=C+-1|0;B=B+1|0;if(!C)break;D=D+1|0;if((b[B>>0]|0)!=(b[D>>0]|0)){r=u;break c}}y=f[x>>2]|0;if(!y){r=x;break}else{w=x;x=y;u=w}}}while(0);f[j>>2]=f[r>>2];f[r>>2]=f[f[(f[a>>2]|0)+(p<<2)>>2]>>2];f[f[(f[a>>2]|0)+(p<<2)>>2]>>2]=o;e=f[g>>2]|0;if(!e){E=43;break a}else o=e}d=f[o>>2]|0;if(!d){E=43;break a}else{g=o;j=o}}f[q>>2]=j;m=f[o>>2]|0;if(!m){E=43;break}else{k=p;l=o;n=o}}if((E|0)==43)return}function Cd(a,b,c,d,e,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;var i=0,j=0;switch(c|0){case 1:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2616;i=c;f[a>>2]=i;return}case 2:{c=ln(40)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2672;i=c;f[a>>2]=i;return}case 4:{c=ln(152)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2728;h=c+96|0;b=c+40|0;j=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));Zm(h);f[c+136>>2]=0;f[c+140>>2]=0;f[c+144>>2]=0;i=c;f[a>>2]=i;return}case 3:{c=ln(68)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2784;h=c+40|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;f[h+12>>2]=0;f[h+16>>2]=0;f[h+20>>2]=0;f[h+24>>2]=0;i=c;f[a>>2]=i;return}case 5:{c=ln(84)|0;f[c+4>>2]=d;h=c+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[h+12>>2]=f[e+12>>2];h=c+24|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];f[c>>2]=2840;f[c+40>>2]=0;f[c+44>>2]=0;f[c+56>>2]=0;f[c+60>>2]=0;f[c+64>>2]=0;h=c+68|0;f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];f[h+12>>2]=f[g+12>>2];i=c;f[a>>2]=i;return}case 6:{c=ln(120)|0;f[c+4>>2]=d;d=c+8|0;f[d>>2]=f[e>>2];f[d+4>>2]=f[e+4>>2];f[d+8>>2]=f[e+8>>2];f[d+12>>2]=f[e+12>>2];e=c+24|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c>>2]=2896;f[c+44>>2]=0;f[c+48>>2]=0;e=c+52|0;f[e>>2]=f[g>>2];f[e+4>>2]=f[g+4>>2];f[e+8>>2]=f[g+8>>2];f[e+12>>2]=f[g+12>>2];f[c+40>>2]=2952;f[c+68>>2]=1;g=c+72|0;f[g>>2]=-1;f[g+4>>2]=-1;f[g+8>>2]=-1;f[g+12>>2]=-1;wn(c+88|0);i=c;f[a>>2]=i;return}default:{i=0;f[a>>2]=i;return}}}function Dd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+48|0;d=c+8|0;e=c+4|0;g=c;h=a+44|0;ci(f[h>>2]|0,b)|0;if(f[h>>2]|0){wn(d);tk(d);i=(f[h>>2]|0)+-1|0;if((i|0)>-1){h=a+40|0;j=i;do{fj(d,(f[(f[h>>2]|0)+(j>>>5<<2)>>2]&1<<(j&31)|0)!=0);j=j+-1|0}while((j|0)>-1)}ld(d,b);Fj(d)}j=a+56|0;ci(f[j>>2]|0,b)|0;if(f[j>>2]|0){wn(d);tk(d);h=(f[j>>2]|0)+-2|0;if((h|0)>-1){j=a+52|0;i=h;do{fj(d,(f[(f[j>>2]|0)+(i>>>5<<2)>>2]&1<<(i&31)|0)!=0);h=i+1|0;fj(d,(f[(f[j>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)!=0);i=i+-2|0}while((i|0)>-1)}ld(d,b);Fj(d)}i=a+68|0;ci(f[i>>2]|0,b)|0;if(f[i>>2]|0){wn(d);tk(d);j=(f[i>>2]|0)+-3|0;if((j|0)>-1){i=a+64|0;h=j;do{fj(d,(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0)!=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d,g,g+4|0)|0;i=j;l=f[i+4>>2]|0;m=f[i>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function Fd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){g=l;c=m;j=n;b:while(1){c:do if(i){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=f[e>>2]|0;d:do if(!u)v=e;else{w=d[q>>1]|0;x=q+2|0;y=e;z=u;while(1){A=z+8|0;if(w<<16>>16!=(d[A>>1]|0)){v=y;break d}if((d[x>>1]|0)!=(d[A+2>>1]|0)){v=y;break d}A=f[z>>2]|0;if(!A){v=z;break}else{B=z;z=A;y=B}}}while(0);f[j>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}else{e=c;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(b>>>0)|0;if((D|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){r=e;s=D;t=u;break b}u=e+8|0;q=f[e>>2]|0;e:do if(!q)E=e;else{y=d[u>>1]|0;z=u+2|0;x=e;w=q;while(1){B=w+8|0;if(y<<16>>16!=(d[B>>1]|0)){E=x;break e}if((d[z>>1]|0)!=(d[B+2>>1]|0)){E=x;break e}B=f[w>>2]|0;if(!B){E=w;break}else{A=w;w=B;x=A}}}while(0);f[j>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}while(0);c=f[p>>2]|0;if(!c){C=39;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){C=39;break}else{k=s;l=r;n=r}}if((C|0)==39)return}function Gd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){g=l;d=m;j=n;b:while(1){c:do if(i){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0)){p=e;break c}q=(f[a>>2]|0)+(o<<2)|0;if(!(f[q>>2]|0)){r=e;s=o;t=q;break b}q=e+8|0;u=f[e>>2]|0;d:do if(!u)v=e;else{w=b[q>>0]|0;x=q+1|0;y=e;z=u;while(1){A=z+8|0;if(w<<24>>24!=(b[A>>0]|0)){v=y;break d}if((b[x>>0]|0)!=(b[A+1>>0]|0)){v=y;break d}A=f[z>>2]|0;if(!A){v=z;break}else{B=z;z=A;y=B}}}while(0);f[j>>2]=f[v>>2];f[v>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}else{e=d;while(1){u=f[e+4>>2]|0;if(u>>>0>>0)D=u;else D=(u>>>0)%(c>>>0)|0;if((D|0)==(k|0)){p=e;break c}u=(f[a>>2]|0)+(D<<2)|0;if(!(f[u>>2]|0)){r=e;s=D;t=u;break b}u=e+8|0;q=f[e>>2]|0;e:do if(!q)E=e;else{y=b[u>>0]|0;z=u+1|0;x=e;w=q;while(1){B=w+8|0;if(y<<24>>24!=(b[B>>0]|0)){E=x;break e}if((b[z>>0]|0)!=(b[B+1>>0]|0)){E=x;break e}B=f[w>>2]|0;if(!B){E=w;break}else{A=w;w=B;x=A}}}while(0);f[j>>2]=f[E>>2];f[E>>2]=f[f[(f[a>>2]|0)+(D<<2)>>2]>>2];f[f[(f[a>>2]|0)+(D<<2)>>2]>>2]=e;e=f[g>>2]|0;if(!e){C=39;break a}}}while(0);d=f[p>>2]|0;if(!d){C=39;break a}else{g=p;j=p}}f[t>>2]=j;m=f[r>>2]|0;if(!m){C=39;break}else{k=s;l=r;n=r}}if((C|0)==39)return}function Hd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;c=u;u=u+48|0;d=c+32|0;e=c+28|0;g=c+16|0;h=c;i=a+16|0;j=f[i>>2]|0;if(j|0){k=f[b>>2]|0;l=i;m=j;a:while(1){j=m;while(1){if((f[j+16>>2]|0)>=(k|0))break;n=f[j+4>>2]|0;if(!n){o=l;break a}else j=n}m=f[j>>2]|0;if(!m){o=j;break}else l=j}if((o|0)!=(i|0)?(k|0)>=(f[o+16>>2]|0):0){p=o;q=p+20|0;u=c;return q|0}}lp(g);f[h>>2]=f[b>>2];b=h+4|0;f[h+8>>2]=0;o=h+12|0;f[o>>2]=0;k=h+8|0;f[b>>2]=k;l=f[g>>2]|0;m=g+4|0;if((l|0)!=(m|0)){n=k;r=l;while(1){l=r+16|0;f[e>>2]=n;f[d>>2]=f[e>>2];ph(b,d,l,l)|0;l=f[r+4>>2]|0;if(!l){s=r+8|0;t=f[s>>2]|0;if((f[t>>2]|0)==(r|0))v=t;else{t=s;do{s=f[t>>2]|0;t=s+8|0;w=f[t>>2]|0}while((f[w>>2]|0)!=(s|0));v=w}}else{t=l;while(1){j=f[t>>2]|0;if(!j)break;else t=j}v=t}if((v|0)==(m|0))break;else r=v}}v=a+12|0;r=f[i>>2]|0;do if(r){d=f[h>>2]|0;e=a+16|0;n=r;while(1){l=f[n+16>>2]|0;if((d|0)<(l|0)){j=f[n>>2]|0;if(!j){x=23;break}else{y=n;z=j}}else{if((l|0)>=(d|0)){x=27;break}A=n+4|0;l=f[A>>2]|0;if(!l){x=26;break}else{y=A;z=l}}e=y;n=z}if((x|0)==23){B=n;C=n;break}else if((x|0)==26){B=n;C=A;break}else if((x|0)==27){B=n;C=e;break}}else{B=i;C=i}while(0);i=f[C>>2]|0;if(!i){x=ln(32)|0;f[x+16>>2]=f[h>>2];A=x+20|0;f[A>>2]=f[b>>2];z=x+24|0;y=f[h+8>>2]|0;f[z>>2]=y;r=f[o>>2]|0;f[x+28>>2]=r;if(!r)f[A>>2]=z;else{f[y+8>>2]=z;f[b>>2]=k;f[k>>2]=0;f[o>>2]=0}f[x>>2]=0;f[x+4>>2]=0;f[x+8>>2]=B;f[C>>2]=x;B=f[f[v>>2]>>2]|0;if(!B)D=x;else{f[v>>2]=B;D=f[C>>2]|0}Oe(f[a+16>>2]|0,D);D=a+20|0;f[D>>2]=(f[D>>2]|0)+1;E=x}else E=i;Ej(h+4|0,f[k>>2]|0);Ej(g,f[m>>2]|0);p=E;q=p+20|0;u=c;return q|0}function Id(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;d=b[c+11>>0]|0;e=d<<24>>24<0;g=e?f[c>>2]|0:c;i=e?f[c+4>>2]|0:d&255;if(i>>>0>3){d=g;c=i;e=i;while(1){j=X(h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24,1540483477)|0;c=(X(j>>>24^j,1540483477)|0)^(X(c,1540483477)|0);e=e+-4|0;if(e>>>0<=3)break;else d=d+4|0}d=i+-4|0;e=d&-4;k=d-e|0;l=g+(e+4)|0;m=c}else{k=i;l=g;m=i}switch(k|0){case 3:{n=h[l+2>>0]<<16^m;o=6;break}case 2:{n=m;o=6;break}case 1:{p=m;o=7;break}default:q=m}if((o|0)==6){p=h[l+1>>0]<<8^n;o=7}if((o|0)==7)q=X(p^h[l>>0],1540483477)|0;l=X(q>>>13^q,1540483477)|0;q=l>>>15^l;l=f[a+4>>2]|0;if(!l){r=0;return r|0}p=l+-1|0;n=(p&l|0)==0;if(!n)if(q>>>0>>0)s=q;else s=(q>>>0)%(l>>>0)|0;else s=q&p;m=f[(f[a>>2]|0)+(s<<2)>>2]|0;if(!m){r=0;return r|0}a=f[m>>2]|0;if(!a){r=0;return r|0}m=(i|0)==0;if(n){n=a;a:while(1){k=f[n+4>>2]|0;c=(k|0)==(q|0);if(!(c|(k&p|0)==(s|0))){r=0;o=40;break}do if(c?(k=n+8|0,e=b[k+11>>0]|0,d=e<<24>>24<0,j=e&255,((d?f[n+12>>2]|0:j)|0)==(i|0)):0){e=f[k>>2]|0;t=d?e:k;if(d){if(m){r=n;o=40;break a}if(!(Vk(t,g,i)|0)){r=n;o=40;break a}else break}if(m){r=n;o=40;break a}if((b[g>>0]|0)==(e&255)<<24>>24){e=k;k=j;j=g;do{k=k+-1|0;e=e+1|0;if(!k){r=n;o=40;break a}j=j+1|0}while((b[e>>0]|0)==(b[j>>0]|0))}}while(0);n=f[n>>2]|0;if(!n){r=0;o=40;break}}if((o|0)==40)return r|0}else u=a;b:while(1){a=f[u+4>>2]|0;do if((a|0)==(q|0)){n=u+8|0;p=b[n+11>>0]|0;c=p<<24>>24<0;j=p&255;if(((c?f[u+12>>2]|0:j)|0)==(i|0)){p=f[n>>2]|0;e=c?p:n;if(c){if(m){r=u;o=40;break b}if(!(Vk(e,g,i)|0)){r=u;o=40;break b}else break}if(m){r=u;o=40;break b}if((b[g>>0]|0)==(p&255)<<24>>24){p=n;n=j;j=g;do{n=n+-1|0;p=p+1|0;if(!n){r=u;o=40;break b}j=j+1|0}while((b[p>>0]|0)==(b[j>>0]|0))}}}else{if(a>>>0>>0)v=a;else v=(a>>>0)%(l>>>0)|0;if((v|0)!=(s|0)){r=0;o=40;break b}}while(0);u=f[u>>2]|0;if(!u){r=0;o=40;break}}if((o|0)==40)return r|0;return 0}function Jd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){e=k;c=l;i=m;b:while(1){c:do if(h){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(n<<2)|0;if(!(f[p>>2]|0)){q=d;r=n;s=p;break b}p=d+12|0;t=f[d>>2]|0;d:do if(!t)u=d;else{v=f[d+8>>2]|0;w=d;x=t;while(1){if((v|0)!=(f[x+8>>2]|0)){u=w;break d}if((f[p>>2]|0)!=(f[x+12>>2]|0)){u=w;break d}y=f[x>>2]|0;if(!y){u=x;break}else{z=x;x=y;w=z}}}while(0);f[i>>2]=f[u>>2];f[u>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){A=39;break a}}}else{d=c;while(1){p=f[d+4>>2]|0;if(p>>>0>>0)B=p;else B=(p>>>0)%(b>>>0)|0;if((B|0)==(j|0)){o=d;break c}p=(f[a>>2]|0)+(B<<2)|0;if(!(f[p>>2]|0)){q=d;r=B;s=p;break b}p=d+12|0;t=f[d>>2]|0;e:do if(!t)C=d;else{w=f[d+8>>2]|0;x=d;v=t;while(1){if((w|0)!=(f[v+8>>2]|0)){C=x;break e}if((f[p>>2]|0)!=(f[v+12>>2]|0)){C=x;break e}z=f[v>>2]|0;if(!z){C=v;break}else{y=v;v=z;x=y}}}while(0);f[i>>2]=f[C>>2];f[C>>2]=f[f[(f[a>>2]|0)+(B<<2)>>2]>>2];f[f[(f[a>>2]|0)+(B<<2)>>2]>>2]=d;d=f[e>>2]|0;if(!d){A=39;break a}}}while(0);c=f[o>>2]|0;if(!c){A=39;break a}else{e=o;i=o}}f[s>>2]=i;l=f[q>>2]|0;if(!l){A=39;break}else{j=r;k=q;m=q}}if((A|0)==39)return}function Kd(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;h=a+4|0;i=f[c>>2]|0;c=i;do if((i|0)!=(h|0)){j=i+16|0;k=b[j+11>>0]|0;l=k<<24>>24<0;m=l?f[i+20>>2]|0:k&255;k=b[g+11>>0]|0;n=k<<24>>24<0;o=n?f[g+4>>2]|0:k&255;k=m>>>0>>0;p=k?m:o;if((p|0)!=0?(q=Vk(n?f[g>>2]|0:g,l?f[j>>2]|0:j,p)|0,(q|0)!=0):0){if((q|0)<0)break}else r=4;if((r|0)==4?o>>>0>>0:0)break;q=o>>>0>>0?o:m;if((q|0)!=0?(m=Vk(l?f[j>>2]|0:j,n?f[g>>2]|0:g,q)|0,(m|0)!=0):0){if((m|0)>=0)r=37}else r=21;if((r|0)==21?!k:0)r=37;if((r|0)==37){f[d>>2]=c;f[e>>2]=c;s=e;return s|0}k=f[i+4>>2]|0;m=(k|0)==0;if(m){q=i+8|0;j=f[q>>2]|0;if((f[j>>2]|0)==(i|0))t=j;else{j=q;do{q=f[j>>2]|0;j=q+8|0;l=f[j>>2]|0}while((f[l>>2]|0)!=(q|0));t=l}}else{j=k;while(1){l=f[j>>2]|0;if(!l)break;else j=l}t=j}do if((t|0)!=(h|0)){k=t+16|0;l=b[k+11>>0]|0;q=l<<24>>24<0;p=q?f[t+20>>2]|0:l&255;l=p>>>0>>0?p:o;if((l|0)!=0?(u=Vk(n?f[g>>2]|0:g,q?f[k>>2]|0:k,l)|0,(u|0)!=0):0){if((u|0)<0)break}else r=31;if((r|0)==31?o>>>0

>>0:0)break;s=yg(a,d,g)|0;return s|0}while(0);if(m){f[d>>2]=c;s=i+4|0;return s|0}else{f[d>>2]=t;s=t;return s|0}}while(0);t=f[i>>2]|0;do if((f[a>>2]|0)==(i|0))v=c;else{if(!t){h=i;while(1){e=f[h+8>>2]|0;if((f[e>>2]|0)==(h|0))h=e;else{w=e;break}}}else{h=t;while(1){m=f[h+4>>2]|0;if(!m){w=h;break}else h=m}}h=w;m=w+16|0;e=b[g+11>>0]|0;o=e<<24>>24<0;n=o?f[g+4>>2]|0:e&255;e=b[m+11>>0]|0;j=e<<24>>24<0;p=j?f[w+20>>2]|0:e&255;e=n>>>0

>>0?n:p;if((e|0)!=0?(u=Vk(j?f[m>>2]|0:m,o?f[g>>2]|0:g,e)|0,(u|0)!=0):0){if((u|0)<0){v=h;break}}else r=13;if((r|0)==13?p>>>0>>0:0){v=h;break}s=yg(a,d,g)|0;return s|0}while(0);if(!t){f[d>>2]=i;s=i;return s|0}else{f[d>>2]=v;s=v+4|0;return s|0}return 0}function Ld(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a;h=b;i=h;j=c;k=d;l=k;if(!i){m=(e|0)!=0;if(!l){if(m){f[e>>2]=(g>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(g>>>0)/(j>>>0)>>>0;return (I=n,o)|0}else{if(!m){n=0;o=0;return (I=n,o)|0}f[e>>2]=a|0;f[e+4>>2]=b&0;n=0;o=0;return (I=n,o)|0}}m=(l|0)==0;do if(j){if(!m){p=(_(l|0)|0)-(_(i|0)|0)|0;if(p>>>0<=31){q=p+1|0;r=31-p|0;s=p-31>>31;t=q;u=g>>>(q>>>0)&s|i<>>(q>>>0)&s;w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}r=j-1|0;if(r&j|0){s=(_(j|0)|0)+33-(_(i|0)|0)|0;q=64-s|0;p=32-s|0;y=p>>31;z=s-32|0;A=z>>31;t=s;u=p-1>>31&i>>>(z>>>0)|(i<>>(s>>>0))&A;v=A&i>>>(s>>>0);w=g<>>(z>>>0))&y|g<>31;break}if(e|0){f[e>>2]=r&g;f[e+4>>2]=0}if((j|0)==1){n=h|b&0;o=a|0|0;return (I=n,o)|0}else{r=vm(j|0)|0;n=i>>>(r>>>0)|0;o=i<<32-r|g>>>(r>>>0)|0;return (I=n,o)|0}}else{if(m){if(e|0){f[e>>2]=(i>>>0)%(j>>>0);f[e+4>>2]=0}n=0;o=(i>>>0)/(j>>>0)>>>0;return (I=n,o)|0}if(!g){if(e|0){f[e>>2]=0;f[e+4>>2]=(i>>>0)%(l>>>0)}n=0;o=(i>>>0)/(l>>>0)>>>0;return (I=n,o)|0}r=l-1|0;if(!(r&l)){if(e|0){f[e>>2]=a|0;f[e+4>>2]=r&i|b&0}n=0;o=i>>>((vm(l|0)|0)>>>0);return (I=n,o)|0}r=(_(l|0)|0)-(_(i|0)|0)|0;if(r>>>0<=30){s=r+1|0;p=31-r|0;t=s;u=i<>>(s>>>0);v=i>>>(s>>>0);w=0;x=g<>2]=a|0;f[e+4>>2]=h|b&0;n=0;o=0;return (I=n,o)|0}while(0);if(!t){B=x;C=w;D=v;E=u;F=0;G=0}else{b=c|0|0;c=k|d&0;d=Vn(b|0,c|0,-1,-1)|0;k=I;h=x;x=w;w=v;v=u;u=t;t=0;do{a=h;h=x>>>31|h<<1;x=t|x<<1;g=v<<1|a>>>31|0;a=v>>>31|w<<1|0;Xn(d|0,k|0,g|0,a|0)|0;i=I;l=i>>31|((i|0)<0?-1:0)<<1;t=l&1;v=Xn(g|0,a|0,l&b|0,(((i|0)<0?-1:0)>>31|((i|0)<0?-1:0)<<1)&c|0)|0;w=I;u=u-1|0}while((u|0)!=0);B=h;C=x;D=w;E=v;F=0;G=t}t=C;C=0;if(e|0){f[e>>2]=E;f[e+4>>2]=D}n=(t|0)>>>31|(B|C)<<1|(C<<1|t>>>31)&0|F;o=(t<<1|0>>>31)&-2|G;return (I=n,o)|0}function Md(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=u;u=u+16|0;h=g;f[c+48>>2]=d;f[c+44>>2]=e;e=f[c+8>>2]|0;d=c+12|0;i=f[d>>2]|0;if((i|0)!=(e|0)){j=i;do{i=j+-4|0;f[d>>2]=i;k=f[i>>2]|0;f[i>>2]=0;if(k|0)Va[f[(f[k>>2]|0)+4>>2]&127](k);j=f[d>>2]|0}while((j|0)!=(e|0))}e=f[c+20>>2]|0;j=c+24|0;d=f[j>>2]|0;if((d|0)!=(e|0))f[j>>2]=d+(~((d+-4-e|0)>>>2)<<2);e=f[c+32>>2]|0;d=c+36|0;j=f[d>>2]|0;if((j|0)!=(e|0))f[d>>2]=j+(~((j+-4-e|0)>>>2)<<2);if(!(f[c+4>>2]|0)){e=ln(32)|0;f[h>>2]=e;f[h+8>>2]=-2147483616;f[h+4>>2]=23;l=e;m=15706;n=l+23|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[e+23>>0]=0;f[a>>2]=-1;pj(a+4|0,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}Ud(a,c);if(f[a>>2]|0){u=g;return}e=a+4|0;j=e+11|0;if((b[j>>0]|0)<0)Oq(f[e>>2]|0);Wi(a,c);if(f[a>>2]|0){u=g;return}if((b[j>>0]|0)<0)Oq(f[e>>2]|0);if(!(Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=29;l=j;m=15730;n=l+29|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+29>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(!(Qa[f[(f[c>>2]|0)+20>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=31;l=j;m=15760;n=l+31|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+31>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(!(Qa[f[(f[c>>2]|0)+24>>2]&127](c)|0)){j=ln(32)|0;f[h>>2]=j;f[h+8>>2]=-2147483616;f[h+4>>2]=31;l=j;m=15792;n=l+31|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[j+31>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}if(Qa[f[(f[c>>2]|0)+28>>2]&127](c)|0){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=g;return}c=ln(48)|0;f[h>>2]=c;f[h+8>>2]=-2147483600;f[h+4>>2]=34;l=c;m=15824;n=l+34|0;do{b[l>>0]=b[m>>0]|0;l=l+1|0;m=m+1|0}while((l|0)<(n|0));b[c+34>>0]=0;f[a>>2]=-1;pj(e,h);if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);u=g;return}function Nd(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;c=u;u=u+32|0;d=c+4|0;e=c;g=c+16|0;h=a+48|0;i=f[h>>2]|0;j=ln(32)|0;f[d>>2]=j;f[d+8>>2]=-2147483616;f[d+4>>2]=20;k=j;l=14538;m=k+20|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[j+20>>0]=0;j=Fk(i+24|0,d)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);i=f[h>>2]|0;n=ln(32)|0;f[d>>2]=n;f[d+8>>2]=-2147483616;f[d+4>>2]=22;k=n;l=14559;m=k+22|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[n+22>>0]=0;n=Fk(i+24|0,d)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);i=a+56|0;o=f[i>>2]|0;f[i>>2]=0;if(o|0)Va[f[(f[o>>2]|0)+4>>2]&127](o);o=f[a+52>>2]|0;p=(((f[o+100>>2]|0)-(f[o+96>>2]|0)|0)/12|0)>>>0<1e3;o=f[h>>2]|0;q=ln(32)|0;f[d>>2]=q;f[d+8>>2]=-2147483616;f[d+4>>2]=18;k=q;l=14582;m=k+18|0;do{b[k>>0]=b[l>>0]|0;k=k+1|0;l=l+1|0}while((k|0)<(m|0));b[q+18>>0]=0;q=Hk(o,d,-1)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);switch(q|0){case -1:{if(j?p|((mi(f[h>>2]|0)|0)>4|n^1):0)r=13;else r=17;break}case 0:{if(j)r=13;else r=21;break}case 2:{r=17;break}default:r=21}if((r|0)==13){j=f[a+44>>2]|0;b[g>>0]=0;n=j+16|0;h=f[n+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[n>>2]|0)>>>0>0)){f[e>>2]=f[j+4>>2];f[d>>2]=f[e>>2];Me(j,d,g,g+1|0)|0}j=ln(296)|0;_i(j);n=f[i>>2]|0;f[i>>2]=j;if(!n)s=j;else{Va[f[(f[n>>2]|0)+4>>2]&127](n);r=21}}else if((r|0)==17){n=f[a+44>>2]|0;b[g>>0]=2;j=n+16|0;h=f[j+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[j>>2]|0)>>>0>0)){f[e>>2]=f[n+4>>2];f[d>>2]=f[e>>2];Me(n,d,g,g+1|0)|0}g=ln(360)|0;xi(g);d=f[i>>2]|0;f[i>>2]=g;if(!d)s=g;else{Va[f[(f[d>>2]|0)+4>>2]&127](d);r=21}}if((r|0)==21){r=f[i>>2]|0;if(!r){t=0;u=c;return t|0}else s=r}t=Ra[f[(f[s>>2]|0)+8>>2]&127](s,a)|0;u=c;return t|0}function Od(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;e=b+12|0;g=f[e>>2]|0;h=c+4|0;i=(f[h>>2]|0)-g|0;j=c;f[j>>2]=(f[c>>2]|0)-g;f[j+4>>2]=i;i=(f[d>>2]|0)-g|0;j=d+4|0;k=(f[j>>2]|0)-g|0;g=d;f[g>>2]=i;f[g+4>>2]=k;g=f[e>>2]|0;if((((k|0)>-1?k:0-k|0)+((i|0)>-1?i:0-i|0)|0)>(g|0)){l=f[c>>2]|0;m=f[h>>2]|0;if((l|0)>-1)if((m|0)<=-1)if((l|0)<1){n=-1;o=-1}else p=6;else{n=1;o=1}else if((m|0)<1){n=-1;o=-1}else p=6;if((p|0)==6){n=(l|0)>0?1:-1;o=(m|0)>0?1:-1}q=X(g,n)|0;r=X(g,o)|0;g=(l<<1)-q|0;f[c>>2]=g;l=(m<<1)-r|0;f[h>>2]=l;if((X(n,o)|0)>-1){o=0-l|0;f[c>>2]=o;s=0-g|0;t=o}else{f[c>>2]=l;s=g;t=l}f[c>>2]=(t+q|0)/2|0;f[h>>2]=(s+r|0)/2|0;r=f[d>>2]|0;s=f[j>>2]|0;if((r|0)>-1)if((s|0)<=-1)if((r|0)<1){u=-1;v=-1}else p=14;else{u=1;v=1}else if((s|0)<1){u=-1;v=-1}else p=14;if((p|0)==14){u=(r|0)>0?1:-1;v=(s|0)>0?1:-1}q=f[e>>2]|0;e=X(q,u)|0;t=X(q,v)|0;q=(r<<1)-e|0;f[d>>2]=q;r=(s<<1)-t|0;f[j>>2]=r;if((X(u,v)|0)>-1){v=0-r|0;f[d>>2]=v;w=0-q|0;x=v}else{f[d>>2]=r;w=q;x=r}r=(x+e|0)/2|0;f[d>>2]=r;e=(w+t|0)/2|0;f[j>>2]=e;y=r;z=e}else{y=i;z=k}if(!y)if(!z){A=y;B=z}else p=22;else if((y|0)<0&(z|0)<1){A=y;B=z}else p=22;if((p|0)==22){if(!y)C=(z|0)==0?0:(z|0)>0?3:1;else C=(y|0)>0?(z>>31)+2|0:(z|0)<1?0:3;z=f[c>>2]|0;y=f[h>>2]|0;switch(C|0){case 1:{C=c;f[C>>2]=y;f[C+4>>2]=0-z;D=f[j>>2]|0;E=0-(f[d>>2]|0)|0;break}case 2:{C=c;f[C>>2]=0-z;f[C+4>>2]=0-y;D=0-(f[d>>2]|0)|0;E=0-(f[j>>2]|0)|0;break}case 3:{C=c;f[C>>2]=0-y;f[C+4>>2]=z;D=0-(f[j>>2]|0)|0;E=f[d>>2]|0;break}default:{C=c;f[C>>2]=z;f[C+4>>2]=y;D=f[d>>2]|0;E=f[j>>2]|0}}j=d;f[j>>2]=D;f[j+4>>2]=E;A=D;B=E}E=(f[c>>2]|0)-A|0;f[a>>2]=E;A=(f[h>>2]|0)-B|0;B=a+4|0;f[B>>2]=A;if((E|0)<0)F=(f[b+4>>2]|0)+E|0;else F=E;f[a>>2]=F;if((A|0)>=0){G=A;f[B>>2]=G;return}G=(f[b+4>>2]|0)+A|0;f[B>>2]=G;return}function Pd(a,b){a=a|0;b=b|0;var c=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;c=a+4|0;if(!b){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[c>>2]=0;return}if(b>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(b<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;g=f[c>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=b+-1|0;i=(h&b|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(b>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=c;c=f[g>>2]|0;if(!c)return;else{k=j;l=g;m=c;n=g}a:while(1){b:do if(i){g=l;c=m;j=n;while(1){e=c;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0))break;p=(f[a>>2]|0)+(o<<2)|0;if(!(f[p>>2]|0)){q=e;r=j;s=o;t=p;break b}p=e+8|0;u=e;while(1){v=f[u>>2]|0;if(!v)break;if((d[p>>1]|0)==(d[v+8>>1]|0))u=v;else break}f[j>>2]=v;f[u>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;p=f[g>>2]|0;if(!p){w=37;break a}else e=p}c=f[e>>2]|0;if(!c){w=37;break a}else{g=e;j=e}}}else{j=l;g=m;c=n;while(1){p=g;while(1){x=f[p+4>>2]|0;if(x>>>0>>0)y=x;else y=(x>>>0)%(b>>>0)|0;if((y|0)==(k|0))break;x=(f[a>>2]|0)+(y<<2)|0;if(!(f[x>>2]|0)){q=p;r=c;s=y;t=x;break b}x=p+8|0;z=p;while(1){A=f[z>>2]|0;if(!A)break;if((d[x>>1]|0)==(d[A+8>>1]|0))z=A;else break}f[c>>2]=A;f[z>>2]=f[f[(f[a>>2]|0)+(y<<2)>>2]>>2];f[f[(f[a>>2]|0)+(y<<2)>>2]>>2]=p;x=f[j>>2]|0;if(!x){w=37;break a}else p=x}g=f[p>>2]|0;if(!g){w=37;break a}else{j=p;c=p}}}while(0);f[t>>2]=r;m=f[q>>2]|0;if(!m){w=37;break}else{k=s;l=q;n=q}}if((w|0)==37)return}function Qd(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;else{k=j;l=g;m=d;n=g}a:while(1){b:do if(i){g=l;d=m;j=n;while(1){e=d;while(1){o=f[e+4>>2]&h;if((o|0)==(k|0))break;p=(f[a>>2]|0)+(o<<2)|0;if(!(f[p>>2]|0)){q=e;r=j;s=o;t=p;break b}p=e+8|0;u=e;while(1){v=f[u>>2]|0;if(!v)break;if((b[p>>0]|0)==(b[v+8>>0]|0))u=v;else break}f[j>>2]=v;f[u>>2]=f[f[(f[a>>2]|0)+(o<<2)>>2]>>2];f[f[(f[a>>2]|0)+(o<<2)>>2]>>2]=e;p=f[g>>2]|0;if(!p){w=37;break a}else e=p}d=f[e>>2]|0;if(!d){w=37;break a}else{g=e;j=e}}}else{j=l;g=m;d=n;while(1){p=g;while(1){x=f[p+4>>2]|0;if(x>>>0>>0)y=x;else y=(x>>>0)%(c>>>0)|0;if((y|0)==(k|0))break;x=(f[a>>2]|0)+(y<<2)|0;if(!(f[x>>2]|0)){q=p;r=d;s=y;t=x;break b}x=p+8|0;z=p;while(1){A=f[z>>2]|0;if(!A)break;if((b[x>>0]|0)==(b[A+8>>0]|0))z=A;else break}f[d>>2]=A;f[z>>2]=f[f[(f[a>>2]|0)+(y<<2)>>2]>>2];f[f[(f[a>>2]|0)+(y<<2)>>2]>>2]=p;x=f[j>>2]|0;if(!x){w=37;break a}else p=x}g=f[p>>2]|0;if(!g){w=37;break a}else{j=p;d=p}}}while(0);f[t>>2]=r;m=f[q>>2]|0;if(!m){w=37;break}else{k=s;l=q;n=q}}if((w|0)==37)return}function Rd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;g=f[c>>2]|0;c=f[b>>2]|0;h=g-c|0;i=a+8|0;j=f[i>>2]|0;if(h>>>0<64){if(j>>>0<=1){k=0;return k|0}l=f[e>>2]|0;m=0;n=1;while(1){o=(f[l+(m<<2)>>2]|0)>>>0>(f[l+(n<<2)>>2]|0)>>>0?n:m;n=n+1|0;if(n>>>0>=j>>>0){k=o;break}else m=o}return k|0}if(j){j=f[a+1128>>2]|0;m=f[e>>2]|0;e=f[a+1140>>2]|0;n=f[d>>2]|0;d=b+4|0;l=b+8|0;if((g|0)==(c|0)){b=0;do{o=j+(b<<2)|0;f[o>>2]=0;p=(f[a>>2]|0)-(f[m+(b<<2)>>2]|0)|0;f[e+(b<<2)>>2]=p;if(p|0){p=f[o>>2]|0;q=h-p|0;f[o>>2]=q>>>0

>>0?p:q}b=b+1|0;q=f[i>>2]|0}while(b>>>0>>0);r=q}else{b=0;do{q=j+(b<<2)|0;f[q>>2]=0;p=(f[a>>2]|0)-(f[m+(b<<2)>>2]|0)|0;f[e+(b<<2)>>2]=p;if(p|0){o=(f[n+(b<<2)>>2]|0)+(1<>2]|0;s=f[(f[d>>2]|0)+24>>2]|0;t=c;u=f[q>>2]|0;do{v=s+((X(t,p)|0)<<2)+(b<<2)|0;u=u+((f[v>>2]|0)>>>0>>0&1)|0;f[q>>2]=u;t=t+1|0}while((t|0)!=(g|0));t=h-u|0;f[q>>2]=t>>>0>>0?u:t}b=b+1|0;t=f[i>>2]|0}while(b>>>0>>0);r=t}if(r){b=f[a+1140>>2]|0;i=a+1128|0;h=0;g=0;c=0;while(1){if(!(f[b+(g<<2)>>2]|0)){w=h;x=c}else{d=f[(f[i>>2]|0)+(g<<2)>>2]|0;l=h>>>0>>0;w=l?d:h;x=l?g:c}g=g+1|0;if(g>>>0>=r>>>0){y=x;break}else{h=w;c=x}}}else y=0}else y=0;x=a+1088|0;c=a+1104|0;w=f[c>>2]|0;h=32-w|0;if((h|0)<4){r=y&15;g=4-h|0;f[c>>2]=g;h=a+1100|0;i=f[h>>2]|r>>>g;f[h>>2]=i;g=a+1092|0;b=f[g>>2]|0;if((b|0)==(f[a+1096>>2]|0))Ri(x,h);else{f[b>>2]=i;f[g>>2]=b+4}f[h>>2]=r<<32-(f[c>>2]|0);k=y;return k|0}r=a+1100|0;h=f[r>>2]|y<<28>>>w;f[r>>2]=h;b=w+4|0;f[c>>2]=b;if((b|0)!=32){k=y;return k|0}b=a+1092|0;w=f[b>>2]|0;if((w|0)==(f[a+1096>>2]|0))Ri(x,r);else{f[w>>2]=h;f[b>>2]=w+4}f[r>>2]=0;f[c>>2]=0;k=y;return k|0}function Sd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;c=a+4|0;if(!b){d=f[a>>2]|0;f[a>>2]=0;if(d|0)Oq(d);f[c>>2]=0;return}if(b>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}d=ln(b<<2)|0;e=f[a>>2]|0;f[a>>2]=d;if(e|0)Oq(e);f[c>>2]=b;c=0;do{f[(f[a>>2]|0)+(c<<2)>>2]=0;c=c+1|0}while((c|0)!=(b|0));c=a+8|0;e=f[c>>2]|0;if(!e)return;d=f[e+4>>2]|0;g=b+-1|0;h=(g&b|0)==0;if(!h)if(d>>>0>>0)i=d;else i=(d>>>0)%(b>>>0)|0;else i=d&g;f[(f[a>>2]|0)+(i<<2)>>2]=c;c=f[e>>2]|0;if(!c)return;else{j=i;k=e;l=c;m=e}a:while(1){b:do if(h){e=k;c=l;i=m;while(1){d=c;while(1){n=f[d+4>>2]&g;if((n|0)==(j|0))break;o=(f[a>>2]|0)+(n<<2)|0;if(!(f[o>>2]|0)){p=d;q=i;r=n;s=o;break b}o=d+8|0;t=d;while(1){u=f[t>>2]|0;if(!u)break;if((f[o>>2]|0)==(f[u+8>>2]|0))t=u;else break}f[i>>2]=u;f[t>>2]=f[f[(f[a>>2]|0)+(n<<2)>>2]>>2];f[f[(f[a>>2]|0)+(n<<2)>>2]>>2]=d;o=f[e>>2]|0;if(!o){v=37;break a}else d=o}c=f[d>>2]|0;if(!c){v=37;break a}else{e=d;i=d}}}else{i=k;e=l;c=m;while(1){o=e;while(1){w=f[o+4>>2]|0;if(w>>>0>>0)x=w;else x=(w>>>0)%(b>>>0)|0;if((x|0)==(j|0))break;w=(f[a>>2]|0)+(x<<2)|0;if(!(f[w>>2]|0)){p=o;q=c;r=x;s=w;break b}w=o+8|0;y=o;while(1){z=f[y>>2]|0;if(!z)break;if((f[w>>2]|0)==(f[z+8>>2]|0))y=z;else break}f[c>>2]=z;f[y>>2]=f[f[(f[a>>2]|0)+(x<<2)>>2]>>2];f[f[(f[a>>2]|0)+(x<<2)>>2]>>2]=o;w=f[i>>2]|0;if(!w){v=37;break a}else o=w}e=f[o>>2]|0;if(!e){v=37;break a}else{i=o;c=o}}}while(0);f[s>>2]=q;l=f[p>>2]|0;if(!l){v=37;break}else{j=r;k=p;m=p}}if((v|0)==37)return}function Td(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;d=a+4|0;if(!c){e=f[a>>2]|0;f[a>>2]=0;if(e|0)Oq(e);f[d>>2]=0;return}if(c>>>0>1073741823){e=ra(8)|0;Oo(e,16035);f[e>>2]=7256;va(e|0,1112,110)}e=ln(c<<2)|0;g=f[a>>2]|0;f[a>>2]=e;if(g|0)Oq(g);f[d>>2]=c;d=0;do{f[(f[a>>2]|0)+(d<<2)>>2]=0;d=d+1|0}while((d|0)!=(c|0));d=a+8|0;g=f[d>>2]|0;if(!g)return;e=f[g+4>>2]|0;h=c+-1|0;i=(h&c|0)==0;if(!i)if(e>>>0>>0)j=e;else j=(e>>>0)%(c>>>0)|0;else j=e&h;f[(f[a>>2]|0)+(j<<2)>>2]=d;d=f[g>>2]|0;if(!d)return;e=a+24|0;k=j;j=g;l=d;d=g;a:while(1){g=j;m=l;n=d;b:while(1){o=m;while(1){p=f[o+4>>2]|0;if(!i)if(p>>>0>>0)q=p;else q=(p>>>0)%(c>>>0)|0;else q=p&h;if((q|0)==(k|0))break;r=(f[a>>2]|0)+(q<<2)|0;if(!(f[r>>2]|0))break b;p=f[o>>2]|0;c:do if(!p)s=o;else{t=f[o+8>>2]|0;u=f[e>>2]|0;v=f[u+8>>2]|0;w=(f[u+12>>2]|0)-v|0;u=v;v=w>>>2;if((w|0)>0){x=o;y=p}else{w=p;while(1){z=f[w>>2]|0;if(!z){s=w;break c}else w=z}}while(1){w=f[y+8>>2]|0;z=0;do{A=f[u+(z<<2)>>2]|0;if(!(b[A+84>>0]|0)){B=f[A+68>>2]|0;C=f[B+(w<<2)>>2]|0;D=f[B+(t<<2)>>2]|0}else{C=w;D=t}z=z+1|0;if((D|0)!=(C|0)){s=x;break c}}while((z|0)<(v|0));z=f[y>>2]|0;if(!z){s=y;break}else{w=y;y=z;x=w}}}while(0);f[n>>2]=f[s>>2];f[s>>2]=f[f[(f[a>>2]|0)+(q<<2)>>2]>>2];f[f[(f[a>>2]|0)+(q<<2)>>2]>>2]=o;p=f[g>>2]|0;if(!p){E=38;break a}else o=p}m=f[o>>2]|0;if(!m){E=38;break a}else{g=o;n=o}}f[r>>2]=n;l=f[o>>2]|0;if(!l){E=38;break}else{k=q;j=o;d=o}}if((E|0)==38)return}function Ud(a,c){a=a|0;c=c|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0;e=u;u=u+16|0;g=e+4|0;h=e;i=e+12|0;j=e+11|0;k=e+10|0;l=e+8|0;m=c+44|0;n=f[m>>2]|0;o=n+16|0;p=f[o+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0)){f[h>>2]=f[n+4>>2];f[g>>2]=f[h>>2];Me(n,g,15886,15891)|0}n=Qa[f[(f[c>>2]|0)+8>>2]&127](c)|0;b[i>>0]=n;b[j>>0]=2;b[k>>0]=(n&255|0)==0?3:2;n=f[m>>2]|0;o=n+16|0;p=f[o+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0)){f[h>>2]=f[n+4>>2];f[g>>2]=f[h>>2];Me(n,g,j,j+1|0)|0;j=f[m>>2]|0;o=j+16|0;p=f[o+4>>2]|0;if(!((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0)){f[h>>2]=f[j+4>>2];f[g>>2]=f[h>>2];Me(j,g,k,k+1|0)|0;k=f[m>>2]|0;o=k+16|0;p=f[o+4>>2]|0;if((p|0)>0|(p|0)==0&(f[o>>2]|0)>>>0>0){q=h;r=k}else{f[h>>2]=f[k+4>>2];f[g>>2]=f[h>>2];Me(k,g,i,i+1|0)|0;q=h;r=f[m>>2]|0}}else{s=h;t=j;v=6}}else{s=h;t=n;v=6}if((v|0)==6){q=h;r=t}t=Qa[f[(f[c>>2]|0)+12>>2]&127](c)|0;b[l>>0]=t;t=r+16|0;q=f[t+4>>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p=m;q=l;r=o;break}else{p=0;q=0;r=0}while(0);k=a+8|0;g=f[k>>2]|0;o=a+12|0;if(!g)s=a+16|0;else{l=f[o>>2]|0;if((l|0)!=(g|0))f[o>>2]=l+(~((l+-4-g|0)>>>2)<<2);Oq(g);g=a+16|0;f[g>>2]=0;f[o>>2]=0;f[k>>2]=0;s=g}f[k>>2]=p;f[o>>2]=q;f[s>>2]=r;r=h>>>0>1073741823?-1:h<<2;s=Lq(r)|0;q=Lq(r)|0;r=c+48|0;o=f[r>>2]|0;g=c+40|0;a=f[g>>2]|0;l=f[c>>2]|0;kh(q|0,(f[l>>2]|0)+o|0,a|0)|0;kh(p|0,(f[l>>2]|0)+o|0,a|0)|0;a=r;r=f[a>>2]|0;o=f[a+4>>2]|0;a=g;g=f[a>>2]|0;l=f[a+4>>2]|0;a=f[c>>2]|0;kh(s|0,(f[a>>2]|0)+r|0,g|0)|0;p=f[c+80>>2]|0;a:do if(p>>>0>1){if(d<<24>>24<=0){c=1;while(1){m=un(g|0,l|0,c|0,0)|0;t=Vn(m|0,I|0,r|0,o|0)|0;kh(q|0,(f[a>>2]|0)+t|0,g|0)|0;c=c+1|0;if(c>>>0>=p>>>0)break a}}c=f[k>>2]|0;t=1;do{m=un(g|0,l|0,t|0,0)|0;v=Vn(m|0,I|0,r|0,o|0)|0;kh(q|0,(f[a>>2]|0)+v|0,g|0)|0;v=0;do{m=c+(v<<2)|0;w=$(n[m>>2]);x=q+(v<<2)|0;y=$(n[x>>2]);if(w>y){n[m>>2]=y;z=$(n[x>>2])}else z=y;x=s+(v<<2)|0;if($(n[x>>2])>2]=z;v=v+1|0}while((v|0)!=(h|0));t=t+1|0}while(t>>>0

>>0)}while(0);if(d<<24>>24>0){d=f[k>>2]|0;k=0;z=$(n[j>>2]);while(1){y=$(n[s+(k<<2)>>2]);w=$(y-$(n[d+(k<<2)>>2]));if(w>z){n[j>>2]=w;A=w}else A=z;k=k+1|0;if((k|0)==(h|0))break;else z=A}}Mq(q);Mq(s);i=1;u=e;return i|0}function Xd(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;g=a+8|0;Mh(g,b,d,e);h=d-e|0;if((h|0)>0){d=0-e|0;i=a+16|0;j=a+32|0;k=a+12|0;l=a+28|0;m=a+20|0;n=a+24|0;o=h;h=f[g>>2]|0;while(1){p=b+(o<<2)|0;q=c+(o<<2)|0;if((h|0)>0){r=0;s=p+(d<<2)|0;t=h;while(1){if((t|0)>0){u=0;do{v=f[s+(u<<2)>>2]|0;w=f[i>>2]|0;if((v|0)>(w|0)){x=f[j>>2]|0;f[x+(u<<2)>>2]=w;y=x}else{x=f[k>>2]|0;w=f[j>>2]|0;f[w+(u<<2)>>2]=(v|0)<(x|0)?x:v;y=w}u=u+1|0}while((u|0)<(f[g>>2]|0));z=y}else z=f[j>>2]|0;u=(f[p+(r<<2)>>2]|0)-(f[z+(r<<2)>>2]|0)|0;w=q+(r<<2)|0;f[w>>2]=u;if((u|0)>=(f[l>>2]|0)){if((u|0)>(f[n>>2]|0)){A=u-(f[m>>2]|0)|0;B=31}}else{A=(f[m>>2]|0)+u|0;B=31}if((B|0)==31){B=0;f[w>>2]=A}r=r+1|0;w=f[g>>2]|0;if((r|0)>=(w|0)){C=w;break}else{s=z;t=w}}}else C=h;o=o-e|0;if((o|0)<=0){D=C;break}else h=C}}else D=f[g>>2]|0;C=e>>>0>1073741823?-1:e<<2;e=Lq(C)|0;sj(e|0,0,C|0)|0;if((D|0)<=0){Mq(e);return 1}C=a+16|0;h=a+32|0;o=a+12|0;z=a+28|0;A=a+20|0;m=a+24|0;a=0;n=e;l=D;while(1){if((l|0)>0){D=0;do{j=f[n+(D<<2)>>2]|0;y=f[C>>2]|0;if((j|0)>(y|0)){k=f[h>>2]|0;f[k+(D<<2)>>2]=y;E=k}else{k=f[o>>2]|0;y=f[h>>2]|0;f[y+(D<<2)>>2]=(j|0)<(k|0)?k:j;E=y}D=D+1|0}while((D|0)<(f[g>>2]|0));F=E}else F=f[h>>2]|0;D=(f[b+(a<<2)>>2]|0)-(f[F+(a<<2)>>2]|0)|0;y=c+(a<<2)|0;f[y>>2]=D;if((D|0)>=(f[z>>2]|0)){if((D|0)>(f[m>>2]|0)){G=D-(f[A>>2]|0)|0;B=16}}else{G=(f[A>>2]|0)+D|0;B=16}if((B|0)==16){B=0;f[y>>2]=G}a=a+1|0;l=f[g>>2]|0;if((a|0)>=(l|0))break;else n=F}Mq(e);return 1}function Yd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;e=f[a>>2]|0;g=e;h=(f[b>>2]|0)-g|0;b=e+(h>>2<<2)|0;i=f[c>>2]|0;c=f[d>>2]|0;d=c-i|0;j=d>>2;k=i;l=c;if((d|0)<=0){m=b;return m|0}d=a+8|0;n=f[d>>2]|0;o=a+4|0;p=f[o>>2]|0;q=p;if((j|0)<=(n-q>>2|0)){r=b;s=q-r|0;t=s>>2;if((j|0)>(t|0)){u=k+(t<<2)|0;t=u;if((u|0)==(l|0))v=p;else{w=l+-4-t|0;x=u;u=p;while(1){f[u>>2]=f[x>>2];x=x+4|0;if((x|0)==(l|0))break;else u=u+4|0}u=p+((w>>>2)+1<<2)|0;f[o>>2]=u;v=u}if((s|0)>0){y=t;z=v}else{m=b;return m|0}}else{y=c;z=p}c=z-(b+(j<<2))>>2;v=b+(c<<2)|0;if(v>>>0

>>0){t=(p+(0-c<<2)+~r|0)>>>2;r=v;s=z;while(1){f[s>>2]=f[r>>2];r=r+4|0;if(r>>>0>=p>>>0)break;else s=s+4|0}f[o>>2]=z+(t+1<<2)}if(c|0){c=v;v=z;do{c=c+-4|0;v=v+-4|0;f[v>>2]=f[c>>2]}while((c|0)!=(b|0))}c=y;if((k|0)==(c|0)){m=b;return m|0}else{A=b;B=k}while(1){f[A>>2]=f[B>>2];B=B+4|0;if((B|0)==(c|0)){m=b;break}else A=A+4|0}return m|0}A=(q-g>>2)+j|0;if(A>>>0>1073741823)aq(a);j=n-g|0;g=j>>1;n=j>>2>>>0<536870911?(g>>>0>>0?A:g):1073741823;g=b;A=h>>2;do if(n)if(n>>>0>1073741823){j=ra(8)|0;Oo(j,16035);f[j>>2]=7256;va(j|0,1112,110)}else{j=ln(n<<2)|0;C=j;D=j;break}else{C=0;D=0}while(0);j=D+(A<<2)|0;A=D+(n<<2)|0;if((l|0)==(k|0))E=j;else{n=((l+-4-i|0)>>>2)+1|0;i=k;k=j;while(1){f[k>>2]=f[i>>2];i=i+4|0;if((i|0)==(l|0))break;else k=k+4|0}E=j+(n<<2)|0}if((h|0)>0)kh(C|0,e|0,h|0)|0;h=q-g|0;if((h|0)>0){kh(E|0,b|0,h|0)|0;F=E+(h>>>2<<2)|0}else F=E;f[a>>2]=D;f[o>>2]=F;f[d>>2]=A;if(!e){m=j;return m|0}Oq(e);m=j;return m|0}function Zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+48|0;d=c+40|0;e=c+36|0;g=c+32|0;h=c;i=a+60|0;ci(f[i>>2]|0,b)|0;wn(h);tk(h);j=f[a+56>>2]|0;k=f[i>>2]|0;i=k>>>5;l=j+(i<<2)|0;m=k&31;k=(i|0)!=0;a:do if(i|m|0){if(!m){n=1;o=j;p=k;while(1){if(p){q=n;r=0;while(1){s=(f[o>>2]&1<>2]&1<>2]&1<>2]&1<>2]=f[a+12>>2];m=b+16|0;w=m;v=f[w>>2]|0;j=f[w+4>>2]|0;if((j|0)>0|(j|0)==0&v>>>0>0){x=j;y=v}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;v=m;x=f[v+4>>2]|0;y=f[v>>2]|0}f[g>>2]=f[a+20>>2];if((x|0)>0|(x|0)==0&y>>>0>0){Fj(h);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(h);u=c;return 1}function _d(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;switch(b-a>>2|0){case 2:{d=b+-4|0;e=f[d>>2]|0;g=f[a>>2]|0;h=f[c>>2]|0;i=f[h>>2]|0;j=(f[h+4>>2]|0)-i>>3;if(j>>>0<=e>>>0)aq(h);k=i;if(j>>>0<=g>>>0)aq(h);if((f[k+(e<<3)>>2]|0)>>>0>=(f[k+(g<<3)>>2]|0)>>>0){l=1;return l|0}f[a>>2]=e;f[d>>2]=g;l=1;return l|0}case 3:{Vg(a,a+4|0,b+-4|0,c)|0;l=1;return l|0}case 4:{jh(a,a+4|0,a+8|0,b+-4|0,c)|0;l=1;return l|0}case 5:{ig(a,a+4|0,a+8|0,a+12|0,b+-4|0,c)|0;l=1;return l|0}case 1:case 0:{l=1;return l|0}default:{g=a+8|0;Vg(a,a+4|0,g,c)|0;d=a+12|0;a:do if((d|0)!=(b|0)){e=f[c>>2]|0;k=f[e>>2]|0;h=(f[e+4>>2]|0)-k>>3;j=k;k=d;i=0;m=g;b:while(1){n=f[k>>2]|0;o=f[m>>2]|0;if(h>>>0<=n>>>0){p=14;break}if(h>>>0<=o>>>0){p=16;break}q=j+(n<<3)|0;if((f[q>>2]|0)>>>0<(f[j+(o<<3)>>2]|0)>>>0){r=m;s=k;t=o;while(1){f[s>>2]=t;if((r|0)==(a|0)){u=a;break}o=r+-4|0;t=f[o>>2]|0;if(h>>>0<=t>>>0){p=20;break b}if((f[q>>2]|0)>>>0>=(f[j+(t<<3)>>2]|0)>>>0){u=r;break}else{v=r;r=o;s=v}}f[u>>2]=n;s=i+1|0;if((s|0)==8){w=0;x=(k+4|0)==(b|0);break a}else y=s}else y=i;s=k+4|0;if((s|0)==(b|0)){w=1;x=0;break a}else{r=k;k=s;i=y;m=r}}if((p|0)==14)aq(e);else if((p|0)==16)aq(e);else if((p|0)==20)aq(e)}else{w=1;x=0}while(0);l=x|w;return l|0}}return 0}function $d(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0;c=u;u=u+48|0;d=c+40|0;e=c+36|0;g=c+32|0;h=c;i=a+80|0;ci(f[i>>2]|0,b)|0;wn(h);tk(h);j=f[a+76>>2]|0;k=f[i>>2]|0;i=k>>>5;l=j+(i<<2)|0;m=k&31;k=(i|0)!=0;a:do if(i|m|0){if(!m){n=1;o=j;p=k;while(1){if(p){q=n;r=0;while(1){s=(f[o>>2]&1<>2]&1<>2]&1<>2]&1<>2]=f[a+12>>2];m=b+16|0;w=m;v=f[w>>2]|0;j=f[w+4>>2]|0;if((j|0)>0|(j|0)==0&v>>>0>0){x=j;y=v}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;v=m;x=f[v+4>>2]|0;y=f[v>>2]|0}f[g>>2]=f[a+16>>2];if((x|0)>0|(x|0)==0&y>>>0>0){Fj(h);u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;Fj(h);u=c;return 1}function ae(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;h=u;u=u+16|0;i=h+4|0;j=h;f[a+72>>2]=e;f[a+64>>2]=g;g=Lq(e>>>0>1073741823?-1:e<<2)|0;k=a+68|0;l=f[k>>2]|0;f[k>>2]=g;if(l|0)Mq(l);l=a+8|0;Mh(l,b,d,e);d=a+56|0;g=f[d>>2]|0;m=f[g+4>>2]|0;n=f[g>>2]|0;o=m-n|0;if((o|0)<=0){u=h;return 1}p=(o>>>2)+-1|0;o=a+16|0;q=a+32|0;r=a+12|0;s=a+28|0;t=a+20|0;v=a+24|0;if(m-n>>2>>>0>p>>>0){w=p;x=n}else{y=g;aq(y)}while(1){f[j>>2]=f[x+(w<<2)>>2];f[i>>2]=f[j>>2];Dc(a,i,b,w);g=X(w,e)|0;n=b+(g<<2)|0;p=c+(g<<2)|0;g=f[l>>2]|0;if((g|0)>0){m=0;z=f[k>>2]|0;A=g;while(1){if((A|0)>0){g=0;do{B=f[z+(g<<2)>>2]|0;C=f[o>>2]|0;if((B|0)>(C|0)){D=f[q>>2]|0;f[D+(g<<2)>>2]=C;E=D}else{D=f[r>>2]|0;C=f[q>>2]|0;f[C+(g<<2)>>2]=(B|0)<(D|0)?D:B;E=C}g=g+1|0}while((g|0)<(f[l>>2]|0));F=E}else F=f[q>>2]|0;g=(f[n+(m<<2)>>2]|0)-(f[F+(m<<2)>>2]|0)|0;C=p+(m<<2)|0;f[C>>2]=g;if((g|0)>=(f[s>>2]|0)){if((g|0)>(f[v>>2]|0)){G=g-(f[t>>2]|0)|0;H=21}}else{G=(f[t>>2]|0)+g|0;H=21}if((H|0)==21){H=0;f[C>>2]=G}m=m+1|0;A=f[l>>2]|0;if((m|0)>=(A|0))break;else z=F}}w=w+-1|0;if((w|0)<=-1){H=5;break}z=f[d>>2]|0;x=f[z>>2]|0;if((f[z+4>>2]|0)-x>>2>>>0<=w>>>0){y=z;H=6;break}}if((H|0)==5){u=h;return 1}else if((H|0)==6)aq(y);return 0} +function $a(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,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&16;l=k>>>j;k=l>>>5&8;n=l>>>k;l=n>>>2&4;i=n>>>l;n=i>>>1&2;h=i>>>n;i=h>>>1&1;s=f[19440+((k|j|l|n|i)+(h>>>i)<<2)>>2]|0;i=(f[s+4>>2]&-8)-d|0;h=f[s+16+(((f[s+16>>2]|0)==0&1)<<2)>>2]|0;if(!h){t=s;v=i}else{n=s;s=i;i=h;while(1){h=(f[i+4>>2]&-8)-d|0;l=h>>>0>>0;j=l?h:s;h=l?i:n;i=f[i+16+(((f[i+16>>2]|0)==0&1)<<2)>>2]|0;if(!i){t=h;v=j;break}else{n=h;s=j}}}s=t+d|0;if(s>>>0>t>>>0){n=f[t+24>>2]|0;i=f[t+12>>2]|0;do if((i|0)==(t|0)){j=t+20|0;h=f[j>>2]|0;if(!h){l=t+16|0;k=f[l>>2]|0;if(!k){w=0;break}else{x=k;y=l}}else{x=h;y=j}while(1){j=x+20|0;h=f[j>>2]|0;if(h|0){x=h;y=j;continue}j=x+16|0;h=f[j>>2]|0;if(!h)break;else{x=h;y=j}}f[y>>2]=0;w=x}else{j=f[t+8>>2]|0;f[j+12>>2]=i;f[i+8>>2]=j;w=i}while(0);do if(n|0){i=f[t+28>>2]|0;j=19440+(i<<2)|0;if((t|0)==(f[j>>2]|0)){f[j>>2]=w;if(!w){f[4785]=e&~(1<>2]|0)!=(t|0)&1)<<2)>>2]=w;if(!w)break}f[w+24>>2]=n;i=f[t+16>>2]|0;if(i|0){f[w+16>>2]=i;f[i+24>>2]=w}i=f[t+20>>2]|0;if(i|0){f[w+20>>2]=i;f[i+24>>2]=w}}while(0);if(v>>>0<16){n=v+d|0;f[t+4>>2]=n|3;e=t+n+4|0;f[e>>2]=f[e>>2]|1}else{f[t+4>>2]=d|3;f[s+4>>2]=v|1;f[s+v>>2]=v;if(m|0){e=f[4789]|0;n=m>>>3;i=19176+(n<<1<<2)|0;j=1<>2]|0;A=j}f[A>>2]=e;f[z+12>>2]=e;f[e+8>>2]=z;f[e+12>>2]=i}f[4786]=v;f[4789]=s}o=t+8|0;u=b;return o|0}else B=d}else B=d}else B=d}else if(a>>>0<=4294967231){i=a+11|0;e=i&-8;j=f[4785]|0;if(j){n=0-e|0;h=i>>>8;if(h)if(e>>>0>16777215)C=31;else{i=(h+1048320|0)>>>16&8;l=h<>>16&4;k=l<>>16&2;D=14-(h|i|l)+(k<>>15)|0;C=e>>>(D+7|0)&1|D<<1}else C=0;D=f[19440+(C<<2)>>2]|0;a:do if(!D){E=0;F=0;G=n;H=57}else{l=0;k=n;i=D;h=e<<((C|0)==31?0:25-(C>>>1)|0);I=0;while(1){J=(f[i+4>>2]&-8)-e|0;if(J>>>0>>0)if(!J){K=0;L=i;M=i;H=61;break a}else{N=i;O=J}else{N=l;O=k}J=f[i+20>>2]|0;i=f[i+16+(h>>>31<<2)>>2]|0;P=(J|0)==0|(J|0)==(i|0)?I:J;J=(i|0)==0;if(J){E=P;F=N;G=O;H=57;break}else{l=N;k=O;h=h<<((J^1)&1);I=P}}}while(0);if((H|0)==57){if((E|0)==0&(F|0)==0){D=2<>>12&16;d=D>>>n;D=d>>>5&8;s=d>>>D;d=s>>>2&4;g=s>>>d;s=g>>>1&2;m=g>>>s;g=m>>>1&1;Q=0;R=f[19440+((D|n|d|s|g)+(m>>>g)<<2)>>2]|0}else{Q=F;R=E}if(!R){S=Q;T=G}else{K=G;L=R;M=Q;H=61}}if((H|0)==61)while(1){H=0;g=(f[L+4>>2]&-8)-e|0;m=g>>>0>>0;s=m?g:K;g=m?L:M;L=f[L+16+(((f[L+16>>2]|0)==0&1)<<2)>>2]|0;if(!L){S=g;T=s;break}else{K=s;M=g;H=61}}if((S|0)!=0?T>>>0<((f[4786]|0)-e|0)>>>0:0){g=S+e|0;if(g>>>0<=S>>>0){o=0;u=b;return o|0}s=f[S+24>>2]|0;m=f[S+12>>2]|0;do if((m|0)==(S|0)){d=S+20|0;n=f[d>>2]|0;if(!n){D=S+16|0;I=f[D>>2]|0;if(!I){U=0;break}else{V=I;W=D}}else{V=n;W=d}while(1){d=V+20|0;n=f[d>>2]|0;if(n|0){V=n;W=d;continue}d=V+16|0;n=f[d>>2]|0;if(!n)break;else{V=n;W=d}}f[W>>2]=0;U=V}else{d=f[S+8>>2]|0;f[d+12>>2]=m;f[m+8>>2]=d;U=m}while(0);do if(s){m=f[S+28>>2]|0;d=19440+(m<<2)|0;if((S|0)==(f[d>>2]|0)){f[d>>2]=U;if(!U){d=j&~(1<>2]|0)!=(S|0)&1)<<2)>>2]=U;if(!U){X=j;break}}f[U+24>>2]=s;d=f[S+16>>2]|0;if(d|0){f[U+16>>2]=d;f[d+24>>2]=U}d=f[S+20>>2]|0;if(d){f[U+20>>2]=d;f[d+24>>2]=U;X=j}else X=j}else X=j;while(0);do if(T>>>0>=16){f[S+4>>2]=e|3;f[g+4>>2]=T|1;f[g+T>>2]=T;j=T>>>3;if(T>>>0<256){s=19176+(j<<1<<2)|0;d=f[4784]|0;m=1<>2]|0;Z=m}f[Z>>2]=g;f[Y+12>>2]=g;f[g+8>>2]=Y;f[g+12>>2]=s;break}s=T>>>8;if(s)if(T>>>0>16777215)_=31;else{m=(s+1048320|0)>>>16&8;d=s<>>16&4;j=d<>>16&2;n=14-(s|m|d)+(j<>>15)|0;_=T>>>(n+7|0)&1|n<<1}else _=0;n=19440+(_<<2)|0;f[g+28>>2]=_;d=g+16|0;f[d+4>>2]=0;f[d>>2]=0;d=1<<_;if(!(X&d)){f[4785]=X|d;f[n>>2]=g;f[g+24>>2]=n;f[g+12>>2]=g;f[g+8>>2]=g;break}d=T<<((_|0)==31?0:25-(_>>>1)|0);j=f[n>>2]|0;while(1){if((f[j+4>>2]&-8|0)==(T|0)){H=97;break}$=j+16+(d>>>31<<2)|0;n=f[$>>2]|0;if(!n){H=96;break}else{d=d<<1;j=n}}if((H|0)==96){f[$>>2]=g;f[g+24>>2]=j;f[g+12>>2]=g;f[g+8>>2]=g;break}else if((H|0)==97){d=j+8|0;n=f[d>>2]|0;f[n+12>>2]=g;f[d>>2]=g;f[g+8>>2]=n;f[g+12>>2]=j;f[g+24>>2]=0;break}}else{n=T+e|0;f[S+4>>2]=n|3;d=S+n+4|0;f[d>>2]=f[d>>2]|1}while(0);o=S+8|0;u=b;return o|0}else B=e}else B=e}else B=-1;while(0);S=f[4786]|0;if(S>>>0>=B>>>0){T=S-B|0;$=f[4789]|0;if(T>>>0>15){_=$+B|0;f[4789]=_;f[4786]=T;f[_+4>>2]=T|1;f[$+S>>2]=T;f[$+4>>2]=B|3}else{f[4786]=0;f[4789]=0;f[$+4>>2]=S|3;T=$+S+4|0;f[T>>2]=f[T>>2]|1}o=$+8|0;u=b;return o|0}$=f[4787]|0;if($>>>0>B>>>0){T=$-B|0;f[4787]=T;S=f[4790]|0;_=S+B|0;f[4790]=_;f[_+4>>2]=T|1;f[S+4>>2]=B|3;o=S+8|0;u=b;return o|0}if(!(f[4902]|0)){f[4904]=4096;f[4903]=4096;f[4905]=-1;f[4906]=-1;f[4907]=0;f[4895]=0;f[4902]=c&-16^1431655768;aa=4096}else aa=f[4904]|0;c=B+48|0;S=B+47|0;T=aa+S|0;_=0-aa|0;aa=T&_;if(aa>>>0<=B>>>0){o=0;u=b;return o|0}X=f[4894]|0;if(X|0?(Y=f[4892]|0,Z=Y+aa|0,Z>>>0<=Y>>>0|Z>>>0>X>>>0):0){o=0;u=b;return o|0}b:do if(!(f[4895]&4)){X=f[4790]|0;c:do if(X){Z=19584;while(1){Y=f[Z>>2]|0;if(Y>>>0<=X>>>0?(ba=Z+4|0,(Y+(f[ba>>2]|0)|0)>>>0>X>>>0):0)break;Y=f[Z+8>>2]|0;if(!Y){H=118;break c}else Z=Y}j=T-$&_;if(j>>>0<2147483647){Y=Nl(j|0)|0;if((Y|0)==((f[Z>>2]|0)+(f[ba>>2]|0)|0))if((Y|0)==(-1|0))ca=j;else{da=j;ea=Y;H=135;break b}else{fa=Y;ga=j;H=126}}else ca=0}else H=118;while(0);do if((H|0)==118){X=Nl(0)|0;if((X|0)!=(-1|0)?(e=X,j=f[4903]|0,Y=j+-1|0,U=((Y&e|0)==0?0:(Y+e&0-j)-e|0)+aa|0,e=f[4892]|0,j=U+e|0,U>>>0>B>>>0&U>>>0<2147483647):0){Y=f[4894]|0;if(Y|0?j>>>0<=e>>>0|j>>>0>Y>>>0:0){ca=0;break}Y=Nl(U|0)|0;if((Y|0)==(X|0)){da=U;ea=X;H=135;break b}else{fa=Y;ga=U;H=126}}else ca=0}while(0);do if((H|0)==126){U=0-ga|0;if(!(c>>>0>ga>>>0&(ga>>>0<2147483647&(fa|0)!=(-1|0))))if((fa|0)==(-1|0)){ca=0;break}else{da=ga;ea=fa;H=135;break b}Y=f[4904]|0;X=S-ga+Y&0-Y;if(X>>>0>=2147483647){da=ga;ea=fa;H=135;break b}if((Nl(X|0)|0)==(-1|0)){Nl(U|0)|0;ca=0;break}else{da=X+ga|0;ea=fa;H=135;break b}}while(0);f[4895]=f[4895]|4;ha=ca;H=133}else{ha=0;H=133}while(0);if(((H|0)==133?aa>>>0<2147483647:0)?(ca=Nl(aa|0)|0,aa=Nl(0)|0,fa=aa-ca|0,ga=fa>>>0>(B+40|0)>>>0,!((ca|0)==(-1|0)|ga^1|ca>>>0>>0&((ca|0)!=(-1|0)&(aa|0)!=(-1|0))^1)):0){da=ga?fa:ha;ea=ca;H=135}if((H|0)==135){ca=(f[4892]|0)+da|0;f[4892]=ca;if(ca>>>0>(f[4893]|0)>>>0)f[4893]=ca;ca=f[4790]|0;do if(ca){ha=19584;while(1){ia=f[ha>>2]|0;ja=ha+4|0;ka=f[ja>>2]|0;if((ea|0)==(ia+ka|0)){H=143;break}fa=f[ha+8>>2]|0;if(!fa)break;else ha=fa}if(((H|0)==143?(f[ha+12>>2]&8|0)==0:0)?ea>>>0>ca>>>0&ia>>>0<=ca>>>0:0){f[ja>>2]=ka+da;fa=(f[4787]|0)+da|0;ga=ca+8|0;aa=(ga&7|0)==0?0:0-ga&7;ga=ca+aa|0;S=fa-aa|0;f[4790]=ga;f[4787]=S;f[ga+4>>2]=S|1;f[ca+fa+4>>2]=40;f[4791]=f[4906];break}if(ea>>>0<(f[4788]|0)>>>0)f[4788]=ea;fa=ea+da|0;S=19584;while(1){if((f[S>>2]|0)==(fa|0)){H=151;break}ga=f[S+8>>2]|0;if(!ga){la=19584;break}else S=ga}if((H|0)==151)if(!(f[S+12>>2]&8)){f[S>>2]=ea;ha=S+4|0;f[ha>>2]=(f[ha>>2]|0)+da;ha=ea+8|0;ga=ea+((ha&7|0)==0?0:0-ha&7)|0;ha=fa+8|0;aa=fa+((ha&7|0)==0?0:0-ha&7)|0;ha=ga+B|0;c=aa-ga-B|0;f[ga+4>>2]=B|3;do if((ca|0)!=(aa|0)){if((f[4789]|0)==(aa|0)){ba=(f[4786]|0)+c|0;f[4786]=ba;f[4789]=ha;f[ha+4>>2]=ba|1;f[ha+ba>>2]=ba;break}ba=f[aa+4>>2]|0;if((ba&3|0)==1){_=ba&-8;$=ba>>>3;d:do if(ba>>>0<256){T=f[aa+8>>2]|0;X=f[aa+12>>2]|0;if((X|0)==(T|0)){f[4784]=f[4784]&~(1<<$);break}else{f[T+12>>2]=X;f[X+8>>2]=T;break}}else{T=f[aa+24>>2]|0;X=f[aa+12>>2]|0;do if((X|0)==(aa|0)){U=aa+16|0;Y=U+4|0;j=f[Y>>2]|0;if(!j){e=f[U>>2]|0;if(!e){ma=0;break}else{na=e;oa=U}}else{na=j;oa=Y}while(1){Y=na+20|0;j=f[Y>>2]|0;if(j|0){na=j;oa=Y;continue}Y=na+16|0;j=f[Y>>2]|0;if(!j)break;else{na=j;oa=Y}}f[oa>>2]=0;ma=na}else{Y=f[aa+8>>2]|0;f[Y+12>>2]=X;f[X+8>>2]=Y;ma=X}while(0);if(!T)break;X=f[aa+28>>2]|0;Y=19440+(X<<2)|0;do if((f[Y>>2]|0)!=(aa|0)){f[T+16+(((f[T+16>>2]|0)!=(aa|0)&1)<<2)>>2]=ma;if(!ma)break d}else{f[Y>>2]=ma;if(ma|0)break;f[4785]=f[4785]&~(1<>2]=T;X=aa+16|0;Y=f[X>>2]|0;if(Y|0){f[ma+16>>2]=Y;f[Y+24>>2]=ma}Y=f[X+4>>2]|0;if(!Y)break;f[ma+20>>2]=Y;f[Y+24>>2]=ma}while(0);pa=aa+_|0;qa=_+c|0}else{pa=aa;qa=c}$=pa+4|0;f[$>>2]=f[$>>2]&-2;f[ha+4>>2]=qa|1;f[ha+qa>>2]=qa;$=qa>>>3;if(qa>>>0<256){ba=19176+($<<1<<2)|0;Z=f[4784]|0;Y=1<<$;if(!(Z&Y)){f[4784]=Z|Y;ra=ba;sa=ba+8|0}else{Y=ba+8|0;ra=f[Y>>2]|0;sa=Y}f[sa>>2]=ha;f[ra+12>>2]=ha;f[ha+8>>2]=ra;f[ha+12>>2]=ba;break}ba=qa>>>8;do if(!ba)ta=0;else{if(qa>>>0>16777215){ta=31;break}Y=(ba+1048320|0)>>>16&8;Z=ba<>>16&4;X=Z<<$;Z=(X+245760|0)>>>16&2;j=14-($|Y|Z)+(X<>>15)|0;ta=qa>>>(j+7|0)&1|j<<1}while(0);ba=19440+(ta<<2)|0;f[ha+28>>2]=ta;_=ha+16|0;f[_+4>>2]=0;f[_>>2]=0;_=f[4785]|0;j=1<>2]=ha;f[ha+24>>2]=ba;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}j=qa<<((ta|0)==31?0:25-(ta>>>1)|0);_=f[ba>>2]|0;while(1){if((f[_+4>>2]&-8|0)==(qa|0)){H=192;break}ua=_+16+(j>>>31<<2)|0;ba=f[ua>>2]|0;if(!ba){H=191;break}else{j=j<<1;_=ba}}if((H|0)==191){f[ua>>2]=ha;f[ha+24>>2]=_;f[ha+12>>2]=ha;f[ha+8>>2]=ha;break}else if((H|0)==192){j=_+8|0;ba=f[j>>2]|0;f[ba+12>>2]=ha;f[j>>2]=ha;f[ha+8>>2]=ba;f[ha+12>>2]=_;f[ha+24>>2]=0;break}}else{ba=(f[4787]|0)+c|0;f[4787]=ba;f[4790]=ha;f[ha+4>>2]=ba|1}while(0);o=ga+8|0;u=b;return o|0}else la=19584;while(1){ha=f[la>>2]|0;if(ha>>>0<=ca>>>0?(va=ha+(f[la+4>>2]|0)|0,va>>>0>ca>>>0):0)break;la=f[la+8>>2]|0}ga=va+-47|0;ha=ga+8|0;c=ga+((ha&7|0)==0?0:0-ha&7)|0;ha=ca+16|0;ga=c>>>0>>0?ca:c;c=ga+8|0;aa=da+-40|0;fa=ea+8|0;S=(fa&7|0)==0?0:0-fa&7;fa=ea+S|0;ba=aa-S|0;f[4790]=fa;f[4787]=ba;f[fa+4>>2]=ba|1;f[ea+aa+4>>2]=40;f[4791]=f[4906];aa=ga+4|0;f[aa>>2]=27;f[c>>2]=f[4896];f[c+4>>2]=f[4897];f[c+8>>2]=f[4898];f[c+12>>2]=f[4899];f[4896]=ea;f[4897]=da;f[4899]=0;f[4898]=c;c=ga+24|0;do{ba=c;c=c+4|0;f[c>>2]=7}while((ba+8|0)>>>0>>0);if((ga|0)!=(ca|0)){c=ga-ca|0;f[aa>>2]=f[aa>>2]&-2;f[ca+4>>2]=c|1;f[ga>>2]=c;ba=c>>>3;if(c>>>0<256){fa=19176+(ba<<1<<2)|0;S=f[4784]|0;j=1<>2]|0;xa=j}f[xa>>2]=ca;f[wa+12>>2]=ca;f[ca+8>>2]=wa;f[ca+12>>2]=fa;break}fa=c>>>8;if(fa)if(c>>>0>16777215)ya=31;else{j=(fa+1048320|0)>>>16&8;S=fa<>>16&4;ba=S<>>16&2;Z=14-(fa|j|S)+(ba<>>15)|0;ya=c>>>(Z+7|0)&1|Z<<1}else ya=0;Z=19440+(ya<<2)|0;f[ca+28>>2]=ya;f[ca+20>>2]=0;f[ha>>2]=0;S=f[4785]|0;ba=1<>2]=ca;f[ca+24>>2]=Z;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}ba=c<<((ya|0)==31?0:25-(ya>>>1)|0);S=f[Z>>2]|0;while(1){if((f[S+4>>2]&-8|0)==(c|0)){H=213;break}za=S+16+(ba>>>31<<2)|0;Z=f[za>>2]|0;if(!Z){H=212;break}else{ba=ba<<1;S=Z}}if((H|0)==212){f[za>>2]=ca;f[ca+24>>2]=S;f[ca+12>>2]=ca;f[ca+8>>2]=ca;break}else if((H|0)==213){ba=S+8|0;c=f[ba>>2]|0;f[c+12>>2]=ca;f[ba>>2]=ca;f[ca+8>>2]=c;f[ca+12>>2]=S;f[ca+24>>2]=0;break}}}else{c=f[4788]|0;if((c|0)==0|ea>>>0>>0)f[4788]=ea;f[4896]=ea;f[4897]=da;f[4899]=0;f[4793]=f[4902];f[4792]=-1;f[4797]=19176;f[4796]=19176;f[4799]=19184;f[4798]=19184;f[4801]=19192;f[4800]=19192;f[4803]=19200;f[4802]=19200;f[4805]=19208;f[4804]=19208;f[4807]=19216;f[4806]=19216;f[4809]=19224;f[4808]=19224;f[4811]=19232;f[4810]=19232;f[4813]=19240;f[4812]=19240;f[4815]=19248;f[4814]=19248;f[4817]=19256;f[4816]=19256;f[4819]=19264;f[4818]=19264;f[4821]=19272;f[4820]=19272;f[4823]=19280;f[4822]=19280;f[4825]=19288;f[4824]=19288;f[4827]=19296;f[4826]=19296;f[4829]=19304;f[4828]=19304;f[4831]=19312;f[4830]=19312;f[4833]=19320;f[4832]=19320;f[4835]=19328;f[4834]=19328;f[4837]=19336;f[4836]=19336;f[4839]=19344;f[4838]=19344;f[4841]=19352;f[4840]=19352;f[4843]=19360;f[4842]=19360;f[4845]=19368;f[4844]=19368;f[4847]=19376;f[4846]=19376;f[4849]=19384;f[4848]=19384;f[4851]=19392;f[4850]=19392;f[4853]=19400;f[4852]=19400;f[4855]=19408;f[4854]=19408;f[4857]=19416;f[4856]=19416;f[4859]=19424;f[4858]=19424;c=da+-40|0;ba=ea+8|0;ha=(ba&7|0)==0?0:0-ba&7;ba=ea+ha|0;ga=c-ha|0;f[4790]=ba;f[4787]=ga;f[ba+4>>2]=ga|1;f[ea+c+4>>2]=40;f[4791]=f[4906]}while(0);ea=f[4787]|0;if(ea>>>0>B>>>0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n(lb|0,mb|0,kb|0,jb|0)|0;Va=+W(+(Xa*Wa));jb=Vn(nb|0,I|0,~~Va>>>0|0,(+K(Va)>=1.0?(Va>0.0?~~+Y(+J(Va/4294967296.0),4294967295.0)>>>0:~~+W((Va-+(~~Va>>>0))/4294967296.0)>>>0):0)|0)|0;nb=f[r>>2]|0;if(!((nb|0)<=(jb|0)?!((nb|0)>=(jb|0)?(tb|0)<(f[U>>2]|0):0):0)){nb=r;f[nb>>2]=jb;f[nb+4>>2]=tb;b[V>>0]=qb;f[Z>>2]=hb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[k>>2]=f[v>>2];f[j>>2]=f[w>>2];Jf(aa,k,j);f[x>>2]=Ja;f[y>>2]=Ia;f[k>>2]=f[x>>2];f[j>>2]=f[y>>2];Jf(ba,k,j)}if(La)break;vb=b[Ha>>0]|0;nb=-1;jb=vb;while(1){kb=nb+-1|0;wb=Ma+kb|0;mb=jb;jb=b[wb>>0]|0;if((jb&255)<(mb&255))break;if((wb|0)==(n|0)){xb=84;break d}else nb=kb}kb=Ma+nb|0;if((jb&255)<(vb&255)){yb=Ha;zb=vb}else{mb=Ma;lb=Ha;while(1){ob=lb+-1|0;if((jb&255)<(h[mb+-2>>0]|0)){yb=ob;zb=1;break}else{Ab=lb;lb=ob;mb=Ab}}}b[wb>>0]=zb;b[yb>>0]=jb;if((nb|0)<-1){Bb=kb;Cb=Ha}else continue;while(1){mb=b[Bb>>0]|0;b[Bb>>0]=b[Cb>>0]|0;b[Cb>>0]=mb;mb=Bb+1|0;lb=Cb+-1|0;if(mb>>>0>>0){Bb=mb;Cb=lb}else continue d}}if(((xb|0)==84?(xb=0,fb):0)?(ib=b[n>>0]|0,b[n>>0]=vb,b[Ha>>0]=ib,Oa):0){ib=Na;kb=ma;do{nb=b[kb>>0]|0;b[kb>>0]=b[ib>>0]|0;b[ib>>0]=nb;kb=kb+1|0;ib=ib+-1|0}while(kb>>>0>>0)}if((hb|0)>=(Ka|0)){Ya=db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>2;k=h;a:while(1){l=(f[6952+(g<<2)>>2]|0)+k|0;h=5;while(1){if(h>>>0>=47){m=211;n=i;o=8;break}p=f[6760+(h<<2)>>2]|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0

>>0){o=106;break a}if((l|0)==(X(q,p)|0)){r=i;break}else h=h+1|0}b:do if((o|0)==8){c:while(1){o=0;h=(l>>>0)/(m>>>0)|0;do if(h>>>0>=m>>>0)if((l|0)!=(X(h,m)|0)){p=m+10|0;q=(l>>>0)/(p>>>0)|0;if(q>>>0>=p>>>0)if((l|0)!=(X(q,p)|0)){q=m+12|0;s=(l>>>0)/(q>>>0)|0;if(s>>>0>=q>>>0)if((l|0)!=(X(s,q)|0)){s=m+16|0;t=(l>>>0)/(s>>>0)|0;if(t>>>0>=s>>>0)if((l|0)!=(X(t,s)|0)){t=m+18|0;v=(l>>>0)/(t>>>0)|0;if(v>>>0>=t>>>0)if((l|0)!=(X(v,t)|0)){v=m+22|0;w=(l>>>0)/(v>>>0)|0;if(w>>>0>=v>>>0)if((l|0)!=(X(w,v)|0)){w=m+28|0;x=(l>>>0)/(w>>>0)|0;if(x>>>0>=w>>>0)if((l|0)==(X(x,w)|0)){y=w;z=9;A=n}else{x=m+30|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+36|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+40|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+42|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+46|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+52|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+58|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+60|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+66|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+70|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+72|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+78|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+82|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+88|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+96|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+100|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+102|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+106|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+108|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+112|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+120|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+126|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+130|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+136|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+138|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+142|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+148|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+150|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+156|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+162|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+166|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+168|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+172|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+178|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+180|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+186|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+190|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+192|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+196|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+198|0;B=(l>>>0)/(x>>>0)|0;if(B>>>0>>0){y=x;z=1;A=l;break}if((l|0)==(X(B,x)|0)){y=x;z=9;A=n;break}x=m+208|0;B=(l>>>0)/(x>>>0)|0;C=B>>>0>>0;D=(l|0)==(X(B,x)|0);y=C|D?x:m+210|0;z=C?1:D?9:0;A=C?l:n}else{y=w;z=1;A=l}}else{y=v;z=9;A=n}else{y=v;z=1;A=l}}else{y=t;z=9;A=n}else{y=t;z=1;A=l}}else{y=s;z=9;A=n}else{y=s;z=1;A=l}}else{y=q;z=9;A=n}else{y=q;z=1;A=l}}else{y=p;z=9;A=n}else{y=p;z=1;A=l}}else{y=m;z=9;A=n}else{y=m;z=1;A=l}while(0);switch(z&15){case 9:{r=A;break b;break}case 0:{m=y;n=A;o=8;break}default:break c}}if(!z)r=A;else{o=107;break a}}while(0);h=g+1|0;p=(h|0)==48;q=j+(p&1)|0;i=r;j=q;g=p?0:h;k=q*210|0}if((o|0)==106){f[d>>2]=l;E=l;break}else if((o|0)==107){f[d>>2]=l;E=A;break}}else{k=Hl(6760,6952,d,c)|0;E=f[k>>2]|0}while(0);u=b;return E|0}function db(a,c,d,e,g,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0.0,Ua=0.0,Va=0.0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0,mb=0,nb=0,ob=0,pb=0,qb=0,rb=0,sb=0,tb=0,ub=0,vb=0,wb=0,xb=0,yb=0,zb=0,Ab=0,Bb=0,Cb=0,Db=0,Eb=0,Fb=0,Gb=0;i=u;u=u+256|0;e=i+104|0;j=i+240|0;k=i+224|0;l=i+160|0;m=i+140|0;n=i+248|0;o=i+72|0;p=i+40|0;q=i+128|0;r=i;s=i+232|0;t=i+220|0;v=i+216|0;w=i+212|0;x=i+208|0;y=i+152|0;z=f[a+28>>2]|0;A=f[a+32>>2]|0;B=l;C=B+48|0;do{f[B>>2]=0;B=B+4|0}while((B|0)<(C|0));if(!g){D=0;E=0}else{Ci(l,g);D=f[l+12>>2]|0;E=f[l+16>>2]|0}B=l+16|0;C=E-D>>2;F=D;D=E;if(C>>>0>=g>>>0){if(C>>>0>g>>>0?(E=F+(g<<2)|0,(E|0)!=(D|0)):0)f[B>>2]=D+(~((D+-4-E|0)>>>2)<<2)}else Ci(l+12|0,g-C|0);C=l+24|0;E=l+28|0;D=f[E>>2]|0;B=f[C>>2]|0;F=D-B>>2;G=B;B=D;if(F>>>0>=g>>>0){if(F>>>0>g>>>0?(D=G+(g<<2)|0,(D|0)!=(B|0)):0)f[E>>2]=B+(~((B+-4-D|0)>>>2)<<2)}else Ci(C,g-F|0);F=l+36|0;C=l+40|0;D=f[C>>2]|0;B=f[F>>2]|0;E=D-B>>2;G=B;B=D;if(E>>>0>=g>>>0){if(E>>>0>g>>>0?(D=G+(g<<2)|0,(D|0)!=(B|0)):0)f[C>>2]=B+(~((B+-4-D|0)>>>2)<<2)}else Ci(F,g-E|0);f[m>>2]=0;E=m+4|0;f[E>>2]=0;f[m+8>>2]=0;F=(g|0)==0;do if(!F)if(g>>>0>1073741823)aq(m);else{D=g<<2;B=ln(D)|0;f[m>>2]=B;C=B+(g<<2)|0;f[m+8>>2]=C;sj(B|0,0,D|0)|0;f[E>>2]=C;break}while(0);C=a+136|0;D=a+140|0;B=f[D>>2]|0;G=f[C>>2]|0;H=B-G>>2;L=G;G=B;if(H>>>0>=g>>>0){if(H>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2]=lb;f[qb+(jb<<2)>>2]=lb<<1^lb>>31;jb=jb+1|0;if((jb|0)==(g|0)){rb=kb;sb=qb;break}else hb=kb}}else{rb=0;sb=f[_>>2]|0}while(0);mo(e,$,sb,g);ib=Zk(e)|0;hb=I;jb=Bm(e)|0;kb=I;Va=+wm(Aa,gb);lb=Vn(jb|0,kb|0,ib|0,hb|0)|0;Ta=+W(+(Va*Ua));hb=Vn(lb|0,I|0,~~Ta>>>0|0,(+K(Ta)>=1.0?(Ta>0.0?~~+Y(+J(Ta/4294967296.0),4294967295.0)>>>0:~~+W((Ta-+(~~Ta>>>0))/4294967296.0)>>>0):0)|0)|0;lb=f[r>>2]|0;if(!((lb|0)<=(hb|0)?!((lb|0)>=(hb|0)?(rb|0)<(f[U>>2]|0):0):0)){lb=r;f[lb>>2]=hb;f[lb+4>>2]=rb;b[V>>0]=ob;f[Z>>2]=fb;f[v>>2]=f[m>>2];f[w>>2]=f[E>>2];f[j>>2]=f[v>>2];f[e>>2]=f[w>>2];Jf(aa,j,e);f[x>>2]=Ha;f[y>>2]=Ga;f[j>>2]=f[x>>2];f[e>>2]=f[y>>2];Jf(ba,j,e)}if(Ja)break;tb=b[Fa>>0]|0;lb=-1;hb=tb;while(1){ib=lb+-1|0;ub=Ka+ib|0;kb=hb;hb=b[ub>>0]|0;if((hb&255)<(kb&255))break;if((ub|0)==(n|0)){vb=84;break d}else lb=ib}ib=Ka+lb|0;if((hb&255)<(tb&255)){wb=Fa;xb=tb}else{kb=Ka;jb=Fa;while(1){mb=jb+-1|0;if((hb&255)<(h[kb+-2>>0]|0)){wb=mb;xb=1;break}else{yb=jb;jb=mb;kb=yb}}}b[ub>>0]=xb;b[wb>>0]=hb;if((lb|0)<-1){zb=ib;Ab=Fa}else continue;while(1){kb=b[zb>>0]|0;b[zb>>0]=b[Ab>>0]|0;b[Ab>>0]=kb;kb=zb+1|0;jb=Ab+-1|0;if(kb>>>0>>0){zb=kb;Ab=jb}else continue d}}if(((vb|0)==84?(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>0)%3|0|0)==0?2:-1)+G|0;if((J|0)==-1)L=-1;else L=f[F+(J<<2)>>2]|0;if((H|0)!=(K|0)?!((H|0)==(L|0)|(K|0)==(L|0)):0){H=0;J=A;F=E;I=D;while(1){M=H+G|0;if(!(f[(f[e>>2]|0)+(M>>>5<<2)>>2]&1<<(M&31))){N=f[(f[a>>2]|0)+(M<<2)>>2]|0;f[g>>2]=N;if(!(f[F+(N>>>5<<2)>>2]&1<<(N&31))){O=0;P=J;Q=N}else{N=f[i>>2]|0;if((N|0)==(f[y>>2]|0))Ri(h,6140);else{f[N>>2]=-1;f[i>>2]=N+4}N=f[v>>2]|0;if((N|0)==(f[w>>2]|0))Ri(z,g);else{f[N>>2]=f[g>>2];f[v>>2]=N+4}N=f[l>>2]|0;R=f[j>>2]|0;if((N|0)==(R<<5|0)){if((N+1|0)<0){S=50;break a}T=R<<6;R=N+32&-32;vi(d,N>>>0<1073741823?(T>>>0>>0?R:T):2147483647);U=f[l>>2]|0}else U=N;f[l>>2]=U+1;N=(f[d>>2]|0)+(U>>>5<<2)|0;f[N>>2]=f[N>>2]&~(1<<(U&31));f[g>>2]=J;O=1;P=J+1|0;Q=J}N=f[d>>2]|0;T=N+(Q>>>5<<2)|0;f[T>>2]=f[T>>2]|1<<(Q&31);T=N;b:do if(O){R=M;while(1){if((R|0)==-1){S=64;break b}V=(f[e>>2]|0)+(R>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(R&31);V=f[g>>2]|0;f[(f[h>>2]|0)+(V<<2)>>2]=R;f[(f[a>>2]|0)+(R<<2)>>2]=V;V=R+1|0;W=((V>>>0)%3|0|0)==0?R+-2|0:V;do if((W|0)==-1)X=-1;else{V=f[(f[x>>2]|0)+(W<<2)>>2]|0;Y=V+1|0;if((V|0)==-1){X=-1;break}X=((Y>>>0)%3|0|0)==0?V+-2|0:Y}while(0);if((X|0)==(M|0))break;else R=X}}else{R=M;while(1){if((R|0)==-1){S=64;break b}W=(f[e>>2]|0)+(R>>>5<<2)|0;f[W>>2]=f[W>>2]|1<<(R&31);f[(f[h>>2]|0)+(f[g>>2]<<2)>>2]=R;W=R+1|0;Y=((W>>>0)%3|0|0)==0?R+-2|0:W;do if((Y|0)==-1)Z=-1;else{W=f[(f[x>>2]|0)+(Y<<2)>>2]|0;V=W+1|0;if((W|0)==-1){Z=-1;break}Z=((V>>>0)%3|0|0)==0?W+-2|0:V}while(0);if((Z|0)==(M|0))break;else R=Z}}while(0);c:do if((S|0)==64){S=0;if((M|0)==-1)break;R=(((M>>>0)%3|0|0)==0?2:-1)+M|0;if((R|0)==-1)break;Y=f[(f[x>>2]|0)+(R<<2)>>2]|0;if((Y|0)==-1)break;R=Y+(((Y>>>0)%3|0|0)==0?2:-1)|0;if((R|0)==-1)break;if(!O){Y=R;while(1){V=(f[e>>2]|0)+(Y>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(Y&31);V=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((V|0)==-1)break c;W=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((W|0)==-1)break c;Y=W+(((W>>>0)%3|0|0)==0?2:-1)|0;if((Y|0)==-1)break c}}Y=f[a>>2]|0;W=R;do{V=(f[e>>2]|0)+(W>>>5<<2)|0;f[V>>2]=f[V>>2]|1<<(W&31);f[Y+(W<<2)>>2]=f[g>>2];V=(((W>>>0)%3|0|0)==0?2:-1)+W|0;if((V|0)==-1)break c;_=f[(f[x>>2]|0)+(V<<2)>>2]|0;if((_|0)==-1)break c;W=_+(((_>>>0)%3|0|0)==0?2:-1)|0}while((W|0)!=-1)}while(0);$=P;aa=T;ba=N}else{$=J;aa=I;ba=F}if((H|0)<2){H=H+1|0;J=$;F=ba;I=aa}else{ca=$;da=aa;ea=ba;break}}}else{ca=A;da=D;ea=E}}else{ca=A;da=D;ea=E}C=C+1|0;B=f[a>>2]|0;if(C>>>0>=(((f[m>>2]|0)-B>>2>>>0)/3|0)>>>0){S=18;break}else{A=ca;D=da;E=ea}}if((S|0)==18){fa=da;ga=f[l>>2]|0;break}else if((S|0)==50)aq(d)}else{fa=q;ga=p}}else{fa=q;ga=p}while(0);p=a+44|0;f[p>>2]=0;a=fa;fa=ga>>>5;q=a+(fa<<2)|0;S=ga&31;ga=(fa|0)!=0;d:do if(fa|S|0)if(!S){l=a;da=0;ea=ga;while(1){e:do if(ea){if(!(f[l>>2]&1)){ca=da+1|0;f[p>>2]=ca;ha=ca}else ha=da;if(!(f[l>>2]&2)){ca=ha+1|0;f[p>>2]=ca;ia=ca}else ia=ha;if(!(f[l>>2]&4)){ca=ia+1|0;f[p>>2]=ca;ja=ca}else ja=ia;if(!(f[l>>2]&8)){ca=ja+1|0;f[p>>2]=ca;ka=ca}else ka=ja;if(!(f[l>>2]&16)){ca=ka+1|0;f[p>>2]=ca;la=ca}else la=ka;if(!(f[l>>2]&32)){ca=la+1|0;f[p>>2]=ca;ma=ca}else ma=la;if(!(f[l>>2]&64)){ca=ma+1|0;f[p>>2]=ca;na=ca}else na=ma;if(!(f[l>>2]&128)){ca=na+1|0;f[p>>2]=ca;oa=ca}else oa=na;if(!(f[l>>2]&256)){ca=oa+1|0;f[p>>2]=ca;pa=ca}else pa=oa;if(!(f[l>>2]&512)){ca=pa+1|0;f[p>>2]=ca;qa=ca}else qa=pa;if(!(f[l>>2]&1024)){ca=qa+1|0;f[p>>2]=ca;ra=ca}else ra=qa;if(!(f[l>>2]&2048)){ca=ra+1|0;f[p>>2]=ca;sa=ca}else sa=ra;if(!(f[l>>2]&4096)){ca=sa+1|0;f[p>>2]=ca;ta=ca}else ta=sa;if(!(f[l>>2]&8192)){ca=ta+1|0;f[p>>2]=ca;ua=ca}else ua=ta;if(!(f[l>>2]&16384)){ca=ua+1|0;f[p>>2]=ca;va=ca}else va=ua;if(!(f[l>>2]&32768)){ca=va+1|0;f[p>>2]=ca;wa=ca}else wa=va;if(!(f[l>>2]&65536)){ca=wa+1|0;f[p>>2]=ca;xa=ca}else xa=wa;if(!(f[l>>2]&131072)){ca=xa+1|0;f[p>>2]=ca;ya=ca}else ya=xa;if(!(f[l>>2]&262144)){ca=ya+1|0;f[p>>2]=ca;za=ca}else za=ya;if(!(f[l>>2]&524288)){ca=za+1|0;f[p>>2]=ca;Aa=ca}else Aa=za;if(!(f[l>>2]&1048576)){ca=Aa+1|0;f[p>>2]=ca;Ba=ca}else Ba=Aa;if(!(f[l>>2]&2097152)){ca=Ba+1|0;f[p>>2]=ca;Ca=ca}else Ca=Ba;if(!(f[l>>2]&4194304)){ca=Ca+1|0;f[p>>2]=ca;Da=ca}else Da=Ca;if(!(f[l>>2]&8388608)){ca=Da+1|0;f[p>>2]=ca;Ea=ca}else Ea=Da;if(!(f[l>>2]&16777216)){ca=Ea+1|0;f[p>>2]=ca;Fa=ca}else Fa=Ea;if(!(f[l>>2]&33554432)){ca=Fa+1|0;f[p>>2]=ca;Ga=ca}else Ga=Fa;if(!(f[l>>2]&67108864)){ca=Ga+1|0;f[p>>2]=ca;Ha=ca}else Ha=Ga;if(!(f[l>>2]&134217728)){ca=Ha+1|0;f[p>>2]=ca;Ia=ca}else Ia=Ha;if(!(f[l>>2]&268435456)){ca=Ia+1|0;f[p>>2]=ca;Ja=ca}else Ja=Ia;if(!(f[l>>2]&536870912)){ca=Ja+1|0;f[p>>2]=ca;Ka=ca}else Ka=Ja;if(!(f[l>>2]&1073741824)){ca=Ka+1|0;f[p>>2]=ca;La=ca}else La=Ka;if((f[l>>2]|0)<=-1){Ma=La;break}ca=La+1|0;f[p>>2]=ca;Ma=ca}else{ca=0;m=da;while(1){if(!(f[l>>2]&1<>2]=ba;Na=ba}else Na=m;if((ca|0)==31){Ma=Na;break e}ca=ca+1|0;if(!ca)break d;else m=Na}}while(0);l=l+4|0;if((q|0)==(l|0))break;else{da=Ma;ea=1}}}else{if(ga){ea=0;da=a;l=0;while(1){if(!(f[da>>2]&1)){m=l+1|0;f[p>>2]=m;Oa=m;Pa=m}else{Oa=l;Pa=ea}if(!(f[da>>2]&2)){m=Oa+1|0;f[p>>2]=m;Qa=m;Ra=m}else{Qa=Oa;Ra=Pa}if(!(f[da>>2]&4)){m=Qa+1|0;f[p>>2]=m;Sa=m;Ta=m}else{Sa=Qa;Ta=Ra}if(!(f[da>>2]&8)){m=Sa+1|0;f[p>>2]=m;Ua=m;Va=m}else{Ua=Sa;Va=Ta}if(!(f[da>>2]&16)){m=Ua+1|0;f[p>>2]=m;Wa=m;Xa=m}else{Wa=Ua;Xa=Va}if(!(f[da>>2]&32)){m=Wa+1|0;f[p>>2]=m;Ya=m;Za=m}else{Ya=Wa;Za=Xa}if(!(f[da>>2]&64)){m=Ya+1|0;f[p>>2]=m;_a=m;$a=m}else{_a=Ya;$a=Za}if(!(f[da>>2]&128)){m=_a+1|0;f[p>>2]=m;ab=m;bb=m}else{ab=_a;bb=$a}if(!(f[da>>2]&256)){m=ab+1|0;f[p>>2]=m;cb=m;db=m}else{cb=ab;db=bb}if(!(f[da>>2]&512)){m=cb+1|0;f[p>>2]=m;eb=m;fb=m}else{eb=cb;fb=db}if(!(f[da>>2]&1024)){m=eb+1|0;f[p>>2]=m;gb=m;hb=m}else{gb=eb;hb=fb}if(!(f[da>>2]&2048)){m=gb+1|0;f[p>>2]=m;ib=m;jb=m}else{ib=gb;jb=hb}if(!(f[da>>2]&4096)){m=ib+1|0;f[p>>2]=m;kb=m;lb=m}else{kb=ib;lb=jb}if(!(f[da>>2]&8192)){m=kb+1|0;f[p>>2]=m;mb=m;nb=m}else{mb=kb;nb=lb}if(!(f[da>>2]&16384)){m=mb+1|0;f[p>>2]=m;ob=m;pb=m}else{ob=mb;pb=nb}if(!(f[da>>2]&32768)){m=ob+1|0;f[p>>2]=m;qb=m;rb=m}else{qb=ob;rb=pb}if(!(f[da>>2]&65536)){m=qb+1|0;f[p>>2]=m;sb=m;tb=m}else{sb=qb;tb=rb}if(!(f[da>>2]&131072)){m=sb+1|0;f[p>>2]=m;ub=m;vb=m}else{ub=sb;vb=tb}if(!(f[da>>2]&262144)){m=ub+1|0;f[p>>2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,e)}if(Ia)break;vb=b[Ka>>0]|0;nb=-1;jb=vb;while(1){kb=nb+-1|0;wb=Na+kb|0;mb=jb;jb=b[wb>>0]|0;if((jb&255)<(mb&255))break;if((wb|0)==(n|0)){xb=84;break d}else nb=kb}kb=Na+nb|0;if((jb&255)<(vb&255)){yb=Ka;zb=vb}else{mb=Na;lb=Ka;while(1){ob=lb+-1|0;if((jb&255)<(h[mb+-2>>0]|0)){yb=ob;zb=1;break}else{Ab=lb;lb=ob;mb=Ab}}}b[wb>>0]=zb;b[yb>>0]=jb;if((nb|0)<-1){Bb=kb;Cb=Ka}else continue;while(1){mb=b[Bb>>0]|0;b[Bb>>0]=b[Cb>>0]|0;b[Cb>>0]=mb;mb=Bb+1|0;lb=Cb+-1|0;if(mb>>>0>>0){Bb=mb;Cb=lb}else continue d}}if(((xb|0)==84?(xb=0,fb):0)?(ib=b[n>>0]|0,b[n>>0]=vb,b[Ka>>0]=ib,cb):0){ib=bb;kb=ja;do{nb=b[kb>>0]|0;b[kb>>0]=b[ib>>0]|0;b[ib>>0]=nb;kb=kb+1|0;ib=ib+-1|0}while(kb>>>0>>0)}if((hb|0)>=(Fa|0)){Wa=db;Xa=Da;Ya=db;Za=Da;_a=Ma;$a=Ca;ab=Da;break}else hb=hb+1|0}}hb=f[V>>2]|0;Da=Vn(Ga|0,Ja|0,hb|0,((hb|0)<0)<<31>>31|0)|0;hb=La;f[hb>>2]=Da;f[hb+4>>2]=I;if(S){hb=f[aa>>2]|0;Da=f[C>>2]|0;Ca=0;do{Ma=f[hb+(Ca<<2)>>2]|0;f[Da+(Ca<<2)>>2]=Ma<<1^Ma>>31;Ca=Ca+1|0}while((Ca|0)!=(g|0));Db=Da}else Db=f[C>>2]|0;lo(e,_,Db,g);if((Fa|0)>0){Eb=a+40+(Aa*12|0)|0;Da=a+40+(Aa*12|0)+4|0;Ca=a+40+(Aa*12|0)+8|0;hb=0;do{La=f[Da>>2]|0;Ja=f[Ca>>2]|0;Ga=(La|0)==(Ja<<5|0);if(!(1<>0])){if(Ga){if((La+1|0)<0){xb=95;break b}Ma=Ja<<6;db=La+32&-32;vi(Eb,La>>>0<1073741823?(Ma>>>0>>0?db:Ma):2147483647);Fb=f[Da>>2]|0}else Fb=La;f[Da>>2]=Fb+1;Ma=(f[Eb>>2]|0)+(Fb>>>5<<2)|0;f[Ma>>2]=f[Ma>>2]|1<<(Fb&31)}else{if(Ga){if((La+1|0)<0){xb=100;break b}Ga=Ja<<6;Ja=La+32&-32;vi(Eb,La>>>0<1073741823?(Ga>>>0>>0?Ja:Ga):2147483647);Gb=f[Da>>2]|0}else Gb=La;f[Da>>2]=Gb+1;La=(f[Eb>>2]|0)+(Gb>>>5<<2)|0;f[La>>2]=f[La>>2]&~(1<<(Gb&31))}hb=hb+1|0}while((hb|0)<(Fa|0))}hb=f[$>>2]|0;Da=d+(Ba<<2)|0;Ca=f[za+4>>2]|0;Aa=f[hb>>2]|0;La=f[hb+4>>2]|0;f[j>>2]=f[za>>2];f[ca>>2]=Ca;f[k>>2]=Aa;f[da>>2]=La;Od(e,ba,j,k);f[Da>>2]=f[e>>2];f[Da+4>>2]=f[ea>>2];Da=f[fa>>2]|0;if(Da|0){La=f[ia>>2]|0;if((La|0)!=(Da|0))f[ia>>2]=La+(~((La+-4-Da|0)>>>2)<<2);Oq(Da)}Da=f[ga>>2]|0;if(Da|0){La=f[ha>>2]|0;if((La|0)!=(Da|0))f[ha>>2]=La+(~((La+-4-Da|0)>>>2)<<2);Oq(Da)}if((na|0)<=2){Hb=Za;Ib=Ya;break a}Da=f[B>>2]|0;wa=f[Da>>2]|0;La=oa+-1|0;if((f[Da+4>>2]|0)-wa>>2>>>0<=La>>>0){xa=Da;xb=18;break}else{Da=oa;oa=La;pa=$a;qa=_a;ra=ab;sa=Za;ta=Ya;ua=Xa;va=Wa;na=Da}}if((xb|0)==18)aq(xa);else if((xb|0)==95)aq(Eb);else if((xb|0)==100)aq(Eb)}else{Hb=M;Ib=N}while(0);if((g|0)>0)s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2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;la=ln(32)|0;f[d>>2]=la;f[x>>2]=-2147483616;f[q>>2]=17;ma=la;na=14495;oa=ma+17|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[la+17>>0]=0;pa=ka+16|0;qa=f[pa>>2]|0;if(qa){ra=pa;sa=qa;b:while(1){qa=sa;while(1){if((f[qa+16>>2]|0)>=(k|0))break;ta=f[qa+4>>2]|0;if(!ta){ua=ra;break b}else qa=ta}sa=f[qa>>2]|0;if(!sa){ua=qa;break}else ra=qa}if(((ua|0)!=(pa|0)?(k|0)>=(f[ua+16>>2]|0):0)?(ra=ua+20|0,(Jh(ra,d)|0)!=0):0)va=Hk(ra,d,-1)|0;else wa=17}else wa=17;if((wa|0)==17){wa=0;va=Hk(ka,d,-1)|0}if((b[w>>0]|0)<0)Oq(f[d>>2]|0);if((va|0)<1)xa=1;else{ra=f[(f[j>>2]|0)+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;sa=ln(32)|0;f[d>>2]=sa;f[z>>2]=-2147483616;f[A>>2]=19;ma=sa;na=14438;oa=ma+19|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[sa+19>>0]=0;ka=ra+16|0;pa=f[ka>>2]|0;if(pa){la=ka;ta=pa;c:while(1){pa=ta;while(1){if((f[pa+16>>2]|0)>=(k|0))break;ya=f[pa+4>>2]|0;if(!ya){za=la;break c}else pa=ya}ta=f[pa>>2]|0;if(!ta){za=pa;break}else la=pa}if((za|0)!=(ka|0)?(k|0)>=(f[za+16>>2]|0):0)Aa=za+20|0;else wa=29}else wa=29;if((wa|0)==29){wa=0;Aa=ra}if(!(Jh(Aa,d)|0))Ba=0;else{la=f[(f[j>>2]|0)+48>>2]|0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;ta=ln(32)|0;f[e>>2]=ta;f[X>>2]=-2147483616;f[Y>>2]=18;ma=ta;na=14458;oa=ma+18|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ta+18>>0]=0;ra=la+16|0;ka=f[ra>>2]|0;if(ka){sa=ra;qa=ka;d:while(1){ka=qa;while(1){if((f[ka+16>>2]|0)>=(k|0))break;ya=f[ka+4>>2]|0;if(!ya){Ca=sa;break d}else ka=ya}qa=f[ka>>2]|0;if(!qa){Ca=ka;break}else sa=ka}if((Ca|0)!=(ra|0)?(k|0)>=(f[Ca+16>>2]|0):0)Da=Ca+20|0;else wa=39}else wa=39;if((wa|0)==39){wa=0;Da=la}sa=(Jh(Da,e)|0)!=0;if((b[Z>>0]|0)<0)Oq(f[e>>2]|0);Ba=sa}if((b[B>>0]|0)<0)Oq(f[d>>2]|0);if(Ba){sa=ja+24|0;qa=b[sa>>0]|0;ta=qa<<24>>24;f[h>>2]=0;f[C>>2]=0;f[D>>2]=0;if(!(qa<<24>>24))Ea=0;else{if(qa<<24>>24<0){wa=48;break a}qa=ta<<2;pa=ln(qa)|0;f[h>>2]=pa;ya=pa+(ta<<2)|0;f[O>>2]=ya;sj(pa|0,0,qa|0)|0;f[C>>2]=ya;Ea=pa}pa=f[(f[j>>2]|0)+48>>2]|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;ya=ln(32)|0;f[i>>2]=ya;f[E>>2]=-2147483616;f[F>>2]=19;ma=ya;na=14438;oa=ma+19|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ya+19>>0]=0;la=b[sa>>0]|0;ra=la<<24>>24;qa=pa+16|0;ta=f[qa>>2]|0;if(ta){Fa=qa;Ga=ta;e:while(1){ta=Ga;while(1){if((f[ta+16>>2]|0)>=(k|0))break;Ha=f[ta+4>>2]|0;if(!Ha){Ia=Fa;break e}else ta=Ha}Ga=f[ta>>2]|0;if(!Ga){Ia=ta;break}else Fa=ta}if(((Ia|0)!=(qa|0)?(k|0)>=(f[Ia+16>>2]|0):0)?(Fa=Ia+20|0,(Jh(Fa,i)|0)!=0):0){Ga=Rg(Fa,i)|0;if((Ga|0)!=(Ia+24|0)){pj(d,Ga+28|0);Ga=b[M>>0]|0;Fa=Ga<<24>>24<0;if(!((Fa?f[N>>2]|0:Ga&255)|0))Ja=Ga;else{if(la<<24>>24>0){ya=Fa?f[d>>2]|0:d;Fa=0;do{Ka=$(bq(ya,e));ka=ya;ya=f[e>>2]|0;if((ka|0)==(ya|0))break;n[Ea+(Fa<<2)>>2]=Ka;Fa=Fa+1|0}while((Fa|0)<(ra|0));La=b[M>>0]|0}else La=Ga;Ja=La}if(Ja<<24>>24<0)Oq(f[d>>2]|0)}}else wa=69}else wa=69;if((wa|0)==69?(wa=0,Fa=Rg(pa,i)|0,(Fa|0)!=(pa+4|0)):0){pj(d,Fa+28|0);Fa=b[G>>0]|0;ya=Fa<<24>>24<0;if(!((ya?f[H>>2]|0:Fa&255)|0))Ma=Fa;else{if(la<<24>>24>0){qa=ya?f[d>>2]|0:d;ya=0;do{Ka=$(bq(qa,e));ka=qa;qa=f[e>>2]|0;if((ka|0)==(qa|0))break;n[Ea+(ya<<2)>>2]=Ka;ya=ya+1|0}while((ya|0)<(ra|0));Na=b[G>>0]|0}else Na=Fa;Ma=Na}if(Ma<<24>>24<0)Oq(f[d>>2]|0)}if((b[I>>0]|0)<0)Oq(f[i>>2]|0);ra=f[(f[j>>2]|0)+48>>2]|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;ya=ln(32)|0;f[d>>2]=ya;f[J>>2]=-2147483616;f[K>>2]=18;ma=ya;na=14458;oa=ma+18|0;do{b[ma>>0]=b[na>>0]|0;ma=ma+1|0;na=na+1|0}while((ma|0)<(oa|0));b[ya+18>>0]=0;na=ra+16|0;ma=f[na>>2]|0;do if(ma){oa=na;Fa=ma;f:while(1){qa=Fa;while(1){if((f[qa+16>>2]|0)>=(k|0))break;la=f[qa+4>>2]|0;if(!la){Pa=oa;break f}else qa=la}Fa=f[qa>>2]|0;if(!Fa){Pa=qa;break}else oa=qa}if((Pa|0)!=(na|0)?(k|0)>=(f[Pa+16>>2]|0):0){oa=Pa+20|0;if(!(Jh(oa,d)|0)){wa=91;break}Qa=$(sk(oa,d,$(1.0)))}else wa=91}else wa=91;while(0);if((wa|0)==91){wa=0;Qa=$(sk(ra,d,$(1.0)))}if((b[L>>0]|0)<0)Oq(f[d>>2]|0);Dl(g,va,f[h>>2]|0,b[sa>>0]|0,Qa);k=f[h>>2]|0;if(k|0){na=f[C>>2]|0;if((na|0)!=(k|0))f[C>>2]=na+(~((na+-4-k|0)>>>2)<<2);Oq(k)}}else Wd(g,ja,va)|0;k=f[P>>2]|0;if((k|0)==(f[Q>>2]|0))Cf(R,g);else{f[k>>2]=1196;f[k+4>>2]=f[s>>2];Ra=k+8|0;f[Ra>>2]=0;na=k+12|0;f[na>>2]=0;f[k+16>>2]=0;ma=(f[y>>2]|0)-(f[V>>2]|0)|0;ya=ma>>2;if(ya|0){if(ya>>>0>1073741823){wa=103;break a}oa=ln(ma)|0;f[na>>2]=oa;f[Ra>>2]=oa;f[k+16>>2]=oa+(ya<<2);ya=f[V>>2]|0;ma=(f[y>>2]|0)-ya|0;if((ma|0)>0){kh(oa|0,ya|0,ma|0)|0;f[na>>2]=oa+(ma>>>2<<2)}}f[k+20>>2]=f[W>>2];f[P>>2]=(f[P>>2]|0)+24}Qe(d,g,ja,m);k=f[S>>2]|0;if(k>>>0<(f[T>>2]|0)>>>0){ma=f[d>>2]|0;f[d>>2]=0;f[k>>2]=ma;f[S>>2]=k+4}else Ze(U,d);k=f[d>>2]|0;f[d>>2]=0;if(k|0){ma=k+88|0;oa=f[ma>>2]|0;f[ma>>2]=0;if(oa|0){ma=f[oa+8>>2]|0;if(ma|0){na=oa+12|0;if((f[na>>2]|0)!=(ma|0))f[na>>2]=ma;Oq(ma)}Oq(oa)}oa=f[k+68>>2]|0;if(oa|0){ma=k+72|0;na=f[ma>>2]|0;if((na|0)!=(oa|0))f[ma>>2]=na+(~((na+-4-oa|0)>>>2)<<2);Oq(oa)}oa=k+64|0;na=f[oa>>2]|0;f[oa>>2]=0;if(na|0){oa=f[na>>2]|0;if(oa|0){ma=na+4|0;if((f[ma>>2]|0)!=(oa|0))f[ma>>2]=oa;Oq(oa)}Oq(na)}Oq(k)}xa=0}f[g>>2]=1196;k=f[r>>2]|0;if(k|0){na=f[y>>2]|0;if((na|0)!=(k|0))f[y>>2]=na+(~((na+-4-k|0)>>>2)<<2);Oq(k)}if(xa|0){v=0;wa=169;break a}break}case 1:case 3:case 5:{k=ja+24|0;na=b[k>>0]|0;oa=na<<24>>24;f[g>>2]=0;f[_>>2]=0;f[aa>>2]=0;if(!(na<<24>>24))Sa=0;else{if(na<<24>>24<0){wa=137;break a}na=ln(oa<<2)|0;f[_>>2]=na;f[g>>2]=na;ma=na+(oa<<2)|0;f[a>>2]=ma;ya=oa;oa=na;while(1){f[oa>>2]=2147483647;ya=ya+-1|0;if(!ya)break;else oa=oa+4|0}f[_>>2]=ma;Sa=b[k>>0]|0}oa=Sa<<24>>24;f[h>>2]=0;f[ba>>2]=0;f[ca>>2]=0;if(!(Sa<<24>>24))Ta=0;else{if(Sa<<24>>24<0){wa=144;break a}ya=oa<<2;sa=ln(ya)|0;f[h>>2]=sa;ra=sa+(oa<<2)|0;f[da>>2]=ra;sj(sa|0,0,ya|0)|0;f[ba>>2]=ra;Ta=sa}sa=ja+80|0;ra=b[k>>0]|0;g:do if(!(f[sa>>2]|0))Ua=ra;else{ya=0;oa=ra;na=Ta;while(1){f[e>>2]=ya;f[d>>2]=f[e>>2];Qb(ja,d,oa,na)|0;Fa=b[k>>0]|0;if(Fa<<24>>24>0){ta=f[g>>2]|0;la=f[h>>2]|0;pa=Fa<<24>>24;Ga=0;do{ka=ta+(Ga<<2)|0;Ha=f[la+(Ga<<2)>>2]|0;if((f[ka>>2]|0)>(Ha|0))f[ka>>2]=Ha;Ga=Ga+1|0}while((Ga|0)<(pa|0))}pa=ya+1|0;if(pa>>>0>=(f[sa>>2]|0)>>>0){Ua=Fa;break g}ya=pa;oa=Fa;na=f[h>>2]|0}}while(0);if(Ua<<24>>24>0){sa=0;ja=Ua;while(1){ra=(f[g>>2]|0)+(sa<<2)|0;ma=f[ea>>2]|0;if((ma|0)==(f[fa>>2]|0)){Ri(ga,ra);Va=b[k>>0]|0}else{f[ma>>2]=f[ra>>2];f[ea>>2]=ma+4;Va=ja}sa=sa+1|0;if((sa|0)>=(Va<<24>>24|0))break;else ja=Va}}ja=f[h>>2]|0;if(ja|0){sa=f[ba>>2]|0;if((sa|0)!=(ja|0))f[ba>>2]=sa+(~((sa+-4-ja|0)>>>2)<<2);Oq(ja)}ja=f[g>>2]|0;if(ja|0){sa=f[_>>2]|0;if((sa|0)!=(ja|0))f[_>>2]=sa+(~((sa+-4-ja|0)>>>2)<<2);Oq(ja)}break}default:{}}ja=ha+1|0;sa=f[o>>2]|0;if(ja>>>0>=(f[p>>2]|0)-sa>>2>>>0){v=1;wa=169;break}k=f[j>>2]|0;ha=ja;ia=sa;t=f[k+4>>2]|0;l=k}if((wa|0)==48)aq(h);else if((wa|0)==103)aq(Ra);else if((wa|0)==137)aq(g);else if((wa|0)==144)aq(h);else if((wa|0)==169){u=c;return v|0}return 0}function hb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa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)|0;a:do if(T){if(z>>>0<3){U=f[w>>2]|0;f[U>>2]=V;$=f[g>>2]|0;if($>>>0>1){aa=1;ba=$;ca=V;while(1){ca=(ca|0)==(ba+-1|0)?0:ca+1|0;f[U+(aa<<2)>>2]=ca;aa=aa+1|0;da=f[g>>2]|0;if(aa>>>0>=da>>>0){ea=da;break}else ba=da}}else ea=$;if(!z){fa=99;break}else{ga=0;ha=ea}while(1){ba=(f[N>>2]|0)+((X(f[M>>2]|0,S+ga|0)|0)<<2)|0;if(!ha)ia=0;else{aa=0;do{ca=f[(f[w>>2]|0)+(aa<<2)>>2]|0;U=(f[a>>2]|0)-(f[(f[Y>>2]|0)+(ca<<2)>>2]|0)|0;do if(U|0){da=f[y>>2]|0;ja=32-da|0;ka=32-U|0;la=f[ba+(ca<<2)>>2]<(ja|0)){ma=la>>>ka;ka=U-ja|0;f[y>>2]=ka;ja=f[h>>2]|ma>>>ka;f[h>>2]=ja;ka=f[j>>2]|0;if((ka|0)==(f[m>>2]|0))Ri(n,h);else{f[ka>>2]=ja;f[j>>2]=ka+4}f[h>>2]=ma<<32-(f[y>>2]|0);break}ma=f[h>>2]|la>>>da;f[h>>2]=ma;la=da+U|0;f[y>>2]=la;if((la|0)!=32)break;la=f[j>>2]|0;if((la|0)==(f[m>>2]|0))Ri(n,h);else{f[la>>2]=ma;f[j>>2]=la+4}f[h>>2]=0;f[y>>2]=0}while(0);aa=aa+1|0;U=f[g>>2]|0}while(aa>>>0>>0);ia=U}ga=ga+1|0;if(ga>>>0>=z>>>0){fa=99;break a}else ha=ia}}$=Z+1|0;Ig(R+($*12|0)|0,f[R+(Z*12|0)>>2]|0,f[R+(Z*12|0)+4>>2]|0);aa=(f[(f[k>>2]|0)+($*12|0)>>2]|0)+(V<<2)|0;ba=(f[aa>>2]|0)+(1<>2]=ba;aa=f[A>>2]|0;U=f[B>>2]|0;b:do if((W|0)==(S|0))na=S;else{ca=f[O>>2]|0;if(!aa){if((f[ca+(V<<2)>>2]|0)>>>0>>0){na=W;break}else{oa=W;pa=S}while(1){la=oa;do{la=la+-1|0;if((pa|0)==(la|0)){na=pa;break b}ma=(f[P>>2]|0)+((X(la,U)|0)<<2)+(V<<2)|0}while((f[ma>>2]|0)>>>0>=ba>>>0);pa=pa+1|0;if((pa|0)==(la|0)){na=la;break b}else oa=la}}else{qa=W;ra=S}while(1){ma=ra;while(1){sa=ca+((X(ma,aa)|0)<<2)|0;if((f[sa+(V<<2)>>2]|0)>>>0>=ba>>>0){ta=qa;break}da=ma+1|0;if((da|0)==(qa|0)){na=qa;break b}else ma=da}while(1){ta=ta+-1|0;if((ma|0)==(ta|0)){na=ma;break b}ua=(f[P>>2]|0)+((X(ta,U)|0)<<2)|0;if((f[ua+(V<<2)>>2]|0)>>>0>>0){va=0;break}}do{la=sa+(va<<2)|0;da=ua+(va<<2)|0;ka=f[la>>2]|0;f[la>>2]=f[da>>2];f[da>>2]=ka;va=va+1|0}while((va|0)!=(aa|0));ra=ma+1|0;if((ra|0)==(ta|0)){na=ta;break}else qa=ta}}while(0);ba=(_(z|0)|0)^31;U=na-S|0;ca=W-na|0;ka=U>>>0>>0;if((U|0)!=(ca|0)){da=f[H>>2]|0;if(ka)f[I>>2]=f[I>>2]|1<<31-da;la=da+1|0;f[H>>2]=la;if((la|0)==32){la=f[J>>2]|0;if((la|0)==(f[K>>2]|0))Ri(L,I);else{f[la>>2]=f[I>>2];f[J>>2]=la+4}f[H>>2]=0;f[I>>2]=0}}la=z>>>1;do if(ka){da=f[C>>2]|0;ja=32-da|0;wa=32-ba|0;xa=la-U<(ja|0)){ya=xa>>>wa;wa=ba-ja|0;f[C>>2]=wa;ja=f[D>>2]|ya>>>wa;f[D>>2]=ja;wa=f[E>>2]|0;if((wa|0)==(f[F>>2]|0))Ri(G,D);else{f[wa>>2]=ja;f[E>>2]=wa+4}f[D>>2]=ya<<32-(f[C>>2]|0);break}ya=f[D>>2]|xa>>>da;f[D>>2]=ya;xa=da+ba|0;f[C>>2]=xa;if((xa|0)==32){xa=f[E>>2]|0;if((xa|0)==(f[F>>2]|0))Ri(G,D);else{f[xa>>2]=ya;f[E>>2]=xa+4}f[D>>2]=0;f[C>>2]=0}}else{xa=f[C>>2]|0;ya=32-xa|0;da=32-ba|0;wa=la-ca<(ya|0)){ja=wa>>>da;da=ba-ya|0;f[C>>2]=da;ya=f[D>>2]|ja>>>da;f[D>>2]=ya;da=f[E>>2]|0;if((da|0)==(f[F>>2]|0))Ri(G,D);else{f[da>>2]=ya;f[E>>2]=da+4}f[D>>2]=ja<<32-(f[C>>2]|0);break}ja=f[D>>2]|wa>>>xa;f[D>>2]=ja;wa=xa+ba|0;f[C>>2]=wa;if((wa|0)==32){wa=f[E>>2]|0;if((wa|0)==(f[F>>2]|0))Ri(G,D);else{f[wa>>2]=ja;f[E>>2]=wa+4}f[D>>2]=0;f[C>>2]=0}}while(0);ba=f[s>>2]|0;la=f[ba+(Z*12|0)>>2]|0;ka=la+(V<<2)|0;f[ka>>2]=(f[ka>>2]|0)+1;Ig(ba+($*12|0)|0,la,f[ba+(Z*12|0)+4>>2]|0);if((na|0)!=(S|0)){ba=f[o>>2]|0;la=f[t>>2]|0;ka=ba-la>>2;wa=f[v>>2]|0;ja=f[l>>2]|0;if((((ka|0)==0?0:(ka*113|0)+-1|0)|0)==(ja+wa|0)){Pc(e);za=f[v>>2]|0;Aa=f[l>>2]|0;Ba=f[o>>2]|0;Ca=f[t>>2]|0}else{za=wa;Aa=ja;Ba=ba;Ca=la}la=Aa+za|0;if((Ba|0)==(Ca|0))Da=0;else Da=(f[Ca+(((la>>>0)/113|0)<<2)>>2]|0)+(((la>>>0)%113|0)*36|0)|0;f[Da>>2]=S;la=Da+4|0;f[la>>2]=r;f[la+4>>2]=x;f[Da+12>>2]=na;f[Da+16>>2]=i;f[Da+20>>2]=aa;f[Da+24>>2]=V;f[Da+28>>2]=U;f[Da+32>>2]=Z;f[l>>2]=(f[l>>2]|0)+1}if((W|0)!=(na|0)){la=f[o>>2]|0;ba=f[t>>2]|0;ja=la-ba>>2;wa=f[v>>2]|0;ka=f[l>>2]|0;if((((ja|0)==0?0:(ja*113|0)+-1|0)|0)==(ka+wa|0)){Pc(e);Ea=f[v>>2]|0;Fa=f[l>>2]|0;Ga=f[o>>2]|0;Ha=f[t>>2]|0}else{Ea=wa;Fa=ka;Ga=la;Ha=ba}ba=Fa+Ea|0;if((Ga|0)==(Ha|0))Ia=0;else Ia=(f[Ha+(((ba>>>0)/113|0)<<2)>>2]|0)+(((ba>>>0)%113|0)*36|0)|0;f[Ia>>2]=na;f[Ia+4>>2]=i;f[Ia+8>>2]=aa;f[Ia+12>>2]=W;ba=Ia+16|0;f[ba>>2]=p;f[ba+4>>2]=q;f[Ia+24>>2]=V;f[Ia+28>>2]=ca;f[Ia+32>>2]=$;ba=(f[l>>2]|0)+1|0;f[l>>2]=ba;Ja=ba}else fa=99}else fa=99;while(0);if((fa|0)==99){fa=0;Ja=f[l>>2]|0}if(!Ja)break;else Q=Ja}}Ja=f[t>>2]|0;Q=f[v>>2]|0;Ia=Ja+(((Q>>>0)/113|0)<<2)|0;q=f[o>>2]|0;p=q;i=Ja;if((q|0)==(Ja|0)){Ka=0;La=0}else{na=(f[Ia>>2]|0)+(((Q>>>0)%113|0)*36|0)|0;Ka=na;La=na}na=Ia;Ia=La;c:while(1){La=Ia;do{Q=La;if((Ka|0)==(Q|0))break c;La=Q+36|0}while((La-(f[na>>2]|0)|0)!=4068);La=na+4|0;na=La;Ia=f[La>>2]|0}f[l>>2]=0;l=p-i>>2;if(l>>>0>2){i=Ja;do{Oq(f[i>>2]|0);i=(f[t>>2]|0)+4|0;f[t>>2]=i;Ma=f[o>>2]|0;Na=Ma-i>>2}while(Na>>>0>2);Oa=Na;Pa=i;Qa=Ma}else{Oa=l;Pa=Ja;Qa=q}switch(Oa|0){case 1:{Ra=56;fa=113;break}case 2:{Ra=113;fa=113;break}default:{}}if((fa|0)==113)f[v>>2]=Ra;if((Pa|0)!=(Qa|0)){Ra=Pa;do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ha=f[j>>2]|ka>>>ia;f[j>>2]=ha;ia=f[l>>2]|0;if((ia|0)==(f[o>>2]|0))Ri(p,j);else{f[ia>>2]=ha;f[l>>2]=ia+4}f[j>>2]=ka<<32-(f[A>>2]|0);break}ka=f[j>>2]|ja>>>ba;f[j>>2]=ka;ja=ba+W|0;f[A>>2]=ja;if((ja|0)!=32)break;ja=f[l>>2]|0;if((ja|0)==(f[o>>2]|0))Ri(p,j);else{f[ja>>2]=ka;f[l>>2]=ja+4}f[j>>2]=0;f[A>>2]=0}while(0);Z=Z+1|0;W=f[i>>2]|0}while(Z>>>0>>0);ga=W}ea=ea+1|0;if(ea>>>0>=U>>>0){da=87;break a}else fa=ga}}Y=V+1|0;Z=f[m>>2]|0;$=Z+(Y*12|0)|0;if(($|0)==(S|0))la=Z;else{Ig($,f[S>>2]|0,f[O+(V*12|0)+4>>2]|0);la=f[m>>2]|0}$=(f[la+(Y*12|0)>>2]|0)+(Q<<2)|0;Z=(f[$>>2]|0)+(1<>2]=Z;$=f[C>>2]|0;W=f[D>>2]|0;b:do if((T|0)==(P|0))ma=P;else{aa=f[L>>2]|0;if(!$){if((f[aa+(Q<<2)>>2]|0)>>>0>>0){ma=T;break}else{na=T;oa=P}while(1){ja=na;do{ja=ja+-1|0;if((oa|0)==(ja|0)){ma=oa;break b}ka=(f[M>>2]|0)+((X(ja,W)|0)<<2)+(Q<<2)|0}while((f[ka>>2]|0)>>>0>=Z>>>0);oa=oa+1|0;if((oa|0)==(ja|0)){ma=ja;break b}else na=ja}}else{pa=T;qa=P}while(1){ka=qa;while(1){ra=aa+((X(ka,$)|0)<<2)|0;if((f[ra+(Q<<2)>>2]|0)>>>0>=Z>>>0){sa=pa;break}ba=ka+1|0;if((ba|0)==(pa|0)){ma=pa;break b}else ka=ba}while(1){sa=sa+-1|0;if((ka|0)==(sa|0)){ma=ka;break b}ta=(f[M>>2]|0)+((X(sa,W)|0)<<2)|0;if((f[ta+(Q<<2)>>2]|0)>>>0>>0){ua=0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E=f[D>>2]|0;f[i>>2]=B;F=i+4|0;f[F>>2]=E;f[i+8>>2]=E<<2;G=i+12|0;H=X(E,B)|0;f[G>>2]=0;J=i+16|0;f[J>>2]=0;f[i+20>>2]=0;do if(H)if(H>>>0>1073741823)aq(G);else{K=H<<2;L=ln(K)|0;f[G>>2]=L;M=L+(H<<2)|0;f[i+20>>2]=M;sj(L|0,0,K|0)|0;f[J>>2]=M;N=L;break}else N=0;while(0);H=i+24|0;f[H>>2]=N;G=a+4|0;L=a+8|0;M=f[G>>2]|0;a:do if((f[L>>2]|0)!=(M|0)){K=j+4|0;O=j+8|0;P=j+8|0;Q=(B|0)==0;R=j+4|0;S=j+8|0;T=k+4|0;U=k+8|0;V=k+8|0;W=a+48|0;Y=j+8|0;Z=a+60|0;$=0;aa=0;ba=0;ca=0;da=M;ea=C;b:while(1){fa=f[(f[(f[ea+4>>2]|0)+8>>2]|0)+(f[da+(ca<<2)>>2]<<2)>>2]|0;switch(f[fa+28>>2]|0){case 1:case 3:case 5:case 2:case 4:case 6:{ga=fa;ha=aa;break}case 9:{ga=f[(f[Z>>2]|0)+(aa<<2)>>2]|0;ha=aa+1|0;break}default:{ia=0;break a}}if(!ga){ia=0;break a}c:do switch(f[ga+28>>2]|0){case 6:{if(Q){ja=ba;ka=ga+24|0;break c}fa=ga+84|0;la=ga+68|0;ma=ga+48|0;na=ga+40|0;oa=ga+24|0;pa=0;do{if(!(b[fa>>0]|0))qa=f[(f[la>>2]|0)+(pa<<2)>>2]|0;else qa=pa;ra=ma;sa=f[ra>>2]|0;ta=f[ra+4>>2]|0;ra=na;ua=un(f[ra>>2]|0,f[ra+4>>2]|0,qa|0,0)|0;ra=Vn(ua|0,I|0,sa|0,ta|0)|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,pa)|0)<<2)+($<<2)|0,(f[f[ga>>2]>>2]|0)+ra|0,b[oa>>0]<<2|0)|0;pa=pa+1|0}while((pa|0)!=(B|0));ja=ba;ka=oa;break}case 1:case 3:case 5:{oa=ga+24|0;pa=b[oa>>0]|0;na=pa<<24>>24;f[j>>2]=0;f[R>>2]=0;f[S>>2]=0;if(!(pa<<24>>24))va=0;else{if(pa<<24>>24<0){wa=24;break b}pa=na<<2;ma=ln(pa)|0;f[j>>2]=ma;la=ma+(na<<2)|0;f[Y>>2]=la;sj(ma|0,0,pa|0)|0;f[R>>2]=la;va=b[oa>>0]|0}la=va<<24>>24;f[k>>2]=0;f[T>>2]=0;f[U>>2]=0;if(!(va<<24>>24)){xa=0;ya=0}else{if(va<<24>>24<0){wa=30;break b}pa=la<<2;ma=ln(pa)|0;f[k>>2]=ma;na=ma+(la<<2)|0;f[V>>2]=na;sj(ma|0,0,pa|0)|0;f[T>>2]=na;xa=ma;ya=ma}if(Q){za=ya;Aa=xa}else{ma=ga+84|0;na=ga+68|0;pa=0;do{if(!(b[ma>>0]|0))Ba=f[(f[na>>2]|0)+(pa<<2)>>2]|0;else Ba=pa;la=f[j>>2]|0;f[g>>2]=Ba;fa=b[oa>>0]|0;f[e>>2]=f[g>>2];Qb(ga,e,fa,la)|0;la=b[oa>>0]|0;fa=la<<24>>24;if(la<<24>>24>0){la=f[j>>2]|0;ra=f[W>>2]|0;ta=f[k>>2]|0;sa=0;do{f[ta+(sa<<2)>>2]=(f[la+(sa<<2)>>2]|0)-(f[ra+(sa+ba<<2)>>2]|0);sa=sa+1|0}while((sa|0)<(fa|0));Ca=ta}else Ca=f[k>>2]|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,pa)|0)<<2)+($<<2)|0,Ca|0,fa<<2|0)|0;pa=pa+1|0}while(pa>>>0>>0);pa=f[k>>2]|0;za=pa;Aa=pa}pa=ba+(b[oa>>0]|0)|0;if(za|0){na=f[T>>2]|0;if((na|0)!=(za|0))f[T>>2]=na+(~((na+-4-za|0)>>>2)<<2);Oq(Aa)}na=f[j>>2]|0;if(na|0){ma=f[R>>2]|0;if((ma|0)!=(na|0))f[R>>2]=ma+(~((ma+-4-na|0)>>>2)<<2);Oq(na)}ja=pa;ka=oa;break}default:{pa=ga+24|0;na=b[pa>>0]|0;ma=na<<24>>24;f[j>>2]=0;f[K>>2]=0;f[O>>2]=0;if(!(na<<24>>24)){Da=0;Ea=0}else{if(na<<24>>24<0){wa=53;break b}na=ma<<2;ta=ln(na)|0;f[j>>2]=ta;sa=ta+(ma<<2)|0;f[P>>2]=sa;sj(ta|0,0,na|0)|0;f[K>>2]=sa;Da=ta;Ea=ta}if(Q){Fa=Ea;Ga=Da}else{ta=ga+84|0;sa=ga+68|0;na=0;do{if(!(b[ta>>0]|0))Ha=f[(f[sa>>2]|0)+(na<<2)>>2]|0;else Ha=na;ma=f[j>>2]|0;f[g>>2]=Ha;ra=b[pa>>0]|0;f[e>>2]=f[g>>2];Pb(ga,e,ra,ma)|0;kh((f[H>>2]|0)+((X(f[F>>2]|0,na)|0)<<2)+($<<2)|0,f[j>>2]|0,b[pa>>0]<<2|0)|0;na=na+1|0}while(na>>>0>>0);na=f[j>>2]|0;Fa=na;Ga=na}if(Fa|0){na=f[K>>2]|0;if((na|0)!=(Fa|0))f[K>>2]=na+(~((na+-4-Fa|0)>>>2)<<2);Oq(Ga)}ja=ba;ka=pa}}while(0);na=ca+1|0;sa=f[G>>2]|0;if(na>>>0>=(f[L>>2]|0)-sa>>2>>>0){wa=66;break}$=$+(b[ka>>0]|0)|0;aa=ha;ba=ja;ca=na;da=sa;ea=f[A>>2]|0}if((wa|0)==24)aq(j);else if((wa|0)==30)aq(k);else if((wa|0)==53)aq(j);else if((wa|0)==66){Ia=f[D>>2]|0;Ja=f[H>>2]|0;wa=67;break}}else{Ia=E;Ja=N;wa=67}while(0);d:do if((wa|0)==67){N=X(Ia,B)|0;if((N|0)>0){E=0;H=0;while(1){D=f[Ja+(E<<2)>>2]|0;if(!D)Ka=H;else{A=(_(D|0)|0)^31;Ka=(A|0)<(H|0)?H:A+1|0}E=E+1|0;if((E|0)>=(N|0)){La=Ka;break}else H=Ka}}else La=0;switch(b[h>>0]|0){case 6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ia);f[t>>2]=0;f[t+4>>2]=i;H=f[F>>2]|0;f[t+8>>2]=H;f[v>>2]=f[i>>2];f[v+4>>2]=i;f[v+8>>2]=H;f[k>>2]=La;f[g>>2]=f[t>>2];f[g+4>>2]=f[t+4>>2];f[g+8>>2]=f[t+8>>2];f[e>>2]=f[v>>2];f[e+4>>2]=f[v+4>>2];f[e+8>>2]=f[v+8>>2];H=Af(j,g,e,k,c)|0;ef(j);if(!H){ia=0;break d}break}case 1:{af(j,Ia);f[w>>2]=0;f[w+4>>2]=i;H=f[F>>2]|0;f[w+8>>2]=H;f[x>>2]=f[i>>2];f[x+4>>2]=i;f[x+8>>2]=H;f[k>>2]=La;f[g>>2]=f[w>>2];f[g+4>>2]=f[w+4>>2];f[g+8>>2]=f[w+8>>2];f[e>>2]=f[x>>2];f[e+4>>2]=f[x+4>>2];f[e+8>>2]=f[x+8>>2];H=zf(j,g,e,k,c)|0;df(j);if(!H){ia=0;break d}break}case 0:{af(j,Ia);f[y>>2]=0;f[y+4>>2]=i;H=f[F>>2]|0;f[y+8>>2]=H;f[z>>2]=f[i>>2];f[z+4>>2]=i;f[z+8>>2]=H;f[k>>2]=La;f[g>>2]=f[y>>2];f[g+4>>2]=f[y+4>>2];f[g+8>>2]=f[y+8>>2];f[e>>2]=f[z>>2];f[e+4>>2]=f[z+4>>2];f[e+8>>2]=f[z+8>>2];H=zf(j,g,e,k,c)|0;df(j);if(!H){ia=0;break d}break}default:{ia=0;break d}}ia=1}while(0);j=f[i+12>>2]|0;if(!j){u=d;return ia|0}i=f[J>>2]|0;if((i|0)!=(j|0))f[J>>2]=i+(~((i+-4-j|0)>>>2)<<2);Oq(j);u=d;return ia|0}function kb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=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+(1<>2]=W;V=f[A>>2]|0;P=f[B>>2]|0;b:do if((R|0)==(N|0))ia=N;else{Y=f[J>>2]|0;if(!V){if((f[Y+(Q<<2)>>2]|0)>>>0>>0){ia=R;break}else{ja=R;ka=N}while(1){ga=ja;do{ga=ga+-1|0;if((ka|0)==(ga|0)){ia=ka;break b}ha=(f[K>>2]|0)+((X(ga,P)|0)<<2)+(Q<<2)|0}while((f[ha>>2]|0)>>>0>=W>>>0);ka=ka+1|0;if((ka|0)==(ga|0)){ia=ga;break b}else ja=ga}}else{la=R;ma=N}while(1){ha=ma;while(1){na=Y+((X(ha,V)|0)<<2)|0;if((f[na+(Q<<2)>>2]|0)>>>0>=W>>>0){oa=la;break}Z=ha+1|0;if((Z|0)==(la|0)){ia=la;break b}else ha=Z}while(1){oa=oa+-1|0;if((ha|0)==(oa|0)){ia=ha;break b}pa=(f[K>>2]|0)+((X(oa,P)|0)<<2)|0;if((f[pa+(Q<<2)>>2]|0)>>>0>>0){qa=0;break}}do{ga=na+(qa<<2)|0;Z=pa+(qa<<2)|0;fa=f[ga>>2]|0;f[ga>>2]=f[Z>>2];f[Z>>2]=fa;qa=qa+1|0}while((qa|0)!=(V|0));ma=ha+1|0;if((ma|0)==(oa|0)){ia=oa;break}else la=oa}}while(0);W=(_(z|0)|0)^31;P=ia-N|0;Y=R-ia|0;fa=P>>>0>>0;if((P|0)!=(Y|0)){Z=f[C>>2]|0;if(fa)f[D>>2]=f[D>>2]|1<<31-Z;ga=Z+1|0;f[C>>2]=ga;if((ga|0)==32){ga=f[E>>2]|0;if((ga|0)==(f[F>>2]|0))Ri(G,D);else{f[ga>>2]=f[D>>2];f[E>>2]=ga+4}f[C>>2]=0;f[D>>2]=0}}ga=z>>>1;if(fa){fa=ga-P|0;if(W|0){Z=0;ea=1<>>1}}}else{ea=ga-Y|0;if(W|0){Z=0;fa=1<>>1}}}fa=f[s>>2]|0;W=f[fa+(T*12|0)>>2]|0;Z=W+(Q<<2)|0;f[Z>>2]=(f[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0:Z+1|0;f[Q+(W<<2)>>2]=Z;W=W+1|0;$=f[g>>2]|0;if(W>>>0>=$>>>0){aa=$;break}else Y=$}}else aa=V;if(!z){ba=81;break}else{ca=0;da=aa}while(1){Y=(f[J>>2]|0)+((X(f[I>>2]|0,O+ca|0)|0)<<2)|0;if(!da)ea=0;else{W=0;do{Z=f[(f[w>>2]|0)+(W<<2)>>2]|0;Q=(f[a>>2]|0)-(f[(f[T>>2]|0)+(Z<<2)>>2]|0)|0;do if(Q|0){$=f[y>>2]|0;fa=32-$|0;ga=32-Q|0;ha=f[Y+(Z<<2)>>2]<(fa|0)){ia=ha>>>ga;ga=Q-fa|0;f[y>>2]=ga;fa=f[h>>2]|ia>>>ga;f[h>>2]=fa;ga=f[j>>2]|0;if((ga|0)==(f[m>>2]|0))Ri(n,h);else{f[ga>>2]=fa;f[j>>2]=ga+4}f[h>>2]=ia<<32-(f[y>>2]|0);break}ia=f[h>>2]|ha>>>$;f[h>>2]=ia;ha=$+Q|0;f[y>>2]=ha;if((ha|0)!=32)break;ha=f[j>>2]|0;if((ha|0)==(f[m>>2]|0))Ri(n,h);else{f[ha>>2]=ia;f[j>>2]=ha+4}f[h>>2]=0;f[y>>2]=0}while(0);W=W+1|0;Q=f[g>>2]|0}while(W>>>0>>0);ea=Q}ca=ca+1|0;if(ca>>>0>=z>>>0){ba=81;break a}else da=ea}}V=U+1|0;Ig(N+(V*12|0)|0,f[N+(U*12|0)>>2]|0,f[N+(U*12|0)+4>>2]|0);W=(f[(f[k>>2]|0)+(V*12|0)>>2]|0)+(R<<2)|0;Y=(f[W>>2]|0)+(1<>2]=Y;W=f[A>>2]|0;Q=f[B>>2]|0;b:do if((S|0)==(O|0))ja=O;else{Z=f[K>>2]|0;if(!W){if((f[Z+(R<<2)>>2]|0)>>>0>>0){ja=S;break}else{ka=S;la=O}while(1){ha=ka;do{ha=ha+-1|0;if((la|0)==(ha|0)){ja=la;break b}ia=(f[L>>2]|0)+((X(ha,Q)|0)<<2)+(R<<2)|0}while((f[ia>>2]|0)>>>0>=Y>>>0);la=la+1|0;if((la|0)==(ha|0)){ja=ha;break b}else ka=ha}}else{ma=S;na=O}while(1){ia=na;while(1){oa=Z+((X(ia,W)|0)<<2)|0;if((f[oa+(R<<2)>>2]|0)>>>0>=Y>>>0){pa=ma;break}$=ia+1|0;if(($|0)==(ma|0)){ja=ma;break b}else ia=$}while(1){pa=pa+-1|0;if((ia|0)==(pa|0)){ja=ia;break b}qa=(f[L>>2]|0)+((X(pa,Q)|0)<<2)|0;if((f[qa+(R<<2)>>2]|0)>>>0>>0){ra=0;break}}do{ha=oa+(ra<<2)|0;$=qa+(ra<<2)|0;ga=f[ha>>2]|0;f[ha>>2]=f[$>>2];f[$>>2]=ga;ra=ra+1|0}while((ra|0)!=(W|0));na=ia+1|0;if((na|0)==(pa|0)){ja=pa;break}else ma=pa}}while(0);Y=(_(z|0)|0)^31;Q=ja-O|0;Z=S-ja|0;ga=Q>>>0>>0;if((Q|0)!=(Z|0)){$=f[D>>2]|0;if(ga)f[E>>2]=f[E>>2]|1<<31-$;ha=$+1|0;f[D>>2]=ha;if((ha|0)==32){ha=f[F>>2]|0;if((ha|0)==(f[G>>2]|0))Ri(H,E);else{f[ha>>2]=f[E>>2];f[F>>2]=ha+4}f[D>>2]=0;f[E>>2]=0}}ha=z>>>1;if(ga)sg(C,Y,ha-Q|0);else sg(C,Y,ha-Z|0);ha=f[s>>2]|0;Y=f[ha+(U*12|0)>>2]|0;ga=Y+(R<<2)|0;f[ga>>2]=(f[ga>>2]|0)+1;Ig(ha+(V*12|0)|0,Y,f[ha+(U*12|0)+4>>2]|0);if((ja|0)!=(O|0)){ha=f[o>>2]|0;Y=f[t>>2]|0;ga=ha-Y>>2;$=f[v>>2]|0;fa=f[l>>2]|0;if((((ga|0)==0?0:(ga*113|0)+-1|0)|0)==(fa+$|0)){Pc(e);sa=f[v>>2]|0;ta=f[l>>2]|0;ua=f[o>>2]|0;va=f[t>>2]|0}else{sa=$;ta=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;ja=Ea;Ba=f[Ea>>2]|0}f[l>>2]=0;l=p-i>>2;if(l>>>0>2){i=Ca;do{Oq(f[i>>2]|0);i=(f[t>>2]|0)+4|0;f[t>>2]=i;Fa=f[o>>2]|0;Ga=Fa-i>>2}while(Ga>>>0>2);Ha=Ga;Ia=i;Ja=Fa}else{Ha=l;Ia=Ca;Ja=q}switch(Ha|0){case 1:{Ka=56;ba=95;break}case 2:{Ka=113;ba=95;break}default:{}}if((ba|0)==95)f[v>>2]=Ka;if((Ia|0)!=(Ja|0)){Ka=Ia;do{Oq(f[Ka>>2]|0);Ka=Ka+4|0}while((Ka|0)!=(Ja|0));Ja=f[t>>2]|0;t=f[o>>2]|0;if((t|0)!=(Ja|0))f[o>>2]=t+(~((t+-4-Ja|0)>>>2)<<2)}Ja=f[e>>2]|0;if(!Ja){u=d;return}Oq(Ja);u=d;return}function mb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=Oa,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;if(!(b[a+32>>0]|0)){r=o;m=0;while(1){s=$(b[r>>0]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}else{r=o;m=0;while(1){s=$($(b[r>>0]|0)/$(127.0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[k>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){t=q;break}else r=r+1|0}}}else t=l;r=t<<24>>24;if(t<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 2:{r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){k=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;u=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=k+u|0;if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(h[u>>0]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){v=q;break}else u=u+1|0}}else{u=o;k=0;while(1){s=$($(h[u>>0]|0)/$(255.0));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){v=l;break}else u=u+1|0}}}else v=m;u=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 3:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$(d[u>>1]|0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){w=q;break}else u=u+2|0}}else{u=o;l=0;while(1){s=$($(d[u>>1]|0)/$(32767.0));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else u=u+2|0}}else w=k;u=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 4:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){s=$(j[u>>1]|0);n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){x=q;break}else u=u+2|0}}else{u=o;m=0;while(1){s=$($(j[u>>1]|0)/$(65535.0));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){x=k;break}else u=u+2|0}}else x=l;u=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 5:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){s=$(f[u>>2]|0);n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){y=q;break}else u=u+4|0}}else{u=o;k=0;while(1){s=$($(f[u>>2]|0)*$(4.65661287e-10));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){y=l;break}else u=u+4|0}}else y=m;u=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 6:{u=a+48|0;k=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,k|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;l=0;while(1){s=$((f[u>>2]|0)>>>0);n[g+(l<<2)>>2]=s;l=l+1|0;q=b[r>>0]|0;if((l|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){z=q;break}else u=u+4|0}}else{u=o;l=0;while(1){s=$($((f[u>>2]|0)>>>0)*$(2.32830644e-10));n[g+(l<<2)>>2]=s;l=l+1|0;m=b[r>>0]|0;if((l|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){z=m;break}else u=u+4|0}}else z=k;u=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 7:{u=a+48|0;l=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,l|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;l=b[r>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;m=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+(f[q+4>>2]|0));n[g+(m<<2)>>2]=s;m=m+1|0;q=b[r>>0]|0;if((m|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else u=u+8|0}}else{u=o;m=0;while(1){k=u;s=$($(+((f[k>>2]|0)>>>0)+4294967296.0*+(f[k+4>>2]|0))*$(1.08420217e-19));n[g+(m<<2)>>2]=s;m=m+1|0;k=b[r>>0]|0;if((m|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){A=k;break}else u=u+8|0}}else A=l;u=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 8:{u=a+48|0;m=f[u>>2]|0;r=f[u+4>>2]|0;u=a+40|0;o=(Vn(un(f[u>>2]|0,f[u+4>>2]|0,f[c>>2]|0,0)|0,I|0,m|0,r|0)|0)+(f[f[a>>2]>>2]|0)|0;r=a+24|0;m=b[r>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0)if(!(b[a+32>>0]|0)){u=o;k=0;while(1){q=u;s=$(+((f[q>>2]|0)>>>0)+4294967296.0*+((f[q+4>>2]|0)>>>0));n[g+(k<<2)>>2]=s;k=k+1|0;q=b[r>>0]|0;if((k|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){B=q;break}else u=u+8|0}}else{u=o;k=0;while(1){l=u;s=$($(+((f[l>>2]|0)>>>0)+4294967296.0*+((f[l+4>>2]|0)>>>0))*$(5.42101086e-20));n[g+(k<<2)>>2]=s;k=k+1|0;l=b[r>>0]|0;if((k|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){B=l;break}else u=u+8|0}}else B=m;u=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(u<<2)|0,0,(e<<24>>24)-u<<2|0)|0;i=1;return i|0}case 9:{u=a+24|0;k=b[u>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){r=f[f[a>>2]>>2]|0;o=a+40|0;l=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;q=Vn(l|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=r+q|0;q=0;while(1){f[g+(q<<2)>>2]=f[o>>2];q=q+1|0;r=b[u>>0]|0;if((q|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){C=r;break}else o=o+4|0}}else C=k;o=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 10:{o=a+24|0;q=b[o>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){u=f[f[a>>2]>>2]|0;m=a+40|0;r=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;l=Vn(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=u+l|0;l=0;while(1){s=$(+p[m>>3]);n[g+(l<<2)>>2]=s;l=l+1|0;u=b[o>>0]|0;if((l|0)>=((u<<24>>24>e<<24>>24?e:u)<<24>>24|0)){D=u;break}else m=m+8|0}}else D=q;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 11:{m=a+24|0;l=b[m>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){o=f[f[a>>2]>>2]|0;k=a+40|0;u=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;r=Vn(u|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=o+r|0;r=0;while(1){s=$((b[k>>0]|0)!=0&1);n[g+(r<<2)>>2]=s;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){E=o;break}else k=k+1|0}}else E=l;k=E<<24>>24;if(E<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function nb(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0.0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0,Ua=0,Va=0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0.0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0.0,kb=0.0,lb=0.0,mb=0.0,nb=0.0,ob=0.0,pb=0.0,qb=0.0,rb=0.0,sb=0.0,tb=0;i=u;u=u+512|0;j=i;k=d+c|0;l=0-k|0;m=a+4|0;n=a+100|0;o=b;b=0;a:while(1){switch(o|0){case 46:{p=6;break a;break}case 48:break;default:{q=0;r=o;s=b;t=0;v=0;break a}}w=f[m>>2]|0;if(w>>>0<(f[n>>2]|0)>>>0){f[m>>2]=w+1;o=h[w>>0]|0;b=1;continue}else{o=Si(a)|0;b=1;continue}}if((p|0)==6){o=f[m>>2]|0;if(o>>>0<(f[n>>2]|0)>>>0){f[m>>2]=o+1;x=h[o>>0]|0}else x=Si(a)|0;if((x|0)==48){o=0;w=0;while(1){y=Vn(o|0,w|0,-1,-1)|0;z=I;A=f[m>>2]|0;if(A>>>0<(f[n>>2]|0)>>>0){f[m>>2]=A+1;B=h[A>>0]|0}else B=Si(a)|0;if((B|0)==48){o=y;w=z}else{q=1;r=B;s=1;t=y;v=z;break}}}else{q=1;r=x;s=b;t=0;v=0}}f[j>>2]=0;b=r+-48|0;x=(r|0)==46;b:do if(x|b>>>0<10){B=j+496|0;w=0;o=0;z=0;y=q;A=s;C=r;D=x;E=b;F=t;G=v;H=0;J=0;c:while(1){do if(D)if(!y){L=w;M=o;N=1;O=z;P=A;Q=H;R=J;S=H;T=J}else break c;else{U=Vn(H|0,J|0,1,0)|0;V=I;W=(C|0)!=48;if((o|0)>=125){if(!W){L=w;M=o;N=y;O=z;P=A;Q=F;R=G;S=U;T=V;break}f[B>>2]=f[B>>2]|1;L=w;M=o;N=y;O=z;P=A;Q=F;R=G;S=U;T=V;break}Y=j+(o<<2)|0;if(!w)Z=E;else Z=C+-48+((f[Y>>2]|0)*10|0)|0;f[Y>>2]=Z;Y=w+1|0;_=(Y|0)==9;L=_?0:Y;M=o+(_&1)|0;N=y;O=W?U:z;P=1;Q=F;R=G;S=U;T=V}while(0);V=f[m>>2]|0;if(V>>>0<(f[n>>2]|0)>>>0){f[m>>2]=V+1;$=h[V>>0]|0}else $=Si(a)|0;E=$+-48|0;D=($|0)==46;if(!(D|E>>>0<10)){aa=L;ba=M;ca=O;da=N;ea=$;fa=P;ga=S;ha=Q;ia=T;ja=R;p=29;break b}else{w=L;o=M;z=O;y=N;A=P;C=$;F=Q;G=R;H=S;J=T}}ka=w;la=o;ma=z;na=H;oa=J;pa=F;qa=G;ra=(A|0)!=0;p=37}else{aa=0;ba=0;ca=0;da=q;ea=r;fa=s;ga=0;ha=t;ia=0;ja=v;p=29}while(0);do if((p|0)==29){v=(da|0)==0;t=v?ga:ha;s=v?ia:ja;v=(fa|0)!=0;if(!(v&(ea|32|0)==101))if((ea|0)>-1){ka=aa;la=ba;ma=ca;na=ga;oa=ia;pa=t;qa=s;ra=v;p=37;break}else{sa=aa;ta=ba;ua=ca;va=ga;wa=ia;xa=v;ya=t;za=s;p=39;break}v=Re(a,g)|0;r=I;if((v|0)==0&(r|0)==-2147483648){if(!g){Ym(a,0);Aa=0.0;break}if(!(f[n>>2]|0)){Ba=0;Ca=0}else{f[m>>2]=(f[m>>2]|0)+-1;Ba=0;Ca=0}}else{Ba=v;Ca=r}r=Vn(Ba|0,Ca|0,t|0,s|0)|0;Da=aa;Ea=ba;Fa=ca;Ga=r;Ha=ga;Ia=I;Ja=ia;p=41}while(0);if((p|0)==37)if(f[n>>2]|0){f[m>>2]=(f[m>>2]|0)+-1;if(ra){Da=ka;Ea=la;Fa=ma;Ga=pa;Ha=na;Ia=qa;Ja=oa;p=41}else p=40}else{sa=ka;ta=la;ua=ma;va=na;wa=oa;xa=ra;ya=pa;za=qa;p=39}if((p|0)==39)if(xa){Da=sa;Ea=ta;Fa=ua;Ga=ya;Ha=va;Ia=za;Ja=wa;p=41}else p=40;do if((p|0)==40){wa=Vq()|0;f[wa>>2]=22;Ym(a,0);Aa=0.0}else if((p|0)==41){wa=f[j>>2]|0;if(!wa){Aa=+(e|0)*0.0;break}if(((Ja|0)<0|(Ja|0)==0&Ha>>>0<10)&((Ga|0)==(Ha|0)&(Ia|0)==(Ja|0))?(c|0)>30|(wa>>>c|0)==0:0){Aa=+(e|0)*+(wa>>>0);break}wa=(d|0)/-2|0;za=((wa|0)<0)<<31>>31;if((Ia|0)>(za|0)|(Ia|0)==(za|0)&Ga>>>0>wa>>>0){wa=Vq()|0;f[wa>>2]=34;Aa=+(e|0)*1797693134862315708145274.0e284*1797693134862315708145274.0e284;break}wa=d+-106|0;za=((wa|0)<0)<<31>>31;if((Ia|0)<(za|0)|(Ia|0)==(za|0)&Ga>>>0>>0){wa=Vq()|0;f[wa>>2]=34;Aa=+(e|0)*2.2250738585072014e-308*2.2250738585072014e-308;break}if(!Da)Ka=Ea;else{if((Da|0)<9){wa=j+(Ea<<2)|0;za=Da;va=f[wa>>2]|0;while(1){va=va*10|0;if((za|0)>=8)break;else za=za+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Xa=xa;Ya=qa}else{Xa=0;Ya=sa}f[ua>>2]=Ya;ua=(o|0)==(Na|0);Wa=(Ya|0)==0&(((o|0)!=(Wa+127&127|0)|ua)^1)?o:Wa;if(ua)break;else{w=Xa;ya=o+-1|0}}va=va+-29|0;if(Xa|0)break;else wa=Wa}wa=Na+127&127;G=Wa+127&127;A=j+((Wa+126&127)<<2)|0;if((wa|0)==(Wa|0)){f[A>>2]=f[A>>2]|f[j+(G<<2)>>2];Za=G}else Za=Wa;f[j+(wa<<2)>>2]=Xa;La=va;Ma=Za;Na=wa;Oa=Oa+9|0}e:while(1){za=Va+1&127;H=j+((Va+127&127)<<2)|0;J=Sa;F=Ta;wa=Ua;while(1){G=(wa|0)==18;A=(wa|0)>27?9:1;_a=J;$a=F;while(1){z=0;while(1){ya=z+$a&127;if((ya|0)==(Va|0)){ab=2;p=88;break}w=f[j+(ya<<2)>>2]|0;ya=f[6752+(z<<2)>>2]|0;if(w>>>0>>0){ab=2;p=88;break}if(w>>>0>ya>>>0)break;ya=z+1|0;if((z|0)<1)z=ya;else{ab=ya;p=88;break}}if((p|0)==88?(p=0,G&(ab|0)==2):0){bb=0.0;cb=0;db=Va;break e}eb=A+_a|0;if(($a|0)==(Va|0)){_a=eb;$a=Va}else break}G=(1<>>A;fb=0;gb=$a;hb=wa;ya=$a;do{w=j+(ya<<2)|0;o=f[w>>2]|0;ua=(o>>>A)+fb|0;f[w>>2]=ua;fb=X(o&G,z)|0;o=(ya|0)==(gb|0)&(ua|0)==0;hb=o?hb+-9|0:hb;gb=o?gb+1&127:gb;ya=ya+1&127}while((ya|0)!=(Va|0));if(!fb){J=eb;F=gb;wa=hb;continue}if((za|0)!=(gb|0))break;f[H>>2]=f[H>>2]|1;J=eb;F=gb;wa=hb}f[j+(Va<<2)>>2]=fb;Sa=eb;Ta=gb;Ua=hb;Va=za}while(1){wa=cb+$a&127;F=db+1&127;if((wa|0)==(db|0)){f[j+(F+-1<<2)>>2]=0;ib=F}else ib=db;bb=bb*1.0e9+ +((f[j+(wa<<2)>>2]|0)>>>0);cb=cb+1|0;if((cb|0)==2)break;else db=ib}jb=+(e|0);kb=bb*jb;wa=_a+53|0;F=wa-d|0;J=(F|0)<(c|0);H=J?((F|0)>0?F:0):c;if((H|0)<53){lb=+rq(+bk(1.0,105-H|0),kb);mb=+Dq(kb,+bk(1.0,53-H|0));nb=lb;ob=mb;pb=lb+(kb-mb)}else{nb=0.0;ob=0.0;pb=kb}va=$a+2&127;if((va|0)!=(ib|0)){ya=f[j+(va<<2)>>2]|0;do if(ya>>>0>=5e8){if((ya|0)!=5e8){qb=jb*.75+ob;break}if(($a+3&127|0)==(ib|0)){qb=jb*.5+ob;break}else{qb=jb*.75+ob;break}}else{if((ya|0)==0?($a+3&127|0)==(ib|0):0){qb=ob;break}qb=jb*.25+ob}while(0);if((53-H|0)>1?!(+Dq(qb,1.0)!=0.0):0)rb=qb+1.0;else rb=qb}else rb=ob;jb=pb+rb-nb;do if((wa&2147483647|0)>(-2-k|0)){ya=!(+K(+jb)>=9007199254740992.0);va=_a+((ya^1)&1)|0;kb=ya?jb:jb*.5;if((va+50|0)<=(l|0)?!(rb!=0.0&(J&((H|0)!=(F|0)|ya))):0){sb=kb;tb=va;break}ya=Vq()|0;f[ya>>2]=34;sb=kb;tb=va}else{sb=jb;tb=_a}while(0);Aa=+sq(sb,tb)}while(0);u=i;return +Aa}function ob(a,c,d,e,g,i){a=a|0;c=+c;d=d|0;e=e|0;g=g|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0,D=0.0,E=0,F=0,G=0,H=0.0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0.0,ga=0.0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0;j=u;u=u+560|0;k=j+8|0;l=j;m=j+524|0;n=m;o=j+512|0;f[l>>2]=0;p=o+12|0;yo(c)|0;if((I|0)<0){q=-c;r=1;s=16605}else{q=c;r=(g&2049|0)!=0&1;s=(g&2048|0)==0?((g&1|0)==0?16606:16611):16608}yo(q)|0;do if(0==0&(I&2146435072|0)==2146435072){t=(i&32|0)!=0;v=r+3|0;Qk(a,32,d,v,g&-65537);Xo(a,s,r);Xo(a,q!=q|0.0!=0.0?(t?18555:16632):t?16624:16628,3);Qk(a,32,d,v,g^8192);w=v}else{c=+tq(q,l)*2.0;v=c!=0.0;if(v)f[l>>2]=(f[l>>2]|0)+-1;t=i|32;if((t|0)==97){x=i&32;y=(x|0)==0?s:s+9|0;z=r|2;A=12-e|0;do if(!(e>>>0>11|(A|0)==0)){B=8.0;C=A;do{C=C+-1|0;B=B*16.0}while((C|0)!=0);if((b[y>>0]|0)==45){D=-(B+(-c-B));break}else{D=c+B-B;break}}else D=c;while(0);A=f[l>>2]|0;C=(A|0)<0?0-A|0:A;E=Rj(C,((C|0)<0)<<31>>31,p)|0;if((E|0)==(p|0)){C=o+11|0;b[C>>0]=48;F=C}else F=E;b[F+-1>>0]=(A>>31&2)+43;A=F+-2|0;b[A>>0]=i+15;E=(e|0)<1;C=(g&8|0)==0;G=m;H=D;while(1){J=~~H;K=G+1|0;b[G>>0]=x|h[16636+J>>0];H=(H-+(J|0))*16.0;if((K-n|0)==1?!(C&(E&H==0.0)):0){b[K>>0]=46;L=G+2|0}else L=K;if(!(H!=0.0))break;else G=L}G=L;if((e|0)!=0?(-2-n+G|0)<(e|0):0){M=G-n|0;N=e+2|0}else{E=G-n|0;M=E;N=E}E=p-A|0;G=E+z+N|0;Qk(a,32,d,G,g);Xo(a,y,z);Qk(a,48,d,G,g^65536);Xo(a,m,M);Qk(a,48,N-M|0,0,0);Xo(a,A,E);Qk(a,32,d,G,g^8192);w=G;break}G=(e|0)<0?6:e;if(v){E=(f[l>>2]|0)+-28|0;f[l>>2]=E;O=c*268435456.0;P=E}else{O=c;P=f[l>>2]|0}E=(P|0)<0?k:k+288|0;C=E;H=O;do{x=~~H>>>0;f[C>>2]=x;C=C+4|0;H=(H-+(x>>>0))*1.0e9}while(H!=0.0);if((P|0)>0){v=E;A=C;z=P;while(1){y=(z|0)<29?z:29;x=A+-4|0;if(x>>>0>=v>>>0){K=x;x=0;do{J=Tn(f[K>>2]|0,0,y|0)|0;Q=Vn(J|0,I|0,x|0,0)|0;J=I;R=hn(Q|0,J|0,1e9,0)|0;f[K>>2]=R;x=jp(Q|0,J|0,1e9,0)|0;K=K+-4|0}while(K>>>0>=v>>>0);if(x){K=v+-4|0;f[K>>2]=x;S=K}else S=v}else S=v;K=A;while(1){if(K>>>0<=S>>>0)break;J=K+-4|0;if(!(f[J>>2]|0))K=J;else break}x=(f[l>>2]|0)-y|0;f[l>>2]=x;if((x|0)>0){v=S;A=K;z=x}else{T=S;U=K;V=x;break}}}else{T=E;U=C;V=P}if((V|0)<0){z=((G+25|0)/9|0)+1|0;A=(t|0)==102;v=T;x=U;J=V;while(1){Q=0-J|0;R=(Q|0)<9?Q:9;if(v>>>0>>0){Q=(1<>>R;Y=0;Z=v;do{_=f[Z>>2]|0;f[Z>>2]=(_>>>R)+Y;Y=X(_&Q,W)|0;Z=Z+4|0}while(Z>>>0>>0);Z=(f[v>>2]|0)==0?v+4|0:v;if(!Y){$=Z;aa=x}else{f[x>>2]=Y;$=Z;aa=x+4|0}}else{$=(f[v>>2]|0)==0?v+4|0:v;aa=x}Z=A?E:$;W=(aa-Z>>2|0)>(z|0)?Z+(z<<2)|0:aa;J=(f[l>>2]|0)+R|0;f[l>>2]=J;if((J|0)>=0){ba=$;ca=W;break}else{v=$;x=W}}}else{ba=T;ca=U}x=E;if(ba>>>0>>0){v=(x-ba>>2)*9|0;J=f[ba>>2]|0;if(J>>>0<10)da=v;else{z=v;v=10;while(1){v=v*10|0;A=z+1|0;if(J>>>0>>0){da=A;break}else z=A}}}else da=0;z=(t|0)==103;v=(G|0)!=0;J=G-((t|0)!=102?da:0)+((v&z)<<31>>31)|0;if((J|0)<(((ca-x>>2)*9|0)+-9|0)){A=J+9216|0;J=E+4+(((A|0)/9|0)+-1024<<2)|0;C=(A|0)%9|0;if((C|0)<8){A=C;C=10;while(1){W=C*10|0;if((A|0)<7){A=A+1|0;C=W}else{ea=W;break}}}else ea=10;C=f[J>>2]|0;A=(C>>>0)%(ea>>>0)|0;t=(J+4|0)==(ca|0);if(!(t&(A|0)==0)){B=(((C>>>0)/(ea>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;W=(ea|0)/2|0;H=A>>>0>>0?.5:t&(A|0)==(W|0)?1.0:1.5;if(!r){fa=H;ga=B}else{W=(b[s>>0]|0)==45;fa=W?-H:H;ga=W?-B:B}W=C-A|0;f[J>>2]=W;if(ga+fa!=ga){A=W+ea|0;f[J>>2]=A;if(A>>>0>999999999){A=ba;W=J;while(1){C=W+-4|0;f[W>>2]=0;if(C>>>0>>0){t=A+-4|0;f[t>>2]=0;ha=t}else ha=A;t=(f[C>>2]|0)+1|0;f[C>>2]=t;if(t>>>0>999999999){A=ha;W=C}else{ia=ha;ja=C;break}}}else{ia=ba;ja=J}W=(x-ia>>2)*9|0;A=f[ia>>2]|0;if(A>>>0<10){ka=ja;la=W;ma=ia}else{C=W;W=10;while(1){W=W*10|0;t=C+1|0;if(A>>>0>>0){ka=ja;la=t;ma=ia;break}else C=t}}}else{ka=J;la=da;ma=ba}}else{ka=J;la=da;ma=ba}C=ka+4|0;na=la;oa=ca>>>0>C>>>0?C:ca;pa=ma}else{na=da;oa=ca;pa=ba}C=oa;while(1){if(C>>>0<=pa>>>0){qa=0;break}W=C+-4|0;if(!(f[W>>2]|0))C=W;else{qa=1;break}}J=0-na|0;do if(z){W=G+((v^1)&1)|0;if((W|0)>(na|0)&(na|0)>-5){ra=i+-1|0;sa=W+-1-na|0}else{ra=i+-2|0;sa=W+-1|0}W=g&8;if(!W){if(qa?(A=f[C+-4>>2]|0,(A|0)!=0):0)if(!((A>>>0)%10|0)){t=0;Z=10;while(1){Z=Z*10|0;Q=t+1|0;if((A>>>0)%(Z>>>0)|0|0){ta=Q;break}else t=Q}}else ta=0;else ta=9;t=((C-x>>2)*9|0)+-9|0;if((ra|32|0)==102){Z=t-ta|0;A=(Z|0)>0?Z:0;ua=ra;va=(sa|0)<(A|0)?sa:A;wa=0;break}else{A=t+na-ta|0;t=(A|0)>0?A:0;ua=ra;va=(sa|0)<(t|0)?sa:t;wa=0;break}}else{ua=ra;va=sa;wa=W}}else{ua=i;va=G;wa=g&8}while(0);G=va|wa;x=(G|0)!=0&1;v=(ua|32|0)==102;if(v){xa=0;ya=(na|0)>0?na:0}else{z=(na|0)<0?J:na;t=Rj(z,((z|0)<0)<<31>>31,p)|0;z=p;if((z-t|0)<2){A=t;while(1){Z=A+-1|0;b[Z>>0]=48;if((z-Z|0)<2)A=Z;else{za=Z;break}}}else za=t;b[za+-1>>0]=(na>>31&2)+43;A=za+-2|0;b[A>>0]=ua;xa=A;ya=z-A|0}A=r+1+va+x+ya|0;Qk(a,32,d,A,g);Xo(a,s,r);Qk(a,48,d,A,g^65536);if(v){J=pa>>>0>E>>>0?E:pa;Z=m+9|0;R=Z;Y=m+8|0;Q=J;do{K=Rj(f[Q>>2]|0,0,Z)|0;if((Q|0)==(J|0))if((K|0)==(Z|0)){b[Y>>0]=48;Aa=Y}else Aa=K;else if(K>>>0>m>>>0){sj(m|0,48,K-n|0)|0;y=K;while(1){_=y+-1|0;if(_>>>0>m>>>0)y=_;else{Aa=_;break}}}else Aa=K;Xo(a,Aa,R-Aa|0);Q=Q+4|0}while(Q>>>0<=E>>>0);if(G|0)Xo(a,16652,1);if(Q>>>0>>0&(va|0)>0){E=va;R=Q;while(1){Y=Rj(f[R>>2]|0,0,Z)|0;if(Y>>>0>m>>>0){sj(m|0,48,Y-n|0)|0;J=Y;while(1){v=J+-1|0;if(v>>>0>m>>>0)J=v;else{Ba=v;break}}}else Ba=Y;Xo(a,Ba,(E|0)<9?E:9);R=R+4|0;J=E+-9|0;if(!(R>>>0>>0&(E|0)>9)){Ca=J;break}else E=J}}else Ca=va;Qk(a,48,Ca+9|0,9,0)}else{E=qa?C:pa+4|0;if((va|0)>-1){R=m+9|0;Z=(wa|0)==0;Q=R;G=0-n|0;J=m+8|0;K=va;v=pa;while(1){x=Rj(f[v>>2]|0,0,R)|0;if((x|0)==(R|0)){b[J>>0]=48;Da=J}else Da=x;do if((v|0)==(pa|0)){x=Da+1|0;Xo(a,Da,1);if(Z&(K|0)<1){Ea=x;break}Xo(a,16652,1);Ea=x}else{if(Da>>>0<=m>>>0){Ea=Da;break}sj(m|0,48,Da+G|0)|0;x=Da;while(1){z=x+-1|0;if(z>>>0>m>>>0)x=z;else{Ea=z;break}}}while(0);Y=Q-Ea|0;Xo(a,Ea,(K|0)>(Y|0)?Y:K);x=K-Y|0;v=v+4|0;if(!(v>>>0>>0&(x|0)>-1)){Fa=x;break}else K=x}}else Fa=va;Qk(a,48,Fa+18|0,18,0);Xo(a,xa,p-xa|0)}Qk(a,32,d,A,g^8192);w=A}while(0);u=j;return ((w|0)<(d|0)?d:w)|0}function pb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0;c=u;u=u+64|0;d=c+56|0;e=c+52|0;g=c+48|0;h=c+60|0;i=c;j=c+44|0;k=c+40|0;l=c+36|0;m=c+32|0;n=c+28|0;o=c+24|0;p=c+20|0;q=c+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]|0;if((D|0)!=(z|0))f[B>>2]=D+(~((D+-4-z|0)>>>2)<<2);f[a+164>>2]=-1;z=a+168|0;f[z>>2]=0;D=f[a+108>>2]|0;E=a+112|0;F=f[E>>2]|0;if((F|0)!=(D|0))f[E>>2]=F+(~(((F+-12-D|0)>>>0)/12|0)*12|0);D=a+132|0;if(f[D>>2]|0){F=a+128|0;E=f[F>>2]|0;if(E|0){G=E;do{E=G;G=f[G>>2]|0;Oq(E)}while((G|0)!=0)}f[F>>2]=0;F=f[a+124>>2]|0;if(F|0){G=a+120|0;E=0;do{f[(f[G>>2]|0)+(E<<2)>>2]=0;E=E+1|0}while((E|0)!=(F|0))}f[D>>2]=0}f[a+144>>2]=0;D=f[s>>2]|0;F=(f[D+28>>2]|0)-(f[D+24>>2]|0)>>2;f[d>>2]=-1;hg(a+152|0,F,d);F=a+72|0;D=f[F>>2]|0;E=a+76|0;G=f[E>>2]|0;if((G|0)!=(D|0))f[E>>2]=G+(~((G+-4-D|0)>>>2)<<2);D=f[s>>2]|0;gk(F,((f[D+4>>2]|0)-(f[D>>2]|0)>>2>>>0)/3|0);f[a+64>>2]=0;if(!(Be(a)|0)){w=0;u=c;return w|0}if(!(Hg(a)|0)){w=0;u=c;return w|0}D=a+172|0;G=a+176|0;H=(((f[G>>2]|0)-(f[D>>2]|0)|0)/136|0)&255;b[h>>0]=H;I=f[(f[x>>2]|0)+44>>2]|0;J=I+16|0;K=f[J+4>>2]|0;if((K|0)>0|(K|0)==0&(f[J>>2]|0)>>>0>0)L=H;else{f[e>>2]=f[I+4>>2];f[d>>2]=f[e>>2];Me(I,d,h,h+1|0)|0;L=b[h>>0]|0}h=a+284|0;f[h>>2]=L&255;L=f[s>>2]|0;I=(f[L+4>>2]|0)-(f[L>>2]|0)|0;L=I>>2;dj(v);f[i>>2]=0;H=i+4|0;f[H>>2]=0;f[i+8>>2]=0;a:do if((I|0)>0){J=a+104|0;K=i+8|0;M=0;b:while(1){N=(M>>>0)/3|0;O=N>>>5;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+1|0;if(R)$=-1;else $=((V>>>0)%3|0|0)==0?Q+-2|0:V;f[m>>2]=$;f[d>>2]=f[m>>2];Pe(a,d,1)|0;f[n>>2]=f[e>>2];f[d>>2]=f[n>>2];if(!(kc(a,d)|0))break b}while(0)}M=M+1|0;if((M|0)>=(L|0)){aa=62;break a}}ba=0}else aa=62;while(0);if((aa|0)==62){aa=f[F>>2]|0;L=f[E>>2]|0;n=L;if((aa|0)!=(L|0)?(m=L+-4|0,aa>>>0>>0):0){L=aa;aa=m;do{m=f[L>>2]|0;f[L>>2]=f[aa>>2];f[aa>>2]=m;L=L+4|0;aa=aa+-4|0}while(L>>>0>>0)}f[o>>2]=n;f[p>>2]=f[i>>2];f[q>>2]=f[H>>2];f[g>>2]=f[o>>2];f[e>>2]=f[p>>2];f[d>>2]=f[q>>2];Yd(F,g,e,d)|0;if((f[G>>2]|0)!=(f[D>>2]|0)?(D=f[y>>2]|0,y=((f[D+100>>2]|0)-(f[D+96>>2]|0)|0)/12|0,b[d>>0]=0,qh(t,y,d),y=f[F>>2]|0,F=f[E>>2]|0,(y|0)!=(F|0)):0){E=y;do{f[r>>2]=f[E>>2];f[d>>2]=f[r>>2];He(a,d)|0;E=E+4|0}while((E|0)!=(F|0))}th(v);F=a+232|0;ld(v,F);v=a+280|0;E=f[v>>2]|0;if((E|0?(f[h>>2]|0)>0:0)?(ld(E,F),(f[h>>2]|0)>1):0){E=1;do{ld((f[v>>2]|0)+(E<<5)|0,F);E=E+1|0}while((E|0)<(f[h>>2]|0))}ci((f[a+272>>2]|0)-(f[a+268>>2]|0)>>2,f[(f[x>>2]|0)+44>>2]|0)|0;ci(f[z>>2]|0,f[(f[x>>2]|0)+44>>2]|0)|0;if(bh(a)|0){z=f[(f[x>>2]|0)+44>>2]|0;x=f[F>>2]|0;F=z+16|0;h=f[F+4>>2]|0;if(!((h|0)>0|(h|0)==0&(f[F>>2]|0)>>>0>0)){F=(f[a+236>>2]|0)-x|0;f[e>>2]=f[z+4>>2];f[d>>2]=f[e>>2];Me(z,d,x,x+F|0)|0}ba=1}else ba=0}F=f[i>>2]|0;if(F|0){i=f[H>>2]|0;if((i|0)!=(F|0))f[H>>2]=i+(~((i+-4-F|0)>>>2)<<2);Oq(F)}w=ba;u=c;return w|0}function qb(a,c,e,g,h){a=a|0;c=c|0;e=e|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0;i=u;u=u+64|0;j=i+16|0;k=i;l=i+24|0;m=i+8|0;n=i+20|0;f[j>>2]=c;c=(a|0)!=0;o=l+40|0;q=o;r=l+39|0;l=m+4|0;s=0;t=0;v=0;a:while(1){do if((t|0)>-1)if((s|0)>(2147483647-t|0)){w=Vq()|0;f[w>>2]=75;x=-1;break}else{x=s+t|0;break}else x=t;while(0);w=f[j>>2]|0;y=b[w>>0]|0;if(!(y<<24>>24)){z=88;break}else{A=y;B=w}b:while(1){switch(A<<24>>24){case 37:{C=B;D=B;z=9;break b;break}case 0:{E=B;break b;break}default:{}}y=B+1|0;f[j>>2]=y;A=b[y>>0]|0;B=y}c:do if((z|0)==9)while(1){z=0;if((b[D+1>>0]|0)!=37){E=C;break c}y=C+1|0;D=D+2|0;f[j>>2]=D;if((b[D>>0]|0)!=37){E=y;break}else{C=y;z=9}}while(0);y=E-w|0;if(c)Xo(a,w,y);if(y|0){s=y;t=x;continue}y=(Aq(b[(f[j>>2]|0)+1>>0]|0)|0)==0;F=f[j>>2]|0;if(!y?(b[F+2>>0]|0)==36:0){G=(b[F+1>>0]|0)+-48|0;H=1;J=3}else{G=-1;H=v;J=1}y=F+J|0;f[j>>2]=y;F=b[y>>0]|0;K=(F<<24>>24)+-32|0;if(K>>>0>31|(1<>24)+-32|K;P=F+1|0;f[j>>2]=P;Q=b[P>>0]|0;R=(Q<<24>>24)+-32|0;if(R>>>0>31|(1<>24==42){if((Aq(b[N+1>>0]|0)|0)!=0?(F=f[j>>2]|0,(b[F+2>>0]|0)==36):0){O=F+1|0;f[h+((b[O>>0]|0)+-48<<2)>>2]=10;S=f[g+((b[O>>0]|0)+-48<<3)>>2]|0;T=1;U=F+3|0}else{if(H|0){V=-1;break}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);O=f[F>>2]|0;f[e>>2]=F+4;W=O}else W=0;S=W;T=0;U=(f[j>>2]|0)+1|0}f[j>>2]=U;O=(S|0)<0;X=O?0-S|0:S;Y=O?L|8192:L;Z=T;_=U}else{O=Ll(j)|0;if((O|0)<0){V=-1;break}X=O;Y=L;Z=H;_=f[j>>2]|0}do if((b[_>>0]|0)==46){if((b[_+1>>0]|0)!=42){f[j>>2]=_+1;O=Ll(j)|0;$=O;aa=f[j>>2]|0;break}if(Aq(b[_+2>>0]|0)|0?(O=f[j>>2]|0,(b[O+3>>0]|0)==36):0){F=O+2|0;f[h+((b[F>>0]|0)+-48<<2)>>2]=10;K=f[g+((b[F>>0]|0)+-48<<3)>>2]|0;F=O+4|0;f[j>>2]=F;$=K;aa=F;break}if(Z|0){V=-1;break a}if(c){F=(f[e>>2]|0)+(4-1)&~(4-1);K=f[F>>2]|0;f[e>>2]=F+4;ba=K}else ba=0;K=(f[j>>2]|0)+2|0;f[j>>2]=K;$=ba;aa=K}else{$=-1;aa=_}while(0);K=0;F=aa;while(1){if(((b[F>>0]|0)+-65|0)>>>0>57){V=-1;break a}O=F;F=F+1|0;f[j>>2]=F;ca=b[(b[O>>0]|0)+-65+(16124+(K*58|0))>>0]|0;da=ca&255;if((da+-1|0)>>>0>=8)break;else K=da}if(!(ca<<24>>24)){V=-1;break}O=(G|0)>-1;do if(ca<<24>>24==19)if(O){V=-1;break a}else z=50;else{if(O){f[h+(G<<2)>>2]=da;P=g+(G<<3)|0;Q=f[P+4>>2]|0;y=k;f[y>>2]=f[P>>2];f[y+4>>2]=Q;z=50;break}if(!c){V=0;break a}We(k,da,e);ea=f[j>>2]|0}while(0);if((z|0)==50){z=0;if(c)ea=F;else{s=0;t=x;v=Z;continue}}O=b[ea+-1>>0]|0;Q=(K|0)!=0&(O&15|0)==3?O&-33:O;O=Y&-65537;y=(Y&8192|0)==0?Y:O;d:do switch(Q|0){case 110:{switch((K&255)<<24>>24){case 0:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 1:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 2:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}case 3:{d[f[k>>2]>>1]=x;s=0;t=x;v=Z;continue a;break}case 4:{b[f[k>>2]>>0]=x;s=0;t=x;v=Z;continue a;break}case 6:{f[f[k>>2]>>2]=x;s=0;t=x;v=Z;continue a;break}case 7:{P=f[k>>2]|0;f[P>>2]=x;f[P+4>>2]=((x|0)<0)<<31>>31;s=0;t=x;v=Z;continue a;break}default:{s=0;t=x;v=Z;continue a}}break}case 112:{fa=120;ga=$>>>0>8?$:8;ha=y|8;z=62;break}case 88:case 120:{fa=Q;ga=$;ha=y;z=62;break}case 111:{P=k;R=f[P>>2]|0;ia=f[P+4>>2]|0;P=Ol(R,ia,o)|0;ja=q-P|0;ka=P;la=0;ma=16588;na=(y&8|0)==0|($|0)>(ja|0)?$:ja+1|0;oa=y;pa=R;qa=ia;z=68;break}case 105:case 100:{ia=k;R=f[ia>>2]|0;ja=f[ia+4>>2]|0;if((ja|0)<0){ia=Xn(0,0,R|0,ja|0)|0;P=I;ra=k;f[ra>>2]=ia;f[ra+4>>2]=P;sa=1;ta=16588;ua=ia;va=P;z=67;break d}else{sa=(y&2049|0)!=0&1;ta=(y&2048|0)==0?((y&1|0)==0?16588:16590):16589;ua=R;va=ja;z=67;break d}break}case 117:{ja=k;sa=0;ta=16588;ua=f[ja>>2]|0;va=f[ja+4>>2]|0;z=67;break}case 99:{b[r>>0]=f[k>>2];wa=r;xa=0;ya=16588;za=o;Aa=1;Ba=O;break}case 109:{ja=Vq()|0;Ca=$o(f[ja>>2]|0)|0;z=72;break}case 115:{ja=f[k>>2]|0;Ca=ja|0?ja:16598;z=72;break}case 67:{f[m>>2]=f[k>>2];f[l>>2]=0;f[k>>2]=m;Da=-1;Ea=m;z=76;break}case 83:{ja=f[k>>2]|0;if(!$){Qk(a,32,X,0,y);Fa=0;z=85}else{Da=$;Ea=ja;z=76}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{s=ob(a,+p[k>>3],X,$,y,Q)|0;t=x;v=Z;continue a;break}default:{wa=w;xa=0;ya=16588;za=o;Aa=$;Ba=y}}while(0);e:do if((z|0)==62){z=0;w=k;Q=f[w>>2]|0;K=f[w+4>>2]|0;w=ul(Q,K,o,fa&32)|0;F=(ha&8|0)==0|(Q|0)==0&(K|0)==0;ka=w;la=F?0:2;ma=F?16588:16588+(fa>>4)|0;na=ga;oa=ha;pa=Q;qa=K;z=68}else if((z|0)==67){z=0;ka=Rj(ua,va,o)|0;la=sa;ma=ta;na=$;oa=y;pa=ua;qa=va;z=68}else if((z|0)==72){z=0;K=tg(Ca,0,$)|0;Q=(K|0)==0;wa=Ca;xa=0;ya=16588;za=Q?Ca+$|0:K;Aa=Q?$:K-Ca|0;Ba=O}else if((z|0)==76){z=0;K=Ea;Q=0;F=0;while(1){w=f[K>>2]|0;if(!w){Ga=Q;Ha=F;break}ja=Po(n,w)|0;if((ja|0)<0|ja>>>0>(Da-Q|0)>>>0){Ga=Q;Ha=ja;break}w=ja+Q|0;if(Da>>>0>w>>>0){K=K+4|0;Q=w;F=ja}else{Ga=w;Ha=ja;break}}if((Ha|0)<0){V=-1;break a}Qk(a,32,X,Ga,y);if(!Ga){Fa=0;z=85}else{F=Ea;Q=0;while(1){K=f[F>>2]|0;if(!K){Fa=Ga;z=85;break e}ja=Po(n,K)|0;Q=ja+Q|0;if((Q|0)>(Ga|0)){Fa=Ga;z=85;break e}Xo(a,n,ja);if(Q>>>0>=Ga>>>0){Fa=Ga;z=85;break}else F=F+4|0}}}while(0);if((z|0)==68){z=0;O=(pa|0)!=0|(qa|0)!=0;F=(na|0)!=0|O;Q=q-ka+((O^1)&1)|0;wa=F?ka:o;xa=la;ya=ma;za=o;Aa=F?((na|0)>(Q|0)?na:Q):na;Ba=(na|0)>-1?oa&-65537:oa}else if((z|0)==85){z=0;Qk(a,32,X,Fa,y^8192);s=(X|0)>(Fa|0)?X:Fa;t=x;v=Z;continue}Q=za-wa|0;F=(Aa|0)<(Q|0)?Q:Aa;O=F+xa|0;ja=(X|0)<(O|0)?O:X;Qk(a,32,ja,O,Ba);Xo(a,ya,xa);Qk(a,48,ja,O,Ba^65536);Qk(a,48,F,Q,0);Xo(a,wa,Q);Qk(a,32,ja,O,Ba^8192);s=ja;t=x;v=Z}f:do if((z|0)==88)if(!a)if(v){Z=1;while(1){t=f[h+(Z<<2)>>2]|0;if(!t){Ia=Z;break}We(g+(Z<<3)|0,t,e);t=Z+1|0;if((Z|0)<9)Z=t;else{Ia=t;break}}if((Ia|0)<10){Z=Ia;while(1){if(f[h+(Z<<2)>>2]|0){V=-1;break f}if((Z|0)<9)Z=Z+1|0;else{V=1;break}}}else V=1}else V=0;else V=x;while(0);u=i;return V|0}function rb(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0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+(~((C+-4-A|0)>>>2)<<2);A=f[s>>2]|0;C=(f[A+4>>2]|0)-(f[A>>2]|0)>>2;gk(z,C-((C>>>0)%3|0)|0);C=a+84|0;z=f[s>>2]|0;A=(f[z+28>>2]|0)-(f[z+24>>2]|0)>>2;b[d>>0]=0;qh(C,A,d);A=a+96|0;z=f[A>>2]|0;B=a+100|0;D=f[B>>2]|0;if((D|0)!=(z|0))f[B>>2]=D+(~((D+-4-z|0)>>>2)<<2);f[a+164>>2]=-1;z=a+168|0;f[z>>2]=0;D=f[a+108>>2]|0;E=a+112|0;F=f[E>>2]|0;if((F|0)!=(D|0))f[E>>2]=F+(~(((F+-12-D|0)>>>0)/12|0)*12|0);D=a+132|0;if(f[D>>2]|0){F=a+128|0;E=f[F>>2]|0;if(E|0){G=E;do{E=G;G=f[G>>2]|0;Oq(E)}while((G|0)!=0)}f[F>>2]=0;F=f[a+124>>2]|0;if(F|0){G=a+120|0;E=0;do{f[(f[G>>2]|0)+(E<<2)>>2]=0;E=E+1|0}while((E|0)!=(F|0))}f[D>>2]=0}f[a+144>>2]=0;D=f[s>>2]|0;F=(f[D+28>>2]|0)-(f[D+24>>2]|0)>>2;f[d>>2]=-1;hg(a+152|0,F,d);F=a+72|0;D=f[F>>2]|0;E=a+76|0;G=f[E>>2]|0;if((G|0)!=(D|0))f[E>>2]=G+(~((G+-4-D|0)>>>2)<<2);D=f[s>>2]|0;gk(F,((f[D+4>>2]|0)-(f[D>>2]|0)>>2>>>0)/3|0);f[a+64>>2]=0;if(!(Be(a)|0)){w=0;u=c;return w|0}if(!(Dg(a)|0)){w=0;u=c;return w|0}D=a+172|0;G=a+176|0;H=(((f[G>>2]|0)-(f[D>>2]|0)|0)/136|0)&255;b[h>>0]=H;I=f[(f[x>>2]|0)+44>>2]|0;J=I+16|0;K=f[J+4>>2]|0;if((K|0)>0|(K|0)==0&(f[J>>2]|0)>>>0>0)L=H;else{f[e>>2]=f[I+4>>2];f[d>>2]=f[e>>2];Me(I,d,h,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(f[(f[s>>2]|0)+12>>2]|0)+(V<<2)>>2]|0;V=(X|0)==-1;U=V?-1:(X>>>0)/3|0;if(V)break;if(f[(f[v>>2]|0)+(U>>>5<<2)>>2]&1<<(U&31)|0)break;f[l>>2]=X;f[d>>2]=f[l>>2];if(!(Yb(a,d)|0))break b}else{X=P+1|0;if(Q)_=-1;else _=((X>>>0)%3|0|0)==0?P+-2|0:X;f[m>>2]=_;f[d>>2]=f[m>>2];Pe(a,d,1)|0;f[n>>2]=f[e>>2];f[d>>2]=f[n>>2];if(!(Yb(a,d)|0))break b}while(0)}K=K+1|0;if((K|0)>=(L|0)){$=62;break a}}aa=0}else $=62;while(0);if(($|0)==62){$=f[F>>2]|0;L=f[E>>2]|0;n=L;if(($|0)!=(L|0)?(m=L+-4|0,$>>>0>>0):0){L=$;$=m;do{m=f[L>>2]|0;f[L>>2]=f[$>>2];f[$>>2]=m;L=L+4|0;$=$+-4|0}while(L>>>0<$>>>0)}f[o>>2]=n;f[p>>2]=f[i>>2];f[q>>2]=f[I>>2];f[g>>2]=f[o>>2];f[e>>2]=f[p>>2];f[d>>2]=f[q>>2];Yd(F,g,e,d)|0;if((f[G>>2]|0)!=(f[D>>2]|0)?(D=f[y>>2]|0,y=((f[D+100>>2]|0)-(f[D+96>>2]|0)|0)/12|0,b[d>>0]=0,qh(v,y,d),y=f[F>>2]|0,F=f[E>>2]|0,(y|0)!=(F|0)):0){E=y;do{f[r>>2]=f[E>>2];f[d>>2]=f[r>>2];He(a,d)|0;E=E+4|0}while((E|0)!=(F|0))}pi(t);ci(f[a+324>>2]|0,f[(f[x>>2]|0)+44>>2]|0)|0;ci(f[z>>2]|0,f[(f[x>>2]|0)+44>>2]|0)|0;if(bh(a)|0){z=f[(f[x>>2]|0)+44>>2]|0;x=f[a+232>>2]|0;t=z+16|0;F=f[t+4>>2]|0;if(!((F|0)>0|(F|0)==0&(f[t>>2]|0)>>>0>0)){t=(f[a+236>>2]|0)-x|0;f[e>>2]=f[z+4>>2];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]|0)+(v<<2)>>2]|0;else D=v;C=D+239^B;A=A+1|0;if((A|0)>=(x|0)){E=C;break}else B=C}}else E=0;B=f[q>>2]|0;x=(B|0)==0;a:do if(!x){A=B+-1|0;C=(A&B|0)==0;if(!C)if(E>>>0>>0)F=E;else F=(E>>>0)%(B>>>0)|0;else F=A&E;G=f[(f[d>>2]|0)+(F<<2)>>2]|0;if((G|0)!=0?(H=f[G>>2]|0,(H|0)!=0):0){G=f[s>>2]|0;I=G+8|0;J=G+12|0;b:do if(C){G=H;while(1){K=f[G+4>>2]|0;L=(K|0)==(E|0);if(!(L|(K&A|0)==(F|0))){M=44;break a}c:do if(L){K=f[G+8>>2]|0;N=f[I>>2]|0;O=(f[J>>2]|0)-N|0;P=N;if((O|0)<=0){Q=G;break b}N=O>>>2;O=0;while(1){R=f[P+(O<<2)>>2]|0;if(!(b[R+84>>0]|0)){S=f[R+68>>2]|0;T=f[S+(v<<2)>>2]|0;U=f[S+(K<<2)>>2]|0}else{T=v;U=K}O=O+1|0;if((U|0)!=(T|0))break c;if((O|0)>=(N|0)){V=G;M=42;break b}}}while(0);G=f[G>>2]|0;if(!G){M=44;break a}}}else{G=H;while(1){L=f[G+4>>2]|0;d:do if((L|0)!=(E|0)){if(L>>>0>>0)X=L;else X=(L>>>0)%(B>>>0)|0;if((X|0)!=(F|0)){M=44;break a}}else{N=f[G+8>>2]|0;O=f[I>>2]|0;K=(f[J>>2]|0)-O|0;P=O;if((K|0)<=0){Q=G;break b}O=K>>>2;K=0;while(1){S=f[P+(K<<2)>>2]|0;if(!(b[S+84>>0]|0)){R=f[S+68>>2]|0;Y=f[R+(v<<2)>>2]|0;Z=f[R+(N<<2)>>2]|0}else{Y=v;Z=N}K=K+1|0;if((Z|0)!=(Y|0))break d;if((K|0)>=(O|0)){V=G;M=42;break b}}}while(0);G=f[G>>2]|0;if(!G){M=44;break a}}}while(0);if((M|0)==42){M=0;if(!V){M=44;break}else Q=V}f[(f[e>>2]|0)+(v<<2)>>2]=f[Q+12>>2];_=t}else M=44}else M=44;while(0);do if((M|0)==44){M=0;if(w){J=y>>>2;I=0;H=0;while(1){A=f[z+(I<<2)>>2]|0;if(!(b[A+84>>0]|0))aa=f[(f[A+68>>2]|0)+(v<<2)>>2]|0;else aa=v;A=aa+239^H;I=I+1|0;if((I|0)>=(J|0)){ba=A;break}else H=A}}else ba=0;e:do if(!x){H=B+-1|0;J=(H&B|0)==0;if(!J)if(ba>>>0>>0)ca=ba;else ca=(ba>>>0)%(B>>>0)|0;else ca=H&ba;I=f[(f[d>>2]|0)+(ca<<2)>>2]|0;if((I|0)!=0?(A=f[I>>2]|0,(A|0)!=0):0){I=f[s>>2]|0;C=I+8|0;G=I+12|0;if(J){J=A;while(1){I=f[J+4>>2]|0;if(!((I|0)==(ba|0)|(I&H|0)==(ca|0))){da=ca;M=76;break e}I=f[J+8>>2]|0;L=f[C>>2]|0;O=(f[G>>2]|0)-L|0;K=L;if((O|0)<=0){ea=v;break e}L=O>>>2;O=0;while(1){N=f[K+(O<<2)>>2]|0;if(!(b[N+84>>0]|0)){P=f[N+68>>2]|0;fa=f[P+(v<<2)>>2]|0;ga=f[P+(I<<2)>>2]|0}else{fa=v;ga=I}O=O+1|0;if((ga|0)!=(fa|0))break;if((O|0)>=(L|0)){ea=v;break e}}J=f[J>>2]|0;if(!J){da=ca;M=76;break e}}}else ha=A;while(1){J=f[ha+4>>2]|0;if((J|0)!=(ba|0)){if(J>>>0>>0)ia=J;else ia=(J>>>0)%(B>>>0)|0;if((ia|0)!=(ca|0)){da=ca;M=76;break e}}J=f[ha+8>>2]|0;H=f[C>>2]|0;L=(f[G>>2]|0)-H|0;O=H;if((L|0)<=0){ea=v;break e}H=L>>>2;L=0;while(1){I=f[O+(L<<2)>>2]|0;if(!(b[I+84>>0]|0)){K=f[I+68>>2]|0;ja=f[K+(v<<2)>>2]|0;ka=f[K+(J<<2)>>2]|0}else{ja=v;ka=J}L=L+1|0;if((ka|0)!=(ja|0))break;if((L|0)>=(H|0)){ea=v;break e}}ha=f[ha>>2]|0;if(!ha){da=ca;M=76;break}}}else{da=ca;M=76}}else{da=0;M=76}while(0);if((M|0)==76){M=0;G=ln(16)|0;f[G+8>>2]=v;f[G+12>>2]=t;f[G+4>>2]=ba;f[G>>2]=0;la=$(((f[o>>2]|0)+1|0)>>>0);ma=$(B>>>0);na=$(n[l>>2]);do if(x|$(na*ma)>>0<3|(B+-1&B|0)!=0)&1;A=~~$(W($(la/na)))>>>0;Ih(d,C>>>0>>0?A:C);C=f[q>>2]|0;A=C+-1|0;if(!(A&C)){oa=C;pa=A&ba;break}if(ba>>>0>>0){oa=C;pa=ba}else{oa=C;pa=(ba>>>0)%(C>>>0)|0}}else{oa=B;pa=da}while(0);C=(f[d>>2]|0)+(pa<<2)|0;A=f[C>>2]|0;if(!A){f[G>>2]=f[p>>2];f[p>>2]=G;f[C>>2]=p;C=f[G>>2]|0;if(C|0){H=f[C+4>>2]|0;C=oa+-1|0;if(C&oa)if(H>>>0>>0)qa=H;else qa=(H>>>0)%(oa>>>0)|0;else qa=H&C;ra=(f[d>>2]|0)+(qa<<2)|0;M=89}}else{f[G>>2]=f[A>>2];ra=A;M=89}if((M|0)==89){M=0;f[ra>>2]=G}f[o>>2]=(f[o>>2]|0)+1;ea=f[h>>2]|0}A=t+1|0;f[(f[e>>2]|0)+(ea<<2)>>2]=t;C=f[k>>2]|0;if((C|0)==(f[r>>2]|0)){Ri(g,h);_=A;break}else{f[C>>2]=f[h>>2];f[k>>2]=C+4;_=A;break}}while(0);v=(f[h>>2]|0)+1|0;f[h>>2]=v;sa=f[j>>2]|0;if(v>>>0>=sa>>>0)break;else t=_}if((_|0)!=(sa|0)){Xa[f[(f[a>>2]|0)+24>>2]&15](a,e,g);f[j>>2]=_}}_=f[g>>2]|0;if(_|0){g=f[k>>2]|0;if((g|0)!=(_|0))f[k>>2]=g+(~((g+-4-_|0)>>>2)<<2);Oq(_)}_=f[e>>2]|0;if(_|0){e=f[i>>2]|0;if((e|0)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,M|0)|0;M=I;T=un(F|0,E|0,F|0,E|0)|0;E=Vn(T|0,I|0,B|0,M|0)|0;M=I;B=a+16|0;T=a+20|0;F=f[T>>2]|0;O=f[a+24>>2]|0;P=(F|0)==(O<<5|0);if(J>>>0>>0|(J|0)==(M|0)&U>>>0>>0){do if(P)if((F+1|0)<0)aq(B);else{E=O<<6;U=F+32&-32;vi(B,F>>>0<1073741823?(E>>>0>>0?U:E):2147483647);da=f[T>>2]|0;break}else da=F;while(0);f[T>>2]=da+1;L=(f[B>>2]|0)+(da>>>5<<2)|0;f[L>>2]=f[L>>2]|1<<(da&31);ea=x;fa=p;ga=K;ha=D}else{do if(P)if((F+1|0)<0)aq(B);else{L=O<<6;N=F+32&-32;vi(B,F>>>0<1073741823?(L>>>0>>0?N:L):2147483647);ia=f[T>>2]|0;break}else ia=F;while(0);f[T>>2]=ia+1;F=(f[B>>2]|0)+(ia>>>5<<2)|0;f[F>>2]=f[F>>2]&~(1<<(ia&31));ea=G;fa=H;ga=C;ha=s}f[a+8>>2]=ea;f[a+12>>2]=fa;u=g;return}while(0);do if(r)ja=m<<1;else{if((e|0)>0){ja=(e<<1)+-2|0;break}fa=a+8|0;f[fa>>2]=0;f[fa+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+(ja<<2)>>2];f[a+12>>2]=f[d+(ja+1<<2)>>2];u=g;return}function ub(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0;g=u;u=u+80|0;h=g+76|0;i=g+72|0;j=g+48|0;k=g+24|0;l=g;m=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&31));ea=G;fa=H;ga=C;ha=s}f[a+8>>2]=ea;f[a+12>>2]=fa;u=g;return}while(0);do if(q)ja=n<<1;else{if((e|0)>0){ja=(e<<1)+-2|0;break}fa=a+8|0;f[fa>>2]=0;f[fa+4>>2]=0;u=g;return}while(0);f[a+8>>2]=f[d+(ja<<2)>>2];f[a+12>>2]=f[d+(ja+1<<2)>>2];u=g;return}function vb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=Oa,D=0,E=0.0,F=0,G=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){m=b[o>>0]|0;q=g+(r<<3)|0;f[q>>2]=m;f[q+4>>2]=((m|0)<0)<<31>>31;r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=g+(t<<3)|0;f[k>>2]=h[m>>0];f[k+4>>2]=0;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){o=d[l>>1]|0;k=g+(q<<3)|0;f[k>>2]=o;f[k+4>>2]=((o|0)<0)<<31>>31;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=j[r>>1];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<3)|0,0,(e<<24>>24)-r<<3|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){l=f[t>>2]|0;m=g+(o<<3)|0;f[m>>2]=l;f[m+4>>2]=((l|0)<0)<<31>>31;o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<3)|0,0,(e<<24>>24)-t<<3|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){r=g+(m<<3)|0;f[r>>2]=f[q>>2];f[r+4>>2]=0;m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<3)|0,0,(e<<24>>24)-q<<3|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){t=k;r=f[t+4>>2]|0;z=g+(l<<3)|0;f[z>>2]=f[t>>2];f[z+4>>2]=r;l=l+1|0;r=b[q>>0]|0;if((l|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){A=r;break}else k=k+8|0}}else A=m;k=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<3)|0,0,(e<<24>>24)-k<<3|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;r=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;z=Vn(r|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+z|0;z=0;while(1){q=o;r=f[q+4>>2]|0;t=g+(z<<3)|0;f[t>>2]=f[q>>2];f[t+4>>2]=r;z=z+1|0;r=b[k>>0]|0;if((z|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){B=r;break}else o=o+8|0}}else B=l;o=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<3)|0,0,(e<<24>>24)-o<<3|0)|0;i=1;return i|0}case 9:{o=a+24|0;z=b[o>>0]|0;if((z<<24>>24>e<<24>>24?e:z)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;r=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(r|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){C=$(n[m>>2]);k=+K(+C)>=1.0?(+C>0.0?~~+Y(+J(+C/4294967296.0),4294967295.0)>>>0:~~+W((+C-+(~~+C>>>0))/4294967296.0)>>>0):0;r=g+(t<<3)|0;f[r>>2]=~~+C>>>0;f[r+4>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){D=k;break}else m=m+4|0}}else D=z;m=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<3)|0,0,(e<<24>>24)-m<<3|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;r=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+r|0;r=0;while(1){E=+p[l>>3];o=+K(E)>=1.0?(E>0.0?~~+Y(+J(E/4294967296.0),4294967295.0)>>>0:~~+W((E-+(~~E>>>0))/4294967296.0)>>>0):0;k=g+(r<<3)|0;f[k>>2]=~~E>>>0;f[k+4>>2]=o;r=r+1|0;o=b[m>>0]|0;if((r|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){F=o;break}else l=l+8|0}}else F=t;l=F<<24>>24;if(F<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<3)|0,0,(e<<24>>24)-l<<3|0)|0;i=1;return i|0}case 11:{l=a+24|0;r=b[l>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){m=f[f[a>>2]>>2]|0;z=a+40|0;o=un(f[z>>2]|0,f[z+4>>2]|0,f[c>>2]|0,0)|0;z=a+48|0;k=Vn(o|0,I|0,f[z>>2]|0,f[z+4>>2]|0)|0;z=m+k|0;k=0;while(1){m=g+(k<<3)|0;f[m>>2]=h[z>>0];f[m+4>>2]=0;k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){G=m;break}else z=z+1|0}}else G=r;z=G<<24>>24;if(G<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(z<<3)|0,0,(e<<24>>24)-z<<3|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function wb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P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2|0;break}else{r=q+-1|0;break}else r=-1;while(0);f[e>>2]=r;q=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((r>>>0)/3|0)*12|0)+(((r>>>0)%3|0)<<2)>>2]|0;r=f[a+48>>2]|0;f[d>>2]=q;o=f[r+4>>2]|0;r=o+4|0;h=f[r>>2]|0;if((h|0)==(f[o+8>>2]|0))Ri(o,d);else{f[h>>2]=q;f[r>>2]=h+4}h=a+40|0;r=f[h>>2]|0;q=r+4|0;o=f[q>>2]|0;if((o|0)==(f[r+8>>2]|0)){Ri(r,e);s=f[h>>2]|0}else{f[o>>2]=f[e>>2];f[q>>2]=o+4;s=r}r=s+24|0;f[(f[s+12>>2]|0)+(n<<2)>>2]=f[r>>2];f[r>>2]=(f[r>>2]|0)+1}r=f[i>>2]|0;if((r|0)==-1)t=-1;else t=f[(f[f[a>>2]>>2]|0)+(r<<2)>>2]|0;r=(f[k>>2]|0)+(t>>>5<<2)|0;n=1<<(t&31);s=f[r>>2]|0;if(!(n&s)){f[r>>2]=s|n;n=f[i>>2]|0;f[e>>2]=n;s=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((n>>>0)/3|0)*12|0)+(((n>>>0)%3|0)<<2)>>2]|0;n=f[a+48>>2]|0;f[d>>2]=s;r=f[n+4>>2]|0;n=r+4|0;o=f[n>>2]|0;if((o|0)==(f[r+8>>2]|0))Ri(r,d);else{f[o>>2]=s;f[n>>2]=o+4}o=a+40|0;n=f[o>>2]|0;s=n+4|0;r=f[s>>2]|0;if((r|0)==(f[n+8>>2]|0)){Ri(n,e);v=f[o>>2]|0}else{f[r>>2]=f[e>>2];f[s>>2]=r+4;v=n}n=v+24|0;f[(f[v+12>>2]|0)+(t<<2)>>2]=f[n>>2];f[n>>2]=(f[n>>2]|0)+1}n=f[b>>2]|0;a:do if((n|0)<3){t=a+12|0;v=a+44|0;r=a+48|0;s=a+40|0;o=a+92|0;q=n;while(1){h=q;while(1){w=a+52+(h*12|0)+4|0;x=f[w>>2]|0;if((f[a+52+(h*12|0)>>2]|0)!=(x|0))break;if((h|0)<2)h=h+1|0;else break a}m=x+-4|0;p=f[m>>2]|0;f[w>>2]=m;f[b>>2]=h;f[i>>2]=p;if((p|0)==-1)break;m=(p>>>0)/3|0;g=f[t>>2]|0;do if(!(f[g+(m>>>5<<2)>>2]&1<<(m&31))){j=p;l=g;b:while(1){y=(j>>>0)/3|0;z=l+(y>>>5<<2)|0;f[z>>2]=1<<(y&31)|f[z>>2];z=f[i>>2]|0;if((z|0)==-1)A=-1;else A=f[(f[f[a>>2]>>2]|0)+(z<<2)>>2]|0;y=(f[k>>2]|0)+(A>>>5<<2)|0;B=1<<(A&31);C=f[y>>2]|0;if(!(B&C)){f[y>>2]=C|B;B=f[i>>2]|0;f[e>>2]=B;C=f[(f[(f[v>>2]|0)+96>>2]|0)+(((B>>>0)/3|0)*12|0)+(((B>>>0)%3|0)<<2)>>2]|0;B=f[r>>2]|0;f[d>>2]=C;y=f[B+4>>2]|0;B=y+4|0;D=f[B>>2]|0;if((D|0)==(f[y+8>>2]|0))Ri(y,d);else{f[D>>2]=C;f[B>>2]=D+4}D=f[s>>2]|0;B=D+4|0;C=f[B>>2]|0;if((C|0)==(f[D+8>>2]|0)){Ri(D,e);E=f[s>>2]|0}else{f[C>>2]=f[e>>2];f[B>>2]=C+4;E=D}D=E+24|0;f[(f[E+12>>2]|0)+(A<<2)>>2]=f[D>>2];f[D>>2]=(f[D>>2]|0)+1;F=f[i>>2]|0}else F=z;z=f[a>>2]|0;if((F|0)==-1){G=93;break}D=F+1|0;C=((D>>>0)%3|0|0)==0?F+-2|0:D;if((C|0)==-1)H=-1;else H=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(((F>>>0)%3|0|0)==0?2:-1)+F|0;if((C|0)==-1)I=-1;else I=f[(f[z+12>>2]|0)+(C<<2)>>2]|0;C=(H|0)==-1;D=C?-1:(H>>>0)/3|0;B=(I|0)==-1;y=B?-1:(I>>>0)/3|0;if(C)J=1;else J=(f[(f[t>>2]|0)+(D>>>5<<2)>>2]&1<<(D&31)|0)!=0;do if(B)if(J){G=93;break b}else G=82;else{if(f[(f[t>>2]|0)+(y>>>5<<2)>>2]&1<<(y&31)|0)if(J){G=93;break b}else{G=82;break}D=f[(f[z>>2]|0)+(I<<2)>>2]|0;if(!(1<<(D&31)&f[(f[k>>2]|0)+(D>>>5<<2)>>2])){K=(f[o>>2]|0)+(D<<2)|0;D=f[K>>2]|0;f[K>>2]=D+1;L=(D|0)>0?1:2}else L=0;if(J?(L|0)<=(f[b>>2]|0):0){M=I;break}f[d>>2]=I;D=a+52+(L*12|0)+4|0;K=f[D>>2]|0;if((K|0)==(f[a+52+(L*12|0)+8>>2]|0))Ri(a+52+(L*12|0)|0,d);else{f[K>>2]=I;f[D>>2]=K+4}if((f[b>>2]|0)>(L|0))f[b>>2]=L;if(J){G=93;break b}else G=82}while(0);if((G|0)==82){G=0;if(C)N=-1;else N=f[(f[f[a>>2]>>2]|0)+(H<<2)>>2]|0;if(!(1<<(N&31)&f[(f[k>>2]|0)+(N>>>5<<2)>>2])){z=(f[o>>2]|0)+(N<<2)|0;y=f[z>>2]|0;f[z>>2]=y+1;O=(y|0)>0?1:2}else O=0;if((O|0)>(f[b>>2]|0))break;else M=H}f[i>>2]=M;j=M;l=f[t>>2]|0}if((G|0)==93){G=0;P=f[b>>2]|0;break}f[d>>2]=H;l=a+52+(O*12|0)+4|0;j=f[l>>2]|0;if((j|0)==(f[a+52+(O*12|0)+8>>2]|0))Ri(a+52+(O*12|0)|0,d);else{f[j>>2]=H;f[l>>2]=j+4}j=f[b>>2]|0;if((j|0)>(O|0)){f[b>>2]=O;Q=O}else Q=j;P=Q}else P=h;while(0);if((P|0)<3)q=P;else break a}u=c;return}while(0);f[i>>2]=-1;u=c;return}function xb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}xb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;xb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function yb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}yb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;yb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function zb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}zb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;zb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ab(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ab(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ab(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}} +function Bb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Bb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Bb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Cb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Cb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Cb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Db(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Db(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Db(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Eb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Eb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Eb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Fb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Fb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Gb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Gb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Gb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Hb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Hb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Hb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ib(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ib(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ib(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Jb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Jb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Jb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Kb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Kb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Kb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Lb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Lb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Lb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Mb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Mb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Mb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Nb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Nb(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Nb(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Ob(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=a;a=b;a:while(1){b=a;e=a+-4|0;g=d;while(1){h=g;b:while(1){i=h;j=b-i|0;k=j>>2;switch(k|0){case 2:{l=5;break a;break}case 3:{l=11;break a;break}case 4:{l=12;break a;break}case 5:{l=13;break a;break}case 1:case 0:{l=84;break a;break}default:{}}if((j|0)<124){l=15;break a}m=h+(((k|0)/2|0)<<2)|0;if((j|0)>3996){j=(k|0)/4|0;n=ig(h,h+(j<<2)|0,m,m+(j<<2)|0,e,c)|0}else n=Vg(h,m,e,c)|0;o=f[h>>2]|0;j=f[m>>2]|0;p=f[c>>2]|0;k=f[p>>2]|0;q=(f[p+4>>2]|0)-k>>3;if(q>>>0<=o>>>0){l=20;break a}r=k;if(q>>>0<=j>>>0){l=22;break a}k=f[r+(o<<3)>>2]|0;s=f[r+(j<<3)>>2]|0;if(k>>>0>>0){t=e;u=n;break}else v=e;while(1){v=v+-4|0;if((h|0)==(v|0))break;w=f[v>>2]|0;if(q>>>0<=w>>>0){l=51;break a}if((f[r+(w<<3)>>2]|0)>>>0>>0){l=53;break b}}s=h+4|0;j=f[e>>2]|0;if(q>>>0<=j>>>0){l=26;break a}if(k>>>0<(f[r+(j<<3)>>2]|0)>>>0)x=s;else{if((s|0)==(e|0)){l=84;break a}else y=s;while(1){z=f[y>>2]|0;if(q>>>0<=z>>>0){l=32;break a}if(k>>>0<(f[r+(z<<3)>>2]|0)>>>0)break;s=y+4|0;if((s|0)==(e|0)){l=84;break a}else y=s}f[y>>2]=j;f[e>>2]=z;x=y+4|0}if((x|0)==(e|0)){l=84;break a}r=f[h>>2]|0;A=f[c>>2]|0;k=f[A>>2]|0;q=(f[A+4>>2]|0)-k>>3;if(q>>>0<=r>>>0){l=38;break a}s=k;k=e;B=x;C=r;while(1){r=s+(C<<3)|0;D=q>>>0>C>>>0;E=B;while(1){F=f[E>>2]|0;if(q>>>0<=F>>>0){l=40;break a}G=f[r>>2]|0;if(G>>>0<(f[s+(F<<3)>>2]|0)>>>0)break;if(D)E=E+4|0;else{l=38;break a}}if(q>>>0>C>>>0)H=k;else{l=46;break a}do{H=H+-4|0;I=f[H>>2]|0;if(q>>>0<=I>>>0){l=47;break a}}while(G>>>0<(f[s+(I<<3)>>2]|0)>>>0);if(E>>>0>=H>>>0){h=E;continue b}D=f[E>>2]|0;f[E>>2]=I;f[H>>2]=D;C=f[h>>2]|0;if(q>>>0<=C>>>0){l=38;break a}else{k=H;B=E+4|0}}}if((l|0)==53){l=0;f[h>>2]=w;f[v>>2]=o;t=v;u=n+1|0}B=h+4|0;c:do if(B>>>0>>0){k=f[B>>2]|0;C=f[c>>2]|0;q=f[C>>2]|0;s=(f[C+4>>2]|0)-q>>3;if(s>>>0>k>>>0){J=t;K=B;L=u;M=m;N=s;O=q;P=C;Q=k}else{R=C;l=57;break a}while(1){C=f[c>>2]|0;k=C+4|0;q=f[M>>2]|0;s=K;j=O;D=N;S=P;r=Q;while(1){F=j;if(D>>>0<=q>>>0){l=59;break a}if((f[F+(r<<3)>>2]|0)>>>0>=(f[F+(q<<3)>>2]|0)>>>0)break;F=s+4|0;T=f[F>>2]|0;j=f[C>>2]|0;D=(f[k>>2]|0)-j>>3;if(D>>>0<=T>>>0){R=C;l=57;break a}else{s=F;S=C;r=T}}C=f[M>>2]|0;O=f[S>>2]|0;N=(f[S+4>>2]|0)-O>>3;D=O;j=D+(C<<3)|0;if(N>>>0>C>>>0)U=J;else{l=65;break a}do{U=U+-4|0;V=f[U>>2]|0;if(N>>>0<=V>>>0){l=66;break a}}while((f[D+(V<<3)>>2]|0)>>>0>=(f[j>>2]|0)>>>0);if(s>>>0>U>>>0){W=M;X=L;Y=s;break c}f[s>>2]=V;f[U>>2]=r;K=s+4|0;Q=f[K>>2]|0;if(N>>>0<=Q>>>0){R=S;l=57;break a}else{J=U;L=L+1|0;M=(M|0)==(s|0)?U:M;P=S}}}else{W=m;X=u;Y=B}while(0);if((Y|0)!=(W|0)){B=f[W>>2]|0;j=f[Y>>2]|0;Z=f[c>>2]|0;D=f[Z>>2]|0;C=(f[Z+4>>2]|0)-D>>3;if(C>>>0<=B>>>0){l=72;break a}k=D;if(C>>>0<=j>>>0){l=74;break a}if((f[k+(B<<3)>>2]|0)>>>0<(f[k+(j<<3)>>2]|0)>>>0){f[Y>>2]=B;f[W>>2]=j;_=X+1|0}else _=X}else _=X;if(!_){$=_d(h,Y,c)|0;j=Y+4|0;if(_d(j,a,c)|0){l=83;break}if($){g=j;continue}}j=Y;if((j-i|0)>=(b-j|0)){l=82;break}Ob(h,Y,c);g=Y+4|0}if((l|0)==82){l=0;Ob(Y+4|0,a,c);d=h;a=Y;continue}else if((l|0)==83){l=0;if($){l=84;break}else{d=h;a=Y;continue}}}switch(l|0){case 5:{l=f[e>>2]|0;Y=f[h>>2]|0;d=f[c>>2]|0;$=f[d>>2]|0;i=(f[d+4>>2]|0)-$>>3;if(i>>>0<=l>>>0)aq(d);_=$;if(i>>>0<=Y>>>0)aq(d);if((f[_+(l<<3)>>2]|0)>>>0>=(f[_+(Y<<3)>>2]|0)>>>0)return;f[h>>2]=l;f[e>>2]=Y;return}case 11:{Vg(h,h+4|0,e,c)|0;return}case 12:{jh(h,h+4|0,h+8|0,e,c)|0;return}case 13:{ig(h,h+4|0,h+8|0,h+12|0,e,c)|0;return}case 15:{ih(h,a,c);return}case 20:{aq(p);break}case 22:{aq(p);break}case 26:{aq(p);break}case 32:{aq(p);break}case 38:{aq(A);break}case 40:{aq(A);break}case 46:{aq(A);break}case 47:{aq(A);break}case 51:{aq(p);break}case 57:{aq(R);break}case 59:{aq(S);break}case 65:{if(N>>>0>(f[J+-4>>2]|0)>>>0)aq(S);else aq(S);break}case 66:{aq(S);break}case 72:{aq(Z);break}case 74:{aq(Z);break}case 84:return}}function Pb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2])>>>0;f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3]>>>0;q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Qb(a,c,e,g){a=a|0;c=c|0;e=e|0;g=g|0;var i=0,k=0,l=0,m=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!g){i=0;return i|0}do switch(f[a+28>>2]|0){case 1:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){m=f[f[a>>2]>>2]|0;o=a+40|0;q=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(q|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=m+r|0;r=0;while(1){f[g+(r<<2)>>2]=b[o>>0];r=r+1|0;m=b[k>>0]|0;if((r|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){s=m;break}else o=o+1|0}}else s=l;o=s<<24>>24;if(s<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 2:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){f[g+(t<<2)>>2]=h[m>>0];t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){u=k;break}else m=m+1|0}}else u=r;m=u<<24>>24;if(u<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 3:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=d[l>>1];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){v=o;break}else l=l+2|0}}else v=t;l=v<<24>>24;if(v<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 4:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=j[r>>1];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){w=m;break}else r=r+2|0}}else w=q;r=w<<24>>24;if(w<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}case 5:{r=a+24|0;k=b[r>>0]|0;if((k<<24>>24>e<<24>>24?e:k)<<24>>24>0){l=f[f[a>>2]>>2]|0;t=a+40|0;m=un(f[t>>2]|0,f[t+4>>2]|0,f[c>>2]|0,0)|0;t=a+48|0;o=Vn(m|0,I|0,f[t>>2]|0,f[t+4>>2]|0)|0;t=l+o|0;o=0;while(1){f[g+(o<<2)>>2]=f[t>>2];o=o+1|0;l=b[r>>0]|0;if((o|0)>=((l<<24>>24>e<<24>>24?e:l)<<24>>24|0)){x=l;break}else t=t+4|0}}else x=k;t=x<<24>>24;if(x<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(t<<2)|0,0,(e<<24>>24)-t<<2|0)|0;i=1;return i|0}case 6:{t=a+24|0;o=b[t>>0]|0;if((o<<24>>24>e<<24>>24?e:o)<<24>>24>0){r=f[f[a>>2]>>2]|0;q=a+40|0;l=un(f[q>>2]|0,f[q+4>>2]|0,f[c>>2]|0,0)|0;q=a+48|0;m=Vn(l|0,I|0,f[q>>2]|0,f[q+4>>2]|0)|0;q=r+m|0;m=0;while(1){f[g+(m<<2)>>2]=f[q>>2];m=m+1|0;r=b[t>>0]|0;if((m|0)>=((r<<24>>24>e<<24>>24?e:r)<<24>>24|0)){y=r;break}else q=q+4|0}}else y=o;q=y<<24>>24;if(y<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(q<<2)|0,0,(e<<24>>24)-q<<2|0)|0;i=1;return i|0}case 7:{q=a+24|0;m=b[q>>0]|0;if((m<<24>>24>e<<24>>24?e:m)<<24>>24>0){t=f[f[a>>2]>>2]|0;k=a+40|0;r=un(f[k>>2]|0,f[k+4>>2]|0,f[c>>2]|0,0)|0;k=a+48|0;l=Vn(r|0,I|0,f[k>>2]|0,f[k+4>>2]|0)|0;k=t+l|0;l=0;while(1){f[g+(l<<2)>>2]=f[k>>2];l=l+1|0;t=b[q>>0]|0;if((l|0)>=((t<<24>>24>e<<24>>24?e:t)<<24>>24|0)){z=t;break}else k=k+8|0}}else z=m;k=z<<24>>24;if(z<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(k<<2)|0,0,(e<<24>>24)-k<<2|0)|0;i=1;return i|0}case 8:{k=a+24|0;l=b[k>>0]|0;if((l<<24>>24>e<<24>>24?e:l)<<24>>24>0){q=f[f[a>>2]>>2]|0;o=a+40|0;t=un(f[o>>2]|0,f[o+4>>2]|0,f[c>>2]|0,0)|0;o=a+48|0;r=Vn(t|0,I|0,f[o>>2]|0,f[o+4>>2]|0)|0;o=q+r|0;r=0;while(1){f[g+(r<<2)>>2]=f[o>>2];r=r+1|0;q=b[k>>0]|0;if((r|0)>=((q<<24>>24>e<<24>>24?e:q)<<24>>24|0)){A=q;break}else o=o+8|0}}else A=l;o=A<<24>>24;if(A<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(o<<2)|0,0,(e<<24>>24)-o<<2|0)|0;i=1;return i|0}case 9:{o=a+24|0;r=b[o>>0]|0;if((r<<24>>24>e<<24>>24?e:r)<<24>>24>0){k=f[f[a>>2]>>2]|0;m=a+40|0;q=un(f[m>>2]|0,f[m+4>>2]|0,f[c>>2]|0,0)|0;m=a+48|0;t=Vn(q|0,I|0,f[m>>2]|0,f[m+4>>2]|0)|0;m=k+t|0;t=0;while(1){k=~~$(n[m>>2]);f[g+(t<<2)>>2]=k;t=t+1|0;k=b[o>>0]|0;if((t|0)>=((k<<24>>24>e<<24>>24?e:k)<<24>>24|0)){B=k;break}else m=m+4|0}}else B=r;m=B<<24>>24;if(B<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(m<<2)|0,0,(e<<24>>24)-m<<2|0)|0;i=1;return i|0}case 10:{m=a+24|0;t=b[m>>0]|0;if((t<<24>>24>e<<24>>24?e:t)<<24>>24>0){o=f[f[a>>2]>>2]|0;l=a+40|0;k=un(f[l>>2]|0,f[l+4>>2]|0,f[c>>2]|0,0)|0;l=a+48|0;q=Vn(k|0,I|0,f[l>>2]|0,f[l+4>>2]|0)|0;l=o+q|0;q=0;while(1){f[g+(q<<2)>>2]=~~+p[l>>3];q=q+1|0;o=b[m>>0]|0;if((q|0)>=((o<<24>>24>e<<24>>24?e:o)<<24>>24|0)){C=o;break}else l=l+8|0}}else C=t;l=C<<24>>24;if(C<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(l<<2)|0,0,(e<<24>>24)-l<<2|0)|0;i=1;return i|0}case 11:{l=a+24|0;q=b[l>>0]|0;if((q<<24>>24>e<<24>>24?e:q)<<24>>24>0){m=f[f[a>>2]>>2]|0;r=a+40|0;o=un(f[r>>2]|0,f[r+4>>2]|0,f[c>>2]|0,0)|0;r=a+48|0;k=Vn(o|0,I|0,f[r>>2]|0,f[r+4>>2]|0)|0;r=m+k|0;k=0;while(1){f[g+(k<<2)>>2]=h[r>>0];k=k+1|0;m=b[l>>0]|0;if((k|0)>=((m<<24>>24>e<<24>>24?e:m)<<24>>24|0)){D=m;break}else r=r+1|0}}else D=q;r=D<<24>>24;if(D<<24>>24>=e<<24>>24){i=1;return i|0}sj(g+(r<<2)|0,0,(e<<24>>24)-r<<2|0)|0;i=1;return i|0}default:{i=0;return i|0}}while(0);return 0}function Rb(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=Oa,J=0,K=0,L=0,M=0,N=Oa;e=u;u=u+48|0;g=e+36|0;h=e+24|0;i=e+12|0;j=e;if(!(xh(a,c,d)|0)){k=0;u=e;return k|0}l=f[(f[(f[c+4>>2]|0)+8>>2]|0)+(d<<2)>>2]|0;if((f[l+28>>2]|0)!=9){k=0;u=e;return k|0}m=c+48|0;c=f[m>>2]|0;o=ln(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=17;p=o;q=14495;r=p+17|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+17>>0]=0;o=c+16|0;s=f[o>>2]|0;if(s){t=o;v=s;a:while(1){s=v;while(1){if((f[s+16>>2]|0)>=(d|0))break;w=f[s+4>>2]|0;if(!w){x=t;break a}else s=w}v=f[s>>2]|0;if(!v){x=s;break}else t=s}if(((x|0)!=(o|0)?(f[x+16>>2]|0)<=(d|0):0)?(o=x+20|0,(Jh(o,g)|0)!=0):0)y=Hk(o,g,-1)|0;else z=12}else z=12;if((z|0)==12)y=Hk(c,g,-1)|0;if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if((y|0)<1){k=0;u=e;return k|0}c=f[m>>2]|0;o=ln(32)|0;f[g>>2]=o;f[g+8>>2]=-2147483616;f[g+4>>2]=19;p=o;q=14438;r=p+19|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[o+19>>0]=0;o=c+16|0;x=f[o>>2]|0;if(x){t=o;v=x;b:while(1){x=v;while(1){if((f[x+16>>2]|0)>=(d|0))break;w=f[x+4>>2]|0;if(!w){A=t;break b}else x=w}v=f[x>>2]|0;if(!v){A=x;break}else t=x}if((A|0)!=(o|0)?(f[A+16>>2]|0)<=(d|0):0)B=A+20|0;else z=24}else z=24;if((z|0)==24)B=c;if(!(Jh(B,g)|0))C=0;else{B=f[m>>2]|0;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;c=ln(32)|0;f[h>>2]=c;f[h+8>>2]=-2147483616;f[h+4>>2]=18;p=c;q=14458;r=p+18|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[c+18>>0]=0;c=B+16|0;A=f[c>>2]|0;if(A){o=c;t=A;c:while(1){A=t;while(1){if((f[A+16>>2]|0)>=(d|0))break;v=f[A+4>>2]|0;if(!v){D=o;break c}else A=v}t=f[A>>2]|0;if(!t){D=A;break}else o=A}if((D|0)!=(c|0)?(f[D+16>>2]|0)<=(d|0):0)E=D+20|0;else z=34}else z=34;if((z|0)==34)E=B;B=(Jh(E,h)|0)!=0;if((b[h+11>>0]|0)<0)Oq(f[h>>2]|0);C=B}if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);if(!C){Wd(a+40|0,l,y)|0;k=1;u=e;return k|0}C=l+24|0;l=b[C>>0]|0;B=l<<24>>24;f[i>>2]=0;E=i+4|0;f[E>>2]=0;f[i+8>>2]=0;do if(l<<24>>24)if(l<<24>>24<0)aq(i);else{D=B<<2;c=ln(D)|0;f[i>>2]=c;o=c+(B<<2)|0;f[i+8>>2]=o;sj(c|0,0,D|0)|0;f[E>>2]=o;F=c;break}else F=0;while(0);B=f[m>>2]|0;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;l=ln(32)|0;f[j>>2]=l;f[j+8>>2]=-2147483616;f[j+4>>2]=19;p=l;q=14438;r=p+19|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[l+19>>0]=0;l=b[C>>0]|0;c=l<<24>>24;o=B+16|0;D=f[o>>2]|0;if(D){t=o;x=D;d:while(1){D=x;while(1){if((f[D+16>>2]|0)>=(d|0))break;v=f[D+4>>2]|0;if(!v){G=t;break d}else D=v}x=f[D>>2]|0;if(!x){G=D;break}else t=D}if(((G|0)!=(o|0)?(f[G+16>>2]|0)<=(d|0):0)?(o=G+20|0,(Jh(o,j)|0)!=0):0){t=Rg(o,j)|0;if((t|0)!=(G+24|0)){pj(g,t+28|0);t=g+11|0;G=b[t>>0]|0;o=G<<24>>24<0;if(!((o?f[g+4>>2]|0:G&255)|0))H=G;else{if(l<<24>>24>0){x=o?f[g>>2]|0:g;o=0;do{I=$(bq(x,h));A=x;x=f[h>>2]|0;if((A|0)==(x|0))break;n[F+(o<<2)>>2]=I;o=o+1|0}while((o|0)<(c|0));J=b[t>>0]|0}else J=G;H=J}if(H<<24>>24<0)Oq(f[g>>2]|0)}}else z=64}else z=64;if((z|0)==64?(H=Rg(B,j)|0,(H|0)!=(B+4|0)):0){pj(g,H+28|0);H=g+11|0;B=b[H>>0]|0;J=B<<24>>24<0;if(!((J?f[g+4>>2]|0:B&255)|0))K=B;else{if(l<<24>>24>0){l=J?f[g>>2]|0:g;J=0;do{I=$(bq(l,h));G=l;l=f[h>>2]|0;if((G|0)==(l|0))break;n[F+(J<<2)>>2]=I;J=J+1|0}while((J|0)<(c|0));L=b[H>>0]|0}else L=B;K=L}if(K<<24>>24<0)Oq(f[g>>2]|0)}if((b[j+11>>0]|0)<0)Oq(f[j>>2]|0);j=f[m>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;m=ln(32)|0;f[g>>2]=m;f[g+8>>2]=-2147483616;f[g+4>>2]=18;p=m;q=14458;r=p+18|0;do{b[p>>0]=b[q>>0]|0;p=p+1|0;q=q+1|0}while((p|0)<(r|0));b[m+18>>0]=0;m=j+16|0;q=f[m>>2]|0;if(q){p=m;r=q;e:while(1){q=r;while(1){if((f[q+16>>2]|0)>=(d|0))break;K=f[q+4>>2]|0;if(!K){M=p;break e}else q=K}r=f[q>>2]|0;if(!r){M=q;break}else p=q}if(((M|0)!=(m|0)?(f[M+16>>2]|0)<=(d|0):0)?(d=M+20|0,(Jh(d,g)|0)!=0):0)N=$(sk(d,g,$(1.0)));else z=86}else z=86;if((z|0)==86)N=$(sk(j,g,$(1.0)));if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);Dl(a+40|0,y,f[i>>2]|0,b[C>>0]|0,N);C=f[i>>2]|0;if(C|0){i=f[E>>2]|0;if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f[s>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(p=(N|0)==(ca|0),!(M&p)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(p&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);f[j>>2]=da;f[x>>2]=ea;N=K<<1;M=b+(N<<2)|0;H=f[y>>2]|0;if((H|0)>0){O=0;P=i;p=H;while(1){if((p|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;U=f[z>>2]|0;if((V|0)>(U|0)){fa=f[A>>2]|0;f[fa+(H<<2)>>2]=U;ga=fa}else{fa=f[B>>2]|0;U=f[A>>2]|0;f[U+(H<<2)>>2]=(V|0)<(fa|0)?fa:V;ga=U}H=H+1|0;U=f[y>>2]|0}while((H|0)<(U|0));ha=ga;ia=U}else{ha=f[A>>2]|0;ia=p}H=(f[M+(O<<2)>>2]|0)-(f[ha+(O<<2)>>2]|0)|0;U=k+(O<<2)|0;f[U>>2]=H;ja=f[C>>2]|0;if((H|0)>=(ja|0)){if((H|0)>(f[E>>2]|0)){ka=H-(f[D>>2]|0)|0;la=52}}else{ka=(f[D>>2]|0)+H|0;la=52}if((la|0)==52){la=0;f[U>>2]=ka}O=O+1|0;if((O|0)>=(ia|0))break;else{P=ha;p=ia}}if((ia|0)>0){p=0;P=j;O=ia;U=ja;while(1){if((O|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;fa=f[z>>2]|0;if((V|0)>(fa|0))f[ha+(H<<2)>>2]=fa;else{fa=f[B>>2]|0;f[ha+(H<<2)>>2]=(V|0)<(fa|0)?fa:V}H=H+1|0;ma=f[y>>2]|0}while((H|0)<(ma|0));na=f[C>>2]|0;oa=ma}else{na=U;oa=O}H=(f[M+(p<<2)>>2]|0)-(f[ha+(p<<2)>>2]|0)|0;V=l+(p<<2)|0;f[V>>2]=H;if((H|0)>=(na|0)){if((H|0)>(f[E>>2]|0)){pa=H-(f[D>>2]|0)|0;la=65}}else{pa=(f[D>>2]|0)+H|0;la=65}if((la|0)==65){la=0;f[V>>2]=pa}p=p+1|0;if((p|0)>=(oa|0))break;else{P=ha;O=oa;U=na}}}}U=f[k>>2]|0;O=f[t>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))qa=(f[F>>2]|0)+U|0;else qa=U;else qa=U-(f[F>>2]|0)|0;f[k>>2]=qa;U=f[a>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ra=(f[F>>2]|0)+U|0;else ra=U;else ra=U-(f[F>>2]|0)|0;f[a>>2]=ra;U=f[l>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))sa=(f[F>>2]|0)+U|0;else sa=U;else sa=U-(f[F>>2]|0)|0;f[l>>2]=sa;U=f[G>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ta=(f[F>>2]|0)+U|0;else ta=U;else ta=U-(f[F>>2]|0)|0;f[G>>2]=ta;if((((ra|0)>-1?ra:0-ra|0)+((qa|0)>-1?qa:0-qa|0)|0)<(((sa|0)>-1?sa:0-sa|0)+((ta|0)>-1?ta:0-ta|0)|0)){fj(g,0);ua=k}else{fj(g,1);ua=l}U=f[ua>>2]|0;if((U|0)<0)va=(f[F>>2]|0)+U|0;else va=U;U=c+(N<<2)|0;f[U>>2]=va;O=f[ua+4>>2]|0;if((O|0)<0)wa=(f[F>>2]|0)+O|0;else wa=O;f[U+4>>2]=wa;K=K+1|0;if((K|0)>=(r|0)){la=3;break}U=f[o>>2]|0;L=f[U>>2]|0;if((f[U+4>>2]|0)-L>>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>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(p=(N|0)==(ca|0),!(M&p)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(p&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);f[j>>2]=da;f[x>>2]=ea;N=K<<1;M=b+(N<<2)|0;H=f[y>>2]|0;if((H|0)>0){O=0;P=i;p=H;while(1){if((p|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;U=f[z>>2]|0;if((V|0)>(U|0)){fa=f[A>>2]|0;f[fa+(H<<2)>>2]=U;ga=fa}else{fa=f[B>>2]|0;U=f[A>>2]|0;f[U+(H<<2)>>2]=(V|0)<(fa|0)?fa:V;ga=U}H=H+1|0;U=f[y>>2]|0}while((H|0)<(U|0));ha=ga;ia=U}else{ha=f[A>>2]|0;ia=p}H=(f[M+(O<<2)>>2]|0)-(f[ha+(O<<2)>>2]|0)|0;U=k+(O<<2)|0;f[U>>2]=H;ja=f[C>>2]|0;if((H|0)>=(ja|0)){if((H|0)>(f[E>>2]|0)){ka=H-(f[D>>2]|0)|0;la=52}}else{ka=(f[D>>2]|0)+H|0;la=52}if((la|0)==52){la=0;f[U>>2]=ka}O=O+1|0;if((O|0)>=(ia|0))break;else{P=ha;p=ia}}if((ia|0)>0){p=0;P=j;O=ia;U=ja;while(1){if((O|0)>0){H=0;do{V=f[P+(H<<2)>>2]|0;fa=f[z>>2]|0;if((V|0)>(fa|0))f[ha+(H<<2)>>2]=fa;else{fa=f[B>>2]|0;f[ha+(H<<2)>>2]=(V|0)<(fa|0)?fa:V}H=H+1|0;ma=f[y>>2]|0}while((H|0)<(ma|0));na=f[C>>2]|0;oa=ma}else{na=U;oa=O}H=(f[M+(p<<2)>>2]|0)-(f[ha+(p<<2)>>2]|0)|0;V=l+(p<<2)|0;f[V>>2]=H;if((H|0)>=(na|0)){if((H|0)>(f[E>>2]|0)){pa=H-(f[D>>2]|0)|0;la=65}}else{pa=(f[D>>2]|0)+H|0;la=65}if((la|0)==65){la=0;f[V>>2]=pa}p=p+1|0;if((p|0)>=(oa|0))break;else{P=ha;O=oa;U=na}}}}U=f[k>>2]|0;O=f[t>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))qa=(f[F>>2]|0)+U|0;else qa=U;else qa=U-(f[F>>2]|0)|0;f[k>>2]=qa;U=f[a>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ra=(f[F>>2]|0)+U|0;else ra=U;else ra=U-(f[F>>2]|0)|0;f[a>>2]=ra;U=f[l>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))sa=(f[F>>2]|0)+U|0;else sa=U;else sa=U-(f[F>>2]|0)|0;f[l>>2]=sa;U=f[G>>2]|0;if((O|0)>=(U|0))if((U|0)<(0-O|0))ta=(f[F>>2]|0)+U|0;else ta=U;else ta=U-(f[F>>2]|0)|0;f[G>>2]=ta;if((((ra|0)>-1?ra:0-ra|0)+((qa|0)>-1?qa:0-qa|0)|0)<(((sa|0)>-1?sa:0-sa|0)+((ta|0)>-1?ta:0-ta|0)|0)){fj(g,0);ua=k}else{fj(g,1);ua=l}U=f[ua>>2]|0;if((U|0)<0)va=(f[F>>2]|0)+U|0;else va=U;U=c+(N<<2)|0;f[U>>2]=va;O=f[ua+4>>2]|0;if((O|0)<0)wa=(f[F>>2]|0)+O|0;else wa=O;f[U+4>>2]=wa;K=K+1|0;if((K|0)>=(r|0)){la=3;break}U=f[o>>2]|0;L=f[U>>2]|0;if((f[U+4>>2]|0)-L>>2>>>0<=K>>>0){J=U;la=4;break}}if((la|0)==3){u=e;return 1}else if((la|0)==4)aq(J);return 0}function Ub(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=Oa,V=Oa,Y=Oa,Z=0,_=0,aa=0,ba=0;d=u;u=u+16|0;e=d;g=a+16|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[g>>2]=$(1.0);i=a+20|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[a+36>>2]=$(1.0);j=f[c+8>>2]|0;a:do if(j|0){k=a+4|0;l=a+12|0;m=a+8|0;o=j;p=j;while(1){q=o+8|0;r=b[q+11>>0]|0;s=r<<24>>24<0;t=s?f[q>>2]|0:q;v=s?f[o+12>>2]|0:r&255;if(v>>>0>3){r=t;s=v;w=v;while(1){x=X(h[r>>0]|h[r+1>>0]<<8|h[r+2>>0]<<16|h[r+3>>0]<<24,1540483477)|0;s=(X(x>>>24^x,1540483477)|0)^(X(s,1540483477)|0);w=w+-4|0;if(w>>>0<=3)break;else r=r+4|0}r=v+-4|0;w=r&-4;y=r-w|0;z=t+(w+4)|0;A=s}else{y=v;z=t;A=v}switch(y|0){case 3:{B=h[z+2>>0]<<16^A;C=8;break}case 2:{B=A;C=8;break}case 1:{D=A;C=9;break}default:E=A}if((C|0)==8){C=0;D=h[z+1>>0]<<8^B;C=9}if((C|0)==9){C=0;E=X(D^h[z>>0],1540483477)|0}w=X(E>>>13^E,1540483477)|0;r=w>>>15^w;w=f[k>>2]|0;x=(w|0)==0;b:do if(!x){F=w+-1|0;G=(F&w|0)==0;if(!G)if(r>>>0>>0)H=r;else H=(r>>>0)%(w>>>0)|0;else H=r&F;I=f[(f[a>>2]|0)+(H<<2)>>2]|0;if((I|0)!=0?(J=f[I>>2]|0,(J|0)!=0):0){I=(v|0)==0;if(G){if(I){G=J;while(1){K=f[G+4>>2]|0;if(!((K|0)==(r|0)|(K&F|0)==(H|0))){L=H;C=50;break b}K=b[G+8+11>>0]|0;if(!((K<<24>>24<0?f[G+12>>2]|0:K&255)|0))break b;G=f[G>>2]|0;if(!G){L=H;C=50;break b}}}else M=J;while(1){G=f[M+4>>2]|0;if(!((G|0)==(r|0)|(G&F|0)==(H|0))){L=H;C=50;break b}G=M+8|0;K=b[G+11>>0]|0;N=K<<24>>24<0;O=K&255;do if(((N?f[M+12>>2]|0:O)|0)==(v|0)){K=f[G>>2]|0;if(N)if(!(Vk(K,t,v)|0))break b;else break;if((b[t>>0]|0)==(K&255)<<24>>24){K=G;P=O;Q=t;do{P=P+-1|0;K=K+1|0;if(!P)break b;Q=Q+1|0}while((b[K>>0]|0)==(b[Q>>0]|0))}}while(0);M=f[M>>2]|0;if(!M){L=H;C=50;break b}}}if(I){F=J;while(1){O=f[F+4>>2]|0;if((O|0)!=(r|0)){if(O>>>0>>0)R=O;else R=(O>>>0)%(w>>>0)|0;if((R|0)!=(H|0)){L=H;C=50;break b}}O=b[F+8+11>>0]|0;if(!((O<<24>>24<0?f[F+12>>2]|0:O&255)|0))break b;F=f[F>>2]|0;if(!F){L=H;C=50;break b}}}else S=J;while(1){F=f[S+4>>2]|0;if((F|0)!=(r|0)){if(F>>>0>>0)T=F;else T=(F>>>0)%(w>>>0)|0;if((T|0)!=(H|0)){L=H;C=50;break b}}F=S+8|0;I=b[F+11>>0]|0;O=I<<24>>24<0;G=I&255;do if(((O?f[S+12>>2]|0:G)|0)==(v|0)){I=f[F>>2]|0;if(O)if(!(Vk(I,t,v)|0))break b;else break;if((b[t>>0]|0)==(I&255)<<24>>24){I=F;N=G;Q=t;do{N=N+-1|0;I=I+1|0;if(!N)break b;Q=Q+1|0}while((b[I>>0]|0)==(b[Q>>0]|0))}}while(0);S=f[S>>2]|0;if(!S){L=H;C=50;break}}}else{L=H;C=50}}else{L=0;C=50}while(0);if((C|0)==50){C=0;Di(e,a,r,q);U=$(((f[l>>2]|0)+1|0)>>>0);V=$(w>>>0);Y=$(n[g>>2]);do if(x|$(Y*V)>>0<3|(w+-1&w|0)!=0)&1;v=~~$(W($(U/Y)))>>>0;ei(a,t>>>0>>0?v:t);t=f[k>>2]|0;v=t+-1|0;if(!(v&t)){Z=t;_=v&r;break}if(r>>>0>>0){Z=t;_=r}else{Z=t;_=(r>>>0)%(t>>>0)|0}}else{Z=w;_=L}while(0);w=f[(f[a>>2]|0)+(_<<2)>>2]|0;if(!w){f[f[e>>2]>>2]=f[m>>2];f[m>>2]=f[e>>2];f[(f[a>>2]|0)+(_<<2)>>2]=m;r=f[e>>2]|0;x=f[r>>2]|0;if(x|0){q=f[x+4>>2]|0;x=Z+-1|0;if(x&Z)if(q>>>0>>0)aa=q;else aa=(q>>>0)%(Z>>>0)|0;else aa=q&x;f[(f[a>>2]|0)+(aa<<2)>>2]=r}}else{f[f[e>>2]>>2]=f[w>>2];f[w>>2]=f[e>>2]}f[l>>2]=(f[l>>2]|0)+1}w=f[p>>2]|0;if(!w)break a;else{o=w;p=w}}}while(0);e=f[c+28>>2]|0;if(!e){u=d;return}else ba=e;do{e=ba;c=ln(40)|0;Ub(c,f[e+20>>2]|0);aa=Ec(i,e+8|0)|0;e=f[aa>>2]|0;f[aa>>2]=c;if(e|0){c=f[e+28>>2]|0;if(c|0){aa=c;do{c=aa;aa=f[aa>>2]|0;ri(c+8|0);Oq(c)}while((aa|0)!=0)}aa=e+20|0;c=f[aa>>2]|0;f[aa>>2]=0;if(c|0)Oq(c);c=f[e+8>>2]|0;if(c|0){aa=c;do{c=aa;aa=f[aa>>2]|0;a=c+8|0;Z=f[c+20>>2]|0;if(Z|0){_=c+24|0;if((f[_>>2]|0)!=(Z|0))f[_>>2]=Z;Oq(Z)}if((b[a+11>>0]|0)<0)O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;else M=(J>>>0)%(D>>>0)|0;else M=J&K;N=f[(f[i>>2]|0)+(M<<2)>>2]|0;do if(N|0?(O=f[N>>2]|0,O|0):0){b:do if(L){P=O;while(1){Q=f[P+4>>2]|0;R=(Q|0)==(J|0);if(!(R|(Q&K|0)==(M|0))){S=27;break b}if((R?(R=P+8|0,(d[R>>1]|0)==G<<16>>16):0)?(d[R+2>>1]|0)==H<<16>>16:0){T=P;S=26;break b}P=f[P>>2]|0;if(!P){S=27;break}}}else{P=O;while(1){R=f[P+4>>2]|0;if((R|0)==(J|0)){Q=P+8|0;if((d[Q>>1]|0)==G<<16>>16?(d[Q+2>>1]|0)==H<<16>>16:0){T=P;S=26;break b}}else{if(R>>>0>>0)U=R;else U=(R>>>0)%(D>>>0)|0;if((U|0)!=(M|0)){S=27;break b}}P=f[P>>2]|0;if(!P){S=27;break}}}while(0);if((S|0)==26){S=0;f[E+(z<<2)>>2]=f[T+12>>2];V=e;X=A;Y=C;Z=B;_=E;break a}else if((S|0)==27){S=0;if(F){aa=0;S=46;break a}else break}}while(0);K=D+-1|0;L=(K&D|0)==0;if(!L)if(J>>>0>>0)ba=J;else ba=(J>>>0)%(D>>>0)|0;else ba=K&J;N=f[(f[i>>2]|0)+(ba<<2)>>2]|0;if((N|0)!=0?(O=f[N>>2]|0,(O|0)!=0):0){if(L){L=O;while(1){N=f[L+4>>2]|0;if(!((N|0)==(J|0)|(N&K|0)==(ba|0))){aa=ba;S=46;break a}N=L+8|0;if((d[N>>1]|0)==G<<16>>16?(d[N+2>>1]|0)==H<<16>>16:0){S=61;break a}L=f[L>>2]|0;if(!L){aa=ba;S=46;break a}}}else ca=O;while(1){L=f[ca+4>>2]|0;if((L|0)!=(J|0)){if(L>>>0>>0)da=L;else da=(L>>>0)%(D>>>0)|0;if((da|0)!=(ba|0)){aa=ba;S=46;break a}}L=ca+8|0;if((d[L>>1]|0)==G<<16>>16?(d[L+2>>1]|0)==H<<16>>16:0){S=61;break a}ca=f[ca>>2]|0;if(!ca){aa=ba;S=46;break}}}else{aa=ba;S=46}}else{aa=0;S=46}while(0);if((S|0)==46){S=0;H=ln(16)|0;G=H+8|0;d[G>>1]=r;d[G+2>>1]=r>>>16;f[H+12>>2]=A;f[H+4>>2]=J;f[H>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(D>>>0);ga=$(n[l>>2]);do if(F|$(ga*fa)>>0<3|(D+-1&D|0)!=0)&1;O=~~$(W($(ea/ga)))>>>0;Uh(i,G>>>0>>0?O:G);G=f[o>>2]|0;O=G+-1|0;if(!(O&G)){ha=G;ia=O&J;break}if(J>>>0>>0){ha=G;ia=J}else{ha=G;ia=(J>>>0)%(G>>>0)|0}}else{ha=D;ia=aa}while(0);J=(f[i>>2]|0)+(ia<<2)|0;F=f[J>>2]|0;if(!F){f[H>>2]=f[v>>2];f[v>>2]=H;f[J>>2]=v;J=f[H>>2]|0;if(J|0){r=f[J+4>>2]|0;J=ha+-1|0;if(J&ha)if(r>>>0>>0)ja=r;else ja=(r>>>0)%(ha>>>0)|0;else ja=r&J;ka=(f[i>>2]|0)+(ja<<2)|0;S=59}}else{f[H>>2]=f[F>>2];ka=F;S=59}if((S|0)==59){S=0;f[ka>>2]=H}f[t>>2]=(f[t>>2]|0)+1;S=61}if((S|0)==61){S=0;F=w;J=f[F>>2]|0;r=un(J|0,f[F+4>>2]|0,A|0,0)|0;kh((f[f[x>>2]>>2]|0)+r|0,j|0,J|0)|0;J=f[k>>2]|0;f[J+(z<<2)>>2]=A;V=J;X=A+1|0;Y=J;Z=J;_=J}J=z+1|0;la=f[m>>2]|0;if(J>>>0>=la>>>0)break;e=V;z=J;A=X;B=Z;C=Y;D=f[o>>2]|0;E=_}if((X|0)==(la|0))ma=Z;else{Z=a+84|0;if(!(b[Z>>0]|0)){_=f[a+72>>2]|0;E=f[a+68>>2]|0;o=E;if((_|0)==(E|0))na=V;else{D=_-E>>2;E=0;do{_=o+(E<<2)|0;f[_>>2]=f[Y+(f[_>>2]<<2)>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q=ln(p)|0;f[j>>2]=q;r=q+(m<<2)|0;f[j+8>>2]=r;sj(q|0,0,p|0)|0;f[o>>2]=r;r=c+48|0;p=c+40|0;m=g+4|0;s=g+12|0;t=g+8|0;v=a+40|0;w=a+64|0;x=f[d>>2]|0;d=q;y=0;z=0;A=q;B=q;C=q;q=0;while(1){D=r;E=f[D>>2]|0;F=f[D+4>>2]|0;D=p;G=un(f[D>>2]|0,f[D+4>>2]|0,x+y|0,0)|0;D=Vn(G|0,I|0,E|0,F|0)|0;F=(f[f[c>>2]>>2]|0)+D|0;D=F;E=h[D>>0]|h[D+1>>0]<<8|h[D+2>>0]<<16|h[D+3>>0]<<24;D=F+4|0;F=h[D>>0]|h[D+1>>0]<<8|h[D+2>>0]<<16|h[D+3>>0]<<24;D=i;f[D>>2]=E;f[D+4>>2]=F;D=(E^318)+239^F;G=(q|0)==0;a:do if(!G){H=q+-1|0;J=(H&q|0)==0;if(!J)if(D>>>0>>0)K=D;else K=(D>>>0)%(q>>>0)|0;else K=D&H;L=f[(f[g>>2]|0)+(K<<2)>>2]|0;do if(L|0?(M=f[L>>2]|0,M|0):0){b:do if(J){N=M;while(1){O=f[N+4>>2]|0;P=(O|0)==(D|0);if(!(P|(O&H|0)==(K|0))){Q=27;break b}if((P?(f[N+8>>2]|0)==(E|0):0)?(f[N+12>>2]|0)==(F|0):0){R=N;Q=26;break b}N=f[N>>2]|0;if(!N){Q=27;break}}}else{N=M;while(1){P=f[N+4>>2]|0;if((P|0)==(D|0)){if((f[N+8>>2]|0)==(E|0)?(f[N+12>>2]|0)==(F|0):0){R=N;Q=26;break b}}else{if(P>>>0>>0)S=P;else S=(P>>>0)%(q>>>0)|0;if((S|0)!=(K|0)){Q=27;break b}}N=f[N>>2]|0;if(!N){Q=27;break}}}while(0);if((Q|0)==26){Q=0;f[A+(y<<2)>>2]=f[R+16>>2];T=d;U=z;V=C;X=B;Y=A;break a}else if((Q|0)==27){Q=0;if(G){Z=0;Q=46;break a}else break}}while(0);H=q+-1|0;J=(H&q|0)==0;if(!J)if(D>>>0>>0)_=D;else _=(D>>>0)%(q>>>0)|0;else _=H&D;L=f[(f[g>>2]|0)+(_<<2)>>2]|0;if((L|0)!=0?(M=f[L>>2]|0,(M|0)!=0):0){if(J){J=M;while(1){L=f[J+4>>2]|0;if(!((L|0)==(D|0)|(L&H|0)==(_|0))){Z=_;Q=46;break a}if((f[J+8>>2]|0)==(E|0)?(f[J+12>>2]|0)==(F|0):0){Q=61;break a}J=f[J>>2]|0;if(!J){Z=_;Q=46;break a}}}else aa=M;while(1){J=f[aa+4>>2]|0;if((J|0)!=(D|0)){if(J>>>0>>0)ba=J;else ba=(J>>>0)%(q>>>0)|0;if((ba|0)!=(_|0)){Z=_;Q=46;break a}}if((f[aa+8>>2]|0)==(E|0)?(f[aa+12>>2]|0)==(F|0):0){Q=61;break a}aa=f[aa>>2]|0;if(!aa){Z=_;Q=46;break}}}else{Z=_;Q=46}}else{Z=0;Q=46}while(0);if((Q|0)==46){Q=0;M=ln(20)|0;J=M+8|0;f[J>>2]=E;f[J+4>>2]=F;f[M+16>>2]=z;f[M+4>>2]=D;f[M>>2]=0;ca=$(((f[s>>2]|0)+1|0)>>>0);da=$(q>>>0);ea=$(n[k>>2]);do if(G|$(ea*da)>>0<3|(q+-1&q|0)!=0)&1;H=~~$(W($(ca/ea)))>>>0;Yh(g,J>>>0>>0?H:J);J=f[m>>2]|0;H=J+-1|0;if(!(H&J)){fa=J;ga=H&D;break}if(D>>>0>>0){fa=J;ga=D}else{fa=J;ga=(D>>>0)%(J>>>0)|0}}else{fa=q;ga=Z}while(0);D=(f[g>>2]|0)+(ga<<2)|0;G=f[D>>2]|0;if(!G){f[M>>2]=f[t>>2];f[t>>2]=M;f[D>>2]=t;D=f[M>>2]|0;if(D|0){F=f[D+4>>2]|0;D=fa+-1|0;if(D&fa)if(F>>>0>>0)ha=F;else ha=(F>>>0)%(fa>>>0)|0;else ha=F&D;ia=(f[g>>2]|0)+(ha<<2)|0;Q=59}}else{f[M>>2]=f[G>>2];ia=G;Q=59}if((Q|0)==59){Q=0;f[ia>>2]=M}f[s>>2]=(f[s>>2]|0)+1;Q=61}if((Q|0)==61){Q=0;G=v;D=f[G>>2]|0;F=un(D|0,f[G+4>>2]|0,z|0,0)|0;kh((f[f[w>>2]>>2]|0)+F|0,i|0,D|0)|0;D=f[j>>2]|0;f[D+(y<<2)>>2]=z;T=D;U=z+1|0;V=D;X=D;Y=D}D=y+1|0;ja=f[l>>2]|0;if(D>>>0>=ja>>>0)break;d=T;y=D;z=U;A=Y;B=X;C=V;q=f[m>>2]|0}if((U|0)==(ja|0))ka=X;else{X=a+84|0;if(!(b[X>>0]|0)){m=f[a+72>>2]|0;q=f[a+68>>2]|0;C=q;if((m|0)==(q|0))la=T;else{B=m-q>>2;q=0;do{m=C+(q<<2)|0;f[m>>2]=f[V+(f[m>>2]<<2)>>2];q=q+1|0}while(q>>>0>>0);la=T}}else{b[X>>0]=0;X=a+68|0;T=a+72|0;B=f[T>>2]|0;q=f[X>>2]|0;V=B-q>>2;C=q;q=B;if(ja>>>0<=V>>>0)if(ja>>>0>>0?(B=C+(ja<<2)|0,(B|0)!=(q|0)):0){f[T>>2]=q+(~((q+-4-B|0)>>>2)<<2);ma=ja}else ma=ja;else{Ch(X,ja-V|0,1220);ma=f[l>>2]|0}V=f[j>>2]|0;if(!ma)la=V;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[V+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);la=V}}f[l>>2]=U;ka=la}if(!ka)na=U;else{la=f[o>>2]|0;if((la|0)!=(ka|0))f[o>>2]=la+(~((la+-4-ka|0)>>>2)<<2);Oq(ka);na=U}}else na=0;U=f[g+8>>2]|0;if(U|0){ka=U;do{U=ka;ka=f[ka>>2]|0;Oq(U)}while((ka|0)!=0)}ka=f[g>>2]|0;f[g>>2]=0;if(!ka){u=e;return na|0}Oq(ka);u=e;return na|0}function Xb(a,c,e){a=a|0;c=c|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K|0)==(M|0))){S=27;break b}if((R?(R=P+8|0,(b[R>>0]|0)==G<<24>>24):0)?(b[R+1>>0]|0)==H<<24>>24:0){T=P;S=26;break b}P=f[P>>2]|0;if(!P){S=27;break}}}else{P=O;while(1){R=f[P+4>>2]|0;if((R|0)==(J|0)){Q=P+8|0;if((b[Q>>0]|0)==G<<24>>24?(b[Q+1>>0]|0)==H<<24>>24:0){T=P;S=26;break b}}else{if(R>>>0>>0)U=R;else U=(R>>>0)%(D>>>0)|0;if((U|0)!=(M|0)){S=27;break b}}P=f[P>>2]|0;if(!P){S=27;break}}}while(0);if((S|0)==26){S=0;f[E+(z<<2)>>2]=f[T+12>>2];V=e;X=A;Y=C;Z=B;_=E;break a}else if((S|0)==27){S=0;if(F){aa=0;S=46;break a}else break}}while(0);K=D+-1|0;L=(K&D|0)==0;if(!L)if(D>>>0>J>>>0)ba=J;else ba=(J>>>0)%(D>>>0)|0;else ba=K&J;N=f[(f[i>>2]|0)+(ba<<2)>>2]|0;if((N|0)!=0?(O=f[N>>2]|0,(O|0)!=0):0){if(L){L=O;while(1){N=f[L+4>>2]|0;if(!((N|0)==(J|0)|(N&K|0)==(ba|0))){aa=ba;S=46;break a}N=L+8|0;if((b[N>>0]|0)==G<<24>>24?(b[N+1>>0]|0)==H<<24>>24:0){S=61;break a}L=f[L>>2]|0;if(!L){aa=ba;S=46;break a}}}else ca=O;while(1){L=f[ca+4>>2]|0;if((L|0)!=(J|0)){if(L>>>0>>0)da=L;else da=(L>>>0)%(D>>>0)|0;if((da|0)!=(ba|0)){aa=ba;S=46;break a}}L=ca+8|0;if((b[L>>0]|0)==G<<24>>24?(b[L+1>>0]|0)==H<<24>>24:0){S=61;break a}ca=f[ca>>2]|0;if(!ca){aa=ba;S=46;break}}}else{aa=ba;S=46}}else{aa=0;S=46}while(0);if((S|0)==46){S=0;H=ln(16)|0;G=H+8|0;b[G>>0]=r;b[G+1>>0]=r>>8;f[H+12>>2]=A;f[H+4>>2]=J;f[H>>2]=0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<<2)|0,(D|0)!=(E|0)):0){f[V>>2]=E+(~((E+-4-D|0)>>>2)<<2);oa=la}else oa=la;else{Ch(Z,la-Y|0,1220);oa=f[m>>2]|0}Y=f[k>>2]|0;if(!oa)na=Y;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[Y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);na=Y}}f[m>>2]=X;ma=na}if(!ma)pa=X;else{na=f[p>>2]|0;if((na|0)!=(ma|0))f[p>>2]=na+(~((na+-4-ma|0)>>>2)<<2);Oq(ma);pa=X}}else pa=0;X=f[i+8>>2]|0;if(X|0){ma=X;do{X=ma;ma=f[ma>>2]|0;Oq(X)}while((ma|0)!=0)}ma=f[i>>2]|0;f[i>>2]=0;if(!ma){u=g;return pa|0}Oq(ma);u=g;return pa|0}function Yb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0;c=u;u=u+16|0;d=c+8|0;e=c;g=c+4|0;h=a+16|0;i=f[h>>2]|0;j=a+20|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k+(~((k+-4-i|0)>>>2)<<2)|0;f[j>>2]=m;l=m}m=a+24|0;if((l|0)==(f[m>>2]|0)){Ri(h,b);n=f[h>>2]|0;o=f[j>>2]|0}else{f[l>>2]=f[b>>2];k=l+4|0;f[j>>2]=k;n=i;o=k}k=f[a+8>>2]|0;i=(f[k+100>>2]|0)-(f[k+96>>2]|0)|0;k=(i|0)/12|0;if((n|0)==(o|0)){u=c;return 1}n=a+28|0;l=(i|0)>0;i=a+164|0;p=a+12|0;q=a+76|0;r=a+80|0;s=a+72|0;t=a+200|0;v=a+320|0;w=a+152|0;x=a+84|0;y=a+324|0;z=a+292|0;A=a+304|0;B=a+316|0;C=a+328|0;D=a+336|0;E=a+332|0;F=a+168|0;G=a+140|0;H=a+120|0;I=o;do{o=f[I+-4>>2]|0;f[b>>2]=o;a:do if((o|0)!=-1?(J=(o>>>0)/3|0,K=f[n>>2]|0,(f[K+(J>>>5<<2)>>2]&1<<(J&31)|0)==0):0){if(l){J=0;L=K;b:while(1){K=J+1|0;f[i>>2]=(f[i>>2]|0)+1;M=f[b>>2]|0;N=(M|0)==-1?-1:(M>>>0)/3|0;M=L+(N>>>5<<2)|0;f[M>>2]=1<<(N&31)|f[M>>2];M=f[q>>2]|0;if((M|0)==(f[r>>2]|0))Ri(s,b);else{f[M>>2]=f[b>>2];f[q>>2]=M+4}f[v>>2]=f[b>>2];M=f[b>>2]|0;if((M|0)==-1)O=-1;else O=f[(f[f[p>>2]>>2]|0)+(M<<2)>>2]|0;P=(f[(f[w>>2]|0)+(O<<2)>>2]|0)!=-1;Q=(f[x>>2]|0)+(O>>>5<<2)|0;R=1<<(O&31);S=f[Q>>2]|0;do if(!(S&R)){f[Q>>2]=S|R;if(P){T=f[b>>2]|0;U=38;break}f[y>>2]=(f[y>>2]|0)+1;V=f[v>>2]|0;W=V+1|0;do if((V|0)!=-1){X=((W>>>0)%3|0|0)==0?V+-2|0:W;if(!((V>>>0)%3|0)){Y=V+2|0;Z=X;break}else{Y=V+-1|0;Z=X;break}}else{Y=-1;Z=-1}while(0);V=f[z>>2]|0;W=f[A>>2]|0;X=W+(f[V+(Z<<2)>>2]<<2)|0;_=f[X>>2]|0;f[X>>2]=_+-1;X=W+(f[V+(Y<<2)>>2]<<2)|0;f[X>>2]=(f[X>>2]|0)+-1;X=f[B>>2]|0;if((X|0)!=-1){V=f[C>>2]|0;if((_|0)<(V|0))$=V;else{W=f[E>>2]|0;$=(_|0)>(W|0)?W:_}_=$-V|0;V=f[D>>2]|0;W=f[3724+(X<<2)>>2]|0;f[d>>2]=W;X=V+(_*12|0)+4|0;aa=f[X>>2]|0;if(aa>>>0<(f[V+(_*12|0)+8>>2]|0)>>>0){f[aa>>2]=W;f[X>>2]=aa+4}else Ri(V+(_*12|0)|0,d)}f[B>>2]=0;_=f[b>>2]|0;V=_+1|0;if((_|0)!=-1?(aa=((V>>>0)%3|0|0)==0?_+-2|0:V,(aa|0)!=-1):0)ba=f[(f[(f[p>>2]|0)+12>>2]|0)+(aa<<2)>>2]|0;else ba=-1;f[b>>2]=ba}else{T=M;U=38}while(0);if((U|0)==38){U=0;M=T+1|0;if((T|0)==-1){U=43;break}R=((M>>>0)%3|0|0)==0?T+-2|0:M;if((R|0)==-1)ca=-1;else ca=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;f[e>>2]=ca;R=(((T>>>0)%3|0|0)==0?2:-1)+T|0;if((R|0)==-1)da=-1;else da=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;R=(ca|0)==-1;S=R?-1:(ca>>>0)/3|0;ea=(da|0)==-1;fa=ea?-1:(da>>>0)/3|0;Q=((M>>>0)%3|0|0)==0?T+-2|0:M;if(((Q|0)!=-1?(M=f[(f[p>>2]|0)+12>>2]|0,aa=f[M+(Q<<2)>>2]|0,(aa|0)!=-1):0)?(Q=(aa>>>0)/3|0,aa=f[n>>2]|0,(f[aa+(Q>>>5<<2)>>2]&1<<(Q&31)|0)==0):0){Q=(((T>>>0)%3|0|0)==0?2:-1)+T|0;do if((Q|0)!=-1){V=f[M+(Q<<2)>>2]|0;if((V|0)==-1)break;_=(V>>>0)/3|0;if(!(f[aa+(_>>>5<<2)>>2]&1<<(_&31))){U=62;break b}}while(0);if(!ea)xf(a,f[i>>2]|0,N,0,fa);nd(t,3);ga=f[e>>2]|0}else{if(!R){xf(a,f[i>>2]|0,N,1,S);aa=f[b>>2]|0;if((aa|0)==-1){U=52;break}else ha=aa}else ha=T;aa=(((ha>>>0)%3|0|0)==0?2:-1)+ha|0;if((aa|0)==-1){U=52;break}Q=f[(f[(f[p>>2]|0)+12>>2]|0)+(aa<<2)>>2]|0;if((Q|0)==-1){U=52;break}aa=(Q>>>0)/3|0;if(f[(f[n>>2]|0)+(aa>>>5<<2)>>2]&1<<(aa&31)|0){U=52;break}nd(t,5);ga=da}f[b>>2]=ga}if((K|0)>=(k|0))break a;J=K;L=f[n>>2]|0}do if((U|0)==43){U=0;f[e>>2]=-1;U=54}else if((U|0)==52){U=0;if(ea)U=54;else{xf(a,f[i>>2]|0,N,0,fa);U=54}}else if((U|0)==62){U=0;nd(t,1);f[F>>2]=(f[F>>2]|0)+1;if(P?(L=f[(f[w>>2]|0)+(O<<2)>>2]|0,(1<<(L&31)&f[(f[G>>2]|0)+(L>>>5<<2)>>2]|0)==0):0){f[g>>2]=f[b>>2];f[d>>2]=f[g>>2];Pe(a,d,0)|0}L=f[i>>2]|0;f[d>>2]=N;J=je(H,d)|0;f[J>>2]=L;L=f[j>>2]|0;f[L+-4>>2]=da;if((L|0)==(f[m>>2]|0)){Ri(h,e);break}else{f[L>>2]=f[e>>2];f[j>>2]=L+4;break}}while(0);if((U|0)==54){U=0;nd(t,7);f[j>>2]=(f[j>>2]|0)+-4}}}else U=11;while(0);if((U|0)==11){U=0;f[j>>2]=I+-4}I=f[j>>2]|0}while((f[h>>2]|0)!=(I|0));u=c;return 1}function Zb(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))Ri(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;do if((g|0)!=-1){l=f[m+28>>2]|0;o=f[l+((((j>>>0)%3|0|0)==0?g+-2|0:j)<<2)>>2]|0;if(!((g>>>0)%3|0)){p=o;q=g+2|0;r=l;break}else{p=o;q=g+-1|0;r=l;break}}else{l=f[m+28>>2]|0;p=f[l+-4>>2]|0;q=-1;r=l}while(0);m=f[r+(q<<2)>>2]|0;q=a+24|0;r=f[q>>2]|0;g=r+(p>>>5<<2)|0;j=1<<(p&31);l=f[g>>2]|0;if(!(l&j)){f[g>>2]=l|j;j=f[b>>2]|0;l=j+1|0;if((j|0)==-1)s=-1;else s=((l>>>0)%3|0|0)==0?j+-2|0:l;f[e>>2]=s;l=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((s>>>0)/3|0)*12|0)+(((s>>>0)%3|0)<<2)>>2]|0;s=f[a+48>>2]|0;f[d>>2]=l;j=f[s+4>>2]|0;s=j+4|0;g=f[s>>2]|0;if((g|0)==(f[j+8>>2]|0))Ri(j,d);else{f[g>>2]=l;f[s>>2]=g+4}g=a+40|0;s=f[g>>2]|0;l=s+4|0;j=f[l>>2]|0;if((j|0)==(f[s+8>>2]|0)){Ri(s,e);t=f[g>>2]|0}else{f[j>>2]=f[e>>2];f[l>>2]=j+4;t=s}s=t+24|0;f[(f[t+12>>2]|0)+(p<<2)>>2]=f[s>>2];f[s>>2]=(f[s>>2]|0)+1;v=f[q>>2]|0}else v=r;r=v+(m>>>5<<2)|0;v=1<<(m&31);s=f[r>>2]|0;if(!(s&v)){f[r>>2]=s|v;v=f[b>>2]|0;do if((v|0)!=-1)if(!((v>>>0)%3|0)){w=v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+4|0;B=f[o>>2]|0;if((B|0)==(f[g+8>>2]|0))Ri(g,d);else{f[B>>2]=y;f[o>>2]=B+4}B=f[v>>2]|0;o=B+4|0;y=f[o>>2]|0;if((y|0)==(f[B+8>>2]|0)){Ri(B,e);C=f[v>>2]|0}else{f[y>>2]=f[e>>2];f[o>>2]=y+4;C=B}B=C+24|0;f[(f[C+12>>2]|0)+(l<<2)>>2]=f[B>>2];f[B>>2]=(f[B>>2]|0)+1;B=f[a>>2]|0;l=f[b>>2]|0;if(A){D=l;E=B;F=57}else{y=l+1|0;do if((l|0)==-1)G=-1;else{o=((y>>>0)%3|0|0)==0?l+-2|0:y;if((o|0)==-1){G=-1;break}if(f[(f[B>>2]|0)+(o>>>5<<2)>>2]&1<<(o&31)|0){G=-1;break}G=f[(f[(f[B+64>>2]|0)+12>>2]|0)+(o<<2)>>2]|0}while(0);f[b>>2]=G;H=(G>>>0)/3|0;I=B}}else{D=j;E=w;F=57}if((F|0)==57){F=0;y=D+1|0;if((D|0)==-1){F=58;break}l=((y>>>0)%3|0|0)==0?D+-2|0:y;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)J=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else J=-1;f[d>>2]=J;l=(((D>>>0)%3|0|0)==0?2:-1)+D|0;if((l|0)!=-1?(f[(f[E>>2]|0)+(l>>>5<<2)>>2]&1<<(l&31)|0)==0:0)K=f[(f[(f[E+64>>2]|0)+12>>2]|0)+(l<<2)>>2]|0;else K=-1;l=(J|0)==-1;y=(J>>>0)/3|0;o=l?-1:y;g=(K|0)==-1;z=(K>>>0)/3|0;L=g?-1:z;do if(!l){M=f[i>>2]|0;if(f[M+(o>>>5<<2)>>2]&1<<(o&31)|0){F=67;break}if(g){N=J;O=y;break}if(!(f[M+(L>>>5<<2)>>2]&1<<(L&31))){F=72;break a}else{N=J;O=y}}else F=67;while(0);if((F|0)==67){F=0;if(g){F=69;break}if(!(f[(f[i>>2]|0)+(L>>>5<<2)>>2]&1<<(L&31))){N=K;O=z}else{F=69;break}}f[b>>2]=N;H=O;I=E}t=H;p=f[i>>2]|0;w=I}do if((F|0)==58){F=0;f[d>>2]=-1;F=69}else if((F|0)==72){F=0;w=f[k>>2]|0;f[w+-4>>2]=K;if((w|0)==(f[n>>2]|0)){Ri(h,d);P=f[k>>2]|0;break}else{f[w>>2]=f[d>>2];p=w+4|0;f[k>>2]=p;P=p;break}}while(0);if((F|0)==69){F=0;p=(f[k>>2]|0)+-4|0;f[k>>2]=p;P=p}Q=f[h>>2]|0;R=P}else{p=r+-4|0;f[k>>2]=p;Q=m;R=p}if((Q|0)==(R|0))break;else{r=R;m=Q}}u=c;return}function _b(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=Oa,K=Oa,L=Oa,M=0,N=0,O=0,P=0;e=u;u=u+64|0;g=e+40|0;i=e+16|0;j=e;k=Id(a,c)|0;if(k|0){f[i>>2]=k;f[g>>2]=f[i>>2];lf(a,g)|0}f[j>>2]=0;k=j+4|0;f[k>>2]=0;f[j+8>>2]=0;Fi(j,8);l=d;d=l;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=l+4|0;l=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;d=f[j>>2]|0;o=d;b[o>>0]=m;b[o+1>>0]=m>>8;b[o+2>>0]=m>>16;b[o+3>>0]=m>>24;m=d+4|0;b[m>>0]=l;b[m+1>>0]=l>>8;b[m+2>>0]=l>>16;b[m+3>>0]=l>>24;pj(i,c);c=i+12|0;f[c>>2]=0;l=i+16|0;f[l>>2]=0;f[i+20>>2]=0;m=f[k>>2]|0;d=f[j>>2]|0;o=m-d|0;if(!o){p=d;q=m;r=0}else{Fi(c,o);p=f[j>>2]|0;q=f[k>>2]|0;r=f[c>>2]|0}kh(r|0,p|0,q-p|0)|0;p=i+11|0;q=b[p>>0]|0;r=q<<24>>24<0;c=r?f[i>>2]|0:i;o=r?f[i+4>>2]|0:q&255;if(o>>>0>3){q=c;r=o;m=o;while(1){d=X(h[q>>0]|h[q+1>>0]<<8|h[q+2>>0]<<16|h[q+3>>0]<<24,1540483477)|0;r=(X(d>>>24^d,1540483477)|0)^(X(r,1540483477)|0);m=m+-4|0;if(m>>>0<=3)break;else q=q+4|0}q=o+-4|0;m=q&-4;s=q-m|0;t=c+(m+4)|0;v=r}else{s=o;t=c;v=o}switch(s|0){case 3:{w=h[t+2>>0]<<16^v;x=10;break}case 2:{w=v;x=10;break}case 1:{y=v;x=11;break}default:z=v}if((x|0)==10){y=h[t+1>>0]<<8^w;x=11}if((x|0)==11)z=X(y^h[t>>0],1540483477)|0;t=X(z>>>13^z,1540483477)|0;z=t>>>15^t;t=a+4|0;y=f[t>>2]|0;w=(y|0)==0;a:do if(!w){v=y+-1|0;s=(v&y|0)==0;if(!s)if(z>>>0>>0)A=z;else A=(z>>>0)%(y>>>0)|0;else A=z&v;r=f[(f[a>>2]|0)+(A<<2)>>2]|0;if((r|0)!=0?(m=f[r>>2]|0,(m|0)!=0):0){r=(o|0)==0;if(s){if(r){s=m;while(1){q=f[s+4>>2]|0;if(!((q|0)==(z|0)|(q&v|0)==(A|0))){B=A;x=52;break a}q=b[s+8+11>>0]|0;if(!((q<<24>>24<0?f[s+12>>2]|0:q&255)|0))break a;s=f[s>>2]|0;if(!s){B=A;x=52;break a}}}else C=m;while(1){s=f[C+4>>2]|0;if(!((s|0)==(z|0)|(s&v|0)==(A|0))){B=A;x=52;break a}s=C+8|0;q=b[s+11>>0]|0;d=q<<24>>24<0;D=q&255;do if(((d?f[C+12>>2]|0:D)|0)==(o|0)){q=f[s>>2]|0;if(d)if(!(Vk(q,c,o)|0))break a;else break;if((b[c>>0]|0)==(q&255)<<24>>24){q=s;E=D;F=c;do{E=E+-1|0;q=q+1|0;if(!E)break a;F=F+1|0}while((b[q>>0]|0)==(b[F>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){B=A;x=52;break a}}}if(r){v=m;while(1){D=f[v+4>>2]|0;if((D|0)!=(z|0)){if(D>>>0>>0)G=D;else G=(D>>>0)%(y>>>0)|0;if((G|0)!=(A|0)){B=A;x=52;break a}}D=b[v+8+11>>0]|0;if(!((D<<24>>24<0?f[v+12>>2]|0:D&255)|0))break a;v=f[v>>2]|0;if(!v){B=A;x=52;break a}}}else H=m;while(1){v=f[H+4>>2]|0;if((v|0)!=(z|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(y>>>0)|0;if((I|0)!=(A|0)){B=A;x=52;break a}}v=H+8|0;r=b[v+11>>0]|0;D=r<<24>>24<0;s=r&255;do if(((D?f[H+12>>2]|0:s)|0)==(o|0)){r=f[v>>2]|0;if(D)if(!(Vk(r,c,o)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=v;d=s;F=c;do{d=d+-1|0;r=r+1|0;if(!d)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){B=A;x=52;break}}}else{B=A;x=52}}else{B=0;x=52}while(0);if((x|0)==52){oi(g,a,z,i);x=a+12|0;J=$(((f[x>>2]|0)+1|0)>>>0);K=$(y>>>0);L=$(n[a+16>>2]);do if(w|$(L*K)>>0<3|(y+-1&y|0)!=0)&1;H=~~$(W($(J/L)))>>>0;ei(a,A>>>0>>0?H:A);A=f[t>>2]|0;H=A+-1|0;if(!(H&A)){M=A;N=H&z;break}if(z>>>0>>0){M=A;N=z}else{M=A;N=(z>>>0)%(A>>>0)|0}}else{M=y;N=B}while(0);B=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!B){y=a+8|0;f[f[g>>2]>>2]=f[y>>2];f[y>>2]=f[g>>2];f[(f[a>>2]|0)+(N<<2)>>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4|0;s=f[q>>2]|0;if(!(b[s+84>>0]|0))v=f[(f[s+68>>2]|0)+(t<<2)>>2]|0;else v=t;f[j>>2]=0;f[j+4>>2]=0;f[j+8>>2]=0;f[j+12>>2]=0;f[j+16>>2]=0;f[j+20>>2]=0;f[h>>2]=v;v=b[s+24>>0]|0;f[g>>2]=f[h>>2];vb(s,g,v,j)|0;v=a+28|0;a=(f[v>>2]|0)==0;a:do if(!p){s=k+8|0;t=j+8|0;w=k+16|0;x=j+16|0;y=l+8|0;z=l+16|0;A=o;B=o;C=0;D=0;E=0;F=0;G=0;H=0;J=a;K=o;while(1){do if(J){L=K+1|0;if((K|0)==-1){M=A;N=-1;O=-1;P=-1;break}Q=((L>>>0)%3|0|0)==0?K+-2|0:L;if((A|0)!=-1)if(!((A>>>0)%3|0)){R=A;S=A+2|0;T=Q;U=A;V=19;break}else{R=A;S=A+-1|0;T=Q;U=A;V=19;break}else{R=-1;S=-1;T=Q;U=-1;V=19}}else{Q=B+1|0;L=((Q>>>0)%3|0|0)==0?B+-2|0:Q;if(!((B>>>0)%3|0)){R=A;S=B+2|0;T=L;U=K;V=19;break}else{R=A;S=B+-1|0;T=L;U=K;V=19;break}}while(0);if((V|0)==19){V=0;if((T|0)==-1){M=R;N=-1;O=S;P=U}else{M=R;N=f[(f[f[m>>2]>>2]|0)+(T<<2)>>2]|0;O=S;P=U}}W=f[n>>2]|0;L=f[W>>2]|0;if((f[W+4>>2]|0)-L>>2>>>0<=N>>>0){V=22;break}Q=f[(f[r>>2]|0)+(f[L+(N<<2)>>2]<<2)>>2]|0;L=f[q>>2]|0;if(!(b[L+84>>0]|0))X=f[(f[L+68>>2]|0)+(Q<<2)>>2]|0;else X=Q;f[k>>2]=0;f[k+4>>2]=0;f[k+8>>2]=0;f[k+12>>2]=0;f[k+16>>2]=0;f[k+20>>2]=0;f[h>>2]=X;Q=b[L+24>>0]|0;f[g>>2]=f[h>>2];vb(L,g,Q,k)|0;if((O|0)==-1)Y=-1;else Y=f[(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[z+2>>0]<<16^A;C=12;break}case 2:{B=A;C=12;break}case 1:{D=A;C=13;break}default:E=A}if((C|0)==12){D=h[z+1>>0]<<8^B;C=13}if((C|0)==13)E=X(D^h[z>>0],1540483477)|0;z=X(E>>>13^E,1540483477)|0;E=z>>>15^z;z=a+4|0;D=f[z>>2]|0;B=(D|0)==0;a:do if(!B){A=D+-1|0;y=(A&D|0)==0;if(!y)if(E>>>0>>0)F=E;else F=(E>>>0)%(D>>>0)|0;else F=E&A;x=f[(f[a>>2]|0)+(F<<2)>>2]|0;if((x|0)!=0?(s=f[x>>2]|0,(s|0)!=0):0){x=(d|0)==0;if(y){if(x){y=s;while(1){w=f[y+4>>2]|0;if(!((w|0)==(E|0)|(w&A|0)==(F|0))){G=F;C=54;break a}w=b[y+8+11>>0]|0;if(!((w<<24>>24<0?f[y+12>>2]|0:w&255)|0))break a;y=f[y>>2]|0;if(!y){G=F;C=54;break a}}}else H=s;while(1){y=f[H+4>>2]|0;if(!((y|0)==(E|0)|(y&A|0)==(F|0))){G=F;C=54;break a}y=H+8|0;w=b[y+11>>0]|0;o=w<<24>>24<0;t=w&255;do if(((o?f[H+12>>2]|0:t)|0)==(d|0)){w=f[y>>2]|0;if(o)if(!(Vk(w,c,d)|0))break a;else break;if((b[c>>0]|0)==(w&255)<<24>>24){w=y;l=t;q=c;do{l=l+-1|0;w=w+1|0;if(!l)break a;q=q+1|0}while((b[w>>0]|0)==(b[q>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){G=F;C=54;break a}}}if(x){A=s;while(1){t=f[A+4>>2]|0;if((t|0)!=(E|0)){if(t>>>0>>0)I=t;else I=(t>>>0)%(D>>>0)|0;if((I|0)!=(F|0)){G=F;C=54;break a}}t=b[A+8+11>>0]|0;if(!((t<<24>>24<0?f[A+12>>2]|0:t&255)|0))break a;A=f[A>>2]|0;if(!A){G=F;C=54;break a}}}else J=s;while(1){A=f[J+4>>2]|0;if((A|0)!=(E|0)){if(A>>>0>>0)K=A;else K=(A>>>0)%(D>>>0)|0;if((K|0)!=(F|0)){G=F;C=54;break a}}A=J+8|0;x=b[A+11>>0]|0;t=x<<24>>24<0;y=x&255;do if(((t?f[J+12>>2]|0:y)|0)==(d|0)){x=f[A>>2]|0;if(t)if(!(Vk(x,c,d)|0))break a;else break;if((b[c>>0]|0)==(x&255)<<24>>24){x=A;o=y;q=c;do{o=o+-1|0;x=x+1|0;if(!o)break a;q=q+1|0}while((b[x>>0]|0)==(b[q>>0]|0))}}while(0);J=f[J>>2]|0;if(!J){G=F;C=54;break}}}else{G=F;C=54}}else{G=0;C=54}while(0);if((C|0)==54){oi(g,a,E,i);C=a+12|0;L=$(((f[C>>2]|0)+1|0)>>>0);M=$(D>>>0);N=$(n[a+16>>2]);do if(B|$(N*M)>>0<3|(D+-1&D|0)!=0)&1;J=~~$(W($(L/N)))>>>0;ei(a,F>>>0>>0?J:F);F=f[z>>2]|0;J=F+-1|0;if(!(J&F)){O=F;P=J&E;break}if(E>>>0>>0){O=F;P=E}else{O=F;P=(E>>>0)%(F>>>0)|0}}else{O=D;P=G}while(0);G=f[(f[a>>2]|0)+(P<<2)>>2]|0;if(!G){D=a+8|0;f[f[g>>2]>>2]=f[D>>2];f[D>>2]=f[g>>2];f[(f[a>>2]|0)+(P<<2)>>2]=D;D=f[g>>2]|0;P=f[D>>2]|0;if(!P)Q=g;else{E=f[P+4>>2]|0;P=O+-1|0;if(P&O)if(E>>>0>>0)R=E;else R=(E>>>0)%(O>>>0)|0;else R=E&P;f[(f[a>>2]|0)+(R<<2)>>2]=D;Q=g}}else{f[f[g>>2]>>2]=f[G>>2];f[G>>2]=f[g>>2];Q=g}f[C>>2]=(f[C>>2]|0)+1;f[Q>>2]=0}Q=f[i+12>>2]|0;if(Q|0){if((f[r>>2]|0)!=(Q|0))f[r>>2]=Q;Oq(Q)}if((b[v>>0]|0)<0)Oq(f[i>>2]|0);i=f[j>>2]|0;if(!i){u=e;return}if((f[k>>2]|0)!=(i|0))f[k>>2]=i;Oq(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if((x|0)==(A|0))D=-1;else{r=(x-A|0)/136|0;v=0;while(1){if((f[B+(v*136|0)>>2]|0)==(c|0))break;t=v+1|0;if(t>>>0>>0)v=t;else{D=-1;break a}}f[g>>2]=v;D=v}while(0);b:do if(!(b[m>>0]|0)){A=(f[y+56>>2]|0)==0;do if(!((p|0)==0|A)){if((p|0)==1?b[B+(D*136|0)+28>>0]|0:0)break;x=ln(88)|0;r=f[a+8>>2]|0;t=B+(D*136|0)+104|0;f[x+4>>2]=0;f[x>>2]=3564;w=x+12|0;f[w>>2]=3588;q=x+64|0;f[q>>2]=0;f[x+68>>2]=0;f[x+72>>2]=0;o=x+16|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[x+76>>2]=r;f[x+80>>2]=t;s=x+84|0;f[s>>2]=0;f[h>>2]=3588;E=h+4|0;F=E+4|0;f[F>>2]=0;f[F+4>>2]=0;f[F+8>>2]=0;f[F+12>>2]=0;f[F+16>>2]=0;f[F+20>>2]=0;F=B+(D*136|0)+4|0;G=i+4|0;f[G>>2]=3588;H=i+56|0;f[H>>2]=0;I=i+60|0;f[I>>2]=0;f[i+64>>2]=0;o=i+8|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[E>>2]=F;o=f[B+(D*136|0)+68>>2]|0;z=((f[o+4>>2]|0)-(f[o>>2]|0)>>2>>>0)/3|0;b[e>>0]=0;qh(h+8|0,z,e);Va[f[(f[h>>2]|0)+8>>2]&127](h);Df(j,h);Df(e,j);f[i>>2]=f[e+4>>2];z=i+4|0;fg(z,e)|0;f[e>>2]=3588;o=f[e+20>>2]|0;if(o|0)Oq(o);o=f[e+8>>2]|0;if(o|0)Oq(o);f[i+36>>2]=F;f[i+40>>2]=t;f[i+44>>2]=r;f[i+48>>2]=x;f[j>>2]=3588;o=f[j+20>>2]|0;if(o|0)Oq(o);o=f[j+8>>2]|0;if(o|0)Oq(o);f[s>>2]=a+72;f[x+8>>2]=f[i>>2];fg(w,z)|0;z=x+44|0;o=i+36|0;f[z>>2]=f[o>>2];f[z+4>>2]=f[o+4>>2];f[z+8>>2]=f[o+8>>2];f[z+12>>2]=f[o+12>>2];b[z+16>>0]=b[o+16>>0]|0;ng(q,f[H>>2]|0,f[I>>2]|0);o=x;z=f[H>>2]|0;if(z|0){J=f[I>>2]|0;if((J|0)!=(z|0))f[I>>2]=J+(~((J+-4-z|0)>>>2)<<2);Oq(z)}f[G>>2]=3588;z=f[i+24>>2]|0;if(z|0)Oq(z);z=f[i+12>>2]|0;if(z|0)Oq(z);f[h>>2]=3588;z=f[h+20>>2]|0;if(z|0)Oq(z);z=f[h+8>>2]|0;if(z|0)Oq(z);K=0;L=o;M=54;break b}while(0);if(!A){b[B+(D*136|0)+100>>0]=0;N=B+(D*136|0)+104|0;M=26}else M=24}else M=24;while(0);if((M|0)==24){N=a+40|0;M=26}if((M|0)==26){D=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+48|0;do if((mi(f[D>>2]|0)|0)==0?(f[y+56>>2]|0)==0:0){if(b[m>>0]|0?(B=f[a+8>>2]|0,((f[B+12>>2]|0)-(f[B+8>>2]|0)|0)>4):0){M=31;break}gf(e,a,N);O=1;P=f[e>>2]|0}else M=31;while(0);if((M|0)==31){Vd(e,a,N);O=0;P=f[e>>2]|0}if(!P)Q=0;else{K=O;L=P;M=54}}if((M|0)==54){M=f[g>>2]|0;if((M|0)==-1)R=a+68|0;else R=(f[n>>2]|0)+(M*136|0)+132|0;f[R>>2]=K;K=ln(76)|0;f[k>>2]=L;rl(K,k,c);c=K;K=f[k>>2]|0;f[k>>2]=0;if(K|0)Va[f[(f[K>>2]|0)+4>>2]&127](K);K=a+188|0;k=f[K>>2]|0;if((k|0)==(f[a+192>>2]|0))Ri(a+184|0,g);else{f[k>>2]=f[g>>2];f[K>>2]=k+4}k=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0;f[l>>2]=c;a=k+12|0;K=f[a>>2]|0;if(K>>>0<(f[k+16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>>2]|0;n=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+4|0;y=f[(f[(f[n>>2]|0)+8>>2]|0)+(c<<2)>>2]|0;f[g>>2]=-1;n=a+172|0;x=f[a+176>>2]|0;A=f[n>>2]|0;B=A;a:do if((x|0)==(A|0))D=-1;else{r=(x-A|0)/136|0;v=0;while(1){if((f[B+(v*136|0)>>2]|0)==(c|0))break;t=v+1|0;if(t>>>0>>0)v=t;else{D=-1;break a}}f[g>>2]=v;D=v}while(0);b:do if(!(b[m>>0]|0)){A=(f[y+56>>2]|0)==0;do if(!((p|0)==0|A)){if((p|0)==1?b[B+(D*136|0)+28>>0]|0:0)break;x=ln(88)|0;r=f[a+8>>2]|0;t=B+(D*136|0)+104|0;f[x+4>>2]=0;f[x>>2]=3564;w=x+12|0;f[w>>2]=3588;q=x+64|0;f[q>>2]=0;f[x+68>>2]=0;f[x+72>>2]=0;o=x+16|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[x+76>>2]=r;f[x+80>>2]=t;s=x+84|0;f[s>>2]=0;f[h>>2]=3588;E=h+4|0;F=E+4|0;f[F>>2]=0;f[F+4>>2]=0;f[F+8>>2]=0;f[F+12>>2]=0;f[F+16>>2]=0;f[F+20>>2]=0;F=B+(D*136|0)+4|0;G=i+4|0;f[G>>2]=3588;H=i+56|0;f[H>>2]=0;I=i+60|0;f[I>>2]=0;f[i+64>>2]=0;o=i+8|0;z=o+44|0;do{f[o>>2]=0;o=o+4|0}while((o|0)<(z|0));f[E>>2]=F;o=f[B+(D*136|0)+68>>2]|0;z=((f[o+4>>2]|0)-(f[o>>2]|0)>>2>>>0)/3|0;b[e>>0]=0;qh(h+8|0,z,e);Va[f[(f[h>>2]|0)+8>>2]&127](h);Df(j,h);Df(e,j);f[i>>2]=f[e+4>>2];z=i+4|0;fg(z,e)|0;f[e>>2]=3588;o=f[e+20>>2]|0;if(o|0)Oq(o);o=f[e+8>>2]|0;if(o|0)Oq(o);f[i+36>>2]=F;f[i+40>>2]=t;f[i+44>>2]=r;f[i+48>>2]=x;f[j>>2]=3588;o=f[j+20>>2]|0;if(o|0)Oq(o);o=f[j+8>>2]|0;if(o|0)Oq(o);f[s>>2]=a+72;f[x+8>>2]=f[i>>2];fg(w,z)|0;z=x+44|0;o=i+36|0;f[z>>2]=f[o>>2];f[z+4>>2]=f[o+4>>2];f[z+8>>2]=f[o+8>>2];f[z+12>>2]=f[o+12>>2];b[z+16>>0]=b[o+16>>0]|0;ng(q,f[H>>2]|0,f[I>>2]|0);o=x;z=f[H>>2]|0;if(z|0){J=f[I>>2]|0;if((J|0)!=(z|0))f[I>>2]=J+(~((J+-4-z|0)>>>2)<<2);Oq(z)}f[G>>2]=3588;z=f[i+24>>2]|0;if(z|0)Oq(z);z=f[i+12>>2]|0;if(z|0)Oq(z);f[h>>2]=3588;z=f[h+20>>2]|0;if(z|0)Oq(z);z=f[h+8>>2]|0;if(z|0)Oq(z);K=0;L=o;M=54;break b}while(0);if(!A){b[B+(D*136|0)+100>>0]=0;N=B+(D*136|0)+104|0;M=26}else M=24}else M=24;while(0);if((M|0)==24){N=a+40|0;M=26}if((M|0)==26){D=(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)+48|0;do if((mi(f[D>>2]|0)|0)==0?(f[y+56>>2]|0)==0:0){if(b[m>>0]|0?(B=f[a+8>>2]|0,((f[B+12>>2]|0)-(f[B+8>>2]|0)|0)>4):0){M=31;break}gf(e,a,N);O=1;P=f[e>>2]|0}else M=31;while(0);if((M|0)==31){Vd(e,a,N);O=0;P=f[e>>2]|0}if(!P)Q=0;else{K=O;L=P;M=54}}if((M|0)==54){M=f[g>>2]|0;if((M|0)==-1)R=a+68|0;else R=(f[n>>2]|0)+(M*136|0)+132|0;f[R>>2]=K;K=ln(76)|0;f[k>>2]=L;rl(K,k,c);c=K;K=f[k>>2]|0;f[k>>2]=0;if(K|0)Va[f[(f[K>>2]|0)+4>>2]&127](K);K=a+188|0;k=f[K>>2]|0;if((k|0)==(f[a+192>>2]|0))Ri(a+184|0,g);else{f[k>>2]=f[g>>2];f[K>>2]=k+4}k=Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0;f[l>>2]=c;a=k+12|0;K=f[a>>2]|0;if(K>>>0<(f[k+16>>2]|0)>>>0){f[l>>2]=0;f[K>>2]=c;f[a>>2]=K+4;S=l}else{Qg(k+8|0,l);S=l}l=f[S>>2]|0;f[S>>2]=0;if(!l)Q=1;else{Va[f[(f[l>>2]|0)+4>>2]&127](l);Q=1}}C=Q;u=d;return C|0}function dc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;c=u;u=u+16|0;d=c+8|0;e=c;g=f[b>>2]|0;if((g|0)==-1){u=c;return}h=(g>>>0)/3|0;i=a+12|0;if(f[(f[i>>2]|0)+(h>>>5<<2)>>2]&1<<(h&31)|0){u=c;return}h=a+56|0;j=f[h>>2]|0;k=a+60|0;l=f[k>>2]|0;if((l|0)==(j|0))m=j;else{n=l+(~((l+-4-j|0)>>>2)<<2)|0;f[k>>2]=n;m=n}n=a+64|0;if((m|0)==(f[n>>2]|0))Ri(h,b);else{f[m>>2]=g;f[k>>2]=m+4}m=f[a>>2]|0;g=f[b>>2]|0;j=g+1|0;if((g|0)!=-1){l=((j>>>0)%3|0|0)==0?g+-2|0:j;if((l|0)==-1)o=-1;else o=f[(f[m>>2]|0)+(l<<2)>>2]|0;l=(((g>>>0)%3|0|0)==0?2:-1)+g|0;if((l|0)==-1){p=o;q=-1}else{p=o;q=f[(f[m>>2]|0)+(l<<2)>>2]|0}}else{p=-1;q=-1}l=a+24|0;m=f[l>>2]|0;o=m+(p>>>5<<2)|0;g=1<<(p&31);j=f[o>>2]|0;if(!(j&g)){f[o>>2]=j|g;g=f[b>>2]|0;j=g+1|0;if((g|0)==-1)r=-1;else r=((j>>>0)%3|0|0)==0?g+-2|0:j;f[e>>2]=r;j=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((r>>>0)/3|0)*12|0)+(((r>>>0)%3|0)<<2)>>2]|0;r=f[a+48>>2]|0;f[d>>2]=j;g=f[r+4>>2]|0;r=g+4|0;o=f[r>>2]|0;if((o|0)==(f[g+8>>2]|0))Ri(g,d);else{f[o>>2]=j;f[r>>2]=o+4}o=a+40|0;r=f[o>>2]|0;j=r+4|0;g=f[j>>2]|0;if((g|0)==(f[r+8>>2]|0)){Ri(r,e);s=f[o>>2]|0}else{f[g>>2]=f[e>>2];f[j>>2]=g+4;s=r}r=s+24|0;f[(f[s+12>>2]|0)+(p<<2)>>2]=f[r>>2];f[r>>2]=(f[r>>2]|0)+1;t=f[l>>2]|0}else t=m;m=t+(q>>>5<<2)|0;t=1<<(q&31);r=f[m>>2]|0;if(!(r&t)){f[m>>2]=r|t;t=f[b>>2]|0;do if((t|0)!=-1)if(!((t>>>0)%3|0)){v=t+2|0;break}else{v=t+-1|0;break}else v=-1;while(0);f[e>>2]=v;t=f[(f[(f[a+44>>2]|0)+96>>2]|0)+(((v>>>0)/3|0)*12|0)+(((v>>>0)%3|0)<<2)>>2]|0;v=f[a+48>>2]|0;f[d>>2]=t;r=f[v+4>>2]|0;v=r+4|0;m=f[v>>2]|0;if((m|0)==(f[r+8>>2]|0))Ri(r,d);else{f[m>>2]=t;f[v>>2]=m+4}m=a+40|0;v=f[m>>2]|0;t=v+4|0;r=f[t>>2]|0;if((r|0)==(f[v+8>>2]|0)){Ri(v,e);w=f[m>>2]|0}else{f[r>>2]=f[e>>2];f[t>>2]=r+4;w=v}v=w+24|0;f[(f[w+12>>2]|0)+(q<<2)>>2]=f[v>>2];f[v>>2]=(f[v>>2]|0)+1}v=f[h>>2]|0;q=f[k>>2]|0;if((v|0)==(q|0)){u=c;return}w=a+44|0;r=a+48|0;t=a+40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f[b>>2]=G;H=(G>>>0)/3|0}else{E=v;F=60}while(0);if((F|0)==60){F=0;v=f[a>>2]|0;if((E|0)==-1){F=61;break}j=E+1|0;o=((j>>>0)%3|0|0)==0?E+-2|0:j;if((o|0)==-1)I=-1;else I=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;f[d>>2]=I;o=(((E>>>0)%3|0|0)==0?2:-1)+E|0;if((o|0)==-1)J=-1;else J=f[(f[v+12>>2]|0)+(o<<2)>>2]|0;o=(I|0)==-1;v=(I>>>0)/3|0;j=o?-1:v;g=(J|0)==-1;z=(J>>>0)/3|0;A=g?-1:z;do if(!o){y=f[i>>2]|0;if(f[y+(j>>>5<<2)>>2]&1<<(j&31)|0){F=68;break}if(g){K=I;L=v;break}if(!(f[y+(A>>>5<<2)>>2]&1<<(A&31))){F=73;break a}else{K=I;L=v}}else F=68;while(0);if((F|0)==68){F=0;if(g){F=70;break}if(!(f[(f[i>>2]|0)+(A>>>5<<2)>>2]&1<<(A&31))){K=J;L=z}else{F=70;break}}f[b>>2]=K;H=L}s=H;p=f[i>>2]|0}do if((F|0)==61){F=0;f[d>>2]=-1;F=70}else if((F|0)==73){F=0;p=f[k>>2]|0;f[p+-4>>2]=J;if((p|0)==(f[n>>2]|0)){Ri(h,d);M=f[k>>2]|0;break}else{f[p>>2]=f[d>>2];s=p+4|0;f[k>>2]=s;M=s;break}}while(0);if((F|0)==70){F=0;s=(f[k>>2]|0)+-4|0;f[k>>2]=s;M=s}N=f[h>>2]|0;O=M}else{s=m+-4|0;f[k>>2]=s;N=q;O=s}if((N|0)==(O|0))break;else{m=O;q=N}}u=c;return}function ec(a,c,e){a=a|0;c=c|0;e=e|0;var g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=Oa,fa=Oa,ga=Oa,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0;g=u;u=u+48|0;i=g+12|0;j=g+32|0;k=g;l=i+16|0;f[i>>2]=0;f[i+4>>2]=0;f[i+8>>2]=0;f[i+12>>2]=0;n[l>>2]=$(1.0);m=a+80|0;o=f[m>>2]|0;f[k>>2]=0;p=k+4|0;f[p>>2]=0;f[k+8>>2]=0;if(o){if(o>>>0>1073741823)aq(k);q=o<<2;r=ln(q)|0;f[k>>2]=r;s=r+(o<<2)|0;f[k+8>>2]=s;sj(r|0,0,q|0)|0;f[p>>2]=s;s=c+48|0;q=c+40|0;o=i+4|0;t=i+12|0;v=i+8|0;w=a+40|0;x=a+64|0;y=f[e>>2]|0;e=0;z=r;A=0;B=0;C=r;D=r;E=r;while(1){r=s;F=f[r>>2]|0;G=f[r+4>>2]|0;r=q;H=un(f[r>>2]|0,f[r+4>>2]|0,y+A|0,0)|0;r=Vn(H|0,I|0,F|0,G|0)|0;G=(f[f[c>>2]>>2]|0)+r|0;r=h[G>>0]|h[G+1>>0]<<8;d[j>>1]=r;G=(r^318)&65535;a:do if(e){F=e+-1|0;H=(F&e|0)==0;if(!H)if(e>>>0>G>>>0)J=G;else J=(G>>>0)%(e>>>0)|0;else J=F&G;K=f[i>>2]|0;L=f[K+(J<<2)>>2]|0;b:do if(L|0?(M=f[L>>2]|0,M|0):0){c:do if(H){N=M;while(1){O=f[N+4>>2]|0;P=(O|0)==(G|0);if(!(P|(O&F|0)==(J|0)))break b;if(P?(d[N+8>>1]|0)==r<<16>>16:0){Q=N;break c}N=f[N>>2]|0;if(!N)break b}}else{N=M;while(1){P=f[N+4>>2]|0;if((P|0)==(G|0)){if((d[N+8>>1]|0)==r<<16>>16){Q=N;break c}}else{if(P>>>0>>0)R=P;else R=(P>>>0)%(e>>>0)|0;if((R|0)!=(J|0))break b}N=f[N>>2]|0;if(!N)break b}}while(0);f[E+(A<<2)>>2]=f[Q+12>>2];S=z;T=B;U=D;V=C;X=E;break a}while(0);if(!H)if(e>>>0>G>>>0)Y=G;else Y=(G>>>0)%(e>>>0)|0;else Y=F&G;L=f[K+(Y<<2)>>2]|0;if(!L){Z=Y;_=e;aa=0;ba=40}else{if(H){M=L;while(1){M=f[M>>2]|0;if(!M){Z=Y;_=e;aa=0;ba=40;break a}N=f[M+4>>2]|0;if(!((N|0)==(G|0)|(N&F|0)==(Y|0))){Z=Y;_=e;aa=0;ba=40;break a}if((d[M+8>>1]|0)==r<<16>>16){ba=55;break a}}}else ca=L;while(1){ca=f[ca>>2]|0;if(!ca){Z=Y;_=e;aa=0;ba=40;break a}M=f[ca+4>>2]|0;if((M|0)!=(G|0)){if(M>>>0>>0)da=M;else da=(M>>>0)%(e>>>0)|0;if((da|0)!=(Y|0)){Z=Y;_=e;aa=0;ba=40;break a}}if((d[ca+8>>1]|0)==r<<16>>16){ba=55;break}}}}else{Z=0;_=0;aa=1;ba=40}while(0);if((ba|0)==40){ba=0;L=ln(16)|0;d[L+8>>1]=r;f[L+12>>2]=B;f[L+4>>2]=G;f[L>>2]=0;ea=$(((f[t>>2]|0)+1|0)>>>0);fa=$(_>>>0);ga=$(n[l>>2]);do if(aa|$(ga*fa)>>0<3|(_+-1&_|0)!=0)&1;F=~~$(W($(ea/ga)))>>>0;Vh(i,M>>>0>>0?F:M);M=f[o>>2]|0;F=M+-1|0;if(!(F&M)){ha=M;ia=F&G;break}if(M>>>0>G>>>0){ha=M;ia=G}else{ha=M;ia=(G>>>0)%(M>>>0)|0}}else{ha=_;ia=Z}while(0);G=(f[i>>2]|0)+(ia<<2)|0;r=f[G>>2]|0;if(!r){f[L>>2]=f[v>>2];f[v>>2]=L;f[G>>2]=v;G=f[L>>2]|0;if(G|0){M=f[G+4>>2]|0;G=ha+-1|0;if(G&ha)if(M>>>0>>0)ja=M;else ja=(M>>>0)%(ha>>>0)|0;else ja=M&G;ka=(f[i>>2]|0)+(ja<<2)|0;ba=53}}else{f[L>>2]=f[r>>2];ka=r;ba=53}if((ba|0)==53){ba=0;f[ka>>2]=L}f[t>>2]=(f[t>>2]|0)+1;ba=55}if((ba|0)==55){ba=0;r=w;G=f[r>>2]|0;M=un(G|0,f[r+4>>2]|0,B|0,0)|0;kh((f[f[x>>2]>>2]|0)+M|0,j|0,G|0)|0;G=f[k>>2]|0;f[G+(A<<2)>>2]=B;S=G;T=B+1|0;U=G;V=G;X=G}G=A+1|0;la=f[m>>2]|0;if(G>>>0>=la>>>0)break;e=f[o>>2]|0;z=S;A=G;B=T;C=V;D=U;E=X}if((T|0)==(la|0))ma=V;else{V=a+84|0;if(!(b[V>>0]|0)){X=f[a+72>>2]|0;E=f[a+68>>2]|0;D=E;if((X|0)==(E|0))na=S;else{C=X-E>>2;E=0;do{X=D+(E<<2)|0;f[X>>2]=f[U+(f[X>>2]<<2)>>2];E=E+1|0}while(E>>>0>>0);na=S}}else{b[V>>0]=0;V=a+68|0;S=a+72|0;C=f[S>>2]|0;E=f[V>>2]|0;U=C-E>>2;D=E;E=C;if(la>>>0<=U>>>0)if(la>>>0>>0?(C=D+(la<<2)|0,(C|0)!=(E|0)):0){f[S>>2]=E+(~((E+-4-C|0)>>>2)<<2);oa=la}else oa=la;else{Ch(V,la-U|0,1220);oa=f[m>>2]|0}U=f[k>>2]|0;if(!oa)na=U;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[U+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);na=U}}f[m>>2]=T;ma=na}if(!ma)pa=T;else{na=f[p>>2]|0;if((na|0)!=(ma|0))f[p>>2]=na+(~((na+-4-ma|0)>>>2)<<2);Oq(ma);pa=T}}else pa=0;T=f[i+8>>2]|0;if(T|0){ma=T;do{T=ma;ma=f[ma>>2]|0;Oq(T)}while((ma|0)!=0)}ma=f[i>>2]|0;f[i>>2]=0;if(!ma){u=g;return pa|0}Oq(ma);u=g;return pa|0}function fc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=Oa,K=Oa,L=Oa,M=0,N=0,O=0,P=0;e=u;u=u+64|0;g=e+40|0;i=e+16|0;j=e;k=Id(a,c)|0;if(k|0){f[i>>2]=k;f[g>>2]=f[i>>2];lf(a,g)|0}f[j>>2]=0;k=j+4|0;f[k>>2]=0;f[j+8>>2]=0;Fi(j,4);l=f[j>>2]|0;m=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[l>>0]=m;b[l+1>>0]=m>>8;b[l+2>>0]=m>>16;b[l+3>>0]=m>>24;pj(i,c);c=i+12|0;f[c>>2]=0;m=i+16|0;f[m>>2]=0;f[i+20>>2]=0;l=f[k>>2]|0;d=f[j>>2]|0;o=l-d|0;if(!o){p=d;q=l;r=0}else{Fi(c,o);p=f[j>>2]|0;q=f[k>>2]|0;r=f[c>>2]|0}kh(r|0,p|0,q-p|0)|0;p=i+11|0;q=b[p>>0]|0;r=q<<24>>24<0;c=r?f[i>>2]|0:i;o=r?f[i+4>>2]|0:q&255;if(o>>>0>3){q=c;r=o;l=o;while(1){d=X(h[q>>0]|h[q+1>>0]<<8|h[q+2>>0]<<16|h[q+3>>0]<<24,1540483477)|0;r=(X(d>>>24^d,1540483477)|0)^(X(r,1540483477)|0);l=l+-4|0;if(l>>>0<=3)break;else q=q+4|0}q=o+-4|0;l=q&-4;s=q-l|0;t=c+(l+4)|0;v=r}else{s=o;t=c;v=o}switch(s|0){case 3:{w=h[t+2>>0]<<16^v;x=10;break}case 2:{w=v;x=10;break}case 1:{y=v;x=11;break}default:z=v}if((x|0)==10){y=h[t+1>>0]<<8^w;x=11}if((x|0)==11)z=X(y^h[t>>0],1540483477)|0;t=X(z>>>13^z,1540483477)|0;z=t>>>15^t;t=a+4|0;y=f[t>>2]|0;w=(y|0)==0;a:do if(!w){v=y+-1|0;s=(v&y|0)==0;if(!s)if(z>>>0>>0)A=z;else A=(z>>>0)%(y>>>0)|0;else A=z&v;r=f[(f[a>>2]|0)+(A<<2)>>2]|0;if((r|0)!=0?(l=f[r>>2]|0,(l|0)!=0):0){r=(o|0)==0;if(s){if(r){s=l;while(1){q=f[s+4>>2]|0;if(!((q|0)==(z|0)|(q&v|0)==(A|0))){B=A;x=52;break a}q=b[s+8+11>>0]|0;if(!((q<<24>>24<0?f[s+12>>2]|0:q&255)|0))break a;s=f[s>>2]|0;if(!s){B=A;x=52;break a}}}else C=l;while(1){s=f[C+4>>2]|0;if(!((s|0)==(z|0)|(s&v|0)==(A|0))){B=A;x=52;break a}s=C+8|0;q=b[s+11>>0]|0;d=q<<24>>24<0;D=q&255;do if(((d?f[C+12>>2]|0:D)|0)==(o|0)){q=f[s>>2]|0;if(d)if(!(Vk(q,c,o)|0))break a;else break;if((b[c>>0]|0)==(q&255)<<24>>24){q=s;E=D;F=c;do{E=E+-1|0;q=q+1|0;if(!E)break a;F=F+1|0}while((b[q>>0]|0)==(b[F>>0]|0))}}while(0);C=f[C>>2]|0;if(!C){B=A;x=52;break a}}}if(r){v=l;while(1){D=f[v+4>>2]|0;if((D|0)!=(z|0)){if(D>>>0>>0)G=D;else G=(D>>>0)%(y>>>0)|0;if((G|0)!=(A|0)){B=A;x=52;break a}}D=b[v+8+11>>0]|0;if(!((D<<24>>24<0?f[v+12>>2]|0:D&255)|0))break a;v=f[v>>2]|0;if(!v){B=A;x=52;break a}}}else H=l;while(1){v=f[H+4>>2]|0;if((v|0)!=(z|0)){if(v>>>0>>0)I=v;else I=(v>>>0)%(y>>>0)|0;if((I|0)!=(A|0)){B=A;x=52;break a}}v=H+8|0;r=b[v+11>>0]|0;D=r<<24>>24<0;s=r&255;do if(((D?f[H+12>>2]|0:s)|0)==(o|0)){r=f[v>>2]|0;if(D)if(!(Vk(r,c,o)|0))break a;else break;if((b[c>>0]|0)==(r&255)<<24>>24){r=v;d=s;F=c;do{d=d+-1|0;r=r+1|0;if(!d)break a;F=F+1|0}while((b[r>>0]|0)==(b[F>>0]|0))}}while(0);H=f[H>>2]|0;if(!H){B=A;x=52;break}}}else{B=A;x=52}}else{B=0;x=52}while(0);if((x|0)==52){oi(g,a,z,i);x=a+12|0;J=$(((f[x>>2]|0)+1|0)>>>0);K=$(y>>>0);L=$(n[a+16>>2]);do if(w|$(L*K)>>0<3|(y+-1&y|0)!=0)&1;H=~~$(W($(J/L)))>>>0;ei(a,A>>>0>>0?H:A);A=f[t>>2]|0;H=A+-1|0;if(!(H&A)){M=A;N=H&z;break}if(z>>>0>>0){M=A;N=z}else{M=A;N=(z>>>0)%(A>>>0)|0}}else{M=y;N=B}while(0);B=f[(f[a>>2]|0)+(N<<2)>>2]|0;if(!B){y=a+8|0;f[f[g>>2]>>2]=f[y>>2];f[y>>2]=f[g>>2];f[(f[a>>2]|0)+(N<<2)>>2]=y;y=f[g>>2]|0;N=f[y>>2]|0;if(!N)O=g;else{z=f[N+4>>2]|0;N=M+-1|0;if(N&M)if(z>>>0>>0)P=z;else P=(z>>>0)%(M>>>0)|0;else P=z&N;f[(f[a>>2]|0)+(P<<2)>>2]=y;O=g}}else{f[f[g>>2]>>2]=f[B>>2];f[B>>2]=f[g>>2];O=g}f[x>>2]=(f[x>>2]|0)+1;f[O>>2]=0}O=f[i+12>>2]|0;if(O|0){if((f[m>>2]|0)!=(O|0))f[m>>2]=O;Oq(O)}if((b[p>>0]|0)<0)Oq(f[i>>2]|0);i=f[j>>2]|0;if(!i){u=e;return}if((f[k>>2]|0)!=(i|0))f[k>>2]=i;Oq(i);u=e;return}function gc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=Oa,da=Oa,ea=Oa,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0;e=u;u=u+48|0;g=e+12|0;h=e+32|0;i=e;j=g+16|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;n[j>>2]=$(1.0);k=a+80|0;l=f[k>>2]|0;f[i>>2]=0;m=i+4|0;f[m>>2]=0;f[i+8>>2]=0;if(l){if(l>>>0>1073741823)aq(i);o=l<<2;p=ln(o)|0;f[i>>2]=p;q=p+(l<<2)|0;f[i+8>>2]=q;sj(p|0,0,o|0)|0;f[m>>2]=q;q=c+48|0;o=c+40|0;l=g+4|0;r=g+12|0;s=g+8|0;t=a+40|0;v=a+64|0;w=f[d>>2]|0;d=0;x=p;y=0;z=0;A=p;B=p;C=p;while(1){p=q;D=f[p>>2]|0;E=f[p+4>>2]|0;p=o;F=un(f[p>>2]|0,f[p+4>>2]|0,w+y|0,0)|0;p=Vn(F|0,I|0,D|0,E|0)|0;E=b[(f[f[c>>2]>>2]|0)+p>>0]|0;b[h>>0]=E;p=E&255^318;a:do if(d){D=d+-1|0;F=(D&d|0)==0;if(!F)if(p>>>0>>0)G=p;else G=(p>>>0)%(d>>>0)|0;else G=D&p;H=f[g>>2]|0;J=f[H+(G<<2)>>2]|0;b:do if(J|0?(K=f[J>>2]|0,K|0):0){c:do if(F){L=K;while(1){M=f[L+4>>2]|0;N=(M|0)==(p|0);if(!(N|(M&D|0)==(G|0)))break b;if(N?(b[L+8>>0]|0)==E<<24>>24:0){O=L;break c}L=f[L>>2]|0;if(!L)break b}}else{L=K;while(1){N=f[L+4>>2]|0;if((N|0)==(p|0)){if((b[L+8>>0]|0)==E<<24>>24){O=L;break c}}else{if(N>>>0>>0)P=N;else P=(N>>>0)%(d>>>0)|0;if((P|0)!=(G|0))break b}L=f[L>>2]|0;if(!L)break b}}while(0);f[C+(y<<2)>>2]=f[O+12>>2];Q=x;R=z;S=B;T=A;U=C;break a}while(0);if(!F)if(p>>>0>>0)V=p;else V=(p>>>0)%(d>>>0)|0;else V=D&p;J=f[H+(V<<2)>>2]|0;if(!J){X=V;Y=d;Z=0;_=40}else{if(F){K=J;while(1){K=f[K>>2]|0;if(!K){X=V;Y=d;Z=0;_=40;break a}L=f[K+4>>2]|0;if(!((L|0)==(p|0)|(L&D|0)==(V|0))){X=V;Y=d;Z=0;_=40;break a}if((b[K+8>>0]|0)==E<<24>>24){_=55;break a}}}else aa=J;while(1){aa=f[aa>>2]|0;if(!aa){X=V;Y=d;Z=0;_=40;break a}K=f[aa+4>>2]|0;if((K|0)!=(p|0)){if(K>>>0>>0)ba=K;else ba=(K>>>0)%(d>>>0)|0;if((ba|0)!=(V|0)){X=V;Y=d;Z=0;_=40;break a}}if((b[aa+8>>0]|0)==E<<24>>24){_=55;break}}}}else{X=0;Y=0;Z=1;_=40}while(0);if((_|0)==40){_=0;J=ln(16)|0;b[J+8>>0]=E;f[J+12>>2]=z;f[J+4>>2]=p;f[J>>2]=0;ca=$(((f[r>>2]|0)+1|0)>>>0);da=$(Y>>>0);ea=$(n[j>>2]);do if(Z|$(ea*da)>>0<3|(Y+-1&Y|0)!=0)&1;D=~~$(W($(ca/ea)))>>>0;ai(g,K>>>0>>0?D:K);K=f[l>>2]|0;D=K+-1|0;if(!(D&K)){fa=K;ga=D&p;break}if(p>>>0>>0){fa=K;ga=p}else{fa=K;ga=(p>>>0)%(K>>>0)|0}}else{fa=Y;ga=X}while(0);p=(f[g>>2]|0)+(ga<<2)|0;E=f[p>>2]|0;if(!E){f[J>>2]=f[s>>2];f[s>>2]=J;f[p>>2]=s;p=f[J>>2]|0;if(p|0){K=f[p+4>>2]|0;p=fa+-1|0;if(p&fa)if(K>>>0>>0)ha=K;else ha=(K>>>0)%(fa>>>0)|0;else ha=K&p;ia=(f[g>>2]|0)+(ha<<2)|0;_=53}}else{f[J>>2]=f[E>>2];ia=E;_=53}if((_|0)==53){_=0;f[ia>>2]=J}f[r>>2]=(f[r>>2]|0)+1;_=55}if((_|0)==55){_=0;E=t;p=f[E>>2]|0;K=un(p|0,f[E+4>>2]|0,z|0,0)|0;kh((f[f[v>>2]>>2]|0)+K|0,h|0,p|0)|0;p=f[i>>2]|0;f[p+(y<<2)>>2]=z;Q=p;R=z+1|0;S=p;T=p;U=p}p=y+1|0;ja=f[k>>2]|0;if(p>>>0>=ja>>>0)break;d=f[l>>2]|0;x=Q;y=p;z=R;A=T;B=S;C=U}if((R|0)==(ja|0))ka=T;else{T=a+84|0;if(!(b[T>>0]|0)){U=f[a+72>>2]|0;C=f[a+68>>2]|0;B=C;if((U|0)==(C|0))la=Q;else{A=U-C>>2;C=0;do{U=B+(C<<2)|0;f[U>>2]=f[S+(f[U>>2]<<2)>>2];C=C+1|0}while(C>>>0>>0);la=Q}}else{b[T>>0]=0;T=a+68|0;Q=a+72|0;A=f[Q>>2]|0;C=f[T>>2]|0;S=A-C>>2;B=C;C=A;if(ja>>>0<=S>>>0)if(ja>>>0>>0?(A=B+(ja<<2)|0,(A|0)!=(C|0)):0){f[Q>>2]=C+(~((C+-4-A|0)>>>2)<<2);ma=ja}else ma=ja;else{Ch(T,ja-S|0,1220);ma=f[k>>2]|0}S=f[i>>2]|0;if(!ma)la=S;else{i=f[a+68>>2]|0;a=0;do{f[i+(a<<2)>>2]=f[S+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);la=S}}f[k>>2]=R;ka=la}if(!ka)na=R;else{la=f[m>>2]|0;if((la|0)!=(ka|0))f[m>>2]=la+(~((la+-4-ka|0)>>>2)<<2);Oq(ka);na=R}}else na=0;R=f[g+8>>2]|0;if(R|0){ka=R;do{R=ka;ka=f[ka>>2]|0;Oq(R)}while((ka|0)!=0)}ka=f[g>>2]|0;f[g>>2]=0;if(!ka){u=e;return na|0}Oq(ka);u=e;return na|0}function hc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,i=0,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>2]|0;if(!M)break b}}else{M=L;while(1){O=f[M+4>>2]|0;if((O|0)==(F|0)){if((f[M+8>>2]|0)==(q|0)){P=M;break c}}else{if(O>>>0>>0)Q=O;else Q=(O>>>0)%(d>>>0)|0;if((Q|0)!=(H|0))break b}M=f[M>>2]|0;if(!M)break b}}while(0);f[D+(z<<2)>>2]=f[P+12>>2];R=y;S=A;T=C;U=B;V=D;break a}while(0);if(!G)if(F>>>0>>0)X=F;else X=(F>>>0)%(d>>>0)|0;else X=E&F;K=f[J+(X<<2)>>2]|0;if(!K){Y=X;Z=d;_=0;aa=40}else{if(G){L=K;while(1){L=f[L>>2]|0;if(!L){Y=X;Z=d;_=0;aa=40;break a}M=f[L+4>>2]|0;if(!((M|0)==(F|0)|(M&E|0)==(X|0))){Y=X;Z=d;_=0;aa=40;break a}if((f[L+8>>2]|0)==(q|0)){aa=55;break a}}}else ba=K;while(1){ba=f[ba>>2]|0;if(!ba){Y=X;Z=d;_=0;aa=40;break a}L=f[ba+4>>2]|0;if((L|0)!=(F|0)){if(L>>>0>>0)ca=L;else ca=(L>>>0)%(d>>>0)|0;if((ca|0)!=(X|0)){Y=X;Z=d;_=0;aa=40;break a}}if((f[ba+8>>2]|0)==(q|0)){aa=55;break}}}}else{Y=0;Z=0;_=1;aa=40}while(0);if((aa|0)==40){aa=0;K=ln(16)|0;f[K+8>>2]=q;f[K+12>>2]=A;f[K+4>>2]=F;f[K>>2]=0;da=$(((f[s>>2]|0)+1|0)>>>0);ea=$(Z>>>0);fa=$(n[k>>2]);do if(_|$(fa*ea)>>0<3|(Z+-1&Z|0)!=0)&1;E=~~$(W($(da/fa)))>>>0;Hi(g,L>>>0>>0?E:L);L=f[m>>2]|0;E=L+-1|0;if(!(E&L)){ga=L;ha=E&F;break}if(F>>>0>>0){ga=L;ha=F}else{ga=L;ha=(F>>>0)%(L>>>0)|0}}else{ga=Z;ha=Y}while(0);F=(f[g>>2]|0)+(ha<<2)|0;q=f[F>>2]|0;if(!q){f[K>>2]=f[t>>2];f[t>>2]=K;f[F>>2]=t;F=f[K>>2]|0;if(F|0){L=f[F+4>>2]|0;F=ga+-1|0;if(F&ga)if(L>>>0>>0)ia=L;else ia=(L>>>0)%(ga>>>0)|0;else ia=L&F;ja=(f[g>>2]|0)+(ia<<2)|0;aa=53}}else{f[K>>2]=f[q>>2];ja=q;aa=53}if((aa|0)==53){aa=0;f[ja>>2]=K}f[s>>2]=(f[s>>2]|0)+1;aa=55}if((aa|0)==55){aa=0;q=v;F=f[q>>2]|0;L=un(F|0,f[q+4>>2]|0,A|0,0)|0;kh((f[f[w>>2]>>2]|0)+L|0,i|0,F|0)|0;F=f[j>>2]|0;f[F+(z<<2)>>2]=A;R=F;S=A+1|0;T=F;U=F;V=F}F=z+1|0;ka=f[l>>2]|0;if(F>>>0>=ka>>>0)break;d=f[m>>2]|0;y=R;z=F;A=S;B=U;C=T;D=V}if((S|0)==(ka|0))la=U;else{U=a+84|0;if(!(b[U>>0]|0)){V=f[a+72>>2]|0;D=f[a+68>>2]|0;C=D;if((V|0)==(D|0))ma=R;else{B=V-D>>2;D=0;do{V=C+(D<<2)|0;f[V>>2]=f[T+(f[V>>2]<<2)>>2];D=D+1|0}while(D>>>0>>0);ma=R}}else{b[U>>0]=0;U=a+68|0;R=a+72|0;B=f[R>>2]|0;D=f[U>>2]|0;T=B-D>>2;C=D;D=B;if(ka>>>0<=T>>>0)if(ka>>>0>>0?(B=C+(ka<<2)|0,(B|0)!=(D|0)):0){f[R>>2]=D+(~((D+-4-B|0)>>>2)<<2);na=ka}else na=ka;else{Ch(U,ka-T|0,1220);na=f[l>>2]|0}T=f[j>>2]|0;if(!na)ma=T;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[T+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);ma=T}}f[l>>2]=S;la=ma}if(!la)oa=S;else{ma=f[o>>2]|0;if((ma|0)!=(la|0))f[o>>2]=ma+(~((ma+-4-la|0)>>>2)<<2);Oq(la);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C=yf(i,k)|0;if(!C){A=k;B=f[A>>2]|0;D=f[A+4>>2]|0;A=B&65535;E=Yn(B|0,D|0,16)|0;F=E&65535;G=D&65535;H=Yn(B|0,D|0,48)|0;J=H&65535;K=((((A^318)&65535)+239^E&65535)+239^D&65535)+239^H&65535;H=f[s>>2]|0;E=(H|0)==0;a:do if(!E){L=H+-1|0;M=(L&H|0)==0;if(!M)if(K>>>0>>0)N=K;else N=(K>>>0)%(H>>>0)|0;else N=K&L;O=f[(f[i>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(K|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}O=M+8|0;if((((d[O>>1]|0)==A<<16>>16?(d[O+2>>1]|0)==F<<16>>16:0)?(d[M+12>>1]|0)==G<<16>>16:0)?(d[O+6>>1]|0)==J<<16>>16:0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(K|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(H>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}M=S+8|0;if((((d[M>>1]|0)==A<<16>>16?(d[M+2>>1]|0)==F<<16>>16:0)?(d[S+12>>1]|0)==G<<16>>16:0)?(d[M+6>>1]|0)==J<<16>>16:0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;J=ln(20)|0;G=J+8|0;F=G;d[F>>1]=B;d[F+2>>1]=B>>>16;F=G+4|0;d[F>>1]=D;d[F+2>>1]=D>>>16;f[J+16>>2]=z;f[J+4>>2]=K;f[J>>2]=0;U=$(((f[p>>2]|0)+1|0)>>>0);V=$(H>>>0);X=$(n[m>>2]);do if(E|$(X*V)>>0<3|(H+-1&H|0)!=0)&1;G=~~$(W($(U/X)))>>>0;Sh(i,F>>>0>>0?G:F);F=f[s>>2]|0;G=F+-1|0;if(!(G&F)){Y=F;Z=G&K;break}if(K>>>0>>0){Y=F;Z=K}else{Y=F;Z=(K>>>0)%(F>>>0)|0}}else{Y=H;Z=Q}while(0);H=(f[i>>2]|0)+(Z<<2)|0;K=f[H>>2]|0;if(!K){f[J>>2]=f[v>>2];f[v>>2]=J;f[H>>2]=v;H=f[J>>2]|0;if(H|0){E=f[H+4>>2]|0;H=Y+-1|0;if(H&Y)if(E>>>0>>0)_=E;else _=(E>>>0)%(Y>>>0)|0;else _=E&H;aa=(f[i>>2]|0)+(_<<2)|0;R=44}}else{f[J>>2]=f[K>>2];aa=K;R=44}if((R|0)==44){R=0;f[aa>>2]=J}f[p>>2]=(f[p>>2]|0)+1}K=w;H=f[K>>2]|0;E=un(H|0,f[K+4>>2]|0,z|0,0)|0;kh((f[f[x>>2]>>2]|0)+E|0,j|0,H|0)|0;H=f[l>>2]|0;f[H+(y<<2)>>2]=z;ba=z+1|0;ca=H}else{H=f[l>>2]|0;f[H+(y<<2)>>2]=f[C+16>>2];ba=z;ca=H}y=y+1|0;da=f[o>>2]|0;if(y>>>0>=da>>>0)break;else z=ba}if((ba|0)==(da|0))ea=ca;else{z=a+84|0;if(!(b[z>>0]|0)){y=f[a+72>>2]|0;j=f[a+68>>2]|0;x=j;if((y|0)==(j|0))fa=ca;else{w=y-j>>2;j=0;do{y=x+(j<<2)|0;f[y>>2]=f[ca+(f[y>>2]<<2)>>2];j=j+1|0}while(j>>>0>>0);fa=ca}}else{b[z>>0]=0;z=a+68|0;ca=a+72|0;w=f[ca>>2]|0;j=f[z>>2]|0;x=w-j>>2;y=j;j=w;if(da>>>0<=x>>>0)if(da>>>0>>0?(w=y+(da<<2)|0,(w|0)!=(j|0)):0){f[ca>>2]=j+(~((j+-4-w|0)>>>2)<<2);ga=da}else ga=da;else{Ch(z,da-x|0,1220);ga=f[o>>2]|0}x=f[l>>2]|0;if(!ga)fa=x;else{l=f[a+68>>2]|0;a=0;do{f[l+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=x}}f[o>>2]=ba;ea=fa}if(!ea)ha=ba;else{fa=f[q>>2]|0;if((fa|0)!=(ea|0))f[q>>2]=fa+(~((fa+-4-ea|0)>>>2)<<2);Oq(ea);ha=ba}}else ha=0;ba=f[i+8>>2]|0;if(ba|0){ea=ba;do{ba=ea;ea=f[ea>>2]|0;Oq(ba)}while((ea|0)!=0)}ea=f[i>>2]|0;f[i>>2]=0;if(!ea){u=g;return ha|0}Oq(ea);u=g;return ha|0}function kc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0;c=u;u=u+16|0;d=c+8|0;e=c;g=c+4|0;h=a+16|0;i=f[h>>2]|0;j=a+20|0;k=f[j>>2]|0;if((k|0)==(i|0))l=i;else{m=k+(~((k+-4-i|0)>>>2)<<2)|0;f[j>>2]=m;l=m}m=a+24|0;if((l|0)==(f[m>>2]|0)){Ri(h,b);n=f[h>>2]|0;o=f[j>>2]|0}else{f[l>>2]=f[b>>2];k=l+4|0;f[j>>2]=k;n=i;o=k}k=f[a+8>>2]|0;i=(f[k+100>>2]|0)-(f[k+96>>2]|0)|0;k=(i|0)/12|0;if((n|0)==(o|0)){u=c;return 1}n=a+28|0;l=(i|0)>0;i=a+164|0;p=a+12|0;q=a+76|0;r=a+80|0;s=a+72|0;t=a+152|0;v=a+84|0;w=a+272|0;x=a+276|0;y=a+268|0;z=a+168|0;A=a+140|0;B=a+120|0;C=o;do{o=f[C+-4>>2]|0;f[b>>2]=o;a:do if((o|0)!=-1?(D=(o>>>0)/3|0,E=f[n>>2]|0,(f[E+(D>>>5<<2)>>2]&1<<(D&31)|0)==0):0){if(l){D=0;F=E;b:while(1){E=D+1|0;f[i>>2]=(f[i>>2]|0)+1;G=f[b>>2]|0;H=(G|0)==-1?-1:(G>>>0)/3|0;G=F+(H>>>5<<2)|0;f[G>>2]=1<<(H&31)|f[G>>2];G=f[q>>2]|0;if((G|0)==(f[r>>2]|0))Ri(s,b);else{f[G>>2]=f[b>>2];f[q>>2]=G+4}G=f[b>>2]|0;if((G|0)==-1)I=-1;else I=f[(f[f[p>>2]>>2]|0)+(G<<2)>>2]|0;J=(f[(f[t>>2]|0)+(I<<2)>>2]|0)!=-1;K=(f[v>>2]|0)+(I>>>5<<2)|0;L=1<<(I&31);M=f[K>>2]|0;do if(!(M&L)){f[K>>2]=M|L;if(J){N=f[b>>2]|0;O=30;break}f[d>>2]=0;P=f[w>>2]|0;if((P|0)==(f[x>>2]|0))Ri(y,d);else{f[P>>2]=0;f[w>>2]=P+4}P=f[b>>2]|0;Q=P+1|0;if((P|0)!=-1?(R=((Q>>>0)%3|0|0)==0?P+-2|0:Q,(R|0)!=-1):0)S=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;else S=-1;f[b>>2]=S}else{N=G;O=30}while(0);if((O|0)==30){O=0;G=N+1|0;if((N|0)==-1){O=35;break}L=((G>>>0)%3|0|0)==0?N+-2|0:G;if((L|0)==-1)T=-1;else T=f[(f[(f[p>>2]|0)+12>>2]|0)+(L<<2)>>2]|0;f[e>>2]=T;L=(((N>>>0)%3|0|0)==0?2:-1)+N|0;if((L|0)==-1)U=-1;else U=f[(f[(f[p>>2]|0)+12>>2]|0)+(L<<2)>>2]|0;L=(T|0)==-1;M=L?-1:(T>>>0)/3|0;V=(U|0)==-1;W=V?-1:(U>>>0)/3|0;K=((G>>>0)%3|0|0)==0?N+-2|0:G;if(((K|0)!=-1?(G=f[(f[p>>2]|0)+12>>2]|0,R=f[G+(K<<2)>>2]|0,(R|0)!=-1):0)?(K=(R>>>0)/3|0,R=f[n>>2]|0,(f[R+(K>>>5<<2)>>2]&1<<(K&31)|0)==0):0){K=(((N>>>0)%3|0|0)==0?2:-1)+N|0;do if((K|0)!=-1){Q=f[G+(K<<2)>>2]|0;if((Q|0)==-1)break;P=(Q>>>0)/3|0;if(!(f[R+(P>>>5<<2)>>2]&1<<(P&31))){O=63;break b}}while(0);if(!V)xf(a,f[i>>2]|0,H,0,W);f[d>>2]=3;R=f[w>>2]|0;if((R|0)==(f[x>>2]|0))Ri(y,d);else{f[R>>2]=3;f[w>>2]=R+4}X=f[e>>2]|0}else{if(!L){xf(a,f[i>>2]|0,H,1,M);R=f[b>>2]|0;if((R|0)==-1){O=44;break}else Y=R}else Y=N;R=(((Y>>>0)%3|0|0)==0?2:-1)+Y|0;if((R|0)==-1){O=44;break}K=f[(f[(f[p>>2]|0)+12>>2]|0)+(R<<2)>>2]|0;if((K|0)==-1){O=44;break}R=(K>>>0)/3|0;if(f[(f[n>>2]|0)+(R>>>5<<2)>>2]&1<<(R&31)|0){O=44;break}f[d>>2]=5;R=f[w>>2]|0;if((R|0)==(f[x>>2]|0))Ri(y,d);else{f[R>>2]=5;f[w>>2]=R+4}X=U}f[b>>2]=X}if((E|0)>=(k|0))break a;D=E;F=f[n>>2]|0}do if((O|0)==35){O=0;f[e>>2]=-1;O=46}else if((O|0)==44){O=0;if(V)O=46;else{xf(a,f[i>>2]|0,H,0,W);O=46}}else if((O|0)==63){O=0;f[d>>2]=1;F=f[w>>2]|0;if((F|0)==(f[x>>2]|0))Ri(y,d);else{f[F>>2]=1;f[w>>2]=F+4}f[z>>2]=(f[z>>2]|0)+1;if(J?(F=f[(f[t>>2]|0)+(I<<2)>>2]|0,(1<<(F&31)&f[(f[A>>2]|0)+(F>>>5<<2)>>2]|0)==0):0){f[g>>2]=f[b>>2];f[d>>2]=f[g>>2];Pe(a,d,0)|0}F=f[i>>2]|0;f[d>>2]=H;D=je(B,d)|0;f[D>>2]=F;F=f[j>>2]|0;f[F+-4>>2]=U;if((F|0)==(f[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;z=Ef(g,j)|0;if(!z){B=f[j>>2]|0;A=B&255;C=B>>>8;D=C&255;E=B>>>16;F=E&255;G=B>>>24;H=G&255;J=C&255;C=E&255;E=(((B&255^318)+239^J)+239^C)+239^G;G=f[r>>2]|0;K=(G|0)==0;a:do if(!K){L=G+-1|0;M=(L&G|0)==0;if(!M)if(E>>>0>>0)N=E;else N=(E>>>0)%(G>>>0)|0;else N=E&L;O=f[(f[g>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(E|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}O=M+8|0;if((((b[O>>0]|0)==A<<24>>24?(b[O+1>>0]|0)==D<<24>>24:0)?(b[O+2>>0]|0)==F<<24>>24:0)?(b[O+3>>0]|0)==H<<24>>24:0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(E|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(G>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}M=S+8|0;if((((b[M>>0]|0)==A<<24>>24?(b[M+1>>0]|0)==D<<24>>24:0)?(b[M+2>>0]|0)==F<<24>>24:0)?(b[M+3>>0]|0)==H<<24>>24:0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;H=ln(16)|0;F=H+8|0;D=B&-16776961|C<<16|J<<8;b[F>>0]=D;b[F+1>>0]=D>>8;b[F+2>>0]=D>>16;b[F+3>>0]=D>>24;f[H+12>>2]=y;f[H+4>>2]=E;f[H>>2]=0;U=$(((f[o>>2]|0)+1|0)>>>0);V=$(G>>>0);X=$(n[l>>2]);do if(K|$(X*V)>>0<3|(G+-1&G|0)!=0)&1;F=~~$(W($(U/X)))>>>0;Zh(g,D>>>0>>0?F:D);D=f[r>>2]|0;F=D+-1|0;if(!(F&D)){Y=D;Z=F&E;break}if(E>>>0>>0){Y=D;Z=E}else{Y=D;Z=(E>>>0)%(D>>>0)|0}}else{Y=G;Z=Q}while(0);G=(f[g>>2]|0)+(Z<<2)|0;E=f[G>>2]|0;if(!E){f[H>>2]=f[t>>2];f[t>>2]=H;f[G>>2]=t;G=f[H>>2]|0;if(G|0){K=f[G+4>>2]|0;G=Y+-1|0;if(G&Y)if(K>>>0>>0)_=K;else _=(K>>>0)%(Y>>>0)|0;else _=K&G;aa=(f[g>>2]|0)+(_<<2)|0;R=44}}else{f[H>>2]=f[E>>2];aa=E;R=44}if((R|0)==44){R=0;f[aa>>2]=H}f[o>>2]=(f[o>>2]|0)+1}E=v;G=f[E>>2]|0;K=un(G|0,f[E+4>>2]|0,y|0,0)|0;kh((f[f[w>>2]>>2]|0)+K|0,i|0,G|0)|0;G=f[k>>2]|0;f[G+(x<<2)>>2]=y;ba=y+1|0;ca=G}else{G=f[k>>2]|0;f[G+(x<<2)>>2]=f[z+12>>2];ba=y;ca=G}x=x+1|0;da=f[m>>2]|0;if(x>>>0>=da>>>0)break;else y=ba}if((ba|0)==(da|0))ea=ca;else{y=a+84|0;if(!(b[y>>0]|0)){x=f[a+72>>2]|0;i=f[a+68>>2]|0;w=i;if((x|0)==(i|0))fa=ca;else{v=x-i>>2;i=0;do{x=w+(i<<2)|0;f[x>>2]=f[ca+(f[x>>2]<<2)>>2];i=i+1|0}while(i>>>0>>0);fa=ca}}else{b[y>>0]=0;y=a+68|0;ca=a+72|0;v=f[ca>>2]|0;i=f[y>>2]|0;w=v-i>>2;x=i;i=v;if(da>>>0<=w>>>0)if(da>>>0>>0?(v=x+(da<<2)|0,(v|0)!=(i|0)):0){f[ca>>2]=i+(~((i+-4-v|0)>>>2)<<2);ga=da}else ga=da;else{Ch(y,da-w|0,1220);ga=f[m>>2]|0}w=f[k>>2]|0;if(!ga)fa=w;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[w+(a<<2)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+16|0;do{b[B>>0]=b[C>>0]|0;B=B+1|0;C=C+1|0}while((B|0)<(E|0));im(i|0,D|0,16)|0;C=Vf(g,i)|0;if(!C){B=f[i>>2]|0;E=f[q>>2]|0;F=f[m>>2]|0;G=f[s>>2]|0;H=(((B^318)+239^E)+239^F)+239^G;J=f[t>>2]|0;K=(J|0)==0;a:do if(!K){L=J+-1|0;M=(L&J|0)==0;if(!M)if(H>>>0>>0)N=H;else N=(H>>>0)%(J>>>0)|0;else N=H&L;O=f[(f[g>>2]|0)+(N<<2)>>2]|0;if((O|0)!=0?(P=f[O>>2]|0,(P|0)!=0):0){if(M){M=P;while(1){O=f[M+4>>2]|0;if(!((O|0)==(H|0)|(O&L|0)==(N|0))){Q=N;R=31;break a}if((((f[M+8>>2]|0)==(B|0)?(f[M+12>>2]|0)==(E|0):0)?(f[M+16>>2]|0)==(F|0):0)?(f[M+20>>2]|0)==(G|0):0)break a;M=f[M>>2]|0;if(!M){Q=N;R=31;break a}}}else S=P;while(1){M=f[S+4>>2]|0;if((M|0)!=(H|0)){if(M>>>0>>0)T=M;else T=(M>>>0)%(J>>>0)|0;if((T|0)!=(N|0)){Q=N;R=31;break a}}if((((f[S+8>>2]|0)==(B|0)?(f[S+12>>2]|0)==(E|0):0)?(f[S+16>>2]|0)==(F|0):0)?(f[S+20>>2]|0)==(G|0):0)break a;S=f[S>>2]|0;if(!S){Q=N;R=31;break}}}else{Q=N;R=31}}else{Q=0;R=31}while(0);if((R|0)==31){R=0;D=ln(28)|0;f[D+8>>2]=B;f[D+12>>2]=E;f[D+16>>2]=F;f[D+20>>2]=G;f[D+24>>2]=z;f[D+4>>2]=H;f[D>>2]=0;U=$(((f[v>>2]|0)+1|0)>>>0);V=$(J>>>0);X=$(n[k>>2]);do if(K|$(X*V)>>0<3|(J+-1&J|0)!=0)&1;M=~~$(W($(U/X)))>>>0;Wh(g,P>>>0>>0?M:P);P=f[t>>2]|0;M=P+-1|0;if(!(M&P)){Y=P;Z=M&H;break}if(H>>>0

>>0){Y=P;Z=H}else{Y=P;Z=(H>>>0)%(P>>>0)|0}}else{Y=J;Z=Q}while(0);J=(f[g>>2]|0)+(Z<<2)|0;H=f[J>>2]|0;if(!H){f[D>>2]=f[w>>2];f[w>>2]=D;f[J>>2]=w;J=f[D>>2]|0;if(J|0){K=f[J+4>>2]|0;J=Y+-1|0;if(J&Y)if(K>>>0>>0)_=K;else _=(K>>>0)%(Y>>>0)|0;else _=K&J;aa=(f[g>>2]|0)+(_<<2)|0;R=44}}else{f[D>>2]=f[H>>2];aa=H;R=44}if((R|0)==44){R=0;f[aa>>2]=D}f[v>>2]=(f[v>>2]|0)+1}H=x;J=f[H>>2]|0;K=un(J|0,f[H+4>>2]|0,z|0,0)|0;kh((f[f[y>>2]>>2]|0)+K|0,h|0,J|0)|0;J=f[j>>2]|0;f[J+(A<<2)>>2]=z;ba=z+1|0;ca=J}else{J=f[j>>2]|0;f[J+(A<<2)>>2]=f[C+24>>2];ba=z;ca=J}A=A+1|0;da=f[l>>2]|0;if(A>>>0>=da>>>0)break;else z=ba}if((ba|0)==(da|0))ea=ca;else{z=a+84|0;if(!(b[z>>0]|0)){A=f[a+72>>2]|0;h=f[a+68>>2]|0;y=h;if((A|0)==(h|0))fa=ca;else{x=A-h>>2;h=0;do{A=y+(h<<2)|0;f[A>>2]=f[ca+(f[A>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);fa=ca}}else{b[z>>0]=0;z=a+68|0;ca=a+72|0;x=f[ca>>2]|0;h=f[z>>2]|0;y=x-h>>2;A=h;h=x;if(da>>>0<=y>>>0)if(da>>>0>>0?(x=A+(da<<2)|0,(x|0)!=(h|0)):0){f[ca>>2]=h+(~((h+-4-x|0)>>>2)<<2);ga=da}else ga=da;else{Ch(z,da-y|0,1220);ga=f[l>>2]|0}y=f[j>>2]|0;if(!ga)fa=y;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);fa=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|0;b[i+3>>0]=b[D+3>>0]|0;b[i+4>>0]=b[D+4>>0]|0;b[i+5>>0]=b[D+5>>0]|0;im(j|0,D|0,6)|0;D=dg(h,j)|0;if(!D){B=d[j>>1]|0;C=d[r>>1]|0;E=d[o>>1]|0;F=(((B^318)&65535)+239^C&65535)+239^E&65535;G=f[t>>2]|0;H=(G|0)==0;a:do if(!H){J=G+-1|0;K=(J&G|0)==0;if(!K)if(F>>>0>>0)L=F;else L=(F>>>0)%(G>>>0)|0;else L=F&J;M=f[(f[h>>2]|0)+(L<<2)>>2]|0;if((M|0)!=0?(N=f[M>>2]|0,(N|0)!=0):0){if(K){K=N;while(1){M=f[K+4>>2]|0;if(!((M|0)==(F|0)|(M&J|0)==(L|0))){O=L;P=29;break a}M=K+8|0;if(((d[M>>1]|0)==B<<16>>16?(d[M+2>>1]|0)==C<<16>>16:0)?(d[K+12>>1]|0)==E<<16>>16:0)break a;K=f[K>>2]|0;if(!K){O=L;P=29;break a}}}else Q=N;while(1){K=f[Q+4>>2]|0;if((K|0)!=(F|0)){if(K>>>0>>0)R=K;else R=(K>>>0)%(G>>>0)|0;if((R|0)!=(L|0)){O=L;P=29;break a}}K=Q+8|0;if(((d[K>>1]|0)==B<<16>>16?(d[K+2>>1]|0)==C<<16>>16:0)?(d[Q+12>>1]|0)==E<<16>>16:0)break a;Q=f[Q>>2]|0;if(!Q){O=L;P=29;break}}}else{O=L;P=29}}else{O=0;P=29}while(0);if((P|0)==29){P=0;N=ln(20)|0;d[N+8>>1]=B;d[N+10>>1]=C;d[N+12>>1]=E;f[N+16>>2]=z;f[N+4>>2]=F;f[N>>2]=0;S=$(((f[v>>2]|0)+1|0)>>>0);T=$(G>>>0);U=$(n[l>>2]);do if(H|$(U*T)>>0<3|(G+-1&G|0)!=0)&1;J=~~$(W($(S/U)))>>>0;Th(h,K>>>0>>0?J:K);K=f[t>>2]|0;J=K+-1|0;if(!(J&K)){V=K;X=J&F;break}if(F>>>0>>0){V=K;X=F}else{V=K;X=(F>>>0)%(K>>>0)|0}}else{V=G;X=O}while(0);G=(f[h>>2]|0)+(X<<2)|0;F=f[G>>2]|0;if(!F){f[N>>2]=f[w>>2];f[w>>2]=N;f[G>>2]=w;G=f[N>>2]|0;if(G|0){H=f[G+4>>2]|0;G=V+-1|0;if(G&V)if(H>>>0>>0)Y=H;else Y=(H>>>0)%(V>>>0)|0;else Y=H&G;Z=(f[h>>2]|0)+(Y<<2)|0;P=42}}else{f[N>>2]=f[F>>2];Z=F;P=42}if((P|0)==42){P=0;f[Z>>2]=N}f[v>>2]=(f[v>>2]|0)+1}F=x;G=f[F>>2]|0;H=un(G|0,f[F+4>>2]|0,z|0,0)|0;kh((f[f[y>>2]>>2]|0)+H|0,i|0,G|0)|0;G=f[k>>2]|0;f[G+(A<<2)>>2]=z;_=z+1|0;aa=G}else{G=f[k>>2]|0;f[G+(A<<2)>>2]=f[D+16>>2];_=z;aa=G}A=A+1|0;ba=f[m>>2]|0;if(A>>>0>=ba>>>0)break;else z=_}if((_|0)==(ba|0))ca=aa;else{z=a+84|0;if(!(b[z>>0]|0)){A=f[a+72>>2]|0;i=f[a+68>>2]|0;y=i;if((A|0)==(i|0))da=aa;else{x=A-i>>2;i=0;do{A=y+(i<<2)|0;f[A>>2]=f[aa+(f[A>>2]<<2)>>2];i=i+1|0}while(i>>>0>>0);da=aa}}else{b[z>>0]=0;z=a+68|0;aa=a+72|0;x=f[aa>>2]|0;i=f[z>>2]|0;y=x-i>>2;A=i;i=x;if(ba>>>0<=y>>>0)if(ba>>>0>>0?(x=A+(ba<<2)|0,(x|0)!=(i|0)):0){f[aa>>2]=i+(~((i+-4-x|0)>>>2)<<2);ea=ba}else ea=ba;else{Ch(z,ba-y|0,1220);ea=f[m>>2]|0}y=f[k>>2]|0;if(!ea)da=y;else{k=f[a+68>>2]|0;a=0;do{f[k+(a<<2)>>2]=f[y+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);da=y}}f[m>>2]=_;ca=da}if(!ca)fa=_;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?2:-1)+F|0;if((J|0)==-1)M=-1;else M=f[G+(J<<2)>>2]|0;J=f[H+(M<<2)>>2]|0;if((I|0)<(B|0)&(K|0)<(B|0)&(J|0)<(B|0)){H=X(I,e)|0;I=X(K,e)|0;K=X(J,e)|0;if(q){J=0;do{f[k+(J<<2)>>2]=(f[b+(J+K<<2)>>2]|0)+(f[b+(J+I<<2)>>2]|0)-(f[b+(J+H<<2)>>2]|0);J=J+1|0}while((J|0)!=(e|0));if(q){J=0;do{H=j+(J<<2)|0;f[H>>2]=(f[H>>2]|0)+(f[k+(J<<2)>>2]|0);J=J+1|0}while((J|0)!=(e|0))}}N=D+1|0}else N=D}else N=D;J=(((E>>>0)%3|0|0)==0?2:-1)+E|0;do if((J|0)!=-1?(H=f[p+(J<<2)>>2]|0,(H|0)!=-1):0)if(!((H>>>0)%3|0)){O=H+2|0;break}else{O=H+-1|0;break}else O=-1;while(0);E=(O|0)==(z|0)?-1:O;if((E|0)==-1)break;else D=N}D=X(B,e)|0;if(N){if(q){E=0;do{z=j+(E<<2)|0;f[z>>2]=(f[z>>2]|0)/(N|0)|0;E=E+1|0}while((E|0)!=(e|0))}E=b+(D<<2)|0;z=c+(D<<2)|0;p=f[g>>2]|0;if((p|0)>0){J=0;H=j;I=p;while(1){if((I|0)>0){p=0;do{K=f[H+(p<<2)>>2]|0;G=f[r>>2]|0;if((K|0)>(G|0)){F=f[s>>2]|0;f[F+(p<<2)>>2]=G;P=F}else{F=f[t>>2]|0;G=f[s>>2]|0;f[G+(p<<2)>>2]=(K|0)<(F|0)?F:K;P=G}p=p+1|0}while((p|0)<(f[g>>2]|0));Q=P}else Q=f[s>>2]|0;p=(f[E+(J<<2)>>2]|0)-(f[Q+(J<<2)>>2]|0)|0;G=z+(J<<2)|0;f[G>>2]=p;if((p|0)>=(f[u>>2]|0)){if((p|0)>(f[w>>2]|0)){R=p-(f[v>>2]|0)|0;S=57}}else{R=(f[v>>2]|0)+p|0;S=57}if((S|0)==57){S=0;f[G>>2]=R}J=J+1|0;I=f[g>>2]|0;if((J|0)>=(I|0))break;else H=Q}}}else{T=D;S=30}}else{T=X(B,e)|0;S=30}if((S|0)==30?(S=0,H=b+(T<<2)|0,I=c+(T<<2)|0,J=f[g>>2]|0,(J|0)>0):0){z=0;E=b+((X(A+-2|0,e)|0)<<2)|0;G=J;while(1){if((G|0)>0){J=0;do{p=f[E+(J<<2)>>2]|0;K=f[r>>2]|0;if((p|0)>(K|0)){F=f[s>>2]|0;f[F+(J<<2)>>2]=K;U=F}else{F=f[t>>2]|0;K=f[s>>2]|0;f[K+(J<<2)>>2]=(p|0)<(F|0)?F:p;U=K}J=J+1|0}while((J|0)<(f[g>>2]|0));V=U}else V=f[s>>2]|0;J=(f[H+(z<<2)>>2]|0)-(f[V+(z<<2)>>2]|0)|0;K=I+(z<<2)|0;f[K>>2]=J;if((J|0)>=(f[u>>2]|0)){if((J|0)>(f[w>>2]|0)){W=J-(f[v>>2]|0)|0;S=42}}else{W=(f[v>>2]|0)+J|0;S=42}if((S|0)==42){S=0;f[K>>2]=W}z=z+1|0;G=f[g>>2]|0;if((z|0)>=(G|0))break;else E=V}}if((A|0)<=2)break a;C=f[i>>2]|0;E=B+-1|0;if((f[l>>2]|0)-C>>2>>>0<=E>>>0)break;else{G=B;B=E;A=G}}aq(i)}while(0);if((e|0)>0)sj(j|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(k);Mq(j);return 1}i=a+16|0;A=a+32|0;B=a+12|0;C=a+28|0;l=a+20|0;V=a+24|0;a=0;W=j;U=e;while(1){if((U|0)>0){e=0;do{T=f[W+(e<<2)>>2]|0;Q=f[i>>2]|0;if((T|0)>(Q|0)){R=f[A>>2]|0;f[R+(e<<2)>>2]=Q;Y=R}else{R=f[B>>2]|0;Q=f[A>>2]|0;f[Q+(e<<2)>>2]=(T|0)<(R|0)?R:T;Y=Q}e=e+1|0}while((e|0)<(f[g>>2]|0));Z=Y}else Z=f[A>>2]|0;e=(f[b+(a<<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((((K>>>0)%3|0|0)==0?G+-2|0:K)<<2)>>2]<<2)>>2]|0,K=f[I+(f[H+((((G>>>0)%3|0|0)==0?2:-1)+G<<2)>>2]<<2)>>2]|0,(J|0)<(C|0)&(L|0)<(C|0)&(K|0)<(C|0)):0){G=X(J,e)|0;J=X(L,e)|0;L=X(K,e)|0;if(q){K=0;do{f[k+(K<<2)>>2]=(f[b+(K+L<<2)>>2]|0)+(f[b+(K+J<<2)>>2]|0)-(f[b+(K+G<<2)>>2]|0);K=K+1|0}while((K|0)!=(e|0));if(q){K=0;do{G=j+(K<<2)|0;f[G>>2]=(f[G>>2]|0)+(f[k+(K<<2)>>2]|0);K=K+1|0}while((K|0)!=(e|0))}}M=E+1|0}else M=E;K=(((F>>>0)%3|0|0)==0?2:-1)+F|0;do if(((K|0)!=-1?(f[p+(K>>>5<<2)>>2]&1<<(K&31)|0)==0:0)?(G=f[(f[(f[x>>2]|0)+12>>2]|0)+(K<<2)>>2]|0,(G|0)!=-1):0)if(!((G>>>0)%3|0)){N=G+2|0;break}else{N=G+-1|0;break}else N=-1;while(0);F=(N|0)==(A|0)?-1:N;if((F|0)==-1)break;else E=M}E=X(C,e)|0;if(M){if(q){F=0;do{A=j+(F<<2)|0;f[A>>2]=(f[A>>2]|0)/(M|0)|0;F=F+1|0}while((F|0)!=(e|0))}F=b+(E<<2)|0;A=c+(E<<2)|0;p=f[g>>2]|0;if((p|0)>0){K=0;G=j;J=p;while(1){if((J|0)>0){p=0;do{L=f[G+(p<<2)>>2]|0;H=f[r>>2]|0;if((L|0)>(H|0)){I=f[s>>2]|0;f[I+(p<<2)>>2]=H;O=I}else{I=f[t>>2]|0;H=f[s>>2]|0;f[H+(p<<2)>>2]=(L|0)<(I|0)?I:L;O=H}p=p+1|0}while((p|0)<(f[g>>2]|0));P=O}else P=f[s>>2]|0;p=(f[F+(K<<2)>>2]|0)-(f[P+(K<<2)>>2]|0)|0;H=A+(K<<2)|0;f[H>>2]=p;if((p|0)>=(f[u>>2]|0)){if((p|0)>(f[w>>2]|0)){Q=p-(f[v>>2]|0)|0;R=55}}else{Q=(f[v>>2]|0)+p|0;R=55}if((R|0)==55){R=0;f[H>>2]=Q}K=K+1|0;J=f[g>>2]|0;if((K|0)>=(J|0))break;else G=P}}}else{S=E;R=28}}else{S=X(C,e)|0;R=28}if((R|0)==28?(R=0,G=b+(S<<2)|0,J=c+(S<<2)|0,K=f[g>>2]|0,(K|0)>0):0){A=0;F=b+((X(B+-2|0,e)|0)<<2)|0;H=K;while(1){if((H|0)>0){K=0;do{p=f[F+(K<<2)>>2]|0;L=f[r>>2]|0;if((p|0)>(L|0)){I=f[s>>2]|0;f[I+(K<<2)>>2]=L;T=I}else{I=f[t>>2]|0;L=f[s>>2]|0;f[L+(K<<2)>>2]=(p|0)<(I|0)?I:p;T=L}K=K+1|0}while((K|0)<(f[g>>2]|0));U=T}else U=f[s>>2]|0;K=(f[G+(A<<2)>>2]|0)-(f[U+(A<<2)>>2]|0)|0;L=J+(A<<2)|0;f[L>>2]=K;if((K|0)>=(f[u>>2]|0)){if((K|0)>(f[w>>2]|0)){V=K-(f[v>>2]|0)|0;R=40}}else{V=(f[v>>2]|0)+K|0;R=40}if((R|0)==40){R=0;f[L>>2]=V}A=A+1|0;H=f[g>>2]|0;if((A|0)>=(H|0))break;else F=U}}if((B|0)<=2)break a;D=f[i>>2]|0;F=C+-1|0;if((f[l>>2]|0)-D>>2>>>0<=F>>>0)break;else{H=C;C=F;B=H}}aq(i)}while(0);if((e|0)>0)sj(j|0,0,e<<2|0)|0;e=f[g>>2]|0;if((e|0)<=0){Mq(k);Mq(j);return 1}i=a+16|0;B=a+32|0;C=a+12|0;D=a+28|0;l=a+20|0;U=a+24|0;a=0;V=j;T=e;while(1){if((T|0)>0){e=0;do{S=f[V+(e<<2)>>2]|0;P=f[i>>2]|0;if((S|0)>(P|0)){Q=f[B>>2]|0;f[Q+(e<<2)>>2]=P;W=Q}else{Q=f[C>>2]|0;P=f[B>>2]|0;f[P+(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1)-Y|0;break}if(q&(T|0)>(Y|0)){$=Z;aa=(T<<1)-Y|0;break}if(H&(T|0)>(Z|0)){$=(T<<1)-Z|0;aa=Y;break}if(P){$=(T|0)<(Z|0)?(T<<1)-Z|0:Z;aa=0}else{$=Z;aa=Y}}else{$=Z;aa=Z}}else{$=Y;aa=Y}}else{$=N;aa=N}while(0);P=0-S|0;M=0-_|0;f[j>>2]=0-O;f[r>>2]=P;f[t>>2]=M;if((O|0)<1){ba=T-_|0;ca=T-S|0}else{H=(_|0)<1?M:_;M=(S|0)<1?P:S;ba=(_|0)>0?M:N-M|0;ca=(S|0)>0?H:N-H|0}H=(ca|0)==0;M=(ba|0)==0;do if(((ba|ca|0)!=0?(P=(N|0)==(ba|0),!(H&P)):0)?(q=(N|0)==(ca|0),!(M&q)):0){if(H&(T|0)<(ba|0)){da=0;ea=(T<<1)-ba|0;break}if(q&(T|0)>(ba|0)){da=N;ea=(T<<1)-ba|0;break}if(P&(T|0)>(ca|0)){da=(T<<1)-ca|0;ea=N;break}if(M){da=(T|0)<(ca|0)?(T<<1)-ca|0:ca;ea=0}else{da=ca;ea=ba}}else{da=N;ea=N}while(0);N=K<<1;M=b+(N<<2)|0;H=M+4|0;O=f[H>>2]|0;f[h>>2]=f[M>>2];f[x>>2]=O;f[i>>2]=$;f[y>>2]=aa;Od(d,n,h,i);O=f[d>>2]|0;f[k>>2]=O;P=f[z>>2]|0;f[A>>2]=P;q=f[H>>2]|0;f[h>>2]=f[M>>2];f[B>>2]=q;f[i>>2]=da;f[C>>2]=ea;Od(d,n,h,i);q=f[d>>2]|0;f[l>>2]=q;M=f[D>>2]|0;f[E>>2]=M;H=f[v>>2]|0;if((H|0)>=(O|0))if((O|0)<(0-H|0))fa=(f[F>>2]|0)+O|0;else fa=O;else fa=O-(f[F>>2]|0)|0;f[k>>2]=fa;if((H|0)>=(P|0))if((P|0)<(0-H|0))ga=(f[F>>2]|0)+P|0;else ga=P;else ga=P-(f[F>>2]|0)|0;f[a>>2]=ga;if((H|0)>=(q|0))if((q|0)<(0-H|0))ha=(f[F>>2]|0)+q|0;else ha=q;else ha=q-(f[F>>2]|0)|0;f[l>>2]=ha;if((H|0)>=(M|0))if((M|0)<(0-H|0))ia=(f[F>>2]|0)+M|0;else ia=M;else ia=M-(f[F>>2]|0)|0;f[G>>2]=ia;if((((ga|0)>-1?ga:0-ga|0)+((fa|0)>-1?fa:0-fa|0)|0)<(((ha|0)>-1?ha:0-ha|0)+((ia|0)>-1?ia:0-ia|0)|0)){fj(g,0);ja=k}else{fj(g,1);ja=l}M=f[ja>>2]|0;if((M|0)<0)ka=(f[F>>2]|0)+M|0;else ka=M;M=c+(N<<2)|0;f[M>>2]=ka;N=f[ja+4>>2]|0;if((N|0)<0)la=(f[F>>2]|0)+N|0;else la=N;f[M+4>>2]=la;K=K+1|0;if((K|0)>=(s|0)){ma=5;break}M=f[p>>2]|0;L=f[M>>2]|0;if((f[M+4>>2]|0)-L>>2>>>0<=K>>>0){J=M;ma=6;break}}if((ma|0)==5){u=e;return 1}else if((ma|0)==6)aq(J);return 0}function rc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0;c=u;u=u+48|0;d=c+24|0;e=c+12|0;g=c;if(!b){h=0;u=c;return h|0}i=a+12|0;j=a+4|0;k=f[j>>2]|0;l=f[a>>2]|0;m=k-l>>2;n=a+16|0;o=f[n>>2]|0;p=f[i>>2]|0;q=o-p>>2;r=p;p=o;if(m>>>0<=q>>>0)if(m>>>0>>0?(o=r+(m<<2)|0,(o|0)!=(p|0)):0){f[n>>2]=p+(~((p+-4-o|0)>>>2)<<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K=0;L=0}while(0);if((t|0)!=(y|0)){y=0;t=0;while(1){f[J+(t<<2)>>2]=y;k=t+1|0;if(k>>>0>>0){y=(f[s+(t<<2)>>2]|0)+y|0;t=k}else break}}t=f[j>>2]|0;j=f[a>>2]|0;y=j;if((t|0)!=(j|0)){k=a+40|0;a=t-j>>2;j=H;t=H;g=H;A=H;p=H;x=H;l=0;o=J;while(1){F=f[y+(l<<2)>>2]|0;G=l+1|0;E=((G>>>0)%3|0|0)==0?l+-2|0:G;if((E|0)==-1)M=-1;else M=f[y+(E<<2)>>2]|0;E=((l>>>0)%3|0|0)==0;G=(E?2:-1)+l|0;if((G|0)==-1)N=-1;else N=f[y+(G<<2)>>2]|0;if(E?(M|0)==(N|0)|((F|0)==(M|0)|(F|0)==(N|0)):0){f[k>>2]=(f[k>>2]|0)+1;O=j;P=t;Q=g;R=A;S=p;T=x;U=l+2|0;V=o}else W=51;a:do if((W|0)==51){W=0;E=f[s+(N<<2)>>2]|0;b:do if((E|0)>0){G=0;B=f[o+(N<<2)>>2]|0;while(1){m=f[p+(B<<3)>>2]|0;if((m|0)==-1){X=j;Y=t;Z=A;_=p;break b}if((m|0)==(M|0)){m=f[p+(B<<3)+4>>2]|0;if((m|0)==-1)$=-1;else $=f[y+(m<<2)>>2]|0;if((F|0)!=($|0))break}m=G+1|0;if((m|0)<(E|0)){G=m;B=B+1|0}else{X=j;Y=t;Z=A;_=p;break b}}m=f[A+(B<<3)+4>>2]|0;r=G;n=B;D=t;while(1){r=r+1|0;if((r|0)>=(E|0))break;C=n+1|0;f[D+(n<<3)>>2]=f[D+(C<<3)>>2];f[D+(n<<3)+4>>2]=f[D+(C<<3)+4>>2];if((f[j+(n<<3)>>2]|0)==-1)break;else{n=C;D=j}}f[g+(n<<3)>>2]=-1;if((m|0)==-1){X=g;Y=g;Z=g;_=g}else{D=f[i>>2]|0;f[D+(l<<2)>>2]=m;f[D+(m<<2)>>2]=l;O=g;P=g;Q=g;R=g;S=g;T=x;U=l;V=o;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(m){if(m>>>0>1073741823)aq(j);p=m<<2;q=ln(p)|0;f[j>>2]=q;r=q+(m<<2)|0;f[j+8>>2]=r;sj(q|0,0,p|0)|0;f[o>>2]=r;r=f[d>>2]|0;d=c+48|0;p=c+40|0;q=i+1|0;m=i+2|0;s=g+4|0;t=g+12|0;v=g+8|0;w=a+40|0;x=a+64|0;y=0;z=0;while(1){A=d;B=f[A>>2]|0;C=f[A+4>>2]|0;A=p;D=un(f[A>>2]|0,f[A+4>>2]|0,r+y|0,0)|0;A=Vn(D|0,I|0,B|0,C|0)|0;C=(f[f[c>>2]>>2]|0)+A|0;b[h>>0]=b[C>>0]|0;b[h+1>>0]=b[C+1>>0]|0;b[h+2>>0]=b[C+2>>0]|0;im(i|0,C|0,3)|0;C=jg(g,i)|0;if(!C){A=b[i>>0]|0;B=b[q>>0]|0;D=b[m>>0]|0;E=((A&255^318)+239^B&255)+239^D&255;F=f[s>>2]|0;G=(F|0)==0;a:do if(!G){H=F+-1|0;J=(H&F|0)==0;if(!J)if(E>>>0>>0)K=E;else K=(E>>>0)%(F>>>0)|0;else K=E&H;L=f[(f[g>>2]|0)+(K<<2)>>2]|0;if((L|0)!=0?(M=f[L>>2]|0,(M|0)!=0):0){if(J){J=M;while(1){L=f[J+4>>2]|0;if(!((L|0)==(E|0)|(L&H|0)==(K|0))){N=K;O=29;break a}L=J+8|0;if(((b[L>>0]|0)==A<<24>>24?(b[L+1>>0]|0)==B<<24>>24:0)?(b[L+2>>0]|0)==D<<24>>24:0)break a;J=f[J>>2]|0;if(!J){N=K;O=29;break a}}}else P=M;while(1){J=f[P+4>>2]|0;if((J|0)!=(E|0)){if(J>>>0>>0)Q=J;else Q=(J>>>0)%(F>>>0)|0;if((Q|0)!=(K|0)){N=K;O=29;break a}}J=P+8|0;if(((b[J>>0]|0)==A<<24>>24?(b[J+1>>0]|0)==B<<24>>24:0)?(b[J+2>>0]|0)==D<<24>>24:0)break a;P=f[P>>2]|0;if(!P){N=K;O=29;break}}}else{N=K;O=29}}else{N=0;O=29}while(0);if((O|0)==29){O=0;M=ln(16)|0;b[M+8>>0]=A;b[M+9>>0]=B;b[M+10>>0]=D;f[M+12>>2]=z;f[M+4>>2]=E;f[M>>2]=0;R=$(((f[t>>2]|0)+1|0)>>>0);S=$(F>>>0);T=$(n[k>>2]);do if(G|$(T*S)>>0<3|(F+-1&F|0)!=0)&1;H=~~$(W($(R/T)))>>>0;_h(g,J>>>0>>0?H:J);J=f[s>>2]|0;H=J+-1|0;if(!(H&J)){U=J;V=H&E;break}if(E>>>0>>0){U=J;V=E}else{U=J;V=(E>>>0)%(J>>>0)|0}}else{U=F;V=N}while(0);F=(f[g>>2]|0)+(V<<2)|0;E=f[F>>2]|0;if(!E){f[M>>2]=f[v>>2];f[v>>2]=M;f[F>>2]=v;F=f[M>>2]|0;if(F|0){G=f[F+4>>2]|0;F=U+-1|0;if(F&U)if(G>>>0>>0)X=G;else X=(G>>>0)%(U>>>0)|0;else X=G&F;Y=(f[g>>2]|0)+(X<<2)|0;O=42}}else{f[M>>2]=f[E>>2];Y=E;O=42}if((O|0)==42){O=0;f[Y>>2]=M}f[t>>2]=(f[t>>2]|0)+1}E=w;F=f[E>>2]|0;G=un(F|0,f[E+4>>2]|0,z|0,0)|0;kh((f[f[x>>2]>>2]|0)+G|0,h|0,F|0)|0;F=f[j>>2]|0;f[F+(y<<2)>>2]=z;Z=z+1|0;_=F}else{F=f[j>>2]|0;f[F+(y<<2)>>2]=f[C+12>>2];Z=z;_=F}y=y+1|0;aa=f[l>>2]|0;if(y>>>0>=aa>>>0)break;else z=Z}if((Z|0)==(aa|0))ba=_;else{z=a+84|0;if(!(b[z>>0]|0)){y=f[a+72>>2]|0;h=f[a+68>>2]|0;x=h;if((y|0)==(h|0))ca=_;else{w=y-h>>2;h=0;do{y=x+(h<<2)|0;f[y>>2]=f[_+(f[y>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);ca=_}}else{b[z>>0]=0;z=a+68|0;_=a+72|0;w=f[_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>>2]|0;f[E>>2]=M;H=f[v>>2]|0;if((H|0)>=(O|0))if((O|0)<(0-H|0))fa=(f[F>>2]|0)+O|0;else fa=O;else fa=O-(f[F>>2]|0)|0;f[k>>2]=fa;if((H|0)>=(P|0))if((P|0)<(0-H|0))ga=(f[F>>2]|0)+P|0;else ga=P;else ga=P-(f[F>>2]|0)|0;f[a>>2]=ga;if((H|0)>=(q|0))if((q|0)<(0-H|0))ha=(f[F>>2]|0)+q|0;else ha=q;else ha=q-(f[F>>2]|0)|0;f[l>>2]=ha;if((H|0)>=(M|0))if((M|0)<(0-H|0))ia=(f[F>>2]|0)+M|0;else ia=M;else ia=M-(f[F>>2]|0)|0;f[G>>2]=ia;if((((ga|0)>-1?ga:0-ga|0)+((fa|0)>-1?fa:0-fa|0)|0)<(((ha|0)>-1?ha:0-ha|0)+((ia|0)>-1?ia:0-ia|0)|0)){fj(g,0);ja=k}else{fj(g,1);ja=l}M=f[ja>>2]|0;if((M|0)<0)ka=(f[F>>2]|0)+M|0;else ka=M;M=c+(N<<2)|0;f[M>>2]=ka;N=f[ja+4>>2]|0;if((N|0)<0)la=(f[F>>2]|0)+N|0;else la=N;f[M+4>>2]=la;K=K+1|0;if((K|0)>=(s|0)){ma=5;break}M=f[p>>2]|0;L=f[M>>2]|0;if((f[M+4>>2]|0)-L>>2>>>0<=K>>>0){J=M;ma=6;break}}if((ma|0)==5){u=e;return 1}else if((ma|0)==6)aq(J);return 0}function uc(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=Oa,T=Oa,U=Oa,V=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0;e=u;u=u+64|0;g=e+36|0;h=e+24|0;i=e+12|0;j=e;k=g+16|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;f[g+12>>2]=0;n[k>>2]=$(1.0);l=a+80|0;m=f[l>>2]|0;f[j>>2]=0;o=j+4|0;f[o>>2]=0;f[j+8>>2]=0;if(m){if(m>>>0>1073741823)aq(j);p=m<<2;q=ln(p)|0;f[j>>2]=q;r=q+(m<<2)|0;f[j+8>>2]=r;sj(q|0,0,p|0)|0;f[o>>2]=r;r=f[d>>2]|0;d=c+48|0;p=c+40|0;q=i+4|0;m=i+8|0;s=g+4|0;t=g+12|0;v=g+8|0;w=a+40|0;x=a+64|0;y=0;z=0;while(1){A=d;B=f[A>>2]|0;C=f[A+4>>2]|0;A=p;D=un(f[A>>2]|0,f[A+4>>2]|0,r+z|0,0)|0;A=Vn(D|0,I|0,B|0,C|0)|0;C=(f[f[c>>2]>>2]|0)+A|0;A=h;B=C;D=A+12|0;do{b[A>>0]=b[B>>0]|0;A=A+1|0;B=B+1|0}while((A|0)<(D|0));im(i|0,C|0,12)|0;B=qg(g,i)|0;if(!B){A=f[i>>2]|0;D=f[q>>2]|0;E=f[m>>2]|0;F=((A^318)+239^D)+239^E;G=f[s>>2]|0;H=(G|0)==0;a:do if(!H){J=G+-1|0;K=(J&G|0)==0;if(!K)if(F>>>0>>0)L=F;else L=(F>>>0)%(G>>>0)|0;else L=F&J;M=f[(f[g>>2]|0)+(L<<2)>>2]|0;if((M|0)!=0?(N=f[M>>2]|0,(N|0)!=0):0){if(K){K=N;while(1){M=f[K+4>>2]|0;if(!((M|0)==(F|0)|(M&J|0)==(L|0))){O=L;P=29;break a}if(((f[K+8>>2]|0)==(A|0)?(f[K+12>>2]|0)==(D|0):0)?(f[K+16>>2]|0)==(E|0):0)break a;K=f[K>>2]|0;if(!K){O=L;P=29;break a}}}else Q=N;while(1){K=f[Q+4>>2]|0;if((K|0)!=(F|0)){if(K>>>0>>0)R=K;else R=(K>>>0)%(G>>>0)|0;if((R|0)!=(L|0)){O=L;P=29;break a}}if(((f[Q+8>>2]|0)==(A|0)?(f[Q+12>>2]|0)==(D|0):0)?(f[Q+16>>2]|0)==(E|0):0)break a;Q=f[Q>>2]|0;if(!Q){O=L;P=29;break}}}else{O=L;P=29}}else{O=0;P=29}while(0);if((P|0)==29){P=0;C=ln(24)|0;f[C+8>>2]=A;f[C+12>>2]=D;f[C+16>>2]=E;f[C+20>>2]=y;f[C+4>>2]=F;f[C>>2]=0;S=$(((f[t>>2]|0)+1|0)>>>0);T=$(G>>>0);U=$(n[k>>2]);do if(H|$(U*T)>>0<3|(G+-1&G|0)!=0)&1;K=~~$(W($(S/U)))>>>0;Xh(g,N>>>0>>0?K:N);N=f[s>>2]|0;K=N+-1|0;if(!(K&N)){V=N;X=K&F;break}if(F>>>0>>0){V=N;X=F}else{V=N;X=(F>>>0)%(N>>>0)|0}}else{V=G;X=O}while(0);G=(f[g>>2]|0)+(X<<2)|0;F=f[G>>2]|0;if(!F){f[C>>2]=f[v>>2];f[v>>2]=C;f[G>>2]=v;G=f[C>>2]|0;if(G|0){H=f[G+4>>2]|0;G=V+-1|0;if(G&V)if(H>>>0>>0)Y=H;else Y=(H>>>0)%(V>>>0)|0;else Y=H&G;Z=(f[g>>2]|0)+(Y<<2)|0;P=42}}else{f[C>>2]=f[F>>2];Z=F;P=42}if((P|0)==42){P=0;f[Z>>2]=C}f[t>>2]=(f[t>>2]|0)+1}F=w;G=f[F>>2]|0;H=un(G|0,f[F+4>>2]|0,y|0,0)|0;kh((f[f[x>>2]>>2]|0)+H|0,h|0,G|0)|0;G=f[j>>2]|0;f[G+(z<<2)>>2]=y;_=y+1|0;aa=G}else{G=f[j>>2]|0;f[G+(z<<2)>>2]=f[B+20>>2];_=y;aa=G}z=z+1|0;ba=f[l>>2]|0;if(z>>>0>=ba>>>0)break;else y=_}if((_|0)==(ba|0))ca=aa;else{y=a+84|0;if(!(b[y>>0]|0)){z=f[a+72>>2]|0;h=f[a+68>>2]|0;x=h;if((z|0)==(h|0))da=aa;else{w=z-h>>2;h=0;do{z=x+(h<<2)|0;f[z>>2]=f[aa+(f[z>>2]<<2)>>2];h=h+1|0}while(h>>>0>>0);da=aa}}else{b[y>>0]=0;y=a+68|0;aa=a+72|0;w=f[aa>>2]|0;h=f[y>>2]|0;x=w-h>>2;z=h;h=w;if(ba>>>0<=x>>>0)if(ba>>>0>>0?(w=z+(ba<<2)|0,(w|0)!=(h|0)):0){f[aa>>2]=h+(~((h+-4-w|0)>>>2)<<2);ea=ba}else ea=ba;else{Ch(y,ba-x|0,1220);ea=f[l>>2]|0}x=f[j>>2]|0;if(!ea)da=x;else{j=f[a+68>>2]|0;a=0;do{f[j+(a<<2)>>2]=f[x+(a<<2)>>2];a=a+1|0}while(a>>>0>>0);da=x}}f[l>>2]=_;ca=da}if(!ca)fa=_;else{da=f[o>>2]|0;if((da|0)!=(ca|0))f[o>>2]=da+(~((da+-4-ca|0)>>>2)<<2);Oq(ca);fa=_}}else fa=0;_=f[g+8>>2]|0;if(_|0){ca=_;do{_=ca;ca=f[ca>>2]|0;Oq(_)}while((ca|0)!=0)}ca=f[g>>2]|0;f[g>>2]=0;if(!ca){u=e;return fa|0}Oq(ca);u=e;return fa|0} +function di(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;Je(e,a+40|0,f[a+8>>2]|0,b,c);gj(a,e);a=f[e>>2]|0;f[e>>2]=0;if(!a){u=d;return 1}e=a+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){b=c+12|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(c)}c=f[a+68>>2]|0;if(c|0){e=a+72|0;b=f[e>>2]|0;if((b|0)!=(c|0))f[e>>2]=b+(~((b+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0){c=f[b>>2]|0;if(c|0){e=b+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(b)}Oq(a);u=d;return 1}function ei(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Bd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Bd(a,e);return}function fi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0;e=u;u=u+48|0;g=e;h=e+32|0;if(!c){i=0;u=e;return i|0}Gn(g);if((dm(c,0)|0)!=-1?Qa[f[(f[c>>2]|0)+16>>2]&127](c)|0:0){Va[f[(f[c>>2]|0)+20>>2]&127](c);ch(h,a,c,g);c=(f[h>>2]|0)==0;a=h+4|0;if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);if(c){c=f[g>>2]|0;a=g+4|0;rg(d,c,c+((f[a>>2]|0)-c)|0);j=(f[a>>2]|0)-(f[g>>2]|0)|0}else j=0}else j=0;a=g+12|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0)Oq(c);c=f[g>>2]|0;if(c|0){a=g+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;Oq(c)}i=j;u=e;return i|0}function gi(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;Fe(e,a+40|0,f[a+8>>2]|0,b,c);gj(a,e);a=f[e>>2]|0;f[e>>2]=0;if(!a){u=d;return 1}e=a+88|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0){e=f[c+8>>2]|0;if(e|0){b=c+12|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e)}Oq(c)}c=f[a+68>>2]|0;if(c|0){e=a+72|0;b=f[e>>2]|0;if((b|0)!=(c|0))f[e>>2]=b+(~((b+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;b=f[c>>2]|0;f[c>>2]=0;if(b|0){c=f[b>>2]|0;if(c|0){e=b+4|0;if((f[e>>2]|0)!=(c|0))f[e>>2]=c;Oq(c)}Oq(b)}Oq(a);u=d;return 1}function hi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{d=g+-4|0;f[c>>2]=d;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=h+88|0;i=f[d>>2]|0;f[d>>2]=0;if(i|0){d=f[i+8>>2]|0;if(d|0){j=i+12|0;if((f[j>>2]|0)!=(d|0))f[j>>2]=d;Oq(d)}Oq(i)}i=f[h+68>>2]|0;if(i|0){d=h+72|0;j=f[d>>2]|0;if((j|0)!=(i|0))f[d>>2]=j+(~((j+-4-i|0)>>>2)<<2);Oq(i)}i=h+64|0;j=f[i>>2]|0;f[i>>2]=0;if(j|0){i=f[j>>2]|0;if(i|0){d=j+4|0;if((f[d>>2]|0)!=(i|0))f[d>>2]=i;Oq(i)}Oq(j)}Oq(h)}g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}Oq(e);return}function ii(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;if(!(Ie(a,c)|0)){i=0;u=d;return i|0}j=a+36|0;k=a+40|0;a=f[j>>2]|0;if((f[k>>2]|0)==(a|0)){i=1;u=d;return i|0}l=c+16|0;m=c+4|0;n=h+1|0;o=0;p=a;do{a=f[p+(o<<2)>>2]|0;q=Qa[f[(f[a>>2]|0)+32>>2]&127](a)|0;b[h>>0]=q;q=l;a=f[q+4>>2]|0;if(!((a|0)>0|(a|0)==0&(f[q>>2]|0)>>>0>0)){f[g>>2]=f[m>>2];f[e>>2]=f[g>>2];Me(c,e,h,n)|0}o=o+1|0;p=f[j>>2]|0}while(o>>>0<(f[k>>2]|0)-p>>2>>>0);i=1;u=d;return i|0}function ji(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=u;u=u+16|0;d=c;lp(a);f[a+16>>2]=0;f[a+20>>2]=0;f[a+12>>2]=a+16;e=a+24|0;lp(e);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;a=ln(32)|0;f[d>>2]=a;f[d+8>>2]=-2147483616;f[d+4>>2]=20;g=a;h=14538;i=g+20|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[a+20>>0]=0;Vj(e,d,1);if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;a=ln(32)|0;f[d>>2]=a;f[d+8>>2]=-2147483616;f[d+4>>2]=22;g=a;h=14559;i=g+22|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[a+22>>0]=0;Vj(e,d,1);if((b[d+11>>0]|0)>=0){u=c;return}Oq(f[d>>2]|0);u=c;return}function ki(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a+4>>2]|0;c=a+8|0;d=f[c>>2]|0;if((d|0)!=(b|0)){e=d;do{d=e+-4|0;f[c>>2]=d;g=f[d>>2]|0;f[d>>2]=0;if(g|0){d=g+88|0;h=f[d>>2]|0;f[d>>2]=0;if(h|0){d=f[h+8>>2]|0;if(d|0){i=h+12|0;if((f[i>>2]|0)!=(d|0))f[i>>2]=d;Oq(d)}Oq(h)}h=f[g+68>>2]|0;if(h|0){d=g+72|0;i=f[d>>2]|0;if((i|0)!=(h|0))f[d>>2]=i+(~((i+-4-h|0)>>>2)<<2);Oq(h)}h=g+64|0;i=f[h>>2]|0;f[h>>2]=0;if(i|0){h=f[i>>2]|0;if(h|0){d=i+4|0;if((f[d>>2]|0)!=(h|0))f[d>>2]=h;Oq(h)}Oq(i)}Oq(g)}e=f[c>>2]|0}while((e|0)!=(b|0))}b=f[a>>2]|0;if(!b)return;Oq(b);return}function li(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+20>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function mi(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=u;u=u+16|0;d=c;e=ln(16)|0;f[d>>2]=e;f[d+8>>2]=-2147483632;f[d+4>>2]=14;g=e;h=14408;i=g+14|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[e+14>>0]=0;e=Hk(a,d,-1)|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);j=ln(16)|0;f[d>>2]=j;f[d+8>>2]=-2147483632;f[d+4>>2]=14;g=j;h=14423;i=g+14|0;do{b[g>>0]=b[h>>0]|0;g=g+1|0;h=h+1|0}while((g|0)<(i|0));b[j+14>>0]=0;j=Hk(a,d,-1)|0;if((b[d+11>>0]|0)>=0){k=(e|0)<(j|0);l=k?j:e;m=(l|0)==-1;n=m?5:l;u=c;return n|0}Oq(f[d>>2]|0);k=(e|0)<(j|0);l=k?j:e;m=(l|0)==-1;n=m?5:l;u=c;return n|0}function ni(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c+8|0;e=c+4|0;g=c;f[g>>2]=f[a+12>>2];h=b+16|0;i=h;j=f[i>>2]|0;k=f[i+4>>2]|0;if((k|0)>0|(k|0)==0&j>>>0>0){l=k;m=j}else{f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;j=h;l=f[j+4>>2]|0;m=f[j>>2]|0}f[g>>2]=f[a+16>>2];if((l|0)>0|(l|0)==0&m>>>0>0){u=c;return 1}f[e>>2]=f[b+4>>2];f[d>>2]=f[e>>2];Me(b,d,g,g+4|0)|0;u=c;return 1}function oi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=ln(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;h=g+8|0;f[h>>2]=f[e>>2];f[h+4>>2]=f[e+4>>2];f[h+8>>2]=f[e+8>>2];f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{Fi(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}kh(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function pi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0;b=a+32|0;ld(a,b);c=a+80|0;d=f[c>>2]|0;if((d|0?(e=a+84|0,(f[e>>2]|0)>0):0)?(ld(d,b),(f[e>>2]|0)>1):0){d=1;do{ld((f[c>>2]|0)+(d<<5)|0,b);d=d+1|0}while((d|0)<(f[e>>2]|0))}e=a+136|0;d=a+140|0;a=f[e>>2]|0;if((f[d>>2]|0)==(a|0))return;c=0;g=a;while(1){a=g;ci((f[a+(c*12|0)+4>>2]|0)-(f[a+(c*12|0)>>2]|0)>>2,b)|0;a=f[e>>2]|0;h=f[a+(c*12|0)>>2]|0;i=(f[a+(c*12|0)+4>>2]|0)-h>>2;if(!i)j=a;else{Mc(h,i,1,0,b)|0;j=f[e>>2]|0}c=c+1|0;if(c>>>0>=(((f[d>>2]|0)-j|0)/12|0)>>>0)break;else g=j}return}function qi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;e=d+16|0;g=f[e>>2]|0;if(!g)if(!(vl(d)|0)){h=f[e>>2]|0;i=5}else j=0;else{h=g;i=5}a:do if((i|0)==5){g=d+20|0;e=f[g>>2]|0;k=e;if((h-e|0)>>>0>>0){j=Sa[f[d+36>>2]&31](d,a,c)|0;break}b:do if((b[d+75>>0]|0)>-1){e=c;while(1){if(!e){l=0;m=a;n=c;o=k;break b}p=e+-1|0;if((b[a+p>>0]|0)==10)break;else e=p}p=Sa[f[d+36>>2]&31](d,a,e)|0;if(p>>>0>>0){j=p;break a}l=e;m=a+e|0;n=c-e|0;o=f[g>>2]|0}else{l=0;m=a;n=c;o=k}while(0);kh(o|0,m|0,n|0)|0;f[g>>2]=(f[g>>2]|0)+n;j=l+n|0}while(0);return j|0}function ri(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+12|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d+28>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;ri(c+8|0);Oq(c)}while((e|0)!=0)}e=d+20|0;c=f[e>>2]|0;f[e>>2]=0;if(c|0)Oq(c);c=f[d+8>>2]|0;if(c|0){e=c;do{c=e;e=f[e>>2]|0;g=c+8|0;h=f[c+20>>2]|0;if(h|0){i=c+24|0;if((f[i>>2]|0)!=(h|0))f[i>>2]=h;Oq(h)}if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);Oq(c)}while((e|0)!=0)}e=f[d>>2]|0;f[d>>2]=0;if(e|0)Oq(e);Oq(d)}if((b[a+11>>0]|0)>=0)return;Oq(f[a>>2]|0);return}function si(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0;g=u;u=u+32|0;h=g+12|0;i=g;f[h>>2]=0;f[h+4>>2]=0;f[h+8>>2]=0;if((e|0)>0){j=i+11|0;k=i+4|0;l=0;do{if((l|0)>0)An(h,14477)|0;il(i,$(n[d+(l<<2)>>2]));m=b[j>>0]|0;o=m<<24>>24<0;lj(h,o?f[i>>2]|0:i,o?f[k>>2]|0:m&255)|0;if((b[j>>0]|0)<0)Oq(f[i>>2]|0);l=l+1|0}while((l|0)<(e|0))}am(Ai(a,c)|0,h)|0;if((b[h+11>>0]|0)>=0){u=g;return}Oq(f[h>>2]|0);u=g;return}function ti(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=u;u=u+16|0;d=c;if((Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){e=1;u=c;return e|0}g=a+4|0;h=a+20|0;i=a+24|0;j=a+16|0;a=0;while(1){k=f[(f[g>>2]|0)+4>>2]|0;l=dm(k,Ra[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;f[d>>2]=l;if((l|0)==-1)break;k=f[h>>2]|0;if((k|0)==(f[i>>2]|0))Ri(j,d);else{f[k>>2]=l;f[h>>2]=k+4}gl(f[g>>2]|0,f[d>>2]|0)|0;a=a+1|0;if((a|0)>=(Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)){e=1;m=9;break}}if((m|0)==9){u=c;return e|0}e=0;u=c;return e|0}function ui(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=1292;hi(a+60|0);b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=a+36|0;d=f[b>>2]|0;if(d|0){c=a+40|0;e=f[c>>2]|0;if((e|0)==(d|0))g=d;else{h=e;do{e=h+-24|0;f[c>>2]=e;Va[f[f[e>>2]>>2]&127](e);h=f[c>>2]|0}while((h|0)!=(d|0));g=f[b>>2]|0}Oq(g)}f[a>>2]=1232;g=f[a+16>>2]|0;if(g|0){b=a+20|0;d=f[b>>2]|0;if((d|0)!=(g|0))f[b>>2]=d+(~((d+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+4>>2]|0;if(!g)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(g|0))f[d>>2]=a+(~((a+-4-g|0)>>>2)<<2);Oq(g);return}function vi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=u;u=u+32|0;d=c+16|0;e=c+8|0;g=c;h=a+8|0;if(f[h>>2]<<5>>>0>=b>>>0){u=c;return}f[d>>2]=0;i=d+4|0;f[i>>2]=0;j=d+8|0;f[j>>2]=0;if((b|0)<0)aq(d);k=((b+-1|0)>>>5)+1|0;b=ln(k<<2)|0;f[d>>2]=b;f[i>>2]=0;f[j>>2]=k;k=f[a>>2]|0;f[e>>2]=k;f[e+4>>2]=0;b=a+4|0;l=f[b>>2]|0;f[g>>2]=k+(l>>>5<<2);f[g+4>>2]=l&31;zg(d,e,g);g=f[a>>2]|0;f[a>>2]=f[d>>2];f[d>>2]=g;d=f[b>>2]|0;f[b>>2]=f[i>>2];f[i>>2]=d;d=f[h>>2]|0;f[h>>2]=f[j>>2];f[j>>2]=d;if(g|0)Oq(g);u=c;return}function wi(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;b=a+136|0;c=f[b>>2]|0;if(c|0){d=a+140|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e;while(1){e=h+-12|0;f[d>>2]=e;i=f[e>>2]|0;if(!i)j=e;else{e=h+-8|0;k=f[e>>2]|0;if((k|0)!=(i|0))f[e>>2]=k+(~((k+-4-i|0)>>>2)<<2);Oq(i);j=f[d>>2]|0}if((j|0)==(c|0))break;else h=j}g=f[b>>2]|0}Oq(g)}g=f[a+104>>2]|0;if(g|0){b=a+108|0;j=f[b>>2]|0;if((j|0)!=(g|0))f[b>>2]=j+(~((j+-4-g|0)>>>2)<<2);Oq(g)}g=f[a+92>>2]|0;if(!g){uj(a);return}j=a+96|0;b=f[j>>2]|0;if((b|0)!=(g|0))f[j>>2]=b+(~((b+-4-g|0)>>>2)<<2);Oq(g);uj(a);return}function xi(a){a=a|0;var c=0,d=0,e=0,g=0;f[a>>2]=3680;c=a+72|0;d=a+136|0;e=a+4|0;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=c;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));n[d>>2]=$(1.0);d=a+140|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[a+164>>2]=-1;d=a+168|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[d+24>>2]=0;wn(a+200|0);Gn(a+232|0);d=a+316|0;e=a+264|0;g=e+52|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=-1;f[a+320>>2]=-1;f[a+324>>2]=0;f[a+328>>2]=2;f[a+332>>2]=7;f[a+336>>2]=0;f[a+340>>2]=0;f[a+344>>2]=0;b[a+352>>0]=0;return}function yi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=(e|0)/12|0;h=g+1|0;if(h>>>0>357913941)aq(a);i=a+8|0;j=((f[i>>2]|0)-d|0)/12|0;k=j<<1;l=j>>>0<178956970?(k>>>0>>0?h:k):357913941;do if(l)if(l>>>0>357913941){k=ra(8)|0;Oo(k,16035);f[k>>2]=7256;va(k|0,1112,110)}else{m=ln(l*12|0)|0;break}else m=0;while(0);k=m+(g*12|0)|0;f[k>>2]=f[b>>2];f[k+4>>2]=f[b+4>>2];f[k+8>>2]=f[b+8>>2];b=k+(((e|0)/-12|0)*12|0)|0;if((e|0)>0)kh(b|0,d|0,e|0)|0;f[a>>2]=b;f[c>>2]=k+12;f[i>>2]=m+(l*12|0);if(!d)return;Oq(d);return}function zi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=a+16|0;h=g;i=f[h+4>>2]|0;if((d|0)<0|(d|0)==0&c>>>0<1|((i|0)>0|(i|0)==0&(f[h>>2]|0)>>>0>0)){j=0;return j|0}b[a+24>>0]=e&1;h=Vn(c|0,d|0,7,0)|0;d=Ik(h|0,I|0,8,0)|0;h=I;c=g;f[c>>2]=d;f[c+4>>2]=h;c=a+4|0;g=f[c>>2]|0;i=f[a>>2]|0;k=g-i|0;l=Vn(k|0,0,8,0)|0;m=e?l:k;l=Vn(m|0,(e?I:0)|0,d|0,h|0)|0;h=i;i=g;if(k>>>0>=l>>>0)if(k>>>0>l>>>0?(g=h+l|0,(g|0)!=(i|0)):0){f[c>>2]=g;n=h}else n=h;else{Fi(a,l-k|0);n=f[a>>2]|0}k=ln(8)|0;f[k>>2]=n+m;f[k+4>>2]=0;m=a+12|0;a=f[m>>2]|0;f[m>>2]=k;if(!a){j=1;return j|0}Oq(a);j=1;return j|0}function Ai(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=u;u=u+16|0;d=c;e=yg(a,d,b)|0;g=f[e>>2]|0;if(g|0){h=g;i=h+28|0;u=c;return i|0}g=ln(40)|0;pj(g+16|0,b);b=g+28|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;b=f[d>>2]|0;f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=b;f[e>>2]=g;b=f[f[a>>2]>>2]|0;if(!b)j=g;else{f[a>>2]=b;j=f[e>>2]|0}Oe(f[a+4>>2]|0,j);j=a+8|0;f[j>>2]=(f[j>>2]|0)+1;h=g;i=h+28|0;u=c;return i|0}function Bi(a,c,d,e,g,h,i,j){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0;k=u;u=u+16|0;l=k;if((-18-c|0)>>>0>>0)aq(a);if((b[a+11>>0]|0)<0)m=f[a>>2]|0;else m=a;if(c>>>0<2147483623){n=d+c|0;d=c<<1;o=n>>>0>>0?d:n;p=o>>>0<11?11:o+16&-16}else p=-17;o=ln(p)|0;if(g|0)Fo(o,m,g)|0;if(i|0)Fo(o+g|0,j,i)|0;j=e-h|0;e=j-g|0;if(e|0)Fo(o+g+i|0,m+g+h|0,e)|0;if((c|0)!=10)Oq(m);f[a>>2]=o;f[a+8>>2]=p|-2147483648;p=j+i|0;f[a+4>>2]=p;b[l>>0]=0;up(o+p|0,l);u=k;return}function Ci(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+8|0;d=f[c>>2]|0;e=a+4|0;g=f[e>>2]|0;if(d-g>>2>>>0>=b>>>0){sj(g|0,0,b<<2|0)|0;f[e>>2]=g+(b<<2);return}h=f[a>>2]|0;i=g-h|0;g=i>>2;j=g+b|0;if(j>>>0>1073741823)aq(a);k=d-h|0;d=k>>1;l=k>>2>>>0<536870911?(d>>>0>>0?j:d):1073741823;do if(l)if(l>>>0>1073741823){d=ra(8)|0;Oo(d,16035);f[d>>2]=7256;va(d|0,1112,110)}else{d=ln(l<<2)|0;m=d;n=d;break}else{m=0;n=0}while(0);d=m+(g<<2)|0;sj(d|0,0,b<<2|0)|0;if((i|0)>0)kh(n|0,h|0,i|0)|0;f[a>>2]=m;f[e>>2]=d+(b<<2);f[c>>2]=m+(l<<2);if(!h)return;Oq(h);return}function Di(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=ln(32)|0;f[a>>2]=g;f[a+4>>2]=c+8;c=a+8|0;b[c>>0]=0;pj(g+8|0,e);h=g+20|0;i=e+12|0;f[h>>2]=0;f[g+24>>2]=0;f[g+28>>2]=0;g=e+16|0;e=f[g>>2]|0;j=f[i>>2]|0;k=e-j|0;if(!k){l=j;m=e;n=0}else{Fi(h,k);l=f[i>>2]|0;m=f[g>>2]|0;n=f[h>>2]|0}kh(n|0,l|0,m-l|0)|0;b[c>>0]=1;c=f[a>>2]|0;f[c+4>>2]=d;f[c>>2]=0;return}function Ei(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=0,h=0,i=0,j=0,k=0.0,l=0,m=0,n=0,o=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=+d;l=j;j=i;while(1){if(j<<24>>24<0)m=f[c>>2]|0;else m=c;p[g>>3]=k;n=Bn(m,l+1|0,18562,g)|0;if((n|0)>-1)if(n>>>0>l>>>0)o=n;else break;else o=l<<1|1;Hj(c,o,0);l=o;j=b[h>>0]|0}Hj(c,n,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Fi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;d=a+8|0;e=f[d>>2]|0;g=a+4|0;h=f[g>>2]|0;if((e-h|0)>>>0>=c>>>0){i=c;j=h;do{b[j>>0]=0;j=(f[g>>2]|0)+1|0;f[g>>2]=j;i=i+-1|0}while((i|0)!=0);return}i=f[a>>2]|0;j=h-i|0;h=j+c|0;if((h|0)<0)aq(a);k=e-i|0;i=k<<1;e=k>>>0<1073741823?(i>>>0>>0?h:i):2147483647;if(!e)l=0;else l=ln(e)|0;i=l+j|0;j=l+e|0;e=c;c=i;l=i;do{b[l>>0]=0;l=c+1|0;c=l;e=e+-1|0}while((e|0)!=0);e=f[a>>2]|0;l=(f[g>>2]|0)-e|0;h=i+(0-l)|0;if((l|0)>0)kh(h|0,e|0,l|0)|0;f[a>>2]=h;f[g>>2]=c;f[d>>2]=j;if(!e)return;Oq(e);return}function Gi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=(d-e|0)/136|0;h=d;if(g>>>0>>0){Ge(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+(b*136|0)|0;if((g|0)==(h|0))return;else i=h;do{f[c>>2]=i+-136;h=f[i+-20>>2]|0;if(h|0){b=i+-16|0;e=f[b>>2]|0;if((e|0)!=(h|0))f[b>>2]=e+(~((e+-4-h|0)>>>2)<<2);Oq(h)}h=f[i+-32>>2]|0;if(h|0){e=i+-28|0;b=f[e>>2]|0;if((b|0)!=(h|0))f[e>>2]=b+(~((b+-4-h|0)>>>2)<<2);Oq(h)}Mi(i+-132|0);i=f[c>>2]|0}while((i|0)!=(g|0));return}function Hi(a,b){a=a|0;b=b|0;var c=0,d=Oa,e=0,g=0;if((b|0)!=1)if(!(b+-1&b))c=b;else c=cb(b)|0;else c=2;b=f[a+4>>2]|0;if(c>>>0>b>>>0){Sd(a,c);return}if(c>>>0>=b>>>0)return;d=$((f[a+12>>2]|0)>>>0);e=~~$(W($(d/$(n[a+16>>2]))))>>>0;if(b>>>0>2&(b+-1&b|0)==0)g=1<<32-(_(e+-1|0)|0);else g=cb(e)|0;e=c>>>0>>0?g:c;if(e>>>0>=b>>>0)return;Sd(a,e);return}function Ii(a){a=a|0;var b=0,c=0,d=0;b=f[a+76>>2]|0;if(b|0){c=a+80|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+64>>2]|0;if(b|0){d=a+68|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}b=f[a+48>>2]|0;if(b|0){d=a+52|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+24>>2]|0;if(b|0){c=a+28|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+12>>2]|0;if(b|0){d=a+16|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Ji(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=u;u=u+16|0;g=e;h=c+11|0;i=b[h>>0]|0;if(i<<24>>24<0)j=f[c+4>>2]|0;else j=i&255;k=j;j=i;while(1){if(j<<24>>24<0)l=f[c>>2]|0;else l=c;f[g>>2]=d;m=Bn(l,k+1|0,18559,g)|0;if((m|0)>-1)if(m>>>0>k>>>0)n=m;else break;else n=k<<1|1;Hj(c,n,0);k=n;j=b[h>>0]|0}Hj(c,m,0);f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2];a=0;while(1){if((a|0)==3)break;f[c+(a<<2)>>2]=0;a=a+1|0}u=e;return}function Ki(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a+8|0;c=f[b>>2]|0;if((c|0)<0){d=0;return d|0}e=a+4|0;a=f[e>>2]|0;g=a+4|0;h=f[g>>2]|0;i=f[a>>2]|0;j=h-i>>2;k=i;i=h;if(c>>>0<=j>>>0)if(c>>>0>>0?(h=k+(c<<2)|0,(h|0)!=(i|0)):0){f[g>>2]=i+(~((i+-4-h|0)>>>2)<<2);l=c}else l=c;else{Ci(a,c-j|0);l=f[b>>2]|0}if((l|0)<=0){d=1;return d|0}b=f[e>>2]|0;e=f[b>>2]|0;j=(f[b+4>>2]|0)-e>>2;c=e;e=0;while(1){if(j>>>0<=e>>>0){m=10;break}f[c+(e<<2)>>2]=e;e=e+1|0;if((e|0)>=(l|0)){d=1;m=12;break}}if((m|0)==10)aq(b);else if((m|0)==12)return d|0;return 0}function Li(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=ln(16)|0;f[g>>2]=h;f[g+8>>2]=-2147483632;f[g+4>>2]=14;i=h;j=14408;k=i+14|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[h+14>>0]=0;Xj(a,g,c);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);c=ln(16)|0;f[g>>2]=c;f[g+8>>2]=-2147483632;f[g+4>>2]=14;i=c;j=14423;k=i+14|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[c+14>>0]=0;Xj(a,g,d);if((b[g+11>>0]|0)>=0){u=e;return}Oq(f[g>>2]|0);u=e;return}function Mi(a){a=a|0;var b=0,c=0,d=0;b=f[a+84>>2]|0;if(b|0){c=a+88|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+72>>2]|0;if(b|0){d=a+76|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+40>>2]|0;if(b|0){c=a+44|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+28>>2]|0;if(b|0){d=a+32|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+12>>2]|0;if(b|0)Oq(b);b=f[a>>2]|0;if(!b)return;Oq(b);return}function Ni(a){a=a|0;var b=0,c=0,d=0,e=0;f[a>>2]=1352;b=a+32|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+88|0;d=f[b>>2]|0;f[b>>2]=0;if(d|0){b=f[d+8>>2]|0;if(b|0){e=d+12|0;if((f[e>>2]|0)!=(b|0))f[e>>2]=b;Oq(b)}Oq(d)}d=f[c+68>>2]|0;if(d|0){b=c+72|0;e=f[b>>2]|0;if((e|0)!=(d|0))f[b>>2]=e+(~((e+-4-d|0)>>>2)<<2);Oq(d)}d=c+64|0;e=f[d>>2]|0;f[d>>2]=0;if(e|0){d=f[e>>2]|0;if(d|0){b=e+4|0;if((f[b>>2]|0)!=(d|0))f[b>>2]=d;Oq(d)}Oq(e)}Oq(c)}c=f[a+16>>2]|0;if(!c)return;e=a+20|0;a=f[e>>2]|0;if((a|0)!=(c|0))f[e>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Oi(){var a=0,b=0,c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0;a=u;u=u+48|0;b=a+32|0;c=a+24|0;d=a+16|0;e=a;g=a+36|0;a=sn()|0;if(a|0?(h=f[a>>2]|0,h|0):0){a=h+48|0;i=f[a>>2]|0;j=f[a+4>>2]|0;if(!((i&-256|0)==1126902528&(j|0)==1129074247)){f[c>>2]=18701;Hn(18651,c)}if((i|0)==1126902529&(j|0)==1129074247)k=f[h+44>>2]|0;else k=h+80|0;f[g>>2]=k;k=f[h>>2]|0;h=f[k+4>>2]|0;if(Sa[f[(f[258]|0)+16>>2]&31](1032,k,g)|0){k=f[g>>2]|0;g=Qa[f[(f[k>>2]|0)+8>>2]&127](k)|0;f[e>>2]=18701;f[e+4>>2]=h;f[e+8>>2]=g;Hn(18565,e)}else{f[d>>2]=18701;f[d+4>>2]=h;Hn(18610,d)}}Hn(18689,b)}function Pi(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;do if(a){if(c>>>0<128){b[a>>0]=c;e=1;break}d=(Jq()|0)+188|0;if(!(f[f[d>>2]>>2]|0))if((c&-128|0)==57216){b[a>>0]=c;e=1;break}else{d=Vq()|0;f[d>>2]=84;e=-1;break}if(c>>>0<2048){b[a>>0]=c>>>6|192;b[a+1>>0]=c&63|128;e=2;break}if(c>>>0<55296|(c&-8192|0)==57344){b[a>>0]=c>>>12|224;b[a+1>>0]=c>>>6&63|128;b[a+2>>0]=c&63|128;e=3;break}if((c+-65536|0)>>>0<1048576){b[a>>0]=c>>>18|240;b[a+1>>0]=c>>>12&63|128;b[a+2>>0]=c>>>6&63|128;b[a+3>>0]=c&63|128;e=4;break}else{d=Vq()|0;f[d>>2]=84;e=-1;break}}else e=1;while(0);return e|0}function Qi(a){a=a|0;var b=0,c=0,d=0;b=f[a+92>>2]|0;if(b|0){c=a+96|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0){d=a+80|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+52>>2]|0;if(b|0){d=a+56|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}f[a+4>>2]=3636;b=f[a+24>>2]|0;if(b|0)Oq(b);b=f[a+12>>2]|0;if(!b)return;Oq(b);return}function Ri(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=a+4|0;d=f[a>>2]|0;e=(f[c>>2]|0)-d|0;g=e>>2;h=g+1|0;if(h>>>0>1073741823)aq(a);i=a+8|0;j=(f[i>>2]|0)-d|0;k=j>>1;l=j>>2>>>0<536870911?(k>>>0>>0?h:k):1073741823;do if(l)if(l>>>0>1073741823){k=ra(8)|0;Oo(k,16035);f[k>>2]=7256;va(k|0,1112,110)}else{k=ln(l<<2)|0;m=k;n=k;break}else{m=0;n=0}while(0);k=m+(g<<2)|0;f[k>>2]=f[b>>2];if((e|0)>0)kh(n|0,d|0,e|0)|0;f[a>>2]=m;f[c>>2]=k+4;f[i>>2]=m+(l<<2);if(!d)return;Oq(d);return}function Si(a){a=a|0;var c=0,d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;c=a+104|0;d=f[c>>2]|0;if((d|0)!=0?(f[a+108>>2]|0)>=(d|0):0)e=4;else{d=Wm(a)|0;if((d|0)>=0){g=f[c>>2]|0;c=a+8|0;if(g){i=f[c>>2]|0;j=f[a+4>>2]|0;k=g-(f[a+108>>2]|0)|0;g=i;if((i-j|0)<(k|0)){l=g;m=g}else{l=j+(k+-1)|0;m=g}}else{g=f[c>>2]|0;l=g;m=g}f[a+100>>2]=l;l=a+4|0;if(!m)n=f[l>>2]|0;else{g=f[l>>2]|0;l=a+108|0;f[l>>2]=m+1-g+(f[l>>2]|0);n=g}g=n+-1|0;if((d|0)==(h[g>>0]|0|0))o=d;else{b[g>>0]=d;o=d}}else e=4}if((e|0)==4){f[a+100>>2]=0;o=-1}return o|0}function Ti(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;f[a>>2]=1544;f[a+4>>2]=b;b=a+8|0;f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];f[b+12>>2]=f[c+12>>2];f[b+16>>2]=f[c+16>>2];f[b+20>>2]=f[c+20>>2];fk(a+32|0,c+24|0);f[a>>2]=2384;c=a+44|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];f[a>>2]=2440;d=a+112|0;c=a+60|0;b=c+52|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(b|0));Zm(d);f[a+152>>2]=0;f[a+156>>2]=0;f[a+160>>2]=0;return}function Ui(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;f[a>>2]=1544;f[a+4>>2]=b;b=a+8|0;f[b>>2]=f[c>>2];f[b+4>>2]=f[c+4>>2];f[b+8>>2]=f[c+8>>2];f[b+12>>2]=f[c+12>>2];f[b+16>>2]=f[c+16>>2];f[b+20>>2]=f[c+20>>2];fk(a+32|0,c+24|0);f[a>>2]=1964;c=a+44|0;f[c>>2]=f[d>>2];f[c+4>>2]=f[d+4>>2];f[c+8>>2]=f[d+8>>2];f[c+12>>2]=f[d+12>>2];f[a>>2]=2020;d=a+112|0;c=a+60|0;b=c+52|0;do{f[c>>2]=0;c=c+4|0}while((c|0)<(b|0));Zm(d);f[a+152>>2]=0;f[a+156>>2]=0;f[a+160>>2]=0;return}function Vi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2440;b=f[a+152>>2]|0;if(b|0){c=a+156|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+112>>2]|0;if(b|0){d=a+116|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0)Oq(b);b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0)Oq(b);b=f[a+60>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Wi(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0;d=u;u=u+16|0;e=d;g=f[(f[c+4>>2]|0)+4>>2]|0;if(!g){f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;u=d;return}if(!(Dj(d+12|0,f[c+44>>2]|0,g)|0)){g=ln(32)|0;f[e>>2]=g;f[e+8>>2]=-2147483616;f[e+4>>2]=26;c=g;h=15859;i=c+26|0;do{b[c>>0]=b[h>>0]|0;c=c+1|0;h=h+1|0}while((c|0)<(i|0));b[g+26>>0]=0;f[a>>2]=-1;pj(a+4|0,e);if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0)}else{f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0}u=d;return}function Xi(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=b+48|0;if((mi(f[c>>2]|0)|0)>9){d=0;return d|0}if((Qa[f[(f[b>>2]|0)+8>>2]&127](b)|0)!=1){d=0;return d|0}e=b+4|0;b=(f[(f[(f[e>>2]|0)+8>>2]|0)+(a<<2)>>2]|0)+56|0;a=f[b>>2]|0;do if((a|0)==3)if((mi(f[c>>2]|0)|0)<4){d=5;return d|0}else{g=f[b>>2]|0;break}else g=a;while(0);a=mi(f[c>>2]|0)|0;if((g|0)==1){d=(a|0)<4?6:0;return d|0}if((a|0)>7){d=0;return d|0}if((mi(f[c>>2]|0)|0)>1){d=1;return d|0}else return ((f[(f[e>>2]|0)+80>>2]|0)>>>0<40?1:4)|0;return 0}function Yi(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2020;b=f[a+152>>2]|0;if(b|0){c=a+156|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+112>>2]|0;if(b|0){d=a+116|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0)Oq(b);b=f[a+84>>2]|0;if(b|0)Oq(b);b=f[a+72>>2]|0;if(b|0)Oq(b);b=f[a+60>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Zi(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=u;u=u+128|0;h=g+124|0;i=g;j=i;k=6596;l=j+124|0;do{f[j>>2]=f[k>>2];j=j+4|0;k=k+4|0}while((j|0)<(l|0));if((c+-1|0)>>>0>2147483646)if(!c){m=h;n=1;o=4}else{h=Vq()|0;f[h>>2]=75;p=-1}else{m=a;n=c;o=4}if((o|0)==4){o=-2-m|0;c=n>>>0>o>>>0?o:n;f[i+48>>2]=c;n=i+20|0;f[n>>2]=m;f[i+44>>2]=m;o=m+c|0;m=i+16|0;f[m>>2]=o;f[i+28>>2]=o;o=Ah(i,d,e)|0;if(!c)p=o;else{c=f[n>>2]|0;b[c+(((c|0)==(f[m>>2]|0))<<31>>31)>>0]=0;p=o}}u=g;return p|0}function _i(a){a=a|0;var c=0,d=0,e=0,g=0;f[a>>2]=3480;c=a+72|0;d=a+136|0;e=a+4|0;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));e=c;g=e+64|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));n[d>>2]=$(1.0);d=a+140|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[a+164>>2]=-1;d=a+168|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;f[d+24>>2]=0;wn(a+200|0);Gn(a+232|0);d=a+264|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;b[d+24>>0]=0;return}function $i(a,c,d,e){a=a|0;c=c|0;d=d|0;e=+e;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+16|0;g=a;if(!c){h=0;u=a;return h|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Gj(d)|0;if(i>>>0>4294967279)aq(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=7}}else{m=i+16&-16;n=ln(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=7}if((l|0)==7){kh(k|0,d|0,i|0)|0;j=k}b[j+i>>0]=0;Zl(c,g,e);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);h=1;u=a;return h|0}function aj(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a=u;u=u+16|0;g=a;if(!c){h=0;u=a;return h|0}f[g>>2]=0;f[g+4>>2]=0;f[g+8>>2]=0;i=Gj(d)|0;if(i>>>0>4294967279)aq(g);if(i>>>0<11){b[g+11>>0]=i;if(!i)j=g;else{k=g;l=7}}else{m=i+16&-16;n=ln(m)|0;f[g>>2]=n;f[g+8>>2]=m|-2147483648;f[g+4>>2]=i;k=n;l=7}if((l|0)==7){kh(k|0,d|0,i|0)|0;j=k}b[j+i>>0]=0;$l(c,g,e);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);h=1;u=a;return h|0}function bj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;c=f[a+28>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;g=c+20|0;h=f[g>>2]|0;f[g>>2]=0;if(h|0){bj(h);Oq(h)}if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);Oq(c)}while((d|0)!=0)}d=a+20|0;c=f[d>>2]|0;f[d>>2]=0;if(c|0)Oq(c);c=f[a+8>>2]|0;if(c|0){d=c;do{c=d;d=f[d>>2]|0;e=c+8|0;h=f[c+20>>2]|0;if(h|0){g=c+24|0;if((f[g>>2]|0)!=(h|0))f[g>>2]=h;Oq(h)}if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);Oq(c)}while((d|0)!=0)}d=f[a>>2]|0;f[a>>2]=0;if(!d)return;Oq(d);return}function cj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0;e=u;u=u+16|0;g=e;h=f[c+36>>2]|0;if(!h){i=ln(32)|0;f[g>>2]=i;f[g+8>>2]=-2147483616;f[g+4>>2]=23;j=i;k=15706;l=j+23|0;do{b[j>>0]=b[k>>0]|0;j=j+1|0;k=k+1|0}while((j|0)<(l|0));b[i+23>>0]=0;f[a>>2]=-1;pj(a+4|0,g);if((b[g+11>>0]|0)<0)Oq(f[g>>2]|0);u=e;return}g=f[c+40>>2]|0;if(!g){Sc(a,c,h,d);u=e;return}else{bi(a,c,g,d);u=e;return}}function dj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;tk(a);b=a+84|0;c=f[b>>2]|0;if((c|0)<=0)return;d=c<<5;e=Lq(c>>>0>134217727|d>>>0>4294967291?-1:d+4|0)|0;f[e>>2]=c;d=e+4|0;e=d+(c<<5)|0;c=d;do{wn(c);c=c+32|0}while((c|0)!=(e|0));e=a+80|0;a=f[e>>2]|0;f[e>>2]=d;if(a|0){d=a+-4|0;c=f[d>>2]|0;if(c|0){g=a+(c<<5)|0;do{g=g+-32|0;Fj(g)}while((g|0)!=(a|0))}Mq(d)}if((f[b>>2]|0)>0)h=0;else return;do{tk((f[e>>2]|0)+(h<<5)|0);h=h+1|0}while((h|0)<(f[b>>2]|0));return}function ej(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;if(!b){d=0;return d|0}if(f[b+4>>2]|0){d=0;return d|0}a=ln(52)|0;Ub(a,c);f[a+40>>2]=0;f[a+44>>2]=0;f[a+48>>2]=0;c=b+4|0;b=f[c>>2]|0;f[c>>2]=a;if(!b){d=1;return d|0}a=b+40|0;c=f[a>>2]|0;if(c|0){e=b+44|0;g=f[e>>2]|0;if((g|0)==(c|0))h=c;else{i=g;do{g=i+-4|0;f[e>>2]=g;j=f[g>>2]|0;f[g>>2]=0;if(j|0){bj(j);Oq(j)}i=f[e>>2]|0}while((i|0)!=(c|0));h=f[a>>2]|0}Oq(h)}bj(b);Oq(b);d=1;return d|0}function fj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[a>>2]|0;if(b){b=c+8|0;d=b;e=Vn(f[d>>2]|0,f[d+4>>2]|0,1,0)|0;d=b;f[d>>2]=e;f[d+4>>2]=I;d=a+28|0;e=f[d>>2]|0;b=a+24|0;f[b>>2]=f[b>>2]|1<>2]|0,f[e+4>>2]|0,1,0)|0;e=c;f[e>>2]=d;f[e+4>>2]=I;e=a+28|0;g=e;h=f[e>>2]|0}e=h+1|0;f[g>>2]=e;if((e|0)!=32)return;e=a+24|0;h=a+16|0;d=f[h>>2]|0;if((d|0)==(f[a+20>>2]|0))Ri(a+12|0,e);else{f[d>>2]=f[e>>2];f[h>>2]=d+4}f[g>>2]=0;f[e>>2]=0;return}function gj(a,b){a=a|0;b=b|0;var c=0,d=0;c=a+32|0;a=f[b>>2]|0;f[b>>2]=0;b=f[c>>2]|0;f[c>>2]=a;if(!b)return;a=b+88|0;c=f[a>>2]|0;f[a>>2]=0;if(c|0){a=f[c+8>>2]|0;if(a|0){d=c+12|0;if((f[d>>2]|0)!=(a|0))f[d>>2]=a;Oq(a)}Oq(c)}c=f[b+68>>2]|0;if(c|0){a=b+72|0;d=f[a>>2]|0;if((d|0)!=(c|0))f[a>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=b+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){a=d+4|0;if((f[a>>2]|0)!=(c|0))f[a>>2]=c;Oq(c)}Oq(d)}Oq(b);return}function hj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;if(c|0){h=a+11|0;i=b[h>>0]|0;if(i<<24>>24<0){j=f[a+4>>2]|0;k=(f[a+8>>2]&2147483647)+-1|0}else{j=i&255;k=10}if((k-j|0)>>>0>>0){xj(a,k,c-k+j|0,j,j,0,0);l=b[h>>0]|0}else l=i;if(l<<24>>24<0)m=f[a>>2]|0;else m=a;Qn(m+j|0,c,d)|0;d=j+c|0;if((b[h>>0]|0)<0)f[a+4>>2]=d;else b[h>>0]=d;b[g>>0]=0;up(m+d|0,g)}u=e;return a|0}function ij(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+48|0;e=d+4|0;g=d;h=f[b+12>>2]|0;i=f[b+4>>2]|0;b=e;j=b+36|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(j|0));zh(g,c,h,i,e);i=f[e+24>>2]|0;if(!i){k=f[g>>2]|0;f[a>>2]=k;u=d;return}h=e+28|0;e=f[h>>2]|0;if((e|0)!=(i|0))f[h>>2]=e+(~((e+-4-i|0)>>>2)<<2);Oq(i);k=f[g>>2]|0;f[a>>2]=k;u=d;return}function jj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=(f[a+8>>2]&2147483647)+-1|0;else k=10;do if(k>>>0>=d>>>0){if(j)l=f[a>>2]|0;else l=a;Eo(l,c,d)|0;b[g>>0]=0;up(l+d|0,g);if((b[h>>0]|0)<0){f[a+4>>2]=d;break}else{b[h>>0]=d;break}}else{if(j)m=f[a+4>>2]|0;else m=i&255;Bi(a,k,d-k|0,m,0,m,d,c)}while(0);u=e;return a|0}function kj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d;do{f[c>>2]=g+-136;d=f[g+-20>>2]|0;if(d|0){h=g+-16|0;i=f[h>>2]|0;if((i|0)!=(d|0))f[h>>2]=i+(~((i+-4-d|0)>>>2)<<2);Oq(d)}d=f[g+-32>>2]|0;if(d|0){i=g+-28|0;h=f[i>>2]|0;if((h|0)!=(d|0))f[i>>2]=h+(~((h+-4-d|0)>>>2)<<2);Oq(d)}Mi(g+-132|0);g=f[c>>2]|0}while((g|0)!=(b|0));e=f[a>>2]|0}Oq(e);return}function lj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j){k=f[a+4>>2]|0;l=(f[a+8>>2]&2147483647)+-1|0}else{k=i&255;l=10}if((l-k|0)>>>0>=d>>>0){if(d|0){if(j)m=f[a>>2]|0;else m=a;Fo(m+k|0,c,d)|0;j=k+d|0;if((b[h>>0]|0)<0)f[a+4>>2]=j;else b[h>>0]=j;b[g>>0]=0;up(m+j|0,g)}}else Bi(a,l,d-l+k|0,k,k,0,d,c);u=e;return a|0}function mj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;f[a>>2]=3932;b=f[a+32>>2]|0;if(b|0){c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+20>>2]|0;if(b|0){d=a+24|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=a+8|0;c=f[b>>2]|0;if(!c)return;d=a+12|0;a=f[d>>2]|0;if((a|0)==(c|0))e=c;else{g=a;do{a=g+-4|0;f[d>>2]=a;h=f[a>>2]|0;f[a>>2]=0;if(h|0)Va[f[(f[h>>2]|0)+4>>2]&127](h);g=f[d>>2]|0}while((g|0)!=(c|0));e=f[b>>2]|0}Oq(e);return}function nj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+4|0;if((Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)<=0){d=1;return d|0}a=0;while(1){e=f[(f[c>>2]|0)+4>>2]|0;g=dm(e,Ra[f[(f[b>>2]|0)+24>>2]&127](b,a)|0)|0;if((g|0)==-1){d=0;h=6;break}e=f[(f[b>>2]|0)+28>>2]|0;i=fl(f[c>>2]|0,g)|0;a=a+1|0;if(!(Ra[e&127](b,i)|0)){d=0;h=6;break}if((a|0)>=(Qa[f[(f[b>>2]|0)+20>>2]&127](b)|0)){d=1;h=6;break}}if((h|0)==6)return d|0;return 0}function oj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;if(!(ho(a,b,c)|0)){d=0;return d|0}if(!(Qa[f[(f[a>>2]|0)+52>>2]&127](a)|0)){d=0;return d|0}c=a+4|0;e=a+8|0;g=f[c>>2]|0;if((f[e>>2]|0)==(g|0)){d=1;return d|0}h=a+36|0;a=0;i=g;while(1){g=f[(f[h>>2]|0)+(a<<2)>>2]|0;if(!(Sa[f[(f[g>>2]|0)+8>>2]&31](g,b,f[i+(a<<2)>>2]|0)|0)){d=0;j=7;break}a=a+1|0;i=f[c>>2]|0;if(a>>>0>=(f[e>>2]|0)-i>>2>>>0){d=1;j=7;break}}if((j|0)==7)return d|0;return 0}function pj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;if((b[c+11>>0]|0)<0){g=f[c>>2]|0;h=f[c+4>>2]|0;if(h>>>0>4294967279)aq(a);if(h>>>0<11){b[a+11>>0]=h;i=a}else{j=h+16&-16;k=ln(j)|0;f[a>>2]=k;f[a+8>>2]=j|-2147483648;f[a+4>>2]=h;i=k}Fo(i,g,h)|0;b[e>>0]=0;up(i+h|0,e)}else{f[a>>2]=f[c>>2];f[a+4>>2]=f[c+4>>2];f[a+8>>2]=f[c+8>>2]}u=d;return}function qj(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0;b[c+53>>0]=1;do if((f[c+4>>2]|0)==(e|0)){b[c+52>>0]=1;a=c+16|0;h=f[a>>2]|0;if(!h){f[a>>2]=d;f[c+24>>2]=g;f[c+36>>2]=1;if(!((g|0)==1?(f[c+48>>2]|0)==1:0))break;b[c+54>>0]=1;break}if((h|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;b[c+54>>0]=1;break}h=c+24|0;a=f[h>>2]|0;if((a|0)==2){f[h>>2]=g;i=g}else i=a;if((i|0)==1?(f[c+48>>2]|0)==1:0)b[c+54>>0]=1}while(0);return}function rj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+36|0;d=a+40|0;e=f[c>>2]|0;if((f[d>>2]|0)!=(e|0)){g=0;h=e;do{vg(h+(g*24|0)|0,b)|0;g=g+1|0;h=f[c>>2]|0}while(g>>>0<(((f[d>>2]|0)-h|0)/24|0)>>>0)}h=a+48|0;d=a+52|0;a=f[h>>2]|0;if((f[d>>2]|0)==(a|0))return 1;else{i=0;j=a}do{a=f[j+(i<<2)>>2]|0;ci(a<<1^a>>31,b)|0;i=i+1|0;j=f[h>>2]|0}while(i>>>0<(f[d>>2]|0)-j>>2>>>0);return 1}function sj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;e=a+d|0;c=c&255;if((d|0)>=67){while(a&3){b[a>>0]=c;a=a+1|0}g=e&-4|0;h=g-64|0;i=c|c<<8|c<<16|c<<24;while((a|0)<=(h|0)){f[a>>2]=i;f[a+4>>2]=i;f[a+8>>2]=i;f[a+12>>2]=i;f[a+16>>2]=i;f[a+20>>2]=i;f[a+24>>2]=i;f[a+28>>2]=i;f[a+32>>2]=i;f[a+36>>2]=i;f[a+40>>2]=i;f[a+44>>2]=i;f[a+48>>2]=i;f[a+52>>2]=i;f[a+56>>2]=i;f[a+60>>2]=i;a=a+64|0}while((a|0)<(g|0)){f[a>>2]=i;a=a+4|0}}while((a|0)<(e|0)){b[a>>0]=c;a=a+1|0}return e-d|0}function tj(a,c,d,e,g){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;do if(!(fp(a,f[c+8>>2]|0,g)|0)){if(fp(a,f[c>>2]|0,g)|0){if((f[c+16>>2]|0)!=(d|0)?(h=c+20|0,(f[h>>2]|0)!=(d|0)):0){f[c+32>>2]=e;f[h>>2]=d;h=c+40|0;f[h>>2]=(f[h>>2]|0)+1;if((f[c+36>>2]|0)==1?(f[c+24>>2]|0)==2:0)b[c+54>>0]=1;f[c+44>>2]=4;break}if((e|0)==1)f[c+32>>2]=1}}else Vm(0,c,d,e);while(0);return}function uj(a){a=a|0;var b=0,c=0,d=0,e=0;b=a+80|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=c+-4|0;d=f[b>>2]|0;if(d|0){e=c+(d<<5)|0;do{e=e+-32|0;Fj(e)}while((e|0)!=(c|0))}Mq(b)}b=f[a+68>>2]|0;if(b|0){c=a+72|0;e=f[c>>2]|0;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);Oq(b)}b=a+44|0;e=f[b>>2]|0;f[b>>2]=0;if(e|0)Oq(e);e=f[a+32>>2]|0;if(!e){Fj(a);return}b=a+36|0;if((f[b>>2]|0)!=(e|0))f[b>>2]=e;Oq(e);Fj(a);return}function vj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3092;b=f[a+136>>2]|0;if(b|0){c=a+140|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0)Oq(b);b=f[a+64>>2]|0;if(b|0)Oq(b);b=f[a+52>>2]|0;if(b|0)Oq(b);b=f[a+40>>2]|0;if(!b)return;Oq(b);return}function wj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0;if((d|0)<0){e=0;return e|0}do if(!b){d=a+4|0;g=f[d>>2]|0;h=f[a>>2]|0;i=g-h|0;if(i>>>0>>0){Fi(a,c-i|0);break}if(i>>>0>c>>>0?(i=h+c|0,(i|0)!=(g|0)):0)f[d>>2]=i}else Cg(a,b,b+c|0);while(0);c=a+24|0;a=c;b=Vn(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=c;f[a>>2]=b;f[a+4>>2]=I;e=1;return e|0}function xj(a,c,d,e,g,h,i){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;if((-17-c|0)>>>0>>0)aq(a);if((b[a+11>>0]|0)<0)j=f[a>>2]|0;else j=a;if(c>>>0<2147483623){k=d+c|0;d=c<<1;l=k>>>0>>0?d:k;m=l>>>0<11?11:l+16&-16}else m=-17;l=ln(m)|0;if(g|0)Fo(l,j,g)|0;k=e-h-g|0;if(k|0)Fo(l+g+i|0,j+g+h|0,k)|0;if((c|0)!=10)Oq(j);f[a>>2]=l;f[a+8>>2]=m|-2147483648;return}function yj(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2728;b=f[a+136>>2]|0;if(b|0){c=a+140|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+96>>2]|0;if(b|0){d=a+100|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+76>>2]|0;if(b|0)Oq(b);b=f[a+64>>2]|0;if(b|0)Oq(b);b=f[a+52>>2]|0;if(b|0)Oq(b);b=f[a+40>>2]|0;if(!b)return;Oq(b);return}function zj(a,b){a=a|0;b=b|0;if(!b)return;else{zj(a,f[b>>2]|0);zj(a,f[b+4>>2]|0);Ej(b+20|0,f[b+24>>2]|0);Oq(b);return}}function Aj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;Yf(a,b,c);c=f[a+100>>2]|0;d=f[a+96>>2]|0;a=d;if((c|0)==(d|0))return;e=f[b>>2]|0;b=(c-d|0)/12|0;d=0;do{c=a+(d*12|0)|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];c=a+(d*12|0)+4|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];c=a+(d*12|0)+8|0;f[c>>2]=f[e+(f[c>>2]<<2)>>2];d=d+1|0}while(d>>>0>>0);return}function Bj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=a+64|0;if((f[d>>2]|0)==0?(e=ln(32)|0,yn(e),g=f[d>>2]|0,f[d>>2]=e,g|0):0){e=f[g>>2]|0;if(e|0){h=g+4|0;if((f[h>>2]|0)!=(e|0))f[h>>2]=e;Oq(e)}Oq(g)}g=Vl(f[a+28>>2]|0)|0;e=X(g,b[a+24>>0]|0)|0;g=((e|0)<0)<<31>>31;h=f[d>>2]|0;i=un(e|0,g|0,c|0,0)|0;if(!(wj(h,0,i,I)|0)){j=0;return j|0}Kk(a,f[d>>2]|0,e,g,0,0);f[a+80>>2]=c;j=1;return j|0}function Cj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+64|0;e=d;if(!(fp(a,b,0)|0))if((b|0)!=0?(g=Eh(b,1056,1040,0)|0,(g|0)!=0):0){b=e+4|0;h=b+52|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(h|0));f[e>>2]=g;f[e+8>>2]=a;f[e+12>>2]=-1;f[e+48>>2]=1;Ya[f[(f[g>>2]|0)+28>>2]&3](g,e,f[c>>2]|0,1);if((f[e+24>>2]|0)==1){f[c>>2]=f[e+16>>2];i=1}else i=0;j=i}else j=0;else j=1;u=d;return j|0}function Dj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;if(!c){d=0;return d|0}e=c+40|0;g=c+44|0;ci((f[g>>2]|0)-(f[e>>2]|0)>>2,b)|0;h=f[e>>2]|0;e=f[g>>2]|0;if((h|0)!=(e|0)){g=h;do{h=f[g>>2]|0;if(h|0){ci(f[h+40>>2]|0,b)|0;lg(a,b,h)|0}g=g+4|0}while((g|0)!=(e|0))}lg(a,b,c)|0;d=1;return d|0}function Ej(a,c){a=a|0;c=c|0;var d=0;if(!c)return;Ej(a,f[c>>2]|0);Ej(a,f[c+4>>2]|0);a=c+16|0;d=c+28|0;if((b[d+11>>0]|0)<0)Oq(f[d>>2]|0);if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);Oq(c);return}function Fj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b;d=c;f[d>>2]=0;f[d+4>>2]=0;qf(a,2,c);c=f[a+12>>2]|0;d=a+16|0;e=f[d>>2]|0;if((e|0)==(c|0))g=c;else{h=e+(~((e+-4-c|0)>>>2)<<2)|0;f[d>>2]=h;g=h}f[a+24>>2]=0;f[a+28>>2]=0;if(c|0){if((g|0)!=(c|0))f[d>>2]=g+(~((g+-4-c|0)>>>2)<<2);Oq(c)}c=f[a>>2]|0;if(!c){u=b;return}g=a+4|0;a=f[g>>2]|0;if((a|0)!=(c|0))f[g>>2]=a+(~((a+-8-c|0)>>>3)<<3);Oq(c);u=b;return}function Gj(a){a=a|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0,k=0,l=0;c=a;a:do if(!(c&3)){d=a;e=4}else{g=a;h=c;while(1){if(!(b[g>>0]|0)){i=h;break a}j=g+1|0;h=j;if(!(h&3)){d=j;e=4;break}else g=j}}while(0);if((e|0)==4){e=d;while(1){k=f[e>>2]|0;if(!((k&-2139062144^-2139062144)&k+-16843009))e=e+4|0;else break}if(!((k&255)<<24>>24))l=e;else{k=e;while(1){e=k+1|0;if(!(b[e>>0]|0)){l=e;break}else k=e}}i=l}return i-c|0}function Hj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=a+11|0;i=b[h>>0]|0;j=i<<24>>24<0;if(j)k=f[a+4>>2]|0;else k=i&255;do if(k>>>0>=c>>>0)if(j){i=(f[a>>2]|0)+c|0;b[g>>0]=0;up(i,g);f[a+4>>2]=c;break}else{b[g>>0]=0;up(a+c|0,g);b[h>>0]=c;break}else hj(a,c-k|0,d)|0;while(0);u=e;return}function Ij(a){a=a|0;var b=0,c=0,d=0;if(!a)return;b=a+88|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0){b=f[c+8>>2]|0;if(b|0){d=c+12|0;if((f[d>>2]|0)!=(b|0))f[d>>2]=b;Oq(b)}Oq(c)}c=f[a+68>>2]|0;if(c|0){b=a+72|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c)}c=a+64|0;d=f[c>>2]|0;f[c>>2]=0;if(d|0){c=f[d>>2]|0;if(c|0){b=d+4|0;if((f[b>>2]|0)!=(c|0))f[b>>2]=c;Oq(c)}Oq(d)}Oq(a);return}function Jj(a,c,d,e,g,h,i,j,k,l){a=a|0;c=c|0;d=d|0;e=e|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;var m=0,n=0,o=0;f[a>>2]=d;if(d|0){m=d+16|0;n=f[m+4>>2]|0;o=a+8|0;f[o>>2]=f[m>>2];f[o+4>>2]=n;n=d+24|0;d=f[n+4>>2]|0;o=a+16|0;f[o>>2]=f[n>>2];f[o+4>>2]=d}b[a+24>>0]=e;f[a+28>>2]=g;b[a+32>>0]=h&1;h=a+40|0;f[h>>2]=i;f[h+4>>2]=j;j=a+48|0;f[j>>2]=k;f[j+4>>2]=l;f[a+56>>2]=c;return}function Kj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=ln(88)|0;d=c+60|0;e=c;g=e+60|0;do{f[e>>2]=0;e=e+4|0}while((e|0)<(g|0));f[d>>2]=c;d=c+64|0;f[d>>2]=0;f[d+4>>2]=0;f[d+8>>2]=0;f[d+12>>2]=0;f[d+16>>2]=0;f[d+20>>2]=0;d=cg(c,b)|0;f[a>>2]=d?c:0;a=d?0:c;if(d)return;Ii(a);Oq(a);return}function Lj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;if((f[c+76>>2]|0)>=0?(Tq(c)|0)!=0:0){d=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(g=c+20|0,h=f[g>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[g>>2]=h+1;b[h>>0]=d;i=e}else i=Nj(c,a)|0;Sq(c);j=i}else k=3;do if((k|0)==3){i=a&255;e=a&255;if((e|0)!=(b[c+75>>0]|0)?(d=c+20|0,h=f[d>>2]|0,h>>>0<(f[c+16>>2]|0)>>>0):0){f[d>>2]=h+1;b[h>>0]=i;j=e;break}j=Nj(c,a)|0}while(0);return j|0}function Mj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d+4|0;g=d;h=d+8|0;i=f[a+4>>2]|0;if((i|0)==-1){j=0;u=d;return j|0}b[h>>0]=i;i=c+16|0;a=f[i+4>>2]|0;if(!((a|0)>0|(a|0)==0&(f[i>>2]|0)>>>0>0)){f[g>>2]=f[c+4>>2];f[e>>2]=f[g>>2];Me(c,e,h,h+1|0)|0}j=1;u=d;return j|0}function Nj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;d=u;u=u+16|0;e=d;g=c&255;b[e>>0]=g;i=a+16|0;j=f[i>>2]|0;if(!j)if(!(vl(a)|0)){k=f[i>>2]|0;l=4}else m=-1;else{k=j;l=4}do if((l|0)==4){j=a+20|0;i=f[j>>2]|0;if(i>>>0>>0?(n=c&255,(n|0)!=(b[a+75>>0]|0)):0){f[j>>2]=i+1;b[i>>0]=g;m=n;break}if((Sa[f[a+36>>2]&31](a,e,1)|0)==1)m=h[e>>0]|0;else m=-1}while(0);u=d;return m|0}function Oj(a,b){a=a|0;b=b|0;if(!b)return;else{Oj(a,f[b>>2]|0);Oj(a,f[b+4>>2]|0);Ej(b+20|0,f[b+24>>2]|0);Oq(b);return}}function Pj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=u;u=u+16|0;g=e;h=e+4|0;f[g>>2]=c;c=ln(32)|0;f[h>>2]=c;f[h+8>>2]=-2147483616;f[h+4>>2]=17;i=c;j=14495;k=i+17|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[c+17>>0]=0;Xj(Hd(a,g)|0,h,d);if((b[h+11>>0]|0)>=0){u=e;return}Oq(f[h>>2]|0);u=e;return}function Qj(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=a+48|0;if((f[a+52>>2]|0)>>>0<=e>>>0)Ce(b,e+1|0,0);c=(f[b>>2]|0)+(e>>>5<<2)|0;f[c>>2]=f[c>>2]|1<<(e&31);c=f[a+36>>2]|0;if((f[a+40>>2]|0)-c>>2>>>0<=e>>>0){d=1;return d|0}Bp(f[c+(e<<2)>>2]|0);d=1;return d|0}function Rj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if(c>>>0>0|(c|0)==0&a>>>0>4294967295){e=d;f=a;g=c;while(1){c=hn(f|0,g|0,10,0)|0;e=e+-1|0;b[e>>0]=c&255|48;c=f;f=jp(f|0,g|0,10,0)|0;if(!(g>>>0>9|(g|0)==9&c>>>0>4294967295))break;else g=I}h=f;i=e}else{h=a;i=d}if(!h)j=i;else{d=h;h=i;while(1){i=h+-1|0;b[i>>0]=(d>>>0)%10|0|48;if(d>>>0<10){j=i;break}else{d=(d>>>0)/10|0;h=i}}}return j|0}function Sj(a){a=a|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=a;while(1){d=c+1|0;if(!(eq(b[c>>0]|0)|0))break;else c=d}a=b[c>>0]|0;switch(a<<24>>24|0){case 45:{e=1;f=5;break}case 43:{e=0;f=5;break}default:{g=0;h=c;i=a}}if((f|0)==5){g=e;h=d;i=b[d>>0]|0}if(!(Aq(i<<24>>24)|0))j=0;else{i=0;d=h;while(1){h=(i*10|0)+48-(b[d>>0]|0)|0;d=d+1|0;if(!(Aq(b[d>>0]|0)|0)){j=h;break}else i=h}}return (g|0?j:0-j|0)|0}function Tj(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=0,h=0;e=u;u=u+16|0;g=e;il(g,d);h=Ai(a,c)|0;c=h+11|0;if((b[c>>0]|0)<0){b[f[h>>2]>>0]=0;f[h+4>>2]=0}else{b[h>>0]=0;b[c>>0]=0}gh(h,0);f[h>>2]=f[g>>2];f[h+4>>2]=f[g+4>>2];f[h+8>>2]=f[g+8>>2];u=e;return}function Uj(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b+8|0;d=b+4|0;e=b;f[e>>2]=f[(f[a+4>>2]|0)+80>>2];g=f[a+44>>2]|0;a=g+16|0;h=f[a+4>>2]|0;if((h|0)>0|(h|0)==0&(f[a>>2]|0)>>>0>0){u=b;return 1}f[d>>2]=f[g+4>>2];f[c>>2]=f[d>>2];Me(g,c,e,e+4|0)|0;u=b;return 1}function Vj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;ll(g,d&1);d=Ai(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}gh(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function Wj(a){a=a|0;if(!a)return;Ej(a+24|0,f[a+28>>2]|0);zj(a+12|0,f[a+16>>2]|0);Ej(a,f[a+4>>2]|0);Oq(a);return}function Xj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;ll(g,d);d=Ai(a,c)|0;c=d+11|0;if((b[c>>0]|0)<0){b[f[d>>2]>>0]=0;f[d+4>>2]=0}else{b[d>>0]=0;b[c>>0]=0}gh(d,0);f[d>>2]=f[g>>2];f[d+4>>2]=f[g+4>>2];f[d+8>>2]=f[g+8>>2];u=e;return}function Yj(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0,i=0,j=0,k=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=-1;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}a=e+28|0;if((b[a+11>>0]|0)<0)k=f[a>>2]|0;else k=a;g=Sj(k)|0;h=(g|0)==-1;i=(g|0)!=0;j=h?d:i;return j|0}function Zj(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0,k=0;d=u;u=u+16|0;e=d;if(c>>>0>10){g=0;u=d;return g|0}h=ln(48)|0;f[e>>2]=h;f[e+8>>2]=-2147483600;f[e+4>>2]=33;i=h;j=15987;k=i+33|0;do{b[i>>0]=b[j>>0]|0;i=i+1|0;j=j+1|0}while((i|0)<(k|0));b[h+33>>0]=0;Xj(a,e,c);if((b[e+11>>0]|0)<0)Oq(f[e>>2]|0);g=1;u=d;return g|0}function _j(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=f[b>>2]|0;if((c|0)==-1)return 1;b=c*3|0;if((b|0)==-1)return 1;c=f[a>>2]|0;a=f[c+(b<<2)>>2]|0;d=b+1|0;e=((d>>>0)%3|0|0)==0?b+-2|0:d;if((e|0)==-1)g=-1;else g=f[c+(e<<2)>>2]|0;e=(((b>>>0)%3|0|0)==0?2:-1)+b|0;if((e|0)==-1)h=-1;else h=f[c+(e<<2)>>2]|0;if((a|0)==(g|0))return 1;else return (a|0)==(h|0)|(g|0)==(h|0)|0;return 0}function $j(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0,j=0,k=0;d=0;while(1){if((h[16654+d>>0]|0)==(a|0)){e=2;break}g=d+1|0;if((g|0)==87){i=16742;j=87;e=5;break}else d=g}if((e|0)==2)if(!d)k=16742;else{i=16742;j=d;e=5}if((e|0)==5)while(1){e=0;d=i;do{a=d;d=d+1|0}while((b[a>>0]|0)!=0);j=j+-1|0;if(!j){k=d;break}else{i=d;e=5}}return jq(k,f[c+20>>2]|0)|0}function ak(a,b){a=+a;b=b|0;var c=0,d=0,e=0,g=0.0,h=0.0,i=0,j=0.0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;e=Yn(c|0,d|0,52)|0;switch(e&2047){case 0:{if(a!=0.0){g=+ak(a*18446744073709551616.0,b);h=g;i=(f[b>>2]|0)+-64|0}else{h=a;i=0}f[b>>2]=i;j=h;break}case 2047:{j=a;break}default:{f[b>>2]=(e&2047)+-1022;f[s>>2]=c;f[s+4>>2]=d&-2146435073|1071644672;j=+p[s>>3]}}return +j}function bk(a,b){a=+a;b=b|0;var c=0.0,d=0,e=0,g=0.0,h=0;if((b|0)<=1023)if((b|0)<-1022){c=a*2.2250738585072014e-308;d=(b|0)<-2044;e=b+2044|0;g=d?c*2.2250738585072014e-308:c;h=d?((e|0)>-1022?e:-1022):b+1022|0}else{g=a;h=b}else{c=a*8988465674311579538646525.0e283;e=(b|0)>2046;d=b+-2046|0;g=e?c*8988465674311579538646525.0e283:c;h=e?((d|0)<1023?d:1023):b+-1023|0}b=Tn(h+1023|0,0,52)|0;h=I;f[s>>2]=b;f[s+4>>2]=h;return +(g*+p[s>>3])}function ck(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;if(!(f[a+80>>2]|0)){b=0;return b|0}c=a+8|0;d=a+12|0;a=f[c>>2]|0;if(((f[d>>2]|0)-a|0)>0){e=0;g=a}else{b=1;return b|0}while(1){a=f[g+(e<<2)>>2]|0;e=e+1|0;if(!(Gl(a,a)|0)){b=0;h=5;break}g=f[c>>2]|0;if((e|0)>=((f[d>>2]|0)-g>>2|0)){b=1;h=5;break}}if((h|0)==5)return b|0;return 0}function dk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=a+36|0;d=a+40|0;e=f[c>>2]|0;if((f[d>>2]|0)==(e|0)){g=1;return g|0}h=a+60|0;a=0;i=e;while(1){e=f[i+(a<<2)>>2]|0;a=a+1|0;if(!(Sa[f[(f[e>>2]|0)+20>>2]&31](e,h,b)|0)){g=0;j=5;break}i=f[c>>2]|0;if(a>>>0>=(f[d>>2]|0)-i>>2>>>0){g=1;j=5;break}}if((j|0)==5)return g|0;return 0}function ek(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0;c=a+36|0;d=a+40|0;a=f[c>>2]|0;if((f[d>>2]|0)==(a|0)){e=1;return e|0}else{g=0;h=a}while(1){a=f[h+(g<<2)>>2]|0;g=g+1|0;if(!(Ra[f[(f[a>>2]|0)+24>>2]&127](a,b)|0)){e=0;i=4;break}h=f[c>>2]|0;if(g>>>0>=(f[d>>2]|0)-h>>2>>>0){e=1;i=4;break}}if((i|0)==4)return e|0;return 0}function fk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;f[a>>2]=0;c=a+4|0;f[c>>2]=0;f[a+8>>2]=0;d=b+4|0;e=(f[d>>2]|0)-(f[b>>2]|0)|0;g=e>>2;if(!g)return;if(g>>>0>1073741823)aq(a);h=ln(e)|0;f[c>>2]=h;f[a>>2]=h;f[a+8>>2]=h+(g<<2);g=f[b>>2]|0;b=(f[d>>2]|0)-g|0;if((b|0)<=0)return;kh(h|0,g|0,b|0)|0;f[c>>2]=h+(b>>>2<<2);return}function gk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;c=a+8|0;d=f[a>>2]|0;if((f[c>>2]|0)-d>>2>>>0>=b>>>0)return;e=a+4|0;if(b>>>0>1073741823){g=ra(8)|0;Oo(g,16035);f[g>>2]=7256;va(g|0,1112,110)}g=(f[e>>2]|0)-d|0;h=ln(b<<2)|0;if((g|0)>0)kh(h|0,d|0,g|0)|0;f[a>>2]=h;f[e>>2]=h+(g>>2<<2);f[c>>2]=h+(b<<2);if(!d)return;Oq(d);return}function hk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0,i=0;b=a+36|0;c=a+40|0;d=f[b>>2]|0;if((f[c>>2]|0)==(d|0)){e=1;return e|0}g=a+60|0;a=0;h=d;while(1){d=f[h+(a<<2)>>2]|0;a=a+1|0;if(!(Ra[f[(f[d>>2]|0)+16>>2]&127](d,g)|0)){e=0;i=5;break}h=f[b>>2]|0;if(a>>>0>=(f[c>>2]|0)-h>>2>>>0){e=1;i=5;break}}if((i|0)==5)return e|0;return 0}function ik(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0;d=f[a+176>>2]|0;e=f[a+172>>2]|0;a=e;if((d|0)==(e|0))return 0;g=(d-e|0)/136|0;e=0;while(1){if((f[a+(e*136|0)>>2]|0)==(c|0)){h=4;break}d=e+1|0;if(d>>>0>>0)e=d;else{h=6;break}}if((h|0)==4)return ((b[a+(e*136|0)+100>>0]|0)==0?0:a+(e*136|0)+4|0)|0;else if((h|0)==6)return 0;return 0}function jk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,h=0,i=0,j=0;d=u;u=u+16|0;e=d;g=ln(16)|0;f[e>>2]=g;f[e+8>>2]=-2147483632;f[e+4>>2]=15;h=g;i=14479;j=h+15|0;do{b[h>>0]=b[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));b[g+15>>0]=0;Xj(a,e,c);if((b[e+11>>0]|0)>=0){u=d;return}Oq(f[e>>2]|0);u=d;return}function kk(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[a+72>>2]|0;if(!c){d=0;return d|0}f[c+4>>2]=a+60;if(!(Qa[f[(f[c>>2]|0)+12>>2]&127](c)|0)){d=0;return d|0}if(!(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)){d=0;return d|0}if(!(Ra[f[(f[a>>2]|0)+44>>2]&127](a,b)|0)){d=0;return d|0}d=Ra[f[(f[a>>2]|0)+48>>2]&127](a,b)|0;return d|0}function lk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;f[a>>2]=0;d=a+4|0;f[d>>2]=0;f[a+8>>2]=0;if(!b)return;if(b>>>0>357913941)aq(a);e=ln(b*12|0)|0;f[d>>2]=e;f[a>>2]=e;f[a+8>>2]=e+(b*12|0);a=b;b=e;do{fk(b,c);b=(f[d>>2]|0)+12|0;f[d>>2]=b;a=a+-1|0}while((a|0)!=0);return}function mk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0;c=f[b>>2]|0;if(!c){d=0;return d|0}e=a+44|0;g=f[e>>2]|0;if(g>>>0<(f[a+48>>2]|0)>>>0){f[b>>2]=0;f[g>>2]=c;f[e>>2]=(f[e>>2]|0)+4;d=1;return d|0}else{Ug(a+40|0,b);d=1;return d|0}return 0}function nk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3564;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3588;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function ok(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3344;f[a+40>>2]=1196;b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a>>2]=1476;b=a+36|0;d=f[b>>2]|0;f[b>>2]=0;if(!d){Ni(a);Oq(a);return}Va[f[(f[d>>2]|0)+4>>2]&127](d);Ni(a);Oq(a);return}function pk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0,i=0;f[c>>2]=2;d=a+4|0;a=c+8|0;e=f[a>>2]|0;g=(f[c+12>>2]|0)-e|0;if(g>>>0<4294967292){Lk(a,g+4|0,0);i=f[a>>2]|0}else i=e;e=i+g|0;g=h[d>>0]|h[d+1>>0]<<8|h[d+2>>0]<<16|h[d+3>>0]<<24;b[e>>0]=g;b[e+1>>0]=g>>8;b[e+2>>0]=g>>16;b[e+3>>0]=g>>24;return}function qk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3612;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3636;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function rk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2188;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c){Oq(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c);Oq(a);return}function sk(a,c,d){a=a|0;c=c|0;d=$(d);var e=0,g=Oa,h=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=d;return $(g)}a=e+28|0;if((b[a+11>>0]|0)<0)h=f[a>>2]|0;else h=a;g=$(+Iq(h));return $(g)}function tk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=u;u=u+16|0;c=b;d=c;f[d>>2]=0;f[d+4>>2]=0;qf(a,2,c);c=f[a+12>>2]|0;d=a+16|0;e=f[d>>2]|0;if((e|0)==(c|0)){g=a+24|0;f[g>>2]=0;h=a+28|0;f[h>>2]=0;u=b;return}f[d>>2]=e+(~((e+-4-c|0)>>>2)<<2);g=a+24|0;f[g>>2]=0;h=a+28|0;f[h>>2]=0;u=b;return}function uk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0,i=0,j=0;c=f[a+176>>2]|0;d=f[a+172>>2]|0;e=d;a:do if((c|0)!=(d|0)){g=(c-d|0)/136|0;h=0;while(1){if((f[e+(h*136|0)>>2]|0)==(b|0))break;i=h+1|0;if(i>>>0>>0)h=i;else break a}j=e+(h*136|0)+104|0;return j|0}while(0);j=a+40|0;return j|0}function vk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3564;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3588;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b)return;Oq(b);return}function wk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1768;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c){Oq(a);return}b=a+36|0;d=f[b>>2]|0;if((d|0)!=(c|0))f[b>>2]=d+(~((d+-4-c|0)>>>2)<<2);Oq(c);Oq(a);return}function xk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3344;f[a+40>>2]=1196;b=f[a+48>>2]|0;if(b|0){c=a+52|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a>>2]=1476;b=a+36|0;d=f[b>>2]|0;f[b>>2]=0;if(!d){Ni(a);return}Va[f[(f[d>>2]|0)+4>>2]&127](d);Ni(a);return}function yk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,g=0,h=0;Nc(a,b);if((b|0)<=-1)return;c=a+88|0;d=f[c>>2]|0;e=f[a+84>>2]|0;if((d-e>>2|0)<=(b|0))return;a=e+(b<<2)|0;b=a+4|0;e=d-b|0;g=e>>2;if(!g)h=d;else{im(a|0,b|0,e|0)|0;h=f[c>>2]|0}e=a+(g<<2)|0;if((h|0)==(e|0))return;f[c>>2]=h+(~((h+-4-e|0)>>>2)<<2);return}function zk(a){a=a|0;var b=0,c=0,d=0,e=0,g=0,h=0;b=f[a+32>>2]|0;c=f[a+36>>2]|0;if((b|0)==(c|0)){d=1;return d|0}e=a+8|0;g=a+44|0;a=b;while(1){b=f[(f[e>>2]|0)+(f[a>>2]<<2)>>2]|0;a=a+4|0;if(!(Ra[f[(f[b>>2]|0)+20>>2]&127](b,f[g>>2]|0)|0)){d=0;h=5;break}if((a|0)==(c|0)){d=1;h=5;break}}if((h|0)==5)return d|0;return 0}function Ak(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=3612;b=f[a+64>>2]|0;if(b|0){c=a+68|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}f[a+12>>2]=3636;b=f[a+32>>2]|0;if(b|0)Oq(b);b=f[a+20>>2]|0;if(!b)return;Oq(b);return}function Bk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0,i=0.0;d=u;u=u+128|0;e=d;g=e;h=g+124|0;do{f[g>>2]=0;g=g+4|0}while((g|0)<(h|0));g=e+4|0;f[g>>2]=a;h=e+8|0;f[h>>2]=-1;f[e+44>>2]=a;f[e+76>>2]=-1;Ym(e,0);i=+Rc(e,c,1);c=(f[g>>2]|0)-(f[h>>2]|0)+(f[e+108>>2]|0)|0;if(b|0)f[b>>2]=c|0?a+c|0:a;u=d;return +i}function Ck(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var g=0,h=0;a=c+16|0;g=f[a>>2]|0;do if(g){if((g|0)!=(d|0)){h=c+36|0;f[h>>2]=(f[h>>2]|0)+1;f[c+24>>2]=2;b[c+54>>0]=1;break}h=c+24|0;if((f[h>>2]|0)==2)f[h>>2]=e}else{f[a>>2]=d;f[c+24>>2]=e;f[c+36>>2]=1}while(0);return}function Dk(a){a=a|0;var b=0,c=0;f[a>>2]=2188;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Ek(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=a+20|0;c=a+28|0;if((f[d>>2]|0)>>>0>(f[c>>2]|0)>>>0)Sa[f[a+36>>2]&31](a,0,0)|0;f[a+16>>2]=0;f[c>>2]=0;f[d>>2]=0;d=f[a>>2]|0;if(!(d&4)){c=(f[a+44>>2]|0)+(f[a+48>>2]|0)|0;f[a+8>>2]=c;f[a+4>>2]=c;e=d<<27>>31}else{f[a>>2]=d|32;e=-1}return e|0}function Fk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=Rg(a,c)|0;if((d|0)==(a+4|0)){e=0;return e|0}a=d+28|0;if((b[a+11>>0]|0)<0)g=f[a>>2]|0;else g=a;e=((Sj(g)|0)+1|0)>>>0>1;return e|0}function Gk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=6152;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+84>>2]|0;if(!b){Og(a);Oq(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b);Og(a);Oq(a);return}function Hk(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,g=0,h=0;e=Rg(a,c)|0;if((e|0)==(a+4|0)){g=d;return g|0}d=e+28|0;if((b[d+11>>0]|0)<0)h=f[d>>2]|0;else h=d;g=Sj(h)|0;return g|0}function Ik(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b>>31|((b|0)<0?-1:0)<<1;f=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;g=d>>31|((d|0)<0?-1:0)<<1;h=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;i=Xn(e^a|0,f^b|0,e|0,f|0)|0;b=I;a=g^e;e=h^f;return Xn((Ld(i,b,Xn(g^c|0,h^d|0,g|0,h|0)|0,I,0)|0)^a|0,I^e|0,a|0,e|0)|0}function Jk(a){a=a|0;var b=0,c=0;f[a>>2]=1768;b=f[a+76>>2]|0;if(b|0)Oq(b);b=a+68|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Mq(c);f[a>>2]=1544;c=f[a+32>>2]|0;if(!c)return;b=a+36|0;a=f[b>>2]|0;if((a|0)!=(c|0))f[b>>2]=a+(~((a+-4-c|0)>>>2)<<2);Oq(c);return}function Kk(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0,i=0,j=0;f[a>>2]=b;h=b+16|0;i=f[h+4>>2]|0;j=a+8|0;f[j>>2]=f[h>>2];f[j+4>>2]=i;i=b+24|0;b=f[i+4>>2]|0;j=a+16|0;f[j>>2]=f[i>>2];f[j+4>>2]=b;b=a+40|0;f[b>>2]=c;f[b+4>>2]=d;d=a+48|0;f[d>>2]=e;f[d+4>>2]=g;return}function Lk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;h=e;e=d;if(g>>>0>=b>>>0){if(g>>>0>b>>>0?(d=h+b|0,(d|0)!=(e|0)):0)f[c>>2]=d}else Fi(a,b-g|0);g=a+24|0;a=g;b=Vn(f[a>>2]|0,f[a+4>>2]|0,1,0)|0;a=g;f[a>>2]=b;f[a+4>>2]=I;return}function Mk(a,c){a=a|0;c=c|0;var d=0,e=0,g=0;d=Rg(a,c)|0;if((d|0)==(a+4|0)){e=-1;return e|0}a=d+28|0;if((b[a+11>>0]|0)<0)g=f[a>>2]|0;else g=a;e=Sj(g)|0;return e|0}function Nk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=6152;b=f[a+96>>2]|0;if(b|0){c=a+100|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~(((d+-12-b|0)>>>0)/12|0)*12|0);Oq(b)}b=f[a+84>>2]|0;if(!b){Og(a);return}d=a+88|0;c=f[d>>2]|0;if((c|0)!=(b|0))f[d>>2]=c+(~((c+-4-b|0)>>>2)<<2);Oq(b);Og(a);return}function Ok(a){a=a|0;var c=0,d=0,e=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=1;c=a+68|0;d=a+28|0;e=d+40|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(e|0));f[c>>2]=a;c=a+72|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;f[c+20>>2]=0;return}function Pk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2244;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Qk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=u;u=u+256|0;g=f;if((c|0)>(d|0)&(e&73728|0)==0){e=c-d|0;sj(g|0,b<<24>>24|0,(e>>>0<256?e:256)|0)|0;if(e>>>0>255){b=c-d|0;d=e;do{Xo(a,g,256);d=d+-256|0}while(d>>>0>255);h=b&255}else h=e;Xo(a,g,h)}u=f;return}function Rk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1824;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Sk(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;var h=0;if(fp(a,f[b+8>>2]|0,g)|0)qj(0,b,c,d,e);else{h=f[a+8>>2]|0;_a[f[(f[h>>2]|0)+20>>2]&3](h,b,c,d,e,g)}return}function Tk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=2300;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Uk(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1880;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Vk(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;a:do if(!d)e=0;else{f=a;g=d;h=c;while(1){i=b[f>>0]|0;j=b[h>>0]|0;if(i<<24>>24!=j<<24>>24)break;g=g+-1|0;if(!g){e=0;break a}else{f=f+1|0;h=h+1|0}}e=(i&255)-(j&255)|0}while(0);return e|0}function Wk(a){a=a|0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+24>>2]|0))return 0;if(!(f[a+28>>2]|0))return 0;if(!(f[a+32>>2]|0))return 0;else return (f[a+36>>2]|0)!=0|0;return 0}function Xk(a){a=a|0;var b=0,c=0;f[a>>2]=2244;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Yk(a){a=a|0;var c=0,d=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;c=0;while(1){if((c|0)==3)break;f[a+(c<<2)>>2]=0;c=c+1|0}if((b[a+11>>0]|0)<0)d=(f[a+8>>2]&2147483647)+-1|0;else d=10;Hj(a,d,0);return}function Zk(a){a=a|0;var b=0,c=0,d=0,e=0.0,g=0.0;b=f[a+8>>2]|0;if((b|0)<2){c=0;d=0;I=c;return d|0}e=+(b|0);g=+Zg(e)*e;e=+W(+(g-+p[a>>3]));c=+K(e)>=1.0?(e>0.0?~~+Y(+J(e/4294967296.0),4294967295.0)>>>0:~~+W((e-+(~~e>>>0))/4294967296.0)>>>0):0;d=~~e>>>0;I=c;return d|0}function _k(a){a=a|0;var b=0,c=0;f[a>>2]=1824;b=f[a+76>>2]|0;if(b|0)Oq(b);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function $k(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=f[(f[a+36>>2]|0)+(e<<2)>>2]|0;e=f[b+32>>2]|0;if(e|0){d=e;return d|0}d=f[b+8>>2]|0;return d|0}function al(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1232;b=f[a+16>>2]|0;if(b|0){c=a+20|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b)}b=f[a+4>>2]|0;if(!b)return;d=a+8|0;a=f[d>>2]|0;if((a|0)!=(b|0))f[d>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function bl(a){a=a|0;var b=0,c=0;f[a>>2]=2300;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function cl(a){a=a|0;if(!(f[a+64>>2]|0))return 0;if(!(f[a+68>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function dl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(fp(a,f[b+8>>2]|0,0)|0)Ck(0,b,c,d);else{e=f[a+8>>2]|0;Ya[f[(f[e>>2]|0)+28>>2]&3](e,b,c,d)}return}function el(a){a=a|0;var b=0,c=0;f[a>>2]=1880;Fj(a+108|0);f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function fl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Ra[f[(f[d>>2]|0)+36>>2]&127](d,b)|0;return c|0}function gl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)<0){c=0;return c|0}d=f[a+4>>2]|0;if(((f[d+12>>2]|0)-(f[d+8>>2]|0)>>2|0)<=(b|0)){c=0;return c|0}d=f[(f[a+8>>2]|0)+(f[(f[a+20>>2]|0)+(b<<2)>>2]<<2)>>2]|0;c=Ra[f[(f[d>>2]|0)+32>>2]&127](d,b)|0;return c|0}function hl(a,c){a=a|0;c=c|0;var d=0,e=0,f=0,g=0;d=b[a>>0]|0;e=b[c>>0]|0;if(d<<24>>24==0?1:d<<24>>24!=e<<24>>24){f=e;g=d}else{d=c;c=a;do{c=c+1|0;d=d+1|0;a=b[c>>0]|0;e=b[d>>0]|0}while(!(a<<24>>24==0?1:a<<24>>24!=e<<24>>24));f=e;g=a}return (g&255)-(f&255)|0}function il(a,b){a=a|0;b=$(b);var c=0,d=0;c=u;u=u+16|0;d=c;Yk(d);Ei(a,d,b);Bo(d);u=c;return}function jl(a){a=a|0;var b=0,c=0,d=0,e=0,g=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((d|0)==(b|0))e=b;else{g=d+(~((d+-4-b|0)>>>2)<<2)|0;f[c>>2]=g;e=g}f[a+12>>2]=0;f[a+16>>2]=0;if(!b)return;if((e|0)!=(b|0))f[c>>2]=e+(~((e+-4-b|0)>>>2)<<2);Oq(b);return}function kl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=f[a+16>>2]|0;if(((f[a+20>>2]|0)-d>>2|0)<=(b|0)){e=-1;return e|0}g=f[d+(b<<2)>>2]|0;if((g|0)<0){e=-1;return e|0}e=f[(f[(f[(f[a+36>>2]|0)+(g<<2)>>2]|0)+16>>2]|0)+(c<<2)>>2]|0;return e|0}function ll(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;Yk(d);Ji(a,d,b);Bo(d);u=c;return}function ml(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0,h=0;d=u;u=u+32|0;e=d;g=d+20|0;f[e>>2]=f[a+60>>2];f[e+4>>2]=0;f[e+8>>2]=b;f[e+12>>2]=g;f[e+16>>2]=c;if((to(za(140,e|0)|0)|0)<0){f[g>>2]=-1;h=-1}else h=f[g>>2]|0;u=d;return h|0}function nl(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=0;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=0;return c|0}b=f[d>>2]|0;if((b|0)==-1){c=0;return c|0}c=f[(f[a+8>>2]|0)+(b<<2)>>2]|0;return c|0}function ol(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=f[a+16>>2]|0;if(((f[a+20>>2]|0)-c>>2|0)<=(b|0)){d=0;return d|0}e=f[c+(b<<2)>>2]|0;if((e|0)<0){d=0;return d|0}b=f[(f[a+36>>2]|0)+(e<<2)>>2]|0;d=(f[b+20>>2]|0)-(f[b+16>>2]|0)>>2;return d|0}function pl(a){a=a|0;if(!(f[a+40>>2]|0))return 0;if(!(f[a+24>>2]|0))return 0;if(!(f[a+28>>2]|0))return 0;if(!(f[a+32>>2]|0))return 0;else return (f[a+36>>2]|0)!=0|0;return 0}function ql(a){a=a|0;var b=0;if(!(f[a+24>>2]|0)){b=0;return b|0}if(!(f[a+28>>2]|0)){b=0;return b|0}if(!(f[a+32>>2]|0)){b=0;return b|0}b=(f[a+36>>2]|0)!=0;return b|0}function rl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;lh(a,c);f[a>>2]=1408;c=a+72|0;d=a+36|0;a=d+36|0;do{f[d>>2]=0;d=d+4|0}while((d|0)<(a|0));d=f[b>>2]|0;f[b>>2]=0;f[c>>2]=d;return}function sl(a){a=a|0;var b=0,c=0;f[a>>2]=3148;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Oq(a);return}Mq(c);Oq(a);return}function tl(a,c){a=a|0;c=c|0;var d=0,e=0;d=a;e=c;c=d+64|0;do{f[d>>2]=f[e>>2];d=d+4|0;e=e+4|0}while((d|0)<(c|0));e=a+64|0;f[a+88>>2]=0;f[e>>2]=0;f[e+4>>2]=0;f[e+8>>2]=0;f[e+12>>2]=0;f[e+16>>2]=0;b[e+20>>0]=0;return}function ul(a,c,d,e){a=a|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;if((a|0)==0&(c|0)==0)f=d;else{g=d;d=c;c=a;while(1){a=g+-1|0;b[a>>0]=h[16636+(c&15)>>0]|0|e;c=Yn(c|0,d|0,4)|0;d=I;if((c|0)==0&(d|0)==0){f=a;break}else g=a}}return f|0}function vl(a){a=a|0;var c=0,d=0,e=0;c=a+74|0;d=b[c>>0]|0;b[c>>0]=d+255|d;d=f[a>>2]|0;if(!(d&8)){f[a+8>>2]=0;f[a+4>>2]=0;c=f[a+44>>2]|0;f[a+28>>2]=c;f[a+20>>2]=c;f[a+16>>2]=c+(f[a+48>>2]|0);e=0}else{f[a>>2]=d|32;e=-1}return e|0}function wl(a){a=a|0;if(!(f[a+60>>2]|0))return 0;if(!(f[a+44>>2]|0))return 0;if(!(f[a+48>>2]|0))return 0;if(!(f[a+52>>2]|0))return 0;else return (f[a+56>>2]|0)!=0|0;return 0}function xl(a,b){a=a|0;b=b|0;var c=0,d=0;c=f[b+88>>2]|0;if(!c){d=0;return d|0}if((f[c>>2]|0)!=2){d=0;return d|0}b=f[c+8>>2]|0;f[a+4>>2]=h[b>>0]|h[b+1>>0]<<8|h[b+2>>0]<<16|h[b+3>>0]<<24;d=1;return d|0}function yl(a){a=a|0;var b=0;if(!(f[a+44>>2]|0)){b=0;return b|0}if(!(f[a+48>>2]|0)){b=0;return b|0}if(!(f[a+52>>2]|0)){b=0;return b|0}b=(f[a+56>>2]|0)!=0;return b|0}function zl(a){a=a|0;vj(a);Oq(a);return}function Al(a){a=a|0;var b=0,c=0;f[a>>2]=2784;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){Oq(a);return}Mq(c);Oq(a);return}function Bl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+44>>2]=c;d=1;return d|0}function Cl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;c=a+4|0;d=f[c>>2]|0;e=f[a>>2]|0;g=d-e|0;if(g>>>0>>0){Fi(a,b-g|0);return}if(g>>>0<=b>>>0)return;g=e+b|0;if((g|0)==(d|0))return;f[c>>2]=g;return}function Dl(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=$(e);f[a+4>>2]=b;Zf(a+8|0,c,c+(d<<2)|0);n[a+20>>2]=e;return}function El(a,b){a=a|0;b=b|0;var c=0;if(!(Qa[f[(f[a>>2]|0)+40>>2]&127](a)|0)){c=0;return c|0}if(!(Ra[f[(f[a>>2]|0)+44>>2]&127](a,b)|0)){c=0;return c|0}c=Ra[f[(f[a>>2]|0)+48>>2]&127](a,b)|0;return c|0}function Fl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+40>>2]=c;d=1;return d|0}function Gl(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=u;u=u+16|0;d=c+4|0;e=c;f[e>>2]=0;f[d>>2]=f[e>>2];e=vc(a,b,d)|0;u=c;return e|0}function Hl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;d=f[c>>2]|0;c=a;e=b-a>>2;while(1){if(!e)break;a=(e|0)/2|0;b=c+(a<<2)|0;g=(f[b>>2]|0)>>>0>>0;c=g?b+4|0:c;e=g?e+-1-a|0:a}return c|0}function Il(a){a=a|0;var c=0;f[a>>2]=0;c=a+8|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;b[a+24>>0]=1;f[a+28>>2]=9;c=a+40|0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[a+56>>2]=-1;f[a+60>>2]=0;return}function Jl(a){a=a|0;yj(a);Oq(a);return}function Kl(a){a=a|0;var b=0;f[a>>2]=3148;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Mq(a);return}function Ll(a){a=a|0;var c=0,d=0,e=0,g=0,h=0;if(!(Aq(b[f[a>>2]>>0]|0)|0))c=0;else{d=0;while(1){e=f[a>>2]|0;g=(d*10|0)+-48+(b[e>>0]|0)|0;h=e+1|0;f[a>>2]=h;if(!(Aq(b[h>>0]|0)|0)){c=g;break}else d=g}}return c|0}function Ml(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+64>>2]=c;d=1;return d|0}function Nl(a){a=a|0;var b=0,c=0;b=f[r>>2]|0;c=b+a|0;if((a|0)>0&(c|0)<(b|0)|(c|0)<0){ea()|0;ya(12);return -1}f[r>>2]=c;if((c|0)>(da()|0)?(ca()|0)==0:0){f[r>>2]=b;ya(12);return -1}return b|0}function Ol(a,c,d){a=a|0;c=c|0;d=d|0;var e=0,f=0;if((a|0)==0&(c|0)==0)e=d;else{f=d;d=c;c=a;while(1){a=f+-1|0;b[a>>0]=c&7|48;c=Yn(c|0,d|0,3)|0;d=I;if((c|0)==0&(d|0)==0){e=a;break}else f=a}}return e|0}function Pl(a,c){a=a|0;c=c|0;var d=0;if(f[c+56>>2]|0){d=0;return d|0}if((b[c+24>>0]|0)!=3){d=0;return d|0}f[a+60>>2]=c;d=1;return d|0}function Ql(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1544;b=f[a+32>>2]|0;if(!b){Oq(a);return}c=a+36|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function Rl(a,b,c,d,e,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;g=g|0;if(fp(a,f[b+8>>2]|0,g)|0)qj(0,b,c,d,e);return}function Sl(a){a=a|0;var b=0;f[a>>2]=2784;b=f[a+56>>2]|0;if(b|0)Oq(b);b=a+48|0;a=f[b>>2]|0;f[b>>2]=0;if(!a)return;Mq(a);return}function Tl(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+56>>2]|0)-(f[e+52>>2]|0)>>2;b[d>>0]=0;qh(a+20|0,g,d);u=c;return}function Ul(a){a=a|0;Vi(a);Oq(a);return}function Vl(a){a=a|0;var b=0;switch(a|0){case 11:case 2:case 1:{b=1;break}case 4:case 3:{b=2;break}case 6:case 5:{b=4;break}case 8:case 7:{b=8;break}case 9:{b=4;break}case 10:{b=8;break}default:b=-1}return b|0}function Wl(a){a=a|0;var c=0,d=0,e=0,g=0;c=u;u=u+16|0;d=c;e=f[a+4>>2]|0;g=(f[e+28>>2]|0)-(f[e+24>>2]|0)>>2;b[d>>0]=0;qh(a+20|0,g,d);u=c;return}function Xl(){var a=0,b=0;a=ln(40)|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;n[a+16>>2]=$(1.0);b=a+20|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;n[a+36>>2]=$(1.0);return a|0}function Yl(a,b){a=+a;b=+b;var c=0,d=0,e=0;p[s>>3]=a;c=f[s>>2]|0;d=f[s+4>>2]|0;p[s>>3]=b;e=f[s+4>>2]&-2147483648|d&2147483647;f[s>>2]=c;f[s+4>>2]=e;return +(+p[s>>3])}function Zl(a,b,c){a=a|0;b=b|0;c=+c;var d=0,e=0;d=u;u=u+16|0;e=d;p[e>>3]=c;_b(a,b,e);u=d;return}function _l(a){a=a|0;f[a>>2]=3656;Qi(a+8|0);Oq(a);return}function $l(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=u;u=u+16|0;e=d;f[e>>2]=c;fc(a,b,e);u=d;return}function am(a,c){a=a|0;c=c|0;var d=0,e=0;if((a|0)!=(c|0)){d=b[c+11>>0]|0;e=d<<24>>24<0;jj(a,e?f[c>>2]|0:c,e?f[c+4>>2]|0:d&255)|0}return a|0}function bm(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=a&65535;d=b&65535;e=X(d,c)|0;f=a>>>16;a=(e>>>16)+(X(d,f)|0)|0;d=b>>>16;b=X(d,c)|0;return (I=(a>>>16)+(X(d,f)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|e&65535|0)|0}function cm(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=Gj(b)|0;d=ln(c+13|0)|0;f[d>>2]=c;f[d+4>>2]=c;f[d+8>>2]=0;e=Fp(d)|0;kh(e|0,b|0,c+1|0)|0;f[a>>2]=e;return}function dm(a,b){a=a|0;b=b|0;var c=0,d=0;if((b|0)==-1|(b|0)>4){c=-1;return c|0}d=f[a+20+(b*12|0)>>2]|0;if(((f[a+20+(b*12|0)+4>>2]|0)-d|0)<=0){c=-1;return c|0}c=f[d>>2]|0;return c|0}function em(a){a=a|0;Yi(a);Oq(a);return}function fm(a){a=a|0;f[a>>2]=3656;Qi(a+8|0);return}function gm(a){a=a|0;var b=0,c=0;f[a>>2]=1544;b=f[a+32>>2]|0;if(!b)return;c=a+36|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function hm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(fp(a,f[b+8>>2]|0,0)|0)Ck(0,b,c,d);return}function im(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;if((c|0)<(a|0)&(a|0)<(c+d|0)){e=a;c=c+d|0;a=a+d|0;while((d|0)>0){a=a-1|0;c=c-1|0;d=d-1|0;b[a>>0]=b[c>>0]|0}a=e}else kh(a,c,d)|0;return a|0}function jm(a){a=a|0;var b=0,c=0,d=0;f[a>>2]=1196;b=f[a+8>>2]|0;if(!b){Oq(a);return}c=a+12|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);Oq(b);Oq(a);return}function km(a){a=a|0;var b=0;f[a>>2]=3204;b=f[a+56>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function lm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=u;u=u+16|0;e=d;f[e>>2]=f[c>>2];g=Sa[f[(f[a>>2]|0)+16>>2]&31](a,b,e)|0;if(g)f[c>>2]=f[e>>2];u=d;return g&1|0}function mm(a,b){a=a|0;b=b|0;var c=0;if(b>>>0>=2){c=0;return c|0}f[a+28>>2]=b;c=1;return c|0}function nm(a){a=a|0;var b=0,c=0;f[a>>2]=3408;b=a+56|0;c=f[b>>2]|0;f[b>>2]=0;if(!c){mj(a);return}Va[f[(f[c>>2]|0)+4>>2]&127](c);mj(a);return}function om(){var a=0,b=0;a=sn()|0;if((a|0?(b=f[a>>2]|0,b|0):0)?(a=b+48|0,(f[a>>2]&-256|0)==1126902528?(f[a+4>>2]|0)==1129074247:0):0)Ho(f[b+12>>2]|0);Ho(Qp()|0)}function pm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,6)|0}function qm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Pf(a,b,c,d,e,f,4)|0}function rm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Wf(a,b,c,d,e,f,2)|0}function sm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Pf(a,b,c,d,e,f,3)|0}function tm(a){a=a|0;var b=0;f[a>>2]=2840;b=f[a+56>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function um(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Wf(a,b,c,d,e,f,1)|0}function vm(a){a=a|0;var c=0;c=b[w+(a&255)>>0]|0;if((c|0)<8)return c|0;c=b[w+(a>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=b[w+(a>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (b[w+(a>>>24)>>0]|0)+24|0}function wm(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0;if(!a){c=0.0;return +c}if((b|0)==0|(a|0)==(b|0)){c=0.0;return +c}d=+(b>>>0)/+(a>>>0);e=1.0-d;f=d*+Zg(d);c=-(f+e*+Zg(e));return +c}function xm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if((b|0)>0)d=0;else return;do{e=f[a+(d<<2)>>2]|0;f[c+(d<<2)>>2]=e<<1^e>>31;d=d+1|0}while((d|0)!=(b|0));return}function ym(a){a=a|0;var b=0;zo(a);f[a>>2]=3344;f[a+40>>2]=1196;f[a+44>>2]=-1;b=a+48|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function zm(a,c){a=a|0;c=c|0;var d=0;b[c+84>>0]=1;a=f[c+68>>2]|0;d=c+72|0;c=f[d>>2]|0;if((c|0)==(a|0))return 1;f[d>>2]=c+(~((c+-4-a|0)>>>2)<<2);return 1}function Am(a){a=a|0;var b=0,c=0;if(pq(a)|0?(b=Mp(f[a>>2]|0)|0,a=b+8|0,c=f[a>>2]|0,f[a>>2]=c+-1,(c+-1|0)<0):0)Oq(b);return}function Bm(a){a=a|0;var b=0,c=0;b=f[a+16>>2]|0;c=(((f[a+12>>2]|0)+1-b|0)/64|0)+b<<3;a=b<<3;b=Vn(c|0,((c|0)<0)<<31>>31|0,a|0,((a|0)<0)<<31>>31|0)|0;return b|0}function Cm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,5)|0}function Dm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Qf(a,b,c,d,e,f,9)|0}function Em(a){a=a|0;var b=0;f[a>>2]=3204;b=f[a+56>>2]|0;if(!b)return;Oq(b);return}function Fm(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+36|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);Ni(a);Oq(a);return}function Gm(a){a=a|0;var b=0,c=0;f[a>>2]=1196;b=f[a+8>>2]|0;if(!b)return;c=a+12|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Hm(a){a=a|0;var c=0;f[a>>2]=1352;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=-1;c=a+16|0;f[a+32>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;b[c+12>>0]=0;return}function Im(a){a=a|0;var b=0;f[a>>2]=2840;b=f[a+56>>2]|0;if(!b)return;Oq(b);return}function Jm(a){a=a|0;var b=0,c=0;f[a>>2]=1476;b=a+36|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);Ni(a);return}function Km(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=$(f);Fg(a,b,c,d,e,f);return}function Lm(a){a=a|0;var b=0,c=0;f[a>>2]=3408;b=a+56|0;c=f[b>>2]|0;f[b>>2]=0;if(c|0)Va[f[(f[c>>2]|0)+4>>2]&127](c);mj(a);Oq(a);return}function Mm(a){a=a|0;var b=0,c=0,d=0;b=f[a>>2]|0;c=a+4|0;d=f[c>>2]|0;if((d|0)!=(b|0))f[c>>2]=d+(~((d+-4-b|0)>>>2)<<2);f[a+12>>2]=0;f[a+16>>2]=0;return}function Nm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,g=0;d=a+20|0;e=f[d>>2]|0;g=(f[a+16>>2]|0)-e|0;a=g>>>0>c>>>0?c:g;kh(e|0,b|0,a|0)|0;f[d>>2]=(f[d>>2]|0)+a;return c|0}function Om(a){a=a|0;var b=0;f[a>>2]=3588;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function Pm(a){a=a|0;var b=0,c=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-8-b|0)>>>3)<<3);Oq(b);return}function Qm(a){a=a|0;var b=0,c=0;b=f[a>>2]|0;if(!b)return;c=a+4|0;a=f[c>>2]|0;if((a|0)!=(b|0))f[c>>2]=a+(~((a+-4-b|0)>>>2)<<2);Oq(b);return}function Rm(a,b){a=a|0;b=b|0;var c=0;c=f[b>>2]|0;return (1<<(c&31)&f[(f[a+28>>2]|0)+(c>>>5<<2)>>2]|0)!=0|0}function Sm(a,b,c){a=a|0;b=b|0;c=c|0;return Sa[f[(f[a>>2]|0)+44>>2]&31](a,b,c)|0}function Tm(a){a=a|0;var c=0;Il(a);c=a+64|0;f[a+88>>2]=0;f[c>>2]=0;f[c+4>>2]=0;f[c+8>>2]=0;f[c+12>>2]=0;f[c+16>>2]=0;b[c+20>>0]=0;return}function Um(a){a=a|0;f[a>>2]=3260;Fj(a+88|0);Oq(a);return}function Vm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((f[b+4>>2]|0)==(c|0)?(c=b+28|0,(f[c>>2]|0)!=1):0)f[c>>2]=d;return}function Wm(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;if((Ek(a)|0)==0?(Sa[f[a+32>>2]&31](a,c,1)|0)==1:0)d=h[c>>0]|0;else d=-1;u=b;return d|0}function Xm(a){a=a|0;var b=0;f[a>>2]=3636;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b){Oq(a);return}Oq(b);Oq(a);return}function Ym(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;f[a+104>>2]=b;c=f[a+8>>2]|0;d=f[a+4>>2]|0;e=c-d|0;f[a+108>>2]=e;f[a+100>>2]=(b|0)!=0&(e|0)>(b|0)?d+b|0:c;return}function Zm(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;return}function _m(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=$(f);Km(a,b,c,d,e,f);return}function $m(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return pm(a,b,c,d,e,f)|0}function an(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return qm(a,b,c,d,e,f)|0}function bn(a,b,c){a=a|0;b=b|0;c=c|0;f[a+4>>2]=b;f[a+8>>2]=f[(f[(f[b+4>>2]|0)+8>>2]|0)+(c<<2)>>2];f[a+12>>2]=c;return 1}function cn(a){a=a|0;var b=0,c=0;if(!a)return;b=f[a>>2]|0;if(b|0){c=a+4|0;if((f[c>>2]|0)!=(b|0))f[c>>2]=b;Oq(b)}Oq(a);return}function dn(a){a=a|0;f[a>>2]=2896;Fj(a+88|0);Oq(a);return}function en(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return rm(a,b,c,d,e,f)|0}function fn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return sm(a,b,c,d,e,f)|0}function gn(a){a=a|0;f[a>>2]=3260;Fj(a+88|0);return}function hn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e|0;Ld(a,b,c,d,g)|0;u=e;return (I=f[g+4>>2]|0,f[g>>2]|0)|0}function jn(a){a=a|0;var b=0;eo(a);f[a>>2]=6152;b=a+84|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;f[b+16>>2]=0;f[b+20>>2]=0;return}function kn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return um(a,b,c,d,e,f)|0}function ln(a){a=a|0;var b=0,c=0;b=(a|0)==0?1:a;while(1){a=$a(b)|0;if(a|0){c=a;break}a=Op()|0;if(!a){c=0;break}Ua[a&3]()}return c|0}function mn(a,b,c){a=a|0;b=b|0;c=c|0;ac(a,b,c);return}function nn(a){a=a|0;var b=0;f[a>>2]=3588;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b)return;Oq(b);return}function on(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Cm(a,b,c,d,e,f)|0}function pn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Dm(a,b,c,d,e,f)|0}function qn(a){a=a|0;f[a>>2]=2896;Fj(a+88|0);return}function rn(a){a=a|0;var b=0,c=0,d=0;b=u;u=u+16|0;c=b;d=Qq(f[a+60>>2]|0)|0;f[c>>2]=d;d=to(Ba(6,c|0)|0)|0;u=b;return d|0}function sn(){var a=0,b=0;a=u;u=u+16|0;if(!(Ka(19700,3)|0)){b=Ia(f[4926]|0)|0;u=a;return b|0}else Hn(18840,a);return 0}function tn(a){a=a|0;var b=0;f[a>>2]=3636;b=f[a+20>>2]|0;if(b|0)Oq(b);b=f[a+8>>2]|0;if(!b)return;Oq(b);return}function un(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;a=c;c=bm(e,a)|0;f=I;return (I=(X(b,a)|0)+(X(d,e)|0)+f|f&0,c|0|0)|0}function vn(a,b){a=a|0;b=b|0;lh(a,b);f[a>>2]=1292;b=a+36|0;a=b+40|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function wn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;f[a+24>>2]=0;f[a+28>>2]=0;return}function xn(a){a=a|0;var b=0;b=u;u=u+16|0;yc(a);if(!(La(f[4926]|0,0)|0)){u=b;return}else Hn(18939,b)}function yn(a){a=a|0;var b=0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;b=a+16|0;f[b>>2]=0;f[b+4>>2]=0;f[b+8>>2]=0;f[b+12>>2]=0;return}function zn(a,b){a=a|0;b=b|0;return vg(a+40|0,b)|0}function An(a,b){a=a|0;b=b|0;return lj(a,b,lq(b)|0)|0}function Bn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,g=0;e=u;u=u+16|0;g=e;f[g>>2]=d;d=Zi(a,b,c,g)|0;u=e;return d|0}function Cn(a,b){a=a|0;b=b|0;return Mj(a+40|0,b)|0}function Dn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qh(a,b,c,d)|0}function En(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return uh(a,b,c,d)|0}function Fn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+24>>2]&127](c,b)|0}function Gn(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;f[a+20>>2]=0;b[a+24>>0]=0;return}function Hn(a,b){a=a|0;b=b|0;var c=0,d=0;c=u;u=u+16|0;d=c;f[d>>2]=b;b=f[1556]|0;Ah(b,a,d)|0;Lj(10,b)|0;Ca()}function In(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;return Ta[a&31](b|0,c|0,d|0,e|0,f|0,g|0)|0}function Jn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+16>>2]&127](c,b)|0}function Kn(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+20>>2]&127](c,b)|0}function Ln(a,b){a=a|0;b=b|0;var c=0;c=f[a+56>>2]|0;return Ra[f[(f[c>>2]|0)+12>>2]&127](c,b)|0}function Mn(){var a=0;a=u;u=u+16|0;if(!(Ja(19704,113)|0)){u=a;return}else Hn(18889,a)}function Nn(a,b,c){a=a|0;b=b|0;c=c|0;Pj(a,b,c);return}function On(a){a=a|0;cf(a);Oq(a);return}function Pn(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;_a[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Qn(a,b,c){a=a|0;b=b|0;c=c|0;if(b|0)sj(a|0,(kq(c)|0)&255|0,b|0)|0;return a|0}function Rn(a){a=a|0;return 4}function Sn(a,b,c){a=a|0;b=b|0;c=c|0;return ej(0,b,c)|0}function Tn(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b<>>32-c;return a<>>0;return (I=b+d+(e>>>0>>0|0)>>>0,e|0)|0}function Wn(a,b){a=a|0;b=b|0;var c=0;if(!b)c=0;else c=Dh(f[b>>2]|0,f[b+4>>2]|0,a)|0;return (c|0?c:a)|0}function Xn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=b-d>>>0;e=b-d-(c>>>0>a>>>0|0)>>>0;return (I=e,a-c>>>0|0)|0}function Yn(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){I=b>>>c;return a>>>c|(b&(1<>>c-32|0}function Zn(a){a=a|0;var b=0;f[a>>2]=3932;b=a+4|0;a=b+44|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function _n(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return De(a,b,c,d)|0}function $n(a){a=a|0;ff(a);Oq(a);return}function ao(a,b){a=a|0;b=b|0;ji(a);f[a+36>>2]=b;f[a+40>>2]=0;return}function bo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return $i(a,b,c,d)|0}function co(a){a=a|0;return 5}function eo(a){a=a|0;var b=0;f[a>>2]=6192;b=a+4|0;a=b+80|0;do{f[b>>2]=0;b=b+4|0}while((b|0)<(a|0));return}function fo(a){a=a|0;return 6}function go(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return aj(a,b,c,d)|0}function ho(a,b,c){a=a|0;b=b|0;c=c|0;f[a+28>>2]=b;f[a+32>>2]=c;return 1}function io(a,b){a=a|0;b=b|0;ji(a);f[a+36>>2]=b;f[a+40>>2]=b;return}function jo(a,b,c){a=a|0;b=b|0;c=c|0;Nn(a,b,c);return}function ko(a){a=a|0;var b=0;b=f[a+56>>2]|0;return Qa[f[(f[b>>2]|0)+28>>2]&127](b)|0}function lo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ve(a,b,c,d,1);return}function mo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ve(a,b,c,d,0);return}function no(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Xg(a,b,c,d)|0}function oo(a,b,c){a=a|0;b=b|0;c=c|0;return fi(a,b,c)|0}function po(a){a=a|0;var b=0;b=f[a+56>>2]|0;return Qa[f[(f[b>>2]|0)+32>>2]&127](b)|0}function qo(a,b,c){a=a|0;b=b|0;c=c|0;return ej(a,b,c)|0}function ro(a,b,c){a=a|0;b=b|0;c=c|0;return Sn(a,b,c)|0}function so(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Za[a&3](b|0,c|0,d|0,e|0,f|0)}function to(a){a=a|0;var b=0,c=0;if(a>>>0>4294963200){b=Vq()|0;f[b>>2]=0-a;c=-1}else c=a;return c|0}function uo(a,b,c){a=a|0;b=b|0;c=c|0;Li(a,b,c);return}function vo(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;f[a+12>>2]=0;f[a+16>>2]=0;return}function wo(a,b){a=a|0;b=b|0;f[a+8>>2]=b;f[a+12>>2]=-1;return 1}function xo(a,b){a=a|0;b=b|0;f[a+52>>2]=b;ip(a,b);return}function yo(a){a=+a;var b=0;p[s>>3]=a;b=f[s>>2]|0;I=f[s+4>>2]|0;return b|0}function zo(a){a=a|0;Hm(a);f[a>>2]=1476;f[a+36>>2]=0;return}function Ao(a){a=a|0;var b=0;if(!a)b=0;else b=(Eh(a,1056,1144,0)|0)!=0&1;return b|0}function Bo(a){a=a|0;if((b[a+11>>0]|0)<0)Oq(f[a>>2]|0);return}function Co(a){a=a|0;if(!a)return;Va[f[(f[a>>2]|0)+4>>2]&127](a);return}function Do(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;Ya[a&3](b|0,c|0,d|0,e|0)}function Eo(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)im(a|0,b|0,c|0)|0;return a|0}function Fo(a,b,c){a=a|0;b=b|0;c=c|0;if(c|0)kh(a|0,b|0,c|0)|0;return a|0}function Go(a,b){a=a|0;b=b|0;return -1}function Ho(a){a=a|0;var b=0;b=u;u=u+16|0;Ua[a&3]();Hn(18992,b)}function Io(a){a=a|0;Lh(a);Oq(a);return}function Jo(a,b,c){a=a|0;b=b|0;c=c|0;Ro(a,b,c);return}function Ko(a,b,c){a=a|0;b=$(b);c=c|0;f[a+4>>2]=c;n[a>>2]=b;return}function Lo(a){a=a|0;To(a);f[a>>2]=3408;f[a+56>>2]=0;return}function Mo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Sa[a&31](b|0,c|0,d|0)|0}function No(a,b){a=a|0;b=b|0;return (wp(a,b)|0)<<24>>24|0}function Oo(a,b){a=a|0;b=b|0;f[a>>2]=7236;cm(a+4|0,b);return}function Po(a,b){a=a|0;b=b|0;var c=0;if(!a)c=0;else c=Pi(a,b,0)|0;return c|0}function Qo(a){a=a|0;return f[a+12>>2]|0}function Ro(a,b,c){a=a|0;b=b|0;c=c|0;uo(a,b,c);return}function So(){var a=0;a=ln(64)|0;Il(a);return a|0}function To(a){a=a|0;Zn(a);f[a>>2]=3764;f[a+52>>2]=0;return}function Uo(a){a=a|0;if(!a)return;bj(a);Oq(a);return}function Vo(a){a=a|0;return Qa[f[(f[a>>2]|0)+60>>2]&127](a)|0}function Wo(a){a=a|0;return f[a+4>>2]|0}function Xo(a,b,c){a=a|0;b=b|0;c=c|0;if(!(f[a>>2]&32))qi(b,c,a)|0;return}function Yo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Xa[a&15](b|0,c|0,d|0)}function Zo(){var a=0;a=ln(96)|0;Tm(a);return a|0}function _o(a){a=a|0;var b=0;b=u;u=u+a|0;u=u+15&-16;return b|0}function $o(a){a=a|0;var b=0;b=(Jq()|0)+188|0;return $j(a,f[b>>2]|0)|0}function ap(a){a=a|0;return ((f[a+100>>2]|0)-(f[a+96>>2]|0)|0)/12|0|0}function bp(a,b){a=a|0;b=b|0;kp(a,b);return}function cp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(3);return 0}function dp(){var a=0;a=ln(12)|0;op(a);return a|0}function ep(a){a=a|0;Ni(a);Oq(a);return}function fp(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function gp(a,b){a=a|0;b=b|0;var c=0;c=sp(a|0)|0;return ((b|0)==0?a:c)|0}function hp(a){a=a|0;return (f[a+12>>2]|0)-(f[a+8>>2]|0)>>2|0}function ip(a,b){a=a|0;b=b|0;f[a+4>>2]=b;return}function jp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ld(a,b,c,d,0)|0}function kp(a,b){a=a|0;b=b|0;jk(a,b);return}function lp(a){a=a|0;f[a+4>>2]=0;f[a+8>>2]=0;f[a>>2]=a+4;return}function mp(){var a=0;a=ln(84)|0;eo(a);return a|0}function np(a){a=a|0;ui(a);Oq(a);return}function op(a){a=a|0;f[a>>2]=0;f[a+4>>2]=0;f[a+8>>2]=0;return}function pp(a){a=a|0;f[a>>2]=7236;Am(a+4|0);return}function qp(a,b,c){a=a|0;b=b|0;c=c|0;return Ra[a&127](b|0,c|0)|0}function rp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(10)}function sp(a){a=a|0;return (a&255)<<24|(a>>8&255)<<16|(a>>16&255)<<8|a>>>24|0}function tp(a){a=a|0;To(a);f[a>>2]=3836;return}function up(a,c){a=a|0;c=c|0;b[a>>0]=b[c>>0]|0;return}function vp(a,b,c){a=a|0;b=b|0;c=c|0;return -1}function wp(a,c){a=a|0;c=c|0;return b[(f[a>>2]|0)+c>>0]|0}function xp(a){a=a|0;return (f[a+4>>2]|0)-(f[a>>2]|0)|0}function yp(a){a=a|0;mj(a);Oq(a);return}function zp(a){a=a|0;if(!a)return;Oq(a);return}function Ap(a){a=a|0;n[a>>2]=$(1.0);f[a+4>>2]=1;return}function Bp(a){a=a|0;b[a+28>>0]=1;return}function Cp(a,b){a=a|0;b=b|0;if(!x){x=a;y=b}}function Dp(a){a=a|0;ji(a);return}function Ep(a,b){a=a|0;b=b|0;return 1}function Fp(a){a=a|0;return a+12|0}function Gp(a,b){a=a|0;b=b|0;f[a+80>>2]=b;return}function Hp(a,b,c){a=a|0;b=b|0;c=c|0;Wa[a&7](b|0,c|0)}function Ip(){var a=0;a=ln(36)|0;qq(a);return a|0}function Jp(a){a=a|0;return gq(a+4|0)|0}function Kp(){var a=0;a=ln(108)|0;jn(a);return a|0}function Lp(a){a=a|0;return (b[a+32>>0]|0)!=0|0}function Mp(a){a=a|0;return a+-12|0}function Np(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(9)}function Op(){var a=0;a=f[4927]|0;f[4927]=a+0;return a|0}function Pp(a){a=a|0;return f[a+56>>2]|0}function Qp(){var a=0;a=f[1786]|0;f[1786]=a+0;return a|0}function Rp(a){a=a|0;Og(a);Oq(a);return}function Sp(a){a=a|0;Sq(a);Oq(a);return}function Tp(a){a=a|0;return b[a+24>>0]|0}function Up(a,b){a=a|0;b=b|0;return 0}function Vp(a){a=a|0;return f[a+40>>2]|0}function Wp(a){a=a|0;return f[a+48>>2]|0}function Xp(a,b){a=a|0;b=b|0;return Qa[a&127](b|0)|0}function Yp(a){a=a|0;return f[a+60>>2]|0}function Zp(a){a=a|0;return f[a+28>>2]|0}function _p(a){a=a|0;sa(a|0)|0;om()}function $p(a){a=a|0;pp(a);Oq(a);return}function aq(a){a=a|0;Ca()}function bq(a,b){a=a|0;b=b|0;return $(+Bk(a,b,0))}function cq(a){a=a|0;return 3}function dq(a,b){a=a|0;b=b|0;u=a;v=b}function eq(a){a=a|0;return ((a|0)==32|(a+-9|0)>>>0<5)&1|0}function fq(a){a=a|0;return f[a+80>>2]|0}function gq(a){a=a|0;return f[a>>2]|0}function hq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(8)}function iq(a,b){a=a|0;b=b|0;Va[a&127](b|0)}function jq(a,b){a=a|0;b=b|0;return Wn(a,b)|0}function kq(a){a=a|0;return a&255|0}function lq(a){a=a|0;return Gj(a)|0}function mq(a,b){a=a|0;b=b|0;return +(+Bk(a,b,1))}function nq(a,b,c){a=a|0;b=b|0;c=c|0;aa(2);return 0}function oq(a){a=a|0;return 2}function pq(a){a=a|0;return 1}function qq(a){a=a|0;Dp(a);return}function rq(a,b){a=+a;b=+b;return +(+Yl(a,b))}function sq(a,b){a=+a;b=b|0;return +(+bk(a,b))}function tq(a,b){a=+a;b=b|0;return +(+ak(a,b))}function uq(){return 3}function vq(a,b,c){a=a|0;b=b|0;c=c|0;aa(7)}function wq(){return 0}function xq(){return -1}function yq(){return ln(1)|0}function zq(){return 4}function Aq(a){a=a|0;return (a+-48|0)>>>0<10|0}function Bq(){return 1}function Cq(){return 2}function Dq(a,b){a=+a;b=+b;return +(+xd(a,b))}function Eq(a,b){a=a|0;b=b|0;aa(1);return 0}function Fq(a){a=a|0;Ha()}function Gq(a){a=a|0;Ua[a&3]()}function Hq(){ua()}function Iq(a){a=a|0;return +(+mq(a,0))}function Jq(){return Yq()|0}function Kq(a,b){a=a|0;b=b|0;aa(6)}function Lq(a){a=a|0;return ln(a)|0}function Mq(a){a=a|0;Oq(a);return}function Nq(a){a=a|0;u=a}function Oq(a){a=a|0;yc(a);return}function Pq(a){a=a|0;I=a}function Qq(a){a=a|0;return a|0}function Rq(a){a=a|0;aa(0);return 0}function Sq(a){a=a|0;return}function Tq(a){a=a|0;return 0}function Uq(){return I|0}function Vq(){return 19632}function Wq(){return u|0}function Xq(a){a=a|0;aa(5)}function Yq(){return 6352}function Zq(){aa(4)} + +// EMSCRIPTEN_END_FUNCS +var Qa=[Rq,oq,pq,pq,oq,gb,Tq,Tq,Tq,hk,kg,pq,Wo,Tq,Tq,pq,Tq,pq,pq,yl,oq,yl,cq,wl,pq,co,wl,pq,fo,cl,pq,Zp,Rn,yl,pq,yl,oq,yl,cq,wl,pq,co,wl,pq,fo,cl,pq,Zp,Rn,yl,pq,cq,Tq,Wo,pq,Tq,pq,cq,pq,ql,oq,ql,Rn,ql,cq,pl,pq,co,pl,pq,fo,Wk,pq,Zp,pq,ql,oq,ql,Rn,ql,cq,pl,pq,co,pl,pq,fo,Wk,pq,Zp,pq,oq,pq,pq,Nd,pq,Vo,Xe,mh,zk,po,ko,pb,Qo,Wo,Mg,Wg,Lf,rb,Qo,Wo,pq,Tq,Tq,zc,Ki,Tq,pq,pq,Uj,Tq,Uj,ck,rn,Jp,Rq,Rq,Rq];var Ra=[Eq,xl,nh,Ie,El,Up,Up,Up,Ep,jb,rj,wo,Ep,Ep,ti,nj,ii,kk,ol,Qj,$k,dk,ek,Te,Go,Up,ni,Up,Pl,$d,Up,Pl,nf,Up,Ml,sh,mm,Ed,Up,Pl,$d,Up,Pl,nf,Up,Ml,sh,mm,Ed,Cn,Go,Up,li,Dd,Up,Fl,Zd,Up,Fl,hf,Up,Bl,rh,mm,Dd,Up,Fl,Zd,Up,Fl,hf,Up,Bl,rh,mm,zn,Kn,Fn,Ln,Jn,dh,ik,uk,cc,ye,Rm,og,vf,wf,ah,ik,uk,bc,ye,Rm,Ep,Up,Up,of,zm,mg,of,Eq,Eq,E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itshift64Shl:Tn,_emscripten_bind_DracoInt8Array_DracoInt8Array_0:dp,_emscripten_bind_DracoInt8Array_GetValue_1:No,_emscripten_bind_DracoInt8Array___destroy___0:cn,_emscripten_bind_DracoInt8Array_size_0:xp,_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2:oo,_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3:En,_emscripten_bind_Encoder_Encoder_0:Ip,_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5:_m,_emscripten_bind_Encoder_SetAttributeQuantization_2:jo,_emscripten_bind_Encoder_SetEncodingMethod_1:bp,_emscripten_bind_Encoder_SetSpeedOptions_2:Jo,_emscripten_bind_Encoder___destroy___0:Wj,_emscripten_bind_GeometryAttribute_GeometryAttribute_0:So,_emscripten_bind_GeometryAttribute___destroy___0:zp,_emscripten_bind_MeshBuilder_AddFacesToMesh_3:no,_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5:pn,_emscripten_bind_MeshBuilder_AddFloatAttribute_5:pn,_emscripten_bind_MeshBuilder_AddInt16Attribute_5:fn,_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5:on,_emscripten_bind_MeshBuilder_AddInt32Attribute_5:on,_emscripten_bind_MeshBuilder_AddInt8Attribute_5:kn,_emscripten_bind_MeshBuilder_AddMetadataToMesh_2:ro,_emscripten_bind_MeshBuilder_AddMetadata_2:qo,_emscripten_bind_MeshBuilder_AddUInt16Attribute_5:an,_emscripten_bind_MeshBuilder_AddUInt32Attribute_5:$m,_emscripten_bind_MeshBuilder_AddUInt8Attribute_5:en,_emscripten_bind_MeshBuilder_MeshBuilder_0:yq,_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3:Dn,_emscripten_bind_MeshBuilder___destroy___0:zp,_emscripten_bind_Mesh_Mesh_0:Kp,_emscripten_bind_Mesh___destroy___0:Co,_emscripten_bind_Mesh_num_attributes_0:hp,_emscripten_bind_Mesh_num_faces_0:ap,_emscripten_bind_Mesh_num_points_0:fq,_emscripten_bind_Mesh_set_num_points_1:Gp,_emscripten_bind_MetadataBuilder_AddDoubleEntry_3:bo,_emscripten_bind_MetadataBuilder_AddIntEntry_3:go,_emscripten_bind_MetadataBuilder_AddStringEntry_3:_n,_emscripten_bind_MetadataBuilder_MetadataBuilder_0:yq,_emscripten_bind_MetadataBuilder___destroy___0:zp,_emscripten_bind_Metadata_Metadata_0:Xl,_emscripten_bind_Metadata___destroy___0:Uo,_emscripten_bind_PointAttribute_PointAttribute_0:Zo,_emscripten_bind_PointAttribute___destroy___0:Ij,_emscripten_bind_PointAttribute_attribute_type_0:Pp,_emscripten_bind_PointAttribute_byte_offset_0:Wp,_emscripten_bind_PointAttribute_byte_stride_0:Vp,_emscripten_bind_PointAttribute_data_type_0:Zp,_emscripten_bind_PointAttribute_normalized_0:Lp,_emscripten_bind_PointAttribute_num_components_0:Tp,_emscripten_bind_PointAttribute_size_0:fq,_emscripten_bind_PointAttribute_unique_id_0:Yp,_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5:pn,_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5:fn,_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5:on,_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5:kn,_emscripten_bind_PointCloudBuilder_AddMetadata_2:qo,_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5:an,_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5:$m,_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5:en,_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0:yq,_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3:Dn,_emscripten_bind_PointCloudBuilder___destroy___0:zp,_emscripten_bind_PointCloud_PointCloud_0:mp,_emscripten_bind_PointCloud___destroy___0:Co,_emscripten_bind_PointCloud_num_attributes_0:hp,_emscripten_bind_PointCloud_num_points_0:fq,_emscripten_bind_VoidPtr___destroy___0:zp,_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE:xq,_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD:wq,_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH:Bq,_emscripten_enum_draco_GeometryAttribute_Type_COLOR:Cq,_emscripten_enum_draco_GeometryAttribute_Type_GENERIC:zq,_emscripten_enum_draco_GeometryAttribute_Type_INVALID:xq,_emscripten_enum_draco_GeometryAttribute_Type_NORMAL:Bq,_emscripten_enum_draco_GeometryAttribute_Type_POSITION:wq,_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD:uq,_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING:Bq,_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING:wq,_emscripten_replace_memory:Pa,_free:yc,_i64Add:Vn,_i64Subtract:Xn,_llvm_bswap_i32:sp,_malloc:$a,_memcpy:kh,_memmove:im,_memset:sj,_sbrk:Nl,dynCall_ii:Xp,dynCall_iii:qp,dynCall_iiii:Mo,dynCall_iiiiiii:In,dynCall_v:Gq,dynCall_vi:iq,dynCall_vii:Hp,dynCall_viii:Yo,dynCall_viiii:Do,dynCall_viiiii:so,dynCall_viiiiii:Pn,establishStackSpace:dq,getTempRet0:Uq,runPostSets:Un,setTempRet0:Pq,setThrew:Cp,stackAlloc:_o,stackRestore:Nq,stackSave:Wq}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___cxa_can_catch=Module["___cxa_can_catch"]=asm["___cxa_can_catch"];var ___cxa_is_pointer_type=Module["___cxa_is_pointer_type"]=asm["___cxa_is_pointer_type"];var ___divdi3=Module["___divdi3"]=asm["___divdi3"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var ___uremdi3=Module["___uremdi3"]=asm["___uremdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _emscripten_bind_DracoInt8Array_DracoInt8Array_0=Module["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"]=asm["_emscripten_bind_DracoInt8Array_DracoInt8Array_0"];var _emscripten_bind_DracoInt8Array_GetValue_1=Module["_emscripten_bind_DracoInt8Array_GetValue_1"]=asm["_emscripten_bind_DracoInt8Array_GetValue_1"];var _emscripten_bind_DracoInt8Array___destroy___0=Module["_emscripten_bind_DracoInt8Array___destroy___0"]=asm["_emscripten_bind_DracoInt8Array___destroy___0"];var _emscripten_bind_DracoInt8Array_size_0=Module["_emscripten_bind_DracoInt8Array_size_0"]=asm["_emscripten_bind_DracoInt8Array_size_0"];var _emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2=Module["_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2"]=asm["_emscripten_bind_Encoder_EncodeMeshToDracoBuffer_2"];var _emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3=Module["_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3"]=asm["_emscripten_bind_Encoder_EncodePointCloudToDracoBuffer_3"];var _emscripten_bind_Encoder_Encoder_0=Module["_emscripten_bind_Encoder_Encoder_0"]=asm["_emscripten_bind_Encoder_Encoder_0"];var _emscripten_bind_Encoder_SetAttributeExplicitQuantization_5=Module["_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5"]=asm["_emscripten_bind_Encoder_SetAttributeExplicitQuantization_5"];var _emscripten_bind_Encoder_SetAttributeQuantization_2=Module["_emscripten_bind_Encoder_SetAttributeQuantization_2"]=asm["_emscripten_bind_Encoder_SetAttributeQuantization_2"];var _emscripten_bind_Encoder_SetEncodingMethod_1=Module["_emscripten_bind_Encoder_SetEncodingMethod_1"]=asm["_emscripten_bind_Encoder_SetEncodingMethod_1"];var _emscripten_bind_Encoder_SetSpeedOptions_2=Module["_emscripten_bind_Encoder_SetSpeedOptions_2"]=asm["_emscripten_bind_Encoder_SetSpeedOptions_2"];var _emscripten_bind_Encoder___destroy___0=Module["_emscripten_bind_Encoder___destroy___0"]=asm["_emscripten_bind_Encoder___destroy___0"];var _emscripten_bind_GeometryAttribute_GeometryAttribute_0=Module["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"]=asm["_emscripten_bind_GeometryAttribute_GeometryAttribute_0"];var _emscripten_bind_GeometryAttribute___destroy___0=Module["_emscripten_bind_GeometryAttribute___destroy___0"]=asm["_emscripten_bind_GeometryAttribute___destroy___0"];var _emscripten_bind_MeshBuilder_AddFacesToMesh_3=Module["_emscripten_bind_MeshBuilder_AddFacesToMesh_3"]=asm["_emscripten_bind_MeshBuilder_AddFacesToMesh_3"];var _emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5=Module["_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5"]=asm["_emscripten_bind_MeshBuilder_AddFloatAttributeToMesh_5"];var _emscripten_bind_MeshBuilder_AddFloatAttribute_5=Module["_emscripten_bind_MeshBuilder_AddFloatAttribute_5"]=asm["_emscripten_bind_MeshBuilder_AddFloatAttribute_5"];var _emscripten_bind_MeshBuilder_AddInt16Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt16Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt16Attribute_5"];var _emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5=Module["_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5"]=asm["_emscripten_bind_MeshBuilder_AddInt32AttributeToMesh_5"];var _emscripten_bind_MeshBuilder_AddInt32Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt32Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt32Attribute_5"];var _emscripten_bind_MeshBuilder_AddInt8Attribute_5=Module["_emscripten_bind_MeshBuilder_AddInt8Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddInt8Attribute_5"];var _emscripten_bind_MeshBuilder_AddMetadataToMesh_2=Module["_emscripten_bind_MeshBuilder_AddMetadataToMesh_2"]=asm["_emscripten_bind_MeshBuilder_AddMetadataToMesh_2"];var _emscripten_bind_MeshBuilder_AddMetadata_2=Module["_emscripten_bind_MeshBuilder_AddMetadata_2"]=asm["_emscripten_bind_MeshBuilder_AddMetadata_2"];var _emscripten_bind_MeshBuilder_AddUInt16Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt16Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt16Attribute_5"];var _emscripten_bind_MeshBuilder_AddUInt32Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt32Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt32Attribute_5"];var _emscripten_bind_MeshBuilder_AddUInt8Attribute_5=Module["_emscripten_bind_MeshBuilder_AddUInt8Attribute_5"]=asm["_emscripten_bind_MeshBuilder_AddUInt8Attribute_5"];var _emscripten_bind_MeshBuilder_MeshBuilder_0=Module["_emscripten_bind_MeshBuilder_MeshBuilder_0"]=asm["_emscripten_bind_MeshBuilder_MeshBuilder_0"];var _emscripten_bind_MeshBuilder_SetMetadataForAttribute_3=Module["_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3"]=asm["_emscripten_bind_MeshBuilder_SetMetadataForAttribute_3"];var _emscripten_bind_MeshBuilder___destroy___0=Module["_emscripten_bind_MeshBuilder___destroy___0"]=asm["_emscripten_bind_MeshBuilder___destroy___0"];var _emscripten_bind_Mesh_Mesh_0=Module["_emscripten_bind_Mesh_Mesh_0"]=asm["_emscripten_bind_Mesh_Mesh_0"];var _emscripten_bind_Mesh___destroy___0=Module["_emscripten_bind_Mesh___destroy___0"]=asm["_emscripten_bind_Mesh___destroy___0"];var _emscripten_bind_Mesh_num_attributes_0=Module["_emscripten_bind_Mesh_num_attributes_0"]=asm["_emscripten_bind_Mesh_num_attributes_0"];var _emscripten_bind_Mesh_num_faces_0=Module["_emscripten_bind_Mesh_num_faces_0"]=asm["_emscripten_bind_Mesh_num_faces_0"];var _emscripten_bind_Mesh_num_points_0=Module["_emscripten_bind_Mesh_num_points_0"]=asm["_emscripten_bind_Mesh_num_points_0"];var _emscripten_bind_Mesh_set_num_points_1=Module["_emscripten_bind_Mesh_set_num_points_1"]=asm["_emscripten_bind_Mesh_set_num_points_1"];var _emscripten_bind_MetadataBuilder_AddDoubleEntry_3=Module["_emscripten_bind_MetadataBuilder_AddDoubleEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddDoubleEntry_3"];var _emscripten_bind_MetadataBuilder_AddIntEntry_3=Module["_emscripten_bind_MetadataBuilder_AddIntEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddIntEntry_3"];var _emscripten_bind_MetadataBuilder_AddStringEntry_3=Module["_emscripten_bind_MetadataBuilder_AddStringEntry_3"]=asm["_emscripten_bind_MetadataBuilder_AddStringEntry_3"];var _emscripten_bind_MetadataBuilder_MetadataBuilder_0=Module["_emscripten_bind_MetadataBuilder_MetadataBuilder_0"]=asm["_emscripten_bind_MetadataBuilder_MetadataBuilder_0"];var _emscripten_bind_MetadataBuilder___destroy___0=Module["_emscripten_bind_MetadataBuilder___destroy___0"]=asm["_emscripten_bind_MetadataBuilder___destroy___0"];var _emscripten_bind_Metadata_Metadata_0=Module["_emscripten_bind_Metadata_Metadata_0"]=asm["_emscripten_bind_Metadata_Metadata_0"];var _emscripten_bind_Metadata___destroy___0=Module["_emscripten_bind_Metadata___destroy___0"]=asm["_emscripten_bind_Metadata___destroy___0"];var _emscripten_bind_PointAttribute_PointAttribute_0=Module["_emscripten_bind_PointAttribute_PointAttribute_0"]=asm["_emscripten_bind_PointAttribute_PointAttribute_0"];var _emscripten_bind_PointAttribute___destroy___0=Module["_emscripten_bind_PointAttribute___destroy___0"]=asm["_emscripten_bind_PointAttribute___destroy___0"];var _emscripten_bind_PointAttribute_attribute_type_0=Module["_emscripten_bind_PointAttribute_attribute_type_0"]=asm["_emscripten_bind_PointAttribute_attribute_type_0"];var _emscripten_bind_PointAttribute_byte_offset_0=Module["_emscripten_bind_PointAttribute_byte_offset_0"]=asm["_emscripten_bind_PointAttribute_byte_offset_0"];var _emscripten_bind_PointAttribute_byte_stride_0=Module["_emscripten_bind_PointAttribute_byte_stride_0"]=asm["_emscripten_bind_PointAttribute_byte_stride_0"];var _emscripten_bind_PointAttribute_data_type_0=Module["_emscripten_bind_PointAttribute_data_type_0"]=asm["_emscripten_bind_PointAttribute_data_type_0"];var _emscripten_bind_PointAttribute_normalized_0=Module["_emscripten_bind_PointAttribute_normalized_0"]=asm["_emscripten_bind_PointAttribute_normalized_0"];var _emscripten_bind_PointAttribute_num_components_0=Module["_emscripten_bind_PointAttribute_num_components_0"]=asm["_emscripten_bind_PointAttribute_num_components_0"];var _emscripten_bind_PointAttribute_size_0=Module["_emscripten_bind_PointAttribute_size_0"]=asm["_emscripten_bind_PointAttribute_size_0"];var _emscripten_bind_PointAttribute_unique_id_0=Module["_emscripten_bind_PointAttribute_unique_id_0"]=asm["_emscripten_bind_PointAttribute_unique_id_0"];var _emscripten_bind_PointCloudBuilder_AddFloatAttribute_5=Module["_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddFloatAttribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt16Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt16Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt32Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt32Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddInt8Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddInt8Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddMetadata_2=Module["_emscripten_bind_PointCloudBuilder_AddMetadata_2"]=asm["_emscripten_bind_PointCloudBuilder_AddMetadata_2"];var _emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt16Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt32Attribute_5"];var _emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5=Module["_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5"]=asm["_emscripten_bind_PointCloudBuilder_AddUInt8Attribute_5"];var _emscripten_bind_PointCloudBuilder_PointCloudBuilder_0=Module["_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0"]=asm["_emscripten_bind_PointCloudBuilder_PointCloudBuilder_0"];var _emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3=Module["_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3"]=asm["_emscripten_bind_PointCloudBuilder_SetMetadataForAttribute_3"];var _emscripten_bind_PointCloudBuilder___destroy___0=Module["_emscripten_bind_PointCloudBuilder___destroy___0"]=asm["_emscripten_bind_PointCloudBuilder___destroy___0"];var _emscripten_bind_PointCloud_PointCloud_0=Module["_emscripten_bind_PointCloud_PointCloud_0"]=asm["_emscripten_bind_PointCloud_PointCloud_0"];var _emscripten_bind_PointCloud___destroy___0=Module["_emscripten_bind_PointCloud___destroy___0"]=asm["_emscripten_bind_PointCloud___destroy___0"];var _emscripten_bind_PointCloud_num_attributes_0=Module["_emscripten_bind_PointCloud_num_attributes_0"]=asm["_emscripten_bind_PointCloud_num_attributes_0"];var _emscripten_bind_PointCloud_num_points_0=Module["_emscripten_bind_PointCloud_num_points_0"]=asm["_emscripten_bind_PointCloud_num_points_0"];var _emscripten_bind_VoidPtr___destroy___0=Module["_emscripten_bind_VoidPtr___destroy___0"]=asm["_emscripten_bind_VoidPtr___destroy___0"];var _emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=Module["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"]=asm["_emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE"];var _emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=Module["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"]=asm["_emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD"];var _emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=Module["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"]=asm["_emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH"];var _emscripten_enum_draco_GeometryAttribute_Type_COLOR=Module["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_COLOR"];var _emscripten_enum_draco_GeometryAttribute_Type_GENERIC=Module["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_GENERIC"];var _emscripten_enum_draco_GeometryAttribute_Type_INVALID=Module["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_INVALID"];var _emscripten_enum_draco_GeometryAttribute_Type_NORMAL=Module["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_NORMAL"];var _emscripten_enum_draco_GeometryAttribute_Type_POSITION=Module["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_POSITION"];var _emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=Module["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"]=asm["_emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD"];var _emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING=Module["_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING"]=asm["_emscripten_enum_draco_MeshEncoderMethod_MESH_EDGEBREAKER_ENCODING"];var _emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING=Module["_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING"]=asm["_emscripten_enum_draco_MeshEncoderMethod_MESH_SEQUENTIAL_ENCODING"];var _emscripten_replace_memory=Module["_emscripten_replace_memory"]=asm["_emscripten_replace_memory"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memmove=Module["_memmove"]=asm["_memmove"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];Module["asm"]=asm;if(memoryInitializer){if(!isDataURI(memoryInitializer)){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]&&status===0){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=exit;function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;throw"abort("+what+"). Build with -s ASSERTIONS=1 for more info."}Module["abort"]=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}Module["noExitRuntime"]=true;run();function WrapperObject(){}WrapperObject.prototype=Object.create(WrapperObject.prototype);WrapperObject.prototype.constructor=WrapperObject;WrapperObject.prototype.__class__=WrapperObject;WrapperObject.__cache__={};Module["WrapperObject"]=WrapperObject;function getCache(__class__){return(__class__||WrapperObject).__cache__}Module["getCache"]=getCache;function wrapPointer(ptr,__class__){var cache=getCache(__class__);var ret=cache[ptr];if(ret)return ret;ret=Object.create((__class__||WrapperObject).prototype);ret.ptr=ptr;return cache[ptr]=ret}Module["wrapPointer"]=wrapPointer;function castObject(obj,__class__){return wrapPointer(obj.ptr,__class__)}Module["castObject"]=castObject;Module["NULL"]=wrapPointer(0);function destroy(obj){if(!obj["__destroy__"])throw"Error: Cannot destroy object. (Did you create it yourself?)";obj["__destroy__"]();delete getCache(obj.__class__)[obj.ptr]}Module["destroy"]=destroy;function compare(obj1,obj2){return obj1.ptr===obj2.ptr}Module["compare"]=compare;function getPointer(obj){return obj.ptr}Module["getPointer"]=getPointer;function getClass(obj){return obj.__class__}Module["getClass"]=getClass;var ensureCache={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:(function(){if(ensureCache.needed){for(var i=0;i=ensureCache.size){assert(len>0);ensureCache.needed+=len;ret=Module["_malloc"](len);ensureCache.temps.push(ret)}else{ret=ensureCache.buffer+ensureCache.pos;ensureCache.pos+=len}return ret}),copy:(function(array,view,offset){var offsetShifted=offset;var bytes=view.BYTES_PER_ELEMENT;switch(bytes){case 2:offsetShifted>>=1;break;case 4:offsetShifted>>=2;break;case 8:offsetShifted>>=3;break}for(var i=0;i>>16&65535)*h+k*(f>>>16&65535)<<16>>>0)|0}},"es6","es3"); +$jscomp.polyfill("Math.clz32",function(d){return d?d:function(d){d=Number(d)>>>0;if(0===d)return 32;var f=0;0===(d&4294901760)&&(d<<=16,f+=16);0===(d&4278190080)&&(d<<=8,f+=8);0===(d&4026531840)&&(d<<=4,f+=4);0===(d&3221225472)&&(d<<=2,f+=2);0===(d&2147483648)&&f++;return f}},"es6","es3");$jscomp.polyfill("Math.trunc",function(d){return d?d:function(d){d=Number(d);if(isNaN(d)||Infinity===d||-Infinity===d||0===d)return d;var f=Math.floor(Math.abs(d));return 0>d?-f:f}},"es6","es3"); +$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var d=0;return function(k){return $jscomp.SYMBOL_PREFIX+(k||"")+d++}}(); +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var d=$jscomp.global.Symbol.iterator;d||(d=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[d]&&$jscomp.defineProperty(Array.prototype,d,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(d){var k=0;return $jscomp.iteratorPrototype(function(){return k>0];b|=e;if(0==e&&!c)break;d++;if(c&&d==c)break}c||(c=d);e="";if(128>b){for(;0e?b+=String.fromCharCode(e):(e-=65536,b+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else b+=String.fromCharCode(e)}}function ha(a,c){0< +a%c&&(a+=c-a%c);return a}function r(){a.HEAP8=ia=new Int8Array(D);a.HEAP16=Ja=new Int16Array(D);a.HEAP32=E=new Int32Array(D);a.HEAPU8=W=new Uint8Array(D);a.HEAPU16=new Uint16Array(D);a.HEAPU32=new Uint32Array(D);a.HEAPF32=new Float32Array(D);a.HEAPF64=new Float64Array(D)}function B(e){for(;0>2]=e;e=la.buffer;for(var d=0;d>2],c.adjusted=e,(sa(p[d]),e)|0;e=E[e>>2]; +return(sa(b),e)|0}function Z(e,c){w.varargs=c;try{var b=w.get(),p=w.get(),d=w.get();e=0;Z.buffers||(Z.buffers=[null,[],[]],Z.printChar=function(c,b){var e=Z.buffers[c];f(e);0===b||10===b?((1===c?a.print:a.printErr)(h(e,0)),e.length=0):e.push(b)});for(c=0;c>2],k=E[p+(8*c+4)>>2],l=0;l=e&&(e=65536+((e&1023)<<10)|a.charCodeAt(++b)&1023);127>=e?++c:c=2047>=e?c+2:65535>=e?c+3:2097151>=e?c+4:67108863>=e?c+5:c+6}c=Array(c+1);b=0;e=c.length;if(0=f&&(f=65536+((f&1023)<<10)|a.charCodeAt(++d)&1023);if(127>=f){if(b>=e)break;c[b++]=f}else{if(2047>=f){if(b+1>=e)break;c[b++]=192|f>>6}else{if(65535>=f){if(b+2>=e)break;c[b++]=224|f>>12}else{if(2097151>=f){if(b+ +3>=e)break;c[b++]=240|f>>18}else{if(67108863>=f){if(b+4>=e)break;c[b++]=248|f>>24}else{if(b+5>=e)break;c[b++]=252|f>>30;c[b++]=128|f>>24&63}c[b++]=128|f>>18&63}c[b++]=128|f>>12&63}c[b++]=128|f>>6&63}c[b++]=128|f&63}}c[b]=0}a=l.alloc(c,ia);l.copy(c,ia,a)}return a}function z(){throw"cannot construct a Status, no constructor in IDL";}function F(){this.ptr=Wa();t(F)[this.ptr]=this}function G(){this.ptr=Xa();t(G)[this.ptr]=this}function H(){this.ptr=Ya();t(H)[this.ptr]=this}function I(){this.ptr=Za(); +t(I)[this.ptr]=this}function J(){this.ptr=$a();t(J)[this.ptr]=this}function n(){this.ptr=ab();t(n)[this.ptr]=this}function P(){this.ptr=bb();t(P)[this.ptr]=this}function x(){this.ptr=cb();t(x)[this.ptr]=this}function K(){this.ptr=db();t(K)[this.ptr]=this}function q(){this.ptr=eb();t(q)[this.ptr]=this}function L(){this.ptr=fb();t(L)[this.ptr]=this}function M(){this.ptr=gb();t(M)[this.ptr]=this}function V(){this.ptr=hb();t(V)[this.ptr]=this}function Q(){this.ptr=ib();t(Q)[this.ptr]=this}function g(){this.ptr= +jb();t(g)[this.ptr]=this}function C(){this.ptr=kb();t(C)[this.ptr]=this}function X(){throw"cannot construct a VoidPtr, no constructor in IDL";}function N(){this.ptr=lb();t(N)[this.ptr]=this}function R(){this.ptr=mb();t(R)[this.ptr]=this}d=d||{};var a="undefined"!==typeof d?d:{},Qa=!1,Ra=!1;a.onRuntimeInitialized=function(){Qa=!0;if(Ra&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.onModuleParsed=function(){Ra=!0;if(Qa&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.isVersionSupported= +function(a){if("string"!==typeof a)return!1;a=a.split(".");return 2>a.length||3=a[1]?!0:0!=a[0]||10>2]},getStr:function(){return u(w.get())},get64:function(){var a=w.get(),c=w.get();0<=a?f(0===c):f(-1===c);return a},getZero:function(){f(0===w.get())}},va={},Ha=1;ka=function(a){f(!Sa);var c=ba;ba=ba+ +a+15&-16;return c}(4);Ca=ta=k(ba);ua=Ca+Fa;Da=k(ua);E[ka>>2]=Da;Sa=!0;a.wasmTableSize=468;a.wasmMaxTableSize=468;a.asmGlobalArg={};a.asmLibraryArg={abort:O,assert:f,enlargeMemory:function(){var e=a.usingWasm?65536:16777216,c=2147483648-e;if(E[ka>>2]>c)return!1;var b=A;for(A=Math.max(A,16777216);A>2];)A=536870912>=A?ha(2*A,e):Math.min(ha((3*A+2147483648)/4,e),c);e=a.reallocBuffer(A);if(!e||e.byteLength!=A)return A=b,!1;a.buffer=D=e;r();return!0},getTotalMemory:function(){return A},abortOnCannotGrowMemory:function(){O("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+ +A+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")},invoke_ii:function(e,c){try{return a.dynCall_ii(e,c)}catch(b){if("number"!==typeof b&&"longjmp"!==b)throw b;a.setThrew(1,0)}},invoke_iii:function(e,c,b){try{return a.dynCall_iii(e,c,b)}catch(p){if("number"!==typeof p&&"longjmp"!==p)throw p;a.setThrew(1,0)}},invoke_iiii:function(e,c,b,d){try{return a.dynCall_iiii(e, +c,b,d)}catch(S){if("number"!==typeof S&&"longjmp"!==S)throw S;a.setThrew(1,0)}},invoke_iiiiiii:function(e,c,b,d,f,g,h){try{return a.dynCall_iiiiiii(e,c,b,d,f,g,h)}catch(da){if("number"!==typeof da&&"longjmp"!==da)throw da;a.setThrew(1,0)}},invoke_v:function(e){try{a.dynCall_v(e)}catch(c){if("number"!==typeof c&&"longjmp"!==c)throw c;a.setThrew(1,0)}},invoke_vi:function(e,c){try{a.dynCall_vi(e,c)}catch(b){if("number"!==typeof b&&"longjmp"!==b)throw b;a.setThrew(1,0)}},invoke_vii:function(e,c,b){try{a.dynCall_vii(e, +c,b)}catch(p){if("number"!==typeof p&&"longjmp"!==p)throw p;a.setThrew(1,0)}},invoke_viii:function(e,c,b,d){try{a.dynCall_viii(e,c,b,d)}catch(S){if("number"!==typeof S&&"longjmp"!==S)throw S;a.setThrew(1,0)}},invoke_viiii:function(e,c,b,d,f){try{a.dynCall_viiii(e,c,b,d,f)}catch(xa){if("number"!==typeof xa&&"longjmp"!==xa)throw xa;a.setThrew(1,0)}},invoke_viiiii:function(e,c,b,d,f,g){try{a.dynCall_viiiii(e,c,b,d,f,g)}catch(ca){if("number"!==typeof ca&&"longjmp"!==ca)throw ca;a.setThrew(1,0)}},invoke_viiiiii:function(e, +c,b,d,f,g,h){try{a.dynCall_viiiiii(e,c,b,d,f,g,h)}catch(da){if("number"!==typeof da&&"longjmp"!==da)throw da;a.setThrew(1,0)}},__ZSt18uncaught_exceptionv:v,___cxa_allocate_exception:function(a){return Ka(a)},___cxa_begin_catch:function(a){var c=y.infos[a];c&&!c.caught&&(c.caught=!0,v.uncaught_exception--);c&&(c.rethrown=!1);y.caught.push(a);y.addRef(y.deAdjust(a));return a},___cxa_find_matching_catch:la,___cxa_pure_virtual:function(){oa=!0;throw"Pure virtual function called!";},___cxa_throw:function(a, +c,b){y.infos[a]={ptr:a,adjusted:a,type:c,destructor:b,refcount:0,caught:!1,rethrown:!1};y.last=a;"uncaught_exception"in v?v.uncaught_exception++:v.uncaught_exception=1;throw a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";},___gxx_personality_v0:function(){},___resumeException:function(a){y.last||(y.last=a);throw a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."; +},___setErrNo:function(d){a.___errno_location&&(E[a.___errno_location()>>2]=d);return d},___syscall140:function(a,c){w.varargs=c;try{var b=w.getStreamFromFD();w.get();var d=w.get(),e=w.get(),f=w.get();FS.llseek(b,d,f);E[e>>2]=b.position;b.getdents&&0===d&&0===f&&(b.getdents=null);return 0}catch(ca){return"undefined"!==typeof FS&&ca instanceof FS.ErrnoError||O(ca),-ca.errno}},___syscall146:Z,___syscall6:function(a,c){w.varargs=c;try{var b=w.getStreamFromFD();FS.close(b);return 0}catch(p){return"undefined"!== +typeof FS&&p instanceof FS.ErrnoError||O(p),-p.errno}},_abort:function(){a.abort()},_emscripten_memcpy_big:function(a,c,b){W.set(W.subarray(c,c+b),a);return a},_llvm_trap:function(){O("trap!")},_pthread_getspecific:function(a){return va[a]||0},_pthread_key_create:function(a,c){if(0==a)return 22;E[a>>2]=Ha;va[Ha]=0;Ha++;return 0},_pthread_once:ma,_pthread_setspecific:function(a,c){if(!(a in va))return 22;va[a]=c;return 0},flush_NO_FILESYSTEM:function(){var d=a._fflush;d&&d(0);if(d=Z.printChar){var c= +Z.buffers;c[1].length&&d(1,10);c[2].length&&d(2,10)}},DYNAMICTOP_PTR:ka,tempDoublePtr:qb,ABORT:oa,STACKTOP:ta,STACK_MAX:ua};var Ua=a.asm(a.asmGlobalArg,a.asmLibraryArg,D);a.asm=Ua;a.___cxa_can_catch=function(){return a.asm.___cxa_can_catch.apply(null,arguments)};a.___cxa_is_pointer_type=function(){return a.asm.___cxa_is_pointer_type.apply(null,arguments)};var $a=a._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0.apply(null, +arguments)},rb=a._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1.apply(null,arguments)},sb=a._emscripten_bind_AttributeOctahedronTransform___destroy___0=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform___destroy___0.apply(null,arguments)},tb=a._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=function(){return a.asm._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0.apply(null, +arguments)},cb=a._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0.apply(null,arguments)},ub=a._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1.apply(null,arguments)},vb=a._emscripten_bind_AttributeQuantizationTransform___destroy___0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform___destroy___0.apply(null, +arguments)},wb=a._emscripten_bind_AttributeQuantizationTransform_min_value_1=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_min_value_1.apply(null,arguments)},xb=a._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0.apply(null,arguments)},yb=a._emscripten_bind_AttributeQuantizationTransform_range_0=function(){return a.asm._emscripten_bind_AttributeQuantizationTransform_range_0.apply(null, +arguments)},bb=a._emscripten_bind_AttributeTransformData_AttributeTransformData_0=function(){return a.asm._emscripten_bind_AttributeTransformData_AttributeTransformData_0.apply(null,arguments)},zb=a._emscripten_bind_AttributeTransformData___destroy___0=function(){return a.asm._emscripten_bind_AttributeTransformData___destroy___0.apply(null,arguments)},Ab=a._emscripten_bind_AttributeTransformData_transform_type_0=function(){return a.asm._emscripten_bind_AttributeTransformData_transform_type_0.apply(null, +arguments)},ib=a._emscripten_bind_DecoderBuffer_DecoderBuffer_0=function(){return a.asm._emscripten_bind_DecoderBuffer_DecoderBuffer_0.apply(null,arguments)},Bb=a._emscripten_bind_DecoderBuffer_Init_2=function(){return a.asm._emscripten_bind_DecoderBuffer_Init_2.apply(null,arguments)},Cb=a._emscripten_bind_DecoderBuffer___destroy___0=function(){return a.asm._emscripten_bind_DecoderBuffer___destroy___0.apply(null,arguments)},Db=a._emscripten_bind_Decoder_DecodeBufferToMesh_2=function(){return a.asm._emscripten_bind_Decoder_DecodeBufferToMesh_2.apply(null, +arguments)},Eb=a._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=function(){return a.asm._emscripten_bind_Decoder_DecodeBufferToPointCloud_2.apply(null,arguments)},jb=a._emscripten_bind_Decoder_Decoder_0=function(){return a.asm._emscripten_bind_Decoder_Decoder_0.apply(null,arguments)},Fb=a._emscripten_bind_Decoder_GetAttributeByUniqueId_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeByUniqueId_2.apply(null,arguments)},Gb=a._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3= +function(){return a.asm._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3.apply(null,arguments)},Hb=a._emscripten_bind_Decoder_GetAttributeFloat_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeFloat_3.apply(null,arguments)},Ib=a._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3.apply(null,arguments)},Jb=a._emscripten_bind_Decoder_GetAttributeIdByName_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeIdByName_2.apply(null, +arguments)},Kb=a._emscripten_bind_Decoder_GetAttributeId_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeId_2.apply(null,arguments)},Lb=a._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3.apply(null,arguments)},Mb=a._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3.apply(null,arguments)},Nb=a._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3= +function(){return a.asm._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3.apply(null,arguments)},Ob=a._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3.apply(null,arguments)},Pb=a._emscripten_bind_Decoder_GetAttributeMetadata_2=function(){return a.asm._emscripten_bind_Decoder_GetAttributeMetadata_2.apply(null,arguments)},Qb=a._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3.apply(null, +arguments)},Rb=a._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3.apply(null,arguments)},Sb=a._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=function(){return a.asm._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3.apply(null,arguments)},Tb=a._emscripten_bind_Decoder_GetAttribute_2=function(){return a.asm._emscripten_bind_Decoder_GetAttribute_2.apply(null,arguments)},Ub=a._emscripten_bind_Decoder_GetEncodedGeometryType_1= +function(){return a.asm._emscripten_bind_Decoder_GetEncodedGeometryType_1.apply(null,arguments)},Vb=a._emscripten_bind_Decoder_GetFaceFromMesh_3=function(){return a.asm._emscripten_bind_Decoder_GetFaceFromMesh_3.apply(null,arguments)},Wb=a._emscripten_bind_Decoder_GetMetadata_1=function(){return a.asm._emscripten_bind_Decoder_GetMetadata_1.apply(null,arguments)},Xb=a._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=function(){return a.asm._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2.apply(null, +arguments)},Yb=a._emscripten_bind_Decoder_SkipAttributeTransform_1=function(){return a.asm._emscripten_bind_Decoder_SkipAttributeTransform_1.apply(null,arguments)},Zb=a._emscripten_bind_Decoder___destroy___0=function(){return a.asm._emscripten_bind_Decoder___destroy___0.apply(null,arguments)},gb=a._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=function(){return a.asm._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0.apply(null,arguments)},$b=a._emscripten_bind_DracoFloat32Array_GetValue_1= +function(){return a.asm._emscripten_bind_DracoFloat32Array_GetValue_1.apply(null,arguments)},ac=a._emscripten_bind_DracoFloat32Array___destroy___0=function(){return a.asm._emscripten_bind_DracoFloat32Array___destroy___0.apply(null,arguments)},bc=a._emscripten_bind_DracoFloat32Array_size_0=function(){return a.asm._emscripten_bind_DracoFloat32Array_size_0.apply(null,arguments)},fb=a._emscripten_bind_DracoInt16Array_DracoInt16Array_0=function(){return a.asm._emscripten_bind_DracoInt16Array_DracoInt16Array_0.apply(null, +arguments)},cc=a._emscripten_bind_DracoInt16Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoInt16Array_GetValue_1.apply(null,arguments)},dc=a._emscripten_bind_DracoInt16Array___destroy___0=function(){return a.asm._emscripten_bind_DracoInt16Array___destroy___0.apply(null,arguments)},ec=a._emscripten_bind_DracoInt16Array_size_0=function(){return a.asm._emscripten_bind_DracoInt16Array_size_0.apply(null,arguments)},lb=a._emscripten_bind_DracoInt32Array_DracoInt32Array_0=function(){return a.asm._emscripten_bind_DracoInt32Array_DracoInt32Array_0.apply(null, +arguments)},fc=a._emscripten_bind_DracoInt32Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoInt32Array_GetValue_1.apply(null,arguments)},gc=a._emscripten_bind_DracoInt32Array___destroy___0=function(){return a.asm._emscripten_bind_DracoInt32Array___destroy___0.apply(null,arguments)},hc=a._emscripten_bind_DracoInt32Array_size_0=function(){return a.asm._emscripten_bind_DracoInt32Array_size_0.apply(null,arguments)},db=a._emscripten_bind_DracoInt8Array_DracoInt8Array_0=function(){return a.asm._emscripten_bind_DracoInt8Array_DracoInt8Array_0.apply(null, +arguments)},ic=a._emscripten_bind_DracoInt8Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoInt8Array_GetValue_1.apply(null,arguments)},jc=a._emscripten_bind_DracoInt8Array___destroy___0=function(){return a.asm._emscripten_bind_DracoInt8Array___destroy___0.apply(null,arguments)},kc=a._emscripten_bind_DracoInt8Array_size_0=function(){return a.asm._emscripten_bind_DracoInt8Array_size_0.apply(null,arguments)},Wa=a._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=function(){return a.asm._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0.apply(null, +arguments)},lc=a._emscripten_bind_DracoUInt16Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoUInt16Array_GetValue_1.apply(null,arguments)},mc=a._emscripten_bind_DracoUInt16Array___destroy___0=function(){return a.asm._emscripten_bind_DracoUInt16Array___destroy___0.apply(null,arguments)},nc=a._emscripten_bind_DracoUInt16Array_size_0=function(){return a.asm._emscripten_bind_DracoUInt16Array_size_0.apply(null,arguments)},Za=a._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=function(){return a.asm._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0.apply(null, +arguments)},oc=a._emscripten_bind_DracoUInt32Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoUInt32Array_GetValue_1.apply(null,arguments)},pc=a._emscripten_bind_DracoUInt32Array___destroy___0=function(){return a.asm._emscripten_bind_DracoUInt32Array___destroy___0.apply(null,arguments)},qc=a._emscripten_bind_DracoUInt32Array_size_0=function(){return a.asm._emscripten_bind_DracoUInt32Array_size_0.apply(null,arguments)},Ya=a._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=function(){return a.asm._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0.apply(null, +arguments)},rc=a._emscripten_bind_DracoUInt8Array_GetValue_1=function(){return a.asm._emscripten_bind_DracoUInt8Array_GetValue_1.apply(null,arguments)},sc=a._emscripten_bind_DracoUInt8Array___destroy___0=function(){return a.asm._emscripten_bind_DracoUInt8Array___destroy___0.apply(null,arguments)},tc=a._emscripten_bind_DracoUInt8Array_size_0=function(){return a.asm._emscripten_bind_DracoUInt8Array_size_0.apply(null,arguments)},hb=a._emscripten_bind_GeometryAttribute_GeometryAttribute_0=function(){return a.asm._emscripten_bind_GeometryAttribute_GeometryAttribute_0.apply(null, +arguments)},uc=a._emscripten_bind_GeometryAttribute___destroy___0=function(){return a.asm._emscripten_bind_GeometryAttribute___destroy___0.apply(null,arguments)},kb=a._emscripten_bind_Mesh_Mesh_0=function(){return a.asm._emscripten_bind_Mesh_Mesh_0.apply(null,arguments)},vc=a._emscripten_bind_Mesh___destroy___0=function(){return a.asm._emscripten_bind_Mesh___destroy___0.apply(null,arguments)},wc=a._emscripten_bind_Mesh_num_attributes_0=function(){return a.asm._emscripten_bind_Mesh_num_attributes_0.apply(null, +arguments)},xc=a._emscripten_bind_Mesh_num_faces_0=function(){return a.asm._emscripten_bind_Mesh_num_faces_0.apply(null,arguments)},yc=a._emscripten_bind_Mesh_num_points_0=function(){return a.asm._emscripten_bind_Mesh_num_points_0.apply(null,arguments)},zc=a._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetDoubleEntry_2.apply(null,arguments)},Ac=a._emscripten_bind_MetadataQuerier_GetEntryName_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetEntryName_2.apply(null, +arguments)},Bc=a._emscripten_bind_MetadataQuerier_GetIntEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetIntEntry_2.apply(null,arguments)},Cc=a._emscripten_bind_MetadataQuerier_GetStringEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_GetStringEntry_2.apply(null,arguments)},Dc=a._emscripten_bind_MetadataQuerier_HasDoubleEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_HasDoubleEntry_2.apply(null,arguments)},Ec=a._emscripten_bind_MetadataQuerier_HasEntry_2= +function(){return a.asm._emscripten_bind_MetadataQuerier_HasEntry_2.apply(null,arguments)},Fc=a._emscripten_bind_MetadataQuerier_HasIntEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_HasIntEntry_2.apply(null,arguments)},Gc=a._emscripten_bind_MetadataQuerier_HasStringEntry_2=function(){return a.asm._emscripten_bind_MetadataQuerier_HasStringEntry_2.apply(null,arguments)},eb=a._emscripten_bind_MetadataQuerier_MetadataQuerier_0=function(){return a.asm._emscripten_bind_MetadataQuerier_MetadataQuerier_0.apply(null, +arguments)},Hc=a._emscripten_bind_MetadataQuerier_NumEntries_1=function(){return a.asm._emscripten_bind_MetadataQuerier_NumEntries_1.apply(null,arguments)},Ic=a._emscripten_bind_MetadataQuerier___destroy___0=function(){return a.asm._emscripten_bind_MetadataQuerier___destroy___0.apply(null,arguments)},mb=a._emscripten_bind_Metadata_Metadata_0=function(){return a.asm._emscripten_bind_Metadata_Metadata_0.apply(null,arguments)},Jc=a._emscripten_bind_Metadata___destroy___0=function(){return a.asm._emscripten_bind_Metadata___destroy___0.apply(null, +arguments)},Kc=a._emscripten_bind_PointAttribute_GetAttributeTransformData_0=function(){return a.asm._emscripten_bind_PointAttribute_GetAttributeTransformData_0.apply(null,arguments)},ab=a._emscripten_bind_PointAttribute_PointAttribute_0=function(){return a.asm._emscripten_bind_PointAttribute_PointAttribute_0.apply(null,arguments)},Lc=a._emscripten_bind_PointAttribute___destroy___0=function(){return a.asm._emscripten_bind_PointAttribute___destroy___0.apply(null,arguments)},Mc=a._emscripten_bind_PointAttribute_attribute_type_0= +function(){return a.asm._emscripten_bind_PointAttribute_attribute_type_0.apply(null,arguments)},Nc=a._emscripten_bind_PointAttribute_byte_offset_0=function(){return a.asm._emscripten_bind_PointAttribute_byte_offset_0.apply(null,arguments)},Oc=a._emscripten_bind_PointAttribute_byte_stride_0=function(){return a.asm._emscripten_bind_PointAttribute_byte_stride_0.apply(null,arguments)},Pc=a._emscripten_bind_PointAttribute_data_type_0=function(){return a.asm._emscripten_bind_PointAttribute_data_type_0.apply(null, +arguments)},Qc=a._emscripten_bind_PointAttribute_normalized_0=function(){return a.asm._emscripten_bind_PointAttribute_normalized_0.apply(null,arguments)},Rc=a._emscripten_bind_PointAttribute_num_components_0=function(){return a.asm._emscripten_bind_PointAttribute_num_components_0.apply(null,arguments)},Sc=a._emscripten_bind_PointAttribute_size_0=function(){return a.asm._emscripten_bind_PointAttribute_size_0.apply(null,arguments)},Tc=a._emscripten_bind_PointAttribute_unique_id_0=function(){return a.asm._emscripten_bind_PointAttribute_unique_id_0.apply(null, +arguments)},Xa=a._emscripten_bind_PointCloud_PointCloud_0=function(){return a.asm._emscripten_bind_PointCloud_PointCloud_0.apply(null,arguments)},Uc=a._emscripten_bind_PointCloud___destroy___0=function(){return a.asm._emscripten_bind_PointCloud___destroy___0.apply(null,arguments)},Vc=a._emscripten_bind_PointCloud_num_attributes_0=function(){return a.asm._emscripten_bind_PointCloud_num_attributes_0.apply(null,arguments)},Wc=a._emscripten_bind_PointCloud_num_points_0=function(){return a.asm._emscripten_bind_PointCloud_num_points_0.apply(null, +arguments)},Xc=a._emscripten_bind_Status___destroy___0=function(){return a.asm._emscripten_bind_Status___destroy___0.apply(null,arguments)},Yc=a._emscripten_bind_Status_code_0=function(){return a.asm._emscripten_bind_Status_code_0.apply(null,arguments)},Zc=a._emscripten_bind_Status_error_msg_0=function(){return a.asm._emscripten_bind_Status_error_msg_0.apply(null,arguments)},$c=a._emscripten_bind_Status_ok_0=function(){return a.asm._emscripten_bind_Status_ok_0.apply(null,arguments)},ad=a._emscripten_bind_VoidPtr___destroy___0= +function(){return a.asm._emscripten_bind_VoidPtr___destroy___0.apply(null,arguments)},bd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM.apply(null,arguments)},cd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM.apply(null,arguments)},dd=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM= +function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM.apply(null,arguments)},ed=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=function(){return a.asm._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM.apply(null,arguments)},fd=a._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=function(){return a.asm._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE.apply(null, +arguments)},gd=a._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=function(){return a.asm._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD.apply(null,arguments)},hd=a._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=function(){return a.asm._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH.apply(null,arguments)},id=a._emscripten_enum_draco_GeometryAttribute_Type_COLOR=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_COLOR.apply(null,arguments)},jd= +a._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_GENERIC.apply(null,arguments)},kd=a._emscripten_enum_draco_GeometryAttribute_Type_INVALID=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_INVALID.apply(null,arguments)},ld=a._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_NORMAL.apply(null,arguments)},md=a._emscripten_enum_draco_GeometryAttribute_Type_POSITION= +function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_POSITION.apply(null,arguments)},nd=a._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=function(){return a.asm._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD.apply(null,arguments)},od=a._emscripten_enum_draco_StatusCode_ERROR=function(){return a.asm._emscripten_enum_draco_StatusCode_ERROR.apply(null,arguments)},pd=a._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=function(){return a.asm._emscripten_enum_draco_StatusCode_INVALID_PARAMETER.apply(null, +arguments)},qd=a._emscripten_enum_draco_StatusCode_IO_ERROR=function(){return a.asm._emscripten_enum_draco_StatusCode_IO_ERROR.apply(null,arguments)},rd=a._emscripten_enum_draco_StatusCode_OK=function(){return a.asm._emscripten_enum_draco_StatusCode_OK.apply(null,arguments)},sd=a._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=function(){return a.asm._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION.apply(null,arguments)},td=a._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=function(){return a.asm._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION.apply(null, +arguments)},nb=a._emscripten_replace_memory=function(){return a.asm._emscripten_replace_memory.apply(null,arguments)};a._free=function(){return a.asm._free.apply(null,arguments)};a._llvm_bswap_i32=function(){return a.asm._llvm_bswap_i32.apply(null,arguments)};var Ka=a._malloc=function(){return a.asm._malloc.apply(null,arguments)};a._memcpy=function(){return a.asm._memcpy.apply(null,arguments)};a._memmove=function(){return a.asm._memmove.apply(null,arguments)};a._memset=function(){return a.asm._memset.apply(null, +arguments)};a._sbrk=function(){return a.asm._sbrk.apply(null,arguments)};a.establishStackSpace=function(){return a.asm.establishStackSpace.apply(null,arguments)};a.getTempRet0=function(){return a.asm.getTempRet0.apply(null,arguments)};a.runPostSets=function(){return a.asm.runPostSets.apply(null,arguments)};var sa=a.setTempRet0=function(){return a.asm.setTempRet0.apply(null,arguments)};a.setThrew=function(){return a.asm.setThrew.apply(null,arguments)};a.stackAlloc=function(){return a.asm.stackAlloc.apply(null, +arguments)};a.stackRestore=function(){return a.asm.stackRestore.apply(null,arguments)};a.stackSave=function(){return a.asm.stackSave.apply(null,arguments)};a.dynCall_ii=function(){return a.asm.dynCall_ii.apply(null,arguments)};a.dynCall_iii=function(){return a.asm.dynCall_iii.apply(null,arguments)};a.dynCall_iiii=function(){return a.asm.dynCall_iiii.apply(null,arguments)};a.dynCall_iiiiiii=function(){return a.asm.dynCall_iiiiiii.apply(null,arguments)};a.dynCall_v=function(){return a.asm.dynCall_v.apply(null, +arguments)};a.dynCall_vi=function(){return a.asm.dynCall_vi.apply(null,arguments)};a.dynCall_vii=function(){return a.asm.dynCall_vii.apply(null,arguments)};a.dynCall_viii=function(){return a.asm.dynCall_viii.apply(null,arguments)};a.dynCall_viiii=function(){return a.asm.dynCall_viiii.apply(null,arguments)};a.dynCall_viiiii=function(){return a.asm.dynCall_viiiii.apply(null,arguments)};a.dynCall_viiiiii=function(){return a.asm.dynCall_viiiiii.apply(null,arguments)};a.asm=Ua;a.then=function(d){if(a.calledRun)d(a); +else{var c=a.onRuntimeInitialized;a.onRuntimeInitialized=function(){c&&c();d(a)}}return a};na.prototype=Error();na.prototype.constructor=na;ra=function c(){a.calledRun||wa();a.calledRun||(ra=c)};a.run=wa;a.exit=function(c,b){if(!b||!a.noExitRuntime||0!==c){if(!a.noExitRuntime&&(oa=!0,ta=void 0,B(ob),a.onExit))a.onExit(c);qa&&process.exit(c);a.quit(c,new na(c))}};a.abort=O;if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0=l.size?(f(0>= +1;break;case 4:d>>=2;break;case 8:d>>=3}for(var c=0;cv;++v)for(var w=v,ba=7,w=w>>>1;w;w>>>=1)--ba;function x(e,c,d){var b,a="number"===typeof c?c:c=0,f="number"===typeof d?d:e.length;b=-1;for(a=f&7;a--;++c)b=b>>>8^z[(b^e[c])&255];for(a=f>>3;a--;c+=8)b=b>>>8^z[(b^e[c])&255],b=b>>>8^z[(b^e[c+1])&255],b=b>>>8^z[(b^e[c+2])&255],b=b>>>8^z[(b^e[c+3])&255],b=b>>>8^z[(b^e[c+4])&255],b=b>>>8^z[(b^e[c+5])&255],b=b>>>8^z[(b^e[c+6])&255],b=b>>>8^z[(b^e[c+7])&255];return(b^4294967295)>>>0} +var A=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759, +2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977, +2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755, +2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956, +3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270, +936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],z=u?new Uint32Array(A):A;function B(){}B.prototype.getName=function(){return this.name};B.prototype.getData=function(){return this.data};B.prototype.H=function(){return this.I};r("Zlib.GunzipMember",B);r("Zlib.GunzipMember.prototype.getName",B.prototype.getName);r("Zlib.GunzipMember.prototype.getData",B.prototype.getData);r("Zlib.GunzipMember.prototype.getMtime",B.prototype.H);function D(e){var c=e.length,d=0,b=Number.POSITIVE_INFINITY,a,f,g,k,m,p,t,h,l,y;for(h=0;hd&&(d=e[h]),e[h]>=1;y=g<<16|h;for(l=p;lF;F++)switch(!0){case 143>=F:E.push([F+48,8]);break;case 255>=F:E.push([F-144+400,9]);break;case 279>=F:E.push([F-256+0,7]);break;case 287>=F:E.push([F-280+192,8]);break;default:n("invalid literal: "+F)} +var ca=function(){function e(a){switch(!0){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272, +a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:n("invalid length: "+a)}}var c=[],d,b;for(d=3;258>=d;d++)b=e(d),c[d]=b[2]<<24|b[1]<< +16|b[0];return c}();u&&new Uint32Array(ca);function G(e,c){this.i=[];this.j=32768;this.d=this.f=this.c=this.n=0;this.input=u?new Uint8Array(e):e;this.o=!1;this.k=H;this.z=!1;if(c||!(c={}))c.index&&(this.c=c.index),c.bufferSize&&(this.j=c.bufferSize),c.bufferType&&(this.k=c.bufferType),c.resize&&(this.z=c.resize);switch(this.k){case I:this.a=32768;this.b=new (u?Uint8Array:Array)(32768+this.j+258);break;case H:this.a=0;this.b=new (u?Uint8Array:Array)(this.j);this.e=this.F;this.q=this.B;this.l=this.D;break;default:n(Error("invalid inflate mode"))}} +var I=0,H=1; +G.prototype.g=function(){for(;!this.o;){var e=J(this,3);e&1&&(this.o=!0);e>>>=1;switch(e){case 0:var c=this.input,d=this.c,b=this.b,a=this.a,f=c.length,g=q,k=q,m=b.length,p=q;this.d=this.f=0;d+1>=f&&n(Error("invalid uncompressed block header: LEN"));g=c[d++]|c[d++]<<8;d+1>=f&&n(Error("invalid uncompressed block header: NLEN"));k=c[d++]|c[d++]<<8;g===~k&&n(Error("invalid uncompressed block header: length verify"));d+g>c.length&&n(Error("input buffer is broken"));switch(this.k){case I:for(;a+g>b.length;){p= +m-a;g-=p;if(u)b.set(c.subarray(d,d+p),a),a+=p,d+=p;else for(;p--;)b[a++]=c[d++];this.a=a;b=this.e();a=this.a}break;case H:for(;a+g>b.length;)b=this.e({t:2});break;default:n(Error("invalid inflate mode"))}if(u)b.set(c.subarray(d,d+g),a),a+=g,d+=g;else for(;g--;)b[a++]=c[d++];this.c=d;this.a=a;this.b=b;break;case 1:this.l(da,ea);break;case 2:fa(this);break;default:n(Error("unknown BTYPE: "+e))}}return this.q()}; +var K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],L=u?new Uint16Array(K):K,N=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],O=u?new Uint16Array(N):N,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],Q=u?new Uint8Array(P):P,R=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ga=u?new Uint16Array(R):R,ha=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12, +13,13],U=u?new Uint8Array(ha):ha,V=new (u?Uint8Array:Array)(288),W,ia;W=0;for(ia=V.length;W=W?8:255>=W?9:279>=W?7:8;var da=D(V),X=new (u?Uint8Array:Array)(30),Y,ja;Y=0;for(ja=X.length;Y=g&&n(Error("input buffer is broken")),d|=a[f++]<>>c;e.d=b-c;e.c=f;return k} +function Z(e,c){for(var d=e.f,b=e.d,a=e.input,f=e.c,g=a.length,k=c[0],m=c[1],p,t;b=g);)d|=a[f++]<>>16;e.f=d>>t;e.d=b-t;e.c=f;return p&65535} +function fa(e){function c(a,c,b){var d,e=this.w,f,g;for(g=0;gf)b>=a&&(this.a=b,d=this.e(),b=this.a),d[b++]=f;else{g=f-257;m=O[g];0=a&&(this.a=b,d=this.e(),b=this.a);for(;m--;)d[b]=d[b++-k]}for(;8<=this.d;)this.d-=8,this.c--;this.a=b}; +G.prototype.D=function(e,c){var d=this.b,b=this.a;this.r=e;for(var a=d.length,f,g,k,m;256!==(f=Z(this,e));)if(256>f)b>=a&&(d=this.e(),a=d.length),d[b++]=f;else{g=f-257;m=O[g];0a&&(d=this.e(),a=d.length);for(;m--;)d[b]=d[b++-k]}for(;8<=this.d;)this.d-=8,this.c--;this.a=b}; +G.prototype.e=function(){var e=new (u?Uint8Array:Array)(this.a-32768),c=this.a-32768,d,b,a=this.b;if(u)e.set(a.subarray(32768,e.length));else{d=0;for(b=e.length;dd;++d)a[d]=a[c+d];this.a=32768;return a}; +G.prototype.F=function(e){var c,d=this.input.length/this.c+1|0,b,a,f,g=this.input,k=this.b;e&&("number"===typeof e.t&&(d=e.t),"number"===typeof e.A&&(d+=e.A));2>d?(b=(g.length-this.c)/this.r[2],f=258*(b/2)|0,a=fc&&(this.b.length=c),e=this.b);return this.buffer=e};function $(e){this.input=e;this.c=0;this.m=[];this.s=!1}$.prototype.G=function(){this.s||this.g();return this.m.slice()}; +$.prototype.g=function(){for(var e=this.input.length;this.c>>0;x(a,q,q)!==t&&n(Error("invalid CRC-32 checksum: 0x"+x(a,q,q).toString(16)+" / 0x"+t.toString(16)));c.M= +d=(h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24)>>>0;(a.length&4294967295)!==d&&n(Error("invalid input size: "+(a.length&4294967295)+" / "+d));this.m.push(c);this.c=l}this.s=!0;var y=this.m,s,M,S=0,T=0,C;s=0;for(M=y.length;sa&&(a=c[p]),c[p]>=1;x=g<<16|p;for(s=m;s>>=1;switch(c){case 0:var d=this.input,a=this.a,b=this.c,e=this.b,f=d.length,g=l,h=l,k=b.length,m=l;this.d=this.f=0;if(a+1>=f)throw Error("invalid uncompressed block header: LEN");g=d[a++]|d[a++]<<8;if(a+1>=f)throw Error("invalid uncompressed block header: NLEN");h=d[a++]|d[a++]<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case A:for(;e+ +g>b.length;){m=k-e;g-=m;if(t)b.set(d.subarray(a,a+m),e),e+=m,a+=m;else for(;m--;)b[e++]=d[a++];this.b=e;b=this.e();e=this.b}break;case y:for(;e+g>b.length;)b=this.e({p:2});break;default:throw Error("invalid inflate mode");}if(t)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.a=a;this.b=e;this.c=b;break;case 1:this.j(ba,ca);break;case 2:for(var n=C(this,5)+257,p=C(this,5)+1,s=C(this,4)+4,x=new (t?Uint8Array:Array)(D.length),S=l,T=l,U=l,u=l,M=l,F=l,z=l,q=l,V=l,q=0;q=P?8:255>=P?9:279>=P?7:8;var ba=v(O),Q=new (t?Uint8Array:Array)(30),R,ga;R=0;for(ga=Q.length;R=g)throw Error("input buffer is broken");a|=e[f++]<>>d;c.d=b-d;c.a=f;return h} +function E(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h=d[0],k=d[1],m,n;b=g);)a|=e[f++]<>>16;if(n>b)throw Error("invalid code length: "+n);c.f=a>>n;c.d=b-n;c.a=f;return m&65535} +w.prototype.j=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length-258,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(this.b=b,a=this.e(),b=this.b),a[b++]=f;else{g=f-257;k=I[g];0=e&&(this.b=b,a=this.e(),b=this.b);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b}; +w.prototype.w=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(a=this.e(),e=a.length),a[b++]=f;else{g=f-257;k=I[g];0e&&(a=this.e(),e=a.length);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b}; +w.prototype.e=function(){var c=new (t?Uint8Array:Array)(this.b-32768),d=this.b-32768,a,b,e=this.c;if(t)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;aa;++a)e[a]=e[d+a];this.b=32768;return e}; +w.prototype.z=function(c){var d,a=this.input.length/this.a+1|0,b,e,f,g=this.input,h=this.c;c&&("number"===typeof c.p&&(a=c.p),"number"===typeof c.u&&(a+=c.u));2>a?(b=(g.length-this.a)/this.o[2],f=258*(b/2)|0,e=fd&&(this.c.length=d),c=this.c);return this.buffer=c};function W(c,d){var a,b;this.input=c;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=c[this.a++];b=c[this.a++];switch(a&15){case ha:this.method=ha;break;default:throw Error("unsupported compression method");}if(0!==((a<<8)+b)%31)throw Error("invalid fcheck flag:"+((a<<8)+b)%31);if(b&32)throw Error("fdict flag is not supported");this.q=new w(c,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})} +W.prototype.k=function(){var c=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(c[this.a++]<<24|c[this.a++]<<16|c[this.a++]<<8|c[this.a++])>>>0;var b=d;if("string"===typeof b){var e=b.split(""),f,g;f=0;for(g=e.length;f>>0;b=e}for(var h=1,k=0,m=b.length,n,p=0;0>>0)throw Error("invalid adler-32 checksum");}return d};var ha=8;r("Zlib.Inflate",W);r("Zlib.Inflate.prototype.decompress",W.prototype.k);var X={ADAPTIVE:B.s,BLOCK:B.t},Y,Z,$,ia;if(Object.keys)Y=Object.keys(X);else for(Z in Y=[],$=0,X)Y[$++]=Z;$=0;for(ia=Y.length;$ + +(c) 2009-2014 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/master/LICENSE +*/ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSZip=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":8}],4:[function(a,b){"use strict";var c=a("./utils"),d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var e="string"!==c.getTypeOf(a);"undefined"==typeof b&&(b=0);var f=0,g=0,h=0;b=-1^b;for(var i=0,j=a.length;j>i;i++)h=e?a[i]:a.charCodeAt(i),g=255&(b^h),f=d[g],b=b>>>8^f;return-1^b}},{"./utils":21}],5:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":21}],6:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!1,c.date=null,c.compression=null,c.comment=null},{}],7:[function(a,b,c){"use strict";var d=a("./utils");c.string2binary=function(a){return d.string2binary(a)},c.string2Uint8Array=function(a){return d.transformTo("uint8array",a)},c.uint8Array2String=function(a){return d.transformTo("string",a)},c.string2Blob=function(a){var b=d.transformTo("arraybuffer",a);return d.arrayBuffer2Blob(b)},c.arrayBuffer2Blob=function(a){return d.arrayBuffer2Blob(a)},c.transformTo=function(a,b){return d.transformTo(a,b)},c.getTypeOf=function(a){return d.getTypeOf(a)},c.checkSupport=function(a){return d.checkSupport(a)},c.MAX_VALUE_16BITS=d.MAX_VALUE_16BITS,c.MAX_VALUE_32BITS=d.MAX_VALUE_32BITS,c.pretty=function(a){return d.pretty(a)},c.findCompression=function(a){return d.findCompression(a)},c.isRegExp=function(a){return d.isRegExp(a)}},{"./utils":21}],8:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("pako");c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a){return e.deflateRaw(a)},c.uncompress=function(a){return e.inflateRaw(a)}},{pako:24}],9:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.comment=null,this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}var d=a("./base64");c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./deprecatedPublicUtils"),c.base64={encode:function(a){return d.encode(a)},decode:function(a){return d.decode(a)}},c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;gc;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},t=function(){var a,b,c={};for(a=0;a0?a.substring(0,b):""},x=function(a,b){return"/"!=a.slice(-1)&&(a+="/"),b="undefined"!=typeof b?b:!1,this.files[a]||v.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},y=function(a,b){var c,f=new j;return a._data instanceof j?(f.uncompressedSize=a._data.uncompressedSize,f.crc32=a._data.crc32,0===f.uncompressedSize||a.dir?(b=i.STORE,f.compressedContent="",f.crc32=0):a._data.compressionMethod===b.magic?f.compressedContent=a._data.getCompressedContent():(c=a._data.getContent(),f.compressedContent=b.compress(d.transformTo(b.compressInputType,c)))):(c=p(a),(!c||0===c.length||a.dir)&&(b=i.STORE,c=""),f.uncompressedSize=c.length,f.crc32=e(c),f.compressedContent=b.compress(d.transformTo(b.compressInputType,c))),f.compressedSize=f.compressedContent.length,f.compressionMethod=b.magic,f},z=function(a,b,c,g){var h,i,j,k,m=(c.compressedContent,d.transformTo("string",l.utf8encode(b.name))),n=b.comment||"",o=d.transformTo("string",l.utf8encode(n)),p=m.length!==b.name.length,q=o.length!==n.length,r=b.options,t="",u="",v="";j=b._initialMetadata.dir!==b.dir?b.dir:r.dir,k=b._initialMetadata.date!==b.date?b.date:r.date,h=k.getHours(),h<<=6,h|=k.getMinutes(),h<<=5,h|=k.getSeconds()/2,i=k.getFullYear()-1980,i<<=4,i|=k.getMonth()+1,i<<=5,i|=k.getDate(),p&&(u=s(1,1)+s(e(m),4)+m,t+="up"+s(u.length,2)+u),q&&(v=s(1,1)+s(this.crc32(o),4)+o,t+="uc"+s(v.length,2)+v);var w="";w+="\n\x00",w+=p||q?"\x00\b":"\x00\x00",w+=c.compressionMethod,w+=s(h,2),w+=s(i,2),w+=s(c.crc32,4),w+=s(c.compressedSize,4),w+=s(c.uncompressedSize,4),w+=s(m.length,2),w+=s(t.length,2);var x=f.LOCAL_FILE_HEADER+w+m+t,y=f.CENTRAL_FILE_HEADER+"\x00"+w+s(o.length,2)+"\x00\x00\x00\x00"+(j===!0?"\x00\x00\x00":"\x00\x00\x00\x00")+s(g,4)+m+t+o;return{fileRecord:x,dirRecord:y,compressedObject:c}},A={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new r(d.name,d._data,t(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(d.isRegExp(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}return this.filter(function(b,c){return!c.dir&&b===a})[0]||null}return a=this.root+a,v.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d.isRegExp(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=x.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":5}],19:[function(a,b){"use strict";var c=a("./utils"),d=function(a){this.data=new Uint8Array(a),this.index=0};d.prototype={append:function(a){0!==a.length&&(a=c.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}},b.exports=d},{"./utils":21}],20:[function(a,b,c){"use strict";for(var d=a("./utils"),e=a("./support"),f=a("./nodeBuffer"),g=new Array(256),h=0;256>h;h++)g[h]=h>=252?6:h>=248?5:h>=240?4:h>=224?3:h>=192?2:1;g[254]=g[254]=1;var i=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=e.uint8array?new Uint8Array(i):new Array(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},j=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+g[a[c]]>b?c:b},k=function(a){var b,c,e,f,h=a.length,i=new Array(2*h);for(c=0,b=0;h>b;)if(e=a[b++],128>e)i[c++]=e;else if(f=g[e],f>4)i[c++]=65533,b+=f-1;else{for(e&=2===f?31:3===f?15:7;f>1&&h>b;)e=e<<6|63&a[b++],f--;f>1?i[c++]=65533:65536>e?i[c++]=e:(e-=65536,i[c++]=55296|e>>10&1023,i[c++]=56320|1023&e)}return i.length!==c&&(i.subarray?i=i.subarray(0,c):i.length=c),d.applyFromCharCode(i)};c.utf8encode=function(a){return e.nodebuffer?f(a,"utf-8"):i(a)},c.utf8decode=function(a){if(e.nodebuffer)return d.transformTo("nodebuffer",a).toString("utf-8");a=d.transformTo(e.uint8array?"uint8array":"array",a);for(var b=[],c=0,f=a.length,g=65536;f>c;){var h=j(a,Math.min(c+g,f));b.push(e.uint8array?k(a.subarray(c,h)):k(a.slice(c,h))),c=h}return b.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;cg&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support"),k=a("./object");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength),this.zipComment=k.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=g.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==n)throw new Error(j[c]);b.header&&g.deflateSetHeader(this.strm,b.header) +};s.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?m:l,e.input="string"==typeof a?i.string2buf(a):a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new h.Buf8(f),e.next_out=0,e.avail_out=f),c=g.deflate(e,d),c!==o&&c!==n)return this.onEnd(c),this.ended=!0,!1;(0===e.avail_out||0===e.avail_in&&d===m)&&this.onData("string"===this.options.to?i.buf2binstring(h.shrinkBuf(e.output,e.next_out)):h.shrinkBuf(e.output,e.next_out))}while((e.avail_in>0||0===e.avail_out)&&c!==o);return d===m?(c=g.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===n):!0},s.prototype.onData=function(a){this.chunks.push(a)},s.prototype.onEnd=function(a){a===n&&(this.result="string"===this.options.to?this.chunks.join(""):h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=s,c.deflate=d,c.deflateRaw=e,c.gzip=f},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(a,b,c){"use strict";function d(a,b){var c=new m(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};m.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,m=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,l.input="string"==typeof a?h.binstring2buf(a):a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(m),l.next_out=0,l.avail_out=m),c=f.inflate(l,i.Z_NO_FLUSH),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&d===i.Z_FINISH)&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=m-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out)))}while(l.avail_in>0&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):!0},m.prototype.onData=function(a){this.chunks.push(a)},m.prototype.onEnd=function(a){a===i.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=m,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],28:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":27}],29:[function(a,b){"use strict";function c(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=c},{}],30:[function(a,b){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(a,b){"use strict";function c(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function d(a,b,c,d){var f=e,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^f[255&(a^b[h])];return-1^a}var e=c();b.exports=d},{}],32:[function(a,b,c){"use strict";function d(a,b){return a.msg=G[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(C.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){D._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,C.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=E(a.adler,b,e,c):2===a.state.wrap&&(a.adler=F(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-jb?a.strstart-(a.w_size-jb):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ib,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&m>f);if(d=ib-(m-f),f=m-ib,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-jb)){C.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=hb)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===H)return sb;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return sb;if(a.strstart-a.block_start>=a.w_size-jb&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?sb:sb}function o(a,b){for(var c,d;;){if(a.lookahead=hb&&(a.ins_h=(a.ins_h<=hb)if(d=D._tr_tally(a,a.strstart-a.match_start,a.match_length-hb),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=hb){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<=hb&&(a.ins_h=(a.ins_h<4096)&&(a.match_length=hb-1)),a.prev_length>=hb&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-hb,d=D._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-hb),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<=hb&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ib;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&f>e);a.match_length=ib-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=hb?(c=D._tr_tally(a,1,a.match_length-hb),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===H)return sb;break}if(a.match_length=0,c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function s(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=B[a.level].max_lazy,a.good_match=B[a.level].good_length,a.nice_match=B[a.level].nice_length,a.max_chain_length=B[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=hb-1,a.match_available=0,a.ins_h=0}function t(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(2*fb),this.dyn_dtree=new C.Buf16(2*(2*db+1)),this.bl_tree=new C.Buf16(2*(2*eb+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(gb+1),this.heap=new C.Buf16(2*cb+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*cb+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function u(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=X,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?lb:qb,a.adler=2===b.wrap?0:1,b.last_flush=H,D._tr_init(b),M):d(a,O)}function v(a){var b=u(a);return b===M&&s(a.state),b}function w(a,b){return a&&a.state?2!==a.state.wrap?O:(a.state.gzhead=b,M):O}function x(a,b,c,e,f,g){if(!a)return O;var h=1;if(b===R&&(b=6),0>e?(h=0,e=-e):e>15&&(h=2,e-=16),1>f||f>Z||c!==Y||8>e||e>15||0>b||b>9||0>g||g>V)return d(a,O);8===e&&(e=9);var i=new t;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<>1,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,v(a)}function y(a,b){return x(a,b,Y,$,_,W)}function z(a,b){var c,h,k,l;if(!a||!a.state||b>L||0>b)return a?d(a,O):O;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===rb&&b!==K)return d(a,0===a.avail_out?Q:O);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===lb)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=F(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=mb):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,wb),h.status=qb);else{var m=Y+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=T||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=kb),m+=31-m%31,h.status=qb,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===mb)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=nb)}else h.status=nb;if(h.status===nb)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=ob)}else h.status=ob;if(h.status===ob)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=pb)}else h.status=pb;if(h.status===pb&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=qb)):h.status=qb),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,M}else if(0===a.avail_in&&e(b)<=e(c)&&b!==K)return d(a,Q);if(h.status===rb&&0!==a.avail_in)return d(a,Q);if(0!==a.avail_in||0!==h.lookahead||b!==H&&h.status!==rb){var o=h.strategy===T?r(h,b):h.strategy===U?q(h,b):B[h.level].func(h,b);if((o===ub||o===vb)&&(h.status=rb),o===sb||o===ub)return 0===a.avail_out&&(h.last_flush=-1),M;if(o===tb&&(b===I?D._tr_align(h):b!==L&&(D._tr_stored_block(h,0,0,!1),b===J&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,M}return b!==K?M:h.wrap<=0?N:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?M:N)}function A(a){var b;return a&&a.state?(b=a.state.status,b!==lb&&b!==mb&&b!==nb&&b!==ob&&b!==pb&&b!==qb&&b!==rb?d(a,O):(a.state=null,b===qb?d(a,P):M)):O}var B,C=a("../utils/common"),D=a("./trees"),E=a("./adler32"),F=a("./crc32"),G=a("./messages"),H=0,I=1,J=3,K=4,L=5,M=0,N=1,O=-2,P=-3,Q=-5,R=-1,S=1,T=2,U=3,V=4,W=0,X=2,Y=8,Z=9,$=15,_=8,ab=29,bb=256,cb=bb+1+ab,db=30,eb=19,fb=2*cb+1,gb=15,hb=3,ib=258,jb=ib+hb+1,kb=32,lb=42,mb=69,nb=73,ob=91,pb=103,qb=113,rb=666,sb=1,tb=2,ub=3,vb=4,wb=3,xb=function(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e};B=[new xb(0,0,0,0,n),new xb(4,4,8,4,o),new xb(4,5,16,8,o),new xb(4,6,32,32,o),new xb(4,4,16,16,p),new xb(8,16,32,32,p),new xb(8,16,128,128,p),new xb(8,32,128,256,p),new xb(32,128,258,1024,p),new xb(32,258,258,4096,p)],c.deflateInit=y,c.deflateInit2=x,c.deflateReset=v,c.deflateResetKeep=u,c.deflateSetHeader=w,c.deflate=z,c.deflateEnd=A,c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(a,b){"use strict";function c(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=c},{}],34:[function(a,b){"use strict";var c=30,d=12;b.exports=function(a,b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;e=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=e.dmax,l=e.wsize,m=e.whave,n=e.wnext,o=e.window,p=e.hold,q=e.bits,r=e.lencode,s=e.distcode,t=(1<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",e.mode=c;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&e.sane){a.msg="invalid distance too far back",e.mode=c;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),e.hold=p,e.bits=q}},{}],35:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(ob),b.distcode=b.distdyn=new r.Buf32(pb),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,rb)}function k(a){if(sb){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sb=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=lb;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=lb;break}if(m>>>=4,n-=4,wb=(15&m)+8,0===c.wbits)c.wbits=wb;else if(wb>c.wbits){a.msg="invalid window size",c.mode=lb;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Bb[2]=m>>>16&255,Bb[3]=m>>>24&255,c.check=t(c.check,Bb,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wb=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wb)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.name+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.comment+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ib;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=bb,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=lb}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=lb;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=lb;break}c.have=0,c.mode=_;case _:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Cb[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,yb={bits:c.lenbits},xb=v(w,c.lens,0,19,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid code lengths set",c.mode=lb;break}c.have=0,c.mode=ab;case ab:for(;c.have>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<sb)m>>>=qb,n-=qb,c.lens[c.have++]=sb;else{if(16===sb){for(zb=qb+2;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,0===c.have){a.msg="invalid bit length repeat",c.mode=lb;break}wb=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sb){for(zb=qb+3;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=3+(7&m),m>>>=3,n-=3}else{for(zb=qb+7;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=lb;break}for(;q--;)c.lens[c.have++]=wb}}if(c.mode===lb)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=lb;break}if(c.lenbits=9,yb={bits:c.lenbits},xb=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid literal/lengths set",c.mode=lb;break}if(c.distbits=6,c.distcode=c.distdyn,yb={bits:c.distbits},xb=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,yb),c.distbits=yb.bits,xb){a.msg="invalid distances set",c.mode=lb;break}if(c.mode=bb,b===B)break a;case bb:c.mode=cb;case cb:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1);break}for(c.back=0;Ab=c.lencode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,c.length=sb,0===rb){c.mode=hb;break}if(32&rb){c.back=-1,c.mode=V;break}if(64&rb){a.msg="invalid literal/length code",c.mode=lb;break}c.extra=15&rb,c.mode=db;case db:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=eb;case eb:for(;Ab=c.distcode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,64&rb){a.msg="invalid distance code",c.mode=lb;break}c.offset=sb,c.extra=15&rb,c.mode=fb;case fb:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=lb;break}c.mode=gb;case gb:if(0===j)break a; +if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=lb;break}q>c.wnext?(q-=c.wnext,ob=c.wsize-q):ob=c.wnext-q,q>c.length&&(q=c.length),pb=c.window}else pb=f,ob=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pb[ob++];while(--q);0===c.length&&(c.mode=cb);break;case hb:if(0===j)break a;f[h++]=c.length,j--,c.mode=cb;break;case ib:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[n+E]]++;for(H=C,G=d;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;d>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===g||1!==G))return-1;for(Q[1]=0,D=1;d>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[n+E]&&(r[Q[b[n+E]]++]=E);if(a===g?(N=R=r,y=19):a===h?(N=j,O-=257,R=k,S-=257,y=256):(N=l,R=m,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<e||a===i&&L>f)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[n+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<e||a===i&&L>f)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":27}],37:[function(a,b){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a){return 256>a?gb[a]:gb[256+(a>>>7)]}function f(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function g(a,b,c){a.bi_valid>V-c?(a.bi_buf|=b<>V-a.bi_valid,a.bi_valid+=c-V):(a.bi_buf|=b<>>=1,c<<=1;while(--b>0);return c>>>1}function j(a){16===a.bi_valid?(f(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function k(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;U>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;T>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function l(a,b,c){var d,e,f=new Array(U+1),g=0;for(d=1;U>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=i(f[h]++,h))}}function m(){var a,b,c,d,e,f=new Array(U+1);for(c=0,d=0;O-1>d;d++)for(ib[d]=c,a=0;a<1<<_[d];a++)hb[c++]=d;for(hb[c-1]=d,e=0,d=0;16>d;d++)for(jb[d]=e,a=0;a<1<>=7;R>d;d++)for(jb[d]=e<<7,a=0;a<1<=b;b++)f[b]=0;for(a=0;143>=a;)eb[2*a+1]=8,a++,f[8]++;for(;255>=a;)eb[2*a+1]=9,a++,f[9]++;for(;279>=a;)eb[2*a+1]=7,a++,f[7]++;for(;287>=a;)eb[2*a+1]=8,a++,f[8]++;for(l(eb,Q+1,f),a=0;R>a;a++)fb[2*a+1]=5,fb[2*a]=i(a,5);kb=new nb(eb,_,P+1,Q,U),lb=new nb(fb,ab,0,R,U),mb=new nb(new Array(0),bb,0,S,W)}function n(a){var b;for(b=0;Q>b;b++)a.dyn_ltree[2*b]=0;for(b=0;R>b;b++)a.dyn_dtree[2*b]=0;for(b=0;S>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*X]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function o(a){a.bi_valid>8?f(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function p(a,b,c,d){o(a),d&&(f(a,c),f(a,~c)),E.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function q(a,b,c,d){var e=2*b,f=2*c;return a[e]c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)r(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],r(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,r(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],k(a,b),l(f,j,a.bl_count)}function u(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1],++hh?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*Y]++):10>=h?a.bl_tree[2*Z]++:a.bl_tree[2*$]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function v(a,b,c){var d,e,f=-1,i=b[1],j=0,k=7,l=4;for(0===i&&(k=138,l=3),d=0;c>=d;d++)if(e=i,i=b[2*(d+1)+1],!(++jj){do h(a,e,a.bl_tree);while(0!==--j)}else 0!==e?(e!==f&&(h(a,e,a.bl_tree),j--),h(a,Y,a.bl_tree),g(a,j-3,2)):10>=j?(h(a,Z,a.bl_tree),g(a,j-3,3)):(h(a,$,a.bl_tree),g(a,j-11,7));j=0,f=e,0===i?(k=138,l=3):e===i?(k=6,l=3):(k=7,l=4)}}function w(a){var b;for(u(a,a.dyn_ltree,a.l_desc.max_code),u(a,a.dyn_dtree,a.d_desc.max_code),t(a,a.bl_desc),b=S-1;b>=3&&0===a.bl_tree[2*cb[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function x(a,b,c,d){var e;for(g(a,b-257,5),g(a,c-1,5),g(a,d-4,4),e=0;d>e;e++)g(a,a.bl_tree[2*cb[e]+1],3);v(a,a.dyn_ltree,b-1),v(a,a.dyn_dtree,c-1)}function y(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return G;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return H;for(b=32;P>b;b++)if(0!==a.dyn_ltree[2*b])return H;return G}function z(a){pb||(m(),pb=!0),a.l_desc=new ob(a.dyn_ltree,kb),a.d_desc=new ob(a.dyn_dtree,lb),a.bl_desc=new ob(a.bl_tree,mb),a.bi_buf=0,a.bi_valid=0,n(a)}function A(a,b,c,d){g(a,(J<<1)+(d?1:0),3),p(a,b,c,!0)}function B(a){g(a,K<<1,3),h(a,X,eb),j(a)}function C(a,b,c,d){var e,f,h=0;a.level>0?(a.strm.data_type===I&&(a.strm.data_type=y(a)),t(a,a.l_desc),t(a,a.d_desc),h=w(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?A(a,b,c,d):a.strategy===F||f===e?(g(a,(K<<1)+(d?1:0),3),s(a,eb,fb)):(g(a,(L<<1)+(d?1:0),3),x(a,a.l_desc.max_code+1,a.d_desc.max_code+1,h+1),s(a,a.dyn_ltree,a.dyn_dtree)),n(a),d&&o(a)}function D(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(hb[c]+P+1)]++,a.dyn_dtree[2*e(b)]++),a.last_lit===a.lit_bufsize-1}var E=a("../utils/common"),F=4,G=0,H=1,I=2,J=0,K=1,L=2,M=3,N=258,O=29,P=256,Q=P+1+O,R=30,S=19,T=2*Q+1,U=15,V=16,W=7,X=256,Y=16,Z=17,$=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ab=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],db=512,eb=new Array(2*(Q+2));d(eb);var fb=new Array(2*R);d(fb);var gb=new Array(db);d(gb);var hb=new Array(N-M+1);d(hb);var ib=new Array(O);d(ib);var jb=new Array(R);d(jb);var kb,lb,mb,nb=function(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length},ob=function(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b},pb=!1;c._tr_init=z,c._tr_stored_block=A,c._tr_flush_block=C,c._tr_tally=D,c._tr_align=B},{"../utils/common":27}],39:[function(a,b){"use strict";function c(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=c},{}]},{},[9])(9)}); \ No newline at end of file diff --git a/three/jsutil/libs/mmdparser.min.js b/three/jsutil/libs/mmdparser.min.js new file mode 100644 index 000000000..f17cd9f8e --- /dev/null +++ b/three/jsutil/libs/mmdparser.min.js @@ -0,0 +1,6 @@ +// https://github.com/takahirox/mmd-parser#readme +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.MMDParser=t.MMDParser||{})}(this,function(t){"use strict";function e(){}function n(t,n){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===n||n,this.encoder=new e}function a(){}function o(){}e.prototype.s2u=function(t){for(var e=this.s2uTable,n="",a=0;a=0&&o<=126||o>=161&&o<=223)&&a0;){var n=this.getUint8();if(t--,0===n)break;e+=String.fromCharCode(n)}for(;t>0;)this.getUint8(),t--;return e},getSjisStringsAsUnicode:function(t){for(var e=[];t>0;){var n=this.getUint8();if(t--,0===n)break;e.push(n)}for(;t>0;)this.getUint8(),t--;return this.encoder.s2u(new Uint8Array(e))},getUnicodeStrings:function(t){for(var e="";t>0;){var n=this.getUint16();if(t-=2,0===n)break;e+=String.fromCharCode(n)}for(;t>0;)this.getUint8(),t--;return e},getTextBuffer:function(){var t=this.getUint32();return this.getUnicodeStrings(t)}},a.prototype={constructor:a,leftToRightVector3:function(t){t[2]=-t[2]},leftToRightQuaternion:function(t){t[0]=-t[0],t[1]=-t[1]},leftToRightEuler:function(t){t[0]=-t[0],t[1]=-t[1]},leftToRightIndexOrder:function(t){var e=t[2];t[2]=t[0],t[0]=e},leftToRightVector3Range:function(t,e){var n=-e[2];e[2]=-t[2],t[2]=n},leftToRightEulerRange:function(t,e){var n=-e[0],a=-e[1];e[0]=-t[0],e[1]=-t[1],t[0]=n,t[1]=a}},o.prototype.parsePmd=function(t,e){var a={},o=new n(t);a.metadata={},a.metadata.format="pmd",a.metadata.coordinateSystem="left";var i=function(){var t=a.metadata;if(t.magic=o.getChars(3),"Pmd"!==t.magic)throw"PMD file magic is not Pmd, but "+t.magic;t.version=o.getFloat32(),t.modelName=o.getSjisStringsAsUnicode(20),t.comment=o.getSjisStringsAsUnicode(256)},r=function(){var t=function(){var t={};return t.position=o.getFloat32Array(3),t.normal=o.getFloat32Array(3),t.uv=o.getFloat32Array(2),t.skinIndices=o.getUint16Array(2),t.skinWeights=[o.getUint8()/100],t.skinWeights.push(1-t.skinWeights[0]),t.edgeFlag=o.getUint8(),t},e=a.metadata;e.vertexCount=o.getUint32(),a.vertices=[];for(var n=0;n0&&(t.englishModelName=o.getSjisStringsAsUnicode(20),t.englishComment=o.getSjisStringsAsUnicode(256))},p=function(){var t=function(){var t={};return t.name=o.getSjisStringsAsUnicode(20),t},e=a.metadata;if(0!==e.englishCompatibility){a.englishBoneNames=[];for(var n=0;n>> 0) - 1; + local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL1 = 6; + local.O3DGC_BINARY_STREAM_MAX_SYMBOL1 = 63; // ((1 << O3DGC_BINARY_STREAM_BITS_PER_SYMBOL1) >>> 0) - 1; + local.O3DGC_BINARY_STREAM_NUM_SYMBOLS_UINT32 = 5; // Math.floor((32 + O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0 - 1) / O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0); + local.O3DGC_BIG_ENDIAN = 0; + local.O3DGC_LITTLE_ENDIAN = 1; + local.O3DGC_MAX_DOUBLE = 1.79769e+308; + local.O3DGC_MIN_LONG = -2147483647; + local.O3DGC_MAX_LONG = 2147483647; + local.O3DGC_MAX_UCHAR8 = 255; + local.O3DGC_MAX_TFAN_SIZE = 256; + local.O3DGC_MAX_ULONG = 4294967295; + local.O3DGC_SC3DMC_START_CODE = 0x00001F1; + local.O3DGC_DV_START_CODE = 0x00001F2; + local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES = 256; + local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES = 256; + local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES = 32; + local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS = 2; + local.O3DGC_SC3DMC_BINARIZATION_FL = 0; // Fixed Length (not supported) + local.O3DGC_SC3DMC_BINARIZATION_BP = 1; // BPC (not supported) + local.O3DGC_SC3DMC_BINARIZATION_FC = 2; // 4 bits Coding (not supported) + local.O3DGC_SC3DMC_BINARIZATION_AC = 3; // Arithmetic Coding (not supported) + local.O3DGC_SC3DMC_BINARIZATION_AC_EGC = 4; // Arithmetic Coding & EGCk + local.O3DGC_SC3DMC_BINARIZATION_ASCII = 5; // Arithmetic Coding & EGCk + local.O3DGC_STREAM_TYPE_UNKOWN = 0; + local.O3DGC_STREAM_TYPE_ASCII = 1; + local.O3DGC_STREAM_TYPE_BINARY = 2; + local.O3DGC_SC3DMC_NO_PREDICTION = 0; // supported + local.O3DGC_SC3DMC_DIFFERENTIAL_PREDICTION = 1; // supported + local.O3DGC_SC3DMC_XOR_PREDICTION = 2; // not supported + local.O3DGC_SC3DMC_ADAPTIVE_DIFFERENTIAL_PREDICTION = 3; // not supported + local.O3DGC_SC3DMC_CIRCULAR_DIFFERENTIAL_PREDICTION = 4; // not supported + local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION = 5; // supported + local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION = 6; // supported + local.O3DGC_SC3DMC_ENCODE_MODE_QBCR = 0; // not supported + local.O3DGC_SC3DMC_ENCODE_MODE_SVA = 1; // not supported + local.O3DGC_SC3DMC_ENCODE_MODE_TFAN = 2; // supported + local.O3DGC_DYNAMIC_VECTOR_ENCODE_MODE_LIFT = 0; + local.O3DGC_MIN_NEIGHBORS_SIZE = 128; + local.O3DGC_MIN_NUM_NEIGHBORS_SIZE = 16; + local.O3DGC_TFANS_MIN_SIZE_ALLOCATED_VERTICES_BUFFER = 128; + local.O3DGC_TFANS_MIN_SIZE_TFAN_SIZE_BUFFER = 8; + local.O3DGC_DEFAULT_VECTOR_SIZE = 32; + + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_UNKOWN = 0; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_POSITION = 1; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_NORMAL = 2; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_COLOR = 3; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_TEXCOORD = 4; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_WEIGHT = 5; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_UNKOWN = 0; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX = 1; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_JOINT_ID = 2; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX_BUFFER_ID = 3; + + module.O3DGC_OK = 0; + module.O3DGC_ERROR_BUFFER_FULL = 1; + module.O3DGC_ERROR_CORRUPTED_STREAM = 5; + module.O3DGC_ERROR_NON_SUPPORTED_FEATURE = 6; + module.O3DGC_ERROR_AC = 7; + + function SystemEndianness() { + var a, b, c; + b = new ArrayBuffer(4); + a = new Uint32Array(b); + c = new Uint8Array(b); + a[0] = 1; + if (c[0] === 1) { + return local.O3DGC_LITTLE_ENDIAN; + } + return local.O3DGC_BIG_ENDIAN; + } + // SC3DMCStats class + module.SC3DMCStats = function () { + this.m_timeCoord = 0; + this.m_timeNormal = 0; + this.m_timeCoordIndex = 0; + this.m_timeFloatAttribute = new Float32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_timeIntAttribute = new Float32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_timeReorder = 0; + this.m_streamSizeCoord = 0; + this.m_streamSizeNormal = 0; + this.m_streamSizeCoordIndex = 0; + this.m_streamSizeFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_streamSizeIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + }; + // SC3DMCTriplet class + module.SC3DMCTriplet = function (a, b, c) { + this.m_a = a; + this.m_b = b; + this.m_c = c; + }; + module.SC3DMCTriplet.prototype.Less = function (rhs) { + var res; + if (this.m_c !== rhs.m_c) { + res = (this.m_c < rhs.m_c); + } else if (this.m_b !== rhs.m_b) { + res = (this.m_b < rhs.m_b); + } else { + res = (this.m_a < rhs.m_a); + } + return res; + }; + module.SC3DMCTriplet.prototype.Equal = function (rhs) { + return (this.m_c === rhs.m_c && this.m_b === rhs.m_b && this.m_a === rhs.m_a); + }; + // SC3DMCPredictor class + module.SC3DMCPredictor = function () { + this.m_id = new module.SC3DMCTriplet(-1, -1, -1); + this.m_pred = new Float32Array(local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + }; + // fix me: optimize this function (e.g., binary search) + function InsertPredictor(e, nPred, list, dimFloatArray) { + var pos, foundOrInserted, j, j1, j0, h, i; + pos = -1; + foundOrInserted = false; + j1 = nPred.m_value; + j0 = 0; + for (j = j0; j < j1; ++j) { + if (e.Equal(list[j].m_id)) { + foundOrInserted = true; + break; + } else if (e.Less(list[j].m_id)) { + if (nPred.m_value < local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS) { + ++nPred.m_value; + } + for (h = nPred.m_value - 1; h > j; --h) { + list[h].m_id.m_a = list[h - 1].m_id.m_a; + list[h].m_id.m_b = list[h - 1].m_id.m_b; + list[h].m_id.m_c = list[h - 1].m_id.m_c; + for (i = 0; i < dimFloatArray; ++i) { + list[h].m_pred[i] = list[h - 1].m_pred[i]; + } + } + list[j].m_id.m_a = e.m_a; + list[j].m_id.m_b = e.m_b; + list[j].m_id.m_c = e.m_c; + pos = j; + foundOrInserted = true; + break; + } + } + if (!foundOrInserted && nPred.m_value < local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS) { + pos = nPred.m_value++; + list[pos].m_id.m_a = e.m_a; + list[pos].m_id.m_b = e.m_b; + list[pos].m_id.m_c = e.m_c; + } + return pos; + } + // Timer class + if (typeof window.performance === 'undefined') { + window.performance = {}; + } + if (!window.performance.now) { + local.nowOffset = Date.now(); + if (performance.timing && performance.timing.navigationStart) { + local.nowOffset = performance.timing.navigationStart; + } + window.performance.now = function now() { + return Date.now() - local.nowOffset; + }; + } + module.Timer = function () { + this.m_start = 0; + this.m_end = 0; + }; + module.Timer.prototype.Tic = function () { + this.m_start = window.performance.now(); + }; + module.Timer.prototype.Toc = function () { + this.m_end = window.performance.now(); + }; + module.Timer.prototype.GetElapsedTime = function () { + return this.m_end - this.m_start; + }; + // Vec3 class + module.Vec3 = function (x, y, z) { + this.m_x = x; + this.m_y = y; + this.m_z = z; + }; + module.Vec3.prototype.Set = function (x, y, z) { + this.m_x = x; + this.m_y = y; + this.m_z = z; + }; + module.Vec3.prototype.Sub = function (lhs, rhs) { + this.m_x = lhs.m_x - rhs.m_x; + this.m_y = lhs.m_y - rhs.m_y; + this.m_z = lhs.m_z - rhs.m_z; + }; + module.Vec3.prototype.Add = function (lhs, rhs) { + this.m_x = lhs.m_x + rhs.m_x; + this.m_y = lhs.m_y + rhs.m_y; + this.m_z = lhs.m_z + rhs.m_z; + }; + module.Vec3.prototype.SelfAdd = function (v) { + this.m_x += v.m_x; + this.m_y += v.m_y; + this.m_z += v.m_z; + }; + module.Vec3.prototype.Cross = function (lhs, rhs) { + this.m_x = lhs.m_y * rhs.m_z - lhs.m_z * rhs.m_y; + this.m_y = lhs.m_z * rhs.m_x - lhs.m_x * rhs.m_z; + this.m_z = lhs.m_x * rhs.m_y - lhs.m_y * rhs.m_x; + }; + module.Vec3.prototype.GetNorm = function () { + return Math.sqrt(this.m_x * this.m_x + this.m_y * this.m_y + this.m_z * this.m_z); + }; + function SphereToCube(vin, vout) { + var ax, ay, az; + ax = Math.abs(vin.m_x); + ay = Math.abs(vin.m_y); + az = Math.abs(vin.m_z); + if (az >= ax && az >= ay) { + if (vin.m_z >= 0) { + vout.m_z = 0; + vout.m_x = vin.m_x; + vout.m_y = vin.m_y; + } else { + vout.m_z = 1; + vout.m_x = -vin.m_x; + vout.m_y = -vin.m_y; + } + } else if (ay >= ax && ay >= az) { + if (vin.m_y >= 0) { + vout.m_z = 2; + vout.m_x = vin.m_z; + vout.m_y = vin.m_x; + } else { + vout.m_z = 3; + vout.m_x = -vin.m_z; + vout.m_y = -vin.m_x; + } + } else { + if (vin.m_x >= 0) { + vout.m_z = 4; + vout.m_x = vin.m_y; + vout.m_y = vin.m_z; + } else { + vout.m_z = 5; + vout.m_x = -vin.m_y; + vout.m_y = -vin.m_z; + } + } + } + local.CubeToSphere = { + 0: function (vin, vout) { + vout.m_x = vin.m_x; + vout.m_y = vin.m_y; + vout.m_z = Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_y * vout.m_y)); + }, + 1: function (vin, vout) { + vout.m_x = -vin.m_x; + vout.m_y = -vin.m_y; + vout.m_z = -Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_y * vout.m_y)); + }, + 2: function (vin, vout) { + vout.m_z = vin.m_x; + vout.m_x = vin.m_y; + vout.m_y = Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_z * vout.m_z)); + }, + 3: function (vin, vout) { + vout.m_z = -vin.m_x; + vout.m_x = -vin.m_y; + vout.m_y = -Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_z * vout.m_z)); + }, + 4: function (vin, vout) { + vout.m_y = vin.m_x; + vout.m_z = vin.m_y; + vout.m_x = Math.sqrt(Math.max(0.0, 1.0 - vout.m_y * vout.m_y - vout.m_z * vout.m_z)); + }, + 5: function (vin, vout) { + vout.m_y = -vin.m_x; + vout.m_z = -vin.m_y; + vout.m_x = -Math.sqrt(Math.max(0.0, 1.0 - vout.m_y * vout.m_y - vout.m_z * vout.m_z)); + } + }; + function IntToUInt(value) { + return (value < 0) ? (-1 - (2 * value)) : (2 * value); + } + function UIntToInt(uiValue) { + return (uiValue & 1) ? -((uiValue + 1) >>> 1) : ((uiValue >>> 1)); + } + module.Iterator = function () { + this.m_count = 0; + }; + module.NumberRef = function () { + this.m_value = 0; + }; + // BinaryStream class + module.BinaryStream = function (buffer) { + this.m_endianness = SystemEndianness(); + this.m_buffer = buffer; + this.m_stream = new Uint8Array(this.m_buffer); + this.m_localBuffer = new ArrayBuffer(4); + this.m_localBufferViewUChar8 = new Uint8Array(this.m_localBuffer); + this.m_localBufferViewFloat32 = new Float32Array(this.m_localBuffer); + this.m_localBufferViewUInt32 = new Uint32Array(this.m_localBuffer); + }; + module.BinaryStream.prototype.ReadFloat32Bin = function (bsIterator) { + if (this.m_endianness === local.O3DGC_BIG_ENDIAN) { + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + } else { + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + } + return this.m_localBufferViewFloat32[0]; + }; + module.BinaryStream.prototype.ReadUInt32Bin = function (bsIterator) { + if (this.m_endianness === local.O3DGC_BIG_ENDIAN) { + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + } else { + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + } + return this.m_localBufferViewUInt32[0]; + }; + module.BinaryStream.prototype.ReadUChar8Bin = function (bsIterator) { + return this.m_stream[bsIterator.m_count++]; + }; + module.BinaryStream.prototype.ReadUInt32ASCII = function (bsIterator) { + var value, shift, i; + value = 0; + shift = 0; + for (i = 0; i < local.O3DGC_BINARY_STREAM_NUM_SYMBOLS_UINT32; ++i) { + value += (this.m_stream[bsIterator.m_count++] << shift) >>> 0; + shift += local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0; + } + return value; + }; + module.BinaryStream.prototype.ReadFloat32ASCII = function (bsIterator) { + var value = this.ReadUInt32ASCII(bsIterator); + if (this.m_endianness === local.O3DGC_BIG_ENDIAN) { + this.m_localBufferViewUChar8[3] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[2] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[1] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[0] = value & local.O3DGC_MAX_UCHAR8; + } else { + this.m_localBufferViewUChar8[0] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[1] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[2] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[3] = value & local.O3DGC_MAX_UCHAR8; + } + return this.m_localBufferViewFloat32[0]; + }; + module.BinaryStream.prototype.ReadIntASCII = function (bsIterator) { + return UIntToInt(this.ReadUIntASCII(bsIterator)); + }; + module.BinaryStream.prototype.ReadUIntASCII = function (bsIterator) { + var i, x, value; + value = this.m_stream[bsIterator.m_count++]; + if (value === local.O3DGC_BINARY_STREAM_MAX_SYMBOL0) { + i = 0; + do { + x = this.m_stream[bsIterator.m_count++]; + value += ((x >>> 1) << i) >>> 0; + i += local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL1; + } while (x & 1); + } + return value; + }; + module.BinaryStream.prototype.ReadUCharASCII = function (bsIterator) { + return this.m_stream[bsIterator.m_count++]; + }; + module.BinaryStream.prototype.ReadFloat32 = function (bsIterator, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.ReadFloat32ASCII(bsIterator); + } + return this.ReadFloat32Bin(bsIterator); + }; + module.BinaryStream.prototype.ReadUInt32 = function (bsIterator, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.ReadUInt32ASCII(bsIterator); + } + return this.ReadUInt32Bin(bsIterator); + }; + module.BinaryStream.prototype.ReadUChar = function (bsIterator, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.ReadUCharASCII(bsIterator); + } + return this.ReadUChar8Bin(bsIterator); + }; + module.BinaryStream.prototype.GetBuffer = function (bsIterator, size) { + return new Uint8Array(this.m_buffer, bsIterator.m_count, size); + }; + + // Copyright (c) 2004 Amir Said (said@ieee.org) & William A. Pearlman (pearlw@ecse.rpi.edu) + // All rights reserved. + + local.O3DGC_AC_MIN_LENGTH = 0x01000000; // threshold for renormalization + local.O3DGC_AC_MAX_LENGTH = 0xFFFFFFFF; // maximum AC interval length + local.O3DGC_AC_BM_LENGTH_SHIFT = 13; // Maximum values for binary models length bits discarded before mult. + local.O3DGC_AC_BM_MAX_COUNT = (1 << local.O3DGC_AC_BM_LENGTH_SHIFT) >>> 0; // for adaptive models + local.O3DGC_AC_DM_LENGTH_SHIFT = 15; // Maximum values for general models length bits discarded before mult. + local.O3DGC_AC_DM_MAX_COUNT = (1 << local.O3DGC_AC_DM_LENGTH_SHIFT) >>> 0; // for adaptive models + // StaticBitModel class + module.StaticBitModel = function () { + this.m_bit0Prob = (1 << (local.O3DGC_AC_BM_LENGTH_SHIFT - 1)) >>> 0; // p0 = 0.5 + }; + module.StaticBitModel.prototype.SetProbability = function (p) { + this.m_bit0Prob = Math.floor(p * ((1 << local.O3DGC_AC_BM_LENGTH_SHIFT) >>> 0)); + }; + // AdaptiveBitModel class + module.AdaptiveBitModel = function () { + // initialization to equiprobable model + this.m_updateCycle = 4; + this.m_bitsUntilUpdate = 4; + this.m_bit0Prob = (1 << (local.O3DGC_AC_BM_LENGTH_SHIFT - 1)) >>> 0; + this.m_bit0Count = 1; + this.m_bitCount = 2; + }; + module.AdaptiveBitModel.prototype.Reset = function () { + this.m_updateCycle = 4; + this.m_bitsUntilUpdate = 4; + this.m_bit0Prob = (1 << (local.O3DGC_AC_BM_LENGTH_SHIFT - 1)) >>> 0; + this.m_bit0Count = 1; + this.m_bitCount = 2; + }; + module.AdaptiveBitModel.prototype.Update = function () { + // halve counts when a threshold is reached + if ((this.m_bitCount += this.m_updateCycle) > local.O3DGC_AC_BM_MAX_COUNT) { + this.m_bitCount = (this.m_bitCount + 1) >>> 1; + this.m_bit0Count = (this.m_bit0Count + 1) >>> 1; + if (this.m_bit0Count === this.m_bitCount) { + ++this.m_bitCount; + } + } + // compute scaled bit 0 probability + var scale = Math.floor(0x80000000 / this.m_bitCount); + this.m_bit0Prob = (this.m_bit0Count * scale) >>> (31 - local.O3DGC_AC_BM_LENGTH_SHIFT); + // set frequency of model updates + this.m_updateCycle = (5 * this.m_updateCycle) >>> 2; + if (this.m_updateCycle > 64) { + this.m_updateCycle = 64; + } + this.m_bitsUntilUpdate = this.m_updateCycle; + }; + // AdaptiveDataModel class + module.AdaptiveDataModel = function () { + this.m_buffer = {}; + this.m_distribution = {}; + this.m_symbolCount = {}; + this.m_decoderTable = {}; + this.m_totalCount = 0; + this.m_updateCycle = 0; + this.m_symbolsUntilUpdate = 0; + this.m_dataSymbols = 0; + this.m_lastSymbol = 0; + this.m_tableSize = 0; + this.m_tableShift = 0; + }; + module.AdaptiveDataModel.prototype.Update = function () { + var n, sum, s, scale, k, max_cycle, w; + // halve counts when a threshold is reached + if ((this.m_totalCount += this.m_updateCycle) > local.O3DGC_AC_DM_MAX_COUNT) { + this.m_totalCount = 0; + for (n = 0; n < this.m_dataSymbols; ++n) { + this.m_totalCount += (this.m_symbolCount[n] = (this.m_symbolCount[n] + 1) >>> 1); + } + } + // compute cumulative distribution, decoder table + sum = 0; + s = 0; + scale = Math.floor(0x80000000 / this.m_totalCount); + if (this.m_tableSize === 0) { + for (k = 0; k < this.m_dataSymbols; ++k) { + this.m_distribution[k] = (scale * sum) >>> (31 - local.O3DGC_AC_DM_LENGTH_SHIFT); + sum += this.m_symbolCount[k]; + } + } else { + for (k = 0; k < this.m_dataSymbols; ++k) { + this.m_distribution[k] = (scale * sum) >>> (31 - local.O3DGC_AC_DM_LENGTH_SHIFT); + sum += this.m_symbolCount[k]; + w = this.m_distribution[k] >>> this.m_tableShift; + while (s < w) { + this.m_decoderTable[++s] = k - 1; + } + } + this.m_decoderTable[0] = 0; + while (s <= this.m_tableSize) { + this.m_decoderTable[++s] = this.m_dataSymbols - 1; + } + } + // set frequency of model updates + this.m_updateCycle = (5 * this.m_updateCycle) >>> 2; + max_cycle = ((this.m_dataSymbols + 6) << 3) >>> 0; + if (this.m_updateCycle > max_cycle) { + this.m_updateCycle = max_cycle; + } + this.m_symbolsUntilUpdate = this.m_updateCycle; + }; + module.AdaptiveDataModel.prototype.Reset = function () { + var k; + if (this.m_dataSymbols === 0) { + return; + } + // restore probability estimates to uniform distribution + this.m_totalCount = 0; + this.m_updateCycle = this.m_dataSymbols; + for (k = 0; k < this.m_dataSymbols; ++k) { + this.m_symbolCount[k] = 1; + } + this.Update(); + this.m_symbolsUntilUpdate = this.m_updateCycle = (this.m_dataSymbols + 6) >>> 1; + }; + module.AdaptiveDataModel.prototype.SetAlphabet = function (number_of_symbols) { + if ((number_of_symbols < 2) || (number_of_symbols > (1 << 11))) { + Console.log("invalid number of data symbols"); + return module.O3DGC_ERROR_AC; + } + if (this.m_dataSymbols !== number_of_symbols) { // assign memory for data model + this.m_dataSymbols = number_of_symbols; + this.m_lastSymbol = this.m_dataSymbols - 1; + // define size of table for fast decoding + if (this.m_dataSymbols > 16) { + var table_bits = 3; + while (this.m_dataSymbols > ((1 << (table_bits + 2)) >>> 0)) { + ++table_bits; + } + this.m_tableSize = (1 << table_bits) >>> 0; + this.m_tableShift = local.O3DGC_AC_DM_LENGTH_SHIFT - table_bits; + this.m_buffer = new ArrayBuffer(4 * (2 * this.m_dataSymbols + this.m_tableSize + 2)); + this.m_distribution = new Uint32Array(this.m_buffer, 0, this.m_dataSymbols); + this.m_symbolCount = new Uint32Array(this.m_buffer, 4 * this.m_dataSymbols, this.m_dataSymbols); + this.m_decoderTable = new Uint32Array(this.m_buffer, 8 * this.m_dataSymbols, this.m_tableSize + 2); + } else {// small alphabet: no table needed + this.m_tableSize = this.m_tableShift = 0; + this.m_buffer = new ArrayBuffer(4 * 2 * this.m_dataSymbols); + this.m_distribution = new Uint32Array(this.m_buffer, 0, this.m_dataSymbols); + this.m_symbolCount = new Uint32Array(this.m_buffer, 4 * this.m_dataSymbols, this.m_dataSymbols); + this.m_decoderTable = {}; + } + } + this.Reset(); // initialize model + return module.O3DGC_OK; + }; + // ArithmeticDecoder class + module.ArithmeticDecoder = function () { + this.m_codeBuffer = {}; + this.m_acShift = 0; + this.m_base = 0; + this.m_value = 0; + this.m_length = 0; // arithmetic coding state + this.m_bufferSize = 0; + this.m_mode = 0; // mode: 0 = undef, 1 = encoder, 2 = decoder + }; + module.ArithmeticDecoder.prototype.SetBuffer = function (max_code_bytes, user_buffer) { + if (max_code_bytes === 0) { + Console.log("invalid codec buffer size"); + return module.O3DGC_ERROR_AC; + } + if (this.m_mode !== 0) { + Console.log("cannot set buffer while encoding or decoding"); + return module.O3DGC_ERROR_AC; + } + this.m_bufferSize = max_code_bytes; + this.m_codeBuffer = user_buffer; + }; + module.ArithmeticDecoder.prototype.StartDecoder = function () { + if (this.m_mode !== 0) { + Console.log("cannot start decoder"); + return module.O3DGC_ERROR_AC; + } + if (this.m_bufferSize === 0) { + Console.log("no code buffer set"); + return module.O3DGC_ERROR_AC; + } + // initialize decoder: interval, pointer, initial code value + this.m_mode = 2; + this.m_length = local.O3DGC_AC_MAX_LENGTH; + this.m_acShift = 3; + this.m_value = ((this.m_codeBuffer[0] << 24) | (this.m_codeBuffer[1] << 16) | (this.m_codeBuffer[2] << 8) | (this.m_codeBuffer[3])) >>> 0; + }; + module.ArithmeticDecoder.prototype.StopDecoder = function () { + if (this.m_mode !== 2) { + Console.log("invalid to stop decoder"); + return module.O3DGC_ERROR_AC; + } + this.m_mode = 0; + }; + module.ArithmeticDecoder.prototype.GetBit = function () { + this.m_length >>>= 1; // halve interval + var bit = (this.m_value >= this.m_length); // decode bit + if (bit) { + this.m_value -= this.m_length; // move base + } + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + return bit; + }; + module.ArithmeticDecoder.prototype.GetBits = function (bits) { + var s = Math.floor(this.m_value / (this.m_length >>>= bits)); // decode symbol, change length + this.m_value -= this.m_length * s; // update interval + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + return s; + }; + module.ArithmeticDecoder.prototype.DecodeStaticBitModel = function (M) { + var x, bit; + x = M.m_bit0Prob * (this.m_length >>> local.O3DGC_AC_BM_LENGTH_SHIFT); // product l x p0 + bit = (this.m_value >= x); // decision + // update & shift interval + if (!bit) { + this.m_length = x; + } else { + this.m_value -= x; // shifted interval base = 0 + this.m_length -= x; + } + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + return bit; // return data bit value + }; + module.ArithmeticDecoder.prototype.DecodeAdaptiveBitModel = function (M) { + var x, bit; + x = M.m_bit0Prob * (this.m_length >>> local.O3DGC_AC_BM_LENGTH_SHIFT); // product l x p0 + bit = (this.m_value >= x); // decision + // update interval + if (!bit) { + this.m_length = x; + ++M.m_bit0Count; + } else { + this.m_value -= x; + this.m_length -= x; + } + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + if (--M.m_bitsUntilUpdate === 0) { + M.Update(); // periodic model update + } + return bit; // return data bit value + }; + module.ArithmeticDecoder.prototype.DecodeAdaptiveDataModel = function (M) { + var n, s, x, y, t, dv, z, m; + y = this.m_length; + if (M.m_tableSize > 0) { // use table look-up for faster decoding + dv = Math.floor(this.m_value / (this.m_length >>>= local.O3DGC_AC_DM_LENGTH_SHIFT)); + t = dv >>> M.m_tableShift; + s = M.m_decoderTable[t]; // initial decision based on table look-up + n = M.m_decoderTable[t + 1] + 1; + while (n > s + 1) { // finish with bisection search + m = (s + n) >>> 1; + if (M.m_distribution[m] > dv) { + n = m; + } else { + s = m; + } + } + // compute products + x = M.m_distribution[s] * this.m_length; + if (s !== M.m_lastSymbol) { + y = M.m_distribution[s + 1] * this.m_length; + } + } else { // decode using only multiplications + x = s = 0; + this.m_length >>>= local.O3DGC_AC_DM_LENGTH_SHIFT; + m = (n = M.m_dataSymbols) >>> 1; + // decode via bisection search + do { + z = this.m_length * M.m_distribution[m]; + if (z > this.m_value) { + n = m; + y = z; // value is smaller + } else { + s = m; + x = z; // value is larger or equal + } + } while ((m = (s + n) >>> 1) !== s); + } + this.m_value -= x; // update interval + this.m_length = y - x; + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + ++M.m_symbolCount[s]; + if (--M.m_symbolsUntilUpdate === 0) { + M.Update(false); // periodic model update + } + return s; + }; + module.ArithmeticDecoder.prototype.ExpGolombDecode = function (k, bModel0, bModel1) { + var symbol, binary_symbol, l; + symbol = 0; + binary_symbol = 0; + do { + l = this.DecodeAdaptiveBitModel(bModel1); + if (l) { + symbol += (1 << k) >>> 0; + k++; + } + } while (l); + while (k--) { //next binary part + if (this.DecodeStaticBitModel(bModel0)) { + binary_symbol = (binary_symbol | (1 << k)) >>> 0; + } + } + return (symbol + binary_symbol); + }; + module.ArithmeticDecoder.prototype.RenormDecInterval = function () { + do { // read least-significant byte + this.m_value = ((this.m_value << 8) | this.m_codeBuffer[++this.m_acShift]) >>> 0; + this.m_length = (this.m_length << 8) >>> 0; + } while (this.m_length < local.O3DGC_AC_MIN_LENGTH); // length multiplied by 256 + }; + module.ArithmeticDecoder.prototype.DecodeIntACEGC = function (mModelValues, bModel0, bModel1, exp_k, M) { + var uiValue = this.DecodeAdaptiveDataModel(mModelValues); + if (uiValue === M) { + uiValue += this.ExpGolombDecode(exp_k, bModel0, bModel1); + } + return UIntToInt(uiValue); + }; + module.ArithmeticDecoder.prototype.DecodeUIntACEGC = function (mModelValues, bModel0, bModel1, exp_k, M) { + var uiValue = this.DecodeAdaptiveDataModel(mModelValues); + if (uiValue === M) { + uiValue += this.ExpGolombDecode(exp_k, bModel0, bModel1); + } + return uiValue; + }; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // FIFO class + module.FIFO = function () { + this.m_data = {}; + this.m_allocated = 0; + this.m_size = 0; + this.m_start = 0; + this.m_end = 0; + }; + module.FIFO.prototype.Clear = function () { + this.m_start = this.m_end = this.m_size = 0; + }; + module.FIFO.prototype.GetAllocatedSize = function () { + return this.m_allocated; + }; + module.FIFO.prototype.GetSize = function () { + return this.m_size; + }; + module.FIFO.prototype.Allocate = function (size) { + if (size > this.m_allocated) { + this.m_allocated = size; + this.m_data = new Int32Array(this.m_allocated); + } + this.Clear(); + return module.O3DGC_OK; + }; + module.FIFO.prototype.PopFirst = function () { + --this.m_size; + var current = this.m_start++; + if (this.m_start === this.m_allocated) { + this.m_end = 0; + } + return this.m_data[current]; + }; + module.FIFO.prototype.PushBack = function (value) { + --this.m_size; + this.m_data[this.m_end] = value; + ++this.m_size; + ++this.m_end; + if (this.m_end === this.m_allocated) { + this.m_end = 0; + } + }; + // IndexedFaceSet class + module.IndexedFaceSet = function () { + this.m_nCoordIndex = 0; + this.m_nCoord = 0; + this.m_nNormal = 0; + this.m_numFloatAttributes = 0; + this.m_numIntAttributes = 0; + this.m_creaseAngle = 30.0; + this.m_ccw = true; + this.m_solid = true; + this.m_convex = true; + this.m_isTriangularMesh = true; + this.m_coordMin = new Float32Array(3); + this.m_coordMax = new Float32Array(3); + this.m_normalMin = new Float32Array(3); + this.m_normalMax = new Float32Array(3); + this.m_nFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_nIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_dimFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_dimIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_typeFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_typeIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_minFloatAttributeBuffer = new ArrayBuffer(4 * local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + this.m_minFloatAttribute = new Float32Array(this.m_minFloatAttributeBuffer); + this.m_maxFloatAttributeBuffer = new ArrayBuffer(4 * local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + this.m_maxFloatAttribute = new Float32Array(this.m_maxFloatAttributeBuffer); + this.m_coordIndex = {}; + this.m_coord = {}; + this.m_normal = {}; + this.m_floatAttribute = []; + this.m_intAttribute = []; + }; + module.IndexedFaceSet.prototype.GetNCoordIndex = function () { + return this.m_nCoordIndex; + }; + module.IndexedFaceSet.prototype.GetNCoordIndex = function () { + return this.m_nCoordIndex; + }; + module.IndexedFaceSet.prototype.GetNCoord = function () { + return this.m_nCoord; + }; + module.IndexedFaceSet.prototype.GetNNormal = function () { + return this.m_nNormal; + }; + module.IndexedFaceSet.prototype.GetNFloatAttribute = function (a) { + return this.m_nFloatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetNIntAttribute = function (a) { + return this.m_nIntAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetNumFloatAttributes = function () { + return this.m_numFloatAttributes; + }; + module.IndexedFaceSet.prototype.GetNumIntAttributes = function () { + return this.m_numIntAttributes; + }; + module.IndexedFaceSet.prototype.GetCoordMinArray = function () { + return this.m_coordMin; + }; + module.IndexedFaceSet.prototype.GetCoordMaxArray = function () { + return this.m_coordMax; + }; + module.IndexedFaceSet.prototype.GetNormalMinArray = function () { + return this.m_normalMin; + }; + module.IndexedFaceSet.prototype.GetNormalMaxArray = function () { + return this.m_normalMax; + }; + module.IndexedFaceSet.prototype.GetFloatAttributeMinArray = function (a) { + return (new Float32Array(this.m_minFloatAttributeBuffer, a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES * 4, this.GetFloatAttributeDim(a))); + }; + module.IndexedFaceSet.prototype.GetFloatAttributeMaxArray = function (a) { + return (new Float32Array(this.m_maxFloatAttributeBuffer, a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES * 4, this.GetFloatAttributeDim(a))); + }; + module.IndexedFaceSet.prototype.GetFloatAttributeDim = function (a) { + return this.m_dimFloatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetIntAttributeDim = function (a) { + return this.m_dimIntAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetFloatAttributeType = function (a) { + return this.m_typeFloatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetIntAttributeType = function (a) { + return this.m_typeIntAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetFloatAttributeMax = function (a, dim) { + return this.m_maxFloatAttribute[a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim]; + }; + module.IndexedFaceSet.prototype.GetCreaseAngle = function () { + return this.m_creaseAngle; + }; + module.IndexedFaceSet.prototype.GetCreaseAngle = function () { + return this.m_creaseAngle; + }; + module.IndexedFaceSet.prototype.GetCCW = function () { + return this.m_ccw; + }; + module.IndexedFaceSet.prototype.GetSolid = function () { + return this.m_solid; + }; + module.IndexedFaceSet.prototype.GetConvex = function () { + return this.m_convex; + }; + module.IndexedFaceSet.prototype.GetIsTriangularMesh = function () { + return this.m_isTriangularMesh; + }; + module.IndexedFaceSet.prototype.GetCoordIndex = function () { + return this.m_coordIndex; + }; + module.IndexedFaceSet.prototype.GetCoordIndex = function () { + return this.m_coordIndex; + }; + module.IndexedFaceSet.prototype.GetCoord = function () { + return this.m_coord; + }; + module.IndexedFaceSet.prototype.GetNormal = function () { + return this.m_normal; + }; + module.IndexedFaceSet.prototype.GetFloatAttribute = function (a) { + return this.m_floatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetIntAttribute = function (a) { + return this.m_intAttribute[a]; + }; + module.IndexedFaceSet.prototype.SetNCoordIndex = function (nCoordIndex) { + this.m_nCoordIndex = nCoordIndex; + }; + module.IndexedFaceSet.prototype.SetNNormalIndex = function (nNormalIndex) { + }; + module.IndexedFaceSet.prototype.SetNormalPerVertex = function (perVertex) { + }; + module.IndexedFaceSet.prototype.SetNFloatAttributeIndex = function (nFloatAttributeIndex) { + }; + module.IndexedFaceSet.prototype.SetNIntAttributeIndex = function (nIntAttributeIndex) { + }; + module.IndexedFaceSet.prototype.SetFloatAttributePerVertex = function (perVertex) { + }; + module.IndexedFaceSet.prototype.SetIntAttributePerVertex = function (perVertex) { + }; + module.IndexedFaceSet.prototype.SetNCoord = function (nCoord) { + this.m_nCoord = nCoord; + }; + module.IndexedFaceSet.prototype.SetNNormal = function (nNormal) { + this.m_nNormal = nNormal; + }; + module.IndexedFaceSet.prototype.SetNumFloatAttributes = function (numFloatAttributes) { + this.m_numFloatAttributes = numFloatAttributes; + }; + module.IndexedFaceSet.prototype.SetNumIntAttributes = function (numIntAttributes) { + this.m_numIntAttributes = numIntAttributes; + }; + module.IndexedFaceSet.prototype.SetCreaseAngle = function (creaseAngle) { + this.m_creaseAngle = creaseAngle; + }; + module.IndexedFaceSet.prototype.SetCCW = function (ccw) { + this.m_ccw = ccw; + }; + module.IndexedFaceSet.prototype.SetSolid = function (solid) { + this.m_solid = solid; + }; + module.IndexedFaceSet.prototype.SetConvex = function (convex) { + this.m_convex = convex; + }; + module.IndexedFaceSet.prototype.SetIsTriangularMesh = function (isTriangularMesh) { + this.m_isTriangularMesh = isTriangularMesh; + }; + module.IndexedFaceSet.prototype.SetCoordMin = function (j, min) { + this.m_coordMin[j] = min; + }; + module.IndexedFaceSet.prototype.SetCoordMax = function (j, max) { + this.m_coordMax[j] = max; + }; + module.IndexedFaceSet.prototype.SetNormalMin = function (j, min) { + this.m_normalMin[j] = min; + }; + module.IndexedFaceSet.prototype.SetNormalMax = function (j, max) { + this.m_normalMax[j] = max; + }; + module.IndexedFaceSet.prototype.SetNFloatAttribute = function (a, nFloatAttribute) { + this.m_nFloatAttribute[a] = nFloatAttribute; + }; + module.IndexedFaceSet.prototype.SetNIntAttribute = function (a, nIntAttribute) { + this.m_nIntAttribute[a] = nIntAttribute; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeDim = function (a, d) { + this.m_dimFloatAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetIntAttributeDim = function (a, d) { + this.m_dimIntAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeType = function (a, d) { + this.m_typeFloatAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetIntAttributeType = function (a, d) { + this.m_typeIntAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeMin = function (a, dim, min) { + this.m_minFloatAttribute[a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim] = min; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeMax = function (a, dim, max) { + this.m_maxFloatAttribute[a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim] = max; + }; + module.IndexedFaceSet.prototype.SetCoordIndex = function (coordIndex) { + this.m_coordIndex = coordIndex; + }; + module.IndexedFaceSet.prototype.SetCoord = function (coord) { + this.m_coord = coord; + }; + module.IndexedFaceSet.prototype.SetNormal = function (normal) { + this.m_normal = normal; + }; + module.IndexedFaceSet.prototype.SetFloatAttribute = function (a, floatAttribute) { + this.m_floatAttribute[a] = floatAttribute; + }; + module.IndexedFaceSet.prototype.SetIntAttribute = function (a, intAttribute) { + this.m_intAttribute[a] = intAttribute; + }; + + // SC3DMCEncodeParams class + module.SC3DMCEncodeParams = function () { + var a; + this.m_numFloatAttributes = 0; + this.m_numIntAttributes = 0; + this.m_floatAttributeQuantBits = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_floatAttributePredMode = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_intAttributePredMode = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_encodeMode = local.O3DGC_SC3DMC_ENCODE_MODE_TFAN; + this.m_streamTypeMode = local.O3DGC_STREAM_TYPE_ASCII; + this.m_coordQuantBits = 14; + this.m_normalQuantBits = 8; + this.m_coordPredMode = local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + this.m_normalPredMode = local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION; + for (a = 0; a < local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES; ++a) { + this.m_floatAttributePredMode[a] = local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + } + for (a = 0; a < local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES; ++a) { + this.m_intAttributePredMode[a] = local.O3DGC_SC3DMC_DIFFERENTIAL_PREDICTION; + } + }; + module.SC3DMCEncodeParams.prototype.GetStreamType = function () { + return this.m_streamTypeMode; + }; + module.SC3DMCEncodeParams.prototype.GetEncodeMode = function () { + return this.m_encodeMode; + }; + module.SC3DMCEncodeParams.prototype.GetNumFloatAttributes = function () { + return this.m_numFloatAttributes; + }; + module.SC3DMCEncodeParams.prototype.GetNumIntAttributes = function () { + return this.m_numIntAttributes; + }; + module.SC3DMCEncodeParams.prototype.GetCoordQuantBits = function () { + return this.m_coordQuantBits; + }; + module.SC3DMCEncodeParams.prototype.GetNormalQuantBits = function () { + return this.m_normalQuantBits; + }; + module.SC3DMCEncodeParams.prototype.GetFloatAttributeQuantBits = function (a) { + return this.m_floatAttributeQuantBits[a]; + }; + module.SC3DMCEncodeParams.prototype.GetCoordPredMode = function () { + return this.m_coordPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetNormalPredMode = function () { + return this.m_normalPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetFloatAttributePredMode = function (a) { + return this.m_floatAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.GetIntAttributePredMode = function (a) { + return this.m_intAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.GetCoordPredMode = function () { + return this.m_coordPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetNormalPredMode = function () { + return this.m_normalPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetFloatAttributePredMode = function (a) { + return this.m_floatAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.GetIntAttributePredMode = function (a) { + return this.m_intAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.SetStreamType = function (streamTypeMode) { + this.m_streamTypeMode = streamTypeMode; + }; + module.SC3DMCEncodeParams.prototype.SetEncodeMode = function (encodeMode) { + this.m_encodeMode = encodeMode; + }; + module.SC3DMCEncodeParams.prototype.SetNumFloatAttributes = function (numFloatAttributes) { + this.m_numFloatAttributes = numFloatAttributes; + }; + module.SC3DMCEncodeParams.prototype.SetNumIntAttributes = function (numIntAttributes) { + this.m_numIntAttributes = numIntAttributes; + }; + module.SC3DMCEncodeParams.prototype.SetCoordQuantBits = function (coordQuantBits) { + this.m_coordQuantBits = coordQuantBits; + }; + module.SC3DMCEncodeParams.prototype.SetNormalQuantBits = function (normalQuantBits) { + this.m_normalQuantBits = normalQuantBits; + }; + module.SC3DMCEncodeParams.prototype.SetFloatAttributeQuantBits = function (a, q) { + this.m_floatAttributeQuantBits[a] = q; + }; + module.SC3DMCEncodeParams.prototype.SetCoordPredMode = function (coordPredMode) { + this.m_coordPredMode = coordPredMode; + }; + module.SC3DMCEncodeParams.prototype.SetNormalPredMode = function (normalPredMode) { + this.m_normalPredMode = normalPredMode; + }; + module.SC3DMCEncodeParams.prototype.SetFloatAttributePredMode = function (a, p) { + this.m_floatAttributePredMode[a] = p; + }; + module.SC3DMCEncodeParams.prototype.SetIntAttributePredMode = function (a, p) { + this.m_intAttributePredMode[a] = p; + }; + // AdjacencyInfo class + module.AdjacencyInfo = function () { + this.m_neighborsSize = 0; // actual allocated size for m_neighbors + this.m_numNeighborsSize = 0; // actual allocated size for m_numNeighbors + this.m_numElements = 0; // number of elements + this.m_neighbors = {}; + this.m_numNeighbors = {}; + }; + module.AdjacencyInfo.prototype.Allocate = function (numNeighborsSize, neighborsSize) { + this.m_numElements = numNeighborsSize; + if (neighborsSize > this.m_neighborsSize) { + this.m_neighborsSize = neighborsSize; + this.m_neighbors = new Int32Array(this.m_neighborsSize); + } + if (numNeighborsSize > this.m_numNeighborsSize) { + this.m_numNeighborsSize = numNeighborsSize; + this.m_numNeighbors = new Int32Array(this.m_numNeighborsSize); + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.AllocateNumNeighborsArray = function (numElements) { + if (numElements > this.m_numNeighborsSize) { + this.m_numNeighborsSize = numElements; + this.m_numNeighbors = new Int32Array(this.m_numNeighborsSize); + } + this.m_numElements = numElements; + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.AllocateNeighborsArray = function () { + var i; + for (i = 1; i < this.m_numElements; ++i) { + this.m_numNeighbors[i] += this.m_numNeighbors[i - 1]; + } + if (this.m_numNeighbors[this.m_numElements - 1] > this.m_neighborsSize) { + this.m_neighborsSize = this.m_numNeighbors[this.m_numElements - 1]; + this.m_neighbors = new Int32Array(this.m_neighborsSize); + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.ClearNumNeighborsArray = function () { + var i; + for (i = 0; i < this.m_numElements; ++i) { + this.m_numNeighbors[i] = 0; + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.ClearNeighborsArray = function () { + var i; + for (i = 0; i < this.m_neighborsSize; ++i) { + this.m_neighbors[i] = -1; + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.Begin = function (element) { + return (element > 0) ? this.m_numNeighbors[element - 1] : 0; + }; + module.AdjacencyInfo.prototype.End = function (element) { + return this.m_numNeighbors[element]; + }; + module.AdjacencyInfo.prototype.AddNeighbor = function (element, neighbor) { + var p, p0, p1; + p0 = this.Begin(element); + p1 = this.End(element); + for (p = p0; p < p1; ++p) { + if (this.m_neighbors[p] === -1) { + this.m_neighbors[p] = neighbor; + return module.O3DGC_OK; + } + } + return module.O3DGC_ERROR_BUFFER_FULL; + }; + module.AdjacencyInfo.prototype.GetNeighbor = function (element) { + return this.m_neighbors[element]; + }; + module.AdjacencyInfo.prototype.GetNumNeighbors = function (element) { + return this.End(element) - this.Begin(element); + }; + module.AdjacencyInfo.prototype.GetNumNeighborsBuffer = function () { + return this.m_numNeighbors; + }; + module.AdjacencyInfo.prototype.GetNeighborsBuffer = function () { + return this.m_neighbors; + }; + // Vector class + module.Vector = function () { + this.m_data = {}; + this.m_allocated = 0; + this.m_size = 0; + }; + module.Vector.prototype.Clear = function () { + this.m_size = 0; + }; + module.Vector.prototype.Get = function (i) { + return this.m_data[i]; + }; + module.Vector.prototype.GetAllocatedSize = function () { + return this.m_allocated; + }; + module.Vector.prototype.GetSize = function () { + return this.m_size; + }; + module.Vector.prototype.GetBuffer = function () { + return this.m_data; + }; + module.Vector.prototype.SetSize = function (size) { + this.m_size = size; + }; + module.Vector.prototype.Allocate = function (size) { + var i, tmp_data; + if (size > this.m_allocated) { + this.m_allocated = size; + tmp_data = new Int32Array(this.m_allocated); + if (this.m_size > 0) { + for (i = 0; i < this.m_size; ++i) { + tmp_data[i] = this.m_data[i]; + } + } + this.m_data = tmp_data; + } + }; + module.Vector.prototype.PushBack = function (value) { + var i, tmp_data; + if (this.m_size === this.m_allocated) { + this.m_allocated *= 2; + if (this.m_allocated < local.O3DGC_DEFAULT_VECTOR_SIZE) { + this.m_allocated = local.O3DGC_DEFAULT_VECTOR_SIZE; + } + tmp_data = new Int32Array(this.m_allocated); + if (this.m_size > 0) { + for (i = 0; i < this.m_size; ++i) { + tmp_data[i] = this.m_data[i]; + } + } + this.m_data = tmp_data; + } + this.m_data[this.m_size++] = value; + }; + // CompressedTriangleFans class + module.CompressedTriangleFans = function () { + this.m_numTFANs = new module.Vector(); + this.m_degrees = new module.Vector(); + this.m_configs = new module.Vector(); + this.m_operations = new module.Vector(); + this.m_indices = new module.Vector(); + this.m_trianglesOrder = new module.Vector(); + this.m_streamType = local.O3DGC_STREAM_TYPE_UNKOWN; + }; + module.CompressedTriangleFans.prototype.GetStreamType = function () { + return this.m_streamType; + }; + module.CompressedTriangleFans.prototype.SetStreamType = function (streamType) { + this.m_streamType = streamType; + }; + module.CompressedTriangleFans.prototype.Clear = function () { + this.m_numTFANs.Clear(); + this.m_degrees.Clear(); + this.m_configs.Clear(); + this.m_operations.Clear(); + this.m_indices.Clear(); + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.Allocate = function (numVertices, numTriangles) { + this.m_numTFANs.Allocate(numVertices); + this.m_degrees.Allocate(2 * numVertices); + this.m_configs.Allocate(2 * numVertices); + this.m_operations.Allocate(2 * numVertices); + this.m_indices.Allocate(2 * numVertices); + this.m_trianglesOrder.Allocate(numTriangles); + this.Clear(); + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.PushNumTFans = function (numTFans) { + this.m_numTFANs.PushBack(numTFans); + }; + module.CompressedTriangleFans.prototype.ReadNumTFans = function (it) { + return this.m_numTFANs.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushDegree = function (degree) { + this.m_degrees.PushBack(degree); + }; + module.CompressedTriangleFans.prototype.ReadDegree = function (it) { + return this.m_degrees.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushConfig = function (config) { + this.m_configs.PushBack(config); + }; + module.CompressedTriangleFans.prototype.ReadConfig = function (it) { + return this.m_configs.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushOperation = function (op) { + this.m_operations.PushBack(op); + }; + module.CompressedTriangleFans.prototype.ReadOperation = function (it) { + return this.m_operations.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushIndex = function (index) { + this.m_indices.PushBack(index); + }; + module.CompressedTriangleFans.prototype.ReadIndex = function (it) { + return this.m_indices.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushTriangleIndex = function (index) { + this.m_trianglesOrder.PushBack(IntToUInt(index)); + }; + module.CompressedTriangleFans.prototype.ReadTriangleIndex = function (it) { + return UIntToInt(this.m_trianglesOrder.Get(it.m_count++)); + }; + module.CompressedTriangleFans.prototype.LoadUIntData = function (data, bstream, it) { + var size, i; + bstream.ReadUInt32ASCII(it); + size = bstream.ReadUInt32ASCII(it); + data.Allocate(size); + data.Clear(); + for (i = 0; i < size; ++i) { + data.PushBack(bstream.ReadUIntASCII(it)); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadIntData = function (data, bstream, it) { + var size, i; + bstream.ReadUInt32ASCII(it); + size = bstream.ReadUInt32ASCII(it); + data.Allocate(size); + data.Clear(); + for (i = 0; i < size; ++i) { + data.PushBack(bstream.ReadIntASCII(it)); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadBinData = function (data, bstream, it) { + var size, symbol, i, h; + bstream.ReadUInt32ASCII(it); + size = bstream.ReadUInt32ASCII(it); + data.Allocate(size * local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0); + data.Clear(); + i = 0; + while (i < size) { + symbol = bstream.ReadUCharASCII(it); + for (h = 0; h < local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0; ++h) { + data.PushBack(symbol & 1); + symbol >>>= 1; + ++i; + } + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadUIntAC = function (data, M, bstream, it) { + + var sizeSize, size, minValue, buffer, acd, mModelValues, i; + sizeSize = bstream.ReadUInt32Bin(it) - 12; + size = bstream.ReadUInt32Bin(it); + if (size === 0) { + return module.O3DGC_OK; + } + minValue = bstream.ReadUInt32Bin(it); + buffer = bstream.GetBuffer(it, sizeSize); + it.m_count += sizeSize; + data.Allocate(size); + acd = new module.ArithmeticDecoder(); + acd.SetBuffer(sizeSize, buffer); + acd.StartDecoder(); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 1); + for (i = 0; i < size; ++i) { + data.PushBack(acd.DecodeAdaptiveDataModel(mModelValues) + minValue); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadIntACEGC = function (data, M, bstream, it) { + var sizeSize, size, minValue, buffer, acd, mModelValues, bModel0, bModel1, value, i; + sizeSize = bstream.ReadUInt32Bin(it) - 12; + size = bstream.ReadUInt32Bin(it); + if (size === 0) { + return module.O3DGC_OK; + } + minValue = bstream.ReadUInt32Bin(it) - local.O3DGC_MAX_LONG; + buffer = bstream.GetBuffer(it, sizeSize); + it.m_count += sizeSize; + data.Allocate(size); + acd = new module.ArithmeticDecoder(); + acd.SetBuffer(sizeSize, buffer); + acd.StartDecoder(); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + for (i = 0; i < size; ++i) { + value = acd.DecodeAdaptiveDataModel(mModelValues); + if (value === M) { + value += acd.ExpGolombDecode(0, bModel0, bModel1); + } + data.PushBack(value + minValue); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadBinAC = function (data, bstream, it) { + var sizeSize, size, buffer, acd, bModel, i; + sizeSize = bstream.ReadUInt32Bin(it) - 8; + size = bstream.ReadUInt32Bin(it); + if (size === 0) { + return module.O3DGC_OK; + } + buffer = bstream.GetBuffer(it, sizeSize); + it.m_count += sizeSize; + data.Allocate(size); + acd = new module.ArithmeticDecoder(); + acd.SetBuffer(sizeSize, buffer); + acd.StartDecoder(); + bModel = new module.AdaptiveBitModel(); + for (i = 0; i < size; ++i) { + data.PushBack(acd.DecodeAdaptiveBitModel(bModel)); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.Load = function (bstream, iterator, decodeTrianglesOrder, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + this.LoadUIntData(this.m_numTFANs, bstream, iterator); + this.LoadUIntData(this.m_degrees, bstream, iterator); + this.LoadUIntData(this.m_configs, bstream, iterator); + this.LoadBinData(this.m_operations, bstream, iterator); + this.LoadIntData(this.m_indices, bstream, iterator); + if (decodeTrianglesOrder) { + this.LoadUIntData(this.m_trianglesOrder, bstream, iterator); + } + } else { + this.LoadIntACEGC(this.m_numTFANs, 4, bstream, iterator); + this.LoadIntACEGC(this.m_degrees, 16, bstream, iterator); + this.LoadUIntAC(this.m_configs, 10, bstream, iterator); + this.LoadBinAC(this.m_operations, bstream, iterator); + this.LoadIntACEGC(this.m_indices, 8, bstream, iterator); + if (decodeTrianglesOrder) { + this.LoadIntACEGC(this.m_trianglesOrder, 16, bstream, iterator); + } + } + return module.O3DGC_OK; + }; + // TriangleFans class + module.TriangleFans = function () { + this.m_verticesAllocatedSize = 0; + this.m_sizeTFANAllocatedSize = 0; + this.m_numTFANs = 0; + this.m_numVertices = 0; + this.m_sizeTFAN = {}; + this.m_vertices = {}; + }; + module.TriangleFans.prototype.Allocate = function (sizeTFAN, verticesSize) { + this.m_numTFANs = 0; + this.m_numVertices = 0; + if (this.m_verticesAllocatedSize < verticesSize) { + this.m_verticesAllocatedSize = verticesSize; + this.m_vertices = new Int32Array(this.m_verticesAllocatedSize); + } + if (this.m_sizeTFANAllocatedSize < sizeTFAN) { + this.m_sizeTFANAllocatedSize = sizeTFAN; + this.m_sizeTFAN = new Int32Array(this.m_sizeTFANAllocatedSize); + } + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.Clear = function () { + this.m_numTFANs = 0; + this.m_numVertices = 0; + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.AddVertex = function (vertex) { + var i, tmp_vertices; + ++this.m_numVertices; + if (this.m_numVertices > this.m_verticesAllocatedSize) { + this.m_verticesAllocatedSize *= 2; + tmp_vertices = new Int32Array(this.m_verticesAllocatedSize); + for (i = 0; i < this.m_numVertices; ++i) { + tmp_vertices[i] = this.m_vertices[i]; + } + this.m_vertices = tmp_vertices; + } + this.m_vertices[this.m_numVertices - 1] = vertex; + ++this.m_sizeTFAN[this.m_numTFANs - 1]; + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.AddTFAN = function () { + var i, tmp_sizeTFAN; + ++this.m_numTFANs; + if (this.m_numTFANs > this.m_sizeTFANAllocatedSize) { + this.m_sizeTFANAllocatedSize *= 2; + tmp_sizeTFAN = new Int32Array(this.m_sizeTFANAllocatedSize); + for (i = 0; i < this.m_numTFANs; ++i) { + tmp_sizeTFAN[i] = this.m_sizeTFAN[i]; + } + this.m_sizeTFAN = tmp_sizeTFAN; + } + this.m_sizeTFAN[this.m_numTFANs - 1] = (this.m_numTFANs > 1) ? this.m_sizeTFAN[this.m_numTFANs - 2] : 0; + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.Begin = function (tfan) { + return (tfan > 0) ? this.m_sizeTFAN[tfan - 1] : 0; + }; + module.TriangleFans.prototype.End = function (tfan) { + return this.m_sizeTFAN[tfan]; + }; + module.TriangleFans.prototype.GetVertex = function (vertex) { + return this.m_vertices[vertex]; + }; + module.TriangleFans.prototype.GetTFANSize = function (tfan) { + return this.End(tfan) - this.Begin(tfan); + }; + module.TriangleFans.prototype.GetNumTFANs = function () { + return this.m_numTFANs; + }; + module.TriangleFans.prototype.GetNumVertices = function () { + return this.m_numVertices; + }; + // TriangleListDecoder class + module.TriangleListDecoder = function () { + this.m_itNumTFans = new module.Iterator(); + this.m_itDegree = new module.Iterator(); + this.m_itConfig = new module.Iterator(); + this.m_itOperation = new module.Iterator(); + this.m_itIndex = new module.Iterator(); + this.m_maxNumVertices = 0; + this.m_maxNumTriangles = 0; + this.m_numTriangles = 0; + this.m_numVertices = 0; + this.m_tempTrianglesSize = 0; + this.m_vertexCount = 0; + this.m_triangleCount = 0; + this.m_numConqueredTriangles = 0; + this.m_numVisitedVertices = 0; + this.m_triangles = {}; + this.m_tempTriangles = {}; + this.m_visitedVertices = {}; + this.m_visitedVerticesValence = {}; + this.m_vertexToTriangle = new module.AdjacencyInfo(); + this.m_ctfans = new module.CompressedTriangleFans(); + this.m_tfans = new module.TriangleFans(); + this.m_streamType = local.O3DGC_STREAM_TYPE_ASCII; + this.m_decodeTrianglesOrder = false; + this.m_decodeVerticesOrder = false; + this.m_processConfig = { + 0: function (decoder, degree) { // ops: 1000001 vertices: -1 -2 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + for (u = 1; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + }, + 1: function (decoder, degree, focusVertex) { // ops: 1xxxxxx1 vertices: -1 x x x x x -2 + var u, op, index; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + for (u = 1; u < degree - 1; ++u) { + op = decoder.m_ctfans.ReadOperation(decoder.m_itOperation); + if (op === 1) { + index = decoder.m_ctfans.ReadIndex(decoder.m_itIndex); + if (index < 0) { + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[-index - 1]); + } else { + decoder.m_tfans.AddVertex(index + focusVertex); + } + } else { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + }, + 2: function (decoder, degree) { // ops: 00000001 vertices: -1 + var u; + for (u = 0; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + }, + 3: function (decoder, degree) { // ops: 00000001 vertices: -2 + var u; + for (u = 0; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + }, + 4: function (decoder, degree) {// ops: 10000000 vertices: -1 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + for (u = 1; u < degree; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + }, + 5: function (decoder, degree) { // ops: 10000000 vertices: -2 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + for (u = 1; u < degree; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + }, + 6: function (decoder, degree) { // ops: 00000000 vertices: + var u; + for (u = 0; u < degree; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + }, + 7: function (decoder, degree) { // ops: 1000001 vertices: -2 -1 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + for (u = 1; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + }, + 8: function (decoder, degree, focusVertex) { // ops: 1xxxxxx1 vertices: -2 x x x x x -1 + var u, op, index; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + for (u = 1; u < degree - 1; ++u) { + op = decoder.m_ctfans.ReadOperation(decoder.m_itOperation); + if (op === 1) { + index = decoder.m_ctfans.ReadIndex(decoder.m_itIndex); + if (index < 0) { + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[-index - 1]); + } else { + decoder.m_tfans.AddVertex(index + focusVertex); + } + } else { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + }, + 9: function (decoder, degree, focusVertex) { // general case + var u, op, index; + for (u = 0; u < degree; ++u) { + op = decoder.m_ctfans.ReadOperation(decoder.m_itOperation); + if (op === 1) { + index = decoder.m_ctfans.ReadIndex(decoder.m_itIndex); + if (index < 0) { + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[-index - 1]); + } else { + decoder.m_tfans.AddVertex(index + focusVertex); + } + } else { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + } + } + }; + }; + module.TriangleListDecoder.prototype.GetStreamType = function () { + return this.m_streamType; + }; + module.TriangleListDecoder.prototype.GetReorderTriangles = function () { + return this.m_decodeTrianglesOrder; + }; + module.TriangleListDecoder.prototype.GetReorderVertices = function () { + return this.m_decodeVerticesOrder; + }; + module.TriangleListDecoder.prototype.SetStreamType = function (streamType) { + this.m_streamType = streamType; + }; + module.TriangleListDecoder.prototype.GetVertexToTriangle = function () { + return this.m_vertexToTriangle; + }; + module.TriangleListDecoder.prototype.Reorder = function () { + var triangles, numTriangles, order, it, prevTriangleIndex, tempTriangles, t, i; + if (this.m_decodeTrianglesOrder) { + triangles = this.m_triangles; + numTriangles = this.m_numTriangles; + order = this.m_ctfans.m_trianglesOrder.m_data; + tempTriangles = this.m_tempTriangles; + tempTriangles.set(triangles); + it = 0; + prevTriangleIndex = 0; + for (i = 0; i < numTriangles; ++i) { + t = UIntToInt(order[it++]) + prevTriangleIndex; + triangles[3 * t] = tempTriangles[3 * i]; + triangles[3 * t + 1] = tempTriangles[3 * i + 1]; + triangles[3 * t + 2] = tempTriangles[3 * i + 2]; + prevTriangleIndex = t + 1; + } + } + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.CompueLocalConnectivityInfo = function (focusVertex) { + var visitedVertices, visitedVerticesValence, triangles, vertexToTriangle, beginV2T, endV2T, numConqueredTriangles, foundOrInserted, numVisitedVertices, tmp, i, j, k, h, x, y, t, p, v; + visitedVertices = this.m_visitedVertices; + visitedVerticesValence = this.m_visitedVerticesValence; + triangles = this.m_triangles; + vertexToTriangle = this.m_vertexToTriangle; + beginV2T = vertexToTriangle.Begin(focusVertex); + endV2T = vertexToTriangle.End(focusVertex); + numConqueredTriangles = 0; + numVisitedVertices = 0; + t = 0; + for (i = beginV2T; (t >= 0) && (i < endV2T); ++i) { + t = vertexToTriangle.GetNeighbor(i); + if (t >= 0) { + ++numConqueredTriangles; + p = 3 * t; + // extract visited vertices + for (k = 0; k < 3; ++k) { + v = triangles[p + k]; + if (v > focusVertex) { // vertices are insertices by increasing traversal order + foundOrInserted = false; + for (j = 0; j < numVisitedVertices; ++j) { + if (v === visitedVertices[j]) { + visitedVerticesValence[j]++; + foundOrInserted = true; + break; + } else if (v < visitedVertices[j]) { + ++numVisitedVertices; + for (h = numVisitedVertices - 1; h > j; --h) { + visitedVertices[h] = visitedVertices[h - 1]; + visitedVerticesValence[h] = visitedVerticesValence[h - 1]; + } + visitedVertices[j] = v; + visitedVerticesValence[j] = 1; + foundOrInserted = true; + break; + } + } + if (!foundOrInserted) { + visitedVertices[numVisitedVertices] = v; + visitedVerticesValence[numVisitedVertices] = 1; + numVisitedVertices++; + } + } + } + } + } + // re-order visited vertices by taking into account their valence (i.e., # of conquered triangles incident to each vertex) + // in order to avoid config. 9 + if (numVisitedVertices > 2) { + for (x = 1; x < numVisitedVertices; ++x) { + if (visitedVerticesValence[x] === 1) { + y = x; + while ((y > 0) && (visitedVerticesValence[y] < visitedVerticesValence[y - 1])) { + tmp = visitedVerticesValence[y]; + visitedVerticesValence[y] = visitedVerticesValence[y - 1]; + visitedVerticesValence[y - 1] = tmp; + tmp = visitedVertices[y]; + visitedVertices[y] = visitedVertices[y - 1]; + visitedVertices[y - 1] = tmp; + --y; + } + } + } + } + this.m_numConqueredTriangles = numConqueredTriangles; + this.m_numVisitedVertices = numVisitedVertices; + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.DecompressTFAN = function (focusVertex) { + var vertexToTriangle, triangles, itDegree, itConfig, tfans, ntfans, processConfig, ctfans, triangleCount, numConqueredTriangles, degree, config, k0, k1, b, c, t, f, k; + vertexToTriangle = this.m_vertexToTriangle; + triangles = this.m_triangles; + itDegree = this.m_itDegree; + itConfig = this.m_itConfig; + tfans = this.m_tfans; + processConfig = this.m_processConfig; + ctfans = this.m_ctfans; + triangleCount = this.m_triangleCount; + numConqueredTriangles = this.m_numConqueredTriangles; + ntfans = ctfans.ReadNumTFans(this.m_itNumTFans); + if (ntfans > 0) { + for (f = 0; f < ntfans; ++f) { + tfans.AddTFAN(); + degree = ctfans.ReadDegree(itDegree) + 2 - numConqueredTriangles; + config = ctfans.ReadConfig(itConfig); + k0 = tfans.GetNumVertices(); + tfans.AddVertex(focusVertex); + processConfig[config](this, degree, focusVertex); + k1 = tfans.GetNumVertices(); + b = tfans.GetVertex(k0 + 1); + for (k = k0 + 2; k < k1; ++k) { + c = tfans.GetVertex(k); + t = triangleCount * 3; + triangles[t++] = focusVertex; + triangles[t++] = b; + triangles[t] = c; + vertexToTriangle.AddNeighbor(focusVertex, triangleCount); + vertexToTriangle.AddNeighbor(b, triangleCount); + vertexToTriangle.AddNeighbor(c, triangleCount); + b = c; + triangleCount++; + } + } + } + this.m_triangleCount = triangleCount; + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.Decompress = function () { + var focusVertex; + for (focusVertex = 0; focusVertex < this.m_numVertices; ++focusVertex) { + if (focusVertex === this.m_vertexCount) { + this.m_vertexCount++; // insert focusVertex + } + this.CompueLocalConnectivityInfo(focusVertex); + this.DecompressTFAN(focusVertex); + } + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.Init = function (triangles, numTriangles, numVertices, maxSizeV2T) { + var i, numNeighbors; + this.m_numTriangles = numTriangles; + this.m_numVertices = numVertices; + this.m_triangles = triangles; + this.m_vertexCount = 0; + this.m_triangleCount = 0; + this.m_itNumTFans.m_count = 0; + this.m_itDegree.m_count = 0; + this.m_itConfig.m_count = 0; + this.m_itOperation.m_count = 0; + this.m_itIndex.m_count = 0; + if (this.m_numVertices > this.m_maxNumVertices) { + this.m_maxNumVertices = this.m_numVertices; + this.m_visitedVerticesValence = new Int32Array(this.m_numVertices); + this.m_visitedVertices = new Int32Array(this.m_numVertices); + } + if (this.m_decodeTrianglesOrder && this.m_tempTrianglesSize < this.m_numTriangles) { + this.m_tempTrianglesSize = this.m_numTriangles; + this.m_tempTriangles = new Int32Array(3 * this.m_tempTrianglesSize); + } + this.m_ctfans.SetStreamType(this.m_streamType); + this.m_ctfans.Allocate(this.m_numVertices, this.m_numTriangles); + this.m_tfans.Allocate(2 * this.m_numVertices, 8 * this.m_numVertices); + // compute vertex-to-triangle adjacency information + this.m_vertexToTriangle.AllocateNumNeighborsArray(numVertices); + numNeighbors = this.m_vertexToTriangle.GetNumNeighborsBuffer(); + for (i = 0; i < numVertices; ++i) { + numNeighbors[i] = maxSizeV2T; + } + this.m_vertexToTriangle.AllocateNeighborsArray(); + this.m_vertexToTriangle.ClearNeighborsArray(); + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.Decode = function (triangles, numTriangles, numVertices, bstream, it) { + var compressionMask, maxSizeV2T; + compressionMask = bstream.ReadUChar(it, this.m_streamType); + this.m_decodeTrianglesOrder = ((compressionMask & 2) !== 0); + this.m_decodeVerticesOrder = ((compressionMask & 1) !== 0); + if (this.m_decodeVerticesOrder) { // vertices reordering not supported + return module.O3DGC_ERROR_NON_SUPPORTED_FEATURE; + } + maxSizeV2T = bstream.ReadUInt32(it, this.m_streamType); + this.Init(triangles, numTriangles, numVertices, maxSizeV2T); + this.m_ctfans.Load(bstream, it, this.m_decodeTrianglesOrder, this.m_streamType); + this.Decompress(); + return module.O3DGC_OK; + }; + // SC3DMCDecoder class + module.SC3DMCDecoder = function () { + var i; + this.m_iterator = new module.Iterator(); + this.m_streamSize = 0; + this.m_params = new module.SC3DMCEncodeParams(); + this.m_triangleListDecoder = new module.TriangleListDecoder(); + this.m_quantFloatArray = {}; + this.m_orientation = {}; + this.m_normals = {}; + this.m_quantFloatArraySize = 0; + this.m_normalsSize = 0; + this.m_orientationSize = 0; + this.m_stats = new module.SC3DMCStats(); + this.m_streamType = local.O3DGC_STREAM_TYPE_UNKOWN; + this.m_neighbors = []; + this.m_idelta = new Float32Array(local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + this.m_minNormal = new Float32Array(2); + this.m_maxNormal = new Float32Array(2); + this.m_minNormal[0] = this.m_minNormal[1] = -2; + this.m_maxNormal[0] = this.m_maxNormal[1] = 2; + for (i = 0; i < local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES; ++i) { + this.m_neighbors[i] = new module.SC3DMCPredictor(); + } + }; + module.SC3DMCDecoder.prototype.GetStats = function () { + return this.m_stats; + }; + module.SC3DMCDecoder.prototype.DecodeHeader = function (ifs, bstream) { + var c0, start_code, mask, j, a, d; + c0 = this.m_iterator.m_count; + start_code = bstream.ReadUInt32(this.m_iterator, local.O3DGC_STREAM_TYPE_BINARY); + if (start_code !== local.O3DGC_SC3DMC_START_CODE) { + this.m_iterator.m_count = c0; + start_code = bstream.ReadUInt32(this.m_iterator, local.O3DGC_STREAM_TYPE_ASCII); + if (start_code !== local.O3DGC_SC3DMC_START_CODE) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + this.m_streamType = local.O3DGC_STREAM_TYPE_ASCII; + } else { + this.m_streamType = local.O3DGC_STREAM_TYPE_BINARY; + } + this.m_streamSize = bstream.ReadUInt32(this.m_iterator, this.m_streamType); + this.m_params.SetEncodeMode(bstream.ReadUChar(this.m_iterator, this.m_streamType)); + + ifs.SetCreaseAngle(bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + mask = bstream.ReadUChar(this.m_iterator, this.m_streamType); + ifs.SetCCW((mask & 1) === 1); + ifs.SetSolid((mask & 2) === 1); + ifs.SetConvex((mask & 4) === 1); + ifs.SetIsTriangularMesh((mask & 8) === 1); + + ifs.SetNCoord(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetNNormal(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetNumFloatAttributes(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetNumIntAttributes(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + + if (ifs.GetNCoord() > 0) { + ifs.SetNCoordIndex(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + for (j = 0; j < 3; ++j) { + ifs.SetCoordMin(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + ifs.SetCoordMax(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + } + this.m_params.SetCoordQuantBits(bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + if (ifs.GetNNormal() > 0) { + ifs.SetNNormalIndex(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + for (j = 0; j < 3; ++j) { + ifs.SetNormalMin(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + ifs.SetNormalMax(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + } + ifs.SetNormalPerVertex(bstream.ReadUChar(this.m_iterator, this.m_streamType) === 1); + this.m_params.SetNormalQuantBits(bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + for (a = 0; a < ifs.GetNumFloatAttributes(); ++a) { + ifs.SetNFloatAttribute(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + if (ifs.GetNFloatAttribute(a) > 0) { + ifs.SetNFloatAttributeIndex(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + d = bstream.ReadUChar(this.m_iterator, this.m_streamType); + ifs.SetFloatAttributeDim(a, d); + for (j = 0; j < d; ++j) { + ifs.SetFloatAttributeMin(a, j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + ifs.SetFloatAttributeMax(a, j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + } + ifs.SetFloatAttributePerVertex(a, bstream.ReadUChar(this.m_iterator, this.m_streamType) === 1); + ifs.SetFloatAttributeType(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + this.m_params.SetFloatAttributeQuantBits(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + } + for (a = 0; a < ifs.GetNumIntAttributes(); ++a) { + ifs.SetNIntAttribute(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + if (ifs.GetNIntAttribute(a) > 0) { + ifs.SetNIntAttributeIndex(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetIntAttributeDim(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + ifs.SetIntAttributePerVertex(a, bstream.ReadUChar(this.m_iterator, this.m_streamType) === 1); + ifs.SetIntAttributeType(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + } + return module.O3DGC_OK; + }; + function DeltaPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride) { + var ws, k, p, w, i, id; + id = new module.SC3DMCTriplet(-1, -1, -1); + for (k = 0; k < 3; ++k) { + w = triangles[ta * 3 + k]; + if (w < v) { + id.m_a = -1; + id.m_b = -1; + id.m_c = w; + p = InsertPredictor(id, nPred, neighbors, dimFloatArray); + if (p !== -1) { + ws = w * stride; + for (i = 0; i < dimFloatArray; ++i) { + neighbors[p].m_pred[i] = quantFloatArray[ws + i]; + } + } + } + } + } + function ParallelogramPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride, v2T, v2TNeighbors) { + var ta3, tb3, as, bs, cs, a, b, c, x, i, k, u1_begin, u1_end, u1, tb, foundB, p, id; + ta3 = ta * 3; + id = new module.SC3DMCTriplet(-1, -1, -1); + if (triangles[ta3] === v) { + a = triangles[ta3 + 1]; + b = triangles[ta3 + 2]; + } else if (triangles[ta3 + 1] === v) { + a = triangles[ta3]; + b = triangles[ta3 + 2]; + } else { + a = triangles[ta3]; + b = triangles[ta3 + 1]; + } + if (a < v && b < v) { + u1_begin = v2T.Begin(a); + u1_end = v2T.End(a); + for (u1 = u1_begin; u1 < u1_end; ++u1) { + tb = v2TNeighbors[u1]; + if (tb < 0) { + break; + } + tb3 = tb * 3; + c = -1; + foundB = false; + for (k = 0; k < 3; ++k) { + x = triangles[tb3 + k]; + if (x === b) { + foundB = true; + } else if (x < v && x !== a) { + c = x; + } + } + if (c !== -1 && foundB) { + if (a < b) { + id.m_a = a; + id.m_b = b; + } else { + id.m_a = b; + id.m_b = a; + } + id.m_c = (-c - 1); + p = InsertPredictor(id, nPred, neighbors, dimFloatArray); + if (p !== -1) { + as = a * stride; + bs = b * stride; + cs = c * stride; + for (i = 0; i < dimFloatArray; ++i) { + neighbors[p].m_pred[i] = quantFloatArray[as + i] + quantFloatArray[bs + i] - quantFloatArray[cs + i]; + } + } + } + } + } + } + module.SC3DMCDecoder.prototype.DecodeIntArrayBinary = function (intArray, + numIntArray, + dimIntArray, + stride, + ifs, + predMode, + bstream) { + var testPredEnabled, bestPred, i, u, ta, u_begin, u_end, buffer, iterator, streamType, predResidual, acd, bModel0, bModel1, mModelPreds, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, exp_k, M, id, mModelValues, neighbors, normals, nPred, v; + iterator = this.m_iterator; + streamType = this.m_streamType; + acd = new module.ArithmeticDecoder(); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + mModelPreds = new module.AdaptiveDataModel(); + mModelPreds.SetAlphabet(local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS + 1); + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numIntArray * dimIntArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); // bitsream size + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + exp_k = 0; + M = 0; + id = new module.SC3DMCTriplet(-1, -1, -1); + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_AC_EGC) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + buffer = bstream.GetBuffer(iterator, streamSize); + iterator.m_count += streamSize; + acd.SetBuffer(streamSize, buffer); + acd.StartDecoder(); + exp_k = acd.ExpGolombDecode(0, bModel0, bModel1); + M = acd.ExpGolombDecode(0, bModel0, bModel1); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + for (v = 0; v < numIntArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimIntArray, intArray, stride); + } + } + if (nPred.m_value > 1) { + bestPred = acd.DecodeAdaptiveDataModel(mModelPreds); + for (i = 0; i < dimIntArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + intArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION) { + for (i = 0; i < dimIntArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + intArray[v * stride + i] = predResidual + intArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimIntArray; ++i) { + predResidual = acd.DecodeUIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + intArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeIntArrayASCII = function (intArray, + numIntArray, + dimIntArray, + stride, + ifs, + predMode, + bstream) { + var testPredEnabled, iterator, streamType, predResidual, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, id, neighbors, normals, nPred, v, u_begin, u_end, u, ta, i, bestPred; + iterator = this.m_iterator; + streamType = this.m_streamType; + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numIntArray * dimIntArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); // bitsream size + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + id = new module.SC3DMCTriplet(-1, -1, -1); + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_ASCII) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + bstream.ReadUInt32(iteratorPred, streamType); // predictors bitsream size + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + for (v = 0; v < numIntArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimIntArray, intArray, stride); + } + } + if (nPred.m_value > 1) { + bestPred = bstream.ReadUCharASCII(iteratorPred); + for (i = 0; i < dimIntArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + intArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION) { + for (i = 0; i < dimIntArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + intArray[v * stride + i] = predResidual + intArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimIntArray; ++i) { + predResidual = bstream.ReadUIntASCII(iterator); + intArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeIntArray = function (intArray, + numIntArray, + dimIntArray, + stride, + ifs, + predMode, + bstream) { + if (this.m_streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.DecodeIntArrayASCII(intArray, numIntArray, dimIntArray, stride, ifs, predMode, bstream); + } + return this.DecodeIntArrayBinary(intArray, numIntArray, dimIntArray, stride, ifs, predMode, bstream); + }; + function ComputeNormals(triangles, ntris, coords, nvert, normals) { + var t3, v, n, t, a, b, c, d1, d2, n0; + n0 = new module.Vec3(); + d1 = new module.Vec3(); + d2 = new module.Vec3(); + n = nvert * 3; + for (v = 0; v < n; ++v) { + normals[v] = 0; + } + for (t = 0; t < ntris; ++t) { + t3 = t * 3; + a = triangles[t3] * 3; + b = triangles[t3 + 1] * 3; + c = triangles[t3 + 2] * 3; + d1.m_x = coords[b] - coords[a]; + d1.m_y = coords[b + 1] - coords[a + 1]; + d1.m_z = coords[b + 2] - coords[a + 2]; + d2.m_x = coords[c] - coords[a]; + d2.m_y = coords[c + 1] - coords[a + 1]; + d2.m_z = coords[c + 2] - coords[a + 2]; + n0.m_x = d1.m_y * d2.m_z - d1.m_z * d2.m_y; + n0.m_y = d1.m_z * d2.m_x - d1.m_x * d2.m_z; + n0.m_z = d1.m_x * d2.m_y - d1.m_y * d2.m_x; + normals[a] += n0.m_x; + normals[a + 1] += n0.m_y; + normals[a + 2] += n0.m_z; + normals[b] += n0.m_x; + normals[b + 1] += n0.m_y; + normals[b + 2] += n0.m_z; + normals[c] += n0.m_x; + normals[c + 1] += n0.m_y; + normals[c + 2] += n0.m_z; + } + } + module.SC3DMCDecoder.prototype.ProcessNormals = function (ifs) { + var v3, v2, nvert, normalSize, normals, quantFloatArray, orientation, triangles, n0, n1, v, rna0, rnb0, ni1, norm0; + nvert = ifs.GetNNormal(); + + normalSize = ifs.GetNNormal() * 3; + if (this.m_normalsSize < normalSize) { + this.m_normalsSize = normalSize; + this.m_normals = new Float32Array(this.m_normalsSize); + } + normals = this.m_normals; + quantFloatArray = this.m_quantFloatArray; + orientation = this.m_orientation; + triangles = ifs.GetCoordIndex(); + ComputeNormals(triangles, ifs.GetNCoordIndex(), quantFloatArray, nvert, normals); + n0 = new module.Vec3(); + n1 = new module.Vec3(); + for (v = 0; v < nvert; ++v) { + v3 = 3 * v; + n0.m_x = normals[v3]; + n0.m_y = normals[v3 + 1]; + n0.m_z = normals[v3 + 2]; + norm0 = Math.sqrt(n0.m_x * n0.m_x + n0.m_y * n0.m_y + n0.m_z * n0.m_z); + if (norm0 === 0.0) { + norm0 = 1.0; + } + SphereToCube(n0, n1); + rna0 = n1.m_x / norm0; + rnb0 = n1.m_y / norm0; + ni1 = n1.m_z + orientation[v]; + orientation[v] = ni1; + if ((ni1 >>> 1) !== (n1.m_z >>> 1)) { + rna0 = 0.0; + rnb0 = 0.0; + } + v2 = v * 2; + normals[v2] = rna0; + normals[v2 + 1] = rnb0; + } + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.IQuantize = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + predMode) { + var v, nin, nout, orientation, normals, CubeToSphere; + if (predMode.m_value === local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION) { + CubeToSphere = local.CubeToSphere; + orientation = this.m_orientation; + normals = this.m_normals; + nin = new module.Vec3(0, 0, 0); + nout = new module.Vec3(0, 0, 0); + this.IQuantizeFloatArray(floatArray, numFloatArray, dimFloatArray, stride, this.m_minNormal, this.m_maxNormal, nQBits + 1); + for (v = 0; v < numFloatArray; ++v) { + nin.m_x = floatArray[stride * v] + normals[2 * v]; + nin.m_y = floatArray[stride * v + 1] + normals[2 * v + 1]; + nin.m_z = orientation[v]; + CubeToSphere[nin.m_z](nin, nout); + floatArray[stride * v] = nout.m_x; + floatArray[stride * v + 1] = nout.m_y; + floatArray[stride * v + 2] = nout.m_z; + } + } else { + this.IQuantizeFloatArray(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits); + } + }; + module.SC3DMCDecoder.prototype.DecodeFloatArrayBinary = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + ifs, + predMode, + bstream) { + var maxNPred, testPredEnabled, testParaPredEnabled, bestPred, dModel, buffer, quantFloatArray, neighbors, normals, nPred, ta, i, v, u, u_begin, u_end, iterator, orientation, streamType, predResidual, acd, bModel0, bModel1, mModelPreds, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, exp_k, M, mModelValues; + iterator = this.m_iterator; + orientation = this.m_orientation; + streamType = this.m_streamType; + acd = new module.ArithmeticDecoder(); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + mModelPreds = new module.AdaptiveDataModel(); + maxNPred = local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS; + mModelPreds.SetAlphabet(maxNPred + 1); + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numFloatArray * dimFloatArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + exp_k = 0; + M = 0; + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_AC_EGC) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + buffer = bstream.GetBuffer(iterator, streamSize); + iterator.m_count += streamSize; + acd.SetBuffer(streamSize, buffer); + acd.StartDecoder(); + exp_k = acd.ExpGolombDecode(0, bModel0, bModel1); + M = acd.ExpGolombDecode(0, bModel0, bModel1); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + if (predMode.m_value === local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION) { + if (this.m_orientationSize < size) { + this.m_orientationSize = size; + this.m_orientation = new Int8Array(this.m_orientationSize); + orientation = this.m_orientation; + } + dModel = new module.AdaptiveDataModel(); + dModel.SetAlphabet(12); + for (i = 0; i < numFloatArray; ++i) { + orientation[i] = UIntToInt(acd.DecodeAdaptiveDataModel(dModel)); + } + this.ProcessNormals(ifs); + dimFloatArray = 2; + } + if (this.m_quantFloatArraySize < size) { + this.m_quantFloatArraySize = size; + this.m_quantFloatArray = new Int32Array(this.m_quantFloatArraySize); + } + quantFloatArray = this.m_quantFloatArray; + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + testParaPredEnabled = predMode.m_value === local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + for (v = 0; v < numFloatArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + if (testParaPredEnabled) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + ParallelogramPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride, v2T, v2TNeighbors); + } + } + if (nPred.m_value < maxNPred) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride); + } + } + } + if (nPred.m_value > 1) { + bestPred = acd.DecodeAdaptiveDataModel(mModelPreds); + for (i = 0; i < dimFloatArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + quantFloatArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && testPredEnabled) { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + quantFloatArray[v * stride + i] = predResidual + quantFloatArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = acd.DecodeUIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + quantFloatArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + this.IQuantize(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, predMode); + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeFloatArrayASCII = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + ifs, + predMode, + bstream) { + var maxNPred, testPredEnabled, testParaPredEnabled, iterator, orientation, streamType, predResidual, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, quantFloatArray, neighbors, normals, nPred, v, u, u_begin, u_end, ta, i, bestPred; + maxNPred = local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS; + iterator = this.m_iterator; + orientation = this.m_orientation; + streamType = this.m_streamType; + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numFloatArray * dimFloatArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_ASCII) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + bstream.ReadUInt32(iteratorPred, streamType); + if (predMode.m_value === local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION) { + if (this.m_orientationSize < numFloatArray) { + this.m_orientationSize = numFloatArray; + this.m_orientation = new Int8Array(this.m_orientationSize); + orientation = this.m_orientation; + } + for (i = 0; i < numFloatArray; ++i) { + orientation[i] = bstream.ReadIntASCII(iterator); + } + this.ProcessNormals(ifs); + dimFloatArray = 2; + } + if (this.m_quantFloatArraySize < size) { + this.m_quantFloatArraySize = size; + this.m_quantFloatArray = new Int32Array(this.m_quantFloatArraySize); + } + quantFloatArray = this.m_quantFloatArray; + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + testParaPredEnabled = predMode.m_value === local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + for (v = 0; v < numFloatArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + if (testParaPredEnabled) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + ParallelogramPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride, v2T, v2TNeighbors); + } + } + if (nPred.m_value < maxNPred) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride); + } + } + } + if (nPred.m_value > 1) { + bestPred = bstream.ReadUCharASCII(iteratorPred); + for (i = 0; i < dimFloatArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + quantFloatArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION) { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + quantFloatArray[v * stride + i] = predResidual + quantFloatArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = bstream.ReadUIntASCII(iterator); + quantFloatArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + this.IQuantize(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, predMode); + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeFloatArray = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + ifs, + predMode, + bstream) { + if (this.m_streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.DecodeFloatArrayASCII(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, ifs, predMode, bstream); + } + return this.DecodeFloatArrayBinary(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, ifs, predMode, bstream); + }; + module.SC3DMCDecoder.prototype.IQuantizeFloatArray = function (floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits) { + var idelta, quantFloatArray, d, r, v; + idelta = this.m_idelta; + quantFloatArray = this.m_quantFloatArray; + for (d = 0; d < dimFloatArray; ++d) { + r = maxFloatArray[d] - minFloatArray[d]; + if (r > 0.0) { + idelta[d] = r / (((1 << nQBits) >>> 0) - 1); + } else { + idelta[d] = 1.0; + } + } + for (v = 0; v < numFloatArray; ++v) { + for (d = 0; d < dimFloatArray; ++d) { + floatArray[v * stride + d] = quantFloatArray[v * stride + d] * idelta[d] + minFloatArray[d]; + } + } + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodePlayload = function (ifs, bstream) { + var params, iterator, stats, predMode, timer, ret, a; + params = this.m_params; + iterator = this.m_iterator; + stats = this.m_stats; + predMode = new module.NumberRef(); + timer = new module.Timer(); + ret = module.O3DGC_OK; + this.m_triangleListDecoder.SetStreamType(this.m_streamType); + stats.m_streamSizeCoordIndex = iterator.m_count; + timer.Tic(); + this.m_triangleListDecoder.Decode(ifs.GetCoordIndex(), ifs.GetNCoordIndex(), ifs.GetNCoord(), bstream, iterator); + timer.Toc(); + stats.m_timeCoordIndex = timer.GetElapsedTime(); + stats.m_streamSizeCoordIndex = iterator.m_count - stats.m_streamSizeCoordIndex; + // decode coord + stats.m_streamSizeCoord = iterator.m_count; + timer.Tic(); + if (ifs.GetNCoord() > 0) { + ret = this.DecodeFloatArray(ifs.GetCoord(), ifs.GetNCoord(), 3, 3, ifs.GetCoordMinArray(), ifs.GetCoordMaxArray(), params.GetCoordQuantBits(), ifs, predMode, bstream); + params.SetCoordPredMode(predMode.m_value); + } + if (ret !== module.O3DGC_OK) { + return ret; + } + timer.Toc(); + stats.m_timeCoord = timer.GetElapsedTime(); + stats.m_streamSizeCoord = iterator.m_count - stats.m_streamSizeCoord; + + // decode Normal + stats.m_streamSizeNormal = iterator.m_count; + timer.Tic(); + if (ifs.GetNNormal() > 0) { + ret = this.DecodeFloatArray(ifs.GetNormal(), ifs.GetNNormal(), 3, 3, ifs.GetNormalMinArray(), ifs.GetNormalMaxArray(), params.GetNormalQuantBits(), ifs, predMode, bstream); + params.SetNormalPredMode(predMode.m_value); + } + if (ret !== module.O3DGC_OK) { + return ret; + } + timer.Toc(); + stats.m_timeNormal = timer.GetElapsedTime(); + stats.m_streamSizeNormal = iterator.m_count - stats.m_streamSizeNormal; + + // decode FloatAttributes + for (a = 0; a < ifs.GetNumFloatAttributes(); ++a) { + stats.m_streamSizeFloatAttribute[a] = iterator.m_count; + timer.Tic(); + ret = this.DecodeFloatArray(ifs.GetFloatAttribute(a), ifs.GetNFloatAttribute(a), ifs.GetFloatAttributeDim(a), ifs.GetFloatAttributeDim(a), ifs.GetFloatAttributeMinArray(a), ifs.GetFloatAttributeMaxArray(a), params.GetFloatAttributeQuantBits(a), ifs, predMode, bstream); + params.SetFloatAttributePredMode(a, predMode.m_value); + timer.Toc(); + stats.m_timeFloatAttribute[a] = timer.GetElapsedTime(); + stats.m_streamSizeFloatAttribute[a] = iterator.m_count - stats.m_streamSizeFloatAttribute[a]; + } + if (ret !== module.O3DGC_OK) { + return ret; + } + // decode IntAttributes + for (a = 0; a < ifs.GetNumIntAttributes(); ++a) { + stats.m_streamSizeIntAttribute[a] = iterator.m_count; + timer.Tic(); + ret = this.DecodeIntArray(ifs.GetIntAttribute(a), ifs.GetNIntAttribute(a), ifs.GetIntAttributeDim(a), ifs.GetIntAttributeDim(a), ifs, predMode, bstream); + params.SetIntAttributePredMode(a, predMode.m_value); + timer.Toc(); + stats.m_timeIntAttribute[a] = timer.GetElapsedTime(); + stats.m_streamSizeIntAttribute[a] = iterator.m_count - stats.m_streamSizeIntAttribute[a]; + } + if (ret !== module.O3DGC_OK) { + return ret; + } + timer.Tic(); + this.m_triangleListDecoder.Reorder(); + timer.Toc(); + stats.m_timeReorder = timer.GetElapsedTime(); + return ret; + }; + // DVEncodeParams class + module.DVEncodeParams = function () { + this.m_encodeMode = local.O3DGC_DYNAMIC_VECTOR_ENCODE_MODE_LIFT; + this.m_streamTypeMode = local.O3DGC_STREAM_TYPE_ASCII; + this.m_quantBits = 10; + }; + module.DVEncodeParams.prototype.GetStreamType = function () { + return this.m_streamTypeMode; + }; + module.DVEncodeParams.prototype.GetEncodeMode = function () { + return this.m_encodeMode; + }; + module.DVEncodeParams.prototype.GetQuantBits = function () { + return this.m_quantBits; + }; + module.DVEncodeParams.prototype.SetStreamType = function (streamTypeMode) { + this.m_streamTypeMode = streamTypeMode; + }; + module.DVEncodeParams.prototype.SetEncodeMode = function (encodeMode) { + this.m_encodeMode = encodeMode; + }; + module.DVEncodeParams.prototype.SetQuantBits = function (quantBits) { + this.m_quantBits = quantBits; + }; + // DynamicVector class + module.DynamicVector = function () { + this.m_num = 0; + this.m_dim = 0; + this.m_stride = 0; + this.m_max = {}; + this.m_min = {}; + this.m_vectors = {}; + }; + module.DynamicVector.prototype.GetNVector = function () { + return this.m_num; + }; + module.DynamicVector.prototype.GetDimVector = function () { + return this.m_dim; + }; + module.DynamicVector.prototype.GetStride = function () { + return this.m_stride; + }; + module.DynamicVector.prototype.GetMinArray = function () { + return this.m_min; + }; + module.DynamicVector.prototype.GetMaxArray = function () { + return this.m_max; + }; + module.DynamicVector.prototype.GetVectors = function () { + return this.m_vectors; + }; + module.DynamicVector.prototype.GetMin = function (j) { + return this.m_min[j]; + }; + module.DynamicVector.prototype.GetMax = function (j) { + return this.m_max[j]; + }; + module.DynamicVector.prototype.SetNVector = function (num) { + this.m_num = num; + }; + module.DynamicVector.prototype.SetDimVector = function (dim) { + this.m_dim = dim; + }; + module.DynamicVector.prototype.SetStride = function (stride) { + this.m_stride = stride; + }; + module.DynamicVector.prototype.SetMinArray = function (min) { + this.m_min = min; + }; + module.DynamicVector.prototype.SetMaxArray = function (max) { + this.m_max = max; + }; + module.DynamicVector.prototype.SetMin = function (j, min) { + this.m_min[j] = min; + }; + module.DynamicVector.prototype.SetMax = function (j, max) { + this.m_max[j] = max; + }; + module.DynamicVector.prototype.SetVectors = function (vectors) { + this.m_vectors = vectors; + }; + // DynamicVectorDecoder class + module.DynamicVectorDecoder = function () { + this.m_streamSize = 0; + this.m_maxNumVectors = 0; + this.m_numVectors = 0; + this.m_dimVectors = 0; + this.m_quantVectors = {}; + this.m_iterator = new module.Iterator(); + this.m_streamType = local.O3DGC_STREAM_TYPE_UNKOWN; + this.m_params = new module.DVEncodeParams(); + }; + module.DynamicVectorDecoder.prototype.GetStreamType = function () { + return this.m_streamType; + }; + module.DynamicVectorDecoder.prototype.GetIterator = function () { + return this.m_iterator; + }; + module.DynamicVectorDecoder.prototype.SetStreamType = function (streamType) { + this.m_streamType = streamType; + }; + module.DynamicVectorDecoder.prototype.SetIterator = function (iterator) { + this.m_iterator = iterator; + }; + module.DynamicVectorDecoder.prototype.IUpdate = function (data, shift, size) { + var p, size1; + size1 = size - 1; + p = 2; + data[shift] -= data[shift + 1] >> 1; + while (p < size1) { + data[shift + p] -= (data[shift + p - 1] + data[shift + p + 1] + 2) >> 2; + p += 2; + } + if (p === size1) { + data[shift + p] -= data[shift + p - 1] >> 1; + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.IPredict = function (data, shift, size) { + var p, size1; + size1 = size - 1; + p = 1; + while (p < size1) { + data[shift + p] += (data[shift + p - 1] + data[shift + p + 1] + 1) >> 1; + p += 2; + } + if (p === size1) { + data[shift + p] += data[shift + p - 1]; + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.Merge = function (data, shift, size) { + var i, h, a, b, tmp; + h = (size >> 1) + (size & 1); + a = h - 1; + b = h; + while (a > 0) { + for (i = a; i < b; i += 2) { + tmp = data[shift + i]; + data[shift + i] = data[shift + i + 1]; + data[shift + i + 1] = tmp; + } + --a; + ++b; + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.ITransform = function (data, shift, size) { + var n, even, k, i; + n = size; + even = 0; + k = 0; + even += ((n & 1) << k++) >>> 0; + while (n > 1) { + n = (n >> 1) + ((n & 1) >>> 0); + even += ((n & 1) << k++) >>> 0; + } + for (i = k - 2; i >= 0; --i) { + n = ((n << 1) >>> 0) - (((even >>> i) & 1)) >>> 0; + this.Merge(data, shift, n); + this.IUpdate(data, shift, n); + this.IPredict(data, shift, n); + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.IQuantize = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits) { + var quantVectors, r, idelta, size, d, v; + quantVectors = this.m_quantVectors; + size = numFloatArray * dimFloatArray; + for (d = 0; d < dimFloatArray; ++d) { + r = maxFloatArray[d] - minFloatArray[d]; + if (r > 0.0) { + idelta = r / (((1 << nQBits) >>> 0) - 1); + } else { + idelta = 1.0; + } + for (v = 0; v < numFloatArray; ++v) { + floatArray[v * stride + d] = quantVectors[v + d * numFloatArray] * idelta + minFloatArray[d]; + } + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.DecodeHeader = function (dynamicVector, bstream) { + var iterator, c0, start_code, streamType; + iterator = this.m_iterator; + c0 = iterator.m_count; + start_code = bstream.ReadUInt32(iterator, local.O3DGC_STREAM_TYPE_BINARY); + if (start_code !== local.O3DGC_DV_START_CODE) { + iterator.m_count = c0; + start_code = bstream.ReadUInt32(iterator, local.O3DGC_STREAM_TYPE_ASCII); + if (start_code !== local.O3DGC_DV_START_CODE) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + this.m_streamType = local.O3DGC_STREAM_TYPE_ASCII; + } else { + this.m_streamType = local.O3DGC_STREAM_TYPE_BINARY; + } + streamType = this.m_streamType; + this.m_streamSize = bstream.ReadUInt32(iterator, streamType); + this.m_params.SetEncodeMode(bstream.ReadUChar(iterator, streamType)); + dynamicVector.SetNVector(bstream.ReadUInt32(iterator, streamType)); + if (dynamicVector.GetNVector() > 0) { + dynamicVector.SetDimVector(bstream.ReadUInt32(iterator, streamType)); + this.m_params.SetQuantBits(bstream.ReadUChar(iterator, streamType)); + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.DecodePlayload = function (dynamicVector, bstream) { + var size, iterator, streamType, ret, start, streamSize, dim, num, j, acd, bModel0, bModel1, exp_k, M, buffer, mModelValues, quantVectors, v, d; + iterator = this.m_iterator; + streamType = this.m_streamType; + ret = module.O3DGC_OK; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); + dim = dynamicVector.GetDimVector(); + num = dynamicVector.GetNVector(); + size = dim * num; + for (j = 0; j < dynamicVector.GetDimVector(); ++j) { + dynamicVector.SetMin(j, bstream.ReadFloat32(iterator, streamType)); + dynamicVector.SetMax(j, bstream.ReadFloat32(iterator, streamType)); + } + acd = new module.ArithmeticDecoder(); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + streamSize -= (iterator.m_count - start); + exp_k = 0; + M = 0; + if (streamType === local.O3DGC_STREAM_TYPE_BINARY) { + buffer = bstream.GetBuffer(iterator, streamSize); + iterator.m_count += streamSize; + acd.SetBuffer(streamSize, buffer); + acd.StartDecoder(); + exp_k = acd.ExpGolombDecode(0, bModel0, bModel1); + M = acd.ExpGolombDecode(0, bModel0, bModel1); + } + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + if (this.m_maxNumVectors < size) { + this.m_maxNumVectors = size; + this.m_quantVectors = new Int32Array(this.m_maxNumVectors); + } + quantVectors = this.m_quantVectors; + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + for (v = 0; v < num; ++v) { + for (d = 0; d < dim; ++d) { + quantVectors[d * num + v] = bstream.ReadIntASCII(iterator); + } + } + } else { + for (v = 0; v < num; ++v) { + for (d = 0; d < dim; ++d) { + quantVectors[d * num + v] = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + } + } + } + for (d = 0; d < dim; ++d) { + this.ITransform(quantVectors, d * num, num); + } + this.IQuantize(dynamicVector.GetVectors(), num, dim, + dynamicVector.GetStride(), dynamicVector.GetMinArray(), + dynamicVector.GetMaxArray(), this.m_params.GetQuantBits()); + return ret; + }; + + return module; +})(); + diff --git a/three/jsutil/libs/opentype.min.js b/three/jsutil/libs/opentype.min.js new file mode 100644 index 000000000..9b3d1358a --- /dev/null +++ b/three/jsutil/libs/opentype.min.js @@ -0,0 +1,118 @@ +/** + * Modules in this bundle + * @license + * + * opentype.js: + * license: MIT (http://opensource.org/licenses/MIT) + * author: Frederik De Bleser + * version: 0.6.5 + * + * tiny-inflate: + * license: MIT (http://opensource.org/licenses/MIT) + * author: Devon Govett + * maintainers: devongovett + * homepage: https://github.com/devongovett/tiny-inflate + * version: 1.0.2 + * + * This header is generated by licensify (https://github.com/twada/licensify) + */ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.opentype = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;os;++s)e[s]=0;for(s=0;30-n>s;++s)e[s+n]=s/n|0;for(i=r,s=0;30>s;++s)t[s]=i,i+=1<n;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;24>n;++n)e.trans[n]=256+n;for(n=0;144>n;++n)e.trans[24+n]=n;for(n=0;8>n;++n)e.trans[168+n]=280+n;for(n=0;112>n;++n)e.trans[176+n]=144+n;for(n=0;5>n;++n)t.table[n]=0;for(t.table[5]=32,n=0;32>n;++n)t.trans[n]=n}function tinf_build_tree(e,t,n,r){var s,i;for(s=0;16>s;++s)e.table[s]=0;for(s=0;r>s;++s)e.table[t[n+s]]++;for(e.table[0]=0,i=0,s=0;16>s;++s)offs[s]=i,i+=e.table[s];for(s=0;r>s;++s)t[n+s]&&(e.trans[offs[t[n+s]]++]=s)}function tinf_getbit(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=1&e.tag;return e.tag>>>=1,t}function tinf_read_bits(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function tinf_decode_symbol(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++s,n+=t.table[s],r-=t.table[s];while(r>=0);return e.tag=i,e.bitcount-=s,t.trans[n+r]}function tinf_decode_trees(e,t,n){var r,s,i,a,o,_;for(r=tinf_read_bits(e,5,257),s=tinf_read_bits(e,5,1),i=tinf_read_bits(e,4,4),a=0;19>a;++a)lengths[a]=0;for(a=0;i>a;++a){var f=tinf_read_bits(e,3,0);lengths[clcidx[a]]=f}for(tinf_build_tree(code_tree,lengths,0,19),o=0;r+s>o;){var d=tinf_decode_symbol(e,code_tree);switch(d){case 16:var b=lengths[o-1];for(_=tinf_read_bits(e,2,3);_;--_)lengths[o++]=b;break;case 17:for(_=tinf_read_bits(e,3,3);_;--_)lengths[o++]=0;break;case 18:for(_=tinf_read_bits(e,7,11);_;--_)lengths[o++]=0;break;default:lengths[o++]=d}}tinf_build_tree(t,lengths,0,r),tinf_build_tree(n,lengths,r,s)}function tinf_inflate_block_data(e,t,n){for(;;){var r=tinf_decode_symbol(e,t);if(256===r)return TINF_OK;if(256>r)e.dest[e.destLen++]=r;else{var s,i,a,o;for(r-=257,s=tinf_read_bits(e,length_bits[r],length_base[r]),i=tinf_decode_symbol(e,n),a=e.destLen-tinf_read_bits(e,dist_bits[i],dist_base[i]),o=a;a+s>o;++o)e.dest[e.destLen++]=e.dest[o]}}}function tinf_inflate_uncompressed_block(e){for(var t,n,r;e.bitcount>8;)e.sourceIndex--,e.bitcount-=8;if(t=e.source[e.sourceIndex+1],t=256*t+e.source[e.sourceIndex],n=e.source[e.sourceIndex+3],n=256*n+e.source[e.sourceIndex+2],t!==(65535&~n))return TINF_DATA_ERROR;for(e.sourceIndex+=4,r=t;r;--r)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,TINF_OK}function tinf_uncompress(e,t){var n,r,s,i=new Data(e,t);do{switch(n=tinf_getbit(i),r=tinf_read_bits(i,2,0)){case 0:s=tinf_inflate_uncompressed_block(i);break;case 1:s=tinf_inflate_block_data(i,sltree,sdtree);break;case 2:tinf_decode_trees(i,i.ltree,i.dtree),s=tinf_inflate_block_data(i,i.ltree,i.dtree);break;default:s=TINF_DATA_ERROR}if(s!==TINF_OK)throw new Error("Data error")}while(!n);return i.destLen0,"No English "+t+" specified.")}var n=[],i=this;t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),e(this.unitsPerEm>0,"No unitsPerEm specified.")},Font.prototype.toTables=function(){return sfnt.fontToTable(this)},Font.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Font.prototype.toArrayBuffer=function(){for(var e=this.toTables(),t=e.encode(),n=new ArrayBuffer(t.length),i=new Uint8Array(n),r=0;r=t;){var s=t+a>>>1,n=e[s].tag;if(n===r)return s;r>n?t=s+1:a=s-1}return-t-1}function binSearch(e,r){for(var t=0,a=e.length-1;a>=t;){var s=t+a>>>1,n=e[s];if(n===r)return s;r>n?t=s+1:a=s-1}return-t-1}var check=require("./check"),Layout={searchTag:searchTag,binSearch:binSearch,getScriptNames:function(){var e=this.getGsubTable();return e?e.scripts.map(function(e){return e.tag}):[]},getScriptTable:function(e,r){var t=this.getGsubTable(r);if(t){var a=t.scripts,s=searchTag(t.scripts,e);if(s>=0)return a[s].script;var n={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return a.splice(-1-s,0,n.script),n}},getLangSysTable:function(e,r,t){var a=this.getScriptTable(e,t);if(a){if("DFLT"===r)return a.defaultLangSys;var s=searchTag(a.langSysRecords,r);if(s>=0)return a.langSysRecords[s].langSys;if(t){var n={tag:r,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return a.langSysRecords.splice(-1-s,0,n),n.langSys}}},getFeatureTable:function(e,r,t,a){var s=this.getLangSysTable(e,r,a);if(s){for(var n,u=s.featureIndexes,i=this.font.tables.gsub.features,g=0;g=i[o-1].tag,"Features must be added in alphabetical order."),n={tag:t,feature:{params:0,lookupListIndexes:[]}},i.push(n),u.push(o),n.feature}}},getLookupTable:function(e,r,t,a,s){var n=this.getFeatureTable(e,r,t,s);if(n){for(var u,i=n.lookupListIndexes,g=this.font.tables.gsub.lookups,o=0;oa;a++)for(var s=t[a],n=s.start,u=s.end,i=n;u>=i;i++)r.push(i);return r}};module.exports=Layout; + +},{"./check":2}],9:[function(require,module,exports){ +"use strict";function loadFromFile(e,a){var r=require("fs");r.readFile(e,function(e,r){return e?a(e.message):void a(null,util.nodeBufferToArrayBuffer(r))})}function loadFromUrl(e,a){var r=new XMLHttpRequest;r.open("get",e,!0),r.responseType="arraybuffer",r.onload=function(){return 200!==r.status?a("Font could not be loaded: "+r.statusText):a(null,r.response)},r.send()}function parseOpenTypeTableEntries(e,a){for(var r=[],s=12,t=0;a>t;t+=1){var n=parse.getTag(e,s),o=parse.getULong(e,s+4),p=parse.getULong(e,s+8),l=parse.getULong(e,s+12);r.push({tag:n,checksum:o,offset:p,length:l,compression:!1}),s+=16}return r}function parseWOFFTableEntries(e,a){for(var r=[],s=44,t=0;a>t;t+=1){var n,o=parse.getTag(e,s),p=parse.getULong(e,s+4),l=parse.getULong(e,s+8),f=parse.getULong(e,s+12);n=f>l?"WOFF":!1,r.push({tag:o,offset:p,compression:n,compressedLength:l,originalLength:f}),s+=20}return r}function uncompressTable(e,a){if("WOFF"===a.compression){var r=new Uint8Array(e.buffer,a.offset+2,a.compressedLength-2),s=new Uint8Array(a.originalLength);if(inflate(r,s),s.byteLength!==a.originalLength)throw new Error("Decompression error: "+a.tag+" decompressed length doesn't match recorded length");var t=new DataView(s.buffer,0);return{data:t,offset:0}}return{data:e,offset:a.offset}}function parseBuffer(e){var a,r,s,t=new _font.Font({empty:!0}),n=new DataView(e,0),o=[],p=parse.getTag(n,0);if(p===String.fromCharCode(0,1,0,0))t.outlinesFormat="truetype",s=parse.getUShort(n,4),o=parseOpenTypeTableEntries(n,s);else if("OTTO"===p)t.outlinesFormat="cff",s=parse.getUShort(n,4),o=parseOpenTypeTableEntries(n,s);else{if("wOFF"!==p)throw new Error("Unsupported OpenType signature "+p);var l=parse.getTag(n,4);if(l===String.fromCharCode(0,1,0,0))t.outlinesFormat="truetype";else{if("OTTO"!==l)throw new Error("Unsupported OpenType flavor "+p);t.outlinesFormat="cff"}s=parse.getUShort(n,12),o=parseWOFFTableEntries(n,s)}for(var f,u,i,c,b,m,d,g,h,T,y=0;s>y;y+=1){var v,F=o[y];switch(F.tag){case"cmap":v=uncompressTable(n,F),t.tables.cmap=cmap.parse(v.data,v.offset),t.encoding=new encoding.CmapEncoding(t.tables.cmap);break;case"fvar":u=F;break;case"head":v=uncompressTable(n,F),t.tables.head=head.parse(v.data,v.offset),t.unitsPerEm=t.tables.head.unitsPerEm,a=t.tables.head.indexToLocFormat;break;case"hhea":v=uncompressTable(n,F),t.tables.hhea=hhea.parse(v.data,v.offset),t.ascender=t.tables.hhea.ascender,t.descender=t.tables.hhea.descender,t.numberOfHMetrics=t.tables.hhea.numberOfHMetrics;break;case"hmtx":m=F;break;case"ltag":v=uncompressTable(n,F),r=ltag.parse(v.data,v.offset);break;case"maxp":v=uncompressTable(n,F),t.tables.maxp=maxp.parse(v.data,v.offset),t.numGlyphs=t.tables.maxp.numGlyphs;break;case"name":h=F;break;case"OS/2":v=uncompressTable(n,F),t.tables.os2=os2.parse(v.data,v.offset);break;case"post":v=uncompressTable(n,F),t.tables.post=post.parse(v.data,v.offset),t.glyphNames=new encoding.GlyphNames(t.tables.post);break;case"glyf":i=F;break;case"loca":g=F;break;case"CFF ":f=F;break;case"kern":d=F;break;case"GPOS":c=F;break;case"GSUB":b=F;break;case"meta":T=F}}var q=uncompressTable(n,h);if(t.tables.name=_name.parse(q.data,q.offset,r),t.names=t.tables.name,i&&g){var k=0===a,w=uncompressTable(n,g),x=loca.parse(w.data,w.offset,t.numGlyphs,k),O=uncompressTable(n,i);t.glyphs=glyf.parse(O.data,O.offset,x,t)}else{if(!f)throw new Error("Font doesn't contain TrueType or CFF outlines.");var U=uncompressTable(n,f);cff.parse(U.data,U.offset,t)}var L=uncompressTable(n,m);if(hmtx.parse(L.data,L.offset,t.numberOfHMetrics,t.numGlyphs,t.glyphs),encoding.addGlyphNames(t),d){var E=uncompressTable(n,d);t.kerningPairs=kern.parse(E.data,E.offset)}else t.kerningPairs={};if(c){var S=uncompressTable(n,c);gpos.parse(S.data,S.offset,t)}if(b){var G=uncompressTable(n,b);t.tables.gsub=gsub.parse(G.data,G.offset)}if(u){var B=uncompressTable(n,u);t.tables.fvar=fvar.parse(B.data,B.offset,t.names)}if(T){var C=uncompressTable(n,T);t.tables.meta=meta.parse(C.data,C.offset),t.metas=t.tables.meta}return t}function load(e,a){var r="undefined"==typeof window,s=r?loadFromFile:loadFromUrl;s(e,function(e,r){if(e)return a(e);var s;try{s=parseBuffer(r)}catch(t){return a(t,null)}return a(null,s)})}function loadSync(e){var a=require("fs"),r=a.readFileSync(e);return parseBuffer(util.nodeBufferToArrayBuffer(r))}var inflate=require("tiny-inflate"),encoding=require("./encoding"),_font=require("./font"),glyph=require("./glyph"),parse=require("./parse"),path=require("./path"),util=require("./util"),cmap=require("./tables/cmap"),cff=require("./tables/cff"),fvar=require("./tables/fvar"),glyf=require("./tables/glyf"),gpos=require("./tables/gpos"),gsub=require("./tables/gsub"),head=require("./tables/head"),hhea=require("./tables/hhea"),hmtx=require("./tables/hmtx"),kern=require("./tables/kern"),ltag=require("./tables/ltag"),loca=require("./tables/loca"),maxp=require("./tables/maxp"),_name=require("./tables/name"),os2=require("./tables/os2"),post=require("./tables/post"),meta=require("./tables/meta");exports._parse=parse,exports.Font=_font.Font,exports.Glyph=glyph.Glyph,exports.Path=path.Path,exports.parse=parseBuffer,exports.load=load,exports.loadSync=loadSync; +},{"./encoding":4,"./font":5,"./glyph":6,"./parse":10,"./path":11,"./tables/cff":14,"./tables/cmap":15,"./tables/fvar":16,"./tables/glyf":17,"./tables/gpos":18,"./tables/gsub":19,"./tables/head":20,"./tables/hhea":21,"./tables/hmtx":22,"./tables/kern":23,"./tables/loca":24,"./tables/ltag":25,"./tables/maxp":26,"./tables/meta":27,"./tables/name":28,"./tables/os2":29,"./tables/post":30,"./util":33,"fs":undefined,"tiny-inflate":1}],10:[function(require,module,exports){ +"use strict";function getUShort(t,r){return t.getUint16(r,!1)}function Parser(t,r){this.data=t,this.offset=r,this.relativeOffset=0}var check=require("./check");exports.getByte=function(t,r){return t.getUint8(r)},exports.getCard8=exports.getByte,exports.getUShort=exports.getCard16=getUShort,exports.getShort=function(t,r){return t.getInt16(r,!1)},exports.getULong=function(t,r){return t.getUint32(r,!1)},exports.getFixed=function(t,r){var e=t.getInt16(r,!1),s=t.getUint16(r+2,!1);return e+s/65535},exports.getTag=function(t,r){for(var e="",s=r;r+4>s;s+=1)e+=String.fromCharCode(t.getInt8(s));return e},exports.getOffset=function(t,r,e){for(var s=0,a=0;e>a;a+=1)s<<=8,s+=t.getUint8(r+a);return s},exports.getBytes=function(t,r,e){for(var s=[],a=r;e>a;a+=1)s.push(t.getUint8(a));return s},exports.bytesToString=function(t){for(var r="",e=0;ea;a++)s+=String.fromCharCode(r.getUint8(e+a));return s},Parser.prototype.parseTag=function(){return this.parseString(4)},Parser.prototype.parseLongDateTime=function(){var t=exports.getULong(this.data,this.offset+this.relativeOffset+4);return t-=2082844800,this.relativeOffset+=8,t},Parser.prototype.parseVersion=function(){var t=getUShort(this.data,this.offset+this.relativeOffset),r=getUShort(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,t+r/4096/10},Parser.prototype.skip=function(t,r){void 0===r&&(r=1),this.relativeOffset+=typeOffsets[t]*r},Parser.prototype.parseOffset16List=Parser.prototype.parseUShortList=function(t){void 0===t&&(t=this.parseUShort());for(var r=new Array(t),e=this.data,s=this.offset+this.relativeOffset,a=0;t>a;a++)r[a]=e.getUint16(s),s+=2;return this.relativeOffset+=2*t,r},Parser.prototype.parseList=function(t,r){r||(r=t,t=this.parseUShort());for(var e=new Array(t),s=0;t>s;s++)e[s]=r.call(this);return e},Parser.prototype.parseRecordList=function(t,r){r||(r=t,t=this.parseUShort());for(var e=new Array(t),s=Object.keys(r),a=0;t>a;a++){for(var o={},i=0;i0?new Parser(this.data,this.offset+r).parseStruct(t):void 0},Parser.prototype.parseListOfLists=function(t){for(var r=this.parseOffset16List(),e=r.length,s=this.relativeOffset,a=new Array(e),o=0;e>o;o++){var i=r[o];if(0!==i)if(this.relativeOffset=i,t){for(var n=this.parseOffset16List(),f=new Array(n.length),p=0;pa;a++)s[a]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:s}}check.assert(!1,"0x"+t.toString(16)+": Coverage format must be 1 or 2.")},Parser.prototype.parseClassDef=function(){var t=this.offset+this.relativeOffset,r=this.parseUShort();return 1===r?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:2===r?{format:2,ranges:this.parseRecordList({start:Parser.uShort,end:Parser.uShort,classId:Parser.uShort})}:void check.assert(!1,"0x"+t.toString(16)+": ClassDef format must be 1 or 2.")},Parser.list=function(t,r){return function(){return this.parseList(t,r)}},Parser.recordList=function(t,r){return function(){return this.parseRecordList(t,r)}},Parser.pointer=function(t){return function(){return this.parsePointer(t)}},Parser.tag=Parser.prototype.parseTag,Parser.byte=Parser.prototype.parseByte,Parser.uShort=Parser.offset16=Parser.prototype.parseUShort,Parser.uShortList=Parser.prototype.parseUShortList,Parser.struct=Parser.prototype.parseStruct,Parser.coverage=Parser.prototype.parseCoverage,Parser.classDef=Parser.prototype.parseClassDef;var langSysTable={reserved:Parser.uShort,reqFeatureIndex:Parser.uShort,featureIndexes:Parser.uShortList};Parser.prototype.parseScriptList=function(){return this.parsePointer(Parser.recordList({tag:Parser.tag,script:Parser.pointer({defaultLangSys:Parser.pointer(langSysTable),langSysRecords:Parser.recordList({tag:Parser.tag,langSys:Parser.pointer(langSysTable)})})}))},Parser.prototype.parseFeatureList=function(){return this.parsePointer(Parser.recordList({tag:Parser.tag,feature:Parser.pointer({featureParams:Parser.offset16,lookupListIndexes:Parser.uShortList})}))},Parser.prototype.parseLookupList=function(t){return this.parsePointer(Parser.list(Parser.pointer(function(){var r=this.parseUShort();check.argument(r>=1&&8>=r,"GSUB lookup type "+r+" unknown.");var e=this.parseUShort(),s=16&e;return{lookupType:r,lookupFlag:e,subtables:this.parseList(Parser.pointer(t[r])),markFilteringSet:s?this.parseUShort():void 0}})))},exports.Parser=Parser; + +},{"./check":2}],11:[function(require,module,exports){ +"use strict";function Path(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}Path.prototype.moveTo=function(t,o){this.commands.push({type:"M",x:t,y:o})},Path.prototype.lineTo=function(t,o){this.commands.push({type:"L",x:t,y:o})},Path.prototype.curveTo=Path.prototype.bezierCurveTo=function(t,o,e,i,s,h){this.commands.push({type:"C",x1:t,y1:o,x2:e,y2:i,x:s,y:h})},Path.prototype.quadTo=Path.prototype.quadraticCurveTo=function(t,o,e,i){this.commands.push({type:"Q",x1:t,y1:o,x:e,y:i})},Path.prototype.close=Path.prototype.closePath=function(){this.commands.push({type:"Z"})},Path.prototype.extend=function(t){t.commands&&(t=t.commands),Array.prototype.push.apply(this.commands,t)},Path.prototype.draw=function(t){t.beginPath();for(var o=0;o=0&&e>0&&(t+=" "),t+=o(i)}return t}t=void 0!==t?t:2;for(var i="",s=0;sa;a++)if(t[a]!==e[a])return!1;return!0}function getSubstFormat(t,e,r){for(var a=t.subtables,s=0;si&&(i=-1-i,o.coverage.glyphs.splice(i,0,u),o.substitute.splice(i,0,0)),o.substitute[i]=e.by},Substitution.prototype.addAlternate=function(t,e,r,a){var s=this.getLookupTable(r,a,t,3,!0),o=getSubstFormat(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});check.assert(1===o.coverage.format,"Ligature: unable to modify coverage table format "+o.coverage.format);var u=e.sub,i=this.binSearch(o.coverage.glyphs,u);0>i&&(i=-1-i,o.coverage.glyphs.splice(i,0,u),o.alternateSets.splice(i,0,0)),o.alternateSets[i]=e.by},Substitution.prototype.addLigature=function(t,e,r,a){r=r||"DFLT",a=a||"DFLT";var s=this.getLookupTable(r,a,t,4,!0),o=s.subtables[0];o||(o={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=o),check.assert(1===o.coverage.format,"Ligature: unable to modify coverage table format "+o.coverage.format);var u=e.sub[0],i=e.sub.slice(1),n={ligGlyph:e.by,components:i},g=this.binSearch(o.coverage.glyphs,u);if(g>=0){for(var l=o.ligatureSets[g],c=0;cs;s++)o[s+1]={name:e+s,type:"TABLE",value:a(t[s],s)};return o}function recordList(e,t,a){var r=t.length,o=[];o[0]={name:e+"Count",type:"USHORT",value:r};for(var s=0;r>s;s++)o=o.concat(a(t[s],s));return o}function Coverage(e){1===e.format?Table.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(ushortList("glyph",e.glyphs))):check.assert(!1,"Can't create coverage table format 2 yet.")}function ScriptList(e){Table.call(this,"scriptListTable",recordList("scriptRecord",e,function(e,t){var a=e.script,r=a.defaultLangSys;return check.assert(!!r,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Table("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Table("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:r.reqFeatureIndex}].concat(ushortList("featureIndex",r.featureIndexes)))}].concat(recordList("langSys",a.langSysRecords,function(e,t){var a=e.langSys;return[{name:"langSysTag"+t,type:"TAG",value:e.tag},{name:"langSys"+t,type:"TABLE",value:new Table("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(ushortList("featureIndex",a.featureIndexes)))}]})))}]}))}function FeatureList(e){Table.call(this,"featureListTable",recordList("featureRecord",e,function(e,t){var a=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Table("featureTable",[{name:"featureParams",type:"USHORT",value:a.featureParams}].concat(ushortList("lookupListIndex",a.lookupListIndexes)))}]}))}function LookupList(e,t){Table.call(this,"lookupListTable",tableList("lookup",e,function(e){var a=t[e.lookupType];return check.assert(!!a,"Unable to write GSUB lookup type "+e.lookupType+" tables."),new Table("lookupTable",[{name:"lookupType",type:"USHORT",value:e.lookupType},{name:"lookupFlag",type:"USHORT",value:e.lookupFlag}].concat(tableList("subtable",e.subtables,a)))}))}var check=require("./check"),encode=require("./types").encode,sizeOf=require("./types").sizeOf;Table.prototype.encode=function(){return encode.TABLE(this)},Table.prototype.sizeOf=function(){return sizeOf.TABLE(this)},Coverage.prototype=Object.create(Table.prototype),Coverage.prototype.constructor=Coverage,ScriptList.prototype=Object.create(Table.prototype),ScriptList.prototype.constructor=ScriptList,FeatureList.prototype=Object.create(Table.prototype),FeatureList.prototype.constructor=FeatureList,LookupList.prototype=Object.create(Table.prototype),LookupList.prototype.constructor=LookupList,exports.Record=exports.Table=Table,exports.Coverage=Coverage,exports.ScriptList=ScriptList,exports.FeatureList=FeatureList,exports.LookupList=LookupList,exports.ushortList=ushortList,exports.tableList=tableList,exports.recordList=recordList; + +},{"./check":2,"./types":32}],14:[function(require,module,exports){ +"use strict";function equals(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var a=0;ar;r+=1)i.push(parse.getOffset(e,p,f)),p+=f;s=n+i[h]}else s=t+2;for(r=0;r>4,i=15&n;if(s===a)break;if(t+=r[s],i===a)break;t+=r[i]}return parseFloat(t)}function parseOperand(e,t){var a,r,n,s;if(28===t)return a=e.parseByte(),r=e.parseByte(),a<<8|r;if(29===t)return a=e.parseByte(),r=e.parseByte(),n=e.parseByte(),s=e.parseByte(),a<<24|r<<16|n<<8|s;if(30===t)return parseFloatOperand(e);if(t>=32&&246>=t)return t-139;if(t>=247&&250>=t)return a=e.parseByte(),256*(t-247)+a+108;if(t>=251&&254>=t)return a=e.parseByte(),256*-(t-251)-a-108;throw new Error("Invalid b0 "+t)}function entriesToObject(e){for(var t={},a=0;a=i?(12===i&&(i=1200+r.parseByte()),n.push([i,s]),s=[]):s.push(parseOperand(r,i))}return entriesToObject(n)}function getCFFString(e,t){return t=390>=t?encoding.cffStandardStrings[t]:e[t-391]}function interpretDict(e,t,a){for(var r={},n=0;nn;n+=1)s=o.parseSID(),h.push(getCFFString(r,s));else if(1===f)for(;h.length<=a;)for(s=o.parseSID(),i=o.parseCard8(),n=0;i>=n;n+=1)h.push(getCFFString(r,s)),s+=1;else{if(2!==f)throw new Error("Unknown charset format "+f);for(;h.length<=a;)for(s=o.parseSID(),i=o.parseCard16(),n=0;i>=n;n+=1)h.push(getCFFString(r,s)),s+=1}return h}function parseCFFEncoding(e,t,a){var r,n,s={},i=new parse.Parser(e,t),o=i.parseCard8();if(0===o){var h=i.parseCard8();for(r=0;h>r;r+=1)n=i.parseCard8(),s[n]=r}else{if(1!==o)throw new Error("Unknown encoding format "+o);var f=i.parseCard8();for(n=1,r=0;f>r;r+=1)for(var p=i.parseCard8(),u=i.parseCard8(),l=p;p+u>=l;l+=1)s[l]=n,n+=1}return new encoding.CffEncoding(s,a)}function parseCFFCharstring(e,t,a){function r(e,t){g&&p.closePath(),p.moveTo(e,t),g=!0}function n(){var t;t=u.length%2!==0,t&&!c&&(d=u.shift()+e.nominalWidthX),l+=u.length>>1,u.length=0,c=!0}function s(a){for(var y,b,C,T,F,I,D,x,k,S,E,O,R=0;R1&&!c&&(d=u.shift()+e.nominalWidthX,c=!0),m+=u.pop(),r(v,m);break;case 5:for(;u.length>0;)v+=u.shift(),m+=u.shift(),p.lineTo(v,m);break;case 6:for(;u.length>0&&(v+=u.shift(),p.lineTo(v,m),0!==u.length);)m+=u.shift(),p.lineTo(v,m);break;case 7:for(;u.length>0&&(m+=u.shift(),p.lineTo(v,m),0!==u.length);)v+=u.shift(),p.lineTo(v,m);break;case 8:for(;u.length>0;)i=v+u.shift(),o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),v=h+u.shift(),m=f+u.shift(),p.curveTo(i,o,h,f,v,m);break;case 10:F=u.pop()+e.subrsBias,I=e.subrs[F],I&&s(I);break;case 11:return;case 12:switch(M=a[R],R+=1,M){case 35:i=v+u.shift(),o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),D=h+u.shift(),x=f+u.shift(),k=D+u.shift(),S=x+u.shift(),E=k+u.shift(),O=S+u.shift(),v=E+u.shift(),m=O+u.shift(),u.shift(),p.curveTo(i,o,h,f,D,x),p.curveTo(k,S,E,O,v,m);break;case 34:i=v+u.shift(),o=m,h=i+u.shift(),f=o+u.shift(),D=h+u.shift(),x=f,k=D+u.shift(),S=f,E=k+u.shift(),O=m,v=E+u.shift(),p.curveTo(i,o,h,f,D,x),p.curveTo(k,S,E,O,v,m);break;case 36:i=v+u.shift(),o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),D=h+u.shift(),x=f,k=D+u.shift(),S=f,E=k+u.shift(),O=S+u.shift(),v=E+u.shift(),p.curveTo(i,o,h,f,D,x),p.curveTo(k,S,E,O,v,m);break;case 37:i=v+u.shift(),o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),D=h+u.shift(),x=f+u.shift(),k=D+u.shift(),S=x+u.shift(),E=k+u.shift(),O=S+u.shift(),Math.abs(E-v)>Math.abs(O-m)?v=E+u.shift():m=O+u.shift(),p.curveTo(i,o,h,f,D,x),p.curveTo(k,S,E,O,v,m);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+M),u.length=0}break;case 14:u.length>0&&!c&&(d=u.shift()+e.nominalWidthX,c=!0),g&&(p.closePath(),g=!1);break;case 18:n();break;case 19:case 20:n(),R+=l+7>>3;break;case 21:u.length>2&&!c&&(d=u.shift()+e.nominalWidthX,c=!0),m+=u.pop(),v+=u.pop(),r(v,m);break;case 22:u.length>1&&!c&&(d=u.shift()+e.nominalWidthX,c=!0),v+=u.pop(),r(v,m);break;case 23:n();break;case 24:for(;u.length>2;)i=v+u.shift(),o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),v=h+u.shift(),m=f+u.shift(),p.curveTo(i,o,h,f,v,m);v+=u.shift(),m+=u.shift(),p.lineTo(v,m);break;case 25:for(;u.length>6;)v+=u.shift(),m+=u.shift(),p.lineTo(v,m);i=v+u.shift(),o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),v=h+u.shift(),m=f+u.shift(),p.curveTo(i,o,h,f,v,m);break;case 26:for(u.length%2&&(v+=u.shift());u.length>0;)i=v,o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),v=h,m=f+u.shift(),p.curveTo(i,o,h,f,v,m);break;case 27:for(u.length%2&&(m+=u.shift());u.length>0;)i=v+u.shift(),o=m,h=i+u.shift(),f=o+u.shift(),v=h+u.shift(),m=f,p.curveTo(i,o,h,f,v,m);break;case 28:y=a[R],b=a[R+1],u.push((y<<24|b<<16)>>16),R+=2;break;case 29:F=u.pop()+e.gsubrsBias,I=e.gsubrs[F],I&&s(I);break;case 30:for(;u.length>0&&(i=v,o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),v=h+u.shift(),m=f+(1===u.length?u.shift():0),p.curveTo(i,o,h,f,v,m),0!==u.length);)i=v+u.shift(),o=m,h=i+u.shift(),f=o+u.shift(),m=f+u.shift(),v=h+(1===u.length?u.shift():0),p.curveTo(i,o,h,f,v,m);break;case 31:for(;u.length>0&&(i=v+u.shift(),o=m,h=i+u.shift(),f=o+u.shift(),m=f+u.shift(),v=h+(1===u.length?u.shift():0),p.curveTo(i,o,h,f,v,m),0!==u.length);)i=v,o=m+u.shift(),h=i+u.shift(),f=o+u.shift(),v=h+u.shift(),m=f+(1===u.length?u.shift():0),p.curveTo(i,o,h,f,v,m);break;default:32>M?console.log("Glyph "+t.index+": unknown operator "+M):247>M?u.push(M-139):251>M?(y=a[R],R+=1,u.push(256*(M-247)+y+108)):255>M?(y=a[R],R+=1,u.push(256*-(M-251)-y-108)):(y=a[R],b=a[R+1],C=a[R+2],T=a[R+3],R+=4,u.push((y<<24|b<<16|C<<8|T)/65536))}}}var i,o,h,f,p=new path.Path,u=[],l=0,c=!1,d=e.defaultWidthX,g=!1,v=0,m=0;return s(a),t.advanceWidth=d,p}function calcCFFSubroutineBias(e){var t;return t=e.length<1240?107:e.length<33900?1131:32768}function parseCFFTable(e,t,a){a.tables.cff={};var r=parseCFFHeader(e,t),n=parseCFFIndex(e,r.endOffset,parse.bytesToString),s=parseCFFIndex(e,n.endOffset),i=parseCFFIndex(e,s.endOffset,parse.bytesToString),o=parseCFFIndex(e,i.endOffset);a.gsubrs=o.objects,a.gsubrsBias=calcCFFSubroutineBias(a.gsubrs);var h=new DataView(new Uint8Array(s.objects[0]).buffer),f=parseCFFTopDict(h,i.objects);a.tables.cff.topDict=f;var p=t+f["private"][1],u=parseCFFPrivateDict(e,p,f["private"][0],i.objects);if(a.defaultWidthX=u.defaultWidthX,a.nominalWidthX=u.nominalWidthX,0!==u.subrs){var l=p+u.subrs,c=parseCFFIndex(e,l);a.subrs=c.objects,a.subrsBias=calcCFFSubroutineBias(a.subrs)}else a.subrs=[],a.subrsBias=0;var d=parseCFFIndex(e,t+f.charStrings);a.nGlyphs=d.objects.length;var g=parseCFFCharset(e,t+f.charset,a.nGlyphs,i.objects);a.cffEncoding=0===f.encoding?new encoding.CffEncoding(encoding.cffStandardEncoding,g):1===f.encoding?new encoding.CffEncoding(encoding.cffExpertEncoding,g):parseCFFEncoding(e,t+f.encoding,g),a.encoding=a.encoding||a.cffEncoding,a.glyphs=new glyphset.GlyphSet(a);for(var v=0;v=0&&(a=r),r=t.indexOf(e),r>=0?a=r+encoding.cffStandardStrings.length:(a=encoding.cffStandardStrings.length+t.length,t.push(e)),a}function makeHeader(){return new table.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function makeNameIndex(e){var t=new table.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);t.names=[];for(var a=0;ar;r+=1)for(var n=a.parseULong(),s=a.parseULong(),o=a.parseULong(),l=n;s>=l;l+=1)e.glyphIndexMap[l]=o,o++}function parseCmapTableFormat4(e,a,r,t,n){var s;e.length=a.parseUShort(),e.language=a.parseUShort();var o;e.segCount=o=a.parseUShort()>>1,a.skip("uShort",3),e.glyphIndexMap={};var l=new parse.Parser(r,t+n+14),p=new parse.Parser(r,t+n+16+2*o),g=new parse.Parser(r,t+n+16+4*o),m=new parse.Parser(r,t+n+16+6*o),u=t+n+16+8*o;for(s=0;o-1>s;s+=1)for(var h,f=l.parseUShort(),c=p.parseUShort(),d=g.parseShort(),i=m.parseUShort(),v=c;f>=v;v+=1)0!==i?(u=m.offset+m.relativeOffset-2,u+=i,u+=2*(v-c),h=parse.getUShort(r,u),0!==h&&(h=h+d&65535)):h=v+d&65535,e.glyphIndexMap[v]=h}function parseCmapTable(e,a){var r,t={};t.version=parse.getUShort(e,a),check.argument(0===t.version,"cmap table version should be 0."),t.numTables=parse.getUShort(e,a+2);var n=-1;for(r=t.numTables-1;r>=0;r-=1){var s=parse.getUShort(e,a+4+8*r),o=parse.getUShort(e,a+4+8*r+2);if(3===s&&(0===o||1===o||10===o)){n=parse.getULong(e,a+4+8*r+4);break}}if(-1===n)return null;var l=new parse.Parser(e,a+n);if(t.format=l.parseUShort(),12===t.format)parseCmapTableFormat12(t,l);else{if(4!==t.format)throw new Error("Only format 4 and 12 cmap tables are supported.");parseCmapTableFormat4(t,l,e,a,n)}return t}function addSegment(e,a,r){e.segments.push({end:a,start:a,delta:-(a-r),offset:0})}function addTerminatorSegment(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function makeCmapTable(e){var a,r=new table.Table("cmap",[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:1},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:12},{name:"format",type:"USHORT",value:4},{name:"length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);for(r.segments=[],a=0;aa;a+=1){var u=r.segments[a];o=o.concat({name:"end_"+a,type:"USHORT",value:u.end}),l=l.concat({name:"start_"+a,type:"USHORT",value:u.start}),p=p.concat({name:"idDelta_"+a,type:"SHORT",value:u.delta}),g=g.concat({name:"idRangeOffset_"+a,type:"USHORT",value:u.offset}),void 0!==u.glyphId&&(m=m.concat({name:"glyph_"+a,type:"USHORT",value:u.glyphId}))}return r.fields=r.fields.concat(o),r.fields.push({name:"reservedPad",type:"USHORT",value:0}),r.fields=r.fields.concat(l),r.fields=r.fields.concat(p),r.fields=r.fields.concat(g),r.fields=r.fields.concat(m),r.length=14+2*o.length+2+2*l.length+2*p.length+2*g.length+2*m.length,r}var check=require("../check"),parse=require("../parse"),table=require("../table");exports.parse=parseCmapTable,exports.make=makeCmapTable; + +},{"../check":2,"../parse":10,"../table":13}],16:[function(require,module,exports){ +"use strict";function addName(e,a){var r=JSON.stringify(e),n=256;for(var t in a){var s=parseInt(t);if(s&&!(256>s)){if(JSON.stringify(a[t])===r)return s;s>=n&&(n=s+1)}}return a[n]=e,n}function makeFvarAxis(e,a,r){var n=addName(a.name,r);return[{name:"tag_"+e,type:"TAG",value:a.tag},{name:"minValue_"+e,type:"FIXED",value:a.minValue<<16},{name:"defaultValue_"+e,type:"FIXED",value:a.defaultValue<<16},{name:"maxValue_"+e,type:"FIXED",value:a.maxValue<<16},{name:"flags_"+e,type:"USHORT",value:0},{name:"nameID_"+e,type:"USHORT",value:n}]}function parseFvarAxis(e,a,r){var n={},t=new parse.Parser(e,a);return n.tag=t.parseTag(),n.minValue=t.parseFixed(),n.defaultValue=t.parseFixed(),n.maxValue=t.parseFixed(),t.skip("uShort",1),n.name=r[t.parseUShort()]||{},n}function makeFvarInstance(e,a,r,n){for(var t=addName(a.name,n),s=[{name:"nameID_"+e,type:"USHORT",value:t},{name:"flags_"+e,type:"USHORT",value:0}],u=0;uo;o++)v.push(parseFvarAxis(e,a+s+o*i,r));for(var m=[],f=a+s+u*i,c=0;p>c;c++)m.push(parseFvarInstance(e,f+c*l,v,r));return{axes:v,instances:m}}var check=require("../check"),parse=require("../parse"),table=require("../table");exports.make=makeFvarTable,exports.parse=parseFvarTable; + +},{"../check":2,"../parse":10,"../table":13}],17:[function(require,module,exports){ +"use strict";function parseGlyphCoordinate(e,r,t,o,a){var n;return(r&o)>0?(n=e.parseByte(),0===(r&a)&&(n=-n),n=t+n):n=(r&a)>0?t:t+e.parseShort(),n}function parseGlyph(e,r,t){var o=new parse.Parser(r,t);e.numberOfContours=o.parseShort(),e._xMin=o.parseShort(),e._yMin=o.parseShort(),e._xMax=o.parseShort(),e._yMax=o.parseShort();var a,n;if(e.numberOfContours>0){var s,p=e.endPointIndices=[];for(s=0;ss;s+=1)if(n=o.parseByte(),a.push(n),(8&n)>0)for(var h=o.parseByte(),l=0;h>l;l+=1)a.push(n),s+=1;if(check.argument(a.length===i,"Bad flags."),p.length>0){var u,c=[];if(i>0){for(s=0;i>s;s+=1)n=a[s],u={},u.onCurve=!!(1&n),u.lastPointOfContour=p.indexOf(s)>=0,c.push(u);var y=0;for(s=0;i>s;s+=1)n=a[s],u=c[s],u.x=parseGlyphCoordinate(o,n,y,2,16),y=u.x;var f=0;for(s=0;i>s;s+=1)n=a[s],u=c[s],u.y=parseGlyphCoordinate(o,n,f,4,32),f=u.y}e.points=c}else e.points=[]}else if(0===e.numberOfContours)e.points=[];else{e.isComposite=!0,e.points=[],e.components=[];for(var v=!0;v;){a=o.parseUShort();var x={glyphIndex:o.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(1&a)>0?(2&a)>0?(x.dx=o.parseShort(),x.dy=o.parseShort()):x.matchedPoints=[o.parseUShort(),o.parseUShort()]:(2&a)>0?(x.dx=o.parseChar(),x.dy=o.parseChar()):x.matchedPoints=[o.parseByte(),o.parseByte()],(8&a)>0?x.xScale=x.yScale=o.parseF2Dot14():(64&a)>0?(x.xScale=o.parseF2Dot14(),x.yScale=o.parseF2Dot14()):(128&a)>0&&(x.xScale=o.parseF2Dot14(),x.scale01=o.parseF2Dot14(),x.scale10=o.parseF2Dot14(),x.yScale=o.parseF2Dot14()),e.components.push(x),v=!!(32&a)}}}function transformPoints(e,r){for(var t=[],o=0;or.points.length-1||o.matchedPoints[1]>a.points.length-1)throw Error("Matched points out of range in "+r.name);var s=r.points[o.matchedPoints[0]],p=a.points[o.matchedPoints[1]],i={xScale:o.xScale,scale01:o.scale01,scale10:o.scale10,yScale:o.yScale,dx:0,dy:0};p=transformPoints([p],i)[0],i.dx=s.x-p.x,i.dy=s.y-p.y,n=transformPoints(a.points,i)}r.points=r.points.concat(n)}}return getPath(r.points)}function parseGlyfTable(e,r,t,o){var a,n=new glyphset.GlyphSet(o);for(a=0;ao;o++)t[a.parseTag()]={offset:a.parseUShort()};return t}function parseCoverageTable(r,e){var a=new parse.Parser(r,e),s=a.parseUShort(),t=a.parseUShort();if(1===s)return a.parseUShortList(t);if(2===s){for(var o=[];t--;)for(var p=a.parseUShort(),n=a.parseUShort(),f=a.parseUShort(),i=p;n>=i;i++)o[f++]=i;return o}}function parseClassDefTable(r,e){var a=new parse.Parser(r,e),s=a.parseUShort();if(1===s){var t=a.parseUShort(),o=a.parseUShort(),p=a.parseUShortList(o);return function(r){return p[r-t]||0}}if(2===s){for(var n=a.parseUShort(),f=[],i=[],h=[],S=0;n>S;S++)f[S]=a.parseUShort(),i[S]=a.parseUShort(),h[S]=a.parseUShort();return function(r){for(var e=0,a=f.length-1;a>e;){var s=e+a+1>>1;rU;U++){var l=v[U],g=h[l];if(!g){g={},t.relativeOffset=l;for(var T=t.parseUShort();T--;){var c=t.parseUShort();f&&(a=t.parseShort()),i&&(s=t.parseShort()),g[c]=a}}u[n[U]]=g}return function(r,e){var a=u[r];return a?a[e]:void 0}}if(2===o){for(var b=t.parseUShort(),P=t.parseUShort(),L=t.parseUShort(),k=t.parseUShort(),d=parseClassDefTable(r,e+b),w=parseClassDefTable(r,e+P),O=[],C=0;L>C;C++)for(var G=O[C]=[],K=0;k>K;K++)f&&(a=t.parseShort()),i&&(s=t.parseShort()),G[K]=a;var V={};for(C=0;Ch;h++)i.push(parsePairPosSubTable(r,e+n[h]));f.getKerningValue=function(r,e){for(var a=i.length;a--;){var s=i[a](r,e);if(void 0!==s)return s}return 0}}return f}function parseGposTable(r,e,a){var s=new parse.Parser(r,e),t=s.parseFixed();check.argument(1===t,"Unsupported GPOS table version."),parseTaggedListTable(r,e+s.parseUShort()),parseTaggedListTable(r,e+s.parseUShort());var o=s.parseUShort();s.relativeOffset=o;for(var p=s.parseUShort(),n=s.parseOffset16List(p),f=e+o,i=0;p>i;i++){var h=parseLookupTable(r,f+n[i]);2!==h.lookupType||a.getGposKerningValue||(a.getGposKerningValue=h.getKerningValue)}}var check=require("../check"),parse=require("../parse");exports.parse=parseGposTable; + +},{"../check":2,"../parse":10}],19:[function(require,module,exports){ +"use strict";function parseGsubTable(e,t){t=t||0;var s=new Parser(e,t),r=s.parseVersion();return check.argument(1===r,"Unsupported GSUB table version."),{version:r,scripts:s.parseScriptList(),features:s.parseFeatureList(),lookups:s.parseLookupList(subtableParsers)}}function makeGsubTable(e){return new table.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new table.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new table.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new table.LookupList(e.lookups,subtableMakers)}])}var check=require("../check"),Parser=require("../parse").Parser,subtableParsers=new Array(9),table=require("../table");subtableParsers[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{substFormat:1,coverage:this.parsePointer(Parser.coverage),deltaGlyphId:this.parseUShort()}:2===t?{substFormat:2,coverage:this.parsePointer(Parser.coverage),substitute:this.parseOffset16List()}:void check.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},subtableParsers[2]=function(){var e=this.parseUShort();return check.argument(1===e,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Parser.coverage),sequences:this.parseListOfLists()}},subtableParsers[3]=function(){var e=this.parseUShort();return check.argument(1===e,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Parser.coverage),alternateSets:this.parseListOfLists()}},subtableParsers[4]=function(){var e=this.parseUShort();return check.argument(1===e,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Parser.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var lookupRecordDesc={sequenceIndex:Parser.uShort,lookupListIndex:Parser.uShort};subtableParsers[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(1===t)return{substFormat:t,coverage:this.parsePointer(Parser.coverage),ruleSets:this.parseListOfLists(function(){var e=this.parseUShort(),t=this.parseUShort();return{input:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,lookupRecordDesc)}})};if(2===t)return{substFormat:t,coverage:this.parsePointer(Parser.coverage),classDef:this.parsePointer(Parser.classDef),classSets:this.parseListOfLists(function(){var e=this.parseUShort(),t=this.parseUShort();return{classes:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,lookupRecordDesc)}})};if(3===t){var s=this.parseUShort(),r=this.parseUShort();return{substFormat:t,coverages:this.parseList(s,Parser.pointer(Parser.coverage)),lookupRecords:this.parseRecordList(r,lookupRecordDesc)}}check.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},subtableParsers[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{substFormat:1,coverage:this.parsePointer(Parser.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(lookupRecordDesc)}})}:2===t?{substFormat:2,coverage:this.parsePointer(Parser.coverage),backtrackClassDef:this.parsePointer(Parser.classDef),inputClassDef:this.parsePointer(Parser.classDef),lookaheadClassDef:this.parsePointer(Parser.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(lookupRecordDesc)}})}:3===t?{substFormat:3,backtrackCoverage:this.parseList(Parser.pointer(Parser.coverage)),inputCoverage:this.parseList(Parser.pointer(Parser.coverage)),lookaheadCoverage:this.parseList(Parser.pointer(Parser.coverage)),lookupRecords:this.parseRecordList(lookupRecordDesc)}:void check.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},subtableParsers[7]=function(){var e=this.parseUShort();check.argument(1===e,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),s=new Parser(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:subtableParsers[t].call(s)}},subtableParsers[8]=function(){var e=this.parseUShort();return check.argument(1===e,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Parser.coverage),backtrackCoverage:this.parseList(Parser.pointer(Parser.coverage)),lookaheadCoverage:this.parseList(Parser.pointer(Parser.coverage)),substitutes:this.parseUShortList()}};var subtableMakers=new Array(9);subtableMakers[1]=function(e){return 1===e.substFormat?new table.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new table.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new table.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new table.Coverage(e.coverage)}].concat(table.ushortList("substitute",e.substitute)))},subtableMakers[3]=function(e){return check.assert(1===e.substFormat,"Lookup type 3 substFormat must be 1."),new table.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new table.Coverage(e.coverage)}].concat(table.tableList("altSet",e.alternateSets,function(e){return new table.Table("alternateSetTable",table.ushortList("alternate",e))})))},subtableMakers[4]=function(e){return check.assert(1===e.substFormat,"Lookup type 4 substFormat must be 1."),new table.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new table.Coverage(e.coverage)}].concat(table.tableList("ligSet",e.ligatureSets,function(e){return new table.Table("ligatureSetTable",table.tableList("ligature",e,function(e){return new table.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:e.ligGlyph}].concat(table.ushortList("component",e.components,e.components.length+1)))}))})))},exports.parse=parseGsubTable,exports.make=makeGsubTable; + +},{"../check":2,"../parse":10,"../table":13}],20:[function(require,module,exports){ +"use strict";function parseHeadTable(e,a){var t={},r=new parse.Parser(e,a);return t.version=r.parseVersion(),t.fontRevision=Math.round(1e3*r.parseFixed())/1e3,t.checkSumAdjustment=r.parseULong(),t.magicNumber=r.parseULong(),check.argument(1594834165===t.magicNumber,"Font header has wrong magic number."),t.flags=r.parseUShort(),t.unitsPerEm=r.parseUShort(),t.created=r.parseLongDateTime(),t.modified=r.parseLongDateTime(),t.xMin=r.parseShort(),t.yMin=r.parseShort(),t.xMax=r.parseShort(),t.yMax=r.parseShort(),t.macStyle=r.parseUShort(),t.lowestRecPPEM=r.parseUShort(),t.fontDirectionHint=r.parseShort(),t.indexToLocFormat=r.parseShort(),t.glyphDataFormat=r.parseShort(),t}function makeHeadTable(e){var a=Math.round((new Date).getTime()/1e3)+2082844800,t=a;return e.createdTimestamp&&(t=e.createdTimestamp+2082844800),new table.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:t},{name:"modified",type:"LONGDATETIME",value:a},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],e)}var check=require("../check"),parse=require("../parse"),table=require("../table");exports.parse=parseHeadTable,exports.make=makeHeadTable; + +},{"../check":2,"../parse":10,"../table":13}],21:[function(require,module,exports){ +"use strict";function parseHheaTable(e,a){var r={},t=new parse.Parser(e,a);return r.version=t.parseVersion(),r.ascender=t.parseShort(),r.descender=t.parseShort(),r.lineGap=t.parseShort(),r.advanceWidthMax=t.parseUShort(),r.minLeftSideBearing=t.parseShort(),r.minRightSideBearing=t.parseShort(),r.xMaxExtent=t.parseShort(),r.caretSlopeRise=t.parseShort(),r.caretSlopeRun=t.parseShort(),r.caretOffset=t.parseShort(),t.relativeOffset+=8,r.metricDataFormat=t.parseShort(),r.numberOfHMetrics=t.parseUShort(),r}function makeHheaTable(e){return new table.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],e)}var parse=require("../parse"),table=require("../table");exports.parse=parseHheaTable,exports.make=makeHheaTable; + +},{"../parse":10,"../table":13}],22:[function(require,module,exports){ +"use strict";function parseHmtxTable(e,a,r,t,s){for(var i,l,n=new parse.Parser(e,a),p=0;t>p;p+=1){r>p&&(i=n.parseUShort(),l=n.parseShort());var d=s.get(p);d.advanceWidth=i,d.leftSideBearing=l}}function makeHmtxTable(e){for(var a=new table.Table("hmtx",[]),r=0;rn;n+=1){var h=s.parseUShort(),u=s.parseUShort(),c=s.parseShort();a[h+","+u]=c}return a}var check=require("../check"),parse=require("../parse");exports.parse=parseKernTable; + +},{"../check":2,"../parse":10}],24:[function(require,module,exports){ +"use strict";function parseLocaTable(r,a,e,s){for(var p=new parse.Parser(r,a),o=s?p.parseUShort:p.parseULong,t=[],c=0;e+1>c;c+=1){var n=o.call(p);s&&(n*=2),t.push(n)}return t}var parse=require("../parse");exports.parse=parseLocaTable; + +},{"../parse":10}],25:[function(require,module,exports){ +"use strict";function makeLtagTable(e){for(var a=new table.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:e.length}]),r="",t=12+4*e.length,n=0;ns&&(s=r.length,r+=e[n]),a.fields.push({name:"offset "+n,type:"USHORT",value:t+s}),a.fields.push({name:"length "+n,type:"USHORT",value:e[n].length})}return a.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),a}function parseLtagTable(e,a){var r=new parse.Parser(e,a),t=r.parseULong();check.argument(1===t,"Unsupported ltag table version."),r.skip("uLong",1);for(var n=r.parseULong(),s=[],l=0;n>l;l++){for(var p="",u=a+r.parseUShort(),g=r.parseUShort(),o=u;u+g>o;++o)p+=String.fromCharCode(e.getInt8(o));s.push(p)}return s}var check=require("../check"),parse=require("../parse"),table=require("../table");exports.make=makeLtagTable,exports.parse=parseLtagTable; + +},{"../check":2,"../parse":10,"../table":13}],26:[function(require,module,exports){ +"use strict";function parseMaxpTable(e,a){var r={},s=new parse.Parser(e,a);return r.version=s.parseVersion(),r.numGlyphs=s.parseUShort(),1===r.version&&(r.maxPoints=s.parseUShort(),r.maxContours=s.parseUShort(),r.maxCompositePoints=s.parseUShort(),r.maxCompositeContours=s.parseUShort(),r.maxZones=s.parseUShort(),r.maxTwilightPoints=s.parseUShort(),r.maxStorage=s.parseUShort(),r.maxFunctionDefs=s.parseUShort(),r.maxInstructionDefs=s.parseUShort(),r.maxStackElements=s.parseUShort(),r.maxSizeOfInstructions=s.parseUShort(),r.maxComponentElements=s.parseUShort(),r.maxComponentDepth=s.parseUShort()),r}function makeMaxpTable(e){return new table.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:e}])}var parse=require("../parse"),table=require("../table");exports.parse=parseMaxpTable,exports.make=makeMaxpTable; + +},{"../parse":10,"../table":13}],27:[function(require,module,exports){ +"use strict";function parseMetaTable(e,a){var r=new parse.Parser(e,a),t=r.parseULong();check.argument(1===t,"Unsupported META table version."),r.parseULong(),r.parseULong();for(var s=r.parseULong(),n={},p=0;s>p;p++){var l=r.parseTag(),u=r.parseULong(),o=r.parseULong(),v=decode.UTF8(e,a+u,o);n[l]=v}return n}function makeMetaTable(e){var a=Object.keys(e).length,r="",t=16+12*a,s=new table.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:t},{name:"numTags",type:"ULONG",value:a}]);for(var n in e){var p=r.length;r+=e[n],s.fields.push({name:"tag "+n,type:"TAG",value:n}),s.fields.push({name:"offset "+n,type:"ULONG",value:t+p}),s.fields.push({name:"length "+n,type:"ULONG",value:e[n].length})}return s.fields.push({name:"stringPool",type:"CHARARRAY",value:r}),s}var types=require("../types"),decode=types.decode,check=require("../check"),parse=require("../parse"),table=require("../table");exports.parse=parseMetaTable,exports.make=makeMetaTable; + +},{"../check":2,"../parse":10,"../table":13,"../types":32}],28:[function(require,module,exports){ +"use strict";function getLanguageCode(e,a,r){switch(e){case 0:if(65535===a)return"und";if(r)return r[a];break;case 1:return macLanguages[a];case 3:return windowsLanguages[a]}return void 0}function getEncoding(e,a,r){switch(e){case 0:return utf16;case 1:return macLanguageEncodings[r]||macScriptEncodings[a];case 3:if(1===a||10===a)return utf16}return void 0}function parseNameTable(e,a,r){for(var n={},t=new parse.Parser(e,a),s=t.parseUShort(),m=t.parseUShort(),i=t.offset+t.parseUShort(),c=0;m>c;c++){var o=t.parseUShort(),u=t.parseUShort(),l=t.parseUShort(),g=t.parseUShort(),d=nameTableNames[g]||g,f=t.parseUShort(),p=t.parseUShort(),h=getLanguageCode(o,l,r),v=getEncoding(o,u,l);if(void 0!==v&&void 0!==h){var x;if(x=v===utf16?decode.UTF16(e,i+p,f):decode.MACSTRING(e,i+p,f,v)){var y=n[d];void 0===y&&(y=n[d]={}),y[h]=x}}}var b=0;return 1===s&&(b=t.parseUShort()),n}function reverseDict(e){var a={};for(var r in e)a[e[r]]=parseInt(r);return a}function makeNameRecord(e,a,r,n,t,s){return new table.Record("NameRecord",[{name:"platformID",type:"USHORT",value:e},{name:"encodingID",type:"USHORT",value:a},{name:"languageID",type:"USHORT",value:r},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:t},{name:"offset",type:"USHORT",value:s}])}function findSubArray(e,a){var r=e.length,n=a.length-r+1;e:for(var t=0;n>t;t++)for(;n>t;t++){for(var s=0;r>s;s++)if(a[t+s]!==e[s])continue e;return t}return-1}function addStringToPool(e,a){var r=findSubArray(e,a);if(0>r){r=a.length;for(var n=0,t=e.length;t>n;++n)a.push(e[n])}return r}function makeNameTable(e,a){var r,n=[],t={},s=reverseDict(nameTableNames);for(var m in e){var i=s[m];if(void 0===i&&(i=m),r=parseInt(i),isNaN(r))throw new Error('Name table entry "'+m+'" does not exist, see nameTableNames for complete list.');t[r]=e[m],n.push(r)}for(var c=reverseDict(macLanguages),o=reverseDict(windowsLanguages),u=[],l=[],g=0;gv&&(v=a.length,a.push(f)),x=4,b=encode.UTF16(p));var k=addStringToPool(b,l);u.push(makeNameRecord(h,x,v,r,b.length,k));var S=o[f];if(void 0!==S){var T=encode.UTF16(p),N=addStringToPool(T,l);u.push(makeNameRecord(3,1,S,r,T.length,N))}}}u.sort(function(e,a){return e.platformID-a.platformID||e.encodingID-a.encodingID||e.languageID-a.languageID||e.nameID-a.nameID});for(var U=new table.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:u.length},{name:"stringOffset",type:"USHORT",value:6+12*u.length}]),I=0;I=a.begin&&et;t++)a.panose[t]=i.parseByte();return a.ulUnicodeRange1=i.parseULong(),a.ulUnicodeRange2=i.parseULong(),a.ulUnicodeRange3=i.parseULong(),a.ulUnicodeRange4=i.parseULong(),a.achVendID=String.fromCharCode(i.parseByte(),i.parseByte(),i.parseByte(),i.parseByte()),a.fsSelection=i.parseUShort(),a.usFirstCharIndex=i.parseUShort(),a.usLastCharIndex=i.parseUShort(),a.sTypoAscender=i.parseShort(),a.sTypoDescender=i.parseShort(),a.sTypoLineGap=i.parseShort(),a.usWinAscent=i.parseUShort(),a.usWinDescent=i.parseUShort(),a.version>=1&&(a.ulCodePageRange1=i.parseULong(),a.ulCodePageRange2=i.parseULong()),a.version>=2&&(a.sxHeight=i.parseShort(),a.sCapHeight=i.parseShort(),a.usDefaultChar=i.parseUShort(),a.usBreakChar=i.parseUShort(),a.usMaxContent=i.parseUShort()),a}function makeOS2Table(e){return new table.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)}var parse=require("../parse"),table=require("../table"),unicodeRanges=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];exports.unicodeRanges=unicodeRanges,exports.getUnicodeRange=getUnicodeRange,exports.parse=parseOS2Table,exports.make=makeOS2Table; + +},{"../parse":10,"../table":13}],30:[function(require,module,exports){ +"use strict";function parsePostTable(e,a){var r,n={},s=new parse.Parser(e,a);switch(n.version=s.parseVersion(),n.italicAngle=s.parseFixed(),n.underlinePosition=s.parseShort(),n.underlineThickness=s.parseShort(),n.isFixedPitch=s.parseULong(),n.minMemType42=s.parseULong(),n.maxMemType42=s.parseULong(),n.minMemType1=s.parseULong(),n.maxMemType1=s.parseULong(),n.version){case 1:n.names=encoding.standardNames.slice();break;case 2:for(n.numberOfGlyphs=s.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs),r=0;r=encoding.standardNames.length){var p=s.parseChar();n.names.push(s.parseString(p))}break;case 2.5:for(n.numberOfGlyphs=s.parseUShort(),n.offset=new Array(n.numberOfGlyphs),r=0;ra.value.tag?1:-1}),a.fields=a.fields.concat(t),a.fields=a.fields.concat(r),a}function metricsForChar(e,a,n){for(var t=0;t0){var i=e.glyphs.get(r);return i.getMetrics()}}return n}function average(e){for(var a=0,n=0;nf||void 0===a)&&f>0&&(a=f),f>m&&(m=f);var v=os2.getUnicodeRange(f);if(32>v)h|=1<v)o|=1<v)c|=1<v))throw new Error("Unicode ranges bits > 123 are reserved for internal usage");d|=1<0?ltag.make(w):void 0,L=post.make(),A=cff.make(e.glyphs,{version:e.getEnglishName("version"),fullName:E,familyName:C,weightName:N,postScriptName:O,unitsPerEm:e.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),F=e.metas&&Object.keys(e.metas).length>0?meta.make(e.metas):void 0,G=[b,M,S,T,B,R,L,A,k];U&&G.push(U),e.tables.gsub&&G.push(gsub.make(e.tables.gsub)),F&&G.push(F);var D=makeSfntTable(G),H=D.encode(),P=computeCheckSum(H),I=D.fields,j=!1;for(g=0;g=0&&255>=e,"Byte value should be between 0 and 255."),[e]},sizeOf.BYTE=constant(1),encode.CHAR=function(e){return[e.charCodeAt(0)]},sizeOf.CHAR=constant(1),encode.CHARARRAY=function(e){for(var n=[],t=0;t>8&255,255&e]},sizeOf.USHORT=constant(2),encode.SHORT=function(e){return e>=LIMIT16&&(e=-(2*LIMIT16-e)),[e>>8&255,255&e]},sizeOf.SHORT=constant(2),encode.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},sizeOf.UINT24=constant(3),encode.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},sizeOf.ULONG=constant(4),encode.LONG=function(e){return e>=LIMIT32&&(e=-(2*LIMIT32-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},sizeOf.LONG=constant(4),encode.FIXED=encode.ULONG,sizeOf.FIXED=sizeOf.ULONG,encode.FWORD=encode.SHORT,sizeOf.FWORD=sizeOf.SHORT,encode.UFWORD=encode.USHORT,sizeOf.UFWORD=sizeOf.USHORT,encode.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},sizeOf.LONGDATETIME=constant(8),encode.TAG=function(e){return check.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},sizeOf.TAG=constant(4),encode.Card8=encode.BYTE,sizeOf.Card8=sizeOf.BYTE,encode.Card16=encode.USHORT,sizeOf.Card16=sizeOf.USHORT,encode.OffSize=encode.BYTE,sizeOf.OffSize=sizeOf.BYTE,encode.SID=encode.USHORT,sizeOf.SID=sizeOf.USHORT,encode.NUMBER=function(e){return e>=-107&&107>=e?[e+139]:e>=108&&1131>=e?(e-=108,[(e>>8)+247,255&e]):e>=-1131&&-108>=e?(e=-e-108,[(e>>8)+251,255&e]):e>=-32768&&32767>=e?encode.NUMBER16(e):encode.NUMBER32(e)},sizeOf.NUMBER=function(e){return encode.NUMBER(e).length},encode.NUMBER16=function(e){return[28,e>>8&255,255&e]},sizeOf.NUMBER16=constant(3),encode.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},sizeOf.NUMBER32=constant(5),encode.REAL=function(e){var n=e.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(n);if(t){var o=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));n=(Math.round(e*o)/o).toString()}var c,r,i="";for(c=0,r=n.length;r>c;c+=1){var a=n[c];i+="e"===a?"-"===n[++c]?"c":"b":"."===a?"a":"-"===a?"e":a}i+=1&i.length?"f":"ff";var f=[30];for(c=0,r=i.length;r>c;c+=2)f.push(parseInt(i.substr(c,2),16));return f},sizeOf.REAL=function(e){return encode.REAL(e).length},encode.NAME=encode.CHARARRAY,sizeOf.NAME=sizeOf.CHARARRAY,encode.STRING=encode.CHARARRAY,sizeOf.STRING=sizeOf.CHARARRAY,decode.UTF8=function(e,n,t){for(var o=[],c=t,r=0;c>r;r++,n+=1)o[r]=e.getUint8(n);return String.fromCharCode.apply(null,o)},decode.UTF16=function(e,n,t){for(var o=[],c=t/2,r=0;c>r;r++,n+=2)o[r]=e.getUint16(n);return String.fromCharCode.apply(null,o)},encode.UTF16=function(e){for(var n=[],t=0;t>8&255,n[n.length]=255&o}return n},sizeOf.UTF16=function(e){return 2*e.length};var eightBitMacEncodings={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈Ć«Č… ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüÝ°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};decode.MACSTRING=function(e,n,t,o){var c=eightBitMacEncodings[o];if(void 0===c)return void 0;for(var r="",i=0;t>i;i++){var a=e.getUint8(n+i);r+=127>=a?String.fromCharCode(a):c[127&a]}return r};var macEncodingTableCache="function"==typeof WeakMap&&new WeakMap,macEncodingCacheKeys,getMacEncodingTable=function(e){if(!macEncodingCacheKeys){macEncodingCacheKeys={};for(var n in eightBitMacEncodings)macEncodingCacheKeys[n]=new String(n)}var t=macEncodingCacheKeys[e];if(void 0===t)return void 0;if(macEncodingTableCache){var o=macEncodingTableCache.get(t);if(void 0!==o)return o}var c=eightBitMacEncodings[e];if(void 0===c)return void 0;for(var r={},i=0;i=128&&(r=t[r],void 0===r))return void 0;o[c]=r}return o},sizeOf.MACSTRING=function(e,n){var t=encode.MACSTRING(e,n);return void 0!==t?t.length:0},encode.INDEX=function(e){var n,t=1,o=[t],c=[];for(n=0;nc;c+=1){var r=parseInt(t[c],0),i=e[r];n=n.concat(encode.OPERAND(i.value,i.type)),n=n.concat(encode.OPERATOR(r))}return n},sizeOf.DICT=function(e){return encode.DICT(e).length},encode.OPERATOR=function(e){return 1200>e?[e]:[12,e-1200]},encode.OPERAND=function(e,n){var t=[];if(Array.isArray(n))for(var o=0;oc;c+=1){var r=e[c];t=t.concat(encode[r.type](r.value))}return wmm&&wmm.set(e,t),t},sizeOf.CHARSTRING=function(e){return encode.CHARSTRING(e).length},encode.OBJECT=function(e){var n=encode[e.type];return check.argument(void 0!==n,"No encoding function for type "+e.type),n(e.value)},sizeOf.OBJECT=function(e){var n=sizeOf[e.type];return check.argument(void 0!==n,"No sizeOf function for type "+e.type),n(e.value)},encode.TABLE=function(e){var n,t=[],o=e.fields.length,c=[],r=[];for(n=0;o>n;n+=1){var i=e.fields[n],a=encode[i.type];check.argument(void 0!==a,"No encoding function for field type "+i.type+" ("+i.name+")");var f=e[i.name];void 0===f&&(f=i.value);var d=a(f);"TABLE"===i.type?(r.push(t.length),t=t.concat([0,0]),c.push(d)):t=t.concat(d)}for(n=0;ns,"Table "+e.tableName+" too big."),t[u]=s>>8,t[u+1]=255&s,t=t.concat(c[n])}return t},sizeOf.TABLE=function(e){for(var n=0,t=e.fields.length,o=0;t>o;o+=1){var c=e.fields[o],r=sizeOf[c.type];check.argument(void 0!==r,"No sizeOf function for field type "+c.type+" ("+c.name+")");var i=e[c.name];void 0===i&&(i=c.value),n+=r(i),"TABLE"===c.type&&(n+=2)}return n},encode.RECORD=encode.TABLE,sizeOf.RECORD=sizeOf.TABLE,encode.LITERAL=function(e){return e},sizeOf.LITERAL=function(e){return e.length},exports.decode=decode,exports.encode=encode,exports.sizeOf=sizeOf; + +},{"./check":2}],33:[function(require,module,exports){ +"use strict";exports.isBrowser=function(){return"undefined"!=typeof window},exports.isNode=function(){return"undefined"==typeof window},exports.nodeBufferToArrayBuffer=function(r){for(var e=new ArrayBuffer(r.length),n=new Uint8Array(e),t=0;te+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}}; +Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f, +v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats); diff --git a/three/jsutil/libs/system.min.js b/three/jsutil/libs/system.min.js new file mode 100644 index 000000000..10ad9ac6f --- /dev/null +++ b/three/jsutil/libs/system.min.js @@ -0,0 +1,4 @@ +// system.js - http://github.com/mrdoob/system.js +'use strict';var System={browser:function(){var a=navigator.userAgent;return/Arora/i.test(a)?"Arora":/Chrome/i.test(a)?"Chrome":/Epiphany/i.test(a)?"Epiphany":/Firefox/i.test(a)?"Firefox":/Mobile(\/.*)? Safari/i.test(a)?"Mobile Safari":/MSIE/i.test(a)?"Internet Explorer":/Midori/i.test(a)?"Midori":/Opera/.test(a)?"Opera":/Safari/i.test(a)?"Safari":!1}(),os:function(){var a=navigator.userAgent;return/Android/i.test(a)?"Android":/CrOS/i.test(a)?"Chrome OS":/iP[ao]d|iPhone/i.test(a)?"iOS":/Linux/i.test(a)? +"Linux":/Mac OS/i.test(a)?"Mac OS":/windows/i.test(a)?"Windows":!1}(),support:{canvas:!!window.CanvasRenderingContext2D,localStorage:function(){try{return!!window.localStorage.getItem}catch(a){return!1}}(),file:!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob,fileSystem:!!window.requestFileSystem||!!window.webkitRequestFileSystem,getUserMedia:!!window.navigator.getUserMedia||!!window.navigator.webkitGetUserMedia||!!window.navigator.mozGetUserMedia||!!window.navigator.msGetUserMedia, +requestAnimationFrame:!!window.mozRequestAnimationFrame||!!window.webkitRequestAnimationFrame||!!window.oRequestAnimationFrame||!!window.msRequestAnimationFrame,sessionStorage:function(){try{return!!window.sessionStorage.getItem}catch(a){return!1}}(),webgl:function(){try{return!!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(a){return!1}}(),worker:!!window.Worker}}; diff --git a/three/jsutil/libs/timeliner_gui.min.js b/three/jsutil/libs/timeliner_gui.min.js new file mode 100644 index 000000000..fca5117d0 --- /dev/null +++ b/three/jsutil/libs/timeliner_gui.min.js @@ -0,0 +1,182 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0;)o>=t.length?(x[o].dom.style.display="none",T.push(x.pop())):(x[o].setState(t[o]),x[o].repaint(n))}var o=document.createElement("div"),a=document.createElement("div");a.style.cssText="margin: 0px; top: 0; left: 0; height: "+LayoutConstants.MARKER_TRACK_HEIGHT+"px";var i=document.createElement("div");style(i,{position:"absolute",top:LayoutConstants.MARKER_TRACK_HEIGHT+"px",left:0,right:0,bottom:0,overflow:"hidden"}),o.appendChild(i);var p=!1,l={width:"22px",height:"22px",padding:"2px"},r={width:"32px",padding:"3px 4px 3px 4px"},d=e.dispatcher,s=(e.controller,new IconButton(16,"play","Play",d));style(s.dom,l,{marginTop:"2px"}),s.onClick(function(e){e.preventDefault(),d.fire("controls.toggle_play")});var u=new IconButton(16,"stop","Stop",d);style(u.dom,l,{marginTop:"2px"}),u.onClick(function(e){d.fire("controls.stop")});var m=document.createElement("input");m.type="range",m.value=0,m.min=-1,m.max=1,m.step=.125,style(m,{width:"80px",margin:"0px",marginLeft:"2px",marginRight:"2px"});var c=0;m.addEventListener("mousedown",function(){c=1}),m.addEventListener("mouseup",function(){c=0,t()}),m.addEventListener("mousemove",function(){c&&t()}),o.appendChild(a);var h={min:0,step:.125},f=new NumberUI(h),y=new NumberUI(h);f.onChange["do"](function(e,t){d.fire("time.update",e),f.paint()}),y.onChange["do"](function(e,t){d.fire("totalTime.update",e),y.paint()}),a.appendChild(f.dom),a.appendChild(document.createTextNode("/")),a.appendChild(y.dom),a.appendChild(s.dom),a.appendChild(u.dom),a.appendChild(m);var v=document.createElement("div");style(v,{marginTop:"4px"}),a.appendChild(v);var g=new IconButton(16,"download_alt","Download animation",d);style(g.dom,r),v.appendChild(g.dom),g.onClick(function(){d.fire("export")});var C=new IconButton(16,"upload_alt","Upload animation",d);style(C.dom,r),v.appendChild(C.dom),C.onClick(function(){d.fire("openfile")});var x=[],T=[];this.layers=x,this.setControlStatus=function(e){p=e,p?(s.setIcon("pause"),s.setTip("Pause")):(s.setIcon("play"),s.setTip("Play"))},this.updateState=function(){var t,n,o=e.controller.getChannelNames();for(t=0;t=0&&(r.style.color=Theme.c)}};this.repaint=a,this.setState=function(e){t=e,o.textContent=e,a()}}var Theme=require("./theme"),LayoutConstants=require("./layout_constants"),utils=require("./utils");module.exports=LayerView; +},{"./layout_constants":6,"./theme":7,"./utils":11}],6:[function(require,module,exports){ +module.exports={LINE_HEIGHT:26,DIAMOND_SIZE:10,MARKER_TRACK_HEIGHT:60,WIDTH:600,HEIGHT:200,LEFT_PANE_WIDTH:250,TIME_SCALE:60}; +},{}],7:[function(require,module,exports){ +module.exports={a:"#343434",b:"#535353",c:"#b8b8b8",d:"#d6d6d6"}; +},{}],8:[function(require,module,exports){ +function time_scaled(){var e=60;tickMark1=time_scale/e,tickMark2=2*tickMark1,tickMark3=8*tickMark1}function TimelinePanel(e){function t(t,n,l){var a=this,r=!1;this.time=t,this.path=function(e){e.beginPath().moveTo(n,l).lineTo(n+DIAMOND_SIZE/2,l+DIAMOND_SIZE/2).lineTo(n,l+DIAMOND_SIZE).lineTo(n-DIAMOND_SIZE/2,l+DIAMOND_SIZE/2).closePath()},this.paint=function(e){a.path(e),r?e.fillStyle("yellow"):e.fillStyle(Theme.c),e.fill().stroke()},this.mouseover=function(){r=!0,v.style.cursor="move",a.paint(x)},this.mouseout=function(){r=!1,v.style.cursor="default",a.paint(x)},this.mousedrag=function(t,n){if(void 0!==M){var l=f(t.offsetx),a=Math.max(l-C,-C),r=n.shiftKey;a&&(e.draggingKeyframe=!0,e.controller.moveKeyframe(M,C,a,r),C+=a,i())}}}function i(){K=!0}function n(){for(S.length=0,I=0,R=_.length;R>=I;I++)A.strokeStyle=Theme.b,A.beginPath(),H=I*LINE_HEIGHT,H=~~H-.5,x.moveTo(0,H).lineTo(width,H).stroke();for(I=0;R>I;I++){var i=_[I],n=e.controller.getChannelKeyTimes(i);H=I*LINE_HEIGHT;for(var l=0;lI;I++){var r=S[I];r.paint(x)}}function l(){var t=width,i=e.totalTime,n=t/time_scale,l=t/i;P.k=l,P.grip_length=n*l;var a=w;P.left=e.scrollTime*l,P.left=Math.min(Math.max(0,P.left),t-P.grip_length),A.beginPath(),A.fillStyle=Theme.b,A.rect(0,5,t,a),A.fill(),A.fillStyle=Theme.c,A.beginPath(),A.rect(P.left,5,P.grip_length,a),A.fill();var r=k*l;A.fillStyle="red",A.fillRect(0,5,r,2)}function a(e){time_scale!==e&&(time_scale=e,time_scaled())}function r(){var e,t=D;for(D=null,I=S.length;I-->0;)if(e=S[I],e.path(x),A.isPointInPath(b.x*E,b.y*E)){D=e;break}t&&t!=D&&(e=t,e.mouseout&&e.mouseout()),D&&(e=D,e.mouseover&&e.mouseover(),O&&(G=e))}function o(){b&&x.save().scale(E,E).translate(0,MARKER_TRACK_HEIGHT).beginPath().rect(0,0,e.width,e.scrollHeight).translate(-g,-d).clip().run(r).restore()}function s(){if(!K)return void o();a(e.timeScale),k=e.currentTime,frame_start=e.scrollTime,A.fillStyle=Theme.a,A.clearRect(0,0,v.width,v.height),A.save(),A.scale(E,E),A.lineWidth=1,width=e.width,height=e.height;var t=time_scale/tickMark1,i=frame_start*time_scale%t,r=(width-p+i)/t;for(I=0;r>I;I++){y=I*t+p-i,A.strokeStyle=Theme.b,A.beginPath(),A.moveTo(y,0),A.lineTo(y,height),A.stroke(),A.fillStyle=Theme.d,A.textAlign="center";var s=(I*t-i)/time_scale+frame_start;s=utils.format_friendly_seconds(s),A.fillText(s,y,38)}for(t=time_scale/tickMark2,r=(width-p+i)/t,I=0;r>I;I++)A.strokeStyle=Theme.c,A.beginPath(),y=I*t+p-i,A.moveTo(y,MARKER_TRACK_HEIGHT-0),A.lineTo(y,MARKER_TRACK_HEIGHT-16),A.stroke();var c=tickMark3/tickMark2;for(t=time_scale/tickMark3,r=(width-p+i)/t,I=0;r>I;I++)I%c!==0&&(A.strokeStyle=Theme.c,A.beginPath(),y=I*t+p-i,A.moveTo(y,MARKER_TRACK_HEIGHT-0),A.lineTo(y,MARKER_TRACK_HEIGHT-10),A.stroke());x.save().translate(0,MARKER_TRACK_HEIGHT).beginPath().rect(0,0,e.width,e.scrollHeight).translate(-g,-d).clip().run(n).restore(),l(),A.strokeStyle="red",y=(k-frame_start)*time_scale+p;var f=utils.format_friendly_seconds(k),h=A.measureText(f).width,u=MARKER_TRACK_HEIGHT-5,m=h/2+4;A.beginPath(),A.moveTo(y,u),A.lineTo(y,height),A.stroke(),A.fillStyle="red",A.textAlign="center",A.beginPath(),A.moveTo(y,u+5),A.lineTo(y+5,u),A.lineTo(y+m,u),A.lineTo(y+m,u-14),A.lineTo(y-m,u-14),A.lineTo(y-m,u),A.lineTo(y-5,u),A.closePath(),A.fill(),A.fillStyle="white",A.fillText(f,y,u-4),A.restore(),K=!1}function c(e){return 0>e-MARKER_TRACK_HEIGHT?-1:(e-MARKER_TRACK_HEIGHT+d)/LINE_HEIGHT|0}function f(e){var t=time_scale/tickMark3;return frame_start+((e-p)/t|0)/tickMark3}function h(e){var t=e-frame_start;return t*=time_scale,t+=p}function u(e){L=v.getBoundingClientRect();var t=e.clientX-L.left,i=e.clientY-L.top;m(t,i)}function m(e,t){G||(N=!0,b={x:e,y:t})}var _,T=e.dispatcher,d=0,g=0,E=window.devicePixelRatio,v=document.createElement("canvas");this.updateState=function(){_=e.controller.getChannelNames(),i()},this.updateState(),this.scrollTo=function(t){d=t*Math.max(_.length*LINE_HEIGHT-e.scrollHeight,0),i()},this.resize=function(){E=window.devicePixelRatio,v.width=e.width*E,v.height=e.height*E,v.style.width=e.width+"px",v.style.height=e.height+"px",e.scrollHeight=e.height-MARKER_TRACK_HEIGHT},this.dom=v,this.resize();var k,I,y,H,R,M,A=v.getContext("2d"),x=proxy_ctx(A),p=20,K=!1,S=[],C=0,w=20,P={left:0,grip_length:0,k:1};this.setTimeScale=a;var D=null,G=null;this.repaint=i,this._paint=s,i();var L;document.addEventListener("mousemove",u),v.addEventListener("dblclick",function(e){L=v.getBoundingClientRect();var t=e.clientX-L.left,i=e.clientY-L.top,n=c(i);f(t);T.fire("keyframe",_[n],k)});var N=!1,b=null;v.addEventListener("mouseout",function(){b=null});var O=!1,Z=!1;utils.handleDrag(v,function(e){O=!0,b={x:e.offsetx,y:e.offsety},o(),G instanceof t&&(C=G.time,M=_[c(e.offsety)],M||(G=null)),T.fire("time.update",f(e.offsetx))},function(e,t){O=!1,G?(Z=!0,G.mousedrag&&G.mousedrag(e,t)):T.fire("time.update",f(e.offsetx))},function(){Z&&T.fire("keyframe.move"),O=!1,G=null,Z=!1,e.draggingKeyframe=!1,i()});var q;utils.handleDrag(v,function(e){q=P.left},function(t){e.scrollTime=Math.max(0,(q+t.dx)/P.k),i()},function(){},function(e){var t=e.offsetx>=P.left&&e.offsetx<=P.left+P.grip_length;return e.offsety<=w&&t})}var LayoutConstants=require("./layout_constants"),Theme=require("./theme"),utils=require("./utils"),proxy_ctx=utils.proxy_ctx,LINE_HEIGHT=LayoutConstants.LINE_HEIGHT,DIAMOND_SIZE=LayoutConstants.DIAMOND_SIZE,MARKER_TRACK_HEIGHT=LayoutConstants.MARKER_TRACK_HEIGHT,LEFT_PANE_WIDTH=LayoutConstants.LEFT_PANE_WIDTH,time_scale=LayoutConstants.TIME_SCALE,frame_start=0,tickMark1,tickMark2,tickMark3;time_scaled(),module.exports=TimelinePanel; +},{"./layout_constants":6,"./theme":7,"./utils":11}],9:[function(require,module,exports){ +function LayerProp(e){this.name=e,this.values=[],this._color="#"+(16777215*Math.random()|0).toString(16)}function Timeliner(e){function t(){E=performance.now()-1e3*w.currentTime,v.setControlStatus(!0)}function n(){E=null,v.setControlStatus(!1)}function i(){if(requestAnimationFrame(i),E){var e=(performance.now()-E)/1e3;b(e),e>w.totalTime&&(E=performance.now())}H&&(T.style.width=w.width+"px",T.style.height=w.height+"px",g(v.dom,y.dom),y.resize(),h(),H=!1,f.fire("resize")),y._paint()}function o(e){}function a(e){e||(e=w.name),e=prompt("Pick a name to save to (localStorage)",e),e&&(w.name=e,o(e))}function r(){var e=w.name;e?o(e):a(e)}function s(){var t=e.serialize(),n="animation.json";saveToFile(JSON.stringify(t,null," "),n)}function l(t){e.deserialize(t),c()}function d(e){var t=JSON.parse(e);l(t)}function c(){v.updateState(),y.updateState(),h()}function h(){var e=w.controller.getChannelNames(),t=e.length*LayoutConstants.LINE_HEIGHT;x.setLength(w.scrollHeight/t),v.repaint(),y.repaint()}function u(){var e=prompt("Paste JSON in here to Load");e&&d(e)}function p(e){e&&d(localStorage[STORAGE_PREFIX+e])}function m(e,t){w.width=e-LayoutConstants.LEFT_PANE_WIDTH-4,w.height=t-44,w.scrollHeight=w.height-LayoutConstants.MARKER_TRACK_HEIGHT,x.setHeight(w.scrollHeight-2),style(x.dom,{top:LayoutConstants.MARKER_TRACK_HEIGHT+"px",left:e-16-4+"px"}),H=!0}function g(e,t){e.style.cssText="position: absolute; left: 0px; top: 0px; height: "+w.height+"px;",style(e,{overflow:"hidden"}),e.style.width=LayoutConstants.LEFT_PANE_WIDTH+"px",t.style.position="absolute",t.style.top="0px",t.style.left=LayoutConstants.LEFT_PANE_WIDTH+"px"}var f=new Dispatcher;e.timeliner=this,e.init(this);var w={width:LayoutConstants.WIDTH,height:LayoutConstants.HEIGHT,scrollHeight:0,totalTime:20,timeScale:6,currentTime:0,scrollTime:0,dispatcher:f,controller:e},y=new TimelinePanel(w),v=new LayerCabinet(w),x=(new UndoManager(f),new ScrollBar(0,10)),T=document.createElement("div");e.setDuration(w.totalTime),f.on("keyframe",function(t){var n=w.currentTime;if(null!=n&&null!=t){var i=e.getChannelKeyTimes(t,n);utils.binarySearch(i,n)<0?e.setKeyframe(t,n):e.delKeyframe(t,n),h()}}),f.on("keyframe.move",function(e,t){});var E=null,C=0,b=function(t){var n=Math.min(Math.max(t,0),w.totalTime);w.currentTime=n,e.setDisplayTime(n),E&&(E=performance.now()-1e3*t),h()};f.on("controls.toggle_play",function(){E?n():t()}),f.on("controls.restart_play",function(){E||t(),b(C)}),f.on("controls.play",t),f.on("controls.pause",n),f.on("controls.stop",function(){null!==E&&n(),b(0)}),f.on("time.update",b),f.on("totalTime.update",function(t){w.totalTime=t,e.setDuration(t),y.repaint()}),f.on("update.scale",function(e){w.timeScale=e,y.setTimeScale(e),y.repaint()}),f.on("controls.undo",function(){}),f.on("controls.redo",function(){});var H=!0;i(),this.openLocalSave=p,f.on("import",function(){u()}.bind(this)),f.on("new",function(){data.blank(),c()}),f.on("openfile",function(){openAs(function(e){d(e)},T)}),f.on("open",p),f.on("export",s),f.on("save",r),f.on("save_as",a),this.save=o,this.load=l,style(T,{textAlign:"left",lineHeight:"1em",position:"absolute",top:"22px"});var L=document.createElement("div");style(L,{position:"fixed",top:"20px",left:"20px",margin:0,border:"1px solid "+Theme.a,padding:0,overflow:"hidden",backgroundColor:Theme.a,color:Theme.d,zIndex:Z_INDEX,fontFamily:"monospace",fontSize:"12px"});var _={position:"absolute",top:"0px",width:"100%",height:"22px",lineHeight:"22px",overflow:"hidden"},S={width:"20px",height:"20px",padding:"2px",marginRight:"2px"},k=document.createElement("div");style(k,_,{borderBottom:"1px solid "+Theme.b,textAlign:"center"});var I=document.createElement("span");k.appendChild(I),I.innerHTML=package_json.description+" "+package_json.version,k.appendChild(I);var R=document.createElement("div");style(R,_,{textAlign:"right"}),k.appendChild(R);var A=new IconButton(10,"resize_full","Maximize",f);style(A.dom,S,{marginRight:"2px"}),R.appendChild(A.dom);var M=document.createElement("div"),W={position:"absolute",width:"100%",height:"22px",lineHeight:"22px",bottom:"0",fontSize:"11px"};style(M,W,{borderTop:"1px solid "+Theme.b,background:Theme.a}),L.appendChild(T),L.appendChild(M),L.appendChild(k);var z=document.createElement("span");z.textContent="Hello!",z.style.marginLeft="10px",f.on("status",function(e){z.textContent=e}),f.on("state:save",function(e){f.fire("status",e),o("autosave")});var D=document.createElement("div");style(D,W,{textAlign:"right"}),M.appendChild(z),M.appendChild(D);var P=document.createElement("div");style(P,{background:"#999",opacity:.2,position:"fixed",margin:0,padding:0,zIndex:Z_INDEX-1,transitionProperty:"top, left, width, height, opacity",transitionDuration:"0.25s",transitionTimingFunction:"ease-in-out"}),document.body.appendChild(L),document.body.appendChild(P),T.appendChild(v.dom),T.appendChild(y.dom),T.appendChild(x.dom),x.onScroll["do"](function(e,t){switch(e){case"scrollto":v.scrollTo(t),y.scrollTo(t)}}),document.addEventListener("keydown",function(e){var t=32==e.keyCode,n=13==e.keyCode,i=(e.metaKey&&91==e.keyCode&&!e.shiftKey,document.activeElement);i.nodeName.match(/(INPUT|BUTTON|SELECT)/)&&i.blur(),t?f.fire("controls.toggle_play"):n?f.fire("controls.restart_play"):27==e.keyCode&&f.fire("controls.pause")}),this.dispose=function(){var e=L.parentElement;e.removeChild(L),e.removeChild(P)},function(){"use strict";function e(e,t,n,i,o){e.style.left=t+"px",e.style.top=n+"px",e.style.width=i+"px",e.style.height=o+"px",e===L&&m(i,o)}function t(){e(P,N.left,N.top,N.width,N.height),P.style.opacity=0}function n(e){B=!0}function i(e){B=!1}function o(e){l(e.touches[0]),e.preventDefault()}function a(e){h(e.touches[0])}function r(e){0==e.touches.length&&f(e.changedTouches[0])}function s(e){l(e)}function l(e){c(e);var t=y||v||T||x,n=!t&&d();W={x:E,y:C,cx:e.clientX,cy:e.clientY,w:N.width,h:N.height,isResizing:t,isMoving:n,onTopEdge:T,onLeftEdge:x,onRightEdge:y,onBottomEdge:v},(t||n)&&e.preventDefault(),e.stopPropagation()}function d(){return F}function c(e){N=L.getBoundingClientRect(),E=e.clientX-N.left,C=e.clientY-N.top,T=R>C,x=R>E,y=E>=N.width-R,v=C>=N.height-R}function h(e){q=e,c(q),X=!0,B&&q.stopPropagation()}function u(){if(requestAnimationFrame(u),X){if(X=!1,W&&W.isResizing){if(W.onRightEdge&&(L.style.width=Math.max(E,b)+"px"),W.onBottomEdge&&(L.style.height=Math.max(C,_)+"px"),W.onLeftEdge){var n=Math.max(W.cx-q.clientX+W.w,b);n>b&&(L.style.width=n+"px",L.style.left=q.clientX+"px")}if(W.onTopEdge){var i=Math.max(W.cy-q.clientY+W.h,_);i>_&&(L.style.height=i+"px",L.style.top=q.clientY+"px")}return t(),void m(N.width,N.height)}if(W&&W.isMoving){switch(p()){case"full-screen":e(P,0,0,window.innerWidth,window.innerHeight),P.style.opacity=.2;break;case"snap-top-edge":e(P,0,0,window.innerWidth,.25*window.innerHeight),P.style.opacity=.2;break;case"snap-left-edge":e(P,0,0,.35*window.innerWidth,window.innerHeight),P.style.opacity=.2;break;case"snap-right-edge":e(P,.65*window.innerWidth,0,.35*window.innerWidth,window.innerHeight),P.style.opacity=.2;break;case"snap-bottom-edge":e(P,0,.75*window.innerHeight,window.innerWidth,.25*window.innerHeight),P.style.opacity=.2;break;default:t()}return z?void e(L,q.clientX-z.width/2,q.clientY-Math.min(W.y,z.height),z.width,z.height):(L.style.top=q.clientY-W.y+"px",void(L.style.left=q.clientX-W.x+"px"))}y&&v||x&&T?L.style.cursor="nwse-resize":y&&T||v&&x?L.style.cursor="nesw-resize":y||x?L.style.cursor="ew-resize":v||T?L.style.cursor="ns-resize":d()?L.style.cursor="move":L.style.cursor="default"}}function p(){return q.clientYthis.MAX_ITEMS&&n.shift(),this.index=n.length-1,e||this.dispatcher.fire("state:save",t.description)},UndoManager.prototype.clear=function(){this.states=[],this.index=-1},UndoManager.prototype.canUndo=function(){return this.index>0},UndoManager.prototype.canRedo=function(){return this.indexn;){var i=n+o>>1;e[i]0){var c=e%1*60;"frames"===t?u=o+"+"+c.toFixed(0)+"f":u+=(e%1).toFixed(2).substring(1)}return u}function proxy_ctx(e){function t(t){return function(){return e[t].apply(e,arguments),o}}function n(t){return function(n){return e[t]=n,o}}var o={};o.run=function(e){return e(o),o};for(var r in e){var i=typeof e[r];switch(i){case"object":break;case"function":o[r]=t(r);break;default:o[r]=n(r)}}return o}module.exports={STORAGE_PREFIX:"timeliner-",Z_INDEX:999,style:style,saveToFile:saveToFile,openAs:openAs,format_friendly_seconds:format_friendly_seconds,proxy_ctx:proxy_ctx,handleDrag:handleDrag,binarySearch:binarySearch};var input,openCallback; +},{}],12:[function(require,module,exports){ +module.exports={ + "unitsPerEm": 1792, + "ascender": 1536, + "descender": -256, + "fonts": { + "plus": { + "advanceWidth": 1408, + "commands": "M,1408,800 C,1408,853,1365,896,1312,896 L,896,896 L,896,1312 C,896,1365,853,1408,800,1408 L,608,1408 C,555,1408,512,1365,512,1312 L,512,896 L,96,896 C,43,896,0,853,0,800 L,0,608 C,0,555,43,512,96,512 L,512,512 L,512,96 C,512,43,555,0,608,0 L,800,0 C,853,0,896,43,896,96 L,896,512 L,1312,512 C,1365,512,1408,555,1408,608 Z" + }, + "minus": { + "advanceWidth": 1408, + "commands": "M,1408,800 C,1408,853,1365,896,1312,896 L,96,896 C,43,896,0,853,0,800 L,0,608 C,0,555,43,512,96,512 L,1312,512 C,1365,512,1408,555,1408,608 Z" + }, + "ok": { + "advanceWidth": 1792, + "commands": "M,1671,970 C,1671,995,1661,1020,1643,1038 L,1507,1174 C,1489,1192,1464,1202,1439,1202 C,1414,1202,1389,1192,1371,1174 L,715,517 L,421,812 C,403,830,378,840,353,840 C,328,840,303,830,285,812 L,149,676 C,131,658,121,633,121,608 C,121,583,131,558,149,540 L,511,178 L,647,42 C,665,24,690,14,715,14 C,740,14,765,24,783,42 L,919,178 L,1643,902 C,1661,920,1671,945,1671,970 Z" + }, + "remove": { + "advanceWidth": 1408, + "commands": "M,1298,214 C,1298,239,1288,264,1270,282 L,976,576 L,1270,870 C,1288,888,1298,913,1298,938 C,1298,963,1288,988,1270,1006 L,1134,1142 C,1116,1160,1091,1170,1066,1170 C,1041,1170,1016,1160,998,1142 L,704,848 L,410,1142 C,392,1160,367,1170,342,1170 C,317,1170,292,1160,274,1142 L,138,1006 C,120,988,110,963,110,938 C,110,913,120,888,138,870 L,432,576 L,138,282 C,120,264,110,239,110,214 C,110,189,120,164,138,146 L,274,10 C,292,-8,317,-18,342,-18 C,367,-18,392,-8,410,10 L,704,304 L,998,10 C,1016,-8,1041,-18,1066,-18 C,1091,-18,1116,-8,1134,10 L,1270,146 C,1288,164,1298,189,1298,214 Z" + }, + "zoom_in": { + "advanceWidth": 1664, + "commands": "M,1024,736 C,1024,753,1009,768,992,768 L,768,768 L,768,992 C,768,1009,753,1024,736,1024 L,672,1024 C,655,1024,640,1009,640,992 L,640,768 L,416,768 C,399,768,384,753,384,736 L,384,672 C,384,655,399,640,416,640 L,640,640 L,640,416 C,640,399,655,384,672,384 L,736,384 C,753,384,768,399,768,416 L,768,640 L,992,640 C,1009,640,1024,655,1024,672 M,1152,704 C,1152,457,951,256,704,256 C,457,256,256,457,256,704 C,256,951,457,1152,704,1152 C,951,1152,1152,951,1152,704 M,1664,-128 C,1664,-94,1650,-61,1627,-38 L,1284,305 C,1365,422,1408,562,1408,704 C,1408,1093,1093,1408,704,1408 C,315,1408,0,1093,0,704 C,0,315,315,0,704,0 C,846,0,986,43,1103,124 L,1446,-218 C,1469,-242,1502,-256,1536,-256 C,1607,-256,1664,-199,1664,-128 Z" + }, + "zoom_out": { + "advanceWidth": 1664, + "commands": "M,1024,736 C,1024,753,1009,768,992,768 L,416,768 C,399,768,384,753,384,736 L,384,672 C,384,655,399,640,416,640 L,992,640 C,1009,640,1024,655,1024,672 M,1152,704 C,1152,457,951,256,704,256 C,457,256,256,457,256,704 C,256,951,457,1152,704,1152 C,951,1152,1152,951,1152,704 M,1664,-128 C,1664,-94,1650,-61,1627,-38 L,1284,305 C,1365,422,1408,562,1408,704 C,1408,1093,1093,1408,704,1408 C,315,1408,0,1093,0,704 C,0,315,315,0,704,0 C,846,0,986,43,1103,124 L,1446,-218 C,1469,-242,1502,-256,1536,-256 C,1607,-256,1664,-199,1664,-128 Z" + }, + "cog": { + "advanceWidth": 1536, + "commands": "M,1024,640 C,1024,499,909,384,768,384 C,627,384,512,499,512,640 C,512,781,627,896,768,896 C,909,896,1024,781,1024,640 M,1536,749 C,1536,766,1524,782,1507,785 L,1324,813 C,1314,846,1300,879,1283,911 C,1317,958,1354,1002,1388,1048 C,1393,1055,1396,1062,1396,1071 C,1396,1079,1394,1087,1389,1093 C,1347,1152,1277,1214,1224,1263 C,1217,1269,1208,1273,1199,1273 C,1190,1273,1181,1270,1175,1264 L,1033,1157 C,1004,1172,974,1184,943,1194 L,915,1378 C,913,1395,897,1408,879,1408 L,657,1408 C,639,1408,625,1396,621,1380 C,605,1320,599,1255,592,1194 C,561,1184,530,1171,501,1156 L,363,1263 C,355,1269,346,1273,337,1273 C,303,1273,168,1127,144,1094 C,139,1087,135,1080,135,1071 C,135,1062,139,1054,145,1047 C,182,1002,218,957,252,909 C,236,879,223,849,213,817 L,27,789 C,12,786,0,768,0,753 L,0,531 C,0,514,12,498,29,495 L,212,468 C,222,434,236,401,253,369 C,219,322,182,278,148,232 C,143,225,140,218,140,209 C,140,201,142,193,147,186 C,189,128,259,66,312,18 C,319,11,328,7,337,7 C,346,7,355,10,362,16 L,503,123 C,532,108,562,96,593,86 L,621,-98 C,623,-115,639,-128,657,-128 L,879,-128 C,897,-128,911,-116,915,-100 C,931,-40,937,25,944,86 C,975,96,1006,109,1035,124 L,1173,16 C,1181,11,1190,7,1199,7 C,1233,7,1368,154,1392,186 C,1398,193,1401,200,1401,209 C,1401,218,1397,227,1391,234 C,1354,279,1318,323,1284,372 C,1300,401,1312,431,1323,463 L,1508,491 C,1524,494,1536,512,1536,527 Z" + }, + "trash": { + "advanceWidth": 1408, + "commands": "M,512,800 C,512,818,498,832,480,832 L,416,832 C,398,832,384,818,384,800 L,384,224 C,384,206,398,192,416,192 L,480,192 C,498,192,512,206,512,224 M,768,800 C,768,818,754,832,736,832 L,672,832 C,654,832,640,818,640,800 L,640,224 C,640,206,654,192,672,192 L,736,192 C,754,192,768,206,768,224 M,1024,800 C,1024,818,1010,832,992,832 L,928,832 C,910,832,896,818,896,800 L,896,224 C,896,206,910,192,928,192 L,992,192 C,1010,192,1024,206,1024,224 M,1152,76 C,1152,28,1125,0,1120,0 L,288,0 C,283,0,256,28,256,76 L,256,1024 L,1152,1024 L,1152,76 M,480,1152 L,529,1269 C,532,1273,540,1279,546,1280 L,863,1280 C,868,1279,877,1273,880,1269 L,928,1152 M,1408,1120 C,1408,1138,1394,1152,1376,1152 L,1067,1152 L,997,1319 C,977,1368,917,1408,864,1408 L,544,1408 C,491,1408,431,1368,411,1319 L,341,1152 L,32,1152 C,14,1152,0,1138,0,1120 L,0,1056 C,0,1038,14,1024,32,1024 L,128,1024 L,128,72 C,128,-38,200,-128,288,-128 L,1120,-128 C,1208,-128,1280,-34,1280,76 L,1280,1024 L,1376,1024 C,1394,1024,1408,1038,1408,1056 Z" + }, + "file_alt": { + "advanceWidth": 1536, + "commands": "M,1468,1156 L,1156,1468 C,1119,1505,1045,1536,992,1536 L,96,1536 C,43,1536,0,1493,0,1440 L,0,-160 C,0,-213,43,-256,96,-256 L,1440,-256 C,1493,-256,1536,-213,1536,-160 L,1536,992 C,1536,1045,1505,1119,1468,1156 M,1024,1400 C,1041,1394,1058,1385,1065,1378 L,1378,1065 C,1385,1058,1394,1041,1400,1024 L,1024,1024 M,1408,-128 L,128,-128 L,128,1408 L,896,1408 L,896,992 C,896,939,939,896,992,896 L,1408,896 Z" + }, + "download_alt": { + "advanceWidth": 1664, + "commands": "M,1280,192 C,1280,157,1251,128,1216,128 C,1181,128,1152,157,1152,192 C,1152,227,1181,256,1216,256 C,1251,256,1280,227,1280,192 M,1536,192 C,1536,157,1507,128,1472,128 C,1437,128,1408,157,1408,192 C,1408,227,1437,256,1472,256 C,1507,256,1536,227,1536,192 M,1664,416 C,1664,469,1621,512,1568,512 L,1104,512 L,968,376 C,931,340,883,320,832,320 C,781,320,733,340,696,376 L,561,512 L,96,512 C,43,512,0,469,0,416 L,0,96 C,0,43,43,0,96,0 L,1568,0 C,1621,0,1664,43,1664,96 M,1339,985 C,1329,1008,1306,1024,1280,1024 L,1024,1024 L,1024,1472 C,1024,1507,995,1536,960,1536 L,704,1536 C,669,1536,640,1507,640,1472 L,640,1024 L,384,1024 C,358,1024,335,1008,325,985 C,315,961,320,933,339,915 L,787,467 C,799,454,816,448,832,448 C,848,448,865,454,877,467 L,1325,915 C,1344,933,1349,961,1339,985 Z" + }, + "repeat": { + "advanceWidth": 1536, + "commands": "M,1536,1280 C,1536,1306,1520,1329,1497,1339 C,1473,1349,1445,1344,1427,1325 L,1297,1196 C,1156,1329,965,1408,768,1408 C,345,1408,0,1063,0,640 C,0,217,345,-128,768,-128 C,997,-128,1213,-27,1359,149 C,1369,162,1369,181,1357,192 L,1220,330 C,1213,336,1204,339,1195,339 C,1186,338,1177,334,1172,327 C,1074,200,927,128,768,128 C,486,128,256,358,256,640 C,256,922,486,1152,768,1152 C,899,1152,1023,1102,1117,1015 L,979,877 C,960,859,955,831,965,808 C,975,784,998,768,1024,768 L,1472,768 C,1507,768,1536,797,1536,832 Z" + }, + "pencil": { + "advanceWidth": 1536, + "commands": "M,363,0 L,256,0 L,256,128 L,128,128 L,128,235 L,219,326 L,454,91 M,886,928 C,886,922,884,916,879,911 L,337,369 C,332,364,326,362,320,362 C,307,362,298,371,298,384 C,298,390,300,396,305,401 L,847,943 C,852,948,858,950,864,950 C,877,950,886,941,886,928 M,832,1120 L,0,288 L,0,-128 L,416,-128 L,1248,704 M,1515,1024 C,1515,1058,1501,1091,1478,1115 L,1243,1349 C,1219,1373,1186,1387,1152,1387 C,1118,1387,1085,1373,1062,1349 L,896,1184 L,1312,768 L,1478,934 C,1501,957,1515,990,1515,1024 Z" + }, + "edit": { + "advanceWidth": 1792, + "commands": "M,888,352 L,832,352 L,832,448 L,736,448 L,736,504 L,852,620 L,1004,468 M,1328,1072 C,1337,1063,1336,1048,1327,1039 L,977,689 C,968,680,953,679,944,688 C,935,697,936,712,945,721 L,1295,1071 C,1304,1080,1319,1081,1328,1072 M,1408,478 C,1408,491,1400,502,1388,507 C,1376,512,1363,510,1353,500 L,1289,436 C,1283,430,1280,422,1280,414 L,1280,288 C,1280,200,1208,128,1120,128 L,288,128 C,200,128,128,200,128,288 L,128,1120 C,128,1208,200,1280,288,1280 L,1120,1280 C,1135,1280,1150,1278,1165,1274 C,1176,1270,1188,1273,1197,1282 L,1246,1331 C,1254,1339,1257,1349,1255,1360 C,1253,1370,1246,1379,1237,1383 C,1200,1400,1160,1408,1120,1408 L,288,1408 C,129,1408,0,1279,0,1120 L,0,288 C,0,129,129,0,288,0 L,1120,0 C,1279,0,1408,129,1408,288 M,1312,1216 L,640,544 L,640,256 L,928,256 L,1600,928 M,1756,1084 C,1793,1121,1793,1183,1756,1220 L,1604,1372 C,1567,1409,1505,1409,1468,1372 L,1376,1280 L,1664,992 L,1756,1084 Z" + }, + "play": { + "advanceWidth": 1408, + "commands": "M,1384,609 C,1415,626,1415,654,1384,671 L,56,1409 C,25,1426,0,1411,0,1376 L,0,-96 C,0,-131,25,-146,56,-129 Z" + }, + "pause": { + "advanceWidth": 1536, + "commands": "M,1536,1344 C,1536,1379,1507,1408,1472,1408 L,960,1408 C,925,1408,896,1379,896,1344 L,896,-64 C,896,-99,925,-128,960,-128 L,1472,-128 C,1507,-128,1536,-99,1536,-64 M,640,1344 C,640,1379,611,1408,576,1408 L,64,1408 C,29,1408,0,1379,0,1344 L,0,-64 C,0,-99,29,-128,64,-128 L,576,-128 C,611,-128,640,-99,640,-64 Z" + }, + "stop": { + "advanceWidth": 1536, + "commands": "M,1536,1344 C,1536,1379,1507,1408,1472,1408 L,64,1408 C,29,1408,0,1379,0,1344 L,0,-64 C,0,-99,29,-128,64,-128 L,1472,-128 C,1507,-128,1536,-99,1536,-64 Z" + }, + "resize_full": { + "advanceWidth": 1536, + "commands": "M,755,480 C,755,488,751,497,745,503 L,631,617 C,625,623,616,627,608,627 C,600,627,591,623,585,617 L,253,285 L,109,429 C,97,441,81,448,64,448 C,29,448,0,419,0,384 L,0,-64 C,0,-99,29,-128,64,-128 L,512,-128 C,547,-128,576,-99,576,-64 C,576,-47,569,-31,557,-19 L,413,125 L,745,457 C,751,463,755,472,755,480 M,1536,1344 C,1536,1379,1507,1408,1472,1408 L,1024,1408 C,989,1408,960,1379,960,1344 C,960,1327,967,1311,979,1299 L,1123,1155 L,791,823 C,785,817,781,808,781,800 C,781,792,785,783,791,777 L,905,663 C,911,657,920,653,928,653 C,936,653,945,657,951,663 L,1283,995 L,1427,851 C,1439,839,1455,832,1472,832 C,1507,832,1536,861,1536,896 Z" + }, + "resize_small": { + "advanceWidth": 1536, + "commands": "M,768,576 C,768,611,739,640,704,640 L,256,640 C,221,640,192,611,192,576 C,192,559,199,543,211,531 L,355,387 L,23,55 C,17,49,13,40,13,32 C,13,24,17,15,23,9 L,137,-105 C,143,-111,152,-115,160,-115 C,168,-115,177,-111,183,-105 L,515,227 L,659,83 C,671,71,687,64,704,64 C,739,64,768,93,768,128 M,1523,1248 C,1523,1256,1519,1265,1513,1271 L,1399,1385 C,1393,1391,1384,1395,1376,1395 C,1368,1395,1359,1391,1353,1385 L,1021,1053 L,877,1197 C,865,1209,849,1216,832,1216 C,797,1216,768,1187,768,1152 L,768,704 C,768,669,797,640,832,640 L,1280,640 C,1315,640,1344,669,1344,704 C,1344,721,1337,737,1325,749 L,1181,893 L,1513,1225 C,1519,1231,1523,1240,1523,1248 Z" + }, + "eye_open": { + "advanceWidth": 1792, + "commands": "M,1664,576 C,1493,312,1217,128,896,128 C,575,128,299,312,128,576 C,223,723,353,849,509,929 C,469,861,448,783,448,704 C,448,457,649,256,896,256 C,1143,256,1344,457,1344,704 C,1344,783,1323,861,1283,929 C,1439,849,1569,723,1664,576 M,944,960 C,944,934,922,912,896,912 C,782,912,688,818,688,704 C,688,678,666,656,640,656 C,614,656,592,678,592,704 C,592,871,729,1008,896,1008 C,922,1008,944,986,944,960 M,1792,576 C,1792,601,1784,624,1772,645 C,1588,947,1251,1152,896,1152 C,541,1152,204,947,20,645 C,8,624,0,601,0,576 C,0,551,8,528,20,507 C,204,205,541,0,896,0 C,1251,0,1588,204,1772,507 C,1784,528,1792,551,1792,576 Z" + }, + "eye_close": { + "advanceWidth": 1792, + "commands": "M,555,201 C,379,280,232,415,128,576 C,223,723,353,849,509,929 C,469,861,448,783,448,704 C,448,561,517,426,633,342 M,944,960 C,944,934,922,912,896,912 C,782,912,688,819,688,704 C,688,678,666,656,640,656 C,614,656,592,678,592,704 C,592,871,729,1008,896,1008 C,922,1008,944,986,944,960 M,1307,1151 C,1307,1162,1301,1172,1291,1178 C,1270,1190,1176,1248,1158,1248 C,1146,1248,1136,1242,1130,1232 L,1076,1135 C,1017,1146,956,1152,896,1152 C,527,1152,218,949,20,645 C,7,625,0,600,0,576 C,0,551,7,527,20,507 C,135,327,298,177,492,89 C,482,72,448,18,448,2 C,448,-10,454,-20,464,-26 C,485,-38,580,-96,598,-96 C,609,-96,620,-90,626,-80 L,675,9 C,886,386,1095,765,1306,1142 C,1307,1144,1307,1149,1307,1151 M,1344,704 C,1344,732,1341,760,1336,788 L,1056,286 C,1229,352,1344,518,1344,704 M,1792,576 C,1792,602,1785,623,1772,645 C,1694,774,1569,899,1445,982 L,1382,870 C,1495,792,1590,691,1664,576 C,1508,334,1261,157,970,132 L,896,0 C,1197,0,1467,137,1663,362 C,1702,407,1741,456,1772,507 C,1785,529,1792,550,1792,576 Z" + }, + "folder_open": { + "advanceWidth": 1920, + "commands": "M,1879,584 C,1879,629,1828,640,1792,640 L,704,640 C,616,640,498,586,440,518 L,104,122 C,88,104,73,80,73,56 C,73,11,124,0,160,0 L,1248,0 C,1336,0,1454,54,1512,122 L,1848,518 C,1864,536,1879,560,1879,584 M,1536,928 C,1536,1051,1435,1152,1312,1152 L,768,1152 L,768,1184 C,768,1307,667,1408,544,1408 L,224,1408 C,101,1408,0,1307,0,1184 L,0,224 C,0,216,1,207,1,199 L,6,205 L,343,601 C,424,697,579,768,704,768 L,1536,768 Z" + }, + "signin": { + "advanceWidth": 1536, + "commands": "M,1184,640 C,1184,657,1177,673,1165,685 L,621,1229 C,609,1241,593,1248,576,1248 C,541,1248,512,1219,512,1184 L,512,896 L,64,896 C,29,896,0,867,0,832 L,0,448 C,0,413,29,384,64,384 L,512,384 L,512,96 C,512,61,541,32,576,32 C,593,32,609,39,621,51 L,1165,595 C,1177,607,1184,623,1184,640 M,1536,992 C,1536,1151,1407,1280,1248,1280 L,928,1280 C,883,1280,896,1212,896,1184 C,896,1147,935,1152,960,1152 L,1248,1152 C,1336,1152,1408,1080,1408,992 L,1408,288 C,1408,200,1336,128,1248,128 L,928,128 C,883,128,896,60,896,32 C,896,15,911,0,928,0 L,1248,0 C,1407,0,1536,129,1536,288 Z" + }, + "upload_alt": { + "advanceWidth": 1664, + "commands": "M,1280,64 C,1280,29,1251,0,1216,0 C,1181,0,1152,29,1152,64 C,1152,99,1181,128,1216,128 C,1251,128,1280,99,1280,64 M,1536,64 C,1536,29,1507,0,1472,0 C,1437,0,1408,29,1408,64 C,1408,99,1437,128,1472,128 C,1507,128,1536,99,1536,64 M,1664,288 C,1664,341,1621,384,1568,384 L,1141,384 C,1114,310,1043,256,960,256 L,704,256 C,621,256,550,310,523,384 L,96,384 C,43,384,0,341,0,288 L,0,-32 C,0,-85,43,-128,96,-128 L,1568,-128 C,1621,-128,1664,-85,1664,-32 M,1339,936 C,1349,959,1344,987,1325,1005 L,877,1453 C,865,1466,848,1472,832,1472 C,816,1472,799,1466,787,1453 L,339,1005 C,320,987,315,959,325,936 C,335,912,358,896,384,896 L,640,896 L,640,448 C,640,413,669,384,704,384 L,960,384 C,995,384,1024,413,1024,448 L,1024,896 L,1280,896 C,1306,896,1329,912,1339,936 Z" + }, + "save": { + "advanceWidth": 1536, + "commands": "M,384,0 L,384,384 L,1152,384 L,1152,0 M,1280,0 L,1280,416 C,1280,469,1237,512,1184,512 L,352,512 C,299,512,256,469,256,416 L,256,0 L,128,0 L,128,1280 L,256,1280 L,256,864 C,256,811,299,768,352,768 L,928,768 C,981,768,1024,811,1024,864 L,1024,1280 C,1044,1280,1083,1264,1097,1250 L,1378,969 C,1391,956,1408,915,1408,896 L,1408,0 M,896,928 C,896,911,881,896,864,896 L,672,896 C,655,896,640,911,640,928 L,640,1248 C,640,1265,655,1280,672,1280 L,864,1280 C,881,1280,896,1265,896,1248 L,896,928 M,1536,896 C,1536,949,1506,1022,1468,1060 L,1188,1340 C,1150,1378,1077,1408,1024,1408 L,96,1408 C,43,1408,0,1365,0,1312 L,0,-32 C,0,-85,43,-128,96,-128 L,1440,-128 C,1493,-128,1536,-85,1536,-32 Z" + }, + "undo": { + "advanceWidth": 1536, + "commands": "M,1536,640 C,1536,1063,1191,1408,768,1408 C,571,1408,380,1329,239,1196 L,109,1325 C,91,1344,63,1349,40,1339 C,16,1329,0,1306,0,1280 L,0,832 C,0,797,29,768,64,768 L,512,768 C,538,768,561,784,571,808 C,581,831,576,859,557,877 L,420,1015 C,513,1102,637,1152,768,1152 C,1050,1152,1280,922,1280,640 C,1280,358,1050,128,768,128 C,609,128,462,200,364,327 C,359,334,350,338,341,339 C,332,339,323,336,316,330 L,179,192 C,168,181,167,162,177,149 C,323,-27,539,-128,768,-128 C,1191,-128,1536,217,1536,640 Z" + }, + "paste": { + "advanceWidth": 1792, + "commands": "M,768,-128 L,768,1024 L,1152,1024 L,1152,608 C,1152,555,1195,512,1248,512 L,1664,512 L,1664,-128 M,1024,1312 C,1024,1295,1009,1280,992,1280 L,288,1280 C,271,1280,256,1295,256,1312 L,256,1376 C,256,1393,271,1408,288,1408 L,992,1408 C,1009,1408,1024,1393,1024,1376 L,1024,1312 M,1280,640 L,1280,939 L,1579,640 M,1792,512 C,1792,565,1762,638,1724,676 L,1316,1084 C,1305,1095,1293,1104,1280,1112 L,1280,1440 C,1280,1493,1237,1536,1184,1536 L,96,1536 C,43,1536,0,1493,0,1440 L,0,96 C,0,43,43,0,96,0 L,640,0 L,640,-160 C,640,-213,683,-256,736,-256 L,1696,-256 C,1749,-256,1792,-213,1792,-160 Z" + }, + "folder_open_alt": { + "advanceWidth": 1920, + "commands": "M,1781,605 C,1781,590,1772,577,1763,566 L,1469,203 C,1435,161,1365,128,1312,128 L,224,128 C,202,128,171,135,171,163 C,171,178,180,191,189,203 L,483,566 C,517,607,587,640,640,640 L,1728,640 C,1750,640,1781,633,1781,605 M,640,768 C,549,768,442,717,384,646 L,128,331 L,128,1184 C,128,1237,171,1280,224,1280 L,544,1280 C,597,1280,640,1237,640,1184 L,640,1120 C,640,1067,683,1024,736,1024 L,1312,1024 C,1365,1024,1408,981,1408,928 L,1408,768 M,1909,605 C,1909,629,1904,652,1894,673 C,1864,737,1796,768,1728,768 L,1536,768 L,1536,928 C,1536,1051,1435,1152,1312,1152 L,768,1152 L,768,1184 C,768,1307,667,1408,544,1408 L,224,1408 C,101,1408,0,1307,0,1184 L,0,224 C,0,101,101,0,224,0 L,1312,0 C,1402,0,1511,52,1568,122 L,1863,485 C,1890,519,1909,561,1909,605 Z" + } + } +} +},{}],13:[function(require,module,exports){ +function IconButton(e,t,n,o){var s={padding:"0.2em 0.4em",margin:"0em",background:"none",outline:"none",fontSize:"16px",border:"none",borderRadius:"0.2em"},i=document.createElement("button");style(i,s);var r=document.createElement("canvas"),a=r.getContext("2d");i.appendChild(r),this.ctx=a,this.dom=i,this.canvas=r;var d=this;this.size=e;var l=1;this.resize=function(){l=window.devicePixelRatio;var n=e,o=font.fonts[t];r.height=n*l,r.style.height=n+"px";var s=n/font.unitsPerEm,i=o.advanceWidth*s+.5|0;i+=2,n+=2,r.width=i*l,r.style.width=i+"px",a.fillStyle=Theme.c,d.draw()},o&&o.on("resize",this.resize),this.setSize=function(t){e=t,this.resize()},this.setIcon=function(e){d.icon=e,font.fonts[e]||console.error("Font icon not found!"),this.resize()},this.onClick=function(e){i.addEventListener("click",e)};var c,h=500;this.onLongHold=function(e){function t(t){t.preventDefault(),t.stopPropagation(),c=setTimeout(function(){c&&e()},h)}function n(){clearTimeout(c)}i.addEventListener("mousedown",t),i.addEventListener("touchstart",t),i.addEventListener("mouseup",n),i.addEventListener("mouseout",n),i.addEventListener("touchend",n)},this.setTip=function(e){n=e};var u={border:"1px solid "+Theme.b},f={border:"1px solid transparent"},v="none",m=(Theme.c,Theme.b);i.style.background=v,style(i,f),i.addEventListener("mouseover",function(){style(i,u),a.fillStyle=Theme.d,a.shadowColor=Theme.b,a.shadowBlur=.5*l,a.shadowOffsetX=1*l,a.shadowOffsetY=1*l,d.draw(),n&&o&&o.fire("status",n)}),i.addEventListener("mousedown",function(){i.style.background=m}),i.addEventListener("mouseup",function(){i.style.background=v,style(i,u)}),i.addEventListener("mouseout",function(){i.style.background=v,style(i,f),d.dropshadow=!1,a.fillStyle=Theme.c,a.shadowColor=null,a.shadowBlur=0,a.shadowOffsetX=0,a.shadowOffsetY=0,d.draw()}),t&&this.setIcon(t)}var font=require("./font.json"),Theme=require("../theme"),style=require("../utils").style,dp;IconButton.prototype.CMD_MAP={M:"moveTo",L:"lineTo",Q:"quadraticCurveTo",C:"bezierCurveTo",Z:"closePath"},IconButton.prototype.draw=function(){if(this.icon){var e=this.ctx,t=font.fonts[this.icon],n=this.size,o=window.devicePixelRatio,s=n/font.unitsPerEm*o,i=t.commands.split(" ");if(e.save(),e.clearRect(0,0,this.canvas.width*o,this.canvas.height*o),this.dropshadow){e.save(),e.fillStyle=Theme.b,e.translate(1.5*o,1.5*o),e.scale(s,-s),e.translate(0,-font.ascender),e.beginPath();for(var r=0,a=i.length;a>r;r++){var d=i[r].split(","),l=d.slice(1);e[this.CMD_MAP[d[0]]].apply(e,l)}e.fill(),e.restore()}e.scale(s,-s),e.translate(0,-font.ascender),e.beginPath();for(var r=0,a=i.length;a>r;r++){var d=i[r].split(","),l=d.slice(1);e[this.CMD_MAP[d[0]]].apply(e,l)}e.fill(),e.restore()}},module.exports=IconButton; +},{"../theme":7,"../utils":11,"./font.json":12}],14:[function(require,module,exports){ +function NumberUI(e){function n(e){e.moved?o():d.focus()}function t(e){var n=e.dx,t=e.dy,i=1*a;h=s+n*i+t*-i,h=Math.max(r,h),c.onChange.fire(h,!0)}function i(e){s=h}function o(){c.onChange.fire(h)}e=e||{};var r=void 0===e.min?-(1/0):e.min,a=e.step||.1,u=e.precision||3,d=document.createElement("input");style(d,{textAlign:"center",fontSize:"10px",padding:"1px",cursor:"ns-resize",width:"40px",margin:0,marginRight:"10px",appearance:"none",outline:"none",border:0,background:"none",borderBottom:"1px dotted "+Theme.c,color:Theme.c});var s,c=this,h=0;this.onChange=new Do,d.addEventListener("change",function(e){h=parseFloat(d.value,10),o()}),handleDrag(d,i,t,n),this.dom=d,this.setValue=function(e){h=e},this.paint=function(){null!=h&&(d.value=h.toFixed(u))}}var Theme=require("../theme"),Do=require("do.js"),style=require("../utils").style,handleDrag=require("../utils").handleDrag;module.exports=NumberUI; +},{"../theme":7,"../utils":11,"do.js":1}],15:[function(require,module,exports){ +function ScrollBar(t,e,o){function r(t){t.preventDefault(),t.target==d?(g=t.clientY,document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",l,!1)):t.clientYm+h&&v.onScroll.fire("pagedown")}function i(t){t.preventDefault();var e=p-h,o=(t.clientY-g)/e;o>1&&(o=1),0>o&&(o=0),v.setPosition(o),v.onScroll.fire("scrollto",o)}function l(t){i(t),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",l,!1)}var n=e?e:12,s=3,a=n+2*s,c=25,u=document.createElement("div");utils.style(u,scrolltrack_style);var p=t-2;u.style.height=p+"px",u.style.width=a+"px";var d=document.createElement("div");utils.style(d,scrollbar_style),d.style.width=n+"px",d.style.height=t/2,d.style.top=0,d.style.left=s+"px",u.appendChild(d);var h,m,v=this;this.setLength=function(t){t=Math.max(Math.min(1,t),0),t*=p,h=Math.max(t,c),d.style.height=h+"px"},this.setHeight=function(e){t=e,p=t-2,u.style.height=p+"px"},this.setPosition=function(t){t=Math.max(Math.min(1,t),0);var e=p-h;m=t*e,d.style.top=m},this.setLength(1),this.setPosition(0),this.onScroll=new SimpleEvent;var g;u.addEventListener("mousedown",r,!1),this.dom=u}var SimpleEvent=require("do.js"),utils=require("../utils"),scrolltrack_style={position:"absolute",background:"-webkit-gradient(linear, left top, right top, color-stop(0, rgb(29,29,29)), color-stop(0.6, rgb(50,50,50)) )",border:"1px solid rgb(29, 29, 29)",textAlign:"center",cursor:"pointer"},scrollbar_style={background:"-webkit-gradient(linear, left top, right top, color-stop(0.2, rgb(88,88,88)), color-stop(0.6, rgb(64,64,64)) )",border:"1px solid rgb(25,25,25)",position:"relative",borderRadius:"6px"};module.exports=ScrollBar; +},{"../utils":11,"do.js":1}]},{},[3,4,5,6,7,8,9,10,11]); diff --git a/three/jsutil/libs/tween.min.js b/three/jsutil/libs/tween.min.js new file mode 100644 index 000000000..90a4463e4 --- /dev/null +++ b/three/jsutil/libs/tween.min.js @@ -0,0 +1,13 @@ +// tween.js - http://github.com/sole/tween.js +'use strict';var TWEEN=TWEEN||function(){var a=[];return{REVISION:"7",getAll:function(){return a},removeAll:function(){a=[]},add:function(c){a.push(c)},remove:function(c){c=a.indexOf(c);-1!==c&&a.splice(c,1)},update:function(c){if(0===a.length)return!1;for(var b=0,d=a.length,c=void 0!==c?c:Date.now();b(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a:0.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a:-0.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a* +a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a*a:0.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return 0.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:1>(a*=2)?0.5*Math.pow(1024,a-1):0.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1- +Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return 1>(a*=2)?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return-(b*Math.pow(2,10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4))},Out:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return b*Math.pow(2,-10*a)*Math.sin((a-c)* +2*Math.PI/0.4)+1},InOut:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return 1>(a*=2)?-0.5*b*Math.pow(2,10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4):0.5*b*Math.pow(2,-10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4)+1}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*(3.5949095*a-2.5949095):0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)}},Bounce:{In:function(a){return 1- +TWEEN.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375},InOut:function(a){return 0.5>a?0.5*TWEEN.Easing.Bounce.In(2*a):0.5*TWEEN.Easing.Bounce.Out(2*a-1)+0.5}}}; +TWEEN.Interpolation={Linear:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),f=TWEEN.Interpolation.Utils.Linear;return 0>c?f(a[0],a[1],d):1b?b:e+1],d-e)},Bezier:function(a,c){var b=0,d=a.length-1,e=Math.pow,f=TWEEN.Interpolation.Utils.Bernstein,h;for(h=0;h<=d;h++)b+=e(1-c,d-h)*e(c,h)*a[h]*f(d,h);return b},CatmullRom:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),f=TWEEN.Interpolation.Utils.CatmullRom;return a[0]===a[b]?(0>c&&(e=Math.floor(d=b*(1+c))),f(a[(e- +1+b)%b],a[e],a[(e+1)%b],a[(e+2)%b],d-e)):0>c?a[0]-(f(a[0],a[0],a[1],a[1],-d)-a[0]):1, + * linewidth: , + * dashed: , + * dashScale: , + * dashSize: , + * gapSize: , + * resolution: , // to be set by renderer + * } + */ + +THREE.UniformsLib.line = { + + linewidth: { value: 1 }, + resolution: { value: new THREE.Vector2( 1, 1 ) }, + dashScale: { value: 1 }, + dashSize: { value: 1 }, + gapSize: { value: 1 } // todo FIX - maybe change to totalSize + +}; + +THREE.ShaderLib[ 'line' ] = { + + uniforms: THREE.UniformsUtils.merge( [ + THREE.UniformsLib.common, + THREE.UniformsLib.fog, + THREE.UniformsLib.line + ] ), + + vertexShader: + ` + #include + #include + #include + #include + #include + + uniform float linewidth; + uniform vec2 resolution; + + attribute vec3 instanceStart; + attribute vec3 instanceEnd; + + attribute vec3 instanceColorStart; + attribute vec3 instanceColorEnd; + + varying vec2 vUv; + + #ifdef USE_DASH + + uniform float dashScale; + attribute float instanceDistanceStart; + attribute float instanceDistanceEnd; + varying float vLineDistance; + + #endif + + void trimSegment( const in vec4 start, inout vec4 end ) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column + float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column + float nearEstimate = - 0.5 * b / a; + + float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); + + end.xyz = mix( start.xyz, end.xyz, alpha ); + + } + + void main() { + + #ifdef USE_COLOR + + vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; + + #endif + + #ifdef USE_DASH + + vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; + + #endif + + float aspect = resolution.x / resolution.y; + + vUv = uv; + + // camera space + vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); + vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column + + if ( perspective ) { + + if ( start.z < 0.0 && end.z >= 0.0 ) { + + trimSegment( start, end ); + + } else if ( end.z < 0.0 && start.z >= 0.0 ) { + + trimSegment( end, start ); + + } + + } + + // clip space + vec4 clipStart = projectionMatrix * start; + vec4 clipEnd = projectionMatrix * end; + + // ndc space + vec2 ndcStart = clipStart.xy / clipStart.w; + vec2 ndcEnd = clipEnd.xy / clipEnd.w; + + // direction + vec2 dir = ndcEnd - ndcStart; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize( dir ); + + // perpendicular to dir + vec2 offset = vec2( dir.y, - dir.x ); + + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + // endcaps + if ( position.y < 0.0 ) { + + offset += - dir; + + } else if ( position.y > 1.0 ) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + gl_Position = clip; + + vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation + + #include + #include + #include + + } + `, + + fragmentShader: + ` + uniform vec3 diffuse; + uniform float opacity; + + #ifdef USE_DASH + + uniform float dashSize; + uniform float gapSize; + + #endif + + varying float vLineDistance; + + #include + #include + #include + #include + #include + + varying vec2 vUv; + + void main() { + + #include + + #ifdef USE_DASH + + if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps + + if ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX + + #endif + + if ( abs( vUv.y ) > 1.0 ) { + + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + + if ( len2 > 1.0 ) discard; + + } + + vec4 diffuseColor = vec4( diffuse, opacity ); + + #include + #include + + gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a ); + + #include + #include + #include + #include + + } + ` +}; + +THREE.LineMaterial = function ( parameters ) { + + THREE.ShaderMaterial.call( this, { + + type: 'LineMaterial', + + uniforms: THREE.UniformsUtils.clone( THREE.ShaderLib[ 'line' ].uniforms ), + + vertexShader: THREE.ShaderLib[ 'line' ].vertexShader, + fragmentShader: THREE.ShaderLib[ 'line' ].fragmentShader + + } ); + + this.dashed = false; + + Object.defineProperties( this, { + + color: { + + enumerable: true, + + get: function () { + + return this.uniforms.diffuse.value; + + }, + + set: function ( value ) { + + this.uniforms.diffuse.value = value; + + } + + }, + + linewidth: { + + enumerable: true, + + get: function () { + + return this.uniforms.linewidth.value; + + }, + + set: function ( value ) { + + this.uniforms.linewidth.value = value; + + } + + }, + + dashScale: { + + enumerable: true, + + get: function () { + + return this.uniforms.dashScale.value; + + }, + + set: function ( value ) { + + this.uniforms.dashScale.value = value; + + } + + }, + + dashSize: { + + enumerable: true, + + get: function () { + + return this.uniforms.dashSize.value; + + }, + + set: function ( value ) { + + this.uniforms.dashSize.value = value; + + } + + }, + + gapSize: { + + enumerable: true, + + get: function () { + + return this.uniforms.gapSize.value; + + }, + + set: function ( value ) { + + this.uniforms.gapSize.value = value; + + } + + }, + + resolution: { + + enumerable: true, + + get: function () { + + return this.uniforms.resolution.value; + + }, + + set: function ( value ) { + + this.uniforms.resolution.value.copy( value ); + + } + + } + + } ); + + this.setValues( parameters ); + +}; + +THREE.LineMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype ); +THREE.LineMaterial.prototype.constructor = THREE.LineMaterial; + +THREE.LineMaterial.prototype.isLineMaterial = true; + +THREE.LineMaterial.prototype.copy = function ( source ) { + + THREE.ShaderMaterial.prototype.copy.call( this, source ); + + this.color.copy( source.color ); + + this.linewidth = source.linewidth; + + this.resolution = source.resolution; + + // todo + + return this; + +}; + diff --git a/three/jsutil/lines/LineSegments2.js b/three/jsutil/lines/LineSegments2.js new file mode 100644 index 000000000..8f444438a --- /dev/null +++ b/three/jsutil/lines/LineSegments2.js @@ -0,0 +1,65 @@ +/** + * @author WestLangley / http://github.com/WestLangley + * + */ + +THREE.LineSegments2 = function ( geometry, material ) { + + THREE.Mesh.call( this ); + + this.type = 'LineSegments2'; + + this.geometry = geometry !== undefined ? geometry : new THREE.LineSegmentsGeometry(); + this.material = material !== undefined ? material : new THREE.LineMaterial( { color: Math.random() * 0xffffff } ); + +}; + +THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), { + + constructor: THREE.LineSegments2, + + isLineSegments2: true, + + computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry... + + var start = new THREE.Vector3(); + var end = new THREE.Vector3(); + + return function computeLineDistances() { + + var geometry = this.geometry; + + var instanceStart = geometry.attributes.instanceStart; + var instanceEnd = geometry.attributes.instanceEnd; + var lineDistances = new Float32Array( 2 * instanceStart.data.count ); + + for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) { + + start.fromBufferAttribute( instanceStart, i ); + end.fromBufferAttribute( instanceEnd, i ); + + lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ]; + lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end ); + + } + + var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1 + + geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0 + geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1 + + return this; + + }; + + }() ), + + copy: function ( source ) { + + // todo + + return this; + + } + +} ); diff --git a/three/jsutil/lines/LineSegmentsGeometry.js b/three/jsutil/lines/LineSegmentsGeometry.js new file mode 100644 index 000000000..e34a6e4c4 --- /dev/null +++ b/three/jsutil/lines/LineSegmentsGeometry.js @@ -0,0 +1,260 @@ +/** + * @author WestLangley / http://github.com/WestLangley + * + */ + +THREE.LineSegmentsGeometry = function () { + + THREE.InstancedBufferGeometry.call( this ); + + this.type = 'LineSegmentsGeometry'; + + var plane = new THREE.BufferGeometry(); + + var positions = [ - 1, 2, 0, 1, 2, 0, - 1, 1, 0, 1, 1, 0, - 1, 0, 0, 1, 0, 0, - 1, - 1, 0, 1, - 1, 0 ]; + var uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ]; + var index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ]; + + this.setIndex( index ); + this.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + this.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + +}; + +THREE.LineSegmentsGeometry.prototype = Object.assign( Object.create( THREE.InstancedBufferGeometry.prototype ), { + + constructor: THREE.LineSegmentsGeometry, + + isLineSegmentsGeometry: true, + + applyMatrix: function ( matrix ) { + + var start = this.attributes.instanceStart; + var end = this.attributes.instanceEnd; + + if ( start !== undefined ) { + + matrix.applyToBufferAttribute( start ); + + matrix.applyToBufferAttribute( end ); + + start.data.needsUpdate = true; + + } + + if ( this.boundingBox !== null ) { + + this.computeBoundingBox(); + + } + + if ( this.boundingSphere !== null ) { + + this.computeBoundingSphere(); + + } + + return this; + + }, + + setPositions: function ( array ) { + + var lineSegments; + + if ( array instanceof Float32Array ) { + + lineSegments = array; + + } else if ( Array.isArray( array ) ) { + + lineSegments = new Float32Array( array ); + + } + + var instanceBuffer = new THREE.InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz + + this.addAttribute( 'instanceStart', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz + this.addAttribute( 'instanceEnd', new THREE.InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz + + // + + this.computeBoundingBox(); + this.computeBoundingSphere(); + + return this; + + }, + + setColors: function ( array ) { + + var colors; + + if ( array instanceof Float32Array ) { + + colors = array; + + } else if ( Array.isArray( array ) ) { + + colors = new Float32Array( array ); + + } + + var instanceColorBuffer = new THREE.InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb + + this.addAttribute( 'instanceColorStart', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb + this.addAttribute( 'instanceColorEnd', new THREE.InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb + + return this; + + }, + + fromWireframeGeometry: function ( geometry ) { + + this.setPositions( geometry.attributes.position.array ); + + return this; + + }, + + fromEdgesGeometry: function ( geometry ) { + + this.setPositions( geometry.attributes.position.array ); + + return this; + + }, + + fromMesh: function ( mesh ) { + + this.fromWireframeGeometry( new THREE.WireframeGeometry( mesh.geometry ) ); + + // set colors, maybe + + return this; + + }, + + fromLineSegements: function ( lineSegments ) { + + var geometry = lineSegments.geometry; + + if ( geometry.isGeometry ) { + + this.setPositions( geometry.vertices ); + + } else if ( geometry.isBufferGeometry ) { + + this.setPositions( geometry.position.array ); // assumes non-indexed + + } + + // set colors, maybe + + return this; + + }, + + computeBoundingBox: function () { + + var box = new THREE.Box3(); + + return function computeBoundingBox() { + + if ( this.boundingBox === null ) { + + this.boundingBox = new THREE.Box3(); + + } + + var start = this.attributes.instanceStart; + var end = this.attributes.instanceEnd; + + if ( start !== undefined && end !== undefined ) { + + this.boundingBox.setFromBufferAttribute( start ); + + box.setFromBufferAttribute( end ); + + this.boundingBox.union( box ); + + } + + }; + + }(), + + computeBoundingSphere: function () { + + var vector = new THREE.Vector3(); + + return function computeBoundingSphere() { + + if ( this.boundingSphere === null ) { + + this.boundingSphere = new THREE.Sphere(); + + } + + if ( this.boundingBox === null ) { + + this.computeBoundingBox(); + + } + + var start = this.attributes.instanceStart; + var end = this.attributes.instanceEnd; + + if ( start !== undefined && end !== undefined ) { + + var center = this.boundingSphere.center; + + this.boundingBox.getCenter( center ); + + var maxRadiusSq = 0; + + for ( var i = 0, il = start.count; i < il; i ++ ) { + + vector.fromBufferAttribute( start, i ); + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + + vector.fromBufferAttribute( end, i ); + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + + } + + this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); + + if ( isNaN( this.boundingSphere.radius ) ) { + + console.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this ); + + } + + } + + }; + + }(), + + toJSON: function () { + + // todo + + }, + + clone: function () { + + // todo + + }, + + copy: function ( source ) { + + // todo + + return this; + + } + +} ); diff --git a/three/jsutil/lines/Wireframe.js b/three/jsutil/lines/Wireframe.js new file mode 100644 index 000000000..9f582cf33 --- /dev/null +++ b/three/jsutil/lines/Wireframe.js @@ -0,0 +1,65 @@ +/** + * @author WestLangley / http://github.com/WestLangley + * + */ + +THREE.Wireframe = function ( geometry, material ) { + + THREE.Mesh.call( this ); + + this.type = 'Wireframe'; + + this.geometry = geometry !== undefined ? geometry : new THREE.LineSegmentsGeometry(); + this.material = material !== undefined ? material : new THREE.LineMaterial( { color: Math.random() * 0xffffff } ); + +}; + +THREE.Wireframe.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), { + + constructor: THREE.Wireframe, + + isWireframe: true, + + computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry... + + var start = new THREE.Vector3(); + var end = new THREE.Vector3(); + + return function computeLineDistances() { + + var geometry = this.geometry; + + var instanceStart = geometry.attributes.instanceStart; + var instanceEnd = geometry.attributes.instanceEnd; + var lineDistances = new Float32Array( 2 * instanceStart.data.count ); + + for ( var i = 0, j = 0, l = instanceStart.data.count; i < l; i ++, j += 2 ) { + + start.fromBufferAttribute( instanceStart, i ); + end.fromBufferAttribute( instanceEnd, i ); + + lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ]; + lineDistances[ j + 1 ] = lineDistances[ j ] + start.distanceTo( end ); + + } + + var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1 + + geometry.addAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0 + geometry.addAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1 + + return this; + + }; + + }() ), + + copy: function ( source ) { + + // todo + + return this; + + } + +} ); diff --git a/three/jsutil/lines/WireframeGeometry2.js b/three/jsutil/lines/WireframeGeometry2.js new file mode 100644 index 000000000..50f153698 --- /dev/null +++ b/three/jsutil/lines/WireframeGeometry2.js @@ -0,0 +1,32 @@ +/** + * @author WestLangley / http://github.com/WestLangley + * + */ + +THREE.WireframeGeometry2 = function ( geometry ) { + + THREE.LineSegmentsGeometry.call( this ); + + this.type = 'WireframeGeometry2'; + + this.fromWireframeGeometry( new THREE.WireframeGeometry( geometry ) ); + + // set colors, maybe + +}; + +THREE.WireframeGeometry2.prototype = Object.assign( Object.create( THREE.LineSegmentsGeometry.prototype ), { + + constructor: THREE.WireframeGeometry2, + + isWireframeGeometry2: true, + + copy: function ( source ) { + + // todo + + return this; + + } + +} ); diff --git a/three/jsutil/loaders/3MFLoader.js b/three/jsutil/loaders/3MFLoader.js new file mode 100644 index 000000000..31ce4066f --- /dev/null +++ b/three/jsutil/loaders/3MFLoader.js @@ -0,0 +1,614 @@ +/** + * @author technohippy / https://github.com/technohippy + */ + +THREE.ThreeMFLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.availableExtensions = []; + +}; + +THREE.ThreeMFLoader.prototype = { + + constructor: THREE.ThreeMFLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( buffer ) { + + onLoad( scope.parse( buffer ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + var scope = this; + + function loadDocument( data ) { + + var zip = null; + var file = null; + + var relsName; + var modelPartNames = []; + var printTicketPartNames = []; + var texturesPartNames = []; + var otherPartNames = []; + + var rels; + var modelParts = {}; + var printTicketParts = {}; + var texturesParts = {}; + var otherParts = {}; + + try { + + zip = new JSZip( data ); // eslint-disable-line no-undef + + } catch ( e ) { + + if ( e instanceof ReferenceError ) { + + console.error( 'THREE.ThreeMFLoader: jszip missing and file is compressed.' ); + return null; + + } + + } + + for ( file in zip.files ) { + + if ( file.match( /\.rels$/ ) ) { + + relsName = file; + + } else if ( file.match( /^3D\/.*\.model$/ ) ) { + + modelPartNames.push( file ); + + } else if ( file.match( /^3D\/Metadata\/.*\.xml$/ ) ) { + + printTicketPartNames.push( file ); + + } else if ( file.match( /^3D\/Textures\/.*/ ) ) { + + texturesPartNames.push( file ); + + } else if ( file.match( /^3D\/Other\/.*/ ) ) { + + otherPartNames.push( file ); + + } + + } + + var relsView = new Uint8Array( zip.file( relsName ).asArrayBuffer() ); + var relsFileText = THREE.LoaderUtils.decodeText( relsView ); + rels = parseRelsXml( relsFileText ); + + for ( var i = 0; i < modelPartNames.length; i ++ ) { + + var modelPart = modelPartNames[ i ]; + var view = new Uint8Array( zip.file( modelPart ).asArrayBuffer() ); + + var fileText = THREE.LoaderUtils.decodeText( view ); + var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' ); + + if ( xmlData.documentElement.nodeName.toLowerCase() !== 'model' ) { + + console.error( 'THREE.ThreeMFLoader: Error loading 3MF - no 3MF document found: ', modelPart ); + + } + + var modelNode = xmlData.querySelector( 'model' ); + var extensions = {}; + + for ( var i = 0; i < modelNode.attributes.length; i ++ ) { + + var attr = modelNode.attributes[ i ]; + if ( attr.name.match( /^xmlns:(.+)$/ ) ) { + + extensions[ attr.value ] = RegExp.$1; + + } + + } + + var modelData = parseModelNode( modelNode ); + modelData[ 'xml' ] = modelNode; + + if ( 0 < Object.keys( extensions ).length ) { + + modelData[ 'extensions' ] = extensions; + + } + + modelParts[ modelPart ] = modelData; + + } + + for ( var i = 0; i < texturesPartNames.length; i ++ ) { + + var texturesPartName = texturesPartNames[ i ]; + texturesParts[ texturesPartName ] = zip.file( texturesPartName ).asBinary(); + + } + + return { + rels: rels, + model: modelParts, + printTicket: printTicketParts, + texture: texturesParts, + other: otherParts + }; + + } + + function parseRelsXml( relsFileText ) { + + var relsXmlData = new DOMParser().parseFromString( relsFileText, 'application/xml' ); + var relsNode = relsXmlData.querySelector( 'Relationship' ); + var target = relsNode.getAttribute( 'Target' ); + var id = relsNode.getAttribute( 'Id' ); + var type = relsNode.getAttribute( 'Type' ); + + return { + target: target, + id: id, + type: type + }; + + } + + function parseMetadataNodes( metadataNodes ) { + + var metadataData = {}; + + for ( var i = 0; i < metadataNodes.length; i ++ ) { + + var metadataNode = metadataNodes[ i ]; + var name = metadataNode.getAttribute( 'name' ); + var validNames = [ + 'Title', + 'Designer', + 'Description', + 'Copyright', + 'LicenseTerms', + 'Rating', + 'CreationDate', + 'ModificationDate' + ]; + + if ( 0 <= validNames.indexOf( name ) ) { + + metadataData[ name ] = metadataNode.textContent; + + } + + } + + return metadataData; + + } + + function parseBasematerialsNode( basematerialsNode ) { + } + + function parseMeshNode( meshNode, extensions ) { + + var meshData = {}; + + var vertices = []; + var vertexNodes = meshNode.querySelectorAll( 'vertices vertex' ); + + for ( var i = 0; i < vertexNodes.length; i ++ ) { + + var vertexNode = vertexNodes[ i ]; + var x = vertexNode.getAttribute( 'x' ); + var y = vertexNode.getAttribute( 'y' ); + var z = vertexNode.getAttribute( 'z' ); + + vertices.push( parseFloat( x ), parseFloat( y ), parseFloat( z ) ); + + } + + meshData[ 'vertices' ] = new Float32Array( vertices.length ); + + for ( var i = 0; i < vertices.length; i ++ ) { + + meshData[ 'vertices' ][ i ] = vertices[ i ]; + + } + + var triangleProperties = []; + var triangles = []; + var triangleNodes = meshNode.querySelectorAll( 'triangles triangle' ); + + for ( var i = 0; i < triangleNodes.length; i ++ ) { + + var triangleNode = triangleNodes[ i ]; + var v1 = triangleNode.getAttribute( 'v1' ); + var v2 = triangleNode.getAttribute( 'v2' ); + var v3 = triangleNode.getAttribute( 'v3' ); + var p1 = triangleNode.getAttribute( 'p1' ); + var p2 = triangleNode.getAttribute( 'p2' ); + var p3 = triangleNode.getAttribute( 'p3' ); + var pid = triangleNode.getAttribute( 'pid' ); + + triangles.push( parseInt( v1, 10 ), parseInt( v2, 10 ), parseInt( v3, 10 ) ); + + var triangleProperty = {}; + + if ( p1 ) { + + triangleProperty[ 'p1' ] = parseInt( p1, 10 ); + + } + + if ( p2 ) { + + triangleProperty[ 'p2' ] = parseInt( p2, 10 ); + + } + + if ( p3 ) { + + triangleProperty[ 'p3' ] = parseInt( p3, 10 ); + + } + + if ( pid ) { + + triangleProperty[ 'pid' ] = pid; + + } + + if ( 0 < Object.keys( triangleProperty ).length ) { + + triangleProperties.push( triangleProperty ); + + } + + } + + meshData[ 'triangleProperties' ] = triangleProperties; + meshData[ 'triangles' ] = new Uint32Array( triangles.length ); + + for ( var i = 0; i < triangles.length; i ++ ) { + + meshData[ 'triangles' ][ i ] = triangles[ i ]; + + } + + return meshData; + + } + + function parseComponentsNode( componentsNode ) { + + } + + function parseObjectNode( objectNode ) { + + var objectData = { + type: objectNode.getAttribute( 'type' ) + }; + + var id = objectNode.getAttribute( 'id' ); + + if ( id ) { + + objectData[ 'id' ] = id; + + } + + var pid = objectNode.getAttribute( 'pid' ); + + if ( pid ) { + + objectData[ 'pid' ] = pid; + + } + + var pindex = objectNode.getAttribute( 'pindex' ); + + if ( pindex ) { + + objectData[ 'pindex' ] = pindex; + + } + + var thumbnail = objectNode.getAttribute( 'thumbnail' ); + + if ( thumbnail ) { + + objectData[ 'thumbnail' ] = thumbnail; + + } + + var partnumber = objectNode.getAttribute( 'partnumber' ); + + if ( partnumber ) { + + objectData[ 'partnumber' ] = partnumber; + + } + + var name = objectNode.getAttribute( 'name' ); + + if ( name ) { + + objectData[ 'name' ] = name; + + } + + var meshNode = objectNode.querySelector( 'mesh' ); + + if ( meshNode ) { + + objectData[ 'mesh' ] = parseMeshNode( meshNode ); + + } + + var componentsNode = objectNode.querySelector( 'components' ); + + if ( componentsNode ) { + + objectData[ 'components' ] = parseComponentsNode( componentsNode ); + + } + + return objectData; + + } + + function parseResourcesNode( resourcesNode ) { + + var resourcesData = {}; + var basematerialsNode = resourcesNode.querySelector( 'basematerials' ); + + if ( basematerialsNode ) { + + resourcesData[ 'basematerial' ] = parseBasematerialsNode( basematerialsNode ); + + } + + resourcesData[ 'object' ] = {}; + var objectNodes = resourcesNode.querySelectorAll( 'object' ); + + for ( var i = 0; i < objectNodes.length; i ++ ) { + + var objectNode = objectNodes[ i ]; + var objectData = parseObjectNode( objectNode ); + resourcesData[ 'object' ][ objectData[ 'id' ] ] = objectData; + + } + + return resourcesData; + + } + + function parseBuildNode( buildNode ) { + + var buildData = []; + var itemNodes = buildNode.querySelectorAll( 'item' ); + + for ( var i = 0; i < itemNodes.length; i ++ ) { + + var itemNode = itemNodes[ i ]; + var buildItem = { + objectid: itemNode.getAttribute( 'objectid' ) + }; + var transform = itemNode.getAttribute( 'transform' ); + + if ( transform ) { + + var t = []; + transform.split( ' ' ).forEach( function ( s ) { + + t.push( parseFloat( s ) ); + + } ); + var mat4 = new THREE.Matrix4(); + buildItem[ 'transform' ] = mat4.set( + t[ 0 ], t[ 3 ], t[ 6 ], t[ 9 ], + t[ 1 ], t[ 4 ], t[ 7 ], t[ 10 ], + t[ 2 ], t[ 5 ], t[ 8 ], t[ 11 ], + 0.0, 0.0, 0.0, 1.0 + ); + + } + + buildData.push( buildItem ); + + } + + return buildData; + + } + + function parseModelNode( modelNode ) { + + var modelData = { unit: modelNode.getAttribute( 'unit' ) || 'millimeter' }; + var metadataNodes = modelNode.querySelectorAll( 'metadata' ); + + if ( metadataNodes ) { + + modelData[ 'metadata' ] = parseMetadataNodes( metadataNodes ); + + } + + var resourcesNode = modelNode.querySelector( 'resources' ); + + if ( resourcesNode ) { + + modelData[ 'resources' ] = parseResourcesNode( resourcesNode ); + + } + + var buildNode = modelNode.querySelector( 'build' ); + + if ( buildNode ) { + + modelData[ 'build' ] = parseBuildNode( buildNode ); + + } + + return modelData; + + } + + function buildMesh( meshData, data3mf ) { + + var geometry = new THREE.BufferGeometry(); + geometry.setIndex( new THREE.BufferAttribute( meshData[ 'triangles' ], 1 ) ); + geometry.addAttribute( 'position', new THREE.BufferAttribute( meshData[ 'vertices' ], 3 ) ); + + if ( meshData[ 'colors' ] ) { + + geometry.addAttribute( 'color', new THREE.BufferAttribute( meshData[ 'colors' ], 3 ) ); + + } + + geometry.computeBoundingSphere(); + + var materialOpts = { + flatShading: true + }; + + if ( meshData[ 'colors' ] && 0 < meshData[ 'colors' ].length ) { + + materialOpts[ 'vertexColors' ] = THREE.VertexColors; + + } else { + + materialOpts[ 'color' ] = 0xaaaaff; + + } + + var material = new THREE.MeshPhongMaterial( materialOpts ); + return new THREE.Mesh( geometry, material ); + + } + + function applyExtensions( extensions, meshData, modelXml, data3mf ) { + + if ( ! extensions ) { + + return; + + } + + var availableExtensions = []; + var keys = Object.keys( extensions ); + + for ( var i = 0; i < keys.length; i ++ ) { + + var ns = keys[ i ]; + + for ( var j = 0; j < scope.availableExtensions.length; j ++ ) { + + var extension = scope.availableExtensions[ j ]; + + if ( extension.ns === ns ) { + + availableExtensions.push( extension ); + + } + + } + + } + + for ( var i = 0; i < availableExtensions.length; i ++ ) { + + var extension = availableExtensions[ i ]; + extension.apply( modelXml, extensions[ extension[ 'ns' ] ], meshData ); + + } + + } + + function buildMeshes( data3mf ) { + + var modelsData = data3mf.model; + var meshes = {}; + var modelsKeys = Object.keys( modelsData ); + + for ( var i = 0; i < modelsKeys.length; i ++ ) { + + var modelsKey = modelsKeys[ i ]; + var modelData = modelsData[ modelsKey ]; + var modelXml = modelData[ 'xml' ]; + var extensions = modelData[ 'extensions' ]; + + var objectIds = Object.keys( modelData[ 'resources' ][ 'object' ] ); + + for ( var j = 0; j < objectIds.length; j ++ ) { + + var objectId = objectIds[ j ]; + var objectData = modelData[ 'resources' ][ 'object' ][ objectId ]; + var meshData = objectData[ 'mesh' ]; + applyExtensions( extensions, meshData, modelXml, data3mf ); + meshes[ objectId ] = buildMesh( meshData, data3mf ); + + } + + } + + return meshes; + + } + + function build( meshes, refs, data3mf ) { + + var group = new THREE.Group(); + var buildData = data3mf.model[ refs[ 'target' ].substring( 1 ) ][ 'build' ]; + + for ( var i = 0; i < buildData.length; i ++ ) { + + var buildItem = buildData[ i ]; + var mesh = meshes[ buildItem[ 'objectid' ] ]; + + if ( buildItem[ 'transform' ] ) { + + mesh.geometry.applyMatrix( buildItem[ 'transform' ] ); + + } + + group.add( mesh ); + + } + + return group; + + } + + var data3mf = loadDocument( data ); + var meshes = buildMeshes( data3mf ); + + return build( meshes, data3mf[ 'rels' ], data3mf ); + + }, + + addExtension: function ( extension ) { + + this.availableExtensions.push( extension ); + + } + +}; diff --git a/three/jsutil/loaders/AMFLoader.js b/three/jsutil/loaders/AMFLoader.js new file mode 100644 index 000000000..55ef7cd3b --- /dev/null +++ b/three/jsutil/loaders/AMFLoader.js @@ -0,0 +1,495 @@ +/* + * @author tamarintech / https://tamarintech.com + * + * Description: Early release of an AMF Loader following the pattern of the + * example loaders in the three.js project. + * + * More information about the AMF format: http://amf.wikispaces.com + * + * Usage: + * var loader = new AMFLoader(); + * loader.load('/path/to/project.amf', function(objecttree) { + * scene.add(objecttree); + * }); + * + * Materials now supported, material colors supported + * Zip support, requires jszip + * No constellation support (yet)! + * + */ + +THREE.AMFLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.AMFLoader.prototype = { + + constructor: THREE.AMFLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + function loadDocument( data ) { + + var view = new DataView( data ); + var magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) ); + + if ( magic === 'PK' ) { + + var zip = null; + var file = null; + + console.log( 'THREE.AMFLoader: Loading Zip' ); + + try { + + zip = new JSZip( data ); // eslint-disable-line no-undef + + } catch ( e ) { + + if ( e instanceof ReferenceError ) { + + console.log( 'THREE.AMFLoader: jszip missing and file is compressed.' ); + return null; + + } + + } + + for ( file in zip.files ) { + + if ( file.toLowerCase().substr( - 4 ) === '.amf' ) { + + break; + + } + + } + + console.log( 'THREE.AMFLoader: Trying to load file asset: ' + file ); + view = new DataView( zip.file( file ).asArrayBuffer() ); + + } + + var fileText = THREE.LoaderUtils.decodeText( view ); + var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' ); + + if ( xmlData.documentElement.nodeName.toLowerCase() !== 'amf' ) { + + console.log( 'THREE.AMFLoader: Error loading AMF - no AMF document found.' ); + return null; + + } + + return xmlData; + + } + + function loadDocumentScale( node ) { + + var scale = 1.0; + var unit = 'millimeter'; + + if ( node.documentElement.attributes.unit !== undefined ) { + + unit = node.documentElement.attributes.unit.value.toLowerCase(); + + } + + var scaleUnits = { + millimeter: 1.0, + inch: 25.4, + feet: 304.8, + meter: 1000.0, + micron: 0.001 + }; + + if ( scaleUnits[ unit ] !== undefined ) { + + scale = scaleUnits[ unit ]; + + } + + console.log( 'THREE.AMFLoader: Unit scale: ' + scale ); + return scale; + + } + + function loadMaterials( node ) { + + var matName = 'AMF Material'; + var matId = node.attributes.id.textContent; + var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 }; + + var loadedMaterial = null; + + for ( var i = 0; i < node.childNodes.length; i ++ ) { + + var matChildEl = node.childNodes[ i ]; + + if ( matChildEl.nodeName === 'metadata' && matChildEl.attributes.type !== undefined ) { + + if ( matChildEl.attributes.type.value === 'name' ) { + + matName = matChildEl.textContent; + + } + + } else if ( matChildEl.nodeName === 'color' ) { + + color = loadColor( matChildEl ); + + } + + } + + loadedMaterial = new THREE.MeshPhongMaterial( { + flatShading: true, + color: new THREE.Color( color.r, color.g, color.b ), + name: matName + } ); + + if ( color.a !== 1.0 ) { + + loadedMaterial.transparent = true; + loadedMaterial.opacity = color.a; + + } + + return { id: matId, material: loadedMaterial }; + + } + + function loadColor( node ) { + + var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 }; + + for ( var i = 0; i < node.childNodes.length; i ++ ) { + + var matColor = node.childNodes[ i ]; + + if ( matColor.nodeName === 'r' ) { + + color.r = matColor.textContent; + + } else if ( matColor.nodeName === 'g' ) { + + color.g = matColor.textContent; + + } else if ( matColor.nodeName === 'b' ) { + + color.b = matColor.textContent; + + } else if ( matColor.nodeName === 'a' ) { + + color.a = matColor.textContent; + + } + + } + + return color; + + } + + function loadMeshVolume( node ) { + + var volume = { name: '', triangles: [], materialid: null }; + + var currVolumeNode = node.firstElementChild; + + if ( node.attributes.materialid !== undefined ) { + + volume.materialId = node.attributes.materialid.nodeValue; + + } + + while ( currVolumeNode ) { + + if ( currVolumeNode.nodeName === 'metadata' ) { + + if ( currVolumeNode.attributes.type !== undefined ) { + + if ( currVolumeNode.attributes.type.value === 'name' ) { + + volume.name = currVolumeNode.textContent; + + } + + } + + } else if ( currVolumeNode.nodeName === 'triangle' ) { + + var v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent; + var v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent; + var v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent; + + volume.triangles.push( v1, v2, v3 ); + + } + + currVolumeNode = currVolumeNode.nextElementSibling; + + } + + return volume; + + } + + function loadMeshVertices( node ) { + + var vertArray = []; + var normalArray = []; + var currVerticesNode = node.firstElementChild; + + while ( currVerticesNode ) { + + if ( currVerticesNode.nodeName === 'vertex' ) { + + var vNode = currVerticesNode.firstElementChild; + + while ( vNode ) { + + if ( vNode.nodeName === 'coordinates' ) { + + var x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent; + var y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent; + var z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent; + + vertArray.push( x, y, z ); + + } else if ( vNode.nodeName === 'normal' ) { + + var nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent; + var ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent; + var nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent; + + normalArray.push( nx, ny, nz ); + + } + + vNode = vNode.nextElementSibling; + + } + + } + currVerticesNode = currVerticesNode.nextElementSibling; + + } + + return { 'vertices': vertArray, 'normals': normalArray }; + + } + + function loadObject( node ) { + + var objId = node.attributes.id.textContent; + var loadedObject = { name: 'amfobject', meshes: [] }; + var currColor = null; + var currObjNode = node.firstElementChild; + + while ( currObjNode ) { + + if ( currObjNode.nodeName === 'metadata' ) { + + if ( currObjNode.attributes.type !== undefined ) { + + if ( currObjNode.attributes.type.value === 'name' ) { + + loadedObject.name = currObjNode.textContent; + + } + + } + + } else if ( currObjNode.nodeName === 'color' ) { + + currColor = loadColor( currObjNode ); + + } else if ( currObjNode.nodeName === 'mesh' ) { + + var currMeshNode = currObjNode.firstElementChild; + var mesh = { vertices: [], normals: [], volumes: [], color: currColor }; + + while ( currMeshNode ) { + + if ( currMeshNode.nodeName === 'vertices' ) { + + var loadedVertices = loadMeshVertices( currMeshNode ); + + mesh.normals = mesh.normals.concat( loadedVertices.normals ); + mesh.vertices = mesh.vertices.concat( loadedVertices.vertices ); + + } else if ( currMeshNode.nodeName === 'volume' ) { + + mesh.volumes.push( loadMeshVolume( currMeshNode ) ); + + } + + currMeshNode = currMeshNode.nextElementSibling; + + } + + loadedObject.meshes.push( mesh ); + + } + + currObjNode = currObjNode.nextElementSibling; + + } + + return { 'id': objId, 'obj': loadedObject }; + + } + + var xmlData = loadDocument( data ); + var amfName = ''; + var amfAuthor = ''; + var amfScale = loadDocumentScale( xmlData ); + var amfMaterials = {}; + var amfObjects = {}; + var childNodes = xmlData.documentElement.childNodes; + + var i, j; + + for ( i = 0; i < childNodes.length; i ++ ) { + + var child = childNodes[ i ]; + + if ( child.nodeName === 'metadata' ) { + + if ( child.attributes.type !== undefined ) { + + if ( child.attributes.type.value === 'name' ) { + + amfName = child.textContent; + + } else if ( child.attributes.type.value === 'author' ) { + + amfAuthor = child.textContent; + + } + + } + + } else if ( child.nodeName === 'material' ) { + + var loadedMaterial = loadMaterials( child ); + + amfMaterials[ loadedMaterial.id ] = loadedMaterial.material; + + } else if ( child.nodeName === 'object' ) { + + var loadedObject = loadObject( child ); + + amfObjects[ loadedObject.id ] = loadedObject.obj; + + } + + } + + var sceneObject = new THREE.Group(); + var defaultMaterial = new THREE.MeshPhongMaterial( { color: 0xaaaaff, flatShading: true } ); + + sceneObject.name = amfName; + sceneObject.userData.author = amfAuthor; + sceneObject.userData.loader = 'AMF'; + + for ( var id in amfObjects ) { + + var part = amfObjects[ id ]; + var meshes = part.meshes; + var newObject = new THREE.Group(); + newObject.name = part.name || ''; + + for ( i = 0; i < meshes.length; i ++ ) { + + var objDefaultMaterial = defaultMaterial; + var mesh = meshes[ i ]; + var vertices = new THREE.Float32BufferAttribute( mesh.vertices, 3 ); + var normals = null; + + if ( mesh.normals.length ) { + + normals = new THREE.Float32BufferAttribute( mesh.normals, 3 ); + + } + + if ( mesh.color ) { + + var color = mesh.color; + + objDefaultMaterial = defaultMaterial.clone(); + objDefaultMaterial.color = new THREE.Color( color.r, color.g, color.b ); + + if ( color.a !== 1.0 ) { + + objDefaultMaterial.transparent = true; + objDefaultMaterial.opacity = color.a; + + } + + } + + var volumes = mesh.volumes; + + for ( j = 0; j < volumes.length; j ++ ) { + + var volume = volumes[ j ]; + var newGeometry = new THREE.BufferGeometry(); + var material = objDefaultMaterial; + + newGeometry.setIndex( volume.triangles ); + newGeometry.addAttribute( 'position', vertices.clone() ); + + if ( normals ) { + + newGeometry.addAttribute( 'normal', normals.clone() ); + + } + + if ( amfMaterials[ volume.materialId ] !== undefined ) { + + material = amfMaterials[ volume.materialId ]; + + } + + newGeometry.scale( amfScale, amfScale, amfScale ); + newObject.add( new THREE.Mesh( newGeometry, material.clone() ) ); + + } + + } + + sceneObject.add( newObject ); + + } + + return sceneObject; + + } + +}; diff --git a/three/jsutil/loaders/AWDLoader.js b/three/jsutil/loaders/AWDLoader.js new file mode 100644 index 000000000..5bb0c03c5 --- /dev/null +++ b/three/jsutil/loaders/AWDLoader.js @@ -0,0 +1,1239 @@ +/** + * Author: Pierre Lepers + * Date: 09/12/2013 17:21 + */ + +( function () { + + var UNCOMPRESSED = 0, + DEFLATE = 1, + LZMA = 2, + + AWD_FIELD_INT8 = 1, + AWD_FIELD_INT16 = 2, + AWD_FIELD_INT32 = 3, + AWD_FIELD_UINT8 = 4, + AWD_FIELD_UINT16 = 5, + AWD_FIELD_UINT32 = 6, + AWD_FIELD_FLOAT32 = 7, + AWD_FIELD_FLOAT64 = 8, + AWD_FIELD_BOOL = 21, + AWD_FIELD_COLOR = 22, + AWD_FIELD_BADDR = 23, + AWD_FIELD_STRING = 31, + AWD_FIELD_BYTEARRAY = 32, + AWD_FIELD_VECTOR2x1 = 41, + AWD_FIELD_VECTOR3x1 = 42, + AWD_FIELD_VECTOR4x1 = 43, + AWD_FIELD_MTX3x2 = 44, + AWD_FIELD_MTX3x3 = 45, + AWD_FIELD_MTX4x3 = 46, + AWD_FIELD_MTX4x4 = 47, + + BOOL = 21, + COLOR = 22, + BADDR = 23, + + INT8 = 1, + INT16 = 2, + INT32 = 3, + UINT8 = 4, + UINT16 = 5, + UINT32 = 6, + FLOAT32 = 7, + FLOAT64 = 8; + + var littleEndian = true; + + function Block() { + + this.id = 0; + this.data = null; + + } + + function AWDProperties() {} + + AWDProperties.prototype = { + set: function ( key, value ) { + + this[ key ] = value; + + }, + + get: function ( key, fallback ) { + + if ( this.hasOwnProperty( key ) ) { + + return this[ key ]; + + } else { + + return fallback; + + } + + } + }; + + THREE.AWDLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.trunk = new THREE.Object3D(); + + this.materialFactory = undefined; + + this._url = ''; + this._baseDir = ''; + + this._data = undefined; + this._ptr = 0; + + this._version = []; + this._streaming = false; + this._optimized_for_accuracy = false; + this._compression = 0; + this._bodylen = 0xFFFFFFFF; + + this._blocks = [ new Block() ]; + + this._accuracyMatrix = false; + this._accuracyGeo = false; + this._accuracyProps = false; + + }; + + THREE.AWDLoader.prototype = { + + constructor: THREE.AWDLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + this._url = url; + this._baseDir = url.substr( 0, url.lastIndexOf( '/' ) + 1 ); + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + var blen = data.byteLength; + + this._ptr = 0; + this._data = new DataView( data ); + + this._parseHeader( ); + + if ( this._compression != 0 ) { + + console.error( 'compressed AWD not supported' ); + + } + + if ( ! this._streaming && this._bodylen != data.byteLength - this._ptr ) { + + console.error( 'AWDLoader: body len does not match file length', this._bodylen, blen - this._ptr ); + + } + + while ( this._ptr < blen ) { + + this.parseNextBlock(); + + } + + return this.trunk; + + }, + + parseNextBlock: function () { + + var assetData, + ns, type, len, block, + blockId = this.readU32(), + ns = this.readU8(), + type = this.readU8(), + flags = this.readU8(), + len = this.readU32(); + + + switch ( type ) { + + case 1: + assetData = this.parseMeshData( len ); + break; + + case 22: + assetData = this.parseContainer( len ); + break; + + case 23: + assetData = this.parseMeshInstance( len ); + break; + + case 81: + assetData = this.parseMaterial( len ); + break; + + case 82: + assetData = this.parseTexture( len ); + break; + + case 101: + assetData = this.parseSkeleton( len ); + break; + + // case 111: + // assetData = this.parseMeshPoseAnimation(len, true); + // break; + + case 112: + assetData = this.parseMeshPoseAnimation( len, false ); + break; + + case 113: + assetData = this.parseVertexAnimationSet( len ); + break; + + case 102: + assetData = this.parseSkeletonPose( len ); + break; + + case 103: + assetData = this.parseSkeletonAnimation( len ); + break; + + case 122: + assetData = this.parseAnimatorSet( len ); + break; + + // case 121: + // assetData = parseUVAnimation(len); + // break; + + default: + //debug('Ignoring block!',type, len); + this._ptr += len; + break; + + } + + + // Store block reference for later use + this._blocks[ blockId ] = block = new Block(); + block.data = assetData; + block.id = blockId; + + + }, + + _parseHeader: function () { + + var version = this._version, + awdmagic = ( this.readU8() << 16 ) | ( this.readU8() << 8 ) | this.readU8(); + + if ( awdmagic != 4282180 ) + throw new Error( "AWDLoader - bad magic" ); + + version[ 0 ] = this.readU8(); + version[ 1 ] = this.readU8(); + + var flags = this.readU16(); + + this._streaming = ( flags & 0x1 ) == 0x1; + + if ( ( version[ 0 ] === 2 ) && ( version[ 1 ] === 1 ) ) { + + this._accuracyMatrix = ( flags & 0x2 ) === 0x2; + this._accuracyGeo = ( flags & 0x4 ) === 0x4; + this._accuracyProps = ( flags & 0x8 ) === 0x8; + + } + + this._geoNrType = this._accuracyGeo ? FLOAT64 : FLOAT32; + this._matrixNrType = this._accuracyMatrix ? FLOAT64 : FLOAT32; + this._propsNrType = this._accuracyProps ? FLOAT64 : FLOAT32; + + this._optimized_for_accuracy = ( flags & 0x2 ) === 0x2; + + this._compression = this.readU8(); + this._bodylen = this.readU32(); + + }, + + parseContainer: function ( len ) { + + var parent, + ctr = new THREE.Object3D(), + par_id = this.readU32(), + mtx = this.parseMatrix4(); + + ctr.name = this.readUTF(); + ctr.applyMatrix( mtx ); + + parent = this._blocks[ par_id ].data || this.trunk; + parent.add( ctr ); + + this.parseProperties( { + 1: this._matrixNrType, + 2: this._matrixNrType, + 3: this._matrixNrType, + 4: UINT8 + } ); + + ctr.extra = this.parseUserAttributes(); + + return ctr; + + }, + + parseMeshInstance: function ( len ) { + + var name, + mesh, geometries, meshLen, meshes, + par_id, data_id, + mtx, + materials, mat, mat_id, + num_materials, + parent, + i; + + par_id = this.readU32(); + mtx = this.parseMatrix4(); + name = this.readUTF(); + data_id = this.readU32(); + num_materials = this.readU16(); + + geometries = this.getBlock( data_id ); + + materials = []; + + for ( i = 0; i < num_materials; i ++ ) { + + mat_id = this.readU32(); + mat = this.getBlock( mat_id ); + materials.push( mat ); + + } + + meshLen = geometries.length; + meshes = []; + + // TODO : BufferGeometry don't support "geometryGroups" for now. + // so we create sub meshes for each groups + if ( meshLen > 1 ) { + + mesh = new THREE.Object3D(); + for ( i = 0; i < meshLen; i ++ ) { + + var sm = new THREE.Mesh( geometries[ i ] ); + meshes.push( sm ); + mesh.add( sm ); + + } + + } else { + + mesh = new THREE.Mesh( geometries[ 0 ] ); + meshes.push( mesh ); + + } + + mesh.applyMatrix( mtx ); + mesh.name = name; + + + parent = this.getBlock( par_id ) || this.trunk; + parent.add( mesh ); + + + var matLen = materials.length; + var maxLen = Math.max( meshLen, matLen ); + for ( i = 0; i < maxLen; i ++ ) + meshes[ i % meshLen ].material = materials[ i % matLen ]; + + + // Ignore for now + this.parseProperties( null ); + mesh.extra = this.parseUserAttributes(); + + return mesh; + + }, + + parseMaterial: function ( len ) { + + var name, + type, + props, + mat, + attributes, + finalize, + num_methods, + methods_parsed; + + name = this.readUTF(); + type = this.readU8(); + num_methods = this.readU8(); + + //log( "AWDLoader parseMaterial ",name ) + + // Read material numerical properties + // (1=color, 2=bitmap url, 11=alpha_blending, 12=alpha_threshold, 13=repeat) + props = this.parseProperties( { + 1: AWD_FIELD_INT32, + 2: AWD_FIELD_BADDR, + 11: AWD_FIELD_BOOL, + 12: AWD_FIELD_FLOAT32, + 13: AWD_FIELD_BOOL + } ); + + methods_parsed = 0; + + while ( methods_parsed < num_methods ) { + + var method_type = this.readU16(); + this.parseProperties( null ); + this.parseUserAttributes(); + + } + + attributes = this.parseUserAttributes(); + + if ( this.materialFactory !== undefined ) { + + mat = this.materialFactory( name ); + if ( mat ) return mat; + + } + + mat = new THREE.MeshPhongMaterial(); + + if ( type === 1 ) { + + // Color material + mat.color.setHex( props.get( 1, 0xcccccc ) ); + + } else if ( type === 2 ) { + + // Bitmap material + var tex_addr = props.get( 2, 0 ); + mat.map = this.getBlock( tex_addr ); + + } + + mat.extra = attributes; + mat.alphaThreshold = props.get( 12, 0.0 ); + mat.repeat = props.get( 13, false ); + + + return mat; + + }, + + parseTexture: function ( len ) { + + var name = this.readUTF(), + type = this.readU8(), + asset, + data_len; + + // External + if ( type === 0 ) { + + data_len = this.readU32(); + var url = this.readUTFBytes( data_len ); + console.log( url ); + + asset = this.loadTexture( url ); + + } else { + // embed texture not supported + } + // Ignore for now + this.parseProperties( null ); + + this.parseUserAttributes(); + return asset; + + }, + + loadTexture: function ( url ) { + + var tex = new THREE.Texture(); + + var loader = new THREE.ImageLoader( this.manager ); + + loader.load( this._baseDir + url, function ( image ) { + + tex.image = image; + tex.needsUpdate = true; + + } ); + + return tex; + + }, + + parseSkeleton: function ( len ) { + + // Array + var name = this.readUTF(), + num_joints = this.readU16(), + skeleton = [], + joints_parsed = 0; + + this.parseProperties( null ); + + while ( joints_parsed < num_joints ) { + + var joint, ibp; + + // Ignore joint id + this.readU16(); + + joint = new THREE.Bone(); + joint.parent = this.readU16() - 1; // 0=null in AWD + joint.name = this.readUTF(); + + ibp = this.parseMatrix4(); + joint.skinMatrix = ibp; + + // Ignore joint props/attributes for now + this.parseProperties( null ); + this.parseUserAttributes(); + + skeleton.push( joint ); + joints_parsed ++; + + } + + // Discard attributes for now + this.parseUserAttributes(); + + + return skeleton; + + }, + + parseSkeletonPose: function ( blockID ) { + + var name = this.readUTF(); + + var num_joints = this.readU16(); + this.parseProperties( null ); + + // debug( 'parse Skeleton Pose. joints : ' + num_joints); + + var pose = []; + + var joints_parsed = 0; + + while ( joints_parsed < num_joints ) { + + var joint_pose; + + var has_transform; //:uint; + var mtx_data; + + has_transform = this.readU8(); + + if ( has_transform === 1 ) { + + mtx_data = this.parseMatrix4(); + + } else { + + mtx_data = new THREE.Matrix4(); + + } + pose[ joints_parsed ] = mtx_data; + joints_parsed ++; + + } + + // Skip attributes for now + this.parseUserAttributes(); + + return pose; + + }, + + parseSkeletonAnimation: function ( blockID ) { + + var frame_dur; + var pose_addr; + var pose; + + var name = this.readUTF(); + + var clip = []; + + var num_frames = this.readU16(); + this.parseProperties( null ); + + var frames_parsed = 0; + var returnedArray; + + // debug( 'parse Skeleton Animation. frames : ' + num_frames); + + while ( frames_parsed < num_frames ) { + + pose_addr = this.readU32(); + frame_dur = this.readU16(); + + pose = this._blocks[ pose_addr ].data; + // debug( 'pose address ',pose[2].elements[12],pose[2].elements[13],pose[2].elements[14] ); + clip.push( { + pose: pose, + duration: frame_dur + } ); + + frames_parsed ++; + + } + + if ( clip.length === 0 ) { + + // debug("Could not this SkeletonClipNode, because no Frames where set."); + return; + + } + // Ignore attributes for now + this.parseUserAttributes(); + return clip; + + }, + + parseVertexAnimationSet: function ( len ) { + + var poseBlockAdress, + name = this.readUTF(), + num_frames = this.readU16(), + props = this.parseProperties( { 1: UINT16 } ), + frames_parsed = 0, + skeletonFrames = []; + + while ( frames_parsed < num_frames ) { + + poseBlockAdress = this.readU32(); + skeletonFrames.push( this._blocks[ poseBlockAdress ].data ); + frames_parsed ++; + + } + + this.parseUserAttributes(); + + + return skeletonFrames; + + }, + + parseAnimatorSet: function ( len ) { + + var targetMesh; + + var animSetBlockAdress; //:int + + var targetAnimationSet; //:AnimationSetBase; + var outputString = ""; //:String = ""; + var name = this.readUTF(); + var type = this.readU16(); + + var props = this.parseProperties( { 1: BADDR } ); + + animSetBlockAdress = this.readU32(); + var targetMeshLength = this.readU16(); + + var meshAdresses = []; //:Vector. = new Vector.; + + for ( var i = 0; i < targetMeshLength; i ++ ) + meshAdresses.push( this.readU32() ); + + var activeState = this.readU16(); + var autoplay = Boolean( this.readU8() ); + this.parseUserAttributes(); + this.parseUserAttributes(); + + var returnedArray; + var targetMeshes = []; //:Vector. = new Vector.; + + for ( i = 0; i < meshAdresses.length; i ++ ) { + + // returnedArray = getAssetByID(meshAdresses[i], [AssetType.MESH]); + // if (returnedArray[0]) + targetMeshes.push( this._blocks[ meshAdresses[ i ] ].data ); + + } + + targetAnimationSet = this._blocks[ animSetBlockAdress ].data; + var thisAnimator; + + if ( type == 1 ) { + + + thisAnimator = { + animationSet: targetAnimationSet, + skeleton: this._blocks[ props.get( 1, 0 ) ].data + }; + + } else if ( type == 2 ) { + // debug( "vertex Anim???"); + } + + + for ( i = 0; i < targetMeshes.length; i ++ ) { + + targetMeshes[ i ].animator = thisAnimator; + + } + // debug("Parsed a Animator: Name = " + name); + + return thisAnimator; + + }, + + parseMeshData: function ( len ) { + + var name = this.readUTF(), + num_subs = this.readU16(), + geom, + subs_parsed = 0, + buffer, + skinW, skinI, + geometries = []; + + // Ignore for now + this.parseProperties( { 1: this._geoNrType, 2: this._geoNrType } ); + + // Loop through sub meshes + while ( subs_parsed < num_subs ) { + + var sm_len, sm_end, attrib; + + geom = new THREE.BufferGeometry(); + geom.name = name; + geometries.push( geom ); + + + sm_len = this.readU32(); + sm_end = this._ptr + sm_len; + + + // Ignore for now + this.parseProperties( { 1: this._geoNrType, 2: this._geoNrType } ); + + // Loop through data streams + while ( this._ptr < sm_end ) { + + var idx = 0, + str_type = this.readU8(), + str_ftype = this.readU8(), + str_len = this.readU32(), + str_end = str_len + this._ptr; + + if ( str_type === 1 ) { + + // VERTICES + + buffer = new Float32Array( ( str_len / 12 ) * 3 ); + attrib = new THREE.BufferAttribute( buffer, 3 ); + + geom.addAttribute( 'position', attrib ); + idx = 0; + + while ( this._ptr < str_end ) { + + buffer[ idx ] = - this.readF32(); + buffer[ idx + 1 ] = this.readF32(); + buffer[ idx + 2 ] = this.readF32(); + idx += 3; + + } + + } else if ( str_type === 2 ) { + + // INDICES + + buffer = new Uint16Array( str_len / 2 ); + attrib = new THREE.BufferAttribute( buffer, 1 ); + geom.setIndex( attrib ); + + idx = 0; + + while ( this._ptr < str_end ) { + + buffer[ idx + 1 ] = this.readU16(); + buffer[ idx ] = this.readU16(); + buffer[ idx + 2 ] = this.readU16(); + idx += 3; + + } + + } else if ( str_type === 3 ) { + + // UVS + + buffer = new Float32Array( ( str_len / 8 ) * 2 ); + attrib = new THREE.BufferAttribute( buffer, 2 ); + + geom.addAttribute( 'uv', attrib ); + idx = 0; + + while ( this._ptr < str_end ) { + + buffer[ idx ] = this.readF32(); + buffer[ idx + 1 ] = 1.0 - this.readF32(); + idx += 2; + + } + + } else if ( str_type === 4 ) { + + // NORMALS + + buffer = new Float32Array( ( str_len / 12 ) * 3 ); + attrib = new THREE.BufferAttribute( buffer, 3 ); + geom.addAttribute( 'normal', attrib ); + idx = 0; + + while ( this._ptr < str_end ) { + + buffer[ idx ] = - this.readF32(); + buffer[ idx + 1 ] = this.readF32(); + buffer[ idx + 2 ] = this.readF32(); + idx += 3; + + } + + } else { + + this._ptr = str_end; + + } + + } + + this.parseUserAttributes(); + + geom.computeBoundingSphere(); + subs_parsed ++; + + } + + //geom.computeFaceNormals(); + + this.parseUserAttributes(); + //finalizeAsset(geom, name); + + return geometries; + + }, + + parseMeshPoseAnimation: function ( len, poseOnly ) { + + var num_frames = 1, + num_submeshes, + frames_parsed, + subMeshParsed, + frame_dur, + x, y, z, + + str_len, + str_end, + geom, + subGeom, + idx = 0, + clip = {}, + indices, + verts, + num_Streams, + streamsParsed, + streamtypes = [], + + props, + thisGeo, + name = this.readUTF(), + geoAdress = this.readU32(); + + var mesh = this.getBlock( geoAdress ); + + if ( mesh === null ) { + + console.log( "parseMeshPoseAnimation target mesh not found at:", geoAdress ); + return; + + } + + geom = mesh.geometry; + geom.morphTargets = []; + + if ( ! poseOnly ) + num_frames = this.readU16(); + + num_submeshes = this.readU16(); + num_Streams = this.readU16(); + + // debug("VA num_frames : ", num_frames ); + // debug("VA num_submeshes : ", num_submeshes ); + // debug("VA numstreams : ", num_Streams ); + + streamsParsed = 0; + while ( streamsParsed < num_Streams ) { + + streamtypes.push( this.readU16() ); + streamsParsed ++; + + } + props = this.parseProperties( { 1: BOOL, 2: BOOL } ); + + clip.looping = props.get( 1, true ); + clip.stitchFinalFrame = props.get( 2, false ); + + frames_parsed = 0; + + while ( frames_parsed < num_frames ) { + + frame_dur = this.readU16(); + subMeshParsed = 0; + + while ( subMeshParsed < num_submeshes ) { + + streamsParsed = 0; + str_len = this.readU32(); + str_end = this._ptr + str_len; + + while ( streamsParsed < num_Streams ) { + + if ( streamtypes[ streamsParsed ] === 1 ) { + + //geom.addAttribute( 'morphTarget'+frames_parsed, Float32Array, str_len/12, 3 ); + var buffer = new Float32Array( str_len / 4 ); + geom.morphTargets.push( { + array: buffer + } ); + + //buffer = geom.attributes['morphTarget'+frames_parsed].array + idx = 0; + + while ( this._ptr < str_end ) { + + buffer[ idx ] = this.readF32(); + buffer[ idx + 1 ] = this.readF32(); + buffer[ idx + 2 ] = this.readF32(); + idx += 3; + + } + + + subMeshParsed ++; + + } else + this._ptr = str_end; + streamsParsed ++; + + } + + } + + + frames_parsed ++; + + } + + this.parseUserAttributes(); + + return null; + + }, + + getBlock: function ( id ) { + + return this._blocks[ id ].data; + + }, + + parseMatrix4: function () { + + var mtx = new THREE.Matrix4(); + var e = mtx.elements; + + e[ 0 ] = this.readF32(); + e[ 1 ] = this.readF32(); + e[ 2 ] = this.readF32(); + e[ 3 ] = 0.0; + //e[3] = 0.0; + + e[ 4 ] = this.readF32(); + e[ 5 ] = this.readF32(); + e[ 6 ] = this.readF32(); + //e[7] = this.readF32(); + e[ 7 ] = 0.0; + + e[ 8 ] = this.readF32(); + e[ 9 ] = this.readF32(); + e[ 10 ] = this.readF32(); + //e[11] = this.readF32(); + e[ 11 ] = 0.0; + + e[ 12 ] = - this.readF32(); + e[ 13 ] = this.readF32(); + e[ 14 ] = this.readF32(); + //e[15] = this.readF32(); + e[ 15 ] = 1.0; + return mtx; + + }, + + parseProperties: function ( expected ) { + + var list_len = this.readU32(); + var list_end = this._ptr + list_len; + + var props = new AWDProperties(); + + if ( expected ) { + + while ( this._ptr < list_end ) { + + var key = this.readU16(); + var len = this.readU32(); + var type; + + if ( expected.hasOwnProperty( key ) ) { + + type = expected[ key ]; + props.set( key, this.parseAttrValue( type, len ) ); + + } else { + + this._ptr += len; + + } + + } + + } + + return props; + + }, + + parseUserAttributes: function () { + + // skip for now + this._ptr = this.readU32() + this._ptr; + return null; + + }, + + parseAttrValue: function ( type, len ) { + + var elem_len; + var read_func; + + switch ( type ) { + + case AWD_FIELD_INT8: + elem_len = 1; + read_func = this.readI8; + break; + + case AWD_FIELD_INT16: + elem_len = 2; + read_func = this.readI16; + break; + + case AWD_FIELD_INT32: + elem_len = 4; + read_func = this.readI32; + break; + + case AWD_FIELD_BOOL: + case AWD_FIELD_UINT8: + elem_len = 1; + read_func = this.readU8; + break; + + case AWD_FIELD_UINT16: + elem_len = 2; + read_func = this.readU16; + break; + + case AWD_FIELD_UINT32: + case AWD_FIELD_BADDR: + elem_len = 4; + read_func = this.readU32; + break; + + case AWD_FIELD_FLOAT32: + elem_len = 4; + read_func = this.readF32; + break; + + case AWD_FIELD_FLOAT64: + elem_len = 8; + read_func = this.readF64; + break; + + case AWD_FIELD_VECTOR2x1: + case AWD_FIELD_VECTOR3x1: + case AWD_FIELD_VECTOR4x1: + case AWD_FIELD_MTX3x2: + case AWD_FIELD_MTX3x3: + case AWD_FIELD_MTX4x3: + case AWD_FIELD_MTX4x4: + elem_len = 8; + read_func = this.readF64; + break; + + } + + if ( elem_len < len ) { + + var list; + var num_read; + var num_elems; + + list = []; + num_read = 0; + num_elems = len / elem_len; + + while ( num_read < num_elems ) { + + list.push( read_func.call( this ) ); + num_read ++; + + } + + return list; + + } else { + + return read_func.call( this ); + + } + + }, + + readU8: function () { + + return this._data.getUint8( this._ptr ++ ); + + }, + readI8: function () { + + return this._data.getInt8( this._ptr ++ ); + + }, + readU16: function () { + + var a = this._data.getUint16( this._ptr, littleEndian ); + this._ptr += 2; + return a; + + }, + readI16: function () { + + var a = this._data.getInt16( this._ptr, littleEndian ); + this._ptr += 2; + return a; + + }, + readU32: function () { + + var a = this._data.getUint32( this._ptr, littleEndian ); + this._ptr += 4; + return a; + + }, + readI32: function () { + + var a = this._data.getInt32( this._ptr, littleEndian ); + this._ptr += 4; + return a; + + }, + readF32: function () { + + var a = this._data.getFloat32( this._ptr, littleEndian ); + this._ptr += 4; + return a; + + }, + readF64: function () { + + var a = this._data.getFloat64( this._ptr, littleEndian ); + this._ptr += 8; + return a; + + }, + + /** + * Converts a UTF-8 byte array to JavaScript's 16-bit Unicode. + * @param {Array.} bytes UTF-8 byte array. + * @return {string} 16-bit Unicode string. + */ + readUTF: function () { + + var len = this.readU16(); + return this.readUTFBytes( len ); + + }, + + /** + * Converts a UTF-8 byte array to JavaScript's 16-bit Unicode. + * @param {Array.} bytes UTF-8 byte array. + * @return {string} 16-bit Unicode string. + */ + readUTFBytes: function ( len ) { + + // TODO(user): Use native implementations if/when available + var out = [], c = 0; + + while ( out.length < len ) { + + var c1 = this._data.getUint8( this._ptr ++, littleEndian ); + if ( c1 < 128 ) { + + out[ c ++ ] = String.fromCharCode( c1 ); + + } else if ( c1 > 191 && c1 < 224 ) { + + var c2 = this._data.getUint8( this._ptr ++, littleEndian ); + out[ c ++ ] = String.fromCharCode( ( c1 & 31 ) << 6 | c2 & 63 ); + + } else { + + var c2 = this._data.getUint8( this._ptr ++, littleEndian ); + var c3 = this._data.getUint8( this._ptr ++, littleEndian ); + out[ c ++ ] = String.fromCharCode( ( c1 & 15 ) << 12 | ( c2 & 63 ) << 6 | c3 & 63 ); + + } + + } + return out.join( '' ); + + } + + }; + +} )(); diff --git a/three/jsutil/loaders/AssimpJSONLoader.js b/three/jsutil/loaders/AssimpJSONLoader.js new file mode 100644 index 000000000..14e7b8772 --- /dev/null +++ b/three/jsutil/loaders/AssimpJSONLoader.js @@ -0,0 +1,289 @@ +/** + * @author Alexander Gessler / http://www.greentoken.de/ + * https://github.com/acgessler + * + * Loader for models imported with Open Asset Import Library (http://assimp.sf.net) + * through assimp2json (https://github.com/acgessler/assimp2json). + * + * Supports any input format that assimp supports, including 3ds, obj, dae, blend, + * fbx, x, ms3d, lwo (and many more). + * + * See webgl_loader_assimp2json example. + */ + +THREE.AssimpJSONLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.AssimpJSONLoader.prototype = { + + constructor: THREE.AssimpJSONLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var path = ( scope.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : scope.path; + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + var json = JSON.parse( text ); + var metadata = json.__metadata__; + + // check if __metadata__ meta header is present + // this header is used to disambiguate between different JSON-based file formats + + if ( typeof metadata !== 'undefined' ) { + + // check if assimp2json at all + + if ( metadata.format !== 'assimp2json' ) { + + onError( 'THREE.AssimpJSONLoader: Not an assimp2json scene.' ); + return; + + // check major format version + + } else if ( metadata.version < 100 && metadata.version >= 200 ) { + + onError( 'THREE.AssimpJSONLoader: Unsupported assimp2json file format version.' ); + return; + + } + + } + + onLoad( scope.parse( json, path ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + parse: function ( json, path ) { + + function parseList( json, handler ) { + + var meshes = new Array( json.length ); + + for ( var i = 0; i < json.length; ++ i ) { + + meshes[ i ] = handler.call( this, json[ i ] ); + + } + + return meshes; + + } + + function parseMesh( json ) { + + var geometry = new THREE.BufferGeometry(); + + var i, l, face; + + var indices = []; + + var vertices = json.vertices || []; + var normals = json.normals || []; + var uvs = json.texturecoords || []; + var colors = json.colors || []; + + uvs = uvs[ 0 ] || []; // only support for a single set of uvs + + for ( i = 0, l = json.faces.length; i < l; i ++ ) { + + face = json.faces[ i ]; + indices.push( face[ 0 ], face[ 1 ], face[ 2 ] ); + + } + + geometry.setIndex( indices ); + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + + if ( normals.length > 0 ) { + + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + } + + if ( uvs.length > 0 ) { + + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + + } + + if ( colors.length > 0 ) { + + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + } + + geometry.computeBoundingSphere(); + + return geometry; + + } + + function parseMaterial( json ) { + + var material = new THREE.MeshPhongMaterial(); + + for ( var i in json.properties ) { + + var property = json.properties[ i ]; + var key = property.key; + var value = property.value; + + switch ( key ) { + + case '$tex.file': { + + var semantic = property.semantic; + + // prop.semantic gives the type of the texture + // 1: diffuse + // 2: specular mao + // 5: height map (bumps) + // 6: normal map + // more values (i.e. emissive, environment) are known by assimp and may be relevant + + if ( semantic === 1 || semantic === 2 || semantic === 5 || semantic === 6 ) { + + var keyname; + + switch ( semantic ) { + + case 1: + keyname = 'map'; + break; + case 2: + keyname = 'specularMap'; + break; + case 5: + keyname = 'bumpMap'; + break; + case 6: + keyname = 'normalMap'; + break; + + } + + var texture = textureLoader.load( value ); + + // TODO: read texture settings from assimp. + // Wrapping is the default, though. + + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + + material[ keyname ] = texture; + + } + + break; + + } + + case '?mat.name': + material.name = value; + break; + + case '$clr.diffuse': + material.color.fromArray( value ); + break; + + case '$clr.specular': + material.specular.fromArray( value ); + break; + + case '$clr.emissive': + material.emissive.fromArray( value ); + break; + + case '$mat.shininess': + material.shininess = value; + break; + + case '$mat.shadingm': + // aiShadingMode_Flat + material.flatShading = ( value === 1 ) ? true : false; + break; + + case '$mat.opacity': + if ( value < 1 ) { + + material.opacity = value; + material.transparent = true; + + } + break; + + } + + } + + return material; + + } + + function parseObject( json, node, meshes, materials ) { + + var obj = new THREE.Object3D(), i, idx; + + obj.name = node.name || ''; + obj.matrix = new THREE.Matrix4().fromArray( node.transformation ).transpose(); + obj.matrix.decompose( obj.position, obj.quaternion, obj.scale ); + + for ( i = 0; node.meshes && i < node.meshes.length; i ++ ) { + + idx = node.meshes[ i ]; + obj.add( new THREE.Mesh( meshes[ idx ], materials[ json.meshes[ idx ].materialindex ] ) ); + + } + + for ( i = 0; node.children && i < node.children.length; i ++ ) { + + obj.add( parseObject( json, node.children[ i ], meshes, materials ) ); + + } + + return obj; + + } + + var textureLoader = new THREE.TextureLoader( this.manager ); + textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); + + var meshes = parseList( json.meshes, parseMesh ); + var materials = parseList( json.materials, parseMaterial ); + return parseObject( json, json.rootnode, meshes, materials ); + + } + +}; diff --git a/three/jsutil/loaders/AssimpLoader.js b/three/jsutil/loaders/AssimpLoader.js new file mode 100644 index 000000000..f2a2dbc3f --- /dev/null +++ b/three/jsutil/loaders/AssimpLoader.js @@ -0,0 +1,2374 @@ +/** + * @author Virtulous / https://virtulo.us/ + */ + +THREE.AssimpLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.AssimpLoader.prototype = { + + constructor: THREE.AssimpLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var path = ( scope.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : scope.path; + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + + loader.load( url, function ( buffer ) { + + onLoad( scope.parse( buffer, path ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + parse: function ( buffer, path ) { + + var textureLoader = new THREE.TextureLoader( this.manager ); + textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); + + var Virtulous = {}; + + Virtulous.KeyFrame = function ( time, matrix ) { + + this.time = time; + this.matrix = matrix.clone(); + this.position = new THREE.Vector3(); + this.quaternion = new THREE.Quaternion(); + this.scale = new THREE.Vector3( 1, 1, 1 ); + this.matrix.decompose( this.position, this.quaternion, this.scale ); + this.clone = function () { + + var n = new Virtulous.KeyFrame( this.time, this.matrix ); + return n; + + }; + this.lerp = function ( nextKey, time ) { + + time -= this.time; + var dist = ( nextKey.time - this.time ); + var l = time / dist; + var l2 = 1 - l; + var keypos = this.position; + var keyrot = this.quaternion; + // var keyscl = key.parentspaceScl || key.scl; + var key2pos = nextKey.position; + var key2rot = nextKey.quaternion; + // var key2scl = key2.parentspaceScl || key2.scl; + Virtulous.KeyFrame.tempAniPos.x = keypos.x * l2 + key2pos.x * l; + Virtulous.KeyFrame.tempAniPos.y = keypos.y * l2 + key2pos.y * l; + Virtulous.KeyFrame.tempAniPos.z = keypos.z * l2 + key2pos.z * l; + // tempAniScale.x = keyscl[0] * l2 + key2scl[0] * l; + // tempAniScale.y = keyscl[1] * l2 + key2scl[1] * l; + // tempAniScale.z = keyscl[2] * l2 + key2scl[2] * l; + Virtulous.KeyFrame.tempAniQuat.set( keyrot.x, keyrot.y, keyrot.z, keyrot.w ); + Virtulous.KeyFrame.tempAniQuat.slerp( key2rot, l ); + return Virtulous.KeyFrame.tempAniMatrix.compose( Virtulous.KeyFrame.tempAniPos, Virtulous.KeyFrame.tempAniQuat, Virtulous.KeyFrame.tempAniScale ); + + }; + + }; + + Virtulous.KeyFrame.tempAniPos = new THREE.Vector3(); + Virtulous.KeyFrame.tempAniQuat = new THREE.Quaternion(); + Virtulous.KeyFrame.tempAniScale = new THREE.Vector3( 1, 1, 1 ); + Virtulous.KeyFrame.tempAniMatrix = new THREE.Matrix4(); + Virtulous.KeyFrameTrack = function () { + + this.keys = []; + this.target = null; + this.time = 0; + this.length = 0; + this._accelTable = {}; + this.fps = 20; + this.addKey = function ( key ) { + + this.keys.push( key ); + + }; + this.init = function () { + + this.sortKeys(); + + if ( this.keys.length > 0 ) + this.length = this.keys[ this.keys.length - 1 ].time; + else + this.length = 0; + + if ( ! this.fps ) return; + + for ( var j = 0; j < this.length * this.fps; j ++ ) { + + for ( var i = 0; i < this.keys.length; i ++ ) { + + if ( this.keys[ i ].time == j ) { + + this._accelTable[ j ] = i; + break; + + } else if ( this.keys[ i ].time < j / this.fps && this.keys[ i + 1 ] && this.keys[ i + 1 ].time >= j / this.fps ) { + + this._accelTable[ j ] = i; + break; + + } + + } + + } + + }; + + this.parseFromThree = function ( data ) { + + var fps = data.fps; + this.target = data.node; + var track = data.hierarchy[ 0 ].keys; + for ( var i = 0; i < track.length; i ++ ) { + + this.addKey( new Virtulous.KeyFrame( i / fps || track[ i ].time, track[ i ].targets[ 0 ].data ) ); + + } + this.init(); + + }; + + this.parseFromCollada = function ( data ) { + + var track = data.keys; + var fps = this.fps; + + for ( var i = 0; i < track.length; i ++ ) { + + this.addKey( new Virtulous.KeyFrame( i / fps || track[ i ].time, track[ i ].matrix ) ); + + } + + this.init(); + + }; + + this.sortKeys = function () { + + this.keys.sort( this.keySortFunc ); + + }; + + this.keySortFunc = function ( a, b ) { + + return a.time - b.time; + + }; + + this.clone = function () { + + var t = new Virtulous.KeyFrameTrack(); + t.target = this.target; + t.time = this.time; + t.length = this.length; + + for ( var i = 0; i < this.keys.length; i ++ ) { + + t.addKey( this.keys[ i ].clone() ); + + } + + t.init(); + return t; + + }; + + this.reTarget = function ( root, compareitor ) { + + if ( ! compareitor ) compareitor = Virtulous.TrackTargetNodeNameCompare; + this.target = compareitor( root, this.target ); + + }; + + this.keySearchAccel = function ( time ) { + + time *= this.fps; + time = Math.floor( time ); + return this._accelTable[ time ] || 0; + + }; + + this.setTime = function ( time ) { + + time = Math.abs( time ); + if ( this.length ) + time = time % this.length + .05; + var key0 = null; + var key1 = null; + + for ( var i = this.keySearchAccel( time ); i < this.keys.length; i ++ ) { + + if ( this.keys[ i ].time == time ) { + + key0 = this.keys[ i ]; + key1 = this.keys[ i ]; + break; + + } else if ( this.keys[ i ].time < time && this.keys[ i + 1 ] && this.keys[ i + 1 ].time > time ) { + + key0 = this.keys[ i ]; + key1 = this.keys[ i + 1 ]; + break; + + } else if ( this.keys[ i ].time < time && i == this.keys.length - 1 ) { + + key0 = this.keys[ i ]; + key1 = this.keys[ 0 ].clone(); + key1.time += this.length + .05; + break; + + } + + } + + if ( key0 && key1 && key0 !== key1 ) { + + this.target.matrixAutoUpdate = false; + this.target.matrix.copy( key0.lerp( key1, time ) ); + this.target.matrixWorldNeedsUpdate = true; + return; + + } + + if ( key0 && key1 && key0 == key1 ) { + + this.target.matrixAutoUpdate = false; + this.target.matrix.copy( key0.matrix ); + this.target.matrixWorldNeedsUpdate = true; + return; + + } + + }; + + }; + + Virtulous.TrackTargetNodeNameCompare = function ( root, target ) { + + function find( node, name ) { + + if ( node.name == name ) + return node; + + for ( var i = 0; i < node.children.length; i ++ ) { + + var r = find( node.children[ i ], name ); + if ( r ) return r; + + } + + return null; + + } + + return find( root, target.name ); + + }; + + Virtulous.Animation = function () { + + this.tracks = []; + this.length = 0; + + this.addTrack = function ( track ) { + + this.tracks.push( track ); + this.length = Math.max( track.length, this.length ); + + }; + + this.setTime = function ( time ) { + + this.time = time; + + for ( var i = 0; i < this.tracks.length; i ++ ) + this.tracks[ i ].setTime( time ); + + }; + + this.clone = function ( target, compareitor ) { + + if ( ! compareitor ) compareitor = Virtulous.TrackTargetNodeNameCompare; + var n = new Virtulous.Animation(); + n.target = target; + for ( var i = 0; i < this.tracks.length; i ++ ) { + + var track = this.tracks[ i ].clone(); + track.reTarget( target, compareitor ); + n.addTrack( track ); + + } + + return n; + + }; + + }; + + var ASSBIN_CHUNK_AICAMERA = 0x1234; + var ASSBIN_CHUNK_AILIGHT = 0x1235; + var ASSBIN_CHUNK_AITEXTURE = 0x1236; + var ASSBIN_CHUNK_AIMESH = 0x1237; + var ASSBIN_CHUNK_AINODEANIM = 0x1238; + var ASSBIN_CHUNK_AISCENE = 0x1239; + var ASSBIN_CHUNK_AIBONE = 0x123a; + var ASSBIN_CHUNK_AIANIMATION = 0x123b; + var ASSBIN_CHUNK_AINODE = 0x123c; + var ASSBIN_CHUNK_AIMATERIAL = 0x123d; + var ASSBIN_CHUNK_AIMATERIALPROPERTY = 0x123e; + var ASSBIN_MESH_HAS_POSITIONS = 0x1; + var ASSBIN_MESH_HAS_NORMALS = 0x2; + var ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS = 0x4; + var ASSBIN_MESH_HAS_TEXCOORD_BASE = 0x100; + var ASSBIN_MESH_HAS_COLOR_BASE = 0x10000; + var AI_MAX_NUMBER_OF_COLOR_SETS = 1; + var AI_MAX_NUMBER_OF_TEXTURECOORDS = 4; + var aiLightSource_UNDEFINED = 0x0; + //! A directional light source has a well-defined direction + //! but is infinitely far away. That's quite a good + //! approximation for sun light. + var aiLightSource_DIRECTIONAL = 0x1; + //! A point light source has a well-defined position + //! in space but no direction - it emits light in all + //! directions. A normal bulb is a point light. + var aiLightSource_POINT = 0x2; + //! A spot light source emits light in a specific + //! angle. It has a position and a direction it is pointing to. + //! A good example for a spot light is a light spot in + //! sport arenas. + var aiLightSource_SPOT = 0x3; + //! The generic light level of the world, including the bounces + //! of all other lightsources. + //! Typically, there's at most one ambient light in a scene. + //! This light type doesn't have a valid position, direction, or + //! other properties, just a color. + var aiLightSource_AMBIENT = 0x4; + /** Flat shading. Shading is done on per-face base, + * diffuse only. Also known as 'faceted shading'. + */ + var aiShadingMode_Flat = 0x1; + /** Simple Gouraud shading. + */ + var aiShadingMode_Gouraud = 0x2; + /** Phong-Shading - + */ + var aiShadingMode_Phong = 0x3; + /** Phong-Blinn-Shading + */ + var aiShadingMode_Blinn = 0x4; + /** Toon-Shading per pixel + * + * Also known as 'comic' shader. + */ + var aiShadingMode_Toon = 0x5; + /** OrenNayar-Shading per pixel + * + * Extension to standard Lambertian shading, taking the + * roughness of the material into account + */ + var aiShadingMode_OrenNayar = 0x6; + /** Minnaert-Shading per pixel + * + * Extension to standard Lambertian shading, taking the + * "darkness" of the material into account + */ + var aiShadingMode_Minnaert = 0x7; + /** CookTorrance-Shading per pixel + * + * Special shader for metallic surfaces. + */ + var aiShadingMode_CookTorrance = 0x8; + /** No shading at all. Constant light influence of 1.0. + */ + var aiShadingMode_NoShading = 0x9; + /** Fresnel shading + */ + var aiShadingMode_Fresnel = 0xa; + var aiTextureType_NONE = 0x0; + /** The texture is combined with the result of the diffuse + * lighting equation. + */ + var aiTextureType_DIFFUSE = 0x1; + /** The texture is combined with the result of the specular + * lighting equation. + */ + var aiTextureType_SPECULAR = 0x2; + /** The texture is combined with the result of the ambient + * lighting equation. + */ + var aiTextureType_AMBIENT = 0x3; + /** The texture is added to the result of the lighting + * calculation. It isn't influenced by incoming light. + */ + var aiTextureType_EMISSIVE = 0x4; + /** The texture is a height map. + * + * By convention, higher gray-scale values stand for + * higher elevations from the base height. + */ + var aiTextureType_HEIGHT = 0x5; + /** The texture is a (tangent space) normal-map. + * + * Again, there are several conventions for tangent-space + * normal maps. Assimp does (intentionally) not + * distinguish here. + */ + var aiTextureType_NORMALS = 0x6; + /** The texture defines the glossiness of the material. + * + * The glossiness is in fact the exponent of the specular + * (phong) lighting equation. Usually there is a conversion + * function defined to map the linear color values in the + * texture to a suitable exponent. Have fun. + */ + var aiTextureType_SHININESS = 0x7; + /** The texture defines per-pixel opacity. + * + * Usually 'white' means opaque and 'black' means + * 'transparency'. Or quite the opposite. Have fun. + */ + var aiTextureType_OPACITY = 0x8; + /** Displacement texture + * + * The exact purpose and format is application-dependent. + * Higher color values stand for higher vertex displacements. + */ + var aiTextureType_DISPLACEMENT = 0x9; + /** Lightmap texture (aka Ambient Occlusion) + * + * Both 'Lightmaps' and dedicated 'ambient occlusion maps' are + * covered by this material property. The texture contains a + * scaling value for the final color value of a pixel. Its + * intensity is not affected by incoming light. + */ + var aiTextureType_LIGHTMAP = 0xA; + /** Reflection texture + * + * Contains the color of a perfect mirror reflection. + * Rarely used, almost never for real-time applications. + */ + var aiTextureType_REFLECTION = 0xB; + /** Unknown texture + * + * A texture reference that does not match any of the definitions + * above is considered to be 'unknown'. It is still imported, + * but is excluded from any further postprocessing. + */ + var aiTextureType_UNKNOWN = 0xC; + var BONESPERVERT = 4; + + function ASSBIN_MESH_HAS_TEXCOORD( n ) { + + return ASSBIN_MESH_HAS_TEXCOORD_BASE << n; + + } + + function ASSBIN_MESH_HAS_COLOR( n ) { + + return ASSBIN_MESH_HAS_COLOR_BASE << n; + + } + + function markBones( scene ) { + + for ( var i in scene.mMeshes ) { + + var mesh = scene.mMeshes[ i ]; + for ( var k in mesh.mBones ) { + + var boneNode = scene.findNode( mesh.mBones[ k ].mName ); + if ( boneNode ) + boneNode.isBone = true; + + } + + } + + } + function cloneTreeToBones( root, scene ) { + + var rootBone = new THREE.Bone(); + rootBone.matrix.copy( root.matrix ); + rootBone.matrixWorld.copy( root.matrixWorld ); + rootBone.position.copy( root.position ); + rootBone.quaternion.copy( root.quaternion ); + rootBone.scale.copy( root.scale ); + scene.nodeCount ++; + rootBone.name = "bone_" + root.name + scene.nodeCount.toString(); + + if ( ! scene.nodeToBoneMap[ root.name ] ) + scene.nodeToBoneMap[ root.name ] = []; + scene.nodeToBoneMap[ root.name ].push( rootBone ); + for ( var i in root.children ) { + + var child = cloneTreeToBones( root.children[ i ], scene ); + if ( child ) + rootBone.add( child ); + + } + + return rootBone; + + } + + function sortWeights( indexes, weights ) { + + var pairs = []; + + for ( var i = 0; i < indexes.length; i ++ ) { + + pairs.push( { + i: indexes[ i ], + w: weights[ i ] + } ); + + } + + pairs.sort( function ( a, b ) { + + return b.w - a.w; + + } ); + + while ( pairs.length < 4 ) { + + pairs.push( { + i: 0, + w: 0 + } ); + + } + + if ( pairs.length > 4 ) + pairs.length = 4; + var sum = 0; + + for ( var i = 0; i < 4; i ++ ) { + + sum += pairs[ i ].w * pairs[ i ].w; + + } + + sum = Math.sqrt( sum ); + + for ( var i = 0; i < 4; i ++ ) { + + pairs[ i ].w = pairs[ i ].w / sum; + indexes[ i ] = pairs[ i ].i; + weights[ i ] = pairs[ i ].w; + + } + + } + + function findMatchingBone( root, name ) { + + if ( root.name.indexOf( "bone_" + name ) == 0 ) + return root; + + for ( var i in root.children ) { + + var ret = findMatchingBone( root.children[ i ], name ); + + if ( ret ) + return ret; + + } + + return undefined; + + } + + function aiMesh() { + + this.mPrimitiveTypes = 0; + this.mNumVertices = 0; + this.mNumFaces = 0; + this.mNumBones = 0; + this.mMaterialIndex = 0; + this.mVertices = []; + this.mNormals = []; + this.mTangents = []; + this.mBitangents = []; + this.mColors = [ + [] + ]; + this.mTextureCoords = [ + [] + ]; + this.mFaces = []; + this.mBones = []; + this.hookupSkeletons = function ( scene, threeScene ) { + + if ( this.mBones.length == 0 ) return; + + var allBones = []; + var offsetMatrix = []; + var skeletonRoot = scene.findNode( this.mBones[ 0 ].mName ); + + while ( skeletonRoot.mParent && skeletonRoot.mParent.isBone ) { + + skeletonRoot = skeletonRoot.mParent; + + } + + var threeSkeletonRoot = skeletonRoot.toTHREE( scene ); + var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene ); + this.threeNode.add( threeSkeletonRootBone ); + + for ( var i = 0; i < this.mBones.length; i ++ ) { + + var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName ); + + if ( bone ) { + + var tbone = bone; + allBones.push( tbone ); + //tbone.matrixAutoUpdate = false; + offsetMatrix.push( this.mBones[ i ].mOffsetMatrix.toTHREE() ); + + } else { + + var skeletonRoot = scene.findNode( this.mBones[ i ].mName ); + if ( ! skeletonRoot ) return; + var threeSkeletonRoot = skeletonRoot.toTHREE( scene ); + var threeSkeletonRootParent = threeSkeletonRoot.parent; + var threeSkeletonRootBone = cloneTreeToBones( threeSkeletonRoot, scene ); + this.threeNode.add( threeSkeletonRootBone ); + var bone = findMatchingBone( threeSkeletonRootBone, this.mBones[ i ].mName ); + var tbone = bone; + allBones.push( tbone ); + //tbone.matrixAutoUpdate = false; + offsetMatrix.push( this.mBones[ i ].mOffsetMatrix.toTHREE() ); + + } + + } + var skeleton = new THREE.Skeleton( allBones, offsetMatrix ); + + this.threeNode.bind( skeleton, new THREE.Matrix4() ); + this.threeNode.material.skinning = true; + + }; + + this.toTHREE = function ( scene ) { + + if ( this.threeNode ) return this.threeNode; + var geometry = new THREE.BufferGeometry(); + var mat; + if ( scene.mMaterials[ this.mMaterialIndex ] ) + mat = scene.mMaterials[ this.mMaterialIndex ].toTHREE( scene ); + else + mat = new THREE.MeshLambertMaterial(); + geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( this.mIndexArray ), 1 ) ); + geometry.addAttribute( 'position', new THREE.BufferAttribute( this.mVertexBuffer, 3 ) ); + if ( this.mNormalBuffer && this.mNormalBuffer.length > 0 ) + geometry.addAttribute( 'normal', new THREE.BufferAttribute( this.mNormalBuffer, 3 ) ); + if ( this.mColorBuffer && this.mColorBuffer.length > 0 ) + geometry.addAttribute( 'color', new THREE.BufferAttribute( this.mColorBuffer, 4 ) ); + if ( this.mTexCoordsBuffers[ 0 ] && this.mTexCoordsBuffers[ 0 ].length > 0 ) + geometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( this.mTexCoordsBuffers[ 0 ] ), 2 ) ); + if ( this.mTexCoordsBuffers[ 1 ] && this.mTexCoordsBuffers[ 1 ].length > 0 ) + geometry.addAttribute( 'uv1', new THREE.BufferAttribute( new Float32Array( this.mTexCoordsBuffers[ 1 ] ), 2 ) ); + if ( this.mTangentBuffer && this.mTangentBuffer.length > 0 ) + geometry.addAttribute( 'tangents', new THREE.BufferAttribute( this.mTangentBuffer, 3 ) ); + if ( this.mBitangentBuffer && this.mBitangentBuffer.length > 0 ) + geometry.addAttribute( 'bitangents', new THREE.BufferAttribute( this.mBitangentBuffer, 3 ) ); + if ( this.mBones.length > 0 ) { + + var weights = []; + var bones = []; + + for ( var i = 0; i < this.mBones.length; i ++ ) { + + for ( var j = 0; j < this.mBones[ i ].mWeights.length; j ++ ) { + + var weight = this.mBones[ i ].mWeights[ j ]; + if ( weight ) { + + if ( ! weights[ weight.mVertexId ] ) weights[ weight.mVertexId ] = []; + if ( ! bones[ weight.mVertexId ] ) bones[ weight.mVertexId ] = []; + weights[ weight.mVertexId ].push( weight.mWeight ); + bones[ weight.mVertexId ].push( parseInt( i ) ); + + } + + } + + } + + for ( var i in bones ) { + + sortWeights( bones[ i ], weights[ i ] ); + + } + + var _weights = []; + var _bones = []; + + for ( var i = 0; i < weights.length; i ++ ) { + + for ( var j = 0; j < 4; j ++ ) { + + if ( weights[ i ] && bones[ i ] ) { + + _weights.push( weights[ i ][ j ] ); + _bones.push( bones[ i ][ j ] ); + + } else { + + _weights.push( 0 ); + _bones.push( 0 ); + + } + + } + + } + + geometry.addAttribute( 'skinWeight', new THREE.BufferAttribute( new Float32Array( _weights ), BONESPERVERT ) ); + geometry.addAttribute( 'skinIndex', new THREE.BufferAttribute( new Float32Array( _bones ), BONESPERVERT ) ); + + } + + var mesh; + + if ( this.mBones.length == 0 ) + mesh = new THREE.Mesh( geometry, mat ); + + if ( this.mBones.length > 0 ) + mesh = new THREE.SkinnedMesh( geometry, mat ); + + this.threeNode = mesh; + //mesh.matrixAutoUpdate = false; + return mesh; + + }; + + } + + function aiFace() { + + this.mNumIndices = 0; + this.mIndices = []; + + } + + function aiVector3D() { + + this.x = 0; + this.y = 0; + this.z = 0; + + this.toTHREE = function () { + + return new THREE.Vector3( this.x, this.y, this.z ); + + }; + + } + + function aiVector2D() { + + this.x = 0; + this.y = 0; + this.toTHREE = function () { + + return new THREE.Vector2( this.x, this.y ); + + }; + + } + + function aiVector4D() { + + this.w = 0; + this.x = 0; + this.y = 0; + this.z = 0; + this.toTHREE = function () { + + return new THREE.Vector4( this.w, this.x, this.y, this.z ); + + }; + + } + + function aiColor4D() { + + this.r = 0; + this.g = 0; + this.b = 0; + this.a = 0; + this.toTHREE = function () { + + return new THREE.Color( this.r, this.g, this.b, this.a ); + + }; + + } + + function aiColor3D() { + + this.r = 0; + this.g = 0; + this.b = 0; + this.a = 0; + this.toTHREE = function () { + + return new THREE.Color( this.r, this.g, this.b, 1 ); + + }; + + } + + function aiQuaternion() { + + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + this.toTHREE = function () { + + return new THREE.Quaternion( this.x, this.y, this.z, this.w ); + + }; + + } + + function aiVertexWeight() { + + this.mVertexId = 0; + this.mWeight = 0; + + } + + function aiString() { + + this.data = []; + this.toString = function () { + + var str = ''; + this.data.forEach( function ( i ) { + + str += ( String.fromCharCode( i ) ); + + } ); + return str.replace( /[^\x20-\x7E]+/g, '' ); + + }; + + } + + function aiVectorKey() { + + this.mTime = 0; + this.mValue = null; + + } + + function aiQuatKey() { + + this.mTime = 0; + this.mValue = null; + + } + + function aiNode() { + + this.mName = ''; + this.mTransformation = []; + this.mNumChildren = 0; + this.mNumMeshes = 0; + this.mMeshes = []; + this.mChildren = []; + this.toTHREE = function ( scene ) { + + if ( this.threeNode ) return this.threeNode; + var o = new THREE.Object3D(); + o.name = this.mName; + o.matrix = this.mTransformation.toTHREE(); + + for ( var i = 0; i < this.mChildren.length; i ++ ) { + + o.add( this.mChildren[ i ].toTHREE( scene ) ); + + } + + for ( var i = 0; i < this.mMeshes.length; i ++ ) { + + o.add( scene.mMeshes[ this.mMeshes[ i ] ].toTHREE( scene ) ); + + } + + this.threeNode = o; + //o.matrixAutoUpdate = false; + o.matrix.decompose( o.position, o.quaternion, o.scale ); + return o; + + }; + + } + + function aiBone() { + + this.mName = ''; + this.mNumWeights = 0; + this.mOffsetMatrix = 0; + + } + + function aiMaterialProperty() { + + this.mKey = ""; + this.mSemantic = 0; + this.mIndex = 0; + this.mData = []; + this.mDataLength = 0; + this.mType = 0; + this.dataAsColor = function () { + + var array = ( new Uint8Array( this.mData ) ).buffer; + var reader = new DataView( array ); + var r = reader.getFloat32( 0, true ); + var g = reader.getFloat32( 4, true ); + var b = reader.getFloat32( 8, true ); + //var a = reader.getFloat32(12, true); + return new THREE.Color( r, g, b ); + + }; + + this.dataAsFloat = function () { + + var array = ( new Uint8Array( this.mData ) ).buffer; + var reader = new DataView( array ); + var r = reader.getFloat32( 0, true ); + return r; + + }; + + this.dataAsBool = function () { + + var array = ( new Uint8Array( this.mData ) ).buffer; + var reader = new DataView( array ); + var r = reader.getFloat32( 0, true ); + return !! r; + + }; + + this.dataAsString = function () { + + var s = new aiString(); + s.data = this.mData; + return s.toString(); + + }; + + this.dataAsMap = function () { + + var s = new aiString(); + s.data = this.mData; + var path = s.toString(); + path = path.replace( /\\/g, '/' ); + + if ( path.indexOf( '/' ) != - 1 ) { + + path = path.substr( path.lastIndexOf( '/' ) + 1 ); + + } + + return textureLoader.load( path ); + + }; + + } + var namePropMapping = { + + "?mat.name": "name", + "$mat.shadingm": "shading", + "$mat.twosided": "twoSided", + "$mat.wireframe": "wireframe", + "$clr.ambient": "ambient", + "$clr.diffuse": "color", + "$clr.specular": "specular", + "$clr.emissive": "emissive", + "$clr.transparent": "transparent", + "$clr.reflective": "reflect", + "$mat.shininess": "shininess", + "$mat.reflectivity": "reflectivity", + "$mat.refracti": "refraction", + "$tex.file": "map" + + }; + + var nameTypeMapping = { + + "?mat.name": "string", + "$mat.shadingm": "bool", + "$mat.twosided": "bool", + "$mat.wireframe": "bool", + "$clr.ambient": "color", + "$clr.diffuse": "color", + "$clr.specular": "color", + "$clr.emissive": "color", + "$clr.transparent": "color", + "$clr.reflective": "color", + "$mat.shininess": "float", + "$mat.reflectivity": "float", + "$mat.refracti": "float", + "$tex.file": "map" + + }; + + function aiMaterial() { + + this.mNumAllocated = 0; + this.mNumProperties = 0; + this.mProperties = []; + this.toTHREE = function ( scene ) { + + var name = this.mProperties[ 0 ].dataAsString(); + var mat = new THREE.MeshPhongMaterial(); + + for ( var i = 0; i < this.mProperties.length; i ++ ) { + + if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'float' ) + mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsFloat(); + if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'color' ) + mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsColor(); + if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'bool' ) + mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsBool(); + if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'string' ) + mat[ namePropMapping[ this.mProperties[ i ].mKey ] ] = this.mProperties[ i ].dataAsString(); + if ( nameTypeMapping[ this.mProperties[ i ].mKey ] == 'map' ) { + + var prop = this.mProperties[ i ]; + if ( prop.mSemantic == aiTextureType_DIFFUSE ) + mat.map = this.mProperties[ i ].dataAsMap(); + if ( prop.mSemantic == aiTextureType_NORMALS ) + mat.normalMap = this.mProperties[ i ].dataAsMap(); + if ( prop.mSemantic == aiTextureType_LIGHTMAP ) + mat.lightMap = this.mProperties[ i ].dataAsMap(); + if ( prop.mSemantic == aiTextureType_OPACITY ) + mat.alphaMap = this.mProperties[ i ].dataAsMap(); + + } + + } + + mat.ambient.r = .53; + mat.ambient.g = .53; + mat.ambient.b = .53; + mat.color.r = 1; + mat.color.g = 1; + mat.color.b = 1; + return mat; + + }; + + } + + + function veclerp( v1, v2, l ) { + + var v = new THREE.Vector3(); + var lm1 = 1 - l; + v.x = v1.x * l + v2.x * lm1; + v.y = v1.y * l + v2.y * lm1; + v.z = v1.z * l + v2.z * lm1; + return v; + + } + + function quatlerp( q1, q2, l ) { + + return q1.clone().slerp( q2, 1 - l ); + + } + + function sampleTrack( keys, time, lne, lerp ) { + + if ( keys.length == 1 ) return keys[ 0 ].mValue.toTHREE(); + + var dist = Infinity; + var key = null; + var nextKey = null; + + for ( var i = 0; i < keys.length; i ++ ) { + + var timeDist = Math.abs( keys[ i ].mTime - time ); + + if ( timeDist < dist && keys[ i ].mTime <= time ) { + + dist = timeDist; + key = keys[ i ]; + nextKey = keys[ i + 1 ]; + + } + + } + + if ( ! key ) { + + return null; + + } else if ( nextKey ) { + + var dT = nextKey.mTime - key.mTime; + var T = key.mTime - time; + var l = T / dT; + + return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l ); + + } else { + + nextKey = keys[ 0 ].clone(); + nextKey.mTime += lne; + + var dT = nextKey.mTime - key.mTime; + var T = key.mTime - time; + var l = T / dT; + + return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l ); + + } + + } + + function aiNodeAnim() { + + this.mNodeName = ""; + this.mNumPositionKeys = 0; + this.mNumRotationKeys = 0; + this.mNumScalingKeys = 0; + this.mPositionKeys = []; + this.mRotationKeys = []; + this.mScalingKeys = []; + this.mPreState = ""; + this.mPostState = ""; + this.init = function ( tps ) { + + if ( ! tps ) tps = 1; + + function t( t ) { + + t.mTime /= tps; + + } + + this.mPositionKeys.forEach( t ); + this.mRotationKeys.forEach( t ); + this.mScalingKeys.forEach( t ); + + }; + + this.sortKeys = function () { + + function comp( a, b ) { + + return a.mTime - b.mTime; + + } + + this.mPositionKeys.sort( comp ); + this.mRotationKeys.sort( comp ); + this.mScalingKeys.sort( comp ); + + }; + + this.getLength = function () { + + return Math.max( + Math.max.apply( null, this.mPositionKeys.map( function ( a ) { + + return a.mTime; + + } ) ), + Math.max.apply( null, this.mRotationKeys.map( function ( a ) { + + return a.mTime; + + } ) ), + Math.max.apply( null, this.mScalingKeys.map( function ( a ) { + + return a.mTime; + + } ) ) + ); + + }; + + this.toTHREE = function ( o, tps ) { + + this.sortKeys(); + var length = this.getLength(); + var track = new Virtulous.KeyFrameTrack(); + + for ( var i = 0; i < length; i += .05 ) { + + var matrix = new THREE.Matrix4(); + var time = i; + var pos = sampleTrack( this.mPositionKeys, time, length, veclerp ); + var scale = sampleTrack( this.mScalingKeys, time, length, veclerp ); + var rotation = sampleTrack( this.mRotationKeys, time, length, quatlerp ); + matrix.compose( pos, rotation, scale ); + + var key = new Virtulous.KeyFrame( time, matrix ); + track.addKey( key ); + + } + + track.target = o.findNode( this.mNodeName ).toTHREE(); + + var tracks = [ track ]; + + if ( o.nodeToBoneMap[ this.mNodeName ] ) { + + for ( var i = 0; i < o.nodeToBoneMap[ this.mNodeName ].length; i ++ ) { + + var t2 = track.clone(); + t2.target = o.nodeToBoneMap[ this.mNodeName ][ i ]; + tracks.push( t2 ); + + } + + } + + return tracks; + + }; + + } + + function aiAnimation() { + + this.mName = ""; + this.mDuration = 0; + this.mTicksPerSecond = 0; + this.mNumChannels = 0; + this.mChannels = []; + this.toTHREE = function ( root ) { + + var animationHandle = new Virtulous.Animation(); + + for ( var i in this.mChannels ) { + + this.mChannels[ i ].init( this.mTicksPerSecond ); + + var tracks = this.mChannels[ i ].toTHREE( root ); + + for ( var j in tracks ) { + + tracks[ j ].init(); + animationHandle.addTrack( tracks[ j ] ); + + } + + } + + animationHandle.length = Math.max.apply( null, animationHandle.tracks.map( function ( e ) { + + return e.length; + + } ) ); + return animationHandle; + + }; + + } + + function aiTexture() { + + this.mWidth = 0; + this.mHeight = 0; + this.texAchFormatHint = []; + this.pcData = []; + + } + + function aiLight() { + + this.mName = ''; + this.mType = 0; + this.mAttenuationConstant = 0; + this.mAttenuationLinear = 0; + this.mAttenuationQuadratic = 0; + this.mAngleInnerCone = 0; + this.mAngleOuterCone = 0; + this.mColorDiffuse = null; + this.mColorSpecular = null; + this.mColorAmbient = null; + + } + + function aiCamera() { + + this.mName = ''; + this.mPosition = null; + this.mLookAt = null; + this.mUp = null; + this.mHorizontalFOV = 0; + this.mClipPlaneNear = 0; + this.mClipPlaneFar = 0; + this.mAspect = 0; + + } + + function aiScene() { + + this.mFlags = 0; + this.mNumMeshes = 0; + this.mNumMaterials = 0; + this.mNumAnimations = 0; + this.mNumTextures = 0; + this.mNumLights = 0; + this.mNumCameras = 0; + this.mRootNode = null; + this.mMeshes = []; + this.mMaterials = []; + this.mAnimations = []; + this.mLights = []; + this.mCameras = []; + this.nodeToBoneMap = {}; + this.findNode = function ( name, root ) { + + if ( ! root ) { + + root = this.mRootNode; + + } + + if ( root.mName == name ) { + + return root; + + } + + for ( var i = 0; i < root.mChildren.length; i ++ ) { + + var ret = this.findNode( name, root.mChildren[ i ] ); + if ( ret ) return ret; + + } + + return null; + + }; + + this.toTHREE = function () { + + this.nodeCount = 0; + + markBones( this ); + + var o = this.mRootNode.toTHREE( this ); + + for ( var i in this.mMeshes ) + this.mMeshes[ i ].hookupSkeletons( this, o ); + + if ( this.mAnimations.length > 0 ) { + + var a = this.mAnimations[ 0 ].toTHREE( this ); + + } + + return { object: o, animation: a }; + + }; + + } + + function aiMatrix4() { + + this.elements = [ + [], + [], + [], + [] + ]; + this.toTHREE = function () { + + var m = new THREE.Matrix4(); + + for ( var i = 0; i < 4; ++ i ) { + + for ( var i2 = 0; i2 < 4; ++ i2 ) { + + m.elements[ i * 4 + i2 ] = this.elements[ i2 ][ i ]; + + } + + } + + return m; + + }; + + } + + var littleEndian = true; + + function readFloat( dataview ) { + + var val = dataview.getFloat32( dataview.readOffset, littleEndian ); + dataview.readOffset += 4; + return val; + + } + + function Read_double( dataview ) { + + var val = dataview.getFloat64( dataview.readOffset, littleEndian ); + dataview.readOffset += 8; + return val; + + } + + function Read_uint8_t( dataview ) { + + var val = dataview.getUint8( dataview.readOffset ); + dataview.readOffset += 1; + return val; + + } + + function Read_uint16_t( dataview ) { + + var val = dataview.getUint16( dataview.readOffset, littleEndian ); + dataview.readOffset += 2; + return val; + + } + + function Read_unsigned_int( dataview ) { + + var val = dataview.getUint32( dataview.readOffset, littleEndian ); + dataview.readOffset += 4; + return val; + + } + + function Read_uint32_t( dataview ) { + + var val = dataview.getUint32( dataview.readOffset, littleEndian ); + dataview.readOffset += 4; + return val; + + } + + function Read_aiVector3D( stream ) { + + var v = new aiVector3D(); + v.x = readFloat( stream ); + v.y = readFloat( stream ); + v.z = readFloat( stream ); + return v; + + } + + function Read_aiVector2D( stream ) { + + var v = new aiVector2D(); + v.x = readFloat( stream ); + v.y = readFloat( stream ); + return v; + + } + + function Read_aiVector4D( stream ) { + + var v = new aiVector4D(); + v.w = readFloat( stream ); + v.x = readFloat( stream ); + v.y = readFloat( stream ); + v.z = readFloat( stream ); + return v; + + } + + function Read_aiColor3D( stream ) { + + var c = new aiColor3D(); + c.r = readFloat( stream ); + c.g = readFloat( stream ); + c.b = readFloat( stream ); + return c; + + } + + function Read_aiColor4D( stream ) { + + var c = new aiColor4D(); + c.r = readFloat( stream ); + c.g = readFloat( stream ); + c.b = readFloat( stream ); + c.a = readFloat( stream ); + return c; + + } + + function Read_aiQuaternion( stream ) { + + var v = new aiQuaternion(); + v.w = readFloat( stream ); + v.x = readFloat( stream ); + v.y = readFloat( stream ); + v.z = readFloat( stream ); + return v; + + } + + function Read_aiString( stream ) { + + var s = new aiString(); + var stringlengthbytes = Read_unsigned_int( stream ); + stream.ReadBytes( s.data, 1, stringlengthbytes ); + return s.toString(); + + } + + function Read_aiVertexWeight( stream ) { + + var w = new aiVertexWeight(); + w.mVertexId = Read_unsigned_int( stream ); + w.mWeight = readFloat( stream ); + return w; + + } + + function Read_aiMatrix4x4( stream ) { + + var m = new aiMatrix4(); + + for ( var i = 0; i < 4; ++ i ) { + + for ( var i2 = 0; i2 < 4; ++ i2 ) { + + m.elements[ i ][ i2 ] = readFloat( stream ); + + } + + } + + return m; + + } + + function Read_aiVectorKey( stream ) { + + var v = new aiVectorKey(); + v.mTime = Read_double( stream ); + v.mValue = Read_aiVector3D( stream ); + return v; + + } + + function Read_aiQuatKey( stream ) { + + var v = new aiQuatKey(); + v.mTime = Read_double( stream ); + v.mValue = Read_aiQuaternion( stream ); + return v; + + } + + function ReadArray( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read( stream ); + + } + + function ReadArray_aiVector2D( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector2D( stream ); + + } + + function ReadArray_aiVector3D( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector3D( stream ); + + } + + function ReadArray_aiVector4D( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVector4D( stream ); + + } + + function ReadArray_aiVertexWeight( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVertexWeight( stream ); + + } + + function ReadArray_aiColor4D( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiColor4D( stream ); + + } + + function ReadArray_aiVectorKey( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiVectorKey( stream ); + + } + + function ReadArray_aiQuatKey( stream, data, size ) { + + for ( var i = 0; i < size; i ++ ) data[ i ] = Read_aiQuatKey( stream ); + + } + + function ReadBounds( stream, T /*p*/, n ) { + + // not sure what to do here, the data isn't really useful. + return stream.Seek( sizeof( T ) * n, aiOrigin_CUR ); + + } + + function ai_assert( bool ) { + + if ( ! bool ) + throw ( "asset failed" ); + + } + + function ReadBinaryNode( stream, parent, depth ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AINODE ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + var node = new aiNode(); + node.mParent = parent; + node.mDepth = depth; + node.mName = Read_aiString( stream ); + node.mTransformation = Read_aiMatrix4x4( stream ); + node.mNumChildren = Read_unsigned_int( stream ); + node.mNumMeshes = Read_unsigned_int( stream ); + + if ( node.mNumMeshes ) { + + node.mMeshes = []; + + for ( var i = 0; i < node.mNumMeshes; ++ i ) { + + node.mMeshes[ i ] = Read_unsigned_int( stream ); + + } + + } + + if ( node.mNumChildren ) { + + node.mChildren = []; + + for ( var i = 0; i < node.mNumChildren; ++ i ) { + + var node2 = ReadBinaryNode( stream, node, depth ++ ); + node.mChildren[ i ] = node2; + + } + + } + + return node; + + } + + // ----------------------------------------------------------------------------------- + + function ReadBinaryBone( stream, b ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AIBONE ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + b.mName = Read_aiString( stream ); + b.mNumWeights = Read_unsigned_int( stream ); + b.mOffsetMatrix = Read_aiMatrix4x4( stream ); + // for the moment we write dumb min/max values for the bones, too. + // maybe I'll add a better, hash-like solution later + if ( shortened ) { + + ReadBounds( stream, b.mWeights, b.mNumWeights ); + + } else { + + // else write as usual + + b.mWeights = []; + ReadArray_aiVertexWeight( stream, b.mWeights, b.mNumWeights ); + + } + + return b; + + } + + function ReadBinaryMesh( stream, mesh ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AIMESH ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + mesh.mPrimitiveTypes = Read_unsigned_int( stream ); + mesh.mNumVertices = Read_unsigned_int( stream ); + mesh.mNumFaces = Read_unsigned_int( stream ); + mesh.mNumBones = Read_unsigned_int( stream ); + mesh.mMaterialIndex = Read_unsigned_int( stream ); + mesh.mNumUVComponents = []; + // first of all, write bits for all existent vertex components + var c = Read_unsigned_int( stream ); + + if ( c & ASSBIN_MESH_HAS_POSITIONS ) { + + if ( shortened ) { + + ReadBounds( stream, mesh.mVertices, mesh.mNumVertices ); + + } else { + + // else write as usual + + mesh.mVertices = []; + mesh.mVertexBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); + stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); + + } + + } + + if ( c & ASSBIN_MESH_HAS_NORMALS ) { + + if ( shortened ) { + + ReadBounds( stream, mesh.mNormals, mesh.mNumVertices ); + + } else { + + // else write as usual + + mesh.mNormals = []; + mesh.mNormalBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); + stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); + + } + + } + + if ( c & ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS ) { + + if ( shortened ) { + + ReadBounds( stream, mesh.mTangents, mesh.mNumVertices ); + ReadBounds( stream, mesh.mBitangents, mesh.mNumVertices ); + + } else { + + // else write as usual + + mesh.mTangents = []; + mesh.mTangentBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); + stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); + mesh.mBitangents = []; + mesh.mBitangentBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 3 * 4 ); + stream.Seek( mesh.mNumVertices * 3 * 4, aiOrigin_CUR ); + + } + + } + + for ( var n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS; ++ n ) { + + if ( ! ( c & ASSBIN_MESH_HAS_COLOR( n ) ) ) break; + + if ( shortened ) { + + ReadBounds( stream, mesh.mColors[ n ], mesh.mNumVertices ); + + } else { + + // else write as usual + + mesh.mColors[ n ] = []; + mesh.mColorBuffer = stream.subArray32( stream.readOffset, stream.readOffset + mesh.mNumVertices * 4 * 4 ); + stream.Seek( mesh.mNumVertices * 4 * 4, aiOrigin_CUR ); + + } + + } + + mesh.mTexCoordsBuffers = []; + + for ( var n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++ n ) { + + if ( ! ( c & ASSBIN_MESH_HAS_TEXCOORD( n ) ) ) break; + + // write number of UV components + mesh.mNumUVComponents[ n ] = Read_unsigned_int( stream ); + + if ( shortened ) { + + ReadBounds( stream, mesh.mTextureCoords[ n ], mesh.mNumVertices ); + + } else { + + // else write as usual + + mesh.mTextureCoords[ n ] = []; + //note that assbin always writes 3d texcoords + mesh.mTexCoordsBuffers[ n ] = []; + + for ( var uv = 0; uv < mesh.mNumVertices; uv ++ ) { + + mesh.mTexCoordsBuffers[ n ].push( readFloat( stream ) ); + mesh.mTexCoordsBuffers[ n ].push( readFloat( stream ) ); + readFloat( stream ); + + } + + } + + } + // write faces. There are no floating-point calculations involved + // in these, so we can write a simple hash over the face data + // to the dump file. We generate a single 32 Bit hash for 512 faces + // using Assimp's standard hashing function. + if ( shortened ) { + + Read_unsigned_int( stream ); + + } else { + + // else write as usual + + // if there are less than 2^16 vertices, we can simply use 16 bit integers ... + mesh.mFaces = []; + + var indexCounter = 0; + mesh.mIndexArray = []; + + for ( var i = 0; i < mesh.mNumFaces; ++ i ) { + + var f = mesh.mFaces[ i ] = new aiFace(); + // BOOST_STATIC_ASSERT(AI_MAX_FACE_INDICES <= 0xffff); + f.mNumIndices = Read_uint16_t( stream ); + f.mIndices = []; + + for ( var a = 0; a < f.mNumIndices; ++ a ) { + + if ( mesh.mNumVertices < ( 1 << 16 ) ) { + + f.mIndices[ a ] = Read_uint16_t( stream ); + + } else { + + f.mIndices[ a ] = Read_unsigned_int( stream ); + + } + + + + } + + if ( f.mNumIndices === 3 ) { + + mesh.mIndexArray.push( f.mIndices[ 0 ] ); + mesh.mIndexArray.push( f.mIndices[ 1 ] ); + mesh.mIndexArray.push( f.mIndices[ 2 ] ); + + } else if ( f.mNumIndices === 4 ) { + + mesh.mIndexArray.push( f.mIndices[ 0 ] ); + mesh.mIndexArray.push( f.mIndices[ 1 ] ); + mesh.mIndexArray.push( f.mIndices[ 2 ] ); + mesh.mIndexArray.push( f.mIndices[ 2 ] ); + mesh.mIndexArray.push( f.mIndices[ 3 ] ); + mesh.mIndexArray.push( f.mIndices[ 0 ] ); + + } else { + + throw ( new Error( "Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp." ) ); + + } + + + + } + + } + // write bones + if ( mesh.mNumBones ) { + + mesh.mBones = []; + + for ( var a = 0; a < mesh.mNumBones; ++ a ) { + + mesh.mBones[ a ] = new aiBone(); + ReadBinaryBone( stream, mesh.mBones[ a ] ); + + } + + } + + } + + function ReadBinaryMaterialProperty( stream, prop ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + prop.mKey = Read_aiString( stream ); + prop.mSemantic = Read_unsigned_int( stream ); + prop.mIndex = Read_unsigned_int( stream ); + prop.mDataLength = Read_unsigned_int( stream ); + prop.mType = Read_unsigned_int( stream ); + prop.mData = []; + stream.ReadBytes( prop.mData, 1, prop.mDataLength ); + + } + + // ----------------------------------------------------------------------------------- + + function ReadBinaryMaterial( stream, mat ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AIMATERIAL ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + mat.mNumAllocated = mat.mNumProperties = Read_unsigned_int( stream ); + + if ( mat.mNumProperties ) { + + if ( mat.mProperties ) { + + delete mat.mProperties; + + } + + mat.mProperties = []; + + for ( var i = 0; i < mat.mNumProperties; ++ i ) { + + mat.mProperties[ i ] = new aiMaterialProperty(); + ReadBinaryMaterialProperty( stream, mat.mProperties[ i ] ); + + } + + } + + } + // ----------------------------------------------------------------------------------- + function ReadBinaryNodeAnim( stream, nd ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AINODEANIM ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + nd.mNodeName = Read_aiString( stream ); + nd.mNumPositionKeys = Read_unsigned_int( stream ); + nd.mNumRotationKeys = Read_unsigned_int( stream ); + nd.mNumScalingKeys = Read_unsigned_int( stream ); + nd.mPreState = Read_unsigned_int( stream ); + nd.mPostState = Read_unsigned_int( stream ); + + if ( nd.mNumPositionKeys ) { + + if ( shortened ) { + + ReadBounds( stream, nd.mPositionKeys, nd.mNumPositionKeys ); + + } else { + + // else write as usual + + nd.mPositionKeys = []; + ReadArray_aiVectorKey( stream, nd.mPositionKeys, nd.mNumPositionKeys ); + + } + + } + + if ( nd.mNumRotationKeys ) { + + if ( shortened ) { + + ReadBounds( stream, nd.mRotationKeys, nd.mNumRotationKeys ); + + } else { + + // else write as usual + + nd.mRotationKeys = []; + ReadArray_aiQuatKey( stream, nd.mRotationKeys, nd.mNumRotationKeys ); + + } + + } + + if ( nd.mNumScalingKeys ) { + + if ( shortened ) { + + ReadBounds( stream, nd.mScalingKeys, nd.mNumScalingKeys ); + + } else { + + // else write as usual + + nd.mScalingKeys = []; + ReadArray_aiVectorKey( stream, nd.mScalingKeys, nd.mNumScalingKeys ); + + } + + } + + } + // ----------------------------------------------------------------------------------- + function ReadBinaryAnim( stream, anim ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AIANIMATION ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + anim.mName = Read_aiString( stream ); + anim.mDuration = Read_double( stream ); + anim.mTicksPerSecond = Read_double( stream ); + anim.mNumChannels = Read_unsigned_int( stream ); + + if ( anim.mNumChannels ) { + + anim.mChannels = []; + + for ( var a = 0; a < anim.mNumChannels; ++ a ) { + + anim.mChannels[ a ] = new aiNodeAnim(); + ReadBinaryNodeAnim( stream, anim.mChannels[ a ] ); + + } + + } + + } + + function ReadBinaryTexture( stream, tex ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AITEXTURE ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + tex.mWidth = Read_unsigned_int( stream ); + tex.mHeight = Read_unsigned_int( stream ); + stream.ReadBytes( tex.achFormatHint, 1, 4 ); + + if ( ! shortened ) { + + if ( ! tex.mHeight ) { + + tex.pcData = []; + stream.ReadBytes( tex.pcData, 1, tex.mWidth ); + + } else { + + tex.pcData = []; + stream.ReadBytes( tex.pcData, 1, tex.mWidth * tex.mHeight * 4 ); + + } + + } + + } + // ----------------------------------------------------------------------------------- + function ReadBinaryLight( stream, l ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AILIGHT ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + l.mName = Read_aiString( stream ); + l.mType = Read_unsigned_int( stream ); + + if ( l.mType != aiLightSource_DIRECTIONAL ) { + + l.mAttenuationConstant = readFloat( stream ); + l.mAttenuationLinear = readFloat( stream ); + l.mAttenuationQuadratic = readFloat( stream ); + + } + + l.mColorDiffuse = Read_aiColor3D( stream ); + l.mColorSpecular = Read_aiColor3D( stream ); + l.mColorAmbient = Read_aiColor3D( stream ); + + if ( l.mType == aiLightSource_SPOT ) { + + l.mAngleInnerCone = readFloat( stream ); + l.mAngleOuterCone = readFloat( stream ); + + } + + } + // ----------------------------------------------------------------------------------- + function ReadBinaryCamera( stream, cam ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AICAMERA ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + cam.mName = Read_aiString( stream ); + cam.mPosition = Read_aiVector3D( stream ); + cam.mLookAt = Read_aiVector3D( stream ); + cam.mUp = Read_aiVector3D( stream ); + cam.mHorizontalFOV = readFloat( stream ); + cam.mClipPlaneNear = readFloat( stream ); + cam.mClipPlaneFar = readFloat( stream ); + cam.mAspect = readFloat( stream ); + + } + + function ReadBinaryScene( stream, scene ) { + + var chunkID = Read_uint32_t( stream ); + ai_assert( chunkID == ASSBIN_CHUNK_AISCENE ); + /*uint32_t size =*/ + Read_uint32_t( stream ); + scene.mFlags = Read_unsigned_int( stream ); + scene.mNumMeshes = Read_unsigned_int( stream ); + scene.mNumMaterials = Read_unsigned_int( stream ); + scene.mNumAnimations = Read_unsigned_int( stream ); + scene.mNumTextures = Read_unsigned_int( stream ); + scene.mNumLights = Read_unsigned_int( stream ); + scene.mNumCameras = Read_unsigned_int( stream ); + // Read node graph + scene.mRootNode = new aiNode(); + scene.mRootNode = ReadBinaryNode( stream, null, 0 ); + // Read all meshes + if ( scene.mNumMeshes ) { + + scene.mMeshes = []; + + for ( var i = 0; i < scene.mNumMeshes; ++ i ) { + + scene.mMeshes[ i ] = new aiMesh(); + ReadBinaryMesh( stream, scene.mMeshes[ i ] ); + + } + + } + // Read materials + if ( scene.mNumMaterials ) { + + scene.mMaterials = []; + + for ( var i = 0; i < scene.mNumMaterials; ++ i ) { + + scene.mMaterials[ i ] = new aiMaterial(); + ReadBinaryMaterial( stream, scene.mMaterials[ i ] ); + + } + + } + // Read all animations + if ( scene.mNumAnimations ) { + + scene.mAnimations = []; + + for ( var i = 0; i < scene.mNumAnimations; ++ i ) { + + scene.mAnimations[ i ] = new aiAnimation(); + ReadBinaryAnim( stream, scene.mAnimations[ i ] ); + + } + + } + // Read all textures + if ( scene.mNumTextures ) { + + scene.mTextures = []; + + for ( var i = 0; i < scene.mNumTextures; ++ i ) { + + scene.mTextures[ i ] = new aiTexture(); + ReadBinaryTexture( stream, scene.mTextures[ i ] ); + + } + + } + // Read lights + if ( scene.mNumLights ) { + + scene.mLights = []; + + for ( var i = 0; i < scene.mNumLights; ++ i ) { + + scene.mLights[ i ] = new aiLight(); + ReadBinaryLight( stream, scene.mLights[ i ] ); + + } + + } + // Read cameras + if ( scene.mNumCameras ) { + + scene.mCameras = []; + + for ( var i = 0; i < scene.mNumCameras; ++ i ) { + + scene.mCameras[ i ] = new aiCamera(); + ReadBinaryCamera( stream, scene.mCameras[ i ] ); + + } + + } + + } + var aiOrigin_CUR = 0; + var aiOrigin_BEG = 1; + + function extendStream( stream ) { + + stream.readOffset = 0; + stream.Seek = function ( off, ori ) { + + if ( ori == aiOrigin_CUR ) { + + stream.readOffset += off; + + } + if ( ori == aiOrigin_BEG ) { + + stream.readOffset = off; + + } + + }; + + stream.ReadBytes = function ( buff, size, n ) { + + var bytes = size * n; + for ( var i = 0; i < bytes; i ++ ) + buff[ i ] = Read_uint8_t( this ); + + }; + + stream.subArray32 = function ( start, end ) { + + var buff = this.buffer; + var newbuff = buff.slice( start, end ); + return new Float32Array( newbuff ); + + }; + + stream.subArrayUint16 = function ( start, end ) { + + var buff = this.buffer; + var newbuff = buff.slice( start, end ); + return new Uint16Array( newbuff ); + + }; + + stream.subArrayUint8 = function ( start, end ) { + + var buff = this.buffer; + var newbuff = buff.slice( start, end ); + return new Uint8Array( newbuff ); + + }; + + stream.subArrayUint32 = function ( start, end ) { + + var buff = this.buffer; + var newbuff = buff.slice( start, end ); + return new Uint32Array( newbuff ); + + }; + + } + + var shortened, compressed; + + function InternReadFile( pFiledata ) { + + var pScene = new aiScene(); + var stream = new DataView( pFiledata ); + extendStream( stream ); + stream.Seek( 44, aiOrigin_CUR ); // signature + /*unsigned int versionMajor =*/ + var versionMajor = Read_unsigned_int( stream ); + /*unsigned int versionMinor =*/ + var versionMinor = Read_unsigned_int( stream ); + /*unsigned int versionRevision =*/ + var versionRevision = Read_unsigned_int( stream ); + /*unsigned int compileFlags =*/ + var compileFlags = Read_unsigned_int( stream ); + shortened = Read_uint16_t( stream ) > 0; + compressed = Read_uint16_t( stream ) > 0; + if ( shortened ) + throw "Shortened binaries are not supported!"; + stream.Seek( 256, aiOrigin_CUR ); // original filename + stream.Seek( 128, aiOrigin_CUR ); // options + stream.Seek( 64, aiOrigin_CUR ); // padding + if ( compressed ) { + + var uncompressedSize = Read_uint32_t( stream ); + var compressedSize = stream.FileSize() - stream.Tell(); + var compressedData = []; + stream.Read( compressedData, 1, compressedSize ); + var uncompressedData = []; + uncompress( uncompressedData, uncompressedSize, compressedData, compressedSize ); + var buff = new ArrayBuffer( uncompressedData ); + ReadBinaryScene( buff, pScene ); + + } else { + + ReadBinaryScene( stream, pScene ); + return pScene.toTHREE(); + + } + + } + + return InternReadFile( buffer ); + + } + +}; diff --git a/three/jsutil/loaders/BVHLoader.js b/three/jsutil/loaders/BVHLoader.js new file mode 100644 index 000000000..a0461e2ae --- /dev/null +++ b/three/jsutil/loaders/BVHLoader.js @@ -0,0 +1,414 @@ +/** + * @author herzig / http://github.com/herzig + * @author Mugen87 / https://github.com/Mugen87 + * + * Description: reads BVH files and outputs a single THREE.Skeleton and an THREE.AnimationClip + * + * Currently only supports bvh files containing a single root. + * + */ + +THREE.BVHLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.animateBonePositions = true; + this.animateBoneRotations = true; + +}; + +THREE.BVHLoader.prototype = { + + constructor: THREE.BVHLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( text ) { + + /* + reads a string array (lines) from a BVH file + and outputs a skeleton structure including motion data + + returns thee root node: + { name: '', channels: [], children: [] } + */ + function readBvh( lines ) { + + // read model structure + + if ( nextLine( lines ) !== 'HIERARCHY' ) { + + console.error( 'THREE.BVHLoader: HIERARCHY expected.' ); + + } + + var list = []; // collects flat array of all bones + var root = readNode( lines, nextLine( lines ), list ); + + // read motion data + + if ( nextLine( lines ) !== 'MOTION' ) { + + console.error( 'THREE.BVHLoader: MOTION expected.' ); + + } + + // number of frames + + var tokens = nextLine( lines ).split( /[\s]+/ ); + var numFrames = parseInt( tokens[ 1 ] ); + + if ( isNaN( numFrames ) ) { + + console.error( 'THREE.BVHLoader: Failed to read number of frames.' ); + + } + + // frame time + + tokens = nextLine( lines ).split( /[\s]+/ ); + var frameTime = parseFloat( tokens[ 2 ] ); + + if ( isNaN( frameTime ) ) { + + console.error( 'THREE.BVHLoader: Failed to read frame time.' ); + + } + + // read frame data line by line + + for ( var i = 0; i < numFrames; i ++ ) { + + tokens = nextLine( lines ).split( /[\s]+/ ); + readFrameData( tokens, i * frameTime, root ); + + } + + return list; + + } + + /* + Recursively reads data from a single frame into the bone hierarchy. + The passed bone hierarchy has to be structured in the same order as the BVH file. + keyframe data is stored in bone.frames. + + - data: splitted string array (frame values), values are shift()ed so + this should be empty after parsing the whole hierarchy. + - frameTime: playback time for this keyframe. + - bone: the bone to read frame data from. + */ + function readFrameData( data, frameTime, bone ) { + + // end sites have no motion data + + if ( bone.type === 'ENDSITE' ) return; + + // add keyframe + + var keyframe = { + time: frameTime, + position: new THREE.Vector3(), + rotation: new THREE.Quaternion() + }; + + bone.frames.push( keyframe ); + + var quat = new THREE.Quaternion(); + + var vx = new THREE.Vector3( 1, 0, 0 ); + var vy = new THREE.Vector3( 0, 1, 0 ); + var vz = new THREE.Vector3( 0, 0, 1 ); + + // parse values for each channel in node + + for ( var i = 0; i < bone.channels.length; i ++ ) { + + switch ( bone.channels[ i ] ) { + + case 'Xposition': + keyframe.position.x = parseFloat( data.shift().trim() ); + break; + case 'Yposition': + keyframe.position.y = parseFloat( data.shift().trim() ); + break; + case 'Zposition': + keyframe.position.z = parseFloat( data.shift().trim() ); + break; + case 'Xrotation': + quat.setFromAxisAngle( vx, parseFloat( data.shift().trim() ) * Math.PI / 180 ); + keyframe.rotation.multiply( quat ); + break; + case 'Yrotation': + quat.setFromAxisAngle( vy, parseFloat( data.shift().trim() ) * Math.PI / 180 ); + keyframe.rotation.multiply( quat ); + break; + case 'Zrotation': + quat.setFromAxisAngle( vz, parseFloat( data.shift().trim() ) * Math.PI / 180 ); + keyframe.rotation.multiply( quat ); + break; + default: + console.warn( 'THREE.BVHLoader: Invalid channel type.' ); + + } + + } + + // parse child nodes + + for ( var i = 0; i < bone.children.length; i ++ ) { + + readFrameData( data, frameTime, bone.children[ i ] ); + + } + + } + + /* + Recursively parses the HIERACHY section of the BVH file + + - lines: all lines of the file. lines are consumed as we go along. + - firstline: line containing the node type and name e.g. 'JOINT hip' + - list: collects a flat list of nodes + + returns: a BVH node including children + */ + function readNode( lines, firstline, list ) { + + var node = { name: '', type: '', frames: [] }; + list.push( node ); + + // parse node type and name + + var tokens = firstline.split( /[\s]+/ ); + + if ( tokens[ 0 ].toUpperCase() === 'END' && tokens[ 1 ].toUpperCase() === 'SITE' ) { + + node.type = 'ENDSITE'; + node.name = 'ENDSITE'; // bvh end sites have no name + + } else { + + node.name = tokens[ 1 ]; + node.type = tokens[ 0 ].toUpperCase(); + + } + + if ( nextLine( lines ) !== '{' ) { + + console.error( 'THREE.BVHLoader: Expected opening { after type & name' ); + + } + + // parse OFFSET + + tokens = nextLine( lines ).split( /[\s]+/ ); + + if ( tokens[ 0 ] !== 'OFFSET' ) { + + console.error( 'THREE.BVHLoader: Expected OFFSET but got: ' + tokens[ 0 ] ); + + } + + if ( tokens.length !== 4 ) { + + console.error( 'THREE.BVHLoader: Invalid number of values for OFFSET.' ); + + } + + var offset = new THREE.Vector3( + parseFloat( tokens[ 1 ] ), + parseFloat( tokens[ 2 ] ), + parseFloat( tokens[ 3 ] ) + ); + + if ( isNaN( offset.x ) || isNaN( offset.y ) || isNaN( offset.z ) ) { + + console.error( 'THREE.BVHLoader: Invalid values of OFFSET.' ); + + } + + node.offset = offset; + + // parse CHANNELS definitions + + if ( node.type !== 'ENDSITE' ) { + + tokens = nextLine( lines ).split( /[\s]+/ ); + + if ( tokens[ 0 ] !== 'CHANNELS' ) { + + console.error( 'THREE.BVHLoader: Expected CHANNELS definition.' ); + + } + + var numChannels = parseInt( tokens[ 1 ] ); + node.channels = tokens.splice( 2, numChannels ); + node.children = []; + + } + + // read children + + while ( true ) { + + var line = nextLine( lines ); + + if ( line === '}' ) { + + return node; + + } else { + + node.children.push( readNode( lines, line, list ) ); + + } + + } + + } + + /* + recursively converts the internal bvh node structure to a THREE.Bone hierarchy + + source: the bvh root node + list: pass an empty array, collects a flat list of all converted THREE.Bones + + returns the root THREE.Bone + */ + function toTHREEBone( source, list ) { + + var bone = new THREE.Bone(); + list.push( bone ); + + bone.position.add( source.offset ); + bone.name = source.name; + + if ( source.type !== 'ENDSITE' ) { + + for ( var i = 0; i < source.children.length; i ++ ) { + + bone.add( toTHREEBone( source.children[ i ], list ) ); + + } + + } + + return bone; + + } + + /* + builds a THREE.AnimationClip from the keyframe data saved in each bone. + + bone: bvh root node + + returns: a THREE.AnimationClip containing position and quaternion tracks + */ + function toTHREEAnimation( bones ) { + + var tracks = []; + + // create a position and quaternion animation track for each node + + for ( var i = 0; i < bones.length; i ++ ) { + + var bone = bones[ i ]; + + if ( bone.type === 'ENDSITE' ) + continue; + + // track data + + var times = []; + var positions = []; + var rotations = []; + + for ( var j = 0; j < bone.frames.length; j ++ ) { + + var frame = bone.frames[ j ]; + + times.push( frame.time ); + + // the animation system animates the position property, + // so we have to add the joint offset to all values + + positions.push( frame.position.x + bone.offset.x ); + positions.push( frame.position.y + bone.offset.y ); + positions.push( frame.position.z + bone.offset.z ); + + rotations.push( frame.rotation.x ); + rotations.push( frame.rotation.y ); + rotations.push( frame.rotation.z ); + rotations.push( frame.rotation.w ); + + } + + if ( scope.animateBonePositions ) { + + tracks.push( new THREE.VectorKeyframeTrack( '.bones[' + bone.name + '].position', times, positions ) ); + + } + + if ( scope.animateBoneRotations ) { + + tracks.push( new THREE.QuaternionKeyframeTrack( '.bones[' + bone.name + '].quaternion', times, rotations ) ); + + } + + } + + return new THREE.AnimationClip( 'animation', - 1, tracks ); + + } + + /* + returns the next non-empty line in lines + */ + function nextLine( lines ) { + + var line; + // skip empty lines + while ( ( line = lines.shift().trim() ).length === 0 ) { } + return line; + + } + + var scope = this; + + var lines = text.split( /[\r\n]+/g ); + + var bones = readBvh( lines ); + + var threeBones = []; + toTHREEBone( bones[ 0 ], threeBones ); + + var threeClip = toTHREEAnimation( bones ); + + return { + skeleton: new THREE.Skeleton( threeBones ), + clip: threeClip + }; + + } + +}; diff --git a/three/jsutil/loaders/BabylonLoader.js b/three/jsutil/loaders/BabylonLoader.js new file mode 100644 index 000000000..3eee2e88b --- /dev/null +++ b/three/jsutil/loaders/BabylonLoader.js @@ -0,0 +1,255 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / https://github.com/Mugen87 + */ + +THREE.BabylonLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.BabylonLoader.prototype = { + + constructor: THREE.BabylonLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( json ) { + + function parseMaterials( json ) { + + var materials = {}; + + for ( var i = 0, l = json.materials.length; i < l; i ++ ) { + + var data = json.materials[ i ]; + + var material = new THREE.MeshPhongMaterial(); + material.name = data.name; + material.color.fromArray( data.diffuse ); + material.emissive.fromArray( data.emissive ); + material.specular.fromArray( data.specular ); + material.shininess = data.specularPower; + material.opacity = data.alpha; + + materials[ data.id ] = material; + + } + + if ( json.multiMaterials ) { + + for ( var i = 0, l = json.multiMaterials.length; i < l; i ++ ) { + + var data = json.multiMaterials[ i ]; + + console.warn( 'THREE.BabylonLoader: Multi materials not yet supported.' ); + + materials[ data.id ] = new THREE.MeshPhongMaterial(); + + } + + } + + return materials; + + } + + function parseGeometry( json ) { + + var geometry = new THREE.BufferGeometry(); + + var indices = json.indices; + var positions = json.positions; + var normals = json.normals; + var uvs = json.uvs; + + // indices + + geometry.setIndex( indices ); + + // positions + + for ( var j = 2, jl = positions.length; j < jl; j += 3 ) { + + positions[ j ] = - positions[ j ]; + + } + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + + // normals + + if ( normals ) { + + for ( var j = 2, jl = normals.length; j < jl; j += 3 ) { + + normals[ j ] = - normals[ j ]; + + } + + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + } + + // uvs + + if ( uvs ) { + + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + + } + + // offsets + + var subMeshes = json.subMeshes; + + if ( subMeshes ) { + + for ( var j = 0, jl = subMeshes.length; j < jl; j ++ ) { + + var subMesh = subMeshes[ j ]; + + geometry.addGroup( subMesh.indexStart, subMesh.indexCount ); + + } + + } + + return geometry; + + } + + function parseObjects( json, materials ) { + + var objects = {}; + var scene = new THREE.Scene(); + + var cameras = json.cameras; + + for ( var i = 0, l = cameras.length; i < l; i ++ ) { + + var data = cameras[ i ]; + + var camera = new THREE.PerspectiveCamera( ( data.fov / Math.PI ) * 180, 1.33, data.minZ, data.maxZ ); + + camera.name = data.name; + camera.position.fromArray( data.position ); + if ( data.rotation ) camera.rotation.fromArray( data.rotation ); + + objects[ data.id ] = camera; + + } + + var lights = json.lights; + + for ( var i = 0, l = lights.length; i < l; i ++ ) { + + var data = lights[ i ]; + + var light; + + switch ( data.type ) { + + case 0: + light = new THREE.PointLight(); + break; + + case 1: + light = new THREE.DirectionalLight(); + break; + + case 2: + light = new THREE.SpotLight(); + break; + + case 3: + light = new THREE.HemisphereLight(); + break; + + } + + light.name = data.name; + if ( data.position ) light.position.set( data.position[ 0 ], data.position[ 1 ], - data.position[ 2 ] ); + light.color.fromArray( data.diffuse ); + if ( data.groundColor ) light.groundColor.fromArray( data.groundColor ); + if ( data.intensity ) light.intensity = data.intensity; + + objects[ data.id ] = light; + + scene.add( light ); + + } + + var meshes = json.meshes; + + for ( var i = 0, l = meshes.length; i < l; i ++ ) { + + var data = meshes[ i ]; + + var object; + + if ( data.indices ) { + + var geometry = parseGeometry( data ); + + object = new THREE.Mesh( geometry, materials[ data.materialId ] ); + + } else { + + object = new THREE.Group(); + + } + + object.name = data.name; + object.position.set( data.position[ 0 ], data.position[ 1 ], - data.position[ 2 ] ); + object.rotation.fromArray( data.rotation ); + if ( data.rotationQuaternion ) object.quaternion.fromArray( data.rotationQuaternion ); + object.scale.fromArray( data.scaling ); + // object.visible = data.isVisible; + + if ( data.parentId ) { + + objects[ data.parentId ].add( object ); + + } else { + + scene.add( object ); + + } + + objects[ data.id ] = object; + + } + + return scene; + + } + + var materials = parseMaterials( json ); + var scene = parseObjects( json, materials ); + + return scene; + + } + +}; diff --git a/three/jsutil/loaders/ColladaLoader.js b/three/jsutil/loaders/ColladaLoader.js new file mode 100644 index 000000000..0eee88d51 --- /dev/null +++ b/three/jsutil/loaders/ColladaLoader.js @@ -0,0 +1,3896 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / https://github.com/Mugen87 + */ + +THREE.ColladaLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.ColladaLoader.prototype = { + + constructor: THREE.ColladaLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var path = ( scope.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : scope.path; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text, path ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + options: { + + set convertUpAxis( value ) { + + console.warn( 'THREE.ColladaLoader: options.convertUpAxis() has been removed. Up axis is converted automatically.' ); + + } + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + parse: function ( text, path ) { + + function getElementsByTagName( xml, name ) { + + // Non recursive xml.getElementsByTagName() ... + + var array = []; + var childNodes = xml.childNodes; + + for ( var i = 0, l = childNodes.length; i < l; i ++ ) { + + var child = childNodes[ i ]; + + if ( child.nodeName === name ) { + + array.push( child ); + + } + + } + + return array; + + } + + function parseStrings( text ) { + + if ( text.length === 0 ) return []; + + var parts = text.trim().split( /\s+/ ); + var array = new Array( parts.length ); + + for ( var i = 0, l = parts.length; i < l; i ++ ) { + + array[ i ] = parts[ i ]; + + } + + return array; + + } + + function parseFloats( text ) { + + if ( text.length === 0 ) return []; + + var parts = text.trim().split( /\s+/ ); + var array = new Array( parts.length ); + + for ( var i = 0, l = parts.length; i < l; i ++ ) { + + array[ i ] = parseFloat( parts[ i ] ); + + } + + return array; + + } + + function parseInts( text ) { + + if ( text.length === 0 ) return []; + + var parts = text.trim().split( /\s+/ ); + var array = new Array( parts.length ); + + for ( var i = 0, l = parts.length; i < l; i ++ ) { + + array[ i ] = parseInt( parts[ i ] ); + + } + + return array; + + } + + function parseId( text ) { + + return text.substring( 1 ); + + } + + function generateId() { + + return 'three_default_' + ( count ++ ); + + } + + function isEmpty( object ) { + + return Object.keys( object ).length === 0; + + } + + // asset + + function parseAsset( xml ) { + + return { + unit: parseAssetUnit( getElementsByTagName( xml, 'unit' )[ 0 ] ), + upAxis: parseAssetUpAxis( getElementsByTagName( xml, 'up_axis' )[ 0 ] ) + }; + + } + + function parseAssetUnit( xml ) { + + if ( ( xml !== undefined ) && ( xml.hasAttribute( 'meter' ) === true ) ) { + + return parseFloat( xml.getAttribute( 'meter' ) ); + + } else { + + return 1; // default 1 meter + + } + + } + + function parseAssetUpAxis( xml ) { + + return xml !== undefined ? xml.textContent : 'Y_UP'; + + } + + // library + + function parseLibrary( xml, libraryName, nodeName, parser ) { + + var library = getElementsByTagName( xml, libraryName )[ 0 ]; + + if ( library !== undefined ) { + + var elements = getElementsByTagName( library, nodeName ); + + for ( var i = 0; i < elements.length; i ++ ) { + + parser( elements[ i ] ); + + } + + } + + } + + function buildLibrary( data, builder ) { + + for ( var name in data ) { + + var object = data[ name ]; + object.build = builder( data[ name ] ); + + } + + } + + // get + + function getBuild( data, builder ) { + + if ( data.build !== undefined ) return data.build; + + data.build = builder( data ); + + return data.build; + + } + + // animation + + function parseAnimation( xml ) { + + var data = { + sources: {}, + samplers: {}, + channels: {} + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + var id; + + switch ( child.nodeName ) { + + case 'source': + id = child.getAttribute( 'id' ); + data.sources[ id ] = parseSource( child ); + break; + + case 'sampler': + id = child.getAttribute( 'id' ); + data.samplers[ id ] = parseAnimationSampler( child ); + break; + + case 'channel': + id = child.getAttribute( 'target' ); + data.channels[ id ] = parseAnimationChannel( child ); + break; + + default: + console.log( child ); + + } + + } + + library.animations[ xml.getAttribute( 'id' ) ] = data; + + } + + function parseAnimationSampler( xml ) { + + var data = { + inputs: {}, + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'input': + var id = parseId( child.getAttribute( 'source' ) ); + var semantic = child.getAttribute( 'semantic' ); + data.inputs[ semantic ] = id; + break; + + } + + } + + return data; + + } + + function parseAnimationChannel( xml ) { + + var data = {}; + + var target = xml.getAttribute( 'target' ); + + // parsing SID Addressing Syntax + + var parts = target.split( '/' ); + + var id = parts.shift(); + var sid = parts.shift(); + + // check selection syntax + + var arraySyntax = ( sid.indexOf( '(' ) !== - 1 ); + var memberSyntax = ( sid.indexOf( '.' ) !== - 1 ); + + if ( memberSyntax ) { + + // member selection access + + parts = sid.split( '.' ); + sid = parts.shift(); + data.member = parts.shift(); + + } else if ( arraySyntax ) { + + // array-access syntax. can be used to express fields in one-dimensional vectors or two-dimensional matrices. + + var indices = sid.split( '(' ); + sid = indices.shift(); + + for ( var i = 0; i < indices.length; i ++ ) { + + indices[ i ] = parseInt( indices[ i ].replace( /\)/, '' ) ); + + } + + data.indices = indices; + + } + + data.id = id; + data.sid = sid; + + data.arraySyntax = arraySyntax; + data.memberSyntax = memberSyntax; + + data.sampler = parseId( xml.getAttribute( 'source' ) ); + + return data; + + } + + function buildAnimation( data ) { + + var tracks = []; + + var channels = data.channels; + var samplers = data.samplers; + var sources = data.sources; + + for ( var target in channels ) { + + if ( channels.hasOwnProperty( target ) ) { + + var channel = channels[ target ]; + var sampler = samplers[ channel.sampler ]; + + var inputId = sampler.inputs.INPUT; + var outputId = sampler.inputs.OUTPUT; + + var inputSource = sources[ inputId ]; + var outputSource = sources[ outputId ]; + + var animation = buildAnimationChannel( channel, inputSource, outputSource ); + + createKeyframeTracks( animation, tracks ); + + } + + } + + return tracks; + + } + + function getAnimation( id ) { + + return getBuild( library.animations[ id ], buildAnimation ); + + } + + function buildAnimationChannel( channel, inputSource, outputSource ) { + + var node = library.nodes[ channel.id ]; + var object3D = getNode( node.id ); + + var transform = node.transforms[ channel.sid ]; + var defaultMatrix = node.matrix.clone().transpose(); + + var time, stride; + var i, il, j, jl; + + var data = {}; + + // the collada spec allows the animation of data in various ways. + // depending on the transform type (matrix, translate, rotate, scale), we execute different logic + + switch ( transform ) { + + case 'matrix': + + for ( i = 0, il = inputSource.array.length; i < il; i ++ ) { + + time = inputSource.array[ i ]; + stride = i * outputSource.stride; + + if ( data[ time ] === undefined ) data[ time ] = {}; + + if ( channel.arraySyntax === true ) { + + var value = outputSource.array[ stride ]; + var index = channel.indices[ 0 ] + 4 * channel.indices[ 1 ]; + + data[ time ][ index ] = value; + + } else { + + for ( j = 0, jl = outputSource.stride; j < jl; j ++ ) { + + data[ time ][ j ] = outputSource.array[ stride + j ]; + + } + + } + + } + + break; + + case 'translate': + console.warn( 'THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform ); + break; + + case 'rotate': + console.warn( 'THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform ); + break; + + case 'scale': + console.warn( 'THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', transform ); + break; + + } + + var keyframes = prepareAnimationData( data, defaultMatrix ); + + var animation = { + name: object3D.uuid, + keyframes: keyframes + }; + + return animation; + + } + + function prepareAnimationData( data, defaultMatrix ) { + + var keyframes = []; + + // transfer data into a sortable array + + for ( var time in data ) { + + keyframes.push( { time: parseFloat( time ), value: data[ time ] } ); + + } + + // ensure keyframes are sorted by time + + keyframes.sort( ascending ); + + // now we clean up all animation data, so we can use them for keyframe tracks + + for ( var i = 0; i < 16; i ++ ) { + + transformAnimationData( keyframes, i, defaultMatrix.elements[ i ] ); + + } + + return keyframes; + + // array sort function + + function ascending( a, b ) { + + return a.time - b.time; + + } + + } + + var position = new THREE.Vector3(); + var scale = new THREE.Vector3(); + var quaternion = new THREE.Quaternion(); + + function createKeyframeTracks( animation, tracks ) { + + var keyframes = animation.keyframes; + var name = animation.name; + + var times = []; + var positionData = []; + var quaternionData = []; + var scaleData = []; + + for ( var i = 0, l = keyframes.length; i < l; i ++ ) { + + var keyframe = keyframes[ i ]; + + var time = keyframe.time; + var value = keyframe.value; + + matrix.fromArray( value ).transpose(); + matrix.decompose( position, quaternion, scale ); + + times.push( time ); + positionData.push( position.x, position.y, position.z ); + quaternionData.push( quaternion.x, quaternion.y, quaternion.z, quaternion.w ); + scaleData.push( scale.x, scale.y, scale.z ); + + } + + if ( positionData.length > 0 ) tracks.push( new THREE.VectorKeyframeTrack( name + '.position', times, positionData ) ); + if ( quaternionData.length > 0 ) tracks.push( new THREE.QuaternionKeyframeTrack( name + '.quaternion', times, quaternionData ) ); + if ( scaleData.length > 0 ) tracks.push( new THREE.VectorKeyframeTrack( name + '.scale', times, scaleData ) ); + + return tracks; + + } + + function transformAnimationData( keyframes, property, defaultValue ) { + + var keyframe; + + var empty = true; + var i, l; + + // check, if values of a property are missing in our keyframes + + for ( i = 0, l = keyframes.length; i < l; i ++ ) { + + keyframe = keyframes[ i ]; + + if ( keyframe.value[ property ] === undefined ) { + + keyframe.value[ property ] = null; // mark as missing + + } else { + + empty = false; + + } + + } + + if ( empty === true ) { + + // no values at all, so we set a default value + + for ( i = 0, l = keyframes.length; i < l; i ++ ) { + + keyframe = keyframes[ i ]; + + keyframe.value[ property ] = defaultValue; + + } + + } else { + + // filling gaps + + createMissingKeyframes( keyframes, property ); + + } + + } + + function createMissingKeyframes( keyframes, property ) { + + var prev, next; + + for ( var i = 0, l = keyframes.length; i < l; i ++ ) { + + var keyframe = keyframes[ i ]; + + if ( keyframe.value[ property ] === null ) { + + prev = getPrev( keyframes, i, property ); + next = getNext( keyframes, i, property ); + + if ( prev === null ) { + + keyframe.value[ property ] = next.value[ property ]; + continue; + + } + + if ( next === null ) { + + keyframe.value[ property ] = prev.value[ property ]; + continue; + + } + + interpolate( keyframe, prev, next, property ); + + } + + } + + } + + function getPrev( keyframes, i, property ) { + + while ( i >= 0 ) { + + var keyframe = keyframes[ i ]; + + if ( keyframe.value[ property ] !== null ) return keyframe; + + i --; + + } + + return null; + + } + + function getNext( keyframes, i, property ) { + + while ( i < keyframes.length ) { + + var keyframe = keyframes[ i ]; + + if ( keyframe.value[ property ] !== null ) return keyframe; + + i ++; + + } + + return null; + + } + + function interpolate( key, prev, next, property ) { + + if ( ( next.time - prev.time ) === 0 ) { + + key.value[ property ] = prev.value[ property ]; + return; + + } + + key.value[ property ] = ( ( key.time - prev.time ) * ( next.value[ property ] - prev.value[ property ] ) / ( next.time - prev.time ) ) + prev.value[ property ]; + + } + + // animation clips + + function parseAnimationClip( xml ) { + + var data = { + name: xml.getAttribute( 'id' ) || 'default', + start: parseFloat( xml.getAttribute( 'start' ) || 0 ), + end: parseFloat( xml.getAttribute( 'end' ) || 0 ), + animations: [] + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'instance_animation': + data.animations.push( parseId( child.getAttribute( 'url' ) ) ); + break; + + } + + } + + library.clips[ xml.getAttribute( 'id' ) ] = data; + + } + + function buildAnimationClip( data ) { + + var tracks = []; + + var name = data.name; + var duration = ( data.end - data.start ) || - 1; + var animations = data.animations; + + for ( var i = 0, il = animations.length; i < il; i ++ ) { + + var animationTracks = getAnimation( animations[ i ] ); + + for ( var j = 0, jl = animationTracks.length; j < jl; j ++ ) { + + tracks.push( animationTracks[ j ] ); + + } + + } + + return new THREE.AnimationClip( name, duration, tracks ); + + } + + function getAnimationClip( id ) { + + return getBuild( library.clips[ id ], buildAnimationClip ); + + } + + // controller + + function parseController( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'skin': + // there is exactly one skin per controller + data.id = parseId( child.getAttribute( 'source' ) ); + data.skin = parseSkin( child ); + break; + + case 'morph': + data.id = parseId( child.getAttribute( 'source' ) ); + console.warn( 'THREE.ColladaLoader: Morph target animation not supported yet.' ); + break; + + } + + } + + library.controllers[ xml.getAttribute( 'id' ) ] = data; + + } + + function parseSkin( xml ) { + + var data = { + sources: {} + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'bind_shape_matrix': + data.bindShapeMatrix = parseFloats( child.textContent ); + break; + + case 'source': + var id = child.getAttribute( 'id' ); + data.sources[ id ] = parseSource( child ); + break; + + case 'joints': + data.joints = parseJoints( child ); + break; + + case 'vertex_weights': + data.vertexWeights = parseVertexWeights( child ); + break; + + } + + } + + return data; + + } + + function parseJoints( xml ) { + + var data = { + inputs: {} + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'input': + var semantic = child.getAttribute( 'semantic' ); + var id = parseId( child.getAttribute( 'source' ) ); + data.inputs[ semantic ] = id; + break; + + } + + } + + return data; + + } + + function parseVertexWeights( xml ) { + + var data = { + inputs: {} + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'input': + var semantic = child.getAttribute( 'semantic' ); + var id = parseId( child.getAttribute( 'source' ) ); + var offset = parseInt( child.getAttribute( 'offset' ) ); + data.inputs[ semantic ] = { id: id, offset: offset }; + break; + + case 'vcount': + data.vcount = parseInts( child.textContent ); + break; + + case 'v': + data.v = parseInts( child.textContent ); + break; + + } + + } + + return data; + + } + + function buildController( data ) { + + var build = { + id: data.id + }; + + var geometry = library.geometries[ build.id ]; + + if ( data.skin !== undefined ) { + + build.skin = buildSkin( data.skin ); + + // we enhance the 'sources' property of the corresponding geometry with our skin data + + geometry.sources.skinIndices = build.skin.indices; + geometry.sources.skinWeights = build.skin.weights; + + } + + return build; + + } + + function buildSkin( data ) { + + var BONE_LIMIT = 4; + + var build = { + joints: [], // this must be an array to preserve the joint order + indices: { + array: [], + stride: BONE_LIMIT + }, + weights: { + array: [], + stride: BONE_LIMIT + } + }; + + var sources = data.sources; + var vertexWeights = data.vertexWeights; + + var vcount = vertexWeights.vcount; + var v = vertexWeights.v; + var jointOffset = vertexWeights.inputs.JOINT.offset; + var weightOffset = vertexWeights.inputs.WEIGHT.offset; + + var jointSource = data.sources[ data.joints.inputs.JOINT ]; + var inverseSource = data.sources[ data.joints.inputs.INV_BIND_MATRIX ]; + + var weights = sources[ vertexWeights.inputs.WEIGHT.id ].array; + var stride = 0; + + var i, j, l; + + // procces skin data for each vertex + + for ( i = 0, l = vcount.length; i < l; i ++ ) { + + var jointCount = vcount[ i ]; // this is the amount of joints that affect a single vertex + var vertexSkinData = []; + + for ( j = 0; j < jointCount; j ++ ) { + + var skinIndex = v[ stride + jointOffset ]; + var weightId = v[ stride + weightOffset ]; + var skinWeight = weights[ weightId ]; + + vertexSkinData.push( { index: skinIndex, weight: skinWeight } ); + + stride += 2; + + } + + // we sort the joints in descending order based on the weights. + // this ensures, we only procced the most important joints of the vertex + + vertexSkinData.sort( descending ); + + // now we provide for each vertex a set of four index and weight values. + // the order of the skin data matches the order of vertices + + for ( j = 0; j < BONE_LIMIT; j ++ ) { + + var d = vertexSkinData[ j ]; + + if ( d !== undefined ) { + + build.indices.array.push( d.index ); + build.weights.array.push( d.weight ); + + } else { + + build.indices.array.push( 0 ); + build.weights.array.push( 0 ); + + } + + } + + } + + // setup bind matrix + + if ( data.bindShapeMatrix ) { + + build.bindMatrix = new THREE.Matrix4().fromArray( data.bindShapeMatrix ).transpose(); + + } else { + + build.bindMatrix = new THREE.Matrix4().identity(); + + } + + // process bones and inverse bind matrix data + + for ( i = 0, l = jointSource.array.length; i < l; i ++ ) { + + var name = jointSource.array[ i ]; + var boneInverse = new THREE.Matrix4().fromArray( inverseSource.array, i * inverseSource.stride ).transpose(); + + build.joints.push( { name: name, boneInverse: boneInverse } ); + + } + + return build; + + // array sort function + + function descending( a, b ) { + + return b.weight - a.weight; + + } + + } + + function getController( id ) { + + return getBuild( library.controllers[ id ], buildController ); + + } + + // image + + function parseImage( xml ) { + + var data = { + init_from: getElementsByTagName( xml, 'init_from' )[ 0 ].textContent + }; + + library.images[ xml.getAttribute( 'id' ) ] = data; + + } + + function buildImage( data ) { + + if ( data.build !== undefined ) return data.build; + + return data.init_from; + + } + + function getImage( id ) { + + var data = library.images[ id ]; + + if ( data !== undefined ) { + + return getBuild( data, buildImage ); + + } + + console.warn( 'THREE.ColladaLoader: Couldn\'t find image with ID:', id ); + + return null; + + } + + // effect + + function parseEffect( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'profile_COMMON': + data.profile = parseEffectProfileCOMMON( child ); + break; + + } + + } + + library.effects[ xml.getAttribute( 'id' ) ] = data; + + } + + function parseEffectProfileCOMMON( xml ) { + + var data = { + surfaces: {}, + samplers: {} + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'newparam': + parseEffectNewparam( child, data ); + break; + + case 'technique': + data.technique = parseEffectTechnique( child ); + break; + + case 'extra': + data.extra = parseEffectExtra( child ); + break; + + } + + } + + return data; + + } + + function parseEffectNewparam( xml, data ) { + + var sid = xml.getAttribute( 'sid' ); + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'surface': + data.surfaces[ sid ] = parseEffectSurface( child ); + break; + + case 'sampler2D': + data.samplers[ sid ] = parseEffectSampler( child ); + break; + + } + + } + + } + + function parseEffectSurface( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'init_from': + data.init_from = child.textContent; + break; + + } + + } + + return data; + + } + + function parseEffectSampler( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'source': + data.source = child.textContent; + break; + + } + + } + + return data; + + } + + function parseEffectTechnique( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'constant': + case 'lambert': + case 'blinn': + case 'phong': + data.type = child.nodeName; + data.parameters = parseEffectParameters( child ); + break; + + } + + } + + return data; + + } + + function parseEffectParameters( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'emission': + case 'diffuse': + case 'specular': + case 'shininess': + case 'transparency': + data[ child.nodeName ] = parseEffectParameter( child ); + break; + case 'transparent': + data[ child.nodeName ] = { + opaque: child.getAttribute( 'opaque' ), + data: parseEffectParameter( child ) + }; + break; + + } + + } + + return data; + + } + + function parseEffectParameter( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'color': + data[ child.nodeName ] = parseFloats( child.textContent ); + break; + + case 'float': + data[ child.nodeName ] = parseFloat( child.textContent ); + break; + + case 'texture': + data[ child.nodeName ] = { id: child.getAttribute( 'texture' ), extra: parseEffectParameterTexture( child ) }; + break; + + } + + } + + return data; + + } + + function parseEffectParameterTexture( xml ) { + + var data = { + technique: {} + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'extra': + parseEffectParameterTextureExtra( child, data ); + break; + + } + + } + + return data; + + } + + function parseEffectParameterTextureExtra( xml, data ) { + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'technique': + parseEffectParameterTextureExtraTechnique( child, data ); + break; + + } + + } + + } + + function parseEffectParameterTextureExtraTechnique( xml, data ) { + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'repeatU': + case 'repeatV': + case 'offsetU': + case 'offsetV': + data.technique[ child.nodeName ] = parseFloat( child.textContent ); + break; + + case 'wrapU': + case 'wrapV': + + // some files have values for wrapU/wrapV which become NaN via parseInt + + if ( child.textContent.toUpperCase() === 'TRUE' ) { + + data.technique[ child.nodeName ] = 1; + + } else if ( child.textContent.toUpperCase() === 'FALSE' ) { + + data.technique[ child.nodeName ] = 0; + + } else { + + data.technique[ child.nodeName ] = parseInt( child.textContent ); + + } + + break; + + } + + } + + } + + function parseEffectExtra( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'technique': + data.technique = parseEffectExtraTechnique( child ); + break; + + } + + } + + return data; + + } + + function parseEffectExtraTechnique( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'double_sided': + data[ child.nodeName ] = parseInt( child.textContent ); + break; + + } + + } + + return data; + + } + + function buildEffect( data ) { + + return data; + + } + + function getEffect( id ) { + + return getBuild( library.effects[ id ], buildEffect ); + + } + + // material + + function parseMaterial( xml ) { + + var data = { + name: xml.getAttribute( 'name' ) + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'instance_effect': + data.url = parseId( child.getAttribute( 'url' ) ); + break; + + } + + } + + library.materials[ xml.getAttribute( 'id' ) ] = data; + + } + + function getTextureLoader( image ) { + + var loader; + + var extension = image.slice( ( image.lastIndexOf( '.' ) - 1 >>> 0 ) + 2 ); // http://www.jstips.co/en/javascript/get-file-extension/ + extension = extension.toLowerCase(); + + switch ( extension ) { + + case 'tga': + loader = tgaLoader; + break; + + default: + loader = textureLoader; + + } + + return loader; + + } + + function buildMaterial( data ) { + + var effect = getEffect( data.url ); + var technique = effect.profile.technique; + var extra = effect.profile.extra; + + var material; + + switch ( technique.type ) { + + case 'phong': + case 'blinn': + material = new THREE.MeshPhongMaterial(); + break; + + case 'lambert': + material = new THREE.MeshLambertMaterial(); + break; + + default: + material = new THREE.MeshBasicMaterial(); + break; + + } + + material.name = data.name; + + function getTexture( textureObject ) { + + var sampler = effect.profile.samplers[ textureObject.id ]; + var image = null; + + // get image + + if ( sampler !== undefined ) { + + var surface = effect.profile.surfaces[ sampler.source ]; + image = getImage( surface.init_from ); + + } else { + + console.warn( 'THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530).' ); + image = getImage( textureObject.id ); + + } + + // create texture if image is avaiable + + if ( image !== null ) { + + var loader = getTextureLoader( image ); + + if ( loader !== undefined ) { + + var texture = loader.load( image ); + + var extra = textureObject.extra; + + if ( extra !== undefined && extra.technique !== undefined && isEmpty( extra.technique ) === false ) { + + var technique = extra.technique; + + texture.wrapS = technique.wrapU ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + texture.wrapT = technique.wrapV ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + + texture.offset.set( technique.offsetU || 0, technique.offsetV || 0 ); + texture.repeat.set( technique.repeatU || 1, technique.repeatV || 1 ); + + } else { + + texture.wrapS = THREE.RepeatWrapping; + texture.wrapT = THREE.RepeatWrapping; + + } + + return texture; + + } else { + + console.warn( 'THREE.ColladaLoader: Loader for texture %s not found.', image ); + + return null; + + } + + } else { + + console.warn( 'THREE.ColladaLoader: Couldn\'t create texture with ID:', textureObject.id ); + + return null; + + } + + } + + var parameters = technique.parameters; + + for ( var key in parameters ) { + + var parameter = parameters[ key ]; + + switch ( key ) { + + case 'diffuse': + if ( parameter.color ) material.color.fromArray( parameter.color ); + if ( parameter.texture ) material.map = getTexture( parameter.texture ); + break; + case 'specular': + if ( parameter.color && material.specular ) material.specular.fromArray( parameter.color ); + if ( parameter.texture ) material.specularMap = getTexture( parameter.texture ); + break; + case 'shininess': + if ( parameter.float && material.shininess ) material.shininess = parameter.float; + break; + case 'emission': + if ( parameter.color && material.emissive ) material.emissive.fromArray( parameter.color ); + if ( parameter.texture ) material.emissiveMap = getTexture( parameter.texture ); + break; + + } + + } + + // + + var transparent = parameters[ 'transparent' ]; + var transparency = parameters[ 'transparency' ]; + + // does not exist but + + if ( transparency === undefined && transparent ) { + + transparency = { + float: 1 + }; + + } + + // does not exist but + + if ( transparent === undefined && transparency ) { + + transparent = { + opaque: 'A_ONE', + data: { + color: [ 1, 1, 1, 1 ] + } }; + + } + + if ( transparent && transparency ) { + + // handle case if a texture exists but no color + + if ( transparent.data.texture ) { + + // we do not set an alpha map (see #13792) + + material.transparent = true; + + } else { + + var color = transparent.data.color; + + switch ( transparent.opaque ) { + + case 'A_ONE': + material.opacity = color[ 3 ] * transparency.float; + break; + case 'RGB_ZERO': + material.opacity = 1 - ( color[ 0 ] * transparency.float ); + break; + case 'A_ZERO': + material.opacity = 1 - ( color[ 3 ] * transparency.float ); + break; + case 'RGB_ONE': + material.opacity = color[ 0 ] * transparency.float; + break; + default: + console.warn( 'THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.', transparent.opaque ); + + } + + if ( material.opacity < 1 ) material.transparent = true; + + } + + } + + // + + if ( extra !== undefined && extra.technique !== undefined && extra.technique.double_sided === 1 ) { + + material.side = THREE.DoubleSide; + + } + + return material; + + } + + function getMaterial( id ) { + + return getBuild( library.materials[ id ], buildMaterial ); + + } + + // camera + + function parseCamera( xml ) { + + var data = { + name: xml.getAttribute( 'name' ) + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'optics': + data.optics = parseCameraOptics( child ); + break; + + } + + } + + library.cameras[ xml.getAttribute( 'id' ) ] = data; + + } + + function parseCameraOptics( xml ) { + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + switch ( child.nodeName ) { + + case 'technique_common': + return parseCameraTechnique( child ); + + } + + } + + return {}; + + } + + function parseCameraTechnique( xml ) { + + var data = {}; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + switch ( child.nodeName ) { + + case 'perspective': + case 'orthographic': + + data.technique = child.nodeName; + data.parameters = parseCameraParameters( child ); + + break; + + } + + } + + return data; + + } + + function parseCameraParameters( xml ) { + + var data = {}; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + switch ( child.nodeName ) { + + case 'xfov': + case 'yfov': + case 'xmag': + case 'ymag': + case 'znear': + case 'zfar': + case 'aspect_ratio': + data[ child.nodeName ] = parseFloat( child.textContent ); + break; + + } + + } + + return data; + + } + + function buildCamera( data ) { + + var camera; + + switch ( data.optics.technique ) { + + case 'perspective': + camera = new THREE.PerspectiveCamera( + data.optics.parameters.yfov, + data.optics.parameters.aspect_ratio, + data.optics.parameters.znear, + data.optics.parameters.zfar + ); + break; + + case 'orthographic': + var ymag = data.optics.parameters.ymag; + var xmag = data.optics.parameters.xmag; + var aspectRatio = data.optics.parameters.aspect_ratio; + + xmag = ( xmag === undefined ) ? ( ymag * aspectRatio ) : xmag; + ymag = ( ymag === undefined ) ? ( xmag / aspectRatio ) : ymag; + + xmag *= 0.5; + ymag *= 0.5; + + camera = new THREE.OrthographicCamera( + - xmag, xmag, ymag, - ymag, // left, right, top, bottom + data.optics.parameters.znear, + data.optics.parameters.zfar + ); + break; + + default: + camera = new THREE.PerspectiveCamera(); + break; + + } + + camera.name = data.name; + + return camera; + + } + + function getCamera( id ) { + + var data = library.cameras[ id ]; + + if ( data !== undefined ) { + + return getBuild( data, buildCamera ); + + } + + console.warn( 'THREE.ColladaLoader: Couldn\'t find camera with ID:', id ); + + return null; + + } + + // light + + function parseLight( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'technique_common': + data = parseLightTechnique( child ); + break; + + } + + } + + library.lights[ xml.getAttribute( 'id' ) ] = data; + + } + + function parseLightTechnique( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'directional': + case 'point': + case 'spot': + case 'ambient': + + data.technique = child.nodeName; + data.parameters = parseLightParameters( child ); + + } + + } + + return data; + + } + + function parseLightParameters( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'color': + var array = parseFloats( child.textContent ); + data.color = new THREE.Color().fromArray( array ); + break; + + case 'falloff_angle': + data.falloffAngle = parseFloat( child.textContent ); + break; + + case 'quadratic_attenuation': + var f = parseFloat( child.textContent ); + data.distance = f ? Math.sqrt( 1 / f ) : 0; + break; + + } + + } + + return data; + + } + + function buildLight( data ) { + + var light; + + switch ( data.technique ) { + + case 'directional': + light = new THREE.DirectionalLight(); + break; + + case 'point': + light = new THREE.PointLight(); + break; + + case 'spot': + light = new THREE.SpotLight(); + break; + + case 'ambient': + light = new THREE.AmbientLight(); + break; + + } + + if ( data.parameters.color ) light.color.copy( data.parameters.color ); + if ( data.parameters.distance ) light.distance = data.parameters.distance; + + return light; + + } + + function getLight( id ) { + + var data = library.lights[ id ]; + + if ( data !== undefined ) { + + return getBuild( data, buildLight ); + + } + + console.warn( 'THREE.ColladaLoader: Couldn\'t find light with ID:', id ); + + return null; + + } + + // geometry + + function parseGeometry( xml ) { + + var data = { + name: xml.getAttribute( 'name' ), + sources: {}, + vertices: {}, + primitives: [] + }; + + var mesh = getElementsByTagName( xml, 'mesh' )[ 0 ]; + + // the following tags inside geometry are not supported yet (see https://github.com/mrdoob/three.js/pull/12606): convex_mesh, spline, brep + if ( mesh === undefined ) return; + + for ( var i = 0; i < mesh.childNodes.length; i ++ ) { + + var child = mesh.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + var id = child.getAttribute( 'id' ); + + switch ( child.nodeName ) { + + case 'source': + data.sources[ id ] = parseSource( child ); + break; + + case 'vertices': + // data.sources[ id ] = data.sources[ parseId( getElementsByTagName( child, 'input' )[ 0 ].getAttribute( 'source' ) ) ]; + data.vertices = parseGeometryVertices( child ); + break; + + case 'polygons': + console.warn( 'THREE.ColladaLoader: Unsupported primitive type: ', child.nodeName ); + break; + + case 'lines': + case 'linestrips': + case 'polylist': + case 'triangles': + data.primitives.push( parseGeometryPrimitive( child ) ); + break; + + default: + console.log( child ); + + } + + } + + library.geometries[ xml.getAttribute( 'id' ) ] = data; + + } + + function parseSource( xml ) { + + var data = { + array: [], + stride: 3 + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'float_array': + data.array = parseFloats( child.textContent ); + break; + + case 'Name_array': + data.array = parseStrings( child.textContent ); + break; + + case 'technique_common': + var accessor = getElementsByTagName( child, 'accessor' )[ 0 ]; + + if ( accessor !== undefined ) { + + data.stride = parseInt( accessor.getAttribute( 'stride' ) ); + + } + break; + + } + + } + + return data; + + } + + function parseGeometryVertices( xml ) { + + var data = {}; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + data[ child.getAttribute( 'semantic' ) ] = parseId( child.getAttribute( 'source' ) ); + + } + + return data; + + } + + function parseGeometryPrimitive( xml ) { + + var primitive = { + type: xml.nodeName, + material: xml.getAttribute( 'material' ), + count: parseInt( xml.getAttribute( 'count' ) ), + inputs: {}, + stride: 0, + hasUV: false + }; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'input': + var id = parseId( child.getAttribute( 'source' ) ); + var semantic = child.getAttribute( 'semantic' ); + var offset = parseInt( child.getAttribute( 'offset' ) ); + primitive.inputs[ semantic ] = { id: id, offset: offset }; + primitive.stride = Math.max( primitive.stride, offset + 1 ); + if ( semantic === 'TEXCOORD' ) primitive.hasUV = true; + break; + + case 'vcount': + primitive.vcount = parseInts( child.textContent ); + break; + + case 'p': + primitive.p = parseInts( child.textContent ); + break; + + } + + } + + return primitive; + + } + + function groupPrimitives( primitives ) { + + var build = {}; + + for ( var i = 0; i < primitives.length; i ++ ) { + + var primitive = primitives[ i ]; + + if ( build[ primitive.type ] === undefined ) build[ primitive.type ] = []; + + build[ primitive.type ].push( primitive ); + + } + + return build; + + } + + function checkUVCoordinates( primitives ) { + + var count = 0; + + for ( var i = 0, l = primitives.length; i < l; i ++ ) { + + var primitive = primitives[ i ]; + + if ( primitive.hasUV === true ) { + + count ++; + + } + + } + + if ( count > 0 && count < primitives.length ) { + + primitives.uvsNeedsFix = true; + + } + + } + + function buildGeometry( data ) { + + var build = {}; + + var sources = data.sources; + var vertices = data.vertices; + var primitives = data.primitives; + + if ( primitives.length === 0 ) return {}; + + // our goal is to create one buffer geometry for a single type of primitives + // first, we group all primitives by their type + + var groupedPrimitives = groupPrimitives( primitives ); + + for ( var type in groupedPrimitives ) { + + var primitiveType = groupedPrimitives[ type ]; + + // second, ensure consistent uv coordinates for each type of primitives (polylist,triangles or lines) + + checkUVCoordinates( primitiveType ); + + // third, create a buffer geometry for each type of primitives + + build[ type ] = buildGeometryType( primitiveType, sources, vertices ); + + } + + return build; + + } + + function buildGeometryType( primitives, sources, vertices ) { + + var build = {}; + + var position = { array: [], stride: 0 }; + var normal = { array: [], stride: 0 }; + var uv = { array: [], stride: 0 }; + var color = { array: [], stride: 0 }; + + var skinIndex = { array: [], stride: 4 }; + var skinWeight = { array: [], stride: 4 }; + + var geometry = new THREE.BufferGeometry(); + + var materialKeys = []; + + var start = 0; + + for ( var p = 0; p < primitives.length; p ++ ) { + + var primitive = primitives[ p ]; + var inputs = primitive.inputs; + + // groups + + var count = 0; + + switch ( primitive.type ) { + + case 'lines': + case 'linestrips': + count = primitive.count * 2; + break; + + case 'triangles': + count = primitive.count * 3; + break; + + case 'polylist': + + for ( var g = 0; g < primitive.count; g ++ ) { + + var vc = primitive.vcount[ g ]; + + switch ( vc ) { + + case 3: + count += 3; // single triangle + break; + + case 4: + count += 6; // quad, subdivided into two triangles + break; + + default: + count += ( vc - 2 ) * 3; // polylist with more than four vertices + break; + + } + + } + + break; + + default: + console.warn( 'THREE.ColladaLoader: Unknow primitive type:', primitive.type ); + + } + + geometry.addGroup( start, count, p ); + start += count; + + // material + + if ( primitive.material ) { + + materialKeys.push( primitive.material ); + + } + + // geometry data + + for ( var name in inputs ) { + + var input = inputs[ name ]; + + switch ( name ) { + + case 'VERTEX': + for ( var key in vertices ) { + + var id = vertices[ key ]; + + switch ( key ) { + + case 'POSITION': + var prevLength = position.array.length; + buildGeometryData( primitive, sources[ id ], input.offset, position.array ); + position.stride = sources[ id ].stride; + + if ( sources.skinWeights && sources.skinIndices ) { + + buildGeometryData( primitive, sources.skinIndices, input.offset, skinIndex.array ); + buildGeometryData( primitive, sources.skinWeights, input.offset, skinWeight.array ); + + } + + // see #3803 + + if ( primitive.hasUV === false && primitives.uvsNeedsFix === true ) { + + var count = ( position.array.length - prevLength ) / position.stride; + + for ( var i = 0; i < count; i ++ ) { + + // fill missing uv coordinates + + uv.array.push( 0, 0 ); + + } + + } + break; + + case 'NORMAL': + buildGeometryData( primitive, sources[ id ], input.offset, normal.array ); + normal.stride = sources[ id ].stride; + break; + + case 'COLOR': + buildGeometryData( primitive, sources[ id ], input.offset, color.array ); + color.stride = sources[ id ].stride; + break; + + case 'TEXCOORD': + buildGeometryData( primitive, sources[ id ], input.offset, uv.array ); + uv.stride = sources[ id ].stride; + break; + + default: + console.warn( 'THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.', key ); + + } + + } + break; + + case 'NORMAL': + buildGeometryData( primitive, sources[ input.id ], input.offset, normal.array ); + normal.stride = sources[ input.id ].stride; + break; + + case 'COLOR': + buildGeometryData( primitive, sources[ input.id ], input.offset, color.array ); + color.stride = sources[ input.id ].stride; + break; + + case 'TEXCOORD': + buildGeometryData( primitive, sources[ input.id ], input.offset, uv.array ); + uv.stride = sources[ input.id ].stride; + break; + + } + + } + + } + + // build geometry + + if ( position.array.length > 0 ) geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( position.array, position.stride ) ); + if ( normal.array.length > 0 ) geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normal.array, normal.stride ) ); + if ( color.array.length > 0 ) geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( color.array, color.stride ) ); + if ( uv.array.length > 0 ) geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uv.array, uv.stride ) ); + + if ( skinIndex.array.length > 0 ) geometry.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( skinIndex.array, skinIndex.stride ) ); + if ( skinWeight.array.length > 0 ) geometry.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeight.array, skinWeight.stride ) ); + + build.data = geometry; + build.type = primitives[ 0 ].type; + build.materialKeys = materialKeys; + + return build; + + } + + function buildGeometryData( primitive, source, offset, array ) { + + var indices = primitive.p; + var stride = primitive.stride; + var vcount = primitive.vcount; + + function pushVector( i ) { + + var index = indices[ i + offset ] * sourceStride; + var length = index + sourceStride; + + for ( ; index < length; index ++ ) { + + array.push( sourceArray[ index ] ); + + } + + } + + var sourceArray = source.array; + var sourceStride = source.stride; + + if ( primitive.vcount !== undefined ) { + + var index = 0; + + for ( var i = 0, l = vcount.length; i < l; i ++ ) { + + var count = vcount[ i ]; + + if ( count === 4 ) { + + var a = index + stride * 0; + var b = index + stride * 1; + var c = index + stride * 2; + var d = index + stride * 3; + + pushVector( a ); pushVector( b ); pushVector( d ); + pushVector( b ); pushVector( c ); pushVector( d ); + + } else if ( count === 3 ) { + + var a = index + stride * 0; + var b = index + stride * 1; + var c = index + stride * 2; + + pushVector( a ); pushVector( b ); pushVector( c ); + + } else if ( count > 4 ) { + + for ( var k = 1, kl = ( count - 2 ); k <= kl; k ++ ) { + + var a = index + stride * 0; + var b = index + stride * k; + var c = index + stride * ( k + 1 ); + + pushVector( a ); pushVector( b ); pushVector( c ); + + } + + } + + index += stride * count; + + } + + } else { + + for ( var i = 0, l = indices.length; i < l; i += stride ) { + + pushVector( i ); + + } + + } + + } + + function getGeometry( id ) { + + return getBuild( library.geometries[ id ], buildGeometry ); + + } + + // kinematics + + function parseKinematicsModel( xml ) { + + var data = { + name: xml.getAttribute( 'name' ) || '', + joints: {}, + links: [] + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'technique_common': + parseKinematicsTechniqueCommon( child, data ); + break; + + } + + } + + library.kinematicsModels[ xml.getAttribute( 'id' ) ] = data; + + } + + function buildKinematicsModel( data ) { + + if ( data.build !== undefined ) return data.build; + + return data; + + } + + function getKinematicsModel( id ) { + + return getBuild( library.kinematicsModels[ id ], buildKinematicsModel ); + + } + + function parseKinematicsTechniqueCommon( xml, data ) { + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'joint': + data.joints[ child.getAttribute( 'sid' ) ] = parseKinematicsJoint( child ); + break; + + case 'link': + data.links.push( parseKinematicsLink( child ) ); + break; + + } + + } + + } + + function parseKinematicsJoint( xml ) { + + var data; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'prismatic': + case 'revolute': + data = parseKinematicsJointParameter( child ); + break; + + } + + } + + return data; + + } + + function parseKinematicsJointParameter( xml, data ) { + + var data = { + sid: xml.getAttribute( 'sid' ), + name: xml.getAttribute( 'name' ) || '', + axis: new THREE.Vector3(), + limits: { + min: 0, + max: 0 + }, + type: xml.nodeName, + static: false, + zeroPosition: 0, + middlePosition: 0 + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'axis': + var array = parseFloats( child.textContent ); + data.axis.fromArray( array ); + break; + case 'limits': + var max = child.getElementsByTagName( 'max' )[ 0 ]; + var min = child.getElementsByTagName( 'min' )[ 0 ]; + + data.limits.max = parseFloat( max.textContent ); + data.limits.min = parseFloat( min.textContent ); + break; + + } + + } + + // if min is equal to or greater than max, consider the joint static + + if ( data.limits.min >= data.limits.max ) { + + data.static = true; + + } + + // calculate middle position + + data.middlePosition = ( data.limits.min + data.limits.max ) / 2.0; + + return data; + + } + + function parseKinematicsLink( xml ) { + + var data = { + sid: xml.getAttribute( 'sid' ), + name: xml.getAttribute( 'name' ) || '', + attachments: [], + transforms: [] + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'attachment_full': + data.attachments.push( parseKinematicsAttachment( child ) ); + break; + + case 'matrix': + case 'translate': + case 'rotate': + data.transforms.push( parseKinematicsTransform( child ) ); + break; + + } + + } + + return data; + + } + + function parseKinematicsAttachment( xml ) { + + var data = { + joint: xml.getAttribute( 'joint' ).split( '/' ).pop(), + transforms: [], + links: [] + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'link': + data.links.push( parseKinematicsLink( child ) ); + break; + + case 'matrix': + case 'translate': + case 'rotate': + data.transforms.push( parseKinematicsTransform( child ) ); + break; + + } + + } + + return data; + + } + + function parseKinematicsTransform( xml ) { + + var data = { + type: xml.nodeName + }; + + var array = parseFloats( xml.textContent ); + + switch ( data.type ) { + + case 'matrix': + data.obj = new THREE.Matrix4(); + data.obj.fromArray( array ).transpose(); + break; + + case 'translate': + data.obj = new THREE.Vector3(); + data.obj.fromArray( array ); + break; + + case 'rotate': + data.obj = new THREE.Vector3(); + data.obj.fromArray( array ); + data.angle = THREE.Math.degToRad( array[ 3 ] ); + break; + + } + + return data; + + } + + // physics + + function parsePhysicsModel( xml ) { + + var data = { + name: xml.getAttribute( 'name' ) || '', + rigidBodies: {} + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'rigid_body': + data.rigidBodies[ child.getAttribute( 'name' ) ] = {}; + parsePhysicsRigidBody( child, data.rigidBodies[ child.getAttribute( 'name' ) ] ); + break; + + } + + } + + library.physicsModels[ xml.getAttribute( 'id' ) ] = data; + + } + + function parsePhysicsRigidBody( xml, data ) { + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'technique_common': + parsePhysicsTechniqueCommon( child, data ); + break; + + } + + } + + } + + function parsePhysicsTechniqueCommon( xml, data ) { + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'inertia': + data.inertia = parseFloats( child.textContent ); + break; + + case 'mass': + data.mass = parseFloats( child.textContent )[0]; + break; + + } + + } + + } + + // scene + + function parseKinematicsScene( xml ) { + + var data = { + bindJointAxis: [] + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'bind_joint_axis': + data.bindJointAxis.push( parseKinematicsBindJointAxis( child ) ); + break; + + } + + } + + library.kinematicsScenes[ parseId( xml.getAttribute( 'url' ) ) ] = data; + + } + + function parseKinematicsBindJointAxis( xml ) { + + var data = { + target: xml.getAttribute( 'target' ).split( '/' ).pop() + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'axis': + var param = child.getElementsByTagName( 'param' )[ 0 ]; + data.axis = param.textContent; + var tmpJointIndex = data.axis.split( 'inst_' ).pop().split( 'axis' )[ 0 ]; + data.jointIndex = tmpJointIndex.substr( 0, tmpJointIndex.length - 1 ); + break; + + } + + } + + return data; + + } + + function buildKinematicsScene( data ) { + + if ( data.build !== undefined ) return data.build; + + return data; + + } + + function getKinematicsScene( id ) { + + return getBuild( library.kinematicsScenes[ id ], buildKinematicsScene ); + + } + + function setupKinematics() { + + var kinematicsModelId = Object.keys( library.kinematicsModels )[ 0 ]; + var kinematicsSceneId = Object.keys( library.kinematicsScenes )[ 0 ]; + var visualSceneId = Object.keys( library.visualScenes )[ 0 ]; + + if ( kinematicsModelId === undefined || kinematicsSceneId === undefined ) return; + + var kinematicsModel = getKinematicsModel( kinematicsModelId ); + var kinematicsScene = getKinematicsScene( kinematicsSceneId ); + var visualScene = getVisualScene( visualSceneId ); + + var bindJointAxis = kinematicsScene.bindJointAxis; + var jointMap = {}; + + for ( var i = 0, l = bindJointAxis.length; i < l; i ++ ) { + + var axis = bindJointAxis[ i ]; + + // the result of the following query is an element of type 'translate', 'rotate','scale' or 'matrix' + + var targetElement = collada.querySelector( '[sid="' + axis.target + '"]' ); + + if ( targetElement ) { + + // get the parent of the transfrom element + + var parentVisualElement = targetElement.parentElement; + + // connect the joint of the kinematics model with the element in the visual scene + + connect( axis.jointIndex, parentVisualElement ); + + } + + } + + function connect( jointIndex, visualElement ) { + + var visualElementName = visualElement.getAttribute( 'name' ); + var joint = kinematicsModel.joints[ jointIndex ]; + + visualScene.traverse( function ( object ) { + + if ( object.name === visualElementName ) { + + jointMap[ jointIndex ] = { + object: object, + transforms: buildTransformList( visualElement ), + joint: joint, + position: joint.zeroPosition + }; + + } + + } ); + + } + + var m0 = new THREE.Matrix4(); + + kinematics = { + + joints: kinematicsModel && kinematicsModel.joints, + + getJointValue: function ( jointIndex ) { + + var jointData = jointMap[ jointIndex ]; + + if ( jointData ) { + + return jointData.position; + + } else { + + console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' doesn\'t exist.' ); + + } + + }, + + setJointValue: function ( jointIndex, value ) { + + var jointData = jointMap[ jointIndex ]; + + if ( jointData ) { + + var joint = jointData.joint; + + if ( value > joint.limits.max || value < joint.limits.min ) { + + console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' value ' + value + ' outside of limits (min: ' + joint.limits.min + ', max: ' + joint.limits.max + ').' ); + + } else if ( joint.static ) { + + console.warn( 'THREE.ColladaLoader: Joint ' + jointIndex + ' is static.' ); + + } else { + + var object = jointData.object; + var axis = joint.axis; + var transforms = jointData.transforms; + + matrix.identity(); + + // each update, we have to apply all transforms in the correct order + + for ( var i = 0; i < transforms.length; i ++ ) { + + var transform = transforms[ i ]; + + // if there is a connection of the transform node with a joint, apply the joint value + + if ( transform.sid && transform.sid.indexOf( jointIndex ) !== - 1 ) { + + switch ( joint.type ) { + + case 'revolute': + matrix.multiply( m0.makeRotationAxis( axis, THREE.Math.degToRad( value ) ) ); + break; + + case 'prismatic': + matrix.multiply( m0.makeTranslation( axis.x * value, axis.y * value, axis.z * value ) ); + break; + + default: + console.warn( 'THREE.ColladaLoader: Unknown joint type: ' + joint.type ); + break; + + } + + } else { + + switch ( transform.type ) { + + case 'matrix': + matrix.multiply( transform.obj ); + break; + + case 'translate': + matrix.multiply( m0.makeTranslation( transform.obj.x, transform.obj.y, transform.obj.z ) ); + break; + + case 'scale': + matrix.scale( transform.obj ); + break; + + case 'rotate': + matrix.multiply( m0.makeRotationAxis( transform.obj, transform.angle ) ); + break; + + } + + } + + } + + object.matrix.copy( matrix ); + object.matrix.decompose( object.position, object.quaternion, object.scale ); + + jointMap[ jointIndex ].position = value; + + } + + } else { + + console.log( 'THREE.ColladaLoader: ' + jointIndex + ' does not exist.' ); + + } + + } + + }; + + } + + function buildTransformList( node ) { + + var transforms = []; + + var xml = collada.querySelector( '[id="' + node.id + '"]' ); + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'matrix': + var array = parseFloats( child.textContent ); + var matrix = new THREE.Matrix4().fromArray( array ).transpose(); + transforms.push( { + sid: child.getAttribute( 'sid' ), + type: child.nodeName, + obj: matrix + } ); + break; + + case 'translate': + case 'scale': + var array = parseFloats( child.textContent ); + var vector = new THREE.Vector3().fromArray( array ); + transforms.push( { + sid: child.getAttribute( 'sid' ), + type: child.nodeName, + obj: vector + } ); + break; + + case 'rotate': + var array = parseFloats( child.textContent ); + var vector = new THREE.Vector3().fromArray( array ); + var angle = THREE.Math.degToRad( array[ 3 ] ); + transforms.push( { + sid: child.getAttribute( 'sid' ), + type: child.nodeName, + obj: vector, + angle: angle + } ); + break; + + } + + } + + return transforms; + + } + + // nodes + + function prepareNodes( xml ) { + + var elements = xml.getElementsByTagName( 'node' ); + + // ensure all node elements have id attributes + + for ( var i = 0; i < elements.length; i ++ ) { + + var element = elements[ i ]; + + if ( element.hasAttribute( 'id' ) === false ) { + + element.setAttribute( 'id', generateId() ); + + } + + } + + } + + var matrix = new THREE.Matrix4(); + var vector = new THREE.Vector3(); + + function parseNode( xml ) { + + var data = { + name: xml.getAttribute( 'name' ) || '', + type: xml.getAttribute( 'type' ), + id: xml.getAttribute( 'id' ), + sid: xml.getAttribute( 'sid' ), + matrix: new THREE.Matrix4(), + nodes: [], + instanceCameras: [], + instanceControllers: [], + instanceLights: [], + instanceGeometries: [], + instanceNodes: [], + transforms: {} + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'node': + data.nodes.push( child.getAttribute( 'id' ) ); + parseNode( child ); + break; + + case 'instance_camera': + data.instanceCameras.push( parseId( child.getAttribute( 'url' ) ) ); + break; + + case 'instance_controller': + data.instanceControllers.push( parseNodeInstance( child ) ); + break; + + case 'instance_light': + data.instanceLights.push( parseId( child.getAttribute( 'url' ) ) ); + break; + + case 'instance_geometry': + data.instanceGeometries.push( parseNodeInstance( child ) ); + break; + + case 'instance_node': + data.instanceNodes.push( parseId( child.getAttribute( 'url' ) ) ); + break; + + case 'matrix': + var array = parseFloats( child.textContent ); + data.matrix.multiply( matrix.fromArray( array ).transpose() ); + data.transforms[ child.getAttribute( 'sid' ) ] = child.nodeName; + break; + + case 'translate': + var array = parseFloats( child.textContent ); + vector.fromArray( array ); + data.matrix.multiply( matrix.makeTranslation( vector.x, vector.y, vector.z ) ); + data.transforms[ child.getAttribute( 'sid' ) ] = child.nodeName; + break; + + case 'rotate': + var array = parseFloats( child.textContent ); + var angle = THREE.Math.degToRad( array[ 3 ] ); + data.matrix.multiply( matrix.makeRotationAxis( vector.fromArray( array ), angle ) ); + data.transforms[ child.getAttribute( 'sid' ) ] = child.nodeName; + break; + + case 'scale': + var array = parseFloats( child.textContent ); + data.matrix.scale( vector.fromArray( array ) ); + data.transforms[ child.getAttribute( 'sid' ) ] = child.nodeName; + break; + + case 'extra': + break; + + default: + console.log( child ); + + } + + } + + if ( hasNode( data.id ) ) { + + console.warn( 'THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.', data.id ); + + } else { + + library.nodes[ data.id ] = data; + + } + + return data; + + } + + function parseNodeInstance( xml ) { + + var data = { + id: parseId( xml.getAttribute( 'url' ) ), + materials: {}, + skeletons: [] + }; + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var child = xml.childNodes[ i ]; + + switch ( child.nodeName ) { + + case 'bind_material': + var instances = child.getElementsByTagName( 'instance_material' ); + + for ( var j = 0; j < instances.length; j ++ ) { + + var instance = instances[ j ]; + var symbol = instance.getAttribute( 'symbol' ); + var target = instance.getAttribute( 'target' ); + + data.materials[ symbol ] = parseId( target ); + + } + + break; + + case 'skeleton': + data.skeletons.push( parseId( child.textContent ) ); + break; + + default: + break; + + } + + } + + return data; + + } + + function buildSkeleton( skeletons, joints ) { + + var boneData = []; + var sortedBoneData = []; + + var i, j, data; + + // a skeleton can have multiple root bones. collada expresses this + // situtation with multiple "skeleton" tags per controller instance + + for ( i = 0; i < skeletons.length; i ++ ) { + + var skeleton = skeletons[ i ]; + + var root; + + if ( hasNode( skeleton ) ) { + + root = getNode( skeleton ); + buildBoneHierarchy( root, joints, boneData ); + + } else if ( hasVisualScene( skeleton ) ) { + + // handle case where the skeleton refers to the visual scene (#13335) + + var visualScene = library.visualScenes[ skeleton ]; + var children = visualScene.children; + + for ( var j = 0; j < children.length; j ++ ) { + + var child = children[ j ]; + + if ( child.type === 'JOINT' ) { + + var root = getNode( child.id ); + buildBoneHierarchy( root, joints, boneData ); + + } + + } + + } else { + + console.error( 'THREE.ColladaLoader: Unable to find root bone of skeleton with ID:', skeleton ); + + } + + } + + // sort bone data (the order is defined in the corresponding controller) + + for ( i = 0; i < joints.length; i ++ ) { + + for ( j = 0; j < boneData.length; j ++ ) { + + data = boneData[ j ]; + + if ( data.bone.name === joints[ i ].name ) { + + sortedBoneData[ i ] = data; + data.processed = true; + break; + + } + + } + + } + + // add unprocessed bone data at the end of the list + + for ( i = 0; i < boneData.length; i ++ ) { + + data = boneData[ i ]; + + if ( data.processed === false ) { + + sortedBoneData.push( data ); + data.processed = true; + + } + + } + + // setup arrays for skeleton creation + + var bones = []; + var boneInverses = []; + + for ( i = 0; i < sortedBoneData.length; i ++ ) { + + data = sortedBoneData[ i ]; + + bones.push( data.bone ); + boneInverses.push( data.boneInverse ); + + } + + return new THREE.Skeleton( bones, boneInverses ); + + } + + function buildBoneHierarchy( root, joints, boneData ) { + + // setup bone data from visual scene + + root.traverse( function ( object ) { + + if ( object.isBone === true ) { + + var boneInverse; + + // retrieve the boneInverse from the controller data + + for ( var i = 0; i < joints.length; i ++ ) { + + var joint = joints[ i ]; + + if ( joint.name === object.name ) { + + boneInverse = joint.boneInverse; + break; + + } + + } + + if ( boneInverse === undefined ) { + + // Unfortunately, there can be joints in the visual scene that are not part of the + // corresponding controller. In this case, we have to create a dummy boneInverse matrix + // for the respective bone. This bone won't affect any vertices, because there are no skin indices + // and weights defined for it. But we still have to add the bone to the sorted bone list in order to + // ensure a correct animation of the model. + + boneInverse = new THREE.Matrix4(); + + } + + boneData.push( { bone: object, boneInverse: boneInverse, processed: false } ); + + } + + } ); + + } + + function buildNode( data ) { + + var objects = []; + + var matrix = data.matrix; + var nodes = data.nodes; + var type = data.type; + var instanceCameras = data.instanceCameras; + var instanceControllers = data.instanceControllers; + var instanceLights = data.instanceLights; + var instanceGeometries = data.instanceGeometries; + var instanceNodes = data.instanceNodes; + + // nodes + + for ( var i = 0, l = nodes.length; i < l; i ++ ) { + + objects.push( getNode( nodes[ i ] ) ); + + } + + // instance cameras + + for ( var i = 0, l = instanceCameras.length; i < l; i ++ ) { + + var instanceCamera = getCamera( instanceCameras[ i ] ); + + if ( instanceCamera !== null ) { + + objects.push( instanceCamera.clone() ); + + } + + } + + // instance controllers + + for ( var i = 0, l = instanceControllers.length; i < l; i ++ ) { + + var instance = instanceControllers[ i ]; + var controller = getController( instance.id ); + var geometries = getGeometry( controller.id ); + var newObjects = buildObjects( geometries, instance.materials ); + + var skeletons = instance.skeletons; + var joints = controller.skin.joints; + + var skeleton = buildSkeleton( skeletons, joints ); + + for ( var j = 0, jl = newObjects.length; j < jl; j ++ ) { + + var object = newObjects[ j ]; + + if ( object.isSkinnedMesh ) { + + object.bind( skeleton, controller.skin.bindMatrix ); + object.normalizeSkinWeights(); + + } + + objects.push( object ); + + } + + } + + // instance lights + + for ( var i = 0, l = instanceLights.length; i < l; i ++ ) { + + var instanceLight = getLight( instanceLights[ i ] ); + + if ( instanceLight !== null ) { + + objects.push( instanceLight.clone() ); + + } + + } + + // instance geometries + + for ( var i = 0, l = instanceGeometries.length; i < l; i ++ ) { + + var instance = instanceGeometries[ i ]; + + // a single geometry instance in collada can lead to multiple object3Ds. + // this is the case when primitives are combined like triangles and lines + + var geometries = getGeometry( instance.id ); + var newObjects = buildObjects( geometries, instance.materials ); + + for ( var j = 0, jl = newObjects.length; j < jl; j ++ ) { + + objects.push( newObjects[ j ] ); + + } + + } + + // instance nodes + + for ( var i = 0, l = instanceNodes.length; i < l; i ++ ) { + + objects.push( getNode( instanceNodes[ i ] ).clone() ); + + } + + var object; + + if ( nodes.length === 0 && objects.length === 1 ) { + + object = objects[ 0 ]; + + } else { + + object = ( type === 'JOINT' ) ? new THREE.Bone() : new THREE.Group(); + + for ( var i = 0; i < objects.length; i ++ ) { + + object.add( objects[ i ] ); + + } + + } + + if ( object.name === '' ) { + + object.name = ( type === 'JOINT' ) ? data.sid : data.name; + + } + + object.matrix.copy( matrix ); + object.matrix.decompose( object.position, object.quaternion, object.scale ); + + return object; + + } + + var fallbackMaterial = new THREE.MeshBasicMaterial( { color: 0xff00ff } ); + + function resolveMaterialBinding( keys, instanceMaterials ) { + + var materials = []; + + for ( var i = 0, l = keys.length; i < l; i ++ ) { + + var id = instanceMaterials[ keys[ i ] ]; + + if ( id === undefined ) { + + console.warn( 'THREE.ColladaLoader: Material with key %s not found. Apply fallback material.', keys[ i ] ); + materials.push( fallbackMaterial ); + + } else { + + materials.push( getMaterial( id ) ); + + } + + } + + return materials; + + } + + function buildObjects( geometries, instanceMaterials ) { + + var objects = []; + + for ( var type in geometries ) { + + var geometry = geometries[ type ]; + + var materials = resolveMaterialBinding( geometry.materialKeys, instanceMaterials ); + + // handle case if no materials are defined + + if ( materials.length === 0 ) { + + if ( type === 'lines' || type === 'linestrips' ) { + + materials.push( new THREE.LineBasicMaterial() ); + + } else { + + materials.push( new THREE.MeshPhongMaterial() ); + + } + + } + + // regard skinning + + var skinning = ( geometry.data.attributes.skinIndex !== undefined ); + + if ( skinning ) { + + for ( var i = 0, l = materials.length; i < l; i ++ ) { + + materials[ i ].skinning = true; + + } + + } + + // choose between a single or multi materials (material array) + + var material = ( materials.length === 1 ) ? materials[ 0 ] : materials; + + // now create a specific 3D object + + var object; + + switch ( type ) { + + case 'lines': + object = new THREE.LineSegments( geometry.data, material ); + break; + + case 'linestrips': + object = new THREE.Line( geometry.data, material ); + break; + + case 'triangles': + case 'polylist': + if ( skinning ) { + + object = new THREE.SkinnedMesh( geometry.data, material ); + + } else { + + object = new THREE.Mesh( geometry.data, material ); + + } + break; + + } + + objects.push( object ); + + } + + return objects; + + } + + function hasNode( id ) { + + return library.nodes[ id ] !== undefined; + + } + + function getNode( id ) { + + return getBuild( library.nodes[ id ], buildNode ); + + } + + // visual scenes + + function parseVisualScene( xml ) { + + var data = { + name: xml.getAttribute( 'name' ), + children: [] + }; + + prepareNodes( xml ); + + var elements = getElementsByTagName( xml, 'node' ); + + for ( var i = 0; i < elements.length; i ++ ) { + + data.children.push( parseNode( elements[ i ] ) ); + + } + + library.visualScenes[ xml.getAttribute( 'id' ) ] = data; + + } + + function buildVisualScene( data ) { + + var group = new THREE.Group(); + group.name = data.name; + + var children = data.children; + + for ( var i = 0; i < children.length; i ++ ) { + + var child = children[ i ]; + + group.add( getNode( child.id ) ); + + } + + return group; + + } + + function hasVisualScene( id ) { + + return library.visualScenes[ id ] !== undefined; + + } + + function getVisualScene( id ) { + + return getBuild( library.visualScenes[ id ], buildVisualScene ); + + } + + // scenes + + function parseScene( xml ) { + + var instance = getElementsByTagName( xml, 'instance_visual_scene' )[ 0 ]; + return getVisualScene( parseId( instance.getAttribute( 'url' ) ) ); + + } + + function setupAnimations() { + + var clips = library.clips; + + if ( isEmpty( clips ) === true ) { + + if ( isEmpty( library.animations ) === false ) { + + // if there are animations but no clips, we create a default clip for playback + + var tracks = []; + + for ( var id in library.animations ) { + + var animationTracks = getAnimation( id ); + + for ( var i = 0, l = animationTracks.length; i < l; i ++ ) { + + tracks.push( animationTracks[ i ] ); + + } + + } + + animations.push( new THREE.AnimationClip( 'default', - 1, tracks ) ); + + } + + } else { + + for ( var id in clips ) { + + animations.push( getAnimationClip( id ) ); + + } + + } + + } + + if ( text.length === 0 ) { + + return { scene: new THREE.Scene() }; + + } + + var xml = new DOMParser().parseFromString( text, 'application/xml' ); + + var collada = getElementsByTagName( xml, 'COLLADA' )[ 0 ]; + + // metadata + + var version = collada.getAttribute( 'version' ); + console.log( 'THREE.ColladaLoader: File version', version ); + + var asset = parseAsset( getElementsByTagName( collada, 'asset' )[ 0 ] ); + var textureLoader = new THREE.TextureLoader( this.manager ); + textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); + + var tgaLoader; + + if ( THREE.TGALoader ) { + + tgaLoader = new THREE.TGALoader( this.manager ); + tgaLoader.setPath( this.resourcePath || path ); + + } + + // + + var animations = []; + var kinematics = {}; + var count = 0; + + // + + var library = { + animations: {}, + clips: {}, + controllers: {}, + images: {}, + effects: {}, + materials: {}, + cameras: {}, + lights: {}, + geometries: {}, + nodes: {}, + visualScenes: {}, + kinematicsModels: {}, + physicsModels: {}, + kinematicsScenes: {} + }; + + parseLibrary( collada, 'library_animations', 'animation', parseAnimation ); + parseLibrary( collada, 'library_animation_clips', 'animation_clip', parseAnimationClip ); + parseLibrary( collada, 'library_controllers', 'controller', parseController ); + parseLibrary( collada, 'library_images', 'image', parseImage ); + parseLibrary( collada, 'library_effects', 'effect', parseEffect ); + parseLibrary( collada, 'library_materials', 'material', parseMaterial ); + parseLibrary( collada, 'library_cameras', 'camera', parseCamera ); + parseLibrary( collada, 'library_lights', 'light', parseLight ); + parseLibrary( collada, 'library_geometries', 'geometry', parseGeometry ); + parseLibrary( collada, 'library_nodes', 'node', parseNode ); + parseLibrary( collada, 'library_visual_scenes', 'visual_scene', parseVisualScene ); + parseLibrary( collada, 'library_kinematics_models', 'kinematics_model', parseKinematicsModel ); + parseLibrary( collada, 'library_physics_models', 'physics_model', parsePhysicsModel ); + parseLibrary( collada, 'scene', 'instance_kinematics_scene', parseKinematicsScene ); + + buildLibrary( library.animations, buildAnimation ); + buildLibrary( library.clips, buildAnimationClip ); + buildLibrary( library.controllers, buildController ); + buildLibrary( library.images, buildImage ); + buildLibrary( library.effects, buildEffect ); + buildLibrary( library.materials, buildMaterial ); + buildLibrary( library.cameras, buildCamera ); + buildLibrary( library.lights, buildLight ); + buildLibrary( library.geometries, buildGeometry ); + buildLibrary( library.visualScenes, buildVisualScene ); + + setupAnimations(); + setupKinematics(); + + var scene = parseScene( getElementsByTagName( collada, 'scene' )[ 0 ] ); + + if ( asset.upAxis === 'Z_UP' ) { + + scene.quaternion.setFromEuler( new THREE.Euler( - Math.PI / 2, 0, 0 ) ); + + } + + scene.scale.multiplyScalar( asset.unit ); + + return { + animations: animations, + kinematics: kinematics, + library: library, + scene: scene + }; + + } + +}; diff --git a/three/jsutil/loaders/DDSLoader.js b/three/jsutil/loaders/DDSLoader.js new file mode 100644 index 000000000..f15a48984 --- /dev/null +++ b/three/jsutil/loaders/DDSLoader.js @@ -0,0 +1,272 @@ +/* + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.DDSLoader = function ( manager ) { + + THREE.CompressedTextureLoader.call( this, manager ); + + this._parser = THREE.DDSLoader.parse; + +}; + +THREE.DDSLoader.prototype = Object.create( THREE.CompressedTextureLoader.prototype ); +THREE.DDSLoader.prototype.constructor = THREE.DDSLoader; + +THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { + + var dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 }; + + // Adapted from @toji's DDS utils + // https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js + + // All values and structures referenced from: + // http://msdn.microsoft.com/en-us/library/bb943991.aspx/ + + var DDS_MAGIC = 0x20534444; + + var DDSD_CAPS = 0x1, + DDSD_HEIGHT = 0x2, + DDSD_WIDTH = 0x4, + DDSD_PITCH = 0x8, + DDSD_PIXELFORMAT = 0x1000, + DDSD_MIPMAPCOUNT = 0x20000, + DDSD_LINEARSIZE = 0x80000, + DDSD_DEPTH = 0x800000; + + var DDSCAPS_COMPLEX = 0x8, + DDSCAPS_MIPMAP = 0x400000, + DDSCAPS_TEXTURE = 0x1000; + + var DDSCAPS2_CUBEMAP = 0x200, + DDSCAPS2_CUBEMAP_POSITIVEX = 0x400, + DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800, + DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000, + DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000, + DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000, + DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000, + DDSCAPS2_VOLUME = 0x200000; + + var DDPF_ALPHAPIXELS = 0x1, + DDPF_ALPHA = 0x2, + DDPF_FOURCC = 0x4, + DDPF_RGB = 0x40, + DDPF_YUV = 0x200, + DDPF_LUMINANCE = 0x20000; + + function fourCCToInt32( value ) { + + return value.charCodeAt( 0 ) + + ( value.charCodeAt( 1 ) << 8 ) + + ( value.charCodeAt( 2 ) << 16 ) + + ( value.charCodeAt( 3 ) << 24 ); + + } + + function int32ToFourCC( value ) { + + return String.fromCharCode( + value & 0xff, + ( value >> 8 ) & 0xff, + ( value >> 16 ) & 0xff, + ( value >> 24 ) & 0xff + ); + + } + + function loadARGBMip( buffer, dataOffset, width, height ) { + + var dataLength = width * height * 4; + var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength ); + var byteArray = new Uint8Array( dataLength ); + var dst = 0; + var src = 0; + for ( var y = 0; y < height; y ++ ) { + + for ( var x = 0; x < width; x ++ ) { + + var b = srcBuffer[ src ]; src ++; + var g = srcBuffer[ src ]; src ++; + var r = srcBuffer[ src ]; src ++; + var a = srcBuffer[ src ]; src ++; + byteArray[ dst ] = r; dst ++; //r + byteArray[ dst ] = g; dst ++; //g + byteArray[ dst ] = b; dst ++; //b + byteArray[ dst ] = a; dst ++; //a + + } + + } + return byteArray; + + } + + var FOURCC_DXT1 = fourCCToInt32( "DXT1" ); + var FOURCC_DXT3 = fourCCToInt32( "DXT3" ); + var FOURCC_DXT5 = fourCCToInt32( "DXT5" ); + var FOURCC_ETC1 = fourCCToInt32( "ETC1" ); + + var headerLengthInt = 31; // The header length in 32 bit ints + + // Offsets into the header array + + var off_magic = 0; + + var off_size = 1; + var off_flags = 2; + var off_height = 3; + var off_width = 4; + + var off_mipmapCount = 7; + + var off_pfFlags = 20; + var off_pfFourCC = 21; + var off_RGBBitCount = 22; + var off_RBitMask = 23; + var off_GBitMask = 24; + var off_BBitMask = 25; + var off_ABitMask = 26; + + var off_caps = 27; + var off_caps2 = 28; + var off_caps3 = 29; + var off_caps4 = 30; + + // Parse header + + var header = new Int32Array( buffer, 0, headerLengthInt ); + + if ( header[ off_magic ] !== DDS_MAGIC ) { + + console.error( 'THREE.DDSLoader.parse: Invalid magic number in DDS header.' ); + return dds; + + } + + if ( ! header[ off_pfFlags ] & DDPF_FOURCC ) { + + console.error( 'THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code.' ); + return dds; + + } + + var blockBytes; + + var fourCC = header[ off_pfFourCC ]; + + var isRGBAUncompressed = false; + + switch ( fourCC ) { + + case FOURCC_DXT1: + + blockBytes = 8; + dds.format = THREE.RGB_S3TC_DXT1_Format; + break; + + case FOURCC_DXT3: + + blockBytes = 16; + dds.format = THREE.RGBA_S3TC_DXT3_Format; + break; + + case FOURCC_DXT5: + + blockBytes = 16; + dds.format = THREE.RGBA_S3TC_DXT5_Format; + break; + + case FOURCC_ETC1: + + blockBytes = 8; + dds.format = THREE.RGB_ETC1_Format; + break; + + default: + + if ( header[ off_RGBBitCount ] === 32 + && header[ off_RBitMask ] & 0xff0000 + && header[ off_GBitMask ] & 0xff00 + && header[ off_BBitMask ] & 0xff + && header[ off_ABitMask ] & 0xff000000 ) { + + isRGBAUncompressed = true; + blockBytes = 64; + dds.format = THREE.RGBAFormat; + + } else { + + console.error( 'THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC( fourCC ) ); + return dds; + + } + + } + + dds.mipmapCount = 1; + + if ( header[ off_flags ] & DDSD_MIPMAPCOUNT && loadMipmaps !== false ) { + + dds.mipmapCount = Math.max( 1, header[ off_mipmapCount ] ); + + } + + var caps2 = header[ off_caps2 ]; + dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false; + if ( dds.isCubemap && ( + ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) + ) ) { + + console.error( 'THREE.DDSLoader.parse: Incomplete cubemap faces' ); + return dds; + + } + + dds.width = header[ off_width ]; + dds.height = header[ off_height ]; + + var dataOffset = header[ off_size ] + 4; + + // Extract mipmaps buffers + + var faces = dds.isCubemap ? 6 : 1; + + for ( var face = 0; face < faces; face ++ ) { + + var width = dds.width; + var height = dds.height; + + for ( var i = 0; i < dds.mipmapCount; i ++ ) { + + if ( isRGBAUncompressed ) { + + var byteArray = loadARGBMip( buffer, dataOffset, width, height ); + var dataLength = byteArray.length; + + } else { + + var dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes; + var byteArray = new Uint8Array( buffer, dataOffset, dataLength ); + + } + + var mipmap = { "data": byteArray, "width": width, "height": height }; + dds.mipmaps.push( mipmap ); + + dataOffset += dataLength; + + width = Math.max( width >> 1, 1 ); + height = Math.max( height >> 1, 1 ); + + } + + } + + return dds; + +}; diff --git a/three/jsutil/loaders/DRACOLoader.js b/three/jsutil/loaders/DRACOLoader.js new file mode 100644 index 000000000..091615bf0 --- /dev/null +++ b/three/jsutil/loaders/DRACOLoader.js @@ -0,0 +1,512 @@ +// Copyright 2016 The Draco Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +'use strict'; + +/** + * @param {THREE.LoadingManager} manager + */ +THREE.DRACOLoader = function(manager) { + this.timeLoaded = 0; + this.manager = manager || THREE.DefaultLoadingManager; + this.materials = null; + this.verbosity = 0; + this.attributeOptions = {}; + this.drawMode = THREE.TrianglesDrawMode; + // Native Draco attribute type to Three.JS attribute type. + this.nativeAttributeMap = { + 'position' : 'POSITION', + 'normal' : 'NORMAL', + 'color' : 'COLOR', + 'uv' : 'TEX_COORD' + }; +}; + +THREE.DRACOLoader.prototype = { + + constructor: THREE.DRACOLoader, + + load: function(url, onLoad, onProgress, onError) { + var scope = this; + var loader = new THREE.FileLoader(scope.manager); + loader.setPath(this.path); + loader.setResponseType('arraybuffer'); + loader.load(url, function(blob) { + scope.decodeDracoFile(blob, onLoad); + }, onProgress, onError); + }, + + setPath: function(value) { + this.path = value; + return this; + }, + + setVerbosity: function(level) { + this.verbosity = level; + return this; + }, + + /** + * Sets desired mode for generated geometry indices. + * Can be either: + * THREE.TrianglesDrawMode + * THREE.TriangleStripDrawMode + */ + setDrawMode: function(drawMode) { + this.drawMode = drawMode; + return this; + }, + + /** + * Skips dequantization for a specific attribute. + * |attributeName| is the THREE.js name of the given attribute type. + * The only currently supported |attributeName| is 'position', more may be + * added in future. + */ + setSkipDequantization: function(attributeName, skip) { + var skipDequantization = true; + if (typeof skip !== 'undefined') + skipDequantization = skip; + this.getAttributeOptions(attributeName).skipDequantization = + skipDequantization; + return this; + }, + + /** + * |attributeUniqueIdMap| specifies attribute unique id for an attribute in + * the geometry to be decoded. The name of the attribute must be one of the + * supported attribute type in Three.JS, including: + * 'position', + * 'color', + * 'normal', + * 'uv', + * 'uv2', + * 'skinIndex', + * 'skinWeight'. + * The format is: + * attributeUniqueIdMap[attributeName] = attributeId + */ + decodeDracoFile: function(rawBuffer, callback, attributeUniqueIdMap, + attributeTypeMap) { + var scope = this; + THREE.DRACOLoader.getDecoderModule() + .then( function ( module ) { + scope.decodeDracoFileInternal( rawBuffer, module.decoder, callback, + attributeUniqueIdMap || {}, attributeTypeMap || {}); + }); + }, + + decodeDracoFileInternal: function(rawBuffer, dracoDecoder, callback, + attributeUniqueIdMap, attributeTypeMap) { + /* + * Here is how to use Draco Javascript decoder and get the geometry. + */ + var buffer = new dracoDecoder.DecoderBuffer(); + buffer.Init(new Int8Array(rawBuffer), rawBuffer.byteLength); + var decoder = new dracoDecoder.Decoder(); + + /* + * Determine what type is this file: mesh or point cloud. + */ + var geometryType = decoder.GetEncodedGeometryType(buffer); + if (geometryType == dracoDecoder.TRIANGULAR_MESH) { + if (this.verbosity > 0) { + console.log('Loaded a mesh.'); + } + } else if (geometryType == dracoDecoder.POINT_CLOUD) { + if (this.verbosity > 0) { + console.log('Loaded a point cloud.'); + } + } else { + var errorMsg = 'THREE.DRACOLoader: Unknown geometry type.'; + console.error(errorMsg); + throw new Error(errorMsg); + } + callback(this.convertDracoGeometryTo3JS(dracoDecoder, decoder, + geometryType, buffer, attributeUniqueIdMap, attributeTypeMap)); + }, + + addAttributeToGeometry: function(dracoDecoder, decoder, dracoGeometry, + attributeName, attributeType, attribute, + geometry, geometryBuffer) { + if (attribute.ptr === 0) { + var errorMsg = 'THREE.DRACOLoader: No attribute ' + attributeName; + console.error(errorMsg); + throw new Error(errorMsg); + } + + var numComponents = attribute.num_components(); + var numPoints = dracoGeometry.num_points(); + var numValues = numPoints * numComponents; + var attributeData; + var TypedBufferAttribute; + + switch ( attributeType ) { + + case Float32Array: + attributeData = new dracoDecoder.DracoFloat32Array(); + decoder.GetAttributeFloatForAllPoints( + dracoGeometry, attribute, attributeData); + geometryBuffer[ attributeName ] = new Float32Array( numValues ); + TypedBufferAttribute = THREE.Float32BufferAttribute; + break; + + case Int8Array: + attributeData = new dracoDecoder.DracoInt8Array(); + decoder.GetAttributeInt8ForAllPoints( + dracoGeometry, attribute, attributeData ); + geometryBuffer[ attributeName ] = new Int8Array( numValues ); + TypedBufferAttribute = THREE.Int8BufferAttribute; + break; + + case Int16Array: + attributeData = new dracoDecoder.DracoInt16Array(); + decoder.GetAttributeInt16ForAllPoints( + dracoGeometry, attribute, attributeData); + geometryBuffer[ attributeName ] = new Int16Array( numValues ); + TypedBufferAttribute = THREE.Int16BufferAttribute; + break; + + case Int32Array: + attributeData = new dracoDecoder.DracoInt32Array(); + decoder.GetAttributeInt32ForAllPoints( + dracoGeometry, attribute, attributeData); + geometryBuffer[ attributeName ] = new Int32Array( numValues ); + TypedBufferAttribute = THREE.Int32BufferAttribute; + break; + + case Uint8Array: + attributeData = new dracoDecoder.DracoUInt8Array(); + decoder.GetAttributeUInt8ForAllPoints( + dracoGeometry, attribute, attributeData); + geometryBuffer[ attributeName ] = new Uint8Array( numValues ); + TypedBufferAttribute = THREE.Uint8BufferAttribute; + break; + + case Uint16Array: + attributeData = new dracoDecoder.DracoUInt16Array(); + decoder.GetAttributeUInt16ForAllPoints( + dracoGeometry, attribute, attributeData); + geometryBuffer[ attributeName ] = new Uint16Array( numValues ); + TypedBufferAttribute = THREE.Uint16BufferAttribute; + break; + + case Uint32Array: + attributeData = new dracoDecoder.DracoUInt32Array(); + decoder.GetAttributeUInt32ForAllPoints( + dracoGeometry, attribute, attributeData); + geometryBuffer[ attributeName ] = new Uint32Array( numValues ); + TypedBufferAttribute = THREE.Uint32BufferAttribute; + break; + + default: + var errorMsg = 'THREE.DRACOLoader: Unexpected attribute type.'; + console.error( errorMsg ); + throw new Error( errorMsg ); + + } + + // Copy data from decoder. + for (var i = 0; i < numValues; i++) { + geometryBuffer[attributeName][i] = attributeData.GetValue(i); + } + // Add attribute to THREEJS geometry for rendering. + geometry.addAttribute(attributeName, + new TypedBufferAttribute(geometryBuffer[attributeName], + numComponents)); + dracoDecoder.destroy(attributeData); + }, + + convertDracoGeometryTo3JS: function(dracoDecoder, decoder, geometryType, + buffer, attributeUniqueIdMap, + attributeTypeMap) { + if (this.getAttributeOptions('position').skipDequantization === true) { + decoder.SkipAttributeTransform(dracoDecoder.POSITION); + } + var dracoGeometry; + var decodingStatus; + var start_time = performance.now(); + if (geometryType === dracoDecoder.TRIANGULAR_MESH) { + dracoGeometry = new dracoDecoder.Mesh(); + decodingStatus = decoder.DecodeBufferToMesh(buffer, dracoGeometry); + } else { + dracoGeometry = new dracoDecoder.PointCloud(); + decodingStatus = + decoder.DecodeBufferToPointCloud(buffer, dracoGeometry); + } + if (!decodingStatus.ok() || dracoGeometry.ptr == 0) { + var errorMsg = 'THREE.DRACOLoader: Decoding failed: '; + errorMsg += decodingStatus.error_msg(); + console.error(errorMsg); + dracoDecoder.destroy(decoder); + dracoDecoder.destroy(dracoGeometry); + throw new Error(errorMsg); + } + + var decode_end = performance.now(); + dracoDecoder.destroy(buffer); + /* + * Example on how to retrieve mesh and attributes. + */ + var numFaces; + if (geometryType == dracoDecoder.TRIANGULAR_MESH) { + numFaces = dracoGeometry.num_faces(); + if (this.verbosity > 0) { + console.log('Number of faces loaded: ' + numFaces.toString()); + } + } else { + numFaces = 0; + } + + var numPoints = dracoGeometry.num_points(); + var numAttributes = dracoGeometry.num_attributes(); + if (this.verbosity > 0) { + console.log('Number of points loaded: ' + numPoints.toString()); + console.log('Number of attributes loaded: ' + + numAttributes.toString()); + } + + // Verify if there is position attribute. + var posAttId = decoder.GetAttributeId(dracoGeometry, + dracoDecoder.POSITION); + if (posAttId == -1) { + var errorMsg = 'THREE.DRACOLoader: No position attribute found.'; + console.error(errorMsg); + dracoDecoder.destroy(decoder); + dracoDecoder.destroy(dracoGeometry); + throw new Error(errorMsg); + } + var posAttribute = decoder.GetAttribute(dracoGeometry, posAttId); + + // Structure for converting to THREEJS geometry later. + var geometryBuffer = {}; + // Import data to Three JS geometry. + var geometry = new THREE.BufferGeometry(); + + // Add native Draco attribute type to geometry. + for (var attributeName in this.nativeAttributeMap) { + // The native attribute type is only used when no unique Id is + // provided. For example, loading .drc files. + if (attributeUniqueIdMap[attributeName] === undefined) { + var attId = decoder.GetAttributeId(dracoGeometry, + dracoDecoder[this.nativeAttributeMap[attributeName]]); + if (attId !== -1) { + if (this.verbosity > 0) { + console.log('Loaded ' + attributeName + ' attribute.'); + } + var attribute = decoder.GetAttribute(dracoGeometry, attId); + this.addAttributeToGeometry(dracoDecoder, decoder, dracoGeometry, + attributeName, Float32Array, attribute, geometry, geometryBuffer); + } + } + } + + // Add attributes of user specified unique id. E.g. GLTF models. + for (var attributeName in attributeUniqueIdMap) { + var attributeType = attributeTypeMap[attributeName] || Float32Array; + var attributeId = attributeUniqueIdMap[attributeName]; + var attribute = decoder.GetAttributeByUniqueId(dracoGeometry, + attributeId); + this.addAttributeToGeometry(dracoDecoder, decoder, dracoGeometry, + attributeName, attributeType, attribute, geometry, geometryBuffer); + } + + // For mesh, we need to generate the faces. + if (geometryType == dracoDecoder.TRIANGULAR_MESH) { + if (this.drawMode === THREE.TriangleStripDrawMode) { + var stripsArray = new dracoDecoder.DracoInt32Array(); + var numStrips = decoder.GetTriangleStripsFromMesh( + dracoGeometry, stripsArray); + geometryBuffer.indices = new Uint32Array(stripsArray.size()); + for (var i = 0; i < stripsArray.size(); ++i) { + geometryBuffer.indices[i] = stripsArray.GetValue(i); + } + dracoDecoder.destroy(stripsArray); + } else { + var numIndices = numFaces * 3; + geometryBuffer.indices = new Uint32Array(numIndices); + var ia = new dracoDecoder.DracoInt32Array(); + for (var i = 0; i < numFaces; ++i) { + decoder.GetFaceFromMesh(dracoGeometry, i, ia); + var index = i * 3; + geometryBuffer.indices[index] = ia.GetValue(0); + geometryBuffer.indices[index + 1] = ia.GetValue(1); + geometryBuffer.indices[index + 2] = ia.GetValue(2); + } + dracoDecoder.destroy(ia); + } + } + + geometry.drawMode = this.drawMode; + if (geometryType == dracoDecoder.TRIANGULAR_MESH) { + geometry.setIndex(new(geometryBuffer.indices.length > 65535 ? + THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute) + (geometryBuffer.indices, 1)); + } + var posTransform = new dracoDecoder.AttributeQuantizationTransform(); + if (posTransform.InitFromAttribute(posAttribute)) { + // Quantized attribute. Store the quantization parameters into the + // THREE.js attribute. + geometry.attributes['position'].isQuantized = true; + geometry.attributes['position'].maxRange = posTransform.range(); + geometry.attributes['position'].numQuantizationBits = + posTransform.quantization_bits(); + geometry.attributes['position'].minValues = new Float32Array(3); + for (var i = 0; i < 3; ++i) { + geometry.attributes['position'].minValues[i] = + posTransform.min_value(i); + } + } + dracoDecoder.destroy(posTransform); + dracoDecoder.destroy(decoder); + dracoDecoder.destroy(dracoGeometry); + + this.decode_time = decode_end - start_time; + this.import_time = performance.now() - decode_end; + + if (this.verbosity > 0) { + console.log('Decode time: ' + this.decode_time); + console.log('Import time: ' + this.import_time); + } + return geometry; + }, + + isVersionSupported: function(version, callback) { + THREE.DRACOLoader.getDecoderModule() + .then( function ( module ) { + callback( module.decoder.isVersionSupported( version ) ); + }); + }, + + getAttributeOptions: function(attributeName) { + if (typeof this.attributeOptions[attributeName] === 'undefined') + this.attributeOptions[attributeName] = {}; + return this.attributeOptions[attributeName]; + } +}; + +THREE.DRACOLoader.decoderPath = './'; +THREE.DRACOLoader.decoderConfig = {}; +THREE.DRACOLoader.decoderModulePromise = null; + +/** + * Sets the base path for decoder source files. + * @param {string} path + */ +THREE.DRACOLoader.setDecoderPath = function ( path ) { + THREE.DRACOLoader.decoderPath = path; +}; + +/** + * Sets decoder configuration and releases singleton decoder module. Module + * will be recreated with the next decoding call. + * @param {Object} config + */ +THREE.DRACOLoader.setDecoderConfig = function ( config ) { + var wasmBinary = THREE.DRACOLoader.decoderConfig.wasmBinary; + THREE.DRACOLoader.decoderConfig = config || {}; + THREE.DRACOLoader.releaseDecoderModule(); + + // Reuse WASM binary. + if ( wasmBinary ) THREE.DRACOLoader.decoderConfig.wasmBinary = wasmBinary; +}; + +/** + * Releases the singleton DracoDecoderModule instance. Module will be recreated + * with the next decoding call. + */ +THREE.DRACOLoader.releaseDecoderModule = function () { + THREE.DRACOLoader.decoderModulePromise = null; +}; + +/** + * Gets WebAssembly or asm.js singleton instance of DracoDecoderModule + * after testing for browser support. Returns Promise that resolves when + * module is available. + * @return {Promise<{decoder: DracoDecoderModule}>} + */ +THREE.DRACOLoader.getDecoderModule = function () { + var scope = this; + var path = THREE.DRACOLoader.decoderPath; + var config = THREE.DRACOLoader.decoderConfig; + var promise = THREE.DRACOLoader.decoderModulePromise; + + if ( promise ) return promise; + + // Load source files. + if ( typeof DracoDecoderModule !== 'undefined' ) { + // Loaded externally. + promise = Promise.resolve(); + } else if ( typeof WebAssembly !== 'object' || config.type === 'js' ) { + // Load with asm.js. + promise = THREE.DRACOLoader._loadScript( path + 'draco_decoder.js' ); + } else { + // Load with WebAssembly. + config.wasmBinaryFile = path + 'draco_decoder.wasm'; + promise = THREE.DRACOLoader._loadScript( path + 'draco_wasm_wrapper.js' ) + .then( function () { + return THREE.DRACOLoader._loadArrayBuffer( config.wasmBinaryFile ); + } ) + .then( function ( wasmBinary ) { + config.wasmBinary = wasmBinary; + } ); + } + + // Wait for source files, then create and return a decoder. + promise = promise.then( function () { + return new Promise( function ( resolve ) { + config.onModuleLoaded = function ( decoder ) { + scope.timeLoaded = performance.now(); + // Module is Promise-like. Wrap before resolving to avoid loop. + resolve( { decoder: decoder } ); + }; + DracoDecoderModule( config ); + } ); + } ); + + THREE.DRACOLoader.decoderModulePromise = promise; + return promise; +}; + +/** + * @param {string} src + * @return {Promise} + */ +THREE.DRACOLoader._loadScript = function ( src ) { + var prevScript = document.getElementById( 'decoder_script' ); + if ( prevScript !== null ) { + prevScript.parentNode.removeChild( prevScript ); + } + var head = document.getElementsByTagName( 'head' )[ 0 ]; + var script = document.createElement( 'script' ); + script.id = 'decoder_script'; + script.type = 'text/javascript'; + script.src = src; + return new Promise( function ( resolve ) { + script.onload = resolve; + head.appendChild( script ); + }); +}; + +/** + * @param {string} src + * @return {Promise} + */ +THREE.DRACOLoader._loadArrayBuffer = function ( src ) { + var loader = new THREE.FileLoader(); + loader.setResponseType( 'arraybuffer' ); + return new Promise( function( resolve, reject ) { + loader.load( src, resolve, undefined, reject ); + }); +}; diff --git a/three/jsutil/loaders/EXRLoader.js b/three/jsutil/loaders/EXRLoader.js new file mode 100644 index 000000000..c7bb432e5 --- /dev/null +++ b/three/jsutil/loaders/EXRLoader.js @@ -0,0 +1,1184 @@ +/** + * @author Richard M. / https://github.com/richardmonette + * + * OpenEXR loader which, currently, supports reading 16 bit half data, in either + * uncompressed or PIZ wavelet compressed form. + * + * Referred to the original Industrial Light & Magic OpenEXR implementation and the TinyEXR / Syoyo Fujita + * implementation, so I have preserved their copyright notices. + */ + +// /* +// Copyright (c) 2014 - 2017, Syoyo Fujita +// All rights reserved. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Syoyo Fujita nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// */ + +// // TinyEXR contains some OpenEXR code, which is licensed under ------------ + +// /////////////////////////////////////////////////////////////////////////// +// // +// // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas +// // Digital Ltd. LLC +// // +// // All rights reserved. +// // +// // Redistribution and use in source and binary forms, with or without +// // modification, are permitted provided that the following conditions are +// // met: +// // * Redistributions of source code must retain the above copyright +// // notice, this list of conditions and the following disclaimer. +// // * Redistributions in binary form must reproduce the above +// // copyright notice, this list of conditions and the following disclaimer +// // in the documentation and/or other materials provided with the +// // distribution. +// // * Neither the name of Industrial Light & Magic nor the names of +// // its contributors may be used to endorse or promote products derived +// // from this software without specific prior written permission. +// // +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// // +// /////////////////////////////////////////////////////////////////////////// + +// // End of OpenEXR license ------------------------------------------------- + +THREE.EXRLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.EXRLoader.prototype = Object.create( THREE.DataTextureLoader.prototype ); + +THREE.EXRLoader.prototype._parser = function ( buffer ) { + + const USHORT_RANGE = (1 << 16); + const BITMAP_SIZE = (USHORT_RANGE >> 3); + + const HUF_ENCBITS = 16; // literal (value) bit length + const HUF_DECBITS = 14; // decoding bit size (>= 8) + + const HUF_ENCSIZE = (1 << HUF_ENCBITS) + 1; // encoding table size + const HUF_DECSIZE = 1 << HUF_DECBITS; // decoding table size + const HUF_DECMASK = HUF_DECSIZE - 1; + + const SHORT_ZEROCODE_RUN = 59; + const LONG_ZEROCODE_RUN = 63; + const SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; + const LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN; + + const BYTES_PER_HALF = 2; + + const ULONG_SIZE = 8; + const FLOAT32_SIZE = 4; + const INT32_SIZE = 4; + const INT16_SIZE = 2; + const INT8_SIZE = 1; + + function reverseLutFromBitmap( bitmap, lut ) { + + var k = 0; + + for ( var i = 0; i < USHORT_RANGE; ++ i ) { + + if ( ( i == 0 ) || ( bitmap[ i >> 3 ] & ( 1 << ( i & 7 ) ) ) ) { + + lut[ k ++ ] = i; + + } + + } + + var n = k - 1; + + while ( k < USHORT_RANGE ) lut[ k ++ ] = 0; + + return n; + + } + + function hufClearDecTable( hdec ) { + + for ( var i = 0; i < HUF_DECSIZE; i ++ ) { + + hdec[ i ] = {}; + hdec[ i ].len = 0; + hdec[ i ].lit = 0; + hdec[ i ].p = null; + + } + + } + + const getBitsReturn = { l: 0, c: 0, lc: 0 }; + + function getBits( nBits, c, lc, uInt8Array, inOffset ) { + + while ( lc < nBits ) { + + c = ( c << 8 ) | parseUint8Array( uInt8Array, inOffset ); + lc += 8; + + } + + lc -= nBits; + + getBitsReturn.l = ( c >> lc ) & ( ( 1 << nBits ) - 1 ); + getBitsReturn.c = c; + getBitsReturn.lc = lc; + } + + const hufTableBuffer = new Array( 59 ); + + function hufCanonicalCodeTable( hcode ) { + + for ( var i = 0; i <= 58; ++ i ) hufTableBuffer[ i ] = 0; + for ( var i = 0; i < HUF_ENCSIZE; ++ i ) hufTableBuffer[ hcode[ i ] ] += 1; + + var c = 0; + + for ( var i = 58; i > 0; -- i ) { + + var nc = ( ( c + hufTableBuffer[ i ] ) >> 1 ); + hufTableBuffer[ i ] = c; + c = nc; + + } + + for ( var i = 0; i < HUF_ENCSIZE; ++ i ) { + + var l = hcode[ i ]; + if ( l > 0 ) hcode[ i ] = l | ( hufTableBuffer[ l ] ++ << 6 ); + + } + + } + + function hufUnpackEncTable( uInt8Array, inDataView, inOffset, ni, im, iM, hcode ) { + + var p = inOffset; + var c = 0; + var lc = 0; + + for ( ; im <= iM; im ++ ) { + + if ( p.value - inOffset.value > ni ) return false; + + getBits( 6, c, lc, uInt8Array, p ); + + var l = getBitsReturn.l; + c = getBitsReturn.c; + lc = getBitsReturn.lc; + + hcode[ im ] = l; + + if ( l == LONG_ZEROCODE_RUN ) { + + if ( p.value - inOffset.value > ni ) { + + throw 'Something wrong with hufUnpackEncTable'; + + } + + getBits( 8, c, lc, uInt8Array, p ); + + var zerun = getBitsReturn.l + SHORTEST_LONG_RUN; + c = getBitsReturn.c; + lc = getBitsReturn.lc; + + if ( im + zerun > iM + 1 ) { + + throw 'Something wrong with hufUnpackEncTable'; + + } + + while ( zerun -- ) hcode[ im ++ ] = 0; + + im --; + + } else if ( l >= SHORT_ZEROCODE_RUN ) { + + var zerun = l - SHORT_ZEROCODE_RUN + 2; + + if ( im + zerun > iM + 1 ) { + + throw 'Something wrong with hufUnpackEncTable'; + + } + + while ( zerun -- ) hcode[ im ++ ] = 0; + + im --; + + } + + } + + hufCanonicalCodeTable( hcode ); + + } + + function hufLength( code ) { return code & 63; } + + function hufCode( code ) { return code >> 6; } + + function hufBuildDecTable( hcode, im, iM, hdecod ) { + + for ( ; im <= iM; im ++ ) { + + var c = hufCode( hcode[ im ] ); + var l = hufLength( hcode[ im ] ); + + if ( c >> l ) { + + throw 'Invalid table entry'; + + } + + if ( l > HUF_DECBITS ) { + + var pl = hdecod[ ( c >> ( l - HUF_DECBITS ) ) ]; + + if ( pl.len ) { + + throw 'Invalid table entry'; + + } + + pl.lit ++; + + if ( pl.p ) { + + var p = pl.p; + pl.p = new Array( pl.lit ); + + for ( var i = 0; i < pl.lit - 1; ++ i ) { + + pl.p[ i ] = p[ i ]; + + } + + } else { + + pl.p = new Array( 1 ); + + } + + pl.p[ pl.lit - 1 ] = im; + + } else if ( l ) { + + var plOffset = 0; + + for ( var i = 1 << ( HUF_DECBITS - l ); i > 0; i -- ) { + + var pl = hdecod[ ( c << ( HUF_DECBITS - l ) ) + plOffset ]; + + if ( pl.len || pl.p ) { + + throw 'Invalid table entry'; + + } + + pl.len = l; + pl.lit = im; + + plOffset ++; + + } + + } + + } + + return true; + + } + + const getCharReturn = { c: 0, lc: 0 }; + + function getChar( c, lc, uInt8Array, inOffset ) { + + c = ( c << 8 ) | parseUint8Array( uInt8Array, inOffset ); + lc += 8; + + getCharReturn.c = c; + getCharReturn.lc = lc; + + } + + const getCodeReturn = { c: 0, lc: 0 }; + + function getCode( po, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outBufferOffset, outBufferEndOffset ) { + + if ( po == rlc ) { + + if ( lc < 8 ) { + + getChar( c, lc, uInt8Array, inOffset ); + c = getCharReturn.c; + lc = getCharReturn.lc; + + } + + lc -= 8; + + var cs = ( c >> lc ); + var cs = new Uint8Array([cs])[0]; + + if ( outBufferOffset.value + cs > outBufferEndOffset ) { + + return false; + + } + + var s = outBuffer[ outBufferOffset.value - 1 ]; + + while ( cs-- > 0 ) { + + outBuffer[ outBufferOffset.value ++ ] = s; + + } + + } else if ( outBufferOffset.value < outBufferEndOffset ) { + + outBuffer[ outBufferOffset.value ++ ] = po; + + } else { + + return false; + + } + + getCodeReturn.c = c; + getCodeReturn.lc = lc; + + } + + var NBITS = 16; + var A_OFFSET = 1 << ( NBITS - 1 ); + var M_OFFSET = 1 << ( NBITS - 1 ); + var MOD_MASK = ( 1 << NBITS ) - 1; + + function UInt16( value ) { + + return ( value & 0xFFFF ); + + } + + function Int16( value ) { + + var ref = UInt16( value ); + return ( ref > 0x7FFF ) ? ref - 0x10000 : ref; + + } + + const wdec14Return = { a: 0, b: 0 }; + + function wdec14( l, h ) { + + var ls = Int16( l ); + var hs = Int16( h ); + + var hi = hs; + var ai = ls + ( hi & 1 ) + ( hi >> 1 ); + + var as = ai; + var bs = ai - hi; + + wdec14Return.a = as; + wdec14Return.b = bs; + + } + + function wav2Decode( j, buffer, nx, ox, ny, oy, mx ) { + + var n = ( nx > ny ) ? ny : nx; + var p = 1; + var p2; + + while ( p <= n ) p <<= 1; + + p >>= 1; + p2 = p; + p >>= 1; + + while ( p >= 1 ) { + + var py = 0; + var ey = py + oy * ( ny - p2 ); + var oy1 = oy * p; + var oy2 = oy * p2; + var ox1 = ox * p; + var ox2 = ox * p2; + var i00, i01, i10, i11; + + for ( ; py <= ey; py += oy2 ) { + + var px = py; + var ex = py + ox * ( nx - p2 ); + + for ( ; px <= ex; px += ox2 ) { + + var p01 = px + ox1; + var p10 = px + oy1; + var p11 = p10 + ox1; + + wdec14( buffer[ px + j ], buffer[ p10 + j ] ); + + i00 = wdec14Return.a; + i10 = wdec14Return.b; + + wdec14( buffer[ p01 + j ], buffer[ p11 + j ] ); + + i01 = wdec14Return.a; + i11 = wdec14Return.b; + + wdec14( i00, i01 ); + + buffer[ px + j ] = wdec14Return.a; + buffer[ p01 + j ] = wdec14Return.b; + + wdec14( i10, i11 ); + + buffer[ p10 + j ] = wdec14Return.a; + buffer[ p11 + j ] = wdec14Return.b; + + } + + if ( nx & p ) { + + var p10 = px + oy1; + + wdec14( buffer[ px + j ], buffer[ p10 + j ] ); + + i00 = wdec14Return.a; + buffer[ p10 + j ] = wdec14Return.b; + + buffer[ px + j ] = i00; + + } + + } + + if ( ny & p ) { + + var px = py; + var ex = py + ox * ( nx - p2 ); + + for ( ; px <= ex; px += ox2 ) { + + var p01 = px + ox1; + + wdec14( buffer[ px + j ], buffer[ p01 + j ] ); + + i00 = wdec14Return.a; + buffer[ p01 + j ] = wdec14Return.b; + + buffer[ px + j ] = i00; + + } + + } + + p2 = p; + p >>= 1; + + } + + return py; + + } + + function hufDecode( encodingTable, decodingTable, uInt8Array, inDataView, inOffset, ni, rlc, no, outBuffer, outOffset ) { + + var c = 0; + var lc = 0; + var outBufferEndOffset = no; + var inOffsetEnd = Math.trunc( inOffset.value + ( ni + 7 ) / 8 ); + + while ( inOffset.value < inOffsetEnd ) { + + getChar( c, lc, uInt8Array, inOffset ); + + c = getCharReturn.c; + lc = getCharReturn.lc; + + while ( lc >= HUF_DECBITS ) { + + var index = ( c >> ( lc - HUF_DECBITS ) ) & HUF_DECMASK; + var pl = decodingTable[ index ]; + + if ( pl.len ) { + + lc -= pl.len; + + getCode( pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset ); + + c = getCodeReturn.c; + lc = getCodeReturn.lc; + + } else { + + if ( ! pl.p ) { + + throw 'hufDecode issues'; + + } + + var j; + + for ( j = 0; j < pl.lit; j ++ ) { + + var l = hufLength( encodingTable[ pl.p[ j ] ] ); + + while ( lc < l && inOffset.value < inOffsetEnd ) { + + getChar( c, lc, uInt8Array, inOffset ); + + c = getCharReturn.c; + lc = getCharReturn.lc; + + } + + if ( lc >= l ) { + + if ( hufCode( encodingTable[ pl.p[ j ] ] ) == ( ( c >> ( lc - l ) ) & ( ( 1 << l ) - 1 ) ) ) { + + lc -= l; + + getCode( pl.p[ j ], rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset ); + + c = getCodeReturn.c; + lc = getCodeReturn.lc; + + break; + + } + + } + + } + + if ( j == pl.lit ) { + + throw 'hufDecode issues'; + + } + + } + + } + + } + + var i = ( 8 - ni ) & 7; + + c >>= i; + lc -= i; + + while ( lc > 0 ) { + + var pl = decodingTable[ ( c << ( HUF_DECBITS - lc ) ) & HUF_DECMASK ]; + + if ( pl.len ) { + + lc -= pl.len; + + getCode( pl.lit, rlc, c, lc, uInt8Array, inDataView, inOffset, outBuffer, outOffset, outBufferEndOffset ); + + c = getCodeReturn.c; + lc = getCodeReturn.lc; + + } else { + + throw 'hufDecode issues'; + + } + + } + + return true; + + } + + function hufUncompress( uInt8Array, inDataView, inOffset, nCompressed, outBuffer, outOffset, nRaw ) { + + var initialInOffset = inOffset.value; + + var im = parseUint32( inDataView, inOffset ); + var iM = parseUint32( inDataView, inOffset ); + + inOffset.value += 4; + + var nBits = parseUint32( inDataView, inOffset ); + + inOffset.value += 4; + + if ( im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE ) { + + throw 'Something wrong with HUF_ENCSIZE'; + + } + + var freq = new Array( HUF_ENCSIZE ); + var hdec = new Array( HUF_DECSIZE ); + + hufClearDecTable( hdec ); + + var ni = nCompressed - ( inOffset.value - initialInOffset ); + + hufUnpackEncTable( uInt8Array, inDataView, inOffset, ni, im, iM, freq ); + + if ( nBits > 8 * ( nCompressed - ( inOffset.value - initialInOffset ) ) ) { + + throw 'Something wrong with hufUncompress'; + + } + + hufBuildDecTable( freq, im, iM, hdec ); + + hufDecode( freq, hdec, uInt8Array, inDataView, inOffset, nBits, iM, nRaw, outBuffer, outOffset ); + + } + + function applyLut( lut, data, nData ) { + + for ( var i = 0; i < nData; ++ i ) { + + data[ i ] = lut[ data[ i ] ]; + + } + + } + + function decompressPIZ( outBuffer, outOffset, uInt8Array, inDataView, inOffset, tmpBufSize, num_channels, exrChannelInfos, dataWidth, num_lines ) { + + var bitmap = new Uint8Array( BITMAP_SIZE ); + + var minNonZero = parseUint16( inDataView, inOffset ); + var maxNonZero = parseUint16( inDataView, inOffset ); + + if ( maxNonZero >= BITMAP_SIZE ) { + + throw 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE'; + + } + + if ( minNonZero <= maxNonZero ) { + + for ( var i = 0; i < maxNonZero - minNonZero + 1; i ++ ) { + + bitmap[ i + minNonZero ] = parseUint8( inDataView, inOffset ); + + } + + } + + var lut = new Uint16Array( USHORT_RANGE ); + var maxValue = reverseLutFromBitmap( bitmap, lut ); + + var length = parseUint32( inDataView, inOffset ); + + hufUncompress( uInt8Array, inDataView, inOffset, length, outBuffer, outOffset, tmpBufSize ); + + var pizChannelData = new Array( num_channels ); + + var outBufferEnd = 0; + + for ( var i = 0; i < num_channels; i ++ ) { + + var exrChannelInfo = exrChannelInfos[ i ]; + + var pixelSize = 2; // assumes HALF_FLOAT + + pizChannelData[ i ] = {}; + pizChannelData[ i ][ 'start' ] = outBufferEnd; + pizChannelData[ i ][ 'end' ] = pizChannelData[ i ][ 'start' ]; + pizChannelData[ i ][ 'nx' ] = dataWidth; + pizChannelData[ i ][ 'ny' ] = num_lines; + pizChannelData[ i ][ 'size' ] = 1; + + outBufferEnd += pizChannelData[ i ].nx * pizChannelData[ i ].ny * pizChannelData[ i ].size; + + } + + var fooOffset = 0; + + for ( var i = 0; i < num_channels; i ++ ) { + + for ( var j = 0; j < pizChannelData[ i ].size; ++ j ) { + + fooOffset += wav2Decode( + j + fooOffset, + outBuffer, + pizChannelData[ i ].nx, + pizChannelData[ i ].size, + pizChannelData[ i ].ny, + pizChannelData[ i ].nx * pizChannelData[ i ].size, + maxValue + ); + + } + + } + + applyLut( lut, outBuffer, outBufferEnd ); + + return true; + + } + + function parseNullTerminatedString( buffer, offset ) { + + var uintBuffer = new Uint8Array( buffer ); + var endOffset = 0; + + while ( uintBuffer[ offset.value + endOffset ] != 0 ) { + + endOffset += 1; + + } + + var stringValue = new TextDecoder().decode( + uintBuffer.slice( offset.value, offset.value + endOffset ) + ); + + offset.value = offset.value + endOffset + 1; + + return stringValue; + + } + + function parseFixedLengthString( buffer, offset, size ) { + + var stringValue = new TextDecoder().decode( + new Uint8Array( buffer ).slice( offset.value, offset.value + size ) + ); + + offset.value = offset.value + size; + + return stringValue; + + } + + function parseUlong( dataView, offset ) { + + var uLong = dataView.getUint32( 0, true ); + + offset.value = offset.value + ULONG_SIZE; + + return uLong; + + } + + function parseUint32( dataView, offset ) { + + var Uint32 = dataView.getUint32(offset.value, true); + + offset.value = offset.value + INT32_SIZE; + + return Uint32; + + } + + function parseUint8Array( uInt8Array, offset ) { + + var Uint8 = uInt8Array[offset.value]; + + offset.value = offset.value + INT8_SIZE; + + return Uint8; + + } + + function parseUint8( dataView, offset ) { + + var Uint8 = dataView.getUint8(offset.value); + + offset.value = offset.value + INT8_SIZE; + + return Uint8; + + } + + function parseFloat32( dataView, offset ) { + + var float = dataView.getFloat32(offset.value, true); + + offset.value += FLOAT32_SIZE; + + return float; + + } + + // https://stackoverflow.com/questions/5678432/decompressing-half-precision-floats-in-javascript + function decodeFloat16( binary ) { + + var exponent = ( binary & 0x7C00 ) >> 10, + fraction = binary & 0x03FF; + + return ( binary >> 15 ? - 1 : 1 ) * ( + exponent ? + ( + exponent === 0x1F ? + fraction ? NaN : Infinity : + Math.pow( 2, exponent - 15 ) * ( 1 + fraction / 0x400 ) + ) : + 6.103515625e-5 * ( fraction / 0x400 ) + ); + + } + + function parseUint16( dataView, offset ) { + + var Uint16 = dataView.getUint16( offset.value, true ); + + offset.value += INT16_SIZE; + + return Uint16; + + } + + function parseFloat16( buffer, offset ) { + + return decodeFloat16( parseUint16( buffer, offset) ); + + } + + function parseChlist( dataView, buffer, offset, size ) { + + var startOffset = offset.value; + var channels = []; + + while ( offset.value < ( startOffset + size - 1 ) ) { + + var name = parseNullTerminatedString( buffer, offset ); + var pixelType = parseUint32( dataView, offset ); // TODO: Cast this to UINT, HALF or FLOAT + var pLinear = parseUint8( dataView, offset ); + offset.value += 3; // reserved, three chars + var xSampling = parseUint32( dataView, offset ); + var ySampling = parseUint32( dataView, offset ); + + channels.push( { + name: name, + pixelType: pixelType, + pLinear: pLinear, + xSampling: xSampling, + ySampling: ySampling + } ); + + } + + offset.value += 1; + + return channels; + + } + + function parseChromaticities( dataView, offset ) { + + var redX = parseFloat32( dataView, offset ); + var redY = parseFloat32( dataView, offset ); + var greenX = parseFloat32( dataView, offset ); + var greenY = parseFloat32( dataView, offset ); + var blueX = parseFloat32( dataView, offset ); + var blueY = parseFloat32( dataView, offset ); + var whiteX = parseFloat32( dataView, offset ); + var whiteY = parseFloat32( dataView, offset ); + + return { redX: redX, redY: redY, greenX: greenX, greenY: greenY, blueX: blueX, blueY: blueY, whiteX: whiteX, whiteY: whiteY }; + + } + + function parseCompression( dataView, offset ) { + + var compressionCodes = [ + 'NO_COMPRESSION', + 'RLE_COMPRESSION', + 'ZIPS_COMPRESSION', + 'ZIP_COMPRESSION', + 'PIZ_COMPRESSION', + 'PXR24_COMPRESSION', + 'B44_COMPRESSION', + 'B44A_COMPRESSION', + 'DWAA_COMPRESSION', + 'DWAB_COMPRESSION' + ]; + + var compression = parseUint8( dataView, offset ); + + return compressionCodes[ compression ]; + + } + + function parseBox2i( dataView, offset ) { + + var xMin = parseUint32( dataView, offset ); + var yMin = parseUint32( dataView, offset ); + var xMax = parseUint32( dataView, offset ); + var yMax = parseUint32( dataView, offset ); + + return { xMin: xMin, yMin: yMin, xMax: xMax, yMax: yMax }; + + } + + function parseLineOrder( dataView, offset ) { + + var lineOrders = [ + 'INCREASING_Y' + ]; + + var lineOrder = parseUint8( dataView, offset ); + + return lineOrders[ lineOrder ]; + + } + + function parseV2f( dataView, offset ) { + + var x = parseFloat32( dataView, offset ); + var y = parseFloat32( dataView, offset ); + + return [ x, y ]; + + } + + function parseValue( dataView, buffer, offset, type, size ) { + + if ( type === 'string' || type === 'iccProfile' ) { + + return parseFixedLengthString( buffer, offset, size ); + + } else if ( type === 'chlist' ) { + + return parseChlist( dataView, buffer, offset, size ); + + } else if ( type === 'chromaticities' ) { + + return parseChromaticities( dataView, offset ); + + } else if ( type === 'compression' ) { + + return parseCompression( dataView, offset ); + + } else if ( type === 'box2i' ) { + + return parseBox2i( dataView, offset ); + + } else if ( type === 'lineOrder' ) { + + return parseLineOrder( dataView, offset ); + + } else if ( type === 'float' ) { + + return parseFloat32( dataView, offset ); + + } else if ( type === 'v2f' ) { + + return parseV2f( dataView, offset ); + + } else if ( type === 'int' ) { + + return parseUint32( dataView, offset ); + + } else { + + throw 'Cannot parse value for unsupported type: ' + type; + + } + + } + + var bufferDataView = new DataView(buffer); + var uInt8Array = new Uint8Array(buffer); + + var EXRHeader = {}; + + var magic = bufferDataView.getUint32( 0, true ); + var versionByteZero = bufferDataView.getUint8( 4, true ); + var fullMask = bufferDataView.getUint8( 5, true ); + + // start of header + + var offset = { value: 8 }; // start at 8, after magic stuff + + var keepReading = true; + + while ( keepReading ) { + + var attributeName = parseNullTerminatedString( buffer, offset ); + + if ( attributeName == 0 ) { + + keepReading = false; + + } else { + + var attributeType = parseNullTerminatedString( buffer, offset ); + var attributeSize = parseUint32( bufferDataView, offset ); + var attributeValue = parseValue( bufferDataView, buffer, offset, attributeType, attributeSize ); + + EXRHeader[ attributeName ] = attributeValue; + + } + + } + + // offsets + + var dataWindowHeight = EXRHeader.dataWindow.yMax + 1; + var scanlineBlockSize = 1; // 1 for NO_COMPRESSION + + if ( EXRHeader.compression === 'PIZ_COMPRESSION' ) { + + scanlineBlockSize = 32; + + } + + var numBlocks = dataWindowHeight / scanlineBlockSize; + + for ( var i = 0; i < numBlocks; i ++ ) { + + var scanlineOffset = parseUlong( bufferDataView, offset ); + + } + + // we should be passed the scanline offset table, start reading pixel data + + var width = EXRHeader.dataWindow.xMax - EXRHeader.dataWindow.xMin + 1; + var height = EXRHeader.dataWindow.yMax - EXRHeader.dataWindow.yMin + 1; + var numChannels = EXRHeader.channels.length; + + var byteArray = new Float32Array( width * height * numChannels ); + + var channelOffsets = { + R: 0, + G: 1, + B: 2, + A: 3 + }; + + if ( EXRHeader.compression === 'NO_COMPRESSION' ) { + + for ( var y = 0; y < height; y ++ ) { + + var y_scanline = parseUint32( bufferDataView, offset ); + var dataSize = parseUint32( bufferDataView, offset ); + + for ( var channelID = 0; channelID < EXRHeader.channels.length; channelID ++ ) { + + var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ]; + + if ( EXRHeader.channels[ channelID ].pixelType === 1 ) { + + // HALF + for ( var x = 0; x < width; x ++ ) { + + var val = parseFloat16( bufferDataView, offset ); + + byteArray[ ( ( ( height - y_scanline ) * ( width * numChannels ) ) + ( x * numChannels ) ) + cOff ] = val; + + } + + } else { + + throw 'EXRLoader._parser: unsupported pixelType ' + EXRHeader.channels[ channelID ].pixelType + '. Only pixelType is 1 (HALF) is supported.'; + + } + + } + + } + + } else if ( EXRHeader.compression === 'PIZ_COMPRESSION' ) { + + for ( var scanlineBlockIdx = 0; scanlineBlockIdx < height / scanlineBlockSize; scanlineBlockIdx ++ ) { + + var line_no = parseUint32( bufferDataView, offset ); + var data_len = parseUint32( bufferDataView, offset ); + + var tmpBufferSize = width * scanlineBlockSize * ( EXRHeader.channels.length * BYTES_PER_HALF ); + var tmpBuffer = new Uint16Array( tmpBufferSize ); + var tmpOffset = { value: 0 }; + + decompressPIZ( tmpBuffer, tmpOffset, uInt8Array, bufferDataView, offset, tmpBufferSize, numChannels, EXRHeader.channels, width, scanlineBlockSize ); + + for ( var line_y = 0; line_y < scanlineBlockSize; line_y ++ ) { + + for ( var channelID = 0; channelID < EXRHeader.channels.length; channelID ++ ) { + + var cOff = channelOffsets[ EXRHeader.channels[ channelID ].name ]; + + if ( EXRHeader.channels[ channelID ].pixelType === 1 ) { + + // HALF + for ( var x = 0; x < width; x ++ ) { + + var val = decodeFloat16( tmpBuffer[ ( channelID * ( scanlineBlockSize * width ) ) + ( line_y * width ) + x ] ); + + var true_y = line_y + ( scanlineBlockIdx * scanlineBlockSize ); + + byteArray[ ( ( ( height - true_y ) * ( width * numChannels ) ) + ( x * numChannels ) ) + cOff ] = val; + + } + + } else { + + throw 'EXRLoader._parser: unsupported pixelType ' + EXRHeader.channels[ channelID ].pixelType + '. Only pixelType is 1 (HALF) is supported.'; + + } + + } + + } + + } + + } else { + + throw 'EXRLoader._parser: ' + EXRHeader.compression + ' is unsupported'; + + } + + return { + header: EXRHeader, + width: width, + height: height, + data: byteArray, + format: EXRHeader.channels.length == 4 ? THREE.RGBAFormat : THREE.RGBFormat, + type: THREE.FloatType + }; + +}; diff --git a/three/jsutil/loaders/EquirectangularToCubeGenerator.js b/three/jsutil/loaders/EquirectangularToCubeGenerator.js new file mode 100644 index 000000000..bd7c4f2be --- /dev/null +++ b/three/jsutil/loaders/EquirectangularToCubeGenerator.js @@ -0,0 +1,116 @@ +/** +* @author Richard M. / https://github.com/richardmonette +*/ + +THREE.EquirectangularToCubeGenerator = function ( sourceTexture, options ) { + + this.sourceTexture = sourceTexture; + this.resolution = options.resolution || 512; + + this.views = [ + { t: [ 1, 0, 0 ], u: [ 0, - 1, 0 ] }, + { t: [ - 1, 0, 0 ], u: [ 0, - 1, 0 ] }, + { t: [ 0, 1, 0 ], u: [ 0, 0, 1 ] }, + { t: [ 0, - 1, 0 ], u: [ 0, 0, - 1 ] }, + { t: [ 0, 0, 1 ], u: [ 0, - 1, 0 ] }, + { t: [ 0, 0, - 1 ], u: [ 0, - 1, 0 ] }, + ]; + + this.camera = new THREE.PerspectiveCamera( 90, 1, 0.1, 10 ); + this.boxMesh = new THREE.Mesh( new THREE.BoxBufferGeometry( 1, 1, 1 ), this.getShader() ); + this.boxMesh.material.side = THREE.BackSide; + this.scene = new THREE.Scene(); + this.scene.add( this.boxMesh ); + + var params = { + format: options.format || this.sourceTexture.format, + magFilter: this.sourceTexture.magFilter, + minFilter: this.sourceTexture.minFilter, + type: options.type || this.sourceTexture.type, + generateMipmaps: this.sourceTexture.generateMipmaps, + anisotropy: this.sourceTexture.anisotropy, + encoding: this.sourceTexture.encoding + }; + + this.renderTarget = new THREE.WebGLRenderTargetCube( this.resolution, this.resolution, params ); + +}; + +THREE.EquirectangularToCubeGenerator.prototype = { + + constructor: THREE.EquirectangularToCubeGenerator, + + update: function ( renderer ) { + + for ( var i = 0; i < 6; i ++ ) { + + this.renderTarget.activeCubeFace = i; + + var v = this.views[ i ]; + + this.camera.position.set( 0, 0, 0 ); + this.camera.up.set( v.u[ 0 ], v.u[ 1 ], v.u[ 2 ] ); + this.camera.lookAt( v.t[ 0 ], v.t[ 1 ], v.t[ 2 ] ); + + renderer.render( this.scene, this.camera, this.renderTarget, true ); + + } + + return this.renderTarget.texture; + + }, + + getShader: function () { + + var shaderMaterial = new THREE.ShaderMaterial( { + + uniforms: { + "equirectangularMap": { value: this.sourceTexture }, + }, + + vertexShader: + "varying vec3 localPosition;\n\ + \n\ + void main() {\n\ + localPosition = position;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "#include \n\ + varying vec3 localPosition;\n\ + uniform sampler2D equirectangularMap;\n\ + \n\ + vec2 EquirectangularSampleUV(vec3 v) {\n\ + vec2 uv = vec2(atan(v.z, v.x), asin(v.y));\n\ + uv *= vec2(0.1591, 0.3183); // inverse atan\n\ + uv += 0.5;\n\ + return uv;\n\ + }\n\ + \n\ + void main() {\n\ + vec2 uv = EquirectangularSampleUV(normalize(localPosition));\n\ + vec3 color = texture2D(equirectangularMap, uv).rgb;\n\ + \n\ + gl_FragColor = vec4( color, 1.0 );\n\ + }", + + blending: THREE.NoBlending + + } ); + + shaderMaterial.type = 'EquirectangularToCubeGenerator'; + + return shaderMaterial; + + }, + + dispose: function () { + + this.boxMesh.geometry.dispose(); + this.boxMesh.material.dispose(); + this.renderTarget.dispose(); + + } + +}; diff --git a/three/jsutil/loaders/FBXLoader.js b/three/jsutil/loaders/FBXLoader.js new file mode 100644 index 000000000..6a45c314b --- /dev/null +++ b/three/jsutil/loaders/FBXLoader.js @@ -0,0 +1,4121 @@ +/** + * @author Kyle-Larson https://github.com/Kyle-Larson + * @author Takahiro https://github.com/takahirox + * @author Lewy Blue https://github.com/looeee + * + * Loader loads FBX file and generates Group representing FBX scene. + * Requires FBX file to be >= 7.0 and in ASCII or >= 6400 in Binary format + * Versions lower than this may load but will probably have errors + * + * Needs Support: + * Morph normals / blend shape normals + * + * FBX format references: + * https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure + * http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html (C++ SDK reference) + * + * Binary format specification: + * https://code.blender.org/2013/08/fbx-binary-file-format-specification/ + */ + + +THREE.FBXLoader = ( function () { + + var fbxTree; + var connections; + var sceneGraph; + + function FBXLoader( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + } + + FBXLoader.prototype = { + + constructor: FBXLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var self = this; + + var path = ( self.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : self.path; + + var loader = new THREE.FileLoader( this.manager ); + loader.setResponseType( 'arraybuffer' ); + + loader.load( url, function ( buffer ) { + + try { + + onLoad( self.parse( buffer, path ) ); + + } catch ( error ) { + + setTimeout( function () { + + if ( onError ) onError( error ); + + self.manager.itemError( url ); + + }, 0 ); + + } + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + parse: function ( FBXBuffer, path ) { + + if ( isFbxFormatBinary( FBXBuffer ) ) { + + fbxTree = new BinaryParser().parse( FBXBuffer ); + + } else { + + var FBXText = convertArrayBufferToString( FBXBuffer ); + + if ( ! isFbxFormatASCII( FBXText ) ) { + + throw new Error( 'THREE.FBXLoader: Unknown format.' ); + + } + + if ( getFbxVersion( FBXText ) < 7000 ) { + + throw new Error( 'THREE.FBXLoader: FBX version not supported, FileVersion: ' + getFbxVersion( FBXText ) ); + + } + + fbxTree = new TextParser().parse( FBXText ); + + } + + // console.log( fbxTree ); + + var textureLoader = new THREE.TextureLoader( this.manager ).setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); + + return new FBXTreeParser( textureLoader ).parse( fbxTree ); + + } + + }; + + // Parse the FBXTree object returned by the BinaryParser or TextParser and return a THREE.Group + function FBXTreeParser( textureLoader ) { + + this.textureLoader = textureLoader; + + } + + FBXTreeParser.prototype = { + + constructor: FBXTreeParser, + + parse: function () { + + connections = this.parseConnections(); + + var images = this.parseImages(); + var textures = this.parseTextures( images ); + var materials = this.parseMaterials( textures ); + var deformers = this.parseDeformers(); + var geometryMap = new GeometryParser().parse( deformers ); + + this.parseScene( deformers, geometryMap, materials ); + + return sceneGraph; + + }, + + // Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry ) + // and details the connection type + parseConnections: function () { + + var connectionMap = new Map(); + + if ( 'Connections' in fbxTree ) { + + var rawConnections = fbxTree.Connections.connections; + + rawConnections.forEach( function ( rawConnection ) { + + var fromID = rawConnection[ 0 ]; + var toID = rawConnection[ 1 ]; + var relationship = rawConnection[ 2 ]; + + if ( ! connectionMap.has( fromID ) ) { + + connectionMap.set( fromID, { + parents: [], + children: [] + } ); + + } + + var parentRelationship = { ID: toID, relationship: relationship }; + connectionMap.get( fromID ).parents.push( parentRelationship ); + + if ( ! connectionMap.has( toID ) ) { + + connectionMap.set( toID, { + parents: [], + children: [] + } ); + + } + + var childRelationship = { ID: fromID, relationship: relationship }; + connectionMap.get( toID ).children.push( childRelationship ); + + } ); + + } + + return connectionMap; + + }, + + // Parse FBXTree.Objects.Video for embedded image data + // These images are connected to textures in FBXTree.Objects.Textures + // via FBXTree.Connections. + parseImages: function () { + + var images = {}; + var blobs = {}; + + if ( 'Video' in fbxTree.Objects ) { + + var videoNodes = fbxTree.Objects.Video; + + for ( var nodeID in videoNodes ) { + + var videoNode = videoNodes[ nodeID ]; + + var id = parseInt( nodeID ); + + images[ id ] = videoNode.RelativeFilename || videoNode.Filename; + + // raw image data is in videoNode.Content + if ( 'Content' in videoNode ) { + + var arrayBufferContent = ( videoNode.Content instanceof ArrayBuffer ) && ( videoNode.Content.byteLength > 0 ); + var base64Content = ( typeof videoNode.Content === 'string' ) && ( videoNode.Content !== '' ); + + if ( arrayBufferContent || base64Content ) { + + var image = this.parseImage( videoNodes[ nodeID ] ); + + blobs[ videoNode.RelativeFilename || videoNode.Filename ] = image; + + } + + } + + } + + } + + for ( var id in images ) { + + var filename = images[ id ]; + + if ( blobs[ filename ] !== undefined ) images[ id ] = blobs[ filename ]; + else images[ id ] = images[ id ].split( '\\' ).pop(); + + } + + return images; + + }, + + // Parse embedded image data in FBXTree.Video.Content + parseImage: function ( videoNode ) { + + var content = videoNode.Content; + var fileName = videoNode.RelativeFilename || videoNode.Filename; + var extension = fileName.slice( fileName.lastIndexOf( '.' ) + 1 ).toLowerCase(); + + var type; + + switch ( extension ) { + + case 'bmp': + + type = 'image/bmp'; + break; + + case 'jpg': + case 'jpeg': + + type = 'image/jpeg'; + break; + + case 'png': + + type = 'image/png'; + break; + + case 'tif': + + type = 'image/tiff'; + break; + + case 'tga': + + if ( typeof THREE.TGALoader !== 'function' ) { + + console.warn( 'FBXLoader: THREE.TGALoader is required to load TGA textures' ); + return; + + } else { + + if ( THREE.Loader.Handlers.get( '.tga' ) === null ) { + + var tgaLoader = new THREE.TGALoader(); + tgaLoader.setPath( this.textureLoader.path ); + + THREE.Loader.Handlers.add( /\.tga$/i, tgaLoader ); + + } + + type = 'image/tga'; + break; + + } + + default: + + console.warn( 'FBXLoader: Image type "' + extension + '" is not supported.' ); + return; + + } + + if ( typeof content === 'string' ) { // ASCII format + + return 'data:' + type + ';base64,' + content; + + } else { // Binary Format + + var array = new Uint8Array( content ); + return window.URL.createObjectURL( new Blob( [ array ], { type: type } ) ); + + } + + }, + + // Parse nodes in FBXTree.Objects.Texture + // These contain details such as UV scaling, cropping, rotation etc and are connected + // to images in FBXTree.Objects.Video + parseTextures: function ( images ) { + + var textureMap = new Map(); + + if ( 'Texture' in fbxTree.Objects ) { + + var textureNodes = fbxTree.Objects.Texture; + for ( var nodeID in textureNodes ) { + + var texture = this.parseTexture( textureNodes[ nodeID ], images ); + textureMap.set( parseInt( nodeID ), texture ); + + } + + } + + return textureMap; + + }, + + // Parse individual node in FBXTree.Objects.Texture + parseTexture: function ( textureNode, images ) { + + var texture = this.loadTexture( textureNode, images ); + + texture.ID = textureNode.id; + + texture.name = textureNode.attrName; + + var wrapModeU = textureNode.WrapModeU; + var wrapModeV = textureNode.WrapModeV; + + var valueU = wrapModeU !== undefined ? wrapModeU.value : 0; + var valueV = wrapModeV !== undefined ? wrapModeV.value : 0; + + // http://download.autodesk.com/us/fbx/SDKdocs/FBX_SDK_Help/files/fbxsdkref/class_k_fbx_texture.html#889640e63e2e681259ea81061b85143a + // 0: repeat(default), 1: clamp + + texture.wrapS = valueU === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + texture.wrapT = valueV === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + + if ( 'Scaling' in textureNode ) { + + var values = textureNode.Scaling.value; + + texture.repeat.x = values[ 0 ]; + texture.repeat.y = values[ 1 ]; + + } + + return texture; + + }, + + // load a texture specified as a blob or data URI, or via an external URL using THREE.TextureLoader + loadTexture: function ( textureNode, images ) { + + var fileName; + + var currentPath = this.textureLoader.path; + + var children = connections.get( textureNode.id ).children; + + if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) { + + fileName = images[ children[ 0 ].ID ]; + + if ( fileName.indexOf( 'blob:' ) === 0 || fileName.indexOf( 'data:' ) === 0 ) { + + this.textureLoader.setPath( undefined ); + + } + + } + + var texture; + + var extension = textureNode.FileName.slice( - 3 ).toLowerCase(); + + if ( extension === 'tga' ) { + + var loader = THREE.Loader.Handlers.get( '.tga' ); + + if ( loader === null ) { + + console.warn( 'FBXLoader: TGALoader not found, creating empty placeholder texture for', fileName ); + texture = new THREE.Texture(); + + } else { + + texture = loader.load( fileName ); + + } + + } else if ( extension === 'psd' ) { + + console.warn( 'FBXLoader: PSD textures are not supported, creating empty placeholder texture for', fileName ); + texture = new THREE.Texture(); + + } else { + + texture = this.textureLoader.load( fileName ); + + } + + this.textureLoader.setPath( currentPath ); + + return texture; + + }, + + // Parse nodes in FBXTree.Objects.Material + parseMaterials: function ( textureMap ) { + + var materialMap = new Map(); + + if ( 'Material' in fbxTree.Objects ) { + + var materialNodes = fbxTree.Objects.Material; + + for ( var nodeID in materialNodes ) { + + var material = this.parseMaterial( materialNodes[ nodeID ], textureMap ); + + if ( material !== null ) materialMap.set( parseInt( nodeID ), material ); + + } + + } + + return materialMap; + + }, + + // Parse single node in FBXTree.Objects.Material + // Materials are connected to texture maps in FBXTree.Objects.Textures + // FBX format currently only supports Lambert and Phong shading models + parseMaterial: function ( materialNode, textureMap ) { + + var ID = materialNode.id; + var name = materialNode.attrName; + var type = materialNode.ShadingModel; + + // Case where FBX wraps shading model in property object. + if ( typeof type === 'object' ) { + + type = type.value; + + } + + // Ignore unused materials which don't have any connections. + if ( ! connections.has( ID ) ) return null; + + var parameters = this.parseParameters( materialNode, textureMap, ID ); + + var material; + + switch ( type.toLowerCase() ) { + + case 'phong': + material = new THREE.MeshPhongMaterial(); + break; + case 'lambert': + material = new THREE.MeshLambertMaterial(); + break; + default: + console.warn( 'THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', type ); + material = new THREE.MeshPhongMaterial( { color: 0x3300ff } ); + break; + + } + + material.setValues( parameters ); + material.name = name; + + return material; + + }, + + // Parse FBX material and return parameters suitable for a three.js material + // Also parse the texture map and return any textures associated with the material + parseParameters: function ( materialNode, textureMap, ID ) { + + var parameters = {}; + + if ( materialNode.BumpFactor ) { + + parameters.bumpScale = materialNode.BumpFactor.value; + + } + if ( materialNode.Diffuse ) { + + parameters.color = new THREE.Color().fromArray( materialNode.Diffuse.value ); + + } else if ( materialNode.DiffuseColor && materialNode.DiffuseColor.type === 'Color' ) { + + // The blender exporter exports diffuse here instead of in materialNode.Diffuse + parameters.color = new THREE.Color().fromArray( materialNode.DiffuseColor.value ); + + } + if ( materialNode.DisplacementFactor ) { + + parameters.displacementScale = materialNode.DisplacementFactor.value; + + } + if ( materialNode.Emissive ) { + + parameters.emissive = new THREE.Color().fromArray( materialNode.Emissive.value ); + + } else if ( materialNode.EmissiveColor && materialNode.EmissiveColor.type === 'Color' ) { + + // The blender exporter exports emissive color here instead of in materialNode.Emissive + parameters.emissive = new THREE.Color().fromArray( materialNode.EmissiveColor.value ); + + } + if ( materialNode.EmissiveFactor ) { + + parameters.emissiveIntensity = parseFloat( materialNode.EmissiveFactor.value ); + + } + if ( materialNode.Opacity ) { + + parameters.opacity = parseFloat( materialNode.Opacity.value ); + + } + if ( parameters.opacity < 1.0 ) { + + parameters.transparent = true; + + } + if ( materialNode.ReflectionFactor ) { + + parameters.reflectivity = materialNode.ReflectionFactor.value; + + } + if ( materialNode.Shininess ) { + + parameters.shininess = materialNode.Shininess.value; + + } + if ( materialNode.Specular ) { + + parameters.specular = new THREE.Color().fromArray( materialNode.Specular.value ); + + } else if ( materialNode.SpecularColor && materialNode.SpecularColor.type === 'Color' ) { + + // The blender exporter exports specular color here instead of in materialNode.Specular + parameters.specular = new THREE.Color().fromArray( materialNode.SpecularColor.value ); + + } + + var self = this; + connections.get( ID ).children.forEach( function ( child ) { + + var type = child.relationship; + + switch ( type ) { + + case 'Bump': + parameters.bumpMap = self.getTexture( textureMap, child.ID ); + break; + + case 'DiffuseColor': + parameters.map = self.getTexture( textureMap, child.ID ); + break; + + case 'DisplacementColor': + parameters.displacementMap = self.getTexture( textureMap, child.ID ); + break; + + + case 'EmissiveColor': + parameters.emissiveMap = self.getTexture( textureMap, child.ID ); + break; + + case 'NormalMap': + parameters.normalMap = self.getTexture( textureMap, child.ID ); + break; + + case 'ReflectionColor': + parameters.envMap = self.getTexture( textureMap, child.ID ); + parameters.envMap.mapping = THREE.EquirectangularReflectionMapping; + break; + + case 'SpecularColor': + parameters.specularMap = self.getTexture( textureMap, child.ID ); + break; + + case 'TransparentColor': + parameters.alphaMap = self.getTexture( textureMap, child.ID ); + parameters.transparent = true; + break; + + case 'AmbientColor': + case 'ShininessExponent': // AKA glossiness map + case 'SpecularFactor': // AKA specularLevel + case 'VectorDisplacementColor': // NOTE: Seems to be a copy of DisplacementColor + default: + console.warn( 'THREE.FBXLoader: %s map is not supported in three.js, skipping texture.', type ); + break; + + } + + } ); + + return parameters; + + }, + + // get a texture from the textureMap for use by a material. + getTexture: function ( textureMap, id ) { + + // if the texture is a layered texture, just use the first layer and issue a warning + if ( 'LayeredTexture' in fbxTree.Objects && id in fbxTree.Objects.LayeredTexture ) { + + console.warn( 'THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.' ); + id = connections.get( id ).children[ 0 ].ID; + + } + + return textureMap.get( id ); + + }, + + // Parse nodes in FBXTree.Objects.Deformer + // Deformer node can contain skinning or Vertex Cache animation data, however only skinning is supported here + // Generates map of Skeleton-like objects for use later when generating and binding skeletons. + parseDeformers: function () { + + var skeletons = {}; + var morphTargets = {}; + + if ( 'Deformer' in fbxTree.Objects ) { + + var DeformerNodes = fbxTree.Objects.Deformer; + + for ( var nodeID in DeformerNodes ) { + + var deformerNode = DeformerNodes[ nodeID ]; + + var relationships = connections.get( parseInt( nodeID ) ); + + if ( deformerNode.attrType === 'Skin' ) { + + var skeleton = this.parseSkeleton( relationships, DeformerNodes ); + skeleton.ID = nodeID; + + if ( relationships.parents.length > 1 ) console.warn( 'THREE.FBXLoader: skeleton attached to more than one geometry is not supported.' ); + skeleton.geometryID = relationships.parents[ 0 ].ID; + + skeletons[ nodeID ] = skeleton; + + } else if ( deformerNode.attrType === 'BlendShape' ) { + + var morphTarget = { + id: nodeID, + }; + + morphTarget.rawTargets = this.parseMorphTargets( relationships, DeformerNodes ); + morphTarget.id = nodeID; + + if ( relationships.parents.length > 1 ) console.warn( 'THREE.FBXLoader: morph target attached to more than one geometry is not supported.' ); + + morphTargets[ nodeID ] = morphTarget; + + } + + } + + } + + return { + + skeletons: skeletons, + morphTargets: morphTargets, + + }; + + }, + + // Parse single nodes in FBXTree.Objects.Deformer + // The top level skeleton node has type 'Skin' and sub nodes have type 'Cluster' + // Each skin node represents a skeleton and each cluster node represents a bone + parseSkeleton: function ( relationships, deformerNodes ) { + + var rawBones = []; + + relationships.children.forEach( function ( child ) { + + var boneNode = deformerNodes[ child.ID ]; + + if ( boneNode.attrType !== 'Cluster' ) return; + + var rawBone = { + + ID: child.ID, + indices: [], + weights: [], + transformLink: new THREE.Matrix4().fromArray( boneNode.TransformLink.a ), + // transform: new THREE.Matrix4().fromArray( boneNode.Transform.a ), + // linkMode: boneNode.Mode, + + }; + + if ( 'Indexes' in boneNode ) { + + rawBone.indices = boneNode.Indexes.a; + rawBone.weights = boneNode.Weights.a; + + } + + rawBones.push( rawBone ); + + } ); + + return { + + rawBones: rawBones, + bones: [] + + }; + + }, + + // The top level morph deformer node has type "BlendShape" and sub nodes have type "BlendShapeChannel" + parseMorphTargets: function ( relationships, deformerNodes ) { + + var rawMorphTargets = []; + + for ( var i = 0; i < relationships.children.length; i ++ ) { + + var child = relationships.children[ i ]; + + var morphTargetNode = deformerNodes[ child.ID ]; + + var rawMorphTarget = { + + name: morphTargetNode.attrName, + initialWeight: morphTargetNode.DeformPercent, + id: morphTargetNode.id, + fullWeights: morphTargetNode.FullWeights.a + + }; + + if ( morphTargetNode.attrType !== 'BlendShapeChannel' ) return; + + var targetRelationships = connections.get( parseInt( child.ID ) ); + + targetRelationships.children.forEach( function ( child ) { + + if ( child.relationship === undefined ) rawMorphTarget.geoID = child.ID; + + } ); + + rawMorphTargets.push( rawMorphTarget ); + + } + + return rawMorphTargets; + + }, + + // create the main THREE.Group() to be returned by the loader + parseScene: function ( deformers, geometryMap, materialMap ) { + + sceneGraph = new THREE.Group(); + + var modelMap = this.parseModels( deformers.skeletons, geometryMap, materialMap ); + + var modelNodes = fbxTree.Objects.Model; + + var self = this; + modelMap.forEach( function ( model ) { + + var modelNode = modelNodes[ model.ID ]; + self.setLookAtProperties( model, modelNode ); + + var parentConnections = connections.get( model.ID ).parents; + + parentConnections.forEach( function ( connection ) { + + var parent = modelMap.get( connection.ID ); + if ( parent !== undefined ) parent.add( model ); + + } ); + + if ( model.parent === null ) { + + sceneGraph.add( model ); + + } + + + } ); + + this.bindSkeleton( deformers.skeletons, geometryMap, modelMap ); + + this.createAmbientLight(); + + this.setupMorphMaterials(); + + sceneGraph.traverse( function ( node ) { + + if ( node.userData.transformData ) { + + if ( node.parent ) node.userData.transformData.parentMatrixWorld = node.parent.matrix; + + var transform = generateTransform( node.userData.transformData ); + + node.applyMatrix( transform ); + + } + + } ); + + var animations = new AnimationParser().parse(); + + // if all the models where already combined in a single group, just return that + if ( sceneGraph.children.length === 1 && sceneGraph.children[ 0 ].isGroup ) { + + sceneGraph.children[ 0 ].animations = animations; + sceneGraph = sceneGraph.children[ 0 ]; + + } + + sceneGraph.animations = animations; + + }, + + // parse nodes in FBXTree.Objects.Model + parseModels: function ( skeletons, geometryMap, materialMap ) { + + var modelMap = new Map(); + var modelNodes = fbxTree.Objects.Model; + + for ( var nodeID in modelNodes ) { + + var id = parseInt( nodeID ); + var node = modelNodes[ nodeID ]; + var relationships = connections.get( id ); + + var model = this.buildSkeleton( relationships, skeletons, id, node.attrName ); + + if ( ! model ) { + + switch ( node.attrType ) { + + case 'Camera': + model = this.createCamera( relationships ); + break; + case 'Light': + model = this.createLight( relationships ); + break; + case 'Mesh': + model = this.createMesh( relationships, geometryMap, materialMap ); + break; + case 'NurbsCurve': + model = this.createCurve( relationships, geometryMap ); + break; + case 'LimbNode': + case 'Root': + model = new THREE.Bone(); + break; + case 'Null': + default: + model = new THREE.Group(); + break; + + } + + model.name = THREE.PropertyBinding.sanitizeNodeName( node.attrName ); + model.ID = id; + + } + + this.getTransformData( model, node ); + modelMap.set( id, model ); + + } + + return modelMap; + + }, + + buildSkeleton: function ( relationships, skeletons, id, name ) { + + var bone = null; + + relationships.parents.forEach( function ( parent ) { + + for ( var ID in skeletons ) { + + var skeleton = skeletons[ ID ]; + + skeleton.rawBones.forEach( function ( rawBone, i ) { + + if ( rawBone.ID === parent.ID ) { + + var subBone = bone; + bone = new THREE.Bone(); + + bone.matrixWorld.copy( rawBone.transformLink ); + + // set name and id here - otherwise in cases where "subBone" is created it will not have a name / id + bone.name = THREE.PropertyBinding.sanitizeNodeName( name ); + bone.ID = id; + + skeleton.bones[ i ] = bone; + + // In cases where a bone is shared between multiple meshes + // duplicate the bone here and and it as a child of the first bone + if ( subBone !== null ) { + + bone.add( subBone ); + + } + + } + + } ); + + } + + } ); + + return bone; + + }, + + // create a THREE.PerspectiveCamera or THREE.OrthographicCamera + createCamera: function ( relationships ) { + + var model; + var cameraAttribute; + + relationships.children.forEach( function ( child ) { + + var attr = fbxTree.Objects.NodeAttribute[ child.ID ]; + + if ( attr !== undefined ) { + + cameraAttribute = attr; + + } + + } ); + + if ( cameraAttribute === undefined ) { + + model = new THREE.Object3D(); + + } else { + + var type = 0; + if ( cameraAttribute.CameraProjectionType !== undefined && cameraAttribute.CameraProjectionType.value === 1 ) { + + type = 1; + + } + + var nearClippingPlane = 1; + if ( cameraAttribute.NearPlane !== undefined ) { + + nearClippingPlane = cameraAttribute.NearPlane.value / 1000; + + } + + var farClippingPlane = 1000; + if ( cameraAttribute.FarPlane !== undefined ) { + + farClippingPlane = cameraAttribute.FarPlane.value / 1000; + + } + + + var width = window.innerWidth; + var height = window.innerHeight; + + if ( cameraAttribute.AspectWidth !== undefined && cameraAttribute.AspectHeight !== undefined ) { + + width = cameraAttribute.AspectWidth.value; + height = cameraAttribute.AspectHeight.value; + + } + + var aspect = width / height; + + var fov = 45; + if ( cameraAttribute.FieldOfView !== undefined ) { + + fov = cameraAttribute.FieldOfView.value; + + } + + var focalLength = cameraAttribute.FocalLength ? cameraAttribute.FocalLength.value : null; + + switch ( type ) { + + case 0: // Perspective + model = new THREE.PerspectiveCamera( fov, aspect, nearClippingPlane, farClippingPlane ); + if ( focalLength !== null ) model.setFocalLength( focalLength ); + break; + + case 1: // Orthographic + model = new THREE.OrthographicCamera( - width / 2, width / 2, height / 2, - height / 2, nearClippingPlane, farClippingPlane ); + break; + + default: + console.warn( 'THREE.FBXLoader: Unknown camera type ' + type + '.' ); + model = new THREE.Object3D(); + break; + + } + + } + + return model; + + }, + + // Create a THREE.DirectionalLight, THREE.PointLight or THREE.SpotLight + createLight: function ( relationships ) { + + var model; + var lightAttribute; + + relationships.children.forEach( function ( child ) { + + var attr = fbxTree.Objects.NodeAttribute[ child.ID ]; + + if ( attr !== undefined ) { + + lightAttribute = attr; + + } + + } ); + + if ( lightAttribute === undefined ) { + + model = new THREE.Object3D(); + + } else { + + var type; + + // LightType can be undefined for Point lights + if ( lightAttribute.LightType === undefined ) { + + type = 0; + + } else { + + type = lightAttribute.LightType.value; + + } + + var color = 0xffffff; + + if ( lightAttribute.Color !== undefined ) { + + color = new THREE.Color().fromArray( lightAttribute.Color.value ); + + } + + var intensity = ( lightAttribute.Intensity === undefined ) ? 1 : lightAttribute.Intensity.value / 100; + + // light disabled + if ( lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0 ) { + + intensity = 0; + + } + + var distance = 0; + if ( lightAttribute.FarAttenuationEnd !== undefined ) { + + if ( lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0 ) { + + distance = 0; + + } else { + + distance = lightAttribute.FarAttenuationEnd.value; + + } + + } + + // TODO: could this be calculated linearly from FarAttenuationStart to FarAttenuationEnd? + var decay = 1; + + switch ( type ) { + + case 0: // Point + model = new THREE.PointLight( color, intensity, distance, decay ); + break; + + case 1: // Directional + model = new THREE.DirectionalLight( color, intensity ); + break; + + case 2: // Spot + var angle = Math.PI / 3; + + if ( lightAttribute.InnerAngle !== undefined ) { + + angle = THREE.Math.degToRad( lightAttribute.InnerAngle.value ); + + } + + var penumbra = 0; + if ( lightAttribute.OuterAngle !== undefined ) { + + // TODO: this is not correct - FBX calculates outer and inner angle in degrees + // with OuterAngle > InnerAngle && OuterAngle <= Math.PI + // while three.js uses a penumbra between (0, 1) to attenuate the inner angle + penumbra = THREE.Math.degToRad( lightAttribute.OuterAngle.value ); + penumbra = Math.max( penumbra, 1 ); + + } + + model = new THREE.SpotLight( color, intensity, distance, angle, penumbra, decay ); + break; + + default: + console.warn( 'THREE.FBXLoader: Unknown light type ' + lightAttribute.LightType.value + ', defaulting to a THREE.PointLight.' ); + model = new THREE.PointLight( color, intensity ); + break; + + } + + if ( lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1 ) { + + model.castShadow = true; + + } + + } + + return model; + + }, + + createMesh: function ( relationships, geometryMap, materialMap ) { + + var model; + var geometry = null; + var material = null; + var materials = []; + + // get geometry and materials(s) from connections + relationships.children.forEach( function ( child ) { + + if ( geometryMap.has( child.ID ) ) { + + geometry = geometryMap.get( child.ID ); + + } + + if ( materialMap.has( child.ID ) ) { + + materials.push( materialMap.get( child.ID ) ); + + } + + } ); + + if ( materials.length > 1 ) { + + material = materials; + + } else if ( materials.length > 0 ) { + + material = materials[ 0 ]; + + } else { + + material = new THREE.MeshPhongMaterial( { color: 0xcccccc } ); + materials.push( material ); + + } + + if ( 'color' in geometry.attributes ) { + + materials.forEach( function ( material ) { + + material.vertexColors = THREE.VertexColors; + + } ); + + } + + if ( geometry.FBX_Deformer ) { + + materials.forEach( function ( material ) { + + material.skinning = true; + + } ); + + model = new THREE.SkinnedMesh( geometry, material ); + + } else { + + model = new THREE.Mesh( geometry, material ); + + } + + return model; + + }, + + createCurve: function ( relationships, geometryMap ) { + + var geometry = relationships.children.reduce( function ( geo, child ) { + + if ( geometryMap.has( child.ID ) ) geo = geometryMap.get( child.ID ); + + return geo; + + }, null ); + + // FBX does not list materials for Nurbs lines, so we'll just put our own in here. + var material = new THREE.LineBasicMaterial( { color: 0x3300ff, linewidth: 1 } ); + return new THREE.Line( geometry, material ); + + }, + + // parse the model node for transform data + getTransformData: function ( model, modelNode ) { + + var transformData = {}; + + if ( 'InheritType' in modelNode ) transformData.inheritType = parseInt( modelNode.InheritType.value ); + + if ( 'RotationOrder' in modelNode ) transformData.eulerOrder = getEulerOrder( modelNode.RotationOrder.value ); + else transformData.eulerOrder = 'ZYX'; + + if ( 'Lcl_Translation' in modelNode ) transformData.translation = modelNode.Lcl_Translation.value; + + if ( 'PreRotation' in modelNode ) transformData.preRotation = modelNode.PreRotation.value; + if ( 'Lcl_Rotation' in modelNode ) transformData.rotation = modelNode.Lcl_Rotation.value; + if ( 'PostRotation' in modelNode ) transformData.postRotation = modelNode.PostRotation.value; + + if ( 'Lcl_Scaling' in modelNode ) transformData.scale = modelNode.Lcl_Scaling.value; + + if ( 'ScalingOffset' in modelNode ) transformData.scalingOffset = modelNode.ScalingOffset.value; + if ( 'ScalingPivot' in modelNode ) transformData.scalingPivot = modelNode.ScalingPivot.value; + + if ( 'RotationOffset' in modelNode ) transformData.rotationOffset = modelNode.RotationOffset.value; + if ( 'RotationPivot' in modelNode ) transformData.rotationPivot = modelNode.RotationPivot.value; + + model.userData.transformData = transformData; + + }, + + setLookAtProperties: function ( model, modelNode ) { + + if ( 'LookAtProperty' in modelNode ) { + + var children = connections.get( model.ID ).children; + + children.forEach( function ( child ) { + + if ( child.relationship === 'LookAtProperty' ) { + + var lookAtTarget = fbxTree.Objects.Model[ child.ID ]; + + if ( 'Lcl_Translation' in lookAtTarget ) { + + var pos = lookAtTarget.Lcl_Translation.value; + + // DirectionalLight, SpotLight + if ( model.target !== undefined ) { + + model.target.position.fromArray( pos ); + sceneGraph.add( model.target ); + + } else { // Cameras and other Object3Ds + + model.lookAt( new THREE.Vector3().fromArray( pos ) ); + + } + + } + + } + + } ); + + } + + }, + + bindSkeleton: function ( skeletons, geometryMap, modelMap ) { + + var bindMatrices = this.parsePoseNodes(); + + for ( var ID in skeletons ) { + + var skeleton = skeletons[ ID ]; + + var parents = connections.get( parseInt( skeleton.ID ) ).parents; + + parents.forEach( function ( parent ) { + + if ( geometryMap.has( parent.ID ) ) { + + var geoID = parent.ID; + var geoRelationships = connections.get( geoID ); + + geoRelationships.parents.forEach( function ( geoConnParent ) { + + if ( modelMap.has( geoConnParent.ID ) ) { + + var model = modelMap.get( geoConnParent.ID ); + + model.bind( new THREE.Skeleton( skeleton.bones ), bindMatrices[ geoConnParent.ID ] ); + + } + + } ); + + } + + } ); + + } + + }, + + parsePoseNodes: function () { + + var bindMatrices = {}; + + if ( 'Pose' in fbxTree.Objects ) { + + var BindPoseNode = fbxTree.Objects.Pose; + + for ( var nodeID in BindPoseNode ) { + + if ( BindPoseNode[ nodeID ].attrType === 'BindPose' ) { + + var poseNodes = BindPoseNode[ nodeID ].PoseNode; + + if ( Array.isArray( poseNodes ) ) { + + poseNodes.forEach( function ( poseNode ) { + + bindMatrices[ poseNode.Node ] = new THREE.Matrix4().fromArray( poseNode.Matrix.a ); + + } ); + + } else { + + bindMatrices[ poseNodes.Node ] = new THREE.Matrix4().fromArray( poseNodes.Matrix.a ); + + } + + } + + } + + } + + return bindMatrices; + + }, + + // Parse ambient color in FBXTree.GlobalSettings - if it's not set to black (default), create an ambient light + createAmbientLight: function () { + + if ( 'GlobalSettings' in fbxTree && 'AmbientColor' in fbxTree.GlobalSettings ) { + + var ambientColor = fbxTree.GlobalSettings.AmbientColor.value; + var r = ambientColor[ 0 ]; + var g = ambientColor[ 1 ]; + var b = ambientColor[ 2 ]; + + if ( r !== 0 || g !== 0 || b !== 0 ) { + + var color = new THREE.Color( r, g, b ); + sceneGraph.add( new THREE.AmbientLight( color, 1 ) ); + + } + + } + + }, + + setupMorphMaterials: function () { + + var self = this; + sceneGraph.traverse( function ( child ) { + + if ( child.isMesh ) { + + if ( child.geometry.morphAttributes.position && child.geometry.morphAttributes.position.length ) { + + if ( Array.isArray( child.material ) ) { + + child.material.forEach( function ( material, i ) { + + self.setupMorphMaterial( child, material, i ); + + } ); + + } else { + + self.setupMorphMaterial( child, child.material ); + + } + + } + + } + + } ); + + }, + + setupMorphMaterial: function ( child, material, index ) { + + var uuid = child.uuid; + var matUuid = material.uuid; + + // if a geometry has morph targets, it cannot share the material with other geometries + var sharedMat = false; + + sceneGraph.traverse( function ( node ) { + + if ( node.isMesh ) { + + if ( Array.isArray( node.material ) ) { + + node.material.forEach( function ( mat ) { + + if ( mat.uuid === matUuid && node.uuid !== uuid ) sharedMat = true; + + } ); + + } else if ( node.material.uuid === matUuid && node.uuid !== uuid ) sharedMat = true; + + } + + } ); + + if ( sharedMat === true ) { + + var clonedMat = material.clone(); + clonedMat.morphTargets = true; + + if ( index === undefined ) child.material = clonedMat; + else child.material[ index ] = clonedMat; + + } else material.morphTargets = true; + + } + + }; + + // parse Geometry data from FBXTree and return map of BufferGeometries + function GeometryParser() {} + + GeometryParser.prototype = { + + constructor: GeometryParser, + + // Parse nodes in FBXTree.Objects.Geometry + parse: function ( deformers ) { + + var geometryMap = new Map(); + + if ( 'Geometry' in fbxTree.Objects ) { + + var geoNodes = fbxTree.Objects.Geometry; + + for ( var nodeID in geoNodes ) { + + var relationships = connections.get( parseInt( nodeID ) ); + var geo = this.parseGeometry( relationships, geoNodes[ nodeID ], deformers ); + + geometryMap.set( parseInt( nodeID ), geo ); + + } + + } + + return geometryMap; + + }, + + // Parse single node in FBXTree.Objects.Geometry + parseGeometry: function ( relationships, geoNode, deformers ) { + + switch ( geoNode.attrType ) { + + case 'Mesh': + return this.parseMeshGeometry( relationships, geoNode, deformers ); + break; + + case 'NurbsCurve': + return this.parseNurbsGeometry( geoNode ); + break; + + } + + }, + + // Parse single node mesh geometry in FBXTree.Objects.Geometry + parseMeshGeometry: function ( relationships, geoNode, deformers ) { + + var skeletons = deformers.skeletons; + var morphTargets = deformers.morphTargets; + + var modelNodes = relationships.parents.map( function ( parent ) { + + return fbxTree.Objects.Model[ parent.ID ]; + + } ); + + // don't create geometry if it is not associated with any models + if ( modelNodes.length === 0 ) return; + + var skeleton = relationships.children.reduce( function ( skeleton, child ) { + + if ( skeletons[ child.ID ] !== undefined ) skeleton = skeletons[ child.ID ]; + + return skeleton; + + }, null ); + + var morphTarget = relationships.children.reduce( function ( morphTarget, child ) { + + if ( morphTargets[ child.ID ] !== undefined ) morphTarget = morphTargets[ child.ID ]; + + return morphTarget; + + }, null ); + + // Assume one model and get the preRotation from that + // if there is more than one model associated with the geometry this may cause problems + var modelNode = modelNodes[ 0 ]; + + var transformData = {}; + + if ( 'RotationOrder' in modelNode ) transformData.eulerOrder = getEulerOrder( modelNode.RotationOrder.value ); + if ( 'InheritType' in modelNode ) transformData.inheritType = parseInt( modelNode.InheritType.value ); + + if ( 'GeometricTranslation' in modelNode ) transformData.translation = modelNode.GeometricTranslation.value; + if ( 'GeometricRotation' in modelNode ) transformData.rotation = modelNode.GeometricRotation.value; + if ( 'GeometricScaling' in modelNode ) transformData.scale = modelNode.GeometricScaling.value; + + var transform = generateTransform( transformData ); + + return this.genGeometry( geoNode, skeleton, morphTarget, transform ); + + }, + + // Generate a THREE.BufferGeometry from a node in FBXTree.Objects.Geometry + genGeometry: function ( geoNode, skeleton, morphTarget, preTransform ) { + + var geo = new THREE.BufferGeometry(); + if ( geoNode.attrName ) geo.name = geoNode.attrName; + + var geoInfo = this.parseGeoNode( geoNode, skeleton ); + var buffers = this.genBuffers( geoInfo ); + + var positionAttribute = new THREE.Float32BufferAttribute( buffers.vertex, 3 ); + + preTransform.applyToBufferAttribute( positionAttribute ); + + geo.addAttribute( 'position', positionAttribute ); + + if ( buffers.colors.length > 0 ) { + + geo.addAttribute( 'color', new THREE.Float32BufferAttribute( buffers.colors, 3 ) ); + + } + + if ( skeleton ) { + + geo.addAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( buffers.weightsIndices, 4 ) ); + + geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( buffers.vertexWeights, 4 ) ); + + // used later to bind the skeleton to the model + geo.FBX_Deformer = skeleton; + + } + + if ( buffers.normal.length > 0 ) { + + var normalAttribute = new THREE.Float32BufferAttribute( buffers.normal, 3 ); + + var normalMatrix = new THREE.Matrix3().getNormalMatrix( preTransform ); + normalMatrix.applyToBufferAttribute( normalAttribute ); + + geo.addAttribute( 'normal', normalAttribute ); + + } + + buffers.uvs.forEach( function ( uvBuffer, i ) { + + // subsequent uv buffers are called 'uv1', 'uv2', ... + var name = 'uv' + ( i + 1 ).toString(); + + // the first uv buffer is just called 'uv' + if ( i === 0 ) { + + name = 'uv'; + + } + + geo.addAttribute( name, new THREE.Float32BufferAttribute( buffers.uvs[ i ], 2 ) ); + + } ); + + if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) { + + // Convert the material indices of each vertex into rendering groups on the geometry. + var prevMaterialIndex = buffers.materialIndex[ 0 ]; + var startIndex = 0; + + buffers.materialIndex.forEach( function ( currentIndex, i ) { + + if ( currentIndex !== prevMaterialIndex ) { + + geo.addGroup( startIndex, i - startIndex, prevMaterialIndex ); + + prevMaterialIndex = currentIndex; + startIndex = i; + + } + + } ); + + // the loop above doesn't add the last group, do that here. + if ( geo.groups.length > 0 ) { + + var lastGroup = geo.groups[ geo.groups.length - 1 ]; + var lastIndex = lastGroup.start + lastGroup.count; + + if ( lastIndex !== buffers.materialIndex.length ) { + + geo.addGroup( lastIndex, buffers.materialIndex.length - lastIndex, prevMaterialIndex ); + + } + + } + + // case where there are multiple materials but the whole geometry is only + // using one of them + if ( geo.groups.length === 0 ) { + + geo.addGroup( 0, buffers.materialIndex.length, buffers.materialIndex[ 0 ] ); + + } + + } + + this.addMorphTargets( geo, geoNode, morphTarget, preTransform ); + + return geo; + + }, + + parseGeoNode: function ( geoNode, skeleton ) { + + var geoInfo = {}; + + geoInfo.vertexPositions = ( geoNode.Vertices !== undefined ) ? geoNode.Vertices.a : []; + geoInfo.vertexIndices = ( geoNode.PolygonVertexIndex !== undefined ) ? geoNode.PolygonVertexIndex.a : []; + + if ( geoNode.LayerElementColor ) { + + geoInfo.color = this.parseVertexColors( geoNode.LayerElementColor[ 0 ] ); + + } + + if ( geoNode.LayerElementMaterial ) { + + geoInfo.material = this.parseMaterialIndices( geoNode.LayerElementMaterial[ 0 ] ); + + } + + if ( geoNode.LayerElementNormal ) { + + geoInfo.normal = this.parseNormals( geoNode.LayerElementNormal[ 0 ] ); + + } + + if ( geoNode.LayerElementUV ) { + + geoInfo.uv = []; + + var i = 0; + while ( geoNode.LayerElementUV[ i ] ) { + + geoInfo.uv.push( this.parseUVs( geoNode.LayerElementUV[ i ] ) ); + i ++; + + } + + } + + geoInfo.weightTable = {}; + + if ( skeleton !== null ) { + + geoInfo.skeleton = skeleton; + + skeleton.rawBones.forEach( function ( rawBone, i ) { + + // loop over the bone's vertex indices and weights + rawBone.indices.forEach( function ( index, j ) { + + if ( geoInfo.weightTable[ index ] === undefined ) geoInfo.weightTable[ index ] = []; + + geoInfo.weightTable[ index ].push( { + + id: i, + weight: rawBone.weights[ j ], + + } ); + + } ); + + } ); + + } + + return geoInfo; + + }, + + genBuffers: function ( geoInfo ) { + + var buffers = { + vertex: [], + normal: [], + colors: [], + uvs: [], + materialIndex: [], + vertexWeights: [], + weightsIndices: [], + }; + + var polygonIndex = 0; + var faceLength = 0; + var displayedWeightsWarning = false; + + // these will hold data for a single face + var facePositionIndexes = []; + var faceNormals = []; + var faceColors = []; + var faceUVs = []; + var faceWeights = []; + var faceWeightIndices = []; + + var self = this; + geoInfo.vertexIndices.forEach( function ( vertexIndex, polygonVertexIndex ) { + + var endOfFace = false; + + // Face index and vertex index arrays are combined in a single array + // A cube with quad faces looks like this: + // PolygonVertexIndex: *24 { + // a: 0, 1, 3, -3, 2, 3, 5, -5, 4, 5, 7, -7, 6, 7, 1, -1, 1, 7, 5, -4, 6, 0, 2, -5 + // } + // Negative numbers mark the end of a face - first face here is 0, 1, 3, -3 + // to find index of last vertex bit shift the index: ^ - 1 + if ( vertexIndex < 0 ) { + + vertexIndex = vertexIndex ^ - 1; // equivalent to ( x * -1 ) - 1 + endOfFace = true; + + } + + var weightIndices = []; + var weights = []; + + facePositionIndexes.push( vertexIndex * 3, vertexIndex * 3 + 1, vertexIndex * 3 + 2 ); + + if ( geoInfo.color ) { + + var data = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.color ); + + faceColors.push( data[ 0 ], data[ 1 ], data[ 2 ] ); + + } + + if ( geoInfo.skeleton ) { + + if ( geoInfo.weightTable[ vertexIndex ] !== undefined ) { + + geoInfo.weightTable[ vertexIndex ].forEach( function ( wt ) { + + weights.push( wt.weight ); + weightIndices.push( wt.id ); + + } ); + + + } + + if ( weights.length > 4 ) { + + if ( ! displayedWeightsWarning ) { + + console.warn( 'THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.' ); + displayedWeightsWarning = true; + + } + + var wIndex = [ 0, 0, 0, 0 ]; + var Weight = [ 0, 0, 0, 0 ]; + + weights.forEach( function ( weight, weightIndex ) { + + var currentWeight = weight; + var currentIndex = weightIndices[ weightIndex ]; + + Weight.forEach( function ( comparedWeight, comparedWeightIndex, comparedWeightArray ) { + + if ( currentWeight > comparedWeight ) { + + comparedWeightArray[ comparedWeightIndex ] = currentWeight; + currentWeight = comparedWeight; + + var tmp = wIndex[ comparedWeightIndex ]; + wIndex[ comparedWeightIndex ] = currentIndex; + currentIndex = tmp; + + } + + } ); + + } ); + + weightIndices = wIndex; + weights = Weight; + + } + + // if the weight array is shorter than 4 pad with 0s + while ( weights.length < 4 ) { + + weights.push( 0 ); + weightIndices.push( 0 ); + + } + + for ( var i = 0; i < 4; ++ i ) { + + faceWeights.push( weights[ i ] ); + faceWeightIndices.push( weightIndices[ i ] ); + + } + + } + + if ( geoInfo.normal ) { + + var data = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.normal ); + + faceNormals.push( data[ 0 ], data[ 1 ], data[ 2 ] ); + + } + + if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) { + + var materialIndex = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.material )[ 0 ]; + + } + + if ( geoInfo.uv ) { + + geoInfo.uv.forEach( function ( uv, i ) { + + var data = getData( polygonVertexIndex, polygonIndex, vertexIndex, uv ); + + if ( faceUVs[ i ] === undefined ) { + + faceUVs[ i ] = []; + + } + + faceUVs[ i ].push( data[ 0 ] ); + faceUVs[ i ].push( data[ 1 ] ); + + } ); + + } + + faceLength ++; + + if ( endOfFace ) { + + self.genFace( buffers, geoInfo, facePositionIndexes, materialIndex, faceNormals, faceColors, faceUVs, faceWeights, faceWeightIndices, faceLength ); + + polygonIndex ++; + faceLength = 0; + + // reset arrays for the next face + facePositionIndexes = []; + faceNormals = []; + faceColors = []; + faceUVs = []; + faceWeights = []; + faceWeightIndices = []; + + } + + } ); + + return buffers; + + }, + + // Generate data for a single face in a geometry. If the face is a quad then split it into 2 tris + genFace: function ( buffers, geoInfo, facePositionIndexes, materialIndex, faceNormals, faceColors, faceUVs, faceWeights, faceWeightIndices, faceLength ) { + + for ( var i = 2; i < faceLength; i ++ ) { + + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ 0 ] ] ); + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ 1 ] ] ); + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ 2 ] ] ); + + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ ( i - 1 ) * 3 ] ] ); + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ ( i - 1 ) * 3 + 1 ] ] ); + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ ( i - 1 ) * 3 + 2 ] ] ); + + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i * 3 ] ] ); + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i * 3 + 1 ] ] ); + buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i * 3 + 2 ] ] ); + + if ( geoInfo.skeleton ) { + + buffers.vertexWeights.push( faceWeights[ 0 ] ); + buffers.vertexWeights.push( faceWeights[ 1 ] ); + buffers.vertexWeights.push( faceWeights[ 2 ] ); + buffers.vertexWeights.push( faceWeights[ 3 ] ); + + buffers.vertexWeights.push( faceWeights[ ( i - 1 ) * 4 ] ); + buffers.vertexWeights.push( faceWeights[ ( i - 1 ) * 4 + 1 ] ); + buffers.vertexWeights.push( faceWeights[ ( i - 1 ) * 4 + 2 ] ); + buffers.vertexWeights.push( faceWeights[ ( i - 1 ) * 4 + 3 ] ); + + buffers.vertexWeights.push( faceWeights[ i * 4 ] ); + buffers.vertexWeights.push( faceWeights[ i * 4 + 1 ] ); + buffers.vertexWeights.push( faceWeights[ i * 4 + 2 ] ); + buffers.vertexWeights.push( faceWeights[ i * 4 + 3 ] ); + + buffers.weightsIndices.push( faceWeightIndices[ 0 ] ); + buffers.weightsIndices.push( faceWeightIndices[ 1 ] ); + buffers.weightsIndices.push( faceWeightIndices[ 2 ] ); + buffers.weightsIndices.push( faceWeightIndices[ 3 ] ); + + buffers.weightsIndices.push( faceWeightIndices[ ( i - 1 ) * 4 ] ); + buffers.weightsIndices.push( faceWeightIndices[ ( i - 1 ) * 4 + 1 ] ); + buffers.weightsIndices.push( faceWeightIndices[ ( i - 1 ) * 4 + 2 ] ); + buffers.weightsIndices.push( faceWeightIndices[ ( i - 1 ) * 4 + 3 ] ); + + buffers.weightsIndices.push( faceWeightIndices[ i * 4 ] ); + buffers.weightsIndices.push( faceWeightIndices[ i * 4 + 1 ] ); + buffers.weightsIndices.push( faceWeightIndices[ i * 4 + 2 ] ); + buffers.weightsIndices.push( faceWeightIndices[ i * 4 + 3 ] ); + + } + + if ( geoInfo.color ) { + + buffers.colors.push( faceColors[ 0 ] ); + buffers.colors.push( faceColors[ 1 ] ); + buffers.colors.push( faceColors[ 2 ] ); + + buffers.colors.push( faceColors[ ( i - 1 ) * 3 ] ); + buffers.colors.push( faceColors[ ( i - 1 ) * 3 + 1 ] ); + buffers.colors.push( faceColors[ ( i - 1 ) * 3 + 2 ] ); + + buffers.colors.push( faceColors[ i * 3 ] ); + buffers.colors.push( faceColors[ i * 3 + 1 ] ); + buffers.colors.push( faceColors[ i * 3 + 2 ] ); + + } + + if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) { + + buffers.materialIndex.push( materialIndex ); + buffers.materialIndex.push( materialIndex ); + buffers.materialIndex.push( materialIndex ); + + } + + if ( geoInfo.normal ) { + + buffers.normal.push( faceNormals[ 0 ] ); + buffers.normal.push( faceNormals[ 1 ] ); + buffers.normal.push( faceNormals[ 2 ] ); + + buffers.normal.push( faceNormals[ ( i - 1 ) * 3 ] ); + buffers.normal.push( faceNormals[ ( i - 1 ) * 3 + 1 ] ); + buffers.normal.push( faceNormals[ ( i - 1 ) * 3 + 2 ] ); + + buffers.normal.push( faceNormals[ i * 3 ] ); + buffers.normal.push( faceNormals[ i * 3 + 1 ] ); + buffers.normal.push( faceNormals[ i * 3 + 2 ] ); + + } + + if ( geoInfo.uv ) { + + geoInfo.uv.forEach( function ( uv, j ) { + + if ( buffers.uvs[ j ] === undefined ) buffers.uvs[ j ] = []; + + buffers.uvs[ j ].push( faceUVs[ j ][ 0 ] ); + buffers.uvs[ j ].push( faceUVs[ j ][ 1 ] ); + + buffers.uvs[ j ].push( faceUVs[ j ][ ( i - 1 ) * 2 ] ); + buffers.uvs[ j ].push( faceUVs[ j ][ ( i - 1 ) * 2 + 1 ] ); + + buffers.uvs[ j ].push( faceUVs[ j ][ i * 2 ] ); + buffers.uvs[ j ].push( faceUVs[ j ][ i * 2 + 1 ] ); + + } ); + + } + + } + + }, + + addMorphTargets: function ( parentGeo, parentGeoNode, morphTarget, preTransform ) { + + if ( morphTarget === null ) return; + + parentGeo.morphAttributes.position = []; + // parentGeo.morphAttributes.normal = []; // not implemented + + var self = this; + morphTarget.rawTargets.forEach( function ( rawTarget ) { + + var morphGeoNode = fbxTree.Objects.Geometry[ rawTarget.geoID ]; + + if ( morphGeoNode !== undefined ) { + + self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name ); + + } + + } ); + + }, + + // a morph geometry node is similar to a standard node, and the node is also contained + // in FBXTree.Objects.Geometry, however it can only have attributes for position, normal + // and a special attribute Index defining which vertices of the original geometry are affected + // Normal and position attributes only have data for the vertices that are affected by the morph + genMorphGeometry: function ( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) { + + var morphGeo = new THREE.BufferGeometry(); + if ( morphGeoNode.attrName ) morphGeo.name = morphGeoNode.attrName; + + var vertexIndices = ( parentGeoNode.PolygonVertexIndex !== undefined ) ? parentGeoNode.PolygonVertexIndex.a : []; + + // make a copy of the parent's vertex positions + var vertexPositions = ( parentGeoNode.Vertices !== undefined ) ? parentGeoNode.Vertices.a.slice() : []; + + var morphPositions = ( morphGeoNode.Vertices !== undefined ) ? morphGeoNode.Vertices.a : []; + var indices = ( morphGeoNode.Indexes !== undefined ) ? morphGeoNode.Indexes.a : []; + + for ( var i = 0; i < indices.length; i ++ ) { + + var morphIndex = indices[ i ] * 3; + + // FBX format uses blend shapes rather than morph targets. This can be converted + // by additively combining the blend shape positions with the original geometry's positions + vertexPositions[ morphIndex ] += morphPositions[ i * 3 ]; + vertexPositions[ morphIndex + 1 ] += morphPositions[ i * 3 + 1 ]; + vertexPositions[ morphIndex + 2 ] += morphPositions[ i * 3 + 2 ]; + + } + + // TODO: add morph normal support + var morphGeoInfo = { + vertexIndices: vertexIndices, + vertexPositions: vertexPositions, + }; + + var morphBuffers = this.genBuffers( morphGeoInfo ); + + var positionAttribute = new THREE.Float32BufferAttribute( morphBuffers.vertex, 3 ); + positionAttribute.name = name || morphGeoNode.attrName; + + preTransform.applyToBufferAttribute( positionAttribute ); + + parentGeo.morphAttributes.position.push( positionAttribute ); + + }, + + // Parse normal from FBXTree.Objects.Geometry.LayerElementNormal if it exists + parseNormals: function ( NormalNode ) { + + var mappingType = NormalNode.MappingInformationType; + var referenceType = NormalNode.ReferenceInformationType; + var buffer = NormalNode.Normals.a; + var indexBuffer = []; + if ( referenceType === 'IndexToDirect' ) { + + if ( 'NormalIndex' in NormalNode ) { + + indexBuffer = NormalNode.NormalIndex.a; + + } else if ( 'NormalsIndex' in NormalNode ) { + + indexBuffer = NormalNode.NormalsIndex.a; + + } + + } + + return { + dataSize: 3, + buffer: buffer, + indices: indexBuffer, + mappingType: mappingType, + referenceType: referenceType + }; + + }, + + // Parse UVs from FBXTree.Objects.Geometry.LayerElementUV if it exists + parseUVs: function ( UVNode ) { + + var mappingType = UVNode.MappingInformationType; + var referenceType = UVNode.ReferenceInformationType; + var buffer = UVNode.UV.a; + var indexBuffer = []; + if ( referenceType === 'IndexToDirect' ) { + + indexBuffer = UVNode.UVIndex.a; + + } + + return { + dataSize: 2, + buffer: buffer, + indices: indexBuffer, + mappingType: mappingType, + referenceType: referenceType + }; + + }, + + // Parse Vertex Colors from FBXTree.Objects.Geometry.LayerElementColor if it exists + parseVertexColors: function ( ColorNode ) { + + var mappingType = ColorNode.MappingInformationType; + var referenceType = ColorNode.ReferenceInformationType; + var buffer = ColorNode.Colors.a; + var indexBuffer = []; + if ( referenceType === 'IndexToDirect' ) { + + indexBuffer = ColorNode.ColorIndex.a; + + } + + return { + dataSize: 4, + buffer: buffer, + indices: indexBuffer, + mappingType: mappingType, + referenceType: referenceType + }; + + }, + + // Parse mapping and material data in FBXTree.Objects.Geometry.LayerElementMaterial if it exists + parseMaterialIndices: function ( MaterialNode ) { + + var mappingType = MaterialNode.MappingInformationType; + var referenceType = MaterialNode.ReferenceInformationType; + + if ( mappingType === 'NoMappingInformation' ) { + + return { + dataSize: 1, + buffer: [ 0 ], + indices: [ 0 ], + mappingType: 'AllSame', + referenceType: referenceType + }; + + } + + var materialIndexBuffer = MaterialNode.Materials.a; + + // Since materials are stored as indices, there's a bit of a mismatch between FBX and what + // we expect.So we create an intermediate buffer that points to the index in the buffer, + // for conforming with the other functions we've written for other data. + var materialIndices = []; + + for ( var i = 0; i < materialIndexBuffer.length; ++ i ) { + + materialIndices.push( i ); + + } + + return { + dataSize: 1, + buffer: materialIndexBuffer, + indices: materialIndices, + mappingType: mappingType, + referenceType: referenceType + }; + + }, + + // Generate a NurbGeometry from a node in FBXTree.Objects.Geometry + parseNurbsGeometry: function ( geoNode ) { + + if ( THREE.NURBSCurve === undefined ) { + + console.error( 'THREE.FBXLoader: The loader relies on THREE.NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry.' ); + return new THREE.BufferGeometry(); + + } + + var order = parseInt( geoNode.Order ); + + if ( isNaN( order ) ) { + + console.error( 'THREE.FBXLoader: Invalid Order %s given for geometry ID: %s', geoNode.Order, geoNode.id ); + return new THREE.BufferGeometry(); + + } + + var degree = order - 1; + + var knots = geoNode.KnotVector.a; + var controlPoints = []; + var pointsValues = geoNode.Points.a; + + for ( var i = 0, l = pointsValues.length; i < l; i += 4 ) { + + controlPoints.push( new THREE.Vector4().fromArray( pointsValues, i ) ); + + } + + var startKnot, endKnot; + + if ( geoNode.Form === 'Closed' ) { + + controlPoints.push( controlPoints[ 0 ] ); + + } else if ( geoNode.Form === 'Periodic' ) { + + startKnot = degree; + endKnot = knots.length - 1 - startKnot; + + for ( var i = 0; i < degree; ++ i ) { + + controlPoints.push( controlPoints[ i ] ); + + } + + } + + var curve = new THREE.NURBSCurve( degree, knots, controlPoints, startKnot, endKnot ); + var vertices = curve.getPoints( controlPoints.length * 7 ); + + var positions = new Float32Array( vertices.length * 3 ); + + vertices.forEach( function ( vertex, i ) { + + vertex.toArray( positions, i * 3 ); + + } ); + + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); + + return geometry; + + }, + + }; + + // parse animation data from FBXTree + function AnimationParser() {} + + AnimationParser.prototype = { + + constructor: AnimationParser, + + // take raw animation clips and turn them into three.js animation clips + parse: function () { + + var animationClips = []; + + var rawClips = this.parseClips(); + + if ( rawClips === undefined ) return; + + for ( var key in rawClips ) { + + var rawClip = rawClips[ key ]; + + var clip = this.addClip( rawClip ); + + animationClips.push( clip ); + + } + + return animationClips; + + }, + + parseClips: function () { + + // since the actual transformation data is stored in FBXTree.Objects.AnimationCurve, + // if this is undefined we can safely assume there are no animations + if ( fbxTree.Objects.AnimationCurve === undefined ) return undefined; + + var curveNodesMap = this.parseAnimationCurveNodes(); + + this.parseAnimationCurves( curveNodesMap ); + + var layersMap = this.parseAnimationLayers( curveNodesMap ); + var rawClips = this.parseAnimStacks( layersMap ); + + return rawClips; + + }, + + // parse nodes in FBXTree.Objects.AnimationCurveNode + // each AnimationCurveNode holds data for an animation transform for a model (e.g. left arm rotation ) + // and is referenced by an AnimationLayer + parseAnimationCurveNodes: function () { + + var rawCurveNodes = fbxTree.Objects.AnimationCurveNode; + + var curveNodesMap = new Map(); + + for ( var nodeID in rawCurveNodes ) { + + var rawCurveNode = rawCurveNodes[ nodeID ]; + + if ( rawCurveNode.attrName.match( /S|R|T|DeformPercent/ ) !== null ) { + + var curveNode = { + + id: rawCurveNode.id, + attr: rawCurveNode.attrName, + curves: {}, + + }; + + curveNodesMap.set( curveNode.id, curveNode ); + + } + + } + + return curveNodesMap; + + }, + + // parse nodes in FBXTree.Objects.AnimationCurve and connect them up to + // previously parsed AnimationCurveNodes. Each AnimationCurve holds data for a single animated + // axis ( e.g. times and values of x rotation) + parseAnimationCurves: function ( curveNodesMap ) { + + var rawCurves = fbxTree.Objects.AnimationCurve; + + // TODO: Many values are identical up to roundoff error, but won't be optimised + // e.g. position times: [0, 0.4, 0. 8] + // position values: [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.235384487103147e-7, 93.67520904541016, -0.9982695579528809] + // clearly, this should be optimised to + // times: [0], positions [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809] + // this shows up in nearly every FBX file, and generally time array is length > 100 + + for ( var nodeID in rawCurves ) { + + var animationCurve = { + + id: rawCurves[ nodeID ].id, + times: rawCurves[ nodeID ].KeyTime.a.map( convertFBXTimeToSeconds ), + values: rawCurves[ nodeID ].KeyValueFloat.a, + + }; + + var relationships = connections.get( animationCurve.id ); + + if ( relationships !== undefined ) { + + var animationCurveID = relationships.parents[ 0 ].ID; + var animationCurveRelationship = relationships.parents[ 0 ].relationship; + + if ( animationCurveRelationship.match( /X/ ) ) { + + curveNodesMap.get( animationCurveID ).curves[ 'x' ] = animationCurve; + + } else if ( animationCurveRelationship.match( /Y/ ) ) { + + curveNodesMap.get( animationCurveID ).curves[ 'y' ] = animationCurve; + + } else if ( animationCurveRelationship.match( /Z/ ) ) { + + curveNodesMap.get( animationCurveID ).curves[ 'z' ] = animationCurve; + + } else if ( animationCurveRelationship.match( /d|DeformPercent/ ) && curveNodesMap.has( animationCurveID ) ) { + + curveNodesMap.get( animationCurveID ).curves[ 'morph' ] = animationCurve; + + } + + } + + } + + }, + + // parse nodes in FBXTree.Objects.AnimationLayer. Each layers holds references + // to various AnimationCurveNodes and is referenced by an AnimationStack node + // note: theoretically a stack can have multiple layers, however in practice there always seems to be one per stack + parseAnimationLayers: function ( curveNodesMap ) { + + var rawLayers = fbxTree.Objects.AnimationLayer; + + var layersMap = new Map(); + + for ( var nodeID in rawLayers ) { + + var layerCurveNodes = []; + + var connection = connections.get( parseInt( nodeID ) ); + + if ( connection !== undefined ) { + + // all the animationCurveNodes used in the layer + var children = connection.children; + + children.forEach( function ( child, i ) { + + if ( curveNodesMap.has( child.ID ) ) { + + var curveNode = curveNodesMap.get( child.ID ); + + // check that the curves are defined for at least one axis, otherwise ignore the curveNode + if ( curveNode.curves.x !== undefined || curveNode.curves.y !== undefined || curveNode.curves.z !== undefined ) { + + if ( layerCurveNodes[ i ] === undefined ) { + + var modelID; + + connections.get( child.ID ).parents.forEach( function ( parent ) { + + if ( parent.relationship !== undefined ) modelID = parent.ID; + + } ); + + var rawModel = fbxTree.Objects.Model[ modelID.toString() ]; + + var node = { + + modelName: THREE.PropertyBinding.sanitizeNodeName( rawModel.attrName ), + ID: rawModel.id, + initialPosition: [ 0, 0, 0 ], + initialRotation: [ 0, 0, 0 ], + initialScale: [ 1, 1, 1 ], + + }; + + sceneGraph.traverse( function ( child ) { + + if ( child.ID = rawModel.id ) { + + node.transform = child.matrix; + + if ( child.userData.transformData ) node.eulerOrder = child.userData.transformData.eulerOrder; + + } + + } ); + + if ( ! node.transform ) node.transform = new THREE.Matrix4(); + + // if the animated model is pre rotated, we'll have to apply the pre rotations to every + // animation value as well + if ( 'PreRotation' in rawModel ) node.preRotation = rawModel.PreRotation.value; + if ( 'PostRotation' in rawModel ) node.postRotation = rawModel.PostRotation.value; + + layerCurveNodes[ i ] = node; + + } + + layerCurveNodes[ i ][ curveNode.attr ] = curveNode; + + } else if ( curveNode.curves.morph !== undefined ) { + + if ( layerCurveNodes[ i ] === undefined ) { + + var deformerID; + + connections.get( child.ID ).parents.forEach( function ( parent ) { + + if ( parent.relationship !== undefined ) deformerID = parent.ID; + + } ); + + var morpherID = connections.get( deformerID ).parents[ 0 ].ID; + var geoID = connections.get( morpherID ).parents[ 0 ].ID; + + // assuming geometry is not used in more than one model + var modelID = connections.get( geoID ).parents[ 0 ].ID; + + var rawModel = fbxTree.Objects.Model[ modelID ]; + + var node = { + + modelName: THREE.PropertyBinding.sanitizeNodeName( rawModel.attrName ), + morphName: fbxTree.Objects.Deformer[ deformerID ].attrName, + + }; + + layerCurveNodes[ i ] = node; + + } + + layerCurveNodes[ i ][ curveNode.attr ] = curveNode; + + } + + } + + } ); + + layersMap.set( parseInt( nodeID ), layerCurveNodes ); + + } + + } + + return layersMap; + + }, + + // parse nodes in FBXTree.Objects.AnimationStack. These are the top level node in the animation + // hierarchy. Each Stack node will be used to create a THREE.AnimationClip + parseAnimStacks: function ( layersMap ) { + + var rawStacks = fbxTree.Objects.AnimationStack; + + // connect the stacks (clips) up to the layers + var rawClips = {}; + + for ( var nodeID in rawStacks ) { + + var children = connections.get( parseInt( nodeID ) ).children; + + if ( children.length > 1 ) { + + // it seems like stacks will always be associated with a single layer. But just in case there are files + // where there are multiple layers per stack, we'll display a warning + console.warn( 'THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.' ); + + } + + var layer = layersMap.get( children[ 0 ].ID ); + + rawClips[ nodeID ] = { + + name: rawStacks[ nodeID ].attrName, + layer: layer, + + }; + + } + + return rawClips; + + }, + + addClip: function ( rawClip ) { + + var tracks = []; + + var self = this; + rawClip.layer.forEach( function ( rawTracks ) { + + tracks = tracks.concat( self.generateTracks( rawTracks ) ); + + } ); + + return new THREE.AnimationClip( rawClip.name, - 1, tracks ); + + }, + + generateTracks: function ( rawTracks ) { + + var tracks = []; + + var initialPosition = new THREE.Vector3(); + var initialRotation = new THREE.Quaternion(); + var initialScale = new THREE.Vector3(); + + if ( rawTracks.transform ) rawTracks.transform.decompose( initialPosition, initialRotation, initialScale ); + + initialPosition = initialPosition.toArray(); + initialRotation = new THREE.Euler().setFromQuaternion( initialRotation, rawTracks.eulerOrder ).toArray(); + initialScale = initialScale.toArray(); + + if ( rawTracks.T !== undefined && Object.keys( rawTracks.T.curves ).length > 0 ) { + + var positionTrack = this.generateVectorTrack( rawTracks.modelName, rawTracks.T.curves, initialPosition, 'position' ); + if ( positionTrack !== undefined ) tracks.push( positionTrack ); + + } + + if ( rawTracks.R !== undefined && Object.keys( rawTracks.R.curves ).length > 0 ) { + + var rotationTrack = this.generateRotationTrack( rawTracks.modelName, rawTracks.R.curves, initialRotation, rawTracks.preRotation, rawTracks.postRotation, rawTracks.eulerOrder ); + if ( rotationTrack !== undefined ) tracks.push( rotationTrack ); + + } + + if ( rawTracks.S !== undefined && Object.keys( rawTracks.S.curves ).length > 0 ) { + + var scaleTrack = this.generateVectorTrack( rawTracks.modelName, rawTracks.S.curves, initialScale, 'scale' ); + if ( scaleTrack !== undefined ) tracks.push( scaleTrack ); + + } + + if ( rawTracks.DeformPercent !== undefined ) { + + var morphTrack = this.generateMorphTrack( rawTracks ); + if ( morphTrack !== undefined ) tracks.push( morphTrack ); + + } + + return tracks; + + }, + + generateVectorTrack: function ( modelName, curves, initialValue, type ) { + + var times = this.getTimesForAllAxes( curves ); + var values = this.getKeyframeTrackValues( times, curves, initialValue ); + + return new THREE.VectorKeyframeTrack( modelName + '.' + type, times, values ); + + }, + + generateRotationTrack: function ( modelName, curves, initialValue, preRotation, postRotation, eulerOrder ) { + + if ( curves.x !== undefined ) { + + this.interpolateRotations( curves.x ); + curves.x.values = curves.x.values.map( THREE.Math.degToRad ); + + } + if ( curves.y !== undefined ) { + + this.interpolateRotations( curves.y ); + curves.y.values = curves.y.values.map( THREE.Math.degToRad ); + + } + if ( curves.z !== undefined ) { + + this.interpolateRotations( curves.z ); + curves.z.values = curves.z.values.map( THREE.Math.degToRad ); + + } + + var times = this.getTimesForAllAxes( curves ); + var values = this.getKeyframeTrackValues( times, curves, initialValue ); + + if ( preRotation !== undefined ) { + + preRotation = preRotation.map( THREE.Math.degToRad ); + preRotation.push( eulerOrder ); + + preRotation = new THREE.Euler().fromArray( preRotation ); + preRotation = new THREE.Quaternion().setFromEuler( preRotation ); + + } + + if ( postRotation !== undefined ) { + + postRotation = postRotation.map( THREE.Math.degToRad ); + postRotation.push( eulerOrder ); + + postRotation = new THREE.Euler().fromArray( postRotation ); + postRotation = new THREE.Quaternion().setFromEuler( postRotation ).inverse(); + + } + + var quaternion = new THREE.Quaternion(); + var euler = new THREE.Euler(); + + var quaternionValues = []; + + for ( var i = 0; i < values.length; i += 3 ) { + + euler.set( values[ i ], values[ i + 1 ], values[ i + 2 ], eulerOrder ); + + quaternion.setFromEuler( euler ); + + if ( preRotation !== undefined ) quaternion.premultiply( preRotation ); + if ( postRotation !== undefined ) quaternion.multiply( postRotation ); + + quaternion.toArray( quaternionValues, ( i / 3 ) * 4 ); + + } + + return new THREE.QuaternionKeyframeTrack( modelName + '.quaternion', times, quaternionValues ); + + }, + + generateMorphTrack: function ( rawTracks ) { + + var curves = rawTracks.DeformPercent.curves.morph; + var values = curves.values.map( function ( val ) { + + return val / 100; + + } ); + + var morphNum = sceneGraph.getObjectByName( rawTracks.modelName ).morphTargetDictionary[ rawTracks.morphName ]; + + return new THREE.NumberKeyframeTrack( rawTracks.modelName + '.morphTargetInfluences[' + morphNum + ']', curves.times, values ); + + }, + + // For all animated objects, times are defined separately for each axis + // Here we'll combine the times into one sorted array without duplicates + getTimesForAllAxes: function ( curves ) { + + var times = []; + + // first join together the times for each axis, if defined + if ( curves.x !== undefined ) times = times.concat( curves.x.times ); + if ( curves.y !== undefined ) times = times.concat( curves.y.times ); + if ( curves.z !== undefined ) times = times.concat( curves.z.times ); + + // then sort them and remove duplicates + times = times.sort( function ( a, b ) { + + return a - b; + + } ).filter( function ( elem, index, array ) { + + return array.indexOf( elem ) == index; + + } ); + + return times; + + }, + + getKeyframeTrackValues: function ( times, curves, initialValue ) { + + var prevValue = initialValue; + + var values = []; + + var xIndex = - 1; + var yIndex = - 1; + var zIndex = - 1; + + times.forEach( function ( time ) { + + if ( curves.x ) xIndex = curves.x.times.indexOf( time ); + if ( curves.y ) yIndex = curves.y.times.indexOf( time ); + if ( curves.z ) zIndex = curves.z.times.indexOf( time ); + + // if there is an x value defined for this frame, use that + if ( xIndex !== - 1 ) { + + var xValue = curves.x.values[ xIndex ]; + values.push( xValue ); + prevValue[ 0 ] = xValue; + + } else { + + // otherwise use the x value from the previous frame + values.push( prevValue[ 0 ] ); + + } + + if ( yIndex !== - 1 ) { + + var yValue = curves.y.values[ yIndex ]; + values.push( yValue ); + prevValue[ 1 ] = yValue; + + } else { + + values.push( prevValue[ 1 ] ); + + } + + if ( zIndex !== - 1 ) { + + var zValue = curves.z.values[ zIndex ]; + values.push( zValue ); + prevValue[ 2 ] = zValue; + + } else { + + values.push( prevValue[ 2 ] ); + + } + + } ); + + return values; + + }, + + // Rotations are defined as Euler angles which can have values of any size + // These will be converted to quaternions which don't support values greater than + // PI, so we'll interpolate large rotations + interpolateRotations: function ( curve ) { + + for ( var i = 1; i < curve.values.length; i ++ ) { + + var initialValue = curve.values[ i - 1 ]; + var valuesSpan = curve.values[ i ] - initialValue; + + var absoluteSpan = Math.abs( valuesSpan ); + + if ( absoluteSpan >= 180 ) { + + var numSubIntervals = absoluteSpan / 180; + + var step = valuesSpan / numSubIntervals; + var nextValue = initialValue + step; + + var initialTime = curve.times[ i - 1 ]; + var timeSpan = curve.times[ i ] - initialTime; + var interval = timeSpan / numSubIntervals; + var nextTime = initialTime + interval; + + var interpolatedTimes = []; + var interpolatedValues = []; + + while ( nextTime < curve.times[ i ] ) { + + interpolatedTimes.push( nextTime ); + nextTime += interval; + + interpolatedValues.push( nextValue ); + nextValue += step; + + } + + curve.times = inject( curve.times, i, interpolatedTimes ); + curve.values = inject( curve.values, i, interpolatedValues ); + + } + + } + + }, + + }; + + // parse an FBX file in ASCII format + function TextParser() {} + + TextParser.prototype = { + + constructor: TextParser, + + getPrevNode: function () { + + return this.nodeStack[ this.currentIndent - 2 ]; + + }, + + getCurrentNode: function () { + + return this.nodeStack[ this.currentIndent - 1 ]; + + }, + + getCurrentProp: function () { + + return this.currentProp; + + }, + + pushStack: function ( node ) { + + this.nodeStack.push( node ); + this.currentIndent += 1; + + }, + + popStack: function () { + + this.nodeStack.pop(); + this.currentIndent -= 1; + + }, + + setCurrentProp: function ( val, name ) { + + this.currentProp = val; + this.currentPropName = name; + + }, + + parse: function ( text ) { + + this.currentIndent = 0; + + this.allNodes = new FBXTree(); + this.nodeStack = []; + this.currentProp = []; + this.currentPropName = ''; + + var self = this; + + var split = text.split( /[\r\n]+/ ); + + split.forEach( function ( line, i ) { + + var matchComment = line.match( /^[\s\t]*;/ ); + var matchEmpty = line.match( /^[\s\t]*$/ ); + + if ( matchComment || matchEmpty ) return; + + var matchBeginning = line.match( '^\\t{' + self.currentIndent + '}(\\w+):(.*){', '' ); + var matchProperty = line.match( '^\\t{' + ( self.currentIndent ) + '}(\\w+):[\\s\\t\\r\\n](.*)' ); + var matchEnd = line.match( '^\\t{' + ( self.currentIndent - 1 ) + '}}' ); + + if ( matchBeginning ) { + + self.parseNodeBegin( line, matchBeginning ); + + } else if ( matchProperty ) { + + self.parseNodeProperty( line, matchProperty, split[ ++ i ] ); + + } else if ( matchEnd ) { + + self.popStack(); + + } else if ( line.match( /^[^\s\t}]/ ) ) { + + // large arrays are split over multiple lines terminated with a ',' character + // if this is encountered the line needs to be joined to the previous line + self.parseNodePropertyContinued( line ); + + } + + } ); + + return this.allNodes; + + }, + + parseNodeBegin: function ( line, property ) { + + var nodeName = property[ 1 ].trim().replace( /^"/, '' ).replace( /"$/, '' ); + + var nodeAttrs = property[ 2 ].split( ',' ).map( function ( attr ) { + + return attr.trim().replace( /^"/, '' ).replace( /"$/, '' ); + + } ); + + var node = { name: nodeName }; + var attrs = this.parseNodeAttr( nodeAttrs ); + + var currentNode = this.getCurrentNode(); + + // a top node + if ( this.currentIndent === 0 ) { + + this.allNodes.add( nodeName, node ); + + } else { // a subnode + + // if the subnode already exists, append it + if ( nodeName in currentNode ) { + + // special case Pose needs PoseNodes as an array + if ( nodeName === 'PoseNode' ) { + + currentNode.PoseNode.push( node ); + + } else if ( currentNode[ nodeName ].id !== undefined ) { + + currentNode[ nodeName ] = {}; + currentNode[ nodeName ][ currentNode[ nodeName ].id ] = currentNode[ nodeName ]; + + } + + if ( attrs.id !== '' ) currentNode[ nodeName ][ attrs.id ] = node; + + } else if ( typeof attrs.id === 'number' ) { + + currentNode[ nodeName ] = {}; + currentNode[ nodeName ][ attrs.id ] = node; + + } else if ( nodeName !== 'Properties70' ) { + + if ( nodeName === 'PoseNode' ) currentNode[ nodeName ] = [ node ]; + else currentNode[ nodeName ] = node; + + } + + } + + if ( typeof attrs.id === 'number' ) node.id = attrs.id; + if ( attrs.name !== '' ) node.attrName = attrs.name; + if ( attrs.type !== '' ) node.attrType = attrs.type; + + this.pushStack( node ); + + }, + + parseNodeAttr: function ( attrs ) { + + var id = attrs[ 0 ]; + + if ( attrs[ 0 ] !== '' ) { + + id = parseInt( attrs[ 0 ] ); + + if ( isNaN( id ) ) { + + id = attrs[ 0 ]; + + } + + } + + var name = '', type = ''; + + if ( attrs.length > 1 ) { + + name = attrs[ 1 ].replace( /^(\w+)::/, '' ); + type = attrs[ 2 ]; + + } + + return { id: id, name: name, type: type }; + + }, + + parseNodeProperty: function ( line, property, contentLine ) { + + var propName = property[ 1 ].replace( /^"/, '' ).replace( /"$/, '' ).trim(); + var propValue = property[ 2 ].replace( /^"/, '' ).replace( /"$/, '' ).trim(); + + // for special case: base64 image data follows "Content: ," line + // Content: , + // "/9j/4RDaRXhpZgAATU0A..." + if ( propName === 'Content' && propValue === ',' ) { + + propValue = contentLine.replace( /"/g, '' ).replace( /,$/, '' ).trim(); + + } + + var currentNode = this.getCurrentNode(); + var parentName = currentNode.name; + + if ( parentName === 'Properties70' ) { + + this.parseNodeSpecialProperty( line, propName, propValue ); + return; + + } + + // Connections + if ( propName === 'C' ) { + + var connProps = propValue.split( ',' ).slice( 1 ); + var from = parseInt( connProps[ 0 ] ); + var to = parseInt( connProps[ 1 ] ); + + var rest = propValue.split( ',' ).slice( 3 ); + + rest = rest.map( function ( elem ) { + + return elem.trim().replace( /^"/, '' ); + + } ); + + propName = 'connections'; + propValue = [ from, to ]; + append( propValue, rest ); + + if ( currentNode[ propName ] === undefined ) { + + currentNode[ propName ] = []; + + } + + } + + // Node + if ( propName === 'Node' ) currentNode.id = propValue; + + // connections + if ( propName in currentNode && Array.isArray( currentNode[ propName ] ) ) { + + currentNode[ propName ].push( propValue ); + + } else { + + if ( propName !== 'a' ) currentNode[ propName ] = propValue; + else currentNode.a = propValue; + + } + + this.setCurrentProp( currentNode, propName ); + + // convert string to array, unless it ends in ',' in which case more will be added to it + if ( propName === 'a' && propValue.slice( - 1 ) !== ',' ) { + + currentNode.a = parseNumberArray( propValue ); + + } + + }, + + parseNodePropertyContinued: function ( line ) { + + var currentNode = this.getCurrentNode(); + + currentNode.a += line; + + // if the line doesn't end in ',' we have reached the end of the property value + // so convert the string to an array + if ( line.slice( - 1 ) !== ',' ) { + + currentNode.a = parseNumberArray( currentNode.a ); + + } + + }, + + // parse "Property70" + parseNodeSpecialProperty: function ( line, propName, propValue ) { + + // split this + // P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1 + // into array like below + // ["Lcl Scaling", "Lcl Scaling", "", "A", "1,1,1" ] + var props = propValue.split( '",' ).map( function ( prop ) { + + return prop.trim().replace( /^\"/, '' ).replace( /\s/, '_' ); + + } ); + + var innerPropName = props[ 0 ]; + var innerPropType1 = props[ 1 ]; + var innerPropType2 = props[ 2 ]; + var innerPropFlag = props[ 3 ]; + var innerPropValue = props[ 4 ]; + + // cast values where needed, otherwise leave as strings + switch ( innerPropType1 ) { + + case 'int': + case 'enum': + case 'bool': + case 'ULongLong': + case 'double': + case 'Number': + case 'FieldOfView': + innerPropValue = parseFloat( innerPropValue ); + break; + + case 'Color': + case 'ColorRGB': + case 'Vector3D': + case 'Lcl_Translation': + case 'Lcl_Rotation': + case 'Lcl_Scaling': + innerPropValue = parseNumberArray( innerPropValue ); + break; + + } + + // CAUTION: these props must append to parent's parent + this.getPrevNode()[ innerPropName ] = { + + 'type': innerPropType1, + 'type2': innerPropType2, + 'flag': innerPropFlag, + 'value': innerPropValue + + }; + + this.setCurrentProp( this.getPrevNode(), innerPropName ); + + }, + + }; + + // Parse an FBX file in Binary format + function BinaryParser() {} + + BinaryParser.prototype = { + + constructor: BinaryParser, + + parse: function ( buffer ) { + + var reader = new BinaryReader( buffer ); + reader.skip( 23 ); // skip magic 23 bytes + + var version = reader.getUint32(); + + console.log( 'THREE.FBXLoader: FBX binary version: ' + version ); + + var allNodes = new FBXTree(); + + while ( ! this.endOfContent( reader ) ) { + + var node = this.parseNode( reader, version ); + if ( node !== null ) allNodes.add( node.name, node ); + + } + + return allNodes; + + }, + + // Check if reader has reached the end of content. + endOfContent: function ( reader ) { + + // footer size: 160bytes + 16-byte alignment padding + // - 16bytes: magic + // - padding til 16-byte alignment (at least 1byte?) + // (seems like some exporters embed fixed 15 or 16bytes?) + // - 4bytes: magic + // - 4bytes: version + // - 120bytes: zero + // - 16bytes: magic + if ( reader.size() % 16 === 0 ) { + + return ( ( reader.getOffset() + 160 + 16 ) & ~ 0xf ) >= reader.size(); + + } else { + + return reader.getOffset() + 160 + 16 >= reader.size(); + + } + + }, + + // recursively parse nodes until the end of the file is reached + parseNode: function ( reader, version ) { + + var node = {}; + + // The first three data sizes depends on version. + var endOffset = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); + var numProperties = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); + + // note: do not remove this even if you get a linter warning as it moves the buffer forward + var propertyListLen = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); + + var nameLen = reader.getUint8(); + var name = reader.getString( nameLen ); + + // Regards this node as NULL-record if endOffset is zero + if ( endOffset === 0 ) return null; + + var propertyList = []; + + for ( var i = 0; i < numProperties; i ++ ) { + + propertyList.push( this.parseProperty( reader ) ); + + } + + // Regards the first three elements in propertyList as id, attrName, and attrType + var id = propertyList.length > 0 ? propertyList[ 0 ] : ''; + var attrName = propertyList.length > 1 ? propertyList[ 1 ] : ''; + var attrType = propertyList.length > 2 ? propertyList[ 2 ] : ''; + + // check if this node represents just a single property + // like (name, 0) set or (name2, [0, 1, 2]) set of {name: 0, name2: [0, 1, 2]} + node.singleProperty = ( numProperties === 1 && reader.getOffset() === endOffset ) ? true : false; + + while ( endOffset > reader.getOffset() ) { + + var subNode = this.parseNode( reader, version ); + + if ( subNode !== null ) this.parseSubNode( name, node, subNode ); + + } + + node.propertyList = propertyList; // raw property list used by parent + + if ( typeof id === 'number' ) node.id = id; + if ( attrName !== '' ) node.attrName = attrName; + if ( attrType !== '' ) node.attrType = attrType; + if ( name !== '' ) node.name = name; + + return node; + + }, + + parseSubNode: function ( name, node, subNode ) { + + // special case: child node is single property + if ( subNode.singleProperty === true ) { + + var value = subNode.propertyList[ 0 ]; + + if ( Array.isArray( value ) ) { + + node[ subNode.name ] = subNode; + + subNode.a = value; + + } else { + + node[ subNode.name ] = value; + + } + + } else if ( name === 'Connections' && subNode.name === 'C' ) { + + var array = []; + + subNode.propertyList.forEach( function ( property, i ) { + + // first Connection is FBX type (OO, OP, etc.). We'll discard these + if ( i !== 0 ) array.push( property ); + + } ); + + if ( node.connections === undefined ) { + + node.connections = []; + + } + + node.connections.push( array ); + + } else if ( subNode.name === 'Properties70' ) { + + var keys = Object.keys( subNode ); + + keys.forEach( function ( key ) { + + node[ key ] = subNode[ key ]; + + } ); + + } else if ( name === 'Properties70' && subNode.name === 'P' ) { + + var innerPropName = subNode.propertyList[ 0 ]; + var innerPropType1 = subNode.propertyList[ 1 ]; + var innerPropType2 = subNode.propertyList[ 2 ]; + var innerPropFlag = subNode.propertyList[ 3 ]; + var innerPropValue; + + if ( innerPropName.indexOf( 'Lcl ' ) === 0 ) innerPropName = innerPropName.replace( 'Lcl ', 'Lcl_' ); + if ( innerPropType1.indexOf( 'Lcl ' ) === 0 ) innerPropType1 = innerPropType1.replace( 'Lcl ', 'Lcl_' ); + + if ( innerPropType1 === 'Color' || innerPropType1 === 'ColorRGB' || innerPropType1 === 'Vector' || innerPropType1 === 'Vector3D' || innerPropType1.indexOf( 'Lcl_' ) === 0 ) { + + innerPropValue = [ + subNode.propertyList[ 4 ], + subNode.propertyList[ 5 ], + subNode.propertyList[ 6 ] + ]; + + } else { + + innerPropValue = subNode.propertyList[ 4 ]; + + } + + // this will be copied to parent, see above + node[ innerPropName ] = { + + 'type': innerPropType1, + 'type2': innerPropType2, + 'flag': innerPropFlag, + 'value': innerPropValue + + }; + + } else if ( node[ subNode.name ] === undefined ) { + + if ( typeof subNode.id === 'number' ) { + + node[ subNode.name ] = {}; + node[ subNode.name ][ subNode.id ] = subNode; + + } else { + + node[ subNode.name ] = subNode; + + } + + } else { + + if ( subNode.name === 'PoseNode' ) { + + if ( ! Array.isArray( node[ subNode.name ] ) ) { + + node[ subNode.name ] = [ node[ subNode.name ] ]; + + } + + node[ subNode.name ].push( subNode ); + + } else if ( node[ subNode.name ][ subNode.id ] === undefined ) { + + node[ subNode.name ][ subNode.id ] = subNode; + + } + + } + + }, + + parseProperty: function ( reader ) { + + var type = reader.getString( 1 ); + + switch ( type ) { + + case 'C': + return reader.getBoolean(); + + case 'D': + return reader.getFloat64(); + + case 'F': + return reader.getFloat32(); + + case 'I': + return reader.getInt32(); + + case 'L': + return reader.getInt64(); + + case 'R': + var length = reader.getUint32(); + return reader.getArrayBuffer( length ); + + case 'S': + var length = reader.getUint32(); + return reader.getString( length ); + + case 'Y': + return reader.getInt16(); + + case 'b': + case 'c': + case 'd': + case 'f': + case 'i': + case 'l': + + var arrayLength = reader.getUint32(); + var encoding = reader.getUint32(); // 0: non-compressed, 1: compressed + var compressedLength = reader.getUint32(); + + if ( encoding === 0 ) { + + switch ( type ) { + + case 'b': + case 'c': + return reader.getBooleanArray( arrayLength ); + + case 'd': + return reader.getFloat64Array( arrayLength ); + + case 'f': + return reader.getFloat32Array( arrayLength ); + + case 'i': + return reader.getInt32Array( arrayLength ); + + case 'l': + return reader.getInt64Array( arrayLength ); + + } + + } + + if ( typeof Zlib === 'undefined' ) { + + console.error( 'THREE.FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js' ); + + } + + var inflate = new Zlib.Inflate( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef + var reader2 = new BinaryReader( inflate.decompress().buffer ); + + switch ( type ) { + + case 'b': + case 'c': + return reader2.getBooleanArray( arrayLength ); + + case 'd': + return reader2.getFloat64Array( arrayLength ); + + case 'f': + return reader2.getFloat32Array( arrayLength ); + + case 'i': + return reader2.getInt32Array( arrayLength ); + + case 'l': + return reader2.getInt64Array( arrayLength ); + + } + + default: + throw new Error( 'THREE.FBXLoader: Unknown property type ' + type ); + + } + + } + + }; + + function BinaryReader( buffer, littleEndian ) { + + this.dv = new DataView( buffer ); + this.offset = 0; + this.littleEndian = ( littleEndian !== undefined ) ? littleEndian : true; + + } + + BinaryReader.prototype = { + + constructor: BinaryReader, + + getOffset: function () { + + return this.offset; + + }, + + size: function () { + + return this.dv.buffer.byteLength; + + }, + + skip: function ( length ) { + + this.offset += length; + + }, + + // seems like true/false representation depends on exporter. + // true: 1 or 'Y'(=0x59), false: 0 or 'T'(=0x54) + // then sees LSB. + getBoolean: function () { + + return ( this.getUint8() & 1 ) === 1; + + }, + + getBooleanArray: function ( size ) { + + var a = []; + + for ( var i = 0; i < size; i ++ ) { + + a.push( this.getBoolean() ); + + } + + return a; + + }, + + getUint8: function () { + + var value = this.dv.getUint8( this.offset ); + this.offset += 1; + return value; + + }, + + getInt16: function () { + + var value = this.dv.getInt16( this.offset, this.littleEndian ); + this.offset += 2; + return value; + + }, + + getInt32: function () { + + var value = this.dv.getInt32( this.offset, this.littleEndian ); + this.offset += 4; + return value; + + }, + + getInt32Array: function ( size ) { + + var a = []; + + for ( var i = 0; i < size; i ++ ) { + + a.push( this.getInt32() ); + + } + + return a; + + }, + + getUint32: function () { + + var value = this.dv.getUint32( this.offset, this.littleEndian ); + this.offset += 4; + return value; + + }, + + // JavaScript doesn't support 64-bit integer so calculate this here + // 1 << 32 will return 1 so using multiply operation instead here. + // There's a possibility that this method returns wrong value if the value + // is out of the range between Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER. + // TODO: safely handle 64-bit integer + getInt64: function () { + + var low, high; + + if ( this.littleEndian ) { + + low = this.getUint32(); + high = this.getUint32(); + + } else { + + high = this.getUint32(); + low = this.getUint32(); + + } + + // calculate negative value + if ( high & 0x80000000 ) { + + high = ~ high & 0xFFFFFFFF; + low = ~ low & 0xFFFFFFFF; + + if ( low === 0xFFFFFFFF ) high = ( high + 1 ) & 0xFFFFFFFF; + + low = ( low + 1 ) & 0xFFFFFFFF; + + return - ( high * 0x100000000 + low ); + + } + + return high * 0x100000000 + low; + + }, + + getInt64Array: function ( size ) { + + var a = []; + + for ( var i = 0; i < size; i ++ ) { + + a.push( this.getInt64() ); + + } + + return a; + + }, + + // Note: see getInt64() comment + getUint64: function () { + + var low, high; + + if ( this.littleEndian ) { + + low = this.getUint32(); + high = this.getUint32(); + + } else { + + high = this.getUint32(); + low = this.getUint32(); + + } + + return high * 0x100000000 + low; + + }, + + getFloat32: function () { + + var value = this.dv.getFloat32( this.offset, this.littleEndian ); + this.offset += 4; + return value; + + }, + + getFloat32Array: function ( size ) { + + var a = []; + + for ( var i = 0; i < size; i ++ ) { + + a.push( this.getFloat32() ); + + } + + return a; + + }, + + getFloat64: function () { + + var value = this.dv.getFloat64( this.offset, this.littleEndian ); + this.offset += 8; + return value; + + }, + + getFloat64Array: function ( size ) { + + var a = []; + + for ( var i = 0; i < size; i ++ ) { + + a.push( this.getFloat64() ); + + } + + return a; + + }, + + getArrayBuffer: function ( size ) { + + var value = this.dv.buffer.slice( this.offset, this.offset + size ); + this.offset += size; + return value; + + }, + + getString: function ( size ) { + + // note: safari 9 doesn't support Uint8Array.indexOf; create intermediate array instead + var a = []; + + for ( var i = 0; i < size; i ++ ) { + + a[ i ] = this.getUint8(); + + } + + var nullByte = a.indexOf( 0 ); + if ( nullByte >= 0 ) a = a.slice( 0, nullByte ); + + return THREE.LoaderUtils.decodeText( new Uint8Array( a ) ); + + } + + }; + + // FBXTree holds a representation of the FBX data, returned by the TextParser ( FBX ASCII format) + // and BinaryParser( FBX Binary format) + function FBXTree() {} + + FBXTree.prototype = { + + constructor: FBXTree, + + add: function ( key, val ) { + + this[ key ] = val; + + }, + + }; + + // ************** UTILITY FUNCTIONS ************** + + function isFbxFormatBinary( buffer ) { + + var CORRECT = 'Kaydara FBX Binary \0'; + + return buffer.byteLength >= CORRECT.length && CORRECT === convertArrayBufferToString( buffer, 0, CORRECT.length ); + + } + + function isFbxFormatASCII( text ) { + + var CORRECT = [ 'K', 'a', 'y', 'd', 'a', 'r', 'a', '\\', 'F', 'B', 'X', '\\', 'B', 'i', 'n', 'a', 'r', 'y', '\\', '\\' ]; + + var cursor = 0; + + function read( offset ) { + + var result = text[ offset - 1 ]; + text = text.slice( cursor + offset ); + cursor ++; + return result; + + } + + for ( var i = 0; i < CORRECT.length; ++ i ) { + + var num = read( 1 ); + if ( num === CORRECT[ i ] ) { + + return false; + + } + + } + + return true; + + } + + function getFbxVersion( text ) { + + var versionRegExp = /FBXVersion: (\d+)/; + var match = text.match( versionRegExp ); + if ( match ) { + + var version = parseInt( match[ 1 ] ); + return version; + + } + throw new Error( 'THREE.FBXLoader: Cannot find the version number for the file given.' ); + + } + + // Converts FBX ticks into real time seconds. + function convertFBXTimeToSeconds( time ) { + + return time / 46186158000; + + } + + var dataArray = []; + + // extracts the data from the correct position in the FBX array based on indexing type + function getData( polygonVertexIndex, polygonIndex, vertexIndex, infoObject ) { + + var index; + + switch ( infoObject.mappingType ) { + + case 'ByPolygonVertex' : + index = polygonVertexIndex; + break; + case 'ByPolygon' : + index = polygonIndex; + break; + case 'ByVertice' : + index = vertexIndex; + break; + case 'AllSame' : + index = infoObject.indices[ 0 ]; + break; + default : + console.warn( 'THREE.FBXLoader: unknown attribute mapping type ' + infoObject.mappingType ); + + } + + if ( infoObject.referenceType === 'IndexToDirect' ) index = infoObject.indices[ index ]; + + var from = index * infoObject.dataSize; + var to = from + infoObject.dataSize; + + return slice( dataArray, infoObject.buffer, from, to ); + + } + + var tempEuler = new THREE.Euler(); + var tempVec = new THREE.Vector3(); + + // generate transformation from FBX transform data + // ref: https://help.autodesk.com/view/FBX/2017/ENU/?guid=__files_GUID_10CDD63C_79C1_4F2D_BB28_AD2BE65A02ED_htm + // ref: http://docs.autodesk.com/FBX/2014/ENU/FBX-SDK-Documentation/index.html?url=cpp_ref/_transformations_2main_8cxx-example.html,topicNumber=cpp_ref__transformations_2main_8cxx_example_htmlfc10a1e1-b18d-4e72-9dc0-70d0f1959f5e + function generateTransform( transformData ) { + + var lTranslationM = new THREE.Matrix4(); + var lPreRotationM = new THREE.Matrix4(); + var lRotationM = new THREE.Matrix4(); + var lPostRotationM = new THREE.Matrix4(); + + var lScalingM = new THREE.Matrix4(); + var lScalingPivotM = new THREE.Matrix4(); + var lScalingOffsetM = new THREE.Matrix4(); + var lRotationOffsetM = new THREE.Matrix4(); + var lRotationPivotM = new THREE.Matrix4(); + + var lParentGX = new THREE.Matrix4(); + var lGlobalT = new THREE.Matrix4(); + + var inheritType = ( transformData.inheritType ) ? transformData.inheritType : 0; + + if ( transformData.translation ) lTranslationM.setPosition( tempVec.fromArray( transformData.translation ) ); + + if ( transformData.preRotation ) { + + var array = transformData.preRotation.map( THREE.Math.degToRad ); + array.push( transformData.eulerOrder ); + lPreRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) ); + + } + + if ( transformData.rotation ) { + + var array = transformData.rotation.map( THREE.Math.degToRad ); + array.push( transformData.eulerOrder ); + lRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) ); + + } + + if ( transformData.postRotation ) { + + var array = transformData.postRotation.map( THREE.Math.degToRad ); + array.push( transformData.eulerOrder ); + lPostRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) ); + + } + + if ( transformData.scale ) lScalingM.scale( tempVec.fromArray( transformData.scale ) ); + + // Pivots and offsets + if ( transformData.scalingOffset ) lScalingOffsetM.setPosition( tempVec.fromArray( transformData.scalingOffset ) ); + if ( transformData.scalingPivot ) lScalingPivotM.setPosition( tempVec.fromArray( transformData.scalingPivot ) ); + if ( transformData.rotationOffset ) lRotationOffsetM.setPosition( tempVec.fromArray( transformData.rotationOffset ) ); + if ( transformData.rotationPivot ) lRotationPivotM.setPosition( tempVec.fromArray( transformData.rotationPivot ) ); + + // parent transform + if ( transformData.parentMatrixWorld ) lParentGX = transformData.parentMatrixWorld; + + // Global Rotation + var lLRM = lPreRotationM.multiply( lRotationM ).multiply( lPostRotationM ); + var lParentGRM = new THREE.Matrix4(); + lParentGX.extractRotation( lParentGRM ); + + // Global Shear*Scaling + var lParentTM = new THREE.Matrix4(); + var lLSM; + var lParentGSM; + var lParentGRSM; + + lParentTM.copyPosition( lParentGX ); + lParentGRSM = lParentTM.getInverse( lParentTM ).multiply( lParentGX ); + lParentGSM = lParentGRM.getInverse( lParentGRM ).multiply( lParentGRSM ); + lLSM = lScalingM; + + var lGlobalRS; + if ( inheritType === 0 ) { + + lGlobalRS = lParentGRM.multiply( lLRM ).multiply( lParentGSM ).multiply( lLSM ); + + } else if ( inheritType === 1 ) { + + lGlobalRS = lParentGRM.multiply( lParentGSM ).multiply( lLRM ).multiply( lLSM ); + + } else { + + var lParentLSM = new THREE.Matrix4().copy( lScalingM ); + + var lParentGSM_noLocal = lParentGSM.multiply( lParentLSM.getInverse( lParentLSM ) ); + + lGlobalRS = lParentGRM.multiply( lLRM ).multiply( lParentGSM_noLocal ).multiply( lLSM ); + + } + + // Calculate the local transform matrix + var lTransform = lTranslationM.multiply( lRotationOffsetM ).multiply( lRotationPivotM ).multiply( lPreRotationM ).multiply( lRotationM ).multiply( lPostRotationM ).multiply( lRotationPivotM.getInverse( lRotationPivotM ) ).multiply( lScalingOffsetM ).multiply( lScalingPivotM ).multiply( lScalingM ).multiply( lScalingPivotM.getInverse( lScalingPivotM ) ); + + var lLocalTWithAllPivotAndOffsetInfo = new THREE.Matrix4().copyPosition( lTransform ); + + var lGlobalTranslation = lParentGX.multiply( lLocalTWithAllPivotAndOffsetInfo ); + lGlobalT.copyPosition( lGlobalTranslation ); + + lTransform = lGlobalT.multiply( lGlobalRS ); + + return lTransform; + + } + + // Returns the three.js intrinsic Euler order corresponding to FBX extrinsic Euler order + // ref: http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html + function getEulerOrder( order ) { + + order = order || 0; + + var enums = [ + 'ZYX', // -> XYZ extrinsic + 'YZX', // -> XZY extrinsic + 'XZY', // -> YZX extrinsic + 'ZXY', // -> YXZ extrinsic + 'YXZ', // -> ZXY extrinsic + 'XYZ', // -> ZYX extrinsic + //'SphericXYZ', // not possible to support + ]; + + if ( order === 6 ) { + + console.warn( 'THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.' ); + return enums[ 0 ]; + + } + + return enums[ order ]; + + } + + // Parses comma separated list of numbers and returns them an array. + // Used internally by the TextParser + function parseNumberArray( value ) { + + var array = value.split( ',' ).map( function ( val ) { + + return parseFloat( val ); + + } ); + + return array; + + } + + function convertArrayBufferToString( buffer, from, to ) { + + if ( from === undefined ) from = 0; + if ( to === undefined ) to = buffer.byteLength; + + return THREE.LoaderUtils.decodeText( new Uint8Array( buffer, from, to ) ); + + } + + function append( a, b ) { + + for ( var i = 0, j = a.length, l = b.length; i < l; i ++, j ++ ) { + + a[ j ] = b[ i ]; + + } + + } + + function slice( a, b, from, to ) { + + for ( var i = from, j = 0; i < to; i ++, j ++ ) { + + a[ j ] = b[ i ]; + + } + + return a; + + } + + // inject array a2 into array a1 at index + function inject( a1, index, a2 ) { + + return a1.slice( 0, index ).concat( a2 ).concat( a1.slice( index ) ); + + } + + return FBXLoader; + +} )(); diff --git a/three/jsutil/loaders/GCodeLoader.js b/three/jsutil/loaders/GCodeLoader.js new file mode 100644 index 000000000..4626f5c4d --- /dev/null +++ b/three/jsutil/loaders/GCodeLoader.js @@ -0,0 +1,225 @@ +'use strict'; + +/** + * THREE.GCodeLoader is used to load gcode files usually used for 3D printing or CNC applications. + * + * Gcode files are composed by commands used by machines to create objects. + * + * @class THREE.GCodeLoader + * @param {Manager} manager Loading manager. + * @author tentone + * @author joewalnes + */ +THREE.GCodeLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.splitLayer = false; + +}; + +THREE.GCodeLoader.prototype.load = function ( url, onLoad, onProgress, onError ) { + + var self = this; + + var loader = new THREE.FileLoader( self.manager ); + loader.setPath( self.path ); + loader.load( url, function ( text ) { + + onLoad( self.parse( text ) ); + + }, onProgress, onError ); + +}; + +THREE.GCodeLoader.prototype.setPath = function ( value ) { + + this.path = value; + return this; + +}; + +THREE.GCodeLoader.prototype.parse = function ( data ) { + + var state = { x: 0, y: 0, z: 0, e: 0, f: 0, extruding: false, relative: false }; + var layers = []; + + var currentLayer = undefined; + + var pathMaterial = new THREE.LineBasicMaterial( { color: 0xFF0000 } ); + pathMaterial.name = 'path'; + + var extrudingMaterial = new THREE.LineBasicMaterial( { color: 0x00FF00 } ); + extrudingMaterial.name = 'extruded'; + + function newLayer( line ) { + + currentLayer = { vertex: [], pathVertex: [], z: line.z }; + layers.push( currentLayer ); + + } + + //Create lie segment between p1 and p2 + function addSegment( p1, p2 ) { + + if ( currentLayer === undefined ) { + + newLayer( p1 ); + + } + + if ( line.extruding ) { + + currentLayer.vertex.push( p1.x, p1.y, p1.z ); + currentLayer.vertex.push( p2.x, p2.y, p2.z ); + + } else { + + currentLayer.pathVertex.push( p1.x, p1.y, p1.z ); + currentLayer.pathVertex.push( p2.x, p2.y, p2.z ); + + } + + } + + function delta( v1, v2 ) { + + return state.relative ? v2 : v2 - v1; + + } + + function absolute( v1, v2 ) { + + return state.relative ? v1 + v2 : v2; + + } + + var lines = data.replace( /;.+/g, '' ).split( '\n' ); + + for ( var i = 0; i < lines.length; i ++ ) { + + var tokens = lines[ i ].split( ' ' ); + var cmd = tokens[ 0 ].toUpperCase(); + + //Argumments + var args = {}; + tokens.splice( 1 ).forEach( function ( token ) { + + if ( token[ 0 ] !== undefined ) { + + var key = token[ 0 ].toLowerCase(); + var value = parseFloat( token.substring( 1 ) ); + args[ key ] = value; + + } + + } ); + + //Process commands + //G0/G1 – Linear Movement + if ( cmd === 'G0' || cmd === 'G1' ) { + + var line = { + x: args.x !== undefined ? absolute( state.x, args.x ) : state.x, + y: args.y !== undefined ? absolute( state.y, args.y ) : state.y, + z: args.z !== undefined ? absolute( state.z, args.z ) : state.z, + e: args.e !== undefined ? absolute( state.e, args.e ) : state.e, + f: args.f !== undefined ? absolute( state.f, args.f ) : state.f, + }; + + //Layer change detection is or made by watching Z, it's made by watching when we extrude at a new Z position + if ( delta( state.e, line.e ) > 0 ) { + + line.extruding = delta( state.e, line.e ) > 0; + + if ( currentLayer == undefined || line.z != currentLayer.z ) { + + newLayer( line ); + + } + + } + + addSegment( state, line ); + state = line; + + } else if ( cmd === 'G2' || cmd === 'G3' ) { + + //G2/G3 - Arc Movement ( G2 clock wise and G3 counter clock wise ) + console.warn( 'THREE.GCodeLoader: Arc command not supported' ); + + } else if ( cmd === 'G90' ) { + + //G90: Set to Absolute Positioning + state.relative = false; + + } else if ( cmd === 'G91' ) { + + //G91: Set to state.relative Positioning + state.relative = true; + + } else if ( cmd === 'G92' ) { + + //G92: Set Position + var line = state; + line.x = args.x !== undefined ? args.x : line.x; + line.y = args.y !== undefined ? args.y : line.y; + line.z = args.z !== undefined ? args.z : line.z; + line.e = args.e !== undefined ? args.e : line.e; + state = line; + + } else { + + console.warn( 'THREE.GCodeLoader: Command not supported:' + cmd ); + + } + + } + + function addObject( vertex, extruding ) { + + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertex, 3 ) ); + + var segments = new THREE.LineSegments( geometry, extruding ? extrudingMaterial : pathMaterial ); + segments.name = 'layer' + i; + object.add( segments ); + + } + + var object = new THREE.Group(); + object.name = 'gcode'; + + if ( this.splitLayer ) { + + for ( var i = 0; i < layers.length; i ++ ) { + + var layer = layers[ i ]; + addObject( layer.vertex, true ); + addObject( layer.pathVertex, false ); + + } + + } else { + + var vertex = [], pathVertex = []; + + for ( var i = 0; i < layers.length; i ++ ) { + + var layer = layers[ i ]; + + vertex = vertex.concat( layer.vertex ); + pathVertex = pathVertex.concat( layer.pathVertex ); + + } + + addObject( vertex, true ); + addObject( pathVertex, false ); + + } + + object.quaternion.setFromEuler( new THREE.Euler( - Math.PI / 2, 0, 0 ) ); + + return object; + +}; diff --git a/three/jsutil/loaders/GLTFLoader.js b/three/jsutil/loaders/GLTFLoader.js new file mode 100644 index 000000000..860c74718 --- /dev/null +++ b/three/jsutil/loaders/GLTFLoader.js @@ -0,0 +1,3186 @@ +/** + * @author Rich Tibbett / https://github.com/richtr + * @author mrdoob / http://mrdoob.com/ + * @author Tony Parisi / http://www.tonyparisi.com/ + * @author Takahiro / https://github.com/takahirox + * @author Don McCurdy / https://www.donmccurdy.com + */ + +THREE.GLTFLoader = ( function () { + + function GLTFLoader( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.dracoLoader = null; + + } + + GLTFLoader.prototype = { + + constructor: GLTFLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var resourcePath; + + if ( this.resourcePath !== undefined ) { + + resourcePath = this.resourcePath; + + } else if ( this.path !== undefined ) { + + resourcePath = this.path; + + } else { + + resourcePath = THREE.LoaderUtils.extractUrlBase( url ); + + } + + // Tells the LoadingManager to track an extra item, which resolves after + // the model is fully loaded. This means the count of items loaded will + // be incorrect, but ensures manager.onLoad() does not fire early. + scope.manager.itemStart( url ); + + var _onError = function ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + console.error( e ); + + } + + scope.manager.itemEnd( url ); + scope.manager.itemError( url ); + + }; + + var loader = new THREE.FileLoader( scope.manager ); + + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + + loader.load( url, function ( data ) { + + try { + + scope.parse( data, resourcePath, function ( gltf ) { + + onLoad( gltf ); + + scope.manager.itemEnd( url ); + + }, _onError ); + + } catch ( e ) { + + _onError( e ); + + } + + }, onProgress, _onError ); + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + setDRACOLoader: function ( dracoLoader ) { + + this.dracoLoader = dracoLoader; + return this; + + }, + + parse: function ( data, path, onLoad, onError ) { + + var content; + var extensions = {}; + + if ( typeof data === 'string' ) { + + content = data; + + } else { + + var magic = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) ); + + if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) { + + try { + + extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data ); + + } catch ( error ) { + + if ( onError ) onError( error ); + return; + + } + + content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content; + + } else { + + content = THREE.LoaderUtils.decodeText( new Uint8Array( data ) ); + + } + + } + + var json = JSON.parse( content ); + + if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) { + + if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.' ) ); + return; + + } + + if ( json.extensionsUsed ) { + + for ( var i = 0; i < json.extensionsUsed.length; ++ i ) { + + var extensionName = json.extensionsUsed[ i ]; + var extensionsRequired = json.extensionsRequired || []; + + switch ( extensionName ) { + + case EXTENSIONS.KHR_LIGHTS_PUNCTUAL: + extensions[ extensionName ] = new GLTFLightsExtension( json ); + break; + + case EXTENSIONS.KHR_MATERIALS_UNLIT: + extensions[ extensionName ] = new GLTFMaterialsUnlitExtension( json ); + break; + + case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: + extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension(); + break; + + case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION: + extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader ); + break; + + case EXTENSIONS.MSFT_TEXTURE_DDS: + extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] = new GLTFTextureDDSExtension(); + break; + + default: + + if ( extensionsRequired.indexOf( extensionName ) >= 0 ) { + + console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' ); + + } + + } + + } + + } + + var parser = new GLTFParser( json, extensions, { + + path: path || this.resourcePath || '', + crossOrigin: this.crossOrigin, + manager: this.manager + + } ); + + parser.parse( function ( scene, scenes, cameras, animations, json ) { + + var glTF = { + scene: scene, + scenes: scenes, + cameras: cameras, + animations: animations, + asset: json.asset, + parser: parser, + userData: {} + }; + + addUnknownExtensionsToUserData( extensions, glTF, json ); + + onLoad( glTF ); + + }, onError ); + + } + + }; + + /* GLTFREGISTRY */ + + function GLTFRegistry() { + + var objects = {}; + + return { + + get: function ( key ) { + + return objects[ key ]; + + }, + + add: function ( key, object ) { + + objects[ key ] = object; + + }, + + remove: function ( key ) { + + delete objects[ key ]; + + }, + + removeAll: function () { + + objects = {}; + + } + + }; + + } + + /*********************************/ + /********** EXTENSIONS ***********/ + /*********************************/ + + var EXTENSIONS = { + KHR_BINARY_GLTF: 'KHR_binary_glTF', + KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression', + KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual', + KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness', + KHR_MATERIALS_UNLIT: 'KHR_materials_unlit', + MSFT_TEXTURE_DDS: 'MSFT_texture_dds' + }; + + /** + * DDS Texture Extension + * + * Specification: + * https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds + * + */ + function GLTFTextureDDSExtension() { + + if ( ! THREE.DDSLoader ) { + + throw new Error( 'THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader' ); + + } + + this.name = EXTENSIONS.MSFT_TEXTURE_DDS; + this.ddsLoader = new THREE.DDSLoader(); + + } + + /** + * Lights Extension + * + * Specification: PENDING + */ + function GLTFLightsExtension( json ) { + + this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL; + + this.lights = []; + + var extension = ( json.extensions && json.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ] ) || {}; + var lightDefs = extension.lights || []; + + for ( var i = 0; i < lightDefs.length; i ++ ) { + + var lightDef = lightDefs[ i ]; + var lightNode; + + var color = new THREE.Color( 0xffffff ); + if ( lightDef.color !== undefined ) color.fromArray( lightDef.color ); + + var range = lightDef.range !== undefined ? lightDef.range : 0; + + switch ( lightDef.type ) { + + case 'directional': + lightNode = new THREE.DirectionalLight( color ); + lightNode.target.position.set( 0, 0, -1 ); + lightNode.add( lightNode.target ); + break; + + case 'point': + lightNode = new THREE.PointLight( color ); + lightNode.distance = range; + break; + + case 'spot': + lightNode = new THREE.SpotLight( color ); + lightNode.distance = range; + // Handle spotlight properties. + lightDef.spot = lightDef.spot || {}; + lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0; + lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0; + lightNode.angle = lightDef.spot.outerConeAngle; + lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle; + lightNode.target.position.set( 0, 0, -1 ); + lightNode.add( lightNode.target ); + break; + + default: + throw new Error( 'THREE.GLTFLoader: Unexpected light type, "' + lightDef.type + '".' ); + + } + + lightNode.decay = 2; + + if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity; + + lightNode.name = lightDef.name || ( 'light_' + i ); + + this.lights.push( lightNode ); + + } + + } + + /** + * Unlit Materials Extension (pending) + * + * PR: https://github.com/KhronosGroup/glTF/pull/1163 + */ + function GLTFMaterialsUnlitExtension( json ) { + + this.name = EXTENSIONS.KHR_MATERIALS_UNLIT; + + } + + GLTFMaterialsUnlitExtension.prototype.getMaterialType = function ( material ) { + + return THREE.MeshBasicMaterial; + + }; + + GLTFMaterialsUnlitExtension.prototype.extendParams = function ( materialParams, material, parser ) { + + var pending = []; + + materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + var metallicRoughness = material.pbrMetallicRoughness; + + if ( metallicRoughness ) { + + if ( Array.isArray( metallicRoughness.baseColorFactor ) ) { + + var array = metallicRoughness.baseColorFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( metallicRoughness.baseColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture.index ) ); + + } + + } + + return Promise.all( pending ); + + }; + + /* BINARY EXTENSION */ + + var BINARY_EXTENSION_BUFFER_NAME = 'binary_glTF'; + var BINARY_EXTENSION_HEADER_MAGIC = 'glTF'; + var BINARY_EXTENSION_HEADER_LENGTH = 12; + var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 }; + + function GLTFBinaryExtension( data ) { + + this.name = EXTENSIONS.KHR_BINARY_GLTF; + this.content = null; + this.body = null; + + var headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH ); + + this.header = { + magic: THREE.LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ), + version: headerView.getUint32( 4, true ), + length: headerView.getUint32( 8, true ) + }; + + if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) { + + throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' ); + + } else if ( this.header.version < 2.0 ) { + + throw new Error( 'THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.' ); + + } + + var chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH ); + var chunkIndex = 0; + + while ( chunkIndex < chunkView.byteLength ) { + + var chunkLength = chunkView.getUint32( chunkIndex, true ); + chunkIndex += 4; + + var chunkType = chunkView.getUint32( chunkIndex, true ); + chunkIndex += 4; + + if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) { + + var contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength ); + this.content = THREE.LoaderUtils.decodeText( contentArray ); + + } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) { + + var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex; + this.body = data.slice( byteOffset, byteOffset + chunkLength ); + + } + + // Clients must ignore chunks with unknown types. + + chunkIndex += chunkLength; + + } + + if ( this.content === null ) { + + throw new Error( 'THREE.GLTFLoader: JSON content not found.' ); + + } + + } + + /** + * DRACO Mesh Compression Extension + * + * Specification: https://github.com/KhronosGroup/glTF/pull/874 + */ + function GLTFDracoMeshCompressionExtension( json, dracoLoader ) { + + if ( ! dracoLoader ) { + + throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' ); + + } + + this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION; + this.json = json; + this.dracoLoader = dracoLoader; + + } + + GLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function ( primitive, parser ) { + + var json = this.json; + var dracoLoader = this.dracoLoader; + var bufferViewIndex = primitive.extensions[ this.name ].bufferView; + var gltfAttributeMap = primitive.extensions[ this.name ].attributes; + var threeAttributeMap = {}; + var attributeNormalizedMap = {}; + var attributeTypeMap = {}; + + for ( var attributeName in gltfAttributeMap ) { + + if ( ! ( attributeName in ATTRIBUTES ) ) continue; + + threeAttributeMap[ ATTRIBUTES[ attributeName ] ] = gltfAttributeMap[ attributeName ]; + + } + + for ( attributeName in primitive.attributes ) { + + if ( ATTRIBUTES[ attributeName ] !== undefined && gltfAttributeMap[ attributeName ] !== undefined ) { + + var accessorDef = json.accessors[ primitive.attributes[ attributeName ] ]; + var componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; + + attributeTypeMap[ ATTRIBUTES[ attributeName ] ] = componentType; + attributeNormalizedMap[ ATTRIBUTES[ attributeName ] ] = accessorDef.normalized === true; + + } + + } + + return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) { + + return new Promise( function ( resolve ) { + + dracoLoader.decodeDracoFile( bufferView, function ( geometry ) { + + for ( var attributeName in geometry.attributes ) { + + var attribute = geometry.attributes[ attributeName ]; + var normalized = attributeNormalizedMap[ attributeName ]; + + if ( normalized !== undefined ) attribute.normalized = normalized; + + } + + resolve( geometry ); + + }, threeAttributeMap, attributeTypeMap ); + + } ); + + } ); + + }; + + /** + * Specular-Glossiness Extension + * + * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness + */ + function GLTFMaterialsPbrSpecularGlossinessExtension() { + + return { + + name: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS, + + specularGlossinessParams: [ + 'color', + 'map', + 'lightMap', + 'lightMapIntensity', + 'aoMap', + 'aoMapIntensity', + 'emissive', + 'emissiveIntensity', + 'emissiveMap', + 'bumpMap', + 'bumpScale', + 'normalMap', + 'displacementMap', + 'displacementScale', + 'displacementBias', + 'specularMap', + 'specular', + 'glossinessMap', + 'glossiness', + 'alphaMap', + 'envMap', + 'envMapIntensity', + 'refractionRatio', + ], + + getMaterialType: function () { + + return THREE.ShaderMaterial; + + }, + + extendParams: function ( params, material, parser ) { + + var pbrSpecularGlossiness = material.extensions[ this.name ]; + + var shader = THREE.ShaderLib[ 'standard' ]; + + var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + var specularMapParsFragmentChunk = [ + '#ifdef USE_SPECULARMAP', + ' uniform sampler2D specularMap;', + '#endif' + ].join( '\n' ); + + var glossinessMapParsFragmentChunk = [ + '#ifdef USE_GLOSSINESSMAP', + ' uniform sampler2D glossinessMap;', + '#endif' + ].join( '\n' ); + + var specularMapFragmentChunk = [ + 'vec3 specularFactor = specular;', + '#ifdef USE_SPECULARMAP', + ' vec4 texelSpecular = texture2D( specularMap, vUv );', + ' texelSpecular = sRGBToLinear( texelSpecular );', + ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', + ' specularFactor *= texelSpecular.rgb;', + '#endif' + ].join( '\n' ); + + var glossinessMapFragmentChunk = [ + 'float glossinessFactor = glossiness;', + '#ifdef USE_GLOSSINESSMAP', + ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );', + ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', + ' glossinessFactor *= texelGlossiness.a;', + '#endif' + ].join( '\n' ); + + var lightPhysicalFragmentChunk = [ + 'PhysicalMaterial material;', + 'material.diffuseColor = diffuseColor.rgb;', + 'material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );', + 'material.specularColor = specularFactor.rgb;', + ].join( '\n' ); + + var fragmentShader = shader.fragmentShader + .replace( 'uniform float roughness;', 'uniform vec3 specular;' ) + .replace( 'uniform float metalness;', 'uniform float glossiness;' ) + .replace( '#include ', specularMapParsFragmentChunk ) + .replace( '#include ', glossinessMapParsFragmentChunk ) + .replace( '#include ', specularMapFragmentChunk ) + .replace( '#include ', glossinessMapFragmentChunk ) + .replace( '#include ', lightPhysicalFragmentChunk ); + + delete uniforms.roughness; + delete uniforms.metalness; + delete uniforms.roughnessMap; + delete uniforms.metalnessMap; + + uniforms.specular = { value: new THREE.Color().setHex( 0x111111 ) }; + uniforms.glossiness = { value: 0.5 }; + uniforms.specularMap = { value: null }; + uniforms.glossinessMap = { value: null }; + + params.vertexShader = shader.vertexShader; + params.fragmentShader = fragmentShader; + params.uniforms = uniforms; + params.defines = { 'STANDARD': '' }; + + params.color = new THREE.Color( 1.0, 1.0, 1.0 ); + params.opacity = 1.0; + + var pending = []; + + if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) { + + var array = pbrSpecularGlossiness.diffuseFactor; + + params.color.fromArray( array ); + params.opacity = array[ 3 ]; + + } + + if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) { + + pending.push( parser.assignTexture( params, 'map', pbrSpecularGlossiness.diffuseTexture.index ) ); + + } + + params.emissive = new THREE.Color( 0.0, 0.0, 0.0 ); + params.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0; + params.specular = new THREE.Color( 1.0, 1.0, 1.0 ); + + if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) { + + params.specular.fromArray( pbrSpecularGlossiness.specularFactor ); + + } + + if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) { + + var specGlossIndex = pbrSpecularGlossiness.specularGlossinessTexture.index; + pending.push( parser.assignTexture( params, 'glossinessMap', specGlossIndex ) ); + pending.push( parser.assignTexture( params, 'specularMap', specGlossIndex ) ); + + } + + return Promise.all( pending ); + + }, + + createMaterial: function ( params ) { + + // setup material properties based on MeshStandardMaterial for Specular-Glossiness + + var material = new THREE.ShaderMaterial( { + defines: params.defines, + vertexShader: params.vertexShader, + fragmentShader: params.fragmentShader, + uniforms: params.uniforms, + fog: true, + lights: true, + opacity: params.opacity, + transparent: params.transparent + } ); + + material.isGLTFSpecularGlossinessMaterial = true; + + material.color = params.color; + + material.map = params.map === undefined ? null : params.map; + + material.lightMap = null; + material.lightMapIntensity = 1.0; + + material.aoMap = params.aoMap === undefined ? null : params.aoMap; + material.aoMapIntensity = 1.0; + + material.emissive = params.emissive; + material.emissiveIntensity = 1.0; + material.emissiveMap = params.emissiveMap === undefined ? null : params.emissiveMap; + + material.bumpMap = params.bumpMap === undefined ? null : params.bumpMap; + material.bumpScale = 1; + + material.normalMap = params.normalMap === undefined ? null : params.normalMap; + if ( params.normalScale ) material.normalScale = params.normalScale; + + material.displacementMap = null; + material.displacementScale = 1; + material.displacementBias = 0; + + material.specularMap = params.specularMap === undefined ? null : params.specularMap; + material.specular = params.specular; + + material.glossinessMap = params.glossinessMap === undefined ? null : params.glossinessMap; + material.glossiness = params.glossiness; + + material.alphaMap = null; + + material.envMap = params.envMap === undefined ? null : params.envMap; + material.envMapIntensity = 1.0; + + material.refractionRatio = 0.98; + + material.extensions.derivatives = true; + + return material; + + }, + + /** + * Clones a GLTFSpecularGlossinessMaterial instance. The ShaderMaterial.copy() method can + * copy only properties it knows about or inherits, and misses many properties that would + * normally be defined by MeshStandardMaterial. + * + * This method allows GLTFSpecularGlossinessMaterials to be cloned in the process of + * loading a glTF model, but cloning later (e.g. by the user) would require these changes + * AND also updating `.onBeforeRender` on the parent mesh. + * + * @param {THREE.ShaderMaterial} source + * @return {THREE.ShaderMaterial} + */ + cloneMaterial: function ( source ) { + + var target = source.clone(); + + target.isGLTFSpecularGlossinessMaterial = true; + + var params = this.specularGlossinessParams; + + for ( var i = 0, il = params.length; i < il; i ++ ) { + + target[ params[ i ] ] = source[ params[ i ] ]; + + } + + return target; + + }, + + // Here's based on refreshUniformsCommon() and refreshUniformsStandard() in WebGLRenderer. + refreshUniforms: function ( renderer, scene, camera, geometry, material, group ) { + + if ( material.isGLTFSpecularGlossinessMaterial !== true ) { + + return; + + } + + var uniforms = material.uniforms; + var defines = material.defines; + + uniforms.opacity.value = material.opacity; + + uniforms.diffuse.value.copy( material.color ); + uniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity ); + + uniforms.map.value = material.map; + uniforms.specularMap.value = material.specularMap; + uniforms.alphaMap.value = material.alphaMap; + + uniforms.lightMap.value = material.lightMap; + uniforms.lightMapIntensity.value = material.lightMapIntensity; + + uniforms.aoMap.value = material.aoMap; + uniforms.aoMapIntensity.value = material.aoMapIntensity; + + // uv repeat and offset setting priorities + // 1. color map + // 2. specular map + // 3. normal map + // 4. bump map + // 5. alpha map + // 6. emissive map + + var uvScaleMap; + + if ( material.map ) { + + uvScaleMap = material.map; + + } else if ( material.specularMap ) { + + uvScaleMap = material.specularMap; + + } else if ( material.displacementMap ) { + + uvScaleMap = material.displacementMap; + + } else if ( material.normalMap ) { + + uvScaleMap = material.normalMap; + + } else if ( material.bumpMap ) { + + uvScaleMap = material.bumpMap; + + } else if ( material.glossinessMap ) { + + uvScaleMap = material.glossinessMap; + + } else if ( material.alphaMap ) { + + uvScaleMap = material.alphaMap; + + } else if ( material.emissiveMap ) { + + uvScaleMap = material.emissiveMap; + + } + + if ( uvScaleMap !== undefined ) { + + // backwards compatibility + if ( uvScaleMap.isWebGLRenderTarget ) { + + uvScaleMap = uvScaleMap.texture; + + } + + if ( uvScaleMap.matrixAutoUpdate === true ) { + + uvScaleMap.updateMatrix(); + + } + + uniforms.uvTransform.value.copy( uvScaleMap.matrix ); + + } + + uniforms.envMap.value = material.envMap; + uniforms.envMapIntensity.value = material.envMapIntensity; + uniforms.flipEnvMap.value = ( material.envMap && material.envMap.isCubeTexture ) ? - 1 : 1; + + uniforms.refractionRatio.value = material.refractionRatio; + + uniforms.specular.value.copy( material.specular ); + uniforms.glossiness.value = material.glossiness; + + uniforms.glossinessMap.value = material.glossinessMap; + + uniforms.emissiveMap.value = material.emissiveMap; + uniforms.bumpMap.value = material.bumpMap; + uniforms.normalMap.value = material.normalMap; + + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + + if ( uniforms.glossinessMap.value !== null && defines.USE_GLOSSINESSMAP === undefined ) { + + defines.USE_GLOSSINESSMAP = ''; + // set USE_ROUGHNESSMAP to enable vUv + defines.USE_ROUGHNESSMAP = ''; + + } + + if ( uniforms.glossinessMap.value === null && defines.USE_GLOSSINESSMAP !== undefined ) { + + delete defines.USE_GLOSSINESSMAP; + delete defines.USE_ROUGHNESSMAP; + + } + + } + + }; + + } + + /*********************************/ + /********** INTERPOLATION ********/ + /*********************************/ + + // Spline Interpolation + // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation + function GLTFCubicSplineInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) { + + THREE.Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); + + } + + GLTFCubicSplineInterpolant.prototype = Object.create( THREE.Interpolant.prototype ); + GLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant; + + GLTFCubicSplineInterpolant.prototype.copySampleValue_ = function ( index ) { + + // Copies a sample value to the result buffer. See description of glTF + // CUBICSPLINE values layout in interpolate_() function below. + + var result = this.resultBuffer, + values = this.sampleValues, + valueSize = this.valueSize, + offset = index * valueSize * 3 + valueSize; + + for ( var i = 0; i !== valueSize; i ++ ) { + + result[ i ] = values[ offset + i ]; + + } + + return result; + + }; + + GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_; + + GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_; + + GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) { + + var result = this.resultBuffer; + var values = this.sampleValues; + var stride = this.valueSize; + + var stride2 = stride * 2; + var stride3 = stride * 3; + + var td = t1 - t0; + + var p = ( t - t0 ) / td; + var pp = p * p; + var ppp = pp * p; + + var offset1 = i1 * stride3; + var offset0 = offset1 - stride3; + + var s0 = 2 * ppp - 3 * pp + 1; + var s1 = ppp - 2 * pp + p; + var s2 = - 2 * ppp + 3 * pp; + var s3 = ppp - pp; + + // Layout of keyframe output values for CUBICSPLINE animations: + // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ] + for ( var i = 0; i !== stride; i ++ ) { + + var p0 = values[ offset0 + i + stride ]; // splineVertex_k + var m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k) + var p1 = values[ offset1 + i + stride ]; // splineVertex_k+1 + var m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k) + + result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1; + + } + + return result; + + }; + + /*********************************/ + /********** INTERNALS ************/ + /*********************************/ + + /* CONSTANTS */ + + var WEBGL_CONSTANTS = { + FLOAT: 5126, + //FLOAT_MAT2: 35674, + FLOAT_MAT3: 35675, + FLOAT_MAT4: 35676, + FLOAT_VEC2: 35664, + FLOAT_VEC3: 35665, + FLOAT_VEC4: 35666, + LINEAR: 9729, + REPEAT: 10497, + SAMPLER_2D: 35678, + POINTS: 0, + LINES: 1, + LINE_LOOP: 2, + LINE_STRIP: 3, + TRIANGLES: 4, + TRIANGLE_STRIP: 5, + TRIANGLE_FAN: 6, + UNSIGNED_BYTE: 5121, + UNSIGNED_SHORT: 5123 + }; + + var WEBGL_TYPE = { + 5126: Number, + //35674: THREE.Matrix2, + 35675: THREE.Matrix3, + 35676: THREE.Matrix4, + 35664: THREE.Vector2, + 35665: THREE.Vector3, + 35666: THREE.Vector4, + 35678: THREE.Texture + }; + + var WEBGL_COMPONENT_TYPES = { + 5120: Int8Array, + 5121: Uint8Array, + 5122: Int16Array, + 5123: Uint16Array, + 5125: Uint32Array, + 5126: Float32Array + }; + + var WEBGL_FILTERS = { + 9728: THREE.NearestFilter, + 9729: THREE.LinearFilter, + 9984: THREE.NearestMipMapNearestFilter, + 9985: THREE.LinearMipMapNearestFilter, + 9986: THREE.NearestMipMapLinearFilter, + 9987: THREE.LinearMipMapLinearFilter + }; + + var WEBGL_WRAPPINGS = { + 33071: THREE.ClampToEdgeWrapping, + 33648: THREE.MirroredRepeatWrapping, + 10497: THREE.RepeatWrapping + }; + + var WEBGL_SIDES = { + 1028: THREE.BackSide, // Culling front + 1029: THREE.FrontSide // Culling back + //1032: THREE.NoSide // Culling front and back, what to do? + }; + + var WEBGL_DEPTH_FUNCS = { + 512: THREE.NeverDepth, + 513: THREE.LessDepth, + 514: THREE.EqualDepth, + 515: THREE.LessEqualDepth, + 516: THREE.GreaterEqualDepth, + 517: THREE.NotEqualDepth, + 518: THREE.GreaterEqualDepth, + 519: THREE.AlwaysDepth + }; + + var WEBGL_BLEND_EQUATIONS = { + 32774: THREE.AddEquation, + 32778: THREE.SubtractEquation, + 32779: THREE.ReverseSubtractEquation + }; + + var WEBGL_BLEND_FUNCS = { + 0: THREE.ZeroFactor, + 1: THREE.OneFactor, + 768: THREE.SrcColorFactor, + 769: THREE.OneMinusSrcColorFactor, + 770: THREE.SrcAlphaFactor, + 771: THREE.OneMinusSrcAlphaFactor, + 772: THREE.DstAlphaFactor, + 773: THREE.OneMinusDstAlphaFactor, + 774: THREE.DstColorFactor, + 775: THREE.OneMinusDstColorFactor, + 776: THREE.SrcAlphaSaturateFactor + // The followings are not supported by Three.js yet + //32769: CONSTANT_COLOR, + //32770: ONE_MINUS_CONSTANT_COLOR, + //32771: CONSTANT_ALPHA, + //32772: ONE_MINUS_CONSTANT_COLOR + }; + + var WEBGL_TYPE_SIZES = { + 'SCALAR': 1, + 'VEC2': 2, + 'VEC3': 3, + 'VEC4': 4, + 'MAT2': 4, + 'MAT3': 9, + 'MAT4': 16 + }; + + var ATTRIBUTES = { + POSITION: 'position', + NORMAL: 'normal', + TEXCOORD_0: 'uv', + TEXCOORD0: 'uv', // deprecated + TEXCOORD: 'uv', // deprecated + TEXCOORD_1: 'uv2', + COLOR_0: 'color', + COLOR0: 'color', // deprecated + COLOR: 'color', // deprecated + WEIGHTS_0: 'skinWeight', + WEIGHT: 'skinWeight', // deprecated + JOINTS_0: 'skinIndex', + JOINT: 'skinIndex' // deprecated + }; + + var PATH_PROPERTIES = { + scale: 'scale', + translation: 'position', + rotation: 'quaternion', + weights: 'morphTargetInfluences' + }; + + var INTERPOLATION = { + CUBICSPLINE: THREE.InterpolateSmooth, // We use custom interpolation GLTFCubicSplineInterpolation for CUBICSPLINE. + // KeyframeTrack.optimize() can't handle glTF Cubic Spline output values layout, + // using THREE.InterpolateSmooth for KeyframeTrack instantiation to prevent optimization. + // See KeyframeTrack.optimize() for the detail. + LINEAR: THREE.InterpolateLinear, + STEP: THREE.InterpolateDiscrete + }; + + var STATES_ENABLES = { + 2884: 'CULL_FACE', + 2929: 'DEPTH_TEST', + 3042: 'BLEND', + 3089: 'SCISSOR_TEST', + 32823: 'POLYGON_OFFSET_FILL', + 32926: 'SAMPLE_ALPHA_TO_COVERAGE' + }; + + var ALPHA_MODES = { + OPAQUE: 'OPAQUE', + MASK: 'MASK', + BLEND: 'BLEND' + }; + + var MIME_TYPE_FORMATS = { + 'image/png': THREE.RGBAFormat, + 'image/jpeg': THREE.RGBFormat + }; + + /* UTILITY FUNCTIONS */ + + function resolveURL( url, path ) { + + // Invalid URL + if ( typeof url !== 'string' || url === '' ) return ''; + + // Absolute URL http://,https://,// + if ( /^(https?:)?\/\//i.test( url ) ) return url; + + // Data URI + if ( /^data:.*,.*$/i.test( url ) ) return url; + + // Blob URL + if ( /^blob:.*$/i.test( url ) ) return url; + + // Relative URL + return path + url; + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material + */ + function createDefaultMaterial() { + + return new THREE.MeshStandardMaterial( { + color: 0xFFFFFF, + emissive: 0x000000, + metalness: 1, + roughness: 1, + transparent: false, + depthTest: true, + side: THREE.FrontSide + } ); + + } + + function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) { + + // Add unknown glTF extensions to an object's userData. + + for ( var name in objectDef.extensions ) { + + if ( knownExtensions[ name ] === undefined ) { + + object.userData.gltfExtensions = object.userData.gltfExtensions || {}; + object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ]; + + } + + } + + } + + /** + * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry} object + * @param {GLTF.definition} def + */ + function assignExtrasToUserData( object, gltfDef ) { + + if ( gltfDef.extras !== undefined ) { + + if ( typeof gltfDef.extras === 'object' ) { + + object.userData = gltfDef.extras; + + } else { + + console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras ); + + } + + } + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets + * + * @param {THREE.BufferGeometry} geometry + * @param {Array} targets + * @param {Array} accessors + */ + function addMorphTargets( geometry, targets, accessors ) { + + var hasMorphPosition = false; + var hasMorphNormal = false; + + for ( var i = 0, il = targets.length; i < il; i ++ ) { + + var target = targets[ i ]; + + if ( target.POSITION !== undefined ) hasMorphPosition = true; + if ( target.NORMAL !== undefined ) hasMorphNormal = true; + + if ( hasMorphPosition && hasMorphNormal ) break; + + } + + if ( ! hasMorphPosition && ! hasMorphNormal ) return; + + var morphPositions = []; + var morphNormals = []; + + for ( var i = 0, il = targets.length; i < il; i ++ ) { + + var target = targets[ i ]; + var attributeName = 'morphTarget' + i; + + if ( hasMorphPosition ) { + + // Three.js morph position is absolute value. The formula is + // basePosition + // + weight0 * ( morphPosition0 - basePosition ) + // + weight1 * ( morphPosition1 - basePosition ) + // ... + // while the glTF one is relative + // basePosition + // + weight0 * glTFmorphPosition0 + // + weight1 * glTFmorphPosition1 + // ... + // then we need to convert from relative to absolute here. + + if ( target.POSITION !== undefined ) { + + // Cloning not to pollute original accessor + var positionAttribute = cloneBufferAttribute( accessors[ target.POSITION ] ); + positionAttribute.name = attributeName; + + var position = geometry.attributes.position; + + for ( var j = 0, jl = positionAttribute.count; j < jl; j ++ ) { + + positionAttribute.setXYZ( + j, + positionAttribute.getX( j ) + position.getX( j ), + positionAttribute.getY( j ) + position.getY( j ), + positionAttribute.getZ( j ) + position.getZ( j ) + ); + + } + + } else { + + positionAttribute = geometry.attributes.position; + + } + + morphPositions.push( positionAttribute ); + + } + + if ( hasMorphNormal ) { + + // see target.POSITION's comment + + var normalAttribute; + + if ( target.NORMAL !== undefined ) { + + var normalAttribute = cloneBufferAttribute( accessors[ target.NORMAL ] ); + normalAttribute.name = attributeName; + + var normal = geometry.attributes.normal; + + for ( var j = 0, jl = normalAttribute.count; j < jl; j ++ ) { + + normalAttribute.setXYZ( + j, + normalAttribute.getX( j ) + normal.getX( j ), + normalAttribute.getY( j ) + normal.getY( j ), + normalAttribute.getZ( j ) + normal.getZ( j ) + ); + + } + + } else { + + normalAttribute = geometry.attributes.normal; + + } + + morphNormals.push( normalAttribute ); + + } + + } + + if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions; + if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals; + + } + + /** + * @param {THREE.Mesh} mesh + * @param {GLTF.Mesh} meshDef + */ + function updateMorphTargets( mesh, meshDef ) { + + mesh.updateMorphTargets(); + + if ( meshDef.weights !== undefined ) { + + for ( var i = 0, il = meshDef.weights.length; i < il; i ++ ) { + + mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ]; + + } + + } + + // .extras has user-defined data, so check that .extras.targetNames is an array. + if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) { + + var targetNames = meshDef.extras.targetNames; + + if ( mesh.morphTargetInfluences.length === targetNames.length ) { + + mesh.morphTargetDictionary = {}; + + for ( var i = 0, il = targetNames.length; i < il; i ++ ) { + + mesh.morphTargetDictionary[ targetNames[ i ] ] = i; + + } + + } else { + + console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' ); + + } + + } + + } + + function isPrimitiveEqual( a, b ) { + + if ( a.indices !== b.indices ) { + + return false; + + } + + return isObjectEqual( a.attributes, b.attributes ); + + } + + function isObjectEqual( a, b ) { + + if ( Object.keys( a ).length !== Object.keys( b ).length ) return false; + + for ( var key in a ) { + + if ( a[ key ] !== b[ key ] ) return false; + + } + + return true; + + } + + function isArrayEqual( a, b ) { + + if ( a.length !== b.length ) return false; + + for ( var i = 0, il = a.length; i < il; i ++ ) { + + if ( a[ i ] !== b[ i ] ) return false; + + } + + return true; + + } + + function getCachedGeometry( cache, newPrimitive ) { + + for ( var i = 0, il = cache.length; i < il; i ++ ) { + + var cached = cache[ i ]; + + if ( isPrimitiveEqual( cached.primitive, newPrimitive ) ) return cached.promise; + + } + + return null; + + } + + function getCachedCombinedGeometry( cache, geometries ) { + + for ( var i = 0, il = cache.length; i < il; i ++ ) { + + var cached = cache[ i ]; + + if ( isArrayEqual( geometries, cached.baseGeometries ) ) return cached.geometry; + + } + + return null; + + } + + function getCachedMultiPassGeometry( cache, geometry, primitives ) { + + for ( var i = 0, il = cache.length; i < il; i ++ ) { + + var cached = cache[ i ]; + + if ( geometry === cached.baseGeometry && isArrayEqual( primitives, cached.primitives ) ) return cached.geometry; + + } + + return null; + + } + + function cloneBufferAttribute( attribute ) { + + if ( attribute.isInterleavedBufferAttribute ) { + + var count = attribute.count; + var itemSize = attribute.itemSize; + var array = attribute.array.slice( 0, count * itemSize ); + + for ( var i = 0; i < count; ++ i ) { + + array[ i ] = attribute.getX( i ); + if ( itemSize >= 2 ) array[ i + 1 ] = attribute.getY( i ); + if ( itemSize >= 3 ) array[ i + 2 ] = attribute.getZ( i ); + if ( itemSize >= 4 ) array[ i + 3 ] = attribute.getW( i ); + + } + + return new THREE.BufferAttribute( array, itemSize, attribute.normalized ); + + } + + return attribute.clone(); + + } + + /** + * Checks if we can build a single Mesh with MultiMaterial from multiple primitives. + * Returns true if all primitives use the same attributes/morphAttributes/mode + * and also have index. Otherwise returns false. + * + * @param {Array} primitives + * @return {Boolean} + */ + function isMultiPassGeometry( primitives ) { + + if ( primitives.length < 2 ) return false; + + var primitive0 = primitives[ 0 ]; + var targets0 = primitive0.targets || []; + + if ( primitive0.indices === undefined ) return false; + + for ( var i = 1, il = primitives.length; i < il; i ++ ) { + + var primitive = primitives[ i ]; + + if ( primitive0.mode !== primitive.mode ) return false; + if ( primitive.indices === undefined ) return false; + if ( ! isObjectEqual( primitive0.attributes, primitive.attributes ) ) return false; + + var targets = primitive.targets || []; + + if ( targets0.length !== targets.length ) return false; + + for ( var j = 0, jl = targets0.length; j < jl; j ++ ) { + + if ( ! isObjectEqual( targets0[ j ], targets[ j ] ) ) return false; + + } + + } + + return true; + + } + + /* GLTF PARSER */ + + function GLTFParser( json, extensions, options ) { + + this.json = json || {}; + this.extensions = extensions || {}; + this.options = options || {}; + + // loader object cache + this.cache = new GLTFRegistry(); + + // BufferGeometry caching + this.primitiveCache = []; + this.multiplePrimitivesCache = []; + this.multiPassGeometryCache = []; + + this.textureLoader = new THREE.TextureLoader( this.options.manager ); + this.textureLoader.setCrossOrigin( this.options.crossOrigin ); + + this.fileLoader = new THREE.FileLoader( this.options.manager ); + this.fileLoader.setResponseType( 'arraybuffer' ); + + } + + GLTFParser.prototype.parse = function ( onLoad, onError ) { + + var json = this.json; + + // Clear the loader cache + this.cache.removeAll(); + + // Mark the special nodes/meshes in json for efficient parse + this.markDefs(); + + // Fire the callback on complete + this.getMultiDependencies( [ + + 'scene', + 'animation', + 'camera' + + ] ).then( function ( dependencies ) { + + var scenes = dependencies.scenes || []; + var scene = scenes[ json.scene || 0 ]; + var animations = dependencies.animations || []; + var cameras = dependencies.cameras || []; + + onLoad( scene, scenes, cameras, animations, json ); + + } ).catch( onError ); + + }; + + /** + * Marks the special nodes/meshes in json for efficient parse. + */ + GLTFParser.prototype.markDefs = function () { + + var nodeDefs = this.json.nodes || []; + var skinDefs = this.json.skins || []; + var meshDefs = this.json.meshes || []; + + var meshReferences = {}; + var meshUses = {}; + + // Nothing in the node definition indicates whether it is a Bone or an + // Object3D. Use the skins' joint references to mark bones. + for ( var skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) { + + var joints = skinDefs[ skinIndex ].joints; + + for ( var i = 0, il = joints.length; i < il; i ++ ) { + + nodeDefs[ joints[ i ] ].isBone = true; + + } + + } + + // Meshes can (and should) be reused by multiple nodes in a glTF asset. To + // avoid having more than one THREE.Mesh with the same name, count + // references and rename instances below. + // + // Example: CesiumMilkTruck sample model reuses "Wheel" meshes. + for ( var nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) { + + var nodeDef = nodeDefs[ nodeIndex ]; + + if ( nodeDef.mesh !== undefined ) { + + if ( meshReferences[ nodeDef.mesh ] === undefined ) { + + meshReferences[ nodeDef.mesh ] = meshUses[ nodeDef.mesh ] = 0; + + } + + meshReferences[ nodeDef.mesh ] ++; + + // Nothing in the mesh definition indicates whether it is + // a SkinnedMesh or Mesh. Use the node's mesh reference + // to mark SkinnedMesh if node has skin. + if ( nodeDef.skin !== undefined ) { + + meshDefs[ nodeDef.mesh ].isSkinnedMesh = true; + + } + + } + + } + + this.json.meshReferences = meshReferences; + this.json.meshUses = meshUses; + + }; + + /** + * Requests the specified dependency asynchronously, with caching. + * @param {string} type + * @param {number} index + * @return {Promise} + */ + GLTFParser.prototype.getDependency = function ( type, index ) { + + var cacheKey = type + ':' + index; + var dependency = this.cache.get( cacheKey ); + + if ( ! dependency ) { + + switch ( type ) { + + case 'scene': + dependency = this.loadScene( index ); + break; + + case 'node': + dependency = this.loadNode( index ); + break; + + case 'mesh': + dependency = this.loadMesh( index ); + break; + + case 'accessor': + dependency = this.loadAccessor( index ); + break; + + case 'bufferView': + dependency = this.loadBufferView( index ); + break; + + case 'buffer': + dependency = this.loadBuffer( index ); + break; + + case 'material': + dependency = this.loadMaterial( index ); + break; + + case 'texture': + dependency = this.loadTexture( index ); + break; + + case 'skin': + dependency = this.loadSkin( index ); + break; + + case 'animation': + dependency = this.loadAnimation( index ); + break; + + case 'camera': + dependency = this.loadCamera( index ); + break; + + default: + throw new Error( 'Unknown type: ' + type ); + + } + + this.cache.add( cacheKey, dependency ); + + } + + return dependency; + + }; + + /** + * Requests all dependencies of the specified type asynchronously, with caching. + * @param {string} type + * @return {Promise>} + */ + GLTFParser.prototype.getDependencies = function ( type ) { + + var dependencies = this.cache.get( type ); + + if ( ! dependencies ) { + + var parser = this; + var defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || []; + + dependencies = Promise.all( defs.map( function ( def, index ) { + + return parser.getDependency( type, index ); + + } ) ); + + this.cache.add( type, dependencies ); + + } + + return dependencies; + + }; + + /** + * Requests all multiple dependencies of the specified types asynchronously, with caching. + * @param {Array} types + * @return {Promise>>} + */ + GLTFParser.prototype.getMultiDependencies = function ( types ) { + + var results = {}; + var pendings = []; + + for ( var i = 0, il = types.length; i < il; i ++ ) { + + var type = types[ i ]; + var value = this.getDependencies( type ); + + value = value.then( function ( key, value ) { + + results[ key ] = value; + + }.bind( this, type + ( type === 'mesh' ? 'es' : 's' ) ) ); + + pendings.push( value ); + + } + + return Promise.all( pendings ).then( function () { + + return results; + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views + * @param {number} bufferIndex + * @return {Promise} + */ + GLTFParser.prototype.loadBuffer = function ( bufferIndex ) { + + var bufferDef = this.json.buffers[ bufferIndex ]; + var loader = this.fileLoader; + + if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) { + + throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' ); + + } + + // If present, GLB container is required to be the first buffer. + if ( bufferDef.uri === undefined && bufferIndex === 0 ) { + + return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body ); + + } + + var options = this.options; + + return new Promise( function ( resolve, reject ) { + + loader.load( resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () { + + reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) ); + + } ); + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views + * @param {number} bufferViewIndex + * @return {Promise} + */ + GLTFParser.prototype.loadBufferView = function ( bufferViewIndex ) { + + var bufferViewDef = this.json.bufferViews[ bufferViewIndex ]; + + return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) { + + var byteLength = bufferViewDef.byteLength || 0; + var byteOffset = bufferViewDef.byteOffset || 0; + return buffer.slice( byteOffset, byteOffset + byteLength ); + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors + * @param {number} accessorIndex + * @return {Promise} + */ + GLTFParser.prototype.loadAccessor = function ( accessorIndex ) { + + var parser = this; + var json = this.json; + + var accessorDef = this.json.accessors[ accessorIndex ]; + + if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) { + + // Ignore empty accessors, which may be used to declare runtime + // information about attributes coming from another source (e.g. Draco + // compression extension). + return null; + + } + + var pendingBufferViews = []; + + if ( accessorDef.bufferView !== undefined ) { + + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) ); + + } else { + + pendingBufferViews.push( null ); + + } + + if ( accessorDef.sparse !== undefined ) { + + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) ); + pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) ); + + } + + return Promise.all( pendingBufferViews ).then( function ( bufferViews ) { + + var bufferView = bufferViews[ 0 ]; + + var itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ]; + var TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ]; + + // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12. + var elementBytes = TypedArray.BYTES_PER_ELEMENT; + var itemBytes = elementBytes * itemSize; + var byteOffset = accessorDef.byteOffset || 0; + var byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined; + var normalized = accessorDef.normalized === true; + var array, bufferAttribute; + + // The buffer is not interleaved if the stride is the item size in bytes. + if ( byteStride && byteStride !== itemBytes ) { + + var ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType; + var ib = parser.cache.get( ibCacheKey ); + + if ( ! ib ) { + + // Use the full buffer if it's interleaved. + array = new TypedArray( bufferView ); + + // Integer parameters to IB/IBA are in array elements, not bytes. + ib = new THREE.InterleavedBuffer( array, byteStride / elementBytes ); + + parser.cache.add( ibCacheKey, ib ); + + } + + bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, byteOffset / elementBytes, normalized ); + + } else { + + if ( bufferView === null ) { + + array = new TypedArray( accessorDef.count * itemSize ); + + } else { + + array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize ); + + } + + bufferAttribute = new THREE.BufferAttribute( array, itemSize, normalized ); + + } + + // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors + if ( accessorDef.sparse !== undefined ) { + + var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR; + var TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ]; + + var byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0; + var byteOffsetValues = accessorDef.sparse.values.byteOffset || 0; + + var sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices ); + var sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize ); + + if ( bufferView !== null ) { + + // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes. + bufferAttribute.setArray( bufferAttribute.array.slice() ); + + } + + for ( var i = 0, il = sparseIndices.length; i < il; i ++ ) { + + var index = sparseIndices[ i ]; + + bufferAttribute.setX( index, sparseValues[ i * itemSize ] ); + if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] ); + if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] ); + if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] ); + if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.' ); + + } + + } + + return bufferAttribute; + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures + * @param {number} textureIndex + * @return {Promise} + */ + GLTFParser.prototype.loadTexture = function ( textureIndex ) { + + var parser = this; + var json = this.json; + var options = this.options; + var textureLoader = this.textureLoader; + + var URL = window.URL || window.webkitURL; + + var textureDef = json.textures[ textureIndex ]; + + var textureExtensions = textureDef.extensions || {}; + + var source; + + if ( textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] ) { + + source = json.images[ textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].source ]; + + } else { + + source = json.images[ textureDef.source ]; + + } + + var sourceURI = source.uri; + var isObjectURL = false; + + if ( source.bufferView !== undefined ) { + + // Load binary image data from bufferView, if provided. + + sourceURI = parser.getDependency( 'bufferView', source.bufferView ).then( function ( bufferView ) { + + isObjectURL = true; + var blob = new Blob( [ bufferView ], { type: source.mimeType } ); + sourceURI = URL.createObjectURL( blob ); + return sourceURI; + + } ); + + } + + return Promise.resolve( sourceURI ).then( function ( sourceURI ) { + + // Load Texture resource. + + var loader = THREE.Loader.Handlers.get( sourceURI ); + + if ( ! loader ) { + + loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] + ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader + : textureLoader; + + } + + return new Promise( function ( resolve, reject ) { + + loader.load( resolveURL( sourceURI, options.path ), resolve, undefined, reject ); + + } ); + + } ).then( function ( texture ) { + + // Clean up resources and configure Texture. + + if ( isObjectURL === true ) { + + URL.revokeObjectURL( sourceURI ); + + } + + texture.flipY = false; + + if ( textureDef.name !== undefined ) texture.name = textureDef.name; + + // Ignore unknown mime types, like DDS files. + if ( source.mimeType in MIME_TYPE_FORMATS ) { + + texture.format = MIME_TYPE_FORMATS[ source.mimeType ]; + + } + + var samplers = json.samplers || {}; + var sampler = samplers[ textureDef.sampler ] || {}; + + texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter; + texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.LinearMipMapLinearFilter; + texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping; + texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping; + + return texture; + + } ); + + }; + + /** + * Asynchronously assigns a texture to the given material parameters. + * @param {Object} materialParams + * @param {string} textureName + * @param {number} textureIndex + * @return {Promise} + */ + GLTFParser.prototype.assignTexture = function ( materialParams, textureName, textureIndex ) { + + return this.getDependency( 'texture', textureIndex ).then( function ( texture ) { + + materialParams[ textureName ] = texture; + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials + * @param {number} materialIndex + * @return {Promise} + */ + GLTFParser.prototype.loadMaterial = function ( materialIndex ) { + + var parser = this; + var json = this.json; + var extensions = this.extensions; + var materialDef = json.materials[ materialIndex ]; + + var materialType; + var materialParams = {}; + var materialExtensions = materialDef.extensions || {}; + + var pending = []; + + if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) { + + var sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ]; + materialType = sgExtension.getMaterialType( materialDef ); + pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) ); + + } else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) { + + var kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ]; + materialType = kmuExtension.getMaterialType( materialDef ); + pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) ); + + } else { + + // Specification: + // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material + + materialType = THREE.MeshStandardMaterial; + + var metallicRoughness = materialDef.pbrMetallicRoughness || {}; + + materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 ); + materialParams.opacity = 1.0; + + if ( Array.isArray( metallicRoughness.baseColorFactor ) ) { + + var array = metallicRoughness.baseColorFactor; + + materialParams.color.fromArray( array ); + materialParams.opacity = array[ 3 ]; + + } + + if ( metallicRoughness.baseColorTexture !== undefined ) { + + pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture.index ) ); + + } + + materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0; + materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0; + + if ( metallicRoughness.metallicRoughnessTexture !== undefined ) { + + var textureIndex = metallicRoughness.metallicRoughnessTexture.index; + pending.push( parser.assignTexture( materialParams, 'metalnessMap', textureIndex ) ); + pending.push( parser.assignTexture( materialParams, 'roughnessMap', textureIndex ) ); + + } + + } + + if ( materialDef.doubleSided === true ) { + + materialParams.side = THREE.DoubleSide; + + } + + var alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE; + + if ( alphaMode === ALPHA_MODES.BLEND ) { + + materialParams.transparent = true; + + } else { + + materialParams.transparent = false; + + if ( alphaMode === ALPHA_MODES.MASK ) { + + materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5; + + } + + } + + if ( materialDef.normalTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture.index ) ); + + materialParams.normalScale = new THREE.Vector2( 1, 1 ); + + if ( materialDef.normalTexture.scale !== undefined ) { + + materialParams.normalScale.set( materialDef.normalTexture.scale, materialDef.normalTexture.scale ); + + } + + } + + if ( materialDef.occlusionTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture.index ) ); + + if ( materialDef.occlusionTexture.strength !== undefined ) { + + materialParams.aoMapIntensity = materialDef.occlusionTexture.strength; + + } + + } + + if ( materialDef.emissiveFactor !== undefined && materialType !== THREE.MeshBasicMaterial ) { + + materialParams.emissive = new THREE.Color().fromArray( materialDef.emissiveFactor ); + + } + + if ( materialDef.emissiveTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) { + + pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture.index ) ); + + } + + return Promise.all( pending ).then( function () { + + var material; + + if ( materialType === THREE.ShaderMaterial ) { + + material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams ); + + } else { + + material = new materialType( materialParams ); + + } + + if ( materialDef.name !== undefined ) material.name = materialDef.name; + + // Normal map textures use OpenGL conventions: + // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialnormaltexture + if ( material.normalScale ) { + + material.normalScale.y = - material.normalScale.y; + + } + + // baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding. + if ( material.map ) material.map.encoding = THREE.sRGBEncoding; + if ( material.emissiveMap ) material.emissiveMap.encoding = THREE.sRGBEncoding; + if ( material.specularMap ) material.specularMap.encoding = THREE.sRGBEncoding; + + assignExtrasToUserData( material, materialDef ); + + if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef ); + + return material; + + } ); + + }; + + /** + * @param {THREE.BufferGeometry} geometry + * @param {GLTF.Primitive} primitiveDef + * @param {Array} accessors + */ + function addPrimitiveAttributes( geometry, primitiveDef, accessors ) { + + var attributes = primitiveDef.attributes; + + for ( var gltfAttributeName in attributes ) { + + var threeAttributeName = ATTRIBUTES[ gltfAttributeName ]; + var bufferAttribute = accessors[ attributes[ gltfAttributeName ] ]; + + // Skip attributes already provided by e.g. Draco extension. + if ( ! threeAttributeName ) continue; + if ( threeAttributeName in geometry.attributes ) continue; + + geometry.addAttribute( threeAttributeName, bufferAttribute ); + + } + + if ( primitiveDef.indices !== undefined && ! geometry.index ) { + + geometry.setIndex( accessors[ primitiveDef.indices ] ); + + } + + if ( primitiveDef.targets !== undefined ) { + + addMorphTargets( geometry, primitiveDef.targets, accessors ); + + } + + assignExtrasToUserData( geometry, primitiveDef ); + + } + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry + * + * Creates BufferGeometries from primitives. + * If we can build a single BufferGeometry with .groups from multiple primitives, returns one BufferGeometry. + * Otherwise, returns BufferGeometries without .groups as many as primitives. + * + * @param {Array} primitives + * @return {Promise>} + */ + GLTFParser.prototype.loadGeometries = function ( primitives ) { + + var parser = this; + var extensions = this.extensions; + var cache = this.primitiveCache; + + var isMultiPass = isMultiPassGeometry( primitives ); + var originalPrimitives; + + if ( isMultiPass ) { + + originalPrimitives = primitives; // save original primitives and use later + + // We build a single BufferGeometry with .groups from multiple primitives + // because all primitives share the same attributes/morph/mode and have indices. + + primitives = [ primitives[ 0 ] ]; + + // Sets .groups and combined indices to a geometry later in this method. + + } + + return this.getDependencies( 'accessor' ).then( function ( accessors ) { + + var pending = []; + + for ( var i = 0, il = primitives.length; i < il; i ++ ) { + + var primitive = primitives[ i ]; + + // See if we've already created this geometry + var cached = getCachedGeometry( cache, primitive ); + + if ( cached ) { + + // Use the cached geometry if it exists + pending.push( cached ); + + } else if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) { + + // Use DRACO geometry if available + var geometryPromise = extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] + .decodePrimitive( primitive, parser ) + .then( function ( geometry ) { + + addPrimitiveAttributes( geometry, primitive, accessors ); + + return geometry; + + } ); + + cache.push( { primitive: primitive, promise: geometryPromise } ); + + pending.push( geometryPromise ); + + } else { + + // Otherwise create a new geometry + var geometry = new THREE.BufferGeometry(); + + addPrimitiveAttributes( geometry, primitive, accessors ); + + var geometryPromise = Promise.resolve( geometry ); + + // Cache this geometry + cache.push( { primitive: primitive, promise: geometryPromise } ); + + pending.push( geometryPromise ); + + } + + } + + return Promise.all( pending ).then( function ( geometries ) { + + if ( isMultiPass ) { + + var baseGeometry = geometries[ 0 ]; + + // See if we've already created this combined geometry + var cache = parser.multiPassGeometryCache; + var cached = getCachedMultiPassGeometry( cache, baseGeometry, originalPrimitives ); + + if ( cached !== null ) return [ cached.geometry ]; + + // Cloning geometry because of index override. + // Attributes can be reused so cloning by myself here. + var geometry = new THREE.BufferGeometry(); + + geometry.name = baseGeometry.name; + geometry.userData = baseGeometry.userData; + + for ( var key in baseGeometry.attributes ) geometry.addAttribute( key, baseGeometry.attributes[ key ] ); + for ( var key in baseGeometry.morphAttributes ) geometry.morphAttributes[ key ] = baseGeometry.morphAttributes[ key ]; + + var indices = []; + var offset = 0; + + for ( var i = 0, il = originalPrimitives.length; i < il; i ++ ) { + + var accessor = accessors[ originalPrimitives[ i ].indices ]; + + for ( var j = 0, jl = accessor.count; j < jl; j ++ ) indices.push( accessor.array[ j ] ); + + geometry.addGroup( offset, accessor.count, i ); + + offset += accessor.count; + + } + + geometry.setIndex( indices ); + + cache.push( { geometry: geometry, baseGeometry: baseGeometry, primitives: originalPrimitives } ); + + return [ geometry ]; + + } else if ( geometries.length > 1 && THREE.BufferGeometryUtils !== undefined ) { + + // Tries to merge geometries with BufferGeometryUtils if possible + + for ( var i = 1, il = primitives.length; i < il; i ++ ) { + + // can't merge if draw mode is different + if ( primitives[ 0 ].mode !== primitives[ i ].mode ) return geometries; + + } + + // See if we've already created this combined geometry + var cache = parser.multiplePrimitivesCache; + var cached = getCachedCombinedGeometry( cache, geometries ); + + if ( cached ) { + + if ( cached.geometry !== null ) return [ cached.geometry ]; + + } else { + + var geometry = THREE.BufferGeometryUtils.mergeBufferGeometries( geometries, true ); + + cache.push( { geometry: geometry, baseGeometries: geometries } ); + + if ( geometry !== null ) return [ geometry ]; + + } + + } + + return geometries; + + } ); + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes + * @param {number} meshIndex + * @return {Promise} + */ + GLTFParser.prototype.loadMesh = function ( meshIndex ) { + + var scope = this; + var json = this.json; + var extensions = this.extensions; + + var meshDef = json.meshes[ meshIndex ]; + + return this.getMultiDependencies( [ + + 'accessor', + 'material' + + ] ).then( function ( dependencies ) { + + var primitives = meshDef.primitives; + var originalMaterials = []; + + for ( var i = 0, il = primitives.length; i < il; i ++ ) { + + originalMaterials[ i ] = primitives[ i ].material === undefined + ? createDefaultMaterial() + : dependencies.materials[ primitives[ i ].material ]; + + } + + return scope.loadGeometries( primitives ).then( function ( geometries ) { + + var isMultiMaterial = geometries.length === 1 && geometries[ 0 ].groups.length > 0; + + var meshes = []; + + for ( var i = 0, il = geometries.length; i < il; i ++ ) { + + var geometry = geometries[ i ]; + var primitive = primitives[ i ]; + + // 1. create Mesh + + var mesh; + + var material = isMultiMaterial ? originalMaterials : originalMaterials[ i ]; + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || + primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || + primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || + primitive.mode === undefined ) { + + // .isSkinnedMesh isn't in glTF spec. See .markDefs() + mesh = meshDef.isSkinnedMesh === true + ? new THREE.SkinnedMesh( geometry, material ) + : new THREE.Mesh( geometry, material ); + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) { + + mesh.drawMode = THREE.TriangleStripDrawMode; + + } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) { + + mesh.drawMode = THREE.TriangleFanDrawMode; + + } + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) { + + mesh = new THREE.LineSegments( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) { + + mesh = new THREE.Line( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) { + + mesh = new THREE.LineLoop( geometry, material ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) { + + mesh = new THREE.Points( geometry, material ); + + } else { + + throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode ); + + } + + if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) { + + updateMorphTargets( mesh, meshDef ); + + } + + mesh.name = meshDef.name || ( 'mesh_' + meshIndex ); + + if ( geometries.length > 1 ) mesh.name += '_' + i; + + assignExtrasToUserData( mesh, meshDef ); + + meshes.push( mesh ); + + // 2. update Material depending on Mesh and BufferGeometry + + var materials = isMultiMaterial ? mesh.material : [ mesh.material ]; + + var useVertexColors = geometry.attributes.color !== undefined; + var useFlatShading = geometry.attributes.normal === undefined; + var useSkinning = mesh.isSkinnedMesh === true; + var useMorphTargets = Object.keys( geometry.morphAttributes ).length > 0; + var useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== undefined; + + for ( var j = 0, jl = materials.length; j < jl; j ++ ) { + + var material = materials[ j ]; + + if ( mesh.isPoints ) { + + var cacheKey = 'PointsMaterial:' + material.uuid; + + var pointsMaterial = scope.cache.get( cacheKey ); + + if ( ! pointsMaterial ) { + + pointsMaterial = new THREE.PointsMaterial(); + THREE.Material.prototype.copy.call( pointsMaterial, material ); + pointsMaterial.color.copy( material.color ); + pointsMaterial.map = material.map; + pointsMaterial.lights = false; // PointsMaterial doesn't support lights yet + + scope.cache.add( cacheKey, pointsMaterial ); + + } + + material = pointsMaterial; + + } else if ( mesh.isLine ) { + + var cacheKey = 'LineBasicMaterial:' + material.uuid; + + var lineMaterial = scope.cache.get( cacheKey ); + + if ( ! lineMaterial ) { + + lineMaterial = new THREE.LineBasicMaterial(); + THREE.Material.prototype.copy.call( lineMaterial, material ); + lineMaterial.color.copy( material.color ); + lineMaterial.lights = false; // LineBasicMaterial doesn't support lights yet + + scope.cache.add( cacheKey, lineMaterial ); + + } + + material = lineMaterial; + + } + + // Clone the material if it will be modified + if ( useVertexColors || useFlatShading || useSkinning || useMorphTargets ) { + + var cacheKey = 'ClonedMaterial:' + material.uuid + ':'; + + if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:'; + if ( useSkinning ) cacheKey += 'skinning:'; + if ( useVertexColors ) cacheKey += 'vertex-colors:'; + if ( useFlatShading ) cacheKey += 'flat-shading:'; + if ( useMorphTargets ) cacheKey += 'morph-targets:'; + if ( useMorphNormals ) cacheKey += 'morph-normals:'; + + var cachedMaterial = scope.cache.get( cacheKey ); + + if ( ! cachedMaterial ) { + + cachedMaterial = material.isGLTFSpecularGlossinessMaterial + ? extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].cloneMaterial( material ) + : material.clone(); + + if ( useSkinning ) cachedMaterial.skinning = true; + if ( useVertexColors ) cachedMaterial.vertexColors = THREE.VertexColors; + if ( useFlatShading ) cachedMaterial.flatShading = true; + if ( useMorphTargets ) cachedMaterial.morphTargets = true; + if ( useMorphNormals ) cachedMaterial.morphNormals = true; + + scope.cache.add( cacheKey, cachedMaterial ); + + } + + material = cachedMaterial; + + } + + materials[ j ] = material; + + // workarounds for mesh and geometry + + if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) { + + console.log( 'THREE.GLTFLoader: Duplicating UVs to support aoMap.' ); + geometry.addAttribute( 'uv2', new THREE.BufferAttribute( geometry.attributes.uv.array, 2 ) ); + + } + + if ( material.isGLTFSpecularGlossinessMaterial ) { + + // for GLTFSpecularGlossinessMaterial(ShaderMaterial) uniforms runtime update + mesh.onBeforeRender = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].refreshUniforms; + + } + + } + + mesh.material = isMultiMaterial ? materials : materials[ 0 ]; + + } + + if ( meshes.length === 1 ) { + + return meshes[ 0 ]; + + } + + var group = new THREE.Group(); + + for ( var i = 0, il = meshes.length; i < il; i ++ ) { + + group.add( meshes[ i ] ); + + } + + return group; + + } ); + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras + * @param {number} cameraIndex + * @return {Promise} + */ + GLTFParser.prototype.loadCamera = function ( cameraIndex ) { + + var camera; + var cameraDef = this.json.cameras[ cameraIndex ]; + var params = cameraDef[ cameraDef.type ]; + + if ( ! params ) { + + console.warn( 'THREE.GLTFLoader: Missing camera parameters.' ); + return; + + } + + if ( cameraDef.type === 'perspective' ) { + + camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 ); + + } else if ( cameraDef.type === 'orthographic' ) { + + camera = new THREE.OrthographicCamera( params.xmag / - 2, params.xmag / 2, params.ymag / 2, params.ymag / - 2, params.znear, params.zfar ); + + } + + if ( cameraDef.name !== undefined ) camera.name = cameraDef.name; + + assignExtrasToUserData( camera, cameraDef ); + + return Promise.resolve( camera ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins + * @param {number} skinIndex + * @return {Promise} + */ + GLTFParser.prototype.loadSkin = function ( skinIndex ) { + + var skinDef = this.json.skins[ skinIndex ]; + + var skinEntry = { joints: skinDef.joints }; + + if ( skinDef.inverseBindMatrices === undefined ) { + + return Promise.resolve( skinEntry ); + + } + + return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) { + + skinEntry.inverseBindMatrices = accessor; + + return skinEntry; + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations + * @param {number} animationIndex + * @return {Promise} + */ + GLTFParser.prototype.loadAnimation = function ( animationIndex ) { + + var json = this.json; + + var animationDef = json.animations[ animationIndex ]; + + return this.getMultiDependencies( [ + + 'accessor', + 'node' + + ] ).then( function ( dependencies ) { + + var tracks = []; + + for ( var i = 0, il = animationDef.channels.length; i < il; i ++ ) { + + var channel = animationDef.channels[ i ]; + var sampler = animationDef.samplers[ channel.sampler ]; + + if ( sampler ) { + + var target = channel.target; + var name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated. + var input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input; + var output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output; + + var inputAccessor = dependencies.accessors[ input ]; + var outputAccessor = dependencies.accessors[ output ]; + + var node = dependencies.nodes[ name ]; + + if ( node ) { + + node.updateMatrix(); + node.matrixAutoUpdate = true; + + var TypedKeyframeTrack; + + switch ( PATH_PROPERTIES[ target.path ] ) { + + case PATH_PROPERTIES.weights: + + TypedKeyframeTrack = THREE.NumberKeyframeTrack; + break; + + case PATH_PROPERTIES.rotation: + + TypedKeyframeTrack = THREE.QuaternionKeyframeTrack; + break; + + case PATH_PROPERTIES.position: + case PATH_PROPERTIES.scale: + default: + + TypedKeyframeTrack = THREE.VectorKeyframeTrack; + break; + + } + + var targetName = node.name ? node.name : node.uuid; + + var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear; + + var targetNames = []; + + if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) { + + // node can be THREE.Group here but + // PATH_PROPERTIES.weights(morphTargetInfluences) should be + // the property of a mesh object under group. + + node.traverse( function ( object ) { + + if ( object.isMesh === true && object.morphTargetInfluences ) { + + targetNames.push( object.name ? object.name : object.uuid ); + + } + + } ); + + } else { + + targetNames.push( targetName ); + + } + + // KeyframeTrack.optimize() will modify given 'times' and 'values' + // buffers before creating a truncated copy to keep. Because buffers may + // be reused by other tracks, make copies here. + for ( var j = 0, jl = targetNames.length; j < jl; j ++ ) { + + var track = new TypedKeyframeTrack( + targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ], + THREE.AnimationUtils.arraySlice( inputAccessor.array, 0 ), + THREE.AnimationUtils.arraySlice( outputAccessor.array, 0 ), + interpolation + ); + + // Here is the trick to enable custom interpolation. + // Overrides .createInterpolant in a factory method which creates custom interpolation. + if ( sampler.interpolation === 'CUBICSPLINE' ) { + + track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) { + + // A CUBICSPLINE keyframe in glTF has three output values for each input value, + // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize() + // must be divided by three to get the interpolant's sampleSize argument. + + return new GLTFCubicSplineInterpolant( this.times, this.values, this.getValueSize() / 3, result ); + + }; + + // Workaround, provide an alternate way to know if the interpolant type is cubis spline to track. + // track.getInterpolation() doesn't return valid value for custom interpolant. + track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true; + + } + + tracks.push( track ); + + } + + } + + } + + } + + var name = animationDef.name !== undefined ? animationDef.name : 'animation_' + animationIndex; + + return new THREE.AnimationClip( name, undefined, tracks ); + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy + * @param {number} nodeIndex + * @return {Promise} + */ + GLTFParser.prototype.loadNode = function ( nodeIndex ) { + + var json = this.json; + var extensions = this.extensions; + + var meshReferences = json.meshReferences; + var meshUses = json.meshUses; + + var nodeDef = json.nodes[ nodeIndex ]; + + return this.getMultiDependencies( [ + + 'mesh', + 'skin', + 'camera', + 'light' + + ] ).then( function ( dependencies ) { + + var node; + + // .isBone isn't in glTF spec. See .markDefs + if ( nodeDef.isBone === true ) { + + node = new THREE.Bone(); + + } else if ( nodeDef.mesh !== undefined ) { + + var mesh = dependencies.meshes[ nodeDef.mesh ]; + + if ( meshReferences[ nodeDef.mesh ] > 1 ) { + + var instanceNum = meshUses[ nodeDef.mesh ] ++; + + node = mesh.clone(); + node.name += '_instance_' + instanceNum; + + // onBeforeRender copy for Specular-Glossiness + node.onBeforeRender = mesh.onBeforeRender; + + for ( var i = 0, il = node.children.length; i < il; i ++ ) { + + node.children[ i ].name += '_instance_' + instanceNum; + node.children[ i ].onBeforeRender = mesh.children[ i ].onBeforeRender; + + } + + } else { + + node = mesh; + + } + + } else if ( nodeDef.camera !== undefined ) { + + node = dependencies.cameras[ nodeDef.camera ]; + + } else if ( nodeDef.extensions + && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ] + && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light !== undefined ) { + + var lights = extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].lights; + node = lights[ nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light ]; + + } else { + + node = new THREE.Object3D(); + + } + + if ( nodeDef.name !== undefined ) { + + node.name = THREE.PropertyBinding.sanitizeNodeName( nodeDef.name ); + + } + + assignExtrasToUserData( node, nodeDef ); + + if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef ); + + if ( nodeDef.matrix !== undefined ) { + + var matrix = new THREE.Matrix4(); + matrix.fromArray( nodeDef.matrix ); + node.applyMatrix( matrix ); + + } else { + + if ( nodeDef.translation !== undefined ) { + + node.position.fromArray( nodeDef.translation ); + + } + + if ( nodeDef.rotation !== undefined ) { + + node.quaternion.fromArray( nodeDef.rotation ); + + } + + if ( nodeDef.scale !== undefined ) { + + node.scale.fromArray( nodeDef.scale ); + + } + + } + + return node; + + } ); + + }; + + /** + * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes + * @param {number} sceneIndex + * @return {Promise} + */ + GLTFParser.prototype.loadScene = function () { + + // scene node hierachy builder + + function buildNodeHierachy( nodeId, parentObject, json, allNodes, skins ) { + + var node = allNodes[ nodeId ]; + var nodeDef = json.nodes[ nodeId ]; + + // build skeleton here as well + + if ( nodeDef.skin !== undefined ) { + + var meshes = node.isGroup === true ? node.children : [ node ]; + + for ( var i = 0, il = meshes.length; i < il; i ++ ) { + + var mesh = meshes[ i ]; + var skinEntry = skins[ nodeDef.skin ]; + + var bones = []; + var boneInverses = []; + + for ( var j = 0, jl = skinEntry.joints.length; j < jl; j ++ ) { + + var jointId = skinEntry.joints[ j ]; + var jointNode = allNodes[ jointId ]; + + if ( jointNode ) { + + bones.push( jointNode ); + + var mat = new THREE.Matrix4(); + + if ( skinEntry.inverseBindMatrices !== undefined ) { + + mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 ); + + } + + boneInverses.push( mat ); + + } else { + + console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', jointId ); + + } + + } + + mesh.bind( new THREE.Skeleton( bones, boneInverses ), mesh.matrixWorld ); + + } + + } + + // build node hierachy + + parentObject.add( node ); + + if ( nodeDef.children ) { + + var children = nodeDef.children; + + for ( var i = 0, il = children.length; i < il; i ++ ) { + + var child = children[ i ]; + buildNodeHierachy( child, node, json, allNodes, skins ); + + } + + } + + } + + return function loadScene( sceneIndex ) { + + var json = this.json; + var extensions = this.extensions; + var sceneDef = this.json.scenes[ sceneIndex ]; + + return this.getMultiDependencies( [ + + 'node', + 'skin' + + ] ).then( function ( dependencies ) { + + var scene = new THREE.Scene(); + if ( sceneDef.name !== undefined ) scene.name = sceneDef.name; + + assignExtrasToUserData( scene, sceneDef ); + + if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef ); + + var nodeIds = sceneDef.nodes || []; + + for ( var i = 0, il = nodeIds.length; i < il; i ++ ) { + + buildNodeHierachy( nodeIds[ i ], scene, json, dependencies.nodes, dependencies.skins ); + + } + + return scene; + + } ); + + }; + + }(); + + return GLTFLoader; + +} )(); diff --git a/three/jsutil/loaders/HDRCubeTextureLoader.js b/three/jsutil/loaders/HDRCubeTextureLoader.js new file mode 100644 index 000000000..b59591f36 --- /dev/null +++ b/three/jsutil/loaders/HDRCubeTextureLoader.js @@ -0,0 +1,194 @@ +/** +* @author Prashant Sharma / spidersharma03 +* @author Ben Houston / http://clara.io / bhouston +*/ + +THREE.HDRCubeTextureLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + // override in sub classes + this.hdrLoader = new THREE.RGBELoader(); + +}; + +THREE.HDRCubeTextureLoader.prototype.load = function ( type, urls, onLoad, onProgress, onError ) { + + var RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) { + + var e = sourceArray[ sourceOffset + 3 ]; + var scale = Math.pow( 2.0, e - 128.0 ) / 255.0; + + destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale; + destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale; + destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale; + + }; + + var RGBEByteToRGBHalf = ( function () { + + // Source: http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410 + + var floatView = new Float32Array( 1 ); + var int32View = new Int32Array( floatView.buffer ); + + /* This method is faster than the OpenEXR implementation (very often + * used, eg. in Ogre), with the additional benefit of rounding, inspired + * by James Tursa?s half-precision code. */ + function toHalf( val ) { + + floatView[ 0 ] = val; + var x = int32View[ 0 ]; + + var bits = ( x >> 16 ) & 0x8000; /* Get the sign */ + var m = ( x >> 12 ) & 0x07ff; /* Keep one extra bit for rounding */ + var e = ( x >> 23 ) & 0xff; /* Using int is faster here */ + + /* If zero, or denormal, or exponent underflows too much for a denormal + * half, return signed zero. */ + if ( e < 103 ) return bits; + + /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */ + if ( e > 142 ) { + + bits |= 0x7c00; + /* If exponent was 0xff and one mantissa bit was set, it means NaN, + * not Inf, so make sure we set one mantissa bit too. */ + bits |= ( ( e == 255 ) ? 0 : 1 ) && ( x & 0x007fffff ); + return bits; + + } + + /* If exponent underflows but not too much, return a denormal */ + if ( e < 113 ) { + + m |= 0x0800; + /* Extra rounding may overflow and set mantissa to 0 and exponent + * to 1, which is OK. */ + bits |= ( m >> ( 114 - e ) ) + ( ( m >> ( 113 - e ) ) & 1 ); + return bits; + + } + + bits |= ( ( e - 112 ) << 10 ) | ( m >> 1 ); + /* Extra rounding. An overflow will set mantissa to 0 and increment + * the exponent, which is OK. */ + bits += m & 1; + return bits; + + } + + return function ( sourceArray, sourceOffset, destArray, destOffset ) { + + var e = sourceArray[ sourceOffset + 3 ]; + var scale = Math.pow( 2.0, e - 128.0 ) / 255.0; + + destArray[ destOffset + 0 ] = toHalf( sourceArray[ sourceOffset + 0 ] * scale ); + destArray[ destOffset + 1 ] = toHalf( sourceArray[ sourceOffset + 1 ] * scale ); + destArray[ destOffset + 2 ] = toHalf( sourceArray[ sourceOffset + 2 ] * scale ); + + }; + + } )(); + + // + + var texture = new THREE.CubeTexture(); + + texture.type = type; + texture.encoding = ( type === THREE.UnsignedByteType ) ? THREE.RGBEEncoding : THREE.LinearEncoding; + texture.format = ( type === THREE.UnsignedByteType ) ? THREE.RGBAFormat : THREE.RGBFormat; + texture.minFilter = ( texture.encoding === THREE.RGBEEncoding ) ? THREE.NearestFilter : THREE.LinearFilter; + texture.magFilter = ( texture.encoding === THREE.RGBEEncoding ) ? THREE.NearestFilter : THREE.LinearFilter; + texture.generateMipmaps = ( texture.encoding !== THREE.RGBEEncoding ); + texture.anisotropy = 0; + + var scope = this.hdrLoader; + + var loaded = 0; + + function loadHDRData( i, onLoad, onProgress, onError ) { + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( urls[ i ], function ( buffer ) { + + loaded ++; + + var texData = scope._parser( buffer ); + + if ( ! texData ) return; + + if ( type === THREE.FloatType ) { + + var numElements = ( texData.data.length / 4 ) * 3; + var floatdata = new Float32Array( numElements ); + + for ( var j = 0; j < numElements; j ++ ) { + + RGBEByteToRGBFloat( texData.data, j * 4, floatdata, j * 3 ); + + } + + texData.data = floatdata; + + } else if ( type === THREE.HalfFloatType ) { + + var numElements = ( texData.data.length / 4 ) * 3; + var halfdata = new Uint16Array( numElements ); + + for ( var j = 0; j < numElements; j ++ ) { + + RGBEByteToRGBHalf( texData.data, j * 4, halfdata, j * 3 ); + + } + + texData.data = halfdata; + + } + + if ( undefined !== texData.image ) { + + texture[ i ].images = texData.image; + + } else if ( undefined !== texData.data ) { + + var dataTexture = new THREE.DataTexture( texData.data, texData.width, texData.height ); + dataTexture.format = texture.format; + dataTexture.type = texture.type; + dataTexture.encoding = texture.encoding; + dataTexture.minFilter = texture.minFilter; + dataTexture.magFilter = texture.magFilter; + dataTexture.generateMipmaps = texture.generateMipmaps; + + texture.images[ i ] = dataTexture; + + } + + if ( loaded === 6 ) { + + texture.needsUpdate = true; + if ( onLoad ) onLoad( texture ); + + } + + }, onProgress, onError ); + + } + + for ( var i = 0; i < urls.length; i ++ ) { + + loadHDRData( i, onLoad, onProgress, onError ); + + } + + return texture; + +}; + +THREE.HDRCubeTextureLoader.prototype.setPath = function ( value ) { + + this.path = value; + return this; + +}; diff --git a/three/jsutil/loaders/KMZLoader.js b/three/jsutil/loaders/KMZLoader.js new file mode 100644 index 000000000..22e171fc6 --- /dev/null +++ b/three/jsutil/loaders/KMZLoader.js @@ -0,0 +1,112 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.KMZLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.KMZLoader.prototype = { + + constructor: THREE.KMZLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + function findFile( url ) { + + for ( var path in zip.files ) { + + if ( path.substr( - url.length ) === url ) { + + return zip.files[ path ]; + + } + + } + + } + + var manager = new THREE.LoadingManager(); + manager.setURLModifier( function ( url ) { + + var image = findFile( url ); + + if ( image ) { + + console.log( 'Loading', url ); + + var blob = new Blob( [ image.asArrayBuffer() ], { type: 'application/octet-stream' } ); + return URL.createObjectURL( blob ); + + } + + return url; + + } ); + + // + + var zip = new JSZip( data ); // eslint-disable-line no-undef + + if ( zip.files[ 'doc.kml' ] ) { + + var xml = new DOMParser().parseFromString( zip.files[ 'doc.kml' ].asText(), 'application/xml' ); + + var model = xml.querySelector( 'Placemark Model Link href' ); + + if ( model ) { + + var loader = new THREE.ColladaLoader( manager ); + return loader.parse( zip.files[ model.textContent ].asText() ); + + } + + } else { + + console.warn( 'KMZLoader: Missing doc.kml file.' ); + + for ( var path in zip.files ) { + + var extension = path.split( '.' ).pop().toLowerCase(); + + if ( extension === 'dae' ) { + + var loader = new THREE.ColladaLoader( manager ); + return loader.parse( zip.files[ path ].asText() ); + + } + + } + + } + + console.error( 'KMZLoader: Couldn\'t find .dae file.' ); + return { scene: new THREE.Group() }; + + } + +}; diff --git a/three/jsutil/loaders/KTXLoader.js b/three/jsutil/loaders/KTXLoader.js new file mode 100644 index 000000000..541eb5562 --- /dev/null +++ b/three/jsutil/loaders/KTXLoader.js @@ -0,0 +1,174 @@ +/** + * @author amakaseev / https://github.com/amakaseev + * + * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ + * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ + * + * ported from https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.khronosTextureContainer.ts + */ + + +THREE.KTXLoader = function ( manager ) { + + THREE.CompressedTextureLoader.call( this, manager ); + + this._parser = THREE.KTXLoader.parse; + +}; + +THREE.KTXLoader.prototype = Object.create( THREE.CompressedTextureLoader.prototype ); +THREE.KTXLoader.prototype.constructor = THREE.KTXLoader; + +THREE.KTXLoader.parse = function ( buffer, loadMipmaps ) { + + var ktx = new KhronosTextureContainer( buffer, 1 ); + + return { + mipmaps: ktx.mipmaps( loadMipmaps ), + width: ktx.pixelWidth, + height: ktx.pixelHeight, + format: ktx.glInternalFormat, + isCubemap: ktx.numberOfFaces === 6, + mipmapCount: ktx.numberOfMipmapLevels + }; + +}; + +var KhronosTextureContainer = ( function () { + + /** + * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file + * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or + * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented + * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented + */ + function KhronosTextureContainer( arrayBuffer, facesExpected, threeDExpected, textureArrayExpected ) { + + this.arrayBuffer = arrayBuffer; + + // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is: + // '´', 'K', 'T', 'X', ' ', '1', '1', 'ª', '\r', '\n', '\x1A', '\n' + // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A + var identifier = new Uint8Array( this.arrayBuffer, 0, 12 ); + if ( identifier[ 0 ] !== 0xAB || + identifier[ 1 ] !== 0x4B || + identifier[ 2 ] !== 0x54 || + identifier[ 3 ] !== 0x58 || + identifier[ 4 ] !== 0x20 || + identifier[ 5 ] !== 0x31 || + identifier[ 6 ] !== 0x31 || + identifier[ 7 ] !== 0xBB || + identifier[ 8 ] !== 0x0D || + identifier[ 9 ] !== 0x0A || + identifier[ 10 ] !== 0x1A || + identifier[ 11 ] !== 0x0A ) { + + console.error( 'texture missing KTX identifier' ); + return; + + } + + // load the reset of the header in native 32 bit int + var header = new Int32Array( this.arrayBuffer, 12, 13 ); + // determine of the remaining header values are recorded in the opposite endianness & require conversion + var oppositeEndianess = header[ 0 ] === 0x01020304; + // read all the header elements in order they exist in the file, without modification (sans endainness) + this.glType = oppositeEndianess ? this.switchEndainness( header[ 1 ] ) : header[ 1 ]; // must be 0 for compressed textures + this.glTypeSize = oppositeEndianess ? this.switchEndainness( header[ 2 ] ) : header[ 2 ]; // must be 1 for compressed textures + this.glFormat = oppositeEndianess ? this.switchEndainness( header[ 3 ] ) : header[ 3 ]; // must be 0 for compressed textures + this.glInternalFormat = oppositeEndianess ? this.switchEndainness( header[ 4 ] ) : header[ 4 ]; // the value of arg passed to gl.compressedTexImage2D(,,x,,,,) + this.glBaseInternalFormat = oppositeEndianess ? this.switchEndainness( header[ 5 ] ) : header[ 5 ]; // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only) + this.pixelWidth = oppositeEndianess ? this.switchEndainness( header[ 6 ] ) : header[ 6 ]; // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,) + this.pixelHeight = oppositeEndianess ? this.switchEndainness( header[ 7 ] ) : header[ 7 ]; // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,) + this.pixelDepth = oppositeEndianess ? this.switchEndainness( header[ 8 ] ) : header[ 8 ]; // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,) + this.numberOfArrayElements = oppositeEndianess ? this.switchEndainness( header[ 9 ] ) : header[ 9 ]; // used for texture arrays + this.numberOfFaces = oppositeEndianess ? this.switchEndainness( header[ 10 ] ) : header[ 10 ]; // used for cubemap textures, should either be 1 or 6 + this.numberOfMipmapLevels = oppositeEndianess ? this.switchEndainness( header[ 11 ] ) : header[ 11 ]; // number of levels; disregard possibility of 0 for compressed textures + this.bytesOfKeyValueData = oppositeEndianess ? this.switchEndainness( header[ 12 ] ) : header[ 12 ]; // the amount of space after the header for meta-data + + // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing. + if ( this.glType !== 0 ) { + + console.warn( 'only compressed formats currently supported' ); + return; + + } else { + + // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard. + this.numberOfMipmapLevels = Math.max( 1, this.numberOfMipmapLevels ); + + } + if ( this.pixelHeight === 0 || this.pixelDepth !== 0 ) { + + console.warn( 'only 2D textures currently supported' ); + return; + + } + if ( this.numberOfArrayElements !== 0 ) { + + console.warn( 'texture arrays not currently supported' ); + return; + + } + if ( this.numberOfFaces !== facesExpected ) { + + console.warn( 'number of faces expected' + facesExpected + ', but found ' + this.numberOfFaces ); + return; + + } + // we now have a completely validated file, so could use existence of loadType as success + // would need to make this more elaborate & adjust checks above to support more than one load type + this.loadType = KhronosTextureContainer.COMPRESSED_2D; + + } + + // not as fast hardware based, but will probably never need to use + KhronosTextureContainer.prototype.switchEndainness = function ( val ) { + + return ( ( val & 0xFF ) << 24 ) | ( ( val & 0xFF00 ) << 8 ) | ( ( val >> 8 ) & 0xFF00 ) | ( ( val >> 24 ) & 0xFF ); + + }; + + // return mipmaps for THREE.js + KhronosTextureContainer.prototype.mipmaps = function ( loadMipmaps ) { + + var mipmaps = []; + + // initialize width & height for level 1 + var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData; + var width = this.pixelWidth; + var height = this.pixelHeight; + var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1; + + for ( var level = 0; level < mipmapCount; level ++ ) { + + var imageSize = new Int32Array( this.arrayBuffer, dataOffset, 1 )[ 0 ]; // size per face, since not supporting array cubemaps + for ( var face = 0; face < this.numberOfFaces; face ++ ) { + + var byteArray = new Uint8Array( this.arrayBuffer, dataOffset + 4, imageSize ); + + mipmaps.push( { "data": byteArray, "width": width, "height": height } ); + + dataOffset += imageSize + 4; // size of the image + 4 for the imageSize field + dataOffset += 3 - ( ( imageSize + 3 ) % 4 ); // add padding for odd sized image + + } + width = Math.max( 1.0, width * 0.5 ); + height = Math.max( 1.0, height * 0.5 ); + + } + + return mipmaps; + + }; + + KhronosTextureContainer.HEADER_LEN = 12 + ( 13 * 4 ); // identifier + header elements (not including key value meta-data pairs) + // load types + KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D() + KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D() + KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D() + KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D() + + return KhronosTextureContainer; + +}() ); diff --git a/three/jsutil/loaders/LoaderSupport.js b/three/jsutil/loaders/LoaderSupport.js new file mode 100644 index 000000000..f93e02d17 --- /dev/null +++ b/three/jsutil/loaders/LoaderSupport.js @@ -0,0 +1,1545 @@ +/** + * @author Kai Salmen / https://kaisalmen.de + * Development repository: https://github.com/kaisalmen/WWOBJLoader + */ + +'use strict'; + +if ( THREE.LoaderSupport === undefined ) { + + THREE.LoaderSupport = {}; + +} + +/** + * Validation functions. + * @class + */ +THREE.LoaderSupport.Validator = { + /** + * If given input is null or undefined, false is returned otherwise true. + * + * @param input Can be anything + * @returns {boolean} + */ + isValid: function( input ) { + return ( input !== null && input !== undefined ); + }, + /** + * If given input is null or undefined, the defaultValue is returned otherwise the given input. + * + * @param input Can be anything + * @param defaultValue Can be anything + * @returns {*} + */ + verifyInput: function( input, defaultValue ) { + return ( input === null || input === undefined ) ? defaultValue : input; + } +}; + + +/** + * Callbacks utilized by loaders and builders. + * @class + */ +THREE.LoaderSupport.Callbacks = (function () { + + var Validator = THREE.LoaderSupport.Validator; + + function Callbacks() { + this.onProgress = null; + this.onReportError = null; + this.onMeshAlter = null; + this.onLoad = null; + this.onLoadMaterials = null; + } + + /** + * Register callback function that is invoked by internal function "announceProgress" to print feedback. + * @memberOf THREE.LoaderSupport.Callbacks + * + * @param {callback} callbackOnProgress Callback function for described functionality + */ + Callbacks.prototype.setCallbackOnProgress = function ( callbackOnProgress ) { + this.onProgress = Validator.verifyInput( callbackOnProgress, this.onProgress ); + }; + + /** + * Register callback function that is invoked when an error is reported. + * @memberOf THREE.LoaderSupport.Callbacks + * + * @param {callback} callbackOnReportError Callback function for described functionality + */ + Callbacks.prototype.setCallbackOnReportError = function ( callbackOnReportError ) { + this.onReportError = Validator.verifyInput( callbackOnReportError, this.onReportError ); + }; + + /** + * Register callback function that is called every time a mesh was loaded. + * Use {@link THREE.LoaderSupport.LoadedMeshUserOverride} for alteration instructions (geometry, material or disregard mesh). + * @memberOf THREE.LoaderSupport.Callbacks + * + * @param {callback} callbackOnMeshAlter Callback function for described functionality + */ + Callbacks.prototype.setCallbackOnMeshAlter = function ( callbackOnMeshAlter ) { + this.onMeshAlter = Validator.verifyInput( callbackOnMeshAlter, this.onMeshAlter ); + }; + + /** + * Register callback function that is called once loading of the complete OBJ file is completed. + * @memberOf THREE.LoaderSupport.Callbacks + * + * @param {callback} callbackOnLoad Callback function for described functionality + */ + Callbacks.prototype.setCallbackOnLoad = function ( callbackOnLoad ) { + this.onLoad = Validator.verifyInput( callbackOnLoad, this.onLoad ); + }; + + /** + * Register callback function that is called when materials have been loaded. + * @memberOf THREE.LoaderSupport.Callbacks + * + * @param {callback} callbackOnLoadMaterials Callback function for described functionality + */ + Callbacks.prototype.setCallbackOnLoadMaterials = function ( callbackOnLoadMaterials ) { + this.onLoadMaterials = Validator.verifyInput( callbackOnLoadMaterials, this.onLoadMaterials ); + }; + + return Callbacks; +})(); + + +/** + * Object to return by callback onMeshAlter. Used to disregard a certain mesh or to return one to many meshes. + * @class + * + * @param {boolean} disregardMesh=false Tell implementation to completely disregard this mesh + * @param {boolean} disregardMesh=false Tell implementation that mesh(es) have been altered or added + */ +THREE.LoaderSupport.LoadedMeshUserOverride = (function () { + + function LoadedMeshUserOverride( disregardMesh, alteredMesh ) { + this.disregardMesh = disregardMesh === true; + this.alteredMesh = alteredMesh === true; + this.meshes = []; + } + + /** + * Add a mesh created within callback. + * + * @memberOf THREE.OBJLoader2.LoadedMeshUserOverride + * + * @param {THREE.Mesh} mesh + */ + LoadedMeshUserOverride.prototype.addMesh = function ( mesh ) { + this.meshes.push( mesh ); + this.alteredMesh = true; + }; + + /** + * Answers if mesh shall be disregarded completely. + * + * @returns {boolean} + */ + LoadedMeshUserOverride.prototype.isDisregardMesh = function () { + return this.disregardMesh; + }; + + /** + * Answers if new mesh(es) were created. + * + * @returns {boolean} + */ + LoadedMeshUserOverride.prototype.providesAlteredMeshes = function () { + return this.alteredMesh; + }; + + return LoadedMeshUserOverride; +})(); + + +/** + * A resource description used by {@link THREE.LoaderSupport.PrepData} and others. + * @class + * + * @param {string} url URL to the file + * @param {string} extension The file extension (type) + */ +THREE.LoaderSupport.ResourceDescriptor = (function () { + + var Validator = THREE.LoaderSupport.Validator; + + function ResourceDescriptor( url, extension ) { + var urlParts = url.split( '/' ); + + if ( urlParts.length < 2 ) { + + this.path = null; + this.name = url; + this.url = url; + + } else { + + this.path = Validator.verifyInput( urlParts.slice( 0, urlParts.length - 1).join( '/' ) + '/', null ); + this.name = urlParts[ urlParts.length - 1 ]; + this.url = url; + + } + this.name = Validator.verifyInput( this.name, 'Unnamed_Resource' ); + this.extension = Validator.verifyInput( extension, 'default' ); + this.extension = this.extension.trim(); + this.content = null; + } + + /** + * Set the content of this resource + * @memberOf THREE.LoaderSupport.ResourceDescriptor + * + * @param {Object} content The file content as arraybuffer or text + */ + ResourceDescriptor.prototype.setContent = function ( content ) { + this.content = Validator.verifyInput( content, null ); + }; + + return ResourceDescriptor; +})(); + + +/** + * Configuration instructions to be used by run method. + * @class + */ +THREE.LoaderSupport.PrepData = (function () { + + var Validator = THREE.LoaderSupport.Validator; + + function PrepData( modelName ) { + this.logging = { + enabled: true, + debug: false + }; + this.modelName = Validator.verifyInput( modelName, '' ); + this.resources = []; + this.callbacks = new THREE.LoaderSupport.Callbacks(); + } + + /** + * Enable or disable logging in general (except warn and error), plus enable or disable debug logging. + * @memberOf THREE.LoaderSupport.PrepData + * + * @param {boolean} enabled True or false. + * @param {boolean} debug True or false. + */ + PrepData.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + }; + + /** + * Returns all callbacks as {@link THREE.LoaderSupport.Callbacks} + * @memberOf THREE.LoaderSupport.PrepData + * + * @returns {THREE.LoaderSupport.Callbacks} + */ + PrepData.prototype.getCallbacks = function () { + return this.callbacks; + }; + + /** + * Add a resource description. + * @memberOf THREE.LoaderSupport.PrepData + * + * @param {THREE.LoaderSupport.ResourceDescriptor} Adds a {@link THREE.LoaderSupport.ResourceDescriptor} + */ + PrepData.prototype.addResource = function ( resource ) { + this.resources.push( resource ); + }; + + /** + * Clones this object and returns it afterwards. Callbacks and resources are not cloned deep (references!). + * @memberOf THREE.LoaderSupport.PrepData + * + * @returns {@link THREE.LoaderSupport.PrepData} + */ + PrepData.prototype.clone = function () { + var clone = new THREE.LoaderSupport.PrepData( this.modelName ); + clone.logging.enabled = this.logging.enabled; + clone.logging.debug = this.logging.debug; + clone.resources = this.resources; + clone.callbacks = this.callbacks; + + var property, value; + for ( property in this ) { + + value = this[ property ]; + if ( ! clone.hasOwnProperty( property ) && typeof this[ property ] !== 'function' ) { + + clone[ property ] = value; + + } + } + + return clone; + }; + + + /** + * Identify files or content of interest from an Array of {@link THREE.LoaderSupport.ResourceDescriptor}. + * @memberOf THREE.LoaderSupport.PrepData + * + * @param {THREE.LoaderSupport.ResourceDescriptor[]} resources Array of {@link THREE.LoaderSupport.ResourceDescriptor} + * @param Object fileDesc Object describing which resources are of interest (ext, type (string or UInt8Array) and ignore (boolean)) + * @returns {{}} Object with each "ext" and the corresponding {@link THREE.LoaderSupport.ResourceDescriptor} + */ + PrepData.prototype.checkResourceDescriptorFiles = function ( resources, fileDesc ) { + var resource, triple, i, found; + var result = {}; + + for ( var index in resources ) { + + resource = resources[ index ]; + found = false; + if ( ! Validator.isValid( resource.name ) ) continue; + if ( Validator.isValid( resource.content ) ) { + + for ( i = 0; i < fileDesc.length && !found; i++ ) { + + triple = fileDesc[ i ]; + if ( resource.extension.toLowerCase() === triple.ext.toLowerCase() ) { + + if ( triple.ignore ) { + + found = true; + + } else if ( triple.type === "ArrayBuffer" ) { + + // fast-fail on bad type + if ( ! ( resource.content instanceof ArrayBuffer || resource.content instanceof Uint8Array ) ) throw 'Provided content is not of type ArrayBuffer! Aborting...'; + result[ triple.ext ] = resource; + found = true; + + } else if ( triple.type === "String" ) { + + if ( ! ( typeof( resource.content ) === 'string' || resource.content instanceof String) ) throw 'Provided content is not of type String! Aborting...'; + result[ triple.ext ] = resource; + found = true; + + } + + } + + } + if ( !found ) throw 'Unidentified resource "' + resource.name + '": ' + resource.url; + + } else { + + // fast-fail on bad type + if ( ! ( typeof( resource.name ) === 'string' || resource.name instanceof String ) ) throw 'Provided file is not properly defined! Aborting...'; + for ( i = 0; i < fileDesc.length && !found; i++ ) { + + triple = fileDesc[ i ]; + if ( resource.extension.toLowerCase() === triple.ext.toLowerCase() ) { + + if ( ! triple.ignore ) result[ triple.ext ] = resource; + found = true; + + } + + } + if ( !found ) throw 'Unidentified resource "' + resource.name + '": ' + resource.url; + + } + } + + return result; + }; + + return PrepData; +})(); + +/** + * Builds one or many THREE.Mesh from one raw set of Arraybuffers, materialGroup descriptions and further parameters. + * Supports vertex, vertexColor, normal, uv and index buffers. + * @class + */ +THREE.LoaderSupport.MeshBuilder = (function () { + + var LOADER_MESH_BUILDER_VERSION = '1.2.2'; + + var Validator = THREE.LoaderSupport.Validator; + + function MeshBuilder() { + console.info( 'Using THREE.LoaderSupport.MeshBuilder version: ' + LOADER_MESH_BUILDER_VERSION ); + this.logging = { + enabled: true, + debug: false + }; + + this.callbacks = new THREE.LoaderSupport.Callbacks(); + this.materials = []; + } + + /** + * Enable or disable logging in general (except warn and error), plus enable or disable debug logging. + * @memberOf THREE.LoaderSupport.MeshBuilder + * + * @param {boolean} enabled True or false. + * @param {boolean} debug True or false. + */ + MeshBuilder.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + }; + + /** + * Initializes the MeshBuilder (currently only default material initialisation). + * @memberOf THREE.LoaderSupport.MeshBuilder + * + */ + MeshBuilder.prototype.init = function () { + var defaultMaterial = new THREE.MeshStandardMaterial( { color: 0xDCF1FF } ); + defaultMaterial.name = 'defaultMaterial'; + + var defaultVertexColorMaterial = new THREE.MeshStandardMaterial( { color: 0xDCF1FF } ); + defaultVertexColorMaterial.name = 'defaultVertexColorMaterial'; + defaultVertexColorMaterial.vertexColors = THREE.VertexColors; + + var defaultLineMaterial = new THREE.LineBasicMaterial(); + defaultLineMaterial.name = 'defaultLineMaterial'; + + var defaultPointMaterial = new THREE.PointsMaterial( { size: 1 } ); + defaultPointMaterial.name = 'defaultPointMaterial'; + + var runtimeMaterials = {}; + runtimeMaterials[ defaultMaterial.name ] = defaultMaterial; + runtimeMaterials[ defaultVertexColorMaterial.name ] = defaultVertexColorMaterial; + runtimeMaterials[ defaultLineMaterial.name ] = defaultLineMaterial; + runtimeMaterials[ defaultPointMaterial.name ] = defaultPointMaterial; + + this.updateMaterials( + { + cmd: 'materialData', + materials: { + materialCloneInstructions: null, + serializedMaterials: null, + runtimeMaterials: runtimeMaterials + } + } + ); + }; + + /** + * Set materials loaded by any supplier of an Array of {@link THREE.Material}. + * @memberOf THREE.LoaderSupport.MeshBuilder + * + * @param {THREE.Material[]} materials Array of {@link THREE.Material} + */ + MeshBuilder.prototype.setMaterials = function ( materials ) { + var payload = { + cmd: 'materialData', + materials: { + materialCloneInstructions: null, + serializedMaterials: null, + runtimeMaterials: Validator.isValid( this.callbacks.onLoadMaterials ) ? this.callbacks.onLoadMaterials( materials ) : materials + } + }; + this.updateMaterials( payload ); + }; + + MeshBuilder.prototype._setCallbacks = function ( callbacks ) { + if ( Validator.isValid( callbacks.onProgress ) ) this.callbacks.setCallbackOnProgress( callbacks.onProgress ); + if ( Validator.isValid( callbacks.onReportError ) ) this.callbacks.setCallbackOnReportError( callbacks.onReportError ); + if ( Validator.isValid( callbacks.onMeshAlter ) ) this.callbacks.setCallbackOnMeshAlter( callbacks.onMeshAlter ); + if ( Validator.isValid( callbacks.onLoad ) ) this.callbacks.setCallbackOnLoad( callbacks.onLoad ); + if ( Validator.isValid( callbacks.onLoadMaterials ) ) this.callbacks.setCallbackOnLoadMaterials( callbacks.onLoadMaterials ); + }; + + /** + * Delegates processing of the payload (mesh building or material update) to the corresponding functions (BW-compatibility). + * @memberOf THREE.LoaderSupport.MeshBuilder + * + * @param {Object} payload Raw Mesh or Material descriptions. + * @returns {THREE.Mesh[]} mesh Array of {@link THREE.Mesh} or null in case of material update + */ + MeshBuilder.prototype.processPayload = function ( payload ) { + if ( payload.cmd === 'meshData' ) { + + return this.buildMeshes( payload ); + + } else if ( payload.cmd === 'materialData' ) { + + this.updateMaterials( payload ); + return null; + + } + }; + + /** + * Builds one or multiple meshes from the data described in the payload (buffers, params, material info). + * @memberOf THREE.LoaderSupport.MeshBuilder + * + * @param {Object} meshPayload Raw mesh description (buffers, params, materials) used to build one to many meshes. + * @returns {THREE.Mesh[]} mesh Array of {@link THREE.Mesh} + */ + MeshBuilder.prototype.buildMeshes = function ( meshPayload ) { + var meshName = meshPayload.params.meshName; + + var bufferGeometry = new THREE.BufferGeometry(); + bufferGeometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( meshPayload.buffers.vertices ), 3 ) ); + if ( Validator.isValid( meshPayload.buffers.indices ) ) { + + bufferGeometry.setIndex( new THREE.BufferAttribute( new Uint32Array( meshPayload.buffers.indices ), 1 )); + + } + var haveVertexColors = Validator.isValid( meshPayload.buffers.colors ); + if ( haveVertexColors ) { + + bufferGeometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( meshPayload.buffers.colors ), 3 ) ); + + } + if ( Validator.isValid( meshPayload.buffers.normals ) ) { + + bufferGeometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( meshPayload.buffers.normals ), 3 ) ); + + } else { + + bufferGeometry.computeVertexNormals(); + + } + if ( Validator.isValid( meshPayload.buffers.uvs ) ) { + + bufferGeometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( meshPayload.buffers.uvs ), 2 ) ); + + } + + var material, materialName, key; + var materialNames = meshPayload.materials.materialNames; + var createMultiMaterial = meshPayload.materials.multiMaterial; + var multiMaterials = []; + for ( key in materialNames ) { + + materialName = materialNames[ key ]; + material = this.materials[ materialName ]; + if ( createMultiMaterial ) multiMaterials.push( material ); + + } + if ( createMultiMaterial ) { + + material = multiMaterials; + var materialGroups = meshPayload.materials.materialGroups; + var materialGroup; + for ( key in materialGroups ) { + + materialGroup = materialGroups[ key ]; + bufferGeometry.addGroup( materialGroup.start, materialGroup.count, materialGroup.index ); + + } + + } + + var meshes = []; + var mesh; + var callbackOnMeshAlter = this.callbacks.onMeshAlter; + var callbackOnMeshAlterResult; + var useOrgMesh = true; + var geometryType = Validator.verifyInput( meshPayload.geometryType, 0 ); + if ( Validator.isValid( callbackOnMeshAlter ) ) { + + callbackOnMeshAlterResult = callbackOnMeshAlter( + { + detail: { + meshName: meshName, + bufferGeometry: bufferGeometry, + material: material, + geometryType: geometryType + } + } + ); + if ( Validator.isValid( callbackOnMeshAlterResult ) ) { + + if ( callbackOnMeshAlterResult.isDisregardMesh() ) { + + useOrgMesh = false; + + } else if ( callbackOnMeshAlterResult.providesAlteredMeshes() ) { + + for ( var i in callbackOnMeshAlterResult.meshes ) { + + meshes.push( callbackOnMeshAlterResult.meshes[ i ] ); + + } + useOrgMesh = false; + + } + + } + + } + if ( useOrgMesh ) { + + if ( meshPayload.computeBoundingSphere ) bufferGeometry.computeBoundingSphere(); + if ( geometryType === 0 ) { + + mesh = new THREE.Mesh( bufferGeometry, material ); + + } else if ( geometryType === 1) { + + mesh = new THREE.LineSegments( bufferGeometry, material ); + + } else { + + mesh = new THREE.Points( bufferGeometry, material ); + + } + mesh.name = meshName; + meshes.push( mesh ); + + } + + var progressMessage; + if ( Validator.isValid( meshes ) && meshes.length > 0 ) { + + var meshNames = []; + for ( var i in meshes ) { + + mesh = meshes[ i ]; + meshNames[ i ] = mesh.name; + + } + progressMessage = 'Adding mesh(es) (' + meshNames.length + ': ' + meshNames + ') from input mesh: ' + meshName; + progressMessage += ' (' + ( meshPayload.progress.numericalValue * 100 ).toFixed( 2 ) + '%)'; + + } else { + + progressMessage = 'Not adding mesh: ' + meshName; + progressMessage += ' (' + ( meshPayload.progress.numericalValue * 100 ).toFixed( 2 ) + '%)'; + + } + var callbackOnProgress = this.callbacks.onProgress; + if ( Validator.isValid( callbackOnProgress ) ) { + + var event = new CustomEvent( 'MeshBuilderEvent', { + detail: { + type: 'progress', + modelName: meshPayload.params.meshName, + text: progressMessage, + numericalValue: meshPayload.progress.numericalValue + } + } ); + callbackOnProgress( event ); + + } + + return meshes; + }; + + /** + * Updates the materials with contained material objects (sync) or from alteration instructions (async). + * @memberOf THREE.LoaderSupport.MeshBuilder + * + * @param {Object} materialPayload Material update instructions + */ + MeshBuilder.prototype.updateMaterials = function ( materialPayload ) { + var material, materialName; + var materialCloneInstructions = materialPayload.materials.materialCloneInstructions; + if ( Validator.isValid( materialCloneInstructions ) ) { + + var materialNameOrg = materialCloneInstructions.materialNameOrg; + var materialOrg = this.materials[ materialNameOrg ]; + + if ( Validator.isValid( materialNameOrg ) ) { + + material = materialOrg.clone(); + + materialName = materialCloneInstructions.materialName; + material.name = materialName; + + var materialProperties = materialCloneInstructions.materialProperties; + for ( var key in materialProperties ) { + + if ( material.hasOwnProperty( key ) && materialProperties.hasOwnProperty( key ) ) material[ key ] = materialProperties[ key ]; + + } + this.materials[ materialName ] = material; + + } else { + + console.warn( 'Requested material "' + materialNameOrg + '" is not available!' ); + + } + } + + var materials = materialPayload.materials.serializedMaterials; + if ( Validator.isValid( materials ) && Object.keys( materials ).length > 0 ) { + + var loader = new THREE.MaterialLoader(); + var materialJson; + for ( materialName in materials ) { + + materialJson = materials[ materialName ]; + if ( Validator.isValid( materialJson ) ) { + + material = loader.parse( materialJson ); + if ( this.logging.enabled ) console.info( 'De-serialized material with name "' + materialName + '" will be added.' ); + this.materials[ materialName ] = material; + } + + } + + } + + materials = materialPayload.materials.runtimeMaterials; + if ( Validator.isValid( materials ) && Object.keys( materials ).length > 0 ) { + + for ( materialName in materials ) { + + material = materials[ materialName ]; + if ( this.logging.enabled ) console.info( 'Material with name "' + materialName + '" will be added.' ); + this.materials[ materialName ] = material; + + } + + } + }; + + /** + * Returns the mapping object of material name and corresponding jsonified material. + * + * @returns {Object} Map of Materials in JSON representation + */ + MeshBuilder.prototype.getMaterialsJSON = function () { + var materialsJSON = {}; + var material; + for ( var materialName in this.materials ) { + + material = this.materials[ materialName ]; + materialsJSON[ materialName ] = material.toJSON(); + } + + return materialsJSON; + }; + + /** + * Returns the mapping object of material name and corresponding material. + * + * @returns {Object} Map of {@link THREE.Material} + */ + MeshBuilder.prototype.getMaterials = function () { + return this.materials; + }; + + return MeshBuilder; +})(); + +/** + * Default implementation of the WorkerRunner responsible for creation and configuration of the parser within the worker. + * + * @class + */ +THREE.LoaderSupport.WorkerRunnerRefImpl = (function () { + + function WorkerRunnerRefImpl() { + var scope = this; + var scopedRunner = function( event ) { + scope.processMessage( event.data ); + }; + self.addEventListener( 'message', scopedRunner, false ); + } + + /** + * Applies values from parameter object via set functions or via direct assignment. + * @memberOf THREE.LoaderSupport.WorkerRunnerRefImpl + * + * @param {Object} parser The parser instance + * @param {Object} params The parameter object + */ + WorkerRunnerRefImpl.prototype.applyProperties = function ( parser, params ) { + var property, funcName, values; + for ( property in params ) { + funcName = 'set' + property.substring( 0, 1 ).toLocaleUpperCase() + property.substring( 1 ); + values = params[ property ]; + + if ( typeof parser[ funcName ] === 'function' ) { + + parser[ funcName ]( values ); + + } else if ( parser.hasOwnProperty( property ) ) { + + parser[ property ] = values; + + } + } + }; + + /** + * Configures the Parser implementation according the supplied configuration object. + * @memberOf THREE.LoaderSupport.WorkerRunnerRefImpl + * + * @param {Object} payload Raw mesh description (buffers, params, materials) used to build one to many meshes. + */ + WorkerRunnerRefImpl.prototype.processMessage = function ( payload ) { + if ( payload.cmd === 'run' ) { + + var callbacks = { + callbackMeshBuilder: function ( payload ) { + self.postMessage( payload ); + }, + callbackProgress: function ( text ) { + if ( payload.logging.enabled && payload.logging.debug ) console.debug( 'WorkerRunner: progress: ' + text ); + } + }; + + // Parser is expected to be named as such + var parser = new Parser(); + if ( typeof parser[ 'setLogging' ] === 'function' ) parser.setLogging( payload.logging.enabled, payload.logging.debug ); + this.applyProperties( parser, payload.params ); + this.applyProperties( parser, payload.materials ); + this.applyProperties( parser, callbacks ); + parser.workerScope = self; + parser.parse( payload.data.input, payload.data.options ); + + if ( payload.logging.enabled ) console.log( 'WorkerRunner: Run complete!' ); + + callbacks.callbackMeshBuilder( { + cmd: 'complete', + msg: 'WorkerRunner completed run.' + } ); + + } else { + + console.error( 'WorkerRunner: Received unknown command: ' + payload.cmd ); + + } + }; + + return WorkerRunnerRefImpl; +})(); + +/** + * This class provides means to transform existing parser code into a web worker. It defines a simple communication protocol + * which allows to configure the worker and receive raw mesh data during execution. + * @class + */ +THREE.LoaderSupport.WorkerSupport = (function () { + + var WORKER_SUPPORT_VERSION = '2.2.1'; + + var Validator = THREE.LoaderSupport.Validator; + + var LoaderWorker = (function () { + + function LoaderWorker() { + this._reset(); + } + + LoaderWorker.prototype._reset = function () { + this.logging = { + enabled: true, + debug: false + }; + this.worker = null; + this.runnerImplName = null; + this.callbacks = { + meshBuilder: null, + onLoad: null + }; + this.terminateRequested = false; + this.queuedMessage = null; + this.started = false; + this.forceCopy = false; + }; + + LoaderWorker.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + }; + + LoaderWorker.prototype.setForceCopy = function ( forceCopy ) { + this.forceCopy = forceCopy === true; + }; + + LoaderWorker.prototype.initWorker = function ( code, runnerImplName ) { + this.runnerImplName = runnerImplName; + var blob = new Blob( [ code ], { type: 'application/javascript' } ); + this.worker = new Worker( window.URL.createObjectURL( blob ) ); + this.worker.onmessage = this._receiveWorkerMessage; + + // set referemce to this, then processing in worker scope within "_receiveWorkerMessage" can access members + this.worker.runtimeRef = this; + + // process stored queuedMessage + this._postMessage(); + }; + + /** + * Executed in worker scope + */ + LoaderWorker.prototype._receiveWorkerMessage = function ( e ) { + var payload = e.data; + switch ( payload.cmd ) { + case 'meshData': + case 'materialData': + case 'imageData': + this.runtimeRef.callbacks.meshBuilder( payload ); + break; + + case 'complete': + this.runtimeRef.queuedMessage = null; + this.started = false; + this.runtimeRef.callbacks.onLoad( payload.msg ); + + if ( this.runtimeRef.terminateRequested ) { + + if ( this.runtimeRef.logging.enabled ) console.info( 'WorkerSupport [' + this.runtimeRef.runnerImplName + ']: Run is complete. Terminating application on request!' ); + this.runtimeRef._terminate(); + + } + break; + + case 'error': + console.error( 'WorkerSupport [' + this.runtimeRef.runnerImplName + ']: Reported error: ' + payload.msg ); + this.runtimeRef.queuedMessage = null; + this.started = false; + this.runtimeRef.callbacks.onLoad( payload.msg ); + + if ( this.runtimeRef.terminateRequested ) { + + if ( this.runtimeRef.logging.enabled ) console.info( 'WorkerSupport [' + this.runtimeRef.runnerImplName + ']: Run reported error. Terminating application on request!' ); + this.runtimeRef._terminate(); + + } + break; + + default: + console.error( 'WorkerSupport [' + this.runtimeRef.runnerImplName + ']: Received unknown command: ' + payload.cmd ); + break; + + } + }; + + LoaderWorker.prototype.setCallbacks = function ( meshBuilder, onLoad ) { + this.callbacks.meshBuilder = Validator.verifyInput( meshBuilder, this.callbacks.meshBuilder ); + this.callbacks.onLoad = Validator.verifyInput( onLoad, this.callbacks.onLoad ); + }; + + LoaderWorker.prototype.run = function( payload ) { + if ( Validator.isValid( this.queuedMessage ) ) { + + console.warn( 'Already processing message. Rejecting new run instruction' ); + return; + + } else { + + this.queuedMessage = payload; + this.started = true; + + } + if ( ! Validator.isValid( this.callbacks.meshBuilder ) ) throw 'Unable to run as no "MeshBuilder" callback is set.'; + if ( ! Validator.isValid( this.callbacks.onLoad ) ) throw 'Unable to run as no "onLoad" callback is set.'; + if ( payload.cmd !== 'run' ) payload.cmd = 'run'; + if ( Validator.isValid( payload.logging ) ) { + + payload.logging.enabled = payload.logging.enabled === true; + payload.logging.debug = payload.logging.debug === true; + + } else { + + payload.logging = { + enabled: true, + debug: false + }; + + } + this._postMessage(); + }; + + LoaderWorker.prototype._postMessage = function () { + if ( Validator.isValid( this.queuedMessage ) && Validator.isValid( this.worker ) ) { + + if ( this.queuedMessage.data.input instanceof ArrayBuffer ) { + + var content; + if ( this.forceCopy ) { + + content = this.queuedMessage.data.input.slice( 0 ); + + } else { + + content = this.queuedMessage.data.input; + + } + this.worker.postMessage( this.queuedMessage, [ content ] ); + + } else { + + this.worker.postMessage( this.queuedMessage ); + + } + + } + }; + + LoaderWorker.prototype.setTerminateRequested = function ( terminateRequested ) { + this.terminateRequested = terminateRequested === true; + if ( this.terminateRequested && Validator.isValid( this.worker ) && ! Validator.isValid( this.queuedMessage ) && this.started ) { + + if ( this.logging.enabled ) console.info( 'Worker is terminated immediately as it is not running!' ); + this._terminate(); + + } + }; + + LoaderWorker.prototype._terminate = function () { + this.worker.terminate(); + this._reset(); + }; + + return LoaderWorker; + + })(); + + function WorkerSupport() { + console.info( 'Using THREE.LoaderSupport.WorkerSupport version: ' + WORKER_SUPPORT_VERSION ); + this.logging = { + enabled: true, + debug: false + }; + + // check worker support first + if ( window.Worker === undefined ) throw "This browser does not support web workers!"; + if ( window.Blob === undefined ) throw "This browser does not support Blob!"; + if ( typeof window.URL.createObjectURL !== 'function' ) throw "This browser does not support Object creation from URL!"; + + this.loaderWorker = new LoaderWorker(); + } + + /** + * Enable or disable logging in general (except warn and error), plus enable or disable debug logging. + * @memberOf THREE.LoaderSupport.WorkerSupport + * + * @param {boolean} enabled True or false. + * @param {boolean} debug True or false. + */ + WorkerSupport.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + this.loaderWorker.setLogging( this.logging.enabled, this.logging.debug ); + }; + + /** + * Forces all ArrayBuffers to be transferred to worker to be copied. + * @memberOf THREE.LoaderSupport.WorkerSupport + * + * @param {boolean} forceWorkerDataCopy True or false. + */ + WorkerSupport.prototype.setForceWorkerDataCopy = function ( forceWorkerDataCopy ) { + this.loaderWorker.setForceCopy( forceWorkerDataCopy ); + }; + + /** + * Validate the status of worker code and the derived worker. + * @memberOf THREE.LoaderSupport.WorkerSupport + * + * @param {Function} functionCodeBuilder Function that is invoked with funcBuildObject and funcBuildSingleton that allows stringification of objects and singletons. + * @param {String} parserName Name of the Parser object + * @param {String[]} libLocations URL of libraries that shall be added to worker code relative to libPath + * @param {String} libPath Base path used for loading libraries + * @param {THREE.LoaderSupport.WorkerRunnerRefImpl} runnerImpl The default worker parser wrapper implementation (communication and execution). An extended class could be passed here. + */ + WorkerSupport.prototype.validate = function ( functionCodeBuilder, parserName, libLocations, libPath, runnerImpl ) { + if ( Validator.isValid( this.loaderWorker.worker ) ) return; + + if ( this.logging.enabled ) { + + console.info( 'WorkerSupport: Building worker code...' ); + console.time( 'buildWebWorkerCode' ); + + } + if ( Validator.isValid( runnerImpl ) ) { + + if ( this.logging.enabled ) console.info( 'WorkerSupport: Using "' + runnerImpl.name + '" as Runner class for worker.' ); + + } else { + + runnerImpl = THREE.LoaderSupport.WorkerRunnerRefImpl; + if ( this.logging.enabled ) console.info( 'WorkerSupport: Using DEFAULT "THREE.LoaderSupport.WorkerRunnerRefImpl" as Runner class for worker.' ); + + } + + var userWorkerCode = functionCodeBuilder( buildObject, buildSingleton ); + userWorkerCode += 'var Parser = '+ parserName + ';\n\n'; + userWorkerCode += buildSingleton( runnerImpl.name, runnerImpl ); + userWorkerCode += 'new ' + runnerImpl.name + '();\n\n'; + + var scope = this; + if ( Validator.isValid( libLocations ) && libLocations.length > 0 ) { + + var libsContent = ''; + var loadAllLibraries = function ( path, locations ) { + if ( locations.length === 0 ) { + + scope.loaderWorker.initWorker( libsContent + userWorkerCode, runnerImpl.name ); + if ( scope.logging.enabled ) console.timeEnd( 'buildWebWorkerCode' ); + + } else { + + var loadedLib = function ( contentAsString ) { + libsContent += contentAsString; + loadAllLibraries( path, locations ); + }; + + var fileLoader = new THREE.FileLoader(); + fileLoader.setPath( path ); + fileLoader.setResponseType( 'text' ); + fileLoader.load( locations[ 0 ], loadedLib ); + locations.shift(); + + } + }; + loadAllLibraries( libPath, libLocations ); + + } else { + + this.loaderWorker.initWorker( userWorkerCode, runnerImpl.name ); + if ( this.logging.enabled ) console.timeEnd( 'buildWebWorkerCode' ); + + } + }; + + /** + * Specify functions that should be build when new raw mesh data becomes available and when the parser is finished. + * @memberOf THREE.LoaderSupport.WorkerSupport + * + * @param {Function} meshBuilder The mesh builder function. Default is {@link THREE.LoaderSupport.MeshBuilder}. + * @param {Function} onLoad The function that is called when parsing is complete. + */ + WorkerSupport.prototype.setCallbacks = function ( meshBuilder, onLoad ) { + this.loaderWorker.setCallbacks( meshBuilder, onLoad ); + }; + + /** + * Runs the parser with the provided configuration. + * @memberOf THREE.LoaderSupport.WorkerSupport + * + * @param {Object} payload Raw mesh description (buffers, params, materials) used to build one to many meshes. + */ + WorkerSupport.prototype.run = function ( payload ) { + this.loaderWorker.run( payload ); + }; + + /** + * Request termination of worker once parser is finished. + * @memberOf THREE.LoaderSupport.WorkerSupport + * + * @param {boolean} terminateRequested True or false. + */ + WorkerSupport.prototype.setTerminateRequested = function ( terminateRequested ) { + this.loaderWorker.setTerminateRequested( terminateRequested ); + }; + + var buildObject = function ( fullName, object ) { + var objectString = fullName + ' = {\n'; + var part; + for ( var name in object ) { + + part = object[ name ]; + if ( typeof( part ) === 'string' || part instanceof String ) { + + part = part.replace( '\n', '\\n' ); + part = part.replace( '\r', '\\r' ); + objectString += '\t' + name + ': "' + part + '",\n'; + + } else if ( part instanceof Array ) { + + objectString += '\t' + name + ': [' + part + '],\n'; + + } else if ( Number.isInteger( part ) ) { + + objectString += '\t' + name + ': ' + part + ',\n'; + + } else if ( typeof part === 'function' ) { + + objectString += '\t' + name + ': ' + part + ',\n'; + + } + + } + objectString += '}\n\n'; + + return objectString; + }; + + var buildSingleton = function ( fullName, object, internalName, basePrototypeName, ignoreFunctions ) { + var objectString = ''; + var objectName = ( Validator.isValid( internalName ) ) ? internalName : object.name; + + var funcString, objectPart, constructorString; + ignoreFunctions = Validator.verifyInput( ignoreFunctions, [] ); + for ( var name in object.prototype ) { + + objectPart = object.prototype[ name ]; + if ( name === 'constructor' ) { + + funcString = objectPart.toString(); + funcString = funcString.replace( 'function', '' ); + constructorString = '\tfunction ' + objectName + funcString + ';\n\n'; + + } else if ( typeof objectPart === 'function' ) { + + if ( ignoreFunctions.indexOf( name ) < 0 ) { + + funcString = objectPart.toString(); + objectString += '\t' + objectName + '.prototype.' + name + ' = ' + funcString + ';\n\n'; + + } + + } + + } + objectString += '\treturn ' + objectName + ';\n'; + objectString += '})();\n\n'; + + var inheritanceBlock = ''; + if ( Validator.isValid( basePrototypeName ) ) { + + inheritanceBlock += '\n'; + inheritanceBlock += objectName + '.prototype = Object.create( ' + basePrototypeName + '.prototype );\n'; + inheritanceBlock += objectName + '.constructor = ' + objectName + ';\n'; + inheritanceBlock += '\n'; + } + if ( ! Validator.isValid( constructorString ) ) { + + constructorString = fullName + ' = (function () {\n\n'; + constructorString += inheritanceBlock + '\t' + object.prototype.constructor.toString() + '\n\n'; + objectString = constructorString + objectString; + + } else { + + objectString = fullName + ' = (function () {\n\n' + inheritanceBlock + constructorString + objectString; + + } + + return objectString; + }; + + return WorkerSupport; + +})(); + +/** + * Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16). + * Workflow: + * prepareWorkers + * enqueueForRun + * processQueue + * tearDown (to force stop) + * + * @class + * + * @param {string} classDef Class definition to be used for construction + */ +THREE.LoaderSupport.WorkerDirector = (function () { + + var LOADER_WORKER_DIRECTOR_VERSION = '2.2.2'; + + var Validator = THREE.LoaderSupport.Validator; + + var MAX_WEB_WORKER = 16; + var MAX_QUEUE_SIZE = 8192; + + function WorkerDirector( classDef ) { + console.info( 'Using THREE.LoaderSupport.WorkerDirector version: ' + LOADER_WORKER_DIRECTOR_VERSION ); + this.logging = { + enabled: true, + debug: false + }; + + this.maxQueueSize = MAX_QUEUE_SIZE ; + this.maxWebWorkers = MAX_WEB_WORKER; + this.crossOrigin = null; + + if ( ! Validator.isValid( classDef ) ) throw 'Provided invalid classDef: ' + classDef; + + this.workerDescription = { + classDef: classDef, + globalCallbacks: {}, + workerSupports: {}, + forceWorkerDataCopy: true + }; + this.objectsCompleted = 0; + this.instructionQueue = []; + this.instructionQueuePointer = 0; + + this.callbackOnFinishedProcessing = null; + } + + /** + * Enable or disable logging in general (except warn and error), plus enable or disable debug logging. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @param {boolean} enabled True or false. + * @param {boolean} debug True or false. + */ + WorkerDirector.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + }; + + /** + * Returns the maximum length of the instruction queue. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @returns {number} + */ + WorkerDirector.prototype.getMaxQueueSize = function () { + return this.maxQueueSize; + }; + + /** + * Returns the maximum number of workers. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @returns {number} + */ + WorkerDirector.prototype.getMaxWebWorkers = function () { + return this.maxWebWorkers; + }; + + /** + * Sets the CORS string to be used. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @param {string} crossOrigin CORS value + */ + WorkerDirector.prototype.setCrossOrigin = function ( crossOrigin ) { + this.crossOrigin = crossOrigin; + }; + + /** + * Forces all ArrayBuffers to be transferred to worker to be copied. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @param {boolean} forceWorkerDataCopy True or false. + */ + WorkerDirector.prototype.setForceWorkerDataCopy = function ( forceWorkerDataCopy ) { + this.workerDescription.forceWorkerDataCopy = forceWorkerDataCopy === true; + }; + + /** + * Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @param {THREE.OBJLoader2.WWOBJLoader2.PrepDataCallbacks} globalCallbacks Register global callbacks used by all web workers + * @param {number} maxQueueSize Set the maximum size of the instruction queue (1-1024) + * @param {number} maxWebWorkers Set the maximum amount of workers (1-16) + */ + WorkerDirector.prototype.prepareWorkers = function ( globalCallbacks, maxQueueSize, maxWebWorkers ) { + if ( Validator.isValid( globalCallbacks ) ) this.workerDescription.globalCallbacks = globalCallbacks; + this.maxQueueSize = Math.min( maxQueueSize, MAX_QUEUE_SIZE ); + this.maxWebWorkers = Math.min( maxWebWorkers, MAX_WEB_WORKER ); + this.maxWebWorkers = Math.min( this.maxWebWorkers, this.maxQueueSize ); + this.objectsCompleted = 0; + this.instructionQueue = []; + this.instructionQueuePointer = 0; + + for ( var instanceNo = 0; instanceNo < this.maxWebWorkers; instanceNo++ ) { + + var workerSupport = new THREE.LoaderSupport.WorkerSupport(); + workerSupport.setLogging( this.logging.enabled, this.logging.debug ); + workerSupport.setForceWorkerDataCopy( this.workerDescription.forceWorkerDataCopy ); + this.workerDescription.workerSupports[ instanceNo ] = { + instanceNo: instanceNo, + inUse: false, + terminateRequested: false, + workerSupport: workerSupport, + loader: null + }; + + } + }; + + /** + * Store run instructions in internal instructionQueue. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @param {THREE.LoaderSupport.PrepData} prepData + */ + WorkerDirector.prototype.enqueueForRun = function ( prepData ) { + if ( this.instructionQueue.length < this.maxQueueSize ) { + this.instructionQueue.push( prepData ); + } + }; + + /** + * Returns if any workers are running. + * + * @memberOf THREE.LoaderSupport.WorkerDirector + * @returns {boolean} + */ + WorkerDirector.prototype.isRunning = function () { + var wsKeys = Object.keys( this.workerDescription.workerSupports ); + return ( ( this.instructionQueue.length > 0 && this.instructionQueuePointer < this.instructionQueue.length ) || wsKeys.length > 0 ); + }; + + /** + * Process the instructionQueue until it is depleted. + * @memberOf THREE.LoaderSupport.WorkerDirector + */ + WorkerDirector.prototype.processQueue = function () { + var prepData, supportDesc; + for ( var instanceNo in this.workerDescription.workerSupports ) { + + supportDesc = this.workerDescription.workerSupports[ instanceNo ]; + if ( ! supportDesc.inUse ) { + + if ( this.instructionQueuePointer < this.instructionQueue.length ) { + + prepData = this.instructionQueue[ this.instructionQueuePointer ]; + this._kickWorkerRun( prepData, supportDesc ); + this.instructionQueuePointer++; + + } else { + + this._deregister( supportDesc ); + + } + + } + + } + + if ( ! this.isRunning() && this.callbackOnFinishedProcessing !== null ) { + + this.callbackOnFinishedProcessing(); + this.callbackOnFinishedProcessing = null; + + } + }; + + WorkerDirector.prototype._kickWorkerRun = function( prepData, supportDesc ) { + supportDesc.inUse = true; + supportDesc.workerSupport.setTerminateRequested( supportDesc.terminateRequested ); + + if ( this.logging.enabled ) console.info( '\nAssigning next item from queue to worker (queue length: ' + this.instructionQueue.length + ')\n\n' ); + + var scope = this; + var prepDataCallbacks = prepData.getCallbacks(); + var globalCallbacks = this.workerDescription.globalCallbacks; + var wrapperOnLoad = function ( event ) { + if ( Validator.isValid( globalCallbacks.onLoad ) ) globalCallbacks.onLoad( event ); + if ( Validator.isValid( prepDataCallbacks.onLoad ) ) prepDataCallbacks.onLoad( event ); + scope.objectsCompleted++; + supportDesc.inUse = false; + + scope.processQueue(); + }; + + var wrapperOnProgress = function ( event ) { + if ( Validator.isValid( globalCallbacks.onProgress ) ) globalCallbacks.onProgress( event ); + if ( Validator.isValid( prepDataCallbacks.onProgress ) ) prepDataCallbacks.onProgress( event ); + }; + + var wrapperOnMeshAlter = function ( event, override ) { + if ( Validator.isValid( globalCallbacks.onMeshAlter ) ) override = globalCallbacks.onMeshAlter( event, override ); + if ( Validator.isValid( prepDataCallbacks.onMeshAlter ) ) override = globalCallbacks.onMeshAlter( event, override ); + return override; + }; + + var wrapperOnLoadMaterials = function ( materials ) { + if ( Validator.isValid( globalCallbacks.onLoadMaterials ) ) materials = globalCallbacks.onLoadMaterials( materials ); + if ( Validator.isValid( prepDataCallbacks.onLoadMaterials ) ) materials = prepDataCallbacks.onLoadMaterials( materials ); + return materials; + }; + + var wrapperOnReportError = function ( errorMessage ) { + var continueProcessing = true; + if ( Validator.isValid( globalCallbacks.onReportError ) ) continueProcessing = globalCallbacks.onReportError( supportDesc, errorMessage ); + if ( Validator.isValid( prepDataCallbacks.onReportError ) ) continueProcessing = prepDataCallbacks.onReportError( supportDesc, errorMessage ); + + if ( ! Validator.isValid( globalCallbacks.onReportError ) && ! Validator.isValid( prepDataCallbacks.onReportError ) ) { + + console.error( 'Loader reported an error: ' ); + console.error( errorMessage ); + + } + if ( continueProcessing ) { + + supportDesc.inUse = false; + scope.processQueue(); + + } + }; + + supportDesc.loader = this._buildLoader( supportDesc.instanceNo ); + + var updatedCallbacks = new THREE.LoaderSupport.Callbacks(); + updatedCallbacks.setCallbackOnLoad( wrapperOnLoad ); + updatedCallbacks.setCallbackOnProgress( wrapperOnProgress ); + updatedCallbacks.setCallbackOnReportError( wrapperOnReportError ); + updatedCallbacks.setCallbackOnMeshAlter( wrapperOnMeshAlter ); + updatedCallbacks.setCallbackOnLoadMaterials( wrapperOnLoadMaterials ); + prepData.callbacks = updatedCallbacks; + + supportDesc.loader.run( prepData, supportDesc.workerSupport ); + }; + + WorkerDirector.prototype._buildLoader = function ( instanceNo ) { + var classDef = this.workerDescription.classDef; + var loader = Object.create( classDef.prototype ); + classDef.call( loader, THREE.DefaultLoadingManager ); + + // verify that all required functions are implemented + if ( ! loader.hasOwnProperty( 'instanceNo' ) ) throw classDef.name + ' has no property "instanceNo".'; + loader.instanceNo = instanceNo; + + if ( ! loader.hasOwnProperty( 'workerSupport' ) ) { + + throw classDef.name + ' has no property "workerSupport".'; + + } + if ( typeof loader.run !== 'function' ) throw classDef.name + ' has no function "run".'; + if ( ! loader.hasOwnProperty( 'callbacks' ) || ! Validator.isValid( loader.callbacks ) ) { + + console.warn( classDef.name + ' has an invalid property "callbacks". Will change to "THREE.LoaderSupport.Callbacks"' ); + loader.callbacks = new THREE.LoaderSupport.Callbacks(); + + } + + return loader; + }; + + WorkerDirector.prototype._deregister = function ( supportDesc ) { + if ( Validator.isValid( supportDesc ) ) { + + supportDesc.workerSupport.setTerminateRequested( true ); + if ( this.logging.enabled ) console.info( 'Requested termination of worker #' + supportDesc.instanceNo + '.' ); + + var loaderCallbacks = supportDesc.loader.callbacks; + if ( Validator.isValid( loaderCallbacks.onProgress ) ) loaderCallbacks.onProgress( { detail: { text: '' } } ); + delete this.workerDescription.workerSupports[ supportDesc.instanceNo ]; + + } + }; + + /** + * Terminate all workers. + * @memberOf THREE.LoaderSupport.WorkerDirector + * + * @param {callback} callbackOnFinishedProcessing Function called once all workers finished processing. + */ + WorkerDirector.prototype.tearDown = function ( callbackOnFinishedProcessing ) { + if ( this.logging.enabled ) console.info( 'WorkerDirector received the deregister call. Terminating all workers!' ); + + this.instructionQueuePointer = this.instructionQueue.length; + this.callbackOnFinishedProcessing = Validator.verifyInput( callbackOnFinishedProcessing, null ); + + for ( var name in this.workerDescription.workerSupports ) { + + this.workerDescription.workerSupports[ name ].terminateRequested = true; + + } + }; + + return WorkerDirector; + +})(); diff --git a/three/jsutil/loaders/MD2Loader.js b/three/jsutil/loaders/MD2Loader.js new file mode 100644 index 000000000..c8878c9f6 --- /dev/null +++ b/three/jsutil/loaders/MD2Loader.js @@ -0,0 +1,387 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.MD2Loader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.MD2Loader.prototype = { + + constructor: THREE.MD2Loader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( buffer ) { + + onLoad( scope.parse( buffer ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: ( function () { + + var normalData = [ + [ - 0.525731, 0.000000, 0.850651 ], [ - 0.442863, 0.238856, 0.864188 ], + [ - 0.295242, 0.000000, 0.955423 ], [ - 0.309017, 0.500000, 0.809017 ], + [ - 0.162460, 0.262866, 0.951056 ], [ 0.000000, 0.000000, 1.000000 ], + [ 0.000000, 0.850651, 0.525731 ], [ - 0.147621, 0.716567, 0.681718 ], + [ 0.147621, 0.716567, 0.681718 ], [ 0.000000, 0.525731, 0.850651 ], + [ 0.309017, 0.500000, 0.809017 ], [ 0.525731, 0.000000, 0.850651 ], + [ 0.295242, 0.000000, 0.955423 ], [ 0.442863, 0.238856, 0.864188 ], + [ 0.162460, 0.262866, 0.951056 ], [ - 0.681718, 0.147621, 0.716567 ], + [ - 0.809017, 0.309017, 0.500000 ], [ - 0.587785, 0.425325, 0.688191 ], + [ - 0.850651, 0.525731, 0.000000 ], [ - 0.864188, 0.442863, 0.238856 ], + [ - 0.716567, 0.681718, 0.147621 ], [ - 0.688191, 0.587785, 0.425325 ], + [ - 0.500000, 0.809017, 0.309017 ], [ - 0.238856, 0.864188, 0.442863 ], + [ - 0.425325, 0.688191, 0.587785 ], [ - 0.716567, 0.681718, - 0.147621 ], + [ - 0.500000, 0.809017, - 0.309017 ], [ - 0.525731, 0.850651, 0.000000 ], + [ 0.000000, 0.850651, - 0.525731 ], [ - 0.238856, 0.864188, - 0.442863 ], + [ 0.000000, 0.955423, - 0.295242 ], [ - 0.262866, 0.951056, - 0.162460 ], + [ 0.000000, 1.000000, 0.000000 ], [ 0.000000, 0.955423, 0.295242 ], + [ - 0.262866, 0.951056, 0.162460 ], [ 0.238856, 0.864188, 0.442863 ], + [ 0.262866, 0.951056, 0.162460 ], [ 0.500000, 0.809017, 0.309017 ], + [ 0.238856, 0.864188, - 0.442863 ], [ 0.262866, 0.951056, - 0.162460 ], + [ 0.500000, 0.809017, - 0.309017 ], [ 0.850651, 0.525731, 0.000000 ], + [ 0.716567, 0.681718, 0.147621 ], [ 0.716567, 0.681718, - 0.147621 ], + [ 0.525731, 0.850651, 0.000000 ], [ 0.425325, 0.688191, 0.587785 ], + [ 0.864188, 0.442863, 0.238856 ], [ 0.688191, 0.587785, 0.425325 ], + [ 0.809017, 0.309017, 0.500000 ], [ 0.681718, 0.147621, 0.716567 ], + [ 0.587785, 0.425325, 0.688191 ], [ 0.955423, 0.295242, 0.000000 ], + [ 1.000000, 0.000000, 0.000000 ], [ 0.951056, 0.162460, 0.262866 ], + [ 0.850651, - 0.525731, 0.000000 ], [ 0.955423, - 0.295242, 0.000000 ], + [ 0.864188, - 0.442863, 0.238856 ], [ 0.951056, - 0.162460, 0.262866 ], + [ 0.809017, - 0.309017, 0.500000 ], [ 0.681718, - 0.147621, 0.716567 ], + [ 0.850651, 0.000000, 0.525731 ], [ 0.864188, 0.442863, - 0.238856 ], + [ 0.809017, 0.309017, - 0.500000 ], [ 0.951056, 0.162460, - 0.262866 ], + [ 0.525731, 0.000000, - 0.850651 ], [ 0.681718, 0.147621, - 0.716567 ], + [ 0.681718, - 0.147621, - 0.716567 ], [ 0.850651, 0.000000, - 0.525731 ], + [ 0.809017, - 0.309017, - 0.500000 ], [ 0.864188, - 0.442863, - 0.238856 ], + [ 0.951056, - 0.162460, - 0.262866 ], [ 0.147621, 0.716567, - 0.681718 ], + [ 0.309017, 0.500000, - 0.809017 ], [ 0.425325, 0.688191, - 0.587785 ], + [ 0.442863, 0.238856, - 0.864188 ], [ 0.587785, 0.425325, - 0.688191 ], + [ 0.688191, 0.587785, - 0.425325 ], [ - 0.147621, 0.716567, - 0.681718 ], + [ - 0.309017, 0.500000, - 0.809017 ], [ 0.000000, 0.525731, - 0.850651 ], + [ - 0.525731, 0.000000, - 0.850651 ], [ - 0.442863, 0.238856, - 0.864188 ], + [ - 0.295242, 0.000000, - 0.955423 ], [ - 0.162460, 0.262866, - 0.951056 ], + [ 0.000000, 0.000000, - 1.000000 ], [ 0.295242, 0.000000, - 0.955423 ], + [ 0.162460, 0.262866, - 0.951056 ], [ - 0.442863, - 0.238856, - 0.864188 ], + [ - 0.309017, - 0.500000, - 0.809017 ], [ - 0.162460, - 0.262866, - 0.951056 ], + [ 0.000000, - 0.850651, - 0.525731 ], [ - 0.147621, - 0.716567, - 0.681718 ], + [ 0.147621, - 0.716567, - 0.681718 ], [ 0.000000, - 0.525731, - 0.850651 ], + [ 0.309017, - 0.500000, - 0.809017 ], [ 0.442863, - 0.238856, - 0.864188 ], + [ 0.162460, - 0.262866, - 0.951056 ], [ 0.238856, - 0.864188, - 0.442863 ], + [ 0.500000, - 0.809017, - 0.309017 ], [ 0.425325, - 0.688191, - 0.587785 ], + [ 0.716567, - 0.681718, - 0.147621 ], [ 0.688191, - 0.587785, - 0.425325 ], + [ 0.587785, - 0.425325, - 0.688191 ], [ 0.000000, - 0.955423, - 0.295242 ], + [ 0.000000, - 1.000000, 0.000000 ], [ 0.262866, - 0.951056, - 0.162460 ], + [ 0.000000, - 0.850651, 0.525731 ], [ 0.000000, - 0.955423, 0.295242 ], + [ 0.238856, - 0.864188, 0.442863 ], [ 0.262866, - 0.951056, 0.162460 ], + [ 0.500000, - 0.809017, 0.309017 ], [ 0.716567, - 0.681718, 0.147621 ], + [ 0.525731, - 0.850651, 0.000000 ], [ - 0.238856, - 0.864188, - 0.442863 ], + [ - 0.500000, - 0.809017, - 0.309017 ], [ - 0.262866, - 0.951056, - 0.162460 ], + [ - 0.850651, - 0.525731, 0.000000 ], [ - 0.716567, - 0.681718, - 0.147621 ], + [ - 0.716567, - 0.681718, 0.147621 ], [ - 0.525731, - 0.850651, 0.000000 ], + [ - 0.500000, - 0.809017, 0.309017 ], [ - 0.238856, - 0.864188, 0.442863 ], + [ - 0.262866, - 0.951056, 0.162460 ], [ - 0.864188, - 0.442863, 0.238856 ], + [ - 0.809017, - 0.309017, 0.500000 ], [ - 0.688191, - 0.587785, 0.425325 ], + [ - 0.681718, - 0.147621, 0.716567 ], [ - 0.442863, - 0.238856, 0.864188 ], + [ - 0.587785, - 0.425325, 0.688191 ], [ - 0.309017, - 0.500000, 0.809017 ], + [ - 0.147621, - 0.716567, 0.681718 ], [ - 0.425325, - 0.688191, 0.587785 ], + [ - 0.162460, - 0.262866, 0.951056 ], [ 0.442863, - 0.238856, 0.864188 ], + [ 0.162460, - 0.262866, 0.951056 ], [ 0.309017, - 0.500000, 0.809017 ], + [ 0.147621, - 0.716567, 0.681718 ], [ 0.000000, - 0.525731, 0.850651 ], + [ 0.425325, - 0.688191, 0.587785 ], [ 0.587785, - 0.425325, 0.688191 ], + [ 0.688191, - 0.587785, 0.425325 ], [ - 0.955423, 0.295242, 0.000000 ], + [ - 0.951056, 0.162460, 0.262866 ], [ - 1.000000, 0.000000, 0.000000 ], + [ - 0.850651, 0.000000, 0.525731 ], [ - 0.955423, - 0.295242, 0.000000 ], + [ - 0.951056, - 0.162460, 0.262866 ], [ - 0.864188, 0.442863, - 0.238856 ], + [ - 0.951056, 0.162460, - 0.262866 ], [ - 0.809017, 0.309017, - 0.500000 ], + [ - 0.864188, - 0.442863, - 0.238856 ], [ - 0.951056, - 0.162460, - 0.262866 ], + [ - 0.809017, - 0.309017, - 0.500000 ], [ - 0.681718, 0.147621, - 0.716567 ], + [ - 0.681718, - 0.147621, - 0.716567 ], [ - 0.850651, 0.000000, - 0.525731 ], + [ - 0.688191, 0.587785, - 0.425325 ], [ - 0.587785, 0.425325, - 0.688191 ], + [ - 0.425325, 0.688191, - 0.587785 ], [ - 0.425325, - 0.688191, - 0.587785 ], + [ - 0.587785, - 0.425325, - 0.688191 ], [ - 0.688191, - 0.587785, - 0.425325 ] + ]; + + return function ( buffer ) { + + console.time( 'MD2Loader' ); + + var data = new DataView( buffer ); + + // http://tfc.duke.free.fr/coding/md2-specs-en.html + + var header = {}; + var headerNames = [ + 'ident', 'version', + 'skinwidth', 'skinheight', + 'framesize', + 'num_skins', 'num_vertices', 'num_st', 'num_tris', 'num_glcmds', 'num_frames', + 'offset_skins', 'offset_st', 'offset_tris', 'offset_frames', 'offset_glcmds', 'offset_end' + ]; + + for ( var i = 0; i < headerNames.length; i ++ ) { + + header[ headerNames[ i ] ] = data.getInt32( i * 4, true ); + + } + + if ( header.ident !== 844121161 || header.version !== 8 ) { + + console.error( 'Not a valid MD2 file' ); + return; + + } + + if ( header.offset_end !== data.byteLength ) { + + console.error( 'Corrupted MD2 file' ); + return; + + } + + // + + var geometry = new THREE.BufferGeometry(); + + // uvs + + var uvsTemp = []; + var offset = header.offset_st; + + for ( var i = 0, l = header.num_st; i < l; i ++ ) { + + var u = data.getInt16( offset + 0, true ); + var v = data.getInt16( offset + 2, true ); + + uvsTemp.push( u / header.skinwidth, 1 - ( v / header.skinheight ) ); + + offset += 4; + + } + + // triangles + + offset = header.offset_tris; + + var vertexIndices = []; + var uvIndices = []; + + for ( var i = 0, l = header.num_tris; i < l; i ++ ) { + + vertexIndices.push( + data.getUint16( offset + 0, true ), + data.getUint16( offset + 2, true ), + data.getUint16( offset + 4, true ) + ); + + uvIndices.push( + data.getUint16( offset + 6, true ), + data.getUint16( offset + 8, true ), + data.getUint16( offset + 10, true ) + ); + + offset += 12; + + } + + // frames + + var translation = new THREE.Vector3(); + var scale = new THREE.Vector3(); + var string = []; + + var frames = []; + + offset = header.offset_frames; + + for ( var i = 0, l = header.num_frames; i < l; i ++ ) { + + scale.set( + data.getFloat32( offset + 0, true ), + data.getFloat32( offset + 4, true ), + data.getFloat32( offset + 8, true ) + ); + + translation.set( + data.getFloat32( offset + 12, true ), + data.getFloat32( offset + 16, true ), + data.getFloat32( offset + 20, true ) + ); + + offset += 24; + + for ( var j = 0; j < 16; j ++ ) { + + var character = data.getUint8( offset + j, true ); + if ( character === 0 ) break; + + string[ j ] = character; + + } + + var frame = { + name: String.fromCharCode.apply( null, string ), + vertices: [], + normals: [] + }; + + offset += 16; + + for ( var j = 0; j < header.num_vertices; j ++ ) { + + var x = data.getUint8( offset ++, true ); + var y = data.getUint8( offset ++, true ); + var z = data.getUint8( offset ++, true ); + var n = normalData[ data.getUint8( offset ++, true ) ]; + + x = x * scale.x + translation.x; + y = y * scale.y + translation.y; + z = z * scale.z + translation.z; + + frame.vertices.push( x, z, y ); // convert to Y-up + frame.normals.push( n[ 0 ], n[ 2 ], n[ 1 ] ); // convert to Y-up + + } + + frames.push( frame ); + + } + + // static + + var positions = []; + var normals = []; + var uvs = []; + + var verticesTemp = frames[ 0 ].vertices; + var normalsTemp = frames[ 0 ].normals; + + for ( var i = 0, l = vertexIndices.length; i < l; i ++ ) { + + var vertexIndex = vertexIndices[ i ]; + var stride = vertexIndex * 3; + + // + + var x = verticesTemp[ stride ]; + var y = verticesTemp[ stride + 1 ]; + var z = verticesTemp[ stride + 2 ]; + + positions.push( x, y, z ); + + // + + var nx = normalsTemp[ stride ]; + var ny = normalsTemp[ stride + 1 ]; + var nz = normalsTemp[ stride + 2 ]; + + normals.push( nx, ny, nz ); + + // + + var uvIndex = uvIndices[ i ]; + stride = uvIndex * 2; + + var u = uvsTemp[ stride ]; + var v = uvsTemp[ stride + 1 ]; + + uvs.push( u, v ); + + } + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + + // animation + + var morphPositions = []; + var morphNormals = []; + + for ( var i = 0, l = frames.length; i < l; i ++ ) { + + var frame = frames[ i ]; + var attributeName = frame.name; + + if ( frame.vertices.length > 0 ) { + + var positions = []; + + for ( var j = 0, jl = vertexIndices.length; j < jl; j ++ ) { + + var vertexIndex = vertexIndices[ j ]; + var stride = vertexIndex * 3; + + var x = frame.vertices[ stride ]; + var y = frame.vertices[ stride + 1 ]; + var z = frame.vertices[ stride + 2 ]; + + positions.push( x, y, z ); + + } + + var positionAttribute = new THREE.Float32BufferAttribute( positions, 3 ); + positionAttribute.name = attributeName; + + morphPositions.push( positionAttribute ); + + } + + if ( frame.normals.length > 0 ) { + + var normals = []; + + for ( var j = 0, jl = vertexIndices.length; j < jl; j ++ ) { + + var vertexIndex = vertexIndices[ j ]; + var stride = vertexIndex * 3; + + var nx = frame.normals[ stride ]; + var ny = frame.normals[ stride + 1 ]; + var nz = frame.normals[ stride + 2 ]; + + normals.push( nx, ny, nz ); + + } + + var normalAttribute = new THREE.Float32BufferAttribute( normals, 3 ); + normalAttribute.name = attributeName; + + morphNormals.push( normalAttribute ); + + } + + } + + geometry.morphAttributes.position = morphPositions; + geometry.morphAttributes.normal = morphNormals; + + geometry.animations = THREE.AnimationClip.CreateClipsFromMorphTargetSequences( frames, 10 ); + + console.timeEnd( 'MD2Loader' ); + + return geometry; + + }; + + } )() + +}; diff --git a/three/jsutil/loaders/MMDLoader.js b/three/jsutil/loaders/MMDLoader.js new file mode 100644 index 000000000..f48c21ed9 --- /dev/null +++ b/three/jsutil/loaders/MMDLoader.js @@ -0,0 +1,1899 @@ +/** + * @author takahiro / https://github.com/takahirox + * + * Dependencies + * - mmd-parser https://github.com/takahirox/mmd-parser + * - THREE.TGALoader + * - THREE.OutlineEffect + * + * MMDLoader creates Three.js Objects from MMD resources as + * PMD, PMX, VMD, and VPD files. + * + * PMD/PMX is a model data format, VMD is a motion data format + * VPD is a posing data format used in MMD(Miku Miku Dance). + * + * MMD official site + * - http://www.geocities.jp/higuchuu4/index_e.htm + * + * PMD, VMD format (in Japanese) + * - http://blog.goo.ne.jp/torisu_tetosuki/e/209ad341d3ece2b1b4df24abf619d6e4 + * + * PMX format + * - https://gist.github.com/felixjones/f8a06bd48f9da9a4539f + * + * TODO + * - light motion in vmd support. + * - SDEF support. + * - uv/material/bone morphing support. + * - more precise grant skinning support. + * - shadow support. + */ + +THREE.MMDLoader = ( function () { + + /** + * @param {THREE.LoadingManager} manager + */ + function MMDLoader( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.loader = new THREE.FileLoader( this.manager ); + + this.parser = null; // lazy generation + this.meshBuilder = new MeshBuilder( this.manager ); + this.animationBuilder = new AnimationBuilder(); + + } + + MMDLoader.prototype = { + + constructor: MMDLoader, + + crossOrigin: 'anonymous', + + /** + * @param {string} value + * @return {THREE.MMDLoader} + */ + setCrossOrigin: function ( crossOrigin ) { + + this.crossOrigin = crossOrigin; + return this; + + }, + + // Load MMD assets as Three.js Object + + /** + * Loads Model file (.pmd or .pmx) as a THREE.SkinnedMesh. + * + * @param {string} url - url to Model(.pmd or .pmx) file + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + load: function ( url, onLoad, onProgress, onError ) { + + var builder = this.meshBuilder.setCrossOrigin( this.crossOrigin ); + + var texturePath = THREE.LoaderUtils.extractUrlBase( url ); + var modelExtension = this._extractExtension( url ).toLowerCase(); + + // Should I detect by seeing header? + if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) { + + if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) ); + + return; + + } + + this[ modelExtension === 'pmd' ? 'loadPMD' : 'loadPMX' ]( url, function ( data ) { + + onLoad( builder.build( data, texturePath, onProgress, onError ) ); + + }, onProgress, onError ); + + }, + + /** + * Loads Motion file(s) (.vmd) as a THREE.AnimationClip. + * If two or more files are specified, they'll be merged. + * + * @param {string|Array} url - url(s) to animation(.vmd) file(s) + * @param {THREE.SkinnedMesh|THREE.Camera} object - tracks will be fitting to this object + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + loadAnimation: function ( url, object, onLoad, onProgress, onError ) { + + var builder = this.animationBuilder; + + this.loadVMD( url, function ( vmd ) { + + onLoad( object.isCamera + ? builder.buildCameraAnimation( vmd ) + : builder.build( vmd, object ) ); + + }, onProgress, onError ); + + }, + + /** + * Loads mode file and motion file(s) as an object containing + * a THREE.SkinnedMesh and a THREE.AnimationClip. + * Tracks of THREE.AnimationClip are fitting to the model. + * + * @param {string} modelUrl - url to Model(.pmd or .pmx) file + * @param {string|Array{string}} vmdUrl - url(s) to animation(.vmd) file + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + loadWithAnimation: function ( modelUrl, vmdUrl, onLoad, onProgress, onError ) { + + var scope = this; + + this.load( modelUrl, function ( mesh ) { + + scope.loadAnimation( vmdUrl, mesh, function ( animation ) { + + onLoad( { + mesh: mesh, + animation: animation + } ); + + }, onProgress, onError ); + + }, onProgress, onError ); + + }, + + // Load MMD assets as Object data parsed by MMDParser + + /** + * Loads .pmd file as an Object. + * + * @param {string} url - url to .pmd file + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + loadPMD: function ( url, onLoad, onProgress, onError ) { + + var parser = this._getParser(); + + this.loader + .setMimeType( undefined ) + .setResponseType( 'arraybuffer' ) + .load( url, function ( buffer ) { + + onLoad( parser.parsePmd( buffer, true ) ); + + }, onProgress, onError ); + + }, + + /** + * Loads .pmx file as an Object. + * + * @param {string} url - url to .pmx file + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + loadPMX: function ( url, onLoad, onProgress, onError ) { + + var parser = this._getParser(); + + this.loader + .setMimeType( undefined ) + .setResponseType( 'arraybuffer' ) + .load( url, function ( buffer ) { + + onLoad( parser.parsePmx( buffer, true ) ); + + }, onProgress, onError ); + + }, + + /** + * Loads .vmd file as an Object. If two or more files are specified + * they'll be merged. + * + * @param {string|Array} url - url(s) to .vmd file(s) + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + loadVMD: function ( url, onLoad, onProgress, onError ) { + + var urls = Array.isArray( url ) ? url : [ url ]; + + var vmds = []; + var vmdNum = urls.length; + + var parser = this._getParser(); + + this.loader + .setMimeType( undefined ) + .setResponseType( 'arraybuffer' ); + + for ( var i = 0, il = urls.length; i < il; i ++ ) { + + this.loader.load( urls[ i ], function ( buffer ) { + + vmds.push( parser.parseVmd( buffer, true ) ); + + if ( vmds.length === vmdNum ) onLoad( parser.mergeVmds( vmds ) ); + + }, onProgress, onError ); + + } + + }, + + /** + * Loads .vpd file as an Object. + * + * @param {string} url - url to .vpd file + * @param {boolean} isUnicode + * @param {function} onLoad + * @param {function} onProgress + * @param {function} onError + */ + loadVPD: function ( url, isUnicode, onLoad, onProgress, onError ) { + + var parser = this._getParser(); + + this.loader + .setMimeType( isUnicode ? undefined : 'text/plain; charset=shift_jis' ) + .setResponseType( 'text' ) + .load( url, function ( text ) { + + onLoad( parser.parseVpd( text, true ) ); + + }, onProgress, onError ); + + }, + + // private methods + + _extractExtension: function ( url ) { + + var index = url.lastIndexOf( '.' ); + return index < 0 ? '' : url.slice( index + 1 ); + + }, + + _getParser: function () { + + if ( this.parser === null ) { + + if ( typeof MMDParser === 'undefined' ) { + + throw new Error( 'THREE.MMDLoader: Import MMDParser https://github.com/takahirox/mmd-parser' ); + + } + + this.parser = new MMDParser.Parser(); + + } + + return this.parser; + + } + + }; + + // Utilities + + /* + * base64 encoded defalut toon textures toon00.bmp - toon10.bmp. + * We don't need to request external toon image files. + * This idea is from http://www20.atpages.jp/katwat/three.js_r58/examples/mytest37/mmd.three.js + */ + var DEFAULT_TOON_TEXTURES = [ + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/bWiiMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh8aBHZBl14e8wAAAABJRU5ErkJggg==', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOUlEQVRYR+3WMREAMAwDsYY/yoDI7MLwIiP40+RJklfcCCBAgAABAgTqArfb/QMCCBAgQIAAgbbAB3z/e0F3js2cAAAAAElFTkSuQmCC', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/B5ilMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh81dWyx0gFwKAAAAABJRU5ErkJggg==', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOklEQVRYR+3WoREAMAwDsWb/UQtCy9wxTOQJ/oQ8SXKKGwEECBAgQIBAXeDt7f4BAQQIECBAgEBb4AOz8Hzx7WLY4wAAAABJRU5ErkJggg==', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABPUlEQVRYR+1XwW7CMAy1+f9fZOMysSEOEweEOPRNdm3HbdOyIhAcklPrOs/PLy9RygBALxzcCDQFmgJNgaZAU6Ap0BR4PwX8gsRMVLssMRH5HcpzJEaWL7EVg9F1IHRlyqQohgVr4FGUlUcMJSjcUlDw0zvjeun70cLWmneoyf7NgBTQSniBTQQSuJAZsOnnaczjIMb5hCiuHKxokCrJfVnrctyZL0PkJAJe1HMil4nxeyi3Ypfn1kX51jpPvo/JeCNC4PhVdHdJw2XjBR8brF8PEIhNVn12AgP7uHsTBguBn53MUZCqv7Lp07Pn5k1Ro+uWmUNn7D+M57rtk7aG0Vo73xyF/fbFf0bPJjDXngnGocDTdFhygZjwUQrMNrDcmZlQT50VJ/g/UwNyHpu778+yW+/ksOz/BFo54P4AsUXMfRq7XWsAAAAASUVORK5CYII=', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACMElEQVRYR+2Xv4pTQRTGf2dubhLdICiii2KnYKHVolhauKWPoGAnNr6BD6CvIVaihYuI2i1ia0BY0MZGRHQXjZj/mSPnnskfNWiWZUlzJ5k7M2cm833nO5Mziej2DWWJRUoCpQKlAntSQCqgw39/iUWAGmh37jrRnVsKlgpiqmkoGVABA7E57fvY+pJDdgKqF6HzFCSADkDq+F6AHABtQ+UMVE5D7zXod7fFNhTEckTbj5XQgHzNN+5tQvc5NG7C6BNkp6D3EmpXHDR+dQAjFLchW3VS9rlw3JBh+B7ys5Cf9z0GW1C/7P32AyBAOAz1q4jGliIH3YPuBnSfQX4OGreTIgEYQb/pBDtPnEQ4CivXYPAWBk13oHrB54yA9QuSn2H4AcKRpEILDt0BUzj+RLR1V5EqjD66NPRBVpLcQwjHoHYJOhsQv6U4mnzmrIXJCFr4LDwm/xBUoboG9XX4cc9VKdYoSA2yk5NQLJaKDUjTBoveG3Z2TElTxwjNK4M3LEZgUdDdruvcXzKBpStgp2NPiWi3ks9ZXxIoFVi+AvHLdc9TqtjL3/aYjpPlrzOcEnK62Szhimdd7xX232zFDTgtxezOu3WNMRLjiKgjtOhHVMd1loynVHvOgjuIIJMaELEqhJAV/RCSLbWTcfPFakFgFlALTRRvx+ok6Hlp/Q+v3fmx90bMyUzaEAhmM3KvHlXTL5DxnbGf/1M8RNNACLL5MNtPxP/mypJAqcDSFfgFhpYqWUzhTEAAAAAASUVORK5CYII=', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', + 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=' + ]; + + // Builders. They build Three.js object from Object data parsed by MMDParser. + + /** + * @param {THREE.LoadingManager} manager + */ + function MeshBuilder( manager ) { + + this.geometryBuilder = new GeometryBuilder(); + this.materialBuilder = new MaterialBuilder( manager ); + + } + + MeshBuilder.prototype = { + + constructor: MeshBuilder, + + crossOrigin: 'anonymous', + + /** + * @param {string} crossOrigin + * @return {MeshBuilder} + */ + setCrossOrigin: function ( crossOrigin ) { + + this.crossOrigin = crossOrigin; + return this; + + }, + + /** + * @param {Object} data - parsed PMD/PMX data + * @param {string} texturePath + * @param {function} onProgress + * @param {function} onError + * @return {THREE.SkinnedMesh} + */ + build: function ( data, texturePath, onProgress, onError ) { + + var geometry = this.geometryBuilder.build( data ); + var material = this.materialBuilder + .setCrossOrigin( this.crossOrigin ) + .setTexturePath( texturePath ) + .build( data, geometry, onProgress, onError ); + + var mesh = new THREE.SkinnedMesh( geometry, material ); + + // console.log( mesh ); // for console debug + + return mesh; + + } + + }; + + // + + function GeometryBuilder() { + + } + + GeometryBuilder.prototype = { + + constructor: GeometryBuilder, + + /** + * @param {Object} data - parsed PMD/PMX data + * @return {THREE.BufferGeometry} + */ + build: function ( data ) { + + // for geometry + var positions = []; + var uvs = []; + var normals = []; + + var indices = []; + + var groups = []; + + var bones = []; + var skinIndices = []; + var skinWeights = []; + + var morphTargets = []; + var morphPositions = []; + + var iks = []; + var grants = []; + + var rigidBodies = []; + var constraints = []; + + // for work + var offset = 0; + var boneTypeTable = {}; + + // positions, normals, uvs, skinIndices, skinWeights + + for ( var i = 0; i < data.metadata.vertexCount; i ++ ) { + + var v = data.vertices[ i ]; + + for ( var j = 0, jl = v.position.length; j < jl; j ++ ) { + + positions.push( v.position[ j ] ); + + } + + for ( var j = 0, jl = v.normal.length; j < jl; j ++ ) { + + normals.push( v.normal[ j ] ); + + } + + for ( var j = 0, jl = v.uv.length; j < jl; j ++ ) { + + uvs.push( v.uv[ j ] ); + + } + + for ( var j = 0; j < 4; j ++ ) { + + skinIndices.push( v.skinIndices.length - 1 >= j ? v.skinIndices[ j ] : 0.0 ); + + } + + for ( var j = 0; j < 4; j ++ ) { + + skinWeights.push( v.skinWeights.length - 1 >= j ? v.skinWeights[ j ] : 0.0 ); + + } + + } + + // indices + + for ( var i = 0; i < data.metadata.faceCount; i ++ ) { + + var face = data.faces[ i ]; + + for ( var j = 0, jl = face.indices.length; j < jl; j ++ ) { + + indices.push( face.indices[ j ] ); + + } + + } + + // groups + + for ( var i = 0; i < data.metadata.materialCount; i ++ ) { + + var material = data.materials[ i ]; + + groups.push( { + offset: offset * 3, + count: material.faceCount * 3 + } ); + + offset += material.faceCount; + + } + + // bones + + for ( var i = 0; i < data.metadata.rigidBodyCount; i ++ ) { + + var body = data.rigidBodies[ i ]; + var value = boneTypeTable[ body.boneIndex ]; + + // keeps greater number if already value is set without any special reasons + value = value === undefined ? body.type : Math.max( body.type, value ); + + boneTypeTable[ body.boneIndex ] = value; + + } + + for ( var i = 0; i < data.metadata.boneCount; i ++ ) { + + var boneData = data.bones[ i ]; + + var bone = { + parent: boneData.parentIndex, + name: boneData.name, + pos: boneData.position.slice( 0, 3 ), + rotq: [ 0, 0, 0, 1 ], + scl: [ 1, 1, 1 ], + rigidBodyType: boneTypeTable[ i ] !== undefined ? boneTypeTable[ i ] : - 1 + }; + + if ( bone.parent !== - 1 ) { + + bone.pos[ 0 ] -= data.bones[ bone.parent ].position[ 0 ]; + bone.pos[ 1 ] -= data.bones[ bone.parent ].position[ 1 ]; + bone.pos[ 2 ] -= data.bones[ bone.parent ].position[ 2 ]; + + } + + bones.push( bone ); + + } + + // iks + + // TODO: remove duplicated codes between PMD and PMX + if ( data.metadata.format === 'pmd' ) { + + for ( var i = 0; i < data.metadata.ikCount; i ++ ) { + + var ik = data.iks[ i ]; + + var param = { + target: ik.target, + effector: ik.effector, + iteration: ik.iteration, + maxAngle: ik.maxAngle * 4, + links: [] + }; + + for ( var j = 0, jl = ik.links.length; j < jl; j ++ ) { + + var link = {}; + link.index = ik.links[ j ].index; + link.enabled = true; + + if ( data.bones[ link.index ].name.indexOf( 'ひざ' ) >= 0 ) { + + link.limitation = new THREE.Vector3( 1.0, 0.0, 0.0 ); + + } + + param.links.push( link ); + + } + + iks.push( param ); + + } + + } else { + + for ( var i = 0; i < data.metadata.boneCount; i ++ ) { + + var ik = data.bones[ i ].ik; + + if ( ik === undefined ) continue; + + var param = { + target: i, + effector: ik.effector, + iteration: ik.iteration, + maxAngle: ik.maxAngle, + links: [] + }; + + for ( var j = 0, jl = ik.links.length; j < jl; j ++ ) { + + var link = {}; + link.index = ik.links[ j ].index; + link.enabled = true; + + if ( ik.links[ j ].angleLimitation === 1 ) { + + // Revert if rotationMin/Max doesn't work well + // link.limitation = new THREE.Vector3( 1.0, 0.0, 0.0 ); + + var rotationMin = ik.links[ j ].lowerLimitationAngle; + var rotationMax = ik.links[ j ].upperLimitationAngle; + + // Convert Left to Right coordinate by myself because + // MMDParser doesn't convert. It's a MMDParser's bug + + var tmp1 = - rotationMax[ 0 ]; + var tmp2 = - rotationMax[ 1 ]; + rotationMax[ 0 ] = - rotationMin[ 0 ]; + rotationMax[ 1 ] = - rotationMin[ 1 ]; + rotationMin[ 0 ] = tmp1; + rotationMin[ 1 ] = tmp2; + + link.rotationMin = new THREE.Vector3().fromArray( rotationMin ); + link.rotationMax = new THREE.Vector3().fromArray( rotationMax ); + + } + + param.links.push( link ); + + } + + iks.push( param ); + + } + + } + + // grants + + if ( data.metadata.format === 'pmx' ) { + + for ( var i = 0; i < data.metadata.boneCount; i ++ ) { + + var boneData = data.bones[ i ]; + var grant = boneData.grant; + + if ( grant === undefined ) continue; + + var param = { + index: i, + parentIndex: grant.parentIndex, + ratio: grant.ratio, + isLocal: grant.isLocal, + affectRotation: grant.affectRotation, + affectPosition: grant.affectPosition, + transformationClass: boneData.transformationClass + }; + + grants.push( param ); + + } + + grants.sort( function ( a, b ) { + + return a.transformationClass - b.transformationClass; + + } ); + + } + + // morph + + function updateAttributes( attribute, morph, ratio ) { + + for ( var i = 0; i < morph.elementCount; i ++ ) { + + var element = morph.elements[ i ]; + + var index; + + if ( data.metadata.format === 'pmd' ) { + + index = data.morphs[ 0 ].elements[ element.index ].index; + + } else { + + index = element.index; + + } + + attribute.array[ index * 3 + 0 ] += element.position[ 0 ] * ratio; + attribute.array[ index * 3 + 1 ] += element.position[ 1 ] * ratio; + attribute.array[ index * 3 + 2 ] += element.position[ 2 ] * ratio; + + } + + } + + for ( var i = 0; i < data.metadata.morphCount; i ++ ) { + + var morph = data.morphs[ i ]; + var params = { name: morph.name }; + + var attribute = new THREE.Float32BufferAttribute( data.metadata.vertexCount * 3, 3 ); + attribute.name = morph.name; + + for ( var j = 0; j < data.metadata.vertexCount * 3; j ++ ) { + + attribute.array[ j ] = positions[ j ]; + + } + + if ( data.metadata.format === 'pmd' ) { + + if ( i !== 0 ) { + + updateAttributes( attribute, morph, 1.0 ); + + } + + } else { + + if ( morph.type === 0 ) { // group + + for ( var j = 0; j < morph.elementCount; j ++ ) { + + var morph2 = data.morphs[ morph.elements[ j ].index ]; + var ratio = morph.elements[ j ].ratio; + + if ( morph2.type === 1 ) { + + updateAttributes( attribute, morph2, ratio ); + + } else { + + // TODO: implement + + } + + } + + } else if ( morph.type === 1 ) { // vertex + + updateAttributes( attribute, morph, 1.0 ); + + } else if ( morph.type === 2 ) { // bone + + // TODO: implement + + } else if ( morph.type === 3 ) { // uv + + // TODO: implement + + } else if ( morph.type === 4 ) { // additional uv1 + + // TODO: implement + + } else if ( morph.type === 5 ) { // additional uv2 + + // TODO: implement + + } else if ( morph.type === 6 ) { // additional uv3 + + // TODO: implement + + } else if ( morph.type === 7 ) { // additional uv4 + + // TODO: implement + + } else if ( morph.type === 8 ) { // material + + // TODO: implement + + } + + } + + morphTargets.push( params ); + morphPositions.push( attribute ); + + } + + // rigid bodies from rigidBodies field. + + for ( var i = 0; i < data.metadata.rigidBodyCount; i ++ ) { + + var rigidBody = data.rigidBodies[ i ]; + var params = {}; + + for ( var key in rigidBody ) { + + params[ key ] = rigidBody[ key ]; + + } + + /* + * RigidBody position parameter in PMX seems global position + * while the one in PMD seems offset from corresponding bone. + * So unify being offset. + */ + if ( data.metadata.format === 'pmx' ) { + + if ( params.boneIndex !== - 1 ) { + + var bone = data.bones[ params.boneIndex ]; + params.position[ 0 ] -= bone.position[ 0 ]; + params.position[ 1 ] -= bone.position[ 1 ]; + params.position[ 2 ] -= bone.position[ 2 ]; + + } + + } + + rigidBodies.push( params ); + + } + + // constraints from constraints field. + + for ( var i = 0; i < data.metadata.constraintCount; i ++ ) { + + var constraint = data.constraints[ i ]; + var params = {}; + + for ( var key in constraint ) { + + params[ key ] = constraint[ key ]; + + } + + var bodyA = rigidBodies[ params.rigidBodyIndex1 ]; + var bodyB = rigidBodies[ params.rigidBodyIndex2 ]; + + // Refer to http://www20.atpages.jp/katwat/wp/?p=4135 + if ( bodyA.type !== 0 && bodyB.type === 2 ) { + + if ( bodyA.boneIndex !== - 1 && bodyB.boneIndex !== - 1 && + data.bones[ bodyB.boneIndex ].parentIndex === bodyA.boneIndex ) { + + bodyB.type = 1; + + } + + } + + constraints.push( params ); + + } + + // build BufferGeometry. + + var geometry = new THREE.BufferGeometry(); + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + geometry.addAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( skinIndices, 4 ) ); + geometry.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeights, 4 ) ); + geometry.setIndex( indices ); + + for ( var i = 0, il = groups.length; i < il; i ++ ) { + + geometry.addGroup( groups[ i ].offset, groups[ i ].count, i ); + + } + + geometry.bones = bones; + + geometry.morphTargets = morphTargets; + geometry.morphAttributes.position = morphPositions; + + geometry.userData.MMD = { + bones: bones, + iks: iks, + grants: grants, + rigidBodies: rigidBodies, + constraints: constraints, + format: data.metadata.format + }; + + geometry.computeBoundingSphere(); + + return geometry; + + } + + }; + + // + + /** + * @param {THREE.LoadingManager} manager + */ + function MaterialBuilder( manager ) { + + this.manager = manager; + + this.textureLoader = new THREE.TextureLoader( this.manager ); + this.tgaLoader = null; // lazy generation + + } + + MaterialBuilder.prototype = { + + constructor: MaterialBuilder, + + crossOrigin: 'anonymous', + + texturePath: undefined, + + /** + * @param {string} crossOrigin + * @return {MaterialBuilder} + */ + setCrossOrigin: function ( crossOrigin ) { + + this.crossOrigin = crossOrigin; + return this; + + }, + + /** + * @param {string} texturePath + * @return {MaterialBuilder} + */ + setTexturePath: function ( texturePath ) { + + this.texturePath = texturePath; + return this; + + }, + + /** + * @param {Object} data - parsed PMD/PMX data + * @param {THREE.BufferGeometry} geometry - some properties are dependend on geometry + * @param {function} onProgress + * @param {function} onError + * @return {Array} + */ + build: function ( data, geometry, onProgress, onError ) { + + var materials = []; + + var textures = {}; + + this.textureLoader.setCrossOrigin( this.crossOrigin ); + + // materials + + for ( var i = 0; i < data.metadata.materialCount; i ++ ) { + + var material = data.materials[ i ]; + + var params = { userData: {} }; + + if ( material.name !== undefined ) params.name = material.name; + + /* + * Color + * + * MMD MeshToonMaterial + * diffuse - color + * specular - specular + * ambient - emissive * a + * (a = 1.0 without map texture or 0.2 with map texture) + * + * MeshToonMaterial doesn't have ambient. Set it to emissive instead. + * It'll be too bright if material has map texture so using coef 0.2. + */ + params.color = new THREE.Color().fromArray( material.diffuse ); + params.opacity = material.diffuse[ 3 ]; + params.specular = new THREE.Color().fromArray( material.specular ); + params.emissive = new THREE.Color().fromArray( material.ambient ); + params.shininess = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 ) + params.transparent = params.opacity !== 1.0; + + // + + params.skinning = geometry.bones.length > 0 ? true : false; + params.morphTargets = geometry.morphTargets.length > 0 ? true : false; + params.lights = true; + params.fog = true; + + // blend + + params.blending = THREE.CustomBlending; + params.blendSrc = THREE.SrcAlphaFactor; + params.blendDst = THREE.OneMinusSrcAlphaFactor; + params.blendSrcAlpha = THREE.SrcAlphaFactor; + params.blendDstAlpha = THREE.DstAlphaFactor; + + // side + + if ( data.metadata.format === 'pmx' && ( material.flag & 0x1 ) === 1 ) { + + params.side = THREE.DoubleSide; + + } else { + + params.side = params.opacity === 1.0 ? THREE.FrontSide : THREE.DoubleSide; + + } + + if ( data.metadata.format === 'pmd' ) { + + // map, envMap + + if ( material.fileName ) { + + var fileName = material.fileName; + var fileNames = fileName.split( '*' ); + + // fileNames[ 0 ]: mapFileName + // fileNames[ 1 ]: envMapFileName( optional ) + + params.map = this._loadTexture( fileNames[ 0 ], textures ); + + if ( fileNames.length > 1 ) { + + var extension = fileNames[ 1 ].slice( - 4 ).toLowerCase(); + + params.envMap = this._loadTexture( + fileNames[ 1 ], + textures, + { sphericalReflectionMapping: true } + ); + + params.combine = extension === '.sph' + ? THREE.MultiplyOperation + : THREE.AddOperation; + + } + + } + + // gradientMap + + var toonFileName = ( material.toonIndex === - 1 ) + ? 'toon00.bmp' + : data.toonTextures[ material.toonIndex ].fileName; + + params.gradientMap = this._loadTexture( + toonFileName, + textures, + { + isToonTexture: true, + isDefaultToonTexture: this._isDefaultToonTexture( toonFileName ) + } + ); + + // parameters for OutlineEffect + + params.userData.outlineParameters = { + thickness: material.edgeFlag === 1 ? 0.003 : 0.0, + color: [ 0, 0, 0 ], + alpha: 1.0, + visible: material.edgeFlag === 1 + }; + + } else { + + // map + + if ( material.textureIndex !== - 1 ) { + + params.map = this._loadTexture( data.textures[ material.textureIndex ], textures ); + + } + + // envMap TODO: support m.envFlag === 3 + + if ( material.envTextureIndex !== - 1 && ( material.envFlag === 1 || material.envFlag == 2 ) ) { + + params.envMap = this._loadTexture( + data.textures[ material.envTextureIndex ], + textures, { sphericalReflectionMapping: true } + ); + + params.combine = material.envFlag === 1 + ? THREE.MultiplyOperation + : THREE.AddOperation; + + } + + // gradientMap + + var toonFileName, isDefaultToon; + + if ( material.toonIndex === - 1 || material.toonFlag !== 0 ) { + + toonFileName = 'toon' + ( '0' + ( material.toonIndex + 1 ) ).slice( - 2 ) + '.bmp'; + isDefaultToon = true; + + } else { + + toonFileName = data.textures[ material.toonIndex ]; + isDefaultToon = false; + + } + + params.gradientMap = this._loadTexture( + toonFileName, + textures, + { + isToonTexture: true, + isDefaultToonTexture: isDefaultToon + } + ); + + // parameters for OutlineEffect + params.userData.outlineParameters = { + thickness: material.edgeSize / 300, // TODO: better calculation? + color: material.edgeColor.slice( 0, 3 ), + alpha: material.edgeColor[ 3 ], + visible: ( material.flag & 0x10 ) !== 0 && material.edgeSize > 0.0 + }; + + } + + if ( params.map !== undefined ) { + + if ( ! params.transparent ) { + + this._checkImageTransparency( params.map, geometry, i ); + + } + + params.emissive.multiplyScalar( 0.2 ); + + } + + materials.push( new THREE.MeshToonMaterial( params ) ); + + } + + if ( data.metadata.format === 'pmx' ) { + + // set transparent true if alpha morph is defined. + + function checkAlphaMorph( elements, materials ) { + + for ( var i = 0, il = elements.length; i < il; i ++ ) { + + var element = elements[ i ]; + + if ( element.index === - 1 ) continue; + + var material = materials[ element.index ]; + + if ( material.opacity !== element.diffuse[ 3 ] ) { + + material.transparent = true; + + } + + } + + } + + for ( var i = 0, il = data.morphs.length; i < il; i ++ ) { + + var morph = data.morphs[ i ]; + var elements = morph.elements; + + if ( morph.type === 0 ) { + + for ( var j = 0, jl = elements.length; j < jl; j ++ ) { + + var morph2 = data.morphs[ elements[ j ].index ]; + + if ( morph2.type !== 8 ) continue; + + checkAlphaMorph( morph2.elements, materials ); + + } + + } else if ( morph.type === 8 ) { + + checkAlphaMorph( elements, materials ); + + } + + } + + } + + return materials; + + }, + + // private methods + + _getTGALoader: function () { + + if ( this.tgaLoader === null ) { + + if ( THREE.TGALoader === undefined ) { + + throw new Error( 'THREE.MMDLoader: Import THREE.TGALoader' ); + + } + + this.tgaLoader = new THREE.TGALoader( this.manager ); + + } + + return this.tgaLoader; + + }, + + _isDefaultToonTexture: function ( name ) { + + if ( name.length !== 10 ) return false; + + return /toon(10|0[0-9])\.bmp/.test( name ); + + }, + + _loadTexture: function ( filePath, textures, params, onProgress, onError ) { + + params = params || {}; + + var scope = this; + + var fullPath; + + if ( params.isDefaultToonTexture === true ) { + + var index; + + try { + + index = parseInt( filePath.match( 'toon([0-9]{2})\.bmp$' )[ 1 ] ); + + } catch ( e ) { + + console.warn( 'THREE.MMDLoader: ' + filePath + ' seems like a ' + + 'not right default texture path. Using toon00.bmp instead.' ); + + index = 0; + + } + + fullPath = DEFAULT_TOON_TEXTURES[ index ]; + + } else { + + fullPath = this.texturePath + filePath; + + } + + if ( textures[ fullPath ] !== undefined ) return textures[ fullPath ]; + + var loader = THREE.Loader.Handlers.get( fullPath ); + + if ( loader === null ) { + + loader = ( filePath.slice( - 4 ).toLowerCase() === '.tga' ) + ? this._getTGALoader() + : this.textureLoader; + + } + + var texture = loader.load( fullPath, function ( t ) { + + // MMD toon texture is Axis-Y oriented + // but Three.js gradient map is Axis-X oriented. + // So here replaces the toon texture image with the rotated one. + if ( params.isToonTexture === true ) { + + t.image = scope._getRotatedImage( t.image ); + + } + + t.flipY = false; + t.wrapS = THREE.RepeatWrapping; + t.wrapT = THREE.RepeatWrapping; + + for ( var i = 0; i < texture.readyCallbacks.length; i ++ ) { + + texture.readyCallbacks[ i ]( texture ); + + } + + delete texture.readyCallbacks; + + }, onProgress, onError ); + + if ( params.sphericalReflectionMapping === true ) { + + texture.mapping = THREE.SphericalReflectionMapping; + + } + + texture.readyCallbacks = []; + + textures[ fullPath ] = texture; + + return texture; + + }, + + _getRotatedImage: function ( image ) { + + var canvas = document.createElement( 'canvas' ); + var context = canvas.getContext( '2d' ); + + var width = image.width; + var height = image.height; + + canvas.width = width; + canvas.height = height; + + context.clearRect( 0, 0, width, height ); + context.translate( width / 2.0, height / 2.0 ); + context.rotate( 0.5 * Math.PI ); // 90.0 * Math.PI / 180.0 + context.translate( - width / 2.0, - height / 2.0 ); + context.drawImage( image, 0, 0 ); + + return context.getImageData( 0, 0, width, height ); + + }, + + // Check if the partial image area used by the texture is transparent. + _checkImageTransparency: function ( map, geometry, groupIndex ) { + + map.readyCallbacks.push( function ( texture ) { + + // Is there any efficient ways? + function createImageData( image ) { + + var canvas = document.createElement( 'canvas' ); + canvas.width = image.width; + canvas.height = image.height; + + var context = canvas.getContext( '2d' ); + context.drawImage( image, 0, 0 ); + + return context.getImageData( 0, 0, canvas.width, canvas.height ); + + } + + function detectImageTransparency( image, uvs, indices ) { + + var width = image.width; + var height = image.height; + var data = image.data; + var threshold = 253; + + if ( data.length / ( width * height ) !== 4 ) return false; + + for ( var i = 0; i < indices.length; i += 3 ) { + + var centerUV = { x: 0.0, y: 0.0 }; + + for ( var j = 0; j < 3; j ++ ) { + + var index = indices[ i * 3 + j ]; + var uv = { x: uvs[ index * 2 + 0 ], y: uvs[ index * 2 + 1 ] }; + + if ( getAlphaByUv( image, uv ) < threshold ) return true; + + centerUV.x += uv.x; + centerUV.y += uv.y; + + } + + centerUV.x /= 3; + centerUV.y /= 3; + + if ( getAlphaByUv( image, centerUV ) < threshold ) return true; + + } + + return false; + + } + + /* + * This method expects + * texture.flipY = false + * texture.wrapS = THREE.RepeatWrapping + * texture.wrapT = THREE.RepeatWrapping + * TODO: more precise + */ + function getAlphaByUv( image, uv ) { + + var width = image.width; + var height = image.height; + + var x = Math.round( uv.x * width ) % width; + var y = Math.round( uv.y * height ) % height; + + if ( x < 0 ) x += width; + if ( y < 0 ) y += height; + + var index = y * width + x; + + return image.data[ index * 4 + 3 ]; + + } + + var imageData = texture.image.data !== undefined + ? texture.image + : createImageData( texture.image ); + + var group = geometry.groups[ groupIndex ]; + + if ( detectImageTransparency( + imageData, + geometry.attributes.uv.array, + geometry.index.array.slice( group.start, group.start + group.count ) ) ) { + + map.transparent = true; + + } + + } ); + + } + + }; + + // + + function AnimationBuilder() { + + } + + AnimationBuilder.prototype = { + + constructor: AnimationBuilder, + + /** + * @param {Object} vmd - parsed VMD data + * @param {THREE.SkinnedMesh} mesh - tracks will be fitting to mesh + * @return {THREE.AnimationClip} + */ + build: function ( vmd, mesh ) { + + // combine skeletal and morph animations + + var tracks = this.buildSkeletalAnimation( vmd, mesh ).tracks; + var tracks2 = this.buildMorphAnimation( vmd, mesh ).tracks; + + for ( var i = 0, il = tracks2.length; i < il; i ++ ) { + + tracks.push( tracks2[ i ] ); + + } + + return new THREE.AnimationClip( '', - 1, tracks ); + + }, + + /** + * @param {Object} vmd - parsed VMD data + * @param {THREE.SkinnedMesh} mesh - tracks will be fitting to mesh + * @return {THREE.AnimationClip} + */ + buildSkeletalAnimation: function ( vmd, mesh ) { + + function pushInterpolation( array, interpolation, index ) { + + array.push( interpolation[ index + 0 ] / 127 ); // x1 + array.push( interpolation[ index + 8 ] / 127 ); // x2 + array.push( interpolation[ index + 4 ] / 127 ); // y1 + array.push( interpolation[ index + 12 ] / 127 ); // y2 + + } + + var tracks = []; + + var motions = {}; + var bones = mesh.skeleton.bones; + var boneNameDictionary = {}; + + for ( var i = 0, il = bones.length; i < il; i ++ ) { + + boneNameDictionary[ bones[ i ].name ] = true; + + } + + for ( var i = 0; i < vmd.metadata.motionCount; i ++ ) { + + var motion = vmd.motions[ i ]; + var boneName = motion.boneName; + + if ( boneNameDictionary[ boneName ] === undefined ) continue; + + motions[ boneName ] = motions[ boneName ] || []; + motions[ boneName ].push( motion ); + + } + + for ( var key in motions ) { + + var array = motions[ key ]; + + array.sort( function ( a, b ) { + + return a.frameNum - b.frameNum; + + } ); + + var times = []; + var positions = []; + var rotations = []; + var pInterpolations = []; + var rInterpolations = []; + + var basePosition = mesh.skeleton.getBoneByName( key ).position.toArray(); + + for ( var i = 0, il = array.length; i < il; i ++ ) { + + var time = array[ i ].frameNum / 30; + var position = array[ i ].position; + var rotation = array[ i ].rotation; + var interpolation = array[ i ].interpolation; + + times.push( time ); + + for ( var j = 0; j < 3; j ++ ) positions.push( basePosition[ j ] + position[ j ] ); + for ( var j = 0; j < 4; j ++ ) rotations.push( rotation[ j ] ); + for ( var j = 0; j < 3; j ++ ) pushInterpolation( pInterpolations, interpolation, j ); + + pushInterpolation( rInterpolations, interpolation, 3 ); + + } + + var targetName = '.bones[' + key + ']'; + + tracks.push( this._createTrack( targetName + '.position', THREE.VectorKeyframeTrack, times, positions, pInterpolations ) ); + tracks.push( this._createTrack( targetName + '.quaternion', THREE.QuaternionKeyframeTrack, times, rotations, rInterpolations ) ); + + } + + return new THREE.AnimationClip( '', - 1, tracks ); + + }, + + /** + * @param {Object} vmd - parsed VMD data + * @param {THREE.SkinnedMesh} mesh - tracks will be fitting to mesh + * @return {THREE.AnimationClip} + */ + buildMorphAnimation: function ( vmd, mesh ) { + + var tracks = []; + + var morphs = {}; + var morphTargetDictionary = mesh.morphTargetDictionary; + + for ( var i = 0; i < vmd.metadata.morphCount; i ++ ) { + + var morph = vmd.morphs[ i ]; + var morphName = morph.morphName; + + if ( morphTargetDictionary[ morphName ] === undefined ) continue; + + morphs[ morphName ] = morphs[ morphName ] || []; + morphs[ morphName ].push( morph ); + + } + + for ( var key in morphs ) { + + var array = morphs[ key ]; + + array.sort( function ( a, b ) { + + return a.frameNum - b.frameNum; + + } ); + + var times = []; + var values = []; + + for ( var i = 0, il = array.length; i < il; i ++ ) { + + times.push( array[ i ].frameNum / 30 ); + values.push( array[ i ].weight ); + + } + + tracks.push( new THREE.NumberKeyframeTrack( '.morphTargetInfluences[' + morphTargetDictionary[ key ] + ']', times, values ) ); + + } + + return new THREE.AnimationClip( '', - 1, tracks ); + + }, + + /** + * @param {Object} vmd - parsed VMD data + * @return {THREE.AnimationClip} + */ + buildCameraAnimation: function ( vmd ) { + + function pushVector3( array, vec ) { + + array.push( vec.x ); + array.push( vec.y ); + array.push( vec.z ); + + } + + function pushQuaternion( array, q ) { + + array.push( q.x ); + array.push( q.y ); + array.push( q.z ); + array.push( q.w ); + + } + + function pushInterpolation( array, interpolation, index ) { + + array.push( interpolation[ index * 4 + 0 ] / 127 ); // x1 + array.push( interpolation[ index * 4 + 1 ] / 127 ); // x2 + array.push( interpolation[ index * 4 + 2 ] / 127 ); // y1 + array.push( interpolation[ index * 4 + 3 ] / 127 ); // y2 + + } + + var tracks = []; + + var cameras = vmd.cameras === undefined ? [] : vmd.cameras.slice(); + + cameras.sort( function ( a, b ) { + + return a.frameNum - b.frameNum; + + } ); + + var times = []; + var centers = []; + var quaternions = []; + var positions = []; + var fovs = []; + + var cInterpolations = []; + var qInterpolations = []; + var pInterpolations = []; + var fInterpolations = []; + + var quaternion = new THREE.Quaternion(); + var euler = new THREE.Euler(); + var position = new THREE.Vector3(); + var center = new THREE.Vector3(); + + for ( var i = 0, il = cameras.length; i < il; i ++ ) { + + var motion = cameras[ i ]; + + var time = motion.frameNum / 30; + var pos = motion.position; + var rot = motion.rotation; + var distance = motion.distance; + var fov = motion.fov; + var interpolation = motion.interpolation; + + times.push( time ); + + position.set( 0, 0, - distance ); + center.set( pos[ 0 ], pos[ 1 ], pos[ 2 ] ); + + euler.set( - rot[ 0 ], - rot[ 1 ], - rot[ 2 ] ); + quaternion.setFromEuler( euler ); + + position.add( center ); + position.applyQuaternion( quaternion ); + + pushVector3( centers, center ); + pushQuaternion( quaternions, quaternion ); + pushVector3( positions, position ); + + fovs.push( fov ); + + for ( var j = 0; j < 3; j ++ ) { + + pushInterpolation( cInterpolations, interpolation, j ); + + } + + pushInterpolation( qInterpolations, interpolation, 3 ); + + // use the same parameter for x, y, z axis. + for ( var j = 0; j < 3; j ++ ) { + + pushInterpolation( pInterpolations, interpolation, 4 ); + + } + + pushInterpolation( fInterpolations, interpolation, 5 ); + + } + + var tracks = []; + + // I expect an object whose name 'target' exists under THREE.Camera + tracks.push( this._createTrack( 'target.position', THREE.VectorKeyframeTrack, times, centers, cInterpolations ) ); + + tracks.push( this._createTrack( '.quaternion', THREE.QuaternionKeyframeTrack, times, quaternions, qInterpolations ) ); + tracks.push( this._createTrack( '.position', THREE.VectorKeyframeTrack, times, positions, pInterpolations ) ); + tracks.push( this._createTrack( '.fov', THREE.NumberKeyframeTrack, times, fovs, fInterpolations ) ); + + return new THREE.AnimationClip( '', - 1, tracks ); + + }, + + // private method + + _createTrack: function ( node, typedKeyframeTrack, times, values, interpolations ) { + + /* + * optimizes here not to let KeyframeTrackPrototype optimize + * because KeyframeTrackPrototype optimizes times and values but + * doesn't optimize interpolations. + */ + if ( times.length > 2 ) { + + times = times.slice(); + values = values.slice(); + interpolations = interpolations.slice(); + + var stride = values.length / times.length; + var interpolateStride = interpolations.length / times.length; + + var index = 1; + + for ( var aheadIndex = 2, endIndex = times.length; aheadIndex < endIndex; aheadIndex ++ ) { + + for ( var i = 0; i < stride; i ++ ) { + + if ( values[ index * stride + i ] !== values[ ( index - 1 ) * stride + i ] || + values[ index * stride + i ] !== values[ aheadIndex * stride + i ] ) { + + index ++; + break; + + } + + } + + if ( aheadIndex > index ) { + + times[ index ] = times[ aheadIndex ]; + + for ( var i = 0; i < stride; i ++ ) { + + values[ index * stride + i ] = values[ aheadIndex * stride + i ]; + + } + + for ( var i = 0; i < interpolateStride; i ++ ) { + + interpolations[ index * interpolateStride + i ] = interpolations[ aheadIndex * interpolateStride + i ]; + + } + + } + + } + + times.length = index + 1; + values.length = ( index + 1 ) * stride; + interpolations.length = ( index + 1 ) * interpolateStride; + + } + + var track = new typedKeyframeTrack( node, times, values ); + + track.createInterpolant = function InterpolantFactoryMethodCubicBezier( result ) { + + return new CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, new Float32Array( interpolations ) ); + + }; + + return track; + + } + + }; + + // interpolation + + function CubicBezierInterpolation( parameterPositions, sampleValues, sampleSize, resultBuffer, params ) { + + THREE.Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); + + this.interpolationParams = params; + + } + + CubicBezierInterpolation.prototype = Object.assign( Object.create( THREE.Interpolant.prototype ), { + + constructor: CubicBezierInterpolation, + + interpolate_: function ( i1, t0, t, t1 ) { + + var result = this.resultBuffer; + var values = this.sampleValues; + var stride = this.valueSize; + var params = this.interpolationParams; + + var offset1 = i1 * stride; + var offset0 = offset1 - stride; + + // No interpolation if next key frame is in one frame in 30fps. + // This is from MMD animation spec. + // '1.5' is for precision loss. times are Float32 in Three.js Animation system. + var weight1 = ( ( t1 - t0 ) < 1 / 30 * 1.5 ) ? 0.0 : ( t - t0 ) / ( t1 - t0 ); + + if ( stride === 4 ) { // Quaternion + + var x1 = params[ i1 * 4 + 0 ]; + var x2 = params[ i1 * 4 + 1 ]; + var y1 = params[ i1 * 4 + 2 ]; + var y2 = params[ i1 * 4 + 3 ]; + + var ratio = this._calculate( x1, x2, y1, y2, weight1 ); + + THREE.Quaternion.slerpFlat( result, 0, values, offset0, values, offset1, ratio ); + + } else if ( stride === 3 ) { // Vector3 + + for ( var i = 0; i !== stride; ++ i ) { + + var x1 = params[ i1 * 12 + i * 4 + 0 ]; + var x2 = params[ i1 * 12 + i * 4 + 1 ]; + var y1 = params[ i1 * 12 + i * 4 + 2 ]; + var y2 = params[ i1 * 12 + i * 4 + 3 ]; + + var ratio = this._calculate( x1, x2, y1, y2, weight1 ); + + result[ i ] = values[ offset0 + i ] * ( 1 - ratio ) + values[ offset1 + i ] * ratio; + + } + + } else { // Number + + var x1 = params[ i1 * 4 + 0 ]; + var x2 = params[ i1 * 4 + 1 ]; + var y1 = params[ i1 * 4 + 2 ]; + var y2 = params[ i1 * 4 + 3 ]; + + var ratio = this._calculate( x1, x2, y1, y2, weight1 ); + + result[ 0 ] = values[ offset0 ] * ( 1 - ratio ) + values[ offset1 ] * ratio; + + } + + return result; + + }, + + _calculate: function ( x1, x2, y1, y2, x ) { + + /* + * Cubic Bezier curves + * https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves + * + * B(t) = ( 1 - t ) ^ 3 * P0 + * + 3 * ( 1 - t ) ^ 2 * t * P1 + * + 3 * ( 1 - t ) * t^2 * P2 + * + t ^ 3 * P3 + * ( 0 <= t <= 1 ) + * + * MMD uses Cubic Bezier curves for bone and camera animation interpolation. + * http://d.hatena.ne.jp/edvakf/20111016/1318716097 + * + * x = ( 1 - t ) ^ 3 * x0 + * + 3 * ( 1 - t ) ^ 2 * t * x1 + * + 3 * ( 1 - t ) * t^2 * x2 + * + t ^ 3 * x3 + * y = ( 1 - t ) ^ 3 * y0 + * + 3 * ( 1 - t ) ^ 2 * t * y1 + * + 3 * ( 1 - t ) * t^2 * y2 + * + t ^ 3 * y3 + * ( x0 = 0, y0 = 0 ) + * ( x3 = 1, y3 = 1 ) + * ( 0 <= t, x1, x2, y1, y2 <= 1 ) + * + * Here solves this equation with Bisection method, + * https://en.wikipedia.org/wiki/Bisection_method + * gets t, and then calculate y. + * + * f(t) = 3 * ( 1 - t ) ^ 2 * t * x1 + * + 3 * ( 1 - t ) * t^2 * x2 + * + t ^ 3 - x = 0 + * + * (Another option: Newton's method + * https://en.wikipedia.org/wiki/Newton%27s_method) + */ + + var c = 0.5; + var t = c; + var s = 1.0 - t; + var loop = 15; + var eps = 1e-5; + var math = Math; + + var sst3, stt3, ttt; + + for ( var i = 0; i < loop; i ++ ) { + + sst3 = 3.0 * s * s * t; + stt3 = 3.0 * s * t * t; + ttt = t * t * t; + + var ft = ( sst3 * x1 ) + ( stt3 * x2 ) + ( ttt ) - x; + + if ( math.abs( ft ) < eps ) break; + + c /= 2.0; + + t += ( ft < 0 ) ? c : - c; + s = 1.0 - t; + + } + + return ( sst3 * y1 ) + ( stt3 * y2 ) + ttt; + + } + + } ); + + return MMDLoader; + +} )(); diff --git a/three/jsutil/loaders/MTLLoader.js b/three/jsutil/loaders/MTLLoader.js new file mode 100644 index 000000000..9c39b2451 --- /dev/null +++ b/three/jsutil/loaders/MTLLoader.js @@ -0,0 +1,568 @@ +/** + * Loads a Wavefront .mtl file specifying materials + * + * @author angelxuanchang + */ + +THREE.MTLLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.MTLLoader.prototype = { + + constructor: THREE.MTLLoader, + + /** + * Loads and parses a MTL asset from a URL. + * + * @param {String} url - URL to the MTL file. + * @param {Function} [onLoad] - Callback invoked with the loaded object. + * @param {Function} [onProgress] - Callback for download progress. + * @param {Function} [onError] - Callback for download errors. + * + * @see setPath setResourcePath + * + * @note In order for relative texture references to resolve correctly + * you must call setResourcePath() explicitly prior to load. + */ + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var path = ( this.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path; + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( this.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text, path ) ); + + }, onProgress, onError ); + + }, + + /** + * Set base path for resolving references. + * If set this path will be prepended to each loaded and found reference. + * + * @see setResourcePath + * @param {String} path + * @return {THREE.MTLLoader} + * + * @example + * mtlLoader.setPath( 'assets/obj/' ); + * mtlLoader.load( 'my.mtl', ... ); + */ + setPath: function ( path ) { + + this.path = path; + return this; + + }, + + /** + * Set base path for additional resources like textures. + * + * @see setPath + * @param {String} path + * @return {THREE.MTLLoader} + * + * @example + * mtlLoader.setPath( 'assets/obj/' ); + * mtlLoader.setResourcePath( 'assets/textures/' ); + * mtlLoader.load( 'my.mtl', ... ); + */ + setResourcePath: function ( path ) { + + this.resourcePath = path; + return this; + + }, + + setTexturePath: function ( path ) { + + console.warn( 'THREE.MTLLoader: .setTexturePath() has been renamed to .setResourcePath().' ); + return this.setResourcePath( path ); + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + setMaterialOptions: function ( value ) { + + this.materialOptions = value; + return this; + + }, + + /** + * Parses a MTL file. + * + * @param {String} text - Content of MTL file + * @return {THREE.MTLLoader.MaterialCreator} + * + * @see setPath setResourcePath + * + * @note In order for relative texture references to resolve correctly + * you must call setResourcePath() explicitly prior to parse. + */ + parse: function ( text, path ) { + + var lines = text.split( '\n' ); + var info = {}; + var delimiter_pattern = /\s+/; + var materialsInfo = {}; + + for ( var i = 0; i < lines.length; i ++ ) { + + var line = lines[ i ]; + line = line.trim(); + + if ( line.length === 0 || line.charAt( 0 ) === '#' ) { + + // Blank line or comment ignore + continue; + + } + + var pos = line.indexOf( ' ' ); + + var key = ( pos >= 0 ) ? line.substring( 0, pos ) : line; + key = key.toLowerCase(); + + var value = ( pos >= 0 ) ? line.substring( pos + 1 ) : ''; + value = value.trim(); + + if ( key === 'newmtl' ) { + + // New material + + info = { name: value }; + materialsInfo[ value ] = info; + + } else { + + if ( key === 'ka' || key === 'kd' || key === 'ks' ) { + + var ss = value.split( delimiter_pattern, 3 ); + info[ key ] = [ parseFloat( ss[ 0 ] ), parseFloat( ss[ 1 ] ), parseFloat( ss[ 2 ] ) ]; + + } else { + + info[ key ] = value; + + } + + } + + } + + var materialCreator = new THREE.MTLLoader.MaterialCreator( this.resourcePath || path, this.materialOptions ); + materialCreator.setCrossOrigin( this.crossOrigin ); + materialCreator.setManager( this.manager ); + materialCreator.setMaterials( materialsInfo ); + return materialCreator; + + } + +}; + +/** + * Create a new THREE-MTLLoader.MaterialCreator + * @param baseUrl - Url relative to which textures are loaded + * @param options - Set of options on how to construct the materials + * side: Which side to apply the material + * THREE.FrontSide (default), THREE.BackSide, THREE.DoubleSide + * wrap: What type of wrapping to apply for textures + * THREE.RepeatWrapping (default), THREE.ClampToEdgeWrapping, THREE.MirroredRepeatWrapping + * normalizeRGB: RGBs need to be normalized to 0-1 from 0-255 + * Default: false, assumed to be already normalized + * ignoreZeroRGBs: Ignore values of RGBs (Ka,Kd,Ks) that are all 0's + * Default: false + * @constructor + */ + +THREE.MTLLoader.MaterialCreator = function ( baseUrl, options ) { + + this.baseUrl = baseUrl || ''; + this.options = options; + this.materialsInfo = {}; + this.materials = {}; + this.materialsArray = []; + this.nameLookup = {}; + + this.side = ( this.options && this.options.side ) ? this.options.side : THREE.FrontSide; + this.wrap = ( this.options && this.options.wrap ) ? this.options.wrap : THREE.RepeatWrapping; + +}; + +THREE.MTLLoader.MaterialCreator.prototype = { + + constructor: THREE.MTLLoader.MaterialCreator, + + crossOrigin: 'anonymous', + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + setManager: function ( value ) { + + this.manager = value; + + }, + + setMaterials: function ( materialsInfo ) { + + this.materialsInfo = this.convert( materialsInfo ); + this.materials = {}; + this.materialsArray = []; + this.nameLookup = {}; + + }, + + convert: function ( materialsInfo ) { + + if ( ! this.options ) return materialsInfo; + + var converted = {}; + + for ( var mn in materialsInfo ) { + + // Convert materials info into normalized form based on options + + var mat = materialsInfo[ mn ]; + + var covmat = {}; + + converted[ mn ] = covmat; + + for ( var prop in mat ) { + + var save = true; + var value = mat[ prop ]; + var lprop = prop.toLowerCase(); + + switch ( lprop ) { + + case 'kd': + case 'ka': + case 'ks': + + // Diffuse color (color under white light) using RGB values + + if ( this.options && this.options.normalizeRGB ) { + + value = [ value[ 0 ] / 255, value[ 1 ] / 255, value[ 2 ] / 255 ]; + + } + + if ( this.options && this.options.ignoreZeroRGBs ) { + + if ( value[ 0 ] === 0 && value[ 1 ] === 0 && value[ 2 ] === 0 ) { + + // ignore + + save = false; + + } + + } + + break; + + default: + + break; + + } + + if ( save ) { + + covmat[ lprop ] = value; + + } + + } + + } + + return converted; + + }, + + preload: function () { + + for ( var mn in this.materialsInfo ) { + + this.create( mn ); + + } + + }, + + getIndex: function ( materialName ) { + + return this.nameLookup[ materialName ]; + + }, + + getAsArray: function () { + + var index = 0; + + for ( var mn in this.materialsInfo ) { + + this.materialsArray[ index ] = this.create( mn ); + this.nameLookup[ mn ] = index; + index ++; + + } + + return this.materialsArray; + + }, + + create: function ( materialName ) { + + if ( this.materials[ materialName ] === undefined ) { + + this.createMaterial_( materialName ); + + } + + return this.materials[ materialName ]; + + }, + + createMaterial_: function ( materialName ) { + + // Create material + + var scope = this; + var mat = this.materialsInfo[ materialName ]; + var params = { + + name: materialName, + side: this.side + + }; + + function resolveURL( baseUrl, url ) { + + if ( typeof url !== 'string' || url === '' ) + return ''; + + // Absolute URL + if ( /^https?:\/\//i.test( url ) ) return url; + + return baseUrl + url; + + } + + function setMapForType( mapType, value ) { + + if ( params[ mapType ] ) return; // Keep the first encountered texture + + var texParams = scope.getTextureParams( value, params ); + var map = scope.loadTexture( resolveURL( scope.baseUrl, texParams.url ) ); + + map.repeat.copy( texParams.scale ); + map.offset.copy( texParams.offset ); + + map.wrapS = scope.wrap; + map.wrapT = scope.wrap; + + params[ mapType ] = map; + + } + + for ( var prop in mat ) { + + var value = mat[ prop ]; + var n; + + if ( value === '' ) continue; + + switch ( prop.toLowerCase() ) { + + // Ns is material specular exponent + + case 'kd': + + // Diffuse color (color under white light) using RGB values + + params.color = new THREE.Color().fromArray( value ); + + break; + + case 'ks': + + // Specular color (color when light is reflected from shiny surface) using RGB values + params.specular = new THREE.Color().fromArray( value ); + + break; + + case 'map_kd': + + // Diffuse texture map + + setMapForType( "map", value ); + + break; + + case 'map_ks': + + // Specular map + + setMapForType( "specularMap", value ); + + break; + + case 'norm': + + setMapForType( "normalMap", value ); + + break; + + case 'map_bump': + case 'bump': + + // Bump texture map + + setMapForType( "bumpMap", value ); + + break; + + case 'map_d': + + // Alpha map + + setMapForType( "alphaMap", value ); + params.transparent = true; + + break; + + case 'ns': + + // The specular exponent (defines the focus of the specular highlight) + // A high exponent results in a tight, concentrated highlight. Ns values normally range from 0 to 1000. + + params.shininess = parseFloat( value ); + + break; + + case 'd': + n = parseFloat( value ); + + if ( n < 1 ) { + + params.opacity = n; + params.transparent = true; + + } + + break; + + case 'tr': + n = parseFloat( value ); + + if ( this.options && this.options.invertTrProperty ) n = 1 - n; + + if ( n > 0 ) { + + params.opacity = 1 - n; + params.transparent = true; + + } + + break; + + default: + break; + + } + + } + + this.materials[ materialName ] = new THREE.MeshPhongMaterial( params ); + return this.materials[ materialName ]; + + }, + + getTextureParams: function ( value, matParams ) { + + var texParams = { + + scale: new THREE.Vector2( 1, 1 ), + offset: new THREE.Vector2( 0, 0 ) + + }; + + var items = value.split( /\s+/ ); + var pos; + + pos = items.indexOf( '-bm' ); + + if ( pos >= 0 ) { + + matParams.bumpScale = parseFloat( items[ pos + 1 ] ); + items.splice( pos, 2 ); + + } + + pos = items.indexOf( '-s' ); + + if ( pos >= 0 ) { + + texParams.scale.set( parseFloat( items[ pos + 1 ] ), parseFloat( items[ pos + 2 ] ) ); + items.splice( pos, 4 ); // we expect 3 parameters here! + + } + + pos = items.indexOf( '-o' ); + + if ( pos >= 0 ) { + + texParams.offset.set( parseFloat( items[ pos + 1 ] ), parseFloat( items[ pos + 2 ] ) ); + items.splice( pos, 4 ); // we expect 3 parameters here! + + } + + texParams.url = items.join( ' ' ).trim(); + return texParams; + + }, + + loadTexture: function ( url, mapping, onLoad, onProgress, onError ) { + + var texture; + var loader = THREE.Loader.Handlers.get( url ); + var manager = ( this.manager !== undefined ) ? this.manager : THREE.DefaultLoadingManager; + + if ( loader === null ) { + + loader = new THREE.TextureLoader( manager ); + + } + + if ( loader.setCrossOrigin ) loader.setCrossOrigin( this.crossOrigin ); + texture = loader.load( url, onLoad, onProgress, onError ); + + if ( mapping !== undefined ) texture.mapping = mapping; + + return texture; + + } + +}; diff --git a/three/jsutil/loaders/NRRDLoader.js b/three/jsutil/loaders/NRRDLoader.js new file mode 100644 index 000000000..e22c234cd --- /dev/null +++ b/three/jsutil/loaders/NRRDLoader.js @@ -0,0 +1,599 @@ +THREE.NRRDLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + +}; + +THREE.NRRDLoader.prototype = { + + constructor: THREE.NRRDLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( data ) { + + onLoad( scope.parse( data ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + // this parser is largely inspired from the XTK NRRD parser : https://github.com/xtk/X + + var _data = data; + + var _dataPointer = 0; + + var _nativeLittleEndian = new Int8Array( new Int16Array( [ 1 ] ).buffer )[ 0 ] > 0; + + var _littleEndian = true; + + var headerObject = {}; + + function scan( type, chunks ) { + + if ( chunks === undefined || chunks === null ) { + + chunks = 1; + + } + + var _chunkSize = 1; + var _array_type = Uint8Array; + + switch ( type ) { + + // 1 byte data types + case 'uchar': + break; + case 'schar': + _array_type = Int8Array; + break; + // 2 byte data types + case 'ushort': + _array_type = Uint16Array; + _chunkSize = 2; + break; + case 'sshort': + _array_type = Int16Array; + _chunkSize = 2; + break; + // 4 byte data types + case 'uint': + _array_type = Uint32Array; + _chunkSize = 4; + break; + case 'sint': + _array_type = Int32Array; + _chunkSize = 4; + break; + case 'float': + _array_type = Float32Array; + _chunkSize = 4; + break; + case 'complex': + _array_type = Float64Array; + _chunkSize = 8; + break; + case 'double': + _array_type = Float64Array; + _chunkSize = 8; + break; + + } + + // increase the data pointer in-place + var _bytes = new _array_type( _data.slice( _dataPointer, + _dataPointer += chunks * _chunkSize ) ); + + // if required, flip the endianness of the bytes + if ( _nativeLittleEndian != _littleEndian ) { + + // we need to flip here since the format doesn't match the native endianness + _bytes = flipEndianness( _bytes, _chunkSize ); + + } + + if ( chunks == 1 ) { + + // if only one chunk was requested, just return one value + return _bytes[ 0 ]; + + } + + // return the byte array + return _bytes; + + } + + //Flips typed array endianness in-place. Based on https://github.com/kig/DataStream.js/blob/master/DataStream.js. + + function flipEndianness( array, chunkSize ) { + + var u8 = new Uint8Array( array.buffer, array.byteOffset, array.byteLength ); + for ( var i = 0; i < array.byteLength; i += chunkSize ) { + + for ( var j = i + chunkSize - 1, k = i; j > k; j --, k ++ ) { + + var tmp = u8[ k ]; + u8[ k ] = u8[ j ]; + u8[ j ] = tmp; + + } + + } + + return array; + + } + + //parse the header + function parseHeader( header ) { + + var data, field, fn, i, l, lines, m, _i, _len; + lines = header.split( /\r?\n/ ); + for ( _i = 0, _len = lines.length; _i < _len; _i ++ ) { + + l = lines[ _i ]; + if ( l.match( /NRRD\d+/ ) ) { + + headerObject.isNrrd = true; + + } else if ( l.match( /^#/ ) ) { + } else if ( m = l.match( /(.*):(.*)/ ) ) { + + field = m[ 1 ].trim(); + data = m[ 2 ].trim(); + fn = THREE.NRRDLoader.prototype.fieldFunctions[ field ]; + if ( fn ) { + + fn.call( headerObject, data ); + + } else { + + headerObject[ field ] = data; + + } + + } + + } + if ( ! headerObject.isNrrd ) { + + throw new Error( 'Not an NRRD file' ); + + } + if ( headerObject.encoding === 'bz2' || headerObject.encoding === 'bzip2' ) { + + throw new Error( 'Bzip is not supported' ); + + } + if ( ! headerObject.vectors ) { + + //if no space direction is set, let's use the identity + headerObject.vectors = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ]; + //apply spacing if defined + if ( headerObject.spacings ) { + + for ( i = 0; i <= 2; i ++ ) { + + if ( ! isNaN( headerObject.spacings[ i ] ) ) { + + headerObject.vectors[ i ].multiplyScalar( headerObject.spacings[ i ] ); + + } + + } + + } + + } + + } + + //parse the data when registred as one of this type : 'text', 'ascii', 'txt' + function parseDataAsText( data, start, end ) { + + var number = ''; + start = start || 0; + end = end || data.length; + var value; + //length of the result is the product of the sizes + var lengthOfTheResult = headerObject.sizes.reduce( function ( previous, current ) { + + return previous * current; + + }, 1 ); + + var base = 10; + if ( headerObject.encoding === 'hex' ) { + + base = 16; + + } + + var result = new headerObject.__array( lengthOfTheResult ); + var resultIndex = 0; + var parsingFunction = parseInt; + if ( headerObject.__array === Float32Array || headerObject.__array === Float64Array ) { + + parsingFunction = parseFloat; + + } + for ( var i = start; i < end; i ++ ) { + + value = data[ i ]; + //if value is not a space + if ( ( value < 9 || value > 13 ) && value !== 32 ) { + + number += String.fromCharCode( value ); + + } else { + + if ( number !== '' ) { + + result[ resultIndex ] = parsingFunction( number, base ); + resultIndex ++; + + } + number = ''; + + } + + } + if ( number !== '' ) { + + result[ resultIndex ] = parsingFunction( number, base ); + resultIndex ++; + + } + return result; + + } + + var _bytes = scan( 'uchar', data.byteLength ); + var _length = _bytes.length; + var _header = null; + var _data_start = 0; + var i; + for ( i = 1; i < _length; i ++ ) { + + if ( _bytes[ i - 1 ] == 10 && _bytes[ i ] == 10 ) { + + // we found two line breaks in a row + // now we know what the header is + _header = this.parseChars( _bytes, 0, i - 2 ); + // this is were the data starts + _data_start = i + 1; + break; + + } + + } + // parse the header + parseHeader( _header ); + + var _data = _bytes.subarray( _data_start ); // the data without header + if ( headerObject.encoding === 'gzip' || headerObject.encoding === 'gz' ) { + + // we need to decompress the datastream + // here we start the unzipping and get a typed Uint8Array back + var inflate = new Zlib.Gunzip( new Uint8Array( _data ) ); // eslint-disable-line no-undef + _data = inflate.decompress(); + + } else if ( headerObject.encoding === 'ascii' || headerObject.encoding === 'text' || headerObject.encoding === 'txt' || headerObject.encoding === 'hex' ) { + + _data = parseDataAsText( _data ); + + } else if ( headerObject.encoding === 'raw' ) { + + //we need to copy the array to create a new array buffer, else we retrieve the original arraybuffer with the header + var _copy = new Uint8Array( _data.length ); + + for ( var i = 0; i < _data.length; i ++ ) { + + _copy[ i ] = _data[ i ]; + + } + + _data = _copy; + + } + // .. let's use the underlying array buffer + _data = _data.buffer; + + var volume = new THREE.Volume(); + volume.header = headerObject; + // + // parse the (unzipped) data to a datastream of the correct type + // + volume.data = new headerObject.__array( _data ); + // get the min and max intensities + var min_max = volume.computeMinMax(); + var min = min_max[ 0 ]; + var max = min_max[ 1 ]; + // attach the scalar range to the volume + volume.windowLow = min; + volume.windowHigh = max; + + // get the image dimensions + volume.dimensions = [ headerObject.sizes[ 0 ], headerObject.sizes[ 1 ], headerObject.sizes[ 2 ] ]; + volume.xLength = volume.dimensions[ 0 ]; + volume.yLength = volume.dimensions[ 1 ]; + volume.zLength = volume.dimensions[ 2 ]; + // spacing + var spacingX = ( new THREE.Vector3( headerObject.vectors[ 0 ][ 0 ], headerObject.vectors[ 0 ][ 1 ], + headerObject.vectors[ 0 ][ 2 ] ) ).length(); + var spacingY = ( new THREE.Vector3( headerObject.vectors[ 1 ][ 0 ], headerObject.vectors[ 1 ][ 1 ], + headerObject.vectors[ 1 ][ 2 ] ) ).length(); + var spacingZ = ( new THREE.Vector3( headerObject.vectors[ 2 ][ 0 ], headerObject.vectors[ 2 ][ 1 ], + headerObject.vectors[ 2 ][ 2 ] ) ).length(); + volume.spacing = [ spacingX, spacingY, spacingZ ]; + + + // Create IJKtoRAS matrix + volume.matrix = new THREE.Matrix4(); + + var _spaceX = 1; + var _spaceY = 1; + var _spaceZ = 1; + + if ( headerObject.space == "left-posterior-superior" ) { + + _spaceX = - 1; + _spaceY = - 1; + + } else if ( headerObject.space === 'left-anterior-superior' ) { + + _spaceX = - 1; + + } + + + if ( ! headerObject.vectors ) { + + volume.matrix.set( + _spaceX, 0, 0, 0, + 0, _spaceY, 0, 0, + 0, 0, _spaceZ, 0, + 0, 0, 0, 1 ); + + } else { + + var v = headerObject.vectors; + + volume.matrix.set( + _spaceX * v[ 0 ][ 0 ], _spaceX * v[ 1 ][ 0 ], _spaceX * v[ 2 ][ 0 ], 0, + _spaceY * v[ 0 ][ 1 ], _spaceY * v[ 1 ][ 1 ], _spaceY * v[ 2 ][ 1 ], 0, + _spaceZ * v[ 0 ][ 2 ], _spaceZ * v[ 1 ][ 2 ], _spaceZ * v[ 2 ][ 2 ], 0, + 0, 0, 0, 1 ); + + } + + volume.inverseMatrix = new THREE.Matrix4(); + volume.inverseMatrix.getInverse( volume.matrix ); + volume.RASDimensions = ( new THREE.Vector3( volume.xLength, volume.yLength, volume.zLength ) ).applyMatrix4( volume.matrix ).round().toArray().map( Math.abs ); + + // .. and set the default threshold + // only if the threshold was not already set + if ( volume.lowerThreshold === - Infinity ) { + + volume.lowerThreshold = min; + + } + if ( volume.upperThreshold === Infinity ) { + + volume.upperThreshold = max; + + } + + return volume; + + }, + + parseChars: function ( array, start, end ) { + + // without borders, use the whole array + if ( start === undefined ) { + + start = 0; + + } + if ( end === undefined ) { + + end = array.length; + + } + + var output = ''; + // create and append the chars + var i = 0; + for ( i = start; i < end; ++ i ) { + + output += String.fromCharCode( array[ i ] ); + + } + + return output; + + }, + + fieldFunctions: { + + type: function ( data ) { + + switch ( data ) { + + case 'uchar': + case 'unsigned char': + case 'uint8': + case 'uint8_t': + this.__array = Uint8Array; + break; + case 'signed char': + case 'int8': + case 'int8_t': + this.__array = Int8Array; + break; + case 'short': + case 'short int': + case 'signed short': + case 'signed short int': + case 'int16': + case 'int16_t': + this.__array = Int16Array; + break; + case 'ushort': + case 'unsigned short': + case 'unsigned short int': + case 'uint16': + case 'uint16_t': + this.__array = Uint16Array; + break; + case 'int': + case 'signed int': + case 'int32': + case 'int32_t': + this.__array = Int32Array; + break; + case 'uint': + case 'unsigned int': + case 'uint32': + case 'uint32_t': + this.__array = Uint32Array; + break; + case 'float': + this.__array = Float32Array; + break; + case 'double': + this.__array = Float64Array; + break; + default: + throw new Error( 'Unsupported NRRD data type: ' + data ); + + } + + return this.type = data; + + }, + + endian: function ( data ) { + + return this.endian = data; + + }, + + encoding: function ( data ) { + + return this.encoding = data; + + }, + + dimension: function ( data ) { + + return this.dim = parseInt( data, 10 ); + + }, + + sizes: function ( data ) { + + var i; + return this.sizes = ( function () { + + var _i, _len, _ref, _results; + _ref = data.split( /\s+/ ); + _results = []; + for ( _i = 0, _len = _ref.length; _i < _len; _i ++ ) { + + i = _ref[ _i ]; + _results.push( parseInt( i, 10 ) ); + + } + return _results; + + } )(); + + }, + + space: function ( data ) { + + return this.space = data; + + }, + + 'space origin': function ( data ) { + + return this.space_origin = data.split( "(" )[ 1 ].split( ")" )[ 0 ].split( "," ); + + }, + + 'space directions': function ( data ) { + + var f, parts, v; + parts = data.match( /\(.*?\)/g ); + return this.vectors = ( function () { + + var _i, _len, _results; + _results = []; + for ( _i = 0, _len = parts.length; _i < _len; _i ++ ) { + + v = parts[ _i ]; + _results.push( ( function () { + + var _j, _len2, _ref, _results2; + _ref = v.slice( 1, - 1 ).split( /,/ ); + _results2 = []; + for ( _j = 0, _len2 = _ref.length; _j < _len2; _j ++ ) { + + f = _ref[ _j ]; + _results2.push( parseFloat( f ) ); + + } + return _results2; + + } )() ); + + } + return _results; + + } )(); + + }, + + spacings: function ( data ) { + + var f, parts; + parts = data.split( /\s+/ ); + return this.spacings = ( function () { + + var _i, _len, _results = []; + + for ( _i = 0, _len = parts.length; _i < _len; _i ++ ) { + + f = parts[ _i ]; + _results.push( parseFloat( f ) ); + + } + return _results; + + } )(); + + } + } + +}; diff --git a/three/jsutil/loaders/NodeMaterialLoader.js b/three/jsutil/loaders/NodeMaterialLoader.js new file mode 100644 index 000000000..db29336b1 --- /dev/null +++ b/three/jsutil/loaders/NodeMaterialLoader.js @@ -0,0 +1,265 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +THREE.NodeMaterialLoader = function ( manager, library ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.nodes = {}; + this.materials = {}; + this.passes = {}; + this.names = {}; + this.library = library || {}; + +}; + +THREE.NodeMaterialLoaderUtils = { + + replaceUUIDObject: function ( object, uuid, value, recursive ) { + + recursive = recursive !== undefined ? recursive : true; + + if ( typeof uuid === "object" ) uuid = uuid.uuid; + + if ( typeof object === "object" ) { + + var keys = Object.keys( object ); + + for ( var i = 0; i < keys.length; i ++ ) { + + var key = keys[ i ]; + + if ( recursive ) { + + object[ key ] = this.replaceUUIDObject( object[ key ], uuid, value ); + + } + + if ( key === uuid ) { + + object[ uuid ] = object[ key ]; + + delete object[ key ]; + + } + + } + + } + + return object === uuid ? value : object; + + }, + + replaceUUID: function ( json, uuid, value ) { + + this.replaceUUIDObject( json, uuid, value, false ); + this.replaceUUIDObject( json.nodes, uuid, value ); + this.replaceUUIDObject( json.materials, uuid, value ); + this.replaceUUIDObject( json.passes, uuid, value ); + this.replaceUUIDObject( json.library, uuid, value, false ); + + return json; + + } + +}; + +Object.assign( THREE.NodeMaterialLoader.prototype, { + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + }, onProgress, onError ); + + return this; + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + getObjectByName: function ( uuid ) { + + return this.names[ uuid ]; + + }, + + getObjectById: function ( uuid ) { + + return this.library[ uuid ] || + this.nodes[ uuid ] || + this.materials[ uuid ] || + this.passes[ uuid ] || + this.names[ uuid ]; + + }, + + getNode: function ( uuid ) { + + var object = this.getObjectById( uuid ); + + if ( ! object ) { + + console.warn( "Node \"" + uuid + "\" not found." ); + + } + + return object; + + }, + + resolve: function( json ) { + + switch( typeof json ) { + + case "boolean": + case "number": + + return json; + + case "string": + + if (/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i.test(json) || this.library[ json ]) { + + return this.getNode( json ); + + } + + return json; + + default: + + if ( Array.isArray( json ) ) { + + for(var i = 0; i < json.length; i++) { + + json[i] = this.resolve( json[i] ); + + } + + } else { + + for ( var prop in json ) { + + if (prop === "uuid") continue; + + json[ prop ] = this.resolve( json[ prop ] ); + + } + + } + + } + + return json; + + }, + + declare: function( json ) { + + var uuid, node, object; + + for ( uuid in json.nodes ) { + + node = json.nodes[ uuid ]; + + object = new THREE[ node.nodeType + "Node" ](); + + if ( node.name ) { + + object.name = node.name; + + this.names[ object.name ] = object; + + } + + this.nodes[ uuid ] = object; + + } + + for ( uuid in json.materials ) { + + node = json.materials[ uuid ]; + + object = new THREE[ node.type ](); + + if ( node.name ) { + + object.name = node.name; + + this.names[ object.name ] = object; + + } + + this.materials[ uuid ] = object; + + } + + for ( uuid in json.passes ) { + + node = json.passes[ uuid ]; + + object = new THREE[ node.type ](); + + if ( node.name ) { + + object.name = node.name; + + this.names[ object.name ] = object; + + } + + this.passes[ uuid ] = object; + + } + + if ( json.material ) this.material = this.materials[ json.material ]; + + if ( json.pass ) this.pass = this.passes[ json.pass ]; + + return json; + + }, + + parse: function ( json ) { + + var uuid; + + json = this.resolve( this.declare( json ) ); + + for ( uuid in json.nodes ) { + + this.nodes[ uuid ].copy( json.nodes[ uuid ] ); + + } + + for ( uuid in json.materials ) { + + this.materials[ uuid ].copy( json.materials[ uuid ] ); + + } + + for ( uuid in json.passes ) { + + this.passes[ uuid ].copy( json.passes[ uuid ] ); + + } + + return this.material || this.pass || this; + + } + +} ); diff --git a/three/jsutil/loaders/OBJLoader.js b/three/jsutil/loaders/OBJLoader.js new file mode 100644 index 000000000..15b1f90bf --- /dev/null +++ b/three/jsutil/loaders/OBJLoader.js @@ -0,0 +1,793 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.OBJLoader = ( function () { + + // o object_name | g group_name + var object_pattern = /^[og]\s*(.+)?/; + // mtllib file_reference + var material_library_pattern = /^mtllib /; + // usemtl material_name + var material_use_pattern = /^usemtl /; + + function ParserState() { + + var state = { + objects: [], + object: {}, + + vertices: [], + normals: [], + colors: [], + uvs: [], + + materialLibraries: [], + + startObject: function ( name, fromDeclaration ) { + + // If the current object (initial from reset) is not from a g/o declaration in the parsed + // file. We need to use it for the first parsed g/o to keep things in sync. + if ( this.object && this.object.fromDeclaration === false ) { + + this.object.name = name; + this.object.fromDeclaration = ( fromDeclaration !== false ); + return; + + } + + var previousMaterial = ( this.object && typeof this.object.currentMaterial === 'function' ? this.object.currentMaterial() : undefined ); + + if ( this.object && typeof this.object._finalize === 'function' ) { + + this.object._finalize( true ); + + } + + this.object = { + name: name || '', + fromDeclaration: ( fromDeclaration !== false ), + + geometry: { + vertices: [], + normals: [], + colors: [], + uvs: [] + }, + materials: [], + smooth: true, + + startMaterial: function ( name, libraries ) { + + var previous = this._finalize( false ); + + // New usemtl declaration overwrites an inherited material, except if faces were declared + // after the material, then it must be preserved for proper MultiMaterial continuation. + if ( previous && ( previous.inherited || previous.groupCount <= 0 ) ) { + + this.materials.splice( previous.index, 1 ); + + } + + var material = { + index: this.materials.length, + name: name || '', + mtllib: ( Array.isArray( libraries ) && libraries.length > 0 ? libraries[ libraries.length - 1 ] : '' ), + smooth: ( previous !== undefined ? previous.smooth : this.smooth ), + groupStart: ( previous !== undefined ? previous.groupEnd : 0 ), + groupEnd: - 1, + groupCount: - 1, + inherited: false, + + clone: function ( index ) { + + var cloned = { + index: ( typeof index === 'number' ? index : this.index ), + name: this.name, + mtllib: this.mtllib, + smooth: this.smooth, + groupStart: 0, + groupEnd: - 1, + groupCount: - 1, + inherited: false + }; + cloned.clone = this.clone.bind( cloned ); + return cloned; + + } + }; + + this.materials.push( material ); + + return material; + + }, + + currentMaterial: function () { + + if ( this.materials.length > 0 ) { + + return this.materials[ this.materials.length - 1 ]; + + } + + return undefined; + + }, + + _finalize: function ( end ) { + + var lastMultiMaterial = this.currentMaterial(); + if ( lastMultiMaterial && lastMultiMaterial.groupEnd === - 1 ) { + + lastMultiMaterial.groupEnd = this.geometry.vertices.length / 3; + lastMultiMaterial.groupCount = lastMultiMaterial.groupEnd - lastMultiMaterial.groupStart; + lastMultiMaterial.inherited = false; + + } + + // Ignore objects tail materials if no face declarations followed them before a new o/g started. + if ( end && this.materials.length > 1 ) { + + for ( var mi = this.materials.length - 1; mi >= 0; mi -- ) { + + if ( this.materials[ mi ].groupCount <= 0 ) { + + this.materials.splice( mi, 1 ); + + } + + } + + } + + // Guarantee at least one empty material, this makes the creation later more straight forward. + if ( end && this.materials.length === 0 ) { + + this.materials.push( { + name: '', + smooth: this.smooth + } ); + + } + + return lastMultiMaterial; + + } + }; + + // Inherit previous objects material. + // Spec tells us that a declared material must be set to all objects until a new material is declared. + // If a usemtl declaration is encountered while this new object is being parsed, it will + // overwrite the inherited material. Exception being that there was already face declarations + // to the inherited material, then it will be preserved for proper MultiMaterial continuation. + + if ( previousMaterial && previousMaterial.name && typeof previousMaterial.clone === 'function' ) { + + var declared = previousMaterial.clone( 0 ); + declared.inherited = true; + this.object.materials.push( declared ); + + } + + this.objects.push( this.object ); + + }, + + finalize: function () { + + if ( this.object && typeof this.object._finalize === 'function' ) { + + this.object._finalize( true ); + + } + + }, + + parseVertexIndex: function ( value, len ) { + + var index = parseInt( value, 10 ); + return ( index >= 0 ? index - 1 : index + len / 3 ) * 3; + + }, + + parseNormalIndex: function ( value, len ) { + + var index = parseInt( value, 10 ); + return ( index >= 0 ? index - 1 : index + len / 3 ) * 3; + + }, + + parseUVIndex: function ( value, len ) { + + var index = parseInt( value, 10 ); + return ( index >= 0 ? index - 1 : index + len / 2 ) * 2; + + }, + + addVertex: function ( a, b, c ) { + + var src = this.vertices; + var dst = this.object.geometry.vertices; + + dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] ); + dst.push( src[ b + 0 ], src[ b + 1 ], src[ b + 2 ] ); + dst.push( src[ c + 0 ], src[ c + 1 ], src[ c + 2 ] ); + + }, + + addVertexPoint: function ( a ) { + + var src = this.vertices; + var dst = this.object.geometry.vertices; + + dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] ); + + }, + + addVertexLine: function ( a ) { + + var src = this.vertices; + var dst = this.object.geometry.vertices; + + dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] ); + + }, + + addNormal: function ( a, b, c ) { + + var src = this.normals; + var dst = this.object.geometry.normals; + + dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] ); + dst.push( src[ b + 0 ], src[ b + 1 ], src[ b + 2 ] ); + dst.push( src[ c + 0 ], src[ c + 1 ], src[ c + 2 ] ); + + }, + + addColor: function ( a, b, c ) { + + var src = this.colors; + var dst = this.object.geometry.colors; + + dst.push( src[ a + 0 ], src[ a + 1 ], src[ a + 2 ] ); + dst.push( src[ b + 0 ], src[ b + 1 ], src[ b + 2 ] ); + dst.push( src[ c + 0 ], src[ c + 1 ], src[ c + 2 ] ); + + }, + + addUV: function ( a, b, c ) { + + var src = this.uvs; + var dst = this.object.geometry.uvs; + + dst.push( src[ a + 0 ], src[ a + 1 ] ); + dst.push( src[ b + 0 ], src[ b + 1 ] ); + dst.push( src[ c + 0 ], src[ c + 1 ] ); + + }, + + addUVLine: function ( a ) { + + var src = this.uvs; + var dst = this.object.geometry.uvs; + + dst.push( src[ a + 0 ], src[ a + 1 ] ); + + }, + + addFace: function ( a, b, c, ua, ub, uc, na, nb, nc ) { + + var vLen = this.vertices.length; + + var ia = this.parseVertexIndex( a, vLen ); + var ib = this.parseVertexIndex( b, vLen ); + var ic = this.parseVertexIndex( c, vLen ); + + this.addVertex( ia, ib, ic ); + + if ( ua !== undefined && ua !== '' ) { + + var uvLen = this.uvs.length; + ia = this.parseUVIndex( ua, uvLen ); + ib = this.parseUVIndex( ub, uvLen ); + ic = this.parseUVIndex( uc, uvLen ); + this.addUV( ia, ib, ic ); + + } + + if ( na !== undefined && na !== '' ) { + + // Normals are many times the same. If so, skip function call and parseInt. + var nLen = this.normals.length; + ia = this.parseNormalIndex( na, nLen ); + + ib = na === nb ? ia : this.parseNormalIndex( nb, nLen ); + ic = na === nc ? ia : this.parseNormalIndex( nc, nLen ); + + this.addNormal( ia, ib, ic ); + + } + + if ( this.colors.length > 0 ) { + + this.addColor( ia, ib, ic ); + + } + + }, + + addPointGeometry: function ( vertices ) { + + this.object.geometry.type = 'Points'; + + var vLen = this.vertices.length; + + for ( var vi = 0, l = vertices.length; vi < l; vi ++ ) { + + this.addVertexPoint( this.parseVertexIndex( vertices[ vi ], vLen ) ); + + } + + }, + + addLineGeometry: function ( vertices, uvs ) { + + this.object.geometry.type = 'Line'; + + var vLen = this.vertices.length; + var uvLen = this.uvs.length; + + for ( var vi = 0, l = vertices.length; vi < l; vi ++ ) { + + this.addVertexLine( this.parseVertexIndex( vertices[ vi ], vLen ) ); + + } + + for ( var uvi = 0, l = uvs.length; uvi < l; uvi ++ ) { + + this.addUVLine( this.parseUVIndex( uvs[ uvi ], uvLen ) ); + + } + + } + + }; + + state.startObject( '', false ); + + return state; + + } + + // + + function OBJLoader( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.materials = null; + + } + + OBJLoader.prototype = { + + constructor: OBJLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( this.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + + return this; + + }, + + setMaterials: function ( materials ) { + + this.materials = materials; + + return this; + + }, + + parse: function ( text ) { + + console.time( 'OBJLoader' ); + + var state = new ParserState(); + + if ( text.indexOf( '\r\n' ) !== - 1 ) { + + // This is faster than String.split with regex that splits on both + text = text.replace( /\r\n/g, '\n' ); + + } + + if ( text.indexOf( '\\\n' ) !== - 1 ) { + + // join lines separated by a line continuation character (\) + text = text.replace( /\\\n/g, '' ); + + } + + var lines = text.split( '\n' ); + var line = '', lineFirstChar = ''; + var lineLength = 0; + var result = []; + + // Faster to just trim left side of the line. Use if available. + var trimLeft = ( typeof ''.trimLeft === 'function' ); + + for ( var i = 0, l = lines.length; i < l; i ++ ) { + + line = lines[ i ]; + + line = trimLeft ? line.trimLeft() : line.trim(); + + lineLength = line.length; + + if ( lineLength === 0 ) continue; + + lineFirstChar = line.charAt( 0 ); + + // @todo invoke passed in handler if any + if ( lineFirstChar === '#' ) continue; + + if ( lineFirstChar === 'v' ) { + + var data = line.split( /\s+/ ); + + switch ( data[ 0 ] ) { + + case 'v': + state.vertices.push( + parseFloat( data[ 1 ] ), + parseFloat( data[ 2 ] ), + parseFloat( data[ 3 ] ) + ); + if ( data.length === 8 ) { + + state.colors.push( + parseFloat( data[ 4 ] ), + parseFloat( data[ 5 ] ), + parseFloat( data[ 6 ] ) + + ); + + } + break; + case 'vn': + state.normals.push( + parseFloat( data[ 1 ] ), + parseFloat( data[ 2 ] ), + parseFloat( data[ 3 ] ) + ); + break; + case 'vt': + state.uvs.push( + parseFloat( data[ 1 ] ), + parseFloat( data[ 2 ] ) + ); + break; + + } + + } else if ( lineFirstChar === 'f' ) { + + var lineData = line.substr( 1 ).trim(); + var vertexData = lineData.split( /\s+/ ); + var faceVertices = []; + + // Parse the face vertex data into an easy to work with format + + for ( var j = 0, jl = vertexData.length; j < jl; j ++ ) { + + var vertex = vertexData[ j ]; + + if ( vertex.length > 0 ) { + + var vertexParts = vertex.split( '/' ); + faceVertices.push( vertexParts ); + + } + + } + + // Draw an edge between the first vertex and all subsequent vertices to form an n-gon + + var v1 = faceVertices[ 0 ]; + + for ( var j = 1, jl = faceVertices.length - 1; j < jl; j ++ ) { + + var v2 = faceVertices[ j ]; + var v3 = faceVertices[ j + 1 ]; + + state.addFace( + v1[ 0 ], v2[ 0 ], v3[ 0 ], + v1[ 1 ], v2[ 1 ], v3[ 1 ], + v1[ 2 ], v2[ 2 ], v3[ 2 ] + ); + + } + + } else if ( lineFirstChar === 'l' ) { + + var lineParts = line.substring( 1 ).trim().split( " " ); + var lineVertices = [], lineUVs = []; + + if ( line.indexOf( "/" ) === - 1 ) { + + lineVertices = lineParts; + + } else { + + for ( var li = 0, llen = lineParts.length; li < llen; li ++ ) { + + var parts = lineParts[ li ].split( "/" ); + + if ( parts[ 0 ] !== "" ) lineVertices.push( parts[ 0 ] ); + if ( parts[ 1 ] !== "" ) lineUVs.push( parts[ 1 ] ); + + } + + } + state.addLineGeometry( lineVertices, lineUVs ); + + } else if ( lineFirstChar === 'p' ) { + + var lineData = line.substr( 1 ).trim(); + var pointData = lineData.split( " " ); + + state.addPointGeometry( pointData ); + + } else if ( ( result = object_pattern.exec( line ) ) !== null ) { + + // o object_name + // or + // g group_name + + // WORKAROUND: https://bugs.chromium.org/p/v8/issues/detail?id=2869 + // var name = result[ 0 ].substr( 1 ).trim(); + var name = ( " " + result[ 0 ].substr( 1 ).trim() ).substr( 1 ); + + state.startObject( name ); + + } else if ( material_use_pattern.test( line ) ) { + + // material + + state.object.startMaterial( line.substring( 7 ).trim(), state.materialLibraries ); + + } else if ( material_library_pattern.test( line ) ) { + + // mtl file + + state.materialLibraries.push( line.substring( 7 ).trim() ); + + } else if ( lineFirstChar === 's' ) { + + result = line.split( ' ' ); + + // smooth shading + + // @todo Handle files that have varying smooth values for a set of faces inside one geometry, + // but does not define a usemtl for each face set. + // This should be detected and a dummy material created (later MultiMaterial and geometry groups). + // This requires some care to not create extra material on each smooth value for "normal" obj files. + // where explicit usemtl defines geometry groups. + // Example asset: examples/models/obj/cerberus/Cerberus.obj + + /* + * http://paulbourke.net/dataformats/obj/ + * or + * http://www.cs.utah.edu/~boulos/cs3505/obj_spec.pdf + * + * From chapter "Grouping" Syntax explanation "s group_number": + * "group_number is the smoothing group number. To turn off smoothing groups, use a value of 0 or off. + * Polygonal elements use group numbers to put elements in different smoothing groups. For free-form + * surfaces, smoothing groups are either turned on or off; there is no difference between values greater + * than 0." + */ + if ( result.length > 1 ) { + + var value = result[ 1 ].trim().toLowerCase(); + state.object.smooth = ( value !== '0' && value !== 'off' ); + + } else { + + // ZBrush can produce "s" lines #11707 + state.object.smooth = true; + + } + var material = state.object.currentMaterial(); + if ( material ) material.smooth = state.object.smooth; + + } else { + + // Handle null terminated files without exception + if ( line === '\0' ) continue; + + throw new Error( 'THREE.OBJLoader: Unexpected line: "' + line + '"' ); + + } + + } + + state.finalize(); + + var container = new THREE.Group(); + container.materialLibraries = [].concat( state.materialLibraries ); + + for ( var i = 0, l = state.objects.length; i < l; i ++ ) { + + var object = state.objects[ i ]; + var geometry = object.geometry; + var materials = object.materials; + var isLine = ( geometry.type === 'Line' ); + var isPoints = ( geometry.type === 'Points' ); + var hasVertexColors = false; + + // Skip o/g line declarations that did not follow with any faces + if ( geometry.vertices.length === 0 ) continue; + + var buffergeometry = new THREE.BufferGeometry(); + + buffergeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( geometry.vertices, 3 ) ); + + if ( geometry.normals.length > 0 ) { + + buffergeometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( geometry.normals, 3 ) ); + + } else { + + buffergeometry.computeVertexNormals(); + + } + + if ( geometry.colors.length > 0 ) { + + hasVertexColors = true; + buffergeometry.addAttribute( 'color', new THREE.Float32BufferAttribute( geometry.colors, 3 ) ); + + } + + if ( geometry.uvs.length > 0 ) { + + buffergeometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( geometry.uvs, 2 ) ); + + } + + // Create materials + + var createdMaterials = []; + + for ( var mi = 0, miLen = materials.length; mi < miLen; mi ++ ) { + + var sourceMaterial = materials[ mi ]; + var material = undefined; + + if ( this.materials !== null ) { + + material = this.materials.create( sourceMaterial.name ); + + // mtl etc. loaders probably can't create line materials correctly, copy properties to a line material. + if ( isLine && material && ! ( material instanceof THREE.LineBasicMaterial ) ) { + + var materialLine = new THREE.LineBasicMaterial(); + materialLine.copy( material ); + materialLine.lights = false; // TOFIX + material = materialLine; + + } else if ( isPoints && material && ! ( material instanceof THREE.PointsMaterial ) ) { + + var materialPoints = new THREE.PointsMaterial( { size: 10, sizeAttenuation: false } ); + materialLine.copy( material ); + material = materialPoints; + + } + + } + + if ( ! material ) { + + if ( isLine ) { + + material = new THREE.LineBasicMaterial(); + + } else if ( isPoints ) { + + material = new THREE.PointsMaterial( { size: 1, sizeAttenuation: false } ); + + } else { + + material = new THREE.MeshPhongMaterial(); + + } + + material.name = sourceMaterial.name; + + } + + material.flatShading = sourceMaterial.smooth ? false : true; + material.vertexColors = hasVertexColors ? THREE.VertexColors : THREE.NoColors; + + createdMaterials.push( material ); + + } + + // Create mesh + + var mesh; + + if ( createdMaterials.length > 1 ) { + + for ( var mi = 0, miLen = materials.length; mi < miLen; mi ++ ) { + + var sourceMaterial = materials[ mi ]; + buffergeometry.addGroup( sourceMaterial.groupStart, sourceMaterial.groupCount, mi ); + + } + + if ( isLine ) { + + mesh = new THREE.LineSegments( buffergeometry, createdMaterials ); + + } else if ( isPoints ) { + + mesh = new THREE.Points( buffergeometry, createdMaterials ); + + } else { + + mesh = new THREE.Mesh( buffergeometry, createdMaterials ); + + } + + } else { + + if ( isLine ) { + + mesh = new THREE.LineSegments( buffergeometry, createdMaterials[ 0 ] ); + + } else if ( isPoints ) { + + mesh = new THREE.Points( buffergeometry, createdMaterials[ 0 ] ); + + } else { + + mesh = new THREE.Mesh( buffergeometry, createdMaterials[ 0 ] ); + + } + + } + + mesh.name = object.name; + + container.add( mesh ); + + } + + console.timeEnd( 'OBJLoader' ); + + return container; + + } + + }; + + return OBJLoader; + +} )(); diff --git a/three/jsutil/loaders/OBJLoader2.js b/three/jsutil/loaders/OBJLoader2.js new file mode 100644 index 000000000..ef8079fb3 --- /dev/null +++ b/three/jsutil/loaders/OBJLoader2.js @@ -0,0 +1,1456 @@ +/** + * @author Kai Salmen / https://kaisalmen.de + * Development repository: https://github.com/kaisalmen/WWOBJLoader + */ + +'use strict'; + +if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} } + +if ( THREE.LoaderSupport === undefined ) console.error( '"THREE.LoaderSupport" is not available. "THREE.OBJLoader2" requires it. Please include "LoaderSupport.js" in your HTML.' ); + +/** + * Use this class to load OBJ data from files or to parse OBJ data from an arraybuffer + * @class + * + * @param {THREE.DefaultLoadingManager} [manager] The loadingManager for the loader to use. Default is {@link THREE.DefaultLoadingManager} + */ +THREE.OBJLoader2 = (function () { + + var OBJLOADER2_VERSION = '2.4.2'; + var Validator = THREE.LoaderSupport.Validator; + + function OBJLoader2( manager ) { + console.info( 'Using THREE.OBJLoader2 version: ' + OBJLOADER2_VERSION ); + + this.manager = Validator.verifyInput( manager, THREE.DefaultLoadingManager ); + this.logging = { + enabled: true, + debug: false + }; + + this.modelName = ''; + this.instanceNo = 0; + this.path = ''; + this.useIndices = false; + this.disregardNormals = false; + this.materialPerSmoothingGroup = false; + this.useOAsMesh = false; + this.loaderRootNode = new THREE.Group(); + + this.meshBuilder = new THREE.LoaderSupport.MeshBuilder(); + this.callbacks = new THREE.LoaderSupport.Callbacks(); + this.workerSupport = new THREE.LoaderSupport.WorkerSupport(); + this.terminateWorkerOnLoad = true; + } + + /** + * Enable or disable logging in general (except warn and error), plus enable or disable debug logging. + * @memberOf THREE.OBJLoader2 + * + * @param {boolean} enabled True or false. + * @param {boolean} debug True or false. + */ + OBJLoader2.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + this.meshBuilder.setLogging( this.logging.enabled, this.logging.debug ); + }; + + /** + * Set the name of the model. + * @memberOf THREE.OBJLoader2 + * + * @param {string} modelName + */ + OBJLoader2.prototype.setModelName = function ( modelName ) { + this.modelName = Validator.verifyInput( modelName, this.modelName ); + }; + + /** + * The URL of the base path. + * @memberOf THREE.OBJLoader2 + * + * @param {string} path URL + */ + OBJLoader2.prototype.setPath = function ( path ) { + this.path = Validator.verifyInput( path, this.path ); + }; + + /** + * Set the node where the loaded objects will be attached directly. + * @memberOf THREE.OBJLoader2 + * + * @param {THREE.Object3D} streamMeshesTo Object already attached to scenegraph where new meshes will be attached to + */ + OBJLoader2.prototype.setStreamMeshesTo = function ( streamMeshesTo ) { + this.loaderRootNode = Validator.verifyInput( streamMeshesTo, this.loaderRootNode ); + }; + + /** + * Set materials loaded by MTLLoader or any other supplier of an Array of {@link THREE.Material}. + * @memberOf THREE.OBJLoader2 + * + * @param {THREE.Material[]} materials Array of {@link THREE.Material} + */ + OBJLoader2.prototype.setMaterials = function ( materials ) { + this.meshBuilder.setMaterials( materials ); + }; + + /** + * Instructs loaders to create indexed {@link THREE.BufferGeometry}. + * @memberOf THREE.OBJLoader2 + * + * @param {boolean} useIndices=false + */ + OBJLoader2.prototype.setUseIndices = function ( useIndices ) { + this.useIndices = useIndices === true; + }; + + /** + * Tells whether normals should be completely disregarded and regenerated. + * @memberOf THREE.OBJLoader2 + * + * @param {boolean} disregardNormals=false + */ + OBJLoader2.prototype.setDisregardNormals = function ( disregardNormals ) { + this.disregardNormals = disregardNormals === true; + }; + + /** + * Tells whether a material shall be created per smoothing group. + * @memberOf THREE.OBJLoader2 + * + * @param {boolean} materialPerSmoothingGroup=false + */ + OBJLoader2.prototype.setMaterialPerSmoothingGroup = function ( materialPerSmoothingGroup ) { + this.materialPerSmoothingGroup = materialPerSmoothingGroup === true; + }; + + /** + * Usually 'o' is meta-information and does not result in creation of new meshes, but mesh creation on occurrence of "o" can be enforced. + * @memberOf THREE.OBJLoader2 + * + * @param {boolean} useOAsMesh=false + */ + OBJLoader2.prototype.setUseOAsMesh = function ( useOAsMesh ) { + this.useOAsMesh = useOAsMesh === true; + }; + + OBJLoader2.prototype._setCallbacks = function ( callbacks ) { + if ( Validator.isValid( callbacks.onProgress ) ) this.callbacks.setCallbackOnProgress( callbacks.onProgress ); + if ( Validator.isValid( callbacks.onReportError ) ) this.callbacks.setCallbackOnReportError( callbacks.onReportError ); + if ( Validator.isValid( callbacks.onMeshAlter ) ) this.callbacks.setCallbackOnMeshAlter( callbacks.onMeshAlter ); + if ( Validator.isValid( callbacks.onLoad ) ) this.callbacks.setCallbackOnLoad( callbacks.onLoad ); + if ( Validator.isValid( callbacks.onLoadMaterials ) ) this.callbacks.setCallbackOnLoadMaterials( callbacks.onLoadMaterials ); + + this.meshBuilder._setCallbacks( this.callbacks ); + }; + + /** + * Announce feedback which is give to the registered callbacks. + * @memberOf THREE.OBJLoader2 + * @private + * + * @param {string} type The type of event + * @param {string} text Textual description of the event + * @param {number} numericalValue Numerical value describing the progress + */ + OBJLoader2.prototype.onProgress = function ( type, text, numericalValue ) { + var content = Validator.isValid( text ) ? text: ''; + var event = { + detail: { + type: type, + modelName: this.modelName, + instanceNo: this.instanceNo, + text: content, + numericalValue: numericalValue + } + }; + + if ( Validator.isValid( this.callbacks.onProgress ) ) this.callbacks.onProgress( event ); + + if ( this.logging.enabled && this.logging.debug ) console.debug( content ); + }; + + OBJLoader2.prototype._onError = function ( event ) { + var output = 'Error occurred while downloading!'; + + if ( event.currentTarget && event.currentTarget.statusText !== null ) { + + output += '\nurl: ' + event.currentTarget.responseURL + '\nstatus: ' + event.currentTarget.statusText; + + } + this.onProgress( 'error', output, -1 ); + this._throwError( output ); + }; + + OBJLoader2.prototype._throwError = function ( errorMessage ) { + if ( Validator.isValid( this.callbacks.onReportError ) ) { + + this.callbacks.onReportError( errorMessage ); + + } else { + + throw errorMessage; + + } + }; + + /** + * Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer. + * @memberOf THREE.OBJLoader2 + * + * @param {string} url A string containing the path/URL of the file to be loaded. + * @param {callback} onLoad A function to be called after loading is successfully completed. The function receives loaded Object3D as an argument. + * @param {callback} [onProgress] A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains total and Integer bytes. + * @param {callback} [onError] A function to be called if an error occurs during loading. The function receives the error as an argument. + * @param {callback} [onMeshAlter] A function to be called after a new mesh raw data becomes available for alteration. + * @param {boolean} [useAsync] If true, uses async loading with worker, if false loads data synchronously. + */ + OBJLoader2.prototype.load = function ( url, onLoad, onProgress, onError, onMeshAlter, useAsync ) { + var resource = new THREE.LoaderSupport.ResourceDescriptor( url, 'OBJ' ); + this._loadObj( resource, onLoad, onProgress, onError, onMeshAlter, useAsync ); + }; + + OBJLoader2.prototype._loadObj = function ( resource, onLoad, onProgress, onError, onMeshAlter, useAsync ) { + var scope = this; + if ( ! Validator.isValid( onError ) ) { + onError = function ( event ) { + scope._onError( event ); + }; + } + + // fast-fail + if ( ! Validator.isValid( resource ) ) onError( 'An invalid ResourceDescriptor was provided. Unable to continue!' ); + var fileLoaderOnLoad = function ( content ) { + + resource.content = content; + if ( useAsync ) { + + scope.parseAsync( content, onLoad ); + + } else { + + var callbacks = new THREE.LoaderSupport.Callbacks(); + callbacks.setCallbackOnMeshAlter( onMeshAlter ); + scope._setCallbacks( callbacks ); + onLoad( + { + detail: { + loaderRootNode: scope.parse( content ), + modelName: scope.modelName, + instanceNo: scope.instanceNo + } + } + ); + + } + }; + + // fast-fail + if ( ! Validator.isValid( resource.url ) || Validator.isValid( resource.content ) ) { + + fileLoaderOnLoad( Validator.isValid( resource.content ) ? resource.content : null ); + + } else { + + if ( ! Validator.isValid( onProgress ) ) { + var numericalValueRef = 0; + var numericalValue = 0; + onProgress = function ( event ) { + if ( ! event.lengthComputable ) return; + + numericalValue = event.loaded / event.total; + if ( numericalValue > numericalValueRef ) { + + numericalValueRef = numericalValue; + var output = 'Download of "' + resource.url + '": ' + ( numericalValue * 100 ).toFixed( 2 ) + '%'; + scope.onProgress( 'progressLoad', output, numericalValue ); + + } + }; + } + + + var fileLoader = new THREE.FileLoader( this.manager ); + fileLoader.setPath( this.path ); + fileLoader.setResponseType( 'arraybuffer' ); + fileLoader.load( resource.url, fileLoaderOnLoad, onProgress, onError ); + + } + }; + + + /** + * Run the loader according the provided instructions. + * @memberOf THREE.OBJLoader2 + * + * @param {THREE.LoaderSupport.PrepData} prepData All parameters and resources required for execution + * @param {THREE.LoaderSupport.WorkerSupport} [workerSupportExternal] Use pre-existing WorkerSupport + */ + OBJLoader2.prototype.run = function ( prepData, workerSupportExternal ) { + this._applyPrepData( prepData ); + var available = prepData.checkResourceDescriptorFiles( prepData.resources, + [ + { ext: "obj", type: "ArrayBuffer", ignore: false }, + { ext: "mtl", type: "String", ignore: false }, + { ext: "zip", type: "String", ignore: true } + ] + ); + if ( Validator.isValid( workerSupportExternal ) ) { + + this.terminateWorkerOnLoad = false; + this.workerSupport = workerSupportExternal; + this.logging.enabled = this.workerSupport.logging.enabled; + this.logging.debug = this.workerSupport.logging.debug; + + } + var scope = this; + var onMaterialsLoaded = function ( materials ) { + if ( materials !== null ) scope.meshBuilder.setMaterials( materials ); + scope._loadObj( available.obj, scope.callbacks.onLoad, null, null, scope.callbacks.onMeshAlter, prepData.useAsync ); + + }; + this._loadMtl( available.mtl, onMaterialsLoaded, null, null, prepData.crossOrigin, prepData.materialOptions ); + }; + + OBJLoader2.prototype._applyPrepData = function ( prepData ) { + if ( Validator.isValid( prepData ) ) { + + this.setLogging( prepData.logging.enabled, prepData.logging.debug ); + this.setModelName( prepData.modelName ); + this.setStreamMeshesTo( prepData.streamMeshesTo ); + this.meshBuilder.setMaterials( prepData.materials ); + this.setUseIndices( prepData.useIndices ); + this.setDisregardNormals( prepData.disregardNormals ); + this.setMaterialPerSmoothingGroup( prepData.materialPerSmoothingGroup ); + this.setUseOAsMesh( prepData.useOAsMesh ); + + this._setCallbacks( prepData.getCallbacks() ); + + } + }; + + /** + * Parses OBJ data synchronously from arraybuffer or string. + * @memberOf THREE.OBJLoader2 + * + * @param {arraybuffer|string} content OBJ data as Uint8Array or String + */ + OBJLoader2.prototype.parse = function ( content ) { + // fast-fail in case of illegal data + if ( ! Validator.isValid( content ) ) { + + console.warn( 'Provided content is not a valid ArrayBuffer or String.' ); + return this.loaderRootNode; + + } + if ( this.logging.enabled ) console.time( 'OBJLoader2 parse: ' + this.modelName ); + this.meshBuilder.init(); + + var parser = new Parser(); + parser.setLogging( this.logging.enabled, this.logging.debug ); + parser.setMaterialPerSmoothingGroup( this.materialPerSmoothingGroup ); + parser.setUseOAsMesh( this.useOAsMesh ); + parser.setUseIndices( this.useIndices ); + parser.setDisregardNormals( this.disregardNormals ); + // sync code works directly on the material references + parser.setMaterials( this.meshBuilder.getMaterials() ); + + var scope = this; + var onMeshLoaded = function ( payload ) { + var meshes = scope.meshBuilder.processPayload( payload ); + var mesh; + for ( var i in meshes ) { + mesh = meshes[ i ]; + scope.loaderRootNode.add( mesh ); + } + }; + parser.setCallbackMeshBuilder( onMeshLoaded ); + var onProgressScoped = function ( text, numericalValue ) { + scope.onProgress( 'progressParse', text, numericalValue ); + }; + parser.setCallbackProgress( onProgressScoped ); + + if ( content instanceof ArrayBuffer || content instanceof Uint8Array ) { + + if ( this.logging.enabled ) console.info( 'Parsing arrayBuffer...' ); + parser.parse( content ); + + } else if ( typeof( content ) === 'string' || content instanceof String ) { + + if ( this.logging.enabled ) console.info( 'Parsing text...' ); + parser.parseText( content ); + + } else { + + this._throwError( 'Provided content was neither of type String nor Uint8Array! Aborting...' ); + + } + if ( this.logging.enabled ) console.timeEnd( 'OBJLoader2 parse: ' + this.modelName ); + + return this.loaderRootNode; + }; + + /** + * Parses OBJ content asynchronously from arraybuffer. + * @memberOf THREE.OBJLoader2 + * + * @param {arraybuffer} content OBJ data as Uint8Array + * @param {callback} onLoad Called after worker successfully completed loading + */ + OBJLoader2.prototype.parseAsync = function ( content, onLoad ) { + var scope = this; + var measureTime = false; + var scopedOnLoad = function () { + onLoad( + { + detail: { + loaderRootNode: scope.loaderRootNode, + modelName: scope.modelName, + instanceNo: scope.instanceNo + } + } + ); + if ( measureTime && scope.logging.enabled ) console.timeEnd( 'OBJLoader2 parseAsync: ' + scope.modelName ); + }; + // fast-fail in case of illegal data + if ( ! Validator.isValid( content ) ) { + + console.warn( 'Provided content is not a valid ArrayBuffer.' ); + scopedOnLoad(); + + } else { + + measureTime = true; + + } + if ( measureTime && this.logging.enabled ) console.time( 'OBJLoader2 parseAsync: ' + this.modelName ); + this.meshBuilder.init(); + + var scopedOnMeshLoaded = function ( payload ) { + var meshes = scope.meshBuilder.processPayload( payload ); + var mesh; + for ( var i in meshes ) { + mesh = meshes[ i ]; + scope.loaderRootNode.add( mesh ); + } + }; + var buildCode = function ( funcBuildObject, funcBuildSingleton ) { + var workerCode = ''; + workerCode += '/**\n'; + workerCode += ' * This code was constructed by OBJLoader2 buildCode.\n'; + workerCode += ' */\n\n'; + workerCode += 'THREE = { LoaderSupport: {} };\n\n'; + workerCode += funcBuildObject( 'THREE.LoaderSupport.Validator', Validator ); + workerCode += funcBuildSingleton( 'Parser', Parser ); + + return workerCode; + }; + this.workerSupport.validate( buildCode, 'Parser' ); + this.workerSupport.setCallbacks( scopedOnMeshLoaded, scopedOnLoad ); + if ( scope.terminateWorkerOnLoad ) this.workerSupport.setTerminateRequested( true ); + + var materialNames = {}; + var materials = this.meshBuilder.getMaterials(); + for ( var materialName in materials ) { + + materialNames[ materialName ] = materialName; + + } + this.workerSupport.run( + { + params: { + useAsync: true, + materialPerSmoothingGroup: this.materialPerSmoothingGroup, + useOAsMesh: this.useOAsMesh, + useIndices: this.useIndices, + disregardNormals: this.disregardNormals + }, + logging: { + enabled: this.logging.enabled, + debug: this.logging.debug + }, + materials: { + // in async case only material names are supplied to parser + materials: materialNames + }, + data: { + input: content, + options: null + } + } + ); + }; + + + /** + * Parse OBJ data either from ArrayBuffer or string + * @class + */ + var Parser = (function () { + + function Parser() { + this.callbackProgress = null; + this.callbackMeshBuilder = null; + this.contentRef = null; + this.legacyMode = false; + + this.materials = {}; + this.useAsync = false; + this.materialPerSmoothingGroup = false; + this.useOAsMesh = false; + this.useIndices = false; + this.disregardNormals = false; + + this.vertices = []; + this.colors = []; + this.normals = []; + this.uvs = []; + + this.rawMesh = { + objectName: '', + groupName: '', + activeMtlName: '', + mtllibName: '', + + // reset with new mesh + faceType: -1, + subGroups: [], + subGroupInUse: null, + smoothingGroup: { + splitMaterials: false, + normalized: -1, + real: -1 + }, + counts: { + doubleIndicesCount: 0, + faceCount: 0, + mtlCount: 0, + smoothingGroupCount: 0 + } + }; + + this.inputObjectCount = 1; + this.outputObjectCount = 1; + this.globalCounts = { + vertices: 0, + faces: 0, + doubleIndicesCount: 0, + lineByte: 0, + currentByte: 0, + totalBytes: 0 + }; + + this.logging = { + enabled: true, + debug: false + }; + } + + Parser.prototype.resetRawMesh = function () { + // faces are stored according combined index of group, material and smoothingGroup (0 or not) + this.rawMesh.subGroups = []; + this.rawMesh.subGroupInUse = null; + this.rawMesh.smoothingGroup.normalized = -1; + this.rawMesh.smoothingGroup.real = -1; + + // this default index is required as it is possible to define faces without 'g' or 'usemtl' + this.pushSmoothingGroup( 1 ); + + this.rawMesh.counts.doubleIndicesCount = 0; + this.rawMesh.counts.faceCount = 0; + this.rawMesh.counts.mtlCount = 0; + this.rawMesh.counts.smoothingGroupCount = 0; + }; + + Parser.prototype.setUseAsync = function ( useAsync ) { + this.useAsync = useAsync; + }; + + Parser.prototype.setMaterialPerSmoothingGroup = function ( materialPerSmoothingGroup ) { + this.materialPerSmoothingGroup = materialPerSmoothingGroup; + }; + + Parser.prototype.setUseOAsMesh = function ( useOAsMesh ) { + this.useOAsMesh = useOAsMesh; + }; + + Parser.prototype.setUseIndices = function ( useIndices ) { + this.useIndices = useIndices; + }; + + Parser.prototype.setDisregardNormals = function ( disregardNormals ) { + this.disregardNormals = disregardNormals; + }; + + Parser.prototype.setMaterials = function ( materials ) { + this.materials = THREE.LoaderSupport.Validator.verifyInput( materials, this.materials ); + this.materials = THREE.LoaderSupport.Validator.verifyInput( this.materials, {} ); + }; + + Parser.prototype.setCallbackMeshBuilder = function ( callbackMeshBuilder ) { + if ( ! THREE.LoaderSupport.Validator.isValid( callbackMeshBuilder ) ) { + + this._throwError( 'Unable to run as no "MeshBuilder" callback is set.' ); + + } + this.callbackMeshBuilder = callbackMeshBuilder; + }; + + Parser.prototype.setCallbackProgress = function ( callbackProgress ) { + this.callbackProgress = callbackProgress; + }; + + Parser.prototype.setLogging = function ( enabled, debug ) { + this.logging.enabled = enabled === true; + this.logging.debug = debug === true; + }; + + Parser.prototype.configure = function () { + this.pushSmoothingGroup( 1 ); + + if ( this.logging.enabled ) { + + var matKeys = Object.keys( this.materials ); + var matNames = ( matKeys.length > 0 ) ? '\n\tmaterialNames:\n\t\t- ' + matKeys.join( '\n\t\t- ' ) : '\n\tmaterialNames: None'; + var printedConfig = 'OBJLoader2.Parser configuration:' + + matNames + + '\n\tuseAsync: ' + this.useAsync + + '\n\tmaterialPerSmoothingGroup: ' + this.materialPerSmoothingGroup + + '\n\tuseOAsMesh: ' + this.useOAsMesh + + '\n\tuseIndices: ' + this.useIndices + + '\n\tdisregardNormals: ' + this.disregardNormals + + '\n\tcallbackMeshBuilderName: ' + this.callbackMeshBuilder.name + + '\n\tcallbackProgressName: ' + this.callbackProgress.name; + console.info( printedConfig ); + } + }; + + /** + * Parse the provided arraybuffer + * @memberOf Parser + * + * @param {Uint8Array} arrayBuffer OBJ data as Uint8Array + */ + Parser.prototype.parse = function ( arrayBuffer ) { + if ( this.logging.enabled ) console.time( 'OBJLoader2.Parser.parse' ); + this.configure(); + + var arrayBufferView = new Uint8Array( arrayBuffer ); + this.contentRef = arrayBufferView; + var length = arrayBufferView.byteLength; + this.globalCounts.totalBytes = length; + var buffer = new Array( 128 ); + + for ( var code, word = '', bufferPointer = 0, slashesCount = 0, i = 0; i < length; i++ ) { + + code = arrayBufferView[ i ]; + switch ( code ) { + // space + case 32: + if ( word.length > 0 ) buffer[ bufferPointer++ ] = word; + word = ''; + break; + // slash + case 47: + if ( word.length > 0 ) buffer[ bufferPointer++ ] = word; + slashesCount++; + word = ''; + break; + + // LF + case 10: + if ( word.length > 0 ) buffer[ bufferPointer++ ] = word; + word = ''; + this.globalCounts.lineByte = this.globalCounts.currentByte; + this.globalCounts.currentByte = i; + this.processLine( buffer, bufferPointer, slashesCount ); + bufferPointer = 0; + slashesCount = 0; + break; + + // CR + case 13: + break; + + default: + word += String.fromCharCode( code ); + break; + } + } + this.finalizeParsing(); + if ( this.logging.enabled ) console.timeEnd( 'OBJLoader2.Parser.parse' ); + }; + + /** + * Parse the provided text + * @memberOf Parser + * + * @param {string} text OBJ data as string + */ + Parser.prototype.parseText = function ( text ) { + if ( this.logging.enabled ) console.time( 'OBJLoader2.Parser.parseText' ); + this.configure(); + this.legacyMode = true; + this.contentRef = text; + var length = text.length; + this.globalCounts.totalBytes = length; + var buffer = new Array( 128 ); + + for ( var char, word = '', bufferPointer = 0, slashesCount = 0, i = 0; i < length; i++ ) { + + char = text[ i ]; + switch ( char ) { + case ' ': + if ( word.length > 0 ) buffer[ bufferPointer++ ] = word; + word = ''; + break; + + case '/': + if ( word.length > 0 ) buffer[ bufferPointer++ ] = word; + slashesCount++; + word = ''; + break; + + case '\n': + if ( word.length > 0 ) buffer[ bufferPointer++ ] = word; + word = ''; + this.globalCounts.lineByte = this.globalCounts.currentByte; + this.globalCounts.currentByte = i; + this.processLine( buffer, bufferPointer, slashesCount ); + bufferPointer = 0; + slashesCount = 0; + break; + + case '\r': + break; + + default: + word += char; + } + } + this.finalizeParsing(); + if ( this.logging.enabled ) console.timeEnd( 'OBJLoader2.Parser.parseText' ); + }; + + Parser.prototype.processLine = function ( buffer, bufferPointer, slashesCount ) { + if ( bufferPointer < 1 ) return; + + var reconstructString = function ( content, legacyMode, start, stop ) { + var line = ''; + if ( stop > start ) { + + var i; + if ( legacyMode ) { + + for ( i = start; i < stop; i++ ) line += content[ i ]; + + } else { + + + for ( i = start; i < stop; i++ ) line += String.fromCharCode( content[ i ] ); + + } + line = line.trim(); + + } + return line; + }; + + var bufferLength, length, i, lineDesignation; + lineDesignation = buffer [ 0 ]; + switch ( lineDesignation ) { + case 'v': + this.vertices.push( parseFloat( buffer[ 1 ] ) ); + this.vertices.push( parseFloat( buffer[ 2 ] ) ); + this.vertices.push( parseFloat( buffer[ 3 ] ) ); + if ( bufferPointer > 4 ) { + + this.colors.push( parseFloat( buffer[ 4 ] ) ); + this.colors.push( parseFloat( buffer[ 5 ] ) ); + this.colors.push( parseFloat( buffer[ 6 ] ) ); + + } + break; + + case 'vt': + this.uvs.push( parseFloat( buffer[ 1 ] ) ); + this.uvs.push( parseFloat( buffer[ 2 ] ) ); + break; + + case 'vn': + this.normals.push( parseFloat( buffer[ 1 ] ) ); + this.normals.push( parseFloat( buffer[ 2 ] ) ); + this.normals.push( parseFloat( buffer[ 3 ] ) ); + break; + + case 'f': + bufferLength = bufferPointer - 1; + + // "f vertex ..." + if ( slashesCount === 0 ) { + + this.checkFaceType( 0 ); + for ( i = 2, length = bufferLength; i < length; i ++ ) { + + this.buildFace( buffer[ 1 ] ); + this.buildFace( buffer[ i ] ); + this.buildFace( buffer[ i + 1 ] ); + + } + + // "f vertex/uv ..." + } else if ( bufferLength === slashesCount * 2 ) { + + this.checkFaceType( 1 ); + for ( i = 3, length = bufferLength - 2; i < length; i += 2 ) { + + this.buildFace( buffer[ 1 ], buffer[ 2 ] ); + this.buildFace( buffer[ i ], buffer[ i + 1 ] ); + this.buildFace( buffer[ i + 2 ], buffer[ i + 3 ] ); + + } + + // "f vertex/uv/normal ..." + } else if ( bufferLength * 2 === slashesCount * 3 ) { + + this.checkFaceType( 2 ); + for ( i = 4, length = bufferLength - 3; i < length; i += 3 ) { + + this.buildFace( buffer[ 1 ], buffer[ 2 ], buffer[ 3 ] ); + this.buildFace( buffer[ i ], buffer[ i + 1 ], buffer[ i + 2 ] ); + this.buildFace( buffer[ i + 3 ], buffer[ i + 4 ], buffer[ i + 5 ] ); + + } + + // "f vertex//normal ..." + } else { + + this.checkFaceType( 3 ); + for ( i = 3, length = bufferLength - 2; i < length; i += 2 ) { + + this.buildFace( buffer[ 1 ], undefined, buffer[ 2 ] ); + this.buildFace( buffer[ i ], undefined, buffer[ i + 1 ] ); + this.buildFace( buffer[ i + 2 ], undefined, buffer[ i + 3 ] ); + + } + + } + break; + + case 'l': + case 'p': + bufferLength = bufferPointer - 1; + if ( bufferLength === slashesCount * 2 ) { + + this.checkFaceType( 4 ); + for ( i = 1, length = bufferLength + 1; i < length; i += 2 ) this.buildFace( buffer[ i ], buffer[ i + 1 ] ); + + } else { + + this.checkFaceType( ( lineDesignation === 'l' ) ? 5 : 6 ); + for ( i = 1, length = bufferLength + 1; i < length; i ++ ) this.buildFace( buffer[ i ] ); + + } + break; + + case 's': + this.pushSmoothingGroup( buffer[ 1 ] ); + break; + + case 'g': + // 'g' leads to creation of mesh if valid data (faces declaration was done before), otherwise only groupName gets set + this.processCompletedMesh(); + this.rawMesh.groupName = reconstructString( this.contentRef, this.legacyMode, this.globalCounts.lineByte + 2, this.globalCounts.currentByte ); + break; + + case 'o': + // 'o' is meta-information and usually does not result in creation of new meshes, but can be enforced with "useOAsMesh" + if ( this.useOAsMesh ) this.processCompletedMesh(); + this.rawMesh.objectName = reconstructString( this.contentRef, this.legacyMode, this.globalCounts.lineByte + 2, this.globalCounts.currentByte ); + break; + + case 'mtllib': + this.rawMesh.mtllibName = reconstructString( this.contentRef, this.legacyMode, this.globalCounts.lineByte + 7, this.globalCounts.currentByte ); + break; + + case 'usemtl': + var mtlName = reconstructString( this.contentRef, this.legacyMode, this.globalCounts.lineByte + 7, this.globalCounts.currentByte ); + if ( mtlName !== '' && this.rawMesh.activeMtlName !== mtlName ) { + + this.rawMesh.activeMtlName = mtlName; + this.rawMesh.counts.mtlCount++; + this.checkSubGroup(); + + } + break; + + default: + break; + } + }; + + Parser.prototype.pushSmoothingGroup = function ( smoothingGroup ) { + var smoothingGroupInt = parseInt( smoothingGroup ); + if ( isNaN( smoothingGroupInt ) ) { + smoothingGroupInt = smoothingGroup === "off" ? 0 : 1; + } + + var smoothCheck = this.rawMesh.smoothingGroup.normalized; + this.rawMesh.smoothingGroup.normalized = this.rawMesh.smoothingGroup.splitMaterials ? smoothingGroupInt : ( smoothingGroupInt === 0 ) ? 0 : 1; + this.rawMesh.smoothingGroup.real = smoothingGroupInt; + + if ( smoothCheck !== smoothingGroupInt ) { + + this.rawMesh.counts.smoothingGroupCount++; + this.checkSubGroup(); + + } + }; + + /** + * Expanded faceTypes include all four face types, both line types and the point type + * faceType = 0: "f vertex ..." + * faceType = 1: "f vertex/uv ..." + * faceType = 2: "f vertex/uv/normal ..." + * faceType = 3: "f vertex//normal ..." + * faceType = 4: "l vertex/uv ..." or "l vertex ..." + * faceType = 5: "l vertex ..." + * faceType = 6: "p vertex ..." + */ + Parser.prototype.checkFaceType = function ( faceType ) { + if ( this.rawMesh.faceType !== faceType ) { + + this.processCompletedMesh(); + this.rawMesh.faceType = faceType; + this.checkSubGroup(); + + } + }; + + Parser.prototype.checkSubGroup = function () { + var index = this.rawMesh.activeMtlName + '|' + this.rawMesh.smoothingGroup.normalized; + this.rawMesh.subGroupInUse = this.rawMesh.subGroups[ index ]; + + if ( ! THREE.LoaderSupport.Validator.isValid( this.rawMesh.subGroupInUse ) ) { + + this.rawMesh.subGroupInUse = { + index: index, + objectName: this.rawMesh.objectName, + groupName: this.rawMesh.groupName, + materialName: this.rawMesh.activeMtlName, + smoothingGroup: this.rawMesh.smoothingGroup.normalized, + vertices: [], + indexMappingsCount: 0, + indexMappings: [], + indices: [], + colors: [], + uvs: [], + normals: [] + }; + this.rawMesh.subGroups[ index ] = this.rawMesh.subGroupInUse; + + } + }; + + Parser.prototype.buildFace = function ( faceIndexV, faceIndexU, faceIndexN ) { + if ( this.disregardNormals ) faceIndexN = undefined; + var scope = this; + var updateSubGroupInUse = function () { + + var faceIndexVi = parseInt( faceIndexV ); + var indexPointerV = 3 * ( faceIndexVi > 0 ? faceIndexVi - 1 : faceIndexVi + scope.vertices.length / 3 ); + + var vertices = scope.rawMesh.subGroupInUse.vertices; + vertices.push( scope.vertices[ indexPointerV++ ] ); + vertices.push( scope.vertices[ indexPointerV++ ] ); + vertices.push( scope.vertices[ indexPointerV ] ); + + var indexPointerC = scope.colors.length > 0 ? indexPointerV + 1 : null; + if ( indexPointerC !== null ) { + + var colors = scope.rawMesh.subGroupInUse.colors; + colors.push( scope.colors[ indexPointerC++ ] ); + colors.push( scope.colors[ indexPointerC++ ] ); + colors.push( scope.colors[ indexPointerC ] ); + + } + if ( faceIndexU ) { + + var faceIndexUi = parseInt( faceIndexU ); + var indexPointerU = 2 * ( faceIndexUi > 0 ? faceIndexUi - 1 : faceIndexUi + scope.uvs.length / 2 ); + var uvs = scope.rawMesh.subGroupInUse.uvs; + uvs.push( scope.uvs[ indexPointerU++ ] ); + uvs.push( scope.uvs[ indexPointerU ] ); + + } + if ( faceIndexN ) { + + var faceIndexNi = parseInt( faceIndexN ); + var indexPointerN = 3 * ( faceIndexNi > 0 ? faceIndexNi - 1 : faceIndexNi + scope.normals.length / 3 ); + var normals = scope.rawMesh.subGroupInUse.normals; + normals.push( scope.normals[ indexPointerN++ ] ); + normals.push( scope.normals[ indexPointerN++ ] ); + normals.push( scope.normals[ indexPointerN ] ); + + } + }; + + if ( this.useIndices ) { + + var mappingName = faceIndexV + ( faceIndexU ? '_' + faceIndexU : '_n' ) + ( faceIndexN ? '_' + faceIndexN : '_n' ); + var indicesPointer = this.rawMesh.subGroupInUse.indexMappings[ mappingName ]; + if ( THREE.LoaderSupport.Validator.isValid( indicesPointer ) ) { + + this.rawMesh.counts.doubleIndicesCount++; + + } else { + + indicesPointer = this.rawMesh.subGroupInUse.vertices.length / 3; + updateSubGroupInUse(); + this.rawMesh.subGroupInUse.indexMappings[ mappingName ] = indicesPointer; + this.rawMesh.subGroupInUse.indexMappingsCount++; + + } + this.rawMesh.subGroupInUse.indices.push( indicesPointer ); + + } else { + + updateSubGroupInUse(); + + } + this.rawMesh.counts.faceCount++; + }; + + Parser.prototype.createRawMeshReport = function ( inputObjectCount ) { + return 'Input Object number: ' + inputObjectCount + + '\n\tObject name: ' + this.rawMesh.objectName + + '\n\tGroup name: ' + this.rawMesh.groupName + + '\n\tMtllib name: ' + this.rawMesh.mtllibName + + '\n\tVertex count: ' + this.vertices.length / 3 + + '\n\tNormal count: ' + this.normals.length / 3 + + '\n\tUV count: ' + this.uvs.length / 2 + + '\n\tSmoothingGroup count: ' + this.rawMesh.counts.smoothingGroupCount + + '\n\tMaterial count: ' + this.rawMesh.counts.mtlCount + + '\n\tReal MeshOutputGroup count: ' + this.rawMesh.subGroups.length; + }; + + /** + * Clear any empty subGroup and calculate absolute vertex, normal and uv counts + */ + Parser.prototype.finalizeRawMesh = function () { + var meshOutputGroupTemp = []; + var meshOutputGroup; + var absoluteVertexCount = 0; + var absoluteIndexMappingsCount = 0; + var absoluteIndexCount = 0; + var absoluteColorCount = 0; + var absoluteNormalCount = 0; + var absoluteUvCount = 0; + var indices; + for ( var name in this.rawMesh.subGroups ) { + + meshOutputGroup = this.rawMesh.subGroups[ name ]; + if ( meshOutputGroup.vertices.length > 0 ) { + + indices = meshOutputGroup.indices; + if ( indices.length > 0 && absoluteIndexMappingsCount > 0 ) { + + for ( var i in indices ) indices[ i ] = indices[ i ] + absoluteIndexMappingsCount; + + } + meshOutputGroupTemp.push( meshOutputGroup ); + absoluteVertexCount += meshOutputGroup.vertices.length; + absoluteIndexMappingsCount += meshOutputGroup.indexMappingsCount; + absoluteIndexCount += meshOutputGroup.indices.length; + absoluteColorCount += meshOutputGroup.colors.length; + absoluteUvCount += meshOutputGroup.uvs.length; + absoluteNormalCount += meshOutputGroup.normals.length; + + } + } + + // do not continue if no result + var result = null; + if ( meshOutputGroupTemp.length > 0 ) { + + result = { + name: this.rawMesh.groupName !== '' ? this.rawMesh.groupName : this.rawMesh.objectName, + subGroups: meshOutputGroupTemp, + absoluteVertexCount: absoluteVertexCount, + absoluteIndexCount: absoluteIndexCount, + absoluteColorCount: absoluteColorCount, + absoluteNormalCount: absoluteNormalCount, + absoluteUvCount: absoluteUvCount, + faceCount: this.rawMesh.counts.faceCount, + doubleIndicesCount: this.rawMesh.counts.doubleIndicesCount + }; + + } + return result; + }; + + Parser.prototype.processCompletedMesh = function () { + var result = this.finalizeRawMesh(); + if ( THREE.LoaderSupport.Validator.isValid( result ) ) { + + if ( this.colors.length > 0 && this.colors.length !== this.vertices.length ) { + + this._throwError( 'Vertex Colors were detected, but vertex count and color count do not match!' ); + + } + if ( this.logging.enabled && this.logging.debug ) console.debug( this.createRawMeshReport( this.inputObjectCount ) ); + this.inputObjectCount++; + + this.buildMesh( result ); + var progressBytesPercent = this.globalCounts.currentByte / this.globalCounts.totalBytes; + this.callbackProgress( 'Completed [o: ' + this.rawMesh.objectName + ' g:' + this.rawMesh.groupName + '] Total progress: ' + ( progressBytesPercent * 100 ).toFixed( 2 ) + '%', progressBytesPercent ); + this.resetRawMesh(); + return true; + + } else { + + return false; + } + }; + + /** + * SubGroups are transformed to too intermediate format that is forwarded to the MeshBuilder. + * It is ensured that SubGroups only contain objects with vertices (no need to check). + * + * @param result + */ + Parser.prototype.buildMesh = function ( result ) { + var meshOutputGroups = result.subGroups; + + var vertexFA = new Float32Array( result.absoluteVertexCount ); + this.globalCounts.vertices += result.absoluteVertexCount / 3; + this.globalCounts.faces += result.faceCount; + this.globalCounts.doubleIndicesCount += result.doubleIndicesCount; + var indexUA = ( result.absoluteIndexCount > 0 ) ? new Uint32Array( result.absoluteIndexCount ) : null; + var colorFA = ( result.absoluteColorCount > 0 ) ? new Float32Array( result.absoluteColorCount ) : null; + var normalFA = ( result.absoluteNormalCount > 0 ) ? new Float32Array( result.absoluteNormalCount ) : null; + var uvFA = ( result.absoluteUvCount > 0 ) ? new Float32Array( result.absoluteUvCount ) : null; + var haveVertexColors = THREE.LoaderSupport.Validator.isValid( colorFA ); + + var meshOutputGroup; + var materialNames = []; + + var createMultiMaterial = ( meshOutputGroups.length > 1 ); + var materialIndex = 0; + var materialIndexMapping = []; + var selectedMaterialIndex; + var materialGroup; + var materialGroups = []; + + var vertexFAOffset = 0; + var indexUAOffset = 0; + var colorFAOffset = 0; + var normalFAOffset = 0; + var uvFAOffset = 0; + var materialGroupOffset = 0; + var materialGroupLength = 0; + + var materialOrg, material, materialName, materialNameOrg; + // only one specific face type + for ( var oodIndex in meshOutputGroups ) { + + if ( ! meshOutputGroups.hasOwnProperty( oodIndex ) ) continue; + meshOutputGroup = meshOutputGroups[ oodIndex ]; + + materialNameOrg = meshOutputGroup.materialName; + if ( this.rawMesh.faceType < 4 ) { + + materialName = materialNameOrg + ( haveVertexColors ? '_vertexColor' : '' ) + ( meshOutputGroup.smoothingGroup === 0 ? '_flat' : '' ); + + + } else { + + materialName = this.rawMesh.faceType === 6 ? 'defaultPointMaterial' : 'defaultLineMaterial'; + + } + materialOrg = this.materials[ materialNameOrg ]; + material = this.materials[ materialName ]; + + // both original and derived names do not lead to an existing material => need to use a default material + if ( ! THREE.LoaderSupport.Validator.isValid( materialOrg ) && ! THREE.LoaderSupport.Validator.isValid( material ) ) { + + var defaultMaterialName = haveVertexColors ? 'defaultVertexColorMaterial' : 'defaultMaterial'; + materialOrg = this.materials[ defaultMaterialName ]; + if ( this.logging.enabled ) console.warn( 'object_group "' + meshOutputGroup.objectName + '_' + + meshOutputGroup.groupName + '" was defined with unresolvable material "' + + materialNameOrg + '"! Assigning "' + defaultMaterialName + '".' ); + materialNameOrg = defaultMaterialName; + + // if names are identical then there is no need for later manipulation + if ( materialNameOrg === materialName ) { + + material = materialOrg; + materialName = defaultMaterialName; + + } + + } + if ( ! THREE.LoaderSupport.Validator.isValid( material ) ) { + + var materialCloneInstructions = { + materialNameOrg: materialNameOrg, + materialName: materialName, + materialProperties: { + vertexColors: haveVertexColors ? 2 : 0, + flatShading: meshOutputGroup.smoothingGroup === 0 + } + }; + var payload = { + cmd: 'materialData', + materials: { + materialCloneInstructions: materialCloneInstructions + } + }; + this.callbackMeshBuilder( payload ); + + // fake entry for async; sync Parser always works on material references (Builder update directly visible here) + if ( this.useAsync ) this.materials[ materialName ] = materialCloneInstructions; + + } + + if ( createMultiMaterial ) { + + // re-use material if already used before. Reduces materials array size and eliminates duplicates + selectedMaterialIndex = materialIndexMapping[ materialName ]; + if ( ! selectedMaterialIndex ) { + + selectedMaterialIndex = materialIndex; + materialIndexMapping[ materialName ] = materialIndex; + materialNames.push( materialName ); + materialIndex++; + + } + materialGroupLength = this.useIndices ? meshOutputGroup.indices.length : meshOutputGroup.vertices.length / 3; + materialGroup = { + start: materialGroupOffset, + count: materialGroupLength, + index: selectedMaterialIndex + }; + materialGroups.push( materialGroup ); + materialGroupOffset += materialGroupLength; + + } else { + + materialNames.push( materialName ); + + } + + vertexFA.set( meshOutputGroup.vertices, vertexFAOffset ); + vertexFAOffset += meshOutputGroup.vertices.length; + + if ( indexUA ) { + + indexUA.set( meshOutputGroup.indices, indexUAOffset ); + indexUAOffset += meshOutputGroup.indices.length; + + } + + if ( colorFA ) { + + colorFA.set( meshOutputGroup.colors, colorFAOffset ); + colorFAOffset += meshOutputGroup.colors.length; + + } + + if ( normalFA ) { + + normalFA.set( meshOutputGroup.normals, normalFAOffset ); + normalFAOffset += meshOutputGroup.normals.length; + + } + if ( uvFA ) { + + uvFA.set( meshOutputGroup.uvs, uvFAOffset ); + uvFAOffset += meshOutputGroup.uvs.length; + + } + + if ( this.logging.enabled && this.logging.debug ) { + var materialIndexLine = THREE.LoaderSupport.Validator.isValid( selectedMaterialIndex ) ? '\n\t\tmaterialIndex: ' + selectedMaterialIndex : ''; + var createdReport = '\tOutput Object no.: ' + this.outputObjectCount + + '\n\t\tgroupName: ' + meshOutputGroup.groupName + + '\n\t\tIndex: ' + meshOutputGroup.index + + '\n\t\tfaceType: ' + this.rawMesh.faceType + + '\n\t\tmaterialName: ' + meshOutputGroup.materialName + + '\n\t\tsmoothingGroup: ' + meshOutputGroup.smoothingGroup + + materialIndexLine + + '\n\t\tobjectName: ' + meshOutputGroup.objectName + + '\n\t\t#vertices: ' + meshOutputGroup.vertices.length / 3 + + '\n\t\t#indices: ' + meshOutputGroup.indices.length + + '\n\t\t#colors: ' + meshOutputGroup.colors.length / 3 + + '\n\t\t#uvs: ' + meshOutputGroup.uvs.length / 2 + + '\n\t\t#normals: ' + meshOutputGroup.normals.length / 3; + console.debug( createdReport ); + } + + } + + this.outputObjectCount++; + this.callbackMeshBuilder( + { + cmd: 'meshData', + progress: { + numericalValue: this.globalCounts.currentByte / this.globalCounts.totalBytes + }, + params: { + meshName: result.name + }, + materials: { + multiMaterial: createMultiMaterial, + materialNames: materialNames, + materialGroups: materialGroups + }, + buffers: { + vertices: vertexFA, + indices: indexUA, + colors: colorFA, + normals: normalFA, + uvs: uvFA + }, + // 0: mesh, 1: line, 2: point + geometryType: this.rawMesh.faceType < 4 ? 0 : ( this.rawMesh.faceType === 6 ) ? 2 : 1 + }, + [ vertexFA.buffer ], + THREE.LoaderSupport.Validator.isValid( indexUA ) ? [ indexUA.buffer ] : null, + THREE.LoaderSupport.Validator.isValid( colorFA ) ? [ colorFA.buffer ] : null, + THREE.LoaderSupport.Validator.isValid( normalFA ) ? [ normalFA.buffer ] : null, + THREE.LoaderSupport.Validator.isValid( uvFA ) ? [ uvFA.buffer ] : null + ); + }; + + Parser.prototype.finalizeParsing = function () { + if ( this.logging.enabled ) console.info( 'Global output object count: ' + this.outputObjectCount ); + if ( this.processCompletedMesh() && this.logging.enabled ) { + + var parserFinalReport = 'Overall counts: ' + + '\n\tVertices: ' + this.globalCounts.vertices + + '\n\tFaces: ' + this.globalCounts.faces + + '\n\tMultiple definitions: ' + this.globalCounts.doubleIndicesCount; + console.info( parserFinalReport ); + + } + }; + + return Parser; + })(); + + /** + * Utility method for loading an mtl file according resource description. Provide url or content. + * @memberOf THREE.OBJLoader2 + * + * @param {string} url URL to the file + * @param {Object} content The file content as arraybuffer or text + * @param {function} onLoad Callback to be called after successful load + * @param {callback} [onProgress] A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains total and Integer bytes. + * @param {callback} [onError] A function to be called if an error occurs during loading. The function receives the error as an argument. + * @param {string} [crossOrigin] CORS value + * @param {Object} [materialOptions] Set material loading options for MTLLoader + */ + OBJLoader2.prototype.loadMtl = function ( url, content, onLoad, onProgress, onError, crossOrigin, materialOptions ) { + var resource = new THREE.LoaderSupport.ResourceDescriptor( url, 'MTL' ); + resource.setContent( content ); + this._loadMtl( resource, onLoad, onProgress, onError, crossOrigin, materialOptions ); + }; + + + OBJLoader2.prototype._loadMtl = function ( resource, onLoad, onProgress, onError, crossOrigin, materialOptions ) { + if ( THREE.MTLLoader === undefined ) console.error( '"THREE.MTLLoader" is not available. "THREE.OBJLoader2" requires it for loading MTL files.' ); + if ( Validator.isValid( resource ) && this.logging.enabled ) console.time( 'Loading MTL: ' + resource.name ); + + var materials = []; + var scope = this; + var processMaterials = function ( materialCreator ) { + var materialCreatorMaterials = []; + if ( Validator.isValid( materialCreator ) ) { + + materialCreator.preload(); + materialCreatorMaterials = materialCreator.materials; + for ( var materialName in materialCreatorMaterials ) { + + if ( materialCreatorMaterials.hasOwnProperty( materialName ) ) { + + materials[ materialName ] = materialCreatorMaterials[ materialName ]; + + } + } + } + + if ( Validator.isValid( resource ) && scope.logging.enabled ) console.timeEnd( 'Loading MTL: ' + resource.name ); + onLoad( materials, materialCreator ); + }; + + // fast-fail + if ( ! Validator.isValid( resource ) || ( ! Validator.isValid( resource.content ) && ! Validator.isValid( resource.url ) ) ) { + + processMaterials(); + + } else { + + var mtlLoader = new THREE.MTLLoader( this.manager ); + crossOrigin = Validator.verifyInput( crossOrigin, 'anonymous' ); + mtlLoader.setCrossOrigin( crossOrigin ); + mtlLoader.setResourcePath( resource.path ); + if ( Validator.isValid( materialOptions ) ) mtlLoader.setMaterialOptions( materialOptions ); + + var parseTextWithMtlLoader = function ( content ) { + var contentAsText = content; + if ( typeof( content ) !== 'string' && ! ( content instanceof String ) ) { + + if ( content.length > 0 || content.byteLength > 0 ) { + + contentAsText = THREE.LoaderUtils.decodeText( content ); + + } else { + + this._throwError( 'Unable to parse mtl as it it seems to be neither a String, an Array or an ArrayBuffer!' ); + } + + } + processMaterials( mtlLoader.parse( contentAsText ) ); + }; + + if ( Validator.isValid( resource.content ) ) { + + parseTextWithMtlLoader( resource.content ); + + } else if ( Validator.isValid( resource.url ) ) { + + var fileLoader = new THREE.FileLoader( this.manager ); + if ( ! Validator.isValid( onError ) ) { + onError = function ( event ) { + scope._onError( event ); + }; + } + if ( ! Validator.isValid( onProgress ) ) { + var numericalValueRef = 0; + var numericalValue = 0; + onProgress = function ( event ) { + if ( ! event.lengthComputable ) return; + + numericalValue = event.loaded / event.total; + if ( numericalValue > numericalValueRef ) { + + numericalValueRef = numericalValue; + var output = 'Download of "' + resource.url + '": ' + ( numericalValue * 100 ).toFixed( 2 ) + '%'; + scope.onProgress( 'progressLoad', output, numericalValue ); + + } + }; + } + + fileLoader.load( resource.url, parseTextWithMtlLoader, onProgress, onError ); + + } + } + }; + + return OBJLoader2; +})(); diff --git a/three/jsutil/loaders/PCDLoader.js b/three/jsutil/loaders/PCDLoader.js new file mode 100644 index 000000000..19d22e929 --- /dev/null +++ b/three/jsutil/loaders/PCDLoader.js @@ -0,0 +1,308 @@ +/** + * @author Filipe Caixeta / http://filipecaixeta.com.br + * @author Mugen87 / https://github.com/Mugen87 + * + * Description: A THREE loader for PCD ascii and binary files. + * + * Limitations: Compressed binary files are not supported. + * + */ + +THREE.PCDLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.littleEndian = true; + +}; + + +THREE.PCDLoader.prototype = { + + constructor: THREE.PCDLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( data ) { + + try { + + onLoad( scope.parse( data, url ) ); + + } catch ( e ) { + + if ( onError ) { + + onError( e ); + + } else { + + throw e; + + } + + } + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data, url ) { + + function parseHeader( data ) { + + var PCDheader = {}; + var result1 = data.search( /[\r\n]DATA\s(\S*)\s/i ); + var result2 = /[\r\n]DATA\s(\S*)\s/i.exec( data.substr( result1 - 1 ) ); + + PCDheader.data = result2[ 1 ]; + PCDheader.headerLen = result2[ 0 ].length + result1; + PCDheader.str = data.substr( 0, PCDheader.headerLen ); + + // remove comments + + PCDheader.str = PCDheader.str.replace( /\#.*/gi, '' ); + + // parse + + PCDheader.version = /VERSION (.*)/i.exec( PCDheader.str ); + PCDheader.fields = /FIELDS (.*)/i.exec( PCDheader.str ); + PCDheader.size = /SIZE (.*)/i.exec( PCDheader.str ); + PCDheader.type = /TYPE (.*)/i.exec( PCDheader.str ); + PCDheader.count = /COUNT (.*)/i.exec( PCDheader.str ); + PCDheader.width = /WIDTH (.*)/i.exec( PCDheader.str ); + PCDheader.height = /HEIGHT (.*)/i.exec( PCDheader.str ); + PCDheader.viewpoint = /VIEWPOINT (.*)/i.exec( PCDheader.str ); + PCDheader.points = /POINTS (.*)/i.exec( PCDheader.str ); + + // evaluate + + if ( PCDheader.version !== null ) + PCDheader.version = parseFloat( PCDheader.version[ 1 ] ); + + if ( PCDheader.fields !== null ) + PCDheader.fields = PCDheader.fields[ 1 ].split( ' ' ); + + if ( PCDheader.type !== null ) + PCDheader.type = PCDheader.type[ 1 ].split( ' ' ); + + if ( PCDheader.width !== null ) + PCDheader.width = parseInt( PCDheader.width[ 1 ] ); + + if ( PCDheader.height !== null ) + PCDheader.height = parseInt( PCDheader.height[ 1 ] ); + + if ( PCDheader.viewpoint !== null ) + PCDheader.viewpoint = PCDheader.viewpoint[ 1 ]; + + if ( PCDheader.points !== null ) + PCDheader.points = parseInt( PCDheader.points[ 1 ], 10 ); + + if ( PCDheader.points === null ) + PCDheader.points = PCDheader.width * PCDheader.height; + + if ( PCDheader.size !== null ) { + + PCDheader.size = PCDheader.size[ 1 ].split( ' ' ).map( function ( x ) { + + return parseInt( x, 10 ); + + } ); + + } + + if ( PCDheader.count !== null ) { + + PCDheader.count = PCDheader.count[ 1 ].split( ' ' ).map( function ( x ) { + + return parseInt( x, 10 ); + + } ); + + } else { + + PCDheader.count = []; + + for ( var i = 0, l = PCDheader.fields.length; i < l; i ++ ) { + + PCDheader.count.push( 1 ); + + } + + } + + PCDheader.offset = {}; + + var sizeSum = 0; + + for ( var i = 0, l = PCDheader.fields.length; i < l; i ++ ) { + + if ( PCDheader.data === 'ascii' ) { + + PCDheader.offset[ PCDheader.fields[ i ] ] = i; + + } else { + + PCDheader.offset[ PCDheader.fields[ i ] ] = sizeSum; + sizeSum += PCDheader.size[ i ]; + + } + + } + + // for binary only + + PCDheader.rowSize = sizeSum; + + return PCDheader; + + } + + var textData = THREE.LoaderUtils.decodeText( data ); + + // parse header (always ascii format) + + var PCDheader = parseHeader( textData ); + + // parse data + + var position = []; + var normal = []; + var color = []; + + // ascii + + if ( PCDheader.data === 'ascii' ) { + + var offset = PCDheader.offset; + var pcdData = textData.substr( PCDheader.headerLen ); + var lines = pcdData.split( '\n' ); + + for ( var i = 0, l = lines.length; i < l; i ++ ) { + + if ( lines[ i ] === '' ) continue; + + var line = lines[ i ].split( ' ' ); + + if ( offset.x !== undefined ) { + + position.push( parseFloat( line[ offset.x ] ) ); + position.push( parseFloat( line[ offset.y ] ) ); + position.push( parseFloat( line[ offset.z ] ) ); + + } + + if ( offset.rgb !== undefined ) { + + var rgb = parseFloat( line[ offset.rgb ] ); + var r = ( rgb >> 16 ) & 0x0000ff; + var g = ( rgb >> 8 ) & 0x0000ff; + var b = ( rgb >> 0 ) & 0x0000ff; + color.push( r / 255, g / 255, b / 255 ); + + } + + if ( offset.normal_x !== undefined ) { + + normal.push( parseFloat( line[ offset.normal_x ] ) ); + normal.push( parseFloat( line[ offset.normal_y ] ) ); + normal.push( parseFloat( line[ offset.normal_z ] ) ); + + } + + } + + } + + // binary + + if ( PCDheader.data === 'binary_compressed' ) { + + console.error( 'THREE.PCDLoader: binary_compressed files are not supported' ); + return; + + } + + if ( PCDheader.data === 'binary' ) { + + var dataview = new DataView( data, PCDheader.headerLen ); + var offset = PCDheader.offset; + + for ( var i = 0, row = 0; i < PCDheader.points; i ++, row += PCDheader.rowSize ) { + + if ( offset.x !== undefined ) { + + position.push( dataview.getFloat32( row + offset.x, this.littleEndian ) ); + position.push( dataview.getFloat32( row + offset.y, this.littleEndian ) ); + position.push( dataview.getFloat32( row + offset.z, this.littleEndian ) ); + + } + + if ( offset.rgb !== undefined ) { + + color.push( dataview.getUint8( row + offset.rgb + 2 ) / 255.0 ); + color.push( dataview.getUint8( row + offset.rgb + 1 ) / 255.0 ); + color.push( dataview.getUint8( row + offset.rgb + 0 ) / 255.0 ); + + } + + if ( offset.normal_x !== undefined ) { + + normal.push( dataview.getFloat32( row + offset.normal_x, this.littleEndian ) ); + normal.push( dataview.getFloat32( row + offset.normal_y, this.littleEndian ) ); + normal.push( dataview.getFloat32( row + offset.normal_z, this.littleEndian ) ); + + } + + } + + } + + // build geometry + + var geometry = new THREE.BufferGeometry(); + + if ( position.length > 0 ) geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) ); + if ( normal.length > 0 ) geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normal, 3 ) ); + if ( color.length > 0 ) geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( color, 3 ) ); + + geometry.computeBoundingSphere(); + + // build material + + var material = new THREE.PointsMaterial( { size: 0.005 } ); + + if ( color.length > 0 ) { + + material.vertexColors = THREE.VertexColors; + + } else { + + material.color.setHex( Math.random() * 0xffffff ); + + } + + // build mesh + + var mesh = new THREE.Points( geometry, material ); + var name = url.split( '' ).reverse().join( '' ); + name = /([^\/]*)/.exec( name ); + name = name[ 1 ].split( '' ).reverse().join( '' ); + mesh.name = name; + + return mesh; + + } + +}; diff --git a/three/jsutil/loaders/PDBLoader.js b/three/jsutil/loaders/PDBLoader.js new file mode 100644 index 000000000..3de2385ac --- /dev/null +++ b/three/jsutil/loaders/PDBLoader.js @@ -0,0 +1,217 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * @author Mugen87 / https://github.com/Mugen87 + */ + +THREE.PDBLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.PDBLoader.prototype = { + + constructor: THREE.PDBLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + // Based on CanvasMol PDB parser + + parse: function ( text ) { + + function trim( text ) { + + return text.replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); + + } + + function capitalize( text ) { + + return text.charAt( 0 ).toUpperCase() + text.substr( 1 ).toLowerCase(); + + } + + function hash( s, e ) { + + return 's' + Math.min( s, e ) + 'e' + Math.max( s, e ); + + } + + function parseBond( start, length ) { + + var eatom = parseInt( lines[ i ].substr( start, length ) ); + + if ( eatom ) { + + var h = hash( satom, eatom ); + + if ( bhash[ h ] === undefined ) { + + bonds.push( [ satom - 1, eatom - 1, 1 ] ); + bhash[ h ] = bonds.length - 1; + + } else { + + // doesn't really work as almost all PDBs + // have just normal bonds appearing multiple + // times instead of being double/triple bonds + // bonds[bhash[h]][2] += 1; + + } + + } + + } + + function buildGeometry() { + + var build = { + geometryAtoms: new THREE.BufferGeometry(), + geometryBonds: new THREE.BufferGeometry(), + json: { + atoms: atoms, + bonds: bonds + } + }; + + var geometryAtoms = build.geometryAtoms; + var geometryBonds = build.geometryBonds; + + var i, l; + + var verticesAtoms = []; + var colorsAtoms = []; + var verticesBonds = []; + + // atoms + + for ( i = 0, l = atoms.length; i < l; i ++ ) { + + var atom = atoms[ i ]; + + var x = atom[ 0 ]; + var y = atom[ 1 ]; + var z = atom[ 2 ]; + + verticesAtoms.push( x, y, z ); + + var r = atom[ 3 ][ 0 ] / 255; + var g = atom[ 3 ][ 1 ] / 255; + var b = atom[ 3 ][ 2 ] / 255; + + colorsAtoms.push( r, g, b ); + + } + + // bonds + + for ( i = 0, l = bonds.length; i < l; i ++ ) { + + var bond = bonds[ i ]; + + var start = bond[ 0 ]; + var end = bond[ 1 ]; + + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 0 ] ); + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 1 ] ); + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 2 ] ); + + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 0 ] ); + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 1 ] ); + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 2 ] ); + + } + + // build geometry + + geometryAtoms.addAttribute( 'position', new THREE.Float32BufferAttribute( verticesAtoms, 3 ) ); + geometryAtoms.addAttribute( 'color', new THREE.Float32BufferAttribute( colorsAtoms, 3 ) ); + + geometryBonds.addAttribute( 'position', new THREE.Float32BufferAttribute( verticesBonds, 3 ) ); + + return build; + + } + + var CPK = { h: [ 255, 255, 255 ], he: [ 217, 255, 255 ], li: [ 204, 128, 255 ], be: [ 194, 255, 0 ], b: [ 255, 181, 181 ], c: [ 144, 144, 144 ], n: [ 48, 80, 248 ], o: [ 255, 13, 13 ], f: [ 144, 224, 80 ], ne: [ 179, 227, 245 ], na: [ 171, 92, 242 ], mg: [ 138, 255, 0 ], al: [ 191, 166, 166 ], si: [ 240, 200, 160 ], p: [ 255, 128, 0 ], s: [ 255, 255, 48 ], cl: [ 31, 240, 31 ], ar: [ 128, 209, 227 ], k: [ 143, 64, 212 ], ca: [ 61, 255, 0 ], sc: [ 230, 230, 230 ], ti: [ 191, 194, 199 ], v: [ 166, 166, 171 ], cr: [ 138, 153, 199 ], mn: [ 156, 122, 199 ], fe: [ 224, 102, 51 ], co: [ 240, 144, 160 ], ni: [ 80, 208, 80 ], cu: [ 200, 128, 51 ], zn: [ 125, 128, 176 ], ga: [ 194, 143, 143 ], ge: [ 102, 143, 143 ], as: [ 189, 128, 227 ], se: [ 255, 161, 0 ], br: [ 166, 41, 41 ], kr: [ 92, 184, 209 ], rb: [ 112, 46, 176 ], sr: [ 0, 255, 0 ], y: [ 148, 255, 255 ], zr: [ 148, 224, 224 ], nb: [ 115, 194, 201 ], mo: [ 84, 181, 181 ], tc: [ 59, 158, 158 ], ru: [ 36, 143, 143 ], rh: [ 10, 125, 140 ], pd: [ 0, 105, 133 ], ag: [ 192, 192, 192 ], cd: [ 255, 217, 143 ], in: [ 166, 117, 115 ], sn: [ 102, 128, 128 ], sb: [ 158, 99, 181 ], te: [ 212, 122, 0 ], i: [ 148, 0, 148 ], xe: [ 66, 158, 176 ], cs: [ 87, 23, 143 ], ba: [ 0, 201, 0 ], la: [ 112, 212, 255 ], ce: [ 255, 255, 199 ], pr: [ 217, 255, 199 ], nd: [ 199, 255, 199 ], pm: [ 163, 255, 199 ], sm: [ 143, 255, 199 ], eu: [ 97, 255, 199 ], gd: [ 69, 255, 199 ], tb: [ 48, 255, 199 ], dy: [ 31, 255, 199 ], ho: [ 0, 255, 156 ], er: [ 0, 230, 117 ], tm: [ 0, 212, 82 ], yb: [ 0, 191, 56 ], lu: [ 0, 171, 36 ], hf: [ 77, 194, 255 ], ta: [ 77, 166, 255 ], w: [ 33, 148, 214 ], re: [ 38, 125, 171 ], os: [ 38, 102, 150 ], ir: [ 23, 84, 135 ], pt: [ 208, 208, 224 ], au: [ 255, 209, 35 ], hg: [ 184, 184, 208 ], tl: [ 166, 84, 77 ], pb: [ 87, 89, 97 ], bi: [ 158, 79, 181 ], po: [ 171, 92, 0 ], at: [ 117, 79, 69 ], rn: [ 66, 130, 150 ], fr: [ 66, 0, 102 ], ra: [ 0, 125, 0 ], ac: [ 112, 171, 250 ], th: [ 0, 186, 255 ], pa: [ 0, 161, 255 ], u: [ 0, 143, 255 ], np: [ 0, 128, 255 ], pu: [ 0, 107, 255 ], am: [ 84, 92, 242 ], cm: [ 120, 92, 227 ], bk: [ 138, 79, 227 ], cf: [ 161, 54, 212 ], es: [ 179, 31, 212 ], fm: [ 179, 31, 186 ], md: [ 179, 13, 166 ], no: [ 189, 13, 135 ], lr: [ 199, 0, 102 ], rf: [ 204, 0, 89 ], db: [ 209, 0, 79 ], sg: [ 217, 0, 69 ], bh: [ 224, 0, 56 ], hs: [ 230, 0, 46 ], mt: [ 235, 0, 38 ], ds: [ 235, 0, 38 ], rg: [ 235, 0, 38 ], cn: [ 235, 0, 38 ], uut: [ 235, 0, 38 ], uuq: [ 235, 0, 38 ], uup: [ 235, 0, 38 ], uuh: [ 235, 0, 38 ], uus: [ 235, 0, 38 ], uuo: [ 235, 0, 38 ] }; + + var atoms = []; + var bonds = []; + var histogram = {}; + + var bhash = {}; + + var x, y, z, index, e; + + // parse + + var lines = text.split( '\n' ); + + for ( var i = 0, l = lines.length; i < l; i ++ ) { + + if ( lines[ i ].substr( 0, 4 ) === 'ATOM' || lines[ i ].substr( 0, 6 ) === 'HETATM' ) { + + x = parseFloat( lines[ i ].substr( 30, 7 ) ); + y = parseFloat( lines[ i ].substr( 38, 7 ) ); + z = parseFloat( lines[ i ].substr( 46, 7 ) ); + index = parseInt( lines[ i ].substr( 6, 5 ) ) - 1; + + e = trim( lines[ i ].substr( 76, 2 ) ).toLowerCase(); + + if ( e === '' ) { + + e = trim( lines[ i ].substr( 12, 2 ) ).toLowerCase(); + + } + + atoms[ index ] = [ x, y, z, CPK[ e ], capitalize( e ) ]; + + if ( histogram[ e ] === undefined ) { + + histogram[ e ] = 1; + + } else { + + histogram[ e ] += 1; + + } + + } else if ( lines[ i ].substr( 0, 6 ) === 'CONECT' ) { + + var satom = parseInt( lines[ i ].substr( 6, 5 ) ); + + parseBond( 11, 5 ); + parseBond( 16, 5 ); + parseBond( 21, 5 ); + parseBond( 26, 5 ); + + } + + } + + // build and return geometry + + return buildGeometry(); + + } + +}; diff --git a/three/jsutil/loaders/PLYLoader.js b/three/jsutil/loaders/PLYLoader.js new file mode 100644 index 000000000..bd8bbd0a1 --- /dev/null +++ b/three/jsutil/loaders/PLYLoader.js @@ -0,0 +1,505 @@ +/** + * @author Wei Meng / http://about.me/menway + * + * Description: A THREE loader for PLY ASCII files (known as the Polygon + * File Format or the Stanford Triangle Format). + * + * Limitations: ASCII decoding assumes file is UTF-8. + * + * Usage: + * var loader = new THREE.PLYLoader(); + * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) { + * + * scene.add( new THREE.Mesh( geometry ) ); + * + * } ); + * + * If the PLY file uses non standard property names, they can be mapped while + * loading. For example, the following maps the properties + * “diffuse_(red|green|blue)” in the file to standard color names. + * + * loader.setPropertyNameMapping( { + * diffuse_red: 'red', + * diffuse_green: 'green', + * diffuse_blue: 'blue' + * } ); + * + */ + + +THREE.PLYLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.propertyNameMapping = {}; + +}; + +THREE.PLYLoader.prototype = { + + constructor: THREE.PLYLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setPropertyNameMapping: function ( mapping ) { + + this.propertyNameMapping = mapping; + + }, + + parse: function ( data ) { + + function parseHeader( data ) { + + var patternHeader = /ply([\s\S]*)end_header\s/; + var headerText = ''; + var headerLength = 0; + var result = patternHeader.exec( data ); + + if ( result !== null ) { + + headerText = result[ 1 ]; + headerLength = result[ 0 ].length; + + } + + var header = { + comments: [], + elements: [], + headerLength: headerLength + }; + + var lines = headerText.split( '\n' ); + var currentElement; + var lineType, lineValues; + + function make_ply_element_property( propertValues, propertyNameMapping ) { + + var property = { type: propertValues[ 0 ] }; + + if ( property.type === 'list' ) { + + property.name = propertValues[ 3 ]; + property.countType = propertValues[ 1 ]; + property.itemType = propertValues[ 2 ]; + + } else { + + property.name = propertValues[ 1 ]; + + } + + if ( property.name in propertyNameMapping ) { + + property.name = propertyNameMapping[ property.name ]; + + } + + return property; + + } + + for ( var i = 0; i < lines.length; i ++ ) { + + var line = lines[ i ]; + line = line.trim(); + + if ( line === '' ) continue; + + lineValues = line.split( /\s+/ ); + lineType = lineValues.shift(); + line = lineValues.join( ' ' ); + + switch ( lineType ) { + + case 'format': + + header.format = lineValues[ 0 ]; + header.version = lineValues[ 1 ]; + + break; + + case 'comment': + + header.comments.push( line ); + + break; + + case 'element': + + if ( currentElement !== undefined ) { + + header.elements.push( currentElement ); + + } + + currentElement = {}; + currentElement.name = lineValues[ 0 ]; + currentElement.count = parseInt( lineValues[ 1 ] ); + currentElement.properties = []; + + break; + + case 'property': + + currentElement.properties.push( make_ply_element_property( lineValues, scope.propertyNameMapping ) ); + + break; + + + default: + + console.log( 'unhandled', lineType, lineValues ); + + } + + } + + if ( currentElement !== undefined ) { + + header.elements.push( currentElement ); + + } + + return header; + + } + + function parseASCIINumber( n, type ) { + + switch ( type ) { + + case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint': + case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32': + + return parseInt( n ); + + case 'float': case 'double': case 'float32': case 'float64': + + return parseFloat( n ); + + } + + } + + function parseASCIIElement( properties, line ) { + + var values = line.split( /\s+/ ); + + var element = {}; + + for ( var i = 0; i < properties.length; i ++ ) { + + if ( properties[ i ].type === 'list' ) { + + var list = []; + var n = parseASCIINumber( values.shift(), properties[ i ].countType ); + + for ( var j = 0; j < n; j ++ ) { + + list.push( parseASCIINumber( values.shift(), properties[ i ].itemType ) ); + + } + + element[ properties[ i ].name ] = list; + + } else { + + element[ properties[ i ].name ] = parseASCIINumber( values.shift(), properties[ i ].type ); + + } + + } + + return element; + + } + + function parseASCII( data, header ) { + + // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format) + + var buffer = { + indices: [], + vertices: [], + normals: [], + uvs: [], + faceVertexUvs: [], + colors: [] + }; + + var result; + + var patternBody = /end_header\s([\s\S]*)$/; + var body = ''; + if ( ( result = patternBody.exec( data ) ) !== null ) { + + body = result[ 1 ]; + + } + + var lines = body.split( '\n' ); + var currentElement = 0; + var currentElementCount = 0; + + for ( var i = 0; i < lines.length; i ++ ) { + + var line = lines[ i ]; + line = line.trim(); + if ( line === '' ) { + + continue; + + } + + if ( currentElementCount >= header.elements[ currentElement ].count ) { + + currentElement ++; + currentElementCount = 0; + + } + + var element = parseASCIIElement( header.elements[ currentElement ].properties, line ); + + handleElement( buffer, header.elements[ currentElement ].name, element ); + + currentElementCount ++; + + } + + return postProcess( buffer ); + + } + + function postProcess( buffer ) { + + var geometry = new THREE.BufferGeometry(); + + // mandatory buffer data + + if ( buffer.indices.length > 0 ) { + + geometry.setIndex( buffer.indices ); + + } + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) ); + + // optional buffer data + + if ( buffer.normals.length > 0 ) { + + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) ); + + } + + if ( buffer.uvs.length > 0 ) { + + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) ); + + } + + if ( buffer.colors.length > 0 ) { + + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( buffer.colors, 3 ) ); + + } + + if ( buffer.faceVertexUvs.length > 0 ) { + + geometry = geometry.toNonIndexed(); + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.faceVertexUvs, 2 ) ); + + } + + geometry.computeBoundingSphere(); + + return geometry; + + } + + function handleElement( buffer, elementName, element ) { + + if ( elementName === 'vertex' ) { + + buffer.vertices.push( element.x, element.y, element.z ); + + if ( 'nx' in element && 'ny' in element && 'nz' in element ) { + + buffer.normals.push( element.nx, element.ny, element.nz ); + + } + + if ( 's' in element && 't' in element ) { + + buffer.uvs.push( element.s, element.t ); + + } + + if ( 'red' in element && 'green' in element && 'blue' in element ) { + + buffer.colors.push( element.red / 255.0, element.green / 255.0, element.blue / 255.0 ); + + } + + } else if ( elementName === 'face' ) { + + var vertex_indices = element.vertex_indices || element.vertex_index; // issue #9338 + var texcoord = element.texcoord; + + if ( vertex_indices.length === 3 ) { + + buffer.indices.push( vertex_indices[ 0 ], vertex_indices[ 1 ], vertex_indices[ 2 ] ); + + if ( texcoord && texcoord.length === 6 ) { + + buffer.faceVertexUvs.push( texcoord[ 0 ], texcoord[ 1 ] ); + buffer.faceVertexUvs.push( texcoord[ 2 ], texcoord[ 3 ] ); + buffer.faceVertexUvs.push( texcoord[ 4 ], texcoord[ 5 ] ); + + } + + } else if ( vertex_indices.length === 4 ) { + + buffer.indices.push( vertex_indices[ 0 ], vertex_indices[ 1 ], vertex_indices[ 3 ] ); + buffer.indices.push( vertex_indices[ 1 ], vertex_indices[ 2 ], vertex_indices[ 3 ] ); + + } + + } + + } + + function binaryRead( dataview, at, type, little_endian ) { + + switch ( type ) { + + // corespondences for non-specific length types here match rply: + case 'int8': case 'char': return [ dataview.getInt8( at ), 1 ]; + case 'uint8': case 'uchar': return [ dataview.getUint8( at ), 1 ]; + case 'int16': case 'short': return [ dataview.getInt16( at, little_endian ), 2 ]; + case 'uint16': case 'ushort': return [ dataview.getUint16( at, little_endian ), 2 ]; + case 'int32': case 'int': return [ dataview.getInt32( at, little_endian ), 4 ]; + case 'uint32': case 'uint': return [ dataview.getUint32( at, little_endian ), 4 ]; + case 'float32': case 'float': return [ dataview.getFloat32( at, little_endian ), 4 ]; + case 'float64': case 'double': return [ dataview.getFloat64( at, little_endian ), 8 ]; + + } + + } + + function binaryReadElement( dataview, at, properties, little_endian ) { + + var element = {}; + var result, read = 0; + + for ( var i = 0; i < properties.length; i ++ ) { + + if ( properties[ i ].type === 'list' ) { + + var list = []; + + result = binaryRead( dataview, at + read, properties[ i ].countType, little_endian ); + var n = result[ 0 ]; + read += result[ 1 ]; + + for ( var j = 0; j < n; j ++ ) { + + result = binaryRead( dataview, at + read, properties[ i ].itemType, little_endian ); + list.push( result[ 0 ] ); + read += result[ 1 ]; + + } + + element[ properties[ i ].name ] = list; + + } else { + + result = binaryRead( dataview, at + read, properties[ i ].type, little_endian ); + element[ properties[ i ].name ] = result[ 0 ]; + read += result[ 1 ]; + + } + + } + + return [ element, read ]; + + } + + function parseBinary( data, header ) { + + var buffer = { + indices: [], + vertices: [], + normals: [], + uvs: [], + faceVertexUvs: [], + colors: [] + }; + + var little_endian = ( header.format === 'binary_little_endian' ); + var body = new DataView( data, header.headerLength ); + var result, loc = 0; + + for ( var currentElement = 0; currentElement < header.elements.length; currentElement ++ ) { + + for ( var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount ++ ) { + + result = binaryReadElement( body, loc, header.elements[ currentElement ].properties, little_endian ); + loc += result[ 1 ]; + var element = result[ 0 ]; + + handleElement( buffer, header.elements[ currentElement ].name, element ); + + } + + } + + return postProcess( buffer ); + + } + + // + + var geometry; + var scope = this; + + if ( data instanceof ArrayBuffer ) { + + var text = THREE.LoaderUtils.decodeText( new Uint8Array( data ) ); + var header = parseHeader( text ); + + geometry = header.format === 'ascii' ? parseASCII( text, header ) : parseBinary( data, header ); + + } else { + + geometry = parseASCII( data, parseHeader( data ) ); + + } + + return geometry; + + } + +}; diff --git a/three/jsutil/loaders/PRWMLoader.js b/three/jsutil/loaders/PRWMLoader.js new file mode 100644 index 000000000..8b1997035 --- /dev/null +++ b/three/jsutil/loaders/PRWMLoader.js @@ -0,0 +1,299 @@ +/** + * @author Kevin Chapelier / https://github.com/kchapelier + * See https://github.com/kchapelier/PRWM for more informations about this file format + */ + +( function ( THREE ) { + + 'use strict'; + + var bigEndianPlatform = null; + + /** + * Check if the endianness of the platform is big-endian (most significant bit first) + * @returns {boolean} True if big-endian, false if little-endian + */ + function isBigEndianPlatform() { + + if ( bigEndianPlatform === null ) { + + var buffer = new ArrayBuffer( 2 ), + uint8Array = new Uint8Array( buffer ), + uint16Array = new Uint16Array( buffer ); + + uint8Array[ 0 ] = 0xAA; // set first byte + uint8Array[ 1 ] = 0xBB; // set second byte + bigEndianPlatform = ( uint16Array[ 0 ] === 0xAABB ); + + } + + return bigEndianPlatform; + + } + + // match the values defined in the spec to the TypedArray types + var InvertedEncodingTypes = [ + null, + Float32Array, + null, + Int8Array, + Int16Array, + null, + Int32Array, + Uint8Array, + Uint16Array, + null, + Uint32Array + ]; + + // define the method to use on a DataView, corresponding the TypedArray type + var getMethods = { + Uint16Array: 'getUint16', + Uint32Array: 'getUint32', + Int16Array: 'getInt16', + Int32Array: 'getInt32', + Float32Array: 'getFloat32', + Float64Array: 'getFloat64' + }; + + + function copyFromBuffer( sourceArrayBuffer, viewType, position, length, fromBigEndian ) { + + var bytesPerElement = viewType.BYTES_PER_ELEMENT, + result; + + if ( fromBigEndian === isBigEndianPlatform() || bytesPerElement === 1 ) { + + result = new viewType( sourceArrayBuffer, position, length ); + + } else { + + var readView = new DataView( sourceArrayBuffer, position, length * bytesPerElement ), + getMethod = getMethods[ viewType.name ], + littleEndian = ! fromBigEndian, + i = 0; + + result = new viewType( length ); + + for ( ; i < length; i ++ ) { + + result[ i ] = readView[ getMethod ]( i * bytesPerElement, littleEndian ); + + } + + } + + return result; + + } + + + function decodePrwm( buffer ) { + + var array = new Uint8Array( buffer ), + version = array[ 0 ], + flags = array[ 1 ], + indexedGeometry = !! ( flags >> 7 & 0x01 ), + indicesType = flags >> 6 & 0x01, + bigEndian = ( flags >> 5 & 0x01 ) === 1, + attributesNumber = flags & 0x1F, + valuesNumber = 0, + indicesNumber = 0; + + if ( bigEndian ) { + + valuesNumber = ( array[ 2 ] << 16 ) + ( array[ 3 ] << 8 ) + array[ 4 ]; + indicesNumber = ( array[ 5 ] << 16 ) + ( array[ 6 ] << 8 ) + array[ 7 ]; + + } else { + + valuesNumber = array[ 2 ] + ( array[ 3 ] << 8 ) + ( array[ 4 ] << 16 ); + indicesNumber = array[ 5 ] + ( array[ 6 ] << 8 ) + ( array[ 7 ] << 16 ); + + } + + /** PRELIMINARY CHECKS **/ + + if ( version === 0 ) { + + throw new Error( 'PRWM decoder: Invalid format version: 0' ); + + } else if ( version !== 1 ) { + + throw new Error( 'PRWM decoder: Unsupported format version: ' + version ); + + } + + if ( ! indexedGeometry ) { + + if ( indicesType !== 0 ) { + + throw new Error( 'PRWM decoder: Indices type must be set to 0 for non-indexed geometries' ); + + } else if ( indicesNumber !== 0 ) { + + throw new Error( 'PRWM decoder: Number of indices must be set to 0 for non-indexed geometries' ); + + } + + } + + /** PARSING **/ + + var pos = 8; + + var attributes = {}, + attributeName, + char, + attributeType, + cardinality, + encodingType, + arrayType, + values, + indices, + i; + + for ( i = 0; i < attributesNumber; i ++ ) { + + attributeName = ''; + + while ( pos < array.length ) { + + char = array[ pos ]; + pos ++; + + if ( char === 0 ) { + + break; + + } else { + + attributeName += String.fromCharCode( char ); + + } + + } + + flags = array[ pos ]; + + attributeType = flags >> 7 & 0x01; + cardinality = ( flags >> 4 & 0x03 ) + 1; + encodingType = flags & 0x0F; + arrayType = InvertedEncodingTypes[ encodingType ]; + + pos ++; + + // padding to next multiple of 4 + pos = Math.ceil( pos / 4 ) * 4; + + values = copyFromBuffer( buffer, arrayType, pos, cardinality * valuesNumber, bigEndian ); + + pos += arrayType.BYTES_PER_ELEMENT * cardinality * valuesNumber; + + attributes[ attributeName ] = { + type: attributeType, + cardinality: cardinality, + values: values + }; + + } + + pos = Math.ceil( pos / 4 ) * 4; + + indices = null; + + if ( indexedGeometry ) { + + indices = copyFromBuffer( + buffer, + indicesType === 1 ? Uint32Array : Uint16Array, + pos, + indicesNumber, + bigEndian + ); + + } + + return { + version: version, + attributes: attributes, + indices: indices + }; + + } + + // Define the public interface + + THREE.PRWMLoader = function PRWMLoader( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + }; + + THREE.PRWMLoader.prototype = { + + constructor: THREE.PRWMLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + + url = url.replace( /\*/g, isBigEndianPlatform() ? 'be' : 'le' ); + + loader.load( url, function ( arrayBuffer ) { + + onLoad( scope.parse( arrayBuffer ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( arrayBuffer ) { + + console.time( 'PRWMLoader' ); + + var data = decodePrwm( arrayBuffer ), + attributesKey = Object.keys( data.attributes ), + bufferGeometry = new THREE.BufferGeometry(), + attribute, + i; + + for ( i = 0; i < attributesKey.length; i ++ ) { + + attribute = data.attributes[ attributesKey[ i ] ]; + bufferGeometry.addAttribute( attributesKey[ i ], new THREE.BufferAttribute( attribute.values, attribute.cardinality, attribute.normalized ) ); + + } + + if ( data.indices !== null ) { + + bufferGeometry.setIndex( new THREE.BufferAttribute( data.indices, 1 ) ); + + } + + console.timeEnd( 'PRWMLoader' ); + + return bufferGeometry; + + } + + }; + + THREE.PRWMLoader.isBigEndianPlatform = function () { + + return isBigEndianPlatform(); + + }; + +} )( THREE ); diff --git a/three/jsutil/loaders/PVRLoader.js b/three/jsutil/loaders/PVRLoader.js new file mode 100644 index 000000000..a4007eedf --- /dev/null +++ b/three/jsutil/loaders/PVRLoader.js @@ -0,0 +1,246 @@ +/* + * PVRLoader + * Author: pierre lepers + * Date: 17/09/2014 11:09 + * + * PVR v2 (legacy) parser + * TODO : Add Support for PVR v3 format + * TODO : implement loadMipmaps option + */ + +THREE.PVRLoader = function ( manager ) { + + THREE.CompressedTextureLoader.call( this, manager ); + + this._parser = THREE.PVRLoader.parse; + +}; + +THREE.PVRLoader.prototype = Object.create( THREE.CompressedTextureLoader.prototype ); +THREE.PVRLoader.prototype.constructor = THREE.PVRLoader; + + +THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) { + + var headerLengthInt = 13; + var header = new Uint32Array( buffer, 0, headerLengthInt ); + + var pvrDatas = { + buffer: buffer, + header: header, + loadMipmaps: loadMipmaps + }; + + if ( header[ 0 ] === 0x03525650 ) { + + // PVR v3 + + return THREE.PVRLoader._parseV3( pvrDatas ); + + } else if ( header[ 11 ] === 0x21525650 ) { + + // PVR v2 + + return THREE.PVRLoader._parseV2( pvrDatas ); + + } else { + + console.error( 'THREE.PVRLoader: Unknown PVR format.' ); + + } + +}; + +THREE.PVRLoader._parseV3 = function ( pvrDatas ) { + + var header = pvrDatas.header; + var bpp, format; + + + var metaLen = header[ 12 ], + pixelFormat = header[ 2 ], + height = header[ 6 ], + width = header[ 7 ], + // numSurfs = header[ 9 ], + numFaces = header[ 10 ], + numMipmaps = header[ 11 ]; + + switch ( pixelFormat ) { + + case 0 : // PVRTC 2bpp RGB + bpp = 2; + format = THREE.RGB_PVRTC_2BPPV1_Format; + break; + + case 1 : // PVRTC 2bpp RGBA + bpp = 2; + format = THREE.RGBA_PVRTC_2BPPV1_Format; + break; + + case 2 : // PVRTC 4bpp RGB + bpp = 4; + format = THREE.RGB_PVRTC_4BPPV1_Format; + break; + + case 3 : // PVRTC 4bpp RGBA + bpp = 4; + format = THREE.RGBA_PVRTC_4BPPV1_Format; + break; + + default : + console.error( 'THREE.PVRLoader: Unsupported PVR format:', pixelFormat ); + + } + + pvrDatas.dataPtr = 52 + metaLen; + pvrDatas.bpp = bpp; + pvrDatas.format = format; + pvrDatas.width = width; + pvrDatas.height = height; + pvrDatas.numSurfaces = numFaces; + pvrDatas.numMipmaps = numMipmaps; + pvrDatas.isCubemap = ( numFaces === 6 ); + + return THREE.PVRLoader._extract( pvrDatas ); + +}; + +THREE.PVRLoader._parseV2 = function ( pvrDatas ) { + + var header = pvrDatas.header; + + var headerLength = header[ 0 ], + height = header[ 1 ], + width = header[ 2 ], + numMipmaps = header[ 3 ], + flags = header[ 4 ], + // dataLength = header[ 5 ], + // bpp = header[ 6 ], + // bitmaskRed = header[ 7 ], + // bitmaskGreen = header[ 8 ], + // bitmaskBlue = header[ 9 ], + bitmaskAlpha = header[ 10 ], + // pvrTag = header[ 11 ], + numSurfs = header[ 12 ]; + + + var TYPE_MASK = 0xff; + var PVRTC_2 = 24, + PVRTC_4 = 25; + + var formatFlags = flags & TYPE_MASK; + + var bpp, format; + var _hasAlpha = bitmaskAlpha > 0; + + if ( formatFlags === PVRTC_4 ) { + + format = _hasAlpha ? THREE.RGBA_PVRTC_4BPPV1_Format : THREE.RGB_PVRTC_4BPPV1_Format; + bpp = 4; + + } else if ( formatFlags === PVRTC_2 ) { + + format = _hasAlpha ? THREE.RGBA_PVRTC_2BPPV1_Format : THREE.RGB_PVRTC_2BPPV1_Format; + bpp = 2; + + } else { + + console.error( 'THREE.PVRLoader: Unknown PVR format:', formatFlags ); + + } + + pvrDatas.dataPtr = headerLength; + pvrDatas.bpp = bpp; + pvrDatas.format = format; + pvrDatas.width = width; + pvrDatas.height = height; + pvrDatas.numSurfaces = numSurfs; + pvrDatas.numMipmaps = numMipmaps + 1; + + // guess cubemap type seems tricky in v2 + // it juste a pvr containing 6 surface (no explicit cubemap type) + pvrDatas.isCubemap = ( numSurfs === 6 ); + + return THREE.PVRLoader._extract( pvrDatas ); + +}; + + +THREE.PVRLoader._extract = function ( pvrDatas ) { + + var pvr = { + mipmaps: [], + width: pvrDatas.width, + height: pvrDatas.height, + format: pvrDatas.format, + mipmapCount: pvrDatas.numMipmaps, + isCubemap: pvrDatas.isCubemap + }; + + var buffer = pvrDatas.buffer; + + var dataOffset = pvrDatas.dataPtr, + bpp = pvrDatas.bpp, + numSurfs = pvrDatas.numSurfaces, + dataSize = 0, + blockSize = 0, + blockWidth = 0, + blockHeight = 0, + widthBlocks = 0, + heightBlocks = 0; + + if ( bpp === 2 ) { + + blockWidth = 8; + blockHeight = 4; + + } else { + + blockWidth = 4; + blockHeight = 4; + + } + + blockSize = ( blockWidth * blockHeight ) * bpp / 8; + + pvr.mipmaps.length = pvrDatas.numMipmaps * numSurfs; + + var mipLevel = 0; + + while ( mipLevel < pvrDatas.numMipmaps ) { + + var sWidth = pvrDatas.width >> mipLevel, + sHeight = pvrDatas.height >> mipLevel; + + widthBlocks = sWidth / blockWidth; + heightBlocks = sHeight / blockHeight; + + // Clamp to minimum number of blocks + if ( widthBlocks < 2 ) widthBlocks = 2; + if ( heightBlocks < 2 ) heightBlocks = 2; + + dataSize = widthBlocks * heightBlocks * blockSize; + + for ( var surfIndex = 0; surfIndex < numSurfs; surfIndex ++ ) { + + var byteArray = new Uint8Array( buffer, dataOffset, dataSize ); + + var mipmap = { + data: byteArray, + width: sWidth, + height: sHeight + }; + + pvr.mipmaps[ surfIndex * pvrDatas.numMipmaps + mipLevel ] = mipmap; + + dataOffset += dataSize; + + } + + mipLevel ++; + + } + + return pvr; + +}; diff --git a/three/jsutil/loaders/PlayCanvasLoader.js b/three/jsutil/loaders/PlayCanvasLoader.js new file mode 100644 index 000000000..00f8ced7d --- /dev/null +++ b/three/jsutil/loaders/PlayCanvasLoader.js @@ -0,0 +1,203 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / https://github.com/Mugen87 + */ + +THREE.PlayCanvasLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.PlayCanvasLoader.prototype = { + + constructor: THREE.PlayCanvasLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( JSON.parse( text ) ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( json ) { + + function parseVertices( data ) { + + var attributes = {}; + + // create a buffer attribute for each array that contains vertex information + + for ( var name in data ) { + + var array = data[ name ]; + + var type = array.type; + var size = array.components; + + var attribute; + + switch ( type ) { + + case 'float32': + attribute = new THREE.Float32BufferAttribute( array.data, size ); + break; + + case 'uint8': + attribute = new THREE.Uint8BufferAttribute( array.data, size ); + break; + + case 'uint16': + attribute = new THREE.Uint16BufferAttribute( array.data, size ); + break; + + default: + console.log( 'THREE.PlayCanvasLoader: Array type "%s" not yet supported.', type ); + + } + + attributes[ name ] = attribute; + + } + + data._attributes = attributes; + + } + + function parseMeshes( data ) { + + // create buffer geometry + + var geometry = new THREE.BufferGeometry(); + + geometry.setIndex( data.indices ); + + var attributes = model.vertices[ data.vertices ]._attributes; + + for ( var name in attributes ) { + + var attribute = attributes[ name ]; + + if ( name === 'texCoord0' ) name = 'uv'; + + geometry.addAttribute( name, attribute ); + + } + + data._geometry = geometry; + + } + + function parseMeshInstances( data ) { + + var node = model.nodes[ data.node ]; + var mesh = model.meshes[ data.mesh ]; + + if ( node._geometries === undefined ) { + + node._geometries = []; + + } + + node._geometries.push( mesh._geometry ); + + } + + function parseNodes( data ) { + + var object = new THREE.Group(); + + var geometries = data._geometries; + + if ( geometries !== undefined ) { + + var material = new THREE.MeshPhongMaterial(); + + for ( var i = 0, l = geometries.length; i < l; i ++ ) { + + var geometry = geometries[ i ]; + + object.add( new THREE.Mesh( geometry, material ) ); + + } + + } + + for ( var i = 0, l = data.rotation.length; i < l; i ++ ) { + + data.rotation[ i ] *= Math.PI / 180; + + } + + // + + object.name = data.name; + + object.position.fromArray( data.position ); + object.quaternion.setFromEuler( new THREE.Euler().fromArray( data.rotation ) ); + object.scale.fromArray( data.scale ); + + data._object = object; + + } + + // + + var model = json.model; + + for ( var i = 0, l = model.vertices.length; i < l; i ++ ) { + + parseVertices( model.vertices[ i ] ); + + } + + for ( var i = 0, l = model.meshes.length; i < l; i ++ ) { + + parseMeshes( model.meshes[ i ] ); + + } + + for ( var i = 0, l = model.meshInstances.length; i < l; i ++ ) { + + parseMeshInstances( model.meshInstances[ i ] ); + + } + + for ( var i = 0, l = model.nodes.length; i < l; i ++ ) { + + parseNodes( model.nodes[ i ] ); + + } + + // setup scene hierarchy + + for ( var i = 0, l = model.parents.length; i < l; i ++ ) { + + var parent = model.parents[ i ]; + + if ( parent === - 1 ) continue; + + model.nodes[ parent ]._object.add( model.nodes[ i ]._object ); + + + } + + return model.nodes[ 0 ]._object; + + } + +}; diff --git a/three/jsutil/loaders/RGBELoader.js b/three/jsutil/loaders/RGBELoader.js new file mode 100644 index 000000000..b79ff88e9 --- /dev/null +++ b/three/jsutil/loaders/RGBELoader.js @@ -0,0 +1,346 @@ +/** + * @author Nikos M. / https://github.com/foo123/ + */ + +// https://github.com/mrdoob/three.js/issues/5552 +// http://en.wikipedia.org/wiki/RGBE_image_format + +THREE.HDRLoader = THREE.RGBELoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +// extend THREE.DataTextureLoader +THREE.RGBELoader.prototype = Object.create( THREE.DataTextureLoader.prototype ); + +// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html +THREE.RGBELoader.prototype._parser = function ( buffer ) { + + var + /* return codes for rgbe routines */ + RGBE_RETURN_SUCCESS = 0, + RGBE_RETURN_FAILURE = - 1, + + /* default error routine. change this to change error handling */ + rgbe_read_error = 1, + rgbe_write_error = 2, + rgbe_format_error = 3, + rgbe_memory_error = 4, + rgbe_error = function ( rgbe_error_code, msg ) { + + switch ( rgbe_error_code ) { + + case rgbe_read_error: console.error( "THREE.RGBELoader Read Error: " + ( msg || '' ) ); + break; + case rgbe_write_error: console.error( "THREE.RGBELoader Write Error: " + ( msg || '' ) ); + break; + case rgbe_format_error: console.error( "THREE.RGBELoader Bad File Format: " + ( msg || '' ) ); + break; + default: + case rgbe_memory_error: console.error( "THREE.RGBELoader: Error: " + ( msg || '' ) ); + + } + return RGBE_RETURN_FAILURE; + + }, + + /* offsets to red, green, and blue components in a data (float) pixel */ + RGBE_DATA_RED = 0, + RGBE_DATA_GREEN = 1, + RGBE_DATA_BLUE = 2, + + /* number of floats per pixel, use 4 since stored in rgba image format */ + RGBE_DATA_SIZE = 4, + + /* flags indicating which fields in an rgbe_header_info are valid */ + RGBE_VALID_PROGRAMTYPE = 1, + RGBE_VALID_FORMAT = 2, + RGBE_VALID_DIMENSIONS = 4, + + NEWLINE = "\n", + + fgets = function ( buffer, lineLimit, consume ) { + + lineLimit = ! lineLimit ? 1024 : lineLimit; + var p = buffer.pos, + i = - 1, len = 0, s = '', chunkSize = 128, + chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) ) + ; + while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) { + + s += chunk; len += chunk.length; + p += chunkSize; + chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) ); + + } + + if ( - 1 < i ) { + + /*for (i=l-1; i>=0; i--) { + byteCode = m.charCodeAt(i); + if (byteCode > 0x7f && byteCode <= 0x7ff) byteLen++; + else if (byteCode > 0x7ff && byteCode <= 0xffff) byteLen += 2; + if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate + }*/ + if ( false !== consume ) buffer.pos += len + i + 1; + return s + chunk.slice( 0, i ); + + } + return false; + + }, + + /* minimal header reading. modify if you want to parse more information */ + RGBE_ReadHeader = function ( buffer ) { + + var line, match, + + // regexes to parse header info fields + magic_token_re = /^#\?(\S+)$/, + gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, + exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, + format_re = /^\s*FORMAT=(\S+)\s*$/, + dimensions_re = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, + + // RGBE format header struct + header = { + + valid: 0, /* indicate which fields are valid */ + + string: '', /* the actual header string */ + + comments: '', /* comments found in header */ + + programtype: 'RGBE', /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */ + + format: '', /* RGBE format, default 32-bit_rle_rgbe */ + + gamma: 1.0, /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */ + + exposure: 1.0, /* a value of 1.0 in an image corresponds to watts/steradian/m^2. defaults to 1.0 */ + + width: 0, height: 0 /* image dimensions, width/height */ + + }; + + if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) { + + return rgbe_error( rgbe_read_error, "no header found" ); + + } + /* if you want to require the magic token then uncomment the next line */ + if ( ! ( match = line.match( magic_token_re ) ) ) { + + return rgbe_error( rgbe_format_error, "bad initial token" ); + + } + header.valid |= RGBE_VALID_PROGRAMTYPE; + header.programtype = match[ 1 ]; + header.string += line + "\n"; + + while ( true ) { + + line = fgets( buffer ); + if ( false === line ) break; + header.string += line + "\n"; + + if ( '#' === line.charAt( 0 ) ) { + + header.comments += line + "\n"; + continue; // comment line + + } + + if ( match = line.match( gamma_re ) ) { + + header.gamma = parseFloat( match[ 1 ], 10 ); + + } + if ( match = line.match( exposure_re ) ) { + + header.exposure = parseFloat( match[ 1 ], 10 ); + + } + if ( match = line.match( format_re ) ) { + + header.valid |= RGBE_VALID_FORMAT; + header.format = match[ 1 ];//'32-bit_rle_rgbe'; + + } + if ( match = line.match( dimensions_re ) ) { + + header.valid |= RGBE_VALID_DIMENSIONS; + header.height = parseInt( match[ 1 ], 10 ); + header.width = parseInt( match[ 2 ], 10 ); + + } + + if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break; + + } + + if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) { + + return rgbe_error( rgbe_format_error, "missing format specifier" ); + + } + if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) { + + return rgbe_error( rgbe_format_error, "missing image size specifier" ); + + } + + return header; + + }, + + RGBE_ReadPixels_RLE = function ( buffer, w, h ) { + + var data_rgba, offset, pos, count, byteValue, + scanline_buffer, ptr, ptr_end, i, l, off, isEncodedRun, + scanline_width = w, num_scanlines = h, rgbeStart + ; + + if ( + // run length encoding is not allowed so read flat + ( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) || + // this file is not run length encoded + ( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) ) + ) { + + // return the flat buffer + return new Uint8Array( buffer ); + + } + + if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) { + + return rgbe_error( rgbe_format_error, "wrong scanline width" ); + + } + + data_rgba = new Uint8Array( 4 * w * h ); + + if ( ! data_rgba || ! data_rgba.length ) { + + return rgbe_error( rgbe_memory_error, "unable to allocate buffer space" ); + + } + + offset = 0; pos = 0; ptr_end = 4 * scanline_width; + rgbeStart = new Uint8Array( 4 ); + scanline_buffer = new Uint8Array( ptr_end ); + + // read in each successive scanline + while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) { + + if ( pos + 4 > buffer.byteLength ) { + + return rgbe_error( rgbe_read_error ); + + } + + rgbeStart[ 0 ] = buffer[ pos ++ ]; + rgbeStart[ 1 ] = buffer[ pos ++ ]; + rgbeStart[ 2 ] = buffer[ pos ++ ]; + rgbeStart[ 3 ] = buffer[ pos ++ ]; + + if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) { + + return rgbe_error( rgbe_format_error, "bad rgbe scanline format" ); + + } + + // read each of the four channels for the scanline into the buffer + // first red, then green, then blue, then exponent + ptr = 0; + while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) { + + count = buffer[ pos ++ ]; + isEncodedRun = count > 128; + if ( isEncodedRun ) count -= 128; + + if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) { + + return rgbe_error( rgbe_format_error, "bad scanline data" ); + + } + + if ( isEncodedRun ) { + + // a (encoded) run of the same value + byteValue = buffer[ pos ++ ]; + for ( i = 0; i < count; i ++ ) { + + scanline_buffer[ ptr ++ ] = byteValue; + + } + //ptr += count; + + } else { + + // a literal-run + scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr ); + ptr += count; pos += count; + + } + + } + + + // now convert data from buffer into rgba + // first red, then green, then blue, then exponent (alpha) + l = scanline_width; //scanline_buffer.byteLength; + for ( i = 0; i < l; i ++ ) { + + off = 0; + data_rgba[ offset ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 1 ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 2 ] = scanline_buffer[ i + off ]; + off += scanline_width; //1; + data_rgba[ offset + 3 ] = scanline_buffer[ i + off ]; + offset += 4; + + } + + num_scanlines --; + + } + + return data_rgba; + + } + ; + + var byteArray = new Uint8Array( buffer ), + byteLength = byteArray.byteLength; + byteArray.pos = 0; + var rgbe_header_info = RGBE_ReadHeader( byteArray ); + + if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) { + + var w = rgbe_header_info.width, + h = rgbe_header_info.height, + image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h ) + ; + if ( RGBE_RETURN_FAILURE !== image_rgba_data ) { + + return { + width: w, height: h, + data: image_rgba_data, + header: rgbe_header_info.string, + gamma: rgbe_header_info.gamma, + exposure: rgbe_header_info.exposure, + format: THREE.RGBEFormat, // handled as THREE.RGBAFormat in shaders + type: THREE.UnsignedByteType + }; + + } + + } + return null; + +}; diff --git a/three/jsutil/loaders/STLLoader.js b/three/jsutil/loaders/STLLoader.js new file mode 100644 index 000000000..c54b93175 --- /dev/null +++ b/three/jsutil/loaders/STLLoader.js @@ -0,0 +1,342 @@ +/** + * @author aleeper / http://adamleeper.com/ + * @author mrdoob / http://mrdoob.com/ + * @author gero3 / https://github.com/gero3 + * @author Mugen87 / https://github.com/Mugen87 + * + * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs. + * + * Supports both binary and ASCII encoded files, with automatic detection of type. + * + * The loader returns a non-indexed buffer geometry. + * + * Limitations: + * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL). + * There is perhaps some question as to how valid it is to always assume little-endian-ness. + * ASCII decoding assumes file is UTF-8. + * + * Usage: + * var loader = new THREE.STLLoader(); + * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) { + * scene.add( new THREE.Mesh( geometry ) ); + * }); + * + * For binary STLs geometry might contain colors for vertices. To use it: + * // use the same code to load STL as above + * if (geometry.hasColors) { + * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors }); + * } else { .... } + * var mesh = new THREE.Mesh( geometry, material ); + */ + + +THREE.STLLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.STLLoader.prototype = { + + constructor: THREE.STLLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( text ) { + + try { + + onLoad( scope.parse( text ) ); + + } catch ( exception ) { + + if ( onError ) { + + onError( exception ); + + } + + } + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + function isBinary( data ) { + + var expect, face_size, n_faces, reader; + reader = new DataView( data ); + face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 ); + n_faces = reader.getUint32( 80, true ); + expect = 80 + ( 32 / 8 ) + ( n_faces * face_size ); + + if ( expect === reader.byteLength ) { + + return true; + + } + + // An ASCII STL data must begin with 'solid ' as the first six bytes. + // However, ASCII STLs lacking the SPACE after the 'd' are known to be + // plentiful. So, check the first 5 bytes for 'solid'. + + // Several encodings, such as UTF-8, precede the text with up to 5 bytes: + // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding + // Search for "solid" to start anywhere after those prefixes. + + // US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd' + + var solid = [ 115, 111, 108, 105, 100 ]; + + for ( var off = 0; off < 5; off ++ ) { + + // If "solid" text is matched to the current offset, declare it to be an ASCII STL. + + if ( matchDataViewAt ( solid, reader, off ) ) return false; + + } + + // Couldn't find "solid" text at the beginning; it is binary STL. + + return true; + + } + + function matchDataViewAt( query, reader, offset ) { + + // Check if each byte in query matches the corresponding byte from the current offset + + for ( var i = 0, il = query.length; i < il; i ++ ) { + + if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false; + + } + + return true; + + } + + function parseBinary( data ) { + + var reader = new DataView( data ); + var faces = reader.getUint32( 80, true ); + + var r, g, b, hasColors = false, colors; + var defaultR, defaultG, defaultB, alpha; + + // process STL header + // check for default color in header ("COLOR=rgba" sequence). + + for ( var index = 0; index < 80 - 10; index ++ ) { + + if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) && + ( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) && + ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) { + + hasColors = true; + colors = []; + + defaultR = reader.getUint8( index + 6 ) / 255; + defaultG = reader.getUint8( index + 7 ) / 255; + defaultB = reader.getUint8( index + 8 ) / 255; + alpha = reader.getUint8( index + 9 ) / 255; + + } + + } + + var dataOffset = 84; + var faceLength = 12 * 4 + 2; + + var geometry = new THREE.BufferGeometry(); + + var vertices = []; + var normals = []; + + for ( var face = 0; face < faces; face ++ ) { + + var start = dataOffset + face * faceLength; + var normalX = reader.getFloat32( start, true ); + var normalY = reader.getFloat32( start + 4, true ); + var normalZ = reader.getFloat32( start + 8, true ); + + if ( hasColors ) { + + var packedColor = reader.getUint16( start + 48, true ); + + if ( ( packedColor & 0x8000 ) === 0 ) { + + // facet has its own unique color + + r = ( packedColor & 0x1F ) / 31; + g = ( ( packedColor >> 5 ) & 0x1F ) / 31; + b = ( ( packedColor >> 10 ) & 0x1F ) / 31; + + } else { + + r = defaultR; + g = defaultG; + b = defaultB; + + } + + } + + for ( var i = 1; i <= 3; i ++ ) { + + var vertexstart = start + i * 12; + + vertices.push( reader.getFloat32( vertexstart, true ) ); + vertices.push( reader.getFloat32( vertexstart + 4, true ) ); + vertices.push( reader.getFloat32( vertexstart + 8, true ) ); + + normals.push( normalX, normalY, normalZ ); + + if ( hasColors ) { + + colors.push( r, g, b ); + + } + + } + + } + + geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) ); + geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) ); + + if ( hasColors ) { + + geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( colors ), 3 ) ); + geometry.hasColors = true; + geometry.alpha = alpha; + + } + + return geometry; + + } + + function parseASCII( data ) { + + var geometry = new THREE.BufferGeometry(); + var patternFace = /facet([\s\S]*?)endfacet/g; + var faceCounter = 0; + + var patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source; + var patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' ); + var patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' ); + + var vertices = []; + var normals = []; + + var normal = new THREE.Vector3(); + + var result; + + while ( ( result = patternFace.exec( data ) ) !== null ) { + + var vertexCountPerFace = 0; + var normalCountPerFace = 0; + + var text = result[ 0 ]; + + while ( ( result = patternNormal.exec( text ) ) !== null ) { + + normal.x = parseFloat( result[ 1 ] ); + normal.y = parseFloat( result[ 2 ] ); + normal.z = parseFloat( result[ 3 ] ); + normalCountPerFace ++; + + } + + while ( ( result = patternVertex.exec( text ) ) !== null ) { + + vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) ); + normals.push( normal.x, normal.y, normal.z ); + vertexCountPerFace ++; + + } + + // every face have to own ONE valid normal + + if ( normalCountPerFace !== 1 ) { + + console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter ); + + } + + // each face have to own THREE valid vertices + + if ( vertexCountPerFace !== 3 ) { + + console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter ); + + } + + faceCounter ++; + + } + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + return geometry; + + } + + function ensureString( buffer ) { + + if ( typeof buffer !== 'string' ) { + + return THREE.LoaderUtils.decodeText( new Uint8Array( buffer ) ); + + } + + return buffer; + + } + + function ensureBinary( buffer ) { + + if ( typeof buffer === 'string' ) { + + var array_buffer = new Uint8Array( buffer.length ); + for ( var i = 0; i < buffer.length; i ++ ) { + + array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian + + } + return array_buffer.buffer || array_buffer; + + } else { + + return buffer; + + } + + } + + // start + + var binData = ensureBinary( data ); + + return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) ); + + } + +}; diff --git a/three/jsutil/loaders/SVGLoader.js b/three/jsutil/loaders/SVGLoader.js new file mode 100644 index 000000000..a71ffa583 --- /dev/null +++ b/three/jsutil/loaders/SVGLoader.js @@ -0,0 +1,1012 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author zz85 / http://joshuakoo.com/ + * @author yomboprime / https://yombo.org + */ + +THREE.SVGLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.SVGLoader.prototype = { + + constructor: THREE.SVGLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( text ) { + + function parseNode( node, style ) { + + if ( node.nodeType !== 1 ) return; + + var transform = getNodeTransform( node ); + + var path = null; + + switch ( node.nodeName ) { + + case 'svg': + break; + + case 'g': + style = parseStyle( node, style ); + break; + + case 'path': + style = parseStyle( node, style ); + if ( node.hasAttribute( 'd' ) && isVisible( style ) ) path = parsePathNode( node, style ); + break; + + case 'rect': + style = parseStyle( node, style ); + if ( isVisible( style ) ) path = parseRectNode( node, style ); + break; + + case 'polygon': + style = parseStyle( node, style ); + if ( isVisible( style ) ) path = parsePolygonNode( node, style ); + break; + + case 'polyline': + style = parseStyle( node, style ); + if ( isVisible( style ) ) path = parsePolylineNode( node, style ); + break; + + case 'circle': + style = parseStyle( node, style ); + if ( isVisible( style ) ) path = parseCircleNode( node, style ); + break; + + case 'ellipse': + style = parseStyle( node, style ); + if ( isVisible( style ) ) path = parseEllipseNode( node, style ); + break; + + case 'line': + style = parseStyle( node, style ); + if ( isVisible( style ) ) path = parseLineNode( node, style ); + break; + + default: + console.log( node ); + + } + + if ( path ) { + + transformPath( path, currentTransform ); + + paths.push( path ); + + } + + var nodes = node.childNodes; + + for ( var i = 0; i < nodes.length; i ++ ) { + + parseNode( nodes[ i ], style ); + + } + + if ( transform ) { + + currentTransform.copy( transformStack.pop() ); + + } + + } + + function parsePathNode( node, style ) { + + var path = new THREE.ShapePath(); + path.color.setStyle( style.fill ); + + var point = new THREE.Vector2(); + var control = new THREE.Vector2(); + + var firstPoint = new THREE.Vector2(); + var isFirstPoint = true; + var doSetFirstPoint = false; + + var d = node.getAttribute( 'd' ); + + // console.log( d ); + + var commands = d.match( /[a-df-z][^a-df-z]*/ig ); + + for ( var i = 0, l = commands.length; i < l; i ++ ) { + + var command = commands[ i ]; + + var type = command.charAt( 0 ); + var data = command.substr( 1 ).trim(); + + if ( isFirstPoint ) { + doSetFirstPoint = true; + } + isFirstPoint = false; + + switch ( type ) { + + case 'M': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 2 ) { + point.x = numbers[ j + 0 ]; + point.y = numbers[ j + 1 ]; + control.x = point.x; + control.y = point.y; + if ( j === 0 ) { + path.moveTo( point.x, point.y ); + } else { + path.lineTo( point.x, point.y ); + } + } + break; + + case 'H': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j ++ ) { + point.x = numbers[ j ]; + control.x = point.x; + control.y = point.y; + path.lineTo( point.x, point.y ); + } + break; + + case 'V': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j ++ ) { + point.y = numbers[ j ]; + control.x = point.x; + control.y = point.y; + path.lineTo( point.x, point.y ); + } + break; + + case 'L': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 2 ) { + point.x = numbers[ j + 0 ]; + point.y = numbers[ j + 1 ]; + control.x = point.x; + control.y = point.y; + path.lineTo( point.x, point.y ); + } + break; + + case 'C': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 6 ) { + path.bezierCurveTo( + numbers[ j + 0 ], + numbers[ j + 1 ], + numbers[ j + 2 ], + numbers[ j + 3 ], + numbers[ j + 4 ], + numbers[ j + 5 ] + ); + control.x = numbers[ j + 2 ]; + control.y = numbers[ j + 3 ]; + point.x = numbers[ j + 4 ]; + point.y = numbers[ j + 5 ]; + } + break; + + case 'S': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 4 ) { + path.bezierCurveTo( + getReflection( point.x, control.x ), + getReflection( point.y, control.y ), + numbers[ j + 0 ], + numbers[ j + 1 ], + numbers[ j + 2 ], + numbers[ j + 3 ] + ); + control.x = numbers[ j + 0 ]; + control.y = numbers[ j + 1 ]; + point.x = numbers[ j + 2 ]; + point.y = numbers[ j + 3 ]; + } + break; + + case 'Q': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 4 ) { + path.quadraticCurveTo( + numbers[ j + 0 ], + numbers[ j + 1 ], + numbers[ j + 2 ], + numbers[ j + 3 ] + ); + control.x = numbers[ j + 0 ]; + control.y = numbers[ j + 1 ]; + point.x = numbers[ j + 2 ]; + point.y = numbers[ j + 3 ]; + } + break; + + case 'T': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 2 ) { + var rx = getReflection( point.x, control.x ); + var ry = getReflection( point.y, control.y ); + path.quadraticCurveTo( + rx, + ry, + numbers[ j + 0 ], + numbers[ j + 1 ] + ); + control.x = rx; + control.y = ry; + point.x = numbers[ j + 0 ]; + point.y = numbers[ j + 1 ]; + } + break; + + case 'A': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) { + var start = point.clone(); + point.x = numbers[ j + 5 ]; + point.y = numbers[ j + 6 ]; + control.x = point.x; + control.y = point.y; + parseArcCommand( + path, numbers[ j ], numbers[ j + 1 ], numbers[ j + 2 ], numbers[ j + 3 ], numbers[ j + 4 ], start, point + ); + } + break; + + // + + case 'm': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 2 ) { + point.x += numbers[ j + 0 ]; + point.y += numbers[ j + 1 ]; + control.x = point.x; + control.y = point.y; + if ( j === 0 ) { + path.moveTo( point.x, point.y ); + } else { + path.lineTo( point.x, point.y ); + } + } + break; + + case 'h': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j ++ ) { + point.x += numbers[ j ]; + control.x = point.x; + control.y = point.y; + path.lineTo( point.x, point.y ); + } + break; + + case 'v': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j ++ ) { + point.y += numbers[ j ]; + control.x = point.x; + control.y = point.y; + path.lineTo( point.x, point.y ); + } + break; + + case 'l': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 2 ) { + point.x += numbers[ j + 0 ]; + point.y += numbers[ j + 1 ]; + control.x = point.x; + control.y = point.y; + path.lineTo( point.x, point.y ); + } + break; + + case 'c': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 6 ) { + path.bezierCurveTo( + point.x + numbers[ j + 0 ], + point.y + numbers[ j + 1 ], + point.x + numbers[ j + 2 ], + point.y + numbers[ j + 3 ], + point.x + numbers[ j + 4 ], + point.y + numbers[ j + 5 ] + ); + control.x = point.x + numbers[ j + 2 ]; + control.y = point.y + numbers[ j + 3 ]; + point.x += numbers[ j + 4 ]; + point.y += numbers[ j + 5 ]; + } + break; + + case 's': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 4 ) { + path.bezierCurveTo( + getReflection( point.x, control.x ), + getReflection( point.y, control.y ), + point.x + numbers[ j + 0 ], + point.y + numbers[ j + 1 ], + point.x + numbers[ j + 2 ], + point.y + numbers[ j + 3 ] + ); + control.x = point.x + numbers[ j + 0 ]; + control.y = point.y + numbers[ j + 1 ]; + point.x += numbers[ j + 2 ]; + point.y += numbers[ j + 3 ]; + } + break; + + case 'q': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 4 ) { + path.quadraticCurveTo( + point.x + numbers[ j + 0 ], + point.y + numbers[ j + 1 ], + point.x + numbers[ j + 2 ], + point.y + numbers[ j + 3 ] + ); + control.x = point.x + numbers[ j + 0 ]; + control.y = point.y + numbers[ j + 1 ]; + point.x += numbers[ j + 2 ]; + point.y += numbers[ j + 3 ]; + } + break; + + case 't': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 2 ) { + var rx = getReflection( point.x, control.x ); + var ry = getReflection( point.y, control.y ); + path.quadraticCurveTo( + rx, + ry, + point.x + numbers[ j + 0 ], + point.y + numbers[ j + 1 ] + ); + control.x = rx; + control.y = ry; + point.x = point.x + numbers[ j + 0 ]; + point.y = point.y + numbers[ j + 1 ]; + } + break; + + case 'a': + var numbers = parseFloats( data ); + for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) { + var start = point.clone(); + point.x += numbers[ j + 5 ]; + point.y += numbers[ j + 6 ]; + control.x = point.x; + control.y = point.y; + parseArcCommand( + path, numbers[ j ], numbers[ j + 1 ], numbers[ j + 2 ], numbers[ j + 3 ], numbers[ j + 4 ], start, point + ); + } + break; + + // + + case 'Z': + case 'z': + path.currentPath.autoClose = true; + if ( path.currentPath.curves.length > 0 ) { + // Reset point to beginning of Path + point.copy( firstPoint ); + path.currentPath.currentPoint.copy( point ); + isFirstPoint = true; + } + break; + + default: + console.warn( command ); + + } + + // console.log( type, parseFloats( data ), parseFloats( data ).length ) + + if ( doSetFirstPoint ) { + + firstPoint.copy( point ); + + doSetFirstPoint = false; + + } + } + + return path; + + } + + /** + * https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes + * https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion + * From + * rx ry x-axis-rotation large-arc-flag sweep-flag x y + * To + * aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation + */ + + function parseArcCommand( path, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, start, end ) { + + x_axis_rotation = x_axis_rotation * Math.PI / 180; + + // Ensure radii are positive + rx = Math.abs( rx ); + ry = Math.abs( ry ); + + // Compute (x1′, y1′) + var dx2 = ( start.x - end.x ) / 2.0; + var dy2 = ( start.y - end.y ) / 2.0; + var x1p = Math.cos( x_axis_rotation ) * dx2 + Math.sin( x_axis_rotation ) * dy2; + var y1p = - Math.sin( x_axis_rotation ) * dx2 + Math.cos( x_axis_rotation ) * dy2; + + // Compute (cx′, cy′) + var rxs = rx * rx; + var rys = ry * ry; + var x1ps = x1p * x1p; + var y1ps = y1p * y1p; + + // Ensure radii are large enough + var cr = x1ps / rxs + y1ps / rys; + + if ( cr > 1 ) { + + // scale up rx,ry equally so cr == 1 + var s = Math.sqrt( cr ); + rx = s * rx; + ry = s * ry; + rxs = rx * rx; + rys = ry * ry; + + } + + var dq = ( rxs * y1ps + rys * x1ps ); + var pq = ( rxs * rys - dq ) / dq; + var q = Math.sqrt( Math.max( 0, pq ) ); + if ( large_arc_flag === sweep_flag ) q = - q; + var cxp = q * rx * y1p / ry; + var cyp = - q * ry * x1p / rx; + + // Step 3: Compute (cx, cy) from (cx′, cy′) + var cx = Math.cos( x_axis_rotation ) * cxp - Math.sin( x_axis_rotation ) * cyp + ( start.x + end.x ) / 2; + var cy = Math.sin( x_axis_rotation ) * cxp + Math.cos( x_axis_rotation ) * cyp + ( start.y + end.y ) / 2; + + // Step 4: Compute θ1 and Δθ + var theta = svgAngle( 1, 0, ( x1p - cxp ) / rx, ( y1p - cyp ) / ry ); + var delta = svgAngle( ( x1p - cxp ) / rx, ( y1p - cyp ) / ry, ( - x1p - cxp ) / rx, ( - y1p - cyp ) / ry ) % ( Math.PI * 2 ); + + path.currentPath.absellipse( cx, cy, rx, ry, theta, theta + delta, sweep_flag === 0, x_axis_rotation ); + + } + + function svgAngle( ux, uy, vx, vy ) { + + var dot = ux * vx + uy * vy; + var len = Math.sqrt( ux * ux + uy * uy ) * Math.sqrt( vx * vx + vy * vy ); + var ang = Math.acos( Math.max( -1, Math.min( 1, dot / len ) ) ); // floating point precision, slightly over values appear + if ( ( ux * vy - uy * vx ) < 0 ) ang = - ang; + return ang; + + } + + /* + * According to https://www.w3.org/TR/SVG/shapes.html#RectElementRXAttribute + * rounded corner should be rendered to elliptical arc, but bezier curve does the job well enough + */ + function parseRectNode( node, style ) { + + var x = parseFloat( node.getAttribute( 'x' ) || 0 ); + var y = parseFloat( node.getAttribute( 'y' ) || 0 ); + var rx = parseFloat( node.getAttribute( 'rx' ) || 0 ); + var ry = parseFloat( node.getAttribute( 'ry' ) || 0 ); + var w = parseFloat( node.getAttribute( 'width' ) ); + var h = parseFloat( node.getAttribute( 'height' ) ); + + var path = new THREE.ShapePath(); + path.color.setStyle( style.fill ); + path.moveTo( x + 2 * rx, y ); + path.lineTo( x + w - 2 * rx, y ); + if ( rx !== 0 || ry !== 0 ) path.bezierCurveTo( x + w, y, x + w, y, x + w, y + 2 * ry ); + path.lineTo( x + w, y + h - 2 * ry ); + if ( rx !== 0 || ry !== 0 ) path.bezierCurveTo( x + w, y + h, x + w, y + h, x + w - 2 * rx, y + h ); + path.lineTo( x + 2 * rx, y + h ); + + if ( rx !== 0 || ry !== 0 ) { + + path.bezierCurveTo( x, y + h, x, y + h, x, y + h - 2 * ry ); + + } + + path.lineTo( x, y + 2 * ry ); + + if ( rx !== 0 || ry !== 0 ) { + + path.bezierCurveTo( x, y, x, y, x + 2 * rx, y ); + + } + + return path; + + } + + function parsePolygonNode( node, style ) { + + function iterator( match, a, b ) { + + var x = parseFloat( a ); + var y = parseFloat( b ); + + if ( index === 0 ) { + path.moveTo( x, y ); + } else { + path.lineTo( x, y ); + } + + index ++; + + } + + var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g; + + var path = new THREE.ShapePath(); + path.color.setStyle( style.fill ); + + var index = 0; + + node.getAttribute( 'points' ).replace(regex, iterator); + + path.currentPath.autoClose = true; + + return path; + + } + + function parsePolylineNode( node, style ) { + + function iterator( match, a, b ) { + + var x = parseFloat( a ); + var y = parseFloat( b ); + + if ( index === 0 ) { + path.moveTo( x, y ); + } else { + path.lineTo( x, y ); + } + + index ++; + + } + + var regex = /(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g; + + var path = new THREE.ShapePath(); + path.color.setStyle( style.fill ); + + var index = 0; + + node.getAttribute( 'points' ).replace(regex, iterator); + + path.currentPath.autoClose = false; + + return path; + + } + + function parseCircleNode( node, style ) { + + var x = parseFloat( node.getAttribute( 'cx' ) ); + var y = parseFloat( node.getAttribute( 'cy' ) ); + var r = parseFloat( node.getAttribute( 'r' ) ); + + var subpath = new THREE.Path(); + subpath.absarc( x, y, r, 0, Math.PI * 2 ); + + var path = new THREE.ShapePath(); + path.color.setStyle( style.fill ); + path.subPaths.push( subpath ); + + return path; + + } + + function parseEllipseNode( node, style ) { + + var x = parseFloat( node.getAttribute( 'cx' ) ); + var y = parseFloat( node.getAttribute( 'cy' ) ); + var rx = parseFloat( node.getAttribute( 'rx' ) ); + var ry = parseFloat( node.getAttribute( 'ry' ) ); + + var subpath = new THREE.Path(); + subpath.absellipse( x, y, rx, ry, 0, Math.PI * 2 ); + + var path = new THREE.ShapePath(); + path.color.setStyle( style.fill ); + path.subPaths.push( subpath ); + + return path; + + } + + function parseLineNode( node, style ) { + + var x1 = parseFloat( node.getAttribute( 'x1' ) ); + var y1 = parseFloat( node.getAttribute( 'y1' ) ); + var x2 = parseFloat( node.getAttribute( 'x2' ) ); + var y2 = parseFloat( node.getAttribute( 'y2' ) ); + + var path = new THREE.ShapePath(); + path.moveTo( x1, y1 ); + path.lineTo( x2, y2 ); + path.currentPath.autoClose = false; + + return path; + + } + + // + + function parseStyle( node, style ) { + + style = Object.assign( {}, style ); // clone style + + if ( node.hasAttribute( 'fill' ) ) style.fill = node.getAttribute( 'fill' ); + if ( node.style.fill !== '' ) style.fill = node.style.fill; + + return style; + + } + + function isVisible( style ) { + + return style.fill !== 'none' && style.fill !== 'transparent'; + + } + + // http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes + + function getReflection( a, b ) { + + return a - ( b - a ); + + } + + function parseFloats( string ) { + + var array = string.split( /[\s,]+|(?=\s?[+\-])/ ); + + for ( var i = 0; i < array.length; i ++ ) { + + var number = array[ i ]; + + // Handle values like 48.6037.7.8 + // TODO Find a regex for this + + if ( number.indexOf( '.' ) !== number.lastIndexOf( '.' ) ) { + + var split = number.split( '.' ); + + for ( var s = 2; s < split.length; s ++ ) { + + array.splice( i + s - 1, 0, '0.' + split[ s ] ); + + } + + } + + array[ i ] = parseFloat( number ); + + } + + return array; + + + } + + function getNodeTransform( node ) { + + if ( ! node.hasAttribute( 'transform' ) ) { + return null; + } + + var transform = parseTransformNode( node ); + + if ( transform ) { + + if ( transformStack.length > 0 ) { + transform.premultiply( transformStack[ transformStack.length - 1 ] ); + } + + currentTransform.copy( transform ); + transformStack.push( transform ); + + } + + return transform; + + } + + function parseTransformNode( node ) { + + var transformAttr = node.getAttribute( 'transform' ); + var transform = null; + var openParPos = transformAttr.indexOf( "(" ); + var closeParPos = transformAttr.indexOf( ")" ); + + if ( openParPos > 0 && openParPos < closeParPos ) { + + var transformType = transformAttr.substr( 0, openParPos ); + + var array = parseFloats( transformAttr.substr( openParPos + 1, closeParPos - openParPos - 1 ) ); + + switch ( transformType ) { + + case "translate": + + if ( array.length >= 1 ) { + + transform = new THREE.Matrix3(); + + var tx = array[ 0 ]; + var ty = tx; + + if ( array.length >= 2 ) { + + ty = array[ 1 ]; + + } + + transform.translate( tx, ty ); + + } + + break; + + case "rotate": + + if ( array.length >= 1 ) { + + var angle = 0; + var cx = 0; + var cy = 0; + + transform = new THREE.Matrix3(); + + // Angle + angle = - array[ 0 ] * Math.PI / 180; + + if ( array.length >= 3 ) { + + // Center x, y + cx = array[ 1 ]; + cy = array[ 2 ]; + + } + + // Rotate around center (cx, cy) + tempTransform1.identity().translate( -cx, -cy ); + tempTransform2.identity().rotate( angle ); + tempTransform3.multiplyMatrices( tempTransform2, tempTransform1 ); + tempTransform1.identity().translate( cx, cy ); + transform.multiplyMatrices( tempTransform1, tempTransform3 ); + + } + + break; + + case "scale": + + if ( array.length >= 1 ) { + + transform = new THREE.Matrix3(); + + var scaleX = array[ 0 ]; + var scaleY = scaleX; + + if ( array.length >= 2 ) { + scaleY = array[ 1 ]; + } + + transform.scale( scaleX, scaleY ); + + } + + break; + + case "skewX": + + if ( array.length === 1 ) { + + transform = new THREE.Matrix3(); + + transform.set( + 1, Math.tan( array[ 0 ] * Math.PI / 180 ), 0, + 0, 1, 0, + 0, 0, 1 + ); + + } + + break; + + case "skewY": + + if ( array.length === 1 ) { + + transform = new THREE.Matrix3(); + + transform.set( + 1, 0, 0, + Math.tan( array[ 0 ] * Math.PI / 180 ), 1, 0, + 0, 0, 1 + ); + + } + + break; + + case "matrix": + + if ( array.length === 6 ) { + + transform = new THREE.Matrix3(); + + transform.set( + array[ 0 ], array[ 2 ], array[ 4 ], + array[ 1 ], array[ 3 ], array[ 5 ], + 0, 0, 1 + ); + + } + + break; + } + + } + + return transform; + + } + + function transformPath( path, m ) { + + function transfVec2( v2 ) { + + tempV3.set( v2.x, v2.y, 1 ).applyMatrix3( m ); + + v2.set( tempV3.x, tempV3.y ); + + } + + var isRotated = isTransformRotated( m ); + + var tempV2 = new THREE.Vector2(); + var tempV3 = new THREE.Vector3(); + + var subPaths = path.subPaths; + + for ( var i = 0, n = subPaths.length; i < n; i++ ) { + + var subPath = subPaths[ i ]; + var curves = subPath.curves; + + for ( var j = 0; j < curves.length; j++ ) { + + var curve = curves[ j ]; + + if ( curve.isLineCurve ) { + + transfVec2( curve.v1 ); + transfVec2( curve.v2 ); + + } else if ( curve.isCubicBezierCurve ) { + + transfVec2( curve.v0 ); + transfVec2( curve.v1 ); + transfVec2( curve.v2 ); + transfVec2( curve.v3 ); + + } else if ( curve.isQuadraticBezierCurve ) { + + transfVec2( curve.v0 ); + transfVec2( curve.v1 ); + transfVec2( curve.v2 ); + + } else if ( curve.isEllipseCurve ) { + + if ( isRotated ) { + console.warn( "SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented." ); + } + + tempV2.set( curve.aX, curve.aY ); + transfVec2( tempV2 ); + curve.aX = tempV2.x; + curve.aY = tempV2.y; + + curve.xRadius *= getTransformScaleX( m ); + curve.yRadius *= getTransformScaleY( m ); + + } + + } + + } + + } + + function isTransformRotated( m ) { + return m.elements[ 1 ] !== 0 || m.elements[ 3 ] !== 0; + } + + function getTransformScaleX( m ) { + var te = m.elements; + return Math.sqrt( te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] ) + } + + function getTransformScaleY( m ) { + var te = m.elements; + return Math.sqrt( te[ 3 ] * te[ 3 ] + te[ 4 ] * te[ 4 ] ) + } + + // + + console.log( 'THREE.SVGLoader' ); + + var paths = []; + + var transformStack = []; + + var tempTransform1 = new THREE.Matrix3(); + var tempTransform2 = new THREE.Matrix3(); + var tempTransform3 = new THREE.Matrix3(); + + var currentTransform = new THREE.Matrix3(); + + console.time( 'THREE.SVGLoader: DOMParser' ); + + var xml = new DOMParser().parseFromString( text, 'image/svg+xml' ); // application/xml + + console.timeEnd( 'THREE.SVGLoader: DOMParser' ); + + console.time( 'THREE.SVGLoader: Parse' ); + + parseNode( xml.documentElement, { fill: '#000' } ); + + // console.log( paths ); + + + console.timeEnd( 'THREE.SVGLoader: Parse' ); + + return paths; + + } + +}; diff --git a/three/jsutil/loaders/TDSLoader.js b/three/jsutil/loaders/TDSLoader.js new file mode 100644 index 000000000..3ea517af1 --- /dev/null +++ b/three/jsutil/loaders/TDSLoader.js @@ -0,0 +1,1127 @@ +/* + * Autodesk 3DS three.js file loader, based on lib3ds. + * + * Loads geometry with uv and materials basic properties with texture support. + * + * @author @tentone + * @author @timknip + * @class TDSLoader + * @constructor + */ + +'use strict'; + +THREE.TDSLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.debug = false; + + this.group = null; + this.position = 0; + + this.materials = []; + this.meshes = []; + +}; + +THREE.TDSLoader.prototype = { + + constructor: THREE.TDSLoader, + + crossOrigin: 'anonymous', + + /** + * Load 3ds file from url. + * + * @method load + * @param {[type]} url URL for the file. + * @param {Function} onLoad onLoad callback, receives group Object3D as argument. + * @param {Function} onProgress onProgress callback. + * @param {Function} onError onError callback. + */ + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var path = this.path !== undefined ? this.path : THREE.LoaderUtils.extractUrlBase( url ); + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + + loader.load( url, function ( data ) { + + onLoad( scope.parse( data, path ) ); + + }, onProgress, onError ); + + }, + + /** + * Parse arraybuffer data and load 3ds file. + * + * @method parse + * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded. + * @param {String} path Path for external resources. + * @return {Object3D} Group loaded from 3ds file. + */ + parse: function ( arraybuffer, path ) { + + this.group = new THREE.Group(); + this.position = 0; + this.materials = []; + this.meshes = []; + + this.readFile( arraybuffer, path ); + + for ( var i = 0; i < this.meshes.length; i ++ ) { + + this.group.add( this.meshes[ i ] ); + + } + + return this.group; + + }, + + /** + * Decode file content to read 3ds data. + * + * @method readFile + * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded. + */ + readFile: function ( arraybuffer, path ) { + + var data = new DataView( arraybuffer ); + var chunk = this.readChunk( data ); + + if ( chunk.id === MLIBMAGIC || chunk.id === CMAGIC || chunk.id === M3DMAGIC ) { + + var next = this.nextChunk( data, chunk ); + + while ( next !== 0 ) { + + if ( next === M3D_VERSION ) { + + var version = this.readDWord( data ); + this.debugMessage( '3DS file version: ' + version ); + + } else if ( next === MDATA ) { + + this.resetPosition( data ); + this.readMeshData( data, path ); + + } else { + + this.debugMessage( 'Unknown main chunk: ' + next.toString( 16 ) ); + + } + + next = this.nextChunk( data, chunk ); + + } + + } + + this.debugMessage( 'Parsed ' + this.meshes.length + ' meshes' ); + + }, + + /** + * Read mesh data chunk. + * + * @method readMeshData + * @param {Dataview} data Dataview in use. + */ + readMeshData: function ( data, path ) { + + var chunk = this.readChunk( data ); + var next = this.nextChunk( data, chunk ); + + while ( next !== 0 ) { + + if ( next === MESH_VERSION ) { + + var version = + this.readDWord( data ); + this.debugMessage( 'Mesh Version: ' + version ); + + } else if ( next === MASTER_SCALE ) { + + var scale = this.readFloat( data ); + this.debugMessage( 'Master scale: ' + scale ); + this.group.scale.set( scale, scale, scale ); + + } else if ( next === NAMED_OBJECT ) { + + this.debugMessage( 'Named Object' ); + this.resetPosition( data ); + this.readNamedObject( data ); + + } else if ( next === MAT_ENTRY ) { + + this.debugMessage( 'Material' ); + this.resetPosition( data ); + this.readMaterialEntry( data, path ); + + } else { + + this.debugMessage( 'Unknown MDATA chunk: ' + next.toString( 16 ) ); + + } + + next = this.nextChunk( data, chunk ); + + } + + }, + + /** + * Read named object chunk. + * + * @method readNamedObject + * @param {Dataview} data Dataview in use. + */ + readNamedObject: function ( data ) { + + var chunk = this.readChunk( data ); + var name = this.readString( data, 64 ); + chunk.cur = this.position; + + var next = this.nextChunk( data, chunk ); + while ( next !== 0 ) { + + if ( next === N_TRI_OBJECT ) { + + this.resetPosition( data ); + var mesh = this.readMesh( data ); + mesh.name = name; + this.meshes.push( mesh ); + + } else { + + this.debugMessage( 'Unknown named object chunk: ' + next.toString( 16 ) ); + + } + + next = this.nextChunk( data, chunk ); + + } + + this.endChunk( chunk ); + + }, + + /** + * Read material data chunk and add it to the material list. + * + * @method readMaterialEntry + * @param {Dataview} data Dataview in use. + */ + readMaterialEntry: function ( data, path ) { + + var chunk = this.readChunk( data ); + var next = this.nextChunk( data, chunk ); + var material = new THREE.MeshPhongMaterial(); + + while ( next !== 0 ) { + + if ( next === MAT_NAME ) { + + material.name = this.readString( data, 64 ); + this.debugMessage( ' Name: ' + material.name ); + + } else if ( next === MAT_WIRE ) { + + this.debugMessage( ' Wireframe' ); + material.wireframe = true; + + } else if ( next === MAT_WIRE_SIZE ) { + + var value = this.readByte( data ); + material.wireframeLinewidth = value; + this.debugMessage( ' Wireframe Thickness: ' + value ); + + } else if ( next === MAT_TWO_SIDE ) { + + material.side = THREE.DoubleSide; + this.debugMessage( ' DoubleSided' ); + + } else if ( next === MAT_ADDITIVE ) { + + this.debugMessage( ' Additive Blending' ); + material.blending = THREE.AdditiveBlending; + + } else if ( next === MAT_DIFFUSE ) { + + this.debugMessage( ' Diffuse Color' ); + material.color = this.readColor( data ); + + } else if ( next === MAT_SPECULAR ) { + + this.debugMessage( ' Specular Color' ); + material.specular = this.readColor( data ); + + } else if ( next === MAT_AMBIENT ) { + + this.debugMessage( ' Ambient color' ); + material.color = this.readColor( data ); + + } else if ( next === MAT_SHININESS ) { + + var shininess = this.readWord( data ); + material.shininess = shininess; + this.debugMessage( ' Shininess : ' + shininess ); + + } else if ( next === MAT_TEXMAP ) { + + this.debugMessage( ' ColorMap' ); + this.resetPosition( data ); + material.map = this.readMap( data, path ); + + } else if ( next === MAT_BUMPMAP ) { + + this.debugMessage( ' BumpMap' ); + this.resetPosition( data ); + material.bumpMap = this.readMap( data, path ); + + } else if ( next === MAT_OPACMAP ) { + + this.debugMessage( ' OpacityMap' ); + this.resetPosition( data ); + material.alphaMap = this.readMap( data, path ); + + } else if ( next === MAT_SPECMAP ) { + + this.debugMessage( ' SpecularMap' ); + this.resetPosition( data ); + material.specularMap = this.readMap( data, path ); + + } else { + + this.debugMessage( ' Unknown material chunk: ' + next.toString( 16 ) ); + + } + + next = this.nextChunk( data, chunk ); + + } + + this.endChunk( chunk ); + + this.materials[ material.name ] = material; + + }, + + /** + * Read mesh data chunk. + * + * @method readMesh + * @param {Dataview} data Dataview in use. + */ + readMesh: function ( data ) { + + var chunk = this.readChunk( data ); + var next = this.nextChunk( data, chunk ); + + var geometry = new THREE.BufferGeometry(); + var uvs = []; + + var material = new THREE.MeshPhongMaterial(); + var mesh = new THREE.Mesh( geometry, material ); + mesh.name = 'mesh'; + + while ( next !== 0 ) { + + if ( next === POINT_ARRAY ) { + + var points = this.readWord( data ); + + this.debugMessage( ' Vertex: ' + points ); + + //BufferGeometry + + var vertices = []; + + for ( var i = 0; i < points; i ++ ) { + + vertices.push( this.readFloat( data ) ); + vertices.push( this.readFloat( data ) ); + vertices.push( this.readFloat( data ) ); + + } + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + + } else if ( next === FACE_ARRAY ) { + + this.resetPosition( data ); + this.readFaceArray( data, mesh ); + + } else if ( next === TEX_VERTS ) { + + var texels = this.readWord( data ); + + this.debugMessage( ' UV: ' + texels ); + + //BufferGeometry + + var uvs = []; + + for ( var i = 0; i < texels; i ++ ) { + + uvs.push( this.readFloat( data ) ); + uvs.push( this.readFloat( data ) ); + + } + + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + + + } else if ( next === MESH_MATRIX ) { + + this.debugMessage( ' Tranformation Matrix (TODO)' ); + + var values = []; + for ( var i = 0; i < 12; i ++ ) { + + values[ i ] = this.readFloat( data ); + + } + + var matrix = new THREE.Matrix4(); + + //X Line + matrix.elements[ 0 ] = values[ 0 ]; + matrix.elements[ 1 ] = values[ 6 ]; + matrix.elements[ 2 ] = values[ 3 ]; + matrix.elements[ 3 ] = values[ 9 ]; + + //Y Line + matrix.elements[ 4 ] = values[ 2 ]; + matrix.elements[ 5 ] = values[ 8 ]; + matrix.elements[ 6 ] = values[ 5 ]; + matrix.elements[ 7 ] = values[ 11 ]; + + //Z Line + matrix.elements[ 8 ] = values[ 1 ]; + matrix.elements[ 9 ] = values[ 7 ]; + matrix.elements[ 10 ] = values[ 4 ]; + matrix.elements[ 11 ] = values[ 10 ]; + + //W Line + matrix.elements[ 12 ] = 0; + matrix.elements[ 13 ] = 0; + matrix.elements[ 14 ] = 0; + matrix.elements[ 15 ] = 1; + + matrix.transpose(); + + var inverse = new THREE.Matrix4(); + inverse.getInverse( matrix, true ); + geometry.applyMatrix( inverse ); + + matrix.decompose( mesh.position, mesh.quaternion, mesh.scale ); + + } else { + + this.debugMessage( ' Unknown mesh chunk: ' + next.toString( 16 ) ); + + } + + next = this.nextChunk( data, chunk ); + + } + + this.endChunk( chunk ); + + geometry.computeVertexNormals(); + + return mesh; + + }, + + /** + * Read face array data chunk. + * + * @method readFaceArray + * @param {Dataview} data Dataview in use. + * @param {Mesh} mesh Mesh to be filled with the data read. + */ + readFaceArray: function ( data, mesh ) { + + var chunk = this.readChunk( data ); + var faces = this.readWord( data ); + + this.debugMessage( ' Faces: ' + faces ); + + var index = []; + + for ( var i = 0; i < faces; ++ i ) { + + index.push( this.readWord( data ), this.readWord( data ), this.readWord( data ) ); + + var visibility = this.readWord( data ); + + } + + mesh.geometry.setIndex( index ); + + //The rest of the FACE_ARRAY chunk is subchunks + + while ( this.position < chunk.end ) { + + var chunk = this.readChunk( data ); + + if ( chunk.id === MSH_MAT_GROUP ) { + + this.debugMessage( ' Material Group' ); + + this.resetPosition( data ); + + var group = this.readMaterialGroup( data ); + + var material = this.materials[ group.name ]; + + if ( material !== undefined ) { + + mesh.material = material; + + if ( material.name === '' ) { + + material.name = mesh.name; + + } + + } + + } else { + + this.debugMessage( ' Unknown face array chunk: ' + chunk.toString( 16 ) ); + + } + + this.endChunk( chunk ); + + } + + this.endChunk( chunk ); + + }, + + /** + * Read texture map data chunk. + * + * @method readMap + * @param {Dataview} data Dataview in use. + * @return {Texture} Texture read from this data chunk. + */ + readMap: function ( data, path ) { + + var chunk = this.readChunk( data ); + var next = this.nextChunk( data, chunk ); + var texture = {}; + + var loader = new THREE.TextureLoader( this.manager ); + loader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); + + while ( next !== 0 ) { + + if ( next === MAT_MAPNAME ) { + + var name = this.readString( data, 128 ); + texture = loader.load( name ); + + this.debugMessage( ' File: ' + path + name ); + + } else if ( next === MAT_MAP_UOFFSET ) { + + texture.offset.x = this.readFloat( data ); + this.debugMessage( ' OffsetX: ' + texture.offset.x ); + + } else if ( next === MAT_MAP_VOFFSET ) { + + texture.offset.y = this.readFloat( data ); + this.debugMessage( ' OffsetY: ' + texture.offset.y ); + + } else if ( next === MAT_MAP_USCALE ) { + + texture.repeat.x = this.readFloat( data ); + this.debugMessage( ' RepeatX: ' + texture.repeat.x ); + + } else if ( next === MAT_MAP_VSCALE ) { + + texture.repeat.y = this.readFloat( data ); + this.debugMessage( ' RepeatY: ' + texture.repeat.y ); + + } else { + + this.debugMessage( ' Unknown map chunk: ' + next.toString( 16 ) ); + + } + + next = this.nextChunk( data, chunk ); + + } + + this.endChunk( chunk ); + + return texture; + + }, + + /** + * Read material group data chunk. + * + * @method readMaterialGroup + * @param {Dataview} data Dataview in use. + * @return {Object} Object with name and index of the object. + */ + readMaterialGroup: function ( data ) { + + var chunk = this.readChunk( data ); + var name = this.readString( data, 64 ); + var numFaces = this.readWord( data ); + + this.debugMessage( ' Name: ' + name ); + this.debugMessage( ' Faces: ' + numFaces ); + + var index = []; + for ( var i = 0; i < numFaces; ++ i ) { + + index.push( this.readWord( data ) ); + + } + + return { name: name, index: index }; + + }, + + /** + * Read a color value. + * + * @method readColor + * @param {DataView} data Dataview. + * @return {Color} Color value read.. + */ + readColor: function ( data ) { + + var chunk = this.readChunk( data ); + var color = new THREE.Color(); + + if ( chunk.id === COLOR_24 || chunk.id === LIN_COLOR_24 ) { + + var r = this.readByte( data ); + var g = this.readByte( data ); + var b = this.readByte( data ); + + color.setRGB( r / 255, g / 255, b / 255 ); + + this.debugMessage( ' Color: ' + color.r + ', ' + color.g + ', ' + color.b ); + + } else if ( chunk.id === COLOR_F || chunk.id === LIN_COLOR_F ) { + + var r = this.readFloat( data ); + var g = this.readFloat( data ); + var b = this.readFloat( data ); + + color.setRGB( r, g, b ); + + this.debugMessage( ' Color: ' + color.r + ', ' + color.g + ', ' + color.b ); + + } else { + + this.debugMessage( ' Unknown color chunk: ' + chunk.toString( 16 ) ); + + } + + this.endChunk( chunk ); + return color; + + }, + + /** + * Read next chunk of data. + * + * @method readChunk + * @param {DataView} data Dataview. + * @return {Object} Chunk of data read. + */ + readChunk: function ( data ) { + + var chunk = {}; + + chunk.cur = this.position; + chunk.id = this.readWord( data ); + chunk.size = this.readDWord( data ); + chunk.end = chunk.cur + chunk.size; + chunk.cur += 6; + + return chunk; + + }, + + /** + * Set position to the end of the current chunk of data. + * + * @method endChunk + * @param {Object} chunk Data chunk. + */ + endChunk: function ( chunk ) { + + this.position = chunk.end; + + }, + + /** + * Move to the next data chunk. + * + * @method nextChunk + * @param {DataView} data Dataview. + * @param {Object} chunk Data chunk. + */ + nextChunk: function ( data, chunk ) { + + if ( chunk.cur >= chunk.end ) { + + return 0; + + } + + this.position = chunk.cur; + + try { + + var next = this.readChunk( data ); + chunk.cur += next.size; + return next.id; + + } catch ( e ) { + + this.debugMessage( 'Unable to read chunk at ' + this.position ); + return 0; + + } + + }, + + /** + * Reset dataview position. + * + * @method resetPosition + * @param {DataView} data Dataview. + */ + resetPosition: function () { + + this.position -= 6; + + }, + + /** + * Read byte value. + * + * @method readByte + * @param {DataView} data Dataview to read data from. + * @return {Number} Data read from the dataview. + */ + readByte: function ( data ) { + + var v = data.getUint8( this.position, true ); + this.position += 1; + return v; + + }, + + /** + * Read 32 bit float value. + * + * @method readFloat + * @param {DataView} data Dataview to read data from. + * @return {Number} Data read from the dataview. + */ + readFloat: function ( data ) { + + try { + + var v = data.getFloat32( this.position, true ); + this.position += 4; + return v; + + } catch ( e ) { + + this.debugMessage( e + ' ' + this.position + ' ' + data.byteLength ); + + } + + }, + + /** + * Read 32 bit signed integer value. + * + * @method readInt + * @param {DataView} data Dataview to read data from. + * @return {Number} Data read from the dataview. + */ + readInt: function ( data ) { + + var v = data.getInt32( this.position, true ); + this.position += 4; + return v; + + }, + + /** + * Read 16 bit signed integer value. + * + * @method readShort + * @param {DataView} data Dataview to read data from. + * @return {Number} Data read from the dataview. + */ + readShort: function ( data ) { + + var v = data.getInt16( this.position, true ); + this.position += 2; + return v; + + }, + + /** + * Read 64 bit unsigned integer value. + * + * @method readDWord + * @param {DataView} data Dataview to read data from. + * @return {Number} Data read from the dataview. + */ + readDWord: function ( data ) { + + var v = data.getUint32( this.position, true ); + this.position += 4; + return v; + + }, + + /** + * Read 32 bit unsigned integer value. + * + * @method readWord + * @param {DataView} data Dataview to read data from. + * @return {Number} Data read from the dataview. + */ + readWord: function ( data ) { + + var v = data.getUint16( this.position, true ); + this.position += 2; + return v; + + }, + + /** + * Read string value. + * + * @method readString + * @param {DataView} data Dataview to read data from. + * @param {Number} maxLength Max size of the string to be read. + * @return {String} Data read from the dataview. + */ + readString: function ( data, maxLength ) { + + var s = ''; + + for ( var i = 0; i < maxLength; i ++ ) { + + var c = this.readByte( data ); + if ( ! c ) { + + break; + + } + + s += String.fromCharCode( c ); + + } + + return s; + + }, + + /** + * Set path to adjust the path to the original 3ds file. + * + * @method setPath + * @param {String} path Path to file. + * @return Self for chaining. + */ + setPath: function ( path ) { + + this.path = path; + + return this; + + }, + + /** + * Set resource path used to determine the path to attached resources like textures. + * + * @method setResourcePath + * @param {String} resourcePath Path to resources. + * @return Self for chaining. + */ + setResourcePath: function ( resourcePath ) { + + this.resourcePath = resourcePath; + + return this; + + }, + + /** + * Set crossOrigin value to configure CORS settings + * for the image loading process. + * + * @method setCrossOrigin + * @param {String} crossOrigin crossOrigin string. + * @return Self for chaining. + */ + setCrossOrigin: function ( crossOrigin ) { + + this.crossOrigin = crossOrigin; + + return this; + + }, + + /** + * Print debug message to the console. + * + * Is controlled by a flag to show or hide debug messages. + * + * @method debugMessage + * @param {Object} message Debug message to print to the console. + */ + debugMessage: function ( message ) { + + if ( this.debug ) { + + console.log( message ); + + } + + } +}; + +var NULL_CHUNK = 0x0000; +var M3DMAGIC = 0x4D4D; +var SMAGIC = 0x2D2D; +var LMAGIC = 0x2D3D; +var MLIBMAGIC = 0x3DAA; +var MATMAGIC = 0x3DFF; +var CMAGIC = 0xC23D; +var M3D_VERSION = 0x0002; +var M3D_KFVERSION = 0x0005; +var COLOR_F = 0x0010; +var COLOR_24 = 0x0011; +var LIN_COLOR_24 = 0x0012; +var LIN_COLOR_F = 0x0013; +var INT_PERCENTAGE = 0x0030; +var FLOAT_PERCENTAGE = 0x0031; +var MDATA = 0x3D3D; +var MESH_VERSION = 0x3D3E; +var MASTER_SCALE = 0x0100; +var LO_SHADOW_BIAS = 0x1400; +var HI_SHADOW_BIAS = 0x1410; +var SHADOW_MAP_SIZE = 0x1420; +var SHADOW_SAMPLES = 0x1430; +var SHADOW_RANGE = 0x1440; +var SHADOW_FILTER = 0x1450; +var RAY_BIAS = 0x1460; +var O_CONSTS = 0x1500; +var AMBIENT_LIGHT = 0x2100; +var BIT_MAP = 0x1100; +var SOLID_BGND = 0x1200; +var V_GRADIENT = 0x1300; +var USE_BIT_MAP = 0x1101; +var USE_SOLID_BGND = 0x1201; +var USE_V_GRADIENT = 0x1301; +var FOG = 0x2200; +var FOG_BGND = 0x2210; +var LAYER_FOG = 0x2302; +var DISTANCE_CUE = 0x2300; +var DCUE_BGND = 0x2310; +var USE_FOG = 0x2201; +var USE_LAYER_FOG = 0x2303; +var USE_DISTANCE_CUE = 0x2301; +var MAT_ENTRY = 0xAFFF; +var MAT_NAME = 0xA000; +var MAT_AMBIENT = 0xA010; +var MAT_DIFFUSE = 0xA020; +var MAT_SPECULAR = 0xA030; +var MAT_SHININESS = 0xA040; +var MAT_SHIN2PCT = 0xA041; +var MAT_TRANSPARENCY = 0xA050; +var MAT_XPFALL = 0xA052; +var MAT_USE_XPFALL = 0xA240; +var MAT_REFBLUR = 0xA053; +var MAT_SHADING = 0xA100; +var MAT_USE_REFBLUR = 0xA250; +var MAT_SELF_ILLUM = 0xA084; +var MAT_TWO_SIDE = 0xA081; +var MAT_DECAL = 0xA082; +var MAT_ADDITIVE = 0xA083; +var MAT_WIRE = 0xA085; +var MAT_FACEMAP = 0xA088; +var MAT_TRANSFALLOFF_IN = 0xA08A; +var MAT_PHONGSOFT = 0xA08C; +var MAT_WIREABS = 0xA08E; +var MAT_WIRE_SIZE = 0xA087; +var MAT_TEXMAP = 0xA200; +var MAT_SXP_TEXT_DATA = 0xA320; +var MAT_TEXMASK = 0xA33E; +var MAT_SXP_TEXTMASK_DATA = 0xA32A; +var MAT_TEX2MAP = 0xA33A; +var MAT_SXP_TEXT2_DATA = 0xA321; +var MAT_TEX2MASK = 0xA340; +var MAT_SXP_TEXT2MASK_DATA = 0xA32C; +var MAT_OPACMAP = 0xA210; +var MAT_SXP_OPAC_DATA = 0xA322; +var MAT_OPACMASK = 0xA342; +var MAT_SXP_OPACMASK_DATA = 0xA32E; +var MAT_BUMPMAP = 0xA230; +var MAT_SXP_BUMP_DATA = 0xA324; +var MAT_BUMPMASK = 0xA344; +var MAT_SXP_BUMPMASK_DATA = 0xA330; +var MAT_SPECMAP = 0xA204; +var MAT_SXP_SPEC_DATA = 0xA325; +var MAT_SPECMASK = 0xA348; +var MAT_SXP_SPECMASK_DATA = 0xA332; +var MAT_SHINMAP = 0xA33C; +var MAT_SXP_SHIN_DATA = 0xA326; +var MAT_SHINMASK = 0xA346; +var MAT_SXP_SHINMASK_DATA = 0xA334; +var MAT_SELFIMAP = 0xA33D; +var MAT_SXP_SELFI_DATA = 0xA328; +var MAT_SELFIMASK = 0xA34A; +var MAT_SXP_SELFIMASK_DATA = 0xA336; +var MAT_REFLMAP = 0xA220; +var MAT_REFLMASK = 0xA34C; +var MAT_SXP_REFLMASK_DATA = 0xA338; +var MAT_ACUBIC = 0xA310; +var MAT_MAPNAME = 0xA300; +var MAT_MAP_TILING = 0xA351; +var MAT_MAP_TEXBLUR = 0xA353; +var MAT_MAP_USCALE = 0xA354; +var MAT_MAP_VSCALE = 0xA356; +var MAT_MAP_UOFFSET = 0xA358; +var MAT_MAP_VOFFSET = 0xA35A; +var MAT_MAP_ANG = 0xA35C; +var MAT_MAP_COL1 = 0xA360; +var MAT_MAP_COL2 = 0xA362; +var MAT_MAP_RCOL = 0xA364; +var MAT_MAP_GCOL = 0xA366; +var MAT_MAP_BCOL = 0xA368; +var NAMED_OBJECT = 0x4000; +var N_DIRECT_LIGHT = 0x4600; +var DL_OFF = 0x4620; +var DL_OUTER_RANGE = 0x465A; +var DL_INNER_RANGE = 0x4659; +var DL_MULTIPLIER = 0x465B; +var DL_EXCLUDE = 0x4654; +var DL_ATTENUATE = 0x4625; +var DL_SPOTLIGHT = 0x4610; +var DL_SPOT_ROLL = 0x4656; +var DL_SHADOWED = 0x4630; +var DL_LOCAL_SHADOW2 = 0x4641; +var DL_SEE_CONE = 0x4650; +var DL_SPOT_RECTANGULAR = 0x4651; +var DL_SPOT_ASPECT = 0x4657; +var DL_SPOT_PROJECTOR = 0x4653; +var DL_SPOT_OVERSHOOT = 0x4652; +var DL_RAY_BIAS = 0x4658; +var DL_RAYSHAD = 0x4627; +var N_CAMERA = 0x4700; +var CAM_SEE_CONE = 0x4710; +var CAM_RANGES = 0x4720; +var OBJ_HIDDEN = 0x4010; +var OBJ_VIS_LOFTER = 0x4011; +var OBJ_DOESNT_CAST = 0x4012; +var OBJ_DONT_RECVSHADOW = 0x4017; +var OBJ_MATTE = 0x4013; +var OBJ_FAST = 0x4014; +var OBJ_PROCEDURAL = 0x4015; +var OBJ_FROZEN = 0x4016; +var N_TRI_OBJECT = 0x4100; +var POINT_ARRAY = 0x4110; +var POINT_FLAG_ARRAY = 0x4111; +var FACE_ARRAY = 0x4120; +var MSH_MAT_GROUP = 0x4130; +var SMOOTH_GROUP = 0x4150; +var MSH_BOXMAP = 0x4190; +var TEX_VERTS = 0x4140; +var MESH_MATRIX = 0x4160; +var MESH_COLOR = 0x4165; +var MESH_TEXTURE_INFO = 0x4170; +var KFDATA = 0xB000; +var KFHDR = 0xB00A; +var KFSEG = 0xB008; +var KFCURTIME = 0xB009; +var AMBIENT_NODE_TAG = 0xB001; +var OBJECT_NODE_TAG = 0xB002; +var CAMERA_NODE_TAG = 0xB003; +var TARGET_NODE_TAG = 0xB004; +var LIGHT_NODE_TAG = 0xB005; +var L_TARGET_NODE_TAG = 0xB006; +var SPOTLIGHT_NODE_TAG = 0xB007; +var NODE_ID = 0xB030; +var NODE_HDR = 0xB010; +var PIVOT = 0xB013; +var INSTANCE_NAME = 0xB011; +var MORPH_SMOOTH = 0xB015; +var BOUNDBOX = 0xB014; +var POS_TRACK_TAG = 0xB020; +var COL_TRACK_TAG = 0xB025; +var ROT_TRACK_TAG = 0xB021; +var SCL_TRACK_TAG = 0xB022; +var MORPH_TRACK_TAG = 0xB026; +var FOV_TRACK_TAG = 0xB023; +var ROLL_TRACK_TAG = 0xB024; +var HOT_TRACK_TAG = 0xB027; +var FALL_TRACK_TAG = 0xB028; +var HIDE_TRACK_TAG = 0xB029; +var POLY_2D = 0x5000; +var SHAPE_OK = 0x5010; +var SHAPE_NOT_OK = 0x5011; +var SHAPE_HOOK = 0x5020; +var PATH_3D = 0x6000; +var PATH_MATRIX = 0x6005; +var SHAPE_2D = 0x6010; +var M_SCALE = 0x6020; +var M_TWIST = 0x6030; +var M_TEETER = 0x6040; +var M_FIT = 0x6050; +var M_BEVEL = 0x6060; +var XZ_CURVE = 0x6070; +var YZ_CURVE = 0x6080; +var INTERPCT = 0x6090; +var DEFORM_LIMIT = 0x60A0; +var USE_CONTOUR = 0x6100; +var USE_TWEEN = 0x6110; +var USE_SCALE = 0x6120; +var USE_TWIST = 0x6130; +var USE_TEETER = 0x6140; +var USE_FIT = 0x6150; +var USE_BEVEL = 0x6160; +var DEFAULT_VIEW = 0x3000; +var VIEW_TOP = 0x3010; +var VIEW_BOTTOM = 0x3020; +var VIEW_LEFT = 0x3030; +var VIEW_RIGHT = 0x3040; +var VIEW_FRONT = 0x3050; +var VIEW_BACK = 0x3060; +var VIEW_USER = 0x3070; +var VIEW_CAMERA = 0x3080; +var VIEW_WINDOW = 0x3090; +var VIEWPORT_LAYOUT_OLD = 0x7000; +var VIEWPORT_DATA_OLD = 0x7010; +var VIEWPORT_LAYOUT = 0x7001; +var VIEWPORT_DATA = 0x7011; +var VIEWPORT_DATA_3 = 0x7012; +var VIEWPORT_SIZE = 0x7020; +var NETWORK_VIEW = 0x7030; diff --git a/three/jsutil/loaders/TGALoader.js b/three/jsutil/loaders/TGALoader.js new file mode 100644 index 000000000..94937dd7f --- /dev/null +++ b/three/jsutil/loaders/TGALoader.js @@ -0,0 +1,548 @@ +/* + * @author Daosheng Mu / https://github.com/DaoshengMu/ + * @author mrdoob / http://mrdoob.com/ + * @author takahirox / https://github.com/takahirox/ + */ + +THREE.TGALoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.TGALoader.prototype = { + + constructor: THREE.TGALoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var texture = new THREE.Texture(); + + var loader = new THREE.FileLoader( this.manager ); + loader.setResponseType( 'arraybuffer' ); + loader.setPath( this.path ); + + loader.load( url, function ( buffer ) { + + texture.image = scope.parse( buffer ); + texture.needsUpdate = true; + + if ( onLoad !== undefined ) { + + onLoad( texture ); + + } + + }, onProgress, onError ); + + return texture; + + }, + + parse: function ( buffer ) { + + // reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js + + function tgaCheckHeader( header ) { + + switch ( header.image_type ) { + + // check indexed type + + case TGA_TYPE_INDEXED: + case TGA_TYPE_RLE_INDEXED: + if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1 ) { + + console.error( 'THREE.TGALoader: Invalid type colormap data for indexed type.' ); + + } + break; + + // check colormap type + + case TGA_TYPE_RGB: + case TGA_TYPE_GREY: + case TGA_TYPE_RLE_RGB: + case TGA_TYPE_RLE_GREY: + if ( header.colormap_type ) { + + console.error( 'THREE.TGALoader: Invalid type colormap data for colormap type.' ); + + } + break; + + // What the need of a file without data ? + + case TGA_TYPE_NO_DATA: + console.error( 'THREE.TGALoader: No data.' ); + + // Invalid type ? + + default: + console.error( 'THREE.TGALoader: Invalid type "%s".', header.image_type ); + + } + + // check image width and height + + if ( header.width <= 0 || header.height <= 0 ) { + + console.error( 'THREE.TGALoader: Invalid image size.' ); + + } + + // check image pixel size + + if ( header.pixel_size !== 8 && header.pixel_size !== 16 && + header.pixel_size !== 24 && header.pixel_size !== 32 ) { + + console.error( 'THREE.TGALoader: Invalid pixel size "%s".', header.pixel_size ); + + } + + } + + // parse tga image buffer + + function tgaParse( use_rle, use_pal, header, offset, data ) { + + var pixel_data, + pixel_size, + pixel_total, + palettes; + + pixel_size = header.pixel_size >> 3; + pixel_total = header.width * header.height * pixel_size; + + // read palettes + + if ( use_pal ) { + + palettes = data.subarray( offset, offset += header.colormap_length * ( header.colormap_size >> 3 ) ); + + } + + // read RLE + + if ( use_rle ) { + + pixel_data = new Uint8Array( pixel_total ); + + var c, count, i; + var shift = 0; + var pixels = new Uint8Array( pixel_size ); + + while ( shift < pixel_total ) { + + c = data[ offset ++ ]; + count = ( c & 0x7f ) + 1; + + // RLE pixels + + if ( c & 0x80 ) { + + // bind pixel tmp array + + for ( i = 0; i < pixel_size; ++ i ) { + + pixels[ i ] = data[ offset ++ ]; + + } + + // copy pixel array + + for ( i = 0; i < count; ++ i ) { + + pixel_data.set( pixels, shift + i * pixel_size ); + + } + + shift += pixel_size * count; + + } else { + + // raw pixels + + count *= pixel_size; + for ( i = 0; i < count; ++ i ) { + + pixel_data[ shift + i ] = data[ offset ++ ]; + + } + shift += count; + + } + + } + + } else { + + // raw pixels + + pixel_data = data.subarray( + offset, offset += ( use_pal ? header.width * header.height : pixel_total ) + ); + + } + + return { + pixel_data: pixel_data, + palettes: palettes + }; + + } + + function tgaGetImageData8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image, palettes ) { + + var colormap = palettes; + var color, i = 0, x, y; + var width = header.width; + + for ( y = y_start; y !== y_end; y += y_step ) { + + for ( x = x_start; x !== x_end; x += x_step, i ++ ) { + + color = image[ i ]; + imageData[ ( x + width * y ) * 4 + 3 ] = 255; + imageData[ ( x + width * y ) * 4 + 2 ] = colormap[ ( color * 3 ) + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = colormap[ ( color * 3 ) + 1 ]; + imageData[ ( x + width * y ) * 4 + 0 ] = colormap[ ( color * 3 ) + 2 ]; + + } + + } + + return imageData; + + } + + function tgaGetImageData16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { + + var color, i = 0, x, y; + var width = header.width; + + for ( y = y_start; y !== y_end; y += y_step ) { + + for ( x = x_start; x !== x_end; x += x_step, i += 2 ) { + + color = image[ i + 0 ] + ( image[ i + 1 ] << 8 ); // Inversed ? + imageData[ ( x + width * y ) * 4 + 0 ] = ( color & 0x7C00 ) >> 7; + imageData[ ( x + width * y ) * 4 + 1 ] = ( color & 0x03E0 ) >> 2; + imageData[ ( x + width * y ) * 4 + 2 ] = ( color & 0x001F ) >> 3; + imageData[ ( x + width * y ) * 4 + 3 ] = ( color & 0x8000 ) ? 0 : 255; + + } + + } + + return imageData; + + } + + function tgaGetImageData24bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { + + var i = 0, x, y; + var width = header.width; + + for ( y = y_start; y !== y_end; y += y_step ) { + + for ( x = x_start; x !== x_end; x += x_step, i += 3 ) { + + imageData[ ( x + width * y ) * 4 + 3 ] = 255; + imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ]; + imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ]; + + } + + } + + return imageData; + + } + + function tgaGetImageData32bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { + + var i = 0, x, y; + var width = header.width; + + for ( y = y_start; y !== y_end; y += y_step ) { + + for ( x = x_start; x !== x_end; x += x_step, i += 4 ) { + + imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ]; + imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ]; + imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 3 ]; + + } + + } + + return imageData; + + } + + function tgaGetImageDataGrey8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { + + var color, i = 0, x, y; + var width = header.width; + + for ( y = y_start; y !== y_end; y += y_step ) { + + for ( x = x_start; x !== x_end; x += x_step, i ++ ) { + + color = image[ i ]; + imageData[ ( x + width * y ) * 4 + 0 ] = color; + imageData[ ( x + width * y ) * 4 + 1 ] = color; + imageData[ ( x + width * y ) * 4 + 2 ] = color; + imageData[ ( x + width * y ) * 4 + 3 ] = 255; + + } + + } + + return imageData; + + } + + function tgaGetImageDataGrey16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) { + + var i = 0, x, y; + var width = header.width; + + for ( y = y_start; y !== y_end; y += y_step ) { + + for ( x = x_start; x !== x_end; x += x_step, i += 2 ) { + + imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ]; + imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 1 ]; + + } + + } + + return imageData; + + } + + function getTgaRGBA( data, width, height, image, palette ) { + + var x_start, + y_start, + x_step, + y_step, + x_end, + y_end; + + switch ( ( header.flags & TGA_ORIGIN_MASK ) >> TGA_ORIGIN_SHIFT ) { + + default: + case TGA_ORIGIN_UL: + x_start = 0; + x_step = 1; + x_end = width; + y_start = 0; + y_step = 1; + y_end = height; + break; + + case TGA_ORIGIN_BL: + x_start = 0; + x_step = 1; + x_end = width; + y_start = height - 1; + y_step = - 1; + y_end = - 1; + break; + + case TGA_ORIGIN_UR: + x_start = width - 1; + x_step = - 1; + x_end = - 1; + y_start = 0; + y_step = 1; + y_end = height; + break; + + case TGA_ORIGIN_BR: + x_start = width - 1; + x_step = - 1; + x_end = - 1; + y_start = height - 1; + y_step = - 1; + y_end = - 1; + break; + + } + + if ( use_grey ) { + + switch ( header.pixel_size ) { + + case 8: + tgaGetImageDataGrey8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); + break; + + case 16: + tgaGetImageDataGrey16bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); + break; + + default: + console.error( 'THREE.TGALoader: Format not supported.' ); + break; + + } + + } else { + + switch ( header.pixel_size ) { + + case 8: + tgaGetImageData8bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image, palette ); + break; + + case 16: + tgaGetImageData16bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); + break; + + case 24: + tgaGetImageData24bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); + break; + + case 32: + tgaGetImageData32bits( data, y_start, y_step, y_end, x_start, x_step, x_end, image ); + break; + + default: + console.error( 'THREE.TGALoader: Format not supported.' ); + break; + + } + + } + + // Load image data according to specific method + // var func = 'tgaGetImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits'; + // func(data, y_start, y_step, y_end, x_start, x_step, x_end, width, image, palette ); + return data; + + } + + // TGA constants + + var TGA_TYPE_NO_DATA = 0, + TGA_TYPE_INDEXED = 1, + TGA_TYPE_RGB = 2, + TGA_TYPE_GREY = 3, + TGA_TYPE_RLE_INDEXED = 9, + TGA_TYPE_RLE_RGB = 10, + TGA_TYPE_RLE_GREY = 11, + + TGA_ORIGIN_MASK = 0x30, + TGA_ORIGIN_SHIFT = 0x04, + TGA_ORIGIN_BL = 0x00, + TGA_ORIGIN_BR = 0x01, + TGA_ORIGIN_UL = 0x02, + TGA_ORIGIN_UR = 0x03; + + if ( buffer.length < 19 ) console.error( 'THREE.TGALoader: Not enough data to contain header.' ); + + var content = new Uint8Array( buffer ), + offset = 0, + header = { + id_length: content[ offset ++ ], + colormap_type: content[ offset ++ ], + image_type: content[ offset ++ ], + colormap_index: content[ offset ++ ] | content[ offset ++ ] << 8, + colormap_length: content[ offset ++ ] | content[ offset ++ ] << 8, + colormap_size: content[ offset ++ ], + origin: [ + content[ offset ++ ] | content[ offset ++ ] << 8, + content[ offset ++ ] | content[ offset ++ ] << 8 + ], + width: content[ offset ++ ] | content[ offset ++ ] << 8, + height: content[ offset ++ ] | content[ offset ++ ] << 8, + pixel_size: content[ offset ++ ], + flags: content[ offset ++ ] + }; + + // check tga if it is valid format + + tgaCheckHeader( header ); + + if ( header.id_length + offset > buffer.length ) { + + console.error( 'THREE.TGALoader: No data.' ); + + } + + // skip the needn't data + + offset += header.id_length; + + // get targa information about RLE compression and palette + + var use_rle = false, + use_pal = false, + use_grey = false; + + switch ( header.image_type ) { + + case TGA_TYPE_RLE_INDEXED: + use_rle = true; + use_pal = true; + break; + + case TGA_TYPE_INDEXED: + use_pal = true; + break; + + case TGA_TYPE_RLE_RGB: + use_rle = true; + break; + + case TGA_TYPE_RGB: + break; + + case TGA_TYPE_RLE_GREY: + use_rle = true; + use_grey = true; + break; + + case TGA_TYPE_GREY: + use_grey = true; + break; + + } + + // + + var canvas = document.createElement( 'canvas' ); + canvas.width = header.width; + canvas.height = header.height; + + var context = canvas.getContext( '2d' ); + var imageData = context.createImageData( header.width, header.height ); + + var result = tgaParse( use_rle, use_pal, header, offset, content ); + var rgbaData = getTgaRGBA( imageData.data, header.width, header.height, result.pixel_data, result.palettes ); + + context.putImageData( imageData, 0, 0 ); + + return canvas; + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + } + +}; diff --git a/three/jsutil/loaders/TTFLoader.js b/three/jsutil/loaders/TTFLoader.js new file mode 100644 index 000000000..32b770d8e --- /dev/null +++ b/three/jsutil/loaders/TTFLoader.js @@ -0,0 +1,200 @@ +/** + * @author gero3 / https://github.com/gero3 + * @author tentone / https://github.com/tentone + * + * Requires opentype.js to be included in the project. + * Loads TTF files and converts them into typeface JSON that can be used directly + * to create THREE.Font objects. + */ + +THREE.TTFLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.reversed = false; + +}; + +THREE.TTFLoader.prototype = { + + constructor: THREE.TTFLoader, + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( buffer ) { + + onLoad( scope.parse( buffer ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( arraybuffer ) { + + function convert( font, reversed ) { + + var round = Math.round; + + var glyphs = {}; + var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 ); + + for ( var i = 0; i < font.glyphs.length; i ++ ) { + + var glyph = font.glyphs.glyphs[ i ]; + + if ( glyph.unicode !== undefined ) { + + var token = { + ha: round( glyph.advanceWidth * scale ), + x_min: round( glyph.xMin * scale ), + x_max: round( glyph.xMax * scale ), + o: '' + }; + + if ( reversed ) { + + glyph.path.commands = reverseCommands( glyph.path.commands ); + + } + + glyph.path.commands.forEach( function ( command, i ) { + + if ( command.type.toLowerCase() === 'c' ) { + + command.type = 'b'; + + } + + token.o += command.type.toLowerCase() + ' '; + + if ( command.x !== undefined && command.y !== undefined ) { + + token.o += round( command.x * scale ) + ' ' + round( command.y * scale ) + ' '; + + } + + if ( command.x1 !== undefined && command.y1 !== undefined ) { + + token.o += round( command.x1 * scale ) + ' ' + round( command.y1 * scale ) + ' '; + + } + + if ( command.x2 !== undefined && command.y2 !== undefined ) { + + token.o += round( command.x2 * scale ) + ' ' + round( command.y2 * scale ) + ' '; + + } + + } ); + + glyphs[ String.fromCharCode( glyph.unicode ) ] = token; + + } + + } + + return { + glyphs: glyphs, + familyName: font.familyName, + ascender: round( font.ascender * scale ), + descender: round( font.descender * scale ), + underlinePosition: font.tables.post.underlinePosition, + underlineThickness: font.tables.post.underlineThickness, + boundingBox: { + xMin: font.tables.head.xMin, + xMax: font.tables.head.xMax, + yMin: font.tables.head.yMin, + yMax: font.tables.head.yMax + }, + resolution: 1000, + original_font_information: font.tables.name + }; + + } + + function reverseCommands( commands ) { + + var paths = []; + var path; + + commands.forEach( function ( c ) { + + if ( c.type.toLowerCase() === 'm' ) { + + path = [ c ]; + paths.push( path ); + + } else if ( c.type.toLowerCase() !== 'z' ) { + + path.push( c ); + + } + + } ); + + var reversed = []; + + paths.forEach( function ( p ) { + + var result = { + type: 'm', + x: p[ p.length - 1 ].x, + y: p[ p.length - 1 ].y + }; + + reversed.push( result ); + + for ( var i = p.length - 1; i > 0; i -- ) { + + var command = p[ i ]; + var result = { type: command.type }; + + if ( command.x2 !== undefined && command.y2 !== undefined ) { + + result.x1 = command.x2; + result.y1 = command.y2; + result.x2 = command.x1; + result.y2 = command.y1; + + } else if ( command.x1 !== undefined && command.y1 !== undefined ) { + + result.x1 = command.x1; + result.y1 = command.y1; + + } + + result.x = p[ i - 1 ].x; + result.y = p[ i - 1 ].y; + reversed.push( result ); + + } + + } ); + + return reversed; + + } + + if ( typeof opentype === 'undefined' ) { + + console.warn( 'THREE.TTFLoader: The loader requires opentype.js. Make sure it\'s included before using the loader.' ); + return null; + + } + + return convert( opentype.parse( arraybuffer ), this.reversed ); + + } + +}; diff --git a/three/jsutil/loaders/VRMLLoader.js b/three/jsutil/loaders/VRMLLoader.js new file mode 100644 index 000000000..062c18e38 --- /dev/null +++ b/three/jsutil/loaders/VRMLLoader.js @@ -0,0 +1,1298 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.VRMLLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +THREE.VRMLLoader.prototype = { + + constructor: THREE.VRMLLoader, + + // for IndexedFaceSet support + isRecordingPoints: false, + isRecordingFaces: false, + points: [], + indexes: [], + + // for Background support + isRecordingAngles: false, + isRecordingColors: false, + angles: [], + colors: [], + + recordingFieldname: null, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var path = ( scope.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : scope.path; + + var loader = new THREE.FileLoader( this.manager ); + loader.setPath( scope.path ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text, path ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + parse: function ( data, path ) { + + var scope = this; + + var textureLoader = new THREE.TextureLoader( this.manager ); + textureLoader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin ); + + function parseV2( lines, scene ) { + + var defines = {}; + var float_pattern = /(\b|\-|\+)([\d\.e]+)/; + var float2_pattern = /([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g; + var float3_pattern = /([\d\.\+\-e]+)\s+([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g; + + /** + * Vertically paints the faces interpolating between the + * specified colors at the specified angels. This is used for the Background + * node, but could be applied to other nodes with multiple faces as well. + * + * When used with the Background node, default is directionIsDown is true if + * interpolating the skyColor down from the Zenith. When interpolationg up from + * the Nadir i.e. interpolating the groundColor, the directionIsDown is false. + * + * The first angle is never specified, it is the Zenith (0 rad). Angles are specified + * in radians. The geometry is thought a sphere, but could be anything. The color interpolation + * is linear along the Y axis in any case. + * + * You must specify one more color than you have angles at the beginning of the colors array. + * This is the color of the Zenith (the top of the shape). + * + * @param geometry + * @param radius + * @param angles + * @param colors + * @param boolean topDown Whether to work top down or bottom up. + */ + function paintFaces( geometry, radius, angles, colors, topDown ) { + + var direction = ( topDown === true ) ? 1 : - 1; + + var coord = [], A = {}, B = {}, applyColor = false; + + for ( var k = 0; k < angles.length; k ++ ) { + + // push the vector at which the color changes + + var vec = { + x: direction * ( Math.cos( angles[ k ] ) * radius ), + y: direction * ( Math.sin( angles[ k ] ) * radius ) + }; + + coord.push( vec ); + + } + + var index = geometry.index; + var positionAttribute = geometry.attributes.position; + var colorAttribute = new THREE.BufferAttribute( new Float32Array( geometry.attributes.position.count * 3 ), 3 ); + + var position = new THREE.Vector3(); + var color = new THREE.Color(); + + for ( var i = 0; i < index.count; i ++ ) { + + var vertexIndex = index.getX( i ); + + position.fromBufferAttribute( positionAttribute, vertexIndex ); + + for ( var j = 0; j < colors.length; j ++ ) { + + // linear interpolation between aColor and bColor, calculate proportion + // A is previous point (angle) + + if ( j === 0 ) { + + A.x = 0; + A.y = ( topDown === true ) ? radius : - 1 * radius; + + } else { + + A.x = coord[ j - 1 ].x; + A.y = coord[ j - 1 ].y; + + } + + // B is current point (angle) + + B = coord[ j ]; + + if ( B !== undefined ) { + + // p has to be between the points A and B which we interpolate + + applyColor = ( topDown === true ) ? ( position.y <= A.y && position.y > B.y ) : ( position.y >= A.y && position.y < B.y ); + + if ( applyColor === true ) { + + var aColor = colors[ j ]; + var bColor = colors[ j + 1 ]; + + // below is simple linear interpolation + + var t = Math.abs( position.y - A.y ) / ( A.y - B.y ); + + // to make it faster, you can only calculate this if the y coord changes, the color is the same for points with the same y + + color.copy( aColor ).lerp( bColor, t ); + + colorAttribute.setXYZ( vertexIndex, color.r, color.g, color.b ); + + } else { + + var colorIndex = ( topDown === true ) ? colors.length - 1 : 0; + var c = colors[ colorIndex ]; + colorAttribute.setXYZ( vertexIndex, c.r, c.g, c.b ); + + } + + } + + } + + } + + geometry.addAttribute( 'color', colorAttribute ); + + } + + var index = []; + + function parseProperty( node, line ) { + + var parts = [], part, property = {}, fieldName; + + /** + * Expression for matching relevant information, such as a name or value, but not the separators + * @type {RegExp} + */ + var regex = /[^\s,\[\]]+/g; + + var point; + + while ( null !== ( part = regex.exec( line ) ) ) { + + parts.push( part[ 0 ] ); + + } + + fieldName = parts[ 0 ]; + + + // trigger several recorders + switch ( fieldName ) { + + case 'skyAngle': + case 'groundAngle': + scope.recordingFieldname = fieldName; + scope.isRecordingAngles = true; + scope.angles = []; + break; + + case 'color': + case 'skyColor': + case 'groundColor': + scope.recordingFieldname = fieldName; + scope.isRecordingColors = true; + scope.colors = []; + break; + + case 'point': + case 'vector': + scope.recordingFieldname = fieldName; + scope.isRecordingPoints = true; + scope.points = []; + break; + + case 'colorIndex': + case 'coordIndex': + case 'normalIndex': + case 'texCoordIndex': + scope.recordingFieldname = fieldName; + scope.isRecordingFaces = true; + scope.indexes = []; + break; + + } + + if ( scope.isRecordingFaces ) { + + // the parts hold the indexes as strings + if ( parts.length > 0 ) { + + for ( var ind = 0; ind < parts.length; ind ++ ) { + + // the part should either be positive integer or -1 + if ( ! /(-?\d+)/.test( parts[ ind ] ) ) { + + continue; + + } + + // end of current face + if ( parts[ ind ] === '-1' ) { + + if ( index.length > 0 ) { + + scope.indexes.push( index ); + + } + + // start new one + index = []; + + } else { + + index.push( parseInt( parts[ ind ] ) ); + + } + + } + + } + + // end + if ( /]/.exec( line ) ) { + + if ( index.length > 0 ) { + + scope.indexes.push( index ); + + } + + // start new one + index = []; + + scope.isRecordingFaces = false; + node[ scope.recordingFieldname ] = scope.indexes; + + } + + } else if ( scope.isRecordingPoints ) { + + if ( node.nodeType == 'Coordinate' ) { + + while ( null !== ( parts = float3_pattern.exec( line ) ) ) { + + point = { + x: parseFloat( parts[ 1 ] ), + y: parseFloat( parts[ 2 ] ), + z: parseFloat( parts[ 3 ] ) + }; + + scope.points.push( point ); + + } + + } + + if ( node.nodeType == 'Normal' ) { + + while ( null !== ( parts = float3_pattern.exec( line ) ) ) { + + point = { + x: parseFloat( parts[ 1 ] ), + y: parseFloat( parts[ 2 ] ), + z: parseFloat( parts[ 3 ] ) + }; + + scope.points.push( point ); + + } + + } + + if ( node.nodeType == 'TextureCoordinate' ) { + + while ( null !== ( parts = float2_pattern.exec( line ) ) ) { + + point = { + x: parseFloat( parts[ 1 ] ), + y: parseFloat( parts[ 2 ] ) + }; + + scope.points.push( point ); + + } + + } + + // end + if ( /]/.exec( line ) ) { + + scope.isRecordingPoints = false; + node.points = scope.points; + + } + + } else if ( scope.isRecordingAngles ) { + + // the parts hold the angles as strings + if ( parts.length > 0 ) { + + for ( var ind = 0; ind < parts.length; ind ++ ) { + + // the part should be a float + if ( ! float_pattern.test( parts[ ind ] ) ) { + + continue; + + } + + scope.angles.push( parseFloat( parts[ ind ] ) ); + + } + + } + + // end + if ( /]/.exec( line ) ) { + + scope.isRecordingAngles = false; + node[ scope.recordingFieldname ] = scope.angles; + + } + + } else if ( scope.isRecordingColors ) { + + while ( null !== ( parts = float3_pattern.exec( line ) ) ) { + + var color = { + r: parseFloat( parts[ 1 ] ), + g: parseFloat( parts[ 2 ] ), + b: parseFloat( parts[ 3 ] ) + }; + + scope.colors.push( color ); + + } + + // end + if ( /]/.exec( line ) ) { + + scope.isRecordingColors = false; + node[ scope.recordingFieldname ] = scope.colors; + + } + + } else if ( parts[ parts.length - 1 ] !== 'NULL' && fieldName !== 'children' ) { + + switch ( fieldName ) { + + case 'diffuseColor': + case 'emissiveColor': + case 'specularColor': + case 'color': + + if ( parts.length !== 4 ) { + + console.warn( 'THREE.VRMLLoader: Invalid color format detected for %s.', fieldName ); + break; + + } + + property = { + r: parseFloat( parts[ 1 ] ), + g: parseFloat( parts[ 2 ] ), + b: parseFloat( parts[ 3 ] ) + }; + + break; + + case 'location': + case 'direction': + case 'translation': + case 'scale': + case 'size': + if ( parts.length !== 4 ) { + + console.warn( 'THREE.VRMLLoader: Invalid vector format detected for %s.', fieldName ); + break; + + } + + property = { + x: parseFloat( parts[ 1 ] ), + y: parseFloat( parts[ 2 ] ), + z: parseFloat( parts[ 3 ] ) + }; + + break; + + case 'intensity': + case 'cutOffAngle': + case 'radius': + case 'topRadius': + case 'bottomRadius': + case 'height': + case 'transparency': + case 'shininess': + case 'ambientIntensity': + case 'creaseAngle': + if ( parts.length !== 2 ) { + + console.warn( 'THREE.VRMLLoader: Invalid single float value specification detected for %s.', fieldName ); + break; + + } + + property = parseFloat( parts[ 1 ] ); + + break; + + case 'rotation': + if ( parts.length !== 5 ) { + + console.warn( 'THREE.VRMLLoader: Invalid quaternion format detected for %s.', fieldName ); + break; + + } + + property = { + x: parseFloat( parts[ 1 ] ), + y: parseFloat( parts[ 2 ] ), + z: parseFloat( parts[ 3 ] ), + w: parseFloat( parts[ 4 ] ) + }; + + break; + + case 'on': + case 'ccw': + case 'solid': + case 'colorPerVertex': + case 'convex': + if ( parts.length !== 2 ) { + + console.warn( 'THREE.VRMLLoader: Invalid format detected for %s.', fieldName ); + break; + + } + + property = parts[ 1 ] === 'TRUE' ? true : false; + + break; + + } + + node[ fieldName ] = property; + + } + + return property; + + } + + function getTree( lines ) { + + var tree = { 'string': 'Scene', children: [] }; + var current = tree; + var matches; + var specification; + + for ( var i = 0; i < lines.length; i ++ ) { + + var comment = ''; + + var line = lines[ i ]; + + // omit whitespace only lines + if ( null !== ( /^\s+?$/g.exec( line ) ) ) { + + continue; + + } + + line = line.trim(); + + // skip empty lines + if ( line === '' ) { + + continue; + + } + + if ( /#/.exec( line ) ) { + + var parts = line.split( '#' ); + + // discard everything after the #, it is a comment + line = parts[ 0 ]; + + // well, let's also keep the comment + comment = parts[ 1 ]; + + } + + if ( matches = /([^\s]*){1}(?:\s+)?{/.exec( line ) ) { + + // first subpattern should match the Node name + + var block = { 'nodeType': matches[ 1 ], 'string': line, 'parent': current, 'children': [], 'comment': comment }; + current.children.push( block ); + current = block; + + if ( /}/.exec( line ) ) { + + // example: geometry Box { size 1 1 1 } # all on the same line + specification = /{(.*)}/.exec( line )[ 1 ]; + + // todo: remove once new parsing is complete? + block.children.push( specification ); + + parseProperty( current, specification ); + + current = current.parent; + + } + + } else if ( /}/.exec( line ) ) { + + current = current.parent; + + } else if ( line !== '' ) { + + parseProperty( current, line ); + // todo: remove once new parsing is complete? we still do not parse geometry and appearance the new way + current.children.push( line ); + + } + + } + + return tree; + + } + + function parseNode( data, parent ) { + + var object; + + if ( typeof data === 'string' ) { + + if ( /USE/.exec( data ) ) { + + var defineKey = /USE\s+?([^\s]+)/.exec( data )[ 1 ]; + + if ( undefined == defines[ defineKey ] ) { + + console.warn( 'THREE.VRMLLoader: %s is not defined.', defineKey ); + + } else { + + if ( /appearance/.exec( data ) && defineKey ) { + + parent.material = defines[ defineKey ].clone(); + + } else if ( /geometry/.exec( data ) && defineKey ) { + + parent.geometry = defines[ defineKey ].clone(); + + // the solid property is not cloned with clone(), is only needed for VRML loading, so we need to transfer it + if ( undefined !== defines[ defineKey ].solid && defines[ defineKey ].solid === false ) { + + parent.geometry.solid = false; + parent.material.side = THREE.DoubleSide; + + } + + } else if ( defineKey ) { + + object = defines[ defineKey ].clone(); + parent.add( object ); + + } + + } + + } + + return; + + } + + object = parent; + + if ( data.string.indexOf( 'AmbientLight' ) > - 1 && data.nodeType === 'PointLight' ) { + + data.nodeType = 'AmbientLight'; + + } + + var l_visible = data.on !== undefined ? data.on : true; + var l_intensity = data.intensity !== undefined ? data.intensity : 1; + var l_color = new THREE.Color(); + + if ( data.color ) { + + l_color.copy( data.color ); + + } + + if ( data.nodeType === 'AmbientLight' ) { + + object = new THREE.AmbientLight( l_color, l_intensity ); + object.visible = l_visible; + + parent.add( object ); + + } else if ( data.nodeType === 'PointLight' ) { + + var l_distance = 0; + + if ( data.radius !== undefined && data.radius < 1000 ) { + + l_distance = data.radius; + + } + + object = new THREE.PointLight( l_color, l_intensity, l_distance ); + object.visible = l_visible; + + parent.add( object ); + + } else if ( data.nodeType === 'SpotLight' ) { + + var l_intensity = 1; + var l_distance = 0; + var l_angle = Math.PI / 3; + var l_penumbra = 0; + var l_visible = true; + + if ( data.radius !== undefined && data.radius < 1000 ) { + + l_distance = data.radius; + + } + + if ( data.cutOffAngle !== undefined ) { + + l_angle = data.cutOffAngle; + + } + + object = new THREE.SpotLight( l_color, l_intensity, l_distance, l_angle, l_penumbra ); + object.visible = l_visible; + + parent.add( object ); + + } else if ( data.nodeType === 'Transform' || data.nodeType === 'Group' ) { + + object = new THREE.Object3D(); + + if ( /DEF/.exec( data.string ) ) { + + object.name = /DEF\s+([^\s]+)/.exec( data.string )[ 1 ]; + defines[ object.name ] = object; + + } + + if ( data.translation !== undefined ) { + + var t = data.translation; + + object.position.set( t.x, t.y, t.z ); + + } + + if ( data.rotation !== undefined ) { + + var r = data.rotation; + + object.quaternion.setFromAxisAngle( new THREE.Vector3( r.x, r.y, r.z ), r.w ); + + } + + if ( data.scale !== undefined ) { + + var s = data.scale; + + object.scale.set( s.x, s.y, s.z ); + + } + + parent.add( object ); + + } else if ( data.nodeType === 'Shape' ) { + + object = new THREE.Mesh(); + + if ( /DEF/.exec( data.string ) ) { + + object.name = /DEF\s+([^\s]+)/.exec( data.string )[ 1 ]; + + defines[ object.name ] = object; + + } + + parent.add( object ); + + } else if ( data.nodeType === 'Background' ) { + + var segments = 20; + + // sky (full sphere): + + var radius = 2e4; + + var skyGeometry = new THREE.SphereBufferGeometry( radius, segments, segments ); + var skyMaterial = new THREE.MeshBasicMaterial( { fog: false, side: THREE.BackSide } ); + + if ( data.skyColor.length > 1 ) { + + paintFaces( skyGeometry, radius, data.skyAngle, data.skyColor, true ); + + skyMaterial.vertexColors = THREE.VertexColors; + + } else { + + var color = data.skyColor[ 0 ]; + skyMaterial.color.setRGB( color.r, color.b, color.g ); + + } + + scene.add( new THREE.Mesh( skyGeometry, skyMaterial ) ); + + // ground (half sphere): + + if ( data.groundColor !== undefined ) { + + radius = 1.2e4; + + var groundGeometry = new THREE.SphereBufferGeometry( radius, segments, segments, 0, 2 * Math.PI, 0.5 * Math.PI, 1.5 * Math.PI ); + var groundMaterial = new THREE.MeshBasicMaterial( { fog: false, side: THREE.BackSide, vertexColors: THREE.VertexColors } ); + + paintFaces( groundGeometry, radius, data.groundAngle, data.groundColor, false ); + + scene.add( new THREE.Mesh( groundGeometry, groundMaterial ) ); + + } + + } else if ( /geometry/.exec( data.string ) ) { + + if ( data.nodeType === 'Box' ) { + + var s = data.size; + + parent.geometry = new THREE.BoxBufferGeometry( s.x, s.y, s.z ); + + } else if ( data.nodeType === 'Cylinder' ) { + + parent.geometry = new THREE.CylinderBufferGeometry( data.radius, data.radius, data.height ); + + } else if ( data.nodeType === 'Cone' ) { + + parent.geometry = new THREE.CylinderBufferGeometry( data.topRadius, data.bottomRadius, data.height ); + + } else if ( data.nodeType === 'Sphere' ) { + + parent.geometry = new THREE.SphereBufferGeometry( data.radius ); + + } else if ( data.nodeType === 'IndexedFaceSet' ) { + + var geometry = new THREE.BufferGeometry(); + + var positions = []; + var colors = []; + var normals = []; + var uvs = []; + + var position, color, normal, uv; + + var i, il, j, jl; + + for ( i = 0, il = data.children.length; i < il; i ++ ) { + + var child = data.children[ i ]; + + // uvs + + if ( child.nodeType === 'TextureCoordinate' ) { + + if ( child.points ) { + + for ( j = 0, jl = child.points.length; j < jl; j ++ ) { + + uv = child.points[ j ]; + uvs.push( uv.x, uv.y ); + + } + + } + + } + + // normals + + if ( child.nodeType === 'Normal' ) { + + if ( child.points ) { + + for ( j = 0, jl = child.points.length; j < jl; j ++ ) { + + normal = child.points[ j ]; + normals.push( normal.x, normal.y, normal.z ); + + } + + } + + } + + // colors + + if ( child.nodeType === 'Color' ) { + + if ( child.color ) { + + for ( j = 0, jl = child.color.length; j < jl; j ++ ) { + + color = child.color[ j ]; + colors.push( color.r, color.g, color.b ); + + } + + } + + } + + // positions + + if ( child.nodeType === 'Coordinate' ) { + + if ( child.points ) { + + for ( j = 0, jl = child.points.length; j < jl; j ++ ) { + + position = child.points[ j ]; + positions.push( position.x, position.y, position.z ); + + } + + } + + if ( child.string.indexOf( 'DEF' ) > - 1 ) { + + var name = /DEF\s+([^\s]+)/.exec( child.string )[ 1 ]; + + defines[ name ] = positions.slice( 0 ); + + } + + if ( child.string.indexOf( 'USE' ) > - 1 ) { + + var defineKey = /USE\s+([^\s]+)/.exec( child.string )[ 1 ]; + + positions = defines[ defineKey ]; + + } + + } + + } + + // some shapes only have vertices for use in other shapes + + if ( data.coordIndex ) { + + function triangulateIndexArray( indexArray, ccw ) { + + if ( ccw === undefined ) { + + // ccw is true by default + ccw = true; + + } + + var triangulatedIndexArray = []; + var skip = 0; + + for ( i = 0, il = indexArray.length; i < il; i ++ ) { + + var indexedFace = indexArray[ i ]; + + // VRML support multipoint indexed face sets (more then 3 vertices). You must calculate the composing triangles here + + skip = 0; + + while ( indexedFace.length >= 3 && skip < ( indexedFace.length - 2 ) ) { + + var i1 = indexedFace[ 0 ]; + var i2 = indexedFace[ skip + ( ccw ? 1 : 2 ) ]; + var i3 = indexedFace[ skip + ( ccw ? 2 : 1 ) ]; + + triangulatedIndexArray.push( i1, i2, i3 ); + + skip ++; + + } + + } + + return triangulatedIndexArray; + + } + + var positionIndexes = data.coordIndex ? triangulateIndexArray( data.coordIndex, data.ccw ) : []; + var normalIndexes = data.normalIndex ? triangulateIndexArray( data.normalIndex, data.ccw ) : positionIndexes; + var colorIndexes = data.colorIndex ? triangulateIndexArray( data.colorIndex, data.ccw ) : positionIndexes; + var uvIndexes = data.texCoordIndex ? triangulateIndexArray( data.texCoordIndex, data.ccw ) : positionIndexes; + + var newIndexes = []; + var newPositions = []; + var newNormals = []; + var newColors = []; + var newUvs = []; + + // if any other index array does not match the coordinate indexes, split any points that differ + + var pointMap = Object.create( null ); + + for ( i = 0; i < positionIndexes.length; i ++ ) { + + var pointAttributes = []; + + var positionIndex = positionIndexes[ i ]; + var normalIndex = normalIndexes[ i ]; + var colorIndex = colorIndexes[ i ]; + var uvIndex = uvIndexes[ i ]; + + var base = 10; // which base to use to represent each value + + pointAttributes.push( positionIndex.toString( base ) ); + + if ( normalIndex !== undefined ) { + + pointAttributes.push( normalIndex.toString( base ) ); + + } + + if ( colorIndex !== undefined ) { + + pointAttributes.push( colorIndex.toString( base ) ); + + } + + if ( uvIndex !== undefined ) { + + pointAttributes.push( uvIndex.toString( base ) ); + + } + + var pointId = pointAttributes.join( ',' ); + var newIndex = pointMap[ pointId ]; + + if ( newIndex === undefined ) { + + newIndex = newPositions.length / 3; + pointMap[ pointId ] = newIndex; + + newPositions.push( + positions[ positionIndex * 3 ], + positions[ positionIndex * 3 + 1 ], + positions[ positionIndex * 3 + 2 ] + ); + + if ( normalIndex !== undefined && normals.length > 0 ) { + + newNormals.push( + normals[ normalIndex * 3 ], + normals[ normalIndex * 3 + 1 ], + normals[ normalIndex * 3 + 2 ] + ); + + } + + if ( colorIndex !== undefined && colors.length > 0 ) { + + newColors.push( + colors[ colorIndex * 3 ], + colors[ colorIndex * 3 + 1 ], + colors[ colorIndex * 3 + 2 ] + ); + + } + + if ( uvIndex !== undefined && uvs.length > 0 ) { + + newUvs.push( + uvs[ uvIndex * 2 ], + uvs[ uvIndex * 2 + 1 ] + ); + + } + + } + + newIndexes.push( newIndex ); + + } + + positions = newPositions; + normals = newNormals; + colors = newColors; + uvs = newUvs; + + geometry.setIndex( newIndexes ); + + } else { + + // do not add dummy mesh to the scene + + parent.parent.remove( parent ); + + } + + if ( false === data.solid ) { + + parent.material.side = THREE.DoubleSide; + + } + + // we need to store it on the geometry for use with defines + geometry.solid = data.solid; + + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + + if ( colors.length > 0 ) { + + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + } + + if ( uvs.length > 0 ) { + + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + + } + + if ( normals.length > 0 ) { + + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + } else { + + // convert geometry to non-indexed to get sharp normals + geometry = geometry.toNonIndexed(); + geometry.computeVertexNormals(); + + } + + geometry.computeBoundingSphere(); + + // see if it's a define + if ( /DEF/.exec( data.string ) ) { + + geometry.name = /DEF ([^\s]+)/.exec( data.string )[ 1 ]; + defines[ geometry.name ] = geometry; + + } + + parent.geometry = geometry; + + } + + return; + + } else if ( /appearance/.exec( data.string ) ) { + + for ( var i = 0; i < data.children.length; i ++ ) { + + var child = data.children[ i ]; + + if ( child.nodeType === 'Material' ) { + + var material = new THREE.MeshPhongMaterial(); + + if ( child.diffuseColor !== undefined ) { + + var d = child.diffuseColor; + + material.color.setRGB( d.r, d.g, d.b ); + + } + + if ( child.emissiveColor !== undefined ) { + + var e = child.emissiveColor; + + material.emissive.setRGB( e.r, e.g, e.b ); + + } + + if ( child.specularColor !== undefined ) { + + var s = child.specularColor; + + material.specular.setRGB( s.r, s.g, s.b ); + + } + + if ( child.transparency !== undefined ) { + + var t = child.transparency; + + // transparency is opposite of opacity + material.opacity = Math.abs( 1 - t ); + + material.transparent = true; + + } + + if ( /DEF/.exec( data.string ) ) { + + material.name = /DEF ([^\s]+)/.exec( data.string )[ 1 ]; + + defines[ material.name ] = material; + + } + + parent.material = material; + + } + + if ( child.nodeType === 'ImageTexture' ) { + + var textureName = /"([^"]+)"/.exec( child.children[ 0 ] ); + + if ( textureName ) { + + parent.material.name = textureName[ 1 ]; + + parent.material.map = textureLoader.load( textureName[ 1 ] ); + + } + + } + + } + + return; + + } + + for ( var i = 0, l = data.children.length; i < l; i ++ ) { + + parseNode( data.children[ i ], object ); + + } + + } + + parseNode( getTree( lines ), scene ); + + } + + var scene = new THREE.Scene(); + + var lines = data.split( '\n' ); + + // some lines do not have breaks + + for ( var i = lines.length - 1; i > - 1; i -- ) { + + var line = lines[ i ]; + + // The # symbol indicates that all subsequent text, until the end of the line is a comment, + // and should be ignored. (see http://gun.teipir.gr/VRML-amgem/spec/part1/grammar.html) + line = line.replace( /(#.*)/, '' ); + + // split lines with {..{ or {..[ - some have both + if ( /{.*[{\[]/.test( line ) ) { + + var parts = line.split( '{' ).join( '{\n' ).split( '\n' ); + parts.unshift( 1 ); + parts.unshift( i ); + lines.splice.apply( lines, parts ); + + } else if ( /\].*}/.test( line ) ) { + + // split lines with ]..} + var parts = line.split( ']' ).join( ']\n' ).split( '\n' ); + parts.unshift( 1 ); + parts.unshift( i ); + lines.splice.apply( lines, parts ); + + } + + if ( /}.*}/.test( line ) ) { + + // split lines with }..} + var parts = line.split( '}' ).join( '}\n' ).split( '\n' ); + parts.unshift( 1 ); + parts.unshift( i ); + lines.splice.apply( lines, parts ); + + } + + if ( /^\b[^\s]+\b$/.test( line.trim() ) ) { + + // prevent lines with single words like "coord" or "geometry", see #12209 + lines[ i + 1 ] = line + ' ' + lines[ i + 1 ].trim(); + lines.splice( i, 1 ); + + } else if ( ( line.indexOf( 'coord' ) > - 1 ) && ( line.indexOf( '[' ) < 0 ) && ( line.indexOf( '{' ) < 0 ) ) { + + // force the parser to create Coordinate node for empty coords + // coord USE something -> coord USE something Coordinate {} + + lines[ i ] += ' Coordinate {}'; + + } + + } + + var header = lines.shift(); + + if ( /V1.0/.exec( header ) ) { + + console.warn( 'THREE.VRMLLoader: V1.0 not supported yet.' ); + + } else if ( /V2.0/.exec( header ) ) { + + parseV2( lines, scene ); + + } + + return scene; + + } + +}; diff --git a/three/jsutil/loaders/VRMLoader.js b/three/jsutil/loaders/VRMLoader.js new file mode 100644 index 000000000..b9ccfe6b5 --- /dev/null +++ b/three/jsutil/loaders/VRMLoader.js @@ -0,0 +1,87 @@ +/** + * @author Takahiro / https://github.com/takahirox + */ + +// VRM Specification: https://dwango.github.io/vrm/vrm_spec/ +// +// VRM is based on glTF 2.0 and VRM extension is defined +// in top-level json.extensions.VRM + +THREE.VRMLoader = ( function () { + + function VRMLoader( manager ) { + + if ( THREE.GLTFLoader === undefined ) { + + throw new Error( 'THREE.VRMLoader: Import THREE.GLTFLoader.' ); + + } + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.gltfLoader = new THREE.GLTFLoader( this.manager ); + + } + + VRMLoader.prototype = { + + constructor: VRMLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + this.gltfLoader.load( url, function ( gltf ) { + + scope.parse( gltf, onLoad ); + + }, onProgress, onError ); + + }, + + setCrossOrigin: function ( value ) { + + this.glTFLoader.setCrossOrigin( value ); + return this; + + }, + + setPath: function ( value ) { + + this.glTFLoader.setPath( value ); + return this; + + }, + + setResourcePath: function ( value ) { + + this.glTFLoader.setResourcePath( value ); + return this; + + }, + + setDRACOLoader: function ( dracoLoader ) { + + this.glTFLoader.setDRACOLoader( dracoLoader ); + return this; + + }, + + parse: function ( gltf, onLoad ) { + + var gltfParser = gltf.parser; + var gltfExtensions = gltf.userData.gltfExtensions || {}; + var vrmExtension = gltfExtensions.VRM || {}; + + // handle VRM Extension here + + onLoad( gltf ); + + } + + }; + + return VRMLoader; + +} )(); diff --git a/three/jsutil/loaders/VTKLoader.js b/three/jsutil/loaders/VTKLoader.js new file mode 100644 index 000000000..c4e319e47 --- /dev/null +++ b/three/jsutil/loaders/VTKLoader.js @@ -0,0 +1,1162 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author Alex Pletzer + * + * Updated on 22.03.2017 + * VTK header is now parsed and used to extract all the compressed data + * @author Andrii Iudin https://github.com/andreyyudin + * @author Paul Kibet Korir https://github.com/polarise + * @author Sriram Somasundharam https://github.com/raamssundar + */ + +THREE.VTKLoader = function ( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + +}; + +Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, { + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var loader = new THREE.FileLoader( scope.manager ); + loader.setPath( scope.path ); + loader.setResponseType( 'arraybuffer' ); + loader.load( url, function ( text ) { + + onLoad( scope.parse( text ) ); + + }, onProgress, onError ); + + }, + + setPath: function ( value ) { + + this.path = value; + return this; + + }, + + parse: function ( data ) { + + function parseASCII( data ) { + + // connectivity of the triangles + var indices = []; + + // triangles vertices + var positions = []; + + // red, green, blue colors in the range 0 to 1 + var colors = []; + + // normal vector, one per vertex + var normals = []; + + var result; + + // pattern for reading vertices, 3 floats or integers + var pat3Floats = /(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)\s+(\-?\d+\.?[\d\-\+e]*)/g; + + // pattern for connectivity, an integer followed by any number of ints + // the first integer is the number of polygon nodes + var patConnectivity = /^(\d+)\s+([\s\d]*)/; + + // indicates start of vertex data section + var patPOINTS = /^POINTS /; + + // indicates start of polygon connectivity section + var patPOLYGONS = /^POLYGONS /; + + // indicates start of triangle strips section + var patTRIANGLE_STRIPS = /^TRIANGLE_STRIPS /; + + // POINT_DATA number_of_values + var patPOINT_DATA = /^POINT_DATA[ ]+(\d+)/; + + // CELL_DATA number_of_polys + var patCELL_DATA = /^CELL_DATA[ ]+(\d+)/; + + // Start of color section + var patCOLOR_SCALARS = /^COLOR_SCALARS[ ]+(\w+)[ ]+3/; + + // NORMALS Normals float + var patNORMALS = /^NORMALS[ ]+(\w+)[ ]+(\w+)/; + + var inPointsSection = false; + var inPolygonsSection = false; + var inTriangleStripSection = false; + var inPointDataSection = false; + var inCellDataSection = false; + var inColorSection = false; + var inNormalsSection = false; + + var lines = data.split( '\n' ); + + for ( var i in lines ) { + + var line = lines[ i ]; + + if ( inPointsSection ) { + + // get the vertices + while ( ( result = pat3Floats.exec( line ) ) !== null ) { + + var x = parseFloat( result[ 1 ] ); + var y = parseFloat( result[ 2 ] ); + var z = parseFloat( result[ 3 ] ); + positions.push( x, y, z ); + + } + + } else if ( inPolygonsSection ) { + + if ( ( result = patConnectivity.exec( line ) ) !== null ) { + + // numVertices i0 i1 i2 ... + var numVertices = parseInt( result[ 1 ] ); + var inds = result[ 2 ].split( /\s+/ ); + + if ( numVertices >= 3 ) { + + var i0 = parseInt( inds[ 0 ] ); + var i1, i2; + var k = 1; + // split the polygon in numVertices - 2 triangles + for ( var j = 0; j < numVertices - 2; ++ j ) { + + i1 = parseInt( inds[ k ] ); + i2 = parseInt( inds[ k + 1 ] ); + indices.push( i0, i1, i2 ); + k ++; + + } + + } + + } + + } else if ( inTriangleStripSection ) { + + if ( ( result = patConnectivity.exec( line ) ) !== null ) { + + // numVertices i0 i1 i2 ... + var numVertices = parseInt( result[ 1 ] ); + var inds = result[ 2 ].split( /\s+/ ); + + if ( numVertices >= 3 ) { + + var i0, i1, i2; + // split the polygon in numVertices - 2 triangles + for ( var j = 0; j < numVertices - 2; j ++ ) { + + if ( j % 2 === 1 ) { + + i0 = parseInt( inds[ j ] ); + i1 = parseInt( inds[ j + 2 ] ); + i2 = parseInt( inds[ j + 1 ] ); + indices.push( i0, i1, i2 ); + + } else { + + i0 = parseInt( inds[ j ] ); + i1 = parseInt( inds[ j + 1 ] ); + i2 = parseInt( inds[ j + 2 ] ); + indices.push( i0, i1, i2 ); + + } + + } + + } + + } + + } else if ( inPointDataSection || inCellDataSection ) { + + if ( inColorSection ) { + + // Get the colors + + while ( ( result = pat3Floats.exec( line ) ) !== null ) { + + var r = parseFloat( result[ 1 ] ); + var g = parseFloat( result[ 2 ] ); + var b = parseFloat( result[ 3 ] ); + colors.push( r, g, b ); + + } + + } else if ( inNormalsSection ) { + + // Get the normal vectors + + while ( ( result = pat3Floats.exec( line ) ) !== null ) { + + var nx = parseFloat( result[ 1 ] ); + var ny = parseFloat( result[ 2 ] ); + var nz = parseFloat( result[ 3 ] ); + normals.push( nx, ny, nz ); + + } + + } + + } + + if ( patPOLYGONS.exec( line ) !== null ) { + + inPolygonsSection = true; + inPointsSection = false; + inTriangleStripSection = false; + + } else if ( patPOINTS.exec( line ) !== null ) { + + inPolygonsSection = false; + inPointsSection = true; + inTriangleStripSection = false; + + } else if ( patTRIANGLE_STRIPS.exec( line ) !== null ) { + + inPolygonsSection = false; + inPointsSection = false; + inTriangleStripSection = true; + + } else if ( patPOINT_DATA.exec( line ) !== null ) { + + inPointDataSection = true; + inPointsSection = false; + inPolygonsSection = false; + inTriangleStripSection = false; + + } else if ( patCELL_DATA.exec( line ) !== null ) { + + inCellDataSection = true; + inPointsSection = false; + inPolygonsSection = false; + inTriangleStripSection = false; + + } else if ( patCOLOR_SCALARS.exec( line ) !== null ) { + + inColorSection = true; + inNormalsSection = false; + inPointsSection = false; + inPolygonsSection = false; + inTriangleStripSection = false; + + } else if ( patNORMALS.exec( line ) !== null ) { + + inNormalsSection = true; + inColorSection = false; + inPointsSection = false; + inPolygonsSection = false; + inTriangleStripSection = false; + + } + + } + + var geometry = new THREE.BufferGeometry(); + geometry.setIndex( indices ); + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + + if ( normals.length === positions.length ) { + + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + + } + + if ( colors.length !== indices.length ) { + + // stagger + + if ( colors.length === positions.length ) { + + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + } + + } else { + + // cell + + geometry = geometry.toNonIndexed(); + var numTriangles = geometry.attributes.position.count / 3; + + if ( colors.length === ( numTriangles * 3 ) ) { + + var newColors = []; + + for ( var i = 0; i < numTriangles; i ++ ) { + + var r = colors[ 3 * i + 0 ]; + var g = colors[ 3 * i + 1 ]; + var b = colors[ 3 * i + 2 ]; + + newColors.push( r, g, b ); + newColors.push( r, g, b ); + newColors.push( r, g, b ); + + } + + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( newColors, 3 ) ); + + } + + } + + return geometry; + + } + + function parseBinary( data ) { + + var count, pointIndex, i, numberOfPoints, s; + var buffer = new Uint8Array( data ); + var dataView = new DataView( data ); + + // Points and normals, by default, are empty + var points = []; + var normals = []; + var indices = []; + + // Going to make a big array of strings + var vtk = []; + var index = 0; + + function findString( buffer, start ) { + + var index = start; + var c = buffer[ index ]; + var s = []; + while ( c !== 10 ) { + + s.push( String.fromCharCode( c ) ); + index ++; + c = buffer[ index ]; + + } + + return { start: start, + end: index, + next: index + 1, + parsedString: s.join( '' ) }; + + } + + var state, line; + + while ( true ) { + + // Get a string + state = findString( buffer, index ); + line = state.parsedString; + + if ( line.indexOf( 'POINTS' ) === 0 ) { + + vtk.push( line ); + // Add the points + numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); + + // Each point is 3 4-byte floats + count = numberOfPoints * 4 * 3; + + points = new Float32Array( numberOfPoints * 3 ); + + pointIndex = state.next; + for ( i = 0; i < numberOfPoints; i ++ ) { + + points[ 3 * i ] = dataView.getFloat32( pointIndex, false ); + points[ 3 * i + 1 ] = dataView.getFloat32( pointIndex + 4, false ); + points[ 3 * i + 2 ] = dataView.getFloat32( pointIndex + 8, false ); + pointIndex = pointIndex + 12; + + } + // increment our next pointer + state.next = state.next + count + 1; + + } else if ( line.indexOf( 'TRIANGLE_STRIPS' ) === 0 ) { + + var numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 ); + var size = parseInt( line.split( ' ' )[ 2 ], 10 ); + // 4 byte integers + count = size * 4; + + indices = new Uint32Array( 3 * size - 9 * numberOfStrips ); + var indicesIndex = 0; + + pointIndex = state.next; + for ( i = 0; i < numberOfStrips; i ++ ) { + + // For each strip, read the first value, then record that many more points + var indexCount = dataView.getInt32( pointIndex, false ); + var strip = []; + pointIndex += 4; + for ( s = 0; s < indexCount; s ++ ) { + + strip.push( dataView.getInt32( pointIndex, false ) ); + pointIndex += 4; + + } + + // retrieves the n-2 triangles from the triangle strip + for ( var j = 0; j < indexCount - 2; j ++ ) { + + if ( j % 2 ) { + + indices[ indicesIndex ++ ] = strip[ j ]; + indices[ indicesIndex ++ ] = strip[ j + 2 ]; + indices[ indicesIndex ++ ] = strip[ j + 1 ]; + + } else { + + + indices[ indicesIndex ++ ] = strip[ j ]; + indices[ indicesIndex ++ ] = strip[ j + 1 ]; + indices[ indicesIndex ++ ] = strip[ j + 2 ]; + + } + + } + + } + // increment our next pointer + state.next = state.next + count + 1; + + } else if ( line.indexOf( 'POLYGONS' ) === 0 ) { + + var numberOfStrips = parseInt( line.split( ' ' )[ 1 ], 10 ); + var size = parseInt( line.split( ' ' )[ 2 ], 10 ); + // 4 byte integers + count = size * 4; + + indices = new Uint32Array( 3 * size - 9 * numberOfStrips ); + var indicesIndex = 0; + + pointIndex = state.next; + for ( i = 0; i < numberOfStrips; i ++ ) { + + // For each strip, read the first value, then record that many more points + var indexCount = dataView.getInt32( pointIndex, false ); + var strip = []; + pointIndex += 4; + for ( s = 0; s < indexCount; s ++ ) { + + strip.push( dataView.getInt32( pointIndex, false ) ); + pointIndex += 4; + + } + + // divide the polygon in n-2 triangle + for ( var j = 1; j < indexCount - 1; j ++ ) { + + indices[ indicesIndex ++ ] = strip[ 0 ]; + indices[ indicesIndex ++ ] = strip[ j ]; + indices[ indicesIndex ++ ] = strip[ j + 1 ]; + + } + + } + // increment our next pointer + state.next = state.next + count + 1; + + } else if ( line.indexOf( 'POINT_DATA' ) === 0 ) { + + numberOfPoints = parseInt( line.split( ' ' )[ 1 ], 10 ); + + // Grab the next line + state = findString( buffer, state.next ); + + // Now grab the binary data + count = numberOfPoints * 4 * 3; + + normals = new Float32Array( numberOfPoints * 3 ); + pointIndex = state.next; + for ( i = 0; i < numberOfPoints; i ++ ) { + + normals[ 3 * i ] = dataView.getFloat32( pointIndex, false ); + normals[ 3 * i + 1 ] = dataView.getFloat32( pointIndex + 4, false ); + normals[ 3 * i + 2 ] = dataView.getFloat32( pointIndex + 8, false ); + pointIndex += 12; + + } + + // Increment past our data + state.next = state.next + count; + + } + + // Increment index + index = state.next; + + if ( index >= buffer.byteLength ) { + + break; + + } + + } + + var geometry = new THREE.BufferGeometry(); + geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); + geometry.addAttribute( 'position', new THREE.BufferAttribute( points, 3 ) ); + + if ( normals.length === points.length ) { + + geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) ); + + } + + return geometry; + + } + + function Float32Concat( first, second ) { + + var firstLength = first.length, result = new Float32Array( firstLength + second.length ); + + result.set( first ); + result.set( second, firstLength ); + + return result; + + } + + function Int32Concat( first, second ) { + + var firstLength = first.length, result = new Int32Array( firstLength + second.length ); + + result.set( first ); + result.set( second, firstLength ); + + return result; + + } + + function parseXML( stringFile ) { + + // Changes XML to JSON, based on https://davidwalsh.name/convert-xml-json + + function xmlToJson( xml ) { + + // Create the return object + var obj = {}; + + if ( xml.nodeType === 1 ) { // element + + // do attributes + + if ( xml.attributes ) { + + if ( xml.attributes.length > 0 ) { + + obj[ 'attributes' ] = {}; + + for ( var j = 0; j < xml.attributes.length; j ++ ) { + + var attribute = xml.attributes.item( j ); + obj[ 'attributes' ][ attribute.nodeName ] = attribute.nodeValue.trim(); + + } + + } + + } + + } else if ( xml.nodeType === 3 ) { // text + + obj = xml.nodeValue.trim(); + + } + + // do children + if ( xml.hasChildNodes() ) { + + for ( var i = 0; i < xml.childNodes.length; i ++ ) { + + var item = xml.childNodes.item( i ); + var nodeName = item.nodeName; + + if ( typeof obj[ nodeName ] === 'undefined' ) { + + var tmp = xmlToJson( item ); + + if ( tmp !== '' ) obj[ nodeName ] = tmp; + + } else { + + if ( typeof obj[ nodeName ].push === 'undefined' ) { + + var old = obj[ nodeName ]; + obj[ nodeName ] = [ old ]; + + } + + var tmp = xmlToJson( item ); + + if ( tmp !== '' ) obj[ nodeName ].push( tmp ); + + } + + } + + } + + return obj; + + } + + // Taken from Base64-js + function Base64toByteArray( b64 ) { + + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array; + var i; + var lookup = []; + var revLookup = []; + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + var len = code.length; + + for ( i = 0; i < len; i ++ ) { + + lookup[ i ] = code[ i ]; + + } + + for ( i = 0; i < len; ++ i ) { + + revLookup[ code.charCodeAt( i ) ] = i; + + } + + revLookup[ '-'.charCodeAt( 0 ) ] = 62; + revLookup[ '_'.charCodeAt( 0 ) ] = 63; + + var j, l, tmp, placeHolders, arr; + var len = b64.length; + + if ( len % 4 > 0 ) { + + throw new Error( 'Invalid string. Length must be a multiple of 4' ); + + } + + placeHolders = b64[ len - 2 ] === '=' ? 2 : b64[ len - 1 ] === '=' ? 1 : 0; + arr = new Arr( len * 3 / 4 - placeHolders ); + l = placeHolders > 0 ? len - 4 : len; + + var L = 0; + + for ( i = 0, j = 0; i < l; i += 4, j += 3 ) { + + tmp = ( revLookup[ b64.charCodeAt( i ) ] << 18 ) | ( revLookup[ b64.charCodeAt( i + 1 ) ] << 12 ) | ( revLookup[ b64.charCodeAt( i + 2 ) ] << 6 ) | revLookup[ b64.charCodeAt( i + 3 ) ]; + arr[ L ++ ] = ( tmp & 0xFF0000 ) >> 16; + arr[ L ++ ] = ( tmp & 0xFF00 ) >> 8; + arr[ L ++ ] = tmp & 0xFF; + + } + + if ( placeHolders === 2 ) { + + tmp = ( revLookup[ b64.charCodeAt( i ) ] << 2 ) | ( revLookup[ b64.charCodeAt( i + 1 ) ] >> 4 ); + arr[ L ++ ] = tmp & 0xFF; + + } else if ( placeHolders === 1 ) { + + tmp = ( revLookup[ b64.charCodeAt( i ) ] << 10 ) | ( revLookup[ b64.charCodeAt( i + 1 ) ] << 4 ) | ( revLookup[ b64.charCodeAt( i + 2 ) ] >> 2 ); + arr[ L ++ ] = ( tmp >> 8 ) & 0xFF; + arr[ L ++ ] = tmp & 0xFF; + + } + + return arr; + + } + + function parseDataArray( ele, compressed ) { + + var numBytes = 0; + + if ( json.attributes.header_type === 'UInt64' ) { + + numBytes = 8; + + } else if ( json.attributes.header_type === 'UInt32' ) { + + numBytes = 4; + + } + + + // Check the format + if ( ele.attributes.format === 'binary' && compressed ) { + + var rawData, content, byteData, blocks, cSizeStart, headerSize, padding, dataOffsets, currentOffset; + + if ( ele.attributes.type === 'Float32' ) { + + var txt = new Float32Array( ); + + } else if ( ele.attributes.type === 'Int64' ) { + + var txt = new Int32Array( ); + + } + + // VTP data with the header has the following structure: + // [#blocks][#u-size][#p-size][#c-size-1][#c-size-2]...[#c-size-#blocks][DATA] + // + // Each token is an integer value whose type is specified by "header_type" at the top of the file (UInt32 if no type specified). The token meanings are: + // [#blocks] = Number of blocks + // [#u-size] = Block size before compression + // [#p-size] = Size of last partial block (zero if it not needed) + // [#c-size-i] = Size in bytes of block i after compression + // + // The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is + // computed by summing the compressed block sizes from preceding blocks according to the header. + + rawData = ele[ '#text' ]; + + byteData = Base64toByteArray( rawData ); + + blocks = byteData[ 0 ]; + for ( var i = 1; i < numBytes - 1; i ++ ) { + + blocks = blocks | ( byteData[ i ] << ( i * numBytes ) ); + + } + + headerSize = ( blocks + 3 ) * numBytes; + padding = ( ( headerSize % 3 ) > 0 ) ? 3 - ( headerSize % 3 ) : 0; + headerSize = headerSize + padding; + + dataOffsets = []; + currentOffset = headerSize; + dataOffsets.push( currentOffset ); + + // Get the blocks sizes after the compression. + // There are three blocks before c-size-i, so we skip 3*numBytes + cSizeStart = 3 * numBytes; + + for ( var i = 0; i < blocks; i ++ ) { + + var currentBlockSize = byteData[ i * numBytes + cSizeStart ]; + + for ( var j = 1; j < numBytes - 1; j ++ ) { + + // Each data point consists of 8 bytes regardless of the header type + currentBlockSize = currentBlockSize | ( byteData[ i * numBytes + cSizeStart + j ] << ( j * 8 ) ); + + } + + currentOffset = currentOffset + currentBlockSize; + dataOffsets.push( currentOffset ); + + } + + for ( var i = 0; i < dataOffsets.length - 1; i ++ ) { + + var inflate = new Zlib.Inflate( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ), { resize: true, verify: true } ); // eslint-disable-line no-undef + content = inflate.decompress(); + content = content.buffer; + + if ( ele.attributes.type === 'Float32' ) { + + content = new Float32Array( content ); + txt = Float32Concat( txt, content ); + + } else if ( ele.attributes.type === 'Int64' ) { + + content = new Int32Array( content ); + txt = Int32Concat( txt, content ); + + } + + } + + delete ele[ '#text' ]; + + if ( ele.attributes.type === 'Int64' ) { + + if ( ele.attributes.format === 'binary' ) { + + txt = txt.filter( function ( el, idx ) { + + if ( idx % 2 !== 1 ) return true; + + } ); + + } + + } + + } else { + + if ( ele.attributes.format === 'binary' && ! compressed ) { + + var content = Base64toByteArray( ele[ '#text' ] ); + + // VTP data for the uncompressed case has the following structure: + // [#bytes][DATA] + // where "[#bytes]" is an integer value specifying the number of bytes in the block of data following it. + content = content.slice( numBytes ).buffer; + + } else { + + if ( ele[ '#text' ] ) { + + var content = ele[ '#text' ].split( /\s+/ ).filter( function ( el ) { + + if ( el !== '' ) return el; + + } ); + + } else { + + var content = new Int32Array( 0 ).buffer; + + } + + } + + delete ele[ '#text' ]; + + // Get the content and optimize it + if ( ele.attributes.type === 'Float32' ) { + + var txt = new Float32Array( content ); + + } else if ( ele.attributes.type === 'Int32' ) { + + var txt = new Int32Array( content ); + + } else if ( ele.attributes.type === 'Int64' ) { + + var txt = new Int32Array( content ); + + if ( ele.attributes.format === 'binary' ) { + + txt = txt.filter( function ( el, idx ) { + + if ( idx % 2 !== 1 ) return true; + + } ); + + } + + } + + } // endif ( ele.attributes.format === 'binary' && compressed ) + + return txt; + + } + + // Main part + // Get Dom + var dom = null; + + if ( window.DOMParser ) { + + try { + + dom = ( new DOMParser() ).parseFromString( stringFile, 'text/xml' ); + + } catch ( e ) { + + dom = null; + + } + + } else if ( window.ActiveXObject ) { + + try { + + dom = new ActiveXObject( 'Microsoft.XMLDOM' ); // eslint-disable-line no-undef + dom.async = false; + + if ( ! dom.loadXML( /* xml */ ) ) { + + throw new Error( dom.parseError.reason + dom.parseError.srcText ); + + } + + } catch ( e ) { + + dom = null; + + } + + } else { + + throw new Error( 'Cannot parse xml string!' ); + + } + + // Get the doc + var doc = dom.documentElement; + // Convert to json + var json = xmlToJson( doc ); + var points = []; + var normals = []; + var indices = []; + + if ( json.PolyData ) { + + var piece = json.PolyData.Piece; + var compressed = json.attributes.hasOwnProperty( 'compressor' ); + + // Can be optimized + // Loop through the sections + var sections = [ 'PointData', 'Points', 'Strips', 'Polys' ];// +['CellData', 'Verts', 'Lines']; + var sectionIndex = 0, numberOfSections = sections.length; + + while ( sectionIndex < numberOfSections ) { + + var section = piece[ sections[ sectionIndex ] ]; + + // If it has a DataArray in it + + if ( section && section.DataArray ) { + + // Depending on the number of DataArrays + + if ( Object.prototype.toString.call( section.DataArray ) === '[object Array]' ) { + + var arr = section.DataArray; + + } else { + + var arr = [ section.DataArray ]; + + } + + var dataArrayIndex = 0, numberOfDataArrays = arr.length; + + while ( dataArrayIndex < numberOfDataArrays ) { + + // Parse the DataArray + if ( ( '#text' in arr[ dataArrayIndex ] ) && ( arr[ dataArrayIndex ][ '#text' ].length > 0 ) ) { + + arr[ dataArrayIndex ].text = parseDataArray( arr[ dataArrayIndex ], compressed ); + + } + + dataArrayIndex ++; + + } + + switch ( sections[ sectionIndex ] ) { + + // if iti is point data + case 'PointData': + + var numberOfPoints = parseInt( piece.attributes.NumberOfPoints ); + var normalsName = section.attributes.Normals; + + if ( numberOfPoints > 0 ) { + + for ( var i = 0, len = arr.length; i < len; i ++ ) { + + if ( normalsName === arr[ i ].attributes.Name ) { + + var components = arr[ i ].attributes.NumberOfComponents; + normals = new Float32Array( numberOfPoints * components ); + normals.set( arr[ i ].text, 0 ); + + } + + } + + } + + break; + + // if it is points + case 'Points': + + var numberOfPoints = parseInt( piece.attributes.NumberOfPoints ); + + if ( numberOfPoints > 0 ) { + + var components = section.DataArray.attributes.NumberOfComponents; + points = new Float32Array( numberOfPoints * components ); + points.set( section.DataArray.text, 0 ); + + } + + break; + + // if it is strips + case 'Strips': + + var numberOfStrips = parseInt( piece.attributes.NumberOfStrips ); + + if ( numberOfStrips > 0 ) { + + var connectivity = new Int32Array( section.DataArray[ 0 ].text.length ); + var offset = new Int32Array( section.DataArray[ 1 ].text.length ); + connectivity.set( section.DataArray[ 0 ].text, 0 ); + offset.set( section.DataArray[ 1 ].text, 0 ); + + var size = numberOfStrips + connectivity.length; + indices = new Uint32Array( 3 * size - 9 * numberOfStrips ); + + var indicesIndex = 0; + + for ( var i = 0, len = numberOfStrips; i < len; i ++ ) { + + var strip = []; + + for ( var s = 0, len1 = offset[ i ], len0 = 0; s < len1 - len0; s ++ ) { + + strip.push( connectivity[ s ] ); + + if ( i > 0 ) len0 = offset[ i - 1 ]; + + } + + for ( var j = 0, len1 = offset[ i ], len0 = 0; j < len1 - len0 - 2; j ++ ) { + + if ( j % 2 ) { + + indices[ indicesIndex ++ ] = strip[ j ]; + indices[ indicesIndex ++ ] = strip[ j + 2 ]; + indices[ indicesIndex ++ ] = strip[ j + 1 ]; + + } else { + + indices[ indicesIndex ++ ] = strip[ j ]; + indices[ indicesIndex ++ ] = strip[ j + 1 ]; + indices[ indicesIndex ++ ] = strip[ j + 2 ]; + + } + + if ( i > 0 ) len0 = offset[ i - 1 ]; + + } + + } + + } + + break; + + // if it is polys + case 'Polys': + + var numberOfPolys = parseInt( piece.attributes.NumberOfPolys ); + + if ( numberOfPolys > 0 ) { + + var connectivity = new Int32Array( section.DataArray[ 0 ].text.length ); + var offset = new Int32Array( section.DataArray[ 1 ].text.length ); + connectivity.set( section.DataArray[ 0 ].text, 0 ); + offset.set( section.DataArray[ 1 ].text, 0 ); + + var size = numberOfPolys + connectivity.length; + indices = new Uint32Array( 3 * size - 9 * numberOfPolys ); + var indicesIndex = 0, connectivityIndex = 0; + var i = 0, len = numberOfPolys, len0 = 0; + + while ( i < len ) { + + var poly = []; + var s = 0, len1 = offset[ i ]; + + while ( s < len1 - len0 ) { + + poly.push( connectivity[ connectivityIndex ++ ] ); + s ++; + + } + + var j = 1; + + while ( j < len1 - len0 - 1 ) { + + indices[ indicesIndex ++ ] = poly[ 0 ]; + indices[ indicesIndex ++ ] = poly[ j ]; + indices[ indicesIndex ++ ] = poly[ j + 1 ]; + j ++; + + } + + i ++; + len0 = offset[ i - 1 ]; + + } + + } + + break; + + default: + break; + + } + + } + + sectionIndex ++; + + } + + var geometry = new THREE.BufferGeometry(); + geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); + geometry.addAttribute( 'position', new THREE.BufferAttribute( points, 3 ) ); + + if ( normals.length === points.length ) { + + geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) ); + + } + + return geometry; + + } else { + + // TODO for vtu,vti,and other xml formats + + } + + } + + function getStringFile( data ) { + + var stringFile = ''; + var charArray = new Uint8Array( data ); + var i = 0; + var len = charArray.length; + + while ( len -- ) { + + stringFile += String.fromCharCode( charArray[ i ++ ] ); + + } + + return stringFile; + + } + + // get the 5 first lines of the files to check if there is the key word binary + var meta = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 250 ) ).split( '\n' ); + + if ( meta[ 0 ].indexOf( 'xml' ) !== - 1 ) { + + return parseXML( getStringFile( data ) ); + + } else if ( meta[ 2 ].includes( 'ASCII' ) ) { + + return parseASCII( getStringFile( data ) ); + + } else { + + return parseBinary( data ); + + } + + } + +} ); diff --git a/three/jsutil/loaders/XLoader.js b/three/jsutil/loaders/XLoader.js new file mode 100644 index 000000000..944aac2b0 --- /dev/null +++ b/three/jsutil/loaders/XLoader.js @@ -0,0 +1,1605 @@ +/** + * @author adrs2002 / https://github.com/adrs2002 + */ + + +( function ( global, factory ) { + + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define( factory ) : + ( global.THREE = global.THREE || {}, global.THREE.XLoader = factory() ); + +}( this, ( function () { + + 'use strict'; + + var classCallCheck = function ( instance, Constructor ) { + + if ( ! ( instance instanceof Constructor ) ) { + + throw new TypeError( "Cannot call a class as a function" ); + + } + + }; + + var createClass = function () { + + function defineProperties( target, props ) { + + for ( var i = 0; i < props.length; i ++ ) { + + var descriptor = props[ i ]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ( "value" in descriptor ) descriptor.writable = true; + Object.defineProperty( target, descriptor.key, descriptor ); + + } + + } + + return function ( Constructor, protoProps, staticProps ) { + + if ( protoProps ) defineProperties( Constructor.prototype, protoProps ); + if ( staticProps ) defineProperties( Constructor, staticProps ); + return Constructor; + + }; + + }(); + + var XboneInf = function XboneInf() { + + classCallCheck( this, XboneInf ); + + this.boneName = ""; + this.BoneIndex = 0; + this.Indeces = []; + this.Weights = []; + this.initMatrix = null; + this.OffsetMatrix = null; + + }; + + var XAnimationInfo = function XAnimationInfo() { + + classCallCheck( this, XAnimationInfo ); + + this.animeName = ""; + this.boneName = ""; + this.targetBone = null; + this.keyType = 4; + this.frameStartLv = 0; + this.keyFrames = []; + this.InverseMx = null; + + }; + + var XAnimationObj = function () { + + function XAnimationObj( _flags ) { + + classCallCheck( this, XAnimationObj ); + + this.fps = 30; + this.name = 'xanimation'; + this.length = 0; + this.hierarchy = []; + this.putFlags = _flags; + if ( this.putFlags.putPos === undefined ) { + + this.putFlags.putPos = true; + + } + if ( this.putFlags.putRot === undefined ) { + + this.putFlags.putRot = true; + + } + if ( this.putFlags.putScl === undefined ) { + + this.putFlags.putScl = true; + + } + + } + + createClass( XAnimationObj, [ { + key: "make", + value: function make( XAnimationInfoArray ) { + + for ( var i = 0; i < XAnimationInfoArray.length; i ++ ) { + + this.hierarchy.push( this.makeBonekeys( XAnimationInfoArray[ i ] ) ); + + } + this.length = this.hierarchy[ 0 ].keys[ this.hierarchy[ 0 ].keys.length - 1 ].time; + + } + }, { + key: "clone", + value: function clone() { + + return Object.assign( {}, this ); + + } + }, { + key: "makeBonekeys", + value: function makeBonekeys( XAnimationInfo ) { + + var refObj = {}; + refObj.name = XAnimationInfo.boneName; + refObj.parent = ""; + refObj.keys = this.keyFrameRefactor( XAnimationInfo ); + refObj.copy = function () { + + return Object.assign( {}, this ); + + }; + return refObj; + + } + }, { + key: "keyFrameRefactor", + value: function keyFrameRefactor( XAnimationInfo ) { + + var keys = []; + for ( var i = 0; i < XAnimationInfo.keyFrames.length; i ++ ) { + + var keyframe = {}; + keyframe.time = XAnimationInfo.keyFrames[ i ].time * this.fps; + if ( XAnimationInfo.keyFrames[ i ].pos && this.putFlags.putPos ) { + + keyframe.pos = XAnimationInfo.keyFrames[ i ].pos; + + } + if ( XAnimationInfo.keyFrames[ i ].rot && this.putFlags.putRot ) { + + keyframe.rot = XAnimationInfo.keyFrames[ i ].rot; + + } + if ( XAnimationInfo.keyFrames[ i ].scl && this.putFlags.putScl ) { + + keyframe.scl = XAnimationInfo.keyFrames[ i ].scl; + + } + if ( XAnimationInfo.keyFrames[ i ].matrix ) { + + keyframe.matrix = XAnimationInfo.keyFrames[ i ].matrix; + if ( this.putFlags.putPos ) { + + keyframe.pos = new THREE.Vector3().setFromMatrixPosition( keyframe.matrix ); + + } + if ( this.putFlags.putRot ) { + + keyframe.rot = new THREE.Quaternion().setFromRotationMatrix( keyframe.matrix ); + + } + if ( this.putFlags.putScl ) { + + keyframe.scl = new THREE.Vector3().setFromMatrixScale( keyframe.matrix ); + + } + + } + keys.push( keyframe ); + + } + return keys; + + } + } ] ); + return XAnimationObj; + + }(); + + var XKeyFrameInfo = function XKeyFrameInfo() { + + classCallCheck( this, XKeyFrameInfo ); + + this.index = 0; + this.Frame = 0; + this.time = 0.0; + this.matrix = null; + + }; + + var XLoader = function () { + + function XLoader( manager ) { + + classCallCheck( this, XLoader ); + + this.debug = false; + this.manager = manager !== undefined ? manager : new THREE.DefaultLoadingManager(); + this.texloader = new THREE.TextureLoader( this.manager ); + this.url = ""; + this.baseDir = ""; + this._putMatLength = 0; + this._nowMat = null; + this._nowFrameName = ""; + this.frameHierarchie = []; + this.Hierarchies = {}; + this.HieStack = []; + this._currentObject = {}; + this._currentFrame = {}; + this._data = null; + this.onLoad = null; + this.IsUvYReverse = true; + this.Meshes = []; + this.animations = []; + this.animTicksPerSecond = 30; + this._currentGeo = null; + this._currentAnime = null; + this._currentAnimeFrames = null; + + } + + createClass( XLoader, [ { + key: '_setArgOption', + value: function _setArgOption( _arg ) { + + var _start = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : 0; + + if ( ! _arg ) { + + return; + + } + for ( var i = _start; i < _arg.length; i ++ ) { + + switch ( i ) { + + case 0: + this.url = _arg[ i ]; + break; + case 1: + this.options = _arg[ i ]; + break; + + } + + } + if ( this.options === undefined ) { + + this.options = {}; + + } + + } + }, { + key: 'load', + value: function load( _arg, onLoad, onProgress, onError ) { + + var _this = this; + + this._setArgOption( _arg ); + var loader = new THREE.FileLoader( this.manager ); + loader.setResponseType( 'arraybuffer' ); + loader.load( this.url, function ( response ) { + + _this._parse( response, onLoad ); + + }, onProgress, onError ); + + } + }, { + key: 'fromResponsedData', + value: function fromResponsedData( _data, _arg, onLoad ) { + + this._setArgOption( _arg ); + this._parse( _data, onLoad ); + + } + }, { + key: '_readLine', + value: function _readLine( line ) { + + var readed = 0; + while ( true ) { + + var find = - 1; + find = line.indexOf( '//', readed ); + if ( find === - 1 ) { + + find = line.indexOf( '#', readed ); + + } + if ( find > - 1 && find < 2 ) { + + var foundNewLine = - 1; + foundNewLine = line.indexOf( "\r\n", readed ); + if ( foundNewLine > 0 ) { + + readed = foundNewLine + 2; + + } else { + + foundNewLine = line.indexOf( "\r", readed ); + if ( foundNewLine > 0 ) { + + readed = foundNewLine + 1; + + } else { + + readed = line.indexOf( "\n", readed ) + 1; + + } + + } + + } else { + + break; + + } + + } + return line.substr( readed ); + + } + }, { + key: '_readLine', + value: function _readLine( line ) { + + var readed = 0; + while ( true ) { + + var find = - 1; + find = line.indexOf( '//', readed ); + if ( find === - 1 ) { + + find = line.indexOf( '#', readed ); + + } + if ( find > - 1 && find < 2 ) { + + var foundNewLine = - 1; + foundNewLine = line.indexOf( "\r\n", readed ); + if ( foundNewLine > 0 ) { + + readed = foundNewLine + 2; + + } else { + + foundNewLine = line.indexOf( "\r", readed ); + if ( foundNewLine > 0 ) { + + readed = foundNewLine + 1; + + } else { + + readed = line.indexOf( "\n", readed ) + 1; + + } + + } + + } else { + + break; + + } + + } + return line.substr( readed ); + + } + }, { + key: '_isBinary', + value: function _isBinary( binData ) { + + var reader = new DataView( binData ); + var face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8; + var n_faces = reader.getUint32( 80, true ); + var expect = 80 + 32 / 8 + n_faces * face_size; + if ( expect === reader.byteLength ) { + + return true; + + } + var fileLength = reader.byteLength; + for ( var index = 0; index < fileLength; index ++ ) { + + if ( reader.getUint8( index, false ) > 127 ) { + + return true; + + } + + } + return false; + + } + }, { + key: 'ensureBinary', + value: function ensureBinary( buf ) { + + if ( typeof buf === "string" ) { + + var array_buffer = new Uint8Array( buf.length ); + for ( var i = 0; i < buf.length; i ++ ) { + + array_buffer[ i ] = buf.charCodeAt( i ) & 0xff; + + } + return array_buffer.buffer || array_buffer; + + } else { + + return buf; + + } + + } + }, { + key: 'ensureString', + value: function ensureString( buf ) { + + if ( typeof buf !== "string" ) { + + return THREE.LoaderUtils.decodeText( new Uint8Array( buf ) ); + + } else { + + return buf; + + } + + } + }, { + key: '_parse', + value: function _parse( data, onLoad ) { + + var binData = this.ensureBinary( data ); + this._data = this.ensureString( data ); + this.onLoad = onLoad; + return this._isBinary( binData ) ? this._parseBinary( binData ) : this._parseASCII(); + + } + }, { + key: '_parseBinary', + value: function _parseBinary( data ) { + + return this._parseASCII( THREE.LoaderUtils.decodeText( new Uint8Array( data ) ) ); + + } + }, { + key: '_parseASCII', + value: function _parseASCII() { + + if ( this.url.lastIndexOf( "/" ) > 0 ) { + + this.baseDir = this.url.substr( 0, this.url.lastIndexOf( "/" ) + 1 ); + + } + var endRead = 16; + this.Hierarchies.children = []; + this._hierarchieParse( this.Hierarchies, endRead ); + this._changeRoot(); + this._currentObject = this.Hierarchies.children.shift(); + this.mainloop(); + + } + }, { + key: '_hierarchieParse', + value: function _hierarchieParse( _parent, _end ) { + + var endRead = _end; + while ( true ) { + + var find1 = this._data.indexOf( '{', endRead ) + 1; + var findEnd = this._data.indexOf( '}', endRead ); + var findNext = this._data.indexOf( '{', find1 ) + 1; + if ( find1 > 0 && findEnd > find1 ) { + + var _currentObject = {}; + _currentObject.children = []; + var nameData = this._readLine( this._data.substr( endRead, find1 - endRead - 1 ) ).trim(); + var word = nameData.split( / /g ); + if ( word.length > 0 ) { + + _currentObject.type = word[ 0 ]; + if ( word.length >= 2 ) { + + _currentObject.name = word[ 1 ]; + + } else { + + _currentObject.name = word[ 0 ] + this.Hierarchies.children.length; + + } + + } else { + + _currentObject.name = nameData; + _currentObject.type = ""; + + } + if ( _currentObject.type === "Animation" ) { + + _currentObject.data = this._data.substr( findNext, findEnd - findNext ).trim(); + var refs = this._hierarchieParse( _currentObject, findEnd + 1 ); + endRead = refs.end; + _currentObject.children = refs.parent.children; + + } else { + + var DataEnder = this._data.lastIndexOf( ';', findNext > 0 ? Math.min( findNext, findEnd ) : findEnd ); + _currentObject.data = this._data.substr( find1, DataEnder - find1 ).trim(); + if ( findNext <= 0 || findEnd < findNext ) { + + endRead = findEnd + 1; + + } else { + + var nextStart = Math.max( DataEnder + 1, find1 ); + var _refs = this._hierarchieParse( _currentObject, nextStart ); + endRead = _refs.end; + _currentObject.children = _refs.parent.children; + + } + + } + _currentObject.parent = _parent; + if ( _currentObject.type != "template" ) { + + _parent.children.push( _currentObject ); + + } + + } else { + + endRead = find1 === - 1 ? this._data.length : findEnd + 1; + break; + + } + + } + return { + parent: _parent, + end: endRead + }; + + } + }, { + key: 'mainloop', + value: function mainloop() { + + var _this2 = this; + + this.mainProc(); + if ( this._currentObject.parent || this._currentObject.children.length > 0 || ! this._currentObject.worked ) { + + setTimeout( function () { + + _this2.mainloop(); + + }, 1 ); + + } else { + + setTimeout( function () { + + _this2.onLoad( { + models: _this2.Meshes, + animations: _this2.animations + } ); + + }, 1 ); + + } + + } + }, { + key: 'mainProc', + value: function mainProc() { + + var breakFlag = false; + while ( true ) { + + if ( ! this._currentObject.worked ) { + + switch ( this._currentObject.type ) { + + case "template": + break; + case "AnimTicksPerSecond": + this.animTicksPerSecond = parseInt( this._currentObject.data ); + break; + case "Frame": + this._setFrame(); + break; + case "FrameTransformMatrix": + this._setFrameTransformMatrix(); + break; + case "Mesh": + this._changeRoot(); + this._currentGeo = {}; + this._currentGeo.name = this._currentObject.name.trim(); + this._currentGeo.parentName = this._getParentName( this._currentObject ).trim(); + this._currentGeo.VertexSetedBoneCount = []; + this._currentGeo.GeometryData = { + vertices: [], + normals: [], + uvs: [], + skinIndices: [], + skinWeights: [], + indices: [], + materialIndices: [] + }; + this._currentGeo.Materials = []; + this._currentGeo.normalVectors = []; + this._currentGeo.BoneInfs = []; + this._currentGeo.baseFrame = this._currentFrame; + this._makeBoneFrom_CurrentFrame(); + this._readVertexDatas(); + breakFlag = true; + break; + case "MeshNormals": + this._readVertexDatas(); + break; + case "MeshTextureCoords": + this._setMeshTextureCoords(); + break; + case "VertexDuplicationIndices": + break; + case "MeshMaterialList": + this._setMeshMaterialList(); + break; + case "Material": + this._setMaterial(); + break; + case "SkinWeights": + this._setSkinWeights(); + break; + case "AnimationSet": + this._changeRoot(); + this._currentAnime = {}; + this._currentAnime.name = this._currentObject.name.trim(); + this._currentAnime.AnimeFrames = []; + break; + case "Animation": + if ( this._currentAnimeFrames ) { + + this._currentAnime.AnimeFrames.push( this._currentAnimeFrames ); + + } + this._currentAnimeFrames = new XAnimationInfo(); + this._currentAnimeFrames.boneName = this._currentObject.data.trim(); + break; + case "AnimationKey": + this._readAnimationKey(); + breakFlag = true; + break; + + } + this._currentObject.worked = true; + + } + if ( this._currentObject.children.length > 0 ) { + + this._currentObject = this._currentObject.children.shift(); + if ( this.debug ) { + + console.log( 'processing ' + this._currentObject.name ); + + } + if ( breakFlag ) break; + + } else { + + if ( this._currentObject.worked ) { + + if ( this._currentObject.parent && ! this._currentObject.parent.parent ) { + + this._changeRoot(); + + } + + } + if ( this._currentObject.parent ) { + + this._currentObject = this._currentObject.parent; + + } else { + + breakFlag = true; + + } + if ( breakFlag ) break; + + } + + } + return; + + } + }, { + key: '_changeRoot', + value: function _changeRoot() { + + if ( this._currentGeo != null && this._currentGeo.name ) { + + this._makeOutputGeometry(); + + } + this._currentGeo = {}; + if ( this._currentAnime != null && this._currentAnime.name ) { + + if ( this._currentAnimeFrames ) { + + this._currentAnime.AnimeFrames.push( this._currentAnimeFrames ); + this._currentAnimeFrames = null; + + } + this._makeOutputAnimation(); + + } + this._currentAnime = {}; + + } + }, { + key: '_getParentName', + value: function _getParentName( _obj ) { + + if ( _obj.parent ) { + + if ( _obj.parent.name ) { + + return _obj.parent.name; + + } else { + + return this._getParentName( _obj.parent ); + + } + + } else { + + return ""; + + } + + } + }, { + key: '_setFrame', + value: function _setFrame() { + + this._nowFrameName = this._currentObject.name.trim(); + this._currentFrame = {}; + this._currentFrame.name = this._nowFrameName; + this._currentFrame.children = []; + if ( this._currentObject.parent && this._currentObject.parent.name ) { + + this._currentFrame.parentName = this._currentObject.parent.name; + + } + this.frameHierarchie.push( this._nowFrameName ); + this.HieStack[ this._nowFrameName ] = this._currentFrame; + + } + }, { + key: '_setFrameTransformMatrix', + value: function _setFrameTransformMatrix() { + + this._currentFrame.FrameTransformMatrix = new THREE.Matrix4(); + var data = this._currentObject.data.split( "," ); + this._ParseMatrixData( this._currentFrame.FrameTransformMatrix, data ); + this._makeBoneFrom_CurrentFrame(); + + } + }, { + key: '_makeBoneFrom_CurrentFrame', + value: function _makeBoneFrom_CurrentFrame() { + + if ( ! this._currentFrame.FrameTransformMatrix ) { + + return; + + } + var b = new THREE.Bone(); + b.name = this._currentFrame.name; + b.applyMatrix( this._currentFrame.FrameTransformMatrix ); + b.matrixWorld = b.matrix; + b.FrameTransformMatrix = this._currentFrame.FrameTransformMatrix; + this._currentFrame.putBone = b; + if ( this._currentFrame.parentName ) { + + for ( var frame in this.HieStack ) { + + if ( this.HieStack[ frame ].name === this._currentFrame.parentName ) { + + this.HieStack[ frame ].putBone.add( this._currentFrame.putBone ); + + } + + } + + } + + } + }, { + key: '_readVertexDatas', + value: function _readVertexDatas() { + + var endRead = 0; + var mode = 0; + var mode_local = 0; + var maxLength = 0; + while ( true ) { + + var changeMode = false; + if ( mode_local === 0 ) { + + var refO = this._readInt1( endRead ); + endRead = refO.endRead; + mode_local = 1; + maxLength = this._currentObject.data.indexOf( ';;', endRead ) + 1; + if ( maxLength <= 0 ) { + + maxLength = this._currentObject.data.length; + + } + + } else { + + var find = 0; + switch ( mode ) { + + case 0: + find = this._currentObject.data.indexOf( ',', endRead ) + 1; + break; + case 1: + find = this._currentObject.data.indexOf( ';,', endRead ) + 1; + break; + + } + if ( find === 0 || find > maxLength ) { + + find = maxLength; + mode_local = 0; + changeMode = true; + + } + switch ( this._currentObject.type ) { + + case "Mesh": + switch ( mode ) { + + case 0: + this._readVertex1( this._currentObject.data.substr( endRead, find - endRead ) ); + break; + case 1: + this._readFace1( this._currentObject.data.substr( endRead, find - endRead ) ); + break; + + } + break; + case "MeshNormals": + switch ( mode ) { + + case 0: + this._readNormalVector1( this._currentObject.data.substr( endRead, find - endRead ) ); + break; + + } + break; + + } + endRead = find + 1; + if ( changeMode ) { + + mode ++; + + } + + } + if ( endRead >= this._currentObject.data.length ) { + + break; + + } + + } + + } + }, { + key: '_readInt1', + value: function _readInt1( start ) { + + var find = this._currentObject.data.indexOf( ';', start ); + return { + refI: parseInt( this._currentObject.data.substr( start, find - start ) ), + endRead: find + 1 + }; + + } + }, { + key: '_readVertex1', + value: function _readVertex1( line ) { + + var data = this._readLine( line.trim() ).substr( 0, line.length - 2 ).split( ";" ); + this._currentGeo.GeometryData.vertices.push( parseFloat( data[ 0 ] ), parseFloat( data[ 1 ] ), parseFloat( data[ 2 ] ) ); + this._currentGeo.GeometryData.skinIndices.push( 0, 0, 0, 0 ); + this._currentGeo.GeometryData.skinWeights.push( 1, 0, 0, 0 ); + this._currentGeo.VertexSetedBoneCount.push( 0 ); + + } + }, { + key: '_readFace1', + value: function _readFace1( line ) { + + var data = this._readLine( line.trim() ).substr( 2, line.length - 4 ).split( "," ); + this._currentGeo.GeometryData.indices.push( parseInt( data[ 0 ], 10 ), parseInt( data[ 1 ], 10 ), parseInt( data[ 2 ], 10 ) ); + + } + }, { + key: '_readNormalVector1', + value: function _readNormalVector1( line ) { + + var data = this._readLine( line.trim() ).substr( 0, line.length - 2 ).split( ";" ); + this._currentGeo.GeometryData.normals.push( parseFloat( data[ 0 ] ), parseFloat( data[ 1 ] ), parseFloat( data[ 2 ] ) ); + + } + }, { + key: '_buildGeometry', + value: function _buildGeometry() { + + var bufferGeometry = new THREE.BufferGeometry(); + var position = []; + var normals = []; + var uvs = []; + var skinIndices = []; + var skinWeights = []; + + // + + var data = this._currentGeo.GeometryData; + + for ( var i = 0, l = data.indices.length; i < l; i ++ ) { + + var stride2 = data.indices[ i ] * 2; + var stride3 = data.indices[ i ] * 3; + var stride4 = data.indices[ i ] * 4; + + position.push( data.vertices[ stride3 ], data.vertices[ stride3 + 1 ], data.vertices[ stride3 + 2 ] ); + normals.push( data.normals[ stride3 ], data.normals[ stride3 + 1 ], data.normals[ stride3 + 2 ] ); + skinIndices.push( data.skinIndices[ stride4 ], data.skinIndices[ stride4 + 1 ], data.skinIndices[ stride4 + 2 ], data.skinIndices[ stride4 + 3 ] ); + skinWeights.push( data.skinWeights[ stride4 ], data.skinWeights[ stride4 + 1 ], data.skinWeights[ stride4 + 2 ], data.skinWeights[ stride4 + 3 ] ); + uvs.push( data.uvs[ stride2 ], data.uvs[ stride2 + 1 ] ); + + } + + // + + bufferGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) ); + bufferGeometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + bufferGeometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); + bufferGeometry.addAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( skinIndices, 4 ) ); + bufferGeometry.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeights, 4 ) ); + + this._computeGroups( bufferGeometry, data.materialIndices ); + + return bufferGeometry; + + } + }, { + key: '_computeGroups', + value: function _computeGroups( bufferGeometry, materialIndices ) { + + var group; + var groups = []; + var materialIndex = undefined; + + for ( var i = 0; i < materialIndices.length; i ++ ) { + + var currentMaterialIndex = materialIndices[ i ]; + + if ( currentMaterialIndex !== materialIndex ) { + + materialIndex = currentMaterialIndex; + + if ( group !== undefined ) { + + group.count = ( i * 3 ) - group.start; + groups.push( group ); + + } + + group = { + start: i * 3, + materialIndex: materialIndex + }; + + } + + } + + if ( group !== undefined ) { + + group.count = ( i * 3 ) - group.start; + groups.push( group ); + + } + + bufferGeometry.groups = groups; + + } + }, { + key: '_setMeshTextureCoords', + value: function _setMeshTextureCoords() { + + var endRead = 0; + var mode = 0; + var mode_local = 0; + while ( true ) { + + switch ( mode ) { + + case 0: + if ( mode_local === 0 ) { + + var refO = this._readInt1( 0 ); + endRead = refO.endRead; + mode_local = 1; + + } else { + + var find = this._currentObject.data.indexOf( ',', endRead ) + 1; + if ( find === 0 ) { + + find = this._currentObject.data.length; + mode = 2; + mode_local = 0; + + } + var line = this._currentObject.data.substr( endRead, find - endRead ); + var data = this._readLine( line.trim() ).split( ";" ); + if ( this.IsUvYReverse ) { + + this._currentGeo.GeometryData.uvs.push( parseFloat( data[ 0 ] ), 1 - parseFloat( data[ 1 ] ) ); + + } else { + + this._currentGeo.GeometryData.uvs.push( parseFloat( data[ 0 ] ), parseFloat( data[ 1 ] ) ); + + } + endRead = find + 1; + + } + break; + + } + if ( endRead >= this._currentObject.data.length ) { + + break; + + } + + } + + } + }, { + key: '_setMeshMaterialList', + value: function _setMeshMaterialList() { + + var endRead = 0; + var mode = 0; + var mode_local = 0; + while ( true ) { + + if ( mode_local < 2 ) { + + var refO = this._readInt1( endRead ); + endRead = refO.endRead; + mode_local ++; + + } else { + + var find = this._currentObject.data.indexOf( ';', endRead ); + if ( find === - 1 ) { + + find = this._currentObject.data.length; + mode = 3; + mode_local = 0; + + } + var line = this._currentObject.data.substr( endRead, find - endRead ); + var data = this._readLine( line.trim() ).split( "," ); + for ( var i = 0; i < data.length; i ++ ) { + + this._currentGeo.GeometryData.materialIndices[ i ] = parseInt( data[ i ] ); + + } + endRead = this._currentObject.data.length; + + } + if ( endRead >= this._currentObject.data.length || mode >= 3 ) { + + break; + + } + + } + + } + }, { + key: '_setMaterial', + value: function _setMaterial() { + + var _nowMat = new THREE.MeshPhongMaterial( { + color: Math.random() * 0xffffff + } ); + _nowMat.side = THREE.FrontSide; + _nowMat.name = this._currentObject.name; + var endRead = 0; + var find = this._currentObject.data.indexOf( ';;', endRead ); + var line = this._currentObject.data.substr( endRead, find - endRead ); + var data = this._readLine( line.trim() ).split( ";" ); + _nowMat.color.r = parseFloat( data[ 0 ] ); + _nowMat.color.g = parseFloat( data[ 1 ] ); + _nowMat.color.b = parseFloat( data[ 2 ] ); + endRead = find + 2; + find = this._currentObject.data.indexOf( ';', endRead ); + line = this._currentObject.data.substr( endRead, find - endRead ); + _nowMat.shininess = parseFloat( this._readLine( line ) ); + endRead = find + 1; + find = this._currentObject.data.indexOf( ';;', endRead ); + line = this._currentObject.data.substr( endRead, find - endRead ); + var data2 = this._readLine( line.trim() ).split( ";" ); + _nowMat.specular.r = parseFloat( data2[ 0 ] ); + _nowMat.specular.g = parseFloat( data2[ 1 ] ); + _nowMat.specular.b = parseFloat( data2[ 2 ] ); + endRead = find + 2; + find = this._currentObject.data.indexOf( ';;', endRead ); + if ( find === - 1 ) { + + find = this._currentObject.data.length; + + } + line = this._currentObject.data.substr( endRead, find - endRead ); + var data3 = this._readLine( line.trim() ).split( ";" ); + _nowMat.emissive.r = parseFloat( data3[ 0 ] ); + _nowMat.emissive.g = parseFloat( data3[ 1 ] ); + _nowMat.emissive.b = parseFloat( data3[ 2 ] ); + var localObject = null; + while ( true ) { + + if ( this._currentObject.children.length > 0 ) { + + localObject = this._currentObject.children.shift(); + if ( this.debug ) { + + console.log( 'processing ' + localObject.name ); + + } + var fileName = localObject.data.substr( 1, localObject.data.length - 2 ); + switch ( localObject.type ) { + + case "TextureFilename": + _nowMat.map = this.texloader.load( this.baseDir + fileName ); + break; + case "BumpMapFilename": + _nowMat.bumpMap = this.texloader.load( this.baseDir + fileName ); + _nowMat.bumpScale = 0.05; + break; + case "NormalMapFilename": + _nowMat.normalMap = this.texloader.load( this.baseDir + fileName ); + _nowMat.normalScale = new THREE.Vector2( 2, 2 ); + break; + case "EmissiveMapFilename": + _nowMat.emissiveMap = this.texloader.load( this.baseDir + fileName ); + break; + case "LightMapFilename": + _nowMat.lightMap = this.texloader.load( this.baseDir + fileName ); + break; + + } + + } else { + + break; + + } + + } + this._currentGeo.Materials.push( _nowMat ); + + } + }, { + key: '_setSkinWeights', + value: function _setSkinWeights() { + + var boneInf = new XboneInf(); + var endRead = 0; + var find = this._currentObject.data.indexOf( ';', endRead ); + var line = this._currentObject.data.substr( endRead, find - endRead ); + endRead = find + 1; + boneInf.boneName = line.substr( 1, line.length - 2 ); + boneInf.BoneIndex = this._currentGeo.BoneInfs.length; + find = this._currentObject.data.indexOf( ';', endRead ); + endRead = find + 1; + find = this._currentObject.data.indexOf( ';', endRead ); + line = this._currentObject.data.substr( endRead, find - endRead ); + var data = this._readLine( line.trim() ).split( "," ); + for ( var i = 0; i < data.length; i ++ ) { + + boneInf.Indeces.push( parseInt( data[ i ] ) ); + + } + endRead = find + 1; + find = this._currentObject.data.indexOf( ';', endRead ); + line = this._currentObject.data.substr( endRead, find - endRead ); + var data2 = this._readLine( line.trim() ).split( "," ); + for ( var _i = 0; _i < data2.length; _i ++ ) { + + boneInf.Weights.push( parseFloat( data2[ _i ] ) ); + + } + endRead = find + 1; + find = this._currentObject.data.indexOf( ';', endRead ); + if ( find <= 0 ) { + + find = this._currentObject.data.length; + + } + line = this._currentObject.data.substr( endRead, find - endRead ); + var data3 = this._readLine( line.trim() ).split( "," ); + boneInf.OffsetMatrix = new THREE.Matrix4(); + this._ParseMatrixData( boneInf.OffsetMatrix, data3 ); + this._currentGeo.BoneInfs.push( boneInf ); + + } + }, { + key: '_makePutBoneList', + value: function _makePutBoneList( _RootName, _bones ) { + + var putting = false; + for ( var frame in this.HieStack ) { + + if ( this.HieStack[ frame ].name === _RootName || putting ) { + + putting = true; + var b = new THREE.Bone(); + b.name = this.HieStack[ frame ].name; + b.applyMatrix( this.HieStack[ frame ].FrameTransformMatrix ); + b.matrixWorld = b.matrix; + b.FrameTransformMatrix = this.HieStack[ frame ].FrameTransformMatrix; + b.pos = new THREE.Vector3().setFromMatrixPosition( b.FrameTransformMatrix ).toArray(); + b.rotq = new THREE.Quaternion().setFromRotationMatrix( b.FrameTransformMatrix ).toArray(); + b.scl = new THREE.Vector3().setFromMatrixScale( b.FrameTransformMatrix ).toArray(); + if ( this.HieStack[ frame ].parentName && this.HieStack[ frame ].parentName.length > 0 ) { + + for ( var i = 0; i < _bones.length; i ++ ) { + + if ( this.HieStack[ frame ].parentName === _bones[ i ].name ) { + + _bones[ i ].add( b ); + b.parent = i; + break; + + } + + } + + } + _bones.push( b ); + + } + + } + + } + }, { + key: '_makeOutputGeometry', + value: function _makeOutputGeometry() { + + var mesh = null; + if ( this._currentGeo.BoneInfs.length > 0 ) { + + var putBones = []; + this._makePutBoneList( this._currentGeo.baseFrame.parentName, putBones ); + for ( var bi = 0; bi < this._currentGeo.BoneInfs.length; bi ++ ) { + + var boneIndex = 0; + for ( var bb = 0; bb < putBones.length; bb ++ ) { + + if ( putBones[ bb ].name === this._currentGeo.BoneInfs[ bi ].boneName ) { + + boneIndex = bb; + putBones[ bb ].OffsetMatrix = new THREE.Matrix4(); + putBones[ bb ].OffsetMatrix.copy( this._currentGeo.BoneInfs[ bi ].OffsetMatrix ); + break; + + } + + } + for ( var vi = 0; vi < this._currentGeo.BoneInfs[ bi ].Indeces.length; vi ++ ) { + + var nowVertexID = this._currentGeo.BoneInfs[ bi ].Indeces[ vi ]; + var nowVal = this._currentGeo.BoneInfs[ bi ].Weights[ vi ]; + + var stride = nowVertexID * 4; + + switch ( this._currentGeo.VertexSetedBoneCount[ nowVertexID ] ) { + + case 0: + this._currentGeo.GeometryData.skinIndices[ stride ] = boneIndex; + this._currentGeo.GeometryData.skinWeights[ stride ] = nowVal; + break; + case 1: + this._currentGeo.GeometryData.skinIndices[ stride + 1 ] = boneIndex; + this._currentGeo.GeometryData.skinWeights[ stride + 1 ] = nowVal; + break; + case 2: + this._currentGeo.GeometryData.skinIndices[ stride + 2 ] = boneIndex; + this._currentGeo.GeometryData.skinWeights[ stride + 2 ] = nowVal; + break; + case 3: + this._currentGeo.GeometryData.skinIndices[ stride + 3 ] = boneIndex; + this._currentGeo.GeometryData.skinWeights[ stride + 3 ] = nowVal; + break; + + } + this._currentGeo.VertexSetedBoneCount[ nowVertexID ] ++; + if ( this._currentGeo.VertexSetedBoneCount[ nowVertexID ] > 4 ) { + + console.log( 'warn! over 4 bone weight! :' + nowVertexID ); + + } + + } + + } + for ( var sk = 0; sk < this._currentGeo.Materials.length; sk ++ ) { + + this._currentGeo.Materials[ sk ].skinning = true; + + } + var offsetList = []; + for ( var _bi = 0; _bi < putBones.length; _bi ++ ) { + + if ( putBones[ _bi ].OffsetMatrix ) { + + offsetList.push( putBones[ _bi ].OffsetMatrix ); + + } else { + + offsetList.push( new THREE.Matrix4() ); + + } + + } + + var bufferGeometry = this._buildGeometry(); + bufferGeometry.bones = putBones; + mesh = new THREE.SkinnedMesh( bufferGeometry, this._currentGeo.Materials.length === 1 ? this._currentGeo.Materials[ 0 ] : this._currentGeo.Materials ); + mesh.skeleton.boneInverses = offsetList; + + } else { + + var _bufferGeometry = this._buildGeometry(); + mesh = new THREE.Mesh( _bufferGeometry, this._currentGeo.Materials.length === 1 ? this._currentGeo.Materials[ 0 ] : this._currentGeo.Materials ); + + } + mesh.name = this._currentGeo.name; + var worldBaseMx = new THREE.Matrix4(); + var currentMxFrame = this._currentGeo.baseFrame.putBone; + if ( currentMxFrame && currentMxFrame.parent ) { + + while ( true ) { + + currentMxFrame = currentMxFrame.parent; + if ( currentMxFrame ) { + + worldBaseMx.multiply( currentMxFrame.FrameTransformMatrix ); + + } else { + + break; + + } + + } + mesh.applyMatrix( worldBaseMx ); + + } + this.Meshes.push( mesh ); + + } + }, { + key: '_readAnimationKey', + value: function _readAnimationKey() { + + var endRead = 0; + var find = this._currentObject.data.indexOf( ';', endRead ); + var line = this._currentObject.data.substr( endRead, find - endRead ); + endRead = find + 1; + var nowKeyType = parseInt( this._readLine( line ) ); + find = this._currentObject.data.indexOf( ';', endRead ); + endRead = find + 1; + line = this._currentObject.data.substr( endRead ); + var data = this._readLine( line.trim() ).split( ";;," ); + for ( var i = 0; i < data.length; i ++ ) { + + var data2 = data[ i ].split( ";" ); + var keyInfo = new XKeyFrameInfo(); + keyInfo.type = nowKeyType; + keyInfo.Frame = parseInt( data2[ 0 ] ); + keyInfo.index = this._currentAnimeFrames.keyFrames.length; + keyInfo.time = keyInfo.Frame; + if ( nowKeyType != 4 ) { + + var frameFound = false; + for ( var mm = 0; mm < this._currentAnimeFrames.keyFrames.length; mm ++ ) { + + if ( this._currentAnimeFrames.keyFrames[ mm ].Frame === keyInfo.Frame ) { + + keyInfo = this._currentAnimeFrames.keyFrames[ mm ]; + frameFound = true; + break; + + } + + } + var frameValue = data2[ 2 ].split( "," ); + switch ( nowKeyType ) { + + case 0: + keyInfo.rot = new THREE.Quaternion( parseFloat( frameValue[ 1 ] ), parseFloat( frameValue[ 2 ] ), parseFloat( frameValue[ 3 ] ), parseFloat( frameValue[ 0 ] ) * - 1 ); + break; + case 1: + keyInfo.scl = new THREE.Vector3( parseFloat( frameValue[ 0 ] ), parseFloat( frameValue[ 1 ] ), parseFloat( frameValue[ 2 ] ) ); + break; + case 2: + keyInfo.pos = new THREE.Vector3( parseFloat( frameValue[ 0 ] ), parseFloat( frameValue[ 1 ] ), parseFloat( frameValue[ 2 ] ) ); + break; + + } + if ( ! frameFound ) { + + this._currentAnimeFrames.keyFrames.push( keyInfo ); + + } + + } else { + + keyInfo.matrix = new THREE.Matrix4(); + this._ParseMatrixData( keyInfo.matrix, data2[ 2 ].split( "," ) ); + this._currentAnimeFrames.keyFrames.push( keyInfo ); + + } + + } + + } + }, { + key: '_makeOutputAnimation', + value: function _makeOutputAnimation() { + + var animationObj = new XAnimationObj( this.options ); + animationObj.fps = this.animTicksPerSecond; + animationObj.name = this._currentAnime.name; + animationObj.make( this._currentAnime.AnimeFrames ); + this.animations.push( animationObj ); + + } + }, { + key: 'assignAnimation', + value: function assignAnimation( _model, _animation, _isBind ) { + + var model = _model; + var animation = _animation; + if ( ! model ) { + + model = this.Meshes[ 0 ]; + + } + if ( ! animation ) { + + animation = this.animations[ 0 ]; + + } + if ( ! model || ! animation ) { + + return null; + + } + var put = {}; + put.fps = animation.fps; + put.name = animation.name; + put.length = animation.length; + put.hierarchy = []; + for ( var b = 0; b < model.skeleton.bones.length; b ++ ) { + + var findAnimation = false; + for ( var i = 0; i < animation.hierarchy.length; i ++ ) { + + if ( model.skeleton.bones[ b ].name === animation.hierarchy[ i ].name ) { + + findAnimation = true; + var c_key = animation.hierarchy[ i ].copy(); + c_key.parent = - 1; + if ( model.skeleton.bones[ b ].parent && model.skeleton.bones[ b ].parent.type === "Bone" ) { + + for ( var bb = 0; bb < put.hierarchy.length; bb ++ ) { + + if ( put.hierarchy[ bb ].name === model.skeleton.bones[ b ].parent.name ) { + + c_key.parent = bb; + c_key.parentName = model.skeleton.bones[ b ].parent.name; + + } + + } + + } + put.hierarchy.push( c_key ); + break; + + } + + } + if ( ! findAnimation ) { + + var _c_key = animation.hierarchy[ 0 ].copy(); + _c_key.name = model.skeleton.bones[ b ].name; + _c_key.parent = - 1; + for ( var k = 0; k < _c_key.keys.length; k ++ ) { + + if ( _c_key.keys[ k ].pos ) { + + _c_key.keys[ k ].pos.set( 0, 0, 0 ); + + } + if ( _c_key.keys[ k ].scl ) { + + _c_key.keys[ k ].scl.set( 1, 1, 1 ); + + } + if ( _c_key.keys[ k ].rot ) { + + _c_key.keys[ k ].rot.set( 0, 0, 0, 1 ); + + } + + } + put.hierarchy.push( _c_key ); + + } + + } + if ( ! model.geometry.animations ) { + + model.geometry.animations = []; + + } + + model.geometry.animations.push( THREE.AnimationClip.parseAnimation( put, model.skeleton.bones ) ); + if ( ! model.animationMixer ) { + + model.animationMixer = new THREE.AnimationMixer( model ); + + } + + return put; + + } + }, { + key: '_ParseMatrixData', + value: function _ParseMatrixData( targetMatrix, data ) { + + targetMatrix.set( parseFloat( data[ 0 ] ), parseFloat( data[ 4 ] ), parseFloat( data[ 8 ] ), parseFloat( data[ 12 ] ), parseFloat( data[ 1 ] ), parseFloat( data[ 5 ] ), parseFloat( data[ 9 ] ), parseFloat( data[ 13 ] ), parseFloat( data[ 2 ] ), parseFloat( data[ 6 ] ), parseFloat( data[ 10 ] ), parseFloat( data[ 14 ] ), parseFloat( data[ 3 ] ), parseFloat( data[ 7 ] ), parseFloat( data[ 11 ] ), parseFloat( data[ 15 ] ) ); + + } + } ] ); + return XLoader; + + }(); + + return XLoader; + +} ) ) ); diff --git a/three/jsutil/loaders/ctm/CTMLoader.js b/three/jsutil/loaders/ctm/CTMLoader.js new file mode 100644 index 000000000..56759dda3 --- /dev/null +++ b/three/jsutil/loaders/ctm/CTMLoader.js @@ -0,0 +1,259 @@ +/** + * Loader for CTM encoded models generated by OpenCTM tools: + * http://openctm.sourceforge.net/ + * + * Uses js-openctm library by Juan Mellado + * http://code.google.com/p/js-openctm/ + * + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.CTMLoader = function () { + + THREE.Loader.call( this ); + +}; + +THREE.CTMLoader.prototype = Object.create( THREE.Loader.prototype ); +THREE.CTMLoader.prototype.constructor = THREE.CTMLoader; + +// Load multiple CTM parts defined in JSON + +THREE.CTMLoader.prototype.loadParts = function ( url, callback, parameters ) { + + parameters = parameters || {}; + + var scope = this; + + var xhr = new XMLHttpRequest(); + + var basePath = parameters.basePath ? parameters.basePath : THREE.LoaderUtils.extractUrlBase( url ); + + xhr.onreadystatechange = function () { + + if ( xhr.readyState === 4 ) { + + if ( xhr.status === 200 || xhr.status === 0 ) { + + var jsonObject = JSON.parse( xhr.responseText ); + + var materials = [], geometries = [], counter = 0; + + function callbackFinal( geometry ) { + + counter += 1; + + geometries.push( geometry ); + + if ( counter === jsonObject.offsets.length ) { + + callback( geometries, materials ); + + } + + } + + + // init materials + + for ( var i = 0; i < jsonObject.materials.length; i ++ ) { + + materials[ i ] = scope.createMaterial( jsonObject.materials[ i ], basePath ); + + } + + // load joined CTM file + + var partUrl = basePath + jsonObject.data; + var parametersPart = { useWorker: parameters.useWorker, worker: parameters.worker, offsets: jsonObject.offsets }; + scope.load( partUrl, callbackFinal, parametersPart ); + + } + + } + + }; + + xhr.open( "GET", url, true ); + xhr.setRequestHeader( "Content-Type", "text/plain" ); + xhr.send( null ); + +}; + +// Load CTMLoader compressed models +// - parameters +// - url (required) +// - callback (required) + +THREE.CTMLoader.prototype.load = function ( url, callback, parameters ) { + + parameters = parameters || {}; + + var scope = this; + + var offsets = parameters.offsets !== undefined ? parameters.offsets : [ 0 ]; + + var xhr = new XMLHttpRequest(), + callbackProgress = null; + + var length = 0; + + xhr.onreadystatechange = function () { + + if ( xhr.readyState === 4 ) { + + if ( xhr.status === 200 || xhr.status === 0 ) { + + var binaryData = new Uint8Array( xhr.response ); + + var s = Date.now(); + + if ( parameters.useWorker ) { + + var worker = parameters.worker || new Worker( 'js/loaders/ctm/CTMWorker.js' ); + + worker.onmessage = function ( event ) { + + var files = event.data; + + for ( var i = 0; i < files.length; i ++ ) { + + var ctmFile = files[ i ]; + + var e1 = Date.now(); + // console.log( "CTM data parse time [worker]: " + (e1-s) + " ms" ); + + scope.createModel( ctmFile, callback ); + + var e = Date.now(); + console.log( "model load time [worker]: " + ( e - e1 ) + " ms, total: " + ( e - s ) ); + + } + + + }; + + worker.postMessage( { "data": binaryData, "offsets": offsets }, [ binaryData.buffer ] ); + + } else { + + for ( var i = 0; i < offsets.length; i ++ ) { + + var stream = new CTM.Stream( binaryData ); + stream.offset = offsets[ i ]; + + var ctmFile = new CTM.File( stream ); + + scope.createModel( ctmFile, callback ); + + } + + //var e = Date.now(); + //console.log( "CTM data parse time [inline]: " + (e-s) + " ms" ); + + } + + } else { + + console.error( "Couldn't load [" + url + "] [" + xhr.status + "]" ); + + } + + } else if ( xhr.readyState === 3 ) { + + if ( callbackProgress ) { + + if ( length === 0 ) { + + length = xhr.getResponseHeader( "Content-Length" ); + + } + + callbackProgress( { total: length, loaded: xhr.responseText.length } ); + + } + + } else if ( xhr.readyState === 2 ) { + + length = xhr.getResponseHeader( "Content-Length" ); + + } + + }; + + xhr.open( "GET", url, true ); + xhr.responseType = "arraybuffer"; + + xhr.send( null ); + +}; + + +THREE.CTMLoader.prototype.createModel = function ( file, callback ) { + + var Model = function () { + + THREE.BufferGeometry.call( this ); + + this.materials = []; + + var indices = file.body.indices; + var positions = file.body.vertices; + var normals = file.body.normals; + + var uvs, colors; + + var uvMaps = file.body.uvMaps; + + if ( uvMaps !== undefined && uvMaps.length > 0 ) { + + uvs = uvMaps[ 0 ].uv; + + } + + var attrMaps = file.body.attrMaps; + + if ( attrMaps !== undefined && attrMaps.length > 0 && attrMaps[ 0 ].name === 'Color' ) { + + colors = attrMaps[ 0 ].attr; + + } + + this.setIndex( new THREE.BufferAttribute( indices, 1 ) ); + this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); + + if ( normals !== undefined ) { + + this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) ); + + } + + if ( uvs !== undefined ) { + + this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) ); + + } + + if ( colors !== undefined ) { + + this.addAttribute( 'color', new THREE.BufferAttribute( colors, 4 ) ); + + } + + }; + + Model.prototype = Object.create( THREE.BufferGeometry.prototype ); + Model.prototype.constructor = Model; + + var geometry = new Model(); + + // compute vertex normals if not present in the CTM model + if ( geometry.attributes.normal === undefined ) { + + geometry.computeVertexNormals(); + + } + + callback( geometry ); + +}; diff --git a/three/jsutil/loaders/ctm/CTMWorker.js b/three/jsutil/loaders/ctm/CTMWorker.js new file mode 100644 index 000000000..151f5aeb1 --- /dev/null +++ b/three/jsutil/loaders/ctm/CTMWorker.js @@ -0,0 +1,19 @@ +importScripts( "lzma.js", "ctm.js" ); + +self.onmessage = function ( event ) { + + var files = []; + + for ( var i = 0; i < event.data.offsets.length; i ++ ) { + + var stream = new CTM.Stream( event.data.data ); + stream.offset = event.data.offsets[ i ]; + + files[ i ] = new CTM.File( stream, [ event.data.data.buffer ] ); + + } + + self.postMessage( files ); + self.close(); + +}; diff --git a/three/jsutil/loaders/ctm/ctm.js b/three/jsutil/loaders/ctm/ctm.js new file mode 100644 index 000000000..ae002cba2 --- /dev/null +++ b/three/jsutil/loaders/ctm/ctm.js @@ -0,0 +1,658 @@ +/* +Copyright (c) 2011 Juan Mellado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* +References: +- "OpenCTM: The Open Compressed Triangle Mesh file format" by Marcus Geelnard + http://openctm.sourceforge.net/ +*/ + +var CTM = CTM || {}; + +// browserify support +if ( typeof module === 'object' ) { + + module.exports = CTM; + +} + +CTM.CompressionMethod = { + RAW: 0x00574152, + MG1: 0x0031474d, + MG2: 0x0032474d +}; + +CTM.Flags = { + NORMALS: 0x00000001 +}; + +CTM.File = function(stream) { + this.load(stream); +}; + +CTM.File.prototype.load = function(stream) { + this.header = new CTM.FileHeader(stream); + + this.body = new CTM.FileBody(this.header); + + this.getReader().read(stream, this.body); +}; + +CTM.File.prototype.getReader = function() { + var reader; + + switch (this.header.compressionMethod){ + case CTM.CompressionMethod.RAW: + reader = new CTM.ReaderRAW(); + break; + case CTM.CompressionMethod.MG1: + reader = new CTM.ReaderMG1(); + break; + case CTM.CompressionMethod.MG2: + reader = new CTM.ReaderMG2(); + break; + } + + return reader; +}; + +CTM.FileHeader = function(stream) { + stream.readInt32(); //magic "OCTM" + this.fileFormat = stream.readInt32(); + this.compressionMethod = stream.readInt32(); + this.vertexCount = stream.readInt32(); + this.triangleCount = stream.readInt32(); + this.uvMapCount = stream.readInt32(); + this.attrMapCount = stream.readInt32(); + this.flags = stream.readInt32(); + this.comment = stream.readString(); +}; + +CTM.FileHeader.prototype.hasNormals = function() { + return this.flags & CTM.Flags.NORMALS; +}; + +CTM.FileBody = function(header) { + var i = header.triangleCount * 3, + v = header.vertexCount * 3, + n = header.hasNormals() ? header.vertexCount * 3 : 0, + u = header.vertexCount * 2, + a = header.vertexCount * 4, + j = 0; + + var data = new ArrayBuffer( + (i + v + n + (u * header.uvMapCount) + (a * header.attrMapCount) ) * 4); + + this.indices = new Uint32Array(data, 0, i); + + this.vertices = new Float32Array(data, i * 4, v); + + if ( header.hasNormals() ) { + this.normals = new Float32Array(data, (i + v) * 4, n); + } + + if (header.uvMapCount) { + this.uvMaps = []; + for (j = 0; j < header.uvMapCount; ++ j) { + this.uvMaps[j] = { uv: new Float32Array(data, + (i + v + n + (j * u) ) * 4, u) }; + } + } + + if (header.attrMapCount) { + this.attrMaps = []; + for (j = 0; j < header.attrMapCount; ++ j) { + this.attrMaps[j] = { attr: new Float32Array(data, + (i + v + n + (u * header.uvMapCount) + (j * a) ) * 4, a) }; + } + } +}; + +CTM.FileMG2Header = function(stream) { + stream.readInt32(); //magic "MG2H" + this.vertexPrecision = stream.readFloat32(); + this.normalPrecision = stream.readFloat32(); + this.lowerBoundx = stream.readFloat32(); + this.lowerBoundy = stream.readFloat32(); + this.lowerBoundz = stream.readFloat32(); + this.higherBoundx = stream.readFloat32(); + this.higherBoundy = stream.readFloat32(); + this.higherBoundz = stream.readFloat32(); + this.divx = stream.readInt32(); + this.divy = stream.readInt32(); + this.divz = stream.readInt32(); + + this.sizex = (this.higherBoundx - this.lowerBoundx) / this.divx; + this.sizey = (this.higherBoundy - this.lowerBoundy) / this.divy; + this.sizez = (this.higherBoundz - this.lowerBoundz) / this.divz; +}; + +CTM.ReaderRAW = function() { +}; + +CTM.ReaderRAW.prototype.read = function(stream, body) { + this.readIndices(stream, body.indices); + this.readVertices(stream, body.vertices); + + if (body.normals) { + this.readNormals(stream, body.normals); + } + if (body.uvMaps) { + this.readUVMaps(stream, body.uvMaps); + } + if (body.attrMaps) { + this.readAttrMaps(stream, body.attrMaps); + } +}; + +CTM.ReaderRAW.prototype.readIndices = function(stream, indices) { + stream.readInt32(); //magic "INDX" + stream.readArrayInt32(indices); +}; + +CTM.ReaderRAW.prototype.readVertices = function(stream, vertices) { + stream.readInt32(); //magic "VERT" + stream.readArrayFloat32(vertices); +}; + +CTM.ReaderRAW.prototype.readNormals = function(stream, normals) { + stream.readInt32(); //magic "NORM" + stream.readArrayFloat32(normals); +}; + +CTM.ReaderRAW.prototype.readUVMaps = function(stream, uvMaps) { + var i = 0; + for (; i < uvMaps.length; ++ i) { + stream.readInt32(); //magic "TEXC" + + uvMaps[i].name = stream.readString(); + uvMaps[i].filename = stream.readString(); + stream.readArrayFloat32(uvMaps[i].uv); + } +}; + +CTM.ReaderRAW.prototype.readAttrMaps = function(stream, attrMaps) { + var i = 0; + for (; i < attrMaps.length; ++ i) { + stream.readInt32(); //magic "ATTR" + + attrMaps[i].name = stream.readString(); + stream.readArrayFloat32(attrMaps[i].attr); + } +}; + +CTM.ReaderMG1 = function() { +}; + +CTM.ReaderMG1.prototype.read = function(stream, body) { + this.readIndices(stream, body.indices); + this.readVertices(stream, body.vertices); + + if (body.normals) { + this.readNormals(stream, body.normals); + } + if (body.uvMaps) { + this.readUVMaps(stream, body.uvMaps); + } + if (body.attrMaps) { + this.readAttrMaps(stream, body.attrMaps); + } +}; + +CTM.ReaderMG1.prototype.readIndices = function(stream, indices) { + stream.readInt32(); //magic "INDX" + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(indices, 3); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + CTM.restoreIndices(indices, indices.length); +}; + +CTM.ReaderMG1.prototype.readVertices = function(stream, vertices) { + stream.readInt32(); //magic "VERT" + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(vertices, 1); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); +}; + +CTM.ReaderMG1.prototype.readNormals = function(stream, normals) { + stream.readInt32(); //magic "NORM" + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(normals, 3); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); +}; + +CTM.ReaderMG1.prototype.readUVMaps = function(stream, uvMaps) { + var i = 0; + for (; i < uvMaps.length; ++ i) { + stream.readInt32(); //magic "TEXC" + + uvMaps[i].name = stream.readString(); + uvMaps[i].filename = stream.readString(); + + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + } +}; + +CTM.ReaderMG1.prototype.readAttrMaps = function(stream, attrMaps) { + var i = 0; + for (; i < attrMaps.length; ++ i) { + stream.readInt32(); //magic "ATTR" + + attrMaps[i].name = stream.readString(); + + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + } +}; + +CTM.ReaderMG2 = function() { +}; + +CTM.ReaderMG2.prototype.read = function(stream, body) { + this.MG2Header = new CTM.FileMG2Header(stream); + + this.readVertices(stream, body.vertices); + this.readIndices(stream, body.indices); + + if (body.normals) { + this.readNormals(stream, body); + } + if (body.uvMaps) { + this.readUVMaps(stream, body.uvMaps); + } + if (body.attrMaps) { + this.readAttrMaps(stream, body.attrMaps); + } +}; + +CTM.ReaderMG2.prototype.readVertices = function(stream, vertices) { + stream.readInt32(); //magic "VERT" + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(vertices, 3); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + var gridIndices = this.readGridIndices(stream, vertices); + + CTM.restoreVertices(vertices, this.MG2Header, gridIndices, this.MG2Header.vertexPrecision); +}; + +CTM.ReaderMG2.prototype.readGridIndices = function(stream, vertices) { + stream.readInt32(); //magic "GIDX" + stream.readInt32(); //packed size + + var gridIndices = new Uint32Array(vertices.length / 3); + + var interleaved = new CTM.InterleavedStream(gridIndices, 1); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + CTM.restoreGridIndices(gridIndices, gridIndices.length); + + return gridIndices; +}; + +CTM.ReaderMG2.prototype.readIndices = function(stream, indices) { + stream.readInt32(); //magic "INDX" + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(indices, 3); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + CTM.restoreIndices(indices, indices.length); +}; + +CTM.ReaderMG2.prototype.readNormals = function(stream, body) { + stream.readInt32(); //magic "NORM" + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(body.normals, 3); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + var smooth = CTM.calcSmoothNormals(body.indices, body.vertices); + + CTM.restoreNormals(body.normals, smooth, this.MG2Header.normalPrecision); +}; + +CTM.ReaderMG2.prototype.readUVMaps = function(stream, uvMaps) { + var i = 0; + for (; i < uvMaps.length; ++ i) { + stream.readInt32(); //magic "TEXC" + + uvMaps[i].name = stream.readString(); + uvMaps[i].filename = stream.readString(); + + var precision = stream.readFloat32(); + + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + CTM.restoreMap(uvMaps[i].uv, 2, precision); + } +}; + +CTM.ReaderMG2.prototype.readAttrMaps = function(stream, attrMaps) { + var i = 0; + for (; i < attrMaps.length; ++ i) { + stream.readInt32(); //magic "ATTR" + + attrMaps[i].name = stream.readString(); + + var precision = stream.readFloat32(); + + stream.readInt32(); //packed size + + var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4); + LZMA.decompress(stream, stream, interleaved, interleaved.data.length); + + CTM.restoreMap(attrMaps[i].attr, 4, precision); + } +}; + +CTM.restoreIndices = function(indices, len) { + var i = 3; + if (len > 0) { + indices[2] += indices[0]; + indices[1] += indices[0]; + } + for (; i < len; i += 3) { + indices[i] += indices[i - 3]; + + if (indices[i] === indices[i - 3]) { + indices[i + 1] += indices[i - 2]; + }else { + indices[i + 1] += indices[i]; + } + + indices[i + 2] += indices[i]; + } +}; + +CTM.restoreGridIndices = function(gridIndices, len) { + var i = 1; + for (; i < len; ++ i) { + gridIndices[i] += gridIndices[i - 1]; + } +}; + +CTM.restoreVertices = function(vertices, grid, gridIndices, precision) { + var gridIdx, delta, x, y, z, + intVertices = new Uint32Array(vertices.buffer, vertices.byteOffset, vertices.length), + ydiv = grid.divx, zdiv = ydiv * grid.divy, + prevGridIdx = 0x7fffffff, prevDelta = 0, + i = 0, j = 0, len = gridIndices.length; + + for (; i < len; j += 3) { + x = gridIdx = gridIndices[i ++]; + + z = ~~(x / zdiv); + x -= ~~(z * zdiv); + y = ~~(x / ydiv); + x -= ~~(y * ydiv); + + delta = intVertices[j]; + if (gridIdx === prevGridIdx) { + delta += prevDelta; + } + + vertices[j] = grid.lowerBoundx + + x * grid.sizex + precision * delta; + vertices[j + 1] = grid.lowerBoundy + + y * grid.sizey + precision * intVertices[j + 1]; + vertices[j + 2] = grid.lowerBoundz + + z * grid.sizez + precision * intVertices[j + 2]; + + prevGridIdx = gridIdx; + prevDelta = delta; + } +}; + +CTM.restoreNormals = function(normals, smooth, precision) { + var ro, phi, theta, sinPhi, + nx, ny, nz, by, bz, len, + intNormals = new Uint32Array(normals.buffer, normals.byteOffset, normals.length), + i = 0, k = normals.length, + PI_DIV_2 = 3.141592653589793238462643 * 0.5; + + for (; i < k; i += 3) { + ro = intNormals[i] * precision; + phi = intNormals[i + 1]; + + if (phi === 0) { + normals[i] = smooth[i] * ro; + normals[i + 1] = smooth[i + 1] * ro; + normals[i + 2] = smooth[i + 2] * ro; + }else { + + if (phi <= 4) { + theta = (intNormals[i + 2] - 2) * PI_DIV_2; + }else { + theta = ( (intNormals[i + 2] * 4 / phi) - 2) * PI_DIV_2; + } + + phi *= precision * PI_DIV_2; + sinPhi = ro * Math.sin(phi); + + nx = sinPhi * Math.cos(theta); + ny = sinPhi * Math.sin(theta); + nz = ro * Math.cos(phi); + + bz = smooth[i + 1]; + by = smooth[i] - smooth[i + 2]; + + len = Math.sqrt(2 * bz * bz + by * by); + if (len > 1e-20) { + by /= len; + bz /= len; + } + + normals[i] = smooth[i] * nz + (smooth[i + 1] * bz - smooth[i + 2] * by) * ny - bz * nx; + normals[i + 1] = smooth[i + 1] * nz - (smooth[i + 2] + smooth[i]) * bz * ny + by * nx; + normals[i + 2] = smooth[i + 2] * nz + (smooth[i] * by + smooth[i + 1] * bz) * ny + bz * nx; + } + } +}; + +CTM.restoreMap = function(map, count, precision) { + var delta, value, + intMap = new Uint32Array(map.buffer, map.byteOffset, map.length), + i = 0, j, len = map.length; + + for (; i < count; ++ i) { + delta = 0; + + for (j = i; j < len; j += count) { + value = intMap[j]; + + delta += value & 1 ? -( (value + 1) >> 1) : value >> 1; + + map[j] = delta * precision; + } + } +}; + +CTM.calcSmoothNormals = function(indices, vertices) { + var smooth = new Float32Array(vertices.length), + indx, indy, indz, nx, ny, nz, + v1x, v1y, v1z, v2x, v2y, v2z, len, + i, k; + + for (i = 0, k = indices.length; i < k;) { + indx = indices[i ++] * 3; + indy = indices[i ++] * 3; + indz = indices[i ++] * 3; + + v1x = vertices[indy] - vertices[indx]; + v2x = vertices[indz] - vertices[indx]; + v1y = vertices[indy + 1] - vertices[indx + 1]; + v2y = vertices[indz + 1] - vertices[indx + 1]; + v1z = vertices[indy + 2] - vertices[indx + 2]; + v2z = vertices[indz + 2] - vertices[indx + 2]; + + nx = v1y * v2z - v1z * v2y; + ny = v1z * v2x - v1x * v2z; + nz = v1x * v2y - v1y * v2x; + + len = Math.sqrt(nx * nx + ny * ny + nz * nz); + if (len > 1e-10) { + nx /= len; + ny /= len; + nz /= len; + } + + smooth[indx] += nx; + smooth[indx + 1] += ny; + smooth[indx + 2] += nz; + smooth[indy] += nx; + smooth[indy + 1] += ny; + smooth[indy + 2] += nz; + smooth[indz] += nx; + smooth[indz + 1] += ny; + smooth[indz + 2] += nz; + } + + for (i = 0, k = smooth.length; i < k; i += 3) { + len = Math.sqrt(smooth[i] * smooth[i] + + smooth[i + 1] * smooth[i + 1] + + smooth[i + 2] * smooth[i + 2]); + + if (len > 1e-10) { + smooth[i] /= len; + smooth[i + 1] /= len; + smooth[i + 2] /= len; + } + } + + return smooth; +}; + +CTM.isLittleEndian = (function() { + var buffer = new ArrayBuffer(2), + bytes = new Uint8Array(buffer), + ints = new Uint16Array(buffer); + + bytes[0] = 1; + + return ints[0] === 1; +}()); + +CTM.InterleavedStream = function(data, count) { + this.data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength); + this.offset = CTM.isLittleEndian ? 3 : 0; + this.count = count * 4; + this.len = this.data.length; +}; + +CTM.InterleavedStream.prototype.writeByte = function(value) { + this.data[this.offset] = value; + + this.offset += this.count; + if (this.offset >= this.len) { + + this.offset -= this.len - 4; + if (this.offset >= this.count) { + + this.offset -= this.count + (CTM.isLittleEndian ? 1 : -1); + } + } +}; + +CTM.Stream = function(data) { + this.data = data; + this.offset = 0; +}; + +CTM.Stream.prototype.TWO_POW_MINUS23 = Math.pow(2, -23); + +CTM.Stream.prototype.TWO_POW_MINUS126 = Math.pow(2, -126); + +CTM.Stream.prototype.readByte = function() { + return this.data[this.offset ++] & 0xff; +}; + +CTM.Stream.prototype.readInt32 = function() { + var i = this.readByte(); + i |= this.readByte() << 8; + i |= this.readByte() << 16; + return i | (this.readByte() << 24); +}; + +CTM.Stream.prototype.readFloat32 = function() { + var m = this.readByte(); + m += this.readByte() << 8; + + var b1 = this.readByte(); + var b2 = this.readByte(); + + m += (b1 & 0x7f) << 16; + var e = ( (b2 & 0x7f) << 1) | ( (b1 & 0x80) >>> 7); + var s = b2 & 0x80 ? -1 : 1; + + if (e === 255) { + return m !== 0 ? NaN : s * Infinity; + } + if (e > 0) { + return s * (1 + (m * this.TWO_POW_MINUS23) ) * Math.pow(2, e - 127); + } + if (m !== 0) { + return s * m * this.TWO_POW_MINUS126; + } + return s * 0; +}; + +CTM.Stream.prototype.readString = function() { + var len = this.readInt32(); + + this.offset += len; + + return String.fromCharCode.apply(null, this.data.subarray(this.offset - len, this.offset)); +}; + +CTM.Stream.prototype.readArrayInt32 = function(array) { + var i = 0, len = array.length; + + while (i < len) { + array[i ++] = this.readInt32(); + } + + return array; +}; + +CTM.Stream.prototype.readArrayFloat32 = function(array) { + var i = 0, len = array.length; + + while (i < len) { + array[i ++] = this.readFloat32(); + } + + return array; +}; diff --git a/three/jsutil/loaders/ctm/license/OpenCTM.txt b/three/jsutil/loaders/ctm/license/OpenCTM.txt new file mode 100644 index 000000000..0e66fa76e --- /dev/null +++ b/three/jsutil/loaders/ctm/license/OpenCTM.txt @@ -0,0 +1,20 @@ +Copyright (c) 2009-2010 Marcus Geelnard + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. diff --git a/three/jsutil/loaders/ctm/license/js-lzma.txt b/three/jsutil/loaders/ctm/license/js-lzma.txt new file mode 100644 index 000000000..8abd0056b --- /dev/null +++ b/three/jsutil/loaders/ctm/license/js-lzma.txt @@ -0,0 +1,19 @@ +Copyright (c) 2011 Juan Mellado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/three/jsutil/loaders/ctm/license/js-openctm.txt b/three/jsutil/loaders/ctm/license/js-openctm.txt new file mode 100644 index 000000000..8abd0056b --- /dev/null +++ b/three/jsutil/loaders/ctm/license/js-openctm.txt @@ -0,0 +1,19 @@ +Copyright (c) 2011 Juan Mellado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/three/jsutil/loaders/ctm/lzma.js b/three/jsutil/loaders/ctm/lzma.js new file mode 100644 index 000000000..9960f2592 --- /dev/null +++ b/three/jsutil/loaders/ctm/lzma.js @@ -0,0 +1,517 @@ + +var LZMA = LZMA || {}; + +// browserify support +if ( typeof module === 'object' ) { + + module.exports = LZMA; + +} + +LZMA.OutWindow = function() { + this._windowSize = 0; +}; + +LZMA.OutWindow.prototype.create = function(windowSize) { + if ( (!this._buffer) || (this._windowSize !== windowSize) ) { + this._buffer = []; + } + this._windowSize = windowSize; + this._pos = 0; + this._streamPos = 0; +}; + +LZMA.OutWindow.prototype.flush = function() { + var size = this._pos - this._streamPos; + if (size !== 0) { + while (size --) { + this._stream.writeByte(this._buffer[this._streamPos ++]); + } + if (this._pos >= this._windowSize) { + this._pos = 0; + } + this._streamPos = this._pos; + } +}; + +LZMA.OutWindow.prototype.releaseStream = function() { + this.flush(); + this._stream = null; +}; + +LZMA.OutWindow.prototype.setStream = function(stream) { + this.releaseStream(); + this._stream = stream; +}; + +LZMA.OutWindow.prototype.init = function(solid) { + if (!solid) { + this._streamPos = 0; + this._pos = 0; + } +}; + +LZMA.OutWindow.prototype.copyBlock = function(distance, len) { + var pos = this._pos - distance - 1; + if (pos < 0) { + pos += this._windowSize; + } + while (len --) { + if (pos >= this._windowSize) { + pos = 0; + } + this._buffer[this._pos ++] = this._buffer[pos ++]; + if (this._pos >= this._windowSize) { + this.flush(); + } + } +}; + +LZMA.OutWindow.prototype.putByte = function(b) { + this._buffer[this._pos ++] = b; + if (this._pos >= this._windowSize) { + this.flush(); + } +}; + +LZMA.OutWindow.prototype.getByte = function(distance) { + var pos = this._pos - distance - 1; + if (pos < 0) { + pos += this._windowSize; + } + return this._buffer[pos]; +}; + +LZMA.RangeDecoder = function() { +}; + +LZMA.RangeDecoder.prototype.setStream = function(stream) { + this._stream = stream; +}; + +LZMA.RangeDecoder.prototype.releaseStream = function() { + this._stream = null; +}; + +LZMA.RangeDecoder.prototype.init = function() { + var i = 5; + + this._code = 0; + this._range = -1; + + while (i --) { + this._code = (this._code << 8) | this._stream.readByte(); + } +}; + +LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits) { + var result = 0, i = numTotalBits, t; + + while (i --) { + this._range >>>= 1; + t = (this._code - this._range) >>> 31; + this._code -= this._range & (t - 1); + result = (result << 1) | (1 - t); + + if ( (this._range & 0xff000000) === 0) { + this._code = (this._code << 8) | this._stream.readByte(); + this._range <<= 8; + } + } + + return result; +}; + +LZMA.RangeDecoder.prototype.decodeBit = function(probs, index) { + var prob = probs[index], + newBound = (this._range >>> 11) * prob; + + if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ) { + this._range = newBound; + probs[index] += (2048 - prob) >>> 5; + if ( (this._range & 0xff000000) === 0) { + this._code = (this._code << 8) | this._stream.readByte(); + this._range <<= 8; + } + return 0; + } + + this._range -= newBound; + this._code -= newBound; + probs[index] -= prob >>> 5; + if ( (this._range & 0xff000000) === 0) { + this._code = (this._code << 8) | this._stream.readByte(); + this._range <<= 8; + } + return 1; +}; + +LZMA.initBitModels = function(probs, len) { + while (len --) { + probs[len] = 1024; + } +}; + +LZMA.BitTreeDecoder = function(numBitLevels) { + this._models = []; + this._numBitLevels = numBitLevels; +}; + +LZMA.BitTreeDecoder.prototype.init = function() { + LZMA.initBitModels(this._models, 1 << this._numBitLevels); +}; + +LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder) { + var m = 1, i = this._numBitLevels; + + while (i --) { + m = (m << 1) | rangeDecoder.decodeBit(this._models, m); + } + return m - (1 << this._numBitLevels); +}; + +LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder) { + var m = 1, symbol = 0, i = 0, bit; + + for (; i < this._numBitLevels; ++ i) { + bit = rangeDecoder.decodeBit(this._models, m); + m = (m << 1) | bit; + symbol |= bit << i; + } + return symbol; +}; + +LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels) { + var m = 1, symbol = 0, i = 0, bit; + + for (; i < numBitLevels; ++ i) { + bit = rangeDecoder.decodeBit(models, startIndex + m); + m = (m << 1) | bit; + symbol |= bit << i; + } + return symbol; +}; + +LZMA.LenDecoder = function() { + this._choice = []; + this._lowCoder = []; + this._midCoder = []; + this._highCoder = new LZMA.BitTreeDecoder(8); + this._numPosStates = 0; +}; + +LZMA.LenDecoder.prototype.create = function(numPosStates) { + for (; this._numPosStates < numPosStates; ++ this._numPosStates) { + this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3); + this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3); + } +}; + +LZMA.LenDecoder.prototype.init = function() { + var i = this._numPosStates; + LZMA.initBitModels(this._choice, 2); + while (i --) { + this._lowCoder[i].init(); + this._midCoder[i].init(); + } + this._highCoder.init(); +}; + +LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState) { + if (rangeDecoder.decodeBit(this._choice, 0) === 0) { + return this._lowCoder[posState].decode(rangeDecoder); + } + if (rangeDecoder.decodeBit(this._choice, 1) === 0) { + return 8 + this._midCoder[posState].decode(rangeDecoder); + } + return 16 + this._highCoder.decode(rangeDecoder); +}; + +LZMA.Decoder2 = function() { + this._decoders = []; +}; + +LZMA.Decoder2.prototype.init = function() { + LZMA.initBitModels(this._decoders, 0x300); +}; + +LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder) { + var symbol = 1; + + do { + symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol); + }while (symbol < 0x100); + + return symbol & 0xff; +}; + +LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte) { + var symbol = 1, matchBit, bit; + + do { + matchBit = (matchByte >> 7) & 1; + matchByte <<= 1; + bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol); + symbol = (symbol << 1) | bit; + if (matchBit !== bit) { + while (symbol < 0x100) { + symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol); + } + break; + } + }while (symbol < 0x100); + + return symbol & 0xff; +}; + +LZMA.LiteralDecoder = function() { +}; + +LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits) { + var i; + + if (this._coders + && (this._numPrevBits === numPrevBits) + && (this._numPosBits === numPosBits) ) { + return; + } + this._numPosBits = numPosBits; + this._posMask = (1 << numPosBits) - 1; + this._numPrevBits = numPrevBits; + + this._coders = []; + + i = 1 << (this._numPrevBits + this._numPosBits); + while (i --) { + this._coders[i] = new LZMA.Decoder2(); + } +}; + +LZMA.LiteralDecoder.prototype.init = function() { + var i = 1 << (this._numPrevBits + this._numPosBits); + while (i --) { + this._coders[i].init(); + } +}; + +LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte) { + return this._coders[( (pos & this._posMask) << this._numPrevBits) + + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )]; +}; + +LZMA.Decoder = function() { + this._outWindow = new LZMA.OutWindow(); + this._rangeDecoder = new LZMA.RangeDecoder(); + this._isMatchDecoders = []; + this._isRepDecoders = []; + this._isRepG0Decoders = []; + this._isRepG1Decoders = []; + this._isRepG2Decoders = []; + this._isRep0LongDecoders = []; + this._posSlotDecoder = []; + this._posDecoders = []; + this._posAlignDecoder = new LZMA.BitTreeDecoder(4); + this._lenDecoder = new LZMA.LenDecoder(); + this._repLenDecoder = new LZMA.LenDecoder(); + this._literalDecoder = new LZMA.LiteralDecoder(); + this._dictionarySize = -1; + this._dictionarySizeCheck = -1; + + this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6); + this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6); + this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6); + this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6); +}; + +LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize) { + if (dictionarySize < 0) { + return false; + } + if (this._dictionarySize !== dictionarySize) { + this._dictionarySize = dictionarySize; + this._dictionarySizeCheck = Math.max(this._dictionarySize, 1); + this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) ); + } + return true; +}; + +LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb) { + var numPosStates = 1 << pb; + + if (lc > 8 || lp > 4 || pb > 4) { + return false; + } + + this._literalDecoder.create(lp, lc); + + this._lenDecoder.create(numPosStates); + this._repLenDecoder.create(numPosStates); + this._posStateMask = numPosStates - 1; + + return true; +}; + +LZMA.Decoder.prototype.init = function() { + var i = 4; + + this._outWindow.init(false); + + LZMA.initBitModels(this._isMatchDecoders, 192); + LZMA.initBitModels(this._isRep0LongDecoders, 192); + LZMA.initBitModels(this._isRepDecoders, 12); + LZMA.initBitModels(this._isRepG0Decoders, 12); + LZMA.initBitModels(this._isRepG1Decoders, 12); + LZMA.initBitModels(this._isRepG2Decoders, 12); + LZMA.initBitModels(this._posDecoders, 114); + + this._literalDecoder.init(); + + while (i --) { + this._posSlotDecoder[i].init(); + } + + this._lenDecoder.init(); + this._repLenDecoder.init(); + this._posAlignDecoder.init(); + this._rangeDecoder.init(); +}; + +LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize) { + var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0, + posState, decoder2, len, distance, posSlot, numDirectBits; + + this._rangeDecoder.setStream(inStream); + this._outWindow.setStream(outStream); + + this.init(); + + while (outSize < 0 || nowPos64 < outSize) { + posState = nowPos64 & this._posStateMask; + + if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0) { + decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte); + + if (state >= 7) { + prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) ); + }else { + prevByte = decoder2.decodeNormal(this._rangeDecoder); + } + this._outWindow.putByte(prevByte); + + state = state < 4 ? 0 : state - (state < 10 ? 3 : 6); + + }else { + + if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1) { + len = 0; + if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0) { + if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0) { + state = state < 7 ? 9 : 11; + len = 1; + } + }else { + if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0) { + distance = rep1; + }else { + if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0) { + distance = rep2; + }else { + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + if (len === 0) { + len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState); + state = state < 7 ? 8 : 11; + } + }else { + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + + len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState); + state = state < 7 ? 7 : 10; + + posSlot = this._posSlotDecoder[len <= 5 ? len - 2 : 3].decode(this._rangeDecoder); + if (posSlot >= 4) { + + numDirectBits = (posSlot >> 1) - 1; + rep0 = (2 | (posSlot & 1) ) << numDirectBits; + + if (posSlot < 14) { + rep0 += LZMA.reverseDecode2(this._posDecoders, + rep0 - posSlot - 1, this._rangeDecoder, numDirectBits); + }else { + rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4; + rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder); + if (rep0 < 0) { + if (rep0 === -1) { + break; + } + return false; + } + } + }else { + rep0 = posSlot; + } + } + + if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck) { + return false; + } + + this._outWindow.copyBlock(rep0, len); + nowPos64 += len; + prevByte = this._outWindow.getByte(0); + } + } + + this._outWindow.flush(); + this._outWindow.releaseStream(); + this._rangeDecoder.releaseStream(); + + return true; +}; + +LZMA.Decoder.prototype.setDecoderProperties = function(properties) { + var value, lc, lp, pb, dictionarySize; + + if (properties.size < 5) { + return false; + } + + value = properties.readByte(); + lc = value % 9; + value = ~~(value / 9); + lp = value % 5; + pb = ~~(value / 5); + + if ( !this.setLcLpPb(lc, lp, pb) ) { + return false; + } + + dictionarySize = properties.readByte(); + dictionarySize |= properties.readByte() << 8; + dictionarySize |= properties.readByte() << 16; + dictionarySize += properties.readByte() * 16777216; + + return this.setDictionarySize(dictionarySize); +}; + +LZMA.decompress = function(properties, inStream, outStream, outSize) { + var decoder = new LZMA.Decoder(); + + if ( !decoder.setDecoderProperties(properties) ) { + throw "Incorrect stream properties"; + } + + if ( !decoder.decode(inStream, outStream, outSize) ) { + throw "Error in data stream"; + } + + return true; +}; diff --git a/three/jsutil/loaders/deprecated/LegacyGLTFLoader.js b/three/jsutil/loaders/deprecated/LegacyGLTFLoader.js new file mode 100644 index 000000000..339582a04 --- /dev/null +++ b/three/jsutil/loaders/deprecated/LegacyGLTFLoader.js @@ -0,0 +1,2238 @@ +/** + * @author Rich Tibbett / https://github.com/richtr + * @author mrdoob / http://mrdoob.com/ + * @author Tony Parisi / http://www.tonyparisi.com/ + * @author Takahiro / https://github.com/takahirox + */ + +THREE.LegacyGLTFLoader = ( function () { + + function LegacyGLTFLoader( manager ) { + + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + } + + LegacyGLTFLoader.prototype = { + + constructor: LegacyGLTFLoader, + + crossOrigin: 'anonymous', + + load: function ( url, onLoad, onProgress, onError ) { + + var scope = this; + + var resourcePath; + + if ( this.resourcePath !== undefined ) { + + resourcePath = this.resourcePath; + + } else if ( this.path !== undefined ) { + + resourcePath = this.path; + + } else { + + resourcePath = THREE.LoaderUtils.extractUrlBase( url ); + + } + + var loader = new THREE.FileLoader( scope.manager ); + + loader.setPath( this.path ); + loader.setResponseType( 'arraybuffer' ); + + loader.load( url, function ( data ) { + + scope.parse( data, resourcePath, onLoad ); + + }, onProgress, onError ); + + }, + + setCrossOrigin: function ( value ) { + + this.crossOrigin = value; + return this; + + }, + + setPath: function ( value ) { + + this.path = value; + + }, + + setResourcePath: function ( value ) { + + this.resourcePath = value; + return this; + + }, + + parse: function ( data, path, callback ) { + + var content; + var extensions = {}; + + var magic = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) ); + + if ( magic === BINARY_EXTENSION_HEADER_DEFAULTS.magic ) { + + extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data ); + content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content; + + } else { + + content = THREE.LoaderUtils.decodeText( new Uint8Array( data ) ); + + } + + var json = JSON.parse( content ); + + if ( json.extensionsUsed && json.extensionsUsed.indexOf( EXTENSIONS.KHR_MATERIALS_COMMON ) >= 0 ) { + + extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] = new GLTFMaterialsCommonExtension( json ); + + } + + var parser = new GLTFParser( json, extensions, { + + crossOrigin: this.crossOrigin, + manager: this.manager, + path: path || this.resourcePath || '' + + } ); + + parser.parse( function ( scene, scenes, cameras, animations ) { + + var glTF = { + "scene": scene, + "scenes": scenes, + "cameras": cameras, + "animations": animations + }; + + callback( glTF ); + + } ); + + } + + }; + + /* GLTFREGISTRY */ + + function GLTFRegistry() { + + var objects = {}; + + return { + + get: function ( key ) { + + return objects[ key ]; + + }, + + add: function ( key, object ) { + + objects[ key ] = object; + + }, + + remove: function ( key ) { + + delete objects[ key ]; + + }, + + removeAll: function () { + + objects = {}; + + }, + + update: function ( scene, camera ) { + + for ( var name in objects ) { + + var object = objects[ name ]; + + if ( object.update ) { + + object.update( scene, camera ); + + } + + } + + } + + }; + + } + + /* GLTFSHADERS */ + + LegacyGLTFLoader.Shaders = { + + update: function () { + + console.warn( 'THREE.LegacyGLTFLoader.Shaders has been deprecated, and now updates automatically.' ); + + } + + }; + + /* GLTFSHADER */ + + function GLTFShader( targetNode, allNodes ) { + + var boundUniforms = {}; + + // bind each uniform to its source node + + var uniforms = targetNode.material.uniforms; + + for ( var uniformId in uniforms ) { + + var uniform = uniforms[ uniformId ]; + + if ( uniform.semantic ) { + + var sourceNodeRef = uniform.node; + + var sourceNode = targetNode; + + if ( sourceNodeRef ) { + + sourceNode = allNodes[ sourceNodeRef ]; + + } + + boundUniforms[ uniformId ] = { + semantic: uniform.semantic, + sourceNode: sourceNode, + targetNode: targetNode, + uniform: uniform + }; + + } + + } + + this.boundUniforms = boundUniforms; + this._m4 = new THREE.Matrix4(); + + } + + // Update - update all the uniform values + GLTFShader.prototype.update = function ( scene, camera ) { + + var boundUniforms = this.boundUniforms; + + for ( var name in boundUniforms ) { + + var boundUniform = boundUniforms[ name ]; + + switch ( boundUniform.semantic ) { + + case "MODELVIEW": + + var m4 = boundUniform.uniform.value; + m4.multiplyMatrices( camera.matrixWorldInverse, boundUniform.sourceNode.matrixWorld ); + break; + + case "MODELVIEWINVERSETRANSPOSE": + + var m3 = boundUniform.uniform.value; + this._m4.multiplyMatrices( camera.matrixWorldInverse, boundUniform.sourceNode.matrixWorld ); + m3.getNormalMatrix( this._m4 ); + break; + + case "PROJECTION": + + var m4 = boundUniform.uniform.value; + m4.copy( camera.projectionMatrix ); + break; + + case "JOINTMATRIX": + + var m4v = boundUniform.uniform.value; + + for ( var mi = 0; mi < m4v.length; mi ++ ) { + + // So it goes like this: + // SkinnedMesh world matrix is already baked into MODELVIEW; + // transform joints to local space, + // then transform using joint's inverse + m4v[ mi ] + .getInverse( boundUniform.sourceNode.matrixWorld ) + .multiply( boundUniform.targetNode.skeleton.bones[ mi ].matrixWorld ) + .multiply( boundUniform.targetNode.skeleton.boneInverses[ mi ] ) + .multiply( boundUniform.targetNode.bindMatrix ); + + } + + break; + + default : + + console.warn( "Unhandled shader semantic: " + boundUniform.semantic ); + break; + + } + + } + + }; + + + /* ANIMATION */ + + LegacyGLTFLoader.Animations = { + + update: function () { + + console.warn( 'THREE.LegacyGLTFLoader.Animation has been deprecated. Use THREE.AnimationMixer instead.' ); + + } + + }; + + /*********************************/ + /********** EXTENSIONS ***********/ + /*********************************/ + + var EXTENSIONS = { + KHR_BINARY_GLTF: 'KHR_binary_glTF', + KHR_MATERIALS_COMMON: 'KHR_materials_common' + }; + + /* MATERIALS COMMON EXTENSION */ + + function GLTFMaterialsCommonExtension( json ) { + + this.name = EXTENSIONS.KHR_MATERIALS_COMMON; + + this.lights = {}; + + var extension = ( json.extensions && json.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] ) || {}; + var lights = extension.lights || {}; + + for ( var lightId in lights ) { + + var light = lights[ lightId ]; + var lightNode; + + var lightParams = light[ light.type ]; + var color = new THREE.Color().fromArray( lightParams.color ); + + switch ( light.type ) { + + case "directional": + lightNode = new THREE.DirectionalLight( color ); + lightNode.position.set( 0, 0, 1 ); + break; + + case "point": + lightNode = new THREE.PointLight( color ); + break; + + case "spot": + lightNode = new THREE.SpotLight( color ); + lightNode.position.set( 0, 0, 1 ); + break; + + case "ambient": + lightNode = new THREE.AmbientLight( color ); + break; + + } + + if ( lightNode ) { + + this.lights[ lightId ] = lightNode; + + } + + } + + } + + /* BINARY EXTENSION */ + + var BINARY_EXTENSION_BUFFER_NAME = 'binary_glTF'; + + var BINARY_EXTENSION_HEADER_DEFAULTS = { magic: 'glTF', version: 1, contentFormat: 0 }; + + var BINARY_EXTENSION_HEADER_LENGTH = 20; + + function GLTFBinaryExtension( data ) { + + this.name = EXTENSIONS.KHR_BINARY_GLTF; + + var headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH ); + + var header = { + magic: THREE.LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ), + version: headerView.getUint32( 4, true ), + length: headerView.getUint32( 8, true ), + contentLength: headerView.getUint32( 12, true ), + contentFormat: headerView.getUint32( 16, true ) + }; + + for ( var key in BINARY_EXTENSION_HEADER_DEFAULTS ) { + + var value = BINARY_EXTENSION_HEADER_DEFAULTS[ key ]; + + if ( header[ key ] !== value ) { + + throw new Error( 'Unsupported glTF-Binary header: Expected "%s" to be "%s".', key, value ); + + } + + } + + var contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH, header.contentLength ); + + this.header = header; + this.content = THREE.LoaderUtils.decodeText( contentArray ); + this.body = data.slice( BINARY_EXTENSION_HEADER_LENGTH + header.contentLength, header.length ); + + } + + GLTFBinaryExtension.prototype.loadShader = function ( shader, bufferViews ) { + + var bufferView = bufferViews[ shader.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].bufferView ]; + var array = new Uint8Array( bufferView ); + + return THREE.LoaderUtils.decodeText( array ); + + }; + + /*********************************/ + /********** INTERNALS ************/ + /*********************************/ + + /* CONSTANTS */ + + var WEBGL_CONSTANTS = { + FLOAT: 5126, + //FLOAT_MAT2: 35674, + FLOAT_MAT3: 35675, + FLOAT_MAT4: 35676, + FLOAT_VEC2: 35664, + FLOAT_VEC3: 35665, + FLOAT_VEC4: 35666, + LINEAR: 9729, + REPEAT: 10497, + SAMPLER_2D: 35678, + TRIANGLES: 4, + LINES: 1, + UNSIGNED_BYTE: 5121, + UNSIGNED_SHORT: 5123, + + VERTEX_SHADER: 35633, + FRAGMENT_SHADER: 35632 + }; + + var WEBGL_TYPE = { + 5126: Number, + //35674: THREE.Matrix2, + 35675: THREE.Matrix3, + 35676: THREE.Matrix4, + 35664: THREE.Vector2, + 35665: THREE.Vector3, + 35666: THREE.Vector4, + 35678: THREE.Texture + }; + + var WEBGL_COMPONENT_TYPES = { + 5120: Int8Array, + 5121: Uint8Array, + 5122: Int16Array, + 5123: Uint16Array, + 5125: Uint32Array, + 5126: Float32Array + }; + + var WEBGL_FILTERS = { + 9728: THREE.NearestFilter, + 9729: THREE.LinearFilter, + 9984: THREE.NearestMipMapNearestFilter, + 9985: THREE.LinearMipMapNearestFilter, + 9986: THREE.NearestMipMapLinearFilter, + 9987: THREE.LinearMipMapLinearFilter + }; + + var WEBGL_WRAPPINGS = { + 33071: THREE.ClampToEdgeWrapping, + 33648: THREE.MirroredRepeatWrapping, + 10497: THREE.RepeatWrapping + }; + + var WEBGL_TEXTURE_FORMATS = { + 6406: THREE.AlphaFormat, + 6407: THREE.RGBFormat, + 6408: THREE.RGBAFormat, + 6409: THREE.LuminanceFormat, + 6410: THREE.LuminanceAlphaFormat + }; + + var WEBGL_TEXTURE_DATATYPES = { + 5121: THREE.UnsignedByteType, + 32819: THREE.UnsignedShort4444Type, + 32820: THREE.UnsignedShort5551Type, + 33635: THREE.UnsignedShort565Type + }; + + var WEBGL_SIDES = { + 1028: THREE.BackSide, // Culling front + 1029: THREE.FrontSide // Culling back + //1032: THREE.NoSide // Culling front and back, what to do? + }; + + var WEBGL_DEPTH_FUNCS = { + 512: THREE.NeverDepth, + 513: THREE.LessDepth, + 514: THREE.EqualDepth, + 515: THREE.LessEqualDepth, + 516: THREE.GreaterEqualDepth, + 517: THREE.NotEqualDepth, + 518: THREE.GreaterEqualDepth, + 519: THREE.AlwaysDepth + }; + + var WEBGL_BLEND_EQUATIONS = { + 32774: THREE.AddEquation, + 32778: THREE.SubtractEquation, + 32779: THREE.ReverseSubtractEquation + }; + + var WEBGL_BLEND_FUNCS = { + 0: THREE.ZeroFactor, + 1: THREE.OneFactor, + 768: THREE.SrcColorFactor, + 769: THREE.OneMinusSrcColorFactor, + 770: THREE.SrcAlphaFactor, + 771: THREE.OneMinusSrcAlphaFactor, + 772: THREE.DstAlphaFactor, + 773: THREE.OneMinusDstAlphaFactor, + 774: THREE.DstColorFactor, + 775: THREE.OneMinusDstColorFactor, + 776: THREE.SrcAlphaSaturateFactor + // The followings are not supported by Three.js yet + //32769: CONSTANT_COLOR, + //32770: ONE_MINUS_CONSTANT_COLOR, + //32771: CONSTANT_ALPHA, + //32772: ONE_MINUS_CONSTANT_COLOR + }; + + var WEBGL_TYPE_SIZES = { + 'SCALAR': 1, + 'VEC2': 2, + 'VEC3': 3, + 'VEC4': 4, + 'MAT2': 4, + 'MAT3': 9, + 'MAT4': 16 + }; + + var PATH_PROPERTIES = { + scale: 'scale', + translation: 'position', + rotation: 'quaternion' + }; + + var INTERPOLATION = { + LINEAR: THREE.InterpolateLinear, + STEP: THREE.InterpolateDiscrete + }; + + var STATES_ENABLES = { + 2884: 'CULL_FACE', + 2929: 'DEPTH_TEST', + 3042: 'BLEND', + 3089: 'SCISSOR_TEST', + 32823: 'POLYGON_OFFSET_FILL', + 32926: 'SAMPLE_ALPHA_TO_COVERAGE' + }; + + /* UTILITY FUNCTIONS */ + + function _each( object, callback, thisObj ) { + + if ( !object ) { + return Promise.resolve(); + } + + var results; + var fns = []; + + if ( Object.prototype.toString.call( object ) === '[object Array]' ) { + + results = []; + + var length = object.length; + + for ( var idx = 0; idx < length; idx ++ ) { + + var value = callback.call( thisObj || this, object[ idx ], idx ); + + if ( value ) { + + fns.push( value ); + + if ( value instanceof Promise ) { + + value.then( function( key, value ) { + + results[ key ] = value; + + }.bind( this, idx )); + + } else { + + results[ idx ] = value; + + } + + } + + } + + } else { + + results = {}; + + for ( var key in object ) { + + if ( object.hasOwnProperty( key ) ) { + + var value = callback.call( thisObj || this, object[ key ], key ); + + if ( value ) { + + fns.push( value ); + + if ( value instanceof Promise ) { + + value.then( function( key, value ) { + + results[ key ] = value; + + }.bind( this, key )); + + } else { + + results[ key ] = value; + + } + + } + + } + + } + + } + + return Promise.all( fns ).then( function() { + + return results; + + }); + + } + + function resolveURL( url, path ) { + + // Invalid URL + if ( typeof url !== 'string' || url === '' ) + return ''; + + // Absolute URL http://,https://,// + if ( /^(https?:)?\/\//i.test( url ) ) { + + return url; + + } + + // Data URI + if ( /^data:.*,.*$/i.test( url ) ) { + + return url; + + } + + // Blob URL + if ( /^blob:.*$/i.test( url ) ) { + + return url; + + } + + // Relative URL + return ( path || '' ) + url; + + } + + // Three.js seems too dependent on attribute names so globally + // replace those in the shader code + function replaceTHREEShaderAttributes( shaderText, technique ) { + + // Expected technique attributes + var attributes = {}; + + for ( var attributeId in technique.attributes ) { + + var pname = technique.attributes[ attributeId ]; + + var param = technique.parameters[ pname ]; + var atype = param.type; + var semantic = param.semantic; + + attributes[ attributeId ] = { + type: atype, + semantic: semantic + }; + + } + + // Figure out which attributes to change in technique + + var shaderParams = technique.parameters; + var shaderAttributes = technique.attributes; + var params = {}; + + for ( var attributeId in attributes ) { + + var pname = shaderAttributes[ attributeId ]; + var shaderParam = shaderParams[ pname ]; + var semantic = shaderParam.semantic; + if ( semantic ) { + + params[ attributeId ] = shaderParam; + + } + + } + + for ( var pname in params ) { + + var param = params[ pname ]; + var semantic = param.semantic; + + var regEx = new RegExp( "\\b" + pname + "\\b", "g" ); + + switch ( semantic ) { + + case "POSITION": + + shaderText = shaderText.replace( regEx, 'position' ); + break; + + case "NORMAL": + + shaderText = shaderText.replace( regEx, 'normal' ); + break; + + case 'TEXCOORD_0': + case 'TEXCOORD0': + case 'TEXCOORD': + + shaderText = shaderText.replace( regEx, 'uv' ); + break; + + case 'TEXCOORD_1': + + shaderText = shaderText.replace( regEx, 'uv2' ); + break; + + case 'COLOR_0': + case 'COLOR0': + case 'COLOR': + + shaderText = shaderText.replace( regEx, 'color' ); + break; + + case "WEIGHT": + + shaderText = shaderText.replace( regEx, 'skinWeight' ); + break; + + case "JOINT": + + shaderText = shaderText.replace( regEx, 'skinIndex' ); + break; + + } + + } + + return shaderText; + + } + + function createDefaultMaterial() { + + return new THREE.MeshPhongMaterial( { + color: 0x00000, + emissive: 0x888888, + specular: 0x000000, + shininess: 0, + transparent: false, + depthTest: true, + side: THREE.FrontSide + } ); + + } + + // Deferred constructor for RawShaderMaterial types + function DeferredShaderMaterial( params ) { + + this.isDeferredShaderMaterial = true; + + this.params = params; + + } + + DeferredShaderMaterial.prototype.create = function () { + + var uniforms = THREE.UniformsUtils.clone( this.params.uniforms ); + + for ( var uniformId in this.params.uniforms ) { + + var originalUniform = this.params.uniforms[ uniformId ]; + + if ( originalUniform.value instanceof THREE.Texture ) { + + uniforms[ uniformId ].value = originalUniform.value; + uniforms[ uniformId ].value.needsUpdate = true; + + } + + uniforms[ uniformId ].semantic = originalUniform.semantic; + uniforms[ uniformId ].node = originalUniform.node; + + } + + this.params.uniforms = uniforms; + + return new THREE.RawShaderMaterial( this.params ); + + }; + + /* GLTF PARSER */ + + function GLTFParser( json, extensions, options ) { + + this.json = json || {}; + this.extensions = extensions || {}; + this.options = options || {}; + + // loader object cache + this.cache = new GLTFRegistry(); + + } + + GLTFParser.prototype._withDependencies = function ( dependencies ) { + + var _dependencies = {}; + + for ( var i = 0; i < dependencies.length; i ++ ) { + + var dependency = dependencies[ i ]; + var fnName = "load" + dependency.charAt( 0 ).toUpperCase() + dependency.slice( 1 ); + + var cached = this.cache.get( dependency ); + + if ( cached !== undefined ) { + + _dependencies[ dependency ] = cached; + + } else if ( this[ fnName ] ) { + + var fn = this[ fnName ](); + this.cache.add( dependency, fn ); + + _dependencies[ dependency ] = fn; + + } + + } + + return _each( _dependencies, function ( dependency ) { + + return dependency; + + } ); + + }; + + GLTFParser.prototype.parse = function ( callback ) { + + var json = this.json; + + // Clear the loader cache + this.cache.removeAll(); + + // Fire the callback on complete + this._withDependencies( [ + + "scenes", + "cameras", + "animations" + + ] ).then( function ( dependencies ) { + + var scenes = []; + + for ( var name in dependencies.scenes ) { + + scenes.push( dependencies.scenes[ name ] ); + + } + + var scene = json.scene !== undefined ? dependencies.scenes[ json.scene ] : scenes[ 0 ]; + + var cameras = []; + + for ( var name in dependencies.cameras ) { + + var camera = dependencies.cameras[ name ]; + cameras.push( camera ); + + } + + var animations = []; + + for ( var name in dependencies.animations ) { + + animations.push( dependencies.animations[ name ] ); + + } + + callback( scene, scenes, cameras, animations ); + + } ); + + }; + + GLTFParser.prototype.loadShaders = function () { + + var json = this.json; + var extensions = this.extensions; + var options = this.options; + + return this._withDependencies( [ + + "bufferViews" + + ] ).then( function ( dependencies ) { + + return _each( json.shaders, function ( shader ) { + + if ( shader.extensions && shader.extensions[ EXTENSIONS.KHR_BINARY_GLTF ] ) { + + return extensions[ EXTENSIONS.KHR_BINARY_GLTF ].loadShader( shader, dependencies.bufferViews ); + + } + + return new Promise( function ( resolve ) { + + var loader = new THREE.FileLoader( options.manager ); + loader.setResponseType( 'text' ); + loader.load( resolveURL( shader.uri, options.path ), function ( shaderText ) { + + resolve( shaderText ); + + } ); + + } ); + + } ); + + } ); + + }; + + GLTFParser.prototype.loadBuffers = function () { + + var json = this.json; + var extensions = this.extensions; + var options = this.options; + + return _each( json.buffers, function ( buffer, name ) { + + if ( name === BINARY_EXTENSION_BUFFER_NAME ) { + + return extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body; + + } + + if ( buffer.type === 'arraybuffer' || buffer.type === undefined ) { + + return new Promise( function ( resolve ) { + + var loader = new THREE.FileLoader( options.manager ); + loader.setResponseType( 'arraybuffer' ); + loader.load( resolveURL( buffer.uri, options.path ), function ( buffer ) { + + resolve( buffer ); + + } ); + + } ); + + } else { + + console.warn( 'THREE.LegacyGLTFLoader: ' + buffer.type + ' buffer type is not supported' ); + + } + + } ); + + }; + + GLTFParser.prototype.loadBufferViews = function () { + + var json = this.json; + + return this._withDependencies( [ + + "buffers" + + ] ).then( function ( dependencies ) { + + return _each( json.bufferViews, function ( bufferView ) { + + var arraybuffer = dependencies.buffers[ bufferView.buffer ]; + + var byteLength = bufferView.byteLength !== undefined ? bufferView.byteLength : 0; + + return arraybuffer.slice( bufferView.byteOffset, bufferView.byteOffset + byteLength ); + + } ); + + } ); + + }; + + GLTFParser.prototype.loadAccessors = function () { + + var json = this.json; + + return this._withDependencies( [ + + "bufferViews" + + ] ).then( function ( dependencies ) { + + return _each( json.accessors, function ( accessor ) { + + var arraybuffer = dependencies.bufferViews[ accessor.bufferView ]; + var itemSize = WEBGL_TYPE_SIZES[ accessor.type ]; + var TypedArray = WEBGL_COMPONENT_TYPES[ accessor.componentType ]; + + // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12. + var elementBytes = TypedArray.BYTES_PER_ELEMENT; + var itemBytes = elementBytes * itemSize; + + // The buffer is not interleaved if the stride is the item size in bytes. + if ( accessor.byteStride && accessor.byteStride !== itemBytes ) { + + // Use the full buffer if it's interleaved. + var array = new TypedArray( arraybuffer ); + + // Integer parameters to IB/IBA are in array elements, not bytes. + var ib = new THREE.InterleavedBuffer( array, accessor.byteStride / elementBytes ); + + return new THREE.InterleavedBufferAttribute( ib, itemSize, accessor.byteOffset / elementBytes ); + + } else { + + array = new TypedArray( arraybuffer, accessor.byteOffset, accessor.count * itemSize ); + + return new THREE.BufferAttribute( array, itemSize ); + + } + + } ); + + } ); + + }; + + GLTFParser.prototype.loadTextures = function () { + + var json = this.json; + var extensions = this.extensions; + var options = this.options; + + return this._withDependencies( [ + + "bufferViews" + + ] ).then( function ( dependencies ) { + + return _each( json.textures, function ( texture ) { + + if ( texture.source ) { + + return new Promise( function ( resolve ) { + + var source = json.images[ texture.source ]; + var sourceUri = source.uri; + var isObjectURL = false; + + if ( source.extensions && source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ] ) { + + var metadata = source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ]; + var bufferView = dependencies.bufferViews[ metadata.bufferView ]; + var blob = new Blob( [ bufferView ], { type: metadata.mimeType } ); + sourceUri = URL.createObjectURL( blob ); + isObjectURL = true; + + } + + var textureLoader = THREE.Loader.Handlers.get( sourceUri ); + + if ( textureLoader === null ) { + + textureLoader = new THREE.TextureLoader( options.manager ); + + } + + textureLoader.setCrossOrigin( options.crossOrigin ); + + textureLoader.load( resolveURL( sourceUri, options.path ), function ( _texture ) { + + if ( isObjectURL ) URL.revokeObjectURL( sourceUri ); + + _texture.flipY = false; + + if ( texture.name !== undefined ) _texture.name = texture.name; + + _texture.format = texture.format !== undefined ? WEBGL_TEXTURE_FORMATS[ texture.format ] : THREE.RGBAFormat; + + if ( texture.internalFormat !== undefined && _texture.format !== WEBGL_TEXTURE_FORMATS[ texture.internalFormat ] ) { + + console.warn( 'THREE.LegacyGLTFLoader: Three.js doesn\'t support texture internalFormat which is different from texture format. ' + + 'internalFormat will be forced to be the same value as format.' ); + + } + + _texture.type = texture.type !== undefined ? WEBGL_TEXTURE_DATATYPES[ texture.type ] : THREE.UnsignedByteType; + + if ( texture.sampler ) { + + var sampler = json.samplers[ texture.sampler ]; + + _texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter; + _texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.NearestMipMapLinearFilter; + _texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping; + _texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping; + + } + + resolve( _texture ); + + }, undefined, function () { + + if ( isObjectURL ) URL.revokeObjectURL( sourceUri ); + + resolve(); + + } ); + + } ); + + } + + } ); + + } ); + + }; + + GLTFParser.prototype.loadMaterials = function () { + + var json = this.json; + + return this._withDependencies( [ + + "shaders", + "textures" + + ] ).then( function ( dependencies ) { + + return _each( json.materials, function ( material ) { + + var materialType; + var materialValues = {}; + var materialParams = {}; + + var khr_material; + + if ( material.extensions && material.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] ) { + + khr_material = material.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ]; + + } + + if ( khr_material ) { + + // don't copy over unused values to avoid material warning spam + var keys = [ 'ambient', 'emission', 'transparent', 'transparency', 'doubleSided' ]; + + switch ( khr_material.technique ) { + + case 'BLINN' : + case 'PHONG' : + materialType = THREE.MeshPhongMaterial; + keys.push( 'diffuse', 'specular', 'shininess' ); + break; + + case 'LAMBERT' : + materialType = THREE.MeshLambertMaterial; + keys.push( 'diffuse' ); + break; + + case 'CONSTANT' : + default : + materialType = THREE.MeshBasicMaterial; + break; + + } + + keys.forEach( function( v ) { + + if ( khr_material.values[ v ] !== undefined ) materialValues[ v ] = khr_material.values[ v ]; + + } ); + + if ( khr_material.doubleSided || materialValues.doubleSided ) { + + materialParams.side = THREE.DoubleSide; + + } + + if ( khr_material.transparent || materialValues.transparent ) { + + materialParams.transparent = true; + materialParams.opacity = ( materialValues.transparency !== undefined ) ? materialValues.transparency : 1; + + } + + } else if ( material.technique === undefined ) { + + materialType = THREE.MeshPhongMaterial; + + Object.assign( materialValues, material.values ); + + } else { + + materialType = DeferredShaderMaterial; + + var technique = json.techniques[ material.technique ]; + + materialParams.uniforms = {}; + + var program = json.programs[ technique.program ]; + + if ( program ) { + + materialParams.fragmentShader = dependencies.shaders[ program.fragmentShader ]; + + if ( ! materialParams.fragmentShader ) { + + console.warn( "ERROR: Missing fragment shader definition:", program.fragmentShader ); + materialType = THREE.MeshPhongMaterial; + + } + + var vertexShader = dependencies.shaders[ program.vertexShader ]; + + if ( ! vertexShader ) { + + console.warn( "ERROR: Missing vertex shader definition:", program.vertexShader ); + materialType = THREE.MeshPhongMaterial; + + } + + // IMPORTANT: FIX VERTEX SHADER ATTRIBUTE DEFINITIONS + materialParams.vertexShader = replaceTHREEShaderAttributes( vertexShader, technique ); + + var uniforms = technique.uniforms; + + for ( var uniformId in uniforms ) { + + var pname = uniforms[ uniformId ]; + var shaderParam = technique.parameters[ pname ]; + + var ptype = shaderParam.type; + + if ( WEBGL_TYPE[ ptype ] ) { + + var pcount = shaderParam.count; + var value; + + if ( material.values !== undefined ) value = material.values[ pname ]; + + var uvalue = new WEBGL_TYPE[ ptype ](); + var usemantic = shaderParam.semantic; + var unode = shaderParam.node; + + switch ( ptype ) { + + case WEBGL_CONSTANTS.FLOAT: + + uvalue = shaderParam.value; + + if ( pname == "transparency" ) { + + materialParams.transparent = true; + + } + + if ( value !== undefined ) { + + uvalue = value; + + } + + break; + + case WEBGL_CONSTANTS.FLOAT_VEC2: + case WEBGL_CONSTANTS.FLOAT_VEC3: + case WEBGL_CONSTANTS.FLOAT_VEC4: + case WEBGL_CONSTANTS.FLOAT_MAT3: + + if ( shaderParam && shaderParam.value ) { + + uvalue.fromArray( shaderParam.value ); + + } + + if ( value ) { + + uvalue.fromArray( value ); + + } + + break; + + case WEBGL_CONSTANTS.FLOAT_MAT2: + + // what to do? + console.warn( "FLOAT_MAT2 is not a supported uniform type" ); + break; + + case WEBGL_CONSTANTS.FLOAT_MAT4: + + if ( pcount ) { + + uvalue = new Array( pcount ); + + for ( var mi = 0; mi < pcount; mi ++ ) { + + uvalue[ mi ] = new WEBGL_TYPE[ ptype ](); + + } + + if ( shaderParam && shaderParam.value ) { + + var m4v = shaderParam.value; + uvalue.fromArray( m4v ); + + } + + if ( value ) { + + uvalue.fromArray( value ); + + } + + } else { + + if ( shaderParam && shaderParam.value ) { + + var m4 = shaderParam.value; + uvalue.fromArray( m4 ); + + } + + if ( value ) { + + uvalue.fromArray( value ); + + } + + } + + break; + + case WEBGL_CONSTANTS.SAMPLER_2D: + + if ( value !== undefined ) { + + uvalue = dependencies.textures[ value ]; + + } else if ( shaderParam.value !== undefined ) { + + uvalue = dependencies.textures[ shaderParam.value ]; + + } else { + + uvalue = null; + + } + + break; + + } + + materialParams.uniforms[ uniformId ] = { + value: uvalue, + semantic: usemantic, + node: unode + }; + + } else { + + throw new Error( "Unknown shader uniform param type: " + ptype ); + + } + + } + + var states = technique.states || {}; + var enables = states.enable || []; + var functions = states.functions || {}; + + var enableCullFace = false; + var enableDepthTest = false; + var enableBlend = false; + + for ( var i = 0, il = enables.length; i < il; i ++ ) { + + var enable = enables[ i ]; + + switch ( STATES_ENABLES[ enable ] ) { + + case 'CULL_FACE': + + enableCullFace = true; + + break; + + case 'DEPTH_TEST': + + enableDepthTest = true; + + break; + + case 'BLEND': + + enableBlend = true; + + break; + + // TODO: implement + case 'SCISSOR_TEST': + case 'POLYGON_OFFSET_FILL': + case 'SAMPLE_ALPHA_TO_COVERAGE': + + break; + + default: + + throw new Error( "Unknown technique.states.enable: " + enable ); + + } + + } + + if ( enableCullFace ) { + + materialParams.side = functions.cullFace !== undefined ? WEBGL_SIDES[ functions.cullFace ] : THREE.FrontSide; + + } else { + + materialParams.side = THREE.DoubleSide; + + } + + materialParams.depthTest = enableDepthTest; + materialParams.depthFunc = functions.depthFunc !== undefined ? WEBGL_DEPTH_FUNCS[ functions.depthFunc ] : THREE.LessDepth; + materialParams.depthWrite = functions.depthMask !== undefined ? functions.depthMask[ 0 ] : true; + + materialParams.blending = enableBlend ? THREE.CustomBlending : THREE.NoBlending; + materialParams.transparent = enableBlend; + + var blendEquationSeparate = functions.blendEquationSeparate; + + if ( blendEquationSeparate !== undefined ) { + + materialParams.blendEquation = WEBGL_BLEND_EQUATIONS[ blendEquationSeparate[ 0 ] ]; + materialParams.blendEquationAlpha = WEBGL_BLEND_EQUATIONS[ blendEquationSeparate[ 1 ] ]; + + } else { + + materialParams.blendEquation = THREE.AddEquation; + materialParams.blendEquationAlpha = THREE.AddEquation; + + } + + var blendFuncSeparate = functions.blendFuncSeparate; + + if ( blendFuncSeparate !== undefined ) { + + materialParams.blendSrc = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 0 ] ]; + materialParams.blendDst = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 1 ] ]; + materialParams.blendSrcAlpha = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 2 ] ]; + materialParams.blendDstAlpha = WEBGL_BLEND_FUNCS[ blendFuncSeparate[ 3 ] ]; + + } else { + + materialParams.blendSrc = THREE.OneFactor; + materialParams.blendDst = THREE.ZeroFactor; + materialParams.blendSrcAlpha = THREE.OneFactor; + materialParams.blendDstAlpha = THREE.ZeroFactor; + + } + + } + + } + + if ( Array.isArray( materialValues.diffuse ) ) { + + materialParams.color = new THREE.Color().fromArray( materialValues.diffuse ); + + } else if ( typeof( materialValues.diffuse ) === 'string' ) { + + materialParams.map = dependencies.textures[ materialValues.diffuse ]; + + } + + delete materialParams.diffuse; + + if ( typeof( materialValues.reflective ) === 'string' ) { + + materialParams.envMap = dependencies.textures[ materialValues.reflective ]; + + } + + if ( typeof( materialValues.bump ) === 'string' ) { + + materialParams.bumpMap = dependencies.textures[ materialValues.bump ]; + + } + + if ( Array.isArray( materialValues.emission ) ) { + + if ( materialType === THREE.MeshBasicMaterial ) { + + materialParams.color = new THREE.Color().fromArray( materialValues.emission ); + + } else { + + materialParams.emissive = new THREE.Color().fromArray( materialValues.emission ); + + } + + } else if ( typeof( materialValues.emission ) === 'string' ) { + + if ( materialType === THREE.MeshBasicMaterial ) { + + materialParams.map = dependencies.textures[ materialValues.emission ]; + + } else { + + materialParams.emissiveMap = dependencies.textures[ materialValues.emission ]; + + } + + } + + if ( Array.isArray( materialValues.specular ) ) { + + materialParams.specular = new THREE.Color().fromArray( materialValues.specular ); + + } else if ( typeof( materialValues.specular ) === 'string' ) { + + materialParams.specularMap = dependencies.textures[ materialValues.specular ]; + + } + + if ( materialValues.shininess !== undefined ) { + + materialParams.shininess = materialValues.shininess; + + } + + var _material = new materialType( materialParams ); + if ( material.name !== undefined ) _material.name = material.name; + + return _material; + + } ); + + } ); + + }; + + GLTFParser.prototype.loadMeshes = function () { + + var json = this.json; + + return this._withDependencies( [ + + "accessors", + "materials" + + ] ).then( function ( dependencies ) { + + return _each( json.meshes, function ( mesh ) { + + var group = new THREE.Group(); + if ( mesh.name !== undefined ) group.name = mesh.name; + + if ( mesh.extras ) group.userData = mesh.extras; + + var primitives = mesh.primitives || []; + + for ( var name in primitives ) { + + var primitive = primitives[ name ]; + + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === undefined ) { + + var geometry = new THREE.BufferGeometry(); + + var attributes = primitive.attributes; + + for ( var attributeId in attributes ) { + + var attributeEntry = attributes[ attributeId ]; + + if ( ! attributeEntry ) return; + + var bufferAttribute = dependencies.accessors[ attributeEntry ]; + + switch ( attributeId ) { + + case 'POSITION': + geometry.addAttribute( 'position', bufferAttribute ); + break; + + case 'NORMAL': + geometry.addAttribute( 'normal', bufferAttribute ); + break; + + case 'TEXCOORD_0': + case 'TEXCOORD0': + case 'TEXCOORD': + geometry.addAttribute( 'uv', bufferAttribute ); + break; + + case 'TEXCOORD_1': + geometry.addAttribute( 'uv2', bufferAttribute ); + break; + + case 'COLOR_0': + case 'COLOR0': + case 'COLOR': + geometry.addAttribute( 'color', bufferAttribute ); + break; + + case 'WEIGHT': + geometry.addAttribute( 'skinWeight', bufferAttribute ); + break; + + case 'JOINT': + geometry.addAttribute( 'skinIndex', bufferAttribute ); + break; + + default: + + if ( ! primitive.material ) break; + + var material = json.materials[ primitive.material ]; + + if ( ! material.technique ) break; + + var parameters = json.techniques[ material.technique ].parameters || {}; + + for( var attributeName in parameters ) { + + if ( parameters [ attributeName ][ 'semantic' ] === attributeId ) { + + geometry.addAttribute( attributeName, bufferAttribute ); + + } + + } + + } + + } + + if ( primitive.indices ) { + + geometry.setIndex( dependencies.accessors[ primitive.indices ] ); + + } + + var material = dependencies.materials !== undefined ? dependencies.materials[ primitive.material ] : createDefaultMaterial(); + + var meshNode = new THREE.Mesh( geometry, material ); + meshNode.castShadow = true; + meshNode.name = ( name === "0" ? group.name : group.name + name ); + + if ( primitive.extras ) meshNode.userData = primitive.extras; + + group.add( meshNode ); + + } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) { + + var geometry = new THREE.BufferGeometry(); + + var attributes = primitive.attributes; + + for ( var attributeId in attributes ) { + + var attributeEntry = attributes[ attributeId ]; + + if ( ! attributeEntry ) return; + + var bufferAttribute = dependencies.accessors[ attributeEntry ]; + + switch ( attributeId ) { + + case 'POSITION': + geometry.addAttribute( 'position', bufferAttribute ); + break; + + case 'COLOR_0': + case 'COLOR0': + case 'COLOR': + geometry.addAttribute( 'color', bufferAttribute ); + break; + + } + + } + + var material = dependencies.materials[ primitive.material ]; + + var meshNode; + + if ( primitive.indices ) { + + geometry.setIndex( dependencies.accessors[ primitive.indices ] ); + + meshNode = new THREE.LineSegments( geometry, material ); + + } else { + + meshNode = new THREE.Line( geometry, material ); + + } + + meshNode.name = ( name === "0" ? group.name : group.name + name ); + + if ( primitive.extras ) meshNode.userData = primitive.extras; + + group.add( meshNode ); + + } else { + + console.warn( "Only triangular and line primitives are supported" ); + + } + + } + + return group; + + } ); + + } ); + + }; + + GLTFParser.prototype.loadCameras = function () { + + var json = this.json; + + return _each( json.cameras, function ( camera ) { + + if ( camera.type == "perspective" && camera.perspective ) { + + var yfov = camera.perspective.yfov; + var aspectRatio = camera.perspective.aspectRatio !== undefined ? camera.perspective.aspectRatio : 1; + + // According to COLLADA spec... + // aspectRatio = xfov / yfov + var xfov = yfov * aspectRatio; + + var _camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspectRatio, camera.perspective.znear || 1, camera.perspective.zfar || 2e6 ); + if ( camera.name !== undefined ) _camera.name = camera.name; + + if ( camera.extras ) _camera.userData = camera.extras; + + return _camera; + + } else if ( camera.type == "orthographic" && camera.orthographic ) { + + var _camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, camera.orthographic.znear, camera.orthographic.zfar ); + if ( camera.name !== undefined ) _camera.name = camera.name; + + if ( camera.extras ) _camera.userData = camera.extras; + + return _camera; + + } + + } ); + + }; + + GLTFParser.prototype.loadSkins = function () { + + var json = this.json; + + return this._withDependencies( [ + + "accessors" + + ] ).then( function ( dependencies ) { + + return _each( json.skins, function ( skin ) { + + var bindShapeMatrix = new THREE.Matrix4(); + + if ( skin.bindShapeMatrix !== undefined ) bindShapeMatrix.fromArray( skin.bindShapeMatrix ); + + var _skin = { + bindShapeMatrix: bindShapeMatrix, + jointNames: skin.jointNames, + inverseBindMatrices: dependencies.accessors[ skin.inverseBindMatrices ] + }; + + return _skin; + + } ); + + } ); + + }; + + GLTFParser.prototype.loadAnimations = function () { + + var json = this.json; + + return this._withDependencies( [ + + "accessors", + "nodes" + + ] ).then( function ( dependencies ) { + + return _each( json.animations, function ( animation, animationId ) { + + var tracks = []; + + for ( var channelId in animation.channels ) { + + var channel = animation.channels[ channelId ]; + var sampler = animation.samplers[ channel.sampler ]; + + if ( sampler ) { + + var target = channel.target; + var name = target.id; + var input = animation.parameters !== undefined ? animation.parameters[ sampler.input ] : sampler.input; + var output = animation.parameters !== undefined ? animation.parameters[ sampler.output ] : sampler.output; + + var inputAccessor = dependencies.accessors[ input ]; + var outputAccessor = dependencies.accessors[ output ]; + + var node = dependencies.nodes[ name ]; + + if ( node ) { + + node.updateMatrix(); + node.matrixAutoUpdate = true; + + var TypedKeyframeTrack = PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.rotation + ? THREE.QuaternionKeyframeTrack + : THREE.VectorKeyframeTrack; + + var targetName = node.name ? node.name : node.uuid; + var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear; + + // KeyframeTrack.optimize() will modify given 'times' and 'values' + // buffers before creating a truncated copy to keep. Because buffers may + // be reused by other tracks, make copies here. + tracks.push( new TypedKeyframeTrack( + targetName + '.' + PATH_PROPERTIES[ target.path ], + THREE.AnimationUtils.arraySlice( inputAccessor.array, 0 ), + THREE.AnimationUtils.arraySlice( outputAccessor.array, 0 ), + interpolation + ) ); + + } + + } + + } + + var name = animation.name !== undefined ? animation.name : "animation_" + animationId; + + return new THREE.AnimationClip( name, undefined, tracks ); + + } ); + + } ); + + }; + + GLTFParser.prototype.loadNodes = function () { + + var json = this.json; + var extensions = this.extensions; + var scope = this; + + return _each( json.nodes, function ( node ) { + + var matrix = new THREE.Matrix4(); + + var _node; + + if ( node.jointName ) { + + _node = new THREE.Bone(); + _node.name = node.name !== undefined ? node.name : node.jointName; + _node.jointName = node.jointName; + + } else { + + _node = new THREE.Object3D(); + if ( node.name !== undefined ) _node.name = node.name; + + } + + if ( node.extras ) _node.userData = node.extras; + + if ( node.matrix !== undefined ) { + + matrix.fromArray( node.matrix ); + _node.applyMatrix( matrix ); + + } else { + + if ( node.translation !== undefined ) { + + _node.position.fromArray( node.translation ); + + } + + if ( node.rotation !== undefined ) { + + _node.quaternion.fromArray( node.rotation ); + + } + + if ( node.scale !== undefined ) { + + _node.scale.fromArray( node.scale ); + + } + + } + + return _node; + + } ).then( function ( __nodes ) { + + return scope._withDependencies( [ + + "meshes", + "skins", + "cameras" + + ] ).then( function ( dependencies ) { + + return _each( __nodes, function ( _node, nodeId ) { + + var node = json.nodes[ nodeId ]; + + if ( node.meshes !== undefined ) { + + for ( var meshId in node.meshes ) { + + var mesh = node.meshes[ meshId ]; + var group = dependencies.meshes[ mesh ]; + + if ( group === undefined ) { + + console.warn( 'LegacyGLTFLoader: Couldn\'t find node "' + mesh + '".' ); + continue; + + } + + for ( var childrenId in group.children ) { + + var child = group.children[ childrenId ]; + + // clone Mesh to add to _node + + var originalMaterial = child.material; + var originalGeometry = child.geometry; + var originalUserData = child.userData; + var originalName = child.name; + + var material; + + if ( originalMaterial.isDeferredShaderMaterial ) { + + originalMaterial = material = originalMaterial.create(); + + } else { + + material = originalMaterial; + + } + + switch ( child.type ) { + + case 'LineSegments': + child = new THREE.LineSegments( originalGeometry, material ); + break; + + case 'LineLoop': + child = new THREE.LineLoop( originalGeometry, material ); + break; + + case 'Line': + child = new THREE.Line( originalGeometry, material ); + break; + + default: + child = new THREE.Mesh( originalGeometry, material ); + + } + + child.castShadow = true; + child.userData = originalUserData; + child.name = originalName; + + var skinEntry; + + if ( node.skin ) { + + skinEntry = dependencies.skins[ node.skin ]; + + } + + // Replace Mesh with SkinnedMesh in library + if ( skinEntry ) { + + var getJointNode = function ( jointId ) { + + var keys = Object.keys( __nodes ); + + for ( var i = 0, il = keys.length; i < il; i ++ ) { + + var n = __nodes[ keys[ i ] ]; + + if ( n.jointName === jointId ) return n; + + } + + return null; + + }; + + var geometry = originalGeometry; + var material = originalMaterial; + material.skinning = true; + + child = new THREE.SkinnedMesh( geometry, material ); + child.castShadow = true; + child.userData = originalUserData; + child.name = originalName; + + var bones = []; + var boneInverses = []; + + for ( var i = 0, l = skinEntry.jointNames.length; i < l; i ++ ) { + + var jointId = skinEntry.jointNames[ i ]; + var jointNode = getJointNode( jointId ); + + if ( jointNode ) { + + bones.push( jointNode ); + + var m = skinEntry.inverseBindMatrices.array; + var mat = new THREE.Matrix4().fromArray( m, i * 16 ); + boneInverses.push( mat ); + + } else { + + console.warn( "WARNING: joint: '" + jointId + "' could not be found" ); + + } + + } + + child.bind( new THREE.Skeleton( bones, boneInverses ), skinEntry.bindShapeMatrix ); + + var buildBoneGraph = function ( parentJson, parentObject, property ) { + + var children = parentJson[ property ]; + + if ( children === undefined ) return; + + for ( var i = 0, il = children.length; i < il; i ++ ) { + + var nodeId = children[ i ]; + var bone = __nodes[ nodeId ]; + var boneJson = json.nodes[ nodeId ]; + + if ( bone !== undefined && bone.isBone === true && boneJson !== undefined ) { + + parentObject.add( bone ); + buildBoneGraph( boneJson, bone, 'children' ); + + } + + } + + }; + + buildBoneGraph( node, child, 'skeletons' ); + + } + + _node.add( child ); + + } + + } + + } + + if ( node.camera !== undefined ) { + + var camera = dependencies.cameras[ node.camera ]; + + _node.add( camera ); + + } + + if ( node.extensions + && node.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ] + && node.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ].light ) { + + var extensionLights = extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ].lights; + var light = extensionLights[ node.extensions[ EXTENSIONS.KHR_MATERIALS_COMMON ].light ]; + + _node.add( light ); + + } + + return _node; + + } ); + + } ); + + } ); + + }; + + GLTFParser.prototype.loadScenes = function () { + + var json = this.json; + + // scene node hierachy builder + + function buildNodeHierachy( nodeId, parentObject, allNodes ) { + + var _node = allNodes[ nodeId ]; + parentObject.add( _node ); + + var node = json.nodes[ nodeId ]; + + if ( node.children ) { + + var children = node.children; + + for ( var i = 0, l = children.length; i < l; i ++ ) { + + var child = children[ i ]; + buildNodeHierachy( child, _node, allNodes ); + + } + + } + + } + + return this._withDependencies( [ + + "nodes" + + ] ).then( function ( dependencies ) { + + return _each( json.scenes, function ( scene ) { + + var _scene = new THREE.Scene(); + if ( scene.name !== undefined ) _scene.name = scene.name; + + if ( scene.extras ) _scene.userData = scene.extras; + + var nodes = scene.nodes || []; + + for ( var i = 0, l = nodes.length; i < l; i ++ ) { + + var nodeId = nodes[ i ]; + buildNodeHierachy( nodeId, _scene, dependencies.nodes ); + + } + + _scene.traverse( function ( child ) { + + // Register raw material meshes with LegacyGLTFLoader.Shaders + if ( child.material && child.material.isRawShaderMaterial ) { + + child.gltfShader = new GLTFShader( child, dependencies.nodes ); + child.onBeforeRender = function(renderer, scene, camera){ + this.gltfShader.update(scene, camera); + }; + + } + + } ); + + return _scene; + + } ); + + } ); + + }; + + return LegacyGLTFLoader; + +} )(); diff --git a/three/jsutil/loaders/sea3d/SEA3D.js b/three/jsutil/loaders/sea3d/SEA3D.js new file mode 100644 index 000000000..1a9ae6a63 --- /dev/null +++ b/three/jsutil/loaders/sea3d/SEA3D.js @@ -0,0 +1,3309 @@ +/** + * SEA3D SDK + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +var SEA3D = { VERSION: 18110 }; + +SEA3D.getVersion = function () { + + // Max = 16777215 - VV.S.S.BB | V = Version | S = Subversion | B = Buildversion + var v = SEA3D.VERSION.toString(), l = v.length; + return v.substring( 0, l - 4 ) + "." + v.substring( l - 4, l - 3 ) + "." + v.substring( l - 3, l - 2 ) + "." + parseFloat( v.substring( l - 2, l ) ).toString(); + +}; + +console.log( 'SEA3D ' + SEA3D.getVersion() ); + +// +// STREAM : STANDARD DATA-IO ( LITTLE-ENDIAN ) +// + +SEA3D.Stream = function ( buffer ) { + + this.position = 0; + this.buffer = buffer || new ArrayBuffer(); + +}; + +SEA3D.Stream.NONE = 0; + +// 1D = 0 at 31 +SEA3D.Stream.BOOLEAN = 1; + +SEA3D.Stream.BYTE = 2; +SEA3D.Stream.UBYTE = 3; + +SEA3D.Stream.SHORT = 4; +SEA3D.Stream.USHORT = 5; + +SEA3D.Stream.INT24 = 6; +SEA3D.Stream.UINT24 = 7; + +SEA3D.Stream.INT = 8; +SEA3D.Stream.UINT = 9; + +SEA3D.Stream.FLOAT = 10; +SEA3D.Stream.DOUBLE = 11; +SEA3D.Stream.DECIMAL = 12; + +// 2D = 32 at 63 + +// 3D = 64 at 95 +SEA3D.Stream.VECTOR3D = 74; + +// 4D = 96 at 127 +SEA3D.Stream.VECTOR4D = 106; + +// Undefined Size = 128 at 255 +SEA3D.Stream.STRING_TINY = 128; +SEA3D.Stream.STRING_SHORT = 129; +SEA3D.Stream.STRING_LONG = 130; + +SEA3D.Stream.ASSET = 200; +SEA3D.Stream.GROUP = 255; + +SEA3D.Stream.BLEND_MODE = [ + "normal", "add", "subtract", "multiply", "dividing", "mix", "alpha", "screen", "darken", + "overlay", "colorburn", "linearburn", "lighten", "colordodge", "lineardodge", + "softlight", "hardlight", "pinlight", "spotlight", "spotlightblend", "hardmix", + "average", "difference", "exclusion", "hue", "saturation", "color", "value", + "linearlight", "grainextract", "reflect", "glow", "darkercolor", "lightercolor", "phoenix", "negation" +]; + +SEA3D.Stream.INTERPOLATION_TABLE = [ + "normal", "linear", + "sine.in", "sine.out", "sine.inout", + "cubic.in", "cubic.out", "cubic.inout", + "quint.in", "quint.out", "quint.inout", + "circ.in", "circ.out", "circ.inout", + "back.in", "back.out", "back.inout", + "quad.in", "quad.out", "quad.inout", + "quart.in", "quart.out", "quart.inout", + "expo.in", "expo.out", "expo.inout", + "elastic.in", "elastic.out", "elastic.inout", + "bounce.in", "bounce.out", "bounce.inout" +]; + +SEA3D.Stream.sizeOf = function ( kind ) { + + if ( kind == 0 ) return 0; + else if ( kind >= 1 && kind <= 31 ) return 1; + else if ( kind >= 32 && kind <= 63 ) return 2; + else if ( kind >= 64 && kind <= 95 ) return 3; + else if ( kind >= 96 && kind <= 125 ) return 4; + return - 1; + +}; + +SEA3D.Stream.prototype = { + + constructor: SEA3D.Stream, + + set buffer( val ) { + + this.buf = val; + this.data = new DataView( val ); + + }, + + get buffer() { + + return this.buf; + + }, + + get bytesAvailable() { + + return this.length - this.position; + + }, + + get length() { + + return this.buf.byteLength; + + } + +}; + +SEA3D.Stream.prototype.getByte = function ( pos ) { + + return this.data.getInt8( pos ); + +}; + +SEA3D.Stream.prototype.readBytes = function ( len ) { + + var buf = this.buf.slice( this.position, this.position + len ); + this.position += len; + return buf; + +}; + +SEA3D.Stream.prototype.readByte = function () { + + return this.data.getInt8( this.position ++ ); + +}; + +SEA3D.Stream.prototype.readUByte = function () { + + return this.data.getUint8( this.position ++ ); + +}; + +SEA3D.Stream.prototype.readBool = function () { + + return this.data.getInt8( this.position ++ ) != 0; + +}; + +SEA3D.Stream.prototype.readShort = function () { + + var v = this.data.getInt16( this.position, true ); + this.position += 2; + return v; + +}; + +SEA3D.Stream.prototype.readUShort = function () { + + var v = this.data.getUint16( this.position, true ); + this.position += 2; + return v; + +}; + +SEA3D.Stream.prototype.readUInt24 = function () { + + var v = this.data.getUint32( this.position, true ) & 0xFFFFFF; + this.position += 3; + return v; + +}; + +SEA3D.Stream.prototype.readUInt24F = function () { + + return this.readUShort() | ( this.readUByte() << 16 ); + +}; + +SEA3D.Stream.prototype.readInt = function () { + + var v = this.data.getInt32( this.position, true ); + this.position += 4; + return v; + +}; + +SEA3D.Stream.prototype.readUInt = function () { + + var v = this.data.getUint32( this.position, true ); + this.position += 4; + return v; + +}; + +SEA3D.Stream.prototype.readFloat = function () { + + var v = this.data.getFloat32( this.position, true ); + this.position += 4; + return v; + +}; + +SEA3D.Stream.prototype.readUInteger = function () { + + var v = this.readUByte(), + r = v & 0x7F; + + if ( ( v & 0x80 ) != 0 ) { + + v = this.readUByte(); + r |= ( v & 0x7F ) << 7; + + if ( ( v & 0x80 ) != 0 ) { + + v = this.readUByte(); + r |= ( v & 0x7F ) << 13; + + } + + } + + return r; + +}; + +SEA3D.Stream.prototype.readVector2 = function () { + + return { x: this.readFloat(), y: this.readFloat() }; + +}; + +SEA3D.Stream.prototype.readVector3 = function () { + + return { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() }; + +}; + +SEA3D.Stream.prototype.readVector4 = function () { + + return { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), w: this.readFloat() }; + +}; + +SEA3D.Stream.prototype.readMatrix = function () { + + var mtx = new Float32Array( 16 ); + + mtx[ 0 ] = this.readFloat(); + mtx[ 1 ] = this.readFloat(); + mtx[ 2 ] = this.readFloat(); + mtx[ 3 ] = 0.0; + mtx[ 4 ] = this.readFloat(); + mtx[ 5 ] = this.readFloat(); + mtx[ 6 ] = this.readFloat(); + mtx[ 7 ] = 0.0; + mtx[ 8 ] = this.readFloat(); + mtx[ 9 ] = this.readFloat(); + mtx[ 10 ] = this.readFloat(); + mtx[ 11 ] = 0.0; + mtx[ 12 ] = this.readFloat(); + mtx[ 13 ] = this.readFloat(); + mtx[ 14 ] = this.readFloat(); + mtx[ 15 ] = 1.0; + + return mtx; + +}; + +SEA3D.Stream.prototype.readUTF8 = function ( len ) { + + var buffer = this.readBytes( len ); + + return THREE.LoaderUtils.decodeText( new Uint8Array( buffer ) ); + +}; + +SEA3D.Stream.prototype.readExt = function () { + + return this.readUTF8( 4 ).replace( /\0/g, "" ); + +}; + +SEA3D.Stream.prototype.readUTF8Tiny = function () { + + return this.readUTF8( this.readUByte() ); + +}; + +SEA3D.Stream.prototype.readUTF8Short = function () { + + return this.readUTF8( this.readUShort() ); + +}; + +SEA3D.Stream.prototype.readUTF8Long = function () { + + return this.readUTF8( this.readUInt() ); + +}; + +SEA3D.Stream.prototype.readUByteArray = function ( length ) { + + var v = new Uint8Array( length ); + + SEA3D.Stream.memcpy( + v.buffer, + 0, + this.buffer, + this.position, + length + ); + + this.position += length; + + return v; + +}; + +SEA3D.Stream.prototype.readUShortArray = function ( length ) { + + var v = new Uint16Array( length ), + len = length * 2; + + SEA3D.Stream.memcpy( + v.buffer, + 0, + this.buffer, + this.position, + len + ); + + this.position += len; + + return v; + +}; + + +SEA3D.Stream.prototype.readUInt24Array = function ( length ) { + + var v = new Uint32Array( length ); + + for ( var i = 0; i < length; i ++ ) { + + v[ i ] = this.readUInt24(); + + } + + return v; + +}; + + +SEA3D.Stream.prototype.readUIntArray = function ( length ) { + + var v = new Uint32Array( length ), + len = length * 4; + + SEA3D.Stream.memcpy( + v.buffer, + 0, + this.buffer, + this.position, + len + ); + + this.position += len; + + return v; + +}; + +SEA3D.Stream.prototype.readFloatArray = function ( length ) { + + var v = new Float32Array( length ), + len = length * 4; + + SEA3D.Stream.memcpy( + v.buffer, + 0, + this.buffer, + this.position, + len + ); + + this.position += len; + + return v; + +}; + + +SEA3D.Stream.prototype.readBlendMode = function () { + + return SEA3D.Stream.BLEND_MODE[ this.readUByte() ]; + +}; + +SEA3D.Stream.prototype.readInterpolation = function () { + + return SEA3D.Stream.INTERPOLATION_TABLE[ this.readUByte() ]; + +}; + +SEA3D.Stream.prototype.readTags = function ( callback ) { + + var numTag = this.readUByte(); + + for ( var i = 0; i < numTag; ++ i ) { + + var kind = this.readUShort(); + var size = this.readUInt(); + var pos = this.position; + + callback( kind, this, size ); + + this.position = pos += size; + + } + +}; + +SEA3D.Stream.prototype.readProperties = function ( sea3d ) { + + var count = this.readUByte(), + props = {}, types = {}; + + props.__type = types; + + for ( var i = 0; i < count; i ++ ) { + + var name = this.readUTF8Tiny(), + type = this.readUByte(); + + types[ name ] = type; + props[ name ] = type == SEA3D.Stream.GROUP ? this.readProperties( sea3d ) : this.readToken( type, sea3d ); + + } + + return props; + +}; + +SEA3D.Stream.prototype.readAnimationList = function ( sea3d ) { + + var list = [], + count = this.readUByte(); + + var i = 0; + while ( i < count ) { + + var attrib = this.readUByte(), + anm = {}; + + anm.relative = ( attrib & 1 ) != 0; + + if ( attrib & 2 ) anm.timeScale = this.readFloat(); + + anm.tag = sea3d.getObject( this.readUInt() ); + + list[ i ++ ] = anm; + + } + + return list; + +}; + +SEA3D.Stream.prototype.readScriptList = function ( sea3d ) { + + var list = [], + count = this.readUByte(); + + var i = 0; + while ( i < count ) { + + var attrib = this.readUByte(), + script = {}; + + script.priority = ( attrib & 1 ) | ( attrib & 2 ); + + if ( attrib & 4 ) { + + var numParams = this.readUByte(); + + script.params = {}; + + for ( var j = 0; j < numParams; j ++ ) { + + var name = this.readUTF8Tiny(); + + script.params[ name ] = this.readObject( sea3d ); + + } + + } + + if ( attrib & 8 ) { + + script.method = this.readUTF8Tiny(); + + } + + script.tag = sea3d.getObject( this.readUInt() ); + + list[ i ++ ] = script; + + } + + return list; + +}; + +SEA3D.Stream.prototype.readObject = function ( sea3d ) { + + return this.readToken( this.readUByte(), sea3d ); + +}; + +SEA3D.Stream.prototype.readToken = function ( type, sea3d ) { + + switch ( type ) { + + // 1D + case SEA3D.Stream.BOOLEAN: + return this.readBool(); + break; + + case SEA3D.Stream.UBYTE: + return this.readUByte(); + break; + + case SEA3D.Stream.USHORT: + return this.readUShort(); + break; + + case SEA3D.Stream.UINT24: + return this.readUInt24(); + break; + + case SEA3D.Stream.INT: + return this.readInt(); + break; + + case SEA3D.Stream.UINT: + return this.readUInt(); + break; + + case SEA3D.Stream.FLOAT: + return this.readFloat(); + break; + + // 3D + case SEA3D.Stream.VECTOR3D: + return this.readVector3(); + break; + + // 4D + case SEA3D.Stream.VECTOR4D: + return this.readVector4(); + break; + + // Undefined Values + case SEA3D.Stream.STRING_TINY: + return this.readUTF8Tiny(); + break; + + case SEA3D.Stream.STRING_SHORT: + return this.readUTF8Short(); + break; + + case SEA3D.Stream.STRING_LONG: + return this.readUTF8Long(); + break; + + case SEA3D.Stream.ASSET: + var asset = this.readUInt(); + return asset > 0 ? sea3d.getObject( asset - 1 ) : null; + break; + + default: + console.error( "DataType not found!" ); + + } + + return null; + +}; + +SEA3D.Stream.prototype.readVector = function ( type, length, offset ) { + + var size = SEA3D.Stream.sizeOf( type ), + i = offset * size, + count = i + ( length * size ); + + switch ( type ) { + + // 1D + case SEA3D.Stream.BOOLEAN: + + return this.readUByteArray( count ); + + + case SEA3D.Stream.UBYTE: + + return this.readUByteArray( count ); + + + case SEA3D.Stream.USHORT: + + return this.readUShortArray( count ); + + + case SEA3D.Stream.UINT24: + + return this.readUInt24Array( count ); + + + case SEA3D.Stream.UINT: + + return this.readUIntArray( count ); + + + case SEA3D.Stream.FLOAT: + + return this.readFloatArray( count ); + + + // 3D + case SEA3D.Stream.VECTOR3D: + + return this.readFloatArray( count ); + + + // 4D + case SEA3D.Stream.VECTOR4D: + + return this.readFloatArray( count ); + + } + +}; + +SEA3D.Stream.prototype.append = function ( data ) { + + var buffer = new ArrayBuffer( this.data.byteLength + data.byteLength ); + + SEA3D.Stream.memcpy( buffer, 0, this.data.buffer, 0, this.data.byteLength ); + SEA3D.Stream.memcpy( buffer, this.data.byteLength, data, 0, data.byteLength ); + + this.buffer = buffer; + +}; + +SEA3D.Stream.prototype.concat = function ( position, length ) { + + return new SEA3D.Stream( this.buffer.slice( position, position + length ) ); + +}; + +/** + * @author DataStream.js + */ + +SEA3D.Stream.memcpy = function ( dst, dstOffset, src, srcOffset, byteLength ) { + + var dstU8 = new Uint8Array( dst, dstOffset, byteLength ); + var srcU8 = new Uint8Array( src, srcOffset, byteLength ); + + dstU8.set( srcU8 ); + +}; + +// +// UByteArray +// + +SEA3D.UByteArray = function () { + + this.ubytes = []; + this.length = 0; + +}; + +SEA3D.UByteArray.prototype = { + + constructor: SEA3D.UByteArray, + + add: function ( ubytes ) { + + this.ubytes.push( ubytes ); + this.length += ubytes.byteLength; + + }, + + toBuffer: function () { + + var memcpy = new Uint8Array( this.length ); + + for ( var i = 0, offset = 0; i < this.ubytes.length; i ++ ) { + + memcpy.set( this.ubytes[ i ], offset ); + offset += this.ubytes[ i ].byteLength; + + } + + return memcpy.buffer; + + } +}; + +// +// Math +// + +SEA3D.Math = { + RAD_TO_DEG: 180 / Math.PI, + DEG_TO_RAD: Math.PI / 180 +}; + +SEA3D.Math.angle = function ( val ) { + + var ang = 180, + inv = val < 0; + + val = ( inv ? - val : val ) % 360; + + if ( val > ang ) { + + val = - ang + ( val - ang ); + + } + + return ( inv ? - val : val ); + +}; + +SEA3D.Math.angleDiff = function ( a, b ) { + + a *= this.DEG_TO_RAD; + b *= this.DEG_TO_RAD; + + return Math.atan2( Math.sin( a - b ), Math.cos( a - b ) ) * this.RAD_TO_DEG; + +}; + +SEA3D.Math.angleArea = function ( angle, target, area ) { + + return Math.abs( this.angleDiff( angle, target ) ) <= area; + +}; + +SEA3D.Math.direction = function ( x1, y1, x2, y2 ) { + + return Math.atan2( y2 - y1, x2 - x1 ); + +}; + +SEA3D.Math.physicalLerp = function ( val, to, deltaTime, duration ) { + + var t = deltaTime / duration; + + if ( t > 1 ) t = 1; + + return val + ( ( to - val ) * t ); + +}; + +SEA3D.Math.physicalAngle = function ( val, to, deltaTime, duration ) { + + if ( Math.abs( val - to ) > 180 ) { + + if ( val > to ) { + + to += 360; + + } else { + + to -= 360; + + } + + } + + var t = deltaTime / duration; + + if ( t > 1 ) t = 1; + + return this.angle( val + ( ( to - val ) * t ) ); + +}; + +SEA3D.Math.zero = function ( value, precision ) { + + precision = precision || 1.0E-3; + + var pValue = value < 0 ? - value : value; + + if ( pValue - precision < 0 ) value = 0; + + return value; + +}; + +SEA3D.Math.round = function ( value, precision ) { + + precision = Math.pow( 10, precision ); + + return Math.round( value * precision ) / precision; + +}; + +SEA3D.Math.lerpAngle = function ( val, tar, t ) { + + if ( Math.abs( val - tar ) > 180 ) { + + if ( val > tar ) { + + tar += 360; + + } else { + + tar -= 360; + + } + + } + + val += ( tar - val ) * t; + + return SEA3D.Math.angle( val ); + +}; + +SEA3D.Math.lerpColor = function ( val, tar, t ) { + + var a0 = val >> 24 & 0xff, + r0 = val >> 16 & 0xff, + g0 = val >> 8 & 0xff, + b0 = val & 0xff; + + var a1 = tar >> 24 & 0xff, + r1 = tar >> 16 & 0xff, + g1 = tar >> 8 & 0xff, + b1 = tar & 0xff; + + a0 += ( a1 - a0 ) * t; + r0 += ( r1 - r0 ) * t; + g0 += ( g1 - g0 ) * t; + b0 += ( b1 - b0 ) * t; + + return a0 << 24 | r0 << 16 | g0 << 8 | b0; + +}; + +SEA3D.Math.lerp = function ( val, tar, t ) { + + return val + ( ( tar - val ) * t ); + +}; + +// +// Timer +// + +SEA3D.Timer = function () { + + this.time = this.start = Date.now(); + +}; + +SEA3D.Timer.prototype = { + + constructor: SEA3D.Timer, + + get now() { + + return Date.now(); + + }, + + get deltaTime() { + + return Date.now() - this.time; + + }, + + get elapsedTime() { + + return Date.now() - this.start; + + }, + + update: function () { + + this.time = Date.now(); + + } +}; + +// +// Object +// + +SEA3D.Object = function ( name, data, type, sea3d ) { + + this.name = name; + this.data = data; + this.type = type; + this.sea3d = sea3d; + +}; + +// +// Geometry Base +// + +SEA3D.GeometryBase = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.attrib = data.readUShort(); + + this.isBig = ( this.attrib & 1 ) != 0; + + // variable uint + data.readVInt = this.isBig ? data.readUInt : data.readUShort; + + this.numVertex = data.readVInt(); + + this.length = this.numVertex * 3; + +}; + +// +// Geometry +// + +SEA3D.Geometry = function ( name, data, sea3d ) { + + SEA3D.GeometryBase.call( this, name, data, sea3d ); + + var i, j, len; + + // NORMAL + if ( this.attrib & 4 ) { + + this.normal = data.readFloatArray( this.length ); + + } + + // TANGENT + if ( this.attrib & 8 ) { + + this.tangent = data.readFloatArray( this.length ); + + } + + // UV + if ( this.attrib & 32 ) { + + var uvCount = data.readUByte(); + + if ( uvCount ) { + + this.uv = []; + + len = this.numVertex * 2; + + i = 0; + while ( i < uvCount ) { + + // UV VERTEX DATA + this.uv[ i ++ ] = data.readFloatArray( len ); + + } + + } + + } + + // JOINT-INDEXES / WEIGHTS + if ( this.attrib & 64 ) { + + this.jointPerVertex = data.readUByte(); + + var jntLen = this.numVertex * this.jointPerVertex; + + this.joint = data.readUShortArray( jntLen ); + this.weight = data.readFloatArray( jntLen ); + + } + + // VERTEX_COLOR + if ( this.attrib & 128 ) { + + var colorAttrib = data.readUByte(); + + var colorCount = data.readUByte(); + + if ( colorCount ) { + + this.numColor = ( ( ( colorAttrib & 64 ) >> 6 ) | ( ( colorAttrib & 128 ) >> 6 ) ) + 1; + + this.color = []; + + for ( i = 0 & 15; i < colorCount; i ++ ) { + + this.color.push( data.readFloatArray( this.numVertex * this.numColor ) ); + + } + + } + + } + + // VERTEX + this.vertex = data.readFloatArray( this.length ); + + // SUB-MESHES + var count = data.readUByte(); + + this.groups = []; + + if ( this.attrib & 1024 ) { + + // INDEXES + for ( i = 0, len = 0; i < count; i ++ ) { + + j = data.readVInt() * 3; + + this.groups.push( { + start: len, + count: j + } ); + + len += j; + + } + + if ( ! ( this.attrib & 2048 ) ) { + + this.indexes = this.isBig ? data.readUIntArray( len ) : data.readUShortArray( len ); + + } + + } else { + + // INDEXES + var stride = this.isBig ? 4 : 2, + bytearray = new SEA3D.UByteArray(); + + for ( i = 0, j = 0; i < count; i ++ ) { + + len = data.readVInt() * 3; + + this.groups.push( { + start: j, + count: len + } ); + + j += len; + + bytearray.add( data.readUByteArray( len * stride ) ); + + } + + this.indexes = this.isBig ? new Uint32Array( bytearray.toBuffer() ) : new Uint16Array( bytearray.toBuffer() ); + + } + +}; + +SEA3D.Geometry.prototype = Object.create( SEA3D.GeometryBase.prototype ); +SEA3D.Geometry.prototype.constructor = SEA3D.Geometry; + +SEA3D.Geometry.prototype.type = "geo"; + +// +// Object3D +// + +SEA3D.Object3D = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.isStatic = false; + this.visible = true; + + this.attrib = data.readUShort(); + + if ( this.attrib & 1 ) this.parent = sea3d.getObject( data.readUInt() ); + + if ( this.attrib & 2 ) this.animations = data.readAnimationList( sea3d ); + + if ( this.attrib & 4 ) this.scripts = data.readScriptList( sea3d ); + + if ( this.attrib & 16 ) this.attributes = sea3d.getObject( data.readUInt() ); + + if ( this.attrib & 32 ) { + + var objectType = data.readUByte(); + + this.isStatic = ( objectType & 1 ) != 0; + this.visible = ( objectType & 2 ) == 0; + + } + +}; + +SEA3D.Object3D.prototype.readTag = function ( kind, data, size ) { + +}; + +// +// Entity3D +// + +SEA3D.Entity3D = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.castShadows = true; + + if ( this.attrib & 64 ) { + + var lightType = data.readUByte(); + + this.castShadows = ( lightType & 1 ) == 0; + + } + +}; + +SEA3D.Entity3D.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Entity3D.prototype.constructor = SEA3D.Entity3D; + +// +// Sound3D +// + +SEA3D.Sound3D = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.autoPlay = ( this.attrib & 64 ) != 0; + + if ( this.attrib & 128 ) this.mixer = sea3d.getObject( data.readUInt() ); + + this.sound = sea3d.getObject( data.readUInt() ); + this.volume = data.readFloat(); + +}; + +SEA3D.Sound3D.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Sound3D.prototype.constructor = SEA3D.Sound3D; + +// +// Sound Point +// + +SEA3D.SoundPoint = function ( name, data, sea3d ) { + + SEA3D.Sound3D.call( this, name, data, sea3d ); + + this.position = data.readVector3(); + this.distance = data.readFloat(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.SoundPoint.prototype = Object.create( SEA3D.Sound3D.prototype ); +SEA3D.SoundPoint.prototype.constructor = SEA3D.SoundPoint; + +SEA3D.SoundPoint.prototype.type = "sp"; + +// +// Container3D +// + +SEA3D.Container3D = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.transform = data.readMatrix(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.Container3D.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Container3D.prototype.constructor = SEA3D.Container3D; + +SEA3D.Container3D.prototype.type = "c3d"; + +// +// Script URL +// + +SEA3D.ScriptURL = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.url = data.readUTF8( data.length ); + +}; + +SEA3D.ScriptURL.prototype.type = "src"; + +// +// Texture URL +// + +SEA3D.TextureURL = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.url = sea3d.config.path + data.readUTF8( data.length ); + +}; + +SEA3D.TextureURL.prototype.type = "urlT"; + +// +// CubeMap URL +// + +SEA3D.CubeMapURL = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.faces = []; + + for ( var i = 0; i < 6; i ++ ) { + + this.faces[ i ] = data.readUTF8Tiny(); + + } + +}; + +SEA3D.CubeMapURL.prototype.type = "cURL"; + +// +// Actions +// + +SEA3D.Actions = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.count = data.readUInt(); + this.actions = []; + + for ( var i = 0; i < this.count; i ++ ) { + + var flag = data.readUByte(); + var kind = data.readUShort(); + + var size = data.readUShort(); + + var position = data.position; + var act = this.actions[ i ] = { kind: kind }; + + // range of animation + if ( flag & 1 ) { + + // start and count in frames + act.range = [ data.readUInt(), data.readUInt() ]; + + } + + // time + if ( flag & 2 ) { + + act.time = data.readUInt(); + + } + + // easing + if ( flag & 4 ) { + + act.intrpl = data.readInterpolation(); + + if ( act.intrpl.indexOf( 'back.' ) == 0 ) { + + act.intrplParam0 = data.readFloat(); + + } else if ( act.intrpl.indexOf( 'elastic.' ) == 0 ) { + + act.intrplParam0 = data.readFloat(); + act.intrplParam1 = data.readFloat(); + + } + + } + + switch ( kind ) { + + case SEA3D.Actions.RTT_TARGET: + act.source = sea3d.getObject( data.readUInt() ); + act.target = sea3d.getObject( data.readUInt() ); + break; + + case SEA3D.Actions.LOOK_AT: + act.source = sea3d.getObject( data.readUInt() ); + act.target = sea3d.getObject( data.readUInt() ); + break; + + case SEA3D.Actions.PLAY_SOUND: + act.sound = sea3d.getObject( data.readUInt() ); + act.offset = data.readUInt(); + break; + + case SEA3D.Actions.PLAY_ANIMATION: + act.object = sea3d.getObject( data.readUInt() ); + act.name = data.readUTF8Tiny(); + break; + + case SEA3D.Actions.FOG: + act.color = data.readUInt24(); + act.min = data.readFloat(); + act.max = data.readFloat(); + break; + + case SEA3D.Actions.ENVIRONMENT: + act.texture = sea3d.getObject( data.readUInt() ); + break; + + case SEA3D.Actions.ENVIRONMENT_COLOR: + act.color = data.readUInt24F(); + break; + + case SEA3D.Actions.CAMERA: + act.camera = sea3d.getObject( data.readUInt() ); + break; + + case SEA3D.Actions.SCRIPTS: + act.scripts = data.readScriptList( sea3d ); + break; + + case SEA3D.Actions.CLASS_OF: + act.classof = sea3d.getObject( data.readUInt() ); + break; + + case SEA3D.Actions.ATTRIBUTES: + act.attributes = sea3d.getObject( data.readUInt() ); + break; + + default: + console.log( "Action \"" + kind + "\" not found." ); + break; + + } + + data.position = position + size; + + } + +}; + +SEA3D.Actions.SCENE = 0; +SEA3D.Actions.ENVIRONMENT_COLOR = 1; +SEA3D.Actions.ENVIRONMENT = 2; +SEA3D.Actions.FOG = 3; +SEA3D.Actions.PLAY_ANIMATION = 4; +SEA3D.Actions.PLAY_SOUND = 5; +SEA3D.Actions.ANIMATION_AUDIO_SYNC = 6; +SEA3D.Actions.LOOK_AT = 7; +SEA3D.Actions.RTT_TARGET = 8; +SEA3D.Actions.CAMERA = 9; +SEA3D.Actions.SCRIPTS = 10; +SEA3D.Actions.CLASS_OF = 11; +SEA3D.Actions.ATTRIBUTES = 12; + +SEA3D.Actions.prototype.type = "act"; + +// +// Properties +// + +SEA3D.Properties = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.props = data.readProperties( sea3d ); + this.props.__name = name; + +}; + +SEA3D.Properties.prototype.type = "prop"; + +// +// File Info +// + +SEA3D.FileInfo = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.info = data.readProperties( sea3d ); + this.info.__name = name; + + sea3d.info = this.info; + +}; + +SEA3D.FileInfo.prototype.type = "info"; + +// +// Java Script +// + +SEA3D.JavaScript = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.src = data.readUTF8( data.length ); + +}; + +SEA3D.JavaScript.prototype.type = "js"; + +// +// Java Script Method +// + +SEA3D.JavaScriptMethod = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var count = data.readUShort(); + + this.methods = {}; + + for ( var i = 0; i < count; i ++ ) { + + var flag = data.readUByte(); + var method = data.readUTF8Tiny(); + + this.methods[ method ] = { + src: data.readUTF8Long() + }; + + } + +}; + +SEA3D.JavaScriptMethod.prototype.type = "jsm"; + +// +// GLSL +// + +SEA3D.GLSL = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.src = data.readUTF8( data.length ); + +}; + +SEA3D.GLSL.prototype.type = "glsl"; + +// +// Dummy +// + +SEA3D.Dummy = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.transform = data.readMatrix(); + + this.width = data.readFloat(); + this.height = data.readFloat(); + this.depth = data.readFloat(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.Dummy.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Dummy.prototype.constructor = SEA3D.Dummy; + +SEA3D.Dummy.prototype.type = "dmy"; + +// +// Line +// + +SEA3D.Line = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.count = ( this.attrib & 64 ? data.readUInt() : data.readUShort() ) * 3; + this.closed = ( this.attrib & 128 ) != 0; + this.transform = data.readMatrix(); + + this.vertex = []; + + var i = 0; + while ( i < this.count ) { + + this.vertex[ i ++ ] = data.readFloat(); + + } + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.Line.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Line.prototype.constructor = SEA3D.Line; + +SEA3D.Line.prototype.type = "line"; + +// +// Sprite +// + +SEA3D.Sprite = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + if ( this.attrib & 256 ) { + + this.material = sea3d.getObject( data.readUInt() ); + + } + + this.position = data.readVector3(); + + this.width = data.readFloat(); + this.height = data.readFloat(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.Sprite.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Sprite.prototype.constructor = SEA3D.Sprite; + +SEA3D.Sprite.prototype.type = "m2d"; + +// +// Mesh +// + +SEA3D.Mesh = function ( name, data, sea3d ) { + + SEA3D.Entity3D.call( this, name, data, sea3d ); + + // MATERIAL + if ( this.attrib & 256 ) { + + this.material = []; + + var len = data.readUByte(); + + if ( len == 1 ) this.material[ 0 ] = sea3d.getObject( data.readUInt() ); + else { + + var i = 0; + while ( i < len ) { + + var matIndex = data.readUInt(); + + if ( matIndex > 0 ) this.material[ i ++ ] = sea3d.getObject( matIndex - 1 ); + else this.material[ i ++ ] = undefined; + + } + + } + + } + + if ( this.attrib & 512 ) { + + this.modifiers = []; + + var len = data.readUByte(); + + for ( var i = 0; i < len; i ++ ) { + + this.modifiers[ i ] = sea3d.getObject( data.readUInt() ); + + } + + } + + if ( this.attrib & 1024 ) { + + this.reference = { + type: data.readUByte(), + ref: sea3d.getObject( data.readUInt() ) + }; + + } + + this.transform = data.readMatrix(); + + this.geometry = sea3d.getObject( data.readUInt() ); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.Mesh.prototype = Object.create( SEA3D.Entity3D.prototype ); +SEA3D.Mesh.prototype.constructor = SEA3D.Mesh; + +SEA3D.Mesh.prototype.type = "m3d"; + +// +// Skeleton +// + +SEA3D.Skeleton = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var length = data.readUShort(); + + this.joint = []; + + for ( var i = 0; i < length; i ++ ) { + + this.joint[ i ] = { + name: data.readUTF8Tiny(), + parentIndex: data.readUShort() - 1, + inverseBindMatrix: data.readMatrix() + }; + + } + +}; + +SEA3D.Skeleton.prototype.type = "skl"; + +// +// Skeleton Local +// + +SEA3D.SkeletonLocal = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var length = data.readUShort(); + + this.joint = []; + + for ( var i = 0; i < length; i ++ ) { + + this.joint[ i ] = { + name: data.readUTF8Tiny(), + parentIndex: data.readUShort() - 1, + // POSITION XYZ + x: data.readFloat(), + y: data.readFloat(), + z: data.readFloat(), + // QUATERNION XYZW + qx: data.readFloat(), + qy: data.readFloat(), + qz: data.readFloat(), + qw: data.readFloat() + }; + + } + +}; + +SEA3D.SkeletonLocal.prototype.type = "sklq"; + +// +// Animation Base +// + +SEA3D.AnimationBase = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var flag = data.readUByte(); + + this.sequence = []; + + if ( flag & 1 ) { + + var count = data.readUShort(); + + for ( var i = 0; i < count; i ++ ) { + + var seqFlag = data.readUByte(); + + this.sequence[ i ] = { + name: data.readUTF8Tiny(), + start: data.readUInt(), + count: data.readUInt(), + repeat: ( seqFlag & 1 ) != 0, + intrpl: ( seqFlag & 2 ) == 0 + }; + + } + + } + + this.frameRate = data.readUByte(); + this.numFrames = data.readUInt(); + + // no contains sequence + if ( this.sequence.length == 0 ) { + + this.sequence[ 0 ] = { name: "root", start: 0, count: this.numFrames, repeat: true, intrpl: true }; + + } + +}; + +// +// Animation +// + +SEA3D.Animation = function ( name, data, sea3d ) { + + SEA3D.AnimationBase.call( this, name, data, sea3d ); + + this.dataList = []; + + for ( var i = 0, l = data.readUByte(); i < l; i ++ ) { + + var kind = data.readUShort(), + type = data.readUByte(); + + var anmRaw = data.readVector( type, this.numFrames, 0 ); + + this.dataList.push( { + kind: kind, + type: type, + blockSize: SEA3D.Stream.sizeOf( type ), + data: anmRaw + } ); + + } + +}; + +SEA3D.Animation.POSITION = 0; +SEA3D.Animation.ROTATION = 1; +SEA3D.Animation.SCALE = 2; +SEA3D.Animation.COLOR = 3; +SEA3D.Animation.MULTIPLIER = 4; +SEA3D.Animation.ATTENUATION_START = 5; +SEA3D.Animation.ATTENUATION_END = 6; +SEA3D.Animation.FOV = 7; +SEA3D.Animation.OFFSET_U = 8; +SEA3D.Animation.OFFSET_V = 9; +SEA3D.Animation.SCALE_U = 10; +SEA3D.Animation.SCALE_V = 11; +SEA3D.Animation.ANGLE = 12; +SEA3D.Animation.ALPHA = 13; +SEA3D.Animation.VOLUME = 14; + +SEA3D.Animation.MORPH = 250; + +SEA3D.Animation.prototype = Object.create( SEA3D.AnimationBase.prototype ); +SEA3D.Animation.prototype.constructor = SEA3D.Animation; + +SEA3D.Animation.prototype.type = "anm"; + +// +// Skeleton Animation +// + +SEA3D.SkeletonAnimation = function ( name, data, sea3d ) { + + SEA3D.AnimationBase.call( this, name, data, sea3d ); + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.numJoints = data.readUShort(); + + this.raw = data.readFloatArray( this.numFrames * this.numJoints * 7 ); + +}; + +SEA3D.SkeletonAnimation.prototype.type = "skla"; + +// +// UVW Animation +// + +SEA3D.UVWAnimation = function ( name, data, sea3d ) { + + SEA3D.Animation.call( this, name, data, sea3d ); + +}; + +SEA3D.UVWAnimation.prototype.type = "auvw"; + +// +// Morph +// + +SEA3D.Morph = function ( name, data, sea3d ) { + + SEA3D.GeometryBase.call( this, name, data, sea3d ); + + var useVertex = ( this.attrib & 2 ) != 0; + var useNormal = ( this.attrib & 4 ) != 0; + + var nodeCount = data.readUShort(); + + this.node = []; + + for ( var i = 0; i < nodeCount; i ++ ) { + + var nodeName = data.readUTF8Tiny(), + verts, norms; + + if ( useVertex ) verts = data.readFloatArray( this.length ); + if ( useNormal ) norms = data.readFloatArray( this.length ); + + this.node[ i ] = { vertex: verts, normal: norms, name: nodeName }; + + } + +}; + +SEA3D.Morph.prototype = Object.create( SEA3D.GeometryBase.prototype ); +SEA3D.Morph.prototype.constructor = SEA3D.Morph; + +SEA3D.Morph.prototype.type = "mph"; + +// +// Morph Animation +// + +SEA3D.MorphAnimation = function ( name, data, sea3d ) { + + SEA3D.AnimationBase.call( this, name, data, sea3d ); + + this.dataList = []; + + for ( var i = 0, l = data.readUByte(); i < l; i ++ ) { + + this.dataList.push( { + kind: SEA3D.Animation.MORPH, + type: SEA3D.Stream.FLOAT, + name: data.readUTF8Tiny(), + blockSize: 1, + data: data.readVector( SEA3D.Stream.FLOAT, this.numFrames, 0 ) + } ); + + } + +}; + +SEA3D.MorphAnimation.prototype.type = "mpha"; + +// +// Vertex Animation +// + +SEA3D.VertexAnimation = function ( name, data, sea3d ) { + + SEA3D.AnimationBase.call( this, name, data, sea3d ); + + var flags = data.readUByte(); + + this.isBig = ( flags & 1 ) != 0; + + data.readVInt = this.isBig ? data.readUInt : data.readUShort; + + this.numVertex = data.readVInt(); + + this.length = this.numVertex * 3; + + var useVertex = ( flags & 2 ) != 0; + var useNormal = ( flags & 4 ) != 0; + + this.frame = []; + + var i, verts, norms; + + for ( i = 0; i < this.numFrames; i ++ ) { + + if ( useVertex ) verts = data.readFloatArray( this.length ); + if ( useNormal ) norms = data.readFloatArray( this.length ); + + this.frame[ i ] = { vertex: verts, normal: norms }; + + } + +}; + +SEA3D.VertexAnimation.prototype = Object.create( SEA3D.AnimationBase.prototype ); +SEA3D.VertexAnimation.prototype.constructor = SEA3D.VertexAnimation; + +SEA3D.VertexAnimation.prototype.type = "vtxa"; + +// +// Camera +// + +SEA3D.Camera = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + if ( this.attrib & 64 ) { + + this.dof = { + distance: data.readFloat(), + range: data.readFloat() + }; + + } + + this.transform = data.readMatrix(); + + this.fov = data.readFloat(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.Camera.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Camera.prototype.constructor = SEA3D.Camera; + +SEA3D.Camera.prototype.type = "cam"; + +// +// Orthographic Camera +// + +SEA3D.OrthographicCamera = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.transform = data.readMatrix(); + + this.height = data.readFloat(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.OrthographicCamera.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.OrthographicCamera.prototype.constructor = SEA3D.OrthographicCamera; + +SEA3D.OrthographicCamera.prototype.type = "camo"; + +// +// Joint Object +// + +SEA3D.JointObject = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.target = sea3d.getObject( data.readUInt() ); + this.joint = data.readUShort(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.JointObject.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.JointObject.prototype.constructor = SEA3D.JointObject; + +SEA3D.JointObject.prototype.type = "jnt"; + +// +// Light +// + +SEA3D.Light = function ( name, data, sea3d ) { + + SEA3D.Object3D.call( this, name, data, sea3d ); + + this.attenStart = Number.MAX_VALUE; + this.attenEnd = Number.MAX_VALUE; + + if ( this.attrib & 64 ) { + + var shadowHeader = data.readUByte(); + + this.shadow = {}; + + this.shadow.opacity = shadowHeader & 1 ? data.readFloat() : 1; + this.shadow.color = shadowHeader & 2 ? data.readUInt24() : 0x000000; + + } + + if ( this.attrib & 512 ) { + + this.attenStart = data.readFloat(); + this.attenEnd = data.readFloat(); + + } + + this.color = data.readUInt24(); + this.multiplier = data.readFloat(); + +}; + +SEA3D.Light.prototype = Object.create( SEA3D.Object3D.prototype ); +SEA3D.Light.prototype.constructor = SEA3D.Light; + +// +// Point Light +// + +SEA3D.PointLight = function ( name, data, sea3d ) { + + SEA3D.Light.call( this, name, data, sea3d ); + + if ( this.attrib & 128 ) { + + this.attenuation = { + start: data.readFloat(), + end: data.readFloat() + }; + + } + + this.position = data.readVector3(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.PointLight.prototype = Object.create( SEA3D.Light.prototype ); +SEA3D.PointLight.prototype.constructor = SEA3D.PointLight; + +SEA3D.PointLight.prototype.type = "plht"; + +// +// Hemisphere Light +// + +SEA3D.HemisphereLight = function ( name, data, sea3d ) { + + SEA3D.Light.call( this, name, data, sea3d ); + + if ( this.attrib & 128 ) { + + this.attenuation = { + start: data.readFloat(), + end: data.readFloat() + }; + + } + + this.secondColor = data.readUInt24(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.HemisphereLight.prototype = Object.create( SEA3D.Light.prototype ); +SEA3D.HemisphereLight.prototype.constructor = SEA3D.HemisphereLight; + +SEA3D.HemisphereLight.prototype.type = "hlht"; + +// +// Ambient Light +// + +SEA3D.AmbientLight = function ( name, data, sea3d ) { + + SEA3D.Light.call( this, name, data, sea3d ); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.AmbientLight.prototype = Object.create( SEA3D.Light.prototype ); +SEA3D.AmbientLight.prototype.constructor = SEA3D.AmbientLight; + +SEA3D.AmbientLight.prototype.type = "alht"; + +// +// Directional Light +// + +SEA3D.DirectionalLight = function ( name, data, sea3d ) { + + SEA3D.Light.call( this, name, data, sea3d ); + + this.transform = data.readMatrix(); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.DirectionalLight.prototype = Object.create( SEA3D.Light.prototype ); +SEA3D.DirectionalLight.prototype.constructor = SEA3D.DirectionalLight; + +SEA3D.DirectionalLight.prototype.type = "dlht"; + +// +// Material +// + +SEA3D.Material = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.technique = []; + this.tecniquesDict = {}; + + this.attrib = data.readUShort(); + + this.alpha = 1; + this.blendMode = "normal"; + + this.doubleSided = ( this.attrib & 1 ) != 0; + + this.receiveLights = ( this.attrib & 2 ) == 0; + this.receiveShadows = ( this.attrib & 4 ) == 0; + this.receiveFog = ( this.attrib & 8 ) == 0; + + this.repeat = ( this.attrib & 16 ) == 0; + + if ( this.attrib & 32 ) + this.alpha = data.readFloat(); + + if ( this.attrib & 64 ) + this.blendMode = data.readBlendMode(); + + if ( this.attrib & 128 ) + this.animations = data.readAnimationList( sea3d ); + + this.depthWrite = ( this.attrib & 256 ) == 0; + this.depthTest = ( this.attrib & 512 ) == 0; + + this.premultipliedAlpha = ( this.attrib & 1024 ) != 0; + + var count = data.readUByte(); + + for ( var i = 0; i < count; ++ i ) { + + var kind = data.readUShort(); + var size = data.readUShort(); + var pos = data.position; + var tech, methodAttrib; + + switch ( kind ) { + + case SEA3D.Material.PHONG: + + tech = { + ambientColor: data.readUInt24(), + diffuseColor: data.readUInt24(), + specularColor: data.readUInt24(), + + specular: data.readFloat(), + gloss: data.readFloat() + }; + + break; + + case SEA3D.Material.PHYSICAL: + + tech = { + color: data.readUInt24(), + roughness: data.readFloat(), + metalness: data.readFloat() + }; + + break; + + case SEA3D.Material.ANISOTROPIC: + break; + + case SEA3D.Material.COMPOSITE_TEXTURE: + + tech = { + composite: sea3d.getObject( data.readUInt() ) + }; + + break; + + case SEA3D.Material.DIFFUSE_MAP: + case SEA3D.Material.SPECULAR_MAP: + case SEA3D.Material.NORMAL_MAP: + case SEA3D.Material.AMBIENT_MAP: + case SEA3D.Material.ALPHA_MAP: + case SEA3D.Material.EMISSIVE_MAP: + case SEA3D.Material.ROUGHNESS_MAP: + case SEA3D.Material.METALNESS_MAP: + + tech = { + texture: sea3d.getObject( data.readUInt() ) + }; + + break; + + case SEA3D.Material.REFLECTION: + case SEA3D.Material.FRESNEL_REFLECTION: + + tech = { + texture: sea3d.getObject( data.readUInt() ), + alpha: data.readFloat() + }; + + if ( kind == SEA3D.Material.FRESNEL_REFLECTION ) { + + tech.power = data.readFloat(); + tech.normal = data.readFloat(); + + } + + break; + + case SEA3D.Material.REFRACTION: + + tech = { + texture: sea3d.getObject( data.readUInt() ), + alpha: data.readFloat(), + ior: data.readFloat() + }; + + break; + + case SEA3D.Material.RIM: + + tech = { + color: data.readUInt24(), + strength: data.readFloat(), + power: data.readFloat(), + blendMode: data.readBlendMode() + }; + + break; + + case SEA3D.Material.LIGHT_MAP: + + tech = { + texture: sea3d.getObject( data.readUInt() ), + channel: data.readUByte(), + blendMode: data.readBlendMode() + }; + + break; + + case SEA3D.Material.DETAIL_MAP: + + tech = { + texture: sea3d.getObject( data.readUInt() ), + scale: data.readFloat(), + blendMode: data.readBlendMode() + }; + + break; + + case SEA3D.Material.CEL: + + tech = { + color: data.readUInt24(), + levels: data.readUByte(), + size: data.readFloat(), + specularCutOff: data.readFloat(), + smoothness: data.readFloat() + }; + + break; + + case SEA3D.Material.TRANSLUCENT: + + tech = { + translucency: data.readFloat(), + scattering: data.readFloat() + }; + + break; + + case SEA3D.Material.BLEND_NORMAL_MAP: + + methodAttrib = data.readUByte(); + + tech = { + texture: sea3d.getObject( data.readUInt() ), + secondaryTexture: sea3d.getObject( data.readUInt() ) + }; + + if ( methodAttrib & 1 ) { + + tech.offsetX0 = data.readFloat(); + tech.offsetY0 = data.readFloat(); + + tech.offsetX1 = data.readFloat(); + tech.offsetY1 = data.readFloat(); + + } else { + + tech.offsetX0 = tech.offsetY0 = + tech.offsetX1 = tech.offsetY1 = 0; + + } + + tech.animate = methodAttrib & 2; + + break; + + case SEA3D.Material.MIRROR_REFLECTION: + + tech = { + texture: sea3d.getObject( data.readUInt() ), + alpha: data.readFloat() + }; + break; + + case SEA3D.Material.EMISSIVE: + + tech = { + color: data.readUInt24F() + }; + + break; + + case SEA3D.Material.VERTEX_COLOR: + + tech = { + blendMode: data.readBlendMode() + }; + + break; + + case SEA3D.Material.WRAP_LIGHTING: + + tech = { + color: data.readUInt24(), + strength: data.readFloat() + }; + + break; + + case SEA3D.Material.COLOR_REPLACE: + + methodAttrib = data.readUByte(); + + tech = { + red: data.readUInt24(), + green: data.readUInt24(), + blue: data.readUInt24F() + }; + + if ( methodAttrib & 1 ) tech.mask = sea3d.getObject( data.readUInt() ); + + if ( methodAttrib & 2 ) tech.alpha = data.readFloat(); + + break; + + case SEA3D.Material.REFLECTION_SPHERICAL: + + tech = { + texture: sea3d.getObject( data.readUInt() ), + alpha: data.readFloat() + }; + + break; + + case SEA3D.Material.REFLECTIVITY: + + methodAttrib = data.readUByte(); + + tech = { + strength: data.readFloat() + }; + + if ( methodAttrib & 1 ) tech.mask = sea3d.getObject( data.readUInt() ); + + break; + + case SEA3D.Material.CLEAR_COAT: + + tech = { + strength: data.readFloat(), + roughness: data.readFloat() + }; + + break; + + case SEA3D.Material.FLACCIDITY: + + methodAttrib = data.readUByte(); + + tech = { + target: sea3d.getObject( data.readUInt() ), + scale: data.readFloat(), + spring: data.readFloat(), + damping: data.readFloat() + }; + + if ( methodAttrib & 1 ) tech.mask = sea3d.getObject( data.readUInt() ); + + break; + + default: + + console.warn( "SEA3D: MaterialTechnique not found:", kind.toString( 16 ) ); + + data.position = pos += size; + + continue; + + } + + tech.kind = kind; + + this.technique.push( tech ); + this.tecniquesDict[ kind ] = tech; + + data.position = pos += size; + + } + +}; + +SEA3D.Material.PHONG = 0; +SEA3D.Material.COMPOSITE_TEXTURE = 1; +SEA3D.Material.DIFFUSE_MAP = 2; +SEA3D.Material.SPECULAR_MAP = 3; +SEA3D.Material.REFLECTION = 4; +SEA3D.Material.REFRACTION = 5; +SEA3D.Material.NORMAL_MAP = 6; +SEA3D.Material.FRESNEL_REFLECTION = 7; +SEA3D.Material.RIM = 8; +SEA3D.Material.LIGHT_MAP = 9; +SEA3D.Material.DETAIL_MAP = 10; +SEA3D.Material.CEL = 11; +SEA3D.Material.TRANSLUCENT = 12; +SEA3D.Material.BLEND_NORMAL_MAP = 13; +SEA3D.Material.MIRROR_REFLECTION = 14; +SEA3D.Material.AMBIENT_MAP = 15; +SEA3D.Material.ALPHA_MAP = 16; +SEA3D.Material.EMISSIVE_MAP = 17; +SEA3D.Material.VERTEX_COLOR = 18; +SEA3D.Material.WRAP_LIGHTING = 19; +SEA3D.Material.COLOR_REPLACE = 20; +SEA3D.Material.REFLECTION_SPHERICAL = 21; +SEA3D.Material.ANISOTROPIC = 22; +SEA3D.Material.EMISSIVE = 23; +SEA3D.Material.PHYSICAL = 24; +SEA3D.Material.ROUGHNESS_MAP = 25; +SEA3D.Material.METALNESS_MAP = 26; +SEA3D.Material.REFLECTIVITY = 27; +SEA3D.Material.CLEAR_COAT = 28; +SEA3D.Material.FLACCIDITY = 29; + +SEA3D.Material.prototype.type = "mat"; + +// +// Composite +// + +SEA3D.Composite = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var layerCount = data.readUByte(); + + this.layer = []; + + for ( var i = 0; i < layerCount; i ++ ) { + + this.layer[ i ] = new SEA3D.Composite.prototype.Layer( data, sea3d ); + + } + +}; + +SEA3D.Composite.prototype.getLayerByName = function ( name ) { + + for ( var i = 0; i < this.layer.length; i ++ ) { + + if ( this.layer[ i ].name == name ) { + + return this.layer[ i ]; + + } + + } + +}; + +SEA3D.Composite.prototype.Layer = function ( data, sea3d ) { + + var attrib = data.readUShort(); + + if ( attrib & 1 ) this.texture = new SEA3D.Composite.LayerBitmap( data, sea3d ); + else this.color = data.readUInt24(); + + if ( attrib & 2 ) { + + this.mask = new SEA3D.Composite.LayerBitmap( data, sea3d ); + + } + + if ( attrib & 4 ) { + + this.name = data.readUTF8Tiny(); + + } + + this.blendMode = attrib & 8 ? data.readBlendMode() : "normal"; + + this.opacity = attrib & 16 ? data.readFloat() : 1; + +}; + +SEA3D.Composite.LayerBitmap = function ( data, sea3d ) { + + this.map = sea3d.getObject( data.readUInt() ); + + var attrib = data.readUShort(); + + this.channel = attrib & 1 ? data.readUByte() : 0; + this.repeat = attrib & 2 == 0; + this.offsetU = attrib & 4 ? data.readFloat() : 0; + this.offsetV = attrib & 8 ? data.readFloat() : 0; + this.scaleU = attrib & 16 ? data.readFloat() : 1; + this.scaleV = attrib & 32 ? data.readFloat() : 1; + this.rotation = attrib & 64 ? data.readFloat() : 0; + + if ( attrib & 128 ) this.animation = data.readAnimationList( sea3d ); + +}; + +SEA3D.Composite.prototype.type = "ctex"; + +// +// Planar Render +// + +SEA3D.PlanarRender = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.attrib = data.readUByte(); + + this.quality = ( this.attrib & 1 ) | ( this.attrib & 2 ); + this.transform = data.readMatrix(); + +}; + +SEA3D.PlanarRender.prototype.type = "rttp"; + +// +// Cube Render +// + +SEA3D.CubeRender = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.attrib = data.readUByte(); + + this.quality = ( this.attrib & 1 ) | ( this.attrib & 2 ); + this.position = data.readVector3(); + +}; + +SEA3D.CubeRender.prototype.type = "rttc"; + +// +// Cube Maps +// + +SEA3D.CubeMap = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.transparent = false; + + this.extension = data.readExt(); + + this.faces = []; + + for ( var i = 0; i < 6; i ++ ) { + + var size = data.readUInt(); + + this.faces[ i ] = data.concat( data.position, size ); + + data.position += size; + + } + +}; + +SEA3D.CubeMap.prototype.type = "cmap"; + +// +// JPEG +// + +SEA3D.JPEG = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.transparent = false; + +}; + +SEA3D.JPEG.prototype.type = "jpg"; + +// +// JPEG_XR +// + +SEA3D.JPEG_XR = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.transparent = true; + +}; + +SEA3D.JPEG_XR.prototype.type = "wdp"; + +// +// PNG +// + +SEA3D.PNG = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.transparent = data.getByte( 25 ) == 0x06; + +}; + +SEA3D.PNG.prototype.type = "png"; + +// +// GIF +// + +SEA3D.GIF = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.transparent = data.getByte( 11 ) > 0; + +}; + +SEA3D.GIF.prototype.type = "gif"; + +// +// OGG +// + +SEA3D.OGG = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + +}; + +SEA3D.OGG.prototype.type = "ogg"; + +// +// MP3 +// + +SEA3D.MP3 = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + +}; + +SEA3D.MP3.prototype.type = "mp3"; + +// +// Texture Update +// + +SEA3D.TextureUpdate = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.index = data.readUInt(); + this.bytes = data.concat( data.position, data.length - data.position ); + +}; + +SEA3D.TextureUpdate.prototype.type = "uTex"; + +// +// FILE FORMAT +// + +SEA3D.File = function ( config ) { + + this.config = { + streaming: true, + timeLimit: 60, + progressive: false + }; + + if ( config ) { + + if ( config.streaming !== undefined ) this.config.streaming = config.streaming; + if ( config.timeLimit !== undefined ) this.config.timeLimit = config.timeLimit; + if ( config.progressive !== undefined ) this.config.progressive = config.progressive; + if ( config.path !== undefined ) this.config.path = config.path; + + } + + this.version = SEA3D.VERSION; + this.objects = []; + this.typeClass = {}; + this.typeRead = {}; + this.typeUnique = {}; + this.position = + this.dataPosition = 0; + this.scope = this; + + // SEA3D + this.addClass( SEA3D.FileInfo, true ); + this.addClass( SEA3D.Geometry, true ); + this.addClass( SEA3D.Mesh ); + this.addClass( SEA3D.Sprite ); + this.addClass( SEA3D.Material ); + this.addClass( SEA3D.Composite ); + this.addClass( SEA3D.PointLight ); + this.addClass( SEA3D.DirectionalLight ); + this.addClass( SEA3D.HemisphereLight ); + this.addClass( SEA3D.AmbientLight ); + this.addClass( SEA3D.Animation, true ); + this.addClass( SEA3D.Skeleton, true ); + this.addClass( SEA3D.SkeletonLocal, true ); + this.addClass( SEA3D.SkeletonAnimation, true ); + this.addClass( SEA3D.UVWAnimation, true ); + this.addClass( SEA3D.JointObject ); + this.addClass( SEA3D.Camera ); + this.addClass( SEA3D.OrthographicCamera ); + this.addClass( SEA3D.Morph, true ); + this.addClass( SEA3D.MorphAnimation, true ); + this.addClass( SEA3D.VertexAnimation, true ); + this.addClass( SEA3D.CubeMap, true ); + this.addClass( SEA3D.Dummy ); + this.addClass( SEA3D.Line ); + this.addClass( SEA3D.SoundPoint ); + this.addClass( SEA3D.PlanarRender ); + this.addClass( SEA3D.CubeRender ); + this.addClass( SEA3D.Actions ); + this.addClass( SEA3D.Container3D ); + this.addClass( SEA3D.Properties ); + + // URL BASED + this.addClass( SEA3D.ScriptURL, true ); + this.addClass( SEA3D.TextureURL, true ); + this.addClass( SEA3D.CubeMapURL, true ); + + // UNIVERSAL + this.addClass( SEA3D.JPEG, true ); + this.addClass( SEA3D.JPEG_XR, true ); + this.addClass( SEA3D.PNG, true ); + this.addClass( SEA3D.GIF, true ); + this.addClass( SEA3D.OGG, true ); + this.addClass( SEA3D.MP3, true ); + this.addClass( SEA3D.JavaScript, true ); + this.addClass( SEA3D.JavaScriptMethod, true ); + this.addClass( SEA3D.GLSL, true ); + + // Updaters + this.addClass( SEA3D.TextureUpdate, true ); + + // Extensions + var i = SEA3D.File.Extensions.length; + + while ( i -- ) { + + SEA3D.File.Extensions[ i ].call( this ); + + } + +}; + +SEA3D.File.Extensions = []; +SEA3D.File.CompressionLibs = {}; +SEA3D.File.DecompressionMethod = {}; + +SEA3D.File.setExtension = function ( callback ) { + + SEA3D.File.Extensions.push( callback ); + +}; + +SEA3D.File.setDecompressionEngine = function ( id, name, method ) { + + SEA3D.File.CompressionLibs[ id ] = name; + SEA3D.File.DecompressionMethod[ id ] = method; + +}; + +SEA3D.File.prototype.addClass = function ( clazz, unique ) { + + this.typeClass[ clazz.prototype.type ] = clazz; + this.typeUnique[ clazz.prototype.type ] = unique === true; + +}; + +SEA3D.File.prototype.readHead = function () { + + if ( this.stream.bytesAvailable < 16 ) + return false; + + if ( this.stream.readUTF8( 3 ) != "SEA" ) + throw new Error( "Invalid SEA3D format." ); + + this.sign = this.stream.readUTF8( 3 ); + + this.version = this.stream.readUInt24(); + + if ( this.stream.readUByte() != 0 ) { + + throw new Error( "Protection algorithm not compatible." ); + + } + + this.compressionID = this.stream.readUByte(); + + this.compressionAlgorithm = SEA3D.File.CompressionLibs[ this.compressionID ]; + this.decompressionMethod = SEA3D.File.DecompressionMethod[ this.compressionID ]; + + if ( this.compressionID > 0 && ! this.decompressionMethod ) { + + throw new Error( "Compression algorithm not compatible." ); + + } + + this.length = this.stream.readUInt(); + + this.dataPosition = this.stream.position; + + this.objects.length = 0; + + this.state = this.readBody; + + if ( this.onHead ) { + + this.onHead( { + file: this, + sign: this.sign + } ); + + } + + return true; + +}; + +SEA3D.File.prototype.getObject = function ( index ) { + + return this.objects[ index ]; + +}; + +SEA3D.File.prototype.getObjectByName = function ( name ) { + + return this.objects[ name ]; + +}; + +SEA3D.File.prototype.readSEAObject = function () { + + if ( this.stream.bytesAvailable < 4 ) + return null; + + var size = this.stream.readUInt(), + position = this.stream.position; + + if ( this.stream.bytesAvailable < size ) + return null; + + var flag = this.stream.readUByte(), + type = this.stream.readExt(), + meta = null; + + var name = flag & 1 ? this.stream.readUTF8Tiny() : "", + compressed = ( flag & 2 ) != 0, + streaming = ( flag & 4 ) != 0; + + if ( flag & 8 ) { + + var metalen = this.stream.readUShort(); + var metabytes = this.stream.concat( this.stream.position, metalen ); + + this.stream.position += metalen; + + if ( compressed && this.decompressionMethod ) { + + metabytes.buffer = this.decompressionMethod( metabytes.buffer ); + + } + + meta = metabytes.readProperties( this ); + + } + + size -= this.stream.position - position; + position = this.stream.position; + + var data = this.stream.concat( position, size ), + obj; + + if ( this.typeClass[ type ] ) { + + if ( compressed && this.decompressionMethod ) { + + data.buffer = this.decompressionMethod( data.buffer ); + + } + + obj = new this.typeClass[ type ]( name, data, this ); + + if ( ( this.config.streaming && streaming || this.config.forceStreaming ) && this.typeRead[ type ] ) { + + this.typeRead[ type ].call( this.scope, obj ); + + } + + } else { + + obj = new SEA3D.Object( name, data, type, this ); + + console.warn( "SEA3D: Unknown format \"" + type + "\" of file \"" + name + "\". Add a module referring for this format." ); + + } + + obj.streaming = streaming; + obj.metadata = meta; + + this.objects.push( this.objects[ obj.name + "." + obj.type ] = obj ); + + this.dataPosition = position + size; + + ++ this.position; + + return obj; + +}; + +SEA3D.File.prototype.isDone = function () { + + return this.position == this.length; + +}; + +SEA3D.File.prototype.readBody = function () { + + this.timer.update(); + + if ( ! this.resume ) return false; + + while ( this.position < this.length ) { + + if ( this.timer.deltaTime < this.config.timeLimit ) { + + this.stream.position = this.dataPosition; + + var sea = this.readSEAObject(); + + if ( sea ) this.dispatchCompleteObject( sea ); + else return false; + + } else return false; + + } + + this.state = this.readComplete; + + return true; + +}; + +SEA3D.File.prototype.initParse = function () { + + this.timer = new SEA3D.Timer(); + this.position = 0; + this.resume = true; + +}; + +SEA3D.File.prototype.parse = function () { + + this.initParse(); + + if ( isFinite( this.config.timeLimit ) ) requestAnimationFrame( this.parseObject.bind( this ) ); + else this.parseObject(); + +}; + +SEA3D.File.prototype.parseObject = function () { + + this.timer.update(); + + while ( this.position < this.length && this.timer.deltaTime < this.config.timeLimit ) { + + var obj = this.objects[ this.position ++ ], + type = obj.type; + + if ( ! this.typeUnique[ type ] ) delete obj.tag; + + if ( ( obj.streaming || this.config.forceStreaming ) && this.typeRead[ type ] ) { + + if ( obj.tag == undefined ) { + + this.typeRead[ type ].call( this.scope, obj ); + + } + + } + + } + + if ( this.position == this.length ) { + + var elapsedTime = this.timer.elapsedTime; + var message = elapsedTime + "ms, " + this.objects.length + " objects"; + + if ( this.onParseComplete ) { + + this.onParseComplete( { + file: this, + timeTotal: elapsedTime, + message: message + } ); + + } else console.log( "SEA3D Parse Complete:", message ); + + } else { + + if ( this.onParseProgress ) { + + this.onParseProgress( { + file: this, + loaded: this.position, + total: this.length + } ); + + } + + setTimeout( this.parseObject.bind( this ), 10 ); + + } + +}; + +SEA3D.File.prototype.readComplete = function () { + + this.stream.position = this.dataPosition; + + if ( this.stream.readUInt24F() != 0x5EA3D1 ) + console.warn( "SEA3D file is corrupted." ); + + delete this.state; + + return false; + +}; + +SEA3D.File.prototype.readState = function () { + + while ( this.state() ) continue; + + if ( this.state ) { + + requestAnimationFrame( this.readState.bind( this ) ); + + this.dispatchProgress(); + + } else { + + this.dispatchComplete(); + + } + +}; + +SEA3D.File.prototype.append = function( buffer ) { + + if (this.state) { + + this.stream.append( buffer ); + + } else { + + this.read( buffer ); + + } + +}; + +SEA3D.File.prototype.read = function ( buffer ) { + + if ( ! buffer ) throw new Error( "No data found." ); + + this.initParse(); + + this.stream = new SEA3D.Stream( buffer ); + this.state = this.readHead; + + this.readState(); + +}; + +SEA3D.File.prototype.dispatchCompleteObject = function ( obj ) { + + if ( ! this.onCompleteObject ) return; + + this.onCompleteObject( { + file: this, + object: obj + } ); + +}; + +SEA3D.File.prototype.dispatchProgress = function () { + + if ( ! this.onProgress ) return; + + this.onProgress( { + file: this, + loaded: this.position, + total: this.length + } ); + +}; + +SEA3D.File.prototype.dispatchDownloadProgress = function ( position, length ) { + + if ( ! this.onDownloadProgress ) return; + + this.onDownloadProgress( { + file: this, + loaded: position, + total: length + } ); + +}; + +SEA3D.File.prototype.dispatchComplete = function () { + + var elapsedTime = this.timer.elapsedTime; + var message = elapsedTime + "ms, " + this.objects.length + " objects"; + + if ( this.onComplete ) this.onComplete( { + file: this, + timeTotal: elapsedTime, + message: message + } ); + else console.log( "SEA3D:", message ); + +}; + +SEA3D.File.prototype.dispatchError = function ( id, message ) { + + if ( this.onError ) this.onError( { file: this, id: id, message: message } ); + else console.error( "SEA3D: #" + id, message ); + +}; + +SEA3D.File.prototype.load = function ( url ) { + + var self = this, + xhr = new XMLHttpRequest(); + + xhr.open( "GET", url, true ); + + if (!this.config.path) { + +// this.config.path = THREE.Loader.prototype.extractUrlBase( url ); + this.config.path = THREE.LoaderUtils.extractUrlBase( url ); + + } + + if ( self.config.progressive ) { + + var position = 0; + + xhr.overrideMimeType( 'text/plain; charset=x-user-defined' ); + + } else { + + xhr.responseType = 'arraybuffer'; + + } + + xhr.onprogress = function ( e ) { + + if ( self.config.progressive ) { + + var binStr = xhr.responseText.substring( position ), + bytes = new Uint8Array( binStr.length ); + + for ( var i = 0; i < binStr.length; i ++ ) { + + bytes[ i ] = binStr.charCodeAt( i ) & 0xFF; + + } + + position += binStr.length; + + self.append( bytes.buffer ); + + } + + self.dispatchDownloadProgress( e.loaded, e.total ); + + }; + + if ( ! self.config.progressive ) { + + xhr.onreadystatechange = function () { + + if ( xhr.readyState === 4 ) { + + if ( xhr.status === 200 || xhr.status === 0 ) { + + self.read( this.response ); + + } else { + + this.dispatchError( 1001, "Couldn't load [" + url + "] [" + xhr.status + "]" ); + + } + + } + + }; + + } + + xhr.send(); + +}; diff --git a/three/jsutil/loaders/sea3d/SEA3DDeflate.js b/three/jsutil/loaders/sea3d/SEA3DDeflate.js new file mode 100644 index 000000000..998861d64 --- /dev/null +++ b/three/jsutil/loaders/sea3d/SEA3DDeflate.js @@ -0,0 +1,887 @@ +/* + * $Id: rawinflate.js,v 0.3 2013/04/09 14:25:38 dankogai Exp dankogai $ + * + * GNU General Public License, version 2 (GPL-2.0) + * http://opensource.org/licenses/GPL-2.0 + * original: + * http://www.onicos.com/staff/iz/amuse/javascript/expert/inflate.txt + */ + +'use strict'; + +SEA3D.Deflate = function () { + + /* Copyright (C) 1999 Masanao Izumo + * Version: 1.0.0.1 + * LastModified: Dec 25 1999 + */ + + /* Interface: + * data = zip_inflate(src); + */ + + /* constant parameters */ + var zip_WSIZE = 32768; // Sliding Window size + var zip_STORED_BLOCK = 0; + var zip_STATIC_TREES = 1; + var zip_DYN_TREES = 2; + + /* for inflate */ + var zip_lbits = 9; // bits in base literal/length lookup table + var zip_dbits = 6; // bits in base distance lookup table + var zip_INBUFSIZ = 32768; // Input buffer size + var zip_INBUF_EXTRA = 64; // Extra buffer + + /* variables (inflate) */ + var zip_slide; + var zip_wp; // current position in slide + var zip_fixed_tl = null; // inflate static + var zip_fixed_td; // inflate static + var zip_fixed_bl, fixed_bd, zip_fixed_bd; // inflate static + var zip_bit_buf; // bit buffer + var zip_bit_len; // bits in bit buffer + var zip_method; + var zip_eof; + var zip_copy_leng; + var zip_copy_dist; + var zip_tl, zip_td; // literal/length and distance decoder tables + var zip_bl, zip_bd; // number of bits decoded by tl and td + + var zip_inflate_data; + var zip_inflate_pos; + + + /* constant tables (inflate) */ + var zip_MASK_BITS = new Array( + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff ); + // Tables for deflate from PKZIP's appnote.txt. + var zip_cplens = new Array( // Copy lengths for literal codes 257..285 + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ); + /* note: see note #13 above about the 258 in this list. */ + var zip_cplext = new Array( // Extra bits for literal codes 257..285 + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 ); // 99==invalid + var zip_cpdist = new Array( // Copy offsets for distance codes 0..29 + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577 ); + var zip_cpdext = new Array( // Extra bits for distance codes + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13 ); + var zip_border = new Array( // Order of the bit length code lengths + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ); + /* objects (inflate) */ + + var zip_HuftList = function () { + + this.next = null; + this.list = null; + + } + + var zip_HuftNode = function () { + + this.e = 0; // number of extra bits or operation + this.b = 0; // number of bits in this code or subcode + + // union + this.n = 0; // literal, length base, or distance base + this.t = null; // (zip_HuftNode) pointer to next level of table + + } + + var zip_HuftBuild = function ( b, // code lengths in bits (all assumed <= BMAX) + n, // number of codes (assumed <= N_MAX) + s, // number of simple-valued codes (0..s-1) + d, // list of base values for non-simple codes + e, // list of extra bits for non-simple codes + mm // maximum lookup bits + ) { + + this.BMAX = 16; // maximum bit length of any code + this.N_MAX = 288; // maximum number of codes in any set + this.status = 0; // 0: success, 1: incomplete table, 2: bad input + this.root = null; // (zip_HuftList) starting table + this.m = 0; // maximum lookup bits, returns actual + + /* Given a list of code lengths and a maximum table size, make a set of + tables to decode that set of codes. Return zero on success, one if + the given code set is incomplete (the tables are still built in this + case), two if the input is invalid (all zero length codes or an + oversubscribed set of lengths), and three if not enough memory. + The code with value 256 is special, and the tables are constructed + so that no bits beyond that code are fetched when that code is + decoded. */ + { + + var a; // counter for codes of length k + var c = new Array( this.BMAX + 1 ); // bit length count table + var el; // length of EOB code (value 256) + var f; // i repeats in table every f entries + var g; // maximum code length + var h; // table level + var i; // counter, current code + var j; // counter + var k; // number of bits in current code + var lx = new Array( this.BMAX + 1 ); // stack of bits per table + var p; // pointer into c[], b[], or v[] + var pidx; // index of p + var q; // (zip_HuftNode) points to current table + var r = new zip_HuftNode(); // table entry for structure assignment + var u = new Array( this.BMAX ); // zip_HuftNode[BMAX][] table stack + var v = new Array( this.N_MAX ); // values in order of bit length + var w; + var x = new Array( this.BMAX + 1 );// bit offsets, then code stack + var xp; // pointer into x or c + var y; // number of dummy codes added + var z; // number of entries in current table + var o; + var tail; // (zip_HuftList) + + tail = this.root = null; + for ( i = 0; i < c.length; i ++ ) + c[ i ] = 0; + for ( i = 0; i < lx.length; i ++ ) + lx[ i ] = 0; + for ( i = 0; i < u.length; i ++ ) + u[ i ] = null; + for ( i = 0; i < v.length; i ++ ) + v[ i ] = 0; + for ( i = 0; i < x.length; i ++ ) + x[ i ] = 0; + + // Generate counts for each bit length + el = n > 256 ? b[ 256 ] : this.BMAX; // set length of EOB code, if any + p = b; pidx = 0; + i = n; + do { + + c[ p[ pidx ]] ++; // assume all entries <= BMAX + pidx ++; + + } while ( -- i > 0 ); + if ( c[ 0 ] == n ) { + + // null input--all zero length codes + this.root = null; + this.m = 0; + this.status = 0; + return; + + } + + // Find minimum and maximum length, bound *m by those + for ( j = 1; j <= this.BMAX; j ++ ) + if ( c[ j ] != 0 ) + break; + k = j; // minimum code length + if ( mm < j ) + mm = j; + for ( i = this.BMAX; i != 0; i -- ) + if ( c[ i ] != 0 ) + break; + g = i; // maximum code length + if ( mm > i ) + mm = i; + + // Adjust last length count to fill out codes, if needed + for ( y = 1 << j; j < i; j ++, y <<= 1 ) + if ( ( y -= c[ j ] ) < 0 ) { + + this.status = 2; // bad input: more codes than bits + this.m = mm; + return; + + } + if ( ( y -= c[ i ] ) < 0 ) { + + this.status = 2; + this.m = mm; + return; + + } + c[ i ] += y; + + // Generate starting offsets into the value table for each length + x[ 1 ] = j = 0; + p = c; + pidx = 1; + xp = 2; + while ( -- i > 0 ) // note that i == g from above + x[ xp ++ ] = ( j += p[ pidx ++ ] ); + + // Make a table of values in order of bit lengths + p = b; pidx = 0; + i = 0; + do { + + if ( ( j = p[ pidx ++ ] ) != 0 ) + v[ x[ j ] ++ ] = i; + + } while ( ++ i < n ); + n = x[ g ]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[ 0 ] = i = 0; // first Huffman code is zero + p = v; pidx = 0; // grab values in bit order + h = - 1; // no tables yet--level -1 + w = lx[ 0 ] = 0; // no bits decoded yet + q = null; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for ( ; k <= g; k ++ ) { + + a = c[ k ]; + while ( a -- > 0 ) { + + // here i is the Huffman code of length k bits for value p[pidx] + // make tables up to required level + while ( k > w + lx[ 1 + h ] ) { + + w += lx[ 1 + h ]; // add bits already decoded + h ++; + + // compute minimum size table less than or equal to *m bits + z = ( z = g - w ) > mm ? mm : z; // upper limit + if ( ( f = 1 << ( j = k - w ) ) > a + 1 ) { + + // try a k-w bit table + // too few codes for k-w bit table + f -= a + 1; // deduct codes from patterns left + xp = k; + while ( ++ j < z ) { + + // try smaller tables up to z bits + if ( ( f <<= 1 ) <= c[ ++ xp ] ) + break; // enough codes to use up j bits + f -= c[ xp ]; // else deduct codes from patterns + + } + + } + if ( w + j > el && w < el ) + j = el - w; // make EOB code end at table + z = 1 << j; // table entries for j-bit table + lx[ 1 + h ] = j; // set table size in stack + + // allocate and link in new table + q = new Array( z ); + for ( o = 0; o < z; o ++ ) { + + q[ o ] = new zip_HuftNode(); + + } + + if ( tail == null ) + tail = this.root = new zip_HuftList(); + else + tail = tail.next = new zip_HuftList(); + tail.next = null; + tail.list = q; + u[ h ] = q; // table starts after link + + /* connect to last table, if there is one */ + if ( h > 0 ) { + + x[ h ] = i; // save pattern for backing up + r.b = lx[ h ]; // bits to dump before this table + r.e = 16 + j; // bits in this table + r.t = q; // pointer to this table + j = ( i & ( ( 1 << w ) - 1 ) ) >> ( w - lx[ h ] ); + u[ h - 1 ][ j ].e = r.e; + u[ h - 1 ][ j ].b = r.b; + u[ h - 1 ][ j ].n = r.n; + u[ h - 1 ][ j ].t = r.t; + + } + + } + + // set up table entry in r + r.b = k - w; + if ( pidx >= n ) + r.e = 99; // out of values--invalid code + else if ( p[ pidx ] < s ) { + + r.e = ( p[ pidx ] < 256 ? 16 : 15 ); // 256 is end-of-block code + r.n = p[ pidx ++ ]; // simple code is just the value + + } else { + + r.e = e[ p[ pidx ] - s ]; // non-simple--look up in lists + r.n = d[ p[ pidx ++ ] - s ]; + + } + + // fill code-like entries with r // + f = 1 << ( k - w ); + for ( j = i >> w; j < z; j += f ) { + + q[ j ].e = r.e; + q[ j ].b = r.b; + q[ j ].n = r.n; + q[ j ].t = r.t; + + } + + // backwards increment the k-bit code i + for ( j = 1 << ( k - 1 ); ( i & j ) != 0; j >>= 1 ) + i ^= j; + i ^= j; + + // backup over finished tables + while ( ( i & ( ( 1 << w ) - 1 ) ) != x[ h ] ) { + + w -= lx[ h ]; // don't need to update q + h --; + + } + + } + + } + + /* return actual size of base table */ + this.m = lx[ 1 ]; + + /* Return true (1) if we were given an incomplete table */ + this.status = ( ( y != 0 && g != 1 ) ? 1 : 0 ); + + } /* end of constructor */ + + } + + + /* routines (inflate) */ + + var zip_GET_BYTE = function () { + + if ( zip_inflate_data.length == zip_inflate_pos ) + return - 1; + return zip_inflate_data[ zip_inflate_pos ++ ]; + + } + + var zip_NEEDBITS = function ( n ) { + + while ( zip_bit_len < n ) { + + zip_bit_buf |= zip_GET_BYTE() << zip_bit_len; + zip_bit_len += 8; + + } + + } + + var zip_GETBITS = function ( n ) { + + return zip_bit_buf & zip_MASK_BITS[ n ]; + + } + + var zip_DUMPBITS = function ( n ) { + + zip_bit_buf >>= n; + zip_bit_len -= n; + + } + + var zip_inflate_codes = function ( buff, off, size ) { + + /* inflate (decompress) the codes in a deflated (compressed) block. + Return an error code or zero if it all goes ok. */ + var e; // table entry flag/number of extra bits + var t; // (zip_HuftNode) pointer to table entry + var n; + + if ( size == 0 ) + return 0; + + // inflate the coded data + n = 0; + for ( ;; ) { + + // do until end of block + zip_NEEDBITS( zip_bl ); + t = zip_tl.list[ zip_GETBITS( zip_bl ) ]; + e = t.e; + while ( e > 16 ) { + + if ( e == 99 ) + return - 1; + zip_DUMPBITS( t.b ); + e -= 16; + zip_NEEDBITS( e ); + t = t.t[ zip_GETBITS( e ) ]; + e = t.e; + + } + zip_DUMPBITS( t.b ); + + if ( e == 16 ) { + + // then it's a literal + zip_wp &= zip_WSIZE - 1; + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = t.n; + if ( n == size ) + return size; + continue; + + } + + // exit if end of block + if ( e == 15 ) + break; + + // it's an EOB or a length + + // get length of block to copy + zip_NEEDBITS( e ); + zip_copy_leng = t.n + zip_GETBITS( e ); + zip_DUMPBITS( e ); + + // decode distance of block to copy + zip_NEEDBITS( zip_bd ); + t = zip_td.list[ zip_GETBITS( zip_bd ) ]; + e = t.e; + + while ( e > 16 ) { + + if ( e == 99 ) + return - 1; + zip_DUMPBITS( t.b ); + e -= 16; + zip_NEEDBITS( e ); + t = t.t[ zip_GETBITS( e ) ]; + e = t.e; + + } + zip_DUMPBITS( t.b ); + zip_NEEDBITS( e ); + zip_copy_dist = zip_wp - t.n - zip_GETBITS( e ); + zip_DUMPBITS( e ); + + // do the copy + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_copy_dist &= zip_WSIZE - 1; + zip_wp &= zip_WSIZE - 1; + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] + = zip_slide[ zip_copy_dist ++ ]; + + } + + if ( n == size ) + return size; + + } + + zip_method = - 1; // done + return n; + + } + + var zip_inflate_stored = function ( buff, off, size ) { + + /* "decompress" an inflated type 0 (stored) block. */ + var n; + + // go to byte boundary + n = zip_bit_len & 7; + zip_DUMPBITS( n ); + + // get the length and its complement + zip_NEEDBITS( 16 ); + n = zip_GETBITS( 16 ); + zip_DUMPBITS( 16 ); + zip_NEEDBITS( 16 ); + if ( n != ( ( ~ zip_bit_buf ) & 0xffff ) ) + return - 1; // error in compressed data + zip_DUMPBITS( 16 ); + + // read and output the compressed data + zip_copy_leng = n; + + n = 0; + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_wp &= zip_WSIZE - 1; + zip_NEEDBITS( 8 ); + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = + zip_GETBITS( 8 ); + zip_DUMPBITS( 8 ); + + } + + if ( zip_copy_leng == 0 ) + zip_method = - 1; // done + return n; + + } + + var zip_inflate_fixed = function ( buff, off, size ) { + + /* decompress an inflated type 1 (fixed Huffman codes) block. We should + either replace this with a custom decoder, or at least precompute the + Huffman tables. */ + + // if first time, set up tables for fixed blocks + if ( zip_fixed_tl == null ) { + + var i; // temporary variable + var l = new Array( 288 ); // length list for huft_build + var h; // zip_HuftBuild + + // literal table + for ( i = 0; i < 144; i ++ ) + l[ i ] = 8; + for ( ; i < 256; i ++ ) + l[ i ] = 9; + for ( ; i < 280; i ++ ) + l[ i ] = 7; + for ( ; i < 288; i ++ ) // make a complete, but wrong code set + l[ i ] = 8; + zip_fixed_bl = 7; + + h = new zip_HuftBuild( l, 288, 257, zip_cplens, zip_cplext, + zip_fixed_bl ); + if ( h.status != 0 ) { + + alert( "HufBuild error: " + h.status ); + return - 1; + + } + zip_fixed_tl = h.root; + zip_fixed_bl = h.m; + + // distance table + for ( i = 0; i < 30; i ++ ) // make an incomplete code set + l[ i ] = 5; + zip_fixed_bd = 5; + + h = new zip_HuftBuild( l, 30, 0, zip_cpdist, zip_cpdext, zip_fixed_bd ); + if ( h.status > 1 ) { + + zip_fixed_tl = null; + alert( "HufBuild error: " + h.status ); + return - 1; + + } + zip_fixed_td = h.root; + zip_fixed_bd = h.m; + + } + + zip_tl = zip_fixed_tl; + zip_td = zip_fixed_td; + zip_bl = zip_fixed_bl; + zip_bd = zip_fixed_bd; + return zip_inflate_codes( buff, off, size ); + + } + + var zip_inflate_dynamic = function ( buff, off, size ) { + + // decompress an inflated type 2 (dynamic Huffman codes) block. + var i; // temporary variables + var j; + var l; // last length + var n; // number of lengths to get + var t; // (zip_HuftNode) literal/length code table + var nb; // number of bit length codes + var nl; // number of literal/length codes + var nd; // number of distance codes + var ll = new Array( 286 + 30 ); // literal/length and distance code lengths + var h; // (zip_HuftBuild) + + for ( i = 0; i < ll.length; i ++ ) + ll[ i ] = 0; + + // read in table lengths + zip_NEEDBITS( 5 ); + nl = 257 + zip_GETBITS( 5 ); // number of literal/length codes + zip_DUMPBITS( 5 ); + zip_NEEDBITS( 5 ); + nd = 1 + zip_GETBITS( 5 ); // number of distance codes + zip_DUMPBITS( 5 ); + zip_NEEDBITS( 4 ); + nb = 4 + zip_GETBITS( 4 ); // number of bit length codes + zip_DUMPBITS( 4 ); + if ( nl > 286 || nd > 30 ) + return - 1; // bad lengths + + // read in bit-length-code lengths + for ( j = 0; j < nb; j ++ ) + { + + zip_NEEDBITS( 3 ); + ll[ zip_border[ j ]] = zip_GETBITS( 3 ); + zip_DUMPBITS( 3 ); + + } + for ( ; j < 19; j ++ ) + ll[ zip_border[ j ]] = 0; + + // build decoding table for trees--single level, 7 bit lookup + zip_bl = 7; + h = new zip_HuftBuild( ll, 19, 19, null, null, zip_bl ); + if ( h.status != 0 ) + return - 1; // incomplete code set + + zip_tl = h.root; + zip_bl = h.m; + + // read in literal and distance code lengths + n = nl + nd; + i = l = 0; + while ( i < n ) { + + zip_NEEDBITS( zip_bl ); + t = zip_tl.list[ zip_GETBITS( zip_bl ) ]; + j = t.b; + zip_DUMPBITS( j ); + j = t.n; + if ( j < 16 ) // length of code in bits (0..15) + ll[ i ++ ] = l = j; // save last length in l + else if ( j == 16 ) { + + // repeat last length 3 to 6 times + zip_NEEDBITS( 2 ); + j = 3 + zip_GETBITS( 2 ); + zip_DUMPBITS( 2 ); + if ( i + j > n ) + return - 1; + while ( j -- > 0 ) + ll[ i ++ ] = l; + + } else if ( j == 17 ) { + + // 3 to 10 zero length codes + zip_NEEDBITS( 3 ); + j = 3 + zip_GETBITS( 3 ); + zip_DUMPBITS( 3 ); + if ( i + j > n ) + return - 1; + while ( j -- > 0 ) + ll[ i ++ ] = 0; + l = 0; + + } else { + + // j == 18: 11 to 138 zero length codes + zip_NEEDBITS( 7 ); + j = 11 + zip_GETBITS( 7 ); + zip_DUMPBITS( 7 ); + if ( i + j > n ) + return - 1; + while ( j -- > 0 ) + ll[ i ++ ] = 0; + l = 0; + + } + + } + + // build the decoding tables for literal/length and distance codes + zip_bl = zip_lbits; + h = new zip_HuftBuild( ll, nl, 257, zip_cplens, zip_cplext, zip_bl ); + if ( zip_bl == 0 ) // no literals or lengths + h.status = 1; + if ( h.status != 0 ) { + + /*if(h.status == 1) + ;// **incomplete literal tree** */ + return - 1; // incomplete code set + + } + zip_tl = h.root; + zip_bl = h.m; + + for ( i = 0; i < nd; i ++ ) + ll[ i ] = ll[ i + nl ]; + zip_bd = zip_dbits; + h = new zip_HuftBuild( ll, nd, 0, zip_cpdist, zip_cpdext, zip_bd ); + zip_td = h.root; + zip_bd = h.m; + + if ( zip_bd == 0 && nl > 257 ) { + + // lengths but no distances + // **incomplete distance tree** + return - 1; + + } + + /*if(h.status == 1) { + ;// **incomplete distance tree** + }*/ + if ( h.status != 0 ) + return - 1; + + // decompress until an end-of-block code + return zip_inflate_codes( buff, off, size ); + + } + + var zip_inflate_start = function () { + + var i; + + if ( zip_slide == null ) + zip_slide = new Array( 2 * zip_WSIZE ); + zip_wp = 0; + zip_bit_buf = 0; + zip_bit_len = 0; + zip_method = - 1; + zip_eof = false; + zip_copy_leng = zip_copy_dist = 0; + zip_tl = null; + + } + + var zip_inflate_internal = function ( buff, off, size ) { + + // decompress an inflated entry + var n, i; + + n = 0; + while ( n < size ) { + + if ( zip_eof && zip_method == - 1 ) + return n; + + if ( zip_copy_leng > 0 ) { + + if ( zip_method != zip_STORED_BLOCK ) { + + // STATIC_TREES or DYN_TREES + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_copy_dist &= zip_WSIZE - 1; + zip_wp &= zip_WSIZE - 1; + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = + zip_slide[ zip_copy_dist ++ ]; + + } + + } else { + + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_wp &= zip_WSIZE - 1; + zip_NEEDBITS( 8 ); + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = zip_GETBITS( 8 ); + zip_DUMPBITS( 8 ); + + } + if ( zip_copy_leng == 0 ) + zip_method = - 1; // done + + } + if ( n == size ) + return n; + + } + + if ( zip_method == - 1 ) { + + if ( zip_eof ) + break; + + // read in last block bit + zip_NEEDBITS( 1 ); + if ( zip_GETBITS( 1 ) != 0 ) + zip_eof = true; + zip_DUMPBITS( 1 ); + + // read in block type + zip_NEEDBITS( 2 ); + zip_method = zip_GETBITS( 2 ); + zip_DUMPBITS( 2 ); + zip_tl = null; + zip_copy_leng = 0; + + } + + switch ( zip_method ) { + case 0: // zip_STORED_BLOCK + i = zip_inflate_stored( buff, off + n, size - n ); + break; + + case 1: // zip_STATIC_TREES + if ( zip_tl != null ) + i = zip_inflate_codes( buff, off + n, size - n ); + else + i = zip_inflate_fixed( buff, off + n, size - n ); + break; + + case 2: // zip_DYN_TREES + if ( zip_tl != null ) + i = zip_inflate_codes( buff, off + n, size - n ); + else + i = zip_inflate_dynamic( buff, off + n, size - n ); + break; + + default: // error + i = - 1; + } + + if ( i == - 1 ) { + + if ( zip_eof ) + return 0; + return - 1; + + } + n += i; + + } + return n; + + } + + var zip_inflate = function ( data ) { + + var i, j, pos = 0; + + zip_inflate_start(); + zip_inflate_data = new Uint8Array( data ); + zip_inflate_pos = 0; + + var buff = new Uint8Array( 1024 ); + + var out = []; + while ( ( i = zip_inflate_internal( buff, 0, buff.length ) ) > 0 ) + for ( j = 0; j < i; j ++ ) + out[ pos ++ ] = buff[ j ]; + + zip_inflate_data = null; // G.C. + return new Uint8Array( out ).buffer; + + } + + return { inflate: zip_inflate }; + +}(); + +/** + * SEA3D Deflate + * @author Sunag / http://www.sunag.com.br/ + */ + +SEA3D.File.DeflateUncompress = function ( data ) { + + return SEA3D.Deflate.inflate( data ); + +}; + +SEA3D.File.setDecompressionEngine( 1, "deflate", SEA3D.File.DeflateUncompress ); diff --git a/three/jsutil/loaders/sea3d/SEA3DDraco.js b/three/jsutil/loaders/sea3d/SEA3DDraco.js new file mode 100644 index 000000000..a13f5265a --- /dev/null +++ b/three/jsutil/loaders/sea3d/SEA3DDraco.js @@ -0,0 +1,212 @@ +/** + * SEA3D - Google Draco + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +// +// Lossy Compression +// + +SEA3D.GeometryDraco = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var attrib = data.readUShort(), + i; + + this.isBig = ( attrib & 1 ) !== 0; + + data.readVInt = this.isBig ? data.readUInt : data.readUShort; + + this.groups = []; + + if ( attrib & 32 ) { + + this.uv = []; + this.uv.length = data.readUByte(); + + } + + if ( attrib & 1024 ) { + + var numGroups = data.readUByte(), + groupOffset = 0; + + for ( i = 0; i < numGroups; i ++ ) { + + var groupLength = data.readVInt() * 3; + + this.groups.push( { + start: groupOffset, + count: groupLength, + } ); + + groupOffset += groupLength; + + } + + } + + var module = SEA3D.GeometryDraco.getModule(), + dracoData = new Int8Array( data.concat( data.position, data.bytesAvailable ).buffer ); + + var decoder = new module.Decoder(); + + var buffer = new module.DecoderBuffer(); + buffer.Init( dracoData, dracoData.length ); + + var mesh = new module.Mesh(); + + var decodingStatus = decoder.DecodeBufferToMesh( buffer, mesh ); + + if ( ! decodingStatus.ok() ) { + + data.position += 5; // jump "DRACO" magic string + var version = data.readUByte() + '.' + data.readUByte(); // draco version + + console.error( "SEA3D Draco", version, "decoding failed:", decodingStatus.error_msg(), "You may need update 'draco_decoder.js'." ); + + // use an empty geometry + this.vertex = new Float32Array(); + + return; + + } + + var index = 0; + + this.vertex = this.readFloat32Array( module, decoder, mesh, index ++ ); + + if ( attrib & 4 ) this.normal = this.readFloat32Array( module, decoder, mesh, index ++ ); + + if ( attrib & 32 ) { + + for ( i = 0; i < this.uv.length; i ++ ) { + + this.uv[ i ] = this.readFloat32Array( module, decoder, mesh, index ++ ); + + } + + } + + if ( attrib & 64 ) { + + this.jointPerVertex = decoder.GetAttribute( mesh, index ).num_components(); + + this.joint = this.readUint16Array( module, decoder, mesh, index ++ ); + this.weight = this.readFloat32Array( module, decoder, mesh, index ++ ); + + } + + this.indexes = this.readIndices( module, decoder, mesh ); + + module.destroy( mesh ); + module.destroy( buffer ); + module.destroy( decoder ); + +}; + +SEA3D.GeometryDraco.getModule = function () { + + if ( ! this.module ) { + + this.module = DracoDecoderModule(); + + } + + return this.module; + +}; + +SEA3D.GeometryDraco.prototype.type = "sdrc"; + +SEA3D.GeometryDraco.prototype.readIndices = function ( module, decoder, mesh ) { + + var numFaces = mesh.num_faces(), + numIndices = numFaces * 3, + indices = new ( numIndices >= 0xFFFE ? Uint32Array : Uint16Array )( numIndices ); + + var ia = new module.DracoInt32Array(); + + for ( var i = 0; i < numFaces; ++ i ) { + + decoder.GetFaceFromMesh( mesh, i, ia ); + + var index = i * 3; + + indices[ index ] = ia.GetValue( 0 ); + indices[ index + 1 ] = ia.GetValue( 1 ); + indices[ index + 2 ] = ia.GetValue( 2 ); + + } + + module.destroy( ia ); + + return indices; + +}; + +SEA3D.GeometryDraco.prototype.readFloat32Array = function ( module, decoder, mesh, attrib ) { + + var attribute = decoder.GetAttribute( mesh, attrib ), + numPoints = mesh.num_points(); + + var dracoArray = new module.DracoFloat32Array(); + decoder.GetAttributeFloatForAllPoints( mesh, attribute, dracoArray ); + + var size = numPoints * attribute.num_components(), + output = new Float32Array( size ); + + for ( var i = 0; i < size; ++ i ) { + + output[ i ] = dracoArray.GetValue( i ); + + } + + module.destroy( dracoArray ); + + return output; + +}; + +SEA3D.GeometryDraco.prototype.readUint16Array = function ( module, decoder, mesh, attrib, type ) { + + var attribute = decoder.GetAttribute( mesh, attrib ), + numPoints = mesh.num_points(); + + var dracoArray = new module.DracoUInt16Array(); + decoder.GetAttributeUInt16ForAllPoints( mesh, attribute, dracoArray ); + + var size = numPoints * attribute.num_components(), + output = new Uint16Array( size ); + + for ( var i = 0; i < size; ++ i ) { + + output[ i ] = dracoArray.GetValue( i ); + + } + + module.destroy( dracoArray ); + + return output; + +}; + +// +// Extension +// + +THREE.SEA3D.EXTENSIONS_LOADER.push( { + + setTypeRead: function () { + + this.file.addClass( SEA3D.GeometryDraco, true ); + this.file.typeRead[ SEA3D.GeometryDraco.prototype.type ] = this.readGeometryBuffer; + + } + +} ); diff --git a/three/jsutil/loaders/sea3d/SEA3DLZMA.js b/three/jsutil/loaders/sea3d/SEA3DLZMA.js new file mode 100644 index 000000000..f1e09eb2d --- /dev/null +++ b/three/jsutil/loaders/sea3d/SEA3DLZMA.js @@ -0,0 +1,810 @@ +/* +Copyright (c) 2011 Juan Mellado + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* +References: +- "LZMA SDK" by Igor Pavlov + http://www.7-zip.org/sdk.html +*/ + +'use strict'; + +SEA3D.LZMA = function () { + + var LZMA = LZMA || {}; + + LZMA.OutWindow = function () { + + this._windowSize = 0; + + }; + + LZMA.OutWindow.prototype.create = function ( windowSize ) { + + if ( ( ! this._buffer ) || ( this._windowSize !== windowSize ) ) { + + this._buffer = []; + + } + this._windowSize = windowSize; + this._pos = 0; + this._streamPos = 0; + + }; + + LZMA.OutWindow.prototype.flush = function () { + + var size = this._pos - this._streamPos; + if ( size !== 0 ) { + + while ( size -- ) { + + this._stream.writeByte( this._buffer[ this._streamPos ++ ] ); + + } + if ( this._pos >= this._windowSize ) { + + this._pos = 0; + + } + this._streamPos = this._pos; + + } + + }; + + LZMA.OutWindow.prototype.releaseStream = function () { + + this.flush(); + this._stream = null; + + }; + + LZMA.OutWindow.prototype.setStream = function ( stream ) { + + this.releaseStream(); + this._stream = stream; + + }; + + LZMA.OutWindow.prototype.init = function ( solid ) { + + if ( ! solid ) { + + this._streamPos = 0; + this._pos = 0; + + } + + }; + + LZMA.OutWindow.prototype.copyBlock = function ( distance, len ) { + + var pos = this._pos - distance - 1; + if ( pos < 0 ) { + + pos += this._windowSize; + + } + while ( len -- ) { + + if ( pos >= this._windowSize ) { + + pos = 0; + + } + this._buffer[ this._pos ++ ] = this._buffer[ pos ++ ]; + if ( this._pos >= this._windowSize ) { + + this.flush(); + + } + + } + + }; + + LZMA.OutWindow.prototype.putByte = function ( b ) { + + this._buffer[ this._pos ++ ] = b; + if ( this._pos >= this._windowSize ) { + + this.flush(); + + } + + }; + + LZMA.OutWindow.prototype.getByte = function ( distance ) { + + var pos = this._pos - distance - 1; + if ( pos < 0 ) { + + pos += this._windowSize; + + } + return this._buffer[ pos ]; + + }; + + LZMA.RangeDecoder = function () { + }; + + LZMA.RangeDecoder.prototype.setStream = function ( stream ) { + + this._stream = stream; + + }; + + LZMA.RangeDecoder.prototype.releaseStream = function () { + + this._stream = null; + + }; + + LZMA.RangeDecoder.prototype.init = function () { + + var i = 5; + + this._code = 0; + this._range = - 1; + + while ( i -- ) { + + this._code = ( this._code << 8 ) | this._stream.readByte(); + + } + + }; + + LZMA.RangeDecoder.prototype.decodeDirectBits = function ( numTotalBits ) { + + var result = 0, i = numTotalBits, t; + + while ( i -- ) { + + this._range >>>= 1; + t = ( this._code - this._range ) >>> 31; + this._code -= this._range & ( t - 1 ); + result = ( result << 1 ) | ( 1 - t ); + + if ( ( this._range & 0xff000000 ) === 0 ) { + + this._code = ( this._code << 8 ) | this._stream.readByte(); + this._range <<= 8; + + } + + } + + return result; + + }; + + LZMA.RangeDecoder.prototype.decodeBit = function ( probs, index ) { + + var prob = probs[ index ], + newBound = ( this._range >>> 11 ) * prob; + + if ( ( this._code ^ 0x80000000 ) < ( newBound ^ 0x80000000 ) ) { + + this._range = newBound; + probs[ index ] += ( 2048 - prob ) >>> 5; + if ( ( this._range & 0xff000000 ) === 0 ) { + + this._code = ( this._code << 8 ) | this._stream.readByte(); + this._range <<= 8; + + } + return 0; + + } + + this._range -= newBound; + this._code -= newBound; + probs[ index ] -= prob >>> 5; + if ( ( this._range & 0xff000000 ) === 0 ) { + + this._code = ( this._code << 8 ) | this._stream.readByte(); + this._range <<= 8; + + } + return 1; + + }; + + LZMA.initBitModels = function ( probs, len ) { + + while ( len -- ) { + + probs[ len ] = 1024; + + } + + }; + + LZMA.BitTreeDecoder = function ( numBitLevels ) { + + this._models = []; + this._numBitLevels = numBitLevels; + + }; + + LZMA.BitTreeDecoder.prototype.init = function () { + + LZMA.initBitModels( this._models, 1 << this._numBitLevels ); + + }; + + LZMA.BitTreeDecoder.prototype.decode = function ( rangeDecoder ) { + + var m = 1, i = this._numBitLevels; + + while ( i -- ) { + + m = ( m << 1 ) | rangeDecoder.decodeBit( this._models, m ); + + } + return m - ( 1 << this._numBitLevels ); + + }; + + LZMA.BitTreeDecoder.prototype.reverseDecode = function ( rangeDecoder ) { + + var m = 1, symbol = 0, i = 0, bit; + + for ( ; i < this._numBitLevels; ++ i ) { + + bit = rangeDecoder.decodeBit( this._models, m ); + m = ( m << 1 ) | bit; + symbol |= bit << i; + + } + return symbol; + + }; + + LZMA.reverseDecode2 = function ( models, startIndex, rangeDecoder, numBitLevels ) { + + var m = 1, symbol = 0, i = 0, bit; + + for ( ; i < numBitLevels; ++ i ) { + + bit = rangeDecoder.decodeBit( models, startIndex + m ); + m = ( m << 1 ) | bit; + symbol |= bit << i; + + } + return symbol; + + }; + + LZMA.LenDecoder = function () { + + this._choice = []; + this._lowCoder = []; + this._midCoder = []; + this._highCoder = new LZMA.BitTreeDecoder( 8 ); + this._numPosStates = 0; + + }; + + LZMA.LenDecoder.prototype.create = function ( numPosStates ) { + + for ( ; this._numPosStates < numPosStates; ++ this._numPosStates ) { + + this._lowCoder[ this._numPosStates ] = new LZMA.BitTreeDecoder( 3 ); + this._midCoder[ this._numPosStates ] = new LZMA.BitTreeDecoder( 3 ); + + } + + }; + + LZMA.LenDecoder.prototype.init = function () { + + var i = this._numPosStates; + LZMA.initBitModels( this._choice, 2 ); + while ( i -- ) { + + this._lowCoder[ i ].init(); + this._midCoder[ i ].init(); + + } + this._highCoder.init(); + + }; + + LZMA.LenDecoder.prototype.decode = function ( rangeDecoder, posState ) { + + if ( rangeDecoder.decodeBit( this._choice, 0 ) === 0 ) { + + return this._lowCoder[ posState ].decode( rangeDecoder ); + + } + if ( rangeDecoder.decodeBit( this._choice, 1 ) === 0 ) { + + return 8 + this._midCoder[ posState ].decode( rangeDecoder ); + + } + return 16 + this._highCoder.decode( rangeDecoder ); + + }; + + LZMA.Decoder2 = function () { + + this._decoders = []; + + }; + + LZMA.Decoder2.prototype.init = function () { + + LZMA.initBitModels( this._decoders, 0x300 ); + + }; + + LZMA.Decoder2.prototype.decodeNormal = function ( rangeDecoder ) { + + var symbol = 1; + + do { + + symbol = ( symbol << 1 ) | rangeDecoder.decodeBit( this._decoders, symbol ); + + }while ( symbol < 0x100 ); + + return symbol & 0xff; + + }; + + LZMA.Decoder2.prototype.decodeWithMatchByte = function ( rangeDecoder, matchByte ) { + + var symbol = 1, matchBit, bit; + + do { + + matchBit = ( matchByte >> 7 ) & 1; + matchByte <<= 1; + bit = rangeDecoder.decodeBit( this._decoders, ( ( 1 + matchBit ) << 8 ) + symbol ); + symbol = ( symbol << 1 ) | bit; + if ( matchBit !== bit ) { + + while ( symbol < 0x100 ) { + + symbol = ( symbol << 1 ) | rangeDecoder.decodeBit( this._decoders, symbol ); + + } + break; + + } + + }while ( symbol < 0x100 ); + + return symbol & 0xff; + + }; + + LZMA.LiteralDecoder = function () { + }; + + LZMA.LiteralDecoder.prototype.create = function ( numPosBits, numPrevBits ) { + + var i; + + if ( this._coders + && ( this._numPrevBits === numPrevBits ) + && ( this._numPosBits === numPosBits ) ) { + + return; + + } + this._numPosBits = numPosBits; + this._posMask = ( 1 << numPosBits ) - 1; + this._numPrevBits = numPrevBits; + + this._coders = []; + + i = 1 << ( this._numPrevBits + this._numPosBits ); + while ( i -- ) { + + this._coders[ i ] = new LZMA.Decoder2(); + + } + + }; + + LZMA.LiteralDecoder.prototype.init = function () { + + var i = 1 << ( this._numPrevBits + this._numPosBits ); + while ( i -- ) { + + this._coders[ i ].init(); + + } + + }; + + LZMA.LiteralDecoder.prototype.getDecoder = function ( pos, prevByte ) { + + return this._coders[ ( ( pos & this._posMask ) << this._numPrevBits ) + + ( ( prevByte & 0xff ) >>> ( 8 - this._numPrevBits ) ) ]; + + }; + + LZMA.Decoder = function () { + + this._outWindow = new LZMA.OutWindow(); + this._rangeDecoder = new LZMA.RangeDecoder(); + this._isMatchDecoders = []; + this._isRepDecoders = []; + this._isRepG0Decoders = []; + this._isRepG1Decoders = []; + this._isRepG2Decoders = []; + this._isRep0LongDecoders = []; + this._posSlotDecoder = []; + this._posDecoders = []; + this._posAlignDecoder = new LZMA.BitTreeDecoder( 4 ); + this._lenDecoder = new LZMA.LenDecoder(); + this._repLenDecoder = new LZMA.LenDecoder(); + this._literalDecoder = new LZMA.LiteralDecoder(); + this._dictionarySize = - 1; + this._dictionarySizeCheck = - 1; + + this._posSlotDecoder[ 0 ] = new LZMA.BitTreeDecoder( 6 ); + this._posSlotDecoder[ 1 ] = new LZMA.BitTreeDecoder( 6 ); + this._posSlotDecoder[ 2 ] = new LZMA.BitTreeDecoder( 6 ); + this._posSlotDecoder[ 3 ] = new LZMA.BitTreeDecoder( 6 ); + + }; + + LZMA.Decoder.prototype.setDictionarySize = function ( dictionarySize ) { + + if ( dictionarySize < 0 ) { + + return false; + + } + if ( this._dictionarySize !== dictionarySize ) { + + this._dictionarySize = dictionarySize; + this._dictionarySizeCheck = Math.max( this._dictionarySize, 1 ); + this._outWindow.create( Math.max( this._dictionarySizeCheck, 4096 ) ); + + } + return true; + + }; + + LZMA.Decoder.prototype.setLcLpPb = function ( lc, lp, pb ) { + + var numPosStates = 1 << pb; + + if ( lc > 8 || lp > 4 || pb > 4 ) { + + return false; + + } + + this._literalDecoder.create( lp, lc ); + + this._lenDecoder.create( numPosStates ); + this._repLenDecoder.create( numPosStates ); + this._posStateMask = numPosStates - 1; + + return true; + + }; + + LZMA.Decoder.prototype.init = function () { + + var i = 4; + + this._outWindow.init( false ); + + LZMA.initBitModels( this._isMatchDecoders, 192 ); + LZMA.initBitModels( this._isRep0LongDecoders, 192 ); + LZMA.initBitModels( this._isRepDecoders, 12 ); + LZMA.initBitModels( this._isRepG0Decoders, 12 ); + LZMA.initBitModels( this._isRepG1Decoders, 12 ); + LZMA.initBitModels( this._isRepG2Decoders, 12 ); + LZMA.initBitModels( this._posDecoders, 114 ); + + this._literalDecoder.init(); + + while ( i -- ) { + + this._posSlotDecoder[ i ].init(); + + } + + this._lenDecoder.init(); + this._repLenDecoder.init(); + this._posAlignDecoder.init(); + this._rangeDecoder.init(); + + }; + + LZMA.Decoder.prototype.decode = function ( inStream, outStream, outSize ) { + + var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0, + posState, decoder2, len, distance, posSlot, numDirectBits; + + this._rangeDecoder.setStream( inStream ); + this._outWindow.setStream( outStream ); + + this.init(); + + while ( outSize < 0 || nowPos64 < outSize ) { + + posState = nowPos64 & this._posStateMask; + + if ( this._rangeDecoder.decodeBit( this._isMatchDecoders, ( state << 4 ) + posState ) === 0 ) { + + decoder2 = this._literalDecoder.getDecoder( nowPos64 ++, prevByte ); + + if ( state >= 7 ) { + + prevByte = decoder2.decodeWithMatchByte( this._rangeDecoder, this._outWindow.getByte( rep0 ) ); + + } else { + + prevByte = decoder2.decodeNormal( this._rangeDecoder ); + + } + this._outWindow.putByte( prevByte ); + + state = state < 4 ? 0 : state - ( state < 10 ? 3 : 6 ); + + } else { + + if ( this._rangeDecoder.decodeBit( this._isRepDecoders, state ) === 1 ) { + + len = 0; + if ( this._rangeDecoder.decodeBit( this._isRepG0Decoders, state ) === 0 ) { + + if ( this._rangeDecoder.decodeBit( this._isRep0LongDecoders, ( state << 4 ) + posState ) === 0 ) { + + state = state < 7 ? 9 : 11; + len = 1; + + } + + } else { + + if ( this._rangeDecoder.decodeBit( this._isRepG1Decoders, state ) === 0 ) { + + distance = rep1; + + } else { + + if ( this._rangeDecoder.decodeBit( this._isRepG2Decoders, state ) === 0 ) { + + distance = rep2; + + } else { + + distance = rep3; + rep3 = rep2; + + } + rep2 = rep1; + + } + rep1 = rep0; + rep0 = distance; + + } + if ( len === 0 ) { + + len = 2 + this._repLenDecoder.decode( this._rangeDecoder, posState ); + state = state < 7 ? 8 : 11; + + } + + } else { + + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + + len = 2 + this._lenDecoder.decode( this._rangeDecoder, posState ); + state = state < 7 ? 7 : 10; + + posSlot = this._posSlotDecoder[ len <= 5 ? len - 2 : 3 ].decode( this._rangeDecoder ); + if ( posSlot >= 4 ) { + + numDirectBits = ( posSlot >> 1 ) - 1; + rep0 = ( 2 | ( posSlot & 1 ) ) << numDirectBits; + + if ( posSlot < 14 ) { + + rep0 += LZMA.reverseDecode2( this._posDecoders, + rep0 - posSlot - 1, this._rangeDecoder, numDirectBits ); + + } else { + + rep0 += this._rangeDecoder.decodeDirectBits( numDirectBits - 4 ) << 4; + rep0 += this._posAlignDecoder.reverseDecode( this._rangeDecoder ); + if ( rep0 < 0 ) { + + if ( rep0 === - 1 ) { + + break; + + } + return false; + + } + + } + + } else { + + rep0 = posSlot; + + } + + } + + if ( rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck ) { + + return false; + + } + + this._outWindow.copyBlock( rep0, len ); + nowPos64 += len; + prevByte = this._outWindow.getByte( 0 ); + + } + + } + + this._outWindow.flush(); + this._outWindow.releaseStream(); + this._rangeDecoder.releaseStream(); + + return true; + + }; + + LZMA.Decoder.prototype.setDecoderProperties = function ( properties ) { + + var value, lc, lp, pb, dictionarySize; + + if ( properties.size < 5 ) { + + return false; + + } + + value = properties.readByte(); + lc = value % 9; + value = ~~ ( value / 9 ); + lp = value % 5; + pb = ~~ ( value / 5 ); + + if ( ! this.setLcLpPb( lc, lp, pb ) ) { + + return false; + + } + + dictionarySize = properties.readByte(); + dictionarySize |= properties.readByte() << 8; + dictionarySize |= properties.readByte() << 16; + dictionarySize += properties.readByte() * 16777216; + + return this.setDictionarySize( dictionarySize ); + + }; + + LZMA.decompress = function ( properties, inStream, outStream, outSize ) { + + var decoder = new LZMA.Decoder(); + + if ( ! decoder.setDecoderProperties( properties ) ) { + + throw "Incorrect stream properties"; + + } + + if ( ! decoder.decode( inStream, outStream, outSize ) ) { + + throw "Error in data stream"; + + } + + return true; + + }; + + LZMA.decompressFile = function ( inStream, outStream ) { + + var decoder = new LZMA.Decoder(), outSize; + + if ( ! decoder.setDecoderProperties( inStream ) ) { + + throw "Incorrect stream properties"; + + } + + outSize = inStream.readByte(); + outSize |= inStream.readByte() << 8; + outSize |= inStream.readByte() << 16; + outSize += inStream.readByte() * 16777216; + + inStream.readByte(); + inStream.readByte(); + inStream.readByte(); + inStream.readByte(); + + if ( ! decoder.decode( inStream, outStream, outSize ) ) { + + throw "Error in data stream"; + + } + + return true; + + }; + + return LZMA; + +}(); + + +/** + * SEA3D LZMA + * @author Sunag / http://www.sunag.com.br/ + */ + +SEA3D.File.LZMAUncompress = function ( data ) { + + data = new Uint8Array( data ); + + var inStream = { + data: data, + position: 0, + readByte: function () { + + return this.data[ this.position ++ ]; + + } + }; + + var outStream = { + data: [], + position: 0, + writeByte: function ( value ) { + + this.data[ this.position ++ ] = value; + + } + }; + + SEA3D.LZMA.decompressFile( inStream, outStream ); + + return new Uint8Array( outStream.data ).buffer; + +}; + +SEA3D.File.setDecompressionEngine( 2, "lzma", SEA3D.File.LZMAUncompress ); diff --git a/three/jsutil/loaders/sea3d/SEA3DLegacy.js b/three/jsutil/loaders/sea3d/SEA3DLegacy.js new file mode 100644 index 000000000..9b3d37a21 --- /dev/null +++ b/three/jsutil/loaders/sea3d/SEA3DLegacy.js @@ -0,0 +1,774 @@ +/** + * SEA3D Legacy for Three.JS + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +// +// Header +// + +Object.assign( THREE.SEA3D.prototype, { + + _onHead: THREE.SEA3D.prototype.onHead, + _updateTransform: THREE.SEA3D.prototype.updateTransform, + _readMorph: THREE.SEA3D.prototype.readMorph, + _readVertexAnimation: THREE.SEA3D.prototype.readVertexAnimation, + _readGeometryBuffer: THREE.SEA3D.prototype.readGeometryBuffer, + _readLine: THREE.SEA3D.prototype.readLine, + _getModifier: THREE.SEA3D.prototype.getModifier, + _readAnimation: THREE.SEA3D.prototype.readAnimation + +} ); + +// +// Utils +// + +THREE.SEA3D.prototype.isLegacy = function ( sea ) { + + var sea3d = sea.sea3d; + + if ( sea3d.sign === "S3D" ) { + + return sea3d.config.legacy; + + } + + return false; + +}; + +THREE.SEA3D.prototype.flipVec3 = function ( v ) { + + if ( ! v ) return; + + var i = 2; + + while ( i < v.length ) { + + v[ i ] = - v[ i ]; + + i += 3; + + } + + return v; + +}; + +THREE.SEA3D.prototype.addVector = function ( v, t ) { + + if ( ! v ) return; + + for ( var i = 0; i < v.length; i ++ ) { + + v[ i ] += t[ i ]; + + } + + return v; + +}; + +THREE.SEA3D.prototype.expandJoints = function ( sea ) { + + var numJoints = sea.numVertex * 4; + + var joint = sea.isBig ? new Uint32Array( numJoints ) : new Uint16Array( numJoints ); + var weight = new Float32Array( numJoints ); + + var w = 0, jpv = sea.jointPerVertex; + + for ( var i = 0; i < sea.numVertex; i ++ ) { + + var tjsIndex = i * 4; + var seaIndex = i * jpv; + + joint[ tjsIndex ] = sea.joint[ seaIndex ]; + if ( jpv > 1 ) joint[ tjsIndex + 1 ] = sea.joint[ seaIndex + 1 ]; + if ( jpv > 2 ) joint[ tjsIndex + 2 ] = sea.joint[ seaIndex + 2 ]; + if ( jpv > 3 ) joint[ tjsIndex + 3 ] = sea.joint[ seaIndex + 3 ]; + + weight[ tjsIndex ] = sea.weight[ seaIndex ]; + if ( jpv > 1 ) weight[ tjsIndex + 1 ] = sea.weight[ seaIndex + 1 ]; + if ( jpv > 2 ) weight[ tjsIndex + 2 ] = sea.weight[ seaIndex + 2 ]; + if ( jpv > 3 ) weight[ tjsIndex + 3 ] = sea.weight[ seaIndex + 3 ]; + + w = weight[ tjsIndex ] + weight[ tjsIndex + 1 ] + weight[ tjsIndex + 2 ] + weight[ tjsIndex + 3 ]; + + weight[ tjsIndex ] += 1 - w; + + } + + sea.joint = joint; + sea.weight = weight; + + sea.jointPerVertex = 4; + +}; + +THREE.SEA3D.prototype.compressJoints = function ( sea ) { + + var numJoints = sea.numVertex * 4; + + var joint = sea.isBig ? new Uint32Array( numJoints ) : new Uint16Array( numJoints ); + var weight = new Float32Array( numJoints ); + + var w = 0, jpv = sea.jointPerVertex; + + for ( var i = 0; i < sea.numVertex; i ++ ) { + + var tjsIndex = i * 4; + var seaIndex = i * jpv; + + joint[ tjsIndex ] = sea.joint[ seaIndex ]; + joint[ tjsIndex + 1 ] = sea.joint[ seaIndex + 1 ]; + joint[ tjsIndex + 2 ] = sea.joint[ seaIndex + 2 ]; + joint[ tjsIndex + 3 ] = sea.joint[ seaIndex + 3 ]; + + weight[ tjsIndex ] = sea.weight[ seaIndex ]; + weight[ tjsIndex + 1 ] = sea.weight[ seaIndex + 1 ]; + weight[ tjsIndex + 2 ] = sea.weight[ seaIndex + 2 ]; + weight[ tjsIndex + 3 ] = sea.weight[ seaIndex + 3 ]; + + w = weight[ tjsIndex ] + weight[ tjsIndex + 1 ] + weight[ tjsIndex + 2 ] + weight[ tjsIndex + 3 ]; + + weight[ tjsIndex ] += 1 - w; + + } + + sea.joint = joint; + sea.weight = weight; + + sea.jointPerVertex = 4; + +}; + +THREE.SEA3D.prototype.flipIndexes = function ( v ) { + + var i = 1; // y >-< z + + while ( i < v.length ) { + + var idx = v[ i + 1 ]; + v[ i + 1 ] = v[ i ]; + v[ i ] = idx; + + i += 3; + + } + + return v; + +}; + +THREE.SEA3D.prototype.flipBoneMatrix = function () { + + var zero = new THREE.Vector3(); + + return function ( mtx ) { + + var pos = THREE.SEA3D.VECBUF.setFromMatrixPosition( mtx ); + pos.z = - pos.z; + + mtx.setPosition( zero ); + mtx.multiplyMatrices( THREE.SEA3D.MTXBUF.makeRotationZ( THREE.Math.degToRad( 180 ) ), mtx ); + mtx.setPosition( pos ); + + return mtx; + + }; + +}(); + +THREE.SEA3D.prototype.flipScaleMatrix = function () { + + var pos = new THREE.Vector3(); + var qua = new THREE.Quaternion(); + var slc = new THREE.Vector3(); + + return function ( local, rotate, parent, parentRotate ) { + + if ( parent ) local.multiplyMatrices( parent, local ); + + local.decompose( pos, qua, slc ); + + slc.z = - slc.z; + + local.compose( pos, qua, slc ); + + if ( rotate ) { + + local.multiplyMatrices( local, THREE.SEA3D.MTXBUF.makeRotationZ( THREE.Math.degToRad( 180 ) ) ); + + } + + if ( parent ) { + + parent = parent.clone(); + + this.flipScaleMatrix( parent, parentRotate ); + + local.multiplyMatrices( parent.getInverse( parent ), local ); + + } + + return local; + + }; + +}(); + +// +// Legacy +// + +THREE.SEA3D.prototype.flipDefaultAnimation = function () { + + var buf1 = new THREE.Matrix4(); + var buf2 = new THREE.Matrix4(); + + var pos = new THREE.Vector3(); + var qua = new THREE.Quaternion(); + var slc = new THREE.Vector3(); + + var to_pos = new THREE.Vector3(); + var to_qua = new THREE.Quaternion(); + var to_slc = new THREE.Vector3(); + + return function ( animation, obj3d, relative ) { + + if ( animation.isFliped ) return; + + var dataList = animation.dataList, + t_anm = []; + + for ( var i = 0; i < dataList.length; i ++ ) { + + var data = dataList[ i ], + raw = data.data, + kind = data.kind, + numFrames = raw.length / data.blockSize; + + switch ( kind ) { + + case SEA3D.Animation.POSITION: + case SEA3D.Animation.ROTATION: + case SEA3D.Animation.SCALE: + + t_anm.push( { + kind: kind, + numFrames: numFrames, + raw: raw + } ); + + break; + + } + + } + + if ( t_anm.length > 0 ) { + + var numFrames = t_anm[ 0 ].numFrames, + parent = undefined; + + if ( relative ) { + + buf1.identity(); + parent = this.flipScaleMatrix( buf2.copy( obj3d.matrixWorld ) ); + + } else { + + if ( obj3d.parent ) { + + parent = this.flipScaleMatrix( buf2.copy( obj3d.parent.matrixWorld ) ); + + } + + this.flipScaleMatrix( buf1.copy( obj3d.matrix ), false, parent ); + + } + + buf1.decompose( pos, qua, slc ); + + for ( var f = 0, t, c; f < numFrames; f ++ ) { + + for ( t = 0; t < t_anm.length; t ++ ) { + + var raw = t_anm[ t ].raw, + kind = t_anm[ t ].kind; + + switch ( kind ) { + + case SEA3D.Animation.POSITION: + + c = f * 3; + + pos.set( + raw[ c ], + raw[ c + 1 ], + raw[ c + 2 ] + ); + + break; + + case SEA3D.Animation.ROTATION: + + c = f * 4; + + qua.set( + raw[ c ], + raw[ c + 1 ], + raw[ c + 2 ], + raw[ c + 3 ] + ); + + break; + + case SEA3D.Animation.SCALE: + + c = f * 4; + + slc.set( + raw[ c ], + raw[ c + 1 ], + raw[ c + 2 ] + ); + + break; + + } + + } + + buf1.compose( pos, qua, slc ); + + this.flipScaleMatrix( buf1, false, buf2 ); + + buf1.decompose( to_pos, to_qua, to_slc ); + + for ( t = 0; t < t_anm.length; t ++ ) { + + var raw = t_anm[ t ].raw, + kind = t_anm[ t ].kind; + + switch ( kind ) { + + case SEA3D.Animation.POSITION: + + c = f * 3; + + raw[ c ] = to_pos.x; + raw[ c + 1 ] = to_pos.y; + raw[ c + 2 ] = to_pos.z; + + break; + + case SEA3D.Animation.ROTATION: + + c = f * 4; + + raw[ c ] = to_qua.x; + raw[ c + 1 ] = to_qua.y; + raw[ c + 2 ] = to_qua.z; + raw[ c + 3 ] = to_qua.w; + + break; + + case SEA3D.Animation.SCALE: + + c = f * 3; + + raw[ c ] = to_slc.x; + raw[ c + 1 ] = to_slc.y; + raw[ c + 2 ] = to_slc.z; + + break; + + } + + } + + } + + } + + animation.isFliped = true; + + }; + +}(); + +THREE.SEA3D.prototype.readAnimation = function ( sea ) { + + if ( ! this.isLegacy( sea ) ) { + + this._readAnimation( sea ); + + } + +}; + +THREE.SEA3D.prototype.getModifier = function ( req ) { + + var sea = req.sea; + + if ( this.isLegacy( sea ) && ! sea.done ) { + + sea.done = true; + + switch ( sea.type ) { + + case SEA3D.SkeletonAnimation.prototype.type: + + this.readSkeletonAnimationLegacy( sea, req.skeleton ); + + return sea.tag; + + break; + + case SEA3D.Animation.prototype.type: + case SEA3D.MorphAnimation.prototype.type: + case SEA3D.UVWAnimation.prototype.type: + + if ( req.scope instanceof THREE.Object3D ) { + + this.flipDefaultAnimation( sea, req.scope, req.relative ); + + } + + this._readAnimation( sea ); + + return sea.tag; + + break; + + case SEA3D.Morph.prototype.type: + + this.readMorphLegacy( sea, req.geometry ); + + break; + + } + + } + + return this._getModifier( req ); + +}; + +THREE.SEA3D.prototype.updateTransform = function () { + + var buf1 = new THREE.Matrix4(); + var identity = new THREE.Matrix4(); + + return function ( obj3d, sea ) { + + if ( this.isLegacy( sea ) ) { + + if ( sea.transform ) buf1.fromArray( sea.transform ); + else buf1.makeTranslation( sea.position.x, sea.position.y, sea.position.z ); + + this.flipScaleMatrix( + buf1, false, + obj3d.parent ? obj3d.parent.matrixWorld : identity, + obj3d.parent instanceof THREE.Bone + ); + + obj3d.position.setFromMatrixPosition( buf1 ); + obj3d.scale.setFromMatrixScale( buf1 ); + + // ignore rotation scale + + buf1.scale( THREE.SEA3D.VECBUF.set( 1 / obj3d.scale.x, 1 / obj3d.scale.y, 1 / obj3d.scale.z ) ); + obj3d.rotation.setFromRotationMatrix( buf1 ); + + obj3d.updateMatrixWorld(); + + } else { + + this._updateTransform( obj3d, sea ); + + } + + }; + +}(); + +THREE.SEA3D.prototype.readSkeleton = function () { + + var mtx_tmp_inv = new THREE.Matrix4(), + mtx_local = new THREE.Matrix4(), + mtx_parent = new THREE.Matrix4(), + pos = new THREE.Vector3(), + qua = new THREE.Quaternion(); + + return function ( sea ) { + + var bones = [], + isLegacy = sea.sea3d.config.legacy; + + for ( var i = 0; i < sea.joint.length; i ++ ) { + + var bone = sea.joint[ i ]; + + // get world inverse matrix + + mtx_tmp_inv.fromArray( bone.inverseBindMatrix ); + + // convert to world matrix + + mtx_local.getInverse( mtx_tmp_inv ); + + // convert to three.js order + + if ( isLegacy ) this.flipBoneMatrix( mtx_local ); + + if ( bone.parentIndex > - 1 ) { + + // to world + + mtx_tmp_inv.fromArray( sea.joint[ bone.parentIndex ].inverseBindMatrix ); + mtx_parent.getInverse( mtx_tmp_inv ); + + // convert parent to three.js order + + if ( isLegacy ) this.flipBoneMatrix( mtx_parent ); + + // to local + + mtx_parent.getInverse( mtx_parent ); + + mtx_local.multiplyMatrices( mtx_parent, mtx_local ); + + } + + // apply matrix + + pos.setFromMatrixPosition( mtx_local ); + qua.setFromRotationMatrix( mtx_local ); + + bones[ i ] = { + name: bone.name, + pos: [ pos.x, pos.y, pos.z ], + rotq: [ qua.x, qua.y, qua.z, qua.w ], + parent: bone.parentIndex + }; + + } + + this.domain.bones = this.bones = this.bones || []; + this.bones.push( this.objects[ sea.name + '.sklq' ] = sea.tag = bones ); + + return bones; + + }; + +}(); + +THREE.SEA3D.prototype.readSkeletonAnimationLegacy = function () { + + var mtx_tmp_inv = new THREE.Matrix4(), + mtx_local = new THREE.Matrix4(), + mtx_global = new THREE.Matrix4(), + mtx_parent = new THREE.Matrix4(); + + return function ( sea, skl ) { + + if ( sea.tag ) return sea.tag; + + var animations = [], + delta = ( 1000 / sea.frameRate ) / 1000, + scale = [ 1, 1, 1 ]; + + for ( var i = 0; i < sea.sequence.length; i ++ ) { + + var seq = sea.sequence[ i ]; + + var start = seq.start; + var end = start + seq.count; + + var animation = { + name: seq.name, + repeat: seq.repeat, + fps: sea.frameRate, + JIT: 0, + length: delta * seq.count, + hierarchy: [] + }; + + var numJoints = sea.numJoints, + raw = sea.raw; + + for ( var j = 0; j < numJoints; j ++ ) { + + var bone = skl.joint[ j ], + node = { parent: bone.parentIndex, keys: [] }, + keys = node.keys, + time = 0; + + for ( var frame = start; frame < end; frame ++ ) { + + var idx = ( frame * numJoints * 7 ) + ( j * 7 ); + + mtx_local.makeRotationFromQuaternion( THREE.SEA3D.QUABUF.set( raw[ idx + 3 ], raw[ idx + 4 ], raw[ idx + 5 ], raw[ idx + 6 ] ) ); + mtx_local.setPosition( THREE.SEA3D.VECBUF.set( raw[ idx ], raw[ idx + 1 ], raw[ idx + 2 ] ) ); + + if ( bone.parentIndex > - 1 ) { + + // to global + + mtx_tmp_inv.fromArray( skl.joint[ bone.parentIndex ].inverseBindMatrix ); + + mtx_parent.getInverse( mtx_tmp_inv ); + + mtx_global.multiplyMatrices( mtx_parent, mtx_local ); + + // convert to three.js matrix + + this.flipBoneMatrix( mtx_global ); + + // flip parent inverse + + this.flipBoneMatrix( mtx_parent ); + + // to local + + mtx_parent.getInverse( mtx_parent ); + + mtx_local.multiplyMatrices( mtx_parent, mtx_global ); + + } else { + + this.flipBoneMatrix( mtx_local ); + + } + + var posQ = THREE.SEA3D.VECBUF.setFromMatrixPosition( mtx_local ); + var newQ = THREE.SEA3D.QUABUF.setFromRotationMatrix( mtx_local ); + + keys.push( { + time: time, + pos: [ posQ.x, posQ.y, posQ.z ], + rot: [ newQ.x, newQ.y, newQ.z, newQ.w ], + scl: scale + } ); + + time += delta; + + } + + animation.hierarchy[ j ] = node; + + } + + animations.push( THREE.SEA3D.AnimationClip.fromClip( THREE.AnimationClip.parseAnimation( animation, skl.tag ), seq.repeat ) ); + + } + + this.domain.clips = this.clips = this.clips || []; + this.clips.push( this.objects[ sea.name + '.anm' ] = sea.tag = animations ); + + }; + +}(); + +THREE.SEA3D.prototype.readMorphLegacy = function ( sea, geo ) { + + for ( var i = 0; i < sea.node.length; i ++ ) { + + var node = sea.node[ i ]; + + this.flipVec3( node.vertex ); + this.flipVec3( node.normal ); + + this.addVector( node.vertex, geo.vertex ); + this.addVector( node.normal, geo.normal ); + + } + + this._readMorph( sea ); + +}; + +THREE.SEA3D.prototype.readMorph = function ( sea ) { + + if ( ! this.isLegacy( sea ) ) { + + this._readMorph( sea ); + + } + +}; + +THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) { + + if ( this.isLegacy( sea ) ) { + + for ( var i = 0, l = sea.frame.length; i < l; i ++ ) { + + var frame = sea.frame[ i ]; + + this.flipVec3( frame.vertex ); + this.flipVec3( frame.normal ); + + } + + } + + this._readVertexAnimation( sea ); + +}; + +THREE.SEA3D.prototype.readGeometryBuffer = function ( sea ) { + + if ( this.isLegacy( sea ) ) { + + this.flipVec3( sea.vertex ); + this.flipVec3( sea.normal ); + + this.flipIndexes( sea.indexes ); + + if ( sea.jointPerVertex > 4 ) this.compressJoints( sea ); + else if ( sea.jointPerVertex < 4 ) this.expandJoints( sea ); + + } + + this._readGeometryBuffer( sea ); + +}; + +THREE.SEA3D.prototype.readLines = function ( sea ) { + + if ( this.isLegacy( sea ) ) { + + this.flipVec3( sea.vertex ); + + } + + this._readLines( sea ); + +}; + +THREE.SEA3D.prototype.onHead = function ( args ) { + + if ( args.sign != "S3D" && args.sign != "TJS" ) { + + throw new Error( "Sign '" + args.sign + "' unknown." ); + + } + +}; + +THREE.SEA3D.EXTENSIONS_LOADER.push( { setTypeRead: function () { + + // CONFIG + + this.config.legacy = this.config.legacy == undefined ? true : this.config.legacy; + + this.file.typeRead[ SEA3D.Skeleton.prototype.type ] = this.readSkeleton; + +} } ); diff --git a/three/jsutil/loaders/sea3d/SEA3DLoader.js b/three/jsutil/loaders/sea3d/SEA3DLoader.js new file mode 100644 index 000000000..0c32285e8 --- /dev/null +++ b/three/jsutil/loaders/sea3d/SEA3DLoader.js @@ -0,0 +1,3845 @@ +/** + * SEA3D for Three.JS + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +// +// +// SEA3D +// + +THREE.SEA3D = function ( config ) { + + this.config = { + id: "", + scripts: true, + runScripts: true, + autoPlay: false, + dummys: true, + multiplier: 1, + bounding: true, + audioRolloffFactor: 10, + lights: true, + useEnvironment: true, + useVertexTexture: true, + forceStatic: false, + streaming: true, + async: true, + paths: {}, + timeLimit: 10 + }; + + if ( config ) this.loadConfig( config ); + +}; + +// +// Polyfills +// + +if ( THREE.Float32BufferAttribute === undefined ) { + + THREE.Float32BufferAttribute = THREE.Float32Attribute; + +} + +THREE.SEA3D.useMultiMaterial = THREE.MultiMaterial.prototype.isMultiMaterial; + +// +// Config +// + +THREE.SEA3D.MTXBUF = new THREE.Matrix4(); +THREE.SEA3D.VECBUF = new THREE.Vector3(); +THREE.SEA3D.QUABUF = new THREE.Quaternion(); + +THREE.SEA3D.BACKGROUND_COLOR = 0x333333; +THREE.SEA3D.HELPER_COLOR = 0x9AB9E5; +THREE.SEA3D.RTT_SIZE = 512; + +THREE.SEA3D.identityMatrixScale = function () { + + var scl = new THREE.Vector3(); + + return function identityMatrixScale( matrix ) { + + scl.setFromMatrixScale( matrix ); + + return matrix.scale( scl.set( 1 / scl.x, 1 / scl.y, 1 / scl.z ) ); + + }; + +}(); + +THREE.SEA3D.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype ), { + + constructor: THREE.SEA3D, + + setShadowMap: function ( light ) { + + light.shadow.mapSize.width = 2048; + light.shadow.mapSize.height = 1024; + + light.castShadow = true; + + light.shadow.camera.left = - 200; + light.shadow.camera.right = 200; + light.shadow.camera.top = 200; + light.shadow.camera.bottom = - 200; + + light.shadow.camera.near = 1; + light.shadow.camera.far = 3000; + light.shadow.camera.fov = 45; + + light.shadow.bias = - 0.001; + + } + +} ); + +Object.defineProperties( THREE.SEA3D.prototype, { + + container: { + + set: function ( val ) { + + this.config.container = val; + + }, + + get: function () { + + return this.config.container; + + } + + }, + + elapsedTime: { + + get: function () { + + return this.file.timer.elapsedTime; + + } + + } + +} ); + +// +// Domain +// + +THREE.SEA3D.Domain = function ( id, objects, container ) { + + this.id = id; + this.objects = objects; + this.container = container; + + this.sources = []; + this.local = {}; + + this.scriptTargets = []; + + this.events = new THREE.EventDispatcher(); + +}; + +THREE.SEA3D.Domain.global = {}; + +THREE.SEA3D.Domain.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype ), { + + constructor: THREE.SEA3D.Domain, + + add: function ( src ) { + + this.sources.push( src ); + + }, + + remove: function ( src ) { + + this.sources.splice( this.sources.indexOf( src ), 1 ); + + }, + + contains: function ( src ) { + + return this.sources.indexOf( src ) != - 1; + + }, + + addEventListener: function ( type, listener ) { + + this.events.addEventListener( type, listener ); + + }, + + hasEventListener: function ( type, listener ) { + + return this.events.hasEventListener( type, listener ); + + }, + + removeEventListener: function ( type, listener ) { + + this.events.removeEventListener( type, listener ); + + }, + + print: function () { + + console.log.apply( console, arguments ); + + }, + + watch: function () { + + console.log.apply( console, 'watch:', arguments ); + + }, + + runScripts: function () { + + for ( var i = 0; i < this.scriptTargets.length; i ++ ) { + + this.runJSMList( this.scriptTargets[ i ] ); + + } + + }, + + runJSMList: function ( target ) { + + var scripts = target.scripts; + + for ( var i = 0; i < scripts.length; i ++ ) { + + this.runJSM( target, scripts[ i ] ); + + } + + return scripts; + + }, + + runJSM: function ( target, script ) { + + var include = { + print: this.print, + watch: this.watch, + sea3d: this, + scene: this.container, + source: new THREE.SEA3D.ScriptDomain( this, target instanceof THREE.SEA3D.Domain ) + }; + + Object.freeze( include.source ); + + THREE.SEA3D.ScriptHandler.add( include.source ); + + try { + + this.methods[ script.method ]( + include, + this.getReference, + THREE.SEA3D.Domain.global, + this.local, + target, + script.params + ); + + } catch ( e ) { + + console.error( 'SEA3D JavaScript: Error running method "' + script.method + '".' ); + console.error( e ); + + } + + }, + + getReference: function ( ns ) { + + return eval( ns ); + + }, + + disposeList: function ( list ) { + + if ( ! list || ! list.length ) return; + + list = list.concat(); + + var i = list.length; + + while ( i -- ) { + + list[ i ].dispose(); + + } + + }, + + dispatchEvent: function ( event ) { + + event.domain = this; + + var sources = this.sources.concat(), + i = sources.length; + + while ( i -- ) { + + sources[ i ].dispatchEvent( event ); + + } + + this.events.dispatchEvent( event ); + + }, + + dispose: function () { + + this.disposeList( this.sources ); + + while ( this.container.children.length ) { + + this.container.remove( this.container.children[ 0 ] ); + + } + + var i = THREE.SEA3D.EXTENSIONS_DOMAIN.length; + + while ( i -- ) { + + var domain = THREE.SEA3D.EXTENSIONS_DOMAIN[ i ]; + + if ( domain.dispose ) domain.dispose.call( this ); + + } + + this.disposeList( this.materials ); + this.disposeList( this.dummys ); + + this.dispatchEvent( { type: "dispose" } ); + + } +} ); + +// +// Domain Manager +// + +THREE.SEA3D.DomainManager = function ( autoDisposeRootDomain ) { + + this.domains = []; + this.autoDisposeRootDomain = autoDisposeRootDomain !== undefined ? autoDisposeRootDomain : true; + +}; + +Object.assign( THREE.SEA3D.DomainManager.prototype, { + + onDisposeDomain: function ( e ) { + + this.remove( e.domain ); + + if ( this.autoDisposeRootDomain && this.domains.length == 1 ) { + + this.dispose(); + + } + + }, + + add: function ( domain ) { + + this._onDisposeDomain = this._onDisposeDomain || this.onDisposeDomain.bind( this ); + + domain.on( "dispose", this._onDisposeDomain ); + + this.domains.push( domain ); + + this.textures = this.textures || domain.textures; + this.cubemaps = this.cubemaps || domain.cubemaps; + this.geometries = this.geometries || domain.geometries; + + }, + + remove: function ( domain ) { + + domain.removeEvent( "dispose", this._onDisposeDomain ); + + this.domains.splice( this.domains.indexOf( domain ), 1 ); + + }, + + contains: function ( domain ) { + + return this.domains.indexOf( domain ) != - 1; + + }, + + disposeList: function ( list ) { + + if ( ! list || ! list.length ) return; + + list = list.concat(); + + var i = list.length; + + while ( i -- ) { + + list[ i ].dispose(); + + } + + }, + + dispose: function () { + + this.disposeList( this.domains ); + this.disposeList( this.textures ); + this.disposeList( this.cubemaps ); + this.disposeList( this.geometries ); + + } + +} ); + +// +// Script ( closure for private functions ) +// + +THREE.SEA3D.ScriptDomain = function ( domain, root ) { + + domain = domain || new THREE.SEA3D.Domain(); + domain.add( this ); + + var events = new THREE.EventDispatcher(); + + this.getId = function () { + + return domain.id; + + }; + + this.isRoot = function () { + + return root; + + }; + + this.addEventListener = function ( type, listener ) { + + events.addEventListener( type, listener ); + + }; + + this.hasEventListener = function ( type, listener ) { + + return events.hasEventListener( type, listener ); + + }; + + this.removeEventListener = function ( type, listener ) { + + events.removeEventListener( type, listener ); + + }; + + this.dispatchEvent = function ( event ) { + + event.script = this; + + events.dispatchEvent( event ); + + }; + + this.dispose = function () { + + domain.remove( this ); + + if ( root ) domain.dispose(); + + this.dispatchEvent( { type: "dispose" } ); + + }; + +}; + +// +// Script Manager ( closure for private functions ) +// + +THREE.SEA3D.ScriptManager = function () { + + this.scripts = []; + + var onDisposeScript = ( function ( e ) { + + this.remove( e.script ); + + } ).bind( this ); + + this.add = function ( src ) { + + src.addEventListener( "dispose", onDisposeScript ); + + this.scripts.push( src ); + + }; + + this.remove = function ( src ) { + + src.removeEventListener( "dispose", onDisposeScript ); + + this.scripts.splice( this.scripts.indexOf( src ), 1 ); + + }; + + this.contains = function ( src ) { + + return this.scripts.indexOf( src ) > - 1; + + }; + + this.dispatchEvent = function ( event ) { + + var scripts = this.scripts.concat(), + i = scripts.length; + + while ( i -- ) { + + scripts[ i ].dispatchEvent( event ); + + } + + }; + +}; + +// +// Script Handler +// + +THREE.SEA3D.ScriptHandler = new THREE.SEA3D.ScriptManager(); + +THREE.SEA3D.ScriptHandler.dispatchUpdate = function ( delta ) { + + this.dispatchEvent( { + type: "update", + delta: delta + } ); + +}; + +// +// Animation Clip +// + +THREE.SEA3D.AnimationClip = function ( name, duration, tracks, repeat ) { + + THREE.AnimationClip.call( this, name, duration, tracks ); + + this.repeat = repeat !== undefined ? repeat : true; + +}; + +THREE.SEA3D.AnimationClip.fromClip = function ( clip, repeat ) { + + return new THREE.SEA3D.AnimationClip( clip.name, clip.duration, clip.tracks, repeat ); + +}; + +THREE.SEA3D.AnimationClip.prototype = Object.assign( Object.create( THREE.AnimationClip.prototype ), { + + constructor: THREE.SEA3D.AnimationClip + +} ); + +// +// Animation +// + +THREE.SEA3D.Animation = function ( clip, timeScale ) { + + this.clip = clip; + this.timeScale = timeScale !== undefined ? timeScale : 1; + +}; + +THREE.SEA3D.Animation.COMPLETE = "animationComplete"; + +THREE.SEA3D.Animation.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype ), { + + constructor: THREE.SEA3D.Animation, + + onComplete: function ( scope ) { + + this.dispatchEvent( { type: THREE.SEA3D.Animation.COMPLETE, target: this } ); + + + } + +} ); + +Object.defineProperties( THREE.SEA3D.Animation.prototype, { + + name: { + + get: function () { + + return this.clip.name; + + } + + }, + + repeat: { + + get: function () { + + return this.clip.repeat; + + } + + }, + + duration: { + + get: function () { + + return this.clip.duration; + + } + + }, + + mixer: { + + set: function ( val ) { + + if ( this.mx ) { + + this.mx.uncacheClip( this.clip ); + delete this.mx; + + } + + if ( val ) { + + this.mx = val; + this.mx.clipAction( this.clip ); + + } + + }, + + get: function () { + + return this.mx; + + } + + } + +} ); + +// +// Animator +// + +THREE.SEA3D.Animator = function ( clips, mixer ) { + + this.updateAnimations( clips, mixer ); + + this.clone = function ( scope ) { + + return new this.constructor( this.clips, new THREE.AnimationMixer( scope ) ).copyFrom( this ); + + }.bind( this ); + +}; + +Object.assign( THREE.SEA3D.Animator.prototype, { + + update: function ( dt ) { + + this.mixer.update( dt || 0 ); + + if ( this.currentAnimationAction && this.currentAnimationAction.paused ) { + + this.pause(); + + if ( this.currentAnimation ) { + + this.currentAnimation.onComplete( this ); + + } + + } + + return this; + + }, + + updateAnimations: function ( clips, mixer ) { + + if ( this.playing ) this.stop(); + + if ( this.mixer ) THREE.SEA3D.AnimationHandler.remove( this ); + + this.mixer = mixer; + + this.relative = false; + this.playing = false; + this.paused = false; + + this.timeScale = 1; + + this.animations = []; + this.animation = {}; + + this.clips = []; + + if ( clips ) { + + for ( var i = 0; i < clips.length; i ++ ) { + + this.addAnimation( clips[ i ] ); + + } + + } + + return this; + + }, + + addAnimation: function ( animation ) { + + if ( animation instanceof THREE.AnimationClip ) { + + this.clips.push( animation ); + + animation = new THREE.SEA3D.Animation( animation ); + + } + + this.animations.push( animation ); + this.animation[ animation.name ] = animation; + + animation.mixer = this.mixer; + + return animation; + + }, + + removeAnimation: function ( animation ) { + + if ( animation instanceof THREE.AnimationClip ) { + + animation = this.getAnimationByClip( animation ); + + } + + this.clips.splice( this.clips.indexOf( animation.clip ), 1 ); + + delete this.animation[ animation.name ]; + this.animations.splice( this.animations.indexOf( animation ), 1 ); + + animation.mixer = null; + + return animation; + + }, + + getAnimationByClip: function ( clip ) { + + for ( var i = 0; i < this.animations.length; i ++ ) { + + if ( this.animations[ i ].clip === clip ) return clip; + + } + + }, + + getAnimationByName: function ( name ) { + + return typeof name === "number" ? this.animations[ name ] : this.animation[ name ]; + + }, + + setAnimationWeight: function ( name, val ) { + + this.mixer.clipAction( this.getAnimationByName( name ).clip ).setEffectiveWeight( val ); + + }, + + getAnimationWeight: function ( name ) { + + return this.mixer.clipAction( this.getAnimationByName( name ).clip ).getEffectiveWeight(); + + }, + + pause: function () { + + if ( this.playing && this.currentAnimation ) { + + THREE.SEA3D.AnimationHandler.remove( this ); + + this.playing = false; + + } + + return this; + + }, + + resume: function () { + + if ( ! this.playing && this.currentAnimation ) { + + THREE.SEA3D.AnimationHandler.add( this ); + + this.playing = true; + + } + + return this; + + }, + + setTimeScale: function ( val ) { + + this.timeScale = val; + + if ( this.currentAnimationAction ) this.updateTimeScale(); + + return this; + + }, + + getTimeScale: function () { + + return this.timeScale; + + }, + + updateTimeScale: function () { + + this.currentAnimationAction.setEffectiveTimeScale( this.timeScale * ( this.currentAnimation ? this.currentAnimation.timeScale : 1 ) ); + + return this; + + }, + + play: function ( name, crossfade, offset, weight ) { + + var animation = this.getAnimationByName( name ); + + if ( ! animation ) throw new Error( 'Animation "' + name + '" not found.' ); + + if ( animation == this.currentAnimation ) { + + if ( offset !== undefined || ! animation.repeat ) this.currentAnimationAction.time = offset !== undefined ? offset : + ( this.currentAnimationAction.timeScale >= 0 ? 0 : this.currentAnimation.duration ); + + this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 ); + this.currentAnimationAction.paused = false; + + return this.resume(); + + } else { + + this.previousAnimation = this.currentAnimation; + this.currentAnimation = animation; + + this.previousAnimationAction = this.currentAnimationAction; + this.currentAnimationAction = this.mixer.clipAction( animation.clip ).setLoop( animation.repeat ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset(); + this.currentAnimationAction.clampWhenFinished = ! animation.repeat; + this.currentAnimationAction.paused = false; + + this.updateTimeScale(); + + if ( offset !== undefined || ! animation.repeat ) this.currentAnimationAction.time = offset !== undefined ? offset : + ( this.currentAnimationAction.timeScale >= 0 ? 0 : this.currentAnimation.duration ); + + this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 ); + + this.currentAnimationAction.play(); + + if ( ! this.playing ) this.mixer.update( 0 ); + + this.playing = true; + + if ( this.previousAnimation ) this.previousAnimationAction.crossFadeTo( this.currentAnimationAction, crossfade || 0, false ); + + THREE.SEA3D.AnimationHandler.add( this ); + + } + + return this; + + }, + + stop: function () { + + if ( this.playing ) THREE.SEA3D.AnimationHandler.remove( this ); + + if ( this.currentAnimation ) { + + this.currentAnimationAction.stop(); + + this.previousAnimation = this.currentAnimation; + this.previousAnimationAction = this.currentAnimationAction; + + delete this.currentAnimationAction; + delete this.currentAnimation; + + this.playing = false; + + } + + return this; + + }, + + playw: function ( name, weight ) { + + if ( ! this.playing && ! this.paused ) THREE.SEA3D.AnimationHandler.add( this ); + + var animation = this.getAnimationByName( name ); + + this.playing = true; + + var clip = this.mixer.clipAction( animation.clip ); + clip.setLoop( animation.repeat ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset(); + clip.clampWhenFinished = ! animation.repeat; + clip.paused = false; + + clip.setEffectiveWeight( weight ).play(); + + return clip; + + }, + + crossFade: function ( fromAnimName, toAnimName, duration, wrap ) { + + this.mixer.stopAllAction(); + + var fromAction = this.playw( fromAnimName, 1 ); + var toAction = this.playw( toAnimName, 1 ); + + fromAction.crossFadeTo( toAction, duration, wrap !== undefined ? wrap : false ); + + return this; + + }, + + stopAll: function () { + + this.stop().mixer.stopAllAction(); + + this.playing = false; + + return this; + + }, + + unPauseAll: function () { + + this.mixer.timeScale = 1; + + this.playing = true; + this.paused = false; + + return this; + + }, + + pauseAll: function () { + + this.mixer.timeScale = 0; + + this.playing = false; + this.paused = true; + + return this; + + }, + + setRelative: function ( val ) { + + if ( this.relative == val ) return; + + this.stop(); + + this.relative = val; + + return this; + + }, + + getRelative: function () { + + return this.relative; + + }, + + copyFrom: function ( scope ) { + + for ( var i = 0; i < this.animations.length; i ++ ) { + + this.animations[ i ].timeScale = scope.animations[ i ].timeScale; + + } + + return this; + + } + +} ); + +// +// Object3D Animator +// + +THREE.SEA3D.Object3DAnimator = function ( clips, object3d ) { + + this.object3d = object3d; + + THREE.SEA3D.Animator.call( this, clips, new THREE.AnimationMixer( object3d ) ); + + this.clone = function ( scope ) { + + return new this.constructor( this.clips, scope ).copyFrom( this ); + + }.bind( this ); + +}; + +THREE.SEA3D.Object3DAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Animator.prototype ), { + + constructor: THREE.SEA3D.Object3DAnimator, + + stop: function () { + + if ( this.currentAnimation ) { + + var animate = this.object3d.animate; + + if ( animate && this instanceof THREE.SEA3D.Object3DAnimator ) { + + animate.position.set( 0, 0, 0 ); + animate.quaternion.set( 0, 0, 0, 1 ); + animate.scale.set( 1, 1, 1 ); + + } + + } + + THREE.SEA3D.Animator.prototype.stop.call( this ); + + }, + + setRelative: function ( val ) { + + THREE.SEA3D.Animator.prototype.setRelative.call( this, val ); + + this.object3d.setAnimator( this.relative ); + + this.updateAnimations( this.clips, new THREE.AnimationMixer( this.relative ? this.object3d.animate : this.object3d ) ); + + } + +} ); + +// +// Camera Animator +// + +THREE.SEA3D.CameraAnimator = function ( clips, object3d ) { + + THREE.SEA3D.Object3DAnimator.call( this, clips, object3d ); + +}; + +THREE.SEA3D.CameraAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Object3DAnimator.prototype ), { + + constructor: THREE.SEA3D.CameraAnimator + +} ); + +// +// Sound Animator +// + +THREE.SEA3D.SoundAnimator = function ( clips, object3d ) { + + THREE.SEA3D.Object3DAnimator.call( this, clips, object3d ); + +}; + +THREE.SEA3D.SoundAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Object3DAnimator.prototype ), { + + constructor: THREE.SEA3D.SoundAnimator + +} ); + +// +// Light Animator +// + +THREE.SEA3D.LightAnimator = function ( clips, object3d ) { + + THREE.SEA3D.Object3DAnimator.call( this, clips, object3d ); + +}; + +THREE.SEA3D.LightAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Object3DAnimator.prototype ), { + + constructor: THREE.SEA3D.LightAnimator + +} ); + +// +// Container +// + +THREE.SEA3D.Object3D = function ( ) { + + THREE.Object3D.call( this ); + +}; + +THREE.SEA3D.Object3D.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), { + + constructor: THREE.SEA3D.Object3D, + + // Relative Animation Extension ( Only used if relative animation is enabled ) + // TODO: It can be done with shader + + updateAnimateMatrix: function ( force ) { + + if ( this.matrixAutoUpdate === true ) this.updateMatrix(); + + if ( this.matrixWorldNeedsUpdate === true || force === true ) { + + if ( this.parent === null ) { + + this.matrixWorld.copy( this.matrix ); + + } else { + + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + + } + + this.animate.updateMatrix(); + + this.matrixWorld.multiplyMatrices( this.matrixWorld, this.animate.matrix ); + + this.matrixWorldNeedsUpdate = false; + + force = true; + + } + + // update children + + for ( var i = 0, l = this.children.length; i < l; i ++ ) { + + this.children[ i ].updateMatrixWorld( force ); + + } + + }, + + setAnimator: function ( val ) { + + if ( this.getAnimator() == val ) + return; + + if ( val ) { + + this.animate = new THREE.Object3D(); + + this.updateMatrixWorld = THREE.SEA3D.Object3D.prototype.updateAnimateMatrix; + + } else { + + delete this.animate; + + this.updateMatrixWorld = THREE.Object3D.prototype.updateMatrixWorld; + + } + + this.matrixWorldNeedsUpdate = true; + + }, + + getAnimator: function () { + + return this.animate != undefined; + + }, + + copy: function ( source ) { + + THREE.Object3D.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Dummy +// + +THREE.SEA3D.Dummy = function ( width, height, depth ) { + + this.width = width != undefined ? width : 100; + this.height = height != undefined ? height : 100; + this.depth = depth != undefined ? depth : 100; + + var geo = new THREE.BoxBufferGeometry( this.width, this.height, this.depth, 1, 1, 1 ); + + geo.computeBoundingBox(); + geo.computeBoundingSphere(); + + THREE.Mesh.call( this, geo, THREE.SEA3D.Dummy.MATERIAL ); + +}; + +THREE.SEA3D.Dummy.MATERIAL = new THREE.MeshBasicMaterial( { wireframe: true, color: THREE.SEA3D.HELPER_COLOR } ); + +THREE.SEA3D.Dummy.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.Dummy, + + copy: function ( source ) { + + THREE.Mesh.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + }, + + dispose: function () { + + this.geometry.dispose(); + + } + +} ); + +// +// Mesh +// + +THREE.SEA3D.Mesh = function ( geometry, material ) { + + THREE.Mesh.call( this, geometry, material ); + +}; + +THREE.SEA3D.Mesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.Mesh, + + setWeight: function ( name, val ) { + + var index = typeof name === "number" ? name : this.morphTargetDictionary[ name ]; + + this.morphTargetInfluences[ index ] = val; + + }, + + getWeight: function ( name ) { + + var index = typeof name === "number" ? name : this.morphTargetDictionary[ name ]; + + return this.morphTargetInfluences[ index ]; + + }, + + copy: function ( source ) { + + THREE.Mesh.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Skinning +// + +THREE.SEA3D.SkinnedMesh = function ( geometry, material, useVertexTexture ) { + + THREE.SkinnedMesh.call( this, geometry, material, useVertexTexture ); + + this.updateAnimations( geometry.animations, new THREE.AnimationMixer( this ) ); + +}; + +THREE.SEA3D.SkinnedMesh.prototype = Object.assign( Object.create( THREE.SkinnedMesh.prototype ), THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Animator.prototype, { + + constructor: THREE.SEA3D.SkinnedMesh, + + boneByName: function ( name ) { + + var bones = this.skeleton.bones; + + for ( var i = 0, bl = bones.length; i < bl; i ++ ) { + + if ( name == bones[ i ].name ) + return bones[ i ]; + + } + + }, + + copy: function ( source ) { + + THREE.SkinnedMesh.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Vertex Animation +// + +THREE.SEA3D.VertexAnimationMesh = function ( geometry, material ) { + + THREE.Mesh.call( this, geometry, material ); + + this.type = 'MorphAnimMesh'; + + this.updateAnimations( geometry.animations, new THREE.AnimationMixer( this ) ); + +}; + +THREE.SEA3D.VertexAnimationMesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Animator.prototype, { + + constructor: THREE.SEA3D.VertexAnimationMesh, + + copy: function ( source ) { + + THREE.Mesh.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Camera +// + +THREE.SEA3D.Camera = function ( fov, aspect, near, far ) { + + THREE.PerspectiveCamera.call( this, fov, aspect, near, far ); + +}; + +THREE.SEA3D.Camera.prototype = Object.assign( Object.create( THREE.PerspectiveCamera.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.Camera, + + copy: function ( source ) { + + THREE.PerspectiveCamera.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Orthographic Camera +// + +THREE.SEA3D.OrthographicCamera = function ( left, right, top, bottom, near, far ) { + + THREE.OrthographicCamera.call( this, left, right, top, bottom, near, far ); + +}; + +THREE.SEA3D.OrthographicCamera.prototype = Object.assign( Object.create( THREE.OrthographicCamera.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.OrthographicCamera, + + copy: function ( source ) { + + THREE.OrthographicCamera.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// PointLight +// + +THREE.SEA3D.PointLight = function ( hex, intensity, distance, decay ) { + + THREE.PointLight.call( this, hex, intensity, distance, decay ); + +}; + +THREE.SEA3D.PointLight.prototype = Object.assign( Object.create( THREE.PointLight.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.PointLight, + + copy: function ( source ) { + + THREE.PointLight.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Point Sound +// + +THREE.SEA3D.PointSound = function ( listener, sound ) { + + THREE.PositionalAudio.call( this, listener ); + + this.setSound( sound ); + +}; + +THREE.SEA3D.PointSound.prototype = Object.assign( Object.create( THREE.PositionalAudio.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.PointSound, + + setSound: function ( sound ) { + + this.sound = sound; + + if ( sound ) { + + if ( sound.buffer ) { + + this.setBuffer( sound.buffer ); + + } else { + + sound.addEventListener( "complete", function ( e ) { + + this.setBuffer( sound.buffer ); + + }.bind( this ) ); + + } + + } + + return this; + + }, + + copy: function ( source ) { + + THREE.PositionalAudio.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( source.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + +// +// Animation Handler +// + +THREE.SEA3D.AnimationHandler = { + + animators: [], + + update: function ( dt ) { + + var i = 0; + + while ( i < this.animators.length ) { + + this.animators[ i ++ ].update( dt ); + + } + + }, + + add: function ( animator ) { + + var index = this.animators.indexOf( animator ); + + if ( index === - 1 ) this.animators.push( animator ); + + }, + + remove: function ( animator ) { + + var index = this.animators.indexOf( animator ); + + if ( index !== - 1 ) this.animators.splice( index, 1 ); + + } + +}; + +// +// Sound +// + +THREE.SEA3D.Sound = function ( src ) { + + this.uuid = THREE.Math.generateUUID(); + + this.src = src; + + new THREE.AudioLoader().load( src, function ( buffer ) { + + this.buffer = buffer; + + this.dispatchEvent( { type: "complete" } ); + + }.bind( this ) ); + +}; + +THREE.SEA3D.Sound.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype ), { + + constructor: THREE.SEA3D.Sound + +} ); + +// +// Output +// + +THREE.SEA3D.Domain.prototype.getMesh = THREE.SEA3D.prototype.getMesh = function ( name ) { + + return this.objects[ "m3d/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getDummy = THREE.SEA3D.prototype.getDummy = function ( name ) { + + return this.objects[ "dmy/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getLine = THREE.SEA3D.prototype.getLine = function ( name ) { + + return this.objects[ "line/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getSound3D = THREE.SEA3D.prototype.getSound3D = function ( name ) { + + return this.objects[ "sn3d/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getMaterial = THREE.SEA3D.prototype.getMaterial = function ( name ) { + + return this.objects[ "mat/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getLight = THREE.SEA3D.prototype.getLight = function ( name ) { + + return this.objects[ "lht/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getGLSL = THREE.SEA3D.prototype.getGLSL = function ( name ) { + + return this.objects[ "glsl/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getCamera = THREE.SEA3D.prototype.getCamera = function ( name ) { + + return this.objects[ "cam/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getTexture = THREE.SEA3D.prototype.getTexture = function ( name ) { + + return this.objects[ "tex/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getCubeMap = THREE.SEA3D.prototype.getCubeMap = function ( name ) { + + return this.objects[ "cmap/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getJointObject = THREE.SEA3D.prototype.getJointObject = function ( name ) { + + return this.objects[ "jnt/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getContainer3D = THREE.SEA3D.prototype.getContainer3D = function ( name ) { + + return this.objects[ "c3d/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getSprite = THREE.SEA3D.prototype.getSprite = function ( name ) { + + return this.objects[ "m2d/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getProperties = THREE.SEA3D.prototype.getProperties = function ( name ) { + + return this.objects[ "prop/" + name ]; + +}; + +// +// Utils +// + +THREE.SEA3D.prototype.isPowerOfTwo = function ( num ) { + + return num ? ( ( num & - num ) == num ) : false; + +}; + +THREE.SEA3D.prototype.nearestPowerOfTwo = function ( num ) { + + return Math.pow( 2, Math.round( Math.log( num ) / Math.LN2 ) ); + +}; + +THREE.SEA3D.prototype.updateTransform = function ( obj3d, sea ) { + + var mtx = THREE.SEA3D.MTXBUF, vec = THREE.SEA3D.VECBUF; + + if ( sea.transform ) mtx.fromArray( sea.transform ); + else mtx.makeTranslation( sea.position.x, sea.position.y, sea.position.z ); + + // matrix + + obj3d.position.setFromMatrixPosition( mtx ); + obj3d.scale.setFromMatrixScale( mtx ); + + // ignore rotation scale + + obj3d.quaternion.setFromRotationMatrix( THREE.SEA3D.identityMatrixScale( mtx ) ); + + // optimize if is static + + if ( this.config.forceStatic || sea.isStatic ) { + + obj3d.updateMatrix(); + obj3d.matrixAutoUpdate = false; + + } + +}; + +THREE.SEA3D.prototype.toVector3 = function ( data ) { + + return new THREE.Vector3( data.x, data.y, data.z ); + +}; + +THREE.SEA3D.prototype.toFaces = function ( faces ) { + + // xyz(- / +) to xyz(+ / -) sequence + var f = []; + + f[ 0 ] = faces[ 1 ]; + f[ 1 ] = faces[ 0 ]; + f[ 2 ] = faces[ 3 ]; + f[ 3 ] = faces[ 2 ]; + f[ 4 ] = faces[ 5 ]; + f[ 5 ] = faces[ 4 ]; + + return f; + +}; + +THREE.SEA3D.prototype.updateScene = function () { + + if ( this.materials != undefined ) { + + for ( var i = 0, l = this.materials.length; i < l; ++ i ) { + + this.materials[ i ].needsUpdate = true; + + } + + } + +}; + +THREE.SEA3D.prototype.addSceneObject = function ( sea, obj3d ) { + + obj3d = obj3d || sea.tag; + + obj3d.visible = sea.visible; + + if ( sea.parent ) sea.parent.tag.add( obj3d ); + else if ( this.config.container ) this.config.container.add( obj3d ); + + if ( sea.attributes ) obj3d.attribs = sea.attributes.tag; + + if ( sea.scripts ) { + + obj3d.scripts = this.getJSMList( obj3d, sea.scripts ); + + if ( this.config.scripts && this.config.runScripts ) this.domain.runJSMList( obj3d ); + + } + +}; + +THREE.SEA3D.prototype.createObjectURL = function ( raw, mime ) { + + return ( window.URL || window.webkitURL ).createObjectURL( new Blob( [ raw ], { type: mime } ) ); + +}; + +THREE.SEA3D.prototype.parsePath = function ( url ) { + + var paths = this.config.paths; + + for ( var name in paths ) { + + url = url.replace( new RegExp( "%" + name + "%", "g" ), paths[ name ] ); + + } + + return url; + +}; + +THREE.SEA3D.prototype.addDefaultAnimation = function ( sea, animatorClass ) { + + var scope = sea.tag; + + for ( var i = 0, count = sea.animations ? sea.animations.length : 0; i < count; i ++ ) { + + var anm = sea.animations[ i ]; + + switch ( anm.tag.type ) { + + case SEA3D.Animation.prototype.type: + + var animation = anm.tag.tag || this.getModifier( { + sea: anm.tag, + scope: scope, + relative: anm.relative + } ); + + scope.animator = new animatorClass( animation, scope ); + scope.animator.setRelative( anm.relative ); + + if ( this.config.autoPlay ) { + + scope.animator.play( 0 ); + + } + + return scope.animator; + + break; + + } + + } + +}; + +// +// Geometry +// + +THREE.SEA3D.prototype.readGeometryBuffer = function ( sea ) { + + var geo = sea.tag || new THREE.BufferGeometry(); + + for ( var i = 0; i < sea.groups.length; i ++ ) { + + var g = sea.groups[ i ]; + + geo.addGroup( g.start, g.count, i ); + + } + + // not indexes? use polygon soup + if ( sea.indexes ) geo.setIndex( new THREE.BufferAttribute( sea.indexes, 1 ) ); + + geo.addAttribute( 'position', new THREE.BufferAttribute( sea.vertex, 3 ) ); + + if ( sea.uv ) { + + geo.addAttribute( 'uv', new THREE.BufferAttribute( sea.uv[ 0 ], 2 ) ); + if ( sea.uv.length > 1 ) geo.addAttribute( 'uv2', new THREE.BufferAttribute( sea.uv[ 1 ], 2 ) ); + + } + + if ( sea.normal ) geo.addAttribute( 'normal', new THREE.BufferAttribute( sea.normal, 3 ) ); + else geo.computeVertexNormals(); + + if ( sea.tangent4 ) geo.addAttribute( 'tangent', new THREE.BufferAttribute( sea.tangent4, 4 ) ); + + if ( sea.color ) geo.addAttribute( 'color', new THREE.BufferAttribute( sea.color[ 0 ], sea.numColor ) ); + + if ( sea.joint ) { + + geo.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( sea.joint, sea.jointPerVertex ) ); + geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( sea.weight, sea.jointPerVertex ) ); + + } + + if ( this.config.bounding ) { + + geo.computeBoundingBox(); + geo.computeBoundingSphere(); + + } + + geo.name = sea.name; + + this.domain.geometries = this.geometries = this.geometries || []; + this.geometries.push( this.objects[ "geo/" + sea.name ] = sea.tag = geo ); + +}; + +// +// Dummy +// + +THREE.SEA3D.prototype.readDummy = function ( sea ) { + + var dummy = new THREE.SEA3D.Dummy( sea.width, sea.height, sea.depth ); + dummy.name = sea.name; + + this.domain.dummys = this.dummys = this.dummys || []; + this.dummys.push( this.objects[ "dmy/" + sea.name ] = sea.tag = dummy ); + + this.addSceneObject( sea ); + this.updateTransform( dummy, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.Object3DAnimator ); + +}; + +// +// Line +// + +THREE.SEA3D.prototype.readLine = function ( sea ) { + + var geo = new THREE.BufferGeometry(); + + if ( sea.closed ) + sea.vertex.push( sea.vertex[ 0 ], sea.vertex[ 1 ], sea.vertex[ 2 ] ); + + geo.addAttribute( 'position', new THREE.Float32BufferAttribute( sea.vertex, 3 ) ); + + var line = new THREE.Line( geo, new THREE.LineBasicMaterial( { color: THREE.SEA3D.HELPER_COLOR, linewidth: 3 } ) ); + line.name = sea.name; + + this.lines = this.lines || []; + this.lines.push( this.objects[ "line/" + sea.name ] = sea.tag = line ); + + this.addSceneObject( sea ); + this.updateTransform( line, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.Object3DAnimator ); + +}; + +// +// Container3D +// + +THREE.SEA3D.prototype.readContainer3D = function ( sea ) { + + var container = new THREE.SEA3D.Object3D(); + + this.domain.containers = this.containers = this.containers || []; + this.containers.push( this.objects[ "c3d/" + sea.name ] = sea.tag = container ); + + this.addSceneObject( sea ); + this.updateTransform( container, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.Object3DAnimator ); + +}; + +// +// Sprite +// + +THREE.SEA3D.prototype.readSprite = function ( sea ) { + + var mat; + + if ( sea.material ) { + + if ( ! sea.material.tag.sprite ) { + + mat = sea.material.tag.sprite = new THREE.SpriteMaterial(); + + this.setBlending( mat, sea.blendMode ); + + var map = sea.material.tag.map; + + if ( map ) { + + map.flipY = true; + mat.map = map; + + } + + mat.color.set( sea.material.tag.color ); + mat.opacity = sea.material.tag.opacity; + mat.fog = sea.material.receiveFog; + + } else { + + mat = sea.material.tag.sprite; + + } + + } + + var sprite = new THREE.Sprite( mat ); + sprite.name = sea.name; + + this.domain.sprites = this.sprites = this.sprites || []; + this.sprites.push( this.objects[ "m2d/" + sea.name ] = sea.tag = sprite ); + + this.addSceneObject( sea ); + this.updateTransform( sprite, sea ); + + sprite.scale.set( sea.width, sea.height, 1 ); + +}; + +// +// Mesh +// + +THREE.SEA3D.prototype.readMesh = function ( sea ) { + + var i, count, geo = sea.geometry.tag, mesh, mat, skeleton, morpher, skeletonAnimation, vertexAnimation, uvwAnimationClips, morphAnimation; + + for ( i = 0, count = sea.modifiers ? sea.modifiers.length : 0; i < count; i ++ ) { + + var mod = sea.modifiers[ i ]; + + switch ( mod.type ) { + + case SEA3D.Skeleton.prototype.type: + case SEA3D.SkeletonLocal.prototype.type: + + skeleton = mod; + + geo.bones = skeleton.tag; + + break; + + case SEA3D.Morph.prototype.type: + + morpher = mod.tag || this.getModifier( { + sea: mod, + geometry: sea.geometry + } ); + + geo.morphAttributes = morpher.attribs; + geo.morphTargets = morpher.targets; + + break; + + } + + } + + for ( i = 0, count = sea.animations ? sea.animations.length : 0; i < count; i ++ ) { + + var anm = sea.animations[ i ], + anmTag = anm.tag; + + switch ( anmTag.type ) { + + case SEA3D.SkeletonAnimation.prototype.type: + + skeletonAnimation = anmTag; + + geo.animations = skeletonAnimation.tag || this.getModifier( { + sea: skeletonAnimation, + skeleton: skeleton, + relative: true + } ); + + break; + + case SEA3D.VertexAnimation.prototype.type: + + vertexAnimation = anmTag; + + geo.morphAttributes = vertexAnimation.tag.attribs; + geo.morphTargets = vertexAnimation.tag.targets; + geo.animations = vertexAnimation.tag.animations; + + break; + + case SEA3D.UVWAnimation.prototype.type: + + uvwAnimationClips = anmTag.tag || this.getModifier( { + sea: anmTag + } ); + + break; + + case SEA3D.MorphAnimation.prototype.type: + + morphAnimation = anmTag.tag || this.getModifier( { + sea: anmTag + } ); + + break; + + } + + } + + var uMorph = morpher != undefined || vertexAnimation != undefined, + uMorphNormal = + ( morpher && morpher.attribs.normal != undefined ) || + ( vertexAnimation && vertexAnimation.tag.attribs.normal != undefined ); + + if ( sea.material ) { + + if ( sea.material.length > 1 ) { + + var mats = []; + + for ( i = 0; i < sea.material.length; i ++ ) { + + mats[ i ] = sea.material[ i ].tag; + + mats[ i ].skinning = skeleton != undefined; + mats[ i ].morphTargets = uMorph; + mats[ i ].morphNormals = uMorphNormal; + mats[ i ].vertexColors = sea.geometry.color ? THREE.VertexColors : THREE.NoColors; + + } + + mat = THREE.SEA3D.useMultiMaterial ? new THREE.MultiMaterial( mats ) : mats; + + } else { + + mat = sea.material[ 0 ].tag; + + mat.skinning = skeleton != undefined; + mat.morphTargets = uMorph; + mat.morphNormals = uMorphNormal; + mat.vertexColors = sea.geometry.color ? THREE.VertexColors : THREE.NoColors; + + } + + } + + if ( skeleton ) { + + mesh = new THREE.SEA3D.SkinnedMesh( geo, mat, this.config.useVertexTexture ); + + if ( this.config.autoPlay && skeletonAnimation ) { + + mesh.play( 0 ); + + } + + } else if ( vertexAnimation ) { + + mesh = new THREE.SEA3D.VertexAnimationMesh( geo, mat ); + + if ( this.config.autoPlay ) { + + mesh.play( 0 ); + + } + + } else { + + mesh = new THREE.SEA3D.Mesh( geo, mat ); + + } + + if ( uvwAnimationClips ) { + + mesh.uvwAnimator = new THREE.SEA3D.Animator( uvwAnimationClips, new THREE.AnimationMixer( mat.map ) ); + + if ( this.config.autoPlay ) { + + mesh.uvwAnimator.play( 0 ); + + } + + } + + if ( morphAnimation ) { + + mesh.morphAnimator = new THREE.SEA3D.Animator( morphAnimation, new THREE.AnimationMixer( mesh ) ); + + if ( this.config.autoPlay ) { + + mesh.morphAnimator.play( 0 ); + + } + + } + + mesh.name = sea.name; + + mesh.castShadow = sea.castShadows; + mesh.receiveShadow = sea.material ? sea.material[ 0 ].receiveShadows : true; + + this.domain.meshes = this.meshes = this.meshes || []; + this.meshes.push( this.objects[ "m3d/" + sea.name ] = sea.tag = mesh ); + + this.addSceneObject( sea ); + this.updateTransform( mesh, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.Object3DAnimator ); + +}; + +// +// Sound Point +// + +THREE.SEA3D.prototype.readSoundPoint = function ( sea ) { + + if ( ! this.audioListener ) { + + this.audioListener = new THREE.AudioListener(); + + if ( this.config.container ) { + + this.config.container.add( this.audioListener ); + + } + + } + + var sound3d = new THREE.SEA3D.PointSound( this.audioListener ); + sound3d.autoplay = sea.autoPlay; + sound3d.setLoop( sea.autoPlay ); + sound3d.setVolume( sea.volume ); + sound3d.setRefDistance( sea.distance ); + sound3d.setRolloffFactor( this.config.audioRolloffFactor ); + sound3d.setSound( sea.sound.tag ); + + sound3d.name = sea.name; + + this.domain.sounds3d = this.sounds3d = this.sounds3d || []; + this.sounds3d.push( this.objects[ "sn3d/" + sea.name ] = sea.tag = sound3d ); + + this.addSceneObject( sea ); + this.updateTransform( sound3d, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.SoundAnimator ); + +}; + +// +// Cube Render +// + +THREE.SEA3D.prototype.readCubeRender = function ( sea ) { + + var cube = new THREE.CubeCamera( 0.1, 5000, THREE.SEA3D.RTT_SIZE ); + cube.renderTarget.cubeCamera = cube; + + sea.tag = cube.renderTarget; + + this.domain.cubeRenderers = this.cubeRenderers = this.cubeRenderers || []; + this.cubeRenderers.push( this.objects[ "rttc/" + sea.name ] = cube ); + + this.addSceneObject( sea, cube ); + this.updateTransform( cube, sea ); + +}; + +// +// Texture (WDP, JPEG, PNG and GIF) +// + +THREE.SEA3D.prototype.readTexture = function ( sea ) { + + var image = new Image(), + texture = new THREE.Texture(); + + texture.name = sea.name; + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + texture.flipY = false; + texture.image = image; + + if ( this.config.anisotropy !== undefined ) texture.anisotropy = this.config.anisotropy; + + image.onload = function () { + + texture.needsUpdate = true; + + }; + + image.src = this.createObjectURL( sea.data.buffer, "image/" + sea.type ); + + this.domain.textures = this.textures = this.textures || []; + this.textures.push( this.objects[ "tex/" + sea.name ] = sea.tag = texture ); + +}; + +// +// Cube Map +// + +THREE.SEA3D.prototype.readCubeMap = function ( sea ) { + + var faces = this.toFaces( sea.faces ), texture = new THREE.CubeTexture( [] ); + + var loaded = 0; + + texture.name = sea.name; + texture.flipY = false; + texture.format = THREE.RGBFormat; + + var onLoaded = function () { + + if ( ++ loaded == 6 ) { + + texture.needsUpdate = true; + + if ( ! this.config.async ) this.file.resume = true; + + } + + }.bind( this ); + + for ( var i = 0; i < faces.length; ++ i ) { + + var cubeImage = new Image(); + cubeImage.onload = onLoaded; + cubeImage.src = this.createObjectURL( faces[ i ].buffer, "image/" + sea.extension ); + + texture.images[ i ] = cubeImage; + + } + + if ( ! this.config.async ) this.file.resume = false; + + this.domain.cubemaps = this.cubemaps = this.cubemaps || []; + this.cubemaps.push( this.objects[ "cmap/" + sea.name ] = sea.tag = texture ); + +}; + +// +// Updaters +// + +THREE.SEA3D.prototype.readTextureUpdate = function ( sea ) { + + var obj = this.file.objects[ sea.index ], + tex = obj.tag; + + var image = new Image(); + + image.onload = function () { + + tex.image = image; + tex.needsUpdate = true; + + }; + + image.src = this.createObjectURL( sea.bytes.buffer, "image/" + obj.type ); + +}; + +// +// Sound (MP3, OGG) +// + +THREE.SEA3D.prototype.readSound = function ( sea ) { + + var sound = new THREE.SEA3D.Sound( this.createObjectURL( sea.data.buffer, "audio/" + sea.type ) ); + sound.name = sea.name; + + this.domain.sounds = this.sounds = this.sounds || []; + this.sounds.push( this.objects[ "snd/" + sea.name ] = sea.tag = sound ); + +}; + +// +// Script URL +// + +THREE.SEA3D.prototype.readScriptURL = function ( sea ) { + + this.file.resume = false; + + var loader = new THREE.FileLoader(); + + loader.setResponseType( "text" ).load( sea.url, function ( src ) { + + this.file.resume = true; + + this.domain.scripts = this.scripts = this.scripts || []; + this.scripts.push( this.objects[ "src/" + sea.name ] = sea.tag = src ); + + }.bind( this ) ); + +}; + +// +// Texture URL +// + +THREE.SEA3D.prototype.readTextureURL = function ( sea ) { + + var texture = new THREE.TextureLoader().load( this.parsePath( sea.url ) ); + + texture.name = sea.name; + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + texture.flipY = false; + + if ( this.config.anisotropy !== undefined ) texture.anisotropy = this.config.anisotropy; + + this.domain.textures = this.textures = this.textures || []; + this.textures.push( this.objects[ "tex/" + sea.name ] = sea.tag = texture ); + +}; + +// +// CubeMap URL +// + +THREE.SEA3D.prototype.readCubeMapURL = function ( sea ) { + + var faces = this.toFaces( sea.faces ); + + for ( var i = 0; i < faces.length; i ++ ) { + + faces[ i ] = this.parsePath( faces[ i ] ); + + } + + var texture, format = faces[ 0 ].substr( - 3 ); + + if ( format == "hdr" ) { + + var usePMREM = THREE.PMREMGenerator != null; + + this.file.resume = ! usePMREM; + + texture = new THREE.HDRCubeTextureLoader().load( THREE.UnsignedByteType, faces, function ( texture ) { + + if ( usePMREM ) { + + var pmremGenerator = new THREE.PMREMGenerator( texture ); + pmremGenerator.update( this.config.renderer ); + + var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods ); + pmremCubeUVPacker.update( this.config.renderer ); + + this.objects[ "cmap/" + sea.name ] = sea.tag = pmremCubeUVPacker.CubeUVRenderTarget.texture; + + this.file.resume = true; + + texture.dispose(); + pmremGenerator.dispose(); + pmremCubeUVPacker.dispose(); + + } + + }.bind( this ) ); + + } else { + + texture = new THREE.CubeTextureLoader().load( faces ); + + } + + texture.name = sea.name; + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + texture.flipY = false; + + if ( this.config.anisotropy !== undefined ) texture.anisotropy = this.config.anisotropy; + + this.domain.cubemaps = this.cubemaps = this.cubemaps || []; + this.cubemaps.push( this.objects[ "cmap/" + sea.name ] = sea.tag = texture ); + +}; + +// +// Runtime +// + +THREE.SEA3D.prototype.getJSMList = function ( target, scripts ) { + + var scriptTarget = []; + + for ( var i = 0; i < scripts.length; i ++ ) { + + var script = scripts[ i ]; + + if ( script.tag.type == SEA3D.JavaScriptMethod.prototype.type ) { + + scriptTarget.push( script ); + + } + + } + + this.domain.scriptTargets = this.scriptTargets = this.scriptTargets || []; + this.scriptTargets.push( target ); + + return scriptTarget; + +}; + +THREE.SEA3D.prototype.readJavaScriptMethod = function ( sea ) { + + try { + + var src = + '(function() {\n' + + 'var $METHOD = {}\n'; + + var declare = + 'function($INC, $REF, global, local, self, $PARAM) {\n' + + 'var watch = $INC["watch"],\n' + + 'scene = $INC["scene"],\n' + + 'sea3d = $INC["sea3d"],\n' + + 'print = $INC["print"];\n'; + + declare += + 'var $SRC = $INC["source"],\n' + + 'addEventListener = $SRC.addEventListener.bind( $SRC ),\n' + + 'hasEventListener = $SRC.hasEventListener.bind( $SRC ),\n' + + 'removeEventListener = $SRC.removeEventListener.bind( $SRC ),\n' + + 'dispatchEvent = $SRC.dispatchEvent.bind( $SRC ),\n' + + 'dispose = $SRC.dispose.bind( $SRC );\n'; + + for ( var name in sea.methods ) { + + src += '$METHOD["' + name + '"] = ' + declare + sea.methods[ name ].src + '}\n'; + + } + + src += 'return $METHOD; })'; + + this.domain.methods = eval( src )(); + + } catch ( e ) { + + console.error( 'SEA3D JavaScriptMethod: Error running "' + sea.name + '".' ); + console.error( e ); + + } + +}; + +// +// GLSL +// + +THREE.SEA3D.prototype.readGLSL = function ( sea ) { + + this.domain.glsl = this.glsl = this.glsl || []; + this.glsl.push( this.objects[ "glsl/" + sea.name ] = sea.tag = sea.src ); + +}; + +// +// Material +// + +THREE.SEA3D.prototype.materialTechnique = +( function () { + + var techniques = {}; + + // FINAL + techniques.onComplete = function ( mat, sea ) { + + if ( sea.alpha < 1 || mat.blending > THREE.NormalBlending ) { + + mat.opacity = sea.alpha; + mat.transparent = true; + + } + + }; + + // PHYSICAL + techniques[ SEA3D.Material.PHYSICAL ] = + function ( mat, tech ) { + + mat.color.setHex( tech.color ); + mat.roughness = tech.roughness; + mat.metalness = tech.metalness; + + }; + + // REFLECTIVITY + techniques[ SEA3D.Material.REFLECTIVITY ] = + function ( mat, tech ) { + + mat.reflectivity = tech.strength; + + }; + + // CLEAR_COAT + techniques[ SEA3D.Material.CLEAR_COAT ] = + function ( mat, tech ) { + + mat.clearCoat = tech.strength; + mat.clearCoatRoughness = tech.roughness; + + }; + + // PHONG + techniques[ SEA3D.Material.PHONG ] = + function ( mat, tech ) { + + mat.color.setHex( tech.diffuseColor ); + mat.specular.setHex( tech.specularColor ).multiplyScalar( tech.specular ); + mat.shininess = tech.gloss; + + }; + + // DIFFUSE_MAP + techniques[ SEA3D.Material.DIFFUSE_MAP ] = + function ( mat, tech, sea ) { + + mat.map = tech.texture.tag; + mat.color.setHex( 0xFFFFFF ); + + mat.map.wrapS = mat.map.wrapT = sea.repeat ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + + if ( tech.texture.transparent ) { + + mat.transparent = true; + + } + + }; + + // ROUGHNESS_MAP + techniques[ SEA3D.Material.ROUGHNESS_MAP ] = + function ( mat, tech ) { + + mat.roughnessMap = tech.texture.tag; + + }; + + // METALNESS_MAP + techniques[ SEA3D.Material.METALNESS_MAP ] = + function ( mat, tech ) { + + mat.metalnessMap = tech.texture.tag; + + }; + + // SPECULAR_MAP + techniques[ SEA3D.Material.SPECULAR_MAP ] = + function ( mat, tech ) { + + if ( mat.specular ) { + + mat.specularMap = tech.texture.tag; + mat.specular.setHex( 0xFFFFFF ); + + } + + }; + + // NORMAL_MAP + techniques[ SEA3D.Material.NORMAL_MAP ] = + function ( mat, tech ) { + + mat.normalMap = tech.texture.tag; + + }; + + // REFLECTION + techniques[ SEA3D.Material.REFLECTION ] = + techniques[ SEA3D.Material.FRESNEL_REFLECTION ] = + function ( mat, tech ) { + + mat.envMap = tech.texture.tag; + mat.envMap.mapping = THREE.CubeReflectionMapping; + mat.combine = THREE.MixOperation; + + mat.reflectivity = tech.alpha; + + }; + + // REFLECTION_SPHERICAL + techniques[ SEA3D.Material.REFLECTION_SPHERICAL ] = + function ( mat, tech ) { + + mat.envMap = tech.texture.tag; + mat.envMap.mapping = THREE.SphericalReflectionMapping; + mat.combine = THREE.MixOperation; + + mat.reflectivity = tech.alpha; + + }; + + // REFRACTION + techniques[ SEA3D.Material.REFRACTION_MAP ] = + function ( mat, tech ) { + + mat.envMap = tech.texture.tag; + mat.envMap.mapping = THREE.CubeRefractionMapping; + + mat.refractionRatio = tech.ior; + mat.reflectivity = tech.alpha; + + }; + + // LIGHT_MAP + techniques[ SEA3D.Material.LIGHT_MAP ] = + function ( mat, tech ) { + + if ( tech.blendMode == "multiply" ) mat.aoMap = tech.texture.tag; + else mat.lightMap = tech.texture.tag; + + }; + + // EMISSIVE + techniques[ SEA3D.Material.EMISSIVE ] = + function ( mat, tech ) { + + mat.emissive.setHex( tech.color ); + + }; + + // EMISSIVE_MAP + techniques[ SEA3D.Material.EMISSIVE_MAP ] = + function ( mat, tech ) { + + mat.emissiveMap = tech.texture.tag; + + }; + + // ALPHA_MAP + techniques[ SEA3D.Material.ALPHA_MAP ] = + function ( mat, tech, sea ) { + + mat.alphaMap = tech.texture.tag; + mat.transparent = true; + + mat.alphaMap.wrapS = mat.alphaMap.wrapT = sea.repeat ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + + }; + + return techniques; + +} )(); + +THREE.SEA3D.prototype.createMaterial = function ( sea ) { + + if ( sea.tecniquesDict[ SEA3D.Material.REFLECTIVITY ] || sea.tecniquesDict[ SEA3D.Material.CLEAR_COAT ] ) { + + return new THREE.MeshPhysicalMaterial(); + + } else if ( sea.tecniquesDict[ SEA3D.Material.PHYSICAL ] ) { + + return new THREE.MeshStandardMaterial(); + + } + + return new THREE.MeshPhongMaterial(); + +}; + +THREE.SEA3D.prototype.setBlending = function ( mat, blendMode ) { + + if ( blendMode === "normal" ) return; + + switch ( blendMode ) { + + case "add": + + mat.blending = THREE.AdditiveBlending; + + break; + + case "subtract": + + mat.blending = THREE.SubtractiveBlending; + + break; + + case "multiply": + + mat.blending = THREE.MultiplyBlending; + + break; + + case "screen": + + mat.blending = THREE.CustomBlending; + mat.blendSrc = THREE.OneFactor; + mat.blendDst = THREE.OneMinusSrcColorFactor; + mat.blendEquation = THREE.AddEquation; + + break; + + } + + mat.transparent = true; + +}; + +THREE.SEA3D.prototype.readMaterial = function ( sea ) { + + var mat = this.createMaterial( sea ); + mat.name = sea.name; + + mat.lights = sea.receiveLights; + mat.fog = sea.receiveFog; + + mat.depthWrite = sea.depthWrite; + mat.depthTest = sea.depthTest; + + mat.premultipliedAlpha = sea.premultipliedAlpha; + + mat.side = sea.doubleSided ? THREE.DoubleSide : THREE.FrontSide; + + this.setBlending( mat, sea.blendMode ); + + for ( var i = 0; i < sea.technique.length; i ++ ) { + + var tech = sea.technique[ i ]; + + if ( this.materialTechnique[ tech.kind ] ) { + + this.materialTechnique[ tech.kind ].call( this, mat, tech, sea ); + + } + + } + + if ( this.materialTechnique.onComplete ) { + + this.materialTechnique.onComplete.call( this, mat, sea ); + + } + + this.domain.materials = this.materials = this.materials || []; + this.materials.push( this.objects[ "mat/" + sea.name ] = sea.tag = mat ); + +}; + +// +// Point Light +// + +THREE.SEA3D.prototype.readPointLight = function ( sea ) { + + var light = new THREE.SEA3D.PointLight( sea.color, sea.multiplier * this.config.multiplier ); + light.name = sea.name; + + if ( sea.attenuation ) { + + light.distance = sea.attenuation.end; + + } + + if ( sea.shadow ) this.setShadowMap( light ); + + this.domain.lights = this.lights = this.lights || []; + this.lights.push( this.objects[ "lht/" + sea.name ] = sea.tag = light ); + + this.addSceneObject( sea ); + + this.updateTransform( light, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.LightAnimator ); + + this.updateScene(); + +}; + +// +// Hemisphere Light +// + +THREE.SEA3D.prototype.readHemisphereLight = function ( sea ) { + + var light = new THREE.HemisphereLight( sea.color, sea.secondColor, sea.multiplier * this.config.multiplier ); + light.position.set( 0, 500, 0 ); + light.name = sea.name; + + this.domain.lights = this.lights = this.lights || []; + this.lights.push( this.objects[ "lht/" + sea.name ] = sea.tag = light ); + + this.addSceneObject( sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.LightAnimator ); + + this.updateScene(); + +}; + +// +// Ambient Light +// + +THREE.SEA3D.prototype.readAmbientLight = function ( sea ) { + + var light = new THREE.AmbientLight( sea.color, sea.multiplier * this.config.multiplier ); + light.name = sea.name; + + this.domain.lights = this.lights = this.lights || []; + this.lights.push( this.objects[ "lht/" + sea.name ] = sea.tag = light ); + + this.addSceneObject( sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.LightAnimator ); + + this.updateScene(); + +}; + +// +// Directional Light +// + +THREE.SEA3D.prototype.readDirectionalLight = function ( sea ) { + + var light = new THREE.DirectionalLight( sea.color, sea.multiplier * this.config.multiplier ); + light.name = sea.name; + + if ( sea.shadow ) { + + this.setShadowMap( light ); + + } + + this.domain.lights = this.lights = this.lights || []; + this.lights.push( this.objects[ "lht/" + sea.name ] = sea.tag = light ); + + this.addSceneObject( sea ); + + this.updateTransform( light, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.LightAnimator ); + + this.updateScene(); + +}; + +// +// Camera +// + +THREE.SEA3D.prototype.readCamera = function ( sea ) { + + var camera = new THREE.SEA3D.Camera( sea.fov ); + camera.name = sea.name; + + this.domain.cameras = this.cameras = this.cameras || []; + this.cameras.push( this.objects[ "cam/" + sea.name ] = sea.tag = camera ); + + this.addSceneObject( sea ); + this.updateTransform( camera, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.CameraAnimator ); + +}; + +// +// Orthographic Camera +// + +THREE.SEA3D.prototype.readOrthographicCamera = function ( sea ) { + + var aspect, width, height; + + var stageWidth = this.config.stageWidth !== undefined ? this.config.stageWidth : ( window ? window.innerWidth : 1024 ); + var stageHeight = this.config.stageHeight !== undefined ? this.config.stageHeight : ( window ? window.innerHeight : 1024 ); + + if ( stageWidth > stageHeight ) { + + aspect = stageWidth / stageHeight; + + width = sea.height * aspect; + height = sea.height; + + } else { + + aspect = stageHeight / stageWidth; + + width = sea.height; + height = sea.height * aspect; + + } + + var camera = new THREE.SEA3D.OrthographicCamera( - width, width, height, - height ); + camera.name = sea.name; + + this.domain.cameras = this.cameras = this.cameras || []; + this.cameras.push( this.objects[ "cam/" + sea.name ] = sea.tag = camera ); + + this.addSceneObject( sea ); + this.updateTransform( camera, sea ); + + this.addDefaultAnimation( sea, THREE.SEA3D.CameraAnimator ); + +}; + +// +// Skeleton +// + +THREE.SEA3D.prototype.getSkeletonFromBones = function ( bonesData ) { + + var bones = [], bone, gbone; + var i, il; + + for ( i = 0, il = bonesData.length; i < il; i ++ ) { + + gbone = bonesData[ i ]; + + bone = new THREE.Bone(); + bones.push( bone ); + + bone.name = gbone.name; + bone.position.fromArray( gbone.pos ); + bone.quaternion.fromArray( gbone.rotq ); + + if ( gbone.scl !== undefined ) bone.scale.fromArray( gbone.scl ); + + } + + for ( i = 0, il = bonesData.length; i < il; i ++ ) { + + gbone = bonesData[ i ]; + + if ( ( gbone.parent !== - 1 ) && ( gbone.parent !== null ) && ( bones[ gbone.parent ] !== undefined ) ) { + + bones[ gbone.parent ].add( bones[ i ] ); + + } + + } + + return new THREE.Skeleton( bones ); + +}; + +THREE.SEA3D.prototype.readSkeletonLocal = function ( sea ) { + + var bones = []; + + for ( var i = 0; i < sea.joint.length; i ++ ) { + + var bone = sea.joint[ i ]; + + bones[ i ] = { + name: bone.name, + pos: [ bone.x, bone.y, bone.z ], + rotq: [ bone.qx, bone.qy, bone.qz, bone.qw ], + parent: bone.parentIndex + }; + + } + + this.domain.bones = this.bones = this.bones || []; + this.bones.push( this.objects[ sea.name + '.sklq' ] = sea.tag = bones ); + +}; + +// +// Joint Object +// + +THREE.SEA3D.prototype.readJointObject = function ( sea ) { + + var mesh = sea.target.tag, + bone = mesh.skeleton.bones[ sea.joint ]; + + this.domain.joints = this.joints = this.joints || []; + this.joints.push( this.objects[ "jnt/" + sea.name ] = sea.tag = bone ); + +}; + +// +// Morph +// + +THREE.SEA3D.prototype.readMorph = function ( sea ) { + + var attribs = { position: [] }, targets = []; + + for ( var i = 0; i < sea.node.length; i ++ ) { + + var node = sea.node[ i ]; + + attribs.position[ i ] = new THREE.Float32BufferAttribute( node.vertex, 3 ); + attribs.position[ i ].name = node.name; + + if ( node.normal ) { + + attribs.normal = attribs.normal || []; + attribs.normal[ i ] = new THREE.Float32BufferAttribute( node.normal, 3 ); + + } + + targets[ i ] = { name: node.name }; + + } + + sea.tag = { + attribs: attribs, + targets: targets + }; + +}; + +// +// Animation +// + +THREE.SEA3D.prototype.readAnimation = function ( sea ) { + + var animations = [], delta = ( 1000 / sea.frameRate ) / 1000; + + for ( var i = 0; i < sea.sequence.length; i ++ ) { + + var seq = sea.sequence[ i ]; + + var tracks = []; + + for ( var j = 0; j < sea.dataList.length; j ++ ) { + + var anm = sea.dataList[ j ], + t, k, times, values, + data = anm.data, + start = seq.start * anm.blockSize, + end = start + ( seq.count * anm.blockSize ), + intrpl = seq.intrpl ? THREE.InterpolateLinear : false, + name = null; + + switch ( anm.kind ) { + + case SEA3D.Animation.POSITION: + + name = '.position'; + + break; + + case SEA3D.Animation.ROTATION: + + name = '.quaternion'; + + break; + + case SEA3D.Animation.SCALE: + + name = '.scale'; + + break; + + case SEA3D.Animation.COLOR: + + name = '.color'; + + break; + + case SEA3D.Animation.MULTIPLIER: + + name = '.intensity'; + + break; + + case SEA3D.Animation.FOV: + + name = '.fov'; + + break; + + case SEA3D.Animation.OFFSET_U: + + name = '.offset[x]'; + + break; + + case SEA3D.Animation.OFFSET_V: + + name = '.offset[y]'; + + break; + + case SEA3D.Animation.SCALE_U: + + name = '.repeat[x]'; + + break; + + case SEA3D.Animation.SCALE_V: + + name = '.repeat[y]'; + + break; + + case SEA3D.Animation.MORPH: + + name = '.morphTargetInfluences[' + anm.name + ']'; + + break; + + } + + if ( ! name ) continue; + + switch ( anm.type ) { + + case SEA3D.Stream.BYTE: + case SEA3D.Stream.UBYTE: + case SEA3D.Stream.INT: + case SEA3D.Stream.UINT: + case SEA3D.Stream.FLOAT: + case SEA3D.Stream.DOUBLE: + case SEA3D.Stream.DECIMAL: + + values = data.subarray( start, end ); + times = new Float32Array( values.length ); + t = 0; + + for ( k = 0; k < times.length; k ++ ) { + + times[ k ] = t; + t += delta; + + } + + tracks.push( new THREE.NumberKeyframeTrack( name, times, values, intrpl ) ); + + break; + + case SEA3D.Stream.VECTOR3D: + + values = data.subarray( start, end ); + times = new Float32Array( values.length / anm.blockSize ); + t = 0; + + for ( k = 0; k < times.length; k ++ ) { + + times[ k ] = t; + t += delta; + + } + + tracks.push( new THREE.VectorKeyframeTrack( name, times, values, intrpl ) ); + + break; + + case SEA3D.Stream.VECTOR4D: + + values = data.subarray( start, end ); + times = new Float32Array( values.length / anm.blockSize ); + t = 0; + + for ( k = 0; k < times.length; k ++ ) { + + times[ k ] = t; + t += delta; + + } + + tracks.push( new THREE.QuaternionKeyframeTrack( name, times, values, intrpl ) ); + + break; + + case SEA3D.Stream.INT24: + case SEA3D.Stream.UINT24: + + values = new Float32Array( ( end - start ) * 3 ); + times = new Float32Array( values.length / 3 ); + t = 0; + + for ( k = 0; k < times.length; k ++ ) { + + values[ ( k * 3 ) ] = ( ( data[ k ] >> 16 ) & 0xFF ) / 255; + values[ ( k * 3 ) + 1 ] = ( ( data[ k ] >> 8 ) & 0xFF ) / 255; + values[ ( k * 3 ) + 2 ] = ( data[ k ] & 0xFF ) / 255; + times[ k ] = t; + t += delta; + + } + + tracks.push( new THREE.VectorKeyframeTrack( name, times, values, intrpl ) );//ColorKeyframeTrack + + break; + + } + + } + + animations.push( new THREE.SEA3D.AnimationClip( seq.name, - 1, tracks, seq.repeat ) ); + + } + + this.domain.clips = this.clips = this.clips || []; + this.clips.push( this.objects[ sea.name + '.anm' ] = sea.tag = animations ); + +}; + +// +// Skeleton Animation +// + +THREE.SEA3D.prototype.readSkeletonAnimation = function ( sea, skl ) { + + skl = ! skl && sea.metadata && sea.metadata.skeleton ? sea.metadata.skeleton : skl; + + if ( ! skl || sea.tag ) return sea.tag; + + var animations = [], delta = ( 1000 / sea.frameRate ) / 1000; + + for ( var i = 0; i < sea.sequence.length; i ++ ) { + + var seq = sea.sequence[ i ]; + + var start = seq.start; + var end = start + seq.count; + + var animation = { + name: seq.name, + fps: sea.frameRate, + length: delta * seq.count, + hierarchy: [] + }; + + var numJoints = sea.numJoints, + raw = sea.raw; + + for ( var j = 0; j < numJoints; j ++ ) { + + var bone = skl.joint[ j ], + node = { parent: bone.parentIndex, keys: [] }, + keys = node.keys, + time = 0; + + for ( var frame = start; frame < end; frame ++ ) { + + var idx = ( frame * numJoints * 7 ) + ( j * 7 ); + + keys.push( { + time: time, + pos: [ raw[ idx ], raw[ idx + 1 ], raw[ idx + 2 ] ], + rot: [ raw[ idx + 3 ], raw[ idx + 4 ], raw[ idx + 5 ], raw[ idx + 6 ] ], + scl: [ 1, 1, 1 ] + } ); + + time += delta; + + } + + animation.hierarchy[ j ] = node; + + } + + animations.push( THREE.SEA3D.AnimationClip.fromClip( THREE.AnimationClip.parseAnimation( animation, skl.tag ), seq.repeat ) ); + + } + + this.domain.clips = this.clips = this.clips || []; + this.clips.push( this.objects[ sea.name + '.skla' ] = sea.tag = animations ); + +}; + +// +// Vertex Animation +// + +THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) { + + var attribs = { position: [] }, targets = [], animations = [], i, j, l; + + for ( i = 0, l = sea.frame.length; i < l; i ++ ) { + + var frame = sea.frame[ i ]; + + attribs.position[ i ] = new THREE.Float32BufferAttribute( frame.vertex, 3 ); + + if ( frame.normal ) { + + attribs.normal = attribs.normal || []; + attribs.normal[ i ] = new THREE.Float32BufferAttribute( frame.normal, 3 ); + + } + + targets[ i ] = { name: i }; + + } + + for ( i = 0; i < sea.sequence.length; i ++ ) { + + var seq = sea.sequence[ i ]; + var seqTargets = []; + + for ( j = 0; j < seq.count; j ++ ) { + + seqTargets[ j ] = targets[ seq.start + j ]; + + } + + animations.push( THREE.SEA3D.AnimationClip.fromClip( THREE.AnimationClip.CreateFromMorphTargetSequence( seq.name, seqTargets, sea.frameRate ), seq.repeat ) ); + + } + + sea.tag = { + attribs: attribs, + targets: targets, + animations: animations + }; + + this.domain.clips = this.clips = this.clips || []; + this.clips.push( this.objects[ sea.name + '.vtxa' ] = sea.tag ); + +}; + +// +// Selector +// + +THREE.SEA3D.prototype.getModifier = function ( req ) { + + var sea = req.sea; + + switch ( sea.type ) { + + case SEA3D.SkeletonAnimation.prototype.type: + + this.readSkeletonAnimation( sea, req.skeleton ); + + break; + + case SEA3D.Animation.prototype.type: + case SEA3D.MorphAnimation.prototype.type: + case SEA3D.UVWAnimation.prototype.type: + + this.readAnimation( sea ); + + break; + + case SEA3D.Morph.prototype.type: + + this.readMorph( sea, req.geometry ); + + break; + + } + + return sea.tag; + +}; + +// +// Actions +// + +THREE.SEA3D.prototype.applyEnvironment = function ( envMap ) { + + for ( var j = 0, l = this.materials.length; j < l; ++ j ) { + + var mat = this.materials[ j ]; + + if ( mat instanceof THREE.MeshStandardMaterial ) { + + if ( mat.envMap ) continue; + + mat.envMap = envMap; + mat.envMap.mapping = THREE.CubeReflectionMapping; + + mat.needsUpdate = true; + + } + + } + +}; + +THREE.SEA3D.prototype.readActions = function ( sea ) { + + for ( var i = 0; i < sea.actions.length; i ++ ) { + + var act = sea.actions[ i ]; + + switch ( act.kind ) { + + case SEA3D.Actions.ATTRIBUTES: + + this.attribs = this.domain.attribs = act.attributes.tag; + + break; + + case SEA3D.Actions.SCRIPTS: + + this.domain.scripts = this.getJSMList( this.domain, act.scripts ); + + if ( this.config.scripts && this.config.runScripts ) this.domain.runJSMList( this.domain ); + + break; + + case SEA3D.Actions.CAMERA: + + this.domain.camera = this.camera = act.camera.tag; + + break; + + case SEA3D.Actions.ENVIRONMENT_COLOR: + + this.domain.background = this.background = this.background || {}; + + this.background.color = new THREE.Color( act.color ); + + break; + + case SEA3D.Actions.ENVIRONMENT: + + this.domain.background = this.background = this.background || {}; + + this.background.texture = act.texture.tag; + + if ( this.config.useEnvironment && this.materials != undefined ) { + + this.applyEnvironment( act.texture.tag ); + + } + + break; + + } + + } + +}; + +// +// Properties +// + +THREE.SEA3D.prototype.updatePropertiesAssets = function ( sea, props ) { + + for ( var name in props ) { + + switch ( props.__type[ name ] ) { + + case SEA3D.Stream.ASSET: + + if ( ! props.__asset ) props.__asset = {}; + if ( ! props.__asset[ name ] ) props.__asset[ name ] = props[ name ]; + + props[ name ] = props.__asset[ name ].tag; + + break; + + case SEA3D.Stream.GROUP: + + props[ name ] = this.updatePropertiesAssets( sea, props[ name ] ); + + break; + + } + + } + + return props; + +}; + +THREE.SEA3D.prototype.readProperties = function ( sea ) { + + var props = this.updatePropertiesAssets( sea, sea.props ); + + this.domain.properties = this.properties = this.properties || []; + this.properties.push( this.objects[ "prop/" + sea.name ] = sea.tag = props ); + +}; + +THREE.SEA3D.prototype.readFileInfo = function ( sea ) { + + this.domain.info = this.updatePropertiesAssets( sea, sea.info ); + +}; + +// +// Events +// + +THREE.SEA3D.Event = { + PROGRESS: "sea3d_progress", + LOAD_PROGRESS: "sea3d_load", + DOWNLOAD_PROGRESS: "sea3d_download", + COMPLETE: "sea3d_complete", + OBJECT_COMPLETE: "sea3d_object", + PARSE_PROGRESS: "parse_progress", + PARSE_COMPLETE: "parse_complete", + ERROR: "sea3d_error" +}; + +THREE.SEA3D.prototype.onProgress = function ( e ) { + + e.status = e.type; + e.progress = e.loaded / e.total; + e.type = THREE.SEA3D.Event.PROGRESS; + + this.dispatchEvent( e ); + +}; + +THREE.SEA3D.prototype.onLoadProgress = function ( e ) { + + e.type = THREE.SEA3D.Event.LOAD_PROGRESS; + this.dispatchEvent( e ); + + this.onProgress( e ); + +}; + +THREE.SEA3D.prototype.onDownloadProgress = function ( e ) { + + e.type = THREE.SEA3D.Event.DOWNLOAD_PROGRESS; + this.dispatchEvent( e ); + + this.onProgress( e ); + +}; + +THREE.SEA3D.prototype.onComplete = function ( e ) { + + e.type = THREE.SEA3D.Event.COMPLETE; + this.dispatchEvent( e ); + +}; + +THREE.SEA3D.prototype.onCompleteObject = function ( e ) { + + e.type = THREE.SEA3D.Event.OBJECT_COMPLETE; + this.dispatchEvent( e ); + +}; + +THREE.SEA3D.prototype.onParseProgress = function ( e ) { + + e.type = THREE.SEA3D.Event.PARSE_PROGRESS; + this.dispatchEvent( e ); + +}; + +THREE.SEA3D.prototype.onParseComplete = function ( e ) { + + e.type = THREE.SEA3D.Event.PARSE_COMPLETE; + this.dispatchEvent( e ); + +}; + +THREE.SEA3D.prototype.onError = function ( e ) { + + e.type = THREE.SEA3D.Event.ERROR; + this.dispatchEvent( e ); + +}; + +// +// Loader +// + +THREE.SEA3D.prototype.createDomain = function () { + + return this.domain = new THREE.SEA3D.Domain( + this.config.id, + this.objects = {}, + this.config.container + ); + +}; + +THREE.SEA3D.prototype.clone = function ( config, onParseComplete, onParseProgress ) { + + if ( ! this.file.isDone() ) throw new Error( "Previous parse is not completed." ); + + this.config.container = config && config.container !== undefined ? config.container : new THREE.Object3D(); + + if ( config ) this.loadConfig( config ); + + var timeLimit = this.config.timeLimit; + + this.config.timeLimit = config && config.timeLimit !== undefined ? config.timeLimit : Infinity; + + this.parse( onParseComplete, onParseProgress ); + + this.config.timeLimit = timeLimit; + + return this.domain; + +}; + +THREE.SEA3D.prototype.loadConfig = function ( config ) { + + for ( var name in config ) { + + this.config[ name ] = config[ name ]; + + } + +}; + +THREE.SEA3D.prototype.parse = function ( onParseComplete, onParseProgress ) { + + delete this.cameras; + delete this.containers; + delete this.lights; + delete this.joints; + delete this.meshes; + delete this.materials; + delete this.sprites; + delete this.sounds3d; + delete this.cubeRenderers; + delete this.sounds; + delete this.glsl; + delete this.dummy; + delete this.camera; + delete this.background; + delete this.properties; + delete this.scriptTargets; + + delete this.domain; + + this.createDomain(); + + this.setTypeRead(); + + this.file.onParseComplete = ( function ( e ) { + + if ( this.config.manager ) this.config.manager.add( this.domain ); + + ( onParseComplete || this.onParseComplete ).call( this, e ); + + } ).bind( this ); + + this.file.onParseProgress = onParseProgress || this.onParseProgress; + + // EXTENSIONS + + var i = THREE.SEA3D.EXTENSIONS_LOADER.length; + + while ( i -- ) { + + var loader = THREE.SEA3D.EXTENSIONS_LOADER[ i ]; + + if ( loader.parse ) loader.parse.call( this ); + + } + + this.file.parse(); + + return this.domain; + +}; + +THREE.SEA3D.prototype.onHead = function ( args ) { + + if ( args.sign != 'TJS' ) { + + throw new Error( "Sign '" + args.sign + "' not supported! Use SEA3D Studio to publish or SEA3DLegacy.js" ); + + } + +}; + +THREE.SEA3D.EXTENSIONS_LOADER = []; +THREE.SEA3D.EXTENSIONS_DOMAIN = []; + +THREE.SEA3D.prototype.setTypeRead = function () { + + this.file.typeRead = {}; + + this.file.typeRead[ SEA3D.Geometry.prototype.type ] = this.readGeometryBuffer; + this.file.typeRead[ SEA3D.Mesh.prototype.type ] = this.readMesh; + this.file.typeRead[ SEA3D.Sprite.prototype.type ] = this.readSprite; + this.file.typeRead[ SEA3D.Container3D.prototype.type ] = this.readContainer3D; + this.file.typeRead[ SEA3D.Line.prototype.type ] = this.readLine; + this.file.typeRead[ SEA3D.Material.prototype.type ] = this.readMaterial; + this.file.typeRead[ SEA3D.Camera.prototype.type ] = this.readCamera; + this.file.typeRead[ SEA3D.OrthographicCamera.prototype.type ] = this.readOrthographicCamera; + this.file.typeRead[ SEA3D.SkeletonLocal.prototype.type ] = this.readSkeletonLocal; + this.file.typeRead[ SEA3D.SkeletonAnimation.prototype.type ] = this.readSkeletonAnimation; + this.file.typeRead[ SEA3D.JointObject.prototype.type ] = this.readJointObject; + this.file.typeRead[ SEA3D.CubeMap.prototype.type ] = this.readCubeMap; + this.file.typeRead[ SEA3D.CubeRender.prototype.type ] = this.readCubeRender; + this.file.typeRead[ SEA3D.Animation.prototype.type ] = + this.file.typeRead[ SEA3D.MorphAnimation.prototype.type ] = + this.file.typeRead[ SEA3D.UVWAnimation.prototype.type ] = this.readAnimation; + this.file.typeRead[ SEA3D.SoundPoint.prototype.type ] = this.readSoundPoint; + this.file.typeRead[ SEA3D.TextureURL.prototype.type ] = this.readTextureURL; + this.file.typeRead[ SEA3D.CubeMapURL.prototype.type ] = this.readCubeMapURL; + this.file.typeRead[ SEA3D.TextureUpdate.prototype.type ] = this.readTextureUpdate; + this.file.typeRead[ SEA3D.Morph.prototype.type ] = this.readMorph; + this.file.typeRead[ SEA3D.VertexAnimation.prototype.type ] = this.readVertexAnimation; + this.file.typeRead[ SEA3D.Actions.prototype.type ] = this.readActions; + this.file.typeRead[ SEA3D.FileInfo.prototype.type ] = this.readFileInfo; + this.file.typeRead[ SEA3D.Properties.prototype.type ] = this.readProperties; + + if ( this.config.dummys ) { + + this.file.typeRead[ SEA3D.Dummy.prototype.type ] = this.readDummy; + + } + + if ( this.config.scripts ) { + + this.file.typeRead[ SEA3D.ScriptURL.prototype.type ] = this.readScriptURL; + this.file.typeRead[ SEA3D.JavaScriptMethod.prototype.type ] = this.readJavaScriptMethod; + + } + + if ( this.config.lights ) { + + this.file.typeRead[ SEA3D.PointLight.prototype.type ] = this.readPointLight; + this.file.typeRead[ SEA3D.DirectionalLight.prototype.type ] = this.readDirectionalLight; + this.file.typeRead[ SEA3D.HemisphereLight.prototype.type ] = this.readHemisphereLight; + this.file.typeRead[ SEA3D.AmbientLight.prototype.type ] = this.readAmbientLight; + + } + + // UNIVERSAL + + this.file.typeRead[ SEA3D.JPEG.prototype.type ] = + this.file.typeRead[ SEA3D.JPEG_XR.prototype.type ] = + this.file.typeRead[ SEA3D.PNG.prototype.type ] = + this.file.typeRead[ SEA3D.GIF.prototype.type ] = this.readTexture; + this.file.typeRead[ SEA3D.MP3.prototype.type ] = this.readSound; + this.file.typeRead[ SEA3D.GLSL.prototype.type ] = this.readGLSL; + + // EXTENSIONS + + var i = THREE.SEA3D.EXTENSIONS_LOADER.length; + + while ( i -- ) { + + var loader = THREE.SEA3D.EXTENSIONS_LOADER[ i ]; + + if ( loader.setTypeRead ) loader.setTypeRead.call( this ); + + } + +}; + +THREE.SEA3D.prototype.load = function ( data ) { + + this.file = new SEA3D.File(); + this.file.scope = this; + this.file.config = this.config; + this.file.onProgress = this.onLoadProgress.bind( this ); + this.file.onCompleteObject = this.onCompleteObject.bind( this ); + this.file.onDownloadProgress = this.onDownloadProgress.bind( this ); + this.file.onParseProgress = this.onParseProgress.bind( this ); + this.file.onParseComplete = this.onParseComplete.bind( this ); + this.file.onError = this.onError.bind( this ); + this.file.onHead = this.onHead.bind( this ); + + this.file.onComplete = ( function ( e ) { + + if ( this.config.manager ) this.config.manager.add( this.domain ); + + this.onComplete.call( this, e ); + + } ).bind( this ); + + // SEA3D + + this.createDomain(); + + this.setTypeRead(); + + if ( data === undefined ) return; + + if ( typeof data === "string" ) this.file.load( data ); + else this.file.read( data ); + +}; diff --git a/three/jsutil/loaders/sea3d/o3dgc/SEA3DGC.js b/three/jsutil/loaders/sea3d/o3dgc/SEA3DGC.js new file mode 100644 index 000000000..062191c38 --- /dev/null +++ b/three/jsutil/loaders/sea3d/o3dgc/SEA3DGC.js @@ -0,0 +1,154 @@ +/** + * SEA3D - o3dgc + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +// +// Lossy Compression +// + +SEA3D.GeometryGC = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var i; + var attrib = data.readUShort(); + var uvIDs = [], jointID, weightID; + + this.isBig = ( attrib & 1 ) != 0; + + data.readVInt = this.isBig ? data.readUInt : data.readUShort; + + // Geometry Flags + // .. + // 1 isBig + // 2 groups + // 4 uv + // 8 tangent + // 16 colors + // 32 joints + // 64 morph + // 128 vertex-animation + // .. + + if ( attrib & 2 ) { + + this.groups = []; + + var numGroups = data.readUByte(), + groupOffset = 0; + + for ( i = 0; i < numGroups; i ++ ) { + + var groupLength = data.readVInt() * 3; + + this.groups.push( { + start: groupOffset, + count: groupLength, + } ); + + groupOffset += groupLength; + + } + + } else { + + this.groups = []; + + } + + if ( attrib & 4 ) { + + this.uv = []; + + var uvCount = data.readUByte(); + + for ( i = 0; i < uvCount; i ++ ) { + + uvIDs[ i ] = data.readUByte(); + + } + + } + + if ( attrib & 32 ) { + + jointID = data.readUByte(); + weightID = data.readUByte(); + + } + + var size = data.readUInt(); + var bytes = data.concat( data.position, size ); + + var bstream = new o3dgc.BinaryStream( bytes.buffer ); + + var decoder = new o3dgc.SC3DMCDecoder(); + var ifs = new o3dgc.IndexedFaceSet(); + + decoder.DecodeHeader( ifs, bstream ); + + var numIndexes = ifs.GetNCoordIndex(); + var numVertex = ifs.GetNCoord(); + + if ( ! this.groups.length ) this.groups.push( { start: 0, count: numIndexes * 3 } ); + + this.indexes = this.isBig ? new Uint32Array( numIndexes * 3 ) : new Uint16Array( numIndexes * 3 ); + this.vertex = new Float32Array( numVertex * 3 ); + + ifs.SetCoordIndex( this.indexes ); + ifs.SetCoord( this.vertex ); + + if ( ifs.GetNNormal() > 0 ) { + + this.normal = new Float32Array( numVertex * 3 ); + ifs.SetNormal( this.normal ); + + } + + for ( i = 0; i < uvIDs.length; i ++ ) { + + this.uv[ i ] = new Float32Array( numVertex * 2 ); + ifs.SetFloatAttribute( uvIDs[ i ], this.uv[ i ] ); + + } + + if ( jointID !== undefined ) { + + this.jointPerVertex = ifs.GetIntAttributeDim( jointID ); + + this.joint = new Uint16Array( numVertex * this.jointPerVertex ); + this.weight = new Float32Array( numVertex * this.jointPerVertex ); + + ifs.SetIntAttribute( jointID, this.joint ); + ifs.SetFloatAttribute( weightID, this.weight ); + + } + + // decode mesh + + decoder.DecodePlayload( ifs, bstream ); + +}; + +SEA3D.GeometryGC.prototype.type = "s3D"; + +// +// Extension +// + +THREE.SEA3D.EXTENSIONS_LOADER.push( { + + setTypeRead: function () { + + this.file.addClass( SEA3D.GeometryGC, true ); + + this.file.typeRead[ SEA3D.GeometryGC.prototype.type ] = this.readGeometryBuffer; + + } + +} ); diff --git a/three/jsutil/loaders/sea3d/physics/SEA3DAmmo.js b/three/jsutil/loaders/sea3d/physics/SEA3DAmmo.js new file mode 100644 index 000000000..22050e72f --- /dev/null +++ b/three/jsutil/loaders/sea3d/physics/SEA3DAmmo.js @@ -0,0 +1,409 @@ +/** _ _ _ _____ __ _______ ______ +* | |___| |_| |__ /__ | | | | _ | * * +* | / _ \ _| | __\ | | \ | _ | U _ +* |_\___/\__|_||_| _ |____/____ |__ \_|_ |_|_____| +* +* @author LoTh / http://3dflashlo.wordpress.com/ +* @author SUNAG / http://www.sunag.com.br/ +* @author Ammo.lab / https://github.com/lo-th/Ammo.lab/ +*/ + +'use strict'; + +SEA3D.AMMO = { + + world: null, + + rigidBodies: [], + rigidBodiesTarget: [], + rigidBodiesEnabled: [], + + constraints: [], + + vehicles: [], + vehiclesWheels: [], + + ACTIVE: 1, + ISLAND_SLEEPING: 2, + WANTS_DEACTIVATION: 3, + DISABLE_DEACTIVATION: 4, + DISABLE_SIMULATION: 5, + VERSION: 0.8, + + init: function ( gravity, worldScale, broadphase ) { + + gravity = gravity !== undefined ? gravity : - 90.8; + + this.worldScale = worldScale == undefined ? 1 : worldScale; + this.broadphase = broadphase == undefined ? 'bvt' : broadphase; + + this.solver = new Ammo.btSequentialImpulseConstraintSolver(); + this.collisionConfig = new Ammo.btDefaultCollisionConfiguration(); + this.dispatcher = new Ammo.btCollisionDispatcher( this.collisionConfig ); + + switch ( this.broadphase ) { + + case 'bvt': + + this.broadphase = new Ammo.btDbvtBroadphase(); + + break; + + case 'sap': + + this.broadphase = new Ammo.btAxisSweep3( + new Ammo.btVector3( - this.worldScale, - this.worldScale, - this.worldScale ), + new Ammo.btVector3( this.worldScale, this.worldScale, this.worldScale ), + 4096 + ); + + break; + + case 'simple': + + this.broadphase = new Ammo.btSimpleBroadphase(); + + break; + + } + + this.world = new Ammo.btDiscreteDynamicsWorld( this.dispatcher, this.broadphase, this.solver, this.collisionConfig ); + + this.setGravity( gravity ); + + console.log( "THREE.AMMO " + this.VERSION ); + + }, + + setGravity: function ( gravity ) { + + this.gravity = gravity; + + this.world.setGravity( new Ammo.btVector3( 0, gravity, 0 ) ); + + return this; + + }, + getGravity: function () { + + return this.gravity; + + }, + + setEnabledRigidBody: function ( rb, enabled ) { + + var index = this.rigidBodies.indexOf( rb ); + + if ( this.rigidBodiesEnabled[ index ] == enabled ) return; + + if ( enabled ) this.world.addRigidBody( rb ); + else this.world.removeRigidBody( rb ); + + this.rigidBodiesEnabled[ index ] = true; + + return this; + + }, + getEnabledRigidBody: function ( rb ) { + + return this.rigidBodiesEnabled[ this.rigidBodies.indexOf( rb ) ]; + + }, + addRigidBody: function ( rb, target, enabled ) { + + enabled = enabled !== undefined ? enabled : true; + + this.rigidBodies.push( rb ); + this.rigidBodiesTarget.push( target ); + this.rigidBodiesEnabled.push( false ); + + this.setEnabledRigidBody( rb, enabled ); + + return this; + + }, + removeRigidBody: function ( rb, destroy ) { + + var index = this.rigidBodies.indexOf( rb ); + + this.setEnabledRigidBody( rb, false ); + + this.rigidBodies.splice( index, 1 ); + this.rigidBodiesTarget.splice( index, 1 ); + this.rigidBodiesEnabled.splice( index, 1 ); + + if ( destroy ) Ammo.destroy( rb ); + + return this; + + }, + containsRigidBody: function ( rb ) { + + return this.rigidBodies.indexOf( rb ) > - 1; + + }, + + addConstraint: function ( ctrt, disableCollisionsBetweenBodies ) { + + disableCollisionsBetweenBodies = disableCollisionsBetweenBodies == undefined ? true : disableCollisionsBetweenBodies; + + this.constraints.push( ctrt ); + this.world.addConstraint( ctrt, disableCollisionsBetweenBodies ); + + return this; + + }, + removeConstraint: function ( ctrt, destroy ) { + + this.constraints.splice( this.constraints.indexOf( ctrt ), 1 ); + this.world.removeConstraint( ctrt ); + + if ( destroy ) Ammo.destroy( ctrt ); + + return this; + + }, + containsConstraint: function ( ctrt ) { + + return this.constraints.indexOf( rb ) > - 1; + + }, + + addVehicle: function ( vehicle, wheels ) { + + this.vehicles.push( vehicle ); + this.vehiclesWheels.push( wheels != undefined ? wheels : [] ); + + this.world.addAction( vehicle ); + + return this; + + }, + removeVehicle: function ( vehicle, destroy ) { + + var index = this.vehicles.indexOf( vehicle ); + + this.vehicles.splice( index, 1 ); + this.vehiclesWheels.splice( index, 1 ); + + this.world.removeAction( vehicle ); + + if ( destroy ) Ammo.destroy( vehicle ); + + return this; + + }, + containsVehicle: function ( vehicle ) { + + return this.vehicles.indexOf( vehicle ) > - 1; + + }, + + createTriangleMesh: function ( geometry, index, removeDuplicateVertices ) { + + index = index == undefined ? - 1 : index; + removeDuplicateVertices = removeDuplicateVertices == undefined ? false : removeDuplicateVertices; + + var mTriMesh = new Ammo.btTriangleMesh(); + + var v0 = new Ammo.btVector3( 0, 0, 0 ); + var v1 = new Ammo.btVector3( 0, 0, 0 ); + var v2 = new Ammo.btVector3( 0, 0, 0 ); + + var vertex = geometry.getAttribute( 'position' ).array; + var indexes = geometry.getIndex().array; + + var group = index >= 0 ? geometry.groups[ index ] : undefined, + start = group ? group.start : 0, + count = group ? group.count : indexes.length; + + var scale = 1 / this.worldScale; + + for ( var idx = start; idx < count; idx += 3 ) { + + var vx1 = indexes[ idx ] * 3, + vx2 = indexes[ idx + 1 ] * 3, + vx3 = indexes[ idx + 2 ] * 3; + + v0.setValue( vertex[ vx1 ] * scale, vertex[ vx1 + 1 ] * scale, vertex[ vx1 + 2 ] * scale ); + v1.setValue( vertex[ vx2 ] * scale, vertex[ vx2 + 1 ] * scale, vertex[ vx2 + 2 ] * scale ); + v2.setValue( vertex[ vx3 ] * scale, vertex[ vx3 + 1 ] * scale, vertex[ vx3 + 2 ] * scale ); + + mTriMesh.addTriangle( v0, v1, v2, removeDuplicateVertices ); + + } + + return mTriMesh; + + }, + createConvexHull: function ( geometry, index ) { + + index = index == undefined ? - 1 : index; + + var mConvexHull = new Ammo.btConvexHullShape(); + + var v0 = new Ammo.btVector3( 0, 0, 0 ); + + var vertex = geometry.getAttribute( 'position' ).array; + var indexes = geometry.getIndex().array; + + var group = index >= 0 ? geometry.groups[ index ] : undefined, + start = group ? group.start : 0, + count = group ? group.count : indexes.length; + + var scale = 1 / this.worldScale; + + for ( var idx = start; idx < count; idx += 3 ) { + + var vx1 = indexes[ idx ] * 3; + + var point = new Ammo.btVector3( + vertex[ vx1 ] * scale, vertex[ vx1 + 1 ] * scale, vertex[ vx1 + 2 ] * scale + ); + + mConvexHull.addPoint( point ); + + } + + return mConvexHull; + + }, + + getTargetByRigidBody: function ( rb ) { + + return this.rigidBodiesTarget[ this.rigidBodies.indexOf( rb ) ]; + + }, + getRigidBodyByTarget: function ( target ) { + + return this.rigidBodies[ this.rigidBodiesTarget.indexOf( target ) ]; + + }, + getTransformFromMatrix: function ( mtx ) { + + var transform = new Ammo.btTransform(); + + var pos = THREE.SEA3D.VECBUF.setFromMatrixPosition( mtx ); + transform.setOrigin( new Ammo.btVector3( pos.x, pos.y, pos.z ) ); + + var scl = THREE.SEA3D.VECBUF.setFromMatrixScale( mtx ); + mtx.scale( scl.set( 1 / scl.x, 1 / scl.y, 1 / scl.z ) ); + + var quat = new THREE.Quaternion().setFromRotationMatrix( mtx ); + + var q = new Ammo.btQuaternion(); + q.setValue( quat.x, quat.y, quat.z, quat.w ); + transform.setRotation( q ); + + Ammo.destroy( q ); + + return transform; + + }, + getMatrixFromTransform: function ( transform ) { + + var position = new THREE.Vector3(); + var quaternion = new THREE.Quaternion(); + var scale = new THREE.Vector3( 1, 1, 1 ); + + return function ( transform, matrix ) { + + matrix = matrix || new THREE.Matrix4(); + + var pos = transform.getOrigin(), + quat = transform.getRotation(); + + position.set( pos.x(), pos.y(), pos.z() ); + quaternion.set( quat.x(), quat.y(), quat.z(), quat.w() ); + + matrix.compose( position, quaternion, scale ); + + return matrix; + + }; + + }(), + + updateTargetTransform: function () { + + var matrix = new THREE.Matrix4(); + + var position = new THREE.Vector3(); + var quaternion = new THREE.Quaternion(); + var scale = new THREE.Vector3( 1, 1, 1 ); + + return function ( obj3d, transform, offset ) { + + var pos = transform.getOrigin(), + quat = transform.getRotation(); + + if ( offset ) { + + position.set( pos.x(), pos.y(), pos.z() ); + quaternion.set( quat.x(), quat.y(), quat.z(), quat.w() ); + + matrix.compose( position, quaternion, scale ); + + matrix.multiplyMatrices( matrix, offset ); + + obj3d.position.setFromMatrixPosition( matrix ); + obj3d.quaternion.setFromRotationMatrix( matrix ); + + } else { + + obj3d.position.set( pos.x(), pos.y(), pos.z() ); + obj3d.quaternion.set( quat.x(), quat.y(), quat.z(), quat.w() ); + + } + + return this; + + }; + + }(), + update: function ( delta, iteration, fixedDelta ) { + + this.world.stepSimulation( delta, iteration || 0, fixedDelta || ( 60 / 1000 ) ); + + var i, j; + + for ( i = 0; i < this.vehicles.length; i ++ ) { + + var vehicle = this.vehicles[ i ], + numWheels = vehicle.getNumWheels(), + wheels = this.vehiclesWheels[ i ]; + + for ( j = 0; j < numWheels; j ++ ) { + + vehicle.updateWheelTransform( j, true ); + + var wheelsTransform = vehicle.getWheelTransformWS( j ), + wheelTarget = wheels[ j ]; + + if ( wheelTarget ) { + + this.updateTargetTransform( wheelTarget, wheelsTransform, wheelTarget.physics ? wheelTarget.physics.offset : null ); + + } + + } + + } + + for ( i = 0; i < this.rigidBodies.length; i ++ ) { + + var rb = this.rigidBodies[ i ], + target = this.rigidBodiesTarget[ i ]; + + if ( target && rb.isActive() ) { + + this.updateTargetTransform( target, rb.getWorldTransform(), target.physics ? target.physics.offset : null ); + + } + + } + + return this; + + } +}; diff --git a/three/jsutil/loaders/sea3d/physics/SEA3DAmmoLoader.js b/three/jsutil/loaders/sea3d/physics/SEA3DAmmoLoader.js new file mode 100644 index 000000000..9239e109a --- /dev/null +++ b/three/jsutil/loaders/sea3d/physics/SEA3DAmmoLoader.js @@ -0,0 +1,590 @@ +/** + * SEA3D+AMMO for Three.JS + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +THREE.SEA3D.prototype.toAmmoVec3 = function ( v ) { + + return new Ammo.btVector3( v.x, v.y, v.z ); + +}; + +// +// Sphere +// + +THREE.SEA3D.prototype.readSphere = function ( sea ) { + + var shape = new Ammo.btSphereShape( sea.radius ); + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Box +// + +THREE.SEA3D.prototype.readBox = function ( sea ) { + + var shape = new Ammo.btBoxShape( new Ammo.btVector3( sea.width * .5, sea.height * .5, sea.depth * .5 ) ); + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Cone +// + +THREE.SEA3D.prototype.readCone = function ( sea ) { + + var shape = new Ammo.btConeShape( sea.radius, sea.height ); + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Cylinder +// + +THREE.SEA3D.prototype.readCylinder = function ( sea ) { + + var shape = new Ammo.btCylinderShape( new Ammo.btVector3( sea.height, sea.radius, sea.radius ) ); + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Capsule +// + +THREE.SEA3D.prototype.readCapsule = function ( sea ) { + + var shape = new Ammo.btCapsuleShape( sea.radius, sea.height ); + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Convex Geometry +// + +THREE.SEA3D.prototype.readConvexGeometry = function ( sea ) { + + if ( this.config.convexHull ) { + + var shape = SEA3D.AMMO.createConvexHull( sea.geometry.tag, sea.subGeometryIndex ); + + } else { + + var triMesh = SEA3D.AMMO.createTriangleMesh( sea.geometry.tag, sea.subGeometryIndex ); + + var shape = new Ammo.btConvexTriangleMeshShape( triMesh, true ); + + } + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Triangle Geometry +// + +THREE.SEA3D.prototype.readTriangleGeometry = function ( sea ) { + + var triMesh = SEA3D.AMMO.createTriangleMesh( sea.geometry.tag, sea.subGeometryIndex ); + + var shape = new Ammo.btBvhTriangleMeshShape( triMesh, true, true ); + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Compound +// + +THREE.SEA3D.prototype.readCompound = function ( sea ) { + + var shape = new Ammo.btCompoundShape(); + + for ( var i = 0; i < sea.compounds.length; i ++ ) { + + var compound = sea.compounds[ i ]; + + THREE.SEA3D.MTXBUF.elements = compound.transform; + + var transform = SEA3D.AMMO.getTransformFromMatrix( THREE.SEA3D.MTXBUF ); + + shape.addChildShape( transform, compound.shape.tag ); + + } + + this.domain.shapes = this.shapes = this.shapes || []; + this.shapes.push( this.objects[ "shpe/" + sea.name ] = sea.tag = shape ); + +}; + +// +// Rigid Body Base +// + +THREE.SEA3D.prototype.readRigidBodyBase = function ( sea ) { + + var shape = sea.shape.tag, + transform, target; + + if ( sea.target ) { + + target = sea.target.tag; + + target.physics = { enabled: true }; + target.updateMatrix(); + + transform = SEA3D.AMMO.getTransformFromMatrix( sea.target.tag.matrix ); + + } else { + + THREE.SEA3D.MTXBUF.fromArray( sea.transform ); + + transform = SEA3D.AMMO.getTransformFromMatrix( THREE.SEA3D.MTXBUF ); + + } + + var motionState = new Ammo.btDefaultMotionState( transform ); + var localInertia = new Ammo.btVector3( 0, 0, 0 ); + + shape.calculateLocalInertia( sea.mass, localInertia ); + + var info = new Ammo.btRigidBodyConstructionInfo( sea.mass, motionState, shape, localInertia ); + info.set_m_friction( sea.friction ); + info.set_m_restitution( sea.restitution ); + info.set_m_linearDamping( sea.linearDamping ); + info.set_m_angularDamping( sea.angularDamping ); + + var rb = new Ammo.btRigidBody( info ); + + if ( target ) { + + target.physics.rigidBody = rb; + + if ( sea.offset ) { + + var offset = new THREE.Matrix4(); + offset.fromArray( sea.offset ); + + target.physics.offset = offset; + + } + + } + + Ammo.destroy( info ); + + this.domain.rigidBodies = this.rigidBodies = this.rigidBodies || []; + this.rigidBodies.push( this.objects[ "rb/" + sea.name ] = sea.tag = rb ); + + return rb; + +}; + +// +// Rigid Body +// + +THREE.SEA3D.prototype.readRigidBody = function ( sea ) { + + var rb = this.readRigidBodyBase( sea ); + + SEA3D.AMMO.addRigidBody( rb, sea.target ? sea.target.tag : undefined, this.config.enabledPhysics ); + +}; + +// +// Car Controller +// + +THREE.SEA3D.prototype.readCarController = function ( sea ) { + + var body = this.readRigidBodyBase( sea ); + + body.setActivationState( SEA3D.AMMO.DISABLE_DEACTIVATION ); + + // Car + + var vehicleRayCaster = new Ammo.btDefaultVehicleRaycaster( SEA3D.AMMO.world ); + + var tuning = new Ammo.btVehicleTuning(); + + tuning.set_m_suspensionStiffness( sea.suspensionStiffness ); + tuning.set_m_suspensionDamping( sea.suspensionDamping ); + tuning.set_m_suspensionCompression( sea.suspensionCompression ); + tuning.set_m_maxSuspensionTravelCm( sea.maxSuspensionTravelCm ); + tuning.set_m_maxSuspensionForce( sea.maxSuspensionForce ); + tuning.set_m_frictionSlip( sea.frictionSlip ); + + var vehicle = new Ammo.btRaycastVehicle( tuning, body, vehicleRayCaster ), + wheels = []; + + vehicle.setCoordinateSystem( 0, 1, 2 ); + + for ( var i = 0; i < sea.wheel.length; i ++ ) { + + var wheel = sea.wheel[ i ]; + + var wheelInfo = vehicle.addWheel( + this.toAmmoVec3( wheel.pos ), + this.toAmmoVec3( wheel.dir ), + this.toAmmoVec3( wheel.axle ), + wheel.suspensionRestLength, + wheel.radius, + tuning, + wheel.isFront + ); + + var target = wheels[ i ] = wheel.target ? wheel.target.tag : undefined; + + if ( target ) { + + target.physics = { enabled: true, rigidBody: wheelInfo }; + + if ( wheel.offset ) { + + var offset = new THREE.Matrix4(); + offset.fromArray( wheel.offset ); + + target.physics.offset = offset; + + } + + if ( target.parent ) { + + target.parent.remove( target ); + + } + + if ( this.container ) { + + this.container.add( target ); + + } + + } + + wheelInfo.set_m_suspensionStiffness( sea.suspensionStiffness ); + wheelInfo.set_m_wheelsDampingRelaxation( sea.dampingRelaxation ); + wheelInfo.set_m_wheelsDampingCompression( sea.dampingCompression ); + wheelInfo.set_m_frictionSlip( sea.frictionSlip ); + + } + + SEA3D.AMMO.addVehicle( vehicle, wheels ); + SEA3D.AMMO.addRigidBody( body, sea.target ? sea.target.tag : undefined, this.config.enabledPhysics ); + + this.domain.vehicles = this.vehicles = this.vehicles || []; + this.vehicles.push( this.objects[ "vhc/" + sea.name ] = sea.tag = vehicle ); + +}; + +// +// P2P Constraint +// + +THREE.SEA3D.prototype.readP2PConstraint = function ( sea ) { + + var ctrt; + + if ( sea.targetB ) { + + ctrt = new Ammo.btPoint2PointConstraint( + sea.targetA.tag, + sea.targetB.tag, + this.toAmmoVec3( sea.pointA ), + this.toAmmoVec3( sea.pointB ) + ); + + } else { + + ctrt = new Ammo.btPoint2PointConstraint( + sea.targetA.tag, + this.toAmmoVec3( sea.pointA ) + ); + + } + + SEA3D.AMMO.addConstraint( ctrt ); + + this.domain.constraints = this.constraints = this.constraints || []; + this.constraints.push( this.objects[ "ctnt/" + sea.name ] = sea.tag = ctrt ); + +}; + +// +// Hinge Constraint +// + +THREE.SEA3D.prototype.readHingeConstraint = function ( sea ) { + + var ctrt; + + if ( sea.targetB ) { + + ctrt = new Ammo.btHingeConstraint( + sea.targetA.tag, + sea.targetB.tag, + this.toAmmoVec3( sea.pointA ), + this.toAmmoVec3( sea.pointB ), + this.toAmmoVec3( sea.axisA ), + this.toAmmoVec3( sea.axisB ), + false + ); + + } else { + + ctrt = new Ammo.btHingeConstraint( + sea.targetA.tag, + this.toAmmoVec3( sea.pointA ), + this.toAmmoVec3( sea.axisA ), + false + ); + + } + + if ( sea.limit ) { + + ctrt.setLimit( sea.limit.low, sea.limit.high, sea.limit.softness, sea.limit.biasFactor, sea.limit.relaxationFactor ); + + } + + if ( sea.angularMotor ) { + + ctrt.enableAngularMotor( true, sea.angularMotor.velocity, sea.angularMotor.impulse ); + + } + + SEA3D.AMMO.addConstraint( ctrt ); + + this.domain.constraints = this.constraints = this.constraints || []; + this.constraints.push( this.objects[ "ctnt/" + sea.name ] = sea.tag = ctrt ); + +}; + +// +// Cone Twist Constraint +// + +THREE.SEA3D.prototype.readConeTwistConstraint = function ( sea ) { + + var ctrt; + + if ( sea.targetB ) { + + ctrt = new Ammo.btConeTwistConstraint( + sea.targetA.tag, + sea.targetB.tag, + this.toAmmoVec3( sea.pointA ), + this.toAmmoVec3( sea.pointB ), + false + ); + + } else { + + ctrt = new Ammo.btConeTwistConstraint( + sea.targetA.tag, + this.toAmmoVec3( sea.pointA ), + false + ); + + } + + SEA3D.AMMO.addConstraint( ctrt ); + + this.domain.constraints = this.constraints = this.constraints || []; + this.constraints.push( this.objects[ "ctnt/" + sea.name ] = sea.tag = ctrt ); + +}; + +// +// Domain +// + +THREE.SEA3D.Domain.prototype.enabledPhysics = function ( enabled ) { + + var i = this.rigidBodies ? this.rigidBodies.length : 0; + + while ( i -- ) { + + SEA3D.AMMO.setEnabledRigidBody( this.rigidBodies[ i ], enabled ); + + } + +}; + +THREE.SEA3D.Domain.prototype.applyContainerTransform = function () { + + this.container.updateMatrix(); + + var matrix = this.container.matrix.clone(); + + this.container.position.set( 0, 0, 0 ); + this.container.quaternion.set( 0, 0, 0, 1 ); + this.container.scale.set( 1, 1, 1 ); + + this.applyTransform( matrix ); + +}; + +THREE.SEA3D.Domain.prototype.applyTransform = function ( matrix ) { + + var mtx = THREE.SEA3D.MTXBUF, vec = THREE.SEA3D.VECBUF; + + var i = this.rigidBodies ? this.rigidBodies.length : 0, + childs = this.container ? this.container.children : [], + targets = []; + + while ( i -- ) { + + var rb = this.rigidBodies[ i ], + target = SEA3D.AMMO.getTargetByRigidBody( rb ), + transform = rb.getWorldTransform(), + transformMatrix = SEA3D.AMMO.getMatrixFromTransform( transform ); + + transformMatrix.multiplyMatrices( transformMatrix, matrix ); + + transform = SEA3D.AMMO.getTransformFromMatrix( transformMatrix ); + + rb.setWorldTransform( transform ); + + if ( target ) targets.push( target ); + + } + + for ( i = 0; i < childs.length; i ++ ) { + + var obj3d = childs[ i ]; + + if ( targets.indexOf( obj3d ) > - 1 ) continue; + + obj3d.updateMatrix(); + + mtx.copy( obj3d.matrix ); + + mtx.multiplyMatrices( matrix, mtx ); + + obj3d.position.setFromMatrixPosition( mtx ); + obj3d.scale.setFromMatrixScale( mtx ); + + // ignore rotation scale + + mtx.scale( vec.set( 1 / obj3d.scale.x, 1 / obj3d.scale.y, 1 / obj3d.scale.z ) ); + obj3d.quaternion.setFromRotationMatrix( mtx ); + + } + +}; + +// +// Extension +// + +THREE.SEA3D.Domain.prototype.getShape = THREE.SEA3D.prototype.getShape = function ( name ) { + + return this.objects[ "shpe/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getRigidBody = THREE.SEA3D.prototype.getRigidBody = function ( name ) { + + return this.objects[ "rb/" + name ]; + +}; + +THREE.SEA3D.Domain.prototype.getConstraint = THREE.SEA3D.prototype.getConstraint = function ( name ) { + + return this.objects[ "ctnt/" + name ]; + +}; + +THREE.SEA3D.EXTENSIONS_LOADER.push( { + + parse: function () { + + delete this.shapes; + delete this.rigidBodies; + delete this.vehicles; + delete this.constraints; + + }, + + setTypeRead: function () { + + // CONFIG + + this.config.physics = this.config.physics !== undefined ? this.config.physics : true; + this.config.convexHull = this.config.convexHull !== undefined ? this.config.convexHull : true; + this.config.enabledPhysics = this.config.enabledPhysics !== undefined ? this.config.enabledPhysics : true; + + if ( this.config.physics ) { + + // SHAPES + + this.file.typeRead[ SEA3D.Sphere.prototype.type ] = this.readSphere; + this.file.typeRead[ SEA3D.Box.prototype.type ] = this.readBox; + this.file.typeRead[ SEA3D.Capsule.prototype.type ] = this.readCapsule; + this.file.typeRead[ SEA3D.Cone.prototype.type ] = this.readCone; + this.file.typeRead[ SEA3D.Cylinder.prototype.type ] = this.readCylinder; + this.file.typeRead[ SEA3D.ConvexGeometry.prototype.type ] = this.readConvexGeometry; + this.file.typeRead[ SEA3D.TriangleGeometry.prototype.type ] = this.readTriangleGeometry; + this.file.typeRead[ SEA3D.Compound.prototype.type ] = this.readCompound; + + // CONSTRAINTS + + this.file.typeRead[ SEA3D.P2PConstraint.prototype.type ] = this.readP2PConstraint; + this.file.typeRead[ SEA3D.HingeConstraint.prototype.type ] = this.readHingeConstraint; + this.file.typeRead[ SEA3D.ConeTwistConstraint.prototype.type ] = this.readConeTwistConstraint; + + // PHYSICS + + this.file.typeRead[ SEA3D.RigidBody.prototype.type ] = this.readRigidBody; + this.file.typeRead[ SEA3D.CarController.prototype.type ] = this.readCarController; + + } + + } +} ); + +THREE.SEA3D.EXTENSIONS_DOMAIN.push( { + + dispose: function () { + + var i; + + i = this.rigidBodies ? this.rigidBodies.length : 0; + while ( i -- ) SEA3D.AMMO.removeRigidBody( this.rigidBodies[ i ], true ); + + i = this.vehicles ? this.vehicles.length : 0; + while ( i -- ) SEA3D.AMMO.removeVehicle( this.vehicles[ i ], true ); + + i = this.constraints ? this.constraints.length : 0; + while ( i -- ) SEA3D.AMMO.removeConstraint( this.constraints[ i ], true ); + + i = this.shapes ? this.shapes.length : 0; + while ( i -- ) Ammo.destroy( this.shapes[ i ] ); + + } + +} ); diff --git a/three/jsutil/loaders/sea3d/physics/SEA3DRigidBody.js b/three/jsutil/loaders/sea3d/physics/SEA3DRigidBody.js new file mode 100644 index 000000000..c4d55a892 --- /dev/null +++ b/three/jsutil/loaders/sea3d/physics/SEA3DRigidBody.js @@ -0,0 +1,442 @@ +/** + * SEA3D - Rigid Body + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +// +// Sphere +// + +SEA3D.Sphere = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.radius = data.readFloat(); + +}; + +SEA3D.Sphere.prototype.type = "sph"; + +// +// Box +// + +SEA3D.Box = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.width = data.readFloat(); + this.height = data.readFloat(); + this.depth = data.readFloat(); + +}; + +SEA3D.Box.prototype.type = "box"; + +// +// Cone +// + +SEA3D.Cone = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.radius = data.readFloat(); + this.height = data.readFloat(); + +}; + +SEA3D.Cone.prototype.type = "cone"; + +// +// Capsule +// + +SEA3D.Capsule = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.radius = data.readFloat(); + this.height = data.readFloat(); + +}; + +SEA3D.Capsule.prototype.type = "cap"; + +// +// Cylinder +// + +SEA3D.Cylinder = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.radius = data.readFloat(); + this.height = data.readFloat(); + +}; + +SEA3D.Cylinder.prototype.type = "cyl"; + +// +// Convex Geometry +// + +SEA3D.ConvexGeometry = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.geometry = sea3d.getObject( data.readUInt() ); + this.subGeometryIndex = data.readUByte(); + +}; + +SEA3D.ConvexGeometry.prototype.type = "gs"; + +// +// Triangle Geometry +// + +SEA3D.TriangleGeometry = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.geometry = sea3d.getObject( data.readUInt() ); + this.subGeometryIndex = data.readUByte(); + +}; + +SEA3D.TriangleGeometry.prototype.type = "sgs"; + +// +// Compound +// + +SEA3D.Compound = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.compounds = []; + + var count = data.readUByte(); + + for ( var i = 0; i < count; i ++ ) { + + this.compounds.push( { + shape: sea3d.getObject( data.readUInt() ), + transform: data.readMatrix() + } ); + + } + +}; + +SEA3D.Compound.prototype.type = "cmps"; + +// +// Physics +// + +SEA3D.Physics = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.attrib = data.readUShort(); + + this.shape = sea3d.getObject( data.readUInt() ); + + if ( this.attrib & 1 ) this.target = sea3d.getObject( data.readUInt() ); + else this.transform = data.readMatrix(); + + if ( this.attrib & 2 ) this.offset = data.readMatrix(); + + if ( this.attrib & 4 ) this.scripts = data.readScriptList( sea3d ); + + if ( this.attrib & 16 ) this.attributes = sea3d.getObject( data.readUInt() ); + +}; + +SEA3D.Physics.prototype.readTag = function ( kind, data, size ) { + +}; + +// +// Rigidy Body Base +// + +SEA3D.RigidBodyBase = function ( name, data, sea3d ) { + + SEA3D.Physics.call( this, name, data, sea3d ); + + if ( this.attrib & 32 ) { + + this.linearDamping = data.readFloat(); + this.angularDamping = data.readFloat(); + + } else { + + this.linearDamping = 0; + this.angularDamping = 0; + + } + + this.mass = data.readFloat(); + this.friction = data.readFloat(); + this.restitution = data.readFloat(); + +}; + +SEA3D.RigidBodyBase.prototype = Object.create( SEA3D.Physics.prototype ); +SEA3D.RigidBodyBase.prototype.constructor = SEA3D.RigidBodyBase; + +// +// Rigidy Body +// + +SEA3D.RigidBody = function ( name, data, sea3d ) { + + SEA3D.RigidBodyBase.call( this, name, data, sea3d ); + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.RigidBody.prototype = Object.create( SEA3D.RigidBodyBase.prototype ); +SEA3D.RigidBody.prototype.constructor = SEA3D.RigidBody; + +SEA3D.RigidBody.prototype.type = "rb"; + +// +// Car Controller +// + +SEA3D.CarController = function ( name, data, sea3d ) { + + SEA3D.RigidBodyBase.call( this, name, data, sea3d ); + + this.suspensionStiffness = data.readFloat(); + this.suspensionCompression = data.readFloat(); + this.suspensionDamping = data.readFloat(); + this.maxSuspensionTravelCm = data.readFloat(); + this.frictionSlip = data.readFloat(); + this.maxSuspensionForce = data.readFloat(); + + this.dampingCompression = data.readFloat(); + this.dampingRelaxation = data.readFloat(); + + var count = data.readUByte(); + + this.wheel = []; + + for ( var i = 0; i < count; i ++ ) { + + this.wheel[ i ] = new SEA3D.CarController.Wheel( data, sea3d ); + + } + + data.readTags( this.readTag.bind( this ) ); + +}; + +SEA3D.CarController.Wheel = function ( data, sea3d ) { + + this.data = data; + this.sea3d = sea3d; + + this.attrib = data.readUShort(); + + this.isFront = ( this.attrib & 1 ) != 0; + + if ( this.attrib & 2 ) { + + this.target = sea3d.getObject( data.readUInt() ); + + } + + if ( this.attrib & 4 ) { + + this.offset = data.readMatrix(); + + } + + this.pos = data.readVector3(); + this.dir = data.readVector3(); + this.axle = data.readVector3(); + + this.radius = data.readFloat(); + this.suspensionRestLength = data.readFloat(); + +}; + +SEA3D.CarController.prototype = Object.create( SEA3D.RigidBodyBase.prototype ); +SEA3D.CarController.prototype.constructor = SEA3D.CarController; + +SEA3D.CarController.prototype.type = "carc"; + +// +// Constraints +// + +SEA3D.Constraints = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.attrib = data.readUShort(); + + this.disableCollisionsBetweenBodies = this.attrib & 1 != 0; + + this.targetA = sea3d.getObject( data.readUInt() ); + this.pointA = data.readVector3(); + + if ( this.attrib & 2 ) { + + this.targetB = sea3d.getObject( data.readUInt() ); + this.pointB = data.readVector3(); + + } + +}; + +// +// P2P Constraint +// + +SEA3D.P2PConstraint = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + SEA3D.Constraints.call( this, name, data, sea3d ); + +}; + +SEA3D.P2PConstraint.prototype = Object.create( SEA3D.Constraints.prototype ); +SEA3D.P2PConstraint.prototype.constructor = SEA3D.P2PConstraint; + +SEA3D.P2PConstraint.prototype.type = "p2pc"; + +// +// Hinge Constraint +// + +SEA3D.HingeConstraint = function ( name, data, sea3d ) { + + SEA3D.Constraints.call( this, name, data, sea3d ); + + this.axisA = data.readVector3(); + + if ( this.attrib & 1 ) { + + this.axisB = data.readVector3(); + + } + + if ( this.attrib & 4 ) { + + this.limit = { + low: data.readFloat(), + high: data.readFloat(), + softness: data.readFloat(), + biasFactor: data.readFloat(), + relaxationFactor: data.readFloat() + }; + + } + + if ( this.attrib & 8 ) { + + this.angularMotor = { + velocity: data.readFloat(), + impulse: data.readFloat() + }; + + } + +}; + +SEA3D.HingeConstraint.prototype = Object.create( SEA3D.Constraints.prototype ); +SEA3D.HingeConstraint.prototype.constructor = SEA3D.HingeConstraint; + +SEA3D.HingeConstraint.prototype.type = "hnec"; + +// +// Cone Twist Constraint +// + +SEA3D.ConeTwistConstraint = function ( name, data, sea3d ) { + + SEA3D.Constraints.call( this, name, data, sea3d ); + + this.axisA = data.readVector3(); + + if ( this.attrib & 1 ) { + + this.axisB = data.readVector3(); + + } + + if ( this.attrib & 4 ) { + + this.limit = { + swingSpan1: data.readFloat(), + swingSpan2: data.readFloat(), + twistSpan: data.readFloat(), + softness: data.readFloat(), + biasFactor: data.readFloat(), + relaxationFactor: data.readFloat() + }; + + } + +}; + +SEA3D.ConeTwistConstraint.prototype = Object.create( SEA3D.Constraints.prototype ); +SEA3D.ConeTwistConstraint.prototype.constructor = SEA3D.ConeTwistConstraint; + +SEA3D.ConeTwistConstraint.prototype.type = "ctwc"; + +// +// Extension +// + +SEA3D.File.setExtension( function () { + + // PHYSICS + this.addClass( SEA3D.Sphere ); + this.addClass( SEA3D.Box ); + this.addClass( SEA3D.Cone ); + this.addClass( SEA3D.Capsule ); + this.addClass( SEA3D.Cylinder ); + this.addClass( SEA3D.ConvexGeometry ); + this.addClass( SEA3D.TriangleGeometry ); + this.addClass( SEA3D.Compound ); + this.addClass( SEA3D.RigidBody ); + this.addClass( SEA3D.P2PConstraint ); + this.addClass( SEA3D.HingeConstraint ); + this.addClass( SEA3D.ConeTwistConstraint ); + this.addClass( SEA3D.CarController ); + +} ); diff --git a/three/jsutil/math/ColorConverter.js b/three/jsutil/math/ColorConverter.js new file mode 100644 index 000000000..15dd84e76 --- /dev/null +++ b/three/jsutil/math/ColorConverter.js @@ -0,0 +1,88 @@ +/** + * @author bhouston / http://exocortex.com/ + * @author zz85 / http://github.com/zz85 + */ + +THREE.ColorConverter = { + + setHSV: function ( color, h, s, v ) { + + // https://gist.github.com/xpansive/1337890#file-index-js + + h = THREE.Math.euclideanModulo( h, 1 ); + s = THREE.Math.clamp( s, 0, 1 ); + v = THREE.Math.clamp( v, 0, 1 ); + + return color.setHSL( h, ( s * v ) / ( ( h = ( 2 - s ) * v ) < 1 ? h : ( 2 - h ) ), h * 0.5 ); + + }, + + getHSV: function() { + + var hsl = {}; + + return function getHSV( color, target ) { + + if ( target === undefined ) { + + console.warn( 'THREE.ColorConverter: .getHSV() target is now required' ); + target = { h: 0, s: 0, l: 0 }; + + } + + color.getHSL( hsl ); + + // based on https://gist.github.com/xpansive/1337890#file-index-js + hsl.s *= ( hsl.l < 0.5 ) ? hsl.l : ( 1 - hsl.l ); + + target.h = hsl.h; + target.s = 2 * hsl.s / ( hsl.l + hsl.s ); + target.v = hsl.l + hsl.s; + + return target; + + }; + + }(), + + // where c, m, y, k is between 0 and 1 + + setCMYK: function ( color, c, m, y, k ) { + + var r = ( 1 - c ) * ( 1 - k ); + var g = ( 1 - m ) * ( 1 - k ); + var b = ( 1 - y ) * ( 1 - k ); + + return color.setRGB( r, g, b ); + + }, + + getCMYK: function ( color, target ) { + + if ( target === undefined ) { + + console.warn( 'THREE.ColorConverter: .getCMYK() target is now required' ); + target = { c: 0, m: 0, y: 0, k:0 }; + + } + + var r = color.r; + var g = color.g; + var b = color.b; + + var k = 1 - Math.max( r, g, b ); + var c = ( 1 - r - k ) / ( 1 - k ); + var m = ( 1 - g - k ) / ( 1 - k ); + var y = ( 1 - b - k ) / ( 1 - k ); + + target.c = c; + target.m = m; + target.y = y; + target.k = k; + + return target; + + } + + +}; diff --git a/three/jsutil/math/Lut.js b/three/jsutil/math/Lut.js new file mode 100644 index 000000000..261e3f6aa --- /dev/null +++ b/three/jsutil/math/Lut.js @@ -0,0 +1,496 @@ +/** + * @author daron1337 / http://daron1337.github.io/ + */ + +THREE.Lut = function ( colormap, numberofcolors ) { + + this.lut = []; + this.map = THREE.ColorMapKeywords[ colormap ]; + this.n = numberofcolors; + this.mapname = colormap; + + var step = 1.0 / this.n; + + for ( var i = 0; i <= 1; i += step ) { + + for ( var j = 0; j < this.map.length - 1; j ++ ) { + + if ( i >= this.map[ j ][ 0 ] && i < this.map[ j + 1 ][ 0 ] ) { + + var min = this.map[ j ][ 0 ]; + var max = this.map[ j + 1 ][ 0 ]; + + var minColor = new THREE.Color( 0xffffff ).setHex( this.map[ j ][ 1 ] ); + var maxColor = new THREE.Color( 0xffffff ).setHex( this.map[ j + 1 ][ 1 ] ); + + var color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) ); + + this.lut.push( color ); + + } + + } + + } + + return this.set( this ); + +}; + +THREE.Lut.prototype = { + + constructor: THREE.Lut, + + lut: [], map: [], mapname: 'rainbow', n: 256, minV: 0, maxV: 1, legend: null, + + set: function ( value ) { + + if ( value instanceof THREE.Lut ) { + + this.copy( value ); + + } + + return this; + + }, + + setMin: function ( min ) { + + this.minV = min; + + return this; + + }, + + setMax: function ( max ) { + + this.maxV = max; + + return this; + + }, + + changeNumberOfColors: function ( numberofcolors ) { + + this.n = numberofcolors; + + return new THREE.Lut( this.mapname, this.n ); + + }, + + changeColorMap: function ( colormap ) { + + this.mapname = colormap; + + return new THREE.Lut( this.mapname, this.n ); + + }, + + copy: function ( lut ) { + + this.lut = lut.lut; + this.mapname = lut.mapname; + this.map = lut.map; + this.n = lut.n; + this.minV = lut.minV; + this.maxV = lut.maxV; + + return this; + + }, + + getColor: function ( alpha ) { + + if ( alpha <= this.minV ) { + + alpha = this.minV; + + } else if ( alpha >= this.maxV ) { + + alpha = this.maxV; + + } + + alpha = ( alpha - this.minV ) / ( this.maxV - this.minV ); + + var colorPosition = Math.round( alpha * this.n ); + colorPosition == this.n ? colorPosition -= 1 : colorPosition; + + return this.lut[ colorPosition ]; + + }, + + addColorMap: function ( colormapName, arrayOfColors ) { + + THREE.ColorMapKeywords[ colormapName ] = arrayOfColors; + + }, + + setLegendOn: function ( parameters ) { + + if ( parameters === undefined ) { + + parameters = {}; + + } + + this.legend = {}; + + this.legend.layout = parameters.hasOwnProperty( 'layout' ) ? parameters[ 'layout' ] : 'vertical'; + + this.legend.position = parameters.hasOwnProperty( 'position' ) ? parameters[ 'position' ] : { 'x': 4, 'y': 0, 'z': 0 }; + + this.legend.dimensions = parameters.hasOwnProperty( 'dimensions' ) ? parameters[ 'dimensions' ] : { 'width': 0.5, 'height': 3 }; + + this.legend.canvas = document.createElement( 'canvas' ); + + this.legend.canvas.setAttribute( 'id', 'legend' ); + this.legend.canvas.setAttribute( 'hidden', true ); + + document.body.appendChild( this.legend.canvas ); + + this.legend.ctx = this.legend.canvas.getContext( '2d' ); + + this.legend.canvas.setAttribute( 'width', 1 ); + this.legend.canvas.setAttribute( 'height', this.n ); + + this.legend.texture = new THREE.Texture( this.legend.canvas ); + + var imageData = this.legend.ctx.getImageData( 0, 0, 1, this.n ); + + var data = imageData.data; + + this.map = THREE.ColorMapKeywords[ this.mapname ]; + + var k = 0; + + var step = 1.0 / this.n; + + for ( var i = 1; i >= 0; i -= step ) { + + for ( var j = this.map.length - 1; j >= 0; j -- ) { + + if ( i < this.map[ j ][ 0 ] && i >= this.map[ j - 1 ][ 0 ] ) { + + var min = this.map[ j - 1 ][ 0 ]; + var max = this.map[ j ][ 0 ]; + + var minColor = new THREE.Color( 0xffffff ).setHex( this.map[ j - 1 ][ 1 ] ); + var maxColor = new THREE.Color( 0xffffff ).setHex( this.map[ j ][ 1 ] ); + + var color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) ); + + data[ k * 4 ] = Math.round( color.r * 255 ); + data[ k * 4 + 1 ] = Math.round( color.g * 255 ); + data[ k * 4 + 2 ] = Math.round( color.b * 255 ); + data[ k * 4 + 3 ] = 255; + + k += 1; + + } + + } + + } + + this.legend.ctx.putImageData( imageData, 0, 0 ); + this.legend.texture.needsUpdate = true; + + this.legend.legendGeometry = new THREE.PlaneBufferGeometry( this.legend.dimensions.width, this.legend.dimensions.height ); + this.legend.legendMaterial = new THREE.MeshBasicMaterial( { map: this.legend.texture, side: THREE.DoubleSide } ); + + this.legend.mesh = new THREE.Mesh( this.legend.legendGeometry, this.legend.legendMaterial ); + + if ( this.legend.layout == 'horizontal' ) { + + this.legend.mesh.rotation.z = - 90 * ( Math.PI / 180 ); + + } + + this.legend.mesh.position.copy( this.legend.position ); + + return this.legend.mesh; + + }, + + setLegendOff: function () { + + this.legend = null; + + return this.legend; + + }, + + setLegendLayout: function ( layout ) { + + if ( ! this.legend ) { + + return false; + + } + + if ( this.legend.layout == layout ) { + + return false; + + } + + if ( layout != 'horizontal' && layout != 'vertical' ) { + + return false; + + } + + this.layout = layout; + + if ( layout == 'horizontal' ) { + + this.legend.mesh.rotation.z = 90 * ( Math.PI / 180 ); + + } + + if ( layout == 'vertical' ) { + + this.legend.mesh.rotation.z = - 90 * ( Math.PI / 180 ); + + } + + return this.legend.mesh; + + }, + + setLegendPosition: function ( position ) { + + this.legend.position = new THREE.Vector3( position.x, position.y, position.z ); + + return this.legend; + + }, + + setLegendLabels: function ( parameters, callback ) { + + if ( ! this.legend ) { + + return false; + + } + + if ( typeof parameters === 'function' ) { + + callback = parameters; + + } + + if ( parameters === undefined ) { + + parameters = {}; + + } + + this.legend.labels = {}; + + this.legend.labels.fontsize = parameters.hasOwnProperty( 'fontsize' ) ? parameters[ 'fontsize' ] : 24; + + this.legend.labels.fontface = parameters.hasOwnProperty( 'fontface' ) ? parameters[ 'fontface' ] : 'Arial'; + + this.legend.labels.title = parameters.hasOwnProperty( 'title' ) ? parameters[ 'title' ] : ''; + + this.legend.labels.um = parameters.hasOwnProperty( 'um' ) ? ' [ ' + parameters[ 'um' ] + ' ]' : ''; + + this.legend.labels.ticks = parameters.hasOwnProperty( 'ticks' ) ? parameters[ 'ticks' ] : 0; + + this.legend.labels.decimal = parameters.hasOwnProperty( 'decimal' ) ? parameters[ 'decimal' ] : 2; + + this.legend.labels.notation = parameters.hasOwnProperty( 'notation' ) ? parameters[ 'notation' ] : 'standard'; + + var backgroundColor = { r: 255, g: 100, b: 100, a: 0.8 }; + var borderColor = { r: 255, g: 0, b: 0, a: 1.0 }; + var borderThickness = 4; + + var canvasTitle = document.createElement( 'canvas' ); + var contextTitle = canvasTitle.getContext( '2d' ); + + contextTitle.font = 'Normal ' + this.legend.labels.fontsize * 1.2 + 'px ' + this.legend.labels.fontface; + + contextTitle.fillStyle = 'rgba(' + backgroundColor.r + ',' + backgroundColor.g + ',' + backgroundColor.b + ',' + backgroundColor.a + ')'; + + contextTitle.strokeStyle = 'rgba(' + borderColor.r + ',' + borderColor.g + ',' + borderColor.b + ',' + borderColor.a + ')'; + + contextTitle.lineWidth = borderThickness; + + contextTitle.fillStyle = 'rgba( 0, 0, 0, 1.0 )'; + + contextTitle.fillText( this.legend.labels.title.toString() + this.legend.labels.um.toString(), borderThickness, this.legend.labels.fontsize + borderThickness ); + + var txtTitle = new THREE.CanvasTexture( canvasTitle ); + txtTitle.minFilter = THREE.LinearFilter; + + var spriteMaterialTitle = new THREE.SpriteMaterial( { map: txtTitle } ); + + var spriteTitle = new THREE.Sprite( spriteMaterialTitle ); + + spriteTitle.scale.set( 2, 1, 1.0 ); + + if ( this.legend.layout == 'vertical' ) { + + spriteTitle.position.set( this.legend.position.x + this.legend.dimensions.width, this.legend.position.y + ( this.legend.dimensions.height * 0.45 ), this.legend.position.z ); + + } + + if ( this.legend.layout == 'horizontal' ) { + + spriteTitle.position.set( this.legend.position.x * 1.015, this.legend.position.y + ( this.legend.dimensions.height * 0.03 ), this.legend.position.z ); + + } + + if ( this.legend.labels.ticks > 0 ) { + + var ticks = {}; + var lines = {}; + + if ( this.legend.layout == 'vertical' ) { + + var topPositionY = this.legend.position.y + ( this.legend.dimensions.height * 0.36 ); + var bottomPositionY = this.legend.position.y - ( this.legend.dimensions.height * 0.61 ); + + } + + if ( this.legend.layout == 'horizontal' ) { + + var topPositionX = this.legend.position.x + ( this.legend.dimensions.height * 0.75 ); + var bottomPositionX = this.legend.position.x - ( this.legend.dimensions.width * 1.2 ); + + } + + for ( var i = 0; i < this.legend.labels.ticks; i ++ ) { + + var value = ( this.maxV - this.minV ) / ( this.legend.labels.ticks - 1 ) * i + this.minV; + + if ( callback ) { + + value = callback( value ); + + } else { + + if ( this.legend.labels.notation == 'scientific' ) { + + value = value.toExponential( this.legend.labels.decimal ); + + } else { + + value = value.toFixed( this.legend.labels.decimal ); + + } + + } + + var canvasTick = document.createElement( 'canvas' ); + var contextTick = canvasTick.getContext( '2d' ); + + contextTick.font = 'Normal ' + this.legend.labels.fontsize + 'px ' + this.legend.labels.fontface; + + contextTick.fillStyle = 'rgba(' + backgroundColor.r + ',' + backgroundColor.g + ',' + backgroundColor.b + ',' + backgroundColor.a + ')'; + + contextTick.strokeStyle = 'rgba(' + borderColor.r + ',' + borderColor.g + ',' + borderColor.b + ',' + borderColor.a + ')'; + + contextTick.lineWidth = borderThickness; + + contextTick.fillStyle = 'rgba( 0, 0, 0, 1.0 )'; + + contextTick.fillText( value.toString(), borderThickness, this.legend.labels.fontsize + borderThickness ); + + var txtTick = new THREE.CanvasTexture( canvasTick ); + txtTick.minFilter = THREE.LinearFilter; + + var spriteMaterialTick = new THREE.SpriteMaterial( { map: txtTick } ); + + var spriteTick = new THREE.Sprite( spriteMaterialTick ); + + spriteTick.scale.set( 2, 1, 1.0 ); + + if ( this.legend.layout == 'vertical' ) { + + var position = bottomPositionY + ( topPositionY - bottomPositionY ) * ( ( value - this.minV ) / ( this.maxV - this.minV ) ); + + spriteTick.position.set( this.legend.position.x + ( this.legend.dimensions.width * 2.7 ), position, this.legend.position.z ); + + } + + if ( this.legend.layout == 'horizontal' ) { + + var position = bottomPositionX + ( topPositionX - bottomPositionX ) * ( ( value - this.minV ) / ( this.maxV - this.minV ) ); + + if ( this.legend.labels.ticks > 5 ) { + + if ( i % 2 === 0 ) { + + var offset = 1.7; + + } else { + + var offset = 2.1; + + } + + } else { + + var offset = 1.7; + + } + + spriteTick.position.set( position, this.legend.position.y - this.legend.dimensions.width * offset, this.legend.position.z ); + + } + + var material = new THREE.LineBasicMaterial( { color: 0x000000, linewidth: 2 } ); + + var points = []; + + + if ( this.legend.layout == 'vertical' ) { + + var linePosition = ( this.legend.position.y - ( this.legend.dimensions.height * 0.5 ) + 0.01 ) + ( this.legend.dimensions.height ) * ( ( value - this.minV ) / ( this.maxV - this.minV ) * 0.99 ); + + points.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.55, linePosition, this.legend.position.z ) ); + + points.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.7, linePosition, this.legend.position.z ) ); + + } + + if ( this.legend.layout == 'horizontal' ) { + + var linePosition = ( this.legend.position.x - ( this.legend.dimensions.height * 0.5 ) + 0.01 ) + ( this.legend.dimensions.height ) * ( ( value - this.minV ) / ( this.maxV - this.minV ) * 0.99 ); + + points.push( new THREE.Vector3( linePosition, this.legend.position.y - this.legend.dimensions.width * 0.55, this.legend.position.z ) ); + + points.push( new THREE.Vector3( linePosition, this.legend.position.y - this.legend.dimensions.width * 0.7, this.legend.position.z ) ); + + } + + var geometry = new THREE.BufferGeometry().setFromPoints( points ); + + var line = new THREE.Line( geometry, material ); + + lines[ i ] = line; + ticks[ i ] = spriteTick; + + } + + } + + return { 'title': spriteTitle, 'ticks': ticks, 'lines': lines }; + + } + +}; + + +THREE.ColorMapKeywords = { + + "rainbow": [[ 0.0, '0x0000FF' ], [ 0.2, '0x00FFFF' ], [ 0.5, '0x00FF00' ], [ 0.8, '0xFFFF00' ], [ 1.0, '0xFF0000' ]], + "cooltowarm": [[ 0.0, '0x3C4EC2' ], [ 0.2, '0x9BBCFF' ], [ 0.5, '0xDCDCDC' ], [ 0.8, '0xF6A385' ], [ 1.0, '0xB40426' ]], + "blackbody": [[ 0.0, '0x000000' ], [ 0.2, '0x780000' ], [ 0.5, '0xE63200' ], [ 0.8, '0xFFFF00' ], [ 1.0, '0xFFFFFF' ]], + "grayscale": [[ 0.0, '0x000000' ], [ 0.2, '0x404040' ], [ 0.5, '0x7F7F80' ], [ 0.8, '0xBFBFBF' ], [ 1.0, '0xFFFFFF' ]] + +}; diff --git a/three/jsutil/modifiers/ExplodeModifier.js b/three/jsutil/modifiers/ExplodeModifier.js new file mode 100644 index 000000000..f83d4968b --- /dev/null +++ b/three/jsutil/modifiers/ExplodeModifier.js @@ -0,0 +1,42 @@ +/** + * Make all faces use unique vertices + * so that each face can be separated from others + * + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.ExplodeModifier = function () { + +}; + +THREE.ExplodeModifier.prototype.modify = function ( geometry ) { + + var vertices = []; + + for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) { + + var n = vertices.length; + + var face = geometry.faces[ i ]; + + var a = face.a; + var b = face.b; + var c = face.c; + + var va = geometry.vertices[ a ]; + var vb = geometry.vertices[ b ]; + var vc = geometry.vertices[ c ]; + + vertices.push( va.clone() ); + vertices.push( vb.clone() ); + vertices.push( vc.clone() ); + + face.a = n; + face.b = n + 1; + face.c = n + 2; + + } + + geometry.vertices = vertices; + +}; diff --git a/three/jsutil/modifiers/SimplifyModifier.js b/three/jsutil/modifiers/SimplifyModifier.js new file mode 100644 index 000000000..b67239cce --- /dev/null +++ b/three/jsutil/modifiers/SimplifyModifier.js @@ -0,0 +1,494 @@ +/* + * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog + * + * Simplification Geometry Modifier + * - based on code and technique + * - by Stan Melax in 1998 + * - Progressive Mesh type Polygon Reduction Algorithm + * - http://www.melax.com/polychop/ + */ + +THREE.SimplifyModifier = function () {}; + +( function () { + + var cb = new THREE.Vector3(), ab = new THREE.Vector3(); + + function pushIfUnique( array, object ) { + + if ( array.indexOf( object ) === - 1 ) array.push( object ); + + } + + function removeFromArray( array, object ) { + + var k = array.indexOf( object ); + if ( k > - 1 ) array.splice( k, 1 ); + + } + + function computeEdgeCollapseCost( u, v ) { + + // if we collapse edge uv by moving u to v then how + // much different will the model change, i.e. the "error". + + var edgelength = v.position.distanceTo( u.position ); + var curvature = 0; + + var sideFaces = []; + var i, il = u.faces.length, face, sideFace; + + // find the "sides" triangles that are on the edge uv + for ( i = 0; i < il; i ++ ) { + + face = u.faces[ i ]; + + if ( face.hasVertex( v ) ) { + + sideFaces.push( face ); + + } + + } + + // use the triangle facing most away from the sides + // to determine our curvature term + for ( i = 0; i < il; i ++ ) { + + var minCurvature = 1; + face = u.faces[ i ]; + + for ( var j = 0; j < sideFaces.length; j ++ ) { + + sideFace = sideFaces[ j ]; + // use dot product of face normals. + var dotProd = face.normal.dot( sideFace.normal ); + minCurvature = Math.min( minCurvature, ( 1.001 - dotProd ) / 2 ); + + } + + curvature = Math.max( curvature, minCurvature ); + + } + + // crude approach in attempt to preserve borders + // though it seems not to be totally correct + var borders = 0; + if ( sideFaces.length < 2 ) { + + // we add some arbitrary cost for borders, + // borders += 10; + curvature = 1; + + } + + var amt = edgelength * curvature + borders; + + return amt; + + } + + function computeEdgeCostAtVertex( v ) { + + // compute the edge collapse cost for all edges that start + // from vertex v. Since we are only interested in reducing + // the object by selecting the min cost edge at each step, we + // only cache the cost of the least cost edge at this vertex + // (in member variable collapse) as well as the value of the + // cost (in member variable collapseCost). + + if ( v.neighbors.length === 0 ) { + + // collapse if no neighbors. + v.collapseNeighbor = null; + v.collapseCost = - 0.01; + + return; + + } + + v.collapseCost = 100000; + v.collapseNeighbor = null; + + // search all neighboring edges for "least cost" edge + for ( var i = 0; i < v.neighbors.length; i ++ ) { + + var collapseCost = computeEdgeCollapseCost( v, v.neighbors[ i ] ); + + if ( ! v.collapseNeighbor ) { + + v.collapseNeighbor = v.neighbors[ i ]; + v.collapseCost = collapseCost; + v.minCost = collapseCost; + v.totalCost = 0; + v.costCount = 0; + + } + + v.costCount ++; + v.totalCost += collapseCost; + + if ( collapseCost < v.minCost ) { + + v.collapseNeighbor = v.neighbors[ i ]; + v.minCost = collapseCost; + + } + + } + + // we average the cost of collapsing at this vertex + v.collapseCost = v.totalCost / v.costCount; + // v.collapseCost = v.minCost; + + } + + function removeVertex( v, vertices ) { + + console.assert( v.faces.length === 0 ); + + while ( v.neighbors.length ) { + + var n = v.neighbors.pop(); + removeFromArray( n.neighbors, v ); + + } + + removeFromArray( vertices, v ); + + } + + function removeFace( f, faces ) { + + removeFromArray( faces, f ); + + if ( f.v1 ) removeFromArray( f.v1.faces, f ); + if ( f.v2 ) removeFromArray( f.v2.faces, f ); + if ( f.v3 ) removeFromArray( f.v3.faces, f ); + + // TODO optimize this! + var vs = [ f.v1, f.v2, f.v3 ]; + var v1, v2; + + for ( var i = 0; i < 3; i ++ ) { + + v1 = vs[ i ]; + v2 = vs[ ( i + 1 ) % 3 ]; + + if ( ! v1 || ! v2 ) continue; + + v1.removeIfNonNeighbor( v2 ); + v2.removeIfNonNeighbor( v1 ); + + } + + } + + function collapse( vertices, faces, u, v ) { // u and v are pointers to vertices of an edge + + // Collapse the edge uv by moving vertex u onto v + + if ( ! v ) { + + // u is a vertex all by itself so just delete it.. + removeVertex( u, vertices ); + return; + + } + + var i; + var tmpVertices = []; + + for ( i = 0; i < u.neighbors.length; i ++ ) { + + tmpVertices.push( u.neighbors[ i ] ); + + } + + + // delete triangles on edge uv: + for ( i = u.faces.length - 1; i >= 0; i -- ) { + + if ( u.faces[ i ].hasVertex( v ) ) { + + removeFace( u.faces[ i ], faces ); + + } + + } + + // update remaining triangles to have v instead of u + for ( i = u.faces.length - 1; i >= 0; i -- ) { + + u.faces[ i ].replaceVertex( u, v ); + + } + + + removeVertex( u, vertices ); + + // recompute the edge collapse costs in neighborhood + for ( i = 0; i < tmpVertices.length; i ++ ) { + + computeEdgeCostAtVertex( tmpVertices[ i ] ); + + } + + } + + + + function minimumCostEdge( vertices ) { + + // O(n * n) approach. TODO optimize this + + var least = vertices[ 0 ]; + + for ( var i = 0; i < vertices.length; i ++ ) { + + if ( vertices[ i ].collapseCost < least.collapseCost ) { + + least = vertices[ i ]; + + } + + } + + return least; + + } + + // we use a triangle class to represent structure of face slightly differently + + function Triangle( v1, v2, v3, a, b, c ) { + + this.a = a; + this.b = b; + this.c = c; + + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + + this.normal = new THREE.Vector3(); + + this.computeNormal(); + + v1.faces.push( this ); + v1.addUniqueNeighbor( v2 ); + v1.addUniqueNeighbor( v3 ); + + v2.faces.push( this ); + v2.addUniqueNeighbor( v1 ); + v2.addUniqueNeighbor( v3 ); + + + v3.faces.push( this ); + v3.addUniqueNeighbor( v1 ); + v3.addUniqueNeighbor( v2 ); + + } + + Triangle.prototype.computeNormal = function () { + + var vA = this.v1.position; + var vB = this.v2.position; + var vC = this.v3.position; + + cb.subVectors( vC, vB ); + ab.subVectors( vA, vB ); + cb.cross( ab ).normalize(); + + this.normal.copy( cb ); + + }; + + Triangle.prototype.hasVertex = function ( v ) { + + return v === this.v1 || v === this.v2 || v === this.v3; + + }; + + Triangle.prototype.replaceVertex = function ( oldv, newv ) { + + if ( oldv === this.v1 ) this.v1 = newv; + else if ( oldv === this.v2 ) this.v2 = newv; + else if ( oldv === this.v3 ) this.v3 = newv; + + removeFromArray( oldv.faces, this ); + newv.faces.push( this ); + + + oldv.removeIfNonNeighbor( this.v1 ); + this.v1.removeIfNonNeighbor( oldv ); + + oldv.removeIfNonNeighbor( this.v2 ); + this.v2.removeIfNonNeighbor( oldv ); + + oldv.removeIfNonNeighbor( this.v3 ); + this.v3.removeIfNonNeighbor( oldv ); + + this.v1.addUniqueNeighbor( this.v2 ); + this.v1.addUniqueNeighbor( this.v3 ); + + this.v2.addUniqueNeighbor( this.v1 ); + this.v2.addUniqueNeighbor( this.v3 ); + + this.v3.addUniqueNeighbor( this.v1 ); + this.v3.addUniqueNeighbor( this.v2 ); + + this.computeNormal(); + + }; + + function Vertex( v, id ) { + + this.position = v; + + this.id = id; // old index id + + this.faces = []; // faces vertex is connected + this.neighbors = []; // neighbouring vertices aka "adjacentVertices" + + // these will be computed in computeEdgeCostAtVertex() + this.collapseCost = 0; // cost of collapsing this vertex, the less the better. aka objdist + this.collapseNeighbor = null; // best candinate for collapsing + + } + + Vertex.prototype.addUniqueNeighbor = function ( vertex ) { + + pushIfUnique( this.neighbors, vertex ); + + }; + + Vertex.prototype.removeIfNonNeighbor = function ( n ) { + + var neighbors = this.neighbors; + var faces = this.faces; + + var offset = neighbors.indexOf( n ); + if ( offset === - 1 ) return; + for ( var i = 0; i < faces.length; i ++ ) { + + if ( faces[ i ].hasVertex( n ) ) return; + + } + + neighbors.splice( offset, 1 ); + + }; + + THREE.SimplifyModifier.prototype.modify = function ( geometry, count ) { + + if ( geometry.isBufferGeometry ) { + + geometry = new THREE.Geometry().fromBufferGeometry( geometry ); + + } + + geometry.mergeVertices(); + + var oldVertices = geometry.vertices; // Three Position + var oldFaces = geometry.faces; // Three Face + + // conversion + var vertices = []; + var faces = []; + + var i, il; + + // + // put data of original geometry in different data structures + // + + // add vertices + + for ( i = 0, il = oldVertices.length; i < il; i ++ ) { + + var vertex = new Vertex( oldVertices[ i ], i ); + vertices.push( vertex ); + + } + + // add faces + + for ( i = 0, il = oldFaces.length; i < il; i ++ ) { + + var face = oldFaces[ i ]; + + var a = face.a; + var b = face.b; + var c = face.c; + + var triangle = new Triangle( vertices[ a ], vertices[ b ], vertices[ c ], a, b, c ); + faces.push( triangle ); + + } + + // compute all edge collapse costs + + for ( i = 0, il = vertices.length; i < il; i ++ ) { + + computeEdgeCostAtVertex( vertices[ i ] ); + + } + + var nextVertex; + + var z = count; + + while ( z -- ) { + + nextVertex = minimumCostEdge( vertices ); + + if ( ! nextVertex ) { + + console.log( 'THREE.SimplifyModifier: No next vertex' ); + break; + + } + + collapse( vertices, faces, nextVertex, nextVertex.collapseNeighbor ); + + } + + // + + var simplifiedGeometry = new THREE.BufferGeometry(); + var position = []; + var index = []; + + // + + for ( i = 0; i < vertices.length; i ++ ) { + + var vertex = vertices[ i ].position; + position.push( vertex.x, vertex.y, vertex.z ); + + } + + // + + for ( i = 0; i < faces.length; i ++ ) { + + var face = faces[ i ]; + + var a = vertices.indexOf( face.v1 ); + var b = vertices.indexOf( face.v2 ); + var c = vertices.indexOf( face.v3 ); + + index.push( a, b, c ); + + } + + // + + simplifiedGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) ); + simplifiedGeometry.setIndex( index ); + + return simplifiedGeometry; + + }; + +} )(); diff --git a/three/jsutil/modifiers/SubdivisionModifier.js b/three/jsutil/modifiers/SubdivisionModifier.js new file mode 100644 index 000000000..0ecc2f004 --- /dev/null +++ b/three/jsutil/modifiers/SubdivisionModifier.js @@ -0,0 +1,401 @@ +/* + * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog + * @author centerionware / http://www.centerionware.com + * + * Subdivision Geometry Modifier + * using Loop Subdivision Scheme + * + * References: + * http://graphics.stanford.edu/~mdfisher/subdivision.html + * http://www.holmes3d.net/graphics/subdivision/ + * http://www.cs.rutgers.edu/~decarlo/readings/subdiv-sg00c.pdf + * + * Known Issues: + * - currently doesn't handle "Sharp Edges" + */ + +THREE.SubdivisionModifier = function ( subdivisions ) { + + this.subdivisions = ( subdivisions === undefined ) ? 1 : subdivisions; + +}; + +// Applies the "modify" pattern +THREE.SubdivisionModifier.prototype.modify = function ( geometry ) { + + if ( geometry.isBufferGeometry ) { + + geometry = new THREE.Geometry().fromBufferGeometry( geometry ); + + } else { + + geometry = geometry.clone(); + + } + + geometry.mergeVertices(); + + var repeats = this.subdivisions; + + while ( repeats -- > 0 ) { + + this.smooth( geometry ); + + } + + geometry.computeFaceNormals(); + geometry.computeVertexNormals(); + + return geometry; + +}; + +( function () { + + // Some constants + var WARNINGS = ! true; // Set to true for development + var ABC = [ 'a', 'b', 'c' ]; + + + function getEdge( a, b, map ) { + + var vertexIndexA = Math.min( a, b ); + var vertexIndexB = Math.max( a, b ); + + var key = vertexIndexA + "_" + vertexIndexB; + + return map[ key ]; + + } + + + function processEdge( a, b, vertices, map, face, metaVertices ) { + + var vertexIndexA = Math.min( a, b ); + var vertexIndexB = Math.max( a, b ); + + var key = vertexIndexA + "_" + vertexIndexB; + + var edge; + + if ( key in map ) { + + edge = map[ key ]; + + } else { + + var vertexA = vertices[ vertexIndexA ]; + var vertexB = vertices[ vertexIndexB ]; + + edge = { + + a: vertexA, // pointer reference + b: vertexB, + newEdge: null, + // aIndex: a, // numbered reference + // bIndex: b, + faces: [] // pointers to face + + }; + + map[ key ] = edge; + + } + + edge.faces.push( face ); + + metaVertices[ a ].edges.push( edge ); + metaVertices[ b ].edges.push( edge ); + + + } + + function generateLookups( vertices, faces, metaVertices, edges ) { + + var i, il, face; + + for ( i = 0, il = vertices.length; i < il; i ++ ) { + + metaVertices[ i ] = { edges: [] }; + + } + + for ( i = 0, il = faces.length; i < il; i ++ ) { + + face = faces[ i ]; + + processEdge( face.a, face.b, vertices, edges, face, metaVertices ); + processEdge( face.b, face.c, vertices, edges, face, metaVertices ); + processEdge( face.c, face.a, vertices, edges, face, metaVertices ); + + } + + } + + function newFace( newFaces, a, b, c, materialIndex ) { + + newFaces.push( new THREE.Face3( a, b, c, undefined, undefined, materialIndex ) ); + + } + + function midpoint( a, b ) { + + return ( Math.abs( b - a ) / 2 ) + Math.min( a, b ); + + } + + function newUv( newUvs, a, b, c ) { + + newUvs.push( [ a.clone(), b.clone(), c.clone() ] ); + + } + + ///////////////////////////// + + // Performs one iteration of Subdivision + THREE.SubdivisionModifier.prototype.smooth = function ( geometry ) { + + var tmp = new THREE.Vector3(); + + var oldVertices, oldFaces, oldUvs; + var newVertices, newFaces, newUVs = []; + + var n, i, il, j, k; + var metaVertices, sourceEdges; + + // new stuff. + var sourceEdges, newEdgeVertices, newSourceVertices; + + oldVertices = geometry.vertices; // { x, y, z} + oldFaces = geometry.faces; // { a: oldVertex1, b: oldVertex2, c: oldVertex3 } + oldUvs = geometry.faceVertexUvs[ 0 ]; + + var hasUvs = oldUvs !== undefined && oldUvs.length > 0; + + /****************************************************** + * + * Step 0: Preprocess Geometry to Generate edges Lookup + * + *******************************************************/ + + metaVertices = new Array( oldVertices.length ); + sourceEdges = {}; // Edge => { oldVertex1, oldVertex2, faces[] } + + generateLookups( oldVertices, oldFaces, metaVertices, sourceEdges ); + + + /****************************************************** + * + * Step 1. + * For each edge, create a new Edge Vertex, + * then position it. + * + *******************************************************/ + + newEdgeVertices = []; + var other, currentEdge, newEdge, face; + var edgeVertexWeight, adjacentVertexWeight, connectedFaces; + + for ( i in sourceEdges ) { + + currentEdge = sourceEdges[ i ]; + newEdge = new THREE.Vector3(); + + edgeVertexWeight = 3 / 8; + adjacentVertexWeight = 1 / 8; + + connectedFaces = currentEdge.faces.length; + + // check how many linked faces. 2 should be correct. + if ( connectedFaces != 2 ) { + + // if length is not 2, handle condition + edgeVertexWeight = 0.5; + adjacentVertexWeight = 0; + + if ( connectedFaces != 1 ) { + + if ( WARNINGS ) console.warn( 'Subdivision Modifier: Number of connected faces != 2, is: ', connectedFaces, currentEdge ); + + } + + } + + newEdge.addVectors( currentEdge.a, currentEdge.b ).multiplyScalar( edgeVertexWeight ); + + tmp.set( 0, 0, 0 ); + + for ( j = 0; j < connectedFaces; j ++ ) { + + face = currentEdge.faces[ j ]; + + for ( k = 0; k < 3; k ++ ) { + + other = oldVertices[ face[ ABC[ k ] ] ]; + if ( other !== currentEdge.a && other !== currentEdge.b ) break; + + } + + tmp.add( other ); + + } + + tmp.multiplyScalar( adjacentVertexWeight ); + newEdge.add( tmp ); + + currentEdge.newEdge = newEdgeVertices.length; + newEdgeVertices.push( newEdge ); + + // console.log(currentEdge, newEdge); + + } + + /****************************************************** + * + * Step 2. + * Reposition each source vertices. + * + *******************************************************/ + + var beta, sourceVertexWeight, connectingVertexWeight; + var connectingEdge, connectingEdges, oldVertex, newSourceVertex; + newSourceVertices = []; + + for ( i = 0, il = oldVertices.length; i < il; i ++ ) { + + oldVertex = oldVertices[ i ]; + + // find all connecting edges (using lookupTable) + connectingEdges = metaVertices[ i ].edges; + n = connectingEdges.length; + + if ( n == 3 ) { + + beta = 3 / 16; + + } else if ( n > 3 ) { + + beta = 3 / ( 8 * n ); // Warren's modified formula + + } + + // Loop's original beta formula + // beta = 1 / n * ( 5/8 - Math.pow( 3/8 + 1/4 * Math.cos( 2 * Math. PI / n ), 2) ); + + sourceVertexWeight = 1 - n * beta; + connectingVertexWeight = beta; + + if ( n <= 2 ) { + + // crease and boundary rules + // console.warn('crease and boundary rules'); + + if ( n == 2 ) { + + if ( WARNINGS ) console.warn( '2 connecting edges', connectingEdges ); + sourceVertexWeight = 3 / 4; + connectingVertexWeight = 1 / 8; + + // sourceVertexWeight = 1; + // connectingVertexWeight = 0; + + } else if ( n == 1 ) { + + if ( WARNINGS ) console.warn( 'only 1 connecting edge' ); + + } else if ( n == 0 ) { + + if ( WARNINGS ) console.warn( '0 connecting edges' ); + + } + + } + + newSourceVertex = oldVertex.clone().multiplyScalar( sourceVertexWeight ); + + tmp.set( 0, 0, 0 ); + + for ( j = 0; j < n; j ++ ) { + + connectingEdge = connectingEdges[ j ]; + other = connectingEdge.a !== oldVertex ? connectingEdge.a : connectingEdge.b; + tmp.add( other ); + + } + + tmp.multiplyScalar( connectingVertexWeight ); + newSourceVertex.add( tmp ); + + newSourceVertices.push( newSourceVertex ); + + } + + + /****************************************************** + * + * Step 3. + * Generate Faces between source vertices + * and edge vertices. + * + *******************************************************/ + + newVertices = newSourceVertices.concat( newEdgeVertices ); + var sl = newSourceVertices.length, edge1, edge2, edge3; + newFaces = []; + + var uv, x0, x1, x2; + var x3 = new THREE.Vector2(); + var x4 = new THREE.Vector2(); + var x5 = new THREE.Vector2(); + + for ( i = 0, il = oldFaces.length; i < il; i ++ ) { + + face = oldFaces[ i ]; + + // find the 3 new edges vertex of each old face + + edge1 = getEdge( face.a, face.b, sourceEdges ).newEdge + sl; + edge2 = getEdge( face.b, face.c, sourceEdges ).newEdge + sl; + edge3 = getEdge( face.c, face.a, sourceEdges ).newEdge + sl; + + // create 4 faces. + + newFace( newFaces, edge1, edge2, edge3, face.materialIndex ); + newFace( newFaces, face.a, edge1, edge3, face.materialIndex ); + newFace( newFaces, face.b, edge2, edge1, face.materialIndex ); + newFace( newFaces, face.c, edge3, edge2, face.materialIndex ); + + // create 4 new uv's + + if ( hasUvs ) { + + uv = oldUvs[ i ]; + + x0 = uv[ 0 ]; + x1 = uv[ 1 ]; + x2 = uv[ 2 ]; + + x3.set( midpoint( x0.x, x1.x ), midpoint( x0.y, x1.y ) ); + x4.set( midpoint( x1.x, x2.x ), midpoint( x1.y, x2.y ) ); + x5.set( midpoint( x0.x, x2.x ), midpoint( x0.y, x2.y ) ); + + newUv( newUVs, x3, x4, x5 ); + newUv( newUVs, x0, x3, x5 ); + + newUv( newUVs, x1, x4, x3 ); + newUv( newUVs, x2, x5, x4 ); + + } + + } + + // Overwrite old arrays + geometry.vertices = newVertices; + geometry.faces = newFaces; + if ( hasUvs ) geometry.faceVertexUvs[ 0 ] = newUVs; + + // console.log('done'); + + }; + +} )(); diff --git a/three/jsutil/modifiers/TessellateModifier.js b/three/jsutil/modifiers/TessellateModifier.js new file mode 100644 index 000000000..7da91e5c0 --- /dev/null +++ b/three/jsutil/modifiers/TessellateModifier.js @@ -0,0 +1,236 @@ +/** + * Break faces with edges longer than maxEdgeLength + * - not recursive + * + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.TessellateModifier = function ( maxEdgeLength ) { + + this.maxEdgeLength = maxEdgeLength; + +}; + +THREE.TessellateModifier.prototype.modify = function ( geometry ) { + + var edge; + + var faces = []; + var faceVertexUvs = []; + var maxEdgeLengthSquared = this.maxEdgeLength * this.maxEdgeLength; + + for ( var i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) { + + faceVertexUvs[ i ] = []; + + } + + for ( var i = 0, il = geometry.faces.length; i < il; i ++ ) { + + var face = geometry.faces[ i ]; + + if ( face instanceof THREE.Face3 ) { + + var a = face.a; + var b = face.b; + var c = face.c; + + var va = geometry.vertices[ a ]; + var vb = geometry.vertices[ b ]; + var vc = geometry.vertices[ c ]; + + var dab = va.distanceToSquared( vb ); + var dbc = vb.distanceToSquared( vc ); + var dac = va.distanceToSquared( vc ); + + if ( dab > maxEdgeLengthSquared || dbc > maxEdgeLengthSquared || dac > maxEdgeLengthSquared ) { + + var m = geometry.vertices.length; + + var triA = face.clone(); + var triB = face.clone(); + + if ( dab >= dbc && dab >= dac ) { + + var vm = va.clone(); + vm.lerp( vb, 0.5 ); + + triA.a = a; + triA.b = m; + triA.c = c; + + triB.a = m; + triB.b = b; + triB.c = c; + + if ( face.vertexNormals.length === 3 ) { + + var vnm = face.vertexNormals[ 0 ].clone(); + vnm.lerp( face.vertexNormals[ 1 ], 0.5 ); + + triA.vertexNormals[ 1 ].copy( vnm ); + triB.vertexNormals[ 0 ].copy( vnm ); + + } + + if ( face.vertexColors.length === 3 ) { + + var vcm = face.vertexColors[ 0 ].clone(); + vcm.lerp( face.vertexColors[ 1 ], 0.5 ); + + triA.vertexColors[ 1 ].copy( vcm ); + triB.vertexColors[ 0 ].copy( vcm ); + + } + + edge = 0; + + } else if ( dbc >= dab && dbc >= dac ) { + + var vm = vb.clone(); + vm.lerp( vc, 0.5 ); + + triA.a = a; + triA.b = b; + triA.c = m; + + triB.a = m; + triB.b = c; + triB.c = a; + + if ( face.vertexNormals.length === 3 ) { + + var vnm = face.vertexNormals[ 1 ].clone(); + vnm.lerp( face.vertexNormals[ 2 ], 0.5 ); + + triA.vertexNormals[ 2 ].copy( vnm ); + + triB.vertexNormals[ 0 ].copy( vnm ); + triB.vertexNormals[ 1 ].copy( face.vertexNormals[ 2 ] ); + triB.vertexNormals[ 2 ].copy( face.vertexNormals[ 0 ] ); + + } + + if ( face.vertexColors.length === 3 ) { + + var vcm = face.vertexColors[ 1 ].clone(); + vcm.lerp( face.vertexColors[ 2 ], 0.5 ); + + triA.vertexColors[ 2 ].copy( vcm ); + + triB.vertexColors[ 0 ].copy( vcm ); + triB.vertexColors[ 1 ].copy( face.vertexColors[ 2 ] ); + triB.vertexColors[ 2 ].copy( face.vertexColors[ 0 ] ); + + } + + edge = 1; + + } else { + + var vm = va.clone(); + vm.lerp( vc, 0.5 ); + + triA.a = a; + triA.b = b; + triA.c = m; + + triB.a = m; + triB.b = b; + triB.c = c; + + if ( face.vertexNormals.length === 3 ) { + + var vnm = face.vertexNormals[ 0 ].clone(); + vnm.lerp( face.vertexNormals[ 2 ], 0.5 ); + + triA.vertexNormals[ 2 ].copy( vnm ); + triB.vertexNormals[ 0 ].copy( vnm ); + + } + + if ( face.vertexColors.length === 3 ) { + + var vcm = face.vertexColors[ 0 ].clone(); + vcm.lerp( face.vertexColors[ 2 ], 0.5 ); + + triA.vertexColors[ 2 ].copy( vcm ); + triB.vertexColors[ 0 ].copy( vcm ); + + } + + edge = 2; + + } + + faces.push( triA, triB ); + geometry.vertices.push( vm ); + + for ( var j = 0, jl = geometry.faceVertexUvs.length; j < jl; j ++ ) { + + if ( geometry.faceVertexUvs[ j ].length ) { + + var uvs = geometry.faceVertexUvs[ j ][ i ]; + + var uvA = uvs[ 0 ]; + var uvB = uvs[ 1 ]; + var uvC = uvs[ 2 ]; + + // AB + + if ( edge === 0 ) { + + var uvM = uvA.clone(); + uvM.lerp( uvB, 0.5 ); + + var uvsTriA = [ uvA.clone(), uvM.clone(), uvC.clone() ]; + var uvsTriB = [ uvM.clone(), uvB.clone(), uvC.clone() ]; + + // BC + + } else if ( edge === 1 ) { + + var uvM = uvB.clone(); + uvM.lerp( uvC, 0.5 ); + + var uvsTriA = [ uvA.clone(), uvB.clone(), uvM.clone() ]; + var uvsTriB = [ uvM.clone(), uvC.clone(), uvA.clone() ]; + + // AC + + } else { + + var uvM = uvA.clone(); + uvM.lerp( uvC, 0.5 ); + + var uvsTriA = [ uvA.clone(), uvB.clone(), uvM.clone() ]; + var uvsTriB = [ uvM.clone(), uvB.clone(), uvC.clone() ]; + + } + + faceVertexUvs[ j ].push( uvsTriA, uvsTriB ); + + } + + } + + } else { + + faces.push( face ); + + for ( var j = 0, jl = geometry.faceVertexUvs.length; j < jl; j ++ ) { + + faceVertexUvs[ j ].push( geometry.faceVertexUvs[ j ][ i ] ); + + } + + } + + } + + } + + geometry.faces = faces; + geometry.faceVertexUvs = faceVertexUvs; + +}; diff --git a/three/jsutil/nodes/Nodes.js b/three/jsutil/nodes/Nodes.js new file mode 100644 index 000000000..5b8a74ee4 --- /dev/null +++ b/three/jsutil/nodes/Nodes.js @@ -0,0 +1,112 @@ +// TODO: all nodes + +// core + +export { Node } from './core/Node.js'; +export { TempNode } from './core/TempNode.js'; +export { InputNode } from './core/InputNode.js'; +export { ConstNode } from './core/ConstNode.js'; +export { VarNode } from './core/VarNode.js'; +export { StructNode } from './core/StructNode.js'; +export { AttributeNode } from './core/AttributeNode.js'; +export { FunctionNode } from './core/FunctionNode.js'; +export { ExpressionNode } from './core/ExpressionNode.js'; +export { FunctionCallNode } from './core/FunctionCallNode.js'; +export { NodeLib } from './core/NodeLib.js'; +export { NodeUtils } from './core/NodeUtils.js'; +export { NodeFrame } from './core/NodeFrame.js'; +export { NodeUniform } from './core/NodeUniform.js'; +export { NodeBuilder } from './core/NodeBuilder.js'; + +// inputs + +export { IntNode } from './inputs/IntNode.js'; +export { FloatNode } from './inputs/FloatNode.js'; +export { Vector2Node } from './inputs/Vector2Node.js'; +export { Vector3Node } from './inputs/Vector3Node.js'; +export { Vector4Node } from './inputs/Vector4Node.js'; +export { ColorNode } from './inputs/ColorNode.js'; +export { Matrix3Node } from './inputs/Matrix3Node.js'; +export { Matrix4Node } from './inputs/Matrix4Node.js'; +export { TextureNode } from './inputs/TextureNode.js'; +export { CubeTextureNode } from './inputs/CubeTextureNode.js'; +export { ScreenNode } from './inputs/ScreenNode.js'; +export { ReflectorNode } from './inputs/ReflectorNode.js'; +export { PropertyNode } from './inputs/PropertyNode.js'; +export { RTTNode } from './inputs/RTTNode.js'; + +// accessors + +export { UVNode } from './accessors/UVNode.js'; +export { ColorsNode } from './accessors/ColorsNode.js'; +export { PositionNode } from './accessors/PositionNode.js'; +export { NormalNode } from './accessors/NormalNode.js'; +export { CameraNode } from './accessors/CameraNode.js'; +export { LightNode } from './accessors/LightNode.js'; +export { ReflectNode } from './accessors/ReflectNode.js'; +export { ScreenUVNode } from './accessors/ScreenUVNode.js'; +export { ResolutionNode } from './accessors/ResolutionNode.js'; + +// math + +export { Math1Node } from './math/Math1Node.js'; +export { Math2Node } from './math/Math2Node.js'; +export { Math3Node } from './math/Math3Node.js'; +export { OperatorNode } from './math/OperatorNode.js'; +export { CondNode } from './math/CondNode.js'; + +// procedural + +export { NoiseNode } from './procedural/NoiseNode.js'; +export { CheckerNode } from './procedural/CheckerNode.js'; + +// bsdfs + +export { BlinnShininessExponentNode } from './bsdfs/BlinnShininessExponentNode.js'; +export { BlinnExponentToRoughnessNode } from './bsdfs/BlinnExponentToRoughnessNode.js'; +export { RoughnessToBlinnExponentNode } from './bsdfs/RoughnessToBlinnExponentNode.js'; + +// misc + +export { TextureCubeUVNode } from './misc/TextureCubeUVNode.js'; +export { TextureCubeNode } from './misc/TextureCubeNode.js'; +export { NormalMapNode } from './misc/NormalMapNode.js'; +export { BumpMapNode } from './misc/BumpMapNode.js'; + +// utils + +export { BypassNode } from './utils/BypassNode.js'; +export { JoinNode } from './utils/JoinNode.js'; +export { SwitchNode } from './utils/SwitchNode.js'; +export { TimerNode } from './utils/TimerNode.js'; +export { VelocityNode } from './utils/VelocityNode.js'; +export { UVTransformNode } from './utils/UVTransformNode.js'; +export { MaxMIPLevelNode } from './utils/MaxMIPLevelNode.js'; +export { ColorSpaceNode } from './utils/ColorSpaceNode.js'; + +// effects + +export { BlurNode } from './effects/BlurNode.js'; +export { ColorAdjustmentNode } from './effects/ColorAdjustmentNode.js'; +export { LuminanceNode } from './effects/LuminanceNode.js'; + +// material nodes + +export { RawNode } from './materials/nodes/RawNode.js'; +export { SpriteNode } from './materials/nodes/SpriteNode.js'; +export { PhongNode } from './materials/nodes/PhongNode.js'; +export { StandardNode } from './materials/nodes/StandardNode.js'; +export { MeshStandardNode } from './materials/nodes/MeshStandardNode.js'; + +// materials + +export { NodeMaterial } from './materials/NodeMaterial.js'; +export { SpriteNodeMaterial } from './materials/SpriteNodeMaterial.js'; +export { PhongNodeMaterial } from './materials/PhongNodeMaterial.js'; +export { StandardNodeMaterial } from './materials/StandardNodeMaterial.js'; +export { MeshStandardNodeMaterial } from './materials/MeshStandardNodeMaterial.js'; + +// postprocessing + +export { NodePostProcessing } from './postprocessing/NodePostProcessing.js'; +//export { NodePass } from './postprocessing/NodePass.js'; diff --git a/three/jsutil/nodes/THREE.Nodes.js b/three/jsutil/nodes/THREE.Nodes.js new file mode 100644 index 000000000..e517f3e25 --- /dev/null +++ b/three/jsutil/nodes/THREE.Nodes.js @@ -0,0 +1,223 @@ +import { + + // core + + Node, + TempNode, + InputNode, + ConstNode, + VarNode, + StructNode, + AttributeNode, + FunctionNode, + ExpressionNode, + FunctionCallNode, + NodeLib, + NodeUtils, + NodeFrame, + NodeUniform, + NodeBuilder, + + // inputs + + IntNode, + FloatNode, + Vector2Node, + Vector3Node, + Vector4Node, + ColorNode, + Matrix3Node, + Matrix4Node, + TextureNode, + CubeTextureNode, + ScreenNode, + ReflectorNode, + PropertyNode, + RTTNode, + + // accessors + + UVNode, + ColorsNode, + PositionNode, + NormalNode, + CameraNode, + LightNode, + ReflectNode, + ScreenUVNode, + ResolutionNode, + + // math + + Math1Node, + Math2Node, + Math3Node, + OperatorNode, + CondNode, + + // procedural + + NoiseNode, + CheckerNode, + + // bsdfs + + BlinnShininessExponentNode, + BlinnExponentToRoughnessNode, + RoughnessToBlinnExponentNode, + + // misc + + TextureCubeUVNode, + TextureCubeNode, + NormalMapNode, + BumpMapNode, + + // utils + + BypassNode, + JoinNode, + SwitchNode, + TimerNode, + VelocityNode, + UVTransformNode, + MaxMIPLevelNode, + ColorSpaceNode, + + // effects + + BlurNode, + ColorAdjustmentNode, + LuminanceNode, + + // material nodes + + RawNode, + SpriteNode, + PhongNode, + StandardNode, + MeshStandardNode, + + // materials + + NodeMaterial, + SpriteNodeMaterial, + PhongNodeMaterial, + StandardNodeMaterial, + MeshStandardNodeMaterial, + + // post-processing + + NodePostProcessing + +} from './Nodes.js'; + +// core + +THREE.Node = Node; +THREE.TempNode = TempNode; +THREE.InputNode = InputNode; +THREE.ConstNode = ConstNode; +THREE.VarNode = VarNode; +THREE.StructNode = StructNode; +THREE.AttributeNode = AttributeNode; +THREE.FunctionNode = FunctionNode; +THREE.ExpressionNode = ExpressionNode; +THREE.FunctionCallNode = FunctionCallNode; +THREE.NodeLib = NodeLib; +THREE.NodeUtils = NodeUtils; +THREE.NodeFrame = NodeFrame; +THREE.NodeUniform = NodeUniform; +THREE.NodeBuilder = NodeBuilder; + +// inputs + +THREE.IntNode = IntNode; +THREE.FloatNode = FloatNode; +THREE.Vector2Node = Vector2Node; +THREE.Vector3Node = Vector3Node; +THREE.Vector4Node = Vector4Node; +THREE.ColorNode = ColorNode; +THREE.Matrix3Node = Matrix3Node; +THREE.Matrix4Node = Matrix4Node; +THREE.TextureNode = TextureNode; +THREE.CubeTextureNode = CubeTextureNode; +THREE.ScreenNode = ScreenNode; +THREE.ReflectorNode = ReflectorNode; +THREE.PropertyNode = PropertyNode; +THREE.RTTNode = RTTNode; + +// accessors + +THREE.UVNode = UVNode; +THREE.ColorsNode = ColorsNode; +THREE.PositionNode = PositionNode; +THREE.NormalNode = NormalNode; +THREE.CameraNode = CameraNode; +THREE.LightNode = LightNode; +THREE.ReflectNode = ReflectNode; +THREE.ScreenUVNode = ScreenUVNode; +THREE.ResolutionNode = ResolutionNode; + +// math + +THREE.Math1Node = Math1Node; +THREE.Math2Node = Math2Node; +THREE.Math3Node = Math3Node; +THREE.OperatorNode = OperatorNode; +THREE.CondNode = CondNode; + +// procedural + +THREE.NoiseNode = NoiseNode; +THREE.CheckerNode = CheckerNode; + +// bsdfs + +THREE.BlinnShininessExponentNode = BlinnShininessExponentNode; +THREE.BlinnExponentToRoughnessNode = BlinnExponentToRoughnessNode; +THREE.RoughnessToBlinnExponentNode = RoughnessToBlinnExponentNode; + +// misc + +THREE.TextureCubeUVNode = TextureCubeUVNode; +THREE.TextureCubeNode = TextureCubeNode; +THREE.NormalMapNode = NormalMapNode; +THREE.BumpMapNode = BumpMapNode; + +// utils + +THREE.BypassNode = BypassNode; +THREE.JoinNode = JoinNode; +THREE.SwitchNode = SwitchNode; +THREE.TimerNode = TimerNode; +THREE.VelocityNode = VelocityNode; +THREE.UVTransformNode = UVTransformNode; +THREE.MaxMIPLevelNode = MaxMIPLevelNode; +THREE.ColorSpaceNode = ColorSpaceNode; + +// effects + +THREE.BlurNode = BlurNode; +THREE.ColorAdjustmentNode = ColorAdjustmentNode; +THREE.LuminanceNode = LuminanceNode; + +// material nodes + +THREE.RawNode = RawNode; +THREE.SpriteNode = SpriteNode; +THREE.PhongNode = PhongNode; +THREE.StandardNode = StandardNode; +THREE.MeshStandardNode = MeshStandardNode; + +// materials + +THREE.NodeMaterial = NodeMaterial; +THREE.SpriteNodeMaterial = SpriteNodeMaterial; +THREE.PhongNodeMaterial = PhongNodeMaterial; +THREE.StandardNodeMaterial = StandardNodeMaterial; +THREE.MeshStandardNodeMaterial = MeshStandardNodeMaterial; + +// post-processing + +THREE.NodePostProcessing = NodePostProcessing; diff --git a/three/jsutil/nodes/accessors/CameraNode.js b/three/jsutil/nodes/accessors/CameraNode.js new file mode 100644 index 000000000..d9f503d57 --- /dev/null +++ b/three/jsutil/nodes/accessors/CameraNode.js @@ -0,0 +1,236 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { FloatNode } from '../inputs/FloatNode.js'; +import { PositionNode } from '../accessors/PositionNode.js'; + +function CameraNode( scope, camera ) { + + TempNode.call( this, 'v3' ); + + this.setScope( scope || CameraNode.POSITION ); + this.setCamera( camera ); + +} + +CameraNode.Nodes = ( function () { + + var depthColor = new FunctionNode( [ + "float depthColor( float mNear, float mFar ) {", + + " #ifdef USE_LOGDEPTHBUF_EXT", + + " float depth = gl_FragDepthEXT / gl_FragCoord.w;", + + " #else", + + " float depth = gl_FragCoord.z / gl_FragCoord.w;", + + " #endif", + + " return 1.0 - smoothstep( mNear, mFar, depth );", + + "}" + ].join( "\n" ) ); + + return { + depthColor: depthColor + }; + +} )(); + +CameraNode.POSITION = 'position'; +CameraNode.DEPTH = 'depth'; +CameraNode.TO_VERTEX = 'toVertex'; + +CameraNode.prototype = Object.create( TempNode.prototype ); +CameraNode.prototype.constructor = CameraNode; +CameraNode.prototype.nodeType = "Camera"; + +CameraNode.prototype.setCamera = function ( camera ) { + + this.camera = camera; + this.updateFrame = camera !== undefined ? this.onUpdateFrame : undefined; + +}; + +CameraNode.prototype.setScope = function ( scope ) { + + switch ( this.scope ) { + + case CameraNode.DEPTH: + + delete this.near; + delete this.far; + + break; + + } + + this.scope = scope; + + switch ( scope ) { + + case CameraNode.DEPTH: + + var camera = this.camera; + + this.near = new FloatNode( camera ? camera.near : 1 ); + this.far = new FloatNode( camera ? camera.far : 1200 ); + + break; + + } + +}; + +CameraNode.prototype.getType = function ( builder ) { + + switch ( this.scope ) { + + case CameraNode.DEPTH: + + return 'f'; + + } + + return this.type; + +}; + +CameraNode.prototype.isUnique = function ( builder ) { + + switch ( this.scope ) { + + case CameraNode.DEPTH: + case CameraNode.TO_VERTEX: + + return true; + + } + + return false; + +}; + +CameraNode.prototype.isShared = function ( builder ) { + + switch ( this.scope ) { + + case CameraNode.POSITION: + + return false; + + } + + return true; + +}; + +CameraNode.prototype.generate = function ( builder, output ) { + + var result; + + switch ( this.scope ) { + + case CameraNode.POSITION: + + result = 'cameraPosition'; + + break; + + case CameraNode.DEPTH: + + var depthColor = builder.include( CameraNode.Nodes.depthColor ); + + result = depthColor + '( ' + this.near.build( builder, 'f' ) + ', ' + this.far.build( builder, 'f' ) + ' )'; + + break; + + case CameraNode.TO_VERTEX: + + result = 'normalize( ' + new PositionNode( PositionNode.WORLD ).build( builder, 'v3' ) + ' - cameraPosition )'; + + break; + + } + + return builder.format( result, this.getType( builder ), output ); + +}; + +CameraNode.prototype.onUpdateFrame = function ( frame ) { + + switch ( this.scope ) { + + case CameraNode.DEPTH: + + var camera = this.camera; + + this.near.value = camera.near; + this.far.value = camera.far; + + break; + + } + +}; + +CameraNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.setScope( source.scope ); + + if ( source.camera ) { + + this.setCamera( source.camera ); + + } + + switch ( source.scope ) { + + case CameraNode.DEPTH: + + this.near.number = source.near; + this.far.number = source.far; + + break; + + } + +}; + +CameraNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.scope = this.scope; + + if ( this.camera ) data.camera = this.camera.uuid; + + switch ( this.scope ) { + + case CameraNode.DEPTH: + + data.near = this.near.value; + data.far = this.far.value; + + break; + + } + + } + + return data; + +}; + +export { CameraNode }; diff --git a/three/jsutil/nodes/accessors/ColorsNode.js b/three/jsutil/nodes/accessors/ColorsNode.js new file mode 100644 index 000000000..2586d1556 --- /dev/null +++ b/three/jsutil/nodes/accessors/ColorsNode.js @@ -0,0 +1,55 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +var vertexDict = [ 'color', 'color2' ], + fragmentDict = [ 'vColor', 'vColor2' ]; + +function ColorsNode( index ) { + + TempNode.call( this, 'v4', { shared: false } ); + + this.index = index || 0; + +} + +ColorsNode.prototype = Object.create( TempNode.prototype ); +ColorsNode.prototype.constructor = ColorsNode; + +ColorsNode.prototype.generate = function ( builder, output ) { + + builder.requires.color[ this.index ] = true; + + var result = builder.isShader( 'vertex' ) ? vertexDict[ this.index ] : fragmentDict[ this.index ]; + + return builder.format( result, this.getType( builder ), output ); + +}; + +ColorsNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.index = source.index; + +}; + +ColorsNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.index = this.index; + + } + + return data; + +}; + +export { ColorsNode }; diff --git a/three/jsutil/nodes/accessors/LightNode.js b/three/jsutil/nodes/accessors/LightNode.js new file mode 100644 index 000000000..f510329f1 --- /dev/null +++ b/three/jsutil/nodes/accessors/LightNode.js @@ -0,0 +1,61 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function LightNode( scope ) { + + TempNode.call( this, 'v3', { shared: false } ); + + this.scope = scope || LightNode.TOTAL; + +} + +LightNode.TOTAL = 'total'; + +LightNode.prototype = Object.create( TempNode.prototype ); +LightNode.prototype.constructor = LightNode; +LightNode.prototype.nodeType = "Light"; + +LightNode.prototype.generate = function ( builder, output ) { + + if ( builder.isCache( 'light' ) ) { + + return builder.format( 'reflectedLight.directDiffuse', this.type, output ); + + } else { + + console.warn( "THREE.LightNode is only compatible in \"light\" channel." ); + + return builder.format( 'vec3( 0.0 )', this.type, output ); + + } + +}; + +LightNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.scope = source.scope; + +}; + +LightNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.scope = this.scope; + + } + + return data; + +}; + +export { LightNode }; diff --git a/three/jsutil/nodes/accessors/NormalNode.js b/three/jsutil/nodes/accessors/NormalNode.js new file mode 100644 index 000000000..db2540970 --- /dev/null +++ b/three/jsutil/nodes/accessors/NormalNode.js @@ -0,0 +1,114 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { NodeLib } from '../core/NodeLib.js'; + +function NormalNode( scope ) { + + TempNode.call( this, 'v3' ); + + this.scope = scope || NormalNode.LOCAL; + +} + +NormalNode.LOCAL = 'local'; +NormalNode.WORLD = 'world'; +NormalNode.VIEW = 'view'; + +NormalNode.prototype = Object.create( TempNode.prototype ); +NormalNode.prototype.constructor = NormalNode; +NormalNode.prototype.nodeType = "Normal"; + +NormalNode.prototype.isShared = function ( builder ) { + + switch ( this.scope ) { + + case NormalNode.WORLD: + + return true; + + } + + return false; + +}; + +NormalNode.prototype.generate = function ( builder, output ) { + + var result; + + switch ( this.scope ) { + + case NormalNode.LOCAL: + + builder.requires.normal = true; + + result = 'normal'; + + break; + + case NormalNode.WORLD: + + builder.requires.worldNormal = true; + + result = builder.isShader( 'vertex' ) ? '( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz' : 'vWNormal'; + + break; + + case NormalNode.VIEW: + + result = 'vNormal'; + + break; + + } + + return builder.format( result, this.getType( builder ), output ); + +}; + +NormalNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.scope = source.scope; + +}; + +NormalNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.scope = this.scope; + + } + + return data; + +}; + +NodeLib.addKeyword( 'normal', function () { + + return new NormalNode(); + +} ); + +NodeLib.addKeyword( 'worldNormal', function () { + + return new NormalNode( NormalNode.WORLD ); + +} ); + +NodeLib.addKeyword( 'viewNormal', function () { + + return new NormalNode( NormalNode.VIEW ); + +} ); + +export { NormalNode }; diff --git a/three/jsutil/nodes/accessors/PositionNode.js b/three/jsutil/nodes/accessors/PositionNode.js new file mode 100644 index 000000000..e81ff9b39 --- /dev/null +++ b/three/jsutil/nodes/accessors/PositionNode.js @@ -0,0 +1,136 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { NodeLib } from '../core/NodeLib.js'; + +function PositionNode( scope ) { + + TempNode.call( this, 'v3' ); + + this.scope = scope || PositionNode.LOCAL; + +} + +PositionNode.LOCAL = 'local'; +PositionNode.WORLD = 'world'; +PositionNode.VIEW = 'view'; +PositionNode.PROJECTION = 'projection'; + +PositionNode.prototype = Object.create( TempNode.prototype ); +PositionNode.prototype.constructor = PositionNode; +PositionNode.prototype.nodeType = "Position"; + +PositionNode.prototype.getType = function ( ) { + + switch ( this.scope ) { + + case PositionNode.PROJECTION: + + return 'v4'; + + } + + return this.type; + +}; + +PositionNode.prototype.isShared = function ( builder ) { + + switch ( this.scope ) { + + case PositionNode.LOCAL: + case PositionNode.WORLD: + + return false; + + } + + return true; + +}; + +PositionNode.prototype.generate = function ( builder, output ) { + + var result; + + switch ( this.scope ) { + + case PositionNode.LOCAL: + + builder.requires.position = true; + + result = builder.isShader( 'vertex' ) ? 'transformed' : 'vPosition'; + + break; + + case PositionNode.WORLD: + + builder.requires.worldPosition = true; + + result = 'vWPosition'; + + break; + + case PositionNode.VIEW: + + result = builder.isShader( 'vertex' ) ? '-mvPosition.xyz' : 'vViewPosition'; + + break; + + case PositionNode.PROJECTION: + + result = builder.isShader( 'vertex' ) ? '( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )' : 'vec4( 0.0 )'; + + break; + + } + + return builder.format( result, this.getType( builder ), output ); + +}; + +PositionNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.scope = source.scope; + +}; + +PositionNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.scope = this.scope; + + } + + return data; + +}; + +NodeLib.addKeyword( 'position', function () { + + return new PositionNode(); + +} ); + +NodeLib.addKeyword( 'worldPosition', function () { + + return new PositionNode( PositionNode.WORLD ); + +} ); + +NodeLib.addKeyword( 'viewPosition', function () { + + return new PositionNode( NormalNode.VIEW ); + +} ); + +export { PositionNode }; diff --git a/three/jsutil/nodes/accessors/ReflectNode.js b/three/jsutil/nodes/accessors/ReflectNode.js new file mode 100644 index 000000000..bc6cc7b17 --- /dev/null +++ b/three/jsutil/nodes/accessors/ReflectNode.js @@ -0,0 +1,103 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function ReflectNode( scope ) { + + TempNode.call( this, 'v3', { unique: true } ); + + this.scope = scope || ReflectNode.CUBE; + +} + +ReflectNode.CUBE = 'cube'; +ReflectNode.SPHERE = 'sphere'; +ReflectNode.VECTOR = 'vector'; + +ReflectNode.prototype = Object.create( TempNode.prototype ); +ReflectNode.prototype.constructor = ReflectNode; +ReflectNode.prototype.nodeType = "Reflect"; + +ReflectNode.prototype.getType = function ( builder ) { + + switch ( this.scope ) { + + case ReflectNode.SPHERE: + + return 'v2'; + + } + + return this.type; + +}; + +ReflectNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + var result; + + switch ( this.scope ) { + + case ReflectNode.VECTOR: + + builder.addNodeCode( 'vec3 reflectVec = inverseTransformDirection( reflect( -normalize( vViewPosition ), normal ), viewMatrix );' ); + + result = 'reflectVec'; + + break; + + case ReflectNode.CUBE: + + var reflectVec = new ReflectNode( ReflectNode.VECTOR ).build( builder, 'v3' ); + + builder.addNodeCode( 'vec3 reflectCubeVec = vec3( -1.0 * ' + reflectVec + '.x, ' + reflectVec + '.yz );' ); + + result = 'reflectCubeVec'; + + break; + + case ReflectNode.SPHERE: + + var reflectVec = new ReflectNode( ReflectNode.VECTOR ).build( builder, 'v3' ); + + builder.addNodeCode( 'vec2 reflectSphereVec = normalize( ( viewMatrix * vec4( ' + reflectVec + ', 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5;' ); + + result = 'reflectSphereVec'; + + break; + + } + + return builder.format( result, this.getType( builder ), output ); + + } else { + + console.warn( "THREE.ReflectNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec3( 0.0 )', this.type, output ); + + } + +}; + +ReflectNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.scope = this.scope; + + } + + return data; + +}; + +export { ReflectNode }; diff --git a/three/jsutil/nodes/accessors/ResolutionNode.js b/three/jsutil/nodes/accessors/ResolutionNode.js new file mode 100644 index 000000000..c6225bc75 --- /dev/null +++ b/three/jsutil/nodes/accessors/ResolutionNode.js @@ -0,0 +1,59 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Vector2Node } from '../inputs/Vector2Node.js'; + +function ResolutionNode() { + + Vector2Node.call( this ); + +} + +ResolutionNode.prototype = Object.create( Vector2Node.prototype ); +ResolutionNode.prototype.constructor = ResolutionNode; +ResolutionNode.prototype.nodeType = "Resolution"; + +ResolutionNode.prototype.updateFrame = function ( frame ) { + + if ( frame.renderer ) { + + var size = frame.renderer.getSize(), + pixelRatio = frame.renderer.getPixelRatio(); + + this.x = size.width * pixelRatio; + this.y = size.height * pixelRatio; + + } else { + + console.warn( "ResolutionNode need a renderer in NodeFrame" ); + + } + +}; + +ResolutionNode.prototype.copy = function ( source ) { + + Vector2Node.prototype.copy.call( this, source ); + + this.renderer = source.renderer; + +}; + +ResolutionNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.renderer = this.renderer.uuid; + + } + + return data; + +}; + +export { ResolutionNode }; diff --git a/three/jsutil/nodes/accessors/ScreenUVNode.js b/three/jsutil/nodes/accessors/ScreenUVNode.js new file mode 100644 index 000000000..a2aac5f01 --- /dev/null +++ b/three/jsutil/nodes/accessors/ScreenUVNode.js @@ -0,0 +1,65 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { ResolutionNode } from './ResolutionNode.js'; + +function ScreenUVNode( resolution ) { + + TempNode.call( this, 'v2' ); + + this.resolution = resolution || new ResolutionNode(); + +} + +ScreenUVNode.prototype = Object.create( TempNode.prototype ); +ScreenUVNode.prototype.constructor = ScreenUVNode; +ScreenUVNode.prototype.nodeType = "ScreenUV"; + +ScreenUVNode.prototype.generate = function ( builder, output ) { + + var result; + + if ( builder.isShader( 'fragment' ) ) { + + result = '( gl_FragCoord.xy / ' + this.resolution.build( builder, 'v2' ) + ')'; + + } else { + + console.warn( "THREE.ScreenUVNode is not compatible with " + builder.shader + " shader." ); + + result = 'vec2( 0.0 )'; + + } + + return builder.format( result, this.getType( builder ), output ); + +}; + +ScreenUVNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.resolution = source.resolution; + +}; + +ScreenUVNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.resolution = this.resolution.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { ScreenUVNode }; + diff --git a/three/jsutil/nodes/accessors/UVNode.js b/three/jsutil/nodes/accessors/UVNode.js new file mode 100644 index 000000000..2753d1fe3 --- /dev/null +++ b/three/jsutil/nodes/accessors/UVNode.js @@ -0,0 +1,69 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { NodeLib } from '../core/NodeLib.js'; + +var vertexDict = [ 'uv', 'uv2' ], + fragmentDict = [ 'vUv', 'vUv2' ]; + +function UVNode( index ) { + + TempNode.call( this, 'v2', { shared: false } ); + + this.index = index || 0; + +} + +UVNode.prototype = Object.create( TempNode.prototype ); +UVNode.prototype.constructor = UVNode; +UVNode.prototype.nodeType = "UV"; + +UVNode.prototype.generate = function ( builder, output ) { + + builder.requires.uv[ this.index ] = true; + + var result = builder.isShader( 'vertex' ) ? vertexDict[ this.index ] : fragmentDict[ this.index ]; + + return builder.format( result, this.getType( builder ), output ); + +}; + +UVNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.index = source.index; + +}; + +UVNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.index = this.index; + + } + + return data; + +}; + +NodeLib.addKeyword( 'uv', function () { + + return new UVNode(); + +} ); + +NodeLib.addKeyword( 'uv2', function () { + + return new UVNode( 1 ); + +} ); + +export { UVNode }; diff --git a/three/jsutil/nodes/bsdfs/BlinnExponentToRoughnessNode.js b/three/jsutil/nodes/bsdfs/BlinnExponentToRoughnessNode.js new file mode 100644 index 000000000..d5d429085 --- /dev/null +++ b/three/jsutil/nodes/bsdfs/BlinnExponentToRoughnessNode.js @@ -0,0 +1,50 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { BlinnShininessExponentNode } from './BlinnShininessExponentNode.js'; + +function BlinnExponentToRoughnessNode( blinnExponent ) { + + TempNode.call( this, 'f' ); + + this.blinnExponent = blinnExponent || new BlinnShininessExponentNode(); + +} + +BlinnExponentToRoughnessNode.prototype = Object.create( TempNode.prototype ); +BlinnExponentToRoughnessNode.prototype.constructor = BlinnExponentToRoughnessNode; +BlinnExponentToRoughnessNode.prototype.nodeType = "BlinnExponentToRoughness"; + +BlinnExponentToRoughnessNode.prototype.generate = function ( builder, output ) { + + return builder.format( 'BlinnExponentToGGXRoughness( ' + this.blinnExponent.build( builder, 'f' ) + ' )', this.type, output ); + +}; + +BlinnExponentToRoughnessNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.blinnExponent = source.blinnExponent; + +}; + +BlinnExponentToRoughnessNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.blinnExponent = this.blinnExponent; + + } + + return data; + +}; + +export { BlinnExponentToRoughnessNode }; diff --git a/three/jsutil/nodes/bsdfs/BlinnShininessExponentNode.js b/three/jsutil/nodes/bsdfs/BlinnShininessExponentNode.js new file mode 100644 index 000000000..b21e7d0ca --- /dev/null +++ b/three/jsutil/nodes/bsdfs/BlinnShininessExponentNode.js @@ -0,0 +1,31 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function BlinnShininessExponentNode() { + + TempNode.call( this, 'f' ); + +} + +BlinnShininessExponentNode.prototype = Object.create( TempNode.prototype ); +BlinnShininessExponentNode.prototype.constructor = BlinnShininessExponentNode; +BlinnShininessExponentNode.prototype.nodeType = "BlinnShininessExponent"; + +BlinnShininessExponentNode.prototype.generate = function ( builder, output ) { + + if ( builder.isCache( 'clearCoat' ) ) { + + return builder.format( 'Material_ClearCoat_BlinnShininessExponent( material )', this.type, output ); + + } else { + + return builder.format( 'Material_BlinnShininessExponent( material )', this.type, output ); + + } + +}; + +export { BlinnShininessExponentNode }; diff --git a/three/jsutil/nodes/bsdfs/RoughnessToBlinnExponentNode.js b/three/jsutil/nodes/bsdfs/RoughnessToBlinnExponentNode.js new file mode 100644 index 000000000..e0811d70d --- /dev/null +++ b/three/jsutil/nodes/bsdfs/RoughnessToBlinnExponentNode.js @@ -0,0 +1,92 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { MaxMIPLevelNode } from '../utils/MaxMIPLevelNode.js'; +import { BlinnShininessExponentNode } from './BlinnShininessExponentNode.js'; + +function RoughnessToBlinnExponentNode( texture ) { + + TempNode.call( this, 'f' ); + + this.texture = texture; + + this.maxMIPLevel = new MaxMIPLevelNode( texture ); + this.blinnShininessExponent = new BlinnShininessExponentNode(); + +} + +RoughnessToBlinnExponentNode.Nodes = ( function () { + + var getSpecularMIPLevel = new FunctionNode( [ + // taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html + "float getSpecularMIPLevel( const in float blinnShininessExponent, const in float maxMIPLevelScalar ) {", + + // float envMapWidth = pow( 2.0, maxMIPLevelScalar ); + // float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 ); + + " float desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );", + + // clamp to allowable LOD ranges. + " return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );", + + "}" + ].join( "\n" ) ); + + return { + getSpecularMIPLevel: getSpecularMIPLevel + }; + +} )(); + +RoughnessToBlinnExponentNode.prototype = Object.create( TempNode.prototype ); +RoughnessToBlinnExponentNode.prototype.constructor = RoughnessToBlinnExponentNode; +RoughnessToBlinnExponentNode.prototype.nodeType = "RoughnessToBlinnExponent"; + +RoughnessToBlinnExponentNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + this.maxMIPLevel.texture = this.texture; + + var getSpecularMIPLevel = builder.include( RoughnessToBlinnExponentNode.Nodes.getSpecularMIPLevel ); + + return builder.format( getSpecularMIPLevel + '( ' + this.blinnShininessExponent.build( builder, 'f' ) + ', ' + this.maxMIPLevel.build( builder, 'f' ) + ' )', this.type, output ); + + } else { + + console.warn( "THREE.RoughnessToBlinnExponentNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( '0.0', this.type, output ); + + } + +}; + +RoughnessToBlinnExponentNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.texture = source.texture; + +}; + +RoughnessToBlinnExponentNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.texture = this.texture; + + } + + return data; + +}; + +export { RoughnessToBlinnExponentNode }; diff --git a/three/jsutil/nodes/core/AttributeNode.js b/three/jsutil/nodes/core/AttributeNode.js new file mode 100644 index 000000000..7941d0eaa --- /dev/null +++ b/three/jsutil/nodes/core/AttributeNode.js @@ -0,0 +1,70 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from './Node.js'; + +function AttributeNode( name, type ) { + + Node.call( this, type ); + + this.name = name; + +} + +AttributeNode.prototype = Object.create( Node.prototype ); +AttributeNode.prototype.constructor = AttributeNode; +AttributeNode.prototype.nodeType = "Attribute"; + +AttributeNode.prototype.getAttributeType = function ( builder ) { + + return typeof this.type === 'number' ? builder.getConstructorFromLength( this.type ) : this.type; + +}; + +AttributeNode.prototype.getType = function ( builder ) { + + var type = this.getAttributeType( builder ); + + return builder.getTypeByFormat( type ); + +}; + +AttributeNode.prototype.generate = function ( builder, output ) { + + var type = this.getAttributeType( builder ); + + var attribute = builder.getAttribute( this.name, type ), + name = builder.isShader( 'vertex' ) ? this.name : attribute.varying.name; + + console.log( attribute ); + + return builder.format( name, this.getType( builder ), output ); + +}; + +AttributeNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + this.type = source.type; + +}; + +AttributeNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.type = this.type; + + } + + return data; + +}; + +export { AttributeNode }; diff --git a/three/jsutil/nodes/core/ConstNode.js b/three/jsutil/nodes/core/ConstNode.js new file mode 100644 index 000000000..8736b86f2 --- /dev/null +++ b/three/jsutil/nodes/core/ConstNode.js @@ -0,0 +1,125 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from './TempNode.js'; + +var declarationRegexp = /^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i; + +function ConstNode( src, useDefine ) { + + TempNode.call( this ); + + this.eval( src || ConstNode.PI, useDefine ); + +} + +ConstNode.PI = 'PI'; +ConstNode.PI2 = 'PI2'; +ConstNode.RECIPROCAL_PI = 'RECIPROCAL_PI'; +ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2'; +ConstNode.LOG2 = 'LOG2'; +ConstNode.EPSILON = 'EPSILON'; + +ConstNode.prototype = Object.create( TempNode.prototype ); +ConstNode.prototype.constructor = ConstNode; +ConstNode.prototype.nodeType = "Const"; + +ConstNode.prototype.getType = function ( builder ) { + + return builder.getTypeByFormat( this.type ); + +}; + +ConstNode.prototype.eval = function ( src, useDefine ) { + + this.src = src || ''; + + var name, type, value = ""; + + var match = this.src.match( declarationRegexp ); + + this.useDefine = useDefine || this.src.charAt( 0 ) === '#'; + + if ( match && match.length > 1 ) { + + type = match[ 1 ]; + name = match[ 2 ]; + value = match[ 3 ]; + + } else { + + name = this.src; + type = 'f'; + + } + + this.name = name; + this.type = type; + this.value = value; + +}; + +ConstNode.prototype.build = function ( builder, output ) { + + if ( output === 'source' ) { + + if ( this.value ) { + + if ( this.useDefine ) { + + return '#define ' + this.name + ' ' + this.value; + + } + + return 'const ' + this.type + ' ' + this.name + ' = ' + this.value + ';'; + + } else if ( this.useDefine ) { + + return this.src; + + } + + } else { + + builder.include( this ); + + return builder.format( this.name, this.getType( builder ), output ); + + } + +}; + +ConstNode.prototype.generate = function ( builder, output ) { + + return builder.format( this.name, this.getType( builder ), output ); + +}; + +ConstNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.eval( source.src, source.useDefine ); + +}; + +ConstNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.src = this.src; + + if ( data.useDefine === true ) data.useDefine = true; + + } + + return data; + +}; + +export { ConstNode }; diff --git a/three/jsutil/nodes/core/ExpressionNode.js b/three/jsutil/nodes/core/ExpressionNode.js new file mode 100644 index 000000000..064d00bc3 --- /dev/null +++ b/three/jsutil/nodes/core/ExpressionNode.js @@ -0,0 +1,17 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { FunctionNode } from './FunctionNode.js'; + +function ExpressionNode( src, type, keywords, extensions, includes ) { + + FunctionNode.call( this, src, includes, extensions, keywords, type ); + +} + +ExpressionNode.prototype = Object.create( FunctionNode.prototype ); +ExpressionNode.prototype.constructor = ExpressionNode; +ExpressionNode.prototype.nodeType = "Expression"; + +export { ExpressionNode }; diff --git a/three/jsutil/nodes/core/FunctionCallNode.js b/three/jsutil/nodes/core/FunctionCallNode.js new file mode 100644 index 000000000..bc5417895 --- /dev/null +++ b/three/jsutil/nodes/core/FunctionCallNode.js @@ -0,0 +1,108 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from './TempNode.js'; + +function FunctionCallNode( func, inputs ) { + + TempNode.call( this ); + + this.setFunction( func, inputs ); + +} + +FunctionCallNode.prototype = Object.create( TempNode.prototype ); +FunctionCallNode.prototype.constructor = FunctionCallNode; +FunctionCallNode.prototype.nodeType = "FunctionCall"; + +FunctionCallNode.prototype.setFunction = function ( func, inputs ) { + + this.value = func; + this.inputs = inputs || []; + +}; + +FunctionCallNode.prototype.getFunction = function () { + + return this.value; + +}; + +FunctionCallNode.prototype.getType = function ( builder ) { + + return this.value.getType( builder ); + +}; + +FunctionCallNode.prototype.generate = function ( builder, output ) { + + var type = this.getType( builder ), + func = this.value; + + var code = func.build( builder, output ) + '( ', + params = []; + + for ( var i = 0; i < func.inputs.length; i ++ ) { + + var inpt = func.inputs[ i ], + param = this.inputs[ i ] || this.inputs[ inpt.name ]; + + params.push( param.build( builder, builder.getTypeByFormat( inpt.type ) ) ); + + } + + code += params.join( ', ' ) + ' )'; + + return builder.format( code, type, output ); + +}; + +FunctionCallNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + for ( var prop in source.inputs ) { + + this.inputs[ prop ] = source.inputs[ prop ]; + + } + + this.value = source.value; + +}; + +FunctionCallNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + var func = this.value; + + data = this.createJSONNode( meta ); + + data.value = this.value.toJSON( meta ).uuid; + + if ( func.inputs.length ) { + + data.inputs = {}; + + for ( var i = 0; i < func.inputs.length; i ++ ) { + + var inpt = func.inputs[ i ], + node = this.inputs[ i ] || this.inputs[ inpt.name ]; + + data.inputs[ inpt.name ] = node.toJSON( meta ).uuid; + + } + + } + + } + + return data; + +}; + +export { FunctionCallNode }; diff --git a/three/jsutil/nodes/core/FunctionNode.js b/three/jsutil/nodes/core/FunctionNode.js new file mode 100644 index 000000000..a183b3210 --- /dev/null +++ b/three/jsutil/nodes/core/FunctionNode.js @@ -0,0 +1,266 @@ +/** + * @author sunag / http://www.sunag.com.br/ + * @thanks bhouston / https://clara.io/ + */ + +import { TempNode } from './TempNode.js'; +import { NodeLib } from './NodeLib.js'; + +var declarationRegexp = /^([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i, + propertiesRegexp = /[a-z_0-9]+/ig; + +function FunctionNode( src, includes, extensions, keywords, type ) { + + this.isMethod = type === undefined; + + TempNode.call( this, type ); + + this.eval( src, includes, extensions, keywords ); + +} + +FunctionNode.prototype = Object.create( TempNode.prototype ); +FunctionNode.prototype.constructor = FunctionNode; +FunctionNode.prototype.nodeType = "Function"; + +FunctionNode.prototype.useKeywords = true; + +FunctionNode.prototype.isShared = function ( builder, output ) { + + return ! this.isMethod; + +}; + +FunctionNode.prototype.getType = function ( builder ) { + + return builder.getTypeByFormat( this.type ); + +}; + +FunctionNode.prototype.getInputByName = function ( name ) { + + var i = this.inputs.length; + + while ( i -- ) { + + if ( this.inputs[ i ].name === name ) { + + return this.inputs[ i ]; + + } + + } + +}; + +FunctionNode.prototype.getIncludeByName = function ( name ) { + + var i = this.includes.length; + + while ( i -- ) { + + if ( this.includes[ i ].name === name ) { + + return this.includes[ i ]; + + } + + } + +}; + +FunctionNode.prototype.generate = function ( builder, output ) { + + var match, offset = 0, src = this.src; + + for ( var i = 0; i < this.includes.length; i ++ ) { + + builder.include( this.includes[ i ], this ); + + } + + for ( var ext in this.extensions ) { + + builder.extensions[ ext ] = true; + + } + + while ( match = propertiesRegexp.exec( this.src ) ) { + + var prop = match[ 0 ], + isGlobal = this.isMethod ? ! this.getInputByName( prop ) : true, + reference = prop; + + if ( this.keywords[ prop ] || ( this.useKeywords && isGlobal && NodeLib.containsKeyword( prop ) ) ) { + + var node = this.keywords[ prop ]; + + if ( ! node ) { + + var keyword = NodeLib.getKeywordData( prop ); + + if ( keyword.cache ) node = builder.keywords[ prop ]; + + node = node || NodeLib.getKeyword( prop, builder ); + + if ( keyword.cache ) builder.keywords[ prop ] = node; + + } + + reference = node.build( builder ); + + } + + if ( prop != reference ) { + + src = src.substring( 0, match.index + offset ) + reference + src.substring( match.index + prop.length + offset ); + + offset += reference.length - prop.length; + + } + + if ( this.getIncludeByName( reference ) === undefined && NodeLib.contains( reference ) ) { + + builder.include( NodeLib.get( reference ) ); + + } + + } + + if ( output === 'source' ) { + + return src; + + } else if ( this.isMethod ) { + + builder.include( this, false, src ); + + return this.name; + + } else { + + return builder.format( '( ' + src + ' )', this.getType( builder ), output ); + + } + +}; + +FunctionNode.prototype.eval = function ( src, includes, extensions, keywords ) { + + this.src = src || ''; + + this.includes = includes || []; + this.extensions = extensions || {}; + this.keywords = keywords || {}; + + if ( this.isMethod ) { + + var match = this.src.match( declarationRegexp ); + + this.inputs = []; + + if ( match && match.length == 4 ) { + + this.type = match[ 1 ]; + this.name = match[ 2 ]; + + var inputs = match[ 3 ].match( propertiesRegexp ); + + if ( inputs ) { + + var i = 0; + + while ( i < inputs.length ) { + + var qualifier = inputs[ i ++ ]; + var type, name; + + if ( qualifier == 'in' || qualifier == 'out' || qualifier == 'inout' ) { + + type = inputs[ i ++ ]; + + } else { + + type = qualifier; + qualifier = ''; + + } + + name = inputs[ i ++ ]; + + this.inputs.push( { + name: name, + type: type, + qualifier: qualifier + } ); + + } + + } + + } else { + + this.type = ''; + this.name = ''; + + } + + } + +}; + +FunctionNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.isMethod = source.isMethod; + this.useKeywords = source.useKeywords; + + this.eval( source.src, source.includes, source.extensions, source.keywords ); + + if ( source.type !== undefined ) this.type = source.type; + +}; + +FunctionNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.src = this.src; + data.isMethod = this.isMethod; + data.useKeywords = this.useKeywords; + + if ( ! this.isMethod ) data.type = this.type; + + data.extensions = JSON.parse( JSON.stringify( this.extensions ) ); + data.keywords = {}; + + for ( var keyword in this.keywords ) { + + data.keywords[ keyword ] = this.keywords[ keyword ].toJSON( meta ).uuid; + + } + + if ( this.includes.length ) { + + data.includes = []; + + for ( var i = 0; i < this.includes.length; i ++ ) { + + data.includes.push( this.includes[ i ].toJSON( meta ).uuid ); + + } + + } + + } + + return data; + +}; + +export { FunctionNode }; diff --git a/three/jsutil/nodes/core/InputNode.js b/three/jsutil/nodes/core/InputNode.js new file mode 100644 index 000000000..ce635b65b --- /dev/null +++ b/three/jsutil/nodes/core/InputNode.js @@ -0,0 +1,85 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from './TempNode.js'; + +function InputNode( type, params ) { + + params = params || {}; + params.shared = params.shared !== undefined ? params.shared : false; + + TempNode.call( this, type, params ); + + this.readonly = false; + +} + +InputNode.prototype = Object.create( TempNode.prototype ); +InputNode.prototype.constructor = InputNode; + +InputNode.prototype.isReadonly = function ( builder ) { + + return this.readonly; + +}; + +InputNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + if ( source.readonly !== undefined ) this.readonly = source.readonly; + +}; + +InputNode.prototype.createJSONNode = function ( meta ) { + + var data = TempNode.prototype.createJSONNode.call( this, meta ); + + if ( this.readonly === true ) data.readonly = this.readonly; + + return data; + +}; + +InputNode.prototype.generate = function ( builder, output, uuid, type, ns, needsUpdate ) { + + uuid = builder.getUuid( uuid || this.getUuid() ); + type = type || this.getType( builder ); + + var data = builder.getNodeData( uuid ), + readonly = this.isReadonly( builder ) && this.generateReadonly !== undefined; + + if ( readonly ) { + + return this.generateReadonly( builder, output, uuid, type, ns, needsUpdate ); + + } else { + + if ( builder.isShader( 'vertex' ) ) { + + if ( ! data.vertex ) { + + data.vertex = builder.createVertexUniform( type, this, ns, needsUpdate ); + + } + + return builder.format( data.vertex.name, type, output ); + + } else { + + if ( ! data.fragment ) { + + data.fragment = builder.createFragmentUniform( type, this, ns, needsUpdate ); + + } + + return builder.format( data.fragment.name, type, output ); + + } + + } + +}; + +export { InputNode }; diff --git a/three/jsutil/nodes/core/Node.js b/three/jsutil/nodes/core/Node.js new file mode 100644 index 000000000..f52dd9e04 --- /dev/null +++ b/three/jsutil/nodes/core/Node.js @@ -0,0 +1,180 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +function Node( type ) { + + this.uuid = THREE.Math.generateUUID(); + + this.name = ""; + + this.type = type; + + this.userData = {}; + +} + +Node.prototype = { + + constructor: Node, + + isNode: true, + + parse: function ( builder, settings ) { + + settings = settings || {}; + + builder.parsing = true; + + this.build( builder.addFlow( settings.slot, settings.cache, settings.context ), 'v4' ); + + builder.clearVertexNodeCode(); + builder.clearFragmentNodeCode(); + + builder.removeFlow(); + + builder.parsing = false; + + }, + + parseAndBuildCode: function ( builder, output, settings ) { + + settings = settings || {}; + + this.parse( builder, settings ); + + return this.buildCode( builder, output, settings ); + + }, + + buildCode: function ( builder, output, settings ) { + + settings = settings || {}; + + var data = { result: this.build( builder.addFlow( settings.slot, settings.cache, settings.context ), output ) }; + + data.code = builder.clearNodeCode(); + + builder.removeFlow(); + + return data; + + }, + + build: function ( builder, output, uuid ) { + + output = output || this.getType( builder, output ); + + var data = builder.getNodeData( uuid || this ); + + if ( builder.parsing ) { + + this.appendDepsNode( builder, data, output ); + + } + + if ( builder.nodes.indexOf( this ) === - 1 ) { + + builder.nodes.push( this ); + + } + + if ( this.updateFrame !== undefined && builder.updaters.indexOf( this ) === - 1 ) { + + builder.updaters.push( this ); + + } + + return this.generate( builder, output, uuid ); + + }, + + appendDepsNode: function ( builder, data, output ) { + + data.deps = ( data.deps || 0 ) + 1; + + var outputLen = builder.getTypeLength( output ); + + if ( outputLen > ( data.outputMax || 0 ) || this.getType( builder, output ) ) { + + data.outputMax = outputLen; + data.output = output; + + } + + }, + + setName: function ( name ) { + + this.name = name; + + return this; + + }, + + getName: function ( builder ) { + + return this.name; + + }, + + getType: function ( builder, output ) { + + return output === 'sampler2D' || output === 'samplerCube' ? output : this.type; + + }, + + getJSONNode: function ( meta ) { + + var isRootObject = ( meta === undefined || typeof meta === 'string' ); + + if ( ! isRootObject && meta.nodes[ this.uuid ] !== undefined ) { + + return meta.nodes[ this.uuid ]; + + } + + }, + + copy: function ( source ) { + + if ( source.name !== undefined ) this.name = source.name; + + if ( source.userData !== undefined ) this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + }, + + createJSONNode: function ( meta ) { + + var isRootObject = ( meta === undefined || typeof meta === 'string' ); + + var data = {}; + + if ( typeof this.nodeType !== "string" ) throw new Error( "Node does not allow serialization." ); + + data.uuid = this.uuid; + data.nodeType = this.nodeType; + + if ( this.name !== "" ) data.name = this.name; + + if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; + + if ( ! isRootObject ) { + + meta.nodes[ this.uuid ] = data; + + } + + return data; + + }, + + toJSON: function ( meta ) { + + return this.getJSONNode( meta ) || this.createJSONNode( meta ); + + } + +}; + +export { Node }; diff --git a/three/jsutil/nodes/core/NodeBuilder.js b/three/jsutil/nodes/core/NodeBuilder.js new file mode 100644 index 000000000..1277ecdba --- /dev/null +++ b/three/jsutil/nodes/core/NodeBuilder.js @@ -0,0 +1,958 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { NodeUniform } from './NodeUniform.js'; +import { NodeUtils } from './NodeUtils.js'; +import { NodeLib } from './NodeLib.js'; +import { FunctionNode } from './FunctionNode.js'; +import { ConstNode } from './ConstNode.js'; +import { StructNode } from './StructNode.js'; +import { Vector2Node } from '../inputs/Vector2Node.js'; +import { Vector3Node } from '../inputs/Vector3Node.js'; +import { Vector4Node } from '../inputs/Vector4Node.js'; +import { TextureNode } from '../inputs/TextureNode.js'; +import { CubeTextureNode } from '../inputs/CubeTextureNode.js'; + +var elements = NodeUtils.elements, + constructors = [ 'float', 'vec2', 'vec3', 'vec4' ], + convertFormatToType = { + float: 'f', + vec2: 'v2', + vec3: 'v3', + vec4: 'v4', + mat4: 'v4', + int: 'i' + }, + convertTypeToFormat = { + t: 'sampler2D', + tc: 'samplerCube', + b: 'bool', + i: 'int', + f: 'float', + c: 'vec3', + v2: 'vec2', + v3: 'vec3', + v4: 'vec4', + m3: 'mat3', + m4: 'mat4' + }; + +function NodeBuilder() { + + this.slots = []; + this.caches = []; + this.contexts = []; + + this.keywords = {}; + + this.nodeData = {}; + + this.requires = { + uv: [], + color: [], + lights: false, + fog: false + }; + + this.includes = { + consts: [], + functions: [], + structs: [] + }; + + this.attributes = {}; + + this.prefixCode = [ + "#ifdef TEXTURE_LOD_EXT", + + " #define texCube(a, b) textureCube(a, b)", + " #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)", + + " #define tex2D(a, b) texture2D(a, b)", + " #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)", + + "#else", + + " #define texCube(a, b) textureCube(a, b)", + " #define texCubeBias(a, b, c) textureCube(a, b, c)", + + " #define tex2D(a, b) texture2D(a, b)", + " #define tex2DBias(a, b, c) texture2D(a, b, c)", + + "#endif", + + "#include ", + "#include " + + ].join( "\n" ); + + this.parsCode = { + vertex: '', + fragment: '' + }; + + this.code = { + vertex: '', + fragment: '' + }; + + this.nodeCode = { + vertex: '', + fragment: '' + }; + + this.resultCode = { + vertex: '', + fragment: '' + }; + + this.finalCode = { + vertex: '', + fragment: '' + }; + + this.inputs = { + uniforms: { + list: [], + vertex: [], + fragment: [] + }, + vars: { + varying: [], + vertex: [], + fragment: [] + } + }; + + // send to material + + this.defines = {}; + + this.uniforms = {}; + + this.extensions = {}; + + this.updaters = []; + + this.nodes = []; + + // -- + + this.parsing = false; + this.optimize = true; + +} + +NodeBuilder.prototype = { + + constructor: NodeBuilder, + + build: function ( vertex, fragment ) { + + this.buildShader( 'vertex', vertex ); + this.buildShader( 'fragment', fragment ); + + if ( this.requires.uv[ 0 ] ) { + + this.addVaryCode( 'varying vec2 vUv;' ); + + this.addVertexFinalCode( 'vUv = uv;' ); + + } + + if ( this.requires.uv[ 1 ] ) { + + this.addVaryCode( 'varying vec2 vUv2;' ); + this.addVertexParsCode( 'attribute vec2 uv2;' ); + + this.addVertexFinalCode( 'vUv2 = uv2;' ); + + } + + if ( this.requires.color[ 0 ] ) { + + this.addVaryCode( 'varying vec4 vColor;' ); + this.addVertexParsCode( 'attribute vec4 color;' ); + + this.addVertexFinalCode( 'vColor = color;' ); + + } + + if ( this.requires.color[ 1 ] ) { + + this.addVaryCode( 'varying vec4 vColor2;' ); + this.addVertexParsCode( 'attribute vec4 color2;' ); + + this.addVertexFinalCode( 'vColor2 = color2;' ); + + } + + if ( this.requires.position ) { + + this.addVaryCode( 'varying vec3 vPosition;' ); + + this.addVertexFinalCode( 'vPosition = transformed;' ); + + } + + if ( this.requires.worldPosition ) { + + this.addVaryCode( 'varying vec3 vWPosition;' ); + + this.addVertexFinalCode( 'vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;' ); + + } + + if ( this.requires.normal ) { + + this.addVaryCode( 'varying vec3 vObjectNormal;' ); + + this.addVertexFinalCode( 'vObjectNormal = normal;' ); + + } + + if ( this.requires.worldNormal ) { + + this.addVaryCode( 'varying vec3 vWNormal;' ); + + this.addVertexFinalCode( 'vWNormal = ( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz;' ); + + } + + return this; + + }, + + buildShader: function ( shader, node ) { + + this.resultCode[ shader ] = node.build( this.setShader( shader ), 'v4' ); + + }, + + setMaterial: function ( material, renderer ) { + + this.material = material; + this.renderer = renderer; + + this.requires.lights = material.lights; + this.requires.fog = material.fog; + + this.mergeDefines( material.defines ); + + return this; + + }, + + addFlow: function ( slot, cache, context ) { + + return this.addSlot( slot ).addCache( cache ).addContext( context ); + + }, + + removeFlow: function () { + + return this.removeSlot().removeCache().removeContext(); + + }, + + addCache: function ( name ) { + + this.cache = name || ''; + this.caches.push( this.cache ); + + return this; + + }, + + removeCache: function () { + + this.caches.pop(); + this.cache = this.caches[ this.caches.length - 1 ] || ''; + + return this; + + }, + + addContext: function ( context ) { + + this.context = Object.assign( {}, this.context, context ); + this.contexts.push( this.context ); + + return this; + + }, + + removeContext: function () { + + this.contexts.pop(); + this.context = this.contexts[ this.contexts.length - 1 ] || {}; + + return this; + + }, + + addSlot: function ( name ) { + + this.slot = name || ''; + this.slots.push( this.slot ); + + return this; + + }, + + removeSlot: function () { + + this.slots.pop(); + this.slot = this.slots[ this.slots.length - 1 ] || ''; + + return this; + + }, + + + addVertexCode: function ( code ) { + + this.addCode( code, 'vertex' ); + + }, + + addFragmentCode: function ( code ) { + + this.addCode( code, 'fragment' ); + + }, + + addCode: function ( code, shader ) { + + this.code[ shader || this.shader ] += code + '\n'; + + }, + + + addVertexNodeCode: function ( code ) { + + this.addNodeCode( code, 'vertex' ); + + }, + + addFragmentNodeCode: function ( code ) { + + this.addNodeCode( code, 'fragment' ); + + }, + + addNodeCode: function ( code, shader ) { + + this.nodeCode[ shader || this.shader ] += code + '\n'; + + }, + + clearNodeCode: function ( shader ) { + + shader = shader || this.shader; + + var code = this.nodeCode[ shader ]; + + this.nodeCode[ shader ] = ''; + + return code; + + }, + + clearVertexNodeCode: function ( ) { + + return this.clearNodeCode( 'vertex' ); + + }, + + clearFragmentNodeCode: function ( ) { + + return this.clearNodeCode( 'fragment' ); + + }, + + addVertexFinalCode: function ( code ) { + + this.addFinalCode( code, 'vertex' ); + + }, + + addFragmentFinalCode: function ( code ) { + + this.addFinalCode( code, 'fragment' ); + + }, + + addFinalCode: function ( code, shader ) { + + this.finalCode[ shader || this.shader ] += code + '\n'; + + }, + + + addVertexParsCode: function ( code ) { + + this.addParsCode( code, 'vertex' ); + + }, + + addFragmentParsCode: function ( code ) { + + this.addParsCode( code, 'fragment' ); + + }, + + addParsCode: function ( code, shader ) { + + this.parsCode[ shader || this.shader ] += code + '\n'; + + }, + + + addVaryCode: function ( code ) { + + this.addVertexParsCode( code ); + this.addFragmentParsCode( code ); + + }, + + + isCache: function ( name ) { + + return this.caches.indexOf( name ) !== - 1; + + }, + + isSlot: function ( name ) { + + return this.slots.indexOf( name ) !== - 1; + + }, + + define: function ( name, value ) { + + this.defines[ name ] = value === undefined ? 1 : value; + + }, + + isDefined: function ( name ) { + + return this.defines[ name ] !== undefined; + + }, + + getVar: function ( uuid, type, ns, shader ) { + + shader = shader || 'varying'; + + var vars = this.getVars( shader ), + data = vars[ uuid ]; + + if ( ! data ) { + + var index = vars.length, + name = ns ? ns : 'nVv' + index; + + data = { name: name, type: type }; + + vars.push( data ); + vars[ uuid ] = data; + + } + + return data; + + }, + + getTempVar: function ( uuid, type, ns ) { + + return this.getVar( uuid, type, ns, this.shader ); + + }, + + getAttribute: function ( name, type ) { + + if ( ! this.attributes[ name ] ) { + + var varying = this.getVar( name, type ); + + this.addVertexParsCode( 'attribute ' + type + ' ' + name + ';' ); + this.addVertexFinalCode( varying.name + ' = ' + name + ';' ); + + this.attributes[ name ] = { varying: varying, name: name, type: type }; + + } + + return this.attributes[ name ]; + + }, + + getCode: function ( shader ) { + + return [ + this.prefixCode, + this.parsCode[ shader ], + this.getVarListCode( this.getVars( 'varying' ), 'varying' ), + this.getVarListCode( this.inputs.uniforms[ shader ], 'uniform' ), + this.getIncludesCode( 'consts', shader ), + this.getIncludesCode( 'structs', shader ), + this.getIncludesCode( 'functions', shader ), + 'void main() {', + this.getVarListCode( this.getVars( shader ) ), + this.code[ shader ], + this.resultCode[ shader ], + this.finalCode[ shader ], + '}' + ].join( "\n" ); + + }, + + getVarListCode: function ( vars, prefix ) { + + prefix = prefix || ''; + + var code = ''; + + for ( var i = 0, l = vars.length; i < l; ++ i ) { + + var nVar = vars[ i ], + type = nVar.type, + name = nVar.name; + + var formatType = this.getFormatByType( type ); + + if ( formatType === undefined ) { + + throw new Error( "Node pars " + formatType + " not found." ); + + } + + code += prefix + ' ' + formatType + ' ' + name + ';\n'; + + } + + return code; + + }, + + getVars: function ( shader ) { + + return this.inputs.vars[ shader || this.shader ]; + + }, + + getNodeData: function ( node ) { + + var uuid = node.isNode ? node.uuid : node; + + return this.nodeData[ uuid ] = this.nodeData[ uuid ] || {}; + + }, + + createUniform: function ( shader, type, node, ns, needsUpdate ) { + + var uniforms = this.inputs.uniforms, + index = uniforms.list.length; + + var uniform = new NodeUniform( { + type: type, + name: ns ? ns : 'nVu' + index, + node: node, + needsUpdate: needsUpdate + } ); + + uniforms.list.push( uniform ); + + uniforms[ shader ].push( uniform ); + uniforms[ shader ][ uniform.name ] = uniform; + + this.uniforms[ uniform.name ] = uniform; + + return uniform; + + }, + + createVertexUniform: function ( type, node, ns, needsUpdate ) { + + return this.createUniform( 'vertex', type, node, ns, needsUpdate ); + + }, + + createFragmentUniform: function ( type, node, ns, needsUpdate ) { + + return this.createUniform( 'fragment', type, node, ns, needsUpdate ); + + }, + + include: function ( node, parent, source ) { + + var includesStruct; + + node = typeof node === 'string' ? NodeLib.get( node ) : node; + + if ( this.context.include === false ) { + + return node.name; + + } + + + if ( node instanceof FunctionNode ) { + + includesStruct = this.includes.functions; + + } else if ( node instanceof ConstNode ) { + + includesStruct = this.includes.consts; + + } else if ( node instanceof StructNode ) { + + includesStruct = this.includes.structs; + + } + + var includes = includesStruct[ this.shader ] = includesStruct[ this.shader ] || []; + + if ( node ) { + + var included = includes[ node.name ]; + + if ( ! included ) { + + included = includes[ node.name ] = { + node: node, + deps: [] + }; + + includes.push( included ); + + included.src = node.build( this, 'source' ); + + } + + if ( node instanceof FunctionNode && parent && includes[ parent.name ] && includes[ parent.name ].deps.indexOf( node ) == - 1 ) { + + includes[ parent.name ].deps.push( node ); + + if ( node.includes && node.includes.length ) { + + var i = 0; + + do { + + this.include( node.includes[ i ++ ], parent ); + + } while ( i < node.includes.length ); + + } + + } + + if ( source ) { + + included.src = source; + + } + + return node.name; + + } else { + + throw new Error( "Include not found." ); + + } + + }, + + colorToVectorProperties: function ( color ) { + + return color.replace( 'r', 'x' ).replace( 'g', 'y' ).replace( 'b', 'z' ).replace( 'a', 'w' ); + + }, + + colorToVector: function ( color ) { + + return color.replace( /c/g, 'v3' ); + + }, + + getIncludes: function ( type, shader ) { + + return this.includes[ type ][ shader || this.shader ]; + + }, + + getIncludesCode: function () { + + function sortByPosition( a, b ) { + + return a.deps.length - b.deps.length; + + } + + return function getIncludesCode( type, shader ) { + + var includes = this.getIncludes( type, shader ); + + if ( ! includes ) return ''; + + var code = '', + includes = includes.sort( sortByPosition ); + + for ( var i = 0; i < includes.length; i ++ ) { + + if ( includes[ i ].src ) code += includes[ i ].src + '\n'; + + } + + return code; + + }; + + }(), + + getConstructorFromLength: function ( len ) { + + return constructors[ len - 1 ]; + + }, + + isTypeMatrix: function ( format ) { + + return /^m/.test( format ); + + }, + + getTypeLength: function ( type ) { + + if ( type === 'f' ) return 1; + + return parseInt( this.colorToVector( type ).substr( 1 ) ); + + }, + + getTypeFromLength: function ( len ) { + + if ( len === 1 ) return 'f'; + + return 'v' + len; + + }, + + findNode: function () { + + for ( var i = 0; i < arguments.length; i ++ ) { + + var nodeCandidate = arguments[ i ]; + + if ( nodeCandidate !== undefined && nodeCandidate.isNode ) { + + return nodeCandidate; + + } + + } + + }, + + resolve: function () { + + for ( var i = 0; i < arguments.length; i ++ ) { + + var nodeCandidate = arguments[ i ]; + + if ( nodeCandidate !== undefined ) { + + if ( nodeCandidate.isNode ) { + + return nodeCandidate; + + } else if ( nodeCandidate.isTexture ) { + + switch ( nodeCandidate.mapping ) { + + case THREE.CubeReflectionMapping: + case THREE.CubeRefractionMapping: + + return new CubeTextureNode( nodeCandidate ); + + break; + + case THREE.CubeUVReflectionMapping: + case THREE.CubeUVRefractionMapping: + + return new TextureCubeNode( new TextureNode( nodeCandidate ) ); + + break; + + default: + + return new TextureNode( nodeCandidate ); + + } + + } else if ( nodeCandidate.isVector2 ) { + + return new Vector2Node( nodeCandidate ); + + } else if ( nodeCandidate.isVector3 ) { + + return new Vector3Node( nodeCandidate ); + + } else if ( nodeCandidate.isVector4 ) { + + return new Vector4Node( nodeCandidate ); + + } + + } + + } + + }, + + format: function ( code, from, to ) { + + var typeToType = this.colorToVector( to + ' <- ' + from ); + + switch ( typeToType ) { + + case 'f <- v2' : return code + '.x'; + case 'f <- v3' : return code + '.x'; + case 'f <- v4' : return code + '.x'; + case 'f <- i' : return 'float( ' + code + ' )'; + + case 'v2 <- f' : return 'vec2( ' + code + ' )'; + case 'v2 <- v3': return code + '.xy'; + case 'v2 <- v4': return code + '.xy'; + case 'v2 <- i' : return 'vec2( float( ' + code + ' ) )'; + + case 'v3 <- f' : return 'vec3( ' + code + ' )'; + case 'v3 <- v2': return 'vec3( ' + code + ', 0.0 )'; + case 'v3 <- v4': return code + '.xyz'; + case 'v3 <- i' : return 'vec2( float( ' + code + ' ) )'; + + case 'v4 <- f' : return 'vec4( ' + code + ' )'; + case 'v4 <- v2': return 'vec4( ' + code + ', 0.0, 1.0 )'; + case 'v4 <- v3': return 'vec4( ' + code + ', 1.0 )'; + case 'v4 <- i' : return 'vec4( float( ' + code + ' ) )'; + + case 'i <- f' : return 'int( ' + code + ' )'; + case 'i <- v2' : return 'int( ' + code + '.x )'; + case 'i <- v3' : return 'int( ' + code + '.x )'; + case 'i <- v4' : return 'int( ' + code + '.x )'; + + } + + return code; + + }, + + getTypeByFormat: function ( format ) { + + return convertFormatToType[ format ] || format; + + }, + + getFormatByType: function ( type ) { + + return convertTypeToFormat[ type ] || type; + + }, + + getUuid: function ( uuid, useCache ) { + + useCache = useCache !== undefined ? useCache : true; + + if ( useCache && this.cache ) uuid = this.cache + '-' + uuid; + + return uuid; + + }, + + getElementByIndex: function ( index ) { + + return elements[ index ]; + + }, + + getIndexByElement: function ( elm ) { + + return elements.indexOf( elm ); + + }, + + isShader: function ( shader ) { + + return this.shader === shader; + + }, + + setShader: function ( shader ) { + + this.shader = shader; + + return this; + + }, + + mergeDefines: function ( defines ) { + + for ( var name in defines ) { + + this.defines[ name ] = defines[ name ]; + + } + + return this.defines; + + }, + + mergeUniform: function ( uniforms ) { + + for ( var name in uniforms ) { + + this.uniforms[ name ] = uniforms[ name ]; + + } + + return this.uniforms; + + }, + + getTextureEncodingFromMap: function ( map, gammaOverrideLinear ) { + + gammaOverrideLinear = gammaOverrideLinear !== undefined ? gammaOverrideLinear : this.context.gamma && ( this.renderer ? this.renderer.gammaInput : false ); + + var encoding; + + if ( ! map ) { + + encoding = THREE.LinearEncoding; + + } else if ( map.isTexture ) { + + encoding = map.encoding; + + } else if ( map.isWebGLRenderTarget ) { + + console.warn( "THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead." ); + encoding = map.texture.encoding; + + } + + // add backwards compatibility for WebGLRenderer.gammaInput/gammaOutput parameter, should probably be removed at some point. + if ( encoding === THREE.LinearEncoding && gammaOverrideLinear ) { + + encoding = THREE.GammaEncoding; + + } + + return encoding; + + } + +}; + +export { NodeBuilder }; diff --git a/three/jsutil/nodes/core/NodeFrame.js b/three/jsutil/nodes/core/NodeFrame.js new file mode 100644 index 000000000..c0e0433d5 --- /dev/null +++ b/three/jsutil/nodes/core/NodeFrame.js @@ -0,0 +1,58 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +function NodeFrame( time ) { + + this.time = time !== undefined ? time : 0; + + this.id = 0; + +} + +NodeFrame.prototype = { + + constructor: NodeFrame, + + update: function ( delta ) { + + ++ this.id; + + this.time += delta; + this.delta = delta; + + return this; + + }, + + setRenderer: function ( renderer ) { + + this.renderer = renderer; + + return this; + + }, + + setRenderTexture: function ( renderTexture ) { + + this.renderTexture = renderTexture; + + return this; + + }, + + updateNode: function ( node ) { + + if ( node.frameId === this.id ) return this; + + node.updateFrame( this ); + + node.frameId = this.id; + + return this; + + } + +}; + +export { NodeFrame }; diff --git a/three/jsutil/nodes/core/NodeLib.js b/three/jsutil/nodes/core/NodeLib.js new file mode 100644 index 000000000..63795db72 --- /dev/null +++ b/three/jsutil/nodes/core/NodeLib.js @@ -0,0 +1,68 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +var NodeLib = { + + nodes: {}, + keywords: {}, + + add: function ( node ) { + + this.nodes[ node.name ] = node; + + }, + + addKeyword: function ( name, callback, cache ) { + + cache = cache !== undefined ? cache : true; + + this.keywords[ name ] = { callback: callback, cache: cache }; + + }, + + remove: function ( node ) { + + delete this.nodes[ node.name ]; + + }, + + removeKeyword: function ( name ) { + + delete this.keywords[ name ]; + + }, + + get: function ( name ) { + + return this.nodes[ name ]; + + }, + + getKeyword: function ( name, material ) { + + return this.keywords[ name ].callback.call( this, material ); + + }, + + getKeywordData: function ( name ) { + + return this.keywords[ name ]; + + }, + + contains: function ( name ) { + + return this.nodes[ name ] != undefined; + + }, + + containsKeyword: function ( name ) { + + return this.keywords[ name ] != undefined; + + } + +}; + +export { NodeLib }; diff --git a/three/jsutil/nodes/core/NodeUniform.js b/three/jsutil/nodes/core/NodeUniform.js new file mode 100644 index 000000000..3ba0bb183 --- /dev/null +++ b/three/jsutil/nodes/core/NodeUniform.js @@ -0,0 +1,36 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +function NodeUniform( params ) { + + params = params || {}; + + this.name = params.name; + this.type = params.type; + this.node = params.node; + this.needsUpdate = params.needsUpdate; + +} + +Object.defineProperties( NodeUniform.prototype, { + + value: { + + get: function () { + + return this.node.value; + + }, + + set: function ( val ) { + + this.node.value = val; + + } + + } + +} ); + +export { NodeUniform }; diff --git a/three/jsutil/nodes/core/NodeUtils.js b/three/jsutil/nodes/core/NodeUtils.js new file mode 100644 index 000000000..60b3ec138 --- /dev/null +++ b/three/jsutil/nodes/core/NodeUtils.js @@ -0,0 +1,75 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +var NodeUtils = { + + elements: [ 'x', 'y', 'z', 'w' ], + + addShortcuts: function () { + + function applyShortcut( proxy, property, subProperty ) { + + if ( subProperty ) { + + return { + + get: function () { + + return this[ proxy ][ property ][ subProperty ]; + + }, + + set: function ( val ) { + + this[ proxy ][ property ][ subProperty ] = val; + + } + + }; + + } else { + + return { + + get: function () { + + return this[ proxy ][ property ]; + + }, + + set: function ( val ) { + + this[ proxy ][ property ] = val; + + } + + }; + + } + + } + + return function addShortcuts( proto, proxy, list ) { + + var shortcuts = {}; + + for ( var i = 0; i < list.length; ++ i ) { + + var data = list[ i ].split( "." ), + property = data[ 0 ], + subProperty = data[ 1 ]; + + shortcuts[ property ] = applyShortcut( proxy, property, subProperty ); + + } + + Object.defineProperties( proto, shortcuts ); + + }; + + }() + +}; + +export { NodeUtils }; diff --git a/three/jsutil/nodes/core/StructNode.js b/three/jsutil/nodes/core/StructNode.js new file mode 100644 index 000000000..9888de356 --- /dev/null +++ b/three/jsutil/nodes/core/StructNode.js @@ -0,0 +1,107 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from './TempNode.js'; + +var declarationRegexp = /^struct\s*([a-z_0-9]+)\s*{\s*((.|\n)*?)}/img, + propertiesRegexp = /\s*(\w*?)\s*(\w*?)(\=|\;)/img; + +function StructNode( src ) { + + TempNode.call( this ); + + this.eval( src ); + +} + +StructNode.prototype = Object.create( TempNode.prototype ); +StructNode.prototype.constructor = StructNode; +StructNode.prototype.nodeType = "Struct"; + +StructNode.prototype.getType = function ( builder ) { + + return builder.getTypeByFormat( this.name ); + +}; + +StructNode.prototype.getInputByName = function ( name ) { + + var i = this.inputs.length; + + while ( i -- ) { + + if ( this.inputs[ i ].name === name ) { + + return this.inputs[ i ]; + + } + + } + +}; + +StructNode.prototype.generate = function ( builder, output ) { + + if ( output === 'source' ) { + + return this.src + ';'; + + } else { + + return builder.format( '( ' + src + ' )', this.getType( builder ), output ); + + } + +}; + +StructNode.prototype.eval = function ( src ) { + + this.src = src || ''; + + this.inputs = []; + + var declaration = declarationRegexp.exec( this.src ); + + if ( declaration ) { + + var properties = declaration[ 2 ], match; + + while ( match = propertiesRegexp.exec( properties ) ) { + + this.inputs.push( { + type: match[ 1 ], + name: match[ 2 ] + } ); + + } + + this.name = declaration[ 1 ]; + + } else { + + this.name = ''; + + } + + this.type = this.name; + +}; + +StructNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.src = this.src; + + } + + return data; + +}; + +export { StructNode }; diff --git a/three/jsutil/nodes/core/TempNode.js b/three/jsutil/nodes/core/TempNode.js new file mode 100644 index 000000000..ead9f8022 --- /dev/null +++ b/three/jsutil/nodes/core/TempNode.js @@ -0,0 +1,133 @@ +/** + * Automatic node cache + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from './Node.js'; + +function TempNode( type, params ) { + + Node.call( this, type ); + + params = params || {}; + + this.shared = params.shared !== undefined ? params.shared : true; + this.unique = params.unique !== undefined ? params.unique : false; + +} + +TempNode.prototype = Object.create( Node.prototype ); +TempNode.prototype.constructor = TempNode; + +TempNode.prototype.build = function ( builder, output, uuid, ns ) { + + output = output || this.getType( builder ); + + if ( this.isShared( builder, output ) ) { + + var isUnique = this.isUnique( builder, output ); + + if ( isUnique && this.constructor.uuid === undefined ) { + + this.constructor.uuid = THREE.Math.generateUUID(); + + } + + uuid = builder.getUuid( uuid || this.getUuid(), ! isUnique ); + + var data = builder.getNodeData( uuid ), + type = data.output || this.getType( builder ); + + if ( builder.parsing ) { + + if ( ( data.deps || 0 ) > 0 ) { + + this.appendDepsNode( builder, data, output ); + + return this.generate( builder, output, uuid ); + + } + + return Node.prototype.build.call( this, builder, output, uuid ); + + } else if ( isUnique ) { + + data.name = data.name || Node.prototype.build.call( this, builder, output, uuid ); + + return data.name; + + } else if ( ! this.isShared( builder, type ) || ( ! builder.optimize || data.deps == 1 ) ) { + + return Node.prototype.build.call( this, builder, output, uuid ); + + } + + uuid = this.getUuid( false ); + + var name = this.getTemp( builder, uuid ); + + if ( name ) { + + return builder.format( name, type, output ); + + } else { + + name = TempNode.prototype.generate.call( this, builder, output, uuid, data.output, ns ); + + var code = this.generate( builder, type, uuid ); + + builder.addNodeCode( name + ' = ' + code + ';' ); + + return builder.format( name, type, output ); + + } + + } + + return Node.prototype.build.call( this, builder, output, uuid ); + +}; + +TempNode.prototype.isShared = function ( builder, output ) { + + return output !== 'sampler2D' && output !== 'samplerCube' && this.shared; + +}; + +TempNode.prototype.isUnique = function ( builder, output ) { + + return this.unique; + +}; + +TempNode.prototype.getUuid = function ( unique ) { + + var uuid = unique || unique == undefined ? this.constructor.uuid || this.uuid : this.uuid; + + if ( typeof this.scope == "string" ) uuid = this.scope + '-' + uuid; + + return uuid; + +}; + +TempNode.prototype.getTemp = function ( builder, uuid ) { + + uuid = uuid || this.uuid; + + var tempVar = builder.getVars()[ uuid ]; + + return tempVar ? tempVar.name : undefined; + +}; + +TempNode.prototype.generate = function ( builder, output, uuid, type, ns ) { + + if ( ! this.isShared( builder, output ) ) console.error( "THREE.TempNode is not shared!" ); + + uuid = uuid || this.uuid; + + return builder.getTempVar( uuid, type || this.getType( builder ), ns ).name; + +}; + +export { TempNode }; diff --git a/three/jsutil/nodes/core/VarNode.js b/three/jsutil/nodes/core/VarNode.js new file mode 100644 index 000000000..9e9e78ee8 --- /dev/null +++ b/three/jsutil/nodes/core/VarNode.js @@ -0,0 +1,66 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from './Node.js'; + +function VarNode( type, value ) { + + Node.call( this, type ); + + this.value = value; + +} + +VarNode.prototype = Object.create( Node.prototype ); +VarNode.prototype.constructor = VarNode; +VarNode.prototype.nodeType = "Var"; + +VarNode.prototype.getType = function ( builder ) { + + return builder.getTypeByFormat( this.type ); + +}; + +VarNode.prototype.generate = function ( builder, output ) { + + var varying = builder.getVar( this.uuid, this.type ); + + if ( this.value && builder.isShader( 'vertex' ) ) { + + builder.addNodeCode( varying.name + ' = ' + this.value.build( builder, this.getType( builder ) ) + ';' ); + + } + + return builder.format( varying.name, this.getType( builder ), output ); + +}; + +VarNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + this.type = source.type; + this.value = source.value; + +}; + +VarNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.type = this.type; + + if ( this.value ) data.value = this.value.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { VarNode }; diff --git a/three/jsutil/nodes/effects/BlurNode.js b/three/jsutil/nodes/effects/BlurNode.js new file mode 100644 index 000000000..80c8d4b57 --- /dev/null +++ b/three/jsutil/nodes/effects/BlurNode.js @@ -0,0 +1,168 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { FloatNode } from '../inputs/FloatNode.js'; +import { Vector2Node } from '../inputs/Vector2Node.js'; +import { UVNode } from '../accessors/UVNode.js'; + +function BlurNode( value, uv, radius, size ) { + + TempNode.call( this, 'v4' ); + + this.value = value; + this.uv = uv || new UVNode(); + this.radius = new Vector2Node( 1, 1 ); + + this.size = size; + + this.blurX = true; + this.blurY = true; + + this.horizontal = new FloatNode( 1 / 64 ); + this.vertical = new FloatNode( 1 / 64 ); + +} + +BlurNode.Nodes = ( function () { + + var blurX = new FunctionNode( [ + "vec4 blurX( sampler2D texture, vec2 uv, float s ) {", + " vec4 sum = vec4( 0.0 );", + " sum += texture2D( texture, vec2( uv.x - 4.0 * s, uv.y ) ) * 0.051;", + " sum += texture2D( texture, vec2( uv.x - 3.0 * s, uv.y ) ) * 0.0918;", + " sum += texture2D( texture, vec2( uv.x - 2.0 * s, uv.y ) ) * 0.12245;", + " sum += texture2D( texture, vec2( uv.x - 1.0 * s, uv.y ) ) * 0.1531;", + " sum += texture2D( texture, vec2( uv.x, uv.y ) ) * 0.1633;", + " sum += texture2D( texture, vec2( uv.x + 1.0 * s, uv.y ) ) * 0.1531;", + " sum += texture2D( texture, vec2( uv.x + 2.0 * s, uv.y ) ) * 0.12245;", + " sum += texture2D( texture, vec2( uv.x + 3.0 * s, uv.y ) ) * 0.0918;", + " sum += texture2D( texture, vec2( uv.x + 4.0 * s, uv.y ) ) * 0.051;", + " return sum * .667;", + "}" + ].join( "\n" ) ); + + var blurY = new FunctionNode( [ + "vec4 blurY( sampler2D texture, vec2 uv, float s ) {", + " vec4 sum = vec4( 0.0 );", + " sum += texture2D( texture, vec2( uv.x, uv.y - 4.0 * s ) ) * 0.051;", + " sum += texture2D( texture, vec2( uv.x, uv.y - 3.0 * s ) ) * 0.0918;", + " sum += texture2D( texture, vec2( uv.x, uv.y - 2.0 * s ) ) * 0.12245;", + " sum += texture2D( texture, vec2( uv.x, uv.y - 1.0 * s ) ) * 0.1531;", + " sum += texture2D( texture, vec2( uv.x, uv.y ) ) * 0.1633;", + " sum += texture2D( texture, vec2( uv.x, uv.y + 1.0 * s ) ) * 0.1531;", + " sum += texture2D( texture, vec2( uv.x, uv.y + 2.0 * s ) ) * 0.12245;", + " sum += texture2D( texture, vec2( uv.x, uv.y + 3.0 * s ) ) * 0.0918;", + " sum += texture2D( texture, vec2( uv.x, uv.y + 4.0 * s ) ) * 0.051;", + " return sum * .667;", + "}" + ].join( "\n" ) ); + + return { + blurX: blurX, + blurY: blurY + }; + +} )(); + + +BlurNode.prototype = Object.create( TempNode.prototype ); +BlurNode.prototype.constructor = BlurNode; +BlurNode.prototype.nodeType = "Blur"; + +BlurNode.prototype.updateFrame = function ( frame ) { + + if ( this.size ) { + + this.horizontal.value = this.radius.x / this.size.x; + this.vertical.value = this.radius.y / this.size.y; + + } else if ( this.value.value && this.value.value.image ) { + + var image = this.value.value.image; + + this.horizontal.value = this.radius.x / image.width; + this.vertical.value = this.radius.y / image.height; + + } + +}; + +BlurNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + var blurCode = [], code; + + var blurX = builder.include( BlurNode.Nodes.blurX ), + blurY = builder.include( BlurNode.Nodes.blurY ); + + if ( this.blurX ) { + + blurCode.push( blurX + '( ' + this.value.build( builder, 'sampler2D' ) + ', ' + this.uv.build( builder, 'v2' ) + ', ' + this.horizontal.build( builder, 'f' ) + ' )' ); + + } + + if ( this.blurY ) { + + blurCode.push( blurY + '( ' + this.value.build( builder, 'sampler2D' ) + ', ' + this.uv.build( builder, 'v2' ) + ', ' + this.vertical.build( builder, 'f' ) + ' )' ); + + } + + if ( blurCode.length == 2 ) code = '( ' + blurCode.join( ' + ' ) + ' / 2.0 )'; + else if ( blurCode.length ) code = '( ' + blurCode[ 0 ] + ' )'; + else code = 'vec4( 0.0 )'; + + return builder.format( code, this.getType( builder ), output ); + + } else { + + console.warn( "THREE.BlurNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec4( 0.0 )', this.getType( builder ), output ); + + } + +}; + +BlurNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.value = source.value; + this.uv = source.uv; + this.radius = source.radius; + + if ( source.size !== undefined ) this.size = new THREE.Vector2( source.size.x, source.size.y ); + + this.blurX = source.blurX; + this.blurY = source.blurY; + +}; + +BlurNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value.toJSON( meta ).uuid; + data.uv = this.uv.toJSON( meta ).uuid; + data.radius = this.radius.toJSON( meta ).uuid; + + if ( this.size ) data.size = { x: this.size.x, y: this.size.y }; + + data.blurX = this.blurX; + data.blurY = this.blurY; + + } + + return data; + +}; + +export { BlurNode }; diff --git a/three/jsutil/nodes/effects/ColorAdjustmentNode.js b/three/jsutil/nodes/effects/ColorAdjustmentNode.js new file mode 100644 index 000000000..0208192de --- /dev/null +++ b/three/jsutil/nodes/effects/ColorAdjustmentNode.js @@ -0,0 +1,136 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { LuminanceNode } from './LuminanceNode.js'; + +function ColorAdjustmentNode( rgb, adjustment, method ) { + + TempNode.call( this, 'v3' ); + + this.rgb = rgb; + this.adjustment = adjustment; + + this.method = method || ColorAdjustmentNode.SATURATION; + +} + +ColorAdjustmentNode.Nodes = ( function () { + + var hue = new FunctionNode( [ + "vec3 hue(vec3 rgb, float adjustment) {", + + " const mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);", + " const mat3 YIQtoRGB = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046);", + + " vec3 yiq = RGBtoYIQ * rgb;", + + " float hue = atan(yiq.z, yiq.y) + adjustment;", + " float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);", + + " return YIQtoRGB * vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));", + + "}" + ].join( "\n" ) ); + + var saturation = new FunctionNode( [ + // Algorithm from Chapter 16 of OpenGL Shading Language + "vec3 saturation(vec3 rgb, float adjustment) {", + + " vec3 intensity = vec3( luminance( rgb ) );", + + " return mix( intensity, rgb, adjustment );", + + "}" + ].join( "\n" ), [ LuminanceNode.Nodes.luminance ] ); // include LuminanceNode function + + var vibrance = new FunctionNode( [ + // Shader by Evan Wallace adapted by @lo-th + "vec3 vibrance(vec3 rgb, float adjustment) {", + + " float average = (rgb.r + rgb.g + rgb.b) / 3.0;", + + " float mx = max(rgb.r, max(rgb.g, rgb.b));", + " float amt = (mx - average) * (-3.0 * adjustment);", + + " return mix(rgb.rgb, vec3(mx), amt);", + + "}" + ].join( "\n" ) ); + + return { + hue: hue, + saturation: saturation, + vibrance: vibrance + }; + +} )(); + +ColorAdjustmentNode.SATURATION = 'saturation'; +ColorAdjustmentNode.HUE = 'hue'; +ColorAdjustmentNode.VIBRANCE = 'vibrance'; +ColorAdjustmentNode.BRIGHTNESS = 'brightness'; +ColorAdjustmentNode.CONTRAST = 'contrast'; + +ColorAdjustmentNode.prototype = Object.create( TempNode.prototype ); +ColorAdjustmentNode.prototype.constructor = ColorAdjustmentNode; +ColorAdjustmentNode.prototype.nodeType = "ColorAdjustment"; + +ColorAdjustmentNode.prototype.generate = function ( builder, output ) { + + var rgb = this.rgb.build( builder, 'v3' ), + adjustment = this.adjustment.build( builder, 'f' ); + + switch ( this.method ) { + + case ColorAdjustmentNode.BRIGHTNESS: + + return builder.format( '( ' + rgb + ' + ' + adjustment + ' )', this.getType( builder ), output ); + + break; + + case ColorAdjustmentNode.CONTRAST: + + return builder.format( '( ' + rgb + ' * ' + adjustment + ' )', this.getType( builder ), output ); + + break; + + } + + var method = builder.include( ColorAdjustmentNode.Nodes[ this.method ] ); + + return builder.format( method + '( ' + rgb + ', ' + adjustment + ' )', this.getType( builder ), output ); + +}; + +ColorAdjustmentNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.rgb = source.rgb; + this.adjustment = source.adjustment; + this.method = source.method; + +}; + +ColorAdjustmentNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.rgb = this.rgb.toJSON( meta ).uuid; + data.adjustment = this.adjustment.toJSON( meta ).uuid; + data.method = this.method; + + } + + return data; + +}; + +export { ColorAdjustmentNode }; diff --git a/three/jsutil/nodes/effects/LuminanceNode.js b/three/jsutil/nodes/effects/LuminanceNode.js new file mode 100644 index 000000000..799a86b5a --- /dev/null +++ b/three/jsutil/nodes/effects/LuminanceNode.js @@ -0,0 +1,73 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { ConstNode } from '../core/ConstNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; + +function LuminanceNode( rgb ) { + + TempNode.call( this, 'f' ); + + this.rgb = rgb; + +} + +LuminanceNode.Nodes = ( function () { + + var LUMA = new ConstNode( "vec3 LUMA vec3( 0.2125, 0.7154, 0.0721 )" ); + + var luminance = new FunctionNode( [ + // Algorithm from Chapter 10 of Graphics Shaders + "float luminance( vec3 rgb ) {", + + " return dot( rgb, LUMA );", + + "}" + ].join( "\n" ), [ LUMA ] ); + + return { + LUMA: LUMA, + luminance: luminance + }; + +} )(); + +LuminanceNode.prototype = Object.create( TempNode.prototype ); +LuminanceNode.prototype.constructor = LuminanceNode; +LuminanceNode.prototype.nodeType = "Luminance"; + +LuminanceNode.prototype.generate = function ( builder, output ) { + + var luminance = builder.include( LuminanceNode.Nodes.luminance ); + + return builder.format( luminance + '( ' + this.rgb.build( builder, 'v3' ) + ' )', this.getType( builder ), output ); + +}; + +LuminanceNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.rgb = source.rgb; + +}; + +LuminanceNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.rgb = this.rgb.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { LuminanceNode }; diff --git a/three/jsutil/nodes/inputs/ColorNode.js b/three/jsutil/nodes/inputs/ColorNode.js new file mode 100644 index 000000000..81413c23a --- /dev/null +++ b/three/jsutil/nodes/inputs/ColorNode.js @@ -0,0 +1,56 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function ColorNode( color, g, b ) { + + InputNode.call( this, 'c' ); + + this.value = color instanceof THREE.Color ? color : new THREE.Color( color || 0, g, b ); + +} + +ColorNode.prototype = Object.create( InputNode.prototype ); +ColorNode.prototype.constructor = ColorNode; +ColorNode.prototype.nodeType = "Color"; + +NodeUtils.addShortcuts( ColorNode.prototype, 'value', [ 'r', 'g', 'b' ] ); + +ColorNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( "vec3( " + this.r + ", " + this.g + ", " + this.b + " )", type, output ); + +}; + +ColorNode.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value.copy( source ); + +}; + +ColorNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.r = this.r; + data.g = this.g; + data.b = this.b; + + if ( this.readonly === true ) data.readonly = true; + + } + + return data; + +}; + +export { ColorNode }; diff --git a/three/jsutil/nodes/inputs/CubeTextureNode.js b/three/jsutil/nodes/inputs/CubeTextureNode.js new file mode 100644 index 000000000..ad7d2b5c5 --- /dev/null +++ b/three/jsutil/nodes/inputs/CubeTextureNode.js @@ -0,0 +1,96 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { ReflectNode } from '../accessors/ReflectNode.js'; +import { ColorSpaceNode } from '../utils/ColorSpaceNode.js'; + +function CubeTextureNode( value, uv, bias ) { + + InputNode.call( this, 'v4', { shared: true } ); + + this.value = value; + this.uv = uv || new ReflectNode(); + this.bias = bias; + +} + +CubeTextureNode.prototype = Object.create( InputNode.prototype ); +CubeTextureNode.prototype.constructor = CubeTextureNode; +CubeTextureNode.prototype.nodeType = "CubeTexture"; + +CubeTextureNode.prototype.getTexture = function ( builder, output ) { + + return InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 'tc' ); + +}; + +CubeTextureNode.prototype.generate = function ( builder, output ) { + + if ( output === 'samplerCube' ) { + + return this.getTexture( builder, output ); + + } + + var cubetex = this.getTexture( builder, output ); + var uv = this.uv.build( builder, 'v3' ); + var bias = this.bias ? this.bias.build( builder, 'f' ) : undefined; + + if ( bias === undefined && builder.context.bias ) { + + bias = new builder.context.bias( this ).build( builder, 'f' ); + + } + + var code; + + if ( bias ) code = 'texCubeBias( ' + cubetex + ', ' + uv + ', ' + bias + ' )'; + else code = 'texCube( ' + cubetex + ', ' + uv + ' )'; + + // add this context to replace ColorSpaceNode.input to code + + builder.addContext( { input: code, encoding: builder.getTextureEncodingFromMap( this.value ), include: builder.isShader( 'vertex' ) } ); + + this.colorSpace = this.colorSpace || new ColorSpaceNode( this ); + code = this.colorSpace.build( builder, this.type ); + + builder.removeContext(); + + return builder.format( code, this.type, output ); + +}; + +CubeTextureNode.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + if ( source.value ) this.value = source.value; + + this.uv = source.uv; + + if ( source.bias ) this.bias = source.bias; + +}; + +CubeTextureNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value.uuid; + data.uv = this.uv.toJSON( meta ).uuid; + + if ( this.bias ) data.bias = this.bias.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { CubeTextureNode }; diff --git a/three/jsutil/nodes/inputs/FloatNode.js b/three/jsutil/nodes/inputs/FloatNode.js new file mode 100644 index 000000000..604bf170a --- /dev/null +++ b/three/jsutil/nodes/inputs/FloatNode.js @@ -0,0 +1,51 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; + +function FloatNode( value ) { + + InputNode.call( this, 'f' ); + + this.value = value || 0; + +} + +FloatNode.prototype = Object.create( InputNode.prototype ); +FloatNode.prototype.constructor = FloatNode; +FloatNode.prototype.nodeType = "Float"; + +FloatNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( this.value + ( this.value % 1 ? '' : '.0' ), type, output ); + +}; + +FloatNode.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value = source.value; + +}; + +FloatNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value; + + if ( this.readonly === true ) data.readonly = true; + + } + + return data; + +}; + +export { FloatNode }; diff --git a/three/jsutil/nodes/inputs/IntNode.js b/three/jsutil/nodes/inputs/IntNode.js new file mode 100644 index 000000000..c35c8a0f4 --- /dev/null +++ b/three/jsutil/nodes/inputs/IntNode.js @@ -0,0 +1,51 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; + +function IntNode( value ) { + + InputNode.call( this, 'i' ); + + this.value = Math.floor( value || 0 ); + +} + +IntNode.prototype = Object.create( InputNode.prototype ); +IntNode.prototype.constructor = IntNode; +IntNode.prototype.nodeType = "Int"; + +IntNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( this.value, type, output ); + +}; + +IntNode.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value = source.value; + +}; + +IntNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value; + + if ( this.readonly === true ) data.readonly = true; + + } + + return data; + +}; + +export { IntNode }; diff --git a/three/jsutil/nodes/inputs/Matrix3Node.js b/three/jsutil/nodes/inputs/Matrix3Node.js new file mode 100644 index 000000000..25799d20f --- /dev/null +++ b/three/jsutil/nodes/inputs/Matrix3Node.js @@ -0,0 +1,70 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; + +function Matrix3Node( matrix ) { + + InputNode.call( this, 'm3' ); + + this.value = matrix || new THREE.Matrix3(); + +} + +Matrix3Node.prototype = Object.create( InputNode.prototype ); +Matrix3Node.prototype.constructor = Matrix3Node; +Matrix3Node.prototype.nodeType = "Matrix3"; + +Object.defineProperties( Matrix3Node.prototype, { + + elements: { + + set: function ( val ) { + + this.value.elements = val; + + }, + + get: function () { + + return this.value.elements; + + } + + } + +} ); + +Matrix3Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( "mat3( " + this.value.elements.join( ", " ) + " )", type, output ); + +}; + + +Matrix3Node.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value.fromArray( source.elements ); + +}; + +Matrix3Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.elements = this.value.elements.concat(); + + } + + return data; + +}; + +export { Matrix3Node }; diff --git a/three/jsutil/nodes/inputs/Matrix4Node.js b/three/jsutil/nodes/inputs/Matrix4Node.js new file mode 100644 index 000000000..50c0084f9 --- /dev/null +++ b/three/jsutil/nodes/inputs/Matrix4Node.js @@ -0,0 +1,69 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; + +function Matrix4Node( matrix ) { + + InputNode.call( this, 'm4' ); + + this.value = matrix || new THREE.Matrix4(); + +} + +Matrix4Node.prototype = Object.create( InputNode.prototype ); +Matrix4Node.prototype.constructor = Matrix4Node; +Matrix4Node.prototype.nodeType = "Matrix4"; + +Object.defineProperties( Matrix4Node.prototype, { + + elements: { + + set: function ( val ) { + + this.value.elements = val; + + }, + + get: function () { + + return this.value.elements; + + } + + } + +} ); + +Matrix4Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( "mat4( " + this.value.elements.join( ", " ) + " )", type, output ); + +}; + +Matrix4Node.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.scope.value.fromArray( source.elements ); + +}; + +Matrix4Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.elements = this.value.elements.concat(); + + } + + return data; + +}; + +export { Matrix4Node }; diff --git a/three/jsutil/nodes/inputs/PropertyNode.js b/three/jsutil/nodes/inputs/PropertyNode.js new file mode 100644 index 000000000..b6d92249a --- /dev/null +++ b/three/jsutil/nodes/inputs/PropertyNode.js @@ -0,0 +1,57 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; + +function PropertyNode( object, property, type ) { + + InputNode.call( this, type ); + + this.object = object; + this.property = property; + +} + +PropertyNode.prototype = Object.create( InputNode.prototype ); +PropertyNode.prototype.constructor = PropertyNode; +PropertyNode.prototype.nodeType = "Property"; + +Object.defineProperties( PropertyNode.prototype, { + + value: { + + get: function () { + + return this.object[ this.property ]; + + }, + + set: function ( val ) { + + this.object[ this.property ] = val; + + } + + } + +} ); + +PropertyNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value; + data.property = this.property; + + } + + return data; + +}; + +export { PropertyNode }; diff --git a/three/jsutil/nodes/inputs/RTTNode.js b/three/jsutil/nodes/inputs/RTTNode.js new file mode 100644 index 000000000..0abc03c8b --- /dev/null +++ b/three/jsutil/nodes/inputs/RTTNode.js @@ -0,0 +1,143 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { NodeMaterial } from '../materials/NodeMaterial.js'; +import { TextureNode } from './TextureNode.js'; + +function RTTNode( width, height, input, options ) { + + options = options || {}; + + this.input = input; + + this.clear = options.clear !== undefined ? options.clear : true; + + this.renderTarget = new THREE.WebGLRenderTarget( width, height, options ); + + this.material = new NodeMaterial(); + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.material ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + + this.render = true; + + TextureNode.call( this, this.renderTarget.texture ); + +} + +RTTNode.prototype = Object.create( TextureNode.prototype ); +RTTNode.prototype.constructor = RTTNode; +RTTNode.prototype.nodeType = "RTT"; + +RTTNode.prototype.build = function ( builder, output, uuid ) { + + var rttBuilder = new THREE.NodeBuilder(); + rttBuilder.nodes = builder.nodes; + rttBuilder.updaters = builder.updaters; + + this.material.fragment.value = this.input; + this.material.build( { builder: rttBuilder } ); + + return TextureNode.prototype.build.call( this, builder, output, uuid ); + +}; + +RTTNode.prototype.updateFramesaveTo = function ( frame ) { + + this.saveTo.render = false; + + if ( this.saveTo !== this.saveToCurrent ) { + + if ( this.saveToMaterial ) this.saveToMaterial.dispose(); + + var material = new NodeMaterial(); + material.fragment.value = this; + material.build(); + + var scene = new THREE.Scene(); + + var quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), material ); + quad.frustumCulled = false; // Avoid getting clipped + scene.add( quad ); + + this.saveToScene = scene; + this.saveToMaterial = material; + + } + + this.saveToCurrent = this.saveTo; + + frame.renderer.render( this.saveToScene, this.camera, this.saveTo.renderTarget, this.saveTo.clear ); + +}; + +RTTNode.prototype.updateFrame = function ( frame ) { + + if ( frame.renderer ) { + + // from the second frame + + if ( this.saveTo && this.saveTo.render === false ) { + + this.updateFramesaveTo( frame ); + + } + + if ( this.render ) { + + if ( this.material.uniforms.renderTexture ) { + + this.material.uniforms.renderTexture.value = frame.renderTexture; + + } + + frame.renderer.render( this.scene, this.camera, this.renderTarget, this.clear ); + + } + + // first frame + + if ( this.saveTo && this.saveTo.render === true ) { + + this.updateFramesaveTo( frame ); + + } + + } else { + + console.warn( "RTTNode need a renderer in NodeFrame" ); + + } + +}; + +RTTNode.prototype.copy = function ( source ) { + + TextureNode.prototype.copy.call( this, source ); + + this.saveTo = source.saveTo; + +}; + +RTTNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = THREE.TextureNode.prototype.toJSON.call( this, meta ); + + if ( this.saveTo ) data.saveTo = this.saveTo.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { RTTNode }; diff --git a/three/jsutil/nodes/inputs/ReflectorNode.js b/three/jsutil/nodes/inputs/ReflectorNode.js new file mode 100644 index 000000000..79e8f23ca --- /dev/null +++ b/three/jsutil/nodes/inputs/ReflectorNode.js @@ -0,0 +1,89 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { PositionNode } from '../accessors/PositionNode.js'; +import { OperatorNode } from '../math/OperatorNode.js'; +import { TextureNode } from './TextureNode.js'; +import { Matrix4Node } from './Matrix4Node.js'; + +function ReflectorNode( mirror ) { + + TempNode.call( this, 'v4' ); + + if ( mirror ) this.setMirror( mirror ); + +} + +ReflectorNode.prototype = Object.create( TempNode.prototype ); +ReflectorNode.prototype.constructor = ReflectorNode; +ReflectorNode.prototype.nodeType = "Reflector"; + +ReflectorNode.prototype.setMirror = function ( mirror ) { + + this.mirror = mirror; + + this.textureMatrix = new Matrix4Node( this.mirror.material.uniforms.textureMatrix.value ); + + this.localPosition = new PositionNode( PositionNode.LOCAL ); + + this.uv = new OperatorNode( this.textureMatrix, this.localPosition, OperatorNode.MUL ); + this.uvResult = new OperatorNode( null, this.uv, OperatorNode.ADD ); + + this.texture = new TextureNode( this.mirror.material.uniforms.tDiffuse.value, this.uv, null, true ); + +}; + +ReflectorNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + this.uvResult.a = this.offset; + this.texture.uv = this.offset ? this.uvResult : this.uv; + + if ( output === 'sampler2D' ) { + + return this.texture.build( builder, output ); + + } + + return builder.format( this.texture.build( builder, this.type ), this.type, output ); + + } else { + + console.warn( "THREE.ReflectorNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec4( 0.0 )', this.type, output ); + + } + +}; + +ReflectorNode.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.scope.mirror = source.mirror; + +}; + +ReflectorNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.mirror = this.mirror.uuid; + + if ( this.offset ) data.offset = this.offset.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { ReflectorNode }; diff --git a/three/jsutil/nodes/inputs/ScreenNode.js b/three/jsutil/nodes/inputs/ScreenNode.js new file mode 100644 index 000000000..27740ee79 --- /dev/null +++ b/three/jsutil/nodes/inputs/ScreenNode.js @@ -0,0 +1,30 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { TextureNode } from './TextureNode.js'; + +function ScreenNode( uv ) { + + TextureNode.call( this, undefined, uv ); + +} + +ScreenNode.prototype = Object.create( TextureNode.prototype ); +ScreenNode.prototype.constructor = ScreenNode; +ScreenNode.prototype.nodeType = "Screen"; + +ScreenNode.prototype.isUnique = function () { + + return true; + +}; + +ScreenNode.prototype.getTexture = function ( builder, output ) { + + return InputNode.prototype.generate.call( this, builder, output, this.getUuid(), 't', 'renderTexture' ); + +}; + +export { ScreenNode }; diff --git a/three/jsutil/nodes/inputs/TextureNode.js b/three/jsutil/nodes/inputs/TextureNode.js new file mode 100644 index 000000000..ddb6d7096 --- /dev/null +++ b/three/jsutil/nodes/inputs/TextureNode.js @@ -0,0 +1,103 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { UVNode } from '../accessors/UVNode.js'; +import { ColorSpaceNode } from '../utils/ColorSpaceNode.js'; + +function TextureNode( value, uv, bias, project ) { + + InputNode.call( this, 'v4', { shared: true } ); + + this.value = value; + this.uv = uv || new UVNode(); + this.bias = bias; + this.project = project !== undefined ? project : false; + +} + +TextureNode.prototype = Object.create( InputNode.prototype ); +TextureNode.prototype.constructor = TextureNode; +TextureNode.prototype.nodeType = "Texture"; + +TextureNode.prototype.getTexture = function ( builder, output ) { + + return InputNode.prototype.generate.call( this, builder, output, this.value.uuid, 't' ); + +}; + +TextureNode.prototype.generate = function ( builder, output ) { + + if ( output === 'sampler2D' ) { + + return this.getTexture( builder, output ); + + } + + var tex = this.getTexture( builder, output ), + uv = this.uv.build( builder, this.project ? 'v4' : 'v2' ), + bias = this.bias ? this.bias.build( builder, 'f' ) : undefined; + + if ( bias == undefined && builder.context.bias ) { + + bias = new builder.context.bias( this ).build( builder, 'f' ); + + } + + var method, code; + + if ( this.project ) method = 'texture2DProj'; + else method = bias ? 'tex2DBias' : 'tex2D'; + + if ( bias ) code = method + '( ' + tex + ', ' + uv + ', ' + bias + ' )'; + else code = method + '( ' + tex + ', ' + uv + ' )'; + + // add this context to replace ColorSpaceNode.input to code + + builder.addContext( { input: code, encoding: builder.getTextureEncodingFromMap( this.value ), include: builder.isShader( 'vertex' ) } ); + + this.colorSpace = this.colorSpace || new ColorSpaceNode( this ); + code = this.colorSpace.build( builder, this.type ); + + builder.removeContext(); + + return builder.format( code, this.type, output ); + +}; + +TextureNode.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + if ( source.value ) this.value = source.value; + + this.uv = source.uv; + + if ( source.bias ) this.bias = source.bias; + if ( source.project !== undefined ) this.project = source.project; + +}; + +TextureNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + if ( this.value ) data.value = this.value.uuid; + + data.uv = this.uv.toJSON( meta ).uuid; + data.project = this.project; + + if ( this.bias ) data.bias = this.bias.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { TextureNode }; diff --git a/three/jsutil/nodes/inputs/Vector2Node.js b/three/jsutil/nodes/inputs/Vector2Node.js new file mode 100644 index 000000000..ebc4add3a --- /dev/null +++ b/three/jsutil/nodes/inputs/Vector2Node.js @@ -0,0 +1,55 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function Vector2Node( x, y ) { + + InputNode.call( this, 'v2' ); + + this.value = x instanceof THREE.Vector2 ? x : new THREE.Vector2( x, y ); + +} + +Vector2Node.prototype = Object.create( InputNode.prototype ); +Vector2Node.prototype.constructor = Vector2Node; +Vector2Node.prototype.nodeType = "Vector2"; + +NodeUtils.addShortcuts( Vector2Node.prototype, 'value', [ 'x', 'y' ] ); + +Vector2Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( "vec2( " + this.x + ", " + this.y + " )", type, output ); + +}; + +Vector2Node.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value.copy( source ); + +}; + +Vector2Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.x = this.x; + data.y = this.y; + + if ( this.readonly === true ) data.readonly = true; + + } + + return data; + +}; + +export { Vector2Node }; diff --git a/three/jsutil/nodes/inputs/Vector3Node.js b/three/jsutil/nodes/inputs/Vector3Node.js new file mode 100644 index 000000000..71554d0f2 --- /dev/null +++ b/three/jsutil/nodes/inputs/Vector3Node.js @@ -0,0 +1,56 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function Vector3Node( x, y, z ) { + + InputNode.call( this, 'v3' ); + + this.value = x instanceof THREE.Vector3 ? x : new THREE.Vector3( x, y, z ); + +} + +Vector3Node.prototype = Object.create( InputNode.prototype ); +Vector3Node.prototype.constructor = Vector3Node; +Vector3Node.prototype.nodeType = "Vector3"; + +NodeUtils.addShortcuts( Vector3Node.prototype, 'value', [ 'x', 'y', 'z' ] ); + +Vector3Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( "vec3( " + this.x + ", " + this.y + ", " + this.z + " )", type, output ); + +}; + +Vector3Node.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value.copy( source ); + +}; + +Vector3Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.x = this.x; + data.y = this.y; + data.z = this.z; + + if ( this.readonly === true ) data.readonly = true; + + } + + return data; + +}; + +export { Vector3Node }; diff --git a/three/jsutil/nodes/inputs/Vector4Node.js b/three/jsutil/nodes/inputs/Vector4Node.js new file mode 100644 index 000000000..7bc4a977e --- /dev/null +++ b/three/jsutil/nodes/inputs/Vector4Node.js @@ -0,0 +1,57 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { InputNode } from '../core/InputNode.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function Vector4Node( x, y, z, w ) { + + InputNode.call( this, 'v4' ); + + this.value = x instanceof THREE.Vector4 ? x : new THREE.Vector4( x, y, z, w ); + +} + +Vector4Node.prototype = Object.create( InputNode.prototype ); +Vector4Node.prototype.constructor = Vector4Node; +Vector4Node.prototype.nodeType = "Vector4"; + +NodeUtils.addShortcuts( Vector4Node.prototype, 'value', [ 'x', 'y', 'z', 'w' ] ); + +Vector4Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) { + + return builder.format( "vec4( " + this.x + ", " + this.y + ", " + this.z + ", " + this.w + " )", type, output ); + +}; + +Vector4Node.prototype.copy = function ( source ) { + + InputNode.prototype.copy.call( this, source ); + + this.value.copy( source ); + +}; + +Vector4Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.x = this.x; + data.y = this.y; + data.z = this.z; + data.w = this.w; + + if ( this.readonly === true ) data.readonly = true; + + } + + return data; + +}; + +export { Vector4Node }; diff --git a/three/jsutil/nodes/materials/MeshStandardNodeMaterial.js b/three/jsutil/nodes/materials/MeshStandardNodeMaterial.js new file mode 100644 index 000000000..958f5bb6f --- /dev/null +++ b/three/jsutil/nodes/materials/MeshStandardNodeMaterial.js @@ -0,0 +1,34 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { MeshStandardNode } from './nodes/MeshStandardNode.js'; +import { NodeMaterial } from './NodeMaterial.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function MeshStandardNodeMaterial() { + + var node = new MeshStandardNode(); + + NodeMaterial.call( this, node, node ); + + this.type = "MeshStandardNodeMaterial"; + +} + +MeshStandardNodeMaterial.prototype = Object.create( NodeMaterial.prototype ); +MeshStandardNodeMaterial.prototype.constructor = MeshStandardNodeMaterial; + +NodeUtils.addShortcuts( MeshStandardNodeMaterial.prototype, 'properties', [ + "color", + "roughness", + "metalness", + "map", + "normalMap", + "normalScale", + "metalnessMap", + "roughnessMap", + "envMap" +] ); + +export { MeshStandardNodeMaterial }; diff --git a/three/jsutil/nodes/materials/NodeMaterial.js b/three/jsutil/nodes/materials/NodeMaterial.js new file mode 100644 index 000000000..43d14deaa --- /dev/null +++ b/three/jsutil/nodes/materials/NodeMaterial.js @@ -0,0 +1,185 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { NodeBuilder } from '../core/NodeBuilder.js'; +import { ColorNode } from '../inputs/ColorNode.js'; +import { PositionNode } from '../accessors/PositionNode.js'; +import { RawNode } from './nodes/RawNode.js'; + +function NodeMaterial( vertex, fragment ) { + + THREE.ShaderMaterial.call( this ); + + this.vertex = vertex || new RawNode( new PositionNode( PositionNode.PROJECTION ) ); + this.fragment = fragment || new RawNode( new ColorNode( 0xFF0000 ) ); + + this.updaters = []; + +} + +NodeMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype ); +NodeMaterial.prototype.constructor = NodeMaterial; +NodeMaterial.prototype.type = "NodeMaterial"; + +NodeMaterial.prototype.isNodeMaterial = true; + +Object.defineProperties( NodeMaterial.prototype, { + + properties: { + + get: function () { + + return this.fragment.properties; + + } + + } + +} ); + +NodeMaterial.prototype.updateFrame = function ( frame ) { + + for ( var i = 0; i < this.updaters.length; ++ i ) { + + frame.updateNode( this.updaters[ i ] ); + + } + +}; + +NodeMaterial.prototype.onBeforeCompile = function ( shader, renderer ) { + + if ( this.needsUpdate ) { + + this.build( { renderer: renderer } ); + + shader.uniforms = this.uniforms; + shader.vertexShader = this.vertexShader; + shader.fragmentShader = this.fragmentShader; + + } + +}; + +NodeMaterial.prototype.build = function ( params ) { + + params = params || {}; + + var builder = params.builder || new NodeBuilder(); + + builder.setMaterial( this, params.renderer ); + builder.build( this.vertex, this.fragment ); + + this.vertexShader = builder.getCode( 'vertex' ); + this.fragmentShader = builder.getCode( 'fragment' ); + + this.defines = builder.defines; + this.uniforms = builder.uniforms; + this.extensions = builder.extensions; + this.updaters = builder.updaters; + + this.fog = builder.requires.fog; + this.lights = builder.requires.lights; + + this.transparent = builder.requires.transparent || this.blending > THREE.NormalBlending; + + this.needsUpdate = false; + + return this; + +}; + +NodeMaterial.prototype.copy = function ( source ) { + + var uuid = this.uuid; + + for ( var name in source ) { + + this[ name ] = source[ name ]; + + } + + this.uuid = uuid; + + if ( source.userData !== undefined ) { + + this.userData = JSON.parse( JSON.stringify( source.userData ) ); + + } + +}; + +NodeMaterial.prototype.toJSON = function ( meta ) { + + var isRootObject = ( meta === undefined || typeof meta === 'string' ); + + if ( isRootObject ) { + + meta = { + nodes: {} + }; + + } + + if ( meta && ! meta.materials ) meta.materials = {}; + + if ( ! meta.materials[ this.uuid ] ) { + + var data = {}; + + data.uuid = this.uuid; + data.type = this.type; + + meta.materials[ data.uuid ] = data; + + if ( this.name !== "" ) data.name = this.name; + + if ( this.size !== undefined ) data.size = this.size; + if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; + + if ( this.blending !== THREE.NormalBlending ) data.blending = this.blending; + if ( this.flatShading === true ) data.flatShading = this.flatShading; + if ( this.side !== THREE.FrontSide ) data.side = this.side; + if ( this.vertexColors !== THREE.NoColors ) data.vertexColors = this.vertexColors; + + if ( this.depthFunc !== THREE.LessEqualDepth ) data.depthFunc = this.depthFunc; + if ( this.depthTest === false ) data.depthTest = this.depthTest; + if ( this.depthWrite === false ) data.depthWrite = this.depthWrite; + + if ( this.linewidth !== 1 ) data.linewidth = this.linewidth; + if ( this.dashSize !== undefined ) data.dashSize = this.dashSize; + if ( this.gapSize !== undefined ) data.gapSize = this.gapSize; + if ( this.scale !== undefined ) data.scale = this.scale; + + if ( this.dithering === true ) data.dithering = true; + + if ( this.wireframe === true ) data.wireframe = this.wireframe; + if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth; + if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap; + if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin; + + if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest; + if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha; + + if ( this.morphTargets === true ) data.morphTargets = true; + if ( this.skinning === true ) data.skinning = true; + + if ( this.visible === false ) data.visible = false; + if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; + + data.fog = this.fog; + data.lights = this.lights; + + data.vertex = this.vertex.toJSON( meta ).uuid; + data.fragment = this.fragment.toJSON( meta ).uuid; + + } + + meta.material = this.uuid; + + return meta; + +}; + +export { NodeMaterial }; diff --git a/three/jsutil/nodes/materials/PhongNodeMaterial.js b/three/jsutil/nodes/materials/PhongNodeMaterial.js new file mode 100644 index 000000000..22b6fec5d --- /dev/null +++ b/three/jsutil/nodes/materials/PhongNodeMaterial.js @@ -0,0 +1,38 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { PhongNode } from './nodes/PhongNode.js'; +import { NodeMaterial } from './NodeMaterial.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function PhongNodeMaterial() { + + var node = new PhongNode(); + + NodeMaterial.call( this, node, node ); + + this.type = "PhongNodeMaterial"; + +} + +PhongNodeMaterial.prototype = Object.create( NodeMaterial.prototype ); +PhongNodeMaterial.prototype.constructor = PhongNodeMaterial; + +NodeUtils.addShortcuts( PhongNodeMaterial.prototype, 'fragment', [ + 'color', + 'alpha', + 'specular', + 'shininess', + 'normal', + 'emissive', + 'ambient', + 'light', + 'shadow', + 'ao', + 'environment', + 'environmentAlpha', + 'position' +] ); + +export { PhongNodeMaterial }; diff --git a/three/jsutil/nodes/materials/SpriteNodeMaterial.js b/three/jsutil/nodes/materials/SpriteNodeMaterial.js new file mode 100644 index 000000000..c0f080d16 --- /dev/null +++ b/three/jsutil/nodes/materials/SpriteNodeMaterial.js @@ -0,0 +1,29 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { SpriteNode } from './nodes/SpriteNode.js'; +import { NodeMaterial } from './NodeMaterial.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function SpriteNodeMaterial() { + + var node = new SpriteNode(); + + NodeMaterial.call( this, node, node ); + + this.type = "SpriteNodeMaterial"; + +} + +SpriteNodeMaterial.prototype = Object.create( NodeMaterial.prototype ); +SpriteNodeMaterial.prototype.constructor = SpriteNodeMaterial; + +NodeUtils.addShortcuts( SpriteNodeMaterial.prototype, 'fragment', [ + 'color', + 'alpha', + 'position', + 'spherical' +] ); + +export { SpriteNodeMaterial }; diff --git a/three/jsutil/nodes/materials/StandardNodeMaterial.js b/three/jsutil/nodes/materials/StandardNodeMaterial.js new file mode 100644 index 000000000..3cdcef92a --- /dev/null +++ b/three/jsutil/nodes/materials/StandardNodeMaterial.js @@ -0,0 +1,40 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { StandardNode } from './nodes/StandardNode.js'; +import { NodeMaterial } from './NodeMaterial.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +function StandardNodeMaterial() { + + var node = new StandardNode(); + + NodeMaterial.call( this, node, node ); + + this.type = "StandardNodeMaterial"; + +} + +StandardNodeMaterial.prototype = Object.create( NodeMaterial.prototype ); +StandardNodeMaterial.prototype.constructor = StandardNodeMaterial; + +NodeUtils.addShortcuts( StandardNodeMaterial.prototype, 'fragment', [ + 'color', + 'alpha', + 'roughness', + 'metalness', + 'reflectivity', + 'clearCoat', + 'clearCoatRoughness', + 'normal', + 'emissive', + 'ambient', + 'light', + 'shadow', + 'ao', + 'environment', + 'position' +] ); + +export { StandardNodeMaterial }; diff --git a/three/jsutil/nodes/materials/nodes/MeshStandardNode.js b/three/jsutil/nodes/materials/nodes/MeshStandardNode.js new file mode 100644 index 000000000..79b60e63d --- /dev/null +++ b/three/jsutil/nodes/materials/nodes/MeshStandardNode.js @@ -0,0 +1,113 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { StandardNode } from './StandardNode.js'; +import { PropertyNode } from '../../inputs/PropertyNode.js'; +import { OperatorNode } from '../../math/OperatorNode.js'; +import { SwitchNode } from '../../utils/SwitchNode.js'; +import { NormalMapNode } from '../../misc/NormalMapNode.js'; + +function MeshStandardNode() { + + StandardNode.call( this ); + + this.properties = { + color: new THREE.Color( 0xffffff ), + roughness: 0.5, + metalness: 0.5, + normalScale: new THREE.Vector2( 1, 1 ) + }; + + this.inputs = { + color: new PropertyNode( this.properties, 'color', 'c' ), + roughness: new PropertyNode( this.properties, 'roughness', 'f' ), + metalness: new PropertyNode( this.properties, 'metalness', 'f' ), + normalScale: new PropertyNode( this.properties, 'normalScale', 'v2' ) + }; + +} + +MeshStandardNode.prototype = Object.create( StandardNode.prototype ); +MeshStandardNode.prototype.constructor = MeshStandardNode; +MeshStandardNode.prototype.nodeType = "MeshStandard"; + +MeshStandardNode.prototype.build = function ( builder ) { + + var props = this.properties, + inputs = this.inputs; + + if ( builder.isShader( 'fragment' ) ) { + + // slots + // * color + // * map + + var color = builder.findNode( props.color, inputs.color ), + map = builder.resolve( props.map ); + + this.color = map ? new OperatorNode( color, map, OperatorNode.MUL ) : color; + + // slots + // * roughness + // * roughnessMap + + var roughness = builder.findNode( props.roughness, inputs.roughness ), + roughnessMap = builder.resolve( props.roughnessMap ); + + this.roughness = roughnessMap ? new OperatorNode( roughness, new SwitchNode( roughnessMap, "g" ), OperatorNode.MUL ) : roughness; + + // slots + // * metalness + // * metalnessMap + + var metalness = builder.findNode( props.metalness, inputs.metalness ), + metalnessMap = builder.resolve( props.metalnessMap ); + + this.metalness = metalnessMap ? new OperatorNode( metalness, new SwitchNode( metalnessMap, "b" ), OperatorNode.MUL ) : metalness; + + // slots + // * normalMap + // * normalScale + + if ( props.normalMap ) { + + this.normal = new NormalMapNode( builder.resolve( props.normalMap ) ); + this.normal.scale = builder.findNode( props.normalScale, inputs.normalScale ); + + } else { + + this.normal = undefined; + + } + + // slots + // * envMap + + this.environment = builder.resolve( props.envMap ); + + } + + // build code + + return StandardNode.prototype.build.call( this, builder ); + +}; + +MeshStandardNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + console.warn( ".toJSON not implemented in", this ); + + } + + return data; + +}; + +export { MeshStandardNode }; diff --git a/three/jsutil/nodes/materials/nodes/PhongNode.js b/three/jsutil/nodes/materials/nodes/PhongNode.js new file mode 100644 index 000000000..9a79b6793 --- /dev/null +++ b/three/jsutil/nodes/materials/nodes/PhongNode.js @@ -0,0 +1,393 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from '../../core/Node.js'; +import { ColorNode } from '../../inputs/ColorNode.js'; +import { FloatNode } from '../../inputs/FloatNode.js'; + +function PhongNode() { + + Node.call( this ); + + this.color = new ColorNode( 0xEEEEEE ); + this.specular = new ColorNode( 0x111111 ); + this.shininess = new FloatNode( 30 ); + +} + +PhongNode.prototype = Object.create( Node.prototype ); +PhongNode.prototype.constructor = PhongNode; +PhongNode.prototype.nodeType = "Phong"; + +PhongNode.prototype.build = function ( builder ) { + + var code; + + builder.define( 'PHONG' ); + + builder.requires.lights = true; + + if ( builder.isShader( 'vertex' ) ) { + + var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined; + + builder.mergeUniform( THREE.UniformsUtils.merge( [ + + THREE.UniformsLib.fog, + THREE.UniformsLib.lights + + ] ) ); + + builder.addParsCode( [ + "varying vec3 vViewPosition;", + + "#ifndef FLAT_SHADED", + + " varying vec3 vNormal;", + + "#endif", + + //"#include ", // encoding functions + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " + ].join( "\n" ) ); + + var output = [ + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + "#ifndef FLAT_SHADED", // normal computed with derivatives when FLAT_SHADED + + " vNormal = normalize( transformedNormal );", + + "#endif", + + "#include " + ]; + + if ( position ) { + + output.push( + position.code, + position.result ? "transformed = " + position.result + ";" : '' + ); + + } + + output.push( + " #include ", + " #include ", + " #include ", + " #include ", + " #include ", + " #include ", + + " vViewPosition = - mvPosition.xyz;", + + " #include ", + " #include ", + " #include " + ); + + code = output.join( "\n" ); + + } else { + + // parse all nodes to reuse generate codes + + this.color.parse( builder, { slot: 'color' } ); + this.specular.parse( builder ); + this.shininess.parse( builder ); + + if ( this.alpha ) this.alpha.parse( builder ); + + if ( this.normal ) this.normal.parse( builder ); + + if ( this.light ) this.light.parse( builder, { cache: 'light' } ); + + if ( this.ao ) this.ao.parse( builder ); + if ( this.ambient ) this.ambient.parse( builder ); + if ( this.shadow ) this.shadow.parse( builder ); + if ( this.emissive ) this.emissive.parse( builder, { slot: 'emissive' } ); + + if ( this.environment ) this.environment.parse( builder, { slot: 'environment' } ); + if ( this.environmentAlpha && this.environment ) this.environmentAlpha.parse( builder ); + + // build code + + var color = this.color.buildCode( builder, 'c', { slot: 'color' } ); + var specular = this.specular.buildCode( builder, 'c' ); + var shininess = this.shininess.buildCode( builder, 'f' ); + + var alpha = this.alpha ? this.alpha.buildCode( builder, 'f' ) : undefined; + + var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined; + + var light = this.light ? this.light.buildCode( builder, 'v3', { cache: 'light' } ) : undefined; + + var ao = this.ao ? this.ao.buildCode( builder, 'f' ) : undefined; + var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined; + var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined; + var emissive = this.emissive ? this.emissive.buildCode( builder, 'c', { slot: 'emissive' } ) : undefined; + + var environment = this.environment ? this.environment.buildCode( builder, 'c', { slot: 'environment' } ) : undefined; + var environmentAlpha = this.environmentAlpha && this.environment ? this.environmentAlpha.buildCode( builder, 'f' ) : undefined; + + builder.requires.transparent = alpha != undefined; + + builder.addParsCode( [ + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " + ].join( "\n" ) ); + + var output = [ + // prevent undeclared normal + "#include ", + + // prevent undeclared material + " BlinnPhongMaterial material;", + + color.code, + " vec3 diffuseColor = " + color.result + ";", + " ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );", + + "#include ", + + specular.code, + " vec3 specular = " + specular.result + ";", + + shininess.code, + " float shininess = max( 0.0001, " + shininess.result + " );", + + " float specularStrength = 1.0;" // Ignored in MaterialNode ( replace to specular ) + ]; + + if ( alpha ) { + + output.push( + alpha.code, + '#ifdef ALPHATEST', + + 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + + '#endif' + ); + + } + + if ( normal ) { + + output.push( + normal.code, + 'normal = ' + normal.result + ';' + ); + + } + + // optimization for now + + output.push( 'material.diffuseColor = ' + ( light ? 'vec3( 1.0 )' : 'diffuseColor' ) + ';' ); + + output.push( + // accumulation + 'material.specularColor = specular;', + 'material.specularShininess = shininess;', + 'material.specularStrength = specularStrength;', + + "#include ", + "#include " + ); + + if ( light ) { + + output.push( + light.code, + "reflectedLight.directDiffuse = " + light.result + ";" + ); + + // apply color + + output.push( + "reflectedLight.directDiffuse *= diffuseColor;", + "reflectedLight.indirectDiffuse *= diffuseColor;" + ); + + } + + if ( ao ) { + + output.push( + ao.code, + "reflectedLight.indirectDiffuse *= " + ao.result + ";" + ); + + } + + if ( ambient ) { + + output.push( + ambient.code, + "reflectedLight.indirectDiffuse += " + ambient.result + ";" + ); + + } + + if ( shadow ) { + + output.push( + shadow.code, + "reflectedLight.directDiffuse *= " + shadow.result + ";", + "reflectedLight.directSpecular *= " + shadow.result + ";" + ); + + } + + if ( emissive ) { + + output.push( + emissive.code, + "reflectedLight.directDiffuse += " + emissive.result + ";" + ); + + } + + output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;" ); + + if ( environment ) { + + output.push( environment.code ); + + if ( environmentAlpha ) { + + output.push( + environmentAlpha.code, + "outgoingLight = mix( outgoingLight, " + environment.result + ", " + environmentAlpha.result + " );" + ); + + } else { + + output.push( "outgoingLight = " + environment.result + ";" ); + + } + + } + /* + switch( builder.material.combine ) { + + case THREE.ENVMAP_BLENDING_MULTIPLY: + + //output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;" ); + //outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + + break; + + + } + */ + if ( alpha ) { + + output.push( "gl_FragColor = vec4( outgoingLight, " + alpha.result + " );" ); + + } else { + + output.push( "gl_FragColor = vec4( outgoingLight, 1.0 );" ); + + } + + output.push( + "#include ", + "#include ", + "#include ", + "#include " + ); + + code = output.join( "\n" ); + + } + + return code; + +}; + +PhongNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + // vertex + + if ( source.position ) this.position = source.position; + + // fragment + + this.color = source.color; + this.specular = source.specular; + this.shininess = source.shininess; + + if ( source.alpha ) this.alpha = source.alpha; + + if ( source.normal ) this.normal = source.normal; + + if ( source.light ) this.light = source.light; + if ( source.shadow ) this.shadow = source.shadow; + + if ( source.ao ) this.ao = source.ao; + + if ( source.emissive ) this.emissive = source.emissive; + if ( source.ambient ) this.ambient = source.ambient; + + if ( source.environment ) this.environment = source.environment; + if ( source.environmentAlpha ) this.environmentAlpha = source.environmentAlpha; + +}; + +PhongNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + // vertex + + if ( this.position ) data.position = this.position.toJSON( meta ).uuid; + + // fragment + + data.color = this.color.toJSON( meta ).uuid; + data.specular = this.specular.toJSON( meta ).uuid; + data.shininess = this.shininess.toJSON( meta ).uuid; + + if ( this.alpha ) data.alpha = this.alpha.toJSON( meta ).uuid; + + if ( this.normal ) data.normal = this.normal.toJSON( meta ).uuid; + + if ( this.light ) data.light = this.light.toJSON( meta ).uuid; + + if ( this.ao ) data.ao = this.ao.toJSON( meta ).uuid; + if ( this.ambient ) data.ambient = this.ambient.toJSON( meta ).uuid; + if ( this.shadow ) data.shadow = this.shadow.toJSON( meta ).uuid; + if ( this.emissive ) data.emissive = this.emissive.toJSON( meta ).uuid; + + if ( this.environment ) data.environment = this.environment.toJSON( meta ).uuid; + if ( this.environmentAlpha ) data.environmentAlpha = this.environmentAlpha.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { PhongNode }; diff --git a/three/jsutil/nodes/materials/nodes/RawNode.js b/three/jsutil/nodes/materials/nodes/RawNode.js new file mode 100644 index 000000000..125a97e6c --- /dev/null +++ b/three/jsutil/nodes/materials/nodes/RawNode.js @@ -0,0 +1,62 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from '../../core/Node.js'; + +function RawNode( value ) { + + Node.call( this, 'v4' ); + + this.value = value; + +} + +RawNode.prototype = Object.create( Node.prototype ); +RawNode.prototype.constructor = RawNode; +RawNode.prototype.nodeType = "Raw"; + +RawNode.prototype.generate = function ( builder ) { + + var data = this.value.parseAndBuildCode( builder, this.type ), + code = data.code + '\n'; + + if ( builder.isShader( 'vertex' ) ) { + + code += 'gl_Position = ' + data.result + ';'; + + } else { + + code += 'gl_FragColor = ' + data.result + ';'; + + } + + return code; + +}; + +RawNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + this.value = source.value; + +}; + +RawNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { RawNode }; diff --git a/three/jsutil/nodes/materials/nodes/SpriteNode.js b/three/jsutil/nodes/materials/nodes/SpriteNode.js new file mode 100644 index 000000000..f3d23822b --- /dev/null +++ b/three/jsutil/nodes/materials/nodes/SpriteNode.js @@ -0,0 +1,213 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from '../../core/Node.js'; +import { ColorNode } from '../../inputs/ColorNode.js'; + +function SpriteNode() { + + Node.call( this ); + + this.color = new ColorNode( 0xEEEEEE ); + this.spherical = true; + +} + +SpriteNode.prototype = Object.create( Node.prototype ); +SpriteNode.prototype.constructor = SpriteNode; +SpriteNode.prototype.nodeType = "Sprite"; + +SpriteNode.prototype.build = function ( builder ) { + + var output, code; + + builder.define( 'SPRITE' ); + + builder.requires.lights = false; + builder.requires.transparent = this.alpha !== undefined; + + if ( builder.isShader( 'vertex' ) ) { + + var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined; + + builder.mergeUniform( THREE.UniformsUtils.merge( [ + THREE.UniformsLib.fog + ] ) ); + + builder.addParsCode( [ + "#include ", + "#include ", + "#include " + ].join( "\n" ) ); + + output = [ + "#include ", + "#include " + ]; + + if ( position ) { + + output.push( + position.code, + position.result ? "transformed = " + position.result + ";" : '' + ); + + } + + output.push( + "#include ", + "#include ", + + 'mat4 modelViewMtx = modelViewMatrix;', + 'mat4 modelMtx = modelMatrix;', + + // ignore position from modelMatrix (use vary position) + 'modelMtx[3][0] = 0.0;', + 'modelMtx[3][1] = 0.0;', + 'modelMtx[3][2] = 0.0;' + ); + + if ( ! this.spherical ) { + + output.push( + 'modelMtx[1][1] = 1.0;' + ); + + } + + output.push( + // http://www.geeks3d.com/20140807/billboarding-vertex-shader-glsl/ + // First colunm. + 'modelViewMtx[0][0] = 1.0;', + 'modelViewMtx[0][1] = 0.0;', + 'modelViewMtx[0][2] = 0.0;' + ); + + if ( this.spherical ) { + + output.push( + // Second colunm. + 'modelViewMtx[1][0] = 0.0;', + 'modelViewMtx[1][1] = 1.0;', + 'modelViewMtx[1][2] = 0.0;' + ); + + } + + output.push( + // Thrid colunm. + 'modelViewMtx[2][0] = 0.0;', + 'modelViewMtx[2][1] = 0.0;', + 'modelViewMtx[2][2] = 1.0;', + + "gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( transformed, 1.0 );", + + "#include ", + "#include ", + "#include " + ); + + } else { + + builder.addParsCode( [ + "#include ", + "#include ", + "#include " + ].join( "\n" ) ); + + builder.addCode( [ + "#include ", + "#include " + ].join( "\n" ) ); + + // parse all nodes to reuse generate codes + + if ( this.alpha ) this.alpha.parse( builder ); + + this.color.parse( builder, { slot: 'color' } ); + + // build code + + var alpha = this.alpha ? this.alpha.buildCode( builder, 'f' ) : undefined, + color = this.color.buildCode( builder, 'c', { slot: 'color' } ); + + if ( alpha ) { + + output = [ + alpha.code, + '#ifdef ALPHATEST', + + 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + + '#endif', + color.code, + "gl_FragColor = vec4( " + color.result + ", " + alpha.result + " );" + ]; + + } else { + + output = [ + color.code, + "gl_FragColor = vec4( " + color.result + ", 1.0 );" + ]; + + } + + output.push( + "#include ", + "#include ", + "#include " + ); + + } + + return output.join( "\n" ); + +}; + +SpriteNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + // vertex + + if ( source.position ) this.position = source.position; + + // fragment + + this.color = source.color; + + if ( source.spherical !== undefined ) this.spherical = source.spherical; + + if ( source.alpha ) this.alpha = source.alpha; + +}; + +SpriteNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + // vertex + + if ( this.position ) data.position = this.position.toJSON( meta ).uuid; + + // fragment + + data.color = this.color.toJSON( meta ).uuid; + + if ( this.spherical === false ) data.spherical = false; + + if ( this.alpha ) data.alpha = this.alpha.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { SpriteNode }; diff --git a/three/jsutil/nodes/materials/nodes/StandardNode.js b/three/jsutil/nodes/materials/nodes/StandardNode.js new file mode 100644 index 000000000..97bfaed60 --- /dev/null +++ b/three/jsutil/nodes/materials/nodes/StandardNode.js @@ -0,0 +1,471 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from '../../core/Node.js'; +import { ColorNode } from '../../inputs/ColorNode.js'; +import { FloatNode } from '../../inputs/FloatNode.js'; +import { RoughnessToBlinnExponentNode } from '../../bsdfs/RoughnessToBlinnExponentNode.js'; + +function StandardNode() { + + Node.call( this ); + + this.color = new ColorNode( 0xEEEEEE ); + this.roughness = new FloatNode( 0.5 ); + this.metalness = new FloatNode( 0.5 ); + +} + +StandardNode.prototype = Object.create( Node.prototype ); +StandardNode.prototype.constructor = StandardNode; +StandardNode.prototype.nodeType = "Standard"; + +StandardNode.prototype.build = function ( builder ) { + + var code; + + builder.define( this.clearCoat || this.clearCoatRoughness ? 'PHYSICAL' : 'STANDARD' ); + + builder.requires.lights = true; + + builder.extensions.shaderTextureLOD = true; + + if ( builder.isShader( 'vertex' ) ) { + + var position = this.position ? this.position.parseAndBuildCode( builder, 'v3', { cache: 'position' } ) : undefined; + + builder.mergeUniform( THREE.UniformsUtils.merge( [ + + THREE.UniformsLib.fog, + THREE.UniformsLib.lights + + ] ) ); + + builder.addParsCode( [ + "varying vec3 vViewPosition;", + + "#ifndef FLAT_SHADED", + + " varying vec3 vNormal;", + + "#endif", + + //"#include ", // encoding functions + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " + + ].join( "\n" ) ); + + var output = [ + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + "#ifndef FLAT_SHADED", // Normal computed with derivatives when FLAT_SHADED + + " vNormal = normalize( transformedNormal );", + + "#endif", + + "#include " + ]; + + if ( position ) { + + output.push( + position.code, + position.result ? "transformed = " + position.result + ";" : '' + ); + + } + + output.push( + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + " vViewPosition = - mvPosition.xyz;", + + "#include ", + "#include " + ); + + code = output.join( "\n" ); + + } else { + + var contextEnvironment = { + bias: RoughnessToBlinnExponentNode, + gamma: true + }; + + var contextGammaOnly = { + gamma: true + }; + + var useClearCoat = ! builder.isDefined( 'STANDARD' ); + + // parse all nodes to reuse generate codes + + this.color.parse( builder, { slot: 'color', context: contextGammaOnly } ); + this.roughness.parse( builder ); + this.metalness.parse( builder ); + + if ( this.alpha ) this.alpha.parse( builder ); + + if ( this.normal ) this.normal.parse( builder ); + + if ( this.clearCoat ) this.clearCoat.parse( builder ); + if ( this.clearCoatRoughness ) this.clearCoatRoughness.parse( builder ); + + if ( this.reflectivity ) this.reflectivity.parse( builder ); + + if ( this.light ) this.light.parse( builder, { cache: 'light' } ); + + if ( this.ao ) this.ao.parse( builder ); + if ( this.ambient ) this.ambient.parse( builder ); + if ( this.shadow ) this.shadow.parse( builder ); + if ( this.emissive ) this.emissive.parse( builder, { slot: 'emissive' } ); + + if ( this.environment ) this.environment.parse( builder, { cache: 'env', context: contextEnvironment, slot: 'environment' } ); // isolate environment from others inputs ( see TextureNode, CubeTextureNode ) + + // build code + + var color = this.color.buildCode( builder, 'c', { slot: 'color', context: contextGammaOnly } ); + var roughness = this.roughness.buildCode( builder, 'f' ); + var metalness = this.metalness.buildCode( builder, 'f' ); + + var alpha = this.alpha ? this.alpha.buildCode( builder, 'f' ) : undefined; + + var normal = this.normal ? this.normal.buildCode( builder, 'v3' ) : undefined; + + var clearCoat = this.clearCoat ? this.clearCoat.buildCode( builder, 'f' ) : undefined; + var clearCoatRoughness = this.clearCoatRoughness ? this.clearCoatRoughness.buildCode( builder, 'f' ) : undefined; + + var reflectivity = this.reflectivity ? this.reflectivity.buildCode( builder, 'f' ) : undefined; + + var light = this.light ? this.light.buildCode( builder, 'v3', { cache: 'light' } ) : undefined; + + var ao = this.ao ? this.ao.buildCode( builder, 'f' ) : undefined; + var ambient = this.ambient ? this.ambient.buildCode( builder, 'c' ) : undefined; + var shadow = this.shadow ? this.shadow.buildCode( builder, 'c' ) : undefined; + var emissive = this.emissive ? this.emissive.buildCode( builder, 'c', { slot: 'emissive' } ) : undefined; + + var environment = this.environment ? this.environment.buildCode( builder, 'c', { cache: 'env', context: contextEnvironment, slot: 'environment' } ) : undefined; + + var clearCoatEnv = useClearCoat && environment ? this.environment.buildCode( builder, 'c', { cache: 'clearCoat', context: contextEnvironment, slot: 'environment' } ) : undefined; + + builder.requires.transparent = alpha !== undefined; + + builder.addParsCode( [ + + "varying vec3 vViewPosition;", + + "#ifndef FLAT_SHADED", + + " varying vec3 vNormal;", + + "#endif", + + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include " + ].join( "\n" ) ); + + var output = [ + "#include ", + + // add before: prevent undeclared normal + " #include ", + + // add before: prevent undeclared material + " PhysicalMaterial material;", + " material.diffuseColor = vec3( 1.0 );", + + color.code, + " vec3 diffuseColor = " + color.result + ";", + " ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );", + + "#include ", + + roughness.code, + " float roughnessFactor = " + roughness.result + ";", + + metalness.code, + " float metalnessFactor = " + metalness.result + ";" + ]; + + if ( alpha ) { + + output.push( + alpha.code, + '#ifdef ALPHATEST', + + 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + + '#endif' + ); + + } + + if ( normal ) { + + output.push( + normal.code, + 'normal = ' + normal.result + ';' + ); + + } + + // optimization for now + + output.push( + 'material.diffuseColor = ' + ( light ? 'vec3( 1.0 )' : 'diffuseColor * (1.0 - metalnessFactor)' ) + ';', + 'material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );' + ); + + if ( clearCoat ) { + + output.push( + clearCoat.code, + 'material.clearCoat = saturate( ' + clearCoat.result + ' );' + ); + + } else if ( useClearCoat ) { + + output.push( 'material.clearCoat = 0.0;' ); + + } + + if ( clearCoatRoughness ) { + + output.push( + clearCoatRoughness.code, + 'material.clearCoatRoughness = clamp( ' + clearCoatRoughness.result + ', 0.04, 1.0 );' + ); + + } else if ( useClearCoat ) { + + output.push( 'material.clearCoatRoughness = 0.0;' ); + + } + + if ( reflectivity ) { + + output.push( + reflectivity.code, + 'material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( ' + reflectivity.result + ' ) ), diffuseColor, metalnessFactor );' + ); + + } else { + + output.push( + 'material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor, metalnessFactor );' + ); + + } + + output.push( + "#include " + ); + + if ( light ) { + + output.push( + light.code, + "reflectedLight.directDiffuse = " + light.result + ";" + ); + + // apply color + + output.push( + "diffuseColor *= 1.0 - metalnessFactor;", + + "reflectedLight.directDiffuse *= diffuseColor;", + "reflectedLight.indirectDiffuse *= diffuseColor;" + ); + + } + + if ( ao ) { + + output.push( + ao.code, + "reflectedLight.indirectDiffuse *= " + ao.result + ";", + "float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );", + "reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, " + ao.result + ", material.specularRoughness );" + ); + + } + + if ( ambient ) { + + output.push( + ambient.code, + "reflectedLight.indirectDiffuse += " + ambient.result + ";" + ); + + } + + if ( shadow ) { + + output.push( + shadow.code, + "reflectedLight.directDiffuse *= " + shadow.result + ";", + "reflectedLight.directSpecular *= " + shadow.result + ";" + ); + + } + + if ( emissive ) { + + output.push( + emissive.code, + "reflectedLight.directDiffuse += " + emissive.result + ";" + ); + + } + + if ( environment ) { + + output.push( environment.code ); + + if ( clearCoatEnv ) { + + output.push( + clearCoatEnv.code, + "clearCoatRadiance += " + clearCoatEnv.result + ";" + ); + + } + + output.push( "radiance += " + environment.result + ";" ); + + } + + output.push( + "#include " + ); + + output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;" ); + + if ( alpha ) { + + output.push( "gl_FragColor = vec4( outgoingLight, " + alpha.result + " );" ); + + } else { + + output.push( "gl_FragColor = vec4( outgoingLight, 1.0 );" ); + + } + + output.push( + "#include ", + "#include ", + "#include ", + "#include ", + "#include " + ); + + code = output.join( "\n" ); + + } + + return code; + +}; + +StandardNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + // vertex + + if ( source.position ) this.position = source.position; + + // fragment + + this.color = source.color; + this.roughness = source.roughness; + this.metalness = source.metalness; + + if ( source.alpha ) this.alpha = source.alpha; + + if ( source.normal ) this.normal = source.normal; + + if ( source.clearCoat ) this.clearCoat = source.clearCoat; + if ( source.clearCoatRoughness ) this.clearCoatRoughness = source.clearCoatRoughness; + + if ( source.reflectivity ) this.reflectivity = source.reflectivity; + + if ( source.light ) this.light = source.light; + if ( source.shadow ) this.shadow = source.shadow; + + if ( source.ao ) this.ao = source.ao; + + if ( source.emissive ) this.emissive = source.emissive; + if ( source.ambient ) this.ambient = source.ambient; + + if ( source.environment ) this.environment = source.environment; + +}; + +StandardNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + // vertex + + if ( this.position ) data.position = this.position.toJSON( meta ).uuid; + + // fragment + + data.color = this.color.toJSON( meta ).uuid; + data.roughness = this.roughness.toJSON( meta ).uuid; + data.metalness = this.metalness.toJSON( meta ).uuid; + + if ( this.alpha ) data.alpha = this.alpha.toJSON( meta ).uuid; + + if ( this.normal ) data.normal = this.normal.toJSON( meta ).uuid; + + if ( this.clearCoat ) data.clearCoat = this.clearCoat.toJSON( meta ).uuid; + if ( this.clearCoatRoughness ) data.clearCoatRoughness = this.clearCoatRoughness.toJSON( meta ).uuid; + + if ( this.reflectivity ) data.reflectivity = this.reflectivity.toJSON( meta ).uuid; + + if ( this.light ) data.light = this.light.toJSON( meta ).uuid; + if ( this.shadow ) data.shadow = this.shadow.toJSON( meta ).uuid; + + if ( this.ao ) data.ao = this.ao.toJSON( meta ).uuid; + + if ( this.emissive ) data.emissive = this.emissive.toJSON( meta ).uuid; + if ( this.ambient ) data.ambient = this.ambient.toJSON( meta ).uuid; + + if ( this.environment ) data.environment = this.environment.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { StandardNode }; diff --git a/three/jsutil/nodes/math/CondNode.js b/three/jsutil/nodes/math/CondNode.js new file mode 100644 index 000000000..484a1cacd --- /dev/null +++ b/three/jsutil/nodes/math/CondNode.js @@ -0,0 +1,107 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function CondNode( a, b, ifNode, elseNode, op ) { + + TempNode.call( this ); + + this.a = a; + this.b = b; + + this.ifNode = ifNode; + this.elseNode = elseNode; + + this.op = op; + +} + +CondNode.EQUAL = '=='; +CondNode.NOT_EQUAL = '!='; +CondNode.GREATER = '>'; +CondNode.GREATER_EQUAL = '>='; +CondNode.LESS = '<'; +CondNode.LESS_EQUAL = '<='; + +CondNode.prototype = Object.create( TempNode.prototype ); +CondNode.prototype.constructor = CondNode; +CondNode.prototype.nodeType = "Cond"; + +CondNode.prototype.getType = function ( builder ) { + + if ( builder.getTypeLength( this.elseNode.getType( builder ) ) > builder.getTypeLength( this.ifNode.getType( builder ) ) ) { + + return this.elseNode.getType( builder ); + + } + + return this.ifNode.getType( builder ); + +}; + +CondNode.prototype.getCondType = function ( builder ) { + + if ( builder.getTypeLength( this.b.getType( builder ) ) > builder.getTypeLength( this.a.getType( builder ) ) ) { + + return this.b.getType( builder ); + + } + + return this.a.getType( builder ); + +}; + +CondNode.prototype.generate = function ( builder, output ) { + + var type = this.getType( builder ), + condType = this.getCondType( builder ), + a = this.a.build( builder, condType ), + b = this.b.build( builder, condType ), + ifNode = this.ifNode.build( builder, type ), + elseNode = this.elseNode.build( builder, type ); + + var code = '( ' + [ a, this.op, b, '?', ifNode, ':', elseNode ].join( ' ' ) + ' )'; + + return builder.format( code, this.getType( builder ), output ); + +}; + +CondNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.a = source.a; + this.b = source.b; + + this.ifNode = source.ifNode; + this.elseNode = source.elseNode; + + this.op = source.op; + +}; + +CondNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.a = this.a.toJSON( meta ).uuid; + data.b = this.b.toJSON( meta ).uuid; + + data.ifNode = this.ifNode.toJSON( meta ).uuid; + data.elseNode = this.elseNode.toJSON( meta ).uuid; + + data.op = this.op; + + } + + return data; + +}; + +export { CondNode }; diff --git a/three/jsutil/nodes/math/Math1Node.js b/three/jsutil/nodes/math/Math1Node.js new file mode 100644 index 000000000..5d76fefea --- /dev/null +++ b/three/jsutil/nodes/math/Math1Node.js @@ -0,0 +1,117 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function Math1Node( a, method ) { + + TempNode.call( this ); + + this.a = a; + + this.method = method; + +} + +Math1Node.RAD = 'radians'; +Math1Node.DEG = 'degrees'; +Math1Node.EXP = 'exp'; +Math1Node.EXP2 = 'exp2'; +Math1Node.LOG = 'log'; +Math1Node.LOG2 = 'log2'; +Math1Node.SQRT = 'sqrt'; +Math1Node.INV_SQRT = 'inversesqrt'; +Math1Node.FLOOR = 'floor'; +Math1Node.CEIL = 'ceil'; +Math1Node.NORMALIZE = 'normalize'; +Math1Node.FRACT = 'fract'; +Math1Node.SAT = 'saturate'; +Math1Node.SIN = 'sin'; +Math1Node.COS = 'cos'; +Math1Node.TAN = 'tan'; +Math1Node.ASIN = 'asin'; +Math1Node.ACOS = 'acos'; +Math1Node.ARCTAN = 'atan'; +Math1Node.ABS = 'abs'; +Math1Node.SIGN = 'sign'; +Math1Node.LENGTH = 'length'; +Math1Node.NEGATE = 'negate'; +Math1Node.INVERT = 'invert'; + +Math1Node.prototype = Object.create( TempNode.prototype ); +Math1Node.prototype.constructor = Math1Node; +Math1Node.prototype.nodeType = "Math1"; + +Math1Node.prototype.getType = function ( builder ) { + + switch ( this.method ) { + + case Math1Node.LENGTH: + + return 'f'; + + } + + return this.a.getType( builder ); + +}; + +Math1Node.prototype.generate = function ( builder, output ) { + + var type = this.getType( builder ), + result = this.a.build( builder, type ); + + switch ( this.method ) { + + case Math1Node.NEGATE: + + result = '( -' + result + ' )'; + + break; + + case Math1Node.INVERT: + + result = '( 1.0 - ' + result + ' )'; + + break; + + default: + + result = this.method + '( ' + result + ' )'; + + break; + + } + + return builder.format( result, type, output ); + +}; + +Math1Node.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.a = source.a; + this.method = source.method; + +}; + +Math1Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.a = this.a.toJSON( meta ).uuid; + data.method = this.method; + + } + + return data; + +}; + +export { Math1Node }; diff --git a/three/jsutil/nodes/math/Math2Node.js b/three/jsutil/nodes/math/Math2Node.js new file mode 100644 index 000000000..85d773b53 --- /dev/null +++ b/three/jsutil/nodes/math/Math2Node.js @@ -0,0 +1,140 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function Math2Node( a, b, method ) { + + TempNode.call( this ); + + this.a = a; + this.b = b; + + this.method = method; + +} + +Math2Node.MIN = 'min'; +Math2Node.MAX = 'max'; +Math2Node.MOD = 'mod'; +Math2Node.STEP = 'step'; +Math2Node.REFLECT = 'reflect'; +Math2Node.DISTANCE = 'distance'; +Math2Node.DOT = 'dot'; +Math2Node.CROSS = 'cross'; +Math2Node.POW = 'pow'; + +Math2Node.prototype = Object.create( TempNode.prototype ); +Math2Node.prototype.constructor = Math2Node; +Math2Node.prototype.nodeType = "Math2"; + +Math2Node.prototype.getInputType = function ( builder ) { + + // use the greater length vector + + if ( builder.getTypeLength( this.b.getType( builder ) ) > builder.getTypeLength( this.a.getType( builder ) ) ) { + + return this.b.getType( builder ); + + } + + return this.a.getType( builder ); + +}; + +Math2Node.prototype.getType = function ( builder ) { + + switch ( this.method ) { + + case Math2Node.DISTANCE: + case Math2Node.DOT: + + return 'f'; + + case Math2Node.CROSS: + + return 'v3'; + + } + + return this.getInputType( builder ); + +}; + +Math2Node.prototype.generate = function ( builder, output ) { + + var a, b, + type = this.getInputType( builder ), + al = builder.getTypeLength( this.a.getType( builder ) ), + bl = builder.getTypeLength( this.b.getType( builder ) ); + + // optimzer + + switch ( this.method ) { + + case Math2Node.CROSS: + + a = this.a.build( builder, 'v3' ); + b = this.b.build( builder, 'v3' ); + + break; + + case Math2Node.STEP: + + a = this.a.build( builder, al === 1 ? 'f' : type ); + b = this.b.build( builder, type ); + + break; + + case Math2Node.MIN: + case Math2Node.MAX: + case Math2Node.MOD: + + a = this.a.build( builder, type ); + b = this.b.build( builder, bl === 1 ? 'f' : type ); + + break; + + default: + + a = this.a.build( builder, type ); + b = this.b.build( builder, type ); + + break; + + } + + return builder.format( this.method + '( ' + a + ', ' + b + ' )', this.getType( builder ), output ); + +}; + +Math2Node.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.a = source.a; + this.b = source.b; + this.method = source.method; + +}; + +Math2Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.a = this.a.toJSON( meta ).uuid; + data.b = this.b.toJSON( meta ).uuid; + data.method = this.method; + + } + + return data; + +}; + +export { Math2Node }; diff --git a/three/jsutil/nodes/math/Math3Node.js b/three/jsutil/nodes/math/Math3Node.js new file mode 100644 index 000000000..6a9f295d8 --- /dev/null +++ b/three/jsutil/nodes/math/Math3Node.js @@ -0,0 +1,120 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function Math3Node( a, b, c, method ) { + + TempNode.call( this ); + + this.a = a; + this.b = b; + this.c = c; + + this.method = method; + +} + +Math3Node.MIX = 'mix'; +Math3Node.REFRACT = 'refract'; +Math3Node.SMOOTHSTEP = 'smoothstep'; +Math3Node.FACEFORWARD = 'faceforward'; + +Math3Node.prototype = Object.create( TempNode.prototype ); +Math3Node.prototype.constructor = Math3Node; +Math3Node.prototype.nodeType = "Math3"; + +Math3Node.prototype.getType = function ( builder ) { + + var a = builder.getTypeLength( this.a.getType( builder ) ); + var b = builder.getTypeLength( this.b.getType( builder ) ); + var c = builder.getTypeLength( this.c.getType( builder ) ); + + if ( a > b && a > c ) { + + return this.a.getType( builder ); + + } else if ( b > c ) { + + return this.b.getType( builder ); + + } + + return this.c.getType( builder ); + +}; + +Math3Node.prototype.generate = function ( builder, output ) { + + var a, b, c, + al = builder.getTypeLength( this.a.getType( builder ) ), + bl = builder.getTypeLength( this.b.getType( builder ) ), + cl = builder.getTypeLength( this.c.getType( builder ) ), + type = this.getType( builder ); + + // optimzer + + switch ( this.method ) { + + case Math3Node.REFRACT: + + a = this.a.build( builder, type ); + b = this.b.build( builder, type ); + c = this.c.build( builder, 'f' ); + + break; + + case Math3Node.MIX: + + a = this.a.build( builder, type ); + b = this.b.build( builder, type ); + c = this.c.build( builder, cl === 1 ? 'f' : type ); + + break; + + default: + + a = this.a.build( builder, type ); + b = this.b.build( builder, type ); + c = this.c.build( builder, type ); + + break; + + } + + return builder.format( this.method + '( ' + a + ', ' + b + ', ' + c + ' )', type, output ); + +}; + +Math3Node.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.a = source.a; + this.b = source.b; + this.c = source.c; + this.method = source.method; + +}; + +Math3Node.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.a = this.a.toJSON( meta ).uuid; + data.b = this.b.toJSON( meta ).uuid; + data.c = this.c.toJSON( meta ).uuid; + data.method = this.method; + + } + + return data; + +}; + +export { Math3Node }; diff --git a/three/jsutil/nodes/math/OperatorNode.js b/three/jsutil/nodes/math/OperatorNode.js new file mode 100644 index 000000000..b6044321f --- /dev/null +++ b/three/jsutil/nodes/math/OperatorNode.js @@ -0,0 +1,87 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; + +function OperatorNode( a, b, op ) { + + TempNode.call( this ); + + this.a = a; + this.b = b; + this.op = op; + +} + +OperatorNode.ADD = '+'; +OperatorNode.SUB = '-'; +OperatorNode.MUL = '*'; +OperatorNode.DIV = '/'; + +OperatorNode.prototype = Object.create( TempNode.prototype ); +OperatorNode.prototype.constructor = OperatorNode; +OperatorNode.prototype.nodeType = "Operator"; + +OperatorNode.prototype.getType = function ( builder ) { + + var a = this.a.getType( builder ), + b = this.b.getType( builder ); + + if ( builder.isTypeMatrix( a ) ) { + + return 'v4'; + + } else if ( builder.getTypeLength( b ) > builder.getTypeLength( a ) ) { + + // use the greater length vector + + return b; + + } + + return a; + +}; + +OperatorNode.prototype.generate = function ( builder, output ) { + + var data = builder.getNodeData( this ), + type = this.getType( builder ); + + var a = this.a.build( builder, type ), + b = this.b.build( builder, type ); + + return builder.format( '( ' + a + ' ' + this.op + ' ' + b + ' )', type, output ); + +}; + +OperatorNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.a = source.a; + this.b = source.b; + this.op = source.op; + +}; + +OperatorNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.a = this.a.toJSON( meta ).uuid; + data.b = this.b.toJSON( meta ).uuid; + data.op = this.op; + + } + + return data; + +}; + +export { OperatorNode }; diff --git a/three/jsutil/nodes/misc/BumpMapNode.js b/three/jsutil/nodes/misc/BumpMapNode.js new file mode 100644 index 000000000..f5f45b1df --- /dev/null +++ b/three/jsutil/nodes/misc/BumpMapNode.js @@ -0,0 +1,166 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FloatNode } from '../inputs/FloatNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { NormalNode } from '../accessors/NormalNode.js'; +import { PositionNode } from '../accessors/PositionNode.js'; + +function BumpMapNode( value, scale ) { + + TempNode.call( this, 'v3' ); + + this.value = value; + this.scale = scale || new FloatNode( 1 ); + + this.toNormalMap = false; + +} + +BumpMapNode.Nodes = ( function () { + + var dHdxy_fwd = new FunctionNode( [ + + // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen + // http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf + + // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2) + + "vec2 dHdxy_fwd( sampler2D bumpMap, vec2 vUv, float bumpScale ) {", + + // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 + + " vec2 dSTdx = dFdx( vUv );", + " vec2 dSTdy = dFdy( vUv );", + + " float Hll = bumpScale * texture2D( bumpMap, vUv ).x;", + " float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;", + " float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;", + + " return vec2( dBx, dBy );", + + "}" + + ].join( "\n" ), null, { derivatives: true } ); + + var perturbNormalArb = new FunctionNode( [ + + "vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {", + + // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 + + " vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );", + " vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );", + " vec3 vN = surf_norm;", // normalized + + " vec3 R1 = cross( vSigmaY, vN );", + " vec3 R2 = cross( vN, vSigmaX );", + + " float fDet = dot( vSigmaX, R1 );", + + " fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );", + + " vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );", + + " return normalize( abs( fDet ) * surf_norm - vGrad );", + + "}" + + ].join( "\n" ), [ dHdxy_fwd ], { derivatives: true } ); + + var bumpToNormal = new FunctionNode( [ + "vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, float scale ) {", + + " vec2 dSTdx = dFdx( uv );", + " vec2 dSTdy = dFdy( uv );", + + " float Hll = texture2D( bumpMap, uv ).x;", + " float dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;", + " float dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;", + + " return vec3( .5 - ( dBx * scale ), .5 - ( dBy * scale ), 1.0 );", + + "}" + ].join( "\n" ), null, { derivatives: true } ); + + return { + dHdxy_fwd: dHdxy_fwd, + perturbNormalArb: perturbNormalArb, + bumpToNormal: bumpToNormal + }; + +} )(); + +BumpMapNode.prototype = Object.create( TempNode.prototype ); +BumpMapNode.prototype.constructor = BumpMapNode; +BumpMapNode.prototype.nodeType = "BumpMap"; + +BumpMapNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + if ( this.toNormalMap ) { + + var bumpToNormal = builder.include( BumpMapNode.Nodes.bumpToNormal ); + + return builder.format( bumpToNormal + '( ' + this.value.build( builder, 'sampler2D' ) + ', ' + + this.value.uv.build( builder, 'v2' ) + ', ' + + this.scale.build( builder, 'f' ) + ' )', this.getType( builder ), output ); + + } else { + + var derivativeHeight = builder.include( BumpMapNode.Nodes.dHdxy_fwd ), + perturbNormalArb = builder.include( BumpMapNode.Nodes.perturbNormalArb ); + + this.normal = this.normal || new NormalNode(); + this.position = this.position || new PositionNode( PositionNode.VIEW ); + + var derivativeHeightCode = derivativeHeight + '( ' + this.value.build( builder, 'sampler2D' ) + ', ' + + this.value.uv.build( builder, 'v2' ) + ', ' + + this.scale.build( builder, 'f' ) + ' )'; + + return builder.format( perturbNormalArb + '( -' + this.position.build( builder, 'v3' ) + ', ' + + this.normal.build( builder, 'v3' ) + ', ' + + derivativeHeightCode + ' )', this.getType( builder ), output ); + + } + + } else { + + console.warn( "THREE.BumpMapNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); + + } + +}; + +BumpMapNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.value = source.value; + this.scale = source.scale; + +}; + +BumpMapNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value.toJSON( meta ).uuid; + data.scale = this.scale.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { BumpMapNode }; diff --git a/three/jsutil/nodes/misc/NormalMapNode.js b/three/jsutil/nodes/misc/NormalMapNode.js new file mode 100644 index 000000000..261d15a2d --- /dev/null +++ b/three/jsutil/nodes/misc/NormalMapNode.js @@ -0,0 +1,117 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { Vector2Node } from '../inputs/Vector2Node.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { UVNode } from '../accessors/UVNode.js'; +import { NormalNode } from '../accessors/NormalNode.js'; +import { PositionNode } from '../accessors/PositionNode.js'; + +function NormalMapNode( value, scale ) { + + TempNode.call( this, 'v3' ); + + this.value = value; + this.scale = scale || new Vector2Node( 1, 1 ); + +} + +NormalMapNode.Nodes = ( function () { + + var perturbNormal2Arb = new FunctionNode( [ + + // Per-Pixel Tangent Space Normal Mapping + // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html + + "vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 mUv, vec2 normalScale ) {", + + // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 + + " vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );", + " vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );", + " vec2 st0 = dFdx( mUv.st );", + " vec2 st1 = dFdy( mUv.st );", + + " float scale = sign( st1.t * st0.s - st0.t * st1.s );", // we do not care about the magnitude + + " vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );", + " vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );", + " vec3 N = normalize( surf_norm );", + " mat3 tsn = mat3( S, T, N );", + + " vec3 mapN = map * 2.0 - 1.0;", + + " mapN.xy *= normalScale;", + " mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );", + + " return normalize( tsn * mapN );", + + "}" + + ].join( "\n" ), null, { derivatives: true } ); + + return { + perturbNormal2Arb: perturbNormal2Arb + }; + +} )(); + +NormalMapNode.prototype = Object.create( TempNode.prototype ); +NormalMapNode.prototype.constructor = NormalMapNode; +NormalMapNode.prototype.nodeType = "NormalMap"; + +NormalMapNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + var perturbNormal2Arb = builder.include( NormalMapNode.Nodes.perturbNormal2Arb ); + + this.normal = this.normal || new NormalNode(); + this.position = this.position || new PositionNode( PositionNode.VIEW ); + this.uv = this.uv || new UVNode(); + + return builder.format( perturbNormal2Arb + '( -' + this.position.build( builder, 'v3' ) + ', ' + + this.normal.build( builder, 'v3' ) + ', ' + + this.value.build( builder, 'v3' ) + ', ' + + this.uv.build( builder, 'v2' ) + ', ' + + this.scale.build( builder, 'v2' ) + ' )', this.getType( builder ), output ); + + } else { + + console.warn( "THREE.NormalMapNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec3( 0.0 )', this.getType( builder ), output ); + + } + +}; + +NormalMapNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.value = source.value; + this.scale = source.scale; + +}; + +NormalMapNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.value = this.value.toJSON( meta ).uuid; + data.scale = this.scale.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { NormalMapNode }; diff --git a/three/jsutil/nodes/misc/TextureCubeNode.js b/three/jsutil/nodes/misc/TextureCubeNode.js new file mode 100644 index 000000000..0d9002016 --- /dev/null +++ b/three/jsutil/nodes/misc/TextureCubeNode.js @@ -0,0 +1,64 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { TextureCubeUVNode } from './TextureCubeUVNode.js'; + +function TextureCubeNode( value, uv ) { + + TempNode.call( this, 'v4' ); + + this.value = value; + this.uv = uv || new TextureCubeUVNode(); + +} + +TextureCubeNode.prototype = Object.create( TempNode.prototype ); +TextureCubeNode.prototype.constructor = TextureCubeNode; +TextureCubeNode.prototype.nodeType = "TextureCube"; + +TextureCubeNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + var uv_10 = this.uv.build( builder ) + '.uv_10', + uv_20 = this.uv.build( builder ) + '.uv_20', + t = this.uv.build( builder ) + '.t'; + + var color10 = builder.getTexelDecodingFunctionFromTexture( 'texture2D( ' + this.value.build( builder, 'sampler2D' ) + ', ' + uv_10 + ' )', this.value.value ), + color20 = builder.getTexelDecodingFunctionFromTexture( 'texture2D( ' + this.value.build( builder, 'sampler2D' ) + ', ' + uv_20 + ' )', this.value.value ); + + return builder.format( 'vec4( mix( ' + color10 + ', ' + color20 + ', ' + t + ' ).rgb, 1.0 )', this.getType( builder ), output ); + + } else { + + console.warn( "THREE.TextureCubeNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec4( 0.0 )', this.getType( builder ), output ); + + } + +}; + +TextureCubeNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.uv = this.uv.toJSON( meta ).uuid; + data.textureSize = this.textureSize.toJSON( meta ).uuid; + data.blinnExponentToRoughness = this.blinnExponentToRoughness.toJSON( meta ).uuid; + + if ( this.roughness ) data.roughness = this.roughness.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { TextureCubeNode }; diff --git a/three/jsutil/nodes/misc/TextureCubeUVNode.js b/three/jsutil/nodes/misc/TextureCubeUVNode.js new file mode 100644 index 000000000..e4f98189f --- /dev/null +++ b/three/jsutil/nodes/misc/TextureCubeUVNode.js @@ -0,0 +1,209 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { ConstNode } from '../core/ConstNode.js'; +import { StructNode } from '../core/StructNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { ReflectNode } from '../accessors/ReflectNode.js'; +import { FloatNode } from '../inputs/FloatNode.js'; +import { BlinnExponentToRoughnessNode } from '../bsdfs/BlinnExponentToRoughnessNode.js'; + +function TextureCubeUVNode( uv, textureSize, blinnExponentToRoughness ) { + + TempNode.call( this, 'TextureCubeUVData' ); // TextureCubeUVData is type as StructNode + + this.uv = uv || new ReflectNode( ReflectNode.VECTOR ); + this.textureSize = textureSize || new FloatNode( 1024 ); + this.blinnExponentToRoughness = blinnExponentToRoughness || new BlinnExponentToRoughnessNode(); + +} + +TextureCubeUVNode.Nodes = ( function () { + + var TextureCubeUVData = new StructNode( [ + "struct TextureCubeUVData {", + " vec2 uv_10;", + " vec2 uv_20;", + " float t;", + "}" + ].join( "\n" ) ); + + var getFaceFromDirection = new FunctionNode( [ + "int getFaceFromDirection(vec3 direction) {", + " vec3 absDirection = abs(direction);", + " int face = -1;", + " if( absDirection.x > absDirection.z ) {", + " if(absDirection.x > absDirection.y )", + " face = direction.x > 0.0 ? 0 : 3;", + " else", + " face = direction.y > 0.0 ? 1 : 4;", + " }", + " else {", + " if(absDirection.z > absDirection.y )", + " face = direction.z > 0.0 ? 2 : 5;", + " else", + " face = direction.y > 0.0 ? 1 : 4;", + " }", + " return face;", + "}" + ].join( "\n" ) ); + + var cubeUV_maxLods1 = new ConstNode( "#define cubeUV_maxLods1 ( log2( cubeUV_textureSize * 0.25 ) - 1.0 )" ); + var cubeUV_rangeClamp = new ConstNode( "#define cubeUV_rangeClamp ( exp2( ( 6.0 - 1.0 ) * 2.0 ) )" ); + + var MipLevelInfo = new FunctionNode( [ + "vec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness, in float cubeUV_textureSize ) {", + " float scale = exp2(cubeUV_maxLods1 - roughnessLevel);", + " float dxRoughness = dFdx(roughness);", + " float dyRoughness = dFdy(roughness);", + " vec3 dx = dFdx( vec * scale * dxRoughness );", + " vec3 dy = dFdy( vec * scale * dyRoughness );", + " float d = max( dot( dx, dx ), dot( dy, dy ) );", + // Clamp the value to the max mip level counts. hard coded to 6 mips" + " d = clamp(d, 1.0, cubeUV_rangeClamp);", + " float mipLevel = 0.5 * log2(d);", + " return vec2(floor(mipLevel), fract(mipLevel));", + "}" + ].join( "\n" ), [ cubeUV_maxLods1, cubeUV_rangeClamp ], { derivatives: true } ); + + var cubeUV_maxLods2 = new ConstNode( "#define cubeUV_maxLods2 ( log2( cubeUV_textureSize * 0.25 ) - 2.0 )" ); + var cubeUV_rcpTextureSize = new ConstNode( "#define cubeUV_rcpTextureSize ( 1.0 / cubeUV_textureSize )" ); + + var getCubeUV = new FunctionNode( [ + "vec2 getCubeUV( vec3 direction, float roughnessLevel, float mipLevel, in float cubeUV_textureSize ) {", + " mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;", + " float a = 16.0 * cubeUV_rcpTextureSize;", + "", + " vec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );", + " vec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;", + // float powScale = exp2(roughnessLevel + mipLevel);" + " float powScale = exp2_packed.x * exp2_packed.y;", + // float scale = 1.0 / exp2(roughnessLevel + 2.0 + mipLevel);" + " float scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;", + // float mipOffset = 0.75*(1.0 - 1.0/exp2(mipLevel))/exp2(roughnessLevel);" + " float mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;", + "", + " bool bRes = mipLevel == 0.0;", + " scale = bRes && (scale < a) ? a : scale;", + "", + " vec3 r;", + " vec2 offset;", + " int face = getFaceFromDirection(direction);", + "", + " float rcpPowScale = 1.0 / powScale;", + "", + " if( face == 0) {", + " r = vec3(direction.x, -direction.z, direction.y);", + " offset = vec2(0.0+mipOffset,0.75 * rcpPowScale);", + " offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;", + " }", + " else if( face == 1) {", + " r = vec3(direction.y, direction.x, direction.z);", + " offset = vec2(scale+mipOffset, 0.75 * rcpPowScale);", + " offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;", + " }", + " else if( face == 2) {", + " r = vec3(direction.z, direction.x, direction.y);", + " offset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);", + " offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;", + " }", + " else if( face == 3) {", + " r = vec3(direction.x, direction.z, direction.y);", + " offset = vec2(0.0+mipOffset,0.5 * rcpPowScale);", + " offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;", + " }", + " else if( face == 4) {", + " r = vec3(direction.y, direction.x, -direction.z);", + " offset = vec2(scale+mipOffset, 0.5 * rcpPowScale);", + " offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;", + " }", + " else {", + " r = vec3(direction.z, -direction.x, direction.y);", + " offset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);", + " offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;", + " }", + " r = normalize(r);", + " float texelOffset = 0.5 * cubeUV_rcpTextureSize;", + " vec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;", + " vec2 base = offset + vec2( texelOffset );", + " return base + s * ( scale - 2.0 * texelOffset );", + "}" + ].join( "\n" ), [ cubeUV_maxLods2, cubeUV_rcpTextureSize, getFaceFromDirection ] ); + + var cubeUV_maxLods3 = new ConstNode( "#define cubeUV_maxLods3 ( log2( cubeUV_textureSize * 0.25 ) - 3.0 )" ); + + var textureCubeUV = new FunctionNode( [ + "TextureCubeUVData textureCubeUV( vec3 reflectedDirection, float roughness, in float cubeUV_textureSize ) {", + " float roughnessVal = roughness * cubeUV_maxLods3;", + " float r1 = floor(roughnessVal);", + " float r2 = r1 + 1.0;", + " float t = fract(roughnessVal);", + " vec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness, cubeUV_textureSize);", + " float s = mipInfo.y;", + " float level0 = mipInfo.x;", + " float level1 = level0 + 1.0;", + " level1 = level1 > 5.0 ? 5.0 : level1;", + "", + // round to nearest mipmap if we are not interpolating." + " level0 += min( floor( s + 0.5 ), 5.0 );", + "", + // Tri linear interpolation." + " vec2 uv_10 = getCubeUV(reflectedDirection, r1, level0, cubeUV_textureSize);", + " vec2 uv_20 = getCubeUV(reflectedDirection, r2, level0, cubeUV_textureSize);", + "", + " return TextureCubeUVData(uv_10, uv_20, t);", + "}" + ].join( "\n" ), [ TextureCubeUVData, cubeUV_maxLods3, MipLevelInfo, getCubeUV ] ); + + return { + TextureCubeUVData: TextureCubeUVData, + textureCubeUV: textureCubeUV + }; + +} )(); + +TextureCubeUVNode.prototype = Object.create( TempNode.prototype ); +TextureCubeUVNode.prototype.constructor = TextureCubeUVNode; +TextureCubeUVNode.prototype.nodeType = "TextureCubeUV"; + +TextureCubeUVNode.prototype.generate = function ( builder, output ) { + + if ( builder.isShader( 'fragment' ) ) { + + var textureCubeUV = builder.include( TextureCubeUVNode.Nodes.textureCubeUV ); + + return builder.format( textureCubeUV + '( ' + this.uv.build( builder, 'v3' ) + ', ' + + this.blinnExponentToRoughness.build( builder, 'f' ) + ', ' + + this.textureSize.build( builder, 'f' ) + ' )', this.getType( builder ), output ); + + } else { + + console.warn( "THREE.TextureCubeUVNode is not compatible with " + builder.shader + " shader." ); + + return builder.format( 'vec4( 0.0 )', this.getType( builder ), output ); + + } + +}; + +TextureCubeUVNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.uv = this.uv.toJSON( meta ).uuid; + data.textureSize = this.textureSize.toJSON( meta ).uuid; + data.blinnExponentToRoughness = this.blinnExponentToRoughness.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { TextureCubeUVNode }; diff --git a/three/jsutil/nodes/postprocessing/NodePass.js b/three/jsutil/nodes/postprocessing/NodePass.js new file mode 100644 index 000000000..f92a2a817 --- /dev/null +++ b/three/jsutil/nodes/postprocessing/NodePass.js @@ -0,0 +1,91 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { NodeMaterial } from '../materials/NodeMaterial.js'; +import { ScreenNode } from '../inputs/ScreenNode.js'; + +function NodePass() { + + THREE.ShaderPass.call( this ); + + this.name = ""; + this.uuid = THREE.Math.generateUUID(); + + this.userData = {}; + + this.textureID = 'renderTexture'; + + this.input = new ScreenNode(); + + this.material = new NodeMaterial(); + + this.needsUpdate = true; + +} + +NodePass.prototype = Object.create( THREE.ShaderPass.prototype ); +NodePass.prototype.constructor = NodePass; + +NodePass.prototype.render = function () { + + if ( this.needsUpdate ) { + + this.material.dispose(); + + this.material.fragment.value = this.input; + + this.needsUpdate = false; + + } + + this.uniforms = this.material.uniforms; + + THREE.ShaderPass.prototype.render.apply( this, arguments ); + +}; + +NodePass.prototype.copy = function ( source ) { + + this.input = source.input; + +}; + +NodePass.prototype.toJSON = function ( meta ) { + + var isRootObject = ( meta === undefined || typeof meta === 'string' ); + + if ( isRootObject ) { + + meta = { + nodes: {} + }; + + } + + if ( meta && ! meta.passes ) meta.passes = {}; + + if ( ! meta.passes[ this.uuid ] ) { + + var data = {}; + + data.uuid = this.uuid; + data.type = "NodePass"; + + meta.passes[ this.uuid ] = data; + + if ( this.name !== "" ) data.name = this.name; + + if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; + + data.input = this.input.toJSON( meta ).uuid; + + } + + meta.pass = this.uuid; + + return meta; + +}; + +export { NodePass }; diff --git a/three/jsutil/nodes/postprocessing/NodePostProcessing.js b/three/jsutil/nodes/postprocessing/NodePostProcessing.js new file mode 100644 index 000000000..cc24ba1d0 --- /dev/null +++ b/three/jsutil/nodes/postprocessing/NodePostProcessing.js @@ -0,0 +1,128 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { NodeMaterial } from '../materials/NodeMaterial.js'; +import { ScreenNode } from '../inputs/ScreenNode.js'; + +function NodePostProcessing( renderer, renderTarget ) { + + if ( renderTarget === undefined ) { + + var parameters = { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBAFormat, + stencilBuffer: false + }; + + var size = renderer.getDrawingBufferSize(); + renderTarget = new THREE.WebGLRenderTarget( size.width, size.height, parameters ); + + } + + this.renderer = renderer; + this.renderTarget = renderTarget; + + this.output = new ScreenNode(); + this.material = new NodeMaterial(); + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.material ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + + this.needsUpdate = true; + +} + +NodePostProcessing.prototype = { + + constructor: NodePostProcessing, + + render: function ( scene, camera, frame ) { + + if ( this.needsUpdate ) { + + this.material.dispose(); + + this.material.fragment.value = this.output; + this.material.build(); + + if ( this.material.uniforms.renderTexture ) { + + this.material.uniforms.renderTexture.value = this.renderTarget.texture; + + } + + this.needsUpdate = false; + + } + + frame.setRenderer( this.renderer ) + .setRenderTexture( this.renderTarget.texture ); + + this.renderer.render( scene, camera, this.renderTarget ); + + frame.updateNode( this.material ); + + this.renderer.render( this.scene, this.camera ); + + }, + + setSize: function ( width, height ) { + + this.renderTarget.setSize( width, height ); + + this.renderer.setSize( width, height ); + + }, + + copy: function ( source ) { + + this.output = source.output; + + }, + + toJSON: function ( meta ) { + + var isRootObject = ( meta === undefined || typeof meta === 'string' ); + + if ( isRootObject ) { + + meta = { + nodes: {} + }; + + } + + if ( meta && ! meta.post ) meta.post = {}; + + if ( ! meta.post[ this.uuid ] ) { + + var data = {}; + + data.uuid = this.uuid; + data.type = "NodePostProcessing"; + + meta.post[ this.uuid ] = data; + + if ( this.name !== "" ) data.name = this.name; + + if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; + + data.output = this.output.toJSON( meta ).uuid; + + } + + meta.post = this.uuid; + + return meta; + + } + +}; + +export { NodePostProcessing }; diff --git a/three/jsutil/nodes/procedural/CheckerNode.js b/three/jsutil/nodes/procedural/CheckerNode.js new file mode 100644 index 000000000..42d1b84ff --- /dev/null +++ b/three/jsutil/nodes/procedural/CheckerNode.js @@ -0,0 +1,75 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { UVNode } from '../accessors/UVNode.js'; + +function CheckerNode( uv ) { + + TempNode.call( this, 'f' ); + + this.uv = uv || new UVNode(); + +} + +CheckerNode.prototype = Object.create( TempNode.prototype ); +CheckerNode.prototype.constructor = CheckerNode; +CheckerNode.prototype.nodeType = "Noise"; + +CheckerNode.Nodes = ( function () { + + // https://github.com/mattdesl/glsl-checker/blob/master/index.glsl + + var checker = new FunctionNode( [ + "float checker( vec2 uv ) {", + + " float cx = floor( uv.x );", + " float cy = floor( uv.y ); ", + " float result = mod( cx + cy, 2.0 );", + + " return sign( result );", + + "}" + ].join( "\n" ) ); + + return { + checker: checker + }; + +} )(); + +CheckerNode.prototype.generate = function ( builder, output ) { + + var snoise = builder.include( CheckerNode.Nodes.checker ); + + return builder.format( snoise + '( ' + this.uv.build( builder, 'v2' ) + ' )', this.getType( builder ), output ); + +}; + +CheckerNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.uv = source.uv; + +}; + +CheckerNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.uv = this.uv.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { CheckerNode }; diff --git a/three/jsutil/nodes/procedural/NoiseNode.js b/three/jsutil/nodes/procedural/NoiseNode.js new file mode 100644 index 000000000..e743febdb --- /dev/null +++ b/three/jsutil/nodes/procedural/NoiseNode.js @@ -0,0 +1,69 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; +import { UVNode } from '../accessors/UVNode.js'; + +function NoiseNode( uv ) { + + TempNode.call( this, 'f' ); + + this.uv = uv || new UVNode(); + +} + +NoiseNode.prototype = Object.create( TempNode.prototype ); +NoiseNode.prototype.constructor = NoiseNode; +NoiseNode.prototype.nodeType = "Noise"; + +NoiseNode.Nodes = ( function () { + + var snoise = new FunctionNode( [ + "float snoise(vec2 co) {", + + " return fract( sin( dot( co.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 );", + + "}" + ].join( "\n" ) ); + + return { + snoise: snoise + }; + +} )(); + +NoiseNode.prototype.generate = function ( builder, output ) { + + var snoise = builder.include( NoiseNode.Nodes.snoise ); + + return builder.format( snoise + '( ' + this.uv.build( builder, 'v2' ) + ' )', this.getType( builder ), output ); + +}; + +NoiseNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.uv = source.uv; + +}; + +NoiseNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.uv = this.uv.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { NoiseNode }; diff --git a/three/jsutil/nodes/utils/BypassNode.js b/three/jsutil/nodes/utils/BypassNode.js new file mode 100644 index 000000000..bc671933c --- /dev/null +++ b/three/jsutil/nodes/utils/BypassNode.js @@ -0,0 +1,85 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from '../core/Node.js'; + +function BypassNode( code, value ) { + + Node.call( this ); + + this.code = code; + this.value = value; + +} + +BypassNode.prototype = Object.create( Node.prototype ); +BypassNode.prototype.constructor = BypassNode; +BypassNode.prototype.nodeType = "Bypass"; + +BypassNode.prototype.getType = function ( builder ) { + + if ( this.value ) { + + return this.value.getType( builder ); + + } else if ( builder.isShader( 'fragment' ) ) { + + return 'f'; + + } + + return 'void'; + +}; + +BypassNode.prototype.generate = function ( builder, output ) { + + var code = this.code.build( builder, output ) + ';'; + + builder.addNodeCode( code ); + + if ( builder.isShader( 'vertex' ) ) { + + if ( this.value ) { + + return this.value.build( builder, output ); + + } + + } else { + + return this.value ? this.value.build( builder, output ) : builder.format( '0.0', 'f', output ); + + } + +}; + +BypassNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + this.code = source.code; + this.value = source.value; + +}; + +BypassNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.code = this.code.toJSON( meta ).uuid; + + if ( this.value ) data.value = this.value.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { BypassNode }; diff --git a/three/jsutil/nodes/utils/ColorSpaceNode.js b/three/jsutil/nodes/utils/ColorSpaceNode.js new file mode 100644 index 000000000..445727351 --- /dev/null +++ b/three/jsutil/nodes/utils/ColorSpaceNode.js @@ -0,0 +1,297 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { ConstNode } from '../core/ConstNode.js'; +import { FunctionNode } from '../core/FunctionNode.js'; + +function ColorSpaceNode( input, method ) { + + TempNode.call( this, 'v4' ); + + this.input = input; + + this.method = method || ColorSpaceNode.LINEAR; + +} + +ColorSpaceNode.Nodes = ( function () { + + // For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/ + + var LinearToLinear = new FunctionNode( [ + "vec4 LinearToLinear( in vec4 value ) {", + + " return value;", + + "}" + ].join( "\n" ) ); + + var GammaToLinear = new FunctionNode( [ + "vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {", + + " return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );", + + "}" + ].join( "\n" ) ); + + var LinearToGamma = new FunctionNode( [ + "vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {", + + " return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );", + + "}" + ].join( "\n" ) ); + + var sRGBToLinear = new FunctionNode( [ + "vec4 sRGBToLinear( in vec4 value ) {", + + " return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );", + + "}" + ].join( "\n" ) ); + + var LinearTosRGB = new FunctionNode( [ + "vec4 LinearTosRGB( in vec4 value ) {", + + " return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );", + + "}" + ].join( "\n" ) ); + + var RGBEToLinear = new FunctionNode( [ + "vec4 RGBEToLinear( in vec4 value ) {", + + " return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );", + + "}" + ].join( "\n" ) ); + + var LinearToRGBE = new FunctionNode( [ + "vec4 LinearToRGBE( in vec4 value ) {", + + " float maxComponent = max( max( value.r, value.g ), value.b );", + " float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );", + " return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );", + // return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 ); + + "}" + ].join( "\n" ) ); + + // reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html + + var RGBMToLinear = new FunctionNode( [ + "vec3 RGBMToLinear( in vec4 value, in float maxRange ) {", + + " return vec4( value.xyz * value.w * maxRange, 1.0 );", + + "}" + ].join( "\n" ) ); + + var LinearToRGBM = new FunctionNode( [ + "vec3 LinearToRGBM( in vec4 value, in float maxRange ) {", + + " float maxRGB = max( value.x, max( value.g, value.b ) );", + " float M = clamp( maxRGB / maxRange, 0.0, 1.0 );", + " M = ceil( M * 255.0 ) / 255.0;", + " return vec4( value.rgb / ( M * maxRange ), M );", + + "}" + ].join( "\n" ) ); + + // reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html + + var RGBDToLinear = new FunctionNode( [ + "vec3 RGBDToLinear( in vec4 value, in float maxRange ) {", + + " return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );", + + "}" + ].join( "\n" ) ); + + + var LinearToRGBD = new FunctionNode( [ + "vec3 LinearToRGBD( in vec4 value, in float maxRange ) {", + + " float maxRGB = max( value.x, max( value.g, value.b ) );", + " float D = max( maxRange / maxRGB, 1.0 );", + " D = min( floor( D ) / 255.0, 1.0 );", + " return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );", + + "}" + ].join( "\n" ) ); + + // LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html + + // M matrix, for encoding + + var cLogLuvM = new ConstNode( "const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );" ); + + var LinearToLogLuv = new FunctionNode( [ + "vec4 LinearToLogLuv( in vec4 value ) {", + + " vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;", + " Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));", + " vec4 vResult;", + " vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;", + " float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;", + " vResult.w = fract(Le);", + " vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;", + " return vResult;", + + "}" + ].join( "\n" ), [ cLogLuvM ] ); + + // Inverse M matrix, for decoding + + var cLogLuvInverseM = new ConstNode( "const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );" ); + + var LogLuvToLinear = new FunctionNode( [ + "vec4 LogLuvToLinear( in vec4 value ) {", + + " float Le = value.z * 255.0 + value.w;", + " vec3 Xp_Y_XYZp;", + " Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);", + " Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;", + " Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;", + " vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;", + " return vec4( max(vRGB, 0.0), 1.0 );", + + "}" + ].join( "\n" ), [ cLogLuvInverseM ] ); + + return { + LinearToLinear: LinearToLinear, + GammaToLinear: GammaToLinear, + LinearToGamma: LinearToGamma, + sRGBToLinear: sRGBToLinear, + LinearTosRGB: LinearTosRGB, + RGBEToLinear: RGBEToLinear, + LinearToRGBE: LinearToRGBE, + RGBMToLinear: RGBMToLinear, + LinearToRGBM: LinearToRGBM, + RGBDToLinear: RGBDToLinear, + LinearToRGBD: LinearToRGBD, + cLogLuvM: cLogLuvM, + LinearToLogLuv: LinearToLogLuv, + cLogLuvInverseM: cLogLuvInverseM, + LogLuvToLinear: LogLuvToLinear + }; + +} )(); + +ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear'; + +ColorSpaceNode.GAMMA_TO_LINEAR = 'GammaToLinear'; +ColorSpaceNode.LINEAR_TO_GAMMA = 'LinearToGamma'; + +ColorSpaceNode.SRGB_TO_LINEAR = 'sRGBToLinear'; +ColorSpaceNode.LINEAR_TO_SRGB = 'LinearTosRGB'; + +ColorSpaceNode.RGBE_TO_LINEAR = 'RGBEToLinear'; +ColorSpaceNode.LINEAR_TO_RGBE = 'LinearToRGBE'; + +ColorSpaceNode.RGBM_TO_LINEAR = 'RGBMToLinear'; +ColorSpaceNode.LINEAR_TO_RGBM = 'LinearToRGBM'; + +ColorSpaceNode.RGBD_TO_LINEAR = 'RGBDToLinear'; +ColorSpaceNode.LINEAR_TO_RGBD = 'LinearToRGBD'; + +ColorSpaceNode.LINEAR_TO_LOG_LUV = 'LinearToLogLuv'; +ColorSpaceNode.LOG_LUV_TO_LINEAR = 'LogLuvToLinear'; + +ColorSpaceNode.prototype = Object.create( TempNode.prototype ); +ColorSpaceNode.prototype.constructor = ColorSpaceNode; +ColorSpaceNode.prototype.nodeType = "ColorAdjustment"; + +ColorSpaceNode.prototype.generate = function ( builder, output ) { + + var input = builder.context.input || this.input.build( builder, 'v4' ), + encodingMethod = builder.context.encoding !== undefined ? this.getEncodingMethod( builder.context.encoding ) : [ this.method ], + factor = this.factor ? this.factor.build( builder, 'f' ) : encodingMethod[ 1 ]; + + var method = builder.include( ColorSpaceNode.Nodes[ encodingMethod[ 0 ] ] ); + + if ( factor ) { + + return builder.format( method + '( ' + input + ', ' + factor + ' )', this.getType( builder ), output ); + + } else { + + return builder.format( method + '( ' + input + ' )', this.getType( builder ), output ); + + } + +}; + +ColorSpaceNode.prototype.getDecodingMethod = function ( encoding ) { + + var components = this.getEncodingComponents( encoding ); + + components[ 0 ] += 'ToLinear'; + + return components; + +}; + +ColorSpaceNode.prototype.getEncodingMethod = function ( encoding ) { + + var components = this.getEncodingComponents( encoding ); + + components[ 0 ] = 'LinearTo' + components[ 0 ]; + + return components; + +}; + +ColorSpaceNode.prototype.getEncodingComponents = function ( encoding ) { + + switch ( encoding ) { + + case THREE.LinearEncoding: + return [ 'Linear' ]; + case THREE.sRGBEncoding: + return [ 'sRGB' ]; + case THREE.RGBEEncoding: + return [ 'RGBE' ]; + case THREE.RGBM7Encoding: + return [ 'RGBM', '7.0' ]; + case THREE.RGBM16Encoding: + return [ 'RGBM', '16.0' ]; + case THREE.RGBDEncoding: + return [ 'RGBD', '256.0' ]; + case THREE.GammaEncoding: + return [ 'Gamma', 'float( GAMMA_FACTOR )' ]; + + } + +}; + +ColorSpaceNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + this.input = source.input; + this.method = source.method; + +}; + +ColorSpaceNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.input = this.input.toJSON( meta ).uuid; + data.method = this.method; + + } + + return data; + +}; + +export { ColorSpaceNode }; diff --git a/three/jsutil/nodes/utils/JoinNode.js b/three/jsutil/nodes/utils/JoinNode.js new file mode 100644 index 000000000..b3d4ca2b1 --- /dev/null +++ b/three/jsutil/nodes/utils/JoinNode.js @@ -0,0 +1,114 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { TempNode } from '../core/TempNode.js'; +import { NodeUtils } from '../core/NodeUtils.js'; + +var inputs = NodeUtils.elements; + +function JoinNode( x, y, z, w ) { + + TempNode.call( this, 'f' ); + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + +} + +JoinNode.prototype = Object.create( TempNode.prototype ); +JoinNode.prototype.constructor = JoinNode; +JoinNode.prototype.nodeType = "Join"; + +JoinNode.prototype.getNumElements = function () { + + var i = inputs.length; + + while ( i -- ) { + + if ( this[ inputs[ i ] ] !== undefined ) { + + ++ i; + + break; + + } + + } + + return Math.max( i, 2 ); + +}; + +JoinNode.prototype.getType = function ( builder ) { + + return builder.getTypeFromLength( this.getNumElements() ); + +}; + +JoinNode.prototype.generate = function ( builder, output ) { + + var type = this.getType( builder ), + length = this.getNumElements(), + outputs = []; + + for ( var i = 0; i < length; i ++ ) { + + var elm = this[ inputs[ i ] ]; + + outputs.push( elm ? elm.build( builder, 'f' ) : '0.0' ); + + } + + var code = ( length > 1 ? builder.getConstructorFromLength( length ) : '' ) + '( ' + outputs.join( ', ' ) + ' )'; + + return builder.format( code, type, output ); + +}; + +JoinNode.prototype.copy = function ( source ) { + + TempNode.prototype.copy.call( this, source ); + + for ( var prop in source.inputs ) { + + this[ prop ] = source.inputs[ prop ]; + + } + +}; + +JoinNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.inputs = {}; + + var length = this.getNumElements(); + + for ( var i = 0; i < length; i ++ ) { + + var elm = this[ inputs[ i ] ]; + + if ( elm ) { + + data.inputs[ inputs[ i ] ] = elm.toJSON( meta ).uuid; + + } + + } + + + } + + return data; + +}; + +export { JoinNode }; diff --git a/three/jsutil/nodes/utils/MaxMIPLevelNode.js b/three/jsutil/nodes/utils/MaxMIPLevelNode.js new file mode 100644 index 000000000..7d42fbfa9 --- /dev/null +++ b/three/jsutil/nodes/utils/MaxMIPLevelNode.js @@ -0,0 +1,61 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { FloatNode } from '../inputs/FloatNode.js'; + +function MaxMIPLevelNode( texture ) { + + FloatNode.call( this ); + + this.texture = texture; + + this.maxMIPLevel = 0; + +} + +MaxMIPLevelNode.prototype = Object.create( FloatNode.prototype ); +MaxMIPLevelNode.prototype.constructor = MaxMIPLevelNode; +MaxMIPLevelNode.prototype.nodeType = "MaxMIPLevel"; + +Object.defineProperties( MaxMIPLevelNode.prototype, { + + value: { + + get: function () { + + if ( this.maxMIPLevel === 0 ) { + + var image = this.texture.value.image ? this.texture.value.image[ 0 ] : undefined; + + this.maxMIPLevel = image !== undefined ? Math.log( Math.max( image.width, image.height ) ) * Math.LOG2E : 0; + + } + + return this.maxMIPLevel; + + }, + + set: function () { } + + } + +} ); + +MaxMIPLevelNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.texture = this.texture.uuid; + + } + + return data; + +}; + +export { MaxMIPLevelNode }; diff --git a/three/jsutil/nodes/utils/SwitchNode.js b/three/jsutil/nodes/utils/SwitchNode.js new file mode 100644 index 000000000..c4b67e964 --- /dev/null +++ b/three/jsutil/nodes/utils/SwitchNode.js @@ -0,0 +1,102 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Node } from '../core/Node.js'; + +function SwitchNode( node, components ) { + + Node.call( this ); + + this.node = node; + this.components = components || 'x'; + +} + +SwitchNode.prototype = Object.create( Node.prototype ); +SwitchNode.prototype.constructor = SwitchNode; +SwitchNode.prototype.nodeType = "Switch"; + +SwitchNode.prototype.getType = function ( builder ) { + + return builder.getTypeFromLength( this.components.length ); + +}; + +SwitchNode.prototype.generate = function ( builder, output ) { + + var type = this.node.getType( builder ), + node = this.node.build( builder, type ), + inputLength = builder.getTypeLength( type ) - 1; + + if ( inputLength > 0 ) { + + // get max length + + var outputLength = 0, + components = builder.colorToVectorProperties( this.components ); + + var i, len = components.length; + + for ( i = 0; i < len; i ++ ) { + + outputLength = Math.max( outputLength, builder.getIndexByElement( components.charAt( i ) ) ); + + } + + if ( outputLength > inputLength ) outputLength = inputLength; + + // split + + node += '.'; + + for ( i = 0; i < len; i ++ ) { + + var elm = components.charAt( i ); + var idx = builder.getIndexByElement( components.charAt( i ) ); + + if ( idx > outputLength ) idx = outputLength; + + node += builder.getElementByIndex( idx ); + + } + + return builder.format( node, this.getType( builder ), output ); + + } else { + + // join + + return builder.format( node, type, output ); + + } + +}; + +SwitchNode.prototype.copy = function ( source ) { + + Node.prototype.copy.call( this, source ); + + this.node = source.node; + this.components = source.components; + +}; + +SwitchNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.node = this.node.toJSON( meta ).uuid; + data.components = this.components; + + } + + return data; + +}; + +export { SwitchNode }; diff --git a/three/jsutil/nodes/utils/TimerNode.js b/three/jsutil/nodes/utils/TimerNode.js new file mode 100644 index 000000000..4e8f27d7b --- /dev/null +++ b/three/jsutil/nodes/utils/TimerNode.js @@ -0,0 +1,105 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { FloatNode } from '../inputs/FloatNode.js'; +import { NodeLib } from '../core/NodeLib.js'; + +function TimerNode( scale, scope, timeScale ) { + + FloatNode.call( this ); + + this.scale = scale !== undefined ? scale : 1; + this.scope = scope || TimerNode.GLOBAL; + + this.timeScale = timeScale !== undefined ? timeScale : this.scale !== 1; + +} + +TimerNode.GLOBAL = 'global'; +TimerNode.LOCAL = 'local'; +TimerNode.DELTA = 'delta'; + +TimerNode.prototype = Object.create( FloatNode.prototype ); +TimerNode.prototype.constructor = TimerNode; +TimerNode.prototype.nodeType = "Timer"; + +TimerNode.prototype.isReadonly = function () { + + // never use TimerNode as readonly but aways as "uniform" + + return false; + +}; + +TimerNode.prototype.isUnique = function () { + + // share TimerNode "uniform" input if is used on more time with others TimerNode + + return this.timeScale && ( this.scope === TimerNode.GLOBAL || this.scope === TimerNode.DELTA ); + +}; + +TimerNode.prototype.updateFrame = function ( frame ) { + + var scale = this.timeScale ? this.scale : 1; + + switch ( this.scope ) { + + case TimerNode.LOCAL: + + this.value += frame.delta * scale; + + break; + + case TimerNode.DELTA: + + this.value = frame.delta * scale; + + break; + + default: + + this.value = frame.time * scale; + + } + +}; + +TimerNode.prototype.copy = function ( source ) { + + FloatNode.prototype.copy.call( this, source ); + + this.scope = source.scope; + this.scale = source.scale; + + this.timeScale = source.timeScale; + +}; + +TimerNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.scope = this.scope; + data.scale = this.scale; + + data.timeScale = this.timeScale; + + } + + return data; + +}; + +NodeLib.addKeyword( 'time', function () { + + return new TimerNode(); + +} ); + +export { TimerNode }; diff --git a/three/jsutil/nodes/utils/UVTransformNode.js b/three/jsutil/nodes/utils/UVTransformNode.js new file mode 100644 index 000000000..a19149ad0 --- /dev/null +++ b/three/jsutil/nodes/utils/UVTransformNode.js @@ -0,0 +1,66 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { ExpressionNode } from '../core/ExpressionNode.js'; +import { Matrix3Node } from '../inputs/Matrix3Node.js'; +import { UVNode } from '../accessors/UVNode.js'; + +function UVTransformNode( uv, position ) { + + ExpressionNode.call( this, "( uvTransform * vec3( uvNode, 1 ) ).xy", "vec2" ); + + this.uv = uv || new UVNode(); + this.position = position || new Matrix3Node(); + +} + +UVTransformNode.prototype = Object.create( ExpressionNode.prototype ); +UVTransformNode.prototype.constructor = UVTransformNode; +UVTransformNode.prototype.nodeType = "UVTransform"; + +UVTransformNode.prototype.generate = function ( builder, output ) { + + this.keywords[ "uvNode" ] = this.uv; + this.keywords[ "uvTransform" ] = this.position; + + return ExpressionNode.prototype.generate.call( this, builder, output ); + +}; + +UVTransformNode.prototype.setUvTransform = function ( tx, ty, sx, sy, rotation, cx, cy ) { + + cx = cx !== undefined ? cx : .5; + cy = cy !== undefined ? cy : .5; + + this.position.value.setUvTransform( tx, ty, sx, sy, rotation, cx, cy ); + +}; + +UVTransformNode.prototype.copy = function ( source ) { + + ExpressionNode.prototype.copy.call( this, source ); + + this.uv = source.uv; + this.position = source.position; + +}; + +UVTransformNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + data.uv = this.uv.toJSON( meta ).uuid; + data.position = this.position.toJSON( meta ).uuid; + + } + + return data; + +}; + +export { UVTransformNode }; diff --git a/three/jsutil/nodes/utils/VelocityNode.js b/three/jsutil/nodes/utils/VelocityNode.js new file mode 100644 index 000000000..69eb79bd0 --- /dev/null +++ b/three/jsutil/nodes/utils/VelocityNode.js @@ -0,0 +1,174 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +import { Vector3Node } from '../inputs/Vector3Node.js'; + +function VelocityNode( target, params ) { + + Vector3Node.call( this ); + + this.params = {}; + + this.velocity = new THREE.Vector3(); + + this.setTarget( target ); + this.setParams( params ); + +} + +VelocityNode.prototype = Object.create( Vector3Node.prototype ); +VelocityNode.prototype.constructor = VelocityNode; +VelocityNode.prototype.nodeType = "Velocity"; + +VelocityNode.prototype.isReadonly = function ( builder ) { + + return false; + +}; + +VelocityNode.prototype.setParams = function ( params ) { + + switch ( this.params.type ) { + + case "elastic": + + delete this.moment; + + delete this.speed; + delete this.springVelocity; + + delete this.lastVelocity; + + break; + + } + + this.params = params || {}; + + switch ( this.params.type ) { + + case "elastic": + + this.moment = new THREE.Vector3(); + + this.speed = new THREE.Vector3(); + this.springVelocity = new THREE.Vector3(); + + this.lastVelocity = new THREE.Vector3(); + + break; + + } + +}; + +VelocityNode.prototype.setTarget = function ( target ) { + + if ( this.target ) { + + delete this.position; + delete this.oldPosition; + + } + + this.target = target; + + if ( target ) { + + this.position = target.getWorldPosition( this.position || new THREE.Vector3() ); + this.oldPosition = this.position.clone(); + + } + +}; + +VelocityNode.prototype.updateFrameVelocity = function ( frame ) { + + if ( this.target ) { + + this.position = this.target.getWorldPosition( this.position || new THREE.Vector3() ); + this.velocity.subVectors( this.position, this.oldPosition ); + this.oldPosition.copy( this.position ); + + } + +}; + +VelocityNode.prototype.updateFrame = function ( frame ) { + + this.updateFrameVelocity( frame ); + + switch ( this.params.type ) { + + case "elastic": + + // convert to real scale: 0 at 1 values + var deltaFps = frame.delta * ( this.params.fps || 60 ); + + var spring = Math.pow( this.params.spring, deltaFps ), + damping = Math.pow( this.params.damping, deltaFps ); + + // fix relative frame-rate + this.velocity.multiplyScalar( Math.exp( - this.params.damping * deltaFps ) ); + + // elastic + this.velocity.add( this.springVelocity ); + this.velocity.add( this.speed.multiplyScalar( damping ).multiplyScalar( 1 - spring ) ); + + // speed + this.speed.subVectors( this.velocity, this.lastVelocity ); + + // spring velocity + this.springVelocity.add( this.speed ); + this.springVelocity.multiplyScalar( spring ); + + // moment + this.moment.add( this.springVelocity ); + + // damping + this.moment.multiplyScalar( damping ); + + this.lastVelocity.copy( this.velocity ); + this.value.copy( this.moment ); + + break; + + default: + + this.value.copy( this.velocity ); + + } + +}; + +VelocityNode.prototype.copy = function ( source ) { + + Vector3Node.prototype.copy.call( this, source ); + + if ( source.target ) object.setTarget( source.target ); + + object.setParams( source.params ); + +}; + +VelocityNode.prototype.toJSON = function ( meta ) { + + var data = this.getJSONNode( meta ); + + if ( ! data ) { + + data = this.createJSONNode( meta ); + + if ( this.target ) data.target = this.target.uuid; + + // clone params + data.params = JSON.parse( JSON.stringify( this.params ) ); + + } + + return data; + +}; + +export { VelocityNode }; diff --git a/three/jsutil/objects/Lensflare.js b/three/jsutil/objects/Lensflare.js new file mode 100644 index 000000000..c43f4fdfe --- /dev/null +++ b/three/jsutil/objects/Lensflare.js @@ -0,0 +1,376 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.Lensflare = function () { + + THREE.Mesh.call( this, THREE.Lensflare.Geometry, new THREE.MeshBasicMaterial( { opacity: 0, transparent: true } ) ); + + this.type = 'Lensflare'; + this.frustumCulled = false; + this.renderOrder = Infinity; + + // + + var positionScreen = new THREE.Vector3(); + + // textures + + var tempMap = new THREE.DataTexture( new Uint8Array( 16 * 16 * 3 ), 16, 16, THREE.RGBFormat ); + tempMap.minFilter = THREE.NearestFilter; + tempMap.magFilter = THREE.NearestFilter; + tempMap.wrapS = THREE.ClampToEdgeWrapping; + tempMap.wrapT = THREE.ClampToEdgeWrapping; + tempMap.needsUpdate = true; + + var occlusionMap = new THREE.DataTexture( new Uint8Array( 16 * 16 * 3 ), 16, 16, THREE.RGBFormat ); + occlusionMap.minFilter = THREE.NearestFilter; + occlusionMap.magFilter = THREE.NearestFilter; + occlusionMap.wrapS = THREE.ClampToEdgeWrapping; + occlusionMap.wrapT = THREE.ClampToEdgeWrapping; + occlusionMap.needsUpdate = true; + + // material + + var geometry = THREE.Lensflare.Geometry; + + var material1a = new THREE.RawShaderMaterial( { + uniforms: { + 'scale': { value: null }, + 'screenPosition': { value: null } + }, + vertexShader: [ + + 'precision highp float;', + + 'uniform vec3 screenPosition;', + 'uniform vec2 scale;', + + 'attribute vec3 position;', + + 'void main() {', + + ' gl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );', + + '}' + + ].join( '\n' ), + fragmentShader: [ + + 'precision highp float;', + + 'void main() {', + + ' gl_FragColor = vec4( 1.0, 0.0, 1.0, 1.0 );', + + '}' + + ].join( '\n' ), + depthTest: true, + depthWrite: false, + transparent: false + } ); + + var material1b = new THREE.RawShaderMaterial( { + uniforms: { + 'map': { value: tempMap }, + 'scale': { value: null }, + 'screenPosition': { value: null } + }, + vertexShader: [ + + 'precision highp float;', + + 'uniform vec3 screenPosition;', + 'uniform vec2 scale;', + + 'attribute vec3 position;', + 'attribute vec2 uv;', + + 'varying vec2 vUV;', + + 'void main() {', + + ' vUV = uv;', + + ' gl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );', + + '}' + + ].join( '\n' ), + fragmentShader: [ + + 'precision highp float;', + + 'uniform sampler2D map;', + + 'varying vec2 vUV;', + + 'void main() {', + + ' gl_FragColor = texture2D( map, vUV );', + + '}' + + ].join( '\n' ), + depthTest: false, + depthWrite: false, + transparent: false + } ); + + // the following object is used for occlusionMap generation + + var mesh1 = new THREE.Mesh( geometry, material1a ); + + // + + var elements = []; + + var shader = THREE.LensflareElement.Shader; + + var material2 = new THREE.RawShaderMaterial( { + uniforms: { + 'map': { value: null }, + 'occlusionMap': { value: occlusionMap }, + 'color': { value: new THREE.Color( 0xffffff ) }, + 'scale': { value: new THREE.Vector2() }, + 'screenPosition': { value: new THREE.Vector3() } + }, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + blending: THREE.AdditiveBlending, + transparent: true, + depthWrite: false + } ); + + var mesh2 = new THREE.Mesh( geometry, material2 ); + + this.addElement = function ( element ) { + + elements.push( element ); + + }; + + // + + var scale = new THREE.Vector2(); + var screenPositionPixels = new THREE.Vector2(); + var validArea = new THREE.Box2(); + var viewport = new THREE.Vector4(); + + this.onBeforeRender = function ( renderer, scene, camera ) { + + viewport.copy( renderer.getCurrentViewport() ); + + var invAspect = viewport.w / viewport.z; + var halfViewportWidth = viewport.z / 2.0; + var halfViewportHeight = viewport.w / 2.0; + + var size = 16 / viewport.w; + scale.set( size * invAspect, size ); + + validArea.min.set( viewport.x, viewport.y ); + validArea.max.set( viewport.x + ( viewport.z - 16 ), viewport.y + ( viewport.w - 16 ) ); + + // calculate position in screen space + + positionScreen.setFromMatrixPosition( this.matrixWorld ); + + positionScreen.applyMatrix4( camera.matrixWorldInverse ); + positionScreen.applyMatrix4( camera.projectionMatrix ); + + // horizontal and vertical coordinate of the lower left corner of the pixels to copy + + screenPositionPixels.x = viewport.x + ( positionScreen.x * halfViewportWidth ) + halfViewportWidth - 8; + screenPositionPixels.y = viewport.y + ( positionScreen.y * halfViewportHeight ) + halfViewportHeight - 8; + + // screen cull + + if ( validArea.containsPoint( screenPositionPixels ) ) { + + // save current RGB to temp texture + + renderer.copyFramebufferToTexture( screenPositionPixels, tempMap ); + + // render pink quad + + var uniforms = material1a.uniforms; + uniforms.scale.value = scale; + uniforms.screenPosition.value = positionScreen; + + renderer.renderBufferDirect( camera, null, geometry, material1a, mesh1, null ); + + // copy result to occlusionMap + + renderer.copyFramebufferToTexture( screenPositionPixels, occlusionMap ); + + // restore graphics + + var uniforms = material1b.uniforms; + uniforms.scale.value = scale; + uniforms.screenPosition.value = positionScreen; + + renderer.renderBufferDirect( camera, null, geometry, material1b, mesh1, null ); + + // render elements + + var vecX = - positionScreen.x * 2; + var vecY = - positionScreen.y * 2; + + for ( var i = 0, l = elements.length; i < l; i ++ ) { + + var element = elements[ i ]; + + var uniforms = material2.uniforms; + + uniforms.color.value.copy( element.color ); + uniforms.map.value = element.texture; + uniforms.screenPosition.value.x = positionScreen.x + vecX * element.distance; + uniforms.screenPosition.value.y = positionScreen.y + vecY * element.distance; + + var size = element.size / viewport.w; + var invAspect = viewport.w / viewport.z; + + uniforms.scale.value.set( size * invAspect, size ); + + material2.uniformsNeedUpdate = true; + + renderer.renderBufferDirect( camera, null, geometry, material2, mesh2, null ); + + } + + } + + }; + + this.dispose = function () { + + material1a.dispose(); + material1b.dispose(); + material2.dispose(); + + tempMap.dispose(); + occlusionMap.dispose(); + + for ( var i = 0, l = elements.length; i < l; i ++ ) { + + elements[ i ].texture.dispose(); + + } + + }; + +}; + +THREE.Lensflare.prototype = Object.create( THREE.Mesh.prototype ); +THREE.Lensflare.prototype.constructor = THREE.Lensflare; +THREE.Lensflare.prototype.isLensflare = true; + +// + +THREE.LensflareElement = function ( texture, size, distance, color ) { + + this.texture = texture; + this.size = size || 1; + this.distance = distance || 0; + this.color = color || new THREE.Color( 0xffffff ); + +}; + +THREE.LensflareElement.Shader = { + + uniforms: { + + 'map': { value: null }, + 'occlusionMap': { value: null }, + 'color': { value: null }, + 'scale': { value: null }, + 'screenPosition': { value: null } + + }, + + vertexShader: [ + + 'precision highp float;', + + 'uniform vec3 screenPosition;', + 'uniform vec2 scale;', + + 'uniform sampler2D occlusionMap;', + + 'attribute vec3 position;', + 'attribute vec2 uv;', + + 'varying vec2 vUV;', + 'varying float vVisibility;', + + 'void main() {', + + ' vUV = uv;', + + ' vec2 pos = position.xy;', + + ' vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );', + ' visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );', + + ' vVisibility = visibility.r / 9.0;', + ' vVisibility *= 1.0 - visibility.g / 9.0;', + ' vVisibility *= visibility.b / 9.0;', + + ' gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );', + + '}' + + ].join( '\n' ), + + fragmentShader: [ + + 'precision highp float;', + + 'uniform sampler2D map;', + 'uniform vec3 color;', + + 'varying vec2 vUV;', + 'varying float vVisibility;', + + 'void main() {', + + ' vec4 texture = texture2D( map, vUV );', + ' texture.a *= vVisibility;', + ' gl_FragColor = texture;', + ' gl_FragColor.rgb *= color;', + + '}' + + ].join( '\n' ) + +}; + +THREE.Lensflare.Geometry = ( function () { + + var geometry = new THREE.BufferGeometry(); + + var float32Array = new Float32Array( [ + - 1, - 1, 0, 0, 0, + 1, - 1, 0, 1, 0, + 1, 1, 0, 1, 1, + - 1, 1, 0, 0, 1 + ] ); + + var interleavedBuffer = new THREE.InterleavedBuffer( float32Array, 5 ); + + geometry.setIndex( [ 0, 1, 2, 0, 2, 3 ] ); + geometry.addAttribute( 'position', new THREE.InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) ); + geometry.addAttribute( 'uv', new THREE.InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) ); + + return geometry; + +} )(); diff --git a/three/jsutil/objects/Reflector.js b/three/jsutil/objects/Reflector.js new file mode 100644 index 000000000..c6e0df052 --- /dev/null +++ b/three/jsutil/objects/Reflector.js @@ -0,0 +1,262 @@ +/** + * @author Slayvin / http://slayvin.net + */ + +THREE.Reflector = function ( geometry, options ) { + + THREE.Mesh.call( this, geometry ); + + this.type = 'Reflector'; + + var scope = this; + + options = options || {}; + + var color = ( options.color !== undefined ) ? new THREE.Color( options.color ) : new THREE.Color( 0x7F7F7F ); + var textureWidth = options.textureWidth || 512; + var textureHeight = options.textureHeight || 512; + var clipBias = options.clipBias || 0; + var shader = options.shader || THREE.Reflector.ReflectorShader; + var recursion = options.recursion !== undefined ? options.recursion : 0; + + // + + var reflectorPlane = new THREE.Plane(); + var normal = new THREE.Vector3(); + var reflectorWorldPosition = new THREE.Vector3(); + var cameraWorldPosition = new THREE.Vector3(); + var rotationMatrix = new THREE.Matrix4(); + var lookAtPosition = new THREE.Vector3( 0, 0, - 1 ); + var clipPlane = new THREE.Vector4(); + var viewport = new THREE.Vector4(); + + var view = new THREE.Vector3(); + var target = new THREE.Vector3(); + var q = new THREE.Vector4(); + + var textureMatrix = new THREE.Matrix4(); + var virtualCamera = new THREE.PerspectiveCamera(); + + var parameters = { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBFormat, + stencilBuffer: false + }; + + var renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters ); + + if ( ! THREE.Math.isPowerOfTwo( textureWidth ) || ! THREE.Math.isPowerOfTwo( textureHeight ) ) { + + renderTarget.texture.generateMipmaps = false; + + } + + var material = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader + } ); + + material.uniforms.tDiffuse.value = renderTarget.texture; + material.uniforms.color.value = color; + material.uniforms.textureMatrix.value = textureMatrix; + + this.material = material; + this.renderOrder = - Infinity; // render first + + this.onBeforeRender = function ( renderer, scene, camera ) { + + if ( 'recursion' in camera.userData ) { + + if ( camera.userData.recursion === recursion ) return; + + camera.userData.recursion ++; + + } + + reflectorWorldPosition.setFromMatrixPosition( scope.matrixWorld ); + cameraWorldPosition.setFromMatrixPosition( camera.matrixWorld ); + + rotationMatrix.extractRotation( scope.matrixWorld ); + + normal.set( 0, 0, 1 ); + normal.applyMatrix4( rotationMatrix ); + + view.subVectors( reflectorWorldPosition, cameraWorldPosition ); + + // Avoid rendering when reflector is facing away + + if ( view.dot( normal ) > 0 ) return; + + view.reflect( normal ).negate(); + view.add( reflectorWorldPosition ); + + rotationMatrix.extractRotation( camera.matrixWorld ); + + lookAtPosition.set( 0, 0, - 1 ); + lookAtPosition.applyMatrix4( rotationMatrix ); + lookAtPosition.add( cameraWorldPosition ); + + target.subVectors( reflectorWorldPosition, lookAtPosition ); + target.reflect( normal ).negate(); + target.add( reflectorWorldPosition ); + + virtualCamera.position.copy( view ); + virtualCamera.up.set( 0, 1, 0 ); + virtualCamera.up.applyMatrix4( rotationMatrix ); + virtualCamera.up.reflect( normal ); + virtualCamera.lookAt( target ); + + virtualCamera.far = camera.far; // Used in WebGLBackground + + virtualCamera.updateMatrixWorld(); + virtualCamera.projectionMatrix.copy( camera.projectionMatrix ); + + virtualCamera.userData.recursion = 0; + + // Update the texture matrix + textureMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); + textureMatrix.multiply( virtualCamera.projectionMatrix ); + textureMatrix.multiply( virtualCamera.matrixWorldInverse ); + textureMatrix.multiply( scope.matrixWorld ); + + // Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html + // Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf + reflectorPlane.setFromNormalAndCoplanarPoint( normal, reflectorWorldPosition ); + reflectorPlane.applyMatrix4( virtualCamera.matrixWorldInverse ); + + clipPlane.set( reflectorPlane.normal.x, reflectorPlane.normal.y, reflectorPlane.normal.z, reflectorPlane.constant ); + + var projectionMatrix = virtualCamera.projectionMatrix; + + q.x = ( Math.sign( clipPlane.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ]; + q.y = ( Math.sign( clipPlane.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ]; + q.z = - 1.0; + q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ]; + + // Calculate the scaled plane vector + clipPlane.multiplyScalar( 2.0 / clipPlane.dot( q ) ); + + // Replacing the third row of the projection matrix + projectionMatrix.elements[ 2 ] = clipPlane.x; + projectionMatrix.elements[ 6 ] = clipPlane.y; + projectionMatrix.elements[ 10 ] = clipPlane.z + 1.0 - clipBias; + projectionMatrix.elements[ 14 ] = clipPlane.w; + + // Render + + scope.visible = false; + + var currentRenderTarget = renderer.getRenderTarget(); + + var currentVrEnabled = renderer.vr.enabled; + var currentShadowAutoUpdate = renderer.shadowMap.autoUpdate; + + renderer.vr.enabled = false; // Avoid camera modification and recursion + renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows + + renderer.render( scene, virtualCamera, renderTarget, true ); + + renderer.vr.enabled = currentVrEnabled; + renderer.shadowMap.autoUpdate = currentShadowAutoUpdate; + + renderer.setRenderTarget( currentRenderTarget ); + + // Restore viewport + + var bounds = camera.bounds; + + if ( bounds !== undefined ) { + + var size = renderer.getSize(); + var pixelRatio = renderer.getPixelRatio(); + + viewport.x = bounds.x * size.width * pixelRatio; + viewport.y = bounds.y * size.height * pixelRatio; + viewport.z = bounds.z * size.width * pixelRatio; + viewport.w = bounds.w * size.height * pixelRatio; + + renderer.state.viewport( viewport ); + + } + + scope.visible = true; + + }; + + this.getRenderTarget = function () { + + return renderTarget; + + }; + +}; + +THREE.Reflector.prototype = Object.create( THREE.Mesh.prototype ); +THREE.Reflector.prototype.constructor = THREE.Reflector; + +THREE.Reflector.ReflectorShader = { + + uniforms: { + + 'color': { + type: 'c', + value: null + }, + + 'tDiffuse': { + type: 't', + value: null + }, + + 'textureMatrix': { + type: 'm4', + value: null + } + + }, + + vertexShader: [ + 'uniform mat4 textureMatrix;', + 'varying vec4 vUv;', + + 'void main() {', + + ' vUv = textureMatrix * vec4( position, 1.0 );', + + ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', + + '}' + ].join( '\n' ), + + fragmentShader: [ + 'uniform vec3 color;', + 'uniform sampler2D tDiffuse;', + 'varying vec4 vUv;', + + 'float blendOverlay( float base, float blend ) {', + + ' return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );', + + '}', + + 'vec3 blendOverlay( vec3 base, vec3 blend ) {', + + ' return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );', + + '}', + + 'void main() {', + + ' vec4 base = texture2DProj( tDiffuse, vUv );', + ' gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );', + + '}' + ].join( '\n' ) +}; diff --git a/three/jsutil/objects/ReflectorRTT.js b/three/jsutil/objects/ReflectorRTT.js new file mode 100644 index 000000000..28bdfc8da --- /dev/null +++ b/three/jsutil/objects/ReflectorRTT.js @@ -0,0 +1,9 @@ +THREE.ReflectorRTT = function ( geometry, options ) { + + THREE.Reflector.call( this, geometry, options ); + + this.geometry.setDrawRange( 0, 0 ); // avoid rendering geometry + +}; + +THREE.ReflectorRTT.prototype = Object.create( THREE.Reflector.prototype ); diff --git a/three/jsutil/objects/Refractor.js b/three/jsutil/objects/Refractor.js new file mode 100644 index 000000000..66684ee8a --- /dev/null +++ b/three/jsutil/objects/Refractor.js @@ -0,0 +1,332 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + * + */ + +THREE.Refractor = function ( geometry, options ) { + + THREE.Mesh.call( this, geometry ); + + this.type = 'Refractor'; + + var scope = this; + + options = options || {}; + + var color = ( options.color !== undefined ) ? new THREE.Color( options.color ) : new THREE.Color( 0x7F7F7F ); + var textureWidth = options.textureWidth || 512; + var textureHeight = options.textureHeight || 512; + var clipBias = options.clipBias || 0; + var shader = options.shader || THREE.Refractor.RefractorShader; + + // + + var virtualCamera = new THREE.PerspectiveCamera(); + virtualCamera.matrixAutoUpdate = false; + virtualCamera.userData.refractor = true; + + // + + var refractorPlane = new THREE.Plane(); + var textureMatrix = new THREE.Matrix4(); + + // render target + + var parameters = { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBFormat, + stencilBuffer: false + }; + + var renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters ); + + if ( ! THREE.Math.isPowerOfTwo( textureWidth ) || ! THREE.Math.isPowerOfTwo( textureHeight ) ) { + + renderTarget.texture.generateMipmaps = false; + + } + + // material + + this.material = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + transparent: true // ensures, refractors are drawn from farthest to closest + } ); + + this.material.uniforms.color.value = color; + this.material.uniforms.tDiffuse.value = renderTarget.texture; + this.material.uniforms.textureMatrix.value = textureMatrix; + + // functions + + var visible = ( function () { + + var refractorWorldPosition = new THREE.Vector3(); + var cameraWorldPosition = new THREE.Vector3(); + var rotationMatrix = new THREE.Matrix4(); + + var view = new THREE.Vector3(); + var normal = new THREE.Vector3(); + + return function visible( camera ) { + + refractorWorldPosition.setFromMatrixPosition( scope.matrixWorld ); + cameraWorldPosition.setFromMatrixPosition( camera.matrixWorld ); + + view.subVectors( refractorWorldPosition, cameraWorldPosition ); + + rotationMatrix.extractRotation( scope.matrixWorld ); + + normal.set( 0, 0, 1 ); + normal.applyMatrix4( rotationMatrix ); + + return view.dot( normal ) < 0; + + }; + + } )(); + + var updateRefractorPlane = ( function () { + + var normal = new THREE.Vector3(); + var position = new THREE.Vector3(); + var quaternion = new THREE.Quaternion(); + var scale = new THREE.Vector3(); + + return function updateRefractorPlane() { + + scope.matrixWorld.decompose( position, quaternion, scale ); + normal.set( 0, 0, 1 ).applyQuaternion( quaternion ).normalize(); + + // flip the normal because we want to cull everything above the plane + + normal.negate(); + + refractorPlane.setFromNormalAndCoplanarPoint( normal, position ); + + }; + + } )(); + + var updateVirtualCamera = ( function () { + + var clipPlane = new THREE.Plane(); + var clipVector = new THREE.Vector4(); + var q = new THREE.Vector4(); + + return function updateVirtualCamera( camera ) { + + virtualCamera.matrixWorld.copy( camera.matrixWorld ); + virtualCamera.matrixWorldInverse.getInverse( virtualCamera.matrixWorld ); + virtualCamera.projectionMatrix.copy( camera.projectionMatrix ); + virtualCamera.far = camera.far; // used in WebGLBackground + + // The following code creates an oblique view frustum for clipping. + // see: Lengyel, Eric. “Oblique View Frustum Depth Projection and Clipping”. + // Journal of Game Development, Vol. 1, No. 2 (2005), Charles River Media, pp. 5–16 + + clipPlane.copy( refractorPlane ); + clipPlane.applyMatrix4( virtualCamera.matrixWorldInverse ); + + clipVector.set( clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.constant ); + + // calculate the clip-space corner point opposite the clipping plane and + // transform it into camera space by multiplying it by the inverse of the projection matrix + + var projectionMatrix = virtualCamera.projectionMatrix; + + q.x = ( Math.sign( clipVector.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ]; + q.y = ( Math.sign( clipVector.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ]; + q.z = - 1.0; + q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ]; + + // calculate the scaled plane vector + + clipVector.multiplyScalar( 2.0 / clipVector.dot( q ) ); + + // replacing the third row of the projection matrix + + projectionMatrix.elements[ 2 ] = clipVector.x; + projectionMatrix.elements[ 6 ] = clipVector.y; + projectionMatrix.elements[ 10 ] = clipVector.z + 1.0 - clipBias; + projectionMatrix.elements[ 14 ] = clipVector.w; + + }; + + } )(); + + // This will update the texture matrix that is used for projective texture mapping in the shader. + // see: http://developer.download.nvidia.com/assets/gamedev/docs/projective_texture_mapping.pdf + + function updateTextureMatrix( camera ) { + + // this matrix does range mapping to [ 0, 1 ] + + textureMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); + + // we use "Object Linear Texgen", so we need to multiply the texture matrix T + // (matrix above) with the projection and view matrix of the virtual camera + // and the model matrix of the refractor + + textureMatrix.multiply( camera.projectionMatrix ); + textureMatrix.multiply( camera.matrixWorldInverse ); + textureMatrix.multiply( scope.matrixWorld ); + + } + + // + + var render = ( function () { + + var viewport = new THREE.Vector4(); + + return function render( renderer, scene, camera ) { + + scope.visible = false; + + var currentRenderTarget = renderer.getRenderTarget(); + var currentVrEnabled = renderer.vr.enabled; + var currentShadowAutoUpdate = renderer.shadowMap.autoUpdate; + + renderer.vr.enabled = false; // avoid camera modification + renderer.shadowMap.autoUpdate = false; // avoid re-computing shadows + + renderer.render( scene, virtualCamera, renderTarget, true ); + + renderer.vr.enabled = currentVrEnabled; + renderer.shadowMap.autoUpdate = currentShadowAutoUpdate; + renderer.setRenderTarget( currentRenderTarget ); + + // restore viewport + + var bounds = camera.bounds; + + if ( bounds !== undefined ) { + + var size = renderer.getSize(); + var pixelRatio = renderer.getPixelRatio(); + + viewport.x = bounds.x * size.width * pixelRatio; + viewport.y = bounds.y * size.height * pixelRatio; + viewport.z = bounds.z * size.width * pixelRatio; + viewport.w = bounds.w * size.height * pixelRatio; + + renderer.state.viewport( viewport ); + + } + + scope.visible = true; + + }; + + } )(); + + // + + this.onBeforeRender = function ( renderer, scene, camera ) { + + // ensure refractors are rendered only once per frame + + if ( camera.userData.refractor === true ) return; + + // avoid rendering when the refractor is viewed from behind + + if ( ! visible( camera ) === true ) return; + + // update + + updateRefractorPlane(); + + updateTextureMatrix( camera ); + + updateVirtualCamera( camera ); + + render( renderer, scene, camera ); + + }; + + this.getRenderTarget = function () { + + return renderTarget; + + }; + +}; + +THREE.Refractor.prototype = Object.create( THREE.Mesh.prototype ); +THREE.Refractor.prototype.constructor = THREE.Refractor; + +THREE.Refractor.RefractorShader = { + + uniforms: { + + 'color': { + type: 'c', + value: null + }, + + 'tDiffuse': { + type: 't', + value: null + }, + + 'textureMatrix': { + type: 'm4', + value: null + } + + }, + + vertexShader: [ + + 'uniform mat4 textureMatrix;', + + 'varying vec4 vUv;', + + 'void main() {', + + ' vUv = textureMatrix * vec4( position, 1.0 );', + + ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', + + '}' + + ].join( '\n' ), + + fragmentShader: [ + + 'uniform vec3 color;', + 'uniform sampler2D tDiffuse;', + + 'varying vec4 vUv;', + + 'float blendOverlay( float base, float blend ) {', + + ' return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );', + + '}', + + 'vec3 blendOverlay( vec3 base, vec3 blend ) {', + + ' return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );', + + '}', + + 'void main() {', + + ' vec4 base = texture2DProj( tDiffuse, vUv );', + + ' gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );', + + '}' + + ].join( '\n' ) +}; diff --git a/three/jsutil/objects/ShadowMesh.js b/three/jsutil/objects/ShadowMesh.js new file mode 100644 index 000000000..fa3122e0c --- /dev/null +++ b/three/jsutil/objects/ShadowMesh.js @@ -0,0 +1,69 @@ +/** + * @author erichlof / http://github.com/erichlof + * + * A shadow Mesh that follows a shadow-casting Mesh in the scene, but is confined to a single plane. + */ + +THREE.ShadowMesh = function ( mesh ) { + + var shadowMaterial = new THREE.MeshBasicMaterial( { + + color: 0x000000, + transparent: true, + opacity: 0.6, + depthWrite: false + + } ); + + THREE.Mesh.call( this, mesh.geometry, shadowMaterial ); + + this.meshMatrix = mesh.matrixWorld; + + this.frustumCulled = false; + this.matrixAutoUpdate = false; + +}; + +THREE.ShadowMesh.prototype = Object.create( THREE.Mesh.prototype ); +THREE.ShadowMesh.prototype.constructor = THREE.ShadowMesh; + +THREE.ShadowMesh.prototype.update = function () { + + var shadowMatrix = new THREE.Matrix4(); + + return function ( plane, lightPosition4D ) { + + // based on https://www.opengl.org/archives/resources/features/StencilTalk/tsld021.htm + + var dot = plane.normal.x * lightPosition4D.x + + plane.normal.y * lightPosition4D.y + + plane.normal.z * lightPosition4D.z + + - plane.constant * lightPosition4D.w; + + var sme = shadowMatrix.elements; + + sme[ 0 ] = dot - lightPosition4D.x * plane.normal.x; + sme[ 4 ] = - lightPosition4D.x * plane.normal.y; + sme[ 8 ] = - lightPosition4D.x * plane.normal.z; + sme[ 12 ] = - lightPosition4D.x * - plane.constant; + + sme[ 1 ] = - lightPosition4D.y * plane.normal.x; + sme[ 5 ] = dot - lightPosition4D.y * plane.normal.y; + sme[ 9 ] = - lightPosition4D.y * plane.normal.z; + sme[ 13 ] = - lightPosition4D.y * - plane.constant; + + sme[ 2 ] = - lightPosition4D.z * plane.normal.x; + sme[ 6 ] = - lightPosition4D.z * plane.normal.y; + sme[ 10 ] = dot - lightPosition4D.z * plane.normal.z; + sme[ 14 ] = - lightPosition4D.z * - plane.constant; + + sme[ 3 ] = - lightPosition4D.w * plane.normal.x; + sme[ 7 ] = - lightPosition4D.w * plane.normal.y; + sme[ 11 ] = - lightPosition4D.w * plane.normal.z; + sme[ 15 ] = dot - lightPosition4D.w * - plane.constant; + + this.matrix.multiplyMatrices( shadowMatrix, this.meshMatrix ); + + }; + +}(); diff --git a/three/jsutil/objects/Sky.js b/three/jsutil/objects/Sky.js new file mode 100644 index 000000000..2adb3ade2 --- /dev/null +++ b/three/jsutil/objects/Sky.js @@ -0,0 +1,222 @@ +/** + * @author zz85 / https://github.com/zz85 + * + * Based on "A Practical Analytic Model for Daylight" + * aka The Preetham Model, the de facto standard analytic skydome model + * http://www.cs.utah.edu/~shirley/papers/sunsky/sunsky.pdf + * + * First implemented by Simon Wallner + * http://www.simonwallner.at/projects/atmospheric-scattering + * + * Improved by Martin Upitis + * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR + * + * Three.js integration by zz85 http://twitter.com/blurspline +*/ + +THREE.Sky = function () { + + var shader = THREE.Sky.SkyShader; + + var material = new THREE.ShaderMaterial( { + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + side: THREE.BackSide + } ); + + THREE.Mesh.call( this, new THREE.BoxBufferGeometry( 1, 1, 1 ), material ); + +}; + +THREE.Sky.prototype = Object.create( THREE.Mesh.prototype ); + +THREE.Sky.SkyShader = { + + uniforms: { + luminance: { value: 1 }, + turbidity: { value: 2 }, + rayleigh: { value: 1 }, + mieCoefficient: { value: 0.005 }, + mieDirectionalG: { value: 0.8 }, + sunPosition: { value: new THREE.Vector3() } + }, + + vertexShader: [ + 'uniform vec3 sunPosition;', + 'uniform float rayleigh;', + 'uniform float turbidity;', + 'uniform float mieCoefficient;', + + 'varying vec3 vWorldPosition;', + 'varying vec3 vSunDirection;', + 'varying float vSunfade;', + 'varying vec3 vBetaR;', + 'varying vec3 vBetaM;', + 'varying float vSunE;', + + 'const vec3 up = vec3( 0.0, 1.0, 0.0 );', + + // constants for atmospheric scattering + 'const float e = 2.71828182845904523536028747135266249775724709369995957;', + 'const float pi = 3.141592653589793238462643383279502884197169;', + + // wavelength of used primaries, according to preetham + 'const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );', + // this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function: + // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn)) + 'const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );', + + // mie stuff + // K coefficient for the primaries + 'const float v = 4.0;', + 'const vec3 K = vec3( 0.686, 0.678, 0.666 );', + // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K + 'const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );', + + // earth shadow hack + // cutoffAngle = pi / 1.95; + 'const float cutoffAngle = 1.6110731556870734;', + 'const float steepness = 1.5;', + 'const float EE = 1000.0;', + + 'float sunIntensity( float zenithAngleCos ) {', + ' zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );', + ' return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );', + '}', + + 'vec3 totalMie( float T ) {', + ' float c = ( 0.2 * T ) * 10E-18;', + ' return 0.434 * c * MieConst;', + '}', + + 'void main() {', + + ' vec4 worldPosition = modelMatrix * vec4( position, 1.0 );', + ' vWorldPosition = worldPosition.xyz;', + + ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', + ' gl_Position.z = gl_Position.w;', // set z to camera.far + + ' vSunDirection = normalize( sunPosition );', + + ' vSunE = sunIntensity( dot( vSunDirection, up ) );', + + ' vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );', + + ' float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );', + + // extinction (absorbtion + out scattering) + // rayleigh coefficients + ' vBetaR = totalRayleigh * rayleighCoefficient;', + + // mie coefficients + ' vBetaM = totalMie( turbidity ) * mieCoefficient;', + + '}' + ].join( '\n' ), + + fragmentShader: [ + 'varying vec3 vWorldPosition;', + 'varying vec3 vSunDirection;', + 'varying float vSunfade;', + 'varying vec3 vBetaR;', + 'varying vec3 vBetaM;', + 'varying float vSunE;', + + 'uniform float luminance;', + 'uniform float mieDirectionalG;', + + 'const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );', + + // constants for atmospheric scattering + 'const float pi = 3.141592653589793238462643383279502884197169;', + + 'const float n = 1.0003;', // refractive index of air + 'const float N = 2.545E25;', // number of molecules per unit volume for air at + // 288.15K and 1013mb (sea level -45 celsius) + + // optical length at zenith for molecules + 'const float rayleighZenithLength = 8.4E3;', + 'const float mieZenithLength = 1.25E3;', + 'const vec3 up = vec3( 0.0, 1.0, 0.0 );', + // 66 arc seconds -> degrees, and the cosine of that + 'const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;', + + // 3.0 / ( 16.0 * pi ) + 'const float THREE_OVER_SIXTEENPI = 0.05968310365946075;', + // 1.0 / ( 4.0 * pi ) + 'const float ONE_OVER_FOURPI = 0.07957747154594767;', + + 'float rayleighPhase( float cosTheta ) {', + ' return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );', + '}', + + 'float hgPhase( float cosTheta, float g ) {', + ' float g2 = pow( g, 2.0 );', + ' float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );', + ' return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );', + '}', + + // Filmic ToneMapping http://filmicgames.com/archives/75 + 'const float A = 0.15;', + 'const float B = 0.50;', + 'const float C = 0.10;', + 'const float D = 0.20;', + 'const float E = 0.02;', + 'const float F = 0.30;', + + 'const float whiteScale = 1.0748724675633854;', // 1.0 / Uncharted2Tonemap(1000.0) + + 'vec3 Uncharted2Tonemap( vec3 x ) {', + ' return ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;', + '}', + + + 'void main() {', + // optical length + // cutoff angle at 90 to avoid singularity in next formula. + ' float zenithAngle = acos( max( 0.0, dot( up, normalize( vWorldPosition - cameraPos ) ) ) );', + ' float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );', + ' float sR = rayleighZenithLength * inverse;', + ' float sM = mieZenithLength * inverse;', + + // combined extinction factor + ' vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );', + + // in scattering + ' float cosTheta = dot( normalize( vWorldPosition - cameraPos ), vSunDirection );', + + ' float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );', + ' vec3 betaRTheta = vBetaR * rPhase;', + + ' float mPhase = hgPhase( cosTheta, mieDirectionalG );', + ' vec3 betaMTheta = vBetaM * mPhase;', + + ' vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );', + ' Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );', + + // nightsky + ' vec3 direction = normalize( vWorldPosition - cameraPos );', + ' float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]', + ' float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]', + ' vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );', + ' vec3 L0 = vec3( 0.1 ) * Fex;', + + // composition + solar disc + ' float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );', + ' L0 += ( vSunE * 19000.0 * Fex ) * sundisk;', + + ' vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );', + + ' vec3 curr = Uncharted2Tonemap( ( log2( 2.0 / pow( luminance, 4.0 ) ) ) * texColor );', + ' vec3 color = curr * whiteScale;', + + ' vec3 retColor = pow( color, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );', + + ' gl_FragColor = vec4( retColor, 1.0 );', + + '}' + ].join( '\n' ) + +}; diff --git a/three/jsutil/objects/Water.js b/three/jsutil/objects/Water.js new file mode 100644 index 000000000..2b5ee95c8 --- /dev/null +++ b/three/jsutil/objects/Water.js @@ -0,0 +1,308 @@ +/** + * @author jbouny / https://github.com/jbouny + * + * Work based on : + * @author Slayvin / http://slayvin.net : Flat mirror for three.js + * @author Stemkoski / http://www.adelphi.edu/~stemkoski : An implementation of water shader based on the flat mirror + * @author Jonas Wagner / http://29a.ch/ && http://29a.ch/slides/2012/webglwater/ : Water shader explanations in WebGL + */ + +THREE.Water = function ( geometry, options ) { + + THREE.Mesh.call( this, geometry ); + + var scope = this; + + options = options || {}; + + var textureWidth = options.textureWidth !== undefined ? options.textureWidth : 512; + var textureHeight = options.textureHeight !== undefined ? options.textureHeight : 512; + + var clipBias = options.clipBias !== undefined ? options.clipBias : 0.0; + var alpha = options.alpha !== undefined ? options.alpha : 1.0; + var time = options.time !== undefined ? options.time : 0.0; + var normalSampler = options.waterNormals !== undefined ? options.waterNormals : null; + var sunDirection = options.sunDirection !== undefined ? options.sunDirection : new THREE.Vector3( 0.70707, 0.70707, 0.0 ); + var sunColor = new THREE.Color( options.sunColor !== undefined ? options.sunColor : 0xffffff ); + var waterColor = new THREE.Color( options.waterColor !== undefined ? options.waterColor : 0x7F7F7F ); + var eye = options.eye !== undefined ? options.eye : new THREE.Vector3( 0, 0, 0 ); + var distortionScale = options.distortionScale !== undefined ? options.distortionScale : 20.0; + var side = options.side !== undefined ? options.side : THREE.FrontSide; + var fog = options.fog !== undefined ? options.fog : false; + + // + + var mirrorPlane = new THREE.Plane(); + var normal = new THREE.Vector3(); + var mirrorWorldPosition = new THREE.Vector3(); + var cameraWorldPosition = new THREE.Vector3(); + var rotationMatrix = new THREE.Matrix4(); + var lookAtPosition = new THREE.Vector3( 0, 0, - 1 ); + var clipPlane = new THREE.Vector4(); + + var view = new THREE.Vector3(); + var target = new THREE.Vector3(); + var q = new THREE.Vector4(); + + var textureMatrix = new THREE.Matrix4(); + + var mirrorCamera = new THREE.PerspectiveCamera(); + + var parameters = { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBFormat, + stencilBuffer: false + }; + + var renderTarget = new THREE.WebGLRenderTarget( textureWidth, textureHeight, parameters ); + + if ( ! THREE.Math.isPowerOfTwo( textureWidth ) || ! THREE.Math.isPowerOfTwo( textureHeight ) ) { + + renderTarget.texture.generateMipmaps = false; + + } + + var mirrorShader = { + + uniforms: THREE.UniformsUtils.merge( [ + THREE.UniformsLib[ 'fog' ], + THREE.UniformsLib[ 'lights' ], + { + normalSampler: { value: null }, + mirrorSampler: { value: null }, + alpha: { value: 1.0 }, + time: { value: 0.0 }, + size: { value: 1.0 }, + distortionScale: { value: 20.0 }, + textureMatrix: { value: new THREE.Matrix4() }, + sunColor: { value: new THREE.Color( 0x7F7F7F ) }, + sunDirection: { value: new THREE.Vector3( 0.70707, 0.70707, 0 ) }, + eye: { value: new THREE.Vector3() }, + waterColor: { value: new THREE.Color( 0x555555 ) } + } + ] ), + + vertexShader: [ + 'uniform mat4 textureMatrix;', + 'uniform float time;', + + 'varying vec4 mirrorCoord;', + 'varying vec4 worldPosition;', + + THREE.ShaderChunk[ 'fog_pars_vertex' ], + THREE.ShaderChunk[ 'shadowmap_pars_vertex' ], + + 'void main() {', + ' mirrorCoord = modelMatrix * vec4( position, 1.0 );', + ' worldPosition = mirrorCoord.xyzw;', + ' mirrorCoord = textureMatrix * mirrorCoord;', + ' vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );', + ' gl_Position = projectionMatrix * mvPosition;', + + THREE.ShaderChunk[ 'fog_vertex' ], + THREE.ShaderChunk[ 'shadowmap_vertex' ], + + '}' + ].join( '\n' ), + + fragmentShader: [ + 'uniform sampler2D mirrorSampler;', + 'uniform float alpha;', + 'uniform float time;', + 'uniform float size;', + 'uniform float distortionScale;', + 'uniform sampler2D normalSampler;', + 'uniform vec3 sunColor;', + 'uniform vec3 sunDirection;', + 'uniform vec3 eye;', + 'uniform vec3 waterColor;', + + 'varying vec4 mirrorCoord;', + 'varying vec4 worldPosition;', + + 'vec4 getNoise( vec2 uv ) {', + ' vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);', + ' vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );', + ' vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );', + ' vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );', + ' vec4 noise = texture2D( normalSampler, uv0 ) +', + ' texture2D( normalSampler, uv1 ) +', + ' texture2D( normalSampler, uv2 ) +', + ' texture2D( normalSampler, uv3 );', + ' return noise * 0.5 - 1.0;', + '}', + + 'void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {', + ' vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );', + ' float direction = max( 0.0, dot( eyeDirection, reflection ) );', + ' specularColor += pow( direction, shiny ) * sunColor * spec;', + ' diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;', + '}', + + THREE.ShaderChunk[ 'common' ], + THREE.ShaderChunk[ 'packing' ], + THREE.ShaderChunk[ 'bsdfs' ], + THREE.ShaderChunk[ 'fog_pars_fragment' ], + THREE.ShaderChunk[ 'lights_pars_begin' ], + THREE.ShaderChunk[ 'shadowmap_pars_fragment' ], + THREE.ShaderChunk[ 'shadowmask_pars_fragment' ], + + 'void main() {', + ' vec4 noise = getNoise( worldPosition.xz * size );', + ' vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );', + + ' vec3 diffuseLight = vec3(0.0);', + ' vec3 specularLight = vec3(0.0);', + + ' vec3 worldToEye = eye-worldPosition.xyz;', + ' vec3 eyeDirection = normalize( worldToEye );', + ' sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );', + + ' float distance = length(worldToEye);', + + ' vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;', + ' vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.z + distortion ) );', + + ' float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );', + ' float rf0 = 0.3;', + ' float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );', + ' vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;', + ' vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);', + ' vec3 outgoingLight = albedo;', + ' gl_FragColor = vec4( outgoingLight, alpha );', + + THREE.ShaderChunk[ 'tonemapping_fragment' ], + THREE.ShaderChunk[ 'fog_fragment' ], + + '}' + ].join( '\n' ) + + }; + + var material = new THREE.ShaderMaterial( { + fragmentShader: mirrorShader.fragmentShader, + vertexShader: mirrorShader.vertexShader, + uniforms: THREE.UniformsUtils.clone( mirrorShader.uniforms ), + transparent: true, + lights: true, + side: side, + fog: fog + } ); + + material.uniforms.mirrorSampler.value = renderTarget.texture; + material.uniforms.textureMatrix.value = textureMatrix; + material.uniforms.alpha.value = alpha; + material.uniforms.time.value = time; + material.uniforms.normalSampler.value = normalSampler; + material.uniforms.sunColor.value = sunColor; + material.uniforms.waterColor.value = waterColor; + material.uniforms.sunDirection.value = sunDirection; + material.uniforms.distortionScale.value = distortionScale; + + material.uniforms.eye.value = eye; + + scope.material = material; + + scope.onBeforeRender = function ( renderer, scene, camera ) { + + mirrorWorldPosition.setFromMatrixPosition( scope.matrixWorld ); + cameraWorldPosition.setFromMatrixPosition( camera.matrixWorld ); + + rotationMatrix.extractRotation( scope.matrixWorld ); + + normal.set( 0, 0, 1 ); + normal.applyMatrix4( rotationMatrix ); + + view.subVectors( mirrorWorldPosition, cameraWorldPosition ); + + // Avoid rendering when mirror is facing away + + if ( view.dot( normal ) > 0 ) return; + + view.reflect( normal ).negate(); + view.add( mirrorWorldPosition ); + + rotationMatrix.extractRotation( camera.matrixWorld ); + + lookAtPosition.set( 0, 0, - 1 ); + lookAtPosition.applyMatrix4( rotationMatrix ); + lookAtPosition.add( cameraWorldPosition ); + + target.subVectors( mirrorWorldPosition, lookAtPosition ); + target.reflect( normal ).negate(); + target.add( mirrorWorldPosition ); + + mirrorCamera.position.copy( view ); + mirrorCamera.up.set( 0, 1, 0 ); + mirrorCamera.up.applyMatrix4( rotationMatrix ); + mirrorCamera.up.reflect( normal ); + mirrorCamera.lookAt( target ); + + mirrorCamera.far = camera.far; // Used in WebGLBackground + + mirrorCamera.updateMatrixWorld(); + mirrorCamera.projectionMatrix.copy( camera.projectionMatrix ); + + // Update the texture matrix + textureMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); + textureMatrix.multiply( mirrorCamera.projectionMatrix ); + textureMatrix.multiply( mirrorCamera.matrixWorldInverse ); + + // Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html + // Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf + mirrorPlane.setFromNormalAndCoplanarPoint( normal, mirrorWorldPosition ); + mirrorPlane.applyMatrix4( mirrorCamera.matrixWorldInverse ); + + clipPlane.set( mirrorPlane.normal.x, mirrorPlane.normal.y, mirrorPlane.normal.z, mirrorPlane.constant ); + + var projectionMatrix = mirrorCamera.projectionMatrix; + + q.x = ( Math.sign( clipPlane.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ]; + q.y = ( Math.sign( clipPlane.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ]; + q.z = - 1.0; + q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ]; + + // Calculate the scaled plane vector + clipPlane.multiplyScalar( 2.0 / clipPlane.dot( q ) ); + + // Replacing the third row of the projection matrix + projectionMatrix.elements[ 2 ] = clipPlane.x; + projectionMatrix.elements[ 6 ] = clipPlane.y; + projectionMatrix.elements[ 10 ] = clipPlane.z + 1.0 - clipBias; + projectionMatrix.elements[ 14 ] = clipPlane.w; + + eye.setFromMatrixPosition( camera.matrixWorld ); + + // + + var currentRenderTarget = renderer.getRenderTarget(); + + var currentVrEnabled = renderer.vr.enabled; + var currentShadowAutoUpdate = renderer.shadowMap.autoUpdate; + + scope.visible = false; + + renderer.vr.enabled = false; // Avoid camera modification and recursion + renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows + + renderer.render( scene, mirrorCamera, renderTarget, true ); + + scope.visible = true; + + renderer.vr.enabled = currentVrEnabled; + renderer.shadowMap.autoUpdate = currentShadowAutoUpdate; + + renderer.setRenderTarget( currentRenderTarget ); + + }; + +}; + +THREE.Water.prototype = Object.create( THREE.Mesh.prototype ); +THREE.Water.prototype.constructor = THREE.Water; diff --git a/three/jsutil/objects/Water2.js b/three/jsutil/objects/Water2.js new file mode 100644 index 000000000..b178f4452 --- /dev/null +++ b/three/jsutil/objects/Water2.js @@ -0,0 +1,338 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + * + * References: + * http://www.valvesoftware.com/publications/2010/siggraph2010_vlachos_waterflow.pdf + * http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html + * + */ + +THREE.Water = function ( geometry, options ) { + + THREE.Mesh.call( this, geometry ); + + this.type = 'Water'; + + var scope = this; + + options = options || {}; + + var color = ( options.color !== undefined ) ? new THREE.Color( options.color ) : new THREE.Color( 0xFFFFFF ); + var textureWidth = options.textureWidth || 512; + var textureHeight = options.textureHeight || 512; + var clipBias = options.clipBias || 0; + var flowDirection = options.flowDirection || new THREE.Vector2( 1, 0 ); + var flowSpeed = options.flowSpeed || 0.03; + var reflectivity = options.reflectivity || 0.02; + var scale = options.scale || 1; + var shader = options.shader || THREE.Water.WaterShader; + + var textureLoader = new THREE.TextureLoader(); + + var flowMap = options.flowMap || undefined; + var normalMap0 = options.normalMap0 || textureLoader.load( 'textures/water/Water_1_M_Normal.jpg' ); + var normalMap1 = options.normalMap1 || textureLoader.load( 'textures/water/Water_2_M_Normal.jpg' ); + + var cycle = 0.15; // a cycle of a flow map phase + var halfCycle = cycle * 0.5; + var textureMatrix = new THREE.Matrix4(); + var clock = new THREE.Clock(); + + // internal components + + if ( THREE.Reflector === undefined ) { + + console.error( 'THREE.Water: Required component THREE.Reflector not found.' ); + return; + + } + + if ( THREE.Refractor === undefined ) { + + console.error( 'THREE.Water: Required component THREE.Refractor not found.' ); + return; + + } + + var reflector = new THREE.Reflector( geometry, { + textureWidth: textureWidth, + textureHeight: textureHeight, + clipBias: clipBias + } ); + + var refractor = new THREE.Refractor( geometry, { + textureWidth: textureWidth, + textureHeight: textureHeight, + clipBias: clipBias + } ); + + reflector.matrixAutoUpdate = false; + refractor.matrixAutoUpdate = false; + + // material + + this.material = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.merge( [ + THREE.UniformsLib[ 'fog' ], + shader.uniforms + ] ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + transparent: true, + fog: true + } ); + + if ( flowMap !== undefined ) { + + this.material.defines.USE_FLOWMAP = ''; + this.material.uniforms.tFlowMap = { + type: 't', + value: flowMap + }; + + } else { + + this.material.uniforms.flowDirection = { + type: 'v2', + value: flowDirection + }; + + } + + // maps + + normalMap0.wrapS = normalMap0.wrapT = THREE.RepeatWrapping; + normalMap1.wrapS = normalMap1.wrapT = THREE.RepeatWrapping; + + this.material.uniforms.tReflectionMap.value = reflector.getRenderTarget().texture; + this.material.uniforms.tRefractionMap.value = refractor.getRenderTarget().texture; + this.material.uniforms.tNormalMap0.value = normalMap0; + this.material.uniforms.tNormalMap1.value = normalMap1; + + // water + + this.material.uniforms.color.value = color; + this.material.uniforms.reflectivity.value = reflectivity; + this.material.uniforms.textureMatrix.value = textureMatrix; + + // inital values + + this.material.uniforms.config.value.x = 0; // flowMapOffset0 + this.material.uniforms.config.value.y = halfCycle; // flowMapOffset1 + this.material.uniforms.config.value.z = halfCycle; // halfCycle + this.material.uniforms.config.value.w = scale; // scale + + // functions + + function updateTextureMatrix( camera ) { + + textureMatrix.set( + 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 + ); + + textureMatrix.multiply( camera.projectionMatrix ); + textureMatrix.multiply( camera.matrixWorldInverse ); + textureMatrix.multiply( scope.matrixWorld ); + + } + + function updateFlow() { + + var delta = clock.getDelta(); + var config = scope.material.uniforms.config; + + config.value.x += flowSpeed * delta; // flowMapOffset0 + config.value.y = config.value.x + halfCycle; // flowMapOffset1 + + // Important: The distance between offsets should be always the value of "halfCycle". + // Moreover, both offsets should be in the range of [ 0, cycle ]. + // This approach ensures a smooth water flow and avoids "reset" effects. + + if ( config.value.x >= cycle ) { + + config.value.x = 0; + config.value.y = halfCycle; + + } else if ( config.value.y >= cycle ) { + + config.value.y = config.value.y - cycle; + + } + + } + + // + + this.onBeforeRender = function ( renderer, scene, camera ) { + + updateTextureMatrix( camera ); + updateFlow(); + + scope.visible = false; + + reflector.matrixWorld.copy( scope.matrixWorld ); + refractor.matrixWorld.copy( scope.matrixWorld ); + + reflector.onBeforeRender( renderer, scene, camera ); + refractor.onBeforeRender( renderer, scene, camera ); + + scope.visible = true; + + }; + +}; + +THREE.Water.prototype = Object.create( THREE.Mesh.prototype ); +THREE.Water.prototype.constructor = THREE.Water; + +THREE.Water.WaterShader = { + + uniforms: { + + 'color': { + type: 'c', + value: null + }, + + 'reflectivity': { + type: 'f', + value: 0 + }, + + 'tReflectionMap': { + type: 't', + value: null + }, + + 'tRefractionMap': { + type: 't', + value: null + }, + + 'tNormalMap0': { + type: 't', + value: null + }, + + 'tNormalMap1': { + type: 't', + value: null + }, + + 'textureMatrix': { + type: 'm4', + value: null + }, + + 'config': { + type: 'v4', + value: new THREE.Vector4() + } + + }, + + vertexShader: [ + + '#include ', + + 'uniform mat4 textureMatrix;', + + 'varying vec4 vCoord;', + 'varying vec2 vUv;', + 'varying vec3 vToEye;', + + 'void main() {', + + ' vUv = uv;', + ' vCoord = textureMatrix * vec4( position, 1.0 );', + + ' vec4 worldPosition = modelMatrix * vec4( position, 1.0 );', + ' vToEye = cameraPosition - worldPosition.xyz;', + + ' vec4 mvPosition = viewMatrix * worldPosition;', // used in fog_vertex + ' gl_Position = projectionMatrix * mvPosition;', + + ' #include ', + + '}' + + ].join( '\n' ), + + fragmentShader: [ + + '#include ', + '#include ', + + 'uniform sampler2D tReflectionMap;', + 'uniform sampler2D tRefractionMap;', + 'uniform sampler2D tNormalMap0;', + 'uniform sampler2D tNormalMap1;', + + '#ifdef USE_FLOWMAP', + ' uniform sampler2D tFlowMap;', + '#else', + ' uniform vec2 flowDirection;', + '#endif', + + 'uniform vec3 color;', + 'uniform float reflectivity;', + 'uniform vec4 config;', + + 'varying vec4 vCoord;', + 'varying vec2 vUv;', + 'varying vec3 vToEye;', + + 'void main() {', + + ' float flowMapOffset0 = config.x;', + ' float flowMapOffset1 = config.y;', + ' float halfCycle = config.z;', + ' float scale = config.w;', + + ' vec3 toEye = normalize( vToEye );', + + // determine flow direction + ' vec2 flow;', + ' #ifdef USE_FLOWMAP', + ' flow = texture2D( tFlowMap, vUv ).rg * 2.0 - 1.0;', + ' #else', + ' flow = flowDirection;', + ' #endif', + ' flow.x *= - 1.0;', + + // sample normal maps (distort uvs with flowdata) + ' vec4 normalColor0 = texture2D( tNormalMap0, ( vUv * scale ) + flow * flowMapOffset0 );', + ' vec4 normalColor1 = texture2D( tNormalMap1, ( vUv * scale ) + flow * flowMapOffset1 );', + + // linear interpolate to get the final normal color + ' float flowLerp = abs( halfCycle - flowMapOffset0 ) / halfCycle;', + ' vec4 normalColor = mix( normalColor0, normalColor1, flowLerp );', + + // calculate normal vector + ' vec3 normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );', + + // calculate the fresnel term to blend reflection and refraction maps + ' float theta = max( dot( toEye, normal ), 0.0 );', + ' float reflectance = reflectivity + ( 1.0 - reflectivity ) * pow( ( 1.0 - theta ), 5.0 );', + + // calculate final uv coords + ' vec3 coord = vCoord.xyz / vCoord.w;', + ' vec2 uv = coord.xy + coord.z * normal.xz * 0.05;', + + ' vec4 reflectColor = texture2D( tReflectionMap, vec2( 1.0 - uv.x, uv.y ) );', + ' vec4 refractColor = texture2D( tRefractionMap, uv );', + + // multiply water color with the mix of both textures + ' gl_FragColor = vec4( color, 1.0 ) * mix( refractColor, reflectColor, reflectance );', + + ' #include ', + ' #include ', + ' #include ', + + '}' + + ].join( '\n' ) +}; diff --git a/three/jsutil/pmrem/PMREMCubeUVPacker.js b/three/jsutil/pmrem/PMREMCubeUVPacker.js new file mode 100644 index 000000000..65b1a85ad --- /dev/null +++ b/three/jsutil/pmrem/PMREMCubeUVPacker.js @@ -0,0 +1,203 @@ +/** + * @author Prashant Sharma / spidersharma03 + * @author Ben Houston / bhouston, https://clara.io + * + * This class takes the cube lods(corresponding to different roughness values), and creates a single cubeUV + * Texture. The format for a given roughness set of faces is simply:: + * +X+Y+Z + * -X-Y-Z + * For every roughness a mip map chain is also saved, which is essential to remove the texture artifacts due to + * minification. + * Right now for every face a PlaneMesh is drawn, which leads to a lot of geometry draw calls, but can be replaced + * later by drawing a single buffer and by sending the appropriate faceIndex via vertex attributes. + * The arrangement of the faces is fixed, as assuming this arrangement, the sampling function has been written. + */ + +THREE.PMREMCubeUVPacker = function ( cubeTextureLods ) { + + this.cubeLods = cubeTextureLods; + var size = cubeTextureLods[ 0 ].width * 4; + + var sourceTexture = cubeTextureLods[ 0 ].texture; + var params = { + format: sourceTexture.format, + magFilter: sourceTexture.magFilter, + minFilter: sourceTexture.minFilter, + type: sourceTexture.type, + generateMipmaps: sourceTexture.generateMipmaps, + anisotropy: sourceTexture.anisotropy, + encoding: ( sourceTexture.encoding === THREE.RGBEEncoding ) ? THREE.RGBM16Encoding : sourceTexture.encoding + }; + + if ( params.encoding === THREE.RGBM16Encoding ) { + + params.magFilter = THREE.LinearFilter; + params.minFilter = THREE.LinearFilter; + + } + + this.CubeUVRenderTarget = new THREE.WebGLRenderTarget( size, size, params ); + this.CubeUVRenderTarget.texture.name = "PMREMCubeUVPacker.cubeUv"; + this.CubeUVRenderTarget.texture.mapping = THREE.CubeUVReflectionMapping; + this.camera = new THREE.OrthographicCamera( - size * 0.5, size * 0.5, - size * 0.5, size * 0.5, 0, 1 ); // top and bottom are swapped for some reason? + + this.scene = new THREE.Scene(); + + this.objects = []; + + var geometry = new THREE.PlaneBufferGeometry( 1, 1 ); + + var faceOffsets = []; + faceOffsets.push( new THREE.Vector2( 0, 0 ) ); + faceOffsets.push( new THREE.Vector2( 1, 0 ) ); + faceOffsets.push( new THREE.Vector2( 2, 0 ) ); + faceOffsets.push( new THREE.Vector2( 0, 1 ) ); + faceOffsets.push( new THREE.Vector2( 1, 1 ) ); + faceOffsets.push( new THREE.Vector2( 2, 1 ) ); + + var textureResolution = size; + size = cubeTextureLods[ 0 ].width; + + var offset2 = 0; + var c = 4.0; + this.numLods = Math.log( cubeTextureLods[ 0 ].width ) / Math.log( 2 ) - 2; // IE11 doesn't support Math.log2 + for ( var i = 0; i < this.numLods; i ++ ) { + + var offset1 = ( textureResolution - textureResolution / c ) * 0.5; + if ( size > 16 ) c *= 2; + var nMips = size > 16 ? 6 : 1; + var mipOffsetX = 0; + var mipOffsetY = 0; + var mipSize = size; + + for ( var j = 0; j < nMips; j ++ ) { + + // Mip Maps + for ( var k = 0; k < 6; k ++ ) { + + // 6 Cube Faces + var material = this.getShader(); + material.uniforms[ 'envMap' ].value = this.cubeLods[ i ].texture; + material.envMap = this.cubeLods[ i ].texture; + material.uniforms[ 'faceIndex' ].value = k; + material.uniforms[ 'mapSize' ].value = mipSize; + + var planeMesh = new THREE.Mesh( geometry, material ); + planeMesh.position.x = faceOffsets[ k ].x * mipSize - offset1 + mipOffsetX; + planeMesh.position.y = faceOffsets[ k ].y * mipSize - offset1 + offset2 + mipOffsetY; + planeMesh.material.side = THREE.BackSide; + planeMesh.scale.setScalar( mipSize ); + this.scene.add( planeMesh ); + this.objects.push( planeMesh ); + + } + mipOffsetY += 1.75 * mipSize; + mipOffsetX += 1.25 * mipSize; + mipSize /= 2; + + } + offset2 += 2 * size; + if ( size > 16 ) size /= 2; + + } + +}; + +THREE.PMREMCubeUVPacker.prototype = { + + constructor: THREE.PMREMCubeUVPacker, + + update: function ( renderer ) { + + var gammaInput = renderer.gammaInput; + var gammaOutput = renderer.gammaOutput; + var toneMapping = renderer.toneMapping; + var toneMappingExposure = renderer.toneMappingExposure; + var currentRenderTarget = renderer.getRenderTarget(); + + renderer.gammaInput = false; + renderer.gammaOutput = false; + renderer.toneMapping = THREE.LinearToneMapping; + renderer.toneMappingExposure = 1.0; + renderer.render( this.scene, this.camera, this.CubeUVRenderTarget, false ); + + renderer.setRenderTarget( currentRenderTarget ); + renderer.toneMapping = toneMapping; + renderer.toneMappingExposure = toneMappingExposure; + renderer.gammaInput = gammaInput; + renderer.gammaOutput = gammaOutput; + + }, + + getShader: function () { + + var shaderMaterial = new THREE.ShaderMaterial( { + + uniforms: { + "faceIndex": { value: 0 }, + "mapSize": { value: 0 }, + "envMap": { value: null }, + "testColor": { value: new THREE.Vector3( 1, 1, 1 ) } + }, + + vertexShader: + "precision highp float;\ + varying vec2 vUv;\ + void main() {\ + vUv = uv;\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\ + }", + + fragmentShader: + "precision highp float;\ + varying vec2 vUv;\ + uniform samplerCube envMap;\ + uniform float mapSize;\ + uniform vec3 testColor;\ + uniform int faceIndex;\ + \ + void main() {\ + vec3 sampleDirection;\ + vec2 uv = vUv;\ + uv = uv * 2.0 - 1.0;\ + uv.y *= -1.0;\ + if(faceIndex == 0) {\ + sampleDirection = normalize(vec3(1.0, uv.y, -uv.x));\ + } else if(faceIndex == 1) {\ + sampleDirection = normalize(vec3(uv.x, 1.0, uv.y));\ + } else if(faceIndex == 2) {\ + sampleDirection = normalize(vec3(uv.x, uv.y, 1.0));\ + } else if(faceIndex == 3) {\ + sampleDirection = normalize(vec3(-1.0, uv.y, uv.x));\ + } else if(faceIndex == 4) {\ + sampleDirection = normalize(vec3(uv.x, -1.0, -uv.y));\ + } else {\ + sampleDirection = normalize(vec3(-uv.x, uv.y, -1.0));\ + }\ + vec4 color = envMapTexelToLinear( textureCube( envMap, sampleDirection ) );\ + gl_FragColor = linearToOutputTexel( color );\ + }", + + blending: THREE.NoBlending + + } ); + + shaderMaterial.type = 'PMREMCubeUVPacker'; + + return shaderMaterial; + + }, + + dispose: function () { + + for ( var i = 0, l = this.objects.length; i < l; i ++ ) { + + this.objects[ i ].material.dispose(); + + } + + this.objects[ 0 ].geometry.dispose(); + + } + +}; diff --git a/three/jsutil/pmrem/PMREMGenerator.js b/three/jsutil/pmrem/PMREMGenerator.js new file mode 100644 index 000000000..c57bf431d --- /dev/null +++ b/three/jsutil/pmrem/PMREMGenerator.js @@ -0,0 +1,285 @@ +/** + * @author Prashant Sharma / spidersharma03 + * @author Ben Houston / bhouston, https://clara.io + * + * To avoid cube map seams, I create an extra pixel around each face. This way when the cube map is + * sampled by an application later(with a little care by sampling the centre of the texel), the extra 1 border + * of pixels makes sure that there is no seams artifacts present. This works perfectly for cubeUV format as + * well where the 6 faces can be arranged in any manner whatsoever. + * Code in the beginning of fragment shader's main function does this job for a given resolution. + * Run Scene_PMREM_Test.html in the examples directory to see the sampling from the cube lods generated + * by this class. + */ + +THREE.PMREMGenerator = function ( sourceTexture, samplesPerLevel, resolution ) { + + this.sourceTexture = sourceTexture; + this.resolution = ( resolution !== undefined ) ? resolution : 256; // NODE: 256 is currently hard coded in the glsl code for performance reasons + this.samplesPerLevel = ( samplesPerLevel !== undefined ) ? samplesPerLevel : 16; + + var monotonicEncoding = ( sourceTexture.encoding === THREE.LinearEncoding ) || + ( sourceTexture.encoding === THREE.GammaEncoding ) || ( sourceTexture.encoding === THREE.sRGBEncoding ); + + this.sourceTexture.minFilter = ( monotonicEncoding ) ? THREE.LinearFilter : THREE.NearestFilter; + this.sourceTexture.magFilter = ( monotonicEncoding ) ? THREE.LinearFilter : THREE.NearestFilter; + this.sourceTexture.generateMipmaps = this.sourceTexture.generateMipmaps && monotonicEncoding; + + this.cubeLods = []; + + var size = this.resolution; + var params = { + format: this.sourceTexture.format, + magFilter: this.sourceTexture.magFilter, + minFilter: this.sourceTexture.minFilter, + type: this.sourceTexture.type, + generateMipmaps: this.sourceTexture.generateMipmaps, + anisotropy: this.sourceTexture.anisotropy, + encoding: this.sourceTexture.encoding + }; + + // how many LODs fit in the given CubeUV Texture. + this.numLods = Math.log( size ) / Math.log( 2 ) - 2; // IE11 doesn't support Math.log2 + + for ( var i = 0; i < this.numLods; i ++ ) { + + var renderTarget = new THREE.WebGLRenderTargetCube( size, size, params ); + renderTarget.texture.name = "PMREMGenerator.cube" + i; + this.cubeLods.push( renderTarget ); + size = Math.max( 16, size / 2 ); + + } + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0.0, 1000 ); + + this.shader = this.getShader(); + this.shader.defines[ 'SAMPLES_PER_LEVEL' ] = this.samplesPerLevel; + this.planeMesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2, 0 ), this.shader ); + this.planeMesh.material.side = THREE.DoubleSide; + this.scene = new THREE.Scene(); + this.scene.add( this.planeMesh ); + this.scene.add( this.camera ); + + this.shader.uniforms[ 'envMap' ].value = this.sourceTexture; + this.shader.envMap = this.sourceTexture; + +}; + +THREE.PMREMGenerator.prototype = { + + constructor: THREE.PMREMGenerator, + + /* + * Prashant Sharma / spidersharma03: More thought and work is needed here. + * Right now it's a kind of a hack to use the previously convolved map to convolve the current one. + * I tried to use the original map to convolve all the lods, but for many textures(specially the high frequency) + * even a high number of samples(1024) dosen't lead to satisfactory results. + * By using the previous convolved maps, a lower number of samples are generally sufficient(right now 32, which + * gives okay results unless we see the reflection very carefully, or zoom in too much), however the math + * goes wrong as the distribution function tries to sample a larger area than what it should be. So I simply scaled + * the roughness by 0.9(totally empirical) to try to visually match the original result. + * The condition "if(i <5)" is also an attemt to make the result match the original result. + * This method requires the most amount of thinking I guess. Here is a paper which we could try to implement in future:: + * http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html + */ + update: function ( renderer ) { + + this.shader.uniforms[ 'envMap' ].value = this.sourceTexture; + this.shader.envMap = this.sourceTexture; + + var gammaInput = renderer.gammaInput; + var gammaOutput = renderer.gammaOutput; + var toneMapping = renderer.toneMapping; + var toneMappingExposure = renderer.toneMappingExposure; + var currentRenderTarget = renderer.getRenderTarget(); + + renderer.toneMapping = THREE.LinearToneMapping; + renderer.toneMappingExposure = 1.0; + renderer.gammaInput = false; + renderer.gammaOutput = false; + + for ( var i = 0; i < this.numLods; i ++ ) { + + var r = i / ( this.numLods - 1 ); + this.shader.uniforms[ 'roughness' ].value = r * 0.9; // see comment above, pragmatic choice + this.shader.uniforms[ 'queryScale' ].value.x = ( i == 0 ) ? - 1 : 1; + var size = this.cubeLods[ i ].width; + this.shader.uniforms[ 'mapSize' ].value = size; + this.renderToCubeMapTarget( renderer, this.cubeLods[ i ] ); + + if ( i < 5 ) this.shader.uniforms[ 'envMap' ].value = this.cubeLods[ i ].texture; + + } + + renderer.setRenderTarget( currentRenderTarget ); + renderer.toneMapping = toneMapping; + renderer.toneMappingExposure = toneMappingExposure; + renderer.gammaInput = gammaInput; + renderer.gammaOutput = gammaOutput; + + }, + + renderToCubeMapTarget: function ( renderer, renderTarget ) { + + for ( var i = 0; i < 6; i ++ ) { + + this.renderToCubeMapTargetFace( renderer, renderTarget, i ); + + } + + }, + + renderToCubeMapTargetFace: function ( renderer, renderTarget, faceIndex ) { + + renderTarget.activeCubeFace = faceIndex; + this.shader.uniforms[ 'faceIndex' ].value = faceIndex; + renderer.render( this.scene, this.camera, renderTarget, true ); + + }, + + getShader: function () { + + var shaderMaterial = new THREE.ShaderMaterial( { + + defines: { + "SAMPLES_PER_LEVEL": 20, + }, + + uniforms: { + "faceIndex": { value: 0 }, + "roughness": { value: 0.5 }, + "mapSize": { value: 0.5 }, + "envMap": { value: null }, + "queryScale": { value: new THREE.Vector3( 1, 1, 1 ) }, + "testColor": { value: new THREE.Vector3( 1, 1, 1 ) }, + }, + + vertexShader: + "varying vec2 vUv;\n\ + void main() {\n\ + vUv = uv;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "#include \n\ + varying vec2 vUv;\n\ + uniform int faceIndex;\n\ + uniform float roughness;\n\ + uniform samplerCube envMap;\n\ + uniform float mapSize;\n\ + uniform vec3 testColor;\n\ + uniform vec3 queryScale;\n\ + \n\ + float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\ + float a = ggxRoughness + 0.0001;\n\ + a *= a;\n\ + return ( 2.0 / a - 2.0 );\n\ + }\n\ + vec3 ImportanceSamplePhong(vec2 uv, mat3 vecSpace, float specPow) {\n\ + float phi = uv.y * 2.0 * PI;\n\ + float cosTheta = pow(1.0 - uv.x, 1.0 / (specPow + 1.0));\n\ + float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n\ + vec3 sampleDir = vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);\n\ + return vecSpace * sampleDir;\n\ + }\n\ + vec3 ImportanceSampleGGX( vec2 uv, mat3 vecSpace, float Roughness )\n\ + {\n\ + float a = Roughness * Roughness;\n\ + float Phi = 2.0 * PI * uv.x;\n\ + float CosTheta = sqrt( (1.0 - uv.y) / ( 1.0 + (a*a - 1.0) * uv.y ) );\n\ + float SinTheta = sqrt( 1.0 - CosTheta * CosTheta );\n\ + return vecSpace * vec3(SinTheta * cos( Phi ), SinTheta * sin( Phi ), CosTheta);\n\ + }\n\ + mat3 matrixFromVector(vec3 n) {\n\ + float a = 1.0 / (1.0 + n.z);\n\ + float b = -n.x * n.y * a;\n\ + vec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\ + vec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\ + return mat3(b1, b2, n);\n\ + }\n\ + \n\ + vec4 testColorMap(float Roughness) {\n\ + vec4 color;\n\ + if(faceIndex == 0)\n\ + color = vec4(1.0,0.0,0.0,1.0);\n\ + else if(faceIndex == 1)\n\ + color = vec4(0.0,1.0,0.0,1.0);\n\ + else if(faceIndex == 2)\n\ + color = vec4(0.0,0.0,1.0,1.0);\n\ + else if(faceIndex == 3)\n\ + color = vec4(1.0,1.0,0.0,1.0);\n\ + else if(faceIndex == 4)\n\ + color = vec4(0.0,1.0,1.0,1.0);\n\ + else\n\ + color = vec4(1.0,0.0,1.0,1.0);\n\ + color *= ( 1.0 - Roughness );\n\ + return color;\n\ + }\n\ + void main() {\n\ + vec3 sampleDirection;\n\ + vec2 uv = vUv*2.0 - 1.0;\n\ + float offset = -1.0/mapSize;\n\ + const float a = -1.0;\n\ + const float b = 1.0;\n\ + float c = -1.0 + offset;\n\ + float d = 1.0 - offset;\n\ + float bminusa = b - a;\n\ + uv.x = (uv.x - a)/bminusa * d - (uv.x - b)/bminusa * c;\n\ + uv.y = (uv.y - a)/bminusa * d - (uv.y - b)/bminusa * c;\n\ + if (faceIndex==0) {\n\ + sampleDirection = vec3(1.0, -uv.y, -uv.x);\n\ + } else if (faceIndex==1) {\n\ + sampleDirection = vec3(-1.0, -uv.y, uv.x);\n\ + } else if (faceIndex==2) {\n\ + sampleDirection = vec3(uv.x, 1.0, uv.y);\n\ + } else if (faceIndex==3) {\n\ + sampleDirection = vec3(uv.x, -1.0, -uv.y);\n\ + } else if (faceIndex==4) {\n\ + sampleDirection = vec3(uv.x, -uv.y, 1.0);\n\ + } else {\n\ + sampleDirection = vec3(-uv.x, -uv.y, -1.0);\n\ + }\n\ + mat3 vecSpace = matrixFromVector(normalize(sampleDirection * queryScale));\n\ + vec3 rgbColor = vec3(0.0);\n\ + const int NumSamples = SAMPLES_PER_LEVEL;\n\ + vec3 vect;\n\ + float weight = 0.0;\n\ + for( int i = 0; i < NumSamples; i ++ ) {\n\ + float sini = sin(float(i));\n\ + float cosi = cos(float(i));\n\ + float r = rand(vec2(sini, cosi));\n\ + vect = ImportanceSampleGGX(vec2(float(i) / float(NumSamples), r), vecSpace, roughness);\n\ + float dotProd = dot(vect, normalize(sampleDirection));\n\ + weight += dotProd;\n\ + vec3 color = envMapTexelToLinear(textureCube(envMap,vect)).rgb;\n\ + rgbColor.rgb += color;\n\ + }\n\ + rgbColor /= float(NumSamples);\n\ + //rgbColor = testColorMap( roughness ).rgb;\n\ + gl_FragColor = linearToOutputTexel( vec4( rgbColor, 1.0 ) );\n\ + }", + + blending: THREE.NoBlending + + } ); + + shaderMaterial.type = 'PMREMGenerator'; + + return shaderMaterial; + + }, + + dispose: function () { + + for ( var i = 0, l = this.cubeLods.length; i < l; i ++ ) { + + this.cubeLods[ i ].dispose(); + + } + + this.planeMesh.geometry.dispose(); + this.planeMesh.material.dispose(); + + } + +}; diff --git a/three/jsutil/postprocessing/AdaptiveToneMappingPass.js b/three/jsutil/postprocessing/AdaptiveToneMappingPass.js new file mode 100644 index 000000000..b69d48391 --- /dev/null +++ b/three/jsutil/postprocessing/AdaptiveToneMappingPass.js @@ -0,0 +1,344 @@ +/** + * @author miibond + * Generate a texture that represents the luminosity of the current scene, adapted over time + * to simulate the optic nerve responding to the amount of light it is receiving. + * Based on a GDC2007 presentation by Wolfgang Engel titled "Post-Processing Pipeline" + * + * Full-screen tone-mapping shader based on http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf + */ + +THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) { + + THREE.Pass.call( this ); + + this.resolution = ( resolution !== undefined ) ? resolution : 256; + this.needsInit = true; + this.adaptive = adaptive !== undefined ? !! adaptive : true; + + this.luminanceRT = null; + this.previousLuminanceRT = null; + this.currentLuminanceRT = null; + + if ( THREE.CopyShader === undefined ) + console.error( "THREE.AdaptiveToneMappingPass relies on THREE.CopyShader" ); + + var copyShader = THREE.CopyShader; + + this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + + this.materialCopy = new THREE.ShaderMaterial( { + + uniforms: this.copyUniforms, + vertexShader: copyShader.vertexShader, + fragmentShader: copyShader.fragmentShader, + blending: THREE.NoBlending, + depthTest: false + + } ); + + if ( THREE.LuminosityShader === undefined ) + console.error( "THREE.AdaptiveToneMappingPass relies on THREE.LuminosityShader" ); + + this.materialLuminance = new THREE.ShaderMaterial( { + + uniforms: THREE.UniformsUtils.clone( THREE.LuminosityShader.uniforms ), + vertexShader: THREE.LuminosityShader.vertexShader, + fragmentShader: THREE.LuminosityShader.fragmentShader, + blending: THREE.NoBlending + } ); + + this.adaptLuminanceShader = { + defines: { + "MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 ) + }, + uniforms: { + "lastLum": { value: null }, + "currentLum": { value: null }, + "minLuminance": { value: 0.01 }, + "delta": { value: 0.016 }, + "tau": { value: 1.0 } + }, + vertexShader: [ + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + ].join( '\n' ), + fragmentShader: [ + "varying vec2 vUv;", + + "uniform sampler2D lastLum;", + "uniform sampler2D currentLum;", + "uniform float minLuminance;", + "uniform float delta;", + "uniform float tau;", + + "void main() {", + + "vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );", + "vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );", + + "float fLastLum = max( minLuminance, lastLum.r );", + "float fCurrentLum = max( minLuminance, currentLum.r );", + + //The adaption seems to work better in extreme lighting differences + //if the input luminance is squared. + "fCurrentLum *= fCurrentLum;", + + // Adapt the luminance using Pattanaik's technique + "float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));", + // "fAdaptedLum = sqrt(fAdaptedLum);", + "gl_FragColor.r = fAdaptedLum;", + "}" + ].join( '\n' ) + }; + + this.materialAdaptiveLum = new THREE.ShaderMaterial( { + + uniforms: THREE.UniformsUtils.clone( this.adaptLuminanceShader.uniforms ), + vertexShader: this.adaptLuminanceShader.vertexShader, + fragmentShader: this.adaptLuminanceShader.fragmentShader, + defines: Object.assign( {}, this.adaptLuminanceShader.defines ), + blending: THREE.NoBlending + } ); + + if ( THREE.ToneMapShader === undefined ) + console.error( "THREE.AdaptiveToneMappingPass relies on THREE.ToneMapShader" ); + + this.materialToneMap = new THREE.ShaderMaterial( { + + uniforms: THREE.UniformsUtils.clone( THREE.ToneMapShader.uniforms ), + vertexShader: THREE.ToneMapShader.vertexShader, + fragmentShader: THREE.ToneMapShader.fragmentShader, + blending: THREE.NoBlending + } ); + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.AdaptiveToneMappingPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + if ( this.needsInit ) { + + this.reset( renderer ); + + this.luminanceRT.texture.type = readBuffer.texture.type; + this.previousLuminanceRT.texture.type = readBuffer.texture.type; + this.currentLuminanceRT.texture.type = readBuffer.texture.type; + this.needsInit = false; + + } + + if ( this.adaptive ) { + + //Render the luminance of the current scene into a render target with mipmapping enabled + this.quad.material = this.materialLuminance; + this.materialLuminance.uniforms.tDiffuse.value = readBuffer.texture; + renderer.render( this.scene, this.camera, this.currentLuminanceRT ); + + //Use the new luminance values, the previous luminance and the frame delta to + //adapt the luminance over time. + this.quad.material = this.materialAdaptiveLum; + this.materialAdaptiveLum.uniforms.delta.value = delta; + this.materialAdaptiveLum.uniforms.lastLum.value = this.previousLuminanceRT.texture; + this.materialAdaptiveLum.uniforms.currentLum.value = this.currentLuminanceRT.texture; + renderer.render( this.scene, this.camera, this.luminanceRT ); + + //Copy the new adapted luminance value so that it can be used by the next frame. + this.quad.material = this.materialCopy; + this.copyUniforms.tDiffuse.value = this.luminanceRT.texture; + renderer.render( this.scene, this.camera, this.previousLuminanceRT ); + + } + + this.quad.material = this.materialToneMap; + this.materialToneMap.uniforms.tDiffuse.value = readBuffer.texture; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + }, + + reset: function( renderer ) { + + // render targets + if ( this.luminanceRT ) { + + this.luminanceRT.dispose(); + + } + if ( this.currentLuminanceRT ) { + + this.currentLuminanceRT.dispose(); + + } + if ( this.previousLuminanceRT ) { + + this.previousLuminanceRT.dispose(); + + } + + var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat }; // was RGB format. changed to RGBA format. see discussion in #8415 / #8450 + + this.luminanceRT = new THREE.WebGLRenderTarget( this.resolution, this.resolution, pars ); + this.luminanceRT.texture.name = "AdaptiveToneMappingPass.l"; + this.luminanceRT.texture.generateMipmaps = false; + + this.previousLuminanceRT = new THREE.WebGLRenderTarget( this.resolution, this.resolution, pars ); + this.previousLuminanceRT.texture.name = "AdaptiveToneMappingPass.pl"; + this.previousLuminanceRT.texture.generateMipmaps = false; + + // We only need mipmapping for the current luminosity because we want a down-sampled version to sample in our adaptive shader + pars.minFilter = THREE.LinearMipMapLinearFilter; + this.currentLuminanceRT = new THREE.WebGLRenderTarget( this.resolution, this.resolution, pars ); + this.currentLuminanceRT.texture.name = "AdaptiveToneMappingPass.cl"; + + if ( this.adaptive ) { + + this.materialToneMap.defines[ "ADAPTED_LUMINANCE" ] = ""; + this.materialToneMap.uniforms.luminanceMap.value = this.luminanceRT.texture; + + } + //Put something in the adaptive luminance texture so that the scene can render initially + this.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 } ); + this.materialLuminance.needsUpdate = true; + this.materialAdaptiveLum.needsUpdate = true; + this.materialToneMap.needsUpdate = true; + // renderer.render( this.scene, this.camera, this.luminanceRT ); + // renderer.render( this.scene, this.camera, this.previousLuminanceRT ); + // renderer.render( this.scene, this.camera, this.currentLuminanceRT ); + + }, + + setAdaptive: function( adaptive ) { + + if ( adaptive ) { + + this.adaptive = true; + this.materialToneMap.defines[ "ADAPTED_LUMINANCE" ] = ""; + this.materialToneMap.uniforms.luminanceMap.value = this.luminanceRT.texture; + + } else { + + this.adaptive = false; + delete this.materialToneMap.defines[ "ADAPTED_LUMINANCE" ]; + this.materialToneMap.uniforms.luminanceMap.value = null; + + } + this.materialToneMap.needsUpdate = true; + + }, + + setAdaptionRate: function( rate ) { + + if ( rate ) { + + this.materialAdaptiveLum.uniforms.tau.value = Math.abs( rate ); + + } + + }, + + setMinLuminance: function( minLum ) { + + if ( minLum ) { + + this.materialToneMap.uniforms.minLuminance.value = minLum; + this.materialAdaptiveLum.uniforms.minLuminance.value = minLum; + + } + + }, + + setMaxLuminance: function( maxLum ) { + + if ( maxLum ) { + + this.materialToneMap.uniforms.maxLuminance.value = maxLum; + + } + + }, + + setAverageLuminance: function( avgLum ) { + + if ( avgLum ) { + + this.materialToneMap.uniforms.averageLuminance.value = avgLum; + + } + + }, + + setMiddleGrey: function( middleGrey ) { + + if ( middleGrey ) { + + this.materialToneMap.uniforms.middleGrey.value = middleGrey; + + } + + }, + + dispose: function() { + + if ( this.luminanceRT ) { + + this.luminanceRT.dispose(); + + } + if ( this.previousLuminanceRT ) { + + this.previousLuminanceRT.dispose(); + + } + if ( this.currentLuminanceRT ) { + + this.currentLuminanceRT.dispose(); + + } + if ( this.materialLuminance ) { + + this.materialLuminance.dispose(); + + } + if ( this.materialAdaptiveLum ) { + + this.materialAdaptiveLum.dispose(); + + } + if ( this.materialCopy ) { + + this.materialCopy.dispose(); + + } + if ( this.materialToneMap ) { + + this.materialToneMap.dispose(); + + } + + } + +} ); diff --git a/three/jsutil/postprocessing/AfterimagePass.js b/three/jsutil/postprocessing/AfterimagePass.js new file mode 100644 index 000000000..7c8ace62d --- /dev/null +++ b/three/jsutil/postprocessing/AfterimagePass.js @@ -0,0 +1,88 @@ +/** + * @author HypnosNova / https://www.threejs.org.cn/gallery/ + */ + +THREE.AfterimagePass = function ( damp ) { + + THREE.Pass.call( this ); + + if ( THREE.AfterimageShader === undefined ) + console.error( "THREE.AfterimagePass relies on THREE.AfterimageShader" ); + + this.shader = THREE.AfterimageShader; + + this.uniforms = THREE.UniformsUtils.clone( this.shader.uniforms ); + + this.uniforms[ "damp" ].value = damp !== undefined ? damp : 0.96; + + this.textureComp = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { + + minFilter: THREE.LinearFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat + + } ); + + this.textureOld = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { + + minFilter: THREE.LinearFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat + + } ); + + this.shaderMaterial = new THREE.ShaderMaterial( { + + uniforms: this.uniforms, + vertexShader: this.shader.vertexShader, + fragmentShader: this.shader.fragmentShader + + } ); + + this.sceneComp = new THREE.Scene(); + this.scene = new THREE.Scene(); + + this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 ); + this.camera.position.z = 1; + + var geometry = new THREE.PlaneBufferGeometry( 2, 2 ); + + this.quadComp = new THREE.Mesh( geometry, this.shaderMaterial ); + this.sceneComp.add( this.quadComp ); + + var material = new THREE.MeshBasicMaterial( { + map: this.textureComp.texture + } ); + + var quadScreen = new THREE.Mesh( geometry, material ); + this.scene.add( quadScreen ); + +}; + +THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.AfterimagePass, + + render: function ( renderer, writeBuffer, readBuffer ) { + + this.uniforms[ "tOld" ].value = this.textureOld.texture; + this.uniforms[ "tNew" ].value = readBuffer.texture; + + this.quadComp.material = this.shaderMaterial; + + renderer.render( this.sceneComp, this.camera, this.textureComp ); + renderer.render( this.scene, this.camera, this.textureOld ); + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + } + +} ); diff --git a/three/jsutil/postprocessing/BloomPass.js b/three/jsutil/postprocessing/BloomPass.js new file mode 100644 index 000000000..6de015196 --- /dev/null +++ b/three/jsutil/postprocessing/BloomPass.js @@ -0,0 +1,119 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) { + + THREE.Pass.call( this ); + + strength = ( strength !== undefined ) ? strength : 1; + kernelSize = ( kernelSize !== undefined ) ? kernelSize : 25; + sigma = ( sigma !== undefined ) ? sigma : 4.0; + resolution = ( resolution !== undefined ) ? resolution : 256; + + // render targets + + var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat }; + + this.renderTargetX = new THREE.WebGLRenderTarget( resolution, resolution, pars ); + this.renderTargetX.texture.name = "BloomPass.x"; + this.renderTargetY = new THREE.WebGLRenderTarget( resolution, resolution, pars ); + this.renderTargetY.texture.name = "BloomPass.y"; + + // copy material + + if ( THREE.CopyShader === undefined ) + console.error( "THREE.BloomPass relies on THREE.CopyShader" ); + + var copyShader = THREE.CopyShader; + + this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + + this.copyUniforms[ "opacity" ].value = strength; + + this.materialCopy = new THREE.ShaderMaterial( { + + uniforms: this.copyUniforms, + vertexShader: copyShader.vertexShader, + fragmentShader: copyShader.fragmentShader, + blending: THREE.AdditiveBlending, + transparent: true + + } ); + + // convolution material + + if ( THREE.ConvolutionShader === undefined ) + console.error( "THREE.BloomPass relies on THREE.ConvolutionShader" ); + + var convolutionShader = THREE.ConvolutionShader; + + this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms ); + + this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX; + this.convolutionUniforms[ "cKernel" ].value = THREE.ConvolutionShader.buildKernel( sigma ); + + this.materialConvolution = new THREE.ShaderMaterial( { + + uniforms: this.convolutionUniforms, + vertexShader: convolutionShader.vertexShader, + fragmentShader: convolutionShader.fragmentShader, + defines: { + "KERNEL_SIZE_FLOAT": kernelSize.toFixed( 1 ), + "KERNEL_SIZE_INT": kernelSize.toFixed( 0 ) + } + + } ); + + this.needsSwap = false; + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.BloomPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST ); + + // Render quad with blured scene into texture (convolution pass 1) + + this.quad.material = this.materialConvolution; + + this.convolutionUniforms[ "tDiffuse" ].value = readBuffer.texture; + this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX; + + renderer.render( this.scene, this.camera, this.renderTargetX, true ); + + + // Render quad with blured scene into texture (convolution pass 2) + + this.convolutionUniforms[ "tDiffuse" ].value = this.renderTargetX.texture; + this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurY; + + renderer.render( this.scene, this.camera, this.renderTargetY, true ); + + // Render original scene with superimposed blur to texture + + this.quad.material = this.materialCopy; + + this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY.texture; + + if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST ); + + renderer.render( this.scene, this.camera, readBuffer, this.clear ); + + } + +} ); + +THREE.BloomPass.blurX = new THREE.Vector2( 0.001953125, 0.0 ); +THREE.BloomPass.blurY = new THREE.Vector2( 0.0, 0.001953125 ); diff --git a/three/jsutil/postprocessing/BokehPass.js b/three/jsutil/postprocessing/BokehPass.js new file mode 100644 index 000000000..fb79ccb43 --- /dev/null +++ b/three/jsutil/postprocessing/BokehPass.js @@ -0,0 +1,125 @@ +/** + * Depth-of-field post-process with bokeh shader + */ + + +THREE.BokehPass = function ( scene, camera, params ) { + + THREE.Pass.call( this ); + + this.scene = scene; + this.camera = camera; + + var focus = ( params.focus !== undefined ) ? params.focus : 1.0; + var aspect = ( params.aspect !== undefined ) ? params.aspect : camera.aspect; + var aperture = ( params.aperture !== undefined ) ? params.aperture : 0.025; + var maxblur = ( params.maxblur !== undefined ) ? params.maxblur : 1.0; + + // render targets + + var width = params.width || window.innerWidth || 1; + var height = params.height || window.innerHeight || 1; + + this.renderTargetColor = new THREE.WebGLRenderTarget( width, height, { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBFormat + } ); + this.renderTargetColor.texture.name = "BokehPass.color"; + + this.renderTargetDepth = this.renderTargetColor.clone(); + this.renderTargetDepth.texture.name = "BokehPass.depth"; + + // depth material + + this.materialDepth = new THREE.MeshDepthMaterial(); + this.materialDepth.depthPacking = THREE.RGBADepthPacking; + this.materialDepth.blending = THREE.NoBlending; + + // bokeh material + + if ( THREE.BokehShader === undefined ) { + + console.error( "THREE.BokehPass relies on THREE.BokehShader" ); + + } + + var bokehShader = THREE.BokehShader; + var bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms ); + + bokehUniforms[ "tDepth" ].value = this.renderTargetDepth.texture; + + bokehUniforms[ "focus" ].value = focus; + bokehUniforms[ "aspect" ].value = aspect; + bokehUniforms[ "aperture" ].value = aperture; + bokehUniforms[ "maxblur" ].value = maxblur; + bokehUniforms[ "nearClip" ].value = camera.near; + bokehUniforms[ "farClip" ].value = camera.far; + + this.materialBokeh = new THREE.ShaderMaterial( { + defines: Object.assign( {}, bokehShader.defines ), + uniforms: bokehUniforms, + vertexShader: bokehShader.vertexShader, + fragmentShader: bokehShader.fragmentShader + } ); + + this.uniforms = bokehUniforms; + this.needsSwap = false; + + this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene2 = new THREE.Scene(); + + this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad2.frustumCulled = false; // Avoid getting clipped + this.scene2.add( this.quad2 ); + + this.oldClearColor = new THREE.Color(); + this.oldClearAlpha = 1; + +}; + +THREE.BokehPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.BokehPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + this.quad2.material = this.materialBokeh; + + // Render depth into texture + + this.scene.overrideMaterial = this.materialDepth; + + this.oldClearColor.copy( renderer.getClearColor() ); + this.oldClearAlpha = renderer.getClearAlpha(); + var oldAutoClear = renderer.autoClear; + renderer.autoClear = false; + + renderer.setClearColor( 0xffffff ); + renderer.setClearAlpha( 1.0 ); + renderer.render( this.scene, this.camera, this.renderTargetDepth, true ); + + // Render bokeh composite + + this.uniforms[ "tColor" ].value = readBuffer.texture; + this.uniforms[ "nearClip" ].value = this.camera.near; + this.uniforms[ "farClip" ].value = this.camera.far; + + if ( this.renderToScreen ) { + + renderer.render( this.scene2, this.camera2 ); + + } else { + + renderer.render( this.scene2, this.camera2, writeBuffer, this.clear ); + + } + + this.scene.overrideMaterial = null; + renderer.setClearColor( this.oldClearColor ); + renderer.setClearAlpha( this.oldClearAlpha ); + renderer.autoClear = this.oldAutoClear; + + } + +} ); diff --git a/three/jsutil/postprocessing/ClearPass.js b/three/jsutil/postprocessing/ClearPass.js new file mode 100644 index 000000000..8b2e80275 --- /dev/null +++ b/three/jsutil/postprocessing/ClearPass.js @@ -0,0 +1,44 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.ClearPass = function ( clearColor, clearAlpha ) { + + THREE.Pass.call( this ); + + this.needsSwap = false; + + this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000; + this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; + +}; + +THREE.ClearPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.ClearPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + var oldClearColor, oldClearAlpha; + + if ( this.clearColor ) { + + oldClearColor = renderer.getClearColor().getHex(); + oldClearAlpha = renderer.getClearAlpha(); + + renderer.setClearColor( this.clearColor, this.clearAlpha ); + + } + + renderer.setRenderTarget( this.renderToScreen ? null : readBuffer ); + renderer.clear(); + + if ( this.clearColor ) { + + renderer.setClearColor( oldClearColor, oldClearAlpha ); + + } + + } + +} ); diff --git a/three/jsutil/postprocessing/CubeTexturePass.js b/three/jsutil/postprocessing/CubeTexturePass.js new file mode 100644 index 000000000..132892d37 --- /dev/null +++ b/three/jsutil/postprocessing/CubeTexturePass.js @@ -0,0 +1,57 @@ +/** + * @author bhouston / http://clara.io/ + */ + +THREE.CubeTexturePass = function ( camera, envMap, opacity ) { + + THREE.Pass.call( this ); + + this.camera = camera; + + this.needsSwap = false; + + this.cubeShader = THREE.ShaderLib[ 'cube' ]; + this.cubeMesh = new THREE.Mesh( + new THREE.BoxBufferGeometry( 10, 10, 10 ), + new THREE.ShaderMaterial( { + uniforms: this.cubeShader.uniforms, + vertexShader: this.cubeShader.vertexShader, + fragmentShader: this.cubeShader.fragmentShader, + depthTest: false, + depthWrite: false, + side: THREE.BackSide + } ) + ); + + this.envMap = envMap; + this.opacity = ( opacity !== undefined ) ? opacity : 1.0; + + this.cubeScene = new THREE.Scene(); + this.cubeCamera = new THREE.PerspectiveCamera(); + this.cubeScene.add( this.cubeMesh ); + +}; + +THREE.CubeTexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.CubeTexturePass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + var oldAutoClear = renderer.autoClear; + renderer.autoClear = false; + + this.cubeCamera.projectionMatrix.copy( this.camera.projectionMatrix ); + this.cubeCamera.quaternion.setFromRotationMatrix( this.camera.matrixWorld ); + + this.cubeMesh.material.uniforms[ "tCube" ].value = this.envMap; + this.cubeMesh.material.uniforms[ "opacity" ].value = this.opacity; + this.cubeMesh.material.transparent = ( this.opacity < 1.0 ); + + renderer.render( this.cubeScene, this.cubeCamera, this.renderToScreen ? null : readBuffer, this.clear ); + + renderer.autoClear = oldAutoClear; + + } + +} ); diff --git a/three/jsutil/postprocessing/DotScreenPass.js b/three/jsutil/postprocessing/DotScreenPass.js new file mode 100644 index 000000000..0d09e713e --- /dev/null +++ b/three/jsutil/postprocessing/DotScreenPass.js @@ -0,0 +1,60 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.DotScreenPass = function ( center, angle, scale ) { + + THREE.Pass.call( this ); + + if ( THREE.DotScreenShader === undefined ) + console.error( "THREE.DotScreenPass relies on THREE.DotScreenShader" ); + + var shader = THREE.DotScreenShader; + + this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center ); + if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle; + if ( scale !== undefined ) this.uniforms[ "scale" ].value = scale; + + this.material = new THREE.ShaderMaterial( { + + uniforms: this.uniforms, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + + } ); + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.DotScreenPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.DotScreenPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + this.uniforms[ "tDiffuse" ].value = readBuffer.texture; + this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height ); + + this.quad.material = this.material; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + } + +} ); diff --git a/three/jsutil/postprocessing/EffectComposer.js b/three/jsutil/postprocessing/EffectComposer.js new file mode 100644 index 000000000..3c3fa65b6 --- /dev/null +++ b/three/jsutil/postprocessing/EffectComposer.js @@ -0,0 +1,189 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.EffectComposer = function ( renderer, renderTarget ) { + + this.renderer = renderer; + + if ( renderTarget === undefined ) { + + var parameters = { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBAFormat, + stencilBuffer: false + }; + + var size = renderer.getDrawingBufferSize(); + renderTarget = new THREE.WebGLRenderTarget( size.width, size.height, parameters ); + renderTarget.texture.name = 'EffectComposer.rt1'; + + } + + this.renderTarget1 = renderTarget; + this.renderTarget2 = renderTarget.clone(); + this.renderTarget2.texture.name = 'EffectComposer.rt2'; + + this.writeBuffer = this.renderTarget1; + this.readBuffer = this.renderTarget2; + + this.passes = []; + + // dependencies + + if ( THREE.CopyShader === undefined ) { + + console.error( 'THREE.EffectComposer relies on THREE.CopyShader' ); + + } + + if ( THREE.ShaderPass === undefined ) { + + console.error( 'THREE.EffectComposer relies on THREE.ShaderPass' ); + + } + + this.copyPass = new THREE.ShaderPass( THREE.CopyShader ); + +}; + +Object.assign( THREE.EffectComposer.prototype, { + + swapBuffers: function () { + + var tmp = this.readBuffer; + this.readBuffer = this.writeBuffer; + this.writeBuffer = tmp; + + }, + + addPass: function ( pass ) { + + this.passes.push( pass ); + + var size = this.renderer.getDrawingBufferSize(); + pass.setSize( size.width, size.height ); + + }, + + insertPass: function ( pass, index ) { + + this.passes.splice( index, 0, pass ); + + }, + + render: function ( delta ) { + + var maskActive = false; + + var pass, i, il = this.passes.length; + + for ( i = 0; i < il; i ++ ) { + + pass = this.passes[ i ]; + + if ( pass.enabled === false ) continue; + + pass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive ); + + if ( pass.needsSwap ) { + + if ( maskActive ) { + + var context = this.renderer.context; + + context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff ); + + this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, delta ); + + context.stencilFunc( context.EQUAL, 1, 0xffffffff ); + + } + + this.swapBuffers(); + + } + + if ( THREE.MaskPass !== undefined ) { + + if ( pass instanceof THREE.MaskPass ) { + + maskActive = true; + + } else if ( pass instanceof THREE.ClearMaskPass ) { + + maskActive = false; + + } + + } + + } + + }, + + reset: function ( renderTarget ) { + + if ( renderTarget === undefined ) { + + var size = this.renderer.getDrawingBufferSize(); + + renderTarget = this.renderTarget1.clone(); + renderTarget.setSize( size.width, size.height ); + + } + + this.renderTarget1.dispose(); + this.renderTarget2.dispose(); + this.renderTarget1 = renderTarget; + this.renderTarget2 = renderTarget.clone(); + + this.writeBuffer = this.renderTarget1; + this.readBuffer = this.renderTarget2; + + }, + + setSize: function ( width, height ) { + + this.renderTarget1.setSize( width, height ); + this.renderTarget2.setSize( width, height ); + + for ( var i = 0; i < this.passes.length; i ++ ) { + + this.passes[ i ].setSize( width, height ); + + } + + } + +} ); + + +THREE.Pass = function () { + + // if set to true, the pass is processed by the composer + this.enabled = true; + + // if set to true, the pass indicates to swap read and write buffer after rendering + this.needsSwap = true; + + // if set to true, the pass clears its buffer before rendering + this.clear = false; + + // if set to true, the result of the pass is rendered to screen + this.renderToScreen = false; + +}; + +Object.assign( THREE.Pass.prototype, { + + setSize: function ( width, height ) {}, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + console.error( 'THREE.Pass: .render() must be implemented in derived pass.' ); + + } + +} ); diff --git a/three/jsutil/postprocessing/FilmPass.js b/three/jsutil/postprocessing/FilmPass.js new file mode 100644 index 000000000..e999fb0a9 --- /dev/null +++ b/three/jsutil/postprocessing/FilmPass.js @@ -0,0 +1,61 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) { + + THREE.Pass.call( this ); + + if ( THREE.FilmShader === undefined ) + console.error( "THREE.FilmPass relies on THREE.FilmShader" ); + + var shader = THREE.FilmShader; + + this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + this.material = new THREE.ShaderMaterial( { + + uniforms: this.uniforms, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + + } ); + + if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale; + if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity; + if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity; + if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount; + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.FilmPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.FilmPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + this.uniforms[ "tDiffuse" ].value = readBuffer.texture; + this.uniforms[ "time" ].value += delta; + + this.quad.material = this.material; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + } + +} ); diff --git a/three/jsutil/postprocessing/GlitchPass.js b/three/jsutil/postprocessing/GlitchPass.js new file mode 100644 index 000000000..21f628cb5 --- /dev/null +++ b/three/jsutil/postprocessing/GlitchPass.js @@ -0,0 +1,116 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.GlitchPass = function ( dt_size ) { + + THREE.Pass.call( this ); + + if ( THREE.DigitalGlitch === undefined ) console.error( "THREE.GlitchPass relies on THREE.DigitalGlitch" ); + + var shader = THREE.DigitalGlitch; + this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + if ( dt_size == undefined ) dt_size = 64; + + + this.uniforms[ "tDisp" ].value = this.generateHeightmap( dt_size ); + + + this.material = new THREE.ShaderMaterial( { + uniforms: this.uniforms, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + } ); + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + + this.goWild = false; + this.curF = 0; + this.generateTrigger(); + +}; + +THREE.GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.GlitchPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + this.uniforms[ "tDiffuse" ].value = readBuffer.texture; + this.uniforms[ 'seed' ].value = Math.random();//default seeding + this.uniforms[ 'byp' ].value = 0; + + if ( this.curF % this.randX == 0 || this.goWild == true ) { + + this.uniforms[ 'amount' ].value = Math.random() / 30; + this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI ); + this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat( - 1, 1 ); + this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 1, 1 ); + this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat( 0, 1 ); + this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat( 0, 1 ); + this.curF = 0; + this.generateTrigger(); + + } else if ( this.curF % this.randX < this.randX / 5 ) { + + this.uniforms[ 'amount' ].value = Math.random() / 90; + this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI ); + this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat( 0, 1 ); + this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat( 0, 1 ); + this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat( - 0.3, 0.3 ); + this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 0.3, 0.3 ); + + } else if ( this.goWild == false ) { + + this.uniforms[ 'byp' ].value = 1; + + } + + this.curF ++; + this.quad.material = this.material; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + }, + + generateTrigger: function() { + + this.randX = THREE.Math.randInt( 120, 240 ); + + }, + + generateHeightmap: function( dt_size ) { + + var data_arr = new Float32Array( dt_size * dt_size * 3 ); + var length = dt_size * dt_size; + + for ( var i = 0; i < length; i ++ ) { + + var val = THREE.Math.randFloat( 0, 1 ); + data_arr[ i * 3 + 0 ] = val; + data_arr[ i * 3 + 1 ] = val; + data_arr[ i * 3 + 2 ] = val; + + } + + var texture = new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType ); + texture.needsUpdate = true; + return texture; + + } + +} ); diff --git a/three/jsutil/postprocessing/HalftonePass.js b/three/jsutil/postprocessing/HalftonePass.js new file mode 100644 index 000000000..17dc84e33 --- /dev/null +++ b/three/jsutil/postprocessing/HalftonePass.js @@ -0,0 +1,74 @@ +/** + * @author meatbags / xavierburrow.com, github/meatbags + * + * RGB Halftone pass for three.js effects composer. Requires THREE.HalftoneShader. + * + */ + +THREE.HalftonePass = function ( width, height, params ) { + + THREE.Pass.call( this ); + + if ( THREE.HalftoneShader === undefined ) { + + console.error( 'THREE.HalftonePass requires THREE.HalftoneShader' ); + + } + + this.uniforms = THREE.UniformsUtils.clone( THREE.HalftoneShader.uniforms ); + this.material = new THREE.ShaderMaterial( { + uniforms: this.uniforms, + fragmentShader: THREE.HalftoneShader.fragmentShader, + vertexShader: THREE.HalftoneShader.vertexShader + } ); + + // set params + this.uniforms.width.value = width; + this.uniforms.height.value = height; + + for ( var key in params ) { + + if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) { + + this.uniforms[key].value = params[key]; + + } + + } + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; + this.scene.add( this.quad ); + + }; + + THREE.HalftonePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.HalftonePass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + this.material.uniforms[ "tDiffuse" ].value = readBuffer.texture; + this.quad.material = this.material; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + }, + + setSize: function ( width, height ) { + + this.uniforms.width.value = width; + this.uniforms.height.value = height; + + } +} ); diff --git a/three/jsutil/postprocessing/MaskPass.js b/three/jsutil/postprocessing/MaskPass.js new file mode 100644 index 000000000..8c3f19f22 --- /dev/null +++ b/three/jsutil/postprocessing/MaskPass.js @@ -0,0 +1,97 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.MaskPass = function ( scene, camera ) { + + THREE.Pass.call( this ); + + this.scene = scene; + this.camera = camera; + + this.clear = true; + this.needsSwap = false; + + this.inverse = false; + +}; + +THREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.MaskPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + var context = renderer.context; + var state = renderer.state; + + // don't update color or depth + + state.buffers.color.setMask( false ); + state.buffers.depth.setMask( false ); + + // lock buffers + + state.buffers.color.setLocked( true ); + state.buffers.depth.setLocked( true ); + + // set up stencil + + var writeValue, clearValue; + + if ( this.inverse ) { + + writeValue = 0; + clearValue = 1; + + } else { + + writeValue = 1; + clearValue = 0; + + } + + state.buffers.stencil.setTest( true ); + state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE ); + state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff ); + state.buffers.stencil.setClear( clearValue ); + + // draw into the stencil buffer + + renderer.render( this.scene, this.camera, readBuffer, this.clear ); + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + // unlock color and depth buffer for subsequent rendering + + state.buffers.color.setLocked( false ); + state.buffers.depth.setLocked( false ); + + // only render where stencil is set to 1 + + state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1 + state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP ); + + } + +} ); + + +THREE.ClearMaskPass = function () { + + THREE.Pass.call( this ); + + this.needsSwap = false; + +}; + +THREE.ClearMaskPass.prototype = Object.create( THREE.Pass.prototype ); + +Object.assign( THREE.ClearMaskPass.prototype, { + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + renderer.state.buffers.stencil.setTest( false ); + + } + +} ); diff --git a/three/jsutil/postprocessing/OutlinePass.js b/three/jsutil/postprocessing/OutlinePass.js new file mode 100644 index 000000000..31ad22d39 --- /dev/null +++ b/three/jsutil/postprocessing/OutlinePass.js @@ -0,0 +1,571 @@ +/** + * @author spidersharma / http://eduperiment.com/ + */ + +THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) { + + this.renderScene = scene; + this.renderCamera = camera; + this.selectedObjects = selectedObjects !== undefined ? selectedObjects : []; + this.visibleEdgeColor = new THREE.Color( 1, 1, 1 ); + this.hiddenEdgeColor = new THREE.Color( 0.1, 0.04, 0.02 ); + this.edgeGlow = 0.0; + this.usePatternTexture = false; + this.edgeThickness = 1.0; + this.edgeStrength = 3.0; + this.downSampleRatio = 2; + this.pulsePeriod = 0; + + THREE.Pass.call( this ); + + this.resolution = ( resolution !== undefined ) ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 ); + + var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat }; + + var resx = Math.round( this.resolution.x / this.downSampleRatio ); + var resy = Math.round( this.resolution.y / this.downSampleRatio ); + + this.maskBufferMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff } ); + this.maskBufferMaterial.side = THREE.DoubleSide; + this.renderTargetMaskBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars ); + this.renderTargetMaskBuffer.texture.name = "OutlinePass.mask"; + this.renderTargetMaskBuffer.texture.generateMipmaps = false; + + this.depthMaterial = new THREE.MeshDepthMaterial(); + this.depthMaterial.side = THREE.DoubleSide; + this.depthMaterial.depthPacking = THREE.RGBADepthPacking; + this.depthMaterial.blending = THREE.NoBlending; + + this.prepareMaskMaterial = this.getPrepareMaskMaterial(); + this.prepareMaskMaterial.side = THREE.DoubleSide; + this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera ); + + this.renderTargetDepthBuffer = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, pars ); + this.renderTargetDepthBuffer.texture.name = "OutlinePass.depth"; + this.renderTargetDepthBuffer.texture.generateMipmaps = false; + + this.renderTargetMaskDownSampleBuffer = new THREE.WebGLRenderTarget( resx, resy, pars ); + this.renderTargetMaskDownSampleBuffer.texture.name = "OutlinePass.depthDownSample"; + this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false; + + this.renderTargetBlurBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars ); + this.renderTargetBlurBuffer1.texture.name = "OutlinePass.blur1"; + this.renderTargetBlurBuffer1.texture.generateMipmaps = false; + this.renderTargetBlurBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars ); + this.renderTargetBlurBuffer2.texture.name = "OutlinePass.blur2"; + this.renderTargetBlurBuffer2.texture.generateMipmaps = false; + + this.edgeDetectionMaterial = this.getEdgeDetectionMaterial(); + this.renderTargetEdgeBuffer1 = new THREE.WebGLRenderTarget( resx, resy, pars ); + this.renderTargetEdgeBuffer1.texture.name = "OutlinePass.edge1"; + this.renderTargetEdgeBuffer1.texture.generateMipmaps = false; + this.renderTargetEdgeBuffer2 = new THREE.WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), pars ); + this.renderTargetEdgeBuffer2.texture.name = "OutlinePass.edge2"; + this.renderTargetEdgeBuffer2.texture.generateMipmaps = false; + + var MAX_EDGE_THICKNESS = 4; + var MAX_EDGE_GLOW = 4; + + this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS ); + this.separableBlurMaterial1.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy ); + this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = 1; + this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW ); + this.separableBlurMaterial2.uniforms[ "texSize" ].value = new THREE.Vector2( Math.round( resx / 2 ), Math.round( resy / 2 ) ); + this.separableBlurMaterial2.uniforms[ "kernelRadius" ].value = MAX_EDGE_GLOW; + + // Overlay material + this.overlayMaterial = this.getOverlayMaterial(); + + // copy material + if ( THREE.CopyShader === undefined ) + console.error( "THREE.OutlinePass relies on THREE.CopyShader" ); + + var copyShader = THREE.CopyShader; + + this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms[ "opacity" ].value = 1.0; + + this.materialCopy = new THREE.ShaderMaterial( { + uniforms: this.copyUniforms, + vertexShader: copyShader.vertexShader, + fragmentShader: copyShader.fragmentShader, + blending: THREE.NoBlending, + depthTest: false, + depthWrite: false, + transparent: true + } ); + + this.enabled = true; + this.needsSwap = false; + + this.oldClearColor = new THREE.Color(); + this.oldClearAlpha = 1; + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + + this.tempPulseColor1 = new THREE.Color(); + this.tempPulseColor2 = new THREE.Color(); + this.textureMatrix = new THREE.Matrix4(); + + function replaceDepthToViewZ( string, camera ) { + + var type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic'; + + return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' ); + + } + +}; + +THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.OutlinePass, + + dispose: function () { + + this.renderTargetMaskBuffer.dispose(); + this.renderTargetDepthBuffer.dispose(); + this.renderTargetMaskDownSampleBuffer.dispose(); + this.renderTargetBlurBuffer1.dispose(); + this.renderTargetBlurBuffer2.dispose(); + this.renderTargetEdgeBuffer1.dispose(); + this.renderTargetEdgeBuffer2.dispose(); + + }, + + setSize: function ( width, height ) { + + this.renderTargetMaskBuffer.setSize( width, height ); + + var resx = Math.round( width / this.downSampleRatio ); + var resy = Math.round( height / this.downSampleRatio ); + this.renderTargetMaskDownSampleBuffer.setSize( resx, resy ); + this.renderTargetBlurBuffer1.setSize( resx, resy ); + this.renderTargetEdgeBuffer1.setSize( resx, resy ); + this.separableBlurMaterial1.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy ); + + resx = Math.round( resx / 2 ); + resy = Math.round( resy / 2 ); + + this.renderTargetBlurBuffer2.setSize( resx, resy ); + this.renderTargetEdgeBuffer2.setSize( resx, resy ); + + this.separableBlurMaterial2.uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy ); + + }, + + changeVisibilityOfSelectedObjects: function ( bVisible ) { + + function gatherSelectedMeshesCallBack( object ) { + + if ( object.isMesh ) { + + if ( bVisible ) { + + object.visible = object.userData.oldVisible; + delete object.userData.oldVisible; + + } else { + + object.userData.oldVisible = object.visible; + object.visible = bVisible; + + } + + } + + } + + for ( var i = 0; i < this.selectedObjects.length; i ++ ) { + + var selectedObject = this.selectedObjects[ i ]; + selectedObject.traverse( gatherSelectedMeshesCallBack ); + + } + + }, + + changeVisibilityOfNonSelectedObjects: function ( bVisible ) { + + var selectedMeshes = []; + + function gatherSelectedMeshesCallBack( object ) { + + if ( object.isMesh ) selectedMeshes.push( object ); + + } + + for ( var i = 0; i < this.selectedObjects.length; i ++ ) { + + var selectedObject = this.selectedObjects[ i ]; + selectedObject.traverse( gatherSelectedMeshesCallBack ); + + } + + function VisibilityChangeCallBack( object ) { + + if ( object.isMesh || object.isLine || object.isSprite ) { + + var bFound = false; + + for ( var i = 0; i < selectedMeshes.length; i ++ ) { + + var selectedObjectId = selectedMeshes[ i ].id; + + if ( selectedObjectId === object.id ) { + + bFound = true; + break; + + } + + } + + if ( ! bFound ) { + + var visibility = object.visible; + + if ( ! bVisible || object.bVisible ) object.visible = bVisible; + + object.bVisible = visibility; + + } + + } + + } + + this.renderScene.traverse( VisibilityChangeCallBack ); + + }, + + updateTextureMatrix: function () { + + this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5, + 0.0, 0.5, 0.0, 0.5, + 0.0, 0.0, 0.5, 0.5, + 0.0, 0.0, 0.0, 1.0 ); + this.textureMatrix.multiply( this.renderCamera.projectionMatrix ); + this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse ); + + }, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + if ( this.selectedObjects.length > 0 ) { + + this.oldClearColor.copy( renderer.getClearColor() ); + this.oldClearAlpha = renderer.getClearAlpha(); + var oldAutoClear = renderer.autoClear; + + renderer.autoClear = false; + + if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST ); + + renderer.setClearColor( 0xffffff, 1 ); + + // Make selected objects invisible + this.changeVisibilityOfSelectedObjects( false ); + + var currentBackground = this.renderScene.background; + this.renderScene.background = null; + + // 1. Draw Non Selected objects in the depth buffer + this.renderScene.overrideMaterial = this.depthMaterial; + renderer.render( this.renderScene, this.renderCamera, this.renderTargetDepthBuffer, true ); + + // Make selected objects visible + this.changeVisibilityOfSelectedObjects( true ); + + // Update Texture Matrix for Depth compare + this.updateTextureMatrix(); + + // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects + this.changeVisibilityOfNonSelectedObjects( false ); + this.renderScene.overrideMaterial = this.prepareMaskMaterial; + this.prepareMaskMaterial.uniforms[ "cameraNearFar" ].value = new THREE.Vector2( this.renderCamera.near, this.renderCamera.far ); + this.prepareMaskMaterial.uniforms[ "depthTexture" ].value = this.renderTargetDepthBuffer.texture; + this.prepareMaskMaterial.uniforms[ "textureMatrix" ].value = this.textureMatrix; + renderer.render( this.renderScene, this.renderCamera, this.renderTargetMaskBuffer, true ); + this.renderScene.overrideMaterial = null; + this.changeVisibilityOfNonSelectedObjects( true ); + + this.renderScene.background = currentBackground; + + // 2. Downsample to Half resolution + this.quad.material = this.materialCopy; + this.copyUniforms[ "tDiffuse" ].value = this.renderTargetMaskBuffer.texture; + renderer.render( this.scene, this.camera, this.renderTargetMaskDownSampleBuffer, true ); + + this.tempPulseColor1.copy( this.visibleEdgeColor ); + this.tempPulseColor2.copy( this.hiddenEdgeColor ); + + if ( this.pulsePeriod > 0 ) { + + var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2; + this.tempPulseColor1.multiplyScalar( scalar ); + this.tempPulseColor2.multiplyScalar( scalar ); + + } + + // 3. Apply Edge Detection Pass + this.quad.material = this.edgeDetectionMaterial; + this.edgeDetectionMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskDownSampleBuffer.texture; + this.edgeDetectionMaterial.uniforms[ "texSize" ].value = new THREE.Vector2( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height ); + this.edgeDetectionMaterial.uniforms[ "visibleEdgeColor" ].value = this.tempPulseColor1; + this.edgeDetectionMaterial.uniforms[ "hiddenEdgeColor" ].value = this.tempPulseColor2; + renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer1, true ); + + // 4. Apply Blur on Half res + this.quad.material = this.separableBlurMaterial1; + this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture; + this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX; + this.separableBlurMaterial1.uniforms[ "kernelRadius" ].value = this.edgeThickness; + renderer.render( this.scene, this.camera, this.renderTargetBlurBuffer1, true ); + this.separableBlurMaterial1.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer1.texture; + this.separableBlurMaterial1.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY; + renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer1, true ); + + // Apply Blur on quarter res + this.quad.material = this.separableBlurMaterial2; + this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetEdgeBuffer1.texture; + this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionX; + renderer.render( this.scene, this.camera, this.renderTargetBlurBuffer2, true ); + this.separableBlurMaterial2.uniforms[ "colorTexture" ].value = this.renderTargetBlurBuffer2.texture; + this.separableBlurMaterial2.uniforms[ "direction" ].value = THREE.OutlinePass.BlurDirectionY; + renderer.render( this.scene, this.camera, this.renderTargetEdgeBuffer2, true ); + + // Blend it additively over the input texture + this.quad.material = this.overlayMaterial; + this.overlayMaterial.uniforms[ "maskTexture" ].value = this.renderTargetMaskBuffer.texture; + this.overlayMaterial.uniforms[ "edgeTexture1" ].value = this.renderTargetEdgeBuffer1.texture; + this.overlayMaterial.uniforms[ "edgeTexture2" ].value = this.renderTargetEdgeBuffer2.texture; + this.overlayMaterial.uniforms[ "patternTexture" ].value = this.patternTexture; + this.overlayMaterial.uniforms[ "edgeStrength" ].value = this.edgeStrength; + this.overlayMaterial.uniforms[ "edgeGlow" ].value = this.edgeGlow; + this.overlayMaterial.uniforms[ "usePatternTexture" ].value = this.usePatternTexture; + + + if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST ); + + renderer.render( this.scene, this.camera, readBuffer, false ); + + renderer.setClearColor( this.oldClearColor, this.oldClearAlpha ); + renderer.autoClear = oldAutoClear; + + } + + if ( this.renderToScreen ) { + + this.quad.material = this.materialCopy; + this.copyUniforms[ "tDiffuse" ].value = readBuffer.texture; + renderer.render( this.scene, this.camera ); + + } + + }, + + getPrepareMaskMaterial: function () { + + return new THREE.ShaderMaterial( { + + uniforms: { + "depthTexture": { value: null }, + "cameraNearFar": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "textureMatrix": { value: new THREE.Matrix4() } + }, + + vertexShader: [ + 'varying vec4 projTexCoord;', + 'varying vec4 vPosition;', + 'uniform mat4 textureMatrix;', + + 'void main() {', + + ' vPosition = modelViewMatrix * vec4( position, 1.0 );', + ' vec4 worldPosition = modelMatrix * vec4( position, 1.0 );', + ' projTexCoord = textureMatrix * worldPosition;', + ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', + + '}' + ].join( '\n' ), + + fragmentShader: [ + '#include ', + 'varying vec4 vPosition;', + 'varying vec4 projTexCoord;', + 'uniform sampler2D depthTexture;', + 'uniform vec2 cameraNearFar;', + + 'void main() {', + + ' float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));', + ' float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );', + ' float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;', + ' gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);', + + '}' + ].join( '\n' ) + + } ); + + }, + + getEdgeDetectionMaterial: function () { + + return new THREE.ShaderMaterial( { + + uniforms: { + "maskTexture": { value: null }, + "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "visibleEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) }, + "hiddenEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) }, + }, + + vertexShader: + "varying vec2 vUv;\n\ + void main() {\n\ + vUv = uv;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "varying vec2 vUv;\ + uniform sampler2D maskTexture;\ + uniform vec2 texSize;\ + uniform vec3 visibleEdgeColor;\ + uniform vec3 hiddenEdgeColor;\ + \ + void main() {\n\ + vec2 invSize = 1.0 / texSize;\ + vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\ + vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\ + vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\ + vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\ + vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\ + float diff1 = (c1.r - c2.r)*0.5;\ + float diff2 = (c3.r - c4.r)*0.5;\ + float d = length( vec2(diff1, diff2) );\ + float a1 = min(c1.g, c2.g);\ + float a2 = min(c3.g, c4.g);\ + float visibilityFactor = min(a1, a2);\ + vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\ + gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\ + }" + } ); + + }, + + getSeperableBlurMaterial: function ( maxRadius ) { + + return new THREE.ShaderMaterial( { + + defines: { + "MAX_RADIUS": maxRadius, + }, + + uniforms: { + "colorTexture": { value: null }, + "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "direction": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "kernelRadius": { value: 1.0 } + }, + + vertexShader: + "varying vec2 vUv;\n\ + void main() {\n\ + vUv = uv;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "#include \ + varying vec2 vUv;\ + uniform sampler2D colorTexture;\ + uniform vec2 texSize;\ + uniform vec2 direction;\ + uniform float kernelRadius;\ + \ + float gaussianPdf(in float x, in float sigma) {\ + return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\ + }\ + void main() {\ + vec2 invSize = 1.0 / texSize;\ + float weightSum = gaussianPdf(0.0, kernelRadius);\ + vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\ + vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\ + vec2 uvOffset = delta;\ + for( int i = 1; i <= MAX_RADIUS; i ++ ) {\ + float w = gaussianPdf(uvOffset.x, kernelRadius);\ + vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\ + vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\ + diffuseSum += ((sample1 + sample2) * w);\ + weightSum += (2.0 * w);\ + uvOffset += delta;\ + }\ + gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\ + }" + } ); + + }, + + getOverlayMaterial: function () { + + return new THREE.ShaderMaterial( { + + uniforms: { + "maskTexture": { value: null }, + "edgeTexture1": { value: null }, + "edgeTexture2": { value: null }, + "patternTexture": { value: null }, + "edgeStrength": { value: 1.0 }, + "edgeGlow": { value: 1.0 }, + "usePatternTexture": { value: 0.0 } + }, + + vertexShader: + "varying vec2 vUv;\n\ + void main() {\n\ + vUv = uv;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "varying vec2 vUv;\ + uniform sampler2D maskTexture;\ + uniform sampler2D edgeTexture1;\ + uniform sampler2D edgeTexture2;\ + uniform sampler2D patternTexture;\ + uniform float edgeStrength;\ + uniform float edgeGlow;\ + uniform bool usePatternTexture;\ + \ + void main() {\ + vec4 edgeValue1 = texture2D(edgeTexture1, vUv);\ + vec4 edgeValue2 = texture2D(edgeTexture2, vUv);\ + vec4 maskColor = texture2D(maskTexture, vUv);\ + vec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\ + float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\ + vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\ + vec4 finalColor = edgeStrength * maskColor.r * edgeValue;\ + if(usePatternTexture)\ + finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\ + gl_FragColor = finalColor;\ + }", + blending: THREE.AdditiveBlending, + depthTest: false, + depthWrite: false, + transparent: true + } ); + + } + +} ); + +THREE.OutlinePass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 ); +THREE.OutlinePass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 ); diff --git a/three/jsutil/postprocessing/RenderPass.js b/three/jsutil/postprocessing/RenderPass.js new file mode 100644 index 000000000..2711be7b5 --- /dev/null +++ b/three/jsutil/postprocessing/RenderPass.js @@ -0,0 +1,63 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) { + + THREE.Pass.call( this ); + + this.scene = scene; + this.camera = camera; + + this.overrideMaterial = overrideMaterial; + + this.clearColor = clearColor; + this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; + + this.clear = true; + this.clearDepth = false; + this.needsSwap = false; + +}; + +THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.RenderPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + var oldAutoClear = renderer.autoClear; + renderer.autoClear = false; + + this.scene.overrideMaterial = this.overrideMaterial; + + var oldClearColor, oldClearAlpha; + + if ( this.clearColor ) { + + oldClearColor = renderer.getClearColor().getHex(); + oldClearAlpha = renderer.getClearAlpha(); + + renderer.setClearColor( this.clearColor, this.clearAlpha ); + + } + + if ( this.clearDepth ) { + + renderer.clearDepth(); + + } + + renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); + + if ( this.clearColor ) { + + renderer.setClearColor( oldClearColor, oldClearAlpha ); + + } + + this.scene.overrideMaterial = null; + renderer.autoClear = oldAutoClear; + } + +} ); diff --git a/three/jsutil/postprocessing/SAOPass.js b/three/jsutil/postprocessing/SAOPass.js new file mode 100644 index 000000000..276504e97 --- /dev/null +++ b/three/jsutil/postprocessing/SAOPass.js @@ -0,0 +1,389 @@ +/** + * @author ludobaka / ludobaka.github.io + * SAO implementation inspired from bhouston previous SAO work + */ + +THREE.SAOPass = function ( scene, camera, depthTexture, useNormals, resolution ) { + + THREE.Pass.call( this ); + + this.scene = scene; + this.camera = camera; + + this.clear = true; + this.needsSwap = false; + + this.supportsDepthTextureExtension = ( depthTexture !== undefined ) ? depthTexture : false; + this.supportsNormalTexture = ( useNormals !== undefined ) ? useNormals : false; + + this.oldClearColor = new THREE.Color(); + this.oldClearAlpha = 1; + + this.params = { + output: 0, + saoBias: 0.5, + saoIntensity: 0.18, + saoScale: 1, + saoKernelRadius: 100, + saoMinResolution: 0, + saoBlur: true, + saoBlurRadius: 8, + saoBlurStdDev: 4, + saoBlurDepthCutoff: 0.01 + }; + + this.resolution = ( resolution !== undefined ) ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 ); + + this.saoRenderTarget = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBAFormat + } ); + this.blurIntermediateRenderTarget = this.saoRenderTarget.clone(); + this.beautyRenderTarget = this.saoRenderTarget.clone(); + + this.normalRenderTarget = new THREE.WebGLRenderTarget( this.resolution.x, this.resolution.y, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat + } ); + this.depthRenderTarget = this.normalRenderTarget.clone(); + + if ( this.supportsDepthTextureExtension ) { + + var depthTexture = new THREE.DepthTexture(); + depthTexture.type = THREE.UnsignedShortType; + depthTexture.minFilter = THREE.NearestFilter; + depthTexture.maxFilter = THREE.NearestFilter; + + this.beautyRenderTarget.depthTexture = depthTexture; + this.beautyRenderTarget.depthBuffer = true; + + } + + this.depthMaterial = new THREE.MeshDepthMaterial(); + this.depthMaterial.depthPacking = THREE.RGBADepthPacking; + this.depthMaterial.blending = THREE.NoBlending; + + this.normalMaterial = new THREE.MeshNormalMaterial(); + this.normalMaterial.blending = THREE.NoBlending; + + if ( THREE.SAOShader === undefined ) { + + console.error( 'THREE.SAOPass relies on THREE.SAOShader' ); + + } + + this.saoMaterial = new THREE.ShaderMaterial( { + defines: Object.assign( {}, THREE.SAOShader.defines ), + fragmentShader: THREE.SAOShader.fragmentShader, + vertexShader: THREE.SAOShader.vertexShader, + uniforms: THREE.UniformsUtils.clone( THREE.SAOShader.uniforms ) + } ); + this.saoMaterial.extensions.derivatives = true; + this.saoMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1; + this.saoMaterial.defines[ 'NORMAL_TEXTURE' ] = this.supportsNormalTexture ? 1 : 0; + this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0; + this.saoMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture; + this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture; + this.saoMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y ); + this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix; + this.saoMaterial.blending = THREE.NoBlending; + + if ( THREE.DepthLimitedBlurShader === undefined ) { + + console.error( 'THREE.SAOPass relies on THREE.DepthLimitedBlurShader' ); + + } + + this.vBlurMaterial = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.clone( THREE.DepthLimitedBlurShader.uniforms ), + defines: Object.assign( {}, THREE.DepthLimitedBlurShader.defines ), + vertexShader: THREE.DepthLimitedBlurShader.vertexShader, + fragmentShader: THREE.DepthLimitedBlurShader.fragmentShader + } ); + this.vBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1; + this.vBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0; + this.vBlurMaterial.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture; + this.vBlurMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture; + this.vBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y ); + this.vBlurMaterial.blending = THREE.NoBlending; + + this.hBlurMaterial = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.clone( THREE.DepthLimitedBlurShader.uniforms ), + defines: Object.assign( {}, THREE.DepthLimitedBlurShader.defines ), + vertexShader: THREE.DepthLimitedBlurShader.vertexShader, + fragmentShader: THREE.DepthLimitedBlurShader.fragmentShader + } ); + this.hBlurMaterial.defines[ 'DEPTH_PACKING' ] = this.supportsDepthTextureExtension ? 0 : 1; + this.hBlurMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0; + this.hBlurMaterial.uniforms[ 'tDiffuse' ].value = this.blurIntermediateRenderTarget.texture; + this.hBlurMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture; + this.hBlurMaterial.uniforms[ 'size' ].value.set( this.resolution.x, this.resolution.y ); + this.hBlurMaterial.blending = THREE.NoBlending; + + if ( THREE.CopyShader === undefined ) { + + console.error( 'THREE.SAOPass relies on THREE.CopyShader' ); + + } + + this.materialCopy = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.clone( THREE.CopyShader.uniforms ), + vertexShader: THREE.CopyShader.vertexShader, + fragmentShader: THREE.CopyShader.fragmentShader, + blending: THREE.NoBlending + } ); + this.materialCopy.transparent = true; + this.materialCopy.depthTest = false; + this.materialCopy.depthWrite = false; + this.materialCopy.blending = THREE.CustomBlending; + this.materialCopy.blendSrc = THREE.DstColorFactor; + this.materialCopy.blendDst = THREE.ZeroFactor; + this.materialCopy.blendEquation = THREE.AddEquation; + this.materialCopy.blendSrcAlpha = THREE.DstAlphaFactor; + this.materialCopy.blendDstAlpha = THREE.ZeroFactor; + this.materialCopy.blendEquationAlpha = THREE.AddEquation; + + if ( THREE.CopyShader === undefined ) { + + console.error( 'THREE.SAOPass relies on THREE.UnpackDepthRGBAShader' ); + + } + + this.depthCopy = new THREE.ShaderMaterial( { + uniforms: THREE.UniformsUtils.clone( THREE.UnpackDepthRGBAShader.uniforms ), + vertexShader: THREE.UnpackDepthRGBAShader.vertexShader, + fragmentShader: THREE.UnpackDepthRGBAShader.fragmentShader, + blending: THREE.NoBlending + } ); + + this.quadCamera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.quadScene = new THREE.Scene(); + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quadScene.add( this.quad ); + +}; + +THREE.SAOPass.OUTPUT = { + 'Beauty': 1, + 'Default': 0, + 'SAO': 2, + 'Depth': 3, + 'Normal': 4 +}; + +THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + constructor: THREE.SAOPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + // Rendering readBuffer first when rendering to screen + if ( this.renderToScreen ) { + + this.materialCopy.blending = THREE.NoBlending; + this.materialCopy.uniforms[ 'tDiffuse' ].value = readBuffer.texture; + this.materialCopy.needsUpdate = true; + this.renderPass( renderer, this.materialCopy, null ); + + } + + if ( this.params.output === 1 ) { + + return; + + } + + this.oldClearColor.copy( renderer.getClearColor() ); + this.oldClearAlpha = renderer.getClearAlpha(); + var oldAutoClear = renderer.autoClear; + renderer.autoClear = false; + + renderer.setRenderTarget( this.depthRenderTarget ); + renderer.clear(); + + this.saoMaterial.uniforms[ 'bias' ].value = this.params.saoBias; + this.saoMaterial.uniforms[ 'intensity' ].value = this.params.saoIntensity; + this.saoMaterial.uniforms[ 'scale' ].value = this.params.saoScale; + this.saoMaterial.uniforms[ 'kernelRadius' ].value = this.params.saoKernelRadius; + this.saoMaterial.uniforms[ 'minResolution' ].value = this.params.saoMinResolution; + this.saoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near; + this.saoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; + // this.saoMaterial.uniforms['randomSeed'].value = Math.random(); + + var depthCutoff = this.params.saoBlurDepthCutoff * ( this.camera.far - this.camera.near ); + this.vBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff; + this.hBlurMaterial.uniforms[ 'depthCutoff' ].value = depthCutoff; + + this.vBlurMaterial.uniforms[ 'cameraNear' ].value = this.camera.near; + this.vBlurMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; + this.hBlurMaterial.uniforms[ 'cameraNear' ].value = this.camera.near; + this.hBlurMaterial.uniforms[ 'cameraFar' ].value = this.camera.far; + + this.params.saoBlurRadius = Math.floor( this.params.saoBlurRadius ); + if ( ( this.prevStdDev !== this.params.saoBlurStdDev ) || ( this.prevNumSamples !== this.params.saoBlurRadius ) ) { + + THREE.BlurShaderUtils.configure( this.vBlurMaterial, this.params.saoBlurRadius, this.params.saoBlurStdDev, new THREE.Vector2( 0, 1 ) ); + THREE.BlurShaderUtils.configure( this.hBlurMaterial, this.params.saoBlurRadius, this.params.saoBlurStdDev, new THREE.Vector2( 1, 0 ) ); + this.prevStdDev = this.params.saoBlurStdDev; + this.prevNumSamples = this.params.saoBlurRadius; + + } + + // Rendering scene to depth texture + renderer.setClearColor( 0x000000 ); + renderer.render( this.scene, this.camera, this.beautyRenderTarget, true ); + + // Re-render scene if depth texture extension is not supported + if ( ! this.supportsDepthTextureExtension ) { + + // Clear rule : far clipping plane in both RGBA and Basic encoding + this.renderOverride( renderer, this.depthMaterial, this.depthRenderTarget, 0x000000, 1.0 ); + + } + + if ( this.supportsNormalTexture ) { + + // Clear rule : default normal is facing the camera + this.renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0x7777ff, 1.0 ); + + } + + // Rendering SAO texture + this.renderPass( renderer, this.saoMaterial, this.saoRenderTarget, 0xffffff, 1.0 ); + + // Blurring SAO texture + if ( this.params.saoBlur ) { + + this.renderPass( renderer, this.vBlurMaterial, this.blurIntermediateRenderTarget, 0xffffff, 1.0 ); + this.renderPass( renderer, this.hBlurMaterial, this.saoRenderTarget, 0xffffff, 1.0 ); + + } + + var outputMaterial = this.materialCopy; + // Setting up SAO rendering + if ( this.params.output === 3 ) { + + if ( this.supportsDepthTextureExtension ) { + + this.materialCopy.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.depthTexture; + this.materialCopy.needsUpdate = true; + + } else { + + this.depthCopy.uniforms[ 'tDiffuse' ].value = this.depthRenderTarget.texture; + this.depthCopy.needsUpdate = true; + outputMaterial = this.depthCopy; + + } + + } else if ( this.params.output === 4 ) { + + this.materialCopy.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture; + this.materialCopy.needsUpdate = true; + + } else { + + this.materialCopy.uniforms[ 'tDiffuse' ].value = this.saoRenderTarget.texture; + this.materialCopy.needsUpdate = true; + + } + + // Blending depends on output, only want a CustomBlending when showing SAO + if ( this.params.output === 0 ) { + + outputMaterial.blending = THREE.CustomBlending; + + } else { + + outputMaterial.blending = THREE.NoBlending; + + } + + // Rendering SAOPass result on top of previous pass + this.renderPass( renderer, outputMaterial, this.renderToScreen ? null : readBuffer ); + + renderer.setClearColor( this.oldClearColor, this.oldClearAlpha ); + renderer.autoClear = oldAutoClear; + + }, + + renderPass: function ( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) { + + // save original state + var originalClearColor = renderer.getClearColor(); + var originalClearAlpha = renderer.getClearAlpha(); + var originalAutoClear = renderer.autoClear; + + // setup pass state + renderer.autoClear = false; + var clearNeeded = ( clearColor !== undefined ) && ( clearColor !== null ); + if ( clearNeeded ) { + + renderer.setClearColor( clearColor ); + renderer.setClearAlpha( clearAlpha || 0.0 ); + + } + + this.quad.material = passMaterial; + renderer.render( this.quadScene, this.quadCamera, renderTarget, clearNeeded ); + + // restore original state + renderer.autoClear = originalAutoClear; + renderer.setClearColor( originalClearColor ); + renderer.setClearAlpha( originalClearAlpha ); + + }, + + renderOverride: function ( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) { + + var originalClearColor = renderer.getClearColor(); + var originalClearAlpha = renderer.getClearAlpha(); + var originalAutoClear = renderer.autoClear; + + renderer.autoClear = false; + + clearColor = overrideMaterial.clearColor || clearColor; + clearAlpha = overrideMaterial.clearAlpha || clearAlpha; + var clearNeeded = ( clearColor !== undefined ) && ( clearColor !== null ); + if ( clearNeeded ) { + + renderer.setClearColor( clearColor ); + renderer.setClearAlpha( clearAlpha || 0.0 ); + + } + + this.scene.overrideMaterial = overrideMaterial; + renderer.render( this.scene, this.camera, renderTarget, clearNeeded ); + this.scene.overrideMaterial = null; + + // restore original state + renderer.autoClear = originalAutoClear; + renderer.setClearColor( originalClearColor ); + renderer.setClearAlpha( originalClearAlpha ); + + }, + + setSize: function ( width, height ) { + + this.beautyRenderTarget.setSize( width, height ); + this.saoRenderTarget.setSize( width, height ); + this.blurIntermediateRenderTarget.setSize( width, height ); + this.normalRenderTarget.setSize( width, height ); + this.depthRenderTarget.setSize( width, height ); + + this.saoMaterial.uniforms[ 'size' ].value.set( width, height ); + this.saoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.getInverse( this.camera.projectionMatrix ); + this.saoMaterial.uniforms[ 'cameraProjectionMatrix' ].value = this.camera.projectionMatrix; + this.saoMaterial.needsUpdate = true; + + this.vBlurMaterial.uniforms[ 'size' ].value.set( width, height ); + this.vBlurMaterial.needsUpdate = true; + + this.hBlurMaterial.uniforms[ 'size' ].value.set( width, height ); + this.hBlurMaterial.needsUpdate = true; + + } + +} ); diff --git a/three/jsutil/postprocessing/SMAAPass.js b/three/jsutil/postprocessing/SMAAPass.js new file mode 100644 index 000000000..29d7f05de --- /dev/null +++ b/three/jsutil/postprocessing/SMAAPass.js @@ -0,0 +1,169 @@ +/** + * @author mpk / http://polko.me/ + */ + +THREE.SMAAPass = function ( width, height ) { + + THREE.Pass.call( this ); + + // render targets + + this.edgesRT = new THREE.WebGLRenderTarget( width, height, { + depthBuffer: false, + stencilBuffer: false, + generateMipmaps: false, + minFilter: THREE.LinearFilter, + format: THREE.RGBFormat + } ); + this.edgesRT.texture.name = "SMAAPass.edges"; + + this.weightsRT = new THREE.WebGLRenderTarget( width, height, { + depthBuffer: false, + stencilBuffer: false, + generateMipmaps: false, + minFilter: THREE.LinearFilter, + format: THREE.RGBAFormat + } ); + this.weightsRT.texture.name = "SMAAPass.weights"; + + // textures + + var areaTextureImage = new Image(); + areaTextureImage.src = this.getAreaTexture(); + + this.areaTexture = new THREE.Texture(); + this.areaTexture.name = "SMAAPass.area"; + this.areaTexture.image = areaTextureImage; + this.areaTexture.format = THREE.RGBFormat; + this.areaTexture.minFilter = THREE.LinearFilter; + this.areaTexture.generateMipmaps = false; + this.areaTexture.needsUpdate = true; + this.areaTexture.flipY = false; + + var searchTextureImage = new Image(); + searchTextureImage.src = this.getSearchTexture(); + + this.searchTexture = new THREE.Texture(); + this.searchTexture.name = "SMAAPass.search"; + this.searchTexture.image = searchTextureImage; + this.searchTexture.magFilter = THREE.NearestFilter; + this.searchTexture.minFilter = THREE.NearestFilter; + this.searchTexture.generateMipmaps = false; + this.searchTexture.needsUpdate = true; + this.searchTexture.flipY = false; + + // materials - pass 1 + + if ( THREE.SMAAShader === undefined ) { + console.error( "THREE.SMAAPass relies on THREE.SMAAShader" ); + } + + this.uniformsEdges = THREE.UniformsUtils.clone( THREE.SMAAShader[0].uniforms ); + + this.uniformsEdges[ "resolution" ].value.set( 1 / width, 1 / height ); + + this.materialEdges = new THREE.ShaderMaterial( { + defines: Object.assign( {}, THREE.SMAAShader[ 0 ].defines ), + uniforms: this.uniformsEdges, + vertexShader: THREE.SMAAShader[0].vertexShader, + fragmentShader: THREE.SMAAShader[0].fragmentShader + } ); + + // materials - pass 2 + + this.uniformsWeights = THREE.UniformsUtils.clone( THREE.SMAAShader[1].uniforms ); + + this.uniformsWeights[ "resolution" ].value.set( 1 / width, 1 / height ); + this.uniformsWeights[ "tDiffuse" ].value = this.edgesRT.texture; + this.uniformsWeights[ "tArea" ].value = this.areaTexture; + this.uniformsWeights[ "tSearch" ].value = this.searchTexture; + + this.materialWeights = new THREE.ShaderMaterial( { + defines: Object.assign( {}, THREE.SMAAShader[ 1 ].defines ), + uniforms: this.uniformsWeights, + vertexShader: THREE.SMAAShader[1].vertexShader, + fragmentShader: THREE.SMAAShader[1].fragmentShader + } ); + + // materials - pass 3 + + this.uniformsBlend = THREE.UniformsUtils.clone( THREE.SMAAShader[2].uniforms ); + + this.uniformsBlend[ "resolution" ].value.set( 1 / width, 1 / height ); + this.uniformsBlend[ "tDiffuse" ].value = this.weightsRT.texture; + + this.materialBlend = new THREE.ShaderMaterial( { + uniforms: this.uniformsBlend, + vertexShader: THREE.SMAAShader[2].vertexShader, + fragmentShader: THREE.SMAAShader[2].fragmentShader + } ); + + this.needsSwap = false; + + this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.SMAAPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.SMAAPass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + // pass 1 + + this.uniformsEdges[ "tDiffuse" ].value = readBuffer.texture; + + this.quad.material = this.materialEdges; + + renderer.render( this.scene, this.camera, this.edgesRT, this.clear ); + + // pass 2 + + this.quad.material = this.materialWeights; + + renderer.render( this.scene, this.camera, this.weightsRT, this.clear ); + + // pass 3 + + this.uniformsBlend[ "tColor" ].value = readBuffer.texture; + + this.quad.material = this.materialBlend; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + }, + + setSize: function ( width, height ) { + + this.edgesRT.setSize( width, height ); + this.weightsRT.setSize( width, height ); + + this.materialEdges.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height ); + this.materialWeights.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height ); + this.materialBlend.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height ); + + }, + + getAreaTexture: function () { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2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AAAASUVORK5CYII='; + }, + + getSearchTexture: function () { + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII='; + } + +} ); diff --git a/three/jsutil/postprocessing/SSAARenderPass.js b/three/jsutil/postprocessing/SSAARenderPass.js new file mode 100644 index 000000000..3088d58ab --- /dev/null +++ b/three/jsutil/postprocessing/SSAARenderPass.js @@ -0,0 +1,180 @@ +/** +* +* Supersample Anti-Aliasing Render Pass +* +* @author bhouston / http://clara.io/ +* +* This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results. +* +* References: https://en.wikipedia.org/wiki/Supersampling +* +*/ + +THREE.SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) { + + THREE.Pass.call( this ); + + this.scene = scene; + this.camera = camera; + + this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16. + this.unbiased = true; + + // as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black. + this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000; + this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; + + if ( THREE.CopyShader === undefined ) console.error( "THREE.SSAARenderPass relies on THREE.CopyShader" ); + + var copyShader = THREE.CopyShader; + this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + + this.copyMaterial = new THREE.ShaderMaterial( { + uniforms: this.copyUniforms, + vertexShader: copyShader.vertexShader, + fragmentShader: copyShader.fragmentShader, + premultipliedAlpha: true, + transparent: true, + blending: THREE.AdditiveBlending, + depthTest: false, + depthWrite: false + } ); + + this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene2 = new THREE.Scene(); + this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.copyMaterial ); + this.quad2.frustumCulled = false; // Avoid getting clipped + this.scene2.add( this.quad2 ); + +}; + +THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.SSAARenderPass, + + dispose: function () { + + if ( this.sampleRenderTarget ) { + + this.sampleRenderTarget.dispose(); + this.sampleRenderTarget = null; + + } + + }, + + setSize: function ( width, height ) { + + if ( this.sampleRenderTarget ) this.sampleRenderTarget.setSize( width, height ); + + }, + + render: function ( renderer, writeBuffer, readBuffer ) { + + if ( ! this.sampleRenderTarget ) { + + this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat } ); + this.sampleRenderTarget.texture.name = "SSAARenderPass.sample"; + + } + + var jitterOffsets = THREE.SSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ]; + + var autoClear = renderer.autoClear; + renderer.autoClear = false; + + var oldClearColor = renderer.getClearColor().getHex(); + var oldClearAlpha = renderer.getClearAlpha(); + + var baseSampleWeight = 1.0 / jitterOffsets.length; + var roundingRange = 1 / 32; + this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture; + + var width = readBuffer.width, height = readBuffer.height; + + // render the scene multiple times, each slightly jitter offset from the last and accumulate the results. + for ( var i = 0; i < jitterOffsets.length; i ++ ) { + + var jitterOffset = jitterOffsets[ i ]; + + if ( this.camera.setViewOffset ) { + + this.camera.setViewOffset( width, height, + jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16 + width, height ); + + } + + var sampleWeight = baseSampleWeight; + + if ( this.unbiased ) { + + // the theory is that equal weights for each sample lead to an accumulation of rounding errors. + // The following equation varies the sampleWeight per sample so that it is uniformly distributed + // across a range of values whose rounding errors cancel each other out. + + var uniformCenteredDistribution = ( - 0.5 + ( i + 0.5 ) / jitterOffsets.length ); + sampleWeight += roundingRange * uniformCenteredDistribution; + + } + + this.copyUniforms[ "opacity" ].value = sampleWeight; + renderer.setClearColor( this.clearColor, this.clearAlpha ); + renderer.render( this.scene, this.camera, this.sampleRenderTarget, true ); + + if ( i === 0 ) { + + renderer.setClearColor( 0x000000, 0.0 ); + + } + + renderer.render( this.scene2, this.camera2, this.renderToScreen ? null : writeBuffer, ( i === 0 ) ); + + } + + if ( this.camera.clearViewOffset ) this.camera.clearViewOffset(); + + renderer.autoClear = autoClear; + renderer.setClearColor( oldClearColor, oldClearAlpha ); + + } + +} ); + + +// These jitter vectors are specified in integers because it is easier. +// I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5) +// before being used, thus these integers need to be scaled by 1/16. +// +// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 +THREE.SSAARenderPass.JitterVectors = [ + [ + [ 0, 0 ] + ], + [ + [ 4, 4 ], [ - 4, - 4 ] + ], + [ + [ - 2, - 6 ], [ 6, - 2 ], [ - 6, 2 ], [ 2, 6 ] + ], + [ + [ 1, - 3 ], [ - 1, 3 ], [ 5, 1 ], [ - 3, - 5 ], + [ - 5, 5 ], [ - 7, - 1 ], [ 3, 7 ], [ 7, - 7 ] + ], + [ + [ 1, 1 ], [ - 1, - 3 ], [ - 3, 2 ], [ 4, - 1 ], + [ - 5, - 2 ], [ 2, 5 ], [ 5, 3 ], [ 3, - 5 ], + [ - 2, 6 ], [ 0, - 7 ], [ - 4, - 6 ], [ - 6, 4 ], + [ - 8, 0 ], [ 7, - 4 ], [ 6, 7 ], [ - 7, - 8 ] + ], + [ + [ - 4, - 7 ], [ - 7, - 5 ], [ - 3, - 5 ], [ - 5, - 4 ], + [ - 1, - 4 ], [ - 2, - 2 ], [ - 6, - 1 ], [ - 4, 0 ], + [ - 7, 1 ], [ - 1, 2 ], [ - 6, 3 ], [ - 3, 3 ], + [ - 7, 6 ], [ - 3, 6 ], [ - 5, 7 ], [ - 1, 7 ], + [ 5, - 7 ], [ 1, - 6 ], [ 6, - 5 ], [ 4, - 4 ], + [ 2, - 3 ], [ 7, - 2 ], [ 1, - 1 ], [ 4, - 1 ], + [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ], + [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ] + ] +]; diff --git a/three/jsutil/postprocessing/SSAOPass.js b/three/jsutil/postprocessing/SSAOPass.js new file mode 100644 index 000000000..e815f3f84 --- /dev/null +++ b/three/jsutil/postprocessing/SSAOPass.js @@ -0,0 +1,190 @@ +'use strict'; + +/** + * Screen-space ambient occlusion pass. + * + * Has the following parameters + * - radius + * - Ambient occlusion shadow radius (numeric value). + * - onlyAO + * - Display only ambient occlusion result (boolean value). + * - aoClamp + * - Ambient occlusion clamp (numeric value). + * - lumInfluence + * - Pixel luminosity influence in AO calculation (numeric value). + * + * To output to screen set renderToScreens true + * + * @author alteredq / http://alteredqualia.com/ + * @author tentone + * @class SSAOPass + */ +THREE.SSAOPass = function ( scene, camera, width, height ) { + + if ( THREE.SSAOShader === undefined ) { + + console.warn( 'THREE.SSAOPass depends on THREE.SSAOShader' ); + return new THREE.ShaderPass(); + + } + + THREE.ShaderPass.call( this, THREE.SSAOShader ); + + this.width = ( width !== undefined ) ? width : 512; + this.height = ( height !== undefined ) ? height : 256; + + this.renderToScreen = false; + + this.camera2 = camera; + this.scene2 = scene; + + //Depth material + this.depthMaterial = new THREE.MeshDepthMaterial(); + this.depthMaterial.depthPacking = THREE.RGBADepthPacking; + this.depthMaterial.blending = THREE.NoBlending; + + //Depth render target + this.depthRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter } ); + //this.depthRenderTarget.texture.name = 'SSAOShader.rt'; + + //Shader uniforms + this.uniforms[ 'tDepth' ].value = this.depthRenderTarget.texture; + this.uniforms[ 'size' ].value.set( this.width, this.height ); + this.uniforms[ 'cameraNear' ].value = this.camera2.near; + this.uniforms[ 'cameraFar' ].value = this.camera2.far; + + this.uniforms[ 'radius' ].value = 4; + this.uniforms[ 'onlyAO' ].value = false; + this.uniforms[ 'aoClamp' ].value = 0.25; + this.uniforms[ 'lumInfluence' ].value = 0.7; + + //Setters and getters for uniforms + + Object.defineProperties( this, { + + radius: { + get: function () { + + return this.uniforms[ 'radius' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'radius' ].value = value; + + } + }, + + onlyAO: { + get: function () { + + return this.uniforms[ 'onlyAO' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'onlyAO' ].value = value; + + } + }, + + aoClamp: { + get: function () { + + return this.uniforms[ 'aoClamp' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'aoClamp' ].value = value; + + } + }, + + lumInfluence: { + get: function () { + + return this.uniforms[ 'lumInfluence' ].value; + + }, + set: function ( value ) { + + this.uniforms[ 'lumInfluence' ].value = value; + + } + }, + + } ); + +}; + +THREE.SSAOPass.prototype = Object.create( THREE.ShaderPass.prototype ); + +/** + * Render using this pass. + * + * @method render + * @param {WebGLRenderer} renderer + * @param {WebGLRenderTarget} writeBuffer Buffer to write output. + * @param {WebGLRenderTarget} readBuffer Input buffer. + * @param {Number} delta Delta time in milliseconds. + * @param {Boolean} maskActive Not used in this pass. + */ +THREE.SSAOPass.prototype.render = function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + //Render depth into depthRenderTarget + this.scene2.overrideMaterial = this.depthMaterial; + + renderer.render( this.scene2, this.camera2, this.depthRenderTarget, true ); + + this.scene2.overrideMaterial = null; + + + //SSAO shaderPass + THREE.ShaderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, delta, maskActive ); + +}; + +/** + * Change scene to be renderer by this render pass. + * + * @method setScene + * @param {Scene} scene + */ +THREE.SSAOPass.prototype.setScene = function ( scene ) { + + this.scene2 = scene; + +}; + +/** + * Set camera used by this render pass. + * + * @method setCamera + * @param {Camera} camera + */ +THREE.SSAOPass.prototype.setCamera = function ( camera ) { + + this.camera2 = camera; + + this.uniforms[ 'cameraNear' ].value = this.camera2.near; + this.uniforms[ 'cameraFar' ].value = this.camera2.far; + +}; + +/** + * Set resolution of this render pass. + * + * @method setSize + * @param {Number} width + * @param {Number} height + */ +THREE.SSAOPass.prototype.setSize = function ( width, height ) { + + this.width = width; + this.height = height; + + this.uniforms[ 'size' ].value.set( this.width, this.height ); + this.depthRenderTarget.setSize( this.width, this.height ); + +}; diff --git a/three/jsutil/postprocessing/SavePass.js b/three/jsutil/postprocessing/SavePass.js new file mode 100644 index 000000000..fd0992e9b --- /dev/null +++ b/three/jsutil/postprocessing/SavePass.js @@ -0,0 +1,64 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.SavePass = function ( renderTarget ) { + + THREE.Pass.call( this ); + + if ( THREE.CopyShader === undefined ) + console.error( "THREE.SavePass relies on THREE.CopyShader" ); + + var shader = THREE.CopyShader; + + this.textureID = "tDiffuse"; + + this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + this.material = new THREE.ShaderMaterial( { + + uniforms: this.uniforms, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + + } ); + + this.renderTarget = renderTarget; + + if ( this.renderTarget === undefined ) { + + this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false } ); + this.renderTarget.texture.name = "SavePass.rt"; + + } + + this.needsSwap = false; + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.SavePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.SavePass, + + render: function ( renderer, writeBuffer, readBuffer ) { + + if ( this.uniforms[ this.textureID ] ) { + + this.uniforms[ this.textureID ].value = readBuffer.texture; + + } + + this.quad.material = this.material; + + renderer.render( this.scene, this.camera, this.renderTarget, this.clear ); + + } + +} ); diff --git a/three/jsutil/postprocessing/ShaderPass.js b/three/jsutil/postprocessing/ShaderPass.js new file mode 100644 index 000000000..b244a0fa5 --- /dev/null +++ b/three/jsutil/postprocessing/ShaderPass.js @@ -0,0 +1,67 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.ShaderPass = function ( shader, textureID ) { + + THREE.Pass.call( this ); + + this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse"; + + if ( shader instanceof THREE.ShaderMaterial ) { + + this.uniforms = shader.uniforms; + + this.material = shader; + + } else if ( shader ) { + + this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + this.material = new THREE.ShaderMaterial( { + + defines: Object.assign( {}, shader.defines ), + uniforms: this.uniforms, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + + } ); + + } + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.ShaderPass, + + render: function( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + if ( this.uniforms[ this.textureID ] ) { + + this.uniforms[ this.textureID ].value = readBuffer.texture; + + } + + this.quad.material = this.material; + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera ); + + } else { + + renderer.render( this.scene, this.camera, writeBuffer, this.clear ); + + } + + } + +} ); diff --git a/three/jsutil/postprocessing/TAARenderPass.js b/three/jsutil/postprocessing/TAARenderPass.js new file mode 100644 index 000000000..58f1fb3d6 --- /dev/null +++ b/three/jsutil/postprocessing/TAARenderPass.js @@ -0,0 +1,131 @@ +/** + * + * Temporal Anti-Aliasing Render Pass + * + * @author bhouston / http://clara.io/ + * + * When there is no motion in the scene, the TAA render pass accumulates jittered camera samples across frames to create a high quality anti-aliased result. + * + * References: + * + * TODO: Add support for motion vector pas so that accumulation of samples across frames can occur on dynamics scenes. + * + */ + +THREE.TAARenderPass = function ( scene, camera, params ) { + + if ( THREE.SSAARenderPass === undefined ) { + + console.error( "THREE.TAARenderPass relies on THREE.SSAARenderPass" ); + + } + + THREE.SSAARenderPass.call( this, scene, camera, params ); + + this.sampleLevel = 0; + this.accumulate = false; + +}; + +THREE.TAARenderPass.JitterVectors = THREE.SSAARenderPass.JitterVectors; + +THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPass.prototype ), { + + constructor: THREE.TAARenderPass, + + render: function ( renderer, writeBuffer, readBuffer, delta ) { + + if ( ! this.accumulate ) { + + THREE.SSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, delta ); + + this.accumulateIndex = - 1; + return; + + } + + var jitterOffsets = THREE.TAARenderPass.JitterVectors[ 5 ]; + + if ( ! this.sampleRenderTarget ) { + + this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params ); + this.sampleRenderTarget.texture.name = "TAARenderPass.sample"; + + } + + if ( ! this.holdRenderTarget ) { + + this.holdRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params ); + this.holdRenderTarget.texture.name = "TAARenderPass.hold"; + + } + + if ( this.accumulate && this.accumulateIndex === - 1 ) { + + THREE.SSAARenderPass.prototype.render.call( this, renderer, this.holdRenderTarget, readBuffer, delta ); + + this.accumulateIndex = 0; + + } + + var autoClear = renderer.autoClear; + renderer.autoClear = false; + + var sampleWeight = 1.0 / ( jitterOffsets.length ); + + if ( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) { + + this.copyUniforms[ "opacity" ].value = sampleWeight; + this.copyUniforms[ "tDiffuse" ].value = writeBuffer.texture; + + // render the scene multiple times, each slightly jitter offset from the last and accumulate the results. + var numSamplesPerFrame = Math.pow( 2, this.sampleLevel ); + for ( var i = 0; i < numSamplesPerFrame; i ++ ) { + + var j = this.accumulateIndex; + var jitterOffset = jitterOffsets[ j ]; + + if ( this.camera.setViewOffset ) { + + this.camera.setViewOffset( readBuffer.width, readBuffer.height, + jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16 + readBuffer.width, readBuffer.height ); + + } + + renderer.render( this.scene, this.camera, writeBuffer, true ); + renderer.render( this.scene2, this.camera2, this.sampleRenderTarget, ( this.accumulateIndex === 0 ) ); + + this.accumulateIndex ++; + + if ( this.accumulateIndex >= jitterOffsets.length ) break; + + } + + if ( this.camera.clearViewOffset ) this.camera.clearViewOffset(); + + } + + var accumulationWeight = this.accumulateIndex * sampleWeight; + + if ( accumulationWeight > 0 ) { + + this.copyUniforms[ "opacity" ].value = 1.0; + this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture; + renderer.render( this.scene2, this.camera2, writeBuffer, true ); + + } + + if ( accumulationWeight < 1.0 ) { + + this.copyUniforms[ "opacity" ].value = 1.0 - accumulationWeight; + this.copyUniforms[ "tDiffuse" ].value = this.holdRenderTarget.texture; + renderer.render( this.scene2, this.camera2, writeBuffer, ( accumulationWeight === 0 ) ); + + } + + renderer.autoClear = autoClear; + + } + +} ); diff --git a/three/jsutil/postprocessing/TexturePass.js b/three/jsutil/postprocessing/TexturePass.js new file mode 100644 index 000000000..f924ba630 --- /dev/null +++ b/three/jsutil/postprocessing/TexturePass.js @@ -0,0 +1,60 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.TexturePass = function ( map, opacity ) { + + THREE.Pass.call( this ); + + if ( THREE.CopyShader === undefined ) + console.error( "THREE.TexturePass relies on THREE.CopyShader" ); + + var shader = THREE.CopyShader; + + this.map = map; + this.opacity = ( opacity !== undefined ) ? opacity : 1.0; + + this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + + this.material = new THREE.ShaderMaterial( { + + uniforms: this.uniforms, + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + depthTest: false, + depthWrite: false + + } ); + + this.needsSwap = false; + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.TexturePass, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + var oldAutoClear = renderer.autoClear; + renderer.autoClear = false; + + this.quad.material = this.material; + + this.uniforms[ "opacity" ].value = this.opacity; + this.uniforms[ "tDiffuse" ].value = this.map; + this.material.transparent = ( this.opacity < 1.0 ); + + renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); + + renderer.autoClear = oldAutoClear; + } + +} ); diff --git a/three/jsutil/postprocessing/UnrealBloomPass.js b/three/jsutil/postprocessing/UnrealBloomPass.js new file mode 100644 index 000000000..b24e7225b --- /dev/null +++ b/three/jsutil/postprocessing/UnrealBloomPass.js @@ -0,0 +1,384 @@ +/** + * @author spidersharma / http://eduperiment.com/ + * + * Inspired from Unreal Engine + * https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/ + */ +THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) { + + THREE.Pass.call( this ); + + this.strength = ( strength !== undefined ) ? strength : 1; + this.radius = radius; + this.threshold = threshold; + this.resolution = ( resolution !== undefined ) ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 ); + + // create color only once here, reuse it later inside the render function + this.clearColor = new THREE.Color( 0, 0, 0 ); + + // render targets + var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat }; + this.renderTargetsHorizontal = []; + this.renderTargetsVertical = []; + this.nMips = 5; + var resx = Math.round( this.resolution.x / 2 ); + var resy = Math.round( this.resolution.y / 2 ); + + this.renderTargetBright = new THREE.WebGLRenderTarget( resx, resy, pars ); + this.renderTargetBright.texture.name = "UnrealBloomPass.bright"; + this.renderTargetBright.texture.generateMipmaps = false; + + for ( var i = 0; i < this.nMips; i ++ ) { + + var renderTarget = new THREE.WebGLRenderTarget( resx, resy, pars ); + + renderTarget.texture.name = "UnrealBloomPass.h" + i; + renderTarget.texture.generateMipmaps = false; + + this.renderTargetsHorizontal.push( renderTarget ); + + var renderTarget = new THREE.WebGLRenderTarget( resx, resy, pars ); + + renderTarget.texture.name = "UnrealBloomPass.v" + i; + renderTarget.texture.generateMipmaps = false; + + this.renderTargetsVertical.push( renderTarget ); + + resx = Math.round( resx / 2 ); + + resy = Math.round( resy / 2 ); + + } + + // luminosity high pass material + + if ( THREE.LuminosityHighPassShader === undefined ) + console.error( "THREE.UnrealBloomPass relies on THREE.LuminosityHighPassShader" ); + + var highPassShader = THREE.LuminosityHighPassShader; + this.highPassUniforms = THREE.UniformsUtils.clone( highPassShader.uniforms ); + + this.highPassUniforms[ "luminosityThreshold" ].value = threshold; + this.highPassUniforms[ "smoothWidth" ].value = 0.01; + + this.materialHighPassFilter = new THREE.ShaderMaterial( { + uniforms: this.highPassUniforms, + vertexShader: highPassShader.vertexShader, + fragmentShader: highPassShader.fragmentShader, + defines: {} + } ); + + // Gaussian Blur Materials + this.separableBlurMaterials = []; + var kernelSizeArray = [ 3, 5, 7, 9, 11 ]; + var resx = Math.round( this.resolution.x / 2 ); + var resy = Math.round( this.resolution.y / 2 ); + + for ( var i = 0; i < this.nMips; i ++ ) { + + this.separableBlurMaterials.push( this.getSeperableBlurMaterial( kernelSizeArray[ i ] ) ); + + this.separableBlurMaterials[ i ].uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy ); + + resx = Math.round( resx / 2 ); + + resy = Math.round( resy / 2 ); + + } + + // Composite material + this.compositeMaterial = this.getCompositeMaterial( this.nMips ); + this.compositeMaterial.uniforms[ "blurTexture1" ].value = this.renderTargetsVertical[ 0 ].texture; + this.compositeMaterial.uniforms[ "blurTexture2" ].value = this.renderTargetsVertical[ 1 ].texture; + this.compositeMaterial.uniforms[ "blurTexture3" ].value = this.renderTargetsVertical[ 2 ].texture; + this.compositeMaterial.uniforms[ "blurTexture4" ].value = this.renderTargetsVertical[ 3 ].texture; + this.compositeMaterial.uniforms[ "blurTexture5" ].value = this.renderTargetsVertical[ 4 ].texture; + this.compositeMaterial.uniforms[ "bloomStrength" ].value = strength; + this.compositeMaterial.uniforms[ "bloomRadius" ].value = 0.1; + this.compositeMaterial.needsUpdate = true; + + var bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ]; + this.compositeMaterial.uniforms[ "bloomFactors" ].value = bloomFactors; + this.bloomTintColors = [ new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), + new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ) ]; + this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors; + + // copy material + if ( THREE.CopyShader === undefined ) { + + console.error( "THREE.BloomPass relies on THREE.CopyShader" ); + + } + + var copyShader = THREE.CopyShader; + + this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms[ "opacity" ].value = 1.0; + + this.materialCopy = new THREE.ShaderMaterial( { + uniforms: this.copyUniforms, + vertexShader: copyShader.vertexShader, + fragmentShader: copyShader.fragmentShader, + blending: THREE.AdditiveBlending, + depthTest: false, + depthWrite: false, + transparent: true + } ); + + this.enabled = true; + this.needsSwap = false; + + this.oldClearColor = new THREE.Color(); + this.oldClearAlpha = 1; + + this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + this.scene = new THREE.Scene(); + + this.basic = new THREE.MeshBasicMaterial(); + + this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); + this.quad.frustumCulled = false; // Avoid getting clipped + this.scene.add( this.quad ); + +}; + +THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { + + constructor: THREE.UnrealBloomPass, + + dispose: function () { + + for ( var i = 0; i < this.renderTargetsHorizontal.length; i ++ ) { + + this.renderTargetsHorizontal[ i ].dispose(); + + } + + for ( var i = 0; i < this.renderTargetsVertical.length; i ++ ) { + + this.renderTargetsVertical[ i ].dispose(); + + } + + this.renderTargetBright.dispose(); + + }, + + setSize: function ( width, height ) { + + var resx = Math.round( width / 2 ); + var resy = Math.round( height / 2 ); + + this.renderTargetBright.setSize( resx, resy ); + + for ( var i = 0; i < this.nMips; i ++ ) { + + this.renderTargetsHorizontal[ i ].setSize( resx, resy ); + this.renderTargetsVertical[ i ].setSize( resx, resy ); + + this.separableBlurMaterials[ i ].uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy ); + + resx = Math.round( resx / 2 ); + resy = Math.round( resy / 2 ); + + } + + }, + + render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { + + this.oldClearColor.copy( renderer.getClearColor() ); + this.oldClearAlpha = renderer.getClearAlpha(); + var oldAutoClear = renderer.autoClear; + renderer.autoClear = false; + + renderer.setClearColor( this.clearColor, 0 ); + + if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST ); + + // Render input to screen + + if ( this.renderToScreen ) { + + this.quad.material = this.basic; + this.basic.map = readBuffer.texture; + + renderer.render( this.scene, this.camera, undefined, true ); + + } + + // 1. Extract Bright Areas + + this.highPassUniforms[ "tDiffuse" ].value = readBuffer.texture; + this.highPassUniforms[ "luminosityThreshold" ].value = this.threshold; + this.quad.material = this.materialHighPassFilter; + + renderer.render( this.scene, this.camera, this.renderTargetBright, true ); + + // 2. Blur All the mips progressively + + var inputRenderTarget = this.renderTargetBright; + + for ( var i = 0; i < this.nMips; i ++ ) { + + this.quad.material = this.separableBlurMaterials[ i ]; + + this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = inputRenderTarget.texture; + this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionX; + renderer.render( this.scene, this.camera, this.renderTargetsHorizontal[ i ], true ); + + this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = this.renderTargetsHorizontal[ i ].texture; + this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionY; + renderer.render( this.scene, this.camera, this.renderTargetsVertical[ i ], true ); + + inputRenderTarget = this.renderTargetsVertical[ i ]; + + } + + // Composite All the mips + + this.quad.material = this.compositeMaterial; + this.compositeMaterial.uniforms[ "bloomStrength" ].value = this.strength; + this.compositeMaterial.uniforms[ "bloomRadius" ].value = this.radius; + this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors; + + renderer.render( this.scene, this.camera, this.renderTargetsHorizontal[ 0 ], true ); + + // Blend it additively over the input texture + + this.quad.material = this.materialCopy; + this.copyUniforms[ "tDiffuse" ].value = this.renderTargetsHorizontal[ 0 ].texture; + + if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST ); + + + if ( this.renderToScreen ) { + + renderer.render( this.scene, this.camera, undefined, false ); + + } else { + + renderer.render( this.scene, this.camera, readBuffer, false ); + + } + + // Restore renderer settings + + renderer.setClearColor( this.oldClearColor, this.oldClearAlpha ); + renderer.autoClear = oldAutoClear; + + }, + + getSeperableBlurMaterial: function ( kernelRadius ) { + + return new THREE.ShaderMaterial( { + + defines: { + "KERNEL_RADIUS": kernelRadius, + "SIGMA": kernelRadius + }, + + uniforms: { + "colorTexture": { value: null }, + "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "direction": { value: new THREE.Vector2( 0.5, 0.5 ) } + }, + + vertexShader: + "varying vec2 vUv;\n\ + void main() {\n\ + vUv = uv;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "#include \ + varying vec2 vUv;\n\ + uniform sampler2D colorTexture;\n\ + uniform vec2 texSize;\ + uniform vec2 direction;\ + \ + float gaussianPdf(in float x, in float sigma) {\ + return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\ + }\ + void main() {\n\ + vec2 invSize = 1.0 / texSize;\ + float fSigma = float(SIGMA);\ + float weightSum = gaussianPdf(0.0, fSigma);\ + vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\ + for( int i = 1; i < KERNEL_RADIUS; i ++ ) {\ + float x = float(i);\ + float w = gaussianPdf(x, fSigma);\ + vec2 uvOffset = direction * invSize * x;\ + vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\ + vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\ + diffuseSum += (sample1 + sample2) * w;\ + weightSum += 2.0 * w;\ + }\ + gl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\ + }" + } ); + + }, + + getCompositeMaterial: function ( nMips ) { + + return new THREE.ShaderMaterial( { + + defines: { + "NUM_MIPS": nMips + }, + + uniforms: { + "blurTexture1": { value: null }, + "blurTexture2": { value: null }, + "blurTexture3": { value: null }, + "blurTexture4": { value: null }, + "blurTexture5": { value: null }, + "dirtTexture": { value: null }, + "bloomStrength": { value: 1.0 }, + "bloomFactors": { value: null }, + "bloomTintColors": { value: null }, + "bloomRadius": { value: 0.0 } + }, + + vertexShader: + "varying vec2 vUv;\n\ + void main() {\n\ + vUv = uv;\n\ + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\ + }", + + fragmentShader: + "varying vec2 vUv;\ + uniform sampler2D blurTexture1;\ + uniform sampler2D blurTexture2;\ + uniform sampler2D blurTexture3;\ + uniform sampler2D blurTexture4;\ + uniform sampler2D blurTexture5;\ + uniform sampler2D dirtTexture;\ + uniform float bloomStrength;\ + uniform float bloomRadius;\ + uniform float bloomFactors[NUM_MIPS];\ + uniform vec3 bloomTintColors[NUM_MIPS];\ + \ + float lerpBloomFactor(const in float factor) { \ + float mirrorFactor = 1.2 - factor;\ + return mix(factor, mirrorFactor, bloomRadius);\ + }\ + \ + void main() {\ + gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \ + lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \ + lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \ + lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \ + lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\ + }" + } ); + + } + +} ); + +THREE.UnrealBloomPass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 ); +THREE.UnrealBloomPass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 ); diff --git a/three/jsutil/renderers/CSS2DRenderer.js b/three/jsutil/renderers/CSS2DRenderer.js new file mode 100644 index 000000000..7d45e232c --- /dev/null +++ b/three/jsutil/renderers/CSS2DRenderer.js @@ -0,0 +1,173 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.CSS2DObject = function ( element ) { + + THREE.Object3D.call( this ); + + this.element = element; + this.element.style.position = 'absolute'; + + this.addEventListener( 'removed', function ( event ) { + + if ( this.element.parentNode !== null ) { + + this.element.parentNode.removeChild( this.element ); + + } + + } ); + +}; + +THREE.CSS2DObject.prototype = Object.create( THREE.Object3D.prototype ); +THREE.CSS2DObject.prototype.constructor = THREE.CSS2DObject; + +// + +THREE.CSS2DRenderer = function () { + + console.log( 'THREE.CSS2DRenderer', THREE.REVISION ); + + var _width, _height; + var _widthHalf, _heightHalf; + + var vector = new THREE.Vector3(); + var viewMatrix = new THREE.Matrix4(); + var viewProjectionMatrix = new THREE.Matrix4(); + + var cache = { + objects: new WeakMap() + }; + + var domElement = document.createElement( 'div' ); + domElement.style.overflow = 'hidden'; + + this.domElement = domElement; + + this.getSize = function () { + + return { + width: _width, + height: _height + }; + + }; + + this.setSize = function ( width, height ) { + + _width = width; + _height = height; + + _widthHalf = _width / 2; + _heightHalf = _height / 2; + + domElement.style.width = width + 'px'; + domElement.style.height = height + 'px'; + + }; + + var renderObject = function ( object, camera ) { + + if ( object instanceof THREE.CSS2DObject ) { + + vector.setFromMatrixPosition( object.matrixWorld ); + vector.applyMatrix4( viewProjectionMatrix ); + + var element = object.element; + var style = 'translate(-50%,-50%) translate(' + ( vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - vector.y * _heightHalf + _heightHalf ) + 'px)'; + + element.style.WebkitTransform = style; + element.style.MozTransform = style; + element.style.oTransform = style; + element.style.transform = style; + + var objectData = { + distanceToCameraSquared: getDistanceToSquared( camera, object ) + }; + + cache.objects.set( object, objectData ); + + if ( element.parentNode !== domElement ) { + + domElement.appendChild( element ); + + } + + } + + for ( var i = 0, l = object.children.length; i < l; i ++ ) { + + renderObject( object.children[ i ], camera ); + + } + + }; + + var getDistanceToSquared = function () { + + var a = new THREE.Vector3(); + var b = new THREE.Vector3(); + + return function ( object1, object2 ) { + + a.setFromMatrixPosition( object1.matrixWorld ); + b.setFromMatrixPosition( object2.matrixWorld ); + + return a.distanceToSquared( b ); + + }; + + }(); + + var filterAndFlatten = function ( scene ) { + + var result = []; + + scene.traverse( function ( object ) { + + if ( object instanceof THREE.CSS2DObject ) result.push( object ); + + } ); + + return result; + + }; + + var zOrder = function ( scene ) { + + var sorted = filterAndFlatten( scene ).sort( function ( a, b ) { + + var distanceA = cache.objects.get( a ).distanceToCameraSquared; + var distanceB = cache.objects.get( b ).distanceToCameraSquared; + + return distanceA - distanceB; + + } ); + + var zMax = sorted.length; + + for ( var i = 0, l = sorted.length; i < l; i ++ ) { + + sorted[ i ].element.style.zIndex = zMax - i; + + } + + }; + + this.render = function ( scene, camera ) { + + scene.updateMatrixWorld(); + + if ( camera.parent === null ) camera.updateMatrixWorld(); + + viewMatrix.copy( camera.matrixWorldInverse ); + viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, viewMatrix ); + + renderObject( scene, camera ); + zOrder( scene ); + + }; + +}; diff --git a/three/jsutil/renderers/CSS3DRenderer.js b/three/jsutil/renderers/CSS3DRenderer.js new file mode 100644 index 000000000..17b764f3d --- /dev/null +++ b/three/jsutil/renderers/CSS3DRenderer.js @@ -0,0 +1,324 @@ +/** + * Based on http://www.emagix.net/academic/mscs-project/item/camera-sync-with-css3-and-webgl-threejs + * @author mrdoob / http://mrdoob.com/ + * @author yomotsu / https://yomotsu.net/ + */ + +THREE.CSS3DObject = function ( element ) { + + THREE.Object3D.call( this ); + + this.element = element; + this.element.style.position = 'absolute'; + + this.addEventListener( 'removed', function () { + + if ( this.element.parentNode !== null ) { + + this.element.parentNode.removeChild( this.element ); + + } + + } ); + +}; + +THREE.CSS3DObject.prototype = Object.create( THREE.Object3D.prototype ); +THREE.CSS3DObject.prototype.constructor = THREE.CSS3DObject; + +THREE.CSS3DSprite = function ( element ) { + + THREE.CSS3DObject.call( this, element ); + +}; + +THREE.CSS3DSprite.prototype = Object.create( THREE.CSS3DObject.prototype ); +THREE.CSS3DSprite.prototype.constructor = THREE.CSS3DSprite; + +// + +THREE.CSS3DRenderer = function () { + + console.log( 'THREE.CSS3DRenderer', THREE.REVISION ); + + var _width, _height; + var _widthHalf, _heightHalf; + + var matrix = new THREE.Matrix4(); + + var cache = { + camera: { fov: 0, style: '' }, + objects: new WeakMap() + }; + + var domElement = document.createElement( 'div' ); + domElement.style.overflow = 'hidden'; + + this.domElement = domElement; + + var cameraElement = document.createElement( 'div' ); + + cameraElement.style.WebkitTransformStyle = 'preserve-3d'; + cameraElement.style.transformStyle = 'preserve-3d'; + + domElement.appendChild( cameraElement ); + + var isIE = /Trident/i.test( navigator.userAgent ); + + this.getSize = function () { + + return { + width: _width, + height: _height + }; + + }; + + this.setSize = function ( width, height ) { + + _width = width; + _height = height; + _widthHalf = _width / 2; + _heightHalf = _height / 2; + + domElement.style.width = width + 'px'; + domElement.style.height = height + 'px'; + + cameraElement.style.width = width + 'px'; + cameraElement.style.height = height + 'px'; + + }; + + function epsilon( value ) { + + return Math.abs( value ) < 1e-10 ? 0 : value; + + } + + function getCameraCSSMatrix( matrix ) { + + var elements = matrix.elements; + + return 'matrix3d(' + + epsilon( elements[ 0 ] ) + ',' + + epsilon( - elements[ 1 ] ) + ',' + + epsilon( elements[ 2 ] ) + ',' + + epsilon( elements[ 3 ] ) + ',' + + epsilon( elements[ 4 ] ) + ',' + + epsilon( - elements[ 5 ] ) + ',' + + epsilon( elements[ 6 ] ) + ',' + + epsilon( elements[ 7 ] ) + ',' + + epsilon( elements[ 8 ] ) + ',' + + epsilon( - elements[ 9 ] ) + ',' + + epsilon( elements[ 10 ] ) + ',' + + epsilon( elements[ 11 ] ) + ',' + + epsilon( elements[ 12 ] ) + ',' + + epsilon( - elements[ 13 ] ) + ',' + + epsilon( elements[ 14 ] ) + ',' + + epsilon( elements[ 15 ] ) + + ')'; + + } + + function getObjectCSSMatrix( matrix, cameraCSSMatrix ) { + + var elements = matrix.elements; + var matrix3d = 'matrix3d(' + + epsilon( elements[ 0 ] ) + ',' + + epsilon( elements[ 1 ] ) + ',' + + epsilon( elements[ 2 ] ) + ',' + + epsilon( elements[ 3 ] ) + ',' + + epsilon( - elements[ 4 ] ) + ',' + + epsilon( - elements[ 5 ] ) + ',' + + epsilon( - elements[ 6 ] ) + ',' + + epsilon( - elements[ 7 ] ) + ',' + + epsilon( elements[ 8 ] ) + ',' + + epsilon( elements[ 9 ] ) + ',' + + epsilon( elements[ 10 ] ) + ',' + + epsilon( elements[ 11 ] ) + ',' + + epsilon( elements[ 12 ] ) + ',' + + epsilon( elements[ 13 ] ) + ',' + + epsilon( elements[ 14 ] ) + ',' + + epsilon( elements[ 15 ] ) + + ')'; + + if ( isIE ) { + + return 'translate(-50%,-50%)' + + 'translate(' + _widthHalf + 'px,' + _heightHalf + 'px)' + + cameraCSSMatrix + + matrix3d; + + } + + return 'translate(-50%,-50%)' + matrix3d; + + } + + function renderObject( object, camera, cameraCSSMatrix ) { + + if ( object instanceof THREE.CSS3DObject ) { + + var style; + + if ( object instanceof THREE.CSS3DSprite ) { + + // http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/ + + matrix.copy( camera.matrixWorldInverse ); + matrix.transpose(); + matrix.copyPosition( object.matrixWorld ); + matrix.scale( object.scale ); + + matrix.elements[ 3 ] = 0; + matrix.elements[ 7 ] = 0; + matrix.elements[ 11 ] = 0; + matrix.elements[ 15 ] = 1; + + style = getObjectCSSMatrix( matrix, cameraCSSMatrix ); + + } else { + + style = getObjectCSSMatrix( object.matrixWorld, cameraCSSMatrix ); + + } + + var element = object.element; + var cachedStyle = cache.objects.get( object ); + + if ( cachedStyle === undefined || cachedStyle !== style ) { + + element.style.WebkitTransform = style; + element.style.transform = style; + + var objectData = { style: style }; + + if ( isIE ) { + + objectData.distanceToCameraSquared = getDistanceToSquared( camera, object ); + + } + + cache.objects.set( object, objectData ); + + } + + if ( element.parentNode !== cameraElement ) { + + cameraElement.appendChild( element ); + + } + + } + + for ( var i = 0, l = object.children.length; i < l; i ++ ) { + + renderObject( object.children[ i ], camera, cameraCSSMatrix ); + + } + + } + + var getDistanceToSquared = function () { + + var a = new THREE.Vector3(); + var b = new THREE.Vector3(); + + return function ( object1, object2 ) { + + a.setFromMatrixPosition( object1.matrixWorld ); + b.setFromMatrixPosition( object2.matrixWorld ); + + return a.distanceToSquared( b ); + + }; + + }(); + + function filterAndFlatten( scene ) { + + var result = []; + + scene.traverse( function ( object ) { + + if ( object instanceof THREE.CSS3DObject ) result.push( object ); + + } ); + + return result; + + } + + function zOrder( scene ) { + + var sorted = filterAndFlatten( scene ).sort( function ( a, b ) { + + var distanceA = cache.objects.get( a ).distanceToCameraSquared; + var distanceB = cache.objects.get( b ).distanceToCameraSquared; + + return distanceA - distanceB; + + } ); + + var zMax = sorted.length; + + for ( var i = 0, l = sorted.length; i < l; i ++ ) { + + sorted[ i ].element.style.zIndex = zMax - i; + + } + + } + + this.render = function ( scene, camera ) { + + var fov = camera.projectionMatrix.elements[ 5 ] * _heightHalf; + + if ( cache.camera.fov !== fov ) { + + if ( camera.isPerspectiveCamera ) { + + domElement.style.WebkitPerspective = fov + 'px'; + domElement.style.perspective = fov + 'px'; + + } + + cache.camera.fov = fov; + + } + + scene.updateMatrixWorld(); + + if ( camera.parent === null ) camera.updateMatrixWorld(); + + var cameraCSSMatrix = camera.isOrthographicCamera ? + 'scale(' + fov + ')' + getCameraCSSMatrix( camera.matrixWorldInverse ) : + 'translateZ(' + fov + 'px)' + getCameraCSSMatrix( camera.matrixWorldInverse ); + + var style = cameraCSSMatrix + + 'translate(' + _widthHalf + 'px,' + _heightHalf + 'px)'; + + if ( cache.camera.style !== style && ! isIE ) { + + cameraElement.style.WebkitTransform = style; + cameraElement.style.transform = style; + + cache.camera.style = style; + + } + + renderObject( scene, camera, cameraCSSMatrix ); + + if ( isIE ) { + + // IE10 and 11 does not support 'preserve-3d'. + // Thus, z-order in 3D will not work. + // We have to calc z-order manually and set CSS z-index for IE. + // FYI: z-index can't handle object intersection + zOrder( scene ); + + } + + }; + +}; diff --git a/three/jsutil/renderers/CanvasRenderer.js b/three/jsutil/renderers/CanvasRenderer.js new file mode 100644 index 000000000..ceea437b2 --- /dev/null +++ b/three/jsutil/renderers/CanvasRenderer.js @@ -0,0 +1,1153 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.SpriteCanvasMaterial = function ( parameters ) { + + THREE.Material.call( this ); + + this.type = 'SpriteCanvasMaterial'; + this.rotation = 0; + this.color = new THREE.Color( 0xffffff ); + this.program = function () {}; + + this.setValues( parameters ); + +}; + +THREE.SpriteCanvasMaterial.prototype = Object.create( THREE.Material.prototype ); +THREE.SpriteCanvasMaterial.prototype.constructor = THREE.SpriteCanvasMaterial; +THREE.SpriteCanvasMaterial.prototype.isSpriteCanvasMaterial = true; + +THREE.SpriteCanvasMaterial.prototype.clone = function () { + + var material = new THREE.SpriteCanvasMaterial(); + + material.copy( this ); + material.color.copy( this.color ); + material.program = this.program; + + return material; + +}; + +// + +THREE.CanvasRenderer = function ( parameters ) { + + console.log( 'THREE.CanvasRenderer', THREE.REVISION ); + + parameters = parameters || {}; + + var _this = this, + _renderData, _elements, _lights, + _projector = new THREE.Projector(), + + _canvas = parameters.canvas !== undefined + ? parameters.canvas + : document.createElement( 'canvas' ), + + _canvasWidth = _canvas.width, + _canvasHeight = _canvas.height, + _canvasWidthHalf = Math.floor( _canvasWidth / 2 ), + _canvasHeightHalf = Math.floor( _canvasHeight / 2 ), + + _viewportX = 0, + _viewportY = 0, + _viewportWidth = _canvasWidth, + _viewportHeight = _canvasHeight, + + _pixelRatio = 1, + + _context = _canvas.getContext( '2d', { + alpha: parameters.alpha === true + } ), + + _clearColor = new THREE.Color( 0x000000 ), + _clearAlpha = parameters.alpha === true ? 0 : 1, + + _contextGlobalAlpha = 1, + _contextGlobalCompositeOperation = 0, + _contextStrokeStyle = null, + _contextFillStyle = null, + _contextLineWidth = null, + _contextLineCap = null, + _contextLineJoin = null, + _contextLineDash = [], + + _v1, _v2, _v3, + + _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, + + _color = new THREE.Color(), + + _diffuseColor = new THREE.Color(), + _emissiveColor = new THREE.Color(), + + _lightColor = new THREE.Color(), + + _patterns = {}, + + _uvs, + _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y, + + _clipBox = new THREE.Box2(), + _clearBox = new THREE.Box2(), + _elemBox = new THREE.Box2(), + + _ambientLight = new THREE.Color(), + _directionalLights = new THREE.Color(), + _pointLights = new THREE.Color(), + + _vector3 = new THREE.Vector3(), // Needed for PointLight + _centroid = new THREE.Vector3(), + _normal = new THREE.Vector3(), + _normalViewMatrix = new THREE.Matrix3(); + + /* TODO + _canvas.mozImageSmoothingEnabled = false; + _canvas.webkitImageSmoothingEnabled = false; + _canvas.msImageSmoothingEnabled = false; + _canvas.imageSmoothingEnabled = false; + */ + + // dash+gap fallbacks for Firefox and everything else + + if ( _context.setLineDash === undefined ) { + + _context.setLineDash = function () {}; + + } + + this.domElement = _canvas; + + this.autoClear = true; + this.sortObjects = true; + this.sortElements = true; + + this.info = { + + render: { + + vertices: 0, + faces: 0 + + } + + }; + + // API + + this.getContext = function () { + + return _context; + + }; + + this.getContextAttributes = function () { + + return _context.getContextAttributes(); + + }; + + this.getPixelRatio = function () { + + return _pixelRatio; + + }; + + this.setPixelRatio = function ( value ) { + + if ( value !== undefined ) _pixelRatio = value; + + }; + + this.setSize = function ( width, height, updateStyle ) { + + _canvasWidth = width * _pixelRatio; + _canvasHeight = height * _pixelRatio; + + _canvas.width = _canvasWidth; + _canvas.height = _canvasHeight; + + _canvasWidthHalf = Math.floor( _canvasWidth / 2 ); + _canvasHeightHalf = Math.floor( _canvasHeight / 2 ); + + if ( updateStyle !== false ) { + + _canvas.style.width = width + 'px'; + _canvas.style.height = height + 'px'; + + } + + _clipBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf ); + _clipBox.max.set( _canvasWidthHalf, _canvasHeightHalf ); + + _clearBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf ); + _clearBox.max.set( _canvasWidthHalf, _canvasHeightHalf ); + + _contextGlobalAlpha = 1; + _contextGlobalCompositeOperation = 0; + _contextStrokeStyle = null; + _contextFillStyle = null; + _contextLineWidth = null; + _contextLineCap = null; + _contextLineJoin = null; + + this.setViewport( 0, 0, width, height ); + + }; + + this.setViewport = function ( x, y, width, height ) { + + _viewportX = x * _pixelRatio; + _viewportY = y * _pixelRatio; + + _viewportWidth = width * _pixelRatio; + _viewportHeight = height * _pixelRatio; + + }; + + this.setScissor = function () {}; + this.setScissorTest = function () {}; + + this.setClearColor = function ( color, alpha ) { + + _clearColor.set( color ); + _clearAlpha = alpha !== undefined ? alpha : 1; + + _clearBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf ); + _clearBox.max.set( _canvasWidthHalf, _canvasHeightHalf ); + + }; + + this.setClearColorHex = function ( hex, alpha ) { + + console.warn( 'THREE.CanvasRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead.' ); + this.setClearColor( hex, alpha ); + + }; + + this.getClearColor = function () { + + return _clearColor; + + }; + + this.getClearAlpha = function () { + + return _clearAlpha; + + }; + + this.getMaxAnisotropy = function () { + + return 0; + + }; + + this.clear = function () { + + if ( _clearBox.isEmpty() === false ) { + + _clearBox.intersect( _clipBox ); + _clearBox.expandByScalar( 2 ); + + _clearBox.min.x = _clearBox.min.x + _canvasWidthHalf; + _clearBox.min.y = - _clearBox.min.y + _canvasHeightHalf; // higher y value ! + _clearBox.max.x = _clearBox.max.x + _canvasWidthHalf; + _clearBox.max.y = - _clearBox.max.y + _canvasHeightHalf; // lower y value ! + + if ( _clearAlpha < 1 ) { + + _context.clearRect( + _clearBox.min.x | 0, + _clearBox.max.y | 0, + ( _clearBox.max.x - _clearBox.min.x ) | 0, + ( _clearBox.min.y - _clearBox.max.y ) | 0 + ); + + } + + if ( _clearAlpha > 0 ) { + + setOpacity( 1 ); + setBlending( THREE.NormalBlending ); + + setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearAlpha + ')' ); + + _context.fillRect( + _clearBox.min.x | 0, + _clearBox.max.y | 0, + ( _clearBox.max.x - _clearBox.min.x ) | 0, + ( _clearBox.min.y - _clearBox.max.y ) | 0 + ); + + } + + _clearBox.makeEmpty(); + + } + + }; + + // compatibility + + this.clearColor = function () {}; + this.clearDepth = function () {}; + this.clearStencil = function () {}; + + this.render = function ( scene, camera ) { + + if ( camera.isCamera === undefined ) { + + console.error( 'THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.' ); + return; + + } + + var background = scene.background; + + if ( background && background.isColor ) { + + setOpacity( 1 ); + setBlending( THREE.NormalBlending ); + + setFillStyle( background.getStyle() ); + _context.fillRect( 0, 0, _canvasWidth, _canvasHeight ); + + } else if ( this.autoClear === true ) { + + this.clear(); + + } + + _this.info.render.vertices = 0; + _this.info.render.faces = 0; + + _context.setTransform( _viewportWidth / _canvasWidth, 0, 0, - _viewportHeight / _canvasHeight, _viewportX, _canvasHeight - _viewportY ); + _context.translate( _canvasWidthHalf, _canvasHeightHalf ); + + _renderData = _projector.projectScene( scene, camera, this.sortObjects, this.sortElements ); + _elements = _renderData.elements; + _lights = _renderData.lights; + + _normalViewMatrix.getNormalMatrix( camera.matrixWorldInverse ); + + /* DEBUG + setFillStyle( 'rgba( 0, 255, 255, 0.5 )' ); + _context.fillRect( _clipBox.min.x, _clipBox.min.y, _clipBox.max.x - _clipBox.min.x, _clipBox.max.y - _clipBox.min.y ); + */ + + calculateLights(); + + for ( var e = 0, el = _elements.length; e < el; e ++ ) { + + var element = _elements[ e ]; + + var material = element.material; + + if ( material === undefined || material.opacity === 0 ) continue; + + _elemBox.makeEmpty(); + + if ( element instanceof THREE.RenderableSprite ) { + + _v1 = element; + _v1.x *= _canvasWidthHalf; _v1.y *= _canvasHeightHalf; + + renderSprite( _v1, element, material ); + + } else if ( element instanceof THREE.RenderableLine ) { + + _v1 = element.v1; _v2 = element.v2; + + _v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf; + _v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf; + + _elemBox.setFromPoints( [ + _v1.positionScreen, + _v2.positionScreen + ] ); + + if ( _clipBox.intersectsBox( _elemBox ) === true ) { + + renderLine( _v1, _v2, element, material ); + + } + + } else if ( element instanceof THREE.RenderableFace ) { + + _v1 = element.v1; _v2 = element.v2; _v3 = element.v3; + + if ( _v1.positionScreen.z < - 1 || _v1.positionScreen.z > 1 ) continue; + if ( _v2.positionScreen.z < - 1 || _v2.positionScreen.z > 1 ) continue; + if ( _v3.positionScreen.z < - 1 || _v3.positionScreen.z > 1 ) continue; + + _v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf; + _v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf; + _v3.positionScreen.x *= _canvasWidthHalf; _v3.positionScreen.y *= _canvasHeightHalf; + + if ( material.overdraw > 0 ) { + + expand( _v1.positionScreen, _v2.positionScreen, material.overdraw ); + expand( _v2.positionScreen, _v3.positionScreen, material.overdraw ); + expand( _v3.positionScreen, _v1.positionScreen, material.overdraw ); + + } + + _elemBox.setFromPoints( [ + _v1.positionScreen, + _v2.positionScreen, + _v3.positionScreen + ] ); + + if ( _clipBox.intersectsBox( _elemBox ) === true ) { + + renderFace3( _v1, _v2, _v3, 0, 1, 2, element, material ); + + } + + } + + /* DEBUG + setLineWidth( 1 ); + setStrokeStyle( 'rgba( 0, 255, 0, 0.5 )' ); + _context.strokeRect( _elemBox.min.x, _elemBox.min.y, _elemBox.max.x - _elemBox.min.x, _elemBox.max.y - _elemBox.min.y ); + */ + + _clearBox.union( _elemBox ); + + } + + /* DEBUG + setLineWidth( 1 ); + setStrokeStyle( 'rgba( 255, 0, 0, 0.5 )' ); + _context.strokeRect( _clearBox.min.x, _clearBox.min.y, _clearBox.max.x - _clearBox.min.x, _clearBox.max.y - _clearBox.min.y ); + */ + + _context.setTransform( 1, 0, 0, 1, 0, 0 ); + + }; + + // + + function calculateLights() { + + _ambientLight.setRGB( 0, 0, 0 ); + _directionalLights.setRGB( 0, 0, 0 ); + _pointLights.setRGB( 0, 0, 0 ); + + for ( var l = 0, ll = _lights.length; l < ll; l ++ ) { + + var light = _lights[ l ]; + var lightColor = light.color; + + if ( light.isAmbientLight ) { + + _ambientLight.add( lightColor ); + + } else if ( light.isDirectionalLight ) { + + // for sprites + + _directionalLights.add( lightColor ); + + } else if ( light.isPointLight ) { + + // for sprites + + _pointLights.add( lightColor ); + + } + + } + + } + + function calculateLight( position, normal, color ) { + + for ( var l = 0, ll = _lights.length; l < ll; l ++ ) { + + var light = _lights[ l ]; + + _lightColor.copy( light.color ); + + if ( light.isDirectionalLight ) { + + var lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld ).normalize(); + + var amount = normal.dot( lightPosition ); + + if ( amount <= 0 ) continue; + + amount *= light.intensity; + + color.add( _lightColor.multiplyScalar( amount ) ); + + } else if ( light.isPointLight ) { + + var lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld ); + + var amount = normal.dot( _vector3.subVectors( lightPosition, position ).normalize() ); + + if ( amount <= 0 ) continue; + + amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 ); + + if ( amount == 0 ) continue; + + amount *= light.intensity; + + color.add( _lightColor.multiplyScalar( amount ) ); + + } + + } + + } + + function renderSprite( v1, element, material ) { + + setOpacity( material.opacity ); + setBlending( material.blending ); + + var scaleX = element.scale.x * _canvasWidthHalf; + var scaleY = element.scale.y * _canvasHeightHalf; + + var dist = Math.sqrt( scaleX * scaleX + scaleY * scaleY ); // allow for rotated sprite + _elemBox.min.set( v1.x - dist, v1.y - dist ); + _elemBox.max.set( v1.x + dist, v1.y + dist ); + + if ( material.isSpriteMaterial ) { + + var texture = material.map; + + if ( texture !== null ) { + + var pattern = _patterns[ texture.id ]; + + if ( pattern === undefined || pattern.version !== texture.version ) { + + pattern = textureToPattern( texture ); + _patterns[ texture.id ] = pattern; + + } + + if ( pattern.canvas !== undefined ) { + + setFillStyle( pattern.canvas ); + + var bitmap = texture.image; + + var ox = bitmap.width * texture.offset.x; + var oy = bitmap.height * texture.offset.y; + + var sx = bitmap.width * texture.repeat.x; + var sy = bitmap.height * texture.repeat.y; + + var cx = scaleX / sx; + var cy = scaleY / sy; + + _context.save(); + _context.translate( v1.x, v1.y ); + if ( material.rotation !== 0 ) _context.rotate( material.rotation ); + _context.translate( - scaleX / 2, - scaleY / 2 ); + _context.scale( cx, cy ); + _context.translate( - ox, - oy ); + _context.fillRect( ox, oy, sx, sy ); + _context.restore(); + + } + + } else { + + // no texture + + setFillStyle( material.color.getStyle() ); + + _context.save(); + _context.translate( v1.x, v1.y ); + if ( material.rotation !== 0 ) _context.rotate( material.rotation ); + _context.scale( scaleX, - scaleY ); + _context.fillRect( - 0.5, - 0.5, 1, 1 ); + _context.restore(); + + } + + } else if ( material.isSpriteCanvasMaterial ) { + + setStrokeStyle( material.color.getStyle() ); + setFillStyle( material.color.getStyle() ); + + _context.save(); + _context.translate( v1.x, v1.y ); + if ( material.rotation !== 0 ) _context.rotate( material.rotation ); + _context.scale( scaleX, scaleY ); + + material.program( _context ); + + _context.restore(); + + } else if ( material.isPointsMaterial ) { + + setFillStyle( material.color.getStyle() ); + + _context.save(); + _context.translate( v1.x, v1.y ); + if ( material.rotation !== 0 ) _context.rotate( material.rotation ); + _context.scale( scaleX * material.size, - scaleY * material.size ); + _context.fillRect( - 0.5, - 0.5, 1, 1 ); + _context.restore(); + + } + + /* DEBUG + setStrokeStyle( 'rgb(255,255,0)' ); + _context.beginPath(); + _context.moveTo( v1.x - 10, v1.y ); + _context.lineTo( v1.x + 10, v1.y ); + _context.moveTo( v1.x, v1.y - 10 ); + _context.lineTo( v1.x, v1.y + 10 ); + _context.stroke(); + */ + + } + + function renderLine( v1, v2, element, material ) { + + setOpacity( material.opacity ); + setBlending( material.blending ); + + _context.beginPath(); + _context.moveTo( v1.positionScreen.x, v1.positionScreen.y ); + _context.lineTo( v2.positionScreen.x, v2.positionScreen.y ); + + if ( material.isLineBasicMaterial ) { + + setLineWidth( material.linewidth ); + setLineCap( material.linecap ); + setLineJoin( material.linejoin ); + + if ( material.vertexColors !== THREE.VertexColors ) { + + setStrokeStyle( material.color.getStyle() ); + + } else { + + var colorStyle1 = element.vertexColors[ 0 ].getStyle(); + var colorStyle2 = element.vertexColors[ 1 ].getStyle(); + + if ( colorStyle1 === colorStyle2 ) { + + setStrokeStyle( colorStyle1 ); + + } else { + + try { + + var grad = _context.createLinearGradient( + v1.positionScreen.x, + v1.positionScreen.y, + v2.positionScreen.x, + v2.positionScreen.y + ); + grad.addColorStop( 0, colorStyle1 ); + grad.addColorStop( 1, colorStyle2 ); + + } catch ( exception ) { + + grad = colorStyle1; + + } + + setStrokeStyle( grad ); + + } + + } + + if ( material.isLineDashedMaterial ) { + + setLineDash( [ material.dashSize, material.gapSize ] ); + + } + + _context.stroke(); + _elemBox.expandByScalar( material.linewidth * 2 ); + + if ( material.isLineDashedMaterial ) { + + setLineDash( [] ); + + } + + } + + } + + function renderFace3( v1, v2, v3, uv1, uv2, uv3, element, material ) { + + _this.info.render.vertices += 3; + _this.info.render.faces ++; + + setOpacity( material.opacity ); + setBlending( material.blending ); + + _v1x = v1.positionScreen.x; _v1y = v1.positionScreen.y; + _v2x = v2.positionScreen.x; _v2y = v2.positionScreen.y; + _v3x = v3.positionScreen.x; _v3y = v3.positionScreen.y; + + drawTriangle( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y ); + + if ( ( material.isMeshLambertMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial ) && material.map === null ) { + + _diffuseColor.copy( material.color ); + _emissiveColor.copy( material.emissive ); + + if ( material.vertexColors === THREE.FaceColors ) { + + _diffuseColor.multiply( element.color ); + + } + + _color.copy( _ambientLight ); + + _centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 ); + + calculateLight( _centroid, element.normalModel, _color ); + + _color.multiply( _diffuseColor ).add( _emissiveColor ); + + material.wireframe === true + ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) + : fillPath( _color ); + + } else if ( material.isMeshBasicMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial ) { + + if ( material.map !== null ) { + + var mapping = material.map.mapping; + + if ( mapping === THREE.UVMapping ) { + + _uvs = element.uvs; + patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uvs[ uv1 ].x, _uvs[ uv1 ].y, _uvs[ uv2 ].x, _uvs[ uv2 ].y, _uvs[ uv3 ].x, _uvs[ uv3 ].y, material.map ); + + } + + } else if ( material.envMap !== null ) { + + if ( material.envMap.mapping === THREE.SphericalReflectionMapping ) { + + _normal.copy( element.vertexNormalsModel[ uv1 ] ).applyMatrix3( _normalViewMatrix ); + _uv1x = 0.5 * _normal.x + 0.5; + _uv1y = 0.5 * _normal.y + 0.5; + + _normal.copy( element.vertexNormalsModel[ uv2 ] ).applyMatrix3( _normalViewMatrix ); + _uv2x = 0.5 * _normal.x + 0.5; + _uv2y = 0.5 * _normal.y + 0.5; + + _normal.copy( element.vertexNormalsModel[ uv3 ] ).applyMatrix3( _normalViewMatrix ); + _uv3x = 0.5 * _normal.x + 0.5; + _uv3y = 0.5 * _normal.y + 0.5; + + patternPath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y, material.envMap ); + + } + + } else { + + _color.copy( material.color ); + + if ( material.vertexColors === THREE.FaceColors ) { + + _color.multiply( element.color ); + + } + + material.wireframe === true + ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) + : fillPath( _color ); + + } + + } else if ( material.isMeshNormalMaterial ) { + + _normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix ); + + _color.setRGB( _normal.x, _normal.y, _normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 ); + + material.wireframe === true + ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) + : fillPath( _color ); + + } else { + + _color.setRGB( 1, 1, 1 ); + + material.wireframe === true + ? strokePath( _color, material.wireframeLinewidth, material.wireframeLinecap, material.wireframeLinejoin ) + : fillPath( _color ); + + } + + } + + // + + function drawTriangle( x0, y0, x1, y1, x2, y2 ) { + + _context.beginPath(); + _context.moveTo( x0, y0 ); + _context.lineTo( x1, y1 ); + _context.lineTo( x2, y2 ); + _context.closePath(); + + } + + function strokePath( color, linewidth, linecap, linejoin ) { + + setLineWidth( linewidth ); + setLineCap( linecap ); + setLineJoin( linejoin ); + setStrokeStyle( color.getStyle() ); + + _context.stroke(); + + _elemBox.expandByScalar( linewidth * 2 ); + + } + + function fillPath( color ) { + + setFillStyle( color.getStyle() ); + _context.fill(); + + } + + function textureToPattern( texture ) { + + if ( texture.version === 0 || + texture instanceof THREE.CompressedTexture || + texture instanceof THREE.DataTexture ) { + + return { + canvas: undefined, + version: texture.version + }; + + } + + var image = texture.image; + + if ( image.complete === false ) { + + return { + canvas: undefined, + version: 0 + }; + + } + + var repeatX = texture.wrapS === THREE.RepeatWrapping || texture.wrapS === THREE.MirroredRepeatWrapping; + var repeatY = texture.wrapT === THREE.RepeatWrapping || texture.wrapT === THREE.MirroredRepeatWrapping; + + var mirrorX = texture.wrapS === THREE.MirroredRepeatWrapping; + var mirrorY = texture.wrapT === THREE.MirroredRepeatWrapping; + + // + + var canvas = document.createElement( 'canvas' ); + canvas.width = image.width * ( mirrorX ? 2 : 1 ); + canvas.height = image.height * ( mirrorY ? 2 : 1 ); + + var context = canvas.getContext( '2d' ); + context.setTransform( 1, 0, 0, - 1, 0, image.height ); + context.drawImage( image, 0, 0 ); + + if ( mirrorX === true ) { + + context.setTransform( - 1, 0, 0, - 1, image.width, image.height ); + context.drawImage( image, - image.width, 0 ); + + } + + if ( mirrorY === true ) { + + context.setTransform( 1, 0, 0, 1, 0, 0 ); + context.drawImage( image, 0, image.height ); + + } + + if ( mirrorX === true && mirrorY === true ) { + + context.setTransform( - 1, 0, 0, 1, image.width, 0 ); + context.drawImage( image, - image.width, image.height ); + + } + + var repeat = 'no-repeat'; + + if ( repeatX === true && repeatY === true ) { + + repeat = 'repeat'; + + } else if ( repeatX === true ) { + + repeat = 'repeat-x'; + + } else if ( repeatY === true ) { + + repeat = 'repeat-y'; + + } + + var pattern = _context.createPattern( canvas, repeat ); + + if ( texture.onUpdate ) texture.onUpdate( texture ); + + return { + canvas: pattern, + version: texture.version + }; + + } + + function patternPath( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, texture ) { + + var pattern = _patterns[ texture.id ]; + + if ( pattern === undefined || pattern.version !== texture.version ) { + + pattern = textureToPattern( texture ); + _patterns[ texture.id ] = pattern; + + } + + if ( pattern.canvas !== undefined ) { + + setFillStyle( pattern.canvas ); + + } else { + + setFillStyle( 'rgba( 0, 0, 0, 1)' ); + _context.fill(); + return; + + } + + // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 + + var a, b, c, d, e, f, det, idet, + offsetX = texture.offset.x / texture.repeat.x, + offsetY = texture.offset.y / texture.repeat.y, + width = texture.image.width * texture.repeat.x, + height = texture.image.height * texture.repeat.y; + + u0 = ( u0 + offsetX ) * width; + v0 = ( v0 + offsetY ) * height; + + u1 = ( u1 + offsetX ) * width; + v1 = ( v1 + offsetY ) * height; + + u2 = ( u2 + offsetX ) * width; + v2 = ( v2 + offsetY ) * height; + + x1 -= x0; y1 -= y0; + x2 -= x0; y2 -= y0; + + u1 -= u0; v1 -= v0; + u2 -= u0; v2 -= v0; + + det = u1 * v2 - u2 * v1; + + if ( det === 0 ) return; + + idet = 1 / det; + + a = ( v2 * x1 - v1 * x2 ) * idet; + b = ( v2 * y1 - v1 * y2 ) * idet; + c = ( u1 * x2 - u2 * x1 ) * idet; + d = ( u1 * y2 - u2 * y1 ) * idet; + + e = x0 - a * u0 - c * v0; + f = y0 - b * u0 - d * v0; + + _context.save(); + _context.transform( a, b, c, d, e, f ); + _context.fill(); + _context.restore(); + + } + + /* + function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) { + + // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 + + var a, b, c, d, e, f, det, idet, + width = image.width - 1, + height = image.height - 1; + + u0 *= width; v0 *= height; + u1 *= width; v1 *= height; + u2 *= width; v2 *= height; + + x1 -= x0; y1 -= y0; + x2 -= x0; y2 -= y0; + + u1 -= u0; v1 -= v0; + u2 -= u0; v2 -= v0; + + det = u1 * v2 - u2 * v1; + + idet = 1 / det; + + a = ( v2 * x1 - v1 * x2 ) * idet; + b = ( v2 * y1 - v1 * y2 ) * idet; + c = ( u1 * x2 - u2 * x1 ) * idet; + d = ( u1 * y2 - u2 * y1 ) * idet; + + e = x0 - a * u0 - c * v0; + f = y0 - b * u0 - d * v0; + + _context.save(); + _context.transform( a, b, c, d, e, f ); + _context.clip(); + _context.drawImage( image, 0, 0 ); + _context.restore(); + + } + */ + + // Hide anti-alias gaps + + function expand( v1, v2, pixels ) { + + var x = v2.x - v1.x, y = v2.y - v1.y, + det = x * x + y * y, idet; + + if ( det === 0 ) return; + + idet = pixels / Math.sqrt( det ); + + x *= idet; y *= idet; + + v2.x += x; v2.y += y; + v1.x -= x; v1.y -= y; + + } + + // Context cached methods. + + function setOpacity( value ) { + + if ( _contextGlobalAlpha !== value ) { + + _context.globalAlpha = value; + _contextGlobalAlpha = value; + + } + + } + + function setBlending( value ) { + + if ( _contextGlobalCompositeOperation !== value ) { + + if ( value === THREE.NormalBlending ) { + + _context.globalCompositeOperation = 'source-over'; + + } else if ( value === THREE.AdditiveBlending ) { + + _context.globalCompositeOperation = 'lighter'; + + } else if ( value === THREE.SubtractiveBlending ) { + + _context.globalCompositeOperation = 'darker'; + + } else if ( value === THREE.MultiplyBlending ) { + + _context.globalCompositeOperation = 'multiply'; + + } + + _contextGlobalCompositeOperation = value; + + } + + } + + function setLineWidth( value ) { + + if ( _contextLineWidth !== value ) { + + _context.lineWidth = value; + _contextLineWidth = value; + + } + + } + + function setLineCap( value ) { + + // "butt", "round", "square" + + if ( _contextLineCap !== value ) { + + _context.lineCap = value; + _contextLineCap = value; + + } + + } + + function setLineJoin( value ) { + + // "round", "bevel", "miter" + + if ( _contextLineJoin !== value ) { + + _context.lineJoin = value; + _contextLineJoin = value; + + } + + } + + function setStrokeStyle( value ) { + + if ( _contextStrokeStyle !== value ) { + + _context.strokeStyle = value; + _contextStrokeStyle = value; + + } + + } + + function setFillStyle( value ) { + + if ( _contextFillStyle !== value ) { + + _context.fillStyle = value; + _contextFillStyle = value; + + } + + } + + function setLineDash( value ) { + + if ( _contextLineDash.length !== value.length ) { + + _context.setLineDash( value ); + _contextLineDash = value; + + } + + } + +}; diff --git a/three/jsutil/renderers/Projector.js b/three/jsutil/renderers/Projector.js new file mode 100644 index 000000000..898f7cb67 --- /dev/null +++ b/three/jsutil/renderers/Projector.js @@ -0,0 +1,1108 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author supereggbert / http://www.paulbrunt.co.uk/ + * @author julianwa / https://github.com/julianwa + */ + +THREE.RenderableObject = function () { + + this.id = 0; + + this.object = null; + this.z = 0; + this.renderOrder = 0; + +}; + +// + +THREE.RenderableFace = function () { + + this.id = 0; + + this.v1 = new THREE.RenderableVertex(); + this.v2 = new THREE.RenderableVertex(); + this.v3 = new THREE.RenderableVertex(); + + this.normalModel = new THREE.Vector3(); + + this.vertexNormalsModel = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ]; + this.vertexNormalsLength = 0; + + this.color = new THREE.Color(); + this.material = null; + this.uvs = [ new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2() ]; + + this.z = 0; + this.renderOrder = 0; + +}; + +// + +THREE.RenderableVertex = function () { + + this.position = new THREE.Vector3(); + this.positionWorld = new THREE.Vector3(); + this.positionScreen = new THREE.Vector4(); + + this.visible = true; + +}; + +THREE.RenderableVertex.prototype.copy = function ( vertex ) { + + this.positionWorld.copy( vertex.positionWorld ); + this.positionScreen.copy( vertex.positionScreen ); + +}; + +// + +THREE.RenderableLine = function () { + + this.id = 0; + + this.v1 = new THREE.RenderableVertex(); + this.v2 = new THREE.RenderableVertex(); + + this.vertexColors = [ new THREE.Color(), new THREE.Color() ]; + this.material = null; + + this.z = 0; + this.renderOrder = 0; + +}; + +// + +THREE.RenderableSprite = function () { + + this.id = 0; + + this.object = null; + + this.x = 0; + this.y = 0; + this.z = 0; + + this.rotation = 0; + this.scale = new THREE.Vector2(); + + this.material = null; + this.renderOrder = 0; + +}; + +// + +THREE.Projector = function () { + + var _object, _objectCount, _objectPool = [], _objectPoolLength = 0, + _vertex, _vertexCount, _vertexPool = [], _vertexPoolLength = 0, + _face, _faceCount, _facePool = [], _facePoolLength = 0, + _line, _lineCount, _linePool = [], _linePoolLength = 0, + _sprite, _spriteCount, _spritePool = [], _spritePoolLength = 0, + + _renderData = { objects: [], lights: [], elements: [] }, + + _vector3 = new THREE.Vector3(), + _vector4 = new THREE.Vector4(), + + _clipBox = new THREE.Box3( new THREE.Vector3( - 1, - 1, - 1 ), new THREE.Vector3( 1, 1, 1 ) ), + _boundingBox = new THREE.Box3(), + _points3 = new Array( 3 ), + + _viewMatrix = new THREE.Matrix4(), + _viewProjectionMatrix = new THREE.Matrix4(), + + _modelMatrix, + _modelViewProjectionMatrix = new THREE.Matrix4(), + + _normalMatrix = new THREE.Matrix3(), + + _frustum = new THREE.Frustum(), + + _clippedVertex1PositionScreen = new THREE.Vector4(), + _clippedVertex2PositionScreen = new THREE.Vector4(); + + // + + this.projectVector = function ( vector, camera ) { + + console.warn( 'THREE.Projector: .projectVector() is now vector.project().' ); + vector.project( camera ); + + }; + + this.unprojectVector = function ( vector, camera ) { + + console.warn( 'THREE.Projector: .unprojectVector() is now vector.unproject().' ); + vector.unproject( camera ); + + }; + + this.pickingRay = function () { + + console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' ); + + }; + + // + + var RenderList = function () { + + var normals = []; + var colors = []; + var uvs = []; + + var object = null; + var material = null; + + var normalMatrix = new THREE.Matrix3(); + + function setObject( value ) { + + object = value; + material = object.material; + + normalMatrix.getNormalMatrix( object.matrixWorld ); + + normals.length = 0; + colors.length = 0; + uvs.length = 0; + + } + + function projectVertex( vertex ) { + + var position = vertex.position; + var positionWorld = vertex.positionWorld; + var positionScreen = vertex.positionScreen; + + positionWorld.copy( position ).applyMatrix4( _modelMatrix ); + positionScreen.copy( positionWorld ).applyMatrix4( _viewProjectionMatrix ); + + var invW = 1 / positionScreen.w; + + positionScreen.x *= invW; + positionScreen.y *= invW; + positionScreen.z *= invW; + + vertex.visible = positionScreen.x >= - 1 && positionScreen.x <= 1 && + positionScreen.y >= - 1 && positionScreen.y <= 1 && + positionScreen.z >= - 1 && positionScreen.z <= 1; + + } + + function pushVertex( x, y, z ) { + + _vertex = getNextVertexInPool(); + _vertex.position.set( x, y, z ); + + projectVertex( _vertex ); + + } + + function pushNormal( x, y, z ) { + + normals.push( x, y, z ); + + } + + function pushColor( r, g, b ) { + + colors.push( r, g, b ); + + } + + function pushUv( x, y ) { + + uvs.push( x, y ); + + } + + function checkTriangleVisibility( v1, v2, v3 ) { + + if ( v1.visible === true || v2.visible === true || v3.visible === true ) return true; + + _points3[ 0 ] = v1.positionScreen; + _points3[ 1 ] = v2.positionScreen; + _points3[ 2 ] = v3.positionScreen; + + return _clipBox.intersectsBox( _boundingBox.setFromPoints( _points3 ) ); + + } + + function checkBackfaceCulling( v1, v2, v3 ) { + + return ( ( v3.positionScreen.x - v1.positionScreen.x ) * + ( v2.positionScreen.y - v1.positionScreen.y ) - + ( v3.positionScreen.y - v1.positionScreen.y ) * + ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0; + + } + + function pushLine( a, b ) { + + var v1 = _vertexPool[ a ]; + var v2 = _vertexPool[ b ]; + + // Clip + + v1.positionScreen.copy( v1.position ).applyMatrix4( _modelViewProjectionMatrix ); + v2.positionScreen.copy( v2.position ).applyMatrix4( _modelViewProjectionMatrix ); + + if ( clipLine( v1.positionScreen, v2.positionScreen ) === true ) { + + // Perform the perspective divide + v1.positionScreen.multiplyScalar( 1 / v1.positionScreen.w ); + v2.positionScreen.multiplyScalar( 1 / v2.positionScreen.w ); + + _line = getNextLineInPool(); + _line.id = object.id; + _line.v1.copy( v1 ); + _line.v2.copy( v2 ); + _line.z = Math.max( v1.positionScreen.z, v2.positionScreen.z ); + _line.renderOrder = object.renderOrder; + + _line.material = object.material; + + if ( object.material.vertexColors === THREE.VertexColors ) { + + _line.vertexColors[ 0 ].fromArray( colors, a * 3 ); + _line.vertexColors[ 1 ].fromArray( colors, b * 3 ); + + } + + _renderData.elements.push( _line ); + + } + + } + + function pushTriangle( a, b, c, material ) { + + var v1 = _vertexPool[ a ]; + var v2 = _vertexPool[ b ]; + var v3 = _vertexPool[ c ]; + + if ( checkTriangleVisibility( v1, v2, v3 ) === false ) return; + + if ( material.side === THREE.DoubleSide || checkBackfaceCulling( v1, v2, v3 ) === true ) { + + _face = getNextFaceInPool(); + + _face.id = object.id; + _face.v1.copy( v1 ); + _face.v2.copy( v2 ); + _face.v3.copy( v3 ); + _face.z = ( v1.positionScreen.z + v2.positionScreen.z + v3.positionScreen.z ) / 3; + _face.renderOrder = object.renderOrder; + + // face normal + _vector3.subVectors( v3.position, v2.position ); + _vector4.subVectors( v1.position, v2.position ); + _vector3.cross( _vector4 ); + _face.normalModel.copy( _vector3 ); + _face.normalModel.applyMatrix3( normalMatrix ).normalize(); + + for ( var i = 0; i < 3; i ++ ) { + + var normal = _face.vertexNormalsModel[ i ]; + normal.fromArray( normals, arguments[ i ] * 3 ); + normal.applyMatrix3( normalMatrix ).normalize(); + + var uv = _face.uvs[ i ]; + uv.fromArray( uvs, arguments[ i ] * 2 ); + + } + + _face.vertexNormalsLength = 3; + + _face.material = material; + + if ( material.vertexColors === THREE.FaceColors ) { + + _face.color.fromArray( colors, a * 3 ); + + } + + _renderData.elements.push( _face ); + + } + + } + + return { + setObject: setObject, + projectVertex: projectVertex, + checkTriangleVisibility: checkTriangleVisibility, + checkBackfaceCulling: checkBackfaceCulling, + pushVertex: pushVertex, + pushNormal: pushNormal, + pushColor: pushColor, + pushUv: pushUv, + pushLine: pushLine, + pushTriangle: pushTriangle + }; + + }; + + var renderList = new RenderList(); + + function projectObject( object ) { + + if ( object.visible === false ) return; + + if ( object instanceof THREE.Light ) { + + _renderData.lights.push( object ); + + } else if ( object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Points ) { + + if ( object.material.visible === false ) return; + if ( object.frustumCulled === true && _frustum.intersectsObject( object ) === false ) return; + + addObject( object ); + + } else if ( object instanceof THREE.Sprite ) { + + if ( object.material.visible === false ) return; + if ( object.frustumCulled === true && _frustum.intersectsSprite( object ) === false ) return; + + addObject( object ); + + } + + var children = object.children; + + for ( var i = 0, l = children.length; i < l; i ++ ) { + + projectObject( children[ i ] ); + + } + + } + + function addObject( object ) { + + _object = getNextObjectInPool(); + _object.id = object.id; + _object.object = object; + + _vector3.setFromMatrixPosition( object.matrixWorld ); + _vector3.applyMatrix4( _viewProjectionMatrix ); + _object.z = _vector3.z; + _object.renderOrder = object.renderOrder; + + _renderData.objects.push( _object ); + + } + + this.projectScene = function ( scene, camera, sortObjects, sortElements ) { + + _faceCount = 0; + _lineCount = 0; + _spriteCount = 0; + + _renderData.elements.length = 0; + + if ( scene.autoUpdate === true ) scene.updateMatrixWorld(); + if ( camera.parent === null ) camera.updateMatrixWorld(); + + _viewMatrix.copy( camera.matrixWorldInverse ); + _viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix ); + + _frustum.setFromMatrix( _viewProjectionMatrix ); + + // + + _objectCount = 0; + + _renderData.objects.length = 0; + _renderData.lights.length = 0; + + projectObject( scene ); + + if ( sortObjects === true ) { + + _renderData.objects.sort( painterSort ); + + } + + // + + var objects = _renderData.objects; + + for ( var o = 0, ol = objects.length; o < ol; o ++ ) { + + var object = objects[ o ].object; + var geometry = object.geometry; + + renderList.setObject( object ); + + _modelMatrix = object.matrixWorld; + + _vertexCount = 0; + + if ( object instanceof THREE.Mesh ) { + + if ( geometry instanceof THREE.BufferGeometry ) { + + var material = object.material; + + var isMultiMaterial = Array.isArray( material ); + + var attributes = geometry.attributes; + var groups = geometry.groups; + + if ( attributes.position === undefined ) continue; + + var positions = attributes.position.array; + + for ( var i = 0, l = positions.length; i < l; i += 3 ) { + + var x = positions[ i ]; + var y = positions[ i + 1 ]; + var z = positions[ i + 2 ]; + + if ( material.morphTargets === true ) { + + var morphTargets = geometry.morphAttributes.position; + var morphInfluences = object.morphTargetInfluences; + + for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) { + + var influence = morphInfluences[ t ]; + + if ( influence === 0 ) continue; + + var target = morphTargets[ t ]; + + x += ( target.getX( i / 3 ) - positions[ i ] ) * influence; + y += ( target.getY( i / 3 ) - positions[ i + 1 ] ) * influence; + z += ( target.getZ( i / 3 ) - positions[ i + 2 ] ) * influence; + + } + + } + + renderList.pushVertex( x, y, z ); + + } + + if ( attributes.normal !== undefined ) { + + var normals = attributes.normal.array; + + for ( var i = 0, l = normals.length; i < l; i += 3 ) { + + renderList.pushNormal( normals[ i ], normals[ i + 1 ], normals[ i + 2 ] ); + + } + + } + + if ( attributes.color !== undefined ) { + + var colors = attributes.color.array; + + for ( var i = 0, l = colors.length; i < l; i += 3 ) { + + renderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] ); + + } + + } + + if ( attributes.uv !== undefined ) { + + var uvs = attributes.uv.array; + + for ( var i = 0, l = uvs.length; i < l; i += 2 ) { + + renderList.pushUv( uvs[ i ], uvs[ i + 1 ] ); + + } + + } + + if ( geometry.index !== null ) { + + var indices = geometry.index.array; + + if ( groups.length > 0 ) { + + for ( var g = 0; g < groups.length; g ++ ) { + + var group = groups[ g ]; + + material = isMultiMaterial === true + ? object.material[ group.materialIndex ] + : object.material; + + if ( material === undefined ) continue; + + for ( var i = group.start, l = group.start + group.count; i < l; i += 3 ) { + + renderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material ); + + } + + } + + } else { + + for ( var i = 0, l = indices.length; i < l; i += 3 ) { + + renderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material ); + + } + + } + + } else { + + if ( groups.length > 0 ) { + + for ( var g = 0; g < groups.length; g ++ ) { + + var group = groups[ g ]; + + material = isMultiMaterial === true + ? object.material[ group.materialIndex ] + : object.material; + + if ( material === undefined ) continue; + + for ( var i = group.start, l = group.start + group.count; i < l; i += 3 ) { + + renderList.pushTriangle( i, i + 1, i + 2, material ); + + } + + } + + } else { + + for ( var i = 0, l = positions.length / 3; i < l; i += 3 ) { + + renderList.pushTriangle( i, i + 1, i + 2, material ); + + } + + } + + } + + } else if ( geometry instanceof THREE.Geometry ) { + + var vertices = geometry.vertices; + var faces = geometry.faces; + var faceVertexUvs = geometry.faceVertexUvs[ 0 ]; + + _normalMatrix.getNormalMatrix( _modelMatrix ); + + var material = object.material; + + var isMultiMaterial = Array.isArray( material ); + + for ( var v = 0, vl = vertices.length; v < vl; v ++ ) { + + var vertex = vertices[ v ]; + + _vector3.copy( vertex ); + + if ( material.morphTargets === true ) { + + var morphTargets = geometry.morphTargets; + var morphInfluences = object.morphTargetInfluences; + + for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) { + + var influence = morphInfluences[ t ]; + + if ( influence === 0 ) continue; + + var target = morphTargets[ t ]; + var targetVertex = target.vertices[ v ]; + + _vector3.x += ( targetVertex.x - vertex.x ) * influence; + _vector3.y += ( targetVertex.y - vertex.y ) * influence; + _vector3.z += ( targetVertex.z - vertex.z ) * influence; + + } + + } + + renderList.pushVertex( _vector3.x, _vector3.y, _vector3.z ); + + } + + for ( var f = 0, fl = faces.length; f < fl; f ++ ) { + + var face = faces[ f ]; + + material = isMultiMaterial === true + ? object.material[ face.materialIndex ] + : object.material; + + if ( material === undefined ) continue; + + var side = material.side; + + var v1 = _vertexPool[ face.a ]; + var v2 = _vertexPool[ face.b ]; + var v3 = _vertexPool[ face.c ]; + + if ( renderList.checkTriangleVisibility( v1, v2, v3 ) === false ) continue; + + var visible = renderList.checkBackfaceCulling( v1, v2, v3 ); + + if ( side !== THREE.DoubleSide ) { + + if ( side === THREE.FrontSide && visible === false ) continue; + if ( side === THREE.BackSide && visible === true ) continue; + + } + + _face = getNextFaceInPool(); + + _face.id = object.id; + _face.v1.copy( v1 ); + _face.v2.copy( v2 ); + _face.v3.copy( v3 ); + + _face.normalModel.copy( face.normal ); + + if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) { + + _face.normalModel.negate(); + + } + + _face.normalModel.applyMatrix3( _normalMatrix ).normalize(); + + var faceVertexNormals = face.vertexNormals; + + for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) { + + var normalModel = _face.vertexNormalsModel[ n ]; + normalModel.copy( faceVertexNormals[ n ] ); + + if ( visible === false && ( side === THREE.BackSide || side === THREE.DoubleSide ) ) { + + normalModel.negate(); + + } + + normalModel.applyMatrix3( _normalMatrix ).normalize(); + + } + + _face.vertexNormalsLength = faceVertexNormals.length; + + var vertexUvs = faceVertexUvs[ f ]; + + if ( vertexUvs !== undefined ) { + + for ( var u = 0; u < 3; u ++ ) { + + _face.uvs[ u ].copy( vertexUvs[ u ] ); + + } + + } + + _face.color = face.color; + _face.material = material; + + _face.z = ( v1.positionScreen.z + v2.positionScreen.z + v3.positionScreen.z ) / 3; + _face.renderOrder = object.renderOrder; + + _renderData.elements.push( _face ); + + } + + } + + } else if ( object instanceof THREE.Line ) { + + _modelViewProjectionMatrix.multiplyMatrices( _viewProjectionMatrix, _modelMatrix ); + + if ( geometry instanceof THREE.BufferGeometry ) { + + var attributes = geometry.attributes; + + if ( attributes.position !== undefined ) { + + var positions = attributes.position.array; + + for ( var i = 0, l = positions.length; i < l; i += 3 ) { + + renderList.pushVertex( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] ); + + } + + if ( attributes.color !== undefined ) { + + var colors = attributes.color.array; + + for ( var i = 0, l = colors.length; i < l; i += 3 ) { + + renderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] ); + + } + + } + + if ( geometry.index !== null ) { + + var indices = geometry.index.array; + + for ( var i = 0, l = indices.length; i < l; i += 2 ) { + + renderList.pushLine( indices[ i ], indices[ i + 1 ] ); + + } + + } else { + + var step = object instanceof THREE.LineSegments ? 2 : 1; + + for ( var i = 0, l = ( positions.length / 3 ) - 1; i < l; i += step ) { + + renderList.pushLine( i, i + 1 ); + + } + + } + + } + + } else if ( geometry instanceof THREE.Geometry ) { + + var vertices = object.geometry.vertices; + + if ( vertices.length === 0 ) continue; + + v1 = getNextVertexInPool(); + v1.positionScreen.copy( vertices[ 0 ] ).applyMatrix4( _modelViewProjectionMatrix ); + + var step = object instanceof THREE.LineSegments ? 2 : 1; + + for ( var v = 1, vl = vertices.length; v < vl; v ++ ) { + + v1 = getNextVertexInPool(); + v1.positionScreen.copy( vertices[ v ] ).applyMatrix4( _modelViewProjectionMatrix ); + + if ( ( v + 1 ) % step > 0 ) continue; + + v2 = _vertexPool[ _vertexCount - 2 ]; + + _clippedVertex1PositionScreen.copy( v1.positionScreen ); + _clippedVertex2PositionScreen.copy( v2.positionScreen ); + + if ( clipLine( _clippedVertex1PositionScreen, _clippedVertex2PositionScreen ) === true ) { + + // Perform the perspective divide + _clippedVertex1PositionScreen.multiplyScalar( 1 / _clippedVertex1PositionScreen.w ); + _clippedVertex2PositionScreen.multiplyScalar( 1 / _clippedVertex2PositionScreen.w ); + + _line = getNextLineInPool(); + + _line.id = object.id; + _line.v1.positionScreen.copy( _clippedVertex1PositionScreen ); + _line.v2.positionScreen.copy( _clippedVertex2PositionScreen ); + + _line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z ); + _line.renderOrder = object.renderOrder; + + _line.material = object.material; + + if ( object.material.vertexColors === THREE.VertexColors ) { + + _line.vertexColors[ 0 ].copy( object.geometry.colors[ v ] ); + _line.vertexColors[ 1 ].copy( object.geometry.colors[ v - 1 ] ); + + } + + _renderData.elements.push( _line ); + + } + + } + + } + + } else if ( object instanceof THREE.Points ) { + + _modelViewProjectionMatrix.multiplyMatrices( _viewProjectionMatrix, _modelMatrix ); + + if ( geometry instanceof THREE.Geometry ) { + + var vertices = object.geometry.vertices; + + for ( var v = 0, vl = vertices.length; v < vl; v ++ ) { + + var vertex = vertices[ v ]; + + _vector4.set( vertex.x, vertex.y, vertex.z, 1 ); + _vector4.applyMatrix4( _modelViewProjectionMatrix ); + + pushPoint( _vector4, object, camera ); + + } + + } else if ( geometry instanceof THREE.BufferGeometry ) { + + var attributes = geometry.attributes; + + if ( attributes.position !== undefined ) { + + var positions = attributes.position.array; + + for ( var i = 0, l = positions.length; i < l; i += 3 ) { + + _vector4.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ], 1 ); + _vector4.applyMatrix4( _modelViewProjectionMatrix ); + + pushPoint( _vector4, object, camera ); + + } + + } + + } + + } else if ( object instanceof THREE.Sprite ) { + + object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld ); + _vector4.set( _modelMatrix.elements[ 12 ], _modelMatrix.elements[ 13 ], _modelMatrix.elements[ 14 ], 1 ); + _vector4.applyMatrix4( _viewProjectionMatrix ); + + pushPoint( _vector4, object, camera ); + + } + + } + + if ( sortElements === true ) { + + _renderData.elements.sort( painterSort ); + + } + + return _renderData; + + }; + + function pushPoint( _vector4, object, camera ) { + + var invW = 1 / _vector4.w; + + _vector4.z *= invW; + + if ( _vector4.z >= - 1 && _vector4.z <= 1 ) { + + _sprite = getNextSpriteInPool(); + _sprite.id = object.id; + _sprite.x = _vector4.x * invW; + _sprite.y = _vector4.y * invW; + _sprite.z = _vector4.z; + _sprite.renderOrder = object.renderOrder; + _sprite.object = object; + + _sprite.rotation = object.rotation; + + _sprite.scale.x = object.scale.x * Math.abs( _sprite.x - ( _vector4.x + camera.projectionMatrix.elements[ 0 ] ) / ( _vector4.w + camera.projectionMatrix.elements[ 12 ] ) ); + _sprite.scale.y = object.scale.y * Math.abs( _sprite.y - ( _vector4.y + camera.projectionMatrix.elements[ 5 ] ) / ( _vector4.w + camera.projectionMatrix.elements[ 13 ] ) ); + + _sprite.material = object.material; + + _renderData.elements.push( _sprite ); + + } + + } + + // Pools + + function getNextObjectInPool() { + + if ( _objectCount === _objectPoolLength ) { + + var object = new THREE.RenderableObject(); + _objectPool.push( object ); + _objectPoolLength ++; + _objectCount ++; + return object; + + } + + return _objectPool[ _objectCount ++ ]; + + } + + function getNextVertexInPool() { + + if ( _vertexCount === _vertexPoolLength ) { + + var vertex = new THREE.RenderableVertex(); + _vertexPool.push( vertex ); + _vertexPoolLength ++; + _vertexCount ++; + return vertex; + + } + + return _vertexPool[ _vertexCount ++ ]; + + } + + function getNextFaceInPool() { + + if ( _faceCount === _facePoolLength ) { + + var face = new THREE.RenderableFace(); + _facePool.push( face ); + _facePoolLength ++; + _faceCount ++; + return face; + + } + + return _facePool[ _faceCount ++ ]; + + + } + + function getNextLineInPool() { + + if ( _lineCount === _linePoolLength ) { + + var line = new THREE.RenderableLine(); + _linePool.push( line ); + _linePoolLength ++; + _lineCount ++; + return line; + + } + + return _linePool[ _lineCount ++ ]; + + } + + function getNextSpriteInPool() { + + if ( _spriteCount === _spritePoolLength ) { + + var sprite = new THREE.RenderableSprite(); + _spritePool.push( sprite ); + _spritePoolLength ++; + _spriteCount ++; + return sprite; + + } + + return _spritePool[ _spriteCount ++ ]; + + } + + // + + function painterSort( a, b ) { + + if ( a.renderOrder !== b.renderOrder ) { + + return a.renderOrder - b.renderOrder; + + } else if ( a.z !== b.z ) { + + return b.z - a.z; + + } else if ( a.id !== b.id ) { + + return a.id - b.id; + + } else { + + return 0; + + } + + } + + function clipLine( s1, s2 ) { + + var alpha1 = 0, alpha2 = 1, + + // Calculate the boundary coordinate of each vertex for the near and far clip planes, + // Z = -1 and Z = +1, respectively. + + bc1near = s1.z + s1.w, + bc2near = s2.z + s2.w, + bc1far = - s1.z + s1.w, + bc2far = - s2.z + s2.w; + + if ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) { + + // Both vertices lie entirely within all clip planes. + return true; + + } else if ( ( bc1near < 0 && bc2near < 0 ) || ( bc1far < 0 && bc2far < 0 ) ) { + + // Both vertices lie entirely outside one of the clip planes. + return false; + + } else { + + // The line segment spans at least one clip plane. + + if ( bc1near < 0 ) { + + // v1 lies outside the near plane, v2 inside + alpha1 = Math.max( alpha1, bc1near / ( bc1near - bc2near ) ); + + } else if ( bc2near < 0 ) { + + // v2 lies outside the near plane, v1 inside + alpha2 = Math.min( alpha2, bc1near / ( bc1near - bc2near ) ); + + } + + if ( bc1far < 0 ) { + + // v1 lies outside the far plane, v2 inside + alpha1 = Math.max( alpha1, bc1far / ( bc1far - bc2far ) ); + + } else if ( bc2far < 0 ) { + + // v2 lies outside the far plane, v2 inside + alpha2 = Math.min( alpha2, bc1far / ( bc1far - bc2far ) ); + + } + + if ( alpha2 < alpha1 ) { + + // The line segment spans two boundaries, but is outside both of them. + // (This can't happen when we're only clipping against just near/far but good + // to leave the check here for future usage if other clip planes are added.) + return false; + + } else { + + // Update the s1 and s2 vertices to match the clipped line segment. + s1.lerp( s2, alpha1 ); + s2.lerp( s1, 1 - alpha2 ); + + return true; + + } + + } + + } + +}; diff --git a/three/jsutil/renderers/RaytracingRenderer.js b/three/jsutil/renderers/RaytracingRenderer.js new file mode 100644 index 000000000..cabfb6865 --- /dev/null +++ b/three/jsutil/renderers/RaytracingRenderer.js @@ -0,0 +1,287 @@ +/** + * RaytracingRenderer renders by raytracing it's scene. However, it does not + * compute the pixels itself but it hands off and coordinates the tasks for workers. + * The workers compute the pixel values and this renderer simply paints it to the Canvas. + * + * @author zz85 / http://github.com/zz85 + */ + +THREE.RaytracingRenderer = function ( parameters ) { + + console.log( 'THREE.RaytracingRenderer', THREE.REVISION ); + + parameters = parameters || {}; + + var scope = this; + var pool = []; + var renderering = false; + + var canvas = document.createElement( 'canvas' ); + var context = canvas.getContext( '2d', { + alpha: parameters.alpha === true + } ); + + var canvasWidth, canvasHeight; + + var clearColor = new THREE.Color( 0x000000 ); + + this.domElement = canvas; + + this.autoClear = true; + + var workers = parameters.workers; + var blockSize = parameters.blockSize || 64; + this.randomize = parameters.randomize; + + var toRender = [], workerId = 0, sceneId = 0; + + console.log( '%cSpinning off ' + workers + ' Workers ', 'font-size: 20px; background: black; color: white; font-family: monospace;' ); + + this.setWorkers = function ( w ) { + + workers = w || navigator.hardwareConcurrency || 4; + + while ( pool.length < workers ) { + + var worker = new Worker( parameters.workerPath ); + worker.id = workerId ++; + + worker.onmessage = function ( e ) { + + var data = e.data; + + if ( ! data ) return; + + if ( data.blockSize && sceneId == data.sceneId ) { // we match sceneId here to be sure + + var imagedata = new ImageData( new Uint8ClampedArray( data.data ), data.blockSize, data.blockSize ); + context.putImageData( imagedata, data.blockX, data.blockY ); + + // completed + + console.log( 'Worker ' + this.id, data.time / 1000, ( Date.now() - reallyThen ) / 1000 + ' s' ); + + if ( pool.length > workers ) { + + pool.splice( pool.indexOf( this ), 1 ); + return this.terminate(); + + } + + renderNext( this ); + + } + + }; + + worker.color = new THREE.Color().setHSL( Math.random(), 0.8, 0.8 ).getHexString(); + pool.push( worker ); + + updateSettings( worker ); + + if ( renderering ) { + + worker.postMessage( { + scene: sceneJSON, + camera: cameraJSON, + annex: materials, + sceneId: sceneId + } ); + + renderNext( worker ); + + } + + } + + if ( ! renderering ) { + + while ( pool.length > workers ) { + + pool.pop().terminate(); + + } + + } + + }; + + this.setWorkers( workers ); + + this.setClearColor = function ( color /*, alpha */ ) { + + clearColor.set( color ); + + }; + + this.setPixelRatio = function () {}; + + this.setSize = function ( width, height ) { + + canvas.width = width; + canvas.height = height; + + canvasWidth = canvas.width; + canvasHeight = canvas.height; + + context.fillStyle = 'white'; + + pool.forEach( updateSettings ); + + }; + + this.setSize( canvas.width, canvas.height ); + + this.clear = function () { + + }; + + // + + var totalBlocks, xblocks, yblocks; + + function updateSettings( worker ) { + + worker.postMessage( { + + init: [ canvasWidth, canvasHeight ], + worker: worker.id, + // workers: pool.length, + blockSize: blockSize + + } ); + + } + + function renderNext( worker ) { + + if ( ! toRender.length ) { + + renderering = false; + return scope.dispatchEvent( { type: "complete" } ); + + } + + var current = toRender.pop(); + + var blockX = ( current % xblocks ) * blockSize; + var blockY = ( current / xblocks | 0 ) * blockSize; + + worker.postMessage( { + render: true, + x: blockX, + y: blockY, + sceneId: sceneId + } ); + + context.fillStyle = '#' + worker.color; + + context.fillRect( blockX, blockY, blockSize, blockSize ); + + } + + var materials = {}; + + var sceneJSON, cameraJSON, reallyThen; + + // additional properties that were not serialize automatically + + var _annex = { + + mirror: 1, + reflectivity: 1, + refractionRatio: 1, + glass: 1 + + }; + + function serializeObject( o ) { + + var mat = o.material; + + if ( ! mat || mat.uuid in materials ) return; + + var props = {}; + for ( var m in _annex ) { + + if ( mat[ m ] !== undefined ) { + + props[ m ] = mat[ m ]; + + } + + } + + materials[ mat.uuid ] = props; + + } + + this.render = function ( scene, camera ) { + + renderering = true; + + // update scene graph + + if ( scene.autoUpdate === true ) scene.updateMatrixWorld(); + + // update camera matrices + + if ( camera.parent === null ) camera.updateMatrixWorld(); + + + sceneJSON = scene.toJSON(); + cameraJSON = camera.toJSON(); + ++ sceneId; + + scene.traverse( serializeObject ); + + pool.forEach( function ( worker ) { + + worker.postMessage( { + scene: sceneJSON, + camera: cameraJSON, + annex: materials, + sceneId: sceneId + } ); + + } ); + + context.clearRect( 0, 0, canvasWidth, canvasHeight ); + reallyThen = Date.now(); + + xblocks = Math.ceil( canvasWidth / blockSize ); + yblocks = Math.ceil( canvasHeight / blockSize ); + totalBlocks = xblocks * yblocks; + + toRender = []; + + for ( var i = 0; i < totalBlocks; i ++ ) { + + toRender.push( i ); + + } + + + // Randomize painting :) + + if ( scope.randomize ) { + + for ( var i = 0; i < totalBlocks; i ++ ) { + + var swap = Math.random() * totalBlocks | 0; + var tmp = toRender[ swap ]; + toRender[ swap ] = toRender[ i ]; + toRender[ i ] = tmp; + + } + + } + + + pool.forEach( renderNext ); + + }; + +}; + +Object.assign( THREE.RaytracingRenderer.prototype, THREE.EventDispatcher.prototype ); diff --git a/three/jsutil/renderers/RaytracingWorker.js b/three/jsutil/renderers/RaytracingWorker.js new file mode 100644 index 000000000..9d95183f7 --- /dev/null +++ b/three/jsutil/renderers/RaytracingWorker.js @@ -0,0 +1,541 @@ +var BLOCK = 128; +var startX, startY; + +var scene, camera, renderer, loader, sceneId; + +importScripts( '../../../build/three.js' ); + + +self.onmessage = function ( e ) { + + var data = e.data; + if ( ! data ) return; + + if ( data.init ) { + + var + width = data.init[ 0 ], + height = data.init[ 1 ]; + + BLOCK = data.blockSize; + + if ( ! renderer ) renderer = new THREE.RaytracingRendererWorker(); + if ( ! loader ) loader = new THREE.ObjectLoader(); + + renderer.setSize( width, height ); + + // TODO fix passing maxRecursionDepth as parameter. + // if (data.maxRecursionDepth) maxRecursionDepth = data.maxRecursionDepth; + + } + + if ( data.scene ) { + + scene = loader.parse( data.scene ); + camera = loader.parse( data.camera ); + + var meta = data.annex; + scene.traverse( function ( o ) { + + if ( o.isPointLight ) { + + o.physicalAttenuation = true; + + } + + var mat = o.material; + + if ( ! mat ) return; + + var material = meta[ mat.uuid ]; + + for ( var m in material ) { + + mat[ m ] = material[ m ]; + + } + + } ); + + sceneId = data.sceneId; + + } + + if ( data.render && scene && camera ) { + + startX = data.x; + startY = data.y; + renderer.render( scene, camera ); + + } + +}; + +/** + * DOM-less version of Raytracing Renderer + * @author mrdoob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + * @author zz95 / http://github.com/zz85 + */ + +THREE.RaytracingRendererWorker = function () { + + console.log( 'THREE.RaytracingRendererWorker', THREE.REVISION ); + + var maxRecursionDepth = 3; + + var canvasWidth, canvasHeight; + var canvasWidthHalf, canvasHeightHalf; + var origin = new THREE.Vector3(); + var direction = new THREE.Vector3(); + + var cameraPosition = new THREE.Vector3(); + + var raycaster = new THREE.Raycaster( origin, direction ); + var ray = raycaster.ray; + + var raycasterLight = new THREE.Raycaster(); + var rayLight = raycasterLight.ray; + + var perspective; + var cameraNormalMatrix = new THREE.Matrix3(); + + var objects; + var lights = []; + var cache = {}; + + this.setSize = function ( width, height ) { + + canvasWidth = width; + canvasHeight = height; + + canvasWidthHalf = Math.floor( canvasWidth / 2 ); + canvasHeightHalf = Math.floor( canvasHeight / 2 ); + + }; + + // + + var spawnRay = ( function () { + + var diffuseColor = new THREE.Color(); + var specularColor = new THREE.Color(); + var lightColor = new THREE.Color(); + var schlick = new THREE.Color(); + + var lightContribution = new THREE.Color(); + + var eyeVector = new THREE.Vector3(); + var lightVector = new THREE.Vector3(); + var normalVector = new THREE.Vector3(); + var halfVector = new THREE.Vector3(); + + var localPoint = new THREE.Vector3(); + var reflectionVector = new THREE.Vector3(); + + var tmpVec = new THREE.Vector3(); + + var tmpColor = []; + + for ( var i = 0; i < maxRecursionDepth; i ++ ) { + + tmpColor[ i ] = new THREE.Color(); + + } + + return function spawnRay( rayOrigin, rayDirection, outputColor, recursionDepth ) { + + outputColor.setRGB( 0, 0, 0 ); + + // + + ray.origin = rayOrigin; + ray.direction = rayDirection; + + var intersections = raycaster.intersectObjects( objects, true ); + + // ray didn't find anything + // (here should come setting of background color?) + + if ( intersections.length === 0 ) return; + + // ray hit + + var intersection = intersections[ 0 ]; + + var point = intersection.point; + var object = intersection.object; + var material = object.material; + var face = intersection.face; + + var vertices = object.geometry.vertices; + + // + + var _object = cache[ object.id ]; + + eyeVector.subVectors( ray.origin, point ).normalize(); + + // resolve pixel diffuse color + + if ( material.isMeshLambertMaterial || + material.isMeshPhongMaterial || + material.isMeshBasicMaterial ) { + + diffuseColor.copyGammaToLinear( material.color ); + + } else { + + diffuseColor.setRGB( 1, 1, 1 ); + + } + + if ( material.vertexColors === THREE.FaceColors ) { + + diffuseColor.multiply( face.color ); + + } + + // compute light shading + + rayLight.origin.copy( point ); + + if ( material.isMeshBasicMaterial ) { + + for ( var i = 0, l = lights.length; i < l; i ++ ) { + + var light = lights[ i ]; + + lightVector.setFromMatrixPosition( light.matrixWorld ); + lightVector.sub( point ); + + rayLight.direction.copy( lightVector ).normalize(); + + var intersections = raycasterLight.intersectObjects( objects, true ); + + // point in shadow + + if ( intersections.length > 0 ) continue; + + // point visible + + outputColor.add( diffuseColor ); + + } + + } else if ( material.isMeshLambertMaterial || material.isMeshPhongMaterial ) { + + var normalComputed = false; + + for ( var i = 0, l = lights.length; i < l; i ++ ) { + + var light = lights[ i ]; + + lightVector.setFromMatrixPosition( light.matrixWorld ); + lightVector.sub( point ); + + rayLight.direction.copy( lightVector ).normalize(); + + var intersections = raycasterLight.intersectObjects( objects, true ); + + // point in shadow + + if ( intersections.length > 0 ) continue; + + // point lit + + if ( normalComputed === false ) { + + // the same normal can be reused for all lights + // (should be possible to cache even more) + + localPoint.copy( point ).applyMatrix4( _object.inverseMatrix ); + computePixelNormal( normalVector, localPoint, material.flatShading, face, vertices ); + normalVector.applyMatrix3( _object.normalMatrix ).normalize(); + + normalComputed = true; + + } + + lightColor.copyGammaToLinear( light.color ); + + // compute attenuation + + var attenuation = 1.0; + + if ( light.physicalAttenuation === true ) { + + attenuation = lightVector.length(); + attenuation = 1.0 / ( attenuation * attenuation ); + + } + + lightVector.normalize(); + + // compute diffuse + + var dot = Math.max( normalVector.dot( lightVector ), 0 ); + var diffuseIntensity = dot * light.intensity; + + lightContribution.copy( diffuseColor ); + lightContribution.multiply( lightColor ); + lightContribution.multiplyScalar( diffuseIntensity * attenuation ); + + outputColor.add( lightContribution ); + + // compute specular + + if ( material.isMeshPhongMaterial ) { + + halfVector.addVectors( lightVector, eyeVector ).normalize(); + + var dotNormalHalf = Math.max( normalVector.dot( halfVector ), 0.0 ); + var specularIntensity = Math.max( Math.pow( dotNormalHalf, material.shininess ), 0.0 ) * diffuseIntensity; + + var specularNormalization = ( material.shininess + 2.0 ) / 8.0; + + specularColor.copyGammaToLinear( material.specular ); + + var alpha = Math.pow( Math.max( 1.0 - lightVector.dot( halfVector ), 0.0 ), 5.0 ); + + schlick.r = specularColor.r + ( 1.0 - specularColor.r ) * alpha; + schlick.g = specularColor.g + ( 1.0 - specularColor.g ) * alpha; + schlick.b = specularColor.b + ( 1.0 - specularColor.b ) * alpha; + + lightContribution.copy( schlick ); + lightContribution.multiply( lightColor ); + lightContribution.multiplyScalar( specularNormalization * specularIntensity * attenuation ); + + outputColor.add( lightContribution ); + + } + + } + + } + + // reflection / refraction + + var reflectivity = material.reflectivity; + + if ( ( material.mirror || material.glass ) && reflectivity > 0 && recursionDepth < maxRecursionDepth ) { + + if ( material.mirror ) { + + reflectionVector.copy( rayDirection ); + reflectionVector.reflect( normalVector ); + + } else if ( material.glass ) { + + var eta = material.refractionRatio; + + var dotNI = rayDirection.dot( normalVector ); + var k = 1.0 - eta * eta * ( 1.0 - dotNI * dotNI ); + + if ( k < 0.0 ) { + + reflectionVector.set( 0, 0, 0 ); + + } else { + + reflectionVector.copy( rayDirection ); + reflectionVector.multiplyScalar( eta ); + + var alpha = eta * dotNI + Math.sqrt( k ); + tmpVec.copy( normalVector ); + tmpVec.multiplyScalar( alpha ); + reflectionVector.sub( tmpVec ); + + } + + } + + var theta = Math.max( eyeVector.dot( normalVector ), 0.0 ); + var rf0 = reflectivity; + var fresnel = rf0 + ( 1.0 - rf0 ) * Math.pow( ( 1.0 - theta ), 5.0 ); + + var weight = fresnel; + + var zColor = tmpColor[ recursionDepth ]; + + spawnRay( point, reflectionVector, zColor, recursionDepth + 1 ); + + if ( material.specular !== undefined ) { + + zColor.multiply( material.specular ); + + } + + zColor.multiplyScalar( weight ); + outputColor.multiplyScalar( 1 - weight ); + outputColor.add( zColor ); + + } + + }; + + }() ); + + var computePixelNormal = ( function () { + + var tmpVec1 = new THREE.Vector3(); + var tmpVec2 = new THREE.Vector3(); + var tmpVec3 = new THREE.Vector3(); + + return function computePixelNormal( outputVector, point, flatShading, face, vertices ) { + + var faceNormal = face.normal; + var vertexNormals = face.vertexNormals; + + if ( flatShading === true ) { + + outputVector.copy( faceNormal ); + + } else { + + // compute barycentric coordinates + + var vA = vertices[ face.a ]; + var vB = vertices[ face.b ]; + var vC = vertices[ face.c ]; + + tmpVec3.crossVectors( tmpVec1.subVectors( vB, vA ), tmpVec2.subVectors( vC, vA ) ); + var areaABC = faceNormal.dot( tmpVec3 ); + + tmpVec3.crossVectors( tmpVec1.subVectors( vB, point ), tmpVec2.subVectors( vC, point ) ); + var areaPBC = faceNormal.dot( tmpVec3 ); + var a = areaPBC / areaABC; + + tmpVec3.crossVectors( tmpVec1.subVectors( vC, point ), tmpVec2.subVectors( vA, point ) ); + var areaPCA = faceNormal.dot( tmpVec3 ); + var b = areaPCA / areaABC; + + var c = 1.0 - a - b; + + // compute interpolated vertex normal + + tmpVec1.copy( vertexNormals[ 0 ] ); + tmpVec1.multiplyScalar( a ); + + tmpVec2.copy( vertexNormals[ 1 ] ); + tmpVec2.multiplyScalar( b ); + + tmpVec3.copy( vertexNormals[ 2 ] ); + tmpVec3.multiplyScalar( c ); + + outputVector.addVectors( tmpVec1, tmpVec2 ); + outputVector.add( tmpVec3 ); + + } + + }; + + }() ); + + var renderBlock = ( function () { + + var blockSize = BLOCK; + + var data = new Uint8ClampedArray( blockSize * blockSize * 4 ); + + var pixelColor = new THREE.Color(); + + return function renderBlock( blockX, blockY ) { + + var index = 0; + + for ( var y = 0; y < blockSize; y ++ ) { + + for ( var x = 0; x < blockSize; x ++, index += 4 ) { + + // spawn primary ray at pixel position + + origin.copy( cameraPosition ); + + direction.set( x + blockX - canvasWidthHalf, - ( y + blockY - canvasHeightHalf ), - perspective ); + direction.applyMatrix3( cameraNormalMatrix ).normalize(); + + spawnRay( origin, direction, pixelColor, 0 ); + + // convert from linear to gamma + + data[ index + 0 ] = Math.sqrt( pixelColor.r ) * 255; + data[ index + 1 ] = Math.sqrt( pixelColor.g ) * 255; + data[ index + 2 ] = Math.sqrt( pixelColor.b ) * 255; + data[ index + 3 ] = 255; + + } + + } + + // Use transferable objects! :) + self.postMessage( { + data: data.buffer, + blockX: blockX, + blockY: blockY, + blockSize: blockSize, + sceneId: sceneId, + time: Date.now(), // time for this renderer + }, [ data.buffer ] ); + + data = new Uint8ClampedArray( blockSize * blockSize * 4 ); + + }; + + }() ); + + this.render = function ( scene, camera ) { + + // update scene graph + + if ( scene.autoUpdate === true ) scene.updateMatrixWorld(); + + // update camera matrices + + if ( camera.parent === null ) camera.updateMatrixWorld(); + + cameraPosition.setFromMatrixPosition( camera.matrixWorld ); + + // + + cameraNormalMatrix.getNormalMatrix( camera.matrixWorld ); + + perspective = 0.5 / Math.tan( THREE.Math.degToRad( camera.fov * 0.5 ) ) * canvasHeight; + + objects = scene.children; + + // collect lights and set up object matrices + + lights.length = 0; + + scene.traverse( function ( object ) { + + if ( object.isPointLight ) { + + lights.push( object ); + + } + + if ( cache[ object.id ] === undefined ) { + + cache[ object.id ] = { + normalMatrix: new THREE.Matrix3(), + inverseMatrix: new THREE.Matrix4() + }; + + } + + var _object = cache[ object.id ]; + + _object.normalMatrix.getNormalMatrix( object.matrixWorld ); + _object.inverseMatrix.getInverse( object.matrixWorld ); + + } ); + + renderBlock( startX, startY ); + + }; + +}; + +Object.assign( THREE.RaytracingRendererWorker.prototype, THREE.EventDispatcher.prototype ); diff --git a/three/jsutil/renderers/SVGRenderer.js b/three/jsutil/renderers/SVGRenderer.js new file mode 100644 index 000000000..05e4aa542 --- /dev/null +++ b/three/jsutil/renderers/SVGRenderer.js @@ -0,0 +1,505 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.SVGObject = function ( node ) { + + THREE.Object3D.call( this ); + + this.node = node; + +}; + +THREE.SVGObject.prototype = Object.create( THREE.Object3D.prototype ); +THREE.SVGObject.prototype.constructor = THREE.SVGObject; + +THREE.SVGRenderer = function () { + + console.log( 'THREE.SVGRenderer', THREE.REVISION ); + + var _this = this, + _renderData, _elements, _lights, + _projector = new THREE.Projector(), + _svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ), + _svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf, + + _v1, _v2, _v3, + + _clipBox = new THREE.Box2(), + _elemBox = new THREE.Box2(), + + _color = new THREE.Color(), + _diffuseColor = new THREE.Color(), + _ambientLight = new THREE.Color(), + _directionalLights = new THREE.Color(), + _pointLights = new THREE.Color(), + _clearColor = new THREE.Color(), + _clearAlpha = 1, + + _vector3 = new THREE.Vector3(), // Needed for PointLight + _centroid = new THREE.Vector3(), + _normal = new THREE.Vector3(), + _normalViewMatrix = new THREE.Matrix3(), + + _viewMatrix = new THREE.Matrix4(), + _viewProjectionMatrix = new THREE.Matrix4(), + + _svgPathPool = [], + _svgNode, _pathCount = 0, + + _currentPath, _currentStyle, + + _quality = 1, _precision = null; + + this.domElement = _svg; + + this.autoClear = true; + this.sortObjects = true; + this.sortElements = true; + + this.info = { + + render: { + + vertices: 0, + faces: 0 + + } + + }; + + this.setQuality = function ( quality ) { + + switch ( quality ) { + + case "high": _quality = 1; break; + case "low": _quality = 0; break; + + } + + }; + + this.setClearColor = function ( color, alpha ) { + + _clearColor.set( color ); + _clearAlpha = alpha !== undefined ? alpha : 1; + + }; + + this.setPixelRatio = function () {}; + + this.setSize = function ( width, height ) { + + _svgWidth = width; _svgHeight = height; + _svgWidthHalf = _svgWidth / 2; _svgHeightHalf = _svgHeight / 2; + + _svg.setAttribute( 'viewBox', ( - _svgWidthHalf ) + ' ' + ( - _svgHeightHalf ) + ' ' + _svgWidth + ' ' + _svgHeight ); + _svg.setAttribute( 'width', _svgWidth ); + _svg.setAttribute( 'height', _svgHeight ); + + _clipBox.min.set( - _svgWidthHalf, - _svgHeightHalf ); + _clipBox.max.set( _svgWidthHalf, _svgHeightHalf ); + + }; + + this.setPrecision = function ( precision ) { + + _precision = precision; + + }; + + function removeChildNodes() { + + _pathCount = 0; + + while ( _svg.childNodes.length > 0 ) { + + _svg.removeChild( _svg.childNodes[ 0 ] ); + + } + + } + + function getSvgColor( color, opacity ) { + + var arg = Math.floor( color.r * 255 ) + ',' + Math.floor( color.g * 255 ) + ',' + Math.floor( color.b * 255 ); + + if ( opacity === undefined || opacity === 1 ) return 'rgb(' + arg + ')'; + + return 'rgb(' + arg + '); fill-opacity: ' + opacity; + + } + + function convert( c ) { + + return _precision !== null ? c.toFixed( _precision ) : c; + + } + + this.clear = function () { + + removeChildNodes(); + _svg.style.backgroundColor = getSvgColor( _clearColor, _clearAlpha ); + + }; + + this.render = function ( scene, camera ) { + + if ( camera instanceof THREE.Camera === false ) { + + console.error( 'THREE.SVGRenderer.render: camera is not an instance of THREE.Camera.' ); + return; + + } + + var background = scene.background; + + if ( background && background.isColor ) { + + removeChildNodes(); + _svg.style.backgroundColor = getSvgColor( background ); + + } else if ( this.autoClear === true ) { + + this.clear(); + + } + + _this.info.render.vertices = 0; + _this.info.render.faces = 0; + + _viewMatrix.copy( camera.matrixWorldInverse ); + _viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix ); + + _renderData = _projector.projectScene( scene, camera, this.sortObjects, this.sortElements ); + _elements = _renderData.elements; + _lights = _renderData.lights; + + _normalViewMatrix.getNormalMatrix( camera.matrixWorldInverse ); + + calculateLights( _lights ); + + // reset accumulated path + + _currentPath = ''; + _currentStyle = ''; + + for ( var e = 0, el = _elements.length; e < el; e ++ ) { + + var element = _elements[ e ]; + var material = element.material; + + if ( material === undefined || material.opacity === 0 ) continue; + + _elemBox.makeEmpty(); + + if ( element instanceof THREE.RenderableSprite ) { + + _v1 = element; + _v1.x *= _svgWidthHalf; _v1.y *= - _svgHeightHalf; + + renderSprite( _v1, element, material ); + + } else if ( element instanceof THREE.RenderableLine ) { + + _v1 = element.v1; _v2 = element.v2; + + _v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf; + _v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf; + + _elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] ); + + if ( _clipBox.intersectsBox( _elemBox ) === true ) { + + renderLine( _v1, _v2, element, material ); + + } + + } else if ( element instanceof THREE.RenderableFace ) { + + _v1 = element.v1; _v2 = element.v2; _v3 = element.v3; + + if ( _v1.positionScreen.z < - 1 || _v1.positionScreen.z > 1 ) continue; + if ( _v2.positionScreen.z < - 1 || _v2.positionScreen.z > 1 ) continue; + if ( _v3.positionScreen.z < - 1 || _v3.positionScreen.z > 1 ) continue; + + _v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf; + _v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf; + _v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= - _svgHeightHalf; + + _elemBox.setFromPoints( [ + _v1.positionScreen, + _v2.positionScreen, + _v3.positionScreen + ] ); + + if ( _clipBox.intersectsBox( _elemBox ) === true ) { + + renderFace3( _v1, _v2, _v3, element, material ); + + } + + } + + } + + flushPath(); // just to flush last svg:path + + scene.traverseVisible( function ( object ) { + + if ( object instanceof THREE.SVGObject ) { + + _vector3.setFromMatrixPosition( object.matrixWorld ); + _vector3.applyMatrix4( _viewProjectionMatrix ); + + var x = _vector3.x * _svgWidthHalf; + var y = - _vector3.y * _svgHeightHalf; + + var node = object.node; + node.setAttribute( 'transform', 'translate(' + x + ',' + y + ')' ); + + _svg.appendChild( node ); + + } + + } ); + + }; + + function calculateLights( lights ) { + + _ambientLight.setRGB( 0, 0, 0 ); + _directionalLights.setRGB( 0, 0, 0 ); + _pointLights.setRGB( 0, 0, 0 ); + + for ( var l = 0, ll = lights.length; l < ll; l ++ ) { + + var light = lights[ l ]; + var lightColor = light.color; + + if ( light.isAmbientLight ) { + + _ambientLight.r += lightColor.r; + _ambientLight.g += lightColor.g; + _ambientLight.b += lightColor.b; + + } else if ( light.isDirectionalLight ) { + + _directionalLights.r += lightColor.r; + _directionalLights.g += lightColor.g; + _directionalLights.b += lightColor.b; + + } else if ( light.isPointLight ) { + + _pointLights.r += lightColor.r; + _pointLights.g += lightColor.g; + _pointLights.b += lightColor.b; + + } + + } + + } + + function calculateLight( lights, position, normal, color ) { + + for ( var l = 0, ll = lights.length; l < ll; l ++ ) { + + var light = lights[ l ]; + var lightColor = light.color; + + if ( light.isDirectionalLight ) { + + var lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld ).normalize(); + + var amount = normal.dot( lightPosition ); + + if ( amount <= 0 ) continue; + + amount *= light.intensity; + + color.r += lightColor.r * amount; + color.g += lightColor.g * amount; + color.b += lightColor.b * amount; + + } else if ( light.isPointLight ) { + + var lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld ); + + var amount = normal.dot( _vector3.subVectors( lightPosition, position ).normalize() ); + + if ( amount <= 0 ) continue; + + amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 ); + + if ( amount == 0 ) continue; + + amount *= light.intensity; + + color.r += lightColor.r * amount; + color.g += lightColor.g * amount; + color.b += lightColor.b * amount; + + } + + } + + } + + function renderSprite( v1, element, material ) { + + var scaleX = element.scale.x * _svgWidthHalf; + var scaleY = element.scale.y * _svgHeightHalf; + + if ( material.isPointsMaterial ) { + + scaleX *= material.size; + scaleY *= material.size; + + } + + var path = 'M' + convert( v1.x - scaleX * 0.5 ) + ',' + convert( v1.y - scaleY * 0.5 ) + 'h' + convert( scaleX ) + 'v' + convert( scaleY ) + 'h' + convert( - scaleX ) + 'z'; + var style = ""; + + if ( material.isSpriteMaterial || material.isPointsMaterial ) { + + style = 'fill:' + getSvgColor( material.color, material.opacity ); + + } + + addPath( style, path ); + + } + + function renderLine( v1, v2, element, material ) { + + var path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y ); + + if ( material.isLineBasicMaterial ) { + + var style = 'fill:none;stroke:' + getSvgColor( material.color, material.opacity ) + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap; + + if ( material.isLineDashedMaterial ) { + + style = style + ';stroke-dasharray:' + material.dashSize + "," + material.gapSize; + + } + + addPath( style, path ); + + } + + } + + function renderFace3( v1, v2, v3, element, material ) { + + _this.info.render.vertices += 3; + _this.info.render.faces ++; + + var path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y ) + 'L' + convert( v3.positionScreen.x ) + ',' + convert( v3.positionScreen.y ) + 'z'; + var style = ''; + + if ( material.isMeshBasicMaterial ) { + + _color.copy( material.color ); + + if ( material.vertexColors === THREE.FaceColors ) { + + _color.multiply( element.color ); + + } + + } else if ( material.isMeshLambertMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial ) { + + _diffuseColor.copy( material.color ); + + if ( material.vertexColors === THREE.FaceColors ) { + + _diffuseColor.multiply( element.color ); + + } + + _color.copy( _ambientLight ); + + _centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 ); + + calculateLight( _lights, _centroid, element.normalModel, _color ); + + _color.multiply( _diffuseColor ).add( material.emissive ); + + } else if ( material.isMeshNormalMaterial ) { + + _normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix ); + + _color.setRGB( _normal.x, _normal.y, _normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 ); + + } + + if ( material.wireframe ) { + + style = 'fill:none;stroke:' + getSvgColor( _color, material.opacity ) + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin; + + } else { + + style = 'fill:' + getSvgColor( _color, material.opacity ); + + } + + addPath( style, path ); + + } + + function addPath( style, path ) { + + if ( _currentStyle === style ) { + + _currentPath += path; + + } else { + + flushPath(); + + _currentStyle = style; + _currentPath = path; + + } + + } + + function flushPath() { + + if ( _currentPath ) { + + _svgNode = getPathNode( _pathCount ++ ); + _svgNode.setAttribute( 'd', _currentPath ); + _svgNode.setAttribute( 'style', _currentStyle ); + _svg.appendChild( _svgNode ); + + } + + _currentPath = ''; + _currentStyle = ''; + + } + + function getPathNode( id ) { + + if ( _svgPathPool[ id ] == null ) { + + _svgPathPool[ id ] = document.createElementNS( 'http://www.w3.org/2000/svg', 'path' ); + + if ( _quality == 0 ) { + + _svgPathPool[ id ].setAttribute( 'shape-rendering', 'crispEdges' ); //optimizeSpeed + + } + + return _svgPathPool[ id ]; + + } + + return _svgPathPool[ id ]; + + } + +}; diff --git a/three/jsutil/renderers/SoftwareRenderer.js b/three/jsutil/renderers/SoftwareRenderer.js new file mode 100644 index 000000000..35495b961 --- /dev/null +++ b/three/jsutil/renderers/SoftwareRenderer.js @@ -0,0 +1,1556 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author ryg / http://farbrausch.de/~fg + * @author mraleph / http://mrale.ph/ + * @author daoshengmu / http://dsmu.me/ + */ + +THREE.SoftwareRenderer = function ( parameters ) { + + console.log( 'THREE.SoftwareRenderer', THREE.REVISION ); + + parameters = parameters || {}; + + var canvas = parameters.canvas !== undefined + ? parameters.canvas + : document.createElement( 'canvas' ); + + var context = canvas.getContext( '2d', { + alpha: parameters.alpha === true + } ); + + var shaders = {}; + var textures = {}; + + var canvasWidth, canvasHeight; + var canvasWBlocks, canvasHBlocks; + var viewportXScale, viewportYScale, viewportZScale; + var viewportXOffs, viewportYOffs, viewportZOffs; + + var clearColor = new THREE.Color( 0x000000 ); + var clearAlpha = parameters.alpha === true ? 0 : 1; + + var imagedata, data, zbuffer; + var numBlocks, blockMaxZ, blockFlags; + + var BLOCK_ISCLEAR = ( 1 << 0 ); + var BLOCK_NEEDCLEAR = ( 1 << 1 ); + + var subpixelBits = 4; + var subpixelBias = ( 1 << subpixelBits ) - 1; + var blockShift = 3; + var blockSize = 1 << blockShift; + var maxZVal = ( 1 << 24 ); // Note: You want to size this so you don't get overflows. + var lineMode = false; + var lookVector = new THREE.Vector3( 0, 0, 1 ); + var crossVector = new THREE.Vector3(); + + var rectx1 = Infinity, recty1 = Infinity; + var rectx2 = 0, recty2 = 0; + + var prevrectx1 = Infinity, prevrecty1 = Infinity; + var prevrectx2 = 0, prevrecty2 = 0; + + var projector = new THREE.Projector(); + + var spriteV1 = new THREE.Vector4(); + var spriteV2 = new THREE.Vector4(); + var spriteV3 = new THREE.Vector4(); + + var spriteUV1 = new THREE.Vector2(); + var spriteUV2 = new THREE.Vector2(); + var spriteUV3 = new THREE.Vector2(); + + var mpVPool = []; + var mpVPoolCount = 0; + var mpNPool = []; + var mpNPoolCount = 0; + var mpUVPool = []; + var mpUVPoolCount = 0; + + var _this = this; + + this.domElement = canvas; + + this.autoClear = true; + + this.setClearColor = function ( color, alpha ) { + + clearColor.set( color ); + clearAlpha = alpha; + clearColorBuffer( clearColor ); + + }; + + this.setPixelRatio = function () {}; + + this.setSize = function ( width, height ) { + + canvasWBlocks = Math.floor( width / blockSize ); + canvasHBlocks = Math.floor( height / blockSize ); + canvasWidth = canvasWBlocks * blockSize; + canvasHeight = canvasHBlocks * blockSize; + + var fixScale = 1 << subpixelBits; + + viewportXScale = fixScale * canvasWidth / 2; + viewportYScale = - fixScale * canvasHeight / 2; + viewportZScale = maxZVal / 2; + + viewportXOffs = fixScale * canvasWidth / 2 + 0.5; + viewportYOffs = fixScale * canvasHeight / 2 + 0.5; + viewportZOffs = maxZVal / 2 + 0.5; + + canvas.width = canvasWidth; + canvas.height = canvasHeight; + + imagedata = context.getImageData( 0, 0, canvasWidth, canvasHeight ); + data = imagedata.data; + + zbuffer = new Int32Array( data.length / 4 ); + + numBlocks = canvasWBlocks * canvasHBlocks; + blockMaxZ = new Int32Array( numBlocks ); + blockFlags = new Uint8Array( numBlocks ); + + for ( var i = 0, l = zbuffer.length; i < l; i ++ ) { + + zbuffer[ i ] = maxZVal; + + } + + for ( var i = 0; i < numBlocks; i ++ ) { + + blockFlags[ i ] = BLOCK_ISCLEAR; + + } + + clearColorBuffer( clearColor ); + + }; + + this.clear = function () { + + rectx1 = Infinity; + recty1 = Infinity; + rectx2 = 0; + recty2 = 0; + mpVPoolCount = 0; + mpNPoolCount = 0; + mpUVPoolCount = 0; + + for ( var i = 0; i < numBlocks; i ++ ) { + + blockMaxZ[ i ] = maxZVal; + blockFlags[ i ] = ( blockFlags[ i ] & BLOCK_ISCLEAR ) ? BLOCK_ISCLEAR : BLOCK_NEEDCLEAR; + + } + + }; + + + this.render = function ( scene, camera ) { + + // TODO: Check why autoClear can't be false. + this.clear(); + + var background = scene.background; + + if ( background && background.isColor ) { + + clearColorBuffer( background ); + + } + + var renderData = projector.projectScene( scene, camera, false, false ); + var elements = renderData.elements; + + for ( var e = 0, el = elements.length; e < el; e ++ ) { + + var element = elements[ e ]; + var material = element.material; + var shader = getMaterialShader( material ); + + if ( ! shader ) continue; + + if ( element instanceof THREE.RenderableFace ) { + + if ( ! element.uvs ) { + + drawTriangle( + element.v1.positionScreen, + element.v2.positionScreen, + element.v3.positionScreen, + null, null, null, + shader, element, material + ); + + } else { + + drawTriangle( + element.v1.positionScreen, + element.v2.positionScreen, + element.v3.positionScreen, + element.uvs[ 0 ], element.uvs[ 1 ], element.uvs[ 2 ], + shader, element, material + ); + + } + + + } else if ( element instanceof THREE.RenderableSprite ) { + + var scaleX = element.scale.x * 0.5; + var scaleY = element.scale.y * 0.5; + + spriteV1.copy( element ); + spriteV1.x -= scaleX; + spriteV1.y += scaleY; + + spriteV2.copy( element ); + spriteV2.x -= scaleX; + spriteV2.y -= scaleY; + + spriteV3.copy( element ); + spriteV3.x += scaleX; + spriteV3.y += scaleY; + + if ( material.map ) { + + spriteUV1.set( 0, 1 ); + spriteUV2.set( 0, 0 ); + spriteUV3.set( 1, 1 ); + + drawTriangle( + spriteV1, spriteV2, spriteV3, + spriteUV1, spriteUV2, spriteUV3, + shader, element, material + ); + + } else { + + drawTriangle( + spriteV1, spriteV2, spriteV3, + null, null, null, + shader, element, material + ); + + } + + spriteV1.copy( element ); + spriteV1.x += scaleX; + spriteV1.y += scaleY; + + spriteV2.copy( element ); + spriteV2.x -= scaleX; + spriteV2.y -= scaleY; + + spriteV3.copy( element ); + spriteV3.x += scaleX; + spriteV3.y -= scaleY; + + if ( material.map ) { + + spriteUV1.set( 1, 1 ); + spriteUV2.set( 0, 0 ); + spriteUV3.set( 1, 0 ); + + drawTriangle( + spriteV1, spriteV2, spriteV3, + spriteUV1, spriteUV2, spriteUV3, + shader, element, material + ); + + } else { + + drawTriangle( + spriteV1, spriteV2, spriteV3, + null, null, null, + shader, element, material + ); + + } + + } else if ( element instanceof THREE.RenderableLine ) { + + var shader = getMaterialShader( material ); + + drawLine( + element.v1.positionScreen, + element.v2.positionScreen, + element.vertexColors[ 0 ], + element.vertexColors[ 1 ], + shader, + material + ); + + } + + } + + finishClear(); + + var x = Math.min( rectx1, prevrectx1 ); + var y = Math.min( recty1, prevrecty1 ); + var width = Math.max( rectx2, prevrectx2 ) - x; + var height = Math.max( recty2, prevrecty2 ) - y; + + /* + // debug; draw zbuffer + + for ( var i = 0, l = zbuffer.length; i < l; i++ ) { + + var o = i * 4; + var v = (65535 - zbuffer[ i ]) >> 3; + data[ o + 0 ] = v; + data[ o + 1 ] = v; + data[ o + 2 ] = v; + data[ o + 3 ] = 255; + } + */ + + if ( x !== Infinity ) { + + context.putImageData( imagedata, 0, 0, x, y, width, height ); + + } + + prevrectx1 = rectx1; prevrecty1 = recty1; + prevrectx2 = rectx2; prevrecty2 = recty2; + + }; + + function getAlpha() { + + return parameters.alpha === true ? clearAlpha : 1; + + } + + function clearColorBuffer( color ) { + + var size = canvasWidth * canvasHeight * 4; + + for ( var i = 0; i < size; i += 4 ) { + + data[ i ] = color.r * 255 | 0; + data[ i + 1 ] = color.g * 255 | 0; + data[ i + 2 ] = color.b * 255 | 0; + data[ i + 3 ] = getAlpha() * 255 | 0; + + } + + context.fillStyle = 'rgba(' + ( ( clearColor.r * 255 ) | 0 ) + ',' + ( ( clearColor.g * 255 ) | 0 ) + ',' + ( ( clearColor.b * 255 ) | 0 ) + ',' + getAlpha() + ')'; + context.fillRect( 0, 0, canvasWidth, canvasHeight ); + + } + + function getPalette( material, bSimulateSpecular ) { + + var i = 0, j = 0; + var diffuseR = material.color.r * 255; + var diffuseG = material.color.g * 255; + var diffuseB = material.color.b * 255; + var palette = new Uint8Array( 256 * 3 ); + + if ( bSimulateSpecular ) { + + while ( i < 204 ) { + + palette[ j ++ ] = Math.min( i * diffuseR / 204, 255 ); + palette[ j ++ ] = Math.min( i * diffuseG / 204, 255 ); + palette[ j ++ ] = Math.min( i * diffuseB / 204, 255 ); + ++ i; + + } + + while ( i < 256 ) { + + // plus specular highlight + palette[ j ++ ] = Math.min( diffuseR + ( i - 204 ) * ( 255 - diffuseR ) / 82, 255 ); + palette[ j ++ ] = Math.min( diffuseG + ( i - 204 ) * ( 255 - diffuseG ) / 82, 255 ); + palette[ j ++ ] = Math.min( diffuseB + ( i - 204 ) * ( 255 - diffuseB ) / 82, 255 ); + ++ i; + + } + + } else { + + while ( i < 256 ) { + + palette[ j ++ ] = Math.min( i * diffuseR / 255, 255 ); + palette[ j ++ ] = Math.min( i * diffuseG / 255, 255 ); + palette[ j ++ ] = Math.min( i * diffuseB / 255, 255 ); + ++ i; + + } + + } + + return palette; + + } + + function basicMaterialShader( buffer, depthBuf, offset, depth, u, v, n, face, material ) { + + var colorOffset = offset * 4; + + var texture = textures[ material.map.id ]; + + if ( ! texture.data ) return; + + var tdim = texture.width; + var isTransparent = material.transparent; + var tbound = tdim - 1; + var tdata = texture.data; + var tIndex = ( ( ( v * tdim ) & tbound ) * tdim + ( ( u * tdim ) & tbound ) ) * 4; + + if ( ! isTransparent ) { + + buffer[ colorOffset ] = tdata[ tIndex ]; + buffer[ colorOffset + 1 ] = tdata[ tIndex + 1 ]; + buffer[ colorOffset + 2 ] = tdata[ tIndex + 2 ]; + buffer[ colorOffset + 3 ] = ( material.opacity << 8 ) - 1; + depthBuf[ offset ] = depth; + + } else { + + var srcR = tdata[ tIndex ]; + var srcG = tdata[ tIndex + 1 ]; + var srcB = tdata[ tIndex + 2 ]; + var opaci = tdata[ tIndex + 3 ] * material.opacity / 255; + var destR = buffer[ colorOffset ]; + var destG = buffer[ colorOffset + 1 ]; + var destB = buffer[ colorOffset + 2 ]; + + buffer[ colorOffset ] = ( srcR * opaci + destR * ( 1 - opaci ) ); + buffer[ colorOffset + 1 ] = ( srcG * opaci + destG * ( 1 - opaci ) ); + buffer[ colorOffset + 2 ] = ( srcB * opaci + destB * ( 1 - opaci ) ); + buffer[ colorOffset + 3 ] = ( material.opacity << 8 ) - 1; + + // Only opaue pixls write to the depth buffer + + if ( buffer[ colorOffset + 3 ] == 255 ) depthBuf[ offset ] = depth; + + } + + } + + function lightingMaterialShader( buffer, depthBuf, offset, depth, u, v, n, face, material ) { + + var colorOffset = offset * 4; + + var texture = textures[ material.map.id ]; + + if ( ! texture.data ) return; + + var tdim = texture.width; + var isTransparent = material.transparent; + var cIndex = ( n > 0 ? ( ~ ~ n ) : 0 ) * 3; + var tbound = tdim - 1; + var tdata = texture.data; + var tIndex = ( ( ( v * tdim ) & tbound ) * tdim + ( ( u * tdim ) & tbound ) ) * 4; + + if ( ! isTransparent ) { + + buffer[ colorOffset ] = ( material.palette[ cIndex ] * tdata[ tIndex ] ) >> 8; + buffer[ colorOffset + 1 ] = ( material.palette[ cIndex + 1 ] * tdata[ tIndex + 1 ] ) >> 8; + buffer[ colorOffset + 2 ] = ( material.palette[ cIndex + 2 ] * tdata[ tIndex + 2 ] ) >> 8; + buffer[ colorOffset + 3 ] = ( material.opacity << 8 ) - 1; + depthBuf[ offset ] = depth; + + } else { + + var foreColorR = material.palette[ cIndex ] * tdata[ tIndex ]; + var foreColorG = material.palette[ cIndex + 1 ] * tdata[ tIndex + 1 ]; + var foreColorB = material.palette[ cIndex + 2 ] * tdata[ tIndex + 2 ]; + var opaci = tdata[ tIndex + 3 ] * material.opacity / 256; + var destR = buffer[ colorOffset ]; + var destG = buffer[ colorOffset + 1 ]; + var destB = buffer[ colorOffset + 2 ]; + + buffer[ colorOffset ] = foreColorR * opaci + destR * ( 1 - opaci ); + buffer[ colorOffset + 1 ] = foreColorG * opaci + destG * ( 1 - opaci ); + buffer[ colorOffset + 2 ] = foreColorB * opaci + destB * ( 1 - opaci ); + buffer[ colorOffset + 3 ] = ( material.opacity << 8 ) - 1; + + // Only opaue pixls write to the depth buffer + + if ( buffer[ colorOffset + 3 ] == 255 ) depthBuf[ offset ] = depth; + + } + + } + + function getMaterialShader( material ) { + + var id = material.id; + var shader = shaders[ id ]; + + if ( shader && material.map && ! textures[ material.map.id ] ) delete shaders[ id ]; + + if ( shaders[ id ] === undefined || material.needsUpdate === true ) { + + if ( material instanceof THREE.MeshBasicMaterial || + material instanceof THREE.MeshLambertMaterial || + material instanceof THREE.MeshPhongMaterial || + material instanceof THREE.SpriteMaterial ) { + + if ( material instanceof THREE.MeshLambertMaterial ) { + + // Generate color palette + if ( ! material.palette ) { + + material.palette = getPalette( material, false ); + + } + + } else if ( material instanceof THREE.MeshPhongMaterial ) { + + // Generate color palette + if ( ! material.palette ) { + + material.palette = getPalette( material, true ); + + } + + } + + var string; + + if ( material.map ) { + + var texture = new THREE.SoftwareRenderer.Texture(); + texture.fromImage( material.map.image ); + + if ( ! texture.data ) return; + + textures[ material.map.id ] = texture; + + if ( material instanceof THREE.MeshBasicMaterial + || material instanceof THREE.SpriteMaterial ) { + + shader = basicMaterialShader; + + } else { + + shader = lightingMaterialShader; + + } + + + } else { + + if ( material.vertexColors === THREE.FaceColors ) { + + string = [ + 'var colorOffset = offset * 4;', + 'buffer[ colorOffset ] = face.color.r * 255;', + 'buffer[ colorOffset + 1 ] = face.color.g * 255;', + 'buffer[ colorOffset + 2 ] = face.color.b * 255;', + 'buffer[ colorOffset + 3 ] = material.opacity * 255;', + 'depthBuf[ offset ] = depth;' + ].join( '\n' ); + + } else { + + string = [ + 'var colorOffset = offset * 4;', + 'buffer[ colorOffset ] = material.color.r * 255;', + 'buffer[ colorOffset + 1 ] = material.color.g * 255;', + 'buffer[ colorOffset + 2 ] = material.color.b * 255;', + 'buffer[ colorOffset + 3 ] = material.opacity * 255;', + 'depthBuf[ offset ] = depth;' + ].join( '\n' ); + + } + + shader = new Function( 'buffer, depthBuf, offset, depth, u, v, n, face, material', string ); + + } + + } else if ( material instanceof THREE.LineBasicMaterial ) { + + var string = [ + 'var colorOffset = offset * 4;', + 'buffer[ colorOffset ] = material.color.r * (color1.r+color2.r) * 0.5 * 255;', + 'buffer[ colorOffset + 1 ] = material.color.g * (color1.g+color2.g) * 0.5 * 255;', + 'buffer[ colorOffset + 2 ] = material.color.b * (color1.b+color2.b) * 0.5 * 255;', + 'buffer[ colorOffset + 3 ] = 255;', + 'depthBuf[ offset ] = depth;' + ].join( '\n' ); + + shader = new Function( 'buffer, depthBuf, offset, depth, color1, color2, material', string ); + + } else { + + var string = [ + 'var colorOffset = offset * 4;', + 'buffer[ colorOffset ] = u * 255;', + 'buffer[ colorOffset + 1 ] = v * 255;', + 'buffer[ colorOffset + 2 ] = 0;', + 'buffer[ colorOffset + 3 ] = 255;', + 'depthBuf[ offset ] = depth;' + ].join( '\n' ); + + shader = new Function( 'buffer, depthBuf, offset, depth, u, v, n, face, material', string ); + + } + + shaders[ id ] = shader; + + material.needsUpdate = false; + + } + + return shader; + + } + + /* + function clearRectangle( x1, y1, x2, y2 ) { + + var xmin = Math.max( Math.min( x1, x2 ), 0 ); + var xmax = Math.min( Math.max( x1, x2 ), canvasWidth ); + var ymin = Math.max( Math.min( y1, y2 ), 0 ); + var ymax = Math.min( Math.max( y1, y2 ), canvasHeight ); + + var offset = ( xmin + ymin * canvasWidth ) * 4 + 3; + var linestep = ( canvasWidth - ( xmax - xmin ) ) * 4; + + for ( var y = ymin; y < ymax; y ++ ) { + + for ( var x = xmin; x < xmax; x ++ ) { + + data[ offset += 4 ] = 0; + + } + + offset += linestep; + + } + + } + */ + + function drawTriangle( v1, v2, v3, uv1, uv2, uv3, shader, face, material ) { + + // TODO: Implement per-pixel z-clipping + + if ( v1.z < - 1 || v1.z > 1 || v2.z < - 1 || v2.z > 1 || v3.z < - 1 || v3.z > 1 ) return; + + // https://gist.github.com/2486101 + // explanation: http://pouet.net/topic.php?which=8760&page=1 + + var fixscale = ( 1 << subpixelBits ); + + // 28.4 fixed-point coordinates + + var x1 = ( v1.x * viewportXScale + viewportXOffs ) | 0; + var x2 = ( v2.x * viewportXScale + viewportXOffs ) | 0; + var x3 = ( v3.x * viewportXScale + viewportXOffs ) | 0; + + var y1 = ( v1.y * viewportYScale + viewportYOffs ) | 0; + var y2 = ( v2.y * viewportYScale + viewportYOffs ) | 0; + var y3 = ( v3.y * viewportYScale + viewportYOffs ) | 0; + + var bHasNormal = face.vertexNormalsModel && face.vertexNormalsModel.length; + var bHasUV = uv1 && uv2 && uv3; + + var longestSide = Math.max( + Math.sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ), + Math.sqrt( ( x2 - x3 ) * ( x2 - x3 ) + ( y2 - y3 ) * ( y2 - y3 ) ), + Math.sqrt( ( x3 - x1 ) * ( x3 - x1 ) + ( y3 - y1 ) * ( y3 - y1 ) ) + ); + + if ( ! ( face instanceof THREE.RenderableSprite ) && ( longestSide > 100 * fixscale ) ) { + + // 1 + // |\ + // |a\ + // |__\ + // |\c|\ + // |b\|d\ + // |__\__\ + // 2 3 + var tempFace = { vertexNormalsModel: [], color: face.color }; + var mpUV12, mpUV23, mpUV31; + + if ( bHasUV ) { + + if ( mpUVPoolCount === mpUVPool.length ) { + + mpUV12 = new THREE.Vector2(); + mpUVPool.push( mpUV12 ); + ++ mpUVPoolCount; + + mpUV23 = new THREE.Vector2(); + mpUVPool.push( mpUV23 ); + ++ mpUVPoolCount; + + mpUV31 = new THREE.Vector2(); + mpUVPool.push( mpUV31 ); + ++ mpUVPoolCount; + + } else { + + mpUV12 = mpUVPool[ mpUVPoolCount ]; + ++ mpUVPoolCount; + + mpUV23 = mpUVPool[ mpUVPoolCount ]; + ++ mpUVPoolCount; + + mpUV31 = mpUVPool[ mpUVPoolCount ]; + ++ mpUVPoolCount; + + } + + var weight; + + weight = ( 1 + v2.z ) * ( v2.w / v1.w ) / ( 1 + v1.z ); + mpUV12.copy( uv1 ).multiplyScalar( weight ).add( uv2 ).multiplyScalar( 1 / ( weight + 1 ) ); + + weight = ( 1 + v3.z ) * ( v3.w / v2.w ) / ( 1 + v2.z ); + mpUV23.copy( uv2 ).multiplyScalar( weight ).add( uv3 ).multiplyScalar( 1 / ( weight + 1 ) ); + + weight = ( 1 + v1.z ) * ( v1.w / v3.w ) / ( 1 + v3.z ); + mpUV31.copy( uv3 ).multiplyScalar( weight ).add( uv1 ).multiplyScalar( 1 / ( weight + 1 ) ); + + } + + var mpV12, mpV23, mpV31; + + if ( mpVPoolCount === mpVPool.length ) { + + mpV12 = new THREE.Vector4(); + mpVPool.push( mpV12 ); + ++ mpVPoolCount; + + mpV23 = new THREE.Vector4(); + mpVPool.push( mpV23 ); + ++ mpVPoolCount; + + mpV31 = new THREE.Vector4(); + mpVPool.push( mpV31 ); + ++ mpVPoolCount; + + } else { + + mpV12 = mpVPool[ mpVPoolCount ]; + ++ mpVPoolCount; + + mpV23 = mpVPool[ mpVPoolCount ]; + ++ mpVPoolCount; + + mpV31 = mpVPool[ mpVPoolCount ]; + ++ mpVPoolCount; + + } + + mpV12.copy( v1 ).add( v2 ).multiplyScalar( 0.5 ); + mpV23.copy( v2 ).add( v3 ).multiplyScalar( 0.5 ); + mpV31.copy( v3 ).add( v1 ).multiplyScalar( 0.5 ); + + var mpN12, mpN23, mpN31; + + if ( bHasNormal ) { + + if ( mpNPoolCount === mpNPool.length ) { + + mpN12 = new THREE.Vector3(); + mpNPool.push( mpN12 ); + ++ mpNPoolCount; + + mpN23 = new THREE.Vector3(); + mpNPool.push( mpN23 ); + ++ mpNPoolCount; + + mpN31 = new THREE.Vector3(); + mpNPool.push( mpN31 ); + ++ mpNPoolCount; + + } else { + + mpN12 = mpNPool[ mpNPoolCount ]; + ++ mpNPoolCount; + + mpN23 = mpNPool[ mpNPoolCount ]; + ++ mpNPoolCount; + + mpN31 = mpNPool[ mpNPoolCount ]; + ++ mpNPoolCount; + + } + + mpN12.copy( face.vertexNormalsModel[ 0 ] ).add( face.vertexNormalsModel[ 1 ] ).normalize(); + mpN23.copy( face.vertexNormalsModel[ 1 ] ).add( face.vertexNormalsModel[ 2 ] ).normalize(); + mpN31.copy( face.vertexNormalsModel[ 2 ] ).add( face.vertexNormalsModel[ 0 ] ).normalize(); + + } + + // a + if ( bHasNormal ) { + + tempFace.vertexNormalsModel[ 0 ] = face.vertexNormalsModel[ 0 ]; + tempFace.vertexNormalsModel[ 1 ] = mpN12; + tempFace.vertexNormalsModel[ 2 ] = mpN31; + + } + + drawTriangle( v1, mpV12, mpV31, uv1, mpUV12, mpUV31, shader, tempFace, material ); + + // b + if ( bHasNormal ) { + + tempFace.vertexNormalsModel[ 0 ] = face.vertexNormalsModel[ 1 ]; + tempFace.vertexNormalsModel[ 1 ] = mpN23; + tempFace.vertexNormalsModel[ 2 ] = mpN12; + + } + + drawTriangle( v2, mpV23, mpV12, uv2, mpUV23, mpUV12, shader, tempFace, material ); + + // c + if ( bHasNormal ) { + + tempFace.vertexNormalsModel[ 0 ] = mpN12; + tempFace.vertexNormalsModel[ 1 ] = mpN23; + tempFace.vertexNormalsModel[ 2 ] = mpN31; + + } + + drawTriangle( mpV12, mpV23, mpV31, mpUV12, mpUV23, mpUV31, shader, tempFace, material ); + + // d + if ( bHasNormal ) { + + tempFace.vertexNormalsModel[ 0 ] = face.vertexNormalsModel[ 2 ]; + tempFace.vertexNormalsModel[ 1 ] = mpN31; + tempFace.vertexNormalsModel[ 2 ] = mpN23; + + } + + drawTriangle( v3, mpV31, mpV23, uv3, mpUV31, mpUV23, shader, tempFace, material ); + + return; + + } + + // Z values (.28 fixed-point) + + var z1 = ( v1.z * viewportZScale + viewportZOffs ) | 0; + var z2 = ( v2.z * viewportZScale + viewportZOffs ) | 0; + var z3 = ( v3.z * viewportZScale + viewportZOffs ) | 0; + + // UV values + var bHasUV = false; + var tu1, tv1, tu2, tv2, tu3, tv3; + + if ( uv1 && uv2 && uv3 ) { + + bHasUV = true; + + tu1 = uv1.x; + tv1 = 1 - uv1.y; + tu2 = uv2.x; + tv2 = 1 - uv2.y; + tu3 = uv3.x; + tv3 = 1 - uv3.y; + + } + + // Normal values + var n1, n2, n3, nz1, nz2, nz3; + + if ( bHasNormal ) { + + n1 = face.vertexNormalsModel[ 0 ]; + n2 = face.vertexNormalsModel[ 1 ]; + n3 = face.vertexNormalsModel[ 2 ]; + nz1 = n1.z * 255; + nz2 = n2.z * 255; + nz3 = n3.z * 255; + + } + + // Deltas + + var dx12 = x1 - x2, dy12 = y2 - y1; + var dx23 = x2 - x3, dy23 = y3 - y2; + var dx31 = x3 - x1, dy31 = y1 - y3; + + // Bounding rectangle + + var minx = Math.max( ( Math.min( x1, x2, x3 ) + subpixelBias ) >> subpixelBits, 0 ); + var maxx = Math.min( ( Math.max( x1, x2, x3 ) + subpixelBias ) >> subpixelBits, canvasWidth ); + var miny = Math.max( ( Math.min( y1, y2, y3 ) + subpixelBias ) >> subpixelBits, 0 ); + var maxy = Math.min( ( Math.max( y1, y2, y3 ) + subpixelBias ) >> subpixelBits, canvasHeight ); + + rectx1 = Math.min( minx, rectx1 ); + rectx2 = Math.max( maxx, rectx2 ); + recty1 = Math.min( miny, recty1 ); + recty2 = Math.max( maxy, recty2 ); + + // Block size, standard 8x8 (must be power of two) + + var q = blockSize; + + // Start in corner of 8x8 block + + minx &= ~ ( q - 1 ); + miny &= ~ ( q - 1 ); + + // Constant part of half-edge functions + + var minXfixscale = ( minx << subpixelBits ); + var minYfixscale = ( miny << subpixelBits ); + + var c1 = dy12 * ( ( minXfixscale ) - x1 ) + dx12 * ( ( minYfixscale ) - y1 ); + var c2 = dy23 * ( ( minXfixscale ) - x2 ) + dx23 * ( ( minYfixscale ) - y2 ); + var c3 = dy31 * ( ( minXfixscale ) - x3 ) + dx31 * ( ( minYfixscale ) - y3 ); + + // Correct for fill convention + + if ( dy12 > 0 || ( dy12 == 0 && dx12 > 0 ) ) c1 ++; + if ( dy23 > 0 || ( dy23 == 0 && dx23 > 0 ) ) c2 ++; + if ( dy31 > 0 || ( dy31 == 0 && dx31 > 0 ) ) c3 ++; + + // Note this doesn't kill subpixel precision, but only because we test for >=0 (not >0). + // It's a bit subtle. :) + c1 = ( c1 - 1 ) >> subpixelBits; + c2 = ( c2 - 1 ) >> subpixelBits; + c3 = ( c3 - 1 ) >> subpixelBits; + + // Z interpolation setup + + var dz12 = z1 - z2, dz31 = z3 - z1; + var invDet = 1.0 / ( dx12 * dy31 - dx31 * dy12 ); + var dzdx = ( invDet * ( dz12 * dy31 - dz31 * dy12 ) ); // dz per one subpixel step in x + var dzdy = ( invDet * ( dz12 * dx31 - dx12 * dz31 ) ); // dz per one subpixel step in y + + // Z at top/left corner of rast area + + var cz = ( z1 + ( ( minXfixscale ) - x1 ) * dzdx + ( ( minYfixscale ) - y1 ) * dzdy ) | 0; + + // Z pixel steps + + dzdx = ( dzdx * fixscale ) | 0; + dzdy = ( dzdy * fixscale ) | 0; + + var dtvdx, dtvdy, cbtu, cbtv; + if ( bHasUV ) { + + // UV interpolation setup + var dtu12 = tu1 - tu2, dtu31 = tu3 - tu1; + var dtudx = ( invDet * ( dtu12 * dy31 - dtu31 * dy12 ) ); // dtu per one subpixel step in x + var dtudy = ( invDet * ( dtu12 * dx31 - dx12 * dtu31 ) ); // dtu per one subpixel step in y + var dtv12 = tv1 - tv2, dtv31 = tv3 - tv1; + dtvdx = ( invDet * ( dtv12 * dy31 - dtv31 * dy12 ) ); // dtv per one subpixel step in x + dtvdy = ( invDet * ( dtv12 * dx31 - dx12 * dtv31 ) ); // dtv per one subpixel step in y + + // UV at top/left corner of rast area + cbtu = ( tu1 + ( minXfixscale - x1 ) * dtudx + ( minYfixscale - y1 ) * dtudy ); + cbtv = ( tv1 + ( minXfixscale - x1 ) * dtvdx + ( minYfixscale - y1 ) * dtvdy ); + + // UV pixel steps + dtudx = dtudx * fixscale; + dtudy = dtudy * fixscale; + dtvdx = dtvdx * fixscale; + dtvdy = dtvdy * fixscale; + + } + + var dnzdy, cbnz; + + if ( bHasNormal ) { + + // Normal interpolation setup + var dnz12 = nz1 - nz2, dnz31 = nz3 - nz1; + var dnzdx = ( invDet * ( dnz12 * dy31 - dnz31 * dy12 ) ); // dnz per one subpixel step in x + var dnzdy = ( invDet * ( dnz12 * dx31 - dx12 * dnz31 ) ); // dnz per one subpixel step in y + + // Normal at top/left corner of rast area + cbnz = ( nz1 + ( minXfixscale - x1 ) * dnzdx + ( minYfixscale - y1 ) * dnzdy ); + + // Normal pixel steps + dnzdx = ( dnzdx * fixscale ); + dnzdy = ( dnzdy * fixscale ); + + } + + // Set up min/max corners + var qm1 = q - 1; // for convenience + var nmin1 = 0, nmax1 = 0; + var nmin2 = 0, nmax2 = 0; + var nmin3 = 0, nmax3 = 0; + var nminz = 0, nmaxz = 0; + if ( dx12 >= 0 ) nmax1 -= qm1 * dx12; else nmin1 -= qm1 * dx12; + if ( dy12 >= 0 ) nmax1 -= qm1 * dy12; else nmin1 -= qm1 * dy12; + if ( dx23 >= 0 ) nmax2 -= qm1 * dx23; else nmin2 -= qm1 * dx23; + if ( dy23 >= 0 ) nmax2 -= qm1 * dy23; else nmin2 -= qm1 * dy23; + if ( dx31 >= 0 ) nmax3 -= qm1 * dx31; else nmin3 -= qm1 * dx31; + if ( dy31 >= 0 ) nmax3 -= qm1 * dy31; else nmin3 -= qm1 * dy31; + if ( dzdx >= 0 ) nmaxz += qm1 * dzdx; else nminz += qm1 * dzdx; + if ( dzdy >= 0 ) nmaxz += qm1 * dzdy; else nminz += qm1 * dzdy; + + // Loop through blocks + var linestep = canvasWidth - q; + + var cb1 = c1; + var cb2 = c2; + var cb3 = c3; + var cbz = cz; + var qstep = - q; + var e1x = qstep * dy12; + var e2x = qstep * dy23; + var e3x = qstep * dy31; + var ezx = qstep * dzdx; + + var etux, etvx; + if ( bHasUV ) { + + etux = qstep * dtudx; + etvx = qstep * dtvdx; + + } + + var enzx; + if ( bHasNormal ) { + + enzx = qstep * dnzdx; + + } + + var x0 = minx; + + for ( var y0 = miny; y0 < maxy; y0 += q ) { + + // New block line - keep hunting for tri outer edge in old block line dir + while ( x0 >= minx && x0 < maxx && cb1 >= nmax1 && cb2 >= nmax2 && cb3 >= nmax3 ) { + + x0 += qstep; + cb1 += e1x; + cb2 += e2x; + cb3 += e3x; + cbz += ezx; + + if ( bHasUV ) { + + cbtu += etux; + cbtv += etvx; + + } + + if ( bHasNormal ) { + + cbnz += enzx; + + } + + } + + // Okay, we're now in a block we know is outside. Reverse direction and go into main loop. + qstep = - qstep; + e1x = - e1x; + e2x = - e2x; + e3x = - e3x; + ezx = - ezx; + + if ( bHasUV ) { + + etux = - etux; + etvx = - etvx; + + } + + if ( bHasNormal ) { + + enzx = - enzx; + + } + + while ( 1 ) { + + // Step everything + x0 += qstep; + cb1 += e1x; + cb2 += e2x; + cb3 += e3x; + cbz += ezx; + + if ( bHasUV ) { + + cbtu += etux; + cbtv += etvx; + + } + + if ( bHasNormal ) { + + cbnz += enzx; + + } + + // We're done with this block line when at least one edge completely out + // If an edge function is too small and decreasing in the current traversal + // dir, we're done with this line. + if ( x0 < minx || x0 >= maxx ) break; + if ( cb1 < nmax1 ) if ( e1x < 0 ) break; else continue; + if ( cb2 < nmax2 ) if ( e2x < 0 ) break; else continue; + if ( cb3 < nmax3 ) if ( e3x < 0 ) break; else continue; + + // We can skip this block if it's already fully covered + var blockX = x0 >> blockShift; + var blockY = y0 >> blockShift; + var blockId = blockX + blockY * canvasWBlocks; + var minz = cbz + nminz; + + // farthest point in block closer than closest point in our tri? + if ( blockMaxZ[ blockId ] < minz ) continue; + + // Need to do a deferred clear? + var bflags = blockFlags[ blockId ]; + if ( bflags & BLOCK_NEEDCLEAR ) clearBlock( blockX, blockY ); + blockFlags[ blockId ] = bflags & ~ ( BLOCK_ISCLEAR | BLOCK_NEEDCLEAR ); + + // Offset at top-left corner + var offset = x0 + y0 * canvasWidth; + + // Accept whole block when fully covered + if ( cb1 >= nmin1 && cb2 >= nmin2 && cb3 >= nmin3 ) { + + var maxz = cbz + nmaxz; + blockMaxZ[ blockId ] = Math.min( blockMaxZ[ blockId ], maxz ); + + var cy1 = cb1; + var cy2 = cb2; + var cyz = cbz; + + var cytu, cytv; + if ( bHasUV ) { + + cytu = cbtu; + cytv = cbtv; + + } + + var cynz; + if ( bHasNormal ) { + + cynz = cbnz; + + } + + + for ( var iy = 0; iy < q; iy ++ ) { + + var cx1 = cy1; + var cx2 = cy2; + var cxz = cyz; + + var cxtu; + var cxtv; + if ( bHasUV ) { + + cxtu = cytu; + cxtv = cytv; + + } + + var cxnz; + if ( bHasNormal ) { + + cxnz = cynz; + + } + + for ( var ix = 0; ix < q; ix ++ ) { + + var z = cxz; + + if ( z < zbuffer[ offset ] ) { + + shader( data, zbuffer, offset, z, cxtu, cxtv, cxnz, face, material ); + + } + + cx1 += dy12; + cx2 += dy23; + cxz += dzdx; + + if ( bHasUV ) { + + cxtu += dtudx; + cxtv += dtvdx; + + } + + if ( bHasNormal ) { + + cxnz += dnzdx; + + } + + offset ++; + + } + + cy1 += dx12; + cy2 += dx23; + cyz += dzdy; + + if ( bHasUV ) { + + cytu += dtudy; + cytv += dtvdy; + + } + + if ( bHasNormal ) { + + cynz += dnzdy; + + } + + offset += linestep; + + } + + } else { + + // Partially covered block + + var cy1 = cb1; + var cy2 = cb2; + var cy3 = cb3; + var cyz = cbz; + + var cytu, cytv; + if ( bHasUV ) { + + cytu = cbtu; + cytv = cbtv; + + } + + var cynz; + if ( bHasNormal ) { + + cynz = cbnz; + + } + + for ( var iy = 0; iy < q; iy ++ ) { + + var cx1 = cy1; + var cx2 = cy2; + var cx3 = cy3; + var cxz = cyz; + + var cxtu; + var cxtv; + if ( bHasUV ) { + + cxtu = cytu; + cxtv = cytv; + + } + + var cxnz; + if ( bHasNormal ) { + + cxnz = cynz; + + } + + for ( var ix = 0; ix < q; ix ++ ) { + + if ( ( cx1 | cx2 | cx3 ) >= 0 ) { + + var z = cxz; + + if ( z < zbuffer[ offset ] ) { + + shader( data, zbuffer, offset, z, cxtu, cxtv, cxnz, face, material ); + + } + + } + + cx1 += dy12; + cx2 += dy23; + cx3 += dy31; + cxz += dzdx; + + if ( bHasUV ) { + + cxtu += dtudx; + cxtv += dtvdx; + + } + + if ( bHasNormal ) { + + cxnz += dnzdx; + + } + + offset ++; + + } + + cy1 += dx12; + cy2 += dx23; + cy3 += dx31; + cyz += dzdy; + + if ( bHasUV ) { + + cytu += dtudy; + cytv += dtvdy; + + } + + if ( bHasNormal ) { + + cynz += dnzdy; + + } + + offset += linestep; + + } + + } + + } + + // Advance to next row of blocks + cb1 += q * dx12; + cb2 += q * dx23; + cb3 += q * dx31; + cbz += q * dzdy; + + if ( bHasUV ) { + + cbtu += q * dtudy; + cbtv += q * dtvdy; + + } + + if ( bHasNormal ) { + + cbnz += q * dnzdy; + + } + + } + + } + + // When drawing line, the blockShiftShift has to be zero. In order to clean pixel + // Using color1 and color2 to interpolation pixel color + // LineWidth is according to material.linewidth + function drawLine( v1, v2, color1, color2, shader, material ) { + + // While the line mode is enable, blockSize has to be changed to 0. + if ( ! lineMode ) { + + lineMode = true; + blockShift = 0; + blockSize = 1 << blockShift; + + _this.setSize( canvas.width, canvas.height ); + + } + + // TODO: Implement per-pixel z-clipping + if ( v1.z < - 1 || v1.z > 1 || v2.z < - 1 || v2.z > 1 ) return; + + var halfLineWidth = Math.floor( ( material.linewidth - 1 ) * 0.5 ); + + // https://gist.github.com/2486101 + // explanation: http://pouet.net/topic.php?which=8760&page=1 + + // 28.4 fixed-point coordinates + var x1 = ( v1.x * viewportXScale + viewportXOffs ) | 0; + var x2 = ( v2.x * viewportXScale + viewportXOffs ) | 0; + + var y1 = ( v1.y * viewportYScale + viewportYOffs ) | 0; + var y2 = ( v2.y * viewportYScale + viewportYOffs ) | 0; + + var z1 = ( v1.z * viewportZScale + viewportZOffs ) | 0; + var z2 = ( v2.z * viewportZScale + viewportZOffs ) | 0; + + // Deltas + var dx12 = x1 - x2, dy12 = y1 - y2, dz12 = z1 - z2; + + // Bounding rectangle + var minx = Math.max( ( Math.min( x1, x2 ) + subpixelBias ) >> subpixelBits, 0 ); + var maxx = Math.min( ( Math.max( x1, x2 ) + subpixelBias ) >> subpixelBits, canvasWidth ); + var miny = Math.max( ( Math.min( y1, y2 ) + subpixelBias ) >> subpixelBits, 0 ); + var maxy = Math.min( ( Math.max( y1, y2 ) + subpixelBias ) >> subpixelBits, canvasHeight ); + var minz = Math.max( ( Math.min( z1, z2 ) + subpixelBias ) >> subpixelBits, 0 ); + var maxz = ( Math.max( z1, z2 ) + subpixelBias ) >> subpixelBits; + + rectx1 = Math.min( minx, rectx1 ); + rectx2 = Math.max( maxx, rectx2 ); + recty1 = Math.min( miny, recty1 ); + recty2 = Math.max( maxy, recty2 ); + + // Get the line's unit vector and cross vector + var length = Math.sqrt( ( dy12 * dy12 ) + ( dx12 * dx12 ) ); + var unitX = ( dx12 / length ); + var unitY = ( dy12 / length ); + var unitZ = ( dz12 / length ); + var pixelX, pixelY, pixelZ; + var pX, pY, pZ; + crossVector.set( unitX, unitY, unitZ ); + crossVector.cross( lookVector ); + crossVector.normalize(); + + while ( length > 0 ) { + + // Get this pixel. + pixelX = x2 + length * unitX; + pixelY = y2 + length * unitY; + pixelZ = z2 + length * unitZ; + + pixelX = ( pixelX + subpixelBias ) >> subpixelBits; + pixelY = ( pixelY + subpixelBias ) >> subpixelBits; + pZ = ( pixelZ + subpixelBias ) >> subpixelBits; + + // Draw line with line width + for ( var i = - halfLineWidth; i <= halfLineWidth; ++ i ) { + + // Compute the line pixels. + // Get the pixels on the vector that crosses to the line vector + pX = Math.floor( ( pixelX + crossVector.x * i ) ); + pY = Math.floor( ( pixelY + crossVector.y * i ) ); + + // if pixel is over the rect. Continue + if ( rectx1 >= pX || rectx2 <= pX || recty1 >= pY || recty2 <= pY ) + continue; + + // Find this pixel at which block + var blockX = pX >> blockShift; + var blockY = pY >> blockShift; + var blockId = blockX + blockY * canvasWBlocks; + + // Compare the pixel depth width z block. + if ( blockMaxZ[ blockId ] < minz ) continue; + + blockMaxZ[ blockId ] = Math.min( blockMaxZ[ blockId ], maxz ); + + var bflags = blockFlags[ blockId ]; + if ( bflags & BLOCK_NEEDCLEAR ) clearBlock( blockX, blockY ); + blockFlags[ blockId ] = bflags & ~ ( BLOCK_ISCLEAR | BLOCK_NEEDCLEAR ); + + // draw pixel + var offset = pX + pY * canvasWidth; + + if ( pZ < zbuffer[ offset ] ) { + + shader( data, zbuffer, offset, pZ, color1, color2, material ); + + } + + } + + -- length; + + } + + } + + function clearBlock( blockX, blockY ) { + + var zoffset = blockX * blockSize + blockY * blockSize * canvasWidth; + var poffset = zoffset * 4; + + var zlinestep = canvasWidth - blockSize; + var plinestep = zlinestep * 4; + + for ( var y = 0; y < blockSize; y ++ ) { + + for ( var x = 0; x < blockSize; x ++ ) { + + zbuffer[ zoffset ++ ] = maxZVal; + + data[ poffset ++ ] = clearColor.r * 255 | 0; + data[ poffset ++ ] = clearColor.g * 255 | 0; + data[ poffset ++ ] = clearColor.b * 255 | 0; + data[ poffset ++ ] = getAlpha() * 255 | 0; + + } + + zoffset += zlinestep; + poffset += plinestep; + + } + + } + + function finishClear( ) { + + var block = 0; + + for ( var y = 0; y < canvasHBlocks; y ++ ) { + + for ( var x = 0; x < canvasWBlocks; x ++ ) { + + if ( blockFlags[ block ] & BLOCK_NEEDCLEAR ) { + + clearBlock( x, y ); + blockFlags[ block ] = BLOCK_ISCLEAR; + + } + + block ++; + + } + + } + + } + +}; + +THREE.SoftwareRenderer.Texture = function () { + + var canvas; + + this.fromImage = function ( image ) { + + if ( ! image || image.width <= 0 || image.height <= 0 ) + return; + + if ( canvas === undefined ) { + + canvas = document.createElement( 'canvas' ); + + } + + var size = image.width > image.height ? image.width : image.height; + size = THREE.Math.ceilPowerOfTwo( size ); + + if ( canvas.width != size || canvas.height != size ) { + + canvas.width = size; + canvas.height = size; + + } + + var ctx = canvas.getContext( '2d' ); + ctx.clearRect( 0, 0, size, size ); + ctx.drawImage( image, 0, 0, size, size ); + + var imgData = ctx.getImageData( 0, 0, size, size ); + + this.data = imgData.data; + this.width = size; + this.height = size; + this.srcUrl = image.src; + + }; + +}; diff --git a/three/jsutil/renderers/WebGLDeferredRenderer.js b/three/jsutil/renderers/WebGLDeferredRenderer.js new file mode 100644 index 000000000..057ed2d1d --- /dev/null +++ b/three/jsutil/renderers/WebGLDeferredRenderer.js @@ -0,0 +1,2522 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * @author MPanknin / http://www.redplant.de/ + * @author takahiro / https://github.com/takahirox + * + * WebGLDeferredRenderer supports two types of Deferred Renderings. + * One is Classic Deferred Rendering and the other one is + * Light Pre-Pass (Deferred Lighting). + * Classic Deferred Rendering is default. You can use Light Pre-Pass + * by calling .enableLightPrePass( true ) method. + * + * Dependencies + * - THREE.CopyShader + * - THREE.RenderPass + * - THREE.ShaderPass + * - THREE.EffectComposer + * - THREE.FXAAShader + * + * TODO + * - reuse existing glsl + * - shadow + * - optimization + * - MRT (when it's available on Three.js) + * - AmbientLight + * - HemisphereLight + * - PointLight (distance < 0) + * - morphNormals + * - BumpMap + * - ToneMap + * - envMap + * - wrapAround + * - addEffect + */ + +THREE.WebGLDeferredRenderer = function ( parameters ) { + + parameters = parameters || {}; + + // private properties + + var _this = this; + + var _gl; + + var _width, _height; + + // for Classic Deferred Rendering + var _compColor; + var _passColor, _passForward, _passCopy; + + // for Light Pre-Pass + var _compReconstruction; + var _passReconstruction; + + // for Common + var _compNormalDepth, _compLight, _compFinal; + var _passNormalDepth, _passLight, _passLightFullscreen, _passFinal, _passFXAA; + + var _depthTexture; + + var _currentCamera; + + var _lightScene, _lightFullscreenScene; + + var _antialias = false; + var _hasTransparentObject = false; + var _lightPrePass = false; + var _cacheKeepAlive = false; + + var _tmpMaterial = new THREE.ShaderMaterial( { visible: false } ); + var _tmpVector3 = new THREE.Vector3(); + + // scene/material/light cache for deferred rendering. + // save them at the creation and release + // if they're unused removeThresholdCount frames + // unless _cacheKeepAlive is true. + + // scene.uuid -> lightScene, lightFullscreenScene + var _lightScenesCache = {}; + var _lightFullscreenScenesCache = {}; + + // object.material.uuid -> deferredMaterial or + // object.material[ n ].uuid -> deferredMaterial + var _normalDepthMaterialsCache = {}; + var _normalDepthShininessMaterialsCache = {}; + var _colorMaterialsCache = {}; + var _reconstructionMaterialsCache = {}; + + // originalLight.uuid -> deferredLight + var _deferredLightsCache = {}; + + // deferredLight.uuid -> deferredLightMaterial + var _classicDeferredLightMaterialsCache = {}; + var _lightPrePassMaterialsCache = {}; + + var _removeThresholdCount = 60; + + // deferredMaterials.uuid -> object.material or + // deferredMaterials.uuid -> object.material[ n ] + // save before render and release after render. + var _originalMaterialsTable = {}; + + // object.uuid -> originalOnBeforeRender + // save before render and release after render. + var _originalOnBeforeRendersTable = {}; + + // object.material.uuid -> object.material.visible or + // object.material[ i ].uuid -> object.material[ i ].visible or + // save before render and release after render. + var _originalVisibleTable = {}; + + // external properties + + this.renderer = undefined; + this.domElement = undefined; + + this.forwardRendering = false; // for debug + + // private methods + + function init( parameters ) { + + _this.renderer = parameters.renderer !== undefined ? parameters.renderer : new THREE.WebGLRenderer(); + _this.domElement = _this.renderer.domElement; + + _gl = _this.renderer.context; + + _width = parameters.width !== undefined ? parameters.width : _this.renderer.getSize().width; + _height = parameters.height !== undefined ? parameters.height : _this.renderer.getSize().height; + + var antialias = parameters.antialias !== undefined ? parameters.antialias : false; + + if ( parameters.cacheKeepAlive !== undefined ) _cacheKeepAlive = parameters.cacheKeepAlive; + + initDepthTexture(); + + initPassNormalDepth(); + initPassColor(); + initPassLight(); + initPassReconstruction(); + initPassFinal(); + + _this.setSize( _width, _height ); + _this.setAntialias( antialias ); + _this.enableLightPrePass( false ); + + } + + function initDepthTexture() { + + _depthTexture = new THREE.DepthTexture( + _width, + _height, + THREE.UnsignedInt248Type, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + THREE.DepthStencilFormat + ); + + } + + function initPassNormalDepth() { + + _passNormalDepth = new THREE.RenderPass(); + _passNormalDepth.clear = true; + + var rt = new THREE.WebGLRenderTarget( _width, _height, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat, + type: THREE.FloatType, + stencilBuffer: true, + depthTexture: _depthTexture + } ); + + rt.texture.generateMipamps = false; + + _compNormalDepth = new THREE.EffectComposer( _this.renderer, rt ); + _compNormalDepth.addPass( _passNormalDepth ); + + } + + function initPassColor() { + + _passColor = new THREE.RenderPass(); + _passColor.clear = true; + + var rt = new THREE.WebGLRenderTarget( _width, _height, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat, + type: THREE.FloatType, + depthTexture: _depthTexture + } ); + + rt.texture.generateMipamps = false; + + _compColor = new THREE.EffectComposer( _this.renderer, rt ); + _compColor.addPass( _passColor ); + + } + + function initPassLight() { + + _passLightFullscreen = new THREE.RenderPass(); + _passLightFullscreen.clear = true; + _passLightFullscreen.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); + + _passLight = new THREE.RenderPass(); + _passLight.clear = false; + + var rt = new THREE.WebGLRenderTarget( _width, _height, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat, + type: THREE.FloatType, + depthTexture: _depthTexture + } ); + + rt.texture.generateMipamps = false; + + _compLight = new THREE.EffectComposer( _this.renderer, rt ); + _compLight.addPass( _passLightFullscreen ); + _compLight.addPass( _passLight ); + + } + + function initPassReconstruction() { + + _passReconstruction = new THREE.RenderPass(); + _passReconstruction.clear = true; + + var rt = new THREE.WebGLRenderTarget( _width, _height, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, + format: THREE.RGBAFormat, + type: THREE.FloatType, + depthTexture: _depthTexture + } ); + + rt.texture.generateMipamps = false; + + _compReconstruction = new THREE.EffectComposer( _this.renderer, rt ); + _compReconstruction.addPass( _passReconstruction ); + + } + + function initPassFinal() { + + _passFinal = new THREE.ShaderPass( THREE.ShaderDeferred[ 'final' ] ); + _passFinal.clear = true; + _passFinal.uniforms.samplerResult.value = _compLight.renderTarget2.texture; + _passFinal.material.blending = THREE.NoBlending; + _passFinal.material.depthWrite = false; + _passFinal.material.depthTest = false; + + _passForward = new THREE.RenderPass(); + _passForward.clear = false; + + _passCopy = new THREE.ShaderPass( THREE.CopyShader ); + + _passFXAA = new THREE.ShaderPass( THREE.FXAAShader ); + + var rt = new THREE.WebGLRenderTarget( _width, _height, { + minFilter: THREE.NearestFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBFormat, + type: THREE.UnsignedByteType, + depthTexture: _depthTexture + } ); + + rt.texture.generateMipamps = false; + + _compFinal = new THREE.EffectComposer( _this.renderer, rt ); + _compFinal.addPass( _passFinal ); + _compFinal.addPass( _passForward ); + _compFinal.addPass( _passCopy ); + _compFinal.addPass( _passFXAA ); + + } + + function initLightScene( scene ) { + + var lightSceneData = _lightScenesCache[ scene.uuid ]; + var lightFullscreenSceneData = _lightFullscreenScenesCache[ scene.uuid ]; + + if ( lightSceneData === undefined ) { + + var s = new THREE.Scene(); + s.userData.lights = {}; + + lightSceneData = createCacheData(); + lightSceneData.scene = s; + + _lightScenesCache[ scene.uuid ] = lightSceneData; + + } + + if ( lightFullscreenSceneData === undefined ) { + + var s = new THREE.Scene(); + s.userData.lights = {}; + + var emissiveLight = createDeferredEmissiveLight(); + + s.userData.emissiveLight = emissiveLight; + s.add( emissiveLight ); + + lightFullscreenSceneData = createCacheData(); + lightFullscreenSceneData.scene = s; + + _lightFullscreenScenesCache[ scene.uuid ] = lightFullscreenSceneData; + + } + + lightSceneData.used = true; + lightFullscreenSceneData.used = true; + + var lightScene = lightSceneData.scene; + var lightFullscreenScene = lightFullscreenSceneData.scene; + + // emissiveLight is only for Classic Deferred Rendering + lightFullscreenScene.userData.emissiveLight.visible = ! _lightPrePass; + + _lightScene = lightScene; + _lightFullscreenScene = lightFullscreenScene; + + } + + function getMaterialFromCacheOrCreate( originalMaterial, cache, createFunc, updateFunc ) { + + var data = cache[ originalMaterial.uuid ]; + + if ( data === undefined ) { + + data = createCacheData(); + data.material = createFunc( originalMaterial ); + cache[ originalMaterial.uuid ] = data; + + } + + data.used = true; + + updateFunc( data.material, originalMaterial ); + + _originalMaterialsTable[ data.material.uuid ] = originalMaterial; + + return data.material; + + } + + function overrideMaterialAndOnBeforeRender( object, getMaterialFunc, onBeforeRender ) { + + if ( object.material === undefined ) return; + + if ( Array.isArray( object.material ) ) { + + for ( var i = 0, il = object.material.length; i < il; i ++ ) { + + object.material[ i ] = getMaterialFunc( object.material[ i ] ); + + } + + } else { + + object.material = getMaterialFunc( object.material ); + + } + + object.onBeforeRender = onBeforeRender; + + } + + function restoreOriginalMaterial( object ) { + + if ( object.material === undefined ) return; + + if ( Array.isArray( object.material ) ) { + + for ( var i = 0, il = object.material.length; i < il; i ++ ) { + + object.material[ i ] = _originalMaterialsTable[ object.material[ i ].uuid ]; + + } + + } else { + + object.material = _originalMaterialsTable[ object.material.uuid ]; + + } + + } + + function setMaterialNormalDepth( object ) { + + overrideMaterialAndOnBeforeRender( object, getNormalDepthMaterial, updateDeferredNormalDepthUniforms ); + + } + + function getNormalDepthMaterial( originalMaterial ) { + + return getMaterialFromCacheOrCreate( + originalMaterial, + ( _lightPrePass ) ? _normalDepthShininessMaterialsCache : _normalDepthMaterialsCache, + createDeferredNormalDepthMaterial, + updateDeferredNormalDepthMaterial + ); + + } + + function createDeferredNormalDepthMaterial( originalMaterial ) { + + var shader = ( _lightPrePass ) ? THREE.ShaderDeferred[ 'normalDepthShininess' ] : THREE.ShaderDeferred[ 'normalDepth' ]; + + return new THREE.ShaderMaterial( { + uniforms: Object.assign( {}, shader.uniforms ), + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + blending: THREE.NoBlending + } ); + + } + + function updateDeferredNormalDepthMaterial( material, originalMaterial ) { + + if ( originalMaterial.skinning !== undefined ) material.skinning = originalMaterial.skinning; + if ( originalMaterial.morphTargets !== undefined ) material.morphTargets = originalMaterial.morphTargets; + + if ( originalMaterial.visible === true ) { + + material.visible = ! originalMaterial.transparent; + + } else { + + material.visible = false; + + } + + } + + function updateDeferredNormalDepthUniforms( renderer, scene, camera, geometry, material, group ) { + + if ( ! _lightPrePass ) return; + + var originalMaterial = _originalMaterialsTable[ material.uuid ]; + + if ( originalMaterial === undefined || originalMaterial.shininess === undefined ) return; + + material.uniforms.shininess.value = originalMaterial.shininess; + + } + + function setMaterialColor( object ) { + + overrideMaterialAndOnBeforeRender( object, getColorMaterial, updateDeferredColorUniforms ); + + } + + function getColorMaterial( originalMaterial ) { + + return getMaterialFromCacheOrCreate( + originalMaterial, + _colorMaterialsCache, + createDeferredColorMaterial, + updateDeferredColorMaterial + ); + + } + + function createDeferredColorMaterial( originalMaterial ) { + + var shader = THREE.ShaderDeferred[ 'color' ]; + + var material = new THREE.ShaderMaterial( { + uniforms: Object.assign( {}, shader.uniforms ), + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + blending: THREE.NoBlending + } ); + + if ( originalMaterial.map !== undefined ) material.map = originalMaterial.map; + + return material; + + } + + function updateDeferredColorMaterial( material, originalMaterial ) { + + if ( originalMaterial.map !== undefined ) material.map = originalMaterial.map; + if ( originalMaterial.skinning !== undefined ) material.skinning = originalMaterial.skinning; + if ( originalMaterial.morphTargets !== undefined ) material.morphTargets = originalMaterial.morphTargets; + + if ( originalMaterial.visible === true ) { + + material.visible = ! originalMaterial.transparent; + + } else { + + material.visible = false; + + } + + } + + function updateDeferredColorUniforms( renderer, scene, camera, geometry, material, group ) { + + var originalMaterial = _originalMaterialsTable[ material.uuid ]; + var uniforms = material.uniforms; + + var diffuse, emissive; + + if ( originalMaterial.isMeshBasicMaterial === true ) { + + emissive = originalMaterial.color; + + } else { + + diffuse = originalMaterial.color; + emissive = originalMaterial.emissive; + + } + + var specular = originalMaterial.specular; + var shininess = originalMaterial.shininess; + var map = originalMaterial.map; + + if ( diffuse !== undefined ) uniforms.diffuse.value.copy( diffuse ); + if ( emissive !== undefined ) uniforms.emissive.value.copy( emissive ); + if ( specular !== undefined ) uniforms.specular.value.copy( specular ); + if ( shininess !== undefined && uniforms.shininess !== undefined ) uniforms.shininess.value = shininess; + if ( map !== undefined ) uniforms.map.value = map; + + } + + function setMaterialReconstruction( object ) { + + overrideMaterialAndOnBeforeRender( object, getReconstructionMaterial, updateDeferredReconstructionUniforms ); + + } + + function getReconstructionMaterial( originalMaterial ) { + + if ( originalMaterial.transparent === true ) { + + _originalMaterialsTable[ originalMaterial.uuid ] = originalMaterial; + return originalMaterial; + + } + + return getMaterialFromCacheOrCreate( + originalMaterial, + _reconstructionMaterialsCache, + createDeferredReconstructionMaterial, + updateDeferredReconstructionMaterial + ); + + } + + function createDeferredReconstructionMaterial( originalMaterial ) { + + var shader = THREE.ShaderDeferred[ 'reconstruction' ]; + + var material = new THREE.ShaderMaterial( { + uniforms: Object.assign( {}, shader.uniforms ), + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + blending: THREE.NoBlending + } ); + + if ( originalMaterial.map !== undefined ) material.map = originalMaterial.map; + + return material; + + } + + function updateDeferredReconstructionMaterial( material, originalMaterial ) { + + updateDeferredColorMaterial( material, originalMaterial ); + + } + + function updateDeferredReconstructionUniforms( renderer, scene, camera, geometry, material, group ) { + + if ( material.transparent === true ) { + + // 'this' is object here because this method is set as object.onBefore() + var onBeforeRender = _originalOnBeforeRendersTable[ this.uuid ]; + + if ( onBeforeRender ) { + + onBeforeRender.call( this, renderer, scene, camera, geometry, material, group ); + + } + + return; + + } + + updateDeferredColorUniforms( renderer, scene, camera, geometry, material, group ); + + material.uniforms.samplerLight.value = _compLight.renderTarget2.texture; + + } + + function setVisibleForForwardRendering( object ) { + + if ( object.material === undefined ) return; + + if ( Array.isArray( object.material ) ) { + + for ( var i = 0, il = object.material.length; i < il; i ++ ) { + + if ( _originalVisibleTable[ object.material[ i ].uuid ] === undefined ) { + + _originalVisibleTable[ object.material[ i ].uuid ] = object.material[ i ].visible; + object.material[ i ].visible = object.material[ i ].transparent && object.material[ i ].visible; + + } + + } + + } else { + + if ( _originalVisibleTable[ object.material.uuid ] === undefined ) { + + _originalVisibleTable[ object.material.uuid ] = object.material.visible; + object.material.visible = object.material.transparent && object.material.visible; + + } + + } + + } + + function restoreVisible( object ) { + + if ( object.material === undefined ) return; + + if ( Array.isArray( object.material ) ) { + + for ( var i = 0, il = object.material.length; i < il; i ++ ) { + + object.material[ i ].visible = _originalVisibleTable[ object.material[ i ].uuid ]; + + } + + } else { + + object.material.visible = _originalVisibleTable[ object.material.uuid ]; + + } + + } + + function createDeferredEmissiveLight() { + + var shader = THREE.ShaderDeferred[ 'emissiveLight' ]; + + var material = new THREE.ShaderMaterial( { + uniforms: Object.assign( {}, shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + blending: THREE.NoBlending, + depthWrite: false + } ); + + var geometry = new THREE.PlaneBufferGeometry( 2, 2 ); + var mesh = new THREE.Mesh( geometry, material ); + + mesh.onBeforeRender = function ( renderer, scene, camera, geometry, material, group ) { + + material.uniforms.samplerColor.value = _compColor.renderTarget2.texture; + + }; + + return mesh; + + } + + function createDeferredLight( originalLight ) { + + if ( originalLight.isPointLight ) { + + return createDeferredPointLight( originalLight ); + + } else if ( originalLight.isSpotLight ) { + + return createDeferredSpotLight( originalLight ); + + } else if ( originalLight.isDirectionalLight ) { + + return createDeferredDirectionalLight( originalLight ); + + } + + return null; + + } + + function createDeferredLightMaterial( originalLight ) { + + if ( originalLight.isPointLight ) { + + return createDeferredPointLightMaterial(); + + } else if ( originalLight.isSpotLight ) { + + return createDeferredSpotLightMaterial(); + + } else if ( originalLight.isDirectionalLight ) { + + return createDeferredDirectionalLightMaterial(); + + } + + return null; + + } + + function getDeferredLightMaterial( light ) { + + var cache = ( _lightPrePass ) ? _lightPrePassMaterialsCache : _classicDeferredLightMaterialsCache; + + var data = cache[ light.uuid ]; + + if ( data === undefined ) { + + data = createCacheData(); + data.material = createDeferredLightMaterial( light.userData.originalLight ); + cache[ light.uuid ] = data; + + } + + data.used = true; + + return data.material; + + } + + function updateDeferredLight( light ) { + + var originalLight = light.userData.originalLight; + + if ( originalLight.isPointLight ) { + + updateDeferredPointLight( light ); + + } + + } + + function createDeferredLightMesh( light, geometry ) { + + var mesh = new THREE.Mesh( geometry, _tmpMaterial ); + + mesh.userData.originalLight = light; + + return mesh; + + } + + function createDeferredLightShaderMaterial( shader ) { + + var material = new THREE.ShaderMaterial( { + uniforms: Object.assign( {}, shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + transparent: true, + blending: THREE.AdditiveBlending, + depthWrite: false + } ); + + if ( _lightPrePass ) material.premultipliedAlpha = true; + + return material; + + } + + function updateDeferredLightCommonUniforms( uniforms ) { + + if ( _lightPrePass ) { + + uniforms.samplerNormalDepthShininess.value = _compNormalDepth.renderTarget2.texture; + + } else { + + uniforms.samplerNormalDepth.value = _compNormalDepth.renderTarget2.texture; + uniforms.samplerColor.value = _compColor.renderTarget2.texture; + + } + + } + + function createDeferredPointLight( light ) { + + var mesh = createDeferredLightMesh( light, new THREE.SphereBufferGeometry( 1, 16, 8 ) ); + mesh.onBeforeRender = updateDeferredPointLightUniforms; + return mesh; + + } + + /* + * optimization: + * Renders PointLight only back face with stencil test. + */ + function createDeferredPointLightMaterial() { + + var shader = ( _lightPrePass ) ? THREE.ShaderDeferred[ 'pointLightPre' ] : THREE.ShaderDeferred[ 'pointLight' ]; + + var material = createDeferredLightShaderMaterial( shader ); + + material.side = THREE.BackSide; + material.depthFunc = THREE.GreaterEqualDepth; + + return material; + + } + + function updateDeferredPointLight( light ) { + + var originalLight = light.userData.originalLight; + var distance = originalLight.distance; + + if ( distance > 0 ) { + + light.scale.set( 1, 1, 1 ).multiplyScalar( distance ); + light.position.setFromMatrixPosition( originalLight.matrixWorld ); + + } + + } + + function updateDeferredPointLightUniforms( renderer, scene, camera, geometry, material, group ) { + + var light = this; + + var originalLight = light.userData.originalLight; + var distance = originalLight.distance; + var uniforms = material.uniforms; + + uniforms.lightColor.value.copy( originalLight.color ); + + if ( distance > 0 ) { + + uniforms.lightRadius.value = distance; + uniforms.lightIntensity.value = originalLight.intensity; + uniforms.lightPositionVS.value.setFromMatrixPosition( originalLight.matrixWorld ).applyMatrix4( _currentCamera.matrixWorldInverse ); + + } else { + + uniforms.lightRadius.value = Infinity; + + } + + updateDeferredLightCommonUniforms( uniforms ); + + } + + function createDeferredSpotLight( light ) { + + var mesh = createDeferredLightMesh( light, new THREE.PlaneBufferGeometry( 2, 2 ) ); + mesh.onBeforeRender = updateDeferredSpotLightUniforms; + return mesh; + + } + + function createDeferredSpotLightMaterial() { + + var shader = ( _lightPrePass ) ? THREE.ShaderDeferred[ 'spotLightPre' ] : THREE.ShaderDeferred[ 'spotLight' ]; + + var material = createDeferredLightShaderMaterial( shader ); + + material.depthTest = false; + + return material; + + } + + function updateDeferredSpotLightUniforms( renderer, scene, camera, geometry, material, group ) { + + var light = this; + + var originalLight = light.userData.originalLight; + var uniforms = light.material.uniforms; + + uniforms.lightAngle.value = originalLight.angle; + uniforms.lightColor.value.copy( originalLight.color ); + uniforms.lightIntensity.value = originalLight.intensity; + uniforms.lightPositionVS.value.setFromMatrixPosition( originalLight.matrixWorld ).applyMatrix4( _currentCamera.matrixWorldInverse ); + + var vec = uniforms.lightDirectionVS.value; + var vec2 = _tmpVector3; + + vec.setFromMatrixPosition( originalLight.matrixWorld ); + vec2.setFromMatrixPosition( originalLight.target.matrixWorld ); + vec.sub( vec2 ).normalize().transformDirection( _currentCamera.matrixWorldInverse ); + + updateDeferredLightCommonUniforms( uniforms ); + + } + + function createDeferredDirectionalLight( light ) { + + var mesh = createDeferredLightMesh( light, new THREE.PlaneBufferGeometry( 2, 2 ) ); + mesh.onBeforeRender = updateDeferredDirectionalLightUniforms; + return mesh; + + } + + function createDeferredDirectionalLightMaterial() { + + var shader = ( _lightPrePass ) ? THREE.ShaderDeferred[ 'directionalLightPre' ] : THREE.ShaderDeferred[ 'directionalLight' ]; + + var material = createDeferredLightShaderMaterial( shader ); + + material.depthTest = false; + + return material; + + } + + function updateDeferredDirectionalLightUniforms( renderer, scene, camera, geometry, material, group ) { + + var light = this; + + var originalLight = light.userData.originalLight; + var uniforms = light.material.uniforms; + + uniforms.lightColor.value.copy( originalLight.color ); + uniforms.lightIntensity.value = originalLight.intensity; + + var vec = uniforms.lightDirectionVS.value; + var vec2 = _tmpVector3; + + vec.setFromMatrixPosition( originalLight.matrixWorld ); + vec2.setFromMatrixPosition( originalLight.target.matrixWorld ); + vec.sub( vec2 ).normalize().transformDirection( _currentCamera.matrixWorldInverse ); + + updateDeferredLightCommonUniforms( uniforms ); + + } + + function saveOriginalOnBeforeRenderAndCheckTransparency( object ) { + + if ( object.material === undefined ) return; + + _originalOnBeforeRendersTable[ object.uuid ] = object.onBeforeRender; + + // _hasTransparentObject is used only for Classic Deferred Rendering + if ( _hasTransparentObject || _lightPrePass ) return; + + if ( ! object.visible ) return; + + if ( Array.isArray( object.material ) ) { + + for ( var i = 0, il = object.material.length; i < il; i ++ ) { + + if ( object.material[ i ].visible === true && object.material[ i ].transparent === true ) { + + _hasTransparentObject = true; + break; + + } + + } + + } else { + + if ( object.material.visible === true && object.material.transparent === true ) _hasTransparentObject = true; + + } + + } + + function restoreOriginalOnBeforeRender( object ) { + + if ( object.material === undefined ) return; + + object.onBeforeRender = _originalOnBeforeRendersTable[ object.uuid ]; + + } + + function addDeferredLightsToLightScene( object ) { + + if ( object.isLight !== true ) return; + + var data = _deferredLightsCache[ object.uuid ]; + + if ( data === undefined ) { + + data = createCacheData(); + data.light = createDeferredLight( object ); + _deferredLightsCache[ object.uuid ] = data; + + } + + data.used = true; + + var light = data.light; + + if ( light === null ) return; + + var scene = ( object.isPointLight === true ) ? _lightScene : _lightFullscreenScene; + + var lights = scene.userData.lights; + + if ( lights[ light.uuid ] === undefined ) { + + scene.add( light ); + + lights[ light.uuid ] = { + light: light, + found: true + }; + + } + + lights[ light.uuid ].found = true; + + } + + function updateDeferredLightsInLightScene( scene ) { + + var lights = scene.userData.lights; + var keys = Object.keys( lights ); + + for ( var i = 0, il = keys.length; i < il; i ++ ) { + + var key = keys[ i ]; + + if ( lights[ key ].found === false ) { + + scene.remove( lights[ key ].light ); + delete lights[ key ]; + + } else { + + var light = lights[ key ].light; + light.material = getDeferredLightMaterial( light ); + + updateDeferredLight( light ); + lights[ key ].found = false; + + } + + } + + } + + function updateDeferredCommonUniforms( camera ) { + + var uniforms = THREE.ShaderDeferredCommon[ 'commonUniforms' ]; + + uniforms.viewWidth.value = _width; + uniforms.viewHeight.value = _height; + + uniforms.matProjInverse.value.getInverse( camera.projectionMatrix ); + + } + + function enableFinalPasses() { + + if ( _lightPrePass ) { + + _passForward.renderToScreen = false; + _passForward.enabled = false; + + _passCopy.renderToScreen = false; + _passCopy.enabled = false; + + if ( _antialias ) { + + _passFinal.renderToScreen = false; + + _passFXAA.renderToScreen = true; + _passFXAA.enabled = true; + + } else { + + _passFinal.renderToScreen = true; + + _passFXAA.renderToScreen = false; + _passFXAA.enabled = false; + + } + + } else { + + if ( _hasTransparentObject ) { + + if ( _antialias ) { + + _passFinal.renderToScreen = false; + + _passForward.renderToScreen = false; + _passForward.enabled = true; + + _passCopy.renderToScreen = false; + _passCopy.enabled = false; + + _passFXAA.renderToScreen = true; + _passFXAA.enabled = true; + + } else { + + _passFinal.renderToScreen = false; + + _passForward.renderToScreen = false; + _passForward.enabled = true; + + _passCopy.renderToScreen = true; + _passCopy.enabled = true; + + _passFXAA.renderToScreen = false; + _passFXAA.enabled = false; + + } + + } else { + + if ( _antialias ) { + + _passFinal.renderToScreen = false; + + _passForward.renderToScreen = false; + _passForward.enabled = false; + + _passCopy.renderToScreen = false; + _passCopy.enabled = false; + + _passFXAA.renderToScreen = true; + _passFXAA.enabled = true; + + } else { + + _passFinal.renderToScreen = true; + + _passForward.renderToScreen = false; + _passForward.enabled = false; + + _passCopy.renderToScreen = false; + _passCopy.enabled = false; + + _passFXAA.renderToScreen = false; + _passFXAA.enabled = false; + + } + + } + + } + + } + + function createCacheData() { + + return { + used: true, + keepAlive: _cacheKeepAlive, + count: 0 + }; + + } + + function cleanupCache( cache ) { + + var keys = Object.keys( cache ); + + for ( var i = 0, il = keys.length; i < il; i ++ ) { + + var key = keys[ i ]; + + if ( cache[ key ].used === false ) { + + cache[ key ].count++; + + if ( cache[ key ].keepAlive === false && cache[ key ].count > _removeThresholdCount ) { + + delete cache[ key ]; + + } + + } else { + + cache[ key ].used = false; + cache[ key ].count = 0; + + } + + } + + } + + function cleanupTable( table ) { + + var keys = Object.keys( table ); + + for ( var i = 0, il = keys.length; i < il; i ++ ) { + + var key = keys[ i ]; + + table[ key ] = undefined; + + } + + } + + function cleanupCaches() { + + cleanupCache( _lightScenesCache ); + cleanupCache( _lightFullscreenScenesCache ); + cleanupCache( _normalDepthMaterialsCache ); + cleanupCache( _normalDepthShininessMaterialsCache ); + cleanupCache( _colorMaterialsCache ); + cleanupCache( _reconstructionMaterialsCache ); + cleanupCache( _classicDeferredLightMaterialsCache ); + cleanupCache( _lightPrePassMaterialsCache ); + cleanupCache( _deferredLightsCache ); + + cleanupTable( _originalMaterialsTable ); + cleanupTable( _originalOnBeforeRendersTable ); + cleanupTable( _originalVisibleTable ); + + } + + /* + * Classic Deferred Rendering + * + * 1) g-buffer normal + depth pass + * + * RGB: normal + * A: depth + * + * + * Light Pre-Pass Rendering + * + * 1') g-buffer normal + depth pass + shininess + * + * RG: normal + * B: shininess + * A: depth + */ + + function renderNormalDepth( scene, camera ) { + + scene.traverse( setMaterialNormalDepth ); + + _passNormalDepth.scene = scene; + _passNormalDepth.camera = camera; + + _this.renderer.autoClearDepth = true; + _this.renderer.autoClearStencil = true; + + _gl.enable( _gl.STENCIL_TEST ); + _gl.stencilFunc( _gl.ALWAYS, 1, 0xffffffff ); + _gl.stencilOp( _gl.REPLACE, _gl.REPLACE, _gl.REPLACE ); + + _compNormalDepth.render(); + + scene.traverse( restoreOriginalMaterial ); + + } + + /* + * Classic Deferred Rendering + * + * 2) g-buffer color pass + * + * R: diffuse + * G: emissive + * B: specular + * A: shininess + */ + + function renderColor( scene, camera ) { + + scene.traverse( setMaterialColor ); + + _passColor.scene = scene; + _passColor.camera = camera; + + _this.renderer.autoClearDepth = false; + _this.renderer.autoClearStencil = false; + + _gl.stencilFunc( _gl.EQUAL, 1, 0xffffffff ); + _gl.stencilOp( _gl.KEEP, _gl.KEEP, _gl.KEEP ); + + _compColor.render(); + + scene.traverse( restoreOriginalMaterial ); + + } + + /* + * Classic Deferred Rendering + * + * 3) light pass + */ + + function renderLight( scene, camera ) { + + scene.traverse( addDeferredLightsToLightScene ); + + updateDeferredLightsInLightScene( _lightScene ); + updateDeferredLightsInLightScene( _lightFullscreenScene ); + + _passLight.scene = _lightScene; + _passLight.camera = camera; + + _passLightFullscreen.scene = _lightFullscreenScene; + + _this.renderer.autoClearDepth = false; + _this.renderer.autoClearStencil = false; + + _compLight.render(); + + _gl.disable( _gl.STENCIL_TEST ); + + } + + /* + * Light Pre-Pass Rendering + * + * 2') Light pre pass + */ + + function renderLightPre( scene, camera ) { + + scene.traverse( addDeferredLightsToLightScene ); + + updateDeferredLightsInLightScene( _lightScene ); + updateDeferredLightsInLightScene( _lightFullscreenScene ); + + _passLight.scene = _lightScene; + _passLight.camera = camera; + + _passLightFullscreen.scene = _lightFullscreenScene; + + _this.renderer.autoClearDepth = false; + _this.renderer.autoClearStencil = false; + + _gl.stencilFunc( _gl.EQUAL, 1, 0xffffffff ); + _gl.stencilOp( _gl.KEEP, _gl.KEEP, _gl.KEEP ); + + _compLight.render(); + + } + + /* + * Light Pre-Pass Rendering + * + * 3') Reconstruction pass + * + * Transprency handling: + * Here renders transparent objects with normal forward rendering. + */ + + function renderReconstruction( scene, camera ) { + + scene.traverse( setMaterialReconstruction ); + + _passReconstruction.scene = scene; + _passReconstruction.camera = camera; + + _this.renderer.autoClearDepth = false; + _this.renderer.autoClearStencil = false; + + _compReconstruction.render(); + + _gl.disable( _gl.STENCIL_TEST ); + + scene.traverse( restoreOriginalMaterial ); + + } + + /* + * Classic Deferred Rendering + * + * 4) Final pass + * + * transparency handling: + * If there's any transparent objects, here renders them on the deferred rendering result + * with normal forward rendering. This may be the easist way but heavy. + * We should consider any better ways someday. + * + * + * Light Pre-Pass Rendering + * + * 4') Final pass + * + * + * Common + * + * antialias handling: + * Here uses postprocessing FXAA for antialias. + * + */ + + function renderFinal( scene, camera ) { + + if ( ! _lightPrePass && _hasTransparentObject ) { + + scene.traverse( setVisibleForForwardRendering ); + scene.traverse( restoreOriginalOnBeforeRender ); + + _passForward.scene = scene; + _passForward.camera = camera; + + } + + enableFinalPasses(); + + _this.renderer.autoClearDepth = false; + _this.renderer.autoClearStencil = false; + + _compFinal.render(); + + if ( ! _lightPrePass && _hasTransparentObject ) { + + scene.traverse( restoreVisible ); + + } + + } + + // external APIs + + this.setSize = function ( width, height ) { + + _width = width; + _height = height; + + this.renderer.setSize( _width, _height ); + + _compNormalDepth.setSize( _width, _height ); + _compColor.setSize( _width, _height ); + _compLight.setSize( _width, _height ); + _compReconstruction.setSize( _width, _height ); + _compFinal.setSize( _width, _height ); + + _depthTexture.image.width = _width; + _depthTexture.image.height = _height; + _depthTexture.needsUpdate = true; + + _passFXAA.uniforms.resolution.value.set( 1 / _width, 1 / _height ); + + }; + + this.setAntialias = function ( enabled ) { + + _antialias = enabled; + + }; + + this.enableLightPrePass = function ( enabled ) { + + _lightPrePass = enabled; + + _passFinal.uniforms.samplerResult.value = ( _lightPrePass ) ? _compReconstruction.renderTarget2.texture : _compLight.renderTarget2.texture; + + }; + + this.render = function ( scene, camera ) { + + // for debug to compare with normal forward rendering + + if ( this.forwardRendering ) { + + this.renderer.render( scene, camera ); + return; + + } + + var currentSceneAutoUpdate = scene.autoUpdate; + var currentAutoClearColor = this.renderer.autoClearColor; + var currentAutoClearDepth = this.renderer.autoClearDepth; + var currentAutoClearStencil = this.renderer.autoClearStencil; + + _currentCamera = camera; + + initLightScene( scene ); + + scene.autoUpdate = false; + scene.updateMatrixWorld(); + + _hasTransparentObject = false; + + scene.traverse( saveOriginalOnBeforeRenderAndCheckTransparency ); + + updateDeferredCommonUniforms( camera ); + + renderNormalDepth( scene, camera ); + + if ( _lightPrePass ) { + + renderLightPre( scene, camera ); + renderReconstruction( scene, camera ); + + } else { + + renderColor( scene, camera ); + renderLight( scene, camera ); + + } + + renderFinal( scene, camera ); + + scene.traverse( restoreOriginalOnBeforeRender ); + + cleanupCaches(); + + scene.autoUpdate = currentSceneAutoUpdate; + this.renderer.autoClearColor = currentAutoClearColor; + this.renderer.autoClearDepth = currentAutoClearDepth; + this.renderer.autoClearStencil = currentAutoClearStencil; + + }; + + // initialize + + init( parameters ); + +}; + +THREE.DeferredShaderChunk = { + + packVector3: [ + + "float vec3_to_float( vec3 data ) {", + + " const float unit = 255.0/256.0;", + " highp float compressed = fract( data.x * unit ) + floor( data.y * unit * 255.0 ) + floor( data.z * unit * 255.0 ) * 255.0;", + " return compressed;", + + "}" + + ].join( "\n" ), + + unpackFloat: [ + + "vec3 float_to_vec3( float data ) {", + + " const float unit = 255.0;", + " vec3 uncompressed;", + " uncompressed.x = fract( data );", + " float zInt = floor( data / unit );", + " uncompressed.z = fract( zInt / unit );", + " uncompressed.y = fract( floor( data - ( zInt * unit ) ) / unit );", + " return uncompressed;", + + "}" + + ].join( "\n" ), + + // Refer to http://aras-p.info/texts/CompactNormalStorage.html + packNormal: [ + + "vec2 normal_to_vec2( vec3 normal ) {", + + " return normal.xy / sqrt( normal.z * 8.0 + 8.0 ) + 0.5;", + + "}" + + ].join( "\n" ), + + unpackVector2: [ + + "vec3 vec2_to_normal( vec2 data ) {", + + " vec2 fenc = data * 4.0 - 2.0;", + " float f = dot( fenc, fenc );", + " float g = sqrt( 1.0 - f / 4.0 );", + " vec3 normal;", + " normal.xy = fenc * g;", + " normal.z = 1.0 - f / 2.0;", + " return normal;", + + "}" + + ].join( "\n" ), + + computeTextureCoord: [ + + "vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );" + + ].join( "\n" ), + + packNormalDepth: [ + + "vec4 packedNormalDepth;", + "packedNormalDepth.xyz = normal * 0.5 + 0.5;", + "packedNormalDepth.w = position.z / position.w;" + + ].join( "\n" ), + + unpackNormalDepth: [ + + "vec4 normalDepthMap = texture2D( samplerNormalDepth, texCoord );", + "float depth = normalDepthMap.w;", + + "if ( depth == 0.0 ) discard;", + + "vec3 normal = normalDepthMap.xyz * 2.0 - 1.0;" + + ].join( "\n" ), + + packNormalDepthShininess: [ + + "vec4 packedNormalDepthShininess;", + "packedNormalDepthShininess.xy = normal_to_vec2( normal );", + "packedNormalDepthShininess.z = shininess;", + "packedNormalDepthShininess.w = position.z / position.w;" + + ].join( "\n" ), + + unpackNormalDepthShininess: [ + + "vec4 normalDepthMap = texture2D( samplerNormalDepthShininess, texCoord );", + "float depth = normalDepthMap.w;", + + "if ( depth == 0.0 ) discard;", + + "vec3 normal = vec2_to_normal( normalDepthMap.xy );", + "float shininess = normalDepthMap.z;" + + ].join( "\n" ), + + packColor: [ + + "vec4 packedColor;", + "packedColor.x = vec3_to_float( diffuseColor.rgb );", + "packedColor.y = vec3_to_float( emissiveColor );", + "packedColor.z = vec3_to_float( specularColor );", + "packedColor.w = shininess;" + + ].join( "\n" ), + + unpackColor: [ + + "vec4 colorMap = texture2D( samplerColor, texCoord );", + "vec3 diffuseColor = float_to_vec3( colorMap.x );", + "vec3 emissiveColor = float_to_vec3( colorMap.y );", + "vec3 specularColor = float_to_vec3( colorMap.z );", + "float shininess = colorMap.w;" + + ].join( "\n" ), + + packLight: [ + + "vec4 packedLight;", + "packedLight.xyz = lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * attenuation;", + "packedLight.w = lightIntensity * specular * max( dot( lightVector, normal ), 0.0 ) * attenuation;" + + ].join( "\n" ), + + computeVertexPositionVS: [ + + "vec2 xy = texCoord * 2.0 - 1.0;", + "vec4 vertexPositionProjected = vec4( xy, depth, 1.0 );", + "vec4 vertexPositionVS = matProjInverse * vertexPositionProjected;", + "vertexPositionVS.xyz /= vertexPositionVS.w;", + "vertexPositionVS.w = 1.0;" + + ].join( "\n" ), + + // TODO: calculate schlick + computeSpecular: [ + + "vec3 halfVector = normalize( lightVector - normalize( vertexPositionVS.xyz ) );", + "float dotNormalHalf = max( dot( normal, halfVector ), 0.0 );", + "float specular = 0.31830988618 * ( shininess * 0.5 + 1.0 ) * pow( dotNormalHalf, shininess );" + + ].join( "\n" ), + + combine: [ + + "gl_FragColor = vec4( lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * ( diffuseColor + specular * specularColor ) * attenuation, 1.0 );" + + ].join( "\n" ) + +}; + +THREE.ShaderDeferredCommon = { + + commonUniforms: { + + matProjInverse: new THREE.Uniform( new THREE.Matrix4() ), + + viewWidth: new THREE.Uniform( 800 ), + viewHeight: new THREE.Uniform( 600 ) + + } + +}; + +THREE.ShaderDeferred = { + + normalDepth: { + + uniforms: {}, + + vertexShader: [ + + "varying vec3 vNormal;", + "varying vec4 vPosition;", + + "#include ", + "#include ", + + "void main() {", + + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + " vNormal = normalize( transformedNormal );", + " vPosition = gl_Position;", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "varying vec3 vNormal;", + "varying vec4 vPosition;", + + "void main() {", + + " vec3 normal = vNormal;", + " vec4 position = vPosition;", + + THREE.DeferredShaderChunk[ "packNormalDepth" ], + + " gl_FragColor = packedNormalDepth;", + + "}" + + ].join( "\n" ) + + }, + + color: { + + uniforms: { + + map: new THREE.Uniform( null ), + offsetRepeat: new THREE.Uniform( new THREE.Vector4( 0, 0, 1, 1 ) ), + + diffuse: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + emissive: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + specular: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + shininess: new THREE.Uniform( 30.0 ) + + }, + + vertexShader: [ + + "#include ", + "#include ", + "#include ", + + "void main() {", + + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform vec3 diffuse;", + "uniform vec3 emissive;", + "uniform vec3 specular;", + "uniform float shininess;", + + "#include ", + "#include ", + THREE.DeferredShaderChunk[ "packVector3" ], + + "void main() {", + + " vec4 diffuseColor = vec4( diffuse, 1.0 );", + " vec3 emissiveColor = emissive;", + " vec3 specularColor = specular;", + + "#include ", + THREE.DeferredShaderChunk[ "packColor" ], + + " gl_FragColor = packedColor;", + + "}" + + ].join( "\n" ) + + }, + + emissiveLight: { + + uniforms: Object.assign( + + { + + samplerColor: new THREE.Uniform( null ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "void main() { ", + + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + + "}" + + ].join( '\n' ), + + fragmentShader: [ + + "uniform sampler2D samplerColor;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackColor" ], + + " gl_FragColor = vec4( emissiveColor, 1.0 );", + + "}" + + ].join( '\n' ) + + }, + + pointLight: { + + uniforms: Object.assign( + + { + + samplerNormalDepth: new THREE.Uniform( null ), + samplerColor: new THREE.Uniform( null ), + + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ), + lightRadius: new THREE.Uniform( 1.0 ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "void main() {", + + " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D samplerNormalDepth;", + "uniform sampler2D samplerColor;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "uniform vec3 lightColor;", + "uniform vec3 lightPositionVS;", + "uniform float lightIntensity;", + "uniform float lightRadius;", + + "uniform mat4 matProjInverse;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepth" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + + " vec3 lightVector = lightPositionVS - vertexPositionVS.xyz;", + " float distance = length( lightVector );", + + " if ( distance > lightRadius ) discard;", + + " lightVector = normalize( lightVector );", + + THREE.DeferredShaderChunk[ "unpackColor" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], + + " //float cutoff = 0.3;", + " //float denom = distance / lightRadius + 1.0;", + " //float attenuation = 1.0 / ( denom * denom );", + " //attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );", + " //attenuation = max( attenuation, 0.0 );", + " //attenuation *= attenuation;", + + " //diffuseColor *= saturate( -distance / lightRadius + 1.0 );", + " //float attenuation = 1.0;", + + " float attenuation = saturate( -distance / lightRadius + 1.0 );", + + THREE.DeferredShaderChunk[ "combine" ], + + "}" + + ].join( "\n" ) + + }, + + spotLight: { + + uniforms: Object.assign( + + { + + samplerNormalDepth: new THREE.Uniform( null ), + samplerColor: new THREE.Uniform( null ), + + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightAngle: new THREE.Uniform( 1.0 ), + lightIntensity: new THREE.Uniform( 1.0 ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "void main() { ", + + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D samplerNormalDepth;", + "uniform sampler2D samplerColor;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "uniform vec3 lightColor;", + "uniform vec3 lightPositionVS;", + "uniform vec3 lightDirectionVS;", + "uniform float lightAngle;", + "uniform float lightIntensity;", + + "uniform mat4 matProjInverse;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepth" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "unpackColor" ], + + " vec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );", + + " float rho = dot( lightDirectionVS, lightVector );", + " float rhoMax = cos( lightAngle );", + + " if ( rho <= rhoMax ) discard;", + + " float theta = rhoMax + 0.0001;", + " float phi = rhoMax + 0.05;", + " float falloff = 4.0;", + + " float spot = 0.0;", + + " if ( rho >= phi ) {", + + " spot = 1.0;", + + " } else if ( rho <= theta ) {", + + " spot = 0.0;", + + " } else { ", + + " spot = pow( ( rho - theta ) / ( phi - theta ), falloff );", + + " }", + + " diffuseColor *= spot;", + + THREE.DeferredShaderChunk[ "computeSpecular" ], + + " const float attenuation = 1.0;", + + THREE.DeferredShaderChunk[ "combine" ], + + "}" + + ].join( "\n" ) + + }, + + directionalLight: { + + uniforms: Object.assign( + + { + + samplerNormalDepth: new THREE.Uniform( null ), + samplerColor: new THREE.Uniform( null ), + + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ) + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "void main() { ", + + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + + "}" + + ].join( '\n' ), + + fragmentShader: [ + + "uniform sampler2D samplerNormalDepth;", + "uniform sampler2D samplerColor;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "uniform vec3 lightColor;", + "uniform vec3 lightDirectionVS;", + "uniform float lightIntensity;", + + "uniform mat4 matProjInverse;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepth" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "unpackColor" ], + + " vec3 lightVector = normalize( lightDirectionVS );", + + THREE.DeferredShaderChunk[ "computeSpecular" ], + + " const float attenuation = 1.0;", + + THREE.DeferredShaderChunk[ "combine" ], + + "}" + + ].join( '\n' ) + + }, + + normalDepthShininess: { + + uniforms: { + + shininess: new THREE.Uniform( 30.0 ) + + }, + + vertexShader: [ + + "varying vec3 vNormal;", + "varying vec4 vPosition;", + + "#include ", + "#include ", + + "void main() {", + + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + " vNormal = normalize( transformedNormal );", + " vPosition = gl_Position;", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "varying vec3 vNormal;", + "varying vec4 vPosition;", + + "uniform float shininess;", + + THREE.DeferredShaderChunk[ "packNormal" ], + + "void main() {", + + " vec3 normal = vNormal;", + " vec4 position = vPosition;", + + THREE.DeferredShaderChunk[ "packNormalDepthShininess" ], + + " gl_FragColor = packedNormalDepthShininess;", + + "}" + + ].join( "\n" ) + + }, + + pointLightPre: { + + uniforms: Object.assign( + + { + + samplerNormalDepthShininess: new THREE.Uniform( null ), + + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ), + lightRadius: new THREE.Uniform( 1.0 ) + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + + vertexShader: [ + + "void main() {", + + " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D samplerNormalDepthShininess;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "uniform vec3 lightColor;", + "uniform vec3 lightPositionVS;", + "uniform float lightIntensity;", + "uniform float lightRadius;", + + "uniform mat4 matProjInverse;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + THREE.DeferredShaderChunk[ "unpackVector2" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + + " vec3 lightVector = lightPositionVS - vertexPositionVS.xyz;", + " float distance = length( lightVector );", + + " if ( distance > lightRadius ) discard;", + + " lightVector = normalize( lightVector );", + + THREE.DeferredShaderChunk[ "computeSpecular" ], + + " float attenuation = saturate( -distance / lightRadius + 1.0 );", + + THREE.DeferredShaderChunk[ "packLight" ], + + " gl_FragColor = packedLight;", + + "}" + + ].join( "\n" ) + + }, + + spotLightPre: { + + uniforms: Object.assign( + + { + + samplerNormalDepthShininess: new THREE.Uniform( null ), + + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightAngle: new THREE.Uniform( 1.0 ), + lightIntensity: new THREE.Uniform( 1.0 ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "void main() { ", + + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D samplerNormalDepthShininess;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "uniform vec3 lightColor;", + "uniform vec3 lightPositionVS;", + "uniform vec3 lightDirectionVS;", + "uniform float lightAngle;", + "uniform float lightIntensity;", + + "uniform mat4 matProjInverse;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + THREE.DeferredShaderChunk[ "unpackVector2" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + + " vec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );", + + " float rho = dot( lightDirectionVS, lightVector );", + " float rhoMax = cos( lightAngle );", + + " if ( rho <= rhoMax ) discard;", + + " float theta = rhoMax + 0.0001;", + " float phi = rhoMax + 0.05;", + " float falloff = 4.0;", + + " float spot = 0.0;", + + " if ( rho >= phi ) {", + + " spot = 1.0;", + + " } else if ( rho <= theta ) {", + + " spot = 0.0;", + + " } else { ", + + " spot = pow( ( rho - theta ) / ( phi - theta ), falloff );", + + " }", + + THREE.DeferredShaderChunk[ "computeSpecular" ], + + " const float attenuation = 1.0;", + + THREE.DeferredShaderChunk[ "packLight" ], + + " gl_FragColor = spot * packedLight;", + + "}" + + ].join( "\n" ) + + }, + + directionalLightPre: { + + uniforms: Object.assign( + + { + + samplerNormalDepthShininess: new THREE.Uniform( null ), + + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "void main() { ", + + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + + "}" + + ].join( '\n' ), + + fragmentShader: [ + + "uniform sampler2D samplerNormalDepthShininess;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "uniform vec3 lightColor;", + "uniform vec3 lightDirectionVS;", + "uniform float lightIntensity;", + + "uniform mat4 matProjInverse;", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + THREE.DeferredShaderChunk[ "unpackVector2" ], + + "void main() {", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + + " vec3 lightVector = normalize( lightDirectionVS );", + + THREE.DeferredShaderChunk[ "computeSpecular" ], + + " const float attenuation = 1.0;", + + THREE.DeferredShaderChunk[ "packLight" ], + + " gl_FragColor = packedLight;", + + "}" + + ].join( '\n' ) + + }, + + reconstruction: { + + uniforms: Object.assign( + + { + + samplerLight: new THREE.Uniform( null ), + + map: new THREE.Uniform( null ), + offsetRepeat: new THREE.Uniform( new THREE.Vector4( 0, 0, 1, 1 ) ), + + diffuse: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + emissive: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + specular: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + shininess: new THREE.Uniform( 30.0 ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), + + vertexShader: [ + + "#include ", + "#include ", + "#include ", + + "void main() {", + + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + "#include ", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D samplerLight;", + + "uniform vec3 diffuse;", + "uniform vec3 emissive;", + "uniform vec3 specular;", + "uniform float shininess;", + + "uniform float viewHeight;", + "uniform float viewWidth;", + + "#include ", + "#include ", + + THREE.DeferredShaderChunk[ "unpackFloat" ], + + "void main() {", + + " vec4 diffuseColor = vec4( diffuse, 1.0 );", + " vec3 emissiveColor = emissive;", + " vec3 specularColor = specular;", + + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + + " vec4 light = texture2D( samplerLight, texCoord );", + + "#include ", + + " vec3 diffuseFinal = diffuseColor.rgb * light.rgb;", + " vec3 emissiveFinal = emissiveColor;", + " vec3 specularFinal = specularColor * light.rgb * light.a;", + + " gl_FragColor = vec4( diffuseFinal + emissiveFinal + specularFinal, 1.0 );", + + "}" + + ].join( "\n" ) + + }, + + // TODO: implement tone mapping + final: { + + uniforms: { + + samplerResult: new THREE.Uniform( null ) + + }, + + vertexShader: [ + + "varying vec2 texCoord;", + + "void main() {", + + " vec4 pos = vec4( sign( position.xy ), 0.0, 1.0 );", + " texCoord = pos.xy * vec2( 0.5 ) + 0.5;", + " gl_Position = pos;", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "varying vec2 texCoord;", + "uniform sampler2D samplerResult;", + + "void main() {", + + " gl_FragColor = texture2D( samplerResult, texCoord );", + + "}" + + ].join( "\n" ) + + } + +}; diff --git a/three/jsutil/shaders/AfterimageShader.js b/three/jsutil/shaders/AfterimageShader.js new file mode 100644 index 000000000..ab4a5df03 --- /dev/null +++ b/three/jsutil/shaders/AfterimageShader.js @@ -0,0 +1,60 @@ +/** + * @author HypnosNova / https://www.threejs.org.cn/gallery/ + * + * Afterimage shader + * I created this effect inspired by a demo on codepen: + * https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1& + */ + +THREE.AfterimageShader = { + + uniforms: { + + "damp": { value: 0.96 }, + "tOld": { value: null }, + "tNew": { value: null } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float damp;", + + "uniform sampler2D tOld;", + "uniform sampler2D tNew;", + + "varying vec2 vUv;", + + "vec4 when_gt( vec4 x, float y ) {", + + "return max( sign( x - y ), 0.0 );", + + "}", + + "void main() {", + + "vec4 texelOld = texture2D( tOld, vUv );", + "vec4 texelNew = texture2D( tNew, vUv );", + + "texelOld *= damp * when_gt( texelOld, 0.1 );", + + "gl_FragColor = max(texelNew, texelOld);", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/BasicShader.js b/three/jsutil/shaders/BasicShader.js new file mode 100644 index 000000000..16fdfe921 --- /dev/null +++ b/three/jsutil/shaders/BasicShader.js @@ -0,0 +1,31 @@ +/** + * @author mrdoob / http://www.mrdoob.com + * + * Simple test shader + */ + +THREE.BasicShader = { + + uniforms: {}, + + vertexShader: [ + + "void main() {", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "void main() {", + + "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/BleachBypassShader.js b/three/jsutil/shaders/BleachBypassShader.js new file mode 100644 index 000000000..0c7d8b054 --- /dev/null +++ b/three/jsutil/shaders/BleachBypassShader.js @@ -0,0 +1,64 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass] + * - based on Nvidia example + * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass + */ + +THREE.BleachBypassShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "opacity": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float opacity;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 base = texture2D( tDiffuse, vUv );", + + "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );", + "float lum = dot( lumCoeff, base.rgb );", + "vec3 blend = vec3( lum );", + + "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );", + + "vec3 result1 = 2.0 * base.rgb * blend;", + "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );", + + "vec3 newColor = mix( result1, result2, L );", + + "float A2 = opacity * base.a;", + "vec3 mixRGB = A2 * newColor.rgb;", + "mixRGB += ( ( 1.0 - A2 ) * base.rgb );", + + "gl_FragColor = vec4( mixRGB, base.a );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/BlendShader.js b/three/jsutil/shaders/BlendShader.js new file mode 100644 index 000000000..8a7a59cd8 --- /dev/null +++ b/three/jsutil/shaders/BlendShader.js @@ -0,0 +1,51 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Blend two textures + */ + +THREE.BlendShader = { + + uniforms: { + + "tDiffuse1": { value: null }, + "tDiffuse2": { value: null }, + "mixRatio": { value: 0.5 }, + "opacity": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float opacity;", + "uniform float mixRatio;", + + "uniform sampler2D tDiffuse1;", + "uniform sampler2D tDiffuse2;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 texel1 = texture2D( tDiffuse1, vUv );", + "vec4 texel2 = texture2D( tDiffuse2, vUv );", + "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/BokehShader.js b/three/jsutil/shaders/BokehShader.js new file mode 100644 index 000000000..a2336d040 --- /dev/null +++ b/three/jsutil/shaders/BokehShader.js @@ -0,0 +1,146 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Depth-of-field shader with bokeh + * ported from GLSL shader by Martins Upitis + * http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html + */ + +THREE.BokehShader = { + + defines: { + "DEPTH_PACKING": 1, + "PERSPECTIVE_CAMERA": 1, + }, + + uniforms: { + + "tColor": { value: null }, + "tDepth": { value: null }, + "focus": { value: 1.0 }, + "aspect": { value: 1.0 }, + "aperture": { value: 0.025 }, + "maxblur": { value: 1.0 }, + "nearClip": { value: 1.0 }, + "farClip": { value: 1000.0 }, + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + "#include ", + + "varying vec2 vUv;", + + "uniform sampler2D tColor;", + "uniform sampler2D tDepth;", + + "uniform float maxblur;", // max blur amount + "uniform float aperture;", // aperture - bigger values for shallower depth of field + + "uniform float nearClip;", + "uniform float farClip;", + + "uniform float focus;", + "uniform float aspect;", + + "#include ", + + "float getDepth( const in vec2 screenPosition ) {", + " #if DEPTH_PACKING == 1", + " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );", + " #else", + " return texture2D( tDepth, screenPosition ).x;", + " #endif", + "}", + + "float getViewZ( const in float depth ) {", + " #if PERSPECTIVE_CAMERA == 1", + " return perspectiveDepthToViewZ( depth, nearClip, farClip );", + " #else", + " return orthographicDepthToViewZ( depth, nearClip, farClip );", + " #endif", + "}", + + + "void main() {", + + "vec2 aspectcorrect = vec2( 1.0, aspect );", + + "float viewZ = getViewZ( getDepth( vUv ) );", + + "float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation + + "vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );", + + "vec2 dofblur9 = dofblur * 0.9;", + "vec2 dofblur7 = dofblur * 0.7;", + "vec2 dofblur4 = dofblur * 0.4;", + + "vec4 col = vec4( 0.0 );", + + "col += texture2D( tColor, vUv.xy );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );", + + "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );", + + "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );", + + "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );", + "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );", + + "gl_FragColor = col / 41.0;", + "gl_FragColor.a = 1.0;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/BokehShader2.js b/three/jsutil/shaders/BokehShader2.js new file mode 100644 index 000000000..8d6f7c581 --- /dev/null +++ b/three/jsutil/shaders/BokehShader2.js @@ -0,0 +1,398 @@ +/** + * @author zz85 / https://github.com/zz85 | twitter.com/blurspline + * + * Depth-of-field shader with bokeh + * ported from GLSL shader by Martins Upitis + * http://blenderartists.org/forum/showthread.php?237488-GLSL-depth-of-field-with-bokeh-v2-4-(update) + * + * Requires #define RINGS and SAMPLES integers + */ + + + +THREE.BokehShader = { + + uniforms: { + + "textureWidth": { value: 1.0 }, + "textureHeight": { value: 1.0 }, + + "focalDepth": { value: 1.0 }, + "focalLength": { value: 24.0 }, + "fstop": { value: 0.9 }, + + "tColor": { value: null }, + "tDepth": { value: null }, + + "maxblur": { value: 1.0 }, + + "showFocus": { value: 0 }, + "manualdof": { value: 0 }, + "vignetting": { value: 0 }, + "depthblur": { value: 0 }, + + "threshold": { value: 0.5 }, + "gain": { value: 2.0 }, + "bias": { value: 0.5 }, + "fringe": { value: 0.7 }, + + "znear": { value: 0.1 }, + "zfar": { value: 100 }, + + "noise": { value: 1 }, + "dithering": { value: 0.0001 }, + "pentagon": { value: 0 }, + + "shaderFocus": { value: 1 }, + "focusCoords": { value: new THREE.Vector2() } + + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#include ", + + "varying vec2 vUv;", + + "uniform sampler2D tColor;", + "uniform sampler2D tDepth;", + "uniform float textureWidth;", + "uniform float textureHeight;", + + "uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below", + "uniform float focalLength; //focal length in mm", + "uniform float fstop; //f-stop value", + "uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)", + + "/*", + "make sure that these two values are the same for your camera, otherwise distances will be wrong.", + "*/", + + "uniform float znear; // camera clipping start", + "uniform float zfar; // camera clipping end", + + "//------------------------------------------", + "//user variables", + + "const int samples = SAMPLES; //samples on the first ring", + "const int rings = RINGS; //ring count", + + "const int maxringsamples = rings * samples;", + + "uniform bool manualdof; // manual dof calculation", + "float ndofstart = 1.0; // near dof blur start", + "float ndofdist = 2.0; // near dof blur falloff distance", + "float fdofstart = 1.0; // far dof blur start", + "float fdofdist = 3.0; // far dof blur falloff distance", + + "float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)", + + "uniform bool vignetting; // use optical lens vignetting", + + "float vignout = 1.3; // vignetting outer border", + "float vignin = 0.0; // vignetting inner border", + "float vignfade = 22.0; // f-stops till vignete fades", + + "uniform bool shaderFocus;", + "// disable if you use external focalDepth value", + + "uniform vec2 focusCoords;", + "// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)", + "// if center of screen use vec2(0.5, 0.5);", + + "uniform float maxblur;", + "//clamp value of max blur (0.0 = no blur, 1.0 default)", + + "uniform float threshold; // highlight threshold;", + "uniform float gain; // highlight gain;", + + "uniform float bias; // bokeh edge bias", + "uniform float fringe; // bokeh chromatic aberration / fringing", + + "uniform bool noise; //use noise instead of pattern for sample dithering", + + "uniform float dithering;", + + "uniform bool depthblur; // blur the depth buffer", + "float dbsize = 1.25; // depth blur size", + + "/*", + "next part is experimental", + "not looking good with small sample and ring count", + "looks okay starting from samples = 4, rings = 4", + "*/", + + "uniform bool pentagon; //use pentagon as bokeh shape?", + "float feather = 0.4; //pentagon shape feather", + + "//------------------------------------------", + + "float penta(vec2 coords) {", + "//pentagonal shape", + "float scale = float(rings) - 1.3;", + "vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);", + "vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);", + "vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);", + "vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);", + "vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);", + "vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);", + + "vec4 one = vec4( 1.0 );", + + "vec4 P = vec4((coords),vec2(scale, scale));", + + "vec4 dist = vec4(0.0);", + "float inorout = -4.0;", + + "dist.x = dot( P, HS0 );", + "dist.y = dot( P, HS1 );", + "dist.z = dot( P, HS2 );", + "dist.w = dot( P, HS3 );", + + "dist = smoothstep( -feather, feather, dist );", + + "inorout += dot( dist, one );", + + "dist.x = dot( P, HS4 );", + "dist.y = HS5.w - abs( P.z );", + + "dist = smoothstep( -feather, feather, dist );", + "inorout += dist.x;", + + "return clamp( inorout, 0.0, 1.0 );", + "}", + + "float bdepth(vec2 coords) {", + "// Depth buffer blur", + "float d = 0.0;", + "float kernel[9];", + "vec2 offset[9];", + + "vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;", + + "offset[0] = vec2(-wh.x,-wh.y);", + "offset[1] = vec2( 0.0, -wh.y);", + "offset[2] = vec2( wh.x -wh.y);", + + "offset[3] = vec2(-wh.x, 0.0);", + "offset[4] = vec2( 0.0, 0.0);", + "offset[5] = vec2( wh.x, 0.0);", + + "offset[6] = vec2(-wh.x, wh.y);", + "offset[7] = vec2( 0.0, wh.y);", + "offset[8] = vec2( wh.x, wh.y);", + + "kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;", + "kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;", + "kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;", + + + "for( int i=0; i<9; i++ ) {", + "float tmp = texture2D(tDepth, coords + offset[i]).r;", + "d += tmp * kernel[i];", + "}", + + "return d;", + "}", + + + "vec3 color(vec2 coords,float blur) {", + "//processing the sample", + + "vec3 col = vec3(0.0);", + "vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);", + + "col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;", + "col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;", + "col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;", + + "vec3 lumcoeff = vec3(0.299,0.587,0.114);", + "float lum = dot(col.rgb, lumcoeff);", + "float thresh = max((lum-threshold)*gain, 0.0);", + "return col+mix(vec3(0.0),col,thresh*blur);", + "}", + + "vec3 debugFocus(vec3 col, float blur, float depth) {", + "float edge = 0.002*depth; //distance based edge smoothing", + "float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);", + "float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);", + + "col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);", + "col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);", + + "return col;", + "}", + + "float linearize(float depth) {", + "return -zfar * znear / (depth * (zfar - znear) - zfar);", + "}", + + + "float vignette() {", + "float dist = distance(vUv.xy, vec2(0.5,0.5));", + "dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);", + "return clamp(dist,0.0,1.0);", + "}", + + "float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {", + "float rings2 = float(rings);", + "float step = PI*2.0 / float(ringsamples);", + "float pw = cos(j*step)*i;", + "float ph = sin(j*step)*i;", + "float p = 1.0;", + "if (pentagon) {", + "p = penta(vec2(pw,ph));", + "}", + "col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;", + "return 1.0 * mix(1.0, i /rings2, bias) * p;", + "}", + + "void main() {", + "//scene depth calculation", + + "float depth = linearize(texture2D(tDepth,vUv.xy).x);", + + "// Blur depth?", + "if ( depthblur ) {", + "depth = linearize(bdepth(vUv.xy));", + "}", + + "//focal plane calculation", + + "float fDepth = focalDepth;", + + "if (shaderFocus) {", + + "fDepth = linearize(texture2D(tDepth,focusCoords).x);", + + "}", + + "// dof blur factor calculation", + + "float blur = 0.0;", + + "if (manualdof) {", + "float a = depth-fDepth; // Focal plane", + "float b = (a-fdofstart)/fdofdist; // Far DoF", + "float c = (-a-ndofstart)/ndofdist; // Near Dof", + "blur = (a>0.0) ? b : c;", + "} else {", + "float f = focalLength; // focal length in mm", + "float d = fDepth*1000.0; // focal plane in mm", + "float o = depth*1000.0; // depth in mm", + + "float a = (o*f)/(o-f);", + "float b = (d*f)/(d-f);", + "float c = (d-f)/(d*fstop*CoC);", + + "blur = abs(a-b)*c;", + "}", + + "blur = clamp(blur,0.0,1.0);", + + "// calculation of pattern for dithering", + + "vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;", + + "// getting blur x and y step factor", + + "float w = (1.0/textureWidth)*blur*maxblur+noise.x;", + "float h = (1.0/textureHeight)*blur*maxblur+noise.y;", + + "// calculation of final color", + + "vec3 col = vec3(0.0);", + + "if(blur < 0.05) {", + "//some optimization thingy", + "col = texture2D(tColor, vUv.xy).rgb;", + "} else {", + "col = texture2D(tColor, vUv.xy).rgb;", + "float s = 1.0;", + "int ringsamples;", + + "for (int i = 1; i <= rings; i++) {", + "/*unboxstart*/", + "ringsamples = i * samples;", + + "for (int j = 0 ; j < maxringsamples ; j++) {", + "if (j >= ringsamples) break;", + "s += gather(float(i), float(j), ringsamples, col, w, h, blur);", + "}", + "/*unboxend*/", + "}", + + "col /= s; //divide by sample count", + "}", + + "if (showFocus) {", + "col = debugFocus(col, blur, depth);", + "}", + + "if (vignetting) {", + "col *= vignette();", + "}", + + "gl_FragColor.rgb = col;", + "gl_FragColor.a = 1.0;", + "} " + + ].join( "\n" ) + +}; + +THREE.BokehDepthShader = { + + uniforms: { + + "mNear": { value: 1.0 }, + "mFar": { value: 1000.0 }, + + }, + + vertexShader: [ + + "varying float vViewZDepth;", + + "void main() {", + + " #include ", + " #include ", + + " vViewZDepth = - mvPosition.z;", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float mNear;", + "uniform float mFar;", + + "varying float vViewZDepth;", + + "void main() {", + + " float color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );", + " gl_FragColor = vec4( vec3( color ), 1.0 );", + + "} " + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/BrightnessContrastShader.js b/three/jsutil/shaders/BrightnessContrastShader.js new file mode 100644 index 000000000..ae90b649c --- /dev/null +++ b/three/jsutil/shaders/BrightnessContrastShader.js @@ -0,0 +1,58 @@ +/** + * @author tapio / http://tapio.github.com/ + * + * Brightness and contrast adjustment + * https://github.com/evanw/glfx.js + * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white) + * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) + */ + +THREE.BrightnessContrastShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "brightness": { value: 0 }, + "contrast": { value: 0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float brightness;", + "uniform float contrast;", + + "varying vec2 vUv;", + + "void main() {", + + "gl_FragColor = texture2D( tDiffuse, vUv );", + + "gl_FragColor.rgb += brightness;", + + "if (contrast > 0.0) {", + "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;", + "} else {", + "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;", + "}", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/ColorCorrectionShader.js b/three/jsutil/shaders/ColorCorrectionShader.js new file mode 100644 index 000000000..93060751c --- /dev/null +++ b/three/jsutil/shaders/ColorCorrectionShader.js @@ -0,0 +1,50 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Color correction + */ + +THREE.ColorCorrectionShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "powRGB": { value: new THREE.Vector3( 2, 2, 2 ) }, + "mulRGB": { value: new THREE.Vector3( 1, 1, 1 ) }, + "addRGB": { value: new THREE.Vector3( 0, 0, 0 ) } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform vec3 powRGB;", + "uniform vec3 mulRGB;", + "uniform vec3 addRGB;", + + "varying vec2 vUv;", + + "void main() {", + + "gl_FragColor = texture2D( tDiffuse, vUv );", + "gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/ColorifyShader.js b/three/jsutil/shaders/ColorifyShader.js new file mode 100644 index 000000000..8b65a861f --- /dev/null +++ b/three/jsutil/shaders/ColorifyShader.js @@ -0,0 +1,49 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Colorify shader + */ + +THREE.ColorifyShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "color": { value: new THREE.Color( 0xffffff ) } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform vec3 color;", + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 texel = texture2D( tDiffuse, vUv );", + + "vec3 luma = vec3( 0.299, 0.587, 0.114 );", + "float v = dot( texel.xyz, luma );", + + "gl_FragColor = vec4( v * color, texel.w );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/ConvolutionShader.js b/three/jsutil/shaders/ConvolutionShader.js new file mode 100644 index 000000000..677f4d9a0 --- /dev/null +++ b/three/jsutil/shaders/ConvolutionShader.js @@ -0,0 +1,101 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Convolution shader + * ported from o3d sample to WebGL / GLSL + * http://o3d.googlecode.com/svn/trunk/samples/convolution.html + */ + +THREE.ConvolutionShader = { + + defines: { + + "KERNEL_SIZE_FLOAT": "25.0", + "KERNEL_SIZE_INT": "25" + + }, + + uniforms: { + + "tDiffuse": { value: null }, + "uImageIncrement": { value: new THREE.Vector2( 0.001953125, 0.0 ) }, + "cKernel": { value: [] } + + }, + + vertexShader: [ + + "uniform vec2 uImageIncrement;", + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float cKernel[ KERNEL_SIZE_INT ];", + + "uniform sampler2D tDiffuse;", + "uniform vec2 uImageIncrement;", + + "varying vec2 vUv;", + + "void main() {", + + "vec2 imageCoord = vUv;", + "vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );", + + "for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {", + + "sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];", + "imageCoord += uImageIncrement;", + + "}", + + "gl_FragColor = sum;", + + "}" + + + ].join( "\n" ), + + buildKernel: function ( sigma ) { + + // We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway. + + function gauss( x, sigma ) { + + return Math.exp( - ( x * x ) / ( 2.0 * sigma * sigma ) ); + + } + + var i, values, sum, halfWidth, kMaxKernelSize = 25, kernelSize = 2 * Math.ceil( sigma * 3.0 ) + 1; + + if ( kernelSize > kMaxKernelSize ) kernelSize = kMaxKernelSize; + halfWidth = ( kernelSize - 1 ) * 0.5; + + values = new Array( kernelSize ); + sum = 0.0; + for ( i = 0; i < kernelSize; ++ i ) { + + values[ i ] = gauss( i - halfWidth, sigma ); + sum += values[ i ]; + + } + + // normalize the kernel + + for ( i = 0; i < kernelSize; ++ i ) values[ i ] /= sum; + + return values; + + } + +}; diff --git a/three/jsutil/shaders/CopyShader.js b/three/jsutil/shaders/CopyShader.js new file mode 100644 index 000000000..9843a42fc --- /dev/null +++ b/three/jsutil/shaders/CopyShader.js @@ -0,0 +1,46 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Full-screen textured quad shader + */ + +THREE.CopyShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "opacity": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float opacity;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 texel = texture2D( tDiffuse, vUv );", + "gl_FragColor = opacity * texel;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/DOFMipMapShader.js b/three/jsutil/shaders/DOFMipMapShader.js new file mode 100644 index 000000000..8f11e9d65 --- /dev/null +++ b/three/jsutil/shaders/DOFMipMapShader.js @@ -0,0 +1,58 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Depth-of-field shader using mipmaps + * - from Matt Handley @applmak + * - requires power-of-2 sized render target with enabled mipmaps + */ + +THREE.DOFMipMapShader = { + + uniforms: { + + "tColor": { value: null }, + "tDepth": { value: null }, + "focus": { value: 1.0 }, + "maxblur": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float focus;", + "uniform float maxblur;", + + "uniform sampler2D tColor;", + "uniform sampler2D tDepth;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 depth = texture2D( tDepth, vUv );", + + "float factor = depth.x - focus;", + + "vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );", + + "gl_FragColor = col;", + "gl_FragColor.a = 1.0;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/DepthLimitedBlurShader.js b/three/jsutil/shaders/DepthLimitedBlurShader.js new file mode 100644 index 000000000..816c14796 --- /dev/null +++ b/three/jsutil/shaders/DepthLimitedBlurShader.js @@ -0,0 +1,155 @@ +THREE.DepthLimitedBlurShader = { + defines: { + 'KERNEL_RADIUS': 4, + 'DEPTH_PACKING': 1, + 'PERSPECTIVE_CAMERA': 1 + }, + uniforms: { + 'tDiffuse': { type: 't', value: null }, + 'size': { type: 'v2', value: new THREE.Vector2( 512, 512 ) }, + 'sampleUvOffsets': { type: 'v2v', value: [ new THREE.Vector2( 0, 0 ) ] }, + 'sampleWeights': { type: '1fv', value: [ 1.0 ] }, + 'tDepth': { type: 't', value: null }, + 'cameraNear': { type: 'f', value: 10 }, + 'cameraFar': { type: 'f', value: 1000 }, + 'depthCutoff': { type: 'f', value: 10 }, + }, + vertexShader: [ + "#include ", + + "uniform vec2 size;", + + "varying vec2 vUv;", + "varying vec2 vInvSize;", + + "void main() {", + " vUv = uv;", + " vInvSize = 1.0 / size;", + + " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + "}" + + ].join( "\n" ), + fragmentShader: [ + "#include ", + "#include ", + + "uniform sampler2D tDiffuse;", + "uniform sampler2D tDepth;", + + "uniform float cameraNear;", + "uniform float cameraFar;", + "uniform float depthCutoff;", + + "uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];", + "uniform float sampleWeights[ KERNEL_RADIUS + 1 ];", + + "varying vec2 vUv;", + "varying vec2 vInvSize;", + + "float getDepth( const in vec2 screenPosition ) {", + " #if DEPTH_PACKING == 1", + " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );", + " #else", + " return texture2D( tDepth, screenPosition ).x;", + " #endif", + "}", + + "float getViewZ( const in float depth ) {", + " #if PERSPECTIVE_CAMERA == 1", + " return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );", + " #else", + " return orthographicDepthToViewZ( depth, cameraNear, cameraFar );", + " #endif", + "}", + + "void main() {", + " float depth = getDepth( vUv );", + " if( depth >= ( 1.0 - EPSILON ) ) {", + " discard;", + " }", + + " float centerViewZ = -getViewZ( depth );", + " bool rBreak = false, lBreak = false;", + + " float weightSum = sampleWeights[0];", + " vec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;", + + " for( int i = 1; i <= KERNEL_RADIUS; i ++ ) {", + + " float sampleWeight = sampleWeights[i];", + " vec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;", + + " vec2 sampleUv = vUv + sampleUvOffset;", + " float viewZ = -getViewZ( getDepth( sampleUv ) );", + + " if( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;", + + " if( ! rBreak ) {", + " diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;", + " weightSum += sampleWeight;", + " }", + + " sampleUv = vUv - sampleUvOffset;", + " viewZ = -getViewZ( getDepth( sampleUv ) );", + + " if( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;", + + " if( ! lBreak ) {", + " diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;", + " weightSum += sampleWeight;", + " }", + + " }", + + " gl_FragColor = diffuseSum / weightSum;", + "}" + ].join( "\n" ) +}; + +THREE.BlurShaderUtils = { + + createSampleWeights: function ( kernelRadius, stdDev ) { + + var gaussian = function ( x, stdDev ) { + + return Math.exp( - ( x * x ) / ( 2.0 * ( stdDev * stdDev ) ) ) / ( Math.sqrt( 2.0 * Math.PI ) * stdDev ); + + }; + + var weights = []; + + for ( var i = 0; i <= kernelRadius; i ++ ) { + + weights.push( gaussian( i, stdDev ) ); + + } + + return weights; + + }, + + createSampleOffsets: function ( kernelRadius, uvIncrement ) { + + var offsets = []; + + for ( var i = 0; i <= kernelRadius; i ++ ) { + + offsets.push( uvIncrement.clone().multiplyScalar( i ) ); + + } + + return offsets; + + }, + + configure: function ( material, kernelRadius, stdDev, uvIncrement ) { + + material.defines[ 'KERNEL_RADIUS' ] = kernelRadius; + material.uniforms[ 'sampleUvOffsets' ].value = THREE.BlurShaderUtils.createSampleOffsets( kernelRadius, uvIncrement ); + material.uniforms[ 'sampleWeights' ].value = THREE.BlurShaderUtils.createSampleWeights( kernelRadius, stdDev ); + material.needsUpdate = true; + + } + +}; diff --git a/three/jsutil/shaders/DigitalGlitch.js b/three/jsutil/shaders/DigitalGlitch.js new file mode 100644 index 000000000..0348e25d5 --- /dev/null +++ b/three/jsutil/shaders/DigitalGlitch.js @@ -0,0 +1,103 @@ +/** + * @author felixturner / http://airtight.cc/ + * + * RGB Shift Shader + * Shifts red and blue channels from center in opposite directions + * Ported from http://kriss.cx/tom/2009/05/rgb-shift/ + * by Tom Butterworth / http://kriss.cx/tom/ + * + * amount: shift distance (1 is width of input) + * angle: shift angle in radians + */ + +THREE.DigitalGlitch = { + + uniforms: { + + "tDiffuse": { value: null },//diffuse texture + "tDisp": { value: null },//displacement texture for digital glitch squares + "byp": { value: 0 },//apply the glitch ? + "amount": { value: 0.08 }, + "angle": { value: 0.02 }, + "seed": { value: 0.02 }, + "seed_x": { value: 0.02 },//-1,1 + "seed_y": { value: 0.02 },//-1,1 + "distortion_x": { value: 0.5 }, + "distortion_y": { value: 0.6 }, + "col_s": { value: 0.05 } + }, + + vertexShader: [ + + "varying vec2 vUv;", + "void main() {", + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + "}" + ].join( "\n" ), + + fragmentShader: [ + "uniform int byp;",//should we apply the glitch ? + + "uniform sampler2D tDiffuse;", + "uniform sampler2D tDisp;", + + "uniform float amount;", + "uniform float angle;", + "uniform float seed;", + "uniform float seed_x;", + "uniform float seed_y;", + "uniform float distortion_x;", + "uniform float distortion_y;", + "uniform float col_s;", + + "varying vec2 vUv;", + + + "float rand(vec2 co){", + "return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);", + "}", + + "void main() {", + "if(byp<1) {", + "vec2 p = vUv;", + "float xs = floor(gl_FragCoord.x / 0.5);", + "float ys = floor(gl_FragCoord.y / 0.5);", + //based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch + "vec4 normal = texture2D (tDisp, p*seed*seed);", + "if(p.ydistortion_x-col_s*seed) {", + "if(seed_x>0.){", + "p.y = 1. - (p.y + distortion_y);", + "}", + "else {", + "p.y = distortion_y;", + "}", + "}", + "if(p.xdistortion_y-col_s*seed) {", + "if(seed_y>0.){", + "p.x=distortion_x;", + "}", + "else {", + "p.x = 1. - (p.x + distortion_x);", + "}", + "}", + "p.x+=normal.x*seed_x*(seed/5.);", + "p.y+=normal.y*seed_y*(seed/5.);", + //base from RGB shift shader + "vec2 offset = amount * vec2( cos(angle), sin(angle));", + "vec4 cr = texture2D(tDiffuse, p + offset);", + "vec4 cga = texture2D(tDiffuse, p);", + "vec4 cb = texture2D(tDiffuse, p - offset);", + "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);", + //add noise + "vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);", + "gl_FragColor = gl_FragColor+ snow;", + "}", + "else {", + "gl_FragColor=texture2D (tDiffuse, vUv);", + "}", + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/DotScreenShader.js b/three/jsutil/shaders/DotScreenShader.js new file mode 100644 index 000000000..7159a6334 --- /dev/null +++ b/three/jsutil/shaders/DotScreenShader.js @@ -0,0 +1,68 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Dot screen shader + * based on glfx.js sepia shader + * https://github.com/evanw/glfx.js + */ + +THREE.DotScreenShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "tSize": { value: new THREE.Vector2( 256, 256 ) }, + "center": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "angle": { value: 1.57 }, + "scale": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform vec2 center;", + "uniform float angle;", + "uniform float scale;", + "uniform vec2 tSize;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "float pattern() {", + + "float s = sin( angle ), c = cos( angle );", + + "vec2 tex = vUv * tSize - center;", + "vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;", + + "return ( sin( point.x ) * sin( point.y ) ) * 4.0;", + + "}", + + "void main() {", + + "vec4 color = texture2D( tDiffuse, vUv );", + + "float average = ( color.r + color.g + color.b ) / 3.0;", + + "gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/FXAAShader.js b/three/jsutil/shaders/FXAAShader.js new file mode 100644 index 000000000..57f593871 --- /dev/null +++ b/three/jsutil/shaders/FXAAShader.js @@ -0,0 +1,1115 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * @author davidedc / http://www.sketchpatch.net/ + * + * NVIDIA FXAA by Timothy Lottes + * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html + * - WebGL port by @supereggbert + * http://www.glge.org/demos/fxaa/ + */ + +THREE.FXAAShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "resolution": { value: new THREE.Vector2( 1 / 1024, 1 / 512 ) } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + "precision highp float;", + "", + "uniform sampler2D tDiffuse;", + "", + "uniform vec2 resolution;", + "", + "varying vec2 vUv;", + "", + "// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)", + "", + "//----------------------------------------------------------------------------------", + "// File: es3-kepler\FXAA\assets\shaders/FXAA_DefaultES.frag", + "// SDK Version: v3.00", + "// Email: gameworks@nvidia.com", + "// Site: http://developer.nvidia.com/", + "//", + "// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.", + "//", + "// Redistribution and use in source and binary forms, with or without", + "// modification, are permitted provided that the following conditions", + "// are met:", + "// * Redistributions of source code must retain the above copyright", + "// notice, this list of conditions and the following disclaimer.", + "// * Redistributions in binary form must reproduce the above copyright", + "// notice, this list of conditions and the following disclaimer in the", + "// documentation and/or other materials provided with the distribution.", + "// * Neither the name of NVIDIA CORPORATION nor the names of its", + "// contributors may be used to endorse or promote products derived", + "// from this software without specific prior written permission.", + "//", + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY", + "// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE", + "// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR", + "// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR", + "// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,", + "// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,", + "// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR", + "// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY", + "// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT", + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE", + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", + "//", + "//----------------------------------------------------------------------------------", + "", + "#define FXAA_PC 1", + "#define FXAA_GLSL_100 1", + "#define FXAA_QUALITY_PRESET 12", + "", + "#define FXAA_GREEN_AS_LUMA 1", + "", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_PC_CONSOLE", + " //", + " // The console algorithm for PC is included", + " // for developers targeting really low spec machines.", + " // Likely better to just run FXAA_PC, and use a really low preset.", + " //", + " #define FXAA_PC_CONSOLE 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_GLSL_120", + " #define FXAA_GLSL_120 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_GLSL_130", + " #define FXAA_GLSL_130 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_HLSL_3", + " #define FXAA_HLSL_3 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_HLSL_4", + " #define FXAA_HLSL_4 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_HLSL_5", + " #define FXAA_HLSL_5 0", + "#endif", + "/*==========================================================================*/", + "#ifndef FXAA_GREEN_AS_LUMA", + " //", + " // For those using non-linear color,", + " // and either not able to get luma in alpha, or not wanting to,", + " // this enables FXAA to run using green as a proxy for luma.", + " // So with this enabled, no need to pack luma in alpha.", + " //", + " // This will turn off AA on anything which lacks some amount of green.", + " // Pure red and blue or combination of only R and B, will get no AA.", + " //", + " // Might want to lower the settings for both,", + " // fxaaConsoleEdgeThresholdMin", + " // fxaaQualityEdgeThresholdMin", + " // In order to insure AA does not get turned off on colors", + " // which contain a minor amount of green.", + " //", + " // 1 = On.", + " // 0 = Off.", + " //", + " #define FXAA_GREEN_AS_LUMA 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_EARLY_EXIT", + " //", + " // Controls algorithm's early exit path.", + " // On PS3 turning this ON adds 2 cycles to the shader.", + " // On 360 turning this OFF adds 10ths of a millisecond to the shader.", + " // Turning this off on console will result in a more blurry image.", + " // So this defaults to on.", + " //", + " // 1 = On.", + " // 0 = Off.", + " //", + " #define FXAA_EARLY_EXIT 1", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_DISCARD", + " //", + " // Only valid for PC OpenGL currently.", + " // Probably will not work when FXAA_GREEN_AS_LUMA = 1.", + " //", + " // 1 = Use discard on pixels which don't need AA.", + " // For APIs which enable concurrent TEX+ROP from same surface.", + " // 0 = Return unchanged color on pixels which don't need AA.", + " //", + " #define FXAA_DISCARD 0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_FAST_PIXEL_OFFSET", + " //", + " // Used for GLSL 120 only.", + " //", + " // 1 = GL API supports fast pixel offsets", + " // 0 = do not use fast pixel offsets", + " //", + " #ifdef GL_EXT_gpu_shader4", + " #define FXAA_FAST_PIXEL_OFFSET 1", + " #endif", + " #ifdef GL_NV_gpu_shader5", + " #define FXAA_FAST_PIXEL_OFFSET 1", + " #endif", + " #ifdef GL_ARB_gpu_shader5", + " #define FXAA_FAST_PIXEL_OFFSET 1", + " #endif", + " #ifndef FXAA_FAST_PIXEL_OFFSET", + " #define FXAA_FAST_PIXEL_OFFSET 0", + " #endif", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#ifndef FXAA_GATHER4_ALPHA", + " //", + " // 1 = API supports gather4 on alpha channel.", + " // 0 = API does not support gather4 on alpha channel.", + " //", + " #if (FXAA_HLSL_5 == 1)", + " #define FXAA_GATHER4_ALPHA 1", + " #endif", + " #ifdef GL_ARB_gpu_shader5", + " #define FXAA_GATHER4_ALPHA 1", + " #endif", + " #ifdef GL_NV_gpu_shader5", + " #define FXAA_GATHER4_ALPHA 1", + " #endif", + " #ifndef FXAA_GATHER4_ALPHA", + " #define FXAA_GATHER4_ALPHA 0", + " #endif", + "#endif", + "", + "", + "/*============================================================================", + " FXAA QUALITY - TUNING KNOBS", + "------------------------------------------------------------------------------", + "NOTE the other tuning knobs are now in the shader function inputs!", + "============================================================================*/", + "#ifndef FXAA_QUALITY_PRESET", + " //", + " // Choose the quality preset.", + " // This needs to be compiled into the shader as it effects code.", + " // Best option to include multiple presets is to", + " // in each shader define the preset, then include this file.", + " //", + " // OPTIONS", + " // -----------------------------------------------------------------------", + " // 10 to 15 - default medium dither (10=fastest, 15=highest quality)", + " // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)", + " // 39 - no dither, very expensive", + " //", + " // NOTES", + " // -----------------------------------------------------------------------", + " // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)", + " // 13 = about same speed as FXAA 3.9 and better than 12", + " // 23 = closest to FXAA 3.9 visually and performance wise", + " // _ = the lowest digit is directly related to performance", + " // _ = the highest digit is directly related to style", + " //", + " #define FXAA_QUALITY_PRESET 12", + "#endif", + "", + "", + "/*============================================================================", + "", + " FXAA QUALITY - PRESETS", + "", + "============================================================================*/", + "", + "/*============================================================================", + " FXAA QUALITY - MEDIUM DITHER PRESETS", + "============================================================================*/", + "#if (FXAA_QUALITY_PRESET == 10)", + " #define FXAA_QUALITY_PS 3", + " #define FXAA_QUALITY_P0 1.5", + " #define FXAA_QUALITY_P1 3.0", + " #define FXAA_QUALITY_P2 12.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 11)", + " #define FXAA_QUALITY_PS 4", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 3.0", + " #define FXAA_QUALITY_P3 12.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 12)", + " #define FXAA_QUALITY_PS 5", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 4.0", + " #define FXAA_QUALITY_P4 12.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 13)", + " #define FXAA_QUALITY_PS 6", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 4.0", + " #define FXAA_QUALITY_P5 12.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 14)", + " #define FXAA_QUALITY_PS 7", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 4.0", + " #define FXAA_QUALITY_P6 12.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 15)", + " #define FXAA_QUALITY_PS 8", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 2.0", + " #define FXAA_QUALITY_P6 4.0", + " #define FXAA_QUALITY_P7 12.0", + "#endif", + "", + "/*============================================================================", + " FXAA QUALITY - LOW DITHER PRESETS", + "============================================================================*/", + "#if (FXAA_QUALITY_PRESET == 20)", + " #define FXAA_QUALITY_PS 3", + " #define FXAA_QUALITY_P0 1.5", + " #define FXAA_QUALITY_P1 2.0", + " #define FXAA_QUALITY_P2 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 21)", + " #define FXAA_QUALITY_PS 4", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 22)", + " #define FXAA_QUALITY_PS 5", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 23)", + " #define FXAA_QUALITY_PS 6", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 24)", + " #define FXAA_QUALITY_PS 7", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 3.0", + " #define FXAA_QUALITY_P6 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 25)", + " #define FXAA_QUALITY_PS 8", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 2.0", + " #define FXAA_QUALITY_P6 4.0", + " #define FXAA_QUALITY_P7 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 26)", + " #define FXAA_QUALITY_PS 9", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 2.0", + " #define FXAA_QUALITY_P6 2.0", + " #define FXAA_QUALITY_P7 4.0", + " #define FXAA_QUALITY_P8 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 27)", + " #define FXAA_QUALITY_PS 10", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 2.0", + " #define FXAA_QUALITY_P6 2.0", + " #define FXAA_QUALITY_P7 2.0", + " #define FXAA_QUALITY_P8 4.0", + " #define FXAA_QUALITY_P9 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 28)", + " #define FXAA_QUALITY_PS 11", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 2.0", + " #define FXAA_QUALITY_P6 2.0", + " #define FXAA_QUALITY_P7 2.0", + " #define FXAA_QUALITY_P8 2.0", + " #define FXAA_QUALITY_P9 4.0", + " #define FXAA_QUALITY_P10 8.0", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_QUALITY_PRESET == 29)", + " #define FXAA_QUALITY_PS 12", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.5", + " #define FXAA_QUALITY_P2 2.0", + " #define FXAA_QUALITY_P3 2.0", + " #define FXAA_QUALITY_P4 2.0", + " #define FXAA_QUALITY_P5 2.0", + " #define FXAA_QUALITY_P6 2.0", + " #define FXAA_QUALITY_P7 2.0", + " #define FXAA_QUALITY_P8 2.0", + " #define FXAA_QUALITY_P9 2.0", + " #define FXAA_QUALITY_P10 4.0", + " #define FXAA_QUALITY_P11 8.0", + "#endif", + "", + "/*============================================================================", + " FXAA QUALITY - EXTREME QUALITY", + "============================================================================*/", + "#if (FXAA_QUALITY_PRESET == 39)", + " #define FXAA_QUALITY_PS 12", + " #define FXAA_QUALITY_P0 1.0", + " #define FXAA_QUALITY_P1 1.0", + " #define FXAA_QUALITY_P2 1.0", + " #define FXAA_QUALITY_P3 1.0", + " #define FXAA_QUALITY_P4 1.0", + " #define FXAA_QUALITY_P5 1.5", + " #define FXAA_QUALITY_P6 2.0", + " #define FXAA_QUALITY_P7 2.0", + " #define FXAA_QUALITY_P8 2.0", + " #define FXAA_QUALITY_P9 2.0", + " #define FXAA_QUALITY_P10 4.0", + " #define FXAA_QUALITY_P11 8.0", + "#endif", + "", + "", + "", + "/*============================================================================", + "", + " API PORTING", + "", + "============================================================================*/", + "#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)", + " #define FxaaBool bool", + " #define FxaaDiscard discard", + " #define FxaaFloat float", + " #define FxaaFloat2 vec2", + " #define FxaaFloat3 vec3", + " #define FxaaFloat4 vec4", + " #define FxaaHalf float", + " #define FxaaHalf2 vec2", + " #define FxaaHalf3 vec3", + " #define FxaaHalf4 vec4", + " #define FxaaInt2 ivec2", + " #define FxaaSat(x) clamp(x, 0.0, 1.0)", + " #define FxaaTex sampler2D", + "#else", + " #define FxaaBool bool", + " #define FxaaDiscard clip(-1)", + " #define FxaaFloat float", + " #define FxaaFloat2 float2", + " #define FxaaFloat3 float3", + " #define FxaaFloat4 float4", + " #define FxaaHalf half", + " #define FxaaHalf2 half2", + " #define FxaaHalf3 half3", + " #define FxaaHalf4 half4", + " #define FxaaSat(x) saturate(x)", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_GLSL_100 == 1)", + " #define FxaaTexTop(t, p) texture2D(t, p, 0.0)", + " #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_GLSL_120 == 1)", + " // Requires,", + " // #version 120", + " // And at least,", + " // #extension GL_EXT_gpu_shader4 : enable", + " // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)", + " #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)", + " #if (FXAA_FAST_PIXEL_OFFSET == 1)", + " #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)", + " #else", + " #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)", + " #endif", + " #if (FXAA_GATHER4_ALPHA == 1)", + " // use #extension GL_ARB_gpu_shader5 : enable", + " #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)", + " #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)", + " #define FxaaTexGreen4(t, p) textureGather(t, p, 1)", + " #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)", + " #endif", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_GLSL_130 == 1)", + " // Requires \"#version 130\" or better", + " #define FxaaTexTop(t, p) textureLod(t, p, 0.0)", + " #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)", + " #if (FXAA_GATHER4_ALPHA == 1)", + " // use #extension GL_ARB_gpu_shader5 : enable", + " #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)", + " #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)", + " #define FxaaTexGreen4(t, p) textureGather(t, p, 1)", + " #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)", + " #endif", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_HLSL_3 == 1)", + " #define FxaaInt2 float2", + " #define FxaaTex sampler2D", + " #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))", + " #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_HLSL_4 == 1)", + " #define FxaaInt2 int2", + " struct FxaaTex { SamplerState smpl; Texture2D tex; };", + " #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)", + " #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)", + "#endif", + "/*--------------------------------------------------------------------------*/", + "#if (FXAA_HLSL_5 == 1)", + " #define FxaaInt2 int2", + " struct FxaaTex { SamplerState smpl; Texture2D tex; };", + " #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)", + " #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)", + " #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)", + " #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)", + " #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)", + " #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)", + "#endif", + "", + "", + "/*============================================================================", + " GREEN AS LUMA OPTION SUPPORT FUNCTION", + "============================================================================*/", + "#if (FXAA_GREEN_AS_LUMA == 0)", + " FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }", + "#else", + " FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }", + "#endif", + "", + "", + "", + "", + "/*============================================================================", + "", + " FXAA3 QUALITY - PC", + "", + "============================================================================*/", + "#if (FXAA_PC == 1)", + "/*--------------------------------------------------------------------------*/", + "FxaaFloat4 FxaaPixelShader(", + " //", + " // Use noperspective interpolation here (turn off perspective interpolation).", + " // {xy} = center of pixel", + " FxaaFloat2 pos,", + " //", + " // Used only for FXAA Console, and not used on the 360 version.", + " // Use noperspective interpolation here (turn off perspective interpolation).", + " // {xy_} = upper left of pixel", + " // {_zw} = lower right of pixel", + " FxaaFloat4 fxaaConsolePosPos,", + " //", + " // Input color texture.", + " // {rgb_} = color in linear or perceptual color space", + " // if (FXAA_GREEN_AS_LUMA == 0)", + " // {__a} = luma in perceptual color space (not linear)", + " FxaaTex tex,", + " //", + " // Only used on the optimized 360 version of FXAA Console.", + " // For everything but 360, just use the same input here as for \"tex\".", + " // For 360, same texture, just alias with a 2nd sampler.", + " // This sampler needs to have an exponent bias of -1.", + " FxaaTex fxaaConsole360TexExpBiasNegOne,", + " //", + " // Only used on the optimized 360 version of FXAA Console.", + " // For everything but 360, just use the same input here as for \"tex\".", + " // For 360, same texture, just alias with a 3nd sampler.", + " // This sampler needs to have an exponent bias of -2.", + " FxaaTex fxaaConsole360TexExpBiasNegTwo,", + " //", + " // Only used on FXAA Quality.", + " // This must be from a constant/uniform.", + " // {x_} = 1.0/screenWidthInPixels", + " // {_y} = 1.0/screenHeightInPixels", + " FxaaFloat2 fxaaQualityRcpFrame,", + " //", + " // Only used on FXAA Console.", + " // This must be from a constant/uniform.", + " // This effects sub-pixel AA quality and inversely sharpness.", + " // Where N ranges between,", + " // N = 0.50 (default)", + " // N = 0.33 (sharper)", + " // {x__} = -N/screenWidthInPixels", + " // {_y_} = -N/screenHeightInPixels", + " // {_z_} = N/screenWidthInPixels", + " // {__w} = N/screenHeightInPixels", + " FxaaFloat4 fxaaConsoleRcpFrameOpt,", + " //", + " // Only used on FXAA Console.", + " // Not used on 360, but used on PS3 and PC.", + " // This must be from a constant/uniform.", + " // {x__} = -2.0/screenWidthInPixels", + " // {_y_} = -2.0/screenHeightInPixels", + " // {_z_} = 2.0/screenWidthInPixels", + " // {__w} = 2.0/screenHeightInPixels", + " FxaaFloat4 fxaaConsoleRcpFrameOpt2,", + " //", + " // Only used on FXAA Console.", + " // Only used on 360 in place of fxaaConsoleRcpFrameOpt2.", + " // This must be from a constant/uniform.", + " // {x__} = 8.0/screenWidthInPixels", + " // {_y_} = 8.0/screenHeightInPixels", + " // {_z_} = -4.0/screenWidthInPixels", + " // {__w} = -4.0/screenHeightInPixels", + " FxaaFloat4 fxaaConsole360RcpFrameOpt2,", + " //", + " // Only used on FXAA Quality.", + " // This used to be the FXAA_QUALITY_SUBPIX define.", + " // It is here now to allow easier tuning.", + " // Choose the amount of sub-pixel aliasing removal.", + " // This can effect sharpness.", + " // 1.00 - upper limit (softer)", + " // 0.75 - default amount of filtering", + " // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)", + " // 0.25 - almost off", + " // 0.00 - completely off", + " FxaaFloat fxaaQualitySubpix,", + " //", + " // Only used on FXAA Quality.", + " // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.", + " // It is here now to allow easier tuning.", + " // The minimum amount of local contrast required to apply algorithm.", + " // 0.333 - too little (faster)", + " // 0.250 - low quality", + " // 0.166 - default", + " // 0.125 - high quality", + " // 0.063 - overkill (slower)", + " FxaaFloat fxaaQualityEdgeThreshold,", + " //", + " // Only used on FXAA Quality.", + " // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.", + " // It is here now to allow easier tuning.", + " // Trims the algorithm from processing darks.", + " // 0.0833 - upper limit (default, the start of visible unfiltered edges)", + " // 0.0625 - high quality (faster)", + " // 0.0312 - visible limit (slower)", + " // Special notes when using FXAA_GREEN_AS_LUMA,", + " // Likely want to set this to zero.", + " // As colors that are mostly not-green", + " // will appear very dark in the green channel!", + " // Tune by looking at mostly non-green content,", + " // then start at zero and increase until aliasing is a problem.", + " FxaaFloat fxaaQualityEdgeThresholdMin,", + " //", + " // Only used on FXAA Console.", + " // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.", + " // It is here now to allow easier tuning.", + " // This does not effect PS3, as this needs to be compiled in.", + " // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.", + " // Due to the PS3 being ALU bound,", + " // there are only three safe values here: 2 and 4 and 8.", + " // These options use the shaders ability to a free *|/ by 2|4|8.", + " // For all other platforms can be a non-power of two.", + " // 8.0 is sharper (default!!!)", + " // 4.0 is softer", + " // 2.0 is really soft (good only for vector graphics inputs)", + " FxaaFloat fxaaConsoleEdgeSharpness,", + " //", + " // Only used on FXAA Console.", + " // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.", + " // It is here now to allow easier tuning.", + " // This does not effect PS3, as this needs to be compiled in.", + " // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.", + " // Due to the PS3 being ALU bound,", + " // there are only two safe values here: 1/4 and 1/8.", + " // These options use the shaders ability to a free *|/ by 2|4|8.", + " // The console setting has a different mapping than the quality setting.", + " // Other platforms can use other values.", + " // 0.125 leaves less aliasing, but is softer (default!!!)", + " // 0.25 leaves more aliasing, and is sharper", + " FxaaFloat fxaaConsoleEdgeThreshold,", + " //", + " // Only used on FXAA Console.", + " // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.", + " // It is here now to allow easier tuning.", + " // Trims the algorithm from processing darks.", + " // The console setting has a different mapping than the quality setting.", + " // This only applies when FXAA_EARLY_EXIT is 1.", + " // This does not apply to PS3,", + " // PS3 was simplified to avoid more shader instructions.", + " // 0.06 - faster but more aliasing in darks", + " // 0.05 - default", + " // 0.04 - slower and less aliasing in darks", + " // Special notes when using FXAA_GREEN_AS_LUMA,", + " // Likely want to set this to zero.", + " // As colors that are mostly not-green", + " // will appear very dark in the green channel!", + " // Tune by looking at mostly non-green content,", + " // then start at zero and increase until aliasing is a problem.", + " FxaaFloat fxaaConsoleEdgeThresholdMin,", + " //", + " // Extra constants for 360 FXAA Console only.", + " // Use zeros or anything else for other platforms.", + " // These must be in physical constant registers and NOT immediates.", + " // Immediates will result in compiler un-optimizing.", + " // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)", + " FxaaFloat4 fxaaConsole360ConstDir", + ") {", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat2 posM;", + " posM.x = pos.x;", + " posM.y = pos.y;", + " #if (FXAA_GATHER4_ALPHA == 1)", + " #if (FXAA_DISCARD == 0)", + " FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);", + " #if (FXAA_GREEN_AS_LUMA == 0)", + " #define lumaM rgbyM.w", + " #else", + " #define lumaM rgbyM.y", + " #endif", + " #endif", + " #if (FXAA_GREEN_AS_LUMA == 0)", + " FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);", + " FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));", + " #else", + " FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);", + " FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));", + " #endif", + " #if (FXAA_DISCARD == 1)", + " #define lumaM luma4A.w", + " #endif", + " #define lumaE luma4A.z", + " #define lumaS luma4A.x", + " #define lumaSE luma4A.y", + " #define lumaNW luma4B.w", + " #define lumaN luma4B.z", + " #define lumaW luma4B.x", + " #else", + " FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);", + " #if (FXAA_GREEN_AS_LUMA == 0)", + " #define lumaM rgbyM.w", + " #else", + " #define lumaM rgbyM.y", + " #endif", + " #if (FXAA_GLSL_100 == 1)", + " FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));", + " #else", + " FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));", + " #endif", + " #endif", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat maxSM = max(lumaS, lumaM);", + " FxaaFloat minSM = min(lumaS, lumaM);", + " FxaaFloat maxESM = max(lumaE, maxSM);", + " FxaaFloat minESM = min(lumaE, minSM);", + " FxaaFloat maxWN = max(lumaN, lumaW);", + " FxaaFloat minWN = min(lumaN, lumaW);", + " FxaaFloat rangeMax = max(maxWN, maxESM);", + " FxaaFloat rangeMin = min(minWN, minESM);", + " FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;", + " FxaaFloat range = rangeMax - rangeMin;", + " FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);", + " FxaaBool earlyExit = range < rangeMaxClamped;", + "/*--------------------------------------------------------------------------*/", + " if(earlyExit)", + " #if (FXAA_DISCARD == 1)", + " FxaaDiscard;", + " #else", + " return rgbyM;", + " #endif", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_GATHER4_ALPHA == 0)", + " #if (FXAA_GLSL_100 == 1)", + " FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));", + " #else", + " FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));", + " #endif", + " #else", + " FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));", + " FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));", + " #endif", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat lumaNS = lumaN + lumaS;", + " FxaaFloat lumaWE = lumaW + lumaE;", + " FxaaFloat subpixRcpRange = 1.0/range;", + " FxaaFloat subpixNSWE = lumaNS + lumaWE;", + " FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;", + " FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat lumaNESE = lumaNE + lumaSE;", + " FxaaFloat lumaNWNE = lumaNW + lumaNE;", + " FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;", + " FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat lumaNWSW = lumaNW + lumaSW;", + " FxaaFloat lumaSWSE = lumaSW + lumaSE;", + " FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);", + " FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);", + " FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;", + " FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;", + " FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;", + " FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;", + " FxaaFloat lengthSign = fxaaQualityRcpFrame.x;", + " FxaaBool horzSpan = edgeHorz >= edgeVert;", + " FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;", + "/*--------------------------------------------------------------------------*/", + " if(!horzSpan) lumaN = lumaW;", + " if(!horzSpan) lumaS = lumaE;", + " if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;", + " FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat gradientN = lumaN - lumaM;", + " FxaaFloat gradientS = lumaS - lumaM;", + " FxaaFloat lumaNN = lumaN + lumaM;", + " FxaaFloat lumaSS = lumaS + lumaM;", + " FxaaBool pairN = abs(gradientN) >= abs(gradientS);", + " FxaaFloat gradient = max(abs(gradientN), abs(gradientS));", + " if(pairN) lengthSign = -lengthSign;", + " FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat2 posB;", + " posB.x = posM.x;", + " posB.y = posM.y;", + " FxaaFloat2 offNP;", + " offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;", + " offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;", + " if(!horzSpan) posB.x += lengthSign * 0.5;", + " if( horzSpan) posB.y += lengthSign * 0.5;", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat2 posN;", + " posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;", + " posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;", + " FxaaFloat2 posP;", + " posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;", + " posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;", + " FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;", + " FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));", + " FxaaFloat subpixE = subpixC * subpixC;", + " FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));", + "/*--------------------------------------------------------------------------*/", + " if(!pairN) lumaNN = lumaSS;", + " FxaaFloat gradientScaled = gradient * 1.0/4.0;", + " FxaaFloat lumaMM = lumaM - lumaNN * 0.5;", + " FxaaFloat subpixF = subpixD * subpixE;", + " FxaaBool lumaMLTZero = lumaMM < 0.0;", + "/*--------------------------------------------------------------------------*/", + " lumaEndN -= lumaNN * 0.5;", + " lumaEndP -= lumaNN * 0.5;", + " FxaaBool doneN = abs(lumaEndN) >= gradientScaled;", + " FxaaBool doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;", + " FxaaBool doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;", + "/*--------------------------------------------------------------------------*/", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 3)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 4)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 5)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 6)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 7)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 8)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 9)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 10)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 11)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;", + "/*--------------------------------------------------------------------------*/", + " #if (FXAA_QUALITY_PS > 12)", + " if(doneNP) {", + " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));", + " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));", + " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;", + " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;", + " doneN = abs(lumaEndN) >= gradientScaled;", + " doneP = abs(lumaEndP) >= gradientScaled;", + " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;", + " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;", + " doneNP = (!doneN) || (!doneP);", + " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;", + " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + " #endif", + "/*--------------------------------------------------------------------------*/", + " }", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat dstN = posM.x - posN.x;", + " FxaaFloat dstP = posP.x - posM.x;", + " if(!horzSpan) dstN = posM.y - posN.y;", + " if(!horzSpan) dstP = posP.y - posM.y;", + "/*--------------------------------------------------------------------------*/", + " FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;", + " FxaaFloat spanLength = (dstP + dstN);", + " FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;", + " FxaaFloat spanLengthRcp = 1.0/spanLength;", + "/*--------------------------------------------------------------------------*/", + " FxaaBool directionN = dstN < dstP;", + " FxaaFloat dst = min(dstN, dstP);", + " FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;", + " FxaaFloat subpixG = subpixF * subpixF;", + " FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;", + " FxaaFloat subpixH = subpixG * fxaaQualitySubpix;", + "/*--------------------------------------------------------------------------*/", + " FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;", + " FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);", + " if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;", + " if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;", + " #if (FXAA_DISCARD == 1)", + " return FxaaTexTop(tex, posM);", + " #else", + " return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);", + " #endif", + "}", + "/*==========================================================================*/", + "#endif", + "", + "void main() {", + " gl_FragColor = FxaaPixelShader(", + " vUv,", + " vec4(0.0),", + " tDiffuse,", + " tDiffuse,", + " tDiffuse,", + " resolution,", + " vec4(0.0),", + " vec4(0.0),", + " vec4(0.0),", + " 0.75,", + " 0.166,", + " 0.0833,", + " 0.0,", + " 0.0,", + " 0.0,", + " vec4(0.0)", + " );", + "", + " // TODO avoid querying texture twice for same texel", + " gl_FragColor.a = texture2D(tDiffuse, vUv).a;", + "}" + ].join("\n") + +}; diff --git a/three/jsutil/shaders/FilmShader.js b/three/jsutil/shaders/FilmShader.js new file mode 100644 index 000000000..3028fbc33 --- /dev/null +++ b/three/jsutil/shaders/FilmShader.js @@ -0,0 +1,104 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Film grain & scanlines shader + * + * - ported from HLSL to WebGL / GLSL + * http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html + * + * Screen Space Static Postprocessor + * + * Produces an analogue noise overlay similar to a film grain / TV static + * + * Original implementation and noise algorithm + * Pat 'Hawthorne' Shearon + * + * Optimized scanlines + noise version with intensity scaling + * Georg 'Leviathan' Steinrohder + * + * This version is provided under a Creative Commons Attribution 3.0 License + * http://creativecommons.org/licenses/by/3.0/ + */ + +THREE.FilmShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "time": { value: 0.0 }, + "nIntensity": { value: 0.5 }, + "sIntensity": { value: 0.05 }, + "sCount": { value: 4096 }, + "grayscale": { value: 1 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#include ", + + // control parameter + "uniform float time;", + + "uniform bool grayscale;", + + // noise effect intensity value (0 = no effect, 1 = full effect) + "uniform float nIntensity;", + + // scanlines effect intensity value (0 = no effect, 1 = full effect) + "uniform float sIntensity;", + + // scanlines effect count value (0 = no effect, 4096 = full effect) + "uniform float sCount;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + // sample the source + "vec4 cTextureScreen = texture2D( tDiffuse, vUv );", + + // make some noise + "float dx = rand( vUv + time );", + + // add noise + "vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );", + + // get us a sine and cosine + "vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );", + + // add scanlines + "cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;", + + // interpolate between source and result by intensity + "cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );", + + // convert to grayscale if desired + "if( grayscale ) {", + + "cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );", + + "}", + + "gl_FragColor = vec4( cResult, cTextureScreen.a );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/FocusShader.js b/three/jsutil/shaders/FocusShader.js new file mode 100644 index 000000000..0afbd60f0 --- /dev/null +++ b/three/jsutil/shaders/FocusShader.js @@ -0,0 +1,91 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Focus shader + * based on PaintEffect postprocess from ro.me + * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js + */ + +THREE.FocusShader = { + + uniforms : { + + "tDiffuse": { value: null }, + "screenWidth": { value: 1024 }, + "screenHeight": { value: 1024 }, + "sampleDistance": { value: 0.94 }, + "waveFactor": { value: 0.00125 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float screenWidth;", + "uniform float screenHeight;", + "uniform float sampleDistance;", + "uniform float waveFactor;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 color, org, tmp, add;", + "float sample_dist, f;", + "vec2 vin;", + "vec2 uv = vUv;", + + "add = color = org = texture2D( tDiffuse, uv );", + + "vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );", + "sample_dist = dot( vin, vin ) * 2.0;", + + "f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;", + + "vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );", + + "add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );", + "if( tmp.b < color.b ) color = tmp;", + + "color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );", + "color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );", + + "gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );", + + "}" + + + ].join( "\n" ) +}; diff --git a/three/jsutil/shaders/FreiChenShader.js b/three/jsutil/shaders/FreiChenShader.js new file mode 100644 index 000000000..0ca440d71 --- /dev/null +++ b/three/jsutil/shaders/FreiChenShader.js @@ -0,0 +1,93 @@ +/** + * @author zz85 / https://github.com/zz85 | https://www.lab4games.net/zz85/blog + * + * Edge Detection Shader using Frei-Chen filter + * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector + * + * aspect: vec2 of (1/width, 1/height) + */ + +THREE.FreiChenShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "aspect": { value: new THREE.Vector2( 512, 512 ) } + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "varying vec2 vUv;", + + "uniform vec2 aspect;", + + "vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);", + + + "mat3 G[9];", + + // hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45 + + "const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );", + "const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );", + "const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );", + "const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );", + "const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );", + "const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );", + "const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );", + "const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );", + "const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );", + + "void main(void)", + "{", + + "G[0] = g0,", + "G[1] = g1,", + "G[2] = g2,", + "G[3] = g3,", + "G[4] = g4,", + "G[5] = g5,", + "G[6] = g6,", + "G[7] = g7,", + "G[8] = g8;", + + "mat3 I;", + "float cnv[9];", + "vec3 sample;", + + /* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */ + "for (float i=0.0; i<3.0; i++) {", + "for (float j=0.0; j<3.0; j++) {", + "sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;", + "I[int(i)][int(j)] = length(sample);", + "}", + "}", + + /* calculate the convolution values for all the masks */ + "for (int i=0; i<9; i++) {", + "float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);", + "cnv[i] = dp3 * dp3;", + "}", + + "float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);", + "float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);", + + "gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);", + "}" + + ].join( "\n" ) +}; diff --git a/three/jsutil/shaders/FresnelShader.js b/three/jsutil/shaders/FresnelShader.js new file mode 100644 index 000000000..e7639a723 --- /dev/null +++ b/three/jsutil/shaders/FresnelShader.js @@ -0,0 +1,74 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Based on Nvidia Cg tutorial + */ + +THREE.FresnelShader = { + + uniforms: { + + "mRefractionRatio": { value: 1.02 }, + "mFresnelBias": { value: 0.1 }, + "mFresnelPower": { value: 2.0 }, + "mFresnelScale": { value: 1.0 }, + "tCube": { value: null } + + }, + + vertexShader: [ + + "uniform float mRefractionRatio;", + "uniform float mFresnelBias;", + "uniform float mFresnelScale;", + "uniform float mFresnelPower;", + + "varying vec3 vReflect;", + "varying vec3 vRefract[3];", + "varying float vReflectionFactor;", + + "void main() {", + + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", + "vec4 worldPosition = modelMatrix * vec4( position, 1.0 );", + + "vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );", + + "vec3 I = worldPosition.xyz - cameraPosition;", + + "vReflect = reflect( I, worldNormal );", + "vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );", + "vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );", + "vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );", + "vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );", + + "gl_Position = projectionMatrix * mvPosition;", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform samplerCube tCube;", + + "varying vec3 vReflect;", + "varying vec3 vRefract[3];", + "varying float vReflectionFactor;", + + "void main() {", + + "vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );", + "vec4 refractedColor = vec4( 1.0 );", + + "refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;", + "refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;", + "refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;", + + "gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/GammaCorrectionShader.js b/three/jsutil/shaders/GammaCorrectionShader.js new file mode 100644 index 000000000..4c2a373fb --- /dev/null +++ b/three/jsutil/shaders/GammaCorrectionShader.js @@ -0,0 +1,45 @@ +/** + * @author WestLangley / http://github.com/WestLangley + * + * Gamma Correction Shader + * http://en.wikipedia.org/wiki/gamma_correction + */ + +THREE.GammaCorrectionShader = { + + uniforms: { + + "tDiffuse": { value: null } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );", + + "gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/HalftoneShader.js b/three/jsutil/shaders/HalftoneShader.js new file mode 100644 index 000000000..56df6b935 --- /dev/null +++ b/three/jsutil/shaders/HalftoneShader.js @@ -0,0 +1,314 @@ +/** + * @author meatbags / xavierburrow.com, github/meatbags + * + * RGB Halftone shader for three.js. + * NOTE: + * Shape (1 = Dot, 2 = Ellipse, 3 = Line, 4 = Square) + * Blending Mode (1 = Linear, 2 = Multiply, 3 = Add, 4 = Lighter, 5 = Darker) + */ + +THREE.HalftoneShader = { + + uniforms: { + "tDiffuse": { value: null }, + "shape": { value: 1 }, + "radius": { value: 4 }, + "rotateR": { value: Math.PI / 12 * 1 }, + "rotateG": { value: Math.PI / 12 * 2 }, + "rotateB": { value: Math.PI / 12 * 3 }, + "scatter": { value: 0 }, + "width": { value: 1 }, + "height": { value: 1 }, + "blending": { value: 1 }, + "blendingMode": { value: 1 }, + "greyscale": { value: false }, + "disable": { value: false } + }, + + vertexShader: [ + + "varying vec2 vUV;", + + "void main() {", + + "vUV = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#define SQRT2_MINUS_ONE 0.41421356", + "#define SQRT2_HALF_MINUS_ONE 0.20710678", + "#define PI2 6.28318531", + "#define SHAPE_DOT 1", + "#define SHAPE_ELLIPSE 2", + "#define SHAPE_LINE 3", + "#define SHAPE_SQUARE 4", + "#define BLENDING_LINEAR 1", + "#define BLENDING_MULTIPLY 2", + "#define BLENDING_ADD 3", + "#define BLENDING_LIGHTER 4", + "#define BLENDING_DARKER 5", + "uniform sampler2D tDiffuse;", + "uniform float radius;", + "uniform float rotateR;", + "uniform float rotateG;", + "uniform float rotateB;", + "uniform float scatter;", + "uniform float width;", + "uniform float height;", + "uniform int shape;", + "uniform bool disable;", + "uniform float blending;", + "uniform int blendingMode;", + "varying vec2 vUV;", + "uniform bool greyscale;", + "const int samples = 8;", + + "float blend( float a, float b, float t ) {", + + // linear blend + "return a * ( 1.0 - t ) + b * t;", + + "}", + + "float hypot( float x, float y ) {", + + // vector magnitude + "return sqrt( x * x + y * y );", + + "}", + + "float rand( vec2 seed ){", + + // get pseudo-random number + "return fract( sin( dot( seed.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 );", + + "}", + + "float distanceToDotRadius( float channel, vec2 coord, vec2 normal, vec2 p, float angle, float rad_max ) {", + + // apply shape-specific transforms + "float dist = hypot( coord.x - p.x, coord.y - p.y );", + "float rad = channel;", + + "if ( shape == SHAPE_DOT ) {", + + "rad = pow( abs( rad ), 1.125 ) * rad_max;", + + "} else if ( shape == SHAPE_ELLIPSE ) {", + + "rad = pow( abs( rad ), 1.125 ) * rad_max;", + + "if ( dist != 0.0 ) {", + "float dot_p = abs( ( p.x - coord.x ) / dist * normal.x + ( p.y - coord.y ) / dist * normal.y );", + "dist = ( dist * ( 1.0 - SQRT2_HALF_MINUS_ONE ) ) + dot_p * dist * SQRT2_MINUS_ONE;", + "}", + + "} else if ( shape == SHAPE_LINE ) {", + + "rad = pow( abs( rad ), 1.5) * rad_max;", + "float dot_p = ( p.x - coord.x ) * normal.x + ( p.y - coord.y ) * normal.y;", + "dist = hypot( normal.x * dot_p, normal.y * dot_p );", + + "} else if ( shape == SHAPE_SQUARE ) {", + + "float theta = atan( p.y - coord.y, p.x - coord.x ) - angle;", + "float sin_t = abs( sin( theta ) );", + "float cos_t = abs( cos( theta ) );", + "rad = pow( abs( rad ), 1.4 );", + "rad = rad_max * ( rad + ( ( sin_t > cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );", + + "}", + + "return rad - dist;", + + "}", + + "struct Cell {", + + // grid sample positions + "vec2 normal;", + "vec2 p1;", + "vec2 p2;", + "vec2 p3;", + "vec2 p4;", + "float samp2;", + "float samp1;", + "float samp3;", + "float samp4;", + + "};", + + "vec4 getSample( vec2 point ) {", + + // multi-sampled point + "vec4 tex = texture2D( tDiffuse, vec2( point.x / width, point.y / height ) );", + "float base = rand( vec2( floor( point.x ), floor( point.y ) ) ) * PI2;", + "float step = PI2 / float( samples );", + "float dist = radius * 0.66;", + + "for ( int i = 0; i < samples; ++i ) {", + + "float r = base + step * float( i );", + "vec2 coord = point + vec2( cos( r ) * dist, sin( r ) * dist );", + "tex += texture2D( tDiffuse, vec2( coord.x / width, coord.y / height ) );", + + "}", + + "tex /= float( samples ) + 1.0;", + "return tex;", + + "}", + + "float getDotColour( Cell c, vec2 p, int channel, float angle, float aa ) {", + + // get colour for given point + "float dist_c_1, dist_c_2, dist_c_3, dist_c_4, res;", + + "if ( channel == 0 ) {", + + "c.samp1 = getSample( c.p1 ).r;", + "c.samp2 = getSample( c.p2 ).r;", + "c.samp3 = getSample( c.p3 ).r;", + "c.samp4 = getSample( c.p4 ).r;", + + "} else if (channel == 1) {", + + "c.samp1 = getSample( c.p1 ).g;", + "c.samp2 = getSample( c.p2 ).g;", + "c.samp3 = getSample( c.p3 ).g;", + "c.samp4 = getSample( c.p4 ).g;", + + "} else {", + + "c.samp1 = getSample( c.p1 ).b;", + "c.samp3 = getSample( c.p3 ).b;", + "c.samp2 = getSample( c.p2 ).b;", + "c.samp4 = getSample( c.p4 ).b;", + + "}", + + "dist_c_1 = distanceToDotRadius( c.samp1, c.p1, c.normal, p, angle, radius );", + "dist_c_2 = distanceToDotRadius( c.samp2, c.p2, c.normal, p, angle, radius );", + "dist_c_3 = distanceToDotRadius( c.samp3, c.p3, c.normal, p, angle, radius );", + "dist_c_4 = distanceToDotRadius( c.samp4, c.p4, c.normal, p, angle, radius );", + "res = ( dist_c_1 > 0.0 ) ? clamp( dist_c_1 / aa, 0.0, 1.0 ) : 0.0;", + "res += ( dist_c_2 > 0.0 ) ? clamp( dist_c_2 / aa, 0.0, 1.0 ) : 0.0;", + "res += ( dist_c_3 > 0.0 ) ? clamp( dist_c_3 / aa, 0.0, 1.0 ) : 0.0;", + "res += ( dist_c_4 > 0.0 ) ? clamp( dist_c_4 / aa, 0.0, 1.0 ) : 0.0;", + "res = clamp( res, 0.0, 1.0 );", + + "return res;", + + "}", + + "Cell getReferenceCell( vec2 p, vec2 origin, float grid_angle, float step ) {", + + // get containing cell + "Cell c;", + + // calc grid + "vec2 n = vec2( cos( grid_angle ), sin( grid_angle ) );", + "float threshold = step * 0.5;", + "float dot_normal = n.x * ( p.x - origin.x ) + n.y * ( p.y - origin.y );", + "float dot_line = -n.y * ( p.x - origin.x ) + n.x * ( p.y - origin.y );", + "vec2 offset = vec2( n.x * dot_normal, n.y * dot_normal );", + "float offset_normal = mod( hypot( offset.x, offset.y ), step );", + "float normal_dir = ( dot_normal < 0.0 ) ? 1.0 : -1.0;", + "float normal_scale = ( ( offset_normal < threshold ) ? -offset_normal : step - offset_normal ) * normal_dir;", + "float offset_line = mod( hypot( ( p.x - offset.x ) - origin.x, ( p.y - offset.y ) - origin.y ), step );", + "float line_dir = ( dot_line < 0.0 ) ? 1.0 : -1.0;", + "float line_scale = ( ( offset_line < threshold ) ? -offset_line : step - offset_line ) * line_dir;", + + // get closest corner + "c.normal = n;", + "c.p1.x = p.x - n.x * normal_scale + n.y * line_scale;", + "c.p1.y = p.y - n.y * normal_scale - n.x * line_scale;", + + // scatter + "if ( scatter != 0.0 ) {", + + "float off_mag = scatter * threshold * 0.5;", + "float off_angle = rand( vec2( floor( c.p1.x ), floor( c.p1.y ) ) ) * PI2;", + "c.p1.x += cos( off_angle ) * off_mag;", + "c.p1.y += sin( off_angle ) * off_mag;", + + "}", + + // find corners + "float normal_step = normal_dir * ( ( offset_normal < threshold ) ? step : -step );", + "float line_step = line_dir * ( ( offset_line < threshold ) ? step : -step );", + "c.p2.x = c.p1.x - n.x * normal_step;", + "c.p2.y = c.p1.y - n.y * normal_step;", + "c.p3.x = c.p1.x + n.y * line_step;", + "c.p3.y = c.p1.y - n.x * line_step;", + "c.p4.x = c.p1.x - n.x * normal_step + n.y * line_step;", + "c.p4.y = c.p1.y - n.y * normal_step - n.x * line_step;", + + "return c;", + + "}", + + "float blendColour( float a, float b, float t ) {", + + // blend colours + "if ( blendingMode == BLENDING_LINEAR ) {", + "return blend( a, b, 1.0 - t );", + "} else if ( blendingMode == BLENDING_ADD ) {", + "return blend( a, min( 1.0, a + b ), t );", + "} else if ( blendingMode == BLENDING_MULTIPLY ) {", + "return blend( a, max( 0.0, a * b ), t );", + "} else if ( blendingMode == BLENDING_LIGHTER ) {", + "return blend( a, max( a, b ), t );", + "} else if ( blendingMode == BLENDING_DARKER ) {", + "return blend( a, min( a, b ), t );", + "} else {", + "return blend( a, b, 1.0 - t );", + "}", + + "}", + + "void main() {", + + "if ( ! disable ) {", + + // setup + "vec2 p = vec2( vUV.x * width, vUV.y * height );", + "vec2 origin = vec2( 0, 0 );", + "float aa = ( radius < 2.5 ) ? radius * 0.5 : 1.25;", + + // get channel samples + "Cell cell_r = getReferenceCell( p, origin, rotateR, radius );", + "Cell cell_g = getReferenceCell( p, origin, rotateG, radius );", + "Cell cell_b = getReferenceCell( p, origin, rotateB, radius );", + "float r = getDotColour( cell_r, p, 0, rotateR, aa );", + "float g = getDotColour( cell_g, p, 1, rotateG, aa );", + "float b = getDotColour( cell_b, p, 2, rotateB, aa );", + + // blend with original + "vec4 colour = texture2D( tDiffuse, vUV );", + "r = blendColour( r, colour.r, blending );", + "g = blendColour( g, colour.g, blending );", + "b = blendColour( b, colour.b, blending );", + + "if ( greyscale ) {", + "r = g = b = (r + b + g) / 3.0;", + "}", + + "gl_FragColor = vec4( r, g, b, 1.0 );", + + "} else {", + + "gl_FragColor = texture2D( tDiffuse, vUV );", + + "}", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/HorizontalBlurShader.js b/three/jsutil/shaders/HorizontalBlurShader.js new file mode 100644 index 000000000..a73c94bad --- /dev/null +++ b/three/jsutil/shaders/HorizontalBlurShader.js @@ -0,0 +1,62 @@ +/** + * @author zz85 / http://www.lab4games.net/zz85/blog + * + * Two pass Gaussian blur filter (horizontal and vertical blur shaders) + * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ + * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html + * + * - 9 samples per pass + * - standard deviation 2.7 + * - "h" and "v" parameters should be set to "1 / width" and "1 / height" + */ + +THREE.HorizontalBlurShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "h": { value: 1.0 / 512.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float h;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 sum = vec4( 0.0 );", + + "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;", + "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;", + + "gl_FragColor = sum;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/HorizontalTiltShiftShader.js b/three/jsutil/shaders/HorizontalTiltShiftShader.js new file mode 100644 index 000000000..3114aba74 --- /dev/null +++ b/three/jsutil/shaders/HorizontalTiltShiftShader.js @@ -0,0 +1,65 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position + * + * - 9 samples per pass + * - standard deviation 2.7 + * - "h" and "v" parameters should be set to "1 / width" and "1 / height" + * - "r" parameter control where "focused" horizontal line lies + */ + +THREE.HorizontalTiltShiftShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "h": { value: 1.0 / 512.0 }, + "r": { value: 0.35 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float h;", + "uniform float r;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 sum = vec4( 0.0 );", + + "float hh = h * abs( r - vUv.y );", + + "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;", + "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;", + + "gl_FragColor = sum;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/HueSaturationShader.js b/three/jsutil/shaders/HueSaturationShader.js new file mode 100644 index 000000000..e22186c94 --- /dev/null +++ b/three/jsutil/shaders/HueSaturationShader.js @@ -0,0 +1,69 @@ +/** + * @author tapio / http://tapio.github.com/ + * + * Hue and saturation adjustment + * https://github.com/evanw/glfx.js + * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc. + * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) + */ + +THREE.HueSaturationShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "hue": { value: 0 }, + "saturation": { value: 0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float hue;", + "uniform float saturation;", + + "varying vec2 vUv;", + + "void main() {", + + "gl_FragColor = texture2D( tDiffuse, vUv );", + + // hue + "float angle = hue * 3.14159265;", + "float s = sin(angle), c = cos(angle);", + "vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;", + "float len = length(gl_FragColor.rgb);", + "gl_FragColor.rgb = vec3(", + "dot(gl_FragColor.rgb, weights.xyz),", + "dot(gl_FragColor.rgb, weights.zxy),", + "dot(gl_FragColor.rgb, weights.yzx)", + ");", + + // saturation + "float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;", + "if (saturation > 0.0) {", + "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));", + "} else {", + "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);", + "}", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/KaleidoShader.js b/three/jsutil/shaders/KaleidoShader.js new file mode 100644 index 000000000..a1ac47cb2 --- /dev/null +++ b/three/jsutil/shaders/KaleidoShader.js @@ -0,0 +1,60 @@ +/** + * @author felixturner / http://airtight.cc/ + * + * Kaleidoscope Shader + * Radial reflection around center point + * Ported from: http://pixelshaders.com/editor/ + * by Toby Schachman / http://tobyschachman.com/ + * + * sides: number of reflections + * angle: initial angle in radians + */ + +THREE.KaleidoShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "sides": { value: 6.0 }, + "angle": { value: 0.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float sides;", + "uniform float angle;", + + "varying vec2 vUv;", + + "void main() {", + + "vec2 p = vUv - 0.5;", + "float r = length(p);", + "float a = atan(p.y, p.x) + angle;", + "float tau = 2. * 3.1416 ;", + "a = mod(a, tau/sides);", + "a = abs(a - tau/sides/2.) ;", + "p = r * vec2(cos(a), sin(a));", + "vec4 color = texture2D(tDiffuse, p + 0.5);", + "gl_FragColor = color;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/LuminosityHighPassShader.js b/three/jsutil/shaders/LuminosityHighPassShader.js new file mode 100644 index 000000000..772d221b1 --- /dev/null +++ b/three/jsutil/shaders/LuminosityHighPassShader.js @@ -0,0 +1,64 @@ +/** + * @author bhouston / http://clara.io/ + * + * Luminosity + * http://en.wikipedia.org/wiki/Luminosity + */ + +THREE.LuminosityHighPassShader = { + + shaderID: "luminosityHighPass", + + uniforms: { + + "tDiffuse": { type: "t", value: null }, + "luminosityThreshold": { type: "f", value: 1.0 }, + "smoothWidth": { type: "f", value: 1.0 }, + "defaultColor": { type: "c", value: new THREE.Color( 0x000000 ) }, + "defaultOpacity": { type: "f", value: 0.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join("\n"), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform vec3 defaultColor;", + "uniform float defaultOpacity;", + "uniform float luminosityThreshold;", + "uniform float smoothWidth;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 texel = texture2D( tDiffuse, vUv );", + + "vec3 luma = vec3( 0.299, 0.587, 0.114 );", + + "float v = dot( texel.xyz, luma );", + + "vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );", + + "float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );", + + "gl_FragColor = mix( outputColor, texel, alpha );", + + "}" + + ].join("\n") + +}; diff --git a/three/jsutil/shaders/LuminosityShader.js b/three/jsutil/shaders/LuminosityShader.js new file mode 100644 index 000000000..19dbbfca0 --- /dev/null +++ b/three/jsutil/shaders/LuminosityShader.js @@ -0,0 +1,50 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Luminosity + * http://en.wikipedia.org/wiki/Luminosity + */ + +THREE.LuminosityShader = { + + uniforms: { + + "tDiffuse": { value: null } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#include ", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 texel = texture2D( tDiffuse, vUv );", + + "float l = linearToRelativeLuminance( texel.rgb );", + + "gl_FragColor = vec4( l, l, l, texel.w );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/MirrorShader.js b/three/jsutil/shaders/MirrorShader.js new file mode 100644 index 000000000..83f7e4fd7 --- /dev/null +++ b/three/jsutil/shaders/MirrorShader.js @@ -0,0 +1,58 @@ +/** + * @author felixturner / http://airtight.cc/ + * + * Mirror Shader + * Copies half the input to the other half + * + * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom) + */ + +THREE.MirrorShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "side": { value: 1 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform int side;", + + "varying vec2 vUv;", + + "void main() {", + + "vec2 p = vUv;", + "if (side == 0){", + "if (p.x > 0.5) p.x = 1.0 - p.x;", + "}else if (side == 1){", + "if (p.x < 0.5) p.x = 1.0 - p.x;", + "}else if (side == 2){", + "if (p.y < 0.5) p.y = 1.0 - p.y;", + "}else if (side == 3){", + "if (p.y > 0.5) p.y = 1.0 - p.y;", + "} ", + "vec4 color = texture2D(tDiffuse, p);", + "gl_FragColor = color;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/NormalMapShader.js b/three/jsutil/shaders/NormalMapShader.js new file mode 100644 index 000000000..957e818f5 --- /dev/null +++ b/three/jsutil/shaders/NormalMapShader.js @@ -0,0 +1,53 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Normal map shader + * - compute normals from heightmap + */ + +THREE.NormalMapShader = { + + uniforms: { + + "heightMap": { value: null }, + "resolution": { value: new THREE.Vector2( 512, 512 ) }, + "scale": { value: new THREE.Vector2( 1, 1 ) }, + "height": { value: 0.05 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float height;", + "uniform vec2 resolution;", + "uniform sampler2D heightMap;", + + "varying vec2 vUv;", + + "void main() {", + + "float val = texture2D( heightMap, vUv ).x;", + + "float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;", + "float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;", + + "gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/OceanShaders.js b/three/jsutil/shaders/OceanShaders.js new file mode 100644 index 000000000..a6e9a80d2 --- /dev/null +++ b/three/jsutil/shaders/OceanShaders.js @@ -0,0 +1,365 @@ +// Author: Aleksandr Albert +// Website: www.routter.co.tt + +// Description: A deep water ocean shader set +// based on an implementation of a Tessendorf Waves +// originally presented by David Li ( www.david.li/waves ) + +// The general method is to apply shaders to simulation Framebuffers +// and then sample these framebuffers when rendering the ocean mesh + +// The set uses 7 shaders: + +// -- Simulation shaders +// [1] ocean_sim_vertex -> Vertex shader used to set up a 2x2 simulation plane centered at (0,0) +// [2] ocean_subtransform -> Fragment shader used to subtransform the mesh (generates the displacement map) +// [3] ocean_initial_spectrum -> Fragment shader used to set intitial wave frequency at a texel coordinate +// [4] ocean_phase -> Fragment shader used to set wave phase at a texel coordinate +// [5] ocean_spectrum -> Fragment shader used to set current wave frequency at a texel coordinate +// [6] ocean_normal -> Fragment shader used to set face normals at a texel coordinate + +// -- Rendering Shader +// [7] ocean_main -> Vertex and Fragment shader used to create the final render + + +THREE.ShaderLib[ 'ocean_sim_vertex' ] = { + vertexShader: [ + 'varying vec2 vUV;', + + 'void main (void) {', + 'vUV = position.xy * 0.5 + 0.5;', + 'gl_Position = vec4(position, 1.0 );', + '}' + ].join( '\n' ) +}; +THREE.ShaderLib[ 'ocean_subtransform' ] = { + uniforms: { + "u_input": { value: null }, + "u_transformSize": { value: 512.0 }, + "u_subtransformSize": { value: 250.0 } + }, + fragmentShader: [ + //GPU FFT using a Stockham formulation + + 'precision highp float;', + '#include ', + + 'uniform sampler2D u_input;', + 'uniform float u_transformSize;', + 'uniform float u_subtransformSize;', + + 'varying vec2 vUV;', + + 'vec2 multiplyComplex (vec2 a, vec2 b) {', + 'return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);', + '}', + + 'void main (void) {', + '#ifdef HORIZONTAL', + 'float index = vUV.x * u_transformSize - 0.5;', + '#else', + 'float index = vUV.y * u_transformSize - 0.5;', + '#endif', + + 'float evenIndex = floor(index / u_subtransformSize) * (u_subtransformSize * 0.5) + mod(index, u_subtransformSize * 0.5);', + + //transform two complex sequences simultaneously + '#ifdef HORIZONTAL', + 'vec4 even = texture2D(u_input, vec2(evenIndex + 0.5, gl_FragCoord.y) / u_transformSize).rgba;', + 'vec4 odd = texture2D(u_input, vec2(evenIndex + u_transformSize * 0.5 + 0.5, gl_FragCoord.y) / u_transformSize).rgba;', + '#else', + 'vec4 even = texture2D(u_input, vec2(gl_FragCoord.x, evenIndex + 0.5) / u_transformSize).rgba;', + 'vec4 odd = texture2D(u_input, vec2(gl_FragCoord.x, evenIndex + u_transformSize * 0.5 + 0.5) / u_transformSize).rgba;', + '#endif', + + 'float twiddleArgument = -2.0 * PI * (index / u_subtransformSize);', + 'vec2 twiddle = vec2(cos(twiddleArgument), sin(twiddleArgument));', + + 'vec2 outputA = even.xy + multiplyComplex(twiddle, odd.xy);', + 'vec2 outputB = even.zw + multiplyComplex(twiddle, odd.zw);', + + 'gl_FragColor = vec4(outputA, outputB);', + '}' + ].join( '\n' ) +}; +THREE.ShaderLib[ 'ocean_initial_spectrum' ] = { + uniforms: { + "u_wind": { value: new THREE.Vector2( 10.0, 10.0 ) }, + "u_resolution": { value: 512.0 }, + "u_size": { value: 250.0 } + }, + fragmentShader: [ + 'precision highp float;', + '#include ', + + 'const float G = 9.81;', + 'const float KM = 370.0;', + 'const float CM = 0.23;', + + 'uniform vec2 u_wind;', + 'uniform float u_resolution;', + 'uniform float u_size;', + + 'float omega (float k) {', + 'return sqrt(G * k * (1.0 + pow2(k / KM)));', + '}', + + 'float tanh (float x) {', + 'return (1.0 - exp(-2.0 * x)) / (1.0 + exp(-2.0 * x));', + '}', + + 'void main (void) {', + 'vec2 coordinates = gl_FragCoord.xy - 0.5;', + + 'float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;', + 'float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;', + + 'vec2 K = (2.0 * PI * vec2(n, m)) / u_size;', + 'float k = length(K);', + + 'float l_wind = length(u_wind);', + + 'float Omega = 0.84;', + 'float kp = G * pow2(Omega / l_wind);', + + 'float c = omega(k) / k;', + 'float cp = omega(kp) / kp;', + + 'float Lpm = exp(-1.25 * pow2(kp / k));', + 'float gamma = 1.7;', + 'float sigma = 0.08 * (1.0 + 4.0 * pow(Omega, -3.0));', + 'float Gamma = exp(-pow2(sqrt(k / kp) - 1.0) / 2.0 * pow2(sigma));', + 'float Jp = pow(gamma, Gamma);', + 'float Fp = Lpm * Jp * exp(-Omega / sqrt(10.0) * (sqrt(k / kp) - 1.0));', + 'float alphap = 0.006 * sqrt(Omega);', + 'float Bl = 0.5 * alphap * cp / c * Fp;', + + 'float z0 = 0.000037 * pow2(l_wind) / G * pow(l_wind / cp, 0.9);', + 'float uStar = 0.41 * l_wind / log(10.0 / z0);', + 'float alpham = 0.01 * ((uStar < CM) ? (1.0 + log(uStar / CM)) : (1.0 + 3.0 * log(uStar / CM)));', + 'float Fm = exp(-0.25 * pow2(k / KM - 1.0));', + 'float Bh = 0.5 * alpham * CM / c * Fm * Lpm;', + + 'float a0 = log(2.0) / 4.0;', + 'float am = 0.13 * uStar / CM;', + 'float Delta = tanh(a0 + 4.0 * pow(c / cp, 2.5) + am * pow(CM / c, 2.5));', + + 'float cosPhi = dot(normalize(u_wind), normalize(K));', + + 'float S = (1.0 / (2.0 * PI)) * pow(k, -4.0) * (Bl + Bh) * (1.0 + Delta * (2.0 * cosPhi * cosPhi - 1.0));', + + 'float dk = 2.0 * PI / u_size;', + 'float h = sqrt(S / 2.0) * dk;', + + 'if (K.x == 0.0 && K.y == 0.0) {', + 'h = 0.0;', //no DC term + '}', + 'gl_FragColor = vec4(h, 0.0, 0.0, 0.0);', + '}' + ].join( '\n' ) +}; +THREE.ShaderLib[ 'ocean_phase' ] = { + uniforms: { + "u_phases": { value: null }, + "u_deltaTime": { value: null }, + "u_resolution": { value: null }, + "u_size": { value: null } + }, + fragmentShader: [ + 'precision highp float;', + '#include ', + + 'const float G = 9.81;', + 'const float KM = 370.0;', + + 'varying vec2 vUV;', + + 'uniform sampler2D u_phases;', + 'uniform float u_deltaTime;', + 'uniform float u_resolution;', + 'uniform float u_size;', + + 'float omega (float k) {', + 'return sqrt(G * k * (1.0 + k * k / KM * KM));', + '}', + + 'void main (void) {', + 'float deltaTime = 1.0 / 60.0;', + 'vec2 coordinates = gl_FragCoord.xy - 0.5;', + 'float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;', + 'float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;', + 'vec2 waveVector = (2.0 * PI * vec2(n, m)) / u_size;', + + 'float phase = texture2D(u_phases, vUV).r;', + 'float deltaPhase = omega(length(waveVector)) * u_deltaTime;', + 'phase = mod(phase + deltaPhase, 2.0 * PI);', + + 'gl_FragColor = vec4(phase, 0.0, 0.0, 0.0);', + '}' + ].join( '\n' ) +}; +THREE.ShaderLib[ 'ocean_spectrum' ] = { + uniforms: { + "u_size": { value: null }, + "u_resolution": { value: null }, + "u_choppiness": { value: null }, + "u_phases": { value: null }, + "u_initialSpectrum": { value: null } + }, + fragmentShader: [ + 'precision highp float;', + '#include ', + + 'const float G = 9.81;', + 'const float KM = 370.0;', + + 'varying vec2 vUV;', + + 'uniform float u_size;', + 'uniform float u_resolution;', + 'uniform float u_choppiness;', + 'uniform sampler2D u_phases;', + 'uniform sampler2D u_initialSpectrum;', + + 'vec2 multiplyComplex (vec2 a, vec2 b) {', + 'return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);', + '}', + + 'vec2 multiplyByI (vec2 z) {', + 'return vec2(-z[1], z[0]);', + '}', + + 'float omega (float k) {', + 'return sqrt(G * k * (1.0 + k * k / KM * KM));', + '}', + + 'void main (void) {', + 'vec2 coordinates = gl_FragCoord.xy - 0.5;', + 'float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;', + 'float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;', + 'vec2 waveVector = (2.0 * PI * vec2(n, m)) / u_size;', + + 'float phase = texture2D(u_phases, vUV).r;', + 'vec2 phaseVector = vec2(cos(phase), sin(phase));', + + 'vec2 h0 = texture2D(u_initialSpectrum, vUV).rg;', + 'vec2 h0Star = texture2D(u_initialSpectrum, vec2(1.0 - vUV + 1.0 / u_resolution)).rg;', + 'h0Star.y *= -1.0;', + + 'vec2 h = multiplyComplex(h0, phaseVector) + multiplyComplex(h0Star, vec2(phaseVector.x, -phaseVector.y));', + + 'vec2 hX = -multiplyByI(h * (waveVector.x / length(waveVector))) * u_choppiness;', + 'vec2 hZ = -multiplyByI(h * (waveVector.y / length(waveVector))) * u_choppiness;', + + //no DC term + 'if (waveVector.x == 0.0 && waveVector.y == 0.0) {', + 'h = vec2(0.0);', + 'hX = vec2(0.0);', + 'hZ = vec2(0.0);', + '}', + + 'gl_FragColor = vec4(hX + multiplyByI(h), hZ);', + '}' + ].join( '\n' ) +}; +THREE.ShaderLib[ 'ocean_normals' ] = { + uniforms: { + "u_displacementMap": { value: null }, + "u_resolution": { value: null }, + "u_size": { value: null } + }, + fragmentShader: [ + 'precision highp float;', + + 'varying vec2 vUV;', + + 'uniform sampler2D u_displacementMap;', + 'uniform float u_resolution;', + 'uniform float u_size;', + + 'void main (void) {', + 'float texel = 1.0 / u_resolution;', + 'float texelSize = u_size / u_resolution;', + + 'vec3 center = texture2D(u_displacementMap, vUV).rgb;', + 'vec3 right = vec3(texelSize, 0.0, 0.0) + texture2D(u_displacementMap, vUV + vec2(texel, 0.0)).rgb - center;', + 'vec3 left = vec3(-texelSize, 0.0, 0.0) + texture2D(u_displacementMap, vUV + vec2(-texel, 0.0)).rgb - center;', + 'vec3 top = vec3(0.0, 0.0, -texelSize) + texture2D(u_displacementMap, vUV + vec2(0.0, -texel)).rgb - center;', + 'vec3 bottom = vec3(0.0, 0.0, texelSize) + texture2D(u_displacementMap, vUV + vec2(0.0, texel)).rgb - center;', + + 'vec3 topRight = cross(right, top);', + 'vec3 topLeft = cross(top, left);', + 'vec3 bottomLeft = cross(left, bottom);', + 'vec3 bottomRight = cross(bottom, right);', + + 'gl_FragColor = vec4(normalize(topRight + topLeft + bottomLeft + bottomRight), 1.0);', + '}' + ].join( '\n' ) +}; +THREE.ShaderLib[ 'ocean_main' ] = { + uniforms: { + "u_displacementMap": { value: null }, + "u_normalMap": { value: null }, + "u_geometrySize": { value: null }, + "u_size": { value: null }, + "u_projectionMatrix": { value: null }, + "u_viewMatrix": { value: null }, + "u_cameraPosition": { value: null }, + "u_skyColor": { value: null }, + "u_oceanColor": { value: null }, + "u_sunDirection": { value: null }, + "u_exposure": { value: null } + }, + vertexShader: [ + 'precision highp float;', + + 'varying vec3 vPos;', + 'varying vec2 vUV;', + + 'uniform mat4 u_projectionMatrix;', + 'uniform mat4 u_viewMatrix;', + 'uniform float u_size;', + 'uniform float u_geometrySize;', + 'uniform sampler2D u_displacementMap;', + + 'void main (void) {', + 'vec3 newPos = position + texture2D(u_displacementMap, uv).rgb * (u_geometrySize / u_size);', + 'vPos = newPos;', + 'vUV = uv;', + 'gl_Position = u_projectionMatrix * u_viewMatrix * vec4(newPos, 1.0);', + '}' + ].join( '\n' ), + fragmentShader: [ + 'precision highp float;', + + 'varying vec3 vPos;', + 'varying vec2 vUV;', + + 'uniform sampler2D u_displacementMap;', + 'uniform sampler2D u_normalMap;', + 'uniform vec3 u_cameraPosition;', + 'uniform vec3 u_oceanColor;', + 'uniform vec3 u_skyColor;', + 'uniform vec3 u_sunDirection;', + 'uniform float u_exposure;', + + 'vec3 hdr (vec3 color, float exposure) {', + 'return 1.0 - exp(-color * exposure);', + '}', + + 'void main (void) {', + 'vec3 normal = texture2D(u_normalMap, vUV).rgb;', + + 'vec3 view = normalize(u_cameraPosition - vPos);', + 'float fresnel = 0.02 + 0.98 * pow(1.0 - dot(normal, view), 5.0);', + 'vec3 sky = fresnel * u_skyColor;', + + 'float diffuse = clamp(dot(normal, normalize(u_sunDirection)), 0.0, 1.0);', + 'vec3 water = (1.0 - fresnel) * u_oceanColor * u_skyColor * diffuse;', + + 'vec3 color = sky + water;', + + 'gl_FragColor = vec4(hdr(color, u_exposure), 1.0);', + '}' + ].join( '\n' ) +}; diff --git a/three/jsutil/shaders/ParallaxShader.js b/three/jsutil/shaders/ParallaxShader.js new file mode 100644 index 000000000..5b9531d70 --- /dev/null +++ b/three/jsutil/shaders/ParallaxShader.js @@ -0,0 +1,184 @@ +// Parallax Occlusion shaders from +// http://sunandblackcat.com/tipFullView.php?topicid=28 +// No tangent-space transforms logic based on +// http://mmikkelsen3d.blogspot.sk/2012/02/parallaxpoc-mapping-and-no-tangent.html + +THREE.ParallaxShader = { + // Ordered from fastest to best quality. + modes: { + none: 'NO_PARALLAX', + basic: 'USE_BASIC_PARALLAX', + steep: 'USE_STEEP_PARALLAX', + occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM + relief: 'USE_RELIEF_PARALLAX' + }, + + uniforms: { + "bumpMap": { value: null }, + "map": { value: null }, + "parallaxScale": { value: null }, + "parallaxMinLayers": { value: null }, + "parallaxMaxLayers": { value: null } + }, + + vertexShader: [ + "varying vec2 vUv;", + "varying vec3 vViewPosition;", + "varying vec3 vNormal;", + + "void main() {", + + "vUv = uv;", + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", + "vViewPosition = -mvPosition.xyz;", + "vNormal = normalize( normalMatrix * normal );", + "gl_Position = projectionMatrix * mvPosition;", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + "uniform sampler2D bumpMap;", + "uniform sampler2D map;", + + "uniform float parallaxScale;", + "uniform float parallaxMinLayers;", + "uniform float parallaxMaxLayers;", + + "varying vec2 vUv;", + "varying vec3 vViewPosition;", + "varying vec3 vNormal;", + + "#ifdef USE_BASIC_PARALLAX", + + "vec2 parallaxMap( in vec3 V ) {", + + "float initialHeight = texture2D( bumpMap, vUv ).r;", + + // No Offset Limitting: messy, floating output at grazing angles. + //"vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;", + + // Offset Limiting + "vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;", + "return vUv - texCoordOffset;", + + "}", + + "#else", + + "vec2 parallaxMap( in vec3 V ) {", + + // Determine number of layers from angle between V and N + "float numLayers = mix( parallaxMaxLayers, parallaxMinLayers, abs( dot( vec3( 0.0, 0.0, 1.0 ), V ) ) );", + + "float layerHeight = 1.0 / numLayers;", + "float currentLayerHeight = 0.0;", + // Shift of texture coordinates for each iteration + "vec2 dtex = parallaxScale * V.xy / V.z / numLayers;", + + "vec2 currentTextureCoords = vUv;", + + "float heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;", + + // while ( heightFromTexture > currentLayerHeight ) + // Infinite loops are not well supported. Do a "large" finite + // loop, but not too large, as it slows down some compilers. + "for ( int i = 0; i < 30; i += 1 ) {", + "if ( heightFromTexture <= currentLayerHeight ) {", + "break;", + "}", + "currentLayerHeight += layerHeight;", + // Shift texture coordinates along vector V + "currentTextureCoords -= dtex;", + "heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;", + "}", + + "#ifdef USE_STEEP_PARALLAX", + + "return currentTextureCoords;", + + "#elif defined( USE_RELIEF_PARALLAX )", + + "vec2 deltaTexCoord = dtex / 2.0;", + "float deltaHeight = layerHeight / 2.0;", + + // Return to the mid point of previous layer + "currentTextureCoords += deltaTexCoord;", + "currentLayerHeight -= deltaHeight;", + + // Binary search to increase precision of Steep Parallax Mapping + "const int numSearches = 5;", + "for ( int i = 0; i < numSearches; i += 1 ) {", + + "deltaTexCoord /= 2.0;", + "deltaHeight /= 2.0;", + "heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;", + // Shift along or against vector V + "if( heightFromTexture > currentLayerHeight ) {", // Below the surface + + "currentTextureCoords -= deltaTexCoord;", + "currentLayerHeight += deltaHeight;", + + "} else {", // above the surface + + "currentTextureCoords += deltaTexCoord;", + "currentLayerHeight -= deltaHeight;", + + "}", + + "}", + "return currentTextureCoords;", + + "#elif defined( USE_OCLUSION_PARALLAX )", + + "vec2 prevTCoords = currentTextureCoords + dtex;", + + // Heights for linear interpolation + "float nextH = heightFromTexture - currentLayerHeight;", + "float prevH = texture2D( bumpMap, prevTCoords ).r - currentLayerHeight + layerHeight;", + + // Proportions for linear interpolation + "float weight = nextH / ( nextH - prevH );", + + // Interpolation of texture coordinates + "return prevTCoords * weight + currentTextureCoords * ( 1.0 - weight );", + + "#else", // NO_PARALLAX + + "return vUv;", + + "#endif", + + "}", + "#endif", + + "vec2 perturbUv( vec3 surfPosition, vec3 surfNormal, vec3 viewPosition ) {", + + "vec2 texDx = dFdx( vUv );", + "vec2 texDy = dFdy( vUv );", + + "vec3 vSigmaX = dFdx( surfPosition );", + "vec3 vSigmaY = dFdy( surfPosition );", + "vec3 vR1 = cross( vSigmaY, surfNormal );", + "vec3 vR2 = cross( surfNormal, vSigmaX );", + "float fDet = dot( vSigmaX, vR1 );", + + "vec2 vProjVscr = ( 1.0 / fDet ) * vec2( dot( vR1, viewPosition ), dot( vR2, viewPosition ) );", + "vec3 vProjVtex;", + "vProjVtex.xy = texDx * vProjVscr.x + texDy * vProjVscr.y;", + "vProjVtex.z = dot( surfNormal, viewPosition );", + + "return parallaxMap( vProjVtex );", + "}", + + "void main() {", + + "vec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );", + "gl_FragColor = texture2D( map, mapUv );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/PixelShader.js b/three/jsutil/shaders/PixelShader.js new file mode 100644 index 000000000..340cc7b5f --- /dev/null +++ b/three/jsutil/shaders/PixelShader.js @@ -0,0 +1,47 @@ +/** + * @author wongbryan / http://wongbryan.github.io + * + * Pixelation shader + */ + +THREE.PixelShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "resolution": { value: null }, + "pixelSize": { value: 1. }, + + }, + + vertexShader: [ + + "varying highp vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float pixelSize;", + "uniform vec2 resolution;", + + "varying highp vec2 vUv;", + + "void main(){", + + "vec2 dxy = pixelSize / resolution;", + "vec2 coord = dxy * floor( vUv / dxy );", + "gl_FragColor = texture2D(tDiffuse, coord);", + + "}" + + ].join( "\n" ) +}; diff --git a/three/jsutil/shaders/RGBShiftShader.js b/three/jsutil/shaders/RGBShiftShader.js new file mode 100644 index 000000000..2740b9c4a --- /dev/null +++ b/three/jsutil/shaders/RGBShiftShader.js @@ -0,0 +1,56 @@ +/** + * @author felixturner / http://airtight.cc/ + * + * RGB Shift Shader + * Shifts red and blue channels from center in opposite directions + * Ported from http://kriss.cx/tom/2009/05/rgb-shift/ + * by Tom Butterworth / http://kriss.cx/tom/ + * + * amount: shift distance (1 is width of input) + * angle: shift angle in radians + */ + +THREE.RGBShiftShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "amount": { value: 0.005 }, + "angle": { value: 0.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float amount;", + "uniform float angle;", + + "varying vec2 vUv;", + + "void main() {", + + "vec2 offset = amount * vec2( cos(angle), sin(angle));", + "vec4 cr = texture2D(tDiffuse, vUv + offset);", + "vec4 cga = texture2D(tDiffuse, vUv);", + "vec4 cb = texture2D(tDiffuse, vUv - offset);", + "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/SAOShader.js b/three/jsutil/shaders/SAOShader.js new file mode 100644 index 000000000..3719d0111 --- /dev/null +++ b/three/jsutil/shaders/SAOShader.js @@ -0,0 +1,177 @@ +THREE.SAOShader = { + defines: { + 'NUM_SAMPLES': 7, + 'NUM_RINGS': 4, + 'NORMAL_TEXTURE': 0, + 'DIFFUSE_TEXTURE': 0, + 'DEPTH_PACKING': 1, + 'PERSPECTIVE_CAMERA': 1 + }, + uniforms: { + + 'tDepth': { type: 't', value: null }, + 'tDiffuse': { type: 't', value: null }, + 'tNormal': { type: 't', value: null }, + 'size': { type: 'v2', value: new THREE.Vector2( 512, 512 ) }, + + 'cameraNear': { type: 'f', value: 1 }, + 'cameraFar': { type: 'f', value: 100 }, + 'cameraProjectionMatrix': { type: 'm4', value: new THREE.Matrix4() }, + 'cameraInverseProjectionMatrix': { type: 'm4', value: new THREE.Matrix4() }, + + 'scale': { type: 'f', value: 1.0 }, + 'intensity': { type: 'f', value: 0.1 }, + 'bias': { type: 'f', value: 0.5 }, + + 'minResolution': { type: 'f', value: 0.0 }, + 'kernelRadius': { type: 'f', value: 100.0 }, + 'randomSeed': { type: 'f', value: 0.0 } + }, + vertexShader: [ + "varying vec2 vUv;", + + "void main() {", + " vUv = uv;", + " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + "}" + + ].join( "\n" ), + fragmentShader: [ + "#include ", + + "varying vec2 vUv;", + + "#if DIFFUSE_TEXTURE == 1", + "uniform sampler2D tDiffuse;", + "#endif", + + "uniform sampler2D tDepth;", + + "#if NORMAL_TEXTURE == 1", + "uniform sampler2D tNormal;", + "#endif", + + "uniform float cameraNear;", + "uniform float cameraFar;", + "uniform mat4 cameraProjectionMatrix;", + "uniform mat4 cameraInverseProjectionMatrix;", + + "uniform float scale;", + "uniform float intensity;", + "uniform float bias;", + "uniform float kernelRadius;", + "uniform float minResolution;", + "uniform vec2 size;", + "uniform float randomSeed;", + + "// RGBA depth", + + "#include ", + + "vec4 getDefaultColor( const in vec2 screenPosition ) {", + " #if DIFFUSE_TEXTURE == 1", + " return texture2D( tDiffuse, vUv );", + " #else", + " return vec4( 1.0 );", + " #endif", + "}", + + "float getDepth( const in vec2 screenPosition ) {", + " #if DEPTH_PACKING == 1", + " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );", + " #else", + " return texture2D( tDepth, screenPosition ).x;", + " #endif", + "}", + + "float getViewZ( const in float depth ) {", + " #if PERSPECTIVE_CAMERA == 1", + " return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );", + " #else", + " return orthographicDepthToViewZ( depth, cameraNear, cameraFar );", + " #endif", + "}", + + "vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {", + " float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];", + " vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );", + " clipPosition *= clipW; // unprojection.", + + " return ( cameraInverseProjectionMatrix * clipPosition ).xyz;", + "}", + + "vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {", + " #if NORMAL_TEXTURE == 1", + " return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );", + " #else", + " return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );", + " #endif", + "}", + + "float scaleDividedByCameraFar;", + "float minResolutionMultipliedByCameraFar;", + + "float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {", + " vec3 viewDelta = sampleViewPosition - centerViewPosition;", + " float viewDistance = length( viewDelta );", + " float scaledScreenDistance = scaleDividedByCameraFar * viewDistance;", + + " return max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );", + "}", + + "// moving costly divides into consts", + "const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );", + "const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );", + + "float getAmbientOcclusion( const in vec3 centerViewPosition ) {", + " // precompute some variables require in getOcclusion.", + " scaleDividedByCameraFar = scale / cameraFar;", + " minResolutionMultipliedByCameraFar = minResolution * cameraFar;", + " vec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );", + + " // jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/", + " float angle = rand( vUv + randomSeed ) * PI2;", + " vec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;", + " vec2 radiusStep = radius;", + + " float occlusionSum = 0.0;", + " float weightSum = 0.0;", + + " for( int i = 0; i < NUM_SAMPLES; i ++ ) {", + " vec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;", + " radius += radiusStep;", + " angle += ANGLE_STEP;", + + " float sampleDepth = getDepth( sampleUv );", + " if( sampleDepth >= ( 1.0 - EPSILON ) ) {", + " continue;", + " }", + + " float sampleViewZ = getViewZ( sampleDepth );", + " vec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );", + " occlusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );", + " weightSum += 1.0;", + " }", + + " if( weightSum == 0.0 ) discard;", + + " return occlusionSum * ( intensity / weightSum );", + "}", + + + "void main() {", + " float centerDepth = getDepth( vUv );", + " if( centerDepth >= ( 1.0 - EPSILON ) ) {", + " discard;", + " }", + + " float centerViewZ = getViewZ( centerDepth );", + " vec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );", + + " float ambientOcclusion = getAmbientOcclusion( viewPosition );", + + " gl_FragColor = getDefaultColor( vUv );", + " gl_FragColor.xyz *= 1.0 - ambientOcclusion;", + "}" + ].join( "\n" ) +}; diff --git a/three/jsutil/shaders/SMAAShader.js b/three/jsutil/shaders/SMAAShader.js new file mode 100644 index 000000000..33c6da757 --- /dev/null +++ b/three/jsutil/shaders/SMAAShader.js @@ -0,0 +1,462 @@ +/** + * @author mpk / http://polko.me/ + * + * WebGL port of Subpixel Morphological Antialiasing (SMAA) v2.8 + * Preset: SMAA 1x Medium (with color edge detection) + * https://github.com/iryoku/smaa/releases/tag/v2.8 + */ + +THREE.SMAAShader = [ { + + defines: { + + "SMAA_THRESHOLD": "0.1" + + }, + + uniforms: { + + "tDiffuse": { value: null }, + "resolution": { value: new THREE.Vector2( 1 / 1024, 1 / 512 ) } + + }, + + vertexShader: [ + + "uniform vec2 resolution;", + + "varying vec2 vUv;", + "varying vec4 vOffset[ 3 ];", + + "void SMAAEdgeDetectionVS( vec2 texcoord ) {", + "vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );", // WebGL port note: Changed sign in W component + "vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );", // WebGL port note: Changed sign in W component + "vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0, 2.0 );", // WebGL port note: Changed sign in W component + "}", + + "void main() {", + + "vUv = uv;", + + "SMAAEdgeDetectionVS( vUv );", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join("\n"), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + "varying vec4 vOffset[ 3 ];", + + "vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {", + "vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );", + + // Calculate color deltas: + "vec4 delta;", + "vec3 C = texture2D( colorTex, texcoord ).rgb;", + + "vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;", + "vec3 t = abs( C - Cleft );", + "delta.x = max( max( t.r, t.g ), t.b );", + + "vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;", + "t = abs( C - Ctop );", + "delta.y = max( max( t.r, t.g ), t.b );", + + // We do the usual threshold: + "vec2 edges = step( threshold, delta.xy );", + + // Then discard if there is no edge: + "if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )", + "discard;", + + // Calculate right and bottom deltas: + "vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;", + "t = abs( C - Cright );", + "delta.z = max( max( t.r, t.g ), t.b );", + + "vec3 Cbottom = texture2D( colorTex, offset[1].zw ).rgb;", + "t = abs( C - Cbottom );", + "delta.w = max( max( t.r, t.g ), t.b );", + + // Calculate the maximum delta in the direct neighborhood: + "float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );", + + // Calculate left-left and top-top deltas: + "vec3 Cleftleft = texture2D( colorTex, offset[2].xy ).rgb;", + "t = abs( C - Cleftleft );", + "delta.z = max( max( t.r, t.g ), t.b );", + + "vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;", + "t = abs( C - Ctoptop );", + "delta.w = max( max( t.r, t.g ), t.b );", + + // Calculate the final maximum delta: + "maxDelta = max( max( maxDelta, delta.z ), delta.w );", + + // Local contrast adaptation in action: + "edges.xy *= step( 0.5 * maxDelta, delta.xy );", + + "return vec4( edges, 0.0, 0.0 );", + "}", + + "void main() {", + + "gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );", + + "}" + + ].join("\n") + +}, { + + defines: { + + "SMAA_MAX_SEARCH_STEPS": "8", + "SMAA_AREATEX_MAX_DISTANCE": "16", + "SMAA_AREATEX_PIXEL_SIZE": "( 1.0 / vec2( 160.0, 560.0 ) )", + "SMAA_AREATEX_SUBTEX_SIZE": "( 1.0 / 7.0 )" + + }, + + uniforms: { + + "tDiffuse": { value: null }, + "tArea": { value: null }, + "tSearch": { value: null }, + "resolution": { value: new THREE.Vector2( 1 / 1024, 1 / 512 ) } + + }, + + vertexShader: [ + + "uniform vec2 resolution;", + + "varying vec2 vUv;", + "varying vec4 vOffset[ 3 ];", + "varying vec2 vPixcoord;", + + "void SMAABlendingWeightCalculationVS( vec2 texcoord ) {", + "vPixcoord = texcoord / resolution;", + + // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): + "vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 );", // WebGL port note: Changed sign in Y and W components + "vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 );", // WebGL port note: Changed sign in Y and W components + + // And these for the searches, they indicate the ends of the loops: + "vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );", + + "}", + + "void main() {", + + "vUv = uv;", + + "SMAABlendingWeightCalculationVS( vUv );", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join("\n"), + + fragmentShader: [ + + "#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )", + + "uniform sampler2D tDiffuse;", + "uniform sampler2D tArea;", + "uniform sampler2D tSearch;", + "uniform vec2 resolution;", + + "varying vec2 vUv;", + "varying vec4 vOffset[3];", + "varying vec2 vPixcoord;", + + "vec2 round( vec2 x ) {", + "return sign( x ) * floor( abs( x ) + 0.5 );", + "}", + + "float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {", + // Not required if searchTex accesses are set to point: + // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0); + // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE + + // e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE; + "e.r = bias + e.r * scale;", + "return 255.0 * texture2D( searchTex, e, 0.0 ).r;", + "}", + + "float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {", + /** + * @PSEUDO_GATHER4 + * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to + * sample between edge, thus fetching four edges in a row. + * Sampling with different offsets in each direction allows to disambiguate + * which edges are active from the four fetched ones. + */ + "vec2 e = vec2( 0.0, 1.0 );", + + "for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {", // WebGL port note: Changed while to for + "e = texture2D( edgesTex, texcoord, 0.0 ).rg;", + "texcoord -= vec2( 2.0, 0.0 ) * resolution;", + "if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;", + "}", + + // We correct the previous (-0.25, -0.125) offset we applied: + "texcoord.x += 0.25 * resolution.x;", + + // The searches are bias by 1, so adjust the coords accordingly: + "texcoord.x += resolution.x;", + + // Disambiguate the length added by the last step: + "texcoord.x += 2.0 * resolution.x;", // Undo last step + "texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);", + + "return texcoord.x;", + "}", + + "float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {", + "vec2 e = vec2( 0.0, 1.0 );", + + "for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {", // WebGL port note: Changed while to for + "e = texture2D( edgesTex, texcoord, 0.0 ).rg;", + "texcoord += vec2( 2.0, 0.0 ) * resolution;", + "if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;", + "}", + + "texcoord.x -= 0.25 * resolution.x;", + "texcoord.x -= resolution.x;", + "texcoord.x -= 2.0 * resolution.x;", + "texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );", + + "return texcoord.x;", + "}", + + "float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {", + "vec2 e = vec2( 1.0, 0.0 );", + + "for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {", // WebGL port note: Changed while to for + "e = texture2D( edgesTex, texcoord, 0.0 ).rg;", + "texcoord += vec2( 0.0, 2.0 ) * resolution;", // WebGL port note: Changed sign + "if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;", + "}", + + "texcoord.y -= 0.25 * resolution.y;", // WebGL port note: Changed sign + "texcoord.y -= resolution.y;", // WebGL port note: Changed sign + "texcoord.y -= 2.0 * resolution.y;", // WebGL port note: Changed sign + "texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 );", // WebGL port note: Changed sign + + "return texcoord.y;", + "}", + + "float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {", + "vec2 e = vec2( 1.0, 0.0 );", + + "for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) {", // WebGL port note: Changed while to for + "e = texture2D( edgesTex, texcoord, 0.0 ).rg;", + "texcoord -= vec2( 0.0, 2.0 ) * resolution;", // WebGL port note: Changed sign + "if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;", + "}", + + "texcoord.y += 0.25 * resolution.y;", // WebGL port note: Changed sign + "texcoord.y += resolution.y;", // WebGL port note: Changed sign + "texcoord.y += 2.0 * resolution.y;", // WebGL port note: Changed sign + "texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 );", // WebGL port note: Changed sign + + "return texcoord.y;", + "}", + + "vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {", + // Rounding prevents precision errors of bilinear filtering: + "vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;", + + // We do a scale and bias for mapping to texel space: + "texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );", + + // Move to proper place, according to the subpixel offset: + "texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;", + + "return texture2D( areaTex, texcoord, 0.0 ).rg;", + "}", + + "vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {", + "vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );", + + "vec2 e = texture2D( edgesTex, texcoord ).rg;", + + "if ( e.g > 0.0 ) {", // Edge at north + "vec2 d;", + + // Find the distance to the left: + "vec2 coords;", + "coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );", + "coords.y = offset[ 1 ].y;", // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET) + "d.x = coords.x;", + + // Now fetch the left crossing edges, two at a time using bilinear + // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to + // discern what value each edge has: + "float e1 = texture2D( edgesTex, coords, 0.0 ).r;", + + // Find the distance to the right: + "coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );", + "d.y = coords.x;", + + // We want the distances to be in pixel units (doing this here allow to + // better interleave arithmetic and memory accesses): + "d = d / resolution.x - pixcoord.x;", + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + "vec2 sqrt_d = sqrt( abs( d ) );", + + // Fetch the right crossing edges: + "coords.y -= 1.0 * resolution.y;", // WebGL port note: Added + "float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;", + + // Ok, we know how this pattern looks like, now it is time for getting + // the actual area: + "weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );", + "}", + + "if ( e.r > 0.0 ) {", // Edge at west + "vec2 d;", + + // Find the distance to the top: + "vec2 coords;", + + "coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );", + "coords.x = offset[ 0 ].x;", // offset[1].x = texcoord.x - 0.25 * resolution.x; + "d.x = coords.y;", + + // Fetch the top crossing edges: + "float e1 = texture2D( edgesTex, coords, 0.0 ).g;", + + // Find the distance to the bottom: + "coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );", + "d.y = coords.y;", + + // We want the distances to be in pixel units: + "d = d / resolution.y - pixcoord.y;", + + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + "vec2 sqrt_d = sqrt( abs( d ) );", + + // Fetch the bottom crossing edges: + "coords.y -= 1.0 * resolution.y;", // WebGL port note: Added + "float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;", + + // Get the area for this direction: + "weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );", + "}", + + "return weights;", + "}", + + "void main() {", + + "gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );", + + "}" + + ].join("\n") + +}, { + + uniforms: { + + "tDiffuse": { value: null }, + "tColor": { value: null }, + "resolution": { value: new THREE.Vector2( 1 / 1024, 1 / 512 ) } + + }, + + vertexShader: [ + + "uniform vec2 resolution;", + + "varying vec2 vUv;", + "varying vec4 vOffset[ 2 ];", + + "void SMAANeighborhoodBlendingVS( vec2 texcoord ) {", + "vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 );", // WebGL port note: Changed sign in W component + "vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 );", // WebGL port note: Changed sign in W component + "}", + + "void main() {", + + "vUv = uv;", + + "SMAANeighborhoodBlendingVS( vUv );", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join("\n"), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform sampler2D tColor;", + "uniform vec2 resolution;", + + "varying vec2 vUv;", + "varying vec4 vOffset[ 2 ];", + + "vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {", + // Fetch the blending weights for current pixel: + "vec4 a;", + "a.xz = texture2D( blendTex, texcoord ).xz;", + "a.y = texture2D( blendTex, offset[ 1 ].zw ).g;", + "a.w = texture2D( blendTex, offset[ 1 ].xy ).a;", + + // Is there any blending weight with a value greater than 0.0? + "if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {", + "return texture2D( colorTex, texcoord, 0.0 );", + "} else {", + // Up to 4 lines can be crossing a pixel (one through each edge). We + // favor blending by choosing the line with the maximum weight for each + // direction: + "vec2 offset;", + "offset.x = a.a > a.b ? a.a : -a.b;", // left vs. right + "offset.y = a.g > a.r ? -a.g : a.r;", // top vs. bottom // WebGL port note: Changed signs + + // Then we go in the direction that has the maximum weight: + "if ( abs( offset.x ) > abs( offset.y )) {", // horizontal vs. vertical + "offset.y = 0.0;", + "} else {", + "offset.x = 0.0;", + "}", + + // Fetch the opposite color and lerp by hand: + "vec4 C = texture2D( colorTex, texcoord, 0.0 );", + "texcoord += sign( offset ) * resolution;", + "vec4 Cop = texture2D( colorTex, texcoord, 0.0 );", + "float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );", + + // WebGL port note: Added gamma correction + "C.xyz = pow(C.xyz, vec3(2.2));", + "Cop.xyz = pow(Cop.xyz, vec3(2.2));", + "vec4 mixed = mix(C, Cop, s);", + "mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));", + + "return mixed;", + "}", + "}", + + "void main() {", + + "gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );", + + "}" + + ].join("\n") + +} ]; diff --git a/three/jsutil/shaders/SSAOShader.js b/three/jsutil/shaders/SSAOShader.js new file mode 100644 index 000000000..239dae26a --- /dev/null +++ b/three/jsutil/shaders/SSAOShader.js @@ -0,0 +1,233 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Screen-space ambient occlusion shader + * - ported from + * SSAO GLSL shader v1.2 + * assembled by Martins Upitis (martinsh) (http://devlog-martinsh.blogspot.com) + * original technique is made by ArKano22 (http://www.gamedev.net/topic/550699-ssao-no-halo-artifacts/) + * - modifications + * - modified to use RGBA packed depth texture (use clear color 1,1,1,1 for depth pass) + * - refactoring and optimizations + */ + +THREE.SSAOShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "tDepth": { value: null }, + "size": { value: new THREE.Vector2( 512, 512 ) }, + "cameraNear": { value: 1 }, + "cameraFar": { value: 100 }, + "radius": { value: 32 }, + "onlyAO": { value: 0 }, + "aoClamp": { value: 0.25 }, + "lumInfluence": { value: 0.7 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float cameraNear;", + "uniform float cameraFar;", + "#ifdef USE_LOGDEPTHBUF", + "uniform float logDepthBufFC;", + "#endif", + + "uniform float radius;", // ao radius + "uniform bool onlyAO;", // use only ambient occlusion pass? + + "uniform vec2 size;", // texture width, height + "uniform float aoClamp;", // depth clamp - reduces haloing at screen edges + + "uniform float lumInfluence;", // how much luminance affects occlusion + + "uniform sampler2D tDiffuse;", + "uniform sampler2D tDepth;", + + "varying vec2 vUv;", + + // "#define PI 3.14159265", + "#define DL 2.399963229728653", // PI * ( 3.0 - sqrt( 5.0 ) ) + "#define EULER 2.718281828459045", + + // user variables + + "const int samples = 64;", // ao sample count + + "const bool useNoise = true;", // use noise instead of pattern for sample dithering + "const float noiseAmount = 0.0004;", // dithering amount + + "const float diffArea = 0.4;", // self-shadowing reduction + "const float gDisplace = 0.4;", // gauss bell center + + + // RGBA depth + + "#include ", + + // generating noise / pattern texture for dithering + + "vec2 rand( const vec2 coord ) {", + + "vec2 noise;", + + "if ( useNoise ) {", + + "float nx = dot ( coord, vec2( 12.9898, 78.233 ) );", + "float ny = dot ( coord, vec2( 12.9898, 78.233 ) * 2.0 );", + + "noise = clamp( fract ( 43758.5453 * sin( vec2( nx, ny ) ) ), 0.0, 1.0 );", + + "} else {", + + "float ff = fract( 1.0 - coord.s * ( size.x / 2.0 ) );", + "float gg = fract( coord.t * ( size.y / 2.0 ) );", + + "noise = vec2( 0.25, 0.75 ) * vec2( ff ) + vec2( 0.75, 0.25 ) * gg;", + + "}", + + "return ( noise * 2.0 - 1.0 ) * noiseAmount;", + + "}", + + "float readDepth( const in vec2 coord ) {", + + "float cameraFarPlusNear = cameraFar + cameraNear;", + "float cameraFarMinusNear = cameraFar - cameraNear;", + "float cameraCoef = 2.0 * cameraNear;", + + "#ifdef USE_LOGDEPTHBUF", + + "float logz = unpackRGBAToDepth( texture2D( tDepth, coord ) );", + "float w = pow(2.0, (logz / logDepthBufFC)) - 1.0;", + "float z = (logz / w) + 1.0;", + + "#else", + + "float z = unpackRGBAToDepth( texture2D( tDepth, coord ) );", + + "#endif", + + "return cameraCoef / ( cameraFarPlusNear - z * cameraFarMinusNear );", + + + "}", + + "float compareDepths( const in float depth1, const in float depth2, inout int far ) {", + + "float garea = 8.0;", // gauss bell width + "float diff = ( depth1 - depth2 ) * 100.0;", // depth difference (0-100) + + // reduce left bell width to avoid self-shadowing + + "if ( diff < gDisplace ) {", + + "garea = diffArea;", + + "} else {", + + "far = 1;", + + "}", + + "float dd = diff - gDisplace;", + "float gauss = pow( EULER, -2.0 * ( dd * dd ) / ( garea * garea ) );", + "return gauss;", + + "}", + + "float calcAO( float depth, float dw, float dh ) {", + + "vec2 vv = vec2( dw, dh );", + + "vec2 coord1 = vUv + radius * vv;", + "vec2 coord2 = vUv - radius * vv;", + + "float temp1 = 0.0;", + "float temp2 = 0.0;", + + "int far = 0;", + "temp1 = compareDepths( depth, readDepth( coord1 ), far );", + + // DEPTH EXTRAPOLATION + + "if ( far > 0 ) {", + + "temp2 = compareDepths( readDepth( coord2 ), depth, far );", + "temp1 += ( 1.0 - temp1 ) * temp2;", + + "}", + + "return temp1;", + + "}", + + "void main() {", + + "vec2 noise = rand( vUv );", + "float depth = readDepth( vUv );", + + "float tt = clamp( depth, aoClamp, 1.0 );", + + "float w = ( 1.0 / size.x ) / tt + ( noise.x * ( 1.0 - noise.x ) );", + "float h = ( 1.0 / size.y ) / tt + ( noise.y * ( 1.0 - noise.y ) );", + + "float ao = 0.0;", + + "float dz = 1.0 / float( samples );", + "float l = 0.0;", + "float z = 1.0 - dz / 2.0;", + + "for ( int i = 0; i <= samples; i ++ ) {", + + "float r = sqrt( 1.0 - z );", + + "float pw = cos( l ) * r;", + "float ph = sin( l ) * r;", + "ao += calcAO( depth, pw * w, ph * h );", + "z = z - dz;", + "l = l + DL;", + + "}", + + "ao /= float( samples );", + "ao = 1.0 - ao;", + + "vec3 color = texture2D( tDiffuse, vUv ).rgb;", + + "vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );", + "float lum = dot( color.rgb, lumcoeff );", + "vec3 luminance = vec3( lum );", + + "vec3 final = vec3( color * mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );", // mix( color * ao, white, luminance ) + + "if ( onlyAO ) {", + + "final = vec3( mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );", // ambient occlusion only + + "}", + + "gl_FragColor = vec4( final, 1.0 );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/SepiaShader.js b/three/jsutil/shaders/SepiaShader.js new file mode 100644 index 000000000..0a296083e --- /dev/null +++ b/three/jsutil/shaders/SepiaShader.js @@ -0,0 +1,54 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Sepia tone shader + * based on glfx.js sepia shader + * https://github.com/evanw/glfx.js + */ + +THREE.SepiaShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "amount": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float amount;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 color = texture2D( tDiffuse, vUv );", + "vec3 c = color.rgb;", + + "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );", + "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );", + "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );", + + "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/SobelOperatorShader.js b/three/jsutil/shaders/SobelOperatorShader.js new file mode 100644 index 000000000..7a5284140 --- /dev/null +++ b/three/jsutil/shaders/SobelOperatorShader.js @@ -0,0 +1,90 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + * + * Sobel Edge Detection (see https://youtu.be/uihBwtPIBxM) + * + * As mentioned in the video the Sobel operator expects a grayscale image as input. + * + */ + +THREE.SobelOperatorShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "resolution": { value: new THREE.Vector2() } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform vec2 resolution;", + "varying vec2 vUv;", + + "void main() {", + + "vec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );", + + // kernel definition (in glsl matrices are filled in column-major order) + + "const mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );", // x direction kernel + "const mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );", // y direction kernel + + // fetch the 3x3 neighbourhood of a fragment + + // first column + + "float tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;", + "float tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;", + "float tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;", + + // second column + + "float tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;", + "float tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;", + "float tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;", + + // third column + + "float tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;", + "float tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;", + "float tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;", + + // gradient value in x direction + + "float valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ", + "Gx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ", + "Gx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ", + + // gradient value in y direction + + "float valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ", + "Gy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ", + "Gy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ", + + // magnitute of the total gradient + + "float G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );", + + "gl_FragColor = vec4( vec3( G ), 1 );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/TechnicolorShader.js b/three/jsutil/shaders/TechnicolorShader.js new file mode 100644 index 000000000..ba1c8e713 --- /dev/null +++ b/three/jsutil/shaders/TechnicolorShader.js @@ -0,0 +1,47 @@ +/** + * @author flimshaw / http://charliehoey.com + * + * Technicolor Shader + * Simulates the look of the two-strip technicolor process popular in early 20th century films. + * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm + * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html + */ + +THREE.TechnicolorShader = { + + uniforms: { + + "tDiffuse": { value: null } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "varying vec2 vUv;", + + "void main() {", + + "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );", + "vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);", + + "gl_FragColor = newTex;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/ToneMapShader.js b/three/jsutil/shaders/ToneMapShader.js new file mode 100644 index 000000000..c6db65a3c --- /dev/null +++ b/three/jsutil/shaders/ToneMapShader.js @@ -0,0 +1,77 @@ +/** + * @author miibond + * + * Full-screen tone-mapping shader based on http://www.cis.rit.edu/people/faculty/ferwerda/publications/sig02_paper.pdf + */ + +THREE.ToneMapShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "averageLuminance": { value: 1.0 }, + "luminanceMap": { value: null }, + "maxLuminance": { value: 16.0 }, + "minLuminance": { value: 0.01 }, + "middleGrey": { value: 0.6 } + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#include ", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "uniform float middleGrey;", + "uniform float minLuminance;", + "uniform float maxLuminance;", + "#ifdef ADAPTED_LUMINANCE", + "uniform sampler2D luminanceMap;", + "#else", + "uniform float averageLuminance;", + "#endif", + + "vec3 ToneMap( vec3 vColor ) {", + "#ifdef ADAPTED_LUMINANCE", + // Get the calculated average luminance + "float fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;", + "#else", + "float fLumAvg = averageLuminance;", + "#endif", + + // Calculate the luminance of the current pixel + "float fLumPixel = linearToRelativeLuminance( vColor );", + + // Apply the modified operator (Eq. 4) + "float fLumScaled = (fLumPixel * middleGrey) / max( minLuminance, fLumAvg );", + + "float fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (maxLuminance * maxLuminance)))) / (1.0 + fLumScaled);", + "return fLumCompressed * vColor;", + "}", + + "void main() {", + + "vec4 texel = texture2D( tDiffuse, vUv );", + + "gl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/TriangleBlurShader.js b/three/jsutil/shaders/TriangleBlurShader.js new file mode 100644 index 000000000..ae9ef55e6 --- /dev/null +++ b/three/jsutil/shaders/TriangleBlurShader.js @@ -0,0 +1,72 @@ +/** + * @author zz85 / http://www.lab4games.net/zz85/blog + * + * Triangle blur shader + * based on glfx.js triangle blur shader + * https://github.com/evanw/glfx.js + * + * A basic blur filter, which convolves the image with a + * pyramid filter. The pyramid filter is separable and is applied as two + * perpendicular triangle filters. + */ + +THREE.TriangleBlurShader = { + + uniforms : { + + "texture": { value: null }, + "delta": { value: new THREE.Vector2( 1, 1 ) } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "#include ", + + "#define ITERATIONS 10.0", + + "uniform sampler2D texture;", + "uniform vec2 delta;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 color = vec4( 0.0 );", + + "float total = 0.0;", + + // randomize the lookup values to hide the fixed number of samples + + "float offset = rand( vUv );", + + "for ( float t = -ITERATIONS; t <= ITERATIONS; t ++ ) {", + + "float percent = ( t + offset - 0.5 ) / ITERATIONS;", + "float weight = 1.0 - abs( percent );", + + "color += texture2D( texture, vUv + delta * percent ) * weight;", + "total += weight;", + + "}", + + "gl_FragColor = color / total;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/UnpackDepthRGBAShader.js b/three/jsutil/shaders/UnpackDepthRGBAShader.js new file mode 100644 index 000000000..55f34a2b0 --- /dev/null +++ b/three/jsutil/shaders/UnpackDepthRGBAShader.js @@ -0,0 +1,49 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Unpack RGBA depth shader + * - show RGBA encoded depth as monochrome color + */ + +THREE.UnpackDepthRGBAShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "opacity": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float opacity;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "#include ", + + "void main() {", + + "float depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );", + "gl_FragColor = vec4( vec3( depth ), opacity );", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/VerticalBlurShader.js b/three/jsutil/shaders/VerticalBlurShader.js new file mode 100644 index 000000000..80f6e901f --- /dev/null +++ b/three/jsutil/shaders/VerticalBlurShader.js @@ -0,0 +1,62 @@ +/** + * @author zz85 / http://www.lab4games.net/zz85/blog + * + * Two pass Gaussian blur filter (horizontal and vertical blur shaders) + * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ + * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html + * + * - 9 samples per pass + * - standard deviation 2.7 + * - "h" and "v" parameters should be set to "1 / width" and "1 / height" + */ + +THREE.VerticalBlurShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "v": { value: 1.0 / 512.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float v;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 sum = vec4( 0.0 );", + + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;", + + "gl_FragColor = sum;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/VerticalTiltShiftShader.js b/three/jsutil/shaders/VerticalTiltShiftShader.js new file mode 100644 index 000000000..ad8ff70c9 --- /dev/null +++ b/three/jsutil/shaders/VerticalTiltShiftShader.js @@ -0,0 +1,65 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position + * + * - 9 samples per pass + * - standard deviation 2.7 + * - "h" and "v" parameters should be set to "1 / width" and "1 / height" + * - "r" parameter control where "focused" horizontal line lies + */ + +THREE.VerticalTiltShiftShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "v": { value: 1.0 / 512.0 }, + "r": { value: 0.35 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform sampler2D tDiffuse;", + "uniform float v;", + "uniform float r;", + + "varying vec2 vUv;", + + "void main() {", + + "vec4 sum = vec4( 0.0 );", + + "float vv = v * abs( r - vUv.y );", + + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;", + "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;", + + "gl_FragColor = sum;", + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/VignetteShader.js b/three/jsutil/shaders/VignetteShader.js new file mode 100644 index 000000000..81d921535 --- /dev/null +++ b/three/jsutil/shaders/VignetteShader.js @@ -0,0 +1,63 @@ +/** + * @author alteredq / http://alteredqualia.com/ + * + * Vignette shader + * based on PaintEffect postprocess from ro.me + * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js + */ + +THREE.VignetteShader = { + + uniforms: { + + "tDiffuse": { value: null }, + "offset": { value: 1.0 }, + "darkness": { value: 1.0 } + + }, + + vertexShader: [ + + "varying vec2 vUv;", + + "void main() {", + + "vUv = uv;", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + + "}" + + ].join( "\n" ), + + fragmentShader: [ + + "uniform float offset;", + "uniform float darkness;", + + "uniform sampler2D tDiffuse;", + + "varying vec2 vUv;", + + "void main() {", + + // Eskil's vignette + + "vec4 texel = texture2D( tDiffuse, vUv );", + "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );", + "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );", + + /* + // alternative version from glfx.js + // this one makes more "dusty" look (as opposed to "burned") + + "vec4 color = texture2D( tDiffuse, vUv );", + "float dist = distance( vUv, vec2( 0.5 ) );", + "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );", + "gl_FragColor = color;", + */ + + "}" + + ].join( "\n" ) + +}; diff --git a/three/jsutil/shaders/VolumeShader.js b/three/jsutil/shaders/VolumeShader.js new file mode 100644 index 000000000..ab073383e --- /dev/null +++ b/three/jsutil/shaders/VolumeShader.js @@ -0,0 +1,324 @@ +/** + * @author Almar Klein / http://almarklein.org + * + * Shaders to render 3D volumes using raycasting. + * The applied techniques are based on similar implementations in the Visvis and Vispy projects. + * This is not the only approach, therefore it's marked 1. + */ + +THREE.VolumeRenderShader1 = { + uniforms: { + "u_size": { value: new THREE.Vector3( 1, 1, 1 ) }, + "u_renderstyle": { value: 0 }, + "u_renderthreshold": { value: 0.5 }, + "u_clim": { value: new THREE.Vector2( 1, 1 ) }, + "u_data": { value: null }, + "u_cmdata": { value: null } + }, + vertexShader: [ + 'varying vec4 v_nearpos;', + 'varying vec4 v_farpos;', + 'varying vec3 v_position;', + + 'mat4 inversemat(mat4 m) {', + // Taken from https://github.com/stackgl/glsl-inverse/blob/master/index.glsl + // This function is licenced by the MIT license to Mikola Lysenko + 'float', + 'a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],', + 'a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],', + 'a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],', + 'a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],', + + 'b00 = a00 * a11 - a01 * a10,', + 'b01 = a00 * a12 - a02 * a10,', + 'b02 = a00 * a13 - a03 * a10,', + 'b03 = a01 * a12 - a02 * a11,', + 'b04 = a01 * a13 - a03 * a11,', + 'b05 = a02 * a13 - a03 * a12,', + 'b06 = a20 * a31 - a21 * a30,', + 'b07 = a20 * a32 - a22 * a30,', + 'b08 = a20 * a33 - a23 * a30,', + 'b09 = a21 * a32 - a22 * a31,', + 'b10 = a21 * a33 - a23 * a31,', + 'b11 = a22 * a33 - a23 * a32,', + + 'det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;', + + 'return mat4(', + 'a11 * b11 - a12 * b10 + a13 * b09,', + 'a02 * b10 - a01 * b11 - a03 * b09,', + 'a31 * b05 - a32 * b04 + a33 * b03,', + 'a22 * b04 - a21 * b05 - a23 * b03,', + 'a12 * b08 - a10 * b11 - a13 * b07,', + 'a00 * b11 - a02 * b08 + a03 * b07,', + 'a32 * b02 - a30 * b05 - a33 * b01,', + 'a20 * b05 - a22 * b02 + a23 * b01,', + 'a10 * b10 - a11 * b08 + a13 * b06,', + 'a01 * b08 - a00 * b10 - a03 * b06,', + 'a30 * b04 - a31 * b02 + a33 * b00,', + 'a21 * b02 - a20 * b04 - a23 * b00,', + 'a11 * b07 - a10 * b09 - a12 * b06,', + 'a00 * b09 - a01 * b07 + a02 * b06,', + 'a31 * b01 - a30 * b03 - a32 * b00,', + 'a20 * b03 - a21 * b01 + a22 * b00) / det;', + '}', + + + 'void main() {', + // Prepare transforms to map to "camera view". See also: + // https://threejs.org/docs/#api/renderers/webgl/WebGLProgram + 'mat4 viewtransformf = viewMatrix;', + 'mat4 viewtransformi = inversemat(viewMatrix);', + + // Project local vertex coordinate to camera position. Then do a step + // backward (in cam coords) to the near clipping plane, and project back. Do + // the same for the far clipping plane. This gives us all the information we + // need to calculate the ray and truncate it to the viewing cone. + 'vec4 position4 = vec4(position, 1.0);', + 'vec4 pos_in_cam = viewtransformf * position4;', + + // Intersection of ray and near clipping plane (z = -1 in clip coords) + 'pos_in_cam.z = -pos_in_cam.w;', + 'v_nearpos = viewtransformi * pos_in_cam;', + + // Intersection of ray and far clipping plane (z = +1 in clip coords) + 'pos_in_cam.z = pos_in_cam.w;', + 'v_farpos = viewtransformi * pos_in_cam;', + + // Set varyings and output pos + 'v_position = position;', + 'gl_Position = projectionMatrix * viewMatrix * modelMatrix * position4;', + '}', + ].join( '\n' ), + fragmentShader: [ + 'precision highp float;', + 'precision mediump sampler3D;', + + 'uniform vec3 u_size;', + 'uniform int u_renderstyle;', + 'uniform float u_renderthreshold;', + 'uniform vec2 u_clim;', + + 'uniform sampler3D u_data;', + 'uniform sampler2D u_cmdata;', + + 'varying vec3 v_position;', + 'varying vec4 v_nearpos;', + 'varying vec4 v_farpos;', + + // The maximum distance through our rendering volume is sqrt(3). + 'const int MAX_STEPS = 887; // 887 for 512^3, 1774 for 1024^3', + 'const int REFINEMENT_STEPS = 4;', + 'const float relative_step_size = 1.0;', + 'const vec4 ambient_color = vec4(0.2, 0.4, 0.2, 1.0);', + 'const vec4 diffuse_color = vec4(0.8, 0.2, 0.2, 1.0);', + 'const vec4 specular_color = vec4(1.0, 1.0, 1.0, 1.0);', + 'const float shininess = 40.0;', + + 'void cast_mip(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray);', + 'void cast_iso(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray);', + + 'float sample1(vec3 texcoords);', + 'vec4 apply_colormap(float val);', + 'vec4 add_lighting(float val, vec3 loc, vec3 step, vec3 view_ray);', + + + 'void main() {', + // Normalize clipping plane info + 'vec3 farpos = v_farpos.xyz / v_farpos.w;', + 'vec3 nearpos = v_nearpos.xyz / v_nearpos.w;', + + // Calculate unit vector pointing in the view direction through this fragment. + 'vec3 view_ray = normalize(nearpos.xyz - farpos.xyz);', + + // Compute the (negative) distance to the front surface or near clipping plane. + // v_position is the back face of the cuboid, so the initial distance calculated in the dot + // product below is the distance from near clip plane to the back of the cuboid + 'float distance = dot(nearpos - v_position, view_ray);', + 'distance = max(distance, min((-0.5 - v_position.x) / view_ray.x,', + '(u_size.x - 0.5 - v_position.x) / view_ray.x));', + 'distance = max(distance, min((-0.5 - v_position.y) / view_ray.y,', + '(u_size.y - 0.5 - v_position.y) / view_ray.y));', + 'distance = max(distance, min((-0.5 - v_position.z) / view_ray.z,', + '(u_size.z - 0.5 - v_position.z) / view_ray.z));', + + // Now we have the starting position on the front surface + 'vec3 front = v_position + view_ray * distance;', + + // Decide how many steps to take + 'int nsteps = int(-distance / relative_step_size + 0.5);', + 'if ( nsteps < 1 )', + 'discard;', + + // Get starting location and step vector in texture coordinates + 'vec3 step = ((v_position - front) / u_size) / float(nsteps);', + 'vec3 start_loc = front / u_size;', + + // For testing: show the number of steps. This helps to establish + // whether the rays are correctly oriented + //'gl_FragColor = vec4(0.0, float(nsteps) / 1.0 / u_size.x, 1.0, 1.0);', + //'return;', + + 'if (u_renderstyle == 0)', + 'cast_mip(start_loc, step, nsteps, view_ray);', + 'else if (u_renderstyle == 1)', + 'cast_iso(start_loc, step, nsteps, view_ray);', + + 'if (gl_FragColor.a < 0.05)', + 'discard;', + '}', + + + 'float sample1(vec3 texcoords) {', + '/* Sample float value from a 3D texture. Assumes intensity data. */', + 'return texture(u_data, texcoords.xyz).r;', + '}', + + + 'vec4 apply_colormap(float val) {', + 'val = (val - u_clim[0]) / (u_clim[1] - u_clim[0]);', + 'return texture2D(u_cmdata, vec2(val, 0.5));', + '}', + + + 'void cast_mip(vec3 start_loc, vec3 step, int nsteps, vec3 view_ray) {', + + 'float max_val = -1e6;', + 'int max_i = 100;', + 'vec3 loc = start_loc;', + + // Enter the raycasting loop. In WebGL 1 the loop index cannot be compared with + // non-constant expression. So we use a hard-coded max, and an additional condition + // inside the loop. + 'for (int iter=0; iter= nsteps)', + 'break;', + // Sample from the 3D texture + 'float val = sample1(loc);', + // Apply MIP operation + 'if (val > max_val) {', + 'max_val = val;', + 'max_i = iter;', + '}', + // Advance location deeper into the volume + 'loc += step;', + '}', + + // Refine location, gives crispier images + 'vec3 iloc = start_loc + step * (float(max_i) - 0.5);', + 'vec3 istep = step / float(REFINEMENT_STEPS);', + 'for (int i=0; i= nsteps)', + 'break;', + + // Sample from the 3D texture + 'float val = sample1(loc);', + + 'if (val > low_threshold) {', + // Take the last interval in smaller steps + 'vec3 iloc = loc - 0.5 * step;', + 'vec3 istep = step / float(REFINEMENT_STEPS);', + 'for (int i=0; i u_renderthreshold) {', + 'gl_FragColor = add_lighting(val, iloc, dstep, view_ray);', + 'return;', + '}', + 'iloc += istep;', + '}', + '}', + + // Advance location deeper into the volume + 'loc += step;', + '}', + '}', + + + 'vec4 add_lighting(float val, vec3 loc, vec3 step, vec3 view_ray)', + '{', + // Calculate color by incorporating lighting + + // View direction + 'vec3 V = normalize(view_ray);', + + // calculate normal vector from gradient + 'vec3 N;', + 'float val1, val2;', + 'val1 = sample1(loc + vec3(-step[0], 0.0, 0.0));', + 'val2 = sample1(loc + vec3(+step[0], 0.0, 0.0));', + 'N[0] = val1 - val2;', + 'val = max(max(val1, val2), val);', + 'val1 = sample1(loc + vec3(0.0, -step[1], 0.0));', + 'val2 = sample1(loc + vec3(0.0, +step[1], 0.0));', + 'N[1] = val1 - val2;', + 'val = max(max(val1, val2), val);', + 'val1 = sample1(loc + vec3(0.0, 0.0, -step[2]));', + 'val2 = sample1(loc + vec3(0.0, 0.0, +step[2]));', + 'N[2] = val1 - val2;', + 'val = max(max(val1, val2), val);', + + 'float gm = length(N); // gradient magnitude', + 'N = normalize(N);', + + // Flip normal so it points towards viewer + 'float Nselect = float(dot(N, V) > 0.0);', + 'N = (2.0 * Nselect - 1.0) * N; // == Nselect * N - (1.0-Nselect)*N;', + + // Init colors + 'vec4 ambient_color = vec4(0.0, 0.0, 0.0, 0.0);', + 'vec4 diffuse_color = vec4(0.0, 0.0, 0.0, 0.0);', + 'vec4 specular_color = vec4(0.0, 0.0, 0.0, 0.0);', + + // note: could allow multiple lights + 'for (int i=0; i<1; i++)', + '{', + // Get light direction (make sure to prevent zero devision) + 'vec3 L = normalize(view_ray); //lightDirs[i];', + 'float lightEnabled = float( length(L) > 0.0 );', + 'L = normalize(L + (1.0 - lightEnabled));', + + // Calculate lighting properties + 'float lambertTerm = clamp(dot(N, L), 0.0, 1.0);', + 'vec3 H = normalize(L+V); // Halfway vector', + 'float specularTerm = pow(max(dot(H, N), 0.0), shininess);', + + // Calculate mask + 'float mask1 = lightEnabled;', + + // Calculate colors + 'ambient_color += mask1 * ambient_color; // * gl_LightSource[i].ambient;', + 'diffuse_color += mask1 * lambertTerm;', + 'specular_color += mask1 * specularTerm * specular_color;', + '}', + + // Calculate final color by componing different components + 'vec4 final_color;', + 'vec4 color = apply_colormap(val);', + 'final_color = color * (ambient_color + diffuse_color) + specular_color;', + 'final_color.a = color.a;', + 'return final_color;', + '}', + ].join( '\n' ) +}; diff --git a/three/jsutil/shaders/WaterRefractionShader.js b/three/jsutil/shaders/WaterRefractionShader.js new file mode 100644 index 000000000..bb3f7d26b --- /dev/null +++ b/three/jsutil/shaders/WaterRefractionShader.js @@ -0,0 +1,101 @@ +/** + * @author Mugen87 / https://github.com/Mugen87 + * + */ + +THREE.WaterRefractionShader = { + + uniforms: { + + 'color': { + type: 'c', + value: null + }, + + 'time': { + type: 'f', + value: 0 + }, + + 'tDiffuse': { + type: 't', + value: null + }, + + 'tDudv': { + type: 't', + value: null + }, + + 'textureMatrix': { + type: 'm4', + value: null + } + + }, + + vertexShader: [ + + 'uniform mat4 textureMatrix;', + + 'varying vec2 vUv;', + 'varying vec4 vUvRefraction;', + + 'void main() {', + + ' vUv = uv;', + + ' vUvRefraction = textureMatrix * vec4( position, 1.0 );', + + ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', + + '}' + + ].join( '\n' ), + + fragmentShader: [ + + 'uniform vec3 color;', + 'uniform float time;', + 'uniform sampler2D tDiffuse;', + 'uniform sampler2D tDudv;', + + 'varying vec2 vUv;', + 'varying vec4 vUvRefraction;', + + 'float blendOverlay( float base, float blend ) {', + + ' return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );', + + '}', + + 'vec3 blendOverlay( vec3 base, vec3 blend ) {', + + ' return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ),blendOverlay( base.b, blend.b ) );', + + '}', + + 'void main() {', + + ' float waveStrength = 0.1;', + ' float waveSpeed = 0.03;', + + // simple distortion (ripple) via dudv map (see https://www.youtube.com/watch?v=6B7IF6GOu7s) + + ' vec2 distortedUv = texture2D( tDudv, vec2( vUv.x + time * waveSpeed, vUv.y ) ).rg * waveStrength;', + ' distortedUv = vUv.xy + vec2( distortedUv.x, distortedUv.y + time * waveSpeed );', + ' vec2 distortion = ( texture2D( tDudv, distortedUv ).rg * 2.0 - 1.0 ) * waveStrength;', + + // new uv coords + + ' vec4 uv = vec4( vUvRefraction );', + ' uv.xy += distortion;', + + ' vec4 base = texture2DProj( tDiffuse, uv );', + + ' gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );', + + '}' + + ].join( '\n' ) +}; diff --git a/three/jsutil/utils/BufferGeometryUtils.js b/three/jsutil/utils/BufferGeometryUtils.js new file mode 100644 index 000000000..c5e21ffd2 --- /dev/null +++ b/three/jsutil/utils/BufferGeometryUtils.js @@ -0,0 +1,385 @@ +/** + * @author mrdoob / http://mrdoob.com/ + */ + +THREE.BufferGeometryUtils = { + + computeTangents: function ( geometry ) { + + var index = geometry.index; + var attributes = geometry.attributes; + + // based on http://www.terathon.com/code/tangent.html + // (per vertex tangents) + + if ( index === null || + attributes.position === undefined || + attributes.normal === undefined || + attributes.uv === undefined ) { + + console.warn( 'THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()' ); + return; + + } + + var indices = index.array; + var positions = attributes.position.array; + var normals = attributes.normal.array; + var uvs = attributes.uv.array; + + var nVertices = positions.length / 3; + + if ( attributes.tangent === undefined ) { + + geometry.addAttribute( 'tangent', new THREE.BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) ); + + } + + var tangents = attributes.tangent.array; + + var tan1 = [], tan2 = []; + + for ( var i = 0; i < nVertices; i ++ ) { + + tan1[ i ] = new THREE.Vector3(); + tan2[ i ] = new THREE.Vector3(); + + } + + var vA = new THREE.Vector3(), + vB = new THREE.Vector3(), + vC = new THREE.Vector3(), + + uvA = new THREE.Vector2(), + uvB = new THREE.Vector2(), + uvC = new THREE.Vector2(), + + sdir = new THREE.Vector3(), + tdir = new THREE.Vector3(); + + function handleTriangle( a, b, c ) { + + vA.fromArray( positions, a * 3 ); + vB.fromArray( positions, b * 3 ); + vC.fromArray( positions, c * 3 ); + + uvA.fromArray( uvs, a * 2 ); + uvB.fromArray( uvs, b * 2 ); + uvC.fromArray( uvs, c * 2 ); + + var x1 = vB.x - vA.x; + var x2 = vC.x - vA.x; + + var y1 = vB.y - vA.y; + var y2 = vC.y - vA.y; + + var z1 = vB.z - vA.z; + var z2 = vC.z - vA.z; + + var s1 = uvB.x - uvA.x; + var s2 = uvC.x - uvA.x; + + var t1 = uvB.y - uvA.y; + var t2 = uvC.y - uvA.y; + + var r = 1.0 / ( s1 * t2 - s2 * t1 ); + + sdir.set( + ( t2 * x1 - t1 * x2 ) * r, + ( t2 * y1 - t1 * y2 ) * r, + ( t2 * z1 - t1 * z2 ) * r + ); + + tdir.set( + ( s1 * x2 - s2 * x1 ) * r, + ( s1 * y2 - s2 * y1 ) * r, + ( s1 * z2 - s2 * z1 ) * r + ); + + tan1[ a ].add( sdir ); + tan1[ b ].add( sdir ); + tan1[ c ].add( sdir ); + + tan2[ a ].add( tdir ); + tan2[ b ].add( tdir ); + tan2[ c ].add( tdir ); + + } + + var groups = geometry.groups; + + if ( groups.length === 0 ) { + + groups = [ { + start: 0, + count: indices.length + } ]; + + } + + for ( var i = 0, il = groups.length; i < il; ++ i ) { + + var group = groups[ i ]; + + var start = group.start; + var count = group.count; + + for ( var j = start, jl = start + count; j < jl; j += 3 ) { + + handleTriangle( + indices[ j + 0 ], + indices[ j + 1 ], + indices[ j + 2 ] + ); + + } + + } + + var tmp = new THREE.Vector3(), tmp2 = new THREE.Vector3(); + var n = new THREE.Vector3(), n2 = new THREE.Vector3(); + var w, t, test; + + function handleVertex( v ) { + + n.fromArray( normals, v * 3 ); + n2.copy( n ); + + t = tan1[ v ]; + + // Gram-Schmidt orthogonalize + + tmp.copy( t ); + tmp.sub( n.multiplyScalar( n.dot( t ) ) ).normalize(); + + // Calculate handedness + + tmp2.crossVectors( n2, t ); + test = tmp2.dot( tan2[ v ] ); + w = ( test < 0.0 ) ? - 1.0 : 1.0; + + tangents[ v * 4 ] = tmp.x; + tangents[ v * 4 + 1 ] = tmp.y; + tangents[ v * 4 + 2 ] = tmp.z; + tangents[ v * 4 + 3 ] = w; + + } + + for ( var i = 0, il = groups.length; i < il; ++ i ) { + + var group = groups[ i ]; + + var start = group.start; + var count = group.count; + + for ( var j = start, jl = start + count; j < jl; j += 3 ) { + + handleVertex( indices[ j + 0 ] ); + handleVertex( indices[ j + 1 ] ); + handleVertex( indices[ j + 2 ] ); + + } + + } + + }, + + /** + * @param {Array} geometries + * @return {THREE.BufferGeometry} + */ + mergeBufferGeometries: function ( geometries, useGroups ) { + + var isIndexed = geometries[ 0 ].index !== null; + + var attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) ); + var morphAttributesUsed = new Set( Object.keys( geometries[ 0 ].morphAttributes ) ); + + var attributes = {}; + var morphAttributes = {}; + + var mergedGeometry = new THREE.BufferGeometry(); + + var offset = 0; + + for ( var i = 0; i < geometries.length; ++ i ) { + + var geometry = geometries[ i ]; + + // ensure that all geometries are indexed, or none + + if ( isIndexed !== ( geometry.index !== null ) ) return null; + + // gather attributes, exit early if they're different + + for ( var name in geometry.attributes ) { + + if ( ! attributesUsed.has( name ) ) return null; + + if ( attributes[ name ] === undefined ) attributes[ name ] = []; + + attributes[ name ].push( geometry.attributes[ name ] ); + + } + + // gather morph attributes, exit early if they're different + + for ( var name in geometry.morphAttributes ) { + + if ( ! morphAttributesUsed.has( name ) ) return null; + + if ( morphAttributes[ name ] === undefined ) morphAttributes[ name ] = []; + + morphAttributes[ name ].push( geometry.morphAttributes[ name ] ); + + } + + // gather .userData + + mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || []; + mergedGeometry.userData.mergedUserData.push( geometry.userData ); + + if ( useGroups ) { + + var count; + + if ( isIndexed ) { + + count = geometry.index.count; + + } else if ( geometry.attributes.position !== undefined ) { + + count = geometry.attributes.position.count; + + } else { + + return null; + + } + + mergedGeometry.addGroup( offset, count, i ); + + offset += count; + + } + + } + + // merge indices + + if ( isIndexed ) { + + var indexOffset = 0; + var mergedIndex = []; + + for ( var i = 0; i < geometries.length; ++ i ) { + + var index = geometries[ i ].index; + + for ( var j = 0; j < index.count; ++ j ) { + + mergedIndex.push( index.getX( j ) + indexOffset ); + + } + + indexOffset += geometries[ i ].attributes.position.count; + + } + + mergedGeometry.setIndex( mergedIndex ); + + } + + // merge attributes + + for ( var name in attributes ) { + + var mergedAttribute = this.mergeBufferAttributes( attributes[ name ] ); + + if ( ! mergedAttribute ) return null; + + mergedGeometry.addAttribute( name, mergedAttribute ); + + } + + // merge morph attributes + + for ( var name in morphAttributes ) { + + var numMorphTargets = morphAttributes[ name ][ 0 ].length; + + if ( numMorphTargets === 0 ) break; + + mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {}; + mergedGeometry.morphAttributes[ name ] = []; + + for ( var i = 0; i < numMorphTargets; ++ i ) { + + var morphAttributesToMerge = []; + + for ( var j = 0; j < morphAttributes[ name ].length; ++ j ) { + + morphAttributesToMerge.push( morphAttributes[ name ][ j ][ i ] ); + + } + + var mergedMorphAttribute = this.mergeBufferAttributes( morphAttributesToMerge ); + + if ( ! mergedMorphAttribute ) return null; + + mergedGeometry.morphAttributes[ name ].push( mergedMorphAttribute ); + + } + + } + + return mergedGeometry; + + }, + + /** + * @param {Array} attributes + * @return {THREE.BufferAttribute} + */ + mergeBufferAttributes: function ( attributes ) { + + var TypedArray; + var itemSize; + var normalized; + var arrayLength = 0; + + for ( var i = 0; i < attributes.length; ++ i ) { + + var attribute = attributes[ i ]; + + if ( attribute.isInterleavedBufferAttribute ) return null; + + if ( TypedArray === undefined ) TypedArray = attribute.array.constructor; + if ( TypedArray !== attribute.array.constructor ) return null; + + if ( itemSize === undefined ) itemSize = attribute.itemSize; + if ( itemSize !== attribute.itemSize ) return null; + + if ( normalized === undefined ) normalized = attribute.normalized; + if ( normalized !== attribute.normalized ) return null; + + arrayLength += attribute.array.length; + + } + + var array = new TypedArray( arrayLength ); + var offset = 0; + + for ( var i = 0; i < attributes.length; ++ i ) { + + array.set( attributes[ i ].array, offset ); + + offset += attributes[ i ].array.length; + + } + + return new THREE.BufferAttribute( array, itemSize, normalized ); + + } + +}; diff --git a/three/jsutil/utils/GeometryUtils.js b/three/jsutil/utils/GeometryUtils.js new file mode 100644 index 000000000..9d7f3ad1e --- /dev/null +++ b/three/jsutil/utils/GeometryUtils.js @@ -0,0 +1,300 @@ +/** + * @author mrdoob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.GeometryUtils = { + + // Merge two geometries or geometry and geometry from object (using object's transform) + + merge: function ( geometry1, geometry2, materialIndexOffset ) { + + console.warn( 'THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.' ); + + var matrix; + + if ( geometry2 instanceof THREE.Mesh ) { + + geometry2.matrixAutoUpdate && geometry2.updateMatrix(); + + matrix = geometry2.matrix; + geometry2 = geometry2.geometry; + + } + + geometry1.merge( geometry2, matrix, materialIndexOffset ); + + }, + + // Get random point in triangle (via barycentric coordinates) + // (uniform distribution) + // http://www.cgafaq.info/wiki/Random_Point_In_Triangle + + randomPointInTriangle: function () { + + var vector = new THREE.Vector3(); + + return function ( vectorA, vectorB, vectorC ) { + + var point = new THREE.Vector3(); + + var a = Math.random(); + var b = Math.random(); + + if ( ( a + b ) > 1 ) { + + a = 1 - a; + b = 1 - b; + + } + + var c = 1 - a - b; + + point.copy( vectorA ); + point.multiplyScalar( a ); + + vector.copy( vectorB ); + vector.multiplyScalar( b ); + + point.add( vector ); + + vector.copy( vectorC ); + vector.multiplyScalar( c ); + + point.add( vector ); + + return point; + + }; + + }(), + + // Get random point in face (triangle) + // (uniform distribution) + + randomPointInFace: function ( face, geometry ) { + + var vA, vB, vC; + + vA = geometry.vertices[ face.a ]; + vB = geometry.vertices[ face.b ]; + vC = geometry.vertices[ face.c ]; + + return THREE.GeometryUtils.randomPointInTriangle( vA, vB, vC ); + + }, + + // Get uniformly distributed random points in mesh + // - create array with cumulative sums of face areas + // - pick random number from 0 to total area + // - find corresponding place in area array by binary search + // - get random point in face + + randomPointsInGeometry: function ( geometry, n ) { + + var face, i, + faces = geometry.faces, + vertices = geometry.vertices, + il = faces.length, + totalArea = 0, + cumulativeAreas = [], + vA, vB, vC; + + // precompute face areas + + for ( i = 0; i < il; i ++ ) { + + face = faces[ i ]; + + vA = vertices[ face.a ]; + vB = vertices[ face.b ]; + vC = vertices[ face.c ]; + + face._area = THREE.GeometryUtils.triangleArea( vA, vB, vC ); + + totalArea += face._area; + + cumulativeAreas[ i ] = totalArea; + + } + + // binary search cumulative areas array + + function binarySearchIndices( value ) { + + function binarySearch( start, end ) { + + // return closest larger index + // if exact number is not found + + if ( end < start ) + return start; + + var mid = start + Math.floor( ( end - start ) / 2 ); + + if ( cumulativeAreas[ mid ] > value ) { + + return binarySearch( start, mid - 1 ); + + } else if ( cumulativeAreas[ mid ] < value ) { + + return binarySearch( mid + 1, end ); + + } else { + + return mid; + + } + + } + + var result = binarySearch( 0, cumulativeAreas.length - 1 ); + return result; + + } + + // pick random face weighted by face area + + var r, index, + result = []; + + var stats = {}; + + for ( i = 0; i < n; i ++ ) { + + r = Math.random() * totalArea; + + index = binarySearchIndices( r ); + + result[ i ] = THREE.GeometryUtils.randomPointInFace( faces[ index ], geometry ); + + if ( ! stats[ index ] ) { + + stats[ index ] = 1; + + } else { + + stats[ index ] += 1; + + } + + } + + return result; + + }, + + randomPointsInBufferGeometry: function ( geometry, n ) { + + var i, + vertices = geometry.attributes.position.array, + totalArea = 0, + cumulativeAreas = [], + vA, vB, vC; + + // precompute face areas + vA = new THREE.Vector3(); + vB = new THREE.Vector3(); + vC = new THREE.Vector3(); + + // geometry._areas = []; + var il = vertices.length / 9; + + for ( i = 0; i < il; i ++ ) { + + vA.set( vertices[ i * 9 + 0 ], vertices[ i * 9 + 1 ], vertices[ i * 9 + 2 ] ); + vB.set( vertices[ i * 9 + 3 ], vertices[ i * 9 + 4 ], vertices[ i * 9 + 5 ] ); + vC.set( vertices[ i * 9 + 6 ], vertices[ i * 9 + 7 ], vertices[ i * 9 + 8 ] ); + + totalArea += THREE.GeometryUtils.triangleArea( vA, vB, vC ); + + cumulativeAreas.push( totalArea ); + + } + + // binary search cumulative areas array + + function binarySearchIndices( value ) { + + function binarySearch( start, end ) { + + // return closest larger index + // if exact number is not found + + if ( end < start ) + return start; + + var mid = start + Math.floor( ( end - start ) / 2 ); + + if ( cumulativeAreas[ mid ] > value ) { + + return binarySearch( start, mid - 1 ); + + } else if ( cumulativeAreas[ mid ] < value ) { + + return binarySearch( mid + 1, end ); + + } else { + + return mid; + + } + + } + + var result = binarySearch( 0, cumulativeAreas.length - 1 ); + return result; + + } + + // pick random face weighted by face area + + var r, index, + result = []; + + for ( i = 0; i < n; i ++ ) { + + r = Math.random() * totalArea; + + index = binarySearchIndices( r ); + + // result[ i ] = THREE.GeometryUtils.randomPointInFace( faces[ index ], geometry, true ); + vA.set( vertices[ index * 9 + 0 ], vertices[ index * 9 + 1 ], vertices[ index * 9 + 2 ] ); + vB.set( vertices[ index * 9 + 3 ], vertices[ index * 9 + 4 ], vertices[ index * 9 + 5 ] ); + vC.set( vertices[ index * 9 + 6 ], vertices[ index * 9 + 7 ], vertices[ index * 9 + 8 ] ); + result[ i ] = THREE.GeometryUtils.randomPointInTriangle( vA, vB, vC ); + + } + + return result; + + }, + + // Get triangle area (half of parallelogram) + // http://mathworld.wolfram.com/TriangleArea.html + + triangleArea: function () { + + var vector1 = new THREE.Vector3(); + var vector2 = new THREE.Vector3(); + + return function ( vectorA, vectorB, vectorC ) { + + vector1.subVectors( vectorB, vectorA ); + vector2.subVectors( vectorC, vectorA ); + vector1.cross( vector2 ); + + return 0.5 * vector1.length(); + + }; + + }(), + + center: function ( geometry ) { + + console.warn( 'THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.' ); + return geometry.center(); + + } + +}; diff --git a/three/jsutil/utils/MathUtils.js b/three/jsutil/utils/MathUtils.js new file mode 100644 index 000000000..951ef7d39 --- /dev/null +++ b/three/jsutil/utils/MathUtils.js @@ -0,0 +1,63 @@ +/** + * @author WestLangley / http://github.com/WestLangley + * @author thezwap / http://github.com/thezwap + */ + +THREE.MathUtils = { + + setQuaternionFromProperEuler: function ( q, a, b, c, order ) { + + // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles + + // rotations are applied to the axes in the order specified by 'order' + // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c' + // angles are in radians + + var cos = Math.cos; + var sin = Math.sin; + + var c2 = cos( b / 2 ); + var s2 = sin( b / 2 ); + + var c13 = cos( ( a + c ) / 2 ); + var s13 = sin( ( a + c ) / 2 ); + + var c1_3 = cos( ( a - c ) / 2 ); + var s1_3 = sin( ( a - c ) / 2 ); + + var c3_1 = cos( ( c - a ) / 2 ); + var s3_1 = sin( ( c - a ) / 2 ); + + if ( order === 'XYX' ) { + + q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 ); + + } else if ( order === 'YZY' ) { + + q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 ); + + } else if ( order === 'ZXZ' ) { + + q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 ); + + } else if ( order === 'XZX' ) { + + q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 ); + + } else if ( order === 'YXY' ) { + + q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 ); + + } else if ( order === 'ZYZ' ) { + + q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 ); + + } else { + + console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.' ); + + } + + } + +}; diff --git a/three/jsutil/utils/SceneUtils.js b/three/jsutil/utils/SceneUtils.js new file mode 100644 index 000000000..faaed8a97 --- /dev/null +++ b/three/jsutil/utils/SceneUtils.js @@ -0,0 +1,38 @@ +/** + * @author alteredq / http://alteredqualia.com/ + */ + +THREE.SceneUtils = { + + createMultiMaterialObject: function ( geometry, materials ) { + + var group = new THREE.Group(); + + for ( var i = 0, l = materials.length; i < l; i ++ ) { + + group.add( new THREE.Mesh( geometry, materials[ i ] ) ); + + } + + return group; + + }, + + detach: function ( child, parent, scene ) { + + child.applyMatrix( parent.matrixWorld ); + parent.remove( child ); + scene.add( child ); + + }, + + attach: function ( child, scene, parent ) { + + child.applyMatrix( new THREE.Matrix4().getInverse( parent.matrixWorld ) ); + + scene.remove( child ); + parent.add( child ); + + } + +}; diff --git a/three/jsutil/utils/ShadowMapViewer.js b/three/jsutil/utils/ShadowMapViewer.js new file mode 100644 index 000000000..48fd2e711 --- /dev/null +++ b/three/jsutil/utils/ShadowMapViewer.js @@ -0,0 +1,192 @@ +/** + * @author arya-s / https://github.com/arya-s + * + * This is a helper for visualising a given light's shadow map. + * It works for shadow casting lights: THREE.DirectionalLight and THREE.SpotLight. + * It renders out the shadow map and displays it on a HUD. + * + * Example usage: + * 1) Include