"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("three"),r=require("react"),n=require("@react-three/fiber");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=a(e),o=s(t),u=s(r);const c=new o.Matrix4,l=new o.Ray,f=new o.Sphere,d=new o.Vector3;class p extends o.Group{constructor(){super(),this.size=0,this.color=new o.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){var r,n;const a=this.instance.current;if(!a||!a.geometry)return;const s=a.userData.instances.indexOf(this.instanceKey);if(-1===s||s>a.geometry.drawRange.count)return;const i=null!==(r=null==(n=e.params.Points)?void 0:n.threshold)&&void 0!==r?r:1;if(f.set(this.getWorldPosition(d),i),!1===e.ray.intersectsSphere(f))return;c.copy(a.matrixWorld).invert(),l.copy(e.ray).applyMatrix4(c);const u=i/((this.scale.x+this.scale.y+this.scale.z)/3),p=u*u,m=l.distanceSqToPoint(this.position);if(m
e.far)return;t.push({distance:n,distanceToRay:Math.sqrt(m),point:r,index:s,face:null,object:this})}}}let m,y;const g=u.createContext(null),h=new o.Matrix4,b=new o.Vector3,x=u.forwardRef((({children:e,range:t,limit:r=1e3,...a},s)=>{const c=u.useRef(null);u.useImperativeHandle(s,(()=>c.current),[]);const[l,f]=u.useState([]),[[d,p,x]]=u.useState((()=>[new Float32Array(3*r),Float32Array.from({length:3*r},(()=>1)),Float32Array.from({length:r},(()=>1))]));u.useEffect((()=>{c.current.geometry.attributes.position.needsUpdate=!0})),n.useFrame((()=>{for(c.current.updateMatrix(),c.current.updateMatrixWorld(),h.copy(c.current.matrixWorld).invert(),c.current.geometry.drawRange.count=Math.min(r,void 0!==t?t:r,l.length),m=0;m