@newkrok/nape-js 3.22.1 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +141 -1
- package/dist/index.d.ts +141 -1
- package/dist/index.js +1 -1
- package/llms-full.txt +44 -0
- package/llms.txt +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {E as E$1,A,G,x,b,l as l$1,D,v as v$1,F as F$1,u,H,I as I$1,J as J$1,K as K$1,L as L$1,N,M,R,_,O as O$1,$,aa,Q,T as T$1,ba,ca,da,ea,V as V$1,P as P$1,fa,ha,ia,U,X as X$1,ja,ga,t,d,ka,la,k,ma,m,na,n,oa,o,pa,p,qa,q as q$1,ra,s,a,e,Z,Y as Y$1,j as j$1,B as B$1,y,C,w,z as z$1,f,g,h,i,r,c}from'./chunk-XFL4PQ5L.js';export{K as AABB,la as AngleJoint,_ as Body,$ as BodyType,ja as Broadphase,ia as Capsule,fa as Circle,aa as Compound,ka as Constraint,W as DebugDrawFlags,ma as DistanceJoint,T as FluidProperties,N as GeomPoly,ca as GravMassMode,da as InertiaMode,ga as InteractionFilter,R as Interactor,na as LineJoint,ea as MassMode,J as MatMN,ba as Material,oa as MotorJoint,S as NapeList,pa as PivotJoint,ha as Polygon,qa as PulleyJoint,V as Shape,U as ShapeType,X as Space,H as Vec2,I as Vec3,ra as WeldJoint,L as Winding}from'./chunk-XFL4PQ5L.js';var Pt={epsilon:1e-8,fluidAngularDragFriction:2.5,fluidAngularDrag:100,fluidVacuumDrag:.5,fluidLinearDrag:.5,collisionSlop:.2,collisionSlopCCD:.5,distanceThresholdCCD:.05,staticCCDLinearThreshold:.05,staticCCDAngularThreshold:.005,bulletCCDLinearThreshold:.125,bulletCCDAngularThreshold:.0125,dynamicSweepLinearThreshold:17,dynamicSweepAngularThreshold:.6,angularCCDSlipScale:.75,arbiterExpirationDelay:6,staticFrictionThreshold:2,elasticThreshold:20,sleepDelay:60,linearSleepThreshold:.2,angularSleepThreshold:.4,contactBiasCoef:.3,contactStaticBiasCoef:.6,contactContinuousBiasCoef:.4,contactContinuousStaticBiasCoef:.5,constraintLinearSlop:.1,constraintAngularSlop:.001,illConditionedThreshold:2e8},Kt=E$1();Kt.Config=Object.assign(Kt.Config||{},Pt);function l(n,e,t){for(;n[e]!=null;){let r=n[e][t];n[e][t]=null,n[e]=r;}}var Xe=class{static version(){return "Nape 2.0.19"}static clearObjectPools(){let e=E$1(),t=e.__zpp;l(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),l(e.phys.InteractorIterator,"zpp_pool","zpp_next"),l(e.phys.BodyIterator,"zpp_pool","zpp_next"),l(e.phys.CompoundIterator,"zpp_pool","zpp_next"),l(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),l(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),l(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),l(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),l(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),l(e.geom.RayResultIterator,"zpp_pool","zpp_next"),l(e.shape.ShapeIterator,"zpp_pool","zpp_next"),l(e.shape.EdgeIterator,"zpp_pool","zpp_next"),l(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),l(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),l(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),l(t.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Body,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Component,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),l(t.util.ZNPNode_ConvexResult,"zpp_pool","next"),l(t.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),l(t.util.ZNPNode_RayResult,"zpp_pool","next"),l(t.phys.ZPP_Material,"zpp_pool","next"),l(t.phys.ZPP_FluidProperties,"zpp_pool","next"),l(t.callbacks.ZPP_CbSetPair,"zpp_pool","next"),l(t.callbacks.ZPP_Callback,"zpp_pool","next"),l(t.callbacks.ZPP_CbSet,"zpp_pool","next"),l(t.geom.ZPP_GeomVert,"zpp_pool","next"),l(t.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),l(t.geom.ZPP_Mat23,"zpp_pool","next"),l(t.geom.ZPP_CutVert,"zpp_pool","next"),l(t.geom.ZPP_CutInt,"zpp_pool","next"),l(t.geom.ZPP_Vec2,"zpp_pool","next"),l(t.geom.ZPP_PartitionVertex,"zpp_pool","next"),l(t.geom.ZPP_SimplifyV,"zpp_pool","next"),l(t.geom.ZPP_SimplifyP,"zpp_pool","next"),l(t.geom.ZPP_PartitionedPoly,"zpp_pool","next"),l(t.geom.ZPP_PartitionPair,"zpp_pool","next"),l(t.geom.ZPP_AABB,"zpp_pool","next"),l(t.geom.ZPP_SimpleVert,"zpp_pool","next"),l(t.geom.ZPP_SimpleSeg,"zpp_pool","next"),l(t.geom.ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.Hashable2_Boolfalse,"zpp_pool","next"),l(t.geom.ZPP_ToiEvent,"zpp_pool","next"),l(t.geom.ZPP_MarchSpan,"zpp_pool","next"),l(t.geom.ZPP_MarchPair,"zpp_pool","next"),l(t.shape.ZPP_Edge,"zpp_pool","next"),l(t.space.ZPP_SweepData,"zpp_pool","next"),l(t.space.ZPP_AABBNode,"zpp_pool","next"),l(t.space.ZPP_AABBPair,"zpp_pool","next"),l(t.dynamics.ZPP_Contact,"zpp_pool","next"),l(t.space.ZPP_Island,"zpp_pool","next"),l(t.space.ZPP_Component,"zpp_pool","next"),l(t.space.ZPP_CallbackSet,"zpp_pool","next"),l(t.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_ColArbiter,"zpp_pool","next"),l(t.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),l(t.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),l(t.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec2","zpp_pool"),l(t.util.ZPP_PubPool,"poolVec3","zpp_pool");}};var ze=class n{get _inner(){return this}constructor(e=1,t=0,r=0,i=1,p=0,s=0){let a=A.get();this.zpp_inner=a,a.outer=this;let c=["a","b","tx","c","d","ty"],f=[e,t,p,r,i,s];for(let u=0;u<f.length;u++)if(f[u]!==f[u])throw new Error("Error: Mat23::"+c[u]+" cannot be NaN");a.setas(e,t,r,i,p,s);}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let t=Math.cos(e),r=Math.sin(e);return new n(t,-r,r,t,0,0)}static translation(e,t){return new n(1,0,0,1,e,t)}static scale(e,t){return new n(e,0,0,t,0,0)}static _wrap(e){return e instanceof n?e:e?e instanceof A?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}_setProp(e,t){if(t!==t)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=t,this.zpp_inner.invalidate();}get a(){return this.zpp_inner.a}set a(e){this._setProp("a",e);}get b(){return this.zpp_inner.b}set b(e){this._setProp("b",e);}get c(){return this.zpp_inner.c}set c(e){this._setProp("c",e);}get d(){return this.zpp_inner.d}set d(e){this._setProp("d",e);}get tx(){return this.zpp_inner.tx}set tx(e){this._setProp("tx",e);}get ty(){return this.zpp_inner.ty}set ty(e){this._setProp("ty",e);}get determinant(){return this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c}clone(){return this.copy()}equals(e,t=0){if(e==null)return false;let r=this.zpp_inner,i=e.zpp_inner,p=r.a-i.a,s=r.b-i.b,a=r.c-i.c,c=r.d-i.d,f=r.tx-i.tx,u=r.ty-i.ty;return (p<0?-p:p)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(c<0?-c:c)<=t&&(f<0?-f:f)<=t&&(u<0?-u:u)<=t}copy(){return new n(this.zpp_inner.a,this.zpp_inner.b,this.zpp_inner.c,this.zpp_inner.d,this.zpp_inner.tx,this.zpp_inner.ty)}set(e){if(e==null)throw new Error("Error: Cannot set form null matrix");let t=e.zpp_inner;return this.zpp_inner.setas(t.a,t.b,t.c,t.d,t.tx,t.ty),this.zpp_inner.invalidate(),this}setAs(e=1,t=0,r=0,i=1,p=0,s=0){return this.zpp_inner.setas(e,t,r,i,p,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=e*e+t*t+r*r+i*i,s=e*i-t*r;s<0&&(s=-s);let a=E$1();return p>a.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner,a=1/(e*i-t*r);return new n(i*a,-t*a,-r*a,e*a,(t*s-i*p)*a,(r*p-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return new n(e,r,t,i,-e*p-r*s,-t*p-i*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let t=e.zpp_inner,r=this.zpp_inner;return new n(t.a*r.a+t.b*r.c,t.a*r.b+t.b*r.d,t.c*r.a+t.d*r.c,t.c*r.b+t.d*r.d,t.a*r.tx+t.b*r.ty+t.tx,t.c*r.tx+t.d*r.ty+t.ty)}transform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");e.zpp_inner.validate();let i=e.zpp_inner.x,p=e.zpp_inner.y,{a:s,b:a,c,d:f,tx:u,ty:m}=this.zpp_inner,y,g;t?(y=i*s+p*a,g=i*c+p*f):(y=i*s+p*a+u,g=i*c+p*f+m);let R=H.get(y,g,r);return e.zpp_inner.weak&&e.dispose(),R}inverseTransform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");if(this.singular())throw new Error("Error: Matrix is singular and inverse transformation cannot be performed");let{a:i,b:p,c:s,d:a,tx:c,ty:f}=this.zpp_inner,u=1/(i*a-p*s);e.zpp_inner.validate();let m=e.zpp_inner.x,y=e.zpp_inner.y,g,R;if(t)g=(m*a-y*p)*u,R=(y*i-m*s)*u;else {let _=m-c,h=y-f;g=(_*a-h*p)*u,R=(h*i-_*s)*u;}let H$1=H.get(g,R,r);return e.zpp_inner.weak&&e.dispose(),H$1}equiorthogonal(){if(this.singular())return false;let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=E$1(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-r*r-i*i;return a*a<p.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,p=E$1(),s=e*t+r*i;if(s*s>=p.Config.epsilon)return false;let a=e*e+t*t-1,c=r*r+i*i-1;return a*a<p.Config.epsilon&&c*c<p.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:i,d:p}=this.zpp_inner,s=E$1(),a=Math.sqrt(t*t+i*i),c=Math.sqrt(r*r+p*p);if(a*a<s.Config.epsilon||c*c<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let f=e?(a+c)/2:1;a=f/a,c=f/c,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*c,this.d=this.zpp_inner.d*c;let u=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,m=.25*Math.PI-.5*Math.acos(u/(f*f));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(m=-m);let y=Math.sin(m),g=Math.cos(m),R=this.zpp_inner.a*g-this.zpp_inner.c*y,H=this.zpp_inner.b*g+this.zpp_inner.d*y,_=this.zpp_inner.c*g+this.zpp_inner.a*y,h=this.zpp_inner.d*g-this.zpp_inner.b*y;return this.c=_,this.a=R,this.d=h,this.b=H,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(true)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(false)}toString(){let{a:e,b:t,c:r,d:i,tx:p,ty:s}=this.zpp_inner;return "{ a: "+e+" b: "+t+" c: "+r+" d: "+i+" tx: "+p+" ty: "+s+" }"}};A._wrapFn=n=>G(n,e=>{let t=Object.create(ze.prototype);return t.zpp_inner=e,e.outer=t,t});function et(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.x}function tt(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.y}function de(n){n.zpp_inner.weak&&n.dispose();}var J=class n{get _inner(){return this}constructor(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::direction cannot be null");let r=new B$1;this.zpp_inner=r;let i=et(e),p=tt(e);r.origin.zpp_inner.x=i,r.origin.zpp_inner.y=p,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),de(e);let s=et(t),a=tt(t);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=a,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),de(t),r.zip_dir=true,r.maxdist=1/0;}static _wrap(e){return e==null?null:e instanceof n?e:G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r})}static fromSegment(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::fromSegment::start is null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::fromSegment::end is null");let r=t.sub(e,true),i=new n(e,r),p=et(e),s=tt(e),a=et(t),c=tt(t),f=a-p,u=c-s,m=Math.sqrt(f*f+u*u);if(m!==m)throw new Error("Error: maxDistance cannot be NaN");return i.zpp_inner.maxdist=m,de(e),de(t),i}get origin(){return this.zpp_inner.origin}set origin(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");this.zpp_inner.origin.set(e),de(e);}get direction(){return this.zpp_inner.direction}set direction(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::direction cannot be null");this.zpp_inner.direction.set(e),this.zpp_inner.zip_dir=true,de(e);}get maxDistance(){return this.zpp_inner.maxdist}set maxDistance(e){if(e!==e)throw new Error("Error: maxDistance cannot be NaN");this.zpp_inner.maxdist=e;}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}aabb(){return K$1._wrap(this.zpp_inner.rayAABB())}at(e,t=false){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let i=r.x,p=r.y,s=i+e*this.zpp_inner.dirx,a=p+e*this.zpp_inner.diry;return H.get(s,a,t)}clone(){return this.copy()}copy(){let e=new n(this.zpp_inner.origin,this.zpp_inner.direction),t=this.zpp_inner.maxdist;if(t!==t)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=t,e}};var ye=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),H._wrap(this.zpp_inner.position)}get toi(){return this._disposed(),this.zpp_inner.toiDistance}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" toi: "+this.zpp_inner.toiDistance+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x._createConvexResult=()=>new ye;var be=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H._wrap(this.zpp_inner.normal)}get distance(){return this._disposed(),this.zpp_inner.toiDistance}get inner(){return this._disposed(),this.zpp_inner.inner}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" distance: "+this.zpp_inner.toiDistance+" ?inner: "+String(this.zpp_inner.inner)+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x._createRayResult=()=>new be;function oe(n){return n?.zpp_inner??n?._inner?.zpp_inner}function nt(n){return n?.zpp_inner??n?._inner?.zpp_inner}function rt(n,e){if(n!=null&&n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let t=n.zpp_inner;if(t._immutable)throw new Error("Error: Vec2 is immutable");t._isimmutable!=null&&t._isimmutable();}function ge(n,e){if(oe(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var Ze=class{static distanceBody(e,t,r,i){rt(r),rt(i);let p=nt(e),s=nt(t);if(p.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=p.shapes.head;for(;a!=null;)y.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)y.validateShape(a.elt),a=a.next;return C.distanceBody(p,s,r.zpp_inner,i.zpp_inner)}static distance(e,t,r,i){rt(r),rt(i),ge(e,"distances"),ge(t,"distances");let p=oe(e),s=oe(t);y.validateShape(p),y.validateShape(s);let a;l$1.zpp_pool==null?a=new l$1:(a=l$1.zpp_pool,l$1.zpp_pool=a.next,a.next=null),a.weak=false;let c=C.distance(p,s,r.zpp_inner,i.zpp_inner,a,1e100);return a.next=l$1.zpp_pool,l$1.zpp_pool=a,c}static intersectsBody(e,t){let r=nt(e),i=nt(t);if(r.shapes.head==null||i.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let p=r.shapes.head;for(;p!=null;)y.validateShape(p.elt),p=p.next;for(p=i.shapes.head;p!=null;)y.validateShape(p.elt),p=p.next;let s=r.aabb,a=i.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return false;let c=r.shapes.head;for(;c!=null;){let f=i.shapes.head;for(;f!=null;){if(w.testCollide_safe(c.elt,f.elt))return true;f=f.next;}c=c.next;}return false}static intersects(e,t){ge(e,"intersection"),ge(t,"intersection");let r=oe(e),i=oe(t);y.validateShape(r),y.validateShape(i);let p=r.aabb,s=i.aabb;return p.minx>s.maxx||p.maxx<s.minx||p.miny>s.maxy||p.maxy<s.miny?false:w.testCollide_safe(r,i)}static contains(e,t){ge(e,"containment"),ge(t,"containment");let r=oe(e),i=oe(t);return y.validateShape(r),y.validateShape(i),w.containTest(r,i)}};var Ve=class{static run(e,t,r,i=2,p=null,s=true,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(p!=null&&p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: MarchingSquares requires an iso function to operate");if(t==null)throw new Error("Error: MarchingSquares requires an AABB to define bounds of surface extraction");if(r==null)throw new Error("Error: MarchingSquares requires a Vec2 to define cell size for surface extraction");let c=r.zpp_inner;if(c._validate!=null&&c._validate(),c.x<=0||c.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(i<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(p!=null){let g=p.zpp_inner;if(g._validate!=null&&g._validate(),g.x<=0||g.y<=0)throw new Error("Error: MarchingSquares cannot with non-positive sub-grid dimensions")}let f=E$1(),u=a??new f.geom.GeomPolyList,m=z$1,y=t.zpp_inner;if(y._validate!=null&&y._validate(),p==null){let g=y.minx,R=y.miny,H=y.maxx,_=y.maxy;m.run(e,g,R,H,_,r,i,s,u);}else {let g=p.zpp_inner;g._validate!=null&&g._validate();let R=y.maxx-y.minx,H=y.maxy-y.miny,_=R/g.x,h=H/g.y,b=_|0,G=h|0;b!==_&&++b,G!==h&&++G;for(let Ye=0;Ye<b;Ye++){let Nt=y.minx+g.x*Ye,Ht=Ye===b-1?y.maxx:Nt+g.x;for(let je=0;je<G;je++){let It=y.miny+g.y*je,Jt=je===G-1?y.maxy:It+g.y;m.run(e,Nt,It,Ht,Jt,r,i,s,u);}}}return c.weak&&r.dispose(),p!=null&&p.zpp_inner.weak&&p.dispose(),u}};var X=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new c,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E$1(),i=new r.geom.Vec2List;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};X.internal=false;function pe(n){if(n.outer==null){let e=E$1();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l$1.zpp_pool,l$1.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function I(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!X.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}I.zpp_pool=null;I.get=function(n){let e;return I.zpp_pool==null?(X.internal=true,e=new I,X.internal=false):(e=I.zpp_pool,I.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};I.prototype.zpp_inner=null;I.prototype.zpp_i=null;I.prototype.zpp_critical=null;I.prototype.zpp_next=null;I.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=I.zpp_pool,I.zpp_pool=this,this.zpp_inner=null,false)};I.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function P(){this.zpp_inner=null,this.zpp_inner=new X,this.zpp_inner.outer=this;}P.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E$1(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};P.prototype.zpp_inner=null;Object.defineProperty(P.prototype,"length",{get:function(){return this.zpp_gl()}});P.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};P.prototype.zpp_vm=function(){this.zpp_inner.valmod();};P.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};P.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=n,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(n);else for(;this.zpp_inner.at_index!=n;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return pe(this.zpp_inner.at_ite.elt)};P.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(n.zpp_inner):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};P.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)):this.zpp_inner.inner.add(n.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};P.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.zpp_inner.inner.head.elt;let e=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}return this.zpp_inner.invalidate(),pe(n)};P.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}else {n=this.zpp_inner.inner.head.elt;let e=pe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),pe(n)};P.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};P.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};P.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};P.prototype.empty=function(){return this.zpp_gl()==0};P.prototype.iterator=function(){return this.zpp_vm(),I.get(this)};P.prototype.copy=function(n){n==null&&(n=false);let e=E$1(),t=new e.geom.Vec2List,r=I.get(this);for(;r.hasNext();){let i=r.next(),p;if(n){if(i!=null&&i.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=i.zpp_inner;s._validate!=null&&s._validate();let a=i.zpp_inner.x,c=i.zpp_inner;c._validate!=null&&c._validate();let f=i.zpp_inner.y,u;if(b.poolVec2==null?u=new e.geom.Vec2:(u=b.poolVec2,b.poolVec2=u.zpp_pool,u.zpp_pool=null,u.zpp_disp=false,u==b.nextVec2&&(b.nextVec2=null)),u.zpp_inner==null){let m;l$1.zpp_pool==null?m=new l$1:(m=l$1.zpp_pool,l$1.zpp_pool=m.next,m.next=null),m.weak=false,m._immutable=false,m.x=a,m.y=f,u.zpp_inner=m,u.zpp_inner.outer=u;}else u.zpp_inner.x=a,u.zpp_inner.y=f,u.zpp_inner._invalidate!=null&&u.zpp_inner._invalidate(u.zpp_inner);u.zpp_inner.weak=false,p=u;}else p=i;t.push(p);}return t};P.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");let e=n.iterator();for(;e.hasNext();){let t=e.next();this.has(t)||this.add(t);}};P.prototype.toString=function(){let n="[",e=true,t=I.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};P.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=I.zpp_pool,I.zpp_pool=e,e.zpp_inner=null;break}return this};P.prototype[Symbol.iterator]=function(){let n=I.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};P.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let t=this.at(e);try{n(t)?++e:this.remove(t);}catch{break}}return this};function se(){if(!M.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}se.prototype.zpp_inner=null;se.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=false,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=M.zpp_pool,M.zpp_pool=e;}return n};se.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr;if(n.wrap==null){let t=n.x,r=n.y;if(t!==t||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let i=E$1(),p;if(b.poolVec2==null?p=new i.geom.Vec2:(p=b.poolVec2,b.poolVec2=p.zpp_pool,p.zpp_pool=null,p.zpp_disp=false,p==b.nextVec2&&(b.nextVec2=null)),p.zpp_inner==null){let s;l$1.zpp_pool==null?s=new l$1:(s=l$1.zpp_pool,l$1.zpp_pool=s.next,s.next=null),s.weak=false,s._immutable=false,s.x=t,s.y=r,p.zpp_inner=s,p.zpp_inner.outer=p;}else {if(p.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=p.zpp_inner;if(s._immutable)throw new Error("Error: Vec2 is immutable");s._isimmutable!=null&&s._isimmutable(),s.x==t&&s.y==r||(s.x=t,s.y=r,s._invalidate!=null&&s._invalidate(s));}p.zpp_inner.weak=false,n.wrap=p,n.wrap.zpp_inner._inuse=true,n.wrap.zpp_inner._invalidate=s=>n.modwrap(s),n.wrap.zpp_inner._validate=()=>n.getwrap();}let e=n.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};se.prototype[Symbol.iterator]=function(){return {_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};var Qt=E$1();Qt.geom.GeomVertexIterator=se;var Y=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new u,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E$1(),i=new r.dynamics.ContactList;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};Y.internal=false;var we=class n{constructor(){if(!D.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof D?G(e,t=>{D.internal=true;let r=new n;return D.internal=false,r.zpp_inner=t,t.outer=r,r}):null:null}get polygon(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.outer_zn}get localNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_lnorm==null&&e.getlnorm(),e.wrap_lnorm}get worldNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_gnorm==null&&e.getgnorm(),e.wrap_gnorm}get length(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.length}get localProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.lprojection}get worldProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");if(e.polygon.body==null)throw new Error("Error: Edge world projection only makes sense for Polygons contained within a rigid body");return e.polygon.validate_gaxi(),e.gprojection}get localVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp0)}get localVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp1)}get worldVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp0)}get worldVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp1)}toString(){let e=this.zpp_inner;return e.polygon==null?"Edge(object-pooled)":e.polygon.body==null?(e.polygon.validate_laxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } }"):(e.polygon.validate_gaxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } worldNormal : { x: "+e.gnormx+" y: "+e.gnormy+" } }")}_wrapVert(e){let t=E$1();if(e.outer==null){e.outer=new t.geom.Vec2;let r=e.outer.zpp_inner;r.outer!=null&&(r.outer.zpp_inner=null,r.outer=null),r._isimmutable=null,r._validate=null,r._invalidate=null,r.next=l$1.zpp_pool,l$1.zpp_pool=r,e.outer.zpp_inner=e;}return e.outer}};D._wrapFn=n=>G(n,e=>{D.internal=true;let t=new we;return D.internal=false,t.zpp_inner=e,e.outer=t,t});var Ee=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return a.ValidationResult_VALID==null&&(a.internal=true,a.ValidationResult_VALID=new n,a.internal=false),a.ValidationResult_VALID}static get DEGENERATE(){return a.ValidationResult_DEGENERATE==null&&(a.internal=true,a.ValidationResult_DEGENERATE=new n,a.internal=false),a.ValidationResult_DEGENERATE}static get CONCAVE(){return a.ValidationResult_CONCAVE==null&&(a.internal=true,a.ValidationResult_CONCAVE=new n,a.internal=false),a.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return a.ValidationResult_SELF_INTERSECTING==null&&(a.internal=true,a.ValidationResult_SELF_INTERSECTING=new n,a.internal=false),a.ValidationResult_SELF_INTERSECTING}toString(){return this===a.ValidationResult_VALID?"VALID":this===a.ValidationResult_DEGENERATE?"DEGENERATE":this===a.ValidationResult_CONCAVE?"CONCAVE":this===a.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},Xt=E$1();Xt.shape.ValidationResult=Ee;var Pe=class n{get _inner(){return this}constructor(e=false){let t=new v$1;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(true),t.ignore=e);}static _wrap(e){return e instanceof n?e:e?e instanceof v$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}get group(){return this.zpp_inner.group==null?null:this.zpp_inner.group.outer}set group(e){if(e===this)throw new Error("Error: Cannot assign InteractionGroup to itself");this.zpp_inner.setGroup(e==null?null:e.zpp_inner);}get ignore(){return this.zpp_inner.ignore}set ignore(e){this.zpp_inner.ignore!=e&&(this.zpp_inner.invalidate(true),this.zpp_inner.ignore=e);}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=E$1();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,true);}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=E$1();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,true);}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};v$1._wrapFn=n=>G(n,e=>{let t=Object.create(Pe.prototype);return t.zpp_inner=e,e.outer=t,t});var xe=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return a.ArbiterType_COLLISION==null&&(a.internal=true,a.ArbiterType_COLLISION=new n,a.internal=false),a.ArbiterType_COLLISION}static get SENSOR(){return a.ArbiterType_SENSOR==null&&(a.internal=true,a.ArbiterType_SENSOR=new n,a.internal=false),a.ArbiterType_SENSOR}static get FLUID(){return a.ArbiterType_FLUID==null&&(a.internal=true,a.ArbiterType_FLUID=new n,a.internal=false),a.ArbiterType_FLUID}toString(){return this===a.ArbiterType_COLLISION?"COLLISION":this===a.ArbiterType_SENSOR?"SENSOR":this===a.ArbiterType_FLUID?"FLUID":""}},en=E$1();en.dynamics.ArbiterType=xe;F$1();var j=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!t.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return t.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==t.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==t.FLUID?this.zpp_inner.fluidarb.outer_zn:null}get shape1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer}get shape2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer}get body1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b2.outer:this.zpp_inner.b1.outer}get body2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b1.outer:this.zpp_inner.b2.outer}get state(){this._activeCheck();let e=E$1(),t=this.zpp_inner.immState;return t==5?(a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT):t==1?(a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT_ONCE):t==6?(a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE):(a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==t.COL}isFluidArbiter(){return this.zpp_inner.type==t.FLUID}isSensorArbiter(){return this.zpp_inner.type==t.SENSOR}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),I$1.get(0,0,0)}toString(){let e=this.zpp_inner.type==t.COL?"CollisionArbiter":this.zpp_inner.type==t.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let t$1=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer,r=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer,i=e+"("+t$1.toString()+"|"+r.toString()+")";return this.zpp_inner.type==t.COL&&(i+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),i+="<-"+this.state.toString(),i}_activeCheck(){if(!this.zpp_inner.active)throw new Error("Error: Arbiter not currently in use")}_checkBody(e){let t=this.zpp_inner,r=t.ws1.id>t.ws2.id?t.b2.outer:t.b1.outer,i=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=i)throw new Error("Error: Arbiter does not relate to body")}},tn=E$1();tn.dynamics.Arbiter=j;var Oe=class extends j{constructor(){super();}get contacts(){return this._activeCheck(),this.zpp_inner.colarb.wrap_contacts==null&&this.zpp_inner.colarb.setupcontacts(),this.zpp_inner.colarb.wrap_contacts}get normal(){return this._activeCheck(),this.zpp_inner.colarb.wrap_normal==null&&this.zpp_inner.colarb.getnormal(),this.zpp_inner.colarb.wrap_normal}get radius(){return this._activeCheck(),this.zpp_inner.colarb.radius}get referenceEdge1(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get referenceEdge2(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get elasticity(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.restitution}set elasticity(e){if(this._mutableCheck("elasticity"),e!==e)throw new Error("Error: CollisionArbiter::elasticity cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::elasticity cannot be negative");this.zpp_inner.colarb.restitution=e,this.zpp_inner.colarb.userdef_restitution=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get dynamicFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.dyn_fric}set dynamicFriction(e){if(this._mutableCheck("dynamicFriction"),e!==e)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be negative");this.zpp_inner.colarb.dyn_fric=e,this.zpp_inner.colarb.userdef_dyn_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get staticFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.stat_fric}set staticFriction(e){if(this._mutableCheck("staticFriction"),e!==e)throw new Error("Error: CollisionArbiter::staticFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::staticFriction cannot be negative");this.zpp_inner.colarb.stat_fric=e,this.zpp_inner.colarb.userdef_stat_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get rollingFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.rfric}set rollingFriction(e){if(this._mutableCheck("rollingFriction"),e!==e)throw new Error("Error: CollisionArbiter::rollingFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::rollingFriction cannot be negative");this.zpp_inner.colarb.rfric=e,this.zpp_inner.colarb.userdef_rfric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}firstVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==-1:false}secondVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==1:false}normalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return !t||r.oc1.fresh?r.oc1.wrapper().rollingImpulse(e):0}_mutableCheck(e){if(!this.zpp_inner.colarb.mutable)throw new Error("Error: CollisionArbiter::"+e+" is only mutable during a pre-handler")}_accumulateImpulse(e,t,r){let i=0,p=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let c=a.oc1.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}if(a.hc2&&(!r||a.oc2.fresh)){let c=a.oc2.wrapper()[e](t),f=c.zpp_inner;f._validate!=null&&f._validate(),i+=f.x,f._validate!=null&&f._validate(),p+=f.y,f._validate!=null&&f._validate(),s+=f.z,c.dispose();}return I$1.get(i,p,s)}};var Re=class extends j{constructor(){super();}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),H._wrap(this.zpp_inner.fluidarb.wrap_position)}set position(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e==null)throw new Error("Error: FluidArbiter::position cannot be null");this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),this.zpp_inner.fluidarb.wrap_position.set(e);}get overlap(){return this._activeCheck(),this.zpp_inner.fluidarb.overlap}set overlap(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e!==e)throw new Error("Error: FluidArbiter::overlap cannot be NaN");if(e<=0||e==1/0)throw new Error("Error: FluidArbiter::overlap must be strictly positive and non infinite");this.zpp_inner.fluidarb.overlap=e;}buoyancyImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb;return e==null?I$1.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?I$1.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):I$1.get(-t.buoyx,-t.buoyy,-(t.buoyy*t.r1x-t.buoyx*t.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return I$1.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),i=this.dragImpulse(e),p=r.zpp_inner,s=i.zpp_inner;return p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.x=s.x+p.x,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.y=s.y+p.y,p._validate!=null&&p._validate(),s._validate!=null&&s._validate(),s.z=s.z+p.z,r.dispose(),i}};var Ce=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!u.internal)throw new Error("Error: Cannot instantiate Contact derp!")}get arbiter(){if(this.zpp_inner.arbiter==null)return null;let e=this.zpp_inner.arbiter.outer;return e.zpp_inner.type==t.COL?e.zpp_inner.colarb.outer_zn:null}get penetration(){return this._inactiveCheck(),-this.zpp_inner.dist}get position(){return this._inactiveCheck(),this.zpp_inner.wrap_position==null&&this.zpp_inner.getposition(),H._wrap(this.zpp_inner.wrap_position)}get fresh(){return this._inactiveCheck(),this.zpp_inner.fresh}get friction(){return this._inactiveCheck(),this.zpp_inner.inner.friction}normalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc;return e==null?I$1.get(t.nx*i,t.ny*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.nx*-i,t.ny*-i,-(t.ny*r.r1x-t.nx*r.r1y)*i):I$1.get(t.nx*i,t.ny*i,(t.ny*r.r2x-t.nx*r.r2y)*i))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jtAcc;return e==null?I$1.get(-t.ny*i,t.nx*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.ny*i,-t.nx*i,-(r.r1x*t.nx+r.r1y*t.ny)*i):I$1.get(-t.ny*i,t.nx*i,(r.r2x*t.nx+r.r2y*t.ny)*i))}rollingImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=t.jrAcc;return e==null?r:(this._checkBody(e,t),e==t.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc,p=r.jtAcc,s=t.jrAcc;if(e==null)return I$1.get(t.nx*i-t.ny*p,t.ny*i+t.nx*p,s);this._checkBody(e,t);let a=t.nx*i-t.ny*p,c=t.ny*i+t.nx*p;return e==t.b1.outer?I$1.get(-a,-c,-(c*r.r1x-a*r.r1y)-s):I$1.get(a,c,c*r.r2x-a*r.r2y+s)}toString(){return this.zpp_inner.arbiter==null||this.zpp_inner.arbiter.cleared?"{object-pooled}":"{Contact}"}_inactiveCheck(){if(this.zpp_inner.inactiveme())throw new Error("Error: Contact not currently in use")}_checkBody(e,t){if(e!=t.b1.outer&&e!=t.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};u._wrapFn=n=>{u.internal=true;let e=new Ce;return u.internal=false,e.zpp_inner=n,n.outer=e,e};function nn(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function V(n){return n.valmod(),n.zip_length&&(n.zip_length=false,n.user_length=nn(n)),n.user_length}function v(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!Y.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}v.zpp_pool=null;v.get=function(n){let e;return v.zpp_pool==null?(Y.internal=true,e=new v,Y.internal=false):(e=v.zpp_pool,v.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};v.prototype.zpp_inner=null;v.prototype.zpp_i=null;v.prototype.zpp_critical=null;v.prototype.zpp_next=null;v.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=V(this.zpp_inner.zpp_inner);return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=v.zpp_pool,v.zpp_pool=this,this.zpp_inner=null,false)};v.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function T(){this.zpp_inner=null,this.zpp_inner=new Y,this.zpp_inner.outer=this;}T.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E$1(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};T.prototype.zpp_inner=null;Object.defineProperty(T.prototype,"length",{get:function(){return V(this.zpp_inner)}});T.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};T.prototype.at=function(n){this.zpp_inner.valmod();let e=V(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=V(this.zpp_inner)-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)for(this.zpp_inner.at_index=0,this.zpp_inner.at_ite=this.zpp_inner.inner.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}for(;this.zpp_inner.at_index!=n;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}return this.zpp_inner.at_ite.wrapper()};T.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(n.zpp_inner);else {if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};T.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=V(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}else this.zpp_inner.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};T.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}return this.zpp_inner.invalidate(),e.wrapper()};T.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),V(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=V(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}else {e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),e.wrapper()};T.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};T.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=false,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};T.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;V(this.zpp_inner)!=0;)this.pop();else for(;V(this.zpp_inner)!=0;)this.shift();};T.prototype.empty=function(){return V(this.zpp_inner)==0};T.prototype.iterator=function(){return this.zpp_inner.valmod(),v.get(this)};T.prototype.copy=function(n){n==null&&(n=false);let e=E$1(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=v.get(this);for(;r.hasNext();){let i=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(i);}return t};T.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=v.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t));}};T.prototype.toString=function(){let n="[",e=true;this.zpp_inner.valmod();let t=v.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};T.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=v.get(this);for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=v.zpp_pool,v.zpp_pool=e,e.zpp_inner=null;break}return this};T.prototype[Symbol.iterator]=function(){let n=v.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};T.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=V(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r);}catch{break}}return this};var E=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return a.CbEvent_BEGIN==null&&(a.internal=true,a.CbEvent_BEGIN=new n,a.internal=false),a.CbEvent_BEGIN}static get ONGOING(){return a.CbEvent_ONGOING==null&&(a.internal=true,a.CbEvent_ONGOING=new n,a.internal=false),a.CbEvent_ONGOING}static get END(){return a.CbEvent_END==null&&(a.internal=true,a.CbEvent_END=new n,a.internal=false),a.CbEvent_END}static get WAKE(){return a.CbEvent_WAKE==null&&(a.internal=true,a.CbEvent_WAKE=new n,a.internal=false),a.CbEvent_WAKE}static get SLEEP(){return a.CbEvent_SLEEP==null&&(a.internal=true,a.CbEvent_SLEEP=new n,a.internal=false),a.CbEvent_SLEEP}static get BREAK(){return a.CbEvent_BREAK==null&&(a.internal=true,a.CbEvent_BREAK=new n,a.internal=false),a.CbEvent_BREAK}static get PRE(){return a.CbEvent_PRE==null&&(a.internal=true,a.CbEvent_PRE=new n,a.internal=false),a.CbEvent_PRE}toString(){return this===a.CbEvent_BEGIN?"BEGIN":this===a.CbEvent_ONGOING?"ONGOING":this===a.CbEvent_END?"END":this===a.CbEvent_WAKE?"WAKE":this===a.CbEvent_SLEEP?"SLEEP":this===a.CbEvent_BREAK?"BREAK":this===a.CbEvent_PRE?"PRE":""}},rn=E$1();rn.callbacks.CbEvent=E;F$1();var q=class n{get _inner(){return this}constructor(){this.zpp_inner=new e,this.zpp_inner.outer=this;}static get ANY_BODY(){return e.ANY_BODY}static get ANY_CONSTRAINT(){return e.ANY_CONSTRAINT}static get ANY_SHAPE(){return e.ANY_SHAPE}static get ANY_COMPOUND(){return e.ANY_COMPOUND}get id(){return this.zpp_inner.id}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}get interactors(){return this.zpp_inner.wrap_interactors==null&&(this.zpp_inner.wrap_interactors=Z.get(this.zpp_inner.interactors,true)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=Y$1.get(this.zpp_inner.constraints,true)),this.zpp_inner.wrap_constraints}including(e){return new(E$1()).callbacks.OptionType(this).including(e)}excluding(e){return new(E$1()).callbacks.OptionType(this).excluding(e)}toString(){return this===e.ANY_BODY?"ANY_BODY":this===e.ANY_SHAPE?"ANY_SHAPE":this===e.ANY_COMPOUND?"ANY_COMPOUND":this===e.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e$1){return e$1 instanceof n?e$1:e$1?e$1 instanceof e?G(e$1,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e$1.zpp_inner?n._wrap(e$1.zpp_inner):null:null}},on=E$1();on.callbacks.CbType=q;F$1();var S=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return a.InteractionType_COLLISION==null&&(a.internal=true,a.InteractionType_COLLISION=new n,a.internal=false),a.InteractionType_COLLISION}static get SENSOR(){return a.InteractionType_SENSOR==null&&(a.internal=true,a.InteractionType_SENSOR=new n,a.internal=false),a.InteractionType_SENSOR}static get FLUID(){return a.InteractionType_FLUID==null&&(a.internal=true,a.InteractionType_FLUID=new n,a.internal=false),a.InteractionType_FLUID}static get ANY(){return a.InteractionType_ANY==null&&(a.internal=true,a.InteractionType_ANY=new n,a.internal=false),a.InteractionType_ANY}toString(){return this===a.InteractionType_COLLISION?"COLLISION":this===a.InteractionType_SENSOR?"SENSOR":this===a.InteractionType_FLUID?"FLUID":this===a.InteractionType_ANY?"ANY":""}},pn=E$1();pn.callbacks.InteractionType=S;var W=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new n,a.internal=false),a.PreFlag_ACCEPT}static get IGNORE(){return a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new n,a.internal=false),a.PreFlag_IGNORE}static get ACCEPT_ONCE(){return a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new n,a.internal=false),a.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new n,a.internal=false),a.PreFlag_IGNORE_ONCE}toString(){return this===a.PreFlag_ACCEPT?"ACCEPT":this===a.PreFlag_IGNORE?"IGNORE":this===a.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===a.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},sn=E$1();sn.callbacks.PreFlag=W;var ve=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new j$1,this.zpp_inner.outer=this,e!=null&&this.including(e),t!=null&&this.excluding(t);}get includes(){return this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes(),this.zpp_inner.wrap_includes}get excludes(){return this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes(),this.zpp_inner.wrap_excludes}including(e){return this.zpp_inner.append(this.zpp_inner.includes,e),this}excluding(e){return this.zpp_inner.append(this.zpp_inner.excludes,e),this}toString(){this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes();let e=this.zpp_inner.wrap_includes.toString();this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes();let t=this.zpp_inner.wrap_excludes.toString();return "@{"+e+" excluding "+t+"}"}static _wrap(e){return e instanceof n?e:e?e instanceof j$1?G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},an=E$1();an.callbacks.OptionType=ve;function ln(n){return n===E.BEGIN?0:n===E.END?1:n===E.WAKE?2:n===E.SLEEP?3:n===E.BREAK?4:n===E.PRE?5:n===E.ONGOING?6:-1}var B=class n{get _inner(){return this}constructor(){if(!f.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null;}static _wrap(e){return e instanceof n?e:e&&e instanceof f?G(e,t=>{if(t.outer)return t.outer;let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):null}get type(){return f.types[this.zpp_inner.type]}get event(){return f.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(f.events[this.zpp_inner.event]!=e){let t=ln(e);this.zpp_inner.swapEvent(t);}}get precedence(){return this.zpp_inner.precedence}set precedence(e){this.zpp_inner.precedence!=e&&(this.zpp_inner.precedence=e,this.zpp_inner.invalidate_precedence());}get space(){return this.zpp_inner.space==null?null:X$1._wrap(this.zpp_inner.space.outer)}set space(e){let t=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=t)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),t!=null){let i=t.zpp_inner.wrap_listeners;i.zpp_inner.reverse_flag?i.push(this):i.unshift(this);}else this.zpp_inner.space=null;}toString(){let t=["BEGIN","END","WAKE","SLEEP","BREAK","PRE","ONGOING"][this.zpp_inner.event];if(this.zpp_inner.type==0){let r=this.zpp_inner.body;return "BodyListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return "ConstraintListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else {let r=this.zpp_inner.interaction,i;switch(r.itype){case 1:i="COLLISION";break;case 2:i="SENSOR";break;case 4:i="FLUID";break;default:i="ALL";}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+i+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+i+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var Ne=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return a.ListenerType_BODY==null&&(a.internal=true,a.ListenerType_BODY=new n,a.internal=false),a.ListenerType_BODY}static get CONSTRAINT(){return a.ListenerType_CONSTRAINT==null&&(a.internal=true,a.ListenerType_CONSTRAINT=new n,a.internal=false),a.ListenerType_CONSTRAINT}static get INTERACTION(){return a.ListenerType_INTERACTION==null&&(a.internal=true,a.ListenerType_INTERACTION=new n,a.internal=false),a.ListenerType_INTERACTION}static get PRE(){return a.ListenerType_PRE==null&&(a.internal=true,a.ListenerType_PRE=new n,a.internal=false),a.ListenerType_PRE}toString(){return this===a.ListenerType_BODY?"BODY":this===a.ListenerType_CONSTRAINT?"CONSTRAINT":this===a.ListenerType_INTERACTION?"INTERACTION":this===a.ListenerType_PRE?"PRE":""}},_n=E$1();_n.callbacks.ListenerType=Ne;F$1();var F=class{constructor(){this.zpp_inner=null;if(!d.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return f.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return ""}};var ke=class extends F{get body(){return this.zpp_inner.body.outer}toString(){return "Cb:"+["WAKE","SLEEP"][this.zpp_inner.event-2]+":"+this.zpp_inner.body.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Be=class extends F{get constraint(){return this.zpp_inner.constraint.outer}toString(){return "Cb:"+["WAKE","SLEEP","BREAK"][this.zpp_inner.event-2]+":"+this.zpp_inner.constraint.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Fe=class extends F{get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get arbiters(){return this.zpp_inner.wrap_arbiters}toString(){return "Cb:"+["BEGIN","END","","","","","ONGOING"][this.zpp_inner.event]+":"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.wrap_arbiters.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Ge=class extends F{get arbiter(){return this.zpp_inner.pre_arbiter.wrapper()}get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get swapped(){return this.zpp_inner.pre_swapped}toString(){return "Cb:PRE::"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.pre_arbiter.wrapper().toString()+" : listnener: "+String(this.zpp_inner.listener.outer)}};var De=class extends B{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: BodyListener::handler cannot be null");let p;if(e===E.WAKE)p=2;else if(e===E.SLEEP)p=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new g(j$1.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: BodyListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};var Me=class extends B{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let p;if(e===E.WAKE)p=2;else if(e===E.SLEEP)p=3;else if(e===E.BREAK)p=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new h(j$1.argument(t),p,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: ConstraintListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};function Ue(n){return n===S.COLLISION?1:n===S.SENSOR?2:n===S.FLUID?4:7}function ae(n){return n==1?S.COLLISION:n==2?S.SENSOR:n==4?S.FLUID:n==7?S.ANY:null}var le=class extends B{constructor(e,t,r,i$1,p,s=0){if(f.internal=true,super(),f.internal=false,p==null)throw new Error("Error: InteractionListener::handler cannot be null");if(e==null)throw new Error("Error: CbEvent cannot be null for InteractionListener");let a;if(e===E.BEGIN)a=0;else if(e===E.END)a=1;else if(e===E.ONGOING)a=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new i(j$1.argument(r),j$1.argument(i$1),a,2),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zni=this,this.zpp_inner.precedence=s,this.zpp_inner_zn.handleri=p,t==null)throw new Error("Error: Cannot set listener interaction type to null");ae(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=Ue(t));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handleri}set handler(e){if(e==null)throw new Error("Error: InteractionListener::handler cannot be null");this.zpp_inner_zn.handleri=e;}get interactionType(){return ae(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ae(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ue(e));}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e;}};var _e=class extends B{constructor(e,t,r,i$1,p=0,s=false){if(f.internal=true,super(),f.internal=false,i$1==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new i(j$1.argument(t),j$1.argument(r),5,3),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_znp=this,this.zpp_inner.precedence=p,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=i$1,e==null)throw new Error("Error: Cannot set listener interaction type to null");ae(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ue(e));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handlerp}set handler(e){if(e==null)throw new Error("Error: PreListener must take a non-null handler!");this.zpp_inner_zn.handlerp=e,this.zpp_inner_zn.wake();}get pure(){return this.zpp_inner_zn.pure}set pure(e){e||this.zpp_inner_zn.wake(),this.zpp_inner_zn.pure=e;}get interactionType(){return ae(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ae(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=Ue(e));}};var We=class n extends ka{constructor(e,t=false){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r$1=new r(e,t);this.zpp_inner=r$1,r$1.outer=this,r$1.outer_zn=this;}static _wrap(e){return e==null?null:e instanceof n?e:e.zpp_inner?.outer instanceof n?e.zpp_inner.outer:G(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new H;return e.zpp_inner._inuse=true,e.zpp_inner._invalidate=this.zpp_inner.bindVec2_invalidate.bind(this.zpp_inner),e}__copy(){throw new Error("Error: UserConstraint::__copy must be overriden")}__broken(){}__validate(){}__draw(e){}__prepare(){}__position(e){throw new Error("Error: UserConstraint::__position must be overriden")}__velocity(e){throw new Error("Error: Userconstraint::__velocity must be overriden")}__eff_mass(e){throw new Error("Error: UserConstraint::__eff_mass must be overriden")}__clamp(e){}__impulse(e,t,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,t=new J$1(e,1);for(let r=0;r<e;r++){if(r<0||r>=t.zpp_inner.m||0>=t.zpp_inner.n)throw new Error("Error: MatMN indices out of range");t.zpp_inner.x[r*t.zpp_inner.n]=this.zpp_inner.jAcc[r];}return t}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let t=false;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=true;break}if(!t)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):I$1.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let i=this.zpp_inner.bodies[r];if(i.body!=null){let p=false;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==i.body){p=true;break}p||e(i.body.outer);}++r;}}__invalidate(){this.zpp_inner.immutable_midstep("UserConstraint::invalidate()"),this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&this.zpp_inner.wake();}__registerBody(e,t){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=t){if(e!=null){if(!this.zpp_inner.remBody(e.zpp_inner))throw new Error("Error: oldBody is not registered to the cosntraint");this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&e.zpp_inner.wake();}t!=null&&this.zpp_inner.addBody(t.zpp_inner),this.zpp_inner.wake(),t?.zpp_inner.wake();}return t}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e;}};function O(n){let{typeName:e,namespaceParts:t,zppListClass:r,wrapElement:i,unwrapElement:p}=n,s=E$1(),a=s.__zpp,c=()=>a.util[r],f=()=>{let _=s;for(let h=1;h<t.length;h++)_=_[t[h]];return _};function u(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!c().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}u.zpp_pool=null,u.get=function(_){let h,b=c();return u.zpp_pool==null?(b.internal=true,h=new u,b.internal=false):(h=u.zpp_pool,u.zpp_pool=h.zpp_next),h.zpp_i=0,h.zpp_inner=_,h.zpp_critical=false,h},u.prototype.zpp_inner=null,u.prototype.zpp_i=null,u.prototype.zpp_critical=null,u.prototype.zpp_next=null,u.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let _=this.zpp_inner;_.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length);let h=_.zpp_inner.user_length;return this.zpp_critical=true,this.zpp_i<h?true:(this.zpp_next=u.zpp_pool,u.zpp_pool=this,this.zpp_inner=null,false)},u.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function m(){this.zpp_inner=null,this.zpp_inner=new(c()),this.zpp_inner.outer=this;}m.fromArray=function(_){if(_==null)throw new Error("Error: Cannot convert null Array to Nape list");let h=new m;for(let b=0;b<_.length;b++)h.push(_[b]);return h},m.prototype.zpp_inner=null,m.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function y(_){return _.zpp_inner.valmod(),_.zpp_inner.zip_length&&(_.zpp_inner.zip_length=false,_.zpp_inner.user_length=_.zpp_inner.inner.length),_.zpp_inner.user_length}Object.defineProperty(m.prototype,"length",{get:function(){return y(this)}}),m.prototype.has=function(_){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(p(_))},m.prototype.at=function(_){if(this.zpp_inner.valmod(),_<0||_>=y(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(_=y(this)-1-_),_<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=_,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(_);else for(;this.zpp_inner.at_index!=_;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return i(this.zpp_inner.at_ite.elt)},m.prototype.push=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(p(_)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.unshift=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=this.zpp_inner.adder!=null?this.zpp_inner.adder(_):true;return h&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(y(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,p(_))):this.zpp_inner.inner.add(p(_)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(_)),h},m.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}return this.zpp_inner.invalidate(),i(_)},m.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let _;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let h;y(this)==1?h=null:h=this.zpp_inner.inner.iterator_at(y(this)-2),_=h==null?this.zpp_inner.inner.head.elt:h.next.elt;let b=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(b),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(h);}else {_=this.zpp_inner.inner.head.elt;let h=i(_);this.zpp_inner.subber!=null&&this.zpp_inner.subber(h),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),i(_)},m.prototype.add=function(_){return this.zpp_inner.reverse_flag?this.push(_):this.unshift(_)},m.prototype.remove=function(_){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let h=false,b=this.zpp_inner.inner.head,G=p(_);for(;b!=null;){if(b.elt==G){h=true;break}b=b.next;}return h&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(_),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(G),this.zpp_inner.invalidate()),h},m.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift();},m.prototype.empty=function(){return this.zpp_inner.inner.head==null},m.prototype.iterator=function(){return this.zpp_inner.valmod(),u.get(this)},m.prototype.copy=function(_){_==null&&(_=false);let h=new m,b=u.get(this);for(;b.hasNext();){let G=b.next();if(_)throw new Error("Error: "+e+" is not a copyable type");h.push(G);}return h},m.prototype.merge=function(_){if(_==null)throw new Error("Error: Cannot merge with null list");let h=u.get(_);for(;h.hasNext();){let b=h.next();this.has(b)||(this.zpp_inner.reverse_flag?this.push(b):this.unshift(b));}},m.prototype.toString=function(){let _="[",h=true,b=u.get(this);for(;b.hasNext();){let G=b.next();h||(_+=","),_+=G==null?"NULL":G.toString(),h=false;}return _+"]"},m.prototype.foreach=function(_){if(_==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let h=u.get(this);for(;h.hasNext();)try{_(h.next());}catch{h.zpp_next=u.zpp_pool,u.zpp_pool=h,h.zpp_inner=null;break}return this},m.prototype.filter=function(_){if(_==null)throw new Error("Error: Cannot select elements of list with null");let h=0;for(;h<y(this);){let b=this.at(h);try{_(b)?++h:this.remove(b);}catch{break}}return this},m.prototype.toArray=function(){let _=[],h=u.get(this);for(;h.hasNext();)_.push(h.next());return _},m.prototype[Symbol.iterator]=function(){let _=u.get(this);return {next(){return _.hasNext()?{value:_.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};let g=f(),R=e+"Iterator",H=e+"List";return g[R]=u,g[H]=m,{Iterator:u,List:m}}var ee=n=>n.outer,K=n=>n.zpp_inner??(n._inner?n._inner.zpp_inner??n._inner:n);O({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:ee,unwrapElement:K});O({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:ee,unwrapElement:K});O({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:ee,unwrapElement:K});O({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:ee,unwrapElement:K});O({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:ee,unwrapElement:K});O({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:ee,unwrapElement:K});O({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:ee,unwrapElement:K});O({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:ee,unwrapElement:K});O({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:K});O({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:n=>n,unwrapElement:n=>n});O({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:n=>n.outer_i,unwrapElement:n=>n.zpp_inner_i});function ue(n){if(n.outer==null){let e=E$1();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l$1.zpp_pool,l$1.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function L(){this.at_index=0,this.at_ite=null,this.zip_length=false,this._length=0,this.inner=null,P.call(this),this.at_ite=null,this.at_index=0,this.zip_length=true,this._length=0;}for(let n in P.prototype)L.prototype[n]=P.prototype[n];Object.defineProperty(L.prototype,"length",{get:function(){return this.zpp_gl()},configurable:true});L.prototype.inner=null;L.prototype._length=0;L.prototype.zip_length=false;L.prototype.at_ite=null;L.prototype.at_index=0;L.get=function(n,e){e==null&&(e=false);let t=new L;return t.inner=n,t.zpp_inner.immutable=e,t};L.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let n=this.inner.next;for(;n!=null;)this._length++,n=n.next;this.zip_length=false;}return this._length};L.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=true,this._length=0,this.at_ite=null);};L.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),(n<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==n;)this.at_index++,this.at_ite=this.at_ite.next;return ue(this.at_ite)};L.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(n.zpp_inner);else {let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}else this.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};L.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.inner.next;let e=ue(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}else {this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=ue(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}return this.zpp_inner.invalidate(),ue(n)};L.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=ue(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}else {n=this.inner.next;let e=ue(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}return this.zpp_inner.invalidate(),ue(n)};L.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};L.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};var un=E$1(),hn=un.__zpp;hn.util.ZPP_MixVec2List=L;var z=E$1();z.Config=Object.assign(z.Config||{},Pt);z.util.Debug=Xe;z.geom.Vec2=H;z.geom.Vec3=I$1;z.geom.Mat23=ze;z.geom.MatMN=J$1;z.geom.AABB=K$1;z.geom.Winding=L$1;z.geom.Ray=J;z.geom.ConvexResult=ye;z.geom.RayResult=be;z.geom.Geom=Ze;z.geom.GeomPoly=N;z.geom.MarchingSquares=Ve;z.geom.Vec2Iterator=I;z.geom.Vec2List=P;z.geom.GeomVertexIterator=se;z.__zpp.geom.ZPP_GeomVertexIterator=M;z.__zpp.util.ZPP_ContactList=Y;z.phys.Interactor=R;z.phys.Body=_;O$1(n=>_._wrap(n));z.phys.BodyType=$;z.phys.Compound=aa;Q(n=>aa._wrap(n));z.phys.FluidProperties=T$1;z.phys.Material=ba;z.phys.GravMassMode=ca;z.phys.InertiaMode=da;z.phys.MassMode=ea;z.shape.Shape=V$1;P$1(n=>V$1._wrap(n));z.shape.Circle=fa;z.shape.Polygon=ha;z.shape.Capsule=ia;z.shape.Edge=we;z.shape.ShapeType=U;z.shape.ValidationResult=Ee;z.space.Space=X$1;z.space.Broadphase=ja;z.dynamics.InteractionFilter=ga;z.dynamics.InteractionGroup=Pe;z.dynamics.ArbiterType=xe;z.dynamics.Arbiter=j;t._createColArb=()=>new Oe;t._createFluidArb=()=>new Re;z.dynamics.Contact=Ce;z.dynamics.ContactIterator=v;z.dynamics.ContactList=T;z.callbacks.CbEvent=E;z.callbacks.CbType=q;z.callbacks.InteractionType=S;z.callbacks.PreFlag=W;z.callbacks.OptionType=ve;z.callbacks.Listener=B;z.callbacks.ListenerType=Ne;z.callbacks.Callback=F;d._createBodyCb=()=>new ke;d._createConCb=()=>new Be;d._createIntCb=()=>new Fe;d._createPreCb=()=>new Ge;z.callbacks.BodyListener=De;z.callbacks.ConstraintListener=Me;z.callbacks.InteractionListener=le;z.callbacks.PreListener=_e;z.constraint.Constraint=ka;k._createFn=(...n)=>new la(...n);m._createFn=(...n)=>new ma(...n);n._createFn=(...n)=>new na(...n);o._createFn=(...n)=>new oa(...n);p._createFn=(...n)=>new pa(...n);q$1._createFn=(...n)=>new qa(...n);s._createFn=(...n)=>new ra(...n);z.constraint.UserConstraint=We;var xt=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,i){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,i){}drawSolidCapsule(e,t,r,i){}drawPoint(e,t){}};function cn(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof N){if(n.zpp_disp)throw new Error("Error: GeomPoly has been disposed and cannot be used!");t=n.copy();}else {if(!Array.isArray(n))throw new Error("Error: vertices must be an Array<Vec2> or GeomPoly");if(n.length<3)throw new Error("Error: At least 3 vertices are required, got "+n.length);for(let f=0;f<n.length;f++)if(n[f]==null)throw new Error("Error: vertices["+f+"] is null");t=new N(n);}if(t.size()<3)throw t.dispose(),new Error("Error: At least 3 vertices are required, got "+t.size());if(t.isDegenerate())throw t.dispose(),new Error("Error: Polygon is degenerate (zero area)");if(!t.isSimple())throw t.dispose(),new Error("Error: Polygon is self-intersecting");let r=e?.simplify??0;if(r>0){let f=t.simplify(r);if(t.dispose(),t=f,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let f=[],u=t.forwardIterator();for(;u.hasNext();){let m=u.next();f.push(H.get(m.x,m.y));}t.dispose(),f.reverse(),t=new N(f);}let i=e?.material,p=e?.filter,s=e?.delaunay??false,a=new _(e?.type??$.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new ha(t,i,p)),t.dispose(),a;let c=t.convexDecomposition(s);for(let f of c)a.shapes.add(new ha(f,i,p));return t.dispose(),a}var Ct=class{constructor(e,t,r={}){this._oneWayListener=null;this._grounded=false;this._groundNormal=null;this._groundBody=null;this._onMovingPlatform=false;this._slopeAngle=0;this._wallLeft=false;this._wallRight=false;this._timeSinceGrounded=0;this.space=e,this.body=t,this._maxSlopeAngle=r.maxSlopeAngle??Math.PI/4,this._maxSlopeCos=Math.cos(this._maxSlopeAngle);let i=256;if(r.filter)this._filter=r.filter;else {let p=t.shapes;for(let s=0;s<p.length;s++){let c=p.at(s).filter;c.collisionGroup=c.collisionGroup|i;}this._filter=new ga(1,~i);}r.oneWayPlatformTag&&r.characterTag&&this._setupOneWayPlatforms(r.oneWayPlatformTag,r.characterTag);}get grounded(){return this._grounded}get groundNormal(){return this._groundNormal}get groundBody(){return this._groundBody}get timeSinceGrounded(){return this._timeSinceGrounded}get maxSlopeAngle(){return this._maxSlopeAngle}set maxSlopeAngle(e){this._maxSlopeAngle=e,this._maxSlopeCos=Math.cos(e);}setVelocity(e,t){this.body.velocity=new H(e,t);}update(){this._wallLeft=false,this._wallRight=false;let e=this.body.position.x,t=this.body.position.y;return this._detectGround(e,t),this._detectWalls(e,t),this._grounded&&this._groundBody?this._onMovingPlatform=this._groundBody.type===$.KINEMATIC:this._onMovingPlatform=false,this._grounded?this._timeSinceGrounded=0:this._timeSinceGrounded+=1/60,{grounded:this._grounded,groundNormal:this._groundNormal,groundBody:this._groundBody,onMovingPlatform:this._onMovingPlatform,slopeAngle:this._slopeAngle,wallLeft:this._wallLeft,wallRight:this._wallRight,timeSinceGrounded:this._timeSinceGrounded}}destroy(){this._oneWayListener&&(this._oneWayListener.space=null,this._oneWayListener=null);}_detectGround(e,t){let i=this._getCharacterRadius(0,1)+4,p=new J(new H(e,t),new H(0,1));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);if(s&&s.distance<=i){let a=s.normal.y;if(a<0){let c=-a;if(c>=this._maxSlopeCos){this._grounded=true,this._groundNormal=new H(s.normal.x,s.normal.y),this._groundBody=s.shape?.body??null,this._slopeAngle=Math.acos(Math.min(1,c));return}}}this._grounded=false,this._groundNormal=null,this._groundBody=null,this._slopeAngle=0;}_detectWalls(e,t){let i=this._getCharacterRadius(1,0)+2,p=new J(new H(e,t),new H(-1,0));p.maxDistance=i;let s=this.space.rayCast(p,false,this._filter);s&&s.distance<=i&&Math.abs(s.normal.x)>.7&&(this._wallLeft=true);let a=new J(new H(e,t),new H(1,0));a.maxDistance=i;let c=this.space.rayCast(a,false,this._filter);c&&c.distance<=i&&Math.abs(c.normal.x)>.7&&(this._wallRight=true);}_setupOneWayPlatforms(e,t){let r=new _e(S.COLLISION,e,t,i=>{try{let p=i.arbiter.collisionArbiter;if(!p)return W.ACCEPT;let s=p.normal.y,a=i.swapped;return s>0!==a?W.IGNORE:W.ACCEPT}catch{return W.ACCEPT}},0,true);r.space=this.space,this._oneWayListener=r;}_getCharacterRadius(e,t){let r=this.body.shapes.at(0);if(!r)return 0;if(r.isCircle())return r.castCircle?.radius??0;if(r.isCapsule()){let a=r.castCapsule;if(a){let c=a.radius,f=a.halfLength,u=this.body.rotation,m=Math.cos(u),y=Math.sin(u);return Math.abs(e*m+t*y)*f+c}}let i=r.bounds,p=i.width/2,s=i.height/2;return Math.abs(e)*p+Math.abs(t)*s}};var vt=class{constructor(e,t,r){this._enabled=true;this._enterListener=null;this._stayListener=null;this._exitListener=null;this._space=e,this._body=t,this._filter=r?.filter??null,this._interactionType=r?.interactionType??S.SENSOR;for(let i=0;i<t.shapes.length;i++){let p=t.shapes.at(i);p.sensorEnabled||(p.sensorEnabled=true);}this.cbType=new q,t.cbTypes.add(this.cbType),this._onEnter=r?.onEnter??null,this._onStay=r?.onStay??null,this._onExit=r?.onExit??null,this._syncListeners();}get onEnter(){return this._onEnter}set onEnter(e){this._onEnter=e,this._syncListeners();}get onStay(){return this._onStay}set onStay(e){this._onStay=e,this._syncListeners();}get onExit(){return this._onExit}set onExit(e){this._onExit=e,this._syncListeners();}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._syncListeners());}get body(){return this._body}get space(){return this._space}dispose(){this._removeListener("enter"),this._removeListener("stay"),this._removeListener("exit"),this._body.cbTypes.remove(this.cbType),this._enabled=false;}_resolveOther(e){let t=e.int1,r=e.int2;return t===this._body?r:r===this._body?t:t.id===this._body.id?r:t}_syncListeners(){this._enabled&&this._onEnter?this._enterListener||(this._enterListener=this._createListener(E.BEGIN,e=>{this._onEnter?.(this._resolveOther(e));})):this._removeListener("enter"),this._enabled&&this._onStay?this._stayListener||(this._stayListener=this._createListener(E.ONGOING,e=>{this._onStay?.(this._resolveOther(e));})):this._removeListener("stay"),this._enabled&&this._onExit?this._exitListener||(this._exitListener=this._createListener(E.END,e=>{this._onExit?.(this._resolveOther(e));})):this._removeListener("exit");}_createListener(e,t){let r=this._filter??q.ANY_BODY,i=new le(e,this._interactionType,this.cbType,r,t);return this._space.listeners.add(i),i}_removeListener(e){let t=e==="enter"?"_enterListener":e==="stay"?"_stayListener":"_exitListener",r=this[t];r&&(r.space=null,this[t]=null);}};var ps="3.22.0";export{j as Arbiter,xe as ArbiterType,ke as BodyCallback,De as BodyListener,F as Callback,E as CbEvent,q as CbType,Ct as CharacterController,Oe as CollisionArbiter,Be as ConstraintCallback,Me as ConstraintListener,Ce as Contact,ye as ConvexResult,xt as DebugDraw,we as Edge,Re as FluidArbiter,Ze as Geom,Fe as InteractionCallback,Pe as InteractionGroup,le as InteractionListener,S as InteractionType,B as Listener,Ne as ListenerType,Ve as MarchingSquares,ze as Mat23,ve as OptionType,Ge as PreCallback,W as PreFlag,_e as PreListener,J as Ray,be as RayResult,vt as TriggerZone,We as UserConstraint,ps as VERSION,Ee as ValidationResult,cn as createConcaveBody};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {E,A,G as G$1,x as x$1,b,l,D as D$1,v as v$1,F as F$1,u,H as H$1,I as I$1,J as J$1,K as K$1,L,N,M,R,_,O,$,aa,Q as Q$1,T as T$1,ba,ca,da,ea,V as V$1,P as P$1,fa,ha,ia,U,X,ja,ga,t,d,ka,la,k,ma,m,na,n,oa,o,pa,p,qa,q as q$1,ra,s,a,e,Z,Y,j,B as B$1,y as y$1,C,w,z,f,g,h as h$1,i,r,c}from'./chunk-XFL4PQ5L.js';export{K as AABB,la as AngleJoint,_ as Body,$ as BodyType,ja as Broadphase,ia as Capsule,fa as Circle,aa as Compound,ka as Constraint,W as DebugDrawFlags,ma as DistanceJoint,T as FluidProperties,N as GeomPoly,ca as GravMassMode,da as InertiaMode,ga as InteractionFilter,R as Interactor,na as LineJoint,ea as MassMode,J as MatMN,ba as Material,oa as MotorJoint,S as NapeList,pa as PivotJoint,ha as Polygon,qa as PulleyJoint,V as Shape,U as ShapeType,X as Space,H as Vec2,I as Vec3,ra as WeldJoint,L as Winding}from'./chunk-XFL4PQ5L.js';var Ot={epsilon:1e-8,fluidAngularDragFriction:2.5,fluidAngularDrag:100,fluidVacuumDrag:.5,fluidLinearDrag:.5,collisionSlop:.2,collisionSlopCCD:.5,distanceThresholdCCD:.05,staticCCDLinearThreshold:.05,staticCCDAngularThreshold:.005,bulletCCDLinearThreshold:.125,bulletCCDAngularThreshold:.0125,dynamicSweepLinearThreshold:17,dynamicSweepAngularThreshold:.6,angularCCDSlipScale:.75,arbiterExpirationDelay:6,staticFrictionThreshold:2,elasticThreshold:20,sleepDelay:60,linearSleepThreshold:.2,angularSleepThreshold:.4,contactBiasCoef:.3,contactStaticBiasCoef:.6,contactContinuousBiasCoef:.4,contactContinuousStaticBiasCoef:.5,constraintLinearSlop:.1,constraintAngularSlop:.001,illConditionedThreshold:2e8},pn=E();pn.Config=Object.assign(pn.Config||{},Ot);function h(n,e,t){for(;n[e]!=null;){let r=n[e][t];n[e][t]=null,n[e]=r;}}var _t=class{static version(){return "Nape 2.0.19"}static clearObjectPools(){let e=E(),t=e.__zpp;h(e.constraint.ConstraintIterator,"zpp_pool","zpp_next"),h(e.phys.InteractorIterator,"zpp_pool","zpp_next"),h(e.phys.BodyIterator,"zpp_pool","zpp_next"),h(e.phys.CompoundIterator,"zpp_pool","zpp_next"),h(e.callbacks.ListenerIterator,"zpp_pool","zpp_next"),h(e.callbacks.CbTypeIterator,"zpp_pool","zpp_next"),h(e.geom.ConvexResultIterator,"zpp_pool","zpp_next"),h(e.geom.GeomPolyIterator,"zpp_pool","zpp_next"),h(e.geom.Vec2Iterator,"zpp_pool","zpp_next"),h(e.geom.RayResultIterator,"zpp_pool","zpp_next"),h(e.shape.ShapeIterator,"zpp_pool","zpp_next"),h(e.shape.EdgeIterator,"zpp_pool","zpp_next"),h(e.dynamics.ContactIterator,"zpp_pool","zpp_next"),h(e.dynamics.ArbiterIterator,"zpp_pool","zpp_next"),h(e.dynamics.InteractionGroupIterator,"zpp_pool","zpp_next"),h(t.util.ZNPNode_ZPP_CbType,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_CallbackSet,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Shape,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Body,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Constraint,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Compound,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Arbiter,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_InteractionListener,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_CbSet,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Interactor,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_BodyListener,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_CbSetPair,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_ConstraintListener,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_CutInt,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_CutVert,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_PartitionVertex,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_SimplifyP,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_PartitionedPoly,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_GeomVert,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_SimpleVert,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_SimpleEvent,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Vec2,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_AABBPair,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Edge,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_AABBNode,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Component,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_FluidArbiter,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_SensorArbiter,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_Listener,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_ColArbiter,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_InteractionGroup,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_ToiEvent,"zpp_pool","next"),h(t.util.ZNPNode_ConvexResult,"zpp_pool","next"),h(t.util.ZNPNode_ZPP_GeomPoly,"zpp_pool","next"),h(t.util.ZNPNode_RayResult,"zpp_pool","next"),h(t.phys.ZPP_Material,"zpp_pool","next"),h(t.phys.ZPP_FluidProperties,"zpp_pool","next"),h(t.callbacks.ZPP_CbSetPair,"zpp_pool","next"),h(t.callbacks.ZPP_Callback,"zpp_pool","next"),h(t.callbacks.ZPP_CbSet,"zpp_pool","next"),h(t.geom.ZPP_GeomVert,"zpp_pool","next"),h(t.geom.ZPP_GeomVertexIterator,"zpp_pool","next"),h(t.geom.ZPP_Mat23,"zpp_pool","next"),h(t.geom.ZPP_CutVert,"zpp_pool","next"),h(t.geom.ZPP_CutInt,"zpp_pool","next"),h(t.geom.ZPP_Vec2,"zpp_pool","next"),h(t.geom.ZPP_PartitionVertex,"zpp_pool","next"),h(t.geom.ZPP_SimplifyV,"zpp_pool","next"),h(t.geom.ZPP_SimplifyP,"zpp_pool","next"),h(t.geom.ZPP_PartitionedPoly,"zpp_pool","next"),h(t.geom.ZPP_PartitionPair,"zpp_pool","next"),h(t.geom.ZPP_AABB,"zpp_pool","next"),h(t.geom.ZPP_SimpleVert,"zpp_pool","next"),h(t.geom.ZPP_SimpleSeg,"zpp_pool","next"),h(t.geom.ZPP_SimpleEvent,"zpp_pool","next"),h(t.util.Hashable2_Boolfalse,"zpp_pool","next"),h(t.geom.ZPP_ToiEvent,"zpp_pool","next"),h(t.geom.ZPP_MarchSpan,"zpp_pool","next"),h(t.geom.ZPP_MarchPair,"zpp_pool","next"),h(t.shape.ZPP_Edge,"zpp_pool","next"),h(t.space.ZPP_SweepData,"zpp_pool","next"),h(t.space.ZPP_AABBNode,"zpp_pool","next"),h(t.space.ZPP_AABBPair,"zpp_pool","next"),h(t.dynamics.ZPP_Contact,"zpp_pool","next"),h(t.space.ZPP_Island,"zpp_pool","next"),h(t.space.ZPP_Component,"zpp_pool","next"),h(t.space.ZPP_CallbackSet,"zpp_pool","next"),h(t.dynamics.ZPP_SensorArbiter,"zpp_pool","next"),h(t.dynamics.ZPP_FluidArbiter,"zpp_pool","next"),h(t.dynamics.ZPP_ColArbiter,"zpp_pool","next"),h(t.dynamics.ZPP_InteractionFilter,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_Body,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_CbSetPair,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_PartitionVertex,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_PartitionPair,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_SimpleVert,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_SimpleSeg,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_SimpleEvent,"zpp_pool","next"),h(t.util.ZPP_Set_ZPP_CbSet,"zpp_pool","next"),h(t.util.ZPP_PubPool,"poolGeomPoly","zpp_pool"),h(t.util.ZPP_PubPool,"poolVec2","zpp_pool"),h(t.util.ZPP_PubPool,"poolVec3","zpp_pool");}};var Ne=class n{get _inner(){return this}constructor(e=1,t=0,r=0,i=1,o=0,s=0){let a=A.get();this.zpp_inner=a,a.outer=this;let l=["a","b","tx","c","d","ty"],c=[e,t,o,r,i,s];for(let _=0;_<c.length;_++)if(c[_]!==c[_])throw new Error("Error: Mat23::"+l[_]+" cannot be NaN");a.setas(e,t,r,i,o,s);}static rotation(e){if(e!==e)throw new Error("Error: Cannot create rotation matrix with NaN angle");let t=Math.cos(e),r=Math.sin(e);return new n(t,-r,r,t,0,0)}static translation(e,t){return new n(1,0,0,1,e,t)}static scale(e,t){return new n(e,0,0,t,0,0)}static _wrap(e){return e instanceof n?e:e?e instanceof A?G$1(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}_setProp(e,t){if(t!==t)throw new Error("Error: Mat23::"+e+" cannot be NaN");this.zpp_inner[e]=t,this.zpp_inner.invalidate();}get a(){return this.zpp_inner.a}set a(e){this._setProp("a",e);}get b(){return this.zpp_inner.b}set b(e){this._setProp("b",e);}get c(){return this.zpp_inner.c}set c(e){this._setProp("c",e);}get d(){return this.zpp_inner.d}set d(e){this._setProp("d",e);}get tx(){return this.zpp_inner.tx}set tx(e){this._setProp("tx",e);}get ty(){return this.zpp_inner.ty}set ty(e){this._setProp("ty",e);}get determinant(){return this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c}clone(){return this.copy()}equals(e,t=0){if(e==null)return false;let r=this.zpp_inner,i=e.zpp_inner,o=r.a-i.a,s=r.b-i.b,a=r.c-i.c,l=r.d-i.d,c=r.tx-i.tx,_=r.ty-i.ty;return (o<0?-o:o)<=t&&(s<0?-s:s)<=t&&(a<0?-a:a)<=t&&(l<0?-l:l)<=t&&(c<0?-c:c)<=t&&(_<0?-_:_)<=t}copy(){return new n(this.zpp_inner.a,this.zpp_inner.b,this.zpp_inner.c,this.zpp_inner.d,this.zpp_inner.tx,this.zpp_inner.ty)}set(e){if(e==null)throw new Error("Error: Cannot set form null matrix");let t=e.zpp_inner;return this.zpp_inner.setas(t.a,t.b,t.c,t.d,t.tx,t.ty),this.zpp_inner.invalidate(),this}setAs(e=1,t=0,r=0,i=1,o=0,s=0){return this.zpp_inner.setas(e,t,r,i,o,s),this.zpp_inner.invalidate(),this}reset(){return this.setAs()}singular(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,o=e*e+t*t+r*r+i*i,s=e*i-t*r;s<0&&(s=-s);let a=E();return o>a.Config.illConditionedThreshold*s}inverse(){if(this.singular())throw new Error("Error: Matrix is singular and cannot be inverted");let{a:e,b:t,c:r,d:i,tx:o,ty:s}=this.zpp_inner,a=1/(e*i-t*r);return new n(i*a,-t*a,-r*a,e*a,(t*s-i*o)*a,(r*o-e*s)*a)}transpose(){let{a:e,b:t,c:r,d:i,tx:o,ty:s}=this.zpp_inner;return new n(e,r,t,i,-e*o-r*s,-t*o-i*s)}concat(e){if(e==null)throw new Error("Error: Cannot concatenate with null Mat23");let t=e.zpp_inner,r=this.zpp_inner;return new n(t.a*r.a+t.b*r.c,t.a*r.b+t.b*r.d,t.c*r.a+t.d*r.c,t.c*r.b+t.d*r.d,t.a*r.tx+t.b*r.ty+t.tx,t.c*r.tx+t.d*r.ty+t.ty)}transform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");e.zpp_inner.validate();let i=e.zpp_inner.x,o=e.zpp_inner.y,{a:s,b:a,c:l,d:c,tx:_,ty:f}=this.zpp_inner,d,b;t?(d=i*s+o*a,b=i*l+o*c):(d=i*s+o*a+_,b=i*l+o*c+f);let A=H$1.get(d,b,r);return e.zpp_inner.weak&&e.dispose(),A}inverseTransform(e,t=false,r=false){if(e!=null&&e.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Cannot transform null Vec2");if(this.singular())throw new Error("Error: Matrix is singular and inverse transformation cannot be performed");let{a:i,b:o,c:s,d:a,tx:l,ty:c}=this.zpp_inner,_=1/(i*a-o*s);e.zpp_inner.validate();let f=e.zpp_inner.x,d=e.zpp_inner.y,b,A;if(t)b=(f*a-d*o)*_,A=(d*i-f*s)*_;else {let u=f-l,m=d-c;b=(u*a-m*o)*_,A=(m*i-u*s)*_;}let U=H$1.get(b,A,r);return e.zpp_inner.weak&&e.dispose(),U}equiorthogonal(){if(this.singular())return false;let{a:e,b:t,c:r,d:i}=this.zpp_inner,o=E(),s=e*t+r*i;if(s*s>=o.Config.epsilon)return false;let a=e*e+t*t-r*r-i*i;return a*a<o.Config.epsilon}orthogonal(){let{a:e,b:t,c:r,d:i}=this.zpp_inner,o=E(),s=e*t+r*i;if(s*s>=o.Config.epsilon)return false;let a=e*e+t*t-1,l=r*r+i*i-1;return a*a<o.Config.epsilon&&l*l<o.Config.epsilon}_orthogonaliseImpl(e){let{a:t,b:r,c:i,d:o}=this.zpp_inner,s=E(),a=Math.sqrt(t*t+i*i),l=Math.sqrt(r*r+o*o);if(a*a<s.Config.epsilon||l*l<s.Config.epsilon)throw new Error("Error: Matrix is singular and cannot be "+(e?"equiorthogonal":"orthogonal")+"ised");let c=e?(a+l)/2:1;a=c/a,l=c/l,this.a=this.zpp_inner.a*a,this.c=this.zpp_inner.c*a,this.b=this.zpp_inner.b*l,this.d=this.zpp_inner.d*l;let _=this.zpp_inner.a*this.zpp_inner.b+this.zpp_inner.c*this.zpp_inner.d,f=.25*Math.PI-.5*Math.acos(_/(c*c));this.zpp_inner.a*this.zpp_inner.d-this.zpp_inner.b*this.zpp_inner.c>0&&(f=-f);let d=Math.sin(f),b=Math.cos(f),A=this.zpp_inner.a*b-this.zpp_inner.c*d,U=this.zpp_inner.b*b+this.zpp_inner.d*d,u=this.zpp_inner.c*b+this.zpp_inner.a*d,m=this.zpp_inner.d*b-this.zpp_inner.b*d;return this.c=u,this.a=A,this.d=m,this.b=U,this.zpp_inner.invalidate(),this}equiorthogonalise(){return this.equiorthogonal()?this:this._orthogonaliseImpl(true)}orthogonalise(){return this.orthogonal()?this:this._orthogonaliseImpl(false)}toString(){let{a:e,b:t,c:r,d:i,tx:o,ty:s}=this.zpp_inner;return "{ a: "+e+" b: "+t+" c: "+r+" d: "+i+" tx: "+o+" ty: "+s+" }"}};A._wrapFn=n=>G$1(n,e=>{let t=Object.create(Ne.prototype);return t.zpp_inner=e,e.outer=t,t});function ut(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.x}function ht(n){if(n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let e=n.zpp_inner;return e._validate!=null&&e._validate(),e.y}function Ie(n){n.zpp_inner.weak&&n.dispose();}var Q=class n{get _inner(){return this}constructor(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::direction cannot be null");let r=new B$1;this.zpp_inner=r;let i=ut(e),o=ht(e);r.origin.zpp_inner.x=i,r.origin.zpp_inner.y=o,r.origin.zpp_inner._invalidate!=null&&r.origin.zpp_inner._invalidate(r.origin.zpp_inner),Ie(e);let s=ut(t),a=ht(t);r.direction.zpp_inner.x=s,r.direction.zpp_inner.y=a,r.direction.zpp_inner._invalidate!=null&&r.direction.zpp_inner._invalidate(r.direction.zpp_inner),Ie(t),r.zip_dir=true,r.maxdist=1/0;}static _wrap(e){return e==null?null:e instanceof n?e:G$1(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r})}static fromSegment(e,t){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::fromSegment::start is null");if(t?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(t==null)throw new Error("Error: Ray::fromSegment::end is null");let r=t.sub(e,true),i=new n(e,r),o=ut(e),s=ht(e),a=ut(t),l=ht(t),c=a-o,_=l-s,f=Math.sqrt(c*c+_*_);if(f!==f)throw new Error("Error: maxDistance cannot be NaN");return i.zpp_inner.maxdist=f,Ie(e),Ie(t),i}get origin(){return this.zpp_inner.origin}set origin(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::origin cannot be null");this.zpp_inner.origin.set(e),Ie(e);}get direction(){return this.zpp_inner.direction}set direction(e){if(e?.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: Ray::direction cannot be null");this.zpp_inner.direction.set(e),this.zpp_inner.zip_dir=true,Ie(e);}get maxDistance(){return this.zpp_inner.maxdist}set maxDistance(e){if(e!==e)throw new Error("Error: maxDistance cannot be NaN");this.zpp_inner.maxdist=e;}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}aabb(){return K$1._wrap(this.zpp_inner.rayAABB())}at(e,t=false){this.zpp_inner.validate_dir();let r=this.zpp_inner.origin.zpp_inner;r._validate!=null&&r._validate();let i=r.x,o=r.y,s=i+e*this.zpp_inner.dirx,a=o+e*this.zpp_inner.diry;return H$1.get(s,a,t)}clone(){return this.copy()}copy(){let e=new n(this.zpp_inner.origin,this.zpp_inner.direction),t=this.zpp_inner.maxdist;if(t!==t)throw new Error("Error: maxDistance cannot be NaN");return e.zpp_inner.maxdist=t,e}};var Te=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x$1.internal)throw new Error("Error: ConvexResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G$1(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H$1._wrap(this.zpp_inner.normal)}get position(){return this._disposed(),H$1._wrap(this.zpp_inner.position)}get toi(){return this._disposed(),this.zpp_inner.toiDistance}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" toi: "+this.zpp_inner.toiDistance+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x$1._createConvexResult=()=>new Te;var Ae=class n{get _inner(){return this}constructor(){if(this.zpp_inner=null,!x$1.internal)throw new Error("Error: RayResult cannot be instantiated derp!")}static _wrap(e){if(!e)return null;if(e instanceof n)return e;let t=e.zpp_inner??e;return G$1(t,r=>{let i=Object.create(n.prototype);return i.zpp_inner=r,i})}get normal(){return this._disposed(),H$1._wrap(this.zpp_inner.normal)}get distance(){return this._disposed(),this.zpp_inner.toiDistance}get inner(){return this._disposed(),this.zpp_inner.inner}get shape(){return this._disposed(),this.zpp_inner.shape}dispose(){this._disposed(),this.zpp_inner.free();}toString(){return this._disposed(),"{ shape: "+String(this.zpp_inner.shape)+" distance: "+this.zpp_inner.toiDistance+" ?inner: "+String(this.zpp_inner.inner)+" }"}_disposed(){if(this.zpp_inner.next!=null)throw new Error("Error: This object has been disposed of and cannot be used")}};x$1._createRayResult=()=>new Ae;function ce(n){return n?.zpp_inner??n?._inner?.zpp_inner}function ct(n){return n?.zpp_inner??n?._inner?.zpp_inner}function ft(n,e){if(n!=null&&n.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let t=n.zpp_inner;if(t._immutable)throw new Error("Error: Vec2 is immutable");t._isimmutable!=null&&t._isimmutable();}function Le(n,e){if(ce(n)?.body?.outer==null)throw new Error(`Error: Shape must be part of a Body to calculate ${e}`)}var je=class{static distanceBody(e,t,r,i){ft(r),ft(i);let o=ct(e),s=ct(t);if(o.shapes.head==null||s.shapes.head==null)throw new Error("Error: Bodies cannot be empty in calculating distances");let a=o.shapes.head;for(;a!=null;)y$1.validateShape(a.elt),a=a.next;for(a=s.shapes.head;a!=null;)y$1.validateShape(a.elt),a=a.next;return C.distanceBody(o,s,r.zpp_inner,i.zpp_inner)}static distance(e,t,r,i){ft(r),ft(i),Le(e,"distances"),Le(t,"distances");let o=ce(e),s=ce(t);y$1.validateShape(o),y$1.validateShape(s);let a;l.zpp_pool==null?a=new l:(a=l.zpp_pool,l.zpp_pool=a.next,a.next=null),a.weak=false;let l$1=C.distance(o,s,r.zpp_inner,i.zpp_inner,a,1e100);return a.next=l.zpp_pool,l.zpp_pool=a,l$1}static intersectsBody(e,t){let r=ct(e),i=ct(t);if(r.shapes.head==null||i.shapes.head==null)throw new Error("Error: Bodies must have shapes to test for intersection.");let o=r.shapes.head;for(;o!=null;)y$1.validateShape(o.elt),o=o.next;for(o=i.shapes.head;o!=null;)y$1.validateShape(o.elt),o=o.next;let s=r.aabb,a=i.aabb;if(s.minx>a.maxx||s.maxx<a.minx||s.miny>a.maxy||s.maxy<a.miny)return false;let l=r.shapes.head;for(;l!=null;){let c=i.shapes.head;for(;c!=null;){if(w.testCollide_safe(l.elt,c.elt))return true;c=c.next;}l=l.next;}return false}static intersects(e,t){Le(e,"intersection"),Le(t,"intersection");let r=ce(e),i=ce(t);y$1.validateShape(r),y$1.validateShape(i);let o=r.aabb,s=i.aabb;return o.minx>s.maxx||o.maxx<s.minx||o.miny>s.maxy||o.maxy<s.miny?false:w.testCollide_safe(r,i)}static contains(e,t){Le(e,"containment"),Le(t,"containment");let r=ce(e),i=ce(t);return y$1.validateShape(r),y$1.validateShape(i),w.containTest(r,i)}};var Ke=class{static run(e,t,r,i=2,o=null,s=true,a=null){if(r!=null&&r.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(o!=null&&o.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");if(e==null)throw new Error("Error: MarchingSquares requires an iso function to operate");if(t==null)throw new Error("Error: MarchingSquares requires an AABB to define bounds of surface extraction");if(r==null)throw new Error("Error: MarchingSquares requires a Vec2 to define cell size for surface extraction");let l=r.zpp_inner;if(l._validate!=null&&l._validate(),l.x<=0||l.y<=0)throw new Error("Error: MarchingSquares cannot operate with non-positive cell dimensions");if(i<0)throw new Error("Error: MarchingSquares cannot use a negative quality value for interpolation");if(o!=null){let b=o.zpp_inner;if(b._validate!=null&&b._validate(),b.x<=0||b.y<=0)throw new Error("Error: MarchingSquares cannot with non-positive sub-grid dimensions")}let c=E(),_=a??new c.geom.GeomPolyList,f=z,d=t.zpp_inner;if(d._validate!=null&&d._validate(),o==null){let b=d.minx,A=d.miny,U=d.maxx,u=d.maxy;f.run(e,b,A,U,u,r,i,s,_);}else {let b=o.zpp_inner;b._validate!=null&&b._validate();let A=d.maxx-d.minx,U=d.maxy-d.miny,u=A/b.x,m=U/b.y,g=u|0,R=m|0;g!==u&&++g,R!==m&&++R;for(let ge=0;ge<g;ge++){let Fe=d.minx+b.x*ge,mt=ge===g-1?d.maxx:Fe+b.x;for(let we=0;we<R;we++){let xe=d.miny+b.y*we,Z=we===R-1?d.maxy:xe+b.y;f.run(e,Fe,xe,mt,Z,r,i,s,_);}}}return l.weak&&r.dispose(),o!=null&&o.zpp_inner.weak&&o.dispose(),_}};var ae=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new c,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E(),i=new r.geom.Vec2List;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};ae.internal=false;function fe(n){if(n.outer==null){let e=E();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l.zpp_pool,l.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function I(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!ae.internal)throw new Error("Error: Cannot instantiate Vec2Iterator derp!")}I.zpp_pool=null;I.get=function(n){let e;return I.zpp_pool==null?(ae.internal=true,e=new I,ae.internal=false):(e=I.zpp_pool,I.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};I.prototype.zpp_inner=null;I.prototype.zpp_i=null;I.prototype.zpp_critical=null;I.prototype.zpp_next=null;I.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=this.zpp_inner.zpp_gl();return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=I.zpp_pool,I.zpp_pool=this,this.zpp_inner=null,false)};I.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function P(){this.zpp_inner=null,this.zpp_inner=new ae,this.zpp_inner.outer=this;}P.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E(),t=new e.geom.Vec2List;for(let r=0;r<n.length;r++)t.push(n[r]);return t};P.prototype.zpp_inner=null;Object.defineProperty(P.prototype,"length",{get:function(){return this.zpp_gl()}});P.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};P.prototype.zpp_vm=function(){this.zpp_inner.valmod();};P.prototype.has=function(n){return this.zpp_vm(),this.zpp_inner.inner.has(n.zpp_inner)};P.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=n,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(n);else for(;this.zpp_inner.at_index!=n;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return fe(this.zpp_inner.at_ite.elt)};P.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(n.zpp_inner):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};P.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;return e&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.empty()?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner)):this.zpp_inner.inner.add(n.zpp_inner),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n)),e};P.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.zpp_inner.inner.head.elt;let e=fe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=fe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}return this.zpp_inner.invalidate(),fe(n)};P.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let e=this.zpp_gl()==1?null:this.zpp_inner.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.zpp_inner.inner.head.elt:e.next.elt;let t=fe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(e);}else {n=this.zpp_inner.inner.head.elt;let e=fe(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),fe(n)};P.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};P.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.zpp_inner.inner.head;for(;t!=null;){if(t.elt==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};P.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};P.prototype.empty=function(){return this.zpp_gl()==0};P.prototype.iterator=function(){return this.zpp_vm(),I.get(this)};P.prototype.copy=function(n){n==null&&(n=false);let e=E(),t=new e.geom.Vec2List,r=I.get(this);for(;r.hasNext();){let i=r.next(),o;if(n){if(i!=null&&i.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=i.zpp_inner;s._validate!=null&&s._validate();let a=i.zpp_inner.x,l$1=i.zpp_inner;l$1._validate!=null&&l$1._validate();let c=i.zpp_inner.y,_;if(b.poolVec2==null?_=new e.geom.Vec2:(_=b.poolVec2,b.poolVec2=_.zpp_pool,_.zpp_pool=null,_.zpp_disp=false,_==b.nextVec2&&(b.nextVec2=null)),_.zpp_inner==null){let f;l.zpp_pool==null?f=new l:(f=l.zpp_pool,l.zpp_pool=f.next,f.next=null),f.weak=false,f._immutable=false,f.x=a,f.y=c,_.zpp_inner=f,_.zpp_inner.outer=_;}else _.zpp_inner.x=a,_.zpp_inner.y=c,_.zpp_inner._invalidate!=null&&_.zpp_inner._invalidate(_.zpp_inner);_.zpp_inner.weak=false,o=_;}else o=i;t.push(o);}return t};P.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");let e=n.iterator();for(;e.hasNext();){let t=e.next();this.has(t)||this.add(t);}};P.prototype.toString=function(){let n="[",e=true,t=I.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};P.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");let e=this.iterator();for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=I.zpp_pool,I.zpp_pool=e,e.zpp_inner=null;break}return this};P.prototype[Symbol.iterator]=function(){let n=I.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};P.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;e<this.zpp_gl();){let t=this.at(e);try{n(t)?++e:this.remove(t);}catch{break}}return this};function me(){if(!M.internal)throw new Error("Error: Cannot instantiate GeomVertexIterator")}me.prototype.zpp_inner=null;me.prototype.hasNext=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr!=this.zpp_inner.start||this.zpp_inner.first;if(this.zpp_inner.first=false,!n){let e=this.zpp_inner;e.outer.zpp_inner=null,e.ptr=e.start=null,e.next=M.zpp_pool,M.zpp_pool=e;}return n};me.prototype.next=function(){if(this.zpp_inner==null)throw new Error("Error: Iterator has been disposed");let n=this.zpp_inner.ptr;if(n.wrap==null){let t=n.x,r=n.y;if(t!==t||r!==r)throw new Error("Error: Vec2 components cannot be NaN");let i=E(),o;if(b.poolVec2==null?o=new i.geom.Vec2:(o=b.poolVec2,b.poolVec2=o.zpp_pool,o.zpp_pool=null,o.zpp_disp=false,o==b.nextVec2&&(b.nextVec2=null)),o.zpp_inner==null){let s;l.zpp_pool==null?s=new l:(s=l.zpp_pool,l.zpp_pool=s.next,s.next=null),s.weak=false,s._immutable=false,s.x=t,s.y=r,o.zpp_inner=s,o.zpp_inner.outer=o;}else {if(o.zpp_disp)throw new Error("Error: Vec2 has been disposed and cannot be used!");let s=o.zpp_inner;if(s._immutable)throw new Error("Error: Vec2 is immutable");s._isimmutable!=null&&s._isimmutable(),s.x==t&&s.y==r||(s.x=t,s.y=r,s._invalidate!=null&&s._invalidate(s));}o.zpp_inner.weak=false,n.wrap=o,n.wrap.zpp_inner._inuse=true,n.wrap.zpp_inner._invalidate=s=>n.modwrap(s),n.wrap.zpp_inner._validate=()=>n.getwrap();}let e=n.wrap;return this.zpp_inner.ptr=this.zpp_inner.forward?this.zpp_inner.ptr.next:this.zpp_inner.ptr.prev,e};me.prototype[Symbol.iterator]=function(){return {_it:this,next(){return this._it.hasNext()?{value:this._it.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};var zn=E();zn.geom.GeomVertexIterator=me;var H=class{constructor(){this.outer=null;this.inner=null;this.immutable=false;this._invalidated=false;this._invalidate=null;this._validate=null;this._modifiable=null;this.adder=null;this.post_adder=null;this.subber=null;this.dontremove=false;this.reverse_flag=false;this.at_index=0;this.at_ite=null;this.push_ite=null;this.zip_length=false;this.user_length=0;this.inner=new u,this._invalidated=true;}static get(e,t){t==null&&(t=false);let r=E(),i=new r.dynamics.ContactList;return i.zpp_inner.inner=e,t&&(i.zpp_inner.immutable=true),i.zpp_inner.zip_length=true,i}valmod(){this.validate(),this.inner.modified&&(this.inner.pushmod&&(this.push_ite=null),this.at_ite=null,this.inner.modified=false,this.inner.pushmod=false,this.zip_length=true);}modified(){this.zip_length=true,this.at_ite=null,this.push_ite=null;}modify_test(){this._modifiable!=null&&this._modifiable();}validate(){this._invalidated&&(this._invalidated=false,this._validate!=null&&this._validate());}invalidate(){this._invalidated=true,this._invalidate!=null&&this._invalidate(this);}};H.internal=false;var Se=class n{constructor(){if(!D$1.internal)throw new Error("Error: Cannot instantiate an Edge derp!")}static _wrap(e){return e?e instanceof n?e:e instanceof D$1?G$1(e,t=>{D$1.internal=true;let r=new n;return D$1.internal=false,r.zpp_inner=t,t.outer=r,r}):null:null}get polygon(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.outer_zn}get localNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_lnorm==null&&e.getlnorm(),e.wrap_lnorm}get worldNormal(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.wrap_gnorm==null&&e.getgnorm(),e.wrap_gnorm}get length(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.length}get localProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),e.lprojection}get worldProjection(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");if(e.polygon.body==null)throw new Error("Error: Edge world projection only makes sense for Polygons contained within a rigid body");return e.polygon.validate_gaxi(),e.gprojection}get localVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp0)}get localVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_laxi(),this._wrapVert(e.lp1)}get worldVertex1(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp0)}get worldVertex2(){let e=this.zpp_inner;if(e.polygon==null)throw new Error("Error: Edge not current in use");return e.polygon.validate_gaxi(),this._wrapVert(e.gp1)}toString(){let e=this.zpp_inner;return e.polygon==null?"Edge(object-pooled)":e.polygon.body==null?(e.polygon.validate_laxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } }"):(e.polygon.validate_gaxi(),"{ localNormal : { x: "+e.lnormx+" y: "+e.lnormy+" } worldNormal : { x: "+e.gnormx+" y: "+e.gnormy+" } }")}_wrapVert(e){let t=E();if(e.outer==null){e.outer=new t.geom.Vec2;let r=e.outer.zpp_inner;r.outer!=null&&(r.outer.zpp_inner=null,r.outer=null),r._isimmutable=null,r._validate=null,r._invalidate=null,r.next=l.zpp_pool,l.zpp_pool=r,e.outer.zpp_inner=e;}return e.outer}};D$1._wrapFn=n=>G$1(n,e=>{D$1.internal=true;let t=new Se;return D$1.internal=false,t.zpp_inner=e,e.outer=t,t});var Ve=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ValidationResult derp!")}static get VALID(){return a.ValidationResult_VALID==null&&(a.internal=true,a.ValidationResult_VALID=new n,a.internal=false),a.ValidationResult_VALID}static get DEGENERATE(){return a.ValidationResult_DEGENERATE==null&&(a.internal=true,a.ValidationResult_DEGENERATE=new n,a.internal=false),a.ValidationResult_DEGENERATE}static get CONCAVE(){return a.ValidationResult_CONCAVE==null&&(a.internal=true,a.ValidationResult_CONCAVE=new n,a.internal=false),a.ValidationResult_CONCAVE}static get SELF_INTERSECTING(){return a.ValidationResult_SELF_INTERSECTING==null&&(a.internal=true,a.ValidationResult_SELF_INTERSECTING=new n,a.internal=false),a.ValidationResult_SELF_INTERSECTING}toString(){return this===a.ValidationResult_VALID?"VALID":this===a.ValidationResult_DEGENERATE?"DEGENERATE":this===a.ValidationResult_CONCAVE?"CONCAVE":this===a.ValidationResult_SELF_INTERSECTING?"SELF_INTERSECTING":""}},dn=E();dn.shape.ValidationResult=Ve;var Ze=class n{get _inner(){return this}constructor(e=false){let t=new v$1;this.zpp_inner=t,t.outer=this,t.ignore!=e&&(t.invalidate(true),t.ignore=e);}static _wrap(e){return e instanceof n?e:e?e instanceof v$1?G$1(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}get group(){return this.zpp_inner.group==null?null:this.zpp_inner.group.outer}set group(e){if(e===this)throw new Error("Error: Cannot assign InteractionGroup to itself");this.zpp_inner.setGroup(e==null?null:e.zpp_inner);}get ignore(){return this.zpp_inner.ignore}set ignore(e){this.zpp_inner.ignore!=e&&(this.zpp_inner.invalidate(true),this.zpp_inner.ignore=e);}get interactors(){if(this.zpp_inner.wrap_interactors==null){let e=E();this.zpp_inner.wrap_interactors=e.zpp_nape.util.ZPP_InteractorList.get(this.zpp_inner.interactors,true);}return this.zpp_inner.wrap_interactors}get groups(){if(this.zpp_inner.wrap_groups==null){let e=E();this.zpp_inner.wrap_groups=e.zpp_nape.util.ZPP_InteractionGroupList.get(this.zpp_inner.groups,true);}return this.zpp_inner.wrap_groups}toString(){let e="InteractionGroup";return this.zpp_inner.ignore&&(e+=":ignore"),e}};v$1._wrapFn=n=>G$1(n,e=>{let t=Object.create(Ze.prototype);return t.zpp_inner=e,e.outer=t,t});var Oe=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ArbiterType derp!")}static get COLLISION(){return a.ArbiterType_COLLISION==null&&(a.internal=true,a.ArbiterType_COLLISION=new n,a.internal=false),a.ArbiterType_COLLISION}static get SENSOR(){return a.ArbiterType_SENSOR==null&&(a.internal=true,a.ArbiterType_SENSOR=new n,a.internal=false),a.ArbiterType_SENSOR}static get FLUID(){return a.ArbiterType_FLUID==null&&(a.internal=true,a.ArbiterType_FLUID=new n,a.internal=false),a.ArbiterType_FLUID}toString(){return this===a.ArbiterType_COLLISION?"COLLISION":this===a.ArbiterType_SENSOR?"SENSOR":this===a.ArbiterType_FLUID?"FLUID":""}},bn=E();bn.dynamics.ArbiterType=Oe;F$1();var q=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!t.internal)throw new Error("Error: Cannot instantiate Arbiter derp!")}get isSleeping(){return this._activeCheck(),this.zpp_inner.sleeping}get type(){return t.types[this.zpp_inner.type]}get collisionArbiter(){return this.zpp_inner.type==t.COL?this.zpp_inner.colarb.outer_zn:null}get fluidArbiter(){return this.zpp_inner.type==t.FLUID?this.zpp_inner.fluidarb.outer_zn:null}get shape1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer}get shape2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer}get body1(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b2.outer:this.zpp_inner.b1.outer}get body2(){return this._activeCheck(),this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.b1.outer:this.zpp_inner.b2.outer}get state(){this._activeCheck();let e=E(),t=this.zpp_inner.immState;return t==5?(a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT):t==1?(a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_ACCEPT_ONCE):t==6?(a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE):(a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new e.callbacks.PreFlag,a.internal=false),a.PreFlag_IGNORE_ONCE)}isCollisionArbiter(){return this.zpp_inner.type==t.COL}isFluidArbiter(){return this.zpp_inner.type==t.FLUID}isSensorArbiter(){return this.zpp_inner.type==t.SENSOR}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),I$1.get(0,0,0)}toString(){let e=this.zpp_inner.type==t.COL?"CollisionArbiter":this.zpp_inner.type==t.FLUID?"FluidArbiter":"SensorArbiter";if(this.zpp_inner.cleared)return e+"(object-pooled)";this._activeCheck();let t$1=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer,r=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer,i=e+"("+t$1.toString()+"|"+r.toString()+")";return this.zpp_inner.type==t.COL&&(i+="["+["SD","DD"][this.zpp_inner.colarb.stat?0:1]+"]"),i+="<-"+this.state.toString(),i}_activeCheck(){if(!this.zpp_inner.active)throw new Error("Error: Arbiter not currently in use")}_checkBody(e){let t=this.zpp_inner,r=t.ws1.id>t.ws2.id?t.b2.outer:t.b1.outer,i=t.ws1.id>t.ws2.id?t.b1.outer:t.b2.outer;if(e!=r&&e!=i)throw new Error("Error: Arbiter does not relate to body")}},gn=E();gn.dynamics.Arbiter=q;var He=class extends q{constructor(){super();}get contacts(){return this._activeCheck(),this.zpp_inner.colarb.wrap_contacts==null&&this.zpp_inner.colarb.setupcontacts(),this.zpp_inner.colarb.wrap_contacts}get normal(){return this._activeCheck(),this.zpp_inner.colarb.wrap_normal==null&&this.zpp_inner.colarb.getnormal(),this.zpp_inner.colarb.wrap_normal}get radius(){return this._activeCheck(),this.zpp_inner.colarb.radius}get referenceEdge1(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws2.outer:this.zpp_inner.ws1.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get referenceEdge2(){this._activeCheck();let e=this.zpp_inner.colarb.__ref_edge1;if(e!=null){let t=this.zpp_inner.ws1.id>this.zpp_inner.ws2.id?this.zpp_inner.ws1.outer:this.zpp_inner.ws2.outer;t.zpp_inner.type==1?t.zpp_inner!=e.polygon&&(e=this.zpp_inner.colarb.__ref_edge2):e=this.zpp_inner.colarb.__ref_edge2;}return e==null?null:e.wrapper()}get elasticity(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.restitution}set elasticity(e){if(this._mutableCheck("elasticity"),e!==e)throw new Error("Error: CollisionArbiter::elasticity cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::elasticity cannot be negative");this.zpp_inner.colarb.restitution=e,this.zpp_inner.colarb.userdef_restitution=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get dynamicFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.dyn_fric}set dynamicFriction(e){if(this._mutableCheck("dynamicFriction"),e!==e)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::dynamicFriction cannot be negative");this.zpp_inner.colarb.dyn_fric=e,this.zpp_inner.colarb.userdef_dyn_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get staticFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.stat_fric}set staticFriction(e){if(this._mutableCheck("staticFriction"),e!==e)throw new Error("Error: CollisionArbiter::staticFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::staticFriction cannot be negative");this.zpp_inner.colarb.stat_fric=e,this.zpp_inner.colarb.userdef_stat_fric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}get rollingFriction(){return this._activeCheck(),this.zpp_inner.colarb.validate_props(),this.zpp_inner.colarb.rfric}set rollingFriction(e){if(this._mutableCheck("rollingFriction"),e!==e)throw new Error("Error: CollisionArbiter::rollingFriction cannot be NaN");if(e<0)throw new Error("Error: CollisionArbiter::rollingFriction cannot be negative");this.zpp_inner.colarb.rfric=e,this.zpp_inner.colarb.userdef_rfric=true,this._activeCheck(),this.zpp_inner.colarb.validate_props();}firstVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==-1:false}secondVertex(){return this._activeCheck(),this.zpp_inner.colarb.__ref_edge1!=null!=(this.zpp_inner.colarb.__ref_edge2!=null)?this.zpp_inner.colarb.__ref_vertex==1:false}normalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("normalImpulse",e,t)}tangentImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("tangentImpulse",e,t)}totalImpulse(e=null,t=false){return this._activeCheck(),e!=null&&this._checkBody(e),this._accumulateImpulse("totalImpulse",e,t)}rollingImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.zpp_inner.colarb;return !t||r.oc1.fresh?r.oc1.wrapper().rollingImpulse(e):0}_mutableCheck(e){if(!this.zpp_inner.colarb.mutable)throw new Error("Error: CollisionArbiter::"+e+" is only mutable during a pre-handler")}_accumulateImpulse(e,t,r){let i=0,o=0,s=0,a=this.zpp_inner.colarb;if(!r||a.oc1.fresh){let l=a.oc1.wrapper()[e](t),c=l.zpp_inner;c._validate!=null&&c._validate(),i+=c.x,c._validate!=null&&c._validate(),o+=c.y,c._validate!=null&&c._validate(),s+=c.z,l.dispose();}if(a.hc2&&(!r||a.oc2.fresh)){let l=a.oc2.wrapper()[e](t),c=l.zpp_inner;c._validate!=null&&c._validate(),i+=c.x,c._validate!=null&&c._validate(),o+=c.y,c._validate!=null&&c._validate(),s+=c.z,l.dispose();}return I$1.get(i,o,s)}};var qe=class extends q{constructor(){super();}get position(){return this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),H$1._wrap(this.zpp_inner.fluidarb.wrap_position)}set position(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e==null)throw new Error("Error: FluidArbiter::position cannot be null");this._activeCheck(),this.zpp_inner.fluidarb.wrap_position==null&&this.zpp_inner.fluidarb.getposition(),this.zpp_inner.fluidarb.wrap_position.set(e);}get overlap(){return this._activeCheck(),this.zpp_inner.fluidarb.overlap}set overlap(e){if(!this.zpp_inner.fluidarb.mutable)throw new Error("Error: Arbiter is mutable only within a pre-handler");if(e!==e)throw new Error("Error: FluidArbiter::overlap cannot be NaN");if(e<=0||e==1/0)throw new Error("Error: FluidArbiter::overlap must be strictly positive and non infinite");this.zpp_inner.fluidarb.overlap=e;}buoyancyImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb;return e==null?I$1.get(t.buoyx,t.buoyy,0):e.zpp_inner==this.zpp_inner.b2?I$1.get(t.buoyx,t.buoyy,t.buoyy*t.r2x-t.buoyx*t.r2y):I$1.get(-t.buoyx,-t.buoyy,-(t.buoyy*t.r1x-t.buoyx*t.r1y))}dragImpulse(e=null){this._activeCheck(),e!=null&&this._checkBody(e);let t=this.zpp_inner.fluidarb,r=e==null||e.zpp_inner==this.zpp_inner.b2?1:-1;return I$1.get(t.dampx*r,t.dampy*r,t.adamp*r)}totalImpulse(e=null,t=false){this._activeCheck(),e!=null&&this._checkBody(e);let r=this.buoyancyImpulse(e),i=this.dragImpulse(e),o=r.zpp_inner,s=i.zpp_inner;return o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.x=s.x+o.x,o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.y=s.y+o.y,o._validate!=null&&o._validate(),s._validate!=null&&s._validate(),s.z=s.z+o.z,r.dispose(),i}};var Re=class{get _inner(){return this}constructor(){if(this.zpp_inner=null,!u.internal)throw new Error("Error: Cannot instantiate Contact derp!")}get arbiter(){if(this.zpp_inner.arbiter==null)return null;let e=this.zpp_inner.arbiter.outer;return e.zpp_inner.type==t.COL?e.zpp_inner.colarb.outer_zn:null}get penetration(){return this._inactiveCheck(),-this.zpp_inner.dist}get position(){return this._inactiveCheck(),this.zpp_inner.wrap_position==null&&this.zpp_inner.getposition(),H$1._wrap(this.zpp_inner.wrap_position)}get fresh(){return this._inactiveCheck(),this.zpp_inner.fresh}get friction(){return this._inactiveCheck(),this.zpp_inner.inner.friction}normalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc;return e==null?I$1.get(t.nx*i,t.ny*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.nx*-i,t.ny*-i,-(t.ny*r.r1x-t.nx*r.r1y)*i):I$1.get(t.nx*i,t.ny*i,(t.ny*r.r2x-t.nx*r.r2y)*i))}tangentImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jtAcc;return e==null?I$1.get(-t.ny*i,t.nx*i):(this._checkBody(e,t),e==t.b1.outer?I$1.get(t.ny*i,-t.nx*i,-(r.r1x*t.nx+r.r1y*t.ny)*i):I$1.get(-t.ny*i,t.nx*i,(r.r2x*t.nx+r.r2y*t.ny)*i))}rollingImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=t.jrAcc;return e==null?r:(this._checkBody(e,t),e==t.b1.outer?-r:r)}totalImpulse(e=null){this._inactiveCheck();let t=this.zpp_inner.arbiter.colarb,r=this.zpp_inner.inner,i=r.jnAcc,o=r.jtAcc,s=t.jrAcc;if(e==null)return I$1.get(t.nx*i-t.ny*o,t.ny*i+t.nx*o,s);this._checkBody(e,t);let a=t.nx*i-t.ny*o,l=t.ny*i+t.nx*o;return e==t.b1.outer?I$1.get(-a,-l,-(l*r.r1x-a*r.r1y)-s):I$1.get(a,l,l*r.r2x-a*r.r2y+s)}toString(){return this.zpp_inner.arbiter==null||this.zpp_inner.arbiter.cleared?"{object-pooled}":"{Contact}"}_inactiveCheck(){if(this.zpp_inner.inactiveme())throw new Error("Error: Contact not currently in use")}_checkBody(e,t){if(e!=t.b1.outer&&e!=t.b2.outer)throw new Error("Error: Contact does not relate to the given body")}};u._wrapFn=n=>{u.internal=true;let e=new Re;return u.internal=false,e.zpp_inner=n,n.outer=e,e};function wn(n){let e=0,t=n.inner.next;for(;t!=null;)t.active&&t.arbiter.active&&e++,t=t.next;return e}function B(n){return n.valmod(),n.zip_length&&(n.zip_length=false,n.user_length=wn(n)),n.user_length}function v(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!H.internal)throw new Error("Error: Cannot instantiate ContactIterator derp!")}v.zpp_pool=null;v.get=function(n){let e;return v.zpp_pool==null?(H.internal=true,e=new v,H.internal=false):(e=v.zpp_pool,v.zpp_pool=e.zpp_next),e.zpp_i=0,e.zpp_inner=n,e.zpp_critical=false,e};v.prototype.zpp_inner=null;v.prototype.zpp_i=null;v.prototype.zpp_critical=null;v.prototype.zpp_next=null;v.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let n=B(this.zpp_inner.zpp_inner);return this.zpp_critical=true,this.zpp_i<n?true:(this.zpp_next=v.zpp_pool,v.zpp_pool=this,this.zpp_inner=null,false)};v.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function T(){this.zpp_inner=null,this.zpp_inner=new H,this.zpp_inner.outer=this;}T.fromArray=function(n){if(n==null)throw new Error("Error: Cannot convert null Array to Nape list");let e=E(),t=new e.dynamics.ContactList;for(let r=0;r<n.length;r++)t.push(n[r]);return t};T.prototype.zpp_inner=null;Object.defineProperty(T.prototype,"length",{get:function(){return B(this.zpp_inner)}});T.prototype.has=function(n){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(n.zpp_inner)};T.prototype.at=function(n){this.zpp_inner.valmod();let e=B(this.zpp_inner);if(n<0||n>=e)throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(n=B(this.zpp_inner)-1-n),n<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)for(this.zpp_inner.at_index=0,this.zpp_inner.at_ite=this.zpp_inner.inner.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}for(;this.zpp_inner.at_index!=n;)for(this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;;){let t=this.zpp_inner.at_ite;if(t.active&&t.arbiter.active)break;this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;}return this.zpp_inner.at_ite.wrapper()};T.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.zpp_inner.inner.add(n.zpp_inner);else {if(this.zpp_inner.push_ite==null){let t=B(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};T.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){if(this.zpp_inner.push_ite==null){let t=B(this.zpp_inner);t==0?this.zpp_inner.push_ite=null:this.zpp_inner.push_ite=this.zpp_inner.inner.iterator_at(t-1);}this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,n.zpp_inner);}else this.zpp_inner.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};T.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),B(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=B(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}return this.zpp_inner.invalidate(),e.wrapper()};T.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.modify_test(),B(this.zpp_inner)==0)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let e;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let t=B(this.zpp_inner),r;t==1?r=null:r=this.zpp_inner.inner.iterator_at(t-2),e=r==null?this.zpp_inner.inner.next:r.next;let i=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(i),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(r);}else {e=this.zpp_inner.inner.next;let t=e.wrapper();this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),e.wrapper()};T.prototype.add=function(n){return this.zpp_inner.reverse_flag?this.push(n):this.unshift(n)};T.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let e=false,t=this.zpp_inner.inner.next;for(;t!=null;){if(t==n.zpp_inner){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};T.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: ContactList is immutable");if(this.zpp_inner.reverse_flag)for(;B(this.zpp_inner)!=0;)this.pop();else for(;B(this.zpp_inner)!=0;)this.shift();};T.prototype.empty=function(){return B(this.zpp_inner)==0};T.prototype.iterator=function(){return this.zpp_inner.valmod(),v.get(this)};T.prototype.copy=function(n){n==null&&(n=false);let e=E(),t=new e.dynamics.ContactList;this.zpp_inner.valmod();let r=v.get(this);for(;r.hasNext();){let i=r.next();if(n)throw new Error("Error: Contact is not a copyable type");t.push(i);}return t};T.prototype.merge=function(n){if(n==null)throw new Error("Error: Cannot merge with null list");n.zpp_inner.valmod();let e=v.get(n);for(;e.hasNext();){let t=e.next();this.has(t)||(this.zpp_inner.reverse_flag?this.push(t):this.unshift(t));}};T.prototype.toString=function(){let n="[",e=true;this.zpp_inner.valmod();let t=v.get(this);for(;t.hasNext();){let r=t.next();e||(n+=","),n+=r==null?"NULL":r.toString(),e=false;}return n+"]"};T.prototype.foreach=function(n){if(n==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let e=v.get(this);for(;e.hasNext();)try{n(e.next());}catch{e.zpp_next=v.zpp_pool,v.zpp_pool=e,e.zpp_inner=null;break}return this};T.prototype[Symbol.iterator]=function(){let n=v.get(this);return {next(){return n.hasNext()?{value:n.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};T.prototype.filter=function(n){if(n==null)throw new Error("Error: Cannot select elements of list with null");let e=0;for(;;){let t=B(this.zpp_inner);if(!(e<t))break;let r=this.at(e);try{n(r)?++e:this.remove(r);}catch{break}}return this};var x=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate CbEvent derp!")}static get BEGIN(){return a.CbEvent_BEGIN==null&&(a.internal=true,a.CbEvent_BEGIN=new n,a.internal=false),a.CbEvent_BEGIN}static get ONGOING(){return a.CbEvent_ONGOING==null&&(a.internal=true,a.CbEvent_ONGOING=new n,a.internal=false),a.CbEvent_ONGOING}static get END(){return a.CbEvent_END==null&&(a.internal=true,a.CbEvent_END=new n,a.internal=false),a.CbEvent_END}static get WAKE(){return a.CbEvent_WAKE==null&&(a.internal=true,a.CbEvent_WAKE=new n,a.internal=false),a.CbEvent_WAKE}static get SLEEP(){return a.CbEvent_SLEEP==null&&(a.internal=true,a.CbEvent_SLEEP=new n,a.internal=false),a.CbEvent_SLEEP}static get BREAK(){return a.CbEvent_BREAK==null&&(a.internal=true,a.CbEvent_BREAK=new n,a.internal=false),a.CbEvent_BREAK}static get PRE(){return a.CbEvent_PRE==null&&(a.internal=true,a.CbEvent_PRE=new n,a.internal=false),a.CbEvent_PRE}toString(){return this===a.CbEvent_BEGIN?"BEGIN":this===a.CbEvent_ONGOING?"ONGOING":this===a.CbEvent_END?"END":this===a.CbEvent_WAKE?"WAKE":this===a.CbEvent_SLEEP?"SLEEP":this===a.CbEvent_BREAK?"BREAK":this===a.CbEvent_PRE?"PRE":""}},xn=E();xn.callbacks.CbEvent=x;F$1();var ee=class n{get _inner(){return this}constructor(){this.zpp_inner=new e,this.zpp_inner.outer=this;}static get ANY_BODY(){return e.ANY_BODY}static get ANY_CONSTRAINT(){return e.ANY_CONSTRAINT}static get ANY_SHAPE(){return e.ANY_SHAPE}static get ANY_COMPOUND(){return e.ANY_COMPOUND}get id(){return this.zpp_inner.id}get userData(){return this.zpp_inner.userData==null&&(this.zpp_inner.userData={}),this.zpp_inner.userData}get interactors(){return this.zpp_inner.wrap_interactors==null&&(this.zpp_inner.wrap_interactors=Z.get(this.zpp_inner.interactors,true)),this.zpp_inner.wrap_interactors}get constraints(){return this.zpp_inner.wrap_constraints==null&&(this.zpp_inner.wrap_constraints=Y.get(this.zpp_inner.constraints,true)),this.zpp_inner.wrap_constraints}including(e){return new(E()).callbacks.OptionType(this).including(e)}excluding(e){return new(E()).callbacks.OptionType(this).excluding(e)}toString(){return this===e.ANY_BODY?"ANY_BODY":this===e.ANY_SHAPE?"ANY_SHAPE":this===e.ANY_COMPOUND?"ANY_COMPOUND":this===e.ANY_CONSTRAINT?"ANY_CONSTRAINT":"CbType#"+this.zpp_inner.id}static _wrap(e$1){return e$1 instanceof n?e$1:e$1?e$1 instanceof e?G$1(e$1,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e$1.zpp_inner?n._wrap(e$1.zpp_inner):null:null}},Pn=E();Pn.callbacks.CbType=ee;F$1();var V=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate InteractionType derp!")}static get COLLISION(){return a.InteractionType_COLLISION==null&&(a.internal=true,a.InteractionType_COLLISION=new n,a.internal=false),a.InteractionType_COLLISION}static get SENSOR(){return a.InteractionType_SENSOR==null&&(a.internal=true,a.InteractionType_SENSOR=new n,a.internal=false),a.InteractionType_SENSOR}static get FLUID(){return a.InteractionType_FLUID==null&&(a.internal=true,a.InteractionType_FLUID=new n,a.internal=false),a.InteractionType_FLUID}static get ANY(){return a.InteractionType_ANY==null&&(a.internal=true,a.InteractionType_ANY=new n,a.internal=false),a.InteractionType_ANY}toString(){return this===a.InteractionType_COLLISION?"COLLISION":this===a.InteractionType_SENSOR?"SENSOR":this===a.InteractionType_FLUID?"FLUID":this===a.InteractionType_ANY?"ANY":""}},En=E();En.callbacks.InteractionType=V;var K=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate PreFlag derp!")}static get ACCEPT(){return a.PreFlag_ACCEPT==null&&(a.internal=true,a.PreFlag_ACCEPT=new n,a.internal=false),a.PreFlag_ACCEPT}static get IGNORE(){return a.PreFlag_IGNORE==null&&(a.internal=true,a.PreFlag_IGNORE=new n,a.internal=false),a.PreFlag_IGNORE}static get ACCEPT_ONCE(){return a.PreFlag_ACCEPT_ONCE==null&&(a.internal=true,a.PreFlag_ACCEPT_ONCE=new n,a.internal=false),a.PreFlag_ACCEPT_ONCE}static get IGNORE_ONCE(){return a.PreFlag_IGNORE_ONCE==null&&(a.internal=true,a.PreFlag_IGNORE_ONCE=new n,a.internal=false),a.PreFlag_IGNORE_ONCE}toString(){return this===a.PreFlag_ACCEPT?"ACCEPT":this===a.PreFlag_IGNORE?"IGNORE":this===a.PreFlag_ACCEPT_ONCE?"ACCEPT_ONCE":this===a.PreFlag_IGNORE_ONCE?"IGNORE_ONCE":""}},Cn=E();Cn.callbacks.PreFlag=K;var ke=class n{get _inner(){return this}constructor(e,t){this.zpp_inner=new j,this.zpp_inner.outer=this,e!=null&&this.including(e),t!=null&&this.excluding(t);}get includes(){return this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes(),this.zpp_inner.wrap_includes}get excludes(){return this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes(),this.zpp_inner.wrap_excludes}including(e){return this.zpp_inner.append(this.zpp_inner.includes,e),this}excluding(e){return this.zpp_inner.append(this.zpp_inner.excludes,e),this}toString(){this.zpp_inner.wrap_includes==null&&this.zpp_inner.setup_includes();let e=this.zpp_inner.wrap_includes.toString();this.zpp_inner.wrap_excludes==null&&this.zpp_inner.setup_excludes();let t=this.zpp_inner.wrap_excludes.toString();return "@{"+e+" excluding "+t+"}"}static _wrap(e){return e instanceof n?e:e?e instanceof j?G$1(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):e.zpp_inner?n._wrap(e.zpp_inner):null:null}},vn=E();vn.callbacks.OptionType=ke;function Nn(n){return n===x.BEGIN?0:n===x.END?1:n===x.WAKE?2:n===x.SLEEP?3:n===x.BREAK?4:n===x.PRE?5:n===x.ONGOING?6:-1}var G=class n{get _inner(){return this}constructor(){if(!f.internal)throw new Error("Error: Cannot instantiate Listener derp!");this.zpp_inner=null;}static _wrap(e){return e instanceof n?e:e&&e instanceof f?G$1(e,t=>{if(t.outer)return t.outer;let r=Object.create(n.prototype);return r.zpp_inner=t,t.outer=r,r}):null}get type(){return f.types[this.zpp_inner.type]}get event(){return f.events[this.zpp_inner.event]}set event(e){if(e==null)throw new Error("Error: Cannot set listener event type to null");if(f.events[this.zpp_inner.event]!=e){let t=Nn(e);this.zpp_inner.swapEvent(t);}}get precedence(){return this.zpp_inner.precedence}set precedence(e){this.zpp_inner.precedence!=e&&(this.zpp_inner.precedence=e,this.zpp_inner.invalidate_precedence());}get space(){return this.zpp_inner.space==null?null:X._wrap(this.zpp_inner.space.outer)}set space(e){let t=e!=null?e._inner??e:null;if((this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=t)if(this.zpp_inner.space!=null&&this.zpp_inner.space.wrap_listeners.remove(this),t!=null){let i=t.zpp_inner.wrap_listeners;i.zpp_inner.reverse_flag?i.push(this):i.unshift(this);}else this.zpp_inner.space=null;}toString(){let t=["BEGIN","END","WAKE","SLEEP","BREAK","PRE","ONGOING"][this.zpp_inner.event];if(this.zpp_inner.type==0){let r=this.zpp_inner.body;return "BodyListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else if(this.zpp_inner.type==1){let r=this.zpp_inner.constraint;return "ConstraintListener{"+t+"::"+String(r.outer_zn.zpp_inner_zn.options.outer)+"}"}else {let r=this.zpp_inner.interaction,i;switch(r.itype){case 1:i="COLLISION";break;case 2:i="SENSOR";break;case 4:i="FLUID";break;default:i="ALL";}return this.zpp_inner.type==2?"InteractionListener{"+t+"#"+i+"::"+String(r.outer_zni.zpp_inner_zn.options1.outer)+":"+String(r.outer_zni.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence:"PreListener{"+i+"::"+String(r.outer_znp.zpp_inner_zn.options1.outer)+":"+String(r.outer_znp.zpp_inner_zn.options2.outer)+"} precedence="+this.zpp_inner.precedence}}};var Be=class n{constructor(){if(!a.internal)throw new Error("Error: Cannot instantiate ListenerType derp!")}static get BODY(){return a.ListenerType_BODY==null&&(a.internal=true,a.ListenerType_BODY=new n,a.internal=false),a.ListenerType_BODY}static get CONSTRAINT(){return a.ListenerType_CONSTRAINT==null&&(a.internal=true,a.ListenerType_CONSTRAINT=new n,a.internal=false),a.ListenerType_CONSTRAINT}static get INTERACTION(){return a.ListenerType_INTERACTION==null&&(a.internal=true,a.ListenerType_INTERACTION=new n,a.internal=false),a.ListenerType_INTERACTION}static get PRE(){return a.ListenerType_PRE==null&&(a.internal=true,a.ListenerType_PRE=new n,a.internal=false),a.ListenerType_PRE}toString(){return this===a.ListenerType_BODY?"BODY":this===a.ListenerType_CONSTRAINT?"CONSTRAINT":this===a.ListenerType_INTERACTION?"INTERACTION":this===a.ListenerType_PRE?"PRE":""}},In=E();In.callbacks.ListenerType=Be;F$1();var D=class{constructor(){this.zpp_inner=null;if(!d.internal)throw new Error("Error: Callback cannot be instantiated derp!")}get event(){return f.events[this.zpp_inner.event]}get listener(){return this.zpp_inner.listener.outer}toString(){return ""}};var Je=class extends D{get body(){return this.zpp_inner.body.outer}toString(){return "Cb:"+["WAKE","SLEEP"][this.zpp_inner.event-2]+":"+this.zpp_inner.body.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Xe=class extends D{get constraint(){return this.zpp_inner.constraint.outer}toString(){return "Cb:"+["WAKE","SLEEP","BREAK"][this.zpp_inner.event-2]+":"+this.zpp_inner.constraint.outer.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var $e=class extends D{get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get arbiters(){return this.zpp_inner.wrap_arbiters}toString(){return "Cb:"+["BEGIN","END","","","","","ONGOING"][this.zpp_inner.event]+":"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.wrap_arbiters.toString()+" : listener: "+String(this.zpp_inner.listener.outer)}};var Qe=class extends D{get arbiter(){return this.zpp_inner.pre_arbiter.wrapper()}get int1(){return this.zpp_inner.int1.outer_i}get int2(){return this.zpp_inner.int2.outer_i}get swapped(){return this.zpp_inner.pre_swapped}toString(){return "Cb:PRE::"+this.zpp_inner.int1.outer_i.toString()+"/"+this.zpp_inner.int2.outer_i.toString()+" : "+this.zpp_inner.pre_arbiter.wrapper().toString()+" : listnener: "+String(this.zpp_inner.listener.outer)}};var et=class extends G{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: BodyListener::handler cannot be null");let o;if(e===x.WAKE)o=2;else if(e===x.SLEEP)o=3;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a BodyListener");this.zpp_inner_zn=new g(j.argument(t),o,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: BodyListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};var tt=class extends G{constructor(e,t,r,i=0){if(f.internal=true,super(),f.internal=false,r==null)throw new Error("Error: ConstraintListener::handler cannot be null");let o;if(e===x.WAKE)o=2;else if(e===x.SLEEP)o=3;else if(e===x.BREAK)o=4;else throw new Error("Error: cbEvent '"+e.toString()+"' is not a valid event type for a ConstraintListener");this.zpp_inner_zn=new h$1(j.argument(t),o,r),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zn=this,this.zpp_inner.precedence=i;}get options(){return this.zpp_inner_zn.options.outer}set options(e){this.zpp_inner_zn.options.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handler}set handler(e){if(e==null)throw new Error("Error: ConstraintListener::handler cannot be null");this.zpp_inner_zn.handler=e;}};function nt(n){return n===V.COLLISION?1:n===V.SENSOR?2:n===V.FLUID?4:7}function ye(n){return n==1?V.COLLISION:n==2?V.SENSOR:n==4?V.FLUID:n==7?V.ANY:null}var ze=class extends G{constructor(e,t,r,i$1,o,s=0){if(f.internal=true,super(),f.internal=false,o==null)throw new Error("Error: InteractionListener::handler cannot be null");if(e==null)throw new Error("Error: CbEvent cannot be null for InteractionListener");let a;if(e===x.BEGIN)a=0;else if(e===x.END)a=1;else if(e===x.ONGOING)a=6;else throw new Error("Error: CbEvent '"+e.toString()+"' is not a valid event type for InteractionListener");if(this.zpp_inner_zn=new i(j.argument(r),j.argument(i$1),a,2),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_zni=this,this.zpp_inner.precedence=s,this.zpp_inner_zn.handleri=o,t==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=t&&(this.zpp_inner_zn.itype=nt(t));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handleri}set handler(e){if(e==null)throw new Error("Error: InteractionListener::handler cannot be null");this.zpp_inner_zn.handleri=e;}get interactionType(){return ye(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=nt(e));}get allowSleepingCallbacks(){return this.zpp_inner_zn.allowSleepingCallbacks}set allowSleepingCallbacks(e){this.zpp_inner_zn.allowSleepingCallbacks=e;}};var de=class extends G{constructor(e,t,r,i$1,o=0,s=false){if(f.internal=true,super(),f.internal=false,i$1==null)throw new Error("Error: PreListener must take a handler!");if(this.zpp_inner_zn=new i(j.argument(t),j.argument(r),5,3),this.zpp_inner=this.zpp_inner_zn,this.zpp_inner.outer=this,this.zpp_inner_zn.outer_znp=this,this.zpp_inner.precedence=o,this.zpp_inner_zn.pure=s,this.zpp_inner_zn.handlerp=i$1,e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=nt(e));}get options1(){return this.zpp_inner_zn.options1.outer}set options1(e){this.zpp_inner_zn.options1.set(e.zpp_inner);}get options2(){return this.zpp_inner_zn.options2.outer}set options2(e){this.zpp_inner_zn.options2.set(e.zpp_inner);}get handler(){return this.zpp_inner_zn.handlerp}set handler(e){if(e==null)throw new Error("Error: PreListener must take a non-null handler!");this.zpp_inner_zn.handlerp=e,this.zpp_inner_zn.wake();}get pure(){return this.zpp_inner_zn.pure}set pure(e){e||this.zpp_inner_zn.wake(),this.zpp_inner_zn.pure=e;}get interactionType(){return ye(this.zpp_inner_zn.itype)}set interactionType(e){if(e==null)throw new Error("Error: Cannot set listener interaction type to null");ye(this.zpp_inner_zn.itype)!=e&&(this.zpp_inner_zn.itype=nt(e));}};var rt=class n extends ka{constructor(e,t=false){if(super(),e<1)throw new Error("Error: Constraint dimension must be at least 1");let r$1=new r(e,t);this.zpp_inner=r$1,r$1.outer=this,r$1.outer_zn=this;}static _wrap(e){return e==null?null:e instanceof n?e:e.zpp_inner?.outer instanceof n?e.zpp_inner.outer:G$1(e,t=>{let r=Object.create(n.prototype);return r.zpp_inner=t.zpp_inner??t,r.zpp_inner.outer=r,r.zpp_inner.outer_zn=r,r})}__bindVec2(){let e=new H$1;return e.zpp_inner._inuse=true,e.zpp_inner._invalidate=this.zpp_inner.bindVec2_invalidate.bind(this.zpp_inner),e}__copy(){throw new Error("Error: UserConstraint::__copy must be overriden")}__broken(){}__validate(){}__draw(e){}__prepare(){}__position(e){throw new Error("Error: UserConstraint::__position must be overriden")}__velocity(e){throw new Error("Error: Userconstraint::__velocity must be overriden")}__eff_mass(e){throw new Error("Error: UserConstraint::__eff_mass must be overriden")}__clamp(e){}__impulse(e,t,r){throw new Error("Error: UserConstraint::__impulse must be overriden")}impulse(){let e=this.zpp_inner.dim,t=new J$1(e,1);for(let r=0;r<e;r++){if(r<0||r>=t.zpp_inner.m||0>=t.zpp_inner.n)throw new Error("Error: MatMN indices out of range");t.zpp_inner.x[r*t.zpp_inner.n]=this.zpp_inner.jAcc[r];}return t}bodyImpulse(e){if(e==null)throw new Error("Error: Cannot evaluate impulse on null body");let t=false;for(let r of this.zpp_inner.bodies)if(r.body==e.zpp_inner){t=true;break}if(!t)throw new Error("Error: Body is not linked to this constraint");return this.zpp_inner.active?this.zpp_inner.bodyImpulse(e.zpp_inner):I$1.get()}visitBodies(e){let t=this.zpp_inner.bodies.length,r=0;for(;r<t;){let i=this.zpp_inner.bodies[r];if(i.body!=null){let o=false;for(let s=r+1;s<t;s++)if(this.zpp_inner.bodies[s].body==i.body){o=true;break}o||e(i.body.outer);}++r;}}__invalidate(){this.zpp_inner.immutable_midstep("UserConstraint::invalidate()"),this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&this.zpp_inner.wake();}__registerBody(e,t){if(this.zpp_inner.immutable_midstep("UserConstraint::registerBody(..)"),e!=t){if(e!=null){if(!this.zpp_inner.remBody(e.zpp_inner))throw new Error("Error: oldBody is not registered to the cosntraint");this.zpp_inner.active&&(this.zpp_inner.space==null?null:this.zpp_inner.space.outer)!=null&&e.zpp_inner.wake();}t!=null&&this.zpp_inner.addBody(t.zpp_inner),this.zpp_inner.wake(),t?.zpp_inner.wake();}return t}get zpp_inner_zn(){return this.zpp_inner}set zpp_inner_zn(e){this.zpp_inner=e;}};function F(n){let{typeName:e,namespaceParts:t,zppListClass:r,wrapElement:i,unwrapElement:o}=n,s=E(),a=s.__zpp,l=()=>a.util[r],c=()=>{let u=s;for(let m=1;m<t.length;m++)u=u[t[m]];return u};function _(){if(this.zpp_next=null,this.zpp_critical=false,this.zpp_i=0,this.zpp_inner=null,!l().internal)throw new Error("Error: Cannot instantiate "+e+"Iterator derp!")}_.zpp_pool=null,_.get=function(u){let m,g=l();return _.zpp_pool==null?(g.internal=true,m=new _,g.internal=false):(m=_.zpp_pool,_.zpp_pool=m.zpp_next),m.zpp_i=0,m.zpp_inner=u,m.zpp_critical=false,m},_.prototype.zpp_inner=null,_.prototype.zpp_i=null,_.prototype.zpp_critical=null,_.prototype.zpp_next=null,_.prototype.hasNext=function(){this.zpp_inner.zpp_inner.valmod();let u=this.zpp_inner;u.zpp_inner.valmod(),u.zpp_inner.zip_length&&(u.zpp_inner.zip_length=false,u.zpp_inner.user_length=u.zpp_inner.inner.length);let m=u.zpp_inner.user_length;return this.zpp_critical=true,this.zpp_i<m?true:(this.zpp_next=_.zpp_pool,_.zpp_pool=this,this.zpp_inner=null,false)},_.prototype.next=function(){return this.zpp_critical=false,this.zpp_inner.at(this.zpp_i++)};function f(){this.zpp_inner=null,this.zpp_inner=new(l()),this.zpp_inner.outer=this;}f.fromArray=function(u){if(u==null)throw new Error("Error: Cannot convert null Array to Nape list");let m=new f;for(let g=0;g<u.length;g++)m.push(u[g]);return m},f.prototype.zpp_inner=null,f.prototype.zpp_gl=function(){return this.zpp_inner.valmod(),this.zpp_inner.zip_length&&(this.zpp_inner.zip_length=false,this.zpp_inner.user_length=this.zpp_inner.inner.length),this.zpp_inner.user_length};function d(u){return u.zpp_inner.valmod(),u.zpp_inner.zip_length&&(u.zpp_inner.zip_length=false,u.zpp_inner.user_length=u.zpp_inner.inner.length),u.zpp_inner.user_length}Object.defineProperty(f.prototype,"length",{get:function(){return d(this)}}),f.prototype.has=function(u){return this.zpp_inner.valmod(),this.zpp_inner.inner.has(o(u))},f.prototype.at=function(u){if(this.zpp_inner.valmod(),u<0||u>=d(this))throw new Error("Error: Index out of bounds");if(this.zpp_inner.reverse_flag&&(u=d(this)-1-u),u<this.zpp_inner.at_index||this.zpp_inner.at_ite==null)this.zpp_inner.at_index=u,this.zpp_inner.at_ite=this.zpp_inner.inner.iterator_at(u);else for(;this.zpp_inner.at_index!=u;)this.zpp_inner.at_index++,this.zpp_inner.at_ite=this.zpp_inner.at_ite.next;return i(this.zpp_inner.at_ite.elt)},f.prototype.push=function(u){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let m=this.zpp_inner.adder!=null?this.zpp_inner.adder(u):true;return m&&(this.zpp_inner.reverse_flag?this.zpp_inner.inner.add(o(u)):(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(d(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,o(u))),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(u)),m},f.prototype.unshift=function(u){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let m=this.zpp_inner.adder!=null?this.zpp_inner.adder(u):true;return m&&(this.zpp_inner.reverse_flag?(this.zpp_inner.push_ite==null&&(this.zpp_inner.push_ite=this.zpp_inner.inner.head==null?null:this.zpp_inner.inner.iterator_at(d(this)-1)),this.zpp_inner.push_ite=this.zpp_inner.inner.insert(this.zpp_inner.push_ite,o(u))):this.zpp_inner.inner.add(o(u)),this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(u)),m},f.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let u;if(this.zpp_inner.reverse_flag){u=this.zpp_inner.inner.head.elt;let m=i(u);this.zpp_inner.subber!=null&&this.zpp_inner.subber(m),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}else {this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let m;d(this)==1?m=null:m=this.zpp_inner.inner.iterator_at(d(this)-2),u=m==null?this.zpp_inner.inner.head.elt:m.next.elt;let g=i(u);this.zpp_inner.subber!=null&&this.zpp_inner.subber(g),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(m);}return this.zpp_inner.invalidate(),i(u)},f.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.modify_test(),this.zpp_inner.inner.head==null)throw new Error("Error: Cannot remove from empty list");this.zpp_inner.valmod();let u;if(this.zpp_inner.reverse_flag){this.zpp_inner.at_ite!=null&&this.zpp_inner.at_ite.next==null&&(this.zpp_inner.at_ite=null);let m;d(this)==1?m=null:m=this.zpp_inner.inner.iterator_at(d(this)-2),u=m==null?this.zpp_inner.inner.head.elt:m.next.elt;let g=i(u);this.zpp_inner.subber!=null&&this.zpp_inner.subber(g),this.zpp_inner.dontremove||this.zpp_inner.inner.erase(m);}else {u=this.zpp_inner.inner.head.elt;let m=i(u);this.zpp_inner.subber!=null&&this.zpp_inner.subber(m),this.zpp_inner.dontremove||this.zpp_inner.inner.pop();}return this.zpp_inner.invalidate(),i(u)},f.prototype.add=function(u){return this.zpp_inner.reverse_flag?this.push(u):this.unshift(u)},f.prototype.remove=function(u){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");this.zpp_inner.modify_test(),this.zpp_inner.valmod();let m=false,g=this.zpp_inner.inner.head,R=o(u);for(;g!=null;){if(g.elt==R){m=true;break}g=g.next;}return m&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(u),this.zpp_inner.dontremove||this.zpp_inner.inner.remove(R),this.zpp_inner.invalidate()),m},f.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: "+e+"List is immutable");if(this.zpp_inner.reverse_flag)for(;this.zpp_inner.inner.head!=null;)this.pop();else for(;this.zpp_inner.inner.head!=null;)this.shift();},f.prototype.empty=function(){return this.zpp_inner.inner.head==null},f.prototype.iterator=function(){return this.zpp_inner.valmod(),_.get(this)},f.prototype.copy=function(u){u==null&&(u=false);let m=new f,g=_.get(this);for(;g.hasNext();){let R=g.next();if(u)throw new Error("Error: "+e+" is not a copyable type");m.push(R);}return m},f.prototype.merge=function(u){if(u==null)throw new Error("Error: Cannot merge with null list");let m=_.get(u);for(;m.hasNext();){let g=m.next();this.has(g)||(this.zpp_inner.reverse_flag?this.push(g):this.unshift(g));}},f.prototype.toString=function(){let u="[",m=true,g=_.get(this);for(;g.hasNext();){let R=g.next();m||(u+=","),u+=R==null?"NULL":R.toString(),m=false;}return u+"]"},f.prototype.foreach=function(u){if(u==null)throw new Error("Error: Cannot execute null on list elements");this.zpp_inner.valmod();let m=_.get(this);for(;m.hasNext();)try{u(m.next());}catch{m.zpp_next=_.zpp_pool,_.zpp_pool=m,m.zpp_inner=null;break}return this},f.prototype.filter=function(u){if(u==null)throw new Error("Error: Cannot select elements of list with null");let m=0;for(;m<d(this);){let g=this.at(m);try{u(g)?++m:this.remove(g);}catch{break}}return this},f.prototype.toArray=function(){let u=[],m=_.get(this);for(;m.hasNext();)u.push(m.next());return u},f.prototype[Symbol.iterator]=function(){let u=_.get(this);return {next(){return u.hasNext()?{value:u.next(),done:false}:{value:void 0,done:true}},[Symbol.iterator](){return this}}};let b=c(),A=e+"Iterator",U=e+"List";return b[A]=_,b[U]=f,{Iterator:_,List:f}}var le=n=>n.outer,J=n=>n.zpp_inner??(n._inner?n._inner.zpp_inner??n._inner:n);F({typeName:"CbType",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_CbTypeList",wrapElement:le,unwrapElement:J});F({typeName:"Listener",namespaceParts:["nape","callbacks"],zppListClass:"ZPP_ListenerList",wrapElement:le,unwrapElement:J});F({typeName:"Constraint",namespaceParts:["nape","constraint"],zppListClass:"ZPP_ConstraintList",wrapElement:le,unwrapElement:J});F({typeName:"InteractionGroup",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_InteractionGroupList",wrapElement:le,unwrapElement:J});F({typeName:"GeomPoly",namespaceParts:["nape","geom"],zppListClass:"ZPP_GeomPolyList",wrapElement:le,unwrapElement:J});F({typeName:"Body",namespaceParts:["nape","phys"],zppListClass:"ZPP_BodyList",wrapElement:le,unwrapElement:J});F({typeName:"Compound",namespaceParts:["nape","phys"],zppListClass:"ZPP_CompoundList",wrapElement:le,unwrapElement:J});F({typeName:"Shape",namespaceParts:["nape","shape"],zppListClass:"ZPP_ShapeList",wrapElement:le,unwrapElement:J});F({typeName:"Arbiter",namespaceParts:["nape","dynamics"],zppListClass:"ZPP_ArbiterList",wrapElement:n=>n.wrapper(),unwrapElement:J});F({typeName:"Edge",namespaceParts:["nape","shape"],zppListClass:"ZPP_EdgeList",wrapElement:n=>n.wrapper(),unwrapElement:J});F({typeName:"ConvexResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_ConvexResultList",wrapElement:n=>n,unwrapElement:n=>n});F({typeName:"RayResult",namespaceParts:["nape","geom"],zppListClass:"ZPP_RayResultList",wrapElement:n=>n,unwrapElement:n=>n});F({typeName:"Interactor",namespaceParts:["nape","phys"],zppListClass:"ZPP_InteractorList",wrapElement:n=>n.outer_i,unwrapElement:n=>n.zpp_inner_i});function be(n){if(n.outer==null){let e=E();n.outer=new e.geom.Vec2;let t=n.outer.zpp_inner;t.outer!=null&&(t.outer.zpp_inner=null,t.outer=null),t._isimmutable=null,t._validate=null,t._invalidate=null,t.next=l.zpp_pool,l.zpp_pool=t,n.outer.zpp_inner=n;}return n.outer}function S(){this.at_index=0,this.at_ite=null,this.zip_length=false,this._length=0,this.inner=null,P.call(this),this.at_ite=null,this.at_index=0,this.zip_length=true,this._length=0;}for(let n in P.prototype)S.prototype[n]=P.prototype[n];Object.defineProperty(S.prototype,"length",{get:function(){return this.zpp_gl()},configurable:true});S.prototype.inner=null;S.prototype._length=0;S.prototype.zip_length=false;S.prototype.at_ite=null;S.prototype.at_index=0;S.get=function(n,e){e==null&&(e=false);let t=new S;return t.inner=n,t.zpp_inner.immutable=e,t};S.prototype.zpp_gl=function(){if(this.zpp_vm(),this.zip_length){this._length=0;let n=this.inner.next;for(;n!=null;)this._length++,n=n.next;this.zip_length=false;}return this._length};S.prototype.zpp_vm=function(){this.zpp_inner.validate(),this.inner.modified&&(this.zip_length=true,this._length=0,this.at_ite=null);};S.prototype.at=function(n){if(this.zpp_vm(),n<0||n>=this.zpp_gl())throw new Error("Error: Index out of bounds");for(this.zpp_inner.reverse_flag&&(n=this.zpp_gl()-1-n),(n<this.at_index||this.at_ite==null)&&(this.at_index=0,this.at_ite=this.inner.next);this.at_index!==n;)this.at_index++,this.at_ite=this.at_ite.next;return be(this.at_ite)};S.prototype.push=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag)this.inner.add(n.zpp_inner);else {let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};S.prototype.unshift=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.zpp_vm(),n.zpp_inner._inuse)throw new Error("Error: Vec2 is already in use");let e=this.zpp_inner.adder!=null?this.zpp_inner.adder(n):true;if(e){if(this.zpp_inner.reverse_flag){let t=this.inner.iterator_at(this.zpp_gl()-1);this.inner.insert(t,n.zpp_inner);}else this.inner.add(n.zpp_inner);this.zpp_inner.invalidate(),this.zpp_inner.post_adder!=null&&this.zpp_inner.post_adder(n);}return e};S.prototype.pop=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){n=this.inner.next;let e=be(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}else {this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=be(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}return this.zpp_inner.invalidate(),be(n)};S.prototype.shift=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.modify_test(),this.empty())throw new Error("Error: Cannot remove from empty list");this.zpp_vm();let n;if(this.zpp_inner.reverse_flag){this.at_ite!=null&&this.at_ite.next==null&&(this.at_ite=null);let e=this.zpp_gl()===1?null:this.inner.iterator_at(this.zpp_gl()-2);n=e==null?this.inner.next:e.next;let t=be(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(t),this.zpp_inner.dontremove||this.inner.erase(e);}else {n=this.inner.next;let e=be(n);this.zpp_inner.subber!=null&&this.zpp_inner.subber(e),this.zpp_inner.dontremove||this.inner.pop();}return this.zpp_inner.invalidate(),be(n)};S.prototype.remove=function(n){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");this.zpp_inner.modify_test(),this.zpp_vm();let e=false,t=this.inner.next;for(;t!=null;){if(n.zpp_inner===t){e=true;break}t=t.next;}return e&&(this.zpp_inner.subber!=null&&this.zpp_inner.subber(n),this.zpp_inner.dontremove||this.inner.remove(n.zpp_inner),this.zpp_inner.invalidate()),e};S.prototype.clear=function(){if(this.zpp_inner.immutable)throw new Error("Error: Vec2List is immutable");if(this.zpp_inner.reverse_flag)for(;!this.empty();)this.pop();else for(;!this.empty();)this.shift();};var Tn=E(),An=Tn.__zpp;An.util.ZPP_MixVec2List=S;var y=E();y.Config=Object.assign(y.Config||{},Ot);y.util.Debug=_t;y.geom.Vec2=H$1;y.geom.Vec3=I$1;y.geom.Mat23=Ne;y.geom.MatMN=J$1;y.geom.AABB=K$1;y.geom.Winding=L;y.geom.Ray=Q;y.geom.ConvexResult=Te;y.geom.RayResult=Ae;y.geom.Geom=je;y.geom.GeomPoly=N;y.geom.MarchingSquares=Ke;y.geom.Vec2Iterator=I;y.geom.Vec2List=P;y.geom.GeomVertexIterator=me;y.__zpp.geom.ZPP_GeomVertexIterator=M;y.__zpp.util.ZPP_ContactList=H;y.phys.Interactor=R;y.phys.Body=_;O(n=>_._wrap(n));y.phys.BodyType=$;y.phys.Compound=aa;Q$1(n=>aa._wrap(n));y.phys.FluidProperties=T$1;y.phys.Material=ba;y.phys.GravMassMode=ca;y.phys.InertiaMode=da;y.phys.MassMode=ea;y.shape.Shape=V$1;P$1(n=>V$1._wrap(n));y.shape.Circle=fa;y.shape.Polygon=ha;y.shape.Capsule=ia;y.shape.Edge=Se;y.shape.ShapeType=U;y.shape.ValidationResult=Ve;y.space.Space=X;y.space.Broadphase=ja;y.dynamics.InteractionFilter=ga;y.dynamics.InteractionGroup=Ze;y.dynamics.ArbiterType=Oe;y.dynamics.Arbiter=q;t._createColArb=()=>new He;t._createFluidArb=()=>new qe;y.dynamics.Contact=Re;y.dynamics.ContactIterator=v;y.dynamics.ContactList=T;y.callbacks.CbEvent=x;y.callbacks.CbType=ee;y.callbacks.InteractionType=V;y.callbacks.PreFlag=K;y.callbacks.OptionType=ke;y.callbacks.Listener=G;y.callbacks.ListenerType=Be;y.callbacks.Callback=D;d._createBodyCb=()=>new Je;d._createConCb=()=>new Xe;d._createIntCb=()=>new $e;d._createPreCb=()=>new Qe;y.callbacks.BodyListener=et;y.callbacks.ConstraintListener=tt;y.callbacks.InteractionListener=ze;y.callbacks.PreListener=de;y.constraint.Constraint=ka;k._createFn=(...n)=>new la(...n);m._createFn=(...n)=>new ma(...n);n._createFn=(...n)=>new na(...n);o._createFn=(...n)=>new oa(...n);p._createFn=(...n)=>new pa(...n);q$1._createFn=(...n)=>new qa(...n);s._createFn=(...n)=>new ra(...n);y.constraint.UserConstraint=rt;var Rt=class{drawSegment(e,t,r){}drawCircle(e,t,r){}drawSolidCircle(e,t,r,i){}drawPolygon(e,t){}drawSolidPolygon(e,t){}drawCapsule(e,t,r,i){}drawSolidCapsule(e,t,r,i){}drawPoint(e,t){}};function Ln(n,e){if(n==null)throw new Error("Error: vertices cannot be null");let t;if(n instanceof N){if(n.zpp_disp)throw new Error("Error: GeomPoly has been disposed and cannot be used!");t=n.copy();}else {if(!Array.isArray(n))throw new Error("Error: vertices must be an Array<Vec2> or GeomPoly");if(n.length<3)throw new Error("Error: At least 3 vertices are required, got "+n.length);for(let c=0;c<n.length;c++)if(n[c]==null)throw new Error("Error: vertices["+c+"] is null");t=new N(n);}if(t.size()<3)throw t.dispose(),new Error("Error: At least 3 vertices are required, got "+t.size());if(t.isDegenerate())throw t.dispose(),new Error("Error: Polygon is degenerate (zero area)");if(!t.isSimple())throw t.dispose(),new Error("Error: Polygon is self-intersecting");let r=e?.simplify??0;if(r>0){let c=t.simplify(r);if(t.dispose(),t=c,t.size()<3||t.isDegenerate())throw t.dispose(),new Error("Error: Polygon became degenerate after simplification (epsilon too large)")}if(!t.isClockwise()){let c=[],_=t.forwardIterator();for(;_.hasNext();){let f=_.next();c.push(H$1.get(f.x,f.y));}t.dispose(),c.reverse(),t=new N(c);}let i=e?.material,o=e?.filter,s=e?.delaunay??false,a=new _(e?.type??$.DYNAMIC,e?.position);if(t.isConvex())return a.shapes.add(new ha(t,i,o)),t.dispose(),a;let l=t.convexDecomposition(s);for(let c of l)a.shapes.add(new ha(c,i,o));return t.dispose(),a}var kt=class{constructor(e,t,r={}){this._oneWayListener=null;this._grounded=false;this._groundNormal=null;this._groundBody=null;this._onMovingPlatform=false;this._slopeAngle=0;this._wallLeft=false;this._wallRight=false;this._timeSinceGrounded=0;this.space=e,this.body=t,this._maxSlopeAngle=r.maxSlopeAngle??Math.PI/4,this._maxSlopeCos=Math.cos(this._maxSlopeAngle);let i=256;if(r.filter)this._filter=r.filter;else {let o=t.shapes;for(let s=0;s<o.length;s++){let l=o.at(s).filter;l.collisionGroup=l.collisionGroup|i;}this._filter=new ga(1,~i);}r.oneWayPlatformTag&&r.characterTag&&this._setupOneWayPlatforms(r.oneWayPlatformTag,r.characterTag);}get grounded(){return this._grounded}get groundNormal(){return this._groundNormal}get groundBody(){return this._groundBody}get timeSinceGrounded(){return this._timeSinceGrounded}get maxSlopeAngle(){return this._maxSlopeAngle}set maxSlopeAngle(e){this._maxSlopeAngle=e,this._maxSlopeCos=Math.cos(e);}setVelocity(e,t){this.body.velocity=new H$1(e,t);}update(){this._wallLeft=false,this._wallRight=false;let e=this.body.position.x,t=this.body.position.y;return this._detectGround(e,t),this._detectWalls(e,t),this._grounded&&this._groundBody?this._onMovingPlatform=this._groundBody.type===$.KINEMATIC:this._onMovingPlatform=false,this._grounded?this._timeSinceGrounded=0:this._timeSinceGrounded+=1/60,{grounded:this._grounded,groundNormal:this._groundNormal,groundBody:this._groundBody,onMovingPlatform:this._onMovingPlatform,slopeAngle:this._slopeAngle,wallLeft:this._wallLeft,wallRight:this._wallRight,timeSinceGrounded:this._timeSinceGrounded}}destroy(){this._oneWayListener&&(this._oneWayListener.space=null,this._oneWayListener=null);}_detectGround(e,t){let i=this._getCharacterRadius(0,1)+4,o=new Q(new H$1(e,t),new H$1(0,1));o.maxDistance=i;let s=this.space.rayCast(o,false,this._filter);if(s&&s.distance<=i){let a=s.normal.y;if(a<0){let l=-a;if(l>=this._maxSlopeCos){this._grounded=true,this._groundNormal=new H$1(s.normal.x,s.normal.y),this._groundBody=s.shape?.body??null,this._slopeAngle=Math.acos(Math.min(1,l));return}}}this._grounded=false,this._groundNormal=null,this._groundBody=null,this._slopeAngle=0;}_detectWalls(e,t){let i=this._getCharacterRadius(1,0)+2,o=new Q(new H$1(e,t),new H$1(-1,0));o.maxDistance=i;let s=this.space.rayCast(o,false,this._filter);s&&s.distance<=i&&Math.abs(s.normal.x)>.7&&(this._wallLeft=true);let a=new Q(new H$1(e,t),new H$1(1,0));a.maxDistance=i;let l=this.space.rayCast(a,false,this._filter);l&&l.distance<=i&&Math.abs(l.normal.x)>.7&&(this._wallRight=true);}_setupOneWayPlatforms(e,t){let r=new de(V.COLLISION,e,t,i=>{try{let o=i.arbiter.collisionArbiter;if(!o)return K.ACCEPT;let s=o.normal.y,a=i.swapped;return s>0!==a?K.IGNORE:K.ACCEPT}catch{return K.ACCEPT}},0,true);r.space=this.space,this._oneWayListener=r;}_getCharacterRadius(e,t){let r=this.body.shapes.at(0);if(!r)return 0;if(r.isCircle())return r.castCircle?.radius??0;if(r.isCapsule()){let a=r.castCapsule;if(a){let l=a.radius,c=a.halfLength,_=this.body.rotation,f=Math.cos(_),d=Math.sin(_);return Math.abs(e*f+t*d)*c+l}}let i=r.bounds,o=i.width/2,s=i.height/2;return Math.abs(e)*o+Math.abs(t)*s}};var Bt=class{constructor(e,t,r){this._enabled=true;this._enterListener=null;this._stayListener=null;this._exitListener=null;this._space=e,this._body=t,this._filter=r?.filter??null,this._interactionType=r?.interactionType??V.SENSOR;for(let i=0;i<t.shapes.length;i++){let o=t.shapes.at(i);o.sensorEnabled||(o.sensorEnabled=true);}this.cbType=new ee,t.cbTypes.add(this.cbType),this._onEnter=r?.onEnter??null,this._onStay=r?.onStay??null,this._onExit=r?.onExit??null,this._syncListeners();}get onEnter(){return this._onEnter}set onEnter(e){this._onEnter=e,this._syncListeners();}get onStay(){return this._onStay}set onStay(e){this._onStay=e,this._syncListeners();}get onExit(){return this._onExit}set onExit(e){this._onExit=e,this._syncListeners();}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._syncListeners());}get body(){return this._body}get space(){return this._space}dispose(){this._removeListener("enter"),this._removeListener("stay"),this._removeListener("exit"),this._body.cbTypes.remove(this.cbType),this._enabled=false;}_resolveOther(e){let t=e.int1,r=e.int2;return t===this._body?r:r===this._body?t:t.id===this._body.id?r:t}_syncListeners(){this._enabled&&this._onEnter?this._enterListener||(this._enterListener=this._createListener(x.BEGIN,e=>{this._onEnter?.(this._resolveOther(e));})):this._removeListener("enter"),this._enabled&&this._onStay?this._stayListener||(this._stayListener=this._createListener(x.ONGOING,e=>{this._onStay?.(this._resolveOther(e));})):this._removeListener("stay"),this._enabled&&this._onExit?this._exitListener||(this._exitListener=this._createListener(x.END,e=>{this._onExit?.(this._resolveOther(e));})):this._removeListener("exit");}_createListener(e,t){let r=this._filter??ee.ANY_BODY,i=new ze(e,this._interactionType,this.cbType,r,t);return this._space.listeners.add(i),i}_removeListener(e){let t=e==="enter"?"_enterListener":e==="stay"?"_stayListener":"_exitListener",r=this[t];r&&(r.space=null,this[t]=null);}};function Ft(n,e){let t=n.length;if(t===0)return {cells:[]};let r=[{x:e.minX,y:e.minY},{x:e.maxX,y:e.minY},{x:e.maxX,y:e.maxY},{x:e.minX,y:e.maxY}];if(t===1)return {cells:[{siteIndex:0,site:{x:n[0].x,y:n[0].y},vertices:r.map(o=>({...o}))}]};let i=[];for(let o=0;o<t;o++){let s=n[o],a=r.map(l=>({x:l.x,y:l.y}));for(let l=0;l<t;l++){if(o===l)continue;if(a.length<3)break;let c=n[l],_=(s.x+c.x)/2,f=(s.y+c.y)/2,d=s.x-c.x,b=s.y-c.y;a=Sn(a,_,f,d,b);}if(a.length>=3)i.push({siteIndex:o,site:{x:s.x,y:s.y},vertices:Vn(a)});else {let l=Math.min(e.maxX-e.minX,e.maxY-e.minY)*.001;i.push({siteIndex:o,site:{x:s.x,y:s.y},vertices:[{x:s.x-l,y:s.y-l},{x:s.x+l,y:s.y-l},{x:s.x+l,y:s.y+l},{x:s.x-l,y:s.y+l}]});}}return {cells:i}}function Sn(n,e,t,r,i){if(n.length===0)return [];let o=[];for(let s=0;s<n.length;s++){let a=n[s],l=n[(s+n.length-1)%n.length],c=(a.x-e)*r+(a.y-t)*i,_=(l.x-e)*r+(l.y-t)*i;if(c>=-1e-10){if(_<-1e-10){let f=_/(_-c);o.push({x:l.x+f*(a.x-l.x),y:l.y+f*(a.y-l.y)});}o.push(a);}else if(_>=-1e-10){let f=_/(_-c);o.push({x:l.x+f*(a.x-l.x),y:l.y+f*(a.y-l.y)});}}return o}function Vn(n){if(n.length<=2)return n;let e=0,t=0;for(let r of n)e+=r.x,t+=r.y;return e/=n.length,t/=n.length,n.sort((r,i)=>Math.atan2(r.y-t,r.x-e)-Math.atan2(i.y-t,i.x-e))}function Mt(n,e,t=Math.random){if(e<=0||n.length<3)return [];let r=1/0,i=1/0,o=-1/0,s=-1/0;for(let _ of n)_.x<r&&(r=_.x),_.y<i&&(i=_.y),_.x>o&&(o=_.x),_.y>s&&(s=_.y);let a=[],l=0,c=e*100;for(;a.length<e&&l<c;){l++;let _=r+t()*(o-r),f=i+t()*(s-i);Zn(_,f,n)&&a.push({x:_,y:f});}return a}function Zn(n,e,t){let r=false,i=t.length;for(let o=0,s=i-1;o<i;s=o++){let a=t[o].x,l=t[o].y,c=t[s].x,_=t[s].y;l>e!=_>e&&n<(c-a)*(e-l)/(_-l)+a&&(r=!r);}return r}function On(n,e,t){let r=t?.fragmentCount??8,i=t?.explosionImpulse??0,o=t?.random??Math.random,s=t?.addToSpace??true,a=Rn(n);if(!a)throw new Error("Error: fractureBody requires a body with at least one Polygon shape");let l=kn(a);if(l.length<3)throw new Error("Error: Polygon shape has fewer than 3 world vertices");let c=1/0,_$1=1/0,f=-1/0,d=-1/0;for(let Z of l)Z.x<c&&(c=Z.x),Z.y<_$1&&(_$1=Z.y),Z.x>f&&(f=Z.x),Z.y>d&&(d=Z.y);let b;if(t?.sites){let Z=Math.cos(n.rotation),te=Math.sin(n.rotation),ne=n.position.x,re=n.position.y;b=t.sites.map(X=>({x:ne+X.x*Z-X.y*te,y:re+X.x*te+X.y*Z}));}else b=Mt(l,r,o);if(b.length<2)return {fragments:[n],originalBody:n};let A=1,U=Ft(b,{minX:c-A,minY:_$1-A,maxX:f+A,maxY:d+A}),u=n.velocity.x,m=n.velocity.y,g=n.angularVel,R=t?.material??Bn(n),ge=t?.filter,Fe=n.space,mt=e.x,we=e.y,xe=[];for(let Z of U.cells){let te=Mn(Z.vertices,l);if(te.length<3)continue;let ne=0,re=0;for(let k of te)ne+=k.x,re+=k.y;ne/=te.length,re/=te.length;let X=[];for(let k of te)X.push(H$1.get(k.x-ne,k.y-re));let an=Fn(X);if(Math.abs(an)<1){for(let k of X)k.dispose();continue}let Pe=new _($.DYNAMIC,H$1.get(ne,re)),ln=new ha(X,R,ge);Pe.shapes.add(ln);let _n=ne-n.position.x,un=re-n.position.y,hn=u-g*un,cn=m+g*_n;if(Pe.velocity=H$1.get(hn,cn),Pe.angularVel=g*.5,i>0){let k=ne-mt,Ee=re-we,Me=Math.sqrt(k*k+Ee*Ee)||1,fn=H$1.get(k/Me*i,Ee/Me*i);Pe.applyImpulse(fn);}if(n.userData!=null){let k=n.userData,Ee=Pe.userData;for(let Me of Object.keys(k))Ee[Me]=k[Me];Ee._fractureFragment=true;}xe.push(Pe);}if(s&&Fe!=null){n.space=null;for(let Z of xe)Z.space=Fe;}return {fragments:xe,originalBody:n}}function Rn(n){for(let e of n.shapes)if(e.isPolygon())return e.castPolygon;return null}function kn(n){let e=[],t=n.worldVerts,r=t.length;for(let i=0;i<r;i++){let o=t.at(i);e.push({x:o.x,y:o.y});}return e}function Bn(n){for(let e of n.shapes)return e.material}function Fn(n){let e=0,t=n.length;for(let r=0;r<t;r++){let i=(r+1)%t;e+=n[r].x*n[i].y,e-=n[i].x*n[r].y;}return e/2}function Mn(n,e){let t=n.slice(),r=e.length;for(let i=0;i<r;i++){if(t.length===0)return [];let o=t;t=[];let s=e[i],a=e[(i+1)%r],l=a.x-s.x,c=a.y-s.y;for(let _=0;_<o.length;_++){let f=o[_],d=o[(_+o.length-1)%o.length],b=l*(f.y-s.y)-c*(f.x-s.x),A=l*(d.y-s.y)-c*(d.x-s.x);b>=0?(A<0&&t.push(sn(d,f,s,a)),t.push(f)):A>=0&&t.push(sn(d,f,s,a));}}return t}function sn(n,e,t,r){let i=n.x,o=n.y,s=e.x,a=e.y,l=t.x,c=t.y,_=r.x,f=r.y,d=(i-s)*(c-f)-(o-a)*(l-_);if(Math.abs(d)<1e-12)return {x:(i+s)/2,y:(o+a)/2};let b=((i-l)*(c-f)-(o-c)*(l-_))/d;return {x:i+b*(s-i),y:o+b*(a-o)}}var Ms="3.22.1";export{q as Arbiter,Oe as ArbiterType,Je as BodyCallback,et as BodyListener,D as Callback,x as CbEvent,ee as CbType,kt as CharacterController,He as CollisionArbiter,Xe as ConstraintCallback,tt as ConstraintListener,Re as Contact,Te as ConvexResult,Rt as DebugDraw,Se as Edge,qe as FluidArbiter,je as Geom,$e as InteractionCallback,Ze as InteractionGroup,ze as InteractionListener,V as InteractionType,G as Listener,Be as ListenerType,Ke as MarchingSquares,Ne as Mat23,ke as OptionType,Qe as PreCallback,K as PreFlag,de as PreListener,Q as Ray,Ae as RayResult,Bt as TriggerZone,rt as UserConstraint,Ms as VERSION,Ve as ValidationResult,Ft as computeVoronoi,Ln as createConcaveBody,On as fractureBody,Mt as generateFractureSites};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/llms-full.txt
CHANGED
|
@@ -1476,6 +1476,47 @@ const bodyArray = space.bodies.toArray();
|
|
|
1476
1476
|
|
|
1477
1477
|
---
|
|
1478
1478
|
|
|
1479
|
+
## Destruction / Fracture
|
|
1480
|
+
|
|
1481
|
+
Voronoi-based body fracture system — unique among JS physics engines.
|
|
1482
|
+
|
|
1483
|
+
### fractureBody(body, impactPoint, options?)
|
|
1484
|
+
|
|
1485
|
+
Shatters a polygon body into Voronoi-generated fragments.
|
|
1486
|
+
|
|
1487
|
+
```typescript
|
|
1488
|
+
import { fractureBody } from "@newkrok/nape-js";
|
|
1489
|
+
|
|
1490
|
+
const result = fractureBody(body, impactPoint, {
|
|
1491
|
+
fragmentCount: 6, // number of Voronoi fragments (default: 8)
|
|
1492
|
+
explosionImpulse: 30, // radial blast impulse in px/s (default: 0)
|
|
1493
|
+
material: myMaterial, // override fragment material (default: original body's)
|
|
1494
|
+
filter: myFilter, // collision filter for fragments
|
|
1495
|
+
addToSpace: true, // auto-add fragments to space (default: true)
|
|
1496
|
+
random: Math.random, // custom RNG for deterministic fracture
|
|
1497
|
+
sites: customPoints, // pre-computed Voronoi sites (body-local coords)
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
result.fragments; // Body[] — new fragment bodies
|
|
1501
|
+
result.originalBody; // Body — original (removed from space when addToSpace=true)
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
### computeVoronoi(points, bounds)
|
|
1505
|
+
|
|
1506
|
+
Raw Voronoi diagram computation. Returns `VoronoiResult` with `cells` array.
|
|
1507
|
+
|
|
1508
|
+
### generateFractureSites(vertices, count, random?)
|
|
1509
|
+
|
|
1510
|
+
Generate random points inside a polygon for use as Voronoi sites.
|
|
1511
|
+
|
|
1512
|
+
**Gotchas:**
|
|
1513
|
+
- Only works on **polygon** shapes (circles/capsules throw).
|
|
1514
|
+
- Must `setTimeout` fracture calls inside collision listeners — modifying the space during a callback throws.
|
|
1515
|
+
- Fragments inherit the original body's velocity. Use `explosionImpulse > 0` for blast scatter.
|
|
1516
|
+
- Pass a seeded `random` for deterministic multiplayer.
|
|
1517
|
+
|
|
1518
|
+
---
|
|
1519
|
+
|
|
1479
1520
|
## Common Patterns
|
|
1480
1521
|
|
|
1481
1522
|
### Adding Bodies to Space
|
|
@@ -1633,6 +1674,9 @@ import {
|
|
|
1633
1674
|
AngleJoint, WeldJoint, MotorJoint,
|
|
1634
1675
|
LineJoint, PulleyJoint,
|
|
1635
1676
|
|
|
1677
|
+
// Destruction / Fracture
|
|
1678
|
+
fractureBody, computeVoronoi, generateFractureSites,
|
|
1679
|
+
|
|
1636
1680
|
// Utilities
|
|
1637
1681
|
NapeList, VERSION
|
|
1638
1682
|
} from "@newkrok/nape-js";
|
package/llms.txt
CHANGED
|
@@ -88,6 +88,12 @@ function update() {
|
|
|
88
88
|
- [Geom](https://newkrok.github.io/nape-js/api/classes/Geom.html): Static utilities — distance queries, ray tests, polygon operations
|
|
89
89
|
- [MarchingSquares](https://newkrok.github.io/nape-js/api/classes/MarchingSquares.html): Contour extraction from scalar fields
|
|
90
90
|
|
|
91
|
+
## Destruction / Fracture
|
|
92
|
+
|
|
93
|
+
- [fractureBody](https://newkrok.github.io/nape-js/api/functions/fractureBody.html): Shatter a polygon body into Voronoi fragments — `fractureBody(body, impactPoint, { fragmentCount?, explosionImpulse?, random? })`
|
|
94
|
+
- [computeVoronoi](https://newkrok.github.io/nape-js/api/functions/computeVoronoi.html): Raw Voronoi diagram computation from point set
|
|
95
|
+
- [generateFractureSites](https://newkrok.github.io/nape-js/api/functions/generateFractureSites.html): Generate random fracture site points within a polygon
|
|
96
|
+
|
|
91
97
|
## Enums
|
|
92
98
|
|
|
93
99
|
- [BodyType](https://newkrok.github.io/nape-js/api/classes/BodyType.html): STATIC, DYNAMIC, KINEMATIC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newkrok/nape-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"description": "High-performance 2D physics engine for TypeScript & JavaScript — rigid bodies, constraints, fluid simulation, raycasting, and deterministic multiplayer. Tree-shakeable, zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|