entt-js 0.0.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/README.md +552 -0
- package/dist/browser/entt.js +4004 -0
- package/dist/browser/entt.min.js +1 -0
- package/dist/browser/index.js +3929 -0
- package/dist/browser/index.min.js +1 -0
- package/dist/entt.d.ts +1069 -0
- package/dist/entt.js +3944 -0
- package/dist/entt.min.js +1 -0
- package/package.json +77 -0
package/dist/entt.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"stable-hash";const t=(function(){class e extends TypeError{constructor(e){super(e)}}return Object.defineProperty(e.prototype,`name`,{value:`NotConstructorError`,configurable:!0}),e})();function n(e,t){if(typeof e.clone==`function`)return e.clone();let n=Object.getOwnPropertyDescriptors(e);t??=Object.create(Object.getPrototypeOf(e));for(let[e,i]of Object.entries(n))Object.defineProperty(t,e,{...i,...`value`in i?{value:r(i.value)}:void 0});return t}function r(e){let t=typeof e;if(t!==`object`||e===null){if(t===`symbol`){if(Symbol.keyFor(e)!=null)throw Error(`Cannot clone global symbol`);return Symbol(e.description)}return t===`function`?function(){return e.apply(this,arguments)}:e}if(Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof DataView||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error||e instanceof Number||e instanceof String||e instanceof Boolean)try{let t=structuredClone(e);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}catch{if(Array.isArray(e))return e.map(e=>r(e));if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e))return new e.constructor(e.buffer,e.byteOffset,e.byteLength/e.constructor.BYTES_PER_ELEMENT);if(e instanceof DataView)return new DataView(e.buffer,e.byteOffset,e.byteLength);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(r(n),r(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(r(e))}),t}if(e instanceof Error)return n(e,new e.constructor(e.message));if(e instanceof Number||e instanceof String||e instanceof Boolean){let t=e.constructor;return new t(e.valueOf())}}return e instanceof Promise?e.then(r):n(e)}function i(e){let t=typeof e==`bigint`;t||(e>>>=0);let n=t?BigInt(1):1;return e?Number((e&n)+(t?BigInt(i(e>>n)):i(e>>>n))):0}function a(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,writable:!0})}function o(e,t){Object.setPrototypeOf(e,t),Object.setPrototypeOf(e.prototype,t.prototype),Object.defineProperty(e,`super_`,{value:t,writable:!0,configurable:!0})}function s(e,t){return Number(e&t-1n)}function c(e,t){let n=e;do{if(t.includes(n))return n;n=Object.getPrototypeOf(n)}while(n!=null);return null}const l=(e,t)=>e<t?-1:e>t?1:0;function u(e,t=l){return e.sort(t)}function d(e,t=l){let n=e.length;if(n>0)for(let r=1;r<n;++r){let n=e[r],i=r;for(;i>0&&t(n,e[i-1])<0;--i)e[i]=e[i-1];e[i]=n}return e}function f(e){return Array.isArray(e)?e:typeof e==`function`||e===void 0?[e,e]:[null,e]}var p=class{value;constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}};const m=(function(){let e=function(e){return typeof e==`bigint`?Math.fround(Number(e&BigInt(255))):e&255};return o(e,Number),Object.defineProperty(e,`MIN_VALUE`,{value:0}),Object.defineProperty(e,`MAX_VALUE`,{value:255}),a(e,`is`,function(t){return typeof t==`number`||Object.getPrototypeOf(t)===Number.prototype?e(t)===Number(t):!1}),e})(),h=(function(){let e=function(e){return typeof e==`bigint`?Math.fround(Number(e&BigInt(4294967295))|0):Math.fround(e??0)};return o(e,Number),e})(),ee=(function(){let e=function(e){return Number(e??0)};return o(e,Number),e})(),g=(function(){let e=function(e){return typeof e==`bigint`?Number(e&BigInt(255))<<24>>24:e<<24>>24};return o(e,Number),Object.defineProperty(e,`MIN_VALUE`,{value:-128}),Object.defineProperty(e,`MAX_VALUE`,{value:127}),a(e,`is`,function(t){return typeof t==`number`||Object.getPrototypeOf(t)===Number.prototype?e(t)===Number(t):!1}),e})(),_=(function(){let e=function(e){return typeof e==`bigint`?Number(e&BigInt(65535)):e&65535};return o(e,Number),Object.defineProperty(e,`MIN_VALUE`,{value:0}),Object.defineProperty(e,`MAX_VALUE`,{value:65535}),a(e,`is`,function(t){return typeof t==`number`||Object.getPrototypeOf(t)===Number.prototype?e(t)===Number(t):!1}),e})(),v=(function(){let e=function(e){return typeof e==`bigint`?Number(e&BigInt(65535))<<16>>16:e<<16>>16};return o(e,Number),Object.defineProperty(e,`MIN_VALUE`,{value:-32768}),Object.defineProperty(e,`MAX_VALUE`,{value:32767}),a(e,`is`,function(t){return typeof t==`number`||Object.getPrototypeOf(t)===Number.prototype?e(t)===Number(t):!1}),e})(),y=(function(){let e=function(e){return typeof e==`bigint`?Number(e&BigInt(4294967295)):(e|0)>>>0};return o(e,Number),Object.defineProperty(e,`MIN_VALUE`,{value:0}),Object.defineProperty(e,`MAX_VALUE`,{value:4294967295}),a(e,`is`,function(t){return typeof t==`number`||Object.getPrototypeOf(t)===Number.prototype?e(t)===Number(t):!1}),e})(),te=(function(){let e=function(e){return typeof e==`bigint`?Number(e&BigInt(4294967295))|0:e|0};return o(e,Number),Object.defineProperty(e,`MIN_VALUE`,{value:-2147483648}),Object.defineProperty(e,`MAX_VALUE`,{value:2147483647}),a(e,`is`,function(t){return typeof t==`number`||Object.getPrototypeOf(t)===Number.prototype?e(t)===Number(t):!1}),e})(),b=BigInt(`0xFFFFFFFFFFFFFFFF`),x=(function(){let e=function(e){if(e==null)return BigInt(0);try{return BigInt(e)&b}catch{return BigInt(0)}};return o(e,BigInt),Object.defineProperty(e,`MIN_VALUE`,{value:BigInt(0)}),Object.defineProperty(e,`MAX_VALUE`,{value:b}),a(e,`is`,function(t){return typeof t==`bigint`||Object.getPrototypeOf(t)===BigInt.prototype?e(t)===BigInt(t):!1}),e})(),ne=(function(){let e=-BigInt(`0x8000000000000000`),t=BigInt(`0x7FFFFFFFFFFFFFFF`),n=function(n){if(n==null)return BigInt(0);try{let r=BigInt(n);return r<e?r&b:r>t?(r&b)-(b+BigInt(1)):r}catch{return BigInt(0)}};return o(n,BigInt),Object.defineProperty(n,`MIN_VALUE`,{value:e}),Object.defineProperty(n,`MAX_VALUE`,{value:t}),a(n,`is`,function(e){return typeof e==`bigint`||Object.getPrototypeOf(e)===BigInt.prototype?n(e)===BigInt(e):!1}),n})(),S=(function(){let e=function(e){return y(e)};return o(e,y),e})(),C={Disabled:0,Static:1,0:`Disabled`,1:`Static`},w=(e,...t)=>e(...t),T=(()=>{let e=new WeakMap;return e.set(Boolean,w),e.set(Number,w),e.set(String,w),e.set(Symbol,w),e.set(S,w),e.set(m,w),e.set(g,w),e.set(_,w),e.set(v,w),e.set(y,w),e.set(te,w),e.set(x,w),e.set(ne,w),e.set(h,w),e.set(ee,w),e.set(BigInt,(e,...t)=>e(t.length===0?0:t[0])),{customCalls:e,emptyClasses:new WeakMap,eto:typeof ENTT_NO_ETO<`u`&&ENTT_NO_ETO?C.Disabled:C.Static,mixin:typeof ENTT_NO_MIXIN<`u`?!ENTT_NO_MIXIN:!0,sparsePage:typeof ENTT_SPARSE_PAGE<`u`?Number(ENTT_SPARSE_PAGE):4096,packedPage:typeof ENTT_PACKED_PAGE<`u`?Number(ENTT_PACKED_PAGE):1024}})();function E(e){if(T.customCalls.has(e)){let t=T.customCalls.get(e);return(...n)=>t(e,...n)}return(...n)=>{try{return new e(...n)}catch(r){if(r instanceof t||r instanceof TypeError&&r.message.includes(`is not a constructor`))return e(...n);throw r}}}function re(e,t){if(!t)return``;let n=0,r=t.index+t[0].length-1,i=r;do{let t=e[i];t===`{`?n++:t===`}`&&n--,i++}while(n>0&&i<e.length);return e.slice(r,i)}function ie(e){if(T.eto===C.Disabled||typeof e!=`function`||e.prototype==null)return!1;if(T.emptyClasses.has(e))return T.emptyClasses.get(e);if(T.eto===C.Static){let t=``;try{t=Function.prototype.toString.call(e)}catch{return!1}if(t.startsWith(`class`)){let n=t.match(/^class\s+\w*(\s+extends\s+[\w$]+)?\s*{/),r=re(t,n);if(!r)throw Error(`impossible`);return/^\{\s*(\r?\n)*\s*\}$/.test(r)?n[1]?ie(Object.getPrototypeOf(e)):!0:!1}else if(t.startsWith(`function`)){let e=re(t,t.match(/^function\s+\w*\s*\(([^)]*)\)\s*{/));if(e)return e===`{ [native code] }`?!1:!/this|return/.test(e);throw Error(`impossible`)}else return!1}return!1}const D=(function(){class e{dispose(){}[Symbol.dispose](){this.dispose()}}return typeof Symbol.dispose!=`symbol`&&delete e.prototype[Symbol.dispose],e})();var ae=class extends D{_registry;_specializations;instantiate;defaultRender;constructor(t,n=[]){super();let r=new Map;this._registry=r,this.defaultRender=t,this._specializations=n.map(e=>({...e,userland:!1})),this.instantiate=function(...n){let i=this.selectSpecialization(...n)??t,a=e([i,n]);if(r.has(a))return r.get(a);let o=i.apply(this,n);return r.set(a,o),o}}selectSpecialization(...e){for(let t of this._specializations)if(t.predicate.apply(this,e))return t.render;return null}addSpecialization(e){this._specializations.push({...e,userland:!0})}removeSpecialization(e){let t=this._specializations.findIndex(t=>t.predicate===e.predicate&&t.render===e.render&&t.userland);t!==-1&&this._specializations.splice(t,1)}removeAllUserlandSpecializations(){this._specializations=this._specializations.filter(e=>!e.userland)}dispose(){this._registry.clear(),this._specializations.length=0}};function O(e,t=[]){return new ae(e,t)}const oe=O(function(e){if(typeof e==`function`&&e.prototype!=null){let t=c(e,[Number,BigInt,y,x]);if(t){let n=this.selectSpecialization(t).call(this,t);return n.ValueType=e,n}let n=e.EntityType;if(!n)throw TypeError(`Invalid EntityType`);let r=oe.instantiate(n);return r.ValueType=e,r}throw TypeError(`Invalid ValueType`)},[{predicate:e=>e===Number,render:function(){return{ValueType:Number,EntityType:Number,VersionType:Number,entityMask:1048575,versionMask:4095}}},{predicate:e=>e===BigInt,render:function(){return{ValueType:BigInt,EntityType:BigInt,VersionType:Number,entityMask:BigInt(4294967295),versionMask:BigInt(4294967295)}}},{predicate:e=>e===y,render:function(){return{ValueType:y,EntityType:y,VersionType:_,entityMask:y(1048575),versionMask:y(4095)}}},{predicate:e=>e===x,render:function(){return{ValueType:x,EntityType:x,VersionType:y,entityMask:x(4294967295),versionMask:x(4294967295)}}}]),se=O(function(e){let{ValueType:t,EntityType:n,VersionType:r,entityMask:a,versionMask:o}=e,s=i(a),l=E(t),u=n===Number?e=>n(e)>>>0:e=>n(e),d=(e=>u(e)&a),f=r===Number?e=>r(o?u(e)>>n(s)&o:0)>>>0:e=>r(o?u(e)>>n(s)&o:0),p=c(t,[Number,BigInt])?e=>t(e):e=>l(e),m=(e,t)=>{let r=n(e)&a;return o&&(r|=(n(t)&o)<<n(s)),r},h=n===Number?(e,t)=>p(m(e,t)>>>0):(e,t)=>p(n(m(e,t))),ee=(e=>{let t=f(e)+r(1);return h(u(e),t+r(t===o?1:0))}),g=(e,t)=>{let r=n(e)&a;return o&&(r|=n(t)&o<<n(s)),r},_=n===Number?(e,t)=>p(g(e,t)>>>0):(e,t)=>p(n(g(e,t))),v=h(a,o),y=h(a,o);return{ValueType:t,EntityType:n,VersionType:r,entityMask:a,versionMask:o,length:s,null:v,tombstone:y,toIntegral:u,toEntity:d,toVersion:f,next:ee,construct:h,combine:_,isNull:e=>d(e)===d(v),isTombstone:o?e=>f(e)===f(y):e=>u(e)===u(y)}}),k=O(function(e){let t=oe.instantiate(e),n=se.instantiate(t);return{...n,BaseType:n,pageSize:T.sparsePage}});var A=class e{it;constructor(e){this.it=e.clone()}clone(t){return t?(this===t||this.it.clone(t.it),t):new e(this.it)}swap(e){this!==e&&this.it.swap(e.it)}base(){return this.it.clone()}selfPlus(e=1){return this.it.selfMinus(e),this}selfMinus(e=1){return this.it.selfPlus(e),this}plus(t){return new e(this.it.minus(t))}minus(t){return new e(this.it.plus(t))}diff(e){return e.it.diff(this.it)}equals(e){return this.it.equals(e.it)}lt(e){return this.it.gt(e.it)}gt(e){return this.it.lt(e.it)}le(e){return this.it.ge(e.it)}ge(e){return this.it.le(e.it)}deref(){return this.it.clone().selfMinus().deref()}write(e){return this.it.write(e)}access(e){return this.it.access(-1-e)}set(e,t){this.it.set(-1-e,t)}};function j(e){return new A(e)}function M(e,t){return[t==null?e.begin():e.clone(),t==null?e.end():t.clone()]}var N=class extends Iterator{first;curr;last;constructor(e,t){super(),this.first=e.clone(),this.last=t.clone(),this.curr=e.clone()}begin(){return this.first.clone()}end(){return this.last.clone()}next(){if(this.curr.equals(this.last))return{done:!0,value:void 0};let e=this.curr.deref();return this.curr.selfPlus(),{done:!1,value:e}}[Symbol.iterator](){return this}},P=class e{pointers;constructor(e){this.pointers=e}base(){return this.pointers[0]}deref(){return this.pointers.map(e=>e.deref())}write(e){return this.pointers.forEach((t,n)=>t.write(e[n])),e}clone(t){return t?(this===t||this.pointers.forEach((e,n)=>{t.pointers[n]=e.clone()}),t):new e(this.pointers.map(e=>e.clone()))}swap(e){if(this===e)return;let t=this.pointers;this.pointers=e.pointers,e.pointers=t}selfPlus(){return this.pointers.forEach(e=>e.selfPlus()),this}equals(e){return this.pointers.every((t,n)=>t.equals(e.pointers[n]))}};function F(e,t){let[n,r]=M(e,t);return new N(n,r)}var ce=class e{array;pos;constructor(e,t){this.array=e,this.pos=t}clone(t){return t?this===t?t:(t.array=this.array,t.pos=this.pos,t):new e(this.array,this.pos)}swap(e){if(this===e)return;let t=this.array,n=this.pos;this.array=e.array,this.pos=e.pos,e.array=t,e.pos=n}selfPlus(e=1){return this.pos+=e,this}plus(t){return new e(this.array,this.pos+t)}selfMinus(e=1){return this.pos-=e,this}minus(t){return new e(this.array,this.pos-t)}diff(e){return this.pos-e.pos}lt(e){return this.pos<e.pos}gt(e){return this.pos>e.pos}le(e){return this.pos<=e.pos}ge(e){return this.pos>=e.pos}equals(e){return this.pos===e.pos}deref(){return this.array[this.pos]}write(e){return this.array[this.pos]=e,e}access(e){return this.array[this.pos+e]}set(e,t){this.array[this.pos+e]=t}},le=class{array;constructor(e){this.array=e}data(){return this.array}begin(){return new ce(this.array,0)}end(){return new ce(this.array,this.array.length)}rbegin(){return new A(this.end())}rend(){return new A(this.begin())}[Symbol.iterator](){return F(this)}};function I(e){if(Array.isArray(e))return new le(e);throw Error(`Invalid argument`)}function ue(e,t){if(e=e.clone(),t=t.clone(),typeof e.diff==`function`&&typeof t.diff==`function`)return t.diff(e);let n=0;for(;!e.equals(t);e.selfPlus())++n;return n}const L={SwapAndPop:0,InPlace:1,SwapOnly:2,Unspecified:0,0:`SwapAndPop`,1:`InPlace`,2:`SwapOnly`};var R=class e{packed;offset;constructor(e=null,t=0){this.packed=e,this.offset=t}clone(t){return t?this===t?t:(t.packed=this.packed,t.offset=this.offset,t):new e(this.packed,this.offset)}swap(e){if(this===e)return;let t=this.packed;this.packed=e.packed,e.packed=t;let n=this.offset;this.offset=e.offset,e.offset=n}data(){return this.packed}selfPlus(e=1){return this.offset-=e,this}selfMinus(e=1){return this.offset+=e,this}plus(t){return new e(this.packed,this.offset-t)}minus(t){return new e(this.packed,this.offset+t)}diff(e){return e.index()-this.index()}equals(e){return this.index()===e.index()}lt(e){return this.index()>e.index()}gt(e){return this.index()<e.index()}le(e){return!this.gt(e)}ge(e){return!this.lt(e)}deref(){return this.access(0)}write(e){return this.set(0,e),e}access(e){let t=this.index()-e;return this.packed[t]}set(e,t){let n=this.index()-e;this.packed[n]=t}index(){return this.offset-1}[Symbol.toPrimitive](e){let t=this.packed.length-1-this.index();return e===`string`?t.toString():t}};const z=O(function(e){let t=k.instantiate(e),n=t.ValueType.name,r=x(t.toEntity(t.null)),i=x(t.pageSize),a=e=>e===L.SwapOnly?x(0):r,o=e=>x(t.toEntity(e)),l=e=>e/i,d=(()=>{let e=t.entityMask,n=t.toIntegral(t.null)&~e;return c(t.EntityType,[Number])?(e,r)=>{let i=e.sparsePtr(r);return i==null?!1:(n&t.toIntegral(r)^t.toIntegral(i))>>>0<t.entityMask}:(e,r)=>{let i=e.sparsePtr(r);return i==null?!1:t.EntityType(n&t.toIntegral(r)^t.toIntegral(i))<t.entityMask}})();return class e extends D{static BasicIterator=R;static Iterator=e.BasicIterator;static ReverseIterator=A;static TraitsType=t;static EntityType=t.ValueType;sparse;packed;mode;head;Type;sparsePtr(e){let t=o(e),n=l(t);return n<this.sparse.length&&this.sparse[n]?this.sparse[n][s(t,i)]:null}sparseRef(e){let t=o(e),n=l(t),r=s(t,i);return{get:()=>this.sparse[n][r],set:e=>{this.sparse[n][r]=e}}}assureAtLeast(e){let n=o(e),r=l(n);for(;this.sparse.length<=r;)this.sparse.push(Array(t.pageSize).fill(t.null));let a=s(n,i);return{get:()=>this.sparse[r][a],set:e=>{this.sparse[r][a]=e}}}static isNull(e){return t.isNull(e)}static isTombstone(e){return t.isTombstone(e)}constructor(e,t){super(),this.sparse=[],this.packed=[];let n=typeof e==`number`?e:t??L.SwapAndPop;this.mode=n,this.head=a(n),this.Type=typeof e==`function`?e:void 0}dispose(){this.clear()}reserve(e){e>this.packed.length&&(this.packed.length=e)}data(){return this.packed}policy(){return this.mode}isNull(e){return t.isNull(e)}isTombstone(e){return t.isTombstone(e)}type(){return this.Type}empty(){return this.packed.length===0}get size(){return this.packed.length}freeList(e){return e!=null&&(this.head=x(e)),this.head}contiguous(){return this.mode!==L.InPlace||this.head===r}access(e){return this.packed[e]}swapAt(e,n){let r=this.packed[e],i=this.packed[n];this.sparseRef(r).set(t.combine(t.EntityType(n),t.toIntegral(r))),this.sparseRef(i).set(t.combine(t.EntityType(e),t.toIntegral(i))),this.packed[e]=i,this.packed[n]=r}tryEmplace(n,i=!1,a){let s=e.prototype.assureAtLeast.call(this,n),c=this.size;switch(this.mode){case L.InPlace:if(this.head!==r&&!i){c=Number(this.head),s.set(t.combine(t.EntityType(this.head),t.toIntegral(n))),this.head=x(t.toEntity(this.packed[c])),this.packed[c]=n;break}case L.SwapAndPop:this.packed.push(n),s.set(t.combine(t.EntityType(this.packed.length-1),t.toIntegral(n)));break;case L.SwapOnly:s.get()==null||t.isNull(s.get())?(this.packed.push(n),s.set(t.combine(t.EntityType(this.packed.length-1),t.toIntegral(n)))):this.bump(n),c=Number(this.head),this.head++,e.prototype.swapAt.call(this,o(s.get()),c);break;default:throw Error(`Unsupported operation`)}return new e.BasicIterator(this.packed,c+1)}push(e,t){return this.tryEmplace(e,!1,t)}pushRange(t,n){let r;n==null?(r=t.begin(),n=t.end()):(r=t.clone(),n=n.clone());let i=e.prototype.end.call(this);for(;!r.equals(n);r.selfPlus())i=this.tryEmplace(r.deref(),!0);return i}add(e){return this.push(e),this}contains(e){return d(this,e)}has(e){return this.contains(e)}swapAndPop(e){let n=this.sparseRef(e),r=t.toEntity(n.get());this.sparseRef(this.packed[this.packed.length-1]).set(t.combine(r,t.toIntegral(this.packed[this.packed.length-1]))),this.packed[r]=this.packed[this.packed.length-1],n.set(t.null),this.packed.pop()}inPlacePop(e){let n=this.sparseRef(e),r=n.get();n.set(t.null);let i=o(r),a=this.head;this.head=x(t.EntityType(i)),this.packed[i]=t.combine(t.EntityType(a),t.EntityType(t.tombstone))}swapOnly(n){let r=this.index(n);this.bump(t.next(n)),r<this.head&&this.head--,e.prototype.swapAt.call(this,r,this.head)}pop(e,t){if(e=e.clone(),t=t.clone(),this.mode===L.SwapAndPop)for(;!e.equals(t);e.selfPlus())this.swapAndPop(e.deref());else if(this.mode===L.InPlace)for(;!e.equals(t);e.selfPlus())this.inPlacePop(e.deref());else if(this.mode===L.SwapOnly)for(;!e.equals(t);e.selfPlus())this.swapOnly(e.deref());else throw Error(`Unsupported operation`)}popAll(){switch(this.mode){case L.InPlace:if(this.head!==r){for(let e of this.packed)t.isTombstone(e)||this.sparseRef(e).set(t.null);break}case L.SwapOnly:case L.SwapAndPop:for(let e of this.packed)this.sparseRef(e).set(t.null);break}this.head=a(this.mode),this.packed.length=0}erase(e,t){if(t!=null)if(e instanceof R&&t instanceof R)this.pop(e,t);else{let n=e.clone();for(t=t.clone();!n.equals(t);n.selfPlus())this.erase(n.deref())}else{let t=this.toIterator(e);this.pop(t,t.plus(1))}}remove(e,t){if(t!=null){let n=0,r=e.clone(),i=t.clone();if(e instanceof R&&t instanceof R)for(;!r.equals(i);){for(;!r.equals(i)&&!this.contains(r.deref());)r.selfPlus();let e=r.clone();for(;!r.equals(i)&&this.contains(r.deref());)r.selfPlus();n+=r.diff(e),this.erase(e,r)}else for(;!r.equals(i);r.selfPlus())n+=Number(this.remove(r.deref()));return n}else return this.has(e)?(this.erase(e),!0):!1}delete(e){return this.remove(e)}clear(){this.popAll(),this.head=a(this.mode),this.packed.length=0}forEach(e,t){for(let n=this.packed.length-1;n>=0;--n){let r=this.packed[n];e.call(t,r,r,this)}}at(e){return this.packed[(this.packed.length-1-e)%this.packed.length]}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}entries(){let t=e.prototype.begin.call(this),n=e.prototype.end.call(this);return F(new P([t,t.clone()]),new P([n,n.clone()]))}current(e){let n=this.sparsePtr(e);return n==null?t.toVersion(t.tombstone):t.toVersion(n)}bump(e){let n=this.sparseRef(e);return n.set(t.combine(t.toIntegral(n.get()),t.toIntegral(e))),this.packed[o(n.get())]=e,t.toVersion(e)}index(e){return Number(o(this.sparsePtr(e)))}find(t){return this.has(t)?this.toIterator(t):e.prototype.end.call(this)}begin(){return new e.BasicIterator(this.packed,this.packed.length)}end(){return new e.BasicIterator(this.packed,0)}rbegin(){return j(e.prototype.end.call(this))}rend(){return j(e.prototype.begin.call(this))}toIterator(t){return e.prototype.end.call(this).minus(this.index(t)).selfMinus()}bindAny(e){}bind(e){this.bindAny(e)}swapOrMove(e,t){}compact(){if(this.mode===L.InPlace){let e=this.packed.length,n=this.head;for(this.head=r;e&&t.isTombstone(this.packed[e-1]);--e);for(;n!==r;){let r=n;if(n=x(o(this.packed[n])),r<e){--e,this.swapOrMove(e,Number(r)),this.packed[r]=this.packed[e];let n=t.EntityType(r);for(this.sparseRef(this.packed[r]).set(t.combine(n,t.toIntegral(this.packed[r])));e&&t.isTombstone(this.packed[e-1]);--e);}}this.packed.length=e}}sort(e,t=u){let n=this.mode===L.SwapOnly?Number(this.head):this.packed.length;this.sortN(n,e,t)}sortN(e,n,r=u){let i=this.packed.slice(0,e).reverse();r(i,n);for(let t=0;t<e;++t)this.packed[e-1-t]=i[t];for(let n=0;n<e;++n){let e=n,r=this.index(this.packed[e]);for(;e!==r;){let n=this.index(this.packed[r]),i=this.packed[e];this.swapOrMove(r,n);let a=t.EntityType(e);this.sparseRef(i).set(t.combine(a,t.toIntegral(this.packed[e])));let o=r;r=n,e=o}}}swapElements(t,n){let r=this.index(t),i=this.index(n);this.swapOrMove(r,i),e.prototype.swapAt.call(this,r,i)}sortAs(n,r){let i=r==null?n.begin():n.clone(),a=r==null?n.end():r.clone(),o=this.mode===L.SwapOnly?Number(this.head):this.packed.length,s=e.prototype.end.call(this).minus(o),c=e.prototype.end.call(this);for(;!s.equals(c)&&!i.equals(a);i.selfPlus()){let e=i.deref();if(this.contains(e)){let n=s.deref();t.toIntegral(n)!==t.toIntegral(e)&&this.swapElements(n,e),s.selfPlus()}}return s}get[Symbol.toStringTag](){return`BasicSparseSet<${n}>`}[Symbol.iterator](){return F(e.prototype.begin.call(this),e.prototype.end.call(this))}}}),B=(()=>z.instantiate(S))(),V=O(function(e,t){return{ElementType:e,EntityType:t,pageSize:e==null?0:`pageSize`in e?e.pageSize:ie(e)?0:T.packedPage,inPlaceDelete:e!=null&&`inPlaceDelete`in e?e.inPlaceDelete:!1}});var de=class extends D{fn;instance;constructor(e,t){super(),this.fn=e,this.instance=t}dispose(){this.reset()}reset(){this.fn=null,this.instance=null}empty(){return this.fn==null}connect(e,t){this.fn=e,this.instance=t}invoke(...e){let t=this.fn;return this.instance?t.apply(this.instance,e):t(...e)}},H=class e extends D{signal;constructor(e){super(),this.signal=e}dispose(){this.signal?.dispose(),this.signal=void 0}empty(){return this.signal.calls.length===0}disconnectIf(e){for(let t=this.signal.calls.length-1;t>=0;--t){let n=this.signal.calls[t];if(e(n)){let e=this.signal.calls[t];this.signal.calls[t]=this.signal.calls[this.signal.calls.length-1],this.signal.calls[this.signal.calls.length-1]=e,this.signal.calls.pop()}}}disconnect(e,t){e!=null&&t!=null?this.disconnectIf(n=>Object.is(n.fn,e)&&Object.is(n.instance,t)):e==null?t==null?this.signal.calls.length=0:this.disconnectIf(e=>Object.is(e.instance,t)):this.disconnectIf(t=>Object.is(t.fn,e))}connect(t,n){this.disconnect(t,n);let r=new de(t,n);return this.signal.calls.push(r),new fe(new de(function(n){new e(n).disconnect(t,this)},n),this.signal)}},U=class extends D{calls;static SinkType=H;constructor(){super(),this.calls=[]}dispose(){this.calls.length=0}get size(){return this.calls.length}empty(){return this.calls.length===0}publish(...e){for(let t=this.calls.length-1;t>=0;--t)this.calls[t].invoke(...e)}collect(e,...t){for(let n=this.calls.length-1;n>=0&&!e(this.calls[n].invoke(...t));--n);}},fe=class{signal;disconnect;constructor(e,t){this.disconnect=e,this.signal=t}empty(){return this.disconnect.empty()}release(){this.disconnect.empty()||(this.disconnect.invoke(this.signal),this.disconnect.reset())}},pe=class extends D{conn;constructor(e){super(),this.conn=e}dispose(){this.conn.release()}empty(){return this.conn.empty()}release(){this.conn.release()}},me=class extends D{};const he=O(function(e){let t=E(e);return class extends me{signal;events;constructor(){super(),this.signal=new U,this.events=[]}dispose(){this.signal.dispose(),this.events.length=0}publish(){for(;this.events.length>0;){let e=this.events.shift();this.signal.publish(e)}}disconnect(e){new U.SinkType(this.signal).disconnect(void 0,e)}clear(){this.events.length=0}bucket(){return new U.SinkType(this.signal)}trigger(e){this.signal.publish(e)}enqueue(...e){this.events.push(t(...e))}get size(){return this.events.length}}});var ge=class extends D{pools;constructor(){super(),this.pools=new Map}dispose(){this.pools.forEach(e=>{e.dispose()}),this.pools.clear()}assure(e){if(!this.pools.has(e)){let t=new(he.instantiate(e));return this.pools.set(e,t),t}return this.pools.get(e)}constAssure(e){return this.pools.get(e)}size(e){if(e!=null){let t=this.constAssure(e);return t?t.size:0}let t=0;return this.pools.forEach(e=>{t+=e.size}),t}sink(e){return this.assure(e).bucket()}trigger(e,t){this.assure(e).trigger(t)}enqueue(e,...t){this.assure(e).enqueue(...t)}disconnect(e){this.pools.forEach(t=>{t.disconnect(e)})}clear(e){e==null?this.pools.forEach(e=>{e.clear()}):this.assure(e).clear()}update(e){e==null?this.pools.forEach(e=>{e.publish()}):this.assure(e).publish()}},_e=class extends D{handlers;constructor(){super(),this.handlers=new Map}dispose(){this.handlers.clear()}on(e,t){this.handlers.set(e,e=>{t(e,this)})}publish(e){let t=e.constructor,n=this.handlers.get(t);n&&n(e)}erase(e){this.handlers.delete(e)}clear(){this.handlers.clear()}contains(e){return this.handlers.has(e)}empty(){return this.handlers.size===0}};const ve=O(function(e){let t=e;return class extends e{static UnderlyingType=t;owner;construction;destruction;update;constructor(...e){super(...e),this.owner=null,this.construction=new U,this.destruction=new U,this.update=new U}dispose(){this.construction.dispose(),this.destruction.dispose(),this.update.dispose(),super.dispose(),this.owner=null}ownerOrAssert(){return this.owner}pop(e,t){let n=this.ownerOrAssert();if(this.destruction.empty())super.pop(e,t);else for(e=e.clone(),t=t.clone();!e.equals(t);e.selfPlus()){let t=e.deref();this.destruction.publish(n,t);let r=super.find(t);super.pop(r,r.plus(1))}}popAll(){let e=this.ownerOrAssert();if(!this.destruction.empty())if(`ElementType`in t&&`EntityType`in t&&t.ElementType===t.EntityType)for(let t=0,n=super.freeList();t<n;++t)this.destruction.publish(e,super.access(t));else for(let n of t.BaseType.prototype[Symbol.iterator].call(this))t.storagePolicy===L.InPlace&&this.isTombstone(n)||this.destruction.publish(e,n);super.popAll()}tryEmplace(e,t,n){let r=this.ownerOrAssert(),i=super.tryEmplace(e,t,n);this.construction.empty()||this.construction.publish(r,i.deref())}insert(e,t,...n){let r=super.size;super.insert(e,t,...n);let i=this.ownerOrAssert();if(!this.construction.empty()){let e=super.size;for(;r!==e;++r)this.construction.publish(i,super.access(r))}}bindAny(e){this.owner=e,super.bindAny(e)}onConstruct(){return new H(this.construction)}onUpdate(){return new H(this.update)}onDestroy(){return new H(this.destruction)}registry(){return this.ownerOrAssert()}generate(e){let t=super.generate(e);return this.construction.empty()||this.construction.publish(this.ownerOrAssert(),t),t}generateRange(e,t){super.generateRange(e,t);let n=this.ownerOrAssert();if(!this.construction.empty()){let[r,i]=M(e,t);for(;!r.equals(i);r.selfPlus())this.construction.publish(n,r.deref())}}emplace(e,...t){return super.emplace(e,...t),this.construction.empty()||this.construction.publish(this.ownerOrAssert(),e),this.get(e)}patch(e,...t){return super.patch(e,...t),this.update.empty()||this.update.publish(this.ownerOrAssert(),e),this.get(e)}}});var W=class e{payload;offset;pageSize;constructor(e,t,n){this.pageSize=e??0,this.payload=t??null,this.offset=n??0}dispose(){this.payload=null,this.offset=0,this.pageSize=0}clone(t){return t?t===this?t:(t.payload=this.payload,t.offset=this.offset,t.pageSize=this.pageSize,t):new e(this.pageSize,this.payload,this.offset)}swap(e){if(this===e)return;let t=this.payload;this.payload=e.payload,e.payload=t;let n=this.offset;this.offset=e.offset,e.offset=n;let r=this.pageSize;this.pageSize=e.pageSize,e.pageSize=r}data(){return this.payload}selfPlus(e=1){return this.offset-=e,this}selfMinus(e=1){return this.offset+=e,this}plus(t){return new e(this.pageSize,this.payload,this.offset-t)}minus(t){return new e(this.pageSize,this.payload,this.offset+t)}diff(e){return e.index()-this.index()}equals(e){return this.index()===e.index()}lt(e){return this.index()>e.index()}gt(e){return this.index()<e.index()}le(e){return!this.gt(e)}ge(e){return!this.lt(e)}deref(){return this.access(0)}write(e){return this.set(0,e),e}access(e){let t=this.index()-e;return this.pageSize===0?this.payload[0][t]:this.payload[t/this.pageSize>>>0][(t&this.pageSize-1)>>>0]}set(e,t){let n=this.index()-e;this.pageSize===0?this.payload[0][n]=t:this.payload[n/this.pageSize>>>0][(n&this.pageSize-1)>>>0]=t}index(){return this.offset-1}};const G=O(function(e,t){let n=z.instantiate(t),i=V.instantiate(e,t),a=E(i.ElementType),o=i.inPlaceDelete?L.InPlace:L.SwapAndPop;if(i.pageSize===0)return class extends n{static TraitsType=i;static storagePolicy=o;static EntityType=t;static ElementType=e;static BaseType=n;static ValueType=void 0;constructor(){super(i.ElementType,o)}get(e){}getAsRef(e){return{get:()=>{},set:()=>{}}}getAsTuple(e){return[]}emplace(e,...t){super.tryEmplace(e,!1)}insert(e,t,n){for(e=e.clone(),t=t.clone();!e.equals(t);e.selfPlus()){let t=e.deref();super.tryEmplace(t,!0)}}patch(e,...t){for(let e of t)e()}[Symbol.iterator](){return F(this)}each(){let e=super.begin(),t=super.end();return F(new P([e]),new P([t]))}reach(){let e=super.rbegin(),t=super.rend();return F(new P([e]),new P([t]))}};let s=class extends n{payload;static TraitsType=i;static Iterator=W;static ReverseIterator=A;static storagePolicy=o;static EntityType=t;static ElementType=e;static BaseType=n;static ValueType=e;elementAt(e){return this.payload[e/i.pageSize>>>0]?.[(e&i.pageSize-1)>>>0]}elementSet(e,t){let n=this.assureAtLeast(e);this.payload[n][(e&i.pageSize-1)>>>0]=t}assureAtLeast(e){let t=e/i.pageSize>>>0;for(;this.payload.length<=t;)this.payload.length===t?this.payload.push(Array(((e&i.pageSize-1)>>>0)+1)):this.payload.push(Array(i.pageSize).fill(void 0));return t}constructor(){super(i.ElementType,o),this.payload=[]}dispose(){this.payload.length=0,super.dispose()}reserve(e){e!==0&&(super.reserve(e),this.assureAtLeast(e-1))}get(e){return this.elementAt(super.index(e))}getAsRef(e){return{get:()=>this.elementAt(super.index(e)),set:t=>{this.elementSet(super.index(e),t)}}}getAsTuple(e){return[this.get(e)]}emplaceElement(e,t,...n){let o=super.tryEmplace(e,t),s;try{s=n.length===1&&n[0]instanceof i.ElementType?r(n[0]):a(...n),this.elementSet(o.index(),s)}catch(e){throw super.pop(o,o.plus(1)),e}return o}tryEmplace(e,t,n){return n==null?this.emplaceElement(e,t):this.emplaceElement(e,t,n)}emplace(e,...t){let n=this.emplaceElement(e,!1,...t);return this.elementAt(n.index())}insert(e,t,n=a()){for(e=e.clone(),t=t.clone();!e.equals(t);e.selfPlus()){let t=e.deref();this.emplaceElement(t,!0,n)}return this.begin()}insertRange(e,t,n){for(e=e.clone(),t=t.clone(),n=n.clone();!e.equals(t);e.selfPlus(),n.selfPlus()){let t=e.deref();this.emplaceElement(t,!0,n.deref())}return this.begin()}patch(e,...t){let n=super.index(e),r;for(let e of t){r=this.elementAt(n);let t=e(r);t!=null&&(this.elementSet(n,t),r=t)}return r}pop(e,t){for(e=e.clone(),t=t.clone();!e.equals(t);e.selfPlus())if(i.inPlaceDelete){let t=e.deref(),n=super.index(t);super.inPlacePop(t),this.elementSet(n,void 0)}else{let t=super.size-1,n=e.deref(),r=super.index(n);if(r!==t){let e=this.elementAt(t);this.elementSet(r,e),this.elementSet(t,void 0)}else this.elementSet(t,void 0);super.swapAndPop(n)}}popAll(){for(let e=super.begin();!(e.index()<0);e.selfPlus())i.inPlaceDelete?this.isTombstone(e.deref())||(super.inPlacePop(e.deref()),this.elementSet(e.index(),void 0)):(super.swapAndPop(e.deref()),this.elementSet(e.index(),void 0))}swapAt(e,t){let n=this.elementAt(e);this.elementSet(e,this.elementAt(t)),this.elementSet(t,n)}moveTo(e,t){let n=this.elementAt(e);this.elementSet(e,void 0),this.elementSet(t,n)}swapOrMove(e,t){if(this.mode===L.InPlace){let r=super.access(t);r!=null&&n.TraitsType.isTombstone(r)?this.moveTo(e,t):s.prototype.swapAt.call(this,e,t)}else s.prototype.swapAt.call(this,e,t)}[Symbol.iterator](){return F(this)}entries(){let e=super.begin(),t=this.begin(),n=super.end(),r=this.end();return F(new P([e,t]),new P([n,r]))}capacity(){return this.payload.length*i.pageSize}begin(){return new W(i.pageSize,this.payload,this.size)}end(){return new W(i.pageSize,this.payload,0)}rbegin(){return j(this.end())}rend(){return j(this.begin())}each(){return this.entries()}reach(){let e=super.rbegin(),t=this.rbegin(),n=super.rend(),r=this.rend();return F(new P([e,t]),new P([n,r]))}forEach(e,t){let n=this.begin(),r=this.end();for(;!n.equals(r);n.selfPlus()){let r=n.deref(),i=this.data()[n.index()];e.call(t,r,i,this)}}};return s},[{predicate:(e,t)=>t===void 0||Object.is(t,e),render:(e=>{let t=z.instantiate(e),n=k.instantiate(e),r=L.SwapOnly;return class extends t{placeholder;static TraitsType=n;static storagePolicy=r;static EntityType=e;static ElementType=e;static BaseType=t;static ValueType=void 0;static Iterator=R;static ReverseIterator=A;constructor(){super(n.ValueType,r),this.placeholder=0n}dispose(){this.placeholder=0n,super.dispose()}fromPlaceholder(){let e=n.combine(n.EntityType(this.placeholder),n.EntityType(0)),t=n.isNull(e);return this.placeholder+=t?0n:1n,e}next(){let e=this.fromPlaceholder();for(;super.current(e)!==n.toVersion(n.tombstone)&&!n.isNull(e);)e=this.fromPlaceholder();return e}popAll(){super.popAll(),this.placeholder=0n}tryEmplace(e){return super.find(this.generate(e))}get(e){}getAsRef(e){return{get:()=>{},set:()=>{}}}getAsTuple(e){return[]}startFrom(e){this.placeholder=BigInt(n.toEntity(e))}generate(e){if(e!=null&&!n.isNull(e)&&!n.isTombstone(e)){let t=n.construct(n.toEntity(e),super.current(e));if(n.isTombstone(t)||super.index(t)>=super.freeList())return super.tryEmplace(e,!0).deref()}let t=super.freeList(),r=t===x(super.size)?this.next():super.data()[t];return super.tryEmplace(r,!0).deref()}generateRange(e,t){let[n,r]=M(e,t),i=x(super.size);for(;!n.equals(r)&&super.freeList()!==i;n.selfPlus())n.write(super.tryEmplace(super.data()[super.freeList()],!0).deref());for(;!n.equals(r);n.selfPlus())n.write(super.tryEmplace(this.next(),!0).deref())}insert(e,t){for(e=e.clone(),t=t.clone();!e.equals(t);e.selfPlus()){let t=e.deref();super.tryEmplace(t,!0)}}patch(e,...t){for(let e of t)e()}each(){let e=super.end(),t=super.freeList();return F(new P([e.minus(Number(t))]),new P([e]))}reach(){let e=super.rbegin(),t=super.freeList();return F(new P([new A(e)]),new P([new A(e.plus(Number(t)))]))}}})}]),ye=O(function(e){return G.instantiate(e,S)}),be=O(function(e,t){return class{static Type=T.mixin?ve.instantiate(G.instantiate(e,t)):G.instantiate(e,t)}}),K=O(function(...e){return be.instantiate(...e).Type}),xe=(...e)=>e.length===1&&e[0].storagePolicy===L.InPlace,Se=new Map,Ce=e=>{if(!Se.has(e)){let t=new e;return Se.set(e,t),t}return Se.get(e)};function q(e,t,n){for(e=e.clone(),t=t.clone();!e.equals(t)&&e.deref().contains(n);e.selfPlus());return e.equals(t)}function we(e,t,n){for(e=e.clone(),t=t.clone();!e.equals(t)&&!e.deref().contains(n);e.selfPlus());return e.equals(t)}function Te(e,t,n){for(e=e.clone(),t=t.clone();!e.equals(t)&&e.deref()!==n;e.selfPlus());return e.equals(t)}function Ee(e,t){if(e===t)return e;let n=e;for(;n!=null;){let e=t;for(;e!=null;){if(n===e)return n;e=Object.getPrototypeOf(e)}n=Object.getPrototypeOf(n)}return null}function J(...e){if(e.length===0)throw Error(`No storage type provided`);let t=e[0];for(let n=1;n<e.length;++n){let r=e[n];if(t=Ee(t,r),t==null)throw Error(`No common storage type found`)}return t}const De=O(function(e,t,n,r){let i=e.Iterator;class a{it;pools;filter;index;valid(i){let a=I(this.pools),o=I(this.filter);return(!t||!e.isTombstone(i))&&(n===1||q(a.begin(),a.begin().plus(this.index),i)&&q(a.begin().plus(this.index+1),a.end(),i))&&(r===0||we(o.begin(),o.end(),i))}seekNext(){for(let e=new i;!this.it.equals(e)&&!this.valid(this.it.deref());this.it.selfPlus());}constructor(e,t,a,o){e!=null&&t!=null&&a!=null&&o!=null?(this.it=e.clone(),this.pools=t,this.filter=a,this.index=o,this.seekNext()):(this.it=new i,this.pools=Array(n),this.filter=Array(r),this.index=0)}selfPlus(){return this.it.selfPlus(),this.seekNext(),this}write(e){throw Error(`Unsupported operation`)}deref(){return this.it.deref()}equals(e){return this.it.equals(e.it)}clone(e){return e?this===e?e:(this.it.clone(e.it),e.pools=this.pools,e.filter=this.filter,e.index=this.index,e):new a(this.it,this.pools,this.filter,this.index)}swap(e){if(this===e)return;let t=this.it;this.it=e.it,e.it=t;let n=this.pools;this.pools=e.pools,e.pools=n;let r=this.filter;this.filter=e.filter,e.filter=r;let i=this.index;this.index=e.index,e.index=i}}return a});var Y=class e{it;constructor(e){this.it=e.clone()}selfPlus(){return this.it.selfPlus(),this}write(e){throw Error(`Unsupported operation`)}deref(){return[this.it.deref(),...this.it.pools.flatMap(e=>e.getAsTuple(this.it.deref()))]}equals(e){return this.it.equals(e.it)}clone(t){return t?(this===t||this.it.clone(t.it),t):new e(this.it)}swap(e){this!==e&&this.it.swap(e.it)}base(){return this.it.clone()}};const Oe=O(function(e,t,n,r){let i=class{pools;filter;index;placeholder;static Iterator=De.instantiate(e,t,n,r);static CommonType=e;static EntityType=e.EntityType;offset(){return this.pools[this.index].policy()===L.SwapOnly?Number(this.pools[this.index].freeList()):this.pools[this.index].size}uncheckedRefresh(){if(this.index=0,n>1)for(let e=1;e<n;++e)this.pools[e].size<this.pools[this.index].size&&(this.index=e)}constructor(t,i){if(this.placeholder=Ce(e),Array.isArray(t)&&Array.isArray(i))this.pools=t,this.filter=i,this.index=n,this.uncheckedRefresh();else{this.pools=Array(n),this.filter=Array(r),this.index=n;for(let e=0,t=this.filter.length;e<t;++e)this.filter[e]=this.placeholder}}poolAt(e,t){if(e<0||e>=n)throw Error(`View pool index out of range`);if(t!==void 0)this.pools[e]=t,this.refresh();else return this.pools[e]}filterAt(e,t){if(e<0||e>=r)throw Error(`View filter index out of range`);if(t!==void 0)this.filter[e]=t;else return this.filter[e]===this.placeholder?null:this.filter[e]}noneOf(e){let t=I(this.filter);return we(t.begin(),t.end(),e)}use(e){this.index=this.index===n?n:e}refresh(){let e=Number(this.index!==n)*n;for(;e<n&&this.pools[e]!=null;++e);e===n&&this.uncheckedRefresh()}handle(){return this.index===n?null:this.pools[this.index]}sizeHint(){return this.index===n?0:this.offset()}begin(){return this.index===n?new i.Iterator:new i.Iterator(e.prototype.end.call(this.pools[this.index]).minus(this.offset()),this.pools,this.filter,this.index)}end(){return this.index===n?new i.Iterator:new i.Iterator(e.prototype.end.call(this.pools[this.index]),this.pools,this.filter,this.index)}front(){let t=this.begin();return t.equals(this.end())?e.TraitsType.null:t.deref()}back(){if(this.index!==n){let t=this.pools[this.index].rbegin(),n=t.plus(this.offset());for(let e=this.index;!t.equals(n)&&!(q(I(this.pools).begin(),I(this.pools).begin().plus(e),t.deref())&&q(I(this.pools).begin().plus(e).plus(1),I(this.pools).end(),t.deref())&&we(I(this.filter).begin(),I(this.filter).end(),t.deref()));t.selfPlus());return t.equals(n)?e.TraitsType.null:t.deref()}return e.TraitsType.null}find(e){return this.contains(e)?new i.Iterator(this.pools[this.index].find(e),this.pools,this.filter,this.index):this.end()}ok(){return this.index!==n&&Te(I(this.filter).begin(),I(this.filter).end(),this.placeholder)}[Symbol.toPrimitive](){return this.ok()}contains(r){return this.index!==n&&(t?!e.isTombstone(r):!0)&&q(I(this.pools).begin(),I(this.pools).begin().plus(this.index),r)&&q(I(this.pools).begin().plus(this.index+1),I(this.pools).end(),r)&&this.noneOf(r)}[Symbol.iterator](){return F(this)}};return i}),X=O(function(e,t){throw Error(`Invalid BasicView instantiation`)},[{predicate:(e,t)=>e.length===1&&(t==null||t.length===0),render(e,t){let n=e[0].constructor,r=Ae.instantiate(n.BaseType,n.storagePolicy),i=r;class a extends r{static CommonType=i.CommonType;static EntityType=i.EntityType;static Iterator=i.Iterator;static ReverseIterator=i.ReverseIterator;constructor(e,t){super(Array.isArray(e)?e[0]:e)}getStorageByElementType(e){return this.getStorageByIndex(0)}getStorageByIndex(e=0){return super.handle()}setStorageByType(e){this.setStorage(0,e)}setStorage(e,t){this.leading=t}access(e){return this.getStorageByIndex()?.get(e)}getByElementType(e,t){if(t!==n.ElementType)throw Error(`Invalid element type`);return this.get(e,0)}get(e,t){return t==null?this.getStorageByIndex()?.getAsTuple(e)??[void 0]:this.getStorageByIndex(t)?.get(e)}each(e,t){if(e!=null&&typeof e==`function`){if(t)if(n.storagePolicy===L.SwapAndPop||n.storagePolicy===L.SwapOnly)if(n.ValueType===void 0)for(let t=super.size;t;--t)e.call(this);else{let t=super.size;if(t!==0)for(let n=this.getStorageByIndex().end(),r=n.minus(t);!r.equals(n);r.selfPlus())e.call(this,r.deref())}else for(let t of this.each())e.call(this,...t.slice(1));else for(let t of this.each())e.apply(this,t);return}return n.storagePolicy===L.SwapAndPop||n.storagePolicy===L.SwapOnly?super.handle()?this.getStorageByIndex().each():F(new P([new R]),new P([new R])):F(new Y(super.begin()),new Y(super.end()))}bitOr(e){let t=[this.leading,...e.pools??[e.leading]],n=Ce(J(...t.map(e=>e.constructor.BaseType))),r=e=>e??n,i=e.filter?[...e.filter.map((t,n)=>r(e.getStorageByIndex(e.pools.length+n)))]:[],a=new(X.instantiate(t,i));return a.pools=t,a.filter=i,a.refresh(),a}}return a}},{predicate:(e,t)=>e.length!==0,render(e,t){let n=Oe.instantiate(J(...e.map(e=>e.constructor.BaseType)),xe(...e),e.length,t.length),r=n;class i extends n{static BaseType=r;static indexOf=n=>[...e.map(e=>e.constructor.ElementType),...t.map(e=>e.constructor.ElementType)].indexOf(n);get(e,...t){return t.map(t=>this.getStorageByIndex(t)?.getAsTuple(e)??[]).flat()}dispatchGet(e,t,n){return e===t?[n[e+1]]:this.getStorageByIndex(t)?.getAsTuple(n[0])??[]}_each(t,n,r,...i){let a=this.getStorageByIndex(t);for(let o of a.each()){let s=o[0];if((!xe(...e)||!a.isTombstone(s))&&i.every(e=>t===e||super.poolAt(e).contains(s))&&super.noneOf(s)){let e=i.flatMap(e=>this.dispatchGet(t,e,o));r?n.apply(this,e):n.call(this,s,...e)}}}pickAndEach(e,t,...n){let r=super.handle();r!=null&&n.forEach(i=>{r===super.poolAt(i)&&this._each(i,e,t,...n)})}static CommonType=r.CommonType;static EntityType=r.EntityType;static Iterator=r.Iterator;constructor(e,t=[]){Array.isArray(e)&&Array.isArray(t)?super([...e],[...t]):super()}useByType(e){this.use(i.indexOf(e))}use(e){this.use(e)}getStorageByElementType(e){return this.getStorageByIndex(i.indexOf(e))}getStorageByIndex(t){return t<e.length?super.poolAt(t):super.filterAt(t-e.length)}setStorageByType(e){let t=i.indexOf(e.constructor.ElementType);this.setStorage(t,e)}setStorage(n,r){if(n<0||n>=e.length+t.length)throw Error(`View storage index out of range`);n<e.length?super.poolAt(n,r):super.filterAt(n-e.length,r)}access(e){return this.get(e)}getByElementType(e,...t){let n=this.get(e,...t.map(e=>i.indexOf(e)));return n.length===1?n[0]:n}getByIndexes(e,...t){return t.length===0?this.get(e):t.length===1?this.getStorageByIndex(t[0])?.get(e):t.map(t=>this.getStorageByIndex(t)?.getAsTuple(e)).flat()}each(t,n){if(t!=null&&typeof t==`function`)this.pickAndEach(t,n,...Array.from({length:e.length},(e,t)=>t));else return F(new Y(super.begin()),new Y(super.end()))}bitOr(e){let t=[...this.pools,...e.pools??[e.leading]],n=Ce(J(...t.map(e=>e.constructor.BaseType))),r=e=>e??n,i=[...this.filter.map((e,t)=>r(this.getStorageByIndex(this.pools.length+t))),...e.filter?e.filter.map((t,n)=>r(e.getStorageByIndex(e.pools.length+n))):[]],a=new(X.instantiate(t,i));return a.pools=t,a.filter=i,a.refresh(),a}}return i}}]);function ke(e,t=[]){return new(X.instantiate(e,t))(e,t)}const Ae=O(function(e,t){class n{leading;static CommonType=e;static EntityType=e.EntityType;static Iterator=t===L.InPlace?De.instantiate(e,!0,1,0):e.Iterator;static ReverseIterator=t===L.InPlace?void 0:e.ReverseIterator;constructor(e){this.leading=e??null}handle(){return this.leading}get size(){if(t===L.InPlace)throw Error(`Size not available for in-place storage views`);return t===L.SwapAndPop?this.leading==null?0:Number(this.leading.size):this.leading==null?0:Number(this.leading.freeList())}sizeHint(){if(t!==L.InPlace)throw Error(`Size hint not available for non in-place storage views`);return this.leading==null?0:Number(this.leading.size)}empty(){if(t===L.InPlace)throw Error(`Empty not available for in-place storage views`);return t===L.SwapAndPop?!this.leading||this.leading.empty():!this.leading||Number(this.leading.freeList())===0}begin(){return t===L.SwapAndPop?this.leading?e.prototype.begin.call(this.leading):new n.Iterator:t===L.SwapOnly?this.leading?e.prototype.end.call(this.leading).minus(Number(this.leading.freeList())):new n.Iterator:this.leading?new n.Iterator(e.prototype.begin.call(this.leading),[this.leading],[],0):new n.Iterator}end(){return t===L.SwapAndPop||t===L.SwapOnly?this.leading?e.prototype.end.call(this.leading):new n.Iterator:this.leading?new n.Iterator(e.prototype.end.call(this.leading),[this.leading],[],0):new n.Iterator}rbegin(){if(t===L.InPlace)throw Error(`Reverse begin not available for in-place storage views`);return this.leading?e.prototype.rbegin.call(this.leading):new n.ReverseIterator(new e.BasicIterator)}rend(){if(t===L.InPlace)throw Error(`Reverse end not available for in-place storage views`);return t===L.SwapAndPop?this.leading?e.prototype.rend.call(this.leading):new n.ReverseIterator(new e.BasicIterator):this.leading?e.prototype.rend.call(this.leading).plus(Number(this.leading.freeList())):new n.ReverseIterator(new e.BasicIterator)}front(){if(t===L.SwapAndPop)return this.empty()?e.TraitsType.null:e.prototype.begin.call(this.leading).deref();if(t===L.SwapOnly)return this.empty()?e.TraitsType.null:e.prototype.end.call(this.leading).minus(Number(this.leading.freeList())).deref();{let t=this.begin();return t.equals(this.end())?e.TraitsType.null:t.deref()}}back(){if(t===L.SwapAndPop||t===L.SwapOnly)return this.empty()?e.TraitsType.null:e.prototype.rbegin.call(this.leading).deref();if(this.leading!=null){let t=e.prototype.rbegin.call(this.leading),n=e.prototype.rend.call(this.leading);for(;!t.equals(n)&&e.isTombstone(t.deref());t.selfPlus());return t.equals(n)?e.TraitsType.null:t.deref()}return e.TraitsType.null}find(e){if(t===L.SwapAndPop)return this.leading==null?new n.Iterator:this.leading.find(e);if(t===L.SwapOnly){let t=this.leading==null?new n.Iterator:this.leading.find(e);return this.leading!=null&&t.index()<Number(this.leading.freeList())?t:new n.Iterator}else return this.leading==null?new n.Iterator:new n.Iterator(this.leading.find(e),[this.leading],[],0)}ok(){return this.leading!=null}contains(e){return t===L.SwapAndPop||t===L.InPlace?this.leading?.contains(e):this.leading!=null&&this.leading.contains(e)&&this.leading.index(e)<Number(this.leading.freeList())}[Symbol.iterator](){return F(this)}}return n});var Z=class e{it;owned;get;get pools(){return[...this.owned,...this.get]}indexToElement(e){return e.constructor.ValueType==null?[]:[e.rbegin().access(this.it.index())]}constructor(e,t,n){e&&t&&n?(this.it=e.clone(),this.owned=t,this.get=n):(this.it=new e,this.owned=[],this.get=[])}selfPlus(){return this.it.selfPlus(),this}write(e){return this.it.write(e),e}deref(){return[this.it.deref(),...this.owned.flatMap(e=>this.indexToElement(e)),...this.get.flatMap(e=>e.getAsTuple(this.it.deref()))]}equals(e){return this.it.equals(e.it)}clone(t){return t?this===t?t:(this.it.clone(t.it),this.owned=t.owned.slice(),this.get=t.get.slice(),t):new e(this.it,this.owned,this.get)}swap(e){if(this===e)return;this.it.swap(e.it);let t=this.owned;this.owned=e.owned,e.owned=t;let n=this.get;this.get=e.get,e.get=n}base(){return this.it.clone()}},je=class extends D{owned(e){return!1}};const Me=O(function(t,n,r,i){class a extends je{static EntityType=t.EntityType;pools;filter;len;swapElements(e,t){for(let r=0;r<n;++r)this.pools[r].swapElements(this.pools[r].access(e),t)}pushOnConstruct(e){let t=this.len;((...n)=>{let[r,...i]=n;return r.contains(e)&&!(r.index(e)<t)&&i.every(t=>t.contains(e))})(...this.pools)&&((...t)=>t.every(t=>!t.contains(e)))(...this.filter)&&this.swapElements(this.len++,e)}pushOnDestroy(e){let t=this.len;((...n)=>{let[r,...i]=n;return r.contains(e)&&!(r.index(e)<t)&&i.every(t=>t.contains(e))})(...this.pools)&&((...t)=>t.reduce((t,n)=>t+Number(n.contains(e)),0)===1)(...this.filter)&&this.swapElements(this.len++,e)}removeIf(e){let t=this.pools;t[0].contains(e)&&t[0].index(e)<this.len&&this.swapElements(--this.len,e)}commonSetup(){let e=this.pools;for(let n=t.prototype.rbegin.call(e[0]),r=n.plus(e[0].size);!n.equals(r);n.selfPlus())this.pushOnConstruct(n.deref())}CommonType=t;constructor(e,t){super(),this.pools=Array(n+r),this.filter=Array(i);for(let t=0;t<n+r;++t)this.pools[t]=e[t];for(let e=0;e<i;++e)this.filter[e]=t[e];this.len=0,e.forEach(e=>{e.onConstruct().connect(function(e,t){a.prototype.pushOnConstruct.call(this,t)},this),e.onDestroy().connect(function(e,t){a.prototype.removeIf.call(this,t)},this)}),t.forEach(e=>{e.onConstruct().connect(function(e,t){a.prototype.removeIf.call(this,t)},this),e.onDestroy().connect(function(e,t){a.prototype.pushOnDestroy.call(this,t)},this)}),this.commonSetup()}owned(t){for(let r=0;r<n;++r)if(Object.is(this.pools[r].type(),t)||e(this.pools[r].type())===t)return!0;return!1}length(){return this.len}storage(e){return e<n+r?this.pools[e]:this.filter[e-(n+r)]}}return a},[{predicate:(e,t,n,r)=>t===0||r===void 0,render:(e,t,n,r)=>{r===void 0&&(r=n,n=t,t=0);let i=E(e);class a extends je{static EntityType=e.EntityType;pools;filter;elem;pushOnConstruct(e){!this.elem.contains(e)&&this.pools.every(t=>t.contains(e))&&this.filter.every(t=>!t.contains(e))&&this.elem.push(e)}pushOnDestroy(e){this.elem.contains(e)&&this.pools.every(t=>t.contains(e))&&this.filter.reduce((t,n)=>t+Number(n.contains(e)),0)===1&&this.elem.remove(e)}removeIf(e){this.elem.remove(e)}commonSetup(){let t=F(e.prototype.begin.call(this.pools[0]),e.prototype.end.call(this.pools[0]));for(let e of t)this.pushOnConstruct(e)}static CommonType=e;constructor(e,t){super(),this.pools=Array(n),this.filter=Array(r);for(let t=0;t<n;++t)this.pools[t]=e[t];for(let e=0;e<r;++e)this.filter[e]=t[e];this.elem=i(),e.forEach(e=>{e.onConstruct().connect(function(e,t){a.prototype.pushOnConstruct.call(this,t)},this),e.onDestroy().connect(function(e,t){a.prototype.removeIf.call(this,t)},this)}),t.forEach(e=>{e.onConstruct().connect(function(e,t){a.prototype.removeIf.call(this,t)},this),e.onDestroy().connect(function(e,t){a.prototype.pushOnDestroy.call(this,t)},this)}),this.commonSetup()}handle(){return this.elem}storage(e){return e<n?this.pools[e]:this.filter[e-n]}}return a}}]),Q=O(function(e,t,n){throw Error(`Invalid BasicGroup instantiation`)},[{predicate:(e,t,n)=>e.length===0||e==null||Array.isArray(e)&&Array.isArray(t)&&n===void 0,render(t,n,r){Array.isArray(t)&&Array.isArray(n)&&r===void 0&&(r=n,n=t);let i=J(...n.map(e=>e.constructor.BaseType),...r.map(e=>e.constructor.BaseType)),a=i.EntityType,o=Me.instantiate(i,0,n.length,r.length);if(n.length===0)throw Error(`Non-owning group must have at least one get type`);class s{static BaseType=i;static UnderlyingType=a;static indexOf(e){return[...n.map(e=>e.constructor.ElementType),...r.map(e=>e.constructor.ElementType)].indexOf(e)}poolsFor(...e){return this.descriptor?e.map(e=>this.descriptor.storage(e)):[]}static EntityType=a;static CommonType=i;static Iterator=i.Iterator;static ReverseIterator=i.ReverseIterator;static Handler=o;descriptor;static groupId(){return e([`non-owning`,...n,...r])}constructor(e){this.descriptor=e??null}handle(){return this.descriptor.handle()}storage(e){return typeof e==`number`?this.ok()?this.descriptor.storage(e):null:this.storage(s.indexOf(e))}ok(){return this.descriptor!=null}get size(){return this.ok()?this.handle().size:0}capacity(){return this.ok()?this.handle().capacity():0}empty(){return!this.ok()||this.handle().empty()}begin(){return this.ok()?this.handle().begin():new i.Iterator}end(){return this.ok()?this.handle().end():new i.Iterator}rbegin(){return this.ok()?this.handle().rbegin():new i.ReverseIterator(new i.Iterator)}rend(){return this.ok()?this.handle().rend():new i.ReverseIterator(new i.Iterator)}front(){let e=this.begin();return e.equals(this.end())?i.TraitsType.null:e.deref()}back(){let e=this.rbegin();return e.equals(this.rend())?i.TraitsType.null:e.deref()}find(e){return this.ok()?this.handle().find(e):new i.Iterator}access(e){return this.begin().access(e)}contains(e){return this.ok()&&this.handle().contains(e)}get(e,...t){return this.getByIndexes(e,...t.map(e=>s.indexOf(e)))}getByIndexes(e,...t){let r=this.poolsFor(...Array.from({length:n.length},(e,t)=>t));return t.length===0?r.flatMap(t=>t.getAsTuple(e)):t.length===1?r[t[0]].get(e):t.flatMap(t=>r[t].getAsTuple(e))}each(e,t){if(typeof e==`function`)for(let n of this){let r=this.get(n);t?e.apply(this,r):e.call(this,n,...r)}else{let e=this.poolsFor(...Array.from({length:n.length},(e,t)=>t));return new N(new Z(this.begin(),[],e),new Z(this.end(),[],e))}}[Symbol.iterator](){return F(this)}sort(e,t,n=u){this.sortByIndexes(e,t.map(e=>s.indexOf(e)),n)}sortByIndexes(e,t,n=u){if(this.ok())if(t.length===0)this.descriptor.handle().sort(e,n);else{let r=this.poolsFor(...t);this.descriptor.handle().sort((n,i)=>t.length===1?e(r[t[0]].get(n),r[t[0]].get(i)):e(t.map(e=>r[e].get(n)),t.map(e=>r[e].get(i))),n)}}sortAs(e,t){this.ok()&&this.descriptor.handle().sortAs(e,t)}}return s}},{predicate:(e,t,n)=>e.length>0,render(t,n,r){let i=J(...t.map(e=>e.constructor.BaseType),...n.map(e=>e.constructor.BaseType),...r.map(e=>e.constructor.BaseType)),a=i.EntityType,o=Me.instantiate(i,t.length,n.length,r.length);class s{static BaseType=i;static UnderlyingType=a;static indexOf(e){return[...t.map(e=>e.constructor.ElementType),...n.map(e=>e.constructor.ElementType),...r.map(e=>e.constructor.ElementType)].indexOf(e)}poolsFor(e,n){return this.descriptor?[...e.map(e=>this.descriptor.storage(e)),...n.map(e=>this.descriptor.storage(e+t.length))]:[]}static EntityType=a;static CommonType=i;static Iterator=i.Iterator;static ReverseIterator=i.ReverseIterator;static Handler=o;descriptor;static groupId(){return e([t,n,r])}constructor(e){this.descriptor=e??null}handle(){return this.storage(0)}ok(){return this.descriptor!=null}storage(e){return typeof e==`number`?this.ok()?this.descriptor.storage(e):null:this.storage(s.indexOf(e))}get size(){return this.ok()?this.descriptor.length():0}empty(){return!this.ok()||!this.descriptor.length()}begin(){return this.ok()?i.prototype.end.call(this.handle()).minus(this.descriptor.length()):new i.Iterator}end(){return this.ok()?i.prototype.end.call(this.handle()):new i.Iterator}rbegin(){return this.ok()?i.prototype.rbegin.call(this.handle()):new i.ReverseIterator(new i.Iterator)}rend(){return this.ok()?i.prototype.rbegin.call(this.handle()).plus(this.descriptor.length()):new i.ReverseIterator(new i.Iterator)}front(){let e=this.begin();return e.equals(this.end())?i.TraitsType.null:e.deref()}back(){let e=this.rbegin();return e.equals(this.rend())?i.TraitsType.null:e.deref()}find(e){let t=this.ok()?this.handle().find(e):new i.Iterator;return t.gte(this.begin())?t:new i.Iterator}access(e){return this.begin().access(e)}contains(e){return this.ok()&&this.handle().contains(e)&&this.handle().index(e)<this.descriptor.length()}get(e,...t){return this.getByIndexes(e,...t.map(e=>s.indexOf(e)))}getByIndexes(e,...r){let i=this.poolsFor(Array.from({length:t.length},(e,t)=>t),Array.from({length:n.length},(e,t)=>t));return r.length===0?i.flatMap(t=>t.getAsTuple(e)):r.length===1?i[r[0]].get(e):r.flatMap(t=>i[t].getAsTuple(e))}each(e,r){if(typeof e==`function`)for(let t of this.each())r?e.apply(this,t.slice(1)):e.apply(this,t);else{let e=this.poolsFor(Array.from({length:t.length},(e,t)=>t),Array.from({length:n.length},(e,t)=>t)),r=this.begin(),i=this.end();return new N(new Z(r,e.slice(0,t.length),e.slice(t.length)),new Z(i,e.slice(0,t.length),e.slice(t.length)))}}[Symbol.iterator](){return F(this)}sort(e,t,n=u){this.sortByIndexes(e,t.map(e=>s.indexOf(e)),n)}sortByIndexes(e,r,i=u){let a=this.poolsFor(Array.from({length:t.length},(e,t)=>t),Array.from({length:n.length},(e,t)=>t));r.length===0?this.storage(0).sortN(this.descriptor.length(),e,i):this.storage(0).sortN(this.descriptor.length(),(t,n)=>r.length===1?e(a[r[0]].get(t),a[r[0]].get(n)):e(r.map(e=>a[e].get(t)),r.map(e=>a[e].get(n))),i),((...e)=>{let[t,...n]=e;for(let e=this.descriptor.length();e;--e){let r=e-1,i=t.data()[r];n.forEach(e=>{e.swapElements(e.data()[r],i)})}}).apply(this,a)}}return s}}]);function Ne(e,t,n=[]){return new(Q.instantiate(e,t,n))}const Pe=O(function(e){let t=K.instantiate(e,e),n=t.TraitsType,r=n.ValueType,i=z.instantiate(e);return class extends D{static TraitsType=n;static EntityType=r;static CommonType=i;entities;vars;groups;pools;constructor(){super(),this.entities=new t,this.entities.bind(this),this.vars=Object.create(null),this.groups=new Map,this.pools=new Map}dispose(){for(let e of this.groups.values())e.dispose();this.groups.clear();for(let e of this.pools.values())e.dispose();this.pools.clear(),this.entities.dispose(),Object.keys(this.vars).forEach((e,t)=>{delete this.vars[t]})}assure(e){let[t,n]=f(e);if(typeof t!=`function`&&t!==void 0)throw Error(`Invalid component type`);if(Object.is(t,r))return this.entities;if(this.pools.has(n))return this.pools.get(n),this.pools.get(n);let i=new(K.instantiate(t,r));return this.pools.set(n,i),i.bind(this),i}constAssure(e){let[t,n]=f(e);if((typeof t==`function`||t===void 0)&&Object.is(t,r))return this.entities;let i=this.pools.get(n);if(i)return i}ctx(){return this.vars}create(e){return this.entities.generate(e)}createRange(e,t){this.entities.generateRange(e,t)}insert(e,t,n,r){n=n.clone(),this.assure(e).insert(t,n,r)}insertRange(e,t,n,r){n=n.clone(),this.assure(e).insertRange(t,n,r)}storage(){return this.pools.entries()}getStorage(e,t=!1){return!t&&(typeof e==`function`||Array.isArray(e)||e===void 0)?this.assure(e):this.constAssure(e)}reset(e){return this.pools.delete(e)}valid(e){let t=this.entities.find(e).index();return t>=0&&t<this.entities.freeList()}current(e){return this.entities.current(e)}destroy(e,t){let r=[...this.pools.values()];for(let t=r.length-1;t>=0;--t)r[t].remove(e);this.entities.erase(e);let i=this.entities.current(e);if(t!==void 0){let r=n.construct(n.toEntity(e),t);return this.entities.bump(n.isTombstone(r)?n.next(r):r)}return i}destroyRange(e,t){let n=t==null?this.entities.sortAs(e):this.entities.sortAs(e,t),r=this.entities.end().minus(Number(this.entities.freeList()));for(let e of this.pools.values())e.remove(r,n);this.entities.erase(r,n)}emplace(e,t,...n){return this.assure(t).emplace(e,...n)}emplaceOrReplace(e,t,...n){let r=this.assure(t);return r.has(e)?r.patch(e,()=>E(r.type())(...n)):r.emplace(e,...n)}patch(e,t,...n){return this.assure(t).patch(e,...n)}replace(e,t,...n){let r=this.assure(t);return r.patch(e,()=>E(r.type())(...n))}remove(e,...t){let n=0;for(let r of t)this.assure(r).delete(e)&&++n;return n}removeRange(e,t,...n){let r=0;if(e=e.clone(),t=t.clone(),e instanceof R&&t instanceof R){let i=n.map(e=>this.assure(e)),a=I(i),o=a.begin(),s=a.end();for(;!o.equals(s);o.selfPlus()){if(n.length>1&&o.deref().data()===e.data()){let e=o.deref();o.write(i[i.length-1]),i[i.length-1]=e}r+=o.deref().remove(e,t)}}else for(let i=n.map(e=>this.assure(e));!e.equals(t);e.selfPlus()){let t=e.deref();for(let e of i)r+=e.remove(t)?1:0}return r}eraseIf(e,t){for(let[n,r]of this.storage())r.contains(e)&&t(n,r)&&r.erase(e)}erase(e,...t){for(let n of t)this.assure(n).erase(e)}eraseRange(e,t,...n){if(e=e.clone(),t=t.clone(),e instanceof R&&t instanceof R){let r=n.map(e=>this.assure(e)),i=I(r),a=i.begin(),o=i.end();for(;!a.equals(o);a.selfPlus()){if(n.length>1&&a.deref().data()===e.data()){let e=a.deref();a.write(r[r.length-1]),r[r.length-1]=e}a.deref().erase(e,t)}}else for(let r=n.map(e=>this.assure(e));!e.equals(t);e.selfPlus()){let t=e.deref();for(let e of r)e.erase(t)}}compact(...e){if(e.length===0)for(let e of this.pools.values())e.compact();else for(let t of e)this.assure(t).compact()}allOf(e,...t){if(t.length===1){let n=this.constAssure(t[0]);return n!=null&&n?.has(e)}return t.every(t=>this.allOf(e,t))}anyOf(e,...t){return t.some(t=>this.allOf(e,t))}tryGet(e,...t){if(t.length===1){let n=this.constAssure(t[0]);return n&&n.has(e)?n.get(e):void 0}return t.map(t=>this.tryGet(e,t))}get(e,...t){return t.length===1?this.assure(t[0]).get(e):t.map(t=>this.get(e,t))}getOrEmplace(e,t,...n){let r=this.assure(t);return r.has(e)?r.get(e):r.emplace(e,...n)}clear(...e){if(e.length===0){let e=[...this.pools.values()];for(let t=e.length-1;t>=0;--t)e[t].clear();let t=this.entities.each();this.entities.erase(t.begin().base(),t.end().base())}else e.forEach(e=>{this.assure(e).clear()})}orphan(e){return![...this.pools.values()].some(t=>t.has(e))}onConstruct(e){return this.assure(e).onConstruct()}onUpdate(e){return this.assure(e).onUpdate()}onDestroy(e){return this.assure(e).onDestroy()}sort(e,t,n=u){let r=this.assure(e);r.sort((e,n)=>t(r.get(e),r.get(n)),n)}sortByEntity(e,t,n=u){this.assure(e).sort(t,n)}sortAs(e,t){let n=this.assure(t);this.assure(e).sortAs(n.begin(),n.end())}view(e,t=[]){let n=e.map(e=>this.assure(e)),r=t.map(e=>this.assure(e));return new(X.instantiate(n,r))(n,r)}group(e,t=[],n=[]){let r=e.map(e=>this.assure(e)),i=t.map(e=>this.assure(e)),a=n.map(e=>this.assure(e)),o=Q.instantiate(r,i,a),s=o.Handler;if(this.groups.has(o.groupId()))return new o(this.groups.get(o.groupId()));let c;return c=r.length===0?new s(i,a):new s([...r,...i],a),this.groups.set(o.groupId(),c),new o(c)}groupIfExists(e,t=[],n=[]){let r=e.map(e=>this.assure(e)),i=t.map(e=>this.assure(e)),a=n.map(e=>this.assure(e)),o=Q.instantiate(r,i,a);return this.groups.has(o.groupId())?new o(this.groups.get(o.groupId())):new o}owned(...e){for(let t of this.groups.values())if(e.some(e=>t.owned(e)))return!0;return!1}}}),Fe=(()=>Pe.instantiate(S))();var $=class e{pools;filter;it;tombstoneCheck;valid(){let e=this.it.deref();return(!this.tombstoneCheck||!this.pools[0].isTombstone(e))&&this.pools.every(t=>t.contains(e))&&!this.filter.some(t=>t?.contains(e))}constructor(e,t,n){e!=null&&t!=null&&n!=null?(this.pools=e,this.it=t.clone(),this.filter=n,this.tombstoneCheck=e.length===1&&e[0].policy()===L.InPlace,!this.it.equals(B.prototype.end.call(e[0]))&&!this.valid()&&this.selfPlus()):(this.pools=[],this.it=new R,this.filter=[],this.tombstoneCheck=!1)}clone(t){if(t)return t===this?this:(t.pools=this.pools.slice(),t.it=this.it.clone(),t.filter=this.filter.slice(),t.tombstoneCheck=this.tombstoneCheck,t);let n=new e;return n.pools=this.pools.slice(),n.it=this.it.clone(),n.filter=this.filter.slice(),n.tombstoneCheck=this.tombstoneCheck,n}swap(e){if(this===e)return;this.it.swap(e.it);let t=this.pools,n=this.filter,r=this.tombstoneCheck;this.pools=e.pools,this.filter=e.filter,this.tombstoneCheck=e.tombstoneCheck,e.pools=t,e.filter=n,e.tombstoneCheck=r}write(e){return this.it.write(e)}deref(){return this.it.deref()}selfPlus(){this.it.selfPlus();for(let e=B.prototype.end.call(this.pools[0]);!this.it.equals(e)&&!this.valid();this.it.selfPlus());return this}selfMinus(){this.it.selfMinus();for(let e=B.prototype.begin.call(this.pools[0]);!this.it.equals(e)&&!this.valid();this.it.selfMinus());return this}equals(e){return this.it.equals(e.it)}};const Ie=O(function(e){class t extends D{pools;filter;offset(){let e=this.pools[0];return e.policy()===L.SwapOnly?Number(e.freeList()):e.size}static EntityType=e.EntityType;static CommonType=e;static Iterator=$;constructor(){super(),this.pools=[],this.filter=[]}dispose(){this.pools.length=0,this.filter.length=0}clear(){this.pools.length=0,this.filter.length=0}iterate(e){if(this.pools.length===0||!(e.size<this.pools[0].size))this.pools.push(e);else{let t=this.pools[0];this.pools[0]=e,this.pools.push(t)}return this}exclude(e){return this.filter.push(e),this}sizeHint(){return this.pools.length===0?0:this.offset()}begin(){return this.pools.length===0?new $:new $(this.pools,e.prototype.end.call(this.pools[0]).minus(this.offset()),this.filter)}end(){return this.pools.length===0?new $:new $(this.pools,e.prototype.end.call(this.pools[0]),this.filter)}ok(){return!(this.pools.length===0&&this.filter.length===0)}contains(e){return this.pools.length!==0&&this.pools.every(t=>t.contains(e))&&!this.filter.some(t=>t?.contains(e))&&this.pools[0].index(e)<this.offset()}each(e){for(let t of this)e(t)}[Symbol.iterator](){return F(this.begin(),this.end())}}return t}),Le=(()=>Ie.instantiate(B))();function Re(e){let t=e.getStorage(e.constructor.EntityType);for(let n of t)e.orphan(n)&&t.erase(n)}const ze=O(function(e){let t=k.instantiate(e.EntityType),n=e.EntityType;class r extends D{static TraitsType=t;static RegistryType=e;static EntityType=n;reg;constructor(e){super(),this.reg=e}dispose(){this.reg=null}get(r,i){let[a]=f(i),o=this.reg.getStorage(i,!0);if(o){let i=o;if(r.saveSize(t.EntityType(o.size)),a===n){r.saveSize(t.EntityType(o.freeList()));let n=e.CommonType.prototype.rbegin.call(i),a=e.CommonType.prototype.rend.call(i);for(;!n.equals(a);n.selfPlus())r.saveEntity(n.deref())}else if(K.instantiate(a,e.EntityType).storagePolicy===L.InPlace){let n=e.CommonType.prototype.rbegin.call(i),a=e.CommonType.prototype.rend.call(i);for(;!n.equals(a);n.selfPlus()){let i=n.deref();if(e.CommonType.isTombstone(i))r.saveEntity(t.null);else{r.saveEntity(i);let e=o.getAsTuple(i);for(let t=0;t<e.length;++t)r.saveComponent(e[t])}}}else for(let e of o.reach())r.saveEntity(e[0]),e.length>1&&r.saveComponent(e[1])}else r.saveSize(t.EntityType(0));return this}getRange(e,n,r,i){let[a]=f(i),o=this.reg.getStorage(i,!0);if(o&&!o.empty())for(e.saveSize(t.EntityType(ue(n,r))),n=n.clone(),r=r.clone();!n.equals(r);n.selfPlus()){let r=n.deref();if(o.contains(r)){e.saveEntity(r);let t=o.getAsTuple(r);for(let n=0;n<t.length;++n)e.saveComponent(t[n])}else e.saveEntity(t.null)}else e.saveSize(t.EntityType(0));return this}}return r}),Be=O(function(e){let t=k.instantiate(e.EntityType),n=e.EntityType,r=E(n);class i extends D{static TraitsType=t;static RegistryType=e;static EntityType=n;reg;constructor(e){super(),this.reg=e}dispose(){this.reg=null}get(e,i){let[a]=f(i),o=this.reg.getStorage(i),s=new p(t.EntityType(0));if(e.loadSize(s),a===n){let n=new p(t.EntityType(0)),i=r();o.reserve(s.value),e.loadSize(n);let a=new p(t.null);for(;s.value>0;--s.value)e.loadEntity(a),o.generate(a.value),i=a.value>i?a.value:i;o.startFrom(t.next(i)),o.freeList(n.value)}else{let r=this.reg.getStorage(n),i=new p(t.null),c=V.instantiate(o.constructor.ElementType,o.constructor.EntityType).pageSize===0,l=c?(()=>void 0):E(a);for(;s.value--;)if(e.loadEntity(i),!t.isNull(i.value)){let t=r.contains(i.value)?i.value:r.generate(i.value);if(c)o.emplace(t);else{let n=new p(l());e.loadComponent(n),o.emplace(t,n.value)}}}return this}orphans(){return Re(this.reg),this}}return i}),Ve=O(function(e){let t=k.instantiate(e.EntityType),n=e.EntityType;class r extends D{static RegistryType=e;static EntityType=n;static TraitsType=t;remloc;reg;restore(e){let n=t.toEntity(e),r=this.remloc.get(n);r!==void 0&&t.toIntegral(r[0])===t.toIntegral(e)?this.reg.valid(r[1])||(r[1]=this.reg.create()):this.remloc.set(n,[e,this.reg.create()])}constructor(e){super(),this.remloc=new Map,this.reg=e}dispose(){this.remloc.clear(),this.reg=null}get(e,r){let[i]=f(r),a=this.reg.getStorage(r),o=new p(t.EntityType(0)),s=new p(t.null);if(e.loadSize(o),i===n){let n=new p(t.EntityType(0));a.reserve(o.value),e.loadSize(n);for(let t=0;t<n.value;++t)e.loadEntity(s),this.restore(s.value);for(let r=n.value;r<o.value;++r){e.loadEntity(s);let n=t.toEntity(s.value),r=this.remloc.get(n);r!==void 0&&(this.reg.valid(r[1])&&this.reg.destroy(r[1]),this.remloc.delete(n))}}else{for(let e of this.remloc.values())a.remove(e[1]);let n=V.instantiate(a.constructor.ElementType,a.constructor.EntityType).pageSize===0,r=n?(()=>void 0):E(i);for(;o.value--;)if(e.loadEntity(s),!t.isNull(s.value))if(this.restore(s.value),n)a.emplace(this.map(s.value));else{let t=new p(r());e.loadComponent(t),a.emplace(this.map(s.value),t.value)}}return this}orphans(){return Re(this.reg),this}contains(e){let n=this.remloc.get(t.toEntity(e));return n!==void 0&&t.toIntegral(n[0])===t.toIntegral(e)}map(e){let n=this.remloc.get(t.toEntity(e));return n!==void 0&&t.toIntegral(n[0])===t.toIntegral(e)?n[1]:t.null}}return r}),He=(()=>ze.instantiate(Fe))(),Ue=(()=>Be.instantiate(Fe))(),We=(()=>Ve.instantiate(Fe))(),Ge=`0.0.0`;export{P as AggregatePointer,ce as ArrayPointer,le as ArrayRange,ge as BasicDispatcher,fe as Connection,We as ContinuousLoader,de as Delegate,L as DeletionPolicy,D as Disposable,_e as Emitter,C as EmptyTypeOptimization,S as Entity,h as Float32,ee as Float64,je as GroupDescriptor,v as Int16,te as Int32,ne as Int64,g as Int8,t as NotConstructorError,N as RangeIterator,Fe as Registry,A as ReversePointer,Le as RuntimeView,$ as RuntimeViewIterator,pe as ScopedConnection,U as Sigh,H as Sink,He as Snapshot,Ue as SnapshotLoader,B as SparseSet,R as SparseSetPointer,W as StoragePointer,ae as Template,_ as Uint16,y as Uint32,x as Uint64,m as Uint8,Ve as basicContinuousLoaderTemplate,se as basicEnttTraitsTemplate,Q as basicGroupTemplate,Pe as basicRegistryTemplate,Ie as basicRuntimeViewTemplate,ve as basicSighMixinTemplate,Be as basicSnapshotLoaderTemplate,ze as basicSnapshotTemplate,z as basicSparseSetTemplate,G as basicStorageTemplate,X as basicViewTemplate,J as commonType,V as componentTraitsTemplate,T as config,E as createSafeNew,O as defineTemplate,w as directCall,ue as distance,k as enttTraitsTemplate,d as insertionSort,oe as internalEnttTraits,ie as isEmptyClass,Ne as makeGroup,M as makeRangePointer,j as makeReversePointer,ke as makeView,u as stdSort,ye as storageTemplate,K as storageTypeTTemplate,be as storageTypeTemplate,F as toIterator,I as toRange,Ge as version};
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "entt-js",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "TypeScript port of EnTT - a fast and reliable entity-component-system (ECS) implementation.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/toyobayashi/entt-js#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/toyobayashi/entt-js/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/toyobayashi/entt-js.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "toyobayashi",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/entt.js",
|
|
20
|
+
"module": "./dist/entt.js",
|
|
21
|
+
"types": "./dist/entt.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/entt.d.ts",
|
|
25
|
+
"node": {
|
|
26
|
+
"production": "./dist/entt.min.js",
|
|
27
|
+
"default": "./dist/entt.js"
|
|
28
|
+
},
|
|
29
|
+
"default": "./dist/entt.js"
|
|
30
|
+
},
|
|
31
|
+
"./browser": {
|
|
32
|
+
"types": "./dist/entt.d.ts",
|
|
33
|
+
"production": "./dist/browser/index.min.js",
|
|
34
|
+
"default": "./dist/browser/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./entt.js": "./dist/entt.js",
|
|
37
|
+
"./entt.min.js": {
|
|
38
|
+
"types": "./dist/entt.d.ts",
|
|
39
|
+
"default": "./dist/entt.min.js"
|
|
40
|
+
},
|
|
41
|
+
"./browser/index.js": {
|
|
42
|
+
"types": "./dist/entt.d.ts",
|
|
43
|
+
"default": "./dist/browser/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./browser/index.min.js": {
|
|
46
|
+
"types": "./dist/entt.d.ts",
|
|
47
|
+
"default": "./dist/browser/index.min.js"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"build": "tsdown && tsc -p tsconfig.json && rollup -c rollup.config.js",
|
|
57
|
+
"dev": "tsdown --watch",
|
|
58
|
+
"test": "vitest --run",
|
|
59
|
+
"benchmark": "node ./tests/benchmark/main.ts",
|
|
60
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json",
|
|
61
|
+
"release": "npm publish"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^24.0.0",
|
|
65
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
66
|
+
"eslint": "^9.37.0",
|
|
67
|
+
"eslint-config-love": "^133.0.0",
|
|
68
|
+
"rollup": "^4.53.3",
|
|
69
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
70
|
+
"tsdown": "^0.17.0",
|
|
71
|
+
"typescript": "~5.9.3",
|
|
72
|
+
"vitest": "^4.0.15"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"stable-hash": "^0.0.6"
|
|
76
|
+
}
|
|
77
|
+
}
|