@hatiolab/things-scene 10.0.0-beta.92 → 10.0.0-beta.93

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.
Files changed (38) hide show
  1. package/dist-types/diagnostics/contract-inspector.d.ts +103 -0
  2. package/dist-types/diagnostics/contract-inspector.d.ts.map +1 -0
  3. package/dist-types/diagnostics/inspector.d.ts +44 -0
  4. package/dist-types/diagnostics/inspector.d.ts.map +1 -1
  5. package/dist-types/math/component-pose.d.ts +51 -0
  6. package/dist-types/math/component-pose.d.ts.map +1 -0
  7. package/dist-types/math/index.d.ts +3 -0
  8. package/dist-types/math/index.d.ts.map +1 -0
  9. package/dist-types/math/pose6dof.d.ts +93 -0
  10. package/dist-types/math/pose6dof.d.ts.map +1 -0
  11. package/dist-types/navigation/index.d.ts +7 -0
  12. package/dist-types/navigation/index.d.ts.map +1 -0
  13. package/dist-types/navigation/nav-graph.d.ts +55 -0
  14. package/dist-types/navigation/nav-graph.d.ts.map +1 -0
  15. package/dist-types/navigation/path-planner.d.ts +29 -0
  16. package/dist-types/navigation/path-planner.d.ts.map +1 -0
  17. package/dist-types/navigation/reservation-table.d.ts +103 -0
  18. package/dist-types/navigation/reservation-table.d.ts.map +1 -0
  19. package/dist-types/navigation/types.d.ts +145 -0
  20. package/dist-types/navigation/types.d.ts.map +1 -0
  21. package/dist-types/things-scene/index.d.ts +8 -2
  22. package/dist-types/things-scene/index.d.ts.map +1 -1
  23. package/dist-types/transfer/container-capacity.d.ts +72 -0
  24. package/dist-types/transfer/container-capacity.d.ts.map +1 -1
  25. package/dist-types/transfer/index.d.ts +7 -1
  26. package/dist-types/transfer/index.d.ts.map +1 -1
  27. package/dist-types/transfer/pickup-helpers.d.ts +65 -0
  28. package/dist-types/transfer/pickup-helpers.d.ts.map +1 -0
  29. package/dist-types/transfer/transfer.d.ts +168 -0
  30. package/dist-types/transfer/transfer.d.ts.map +1 -0
  31. package/dist-types/transfer/types.d.ts +104 -0
  32. package/dist-types/transfer/types.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/things-scene-min.js +10 -10
  35. package/things-scene-min.js.map +1 -1
  36. package/things-scene-transfer.mjs +6 -1
  37. package/things-scene.mjs +3 -3
  38. package/things-scene.mjs.map +1 -1
@@ -1 +1,6 @@
1
- class t{positionAt(t,e,s){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const e=new t;class s{constructor(t){this.owner=t}positionAt(t,e,s,n){if(0!==t)return null;const i=this.owner?.state?.width??0,r=this.owner?.state?.height??0,o=n?.state?.width??0,a=n?.state?.height??0;return{x:Math.max(0,(i-o)/2),y:Math.max(0,(r-a)/2),z:0}}capacity(t){return t.maxCount??1}}const n="_transferSlotId";function i(t){return class extends t{get slots(){return[]}get arrangementStrategy(){return e}canReceive(t){return null!==this.findSlot(t)}findSlot(t){const e=this.slots;if(!e.length)return null;for(const s of e){if(s.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!s.allowedTypes.includes(e))continue}const e=s.maxCount??this.arrangementStrategy.capacity(s);if(!(this._countOccupied(s.id)>=e))return s}return null}async receive(t,e={}){const s=this.findSlot(t);if(!s)return void this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const i=this._countOccupied(s.id),r=this.arrangementStrategy.positionAt(i,s,i,t);t[n]=s.id;const{animated:o=!1,duration:a,ease:c}=e;this.reparent?.(t,{animated:o,duration:a,ease:c}),!o&&t._realObject&&(t._realObject.suppressTransform=!1);{const e=this._realObject?.receivingSurfaceY??0,n={};if(r&&(n.left=r.x,n.top=r.y),0!==e)n.zPos=0;else if(s.localPosition&&Number.isFinite(s.localPosition.z)){const t=this._realObject?.geometricOffsetY??0;n.zPos=s.localPosition.z+t}Object.keys(n).length&&t.setState?.(n)}this.trigger("transfer-received",{type:"transfer-received",component:t,container:this,slotId:s.id})}async dispatch(t,e,s={}){e.canReceive(t)?(delete t[n],await e.receive(t,s),this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e})):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"target-full"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}attachPointFor(t){const e=t?.[n];if(!e)return null;const s=this.slots.find(t=>t.id===e);return s?{position:s.localPosition??{x:0,y:0,z:0},rotation:s.localRotation??{x:0,y:0,z:0},slotId:s.id}:null}_countOccupied(t){const e=this.components;return e?e.filter(e=>e[n]===t).length:0}}}const r=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};export{s as CenteringSlotStrategy,i as ContainerCapacity,t as FixedSlotStrategy,n as TRANSFER_SLOT_KEY,e as fixedSlotStrategy,r as globalSimClock};
1
+ const t={x:0,y:0,z:0,w:1};function e(t){const e=t/2;return{x:0,y:Math.sin(e),z:0,w:Math.cos(e)}}function s(t,e){const s=t.rotation,i=e.rotation,r=e.position,n=s.w*r.x+s.y*r.z-s.z*r.y,o=s.w*r.y+s.z*r.x-s.x*r.z,h=s.w*r.z+s.x*r.y-s.y*r.x,a=-s.x*r.x-s.y*r.y-s.z*r.z,c=n*s.w+a*-s.x+o*-s.z-h*-s.y,l=o*s.w+a*-s.y+h*-s.x-n*-s.z,d=h*s.w+a*-s.z+n*-s.y-o*-s.x,u={x:s.w*i.x+s.x*i.w+s.y*i.z-s.z*i.y,y:s.w*i.y-s.x*i.z+s.y*i.w+s.z*i.x,z:s.w*i.z+s.x*i.y-s.y*i.x+s.z*i.w,w:s.w*i.w-s.x*i.x-s.y*i.y-s.z*i.z};return{position:{x:t.position.x+c,y:t.position.y+l,z:t.position.z+d},rotation:u}}const i={east:{axis:{x:1,y:0,z:0},yaw:0,idSuffix:"east"},west:{axis:{x:-1,y:0,z:0},yaw:Math.PI,idSuffix:"west"},south:{axis:{x:0,y:0,z:1},yaw:-Math.PI/2,idSuffix:"south"},north:{axis:{x:0,y:0,z:-1},yaw:Math.PI/2,idSuffix:"north"}};function r(t){const{carrierWorld:r,width:n,depth:o,entryHeight:h,approachDistance:a,sides:c,toolType:l,tolerance:d,priority:u}=t,_=n/2,y=o/2;return c.map(t=>{const n=i[t],o="string"==typeof l?l:l[t]??"unknown",c={position:{x:n.axis.x*("east"===t||"west"===t?_:0),y:h,z:n.axis.z*("north"===t||"south"===t?y:0)},rotation:e(n.yaw)},m={position:{x:c.position.x+n.axis.x*a,y:h,z:c.position.z+n.axis.z*a},rotation:e(n.yaw)};return{id:`entry-${n.idSuffix}`,toolType:o,approach:s(r,m),engage:s(r,c),tolerance:d,priority:u}})}function n(e){const{carrierWorld:i,topY:r,approachDistance:n,toolType:o,tolerance:h,priority:a,id:c}=e,l={position:{x:0,y:r,z:0},rotation:{...t}};return{id:c??"top",toolType:o,approach:s(i,{position:{x:0,y:r+n,z:0},rotation:{...t}}),engage:s(i,l),tolerance:h,priority:a}}function o(t,e){return t.filter(t=>t.toolType===e.toolType)}function h(t,e){if(0===t.length)return null;const s=t.map(t=>{const s=t.approach.position.x-e.x,i=t.approach.position.y-e.y,r=t.approach.position.z-e.z;return{f:t,dist:Math.sqrt(s*s+i*i+r*r)}});return s.sort((t,e)=>{const s=t.f.priority??0,i=e.f.priority??0;return s!==i?s-i:t.dist-e.dist}),s[0].f}class a{positionAt(t,e,s){return 0!==t?null:e.localPosition??{x:0,y:0,z:0}}capacity(t){return 1}}const c=new a;class l{constructor(t){this.owner=t}positionAt(t,e,s,i){if(0!==t)return null;const r=this.owner?.state?.width??0,n=this.owner?.state?.height??0,o=i?.state?.width??0,h=i?.state?.height??0;return{x:Math.max(0,(r-o)/2),y:Math.max(0,(n-h)/2),z:0}}capacity(t){return t.maxCount??1}}
2
+ /**
3
+ * @license
4
+ * Copyright 2010-2026 Three.js Authors
5
+ * SPDX-License-Identifier: MIT
6
+ */const d=2e3;function u(...t){t=function(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}(t);const e="THREE."+t.shift();{const s=t[0];s&&s.isStackTrace?console.warn(s.getError(e)):console.warn(e,...t)}}function _(t,e,s){return Math.max(e,Math.min(s,t))}class y{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,r,n,o){let h=s[i+0],a=s[i+1],c=s[i+2],l=s[i+3],d=r[n+0],u=r[n+1],_=r[n+2],y=r[n+3];if(l!==y||h!==d||a!==u||c!==_){let t=h*d+a*u+c*_+l*y;t<0&&(d=-d,u=-u,_=-_,y=-y,t=-t);let e=1-o;if(t<.9995){const s=Math.acos(t),i=Math.sin(s);e=Math.sin(e*s)/i,h=h*e+d*(o=Math.sin(o*s)/i),a=a*e+u*o,c=c*e+_*o,l=l*e+y*o}else{h=h*e+d*o,a=a*e+u*o,c=c*e+_*o,l=l*e+y*o;const t=1/Math.sqrt(h*h+a*a+c*c+l*l);h*=t,a*=t,c*=t,l*=t}}t[e]=h,t[e+1]=a,t[e+2]=c,t[e+3]=l}static multiplyQuaternionsFlat(t,e,s,i,r,n){const o=s[i],h=s[i+1],a=s[i+2],c=s[i+3],l=r[n],d=r[n+1],u=r[n+2],_=r[n+3];return t[e]=o*_+c*l+h*u-a*d,t[e+1]=h*_+c*d+a*l-o*u,t[e+2]=a*_+c*u+o*d-h*l,t[e+3]=c*_-o*l-h*d-a*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t._x,i=t._y,r=t._z,n=t._order,o=Math.cos,h=Math.sin,a=o(s/2),c=o(i/2),l=o(r/2),d=h(s/2),_=h(i/2),y=h(r/2);switch(n){case"XYZ":this._x=d*c*l+a*_*y,this._y=a*_*l-d*c*y,this._z=a*c*y+d*_*l,this._w=a*c*l-d*_*y;break;case"YXZ":this._x=d*c*l+a*_*y,this._y=a*_*l-d*c*y,this._z=a*c*y-d*_*l,this._w=a*c*l+d*_*y;break;case"ZXY":this._x=d*c*l-a*_*y,this._y=a*_*l+d*c*y,this._z=a*c*y+d*_*l,this._w=a*c*l-d*_*y;break;case"ZYX":this._x=d*c*l-a*_*y,this._y=a*_*l+d*c*y,this._z=a*c*y-d*_*l,this._w=a*c*l+d*_*y;break;case"YZX":this._x=d*c*l+a*_*y,this._y=a*_*l+d*c*y,this._z=a*c*y-d*_*l,this._w=a*c*l-d*_*y;break;case"XZY":this._x=d*c*l-a*_*y,this._y=a*_*l-d*c*y,this._z=a*c*y+d*_*l,this._w=a*c*l+d*_*y;break;default:u("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],r=e[8],n=e[1],o=e[5],h=e[9],a=e[2],c=e[6],l=e[10],d=s+o+l;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(c-h)*t,this._y=(r-a)*t,this._z=(n-i)*t}else if(s>o&&s>l){const t=2*Math.sqrt(1+s-o-l);this._w=(c-h)/t,this._x=.25*t,this._y=(i+n)/t,this._z=(r+a)/t}else if(o>l){const t=2*Math.sqrt(1+o-s-l);this._w=(r-a)/t,this._x=(i+n)/t,this._y=.25*t,this._z=(h+c)/t}else{const t=2*Math.sqrt(1+l-s-o);this._w=(n-i)/t,this._x=(r+a)/t,this._y=(h+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<1e-8?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(_(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(0===s)return this;const i=Math.min(1,e/s);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,i=t._y,r=t._z,n=t._w,o=e._x,h=e._y,a=e._z,c=e._w;return this._x=s*c+n*o+i*a-r*h,this._y=i*c+n*h+r*o-s*a,this._z=r*c+n*a+s*h-i*o,this._w=n*c-s*o-i*h-r*a,this._onChangeCallback(),this}slerp(t,e){let s=t._x,i=t._y,r=t._z,n=t._w,o=this.dot(t);o<0&&(s=-s,i=-i,r=-r,n=-n,o=-o);let h=1-e;if(o<.9995){const t=Math.acos(o),a=Math.sin(t);h=Math.sin(h*t)/a,e=Math.sin(e*t)/a,this._x=this._x*h+s*e,this._y=this._y*h+i*e,this._z=this._z*h+r*e,this._w=this._w*h+n*e,this._onChangeCallback()}else this._x=this._x*h+s*e,this._y=this._y*h+i*e,this._z=this._z*h+r*e,this._w=this._w*h+n*e,this.normalize();return this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class m{constructor(t=0,e=0,s=0){m.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return void 0===s&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(x.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(x.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6]*i,this.y=r[1]*e+r[4]*s+r[7]*i,this.z=r[2]*e+r[5]*s+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,r=t.elements,n=1/(r[3]*e+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*s+r[8]*i+r[12])*n,this.y=(r[1]*e+r[5]*s+r[9]*i+r[13])*n,this.z=(r[2]*e+r[6]*s+r[10]*i+r[14])*n,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,r=t.x,n=t.y,o=t.z,h=t.w,a=2*(n*i-o*s),c=2*(o*e-r*i),l=2*(r*s-n*e);return this.x=e+h*a+n*l-o*c,this.y=s+h*c+o*a-r*l,this.z=i+h*l+r*c-n*a,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,s=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*s+r[8]*i,this.y=r[1]*e+r[5]*s+r[9]*i,this.z=r[2]*e+r[6]*s+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=_(this.x,t.x,e.x),this.y=_(this.y,t.y,e.y),this.z=_(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=_(this.x,t,e),this.y=_(this.y,t,e),this.z=_(this.z,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(_(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,r=t.z,n=e.x,o=e.y,h=e.z;return this.x=i*h-r*o,this.y=r*n-s*h,this.z=s*o-i*n,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return p.copy(this).projectOnVector(t),this.sub(p)}reflect(t){return this.sub(p.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(_(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const p=new m,x=new y;class f{constructor(t,e,s,i,r,n,o,h,a,c,l,d,u,_,y,m){f.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,s,i,r,n,o,h,a,c,l,d,u,_,y,m)}set(t,e,s,i,r,n,o,h,a,c,l,d,u,_,y,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=s,p[12]=i,p[1]=r,p[5]=n,p[9]=o,p[13]=h,p[2]=a,p[6]=c,p[10]=l,p[14]=d,p[3]=u,p[7]=_,p[11]=y,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new f).fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),s.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this)}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();const e=this.elements,s=t.elements,i=1/z.setFromMatrixColumn(t,0).length(),r=1/z.setFromMatrixColumn(t,1).length(),n=1/z.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*r,e[5]=s[5]*r,e[6]=s[6]*r,e[7]=0,e[8]=s[8]*n,e[9]=s[9]*n,e[10]=s[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,r=t.z,n=Math.cos(s),o=Math.sin(s),h=Math.cos(i),a=Math.sin(i),c=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){const t=n*c,s=n*l,i=o*c,r=o*l;e[0]=h*c,e[4]=-h*l,e[8]=a,e[1]=s+i*a,e[5]=t-r*a,e[9]=-o*h,e[2]=r-t*a,e[6]=i+s*a,e[10]=n*h}else if("YXZ"===t.order){const t=h*c,s=h*l,i=a*c,r=a*l;e[0]=t+r*o,e[4]=i*o-s,e[8]=n*a,e[1]=n*l,e[5]=n*c,e[9]=-o,e[2]=s*o-i,e[6]=r+t*o,e[10]=n*h}else if("ZXY"===t.order){const t=h*c,s=h*l,i=a*c,r=a*l;e[0]=t-r*o,e[4]=-n*l,e[8]=i+s*o,e[1]=s+i*o,e[5]=n*c,e[9]=r-t*o,e[2]=-n*a,e[6]=o,e[10]=n*h}else if("ZYX"===t.order){const t=n*c,s=n*l,i=o*c,r=o*l;e[0]=h*c,e[4]=i*a-s,e[8]=t*a+r,e[1]=h*l,e[5]=r*a+t,e[9]=s*a-i,e[2]=-a,e[6]=o*h,e[10]=n*h}else if("YZX"===t.order){const t=n*h,s=n*a,i=o*h,r=o*a;e[0]=h*c,e[4]=r-t*l,e[8]=i*l+s,e[1]=l,e[5]=n*c,e[9]=-o*c,e[2]=-a*c,e[6]=s*l+i,e[10]=t-r*l}else if("XZY"===t.order){const t=n*h,s=n*a,i=o*h,r=o*a;e[0]=h*c,e[4]=-l,e[8]=a*c,e[1]=t*l+r,e[5]=n*c,e[9]=s*l-i,e[2]=i*l-s,e[6]=o*c,e[10]=r*l+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(M,t,w)}lookAt(t,e,s){const i=this.elements;return C.subVectors(t,e),0===C.lengthSq()&&(C.z=1),C.normalize(),b.crossVectors(s,C),0===b.lengthSq()&&(1===Math.abs(s.z)?C.x+=1e-4:C.z+=1e-4,C.normalize(),b.crossVectors(s,C)),b.normalize(),S.crossVectors(C,b),i[0]=b.x,i[4]=S.x,i[8]=C.x,i[1]=b.y,i[5]=S.y,i[9]=C.y,i[2]=b.z,i[6]=S.z,i[10]=C.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,r=this.elements,n=s[0],o=s[4],h=s[8],a=s[12],c=s[1],l=s[5],d=s[9],u=s[13],_=s[2],y=s[6],m=s[10],p=s[14],x=s[3],f=s[7],z=s[11],g=s[15],M=i[0],w=i[4],b=i[8],S=i[12],C=i[1],k=i[5],R=i[9],v=i[13],I=i[2],E=i[6],T=i[10],F=i[14],A=i[3],N=i[7],j=i[11],P=i[15];return r[0]=n*M+o*C+h*I+a*A,r[4]=n*w+o*k+h*E+a*N,r[8]=n*b+o*R+h*T+a*j,r[12]=n*S+o*v+h*F+a*P,r[1]=c*M+l*C+d*I+u*A,r[5]=c*w+l*k+d*E+u*N,r[9]=c*b+l*R+d*T+u*j,r[13]=c*S+l*v+d*F+u*P,r[2]=_*M+y*C+m*I+p*A,r[6]=_*w+y*k+m*E+p*N,r[10]=_*b+y*R+m*T+p*j,r[14]=_*S+y*v+m*F+p*P,r[3]=x*M+f*C+z*I+g*A,r[7]=x*w+f*k+z*E+g*N,r[11]=x*b+f*R+z*T+g*j,r[15]=x*S+f*v+z*F+g*P,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],i=t[8],r=t[12],n=t[1],o=t[5],h=t[9],a=t[13],c=t[2],l=t[6],d=t[10],u=t[14],_=t[3],y=t[7],m=t[11],p=t[15],x=h*u-a*d,f=o*u-a*l,z=o*d-h*l,g=n*u-a*c,M=n*d-h*c,w=n*l-o*c;return e*(y*x-m*f+p*z)-s*(_*x-m*g+p*M)+i*(_*f-y*g+p*w)-r*(_*z-y*M+m*w)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],r=t[3],n=t[4],o=t[5],h=t[6],a=t[7],c=t[8],l=t[9],d=t[10],u=t[11],_=t[12],y=t[13],m=t[14],p=t[15],x=e*o-s*n,f=e*h-i*n,z=e*a-r*n,g=s*h-i*o,M=s*a-r*o,w=i*a-r*h,b=c*y-l*_,S=c*m-d*_,C=c*p-u*_,k=l*m-d*y,R=l*p-u*y,v=d*p-u*m,I=x*v-f*R+z*k+g*C-M*S+w*b;if(0===I)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/I;return t[0]=(o*v-h*R+a*k)*E,t[1]=(i*R-s*v-r*k)*E,t[2]=(y*w-m*M+p*g)*E,t[3]=(d*M-l*w-u*g)*E,t[4]=(h*C-n*v-a*S)*E,t[5]=(e*v-i*C+r*S)*E,t[6]=(m*z-_*w-p*f)*E,t[7]=(c*w-d*z+u*f)*E,t[8]=(n*R-o*C+a*b)*E,t[9]=(s*C-e*R-r*b)*E,t[10]=(_*M-y*z+p*x)*E,t[11]=(l*z-c*M-u*x)*E,t[12]=(o*S-n*k-h*b)*E,t[13]=(e*k-s*S+i*b)*E,t[14]=(y*f-_*g-m*x)*E,t[15]=(c*g-l*f+d*x)*E,this}scale(t){const e=this.elements,s=t.x,i=t.y,r=t.z;return e[0]*=s,e[4]*=i,e[8]*=r,e[1]*=s,e[5]*=i,e[9]*=r,e[2]*=s,e[6]*=i,e[10]*=r,e[3]*=s,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),r=1-s,n=t.x,o=t.y,h=t.z,a=r*n,c=r*o;return this.set(a*n+s,a*o-i*h,a*h+i*o,0,a*o+i*h,c*o+s,c*h-i*n,0,a*h-i*o,c*h+i*n,r*h*h+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,r,n){return this.set(1,s,r,0,t,1,n,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,r=e._x,n=e._y,o=e._z,h=e._w,a=r+r,c=n+n,l=o+o,d=r*a,u=r*c,_=r*l,y=n*c,m=n*l,p=o*l,x=h*a,f=h*c,z=h*l,g=s.x,M=s.y,w=s.z;return i[0]=(1-(y+p))*g,i[1]=(u+z)*g,i[2]=(_-f)*g,i[3]=0,i[4]=(u-z)*M,i[5]=(1-(d+p))*M,i[6]=(m+x)*M,i[7]=0,i[8]=(_+f)*w,i[9]=(m-x)*w,i[10]=(1-(d+y))*w,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinant();if(0===r)return s.set(1,1,1),e.identity(),this;let n=z.set(i[0],i[1],i[2]).length();const o=z.set(i[4],i[5],i[6]).length(),h=z.set(i[8],i[9],i[10]).length();r<0&&(n=-n),g.copy(this);const a=1/n,c=1/o,l=1/h;return g.elements[0]*=a,g.elements[1]*=a,g.elements[2]*=a,g.elements[4]*=c,g.elements[5]*=c,g.elements[6]*=c,g.elements[8]*=l,g.elements[9]*=l,g.elements[10]*=l,e.setFromRotationMatrix(g),s.x=n,s.y=o,s.z=h,this}makePerspective(t,e,s,i,r,n,o=2e3,h=!1){const a=this.elements,c=2*r/(e-t),l=2*r/(s-i),u=(e+t)/(e-t),_=(s+i)/(s-i);let y,m;if(h)y=r/(n-r),m=n*r/(n-r);else if(o===d)y=-(n+r)/(n-r),m=-2*n*r/(n-r);else{if(2001!==o)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);y=-n/(n-r),m=-n*r/(n-r)}return a[0]=c,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=_,a[13]=0,a[2]=0,a[6]=0,a[10]=y,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,s,i,r,n,o=2e3,h=!1){const a=this.elements,c=2/(e-t),l=2/(s-i),u=-(e+t)/(e-t),_=-(s+i)/(s-i);let y,m;if(h)y=1/(n-r),m=n/(n-r);else if(o===d)y=-2/(n-r),m=-(n+r)/(n-r);else{if(2001!==o)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);y=-1/(n-r),m=-r/(n-r)}return a[0]=c,a[4]=0,a[8]=0,a[12]=u,a[1]=0,a[5]=l,a[9]=0,a[13]=_,a[2]=0,a[6]=0,a[10]=y,a[14]=m,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let t=0;t<16;t++)if(e[t]!==s[t])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const z=new m,g=new f,M=new m(0,0,0),w=new m(1,1,1),b=new m,S=new m,C=new m,k=new f,R=new y;class v{constructor(t=0,e=0,s=0,i=v.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const i=t.elements,r=i[0],n=i[4],o=i[8],h=i[1],a=i[5],c=i[9],l=i[2],d=i[6],y=i[10];switch(e){case"XYZ":this._y=Math.asin(_(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,y),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(d,a),this._z=0);break;case"YXZ":this._x=Math.asin(-_(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,y),this._z=Math.atan2(h,a)):(this._y=Math.atan2(-l,r),this._z=0);break;case"ZXY":this._x=Math.asin(_(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-l,y),this._z=Math.atan2(-n,a)):(this._y=0,this._z=Math.atan2(h,r));break;case"ZYX":this._y=Math.asin(-_(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(d,y),this._z=Math.atan2(h,r)):(this._x=0,this._z=Math.atan2(-n,a));break;case"YZX":this._z=Math.asin(_(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-c,a),this._y=Math.atan2(-l,r)):(this._x=0,this._y=Math.atan2(o,y));break;case"XZY":this._z=Math.asin(-_(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(d,a),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-c,y),this._y=0);break;default:u("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===s&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return k.makeRotationFromQuaternion(t),this.setFromRotationMatrix(k,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return R.setFromEuler(this),this.setFromQuaternion(R,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}v.DEFAULT_ORDER="XYZ","undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"183"}})),"undefined"!=typeof window&&(window.__THREE__?u("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="183");const I=new class{constructor(){this._now=0,this._speed=1,this._paused=!1,this._listeners=new Set}get now(){return this._now}get speed(){return this._speed}set speed(t){this._speed=Math.max(0,t),this._speed>0&&(this._paused=!1)}get isPaused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1}tick(t){if(this._paused||0===this._speed)return 0;const e=Math.min(t,200)*this._speed;return this._now+=e,this._notify(e),e}step(t){t<=0||(this._now+=t,this._notify(t))}onTick(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(t){this._listeners.forEach(e=>e(t))}};function E(t){if(!t)return;const e=t?.state?.id??t?.id;return"string"==typeof e?e:void 0}function T(t){const e={transferId:t.transferId,phase:t.phase,timeline:{...t.timeline}},s=t.sourceId??E(t.source),i=t.targetId??E(t.target),r=t.carrierId??E(t.carrier);return void 0!==s&&(e.sourceId=s),void 0!==i&&(e.targetId=i),void 0!==r&&(e.carrierId=r),void 0!==t.slotId&&(e.slotId=t.slotId),void 0!==t.rejectReason&&(e.rejectReason=t.rejectReason),e}"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_SIM_CLOCK__=I);let F=1;class A{constructor(t){this._phase="pending",this._slot=null,this.id="xfer-"+F++,this.source=t.source,this.target=t.target,this.carrier=t.carrier,this.options=t.options??{},this.physical=t.physical??null,this._timeline={initiatedAt:I.now}}get phase(){return this._phase}get timeline(){return this._timeline}async execute(){this._phase="planning",this._timeline.planStartAt=I.now;const t=this.target.canAccept?.(this.carrier);if(t){if(!t.ok){this._rejectReason=t.reason,this._phase="rolled-back";const e=this._buildReceipt();return N.append(e),e}this._slot=t.slot}else{if(!this.target.canReceive(this.carrier)){this._rejectReason="cannot-receive",this._phase="rolled-back";const t=this._buildReceipt();return N.append(t),t}this._slot="function"==typeof this.target.findSlot?this.target.findSlot(this.carrier):null}if(this._timeline.planEndAt=I.now,this.physical){this._phase="physical",this._timeline.physicalStartAt=I.now;try{await this.physical()}catch(t){this._rejectReason=`physical-failed: ${t.message??"unknown"}`,this._phase="rolled-back";const e=this._buildReceipt();return N.append(e),e}this._timeline.physicalEndAt=I.now}this._phase="handoff",this._timeline.handoffAt=I.now;const e=this.target.accept??this.target.receive;await e.call(this.target,this.carrier,this.options),this._phase="committed",this._timeline.committedAt=I.now;const s=this._buildReceipt();return N.append(s),s}rollback(){if("committed"===this._phase)throw new Error("Cannot rollback a committed transfer");this._rejectReason=this._rejectReason??"manual-rollback",this._phase="rolled-back",N.append(this._buildReceipt())}_buildReceipt(){return{transferId:this.id,source:this.source,target:this.target,carrier:this.carrier,sourceId:E(this.source),targetId:E(this.target),carrierId:E(this.carrier),phase:this._phase,timeline:{...this._timeline},slotId:this._slot?.id,rejectReason:this._rejectReason}}}const N=new class{constructor(){this._entries=[],this._maxEntries=1e3,this._listeners=new Set}append(t){this._entries.push(t),this._entries.length>this._maxEntries&&this._entries.shift(),this._listeners.forEach(e=>e(t))}entries(){return[...this._entries]}forCarrier(t){const e=E(t);return this._entries.filter(s=>s.carrier===t||e&&s.carrierId===e)}forCarrierId(t){return this._entries.filter(e=>e.carrierId===t)}forSourceId(t){return this._entries.filter(e=>e.sourceId===t)}forTargetId(t){return this._entries.filter(e=>e.targetId===t)}forPhase(t){return this._entries.filter(e=>e.phase===t)}inTimeRange(t,e,s="init"){return"init"===s?this._entries.filter(s=>s.timeline.initiatedAt>=t&&s.timeline.initiatedAt<=e):this._entries.filter(s=>{const i=s.timeline.initiatedAt,r=s.timeline.committedAt??s.timeline.handoffAt??s.timeline.physicalEndAt??s.timeline.planEndAt??i;return i<=e&&r>=t})}groupByRejectReason(){const t=new Map;for(const e of this._entries)if(e.rejectReason){const s=t.get(e.rejectReason)??[];s.push(e),t.set(e.rejectReason,s)}return t}stats(){const t=this._entries.length,e={};let s=0,i=0;for(const t of this._entries)e[t.phase]=(e[t.phase]??0)+1,"committed"===t.phase&&void 0!==t.timeline.committedAt&&(s+=t.timeline.committedAt-t.timeline.initiatedAt,i++);const r=e["rolled-back"]??0;return{total:t,byPhase:e,committed:e.committed??0,rolledBack:r,rejectionRate:t>0?r/t:0,avgTransferDurationMs:i>0?s/i:0}}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}clear(){this._entries.length=0}setMaxEntries(t){this._maxEntries=Math.max(1,t)}toJSON(){return this._entries.map(T)}fromJSON(t){this._entries=t.map(t=>({transferId:t.transferId,source:void 0,target:void 0,carrier:void 0,sourceId:t.sourceId,targetId:t.targetId,carrierId:t.carrierId,phase:t.phase,timeline:{...t.timeline},slotId:t.slotId,rejectReason:t.rejectReason}))}replayTo(t){for(const e of this._entries)t(e)}};"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_TRANSFER_LOG__=N);const j=new v,P="_transferSlotId";function O(t){return class extends t{get slots(){return[]}get arrangementStrategy(){return c}canReceive(t){return null!==this.findSlot(t)}findSlot(t){const e=this.slots;if(!e.length)return null;for(const s of e){if(s.allowedTypes?.length){const e=t?.state?.type??t?.type;if(!e||!s.allowedTypes.includes(e))continue}const e=s.maxCount??this.arrangementStrategy.capacity(s);if(!(this._countOccupied(s.id)>=e))return s}return null}async receive(t,e={}){const s=this.findSlot(t);if(!s)return void this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:"no-slot"});const i=this._countOccupied(s.id),r=this.arrangementStrategy.positionAt(i,s,i,t);t[P]=s.id;const{animated:n=!1,duration:o,ease:h}=e;this.reparent?.(t,{animated:n,duration:o,ease:h}),!n&&t._realObject&&(t._realObject.suppressTransform=!1);{const e=this._realObject?.receivingSurfaceY??0,i={};if(r&&(i.left=r.x,i.top=r.y),0!==e)i.zPos=0;else if(s.localPosition&&Number.isFinite(s.localPosition.z)){const t=this._realObject?.geometricOffsetY??0;i.zPos=s.localPosition.z+t}const n=this.acceptanceRotation?.(t,s);n&&(j.setFromQuaternion(new y(n.x,n.y,n.z,n.w),"XYZ"),i.rotationX=j.x,i.rotation=-j.y,i.rotationY=j.z),Object.keys(i).length&&t.setState?.(i)}this.trigger("transfer-received",{type:"transfer-received",component:t,container:this,slotId:s.id})}async dispatch(t,e,s={}){const i=new A({source:this,target:e,carrier:t,options:s,physical:async()=>{delete t[P]}}),r=await i.execute();"rolled-back"!==r.phase?this.trigger("transfer-dispatched",{type:"transfer-dispatched",component:t,container:this,target:e}):this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:r.rejectReason??"rejected"})}route(t){return null}resolveRoute(t,e){}rejectRoute(t,e="rejected"){this.trigger("transfer-rejected",{type:"transfer-rejected",component:t,container:this,reason:e})}acceptanceRotation(t,e){}canAccept(t){const e=this.slots;if(!e.length)return{ok:!1,reason:"no-slots-defined"};const s=this.findSlot(t);if(!s){const s=t?.state?.type??t?.type;for(const t of e)if(!t.allowedTypes?.length||!s||t.allowedTypes.includes(s))return{ok:!1,reason:"all-slots-full"};return{ok:!1,reason:"type-not-accepted"}}return{ok:!0,slot:s}}accept(t,e){return this.receive(t,e)}deliveryWorldRotation(t){const e=this.acceptanceRotation?.(t);if(!e)return;const s=this._realObject?.object3d;if(!s)return;s.updateWorldMatrix(!0,!1);const i=new y;s.getWorldQuaternion(i);const r=new y(e.x,e.y,e.z,e.w);return i.clone().multiply(r)}deliveryWorldPosition(t){const e=this._realObject,s=e?.object3d;if(!s)return;s.updateWorldMatrix(!0,!1);const i=new m;s.getWorldPosition(i);const r=e.receivingSurfaceY;if("number"==typeof r&&0!==r){const t=e.geometricOffsetY??0,n=new m(0,r-t,0);return s.localToWorld(n),{x:i.x,y:n.y,z:i.z}}return{x:i.x,y:i.y,z:i.z}}attachPointFor(t){const e=t?.[P];if(!e)return null;const s=this.slots.find(t=>t.id===e);return s?{position:s.localPosition??{x:0,y:0,z:0},rotation:s.localRotation??{x:0,y:0,z:0},slotId:s.id}:null}_countOccupied(t){const e=this.components;return e?e.filter(e=>e[P]===t).length:0}}}let Y=1;function q(t,e){return t.startSimMs<e.endSimMs&&e.startSimMs<t.endSimMs}const L={resolveConflict:(t,e)=>t.priority!==e.priority?t.priority<e.priority?"b-yields":"a-yields":t.id<e.id?"b-yields":"a-yields"};class X{constructor(t=L){this._byResource=new Map,this._byReserver=new Map,this._listeners=new Set,this._conflictLog=[],this._maxConflictLog=1e3,this._yieldPolicy=t}add(t){const e={...t,id:"res-"+Y++},s=(this._byResource.get(e.resource)??[]).filter(t=>q(t.timeWindow,e.timeWindow));if(0===s.length)return this._insert(e),this._emit({kind:"added",reservation:e}),{ok:!0,reservation:e};const i=s.map(t=>{const s=this._yieldPolicy.resolveConflict(e,t);return{a:e,b:t,decision:s}});if(i.every(t=>"b-yields"===t.decision)){const i=s.slice();for(const t of i)this._remove(t),this._emit({kind:"evicted",reservation:t,by:e});return this._insert(e),this._emit({kind:"added",reservation:e}),this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:i,outcome:"preempted"}),{ok:"preempted",reservation:e,evicted:i}}return this._appendConflictLog({simTime:e.timeWindow.startSimMs,resource:e.resource,proposed:t,existing:s.slice(),outcome:"rejected"}),{ok:!1,conflicts:i}}conflictLog(){return[...this._conflictLog]}setMaxConflictLog(t){this._maxConflictLog=Math.max(1,t)}_appendConflictLog(t){this._conflictLog.push(t),this._conflictLog.length>this._maxConflictLog&&this._conflictLog.shift()}conflicts(t,e){return(this._byResource.get(t)??[]).filter(t=>q(t.timeWindow,e))}release(t){this._remove(t)&&this._emit({kind:"released",reservation:t})}releaseAllOf(t){const e=(this._byReserver.get(t)??[]).slice();for(const t of e)this._remove(t),this._emit({kind:"released",reservation:t});return e}forResource(t){return[...this._byResource.get(t)??[]]}forReserver(t){return[...this._byReserver.get(t)??[]]}all(){const t=[];for(const e of this._byResource.values())t.push(...e);return t}clear(){this._byResource.clear(),this._byReserver.clear(),this._conflictLog.length=0}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_insert(t){let e=this._byResource.get(t.resource);e||(e=[],this._byResource.set(t.resource,e));const s=e.findIndex(e=>e.timeWindow.startSimMs>t.timeWindow.startSimMs);s<0?e.push(t):e.splice(s,0,t);let i=this._byReserver.get(t.reserverId);i||(i=[],this._byReserver.set(t.reserverId,i)),i.push(t)}_remove(t){const e=this._byResource.get(t.resource);if(!e)return!1;const s=e.findIndex(e=>e.id===t.id);if(s<0)return!1;e.splice(s,1),0===e.length&&this._byResource.delete(t.resource);const i=this._byReserver.get(t.reserverId);if(i){const e=i.findIndex(e=>e.id===t.id);e>=0&&i.splice(e,1),0===i.length&&this._byReserver.delete(t.reserverId)}return!0}_emit(t){this._listeners.forEach(e=>e(t))}}const Z=new X;"undefined"!=typeof globalThis&&(globalThis.__THINGS_SCENE_RESERVATION_TABLE__=Z);class W{constructor(){this.nodes=new Map,this.edges=new Map,this.laneEndpoints=new Map}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.edges.set(t.id,[]))}addEdge(t){const e=this.edges.get(t.fromNode);if(!e)throw new Error(`NavGraph.addEdge: source node not found: ${t.fromNode}`);if(!this.nodes.has(t.toNode))throw new Error(`NavGraph.addEdge: target node not found: ${t.toNode}`);e.push(t)}edgesFrom(t){return this.edges.get(t)??[]}findNearestNode(t){let e=null,s=1/0;for(const i of this.nodes.values()){const r=V(i.position,t);r<s&&(s=r,e=i)}return e}}function V(t,e){const s=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return s*s+i*i+r*r}function Q(t,e){return Math.sqrt(V(t,e))}function D(t,e,s={}){const i=new W,r=s.defaultSpeed??100;for(const e of t){const t=e.geometry.centerPoints;if(t.length<2)continue;const s=`${e.id}:start`,n=`${e.id}:end`;i.addNode({id:s,position:t[0],type:"lane-start"}),i.addNode({id:n,position:t[t.length-1],type:"lane-end"}),i.laneEndpoints.set(e.id,{startNodeId:s,endNodeId:n});let o=0;for(let e=1;e<t.length;e++)o+=Q(t[e-1],t[e]);const h=o/(e.speedLimit??r)*1e3;i.addEdge({fromNode:s,toNode:n,resource:e.id,distance:o,durationMs:h,forward:!0}),"twoway"===e.direction&&i.addEdge({fromNode:n,toNode:s,resource:e.id,distance:o,durationMs:h,forward:!1})}for(const t of e){if(t.lanes.length<2)continue;const e=[];for(const s of t.lanes){const r=i.laneEndpoints.get(s);if(!r)continue;const n=i.nodes.get(r.startNodeId).position,o=i.nodes.get(r.endNodeId).position;let h=0,a=0,c=0;for(const e of t.lanes){if(e===s)continue;const t=i.laneEndpoints.get(e);if(!t)continue;const r=i.nodes.get(t.startNodeId).position,l=i.nodes.get(t.endNodeId).position;h+=Math.min(V(n,r),V(n,l)),a+=Math.min(V(o,r),V(o,l)),c++}if(0===c)continue;const l=h<a?r.startNodeId:r.endNodeId;e.push({laneId:s,nodeId:l,pos:i.nodes.get(l).position})}for(let s=0;s<e.length;s++)for(let r=0;r<e.length;r++){if(s===r)continue;const n=e[s],o=e[r],h=Q(n.pos,o.pos);i.addEdge({fromNode:n.nodeId,toNode:o.nodeId,resource:t.id,distance:h,durationMs:t.crossingTimeMs,forward:!0})}}return i}function H(t,e,s,i={}){const r=t.nodes.get(e),n=t.nodes.get(s);if(!r||!n)return null;const o=i.speed?.max??100,h=e=>{const s=t.nodes.get(e);var i,r;return(i=s.position,r=n.position,Math.sqrt(function(t,e){const s=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return s*s+i*i+r*r}(i,r)))/o*1e3},a=new Map,c=new Set,l=new Set,d={nodeId:e,gScore:0,fScore:h(e)};a.set(e,d),c.add(e);const u=i.startSimMs??0,_=i.deadlineSimMs;for(;c.size>0;){let e=null,i=null;for(const t of c){const s=a.get(t);(!i||s.fScore<i.fScore||s.fScore===i.fScore&&t<e)&&(i=s,e=t)}if(!i||!e)return null;if(e===s){const t=[];let e=i,s=0;for(;e&&e.cameFromEdge;){const i=e.cameFromEdge,r=u+(e.gScore-i.durationMs);t.unshift({resource:i.resource,timeWindow:{startSimMs:r,endSimMs:r+i.durationMs},fromPos:i.fromPos,toPos:i.toPos}),s+=i.distance,e=a.get(i.fromNodeId)}const r=i.gScore;return void 0!==_&&u+r>_?null:{segments:t,totalDurationMs:r,totalDistance:s}}c.delete(e),l.add(e);for(const s of t.edgesFrom(e)){if(l.has(s.toNode))continue;const e=i.gScore+s.durationMs,r=a.get(s.toNode);if(!r||e<r.gScore){const i=t.nodes.get(s.fromNode),r=t.nodes.get(s.toNode),n={nodeId:s.toNode,gScore:e,fScore:e+h(s.toNode),cameFromEdge:{fromNodeId:s.fromNode,resource:s.resource,distance:s.distance,durationMs:s.durationMs,fromPos:i.position,toPos:r.position}};a.set(s.toNode,n),c.add(s.toNode)}}}return null}function B(t,e,s=0,i){return t.segments.map(t=>({resource:t.resource,timeWindow:t.timeWindow,reserverId:e,priority:s,metadata:i}))}export{l as CenteringSlotStrategy,O as ContainerCapacity,a as FixedSlotStrategy,W as NavGraph,X as ReservationTable,P as TRANSFER_SLOT_KEY,A as Transfer,D as buildNavGraph,h as chooseNearestPickupFrame,o as filterByToolType,c as fixedSlotStrategy,I as globalSimClock,H as planPathAStar,B as planToReservations,e as quatFromYaw,T as receiptToJSON,r as rectangularFootprintFrames,Z as reservationTable,L as standardYieldPolicy,n as topApproachFrame,N as transferLog};