e2b3bb7088
- engine_update_job leert jetzt _engine_cache nach Abschluss (on_done), sonst zeigte das Dashboard bis zu 1h "Update verfuegbar" trotz erfolgter Aktualisierung (1h-Cache wurde nie invalidiert wie bei den anderen Jobs). - check_updates_job leert zusaetzlich _comp_cache, damit "Nach Updates suchen" auch den Hermes-Status frisch prueft. - Neu: GET /api/maintenance/update-details (os|engine|hermes) liefert, was genau aktualisiert wird (apt-Paketliste, Engine Build X->Y + Release-Notes, Hermes-Commits HEAD..origin/branch). - Frontend: "Aktualisieren"-Buttons -> "Anzeigen"; oeffnen ein Detail-Fenster mit den konkreten Aenderungen, erst "Jetzt aktualisieren" startet das Update. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3923 lines
1.1 MiB
Plaintext
3923 lines
1.1 MiB
Plaintext
import{R as Fh,B as Ww,a as Xw,V as _n,F as qw,r as Iy,g as ki,b as q,c as go,d as Yw,e as jw,_ as Tc,u as $w,j as Zw,f as Kw,h as Se,l as Jw,S as Qw,i as Cg,T as eS}from"./index-Qs-v42ar.js";const tS=r=>typeof r=="object"&&typeof r.then=="function",Zc=[];function nS(r,e,t=(n,i)=>n===i){if(r===e)return!0;if(!r||!e)return!1;const n=r.length;if(e.length!==n)return!1;for(let i=0;i<n;i++)if(!t(r[i],e[i]))return!1;return!0}function iS(r,e=null,t=!1,n={}){e===null&&(e=[r]);for(const s of Zc)if(nS(e,s.keys,s.equal)){if(t)return;if(Object.prototype.hasOwnProperty.call(s,"error"))throw s.error;if(Object.prototype.hasOwnProperty.call(s,"response"))return n.lifespan&&n.lifespan>0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,n.lifespan)),s.response;if(!t)throw s.promise}const i={keys:e,equal:n.equal,remove:()=>{const s=Zc.indexOf(i);s!==-1&&Zc.splice(s,1)},promise:(tS(r)?r:r(...e)).then(s=>{i.response=s,n.lifespan&&n.lifespan>0&&(i.timeout=setTimeout(i.remove,n.lifespan))}).catch(s=>i.error=s)};if(Zc.push(i),!t)throw i.promise}const rS=(r,e,t)=>iS(r,e,!1,t);function sS(r,e,t){return Math.max(e,Math.min(r,t))}const Tt={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function Rg(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function Pg(r,e,t,n=.15){return n===0?sS(r,e,t):r<e?-Rg(e-r,t-e,n)+e:r>t?+Rg(r-t,t-e,n)+t:r}function oS(r,[e,t],[n,i]){const[[s,o],[a,c]]=r;return[Pg(e,s,o,n),Pg(t,a,c,i)]}function aS(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function cS(r){var e=aS(r,"string");return typeof e=="symbol"?e:String(e)}function $t(r,e,t){return e=cS(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Lg(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function Ut(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Lg(Object(t),!0).forEach(function(n){$t(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Lg(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Uy={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function Dg(r){return r?r[0].toUpperCase()+r.slice(1):""}const lS=["enter","leave"];function uS(r=!1,e){return r&&!lS.includes(e)}function hS(r,e="",t=!1){const n=Uy[r],i=n&&n[e]||e;return"on"+Dg(r)+Dg(i)+(uS(t,i)?"Capture":"")}const fS=["gotpointercapture","lostpointercapture"];function dS(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=fS.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(n);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:t}}function pS(r,e=""){const t=Uy[r],n=t&&t[e]||e;return r+n}function Du(r){return"touches"in r}function Oy(r){return Du(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function mS(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function gS(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Ny(r){return Du(r)?gS(r)[0]:r}function Pd(r,e){try{const t=e.clientX-r.clientX,n=e.clientY-r.clientY,i=(e.clientX+r.clientX)/2,s=(e.clientY+r.clientY)/2,o=Math.hypot(t,n);return{angle:-(Math.atan2(t,n)*180)/Math.PI,distance:o,origin:[i,s]}}catch{}return null}function vS(r){return mS(r).map(e=>e.identifier)}function Ig(r,e){const[t,n]=Array.from(r.touches).filter(i=>e.includes(i.identifier));return Pd(t,n)}function kh(r){const e=Ny(r);return Du(r)?e.identifier:e.pointerId}function To(r){const e=Ny(r);return[e.clientX,e.clientY]}const Ug=40,Og=800;function Fy(r){let{deltaX:e,deltaY:t,deltaMode:n}=r;return n===1?(e*=Ug,t*=Ug):n===2&&(e*=Og,t*=Og),[e,t]}function _S(r){var e,t;const{scrollX:n,scrollY:i,scrollLeft:s,scrollTop:o}=r.currentTarget;return[(e=n??s)!==null&&e!==void 0?e:0,(t=i??o)!==null&&t!==void 0?t:0]}function yS(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:s})}return e}function gu(r,...e){return typeof r=="function"?r(...e):r}function xS(){}function bS(...r){return r.length===0?xS:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function Ng(r,e){return Object.assign({},e,r||{})}const wS=32;class ky{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?gu(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let s=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,yS(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,s=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const w=t._delta.map(Math.abs);Tt.addTo(t._distance,w)}this.axisIntent&&this.axisIntent(e);const[o,a]=t._movement,[c,l]=n.threshold,{_step:u,values:h}=t;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=c&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=l&&h[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=c&&Math.sign(o)*c),u[1]===!1&&(u[1]=Math.abs(a)>=l&&Math.sign(a)*l)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const f=[0,0];if(n.hasCustomTransform){const[w,S]=h;f[0]=u[0]!==!1?w-u[0]:0,f[1]=u[1]!==!1?S-u[1]:0}else f[0]=u[0]!==!1?o-u[0]:0,f[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(f);const d=t.offset,m=t._active&&!t._blocked||t.active;m&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=gu(n.bounds,t)),this.setup&&this.setup()),t.movement=f,this.computeOffset()));const[v,g]=t.offset,[[p,_],[y,x]]=t._bounds;t.overflow=[v<p?-1:v>_?1:0,g<y?-1:g>x?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const b=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=oS(t._bounds,t.offset,b),t.delta=Tt.sub(t.offset,d),this.computeMovement(),m&&(!t.last||s>wS)){t.delta=Tt.sub(t.offset,d);const w=t.delta.map(Math.abs);Tt.addTo(t.distance,w),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[w[0]/s,w[1]/s],t.timeDelta=s)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(Ut(Ut(Ut({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function SS([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class Ac extends ky{constructor(...e){super(...e),$t(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Tt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Tt.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[Oy(e)]:n.axisThreshold;t.axis=SS(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ES=r=>r,Fg=.15,zy={enabled(r=!0){return r},eventOptions(r,e,t){return Ut(Ut({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Fg,Fg];case!1:return[0,0];default:return Tt.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return Tt.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;return this.hasCustomTransform=!!n,n||ES},threshold(r){return Tt.toVector(r,0)}},MS=0,Es=Ut(Ut({},zy),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=MS){return r},bounds(r={}){if(typeof r=="function")return s=>Es.bounds(r(s));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),kg={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class TS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),i={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=Es.bounds(i)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=kh(e),n._pointerActive=!0,this.computeValues(To(e)),this.computeInitial(),t.preventScrollAxis&&Oy(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const i=kh(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const s=To(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=Tt.sub(s,t._values),this.computeValues(s)),Tt.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const i=kh(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[s,o]=t._distance;if(t.tap=s<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[l,u]=t._movement,[h,f]=n.swipe.velocity,[d,m]=n.swipe.distance,v=n.swipe.duration;if(t.elapsedTime<v){const g=Math.abs(a/t.timeDelta),p=Math.abs(c/t.timeDelta);g>h&&Math.abs(l)>d&&(t.swipe[0]=Math.sign(a)),p>f&&Math.abs(u)>m&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,AS(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=kg[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,Tt.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in kg&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function AS(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Cc=typeof window<"u"&&window.document&&window.document.createElement;function By(){return Cc&&"ontouchstart"in window}function CS(){return By()||Cc&&window.navigator.maxTouchPoints>1}function RS(){return Cc&&"onpointerdown"in window}function PS(){return Cc&&"exitPointerLock"in window.document}function LS(){try{return"constructor"in GestureEvent}catch{return!1}}const Qn={isBrowser:Cc,gesture:LS(),touch:By(),touchscreen:CS(),pointer:RS(),pointerLock:PS()},DS=250,IS=180,US=.5,OS=50,NS=250,FS=10,zg={mouse:0,touch:0,pen:8},kS=Ut(Ut({},Es),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&Qn.pointerLock,Qn.touch&&t?"touch":this.pointerLock?"mouse":Qn.pointer&&!i?"pointer":Qn.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?DS:void 0,!(!Qn.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const s=Tt.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,s},swipe({velocity:r=US,distance:e=OS,duration:t=NS}={}){return{velocity:this.transform(Tt.toVector(r)),distance:this.transform(Tt.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return IS;case!1:return 0;default:return r}},axisThreshold(r){return r?Ut(Ut({},zg),r):zg},keyboardDisplacement(r=FS){return r}});function Gy(r){const[e,t]=r.overflow,[n,i]=r._delta,[s,o]=r._direction;(e<0&&n>0&&s<0||e>0&&n<0&&s>0)&&(r._movement[0]=r._movementBound[0]),(t<0&&i>0&&o<0||t>0&&i<0&&o>0)&&(r._movement[1]=r._movementBound[1])}const zS=30,BS=100;class GS extends ky{constructor(...e){super(...e),$t(this,"ingKey","pinching"),$t(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:t,lastOffset:n}=this.state;e==="wheel"?this.state.offset=Tt.add(t,n):this.state.offset=[(1+t[0])*n[0],t[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,n]=e._movement;if(!e.axis){const i=Math.abs(t)*zS-Math.abs(n);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const t=this.state,n=this.ctrl.touchIds;if(t._active&&t._touchIds.every(s=>n.has(s))||n.size<2)return;this.start(e),t._touchIds=Array.from(n).slice(0,2);const i=Ig(e,t._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const t=this.state,n=t._pointerEvents,i=this.ctrl.pointerIds;if(t._active&&Array.from(n.keys()).every(o=>i.has(o))||(n.size<2&&n.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const s=Pd(...Array.from(n.values()));s&&this.pinchStart(e,s)}pinchStart(e,t){const n=this.state;n.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=Ig(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const n=Pd(...Array.from(t.values()));n&&this.pinchMove(e,n)}pinchMove(e,t){const n=this.state,i=n._values[1],s=t.angle-i;let o=0;Math.abs(s)>270&&(o+=Math.sign(s)),this.computeValues([t.distance,t.angle-360*o]),n.origin=t.origin,n.turns=o,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const n=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=Tt.sub(t._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(n=>e[n]):!e[t])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-Fy(e)[1]/BS*n.offset[0],0],Tt.addTo(n._movement,n._delta),Gy(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const VS=Ut(Ut({},zy),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!Qn.touch&&Qn.gesture)return"gesture";if(Qn.touch&&n)return"touch";if(Qn.touchscreen){if(Qn.pointer)return"pointer";if(Qn.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const a=Ng(gu(t,o),{min:-1/0,max:1/0});return[a.min,a.max]},s=o=>{const a=Ng(gu(n,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[i(),s()]:o=>[i(o),s(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",Tt.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}});class HS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(To(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const t=To(e),n=this.state;n._delta=Tt.sub(t,n._values),Tt.addTo(n._movement,n._delta),this.computeValues(t),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const WS=Ut(Ut({},Es),{},{mouseOnly:(r=!0)=>r});class XS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const t=this.state,n=_S(e);t._delta=Tt.sub(n,t._values),Tt.addTo(t._movement,t._delta),this.computeValues(n),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const qS=Es;class YS extends Ac{constructor(...e){super(...e),$t(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const t=this.state;t._delta=Fy(e),Tt.addTo(t._movement,t._delta),Gy(t),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const jS=Es;class $S extends Ac{constructor(...e){super(...e),$t(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(To(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const t=this.state;if(!t._active)return;t._active=!1;const n=To(e);t._movement=t._delta=Tt.sub(n,t._values),this.computeValues(n),this.compute(e),t.delta=t.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const ZS=Ut(Ut({},Es),{},{mouseOnly:(r=!0)=>r}),Gp=new Map,Ld=new Map;function KS(r){Gp.set(r.key,r.engine),Ld.set(r.key,r.resolver)}const JS={key:"drag",engine:TS,resolver:kS},QS={key:"hover",engine:$S,resolver:ZS},eE={key:"move",engine:HS,resolver:WS},tE={key:"pinch",engine:GS,resolver:VS},nE={key:"scroll",engine:XS,resolver:qS},iE={key:"wheel",engine:YS,resolver:jS};function rE(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function sE(r,e){if(r==null)return{};var t=rE(r,e),n,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);for(i=0;i<s.length;i++)n=s[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const oE={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=Qn.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},aE=["target","eventOptions","window","enabled","transform"];function nu(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=nu(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function cE(r,e,t={}){const n=r,{target:i,eventOptions:s,window:o,enabled:a,transform:c}=n,l=sE(n,aE);if(t.shared=nu({target:i,eventOptions:s,window:o,enabled:a,transform:c},oE),e){const u=Ld.get(e);t[e]=nu(Ut({shared:t.shared},l),u)}else for(const u in l){const h=Ld.get(u);h&&(t[u]=nu(Ut({shared:t.shared},l[u]),h))}return t}class Vy{constructor(e,t){$t(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,s){const o=this._listeners,a=pS(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=Ut(Ut({},c),s);e.addEventListener(a,i,l);const u=()=>{e.removeEventListener(a,i,l),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class lE{constructor(){$t(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}let uE=class{constructor(e){$t(this,"gestures",new Set),$t(this,"_targetEventStore",new Vy(this)),$t(this,"gestureEventStores",{}),$t(this,"gestureTimeoutStores",{}),$t(this,"handlers",{}),$t(this,"config",{}),$t(this,"pointerIds",new Set),$t(this,"touchIds",new Set),$t(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),hE(this,e)}setEventIds(e){if(Du(e))return this.touchIds=new Set(vS(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=cE(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const a=this.config[o],c=Bg(n,a.eventOptions,!!i);if(a.enabled){const l=Gp.get(o);new l(this,e,o).bind(c)}}const s=Bg(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)s(o,"",a=>this.nativeHandlers[o](Ut(Ut({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const s in n)n[s]=bS(...n[s]);if(!i)return n;for(const s in n){const{device:o,capture:a,passive:c}=dS(s);this._targetEventStore.add(i,o,"",n[s],{capture:a,passive:c})}}}};function Ds(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Vy(r,e),r.gestureTimeoutStores[e]=new lE}function hE(r,e){e.drag&&Ds(r,"drag"),e.wheel&&Ds(r,"wheel"),e.scroll&&Ds(r,"scroll"),e.move&&Ds(r,"move"),e.pinch&&Ds(r,"pinch"),e.hover&&Ds(r,"hover")}const Bg=(r,e,t)=>(n,i,s,o={},a=!1)=>{var c,l;const u=(c=o.capture)!==null&&c!==void 0?c:e.capture,h=(l=o.passive)!==null&&l!==void 0?l:e.passive;let f=a?n:hS(n,i,u);t&&h&&(f+="Passive"),r[f]=r[f]||[],r[f].push(s)},fE=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function dE(r){const e={},t={},n=new Set;for(let i in r)fE.test(i)?(n.add(RegExp.lastMatch),t[i]=r[i]):e[i]=r[i];return[t,e,n]}function Is(r,e,t,n,i,s){if(!r.has(t)||!Gp.has(n))return;const o=t+"Start",a=t+"End",c=l=>{let u;return l.first&&o in e&&e[o](l),t in e&&(u=e[t](l)),l.last&&a in e&&e[a](l),u};i[n]=c,s[n]=s[n]||{}}function pE(r,e){const[t,n,i]=dE(r),s={};return Is(i,t,"onDrag","drag",s,e),Is(i,t,"onWheel","wheel",s,e),Is(i,t,"onScroll","scroll",s,e),Is(i,t,"onPinch","pinch",s,e),Is(i,t,"onMove","move",s,e),Is(i,t,"onHover","hover",s,e),{handlers:s,config:e,nativeHandlers:n}}function mE(r,e={},t,n){const i=Fh.useMemo(()=>new uE(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),Fh.useEffect(i.effect.bind(i)),Fh.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function gE(r){return r.forEach(KS),function(t,n){const{handlers:i,nativeHandlers:s,config:o}=pE(t,n||{});return mE(i,o,void 0,s)}}function vE(r,e){return gE([JS,tE,nE,iE,eE,QS])(r,e||{})}const Kc=(r,e)=>{const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,c=new Ww;let l=0;if(r.forEach((u,h)=>{let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;s[d]===void 0&&(s[d]=[]),s[d].push(u.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(u.userData),e){let d;if(u.index)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,d,h),l+=d}}),t){let u=0;const h=[];r.forEach(f=>{const d=f.index;for(let m=0;m<d.count;++m)h.push(d.getX(m)+u);u+=f.attributes.position.count}),c.setIndex(h)}for(let u in s){const h=Gg(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,h)}for(let u in o){const h=o[u][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<h;++f){const d=[];for(let v=0;v<o[u].length;++v)d.push(o[u][v][f]);const m=Gg(d);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(m)}}return c},Gg=r=>{let e,t,n,i=0;if(r.forEach(s=>{if(e===void 0&&(e=s.array.constructor),e!==s.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=s.itemSize),t!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=s.normalized),n!==s.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=s.array.length}),e&&t){const s=new e(i);let o=0;return r.forEach(a=>{s.set(a.array,o),o+=a.array.length}),new Xw(s,t,n)}},zh=new qw,Bh=new _n,Us=new _n,ci=new _n,Gi=new _n,Ti=new _n,Vi=new _n,Hi=new _n,Jo=new _n,Qo=new _n,ea=new _n,Jc=new _n,ta=new _n,na=new _n,ia=new _n;class Vg{constructor(e,t,n){this.camera=e,this.scene=t,this.startPoint=new _n,this.endPoint=new _n,this.collection=[],this.deep=n||Number.MAX_VALUE}select(e,t){return this.startPoint=e||this.startPoint,this.endPoint=t||this.endPoint,this.collection=[],this.updateFrustum(this.startPoint,this.endPoint),this.searchChildInFrustum(zh,this.scene),this.collection}updateFrustum(e,t){if(e=e||this.startPoint,t=t||this.endPoint,e.x===t.x&&(t.x+=Number.EPSILON),e.y===t.y&&(t.y+=Number.EPSILON),this.camera.updateProjectionMatrix(),this.camera.updateMatrixWorld(),this.camera.isPerspectiveCamera){Us.copy(e),Us.x=Math.min(e.x,t.x),Us.y=Math.max(e.y,t.y),t.x=Math.max(e.x,t.x),t.y=Math.min(e.y,t.y),ci.setFromMatrixPosition(this.camera.matrixWorld),Gi.copy(Us),Ti.set(t.x,Us.y,0),Vi.copy(t),Hi.set(Us.x,t.y,0),Gi.unproject(this.camera),Ti.unproject(this.camera),Vi.unproject(this.camera),Hi.unproject(this.camera),ta.copy(Gi).sub(ci),na.copy(Ti).sub(ci),ia.copy(Vi).sub(ci),ta.normalize(),na.normalize(),ia.normalize(),ta.multiplyScalar(this.deep),na.multiplyScalar(this.deep),ia.multiplyScalar(this.deep),ta.add(ci),na.add(ci),ia.add(ci);var n=zh.planes;n[0].setFromCoplanarPoints(ci,Gi,Ti),n[1].setFromCoplanarPoints(ci,Ti,Vi),n[2].setFromCoplanarPoints(Vi,Hi,ci),n[3].setFromCoplanarPoints(Hi,Gi,ci),n[4].setFromCoplanarPoints(Ti,Vi,Hi),n[5].setFromCoplanarPoints(ia,na,ta),n[5].normal.multiplyScalar(-1)}else if(this.camera.isOrthographicCamera){const i=Math.min(e.x,t.x),s=Math.max(e.y,t.y),o=Math.max(e.x,t.x),a=Math.min(e.y,t.y);Gi.set(i,s,-1),Ti.set(o,s,-1),Vi.set(o,a,-1),Hi.set(i,a,-1),Jo.set(i,s,1),Qo.set(o,s,1),ea.set(o,a,1),Jc.set(i,a,1),Gi.unproject(this.camera),Ti.unproject(this.camera),Vi.unproject(this.camera),Hi.unproject(this.camera),Jo.unproject(this.camera),Qo.unproject(this.camera),ea.unproject(this.camera),Jc.unproject(this.camera);var n=zh.planes;n[0].setFromCoplanarPoints(Gi,Jo,Qo),n[1].setFromCoplanarPoints(Ti,Qo,ea),n[2].setFromCoplanarPoints(ea,Jc,Hi),n[3].setFromCoplanarPoints(Jc,Jo,Gi),n[4].setFromCoplanarPoints(Ti,Vi,Hi),n[5].setFromCoplanarPoints(ea,Qo,Jo),n[5].normal.multiplyScalar(-1)}else console.error("THREE.SelectionBox: Unsupported camera type.")}searchChildInFrustum(e,t){if((t.isMesh||t.isLine||t.isPoints)&&t.material!==void 0&&(t.geometry.boundingSphere===null&&t.geometry.computeBoundingSphere(),Bh.copy(t.geometry.boundingSphere.center),Bh.applyMatrix4(t.matrixWorld),e.containsPoint(Bh)&&this.collection.push(t)),t.children.length>0)for(let n=0;n<t.children.length;n++)this.searchChildInFrustum(e,t.children[n])}}function Hy(){var r=(function(e){function t(k,U,R,F,H,Y,J,ie){var ne=1-J;ie.x=ne*ne*k+2*ne*J*R+J*J*H,ie.y=ne*ne*U+2*ne*J*F+J*J*Y}function n(k,U,R,F,H,Y,J,ie,ne,ee){var ge=1-ne;ee.x=ge*ge*ge*k+3*ge*ge*ne*R+3*ge*ne*ne*H+ne*ne*ne*J,ee.y=ge*ge*ge*U+3*ge*ge*ne*F+3*ge*ne*ne*Y+ne*ne*ne*ie}function i(k,U){for(var R=/([MLQCZ])([^MLQCZ]*)/g,F,H,Y,J,ie;F=R.exec(k);){var ne=F[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map(function(ee){return parseFloat(ee)});switch(F[1]){case"M":J=H=ne[0],ie=Y=ne[1];break;case"L":(ne[0]!==J||ne[1]!==ie)&&U("L",J,ie,J=ne[0],ie=ne[1]);break;case"Q":{U("Q",J,ie,J=ne[2],ie=ne[3],ne[0],ne[1]);break}case"C":{U("C",J,ie,J=ne[4],ie=ne[5],ne[0],ne[1],ne[2],ne[3]);break}case"Z":(J!==H||ie!==Y)&&U("L",J,ie,H,Y);break}}}function s(k,U,R){R===void 0&&(R=16);var F={x:0,y:0};i(k,function(H,Y,J,ie,ne,ee,ge,me,te){switch(H){case"L":U(Y,J,ie,ne);break;case"Q":{for(var D=Y,Q=J,j=1;j<R;j++)t(Y,J,ee,ge,ie,ne,j/(R-1),F),U(D,Q,F.x,F.y),D=F.x,Q=F.y;break}case"C":{for(var K=Y,W=J,ye=1;ye<R;ye++)n(Y,J,ee,ge,me,te,ie,ne,ye/(R-1),F),U(K,W,F.x,F.y),K=F.x,W=F.y;break}}})}var o="precision highp float;attribute vec2 aUV;varying vec2 vUV;void main(){vUV=aUV;gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}",a="precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){gl_FragColor=texture2D(tex,vUV);}",c=new WeakMap,l={premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!1};function u(k,U){var R=k.getContext?k.getContext("webgl",l):k,F=c.get(R);if(!F){let ge=function(K){var W=Y[K];if(!W&&(W=Y[K]=R.getExtension(K),!W))throw new Error(K+" not supported");return W},me=function(K,W){var ye=R.createShader(W);return R.shaderSource(ye,K),R.compileShader(ye),ye},te=function(K,W,ye,re){if(!J[K]){var fe={},xe={},ce=R.createProgram();R.attachShader(ce,me(W,R.VERTEX_SHADER)),R.attachShader(ce,me(ye,R.FRAGMENT_SHADER)),R.linkProgram(ce),J[K]={program:ce,transaction:function(B){R.useProgram(ce),B({setUniform:function($,he){for(var de=[],pe=arguments.length-2;pe-- >0;)de[pe]=arguments[pe+2];var Me=xe[he]||(xe[he]=R.getUniformLocation(ce,he));R["uniform"+$].apply(R,[Me].concat(de))},setAttribute:function($,he,de,pe,Me){var we=fe[$];we||(we=fe[$]={buf:R.createBuffer(),loc:R.getAttribLocation(ce,$),data:null}),R.bindBuffer(R.ARRAY_BUFFER,we.buf),R.vertexAttribPointer(we.loc,he,R.FLOAT,!1,0,0),R.enableVertexAttribArray(we.loc),H?R.vertexAttribDivisor(we.loc,pe):ge("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(we.loc,pe),Me!==we.data&&(R.bufferData(R.ARRAY_BUFFER,Me,de),we.data=Me)}})}}}J[K].transaction(re)},D=function(K,W){ne++;try{R.activeTexture(R.TEXTURE0+ne);var ye=ie[K];ye||(ye=ie[K]=R.createTexture(),R.bindTexture(R.TEXTURE_2D,ye),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,R.NEAREST),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,R.NEAREST)),R.bindTexture(R.TEXTURE_2D,ye),W(ye,ne)}finally{ne--}},Q=function(K,W,ye){var re=R.createFramebuffer();ee.push(re),R.bindFramebuffer(R.FRAMEBUFFER,re),R.activeTexture(R.TEXTURE0+W),R.bindTexture(R.TEXTURE_2D,K),R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_2D,K,0);try{ye(re)}finally{R.deleteFramebuffer(re),R.bindFramebuffer(R.FRAMEBUFFER,ee[--ee.length-1]||null)}},j=function(){Y={},J={},ie={},ne=-1,ee.length=0};var H=typeof WebGL2RenderingContext<"u"&&R instanceof WebGL2RenderingContext,Y={},J={},ie={},ne=-1,ee=[];R.canvas.addEventListener("webglcontextlost",function(K){j(),K.preventDefault()},!1),c.set(R,F={gl:R,isWebGL2:H,getExtension:ge,withProgram:te,withTexture:D,withTextureFramebuffer:Q,handleContextLoss:j})}U(F)}function h(k,U,R,F,H,Y,J,ie){J===void 0&&(J=15),ie===void 0&&(ie=null),u(k,function(ne){var ee=ne.gl,ge=ne.withProgram,me=ne.withTexture;me("copy",function(te,D){ee.texImage2D(ee.TEXTURE_2D,0,ee.RGBA,H,Y,0,ee.RGBA,ee.UNSIGNED_BYTE,U),ge("copy",o,a,function(Q){var j=Q.setUniform,K=Q.setAttribute;K("aUV",2,ee.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),j("1i","image",D),ee.bindFramebuffer(ee.FRAMEBUFFER,ie||null),ee.disable(ee.BLEND),ee.colorMask(J&8,J&4,J&2,J&1),ee.viewport(R,F,H,Y),ee.scissor(R,F,H,Y),ee.drawArrays(ee.TRIANGLES,0,3)})})})}function f(k,U,R){var F=k.width,H=k.height;u(k,function(Y){var J=Y.gl,ie=new Uint8Array(F*H*4);J.readPixels(0,0,F,H,J.RGBA,J.UNSIGNED_BYTE,ie),k.width=U,k.height=R,h(J,ie,0,0,F,H)})}var d=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:h,resizeWebGLCanvasWithoutClearing:f});function m(k,U,R,F,H,Y){Y===void 0&&(Y=1);var J=new Uint8Array(k*U),ie=F[2]-F[0],ne=F[3]-F[1],ee=[];s(R,function(K,W,ye,re){ee.push({x1:K,y1:W,x2:ye,y2:re,minX:Math.min(K,ye),minY:Math.min(W,re),maxX:Math.max(K,ye),maxY:Math.max(W,re)})}),ee.sort(function(K,W){return K.maxX-W.maxX});for(var ge=0;ge<k;ge++)for(var me=0;me<U;me++){var te=Q(F[0]+ie*(ge+.5)/k,F[1]+ne*(me+.5)/U),D=Math.pow(1-Math.abs(te)/H,Y)/2;te<0&&(D=1-D),D=Math.max(0,Math.min(255,Math.round(D*255))),J[me*k+ge]=D}return J;function Q(K,W){for(var ye=1/0,re=1/0,fe=ee.length;fe--;){var xe=ee[fe];if(xe.maxX+re<=K)break;if(K+re>xe.minX&&W-re<xe.maxY&&W+re>xe.minY){var ce=p(K,W,xe.x1,xe.y1,xe.x2,xe.y2);ce<ye&&(ye=ce,re=Math.sqrt(ye))}}return j(K,W)&&(re=-re),re}function j(K,W){for(var ye=0,re=ee.length;re--;){var fe=ee[re];if(fe.maxX<=K)break;var xe=fe.y1>W!=fe.y2>W&&K<(fe.x2-fe.x1)*(W-fe.y1)/(fe.y2-fe.y1)+fe.x1;xe&&(ye+=fe.y1<fe.y2?1:-1)}return ye!==0}}function v(k,U,R,F,H,Y,J,ie,ne,ee){Y===void 0&&(Y=1),ie===void 0&&(ie=0),ne===void 0&&(ne=0),ee===void 0&&(ee=0),g(k,U,R,F,H,Y,J,null,ie,ne,ee)}function g(k,U,R,F,H,Y,J,ie,ne,ee,ge){Y===void 0&&(Y=1),ne===void 0&&(ne=0),ee===void 0&&(ee=0),ge===void 0&&(ge=0);for(var me=m(k,U,R,F,H,Y),te=new Uint8Array(me.length*4),D=0;D<me.length;D++)te[D*4+ge]=me[D];h(J,te,ne,ee,k,U,1<<3-ge,ie)}function p(k,U,R,F,H,Y){var J=H-R,ie=Y-F,ne=J*J+ie*ie,ee=ne?Math.max(0,Math.min(1,((k-R)*J+(U-F)*ie)/ne)):0,ge=k-(R+ee*J),me=U-(F+ee*ie);return ge*ge+me*me}var _=Object.freeze({__proto__:null,generate:m,generateIntoCanvas:v,generateIntoFramebuffer:g}),y="precision highp float;uniform vec4 uGlyphBounds;attribute vec2 aUV;attribute vec4 aLineSegment;varying vec4 vLineSegment;varying vec2 vGlyphXY;void main(){vLineSegment=aLineSegment;vGlyphXY=mix(uGlyphBounds.xy,uGlyphBounds.zw,aUV);gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}",x="precision highp float;uniform vec4 uGlyphBounds;uniform float uMaxDistance;uniform float uExponent;varying vec4 vLineSegment;varying vec2 vGlyphXY;float absDistToSegment(vec2 point,vec2 lineA,vec2 lineB){vec2 lineDir=lineB-lineA;float lenSq=dot(lineDir,lineDir);float t=lenSq==0.0 ? 0.0 : clamp(dot(point-lineA,lineDir)/lenSq,0.0,1.0);vec2 linePt=lineA+t*lineDir;return distance(point,linePt);}void main(){vec4 seg=vLineSegment;vec2 p=vGlyphXY;float dist=absDistToSegment(p,seg.xy,seg.zw);float val=pow(1.0-clamp(dist/uMaxDistance,0.0,1.0),uExponent)*0.5;bool crossing=(seg.y>p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y<vLineSegment.w;gl_FragColor=vec4(crossingUp ? 1.0/255.0 : 0.0,crossing&&!crossingUp ? 1.0/255.0 : 0.0,0.0,val);}",b="precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){vec4 color=texture2D(tex,vUV);bool inside=color.r!=color.g;float val=inside ? 1.0-color.a : color.a;gl_FragColor=vec4(val);}",w=new Float32Array([0,0,2,0,0,2]),S=null,M=!1,E={},T=new WeakMap;function L(k){if(!M&&!V(k))throw new Error("WebGL generation not supported")}function P(k,U,R,F,H,Y,J){if(Y===void 0&&(Y=1),J===void 0&&(J=null),!J&&(J=S,!J)){var ie=typeof OffscreenCanvas=="function"?new OffscreenCanvas(1,1):typeof document<"u"?document.createElement("canvas"):null;if(!ie)throw new Error("OffscreenCanvas or DOM canvas not supported");J=S=ie.getContext("webgl",{depth:!1})}L(J);var ne=new Uint8Array(k*U*4);u(J,function(te){var D=te.gl,Q=te.withTexture,j=te.withTextureFramebuffer;Q("readable",function(K,W){D.texImage2D(D.TEXTURE_2D,0,D.RGBA,k,U,0,D.RGBA,D.UNSIGNED_BYTE,null),j(K,W,function(ye){z(k,U,R,F,H,Y,D,ye,0,0,0),D.readPixels(0,0,k,U,D.RGBA,D.UNSIGNED_BYTE,ne)})})});for(var ee=new Uint8Array(k*U),ge=0,me=0;ge<ne.length;ge+=4)ee[me++]=ne[ge];return ee}function A(k,U,R,F,H,Y,J,ie,ne,ee){Y===void 0&&(Y=1),ie===void 0&&(ie=0),ne===void 0&&(ne=0),ee===void 0&&(ee=0),z(k,U,R,F,H,Y,J,null,ie,ne,ee)}function z(k,U,R,F,H,Y,J,ie,ne,ee,ge){Y===void 0&&(Y=1),ne===void 0&&(ne=0),ee===void 0&&(ee=0),ge===void 0&&(ge=0),L(J);var me=[];s(R,function(te,D,Q,j){me.push(te,D,Q,j)}),me=new Float32Array(me),u(J,function(te){var D=te.gl,Q=te.isWebGL2,j=te.getExtension,K=te.withProgram,W=te.withTexture,ye=te.withTextureFramebuffer,re=te.handleContextLoss;if(W("rawDistances",function(fe,xe){(k!==fe._lastWidth||U!==fe._lastHeight)&&D.texImage2D(D.TEXTURE_2D,0,D.RGBA,fe._lastWidth=k,fe._lastHeight=U,0,D.RGBA,D.UNSIGNED_BYTE,null),K("main",y,x,function(ce){var Pe=ce.setAttribute,B=ce.setUniform,I=!Q&&j("ANGLE_instanced_arrays"),$=!Q&&j("EXT_blend_minmax");Pe("aUV",2,D.STATIC_DRAW,0,w),Pe("aLineSegment",4,D.DYNAMIC_DRAW,1,me),B.apply(void 0,["4f","uGlyphBounds"].concat(F)),B("1f","uMaxDistance",H),B("1f","uExponent",Y),ye(fe,xe,function(he){D.enable(D.BLEND),D.colorMask(!0,!0,!0,!0),D.viewport(0,0,k,U),D.scissor(0,0,k,U),D.blendFunc(D.ONE,D.ONE),D.blendEquationSeparate(D.FUNC_ADD,Q?D.MAX:$.MAX_EXT),D.clear(D.COLOR_BUFFER_BIT),Q?D.drawArraysInstanced(D.TRIANGLES,0,3,me.length/4):I.drawArraysInstancedANGLE(D.TRIANGLES,0,3,me.length/4)})}),K("post",o,b,function(ce){ce.setAttribute("aUV",2,D.STATIC_DRAW,0,w),ce.setUniform("1i","tex",xe),D.bindFramebuffer(D.FRAMEBUFFER,ie),D.disable(D.BLEND),D.colorMask(ge===0,ge===1,ge===2,ge===3),D.viewport(ne,ee,k,U),D.scissor(ne,ee,k,U),D.drawArrays(D.TRIANGLES,0,3)})}),D.isContextLost())throw re(),new Error("webgl context lost")})}function V(k){var U=!k||k===S?E:k.canvas||k,R=T.get(U);if(R===void 0){M=!0;var F=null;try{var H=[97,106,97,61,99,137,118,80,80,118,137,99,61,97,106,97],Y=P(4,4,"M8,8L16,8L24,24L16,24Z",[0,0,32,32],24,1,k);R=Y&&H.length===Y.length&&Y.every(function(J,ie){return J===H[ie]}),R||(F="bad trial run results",console.info(H,Y))}catch(J){R=!1,F=J.message}F&&console.warn("WebGL SDF generation not supported:",F),M=!1,T.set(U,R)}return R}var N=Object.freeze({__proto__:null,generate:P,generateIntoCanvas:A,generateIntoFramebuffer:z,isSupported:V});function C(k,U,R,F,H,Y){H===void 0&&(H=Math.max(F[2]-F[0],F[3]-F[1])/2),Y===void 0&&(Y=1);try{return P.apply(N,arguments)}catch(J){return console.info("WebGL SDF generation failed, falling back to JS",J),m.apply(_,arguments)}}function O(k,U,R,F,H,Y,J,ie,ne,ee){H===void 0&&(H=Math.max(F[2]-F[0],F[3]-F[1])/2),Y===void 0&&(Y=1),ie===void 0&&(ie=0),ne===void 0&&(ne=0),ee===void 0&&(ee=0);try{return A.apply(N,arguments)}catch(ge){return console.info("WebGL SDF generation failed, falling back to JS",ge),v.apply(_,arguments)}}return e.forEachPathCommand=i,e.generate=C,e.generateIntoCanvas=O,e.javascript=_,e.pathToLineSegments=s,e.webgl=N,e.webglUtils=d,Object.defineProperty(e,"__esModule",{value:!0}),e})({});return r}function _E(){var r=(function(e){var t={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},n={},i={};n.L=1,i[1]="L",Object.keys(t).forEach(function(re,fe){n[re]=1<<fe+1,i[n[re]]=re}),Object.freeze(n);var s=n.LRI|n.RLI|n.FSI,o=n.L|n.R|n.AL,a=n.B|n.S|n.WS|n.ON|n.FSI|n.LRI|n.RLI|n.PDI,c=n.BN|n.RLE|n.LRE|n.RLO|n.LRO|n.PDF,l=n.S|n.WS|n.B|s|n.PDI|c,u=null;function h(){if(!u){u=new Map;var re=function(xe){if(t.hasOwnProperty(xe)){var ce=0;t[xe].split(",").forEach(function(Pe){var B=Pe.split("+"),I=B[0],$=B[1];I=parseInt(I,36),$=$?parseInt($,36):0,u.set(ce+=I,n[xe]);for(var he=0;he<$;he++)u.set(++ce,n[xe])})}};for(var fe in t)re(fe)}}function f(re){return h(),u.get(re.codePointAt(0))||n.L}function d(re){return i[f(re)]}var m={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function v(re,fe){var xe=36,ce=0,Pe=new Map,B=fe&&new Map,I;return re.split(",").forEach(function $(he){if(he.indexOf("+")!==-1)for(var de=+he;de--;)$(I);else{I=he;var pe=he.split(">"),Me=pe[0],we=pe[1];Me=String.fromCodePoint(ce+=parseInt(Me,xe)),we=String.fromCodePoint(ce+=parseInt(we,xe)),Pe.set(Me,we),fe&&B.set(we,Me)}}),{map:Pe,reverseMap:B}}var g,p,_;function y(){if(!g){var re=v(m.pairs,!0),fe=re.map,xe=re.reverseMap;g=fe,p=xe,_=v(m.canonical,!1).map}}function x(re){return y(),g.get(re)||null}function b(re){return y(),p.get(re)||null}function w(re){return y(),_.get(re)||null}var S=n.L,M=n.R,E=n.EN,T=n.ES,L=n.ET,P=n.AN,A=n.CS,z=n.B,V=n.S,N=n.ON,C=n.BN,O=n.NSM,k=n.AL,U=n.LRO,R=n.RLO,F=n.LRE,H=n.RLE,Y=n.PDF,J=n.LRI,ie=n.RLI,ne=n.FSI,ee=n.PDI;function ge(re,fe){for(var xe=125,ce=new Uint32Array(re.length),Pe=0;Pe<re.length;Pe++)ce[Pe]=f(re[Pe]);var B=new Map;function I(Tn,ai){var An=ce[Tn];ce[Tn]=ai,B.set(An,B.get(An)-1),An&a&&B.set(a,B.get(a)-1),B.set(ai,(B.get(ai)||0)+1),ai&a&&B.set(a,(B.get(a)||0)+1)}for(var $=new Uint8Array(re.length),he=new Map,de=[],pe=null,Me=0;Me<re.length;Me++)pe||de.push(pe={start:Me,end:re.length-1,level:fe==="rtl"?1:fe==="ltr"?0:Tg(Me,!1)}),ce[Me]&z&&(pe.end=Me,pe=null);for(var we=H|F|R|U|s|ee|Y|z,ue=function(Tn){return Tn+(Tn&1?1:2)},Ce=function(Tn){return Tn+(Tn&1?2:1)},ze=0;ze<de.length;ze++){pe=de[ze];var Le=[{_level:pe.level,_override:0,_isolate:0}],Ee=void 0,De=0,Ve=0,je=0;B.clear();for(var Z=pe.start;Z<=pe.end;Z++){var Ae=ce[Z];if(Ee=Le[Le.length-1],B.set(Ae,(B.get(Ae)||0)+1),Ae&a&&B.set(a,(B.get(a)||0)+1),Ae&we)if(Ae&(H|F)){$[Z]=Ee._level;var le=(Ae===H?Ce:ue)(Ee._level);le<=xe&&!De&&!Ve?Le.push({_level:le,_override:0,_isolate:0}):De||Ve++}else if(Ae&(R|U)){$[Z]=Ee._level;var Re=(Ae===R?Ce:ue)(Ee._level);Re<=xe&&!De&&!Ve?Le.push({_level:Re,_override:Ae&R?M:S,_isolate:0}):De||Ve++}else if(Ae&s){Ae&ne&&(Ae=Tg(Z+1,!0)===1?ie:J),$[Z]=Ee._level,Ee._override&&I(Z,Ee._override);var Fe=(Ae===ie?Ce:ue)(Ee._level);Fe<=xe&&De===0&&Ve===0?(je++,Le.push({_level:Fe,_override:0,_isolate:1,_isolInitIndex:Z})):De++}else if(Ae&ee){if(De>0)De--;else if(je>0){for(Ve=0;!Le[Le.length-1]._isolate;)Le.pop();var tt=Le[Le.length-1]._isolInitIndex;tt!=null&&(he.set(tt,Z),he.set(Z,tt)),Le.pop(),je--}Ee=Le[Le.length-1],$[Z]=Ee._level,Ee._override&&I(Z,Ee._override)}else Ae&Y?(De===0&&(Ve>0?Ve--:!Ee._isolate&&Le.length>1&&(Le.pop(),Ee=Le[Le.length-1])),$[Z]=Ee._level):Ae&z&&($[Z]=pe.level);else $[Z]=Ee._level,Ee._override&&Ae!==C&&I(Z,Ee._override)}for(var lt=[],ft=null,ut=pe.start;ut<=pe.end;ut++){var xt=ce[ut];if(!(xt&c)){var dt=$[ut],ct=xt&s,Mn=xt===ee;ft&&dt===ft._level?(ft._end=ut,ft._endsWithIsolInit=ct):lt.push(ft={_start:ut,_end:ut,_level:dt,_startsWithPDI:Mn,_endsWithIsolInit:ct})}}for(var fn=[],yt=0;yt<lt.length;yt++){var kt=lt[yt];if(!kt._startsWithPDI||kt._startsWithPDI&&!he.has(kt._start)){for(var yn=[ft=kt],Vt=void 0;ft&&ft._endsWithIsolInit&&(Vt=he.get(ft._end))!=null;)for(var Ht=yt+1;Ht<lt.length;Ht++)if(lt[Ht]._start===Vt){yn.push(ft=lt[Ht]);break}for(var sn=[],Ei=0;Ei<yn.length;Ei++)for(var Un=yn[Ei],X=Un._start;X<=Un._end;X++)sn.push(X);for(var ae=$[sn[0]],ve=pe.level,se=sn[0]-1;se>=0;se--)if(!(ce[se]&c)){ve=$[se];break}var _e=sn[sn.length-1],Ge=$[_e],We=pe.level;if(!(ce[_e]&s)){for(var qe=_e+1;qe<=pe.end;qe++)if(!(ce[qe]&c)){We=$[qe];break}}fn.push({_seqIndices:sn,_sosType:Math.max(ve,ae)%2?M:S,_eosType:Math.max(We,Ge)%2?M:S})}}for(var Ye=0;Ye<fn.length;Ye++){var nt=fn[Ye],Te=nt._seqIndices,Ze=nt._sosType,At=nt._eosType,bt=$[Te[0]]&1?M:S;if(B.get(O))for(var dn=0;dn<Te.length;dn++){var Xn=Te[dn];if(ce[Xn]&O){for(var Ct=Ze,at=dn-1;at>=0;at--)if(!(ce[Te[at]]&c)){Ct=ce[Te[at]];break}I(Xn,Ct&(s|ee)?N:Ct)}}if(B.get(E))for(var fr=0;fr<Te.length;fr++){var Wt=Te[fr];if(ce[Wt]&E)for(var qn=fr-1;qn>=-1;qn--){var Vo=qn===-1?Ze:ce[Te[qn]];if(Vo&o){Vo===k&&I(Wt,P);break}}}if(B.get(k))for(var Bi=0;Bi<Te.length;Bi++){var Rs=Te[Bi];ce[Rs]&k&&I(Rs,M)}if(B.get(T)||B.get(A))for(var Xt=1;Xt<Te.length-1;Xt++){var si=Te[Xt];if(ce[si]&(T|A)){for(var Mi=0,on=0,zr=Xt-1;zr>=0&&(Mi=ce[Te[zr]],!!(Mi&c));zr--);for(var Ho=Xt+1;Ho<Te.length&&(on=ce[Te[Ho]],!!(on&c));Ho++);Mi===on&&(ce[si]===T?Mi===E:Mi&(E|P))&&I(si,Mi)}}if(B.get(E))for(var On=0;On<Te.length;On++){var Gw=Te[On];if(ce[Gw]&E){for(var Hc=On-1;Hc>=0&&ce[Te[Hc]]&(L|c);Hc--)I(Te[Hc],E);for(On++;On<Te.length&&ce[Te[On]]&(L|c|E);On++)ce[Te[On]]!==E&&I(Te[On],E)}}if(B.get(L)||B.get(T)||B.get(A))for(var Wo=0;Wo<Te.length;Wo++){var dg=Te[Wo];if(ce[dg]&(L|T|A)){I(dg,N);for(var Wc=Wo-1;Wc>=0&&ce[Te[Wc]]&c;Wc--)I(Te[Wc],N);for(var Xc=Wo+1;Xc<Te.length&&ce[Te[Xc]]&c;Xc++)I(Te[Xc],N)}}if(B.get(E))for(var Ah=0,pg=Ze;Ah<Te.length;Ah++){var mg=Te[Ah],Ch=ce[mg];Ch&E?pg===S&&I(mg,S):Ch&o&&(pg=Ch)}if(B.get(a)){var Xo=M|E|P,gg=Xo|S,qc=[];{for(var Ps=[],Ls=0;Ls<Te.length;Ls++)if(ce[Te[Ls]]&a){var qo=re[Te[Ls]],vg=void 0;if(x(qo)!==null)if(Ps.length<63)Ps.push({char:qo,seqIndex:Ls});else break;else if((vg=b(qo))!==null)for(var Yo=Ps.length-1;Yo>=0;Yo--){var Rh=Ps[Yo].char;if(Rh===vg||Rh===b(w(qo))||x(w(Rh))===qo){qc.push([Ps[Yo].seqIndex,Ls]),Ps.length=Yo;break}}}qc.sort(function(Tn,ai){return Tn[0]-ai[0]})}for(var Ph=0;Ph<qc.length;Ph++){for(var _g=qc[Ph],Yc=_g[0],Lh=_g[1],yg=!1,oi=0,Dh=Yc+1;Dh<Lh;Dh++){var xg=Te[Dh];if(ce[xg]&gg){yg=!0;var bg=ce[xg]&Xo?M:S;if(bg===bt){oi=bg;break}}}if(yg&&!oi){oi=Ze;for(var Ih=Yc-1;Ih>=0;Ih--){var wg=Te[Ih];if(ce[wg]&gg){var Sg=ce[wg]&Xo?M:S;Sg!==bt?oi=Sg:oi=bt;break}}}if(oi){if(ce[Te[Yc]]=ce[Te[Lh]]=oi,oi!==bt){for(var jo=Yc+1;jo<Te.length;jo++)if(!(ce[Te[jo]]&c)){f(re[Te[jo]])&O&&(ce[Te[jo]]=oi);break}}if(oi!==bt){for(var $o=Lh+1;$o<Te.length;$o++)if(!(ce[Te[$o]]&c)){f(re[Te[$o]])&O&&(ce[Te[$o]]=oi);break}}}}for(var dr=0;dr<Te.length;dr++)if(ce[Te[dr]]&a){for(var Eg=dr,Uh=dr,Oh=Ze,Zo=dr-1;Zo>=0;Zo--)if(ce[Te[Zo]]&c)Eg=Zo;else{Oh=ce[Te[Zo]]&Xo?M:S;break}for(var Mg=At,Ko=dr+1;Ko<Te.length;Ko++)if(ce[Te[Ko]]&(a|c))Uh=Ko;else{Mg=ce[Te[Ko]]&Xo?M:S;break}for(var Nh=Eg;Nh<=Uh;Nh++)ce[Te[Nh]]=Oh===Mg?Oh:bt;dr=Uh}}}for(var Nn=pe.start;Nn<=pe.end;Nn++){var Vw=$[Nn],jc=ce[Nn];if(Vw&1?jc&(S|E|P)&&$[Nn]++:jc&M?$[Nn]++:jc&(P|E)&&($[Nn]+=2),jc&c&&($[Nn]=Nn===0?pe.level:$[Nn-1]),Nn===pe.end||f(re[Nn])&(V|z))for(var $c=Nn;$c>=0&&f(re[$c])&l;$c--)$[$c]=pe.level}}return{levels:$,paragraphs:de};function Tg(Tn,ai){for(var An=Tn;An<re.length;An++){var pr=ce[An];if(pr&(M|k))return 1;if(pr&(z|S)||ai&&pr===ee)return 0;if(pr&s){var Ag=Hw(An);An=Ag===-1?re.length:Ag}}return 0}function Hw(Tn){for(var ai=1,An=Tn+1;An<re.length;An++){var pr=ce[An];if(pr&z)break;if(pr&ee){if(--ai===0)return An}else pr&s&&ai++}return-1}}var me="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",te;function D(){if(!te){var re=v(me,!0),fe=re.map,xe=re.reverseMap;xe.forEach(function(ce,Pe){fe.set(Pe,ce)}),te=fe}}function Q(re){return D(),te.get(re)||null}function j(re,fe,xe,ce){var Pe=re.length;xe=Math.max(0,xe==null?0:+xe),ce=Math.min(Pe-1,ce==null?Pe-1:+ce);for(var B=new Map,I=xe;I<=ce;I++)if(fe[I]&1){var $=Q(re[I]);$!==null&&B.set(I,$)}return B}function K(re,fe,xe,ce){var Pe=re.length;xe=Math.max(0,xe==null?0:+xe),ce=Math.min(Pe-1,ce==null?Pe-1:+ce);var B=[];return fe.paragraphs.forEach(function(I){var $=Math.max(xe,I.start),he=Math.min(ce,I.end);if($<he){for(var de=fe.levels.slice($,he+1),pe=he;pe>=$&&f(re[pe])&l;pe--)de[pe]=I.level;for(var Me=I.level,we=1/0,ue=0;ue<de.length;ue++){var Ce=de[ue];Ce>Me&&(Me=Ce),Ce<we&&(we=Ce|1)}for(var ze=Me;ze>=we;ze--)for(var Le=0;Le<de.length;Le++)if(de[Le]>=ze){for(var Ee=Le;Le+1<de.length&&de[Le+1]>=ze;)Le++;Le>Ee&&B.push([Ee+$,Le+$])}}}),B}function W(re,fe,xe,ce){var Pe=ye(re,fe,xe,ce),B=[].concat(re);return Pe.forEach(function(I,$){B[$]=(fe.levels[I]&1?Q(re[I]):null)||re[I]}),B.join("")}function ye(re,fe,xe,ce){for(var Pe=K(re,fe,xe,ce),B=[],I=0;I<re.length;I++)B[I]=I;return Pe.forEach(function($){for(var he=$[0],de=$[1],pe=B.slice(he,de+1),Me=pe.length;Me--;)B[de-Me]=pe[Me]}),B}return e.closingToOpeningBracket=b,e.getBidiCharType=f,e.getBidiCharTypeName=d,e.getCanonicalBracket=w,e.getEmbeddingLevels=ge,e.getMirroredCharacter=Q,e.getMirroredCharactersMap=j,e.getReorderSegments=K,e.getReorderedIndices=ye,e.getReorderedString=W,e.openingToClosingBracket=x,Object.defineProperty(e,"__esModule",{value:!0}),e})({});return r}/*!
|
|
* camera-controls
|
|
* https://github.com/yomotsu/camera-controls
|
|
* (c) 2017 @yomotsu
|
|
* Released under the MIT License.
|
|
*/const Lt={LEFT:1,RIGHT:2,MIDDLE:4},oe=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),Os={NONE:0,IN:1,OUT:-1};function Br(r){return r.isPerspectiveCamera}function wr(r){return r.isOrthographicCamera}const Ns=Math.PI*2,Hg=Math.PI/2,Wy=1e-5,ra=Math.PI/180;function pi(r,e,t){return Math.max(e,Math.min(t,r))}function Mt(r,e=Wy){return Math.abs(r)<e}function vt(r,e,t=Wy){return Mt(r-e,t)}function Wg(r,e){return Math.round(r/e)*e}function sa(r){return isFinite(r)?r:r<0?-Number.MAX_VALUE:Number.MAX_VALUE}function oa(r){return Math.abs(r)<Number.MAX_VALUE?r:r*(1/0)}function Qc(r,e,t,n,i=1/0,s){n=Math.max(1e-4,n);const o=2/n,a=o*s,c=1/(1+a+.48*a*a+.235*a*a*a);let l=r-e;const u=e,h=i*n;l=pi(l,-h,h),e=r-l;const f=(t.value+o*l)*s;t.value=(t.value-o*f)*c;let d=e+(l+f)*c;return u-r>0==d>u&&(d=u,t.value=(d-u)/s),d}function Xg(r,e,t,n,i=1/0,s,o){n=Math.max(1e-4,n);const a=2/n,c=a*s,l=1/(1+c+.48*c*c+.235*c*c*c);let u=e.x,h=e.y,f=e.z,d=r.x-u,m=r.y-h,v=r.z-f;const g=u,p=h,_=f,y=i*n,x=y*y,b=d*d+m*m+v*v;if(b>x){const V=Math.sqrt(b);d=d/V*y,m=m/V*y,v=v/V*y}u=r.x-d,h=r.y-m,f=r.z-v;const w=(t.x+a*d)*s,S=(t.y+a*m)*s,M=(t.z+a*v)*s;t.x=(t.x-a*w)*l,t.y=(t.y-a*S)*l,t.z=(t.z-a*M)*l,o.x=u+(d+w)*l,o.y=h+(m+S)*l,o.z=f+(v+M)*l;const E=g-r.x,T=p-r.y,L=_-r.z,P=o.x-g,A=o.y-p,z=o.z-_;return E*P+T*A+L*z>0&&(o.x=g,o.y=p,o.z=_,t.x=(o.x-g)/s,t.y=(o.y-p)/s,t.z=(o.z-_)/s),o}function Gh(r,e){e.set(0,0),r.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=r.length,e.y/=r.length}function Vh(r,e){return wr(r)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}let yE=class{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e)}}};var Hh;const xE="2.10.1",el=1/8,bE=/Mac/.test((Hh=globalThis==null?void 0:globalThis.navigator)===null||Hh===void 0?void 0:Hh.platform);let $e,qg,tl,Wh,Cn,it,pt,Fs,aa,Ai,Ci,Gr,Yg,jg,Yn,ca,ks,$g,Xh,Zg,qh,Yh,nl,nn=class Dd extends yE{static install(e){$e=e.THREE,qg=Object.freeze(new $e.Vector3(0,0,0)),tl=Object.freeze(new $e.Vector3(0,1,0)),Wh=Object.freeze(new $e.Vector3(0,0,1)),Cn=new $e.Vector2,it=new $e.Vector3,pt=new $e.Vector3,Fs=new $e.Vector3,aa=new $e.Vector3,Ai=new $e.Vector3,Ci=new $e.Vector3,Gr=new $e.Vector3,Yg=new $e.Vector3,jg=new $e.Vector3,Yn=new $e.Spherical,ca=new $e.Spherical,ks=new $e.Box3,$g=new $e.Box3,Xh=new $e.Sphere,Zg=new $e.Quaternion,qh=new $e.Quaternion,Yh=new $e.Matrix4,nl=new $e.Raycaster}static get ACTION(){return oe}set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=oe.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Os.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new $e.Vector3,this._focalOffsetVelocity=new $e.Vector3,this._zoomVelocity={value:0},this._truckInternal=(p,_,y,x)=>{let b,w;if(Br(this._camera)){const S=it.copy(this._camera.position).sub(this._target),M=this._camera.getEffectiveFOV()*ra,E=S.length()*Math.tan(M*.5);b=this.truckSpeed*p*E/this._elementRect.height,w=this.truckSpeed*_*E/this._elementRect.height}else if(wr(this._camera)){const S=this._camera;b=this.truckSpeed*p*(S.right-S.left)/S.zoom/this._elementRect.width,w=this.truckSpeed*_*(S.top-S.bottom)/S.zoom/this._elementRect.height}else return;x?(y?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(b,0,!0),this.forward(-w,!0)):y?this.setFocalOffset(this._focalOffsetEnd.x+b,this._focalOffsetEnd.y+w,this._focalOffsetEnd.z,!0):this.truck(b,w,!0)},this._rotateInternal=(p,_)=>{const y=Ns*this.azimuthRotateSpeed*p/this._elementRect.height,x=Ns*this.polarRotateSpeed*_/this._elementRect.height;this.rotate(y,x,!0)},this._dollyInternal=(p,_,y)=>{const x=Math.pow(.95,-p*this.dollySpeed),b=this._sphericalEnd.radius,w=this._sphericalEnd.radius*x,S=pi(w,this.minDistance,this.maxDistance),M=S-w;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(w,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(M,!0),this._dollyToNoClamp(S,!0)):this._dollyToNoClamp(S,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?w:S)-b,this._dollyControlCoord.set(_,y)),this._lastDollyDirection=Math.sign(-p)},this._zoomInternal=(p,_,y)=>{const x=Math.pow(.95,p*this.dollySpeed),b=this._zoom,w=this._zoom*x;this.zoomTo(w,!0),this.dollyToCursor&&(this._changedZoom+=w-b,this._dollyControlCoord.set(_,y))},typeof $e>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new $e.Quaternion().setFromUnitVectors(this._camera.up,tl),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=oe.NONE,this._target=new $e.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new $e.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new $e.Spherical().setFromVector3(it.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new $e.Vector3,new $e.Vector3,new $e.Vector3,new $e.Vector3],this._updateNearPlaneCorners(),this._boundary=new $e.Box3(new $e.Vector3(-1/0,-1/0,-1/0),new $e.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new $e.Vector2,this.mouseButtons={left:oe.ROTATE,middle:oe.DOLLY,right:oe.TRUCK,wheel:Br(this._camera)?oe.DOLLY:wr(this._camera)?oe.ZOOM:oe.NONE},this.touches={one:oe.TOUCH_ROTATE,two:Br(this._camera)?oe.TOUCH_DOLLY_TRUCK:wr(this._camera)?oe.TOUCH_ZOOM_TRUCK:oe.NONE,three:oe.TOUCH_TRUCK};const n=new $e.Vector2,i=new $e.Vector2,s=new $e.Vector2,o=p=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const x=this._domElement.getBoundingClientRect(),b=p.clientX/x.width,w=p.clientY/x.height;if(b<this._interactiveArea.left||b>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}const _=p.pointerType!=="mouse"?null:(p.buttons&Lt.LEFT)===Lt.LEFT?Lt.LEFT:(p.buttons&Lt.MIDDLE)===Lt.MIDDLE?Lt.MIDDLE:(p.buttons&Lt.RIGHT)===Lt.RIGHT?Lt.RIGHT:null;if(_!==null){const x=this._findPointerByMouseButton(_);x&&this._disposePointer(x)}if((p.buttons&Lt.LEFT)===Lt.LEFT&&this._lockedPointer)return;const y={pointerId:p.pointerId,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:_};this._activePointers.push(y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,f(p)},a=p=>{p.cancelable&&p.preventDefault();const _=p.pointerId,y=this._lockedPointer||this._findPointerById(_);if(y){if(y.clientX=p.clientX,y.clientY=p.clientY,y.deltaX=p.movementX,y.deltaY=p.movementY,this._state=0,p.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(p.buttons&Lt.LEFT)===Lt.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(p.buttons&Lt.MIDDLE)===Lt.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(p.buttons&Lt.RIGHT)===Lt.RIGHT&&(this._state=this._state|this.mouseButtons.right);d()}},c=p=>{const _=this._findPointerById(p.pointerId);if(!(_&&_===this._lockedPointer)){if(_&&this._disposePointer(_),p.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=oe.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=oe.NONE;m()}};let l=-1;const u=p=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===oe.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const w=this._domElement.getBoundingClientRect(),S=p.clientX/w.width,M=p.clientY/w.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}if(p.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===oe.ROTATE||this.mouseButtons.wheel===oe.TRUCK){const w=performance.now();l-w<1e3&&this._getClientRect(this._elementRect),l=w}const _=bE?-1:-3,y=p.deltaMode===1||p.ctrlKey?p.deltaY/_:p.deltaY/(_*10),x=this.dollyToCursor?(p.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,b=this.dollyToCursor?(p.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case oe.ROTATE:{this._rotateInternal(p.deltaX,p.deltaY),this._isUserControllingRotate=!0;break}case oe.TRUCK:{this._truckInternal(p.deltaX,p.deltaY,!1,!1),this._isUserControllingTruck=!0;break}case oe.SCREEN_PAN:{this._truckInternal(p.deltaX,p.deltaY,!1,!0),this._isUserControllingTruck=!0;break}case oe.OFFSET:{this._truckInternal(p.deltaX,p.deltaY,!0,!1),this._isUserControllingOffset=!0;break}case oe.DOLLY:{this._dollyInternal(-y,x,b),this._isUserControllingDolly=!0;break}case oe.ZOOM:{this._zoomInternal(-y,x,b),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},h=p=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Dd.ACTION.NONE){const _=p instanceof PointerEvent?p.pointerId:0,y=this._findPointerById(_);y&&this._disposePointer(y),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}p.preventDefault()}},f=p=>{if(!this._enabled)return;if(Gh(this._activePointers,Cn),this._getClientRect(this._elementRect),n.copy(Cn),i.copy(Cn),this._activePointers.length>=2){const y=Cn.x-this._activePointers[1].clientX,x=Cn.y-this._activePointers[1].clientY,b=Math.sqrt(y*y+x*x);s.set(0,b);const w=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,S=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(w,S)}if(this._state=0,!p)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in p&&p.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(p.buttons&Lt.LEFT)===Lt.LEFT&&(this._state=this._state|this.mouseButtons.left),(p.buttons&Lt.MIDDLE)===Lt.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(p.buttons&Lt.RIGHT)===Lt.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&oe.ROTATE)===oe.ROTATE||(this._state&oe.TOUCH_ROTATE)===oe.TOUCH_ROTATE||(this._state&oe.TOUCH_DOLLY_ROTATE)===oe.TOUCH_DOLLY_ROTATE||(this._state&oe.TOUCH_ZOOM_ROTATE)===oe.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&oe.TRUCK)===oe.TRUCK||(this._state&oe.SCREEN_PAN)===oe.SCREEN_PAN||(this._state&oe.TOUCH_TRUCK)===oe.TOUCH_TRUCK||(this._state&oe.TOUCH_SCREEN_PAN)===oe.TOUCH_SCREEN_PAN||(this._state&oe.TOUCH_DOLLY_TRUCK)===oe.TOUCH_DOLLY_TRUCK||(this._state&oe.TOUCH_DOLLY_SCREEN_PAN)===oe.TOUCH_DOLLY_SCREEN_PAN||(this._state&oe.TOUCH_ZOOM_TRUCK)===oe.TOUCH_ZOOM_TRUCK||(this._state&oe.TOUCH_ZOOM_SCREEN_PAN)===oe.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&oe.DOLLY)===oe.DOLLY||(this._state&oe.TOUCH_DOLLY)===oe.TOUCH_DOLLY||(this._state&oe.TOUCH_DOLLY_TRUCK)===oe.TOUCH_DOLLY_TRUCK||(this._state&oe.TOUCH_DOLLY_SCREEN_PAN)===oe.TOUCH_DOLLY_SCREEN_PAN||(this._state&oe.TOUCH_DOLLY_OFFSET)===oe.TOUCH_DOLLY_OFFSET||(this._state&oe.TOUCH_DOLLY_ROTATE)===oe.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&oe.ZOOM)===oe.ZOOM||(this._state&oe.TOUCH_ZOOM)===oe.TOUCH_ZOOM||(this._state&oe.TOUCH_ZOOM_TRUCK)===oe.TOUCH_ZOOM_TRUCK||(this._state&oe.TOUCH_ZOOM_SCREEN_PAN)===oe.TOUCH_ZOOM_SCREEN_PAN||(this._state&oe.TOUCH_ZOOM_OFFSET)===oe.TOUCH_ZOOM_OFFSET||(this._state&oe.TOUCH_ZOOM_ROTATE)===oe.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&oe.OFFSET)===oe.OFFSET||(this._state&oe.TOUCH_OFFSET)===oe.TOUCH_OFFSET||(this._state&oe.TOUCH_DOLLY_OFFSET)===oe.TOUCH_DOLLY_OFFSET||(this._state&oe.TOUCH_ZOOM_OFFSET)===oe.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Gh(this._activePointers,Cn);const _=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,y=_?-_.deltaX:i.x-Cn.x,x=_?-_.deltaY:i.y-Cn.y;if(i.copy(Cn),((this._state&oe.ROTATE)===oe.ROTATE||(this._state&oe.TOUCH_ROTATE)===oe.TOUCH_ROTATE||(this._state&oe.TOUCH_DOLLY_ROTATE)===oe.TOUCH_DOLLY_ROTATE||(this._state&oe.TOUCH_ZOOM_ROTATE)===oe.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(y,x),this._isUserControllingRotate=!0),(this._state&oe.DOLLY)===oe.DOLLY||(this._state&oe.ZOOM)===oe.ZOOM){const b=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,S=this.dollyDragInverted?-1:1;(this._state&oe.DOLLY)===oe.DOLLY?(this._dollyInternal(S*x*el,b,w),this._isUserControllingDolly=!0):(this._zoomInternal(S*x*el,b,w),this._isUserControllingZoom=!0)}if((this._state&oe.TOUCH_DOLLY)===oe.TOUCH_DOLLY||(this._state&oe.TOUCH_ZOOM)===oe.TOUCH_ZOOM||(this._state&oe.TOUCH_DOLLY_TRUCK)===oe.TOUCH_DOLLY_TRUCK||(this._state&oe.TOUCH_ZOOM_TRUCK)===oe.TOUCH_ZOOM_TRUCK||(this._state&oe.TOUCH_DOLLY_SCREEN_PAN)===oe.TOUCH_DOLLY_SCREEN_PAN||(this._state&oe.TOUCH_ZOOM_SCREEN_PAN)===oe.TOUCH_ZOOM_SCREEN_PAN||(this._state&oe.TOUCH_DOLLY_OFFSET)===oe.TOUCH_DOLLY_OFFSET||(this._state&oe.TOUCH_ZOOM_OFFSET)===oe.TOUCH_ZOOM_OFFSET||(this._state&oe.TOUCH_DOLLY_ROTATE)===oe.TOUCH_DOLLY_ROTATE||(this._state&oe.TOUCH_ZOOM_ROTATE)===oe.TOUCH_ZOOM_ROTATE){const b=Cn.x-this._activePointers[1].clientX,w=Cn.y-this._activePointers[1].clientY,S=Math.sqrt(b*b+w*w),M=s.y-S;s.set(0,S);const E=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&oe.TOUCH_DOLLY)===oe.TOUCH_DOLLY||(this._state&oe.TOUCH_DOLLY_ROTATE)===oe.TOUCH_DOLLY_ROTATE||(this._state&oe.TOUCH_DOLLY_TRUCK)===oe.TOUCH_DOLLY_TRUCK||(this._state&oe.TOUCH_DOLLY_SCREEN_PAN)===oe.TOUCH_DOLLY_SCREEN_PAN||(this._state&oe.TOUCH_DOLLY_OFFSET)===oe.TOUCH_DOLLY_OFFSET?(this._dollyInternal(M*el,E,T),this._isUserControllingDolly=!0):(this._zoomInternal(M*el,E,T),this._isUserControllingZoom=!0)}((this._state&oe.TRUCK)===oe.TRUCK||(this._state&oe.TOUCH_TRUCK)===oe.TOUCH_TRUCK||(this._state&oe.TOUCH_DOLLY_TRUCK)===oe.TOUCH_DOLLY_TRUCK||(this._state&oe.TOUCH_ZOOM_TRUCK)===oe.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(y,x,!1,!1),this._isUserControllingTruck=!0),((this._state&oe.SCREEN_PAN)===oe.SCREEN_PAN||(this._state&oe.TOUCH_SCREEN_PAN)===oe.TOUCH_SCREEN_PAN||(this._state&oe.TOUCH_DOLLY_SCREEN_PAN)===oe.TOUCH_DOLLY_SCREEN_PAN||(this._state&oe.TOUCH_ZOOM_SCREEN_PAN)===oe.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(y,x,!1,!0),this._isUserControllingTruck=!0),((this._state&oe.OFFSET)===oe.OFFSET||(this._state&oe.TOUCH_OFFSET)===oe.TOUCH_OFFSET||(this._state&oe.TOUCH_DOLLY_OFFSET)===oe.TOUCH_DOLLY_OFFSET||(this._state&oe.TOUCH_ZOOM_OFFSET)===oe.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(y,x,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},m=()=>{Gh(this._activePointers,Cn),i.copy(Cn),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",v),this._domElement.ownerDocument.addEventListener("pointerlockerror",g),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),f())},this.unlockPointer=()=>{var p,_,y;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(p=this._domElement)===null||p===void 0||p.ownerDocument.exitPointerLock(),(_=this._domElement)===null||_===void 0||_.ownerDocument.removeEventListener("pointerlockchange",v),(y=this._domElement)===null||y===void 0||y.ownerDocument.removeEventListener("pointerlockerror",g),this.cancel()};const v=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},g=()=>{this.unlockPointer()};this._addAllEventListeners=p=>{this._domElement=p,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",h)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",h),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",v),this._domElement.ownerDocument.removeEventListener("pointerlockerror",g))},this.cancel=()=>{this._state!==oe.NONE&&(this._state=oe.NONE,this._activePointers.length=0,m())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=pi(e.width,0,1),this._interactiveArea.height=pi(e.height,0,1),this._interactiveArea.x=pi(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=pi(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const i=pi(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=pi(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!n||vt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&vt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Os.NONE,this._changedDolly=0,this._dollyToNoClamp(pi(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),a=vt(o,this._spherical.radius);if(!(n>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,o)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const s=!t||vt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(aa).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||vt(this._target.x,this._targetEnd.x,this.restThreshold)&&vt(this._target.y,this._targetEnd.y,this.restThreshold)&&vt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=pi(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||vt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Ai.setFromMatrixColumn(this._camera.matrix,0),Ci.setFromMatrixColumn(this._camera.matrix,1),Ai.multiplyScalar(e),Ci.multiplyScalar(-t);const i=it.copy(Ai).add(Ci),s=pt.copy(this._targetEnd).add(i);return this.moveTo(s.x,s.y,s.z,n)}forward(e,t=!1){it.setFromMatrixColumn(this._camera.matrix,0),it.crossVectors(this._camera.up,it),it.multiplyScalar(e);const n=pt.copy(this._targetEnd).add(it);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return it.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+it.x,this._targetEnd.y+it.y,this._targetEnd.z+it.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;const s=it.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);const o=!i||vt(this._target.x,this._targetEnd.x,this.restThreshold)&&vt(this._target.y,this._targetEnd.y,this.restThreshold)&&vt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(e,t,n,i=!1){const a=it.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,i)}fitToBox(e,t,{cover:n=!1,paddingLeft:i=0,paddingRight:s=0,paddingBottom:o=0,paddingTop:a=0}={}){const c=[],l=e.isBox3?ks.copy(e):ks.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Wg(this._sphericalEnd.theta,Hg),h=Wg(this._sphericalEnd.phi,Hg);c.push(this.rotateTo(u,h,t));const f=it.setFromSpherical(this._sphericalEnd).normalize(),d=Zg.setFromUnitVectors(f,Wh),m=vt(Math.abs(f.y),1);m&&d.multiply(qh.setFromAxisAngle(tl,u)),d.multiply(this._yAxisUpSpaceInverse);const v=$g.makeEmpty();pt.copy(l.min).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.min).setX(l.max.x).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.min).setY(l.max.y).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.max).setZ(l.min.z).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.min).setZ(l.max.z).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.max).setY(l.min.y).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.max).setX(l.min.x).applyQuaternion(d),v.expandByPoint(pt),pt.copy(l.max).applyQuaternion(d),v.expandByPoint(pt),v.min.x-=i,v.min.y-=o,v.max.x+=s,v.max.y+=a,d.setFromUnitVectors(Wh,f),m&&d.premultiply(qh.invert()),d.premultiply(this._yAxisUpSpace);const g=v.getSize(it),p=v.getCenter(pt).applyQuaternion(d);if(Br(this._camera)){const _=this.getDistanceToFitBox(g.x,g.y,g.z,n);c.push(this.moveTo(p.x,p.y,p.z,t)),c.push(this.dollyTo(_,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(wr(this._camera)){const _=this._camera,y=_.right-_.left,x=_.top-_.bottom,b=n?Math.max(y/g.x,x/g.y):Math.min(y/g.x,x/g.y);c.push(this.moveTo(p.x,p.y,p.z,t)),c.push(this.zoomTo(b,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],s="isObject3D"in e?Dd.createBoundingSphere(e,Xh):Xh.copy(e);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),Br(this._camera)){const o=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(o,t))}else if(wr(this._camera)){const o=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,c=2*s.radius,l=Math.min(o/c,a/c);n.push(this.zoomTo(l,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,i,s,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Os.NONE,this._changedDolly=0;const c=pt.set(i,s,o),l=it.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(l.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!a||vt(this._target.x,this._targetEnd.x,this.restThreshold)&&vt(this._target.y,this._targetEnd.y,this.restThreshold)&&vt(this._target.z,this._targetEnd.z,this.restThreshold)&&vt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&vt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&vt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,n,i,s,o,a,c,l,u,h,f,d,m=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Os.NONE,this._changedDolly=0;const v=it.set(i,s,o),g=pt.set(e,t,n);Yn.setFromVector3(g.sub(v).applyQuaternion(this._yAxisUpSpace));const p=Fs.set(u,h,f),_=pt.set(a,c,l);ca.setFromVector3(_.sub(p).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(v.lerp(p,d));const y=ca.theta-Yn.theta,x=ca.phi-Yn.phi,b=ca.radius-Yn.radius;this._sphericalEnd.set(Yn.radius+b*d,Yn.phi+x*d,Yn.theta+y*d),this.normalizeRotations(),this._needsUpdate=!0,m||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const w=!m||vt(this._target.x,this._targetEnd.x,this.restThreshold)&&vt(this._target.y,this._targetEnd.y,this.restThreshold)&&vt(this._target.z,this._targetEnd.z,this.restThreshold)&&vt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&vt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&vt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(w)}setPosition(e,t,n,i=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,n,i=!1){const s=this.getPosition(it),o=this.setLookAt(s.x,s.y,s.z,e,t,n,i);return this._sphericalEnd.phi=pi(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(e,t,n,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);const s=!i||vt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&vt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&vt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Ai.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Ci.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Gr.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const i=it.set(e,t,n),s=i.distanceTo(this._camera.position),o=i.sub(this._camera.position);Ai.multiplyScalar(o.x),Ci.multiplyScalar(o.y),Gr.multiplyScalar(o.z),it.copy(Ai).add(Ci).add(Gr),it.z=it.z+s,this.dollyTo(s,!1),this.setFocalOffset(-it.x,it.y,-it.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,i){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new $e.Vector4,typeof e=="number"?this._viewport.set(e,t,n,i):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,i=!1){if(Vh(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,o=this._camera.getEffectiveFOV()*ra,a=this._camera.aspect;return((i?s>a:s<a)?t:e/a)*.5/Math.tan(o*.5)+n*.5}getDistanceToFitSphere(e){if(Vh(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*ra,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,i=1<this._camera.aspect?t:n;return e/Math.sin(i*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new $e.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new $e.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new $e.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new $e.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ns,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ns),this._spherical.theta+=Ns*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ns)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!vt(this._camera.up.x,this._cameraUp0.x)||!vt(this._camera.up.y,this._cameraUp0.y)||!vt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(it);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,tl),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=it.subVectors(this._target,this._camera.position).normalize(),t=pt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(it);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,i=this._sphericalEnd.radius-this._spherical.radius,s=Yg.subVectors(this._targetEnd,this._target),o=jg.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(Mt(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const h=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Qc(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,h,1/0,e),this._needsUpdate=!0}if(Mt(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const h=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Qc(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,h,1/0,e),this._needsUpdate=!0}if(Mt(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const h=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Qc(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,h,this.maxSpeed,e),this._needsUpdate=!0}if(Mt(s.x)&&Mt(s.y)&&Mt(s.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const h=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Xg(this._target,this._targetEnd,this._targetVelocity,h,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Mt(o.x)&&Mt(o.y)&&Mt(o.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const h=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Xg(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,h,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Mt(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const h=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Qc(this._zoom,this._zoomEnd,this._zoomVelocity,h,1/0,e)}if(this.dollyToCursor){if(Br(this._camera)&&this._changedDolly!==0){const h=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection(aa),m=it.copy(d).cross(f.up).normalize();m.lengthSq()===0&&(m.x=1);const v=pt.crossVectors(m,d),g=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*ra*.5),_=(this._sphericalEnd.radius-h-this._sphericalEnd.radius)/this._sphericalEnd.radius,y=Fs.copy(this._targetEnd).add(m.multiplyScalar(this._dollyControlCoord.x*g*f.aspect)).add(v.multiplyScalar(this._dollyControlCoord.y*g)),x=it.copy(this._targetEnd).lerp(y,_),b=this._lastDollyDirection===Os.IN&&this._spherical.radius<=this.minDistance,w=this._lastDollyDirection===Os.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(b||w)){this._sphericalEnd.radius-=h,this._spherical.radius-=h;const M=pt.copy(d).multiplyScalar(-h);x.add(M)}this._boundary.clampPoint(x,x);const S=pt.subVectors(x,this._targetEnd);this._targetEnd.copy(x),this._target.add(S),this._changedDolly-=h,Mt(this._changedDolly)&&(this._changedDolly=0)}else if(wr(this._camera)&&this._changedZoom!==0){const h=this._zoom-this._lastZoom,f=this._camera,d=it.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),m=pt.set(0,0,-1).applyQuaternion(f.quaternion),v=Fs.copy(d).add(m.multiplyScalar(-d.dot(f.up))),p=-(this._zoom-h-this._zoom)/this._zoom,_=this._getCameraDirection(aa),y=this._targetEnd.dot(_),x=it.copy(this._targetEnd).lerp(v,p),b=x.dot(_),w=_.multiplyScalar(b-y);x.sub(w),this._boundary.clampPoint(x,x);const S=pt.subVectors(x,this._targetEnd);this._targetEnd.copy(x),this._target.add(S),this._changedZoom-=h,Mt(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Mt(this._focalOffset.x)||!Mt(this._focalOffset.y)||!Mt(this._focalOffset.z))&&(Ai.setFromMatrixColumn(this._camera.matrix,0),Ci.setFromMatrixColumn(this._camera.matrix,1),Gr.setFromMatrixColumn(this._camera.matrix,2),Ai.multiplyScalar(this._focalOffset.x),Ci.multiplyScalar(-this._focalOffset.y),Gr.multiplyScalar(this._focalOffset.z),it.copy(Ai).add(Ci).add(Gr),this._camera.position.add(it),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),it.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),Mt(t,this.restThreshold)&&Mt(n,this.restThreshold)&&Mt(i,this.restThreshold)&&Mt(s.x,this.restThreshold)&&Mt(s.y,this.restThreshold)&&Mt(s.z,this.restThreshold)&&Mt(o.x,this.restThreshold)&&Mt(o.y,this.restThreshold)&&Mt(o.z,this.restThreshold)&&Mt(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:sa(this.maxDistance),minZoom:this.minZoom,maxZoom:sa(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:sa(this.maxPolarAngle),minAzimuthAngle:sa(this.minAzimuthAngle),maxAzimuthAngle:sa(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:it.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=oa(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=oa(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=oa(n.maxPolarAngle),this.minAzimuthAngle=oa(n.minAzimuthAngle),this.maxAzimuthAngle=oa(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Yn.setFromVector3(it.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Yn.theta,Yn.phi,t),this.dollyTo(Yn.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",xE),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const i=t.lengthSq();if(i===0)return e;const s=pt.copy(t).add(e),a=this._boundary.clampPoint(s,Fs).sub(s),c=a.lengthSq();if(c===0)return e.add(t);if(c===i)return e;if(n===0)return e.add(t).add(a);{const l=1+n*c/t.dot(a);return e.add(pt.copy(t).multiplyScalar(l)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Br(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*ra,i=Math.tan(n*.5)*t,s=i*e.aspect;this._nearPlaneCorners[0].set(-s,-i,0),this._nearPlaneCorners[1].set(s,-i,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(-s,i,0)}else if(wr(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,i=e.right*t,s=e.top*t,o=e.bottom*t;this._nearPlaneCorners[0].set(n,s,0),this._nearPlaneCorners[1].set(i,s,0),this._nearPlaneCorners[2].set(i,o,0),this._nearPlaneCorners[3].set(n,o,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Vh(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(aa);Yh.lookAt(qg,n,this._camera.up);for(let i=0;i<4;i++){const s=pt.copy(this._nearPlaneCorners[i]);s.applyMatrix4(Yh);const o=Fs.addVectors(this._target,s);nl.set(o,n),nl.far=this._spherical.radius+1;const a=nl.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new $e.Sphere){const n=t,i=n.center;ks.makeEmpty(),e.traverseVisible(o=>{o.isMesh&&ks.expandByObject(o)}),ks.getCenter(i);let s=0;return e.traverseVisible(o=>{if(!o.isMesh)return;const a=o;if(!a.geometry)return;const c=a.geometry.clone();c.applyMatrix4(a.matrixWorld);const u=c.attributes.position;for(let h=0,f=u.count;h<f;h++)it.fromBufferAttribute(u,h),s=Math.max(s,i.distanceToSquared(it))}),n.radius=Math.sqrt(s),n}};const wE={},Kg=r=>{let e;const t=new Set,n=(c,l)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const h=e;e=l??typeof u!="object"?u:Object.assign({},e,u),t.forEach(f=>f(e,h))}},i=()=>e,a={setState:n,getState:i,subscribe:c=>(t.add(c),()=>t.delete(c)),destroy:()=>{(wE?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}};return e=r(n,i,a),a},SE=r=>r?Kg(r):Kg;var jh={exports:{}},$h={},Zh={exports:{}},Kh={};/**
|
|
* @license React
|
|
* use-sync-external-store-shim.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/var Jg;function EE(){if(Jg)return Kh;Jg=1;var r=Iy();function e(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var t=typeof Object.is=="function"?Object.is:e,n=r.useState,i=r.useEffect,s=r.useLayoutEffect,o=r.useDebugValue;function a(h,f){var d=f(),m=n({inst:{value:d,getSnapshot:f}}),v=m[0].inst,g=m[1];return s(function(){v.value=d,v.getSnapshot=f,c(v)&&g({inst:v})},[h,d,f]),i(function(){return c(v)&&g({inst:v}),h(function(){c(v)&&g({inst:v})})},[h]),o(d),d}function c(h){var f=h.getSnapshot;h=h.value;try{var d=f();return!t(h,d)}catch{return!0}}function l(h,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Kh.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:u,Kh}var Qg;function ME(){return Qg||(Qg=1,Zh.exports=EE()),Zh.exports}/**
|
|
* @license React
|
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/var e0;function TE(){if(e0)return $h;e0=1;var r=Iy(),e=ME();function t(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var n=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=r.useRef,o=r.useEffect,a=r.useMemo,c=r.useDebugValue;return $h.useSyncExternalStoreWithSelector=function(l,u,h,f,d){var m=s(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function p(w){if(!_){if(_=!0,y=w,w=f(w),d!==void 0&&v.hasValue){var S=v.value;if(d(S,w))return x=S}return x=w}if(S=x,n(y,w))return S;var M=f(w);return d!==void 0&&d(S,M)?S:(y=w,x=M)}var _=!1,y,x,b=h===void 0?null:h;return[function(){return p(u())},b===null?void 0:function(){return p(b())}]},[u,h,f,d]);var g=i(l,m[0],m[1]);return o(function(){v.hasValue=!0,v.value=g},[g]),c(g),g},$h}var t0;function AE(){return t0||(t0=1,jh.exports=TE()),jh.exports}var CE=AE();const RE=ki(CE),PE={},{useSyncExternalStoreWithSelector:LE}=RE;function Xy(r,e=r.getState,t){const n=LE(r.subscribe,r.getState,r.getServerState||r.getState,e,t);return q.useDebugValue(n),n}const n0=r=>{(PE?"production":void 0)!=="production"&&typeof r!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e=typeof r=="function"?SE(r):r,t=(n,i)=>Xy(e,n,i);return Object.assign(t,e),t},DE=r=>r?n0(r):n0;/**
|
|
* @license
|
|
* Copyright 2010-2023 Three.js Authors
|
|
* SPDX-License-Identifier: MIT
|
|
*/const Iu="154",qy={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},IE={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Yy=0,Id=1,jy=2,UE=3,$y=0,Uu=1,za=2,mi=3,Oi=0,vn=1,Dt=2,OE=2,nr=0,ls=1,Ud=2,Od=3,Nd=4,Zy=5,ns=100,Ky=101,Jy=102,Fd=103,kd=104,Qy=200,ex=201,tx=202,nx=203,Vp=204,Hp=205,ix=206,rx=207,sx=208,ox=209,ax=210,cx=0,lx=1,ux=2,vu=3,hx=4,fx=5,dx=6,px=7,Rc=0,mx=1,gx=2,yi=0,vx=1,_x=2,yx=3,Wp=4,xx=5,Ou=300,Pr=301,Lr=302,Ka=303,Ja=304,Oo=306,Qa=1e3,gn=1001,ec=1002,Yt=1003,_u=1004,NE=1004,Ba=1005,FE=1005,Pt=1006,Xp=1007,kE=1007,Dr=1008,zE=1008,Ii=1009,bx=1010,wx=1011,Nu=1012,qp=1013,tr=1014,Li=1015,Ao=1016,Yp=1017,jp=1018,Mr=1020,Sx=1021,Ln=1023,Ex=1024,Mx=1025,Tr=1026,ms=1027,Tx=1028,$p=1029,Ax=1030,Zp=1031,Kp=1033,iu=33776,ru=33777,su=33778,ou=33779,zd=35840,Bd=35841,Gd=35842,Vd=35843,Cx=36196,Hd=37492,Wd=37496,Xd=37808,qd=37809,Yd=37810,jd=37811,$d=37812,Zd=37813,Kd=37814,Jd=37815,Qd=37816,ep=37817,tp=37818,np=37819,ip=37820,rp=37821,au=36492,Rx=36283,sp=36284,op=36285,ap=36286,Px=2200,Lx=2201,Dx=2202,tc=2300,nc=2301,cu=2302,ss=2400,os=2401,ic=2402,Fu=2500,Jp=2501,BE=0,GE=1,VE=2,Qp=3e3,Ar=3001,Ix=3200,em=3201,Or=0,Ux=1,Cr="",et="srgb",xi="srgb-linear",tm="display-p3",HE=0,lu=7680,WE=7681,XE=7682,qE=7683,YE=34055,jE=34056,$E=5386,ZE=512,KE=513,JE=514,QE=515,eM=516,tM=517,nM=518,Ox=519,Nx=512,Fx=513,kx=514,zx=515,Bx=516,Gx=517,Vx=518,Hx=519,rc=35044,iM=35048,rM=35040,sM=35045,oM=35049,aM=35041,cM=35046,lM=35050,uM=35042,hM="100",cp="300 es",yu=1035,Di=2e3,sc=2001;let ar=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}};const pn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let i0=1234567;const us=Math.PI/180,Co=180/Math.PI;function Bn(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(pn[r&255]+pn[r>>8&255]+pn[r>>16&255]+pn[r>>24&255]+"-"+pn[e&255]+pn[e>>8&255]+"-"+pn[e>>16&15|64]+pn[e>>24&255]+"-"+pn[t&63|128]+pn[t>>8&255]+"-"+pn[t>>16&255]+pn[t>>24&255]+pn[n&255]+pn[n>>8&255]+pn[n>>16&255]+pn[n>>24&255]).toLowerCase()}function Bt(r,e,t){return Math.max(e,Math.min(t,r))}function nm(r,e){return(r%e+e)%e}function fM(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function dM(r,e,t){return r!==e?(t-r)/(e-r):0}function Ga(r,e,t){return(1-t)*r+t*e}function pM(r,e,t,n){return Ga(r,e,1-Math.exp(-t*n))}function mM(r,e=1){return e-Math.abs(nm(r,e*2)-e)}function gM(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function vM(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function _M(r,e){return r+Math.floor(Math.random()*(e-r+1))}function yM(r,e){return r+Math.random()*(e-r)}function xM(r){return r*(.5-Math.random())}function bM(r){r!==void 0&&(i0=r);let e=i0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function wM(r){return r*us}function SM(r){return r*Co}function lp(r){return(r&r-1)===0&&r!==0}function Wx(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function xu(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function EM(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),f=o((e-n)/2),d=s((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":r.set(a*u,c*h,c*f,a*l);break;case"YZY":r.set(c*f,a*u,c*h,a*l);break;case"ZXZ":r.set(c*h,c*f,a*u,a*l);break;case"XZX":r.set(a*u,c*m,c*d,a*l);break;case"YXY":r.set(c*d,a*u,c*m,a*l);break;case"ZYZ":r.set(c*m,c*d,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function zn(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function ot(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const bu={DEG2RAD:us,RAD2DEG:Co,generateUUID:Bn,clamp:Bt,euclideanModulo:nm,mapLinear:fM,inverseLerp:dM,lerp:Ga,damp:pM,pingpong:mM,smoothstep:gM,smootherstep:vM,randInt:_M,randFloat:yM,randFloatSpread:xM,seededRandom:bM,degToRad:wM,radToDeg:SM,isPowerOfTwo:lp,ceilPowerOfTwo:Wx,floorPowerOfTwo:xu,setQuaternionFromProperEuler:EM,normalize:ot,denormalize:zn};class be{constructor(e=0,t=0){be.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class rt{constructor(e,t,n,i,s,o,a,c,l){rt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,c,l)}set(e,t,n,i,s,o,a,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],d=n[5],m=n[8],v=i[0],g=i[3],p=i[6],_=i[1],y=i[4],x=i[7],b=i[2],w=i[5],S=i[8];return s[0]=o*v+a*_+c*b,s[3]=o*g+a*y+c*w,s[6]=o*p+a*x+c*S,s[1]=l*v+u*_+h*b,s[4]=l*g+u*y+h*w,s[7]=l*p+u*x+h*S,s[2]=f*v+d*_+m*b,s[5]=f*g+d*y+m*w,s[8]=f*p+d*x+m*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*s*u+n*a*c+i*s*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,f=a*c-u*s,d=l*s-o*c,m=t*h+n*f+i*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return e[0]=h*v,e[1]=(i*l-u*n)*v,e[2]=(a*n-i*o)*v,e[3]=f*v,e[4]=(u*t-i*c)*v,e[5]=(i*s-a*t)*v,e[6]=d*v,e[7]=(n*c-l*t)*v,e[8]=(o*t-n*s)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Jh.makeScale(e,t)),this}rotate(e){return this.premultiply(Jh.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Jh=new rt;function Xx(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}const MM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function vo(r,e){return new MM[r](e)}function oc(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const r0={};function Va(r){r in r0||(r0[r]=!0,console.warn(r))}function wo(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Qh(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}const TM=new rt().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),AM=new rt().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function CM(r){return r.convertSRGBToLinear().applyMatrix3(AM)}function RM(r){return r.applyMatrix3(TM).convertLinearToSRGB()}const PM={[xi]:r=>r,[et]:r=>r.convertSRGBToLinear(),[tm]:CM},LM={[xi]:r=>r,[et]:r=>r.convertLinearToSRGB(),[tm]:RM},Zn={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return xi},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=PM[e],i=LM[t];if(n===void 0||i===void 0)throw new Error(`Unsupported color space conversion, "${e}" to "${t}".`);return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}};let zs;class im{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{zs===void 0&&(zs=oc("canvas")),zs.width=e.width,zs.height=e.height;const n=zs.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=zs}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=oc("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=wo(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(wo(t[n]/255)*255):t[n]=wo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let DM=0;class as{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:DM++}),this.uuid=Bn(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(ef(i[o].image)):s.push(ef(i[o]))}else s=ef(i);n.url=s}return t||(e.images[this.uuid]=n),n}}function ef(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?im.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let IM=0;class Ft extends ar{constructor(e=Ft.DEFAULT_IMAGE,t=Ft.DEFAULT_MAPPING,n=gn,i=gn,s=Pt,o=Dr,a=Ln,c=Ii,l=Ft.DEFAULT_ANISOTROPY,u=Cr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:IM++}),this.uuid=Bn(),this.name="",this.source=new as(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new be(0,0),this.repeat=new be(1,1),this.center=new be(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new rt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(Va("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===Ar?et:Cr),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ou)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Qa:e.x=e.x-Math.floor(e.x);break;case gn:e.x=e.x<0?0:1;break;case ec:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Qa:e.y=e.y-Math.floor(e.y);break;case gn:e.y=e.y<0?0:1;break;case ec:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Va("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===et?Ar:Qp}set encoding(e){Va("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ar?et:Cr}}Ft.DEFAULT_IMAGE=null;Ft.DEFAULT_MAPPING=Ou;Ft.DEFAULT_ANISOTROPY=1;class mt{constructor(e=0,t=0,n=0,i=1){mt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const c=e.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],m=c[9],v=c[2],g=c[6],p=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(m-g)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(m+g)<.1&&Math.abs(l+d+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const y=(l+1)/2,x=(d+1)/2,b=(p+1)/2,w=(u+f)/4,S=(h+v)/4,M=(m+g)/4;return y>x&&y>b?y<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(y),i=w/n,s=S/n):x>b?x<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(x),n=w/i,s=M/i):b<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),n=S/s,i=M/s),this.set(n,i,s,t),this}let _=Math.sqrt((g-m)*(g-m)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(_)<.001&&(_=1),this.x=(g-m)/_,this.y=(h-v)/_,this.z=(f-u)/_,this.w=Math.acos((l+d+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class bi extends ar{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new mt(0,0,e,t),this.scissorTest=!1,this.viewport=new mt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(Va("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Ar?et:Cr),this.texture=new Ft(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Pt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new as(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ku extends Ft{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Yt,this.minFilter=Yt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class UM extends bi{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new ku(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class rm extends Ft{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Yt,this.minFilter=Yt,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class OM extends bi{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new rm(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class NM extends bi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const s=this.texture;this.texture=[];for(let o=0;o<n;o++)this.texture[o]=s.clone(),this.texture[o].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,s=this.texture.length;i<s;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class ln{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,o,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3];const f=s[o+0],d=s[o+1],m=s[o+2],v=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=m,e[t+3]=v;return}if(h!==v||c!==f||l!==d||u!==m){let g=1-a;const p=c*f+l*d+u*m+h*v,_=p>=0?1:-1,y=1-p*p;if(y>Number.EPSILON){const b=Math.sqrt(y),w=Math.atan2(b,p*_);g=Math.sin(g*w)/b,a=Math.sin(a*w)/b}const x=a*_;if(c=c*g+f*x,l=l*g+d*x,u=u*g+m*x,h=h*g+v*x,g===1-a){const b=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=b,l*=b,u*=b,h*=b}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=s[o],f=s[o+1],d=s[o+2],m=s[o+3];return e[t]=a*m+u*h+c*d-l*f,e[t+1]=c*m+u*f+l*h-a*d,e[t+2]=l*m+u*d+a*f-c*h,e[t+3]=u*m-a*h-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(s/2),f=c(n/2),d=c(i/2),m=c(s/2);switch(o){case"XYZ":this._x=f*u*h+l*d*m,this._y=l*d*h-f*u*m,this._z=l*u*m+f*d*h,this._w=l*u*h-f*d*m;break;case"YXZ":this._x=f*u*h+l*d*m,this._y=l*d*h-f*u*m,this._z=l*u*m-f*d*h,this._w=l*u*h+f*d*m;break;case"ZXY":this._x=f*u*h-l*d*m,this._y=l*d*h+f*u*m,this._z=l*u*m+f*d*h,this._w=l*u*h-f*d*m;break;case"ZYX":this._x=f*u*h-l*d*m,this._y=l*d*h+f*u*m,this._z=l*u*m-f*d*h,this._w=l*u*h+f*d*m;break;case"YZX":this._x=f*u*h+l*d*m,this._y=l*d*h+f*u*m,this._z=l*u*m-f*d*h,this._w=l*u*h-f*d*m;break;case"XZY":this._x=f*u*h-l*d*m,this._y=l*d*h-f*u*m,this._z=l*u*m+f*d*h,this._w=l*u*h+f*d*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],f=n+a+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(o-i)*d}else if(n>a&&n>h){const d=2*Math.sqrt(1+n-a-h);this._w=(u-c)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(s+l)/d}else if(a>h){const d=2*Math.sqrt(1+a-n-h);this._w=(s-l)/d,this._x=(i+o)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-n-a);this._w=(o-i)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+i*l-s*c,this._y=i*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-i*a,this._w=o*u-n*a-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const d=1-t;return this._w=d*o+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(e=0,t=0,n=0){G.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(s0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(s0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=c*t+o*i-a*n,u=c*n+a*t-s*i,h=c*i+s*n-o*t,f=-s*t-o*n-a*i;return this.x=l*c+f*-s+u*-a-h*-o,this.y=u*c+f*-o+h*-s-l*-a,this.z=h*c+f*-a+l*-o-u*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-s*a,this.y=s*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return tf.copy(this).projectOnVector(e),this.sub(tf)}reflect(e){return this.sub(tf.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const tf=new G,s0=new ln;class Hn{constructor(e=new G(1/0,1/0,1/0),t=new G(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Xi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Xi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Xi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),e.boundingBox!==void 0)e.boundingBox===null&&e.computeBoundingBox(),Bs.copy(e.boundingBox),Bs.applyMatrix4(e.matrixWorld),this.union(Bs);else{const i=e.geometry;if(i!==void 0)if(t&&i.attributes!==void 0&&i.attributes.position!==void 0){const s=i.attributes.position;for(let o=0,a=s.count;o<a;o++)Xi.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(Xi)}else i.boundingBox===null&&i.computeBoundingBox(),Bs.copy(i.boundingBox),Bs.applyMatrix4(e.matrixWorld),this.union(Bs)}const n=e.children;for(let i=0,s=n.length;i<s;i++)this.expandByObject(n[i],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Xi),Xi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(la),il.subVectors(this.max,la),Gs.subVectors(e.a,la),Vs.subVectors(e.b,la),Hs.subVectors(e.c,la),mr.subVectors(Vs,Gs),gr.subVectors(Hs,Vs),Vr.subVectors(Gs,Hs);let t=[0,-mr.z,mr.y,0,-gr.z,gr.y,0,-Vr.z,Vr.y,mr.z,0,-mr.x,gr.z,0,-gr.x,Vr.z,0,-Vr.x,-mr.y,mr.x,0,-gr.y,gr.x,0,-Vr.y,Vr.x,0];return!nf(t,Gs,Vs,Hs,il)||(t=[1,0,0,0,1,0,0,0,1],!nf(t,Gs,Vs,Hs,il))?!1:(rl.crossVectors(mr,gr),t=[rl.x,rl.y,rl.z],nf(t,Gs,Vs,Hs,il))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Wi=[new G,new G,new G,new G,new G,new G,new G,new G],Xi=new G,Bs=new Hn,Gs=new G,Vs=new G,Hs=new G,mr=new G,gr=new G,Vr=new G,la=new G,il=new G,rl=new G,Hr=new G;function nf(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Hr.fromArray(r,s);const a=i.x*Math.abs(Hr.x)+i.y*Math.abs(Hr.y)+i.z*Math.abs(Hr.z),c=e.dot(Hr),l=t.dot(Hr),u=n.dot(Hr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const FM=new Hn,ua=new G,rf=new G;let Wn=class{constructor(e=new G,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):FM.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ua.subVectors(e,this.center);const t=ua.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(ua,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(rf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ua.copy(e.center).add(rf)),this.expandByPoint(ua.copy(e.center).sub(rf))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}};const qi=new G,sf=new G,sl=new G,vr=new G,of=new G,ol=new G,af=new G;class No{constructor(e=new G,t=new G(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,qi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=qi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qi.copy(this.origin).addScaledVector(this.direction,t),qi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){sf.copy(e).add(t).multiplyScalar(.5),sl.copy(t).sub(e).normalize(),vr.copy(this.origin).sub(sf);const s=e.distanceTo(t)*.5,o=-this.direction.dot(sl),a=vr.dot(this.direction),c=-vr.dot(sl),l=vr.lengthSq(),u=Math.abs(1-o*o);let h,f,d,m;if(u>0)if(h=o*c-a,f=o*a-c,m=s*u,h>=0)if(f>=-m)if(f<=m){const v=1/u;h*=v,f*=v,d=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;else f<=-m?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l):f<=m?(h=0,f=Math.min(Math.max(-s,-c),s),d=f*(f+2*c)+l):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-c),s),d=-h*h+f*(f+2*c)+l);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(sf).addScaledVector(sl,f),d}intersectSphere(e,t){qi.subVectors(e.center,this.origin);const n=qi.dot(this.direction),i=qi.dot(qi)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-f.z)*h,c=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,c=(e.min.z-f.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,qi)!==null}intersectTriangle(e,t,n,i,s){of.subVectors(t,e),ol.subVectors(n,e),af.crossVectors(of,ol);let o=this.direction.dot(af),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;vr.subVectors(this.origin,e);const c=a*this.direction.dot(ol.crossVectors(vr,ol));if(c<0)return null;const l=a*this.direction.dot(of.cross(vr));if(l<0||c+l>o)return null;const u=-a*vr.dot(af);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ke{constructor(e,t,n,i,s,o,a,c,l,u,h,f,d,m,v,g){Ke.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,c,l,u,h,f,d,m,v,g)}set(e,t,n,i,s,o,a,c,l,u,h,f,d,m,v,g){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=f,p[3]=d,p[7]=m,p[11]=v,p[15]=g,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 Ke().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ws.setFromMatrixColumn(e,0).length(),s=1/Ws.setFromMatrixColumn(e,1).length(),o=1/Ws.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const f=o*u,d=o*h,m=a*u,v=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=d+m*l,t[5]=f-v*l,t[9]=-a*c,t[2]=v-f*l,t[6]=m+d*l,t[10]=o*c}else if(e.order==="YXZ"){const f=c*u,d=c*h,m=l*u,v=l*h;t[0]=f+v*a,t[4]=m*a-d,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=d*a-m,t[6]=v+f*a,t[10]=o*c}else if(e.order==="ZXY"){const f=c*u,d=c*h,m=l*u,v=l*h;t[0]=f-v*a,t[4]=-o*h,t[8]=m+d*a,t[1]=d+m*a,t[5]=o*u,t[9]=v-f*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const f=o*u,d=o*h,m=a*u,v=a*h;t[0]=c*u,t[4]=m*l-d,t[8]=f*l+v,t[1]=c*h,t[5]=v*l+f,t[9]=d*l-m,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const f=o*c,d=o*l,m=a*c,v=a*l;t[0]=c*u,t[4]=v-f*h,t[8]=m*h+d,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=d*h+m,t[10]=f-v*h}else if(e.order==="XZY"){const f=o*c,d=o*l,m=a*c,v=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=f*h+v,t[5]=o*u,t[9]=d*h-m,t[2]=m*h-d,t[6]=a*u,t[10]=v*h+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kM,e,zM)}lookAt(e,t,n){const i=this.elements;return Fn.subVectors(e,t),Fn.lengthSq()===0&&(Fn.z=1),Fn.normalize(),_r.crossVectors(n,Fn),_r.lengthSq()===0&&(Math.abs(n.z)===1?Fn.x+=1e-4:Fn.z+=1e-4,Fn.normalize(),_r.crossVectors(n,Fn)),_r.normalize(),al.crossVectors(Fn,_r),i[0]=_r.x,i[4]=al.x,i[8]=Fn.x,i[1]=_r.y,i[5]=al.y,i[9]=Fn.y,i[2]=_r.z,i[6]=al.z,i[10]=Fn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],d=n[13],m=n[2],v=n[6],g=n[10],p=n[14],_=n[3],y=n[7],x=n[11],b=n[15],w=i[0],S=i[4],M=i[8],E=i[12],T=i[1],L=i[5],P=i[9],A=i[13],z=i[2],V=i[6],N=i[10],C=i[14],O=i[3],k=i[7],U=i[11],R=i[15];return s[0]=o*w+a*T+c*z+l*O,s[4]=o*S+a*L+c*V+l*k,s[8]=o*M+a*P+c*N+l*U,s[12]=o*E+a*A+c*C+l*R,s[1]=u*w+h*T+f*z+d*O,s[5]=u*S+h*L+f*V+d*k,s[9]=u*M+h*P+f*N+d*U,s[13]=u*E+h*A+f*C+d*R,s[2]=m*w+v*T+g*z+p*O,s[6]=m*S+v*L+g*V+p*k,s[10]=m*M+v*P+g*N+p*U,s[14]=m*E+v*A+g*C+p*R,s[3]=_*w+y*T+x*z+b*O,s[7]=_*S+y*L+x*V+b*k,s[11]=_*M+y*P+x*N+b*U,s[15]=_*E+y*A+x*C+b*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],f=e[10],d=e[14],m=e[3],v=e[7],g=e[11],p=e[15];return m*(+s*c*h-i*l*h-s*a*f+n*l*f+i*a*d-n*c*d)+v*(+t*c*d-t*l*f+s*o*f-i*o*d+i*l*u-s*c*u)+g*(+t*l*h-t*a*d-s*o*h+n*o*d+s*a*u-n*l*u)+p*(-i*a*u-t*c*h+t*a*f+i*o*h-n*o*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],m=e[12],v=e[13],g=e[14],p=e[15],_=h*g*l-v*f*l+v*c*d-a*g*d-h*c*p+a*f*p,y=m*f*l-u*g*l-m*c*d+o*g*d+u*c*p-o*f*p,x=u*v*l-m*h*l+m*a*d-o*v*d-u*a*p+o*h*p,b=m*h*c-u*v*c-m*a*f+o*v*f+u*a*g-o*h*g,w=t*_+n*y+i*x+s*b;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/w;return e[0]=_*S,e[1]=(v*f*s-h*g*s-v*i*d+n*g*d+h*i*p-n*f*p)*S,e[2]=(a*g*s-v*c*s+v*i*l-n*g*l-a*i*p+n*c*p)*S,e[3]=(h*c*s-a*f*s-h*i*l+n*f*l+a*i*d-n*c*d)*S,e[4]=y*S,e[5]=(u*g*s-m*f*s+m*i*d-t*g*d-u*i*p+t*f*p)*S,e[6]=(m*c*s-o*g*s-m*i*l+t*g*l+o*i*p-t*c*p)*S,e[7]=(o*f*s-u*c*s+u*i*l-t*f*l-o*i*d+t*c*d)*S,e[8]=x*S,e[9]=(m*h*s-u*v*s-m*n*d+t*v*d+u*n*p-t*h*p)*S,e[10]=(o*v*s-m*a*s+m*n*l-t*v*l-o*n*p+t*a*p)*S,e[11]=(u*a*s-o*h*s-u*n*l+t*h*l+o*n*d-t*a*d)*S,e[12]=b*S,e[13]=(u*v*i-m*h*i+m*n*f-t*v*f-u*n*g+t*h*g)*S,e[14]=(m*a*i-o*v*i-m*n*c+t*v*c+o*n*g-t*a*g)*S,e[15]=(o*h*i-u*a*i+u*n*c-t*h*c-o*n*f+t*a*f)*S,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*o,0,l*c-i*a,u*c+i*o,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,h=a+a,f=s*l,d=s*u,m=s*h,v=o*u,g=o*h,p=a*h,_=c*l,y=c*u,x=c*h,b=n.x,w=n.y,S=n.z;return i[0]=(1-(v+p))*b,i[1]=(d+x)*b,i[2]=(m-y)*b,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(f+p))*w,i[6]=(g+_)*w,i[7]=0,i[8]=(m+y)*S,i[9]=(g-_)*S,i[10]=(1-(f+v))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Ws.set(i[0],i[1],i[2]).length();const o=Ws.set(i[4],i[5],i[6]).length(),a=Ws.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],li.copy(this);const l=1/s,u=1/o,h=1/a;return li.elements[0]*=l,li.elements[1]*=l,li.elements[2]*=l,li.elements[4]*=u,li.elements[5]*=u,li.elements[6]*=u,li.elements[8]*=h,li.elements[9]*=h,li.elements[10]*=h,t.setFromRotationMatrix(li),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=Di){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),h=(t+e)/(t-e),f=(n+i)/(n-i);let d,m;if(a===Di)d=-(o+s)/(o-s),m=-2*o*s/(o-s);else if(a===sc)d=-o/(o-s),m=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=Di){const c=this.elements,l=1/(t-e),u=1/(n-i),h=1/(o-s),f=(t+e)*l,d=(n+i)*u;let m,v;if(a===Di)m=(o+s)*h,v=-2*h;else if(a===sc)m=s*h,v=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=v,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ws=new G,li=new Ke,kM=new G(0,0,0),zM=new G(1,1,1),_r=new G,al=new G,Fn=new G,o0=new Ke,a0=new ln;class Ir{constructor(e=0,t=0,n=0,i=Ir.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],o=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(Bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Bt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Bt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Bt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Bt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return o0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(o0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return a0.setFromEuler(this),this.setFromQuaternion(a0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ir.DEFAULT_ORDER="XYZ";class hs{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let BM=0;const c0=new G,Xs=new ln,Yi=new Ke,cl=new G,ha=new G,GM=new G,VM=new ln,l0=new G(1,0,0),u0=new G(0,1,0),h0=new G(0,0,1),HM={type:"added"},f0={type:"removed"};class gt extends ar{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:BM++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();const e=new G,t=new Ir,n=new ln,i=new G(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ke},normalMatrix:{value:new rt}}),this.matrix=new Ke,this.matrixWorld=new Ke,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new hs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Xs.setFromAxisAngle(e,t),this.quaternion.multiply(Xs),this}rotateOnWorldAxis(e,t){return Xs.setFromAxisAngle(e,t),this.quaternion.premultiply(Xs),this}rotateX(e){return this.rotateOnAxis(l0,e)}rotateY(e){return this.rotateOnAxis(u0,e)}rotateZ(e){return this.rotateOnAxis(h0,e)}translateOnAxis(e,t){return c0.copy(e).applyQuaternion(this.quaternion),this.position.add(c0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(l0,e)}translateY(e){return this.translateOnAxis(u0,e)}translateZ(e){return this.translateOnAxis(h0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Yi.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?cl.copy(e):cl.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),ha.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Yi.lookAt(ha,cl,this.up):Yi.lookAt(cl,ha,this.up),this.quaternion.setFromRotationMatrix(Yi),i&&(Yi.extractRotation(i.matrixWorld),Xs.setFromRotationMatrix(Yi),this.quaternion.premultiply(Xs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(HM)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(f0)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(f0)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Yi.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Yi.multiply(e.parent.matrixWorld)),e.applyMatrix4(Yi),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,s=this.children.length;i<s;i++){const o=this.children[i].getObjectsByProperty(e,t);o.length>0&&(n=n.concat(o))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ha,e,GM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ha,VM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const s=t[n];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++){const a=i[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(s(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),f=o(e.skeletons),d=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}gt.DEFAULT_UP=new G(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ui=new G,ji=new G,cf=new G,$i=new G,qs=new G,Ys=new G,d0=new G,lf=new G,uf=new G,hf=new G;let ll=!1;class Pn{constructor(e=new G,t=new G,n=new G){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ui.subVectors(e,t),i.cross(ui);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){ui.subVectors(i,t),ji.subVectors(n,t),cf.subVectors(e,t);const o=ui.dot(ui),a=ui.dot(ji),c=ui.dot(cf),l=ji.dot(ji),u=ji.dot(cf),h=o*l-a*a;if(h===0)return s.set(-2,-1,-1);const f=1/h,d=(l*c-a*u)*f,m=(o*u-a*c)*f;return s.set(1-d-m,m,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,$i),$i.x>=0&&$i.y>=0&&$i.x+$i.y<=1}static getUV(e,t,n,i,s,o,a,c){return ll===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),ll=!0),this.getInterpolation(e,t,n,i,s,o,a,c)}static getInterpolation(e,t,n,i,s,o,a,c){return this.getBarycoord(e,t,n,i,$i),c.setScalar(0),c.addScaledVector(s,$i.x),c.addScaledVector(o,$i.y),c.addScaledVector(a,$i.z),c}static isFrontFacing(e,t,n,i){return ui.subVectors(n,t),ji.subVectors(e,t),ui.cross(ji).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ui.subVectors(this.c,this.b),ji.subVectors(this.a,this.b),ui.cross(ji).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Pn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Pn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return ll===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),ll=!0),Pn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return Pn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Pn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Pn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;qs.subVectors(i,n),Ys.subVectors(s,n),lf.subVectors(e,n);const c=qs.dot(lf),l=Ys.dot(lf);if(c<=0&&l<=0)return t.copy(n);uf.subVectors(e,i);const u=qs.dot(uf),h=Ys.dot(uf);if(u>=0&&h<=u)return t.copy(i);const f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(qs,o);hf.subVectors(e,s);const d=qs.dot(hf),m=Ys.dot(hf);if(m>=0&&d<=m)return t.copy(s);const v=d*l-c*m;if(v<=0&&l>=0&&m<=0)return a=l/(l-m),t.copy(n).addScaledVector(Ys,a);const g=u*m-d*h;if(g<=0&&h-u>=0&&d-m>=0)return d0.subVectors(s,i),a=(h-u)/(h-u+(d-m)),t.copy(i).addScaledVector(d0,a);const p=1/(g+v+f);return o=v*p,a=f*p,t.copy(n).addScaledVector(qs,o).addScaledVector(Ys,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let WM=0;class un extends ar{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:WM++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=ls,this.side=Oi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Vp,this.blendDst=Hp,this.blendEquation=ns,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=vu,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ox,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=lu,this.stencilZFail=lu,this.stencilZPass=lu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ls&&(n.blending=this.blending),this.side!==Oi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(t){const s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const qx={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},hi={h:0,s:0,l:0},ul={h:0,s:0,l:0};function ff(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class Ne{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=et){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Zn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Zn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Zn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Zn.workingColorSpace){if(e=nm(e,1),t=Bt(t,0,1),n=Bt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=ff(o,s,e+1/3),this.g=ff(o,s,e),this.b=ff(o,s,e-1/3)}return Zn.toWorkingColorSpace(this,i),this}setStyle(e,t=et){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=et){const n=qx[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=wo(e.r),this.g=wo(e.g),this.b=wo(e.b),this}copyLinearToSRGB(e){return this.r=Qh(e.r),this.g=Qh(e.g),this.b=Qh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=et){return Zn.fromWorkingColorSpace(mn.copy(this),e),Math.round(Bt(mn.r*255,0,255))*65536+Math.round(Bt(mn.g*255,0,255))*256+Math.round(Bt(mn.b*255,0,255))}getHexString(e=et){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Zn.workingColorSpace){Zn.fromWorkingColorSpace(mn.copy(this),t);const n=mn.r,i=mn.g,s=mn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-n)/h+2;break;case s:c=(n-i)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=Zn.workingColorSpace){return Zn.fromWorkingColorSpace(mn.copy(this),t),e.r=mn.r,e.g=mn.g,e.b=mn.b,e}getStyle(e=et){Zn.fromWorkingColorSpace(mn.copy(this),e);const t=mn.r,n=mn.g,i=mn.b;return e!==et?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(hi),hi.h+=e,hi.s+=t,hi.l+=n,this.setHSL(hi.h,hi.s,hi.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(hi),e.getHSL(ul);const n=Ga(hi.h,ul.h,t),i=Ga(hi.s,ul.s,t),s=Ga(hi.l,ul.l,t);return this.setHSL(n,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*i,this.g=s[1]*t+s[4]*n+s[7]*i,this.b=s[2]*t+s[5]*n+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const mn=new Ne;Ne.NAMES=qx;class cr extends un{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Rc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const er=XM();function XM(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function Rn(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=Bt(r,-65504,65504),er.floatView[0]=r;const e=er.uint32View[0],t=e>>23&511;return er.baseTable[t]+((e&8388607)>>er.shiftTable[t])}function Ua(r){const e=r>>10;return er.uint32View[0]=er.mantissaTable[er.offsetTable[e]+(r&1023)]+er.exponentTable[e],er.floatView[0]}const qM={toHalfFloat:Rn,fromHalfFloat:Ua},jt=new G,hl=new be;class wt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=rc,this.updateRange={offset:0,count:-1},this.gpuType=Li,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)hl.fromBufferAttribute(this,t),hl.applyMatrix3(e),this.setXY(t,hl.x,hl.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix3(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix4(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyNormalMatrix(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.transformDirection(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=zn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=zn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=zn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=zn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),s=ot(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==rc&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}class YM extends wt{constructor(e,t,n){super(new Int8Array(e),t,n)}}class jM extends wt{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class $M extends wt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class ZM extends wt{constructor(e,t,n){super(new Int16Array(e),t,n)}}class sm extends wt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class KM extends wt{constructor(e,t,n){super(new Int32Array(e),t,n)}}class om extends wt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class JM extends wt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Ua(this.array[e*this.itemSize]);return this.normalized&&(t=zn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize]=Rn(t),this}getY(e){let t=Ua(this.array[e*this.itemSize+1]);return this.normalized&&(t=zn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize+1]=Rn(t),this}getZ(e){let t=Ua(this.array[e*this.itemSize+2]);return this.normalized&&(t=zn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize+2]=Rn(t),this}getW(e){let t=Ua(this.array[e*this.itemSize+3]);return this.normalized&&(t=zn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ot(t,this.array)),this.array[e*this.itemSize+3]=Rn(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array)),this.array[e+0]=Rn(t),this.array[e+1]=Rn(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array)),this.array[e+0]=Rn(t),this.array[e+1]=Rn(n),this.array[e+2]=Rn(i),this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),s=ot(s,this.array)),this.array[e+0]=Rn(t),this.array[e+1]=Rn(n),this.array[e+2]=Rn(i),this.array[e+3]=Rn(s),this}}class He extends wt{constructor(e,t,n){super(new Float32Array(e),t,n)}}class QM extends wt{constructor(e,t,n){super(new Float64Array(e),t,n)}}let eT=0;const jn=new Ke,df=new gt,js=new G,kn=new Hn,fa=new Hn,tn=new G;class st extends ar{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:eT++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Xx(e)?om:sm)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new rt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return jn.makeRotationFromQuaternion(e),this.applyMatrix4(jn),this}rotateX(e){return jn.makeRotationX(e),this.applyMatrix4(jn),this}rotateY(e){return jn.makeRotationY(e),this.applyMatrix4(jn),this}rotateZ(e){return jn.makeRotationZ(e),this.applyMatrix4(jn),this}translate(e,t,n){return jn.makeTranslation(e,t,n),this.applyMatrix4(jn),this}scale(e,t,n){return jn.makeScale(e,t,n),this.applyMatrix4(jn),this}lookAt(e){return df.lookAt(e),df.updateMatrix(),this.applyMatrix4(df.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(js).negate(),this.translate(js.x,js.y,js.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new He(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Hn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new G(-1/0,-1/0,-1/0),new G(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const s=t[n];kn.setFromBufferAttribute(s),this.morphTargetsRelative?(tn.addVectors(this.boundingBox.min,kn.min),this.boundingBox.expandByPoint(tn),tn.addVectors(this.boundingBox.max,kn.max),this.boundingBox.expandByPoint(tn)):(this.boundingBox.expandByPoint(kn.min),this.boundingBox.expandByPoint(kn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Wn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new G,1/0);return}if(e){const n=this.boundingSphere.center;if(kn.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){const a=t[s];fa.setFromBufferAttribute(a),this.morphTargetsRelative?(tn.addVectors(kn.min,fa.min),kn.expandByPoint(tn),tn.addVectors(kn.max,fa.max),kn.expandByPoint(tn)):(kn.expandByPoint(fa.min),kn.expandByPoint(fa.max))}kn.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)tn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(tn));if(t)for(let s=0,o=t.length;s<o;s++){const a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)tn.fromBufferAttribute(a,l),c&&(js.fromBufferAttribute(e,l),tn.add(js)),i=Math.max(i,n.distanceToSquared(tn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new wt(new Float32Array(4*a),4));const c=this.getAttribute("tangent").array,l=[],u=[];for(let T=0;T<a;T++)l[T]=new G,u[T]=new G;const h=new G,f=new G,d=new G,m=new be,v=new be,g=new be,p=new G,_=new G;function y(T,L,P){h.fromArray(i,T*3),f.fromArray(i,L*3),d.fromArray(i,P*3),m.fromArray(o,T*2),v.fromArray(o,L*2),g.fromArray(o,P*2),f.sub(h),d.sub(h),v.sub(m),g.sub(m);const A=1/(v.x*g.y-g.x*v.y);isFinite(A)&&(p.copy(f).multiplyScalar(g.y).addScaledVector(d,-v.y).multiplyScalar(A),_.copy(d).multiplyScalar(v.x).addScaledVector(f,-g.x).multiplyScalar(A),l[T].add(p),l[L].add(p),l[P].add(p),u[T].add(_),u[L].add(_),u[P].add(_))}let x=this.groups;x.length===0&&(x=[{start:0,count:n.length}]);for(let T=0,L=x.length;T<L;++T){const P=x[T],A=P.start,z=P.count;for(let V=A,N=A+z;V<N;V+=3)y(n[V+0],n[V+1],n[V+2])}const b=new G,w=new G,S=new G,M=new G;function E(T){S.fromArray(s,T*3),M.copy(S);const L=l[T];b.copy(L),b.sub(S.multiplyScalar(S.dot(L))).normalize(),w.crossVectors(M,L);const A=w.dot(u[T])<0?-1:1;c[T*4]=b.x,c[T*4+1]=b.y,c[T*4+2]=b.z,c[T*4+3]=A}for(let T=0,L=x.length;T<L;++T){const P=x[T],A=P.start,z=P.count;for(let V=A,N=A+z;V<N;V+=3)E(n[V+0]),E(n[V+1]),E(n[V+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new wt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const i=new G,s=new G,o=new G,a=new G,c=new G,l=new G,u=new G,h=new G;if(e)for(let f=0,d=e.count;f<d;f+=3){const m=e.getX(f+0),v=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,v),o.fromBufferAttribute(t,g),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),a.fromBufferAttribute(n,m),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,g),a.add(u),c.add(u),l.add(u),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let f=0,d=t.count;f<d;f+=3)i.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),u.subVectors(o,s),h.subVectors(i,s),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)tn.fromBufferAttribute(e,t),tn.normalize(),e.setXYZ(t,tn.x,tn.y,tn.z)}toNonIndexed(){function e(a,c){const l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u);let d=0,m=0;for(let v=0,g=c.length;v<g;v++){a.isInterleavedBufferAttribute?d=c[v]*a.data.stride+a.offset:d=c[v]*u;for(let p=0;p<u;p++)f[m++]=l[d++]}return new wt(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new st,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const s=this.morphAttributes;for(const a in s){const c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){const f=l[u],d=e(f,n);c.push(d)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){const d=l[h];u.push(d.toJSON(e.data))}u.length>0&&(i[c]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],h=s[l];for(let f=0,d=h.length;f<d;f++)u.push(h[f].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const p0=new Ke,Wr=new No,fl=new Wn,m0=new G,$s=new G,Zs=new G,Ks=new G,pf=new G,dl=new G,pl=new be,ml=new be,gl=new be,g0=new G,v0=new G,_0=new G,vl=new G,_l=new G;class Ot extends gt{constructor(e=new st,t=new cr){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(s&&a){dl.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=a[c],h=s[c];u!==0&&(pf.fromBufferAttribute(h,e),o?dl.addScaledVector(pf,u):dl.addScaledVector(pf.sub(t),u))}t.add(dl)}return t}raycast(e,t){const n=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),fl.copy(n.boundingSphere),fl.applyMatrix4(s),Wr.copy(e.ray).recast(e.near),!(fl.containsPoint(Wr.origin)===!1&&(Wr.intersectSphere(fl,m0)===null||Wr.origin.distanceToSquared(m0)>(e.far-e.near)**2))&&(p0.copy(s).invert(),Wr.copy(e.ray).applyMatrix4(p0),!(n.boundingBox!==null&&Wr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Wr)))}_computeIntersections(e,t,n){let i;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=f.length;m<v;m++){const g=f[m],p=o[g.materialIndex],_=Math.max(g.start,d.start),y=Math.min(a.count,Math.min(g.start+g.count,d.start+d.count));for(let x=_,b=y;x<b;x+=3){const w=a.getX(x),S=a.getX(x+1),M=a.getX(x+2);i=yl(this,p,e,n,l,u,h,w,S,M),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const m=Math.max(0,d.start),v=Math.min(a.count,d.start+d.count);for(let g=m,p=v;g<p;g+=3){const _=a.getX(g),y=a.getX(g+1),x=a.getX(g+2);i=yl(this,o,e,n,l,u,h,_,y,x),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let m=0,v=f.length;m<v;m++){const g=f[m],p=o[g.materialIndex],_=Math.max(g.start,d.start),y=Math.min(c.count,Math.min(g.start+g.count,d.start+d.count));for(let x=_,b=y;x<b;x+=3){const w=x,S=x+1,M=x+2;i=yl(this,p,e,n,l,u,h,w,S,M),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const m=Math.max(0,d.start),v=Math.min(c.count,d.start+d.count);for(let g=m,p=v;g<p;g+=3){const _=g,y=g+1,x=g+2;i=yl(this,o,e,n,l,u,h,_,y,x),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function tT(r,e,t,n,i,s,o,a){let c;if(e.side===vn?c=n.intersectTriangle(o,s,i,!0,a):c=n.intersectTriangle(i,s,o,e.side===Oi,a),c===null)return null;_l.copy(a),_l.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(_l);return l<t.near||l>t.far?null:{distance:l,point:_l.clone(),object:r}}function yl(r,e,t,n,i,s,o,a,c,l){r.getVertexPosition(a,$s),r.getVertexPosition(c,Zs),r.getVertexPosition(l,Ks);const u=tT(r,e,t,n,$s,Zs,Ks,vl);if(u){i&&(pl.fromBufferAttribute(i,a),ml.fromBufferAttribute(i,c),gl.fromBufferAttribute(i,l),u.uv=Pn.getInterpolation(vl,$s,Zs,Ks,pl,ml,gl,new be)),s&&(pl.fromBufferAttribute(s,a),ml.fromBufferAttribute(s,c),gl.fromBufferAttribute(s,l),u.uv1=Pn.getInterpolation(vl,$s,Zs,Ks,pl,ml,gl,new be),u.uv2=u.uv1),o&&(g0.fromBufferAttribute(o,a),v0.fromBufferAttribute(o,c),_0.fromBufferAttribute(o,l),u.normal=Pn.getInterpolation(vl,$s,Zs,Ks,g0,v0,_0,new G),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a,b:c,c:l,normal:new G,materialIndex:0};Pn.getNormal($s,Zs,Ks,h.normal),u.face=h}return u}class lr extends st{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const c=[],l=[],u=[],h=[];let f=0,d=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(c),this.setAttribute("position",new He(l,3)),this.setAttribute("normal",new He(u,3)),this.setAttribute("uv",new He(h,2));function m(v,g,p,_,y,x,b,w,S,M,E){const T=x/S,L=b/M,P=x/2,A=b/2,z=w/2,V=S+1,N=M+1;let C=0,O=0;const k=new G;for(let U=0;U<N;U++){const R=U*L-A;for(let F=0;F<V;F++){const H=F*T-P;k[v]=H*_,k[g]=R*y,k[p]=z,l.push(k.x,k.y,k.z),k[v]=0,k[g]=0,k[p]=w>0?1:-1,u.push(k.x,k.y,k.z),h.push(F/S),h.push(1-U/M),C+=1}}for(let U=0;U<M;U++)for(let R=0;R<S;R++){const F=f+R+V*U,H=f+R+V*(U+1),Y=f+(R+1)+V*(U+1),J=f+(R+1)+V*U;c.push(F,H,J),c.push(H,Y,J),O+=6}a.addGroup(d,O,E),d+=O,f+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ro(r){const e={};for(const t in r){e[t]={};for(const n in r[t]){const i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function bn(r){const e={};for(let t=0;t<r.length;t++){const n=Ro(r[t]);for(const i in n)e[i]=n[i]}return e}function nT(r){const e=[];for(let t=0;t<r.length;t++)e.push(r[t].clone());return e}function Yx(r){return r.getRenderTarget()===null?r.outputColorSpace:xi}const am={clone:Ro,merge:bn};var iT=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,rT=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class Ni extends un{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=iT,this.fragmentShader=rT,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ro(e.uniforms),this.uniformsGroups=nT(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Pc extends gt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ke,this.projectionMatrix=new Ke,this.projectionMatrixInverse=new Ke,this.coordinateSystem=Di}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Zt extends Pc{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Co*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(us*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Co*2*Math.atan(Math.tan(us*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(us*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Js=-90,Qs=1;class jx extends gt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new Zt(Js,Qs,e,t);i.layers=this.layers,this.add(i);const s=new Zt(Js,Qs,e,t);s.layers=this.layers,this.add(s);const o=new Zt(Js,Qs,e,t);o.layers=this.layers,this.add(o);const a=new Zt(Js,Qs,e,t);a.layers=this.layers,this.add(a);const c=new Zt(Js,Qs,e,t);c.layers=this.layers,this.add(c);const l=new Zt(Js,Qs,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,c]=t;for(const l of t)this.remove(l);if(e===Di)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===sc)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,s,o,a,c,l]=this.children,u=e.getRenderTarget(),h=e.toneMapping,f=e.xr.enabled;e.toneMapping=yi,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,s),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,c),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.toneMapping=h,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class Lc extends Ft{constructor(e,t,n,i,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Pr,super(e,t,n,i,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class $x extends bi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(Va("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Ar?et:Cr),this.texture=new Lc(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Pt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},i=new lr(5,5,5),s=new Ni({name:"CubemapFromEquirect",uniforms:Ro(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:vn,blending:nr});s.uniforms.tEquirect.value=t;const o=new Ot(i,s),a=t.minFilter;return t.minFilter===Dr&&(t.minFilter=Pt),new jx(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}}const mf=new G,sT=new G,oT=new rt;class Qi{constructor(e=new G(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=mf.subVectors(n,t).cross(sT.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(mf),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||oT.getNormalMatrix(e),i=this.coplanarPoint(mf).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Xr=new Wn,xl=new G;class zu{constructor(e=new Qi,t=new Qi,n=new Qi,i=new Qi,s=new Qi,o=new Qi){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Di){const n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],c=i[3],l=i[4],u=i[5],h=i[6],f=i[7],d=i[8],m=i[9],v=i[10],g=i[11],p=i[12],_=i[13],y=i[14],x=i[15];if(n[0].setComponents(c-s,f-l,g-d,x-p).normalize(),n[1].setComponents(c+s,f+l,g+d,x+p).normalize(),n[2].setComponents(c+o,f+u,g+m,x+_).normalize(),n[3].setComponents(c-o,f-u,g-m,x-_).normalize(),n[4].setComponents(c-a,f-h,g-v,x-y).normalize(),t===Di)n[5].setComponents(c+a,f+h,g+v,x+y).normalize();else if(t===sc)n[5].setComponents(a,h,v,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Xr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Xr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Xr)}intersectsSprite(e){return Xr.center.set(0,0,0),Xr.radius=.7071067811865476,Xr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(xl.x=i.normal.x>0?e.max.x:e.min.x,xl.y=i.normal.y>0?e.max.y:e.min.y,xl.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(xl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Zx(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function aT(r,e){const t=e.isWebGL2,n=new WeakMap;function i(l,u){const h=l.array,f=l.usage,d=r.createBuffer();r.bindBuffer(u,d),r.bufferData(u,h,f),l.onUploadCallback();let m;if(h instanceof Float32Array)m=r.FLOAT;else if(h instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)m=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=r.UNSIGNED_SHORT;else if(h instanceof Int16Array)m=r.SHORT;else if(h instanceof Uint32Array)m=r.UNSIGNED_INT;else if(h instanceof Int32Array)m=r.INT;else if(h instanceof Int8Array)m=r.BYTE;else if(h instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:d,type:m,bytesPerElement:h.BYTES_PER_ELEMENT,version:l.version}}function s(l,u,h){const f=u.array,d=u.updateRange;r.bindBuffer(h,l),d.count===-1?r.bufferSubData(h,0,f):(t?r.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):r.bufferSubData(h,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1),u.onUploadCallback()}function o(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u&&(r.deleteBuffer(u.buffer),n.delete(l))}function c(l,u){if(l.isGLBufferAttribute){const f=n.get(l);(!f||f.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const h=n.get(l);h===void 0?n.set(l,i(l,u)):h.version<l.version&&(s(h.buffer,l,u),h.version=l.version)}return{get:o,remove:a,update:c}}class Nr extends st{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const s=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,u=c+1,h=e/a,f=t/c,d=[],m=[],v=[],g=[];for(let p=0;p<u;p++){const _=p*f-o;for(let y=0;y<l;y++){const x=y*h-s;m.push(x,-_,0),v.push(0,0,1),g.push(y/a),g.push(1-p/c)}}for(let p=0;p<c;p++)for(let _=0;_<a;_++){const y=_+l*p,x=_+l*(p+1),b=_+1+l*(p+1),w=_+1+l*p;d.push(y,x,w),d.push(x,b,w)}this.setIndex(d),this.setAttribute("position",new He(m,3)),this.setAttribute("normal",new He(v,3)),this.setAttribute("uv",new He(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nr(e.width,e.height,e.widthSegments,e.heightSegments)}}var cT=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,lT=`#ifdef USE_ALPHAHASH
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
float hash2D( vec2 value ) {
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
}
|
|
float hash3D( vec3 value ) {
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
}
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|
float maxDeriv = max(
|
|
length( dFdx( position.xyz ) ),
|
|
length( dFdy( position.xyz ) )
|
|
);
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
vec2 pixScales = vec2(
|
|
exp2( floor( log2( pixScale ) ) ),
|
|
exp2( ceil( log2( pixScale ) ) )
|
|
);
|
|
vec2 alpha = vec2(
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|
);
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
vec3 cases = vec3(
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
);
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|
: cases.z;
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
}
|
|
#endif`,uT=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,hT=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,fT=`#ifdef USE_ALPHATEST
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif`,dT=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,pT=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,mT=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,gT=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,vT=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,_T=`float G_BlinnPhong_Implicit( ) {
|
|
return 0.25;
|
|
}
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
}
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
float G = G_BlinnPhong_Implicit( );
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
return F * ( G * D );
|
|
} // validated`,yT=`#ifdef USE_IRIDESCENCE
|
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
3.2404542, -0.9692660, 0.0556434,
|
|
-1.5371385, 1.8760108, -0.2040259,
|
|
-0.4985314, 0.0415560, 1.0572252
|
|
);
|
|
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
}
|
|
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
}
|
|
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
}
|
|
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
xyz /= 1.0685e-7;
|
|
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
return rgb;
|
|
}
|
|
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
vec3 I;
|
|
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
if ( cosTheta2Sq < 0.0 ) {
|
|
return vec3( 1.0 );
|
|
}
|
|
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
float R21 = R12;
|
|
float T121 = 1.0 - R12;
|
|
float phi12 = 0.0;
|
|
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
float phi21 = PI - phi12;
|
|
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
vec3 phi23 = vec3( 0.0 );
|
|
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
vec3 phi = vec3( phi21 ) + phi23;
|
|
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
vec3 r123 = sqrt( R123 );
|
|
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
vec3 C0 = R12 + Rs;
|
|
I = C0;
|
|
vec3 Cm = Rs - T121;
|
|
for ( int m = 1; m <= 2; ++ m ) {
|
|
Cm *= r123;
|
|
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
I += Cm * Sm;
|
|
}
|
|
return max( I, vec3( 0.0 ) );
|
|
}
|
|
#endif`,xT=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = dFdx( surf_pos.xyz );
|
|
vec3 vSigmaY = dFdy( surf_pos.xyz );
|
|
vec3 vN = surf_norm;
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
}
|
|
#endif`,bT=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
bool clipped = true;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
}
|
|
#pragma unroll_loop_end
|
|
if ( clipped ) discard;
|
|
#endif
|
|
#endif`,wT=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,ST=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,ET=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,MT=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,TT=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,AT=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,CT=`#if defined( USE_COLOR_ALPHA )
|
|
vColor = vec4( 1.0 );
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
vColor = vec3( 1.0 );
|
|
#endif
|
|
#ifdef USE_COLOR
|
|
vColor *= color;
|
|
#endif
|
|
#ifdef USE_INSTANCING_COLOR
|
|
vColor.xyz *= instanceColor.xyz;
|
|
#endif`,RT=`#define PI 3.141592653589793
|
|
#define PI2 6.283185307179586
|
|
#define PI_HALF 1.5707963267948966
|
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
#define RECIPROCAL_PI2 0.15915494309189535
|
|
#define EPSILON 1e-6
|
|
#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
float pow2( const in float x ) { return x*x; }
|
|
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
float pow3( const in float x ) { return x*x*x; }
|
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
highp float rand( const in vec2 uv ) {
|
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
return fract( sin( sn ) * c );
|
|
}
|
|
#ifdef HIGH_PRECISION
|
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
#else
|
|
float precisionSafeLength( vec3 v ) {
|
|
float maxComponent = max3( abs( v ) );
|
|
return length( v / maxComponent ) * maxComponent;
|
|
}
|
|
#endif
|
|
struct IncidentLight {
|
|
vec3 color;
|
|
vec3 direction;
|
|
bool visible;
|
|
};
|
|
struct ReflectedLight {
|
|
vec3 directDiffuse;
|
|
vec3 directSpecular;
|
|
vec3 indirectDiffuse;
|
|
vec3 indirectSpecular;
|
|
};
|
|
struct GeometricContext {
|
|
vec3 position;
|
|
vec3 normal;
|
|
vec3 viewDir;
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal;
|
|
#endif
|
|
};
|
|
#ifdef USE_ALPHAHASH
|
|
varying vec3 vPosition;
|
|
#endif
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
}
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
}
|
|
mat3 transposeMat3( const in mat3 m ) {
|
|
mat3 tmp;
|
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
return tmp;
|
|
}
|
|
float luminance( const in vec3 rgb ) {
|
|
const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
|
|
return dot( weights, rgb );
|
|
}
|
|
bool isPerspectiveMatrix( mat4 m ) {
|
|
return m[ 2 ][ 3 ] == - 1.0;
|
|
}
|
|
vec2 equirectUv( in vec3 dir ) {
|
|
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
return vec2( u, v );
|
|
}
|
|
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
return RECIPROCAL_PI * diffuseColor;
|
|
}
|
|
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
}
|
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
} // validated`,PT=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
#define cubeUV_minMipLevel 4.0
|
|
#define cubeUV_minTileSize 16.0
|
|
float getFace( vec3 direction ) {
|
|
vec3 absDirection = abs( direction );
|
|
float face = - 1.0;
|
|
if ( absDirection.x > absDirection.z ) {
|
|
if ( absDirection.x > absDirection.y )
|
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
} else {
|
|
if ( absDirection.z > absDirection.y )
|
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
}
|
|
return face;
|
|
}
|
|
vec2 getUV( vec3 direction, float face ) {
|
|
vec2 uv;
|
|
if ( face == 0.0 ) {
|
|
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 1.0 ) {
|
|
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
} else if ( face == 2.0 ) {
|
|
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
} else if ( face == 3.0 ) {
|
|
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 4.0 ) {
|
|
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
} else {
|
|
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
}
|
|
return 0.5 * ( uv + 1.0 );
|
|
}
|
|
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
float face = getFace( direction );
|
|
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
float faceSize = exp2( mipInt );
|
|
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
if ( face > 2.0 ) {
|
|
uv.y += faceSize;
|
|
face -= 3.0;
|
|
}
|
|
uv.x += face * faceSize;
|
|
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
#ifdef texture2DGradEXT
|
|
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
#else
|
|
return texture2D( envMap, uv ).rgb;
|
|
#endif
|
|
}
|
|
#define cubeUV_r0 1.0
|
|
#define cubeUV_v0 0.339
|
|
#define cubeUV_m0 - 2.0
|
|
#define cubeUV_r1 0.8
|
|
#define cubeUV_v1 0.276
|
|
#define cubeUV_m1 - 1.0
|
|
#define cubeUV_r4 0.4
|
|
#define cubeUV_v4 0.046
|
|
#define cubeUV_m4 2.0
|
|
#define cubeUV_r5 0.305
|
|
#define cubeUV_v5 0.016
|
|
#define cubeUV_m5 3.0
|
|
#define cubeUV_r6 0.21
|
|
#define cubeUV_v6 0.0038
|
|
#define cubeUV_m6 4.0
|
|
float roughnessToMip( float roughness ) {
|
|
float mip = 0.0;
|
|
if ( roughness >= cubeUV_r1 ) {
|
|
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
} else if ( roughness >= cubeUV_r4 ) {
|
|
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
} else if ( roughness >= cubeUV_r5 ) {
|
|
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
} else if ( roughness >= cubeUV_r6 ) {
|
|
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
} else {
|
|
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
return mip;
|
|
}
|
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
float mipF = fract( mip );
|
|
float mipInt = floor( mip );
|
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
if ( mipF == 0.0 ) {
|
|
return vec4( color0, 1.0 );
|
|
} else {
|
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
}
|
|
}
|
|
#endif`,LT=`vec3 transformedNormal = objectNormal;
|
|
#ifdef USE_INSTANCING
|
|
mat3 m = mat3( instanceMatrix );
|
|
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
|
transformedNormal = m * transformedNormal;
|
|
#endif
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
#ifdef FLIP_SIDED
|
|
transformedNormal = - transformedNormal;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#ifdef FLIP_SIDED
|
|
transformedTangent = - transformedTangent;
|
|
#endif
|
|
#endif`,DT=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,IT=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
#endif`,UT=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,OT=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,NT="gl_FragColor = linearToOutputTexel( gl_FragColor );",FT=`vec4 LinearToLinear( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 LinearTosRGB( in vec4 value ) {
|
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
}`,kT=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vec3 cameraToFrag;
|
|
if ( isOrthographic ) {
|
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
#else
|
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
#endif
|
|
#else
|
|
vec3 reflectVec = vReflect;
|
|
#endif
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
#else
|
|
vec4 envColor = vec4( 0.0 );
|
|
#endif
|
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_MIX )
|
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
#endif
|
|
#endif`,zT=`#ifdef USE_ENVMAP
|
|
uniform float envMapIntensity;
|
|
uniform float flipEnvMap;
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#else
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
|
|
#endif`,BT=`#ifdef USE_ENVMAP
|
|
uniform float reflectivity;
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
varying vec3 vWorldPosition;
|
|
uniform float refractionRatio;
|
|
#else
|
|
varying vec3 vReflect;
|
|
#endif
|
|
#endif`,GT=`#ifdef USE_ENVMAP
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
|
|
varying vec3 vWorldPosition;
|
|
#else
|
|
varying vec3 vReflect;
|
|
uniform float refractionRatio;
|
|
#endif
|
|
#endif`,VT=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vWorldPosition = worldPosition.xyz;
|
|
#else
|
|
vec3 cameraToVertex;
|
|
if ( isOrthographic ) {
|
|
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vReflect = reflect( cameraToVertex, worldNormal );
|
|
#else
|
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
#endif
|
|
#endif
|
|
#endif`,HT=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,WT=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,XT=`#ifdef USE_FOG
|
|
#ifdef FOG_EXP2
|
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
#else
|
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
#endif
|
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
#endif`,qT=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,YT=`#ifdef USE_GRADIENTMAP
|
|
uniform sampler2D gradientMap;
|
|
#endif
|
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
float dotNL = dot( normal, lightDirection );
|
|
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
#ifdef USE_GRADIENTMAP
|
|
return vec3( texture2D( gradientMap, coord ).r );
|
|
#else
|
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
#endif
|
|
}`,jT=`#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
reflectedLight.indirectDiffuse += lightMapIrradiance;
|
|
#endif`,$T=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,ZT=`LambertMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularStrength = specularStrength;`,KT=`varying vec3 vViewPosition;
|
|
struct LambertMaterial {
|
|
vec3 diffuseColor;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Lambert
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,JT=`uniform bool receiveShadow;
|
|
uniform vec3 ambientLightColor;
|
|
uniform vec3 lightProbe[ 9 ];
|
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
float x = normal.x, y = normal.y, z = normal.z;
|
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
return result;
|
|
}
|
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
return irradiance;
|
|
}
|
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
vec3 irradiance = ambientLightColor;
|
|
return irradiance;
|
|
}
|
|
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
#if defined ( LEGACY_LIGHTS )
|
|
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
|
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
|
}
|
|
return 1.0;
|
|
#else
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
if ( cutoffDistance > 0.0 ) {
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
}
|
|
return distanceFalloff;
|
|
#endif
|
|
}
|
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
}
|
|
#if NUM_DIR_LIGHTS > 0
|
|
struct DirectionalLight {
|
|
vec3 direction;
|
|
vec3 color;
|
|
};
|
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
|
|
light.color = directionalLight.color;
|
|
light.direction = directionalLight.direction;
|
|
light.visible = true;
|
|
}
|
|
#endif
|
|
#if NUM_POINT_LIGHTS > 0
|
|
struct PointLight {
|
|
vec3 position;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
};
|
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
|
|
vec3 lVector = pointLight.position - geometry.position;
|
|
light.direction = normalize( lVector );
|
|
float lightDistance = length( lVector );
|
|
light.color = pointLight.color;
|
|
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
}
|
|
#endif
|
|
#if NUM_SPOT_LIGHTS > 0
|
|
struct SpotLight {
|
|
vec3 position;
|
|
vec3 direction;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
float coneCos;
|
|
float penumbraCos;
|
|
};
|
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
|
|
vec3 lVector = spotLight.position - geometry.position;
|
|
light.direction = normalize( lVector );
|
|
float angleCos = dot( light.direction, spotLight.direction );
|
|
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
if ( spotAttenuation > 0.0 ) {
|
|
float lightDistance = length( lVector );
|
|
light.color = spotLight.color * spotAttenuation;
|
|
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
} else {
|
|
light.color = vec3( 0.0 );
|
|
light.visible = false;
|
|
}
|
|
}
|
|
#endif
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
struct RectAreaLight {
|
|
vec3 color;
|
|
vec3 position;
|
|
vec3 halfWidth;
|
|
vec3 halfHeight;
|
|
};
|
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
#endif
|
|
#if NUM_HEMI_LIGHTS > 0
|
|
struct HemisphereLight {
|
|
vec3 direction;
|
|
vec3 skyColor;
|
|
vec3 groundColor;
|
|
};
|
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
float dotNL = dot( normal, hemiLight.direction );
|
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
return irradiance;
|
|
}
|
|
#endif`,QT=`#ifdef USE_ENVMAP
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
|
return PI * envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
|
return envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#endif
|
|
#endif`,eA=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,tA=`varying vec3 vViewPosition;
|
|
struct ToonMaterial {
|
|
vec3 diffuseColor;
|
|
};
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Toon
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,nA=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,iA=`varying vec3 vViewPosition;
|
|
struct BlinnPhongMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 specularColor;
|
|
float specularShininess;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
}
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,rA=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
material.roughness = min( material.roughness, 1.0 );
|
|
#ifdef IOR
|
|
material.ior = ior;
|
|
#ifdef USE_SPECULAR
|
|
float specularIntensityFactor = specularIntensity;
|
|
vec3 specularColorFactor = specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
#endif
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
#else
|
|
float specularIntensityFactor = 1.0;
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
#else
|
|
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
material.clearcoat = clearcoat;
|
|
material.clearcoatRoughness = clearcoatRoughness;
|
|
material.clearcoatF0 = vec3( 0.04 );
|
|
material.clearcoatF90 = 1.0;
|
|
#ifdef USE_CLEARCOATMAP
|
|
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
#endif
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
material.clearcoatRoughness += geometryRoughness;
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
material.iridescence = iridescence;
|
|
material.iridescenceIOR = iridescenceIOR;
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
#else
|
|
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
material.sheenColor = sheenColor;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
#endif
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
#ifdef USE_ANISOTROPYMAP
|
|
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
#else
|
|
vec2 anisotropyV = anisotropyVector;
|
|
#endif
|
|
material.anisotropy = length( anisotropyV );
|
|
anisotropyV /= material.anisotropy;
|
|
material.anisotropy = saturate( material.anisotropy );
|
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;
|
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;
|
|
#endif`,sA=`struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
float roughness;
|
|
vec3 specularColor;
|
|
float specularF90;
|
|
#ifdef USE_CLEARCOAT
|
|
float clearcoat;
|
|
float clearcoatRoughness;
|
|
vec3 clearcoatF0;
|
|
float clearcoatF90;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float iridescence;
|
|
float iridescenceIOR;
|
|
float iridescenceThickness;
|
|
vec3 iridescenceFresnel;
|
|
vec3 iridescenceF0;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
vec3 sheenColor;
|
|
float sheenRoughness;
|
|
#endif
|
|
#ifdef IOR
|
|
float ior;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
float transmission;
|
|
float transmissionAlpha;
|
|
float thickness;
|
|
float attenuationDistance;
|
|
vec3 attenuationColor;
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float anisotropy;
|
|
float alphaT;
|
|
vec3 anisotropyT;
|
|
vec3 anisotropyB;
|
|
#endif
|
|
};
|
|
vec3 clearcoatSpecular = vec3( 0.0 );
|
|
vec3 sheenSpecular = vec3( 0.0 );
|
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
float x2 = x * x;
|
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
}
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
float a2 = pow2( alpha );
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|
}
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
float a2 = pow2( alpha );
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
float v = 0.5 / ( gv + gl );
|
|
return saturate(v);
|
|
}
|
|
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
float a2 = alphaT * alphaB;
|
|
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
highp float v2 = dot( v, v );
|
|
float w2 = a2 / v2;
|
|
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
}
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
vec3 f0 = material.clearcoatF0;
|
|
float f90 = material.clearcoatF90;
|
|
float roughness = material.clearcoatRoughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
return F * ( V * D );
|
|
}
|
|
#endif
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
vec3 f0 = material.specularColor;
|
|
float f90 = material.specularF90;
|
|
float roughness = material.roughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
#ifdef USE_IRIDESCENCE
|
|
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float dotTL = dot( material.anisotropyT, lightDir );
|
|
float dotTV = dot( material.anisotropyT, viewDir );
|
|
float dotTH = dot( material.anisotropyT, halfDir );
|
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
#else
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
#endif
|
|
return F * ( V * D );
|
|
}
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
const float LUT_SIZE = 64.0;
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
float dotNV = saturate( dot( N, V ) );
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
return uv;
|
|
}
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
float l = length( f );
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
}
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
float x = dot( v1, v2 );
|
|
float y = abs( x );
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
float v = a / b;
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|
}
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
vec3 lightNormal = cross( v1, v2 );
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
vec3 T1, T2;
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|
T2 = - cross( N, T1 );
|
|
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|
vec3 coords[ 4 ];
|
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
vec3 vectorFormFactor = vec3( 0.0 );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
return vec3( result );
|
|
}
|
|
#if defined( USE_SHEEN )
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|
float alpha = pow2( roughness );
|
|
float invAlpha = 1.0 / alpha;
|
|
float cos2h = dotNH * dotNH;
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
}
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
}
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|
return sheenColor * ( D * V );
|
|
}
|
|
#endif
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float r2 = roughness * roughness;
|
|
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
return saturate( DG * RECIPROCAL_PI );
|
|
}
|
|
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
vec4 r = roughness * c0 + c1;
|
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
return fab;
|
|
}
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
return specularColor * fab.x + specularF90 * fab.y;
|
|
}
|
|
#ifdef USE_IRIDESCENCE
|
|
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#else
|
|
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#endif
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
#ifdef USE_IRIDESCENCE
|
|
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
#else
|
|
vec3 Fr = specularColor;
|
|
#endif
|
|
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
float Ess = fab.x + fab.y;
|
|
float Ems = 1.0 - Ess;
|
|
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
singleScatter += FssEss;
|
|
multiScatter += Fms * Ems;
|
|
}
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometry.normal;
|
|
vec3 viewDir = geometry.viewDir;
|
|
vec3 position = geometry.position;
|
|
vec3 lightPos = rectAreaLight.position;
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
vec3 lightColor = rectAreaLight.color;
|
|
float roughness = material.roughness;
|
|
vec3 rectCoords[ 4 ];
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|
mat3 mInv = mat3(
|
|
vec3( t1.x, 0, t1.y ),
|
|
vec3( 0, 1, 0 ),
|
|
vec3( t1.z, 0, t1.w )
|
|
);
|
|
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
}
|
|
#endif
|
|
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
|
|
#endif
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
#ifdef USE_IRIDESCENCE
|
|
computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
#else
|
|
computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
#endif
|
|
vec3 totalScattering = singleScattering + multiScattering;
|
|
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
}
|
|
#define RE_Direct RE_Direct_Physical
|
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
}`,oA=`
|
|
GeometricContext geometry;
|
|
geometry.position = - vViewPosition;
|
|
geometry.normal = normal;
|
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
#ifdef USE_CLEARCOAT
|
|
geometry.clearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
material.iridescence = 0.0;
|
|
} else {
|
|
material.iridescence = saturate( material.iridescence );
|
|
}
|
|
if ( material.iridescence > 0.0 ) {
|
|
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
}
|
|
#endif
|
|
IncidentLight directLight;
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
PointLight pointLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
pointLight = pointLights[ i ];
|
|
getPointLightInfo( pointLight, geometry, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
pointLightShadow = pointLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
SpotLight spotLight;
|
|
vec4 spotColor;
|
|
vec3 spotLightCoord;
|
|
bool inSpotLightMap;
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
spotLight = spotLights[ i ];
|
|
getSpotLightInfo( spotLight, geometry, directLight );
|
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
#else
|
|
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#endif
|
|
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
#endif
|
|
#undef SPOT_LIGHT_MAP_INDEX
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
DirectionalLight directionalLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
directionalLight = directionalLights[ i ];
|
|
getDirectionalLightInfo( directionalLight, geometry, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
RectAreaLight rectAreaLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
rectAreaLight = rectAreaLights[ i ];
|
|
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,aA=`#if defined( RE_IndirectDiffuse )
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
irradiance += lightMapIrradiance;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
iblIrradiance += getIBLIrradiance( geometry.normal );
|
|
#endif
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
#ifdef USE_ANISOTROPY
|
|
radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
#else
|
|
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
|
|
#endif
|
|
#endif`,cA=`#if defined( RE_IndirectDiffuse )
|
|
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
|
#endif`,lA=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,uA=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,hA=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#else
|
|
uniform float logDepthBufFC;
|
|
#endif
|
|
#endif`,fA=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#else
|
|
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
|
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
|
gl_Position.z *= gl_Position.w;
|
|
}
|
|
#endif
|
|
#endif`,dA=`#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, vMapUv );
|
|
#endif`,pA=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,mA=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
#if defined( USE_POINTS_UV )
|
|
vec2 uv = vUv;
|
|
#else
|
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, uv );
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
#endif`,gA=`#if defined( USE_POINTS_UV )
|
|
varying vec2 vUv;
|
|
#else
|
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,vA=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,_A=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,yA=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
|
|
vColor *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
#if defined( USE_COLOR_ALPHA )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
#elif defined( USE_COLOR )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
#endif
|
|
}
|
|
#endif`,xA=`#ifdef USE_MORPHNORMALS
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
|
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
|
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
|
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
|
#endif
|
|
#endif`,bA=`#ifdef USE_MORPHTARGETS
|
|
uniform float morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
uniform sampler2DArray morphTargetsTexture;
|
|
uniform ivec2 morphTargetsTextureSize;
|
|
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
int y = texelIndex / morphTargetsTextureSize.x;
|
|
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
}
|
|
#else
|
|
#ifndef USE_MORPHNORMALS
|
|
uniform float morphTargetInfluences[ 8 ];
|
|
#else
|
|
uniform float morphTargetInfluences[ 4 ];
|
|
#endif
|
|
#endif
|
|
#endif`,wA=`#ifdef USE_MORPHTARGETS
|
|
transformed *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
|
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
|
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
|
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
|
#ifndef USE_MORPHNORMALS
|
|
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
|
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
|
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
|
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
|
#endif
|
|
#endif
|
|
#endif`,SA=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
#ifdef FLAT_SHADED
|
|
vec3 fdx = dFdx( vViewPosition );
|
|
vec3 fdy = dFdy( vViewPosition );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
#else
|
|
vec3 normal = normalize( vNormal );
|
|
#ifdef DOUBLE_SIDED
|
|
normal *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
#if defined( USE_NORMALMAP )
|
|
vNormalMapUv
|
|
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
vClearcoatNormalMapUv
|
|
#else
|
|
vUv
|
|
#endif
|
|
);
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn[0] *= faceDirection;
|
|
tbn[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn2[0] *= faceDirection;
|
|
tbn2[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
vec3 geometryNormal = normal;`,EA=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
#ifdef FLIP_SIDED
|
|
normal = - normal;
|
|
#endif
|
|
#ifdef DOUBLE_SIDED
|
|
normal = normal * faceDirection;
|
|
#endif
|
|
normal = normalize( normalMatrix * normal );
|
|
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
mapN.xy *= normalScale;
|
|
normal = normalize( tbn * mapN );
|
|
#elif defined( USE_BUMPMAP )
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
#endif`,MA=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,TA=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,AA=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,CA=`#ifdef USE_NORMALMAP
|
|
uniform sampler2D normalMap;
|
|
uniform vec2 normalScale;
|
|
#endif
|
|
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
uniform mat3 normalMatrix;
|
|
#endif
|
|
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
vec3 q0 = dFdx( eye_pos.xyz );
|
|
vec3 q1 = dFdy( eye_pos.xyz );
|
|
vec2 st0 = dFdx( uv.st );
|
|
vec2 st1 = dFdy( uv.st );
|
|
vec3 N = surf_norm;
|
|
vec3 q1perp = cross( q1, N );
|
|
vec3 q0perp = cross( N, q0 );
|
|
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
float det = max( dot( T, T ), dot( B, B ) );
|
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
return mat3( T * scale, B * scale, N );
|
|
}
|
|
#endif`,RA=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = geometryNormal;
|
|
#endif`,PA=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
#endif`,LA=`#ifdef USE_CLEARCOATMAP
|
|
uniform sampler2D clearcoatMap;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform sampler2D clearcoatNormalMap;
|
|
uniform vec2 clearcoatNormalScale;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform sampler2D clearcoatRoughnessMap;
|
|
#endif`,DA=`#ifdef USE_IRIDESCENCEMAP
|
|
uniform sampler2D iridescenceMap;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
#endif`,IA=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,UA=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
return normalize( normal ) * 0.5 + 0.5;
|
|
}
|
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
return 2.0 * rgb.xyz - 1.0;
|
|
}
|
|
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
|
|
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
|
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
|
const float ShiftRight8 = 1. / 256.;
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|
vec4 r = vec4( fract( v * PackFactors ), v );
|
|
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
|
}
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|
return dot( v, UnpackFactors );
|
|
}
|
|
vec2 packDepthToRG( in highp float v ) {
|
|
return packDepthToRGBA( v ).yx;
|
|
}
|
|
float unpackRGToDepth( const in highp vec2 v ) {
|
|
return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
|
|
}
|
|
vec4 pack2HalfToRGBA( vec2 v ) {
|
|
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
}
|
|
vec2 unpackRGBATo2Half( vec4 v ) {
|
|
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
}
|
|
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( viewZ + near ) / ( near - far );
|
|
}
|
|
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return depth * ( near - far ) - near;
|
|
}
|
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
}
|
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
}`,OA=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,NA=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_INSTANCING
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
#endif
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
gl_Position = projectionMatrix * mvPosition;`,FA=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,kA=`#ifdef DITHERING
|
|
vec3 dithering( vec3 color ) {
|
|
float grid_position = rand( gl_FragCoord.xy );
|
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
return color + dither_shift_RGB;
|
|
}
|
|
#endif`,zA=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,BA=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,GA=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|
}
|
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
}
|
|
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|
float occlusion = 1.0;
|
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
float hard_shadow = step( compare , distribution.x );
|
|
if (hard_shadow != 1.0 ) {
|
|
float distance = compare - distribution.x ;
|
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
}
|
|
return occlusion;
|
|
}
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
if ( frustumTest ) {
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx0 = - texelSize.x * shadowRadius;
|
|
float dy0 = - texelSize.y * shadowRadius;
|
|
float dx1 = + texelSize.x * shadowRadius;
|
|
float dy1 = + texelSize.y * shadowRadius;
|
|
float dx2 = dx0 / 2.0;
|
|
float dy2 = dy0 / 2.0;
|
|
float dx3 = dx1 / 2.0;
|
|
float dy3 = dy1 / 2.0;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
) * ( 1.0 / 17.0 );
|
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx = texelSize.x;
|
|
float dy = texelSize.y;
|
|
vec2 uv = shadowCoord.xy;
|
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
uv -= f * texelSize;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
f.x ),
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.x ),
|
|
f.y )
|
|
) * ( 1.0 / 9.0 );
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#else
|
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#endif
|
|
}
|
|
return shadow;
|
|
}
|
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
vec3 absV = abs( v );
|
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
absV *= scaleToCube;
|
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
vec2 planar = v.xy;
|
|
float almostATexel = 1.5 * texelSizeY;
|
|
float almostOne = 1.0 - almostATexel;
|
|
if ( absV.z >= almostOne ) {
|
|
if ( v.z > 0.0 )
|
|
planar.x = 4.0 - v.x;
|
|
} else if ( absV.x >= almostOne ) {
|
|
float signX = sign( v.x );
|
|
planar.x = v.z * signX + 2.0 * signX;
|
|
} else if ( absV.y >= almostOne ) {
|
|
float signY = sign( v.y );
|
|
planar.x = v.x + 2.0 * signY + 2.0;
|
|
planar.y = v.z * signY - 2.0;
|
|
}
|
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
}
|
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
return (
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
) * ( 1.0 / 9.0 );
|
|
#else
|
|
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
#endif
|
|
}
|
|
#endif`,VA=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#endif`,HA=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
vec4 shadowWorldPosition;
|
|
#endif
|
|
#if defined( USE_SHADOWMAP )
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
shadowWorldPosition = worldPosition;
|
|
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
#endif
|
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif`,WA=`float getShadowMask() {
|
|
float shadow = 1.0;
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
directionalLight = directionalLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
spotLight = spotLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
pointLight = pointLightShadows[ i ];
|
|
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
return shadow;
|
|
}`,XA=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,qA=`#ifdef USE_SKINNING
|
|
uniform mat4 bindMatrix;
|
|
uniform mat4 bindMatrixInverse;
|
|
uniform highp sampler2D boneTexture;
|
|
uniform int boneTextureSize;
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
float j = i * 4.0;
|
|
float x = mod( j, float( boneTextureSize ) );
|
|
float y = floor( j / float( boneTextureSize ) );
|
|
float dx = 1.0 / float( boneTextureSize );
|
|
float dy = 1.0 / float( boneTextureSize );
|
|
y = dy * ( y + 0.5 );
|
|
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
|
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
|
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
|
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
|
mat4 bone = mat4( v1, v2, v3, v4 );
|
|
return bone;
|
|
}
|
|
#endif`,YA=`#ifdef USE_SKINNING
|
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
vec4 skinned = vec4( 0.0 );
|
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
#endif`,jA=`#ifdef USE_SKINNING
|
|
mat4 skinMatrix = mat4( 0.0 );
|
|
skinMatrix += skinWeight.x * boneMatX;
|
|
skinMatrix += skinWeight.y * boneMatY;
|
|
skinMatrix += skinWeight.z * boneMatZ;
|
|
skinMatrix += skinWeight.w * boneMatW;
|
|
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
#ifdef USE_TANGENT
|
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#endif
|
|
#endif`,$A=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,ZA=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,KA=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,JA=`#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
uniform float toneMappingExposure;
|
|
vec3 LinearToneMapping( vec3 color ) {
|
|
return saturate( toneMappingExposure * color );
|
|
}
|
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
}
|
|
vec3 OptimizedCineonToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
color = max( vec3( 0.0 ), color - 0.004 );
|
|
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
}
|
|
vec3 RRTAndODTFit( vec3 v ) {
|
|
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
return a / b;
|
|
}
|
|
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
const mat3 ACESInputMat = mat3(
|
|
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
vec3( 0.04823, 0.01566, 0.83777 )
|
|
);
|
|
const mat3 ACESOutputMat = mat3(
|
|
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
vec3( -0.07367, -0.00605, 1.07602 )
|
|
);
|
|
color *= toneMappingExposure / 0.6;
|
|
color = ACESInputMat * color;
|
|
color = RRTAndODTFit( color );
|
|
color = ACESOutputMat * color;
|
|
return saturate( color );
|
|
}
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,QA=`#ifdef USE_TRANSMISSION
|
|
material.transmission = transmission;
|
|
material.transmissionAlpha = 1.0;
|
|
material.thickness = thickness;
|
|
material.attenuationDistance = attenuationDistance;
|
|
material.attenuationColor = attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
#endif
|
|
vec3 pos = vWorldPosition;
|
|
vec3 v = normalize( cameraPosition - pos );
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
|
|
material.attenuationColor, material.attenuationDistance );
|
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
#endif`,e2=`#ifdef USE_TRANSMISSION
|
|
uniform float transmission;
|
|
uniform float thickness;
|
|
uniform float attenuationDistance;
|
|
uniform vec3 attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform sampler2D transmissionMap;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform sampler2D thicknessMap;
|
|
#endif
|
|
uniform vec2 transmissionSamplerSize;
|
|
uniform sampler2D transmissionSamplerMap;
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
varying vec3 vWorldPosition;
|
|
float w0( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
}
|
|
float w1( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
}
|
|
float w2( float a ){
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
}
|
|
float w3( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
}
|
|
float g0( float a ) {
|
|
return w0( a ) + w1( a );
|
|
}
|
|
float g1( float a ) {
|
|
return w2( a ) + w3( a );
|
|
}
|
|
float h0( float a ) {
|
|
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
}
|
|
float h1( float a ) {
|
|
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
}
|
|
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
uv = uv * texelSize.zw + 0.5;
|
|
vec2 iuv = floor( uv );
|
|
vec2 fuv = fract( uv );
|
|
float g0x = g0( fuv.x );
|
|
float g1x = g1( fuv.x );
|
|
float h0x = h0( fuv.x );
|
|
float h1x = h1( fuv.x );
|
|
float h0y = h0( fuv.y );
|
|
float h1y = h1( fuv.y );
|
|
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
}
|
|
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
return mix( fSample, cSample, fract( lod ) );
|
|
}
|
|
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
vec3 modelScale;
|
|
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
return normalize( refractionVector ) * thickness * modelScale;
|
|
}
|
|
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
}
|
|
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
}
|
|
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
if ( isinf( attenuationDistance ) ) {
|
|
return vec3( 1.0 );
|
|
} else {
|
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
}
|
|
}
|
|
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
}
|
|
#endif`,t2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,n2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform mat3 mapTransform;
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform mat3 alphaMapTransform;
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
uniform mat3 lightMapTransform;
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
uniform mat3 aoMapTransform;
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
uniform mat3 bumpMapTransform;
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
uniform mat3 normalMapTransform;
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
uniform mat3 displacementMapTransform;
|
|
varying vec2 vDisplacementMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
uniform mat3 emissiveMapTransform;
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
uniform mat3 metalnessMapTransform;
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
uniform mat3 roughnessMapTransform;
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform mat3 anisotropyMapTransform;
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
uniform mat3 clearcoatMapTransform;
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform mat3 clearcoatNormalMapTransform;
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform mat3 clearcoatRoughnessMapTransform;
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform mat3 sheenColorMapTransform;
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform mat3 sheenRoughnessMapTransform;
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
uniform mat3 iridescenceMapTransform;
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform mat3 iridescenceThicknessMapTransform;
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
uniform mat3 specularMapTransform;
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform mat3 specularColorMapTransform;
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform mat3 specularIntensityMapTransform;
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,i2=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
vUv = vec3( uv, 1 ).xy;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif`,r2=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_INSTANCING
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
#endif
|
|
worldPosition = modelMatrix * worldPosition;
|
|
#endif`;const s2=`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,o2=`uniform sampler2D t2D;
|
|
uniform float backgroundIntensity;
|
|
varying vec2 vUv;
|
|
void main() {
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,a2=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,c2=`#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
uniform float flipEnvMap;
|
|
uniform float backgroundBlurriness;
|
|
uniform float backgroundIntensity;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,l2=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,u2=`uniform samplerCube tCube;
|
|
uniform float tFlip;
|
|
uniform float opacity;
|
|
varying vec3 vWorldDirection;
|
|
void main() {
|
|
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
gl_FragColor = texColor;
|
|
gl_FragColor.a *= opacity;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,h2=`#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,f2=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#endif
|
|
}`,d2=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,p2=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|
}`,m2=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,g2=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,v2=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,_2=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,y2=`#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,x2=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,b2=`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,w2=`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,S2=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,E2=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
vec3 viewDir = normalize( vViewPosition );
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
vec3 y = cross( viewDir, x );
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
#ifdef USE_MATCAP
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
#else
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
#endif
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,M2=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,T2=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,A2=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,C2=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,R2=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,P2=`#define STANDARD
|
|
#ifdef PHYSICAL
|
|
#define IOR
|
|
#define USE_SPECULAR
|
|
#endif
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float roughness;
|
|
uniform float metalness;
|
|
uniform float opacity;
|
|
#ifdef IOR
|
|
uniform float ior;
|
|
#endif
|
|
#ifdef USE_SPECULAR
|
|
uniform float specularIntensity;
|
|
uniform vec3 specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform sampler2D specularColorMap;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform sampler2D specularIntensityMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
uniform float clearcoat;
|
|
uniform float clearcoatRoughness;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
uniform float iridescence;
|
|
uniform float iridescenceIOR;
|
|
uniform float iridescenceThicknessMinimum;
|
|
uniform float iridescenceThicknessMaximum;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
uniform vec3 sheenColor;
|
|
uniform float sheenRoughness;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform sampler2D sheenColorMap;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform sampler2D sheenRoughnessMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
uniform vec2 anisotropyVector;
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform sampler2D anisotropyMap;
|
|
#endif
|
|
#endif
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,L2=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,D2=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,I2=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#ifdef USE_POINTS_UV
|
|
varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
void main() {
|
|
#ifdef USE_POINTS_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,U2=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,O2=`#include <common>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,N2=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,F2=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
vec2 scale;
|
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
#ifndef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
#endif
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,k2=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,Qe={alphahash_fragment:cT,alphahash_pars_fragment:lT,alphamap_fragment:uT,alphamap_pars_fragment:hT,alphatest_fragment:fT,alphatest_pars_fragment:dT,aomap_fragment:pT,aomap_pars_fragment:mT,begin_vertex:gT,beginnormal_vertex:vT,bsdfs:_T,iridescence_fragment:yT,bumpmap_pars_fragment:xT,clipping_planes_fragment:bT,clipping_planes_pars_fragment:wT,clipping_planes_pars_vertex:ST,clipping_planes_vertex:ET,color_fragment:MT,color_pars_fragment:TT,color_pars_vertex:AT,color_vertex:CT,common:RT,cube_uv_reflection_fragment:PT,defaultnormal_vertex:LT,displacementmap_pars_vertex:DT,displacementmap_vertex:IT,emissivemap_fragment:UT,emissivemap_pars_fragment:OT,colorspace_fragment:NT,colorspace_pars_fragment:FT,envmap_fragment:kT,envmap_common_pars_fragment:zT,envmap_pars_fragment:BT,envmap_pars_vertex:GT,envmap_physical_pars_fragment:QT,envmap_vertex:VT,fog_vertex:HT,fog_pars_vertex:WT,fog_fragment:XT,fog_pars_fragment:qT,gradientmap_pars_fragment:YT,lightmap_fragment:jT,lightmap_pars_fragment:$T,lights_lambert_fragment:ZT,lights_lambert_pars_fragment:KT,lights_pars_begin:JT,lights_toon_fragment:eA,lights_toon_pars_fragment:tA,lights_phong_fragment:nA,lights_phong_pars_fragment:iA,lights_physical_fragment:rA,lights_physical_pars_fragment:sA,lights_fragment_begin:oA,lights_fragment_maps:aA,lights_fragment_end:cA,logdepthbuf_fragment:lA,logdepthbuf_pars_fragment:uA,logdepthbuf_pars_vertex:hA,logdepthbuf_vertex:fA,map_fragment:dA,map_pars_fragment:pA,map_particle_fragment:mA,map_particle_pars_fragment:gA,metalnessmap_fragment:vA,metalnessmap_pars_fragment:_A,morphcolor_vertex:yA,morphnormal_vertex:xA,morphtarget_pars_vertex:bA,morphtarget_vertex:wA,normal_fragment_begin:SA,normal_fragment_maps:EA,normal_pars_fragment:MA,normal_pars_vertex:TA,normal_vertex:AA,normalmap_pars_fragment:CA,clearcoat_normal_fragment_begin:RA,clearcoat_normal_fragment_maps:PA,clearcoat_pars_fragment:LA,iridescence_pars_fragment:DA,opaque_fragment:IA,packing:UA,premultiplied_alpha_fragment:OA,project_vertex:NA,dithering_fragment:FA,dithering_pars_fragment:kA,roughnessmap_fragment:zA,roughnessmap_pars_fragment:BA,shadowmap_pars_fragment:GA,shadowmap_pars_vertex:VA,shadowmap_vertex:HA,shadowmask_pars_fragment:WA,skinbase_vertex:XA,skinning_pars_vertex:qA,skinning_vertex:YA,skinnormal_vertex:jA,specularmap_fragment:$A,specularmap_pars_fragment:ZA,tonemapping_fragment:KA,tonemapping_pars_fragment:JA,transmission_fragment:QA,transmission_pars_fragment:e2,uv_pars_fragment:t2,uv_pars_vertex:n2,uv_vertex:i2,worldpos_vertex:r2,background_vert:s2,background_frag:o2,backgroundCube_vert:a2,backgroundCube_frag:c2,cube_vert:l2,cube_frag:u2,depth_vert:h2,depth_frag:f2,distanceRGBA_vert:d2,distanceRGBA_frag:p2,equirect_vert:m2,equirect_frag:g2,linedashed_vert:v2,linedashed_frag:_2,meshbasic_vert:y2,meshbasic_frag:x2,meshlambert_vert:b2,meshlambert_frag:w2,meshmatcap_vert:S2,meshmatcap_frag:E2,meshnormal_vert:M2,meshnormal_frag:T2,meshphong_vert:A2,meshphong_frag:C2,meshphysical_vert:R2,meshphysical_frag:P2,meshtoon_vert:L2,meshtoon_frag:D2,points_vert:I2,points_frag:U2,shadow_vert:O2,shadow_frag:N2,sprite_vert:F2,sprite_frag:k2},ke={common:{diffuse:{value:new Ne(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new rt},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new rt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new rt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new rt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new rt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new rt},normalScale:{value:new be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new rt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new rt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new rt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new rt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ne(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ne(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0},uvTransform:{value:new rt}},sprite:{diffuse:{value:new Ne(16777215)},opacity:{value:1},center:{value:new be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new rt},alphaMap:{value:null},alphaMapTransform:{value:new rt},alphaTest:{value:0}}},gi={basic:{uniforms:bn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.fog]),vertexShader:Qe.meshbasic_vert,fragmentShader:Qe.meshbasic_frag},lambert:{uniforms:bn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,ke.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Qe.meshlambert_vert,fragmentShader:Qe.meshlambert_frag},phong:{uniforms:bn([ke.common,ke.specularmap,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,ke.lights,{emissive:{value:new Ne(0)},specular:{value:new Ne(1118481)},shininess:{value:30}}]),vertexShader:Qe.meshphong_vert,fragmentShader:Qe.meshphong_frag},standard:{uniforms:bn([ke.common,ke.envmap,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.roughnessmap,ke.metalnessmap,ke.fog,ke.lights,{emissive:{value:new Ne(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qe.meshphysical_vert,fragmentShader:Qe.meshphysical_frag},toon:{uniforms:bn([ke.common,ke.aomap,ke.lightmap,ke.emissivemap,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.gradientmap,ke.fog,ke.lights,{emissive:{value:new Ne(0)}}]),vertexShader:Qe.meshtoon_vert,fragmentShader:Qe.meshtoon_frag},matcap:{uniforms:bn([ke.common,ke.bumpmap,ke.normalmap,ke.displacementmap,ke.fog,{matcap:{value:null}}]),vertexShader:Qe.meshmatcap_vert,fragmentShader:Qe.meshmatcap_frag},points:{uniforms:bn([ke.points,ke.fog]),vertexShader:Qe.points_vert,fragmentShader:Qe.points_frag},dashed:{uniforms:bn([ke.common,ke.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qe.linedashed_vert,fragmentShader:Qe.linedashed_frag},depth:{uniforms:bn([ke.common,ke.displacementmap]),vertexShader:Qe.depth_vert,fragmentShader:Qe.depth_frag},normal:{uniforms:bn([ke.common,ke.bumpmap,ke.normalmap,ke.displacementmap,{opacity:{value:1}}]),vertexShader:Qe.meshnormal_vert,fragmentShader:Qe.meshnormal_frag},sprite:{uniforms:bn([ke.sprite,ke.fog]),vertexShader:Qe.sprite_vert,fragmentShader:Qe.sprite_frag},background:{uniforms:{uvTransform:{value:new rt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qe.background_vert,fragmentShader:Qe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Qe.backgroundCube_vert,fragmentShader:Qe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qe.cube_vert,fragmentShader:Qe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qe.equirect_vert,fragmentShader:Qe.equirect_frag},distanceRGBA:{uniforms:bn([ke.common,ke.displacementmap,{referencePosition:{value:new G},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qe.distanceRGBA_vert,fragmentShader:Qe.distanceRGBA_frag},shadow:{uniforms:bn([ke.lights,ke.fog,{color:{value:new Ne(0)},opacity:{value:1}}]),vertexShader:Qe.shadow_vert,fragmentShader:Qe.shadow_frag}};gi.physical={uniforms:bn([gi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new rt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new rt},clearcoatNormalScale:{value:new be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new rt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new rt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new rt},sheen:{value:0},sheenColor:{value:new Ne(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new rt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new rt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new rt},transmissionSamplerSize:{value:new be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new rt},attenuationDistance:{value:0},attenuationColor:{value:new Ne(0)},specularColor:{value:new Ne(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new rt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new rt},anisotropyVector:{value:new be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new rt}}]),vertexShader:Qe.meshphysical_vert,fragmentShader:Qe.meshphysical_frag};const bl={r:0,b:0,g:0};function z2(r,e,t,n,i,s,o){const a=new Ne(0);let c=s===!0?0:1,l,u,h=null,f=0,d=null;function m(g,p){let _=!1,y=p.isScene===!0?p.background:null;switch(y&&y.isTexture&&(y=(p.backgroundBlurriness>0?t:e).get(y)),y===null?v(a,c):y&&y.isColor&&(v(y,1),_=!0),r.xr.getEnvironmentBlendMode()){case"opaque":_=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,o),_=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,o),_=!0;break}(r.autoClear||_)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),y&&(y.isCubeTexture||y.mapping===Oo)?(u===void 0&&(u=new Ot(new lr(1,1,1),new Ni({name:"BackgroundCubeMaterial",uniforms:Ro(gi.backgroundCube.uniforms),vertexShader:gi.backgroundCube.vertexShader,fragmentShader:gi.backgroundCube.fragmentShader,side:vn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(w,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=y,u.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=p.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,u.material.toneMapped=y.colorSpace!==et,(h!==y||f!==y.version||d!==r.toneMapping)&&(u.material.needsUpdate=!0,h=y,f=y.version,d=r.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Ot(new Nr(2,2),new Ni({name:"BackgroundMaterial",uniforms:Ro(gi.background.uniforms),vertexShader:gi.background.vertexShader,fragmentShader:gi.background.fragmentShader,side:Oi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=p.backgroundIntensity,l.material.toneMapped=y.colorSpace!==et,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(h!==y||f!==y.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=y,f=y.version,d=r.toneMapping),l.layers.enableAll(),g.unshift(l,l.geometry,l.material,0,0,null))}function v(g,p){g.getRGB(bl,Yx(r)),n.buffers.color.setClear(bl.r,bl.g,bl.b,p,o)}return{getClearColor:function(){return a},setClearColor:function(g,p=1){a.set(g),c=p,v(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,v(a,c)},render:m}}function B2(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},c=g(null);let l=c,u=!1;function h(z,V,N,C,O){let k=!1;if(o){const U=v(C,N,V);l!==U&&(l=U,d(l.object)),k=p(z,C,N,O),k&&_(z,C,N,O)}else{const U=V.wireframe===!0;(l.geometry!==C.id||l.program!==N.id||l.wireframe!==U)&&(l.geometry=C.id,l.program=N.id,l.wireframe=U,k=!0)}O!==null&&t.update(O,r.ELEMENT_ARRAY_BUFFER),(k||u)&&(u=!1,M(z,V,N,C),O!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function f(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(z){return n.isWebGL2?r.bindVertexArray(z):s.bindVertexArrayOES(z)}function m(z){return n.isWebGL2?r.deleteVertexArray(z):s.deleteVertexArrayOES(z)}function v(z,V,N){const C=N.wireframe===!0;let O=a[z.id];O===void 0&&(O={},a[z.id]=O);let k=O[V.id];k===void 0&&(k={},O[V.id]=k);let U=k[C];return U===void 0&&(U=g(f()),k[C]=U),U}function g(z){const V=[],N=[],C=[];for(let O=0;O<i;O++)V[O]=0,N[O]=0,C[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:N,attributeDivisors:C,object:z,attributes:{},index:null}}function p(z,V,N,C){const O=l.attributes,k=V.attributes;let U=0;const R=N.getAttributes();for(const F in R)if(R[F].location>=0){const Y=O[F];let J=k[F];if(J===void 0&&(F==="instanceMatrix"&&z.instanceMatrix&&(J=z.instanceMatrix),F==="instanceColor"&&z.instanceColor&&(J=z.instanceColor)),Y===void 0||Y.attribute!==J||J&&Y.data!==J.data)return!0;U++}return l.attributesNum!==U||l.index!==C}function _(z,V,N,C){const O={},k=V.attributes;let U=0;const R=N.getAttributes();for(const F in R)if(R[F].location>=0){let Y=k[F];Y===void 0&&(F==="instanceMatrix"&&z.instanceMatrix&&(Y=z.instanceMatrix),F==="instanceColor"&&z.instanceColor&&(Y=z.instanceColor));const J={};J.attribute=Y,Y&&Y.data&&(J.data=Y.data),O[F]=J,U++}l.attributes=O,l.attributesNum=U,l.index=C}function y(){const z=l.newAttributes;for(let V=0,N=z.length;V<N;V++)z[V]=0}function x(z){b(z,0)}function b(z,V){const N=l.newAttributes,C=l.enabledAttributes,O=l.attributeDivisors;N[z]=1,C[z]===0&&(r.enableVertexAttribArray(z),C[z]=1),O[z]!==V&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](z,V),O[z]=V)}function w(){const z=l.newAttributes,V=l.enabledAttributes;for(let N=0,C=V.length;N<C;N++)V[N]!==z[N]&&(r.disableVertexAttribArray(N),V[N]=0)}function S(z,V,N,C,O,k,U){U===!0?r.vertexAttribIPointer(z,V,N,O,k):r.vertexAttribPointer(z,V,N,C,O,k)}function M(z,V,N,C){if(n.isWebGL2===!1&&(z.isInstancedMesh||C.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;y();const O=C.attributes,k=N.getAttributes(),U=V.defaultAttributeValues;for(const R in k){const F=k[R];if(F.location>=0){let H=O[R];if(H===void 0&&(R==="instanceMatrix"&&z.instanceMatrix&&(H=z.instanceMatrix),R==="instanceColor"&&z.instanceColor&&(H=z.instanceColor)),H!==void 0){const Y=H.normalized,J=H.itemSize,ie=t.get(H);if(ie===void 0)continue;const ne=ie.buffer,ee=ie.type,ge=ie.bytesPerElement,me=n.isWebGL2===!0&&(ee===r.INT||ee===r.UNSIGNED_INT||H.gpuType===qp);if(H.isInterleavedBufferAttribute){const te=H.data,D=te.stride,Q=H.offset;if(te.isInstancedInterleavedBuffer){for(let j=0;j<F.locationSize;j++)b(F.location+j,te.meshPerAttribute);z.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let j=0;j<F.locationSize;j++)x(F.location+j);r.bindBuffer(r.ARRAY_BUFFER,ne);for(let j=0;j<F.locationSize;j++)S(F.location+j,J/F.locationSize,ee,Y,D*ge,(Q+J/F.locationSize*j)*ge,me)}else{if(H.isInstancedBufferAttribute){for(let te=0;te<F.locationSize;te++)b(F.location+te,H.meshPerAttribute);z.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=H.meshPerAttribute*H.count)}else for(let te=0;te<F.locationSize;te++)x(F.location+te);r.bindBuffer(r.ARRAY_BUFFER,ne);for(let te=0;te<F.locationSize;te++)S(F.location+te,J/F.locationSize,ee,Y,J*ge,J/F.locationSize*te*ge,me)}}else if(U!==void 0){const Y=U[R];if(Y!==void 0)switch(Y.length){case 2:r.vertexAttrib2fv(F.location,Y);break;case 3:r.vertexAttrib3fv(F.location,Y);break;case 4:r.vertexAttrib4fv(F.location,Y);break;default:r.vertexAttrib1fv(F.location,Y)}}}}w()}function E(){P();for(const z in a){const V=a[z];for(const N in V){const C=V[N];for(const O in C)m(C[O].object),delete C[O];delete V[N]}delete a[z]}}function T(z){if(a[z.id]===void 0)return;const V=a[z.id];for(const N in V){const C=V[N];for(const O in C)m(C[O].object),delete C[O];delete V[N]}delete a[z.id]}function L(z){for(const V in a){const N=a[V];if(N[z.id]===void 0)continue;const C=N[z.id];for(const O in C)m(C[O].object),delete C[O];delete N[z.id]}}function P(){A(),u=!0,l!==c&&(l=c,d(l.object))}function A(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:P,resetDefaultState:A,dispose:E,releaseStatesOfGeometry:T,releaseStatesOfProgram:L,initAttributes:y,enableAttribute:x,disableUnusedAttributes:w}}function G2(r,e,t,n){const i=n.isWebGL2;let s;function o(l){s=l}function a(l,u){r.drawArrays(s,l,u),t.update(u,s,1)}function c(l,u,h){if(h===0)return;let f,d;if(i)f=r,d="drawArraysInstanced";else if(f=e.get("ANGLE_instanced_arrays"),d="drawArraysInstancedANGLE",f===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[d](s,l,u,h),t.update(u,s,h)}this.setMode=o,this.render=a,this.renderInstances=c}function V2(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const S=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(S){if(S==="highp"){if(r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.HIGH_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";S="mediump"}return S==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const c=s(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);const l=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=r.getParameter(r.MAX_TEXTURE_SIZE),m=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),v=r.getParameter(r.MAX_VERTEX_ATTRIBS),g=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),p=r.getParameter(r.MAX_VARYING_VECTORS),_=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,x=o||e.has("OES_texture_float"),b=y&&x,w=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:m,maxAttributes:v,maxVertexUniforms:g,maxVaryings:p,maxFragmentUniforms:_,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:b,maxSamples:w}}function H2(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new Qi,a=new rt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){const d=h.length!==0||f||n!==0||i;return i=f,n=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){t=u(h,f,0)},this.setState=function(h,f,d){const m=h.clippingPlanes,v=h.clipIntersection,g=h.clipShadows,p=r.get(h);if(!i||m===null||m.length===0||s&&!g)s?u(null):l();else{const _=s?0:n,y=_*4;let x=p.clippingState||null;c.value=x,x=u(m,f,y,d);for(let b=0;b!==y;++b)x[b]=t[b];p.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,m){const v=h!==null?h.length:0;let g=null;if(v!==0){if(g=c.value,m!==!0||g===null){const p=d+v*4,_=f.matrixWorldInverse;a.getNormalMatrix(_),(g===null||g.length<p)&&(g=new Float32Array(p));for(let y=0,x=d;y!==v;++y,x+=4)o.copy(h[y]).applyMatrix4(_,a),o.normal.toArray(g,x),g[x+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function W2(r){let e=new WeakMap;function t(o,a){return a===Ka?o.mapping=Pr:a===Ja&&(o.mapping=Lr),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){const a=o.mapping;if(a===Ka||a===Ja)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new $x(c.height/2);return l.fromEquirectangularTexture(r,o),e.set(o,l),o.addEventListener("dispose",i),t(l.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class Ms extends Pc{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const _o=4,y0=[.125,.215,.35,.446,.526,.582],is=20,gf=new Ms,x0=new Ne;let vf=null;const es=(1+Math.sqrt(5))/2,eo=1/es,b0=[new G(1,1,1),new G(-1,1,1),new G(1,1,-1),new G(-1,1,-1),new G(0,es,eo),new G(0,es,-eo),new G(eo,0,es),new G(-eo,0,es),new G(es,eo,0),new G(-es,eo,0)];class up{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){vf=this._renderer.getRenderTarget(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=E0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=S0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(vf),e.scissorTest=!1,wl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Pr||e.mapping===Lr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),vf=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Pt,minFilter:Pt,generateMipmaps:!1,type:Ao,format:Ln,colorSpace:xi,depthBuffer:!1},i=w0(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=w0(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=X2(s)),this._blurMaterial=q2(s,e,t)}return i}_compileMaterial(e){const t=new Ot(this._lodPlanes[0],e);this._renderer.compile(t,gf)}_sceneToCubeUV(e,t,n,i){const a=new Zt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,f=u.toneMapping;u.getClearColor(x0),u.toneMapping=yi,u.autoClear=!1;const d=new cr({name:"PMREM.Background",side:vn,depthWrite:!1,depthTest:!1}),m=new Ot(new lr,d);let v=!1;const g=e.background;g?g.isColor&&(d.color.copy(g),e.background=null,v=!0):(d.color.copy(x0),v=!0);for(let p=0;p<6;p++){const _=p%3;_===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):_===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));const y=this._cubeSize;wl(i,_*y,p>2?y:0,y,y),u.setRenderTarget(i),v&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=f,u.autoClear=h,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Pr||e.mapping===Lr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=E0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=S0());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Ot(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const c=this._cubeSize;wl(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,gf)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=b0[(i-1)%b0.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new Ot(this._lodPlanes[i],l),f=l.uniforms,d=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*is-1),v=s/m,g=isFinite(s)?1+Math.floor(u*v):is;g>is&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${is}`);const p=[];let _=0;for(let S=0;S<is;++S){const M=S/v,E=Math.exp(-M*M/2);p.push(E),S===0?_+=E:S<g&&(_+=2*E)}for(let S=0;S<p.length;S++)p[S]=p[S]/_;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=p,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:y}=this;f.dTheta.value=m,f.mipInt.value=y-n;const x=this._sizeLods[i],b=3*x*(i>y-_o?i-y+_o:0),w=4*(this._cubeSize-x);wl(t,b,w,3*x,2*x),c.setRenderTarget(t),c.render(h,gf)}}function X2(r){const e=[],t=[],n=[];let i=r;const s=r-_o+1+y0.length;for(let o=0;o<s;o++){const a=Math.pow(2,i);t.push(a);let c=1/a;o>r-_o?c=y0[o-r+_o-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],d=6,m=6,v=3,g=2,p=1,_=new Float32Array(v*m*d),y=new Float32Array(g*m*d),x=new Float32Array(p*m*d);for(let w=0;w<d;w++){const S=w%3*2/3-1,M=w>2?0:-1,E=[S,M,0,S+2/3,M,0,S+2/3,M+1,0,S,M,0,S+2/3,M+1,0,S,M+1,0];_.set(E,v*m*w),y.set(f,g*m*w);const T=[w,w,w,w,w,w];x.set(T,p*m*w)}const b=new st;b.setAttribute("position",new wt(_,v)),b.setAttribute("uv",new wt(y,g)),b.setAttribute("faceIndex",new wt(x,p)),e.push(b),i>_o&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function w0(r,e,t){const n=new bi(r,e,t);return n.texture.mapping=Oo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function wl(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function q2(r,e,t){const n=new Float32Array(is),i=new G(0,1,0);return new Ni({name:"SphericalGaussianBlur",defines:{n:is,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:cm(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform int samples;
|
|
uniform float weights[ n ];
|
|
uniform bool latitudinal;
|
|
uniform float dTheta;
|
|
uniform float mipInt;
|
|
uniform vec3 poleAxis;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
vec3 getSample( float theta, vec3 axis ) {
|
|
|
|
float cosTheta = cos( theta );
|
|
// Rodrigues' axis-angle rotation
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
|
|
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
|
|
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
|
|
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
|
|
}
|
|
|
|
axis = normalize( axis );
|
|
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
|
|
for ( int i = 1; i < n; i++ ) {
|
|
|
|
if ( i >= samples ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
float theta = dTheta * float( i );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
|
|
}
|
|
|
|
}
|
|
`,blending:nr,depthTest:!1,depthWrite:!1})}function S0(){return new Ni({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cm(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
|
|
}
|
|
`,blending:nr,depthTest:!1,depthWrite:!1})}function E0(){return new Ni({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cm(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
uniform float flipEnvMap;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform samplerCube envMap;
|
|
|
|
void main() {
|
|
|
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
|
|
}
|
|
`,blending:nr,depthTest:!1,depthWrite:!1})}function cm(){return`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
attribute float faceIndex;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
// RH coordinate system; PMREM face-indexing convention
|
|
vec3 getDirection( vec2 uv, float face ) {
|
|
|
|
uv = 2.0 * uv - 1.0;
|
|
|
|
vec3 direction = vec3( uv, 1.0 );
|
|
|
|
if ( face == 0.0 ) {
|
|
|
|
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
|
|
} else if ( face == 1.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
|
|
} else if ( face == 2.0 ) {
|
|
|
|
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
|
|
} else if ( face == 3.0 ) {
|
|
|
|
direction = direction.zyx;
|
|
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
|
|
} else if ( face == 4.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
|
|
} else if ( face == 5.0 ) {
|
|
|
|
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vOutputDirection = getDirection( uv, faceIndex );
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}
|
|
`}function Y2(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===Ka||c===Ja,u=c===Pr||c===Lr;if(l||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new up(r)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{const h=a.image;if(l&&h&&h.height>0||u&&h&&i(h)){t===null&&(t=new up(r));const f=l?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),a.addEventListener("dispose",s),f.texture}else return null}}}return a}function i(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){const c=a.target;c.removeEventListener("dispose",s);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function j2(r){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function $2(r,e,t,n){const i={},s=new WeakMap;function o(h){const f=h.target;f.index!==null&&e.remove(f.index);for(const m in f.attributes)e.remove(f.attributes[m]);for(const m in f.morphAttributes){const v=f.morphAttributes[m];for(let g=0,p=v.length;g<p;g++)e.remove(v[g])}f.removeEventListener("dispose",o),delete i[f.id];const d=s.get(f);d&&(e.remove(d),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,t.memory.geometries++),f}function c(h){const f=h.attributes;for(const m in f)e.update(f[m],r.ARRAY_BUFFER);const d=h.morphAttributes;for(const m in d){const v=d[m];for(let g=0,p=v.length;g<p;g++)e.update(v[g],r.ARRAY_BUFFER)}}function l(h){const f=[],d=h.index,m=h.attributes.position;let v=0;if(d!==null){const _=d.array;v=d.version;for(let y=0,x=_.length;y<x;y+=3){const b=_[y+0],w=_[y+1],S=_[y+2];f.push(b,w,w,S,S,b)}}else{const _=m.array;v=m.version;for(let y=0,x=_.length/3-1;y<x;y+=3){const b=y+0,w=y+1,S=y+2;f.push(b,w,w,S,S,b)}}const g=new(Xx(f)?om:sm)(f,1);g.version=v;const p=s.get(h);p&&e.remove(p),s.set(h,g)}function u(h){const f=s.get(h);if(f){const d=h.index;d!==null&&f.version<d.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function Z2(r,e,t,n){const i=n.isWebGL2;let s;function o(f){s=f}let a,c;function l(f){a=f.type,c=f.bytesPerElement}function u(f,d){r.drawElements(s,d,a,f*c),t.update(d,s,1)}function h(f,d,m){if(m===0)return;let v,g;if(i)v=r,g="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[g](s,d,a,f*c,m),t.update(d,s,m)}this.setMode=o,this.setIndex=l,this.render=u,this.renderInstances=h}function K2(r){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case r.TRIANGLES:t.triangles+=a*(s/3);break;case r.LINES:t.lines+=a*(s/2);break;case r.LINE_STRIP:t.lines+=a*(s-1);break;case r.LINE_LOOP:t.lines+=a*s;break;case r.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function J2(r,e){return r[0]-e[0]}function Q2(r,e){return Math.abs(e[1])-Math.abs(r[1])}function eC(r,e,t){const n={},i=new Float32Array(8),s=new WeakMap,o=new mt,a=[];for(let l=0;l<8;l++)a[l]=[l,0];function c(l,u,h){const f=l.morphTargetInfluences;if(e.isWebGL2===!0){const d=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,m=d!==void 0?d.length:0;let v=s.get(u);if(v===void 0||v.count!==m){let z=function(){P.dispose(),s.delete(u),u.removeEventListener("dispose",z)};v!==void 0&&v.texture.dispose();const _=u.morphAttributes.position!==void 0,y=u.morphAttributes.normal!==void 0,x=u.morphAttributes.color!==void 0,b=u.morphAttributes.position||[],w=u.morphAttributes.normal||[],S=u.morphAttributes.color||[];let M=0;_===!0&&(M=1),y===!0&&(M=2),x===!0&&(M=3);let E=u.attributes.position.count*M,T=1;E>e.maxTextureSize&&(T=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const L=new Float32Array(E*T*4*m),P=new ku(L,E,T,m);P.type=Li,P.needsUpdate=!0;const A=M*4;for(let V=0;V<m;V++){const N=b[V],C=w[V],O=S[V],k=E*T*4*V;for(let U=0;U<N.count;U++){const R=U*A;_===!0&&(o.fromBufferAttribute(N,U),L[k+R+0]=o.x,L[k+R+1]=o.y,L[k+R+2]=o.z,L[k+R+3]=0),y===!0&&(o.fromBufferAttribute(C,U),L[k+R+4]=o.x,L[k+R+5]=o.y,L[k+R+6]=o.z,L[k+R+7]=0),x===!0&&(o.fromBufferAttribute(O,U),L[k+R+8]=o.x,L[k+R+9]=o.y,L[k+R+10]=o.z,L[k+R+11]=O.itemSize===4?o.w:1)}}v={count:m,texture:P,size:new be(E,T)},s.set(u,v),u.addEventListener("dispose",z)}let g=0;for(let _=0;_<f.length;_++)g+=f[_];const p=u.morphTargetsRelative?1:1-g;h.getUniforms().setValue(r,"morphTargetBaseInfluence",p),h.getUniforms().setValue(r,"morphTargetInfluences",f),h.getUniforms().setValue(r,"morphTargetsTexture",v.texture,t),h.getUniforms().setValue(r,"morphTargetsTextureSize",v.size)}else{const d=f===void 0?0:f.length;let m=n[u.id];if(m===void 0||m.length!==d){m=[];for(let y=0;y<d;y++)m[y]=[y,0];n[u.id]=m}for(let y=0;y<d;y++){const x=m[y];x[0]=y,x[1]=f[y]}m.sort(Q2);for(let y=0;y<8;y++)y<d&&m[y][1]?(a[y][0]=m[y][0],a[y][1]=m[y][1]):(a[y][0]=Number.MAX_SAFE_INTEGER,a[y][1]=0);a.sort(J2);const v=u.morphAttributes.position,g=u.morphAttributes.normal;let p=0;for(let y=0;y<8;y++){const x=a[y],b=x[0],w=x[1];b!==Number.MAX_SAFE_INTEGER&&w?(v&&u.getAttribute("morphTarget"+y)!==v[b]&&u.setAttribute("morphTarget"+y,v[b]),g&&u.getAttribute("morphNormal"+y)!==g[b]&&u.setAttribute("morphNormal"+y,g[b]),i[y]=w,p+=w):(v&&u.hasAttribute("morphTarget"+y)===!0&&u.deleteAttribute("morphTarget"+y),g&&u.hasAttribute("morphNormal"+y)===!0&&u.deleteAttribute("morphNormal"+y),i[y]=0)}const _=u.morphTargetsRelative?1:1-p;h.getUniforms().setValue(r,"morphTargetBaseInfluence",_),h.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:c}}function tC(r,e,t,n){let i=new WeakMap;function s(c){const l=n.render.frame,u=c.geometry,h=e.get(c,u);if(i.get(h)!==l&&(e.update(h),i.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(t.update(c.instanceMatrix,r.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,r.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){const f=c.skeleton;i.get(f)!==l&&(f.update(),i.set(f,l))}return h}function o(){i=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}const Kx=new Ft,Jx=new ku,Qx=new rm,eb=new Lc,M0=[],T0=[],A0=new Float32Array(16),C0=new Float32Array(9),R0=new Float32Array(4);function Fo(r,e,t){const n=r[0];if(n<=0||n>0)return r;const i=e*t;let s=M0[i];if(s===void 0&&(s=new Float32Array(i),M0[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Qt(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function en(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function Bu(r,e){let t=T0[e];t===void 0&&(t=new Int32Array(e),T0[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function nC(r,e){const t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function iC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Qt(t,e))return;r.uniform2fv(this.addr,e),en(t,e)}}function rC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Qt(t,e))return;r.uniform3fv(this.addr,e),en(t,e)}}function sC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Qt(t,e))return;r.uniform4fv(this.addr,e),en(t,e)}}function oC(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Qt(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),en(t,e)}else{if(Qt(t,n))return;R0.set(n),r.uniformMatrix2fv(this.addr,!1,R0),en(t,n)}}function aC(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Qt(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),en(t,e)}else{if(Qt(t,n))return;C0.set(n),r.uniformMatrix3fv(this.addr,!1,C0),en(t,n)}}function cC(r,e){const t=this.cache,n=e.elements;if(n===void 0){if(Qt(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),en(t,e)}else{if(Qt(t,n))return;A0.set(n),r.uniformMatrix4fv(this.addr,!1,A0),en(t,n)}}function lC(r,e){const t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function uC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Qt(t,e))return;r.uniform2iv(this.addr,e),en(t,e)}}function hC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Qt(t,e))return;r.uniform3iv(this.addr,e),en(t,e)}}function fC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Qt(t,e))return;r.uniform4iv(this.addr,e),en(t,e)}}function dC(r,e){const t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function pC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Qt(t,e))return;r.uniform2uiv(this.addr,e),en(t,e)}}function mC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Qt(t,e))return;r.uniform3uiv(this.addr,e),en(t,e)}}function gC(r,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Qt(t,e))return;r.uniform4uiv(this.addr,e),en(t,e)}}function vC(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||Kx,i)}function _C(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Qx,i)}function yC(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||eb,i)}function xC(r,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Jx,i)}function bC(r){switch(r){case 5126:return nC;case 35664:return iC;case 35665:return rC;case 35666:return sC;case 35674:return oC;case 35675:return aC;case 35676:return cC;case 5124:case 35670:return lC;case 35667:case 35671:return uC;case 35668:case 35672:return hC;case 35669:case 35673:return fC;case 5125:return dC;case 36294:return pC;case 36295:return mC;case 36296:return gC;case 35678:case 36198:case 36298:case 36306:case 35682:return vC;case 35679:case 36299:case 36307:return _C;case 35680:case 36300:case 36308:case 36293:return yC;case 36289:case 36303:case 36311:case 36292:return xC}}function wC(r,e){r.uniform1fv(this.addr,e)}function SC(r,e){const t=Fo(e,this.size,2);r.uniform2fv(this.addr,t)}function EC(r,e){const t=Fo(e,this.size,3);r.uniform3fv(this.addr,t)}function MC(r,e){const t=Fo(e,this.size,4);r.uniform4fv(this.addr,t)}function TC(r,e){const t=Fo(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function AC(r,e){const t=Fo(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function CC(r,e){const t=Fo(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function RC(r,e){r.uniform1iv(this.addr,e)}function PC(r,e){r.uniform2iv(this.addr,e)}function LC(r,e){r.uniform3iv(this.addr,e)}function DC(r,e){r.uniform4iv(this.addr,e)}function IC(r,e){r.uniform1uiv(this.addr,e)}function UC(r,e){r.uniform2uiv(this.addr,e)}function OC(r,e){r.uniform3uiv(this.addr,e)}function NC(r,e){r.uniform4uiv(this.addr,e)}function FC(r,e,t){const n=this.cache,i=e.length,s=Bu(t,i);Qt(n,s)||(r.uniform1iv(this.addr,s),en(n,s));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Kx,s[o])}function kC(r,e,t){const n=this.cache,i=e.length,s=Bu(t,i);Qt(n,s)||(r.uniform1iv(this.addr,s),en(n,s));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Qx,s[o])}function zC(r,e,t){const n=this.cache,i=e.length,s=Bu(t,i);Qt(n,s)||(r.uniform1iv(this.addr,s),en(n,s));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||eb,s[o])}function BC(r,e,t){const n=this.cache,i=e.length,s=Bu(t,i);Qt(n,s)||(r.uniform1iv(this.addr,s),en(n,s));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||Jx,s[o])}function GC(r){switch(r){case 5126:return wC;case 35664:return SC;case 35665:return EC;case 35666:return MC;case 35674:return TC;case 35675:return AC;case 35676:return CC;case 5124:case 35670:return RC;case 35667:case 35671:return PC;case 35668:case 35672:return LC;case 35669:case 35673:return DC;case 5125:return IC;case 36294:return UC;case 36295:return OC;case 36296:return NC;case 35678:case 36198:case 36298:case 36306:case 35682:return FC;case 35679:case 36299:case 36307:return kC;case 35680:case 36300:case 36308:case 36293:return zC;case 36289:case 36303:case 36311:case 36292:return BC}}class VC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=bC(t.type)}}class HC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=GC(t.type)}}class WC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let s=0,o=i.length;s!==o;++s){const a=i[s];a.setValue(e,t[a.id],n)}}}const _f=/(\w+)(\])?(\[|\.)?/g;function P0(r,e){r.seq.push(e),r.map[e.id]=e}function XC(r,e,t){const n=r.name,i=n.length;for(_f.lastIndex=0;;){const s=_f.exec(n),o=_f.lastIndex;let a=s[1];const c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){P0(t,l===void 0?new VC(a,r,e):new HC(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new WC(a),P0(t,h)),t=h}}}class uu{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);XC(s,o,this)}}setValue(e,t,n,i){const s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){const a=t[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,s=e.length;i!==s;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function L0(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}let qC=0;function YC(r,e){const t=r.split(`
|
|
`),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=i;o<s;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
`)}function jC(r){switch(r){case xi:return["Linear","( value )"];case et:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),["Linear","( value )"]}}function D0(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return t.toUpperCase()+`
|
|
|
|
`+i+`
|
|
|
|
`+YC(r.getShaderSource(e),o)}else return i}function $C(r,e){const t=jC(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function ZC(r,e){let t;switch(e){case vx:t="Linear";break;case _x:t="Reinhard";break;case yx:t="OptimizedCineon";break;case Wp:t="ACESFilmic";break;case xx:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function KC(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Oa).join(`
|
|
`)}function JC(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
`)}function QC(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const s=r.getActiveAttrib(e,i),o=s.name;let a=1;s.type===r.FLOAT_MAT2&&(a=2),s.type===r.FLOAT_MAT3&&(a=3),s.type===r.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function Oa(r){return r!==""}function I0(r,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return r.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function U0(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const eR=/^[ \t]*#include +<([\w\d./]+)>/gm;function hp(r){return r.replace(eR,nR)}const tR=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function nR(r,e){let t=Qe[e];if(t===void 0){const n=tR.get(e);if(n!==void 0)t=Qe[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return hp(t)}const iR=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function O0(r){return r.replace(iR,rR)}function rR(r,e,t,n){let i="";for(let s=parseInt(e);s<parseInt(t);s++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function N0(r){let e="precision "+r.precision+` float;
|
|
precision `+r.precision+" int;";return r.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}function sR(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Uu?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===za?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===mi&&(e="SHADOWMAP_TYPE_VSM"),e}function oR(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case Pr:case Lr:e="ENVMAP_TYPE_CUBE";break;case Oo:e="ENVMAP_TYPE_CUBE_UV";break}return e}function aR(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case Lr:e="ENVMAP_MODE_REFRACTION";break}return e}function cR(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case Rc:e="ENVMAP_BLENDING_MULTIPLY";break;case mx:e="ENVMAP_BLENDING_MIX";break;case gx:e="ENVMAP_BLENDING_ADD";break}return e}function lR(r){const e=r.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function uR(r,e,t,n){const i=r.getContext(),s=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=sR(t),l=oR(t),u=aR(t),h=cR(t),f=lR(t),d=t.isWebGL2?"":KC(t),m=JC(s),v=i.createProgram();let g,p,_=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Oa).join(`
|
|
`),g.length>0&&(g+=`
|
|
`),p=[d,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Oa).join(`
|
|
`),p.length>0&&(p+=`
|
|
`)):(g=[N0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
`].filter(Oa).join(`
|
|
`),p=[d,N0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==yi?"#define TONE_MAPPING":"",t.toneMapping!==yi?Qe.tonemapping_pars_fragment:"",t.toneMapping!==yi?ZC("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Qe.colorspace_pars_fragment,$C("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(Oa).join(`
|
|
`)),o=hp(o),o=I0(o,t),o=U0(o,t),a=hp(a),a=I0(a,t),a=U0(a,t),o=O0(o),a=O0(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(_=`#version 300 es
|
|
`,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+g,p=["#define varying in",t.glslVersion===cp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===cp?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
`)+`
|
|
`+p);const y=_+g+o,x=_+p+a,b=L0(i,i.VERTEX_SHADER,y),w=L0(i,i.FRAGMENT_SHADER,x);if(i.attachShader(v,b),i.attachShader(v,w),t.index0AttributeName!==void 0?i.bindAttribLocation(v,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v),r.debug.checkShaderErrors){const E=i.getProgramInfoLog(v).trim(),T=i.getShaderInfoLog(b).trim(),L=i.getShaderInfoLog(w).trim();let P=!0,A=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(P=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,v,b,w);else{const z=D0(i,b,"vertex"),V=D0(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
|
|
|
|
Program Info Log: `+E+`
|
|
`+z+`
|
|
`+V)}else E!==""?console.warn("THREE.WebGLProgram: Program Info Log:",E):(T===""||L==="")&&(A=!1);A&&(this.diagnostics={runnable:P,programLog:E,vertexShader:{log:T,prefix:g},fragmentShader:{log:L,prefix:p}})}i.deleteShader(b),i.deleteShader(w);let S;this.getUniforms=function(){return S===void 0&&(S=new uu(i,v)),S};let M;return this.getAttributes=function(){return M===void 0&&(M=QC(i,v)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qC++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=w,this}let hR=0;class fR{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new dR(e),t.set(e,n)),n}}class dR{constructor(e){this.id=hR++,this.code=e,this.usedTimes=0}}function pR(r,e,t,n,i,s,o){const a=new hs,c=new fR,l=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(E){return E===0?"uv":`uv${E}`}function g(E,T,L,P,A){const z=P.fog,V=A.geometry,N=E.isMeshStandardMaterial?P.environment:null,C=(E.isMeshStandardMaterial?t:e).get(E.envMap||N),O=C&&C.mapping===Oo?C.image.height:null,k=m[E.type];E.precision!==null&&(d=i.getMaxPrecision(E.precision),d!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",d,"instead."));const U=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,R=U!==void 0?U.length:0;let F=0;V.morphAttributes.position!==void 0&&(F=1),V.morphAttributes.normal!==void 0&&(F=2),V.morphAttributes.color!==void 0&&(F=3);let H,Y,J,ie;if(k){const ut=gi[k];H=ut.vertexShader,Y=ut.fragmentShader}else H=E.vertexShader,Y=E.fragmentShader,c.update(E),J=c.getVertexShaderID(E),ie=c.getFragmentShaderID(E);const ne=r.getRenderTarget(),ee=A.isInstancedMesh===!0,ge=!!E.map,me=!!E.matcap,te=!!C,D=!!E.aoMap,Q=!!E.lightMap,j=!!E.bumpMap,K=!!E.normalMap,W=!!E.displacementMap,ye=!!E.emissiveMap,re=!!E.metalnessMap,fe=!!E.roughnessMap,xe=E.anisotropy>0,ce=E.clearcoat>0,Pe=E.iridescence>0,B=E.sheen>0,I=E.transmission>0,$=xe&&!!E.anisotropyMap,he=ce&&!!E.clearcoatMap,de=ce&&!!E.clearcoatNormalMap,pe=ce&&!!E.clearcoatRoughnessMap,Me=Pe&&!!E.iridescenceMap,we=Pe&&!!E.iridescenceThicknessMap,ue=B&&!!E.sheenColorMap,Ce=B&&!!E.sheenRoughnessMap,ze=!!E.specularMap,Le=!!E.specularColorMap,Ee=!!E.specularIntensityMap,De=I&&!!E.transmissionMap,Ve=I&&!!E.thicknessMap,je=!!E.gradientMap,Z=!!E.alphaMap,Ae=E.alphaTest>0,le=!!E.alphaHash,Re=!!E.extensions,Fe=!!V.attributes.uv1,tt=!!V.attributes.uv2,lt=!!V.attributes.uv3;return{isWebGL2:u,shaderID:k,shaderType:E.type,shaderName:E.name,vertexShader:H,fragmentShader:Y,defines:E.defines,customVertexShaderID:J,customFragmentShaderID:ie,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:d,instancing:ee,instancingColor:ee&&A.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:ne===null?r.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:xi,map:ge,matcap:me,envMap:te,envMapMode:te&&C.mapping,envMapCubeUVHeight:O,aoMap:D,lightMap:Q,bumpMap:j,normalMap:K,displacementMap:f&&W,emissiveMap:ye,normalMapObjectSpace:K&&E.normalMapType===Ux,normalMapTangentSpace:K&&E.normalMapType===Or,metalnessMap:re,roughnessMap:fe,anisotropy:xe,anisotropyMap:$,clearcoat:ce,clearcoatMap:he,clearcoatNormalMap:de,clearcoatRoughnessMap:pe,iridescence:Pe,iridescenceMap:Me,iridescenceThicknessMap:we,sheen:B,sheenColorMap:ue,sheenRoughnessMap:Ce,specularMap:ze,specularColorMap:Le,specularIntensityMap:Ee,transmission:I,transmissionMap:De,thicknessMap:Ve,gradientMap:je,opaque:E.transparent===!1&&E.blending===ls,alphaMap:Z,alphaTest:Ae,alphaHash:le,combine:E.combine,mapUv:ge&&v(E.map.channel),aoMapUv:D&&v(E.aoMap.channel),lightMapUv:Q&&v(E.lightMap.channel),bumpMapUv:j&&v(E.bumpMap.channel),normalMapUv:K&&v(E.normalMap.channel),displacementMapUv:W&&v(E.displacementMap.channel),emissiveMapUv:ye&&v(E.emissiveMap.channel),metalnessMapUv:re&&v(E.metalnessMap.channel),roughnessMapUv:fe&&v(E.roughnessMap.channel),anisotropyMapUv:$&&v(E.anisotropyMap.channel),clearcoatMapUv:he&&v(E.clearcoatMap.channel),clearcoatNormalMapUv:de&&v(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:pe&&v(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Me&&v(E.iridescenceMap.channel),iridescenceThicknessMapUv:we&&v(E.iridescenceThicknessMap.channel),sheenColorMapUv:ue&&v(E.sheenColorMap.channel),sheenRoughnessMapUv:Ce&&v(E.sheenRoughnessMap.channel),specularMapUv:ze&&v(E.specularMap.channel),specularColorMapUv:Le&&v(E.specularColorMap.channel),specularIntensityMapUv:Ee&&v(E.specularIntensityMap.channel),transmissionMapUv:De&&v(E.transmissionMap.channel),thicknessMapUv:Ve&&v(E.thicknessMap.channel),alphaMapUv:Z&&v(E.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(K||xe),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:Fe,vertexUv2s:tt,vertexUv3s:lt,pointsUvs:A.isPoints===!0&&!!V.attributes.uv&&(ge||Z),fog:!!z,useFog:E.fog===!0,fogExp2:z&&z.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:A.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:R,morphTextureStride:F,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:r.shadowMap.enabled&&L.length>0,shadowMapType:r.shadowMap.type,toneMapping:E.toneMapped?r.toneMapping:yi,useLegacyLights:r.useLegacyLights,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Dt,flipSided:E.side===vn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionDerivatives:Re&&E.extensions.derivatives===!0,extensionFragDepth:Re&&E.extensions.fragDepth===!0,extensionDrawBuffers:Re&&E.extensions.drawBuffers===!0,extensionShaderTextureLOD:Re&&E.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:E.customProgramCacheKey()}}function p(E){const T=[];if(E.shaderID?T.push(E.shaderID):(T.push(E.customVertexShaderID),T.push(E.customFragmentShaderID)),E.defines!==void 0)for(const L in E.defines)T.push(L),T.push(E.defines[L]);return E.isRawShaderMaterial===!1&&(_(T,E),y(T,E),T.push(r.outputColorSpace)),T.push(E.customProgramCacheKey),T.join()}function _(E,T){E.push(T.precision),E.push(T.outputColorSpace),E.push(T.envMapMode),E.push(T.envMapCubeUVHeight),E.push(T.mapUv),E.push(T.alphaMapUv),E.push(T.lightMapUv),E.push(T.aoMapUv),E.push(T.bumpMapUv),E.push(T.normalMapUv),E.push(T.displacementMapUv),E.push(T.emissiveMapUv),E.push(T.metalnessMapUv),E.push(T.roughnessMapUv),E.push(T.anisotropyMapUv),E.push(T.clearcoatMapUv),E.push(T.clearcoatNormalMapUv),E.push(T.clearcoatRoughnessMapUv),E.push(T.iridescenceMapUv),E.push(T.iridescenceThicknessMapUv),E.push(T.sheenColorMapUv),E.push(T.sheenRoughnessMapUv),E.push(T.specularMapUv),E.push(T.specularColorMapUv),E.push(T.specularIntensityMapUv),E.push(T.transmissionMapUv),E.push(T.thicknessMapUv),E.push(T.combine),E.push(T.fogExp2),E.push(T.sizeAttenuation),E.push(T.morphTargetsCount),E.push(T.morphAttributeCount),E.push(T.numDirLights),E.push(T.numPointLights),E.push(T.numSpotLights),E.push(T.numSpotLightMaps),E.push(T.numHemiLights),E.push(T.numRectAreaLights),E.push(T.numDirLightShadows),E.push(T.numPointLightShadows),E.push(T.numSpotLightShadows),E.push(T.numSpotLightShadowsWithMaps),E.push(T.shadowMapType),E.push(T.toneMapping),E.push(T.numClippingPlanes),E.push(T.numClipIntersection),E.push(T.depthPacking)}function y(E,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.matcap&&a.enable(4),T.envMap&&a.enable(5),T.normalMapObjectSpace&&a.enable(6),T.normalMapTangentSpace&&a.enable(7),T.clearcoat&&a.enable(8),T.iridescence&&a.enable(9),T.alphaTest&&a.enable(10),T.vertexColors&&a.enable(11),T.vertexAlphas&&a.enable(12),T.vertexUv1s&&a.enable(13),T.vertexUv2s&&a.enable(14),T.vertexUv3s&&a.enable(15),T.vertexTangents&&a.enable(16),T.anisotropy&&a.enable(17),E.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.skinning&&a.enable(4),T.morphTargets&&a.enable(5),T.morphNormals&&a.enable(6),T.morphColors&&a.enable(7),T.premultipliedAlpha&&a.enable(8),T.shadowMapEnabled&&a.enable(9),T.useLegacyLights&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),E.push(a.mask)}function x(E){const T=m[E.type];let L;if(T){const P=gi[T];L=am.clone(P.uniforms)}else L=E.uniforms;return L}function b(E,T){let L;for(let P=0,A=l.length;P<A;P++){const z=l[P];if(z.cacheKey===T){L=z,++L.usedTimes;break}}return L===void 0&&(L=new uR(r,T,E,s),l.push(L)),L}function w(E){if(--E.usedTimes===0){const T=l.indexOf(E);l[T]=l[l.length-1],l.pop(),E.destroy()}}function S(E){c.remove(E)}function M(){c.dispose()}return{getParameters:g,getProgramCacheKey:p,getUniforms:x,acquireProgram:b,releaseProgram:w,releaseShaderCache:S,programs:l,dispose:M}}function mR(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function gR(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function F0(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function k0(){const r=[];let e=0;const t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(h,f,d,m,v,g){let p=r[e];return p===void 0?(p={id:h.id,object:h,geometry:f,material:d,groupOrder:m,renderOrder:h.renderOrder,z:v,group:g},r[e]=p):(p.id=h.id,p.object=h,p.geometry=f,p.material=d,p.groupOrder=m,p.renderOrder=h.renderOrder,p.z=v,p.group=g),e++,p}function a(h,f,d,m,v,g){const p=o(h,f,d,m,v,g);d.transmission>0?n.push(p):d.transparent===!0?i.push(p):t.push(p)}function c(h,f,d,m,v,g){const p=o(h,f,d,m,v,g);d.transmission>0?n.unshift(p):d.transparent===!0?i.unshift(p):t.unshift(p)}function l(h,f){t.length>1&&t.sort(h||gR),n.length>1&&n.sort(f||F0),i.length>1&&i.sort(f||F0)}function u(){for(let h=e,f=r.length;h<f;h++){const d=r[h];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:c,finish:u,sort:l}}function vR(){let r=new WeakMap;function e(n,i){const s=r.get(n);let o;return s===void 0?(o=new k0,r.set(n,[o])):i>=s.length?(o=new k0,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function _R(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new G,color:new Ne};break;case"SpotLight":t={position:new G,direction:new G,color:new Ne,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new G,color:new Ne,distance:0,decay:0};break;case"HemisphereLight":t={direction:new G,skyColor:new Ne,groundColor:new Ne};break;case"RectAreaLight":t={color:new Ne,position:new G,halfWidth:new G,halfHeight:new G};break}return r[e.id]=t,t}}}function yR(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let xR=0;function bR(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function wR(r,e){const t=new _R,n=yR(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let u=0;u<9;u++)i.probe.push(new G);const s=new G,o=new Ke,a=new Ke;function c(u,h){let f=0,d=0,m=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let v=0,g=0,p=0,_=0,y=0,x=0,b=0,w=0,S=0,M=0;u.sort(bR);const E=h===!0?Math.PI:1;for(let L=0,P=u.length;L<P;L++){const A=u[L],z=A.color,V=A.intensity,N=A.distance,C=A.shadow&&A.shadow.map?A.shadow.map.texture:null;if(A.isAmbientLight)f+=z.r*V*E,d+=z.g*V*E,m+=z.b*V*E;else if(A.isLightProbe)for(let O=0;O<9;O++)i.probe[O].addScaledVector(A.sh.coefficients[O],V);else if(A.isDirectionalLight){const O=t.get(A);if(O.color.copy(A.color).multiplyScalar(A.intensity*E),A.castShadow){const k=A.shadow,U=n.get(A);U.shadowBias=k.bias,U.shadowNormalBias=k.normalBias,U.shadowRadius=k.radius,U.shadowMapSize=k.mapSize,i.directionalShadow[v]=U,i.directionalShadowMap[v]=C,i.directionalShadowMatrix[v]=A.shadow.matrix,x++}i.directional[v]=O,v++}else if(A.isSpotLight){const O=t.get(A);O.position.setFromMatrixPosition(A.matrixWorld),O.color.copy(z).multiplyScalar(V*E),O.distance=N,O.coneCos=Math.cos(A.angle),O.penumbraCos=Math.cos(A.angle*(1-A.penumbra)),O.decay=A.decay,i.spot[p]=O;const k=A.shadow;if(A.map&&(i.spotLightMap[S]=A.map,S++,k.updateMatrices(A),A.castShadow&&M++),i.spotLightMatrix[p]=k.matrix,A.castShadow){const U=n.get(A);U.shadowBias=k.bias,U.shadowNormalBias=k.normalBias,U.shadowRadius=k.radius,U.shadowMapSize=k.mapSize,i.spotShadow[p]=U,i.spotShadowMap[p]=C,w++}p++}else if(A.isRectAreaLight){const O=t.get(A);O.color.copy(z).multiplyScalar(V),O.halfWidth.set(A.width*.5,0,0),O.halfHeight.set(0,A.height*.5,0),i.rectArea[_]=O,_++}else if(A.isPointLight){const O=t.get(A);if(O.color.copy(A.color).multiplyScalar(A.intensity*E),O.distance=A.distance,O.decay=A.decay,A.castShadow){const k=A.shadow,U=n.get(A);U.shadowBias=k.bias,U.shadowNormalBias=k.normalBias,U.shadowRadius=k.radius,U.shadowMapSize=k.mapSize,U.shadowCameraNear=k.camera.near,U.shadowCameraFar=k.camera.far,i.pointShadow[g]=U,i.pointShadowMap[g]=C,i.pointShadowMatrix[g]=A.shadow.matrix,b++}i.point[g]=O,g++}else if(A.isHemisphereLight){const O=t.get(A);O.skyColor.copy(A.color).multiplyScalar(V*E),O.groundColor.copy(A.groundColor).multiplyScalar(V*E),i.hemi[y]=O,y++}}_>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ke.LTC_FLOAT_1,i.rectAreaLTC2=ke.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ke.LTC_HALF_1,i.rectAreaLTC2=ke.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=m;const T=i.hash;(T.directionalLength!==v||T.pointLength!==g||T.spotLength!==p||T.rectAreaLength!==_||T.hemiLength!==y||T.numDirectionalShadows!==x||T.numPointShadows!==b||T.numSpotShadows!==w||T.numSpotMaps!==S)&&(i.directional.length=v,i.spot.length=p,i.rectArea.length=_,i.point.length=g,i.hemi.length=y,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=w,i.spotShadowMap.length=w,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=w+S-M,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=M,T.directionalLength=v,T.pointLength=g,T.spotLength=p,T.rectAreaLength=_,T.hemiLength=y,T.numDirectionalShadows=x,T.numPointShadows=b,T.numSpotShadows=w,T.numSpotMaps=S,i.version=xR++)}function l(u,h){let f=0,d=0,m=0,v=0,g=0;const p=h.matrixWorldInverse;for(let _=0,y=u.length;_<y;_++){const x=u[_];if(x.isDirectionalLight){const b=i.directional[f];b.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(p),f++}else if(x.isSpotLight){const b=i.spot[m];b.position.setFromMatrixPosition(x.matrixWorld),b.position.applyMatrix4(p),b.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(p),m++}else if(x.isRectAreaLight){const b=i.rectArea[v];b.position.setFromMatrixPosition(x.matrixWorld),b.position.applyMatrix4(p),a.identity(),o.copy(x.matrixWorld),o.premultiply(p),a.extractRotation(o),b.halfWidth.set(x.width*.5,0,0),b.halfHeight.set(0,x.height*.5,0),b.halfWidth.applyMatrix4(a),b.halfHeight.applyMatrix4(a),v++}else if(x.isPointLight){const b=i.point[d];b.position.setFromMatrixPosition(x.matrixWorld),b.position.applyMatrix4(p),d++}else if(x.isHemisphereLight){const b=i.hemi[g];b.direction.setFromMatrixPosition(x.matrixWorld),b.direction.transformDirection(p),g++}}}return{setup:c,setupView:l,state:i}}function z0(r,e){const t=new wR(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function c(h){t.setup(n,h)}function l(h){t.setupView(n,h)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}function SR(r,e){let t=new WeakMap;function n(s,o=0){const a=t.get(s);let c;return a===void 0?(c=new z0(r,e),t.set(s,[c])):o>=a.length?(c=new z0(r,e),a.push(c)):c=a[o],c}function i(){t=new WeakMap}return{get:n,dispose:i}}class Gu extends un{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ix,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Vu extends un{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const ER=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,MR=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
#include <packing>
|
|
void main() {
|
|
const float samples = float( VSM_SAMPLES );
|
|
float mean = 0.0;
|
|
float squared_mean = 0.0;
|
|
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
for ( float i = 0.0; i < samples; i ++ ) {
|
|
float uvOffset = uvStart + i * uvStride;
|
|
#ifdef HORIZONTAL_PASS
|
|
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
mean += distribution.x;
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
#else
|
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
mean += depth;
|
|
squared_mean += depth * depth;
|
|
#endif
|
|
}
|
|
mean = mean / samples;
|
|
squared_mean = squared_mean / samples;
|
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
}`;function TR(r,e,t){let n=new zu;const i=new be,s=new be,o=new mt,a=new Gu({depthPacking:em}),c=new Vu,l={},u=t.maxTextureSize,h={[Oi]:vn,[vn]:Oi,[Dt]:Dt},f=new Ni({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new be},radius:{value:4}},vertexShader:ER,fragmentShader:MR}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const m=new st;m.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ot(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Uu;let p=this.type;this.render=function(b,w,S){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;const M=r.getRenderTarget(),E=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),L=r.state;L.setBlending(nr),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const P=p!==mi&&this.type===mi,A=p===mi&&this.type!==mi;for(let z=0,V=b.length;z<V;z++){const N=b[z],C=N.shadow;if(C===void 0){console.warn("THREE.WebGLShadowMap:",N,"has no shadow.");continue}if(C.autoUpdate===!1&&C.needsUpdate===!1)continue;i.copy(C.mapSize);const O=C.getFrameExtents();if(i.multiply(O),s.copy(C.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/O.x),i.x=s.x*O.x,C.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/O.y),i.y=s.y*O.y,C.mapSize.y=s.y)),C.map===null||P===!0||A===!0){const U=this.type!==mi?{minFilter:Yt,magFilter:Yt}:{};C.map!==null&&C.map.dispose(),C.map=new bi(i.x,i.y,U),C.map.texture.name=N.name+".shadowMap",C.camera.updateProjectionMatrix()}r.setRenderTarget(C.map),r.clear();const k=C.getViewportCount();for(let U=0;U<k;U++){const R=C.getViewport(U);o.set(s.x*R.x,s.y*R.y,s.x*R.z,s.y*R.w),L.viewport(o),C.updateMatrices(N,U),n=C.getFrustum(),x(w,S,C.camera,N,this.type)}C.isPointLightShadow!==!0&&this.type===mi&&_(C,S),C.needsUpdate=!1}p=this.type,g.needsUpdate=!1,r.setRenderTarget(M,E,T)};function _(b,w){const S=e.update(v);f.defines.VSM_SAMPLES!==b.blurSamples&&(f.defines.VSM_SAMPLES=b.blurSamples,d.defines.VSM_SAMPLES=b.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new bi(i.x,i.y)),f.uniforms.shadow_pass.value=b.map.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(w,null,S,f,v,null),d.uniforms.shadow_pass.value=b.mapPass.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(w,null,S,d,v,null)}function y(b,w,S,M){let E=null;const T=S.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)E=T;else if(E=S.isPointLight===!0?c:a,r.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const L=E.uuid,P=w.uuid;let A=l[L];A===void 0&&(A={},l[L]=A);let z=A[P];z===void 0&&(z=E.clone(),A[P]=z),E=z}if(E.visible=w.visible,E.wireframe=w.wireframe,M===mi?E.side=w.shadowSide!==null?w.shadowSide:w.side:E.side=w.shadowSide!==null?w.shadowSide:h[w.side],E.alphaMap=w.alphaMap,E.alphaTest=w.alphaTest,E.map=w.map,E.clipShadows=w.clipShadows,E.clippingPlanes=w.clippingPlanes,E.clipIntersection=w.clipIntersection,E.displacementMap=w.displacementMap,E.displacementScale=w.displacementScale,E.displacementBias=w.displacementBias,E.wireframeLinewidth=w.wireframeLinewidth,E.linewidth=w.linewidth,S.isPointLight===!0&&E.isMeshDistanceMaterial===!0){const L=r.properties.get(E);L.light=S}return E}function x(b,w,S,M,E){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&E===mi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(S.matrixWorldInverse,b.matrixWorld);const P=e.update(b),A=b.material;if(Array.isArray(A)){const z=P.groups;for(let V=0,N=z.length;V<N;V++){const C=z[V],O=A[C.materialIndex];if(O&&O.visible){const k=y(b,O,M,E);r.renderBufferDirect(S,null,P,k,b,C)}}}else if(A.visible){const z=y(b,A,M,E);r.renderBufferDirect(S,null,P,z,b,null)}}const L=b.children;for(let P=0,A=L.length;P<A;P++)x(L[P],w,S,M,E)}}function AR(r,e,t){const n=t.isWebGL2;function i(){let Z=!1;const Ae=new mt;let le=null;const Re=new mt(0,0,0,0);return{setMask:function(Fe){le!==Fe&&!Z&&(r.colorMask(Fe,Fe,Fe,Fe),le=Fe)},setLocked:function(Fe){Z=Fe},setClear:function(Fe,tt,lt,ft,ut){ut===!0&&(Fe*=ft,tt*=ft,lt*=ft),Ae.set(Fe,tt,lt,ft),Re.equals(Ae)===!1&&(r.clearColor(Fe,tt,lt,ft),Re.copy(Ae))},reset:function(){Z=!1,le=null,Re.set(-1,0,0,0)}}}function s(){let Z=!1,Ae=null,le=null,Re=null;return{setTest:function(Fe){Fe?ne(r.DEPTH_TEST):ee(r.DEPTH_TEST)},setMask:function(Fe){Ae!==Fe&&!Z&&(r.depthMask(Fe),Ae=Fe)},setFunc:function(Fe){if(le!==Fe){switch(Fe){case cx:r.depthFunc(r.NEVER);break;case lx:r.depthFunc(r.ALWAYS);break;case ux:r.depthFunc(r.LESS);break;case vu:r.depthFunc(r.LEQUAL);break;case hx:r.depthFunc(r.EQUAL);break;case fx:r.depthFunc(r.GEQUAL);break;case dx:r.depthFunc(r.GREATER);break;case px:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}le=Fe}},setLocked:function(Fe){Z=Fe},setClear:function(Fe){Re!==Fe&&(r.clearDepth(Fe),Re=Fe)},reset:function(){Z=!1,Ae=null,le=null,Re=null}}}function o(){let Z=!1,Ae=null,le=null,Re=null,Fe=null,tt=null,lt=null,ft=null,ut=null;return{setTest:function(xt){Z||(xt?ne(r.STENCIL_TEST):ee(r.STENCIL_TEST))},setMask:function(xt){Ae!==xt&&!Z&&(r.stencilMask(xt),Ae=xt)},setFunc:function(xt,dt,ct){(le!==xt||Re!==dt||Fe!==ct)&&(r.stencilFunc(xt,dt,ct),le=xt,Re=dt,Fe=ct)},setOp:function(xt,dt,ct){(tt!==xt||lt!==dt||ft!==ct)&&(r.stencilOp(xt,dt,ct),tt=xt,lt=dt,ft=ct)},setLocked:function(xt){Z=xt},setClear:function(xt){ut!==xt&&(r.clearStencil(xt),ut=xt)},reset:function(){Z=!1,Ae=null,le=null,Re=null,Fe=null,tt=null,lt=null,ft=null,ut=null}}}const a=new i,c=new s,l=new o,u=new WeakMap,h=new WeakMap;let f={},d={},m=new WeakMap,v=[],g=null,p=!1,_=null,y=null,x=null,b=null,w=null,S=null,M=null,E=!1,T=null,L=null,P=null,A=null,z=null;const V=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let N=!1,C=0;const O=r.getParameter(r.VERSION);O.indexOf("WebGL")!==-1?(C=parseFloat(/^WebGL (\d)/.exec(O)[1]),N=C>=1):O.indexOf("OpenGL ES")!==-1&&(C=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),N=C>=2);let k=null,U={};const R=r.getParameter(r.SCISSOR_BOX),F=r.getParameter(r.VIEWPORT),H=new mt().fromArray(R),Y=new mt().fromArray(F);function J(Z,Ae,le,Re){const Fe=new Uint8Array(4),tt=r.createTexture();r.bindTexture(Z,tt),r.texParameteri(Z,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(Z,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let lt=0;lt<le;lt++)n&&(Z===r.TEXTURE_3D||Z===r.TEXTURE_2D_ARRAY)?r.texImage3D(Ae,0,r.RGBA,1,1,Re,0,r.RGBA,r.UNSIGNED_BYTE,Fe):r.texImage2D(Ae+lt,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,Fe);return tt}const ie={};ie[r.TEXTURE_2D]=J(r.TEXTURE_2D,r.TEXTURE_2D,1),ie[r.TEXTURE_CUBE_MAP]=J(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(ie[r.TEXTURE_2D_ARRAY]=J(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),ie[r.TEXTURE_3D]=J(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),a.setClear(0,0,0,1),c.setClear(1),l.setClear(0),ne(r.DEPTH_TEST),c.setFunc(vu),W(!1),ye(Id),ne(r.CULL_FACE),j(nr);function ne(Z){f[Z]!==!0&&(r.enable(Z),f[Z]=!0)}function ee(Z){f[Z]!==!1&&(r.disable(Z),f[Z]=!1)}function ge(Z,Ae){return d[Z]!==Ae?(r.bindFramebuffer(Z,Ae),d[Z]=Ae,n&&(Z===r.DRAW_FRAMEBUFFER&&(d[r.FRAMEBUFFER]=Ae),Z===r.FRAMEBUFFER&&(d[r.DRAW_FRAMEBUFFER]=Ae)),!0):!1}function me(Z,Ae){let le=v,Re=!1;if(Z)if(le=m.get(Ae),le===void 0&&(le=[],m.set(Ae,le)),Z.isWebGLMultipleRenderTargets){const Fe=Z.texture;if(le.length!==Fe.length||le[0]!==r.COLOR_ATTACHMENT0){for(let tt=0,lt=Fe.length;tt<lt;tt++)le[tt]=r.COLOR_ATTACHMENT0+tt;le.length=Fe.length,Re=!0}}else le[0]!==r.COLOR_ATTACHMENT0&&(le[0]=r.COLOR_ATTACHMENT0,Re=!0);else le[0]!==r.BACK&&(le[0]=r.BACK,Re=!0);Re&&(t.isWebGL2?r.drawBuffers(le):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(le))}function te(Z){return g!==Z?(r.useProgram(Z),g=Z,!0):!1}const D={[ns]:r.FUNC_ADD,[Ky]:r.FUNC_SUBTRACT,[Jy]:r.FUNC_REVERSE_SUBTRACT};if(n)D[Fd]=r.MIN,D[kd]=r.MAX;else{const Z=e.get("EXT_blend_minmax");Z!==null&&(D[Fd]=Z.MIN_EXT,D[kd]=Z.MAX_EXT)}const Q={[Qy]:r.ZERO,[ex]:r.ONE,[tx]:r.SRC_COLOR,[Vp]:r.SRC_ALPHA,[ax]:r.SRC_ALPHA_SATURATE,[sx]:r.DST_COLOR,[ix]:r.DST_ALPHA,[nx]:r.ONE_MINUS_SRC_COLOR,[Hp]:r.ONE_MINUS_SRC_ALPHA,[ox]:r.ONE_MINUS_DST_COLOR,[rx]:r.ONE_MINUS_DST_ALPHA};function j(Z,Ae,le,Re,Fe,tt,lt,ft){if(Z===nr){p===!0&&(ee(r.BLEND),p=!1);return}if(p===!1&&(ne(r.BLEND),p=!0),Z!==Zy){if(Z!==_||ft!==E){if((y!==ns||w!==ns)&&(r.blendEquation(r.FUNC_ADD),y=ns,w=ns),ft)switch(Z){case ls:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ud:r.blendFunc(r.ONE,r.ONE);break;case Od:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Nd:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",Z);break}else switch(Z){case ls:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case Ud:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case Od:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case Nd:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Z);break}x=null,b=null,S=null,M=null,_=Z,E=ft}return}Fe=Fe||Ae,tt=tt||le,lt=lt||Re,(Ae!==y||Fe!==w)&&(r.blendEquationSeparate(D[Ae],D[Fe]),y=Ae,w=Fe),(le!==x||Re!==b||tt!==S||lt!==M)&&(r.blendFuncSeparate(Q[le],Q[Re],Q[tt],Q[lt]),x=le,b=Re,S=tt,M=lt),_=Z,E=!1}function K(Z,Ae){Z.side===Dt?ee(r.CULL_FACE):ne(r.CULL_FACE);let le=Z.side===vn;Ae&&(le=!le),W(le),Z.blending===ls&&Z.transparent===!1?j(nr):j(Z.blending,Z.blendEquation,Z.blendSrc,Z.blendDst,Z.blendEquationAlpha,Z.blendSrcAlpha,Z.blendDstAlpha,Z.premultipliedAlpha),c.setFunc(Z.depthFunc),c.setTest(Z.depthTest),c.setMask(Z.depthWrite),a.setMask(Z.colorWrite);const Re=Z.stencilWrite;l.setTest(Re),Re&&(l.setMask(Z.stencilWriteMask),l.setFunc(Z.stencilFunc,Z.stencilRef,Z.stencilFuncMask),l.setOp(Z.stencilFail,Z.stencilZFail,Z.stencilZPass)),fe(Z.polygonOffset,Z.polygonOffsetFactor,Z.polygonOffsetUnits),Z.alphaToCoverage===!0?ne(r.SAMPLE_ALPHA_TO_COVERAGE):ee(r.SAMPLE_ALPHA_TO_COVERAGE)}function W(Z){T!==Z&&(Z?r.frontFace(r.CW):r.frontFace(r.CCW),T=Z)}function ye(Z){Z!==Yy?(ne(r.CULL_FACE),Z!==L&&(Z===Id?r.cullFace(r.BACK):Z===jy?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):ee(r.CULL_FACE),L=Z}function re(Z){Z!==P&&(N&&r.lineWidth(Z),P=Z)}function fe(Z,Ae,le){Z?(ne(r.POLYGON_OFFSET_FILL),(A!==Ae||z!==le)&&(r.polygonOffset(Ae,le),A=Ae,z=le)):ee(r.POLYGON_OFFSET_FILL)}function xe(Z){Z?ne(r.SCISSOR_TEST):ee(r.SCISSOR_TEST)}function ce(Z){Z===void 0&&(Z=r.TEXTURE0+V-1),k!==Z&&(r.activeTexture(Z),k=Z)}function Pe(Z,Ae,le){le===void 0&&(k===null?le=r.TEXTURE0+V-1:le=k);let Re=U[le];Re===void 0&&(Re={type:void 0,texture:void 0},U[le]=Re),(Re.type!==Z||Re.texture!==Ae)&&(k!==le&&(r.activeTexture(le),k=le),r.bindTexture(Z,Ae||ie[Z]),Re.type=Z,Re.texture=Ae)}function B(){const Z=U[k];Z!==void 0&&Z.type!==void 0&&(r.bindTexture(Z.type,null),Z.type=void 0,Z.texture=void 0)}function I(){try{r.compressedTexImage2D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function $(){try{r.compressedTexImage3D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function he(){try{r.texSubImage2D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function de(){try{r.texSubImage3D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function pe(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Me(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function we(){try{r.texStorage2D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function ue(){try{r.texStorage3D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Ce(){try{r.texImage2D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function ze(){try{r.texImage3D.apply(r,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}}function Le(Z){H.equals(Z)===!1&&(r.scissor(Z.x,Z.y,Z.z,Z.w),H.copy(Z))}function Ee(Z){Y.equals(Z)===!1&&(r.viewport(Z.x,Z.y,Z.z,Z.w),Y.copy(Z))}function De(Z,Ae){let le=h.get(Ae);le===void 0&&(le=new WeakMap,h.set(Ae,le));let Re=le.get(Z);Re===void 0&&(Re=r.getUniformBlockIndex(Ae,Z.name),le.set(Z,Re))}function Ve(Z,Ae){const Re=h.get(Ae).get(Z);u.get(Ae)!==Re&&(r.uniformBlockBinding(Ae,Re,Z.__bindingPointIndex),u.set(Ae,Re))}function je(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),n===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),f={},k=null,U={},d={},m=new WeakMap,v=[],g=null,p=!1,_=null,y=null,x=null,b=null,w=null,S=null,M=null,E=!1,T=null,L=null,P=null,A=null,z=null,H.set(0,0,r.canvas.width,r.canvas.height),Y.set(0,0,r.canvas.width,r.canvas.height),a.reset(),c.reset(),l.reset()}return{buffers:{color:a,depth:c,stencil:l},enable:ne,disable:ee,bindFramebuffer:ge,drawBuffers:me,useProgram:te,setBlending:j,setMaterial:K,setFlipSided:W,setCullFace:ye,setLineWidth:re,setPolygonOffset:fe,setScissorTest:xe,activeTexture:ce,bindTexture:Pe,unbindTexture:B,compressedTexImage2D:I,compressedTexImage3D:$,texImage2D:Ce,texImage3D:ze,updateUBOMapping:De,uniformBlockBinding:Ve,texStorage2D:we,texStorage3D:ue,texSubImage2D:he,texSubImage3D:de,compressedTexSubImage2D:pe,compressedTexSubImage3D:Me,scissor:Le,viewport:Ee,reset:je}}function CR(r,e,t,n,i,s,o){const a=i.isWebGL2,c=i.maxTextures,l=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,f=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,d=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let v;const g=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(B,I){return p?new OffscreenCanvas(B,I):oc("canvas")}function y(B,I,$,he){let de=1;if((B.width>he||B.height>he)&&(de=he/Math.max(B.width,B.height)),de<1||I===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const pe=I?xu:Math.floor,Me=pe(de*B.width),we=pe(de*B.height);v===void 0&&(v=_(Me,we));const ue=$?_(Me,we):v;return ue.width=Me,ue.height=we,ue.getContext("2d").drawImage(B,0,0,Me,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+Me+"x"+we+")."),ue}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function x(B){return lp(B.width)&&lp(B.height)}function b(B){return a?!1:B.wrapS!==gn||B.wrapT!==gn||B.minFilter!==Yt&&B.minFilter!==Pt}function w(B,I){return B.generateMipmaps&&I&&B.minFilter!==Yt&&B.minFilter!==Pt}function S(B){r.generateMipmap(B)}function M(B,I,$,he,de=!1){if(a===!1)return I;if(B!==null){if(r[B]!==void 0)return r[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let pe=I;return I===r.RED&&($===r.FLOAT&&(pe=r.R32F),$===r.HALF_FLOAT&&(pe=r.R16F),$===r.UNSIGNED_BYTE&&(pe=r.R8)),I===r.RG&&($===r.FLOAT&&(pe=r.RG32F),$===r.HALF_FLOAT&&(pe=r.RG16F),$===r.UNSIGNED_BYTE&&(pe=r.RG8)),I===r.RGBA&&($===r.FLOAT&&(pe=r.RGBA32F),$===r.HALF_FLOAT&&(pe=r.RGBA16F),$===r.UNSIGNED_BYTE&&(pe=he===et&&de===!1?r.SRGB8_ALPHA8:r.RGBA8),$===r.UNSIGNED_SHORT_4_4_4_4&&(pe=r.RGBA4),$===r.UNSIGNED_SHORT_5_5_5_1&&(pe=r.RGB5_A1)),(pe===r.R16F||pe===r.R32F||pe===r.RG16F||pe===r.RG32F||pe===r.RGBA16F||pe===r.RGBA32F)&&e.get("EXT_color_buffer_float"),pe}function E(B,I,$){return w(B,$)===!0||B.isFramebufferTexture&&B.minFilter!==Yt&&B.minFilter!==Pt?Math.log2(Math.max(I.width,I.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?I.mipmaps.length:1}function T(B){return B===Yt||B===_u||B===Ba?r.NEAREST:r.LINEAR}function L(B){const I=B.target;I.removeEventListener("dispose",L),A(I),I.isVideoTexture&&m.delete(I)}function P(B){const I=B.target;I.removeEventListener("dispose",P),V(I)}function A(B){const I=n.get(B);if(I.__webglInit===void 0)return;const $=B.source,he=g.get($);if(he){const de=he[I.__cacheKey];de.usedTimes--,de.usedTimes===0&&z(B),Object.keys(he).length===0&&g.delete($)}n.remove(B)}function z(B){const I=n.get(B);r.deleteTexture(I.__webglTexture);const $=B.source,he=g.get($);delete he[I.__cacheKey],o.memory.textures--}function V(B){const I=B.texture,$=n.get(B),he=n.get(I);if(he.__webglTexture!==void 0&&(r.deleteTexture(he.__webglTexture),o.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let de=0;de<6;de++)r.deleteFramebuffer($.__webglFramebuffer[de]),$.__webglDepthbuffer&&r.deleteRenderbuffer($.__webglDepthbuffer[de]);else{if(r.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&r.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&r.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let de=0;de<$.__webglColorRenderbuffer.length;de++)$.__webglColorRenderbuffer[de]&&r.deleteRenderbuffer($.__webglColorRenderbuffer[de]);$.__webglDepthRenderbuffer&&r.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let de=0,pe=I.length;de<pe;de++){const Me=n.get(I[de]);Me.__webglTexture&&(r.deleteTexture(Me.__webglTexture),o.memory.textures--),n.remove(I[de])}n.remove(I),n.remove(B)}let N=0;function C(){N=0}function O(){const B=N;return B>=c&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+c),N+=1,B}function k(B){const I=[];return I.push(B.wrapS),I.push(B.wrapT),I.push(B.wrapR||0),I.push(B.magFilter),I.push(B.minFilter),I.push(B.anisotropy),I.push(B.internalFormat),I.push(B.format),I.push(B.type),I.push(B.generateMipmaps),I.push(B.premultiplyAlpha),I.push(B.flipY),I.push(B.unpackAlignment),I.push(B.colorSpace),I.join()}function U(B,I){const $=n.get(B);if(B.isVideoTexture&&ce(B),B.isRenderTargetTexture===!1&&B.version>0&&$.__version!==B.version){const he=B.image;if(he===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(he.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ge($,B,I);return}}t.bindTexture(r.TEXTURE_2D,$.__webglTexture,r.TEXTURE0+I)}function R(B,I){const $=n.get(B);if(B.version>0&&$.__version!==B.version){ge($,B,I);return}t.bindTexture(r.TEXTURE_2D_ARRAY,$.__webglTexture,r.TEXTURE0+I)}function F(B,I){const $=n.get(B);if(B.version>0&&$.__version!==B.version){ge($,B,I);return}t.bindTexture(r.TEXTURE_3D,$.__webglTexture,r.TEXTURE0+I)}function H(B,I){const $=n.get(B);if(B.version>0&&$.__version!==B.version){me($,B,I);return}t.bindTexture(r.TEXTURE_CUBE_MAP,$.__webglTexture,r.TEXTURE0+I)}const Y={[Qa]:r.REPEAT,[gn]:r.CLAMP_TO_EDGE,[ec]:r.MIRRORED_REPEAT},J={[Yt]:r.NEAREST,[_u]:r.NEAREST_MIPMAP_NEAREST,[Ba]:r.NEAREST_MIPMAP_LINEAR,[Pt]:r.LINEAR,[Xp]:r.LINEAR_MIPMAP_NEAREST,[Dr]:r.LINEAR_MIPMAP_LINEAR},ie={[Nx]:r.NEVER,[Hx]:r.ALWAYS,[Fx]:r.LESS,[zx]:r.LEQUAL,[kx]:r.EQUAL,[Vx]:r.GEQUAL,[Bx]:r.GREATER,[Gx]:r.NOTEQUAL};function ne(B,I,$){if($?(r.texParameteri(B,r.TEXTURE_WRAP_S,Y[I.wrapS]),r.texParameteri(B,r.TEXTURE_WRAP_T,Y[I.wrapT]),(B===r.TEXTURE_3D||B===r.TEXTURE_2D_ARRAY)&&r.texParameteri(B,r.TEXTURE_WRAP_R,Y[I.wrapR]),r.texParameteri(B,r.TEXTURE_MAG_FILTER,J[I.magFilter]),r.texParameteri(B,r.TEXTURE_MIN_FILTER,J[I.minFilter])):(r.texParameteri(B,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(B,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(B===r.TEXTURE_3D||B===r.TEXTURE_2D_ARRAY)&&r.texParameteri(B,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(I.wrapS!==gn||I.wrapT!==gn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(B,r.TEXTURE_MAG_FILTER,T(I.magFilter)),r.texParameteri(B,r.TEXTURE_MIN_FILTER,T(I.minFilter)),I.minFilter!==Yt&&I.minFilter!==Pt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),I.compareFunction&&(r.texParameteri(B,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(B,r.TEXTURE_COMPARE_FUNC,ie[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const he=e.get("EXT_texture_filter_anisotropic");if(I.magFilter===Yt||I.minFilter!==Ba&&I.minFilter!==Dr||I.type===Li&&e.has("OES_texture_float_linear")===!1||a===!1&&I.type===Ao&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||n.get(I).__currentAnisotropy)&&(r.texParameterf(B,he.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy)}}function ee(B,I){let $=!1;B.__webglInit===void 0&&(B.__webglInit=!0,I.addEventListener("dispose",L));const he=I.source;let de=g.get(he);de===void 0&&(de={},g.set(he,de));const pe=k(I);if(pe!==B.__cacheKey){de[pe]===void 0&&(de[pe]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,$=!0),de[pe].usedTimes++;const Me=de[B.__cacheKey];Me!==void 0&&(de[B.__cacheKey].usedTimes--,Me.usedTimes===0&&z(I)),B.__cacheKey=pe,B.__webglTexture=de[pe].texture}return $}function ge(B,I,$){let he=r.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(he=r.TEXTURE_2D_ARRAY),I.isData3DTexture&&(he=r.TEXTURE_3D);const de=ee(B,I),pe=I.source;t.bindTexture(he,B.__webglTexture,r.TEXTURE0+$);const Me=n.get(pe);if(pe.version!==Me.__version||de===!0){t.activeTexture(r.TEXTURE0+$),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,I.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,I.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const we=b(I)&&x(I.image)===!1;let ue=y(I.image,we,!1,u);ue=Pe(I,ue);const Ce=x(ue)||a,ze=s.convert(I.format,I.colorSpace);let Le=s.convert(I.type),Ee=M(I.internalFormat,ze,Le,I.colorSpace);ne(he,I,Ce);let De;const Ve=I.mipmaps,je=a&&I.isVideoTexture!==!0,Z=Me.__version===void 0||de===!0,Ae=E(I,ue,Ce);if(I.isDepthTexture)Ee=r.DEPTH_COMPONENT,a?I.type===Li?Ee=r.DEPTH_COMPONENT32F:I.type===tr?Ee=r.DEPTH_COMPONENT24:I.type===Mr?Ee=r.DEPTH24_STENCIL8:Ee=r.DEPTH_COMPONENT16:I.type===Li&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Tr&&Ee===r.DEPTH_COMPONENT&&I.type!==Nu&&I.type!==tr&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=tr,Le=s.convert(I.type)),I.format===ms&&Ee===r.DEPTH_COMPONENT&&(Ee=r.DEPTH_STENCIL,I.type!==Mr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Mr,Le=s.convert(I.type))),Z&&(je?t.texStorage2D(r.TEXTURE_2D,1,Ee,ue.width,ue.height):t.texImage2D(r.TEXTURE_2D,0,Ee,ue.width,ue.height,0,ze,Le,null));else if(I.isDataTexture)if(Ve.length>0&&Ce){je&&Z&&t.texStorage2D(r.TEXTURE_2D,Ae,Ee,Ve[0].width,Ve[0].height);for(let le=0,Re=Ve.length;le<Re;le++)De=Ve[le],je?t.texSubImage2D(r.TEXTURE_2D,le,0,0,De.width,De.height,ze,Le,De.data):t.texImage2D(r.TEXTURE_2D,le,Ee,De.width,De.height,0,ze,Le,De.data);I.generateMipmaps=!1}else je?(Z&&t.texStorage2D(r.TEXTURE_2D,Ae,Ee,ue.width,ue.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,ue.width,ue.height,ze,Le,ue.data)):t.texImage2D(r.TEXTURE_2D,0,Ee,ue.width,ue.height,0,ze,Le,ue.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){je&&Z&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Ae,Ee,Ve[0].width,Ve[0].height,ue.depth);for(let le=0,Re=Ve.length;le<Re;le++)De=Ve[le],I.format!==Ln?ze!==null?je?t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,le,0,0,0,De.width,De.height,ue.depth,ze,De.data,0,0):t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,le,Ee,De.width,De.height,ue.depth,0,De.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?t.texSubImage3D(r.TEXTURE_2D_ARRAY,le,0,0,0,De.width,De.height,ue.depth,ze,Le,De.data):t.texImage3D(r.TEXTURE_2D_ARRAY,le,Ee,De.width,De.height,ue.depth,0,ze,Le,De.data)}else{je&&Z&&t.texStorage2D(r.TEXTURE_2D,Ae,Ee,Ve[0].width,Ve[0].height);for(let le=0,Re=Ve.length;le<Re;le++)De=Ve[le],I.format!==Ln?ze!==null?je?t.compressedTexSubImage2D(r.TEXTURE_2D,le,0,0,De.width,De.height,ze,De.data):t.compressedTexImage2D(r.TEXTURE_2D,le,Ee,De.width,De.height,0,De.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):je?t.texSubImage2D(r.TEXTURE_2D,le,0,0,De.width,De.height,ze,Le,De.data):t.texImage2D(r.TEXTURE_2D,le,Ee,De.width,De.height,0,ze,Le,De.data)}else if(I.isDataArrayTexture)je?(Z&&t.texStorage3D(r.TEXTURE_2D_ARRAY,Ae,Ee,ue.width,ue.height,ue.depth),t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,ue.width,ue.height,ue.depth,ze,Le,ue.data)):t.texImage3D(r.TEXTURE_2D_ARRAY,0,Ee,ue.width,ue.height,ue.depth,0,ze,Le,ue.data);else if(I.isData3DTexture)je?(Z&&t.texStorage3D(r.TEXTURE_3D,Ae,Ee,ue.width,ue.height,ue.depth),t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,ue.width,ue.height,ue.depth,ze,Le,ue.data)):t.texImage3D(r.TEXTURE_3D,0,Ee,ue.width,ue.height,ue.depth,0,ze,Le,ue.data);else if(I.isFramebufferTexture){if(Z)if(je)t.texStorage2D(r.TEXTURE_2D,Ae,Ee,ue.width,ue.height);else{let le=ue.width,Re=ue.height;for(let Fe=0;Fe<Ae;Fe++)t.texImage2D(r.TEXTURE_2D,Fe,Ee,le,Re,0,ze,Le,null),le>>=1,Re>>=1}}else if(Ve.length>0&&Ce){je&&Z&&t.texStorage2D(r.TEXTURE_2D,Ae,Ee,Ve[0].width,Ve[0].height);for(let le=0,Re=Ve.length;le<Re;le++)De=Ve[le],je?t.texSubImage2D(r.TEXTURE_2D,le,0,0,ze,Le,De):t.texImage2D(r.TEXTURE_2D,le,Ee,ze,Le,De);I.generateMipmaps=!1}else je?(Z&&t.texStorage2D(r.TEXTURE_2D,Ae,Ee,ue.width,ue.height),t.texSubImage2D(r.TEXTURE_2D,0,0,0,ze,Le,ue)):t.texImage2D(r.TEXTURE_2D,0,Ee,ze,Le,ue);w(I,Ce)&&S(he),Me.__version=pe.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function me(B,I,$){if(I.image.length!==6)return;const he=ee(B,I),de=I.source;t.bindTexture(r.TEXTURE_CUBE_MAP,B.__webglTexture,r.TEXTURE0+$);const pe=n.get(de);if(de.version!==pe.__version||he===!0){t.activeTexture(r.TEXTURE0+$),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,I.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,I.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE);const Me=I.isCompressedTexture||I.image[0].isCompressedTexture,we=I.image[0]&&I.image[0].isDataTexture,ue=[];for(let le=0;le<6;le++)!Me&&!we?ue[le]=y(I.image[le],!1,!0,l):ue[le]=we?I.image[le].image:I.image[le],ue[le]=Pe(I,ue[le]);const Ce=ue[0],ze=x(Ce)||a,Le=s.convert(I.format,I.colorSpace),Ee=s.convert(I.type),De=M(I.internalFormat,Le,Ee,I.colorSpace),Ve=a&&I.isVideoTexture!==!0,je=pe.__version===void 0||he===!0;let Z=E(I,Ce,ze);ne(r.TEXTURE_CUBE_MAP,I,ze);let Ae;if(Me){Ve&&je&&t.texStorage2D(r.TEXTURE_CUBE_MAP,Z,De,Ce.width,Ce.height);for(let le=0;le<6;le++){Ae=ue[le].mipmaps;for(let Re=0;Re<Ae.length;Re++){const Fe=Ae[Re];I.format!==Ln?Le!==null?Ve?t.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re,0,0,Fe.width,Fe.height,Le,Fe.data):t.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re,De,Fe.width,Fe.height,0,Fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ve?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re,0,0,Fe.width,Fe.height,Le,Ee,Fe.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re,De,Fe.width,Fe.height,0,Le,Ee,Fe.data)}}}else{Ae=I.mipmaps,Ve&&je&&(Ae.length>0&&Z++,t.texStorage2D(r.TEXTURE_CUBE_MAP,Z,De,ue[0].width,ue[0].height));for(let le=0;le<6;le++)if(we){Ve?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,ue[le].width,ue[le].height,Le,Ee,ue[le].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,De,ue[le].width,ue[le].height,0,Le,Ee,ue[le].data);for(let Re=0;Re<Ae.length;Re++){const tt=Ae[Re].image[le].image;Ve?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re+1,0,0,tt.width,tt.height,Le,Ee,tt.data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re+1,De,tt.width,tt.height,0,Le,Ee,tt.data)}}else{Ve?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,Le,Ee,ue[le]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,De,Le,Ee,ue[le]);for(let Re=0;Re<Ae.length;Re++){const Fe=Ae[Re];Ve?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re+1,0,0,Le,Ee,Fe.image[le]):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+le,Re+1,De,Le,Ee,Fe.image[le])}}}w(I,ze)&&S(r.TEXTURE_CUBE_MAP),pe.__version=de.version,I.onUpdate&&I.onUpdate(I)}B.__version=I.version}function te(B,I,$,he,de){const pe=s.convert($.format,$.colorSpace),Me=s.convert($.type),we=M($.internalFormat,pe,Me,$.colorSpace);n.get(I).__hasExternalTextures||(de===r.TEXTURE_3D||de===r.TEXTURE_2D_ARRAY?t.texImage3D(de,0,we,I.width,I.height,I.depth,0,pe,Me,null):t.texImage2D(de,0,we,I.width,I.height,0,pe,Me,null)),t.bindFramebuffer(r.FRAMEBUFFER,B),xe(I)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,he,de,n.get($).__webglTexture,0,fe(I)):(de===r.TEXTURE_2D||de>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,he,de,n.get($).__webglTexture,0),t.bindFramebuffer(r.FRAMEBUFFER,null)}function D(B,I,$){if(r.bindRenderbuffer(r.RENDERBUFFER,B),I.depthBuffer&&!I.stencilBuffer){let he=r.DEPTH_COMPONENT16;if($||xe(I)){const de=I.depthTexture;de&&de.isDepthTexture&&(de.type===Li?he=r.DEPTH_COMPONENT32F:de.type===tr&&(he=r.DEPTH_COMPONENT24));const pe=fe(I);xe(I)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,pe,he,I.width,I.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,pe,he,I.width,I.height)}else r.renderbufferStorage(r.RENDERBUFFER,he,I.width,I.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,B)}else if(I.depthBuffer&&I.stencilBuffer){const he=fe(I);$&&xe(I)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,he,r.DEPTH24_STENCIL8,I.width,I.height):xe(I)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,he,r.DEPTH24_STENCIL8,I.width,I.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,I.width,I.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,B)}else{const he=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let de=0;de<he.length;de++){const pe=he[de],Me=s.convert(pe.format,pe.colorSpace),we=s.convert(pe.type),ue=M(pe.internalFormat,Me,we,pe.colorSpace),Ce=fe(I);$&&xe(I)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Ce,ue,I.width,I.height):xe(I)?f.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ce,ue,I.width,I.height):r.renderbufferStorage(r.RENDERBUFFER,ue,I.width,I.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function Q(B,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(r.FRAMEBUFFER,B),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),U(I.depthTexture,0);const he=n.get(I.depthTexture).__webglTexture,de=fe(I);if(I.depthTexture.format===Tr)xe(I)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,he,0,de):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,he,0);else if(I.depthTexture.format===ms)xe(I)?f.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,he,0,de):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,he,0);else throw new Error("Unknown depthTexture format")}function j(B){const I=n.get(B),$=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");Q(I.__webglFramebuffer,B)}else if($){I.__webglDepthbuffer=[];for(let he=0;he<6;he++)t.bindFramebuffer(r.FRAMEBUFFER,I.__webglFramebuffer[he]),I.__webglDepthbuffer[he]=r.createRenderbuffer(),D(I.__webglDepthbuffer[he],B,!1)}else t.bindFramebuffer(r.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer=r.createRenderbuffer(),D(I.__webglDepthbuffer,B,!1);t.bindFramebuffer(r.FRAMEBUFFER,null)}function K(B,I,$){const he=n.get(B);I!==void 0&&te(he.__webglFramebuffer,B,B.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),$!==void 0&&j(B)}function W(B){const I=B.texture,$=n.get(B),he=n.get(I);B.addEventListener("dispose",P),B.isWebGLMultipleRenderTargets!==!0&&(he.__webglTexture===void 0&&(he.__webglTexture=r.createTexture()),he.__version=I.version,o.memory.textures++);const de=B.isWebGLCubeRenderTarget===!0,pe=B.isWebGLMultipleRenderTargets===!0,Me=x(B)||a;if(de){$.__webglFramebuffer=[];for(let we=0;we<6;we++)$.__webglFramebuffer[we]=r.createFramebuffer()}else{if($.__webglFramebuffer=r.createFramebuffer(),pe)if(i.drawBuffers){const we=B.texture;for(let ue=0,Ce=we.length;ue<Ce;ue++){const ze=n.get(we[ue]);ze.__webglTexture===void 0&&(ze.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&B.samples>0&&xe(B)===!1){const we=pe?I:[I];$.__webglMultisampledFramebuffer=r.createFramebuffer(),$.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,$.__webglMultisampledFramebuffer);for(let ue=0;ue<we.length;ue++){const Ce=we[ue];$.__webglColorRenderbuffer[ue]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,$.__webglColorRenderbuffer[ue]);const ze=s.convert(Ce.format,Ce.colorSpace),Le=s.convert(Ce.type),Ee=M(Ce.internalFormat,ze,Le,Ce.colorSpace,B.isXRRenderTarget===!0),De=fe(B);r.renderbufferStorageMultisample(r.RENDERBUFFER,De,Ee,B.width,B.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+ue,r.RENDERBUFFER,$.__webglColorRenderbuffer[ue])}r.bindRenderbuffer(r.RENDERBUFFER,null),B.depthBuffer&&($.__webglDepthRenderbuffer=r.createRenderbuffer(),D($.__webglDepthRenderbuffer,B,!0)),t.bindFramebuffer(r.FRAMEBUFFER,null)}}if(de){t.bindTexture(r.TEXTURE_CUBE_MAP,he.__webglTexture),ne(r.TEXTURE_CUBE_MAP,I,Me);for(let we=0;we<6;we++)te($.__webglFramebuffer[we],B,I,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+we);w(I,Me)&&S(r.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(pe){const we=B.texture;for(let ue=0,Ce=we.length;ue<Ce;ue++){const ze=we[ue],Le=n.get(ze);t.bindTexture(r.TEXTURE_2D,Le.__webglTexture),ne(r.TEXTURE_2D,ze,Me),te($.__webglFramebuffer,B,ze,r.COLOR_ATTACHMENT0+ue,r.TEXTURE_2D),w(ze,Me)&&S(r.TEXTURE_2D)}t.unbindTexture()}else{let we=r.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(a?we=B.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(we,he.__webglTexture),ne(we,I,Me),te($.__webglFramebuffer,B,I,r.COLOR_ATTACHMENT0,we),w(I,Me)&&S(we),t.unbindTexture()}B.depthBuffer&&j(B)}function ye(B){const I=x(B)||a,$=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let he=0,de=$.length;he<de;he++){const pe=$[he];if(w(pe,I)){const Me=B.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,we=n.get(pe).__webglTexture;t.bindTexture(Me,we),S(Me),t.unbindTexture()}}}function re(B){if(a&&B.samples>0&&xe(B)===!1){const I=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],$=B.width,he=B.height;let de=r.COLOR_BUFFER_BIT;const pe=[],Me=B.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,we=n.get(B),ue=B.isWebGLMultipleRenderTargets===!0;if(ue)for(let Ce=0;Ce<I.length;Ce++)t.bindFramebuffer(r.FRAMEBUFFER,we.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ce,r.RENDERBUFFER,null),t.bindFramebuffer(r.FRAMEBUFFER,we.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ce,r.TEXTURE_2D,null,0);t.bindFramebuffer(r.READ_FRAMEBUFFER,we.__webglMultisampledFramebuffer),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,we.__webglFramebuffer);for(let Ce=0;Ce<I.length;Ce++){pe.push(r.COLOR_ATTACHMENT0+Ce),B.depthBuffer&&pe.push(Me);const ze=we.__ignoreDepthValues!==void 0?we.__ignoreDepthValues:!1;if(ze===!1&&(B.depthBuffer&&(de|=r.DEPTH_BUFFER_BIT),B.stencilBuffer&&(de|=r.STENCIL_BUFFER_BIT)),ue&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,we.__webglColorRenderbuffer[Ce]),ze===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[Me]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[Me])),ue){const Le=n.get(I[Ce]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,Le,0)}r.blitFramebuffer(0,0,$,he,0,0,$,he,de,r.NEAREST),d&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,pe)}if(t.bindFramebuffer(r.READ_FRAMEBUFFER,null),t.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),ue)for(let Ce=0;Ce<I.length;Ce++){t.bindFramebuffer(r.FRAMEBUFFER,we.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ce,r.RENDERBUFFER,we.__webglColorRenderbuffer[Ce]);const ze=n.get(I[Ce]).__webglTexture;t.bindFramebuffer(r.FRAMEBUFFER,we.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+Ce,r.TEXTURE_2D,ze,0)}t.bindFramebuffer(r.DRAW_FRAMEBUFFER,we.__webglMultisampledFramebuffer)}}function fe(B){return Math.min(h,B.samples)}function xe(B){const I=n.get(B);return a&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function ce(B){const I=o.render.frame;m.get(B)!==I&&(m.set(B,I),B.update())}function Pe(B,I){const $=B.colorSpace,he=B.format,de=B.type;return B.isCompressedTexture===!0||B.format===yu||$!==xi&&$!==Cr&&($===et?a===!1?e.has("EXT_sRGB")===!0&&he===Ln?(B.format=yu,B.minFilter=Pt,B.generateMipmaps=!1):I=im.sRGBToLinear(I):(he!==Ln||de!==Ii)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",$)),I}this.allocateTextureUnit=O,this.resetTextureUnits=C,this.setTexture2D=U,this.setTexture2DArray=R,this.setTexture3D=F,this.setTextureCube=H,this.rebindTextures=K,this.setupRenderTarget=W,this.updateRenderTargetMipmap=ye,this.updateMultisampleRenderTarget=re,this.setupDepthRenderbuffer=j,this.setupFrameBufferTexture=te,this.useMultisampledRTT=xe}function tb(r,e,t){const n=t.isWebGL2;function i(s,o=Cr){let a;if(s===Ii)return r.UNSIGNED_BYTE;if(s===Yp)return r.UNSIGNED_SHORT_4_4_4_4;if(s===jp)return r.UNSIGNED_SHORT_5_5_5_1;if(s===bx)return r.BYTE;if(s===wx)return r.SHORT;if(s===Nu)return r.UNSIGNED_SHORT;if(s===qp)return r.INT;if(s===tr)return r.UNSIGNED_INT;if(s===Li)return r.FLOAT;if(s===Ao)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===Sx)return r.ALPHA;if(s===Ln)return r.RGBA;if(s===Ex)return r.LUMINANCE;if(s===Mx)return r.LUMINANCE_ALPHA;if(s===Tr)return r.DEPTH_COMPONENT;if(s===ms)return r.DEPTH_STENCIL;if(s===yu)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===Tx)return r.RED;if(s===$p)return r.RED_INTEGER;if(s===Ax)return r.RG;if(s===Zp)return r.RG_INTEGER;if(s===Kp)return r.RGBA_INTEGER;if(s===iu||s===ru||s===su||s===ou)if(o===et)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===iu)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ru)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===su)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===ou)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===iu)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ru)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===su)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===ou)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===zd||s===Bd||s===Gd||s===Vd)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===zd)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Bd)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Gd)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Vd)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===Cx)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Hd||s===Wd)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Hd)return o===et?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Wd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Xd||s===qd||s===Yd||s===jd||s===$d||s===Zd||s===Kd||s===Jd||s===Qd||s===ep||s===tp||s===np||s===ip||s===rp)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Xd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===qd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Yd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===jd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===$d)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Zd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Kd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Jd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Qd)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===ep)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===tp)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===np)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===ip)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===rp)return o===et?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===au)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===au)return o===et?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===Rx||s===sp||s===op||s===ap)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===au)return a.COMPRESSED_RED_RGTC1_EXT;if(s===sp)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===op)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===ap)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Mr?n?r.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}class nb extends Zt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class yo extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const RR={type:"move"};class yf{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new yo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new yo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new G,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new G),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new yo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new G,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new G),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const v of e.hand.values()){const g=t.getJointPose(v,n),p=this._getHandJoint(l,v);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,m=.005;l.inputState.pinching&&f>d+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(RR)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new yo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class ib extends Ft{constructor(e,t,n,i,s,o,a,c,l,u){if(u=u!==void 0?u:Tr,u!==Tr&&u!==ms)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Tr&&(n=tr),n===void 0&&u===ms&&(n=Mr),super(null,i,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Yt,this.minFilter=c!==void 0?c:Yt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class PR extends ar{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,d=null,m=null;const v=t.getContextAttributes();let g=null,p=null;const _=[],y=[],x=new Zt;x.layers.enable(1),x.viewport=new mt;const b=new Zt;b.layers.enable(2),b.viewport=new mt;const w=[x,b],S=new nb;S.layers.enable(1),S.layers.enable(2);let M=null,E=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(R){let F=_[R];return F===void 0&&(F=new yf,_[R]=F),F.getTargetRaySpace()},this.getControllerGrip=function(R){let F=_[R];return F===void 0&&(F=new yf,_[R]=F),F.getGripSpace()},this.getHand=function(R){let F=_[R];return F===void 0&&(F=new yf,_[R]=F),F.getHandSpace()};function T(R){const F=y.indexOf(R.inputSource);if(F===-1)return;const H=_[F];H!==void 0&&(H.update(R.inputSource,R.frame,l||o),H.dispatchEvent({type:R.type,data:R.inputSource}))}function L(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",L),i.removeEventListener("inputsourceschange",P);for(let R=0;R<_.length;R++){const F=y[R];F!==null&&(y[R]=null,_[R].disconnect(F))}M=null,E=null,e.setRenderTarget(g),d=null,f=null,h=null,i=null,p=null,U.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(R){s=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(R){a=R,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(R){l=R},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return i},this.setSession=async function(R){if(i=R,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",L),i.addEventListener("inputsourceschange",P),v.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const F={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,F),i.updateRenderState({baseLayer:d}),p=new bi(d.framebufferWidth,d.framebufferHeight,{format:Ln,type:Ii,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let F=null,H=null,Y=null;v.depth&&(Y=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,F=v.stencil?ms:Tr,H=v.stencil?Mr:tr);const J={colorFormat:t.RGBA8,depthFormat:Y,scaleFactor:s};h=new XRWebGLBinding(i,t),f=h.createProjectionLayer(J),i.updateRenderState({layers:[f]}),p=new bi(f.textureWidth,f.textureHeight,{format:Ln,type:Ii,depthTexture:new ib(f.textureWidth,f.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const ie=e.properties.get(p);ie.__ignoreDepthValues=f.ignoreDepthValues}p.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),U.setContext(i),U.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function P(R){for(let F=0;F<R.removed.length;F++){const H=R.removed[F],Y=y.indexOf(H);Y>=0&&(y[Y]=null,_[Y].disconnect(H))}for(let F=0;F<R.added.length;F++){const H=R.added[F];let Y=y.indexOf(H);if(Y===-1){for(let ie=0;ie<_.length;ie++)if(ie>=y.length){y.push(H),Y=ie;break}else if(y[ie]===null){y[ie]=H,Y=ie;break}if(Y===-1)break}const J=_[Y];J&&J.connect(H)}}const A=new G,z=new G;function V(R,F,H){A.setFromMatrixPosition(F.matrixWorld),z.setFromMatrixPosition(H.matrixWorld);const Y=A.distanceTo(z),J=F.projectionMatrix.elements,ie=H.projectionMatrix.elements,ne=J[14]/(J[10]-1),ee=J[14]/(J[10]+1),ge=(J[9]+1)/J[5],me=(J[9]-1)/J[5],te=(J[8]-1)/J[0],D=(ie[8]+1)/ie[0],Q=ne*te,j=ne*D,K=Y/(-te+D),W=K*-te;F.matrixWorld.decompose(R.position,R.quaternion,R.scale),R.translateX(W),R.translateZ(K),R.matrixWorld.compose(R.position,R.quaternion,R.scale),R.matrixWorldInverse.copy(R.matrixWorld).invert();const ye=ne+K,re=ee+K,fe=Q-W,xe=j+(Y-W),ce=ge*ee/re*ye,Pe=me*ee/re*ye;R.projectionMatrix.makePerspective(fe,xe,ce,Pe,ye,re),R.projectionMatrixInverse.copy(R.projectionMatrix).invert()}function N(R,F){F===null?R.matrixWorld.copy(R.matrix):R.matrixWorld.multiplyMatrices(F.matrixWorld,R.matrix),R.matrixWorldInverse.copy(R.matrixWorld).invert()}this.updateCamera=function(R){if(i===null)return;S.near=b.near=x.near=R.near,S.far=b.far=x.far=R.far,(M!==S.near||E!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),M=S.near,E=S.far);const F=R.parent,H=S.cameras;N(S,F);for(let Y=0;Y<H.length;Y++)N(H[Y],F);H.length===2?V(S,x,b):S.projectionMatrix.copy(x.projectionMatrix),C(R,S,F)};function C(R,F,H){H===null?R.matrix.copy(F.matrixWorld):(R.matrix.copy(H.matrixWorld),R.matrix.invert(),R.matrix.multiply(F.matrixWorld)),R.matrix.decompose(R.position,R.quaternion,R.scale),R.updateMatrixWorld(!0);const Y=R.children;for(let J=0,ie=Y.length;J<ie;J++)Y[J].updateMatrixWorld(!0);R.projectionMatrix.copy(F.projectionMatrix),R.projectionMatrixInverse.copy(F.projectionMatrixInverse),R.isPerspectiveCamera&&(R.fov=Co*2*Math.atan(1/R.projectionMatrix.elements[5]),R.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(R){c=R,f!==null&&(f.fixedFoveation=R),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=R)};let O=null;function k(R,F){if(u=F.getViewerPose(l||o),m=F,u!==null){const H=u.views;d!==null&&(e.setRenderTargetFramebuffer(p,d.framebuffer),e.setRenderTarget(p));let Y=!1;H.length!==S.cameras.length&&(S.cameras.length=0,Y=!0);for(let J=0;J<H.length;J++){const ie=H[J];let ne=null;if(d!==null)ne=d.getViewport(ie);else{const ge=h.getViewSubImage(f,ie);ne=ge.viewport,J===0&&(e.setRenderTargetTextures(p,ge.colorTexture,f.ignoreDepthValues?void 0:ge.depthStencilTexture),e.setRenderTarget(p))}let ee=w[J];ee===void 0&&(ee=new Zt,ee.layers.enable(J),ee.viewport=new mt,w[J]=ee),ee.matrix.fromArray(ie.transform.matrix),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.projectionMatrix.fromArray(ie.projectionMatrix),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert(),ee.viewport.set(ne.x,ne.y,ne.width,ne.height),J===0&&(S.matrix.copy(ee.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),Y===!0&&S.cameras.push(ee)}}for(let H=0;H<_.length;H++){const Y=y[H],J=_[H];Y!==null&&J!==void 0&&J.update(Y,F,l||o)}O&&O(R,F),F.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:F}),m=null}const U=new Zx;U.setAnimationLoop(k),this.setAnimationLoop=function(R){O=R},this.dispose=function(){}}}function LR(r,e){function t(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function n(g,p){p.color.getRGB(g.fogColor.value,Yx(r)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function i(g,p,_,y,x){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(g,p):p.isMeshToonMaterial?(s(g,p),h(g,p)):p.isMeshPhongMaterial?(s(g,p),u(g,p)):p.isMeshStandardMaterial?(s(g,p),f(g,p),p.isMeshPhysicalMaterial&&d(g,p,x)):p.isMeshMatcapMaterial?(s(g,p),m(g,p)):p.isMeshDepthMaterial?s(g,p):p.isMeshDistanceMaterial?(s(g,p),v(g,p)):p.isMeshNormalMaterial?s(g,p):p.isLineBasicMaterial?(o(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?c(g,p,_,y):p.isSpriteMaterial?l(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,t(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===vn&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,t(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===vn&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,t(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,t(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);const _=e.get(p).envMap;if(_&&(g.envMap.value=_,g.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap){g.lightMap.value=p.lightMap;const y=r.useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=p.lightMapIntensity*y,t(p.lightMap,g.lightMapTransform)}p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,_,y){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*_,g.scale.value=y*.5,p.map&&(g.map.value=p.map,t(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function l(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function h(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function f(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,g.roughnessMapTransform)),e.get(p).envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function d(g,p,_){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===vn&&g.clearcoatNormalScale.value.negate())),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=_.texture,g.transmissionSamplerSize.value.set(_.width,_.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function v(g,p){const _=e.get(p).light;g.referencePosition.value.setFromMatrixPosition(_.matrixWorld),g.nearDistance.value=_.shadow.camera.near,g.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function DR(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(_,y){const x=y.program;n.uniformBlockBinding(_,x)}function l(_,y){let x=i[_.id];x===void 0&&(m(_),x=u(_),i[_.id]=x,_.addEventListener("dispose",g));const b=y.program;n.updateUBOMapping(_,b);const w=e.render.frame;s[_.id]!==w&&(f(_),s[_.id]=w)}function u(_){const y=h();_.__bindingPointIndex=y;const x=r.createBuffer(),b=_.__size,w=_.usage;return r.bindBuffer(r.UNIFORM_BUFFER,x),r.bufferData(r.UNIFORM_BUFFER,b,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,y,x),x}function h(){for(let _=0;_<a;_++)if(o.indexOf(_)===-1)return o.push(_),_;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(_){const y=i[_.id],x=_.uniforms,b=_.__cache;r.bindBuffer(r.UNIFORM_BUFFER,y);for(let w=0,S=x.length;w<S;w++){const M=x[w];if(d(M,w,b)===!0){const E=M.__offset,T=Array.isArray(M.value)?M.value:[M.value];let L=0;for(let P=0;P<T.length;P++){const A=T[P],z=v(A);typeof A=="number"?(M.__data[0]=A,r.bufferSubData(r.UNIFORM_BUFFER,E+L,M.__data)):A.isMatrix3?(M.__data[0]=A.elements[0],M.__data[1]=A.elements[1],M.__data[2]=A.elements[2],M.__data[3]=A.elements[0],M.__data[4]=A.elements[3],M.__data[5]=A.elements[4],M.__data[6]=A.elements[5],M.__data[7]=A.elements[0],M.__data[8]=A.elements[6],M.__data[9]=A.elements[7],M.__data[10]=A.elements[8],M.__data[11]=A.elements[0]):(A.toArray(M.__data,L),L+=z.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,E,M.__data)}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function d(_,y,x){const b=_.value;if(x[y]===void 0){if(typeof b=="number")x[y]=b;else{const w=Array.isArray(b)?b:[b],S=[];for(let M=0;M<w.length;M++)S.push(w[M].clone());x[y]=S}return!0}else if(typeof b=="number"){if(x[y]!==b)return x[y]=b,!0}else{const w=Array.isArray(x[y])?x[y]:[x[y]],S=Array.isArray(b)?b:[b];for(let M=0;M<w.length;M++){const E=w[M];if(E.equals(S[M])===!1)return E.copy(S[M]),!0}}return!1}function m(_){const y=_.uniforms;let x=0;const b=16;let w=0;for(let S=0,M=y.length;S<M;S++){const E=y[S],T={boundary:0,storage:0},L=Array.isArray(E.value)?E.value:[E.value];for(let P=0,A=L.length;P<A;P++){const z=L[P],V=v(z);T.boundary+=V.boundary,T.storage+=V.storage}if(E.__data=new Float32Array(T.storage/Float32Array.BYTES_PER_ELEMENT),E.__offset=x,S>0){w=x%b;const P=b-w;w!==0&&P-T.boundary<0&&(x+=b-w,E.__offset=x)}x+=T.storage}return w=x%b,w>0&&(x+=b-w),_.__size=x,_.__cache={},this}function v(_){const y={boundary:0,storage:0};return typeof _=="number"?(y.boundary=4,y.storage=4):_.isVector2?(y.boundary=8,y.storage=8):_.isVector3||_.isColor?(y.boundary=16,y.storage=12):_.isVector4?(y.boundary=16,y.storage=16):_.isMatrix3?(y.boundary=48,y.storage=48):_.isMatrix4?(y.boundary=64,y.storage=64):_.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",_),y}function g(_){const y=_.target;y.removeEventListener("dispose",g);const x=o.indexOf(y.__bindingPointIndex);o.splice(x,1),r.deleteBuffer(i[y.id]),delete i[y.id],delete s[y.id]}function p(){for(const _ in i)r.deleteBuffer(i[_]);o=[],i={},s={}}return{bind:c,update:l,dispose:p}}function IR(){const r=oc("canvas");return r.style.display="block",r}class lm{constructor(e={}){const{canvas:t=IR(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=o;const d=new Uint32Array(4),m=new Int32Array(4);let v=null,g=null;const p=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=et,this.useLegacyLights=!0,this.toneMapping=yi,this.toneMappingExposure=1;const y=this;let x=!1,b=0,w=0,S=null,M=-1,E=null;const T=new mt,L=new mt;let P=null;const A=new Ne(0);let z=0,V=t.width,N=t.height,C=1,O=null,k=null;const U=new mt(0,0,V,N),R=new mt(0,0,V,N);let F=!1;const H=new zu;let Y=!1,J=!1,ie=null;const ne=new Ke,ee=new be,ge=new G,me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function te(){return S===null?C:1}let D=n;function Q(X,ae){for(let ve=0;ve<X.length;ve++){const se=X[ve],_e=t.getContext(se,ae);if(_e!==null)return _e}return null}try{const X={alpha:!0,depth:i,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Iu}`),t.addEventListener("webglcontextlost",Ae,!1),t.addEventListener("webglcontextrestored",le,!1),t.addEventListener("webglcontextcreationerror",Re,!1),D===null){const ae=["webgl2","webgl","experimental-webgl"];if(y.isWebGL1Renderer===!0&&ae.shift(),D=Q(ae,X),D===null)throw Q(ae)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&D instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),D.getShaderPrecisionFormat===void 0&&(D.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(X){throw console.error("THREE.WebGLRenderer: "+X.message),X}let j,K,W,ye,re,fe,xe,ce,Pe,B,I,$,he,de,pe,Me,we,ue,Ce,ze,Le,Ee,De,Ve;function je(){j=new j2(D),K=new V2(D,j,e),j.init(K),Ee=new tb(D,j,K),W=new AR(D,j,K),ye=new K2(D),re=new mR,fe=new CR(D,j,W,re,K,Ee,ye),xe=new W2(y),ce=new Y2(y),Pe=new aT(D,K),De=new B2(D,j,Pe,K),B=new $2(D,Pe,ye,De),I=new tC(D,B,Pe,ye),Ce=new eC(D,K,fe),Me=new H2(re),$=new pR(y,xe,ce,j,K,De,Me),he=new LR(y,re),de=new vR,pe=new SR(j,K),ue=new z2(y,xe,ce,W,I,f,c),we=new TR(y,I,K),Ve=new DR(D,ye,K,W),ze=new G2(D,j,ye,K),Le=new Z2(D,j,ye,K),ye.programs=$.programs,y.capabilities=K,y.extensions=j,y.properties=re,y.renderLists=de,y.shadowMap=we,y.state=W,y.info=ye}je();const Z=new PR(y,D);this.xr=Z,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const X=j.get("WEBGL_lose_context");X&&X.loseContext()},this.forceContextRestore=function(){const X=j.get("WEBGL_lose_context");X&&X.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(X){X!==void 0&&(C=X,this.setSize(V,N,!1))},this.getSize=function(X){return X.set(V,N)},this.setSize=function(X,ae,ve=!0){if(Z.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=X,N=ae,t.width=Math.floor(X*C),t.height=Math.floor(ae*C),ve===!0&&(t.style.width=X+"px",t.style.height=ae+"px"),this.setViewport(0,0,X,ae)},this.getDrawingBufferSize=function(X){return X.set(V*C,N*C).floor()},this.setDrawingBufferSize=function(X,ae,ve){V=X,N=ae,C=ve,t.width=Math.floor(X*ve),t.height=Math.floor(ae*ve),this.setViewport(0,0,X,ae)},this.getCurrentViewport=function(X){return X.copy(T)},this.getViewport=function(X){return X.copy(U)},this.setViewport=function(X,ae,ve,se){X.isVector4?U.set(X.x,X.y,X.z,X.w):U.set(X,ae,ve,se),W.viewport(T.copy(U).multiplyScalar(C).floor())},this.getScissor=function(X){return X.copy(R)},this.setScissor=function(X,ae,ve,se){X.isVector4?R.set(X.x,X.y,X.z,X.w):R.set(X,ae,ve,se),W.scissor(L.copy(R).multiplyScalar(C).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(X){W.setScissorTest(F=X)},this.setOpaqueSort=function(X){O=X},this.setTransparentSort=function(X){k=X},this.getClearColor=function(X){return X.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(X=!0,ae=!0,ve=!0){let se=0;if(X){let _e=!1;if(S!==null){const Ge=S.texture.format;_e=Ge===Kp||Ge===Zp||Ge===$p}if(_e){const Ge=S.texture.type,We=Ge===Ii||Ge===tr||Ge===Nu||Ge===Mr||Ge===Yp||Ge===jp,qe=ue.getClearColor(),Ye=ue.getClearAlpha(),nt=qe.r,Te=qe.g,Ze=qe.b;We?(d[0]=nt,d[1]=Te,d[2]=Ze,d[3]=Ye,D.clearBufferuiv(D.COLOR,0,d)):(m[0]=nt,m[1]=Te,m[2]=Ze,m[3]=Ye,D.clearBufferiv(D.COLOR,0,m))}else se|=D.COLOR_BUFFER_BIT}ae&&(se|=D.DEPTH_BUFFER_BIT),ve&&(se|=D.STENCIL_BUFFER_BIT),D.clear(se)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ae,!1),t.removeEventListener("webglcontextrestored",le,!1),t.removeEventListener("webglcontextcreationerror",Re,!1),de.dispose(),pe.dispose(),re.dispose(),xe.dispose(),ce.dispose(),I.dispose(),De.dispose(),Ve.dispose(),$.dispose(),Z.dispose(),Z.removeEventListener("sessionstart",xt),Z.removeEventListener("sessionend",dt),ie&&(ie.dispose(),ie=null),ct.stop()};function Ae(X){X.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function le(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const X=ye.autoReset,ae=we.enabled,ve=we.autoUpdate,se=we.needsUpdate,_e=we.type;je(),ye.autoReset=X,we.enabled=ae,we.autoUpdate=ve,we.needsUpdate=se,we.type=_e}function Re(X){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",X.statusMessage)}function Fe(X){const ae=X.target;ae.removeEventListener("dispose",Fe),tt(ae)}function tt(X){lt(X),re.remove(X)}function lt(X){const ae=re.get(X).programs;ae!==void 0&&(ae.forEach(function(ve){$.releaseProgram(ve)}),X.isShaderMaterial&&$.releaseShaderCache(X))}this.renderBufferDirect=function(X,ae,ve,se,_e,Ge){ae===null&&(ae=me);const We=_e.isMesh&&_e.matrixWorld.determinant()<0,qe=sn(X,ae,ve,se,_e);W.setMaterial(se,We);let Ye=ve.index,nt=1;se.wireframe===!0&&(Ye=B.getWireframeAttribute(ve),nt=2);const Te=ve.drawRange,Ze=ve.attributes.position;let At=Te.start*nt,bt=(Te.start+Te.count)*nt;Ge!==null&&(At=Math.max(At,Ge.start*nt),bt=Math.min(bt,(Ge.start+Ge.count)*nt)),Ye!==null?(At=Math.max(At,0),bt=Math.min(bt,Ye.count)):Ze!=null&&(At=Math.max(At,0),bt=Math.min(bt,Ze.count));const dn=bt-At;if(dn<0||dn===1/0)return;De.setup(_e,se,qe,ve,Ye);let Xn,Ct=ze;if(Ye!==null&&(Xn=Pe.get(Ye),Ct=Le,Ct.setIndex(Xn)),_e.isMesh)se.wireframe===!0?(W.setLineWidth(se.wireframeLinewidth*te()),Ct.setMode(D.LINES)):Ct.setMode(D.TRIANGLES);else if(_e.isLine){let at=se.linewidth;at===void 0&&(at=1),W.setLineWidth(at*te()),_e.isLineSegments?Ct.setMode(D.LINES):_e.isLineLoop?Ct.setMode(D.LINE_LOOP):Ct.setMode(D.LINE_STRIP)}else _e.isPoints?Ct.setMode(D.POINTS):_e.isSprite&&Ct.setMode(D.TRIANGLES);if(_e.isInstancedMesh)Ct.renderInstances(At,dn,_e.count);else if(ve.isInstancedBufferGeometry){const at=ve._maxInstanceCount!==void 0?ve._maxInstanceCount:1/0,fr=Math.min(ve.instanceCount,at);Ct.renderInstances(At,dn,fr)}else Ct.render(At,dn)},this.compile=function(X,ae){function ve(se,_e,Ge){se.transparent===!0&&se.side===Dt&&se.forceSinglePass===!1?(se.side=vn,se.needsUpdate=!0,Vt(se,_e,Ge),se.side=Oi,se.needsUpdate=!0,Vt(se,_e,Ge),se.side=Dt):Vt(se,_e,Ge)}g=pe.get(X),g.init(),_.push(g),X.traverseVisible(function(se){se.isLight&&se.layers.test(ae.layers)&&(g.pushLight(se),se.castShadow&&g.pushShadow(se))}),g.setupLights(y.useLegacyLights),X.traverse(function(se){const _e=se.material;if(_e)if(Array.isArray(_e))for(let Ge=0;Ge<_e.length;Ge++){const We=_e[Ge];ve(We,X,se)}else ve(_e,X,se)}),_.pop(),g=null};let ft=null;function ut(X){ft&&ft(X)}function xt(){ct.stop()}function dt(){ct.start()}const ct=new Zx;ct.setAnimationLoop(ut),typeof self<"u"&&ct.setContext(self),this.setAnimationLoop=function(X){ft=X,Z.setAnimationLoop(X),X===null?ct.stop():ct.start()},Z.addEventListener("sessionstart",xt),Z.addEventListener("sessionend",dt),this.render=function(X,ae){if(ae!==void 0&&ae.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(x===!0)return;X.matrixWorldAutoUpdate===!0&&X.updateMatrixWorld(),ae.parent===null&&ae.matrixWorldAutoUpdate===!0&&ae.updateMatrixWorld(),Z.enabled===!0&&Z.isPresenting===!0&&(Z.cameraAutoUpdate===!0&&Z.updateCamera(ae),ae=Z.getCamera()),X.isScene===!0&&X.onBeforeRender(y,X,ae,S),g=pe.get(X,_.length),g.init(),_.push(g),ne.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),H.setFromProjectionMatrix(ne),J=this.localClippingEnabled,Y=Me.init(this.clippingPlanes,J),v=de.get(X,p.length),v.init(),p.push(v),Mn(X,ae,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(O,k),this.info.render.frame++,Y===!0&&Me.beginShadows();const ve=g.state.shadowsArray;if(we.render(ve,X,ae),Y===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(v,X),g.setupLights(y.useLegacyLights),ae.isArrayCamera){const se=ae.cameras;for(let _e=0,Ge=se.length;_e<Ge;_e++){const We=se[_e];fn(v,X,We,We.viewport)}}else fn(v,X,ae);S!==null&&(fe.updateMultisampleRenderTarget(S),fe.updateRenderTargetMipmap(S)),X.isScene===!0&&X.onAfterRender(y,X,ae),De.resetDefaultState(),M=-1,E=null,_.pop(),_.length>0?g=_[_.length-1]:g=null,p.pop(),p.length>0?v=p[p.length-1]:v=null};function Mn(X,ae,ve,se){if(X.visible===!1)return;if(X.layers.test(ae.layers)){if(X.isGroup)ve=X.renderOrder;else if(X.isLOD)X.autoUpdate===!0&&X.update(ae);else if(X.isLight)g.pushLight(X),X.castShadow&&g.pushShadow(X);else if(X.isSprite){if(!X.frustumCulled||H.intersectsSprite(X)){se&&ge.setFromMatrixPosition(X.matrixWorld).applyMatrix4(ne);const We=I.update(X),qe=X.material;qe.visible&&v.push(X,We,qe,ve,ge.z,null)}}else if((X.isMesh||X.isLine||X.isPoints)&&(!X.frustumCulled||H.intersectsObject(X))){const We=I.update(X),qe=X.material;if(se&&(X.boundingSphere!==void 0?(X.boundingSphere===null&&X.computeBoundingSphere(),ge.copy(X.boundingSphere.center)):(We.boundingSphere===null&&We.computeBoundingSphere(),ge.copy(We.boundingSphere.center)),ge.applyMatrix4(X.matrixWorld).applyMatrix4(ne)),Array.isArray(qe)){const Ye=We.groups;for(let nt=0,Te=Ye.length;nt<Te;nt++){const Ze=Ye[nt],At=qe[Ze.materialIndex];At&&At.visible&&v.push(X,We,At,ve,ge.z,Ze)}}else qe.visible&&v.push(X,We,qe,ve,ge.z,null)}}const Ge=X.children;for(let We=0,qe=Ge.length;We<qe;We++)Mn(Ge[We],ae,ve,se)}function fn(X,ae,ve,se){const _e=X.opaque,Ge=X.transmissive,We=X.transparent;g.setupLightsView(ve),Y===!0&&Me.setGlobalState(y.clippingPlanes,ve),Ge.length>0&&yt(_e,Ge,ae,ve),se&&W.viewport(T.copy(se)),_e.length>0&&kt(_e,ae,ve),Ge.length>0&&kt(Ge,ae,ve),We.length>0&&kt(We,ae,ve),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function yt(X,ae,ve,se){const _e=K.isWebGL2;ie===null&&(ie=new bi(1,1,{generateMipmaps:!0,type:j.has("EXT_color_buffer_half_float")?Ao:Ii,minFilter:Dr,samples:_e?4:0})),y.getDrawingBufferSize(ee),_e?ie.setSize(ee.x,ee.y):ie.setSize(xu(ee.x),xu(ee.y));const Ge=y.getRenderTarget();y.setRenderTarget(ie),y.getClearColor(A),z=y.getClearAlpha(),z<1&&y.setClearColor(16777215,.5),y.clear();const We=y.toneMapping;y.toneMapping=yi,kt(X,ve,se),fe.updateMultisampleRenderTarget(ie),fe.updateRenderTargetMipmap(ie);let qe=!1;for(let Ye=0,nt=ae.length;Ye<nt;Ye++){const Te=ae[Ye],Ze=Te.object,At=Te.geometry,bt=Te.material,dn=Te.group;if(bt.side===Dt&&Ze.layers.test(se.layers)){const Xn=bt.side;bt.side=vn,bt.needsUpdate=!0,yn(Ze,ve,se,At,bt,dn),bt.side=Xn,bt.needsUpdate=!0,qe=!0}}qe===!0&&(fe.updateMultisampleRenderTarget(ie),fe.updateRenderTargetMipmap(ie)),y.setRenderTarget(Ge),y.setClearColor(A,z),y.toneMapping=We}function kt(X,ae,ve){const se=ae.isScene===!0?ae.overrideMaterial:null;for(let _e=0,Ge=X.length;_e<Ge;_e++){const We=X[_e],qe=We.object,Ye=We.geometry,nt=se===null?We.material:se,Te=We.group;qe.layers.test(ve.layers)&&yn(qe,ae,ve,Ye,nt,Te)}}function yn(X,ae,ve,se,_e,Ge){X.onBeforeRender(y,ae,ve,se,_e,Ge),X.modelViewMatrix.multiplyMatrices(ve.matrixWorldInverse,X.matrixWorld),X.normalMatrix.getNormalMatrix(X.modelViewMatrix),_e.onBeforeRender(y,ae,ve,se,X,Ge),_e.transparent===!0&&_e.side===Dt&&_e.forceSinglePass===!1?(_e.side=vn,_e.needsUpdate=!0,y.renderBufferDirect(ve,ae,se,_e,X,Ge),_e.side=Oi,_e.needsUpdate=!0,y.renderBufferDirect(ve,ae,se,_e,X,Ge),_e.side=Dt):y.renderBufferDirect(ve,ae,se,_e,X,Ge),X.onAfterRender(y,ae,ve,se,_e,Ge)}function Vt(X,ae,ve){ae.isScene!==!0&&(ae=me);const se=re.get(X),_e=g.state.lights,Ge=g.state.shadowsArray,We=_e.state.version,qe=$.getParameters(X,_e.state,Ge,ae,ve),Ye=$.getProgramCacheKey(qe);let nt=se.programs;se.environment=X.isMeshStandardMaterial?ae.environment:null,se.fog=ae.fog,se.envMap=(X.isMeshStandardMaterial?ce:xe).get(X.envMap||se.environment),nt===void 0&&(X.addEventListener("dispose",Fe),nt=new Map,se.programs=nt);let Te=nt.get(Ye);if(Te!==void 0){if(se.currentProgram===Te&&se.lightsStateVersion===We)return Ht(X,qe),Te}else qe.uniforms=$.getUniforms(X),X.onBuild(ve,qe,y),X.onBeforeCompile(qe,y),Te=$.acquireProgram(qe,Ye),nt.set(Ye,Te),se.uniforms=qe.uniforms;const Ze=se.uniforms;(!X.isShaderMaterial&&!X.isRawShaderMaterial||X.clipping===!0)&&(Ze.clippingPlanes=Me.uniform),Ht(X,qe),se.needsLights=Un(X),se.lightsStateVersion=We,se.needsLights&&(Ze.ambientLightColor.value=_e.state.ambient,Ze.lightProbe.value=_e.state.probe,Ze.directionalLights.value=_e.state.directional,Ze.directionalLightShadows.value=_e.state.directionalShadow,Ze.spotLights.value=_e.state.spot,Ze.spotLightShadows.value=_e.state.spotShadow,Ze.rectAreaLights.value=_e.state.rectArea,Ze.ltc_1.value=_e.state.rectAreaLTC1,Ze.ltc_2.value=_e.state.rectAreaLTC2,Ze.pointLights.value=_e.state.point,Ze.pointLightShadows.value=_e.state.pointShadow,Ze.hemisphereLights.value=_e.state.hemi,Ze.directionalShadowMap.value=_e.state.directionalShadowMap,Ze.directionalShadowMatrix.value=_e.state.directionalShadowMatrix,Ze.spotShadowMap.value=_e.state.spotShadowMap,Ze.spotLightMatrix.value=_e.state.spotLightMatrix,Ze.spotLightMap.value=_e.state.spotLightMap,Ze.pointShadowMap.value=_e.state.pointShadowMap,Ze.pointShadowMatrix.value=_e.state.pointShadowMatrix);const At=Te.getUniforms(),bt=uu.seqWithValue(At.seq,Ze);return se.currentProgram=Te,se.uniformsList=bt,Te}function Ht(X,ae){const ve=re.get(X);ve.outputColorSpace=ae.outputColorSpace,ve.instancing=ae.instancing,ve.skinning=ae.skinning,ve.morphTargets=ae.morphTargets,ve.morphNormals=ae.morphNormals,ve.morphColors=ae.morphColors,ve.morphTargetsCount=ae.morphTargetsCount,ve.numClippingPlanes=ae.numClippingPlanes,ve.numIntersection=ae.numClipIntersection,ve.vertexAlphas=ae.vertexAlphas,ve.vertexTangents=ae.vertexTangents,ve.toneMapping=ae.toneMapping}function sn(X,ae,ve,se,_e){ae.isScene!==!0&&(ae=me),fe.resetTextureUnits();const Ge=ae.fog,We=se.isMeshStandardMaterial?ae.environment:null,qe=S===null?y.outputColorSpace:S.isXRRenderTarget===!0?S.texture.colorSpace:xi,Ye=(se.isMeshStandardMaterial?ce:xe).get(se.envMap||We),nt=se.vertexColors===!0&&!!ve.attributes.color&&ve.attributes.color.itemSize===4,Te=!!ve.attributes.tangent&&(!!se.normalMap||se.anisotropy>0),Ze=!!ve.morphAttributes.position,At=!!ve.morphAttributes.normal,bt=!!ve.morphAttributes.color,dn=se.toneMapped?y.toneMapping:yi,Xn=ve.morphAttributes.position||ve.morphAttributes.normal||ve.morphAttributes.color,Ct=Xn!==void 0?Xn.length:0,at=re.get(se),fr=g.state.lights;if(Y===!0&&(J===!0||X!==E)){const on=X===E&&se.id===M;Me.setState(se,X,on)}let Wt=!1;se.version===at.__version?(at.needsLights&&at.lightsStateVersion!==fr.state.version||at.outputColorSpace!==qe||_e.isInstancedMesh&&at.instancing===!1||!_e.isInstancedMesh&&at.instancing===!0||_e.isSkinnedMesh&&at.skinning===!1||!_e.isSkinnedMesh&&at.skinning===!0||at.envMap!==Ye||se.fog===!0&&at.fog!==Ge||at.numClippingPlanes!==void 0&&(at.numClippingPlanes!==Me.numPlanes||at.numIntersection!==Me.numIntersection)||at.vertexAlphas!==nt||at.vertexTangents!==Te||at.morphTargets!==Ze||at.morphNormals!==At||at.morphColors!==bt||at.toneMapping!==dn||K.isWebGL2===!0&&at.morphTargetsCount!==Ct)&&(Wt=!0):(Wt=!0,at.__version=se.version);let qn=at.currentProgram;Wt===!0&&(qn=Vt(se,ae,_e));let Vo=!1,Bi=!1,Rs=!1;const Xt=qn.getUniforms(),si=at.uniforms;if(W.useProgram(qn.program)&&(Vo=!0,Bi=!0,Rs=!0),se.id!==M&&(M=se.id,Bi=!0),Vo||E!==X){if(Xt.setValue(D,"projectionMatrix",X.projectionMatrix),K.logarithmicDepthBuffer&&Xt.setValue(D,"logDepthBufFC",2/(Math.log(X.far+1)/Math.LN2)),E!==X&&(E=X,Bi=!0,Rs=!0),se.isShaderMaterial||se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshStandardMaterial||se.envMap){const on=Xt.map.cameraPosition;on!==void 0&&on.setValue(D,ge.setFromMatrixPosition(X.matrixWorld))}(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial)&&Xt.setValue(D,"isOrthographic",X.isOrthographicCamera===!0),(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial||se.isShadowMaterial||_e.isSkinnedMesh)&&Xt.setValue(D,"viewMatrix",X.matrixWorldInverse)}if(_e.isSkinnedMesh){Xt.setOptional(D,_e,"bindMatrix"),Xt.setOptional(D,_e,"bindMatrixInverse");const on=_e.skeleton;on&&(K.floatVertexTextures?(on.boneTexture===null&&on.computeBoneTexture(),Xt.setValue(D,"boneTexture",on.boneTexture,fe),Xt.setValue(D,"boneTextureSize",on.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const Mi=ve.morphAttributes;if((Mi.position!==void 0||Mi.normal!==void 0||Mi.color!==void 0&&K.isWebGL2===!0)&&Ce.update(_e,ve,qn),(Bi||at.receiveShadow!==_e.receiveShadow)&&(at.receiveShadow=_e.receiveShadow,Xt.setValue(D,"receiveShadow",_e.receiveShadow)),se.isMeshGouraudMaterial&&se.envMap!==null&&(si.envMap.value=Ye,si.flipEnvMap.value=Ye.isCubeTexture&&Ye.isRenderTargetTexture===!1?-1:1),Bi&&(Xt.setValue(D,"toneMappingExposure",y.toneMappingExposure),at.needsLights&&Ei(si,Rs),Ge&&se.fog===!0&&he.refreshFogUniforms(si,Ge),he.refreshMaterialUniforms(si,se,C,N,ie),uu.upload(D,at.uniformsList,si,fe)),se.isShaderMaterial&&se.uniformsNeedUpdate===!0&&(uu.upload(D,at.uniformsList,si,fe),se.uniformsNeedUpdate=!1),se.isSpriteMaterial&&Xt.setValue(D,"center",_e.center),Xt.setValue(D,"modelViewMatrix",_e.modelViewMatrix),Xt.setValue(D,"normalMatrix",_e.normalMatrix),Xt.setValue(D,"modelMatrix",_e.matrixWorld),se.isShaderMaterial||se.isRawShaderMaterial){const on=se.uniformsGroups;for(let zr=0,Ho=on.length;zr<Ho;zr++)if(K.isWebGL2){const On=on[zr];Ve.update(On,qn),Ve.bind(On,qn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return qn}function Ei(X,ae){X.ambientLightColor.needsUpdate=ae,X.lightProbe.needsUpdate=ae,X.directionalLights.needsUpdate=ae,X.directionalLightShadows.needsUpdate=ae,X.pointLights.needsUpdate=ae,X.pointLightShadows.needsUpdate=ae,X.spotLights.needsUpdate=ae,X.spotLightShadows.needsUpdate=ae,X.rectAreaLights.needsUpdate=ae,X.hemisphereLights.needsUpdate=ae}function Un(X){return X.isMeshLambertMaterial||X.isMeshToonMaterial||X.isMeshPhongMaterial||X.isMeshStandardMaterial||X.isShadowMaterial||X.isShaderMaterial&&X.lights===!0}this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return S},this.setRenderTargetTextures=function(X,ae,ve){re.get(X.texture).__webglTexture=ae,re.get(X.depthTexture).__webglTexture=ve;const se=re.get(X);se.__hasExternalTextures=!0,se.__hasExternalTextures&&(se.__autoAllocateDepthBuffer=ve===void 0,se.__autoAllocateDepthBuffer||j.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),se.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(X,ae){const ve=re.get(X);ve.__webglFramebuffer=ae,ve.__useDefaultFramebuffer=ae===void 0},this.setRenderTarget=function(X,ae=0,ve=0){S=X,b=ae,w=ve;let se=!0,_e=null,Ge=!1,We=!1;if(X){const Ye=re.get(X);Ye.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(D.FRAMEBUFFER,null),se=!1):Ye.__webglFramebuffer===void 0?fe.setupRenderTarget(X):Ye.__hasExternalTextures&&fe.rebindTextures(X,re.get(X.texture).__webglTexture,re.get(X.depthTexture).__webglTexture);const nt=X.texture;(nt.isData3DTexture||nt.isDataArrayTexture||nt.isCompressedArrayTexture)&&(We=!0);const Te=re.get(X).__webglFramebuffer;X.isWebGLCubeRenderTarget?(_e=Te[ae],Ge=!0):K.isWebGL2&&X.samples>0&&fe.useMultisampledRTT(X)===!1?_e=re.get(X).__webglMultisampledFramebuffer:_e=Te,T.copy(X.viewport),L.copy(X.scissor),P=X.scissorTest}else T.copy(U).multiplyScalar(C).floor(),L.copy(R).multiplyScalar(C).floor(),P=F;if(W.bindFramebuffer(D.FRAMEBUFFER,_e)&&K.drawBuffers&&se&&W.drawBuffers(X,_e),W.viewport(T),W.scissor(L),W.setScissorTest(P),Ge){const Ye=re.get(X.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+ae,Ye.__webglTexture,ve)}else if(We){const Ye=re.get(X.texture),nt=ae||0;D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ye.__webglTexture,ve||0,nt)}M=-1},this.readRenderTargetPixels=function(X,ae,ve,se,_e,Ge,We){if(!(X&&X.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let qe=re.get(X).__webglFramebuffer;if(X.isWebGLCubeRenderTarget&&We!==void 0&&(qe=qe[We]),qe){W.bindFramebuffer(D.FRAMEBUFFER,qe);try{const Ye=X.texture,nt=Ye.format,Te=Ye.type;if(nt!==Ln&&Ee.convert(nt)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ze=Te===Ao&&(j.has("EXT_color_buffer_half_float")||K.isWebGL2&&j.has("EXT_color_buffer_float"));if(Te!==Ii&&Ee.convert(Te)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===Li&&(K.isWebGL2||j.has("OES_texture_float")||j.has("WEBGL_color_buffer_float")))&&!Ze){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ae>=0&&ae<=X.width-se&&ve>=0&&ve<=X.height-_e&&D.readPixels(ae,ve,se,_e,Ee.convert(nt),Ee.convert(Te),Ge)}finally{const Ye=S!==null?re.get(S).__webglFramebuffer:null;W.bindFramebuffer(D.FRAMEBUFFER,Ye)}}},this.copyFramebufferToTexture=function(X,ae,ve=0){const se=Math.pow(2,-ve),_e=Math.floor(ae.image.width*se),Ge=Math.floor(ae.image.height*se);fe.setTexture2D(ae,0),D.copyTexSubImage2D(D.TEXTURE_2D,ve,0,0,X.x,X.y,_e,Ge),W.unbindTexture()},this.copyTextureToTexture=function(X,ae,ve,se=0){const _e=ae.image.width,Ge=ae.image.height,We=Ee.convert(ve.format),qe=Ee.convert(ve.type);fe.setTexture2D(ve,0),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,ve.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ve.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,ve.unpackAlignment),ae.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,se,X.x,X.y,_e,Ge,We,qe,ae.image.data):ae.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,se,X.x,X.y,ae.mipmaps[0].width,ae.mipmaps[0].height,We,ae.mipmaps[0].data):D.texSubImage2D(D.TEXTURE_2D,se,X.x,X.y,We,qe,ae.image),se===0&&ve.generateMipmaps&&D.generateMipmap(D.TEXTURE_2D),W.unbindTexture()},this.copyTextureToTexture3D=function(X,ae,ve,se,_e=0){if(y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ge=X.max.x-X.min.x+1,We=X.max.y-X.min.y+1,qe=X.max.z-X.min.z+1,Ye=Ee.convert(se.format),nt=Ee.convert(se.type);let Te;if(se.isData3DTexture)fe.setTexture3D(se,0),Te=D.TEXTURE_3D;else if(se.isDataArrayTexture)fe.setTexture2DArray(se,0),Te=D.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,se.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,se.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,se.unpackAlignment);const Ze=D.getParameter(D.UNPACK_ROW_LENGTH),At=D.getParameter(D.UNPACK_IMAGE_HEIGHT),bt=D.getParameter(D.UNPACK_SKIP_PIXELS),dn=D.getParameter(D.UNPACK_SKIP_ROWS),Xn=D.getParameter(D.UNPACK_SKIP_IMAGES),Ct=ve.isCompressedTexture?ve.mipmaps[0]:ve.image;D.pixelStorei(D.UNPACK_ROW_LENGTH,Ct.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Ct.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,X.min.x),D.pixelStorei(D.UNPACK_SKIP_ROWS,X.min.y),D.pixelStorei(D.UNPACK_SKIP_IMAGES,X.min.z),ve.isDataTexture||ve.isData3DTexture?D.texSubImage3D(Te,_e,ae.x,ae.y,ae.z,Ge,We,qe,Ye,nt,Ct.data):ve.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),D.compressedTexSubImage3D(Te,_e,ae.x,ae.y,ae.z,Ge,We,qe,Ye,Ct.data)):D.texSubImage3D(Te,_e,ae.x,ae.y,ae.z,Ge,We,qe,Ye,nt,Ct),D.pixelStorei(D.UNPACK_ROW_LENGTH,Ze),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,At),D.pixelStorei(D.UNPACK_SKIP_PIXELS,bt),D.pixelStorei(D.UNPACK_SKIP_ROWS,dn),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Xn),_e===0&&se.generateMipmaps&&D.generateMipmap(Te),W.unbindTexture()},this.initTexture=function(X){X.isCubeTexture?fe.setTextureCube(X,0):X.isData3DTexture?fe.setTexture3D(X,0):X.isDataArrayTexture||X.isCompressedArrayTexture?fe.setTexture2DArray(X,0):fe.setTexture2D(X,0),W.unbindTexture()},this.resetState=function(){b=0,w=0,S=null,W.reset(),De.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Di}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===et?Ar:Qp}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ar?et:xi}}class rb extends lm{}rb.prototype.isWebGL1Renderer=!0;class Hu{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ne(e),this.density=t}clone(){return new Hu(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Wu{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ne(e),this.near=t,this.far=n}clone(){return new Wu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class ac extends gt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class Xu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=rc,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Bn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const xn=new G;class gs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)xn.fromBufferAttribute(this,t),xn.applyMatrix4(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)xn.fromBufferAttribute(this,t),xn.applyNormalMatrix(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)xn.fromBufferAttribute(this,t),xn.transformDirection(e),this.setXYZ(t,xn.x,xn.y,xn.z);return this}setX(e,t){return this.normalized&&(t=ot(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ot(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ot(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ot(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=zn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=zn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=zn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=zn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ot(t,this.array),n=ot(n,this.array),i=ot(i,this.array),s=ot(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new wt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new gs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class um extends un{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ne(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let to;const da=new G,no=new G,io=new G,ro=new be,pa=new be,sb=new Ke,Sl=new G,ma=new G,El=new G,B0=new be,xf=new be,G0=new be;class ob extends gt{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",to===void 0){to=new st;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Xu(t,5);to.setIndex([0,1,2,0,2,3]),to.setAttribute("position",new gs(n,3,0,!1)),to.setAttribute("uv",new gs(n,2,3,!1))}this.geometry=to,this.material=e!==void 0?e:new um,this.center=new be(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),no.setFromMatrixScale(this.matrixWorld),sb.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),io.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&no.multiplyScalar(-io.z);const n=this.material.rotation;let i,s;n!==0&&(s=Math.cos(n),i=Math.sin(n));const o=this.center;Ml(Sl.set(-.5,-.5,0),io,o,no,i,s),Ml(ma.set(.5,-.5,0),io,o,no,i,s),Ml(El.set(.5,.5,0),io,o,no,i,s),B0.set(0,0),xf.set(1,0),G0.set(1,1);let a=e.ray.intersectTriangle(Sl,ma,El,!1,da);if(a===null&&(Ml(ma.set(-.5,.5,0),io,o,no,i,s),xf.set(0,1),a=e.ray.intersectTriangle(Sl,El,ma,!1,da),a===null))return;const c=e.ray.origin.distanceTo(da);c<e.near||c>e.far||t.push({distance:c,point:da.clone(),uv:Pn.getInterpolation(da,Sl,ma,El,B0,xf,G0,new be),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Ml(r,e,t,n,i,s){ro.subVectors(r,t).addScalar(.5).multiply(n),i!==void 0?(pa.x=s*ro.x-i*ro.y,pa.y=i*ro.x+s*ro.y):pa.copy(ro),r.copy(e),r.x+=pa.x,r.y+=pa.y,r.applyMatrix4(sb)}const Tl=new G,V0=new G;class ab extends gt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let s;for(s=0;s<i.length&&!(t<i[s].distance);s++);return i.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Tl.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Tl);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Tl.setFromMatrixPosition(e.matrixWorld),V0.setFromMatrixPosition(this.matrixWorld);const n=Tl.distanceTo(V0)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i<s;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<s;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,s=n.length;i<s;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const H0=new G,W0=new mt,X0=new mt,UR=new G,q0=new Ke,so=new G,bf=new Wn,Y0=new Ke,wf=new No;class cb extends Ot{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ke,this.bindMatrixInverse=new Ke,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Hn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)so.fromBufferAttribute(t,n),this.applyBoneTransform(n,so),this.boundingBox.expandByPoint(so)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Wn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)so.fromBufferAttribute(t,n),this.applyBoneTransform(n,so),this.boundingSphere.expandByPoint(so)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),bf.copy(this.boundingSphere),bf.applyMatrix4(i),e.ray.intersectsSphere(bf)!==!1&&(Y0.copy(i).invert(),wf.copy(e.ray).applyMatrix4(Y0),!(this.boundingBox!==null&&wf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,wf)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new mt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;W0.fromBufferAttribute(i.attributes.skinIndex,e),X0.fromBufferAttribute(i.attributes.skinWeight,e),H0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=X0.getComponent(s);if(o!==0){const a=W0.getComponent(s);q0.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(UR.copy(H0).applyMatrix4(q0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class hm extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class So extends Ft{constructor(e=null,t=1,n=1,i,s,o,a,c,l=Yt,u=Yt,h,f){super(null,o,a,c,l,u,i,s,h,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const j0=new Ke,OR=new Ke;class qu{constructor(e=[],t=[]){this.uuid=Bn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ke)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ke;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const a=e[s]?e[s].matrixWorld:OR;j0.multiplyMatrices(a,t[s]),j0.toArray(n,s*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new qu(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Wx(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new So(t,e,e,Ln,Li);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const s=e.bones[n];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new hm),this.bones.push(o),this.boneInverses.push(new Ke().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,s=t.length;i<s;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class vs extends wt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const oo=new Ke,$0=new Ke,Al=[],Z0=new Hn,NR=new Ke,ga=new Ot,va=new Wn;class lb extends Ot{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new vs(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,NR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Hn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,oo),Z0.copy(e.boundingBox).applyMatrix4(oo),this.boundingBox.union(Z0)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Wn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,oo),va.copy(e.boundingSphere).applyMatrix4(oo),this.boundingSphere.union(va)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ga.geometry=this.geometry,ga.material=this.material,ga.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),va.copy(this.boundingSphere),va.applyMatrix4(n),e.ray.intersectsSphere(va)!==!1))for(let s=0;s<i;s++){this.getMatrixAt(s,oo),$0.multiplyMatrices(n,oo),ga.matrixWorld=$0,ga.raycast(e,Al);for(let o=0,a=Al.length;o<a;o++){const c=Al[o];c.instanceId=s,c.object=this,t.push(c)}Al.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new vs(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class Sn extends un{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ne(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const K0=new G,J0=new G,Q0=new Ke,Sf=new No,Cl=new Wn;let Ur=class extends gt{constructor(e=new st,t=new Sn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)K0.fromBufferAttribute(t,i-1),J0.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=K0.distanceTo(J0);e.setAttribute("lineDistance",new He(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Cl.copy(n.boundingSphere),Cl.applyMatrix4(i),Cl.radius+=s,e.ray.intersectsSphere(Cl)===!1)return;Q0.copy(i).invert(),Sf.copy(e.ray).applyMatrix4(Q0);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new G,u=new G,h=new G,f=new G,d=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){const p=Math.max(0,o.start),_=Math.min(m.count,o.start+o.count);for(let y=p,x=_-1;y<x;y+=d){const b=m.getX(y),w=m.getX(y+1);if(l.fromBufferAttribute(g,b),u.fromBufferAttribute(g,w),Sf.distanceSqToSegment(l,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(f);M<e.near||M>e.far||t.push({distance:M,point:h.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else{const p=Math.max(0,o.start),_=Math.min(g.count,o.start+o.count);for(let y=p,x=_-1;y<x;y+=d){if(l.fromBufferAttribute(g,y),u.fromBufferAttribute(g,y+1),Sf.distanceSqToSegment(l,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);const w=e.ray.origin.distanceTo(f);w<e.near||w>e.far||t.push({distance:w,point:h.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};const ev=new G,tv=new G;class zi extends Ur{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)ev.fromBufferAttribute(t,i),tv.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ev.distanceTo(tv);e.setAttribute("lineDistance",new He(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ub extends Ur{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class fm extends un{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ne(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const nv=new Ke,fp=new No,Rl=new Wn,Pl=new G;class hb extends gt{constructor(e=new st,t=new fm){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Rl.copy(n.boundingSphere),Rl.applyMatrix4(i),Rl.radius+=s,e.ray.intersectsSphere(Rl)===!1)return;nv.copy(i).invert(),fp.copy(e.ray).applyMatrix4(nv);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){const f=Math.max(0,o.start),d=Math.min(l.count,o.start+o.count);for(let m=f,v=d;m<v;m++){const g=l.getX(m);Pl.fromBufferAttribute(h,g),iv(Pl,g,c,i,e,t,this)}}else{const f=Math.max(0,o.start),d=Math.min(h.count,o.start+o.count);for(let m=f,v=d;m<v;m++)Pl.fromBufferAttribute(h,m),iv(Pl,m,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function iv(r,e,t,n,i,s,o){const a=fp.distanceSqToPoint(r);if(a<t){const c=new G;fp.closestPointToPoint(r,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}class FR extends Ft{constructor(e,t,n,i,s,o,a,c,l){super(e,t,n,i,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Pt,this.magFilter=s!==void 0?s:Pt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class kR extends Ft{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Yt,this.minFilter=Yt,this.generateMipmaps=!1,this.needsUpdate=!0}}class dm extends Ft{constructor(e,t,n,i,s,o,a,c,l,u,h,f){super(null,o,a,c,l,u,i,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zR extends dm{constructor(e,t,n,i,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=gn}}class BR extends Ft{constructor(e,t,n,i,s,o,a,c,l){super(e,t,n,i,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class wi{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const s=n.length;let o;t?o=t:o=e*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(s-1);const u=n[i],f=n[i+1]-u,d=(o-u)/f;return(i+d)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),c=t||(o.isVector2?new be:new G);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new G,i=[],s=[],o=[],a=new G,c=new Ke;for(let d=0;d<=e;d++){const m=d/e;i[d]=this.getTangentAt(m,new G)}s[0]=new G,o[0]=new G;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(Bt(i[d-1].dot(i[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(a,m))}o[d].crossVectors(i[d],s[d])}if(t===!0){let d=Math.acos(Bt(s[0].dot(s[e]),-1,1));d/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(c.makeRotationAxis(i[m],d*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Yu extends wi{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){const n=t||new be,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+e*s;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*u-d*h+this.aX,l=f*h+d*u+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class fb extends Yu{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function pm(){let r=0,e=0,t=0,n=0;function i(s,o,a,c){r=s,e=a,t=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){i(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let f=(o-s)/l-(a-s)/(l+u)+(a-o)/u,d=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,d*=u,i(o,a,f,d)},calc:function(s){const o=s*s,a=o*s;return r+e*s+t*o+n*a}}}const Ll=new G,Ef=new pm,Mf=new pm,Tf=new pm;class db extends wi{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new G){const n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%s]:(Ll.subVectors(i[0],i[1]).add(i[0]),l=Ll);const h=i[a%s],f=i[(a+1)%s];if(this.closed||a+2<s?u=i[(a+2)%s]:(Ll.subVectors(i[s-1],i[s-2]).add(i[s-1]),u=Ll),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let m=Math.pow(l.distanceToSquared(h),d),v=Math.pow(h.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(u),d);v<1e-4&&(v=1),m<1e-4&&(m=v),g<1e-4&&(g=v),Ef.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,m,v,g),Mf.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,m,v,g),Tf.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,m,v,g)}else this.curveType==="catmullrom"&&(Ef.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),Mf.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),Tf.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(Ef.calc(c),Mf.calc(c),Tf.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new G().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function rv(r,e,t,n,i){const s=(n-e)*.5,o=(i-t)*.5,a=r*r,c=r*a;return(2*t-2*n+s+o)*c+(-3*t+3*n-2*s-o)*a+s*r+t}function GR(r,e){const t=1-r;return t*t*e}function VR(r,e){return 2*(1-r)*r*e}function HR(r,e){return r*r*e}function Ha(r,e,t,n){return GR(r,e)+VR(r,t)+HR(r,n)}function WR(r,e){const t=1-r;return t*t*t*e}function XR(r,e){const t=1-r;return 3*t*t*r*e}function qR(r,e){return 3*(1-r)*r*r*e}function YR(r,e){return r*r*r*e}function Wa(r,e,t,n,i){return WR(r,e)+XR(r,t)+qR(r,n)+YR(r,i)}class mm extends wi{constructor(e=new be,t=new be,n=new be,i=new be){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new be){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Wa(e,i.x,s.x,o.x,a.x),Wa(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class pb extends wi{constructor(e=new G,t=new G,n=new G,i=new G){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new G){const n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Wa(e,i.x,s.x,o.x,a.x),Wa(e,i.y,s.y,o.y,a.y),Wa(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class ju extends wi{constructor(e=new be,t=new be){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new be){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new be){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class gm extends wi{constructor(e=new G,t=new G){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new G){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new G){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class vm extends wi{constructor(e=new be,t=new be,n=new be){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new be){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Ha(e,i.x,s.x,o.x),Ha(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class $u extends wi{constructor(e=new G,t=new G,n=new G){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new G){const n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(Ha(e,i.x,s.x,o.x),Ha(e,i.y,s.y,o.y),Ha(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class _m extends wi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new be){const n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,c=i[o===0?o:o-1],l=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(rv(a,c.x,l.x,u.x,h.x),rv(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new be().fromArray(i))}return this}}var ym=Object.freeze({__proto__:null,ArcCurve:fb,CatmullRomCurve3:db,CubicBezierCurve:mm,CubicBezierCurve3:pb,EllipseCurve:Yu,LineCurve:ju,LineCurve3:gm,QuadraticBezierCurve:vm,QuadraticBezierCurve3:$u,SplineCurve:_m});class mb extends wi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new ju(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=n){const o=i[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new ym[i.type]().fromJSON(i))}return this}}class cc extends mb{constructor(e){super(),this.type="Path",this.currentPoint=new be,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new ju(this.currentPoint.clone(),new be(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const s=new vm(this.currentPoint.clone(),new be(e,t),new be(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){const a=new mm(this.currentPoint.clone(),new be(e,t),new be(n,i),new be(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new _m(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,i,s,o,a,c),this}absellipse(e,t,n,i,s,o,a,c){const l=new Yu(e,t,n,i,s,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Dc extends st{constructor(e=[new be(0,-.5),new be(.5,0),new be(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Bt(i,0,Math.PI*2);const s=[],o=[],a=[],c=[],l=[],u=1/t,h=new G,f=new be,d=new G,m=new G,v=new G;let g=0,p=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].y,d.x=p*1,d.y=-g,d.z=p*0,v.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(v.x,v.y,v.z);break;default:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].y,d.x=p*1,d.y=-g,d.z=p*0,m.copy(d),d.x+=v.x,d.y+=v.y,d.z+=v.z,d.normalize(),c.push(d.x,d.y,d.z),v.copy(m)}for(let _=0;_<=t;_++){const y=n+_*u*i,x=Math.sin(y),b=Math.cos(y);for(let w=0;w<=e.length-1;w++){h.x=e[w].x*x,h.y=e[w].y,h.z=e[w].x*b,o.push(h.x,h.y,h.z),f.x=_/t,f.y=w/(e.length-1),a.push(f.x,f.y);const S=c[3*w+0]*x,M=c[3*w+1],E=c[3*w+0]*b;l.push(S,M,E)}}for(let _=0;_<t;_++)for(let y=0;y<e.length-1;y++){const x=y+_*e.length,b=x,w=x+e.length,S=x+e.length+1,M=x+1;s.push(b,w,M),s.push(S,M,w)}this.setIndex(s),this.setAttribute("position",new He(o,3)),this.setAttribute("uv",new He(a,2)),this.setAttribute("normal",new He(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Dc(e.points,e.segments,e.phiStart,e.phiLength)}}class Zu extends Dc{constructor(e=1,t=1,n=4,i=8){const s=new cc;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Zu(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ku extends st{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const s=[],o=[],a=[],c=[],l=new G,u=new be;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=t;h++,f+=3){const d=n+h/t*i;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/e+1)/2,u.y=(o[f+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new He(o,3)),this.setAttribute("normal",new He(a,3)),this.setAttribute("uv",new He(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ku(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Ts extends st{constructor(e=1,t=1,n=1,i=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};const l=this;i=Math.floor(i),s=Math.floor(s);const u=[],h=[],f=[],d=[];let m=0;const v=[],g=n/2;let p=0;_(),o===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new He(h,3)),this.setAttribute("normal",new He(f,3)),this.setAttribute("uv",new He(d,2));function _(){const x=new G,b=new G;let w=0;const S=(t-e)/n;for(let M=0;M<=s;M++){const E=[],T=M/s,L=T*(t-e)+e;for(let P=0;P<=i;P++){const A=P/i,z=A*c+a,V=Math.sin(z),N=Math.cos(z);b.x=L*V,b.y=-T*n+g,b.z=L*N,h.push(b.x,b.y,b.z),x.set(V,S,N).normalize(),f.push(x.x,x.y,x.z),d.push(A,1-T),E.push(m++)}v.push(E)}for(let M=0;M<i;M++)for(let E=0;E<s;E++){const T=v[E][M],L=v[E+1][M],P=v[E+1][M+1],A=v[E][M+1];u.push(T,L,A),u.push(L,P,A),w+=6}l.addGroup(p,w,0),p+=w}function y(x){const b=m,w=new be,S=new G;let M=0;const E=x===!0?e:t,T=x===!0?1:-1;for(let P=1;P<=i;P++)h.push(0,g*T,0),f.push(0,T,0),d.push(.5,.5),m++;const L=m;for(let P=0;P<=i;P++){const z=P/i*c+a,V=Math.cos(z),N=Math.sin(z);S.x=E*N,S.y=g*T,S.z=E*V,h.push(S.x,S.y,S.z),f.push(0,T,0),w.x=V*.5+.5,w.y=N*.5*T+.5,d.push(w.x,w.y),m++}for(let P=0;P<i;P++){const A=b+P,z=L+P;x===!0?u.push(z,z+1,A):u.push(z+1,z,A),M+=3}l.addGroup(p,M,x===!0?1:2),p+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ts(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ju extends Ts{constructor(e=1,t=1,n=32,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new Ju(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fr extends st{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const s=[],o=[];a(i),l(n),u(),this.setAttribute("position",new He(s,3)),this.setAttribute("normal",new He(s.slice(),3)),this.setAttribute("uv",new He(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(_){const y=new G,x=new G,b=new G;for(let w=0;w<t.length;w+=3)d(t[w+0],y),d(t[w+1],x),d(t[w+2],b),c(y,x,b,_)}function c(_,y,x,b){const w=b+1,S=[];for(let M=0;M<=w;M++){S[M]=[];const E=_.clone().lerp(x,M/w),T=y.clone().lerp(x,M/w),L=w-M;for(let P=0;P<=L;P++)P===0&&M===w?S[M][P]=E:S[M][P]=E.clone().lerp(T,P/L)}for(let M=0;M<w;M++)for(let E=0;E<2*(w-M)-1;E++){const T=Math.floor(E/2);E%2===0?(f(S[M][T+1]),f(S[M+1][T]),f(S[M][T])):(f(S[M][T+1]),f(S[M+1][T+1]),f(S[M+1][T]))}}function l(_){const y=new G;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(_),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function u(){const _=new G;for(let y=0;y<s.length;y+=3){_.x=s[y+0],_.y=s[y+1],_.z=s[y+2];const x=g(_)/2/Math.PI+.5,b=p(_)/Math.PI+.5;o.push(x,1-b)}m(),h()}function h(){for(let _=0;_<o.length;_+=6){const y=o[_+0],x=o[_+2],b=o[_+4],w=Math.max(y,x,b),S=Math.min(y,x,b);w>.9&&S<.1&&(y<.2&&(o[_+0]+=1),x<.2&&(o[_+2]+=1),b<.2&&(o[_+4]+=1))}}function f(_){s.push(_.x,_.y,_.z)}function d(_,y){const x=_*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function m(){const _=new G,y=new G,x=new G,b=new G,w=new be,S=new be,M=new be;for(let E=0,T=0;E<s.length;E+=9,T+=6){_.set(s[E+0],s[E+1],s[E+2]),y.set(s[E+3],s[E+4],s[E+5]),x.set(s[E+6],s[E+7],s[E+8]),w.set(o[T+0],o[T+1]),S.set(o[T+2],o[T+3]),M.set(o[T+4],o[T+5]),b.copy(_).add(y).add(x).divideScalar(3);const L=g(b);v(w,T+0,_,L),v(S,T+2,y,L),v(M,T+4,x,L)}}function v(_,y,x,b){b<0&&_.x===1&&(o[y]=_.x-1),x.x===0&&x.z===0&&(o[y]=b/2/Math.PI+.5)}function g(_){return Math.atan2(_.z,-_.x)}function p(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fr(e.vertices,e.indices,e.radius,e.details)}}class Qu extends Fr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Qu(e.radius,e.detail)}}const Dl=new G,Il=new G,Af=new G,Ul=new Pn;class gb extends st{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),s=Math.cos(us*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),f={},d=[];for(let m=0;m<c;m+=3){o?(l[0]=o.getX(m),l[1]=o.getX(m+1),l[2]=o.getX(m+2)):(l[0]=m,l[1]=m+1,l[2]=m+2);const{a:v,b:g,c:p}=Ul;if(v.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),Ul.getNormal(Af),h[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,h[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,h[2]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let _=0;_<3;_++){const y=(_+1)%3,x=h[_],b=h[y],w=Ul[u[_]],S=Ul[u[y]],M=`${x}_${b}`,E=`${b}_${x}`;E in f&&f[E]?(Af.dot(f[E].normal)<=s&&(d.push(w.x,w.y,w.z),d.push(S.x,S.y,S.z)),f[E]=null):M in f||(f[M]={index0:l[_],index1:l[y],normal:Af.clone()})}}for(const m in f)if(f[m]){const{index0:v,index1:g}=f[m];Dl.fromBufferAttribute(a,v),Il.fromBufferAttribute(a,g),d.push(Dl.x,Dl.y,Dl.z),d.push(Il.x,Il.y,Il.z)}this.setAttribute("position",new He(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class fs extends cc{constructor(e){super(e),this.uuid=Bn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new cc().fromJSON(i))}return this}}const jR={triangulate:function(r,e,t=2){const n=e&&e.length,i=n?e[0]*t:r.length;let s=vb(r,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,f,d;if(n&&(s=QR(r,e,s,t)),r.length>80*t){a=l=r[0],c=u=r[1];for(let m=t;m<i;m+=t)h=r[m],f=r[m+1],h<a&&(a=h),f<c&&(c=f),h>l&&(l=h),f>u&&(u=f);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return lc(s,o,t,a,c,d,0),o}};function vb(r,e,t,n,i){let s,o;if(i===uP(r,e,t,n)>0)for(s=e;s<t;s+=n)o=sv(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=sv(s,r[s],r[s+1],o);return o&&eh(o,o.next)&&(hc(o),o=o.next),o}function _s(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(eh(t,t.next)||It(t.prev,t,t.next)===0)){if(hc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function lc(r,e,t,n,i,s,o){if(!r)return;!o&&s&&rP(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?ZR(r,n,i,s):$R(r)){e.push(c.i/t|0),e.push(r.i/t|0),e.push(l.i/t|0),hc(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=KR(_s(r),e,t),lc(r,e,t,n,i,s,2)):o===2&&JR(r,e,t,n,i,s):lc(_s(r),e,t,n,i,s,1);break}}}function $R(r){const e=r.prev,t=r,n=r.next;if(It(e,t,n)>=0)return!1;const i=e.x,s=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,f=i>s?i>o?i:o:s>o?s:o,d=a>c?a>l?a:l:c>l?c:l;let m=n.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=h&&m.y<=d&&xo(i,a,s,c,o,l,m.x,m.y)&&It(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function ZR(r,e,t,n){const i=r.prev,s=r,o=r.next;if(It(i,s,o)>=0)return!1;const a=i.x,c=s.x,l=o.x,u=i.y,h=s.y,f=o.y,d=a<c?a<l?a:l:c<l?c:l,m=u<h?u<f?u:f:h<f?h:f,v=a>c?a>l?a:l:c>l?c:l,g=u>h?u>f?u:f:h>f?h:f,p=dp(d,m,e,t,n),_=dp(v,g,e,t,n);let y=r.prevZ,x=r.nextZ;for(;y&&y.z>=p&&x&&x.z<=_;){if(y.x>=d&&y.x<=v&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&xo(a,u,c,h,l,f,y.x,y.y)&&It(y.prev,y,y.next)>=0||(y=y.prevZ,x.x>=d&&x.x<=v&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&xo(a,u,c,h,l,f,x.x,x.y)&&It(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;y&&y.z>=p;){if(y.x>=d&&y.x<=v&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&xo(a,u,c,h,l,f,y.x,y.y)&&It(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=_;){if(x.x>=d&&x.x<=v&&x.y>=m&&x.y<=g&&x!==i&&x!==o&&xo(a,u,c,h,l,f,x.x,x.y)&&It(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function KR(r,e,t){let n=r;do{const i=n.prev,s=n.next.next;!eh(i,s)&&_b(i,n,n.next,s)&&uc(i,s)&&uc(s,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),hc(n),hc(n.next),n=r=s),n=n.next}while(n!==r);return _s(n)}function JR(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&aP(o,a)){let c=yb(o,a);o=_s(o,o.next),c=_s(c,c.next),lc(o,e,t,n,i,s,0),lc(c,e,t,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function QR(r,e,t,n){const i=[];let s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:r.length,l=vb(r,a,c,n,!1),l===l.next&&(l.steiner=!0),i.push(oP(l));for(i.sort(eP),s=0;s<i.length;s++)t=tP(i[s],t);return t}function eP(r,e){return r.x-e.x}function tP(r,e){const t=nP(r,e);if(!t)return e;const n=yb(t,r);return _s(n,n.next),_s(t,t.next)}function nP(r,e){let t=e,n=-1/0,i;const s=r.x,o=r.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const f=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=s&&f>n&&(n=f,i=t.x<t.next.x?t:t.next,f===s))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,c=i.x,l=i.y;let u=1/0,h;t=i;do s>=t.x&&t.x>=c&&s!==t.x&&xo(o<l?s:n,o,c,l,o<l?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),uc(t,r)&&(h<u||h===u&&(t.x>i.x||t.x===i.x&&iP(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function iP(r,e){return It(r.prev,r,e.prev)<0&&It(e.next,r,r.next)<0}function rP(r,e,t,n){let i=r;do i.z===0&&(i.z=dp(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,sP(i)}function sP(r){let e,t,n,i,s,o,a,c,l=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,c--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,l*=2}while(o>1);return r}function dp(r,e,t,n,i){return r=(r-t)*i|0,e=(e-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function oP(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function xo(r,e,t,n,i,s,o,a){return(i-o)*(e-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(n-a)}function aP(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!cP(r,e)&&(uc(r,e)&&uc(e,r)&&lP(r,e)&&(It(r.prev,r,e.prev)||It(r,e.prev,e))||eh(r,e)&&It(r.prev,r,r.next)>0&&It(e.prev,e,e.next)>0)}function It(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function eh(r,e){return r.x===e.x&&r.y===e.y}function _b(r,e,t,n){const i=Nl(It(r,e,t)),s=Nl(It(r,e,n)),o=Nl(It(t,n,r)),a=Nl(It(t,n,e));return!!(i!==s&&o!==a||i===0&&Ol(r,t,e)||s===0&&Ol(r,n,e)||o===0&&Ol(t,r,n)||a===0&&Ol(t,e,n))}function Ol(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Nl(r){return r>0?1:r<0?-1:0}function cP(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&_b(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function uc(r,e){return It(r.prev,r,r.next)<0?It(r,e,r.next)>=0&&It(r,r.prev,e)>=0:It(r,e,r.prev)<0||It(r,r.next,e)<0}function lP(r,e){let t=r,n=!1;const i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function yb(r,e){const t=new pp(r.i,r.x,r.y),n=new pp(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function sv(r,e,t,n){const i=new pp(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function hc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function pp(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function uP(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}class Ui{static area(e){const t=e.length;let n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return Ui.area(e)<0}static triangulateShape(e,t){const n=[],i=[],s=[];ov(e),av(n,e);let o=e.length;t.forEach(ov);for(let c=0;c<t.length;c++)i.push(o),o+=t[c].length,av(n,t[c]);const a=jR.triangulate(n,i);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}}function ov(r){const e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function av(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}class th extends st{constructor(e=new fs([new be(.5,.5),new be(-.5,.5),new be(-.5,-.5),new be(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],s=[];for(let a=0,c=e.length;a<c;a++){const l=e[a];o(l)}this.setAttribute("position",new He(i,3)),this.setAttribute("uv",new He(s,2)),this.computeVertexNormals();function o(a){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:d-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const p=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:hP;let y,x=!1,b,w,S,M;p&&(y=p.getSpacedPoints(u),x=!0,f=!1,b=p.computeFrenetFrames(u,!1),w=new G,S=new G,M=new G),f||(g=0,d=0,m=0,v=0);const E=a.extractPoints(l);let T=E.shape;const L=E.holes;if(!Ui.isClockWise(T)){T=T.reverse();for(let D=0,Q=L.length;D<Q;D++){const j=L[D];Ui.isClockWise(j)&&(L[D]=j.reverse())}}const A=Ui.triangulateShape(T,L),z=T;for(let D=0,Q=L.length;D<Q;D++){const j=L[D];T=T.concat(j)}function V(D,Q,j){return Q||console.error("THREE.ExtrudeGeometry: vec does not exist"),D.clone().addScaledVector(Q,j)}const N=T.length,C=A.length;function O(D,Q,j){let K,W,ye;const re=D.x-Q.x,fe=D.y-Q.y,xe=j.x-D.x,ce=j.y-D.y,Pe=re*re+fe*fe,B=re*ce-fe*xe;if(Math.abs(B)>Number.EPSILON){const I=Math.sqrt(Pe),$=Math.sqrt(xe*xe+ce*ce),he=Q.x-fe/I,de=Q.y+re/I,pe=j.x-ce/$,Me=j.y+xe/$,we=((pe-he)*ce-(Me-de)*xe)/(re*ce-fe*xe);K=he+re*we-D.x,W=de+fe*we-D.y;const ue=K*K+W*W;if(ue<=2)return new be(K,W);ye=Math.sqrt(ue/2)}else{let I=!1;re>Number.EPSILON?xe>Number.EPSILON&&(I=!0):re<-Number.EPSILON?xe<-Number.EPSILON&&(I=!0):Math.sign(fe)===Math.sign(ce)&&(I=!0),I?(K=-fe,W=re,ye=Math.sqrt(Pe)):(K=re,W=fe,ye=Math.sqrt(Pe/2))}return new be(K/ye,W/ye)}const k=[];for(let D=0,Q=z.length,j=Q-1,K=D+1;D<Q;D++,j++,K++)j===Q&&(j=0),K===Q&&(K=0),k[D]=O(z[D],z[j],z[K]);const U=[];let R,F=k.concat();for(let D=0,Q=L.length;D<Q;D++){const j=L[D];R=[];for(let K=0,W=j.length,ye=W-1,re=K+1;K<W;K++,ye++,re++)ye===W&&(ye=0),re===W&&(re=0),R[K]=O(j[K],j[ye],j[re]);U.push(R),F=F.concat(R)}for(let D=0;D<g;D++){const Q=D/g,j=d*Math.cos(Q*Math.PI/2),K=m*Math.sin(Q*Math.PI/2)+v;for(let W=0,ye=z.length;W<ye;W++){const re=V(z[W],k[W],K);ne(re.x,re.y,-j)}for(let W=0,ye=L.length;W<ye;W++){const re=L[W];R=U[W];for(let fe=0,xe=re.length;fe<xe;fe++){const ce=V(re[fe],R[fe],K);ne(ce.x,ce.y,-j)}}}const H=m+v;for(let D=0;D<N;D++){const Q=f?V(T[D],F[D],H):T[D];x?(S.copy(b.normals[0]).multiplyScalar(Q.x),w.copy(b.binormals[0]).multiplyScalar(Q.y),M.copy(y[0]).add(S).add(w),ne(M.x,M.y,M.z)):ne(Q.x,Q.y,0)}for(let D=1;D<=u;D++)for(let Q=0;Q<N;Q++){const j=f?V(T[Q],F[Q],H):T[Q];x?(S.copy(b.normals[D]).multiplyScalar(j.x),w.copy(b.binormals[D]).multiplyScalar(j.y),M.copy(y[D]).add(S).add(w),ne(M.x,M.y,M.z)):ne(j.x,j.y,h/u*D)}for(let D=g-1;D>=0;D--){const Q=D/g,j=d*Math.cos(Q*Math.PI/2),K=m*Math.sin(Q*Math.PI/2)+v;for(let W=0,ye=z.length;W<ye;W++){const re=V(z[W],k[W],K);ne(re.x,re.y,h+j)}for(let W=0,ye=L.length;W<ye;W++){const re=L[W];R=U[W];for(let fe=0,xe=re.length;fe<xe;fe++){const ce=V(re[fe],R[fe],K);x?ne(ce.x,ce.y+y[u-1].y,y[u-1].x+j):ne(ce.x,ce.y,h+j)}}}Y(),J();function Y(){const D=i.length/3;if(f){let Q=0,j=N*Q;for(let K=0;K<C;K++){const W=A[K];ee(W[2]+j,W[1]+j,W[0]+j)}Q=u+g*2,j=N*Q;for(let K=0;K<C;K++){const W=A[K];ee(W[0]+j,W[1]+j,W[2]+j)}}else{for(let Q=0;Q<C;Q++){const j=A[Q];ee(j[2],j[1],j[0])}for(let Q=0;Q<C;Q++){const j=A[Q];ee(j[0]+N*u,j[1]+N*u,j[2]+N*u)}}n.addGroup(D,i.length/3-D,0)}function J(){const D=i.length/3;let Q=0;ie(z,Q),Q+=z.length;for(let j=0,K=L.length;j<K;j++){const W=L[j];ie(W,Q),Q+=W.length}n.addGroup(D,i.length/3-D,1)}function ie(D,Q){let j=D.length;for(;--j>=0;){const K=j;let W=j-1;W<0&&(W=D.length-1);for(let ye=0,re=u+g*2;ye<re;ye++){const fe=N*ye,xe=N*(ye+1),ce=Q+K+fe,Pe=Q+W+fe,B=Q+W+xe,I=Q+K+xe;ge(ce,Pe,B,I)}}}function ne(D,Q,j){c.push(D),c.push(Q),c.push(j)}function ee(D,Q,j){me(D),me(Q),me(j);const K=i.length/3,W=_.generateTopUV(n,i,K-3,K-2,K-1);te(W[0]),te(W[1]),te(W[2])}function ge(D,Q,j,K){me(D),me(Q),me(K),me(Q),me(j),me(K);const W=i.length/3,ye=_.generateSideWallUV(n,i,W-6,W-3,W-2,W-1);te(ye[0]),te(ye[1]),te(ye[3]),te(ye[1]),te(ye[2]),te(ye[3])}function me(D){i.push(c[D*3+0]),i.push(c[D*3+1]),i.push(c[D*3+2])}function te(D){s.push(D.x),s.push(D.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return fP(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,o=e.shapes.length;s<o;s++){const a=t[e.shapes[s]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new ym[i.type]().fromJSON(i)),new th(n,e.options)}}const hP={generateTopUV:function(r,e,t,n,i){const s=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[i*3],u=e[i*3+1];return[new be(s,o),new be(a,c),new be(l,u)]},generateSideWallUV:function(r,e,t,n,i,s){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],u=e[n*3+1],h=e[n*3+2],f=e[i*3],d=e[i*3+1],m=e[i*3+2],v=e[s*3],g=e[s*3+1],p=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new be(o,1-c),new be(l,1-h),new be(f,1-m),new be(v,1-p)]:[new be(a,1-c),new be(u,1-h),new be(d,1-m),new be(g,1-p)]}};function fP(r,e,t){if(t.shapes=[],Array.isArray(r))for(let n=0,i=r.length;n<i;n++){const s=r[n];t.shapes.push(s.uuid)}else t.shapes.push(r.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class nh extends Fr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nh(e.radius,e.detail)}}class Ic extends Fr{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ic(e.radius,e.detail)}}class ih extends st{constructor(e=.5,t=1,n=32,i=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:s,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],c=[],l=[],u=[];let h=e;const f=(t-e)/i,d=new G,m=new be;for(let v=0;v<=i;v++){for(let g=0;g<=n;g++){const p=s+g/n*o;d.x=h*Math.cos(p),d.y=h*Math.sin(p),c.push(d.x,d.y,d.z),l.push(0,0,1),m.x=(d.x/t+1)/2,m.y=(d.y/t+1)/2,u.push(m.x,m.y)}h+=f}for(let v=0;v<i;v++){const g=v*(n+1);for(let p=0;p<n;p++){const _=p+g,y=_,x=_+n+1,b=_+n+2,w=_+1;a.push(y,x,w),a.push(x,b,w)}}this.setIndex(a),this.setAttribute("position",new He(c,3)),this.setAttribute("normal",new He(l,3)),this.setAttribute("uv",new He(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ih(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class rh extends st{constructor(e=new fs([new be(0,.5),new be(-.5,-.5),new be(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],s=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new He(i,3)),this.setAttribute("normal",new He(s,3)),this.setAttribute("uv",new He(o,2));function l(u){const h=i.length/3,f=u.extractPoints(t);let d=f.shape;const m=f.holes;Ui.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,p=m.length;g<p;g++){const _=m[g];Ui.isClockWise(_)===!0&&(m[g]=_.reverse())}const v=Ui.triangulateShape(d,m);for(let g=0,p=m.length;g<p;g++){const _=m[g];d=d.concat(_)}for(let g=0,p=d.length;g<p;g++){const _=d[g];i.push(_.x,_.y,0),s.push(0,0,1),o.push(_.x,_.y)}for(let g=0,p=v.length;g<p;g++){const _=v[g],y=_[0]+h,x=_[1]+h,b=_[2]+h;n.push(y,x,b),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return dP(t,e)}static fromJSON(e,t){const n=[];for(let i=0,s=e.shapes.length;i<s;i++){const o=t[e.shapes[i]];n.push(o)}return new rh(n,e.curveSegments)}}function dP(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){const i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}class Uc extends st{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new G,f=new G,d=[],m=[],v=[],g=[];for(let p=0;p<=n;p++){const _=[],y=p/n;let x=0;p===0&&o===0?x=.5/t:p===n&&c===Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){const w=b/t;h.x=-e*Math.cos(i+w*s)*Math.sin(o+y*a),h.y=e*Math.cos(o+y*a),h.z=e*Math.sin(i+w*s)*Math.sin(o+y*a),m.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),g.push(w+x,1-y),_.push(l++)}u.push(_)}for(let p=0;p<n;p++)for(let _=0;_<t;_++){const y=u[p][_+1],x=u[p][_],b=u[p+1][_],w=u[p+1][_+1];(p!==0||o>0)&&d.push(y,x,w),(p!==n-1||c<Math.PI)&&d.push(x,b,w)}this.setIndex(d),this.setAttribute("position",new He(m,3)),this.setAttribute("normal",new He(v,3)),this.setAttribute("uv",new He(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Uc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class sh extends Fr{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new sh(e.radius,e.detail)}}class oh extends st{constructor(e=1,t=.4,n=12,i=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:s},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],c=[],l=[],u=new G,h=new G,f=new G;for(let d=0;d<=n;d++)for(let m=0;m<=i;m++){const v=m/i*s,g=d/n*Math.PI*2;h.x=(e+t*Math.cos(g))*Math.cos(v),h.y=(e+t*Math.cos(g))*Math.sin(v),h.z=t*Math.sin(g),a.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(m/i),l.push(d/n)}for(let d=1;d<=n;d++)for(let m=1;m<=i;m++){const v=(i+1)*d+m-1,g=(i+1)*(d-1)+m-1,p=(i+1)*(d-1)+m,_=(i+1)*d+m;o.push(v,g,_),o.push(g,p,_)}this.setIndex(o),this.setAttribute("position",new He(a,3)),this.setAttribute("normal",new He(c,3)),this.setAttribute("uv",new He(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oh(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class ah extends st{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],c=[],l=[],u=[],h=new G,f=new G,d=new G,m=new G,v=new G,g=new G,p=new G;for(let y=0;y<=n;++y){const x=y/n*s*Math.PI*2;_(x,s,o,e,d),_(x+.01,s,o,e,m),g.subVectors(m,d),p.addVectors(m,d),v.crossVectors(g,p),p.crossVectors(v,g),v.normalize(),p.normalize();for(let b=0;b<=i;++b){const w=b/i*Math.PI*2,S=-t*Math.cos(w),M=t*Math.sin(w);h.x=d.x+(S*p.x+M*v.x),h.y=d.y+(S*p.y+M*v.y),h.z=d.z+(S*p.z+M*v.z),c.push(h.x,h.y,h.z),f.subVectors(h,d).normalize(),l.push(f.x,f.y,f.z),u.push(y/n),u.push(b/i)}}for(let y=1;y<=n;y++)for(let x=1;x<=i;x++){const b=(i+1)*(y-1)+(x-1),w=(i+1)*y+(x-1),S=(i+1)*y+x,M=(i+1)*(y-1)+x;a.push(b,w,M),a.push(w,S,M)}this.setIndex(a),this.setAttribute("position",new He(c,3)),this.setAttribute("normal",new He(l,3)),this.setAttribute("uv",new He(u,2));function _(y,x,b,w,S){const M=Math.cos(y),E=Math.sin(y),T=b/x*y,L=Math.cos(T);S.x=w*(2+L)*.5*M,S.y=w*(2+L)*E*.5,S.z=w*Math.sin(T)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ah(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ys extends st{constructor(e=new $u(new G(-1,-1,0),new G(-1,1,0),new G(1,1,0)),t=64,n=1,i=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new G,c=new G,l=new be;let u=new G;const h=[],f=[],d=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new He(h,3)),this.setAttribute("normal",new He(f,3)),this.setAttribute("uv",new He(d,2));function v(){for(let y=0;y<t;y++)g(y);g(s===!1?t:0),_(),p()}function g(y){u=e.getPointAt(y/t,u);const x=o.normals[y],b=o.binormals[y];for(let w=0;w<=i;w++){const S=w/i*Math.PI*2,M=Math.sin(S),E=-Math.cos(S);c.x=E*x.x+M*b.x,c.y=E*x.y+M*b.y,c.z=E*x.z+M*b.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function p(){for(let y=1;y<=t;y++)for(let x=1;x<=i;x++){const b=(i+1)*(y-1)+(x-1),w=(i+1)*y+(x-1),S=(i+1)*y+x,M=(i+1)*(y-1)+x;m.push(b,w,M),m.push(w,S,M)}}function _(){for(let y=0;y<=t;y++)for(let x=0;x<=i;x++)l.x=y/t,l.y=x/i,d.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ys(new ym[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class xb extends st{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new G,s=new G;if(e.index!==null){const o=e.attributes.position,a=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){const h=c[l],f=h.start,d=h.count;for(let m=f,v=f+d;m<v;m+=3)for(let g=0;g<3;g++){const p=a.getX(m+g),_=a.getX(m+(g+1)%3);i.fromBufferAttribute(o,p),s.fromBufferAttribute(o,_),cv(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}}else{const o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){const u=3*a+l,h=3*a+(l+1)%3;i.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),cv(i,s,n)===!0&&(t.push(i.x,i.y,i.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new He(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function cv(r,e,t){const n=`${r.x},${r.y},${r.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${r.x},${r.y},${r.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var lv=Object.freeze({__proto__:null,BoxGeometry:lr,CapsuleGeometry:Zu,CircleGeometry:Ku,ConeGeometry:Ju,CylinderGeometry:Ts,DodecahedronGeometry:Qu,EdgesGeometry:gb,ExtrudeGeometry:th,IcosahedronGeometry:nh,LatheGeometry:Dc,OctahedronGeometry:Ic,PlaneGeometry:Nr,PolyhedronGeometry:Fr,RingGeometry:ih,ShapeGeometry:rh,SphereGeometry:Uc,TetrahedronGeometry:sh,TorusGeometry:oh,TorusKnotGeometry:ah,TubeGeometry:ys,WireframeGeometry:xb});class bb extends un{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ne(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class wb extends Ni{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xm extends un{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ne(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Or,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Sb extends xm{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new be(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Bt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ne(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ne(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ne(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Eb extends un{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ne(16777215),this.specular=new Ne(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Or,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Rc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Mb extends un{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ne(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Or,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Tb extends un{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Or,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Ab extends un{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ne(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ne(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Or,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Rc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Cb extends un{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ne(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Or,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Rb extends Sn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Kn(r,e,t){return bm(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)}function cs(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function bm(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Pb(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function mp(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let c=0;c!==e;++c)i[o++]=r[a+c]}return i}function wm(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)}function pP(r,e,t,n,i=30){const s=r.clone();s.name=e;const o=[];for(let c=0;c<s.tracks.length;++c){const l=s.tracks[c],u=l.getValueSize(),h=[],f=[];for(let d=0;d<l.times.length;++d){const m=l.times[d]*i;if(!(m<t||m>=n)){h.push(l.times[d]);for(let v=0;v<u;++v)f.push(l.values[d*u+v])}}h.length!==0&&(l.times=cs(h,l.times.constructor),l.values=cs(f,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function mP(r,e=0,t=r,n=30){n<=0&&(n=30);const i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;const l=r.tracks.find(function(p){return p.name===a.name&&p.ValueTypeName===c});if(l===void 0)continue;let u=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let f=0;const d=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);const m=a.times.length-1;let v;if(s<=a.times[0]){const p=u,_=h-u;v=Kn(a.values,p,_)}else if(s>=a.times[m]){const p=m*h+u,_=p+h-u;v=Kn(a.values,p,_)}else{const p=a.createInterpolant(),_=u,y=h-u;p.evaluate(s),v=Kn(p.resultBuffer,_,y)}c==="quaternion"&&new ln().fromArray(v).normalize().conjugate().toArray(v);const g=l.times.length;for(let p=0;p<g;++p){const _=p*d+f;if(c==="quaternion")ln.multiplyQuaternionsFlat(l.values,_,v,0,l.values,_);else{const y=d-f*2;for(let x=0;x<y;++x)l.values[_+x]-=v[x]}}}return r.blendMode=Jp,r}const gP={arraySlice:Kn,convertArray:cs,isTypedArray:bm,getKeyframeOrder:Pb,sortedArray:mp,flattenJSON:wm,subclip:pP,makeClipAdditive:mP};class Oc{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=s)){const a=t[1];e<a&&(n=2,s=a);for(let c=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Lb extends Oc{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ss,endingEnd:ss}}intervalChanged_(e,t,n){const i=this.parameterPositions;let s=e-2,o=e+1,a=i[s],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case os:s=e,a=2*t-n;break;case ic:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case os:o=e,c=2*n-t;break;case ic:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}const l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,d=this._weightNext,m=(n-t)/(i-t),v=m*m,g=v*m,p=-f*g+2*f*v-f*m,_=(1+f)*g+(-1.5-2*f)*v+(-.5+f)*m+1,y=(-1-d)*g+(1.5+d)*v+.5*m,x=d*g-d*v;for(let b=0;b!==a;++b)s[b]=p*o[u+b]+_*o[l+b]+y*o[c+b]+x*o[h+b];return s}}class Sm extends Oc{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(n-t)/(i-t),h=1-u;for(let f=0;f!==a;++f)s[f]=o[l+f]*h+o[c+f]*u;return s}}class Db extends Oc{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Si{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=cs(t,this.TimeBufferType),this.values=cs(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:cs(e.times,Array),values:cs(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Db(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Sm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Lb(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case tc:t=this.InterpolantFactoryMethodDiscrete;break;case nc:t=this.InterpolantFactoryMethodLinear;break;case cu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return tc;case this.InterpolantFactoryMethodLinear:return nc;case this.InterpolantFactoryMethodSmooth:return cu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=Kn(n,s,o),this.values=Kn(this.values,s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&bm(i))for(let a=0,c=i.length;a!==c;++a){const l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=Kn(this.times),t=Kn(this.values),n=this.getValueSize(),i=this.getInterpolation()===cu,s=e.length-1;let o=1;for(let a=1;a<s;++a){let c=!1;const l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(i)c=!0;else{const h=a*n,f=h-n,d=h+n;for(let m=0;m!==n;++m){const v=t[h+m];if(v!==t[f+m]||v!==t[d+m]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];const h=a*n,f=o*n;for(let d=0;d!==n;++d)t[f+d]=t[h+d]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=Kn(e,0,o),this.values=Kn(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=Kn(this.times,0),t=Kn(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Si.prototype.TimeBufferType=Float32Array;Si.prototype.ValueBufferType=Float32Array;Si.prototype.DefaultInterpolation=nc;class As extends Si{}As.prototype.ValueTypeName="bool";As.prototype.ValueBufferType=Array;As.prototype.DefaultInterpolation=tc;As.prototype.InterpolantFactoryMethodLinear=void 0;As.prototype.InterpolantFactoryMethodSmooth=void 0;class Em extends Si{}Em.prototype.ValueTypeName="color";class fc extends Si{}fc.prototype.ValueTypeName="number";class Ib extends Oc{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t);let l=e*a;for(let u=l+a;l!==u;l+=4)ln.slerpFlat(s,0,o,l-a,o,l,c);return s}}class ko extends Si{InterpolantFactoryMethodLinear(e){return new Ib(this.times,this.values,this.getValueSize(),e)}}ko.prototype.ValueTypeName="quaternion";ko.prototype.DefaultInterpolation=nc;ko.prototype.InterpolantFactoryMethodSmooth=void 0;class Cs extends Si{}Cs.prototype.ValueTypeName="string";Cs.prototype.ValueBufferType=Array;Cs.prototype.DefaultInterpolation=tc;Cs.prototype.InterpolantFactoryMethodLinear=void 0;Cs.prototype.InterpolantFactoryMethodSmooth=void 0;class dc extends Si{}dc.prototype.ValueTypeName="vector";class pc{constructor(e,t=-1,n,i=Fu){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Bn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(_P(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(Si.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);const u=Pb(c);c=mp(c,1,u),l=mp(l,1,u),!i&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new fc(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],u=l.name.match(s);if(u&&u.length>1){const h=u[1];let f=i[h];f||(i[h]=f=[]),f.push(l)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,f,d,m,v){if(d.length!==0){const g=[],p=[];wm(d,g,p,m),g.length!==0&&v.push(new h(f,g,p))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h<l.length;h++){const f=l[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const d={};let m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let v=0;v<f[m].morphTargets.length;v++)d[f[m].morphTargets[v]]=-1;for(const v in d){const g=[],p=[];for(let _=0;_!==f[m].morphTargets.length;++_){const y=f[m];g.push(y.time),p.push(y.morphTarget===v?1:0)}i.push(new fc(".morphTargetInfluence["+v+"]",g,p))}c=d.length*o}else{const d=".bones["+t[h].name+"]";n(dc,d+".position",f,"pos",i),n(ko,d+".quaternion",f,"rot",i),n(dc,d+".scale",f,"scl",i)}}return i.length===0?null:new this(s,c,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function vP(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return fc;case"vector":case"vector2":case"vector3":case"vector4":return dc;case"color":return Em;case"quaternion":return ko;case"bool":case"boolean":return As;case"string":return Cs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function _P(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=vP(r.type);if(r.times===void 0){const t=[],n=[];wm(r.keys,t,n,"value"),r.times=t,r.values=n}return e.parse!==void 0?e.parse(r):new e(r.name,r.times,r.values,r.interpolation)}const xs={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class Mm{constructor(e,t,n){const i=this;let s=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,s===!1&&i.onStart!==void 0&&i.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){const d=l[h],m=l[h+1];if(d.global&&(d.lastIndex=0),d.test(u))return m}return null}}}const Ub=new Mm;class Dn{constructor(e){this.manager=e!==void 0?e:Ub,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Dn.DEFAULT_MATERIAL_NAME="__DEFAULT";const Zi={};class yP extends Error{constructor(e,t){super(e),this.response=t}}class sr extends Dn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=xs.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zi[e]!==void 0){Zi[e].push({onLoad:t,onProgress:n,onError:i});return}Zi[e]=[],Zi[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const u=Zi[e],h=l.body.getReader(),f=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=f?parseInt(f):0,m=d!==0;let v=0;const g=new ReadableStream({start(p){_();function _(){h.read().then(({done:y,value:x})=>{if(y)p.close();else{v+=x.byteLength;const b=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:d});for(let w=0,S=u.length;w<S;w++){const M=u[w];M.onProgress&&M.onProgress(b)}p.enqueue(x),_()}})}}});return new Response(g)}else throw new yP(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(m=>d.decode(m))}}}).then(l=>{xs.add(e,l);const u=Zi[e];delete Zi[e];for(let h=0,f=u.length;h<f;h++){const d=u[h];d.onLoad&&d.onLoad(l)}}).catch(l=>{const u=Zi[e];if(u===void 0)throw this.manager.itemError(e),l;delete Zi[e];for(let h=0,f=u.length;h<f;h++){const d=u[h];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class xP extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new sr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=pc.parse(e[n]);t.push(i)}return t}}class bP extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=[],a=new dm,c=new sr(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(h){c.load(e[h],function(f){const d=s.parse(f,!0);o[h]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},l+=1,l===6&&(d.mipmapCount===1&&(a.minFilter=Pt),a.image=o,a.format=d.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let h=0,f=e.length;h<f;++h)u(h);else c.load(e,function(h){const f=s.parse(h,!0);if(f.isCubemap){const d=f.mipmaps.length/f.mipmapCount;for(let m=0;m<d;m++){o[m]={mipmaps:[]};for(let v=0;v<f.mipmapCount;v++)o[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+v]),o[m].format=f.format,o[m].width=f.width,o[m].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=Pt),a.format=f.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}}class mc extends Dn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=xs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=oc("img");function c(){u(),xs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(h){u(),i&&i(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class wP extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=new Lc;s.colorSpace=et;const o=new mc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,i)}for(let l=0;l<e.length;++l)c(l);return s}}class SP extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new So,a=new sr(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){const l=s.parse(c);l&&(l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:gn,o.wrapT=l.wrapT!==void 0?l.wrapT:gn,o.magFilter=l.magFilter!==void 0?l.magFilter:Pt,o.minFilter=l.minFilter!==void 0?l.minFilter:Pt,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0?o.colorSpace=l.colorSpace:l.encoding!==void 0&&(o.encoding=l.encoding),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Dr),l.mipmapCount===1&&(o.minFilter=Pt),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l))},n,i),o}}class Ob extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=new Ft,o=new mc(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class kr extends gt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ne(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class Nb extends kr{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ne(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Cf=new Ke,uv=new G,hv=new G;class Tm{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new be(512,512),this.map=null,this.mapPass=null,this.matrix=new Ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zu,this._frameExtents=new be(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;uv.setFromMatrixPosition(e.matrixWorld),t.position.copy(uv),hv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(hv),t.updateMatrixWorld(),Cf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cf),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Cf)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class EP extends Tm{constructor(){super(new Zt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Co*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Fb extends kr{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new EP}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const fv=new Ke,_a=new G,Rf=new G;class MP extends Tm{constructor(){super(new Zt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new be(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new G(1,0,0),new G(-1,0,0),new G(0,0,1),new G(0,0,-1),new G(0,1,0),new G(0,-1,0)],this._cubeUps=[new G(0,1,0),new G(0,1,0),new G(0,1,0),new G(0,1,0),new G(0,0,1),new G(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),_a.setFromMatrixPosition(e.matrixWorld),n.position.copy(_a),Rf.copy(n.position),Rf.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Rf),n.updateMatrixWorld(),i.makeTranslation(-_a.x,-_a.y,-_a.z),fv.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fv)}}class kb extends kr{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new MP}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class TP extends Tm{constructor(){super(new Ms(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class zb extends kr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new TP}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Bb extends kr{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Gb extends kr{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Vb{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new G)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(n*s)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*n*s),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-i*i)}}class ch extends kr{constructor(e=new Vb,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class lh extends Dn{constructor(e){super(e),this.textures={}}load(e,t,n,i){const s=this,o=new sr(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const i=lh.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new Ne().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==1&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(i.uniforms[s]={},o.type){case"t":i.uniforms[s].value=n(o.value);break;case"c":i.uniforms[s].value=new Ne().setHex(o.value);break;case"v2":i.uniforms[s].value=new be().fromArray(o.value);break;case"v3":i.uniforms[s].value=new G().fromArray(o.value);break;case"v4":i.uniforms[s].value=new mt().fromArray(o.value);break;case"m3":i.uniforms[s].value=new rt().fromArray(o.value);break;case"m4":i.uniforms[s].value=new Ke().fromArray(o.value);break;default:i.uniforms[s].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)i.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new be().fromArray(s)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new be().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:bb,SpriteMaterial:um,RawShaderMaterial:wb,ShaderMaterial:Ni,PointsMaterial:fm,MeshPhysicalMaterial:Sb,MeshStandardMaterial:xm,MeshPhongMaterial:Eb,MeshToonMaterial:Mb,MeshNormalMaterial:Tb,MeshLambertMaterial:Ab,MeshDepthMaterial:Gu,MeshDistanceMaterial:Vu,MeshBasicMaterial:cr,MeshMatcapMaterial:Cb,LineDashedMaterial:Rb,LineBasicMaterial:Sn,Material:un};return new t[e]}}class gp{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Am extends st{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class Hb extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new sr(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(d,m){if(t[m]!==void 0)return t[m];const g=d.interleavedBuffers[m],p=s(d,g.buffer),_=vo(g.type,p),y=new Xu(_,g.stride);return y.uuid=g.uuid,t[m]=y,y}function s(d,m){if(n[m]!==void 0)return n[m];const g=d.arrayBuffers[m],p=new Uint32Array(g).buffer;return n[m]=p,p}const o=e.isInstancedBufferGeometry?new Am:new st,a=e.data.index;if(a!==void 0){const d=vo(a.type,a.array);o.setIndex(new wt(d,1))}const c=e.data.attributes;for(const d in c){const m=c[d];let v;if(m.isInterleavedBufferAttribute){const g=i(e.data,m.data);v=new gs(g,m.itemSize,m.offset,m.normalized)}else{const g=vo(m.type,m.array),p=m.isInstancedBufferAttribute?vs:wt;v=new p(g,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),m.usage!==void 0&&v.setUsage(m.usage),m.updateRange!==void 0&&(v.updateRange.offset=m.updateRange.offset,v.updateRange.count=m.updateRange.count),o.setAttribute(d,v)}const l=e.data.morphAttributes;if(l)for(const d in l){const m=l[d],v=[];for(let g=0,p=m.length;g<p;g++){const _=m[g];let y;if(_.isInterleavedBufferAttribute){const x=i(e.data,_.data);y=new gs(x,_.itemSize,_.offset,_.normalized)}else{const x=vo(_.type,_.array);y=new wt(x,_.itemSize,_.normalized)}_.name!==void 0&&(y.name=_.name),v.push(y)}o.morphAttributes[d]=v}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,m=h.length;d!==m;++d){const v=h[d];o.addGroup(v.start,v.count,v.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const d=new G;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new Wn(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class AP extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=this.path===""?gp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new sr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?gp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const s=new sr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let h=!1;for(const f in o)if(o[f].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const s=new fs().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(s){s.isBone&&(i[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=new qu().fromJSON(e[s],i);n[a.uuid]=a}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new Hb;for(let s=0,o=e.length;s<o;s++){let a;const c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(c);break;default:c.type in lv?a=lv[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const s=new lh;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){const c=e[o];n[c.uuid]===void 0&&(n[c.uuid]=s.parse(c)),i[c.uuid]=n[c.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],s=pc.parse(i);t[s.uuid]=s}return t}parseImages(e,t){const n=this,i={};let s;function o(c){return n.manager.itemStart(c),s.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){const l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:vo(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){const c=new Mm(t);s=new mc(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){const h=e[l],f=h.url;if(Array.isArray(f)){const d=[];for(let m=0,v=f.length;m<v;m++){const g=f[m],p=a(g);p!==null&&(p instanceof HTMLImageElement?d.push(p):d.push(new So(p.data,p.width,p.height)))}i[h.uuid]=new as(d)}else{const d=a(h.url);i[h.uuid]=new as(d)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function s(o){if(typeof o=="string"){const a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await i.loadAsync(c)}else return o.data?{data:vo(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){i=new mc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const c=e[o],l=c.url;if(Array.isArray(l)){const u=[];for(let h=0,f=l.length;h<f;h++){const d=l[h],m=await s(d);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new So(m.data,m.width,m.height)))}n[c.uuid]=new as(u)}else{const u=await s(c.url);n[c.uuid]=new as(u)}}}return n}parseTextures(e,t){function n(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const i={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){const a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const c=t[a.image],l=c.data;let u;Array.isArray(l)?(u=new Lc,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new So:u=new Ft,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,CP)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],dv),u.wrapT=n(a.wrap[1],dv)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.encoding!==void 0&&(u.encoding=a.encoding),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,pv)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,pv)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(e,t,n,i,s){let o;function a(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function c(f){if(f!==void 0){if(Array.isArray(f)){const d=[];for(let m=0,v=f.length;m<v;m++){const g=f[m];n[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(n[g])}return d}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function l(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let u,h;switch(e.type){case"Scene":o=new ac,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ne(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Wu(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Hu(e.fog.color,e.fog.density))),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":o=new Zt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Ms(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Bb(e.color,e.intensity);break;case"DirectionalLight":o=new zb(e.color,e.intensity);break;case"PointLight":o=new kb(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Gb(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Fb(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new Nb(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new ch().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new cb(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new Ot(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);const f=e.count,d=e.instanceMatrix,m=e.instanceColor;o=new lb(u,h,f),o.instanceMatrix=new vs(new Float32Array(d.array),16),m!==void 0&&(o.instanceColor=new vs(new Float32Array(m.array),m.itemSize));break;case"LOD":o=new ab;break;case"Line":o=new Ur(a(e.geometry),c(e.material));break;case"LineLoop":o=new ub(a(e.geometry),c(e.material));break;case"LineSegments":o=new zi(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new hb(a(e.geometry),c(e.material));break;case"Sprite":o=new ob(c(e.material));break;case"Group":o=new yo;break;case"Bone":o=new hm;break;default:o=new gt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let d=0;d<f.length;d++)o.add(this.parseObject(f[d],t,n,i,s))}if(e.animations!==void 0){const f=e.animations;for(let d=0;d<f.length;d++){const m=f[d];o.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const f=e.levels;for(let d=0;d<f.length;d++){const m=f[d],v=o.getObjectByProperty("uuid",m.object);v!==void 0&&o.addLevel(v,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const CP={UVMapping:Ou,CubeReflectionMapping:Pr,CubeRefractionMapping:Lr,EquirectangularReflectionMapping:Ka,EquirectangularRefractionMapping:Ja,CubeUVReflectionMapping:Oo},dv={RepeatWrapping:Qa,ClampToEdgeWrapping:gn,MirroredRepeatWrapping:ec},pv={NearestFilter:Yt,NearestMipmapNearestFilter:_u,NearestMipmapLinearFilter:Ba,LinearFilter:Pt,LinearMipmapNearestFilter:Xp,LinearMipmapLinearFilter:Dr};class RP extends Dn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=xs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){xs.add(e,c),t&&t(c),s.manager.itemEnd(e)}).catch(function(c){i&&i(c),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}let Fl;class Cm{static getContext(){return Fl===void 0&&(Fl=new(window.AudioContext||window.webkitAudioContext)),Fl}static setContext(e){Fl=e}}class PP extends Dn{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new sr(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{const l=c.slice(0);Cm.getContext().decodeAudioData(l,function(h){t(h)},a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),s.manager.itemError(e)}}}class LP extends ch{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=new Ne().set(e),s=new Ne().set(t),o=new G(i.r,i.g,i.b),a=new G(s.r,s.g,s.b),c=Math.sqrt(Math.PI),l=c*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(c),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}}class DP extends ch{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=new Ne().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const mv=new Ke,gv=new Ke,qr=new Ke;class IP{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Zt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Zt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,qr.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,o=t.near*Math.tan(us*t.fov*.5)/t.zoom;let a,c;gv.elements[12]=-i,mv.elements[12]=i,a=-o*t.aspect+s,c=o*t.aspect+s,qr.elements[0]=2*t.near/(c-a),qr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(qr),a=-o*t.aspect-s,c=o*t.aspect-s,qr.elements[0]=2*t.near/(c-a),qr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(qr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(gv),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(mv)}}class Rm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=vv(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=vv();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function vv(){return(typeof performance>"u"?Date:performance).now()}const Yr=new G,_v=new ln,UP=new G,jr=new G;class OP extends gt{constructor(){super(),this.type="AudioListener",this.context=Cm.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Rm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Yr,_v,UP),jr.set(0,0,-1).applyQuaternion(_v),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Yr.x,i),t.positionY.linearRampToValueAtTime(Yr.y,i),t.positionZ.linearRampToValueAtTime(Yr.z,i),t.forwardX.linearRampToValueAtTime(jr.x,i),t.forwardY.linearRampToValueAtTime(jr.y,i),t.forwardZ.linearRampToValueAtTime(jr.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(Yr.x,Yr.y,Yr.z),t.setOrientation(jr.x,jr.y,jr.z,n.x,n.y,n.z)}}class Wb extends gt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const $r=new G,yv=new ln,NP=new G,Zr=new G;class FP extends Wb{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose($r,yv,NP),Zr.set(0,0,1).applyQuaternion(yv);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime($r.x,n),t.positionY.linearRampToValueAtTime($r.y,n),t.positionZ.linearRampToValueAtTime($r.z,n),t.orientationX.linearRampToValueAtTime(Zr.x,n),t.orientationY.linearRampToValueAtTime(Zr.y,n),t.orientationZ.linearRampToValueAtTime(Zr.z,n)}else t.setPosition($r.x,$r.y,$r.z),t.setOrientation(Zr.x,Zr.y,Zr.z)}}class kP{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class Xb{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,s,o;switch(t){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,s=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[s+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let s=n,o=i;s!==o;++s)t[s]=t[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,s){if(i>=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){ln.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,s){const o=this._workIndex*s;ln.multiplyQuaternionsFlat(e,o,e,t,e,n),ln.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,s){const o=1-i;for(let a=0;a!==s;++a){const c=t+a;e[c]=e[c]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,s){for(let o=0;o!==s;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Pm="\\[\\]\\.:\\/",zP=new RegExp("["+Pm+"]","g"),Lm="[^"+Pm+"]",BP="[^"+Pm.replace("\\.","")+"]",GP=/((?:WC+[\/:])*)/.source.replace("WC",Lm),VP=/(WCOD+)?/.source.replace("WCOD",BP),HP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Lm),WP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Lm),XP=new RegExp("^"+GP+VP+HP+WP+"$"),qP=["material","materials","bones","map"];class YP{constructor(e,t,n){const i=n||ht.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ht{constructor(e,t,n){this.path=t,this.parsedPath=n||ht.parseTrackName(t),this.node=ht.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ht.Composite(e,t,n):new ht(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(zP,"")}static parseTrackName(e){const t=XP.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);qP.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===t||a.uuid===t)return a;const c=n(a.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let s=t.propertyIndex;if(e||(e=ht.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[i];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ht.Composite=YP;ht.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ht.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ht.prototype.GetterByBindingType=[ht.prototype._getValue_direct,ht.prototype._getValue_array,ht.prototype._getValue_arrayElement,ht.prototype._getValue_toArray];ht.prototype.SetterByBindingTypeAndVersioning=[[ht.prototype._setValue_direct,ht.prototype._setValue_direct_setNeedsUpdate,ht.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ht.prototype._setValue_array,ht.prototype._setValue_array_setNeedsUpdate,ht.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ht.prototype._setValue_arrayElement,ht.prototype._setValue_arrayElement_setNeedsUpdate,ht.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ht.prototype._setValue_fromArray,ht.prototype._setValue_fromArray_setNeedsUpdate,ht.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class jP{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Bn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,s=this._bindings,o=s.length;let a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const f=arguments[u],d=f.uuid;let m=t[d];if(m===void 0){m=c++,t[d]=m,e.push(f);for(let v=0,g=o;v!==g;++v)s[v].push(new ht(f,n[v],i[v]))}else if(m<l){a=e[m];const v=--l,g=e[v];t[g.uuid]=m,e[m]=g,t[d]=v,e[v]=f;for(let p=0,_=o;p!==_;++p){const y=s[p],x=y[v];let b=y[m];y[m]=x,b===void 0&&(b=new ht(f,n[p],i[p])),y[v]=b}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){const h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,m=i;d!==m;++d){const v=n[d],g=v[h],p=v[u];v[u]=g,v[h]=p}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){const l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const f=--s,d=e[f],m=--o,v=e[m];t[d.uuid]=h,e[h]=d,t[v.uuid]=f,e[f]=v,e.pop();for(let g=0,p=i;g!==p;++g){const _=n[g],y=_[f],x=_[m];_[h]=y,_[f]=x,_.pop()}}else{const f=--o,d=e[f];f>0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let m=0,v=i;m!==v;++m){const g=n[m];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const s=this._bindings;if(i!==void 0)return s[i];const o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=s.length,n[e]=i,o.push(e),a.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){const m=c[f];h[f]=new ht(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=n,o[n]=c,o.pop(),s[n]=s[a],s.pop(),i[n]=i[a],i.pop()}}}class qb{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const s=t.tracks,o=s.length,a=new Array(o),c={endingStart:ss,endingEnd:ss};for(let l=0;l!==o;++l){const u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Lx,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,s=e._clip.duration,o=s/i,a=i/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,s=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const c=(e-s)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Jp:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Fu:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,s=this._loopCount;const o=n===Dx;if(e===0)return s===-1?i:o&&(s&1)===1?t-i:i;if(n===Px){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,s+=Math.abs(a);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=os,i.endingEnd=os):(e?i.endingStart=this.zeroSlopeAtStart?os:ss:i.endingStart=ic,t?i.endingEnd=this.zeroSlopeAtEnd?os:ss:i.endingEnd=ic)}_scheduleFading(e,t,n){const i=this._mixer,s=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=n,this}}const $P=new Float32Array(1);class ZP extends ar{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,s=i.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){const f=i[h],d=f.name;let m=u[d];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,d));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new Xb(ht.create(n,d,v),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,d),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,s=this._actionsByClip;let o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;const h=a.actionByRoot,f=(e._localRoot||this._root).uuid;delete h[f],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,s=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,s=t[i];e._cacheIndex=i,t[i]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Sm(new Float32Array(2),new Float32Array(2),1,$P),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,s=t[i];e.__cacheIndex=i,t[i]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){const i=t||this._root,s=i.uuid;let o=typeof e=="string"?pc.findByName(i,e):e;const a=o!==null?o.uuid:e,c=this._actionsByClip[a];let l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Fu),c!==void 0){const h=c.actionByRoot[s];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;const u=new qb(this,o,t,n);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){const n=t||this._root,i=n.uuid,s=typeof e=="string"?pc.findByName(n,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,s,o);const a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,s=i[n];if(s!==void 0){const o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){const l=o[a];this._deactivateAction(l);const u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const i=this._bindingsByRootAndName,s=i[t];if(s!==void 0)for(const o in s){const a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class Dm{constructor(e){this.value=e}clone(){return new Dm(this.value.clone===void 0?this.value:this.value.clone())}}let KP=0;class JP extends ar{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:KP++}),this.name="",this.usage=rc,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++)this.uniforms.push(t[n].clone());return this}clone(){return new this.constructor().copy(this)}}class QP extends Xu{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class eL{constructor(e,t,n,i,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class Im{constructor(e,t,n=0,i=1/0){this.ray=new No(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new hs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return vp(e,this,n,t),n.sort(xv),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)vp(e[i],this,n,t);return n.sort(xv),n}}function xv(r,e){return r.distance-e.distance}function vp(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){const i=r.children;for(let s=0,o=i.length;s<o;s++)vp(i[s],e,t,!0)}}class Yb{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Bt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class tL{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}const bv=new be;class nL{constructor(e=new be(1/0,1/0),t=new be(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=bv.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,bv).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const wv=new G,kl=new G;class iL{constructor(e=new G,t=new G){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){wv.subVectors(e,this.start),kl.subVectors(this.end,this.start);const n=kl.dot(kl);let s=kl.dot(wv)/n;return t&&(s=Bt(s,0,1)),s}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Sv=new G;class rL extends gt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new st,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){const l=o/c*Math.PI*2,u=a/c*Math.PI*2;i.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new He(i,3));const s=new Sn({fog:!1,toneMapped:!1});this.cone=new zi(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Sv.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Sv),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const yr=new G,zl=new Ke,Pf=new Ke;class sL extends zi{constructor(e){const t=jb(e),n=new st,i=[],s=[],o=new Ne(0,0,1),a=new Ne(0,1,0);for(let l=0;l<t.length;l++){const u=t[l];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}n.setAttribute("position",new He(i,3)),n.setAttribute("color",new He(s,3));const c=new Sn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Pf.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){const a=t[s];a.parent&&a.parent.isBone&&(zl.multiplyMatrices(Pf,a.matrixWorld),yr.setFromMatrixPosition(zl),i.setXYZ(o,yr.x,yr.y,yr.z),zl.multiplyMatrices(Pf,a.parent.matrixWorld),yr.setFromMatrixPosition(zl),i.setXYZ(o+1,yr.x,yr.y,yr.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function jb(r){const e=[];r.isBone===!0&&e.push(r);for(let t=0;t<r.children.length;t++)e.push.apply(e,jb(r.children[t]));return e}class oL extends Ot{constructor(e,t,n){const i=new Uc(t,4,2),s=new cr({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const aL=new G,Ev=new Ne,Mv=new Ne;class cL extends gt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new Ic(t);i.rotateY(Math.PI*.5),this.material=new cr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=i.getAttribute("position"),o=new Float32Array(s.count*3);i.setAttribute("color",new wt(o,3)),this.add(new Ot(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Ev.copy(this.light.color),Mv.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const s=n<i/2?Ev:Mv;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(aL.setFromMatrixPosition(this.light.matrixWorld).negate())}}class lL extends zi{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ne(n),i=new Ne(i);const s=t/2,o=e/t,a=e/2,c=[],l=[];for(let f=0,d=0,m=-a;f<=t;f++,m+=o){c.push(-a,0,m,a,0,m),c.push(m,0,-a,m,0,a);const v=f===s?n:i;v.toArray(l,d),d+=3,v.toArray(l,d),d+=3,v.toArray(l,d),d+=3,v.toArray(l,d),d+=3}const u=new st;u.setAttribute("position",new He(c,3)),u.setAttribute("color",new He(l,3));const h=new Sn({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class uL extends zi{constructor(e=10,t=16,n=8,i=64,s=4473924,o=8947848){s=new Ne(s),o=new Ne(o);const a=[],c=[];if(t>1)for(let h=0;h<t;h++){const f=h/t*(Math.PI*2),d=Math.sin(f)*e,m=Math.cos(f)*e;a.push(0,0,0),a.push(d,0,m);const v=h&1?s:o;c.push(v.r,v.g,v.b),c.push(v.r,v.g,v.b)}for(let h=0;h<n;h++){const f=h&1?s:o,d=e-e/n*h;for(let m=0;m<i;m++){let v=m/i*(Math.PI*2),g=Math.sin(v)*d,p=Math.cos(v)*d;a.push(g,0,p),c.push(f.r,f.g,f.b),v=(m+1)/i*(Math.PI*2),g=Math.sin(v)*d,p=Math.cos(v)*d,a.push(g,0,p),c.push(f.r,f.g,f.b)}}const l=new st;l.setAttribute("position",new He(a,3)),l.setAttribute("color",new He(c,3));const u=new Sn({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Tv=new G,Bl=new G,Av=new G;class hL extends gt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new st;i.setAttribute("position",new He([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Sn({fog:!1,toneMapped:!1});this.lightPlane=new Ur(i,s),this.add(this.lightPlane),i=new st,i.setAttribute("position",new He([0,0,0,0,0,1],3)),this.targetLine=new Ur(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Tv.setFromMatrixPosition(this.light.matrixWorld),Bl.setFromMatrixPosition(this.light.target.matrixWorld),Av.subVectors(Bl,Tv),this.lightPlane.lookAt(Bl),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Bl),this.targetLine.scale.z=Av.length()}}const Gl=new G,zt=new Pc;class fL extends zi{constructor(e){const t=new st,n=new Sn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,v){c(m),c(v)}function c(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new He(i,3)),t.setAttribute("color",new He(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new Ne(16755200),u=new Ne(16711680),h=new Ne(43775),f=new Ne(16777215),d=new Ne(3355443);this.setColors(l,u,h,f,d)}setColors(e,t,n,i,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;zt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),qt("c",t,e,zt,0,0,-1),qt("t",t,e,zt,0,0,1),qt("n1",t,e,zt,-n,-i,-1),qt("n2",t,e,zt,n,-i,-1),qt("n3",t,e,zt,-n,i,-1),qt("n4",t,e,zt,n,i,-1),qt("f1",t,e,zt,-n,-i,1),qt("f2",t,e,zt,n,-i,1),qt("f3",t,e,zt,-n,i,1),qt("f4",t,e,zt,n,i,1),qt("u1",t,e,zt,n*.7,i*1.1,-1),qt("u2",t,e,zt,-n*.7,i*1.1,-1),qt("u3",t,e,zt,0,i*2,-1),qt("cf1",t,e,zt,-n,0,1),qt("cf2",t,e,zt,n,0,1),qt("cf3",t,e,zt,0,-i,1),qt("cf4",t,e,zt,0,i,1),qt("cn1",t,e,zt,-n,0,-1),qt("cn2",t,e,zt,n,0,-1),qt("cn3",t,e,zt,0,-i,-1),qt("cn4",t,e,zt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function qt(r,e,t,n,i,s,o){Gl.set(i,s,o).unproject(n);const a=e[r];if(a!==void 0){const c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],Gl.x,Gl.y,Gl.z)}}const Vl=new Hn;class dL extends zi{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),s=new st;s.setIndex(new wt(n,1)),s.setAttribute("position",new wt(i,3)),super(s,new Sn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Vl.setFromObject(this.object),Vl.isEmpty())return;const t=Vl.min,n=Vl.max,i=this.geometry.attributes.position,s=i.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class pL extends zi{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new st;s.setIndex(new wt(n,1)),s.setAttribute("position",new He(i,3)),super(s,new Sn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class mL extends Ur{constructor(e,t=1,n=16776960){const i=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new st;o.setAttribute("position",new He(s,3)),o.computeBoundingSphere(),super(o,new Sn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new st;c.setAttribute("position",new He(a,3)),c.computeBoundingSphere(),this.add(new Ot(c,new cr({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Cv=new G;let Hl,Lf;class gL extends gt{constructor(e=new G(0,0,1),t=new G(0,0,0),n=1,i=16776960,s=n*.2,o=s*.2){super(),this.type="ArrowHelper",Hl===void 0&&(Hl=new st,Hl.setAttribute("position",new He([0,0,0,0,1,0],3)),Lf=new Ts(0,.5,1,5,1),Lf.translate(0,-.5,0)),this.position.copy(t),this.line=new Ur(Hl,new Sn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ot(Lf,new cr({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Cv.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Cv,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class vL extends zi{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new st;i.setAttribute("position",new He(t,3)),i.setAttribute("color",new He(n,3));const s=new Sn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){const i=new Ne,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class _L{constructor(){this.type="ShapePath",this.color=new Ne,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new cc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(p){const _=[];for(let y=0,x=p.length;y<x;y++){const b=p[y],w=new fs;w.curves=b.curves,_.push(w)}return _}function n(p,_){const y=_.length;let x=!1;for(let b=y-1,w=0;w<y;b=w++){let S=_[b],M=_[w],E=M.x-S.x,T=M.y-S.y;if(Math.abs(T)>Number.EPSILON){if(T<0&&(S=_[w],E=-E,M=_[b],T=-T),p.y<S.y||p.y>M.y)continue;if(p.y===S.y){if(p.x===S.x)return!0}else{const L=T*(p.x-S.x)-E*(p.y-S.y);if(L===0)return!0;if(L<0)continue;x=!x}}else{if(p.y!==S.y)continue;if(M.x<=p.x&&p.x<=S.x||S.x<=p.x&&p.x<=M.x)return!0}}return x}const i=Ui.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c;const l=[];if(s.length===1)return a=s[0],c=new fs,c.curves=a.curves,l.push(c),l;let u=!i(s[0].getPoints());u=e?!u:u;const h=[],f=[];let d=[],m=0,v;f[m]=void 0,d[m]=[];for(let p=0,_=s.length;p<_;p++)a=s[p],v=a.getPoints(),o=i(v),o=e?!o:o,o?(!u&&f[m]&&m++,f[m]={s:new fs,p:v},f[m].s.curves=a.curves,u&&m++,d[m]=[]):d[m].push({h:a,p:v[0]});if(!f[0])return t(s);if(f.length>1){let p=!1,_=0;for(let y=0,x=f.length;y<x;y++)h[y]=[];for(let y=0,x=f.length;y<x;y++){const b=d[y];for(let w=0;w<b.length;w++){const S=b[w];let M=!0;for(let E=0;E<f.length;E++)n(S.p,f[E].p)&&(y!==E&&_++,M?(M=!1,h[E].push(S)):p=!0);M&&h[y].push(S)}}_>0&&p===!1&&(d=h)}let g;for(let p=0,_=f.length;p<_;p++){c=f[p].s,l.push(c),g=d[p];for(let y=0,x=g.length;y<x;y++)c.holes.push(g[y].h)}return l}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Iu}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Iu);const $b=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Wp,AddEquation:ns,AddOperation:gx,AdditiveAnimationBlendMode:Jp,AdditiveBlending:Ud,AlphaFormat:Sx,AlwaysCompare:Hx,AlwaysDepth:lx,AlwaysStencilFunc:Ox,AmbientLight:Bb,AmbientLightProbe:DP,AnimationAction:qb,AnimationClip:pc,AnimationLoader:xP,AnimationMixer:ZP,AnimationObjectGroup:jP,AnimationUtils:gP,ArcCurve:fb,ArrayCamera:nb,ArrowHelper:gL,Audio:Wb,AudioAnalyser:kP,AudioContext:Cm,AudioListener:OP,AudioLoader:PP,AxesHelper:vL,BackSide:vn,BasicDepthPacking:Ix,BasicShadowMap:$y,Bone:hm,BooleanKeyframeTrack:As,Box2:nL,Box3:Hn,Box3Helper:pL,BoxGeometry:lr,BoxHelper:dL,BufferAttribute:wt,BufferGeometry:st,BufferGeometryLoader:Hb,ByteType:bx,Cache:xs,Camera:Pc,CameraHelper:fL,CanvasTexture:BR,CapsuleGeometry:Zu,CatmullRomCurve3:db,CineonToneMapping:yx,CircleGeometry:Ku,ClampToEdgeWrapping:gn,Clock:Rm,Color:Ne,ColorKeyframeTrack:Em,ColorManagement:Zn,CompressedArrayTexture:zR,CompressedTexture:dm,CompressedTextureLoader:bP,ConeGeometry:Ju,CubeCamera:jx,CubeReflectionMapping:Pr,CubeRefractionMapping:Lr,CubeTexture:Lc,CubeTextureLoader:wP,CubeUVReflectionMapping:Oo,CubicBezierCurve:mm,CubicBezierCurve3:pb,CubicInterpolant:Lb,CullFaceBack:Id,CullFaceFront:jy,CullFaceFrontBack:UE,CullFaceNone:Yy,Curve:wi,CurvePath:mb,CustomBlending:Zy,CustomToneMapping:xx,CylinderGeometry:Ts,Cylindrical:tL,Data3DTexture:rm,DataArrayTexture:ku,DataTexture:So,DataTextureLoader:SP,DataUtils:qM,DecrementStencilOp:qE,DecrementWrapStencilOp:jE,DefaultLoadingManager:Ub,DepthFormat:Tr,DepthStencilFormat:ms,DepthTexture:ib,DirectionalLight:zb,DirectionalLightHelper:hL,DiscreteInterpolant:Db,DisplayP3ColorSpace:tm,DodecahedronGeometry:Qu,DoubleSide:Dt,DstAlphaFactor:ix,DstColorFactor:sx,DynamicCopyUsage:lM,DynamicDrawUsage:iM,DynamicReadUsage:oM,EdgesGeometry:gb,EllipseCurve:Yu,EqualCompare:kx,EqualDepth:hx,EqualStencilFunc:JE,EquirectangularReflectionMapping:Ka,EquirectangularRefractionMapping:Ja,Euler:Ir,EventDispatcher:ar,ExtrudeGeometry:th,FileLoader:sr,Float16BufferAttribute:JM,Float32BufferAttribute:He,Float64BufferAttribute:QM,FloatType:Li,Fog:Wu,FogExp2:Hu,FramebufferTexture:kR,FrontSide:Oi,Frustum:zu,GLBufferAttribute:eL,GLSL1:hM,GLSL3:cp,GreaterCompare:Bx,GreaterDepth:dx,GreaterEqualCompare:Vx,GreaterEqualDepth:fx,GreaterEqualStencilFunc:nM,GreaterStencilFunc:eM,GridHelper:lL,Group:yo,HalfFloatType:Ao,HemisphereLight:Nb,HemisphereLightHelper:cL,HemisphereLightProbe:LP,IcosahedronGeometry:nh,ImageBitmapLoader:RP,ImageLoader:mc,ImageUtils:im,IncrementStencilOp:XE,IncrementWrapStencilOp:YE,InstancedBufferAttribute:vs,InstancedBufferGeometry:Am,InstancedInterleavedBuffer:QP,InstancedMesh:lb,Int16BufferAttribute:ZM,Int32BufferAttribute:KM,Int8BufferAttribute:YM,IntType:qp,InterleavedBuffer:Xu,InterleavedBufferAttribute:gs,Interpolant:Oc,InterpolateDiscrete:tc,InterpolateLinear:nc,InterpolateSmooth:cu,InvertStencilOp:$E,KeepStencilOp:lu,KeyframeTrack:Si,LOD:ab,LatheGeometry:Dc,Layers:hs,LessCompare:Fx,LessDepth:ux,LessEqualCompare:zx,LessEqualDepth:vu,LessEqualStencilFunc:QE,LessStencilFunc:KE,Light:kr,LightProbe:ch,Line:Ur,Line3:iL,LineBasicMaterial:Sn,LineCurve:ju,LineCurve3:gm,LineDashedMaterial:Rb,LineLoop:ub,LineSegments:zi,LinearEncoding:Qp,LinearFilter:Pt,LinearInterpolant:Sm,LinearMipMapLinearFilter:zE,LinearMipMapNearestFilter:kE,LinearMipmapLinearFilter:Dr,LinearMipmapNearestFilter:Xp,LinearSRGBColorSpace:xi,LinearToneMapping:vx,Loader:Dn,LoaderUtils:gp,LoadingManager:Mm,LoopOnce:Px,LoopPingPong:Dx,LoopRepeat:Lx,LuminanceAlphaFormat:Mx,LuminanceFormat:Ex,MOUSE:qy,Material:un,MaterialLoader:lh,MathUtils:bu,Matrix3:rt,Matrix4:Ke,MaxEquation:kd,Mesh:Ot,MeshBasicMaterial:cr,MeshDepthMaterial:Gu,MeshDistanceMaterial:Vu,MeshLambertMaterial:Ab,MeshMatcapMaterial:Cb,MeshNormalMaterial:Tb,MeshPhongMaterial:Eb,MeshPhysicalMaterial:Sb,MeshStandardMaterial:xm,MeshToonMaterial:Mb,MinEquation:Fd,MirroredRepeatWrapping:ec,MixOperation:mx,MultiplyBlending:Nd,MultiplyOperation:Rc,NearestFilter:Yt,NearestMipMapLinearFilter:FE,NearestMipMapNearestFilter:NE,NearestMipmapLinearFilter:Ba,NearestMipmapNearestFilter:_u,NeverCompare:Nx,NeverDepth:cx,NeverStencilFunc:ZE,NoBlending:nr,NoColorSpace:Cr,NoToneMapping:yi,NormalAnimationBlendMode:Fu,NormalBlending:ls,NotEqualCompare:Gx,NotEqualDepth:px,NotEqualStencilFunc:tM,NumberKeyframeTrack:fc,Object3D:gt,ObjectLoader:AP,ObjectSpaceNormalMap:Ux,OctahedronGeometry:Ic,OneFactor:ex,OneMinusDstAlphaFactor:rx,OneMinusDstColorFactor:ox,OneMinusSrcAlphaFactor:Hp,OneMinusSrcColorFactor:nx,OrthographicCamera:Ms,PCFShadowMap:Uu,PCFSoftShadowMap:za,PMREMGenerator:up,Path:cc,PerspectiveCamera:Zt,Plane:Qi,PlaneGeometry:Nr,PlaneHelper:mL,PointLight:kb,PointLightHelper:oL,Points:hb,PointsMaterial:fm,PolarGridHelper:uL,PolyhedronGeometry:Fr,PositionalAudio:FP,PropertyBinding:ht,PropertyMixer:Xb,QuadraticBezierCurve:vm,QuadraticBezierCurve3:$u,Quaternion:ln,QuaternionKeyframeTrack:ko,QuaternionLinearInterpolant:Ib,RED_GREEN_RGTC2_Format:op,RED_RGTC1_Format:Rx,REVISION:Iu,RGBADepthPacking:em,RGBAFormat:Ln,RGBAIntegerFormat:Kp,RGBA_ASTC_10x10_Format:np,RGBA_ASTC_10x5_Format:Qd,RGBA_ASTC_10x6_Format:ep,RGBA_ASTC_10x8_Format:tp,RGBA_ASTC_12x10_Format:ip,RGBA_ASTC_12x12_Format:rp,RGBA_ASTC_4x4_Format:Xd,RGBA_ASTC_5x4_Format:qd,RGBA_ASTC_5x5_Format:Yd,RGBA_ASTC_6x5_Format:jd,RGBA_ASTC_6x6_Format:$d,RGBA_ASTC_8x5_Format:Zd,RGBA_ASTC_8x6_Format:Kd,RGBA_ASTC_8x8_Format:Jd,RGBA_BPTC_Format:au,RGBA_ETC2_EAC_Format:Wd,RGBA_PVRTC_2BPPV1_Format:Vd,RGBA_PVRTC_4BPPV1_Format:Gd,RGBA_S3TC_DXT1_Format:ru,RGBA_S3TC_DXT3_Format:su,RGBA_S3TC_DXT5_Format:ou,RGB_ETC1_Format:Cx,RGB_ETC2_Format:Hd,RGB_PVRTC_2BPPV1_Format:Bd,RGB_PVRTC_4BPPV1_Format:zd,RGB_S3TC_DXT1_Format:iu,RGFormat:Ax,RGIntegerFormat:Zp,RawShaderMaterial:wb,Ray:No,Raycaster:Im,RectAreaLight:Gb,RedFormat:Tx,RedIntegerFormat:$p,ReinhardToneMapping:_x,RepeatWrapping:Qa,ReplaceStencilOp:WE,ReverseSubtractEquation:Jy,RingGeometry:ih,SIGNED_RED_GREEN_RGTC2_Format:ap,SIGNED_RED_RGTC1_Format:sp,SRGBColorSpace:et,Scene:ac,ShaderChunk:Qe,ShaderLib:gi,ShaderMaterial:Ni,ShadowMaterial:bb,Shape:fs,ShapeGeometry:rh,ShapePath:_L,ShapeUtils:Ui,ShortType:wx,Skeleton:qu,SkeletonHelper:sL,SkinnedMesh:cb,Source:as,Sphere:Wn,SphereGeometry:Uc,Spherical:Yb,SphericalHarmonics3:Vb,SplineCurve:_m,SpotLight:Fb,SpotLightHelper:rL,Sprite:ob,SpriteMaterial:um,SrcAlphaFactor:Vp,SrcAlphaSaturateFactor:ax,SrcColorFactor:tx,StaticCopyUsage:cM,StaticDrawUsage:rc,StaticReadUsage:sM,StereoCamera:IP,StreamCopyUsage:uM,StreamDrawUsage:rM,StreamReadUsage:aM,StringKeyframeTrack:Cs,SubtractEquation:Ky,SubtractiveBlending:Od,TOUCH:IE,TangentSpaceNormalMap:Or,TetrahedronGeometry:sh,Texture:Ft,TextureLoader:Ob,TorusGeometry:oh,TorusKnotGeometry:ah,Triangle:Pn,TriangleFanDrawMode:VE,TriangleStripDrawMode:GE,TrianglesDrawMode:BE,TubeGeometry:ys,TwoPassDoubleSide:OE,UVMapping:Ou,Uint16BufferAttribute:sm,Uint32BufferAttribute:om,Uint8BufferAttribute:jM,Uint8ClampedBufferAttribute:$M,Uniform:Dm,UniformsGroup:JP,UniformsLib:ke,UniformsUtils:am,UnsignedByteType:Ii,UnsignedInt248Type:Mr,UnsignedIntType:tr,UnsignedShort4444Type:Yp,UnsignedShort5551Type:jp,UnsignedShortType:Nu,VSMShadowMap:mi,Vector2:be,Vector3:G,Vector4:mt,VectorKeyframeTrack:dc,VideoTexture:FR,WebGL1Renderer:rb,WebGL3DRenderTarget:OM,WebGLArrayRenderTarget:UM,WebGLCoordinateSystem:Di,WebGLCubeRenderTarget:$x,WebGLMultipleRenderTargets:NM,WebGLRenderTarget:bi,WebGLRenderer:lm,WebGLUtils:tb,WebGPUCoordinateSystem:sc,WireframeGeometry:xb,WrapAroundEnding:ic,ZeroCurvatureEnding:ss,ZeroFactor:Qy,ZeroSlopeEnding:os,ZeroStencilOp:HE,_SRGBAFormat:yu,sRGBEncoding:Ar},Symbol.toStringTag,{value:"Module"}));function yL(r){let e;const t=new Set,n=(l,u)=>{const h=typeof l=="function"?l(e):l;if(h!==e){const f=e;e=u?h:Object.assign({},e,h),t.forEach(d=>d(e,f))}},i=()=>e,s=(l,u=i,h=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let f=u(e);function d(){const m=u(e);if(!h(f,m)){const v=f;l(f=m,v)}}return t.add(d),()=>t.delete(d)},c={setState:n,getState:i,subscribe:(l,u,h)=>u||h?s(l,u,h):(t.add(l),()=>t.delete(l)),destroy:()=>t.clear()};return e=r(n,i,c),c}const xL=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),Rv=xL?q.useEffect:q.useLayoutEffect;function bL(r){const e=typeof r=="function"?yL(r):r,t=(n=e.getState,i=Object.is)=>{const[,s]=q.useReducer(g=>g+1,0),o=e.getState(),a=q.useRef(o),c=q.useRef(n),l=q.useRef(i),u=q.useRef(!1),h=q.useRef();h.current===void 0&&(h.current=n(o));let f,d=!1;(a.current!==o||c.current!==n||l.current!==i||u.current)&&(f=n(o),d=!i(h.current,f)),Rv(()=>{d&&(h.current=f),a.current=o,c.current=n,l.current=i,u.current=!1});const m=q.useRef(o);Rv(()=>{const g=()=>{try{const _=e.getState(),y=c.current(_);l.current(h.current,y)||(a.current=_,h.current=y,s())}catch{u.current=!0,s()}},p=e.subscribe(g);return e.getState()!==m.current&&g(),p},[]);const v=d?f:h.current;return q.useDebugValue(v),v};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const n=[t,e];return{next(){const i=n.length<=0;return{value:n.shift(),done:i}}}},t}var Df={exports:{}},If={};/**
|
|
* @license React
|
|
* scheduler.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/var Pv;function wL(){return Pv||(Pv=1,(function(r){function e(O,k){var U=O.length;O.push(k);e:for(;0<U;){var R=U-1>>>1,F=O[R];if(0<i(F,k))O[R]=k,O[U]=F,U=R;else break e}}function t(O){return O.length===0?null:O[0]}function n(O){if(O.length===0)return null;var k=O[0],U=O.pop();if(U!==k){O[0]=U;e:for(var R=0,F=O.length,H=F>>>1;R<H;){var Y=2*(R+1)-1,J=O[Y],ie=Y+1,ne=O[ie];if(0>i(J,U))ie<F&&0>i(ne,J)?(O[R]=ne,O[ie]=U,R=ie):(O[R]=J,O[Y]=U,R=Y);else if(ie<F&&0>i(ne,U))O[R]=ne,O[ie]=U,R=ie;else break e}}return k}function i(O,k){var U=O.sortIndex-k.sortIndex;return U!==0?U:O.id-k.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;r.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();r.unstable_now=function(){return o.now()-a}}var c=[],l=[],u=1,h=null,f=3,d=!1,m=!1,v=!1,g=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(O){for(var k=t(l);k!==null;){if(k.callback===null)n(l);else if(k.startTime<=O)n(l),k.sortIndex=k.expirationTime,e(c,k);else break;k=t(l)}}function x(O){if(v=!1,y(O),!m)if(t(c)!==null)m=!0,N(b);else{var k=t(l);k!==null&&C(x,k.startTime-O)}}function b(O,k){m=!1,v&&(v=!1,p(M),M=-1),d=!0;var U=f;try{for(y(k),h=t(c);h!==null&&(!(h.expirationTime>k)||O&&!L());){var R=h.callback;if(typeof R=="function"){h.callback=null,f=h.priorityLevel;var F=R(h.expirationTime<=k);k=r.unstable_now(),typeof F=="function"?h.callback=F:h===t(c)&&n(c),y(k)}else n(c);h=t(c)}if(h!==null)var H=!0;else{var Y=t(l);Y!==null&&C(x,Y.startTime-k),H=!1}return H}finally{h=null,f=U,d=!1}}var w=!1,S=null,M=-1,E=5,T=-1;function L(){return!(r.unstable_now()-T<E)}function P(){if(S!==null){var O=r.unstable_now();T=O;var k=!0;try{k=S(!0,O)}finally{k?A():(w=!1,S=null)}}else w=!1}var A;if(typeof _=="function")A=function(){_(P)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,V=z.port2;z.port1.onmessage=P,A=function(){V.postMessage(null)}}else A=function(){g(P,0)};function N(O){S=O,w||(w=!0,A())}function C(O,k){M=g(function(){O(r.unstable_now())},k)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(O){O.callback=null},r.unstable_continueExecution=function(){m||d||(m=!0,N(b))},r.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<O?Math.floor(1e3/O):5},r.unstable_getCurrentPriorityLevel=function(){return f},r.unstable_getFirstCallbackNode=function(){return t(c)},r.unstable_next=function(O){switch(f){case 1:case 2:case 3:var k=3;break;default:k=f}var U=f;f=k;try{return O()}finally{f=U}},r.unstable_pauseExecution=function(){},r.unstable_requestPaint=function(){},r.unstable_runWithPriority=function(O,k){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var U=f;f=O;try{return k()}finally{f=U}},r.unstable_scheduleCallback=function(O,k,U){var R=r.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?R+U:R):U=R,O){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=U+F,O={id:u++,callback:k,priorityLevel:O,startTime:U,expirationTime:F,sortIndex:-1},U>R?(O.sortIndex=U,e(l,O),t(c)===null&&O===t(l)&&(v?(p(M),M=-1):v=!0,C(x,U-R))):(O.sortIndex=F,e(c,O),m||d||(m=!0,N(b))),O},r.unstable_shouldYield=L,r.unstable_wrapCallback=function(O){var k=f;return function(){var U=f;f=k;try{return O.apply(this,arguments)}finally{f=U}}}})(If)),If}var Lv;function SL(){return Lv||(Lv=1,Df.exports=wL()),Df.exports}var Dv=SL();const Um={},Zb=r=>void Object.assign(Um,r);function EL(r,e){function t(u,{args:h=[],attach:f,...d},m){let v=`${u[0].toUpperCase()}${u.slice(1)}`,g;if(u==="primitive"){if(d.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const p=d.object;g=po(p,{type:u,root:m,attach:f,primitive:!0})}else{const p=Um[v];if(!p)throw new Error(`R3F: ${v} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(h))throw new Error("R3F: The args prop must be an array!");g=po(new p(...h),{type:u,root:m,attach:f,memoizedProps:{args:h}})}return g.__r3f.attach===void 0&&(g instanceof st?g.__r3f.attach="geometry":g instanceof un&&(g.__r3f.attach="material")),v!=="inject"&&Nf(g,d),g}function n(u,h){let f=!1;if(h){var d,m;(d=h.__r3f)!=null&&d.attach?Of(u,h,h.__r3f.attach):h.isObject3D&&u.isObject3D&&(u.add(h),f=!0),f||(m=u.__r3f)==null||m.objects.push(h),h.__r3f||po(h,{}),h.__r3f.parent=u,yp(h),mo(h)}}function i(u,h,f){let d=!1;if(h){var m,v;if((m=h.__r3f)!=null&&m.attach)Of(u,h,h.__r3f.attach);else if(h.isObject3D&&u.isObject3D){h.parent=u,h.dispatchEvent({type:"added"});const g=u.children.filter(_=>_!==h),p=g.indexOf(f);u.children=[...g.slice(0,p),h,...g.slice(p)],d=!0}d||(v=u.__r3f)==null||v.objects.push(h),h.__r3f||po(h,{}),h.__r3f.parent=u,yp(h),mo(h)}}function s(u,h,f=!1){u&&[...u].forEach(d=>o(h,d,f))}function o(u,h,f){if(h){var d,m,v;if(h.__r3f&&(h.__r3f.parent=null),(d=u.__r3f)!=null&&d.objects&&(u.__r3f.objects=u.__r3f.objects.filter(x=>x!==h)),(m=h.__r3f)!=null&&m.attach)Fv(u,h,h.__r3f.attach);else if(h.isObject3D&&u.isObject3D){var g;u.remove(h),(g=h.__r3f)!=null&&g.root&&LL(h.__r3f.root,h)}const _=(v=h.__r3f)==null?void 0:v.primitive,y=f===void 0?h.dispose!==null&&!_:f;if(!_){var p;s((p=h.__r3f)==null?void 0:p.objects,h,y),s(h.children,h,y)}delete h.__r3f,y&&h.dispose&&h.type!=="Scene"&&Dv.unstable_scheduleCallback(Dv.unstable_IdlePriority,()=>{try{h.dispose()}catch{}}),mo(u)}}function a(u,h,f,d){var m;const v=(m=u.__r3f)==null?void 0:m.parent;if(!v)return;const g=t(h,f,u.__r3f.root);if(u.children){for(const p of u.children)p.__r3f&&n(g,p);u.children=u.children.filter(p=>!p.__r3f)}u.__r3f.objects.forEach(p=>n(g,p)),u.__r3f.objects=[],u.__r3f.autoRemovedBeforeAppend||o(v,u),g.parent&&(g.__r3f.autoRemovedBeforeAppend=!0),n(v,g),g.raycast&&g.__r3f.eventCount&&g.__r3f.root.getState().internal.interaction.push(g),[d,d.alternate].forEach(p=>{p!==null&&(p.stateNode=g,p.ref&&(typeof p.ref=="function"?p.ref(g):p.ref.current=g))})}const c=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:Yw({createInstance:t,removeChild:o,appendChild:n,appendInitialChild:n,insertBefore:i,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(u,h)=>{if(!h)return;const f=u.getState().scene;f.__r3f&&(f.__r3f.root=u,n(f,h))},removeChildFromContainer:(u,h)=>{h&&o(u.getState().scene,h)},insertInContainerBefore:(u,h,f)=>{if(!h||!f)return;const d=u.getState().scene;d.__r3f&&i(d,h,f)},getRootHostContext:()=>null,getChildHostContext:u=>u,finalizeInitialChildren(u){var h;return!!((h=u==null?void 0:u.__r3f)!=null?h:{}).handlers},prepareUpdate(u,h,f,d){var m;if(((m=u==null?void 0:u.__r3f)!=null?m:{}).primitive&&d.object&&d.object!==u)return[!0];{const{args:g=[],children:p,..._}=d,{args:y=[],children:x,...b}=f;if(!Array.isArray(g))throw new Error("R3F: the args prop must be an array!");if(g.some((S,M)=>S!==y[M]))return[!0];const w=i1(u,_,b,!0);return w.changes.length?[!1,w]:null}},commitUpdate(u,[h,f],d,m,v,g){h?a(u,d,v,g):Nf(u,f)},commitMount(u,h,f,d){var m;const v=(m=u.__r3f)!=null?m:{};u.raycast&&v.handlers&&v.eventCount&&u.__r3f.root.getState().internal.interaction.push(u)},getPublicInstance:u=>u,prepareForCommit:()=>null,preparePortalMount:u=>po(u.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(u){var h;const{attach:f,parent:d}=(h=u.__r3f)!=null?h:{};f&&d&&Fv(d,u,f),u.isObject3D&&(u.visible=!1),mo(u)},unhideInstance(u,h){var f;const{attach:d,parent:m}=(f=u.__r3f)!=null?f:{};d&&m&&Of(m,u,d),(u.isObject3D&&h.visible==null||h.visible)&&(u.visible=!0),mo(u)},createTextInstance:c,hideTextInstance:c,unhideTextInstance:c,getCurrentEventPriority:()=>e?e():go.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&Rt.fun(performance.now)?performance.now:Rt.fun(Date.now)?Date.now:()=>0,scheduleTimeout:Rt.fun(setTimeout)?setTimeout:void 0,cancelTimeout:Rt.fun(clearTimeout)?clearTimeout:void 0}),applyProps:Nf}}var Iv,Uv;const Uf=r=>"colorSpace"in r||"outputColorSpace"in r,Kb=()=>{var r;return(r=Um.ColorManagement)!=null?r:null},Jb=r=>r&&r.isOrthographicCamera,ML=r=>r&&r.hasOwnProperty("current"),Nc=typeof window<"u"&&((Iv=window.document)!=null&&Iv.createElement||((Uv=window.navigator)==null?void 0:Uv.product)==="ReactNative")?q.useLayoutEffect:q.useEffect;function Qb(r){const e=q.useRef(r);return Nc(()=>void(e.current=r),[r]),e}function TL({set:r}){return Nc(()=>(r(new Promise(()=>null)),()=>r(!1)),[r]),null}class e1 extends q.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}e1.getDerivedStateFromError=()=>({error:!0});const t1="__default",Ov=new Map,AL=r=>r&&!!r.memoized&&!!r.changes;function n1(r){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(r)?Math.min(Math.max(r[0],t),r[1]):r}const ya=r=>{var e;return(e=r.__r3f)==null?void 0:e.root.getState()},Rt={obj:r=>r===Object(r)&&!Rt.arr(r)&&typeof r!="function",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",boo:r=>typeof r=="boolean",und:r=>r===void 0,arr:r=>Array.isArray(r),equ(r,e,{arrays:t="shallow",objects:n="reference",strict:i=!0}={}){if(typeof r!=typeof e||!!r!=!!e)return!1;if(Rt.str(r)||Rt.num(r))return r===e;const s=Rt.obj(r);if(s&&n==="reference")return r===e;const o=Rt.arr(r);if(o&&t==="reference")return r===e;if((o||s)&&r===e)return!0;let a;for(a in r)if(!(a in e))return!1;if(s&&t==="shallow"&&n==="shallow"){for(a in i?e:r)if(!Rt.equ(r[a],e[a],{strict:i,objects:"reference"}))return!1}else for(a in i?e:r)if(r[a]!==e[a])return!1;if(Rt.und(a)){if(o&&r.length===0&&e.length===0||s&&Object.keys(r).length===0&&Object.keys(e).length===0)return!0;if(r!==e)return!1}return!0}};function CL(r){r.dispose&&r.type!=="Scene"&&r.dispose();for(const e in r)e.dispose==null||e.dispose(),delete r[e]}function po(r,e){const t=r;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},r}function _p(r,e){let t=r;if(e.includes("-")){const n=e.split("-"),i=n.pop();return t=n.reduce((s,o)=>s[o],r),{target:t,key:i}}else return{target:t,key:e}}const Nv=/-\d+$/;function Of(r,e,t){if(Rt.str(t)){if(Nv.test(t)){const s=t.replace(Nv,""),{target:o,key:a}=_p(r,s);Array.isArray(o[a])||(o[a]=[])}const{target:n,key:i}=_p(r,t);e.__r3f.previousAttach=n[i],n[i]=e}else e.__r3f.previousAttach=t(r,e)}function Fv(r,e,t){var n,i;if(Rt.str(t)){const{target:s,key:o}=_p(r,t),a=e.__r3f.previousAttach;a===void 0?delete s[o]:s[o]=a}else(n=e.__r3f)==null||n.previousAttach==null||n.previousAttach(r,e);(i=e.__r3f)==null||delete i.previousAttach}function i1(r,{children:e,key:t,ref:n,...i},{children:s,key:o,ref:a,...c}={},l=!1){var u;const h=(u=r==null?void 0:r.__r3f)!=null?u:{},f=Object.entries(i),d=[];if(l){const v=Object.keys(c);for(let g=0;g<v.length;g++)i.hasOwnProperty(v[g])||f.unshift([v[g],t1+"remove"])}f.forEach(([v,g])=>{var p;if((p=r.__r3f)!=null&&p.primitive&&v==="object"||Rt.equ(g,c[v]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(v))return d.push([v,g,!0,[]]);let _=[];v.includes("-")&&(_=v.split("-")),d.push([v,g,!1,_]);for(const y in i){const x=i[y];y.startsWith(`${v}-`)&&d.push([y,x,!1,y.split("-")])}});const m={...i};return h.memoizedProps&&h.memoizedProps.args&&(m.args=h.memoizedProps.args),h.memoizedProps&&h.memoizedProps.attach&&(m.attach=h.memoizedProps.attach),{memoized:m,changes:d}}function Nf(r,e){var t,n,i;const s=(t=r.__r3f)!=null?t:{},o=s.root,a=(n=o==null||o.getState==null?void 0:o.getState())!=null?n:{},{memoized:c,changes:l}=AL(e)?e:i1(r,e),u=s.eventCount;r.__r3f&&(r.__r3f.memoizedProps=c);for(let f=0;f<l.length;f++){let[d,m,v,g]=l[f];if(Uf(r)){const x="srgb",b="srgb-linear";d==="encoding"?(d="colorSpace",m=m===3001?x:b):d==="outputEncoding"&&(d="outputColorSpace",m=m===3001?x:b)}let p=r,_=p[d];if(g.length&&(_=g.reduce((y,x)=>y[x],r),!(_&&_.set))){const[y,...x]=g.reverse();p=x.reverse().reduce((b,w)=>b[w],r),d=y}if(m===t1+"remove")if(p.constructor){let y=Ov.get(p.constructor);y||(y=new p.constructor,Ov.set(p.constructor,y)),m=y[d]}else m=0;if(v)m?s.handlers[d]=m:delete s.handlers[d],s.eventCount=Object.keys(s.handlers).length;else if(_&&_.set&&(_.copy||_ instanceof hs)){if(Array.isArray(m))_.fromArray?_.fromArray(m):_.set(...m);else if(_.copy&&m&&m.constructor&&_.constructor===m.constructor)_.copy(m);else if(m!==void 0){const y=_ instanceof Ne;!y&&_.setScalar?_.setScalar(m):_ instanceof hs&&m instanceof hs?_.mask=m.mask:_.set(m),!Kb()&&!a.linear&&y&&_.convertSRGBToLinear()}}else if(p[d]=m,p[d]instanceof Ft&&p[d].format===Ln&&p[d].type===Ii){const y=p[d];Uf(y)&&Uf(a.gl)?y.colorSpace=a.gl.outputColorSpace:y.encoding=a.gl.outputEncoding}mo(r)}if(s.parent&&a.internal&&r.raycast&&u!==s.eventCount){const f=a.internal.interaction.indexOf(r);f>-1&&a.internal.interaction.splice(f,1),s.eventCount&&a.internal.interaction.push(r)}return!(l.length===1&&l[0][0]==="onUpdate")&&l.length&&(i=r.__r3f)!=null&&i.parent&&yp(r),r}function mo(r){var e,t;const n=(e=r.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();n&&n.internal.frames===0&&n.invalidate()}function yp(r){r.onUpdate==null||r.onUpdate(r)}function RL(r,e){r.manual||(Jb(r)?(r.left=e.width/-2,r.right=e.width/2,r.top=e.height/2,r.bottom=e.height/-2):r.aspect=e.width/e.height,r.updateProjectionMatrix(),r.updateMatrixWorld())}function Wl(r){return(r.eventObject||r.object).uuid+"/"+r.index+r.instanceId}function PL(){var r;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return go.DefaultEventPriority;switch((r=e.event)==null?void 0:r.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return go.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return go.ContinuousEventPriority;default:return go.DefaultEventPriority}}function r1(r,e,t,n){const i=t.get(e);i&&(t.delete(e),t.size===0&&(r.delete(n),i.target.releasePointerCapture(n)))}function LL(r,e){const{internal:t}=r.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,i)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(i)}),t.capturedMap.forEach((n,i)=>{r1(t.capturedMap,e,n,i)})}function DL(r){function e(c){const{internal:l}=r.getState(),u=c.offsetX-l.initialClick[0],h=c.offsetY-l.initialClick[1];return Math.round(Math.sqrt(u*u+h*h))}function t(c){return c.filter(l=>["Move","Over","Enter","Out","Leave"].some(u=>{var h;return(h=l.__r3f)==null?void 0:h.handlers["onPointer"+u]}))}function n(c,l){const u=r.getState(),h=new Set,f=[],d=l?l(u.internal.interaction):u.internal.interaction;for(let p=0;p<d.length;p++){const _=ya(d[p]);_&&(_.raycaster.camera=void 0)}u.previousRoot||u.events.compute==null||u.events.compute(c,u);function m(p){const _=ya(p);if(!_||!_.events.enabled||_.raycaster.camera===null)return[];if(_.raycaster.camera===void 0){var y;_.events.compute==null||_.events.compute(c,_,(y=_.previousRoot)==null?void 0:y.getState()),_.raycaster.camera===void 0&&(_.raycaster.camera=null)}return _.raycaster.camera?_.raycaster.intersectObject(p,!0):[]}let v=d.flatMap(m).sort((p,_)=>{const y=ya(p.object),x=ya(_.object);return!y||!x?p.distance-_.distance:x.events.priority-y.events.priority||p.distance-_.distance}).filter(p=>{const _=Wl(p);return h.has(_)?!1:(h.add(_),!0)});u.events.filter&&(v=u.events.filter(v,u));for(const p of v){let _=p.object;for(;_;){var g;(g=_.__r3f)!=null&&g.eventCount&&f.push({...p,eventObject:_}),_=_.parent}}if("pointerId"in c&&u.internal.capturedMap.has(c.pointerId))for(let p of u.internal.capturedMap.get(c.pointerId).values())h.has(Wl(p.intersection))||f.push(p.intersection);return f}function i(c,l,u,h){const f=r.getState();if(c.length){const d={stopped:!1};for(const m of c){const v=ya(m.object)||f,{raycaster:g,pointer:p,camera:_,internal:y}=v,x=new G(p.x,p.y,0).unproject(_),b=T=>{var L,P;return(L=(P=y.capturedMap.get(T))==null?void 0:P.has(m.eventObject))!=null?L:!1},w=T=>{const L={intersection:m,target:l.target};y.capturedMap.has(T)?y.capturedMap.get(T).set(m.eventObject,L):y.capturedMap.set(T,new Map([[m.eventObject,L]])),l.target.setPointerCapture(T)},S=T=>{const L=y.capturedMap.get(T);L&&r1(y.capturedMap,m.eventObject,L,T)};let M={};for(let T in l){let L=l[T];typeof L!="function"&&(M[T]=L)}let E={...m,...M,pointer:p,intersections:c,stopped:d.stopped,delta:u,unprojectedPoint:x,ray:g.ray,camera:_,stopPropagation(){const T="pointerId"in l&&y.capturedMap.get(l.pointerId);if((!T||T.has(m.eventObject))&&(E.stopped=d.stopped=!0,y.hovered.size&&Array.from(y.hovered.values()).find(L=>L.eventObject===m.eventObject))){const L=c.slice(0,c.indexOf(m));s([...L,m])}},target:{hasPointerCapture:b,setPointerCapture:w,releasePointerCapture:S},currentTarget:{hasPointerCapture:b,setPointerCapture:w,releasePointerCapture:S},nativeEvent:l};if(h(E),d.stopped===!0)break}}return c}function s(c){const{internal:l}=r.getState();for(const u of l.hovered.values())if(!c.length||!c.find(h=>h.object===u.object&&h.index===u.index&&h.instanceId===u.instanceId)){const f=u.eventObject.__r3f,d=f==null?void 0:f.handlers;if(l.hovered.delete(Wl(u)),f!=null&&f.eventCount){const m={...u,intersections:c};d.onPointerOut==null||d.onPointerOut(m),d.onPointerLeave==null||d.onPointerLeave(m)}}}function o(c,l){for(let u=0;u<l.length;u++){const h=l[u].__r3f;h==null||h.handlers.onPointerMissed==null||h.handlers.onPointerMissed(c)}}function a(c){switch(c){case"onPointerLeave":case"onPointerCancel":return()=>s([]);case"onLostPointerCapture":return l=>{const{internal:u}=r.getState();"pointerId"in l&&u.capturedMap.has(l.pointerId)&&requestAnimationFrame(()=>{u.capturedMap.has(l.pointerId)&&(u.capturedMap.delete(l.pointerId),s([]))})}}return function(u){const{onPointerMissed:h,internal:f}=r.getState();f.lastEvent.current=u;const d=c==="onPointerMove",m=c==="onClick"||c==="onContextMenu"||c==="onDoubleClick",g=n(u,d?t:void 0),p=m?e(u):0;c==="onPointerDown"&&(f.initialClick=[u.offsetX,u.offsetY],f.initialHits=g.map(y=>y.eventObject)),m&&!g.length&&p<=2&&(o(u,f.interaction),h&&h(u)),d&&s(g);function _(y){const x=y.eventObject,b=x.__r3f,w=b==null?void 0:b.handlers;if(b!=null&&b.eventCount)if(d){if(w.onPointerOver||w.onPointerEnter||w.onPointerOut||w.onPointerLeave){const S=Wl(y),M=f.hovered.get(S);M?M.stopped&&y.stopPropagation():(f.hovered.set(S,y),w.onPointerOver==null||w.onPointerOver(y),w.onPointerEnter==null||w.onPointerEnter(y))}w.onPointerMove==null||w.onPointerMove(y)}else{const S=w[c];S?(!m||f.initialHits.includes(x))&&(o(u,f.interaction.filter(M=>!f.initialHits.includes(M))),S(y)):m&&f.initialHits.includes(x)&&o(u,f.interaction.filter(M=>!f.initialHits.includes(M)))}}i(g,u,p,_)}}return{handlePointer:a}}const s1=r=>!!(r!=null&&r.render),o1=q.createContext(null),IL=(r,e)=>{const t=bL((a,c)=>{const l=new G,u=new G,h=new G;function f(p=c().camera,_=u,y=c().size){const{width:x,height:b,top:w,left:S}=y,M=x/b;_ instanceof G?h.copy(_):h.set(..._);const E=p.getWorldPosition(l).distanceTo(h);if(Jb(p))return{width:x/p.zoom,height:b/p.zoom,top:w,left:S,factor:1,distance:E,aspect:M};{const T=p.fov*Math.PI/180,L=2*Math.tan(T/2)*E,P=L*(x/b);return{width:P,height:L,top:w,left:S,factor:x/P,distance:E,aspect:M}}}let d;const m=p=>a(_=>({performance:{..._.performance,current:p}})),v=new be;return{set:a,get:c,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(p=1)=>r(c(),p),advance:(p,_)=>e(p,_,c()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Rm,pointer:v,mouse:v,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const p=c();d&&clearTimeout(d),p.performance.current!==p.performance.min&&m(p.performance.min),d=setTimeout(()=>m(c().performance.max),p.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:f},setEvents:p=>a(_=>({..._,events:{..._.events,...p}})),setSize:(p,_,y,x,b)=>{const w=c().camera,S={width:p,height:_,top:x||0,left:b||0,updateStyle:y};a(M=>({size:S,viewport:{...M.viewport,...f(w,u,S)}}))},setDpr:p=>a(_=>{const y=n1(p);return{viewport:{..._.viewport,dpr:y,initialDpr:_.viewport.initialDpr||y}}}),setFrameloop:(p="always")=>{const _=c().clock;_.stop(),_.elapsedTime=0,p!=="never"&&(_.start(),_.elapsedTime=0),a(()=>({frameloop:p}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:q.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(p,_,y)=>{const x=c().internal;return x.priority=x.priority+(_>0?1:0),x.subscribers.push({ref:p,priority:_,store:y}),x.subscribers=x.subscribers.sort((b,w)=>b.priority-w.priority),()=>{const b=c().internal;b!=null&&b.subscribers&&(b.priority=b.priority-(_>0?1:0),b.subscribers=b.subscribers.filter(w=>w.ref!==p))}}}}}),n=t.getState();let i=n.size,s=n.viewport.dpr,o=n.camera;return t.subscribe(()=>{const{camera:a,size:c,viewport:l,gl:u,set:h}=t.getState();if(c!==i||l.dpr!==s){var f;i=c,s=l.dpr,RL(a,c),u.setPixelRatio(l.dpr);const d=(f=c.updateStyle)!=null?f:typeof HTMLCanvasElement<"u"&&u.domElement instanceof HTMLCanvasElement;u.setSize(c.width,c.height,d)}a!==o&&(o=a,h(d=>({viewport:{...d.viewport,...d.viewport.getCurrentViewport(a)}})))}),t.subscribe(a=>r(a)),t};function UL(r,e){const t={callback:r};return e.add(t),()=>void e.delete(t)}let Xl,a1=new Set,OL=new Set,NL=new Set;const FL=r=>UL(r,a1);function Ff(r,e){if(r.size)for(const{callback:t}of r.values())t(e)}function xa(r,e){switch(r){case"before":return Ff(a1,e);case"after":return Ff(OL,e);case"tail":return Ff(NL,e)}}let kf,zf;function Bf(r,e,t){let n=e.clock.getDelta();for(e.frameloop==="never"&&typeof r=="number"&&(n=r-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=r),kf=e.internal.subscribers,Xl=0;Xl<kf.length;Xl++)zf=kf[Xl],zf.ref.current(zf.store.getState(),n,t);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}function kL(r){let e=!1,t,n,i;function s(c){n=requestAnimationFrame(s),e=!0,t=0,xa("before",c);for(const u of r.values()){var l;i=u.store.getState(),i.internal.active&&(i.frameloop==="always"||i.internal.frames>0)&&!((l=i.gl.xr)!=null&&l.isPresenting)&&(t+=Bf(c,i))}if(xa("after",c),t===0)return xa("tail",c),e=!1,cancelAnimationFrame(n)}function o(c,l=1){var u;if(!c)return r.forEach(h=>o(h.store.getState()),l);(u=c.gl.xr)!=null&&u.isPresenting||!c.internal.active||c.frameloop==="never"||(c.internal.frames=Math.min(60,c.internal.frames+l),e||(e=!0,requestAnimationFrame(s)))}function a(c,l=!0,u,h){if(l&&xa("before",c),u)Bf(c,u,h);else for(const f of r.values())Bf(c,f.store.getState());l&&xa("after",c)}return{loop:s,invalidate:o,advance:a}}function c1(){const r=q.useContext(o1);if(!r)throw new Error("R3F: Hooks can only be used within the Canvas component!");return r}function Kt(r=t=>t,e){return c1()(r,e)}function uh(r,e=0){const t=c1(),n=t.getState().internal.subscribe,i=Qb(r);return Nc(()=>n(i,e,t),[e,n,t]),null}const Po=new Map,{invalidate:kv,advance:zv}=kL(Po),{reconciler:wu,applyProps:ts}=EL(Po,PL),ao={objects:"shallow",strict:!1},zL=(r,e)=>{const t=typeof r=="function"?r(e):r;return s1(t)?t:new lm({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...r})};function BL(r,e){if(e)return e;if(typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&r.parentElement){const{width:t,height:n,top:i,left:s}=r.parentElement.getBoundingClientRect();return{width:t,height:n,top:i,left:s}}else if(typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height,top:0,left:0};return{width:0,height:0,top:0,left:0}}function GL(r){const e=Po.get(r),t=e==null?void 0:e.fiber,n=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const i=typeof reportError=="function"?reportError:console.error,s=n||IL(kv,zv),o=t||wu.createContainer(s,go.ConcurrentRoot,null,!1,null,"",i,null);e||Po.set(r,{fiber:o,store:s});let a,c=!1,l;return{configure(u={}){let{gl:h,size:f,scene:d,events:m,onCreated:v,shadows:g=!1,linear:p=!1,flat:_=!1,legacy:y=!1,orthographic:x=!1,frameloop:b="always",dpr:w=[1,2],performance:S,raycaster:M,camera:E,onPointerMissed:T}=u,L=s.getState(),P=L.gl;L.gl||L.set({gl:P=zL(h,r)});let A=L.raycaster;A||L.set({raycaster:A=new Im});const{params:z,...V}=M||{};if(Rt.equ(V,A,ao)||ts(A,{...V}),Rt.equ(z,A.params,ao)||ts(A,{params:{...A.params,...z}}),!L.camera||L.camera===l&&!Rt.equ(l,E,ao)){l=E;const R=E instanceof Pc,F=R?E:x?new Ms(0,0,0,0,.1,1e3):new Zt(75,0,.1,1e3);R||(F.position.z=5,E&&ts(F,E),!L.camera&&!(E!=null&&E.rotation)&&F.lookAt(0,0,0)),L.set({camera:F})}if(!L.scene){let R;d instanceof ac?R=d:(R=new ac,d&&ts(R,d)),L.set({scene:po(R)})}if(!L.xr){const R=(Y,J)=>{const ie=s.getState();ie.frameloop!=="never"&&zv(Y,!0,ie,J)},F=()=>{const Y=s.getState();Y.gl.xr.enabled=Y.gl.xr.isPresenting,Y.gl.xr.setAnimationLoop(Y.gl.xr.isPresenting?R:null),Y.gl.xr.isPresenting||kv(Y)},H={connect(){const Y=s.getState().gl;Y.xr.addEventListener("sessionstart",F),Y.xr.addEventListener("sessionend",F)},disconnect(){const Y=s.getState().gl;Y.xr.removeEventListener("sessionstart",F),Y.xr.removeEventListener("sessionend",F)}};P.xr&&H.connect(),L.set({xr:H})}if(P.shadowMap){const R=P.shadowMap.enabled,F=P.shadowMap.type;if(P.shadowMap.enabled=!!g,Rt.boo(g))P.shadowMap.type=za;else if(Rt.str(g)){var N;const H={basic:$y,percentage:Uu,soft:za,variance:mi};P.shadowMap.type=(N=H[g])!=null?N:za}else Rt.obj(g)&&Object.assign(P.shadowMap,g);(R!==P.shadowMap.enabled||F!==P.shadowMap.type)&&(P.shadowMap.needsUpdate=!0)}const C=Kb();C&&("enabled"in C?C.enabled=!y:"legacyMode"in C&&(C.legacyMode=y)),ts(P,{outputEncoding:p?3e3:3001,toneMapping:_?yi:Wp}),L.legacy!==y&&L.set(()=>({legacy:y})),L.linear!==p&&L.set(()=>({linear:p})),L.flat!==_&&L.set(()=>({flat:_})),h&&!Rt.fun(h)&&!s1(h)&&!Rt.equ(h,P,ao)&&ts(P,h),m&&!L.events.handlers&&L.set({events:m(s)});const U=BL(r,f);return Rt.equ(U,L.size,ao)||L.setSize(U.width,U.height,U.updateStyle,U.top,U.left),w&&L.viewport.dpr!==n1(w)&&L.setDpr(w),L.frameloop!==b&&L.setFrameloop(b),L.onPointerMissed||L.set({onPointerMissed:T}),S&&!Rt.equ(S,L.performance,ao)&&L.set(R=>({performance:{...R.performance,...S}})),a=v,c=!0,this},render(u){return c||this.configure(),wu.updateContainer(q.createElement(VL,{store:s,children:u,onCreated:a,rootElement:r}),o,null,()=>{}),s},unmount(){l1(r)}}}function VL({store:r,children:e,onCreated:t,rootElement:n}){return Nc(()=>{const i=r.getState();i.set(s=>({internal:{...s.internal,active:!0}})),t&&t(i),r.getState().events.connected||i.events.connect==null||i.events.connect(n)},[]),q.createElement(o1.Provider,{value:r},e)}function l1(r,e){const t=Po.get(r),n=t==null?void 0:t.fiber;if(n){const i=t==null?void 0:t.store.getState();i&&(i.internal.active=!1),wu.updateContainer(null,n,null,()=>{i&&setTimeout(()=>{try{var s,o,a,c;i.events.disconnect==null||i.events.disconnect(),(s=i.gl)==null||(o=s.renderLists)==null||o.dispose==null||o.dispose(),(a=i.gl)==null||a.forceContextLoss==null||a.forceContextLoss(),(c=i.gl)!=null&&c.xr&&i.xr.disconnect(),CL(i),Po.delete(r)}catch{}},500)})}}wu.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:q.version});const Gf={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function HL(r){const{handlePointer:e}=DL(r);return{priority:1,enabled:!0,compute(t,n,i){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(Gf).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:i}=r.getState();(t=i.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{var n;const{set:i,events:s}=r.getState();s.disconnect==null||s.disconnect(),i(o=>({events:{...o.events,connected:t}})),Object.entries((n=s.handlers)!=null?n:[]).forEach(([o,a])=>{const[c,l]=Gf[o];t.addEventListener(c,a,{passive:l})})},disconnect:()=>{const{set:t,events:n}=r.getState();if(n.connected){var i;Object.entries((i=n.handlers)!=null?i:[]).forEach(([s,o])=>{if(n&&n.connected instanceof HTMLElement){const[a]=Gf[s];n.connected.removeEventListener(a,o)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}const WL=q.forwardRef(function({children:e,fallback:t,resize:n,style:i,gl:s,events:o=HL,eventSource:a,eventPrefix:c,shadows:l,linear:u,flat:h,legacy:f,orthographic:d,frameloop:m,dpr:v,performance:g,raycaster:p,camera:_,onPointerMissed:y,onCreated:x,...b},w){q.useMemo(()=>Zb($b),[]);const S=$w(),[M,E]=Zw({scroll:!0,debounce:{scroll:50,resize:0},...n}),T=q.useRef(null),L=q.useRef(null);q.useImperativeHandle(w,()=>T.current);const P=Qb(y),[A,z]=q.useState(!1),[V,N]=q.useState(!1);if(A)throw A;if(V)throw V;const C=q.useRef(null);Nc(()=>{const k=T.current;E.width>0&&E.height>0&&k&&(C.current||(C.current=GL(k)),C.current.configure({gl:s,events:o,shadows:l,linear:u,flat:h,legacy:f,orthographic:d,frameloop:m,dpr:v,performance:g,raycaster:p,camera:_,size:E,onPointerMissed:(...U)=>P.current==null?void 0:P.current(...U),onCreated:U=>{U.events.connect==null||U.events.connect(a?ML(a)?a.current:a:L.current),c&&U.setEvents({compute:(R,F)=>{const H=R[c+"X"],Y=R[c+"Y"];F.pointer.set(H/F.size.width*2-1,-(Y/F.size.height)*2+1),F.raycaster.setFromCamera(F.pointer,F.camera)}}),x==null||x(U)}}),C.current.render(q.createElement(S,null,q.createElement(e1,{set:N},q.createElement(q.Suspense,{fallback:q.createElement(TL,{set:z})},e)))))}),q.useEffect(()=>{const k=T.current;if(k)return()=>l1(k)},[]);const O=a?"none":"auto";return q.createElement("div",Tc({ref:L,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:O,...i}},b),q.createElement("div",{ref:M,style:{width:"100%",height:"100%"}},q.createElement("canvas",{ref:T,style:{display:"block"}},t)))}),XL=q.forwardRef(function(e,t){return q.createElement(jw,null,q.createElement(WL,Tc({},e,{ref:t})))});function qL(r,e,t){var n,i=1;r==null&&(r=0),e==null&&(e=0),t==null&&(t=0);function s(){var o,a=n.length,c,l=0,u=0,h=0;for(o=0;o<a;++o)c=n[o],l+=c.x||0,u+=c.y||0,h+=c.z||0;for(l=(l/a-r)*i,u=(u/a-e)*i,h=(h/a-t)*i,o=0;o<a;++o)c=n[o],l&&(c.x-=l),u&&(c.y-=u),h&&(c.z-=h)}return s.initialize=function(o){n=o},s.x=function(o){return arguments.length?(r=+o,s):r},s.y=function(o){return arguments.length?(e=+o,s):e},s.z=function(o){return arguments.length?(t=+o,s):t},s.strength=function(o){return arguments.length?(i=+o,s):i},s}function YL(r){const e=+this._x.call(null,r);return u1(this.cover(e),e,r)}function u1(r,e,t){if(isNaN(e))return r;var n,i=r._root,s={data:t},o=r._x0,a=r._x1,c,l,u,h,f;if(!i)return r._root=s,r;for(;i.length;)if((u=e>=(c=(o+a)/2))?o=c:a=c,n=i,!(i=i[h=+u]))return n[h]=s,r;if(l=+r._x.call(null,i.data),e===l)return s.next=i,n?n[h]=s:r._root=s,r;do n=n?n[h]=new Array(2):r._root=new Array(2),(u=e>=(c=(o+a)/2))?o=c:a=c;while((h=+u)==(f=+(l>=c)));return n[f]=i,n[h]=s,r}function jL(r){Array.isArray(r)||(r=Array.from(r));const e=r.length,t=new Float64Array(e);let n=1/0,i=-1/0;for(let s=0,o;s<e;++s)isNaN(o=+this._x.call(null,r[s]))||(t[s]=o,o<n&&(n=o),o>i&&(i=o));if(n>i)return this;this.cover(n).cover(i);for(let s=0;s<e;++s)u1(this,t[s],r[s]);return this}function $L(r){if(isNaN(r=+r))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(r))+1;else{for(var n=t-e||1,i=this._root,s,o;e>r||r>=t;)switch(o=+(r<e),s=new Array(2),s[o]=i,i=s,n*=2,o){case 0:t=e+n;break;case 1:e=t-n;break}this._root&&this._root.length&&(this._root=i)}return this._x0=e,this._x1=t,this}function ZL(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function KL(r){return arguments.length?this.cover(+r[0][0]).cover(+r[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function ir(r,e,t){this.node=r,this.x0=e,this.x1=t}function JL(r,e){var t,n=this._x0,i,s,o=this._x1,a=[],c=this._root,l,u;for(c&&a.push(new ir(c,n,o)),e==null?e=1/0:(n=r-e,o=r+e);l=a.pop();)if(!(!(c=l.node)||(i=l.x0)>o||(s=l.x1)<n))if(c.length){var h=(i+s)/2;a.push(new ir(c[1],h,s),new ir(c[0],i,h)),(u=+(r>=h))&&(l=a[a.length-1],a[a.length-1]=a[a.length-1-u],a[a.length-1-u]=l)}else{var f=Math.abs(r-+this._x.call(null,c.data));f<e&&(e=f,n=r-f,o=r+f,t=c.data)}return t}function QL(r){if(isNaN(c=+this._x.call(null,r)))return this;var e,t=this._root,n,i,s,o=this._x0,a=this._x1,c,l,u,h,f;if(!t)return this;if(t.length)for(;;){if((u=c>=(l=(o+a)/2))?o=l:a=l,e=t,!(t=t[h=+u]))return this;if(!t.length)break;e[h+1&1]&&(n=e,f=h)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[h]=s:delete e[h],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(n?n[f]=t:this._root=t),this):(this._root=s,this)}function eD(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function tD(){return this._root}function nD(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function iD(r){var e=[],t,n=this._root,i,s,o;for(n&&e.push(new ir(n,this._x0,this._x1));t=e.pop();)if(!r(n=t.node,s=t.x0,o=t.x1)&&n.length){var a=(s+o)/2;(i=n[1])&&e.push(new ir(i,a,o)),(i=n[0])&&e.push(new ir(i,s,a))}return this}function rD(r){var e=[],t=[],n;for(this._root&&e.push(new ir(this._root,this._x0,this._x1));n=e.pop();){var i=n.node;if(i.length){var s,o=n.x0,a=n.x1,c=(o+a)/2;(s=i[0])&&e.push(new ir(s,o,c)),(s=i[1])&&e.push(new ir(s,c,a))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.x1);return this}function sD(r){return r[0]}function oD(r){return arguments.length?(this._x=r,this):this._x}function Om(r,e){var t=new Nm(e??sD,NaN,NaN);return r==null?t:t.addAll(r)}function Nm(r,e,t){this._x=r,this._x0=e,this._x1=t,this._root=void 0}function Bv(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var In=Om.prototype=Nm.prototype;In.copy=function(){var r=new Nm(this._x,this._x0,this._x1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=Bv(e),r;for(t=[{source:e,target:r._root=new Array(2)}];e=t.pop();)for(var i=0;i<2;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(2)}):e.target[i]=Bv(n));return r};In.add=YL;In.addAll=jL;In.cover=$L;In.data=ZL;In.extent=KL;In.find=JL;In.remove=QL;In.removeAll=eD;In.root=tD;In.size=nD;In.visit=iD;In.visitAfter=rD;In.x=oD;function aD(r){const e=+this._x.call(null,r),t=+this._y.call(null,r);return h1(this.cover(e,t),e,t,r)}function h1(r,e,t,n){if(isNaN(e)||isNaN(t))return r;var i,s=r._root,o={data:n},a=r._x0,c=r._y0,l=r._x1,u=r._y1,h,f,d,m,v,g,p,_;if(!s)return r._root=o,r;for(;s.length;)if((v=e>=(h=(a+l)/2))?a=h:l=h,(g=t>=(f=(c+u)/2))?c=f:u=f,i=s,!(s=s[p=g<<1|v]))return i[p]=o,r;if(d=+r._x.call(null,s.data),m=+r._y.call(null,s.data),e===d&&t===m)return o.next=s,i?i[p]=o:r._root=o,r;do i=i?i[p]=new Array(4):r._root=new Array(4),(v=e>=(h=(a+l)/2))?a=h:l=h,(g=t>=(f=(c+u)/2))?c=f:u=f;while((p=g<<1|v)===(_=(m>=f)<<1|d>=h));return i[_]=s,i[p]=o,r}function cD(r){var e,t,n=r.length,i,s,o=new Array(n),a=new Array(n),c=1/0,l=1/0,u=-1/0,h=-1/0;for(t=0;t<n;++t)isNaN(i=+this._x.call(null,e=r[t]))||isNaN(s=+this._y.call(null,e))||(o[t]=i,a[t]=s,i<c&&(c=i),i>u&&(u=i),s<l&&(l=s),s>h&&(h=s));if(c>u||l>h)return this;for(this.cover(c,l).cover(u,h),t=0;t<n;++t)h1(this,o[t],a[t],r[t]);return this}function lD(r,e){if(isNaN(r=+r)||isNaN(e=+e))return this;var t=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(t))i=(t=Math.floor(r))+1,s=(n=Math.floor(e))+1;else{for(var o=i-t||1,a=this._root,c,l;t>r||r>=i||n>e||e>=s;)switch(l=(e<n)<<1|r<t,c=new Array(4),c[l]=a,a=c,o*=2,l){case 0:i=t+o,s=n+o;break;case 1:t=i-o,s=n+o;break;case 2:i=t+o,n=s-o;break;case 3:t=i-o,n=s-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=t,this._y0=n,this._x1=i,this._y1=s,this}function uD(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function hD(r){return arguments.length?this.cover(+r[0][0],+r[0][1]).cover(+r[1][0],+r[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function wn(r,e,t,n,i){this.node=r,this.x0=e,this.y0=t,this.x1=n,this.y1=i}function fD(r,e,t){var n,i=this._x0,s=this._y0,o,a,c,l,u=this._x1,h=this._y1,f=[],d=this._root,m,v;for(d&&f.push(new wn(d,i,s,u,h)),t==null?t=1/0:(i=r-t,s=e-t,u=r+t,h=e+t,t*=t);m=f.pop();)if(!(!(d=m.node)||(o=m.x0)>u||(a=m.y0)>h||(c=m.x1)<i||(l=m.y1)<s))if(d.length){var g=(o+c)/2,p=(a+l)/2;f.push(new wn(d[3],g,p,c,l),new wn(d[2],o,p,g,l),new wn(d[1],g,a,c,p),new wn(d[0],o,a,g,p)),(v=(e>=p)<<1|r>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-v],f[f.length-1-v]=m)}else{var _=r-+this._x.call(null,d.data),y=e-+this._y.call(null,d.data),x=_*_+y*y;if(x<t){var b=Math.sqrt(t=x);i=r-b,s=e-b,u=r+b,h=e+b,n=d.data}}return n}function dD(r){if(isNaN(u=+this._x.call(null,r))||isNaN(h=+this._y.call(null,r)))return this;var e,t=this._root,n,i,s,o=this._x0,a=this._y0,c=this._x1,l=this._y1,u,h,f,d,m,v,g,p;if(!t)return this;if(t.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(v=h>=(d=(a+l)/2))?a=d:l=d,e=t,!(t=t[g=v<<1|m]))return this;if(!t.length)break;(e[g+1&3]||e[g+2&3]||e[g+3&3])&&(n=e,p=g)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[g]=s:delete e[g],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[p]=t:this._root=t),this):(this._root=s,this)}function pD(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function mD(){return this._root}function gD(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function vD(r){var e=[],t,n=this._root,i,s,o,a,c;for(n&&e.push(new wn(n,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!r(n=t.node,s=t.x0,o=t.y0,a=t.x1,c=t.y1)&&n.length){var l=(s+a)/2,u=(o+c)/2;(i=n[3])&&e.push(new wn(i,l,u,a,c)),(i=n[2])&&e.push(new wn(i,s,u,l,c)),(i=n[1])&&e.push(new wn(i,l,o,a,u)),(i=n[0])&&e.push(new wn(i,s,o,l,u))}return this}function _D(r){var e=[],t=[],n;for(this._root&&e.push(new wn(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var i=n.node;if(i.length){var s,o=n.x0,a=n.y0,c=n.x1,l=n.y1,u=(o+c)/2,h=(a+l)/2;(s=i[0])&&e.push(new wn(s,o,a,u,h)),(s=i[1])&&e.push(new wn(s,u,a,c,h)),(s=i[2])&&e.push(new wn(s,o,h,u,l)),(s=i[3])&&e.push(new wn(s,u,h,c,l))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.y0,n.x1,n.y1);return this}function yD(r){return r[0]}function xD(r){return arguments.length?(this._x=r,this):this._x}function bD(r){return r[1]}function wD(r){return arguments.length?(this._y=r,this):this._y}function Fm(r,e,t){var n=new km(e??yD,t??bD,NaN,NaN,NaN,NaN);return r==null?n:n.addAll(r)}function km(r,e,t,n,i,s){this._x=r,this._y=e,this._x0=t,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function Gv(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var En=Fm.prototype=km.prototype;En.copy=function(){var r=new km(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=Gv(e),r;for(t=[{source:e,target:r._root=new Array(4)}];e=t.pop();)for(var i=0;i<4;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(4)}):e.target[i]=Gv(n));return r};En.add=aD;En.addAll=cD;En.cover=lD;En.data=uD;En.extent=hD;En.find=fD;En.remove=dD;En.removeAll=pD;En.root=mD;En.size=gD;En.visit=vD;En.visitAfter=_D;En.x=xD;En.y=wD;function SD(r){const e=+this._x.call(null,r),t=+this._y.call(null,r),n=+this._z.call(null,r);return f1(this.cover(e,t,n),e,t,n,r)}function f1(r,e,t,n,i){if(isNaN(e)||isNaN(t)||isNaN(n))return r;var s,o=r._root,a={data:i},c=r._x0,l=r._y0,u=r._z0,h=r._x1,f=r._y1,d=r._z1,m,v,g,p,_,y,x,b,w,S,M;if(!o)return r._root=a,r;for(;o.length;)if((x=e>=(m=(c+h)/2))?c=m:h=m,(b=t>=(v=(l+f)/2))?l=v:f=v,(w=n>=(g=(u+d)/2))?u=g:d=g,s=o,!(o=o[S=w<<2|b<<1|x]))return s[S]=a,r;if(p=+r._x.call(null,o.data),_=+r._y.call(null,o.data),y=+r._z.call(null,o.data),e===p&&t===_&&n===y)return a.next=o,s?s[S]=a:r._root=a,r;do s=s?s[S]=new Array(8):r._root=new Array(8),(x=e>=(m=(c+h)/2))?c=m:h=m,(b=t>=(v=(l+f)/2))?l=v:f=v,(w=n>=(g=(u+d)/2))?u=g:d=g;while((S=w<<2|b<<1|x)===(M=(y>=g)<<2|(_>=v)<<1|p>=m));return s[M]=o,s[S]=a,r}function ED(r){Array.isArray(r)||(r=Array.from(r));const e=r.length,t=new Float64Array(e),n=new Float64Array(e),i=new Float64Array(e);let s=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,u=-1/0;for(let h=0,f,d,m,v;h<e;++h)isNaN(d=+this._x.call(null,f=r[h]))||isNaN(m=+this._y.call(null,f))||isNaN(v=+this._z.call(null,f))||(t[h]=d,n[h]=m,i[h]=v,d<s&&(s=d),d>c&&(c=d),m<o&&(o=m),m>l&&(l=m),v<a&&(a=v),v>u&&(u=v));if(s>c||o>l||a>u)return this;this.cover(s,o,a).cover(c,l,u);for(let h=0;h<e;++h)f1(this,t[h],n[h],i[h],r[h]);return this}function MD(r,e,t){if(isNaN(r=+r)||isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,i=this._y0,s=this._z0,o=this._x1,a=this._y1,c=this._z1;if(isNaN(n))o=(n=Math.floor(r))+1,a=(i=Math.floor(e))+1,c=(s=Math.floor(t))+1;else{for(var l=o-n||1,u=this._root,h,f;n>r||r>=o||i>e||e>=a||s>t||t>=c;)switch(f=(t<s)<<2|(e<i)<<1|r<n,h=new Array(8),h[f]=u,u=h,l*=2,f){case 0:o=n+l,a=i+l,c=s+l;break;case 1:n=o-l,a=i+l,c=s+l;break;case 2:o=n+l,i=a-l,c=s+l;break;case 3:n=o-l,i=a-l,c=s+l;break;case 4:o=n+l,a=i+l,s=c-l;break;case 5:n=o-l,a=i+l,s=c-l;break;case 6:o=n+l,i=a-l,s=c-l;break;case 7:n=o-l,i=a-l,s=c-l;break}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=i,this._z0=s,this._x1=o,this._y1=a,this._z1=c,this}function TD(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function AD(r){return arguments.length?this.cover(+r[0][0],+r[0][1],+r[0][2]).cover(+r[1][0],+r[1][1],+r[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function Et(r,e,t,n,i,s,o){this.node=r,this.x0=e,this.y0=t,this.z0=n,this.x1=i,this.y1=s,this.z1=o}function CD(r,e,t,n){var i,s=this._x0,o=this._y0,a=this._z0,c,l,u,h,f,d,m=this._x1,v=this._y1,g=this._z1,p=[],_=this._root,y,x;for(_&&p.push(new Et(_,s,o,a,m,v,g)),n==null?n=1/0:(s=r-n,o=e-n,a=t-n,m=r+n,v=e+n,g=t+n,n*=n);y=p.pop();)if(!(!(_=y.node)||(c=y.x0)>m||(l=y.y0)>v||(u=y.z0)>g||(h=y.x1)<s||(f=y.y1)<o||(d=y.z1)<a))if(_.length){var b=(c+h)/2,w=(l+f)/2,S=(u+d)/2;p.push(new Et(_[7],b,w,S,h,f,d),new Et(_[6],c,w,S,b,f,d),new Et(_[5],b,l,S,h,w,d),new Et(_[4],c,l,S,b,w,d),new Et(_[3],b,w,u,h,f,S),new Et(_[2],c,w,u,b,f,S),new Et(_[1],b,l,u,h,w,S),new Et(_[0],c,l,u,b,w,S)),(x=(t>=S)<<2|(e>=w)<<1|r>=b)&&(y=p[p.length-1],p[p.length-1]=p[p.length-1-x],p[p.length-1-x]=y)}else{var M=r-+this._x.call(null,_.data),E=e-+this._y.call(null,_.data),T=t-+this._z.call(null,_.data),L=M*M+E*E+T*T;if(L<n){var P=Math.sqrt(n=L);s=r-P,o=e-P,a=t-P,m=r+P,v=e+P,g=t+P,i=_.data}}return i}const RD=(r,e,t,n,i,s)=>Math.sqrt((r-n)**2+(e-i)**2+(t-s)**2);function PD(r,e,t,n){const i=[],s=r-n,o=e-n,a=t-n,c=r+n,l=e+n,u=t+n;return this.visit((h,f,d,m,v,g,p)=>{if(!h.length)do{const _=h.data;RD(r,e,t,this._x(_),this._y(_),this._z(_))<=n&&i.push(_)}while(h=h.next);return f>c||d>l||m>u||v<s||g<o||p<a}),i}function LD(r){if(isNaN(f=+this._x.call(null,r))||isNaN(d=+this._y.call(null,r))||isNaN(m=+this._z.call(null,r)))return this;var e,t=this._root,n,i,s,o=this._x0,a=this._y0,c=this._z0,l=this._x1,u=this._y1,h=this._z1,f,d,m,v,g,p,_,y,x,b,w;if(!t)return this;if(t.length)for(;;){if((_=f>=(v=(o+l)/2))?o=v:l=v,(y=d>=(g=(a+u)/2))?a=g:u=g,(x=m>=(p=(c+h)/2))?c=p:h=p,e=t,!(t=t[b=x<<2|y<<1|_]))return this;if(!t.length)break;(e[b+1&7]||e[b+2&7]||e[b+3&7]||e[b+4&7]||e[b+5&7]||e[b+6&7]||e[b+7&7])&&(n=e,w=b)}for(;t.data!==r;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[b]=s:delete e[b],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[w]=t:this._root=t),this):(this._root=s,this)}function DD(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function ID(){return this._root}function UD(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function OD(r){var e=[],t,n=this._root,i,s,o,a,c,l,u;for(n&&e.push(new Et(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!r(n=t.node,s=t.x0,o=t.y0,a=t.z0,c=t.x1,l=t.y1,u=t.z1)&&n.length){var h=(s+c)/2,f=(o+l)/2,d=(a+u)/2;(i=n[7])&&e.push(new Et(i,h,f,d,c,l,u)),(i=n[6])&&e.push(new Et(i,s,f,d,h,l,u)),(i=n[5])&&e.push(new Et(i,h,o,d,c,f,u)),(i=n[4])&&e.push(new Et(i,s,o,d,h,f,u)),(i=n[3])&&e.push(new Et(i,h,f,a,c,l,d)),(i=n[2])&&e.push(new Et(i,s,f,a,h,l,d)),(i=n[1])&&e.push(new Et(i,h,o,a,c,f,d)),(i=n[0])&&e.push(new Et(i,s,o,a,h,f,d))}return this}function ND(r){var e=[],t=[],n;for(this._root&&e.push(new Et(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=e.pop();){var i=n.node;if(i.length){var s,o=n.x0,a=n.y0,c=n.z0,l=n.x1,u=n.y1,h=n.z1,f=(o+l)/2,d=(a+u)/2,m=(c+h)/2;(s=i[0])&&e.push(new Et(s,o,a,c,f,d,m)),(s=i[1])&&e.push(new Et(s,f,a,c,l,d,m)),(s=i[2])&&e.push(new Et(s,o,d,c,f,u,m)),(s=i[3])&&e.push(new Et(s,f,d,c,l,u,m)),(s=i[4])&&e.push(new Et(s,o,a,m,f,d,h)),(s=i[5])&&e.push(new Et(s,f,a,m,l,d,h)),(s=i[6])&&e.push(new Et(s,o,d,m,f,u,h)),(s=i[7])&&e.push(new Et(s,f,d,m,l,u,h))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function FD(r){return r[0]}function kD(r){return arguments.length?(this._x=r,this):this._x}function zD(r){return r[1]}function BD(r){return arguments.length?(this._y=r,this):this._y}function GD(r){return r[2]}function VD(r){return arguments.length?(this._z=r,this):this._z}function zm(r,e,t,n){var i=new Bm(e??FD,t??zD,n??GD,NaN,NaN,NaN,NaN,NaN,NaN);return r==null?i:i.addAll(r)}function Bm(r,e,t,n,i,s,o,a,c){this._x=r,this._y=e,this._z=t,this._x0=n,this._y0=i,this._z0=s,this._x1=o,this._y1=a,this._z1=c,this._root=void 0}function Vv(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var hn=zm.prototype=Bm.prototype;hn.copy=function(){var r=new Bm(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=Vv(e),r;for(t=[{source:e,target:r._root=new Array(8)}];e=t.pop();)for(var i=0;i<8;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(8)}):e.target[i]=Vv(n));return r};hn.add=SD;hn.addAll=ED;hn.cover=MD;hn.data=TD;hn.extent=AD;hn.find=CD;hn.findAllWithinRadius=PD;hn.remove=LD;hn.removeAll=DD;hn.root=ID;hn.size=UD;hn.visit=OD;hn.visitAfter=ND;hn.x=kD;hn.y=BD;hn.z=VD;function Nt(r){return function(){return r}}function ei(r){return(r()-.5)*1e-6}function Vf(r){return r.x+r.vx}function Hv(r){return r.y+r.vy}function HD(r){return r.z+r.vz}function d1(r){var e,t,n,i,s=1,o=1;typeof r!="function"&&(r=Nt(r==null?1:+r));function a(){for(var u,h=e.length,f,d,m,v,g,p,_,y=0;y<o;++y)for(f=(t===1?Om(e,Vf):t===2?Fm(e,Vf,Hv):t===3?zm(e,Vf,Hv,HD):null).visitAfter(c),u=0;u<h;++u)d=e[u],p=n[d.index],_=p*p,m=d.x+d.vx,t>1&&(v=d.y+d.vy),t>2&&(g=d.z+d.vz),f.visit(x);function x(b,w,S,M,E,T,L){var P=[w,S,M,E,T,L],A=P[0],z=P[1],V=P[2],N=P[t],C=P[t+1],O=P[t+2],k=b.data,U=b.r,R=p+U;if(k){if(k.index>d.index){var F=m-k.x-k.vx,H=t>1?v-k.y-k.vy:0,Y=t>2?g-k.z-k.vz:0,J=F*F+H*H+Y*Y;J<R*R&&(F===0&&(F=ei(i),J+=F*F),t>1&&H===0&&(H=ei(i),J+=H*H),t>2&&Y===0&&(Y=ei(i),J+=Y*Y),J=(R-(J=Math.sqrt(J)))/J*s,d.vx+=(F*=J)*(R=(U*=U)/(_+U)),t>1&&(d.vy+=(H*=J)*R),t>2&&(d.vz+=(Y*=J)*R),k.vx-=F*(R=1-R),t>1&&(k.vy-=H*R),t>2&&(k.vz-=Y*R))}return}return A>m+R||N<m-R||t>1&&(z>v+R||C<v-R)||t>2&&(V>g+R||O<g-R)}}function c(u){if(u.data)return u.r=n[u.data.index];for(var h=u.r=0;h<Math.pow(2,t);++h)u[h]&&u[h].r>u.r&&(u.r=u[h].r)}function l(){if(e){var u,h=e.length,f;for(n=new Array(h),u=0;u<h;++u)f=e[u],n[f.index]=+r(f,u,e)}}return a.initialize=function(u,...h){e=u,i=h.find(f=>typeof f=="function")||Math.random,t=h.find(f=>[1,2,3].includes(f))||2,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(s=+u,a):s},a.radius=function(u){return arguments.length?(r=typeof u=="function"?u:Nt(+u),l(),a):r},a}function WD(r){return r.index}function Wv(r,e){var t=r.get(e);if(!t)throw new Error("node not found: "+e);return t}function p1(r){var e=WD,t=f,n,i=Nt(30),s,o,a,c,l,u,h=1;r==null&&(r=[]);function f(p){return 1/Math.min(c[p.source.index],c[p.target.index])}function d(p){for(var _=0,y=r.length;_<h;++_)for(var x=0,b,w,S,M=0,E=0,T=0,L,P;x<y;++x)b=r[x],w=b.source,S=b.target,M=S.x+S.vx-w.x-w.vx||ei(u),a>1&&(E=S.y+S.vy-w.y-w.vy||ei(u)),a>2&&(T=S.z+S.vz-w.z-w.vz||ei(u)),L=Math.sqrt(M*M+E*E+T*T),L=(L-s[x])/L*p*n[x],M*=L,E*=L,T*=L,S.vx-=M*(P=l[x]),a>1&&(S.vy-=E*P),a>2&&(S.vz-=T*P),w.vx+=M*(P=1-P),a>1&&(w.vy+=E*P),a>2&&(w.vz+=T*P)}function m(){if(o){var p,_=o.length,y=r.length,x=new Map(o.map((w,S)=>[e(w,S,o),w])),b;for(p=0,c=new Array(_);p<y;++p)b=r[p],b.index=p,typeof b.source!="object"&&(b.source=Wv(x,b.source)),typeof b.target!="object"&&(b.target=Wv(x,b.target)),c[b.source.index]=(c[b.source.index]||0)+1,c[b.target.index]=(c[b.target.index]||0)+1;for(p=0,l=new Array(y);p<y;++p)b=r[p],l[p]=c[b.source.index]/(c[b.source.index]+c[b.target.index]);n=new Array(y),v(),s=new Array(y),g()}}function v(){if(o)for(var p=0,_=r.length;p<_;++p)n[p]=+t(r[p],p,r)}function g(){if(o)for(var p=0,_=r.length;p<_;++p)s[p]=+i(r[p],p,r)}return d.initialize=function(p,..._){o=p,u=_.find(y=>typeof y=="function")||Math.random,a=_.find(y=>[1,2,3].includes(y))||2,m()},d.links=function(p){return arguments.length?(r=p,m(),d):r},d.id=function(p){return arguments.length?(e=p,d):e},d.iterations=function(p){return arguments.length?(h=+p,d):h},d.strength=function(p){return arguments.length?(t=typeof p=="function"?p:Nt(+p),v(),d):t},d.distance=function(p){return arguments.length?(i=typeof p=="function"?p:Nt(+p),g(),d):i},d}var XD={value:()=>{}};function m1(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new hu(t)}function hu(r){this._=r}function qD(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");if(i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}hu.prototype=m1.prototype={constructor:hu,on:function(r,e){var t=this._,n=qD(r+"",t),i,s=-1,o=n.length;if(arguments.length<2){for(;++s<o;)if((i=(r=n[s]).type)&&(i=YD(t[i],r.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(i=(r=n[s]).type)t[i]=Xv(t[i],r.name,e);else if(e==null)for(i in t)t[i]=Xv(t[i],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new hu(r)},call:function(r,e){if((i=arguments.length-2)>0)for(var t=new Array(i),n=0,i,s;n<i;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(s=this._[r],n=0,i=s.length;n<i;++n)s[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],i=0,s=n.length;i<s;++i)n[i].value.apply(e,t)}};function YD(r,e){for(var t=0,n=r.length,i;t<n;++t)if((i=r[t]).name===e)return i.value}function Xv(r,e,t){for(var n=0,i=r.length;n<i;++n)if(r[n].name===e){r[n]=XD,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var Lo=0,Na=0,ba=0,g1=1e3,Su,Fa,Eu=0,bs=0,hh=0,gc=typeof performance=="object"&&performance.now?performance:Date,v1=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function _1(){return bs||(v1(jD),bs=gc.now()+hh)}function jD(){bs=0}function xp(){this._call=this._time=this._next=null}xp.prototype=y1.prototype={constructor:xp,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?_1():+t)+(e==null?0:+e),!this._next&&Fa!==this&&(Fa?Fa._next=this:Su=this,Fa=this),this._call=r,this._time=t,bp()},stop:function(){this._call&&(this._call=null,this._time=1/0,bp())}};function y1(r,e,t){var n=new xp;return n.restart(r,e,t),n}function $D(){_1(),++Lo;for(var r=Su,e;r;)(e=bs-r._time)>=0&&r._call.call(void 0,e),r=r._next;--Lo}function qv(){bs=(Eu=gc.now())+hh,Lo=Na=0;try{$D()}finally{Lo=0,KD(),bs=0}}function ZD(){var r=gc.now(),e=r-Eu;e>g1&&(hh-=e,Eu=r)}function KD(){for(var r,e=Su,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Su=t);Fa=r,bp(n)}function bp(r){if(!Lo){Na&&(Na=clearTimeout(Na));var e=r-bs;e>24?(r<1/0&&(Na=setTimeout(qv,r-gc.now()-hh)),ba&&(ba=clearInterval(ba))):(ba||(Eu=gc.now(),ba=setInterval(ZD,g1)),Lo=1,v1(qv))}}const JD=1664525,QD=1013904223,Yv=4294967296;function eI(){let r=1;return()=>(r=(JD*r+QD)%Yv)/Yv}var jv=3;function Hf(r){return r.x}function $v(r){return r.y}function tI(r){return r.z}var nI=10,iI=Math.PI*(3-Math.sqrt(5)),rI=Math.PI*20/(9+Math.sqrt(221));function x1(r,e){e=e||2;var t=Math.min(jv,Math.max(1,Math.round(e))),n,i=1,s=.001,o=1-Math.pow(s,1/300),a=0,c=.6,l=new Map,u=y1(d),h=m1("tick","end"),f=eI();r==null&&(r=[]);function d(){m(),h.call("tick",n),i<s&&(u.stop(),h.call("end",n))}function m(p){var _,y=r.length,x;p===void 0&&(p=1);for(var b=0;b<p;++b)for(i+=(a-i)*o,l.forEach(function(w){w(i)}),_=0;_<y;++_)x=r[_],x.fx==null?x.x+=x.vx*=c:(x.x=x.fx,x.vx=0),t>1&&(x.fy==null?x.y+=x.vy*=c:(x.y=x.fy,x.vy=0)),t>2&&(x.fz==null?x.z+=x.vz*=c:(x.z=x.fz,x.vz=0));return n}function v(){for(var p=0,_=r.length,y;p<_;++p){if(y=r[p],y.index=p,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),y.fz!=null&&(y.z=y.fz),isNaN(y.x)||t>1&&isNaN(y.y)||t>2&&isNaN(y.z)){var x=nI*(t>2?Math.cbrt(.5+p):t>1?Math.sqrt(.5+p):p),b=p*iI,w=p*rI;t===1?y.x=x:t===2?(y.x=x*Math.cos(b),y.y=x*Math.sin(b)):(y.x=x*Math.sin(b)*Math.cos(w),y.y=x*Math.cos(b),y.z=x*Math.sin(b)*Math.sin(w))}(isNaN(y.vx)||t>1&&isNaN(y.vy)||t>2&&isNaN(y.vz))&&(y.vx=0,t>1&&(y.vy=0),t>2&&(y.vz=0))}}function g(p){return p.initialize&&p.initialize(r,f,t),p}return v(),n={tick:m,restart:function(){return u.restart(d),n},stop:function(){return u.stop(),n},numDimensions:function(p){return arguments.length?(t=Math.min(jv,Math.max(1,Math.round(p))),l.forEach(g),n):t},nodes:function(p){return arguments.length?(r=p,v(),l.forEach(g),n):r},alpha:function(p){return arguments.length?(i=+p,n):i},alphaMin:function(p){return arguments.length?(s=+p,n):s},alphaDecay:function(p){return arguments.length?(o=+p,n):+o},alphaTarget:function(p){return arguments.length?(a=+p,n):a},velocityDecay:function(p){return arguments.length?(c=1-p,n):1-c},randomSource:function(p){return arguments.length?(f=p,l.forEach(g),n):f},force:function(p,_){return arguments.length>1?(_==null?l.delete(p):l.set(p,g(_)),n):l.get(p)},find:function(){var p=Array.prototype.slice.call(arguments),_=p.shift()||0,y=(t>1?p.shift():null)||0,x=(t>2?p.shift():null)||0,b=p.shift()||1/0,w=0,S=r.length,M,E,T,L,P,A;for(b*=b,w=0;w<S;++w)P=r[w],M=_-P.x,E=y-(P.y||0),T=x-(P.z||0),L=M*M+E*E+T*T,L<b&&(A=P,b=L);return A},on:function(p,_){return arguments.length>1?(h.on(p,_),n):h.on(p)}}}function b1(){var r,e,t,n,i,s=Nt(-30),o,a=1,c=1/0,l=.81;function u(m){var v,g=r.length,p=(e===1?Om(r,Hf):e===2?Fm(r,Hf,$v):e===3?zm(r,Hf,$v,tI):null).visitAfter(f);for(i=m,v=0;v<g;++v)t=r[v],p.visit(d)}function h(){if(r){var m,v=r.length,g;for(o=new Array(v),m=0;m<v;++m)g=r[m],o[g.index]=+s(g,m,r)}}function f(m){var v=0,g,p,_=0,y,x,b,w,S=m.length;if(S){for(y=x=b=w=0;w<S;++w)(g=m[w])&&(p=Math.abs(g.value))&&(v+=g.value,_+=p,y+=p*(g.x||0),x+=p*(g.y||0),b+=p*(g.z||0));v*=Math.sqrt(4/S),m.x=y/_,e>1&&(m.y=x/_),e>2&&(m.z=b/_)}else{g=m,g.x=g.data.x,e>1&&(g.y=g.data.y),e>2&&(g.z=g.data.z);do v+=o[g.data.index];while(g=g.next)}m.value=v}function d(m,v,g,p,_){if(!m.value)return!0;var y=[g,p,_][e-1],x=m.x-t.x,b=e>1?m.y-t.y:0,w=e>2?m.z-t.z:0,S=y-v,M=x*x+b*b+w*w;if(S*S/l<M)return M<c&&(x===0&&(x=ei(n),M+=x*x),e>1&&b===0&&(b=ei(n),M+=b*b),e>2&&w===0&&(w=ei(n),M+=w*w),M<a&&(M=Math.sqrt(a*M)),t.vx+=x*m.value*i/M,e>1&&(t.vy+=b*m.value*i/M),e>2&&(t.vz+=w*m.value*i/M)),!0;if(m.length||M>=c)return;(m.data!==t||m.next)&&(x===0&&(x=ei(n),M+=x*x),e>1&&b===0&&(b=ei(n),M+=b*b),e>2&&w===0&&(w=ei(n),M+=w*w),M<a&&(M=Math.sqrt(a*M)));do m.data!==t&&(S=o[m.data.index]*i/M,t.vx+=x*S,e>1&&(t.vy+=b*S),e>2&&(t.vz+=w*S));while(m=m.next)}return u.initialize=function(m,...v){r=m,n=v.find(g=>typeof g=="function")||Math.random,e=v.find(g=>[1,2,3].includes(g))||2,h()},u.strength=function(m){return arguments.length?(s=typeof m=="function"?m:Nt(+m),h(),u):s},u.distanceMin=function(m){return arguments.length?(a=m*m,u):Math.sqrt(a)},u.distanceMax=function(m){return arguments.length?(c=m*m,u):Math.sqrt(c)},u.theta=function(m){return arguments.length?(l=m*m,u):Math.sqrt(l)},u}function sI(r,e,t,n){var i,s,o=Nt(.1),a,c;typeof r!="function"&&(r=Nt(+r)),e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function l(h){for(var f=0,d=i.length;f<d;++f){var m=i[f],v=m.x-e||1e-6,g=(m.y||0)-t||1e-6,p=(m.z||0)-n||1e-6,_=Math.sqrt(v*v+g*g+p*p),y=(c[f]-_)*a[f]*h/_;m.vx+=v*y,s>1&&(m.vy+=g*y),s>2&&(m.vz+=p*y)}}function u(){if(i){var h,f=i.length;for(a=new Array(f),c=new Array(f),h=0;h<f;++h)c[h]=+r(i[h],h,i),a[h]=isNaN(c[h])?0:+o(i[h],h,i)}}return l.initialize=function(h,...f){i=h,s=f.find(d=>[1,2,3].includes(d))||2,u()},l.strength=function(h){return arguments.length?(o=typeof h=="function"?h:Nt(+h),u(),l):o},l.radius=function(h){return arguments.length?(r=typeof h=="function"?h:Nt(+h),u(),l):r},l.x=function(h){return arguments.length?(e=+h,l):e},l.y=function(h){return arguments.length?(t=+h,l):t},l.z=function(h){return arguments.length?(n=+h,l):n},l}function wp(r){var e=Nt(.1),t,n,i;typeof r!="function"&&(r=Nt(r==null?0:+r));function s(a){for(var c=0,l=t.length,u;c<l;++c)u=t[c],u.vx+=(i[c]-u.x)*n[c]*a}function o(){if(t){var a,c=t.length;for(n=new Array(c),i=new Array(c),a=0;a<c;++a)n[a]=isNaN(i[a]=+r(t[a],a,t))?0:+e(t[a],a,t)}}return s.initialize=function(a){t=a,o()},s.strength=function(a){return arguments.length?(e=typeof a=="function"?a:Nt(+a),o(),s):e},s.x=function(a){return arguments.length?(r=typeof a=="function"?a:Nt(+a),o(),s):r},s}function Sp(r){var e=Nt(.1),t,n,i;typeof r!="function"&&(r=Nt(r==null?0:+r));function s(a){for(var c=0,l=t.length,u;c<l;++c)u=t[c],u.vy+=(i[c]-u.y)*n[c]*a}function o(){if(t){var a,c=t.length;for(n=new Array(c),i=new Array(c),a=0;a<c;++a)n[a]=isNaN(i[a]=+r(t[a],a,t))?0:+e(t[a],a,t)}}return s.initialize=function(a){t=a,o()},s.strength=function(a){return arguments.length?(e=typeof a=="function"?a:Nt(+a),o(),s):e},s.y=function(a){return arguments.length?(r=typeof a=="function"?a:Nt(+a),o(),s):r},s}function oI(r){var e=Nt(.1),t,n,i;typeof r!="function"&&(r=Nt(r==null?0:+r));function s(a){for(var c=0,l=t.length,u;c<l;++c)u=t[c],u.vz+=(i[c]-u.z)*n[c]*a}function o(){if(t){var a,c=t.length;for(n=new Array(c),i=new Array(c),a=0;a<c;++a)n[a]=isNaN(i[a]=+r(t[a],a,t))?0:+e(t[a],a,t)}}return s.initialize=function(a){t=a,o()},s.strength=function(a){return arguments.length?(e=typeof a=="function"?a:Nt(+a),o(),s):e},s.z=function(a){return arguments.length?(r=typeof a=="function"?a:Nt(+a),o(),s):r},s}function aI(r){var e=0,t=r.children,n=t&&t.length;if(!n)e=1;else for(;--n>=0;)e+=t[n].value;r.value=e}function cI(){return this.eachAfter(aI)}function lI(r,e){let t=-1;for(const n of this)r.call(e,n,++t,this);return this}function uI(r,e){for(var t=this,n=[t],i,s,o=-1;t=n.pop();)if(r.call(e,t,++o,this),i=t.children)for(s=i.length-1;s>=0;--s)n.push(i[s]);return this}function hI(r,e){for(var t=this,n=[t],i=[],s,o,a,c=-1;t=n.pop();)if(i.push(t),s=t.children)for(o=0,a=s.length;o<a;++o)n.push(s[o]);for(;t=i.pop();)r.call(e,t,++c,this);return this}function fI(r,e){let t=-1;for(const n of this)if(r.call(e,n,++t,this))return n}function dI(r){return this.eachAfter(function(e){for(var t=+r(e.data)||0,n=e.children,i=n&&n.length;--i>=0;)t+=n[i].value;e.value=t})}function pI(r){return this.eachBefore(function(e){e.children&&e.children.sort(r)})}function mI(r){for(var e=this,t=gI(e,r),n=[e];e!==t;)e=e.parent,n.push(e);for(var i=n.length;r!==t;)n.splice(i,0,r),r=r.parent;return n}function gI(r,e){if(r===e)return r;var t=r.ancestors(),n=e.ancestors(),i=null;for(r=t.pop(),e=n.pop();r===e;)i=r,r=t.pop(),e=n.pop();return i}function vI(){for(var r=this,e=[r];r=r.parent;)e.push(r);return e}function _I(){return Array.from(this)}function yI(){var r=[];return this.eachBefore(function(e){e.children||r.push(e)}),r}function xI(){var r=this,e=[];return r.each(function(t){t!==r&&e.push({source:t.parent,target:t})}),e}function*bI(){var r=this,e,t=[r],n,i,s;do for(e=t.reverse(),t=[];r=e.pop();)if(yield r,n=r.children)for(i=0,s=n.length;i<s;++i)t.push(n[i]);while(t.length)}function fh(r,e){r instanceof Map?(r=[void 0,r],e===void 0&&(e=EI)):e===void 0&&(e=SI);for(var t=new Do(r),n,i=[t],s,o,a,c;n=i.pop();)if((o=e(n.data))&&(c=(o=Array.from(o)).length))for(n.children=o,a=c-1;a>=0;--a)i.push(s=o[a]=new Do(o[a])),s.parent=n,s.depth=n.depth+1;return t.eachBefore(w1)}function wI(){return fh(this).eachBefore(MI)}function SI(r){return r.children}function EI(r){return Array.isArray(r)?r[1]:null}function MI(r){r.data.value!==void 0&&(r.value=r.data.value),r.data=r.data.data}function w1(r){var e=0;do r.height=e;while((r=r.parent)&&r.height<++e)}function Do(r){this.data=r,this.depth=this.height=0,this.parent=null}Do.prototype=fh.prototype={constructor:Do,count:cI,each:lI,eachAfter:hI,eachBefore:uI,find:fI,sum:dI,sort:pI,path:mI,ancestors:vI,descendants:_I,leaves:yI,links:xI,copy:wI,[Symbol.iterator]:bI};function Wf(r){return r==null?null:S1(r)}function S1(r){if(typeof r!="function")throw new Error;return r}function wa(){return 0}function Sa(r){return function(){return r}}function TI(r){r.x0=Math.round(r.x0),r.y0=Math.round(r.y0),r.x1=Math.round(r.x1),r.y1=Math.round(r.y1)}function AI(r,e,t,n,i){for(var s=r.children,o,a=-1,c=s.length,l=r.value&&(n-e)/r.value;++a<c;)o=s[a],o.y0=t,o.y1=i,o.x0=e,o.x1=e+=o.value*l}var CI={depth:-1},Zv={},Xf={};function RI(r){return r.id}function PI(r){return r.parentId}function LI(){var r=RI,e=PI,t;function n(i){var s=Array.from(i),o=r,a=e,c,l,u,h,f,d,m,v,g=new Map;if(t!=null){const p=s.map((x,b)=>DI(t(x,b,i))),_=p.map(Kv),y=new Set(p).add("");for(const x of _)y.has(x)||(y.add(x),p.push(x),_.push(Kv(x)),s.push(Xf));o=(x,b)=>p[b],a=(x,b)=>_[b]}for(u=0,c=s.length;u<c;++u)l=s[u],d=s[u]=new Do(l),(m=o(l,u,i))!=null&&(m+="")&&(v=d.id=m,g.set(v,g.has(v)?Zv:d)),(m=a(l,u,i))!=null&&(m+="")&&(d.parent=m);for(u=0;u<c;++u)if(d=s[u],m=d.parent){if(f=g.get(m),!f)throw new Error("missing: "+m);if(f===Zv)throw new Error("ambiguous: "+m);f.children?f.children.push(d):f.children=[d],d.parent=f}else{if(h)throw new Error("multiple roots");h=d}if(!h)throw new Error("no root");if(t!=null){for(;h.data===Xf&&h.children.length===1;)h=h.children[0],--c;for(let p=s.length-1;p>=0&&(d=s[p],d.data===Xf);--p)d.data=null}if(h.parent=CI,h.eachBefore(function(p){p.depth=p.parent.depth+1,--c}).eachBefore(w1),h.parent=null,c>0)throw new Error("cycle");return h}return n.id=function(i){return arguments.length?(r=Wf(i),n):r},n.parentId=function(i){return arguments.length?(e=Wf(i),n):e},n.path=function(i){return arguments.length?(t=Wf(i),n):t},n}function DI(r){r=`${r}`;let e=r.length;return Ep(r,e-1)&&!Ep(r,e-2)&&(r=r.slice(0,-1)),r[0]==="/"?r:`/${r}`}function Kv(r){let e=r.length;if(e<2)return"";for(;--e>1&&!Ep(r,e););return r.slice(0,e)}function Ep(r,e){if(r[e]==="/"){let t=0;for(;e>0&&r[--e]==="\\";)++t;if((t&1)===0)return!0}return!1}function II(r,e){return r.parent===e.parent?1:2}function qf(r){var e=r.children;return e?e[0]:r.t}function Yf(r){var e=r.children;return e?e[e.length-1]:r.t}function UI(r,e,t){var n=t/(e.i-r.i);e.c-=n,e.s+=t,r.c+=n,e.z+=t,e.m+=t}function OI(r){for(var e=0,t=0,n=r.children,i=n.length,s;--i>=0;)s=n[i],s.z+=e,s.m+=e,e+=s.s+(t+=s.c)}function NI(r,e,t){return r.a.parent===e.parent?r.a:t}function fu(r,e){this._=r,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e}fu.prototype=Object.create(Do.prototype);function FI(r){for(var e=new fu(r,0),t,n=[e],i,s,o,a;t=n.pop();)if(s=t._.children)for(t.children=new Array(a=s.length),o=a-1;o>=0;--o)n.push(i=t.children[o]=new fu(s[o],o)),i.parent=t;return(e.parent=new fu(null,0)).children=[e],e}function kI(){var r=II,e=1,t=1,n=null;function i(l){var u=FI(l);if(u.eachAfter(s),u.parent.m=-u.z,u.eachBefore(o),n)l.eachBefore(c);else{var h=l,f=l,d=l;l.eachBefore(function(_){_.x<h.x&&(h=_),_.x>f.x&&(f=_),_.depth>d.depth&&(d=_)});var m=h===f?1:r(h,f)/2,v=m-h.x,g=e/(f.x+m+v),p=t/(d.depth||1);l.eachBefore(function(_){_.x=(_.x+v)*g,_.y=_.depth*p})}return l}function s(l){var u=l.children,h=l.parent.children,f=l.i?h[l.i-1]:null;if(u){OI(l);var d=(u[0].z+u[u.length-1].z)/2;f?(l.z=f.z+r(l._,f._),l.m=l.z-d):l.z=d}else f&&(l.z=f.z+r(l._,f._));l.parent.A=a(l,f,l.parent.A||h[0])}function o(l){l._.x=l.z+l.parent.m,l.m+=l.parent.m}function a(l,u,h){if(u){for(var f=l,d=l,m=u,v=f.parent.children[0],g=f.m,p=d.m,_=m.m,y=v.m,x;m=Yf(m),f=qf(f),m&&f;)v=qf(v),d=Yf(d),d.a=l,x=m.z+_-f.z-g+r(m._,f._),x>0&&(UI(NI(m,l,h),l,x),g+=x,p+=x),_+=m.m,g+=f.m,y+=v.m,p+=d.m;m&&!Yf(d)&&(d.t=m,d.m+=_-p),f&&!qf(v)&&(v.t=f,v.m+=g-y,h=l)}return h}function c(l){l.x*=e,l.y=l.depth*t}return i.separation=function(l){return arguments.length?(r=l,i):r},i.size=function(l){return arguments.length?(n=!1,e=+l[0],t=+l[1],i):n?null:[e,t]},i.nodeSize=function(l){return arguments.length?(n=!0,e=+l[0],t=+l[1],i):n?[e,t]:null},i}function zI(r,e,t,n,i){for(var s=r.children,o,a=-1,c=s.length,l=r.value&&(i-t)/r.value;++a<c;)o=s[a],o.x0=e,o.x1=n,o.y0=t,o.y1=t+=o.value*l}var BI=(1+Math.sqrt(5))/2;function GI(r,e,t,n,i,s){for(var o=[],a=e.children,c,l,u=0,h=0,f=a.length,d,m,v=e.value,g,p,_,y,x,b,w;u<f;){d=i-t,m=s-n;do g=a[h++].value;while(!g&&h<f);for(p=_=g,b=Math.max(m/d,d/m)/(v*r),w=g*g*b,x=Math.max(_/w,w/p);h<f;++h){if(g+=l=a[h].value,l<p&&(p=l),l>_&&(_=l),w=g*g*b,y=Math.max(_/w,w/p),y>x){g-=l;break}x=y}o.push(c={value:g,dice:d<m,children:a.slice(u,h)}),c.dice?AI(c,t,n,i,v?n+=m*g/v:s):zI(c,t,n,v?t+=d*g/v:i,s),v-=g,u=h}return o}const VI=(function r(e){function t(n,i,s,o,a){GI(e,n,i,s,o,a)}return t.ratio=function(n){return r((n=+n)>1?n:1)},t})(BI);function HI(){var r=VI,e=!1,t=1,n=1,i=[0],s=wa,o=wa,a=wa,c=wa,l=wa;function u(f){return f.x0=f.y0=0,f.x1=t,f.y1=n,f.eachBefore(h),i=[0],e&&f.eachBefore(TI),f}function h(f){var d=i[f.depth],m=f.x0+d,v=f.y0+d,g=f.x1-d,p=f.y1-d;g<m&&(m=g=(m+g)/2),p<v&&(v=p=(v+p)/2),f.x0=m,f.y0=v,f.x1=g,f.y1=p,f.children&&(d=i[f.depth+1]=s(f)/2,m+=l(f)-d,v+=o(f)-d,g-=a(f)-d,p-=c(f)-d,g<m&&(m=g=(m+g)/2),p<v&&(v=p=(v+p)/2),r(f,m,v,g,p))}return u.round=function(f){return arguments.length?(e=!!f,u):e},u.size=function(f){return arguments.length?(t=+f[0],n=+f[1],u):[t,n]},u.tile=function(f){return arguments.length?(r=S1(f),u):r},u.padding=function(f){return arguments.length?u.paddingInner(f).paddingOuter(f):u.paddingInner()},u.paddingInner=function(f){return arguments.length?(s=typeof f=="function"?f:Sa(+f),u):s},u.paddingOuter=function(f){return arguments.length?u.paddingTop(f).paddingRight(f).paddingBottom(f).paddingLeft(f):u.paddingTop()},u.paddingTop=function(f){return arguments.length?(o=typeof f=="function"?f:Sa(+f),u):o},u.paddingRight=function(f){return arguments.length?(a=typeof f=="function"?f:Sa(+f),u):a},u.paddingBottom=function(f){return arguments.length?(c=typeof f=="function"?f:Sa(+f),u):c},u.paddingLeft=function(f){return arguments.length?(l=typeof f=="function"?f:Sa(+f),u):l},u}var jf,Jv;function Gm(){if(Jv)return jf;Jv=1;function r(t){return!t||typeof t!="object"||typeof t=="function"||Array.isArray(t)||t instanceof Set||t instanceof Map||t instanceof RegExp||t instanceof Date}function e(t,n){t=t||{};var i={};for(var s in n){var o=t[s],a=n[s];if(!r(a)){i[s]=e(o,a);continue}o===void 0?i[s]=a:i[s]=o}return i}return jf=e,jf}var $f,Qv;function ur(){return Qv||(Qv=1,$f=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),$f}var Zf,e_;function WI(){if(e_)return Zf;e_=1;var r=Gm(),e=ur(),t={dimensions:["x","y"],center:.5,scale:1};function n(s,o,a){if(!e(o))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");a=r(a,t);var c=a.dimensions;if(!Array.isArray(c)||c.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");var l=a.center,u=a.scale,h=Math.PI*2,f=(l-.5)*u,d=o.order,m=c[0],v=c[1];function g(y,x){return x[m]=u*Math.cos(y*h/d)+f,x[v]=u*Math.sin(y*h/d)+f,x}var p=0;if(!s){var _={};return o.forEachNode(function(y){_[y]=g(p++,{})}),_}o.updateEachNodeAttributes(function(y,x){return g(p++,x),x},{attributes:c})}var i=n.bind(null,!1);return i.assign=n.bind(null,!0),Zf=i,Zf}var XI=WI();const qI=ki(XI);var Kf,t_;function YI(){if(t_)return Kf;t_=1;var r=0,e=1,t=2,n=3;function i(o,a){return o+"§"+a}function s(){return .01*(.5-Math.random())}return Kf=function(a,c){var l=a.margin,u=a.ratio,h=a.expansion,f=a.gridSize,d=a.speed,m,v,g,p,_,y,x=!0,b=c.length,w=b/n|0,S=new Float32Array(w),M=new Float32Array(w),E=1/0,T=1/0,L=-1/0,P=-1/0;for(m=0;m<b;m+=n)g=c[m+r],p=c[m+e],y=c[m+t]*u+l,E=Math.min(E,g-y),L=Math.max(L,g+y),T=Math.min(T,p-y),P=Math.max(P,p+y);var A=L-E,z=P-T,V=(E+L)/2,N=(T+P)/2;E=V-h*A/2,L=V+h*A/2,T=N-h*z/2,P=N+h*z/2;var C=new Array(f*f),O=C.length,k;for(k=0;k<O;k++)C[k]=[];var U,R,F,H,Y,J,ie,ne,ee,ge;for(m=0;m<b;m+=n)for(g=c[m+r],p=c[m+e],y=c[m+t]*u+l,U=g-y,R=g+y,F=p-y,H=p+y,Y=Math.floor(f*(U-E)/(L-E)),J=Math.floor(f*(R-E)/(L-E)),ie=Math.floor(f*(F-T)/(P-T)),ne=Math.floor(f*(H-T)/(P-T)),ee=Y;ee<=J;ee++)for(ge=ie;ge<=ne;ge++)C[ee*f+ge].push(m);var me,te=new Set,D,Q,j,K,W,ye,re,fe,xe,ce,Pe,B,I;for(k=0;k<O;k++)for(me=C[k],m=0,_=me.length;m<_;m++)for(D=me[m],j=c[D+r],W=c[D+e],re=c[D+t],v=m+1;v<_;v++)Q=me[v],xe=i(D,Q),!(O>1&&te.has(xe))&&(O>1&&te.add(xe),K=c[Q+r],ye=c[Q+e],fe=c[Q+t],ce=K-j,Pe=ye-W,B=Math.sqrt(ce*ce+Pe*Pe),I=B<re*u+l+(fe*u+l),I&&(x=!1,Q=Q/n|0,B>0?(S[Q]+=ce/B*(1+re),M[Q]+=Pe/B*(1+re)):(S[Q]+=A*s(),M[Q]+=z*s())));for(m=0,v=0;m<b;m+=n,v++)c[m+r]+=S[v]*.1*d,c[m+e]+=M[v]*.1*d;return{converged:x}},Kf}var Kr={},n_;function jI(){if(n_)return Kr;n_=1;var r=3;return Kr.validateSettings=function(e){return"gridSize"in e&&typeof e.gridSize!="number"||e.gridSize<=0?{message:"the `gridSize` setting should be a positive number."}:"margin"in e&&typeof e.margin!="number"||e.margin<0?{message:"the `margin` setting should be 0 or a positive number."}:"expansion"in e&&typeof e.expansion!="number"||e.expansion<=0?{message:"the `expansion` setting should be a positive number."}:"ratio"in e&&typeof e.ratio!="number"||e.ratio<=0?{message:"the `ratio` setting should be a positive number."}:"speed"in e&&typeof e.speed!="number"||e.speed<=0?{message:"the `speed` setting should be a positive number."}:null},Kr.graphToByteArray=function(e,t){var n=e.order,i=new Float32Array(n*r),s=0;return e.forEachNode(function(o,a){typeof t=="function"&&(a=t(o,a)),i[s]=a.x,i[s+1]=a.y,i[s+2]=a.size||1,s+=r}),i},Kr.assignLayoutChanges=function(e,t,n){var i=0;e.forEachNode(function(s){var o={x:t[i],y:t[i+1]};typeof n=="function"&&(o=n(s,o)),e.mergeNodeAttributes(s,o),i+=r})},Kr.collectLayoutChanges=function(e,t,n){var i={},s=0;return e.forEachNode(function(o){var a={x:t[s],y:t[s+1]};typeof n=="function"&&(a=n(o,a)),i[o]=a,s+=r}),i},Kr.createWorker=function(t){var n=window.URL||window.webkitURL,i=t.toString(),s=n.createObjectURL(new Blob(["("+i+").call(this);"],{type:"text/javascript"})),o=new Worker(s);return n.revokeObjectURL(s),o},Kr}var Jf,i_;function $I(){return i_||(i_=1,Jf={gridSize:20,margin:5,expansion:1.1,ratio:1,speed:3}),Jf}var Qf,r_;function ZI(){if(r_)return Qf;r_=1;var r=ur(),e=YI(),t=jI(),n=$I(),i=500;function s(a,c,l){if(!r(c))throw new Error("graphology-layout-noverlap: the given graph is not a valid graphology instance.");typeof l=="number"?l={maxIterations:l}:l=l||{};var u=l.maxIterations||i;if(typeof u!="number"||u<=0)throw new Error("graphology-layout-force: you should provide a positive number of maximum iterations.");var h=Object.assign({},n,l.settings),f=t.validateSettings(h);if(f)throw new Error("graphology-layout-noverlap: "+f.message);var d=t.graphToByteArray(c,l.inputReducer),m=!1,v;for(v=0;v<u&&!m;v++)m=e(h,d).converged;if(a){t.assignLayoutChanges(c,d,l.outputReducer);return}return t.collectLayoutChanges(c,d,l.outputReducer)}var o=s.bind(null,!1);return o.assign=s.bind(null,!0),Qf=o,Qf}var KI=ZI();const JI=ki(KI);var Ea={},s_;function dh(){if(s_)return Ea;s_=1;function r(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var s={},o=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(o=i);var a=function(l){return o(l[n])},c=function(){return o(void 0)};return typeof n=="string"?(s.fromAttributes=a,s.fromGraph=function(l,u){return a(l.getNodeAttributes(u))},s.fromEntry=function(l,u){return a(u)}):typeof n=="function"?(s.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},s.fromGraph=function(l,u){return o(n(u,l.getNodeAttributes(u)))},s.fromEntry=function(l,u){return o(n(l,u))}):(s.fromAttributes=c,s.fromGraph=c,s.fromEntry=c),s}function t(n,i){var s={},o=function(l){return typeof l>"u"?i:l};typeof i=="function"&&(o=i);var a=function(l){return o(l[n])},c=function(){return o(void 0)};return typeof n=="string"?(s.fromAttributes=a,s.fromGraph=function(l,u){return a(l.getEdgeAttributes(u))},s.fromEntry=function(l,u){return a(u)},s.fromPartialEntry=s.fromEntry,s.fromMinimalEntry=s.fromEntry):typeof n=="function"?(s.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},s.fromGraph=function(l,u){var h=l.extremities(u);return o(n(u,l.getEdgeAttributes(u),h[0],h[1],l.getNodeAttributes(h[0]),l.getNodeAttributes(h[1]),l.isUndirected(u)))},s.fromEntry=function(l,u,h,f,d,m,v){return o(n(l,u,h,f,d,m,v))},s.fromPartialEntry=function(l,u,h,f){return o(n(l,u,h,f))},s.fromMinimalEntry=function(l,u){return o(n(l,u))}):(s.fromAttributes=c,s.fromGraph=c,s.fromEntry=c,s.fromMinimalEntry=c),s}return Ea.createNodeValueGetter=e,Ea.createEdgeValueGetter=t,Ea.createEdgeWeightGetter=function(n){return t(n,r)},Ea}var ed,o_;function QI(){if(o_)return ed;o_=1;var r=0,e=1,t=2,n=3,i=4,s=5,o=6,a=7,c=8,l=9,u=0,h=1,f=2,d=0,m=1,v=2,g=3,p=4,_=5,y=6,x=7,b=8,w=3,S=10,M=3,E=9,T=10;return ed=function(P,A,z){var V,N,C,O,k,U,R,F,H,Y,J=A.length,ie=z.length,ne=P.adjustSizes,ee=P.barnesHutTheta*P.barnesHutTheta,ge,me,te,D,Q,j,K,W=[];for(C=0;C<J;C+=S)A[C+i]=A[C+t],A[C+s]=A[C+n],A[C+t]=0,A[C+n]=0;if(P.outboundAttractionDistribution){for(ge=0,C=0;C<J;C+=S)ge+=A[C+o];ge/=J/S}if(P.barnesHutOptimize){var ye=1/0,re=-1/0,fe=1/0,xe=-1/0,ce,Pe,B;for(C=0;C<J;C+=S)ye=Math.min(ye,A[C+r]),re=Math.max(re,A[C+r]),fe=Math.min(fe,A[C+e]),xe=Math.max(xe,A[C+e]);var I=re-ye,$=xe-fe;for(I>$?(fe-=(I-$)/2,xe=fe+I):(ye-=($-I)/2,re=ye+$),W[0+d]=-1,W[0+m]=(ye+re)/2,W[0+v]=(fe+xe)/2,W[0+g]=Math.max(re-ye,xe-fe),W[0+p]=-1,W[0+_]=-1,W[0+y]=0,W[0+x]=0,W[0+b]=0,V=1,C=0;C<J;C+=S)for(N=0,B=w;;)if(W[N+_]>=0){A[C+r]<W[N+m]?A[C+e]<W[N+v]?ce=W[N+_]:ce=W[N+_]+E:A[C+e]<W[N+v]?ce=W[N+_]+E*2:ce=W[N+_]+E*3,W[N+x]=(W[N+x]*W[N+y]+A[C+r]*A[C+o])/(W[N+y]+A[C+o]),W[N+b]=(W[N+b]*W[N+y]+A[C+e]*A[C+o])/(W[N+y]+A[C+o]),W[N+y]+=A[C+o],N=ce;continue}else if(W[N+d]<0){W[N+d]=C;break}else{if(W[N+_]=V*E,F=W[N+g]/2,H=W[N+_],W[H+d]=-1,W[H+m]=W[N+m]-F,W[H+v]=W[N+v]-F,W[H+g]=F,W[H+p]=H+E,W[H+_]=-1,W[H+y]=0,W[H+x]=0,W[H+b]=0,H+=E,W[H+d]=-1,W[H+m]=W[N+m]-F,W[H+v]=W[N+v]+F,W[H+g]=F,W[H+p]=H+E,W[H+_]=-1,W[H+y]=0,W[H+x]=0,W[H+b]=0,H+=E,W[H+d]=-1,W[H+m]=W[N+m]+F,W[H+v]=W[N+v]-F,W[H+g]=F,W[H+p]=H+E,W[H+_]=-1,W[H+y]=0,W[H+x]=0,W[H+b]=0,H+=E,W[H+d]=-1,W[H+m]=W[N+m]+F,W[H+v]=W[N+v]+F,W[H+g]=F,W[H+p]=W[N+p],W[H+_]=-1,W[H+y]=0,W[H+x]=0,W[H+b]=0,V+=4,A[W[N+d]+r]<W[N+m]?A[W[N+d]+e]<W[N+v]?ce=W[N+_]:ce=W[N+_]+E:A[W[N+d]+e]<W[N+v]?ce=W[N+_]+E*2:ce=W[N+_]+E*3,W[N+y]=A[W[N+d]+o],W[N+x]=A[W[N+d]+r],W[N+b]=A[W[N+d]+e],W[ce+d]=W[N+d],W[N+d]=-1,A[C+r]<W[N+m]?A[C+e]<W[N+v]?Pe=W[N+_]:Pe=W[N+_]+E:A[C+e]<W[N+v]?Pe=W[N+_]+E*2:Pe=W[N+_]+E*3,ce===Pe)if(B--){N=ce;continue}else{B=w;break}W[Pe+d]=C;break}}if(P.barnesHutOptimize)for(me=P.scalingRatio,C=0;C<J;C+=S)for(N=0;;)if(W[N+_]>=0)if(j=Math.pow(A[C+r]-W[N+x],2)+Math.pow(A[C+e]-W[N+b],2),Y=W[N+g],4*Y*Y/j<ee){if(te=A[C+r]-W[N+x],D=A[C+e]-W[N+b],ne===!0?j>0?(K=me*A[C+o]*W[N+y]/j,A[C+t]+=te*K,A[C+n]+=D*K):j<0&&(K=-me*A[C+o]*W[N+y]/Math.sqrt(j),A[C+t]+=te*K,A[C+n]+=D*K):j>0&&(K=me*A[C+o]*W[N+y]/j,A[C+t]+=te*K,A[C+n]+=D*K),N=W[N+p],N<0)break;continue}else{N=W[N+_];continue}else{if(U=W[N+d],U>=0&&U!==C&&(te=A[C+r]-A[U+r],D=A[C+e]-A[U+e],j=te*te+D*D,ne===!0?j>0?(K=me*A[C+o]*A[U+o]/j,A[C+t]+=te*K,A[C+n]+=D*K):j<0&&(K=-me*A[C+o]*A[U+o]/Math.sqrt(j),A[C+t]+=te*K,A[C+n]+=D*K):j>0&&(K=me*A[C+o]*A[U+o]/j,A[C+t]+=te*K,A[C+n]+=D*K)),N=W[N+p],N<0)break;continue}else for(me=P.scalingRatio,O=0;O<J;O+=S)for(k=0;k<O;k+=S)te=A[O+r]-A[k+r],D=A[O+e]-A[k+e],ne===!0?(j=Math.sqrt(te*te+D*D)-A[O+c]-A[k+c],j>0?(K=me*A[O+o]*A[k+o]/j/j,A[O+t]+=te*K,A[O+n]+=D*K,A[k+t]-=te*K,A[k+n]-=D*K):j<0&&(K=100*me*A[O+o]*A[k+o],A[O+t]+=te*K,A[O+n]+=D*K,A[k+t]-=te*K,A[k+n]-=D*K)):(j=Math.sqrt(te*te+D*D),j>0&&(K=me*A[O+o]*A[k+o]/j/j,A[O+t]+=te*K,A[O+n]+=D*K,A[k+t]-=te*K,A[k+n]-=D*K));for(H=P.gravity/P.scalingRatio,me=P.scalingRatio,C=0;C<J;C+=S)K=0,te=A[C+r],D=A[C+e],j=Math.sqrt(Math.pow(te,2)+Math.pow(D,2)),P.strongGravityMode?j>0&&(K=me*A[C+o]*H):j>0&&(K=me*A[C+o]*H/j),A[C+t]-=te*K,A[C+n]-=D*K;for(me=1*(P.outboundAttractionDistribution?ge:1),R=0;R<ie;R+=M)O=z[R+u],k=z[R+h],F=z[R+f],Q=Math.pow(F,P.edgeWeightInfluence),te=A[O+r]-A[k+r],D=A[O+e]-A[k+e],ne===!0?(j=Math.sqrt(te*te+D*D)-A[O+c]-A[k+c],P.linLogMode?P.outboundAttractionDistribution?j>0&&(K=-me*Q*Math.log(1+j)/j/A[O+o]):j>0&&(K=-me*Q*Math.log(1+j)/j):P.outboundAttractionDistribution?j>0&&(K=-me*Q/A[O+o]):j>0&&(K=-me*Q)):(j=Math.sqrt(Math.pow(te,2)+Math.pow(D,2)),P.linLogMode?P.outboundAttractionDistribution?j>0&&(K=-me*Q*Math.log(1+j)/j/A[O+o]):j>0&&(K=-me*Q*Math.log(1+j)/j):P.outboundAttractionDistribution?(j=1,K=-me*Q/A[O+o]):(j=1,K=-me*Q)),j>0&&(A[O+t]+=te*K,A[O+n]+=D*K,A[k+t]-=te*K,A[k+n]-=D*K);var he,de,pe,Me,we,ue;if(ne===!0)for(C=0;C<J;C+=S)A[C+l]!==1&&(he=Math.sqrt(Math.pow(A[C+t],2)+Math.pow(A[C+n],2)),he>T&&(A[C+t]=A[C+t]*T/he,A[C+n]=A[C+n]*T/he),de=A[C+o]*Math.sqrt((A[C+i]-A[C+t])*(A[C+i]-A[C+t])+(A[C+s]-A[C+n])*(A[C+s]-A[C+n])),pe=Math.sqrt((A[C+i]+A[C+t])*(A[C+i]+A[C+t])+(A[C+s]+A[C+n])*(A[C+s]+A[C+n]))/2,Me=.1*Math.log(1+pe)/(1+Math.sqrt(de)),we=A[C+r]+A[C+t]*(Me/P.slowDown),A[C+r]=we,ue=A[C+e]+A[C+n]*(Me/P.slowDown),A[C+e]=ue);else for(C=0;C<J;C+=S)A[C+l]!==1&&(de=A[C+o]*Math.sqrt((A[C+i]-A[C+t])*(A[C+i]-A[C+t])+(A[C+s]-A[C+n])*(A[C+s]-A[C+n])),pe=Math.sqrt((A[C+i]+A[C+t])*(A[C+i]+A[C+t])+(A[C+s]+A[C+n])*(A[C+s]+A[C+n]))/2,Me=A[C+a]*Math.log(1+pe)/(1+Math.sqrt(de)),A[C+a]=Math.min(1,Math.sqrt(Me*(Math.pow(A[C+t],2)+Math.pow(A[C+n],2))/(1+Math.sqrt(de)))),we=A[C+r]+A[C+t]*(Me/P.slowDown),A[C+r]=we,ue=A[C+e]+A[C+n]*(Me/P.slowDown),A[C+e]=ue);return{}},ed}var Ki={},a_;function eU(){if(a_)return Ki;a_=1;var r=10,e=3;return Ki.assign=function(t){t=t||{};var n=Array.prototype.slice.call(arguments).slice(1),i,s,o;for(i=0,o=n.length;i<o;i++)if(n[i])for(s in n[i])t[s]=n[i][s];return t},Ki.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Ki.graphToByteArrays=function(t,n){var i=t.order,s=t.size,o={},a,c=new Float32Array(i*r),l=new Float32Array(s*e);return a=0,t.forEachNode(function(u,h){o[u]=a,c[a]=h.x,c[a+1]=h.y,c[a+2]=0,c[a+3]=0,c[a+4]=0,c[a+5]=0,c[a+6]=1,c[a+7]=1,c[a+8]=h.size||1,c[a+9]=h.fixed?1:0,a+=r}),a=0,t.forEachEdge(function(u,h,f,d,m,v,g){var p=o[f],_=o[d],y=n(u,h,f,d,m,v,g);c[p+6]+=y,c[_+6]+=y,l[a]=p,l[a+1]=_,l[a+2]=y,a+=e}),{nodes:c,edges:l}},Ki.assignLayoutChanges=function(t,n,i){var s=0;t.updateEachNodeAttributes(function(o,a){return a.x=n[s],a.y=n[s+1],s+=r,i?i(o,a):a})},Ki.readGraphPositions=function(t,n){var i=0;t.forEachNode(function(s,o){n[i]=o.x,n[i+1]=o.y,i+=r})},Ki.collectLayoutChanges=function(t,n,i){for(var s=t.nodes(),o={},a=0,c=0,l=n.length;a<l;a+=r){if(i){var u=Object.assign({},t.getNodeAttributes(s[c]));u.x=n[a],u.y=n[a+1],u=i(s[c],u),o[s[c]]={x:u.x,y:u.y}}else o[s[c]]={x:n[a],y:n[a+1]};c++}return o},Ki.createWorker=function(n){var i=window.URL||window.webkitURL,s=n.toString(),o=i.createObjectURL(new Blob(["("+s+").call(this);"],{type:"text/javascript"})),a=new Worker(o);return i.revokeObjectURL(o),a},Ki}var td,c_;function tU(){return c_||(c_=1,td={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),td}var nd,l_;function nU(){if(l_)return nd;l_=1;var r=ur(),e=dh().createEdgeWeightGetter,t=QI(),n=eU(),i=tU();function s(c,l,u){if(!r(l))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof u=="number"&&(u={iterations:u});var h=u.iterations;if(typeof h!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(h<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var f=e("getEdgeWeight"in u?u.getEdgeWeight:"weight").fromEntry,d=typeof u.outputReducer=="function"?u.outputReducer:null,m=n.assign({},i,u.settings),v=n.validateSettings(m);if(v)throw new Error("graphology-layout-forceatlas2: "+v.message);var g=n.graphToByteArrays(l,f),p;for(p=0;p<h;p++)t(m,g.nodes,g.edges);if(c){n.assignLayoutChanges(l,g.nodes,d);return}return n.collectLayoutChanges(l,g.nodes)}function o(c){var l=typeof c=="number"?c:c.order;return{barnesHutOptimize:l>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(l)}}var a=s.bind(null,!1);return a.assign=s.bind(null,!0),a.inferSettings=o,nd=a,nd}var iU=nU();const rU=ki(iU);var id,u_;function sU(){if(u_)return id;u_=1;var r=Gm(),e=ur(),t={dimensions:["x","y"],center:.5,rng:Math.random,scale:1};function n(s,o,a){if(!e(o))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");a=r(a,t);var c=a.dimensions;if(!Array.isArray(c)||c.length<1)throw new Error("graphology-layout/random: given dimensions are invalid.");var l=c.length,u=a.center,h=a.rng,f=a.scale,d=(u-.5)*f;function m(g){for(var p=0;p<l;p++)g[c[p]]=h()*f+d;return g}if(!s){var v={};return o.forEachNode(function(g){v[g]=m({})}),v}o.updateEachNodeAttributes(function(g,p){return m(p),p},{attributes:c})}var i=n.bind(null,!1);return i.assign=n.bind(null,!0),id=i,id}var oU=sU();const aU=ki(oU);var ql={},rd={},h_;function E1(){return h_||(h_=1,(function(r){var e=Math.pow(2,8)-1,t=Math.pow(2,16)-1,n=Math.pow(2,32)-1,i=Math.pow(2,7)-1,s=Math.pow(2,15)-1,o=Math.pow(2,31)-1;r.getPointerArray=function(c){var l=c-1;if(l<=e)return Uint8Array;if(l<=t)return Uint16Array;if(l<=n)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},r.getSignedPointerArray=function(c){var l=c-1;return l<=i?Int8Array:l<=s?Int16Array:l<=o?Int32Array:Float64Array},r.getNumberType=function(c){return c===(c|0)?Math.sign(c)===-1?c<=127&&c>=-128?Int8Array:c<=32767&&c>=-32768?Int16Array:Int32Array:c<=255?Uint8Array:c<=65535?Uint16Array:Uint32Array:Float64Array};var a={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};r.getMinimalRepresentation=function(c,l){var u=null,h=0,f,d,m,v,g;for(v=0,g=c.length;v<g;v++)m=l?l(c[v]):c[v],d=r.getNumberType(m),f=a[d.name],f>h&&(h=f,u=d);return u},r.isTypedArray=function(c){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(c)},r.concat=function(){var c=0,l,u,h;for(l=0,h=arguments.length;l<h;l++)c+=arguments[l].length;var f=new arguments[0].constructor(c);for(l=0,u=0;l<h;l++)f.set(arguments[l],u),u+=arguments[l].length;return f},r.indices=function(c){for(var l=r.getPointerArray(c),u=new l(c),h=0;h<c;h++)u[h]=h;return u}})(rd)),rd}var f_;function cU(){if(f_)return ql;f_=1;var r=E1(),e=dh().createEdgeWeightGetter;function t(s,o){return s==="outbound"||s==="inbound"?o.directedSize+o.undirectedSize*2:s==="in"||s==="out"||s==="directed"?o.directedSize:o.undirectedSize*2}function n(s,o){o=o||"outbound";var a=s[o+"Neighbors"].bind(s),c=t(o,s),l=r.getPointerArray(c),u=r.getPointerArray(s.order);this.graph=s,this.neighborhood=new u(c),this.starts=new l(s.order+1),this.nodes=s.nodes();var h={},f,d,m,v,g,p,_=0;for(f=0,d=s.order;f<d;f++)h[this.nodes[f]]=f;for(f=0,d=s.order;f<d;f++)for(g=this.nodes[f],p=a(g),this.starts[f]=_,m=0,v=p.length;m<v;m++)this.neighborhood[_++]=h[p[m]];this.starts[f]=c}n.prototype.bounds=function(s){return[this.starts[s],this.starts[s+1]]},n.prototype.project=function(){var s=this,o={};return s.nodes.forEach(function(a,c){o[a]=Array.from(s.neighborhood.slice(s.starts[c],s.starts[c+1])).map(function(l){return s.nodes[l]})}),o},n.prototype.collect=function(s){var o,a,c={};for(o=0,a=s.length;o<a;o++)c[this.nodes[o]]=s[o];return c},n.prototype.assign=function(s,o){var a=0;this.graph.updateEachNodeAttributes(function(c,l){return l[s]=o[a++],l},{attributes:[s]})},ql.NeighborhoodIndex=n;function i(s,o,a){a=a||"outbound";var c=s[a+"Edges"].bind(s),l=t(a,s),u=r.getPointerArray(l),h=r.getPointerArray(s.order),f=e(o).fromMinimalEntry;this.graph=s,this.neighborhood=new h(l),this.weights=new Float64Array(l),this.outDegrees=new Float64Array(s.order),this.starts=new u(s.order+1),this.nodes=s.nodes();var d={},m,v,g,p,_,y,x,b,w,S=0;for(m=0,v=s.order;m<v;m++)d[this.nodes[m]]=m;for(m=0,v=s.order;m<v;m++)for(_=this.nodes[m],x=c(_),this.starts[m]=S,g=0,p=x.length;g<p;g++)b=x[g],y=s.opposite(_,b),w=f(b,s.getEdgeAttributes(b)),this.neighborhood[S]=d[y],this.weights[S++]=w,this.outDegrees[m]+=w;this.starts[m]=l}return i.prototype.bounds=n.prototype.bounds,i.prototype.project=n.prototype.project,i.prototype.collect=n.prototype.collect,i.prototype.assign=n.prototype.assign,ql.WeightedNeighborhoodIndex=i,ql}var sd,d_;function lU(){if(d_)return sd;d_=1;var r=ur(),e=Gm(),t=cU().WeightedNeighborhoodIndex,n={nodePagerankAttribute:"pagerank",getEdgeWeight:"weight",alpha:.85,maxIterations:100,tolerance:1e-6};function i(o,a,c){if(!r(a))throw new Error("graphology-metrics/centrality/pagerank: the given graph is not a valid graphology instance.");c=e(c,n);var l=c.alpha,u=c.maxIterations,h=c.tolerance,f=c.nodePagerankAttribute,d=a.order,m=1/d,v=new t(a,c.getEdgeWeight),g,p,_,y,x=new Float64Array(a.order),b=new Float64Array(v.weights.length),w=[];for(g=0;g<d;g++)for(x[g]=m,_=v.starts[g+1],y=v.outDegrees[g],y===0&&w.push(g),p=v.starts[g];p<_;p++)b[p]=v.weights[p]/y;for(var S=0,M=0,E,T,L,P=!1;S<u;){for(L=x,x=new Float64Array(a.order),E=0,g=0,_=w.length;g<_;g++)E+=L[w[g]];for(E*=l,g=0;g<d;g++){for(_=v.starts[g+1],p=v.starts[g];p<_;p++)T=v.neighborhood[p],x[T]+=l*L[g]*b[p];x[g]+=E*m+(1-l)*m}for(M=0,g=0;g<d;g++)M+=Math.abs(x[g]-L[g]);if(M<d*h){P=!0;break}S++}if(!P)throw Error("graphology-metrics/centrality/pagerank: failed to converge.");if(o){v.assign(f,x);return}return v.collect(x)}var s=i.bind(null,!1);return s.assign=i.bind(null,!0),sd=s,sd}var uU=lU();const hU=ki(uU);var Ma={},p_;function fU(){if(p_)return Ma;p_=1;var r=ur();function e(s,o,a,c){var l=o+"Centrality";if(!r(a))throw new Error("graphology-centrality/"+l+": the given graph is not a valid graphology instance.");if(o!=="degree"&&a.type==="undirected")throw new Error("graphology-centrality/"+l+": cannot compute "+o+" centrality on an undirected graph.");c=c||{};var u=c.nodeCentralityAttribute||l,h=a.order-1,f=a[o].bind(a);if(s){a.updateEachNodeAttributes(function(m,v){return v[u]=f(m)/h,v},{attributes:[u]});return}var d={};return a.forEachNode(function(m){d[m]=f(m)/h}),d}var t=e.bind(null,!1,"degree"),n=e.bind(null,!1,"inDegree"),i=e.bind(null,!1,"outDegree");return t.assign=e.bind(null,!0,"degree"),n.assign=e.bind(null,!0,"inDegree"),i.assign=e.bind(null,!0,"outDegree"),Ma.degreeCentrality=t,Ma.inDegreeCentrality=n,Ma.outDegreeCentrality=i,Ma}var dU=fU();const pU={};function mU(){(pU?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180.");const r=q.createContext(void 0);return{Provider:({createStore:i,children:s})=>{const o=q.useRef();return o.current||(o.current=i()),q.createElement(r.Provider,{value:o.current},s)},useStore:(i,s)=>{const o=q.useContext(r);if(!o)throw new Error("Seems like you have not used zustand provider as an ancestor.");return Xy(o,i,s)},useStoreApi:()=>{const i=q.useContext(r);if(!i)throw new Error("Seems like you have not used zustand provider as an ancestor.");return q.useMemo(()=>({...i}),[i])}}}var fi={},Jr={},od,m_;function ph(){if(m_)return od;m_=1;function r(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},r.empty=function(){var e=new r(function(){return{done:!0}});return e},r.fromSequence=function(e){var t=0,n=e.length;return new r(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},r.is=function(e){return e instanceof r?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},od=r,od}var Yl={},g_;function M1(){return g_||(g_=1,Yl.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",Yl.SYMBOL_SUPPORT=typeof Symbol<"u"),Yl}var ad,v_;function Vm(){if(v_)return ad;v_=1;var r=M1(),e=r.ARRAY_BUFFER_SUPPORT,t=r.SYMBOL_SUPPORT;return ad=function(i,s){var o,a,c,l,u;if(!i)throw new Error("obliterator/forEach: invalid iterable.");if(typeof s!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(i)||e&&ArrayBuffer.isView(i)||typeof i=="string"||i.toString()==="[object Arguments]"){for(c=0,l=i.length;c<l;c++)s(i[c],c);return}if(typeof i.forEach=="function"){i.forEach(s);return}if(t&&Symbol.iterator in i&&typeof i.next!="function"&&(i=i[Symbol.iterator]()),typeof i.next=="function"){for(o=i,c=0;u=o.next(),u.done!==!0;)s(u.value,c),c++;return}for(a in i)i.hasOwnProperty(a)&&s(i[a],a)},ad}var cd,__;function gU(){if(__)return cd;__=1;var r=ph(),e=Vm();function t(){this.clear()}return t.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},t.prototype.enqueue=function(n){return this.items.push(n),++this.size},t.prototype.dequeue=function(){if(this.size){var n=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,n}},t.prototype.peek=function(){if(this.size)return this.items[this.offset]},t.prototype.forEach=function(n,i){i=arguments.length>1?i:this;for(var s=this.offset,o=0,a=this.items.length;s<a;s++,o++)n.call(i,this.items[s],o,this)},t.prototype.toArray=function(){return this.items.slice(this.offset)},t.prototype.values=function(){var n=this.items,i=this.offset;return new r(function(){if(i>=n.length)return{done:!0};var s=n[i];return i++,{value:s,done:!1}})},t.prototype.entries=function(){var n=this.items,i=this.offset,s=0;return new r(function(){if(i>=n.length)return{done:!0};var o=n[i];return i++,{value:[s++,o],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.toString=function(){return this.toArray().join(",")},t.prototype.toJSON=function(){return this.toArray()},t.prototype.inspect=function(){var n=this.toArray();return Object.defineProperty(n,"constructor",{value:t,enumerable:!1}),n},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(n){var i=new t;return e(n,function(s){i.enqueue(s)}),i},t.of=function(){return t.from(arguments)},cd=t,cd}var ld,y_;function vU(){return y_||(y_=1,ld=function(e,t){var n=t.length;if(n!==0){var i=e.length;e.length+=n;for(var s=0;s<n;s++)e[i+s]=t[s]}}),ld}var x_;function _U(){if(x_)return Jr;x_=1;var r=ur(),e=gU(),t=vU();function n(l,u,h){if(!r(l))throw new Error("graphology-shortest-path: invalid graphology instance.");if(arguments.length<3)throw new Error("graphology-shortest-path: invalid number of arguments. Expecting at least 3.");if(!l.hasNode(u))throw new Error('graphology-shortest-path: the "'+u+'" source node does not exist in the given graph.');if(!l.hasNode(h))throw new Error('graphology-shortest-path: the "'+h+'" target node does not exist in the given graph.');if(u=""+u,h=""+h,u===h)return[u];var f=l.inboundNeighbors.bind(l),d=l.outboundNeighbors.bind(l),m={},v={};m[u]=null,v[h]=null;var g=[u],p=[h],_,y,x,b,w,S,M,E,T=!1;e:for(;g.length&&p.length;)if(g.length<=p.length){for(_=g,g=[],w=0,M=_.length;w<M;w++)for(y=_[w],x=d(y),S=0,E=x.length;S<E;S++)if(b=x[S],b in m||(g.push(b),m[b]=y),b in v){T=!0;break e}}else for(_=p,p=[],w=0,M=_.length;w<M;w++)for(y=_[w],x=f(y),S=0,E=x.length;S<E;S++)if(b=x[S],b in v||(p.push(b),v[b]=y),b in m){T=!0;break e}if(!T)return null;for(var L=[];b;)L.unshift(b),b=m[b];for(b=v[L[L.length-1]];b;)L.push(b),b=v[b];return L.length?L:null}function i(l,u){if(!r(l))throw new Error("graphology-shortest-path: invalid graphology instance.");if(arguments.length<2)throw new Error("graphology-shortest-path: invalid number of arguments. Expecting at least 2.");if(!l.hasNode(u))throw new Error('graphology-shortest-path: the "'+u+'" source node does not exist in the given graph.');u=""+u;var h={},f={},d,m,v,g,p,_;for(h[u]=!0,f[u]=[u];Object.keys(h).length;){d=h,h={};for(v in d)for(m=l.outboundNeighbors(v),p=0,_=m.length;p<_;p++)g=m[p],f[g]||(f[g]=f[v].concat(g),h[g]=!0)}return f}function s(l,u,h){if(!r(u))throw new Error("graphology-shortest-path: invalid graphology instance.");if(!u.hasNode(h))throw new Error('graphology-shortest-path: the "'+h+'" source node does not exist in the given graph.');h=""+h;var f=new Set,d={},m=0;d[h]=0;for(var v=[h],g,p,_;v.length!==0;){var y=[];for(g=0,p=v.length;g<p;g++)_=v[g],!f.has(_)&&(f.add(_),t(y,u[l](_)),d[_]=m);m++,v=y}return d}var o=s.bind(null,"outboundNeighbors"),a=s.bind(null,"neighbors");function c(l,u){u=""+u;var h=[],f={},d={},m=l.nodes(),v,g,p,_,y,x,b,w,S;for(x=0,w=m.length;x<w;x++)_=m[x],f[_]=[],d[_]=0;var M={};d[u]=1,M[u]=0;for(var E=e.of(u);E.size;)for(_=E.dequeue(),h.push(_),v=M[_],g=d[_],p=l.outboundNeighbors(_),b=0,S=p.length;b<S;b++)y=p[b],y in M||(E.enqueue(y),M[y]=v+1),M[y]===v+1&&(d[y]+=g,f[y].push(_));return[h,f,d]}return Jr.bidirectional=n,Jr.singleSource=i,Jr.singleSourceLength=o,Jr.undirectedSingleSourceLength=a,Jr.brandes=c,Jr}var ud={},b_;function yU(){if(b_)return ud;b_=1;var r=function(){return!0};return ud.edgePathFromNodePath=function(e,t){var n=t.length,i,s,o,a;if(n<2)return s=t[0],a=e.multi?e.findEdge(s,s,r):e.edge(s,s),a?[a]:[];n--;var c=new Array(n);for(i=0;i<n;i++){if(s=t[i],o=t[i+1],a=e.multi?e.findOutboundEdge(s,o,r):e.edge(s,o),a===void 0)throw new Error("graphology-shortest-path: given path is impossible in given graph.");c[i]=a}return c},ud}var Ta={},co={},w_;function xU(){if(w_)return co;w_=1;var r=function(i,s){return i<s?-1:i>s?1:0},e=function(i,s){return i<s?1:i>s?-1:0};function t(i){return function(s,o){return i(o,s)}}function n(i){return i===2?function(s,o){return s[0]<o[0]?-1:s[0]>o[0]?1:s[1]<o[1]?-1:s[1]>o[1]?1:0}:function(s,o){for(var a=0;a<i;){if(s[a]<o[a])return-1;if(s[a]>o[a])return 1;a++}return 0}}return co.DEFAULT_COMPARATOR=r,co.DEFAULT_REVERSE_COMPARATOR=e,co.reverseComparator=t,co.createTupleComparator=n,co}var lo={},S_;function bU(){if(S_)return lo;S_=1;var r=Vm(),e=E1();function t(o){return Array.isArray(o)||e.isTypedArray(o)}function n(o){if(typeof o.length=="number")return o.length;if(typeof o.size=="number")return o.size}function i(o){var a=n(o),c=typeof a=="number"?new Array(a):[],l=0;return r(o,function(u){c[l++]=u}),c}function s(o){var a=n(o),c=typeof a=="number"?e.getPointerArray(a):Array,l=typeof a=="number"?new Array(a):[],u=typeof a=="number"?new c(a):[],h=0;return r(o,function(f){l[h]=f,u[h]=h++}),[l,u]}return lo.isArrayLike=t,lo.guessLength=n,lo.toArray=i,lo.toArrayWithIndices=s,lo}var hd,E_;function T1(){if(E_)return hd;E_=1;var r=Vm(),e=xU(),t=bU(),n=e.DEFAULT_COMPARATOR,i=e.reverseComparator;function s(p,_,y,x){for(var b=_[x],w,S;x>y;){if(w=x-1>>1,S=_[w],p(b,S)<0){_[x]=S,x=w;continue}break}_[x]=b}function o(p,_,y){for(var x=_.length,b=y,w=_[y],S=2*y+1,M;S<x;)M=S+1,M<x&&p(_[S],_[M])>=0&&(S=M),_[y]=_[S],y=S,S=2*y+1;_[y]=w,s(p,_,b,y)}function a(p,_,y){_.push(y),s(p,_,0,_.length-1)}function c(p,_){var y=_.pop();if(_.length!==0){var x=_[0];return _[0]=y,o(p,_,0),x}return y}function l(p,_,y){if(_.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var x=_[0];return _[0]=y,o(p,_,0),x}function u(p,_,y){var x;return _.length!==0&&p(_[0],y)<0&&(x=_[0],_[0]=y,y=x,o(p,_,0)),y}function h(p,_){for(var y=_.length,x=y>>1,b=x;--b>=0;)o(p,_,b)}function f(p,_){for(var y=_.length,x=0,b=new Array(y);x<y;)b[x++]=c(p,_);return b}function d(p,_,y){arguments.length===2&&(y=_,_=p,p=n);var x=i(p),b,w,S,M=1/0,E;if(_===1){if(t.isArrayLike(y)){for(b=0,w=y.length;b<w;b++)S=y[b],(M===1/0||p(S,M)<0)&&(M=S);return E=new y.constructor(1),E[0]=M,E}return r(y,function(L){(M===1/0||p(L,M)<0)&&(M=L)}),[M]}if(t.isArrayLike(y)){if(_>=y.length)return y.slice().sort(p);for(E=y.slice(0,_),h(x,E),b=_,w=y.length;b<w;b++)x(y[b],E[0])>0&&l(x,E,y[b]);return E.sort(p)}var T=t.guessLength(y);return T!==null&&T<_&&(_=T),E=new Array(_),b=0,r(y,function(L){b<_?E[b]=L:(b===_&&h(x,E),x(L,E[0])>0&&l(x,E,L)),b++}),E.length>b&&(E.length=b),E.sort(p)}function m(p,_,y){arguments.length===2&&(y=_,_=p,p=n);var x=i(p),b,w,S,M=-1/0,E;if(_===1){if(t.isArrayLike(y)){for(b=0,w=y.length;b<w;b++)S=y[b],(M===-1/0||p(S,M)>0)&&(M=S);return E=new y.constructor(1),E[0]=M,E}return r(y,function(L){(M===-1/0||p(L,M)>0)&&(M=L)}),[M]}if(t.isArrayLike(y)){if(_>=y.length)return y.slice().sort(x);for(E=y.slice(0,_),h(p,E),b=_,w=y.length;b<w;b++)p(y[b],E[0])>0&&l(p,E,y[b]);return E.sort(x)}var T=t.guessLength(y);return T!==null&&T<_&&(_=T),E=new Array(_),b=0,r(y,function(L){b<_?E[b]=L:(b===_&&h(p,E),p(L,E[0])>0&&l(p,E,L)),b++}),E.length>b&&(E.length=b),E.sort(x)}function v(p){if(this.clear(),this.comparator=p||n,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}v.prototype.clear=function(){this.items=[],this.size=0},v.prototype.push=function(p){return a(this.comparator,this.items,p),++this.size},v.prototype.peek=function(){return this.items[0]},v.prototype.pop=function(){return this.size!==0&&this.size--,c(this.comparator,this.items)},v.prototype.replace=function(p){return l(this.comparator,this.items,p)},v.prototype.pushpop=function(p){return u(this.comparator,this.items,p)},v.prototype.consume=function(){return this.size=0,f(this.comparator,this.items)},v.prototype.toArray=function(){return f(this.comparator,this.items.slice())},v.prototype.inspect=function(){var p=this.toArray();return Object.defineProperty(p,"constructor",{value:v,enumerable:!1}),p},typeof Symbol<"u"&&(v.prototype[Symbol.for("nodejs.util.inspect.custom")]=v.prototype.inspect);function g(p){if(this.clear(),this.comparator=p||n,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=i(this.comparator)}return g.prototype=v.prototype,v.from=function(p,_){var y=new v(_),x;return t.isArrayLike(p)?x=p.slice():x=t.toArray(p),h(y.comparator,x),y.items=x,y.size=x.length,y},g.from=function(p,_){var y=new g(_),x;return t.isArrayLike(p)?x=p.slice():x=t.toArray(p),h(y.comparator,x),y.items=x,y.size=x.length,y},v.siftUp=o,v.siftDown=s,v.push=a,v.pop=c,v.replace=l,v.pushpop=u,v.heapify=h,v.consume=f,v.nsmallest=d,v.nlargest=m,v.MinHeap=v,v.MaxHeap=g,hd=v,hd}var M_;function wU(){if(M_)return Ta;M_=1;var r=ur(),e=dh().createEdgeWeightGetter,t=T1(),n="weight";function i(h,f){return h[0]>f[0]?1:h[0]<f[0]?-1:h[1]>f[1]?1:h[1]<f[1]?-1:h[2]>f[2]?1:h[2]<f[2]?-1:0}function s(h,f){return h[0]>f[0]?1:h[0]<f[0]?-1:h[1]>f[1]?1:h[1]<f[1]?-1:h[2]>f[2]?1:h[2]<f[2]?-1:h[3]>f[3]?1:h[3]<f[3]?-1:0}function o(h,f,d,m){if(f=""+f,d=""+d,!r(h))throw new Error("graphology-shortest-path/dijkstra: invalid graphology instance.");if(f&&!h.hasNode(f))throw new Error('graphology-shortest-path/dijkstra: the "'+f+'" source node does not exist in the given graph.');if(d&&!h.hasNode(d))throw new Error('graphology-shortest-path/dijkstra: the "'+d+'" target node does not exist in the given graph.');if(m=e(m||n).fromMinimalEntry,f===d)return[0,[f]];var v=[{},{}],g=[{},{}],p=[new t(i),new t(i)],_=[{},{}];g[0][f]=[f],g[1][d]=[d],_[0][f]=0,_[1][d]=0;var y=[],x=1/0,b=0,w=1,S,M,E,T,L,P,A,z,V;for(p[0].push([0,b++,f]),p[1].push([0,b++,d]);p[0].size&&p[1].size;)if(w=1-w,S=p[w].pop(),T=S[0],L=S[2],!(L in v[w])){if(v[w][L]=T,L in v[1-w])return[x,y];for(M=w===1?h.inboundEdges(L):h.outboundEdges(L),z=0,V=M.length;z<V;z++){if(A=M[z],P=h.opposite(L,A),E=v[w][L]+m(A,h.getEdgeAttributes(A)),P in v[w]&&E<v[w][P])throw Error("graphology-shortest-path/dijkstra: contradictory paths found. Do some of your edges have a negative weight?");(!(P in _[w])||E<_[w][P])&&(_[w][P]=E,p[w].push([E,b++,P]),g[w][P]=g[w][L].concat(P),P in _[0]&&P in _[1]&&(T=_[0][P]+_[1][P],(y.length===0||x>T)&&(x=T,y=g[0][P].concat(g[1][P].slice(0,-1).reverse()))))}}return[1/0,null]}function a(h,f,d,m,v,g){if(!r(h))throw new Error("graphology-shortest-path/dijkstra: invalid graphology instance.");d=e(d||n).fromMinimalEntry;var p={},_={},y=new t(i),x=0,b,w,S,M,E,T,L,P,A,z,V;for(P=0,z=f.length;P<z;P++)M=f[P],_[M]=0,y.push([0,x++,M]),g&&(g[M]=[M]);for(;y.size;)if(w=y.pop(),L=w[0],M=w[2],!(M in p)){if(p[M]=L,M===v)break;for(b=h.outboundEdges(M),A=0,V=b.length;A<V;A++){if(T=b[A],E=h.opposite(M,T),S=d(T,h.getEdgeAttributes(T))+p[M],E in p&&S<p[E])throw Error("graphology-shortest-path/dijkstra: contradictory paths found. Do some of your edges have a negative weight?");(!(E in _)||S<_[E])&&(_[E]=S,y.push([S,x++,E]),g&&(g[E]=g[M].concat(E)))}}return p}function c(h,f,d){var m={};return a(h,[f],d,0,null,m),m}function l(h,f,d,m){return o(h,f,d,m)[1]}function u(h,f,d){f=""+f,d=e(d||n).fromMinimalEntry;var m=[],v={},g={},p=h.nodes(),_,y,x,b,w,S,M,E,T,L;for(T=0,L=p.length;T<L;T++)S=p[T],v[S]=[],g[S]=0;var P={};g[f]=1;var A={};A[f]=0;var z=0,V=new t(s);for(V.push([0,z++,f,f]);V.size;)if(y=V.pop(),b=y[0],x=y[2],S=y[3],!(S in P))for(g[S]+=g[x],m.push(S),P[S]=b,_=h.outboundEdges(S),T=0,L=_.length;T<L;T++)E=_[T],M=h.opposite(S,E),w=b+d(E,h.getEdgeAttributes(E)),!(M in P)&&(!(M in A)||w<A[M])?(A[M]=w,V.push([w,z++,S,M]),g[M]=0,v[M]=[S]):w===A[M]&&(g[M]+=g[S],v[M].push(S));return[m,v,g]}return Ta.bidirectional=l,Ta.singleSource=c,Ta.brandes=u,Ta}var fd={},T_;function SU(){if(T_)return fd;T_=1;var r=ur(),e=dh().createEdgeWeightGetter,t=T1(),n="weight";function i(o,a){return o[0]>a[0]?1:o[0]<a[0]?-1:o[1]>a[1]?1:o[1]<a[1]?-1:0}function s(o,a,c,l,u,h){if(!r(o))throw new Error("graphology-shortest-path/astar: invalid graphology instance.");if(a&&!o.hasNode(a))throw new Error('graphology-shortest-path/astar: the "'+a+'" source node does not exist in the given graph.');if(c&&!o.hasNode(c))throw new Error('graphology-shortest-path/astar: the "'+c+'" target node does not exist in the given graph.');if(l=e(l||n).fromMinimalEntry,a===c)return[a];u=u||function(){return 0},h=h||{};var f=0,d=new t(i);d.push([0,f++,a,0,null]);var m={},v={},g,p,_,y,x,b,w,S,M,E,T,L;function P(A,z,V,N){if(L=p===V?N:V,E=l(A,z),E!==null){if(T=y+E,m.hasOwnProperty(L)){if(_=m[L],S=_[0],M=_[1],S<=T)return}else M=u(L,c);h.cutoff&&T+M>h.cutoff||(m[L]=[T,M],d.push([T+M,f++,L,T,p]))}}for(;d.size!==0;){if(g=d.pop(),p=g[2],y=g[3],x=g[4],p===c){for(b=[p],w=x;w!==null;)b.push(w),w=v[w];return b.reverse(),b}v.hasOwnProperty(p)&&(v[p]===null||(S=m[p][0],S<y))||(v[p]=x,o.forEachOutboundEdge(p,P))}return null}return fd.bidirectional=s,fd}var A_;function EU(){if(A_)return fi;A_=1;var r=_U(),e=yU();return fi.unweighted=r,fi.dijkstra=wU(),fi.astar=SU(),fi.bidirectional=r.bidirectional,fi.singleSource=r.singleSource,fi.singleSourceLength=r.singleSourceLength,fi.undirectedSingleSourceLength=r.undirectedSingleSourceLength,fi.brandes=r.brandes,fi.edgePathFromNodePath=e.edgePathFromNodePath,fi}EU();var jl={exports:{}},C_;function MU(){if(C_)return jl.exports;C_=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(b,w,S){return Function.prototype.apply.call(b,w,S)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(b){return Object.getOwnPropertyNames(b).concat(Object.getOwnPropertySymbols(b))}:t=function(b){return Object.getOwnPropertyNames(b)};function n(x){console&&console.warn&&console.warn(x)}var i=Number.isNaN||function(b){return b!==b};function s(){s.init.call(this)}jl.exports=s,jl.exports.once=p,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(x){if(typeof x!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof x)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(x){if(typeof x!="number"||x<0||i(x))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+x+".");o=x}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(b){if(typeof b!="number"||b<0||i(b))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+b+".");return this._maxListeners=b,this};function c(x){return x._maxListeners===void 0?s.defaultMaxListeners:x._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(b){for(var w=[],S=1;S<arguments.length;S++)w.push(arguments[S]);var M=b==="error",E=this._events;if(E!==void 0)M=M&&E.error===void 0;else if(!M)return!1;if(M){var T;if(w.length>0&&(T=w[0]),T instanceof Error)throw T;var L=new Error("Unhandled error."+(T?" ("+T.message+")":""));throw L.context=T,L}var P=E[b];if(P===void 0)return!1;if(typeof P=="function")e(P,this,w);else for(var A=P.length,z=m(P,A),S=0;S<A;++S)e(z[S],this,w);return!0};function l(x,b,w,S){var M,E,T;if(a(w),E=x._events,E===void 0?(E=x._events=Object.create(null),x._eventsCount=0):(E.newListener!==void 0&&(x.emit("newListener",b,w.listener?w.listener:w),E=x._events),T=E[b]),T===void 0)T=E[b]=w,++x._eventsCount;else if(typeof T=="function"?T=E[b]=S?[w,T]:[T,w]:S?T.unshift(w):T.push(w),M=c(x),M>0&&T.length>M&&!T.warned){T.warned=!0;var L=new Error("Possible EventEmitter memory leak detected. "+T.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit");L.name="MaxListenersExceededWarning",L.emitter=x,L.type=b,L.count=T.length,n(L)}return x}s.prototype.addListener=function(b,w){return l(this,b,w,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(b,w){return l(this,b,w,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(x,b,w){var S={fired:!1,wrapFn:void 0,target:x,type:b,listener:w},M=u.bind(S);return M.listener=w,S.wrapFn=M,M}s.prototype.once=function(b,w){return a(w),this.on(b,h(this,b,w)),this},s.prototype.prependOnceListener=function(b,w){return a(w),this.prependListener(b,h(this,b,w)),this},s.prototype.removeListener=function(b,w){var S,M,E,T,L;if(a(w),M=this._events,M===void 0)return this;if(S=M[b],S===void 0)return this;if(S===w||S.listener===w)--this._eventsCount===0?this._events=Object.create(null):(delete M[b],M.removeListener&&this.emit("removeListener",b,S.listener||w));else if(typeof S!="function"){for(E=-1,T=S.length-1;T>=0;T--)if(S[T]===w||S[T].listener===w){L=S[T].listener,E=T;break}if(E<0)return this;E===0?S.shift():v(S,E),S.length===1&&(M[b]=S[0]),M.removeListener!==void 0&&this.emit("removeListener",b,L||w)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(b){var w,S,M;if(S=this._events,S===void 0)return this;if(S.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):S[b]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete S[b]),this;if(arguments.length===0){var E=Object.keys(S),T;for(M=0;M<E.length;++M)T=E[M],T!=="removeListener"&&this.removeAllListeners(T);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(w=S[b],typeof w=="function")this.removeListener(b,w);else if(w!==void 0)for(M=w.length-1;M>=0;M--)this.removeListener(b,w[M]);return this};function f(x,b,w){var S=x._events;if(S===void 0)return[];var M=S[b];return M===void 0?[]:typeof M=="function"?w?[M.listener||M]:[M]:w?g(M):m(M,M.length)}s.prototype.listeners=function(b){return f(this,b,!0)},s.prototype.rawListeners=function(b){return f(this,b,!1)},s.listenerCount=function(x,b){return typeof x.listenerCount=="function"?x.listenerCount(b):d.call(x,b)},s.prototype.listenerCount=d;function d(x){var b=this._events;if(b!==void 0){var w=b[x];if(typeof w=="function")return 1;if(w!==void 0)return w.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function m(x,b){for(var w=new Array(b),S=0;S<b;++S)w[S]=x[S];return w}function v(x,b){for(;b+1<x.length;b++)x[b]=x[b+1];x.pop()}function g(x){for(var b=new Array(x.length),w=0;w<b.length;++w)b[w]=x[w].listener||x[w];return b}function p(x,b){return new Promise(function(w,S){function M(T){x.removeListener(b,E),S(T)}function E(){typeof x.removeListener=="function"&&x.removeListener("error",M),w([].slice.call(arguments))}y(x,b,E,{once:!0}),b!=="error"&&_(x,M,{once:!0})})}function _(x,b,w){typeof x.on=="function"&&y(x,"error",b,w)}function y(x,b,w,S){if(typeof x.on=="function")S.once?x.once(b,w):x.on(b,w);else if(typeof x.addEventListener=="function")x.addEventListener(b,function M(E){S.once&&x.removeEventListener(b,M),w(E)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof x)}return jl.exports}var TU=MU(),AU=ph();const ri=ki(AU);var dd,R_;function A1(){if(R_)return dd;R_=1;var r=ph(),e=M1(),t=e.ARRAY_BUFFER_SUPPORT,n=e.SYMBOL_SUPPORT;function i(s){return typeof s=="string"||Array.isArray(s)||t&&ArrayBuffer.isView(s)?r.fromSequence(s):typeof s!="object"||s===null?null:n&&typeof s[Symbol.iterator]=="function"?s[Symbol.iterator]():typeof s.next=="function"?s:null}return dd=function(o){var a=i(o);if(!a)throw new Error("obliterator: target is not iterable nor a valid iterator.");return a},dd}var pd,P_;function CU(){if(P_)return pd;P_=1;var r=A1();return pd=function(t,n){for(var i=arguments.length>1?n:1/0,s=i!==1/0?new Array(i):[],o,a=0,c=r(t);;){if(a===i)return s;if(o=c.next(),o.done)return a!==n&&(s.length=a),s;s[a++]=o.value}},pd}var RU=CU();const C1=ki(RU);var md,L_;function PU(){if(L_)return md;L_=1;var r=ph(),e=A1();return md=function(){var n=arguments,i=null,s=-1;return new r(function(){var a=null;do{if(i===null){if(s++,s>=n.length)return{done:!0};i=e(n[s])}if(a=i.next(),a.done===!0){i=null;continue}break}while(!0);return a})},md}var LU=PU();const rr=ki(LU);function DU(){const r=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const n in arguments[e])r[n]=arguments[e][n];return r}let Jt=DU;typeof Object.assign=="function"&&(Jt=Object.assign);function ii(r,e,t,n){const i=r._nodes.get(e);let s=null;return i&&(n==="mixed"?s=i.out&&i.out[t]||i.undirected&&i.undirected[t]:n==="directed"?s=i.out&&i.out[t]:s=i.undirected&&i.undirected[t]),s}function cn(r){return typeof r=="object"&&r!==null}function R1(r){let e;for(e in r)return!1;return!0}function $n(r,e,t){Object.defineProperty(r,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function di(r,e,t){const n={enumerable:!0,configurable:!0};typeof t=="function"?n.get=t:(n.value=t,n.writable=!1),Object.defineProperty(r,e,n)}function D_(r){return!(!cn(r)||r.attributes&&!Array.isArray(r.attributes))}function IU(){let r=Math.floor(Math.random()*256)&255;return()=>r++}class Hm extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class Be extends Hm{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Be.prototype.constructor)}}class Ie extends Hm{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Ie.prototype.constructor)}}class Xe extends Hm{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Xe.prototype.constructor)}}function P1(r,e){this.key=r,this.attributes=e,this.clear()}P1.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function L1(r,e){this.key=r,this.attributes=e,this.clear()}L1.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function D1(r,e){this.key=r,this.attributes=e,this.clear()}D1.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function zo(r,e,t,n,i){this.key=e,this.attributes=i,this.undirected=r,this.source=t,this.target=n}zo.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");const t=this.source.key,n=this.target.key;this.source[r][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)};zo.prototype.attachMulti=function(){let r="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(r=e="undirected");const i=this.source[r],s=i[n];if(typeof s>"u"){i[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}s.previous=this,this.next=s,i[n]=this,this.target[e][t]=this};zo.prototype.detach=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][r]};zo.prototype.detachMulti=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const I1=0,U1=1,UU=2,O1=3;function hr(r,e,t,n,i,s,o){let a,c,l,u;if(n=""+n,t===I1){if(a=r._nodes.get(n),!a)throw new Ie(`Graph.${e}: could not find the "${n}" node in the graph.`);l=i,u=s}else if(t===O1){if(i=""+i,c=r._edges.get(i),!c)throw new Ie(`Graph.${e}: could not find the "${i}" edge in the graph.`);const h=c.source.key,f=c.target.key;if(n===h)a=c.target;else if(n===f)a=c.source;else throw new Ie(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${h}, ${f}).`);l=s,u=o}else{if(c=r._edges.get(n),!c)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===U1?a=c.source:a=c.target,l=i,u=s}return[a,l,u]}function OU(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=hr(this,e,t,n,i,s);return o.attributes[a]}}function NU(r,e,t){r.prototype[e]=function(n,i){const[s]=hr(this,e,t,n,i);return s.attributes}}function FU(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=hr(this,e,t,n,i,s);return o.attributes.hasOwnProperty(a)}}function kU(r,e,t){r.prototype[e]=function(n,i,s,o){const[a,c,l]=hr(this,e,t,n,i,s,o);return a.attributes[c]=l,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function zU(r,e,t){r.prototype[e]=function(n,i,s,o){const[a,c,l]=hr(this,e,t,n,i,s,o);if(typeof l!="function")throw new Be(`Graph.${e}: updater should be a function.`);const u=a.attributes,h=l(u[c]);return u[c]=h,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function BU(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=hr(this,e,t,n,i,s);return delete o.attributes[a],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:a}),this}}function GU(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=hr(this,e,t,n,i,s);if(!cn(a))throw new Be(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=a,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function VU(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=hr(this,e,t,n,i,s);if(!cn(a))throw new Be(`Graph.${e}: provided attributes are not a plain object.`);return Jt(o.attributes,a),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:a}),this}}function HU(r,e,t){r.prototype[e]=function(n,i,s){const[o,a]=hr(this,e,t,n,i,s);if(typeof a!="function")throw new Be(`Graph.${e}: provided updater is not a function.`);return o.attributes=a(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const WU=[{name:r=>`get${r}Attribute`,attacher:OU},{name:r=>`get${r}Attributes`,attacher:NU},{name:r=>`has${r}Attribute`,attacher:FU},{name:r=>`set${r}Attribute`,attacher:kU},{name:r=>`update${r}Attribute`,attacher:zU},{name:r=>`remove${r}Attribute`,attacher:BU},{name:r=>`replace${r}Attributes`,attacher:GU},{name:r=>`merge${r}Attributes`,attacher:VU},{name:r=>`update${r}Attributes`,attacher:HU}];function XU(r){WU.forEach(function({name:e,attacher:t}){t(r,e("Node"),I1),t(r,e("Source"),U1),t(r,e("Target"),UU),t(r,e("Opposite"),O1)})}function qU(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=ii(this,o,a,t),!s)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]}}function YU(r,e,t){r.prototype[e]=function(n){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,o=""+arguments[1];if(i=ii(this,s,o,t),!i)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${s}" - "${o}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function jU(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=ii(this,o,a,t),!s)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes.hasOwnProperty(i)}}function $U(r,e,t){r.prototype[e]=function(n,i,s){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,c=""+i;if(i=arguments[2],s=arguments[3],o=ii(this,a,c,t),!o)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[i]=s,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function ZU(r,e,t){r.prototype[e]=function(n,i,s){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,c=""+i;if(i=arguments[2],s=arguments[3],o=ii(this,a,c,t),!o)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof s!="function")throw new Be(`Graph.${e}: updater should be a function.`);return o.attributes[i]=s(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function KU(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=ii(this,o,a,t),!s)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete s.attributes[i],this.emit("edgeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:i}),this}}function JU(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=ii(this,o,a,t),!s)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!cn(i))throw new Be(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=i,this.emit("edgeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function QU(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=ii(this,o,a,t),!s)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!cn(i))throw new Be(`Graph.${e}: provided attributes are not a plain object.`);return Jt(s.attributes,i),this.emit("edgeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:i}),this}}function eO(r,e,t){r.prototype[e]=function(n,i){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new Xe(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new Xe(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,a=""+i;if(i=arguments[2],s=ii(this,o,a,t),!s)throw new Ie(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(t!=="mixed")throw new Xe(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new Ie(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new Be(`Graph.${e}: provided updater is not a function.`);return s.attributes=i(s.attributes),this.emit("edgeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const tO=[{name:r=>`get${r}Attribute`,attacher:qU},{name:r=>`get${r}Attributes`,attacher:YU},{name:r=>`has${r}Attribute`,attacher:jU},{name:r=>`set${r}Attribute`,attacher:$U},{name:r=>`update${r}Attribute`,attacher:ZU},{name:r=>`remove${r}Attribute`,attacher:KU},{name:r=>`replace${r}Attributes`,attacher:JU},{name:r=>`merge${r}Attributes`,attacher:QU},{name:r=>`update${r}Attributes`,attacher:eO}];function nO(r){tO.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}const iO=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function rO(r,e,t,n){let i=!1;for(const s in e){if(s===n)continue;const o=e[s];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),r&&i)return o.key}}function sO(r,e,t,n){let i,s,o,a=!1;for(const c in e)if(c!==n){i=e[c];do{if(s=i.source,o=i.target,a=t(i.key,i.attributes,s.key,o.key,s.attributes,o.attributes,i.undirected),r&&a)return i.key;i=i.next}while(i!==void 0)}}function gd(r,e){const t=Object.keys(r),n=t.length;let i,s=0;return new ri(function(){do if(i)i=i.next;else{if(s>=n)return{done:!0};const a=t[s++];if(a===e){i=void 0;continue}i=r[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}})}function oO(r,e,t,n){const i=e[t];if(!i)return;const s=i.source,o=i.target;if(n(i.key,i.attributes,s.key,o.key,s.attributes,o.attributes,i.undirected)&&r)return i.key}function aO(r,e,t,n){let i=e[t];if(!i)return;let s=!1;do{if(s=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),r&&s)return i.key;i=i.next}while(i!==void 0)}function vd(r,e){let t=r[e];return t.next!==void 0?new ri(function(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}):ri.of({edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected})}function cO(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return typeof Array.from=="function"?Array.from(r._edges.keys()):C1(r._edges.keys(),r._edges.size);const t=e==="undirected"?r.undirectedSize:r.directedSize,n=new Array(t),i=e==="undirected",s=r._edges.values();let o=0,a,c;for(;a=s.next(),a.done!==!0;)c=a.value,c.undirected===i&&(n[o++]=c.key);return n}function N1(r,e,t,n){if(e.size===0)return;const i=t!=="mixed"&&t!==e.type,s=t==="undirected";let o,a,c=!1;const l=e._edges.values();for(;o=l.next(),o.done!==!0;){if(a=o.value,i&&a.undirected!==s)continue;const{key:u,attributes:h,source:f,target:d}=a;if(c=n(u,h,f.key,d.key,f.attributes,d.attributes,a.undirected),r&&c)return u}}function lO(r,e){if(r.size===0)return ri.empty();const t=e!=="mixed"&&e!==r.type,n=e==="undirected",i=r._edges.values();return new ri(function(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(t&&a.undirected!==n))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}})}function Wm(r,e,t,n,i,s){const o=e?sO:rO;let a;if(t!=="undirected"&&(n!=="out"&&(a=o(r,i.in,s),r&&a)||n!=="in"&&(a=o(r,i.out,s,n?void 0:i.key),r&&a))||t!=="directed"&&(a=o(r,i.undirected,s),r&&a))return a}function uO(r,e,t,n){const i=[];return Wm(!1,r,e,t,n,function(s){i.push(s)}),i}function hO(r,e,t){let n=ri.empty();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=rr(n,gd(t.in))),e!=="in"&&typeof t.out<"u"&&(n=rr(n,gd(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(n=rr(n,gd(t.undirected))),n}function Xm(r,e,t,n,i,s,o){const a=t?aO:oO;let c;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(c=a(r,i.in,s,o),r&&c)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==s)&&(c=a(r,i.out,s,o),r&&c))||e!=="directed"&&typeof i.undirected<"u"&&(c=a(r,i.undirected,s,o),r&&c))return c}function fO(r,e,t,n,i){const s=[];return Xm(!1,r,e,t,n,i,function(o){s.push(o)}),s}function dO(r,e,t,n){let i=ri.empty();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(i=rr(i,vd(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(i=rr(i,vd(t.out,n)))),r!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(i=rr(i,vd(t.undirected,n))),i}function pO(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(s,o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return cO(this,n);if(arguments.length===1){s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new Ie(`Graph.${t}: could not find the "${s}" node in the graph.`);return uO(this.multi,n==="mixed"?this.type:n,i,a)}if(arguments.length===2){s=""+s,o=""+o;const a=this._nodes.get(s);if(!a)throw new Ie(`Graph.${t}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(o))throw new Ie(`Graph.${t}: could not find the "${o}" target node in the graph.`);return fO(n,this.multi,i,a,o)}throw new Be(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function mO(r,e){const{name:t,type:n,direction:i}=e,s="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(l,u,h){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return h=l,N1(!1,this,n,h);if(arguments.length===2){l=""+l,h=u;const f=this._nodes.get(l);if(typeof f>"u")throw new Ie(`Graph.${s}: could not find the "${l}" node in the graph.`);return Wm(!1,this.multi,n==="mixed"?this.type:n,i,f,h)}if(arguments.length===3){l=""+l,u=""+u;const f=this._nodes.get(l);if(!f)throw new Ie(`Graph.${s}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new Ie(`Graph.${s}: could not find the "${u}" target node in the graph.`);return Xm(!1,n,this.multi,i,f,u,h)}throw new Be(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);r.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),u=l.pop();let h;if(l.length===0){let f=0;n!=="directed"&&(f+=this.undirectedSize),n!=="undirected"&&(f+=this.directedSize),h=new Array(f);let d=0;l.push((m,v,g,p,_,y,x)=>{h[d++]=u(m,v,g,p,_,y,x)})}else h=[],l.push((f,d,m,v,g,p,_)=>{h.push(u(f,d,m,v,g,p,_))});return this[s].apply(this,l),h};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(){const l=Array.prototype.slice.call(arguments),u=l.pop(),h=[];return l.push((f,d,m,v,g,p,_)=>{u(f,d,m,v,g,p,_)&&h.push(f)}),this[s].apply(this,l),h};const c="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[c]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new Be(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new Be(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let u,h;l.length===2?(u=l[0],h=l[1],l=[]):l.length===3?(u=l[1],h=l[2],l=[l[0]]):l.length===4&&(u=l[2],h=l[3],l=[l[0],l[1]]);let f=h;return l.push((d,m,v,g,p,_,y)=>{f=u(f,d,m,v,g,p,_,y)}),this[s].apply(this,l),f}}function gO(r,e){const{name:t,type:n,direction:i}=e,s="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(c,l,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return u=c,N1(!0,this,n,u);if(arguments.length===2){c=""+c,u=l;const h=this._nodes.get(c);if(typeof h>"u")throw new Ie(`Graph.${s}: could not find the "${c}" node in the graph.`);return Wm(!0,this.multi,n==="mixed"?this.type:n,i,h,u)}if(arguments.length===3){c=""+c,l=""+l;const h=this._nodes.get(c);if(!h)throw new Ie(`Graph.${s}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new Ie(`Graph.${s}: could not find the "${l}" target node in the graph.`);return Xm(!0,n,this.multi,i,h,l,u)}throw new Be(`Graph.${s}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();return c.push((h,f,d,m,v,g,p)=>l(h,f,d,m,v,g,p)),!!this[s].apply(this,c)};const a="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();return c.push((h,f,d,m,v,g,p)=>!l(h,f,d,m,v,g,p)),!this[s].apply(this,c)}}function vO(r,e){const{name:t,type:n,direction:i}=e,s=t.slice(0,-1)+"Entries";r.prototype[s]=function(o,a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ri.empty();if(!arguments.length)return lO(this,n);if(arguments.length===1){o=""+o;const c=this._nodes.get(o);if(!c)throw new Ie(`Graph.${s}: could not find the "${o}" node in the graph.`);return hO(n,i,c)}if(arguments.length===2){o=""+o,a=""+a;const c=this._nodes.get(o);if(!c)throw new Ie(`Graph.${s}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new Ie(`Graph.${s}: could not find the "${a}" target node in the graph.`);return dO(n,i,c,a)}throw new Be(`Graph.${s}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function _O(r){iO.forEach(e=>{pO(r,e),mO(r,e),gO(r,e),vO(r,e)})}const yO=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function mh(){this.A=null,this.B=null}mh.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};mh.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function Aa(r,e,t,n,i){for(const s in n){const o=n[s],a=o.source,c=o.target,l=a===t?c:a;if(e&&e.has(l.key))continue;const u=i(l.key,l.attributes);if(r&&u)return l.key}}function qm(r,e,t,n,i){if(e!=="mixed"){if(e==="undirected")return Aa(r,null,n,n.undirected,i);if(typeof t=="string")return Aa(r,null,n,n[t],i)}const s=new mh;let o;if(e!=="undirected"){if(t!=="out"){if(o=Aa(r,null,n,n.in,i),r&&o)return o;s.wrap(n.in)}if(t!=="in"){if(o=Aa(r,s,n,n.out,i),r&&o)return o;s.wrap(n.out)}}if(e!=="directed"&&(o=Aa(r,s,n,n.undirected,i),r&&o))return o}function xO(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return qm(!1,r,e,t,function(i){n.push(i)}),n}function Ca(r,e,t){const n=Object.keys(t),i=n.length;let s=0;return new ri(function(){let a=null;do{if(s>=i)return r&&r.wrap(t),{done:!0};const c=t[n[s++]],l=c.source,u=c.target;if(a=l===e?u:l,r&&r.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function bO(r,e,t){if(r!=="mixed"){if(r==="undirected")return Ca(null,t,t.undirected);if(typeof e=="string")return Ca(null,t,t[e])}let n=ri.empty();const i=new mh;return r!=="undirected"&&(e!=="out"&&(n=rr(n,Ca(i,t,t.in))),e!=="in"&&(n=rr(n,Ca(i,t,t.out)))),r!=="directed"&&(n=rr(n,Ca(i,t,t.undirected))),n}function wO(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];s=""+s;const o=this._nodes.get(s);if(typeof o>"u")throw new Ie(`Graph.${t}: could not find the "${s}" node in the graph.`);return xO(n==="mixed"?this.type:n,i,o)}}function SO(r,e){const{name:t,type:n,direction:i}=e,s="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(l,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;l=""+l;const h=this._nodes.get(l);if(typeof h>"u")throw new Ie(`Graph.${s}: could not find the "${l}" node in the graph.`);qm(!1,n==="mixed"?this.type:n,i,h,u)};const o="map"+t[0].toUpperCase()+t.slice(1);r.prototype[o]=function(l,u){const h=[];return this[s](l,(f,d)=>{h.push(u(f,d))}),h};const a="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[a]=function(l,u){const h=[];return this[s](l,(f,d)=>{u(f,d)&&h.push(f)}),h};const c="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[c]=function(l,u,h){if(arguments.length<3)throw new Be(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let f=h;return this[s](l,(d,m)=>{f=u(f,d,m)}),f}}function EO(r,e){const{name:t,type:n,direction:i}=e,s=t[0].toUpperCase()+t.slice(1,-1),o="find"+s;r.prototype[o]=function(l,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;l=""+l;const h=this._nodes.get(l);if(typeof h>"u")throw new Ie(`Graph.${o}: could not find the "${l}" node in the graph.`);return qm(!0,n==="mixed"?this.type:n,i,h,u)};const a="some"+s;r.prototype[a]=function(l,u){return!!this[o](l,u)};const c="every"+s;r.prototype[c]=function(l,u){return!this[o](l,(f,d)=>!u(f,d))}}function MO(r,e){const{name:t,type:n,direction:i}=e,s=t.slice(0,-1)+"Entries";r.prototype[s]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ri.empty();o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new Ie(`Graph.${s}: could not find the "${o}" node in the graph.`);return bO(n==="mixed"?this.type:n,i,a)}}function TO(r){yO.forEach(e=>{wO(r,e),SO(r,e),EO(r,e),MO(r,e)})}function $l(r,e,t,n,i){const s=n._nodes.values(),o=n.type;let a,c,l,u,h,f;for(;a=s.next(),a.done!==!0;){let d=!1;if(c=a.value,o!=="undirected"){u=c.out;for(l in u){h=u[l];do f=h.target,d=!0,i(c.key,f.key,c.attributes,f.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}if(o!=="directed"){u=c.undirected;for(l in u)if(!(e&&c.key>l)){h=u[l];do f=h.target,f.key!==l&&(f=h.source),d=!0,i(c.key,f.key,c.attributes,f.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}t&&!d&&i(c.key,null,c.attributes,null,null,null,null)}}function AO(r,e){const t={key:r};return R1(e.attributes)||(t.attributes=Jt({},e.attributes)),t}function CO(r,e,t){const n={key:e,source:t.source.key,target:t.target.key};return R1(t.attributes)||(n.attributes=Jt({},t.attributes)),r==="mixed"&&t.undirected&&(n.undirected=!0),n}function RO(r){if(!cn(r))throw new Be('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new Be("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!cn(r.attributes)||r.attributes===null))throw new Be("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function PO(r){if(!cn(r))throw new Be('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new Be("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new Be("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!cn(r.attributes)||r.attributes===null))throw new Be("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new Be("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const LO=IU(),DO=new Set(["directed","undirected","mixed"]),I_=new Set(["domain","_events","_eventsCount","_maxListeners"]),IO=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],UO={allowSelfLoops:!0,multi:!1,type:"mixed"};function OO(r,e,t){if(t&&!cn(t))throw new Be(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new Xe(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function U_(r,e,t){const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function F1(r,e,t,n,i,s,o,a){if(!n&&r.type==="undirected")throw new Xe(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new Xe(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!cn(a))throw new Be(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`);if(s=""+s,o=""+o,a=a||{},!r.allowSelfLoops&&s===o)throw new Xe(`Graph.${e}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=r._nodes.get(s),l=r._nodes.get(o);if(!c)throw new Ie(`Graph.${e}: source node "${s}" not found.`);if(!l)throw new Ie(`Graph.${e}: target node "${o}" not found.`);const u={key:null,undirected:n,source:s,target:o,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new Xe(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!r.multi&&(n?typeof c.undirected[o]<"u":typeof c.out[o]<"u"))throw new Xe(`Graph.${e}: an edge linking "${s}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const h=new zo(n,i,c,l,a);r._edges.set(i,h);const f=s===o;return n?(c.undirectedDegree++,l.undirectedDegree++,f&&(c.undirectedLoops++,r._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,f&&(c.directedLoops++,r._directedSelfLoopCount++)),r.multi?h.attachMulti():h.attach(),n?r._undirectedSize++:r._directedSize++,u.key=i,r.emit("edgeAdded",u),i}function NO(r,e,t,n,i,s,o,a,c){if(!n&&r.type==="undirected")throw new Xe(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new Xe(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(c){if(typeof a!="function")throw new Be(`Graph.${e}: invalid updater function. Expecting a function but got "${a}"`)}else if(!cn(a))throw new Be(`Graph.${e}: invalid attributes. Expecting an object but got "${a}"`)}s=""+s,o=""+o;let l;if(c&&(l=a,a=void 0),!r.allowSelfLoops&&s===o)throw new Xe(`Graph.${e}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=r._nodes.get(s),h=r._nodes.get(o),f,d;if(!t&&(f=r._edges.get(i),f)){if((f.source.key!==s||f.target.key!==o)&&(!n||f.source.key!==o||f.target.key!==s))throw new Xe(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${s}" source & "${o}" target vs. ("${f.source.key}", "${f.target.key}").`);d=f}if(!d&&!r.multi&&u&&(d=n?u.undirected[o]:u.out[o]),d){const _=[d.key,!1,!1,!1];if(c?!l:!a)return _;if(c){const y=d.attributes;d.attributes=l(y),r.emit("edgeAttributesUpdated",{type:"replace",key:d.key,attributes:d.attributes})}else Jt(d.attributes,a),r.emit("edgeAttributesUpdated",{type:"merge",key:d.key,attributes:d.attributes,data:a});return _}a=a||{},c&&l&&(a=l(a));const m={key:null,undirected:n,source:s,target:o,attributes:a};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new Xe(`Graph.${e}: the "${i}" edge already exists in the graph.`);let v=!1,g=!1;u||(u=U_(r,s,{}),v=!0,s===o&&(h=u,g=!0)),h||(h=U_(r,o,{}),g=!0),f=new zo(n,i,u,h,a),r._edges.set(i,f);const p=s===o;return n?(u.undirectedDegree++,h.undirectedDegree++,p&&(u.undirectedLoops++,r._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,p&&(u.directedLoops++,r._directedSelfLoopCount++)),r.multi?f.attachMulti():f.attach(),n?r._undirectedSize++:r._directedSize++,m.key=i,r.emit("edgeAdded",m),[i,!0,v,g]}function uo(r,e){r._edges.delete(e.key);const{source:t,target:n,attributes:i}=e,s=e.undirected,o=t===n;s?(t.undirectedDegree--,n.undirectedDegree--,o&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,o&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),s?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:i,source:t.key,target:n.key,undirected:s})}class St extends TU.EventEmitter{constructor(e){if(super(),e=Jt({},UO,e),typeof e.multi!="boolean")throw new Be(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!DO.has(e.type))throw new Be(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new Be(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?P1:e.type==="directed"?L1:D1;$n(this,"NodeDataClass",t);const n="geid_"+LO()+"_";let i=0;const s=()=>{let o;do o=n+i++;while(this._edges.has(o));return o};$n(this,"_attributes",{}),$n(this,"_nodes",new Map),$n(this,"_edges",new Map),$n(this,"_directedSize",0),$n(this,"_undirectedSize",0),$n(this,"_directedSelfLoopCount",0),$n(this,"_undirectedSelfLoopCount",0),$n(this,"_edgeKeyGenerator",s),$n(this,"_options",e),I_.forEach(o=>$n(this,o,this[o])),di(this,"order",()=>this._nodes.size),di(this,"size",()=>this._edges.size),di(this,"directedSize",()=>this._directedSize),di(this,"undirectedSize",()=>this._undirectedSize),di(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),di(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),di(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),di(this,"multi",this._options.multi),di(this,"type",this._options.type),di(this,"allowSelfLoops",this._options.allowSelfLoops),di(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new Be(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new Be(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new Be(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new Xe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new Ie(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||void 0;if(i)return i.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new Xe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new Ie(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=n.undirected&&n.undirected[t]||void 0;if(i)return i.key}edge(e,t){if(this.multi)throw new Xe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new Ie(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new Ie(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new Ie(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new Ie(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new Ie(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new Ie(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=n.source.key,s=n.target.key;if(e===i)return s;if(e===s)return i;throw new Ie(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${s}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new Ie(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new Ie(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new Ie(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new Ie(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return OO(this,e,t).key}mergeNode(e,t){if(t&&!cn(t))throw new Be(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(Jt(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new Be(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const s=n.attributes;n.attributes=t(s),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new Ie(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in t.out){n=t.out[i];do uo(this,n),n=n.next;while(n)}for(const i in t.in){n=t.in[i];do uo(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in t.undirected){n=t.undirected[i];do uo(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(t=ii(this,n,i,this.type),!t)throw new Ie(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new Ie(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return uo(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new Xe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Xe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const n=ii(this,e,t,"directed");if(!n)throw new Ie(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return uo(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new Xe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new Xe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=ii(this,e,t,"undirected");if(!n)throw new Ie(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return uo(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new Be("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!cn(e))throw new Be("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!cn(e))throw new Be("Graph.mergeAttributes: provided attributes are not a plain object.");return Jt(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new Be("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new Be("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!D_(t))throw new Be("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,s;for(;i=n.next(),i.done!==!0;)s=i.value,s.attributes=e(s.key,s.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new Be("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!D_(t))throw new Be("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,s,o,a;for(;i=n.next(),i.done!==!0;)s=i.value,o=s.source,a=s.target,s.attributes=e(s.key,s.attributes,o.key,a.key,o.attributes,a.attributes,s.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new Be("Graph.forEachAdjacencyEntry: expecting a callback.");$l(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new Be("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");$l(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new Be("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");$l(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new Be("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");$l(!1,!0,!0,this,e)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):C1(this._nodes.keys(),this._nodes.size)}forEachNode(e){if(typeof e!="function")throw new Be("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new Be("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new Be("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,i;const s=new Array(this.order);let o=0;for(;n=t.next(),n.done!==!0;)i=n.value,s[o++]=e(i.key,i.attributes);return s}someNode(e){if(typeof e!="function")throw new Be("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new Be("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new Be("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,i;const s=[];for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&s.push(i.key);return s}reduceNodes(e,t){if(typeof e!="function")throw new Be("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new Be("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const i=this._nodes.values();let s,o;for(;s=i.next(),s.done!==!0;)o=s.value,n=e(n,o.key,o.attributes);return n}nodeEntries(){const e=this._nodes.values();return new ri(()=>{const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,s)=>{e[t++]=AO(s,i)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((i,s)=>{n[t++]=CO(this.type,s,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof St)return e.forEachNode((c,l)=>{t?this.mergeNode(c,l):this.addNode(c,l)}),e.forEachEdge((c,l,u,h,f,d,m)=>{t?m?this.mergeUndirectedEdgeWithKey(c,u,h,l):this.mergeDirectedEdgeWithKey(c,u,h,l):m?this.addUndirectedEdgeWithKey(c,u,h,l):this.addDirectedEdgeWithKey(c,u,h,l)}),this;if(!cn(e))throw new Be("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!cn(e.attributes))throw new Be("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,s,o,a;if(e.nodes){if(s=e.nodes,!Array.isArray(s))throw new Be("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=s.length;n<i;n++){o=s[n],RO(o);const{key:c,attributes:l}=o;t?this.mergeNode(c,l):this.addNode(c,l)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),s=e.edges,!Array.isArray(s))throw new Be("Graph.import: invalid edges. Expecting an array.");for(n=0,i=s.length;n<i;n++){a=s[n],PO(a);const{source:l,target:u,attributes:h,undirected:f=c}=a;let d;"key"in a?(d=t?f?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:f?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,d.call(this,a.key,l,u,h)):(d=t?f?this.mergeUndirectedEdge:this.mergeDirectedEdge:f?this.addUndirectedEdge:this.addDirectedEdge,d.call(this,l,u,h))}}return this}nullCopy(e){const t=new St(Jt({},this._options,e));return t.replaceAttributes(Jt({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const s=Jt({},n.attributes);n=new t.NodeDataClass(i,s),t._nodes.set(i,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new Xe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new Xe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new Xe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let i,s;for(;i=n.next(),i.done!==!0;)s=i.value,F1(t,"copy",!1,s.undirected,s.key,s.source.key,s.target.key,Jt({},s.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((s,o)=>{e[o]=s.attributes});const t={},n={};this._edges.forEach((s,o)=>{const a=s.undirected?"--":"->";let c="",l=s.source.key,u=s.target.key,h;s.undirected&&l>u&&(h=l,l=u,u=h);const f=`(${l})${a}(${u})`;o.startsWith("geid_")?this.multi&&(typeof n[f]>"u"?n[f]=0:n[f]++,c+=`${n[f]}. `):c+=`[${o}]: `,c+=f,t[c]=s.attributes});const i={};for(const s in this)this.hasOwnProperty(s)&&!I_.has(s)&&typeof this[s]!="function"&&typeof s!="symbol"&&(i[s]=this[s]);return i.attributes=this._attributes,i.nodes=e,i.edges=t,$n(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(St.prototype[Symbol.for("nodejs.util.inspect.custom")]=St.prototype.inspect);IO.forEach(r=>{["add","merge","update"].forEach(e=>{const t=r.name(e),n=e==="add"?F1:NO;r.generateKey?St.prototype[t]=function(i,s,o){return n(this,t,!0,(r.type||this.type)==="undirected",null,i,s,o,e==="update")}:St.prototype[t]=function(i,s,o,a){return n(this,t,!1,(r.type||this.type)==="undirected",i,s,o,a,e==="update")}})});XU(St);nO(St);_O(St);TO(St);class k1 extends St{constructor(e){const t=Jt({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new Be("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new Be('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class z1 extends St{constructor(e){const t=Jt({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new Be("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new Be('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class B1 extends St{constructor(e){const t=Jt({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Be("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class G1 extends St{constructor(e){const t=Jt({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Be("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new Be('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class V1 extends St{constructor(e){const t=Jt({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new Be("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new Be('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Bo(r){r.from=function(e,t){const n=Jt({},e.options,t),i=new r(n);return i.import(e),i}}Bo(St);Bo(k1);Bo(z1);Bo(B1);Bo(G1);Bo(V1);St.Graph=St;St.DirectedGraph=k1;St.UndirectedGraph=z1;St.MultiGraph=B1;St.MultiDirectedGraph=G1;St.MultiUndirectedGraph=V1;St.InvalidArgumentsGraphError=Be;St.NotFoundGraphError=Ie;St.UsageGraphError=Xe;const Fc=new G,Ym=new G,FO=new G;function kO(r,e,t){const n=Fc.setFromMatrixPosition(r.matrixWorld);n.project(e);const i=t.width/2,s=t.height/2;return[n.x*i+i,-(n.y*s)+s]}function zO(r,e){const t=Fc.setFromMatrixPosition(r.matrixWorld),n=Ym.setFromMatrixPosition(e.matrixWorld),i=t.sub(n),s=e.getWorldDirection(FO);return i.angleTo(s)>Math.PI/2}function BO(r,e,t,n){const i=Fc.setFromMatrixPosition(r.matrixWorld),s=i.clone();s.project(e),t.setFromCamera(s,e);const o=t.intersectObjects(n,!0);if(o.length){const a=o[0].distance;return i.distanceTo(t.ray.origin)<a}return!0}function GO(r,e){if(e instanceof Ms)return e.zoom;if(e instanceof Zt){const t=Fc.setFromMatrixPosition(r.matrixWorld),n=Ym.setFromMatrixPosition(e.matrixWorld),i=e.fov*Math.PI/180,s=t.distanceTo(n);return 1/(2*Math.tan(i/2)*s)}else return 1}function VO(r,e,t){if(e instanceof Zt||e instanceof Ms){const n=Fc.setFromMatrixPosition(r.matrixWorld),i=Ym.setFromMatrixPosition(e.matrixWorld),s=n.distanceTo(i),o=(t[1]-t[0])/(e.far-e.near),a=t[1]-o*e.far;return Math.round(o*s+a)}}const Mp=r=>Math.abs(r)<1e-10?0:r;function H1(r,e,t=""){let n="matrix3d(";for(let i=0;i!==16;i++)n+=Mp(e[i]*r.elements[i])+(i!==15?",":")");return t+n}const HO=(r=>e=>H1(e,r))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),WO=(r=>(e,t)=>H1(e,r(t),"translate(-50%,-50%)"))(r=>[1/r,1/r,1/r,1,-1/r,-1/r,-1/r,-1,1/r,1/r,1/r,1,1,1,1,1]);function XO(r){return r&&typeof r=="object"&&"current"in r}const jm=q.forwardRef(({children:r,eps:e=.001,style:t,className:n,prepend:i,center:s,fullscreen:o,portal:a,distanceFactor:c,sprite:l=!1,transform:u=!1,occlude:h,onOcclude:f,castShadow:d,receiveShadow:m,material:v,geometry:g,zIndexRange:p=[16777271,0],calculatePosition:_=kO,as:y="div",wrapperClass:x,pointerEvents:b="auto",...w},S)=>{const{gl:M,camera:E,scene:T,size:L,raycaster:P,events:A,viewport:z}=Kt(),[V]=q.useState(()=>document.createElement(y)),N=q.useRef(),C=q.useRef(null),O=q.useRef(0),k=q.useRef([0,0]),U=q.useRef(null),R=q.useRef(null),F=(a==null?void 0:a.current)||A.connected||M.domElement.parentNode,H=q.useRef(null),Y=q.useRef(!1),J=q.useMemo(()=>h&&h!=="blending"||Array.isArray(h)&&h.length&&XO(h[0]),[h]);q.useLayoutEffect(()=>{const me=M.domElement;h&&h==="blending"?(me.style.zIndex=`${Math.floor(p[0]/2)}`,me.style.position="absolute",me.style.pointerEvents="none"):(me.style.zIndex=null,me.style.position=null,me.style.pointerEvents=null)},[h]),q.useLayoutEffect(()=>{if(C.current){const me=N.current=Kw.createRoot(V);if(T.updateMatrixWorld(),u)V.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const te=_(C.current,E,L);V.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${te[0]}px,${te[1]}px,0);transform-origin:0 0;`}return F&&(i?F.prepend(V):F.appendChild(V)),()=>{F&&F.removeChild(V),me.unmount()}}},[F,u]),q.useLayoutEffect(()=>{x&&(V.className=x)},[x]);const ie=q.useMemo(()=>u?{position:"absolute",top:0,left:0,width:L.width,height:L.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:s?"translate3d(-50%,-50%,0)":"none",...o&&{top:-L.height/2,left:-L.width/2,width:L.width,height:L.height},...t},[t,s,o,L,u]),ne=q.useMemo(()=>({position:"absolute",pointerEvents:b}),[b]);q.useLayoutEffect(()=>{if(Y.current=!1,u){var me;(me=N.current)==null||me.render(q.createElement("div",{ref:U,style:ie},q.createElement("div",{ref:R,style:ne},q.createElement("div",{ref:S,className:n,style:t,children:r}))))}else{var te;(te=N.current)==null||te.render(q.createElement("div",{ref:S,style:ie,className:n,children:r}))}});const ee=q.useRef(!0);uh(me=>{if(C.current){E.updateMatrixWorld(),C.current.updateWorldMatrix(!0,!1);const te=u?k.current:_(C.current,E,L);if(u||Math.abs(O.current-E.zoom)>e||Math.abs(k.current[0]-te[0])>e||Math.abs(k.current[1]-te[1])>e){const D=zO(C.current,E);let Q=!1;J&&(Array.isArray(h)?Q=h.map(ye=>ye.current):h!=="blending"&&(Q=[T]));const j=ee.current;if(Q){const ye=BO(C.current,E,P,Q);ee.current=ye&&!D}else ee.current=!D;j!==ee.current&&(f?f(!ee.current):V.style.display=ee.current?"block":"none");const K=Math.floor(p[0]/2),W=h?J?[p[0],K]:[K-1,0]:p;if(V.style.zIndex=`${VO(C.current,E,W)}`,u){const[ye,re]=[L.width/2,L.height/2],fe=E.projectionMatrix.elements[5]*re,{isOrthographicCamera:xe,top:ce,left:Pe,bottom:B,right:I}=E,$=HO(E.matrixWorldInverse),he=xe?`scale(${fe})translate(${Mp(-(I+Pe)/2)}px,${Mp((ce+B)/2)}px)`:`translateZ(${fe}px)`;let de=C.current.matrixWorld;l&&(de=E.matrixWorldInverse.clone().transpose().copyPosition(de).scale(C.current.scale),de.elements[3]=de.elements[7]=de.elements[11]=0,de.elements[15]=1),V.style.width=L.width+"px",V.style.height=L.height+"px",V.style.perspective=xe?"":`${fe}px`,U.current&&R.current&&(U.current.style.transform=`${he}${$}translate(${ye}px,${re}px)`,R.current.style.transform=WO(de,1/((c||10)/400)))}else{const ye=c===void 0?1:GO(C.current,E)*c;V.style.transform=`translate3d(${te[0]}px,${te[1]}px,0) scale(${ye})`}k.current=te,O.current=E.zoom}}if(!J&&H.current&&!Y.current)if(u){if(U.current){const te=U.current.children[0];if(te!=null&&te.clientWidth&&te!=null&&te.clientHeight){const{isOrthographicCamera:D}=E;if(D||g)w.scale&&(Array.isArray(w.scale)?w.scale instanceof G?H.current.scale.copy(w.scale.clone().divideScalar(1)):H.current.scale.set(1/w.scale[0],1/w.scale[1],1/w.scale[2]):H.current.scale.setScalar(1/w.scale));else{const Q=(c||10)/400,j=te.clientWidth*Q,K=te.clientHeight*Q;H.current.scale.set(j,K,1)}Y.current=!0}}}else{const te=V.children[0];if(te!=null&&te.clientWidth&&te!=null&&te.clientHeight){const D=1/z.factor,Q=te.clientWidth*D,j=te.clientHeight*D;H.current.scale.set(Q,j,1),Y.current=!0}H.current.lookAt(me.camera.position)}});const ge=q.useMemo(()=>({vertexShader:u?void 0:`
|
|
/*
|
|
This shader is from the THREE's SpriteMaterial.
|
|
We need to turn the backing plane into a Sprite
|
|
(make it always face the camera) if "transfrom"
|
|
is false.
|
|
*/
|
|
#include <common>
|
|
|
|
void main() {
|
|
vec2 center = vec2(0., 1.);
|
|
float rotation = 0.0;
|
|
|
|
// This is somewhat arbitrary, but it seems to work well
|
|
// Need to figure out how to derive this dynamically if it even matters
|
|
float size = 0.03;
|
|
|
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
vec2 scale;
|
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
}
|
|
`,fragmentShader:`
|
|
void main() {
|
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
}
|
|
`}),[u]);return q.createElement("group",Tc({},w,{ref:C}),h&&!J&&q.createElement("mesh",{castShadow:d,receiveShadow:m,ref:H},g||q.createElement("planeGeometry",null),v||q.createElement("shaderMaterial",{side:Dt,vertexShader:ge.vertexShader,fragmentShader:ge.fragmentShader})))});function ds(r,e="pointer",t="auto",n=document.body){q.useEffect(()=>{if(r)return n.style.cursor=e,()=>void(n.style.cursor=t)},[r])}let $m=zc();const Je=r=>kc(r,$m);let Zm=zc();Je.write=r=>kc(r,Zm);let gh=zc();Je.onStart=r=>kc(r,gh);let Km=zc();Je.onFrame=r=>kc(r,Km);let Jm=zc();Je.onFinish=r=>kc(r,Jm);let Eo=[];Je.setTimeout=(r,e)=>{let t=Je.now()+e,n=()=>{let s=Eo.findIndex(o=>o.cancel==n);~s&&Eo.splice(s,1),Er-=~s?1:0},i={time:t,handler:r,cancel:n};return Eo.splice(W1(t),0,i),Er+=1,X1(),i};let W1=r=>~(~Eo.findIndex(e=>e.time>r)||~Eo.length);Je.cancel=r=>{gh.delete(r),Km.delete(r),Jm.delete(r),$m.delete(r),Zm.delete(r)};Je.sync=r=>{Tp=!0,Je.batchedUpdates(r),Tp=!1};Je.throttle=r=>{let e;function t(){try{r(...e)}finally{e=null}}function n(...i){e=i,Je.onStart(t)}return n.handler=r,n.cancel=()=>{gh.delete(t),e=null},n};let Qm=typeof window<"u"?window.requestAnimationFrame:()=>{};Je.use=r=>Qm=r;Je.now=typeof performance<"u"?()=>performance.now():Date.now;Je.batchedUpdates=r=>r();Je.catch=console.error;Je.frameLoop="always";Je.advance=()=>{Je.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):Y1()};let Sr=-1,Er=0,Tp=!1;function kc(r,e){Tp?(e.delete(r),r(0)):(e.add(r),X1())}function X1(){Sr<0&&(Sr=0,Je.frameLoop!=="demand"&&Qm(q1))}function qO(){Sr=-1}function q1(){~Sr&&(Qm(q1),Je.batchedUpdates(Y1))}function Y1(){let r=Sr;Sr=Je.now();let e=W1(Sr);if(e&&(j1(Eo.splice(0,e),t=>t.handler()),Er-=e),!Er){qO();return}gh.flush(),$m.flush(r?Math.min(64,Sr-r):16.667),Km.flush(),Zm.flush(),Jm.flush()}function zc(){let r=new Set,e=r;return{add(t){Er+=e==r&&!r.has(t)?1:0,r.add(t)},delete(t){return Er-=e==r&&r.has(t)?1:0,r.delete(t)},flush(t){e.size&&(r=new Set,Er-=e.size,j1(e,n=>n(t)&&r.add(n)),Er+=r.size,e=r)}}}function j1(r,e){r.forEach(t=>{try{e(t)}catch(n){Je.catch(n)}})}function Ap(){}const YO=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,configurable:!0}),Oe={arr:Array.isArray,obj:r=>!!r&&r.constructor.name==="Object",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",und:r=>r===void 0};function Ji(r,e){if(Oe.arr(r)){if(!Oe.arr(e)||r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}return r===e}const _t=(r,e)=>r.forEach(e);function or(r,e,t){if(Oe.arr(r)){for(let n=0;n<r.length;n++)e.call(t,r[n],`${n}`);return}for(const n in r)r.hasOwnProperty(n)&&e.call(t,r[n],n)}const ni=r=>Oe.und(r)?[]:Oe.arr(r)?r:[r];function Xa(r,e){if(r.size){const t=Array.from(r);r.clear(),_t(t,e)}}const ka=(r,...e)=>Xa(r,t=>t(...e)),eg=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent);let tg,$1,Rr=null,Z1=!1,ng=Ap;const jO=r=>{r.to&&($1=r.to),r.now&&(Je.now=r.now),r.colors!==void 0&&(Rr=r.colors),r.skipAnimation!=null&&(Z1=r.skipAnimation),r.createStringInterpolator&&(tg=r.createStringInterpolator),r.requestAnimationFrame&&Je.use(r.requestAnimationFrame),r.batchedUpdates&&(Je.batchedUpdates=r.batchedUpdates),r.willAdvance&&(ng=r.willAdvance),r.frameLoop&&(Je.frameLoop=r.frameLoop)};var Fi=Object.freeze({__proto__:null,get createStringInterpolator(){return tg},get to(){return $1},get colors(){return Rr},get skipAnimation(){return Z1},get willAdvance(){return ng},assign:jO});const qa=new Set;let ti=[],_d=[],Mu=0;const vh={get idle(){return!qa.size&&!ti.length},start(r){Mu>r.priority?(qa.add(r),Je.onStart($O)):(K1(r),Je(Cp))},advance:Cp,sort(r){if(Mu)Je.onFrame(()=>vh.sort(r));else{const e=ti.indexOf(r);~e&&(ti.splice(e,1),J1(r))}},clear(){ti=[],qa.clear()}};function $O(){qa.forEach(K1),qa.clear(),Je(Cp)}function K1(r){ti.includes(r)||J1(r)}function J1(r){ti.splice(ZO(ti,e=>e.priority>r.priority),0,r)}function Cp(r){const e=_d;for(let t=0;t<ti.length;t++){const n=ti[t];Mu=n.priority,n.idle||(ng(n),n.advance(r),n.idle||e.push(n))}return Mu=0,_d=ti,_d.length=0,ti=e,ti.length>0}function ZO(r,e){const t=r.findIndex(e);return t<0?r.length:t}const KO={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199},_i="[-+]?\\d*\\.?\\d+",Tu=_i+"%";function _h(...r){return"\\(\\s*("+r.join(")\\s*,\\s*(")+")\\s*\\)"}const JO=new RegExp("rgb"+_h(_i,_i,_i)),QO=new RegExp("rgba"+_h(_i,_i,_i,_i)),e3=new RegExp("hsl"+_h(_i,Tu,Tu)),t3=new RegExp("hsla"+_h(_i,Tu,Tu,_i)),n3=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,i3=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,r3=/^#([0-9a-fA-F]{6})$/,s3=/^#([0-9a-fA-F]{8})$/;function o3(r){let e;return typeof r=="number"?r>>>0===r&&r>=0&&r<=4294967295?r:null:(e=r3.exec(r))?parseInt(e[1]+"ff",16)>>>0:Rr&&Rr[r]!==void 0?Rr[r]:(e=JO.exec(r))?(ho(e[1])<<24|ho(e[2])<<16|ho(e[3])<<8|255)>>>0:(e=QO.exec(r))?(ho(e[1])<<24|ho(e[2])<<16|ho(e[3])<<8|F_(e[4]))>>>0:(e=n3.exec(r))?parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+"ff",16)>>>0:(e=s3.exec(r))?parseInt(e[1],16)>>>0:(e=i3.exec(r))?parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+e[4]+e[4],16)>>>0:(e=e3.exec(r))?(O_(N_(e[1]),Zl(e[2]),Zl(e[3]))|255)>>>0:(e=t3.exec(r))?(O_(N_(e[1]),Zl(e[2]),Zl(e[3]))|F_(e[4]))>>>0:null}function yd(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*(2/3-t)*6:r}function O_(r,e,t){const n=t<.5?t*(1+e):t+e-t*e,i=2*t-n,s=yd(i,n,r+1/3),o=yd(i,n,r),a=yd(i,n,r-1/3);return Math.round(s*255)<<24|Math.round(o*255)<<16|Math.round(a*255)<<8}function ho(r){const e=parseInt(r,10);return e<0?0:e>255?255:e}function N_(r){return(parseFloat(r)%360+360)%360/360}function F_(r){const e=parseFloat(r);return e<0?0:e>1?255:Math.round(e*255)}function Zl(r){const e=parseFloat(r);return e<0?0:e>100?1:e/100}function k_(r){let e=o3(r);if(e===null)return r;e=e||0;let t=(e&4278190080)>>>24,n=(e&16711680)>>>16,i=(e&65280)>>>8,s=(e&255)/255;return`rgba(${t}, ${n}, ${i}, ${s})`}const vc=(r,e,t)=>{if(Oe.fun(r))return r;if(Oe.arr(r))return vc({range:r,output:e,extrapolate:t});if(Oe.str(r.output[0]))return tg(r);const n=r,i=n.output,s=n.range||[0,1],o=n.extrapolateLeft||n.extrapolate||"extend",a=n.extrapolateRight||n.extrapolate||"extend",c=n.easing||(l=>l);return l=>{const u=c3(l,s);return a3(l,s[u],s[u+1],i[u],i[u+1],c,o,a,n.map)}};function a3(r,e,t,n,i,s,o,a,c){let l=c?c(r):r;if(l<e){if(o==="identity")return l;o==="clamp"&&(l=e)}if(l>t){if(a==="identity")return l;a==="clamp"&&(l=t)}return n===i?n:e===t?r<=e?n:i:(e===-1/0?l=-l:t===1/0?l=l-e:l=(l-e)/(t-e),l=s(l),n===-1/0?l=-l:i===1/0?l=l+n:l=l*(i-n)+n,l)}function c3(r,e){for(var t=1;t<e.length-1&&!(e[t]>=r);++t);return t-1}const l3={linear:r=>r};function Rp(){return Rp=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Rp.apply(this,arguments)}const Io=Symbol.for("FluidValue.get"),ws=Symbol.for("FluidValue.observers"),Pi=r=>!!(r&&r[Io]),Jn=r=>r&&r[Io]?r[Io]():r,z_=r=>r[ws]||null;function u3(r,e){r.eventObserved?r.eventObserved(e):r(e)}function Au(r,e){let t=r[ws];t&&t.forEach(n=>{u3(n,e)})}class h3{constructor(e){if(this[Io]=void 0,this[ws]=void 0,!e&&!(e=this.get))throw Error("Unknown getter");f3(this,e)}}const f3=(r,e)=>Q1(r,Io,e);function Bc(r,e){if(r[Io]){let t=r[ws];t||Q1(r,ws,t=new Set),t.has(e)||(t.add(e),r.observerAdded&&r.observerAdded(t.size,e))}return e}function Cu(r,e){let t=r[ws];if(t&&t.has(e)){const n=t.size-1;n?t.delete(e):r[ws]=null,r.observerRemoved&&r.observerRemoved(n,e)}}const Q1=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,configurable:!0}),du=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,d3=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,B_=new RegExp(`(${du.source})(%|[a-z]+)`,"i"),p3=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,yh=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/,ew=r=>{const[e,t]=m3(r);if(!e||eg())return r;const n=window.getComputedStyle(document.documentElement).getPropertyValue(e);if(n)return n.trim();if(t&&t.startsWith("--")){const i=window.getComputedStyle(document.documentElement).getPropertyValue(t);return i||r}else{if(t&&yh.test(t))return ew(t);if(t)return t}return r},m3=r=>{const e=yh.exec(r);if(!e)return[,];const[,t,n]=e;return[t,n]};let xd;const g3=(r,e,t,n,i)=>`rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)}, ${i})`,tw=r=>{xd||(xd=Rr?new RegExp(`(${Object.keys(Rr).join("|")})(?!\\w)`,"g"):/^\b$/);const e=r.output.map(s=>Jn(s).replace(yh,ew).replace(d3,k_).replace(xd,k_)),t=e.map(s=>s.match(du).map(Number)),i=t[0].map((s,o)=>t.map(a=>{if(!(o in a))throw Error('The arity of each "output" value must be equal');return a[o]})).map(s=>vc(Rp({},r,{output:s})));return s=>{var o;const a=!B_.test(e[0])&&((o=e.find(l=>B_.test(l)))==null?void 0:o.replace(du,""));let c=0;return e[0].replace(du,()=>`${i[c++](s)}${a||""}`).replace(p3,g3)}},ig="react-spring: ",nw=r=>{const e=r;let t=!1;if(typeof e!="function")throw new TypeError(`${ig}once requires a function parameter`);return(...n)=>{t||(e(...n),t=!0)}},v3=nw(console.warn);function _3(){v3(`${ig}The "interpolate" function is deprecated in v9 (use "to" instead)`)}const y3=nw(console.warn);function x3(){y3(`${ig}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`)}function xh(r){return Oe.str(r)&&(r[0]=="#"||/\d/.test(r)||!eg()&&yh.test(r)||r in(Rr||{}))}const rg=eg()?q.useEffect:q.useLayoutEffect,b3=()=>{const r=q.useRef(!1);return rg(()=>(r.current=!0,()=>{r.current=!1}),[]),r};function iw(){const r=q.useState()[1],e=b3();return()=>{e.current&&r(Math.random())}}function w3(r,e){const[t]=q.useState(()=>({inputs:e,result:r()})),n=q.useRef(),i=n.current;let s=i;return s?e&&s.inputs&&S3(e,s.inputs)||(s={inputs:e,result:r()}):s=t,q.useEffect(()=>{n.current=s,i==t&&(t.inputs=t.result=void 0)},[s]),s.result}function S3(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}const rw=r=>q.useEffect(r,E3),E3=[];function G_(r){const e=q.useRef();return q.useEffect(()=>{e.current=r}),e.current}const _c=Symbol.for("Animated:node"),M3=r=>!!r&&r[_c]===r,Ri=r=>r&&r[_c],sg=(r,e)=>YO(r,_c,e),bh=r=>r&&r[_c]&&r[_c].getPayload();class sw{constructor(){this.payload=void 0,sg(this,this)}getPayload(){return this.payload||[]}}class Go extends sw{constructor(e){super(),this.done=!0,this.elapsedTime=void 0,this.lastPosition=void 0,this.lastVelocity=void 0,this.v0=void 0,this.durationProgress=0,this._value=e,Oe.num(this._value)&&(this.lastPosition=this._value)}static create(e){return new Go(e)}getPayload(){return[this]}getValue(){return this._value}setValue(e,t){return Oe.num(e)&&(this.lastPosition=e,t&&(e=Math.round(e/t)*t,this.done&&(this.lastPosition=e))),this._value===e?!1:(this._value=e,!0)}reset(){const{done:e}=this;this.done=!1,Oe.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,e&&(this.lastVelocity=null),this.v0=null)}}class Uo extends Go{constructor(e){super(0),this._string=null,this._toString=void 0,this._toString=vc({output:[e,e]})}static create(e){return new Uo(e)}getValue(){let e=this._string;return e??(this._string=this._toString(this._value))}setValue(e){if(Oe.str(e)){if(e==this._string)return!1;this._string=e,this._value=1}else if(super.setValue(e))this._string=null;else return!1;return!0}reset(e){e&&(this._toString=vc({output:[this.getValue(),e]})),this._value=0,super.reset()}}const Ru={dependencies:null};class og extends sw{constructor(e){super(),this.source=e,this.setValue(e)}getValue(e){const t={};return or(this.source,(n,i)=>{M3(n)?t[i]=n.getValue(e):Pi(n)?t[i]=Jn(n):e||(t[i]=n)}),t}setValue(e){this.source=e,this.payload=this._makePayload(e)}reset(){this.payload&&_t(this.payload,e=>e.reset())}_makePayload(e){if(e){const t=new Set;return or(e,this._addToPayload,t),Array.from(t)}}_addToPayload(e){Ru.dependencies&&Pi(e)&&Ru.dependencies.add(e);const t=bh(e);t&&_t(t,n=>this.add(n))}}class ag extends og{constructor(e){super(e)}static create(e){return new ag(e)}getValue(){return this.source.map(e=>e.getValue())}setValue(e){const t=this.getPayload();return e.length==t.length?t.map((n,i)=>n.setValue(e[i])).some(Boolean):(super.setValue(e.map(T3)),!0)}}function T3(r){return(xh(r)?Uo:Go).create(r)}function Pp(r){const e=Ri(r);return e?e.constructor:Oe.arr(r)?ag:xh(r)?Uo:Go}function Pu(){return Pu=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Pu.apply(this,arguments)}const V_=(r,e)=>{const t=!Oe.fun(r)||r.prototype&&r.prototype.isReactComponent;return q.forwardRef((n,i)=>{const s=q.useRef(null),o=t&&q.useCallback(m=>{s.current=R3(i,m)},[i]),[a,c]=C3(n,e),l=iw(),u=()=>{const m=s.current;if(t&&!m)return;(m?e.applyAnimatedValues(m,a.getValue(!0)):!1)===!1&&l()},h=new A3(u,c),f=q.useRef();rg(()=>(f.current=h,_t(c,m=>Bc(m,h)),()=>{f.current&&(_t(f.current.deps,m=>Cu(m,f.current)),Je.cancel(f.current.update))})),q.useEffect(u,[]),rw(()=>()=>{const m=f.current;_t(m.deps,v=>Cu(v,m))});const d=e.getComponentProps(a.getValue());return q.createElement(r,Pu({},d,{ref:o}))})};class A3{constructor(e,t){this.update=e,this.deps=t}eventObserved(e){e.type=="change"&&Je.write(this.update)}}function C3(r,e){const t=new Set;return Ru.dependencies=t,r.style&&(r=Pu({},r,{style:e.createAnimatedStyle(r.style)})),r=new og(r),Ru.dependencies=null,[r,t]}function R3(r,e){return r&&(Oe.fun(r)?r(e):r.current=e),e}const H_=Symbol.for("AnimatedComponent"),P3=(r,{applyAnimatedValues:e=()=>!1,createAnimatedStyle:t=i=>new og(i),getComponentProps:n=i=>i}={})=>{const i={applyAnimatedValues:e,createAnimatedStyle:t,getComponentProps:n},s=o=>{const a=W_(o)||"Anonymous";return Oe.str(o)?o=s[o]||(s[o]=V_(o,i)):o=o[H_]||(o[H_]=V_(o,i)),o.displayName=`Animated(${a})`,o};return or(r,(o,a)=>{Oe.arr(r)&&(a=W_(o)),s[a]=s(o)}),{animated:s}},W_=r=>Oe.str(r)?r:r&&Oe.str(r.displayName)?r.displayName:Oe.fun(r)&&r.name||null;function rn(){return rn=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},rn.apply(this,arguments)}function rs(r,...e){return Oe.fun(r)?r(...e):r}const Ya=(r,e)=>r===!0||!!(e&&r&&(Oe.fun(r)?r(e):ni(r).includes(e))),ow=(r,e)=>Oe.obj(r)?e&&r[e]:r,aw=(r,e)=>r.default===!0?r[e]:r.default?r.default[e]:void 0,L3=r=>r,cg=(r,e=L3)=>{let t=D3;r.default&&r.default!==!0&&(r=r.default,t=Object.keys(r));const n={};for(const i of t){const s=e(r[i],i);Oe.und(s)||(n[i]=s)}return n},D3=["config","onProps","onStart","onChange","onPause","onResume","onRest"],I3={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function U3(r){const e={};let t=0;if(or(r,(n,i)=>{I3[i]||(e[i]=n,t++)}),t)return e}function cw(r){const e=U3(r);if(e){const t={to:e};return or(r,(n,i)=>i in e||(t[i]=n)),t}return rn({},r)}function yc(r){return r=Jn(r),Oe.arr(r)?r.map(yc):xh(r)?Fi.createStringInterpolator({range:[0,1],output:[r,r]})(1):r}function O3(r){for(const e in r)return!0;return!1}function Lp(r){return Oe.fun(r)||Oe.arr(r)&&Oe.obj(r[0])}function N3(r,e){var t;(t=r.ref)==null||t.delete(r),e==null||e.delete(r)}function F3(r,e){if(e&&r.ref!==e){var t;(t=r.ref)==null||t.delete(r),e.add(r),r.ref=e}}const k3={default:{tension:170,friction:26}},Dp=rn({},k3.default,{mass:1,damping:1,easing:l3.linear,clamp:!1});class z3{constructor(){this.tension=void 0,this.friction=void 0,this.frequency=void 0,this.damping=void 0,this.mass=void 0,this.velocity=0,this.restVelocity=void 0,this.precision=void 0,this.progress=void 0,this.duration=void 0,this.easing=void 0,this.clamp=void 0,this.bounce=void 0,this.decay=void 0,this.round=void 0,Object.assign(this,Dp)}}function B3(r,e,t){t&&(t=rn({},t),X_(t,e),e=rn({},t,e)),X_(r,e),Object.assign(r,e);for(const o in Dp)r[o]==null&&(r[o]=Dp[o]);let{mass:n,frequency:i,damping:s}=r;return Oe.und(i)||(i<.01&&(i=.01),s<0&&(s=0),r.tension=Math.pow(2*Math.PI/i,2)*n,r.friction=4*Math.PI*s*n/i),r}function X_(r,e){if(!Oe.und(e.decay))r.duration=void 0;else{const t=!Oe.und(e.tension)||!Oe.und(e.friction);(t||!Oe.und(e.frequency)||!Oe.und(e.damping)||!Oe.und(e.mass))&&(r.duration=void 0,r.decay=void 0),t&&(r.frequency=void 0)}}const q_=[];class G3{constructor(){this.changed=!1,this.values=q_,this.toValues=null,this.fromValues=q_,this.to=void 0,this.from=void 0,this.config=new z3,this.immediate=!1}}function lw(r,{key:e,props:t,defaultProps:n,state:i,actions:s}){return new Promise((o,a)=>{var c;let l,u,h=Ya((c=t.cancel)!=null?c:n==null?void 0:n.cancel,e);if(h)m();else{Oe.und(t.pause)||(i.paused=Ya(t.pause,e));let v=n==null?void 0:n.pause;v!==!0&&(v=i.paused||Ya(v,e)),l=rs(t.delay||0,e),v?(i.resumeQueue.add(d),s.pause()):(s.resume(),d())}function f(){i.resumeQueue.add(d),i.timeouts.delete(u),u.cancel(),l=u.time-Je.now()}function d(){l>0&&!Fi.skipAnimation?(i.delayed=!0,u=Je.setTimeout(m,l),i.pauseQueue.add(f),i.timeouts.add(u)):m()}function m(){i.delayed&&(i.delayed=!1),i.pauseQueue.delete(f),i.timeouts.delete(u),r<=(i.cancelId||0)&&(h=!0);try{s.start(rn({},t,{callId:r,cancel:h}),o)}catch(v){a(v)}}})}const lg=(r,e)=>e.length==1?e[0]:e.some(t=>t.cancelled)?Mo(r.get()):e.every(t=>t.noop)?uw(r.get()):vi(r.get(),e.every(t=>t.finished)),uw=r=>({value:r,noop:!0,finished:!0,cancelled:!1}),vi=(r,e,t=!1)=>({value:r,finished:e,cancelled:t}),Mo=r=>({value:r,cancelled:!0,finished:!1});function hw(r,e,t,n){const{callId:i,parentId:s,onRest:o}=e,{asyncTo:a,promise:c}=t;return!s&&r===a&&!e.reset?c:t.promise=(async()=>{t.asyncId=i,t.asyncTo=r;const l=cg(e,(g,p)=>p==="onRest"?void 0:g);let u,h;const f=new Promise((g,p)=>(u=g,h=p)),d=g=>{const p=i<=(t.cancelId||0)&&Mo(n)||i!==t.asyncId&&vi(n,!1);if(p)throw g.result=p,h(g),g},m=(g,p)=>{const _=new Y_,y=new j_;return(async()=>{if(Fi.skipAnimation)throw xc(t),y.result=vi(n,!1),h(y),y;d(_);const x=Oe.obj(g)?rn({},g):rn({},p,{to:g});x.parentId=i,or(l,(w,S)=>{Oe.und(x[S])&&(x[S]=w)});const b=await n.start(x);return d(_),t.paused&&await new Promise(w=>{t.resumeQueue.add(w)}),b})()};let v;if(Fi.skipAnimation)return xc(t),vi(n,!1);try{let g;Oe.arr(r)?g=(async p=>{for(const _ of p)await m(_)})(r):g=Promise.resolve(r(m,n.stop.bind(n))),await Promise.all([g.then(u),f]),v=vi(n.get(),!0,!1)}catch(g){if(g instanceof Y_)v=g.result;else if(g instanceof j_)v=g.result;else throw g}finally{i==t.asyncId&&(t.asyncId=s,t.asyncTo=s?a:void 0,t.promise=s?c:void 0)}return Oe.fun(o)&&Je.batchedUpdates(()=>{o(v,n,n.item)}),v})()}function xc(r,e){Xa(r.timeouts,t=>t.cancel()),r.pauseQueue.clear(),r.resumeQueue.clear(),r.asyncId=r.asyncTo=r.promise=void 0,e&&(r.cancelId=e)}class Y_ extends Error{constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."),this.result=void 0}}class j_ extends Error{constructor(){super("SkipAnimationSignal"),this.result=void 0}}const Ip=r=>r instanceof ug;let V3=1;class ug extends h3{constructor(...e){super(...e),this.id=V3++,this.key=void 0,this._priority=0}get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e))}get(){const e=Ri(this);return e&&e.getValue()}to(...e){return Fi.to(this,e)}interpolate(...e){return _3(),Fi.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach()}observerRemoved(e){e==0&&this._detach()}_attach(){}_detach(){}_onChange(e,t=!1){Au(this,{type:"change",parent:this,value:e,idle:t})}_onPriorityChange(e){this.idle||vh.sort(this),Au(this,{type:"priority",parent:this,priority:e})}}const Ss=Symbol.for("SpringPhase"),fw=1,Up=2,Op=4,bd=r=>(r[Ss]&fw)>0,xr=r=>(r[Ss]&Up)>0,Ra=r=>(r[Ss]&Op)>0,$_=(r,e)=>e?r[Ss]|=Up|fw:r[Ss]&=~Up,Z_=(r,e)=>e?r[Ss]|=Op:r[Ss]&=~Op;class H3 extends ug{constructor(e,t){if(super(),this.key=void 0,this.animation=new G3,this.queue=void 0,this.defaultProps={},this._state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._pendingCalls=new Set,this._lastCallId=0,this._lastToId=0,this._memoizedDuration=0,!Oe.und(e)||!Oe.und(t)){const n=Oe.obj(e)?rn({},e):rn({},t,{from:e});Oe.und(n.default)&&(n.default=!0),this.start(n)}}get idle(){return!(xr(this)||this._state.asyncTo)||Ra(this)}get goal(){return Jn(this.animation.to)}get velocity(){const e=Ri(this);return e instanceof Go?e.lastVelocity||0:e.getPayload().map(t=>t.lastVelocity||0)}get hasAnimated(){return bd(this)}get isAnimating(){return xr(this)}get isPaused(){return Ra(this)}get isDelayed(){return this._state.delayed}advance(e){let t=!0,n=!1;const i=this.animation;let{config:s,toValues:o}=i;const a=bh(i.to);!a&&Pi(i.to)&&(o=ni(Jn(i.to))),i.values.forEach((u,h)=>{if(u.done)return;const f=u.constructor==Uo?1:a?a[h].lastPosition:o[h];let d=i.immediate,m=f;if(!d){if(m=u.lastPosition,s.tension<=0){u.done=!0;return}let v=u.elapsedTime+=e;const g=i.fromValues[h],p=u.v0!=null?u.v0:u.v0=Oe.arr(s.velocity)?s.velocity[h]:s.velocity;let _;const y=s.precision||(g==f?.005:Math.min(1,Math.abs(f-g)*.001));if(Oe.und(s.duration))if(s.decay){const x=s.decay===!0?.998:s.decay,b=Math.exp(-(1-x)*v);m=g+p/(1-x)*(1-b),d=Math.abs(u.lastPosition-m)<=y,_=p*b}else{_=u.lastVelocity==null?p:u.lastVelocity;const x=s.restVelocity||y/10,b=s.clamp?0:s.bounce,w=!Oe.und(b),S=g==f?u.v0>0:g<f;let M,E=!1;const T=1,L=Math.ceil(e/T);for(let P=0;P<L&&(M=Math.abs(_)>x,!(!M&&(d=Math.abs(f-m)<=y,d)));++P){w&&(E=m==f||m>f==S,E&&(_=-_*b,m=f));const A=-s.tension*1e-6*(m-f),z=-s.friction*.001*_,V=(A+z)/s.mass;_=_+V*T,m=m+_*T}}else{let x=1;s.duration>0&&(this._memoizedDuration!==s.duration&&(this._memoizedDuration=s.duration,u.durationProgress>0&&(u.elapsedTime=s.duration*u.durationProgress,v=u.elapsedTime+=e)),x=(s.progress||0)+v/this._memoizedDuration,x=x>1?1:x<0?0:x,u.durationProgress=x),m=g+s.easing(x)*(f-g),_=(m-u.lastPosition)/e,d=x==1}u.lastVelocity=_,Number.isNaN(m)&&(console.warn("Got NaN while animating:",this),d=!0)}a&&!a[h].done&&(d=!1),d?u.done=!0:t=!1,u.setValue(m,s.round)&&(n=!0)});const c=Ri(this),l=c.getValue();if(t){const u=Jn(i.to);(l!==u||n)&&!s.decay?(c.setValue(u),this._onChange(u)):n&&s.decay&&this._onChange(l),this._stop()}else n&&this._onChange(l)}set(e){return Je.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e)}),this}pause(){this._update({pause:!0})}resume(){this._update({pause:!1})}finish(){if(xr(this)){const{to:e,config:t}=this.animation;Je.batchedUpdates(()=>{this._onStart(),t.decay||this._set(e,!1),this._stop()})}return this}update(e){return(this.queue||(this.queue=[])).push(e),this}start(e,t){let n;return Oe.und(e)?(n=this.queue||[],this.queue=[]):n=[Oe.obj(e)?e:rn({},t,{to:e})],Promise.all(n.map(i=>this._update(i))).then(i=>lg(this,i))}stop(e){const{to:t}=this.animation;return this._focus(this.get()),xc(this._state,e&&this._lastCallId),Je.batchedUpdates(()=>this._stop(t,e)),this}reset(){this._update({reset:!0})}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1)}_prepareNode(e){const t=this.key||"";let{to:n,from:i}=e;n=Oe.obj(n)?n[t]:n,(n==null||Lp(n))&&(n=void 0),i=Oe.obj(i)?i[t]:i,i==null&&(i=void 0);const s={to:n,from:i};return bd(this)||(e.reverse&&([n,i]=[i,n]),i=Jn(i),Oe.und(i)?Ri(this)||this._set(n):this._set(i)),s}_update(e,t){let n=rn({},e);const{key:i,defaultProps:s}=this;n.default&&Object.assign(s,cg(n,(c,l)=>/^on/.test(l)?ow(c,i):c)),J_(this,n,"onProps"),La(this,"onProps",n,this);const o=this._prepareNode(n);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");const a=this._state;return lw(++this._lastCallId,{key:i,props:n,defaultProps:s,state:a,actions:{pause:()=>{Ra(this)||(Z_(this,!0),ka(a.pauseQueue),La(this,"onPause",vi(this,Pa(this,this.animation.to)),this))},resume:()=>{Ra(this)&&(Z_(this,!1),xr(this)&&this._resume(),ka(a.resumeQueue),La(this,"onResume",vi(this,Pa(this,this.animation.to)),this))},start:this._merge.bind(this,o)}}).then(c=>{if(n.loop&&c.finished&&!(t&&c.noop)){const l=dw(n);if(l)return this._update(l,!0)}return c})}_merge(e,t,n){if(t.cancel)return this.stop(!0),n(Mo(this));const i=!Oe.und(e.to),s=!Oe.und(e.from);if(i||s)if(t.callId>this._lastToId)this._lastToId=t.callId;else return n(Mo(this));const{key:o,defaultProps:a,animation:c}=this,{to:l,from:u}=c;let{to:h=l,from:f=u}=e;s&&!i&&(!t.default||Oe.und(h))&&(h=f),t.reverse&&([h,f]=[f,h]);const d=!Ji(f,u);d&&(c.from=f),f=Jn(f);const m=!Ji(h,l);m&&this._focus(h);const v=Lp(t.to),{config:g}=c,{decay:p,velocity:_}=g;(i||s)&&(g.velocity=0),t.config&&!v&&B3(g,rs(t.config,o),t.config!==a.config?rs(a.config,o):void 0);let y=Ri(this);if(!y||Oe.und(h))return n(vi(this,!0));const x=Oe.und(t.reset)?s&&!t.default:!Oe.und(f)&&Ya(t.reset,o),b=x?f:this.get(),w=yc(h),S=Oe.num(w)||Oe.arr(w)||xh(w),M=!v&&(!S||Ya(a.immediate||t.immediate,o));if(m){const P=Pp(h);if(P!==y.constructor)if(M)y=this._set(w);else throw Error(`Cannot animate between ${y.constructor.name} and ${P.name}, as the "to" prop suggests`)}const E=y.constructor;let T=Pi(h),L=!1;if(!T){const P=x||!bd(this)&&d;(m||P)&&(L=Ji(yc(b),w),T=!L),(!Ji(c.immediate,M)&&!M||!Ji(g.decay,p)||!Ji(g.velocity,_))&&(T=!0)}if(L&&xr(this)&&(c.changed&&!x?T=!0:T||this._stop(l)),!v&&((T||Pi(l))&&(c.values=y.getPayload(),c.toValues=Pi(h)?null:E==Uo?[1]:ni(w)),c.immediate!=M&&(c.immediate=M,!M&&!x&&this._set(l)),T)){const{onRest:P}=c;_t(X3,z=>J_(this,t,z));const A=vi(this,Pa(this,l));ka(this._pendingCalls,A),this._pendingCalls.add(n),c.changed&&Je.batchedUpdates(()=>{c.changed=!x,P==null||P(A,this),x?rs(a.onRest,A):c.onStart==null||c.onStart(A,this)})}x&&this._set(b),v?n(hw(t.to,t,this._state,this)):T?this._start():xr(this)&&!m?this._pendingCalls.add(n):n(uw(b))}_focus(e){const t=this.animation;e!==t.to&&(z_(this)&&this._detach(),t.to=e,z_(this)&&this._attach())}_attach(){let e=0;const{to:t}=this.animation;Pi(t)&&(Bc(t,this),Ip(t)&&(e=t.priority+1)),this.priority=e}_detach(){const{to:e}=this.animation;Pi(e)&&Cu(e,this)}_set(e,t=!0){const n=Jn(e);if(!Oe.und(n)){const i=Ri(this);if(!i||!Ji(n,i.getValue())){const s=Pp(n);!i||i.constructor!=s?sg(this,s.create(n)):i.setValue(n),i&&Je.batchedUpdates(()=>{this._onChange(n,t)})}}return Ri(this)}_onStart(){const e=this.animation;e.changed||(e.changed=!0,La(this,"onStart",vi(this,Pa(this,e.to)),this))}_onChange(e,t){t||(this._onStart(),rs(this.animation.onChange,e,this)),rs(this.defaultProps.onChange,e,this),super._onChange(e,t)}_start(){const e=this.animation;Ri(this).reset(Jn(e.to)),e.immediate||(e.fromValues=e.values.map(t=>t.lastPosition)),xr(this)||($_(this,!0),Ra(this)||this._resume())}_resume(){Fi.skipAnimation?this.finish():vh.start(this)}_stop(e,t){if(xr(this)){$_(this,!1);const n=this.animation;_t(n.values,s=>{s.done=!0}),n.toValues&&(n.onChange=n.onPause=n.onResume=void 0),Au(this,{type:"idle",parent:this});const i=t?Mo(this.get()):vi(this.get(),Pa(this,e??n.to));ka(this._pendingCalls,i),n.changed&&(n.changed=!1,La(this,"onRest",i,this))}}}function Pa(r,e){const t=yc(e),n=yc(r.get());return Ji(n,t)}function dw(r,e=r.loop,t=r.to){let n=rs(e);if(n){const i=n!==!0&&cw(n),s=(i||r).reverse,o=!i||i.reset;return bc(rn({},r,{loop:e,default:!1,pause:void 0,to:!s||Lp(t)?t:void 0,from:o?r.from:void 0,reset:o},i))}}function bc(r){const{to:e,from:t}=r=cw(r),n=new Set;return Oe.obj(e)&&K_(e,n),Oe.obj(t)&&K_(t,n),r.keys=n.size?Array.from(n):null,r}function W3(r){const e=bc(r);return Oe.und(e.default)&&(e.default=cg(e)),e}function K_(r,e){or(r,(t,n)=>t!=null&&e.add(n))}const X3=["onStart","onRest","onChange","onPause","onResume"];function J_(r,e,t){r.animation[t]=e[t]!==aw(e,t)?ow(e[t],r.key):void 0}function La(r,e,...t){var n,i,s,o;(n=(i=r.animation)[e])==null||n.call(i,...t),(s=(o=r.defaultProps)[e])==null||s.call(o,...t)}const q3=["onStart","onChange","onRest"];let Y3=1;class j3{constructor(e,t){this.id=Y3++,this.springs={},this.queue=[],this.ref=void 0,this._flush=void 0,this._initialProps=void 0,this._lastAsyncId=0,this._active=new Set,this._changed=new Set,this._started=!1,this._item=void 0,this._state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._events={onStart:new Map,onChange:new Map,onRest:new Map},this._onFrame=this._onFrame.bind(this),t&&(this._flush=t),e&&this.start(rn({default:!0},e))}get idle(){return!this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e}get(){const e={};return this.each((t,n)=>e[n]=t.get()),e}set(e){for(const t in e){const n=e[t];Oe.und(n)||this.springs[t].set(n)}}update(e){return e&&this.queue.push(bc(e)),this}start(e){let{queue:t}=this;return e?t=ni(e).map(bc):this.queue=[],this._flush?this._flush(this,t):(_w(this,t),Np(this,t))}stop(e,t){if(e!==!!e&&(t=e),t){const n=this.springs;_t(ni(t),i=>n[i].stop(!!e))}else xc(this._state,this._lastAsyncId),this.each(n=>n.stop(!!e));return this}pause(e){if(Oe.und(e))this.start({pause:!0});else{const t=this.springs;_t(ni(e),n=>t[n].pause())}return this}resume(e){if(Oe.und(e))this.start({pause:!1});else{const t=this.springs;_t(ni(e),n=>t[n].resume())}return this}each(e){or(this.springs,e)}_onFrame(){const{onStart:e,onChange:t,onRest:n}=this._events,i=this._active.size>0,s=this._changed.size>0;(i&&!this._started||s&&!this._started)&&(this._started=!0,Xa(e,([c,l])=>{l.value=this.get(),c(l,this,this._item)}));const o=!i&&this._started,a=s||o&&n.size?this.get():null;s&&t.size&&Xa(t,([c,l])=>{l.value=a,c(l,this,this._item)}),o&&(this._started=!1,Xa(n,([c,l])=>{l.value=a,c(l,this,this._item)}))}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;Je.onFrame(this._onFrame)}}function Np(r,e){return Promise.all(e.map(t=>pw(r,t))).then(t=>lg(r,t))}async function pw(r,e,t){const{keys:n,to:i,from:s,loop:o,onRest:a,onResolve:c}=e,l=Oe.obj(e.default)&&e.default;o&&(e.loop=!1),i===!1&&(e.to=null),s===!1&&(e.from=null);const u=Oe.arr(i)||Oe.fun(i)?i:void 0;u?(e.to=void 0,e.onRest=void 0,l&&(l.onRest=void 0)):_t(q3,v=>{const g=e[v];if(Oe.fun(g)){const p=r._events[v];e[v]=({finished:_,cancelled:y})=>{const x=p.get(g);x?(_||(x.finished=!1),y&&(x.cancelled=!0)):p.set(g,{value:null,finished:_||!1,cancelled:y||!1})},l&&(l[v]=e[v])}});const h=r._state;e.pause===!h.paused?(h.paused=e.pause,ka(e.pause?h.pauseQueue:h.resumeQueue)):h.paused&&(e.pause=!0);const f=(n||Object.keys(r.springs)).map(v=>r.springs[v].start(e)),d=e.cancel===!0||aw(e,"cancel")===!0;(u||d&&h.asyncId)&&f.push(lw(++r._lastAsyncId,{props:e,state:h,actions:{pause:Ap,resume:Ap,start(v,g){d?(xc(h,r._lastAsyncId),g(Mo(r))):(v.onRest=a,g(hw(u,v,h,r)))}}})),h.paused&&await new Promise(v=>{h.resumeQueue.add(v)});const m=lg(r,await Promise.all(f));if(o&&m.finished&&!(t&&m.noop)){const v=dw(e,o,i);if(v)return _w(r,[v]),pw(r,v,!0)}return c&&Je.batchedUpdates(()=>c(m,r,r.item)),m}function Q_(r,e){const t=rn({},r.springs);return e&&_t(ni(e),n=>{Oe.und(n.keys)&&(n=bc(n)),Oe.obj(n.to)||(n=rn({},n,{to:void 0})),vw(t,n,i=>gw(i))}),mw(r,t),t}function mw(r,e){or(e,(t,n)=>{r.springs[n]||(r.springs[n]=t,Bc(t,r))})}function gw(r,e){const t=new H3;return t.key=r,e&&Bc(t,e),t}function vw(r,e,t){e.keys&&_t(e.keys,n=>{(r[n]||(r[n]=t(n)))._prepareNode(e)})}function _w(r,e){_t(e,t=>{vw(r.springs,t,n=>gw(n,r))})}function $3(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}const Z3=["children"],wh=r=>{let{children:e}=r,t=$3(r,Z3);const n=q.useContext(Lu),i=t.pause||!!n.pause,s=t.immediate||!!n.immediate;t=w3(()=>({pause:i,immediate:s}),[i,s]);const{Provider:o}=Lu;return q.createElement(o,{value:t},e)},Lu=K3(wh,{});wh.Provider=Lu.Provider;wh.Consumer=Lu.Consumer;function K3(r,e){return Object.assign(r,q.createContext(e)),r.Provider._context=r,r.Consumer._context=r,r}const J3=()=>{const r=[],e=function(i){x3();const s=[];return _t(r,(o,a)=>{if(Oe.und(i))s.push(o.start());else{const c=t(i,o,a);c&&s.push(o.start(c))}}),s};e.current=r,e.add=function(n){r.includes(n)||r.push(n)},e.delete=function(n){const i=r.indexOf(n);~i&&r.splice(i,1)},e.pause=function(){return _t(r,n=>n.pause(...arguments)),this},e.resume=function(){return _t(r,n=>n.resume(...arguments)),this},e.set=function(n){_t(r,i=>i.set(n))},e.start=function(n){const i=[];return _t(r,(s,o)=>{if(Oe.und(n))i.push(s.start());else{const a=this._getProps(n,s,o);a&&i.push(s.start(a))}}),i},e.stop=function(){return _t(r,n=>n.stop(...arguments)),this},e.update=function(n){return _t(r,(i,s)=>i.update(this._getProps(n,i,s))),this};const t=function(i,s,o){return Oe.fun(i)?i(o,s):i};return e._getProps=t,e};function Q3(r,e,t){const n=Oe.fun(e)&&e;n&&!t&&(t=[]);const i=q.useMemo(()=>n||arguments.length==3?J3():void 0,[]),s=q.useRef(0),o=iw(),a=q.useMemo(()=>({ctrls:[],queue:[],flush(p,_){const y=Q_(p,_);return s.current>0&&!a.queue.length&&!Object.keys(y).some(b=>!p.springs[b])?Np(p,_):new Promise(b=>{mw(p,y),a.queue.push(()=>{b(Np(p,_))}),o()})}}),[]),c=q.useRef([...a.ctrls]),l=[],u=G_(r)||0;q.useMemo(()=>{_t(c.current.slice(r,u),p=>{N3(p,i),p.stop(!0)}),c.current.length=r,h(u,r)},[r]),q.useMemo(()=>{h(0,Math.min(u,r))},t);function h(p,_){for(let y=p;y<_;y++){const x=c.current[y]||(c.current[y]=new j3(null,a.flush)),b=n?n(y,x):e[y];b&&(l[y]=W3(b))}}const f=c.current.map((p,_)=>Q_(p,l[_])),d=q.useContext(wh),m=G_(d),v=d!==m&&O3(d);rg(()=>{s.current++,a.ctrls=c.current;const{queue:p}=a;p.length&&(a.queue=[],_t(p,_=>_())),_t(c.current,(_,y)=>{i==null||i.add(_),v&&_.start({default:d});const x=l[y];x&&(F3(_,x.ref),_.ref?_.queue.push(x):_.start(x))})}),rw(()=>()=>{_t(a.ctrls,p=>p.stop(!0))});const g=f.map(p=>rn({},p));return i?[g,i]:g}function Gn(r,e){const t=Oe.fun(r),[[n],i]=Q3(1,t?r:[r],t?e||[]:e);return t||arguments.length==2?[n,i]:n}let ey;(function(r){r.MOUNT="mount",r.ENTER="enter",r.UPDATE="update",r.LEAVE="leave"})(ey||(ey={}));class eN extends ug{constructor(e,t){super(),this.key=void 0,this.idle=!0,this.calc=void 0,this._active=new Set,this.source=e,this.calc=vc(...t);const n=this._get(),i=Pp(n);sg(this,i.create(n))}advance(e){const t=this._get(),n=this.get();Ji(t,n)||(Ri(this).setValue(t),this._onChange(t,this.idle)),!this.idle&&ty(this._active)&&wd(this)}_get(){const e=Oe.arr(this.source)?this.source.map(Jn):ni(Jn(this.source));return this.calc(...e)}_start(){this.idle&&!ty(this._active)&&(this.idle=!1,_t(bh(this),e=>{e.done=!1}),Fi.skipAnimation?(Je.batchedUpdates(()=>this.advance()),wd(this)):vh.start(this))}_attach(){let e=1;_t(ni(this.source),t=>{Pi(t)&&Bc(t,this),Ip(t)&&(t.idle||this._active.add(t),e=Math.max(e,t.priority+1))}),this.priority=e,this._start()}_detach(){_t(ni(this.source),e=>{Pi(e)&&Cu(e,this)}),this._active.clear(),wd(this)}eventObserved(e){e.type=="change"?e.idle?this.advance():(this._active.add(e.parent),this._start()):e.type=="idle"?this._active.delete(e.parent):e.type=="priority"&&(this.priority=ni(this.source).reduce((t,n)=>Math.max(t,(Ip(n)?n.priority:0)+1),0))}}function tN(r){return r.idle!==!1}function ty(r){return!r.size||Array.from(r).every(tN)}function wd(r){r.idle||(r.idle=!0,_t(bh(r),e=>{e.done=!0}),Au(r,{type:"idle",parent:r}))}Fi.assign({createStringInterpolator:tw,to:(r,e)=>new eN(r,e)});const nN=["primitive"].concat(Object.keys($b).filter(r=>/^[A-Z]/.test(r)).map(r=>r[0].toLowerCase()+r.slice(1)));Fi.assign({createStringInterpolator:tw,colors:KO,frameLoop:"demand"});FL(()=>{Je.advance()});const iN=P3(nN,{applyAnimatedValues:ts}),Gt=iN.animated,yw=q.forwardRef(function({children:e,follow:t=!0,lockX:n=!1,lockY:i=!1,lockZ:s=!1,...o},a){const c=q.useRef(null),l=q.useRef(null),u=new ln;return uh(({camera:h})=>{if(!t||!l.current)return;const f=l.current.rotation.clone();l.current.updateMatrix(),l.current.updateWorldMatrix(!1,!1),l.current.getWorldQuaternion(u),h.getWorldQuaternion(c.current.quaternion).premultiply(u.invert()),n&&(l.current.rotation.x=f.x),i&&(l.current.rotation.y=f.y),s&&(l.current.rotation.z=f.z)}),q.useImperativeHandle(a,()=>l.current,[]),q.createElement("group",Tc({ref:l,matrixAutoUpdate:!1,matrixWorldAutoUpdate:!1},o),q.createElement("group",{ref:c},e))});function rN(){var r=Object.create(null);function e(i,s){var o=i.id,a=i.name,c=i.dependencies;c===void 0&&(c=[]);var l=i.init;l===void 0&&(l=function(){});var u=i.getTransferables;if(u===void 0&&(u=null),!r[o])try{c=c.map(function(f){return f&&f.isWorkerModule&&(e(f,function(d){if(d instanceof Error)throw d}),f=r[f.id].value),f}),l=n("<"+a+">.init",l),u&&(u=n("<"+a+">.getTransferables",u));var h=null;typeof l=="function"?h=l.apply(void 0,c):console.error("worker module init function failed to rehydrate"),r[o]={id:o,value:h,getTransferables:u},s(h)}catch(f){f&&f.noLog||console.error(f),s(f)}}function t(i,s){var o,a=i.id,c=i.args;(!r[a]||typeof r[a].value!="function")&&s(new Error("Worker module "+a+": not found or its 'init' did not return a function"));try{var l=(o=r[a]).value.apply(o,c);l&&typeof l.then=="function"?l.then(u,function(h){return s(h instanceof Error?h:new Error(""+h))}):u(l)}catch(h){s(h)}function u(h){try{var f=r[a].getTransferables&&r[a].getTransferables(h);(!f||!Array.isArray(f)||!f.length)&&(f=void 0),s(h,f)}catch(d){console.error(d),s(d)}}}function n(i,s){var o=void 0;self.troikaDefine=function(c){return o=c};var a=URL.createObjectURL(new Blob(["/** "+i.replace(/\*/g,"")+` **/
|
|
|
|
troikaDefine(
|
|
`+s+`
|
|
)`],{type:"application/javascript"}));try{importScripts(a)}catch(c){console.error(c)}return URL.revokeObjectURL(a),delete self.troikaDefine,o}self.addEventListener("message",function(i){var s=i.data,o=s.messageId,a=s.action,c=s.data;try{a==="registerModule"&&e(c,function(l){l instanceof Error?postMessage({messageId:o,success:!1,error:l.message}):postMessage({messageId:o,success:!0,result:{isCallable:typeof l=="function"}})}),a==="callModule"&&t(c,function(l,u){l instanceof Error?postMessage({messageId:o,success:!1,error:l.message}):postMessage({messageId:o,success:!0,result:l},u||void 0)})}catch(l){postMessage({messageId:o,success:!1,error:l.stack})}})}function sN(r){var e=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return e._getInitResult().then(function(i){if(typeof i=="function")return i.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")})};return e._getInitResult=function(){var t=r.dependencies,n=r.init;t=Array.isArray(t)?t.map(function(s){return s&&s._getInitResult?s._getInitResult():s}):[];var i=Promise.all(t).then(function(s){return n.apply(null,s)});return e._getInitResult=function(){return i},i},e}var xw=function(){var r=!1;if(typeof window<"u"&&typeof window.document<"u")try{var e=new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"})));e.terminate(),r=!0}catch(t){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return xw=function(){return r},r},oN=0,aN=0,Sd=!1,ja=Object.create(null),$a=Object.create(null),Fp=Object.create(null);function Gc(r){if((!r||typeof r.init!="function")&&!Sd)throw new Error("requires `options.init` function");var e=r.dependencies,t=r.init,n=r.getTransferables,i=r.workerId;if(!xw())return sN(r);i==null&&(i="#default");var s="workerModule"+ ++oN,o=r.name||s,a=null;e=e&&e.map(function(l){return typeof l=="function"&&!l.workerModuleData&&(Sd=!0,l=Gc({workerId:i,name:"<"+o+"> function dependency: "+l.name,init:`function(){return (
|
|
`+pu(l)+`
|
|
)}`}),Sd=!1),l&&l.workerModuleData&&(l=l.workerModuleData),l});function c(){for(var l=[],u=arguments.length;u--;)l[u]=arguments[u];if(!a){a=ny(i,"registerModule",c.workerModuleData);var h=function(){a=null,$a[i].delete(h)};($a[i]||($a[i]=new Set)).add(h)}return a.then(function(f){var d=f.isCallable;if(d)return ny(i,"callModule",{id:s,args:l});throw new Error("Worker module function was called but `init` did not return a callable function")})}return c.workerModuleData={isWorkerModule:!0,id:s,name:o,dependencies:e,init:pu(t),getTransferables:n&&pu(n)},c}function cN(r){$a[r]&&$a[r].forEach(function(e){e()}),ja[r]&&(ja[r].terminate(),delete ja[r])}function pu(r){var e=r.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function lN(r){var e=ja[r];if(!e){var t=pu(rN);e=ja[r]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+r.replace(/\*/g,"")+` **/
|
|
|
|
;(`+t+")()"],{type:"application/javascript"}))),e.onmessage=function(n){var i=n.data,s=i.messageId,o=Fp[s];if(!o)throw new Error("WorkerModule response with empty or unknown messageId");delete Fp[s],o(i)}}return e}function ny(r,e,t){return new Promise(function(n,i){var s=++aN;Fp[s]=function(o){o.success?n(o.result):i(new Error("Error in worker "+e+" call: "+o.error))},lN(r).postMessage({messageId:s,action:e,data:t})})}const bw=/\bvoid\s+main\s*\(\s*\)\s*{/g;function kp(r){const e=/^[ \t]*#include +<([\w\d./]+)>/gm;function t(n,i){let s=Qe[i];return s?kp(s):n}return r.replace(e,t)}const an=[];for(let r=0;r<256;r++)an[r]=(r<16?"0":"")+r.toString(16);function uN(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(an[r&255]+an[r>>8&255]+an[r>>16&255]+an[r>>24&255]+"-"+an[e&255]+an[e>>8&255]+"-"+an[e>>16&15|64]+an[e>>24&255]+"-"+an[t&63|128]+an[t>>8&255]+"-"+an[t>>16&255]+an[t>>24&255]+an[n&255]+an[n>>8&255]+an[n>>16&255]+an[n>>24&255]).toUpperCase()}const Qr=Object.assign||function(){let r=arguments[0];for(let e=1,t=arguments.length;e<t;e++){let n=arguments[e];if(n)for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])}return r},hN=Date.now(),iy=new WeakMap,ry=new Map;let fN=1e10;function zp(r,e){const t=gN(e);let n=iy.get(r);if(n||iy.set(r,n=Object.create(null)),n[t])return new n[t];const i=`_onBeforeCompile${t}`,s=function(l,u){r.onBeforeCompile.call(this,l,u);const h=this.customProgramCacheKey()+"|"+l.vertexShader+"|"+l.fragmentShader;let f=ry[h];if(!f){const d=dN(this,l,e,t);f=ry[h]=d}l.vertexShader=f.vertexShader,l.fragmentShader=f.fragmentShader,Qr(l.uniforms,this.uniforms),e.timeUniform&&(l.uniforms[e.timeUniform]={get value(){return Date.now()-hN}}),this[i]&&this[i](l)},o=function(){return a(e.chained?r:r.clone())},a=function(l){const u=Object.create(l,c);return Object.defineProperty(u,"baseMaterial",{value:r}),Object.defineProperty(u,"id",{value:fN++}),u.uuid=uN(),u.uniforms=Qr({},l.uniforms,e.uniforms),u.defines=Qr({},l.defines,e.defines),u.defines[`TROIKA_DERIVED_MATERIAL_${t}`]="",u.extensions=Qr({},l.extensions,e.extensions),u._listeners=void 0,u},c={constructor:{value:o},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return r.customProgramCacheKey()+"|"+t}},onBeforeCompile:{get(){return s},set(l){this[i]=l}},copy:{writable:!0,configurable:!0,value:function(l){return r.copy.call(this,l),!r.isShaderMaterial&&!r.isDerivedMaterial&&(Qr(this.extensions,l.extensions),Qr(this.defines,l.defines),Qr(this.uniforms,am.clone(l.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const l=new r.constructor;return a(l).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let l=this._depthMaterial;return l||(l=this._depthMaterial=zp(r.isDerivedMaterial?r.getDepthMaterial():new Gu({depthPacking:em}),e),l.defines.IS_DEPTH_MATERIAL="",l.uniforms=this.uniforms),l}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let l=this._distanceMaterial;return l||(l=this._distanceMaterial=zp(r.isDerivedMaterial?r.getDistanceMaterial():new Vu,e),l.defines.IS_DISTANCE_MATERIAL="",l.uniforms=this.uniforms),l}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:l,_distanceMaterial:u}=this;l&&l.dispose(),u&&u.dispose(),r.dispose.call(this)}}};return n[t]=o,new o}function dN(r,{vertexShader:e,fragmentShader:t},n,i){let{vertexDefs:s,vertexMainIntro:o,vertexMainOutro:a,vertexTransform:c,fragmentDefs:l,fragmentMainIntro:u,fragmentMainOutro:h,fragmentColorTransform:f,customRewriter:d,timeUniform:m}=n;if(s=s||"",o=o||"",a=a||"",l=l||"",u=u||"",h=h||"",(c||d)&&(e=kp(e)),(f||d)&&(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,`
|
|
//!BEGIN_POST_CHUNK $1
|
|
$&
|
|
//!END_POST_CHUNK
|
|
`),t=kp(t)),d){let v=d({vertexShader:e,fragmentShader:t});e=v.vertexShader,t=v.fragmentShader}if(f){let v=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,g=>(v.push(g),"")),h=`${f}
|
|
${v.join(`
|
|
`)}
|
|
${h}`}if(m){const v=`
|
|
uniform float ${m};
|
|
`;s=v+s,l=v+l}return c&&(e=`vec3 troika_position_${i};
|
|
vec3 troika_normal_${i};
|
|
vec2 troika_uv_${i};
|
|
${e}
|
|
`,s=`${s}
|
|
void troikaVertexTransform${i}(inout vec3 position, inout vec3 normal, inout vec2 uv) {
|
|
${c}
|
|
}
|
|
`,o=`
|
|
troika_position_${i} = vec3(position);
|
|
troika_normal_${i} = vec3(normal);
|
|
troika_uv_${i} = vec2(uv);
|
|
troikaVertexTransform${i}(troika_position_${i}, troika_normal_${i}, troika_uv_${i});
|
|
${o}
|
|
`,e=e.replace(/\b(position|normal|uv)\b/g,(v,g,p,_)=>/\battribute\s+vec[23]\s+$/.test(_.substr(0,p))?g:`troika_${g}_${i}`),r.map&&r.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${i}`))),e=sy(e,i,s,o,a),t=sy(t,i,l,u,h),{vertexShader:e,fragmentShader:t}}function sy(r,e,t,n,i){return(n||i||t)&&(r=r.replace(bw,`
|
|
${t}
|
|
void troikaOrigMain${e}() {`),r+=`
|
|
void main() {
|
|
${n}
|
|
troikaOrigMain${e}();
|
|
${i}
|
|
}`),r}function pN(r,e){return r==="uniforms"?void 0:typeof e=="function"?e.toString():e}let mN=0;const oy=new Map;function gN(r){const e=JSON.stringify(r,pN);let t=oy.get(e);return t==null&&oy.set(e,t=++mN),t}function vN(r,e,t){const{defaultFontURL:n}=t,i=Object.create(null),s=1/0,o=/[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/,a="[^\\S\\u00A0]",c=new RegExp(`${a}|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]`);function l(_,y){function x(){const b=w=>{console.error(`Failure loading font ${_}${_===n?"":"; trying fallback"}`,w),_!==n&&(_=n,x())};try{const w=new XMLHttpRequest;w.open("get",_,!0),w.responseType="arraybuffer",w.onload=function(){if(w.status>=400)b(new Error(w.statusText));else if(w.status>0)try{const S=r(w.response);y(S)}catch(S){b(S)}},w.onerror=b,w.send()}catch(w){b(w)}}x()}function u(_,y){_||(_=n);let x=i[_];x?x.pending?x.pending.push(y):y(x):(i[_]={pending:[y]},l(_,b=>{let w=i[_].pending;i[_]=b,w.forEach(S=>S(b))}))}function h({text:_="",font:y=n,sdfGlyphSize:x=64,fontSize:b=1,letterSpacing:w=0,lineHeight:S="normal",maxWidth:M=s,direction:E,textAlign:T="left",textIndent:L=0,whiteSpace:P="normal",overflowWrap:A="normal",anchorX:z=0,anchorY:V=0,includeCaretPositions:N=!1,chunkedBoundsSize:C=8192,colorRanges:O=null},k,U=!1){const R=v(),F={fontLoad:0,typesetting:0};_.indexOf("\r")>-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),_=_.replace(/\r\n/g,`
|
|
`).replace(/\r/g,`
|
|
`)),b=+b,w=+w,M=+M,S=S||"normal",L=+L,u(y,H=>{const Y=isFinite(M);let J=null,ie=null,ne=null,ee=null,ge=null,me=null,te=null,D=0,Q=0,j=P!=="nowrap";const{ascender:K,descender:W,unitsPerEm:ye,lineGap:re,capHeight:fe,xHeight:xe}=H;F.fontLoad=v()-R;const ce=v(),Pe=b/ye;S==="normal"&&(S=(K-W+re)/ye),S=S*b;const B=(S-(K-W)*Pe)/2,I=-(K*Pe+B),$=Math.min(S,(K-W)*Pe),he=(K+W)/2*Pe-$/2;let de=L,pe=new g;const Me=[pe];H.forEachGlyph(_,b,w,(Ce,ze,Le)=>{const Ee=_.charAt(Le),De=Ce.advanceWidth*Pe,Ve=pe.count;let je;if("isEmpty"in Ce||(Ce.isWhitespace=!!Ee&&new RegExp(a).test(Ee),Ce.canBreakAfter=!!Ee&&c.test(Ee),Ce.isEmpty=Ce.xMin===Ce.xMax||Ce.yMin===Ce.yMax||o.test(Ee)),!Ce.isWhitespace&&!Ce.isEmpty&&Q++,j&&Y&&!Ce.isWhitespace&&ze+De+de>M&&Ve){if(pe.glyphAt(Ve-1).glyphObj.canBreakAfter)je=new g,de=-ze;else for(let Ae=Ve;Ae--;)if(Ae===0&&A==="break-word"){je=new g,de=-ze;break}else if(pe.glyphAt(Ae).glyphObj.canBreakAfter){je=pe.splitAt(Ae+1);const le=je.glyphAt(0).x;de-=le;for(let Re=je.count;Re--;)je.glyphAt(Re).x-=le;break}je&&(pe.isSoftWrapped=!0,pe=je,Me.push(pe),D=M)}let Z=pe.glyphAt(pe.count);Z.glyphObj=Ce,Z.x=ze+de,Z.width=De,Z.charIndex=Le,Ee===`
|
|
`&&(pe=new g,Me.push(pe),de=-(ze+De+w*b)+L)}),Me.forEach(Ce=>{for(let ze=Ce.count;ze--;){let{glyphObj:Le,x:Ee,width:De}=Ce.glyphAt(ze);if(!Le.isWhitespace){Ce.width=Ee+De,Ce.width>D&&(D=Ce.width);return}}});let we=0,ue=0;if(z&&(typeof z=="number"?we=-z:typeof z=="string"&&(we=-D*(z==="left"?0:z==="center"?.5:z==="right"?1:d(z)))),V){if(typeof V=="number")ue=-V;else if(typeof V=="string"){let Ce=Me.length*S;ue=V==="top"?0:V==="top-baseline"?-I:V==="top-cap"?-I-fe*Pe:V==="top-ex"?-I-xe*Pe:V==="middle"?Ce/2:V==="bottom"?Ce:V==="bottom-baseline"?Ce-B+W*Pe:d(V)*Ce}}if(!U){const Ce=e.getEmbeddingLevels(_,E);J=new Uint16Array(Q),ie=new Float32Array(Q*2),ne={},me=[s,s,-s,-s],te=[];let ze=I;N&&(ge=new Float32Array(_.length*3)),O&&(ee=new Uint8Array(Q*3));let Le=0,Ee=-1,De=-1,Ve,je;if(Me.forEach((Z,Ae)=>{let{count:le,width:Re}=Z;if(le>0){let Fe=0;for(let dt=le;dt--&&Z.glyphAt(dt).glyphObj.isWhitespace;)Fe++;let tt=0,lt=0;if(T==="center")tt=(D-Re)/2;else if(T==="right")tt=D-Re;else if(T==="justify"&&Z.isSoftWrapped){let dt=0;for(let ct=le-Fe;ct--;)Z.glyphAt(ct).glyphObj.isWhitespace&&dt++;lt=(D-Re)/dt}if(lt||tt){let dt=0;for(let ct=0;ct<le;ct++){let Mn=Z.glyphAt(ct);const fn=Mn.glyphObj;Mn.x+=tt+dt,lt!==0&&fn.isWhitespace&&ct<le-Fe&&(dt+=lt,Mn.width+=lt)}}const ft=e.getReorderSegments(_,Ce,Z.glyphAt(0).charIndex,Z.glyphAt(Z.count-1).charIndex);for(let dt=0;dt<ft.length;dt++){const[ct,Mn]=ft[dt];let fn=1/0,yt=-1/0;for(let kt=0;kt<le;kt++)if(Z.glyphAt(kt).charIndex>=ct){let yn=kt,Vt=kt;for(;Vt<le;Vt++){let Ht=Z.glyphAt(Vt);if(Ht.charIndex>Mn)break;Vt<le-Fe&&(fn=Math.min(fn,Ht.x),yt=Math.max(yt,Ht.x+Ht.width))}for(let Ht=yn;Ht<Vt;Ht++){const sn=Z.glyphAt(Ht);sn.x=yt-(sn.x+sn.width-fn)}break}}let ut;const xt=dt=>ut=dt;for(let dt=0;dt<le;dt++){let ct=Z.glyphAt(dt);ut=ct.glyphObj;const Mn=ut.index,fn=Ce.levels[ct.charIndex]&1;if(fn){const yt=e.getMirroredCharacter(_[ct.charIndex]);yt&&H.forEachGlyph(yt,0,0,xt)}if(N){const{charIndex:yt}=ct,kt=ct.x+we,yn=ct.x+ct.width+we;ge[yt*3]=fn?yn:kt,ge[yt*3+1]=fn?kt:yn,ge[yt*3+2]=ze+he+ue;const Vt=yt-Ee;Vt>1&&m(ge,Ee,Vt),Ee=yt}if(O){const{charIndex:yt}=ct;for(;yt>De;)De++,O.hasOwnProperty(De)&&(je=O[De])}if(!ut.isWhitespace&&!ut.isEmpty){const yt=Le++;ne[Mn]||(ne[Mn]={path:ut.path,pathBounds:[ut.xMin,ut.yMin,ut.xMax,ut.yMax]});const kt=ct.x+we,yn=ze+ue;ie[yt*2]=kt,ie[yt*2+1]=yn;const Vt=kt+ut.xMin*Pe,Ht=yn+ut.yMin*Pe,sn=kt+ut.xMax*Pe,Ei=yn+ut.yMax*Pe;Vt<me[0]&&(me[0]=Vt),Ht<me[1]&&(me[1]=Ht),sn>me[2]&&(me[2]=sn),Ei>me[3]&&(me[3]=Ei),yt%C===0&&(Ve={start:yt,end:yt,rect:[s,s,-s,-s]},te.push(Ve)),Ve.end++;const Un=Ve.rect;if(Vt<Un[0]&&(Un[0]=Vt),Ht<Un[1]&&(Un[1]=Ht),sn>Un[2]&&(Un[2]=sn),Ei>Un[3]&&(Un[3]=Ei),J[yt]=Mn,O){const X=yt*3;ee[X]=je>>16&255,ee[X+1]=je>>8&255,ee[X+2]=je&255}}}}ze-=S}),ge){const Z=_.length-Ee;Z>1&&m(ge,Ee,Z)}}F.typesetting=v()-ce,k({glyphIds:J,glyphPositions:ie,glyphData:ne,caretPositions:ge,caretHeight:$,glyphColors:ee,chunkedBounds:te,fontSize:b,unitsPerEm:ye,ascender:K*Pe,descender:W*Pe,capHeight:fe*Pe,xHeight:xe*Pe,lineHeight:S,topBaseline:I,blockBounds:[we,ue-Me.length*S,we+D,ue],visibleBounds:me,timings:F})})}function f(_,y){h(_,x=>{const[b,w,S,M]=x.blockBounds;y({width:S-b,height:M-w})},{})}function d(_){let y=_.match(/^([\d.]+)%$/),x=y?parseFloat(y[1]):NaN;return isNaN(x)?0:x/100}function m(_,y,x){const b=_[y*3],w=_[y*3+1],S=_[y*3+2],M=(w-b)/x;for(let E=0;E<x;E++){const T=(y+E)*3;_[T]=b+M*E,_[T+1]=b+M*(E+1),_[T+2]=S}}function v(){return(self.performance||Date).now()}function g(){this.data=[]}const p=["glyphObj","x","width","charIndex"];return g.prototype={width:0,isSoftWrapped:!1,get count(){return Math.ceil(this.data.length/p.length)},glyphAt(_){let y=g.flyweight;return y.data=this.data,y.index=_,y},splitAt(_){let y=new g;return y.data=this.data.splice(_*p.length),y}},g.flyweight=p.reduce((_,y,x,b)=>(Object.defineProperty(_,y,{get(){return this.data[this.index*p.length+x]},set(w){this.data[this.index*p.length+x]=w}}),_),{data:null,index:0}),{typeset:h,measure:f,loadFont:u}}const ps=()=>(self.performance||Date).now(),Sh=Hy();let ay;function _N(r,e,t,n,i,s,o,a,c,l,u=!0){return u?xN(r,e,t,n,i,s,o,a,c,l).then(null,h=>(ay||(console.warn("WebGL SDF generation failed, falling back to JS",h),ay=!0),ly(r,e,t,n,i,s,o,a,c,l))):ly(r,e,t,n,i,s,o,a,c,l)}const mu=[],yN=5;let Bp=0;function ww(){const r=ps();for(;mu.length&&ps()-r<yN;)mu.shift()();Bp=mu.length?setTimeout(ww,0):0}const xN=(...r)=>new Promise((e,t)=>{mu.push(()=>{const n=ps();try{Sh.webgl.generateIntoCanvas(...r),e({timing:ps()-n})}catch(i){t(i)}}),Bp||(Bp=setTimeout(ww,0))}),bN=4,wN=2e3,cy={};let SN=0;function ly(r,e,t,n,i,s,o,a,c,l){const u="TroikaTextSDFGenerator_JS_"+SN++%bN;let h=cy[u];return h||(h=cy[u]={workerModule:Gc({name:u,workerId:u,dependencies:[Hy,ps],init(f,d){const m=f().javascript.generate;return function(...v){const g=d();return{textureData:m(...v),timing:d()-g}}},getTransferables(f){return[f.textureData.buffer]}}),requests:0,idleTimer:null}),h.requests++,clearTimeout(h.idleTimer),h.workerModule(r,e,t,n,i,s).then(({textureData:f,timing:d})=>{const m=ps(),v=new Uint8Array(f.length*4);for(let g=0;g<f.length;g++)v[g*4+l]=f[g];return Sh.webglUtils.renderImageData(o,v,a,c,r,e,1<<3-l),d+=ps()-m,--h.requests===0&&(h.idleTimer=setTimeout(()=>{cN(u)},wN)),{timing:d}})}function EN(r){r._warm||(Sh.webgl.isSupported(r),r._warm=!0)}const MN=Sh.webglUtils.resizeWebGLCanvasWithoutClearing;/*!
|
|
Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering.
|
|
Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE
|
|
*/function TN(){return typeof window>"u"&&(self.window=self),(function(r){var e={parse:function(i){var s=e._bin,o=new Uint8Array(i);if(s.readASCII(o,0,4)=="ttcf"){var a=4;s.readUshort(o,a),a+=2,s.readUshort(o,a),a+=2;var c=s.readUint(o,a);a+=4;for(var l=[],u=0;u<c;u++){var h=s.readUint(o,a);a+=4,l.push(e._readFont(o,h))}return l}return[e._readFont(o,0)]},_readFont:function(i,s){var o=e._bin,a=s;o.readFixed(i,s),s+=4;var c=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2;for(var l=["cmap","head","hhea","maxp","hmtx","name","OS/2","post","loca","glyf","kern","CFF ","GPOS","GSUB","SVG "],u={_data:i,_offset:a},h={},f=0;f<c;f++){var d=o.readASCII(i,s,4);s+=4,o.readUint(i,s),s+=4;var m=o.readUint(i,s);s+=4;var v=o.readUint(i,s);s+=4,h[d]={offset:m,length:v}}for(f=0;f<l.length;f++){var g=l[f];h[g]&&(u[g.trim()]=e[g.trim()].parse(i,h[g].offset,h[g].length,u))}return u},_tabOffset:function(i,s,o){for(var a=e._bin,c=a.readUshort(i,o+4),l=o+12,u=0;u<c;u++){var h=a.readASCII(i,l,4);l+=4,a.readUint(i,l),l+=4;var f=a.readUint(i,l);if(l+=4,a.readUint(i,l),l+=4,h==s)return f}return 0}};e._bin={readFixed:function(i,s){return(i[s]<<8|i[s+1])+(i[s+2]<<8|i[s+3])/65540},readF2dot14:function(i,s){return e._bin.readShort(i,s)/16384},readInt:function(i,s){return e._bin._view(i).getInt32(s)},readInt8:function(i,s){return e._bin._view(i).getInt8(s)},readShort:function(i,s){return e._bin._view(i).getInt16(s)},readUshort:function(i,s){return e._bin._view(i).getUint16(s)},readUshorts:function(i,s,o){for(var a=[],c=0;c<o;c++)a.push(e._bin.readUshort(i,s+2*c));return a},readUint:function(i,s){return e._bin._view(i).getUint32(s)},readUint64:function(i,s){return 4294967296*e._bin.readUint(i,s)+e._bin.readUint(i,s+4)},readASCII:function(i,s,o){for(var a="",c=0;c<o;c++)a+=String.fromCharCode(i[s+c]);return a},readUnicode:function(i,s,o){for(var a="",c=0;c<o;c++){var l=i[s++]<<8|i[s++];a+=String.fromCharCode(l)}return a},_tdec:typeof window<"u"&&window.TextDecoder?new window.TextDecoder:null,readUTF8:function(i,s,o){var a=e._bin._tdec;return a&&s==0&&o==i.length?a.decode(i):e._bin.readASCII(i,s,o)},readBytes:function(i,s,o){for(var a=[],c=0;c<o;c++)a.push(i[s+c]);return a},readASCIIArray:function(i,s,o){for(var a=[],c=0;c<o;c++)a.push(String.fromCharCode(i[s+c]));return a},_view:function(i){return i._dataView||(i._dataView=i.buffer?new DataView(i.buffer,i.byteOffset,i.byteLength):new DataView(new Uint8Array(i).buffer))}},e._lctf={},e._lctf.parse=function(i,s,o,a,c){var l=e._bin,u={},h=s;l.readFixed(i,s),s+=4;var f=l.readUshort(i,s);s+=2;var d=l.readUshort(i,s);s+=2;var m=l.readUshort(i,s);return s+=2,u.scriptList=e._lctf.readScriptList(i,h+f),u.featureList=e._lctf.readFeatureList(i,h+d),u.lookupList=e._lctf.readLookupList(i,h+m,c),u},e._lctf.readLookupList=function(i,s,o){var a=e._bin,c=s,l=[],u=a.readUshort(i,s);s+=2;for(var h=0;h<u;h++){var f=a.readUshort(i,s);s+=2;var d=e._lctf.readLookupTable(i,c+f,o);l.push(d)}return l},e._lctf.readLookupTable=function(i,s,o){var a=e._bin,c=s,l={tabs:[]};l.ltype=a.readUshort(i,s),s+=2,l.flag=a.readUshort(i,s),s+=2;var u=a.readUshort(i,s);s+=2;for(var h=l.ltype,f=0;f<u;f++){var d=a.readUshort(i,s);s+=2;var m=o(i,h,c+d,l);l.tabs.push(m)}return l},e._lctf.numOfOnes=function(i){for(var s=0,o=0;o<32;o++)(i>>>o&1)!=0&&s++;return s},e._lctf.readClassDef=function(i,s){var o=e._bin,a=[],c=o.readUshort(i,s);if(s+=2,c==1){var l=o.readUshort(i,s);s+=2;var u=o.readUshort(i,s);s+=2;for(var h=0;h<u;h++)a.push(l+h),a.push(l+h),a.push(o.readUshort(i,s)),s+=2}if(c==2){var f=o.readUshort(i,s);for(s+=2,h=0;h<f;h++)a.push(o.readUshort(i,s)),s+=2,a.push(o.readUshort(i,s)),s+=2,a.push(o.readUshort(i,s)),s+=2}return a},e._lctf.getInterval=function(i,s){for(var o=0;o<i.length;o+=3){var a=i[o],c=i[o+1];if(i[o+2],a<=s&&s<=c)return o}return-1},e._lctf.readCoverage=function(i,s){var o=e._bin,a={};a.fmt=o.readUshort(i,s),s+=2;var c=o.readUshort(i,s);return s+=2,a.fmt==1&&(a.tab=o.readUshorts(i,s,c)),a.fmt==2&&(a.tab=o.readUshorts(i,s,3*c)),a},e._lctf.coverageIndex=function(i,s){var o=i.tab;if(i.fmt==1)return o.indexOf(s);if(i.fmt==2){var a=e._lctf.getInterval(o,s);if(a!=-1)return o[a+2]+(s-o[a])}return-1},e._lctf.readFeatureList=function(i,s){var o=e._bin,a=s,c=[],l=o.readUshort(i,s);s+=2;for(var u=0;u<l;u++){var h=o.readASCII(i,s,4);s+=4;var f=o.readUshort(i,s);s+=2;var d=e._lctf.readFeatureTable(i,a+f);d.tag=h.trim(),c.push(d)}return c},e._lctf.readFeatureTable=function(i,s){var o=e._bin,a=s,c={},l=o.readUshort(i,s);s+=2,l>0&&(c.featureParams=a+l);var u=o.readUshort(i,s);s+=2,c.tab=[];for(var h=0;h<u;h++)c.tab.push(o.readUshort(i,s+2*h));return c},e._lctf.readScriptList=function(i,s){var o=e._bin,a=s,c={},l=o.readUshort(i,s);s+=2;for(var u=0;u<l;u++){var h=o.readASCII(i,s,4);s+=4;var f=o.readUshort(i,s);s+=2,c[h.trim()]=e._lctf.readScriptTable(i,a+f)}return c},e._lctf.readScriptTable=function(i,s){var o=e._bin,a=s,c={},l=o.readUshort(i,s);s+=2,c.default=e._lctf.readLangSysTable(i,a+l);var u=o.readUshort(i,s);s+=2;for(var h=0;h<u;h++){var f=o.readASCII(i,s,4);s+=4;var d=o.readUshort(i,s);s+=2,c[f.trim()]=e._lctf.readLangSysTable(i,a+d)}return c},e._lctf.readLangSysTable=function(i,s){var o=e._bin,a={};o.readUshort(i,s),s+=2,a.reqFeature=o.readUshort(i,s),s+=2;var c=o.readUshort(i,s);return s+=2,a.features=o.readUshorts(i,s,c),a},e.CFF={},e.CFF.parse=function(i,s,o){var a=e._bin;(i=new Uint8Array(i.buffer,s,o))[s=0],i[++s],i[++s],i[++s],s++;var c=[];s=e.CFF.readIndex(i,s,c);for(var l=[],u=0;u<c.length-1;u++)l.push(a.readASCII(i,s+c[u],c[u+1]-c[u]));s+=c[c.length-1];var h=[];s=e.CFF.readIndex(i,s,h);var f=[];for(u=0;u<h.length-1;u++)f.push(e.CFF.readDict(i,s+h[u],s+h[u+1]));s+=h[h.length-1];var d=f[0],m=[];s=e.CFF.readIndex(i,s,m);var v=[];for(u=0;u<m.length-1;u++)v.push(a.readASCII(i,s+m[u],m[u+1]-m[u]));if(s+=m[m.length-1],e.CFF.readSubrs(i,s,d),d.CharStrings){s=d.CharStrings,m=[],s=e.CFF.readIndex(i,s,m);var g=[];for(u=0;u<m.length-1;u++)g.push(a.readBytes(i,s+m[u],m[u+1]-m[u]));d.CharStrings=g}if(d.ROS){s=d.FDArray;var p=[];for(s=e.CFF.readIndex(i,s,p),d.FDArray=[],u=0;u<p.length-1;u++){var _=e.CFF.readDict(i,s+p[u],s+p[u+1]);e.CFF._readFDict(i,_,v),d.FDArray.push(_)}s+=p[p.length-1],s=d.FDSelect,d.FDSelect=[];var y=i[s];if(s++,y!=3)throw y;var x=a.readUshort(i,s);for(s+=2,u=0;u<x+1;u++)d.FDSelect.push(a.readUshort(i,s),i[s+2]),s+=3}return d.Encoding&&(d.Encoding=e.CFF.readEncoding(i,d.Encoding,d.CharStrings.length)),d.charset&&(d.charset=e.CFF.readCharset(i,d.charset,d.CharStrings.length)),e.CFF._readFDict(i,d,v),d},e.CFF._readFDict=function(i,s,o){var a;for(var c in s.Private&&(a=s.Private[1],s.Private=e.CFF.readDict(i,a,a+s.Private[0]),s.Private.Subrs&&e.CFF.readSubrs(i,a+s.Private.Subrs,s.Private)),s)["FamilyName","FontName","FullName","Notice","version","Copyright"].indexOf(c)!=-1&&(s[c]=o[s[c]-426+35])},e.CFF.readSubrs=function(i,s,o){var a=e._bin,c=[];s=e.CFF.readIndex(i,s,c);var l,u=c.length;l=u<1240?107:u<33900?1131:32768,o.Bias=l,o.Subrs=[];for(var h=0;h<c.length-1;h++)o.Subrs.push(a.readBytes(i,s+c[h],c[h+1]-c[h]))},e.CFF.tableSE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,0,111,112,113,114,0,115,116,117,118,119,120,121,122,0,123,0,124,125,126,127,128,129,130,131,0,132,133,0,134,135,136,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,139,0,0,0,0,140,141,142,143,0,0,0,0,0,144,0,0,0,145,0,0,146,147,148,149,0,0,0,0],e.CFF.glyphByUnicode=function(i,s){for(var o=0;o<i.charset.length;o++)if(i.charset[o]==s)return o;return-1},e.CFF.glyphBySE=function(i,s){return s<0||s>255?-1:e.CFF.glyphByUnicode(i,e.CFF.tableSE[s])},e.CFF.readEncoding=function(i,s,o){e._bin;var a=[".notdef"],c=i[s];if(s++,c!=0)throw"error: unknown encoding format: "+c;var l=i[s];s++;for(var u=0;u<l;u++)a.push(i[s+u]);return a},e.CFF.readCharset=function(i,s,o){var a=e._bin,c=[".notdef"],l=i[s];if(s++,l==0)for(var u=0;u<o;u++){var h=a.readUshort(i,s);s+=2,c.push(h)}else{if(l!=1&&l!=2)throw"error: format: "+l;for(;c.length<o;){h=a.readUshort(i,s),s+=2;var f=0;for(l==1?(f=i[s],s++):(f=a.readUshort(i,s),s+=2),u=0;u<=f;u++)c.push(h),h++}}return c},e.CFF.readIndex=function(i,s,o){var a=e._bin,c=a.readUshort(i,s)+1,l=i[s+=2];if(s++,l==1)for(var u=0;u<c;u++)o.push(i[s+u]);else if(l==2)for(u=0;u<c;u++)o.push(a.readUshort(i,s+2*u));else if(l==3)for(u=0;u<c;u++)o.push(16777215&a.readUint(i,s+3*u-1));else if(c!=1)throw"unsupported offset size: "+l+", count: "+c;return(s+=c*l)-1},e.CFF.getCharString=function(i,s,o){var a=e._bin,c=i[s],l=i[s+1];i[s+2],i[s+3],i[s+4];var u=1,h=null,f=null;c<=20&&(h=c,u=1),c==12&&(h=100*c+l,u=2),21<=c&&c<=27&&(h=c,u=1),c==28&&(f=a.readShort(i,s+1),u=3),29<=c&&c<=31&&(h=c,u=1),32<=c&&c<=246&&(f=c-139,u=1),247<=c&&c<=250&&(f=256*(c-247)+l+108,u=2),251<=c&&c<=254&&(f=256*-(c-251)-l-108,u=2),c==255&&(f=a.readInt(i,s+1)/65535,u=5),o.val=f??"o"+h,o.size=u},e.CFF.readCharString=function(i,s,o){for(var a=s+o,c=e._bin,l=[];s<a;){var u=i[s],h=i[s+1];i[s+2],i[s+3],i[s+4];var f=1,d=null,m=null;u<=20&&(d=u,f=1),u==12&&(d=100*u+h,f=2),u!=19&&u!=20||(d=u,f=2),21<=u&&u<=27&&(d=u,f=1),u==28&&(m=c.readShort(i,s+1),f=3),29<=u&&u<=31&&(d=u,f=1),32<=u&&u<=246&&(m=u-139,f=1),247<=u&&u<=250&&(m=256*(u-247)+h+108,f=2),251<=u&&u<=254&&(m=256*-(u-251)-h-108,f=2),u==255&&(m=c.readInt(i,s+1)/65535,f=5),l.push(m??"o"+d),s+=f}return l},e.CFF.readDict=function(i,s,o){for(var a=e._bin,c={},l=[];s<o;){var u=i[s],h=i[s+1];i[s+2],i[s+3],i[s+4];var f=1,d=null,m=null;if(u==28&&(m=a.readShort(i,s+1),f=3),u==29&&(m=a.readInt(i,s+1),f=5),32<=u&&u<=246&&(m=u-139,f=1),247<=u&&u<=250&&(m=256*(u-247)+h+108,f=2),251<=u&&u<=254&&(m=256*-(u-251)-h-108,f=2),u==255)throw m=a.readInt(i,s+1)/65535,f=5,"unknown number";if(u==30){var v=[];for(f=1;;){var g=i[s+f];f++;var p=g>>4,_=15&g;if(p!=15&&v.push(p),_!=15&&v.push(_),_==15)break}for(var y="",x=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],b=0;b<v.length;b++)y+=x[v[b]];m=parseFloat(y)}u<=21&&(d=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][u],f=1,u==12&&(d=["Copyright","isFixedPitch","ItalicAngle","UnderlinePosition","UnderlineThickness","PaintType","CharstringType","FontMatrix","StrokeWidth","BlueScale","BlueShift","BlueFuzz","StemSnapH","StemSnapV","ForceBold",0,0,"LanguageGroup","ExpansionFactor","initialRandomSeed","SyntheticBase","PostScript","BaseFontName","BaseFontBlend",0,0,0,0,0,0,"ROS","CIDFontVersion","CIDFontRevision","CIDFontType","CIDCount","UIDBase","FDArray","FDSelect","FontName"][h],f=2)),d!=null?(c[d]=l.length==1?l[0]:l,l=[]):l.push(m),s+=f}return c},e.cmap={},e.cmap.parse=function(i,s,o){i=new Uint8Array(i.buffer,s,o),s=0;var a=e._bin,c={};a.readUshort(i,s),s+=2;var l=a.readUshort(i,s);s+=2;var u=[];c.tables=[];for(var h=0;h<l;h++){var f=a.readUshort(i,s);s+=2;var d=a.readUshort(i,s);s+=2;var m=a.readUint(i,s);s+=4;var v="p"+f+"e"+d,g=u.indexOf(m);if(g==-1){var p;g=c.tables.length,u.push(m);var _=a.readUshort(i,m);_==0?p=e.cmap.parse0(i,m):_==4?p=e.cmap.parse4(i,m):_==6?p=e.cmap.parse6(i,m):_==12?p=e.cmap.parse12(i,m):console.debug("unknown format: "+_,f,d,m),c.tables.push(p)}if(c[v]!=null)throw"multiple tables for one platform+encoding";c[v]=g}return c},e.cmap.parse0=function(i,s){var o=e._bin,a={};a.format=o.readUshort(i,s),s+=2;var c=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2,a.map=[];for(var l=0;l<c-6;l++)a.map.push(i[s+l]);return a},e.cmap.parse4=function(i,s){var o=e._bin,a=s,c={};c.format=o.readUshort(i,s),s+=2;var l=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2;var u=o.readUshort(i,s);s+=2;var h=u/2;c.searchRange=o.readUshort(i,s),s+=2,c.entrySelector=o.readUshort(i,s),s+=2,c.rangeShift=o.readUshort(i,s),s+=2,c.endCount=o.readUshorts(i,s,h),s+=2*h,s+=2,c.startCount=o.readUshorts(i,s,h),s+=2*h,c.idDelta=[];for(var f=0;f<h;f++)c.idDelta.push(o.readShort(i,s)),s+=2;for(c.idRangeOffset=o.readUshorts(i,s,h),s+=2*h,c.glyphIdArray=[];s<a+l;)c.glyphIdArray.push(o.readUshort(i,s)),s+=2;return c},e.cmap.parse6=function(i,s){var o=e._bin,a={};a.format=o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,a.firstCode=o.readUshort(i,s),s+=2;var c=o.readUshort(i,s);s+=2,a.glyphIdArray=[];for(var l=0;l<c;l++)a.glyphIdArray.push(o.readUshort(i,s)),s+=2;return a},e.cmap.parse12=function(i,s){var o=e._bin,a={};a.format=o.readUshort(i,s),s+=2,s+=2,o.readUint(i,s),s+=4,o.readUint(i,s),s+=4;var c=o.readUint(i,s);s+=4,a.groups=[];for(var l=0;l<c;l++){var u=s+12*l,h=o.readUint(i,u+0),f=o.readUint(i,u+4),d=o.readUint(i,u+8);a.groups.push([h,f,d])}return a},e.glyf={},e.glyf.parse=function(i,s,o,a){for(var c=[],l=0;l<a.maxp.numGlyphs;l++)c.push(null);return c},e.glyf._parseGlyf=function(i,s){var o=e._bin,a=i._data,c=e._tabOffset(a,"glyf",i._offset)+i.loca[s];if(i.loca[s]==i.loca[s+1])return null;var l={};if(l.noc=o.readShort(a,c),c+=2,l.xMin=o.readShort(a,c),c+=2,l.yMin=o.readShort(a,c),c+=2,l.xMax=o.readShort(a,c),c+=2,l.yMax=o.readShort(a,c),c+=2,l.xMin>=l.xMax||l.yMin>=l.yMax)return null;if(l.noc>0){l.endPts=[];for(var u=0;u<l.noc;u++)l.endPts.push(o.readUshort(a,c)),c+=2;var h=o.readUshort(a,c);if(c+=2,a.length-c<h)return null;l.instructions=o.readBytes(a,c,h),c+=h;var f=l.endPts[l.noc-1]+1;for(l.flags=[],u=0;u<f;u++){var d=a[c];if(c++,l.flags.push(d),(8&d)!=0){var m=a[c];c++;for(var v=0;v<m;v++)l.flags.push(d),u++}}for(l.xs=[],u=0;u<f;u++){var g=(2&l.flags[u])!=0,p=(16&l.flags[u])!=0;g?(l.xs.push(p?a[c]:-a[c]),c++):p?l.xs.push(0):(l.xs.push(o.readShort(a,c)),c+=2)}for(l.ys=[],u=0;u<f;u++)g=(4&l.flags[u])!=0,p=(32&l.flags[u])!=0,g?(l.ys.push(p?a[c]:-a[c]),c++):p?l.ys.push(0):(l.ys.push(o.readShort(a,c)),c+=2);var _=0,y=0;for(u=0;u<f;u++)_+=l.xs[u],y+=l.ys[u],l.xs[u]=_,l.ys[u]=y}else{var x;l.parts=[];do{x=o.readUshort(a,c),c+=2;var b={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(l.parts.push(b),b.glyphIndex=o.readUshort(a,c),c+=2,1&x){var w=o.readShort(a,c);c+=2;var S=o.readShort(a,c);c+=2}else w=o.readInt8(a,c),c++,S=o.readInt8(a,c),c++;2&x?(b.m.tx=w,b.m.ty=S):(b.p1=w,b.p2=S),8&x?(b.m.a=b.m.d=o.readF2dot14(a,c),c+=2):64&x?(b.m.a=o.readF2dot14(a,c),c+=2,b.m.d=o.readF2dot14(a,c),c+=2):128&x&&(b.m.a=o.readF2dot14(a,c),c+=2,b.m.b=o.readF2dot14(a,c),c+=2,b.m.c=o.readF2dot14(a,c),c+=2,b.m.d=o.readF2dot14(a,c),c+=2)}while(32&x);if(256&x){var M=o.readUshort(a,c);for(c+=2,l.instr=[],u=0;u<M;u++)l.instr.push(a[c]),c++}}return l},e.GPOS={},e.GPOS.parse=function(i,s,o,a){return e._lctf.parse(i,s,o,a,e.GPOS.subt)},e.GPOS.subt=function(i,s,o,a){var c=e._bin,l=o,u={};if(u.fmt=c.readUshort(i,o),o+=2,s==1||s==2||s==3||s==7||s==8&&u.fmt<=2){var h=c.readUshort(i,o);o+=2,u.coverage=e._lctf.readCoverage(i,h+l)}if(s==1&&u.fmt==1){var f=c.readUshort(i,o);o+=2;var d=e._lctf.numOfOnes(f);f!=0&&(u.pos=e.GPOS.readValueRecord(i,o,f))}else if(s==2&&u.fmt>=1&&u.fmt<=2){f=c.readUshort(i,o),o+=2;var m=c.readUshort(i,o);o+=2,d=e._lctf.numOfOnes(f);var v=e._lctf.numOfOnes(m);if(u.fmt==1){u.pairsets=[];var g=c.readUshort(i,o);o+=2;for(var p=0;p<g;p++){var _=l+c.readUshort(i,o);o+=2;var y=c.readUshort(i,_);_+=2;for(var x=[],b=0;b<y;b++){var w=c.readUshort(i,_);_+=2,f!=0&&(P=e.GPOS.readValueRecord(i,_,f),_+=2*d),m!=0&&(A=e.GPOS.readValueRecord(i,_,m),_+=2*v),x.push({gid2:w,val1:P,val2:A})}u.pairsets.push(x)}}if(u.fmt==2){var S=c.readUshort(i,o);o+=2;var M=c.readUshort(i,o);o+=2;var E=c.readUshort(i,o);o+=2;var T=c.readUshort(i,o);for(o+=2,u.classDef1=e._lctf.readClassDef(i,l+S),u.classDef2=e._lctf.readClassDef(i,l+M),u.matrix=[],p=0;p<E;p++){var L=[];for(b=0;b<T;b++){var P=null,A=null;f!=0&&(P=e.GPOS.readValueRecord(i,o,f),o+=2*d),m!=0&&(A=e.GPOS.readValueRecord(i,o,m),o+=2*v),L.push({val1:P,val2:A})}u.matrix.push(L)}}}else{if(s==9&&u.fmt==1){var z=c.readUshort(i,o);o+=2;var V=c.readUint(i,o);if(o+=4,a.ltype==9)a.ltype=z;else if(a.ltype!=z)throw"invalid extension substitution";return e.GPOS.subt(i,a.ltype,l+V)}console.debug("unsupported GPOS table LookupType",s,"format",u.fmt)}return u},e.GPOS.readValueRecord=function(i,s,o){var a=e._bin,c=[];return c.push(1&o?a.readShort(i,s):0),s+=1&o?2:0,c.push(2&o?a.readShort(i,s):0),s+=2&o?2:0,c.push(4&o?a.readShort(i,s):0),s+=4&o?2:0,c.push(8&o?a.readShort(i,s):0),s+=8&o?2:0,c},e.GSUB={},e.GSUB.parse=function(i,s,o,a){return e._lctf.parse(i,s,o,a,e.GSUB.subt)},e.GSUB.subt=function(i,s,o,a){var c=e._bin,l=o,u={};if(u.fmt=c.readUshort(i,o),o+=2,s!=1&&s!=4&&s!=5&&s!=6)return null;if(s==1||s==4||s==5&&u.fmt<=2||s==6&&u.fmt<=2){var h=c.readUshort(i,o);o+=2,u.coverage=e._lctf.readCoverage(i,l+h)}if(s==1&&u.fmt>=1&&u.fmt<=2){if(u.fmt==1)u.delta=c.readShort(i,o),o+=2;else if(u.fmt==2){var f=c.readUshort(i,o);o+=2,u.newg=c.readUshorts(i,o,f),o+=2*u.newg.length}}else if(s==4){u.vals=[],f=c.readUshort(i,o),o+=2;for(var d=0;d<f;d++){var m=c.readUshort(i,o);o+=2,u.vals.push(e.GSUB.readLigatureSet(i,l+m))}}else if(s==5&&u.fmt==2){if(u.fmt==2){var v=c.readUshort(i,o);o+=2,u.cDef=e._lctf.readClassDef(i,l+v),u.scset=[];var g=c.readUshort(i,o);for(o+=2,d=0;d<g;d++){var p=c.readUshort(i,o);o+=2,u.scset.push(p==0?null:e.GSUB.readSubClassSet(i,l+p))}}}else if(s==6&&u.fmt==3){if(u.fmt==3){for(d=0;d<3;d++){f=c.readUshort(i,o),o+=2;for(var _=[],y=0;y<f;y++)_.push(e._lctf.readCoverage(i,l+c.readUshort(i,o+2*y)));o+=2*f,d==0&&(u.backCvg=_),d==1&&(u.inptCvg=_),d==2&&(u.ahedCvg=_)}f=c.readUshort(i,o),o+=2,u.lookupRec=e.GSUB.readSubstLookupRecords(i,o,f)}}else{if(s==7&&u.fmt==1){var x=c.readUshort(i,o);o+=2;var b=c.readUint(i,o);if(o+=4,a.ltype==9)a.ltype=x;else if(a.ltype!=x)throw"invalid extension substitution";return e.GSUB.subt(i,a.ltype,l+b)}console.debug("unsupported GSUB table LookupType",s,"format",u.fmt)}return u},e.GSUB.readSubClassSet=function(i,s){var o=e._bin.readUshort,a=s,c=[],l=o(i,s);s+=2;for(var u=0;u<l;u++){var h=o(i,s);s+=2,c.push(e.GSUB.readSubClassRule(i,a+h))}return c},e.GSUB.readSubClassRule=function(i,s){var o=e._bin.readUshort,a={},c=o(i,s),l=o(i,s+=2);s+=2,a.input=[];for(var u=0;u<c-1;u++)a.input.push(o(i,s)),s+=2;return a.substLookupRecords=e.GSUB.readSubstLookupRecords(i,s,l),a},e.GSUB.readSubstLookupRecords=function(i,s,o){for(var a=e._bin.readUshort,c=[],l=0;l<o;l++)c.push(a(i,s),a(i,s+2)),s+=4;return c},e.GSUB.readChainSubClassSet=function(i,s){var o=e._bin,a=s,c=[],l=o.readUshort(i,s);s+=2;for(var u=0;u<l;u++){var h=o.readUshort(i,s);s+=2,c.push(e.GSUB.readChainSubClassRule(i,a+h))}return c},e.GSUB.readChainSubClassRule=function(i,s){for(var o=e._bin,a={},c=["backtrack","input","lookahead"],l=0;l<c.length;l++){var u=o.readUshort(i,s);s+=2,l==1&&u--,a[c[l]]=o.readUshorts(i,s,u),s+=2*a[c[l]].length}return u=o.readUshort(i,s),s+=2,a.subst=o.readUshorts(i,s,2*u),s+=2*a.subst.length,a},e.GSUB.readLigatureSet=function(i,s){var o=e._bin,a=s,c=[],l=o.readUshort(i,s);s+=2;for(var u=0;u<l;u++){var h=o.readUshort(i,s);s+=2,c.push(e.GSUB.readLigature(i,a+h))}return c},e.GSUB.readLigature=function(i,s){var o=e._bin,a={chain:[]};a.nglyph=o.readUshort(i,s),s+=2;var c=o.readUshort(i,s);s+=2;for(var l=0;l<c-1;l++)a.chain.push(o.readUshort(i,s)),s+=2;return a},e.head={},e.head.parse=function(i,s,o){var a=e._bin,c={};return a.readFixed(i,s),s+=4,c.fontRevision=a.readFixed(i,s),s+=4,a.readUint(i,s),s+=4,a.readUint(i,s),s+=4,c.flags=a.readUshort(i,s),s+=2,c.unitsPerEm=a.readUshort(i,s),s+=2,c.created=a.readUint64(i,s),s+=8,c.modified=a.readUint64(i,s),s+=8,c.xMin=a.readShort(i,s),s+=2,c.yMin=a.readShort(i,s),s+=2,c.xMax=a.readShort(i,s),s+=2,c.yMax=a.readShort(i,s),s+=2,c.macStyle=a.readUshort(i,s),s+=2,c.lowestRecPPEM=a.readUshort(i,s),s+=2,c.fontDirectionHint=a.readShort(i,s),s+=2,c.indexToLocFormat=a.readShort(i,s),s+=2,c.glyphDataFormat=a.readShort(i,s),s+=2,c},e.hhea={},e.hhea.parse=function(i,s,o){var a=e._bin,c={};return a.readFixed(i,s),s+=4,c.ascender=a.readShort(i,s),s+=2,c.descender=a.readShort(i,s),s+=2,c.lineGap=a.readShort(i,s),s+=2,c.advanceWidthMax=a.readUshort(i,s),s+=2,c.minLeftSideBearing=a.readShort(i,s),s+=2,c.minRightSideBearing=a.readShort(i,s),s+=2,c.xMaxExtent=a.readShort(i,s),s+=2,c.caretSlopeRise=a.readShort(i,s),s+=2,c.caretSlopeRun=a.readShort(i,s),s+=2,c.caretOffset=a.readShort(i,s),s+=2,s+=8,c.metricDataFormat=a.readShort(i,s),s+=2,c.numberOfHMetrics=a.readUshort(i,s),s+=2,c},e.hmtx={},e.hmtx.parse=function(i,s,o,a){for(var c=e._bin,l={aWidth:[],lsBearing:[]},u=0,h=0,f=0;f<a.maxp.numGlyphs;f++)f<a.hhea.numberOfHMetrics&&(u=c.readUshort(i,s),s+=2,h=c.readShort(i,s),s+=2),l.aWidth.push(u),l.lsBearing.push(h);return l},e.kern={},e.kern.parse=function(i,s,o,a){var c=e._bin,l=c.readUshort(i,s);if(s+=2,l==1)return e.kern.parseV1(i,s-2,o,a);var u=c.readUshort(i,s);s+=2;for(var h={glyph1:[],rval:[]},f=0;f<u;f++){s+=2,o=c.readUshort(i,s),s+=2;var d=c.readUshort(i,s);s+=2;var m=d>>>8;if((m&=15)!=0)throw"unknown kern table format: "+m;s=e.kern.readFormat0(i,s,h)}return h},e.kern.parseV1=function(i,s,o,a){var c=e._bin;c.readFixed(i,s),s+=4;var l=c.readUint(i,s);s+=4;for(var u={glyph1:[],rval:[]},h=0;h<l;h++){c.readUint(i,s),s+=4;var f=c.readUshort(i,s);s+=2,c.readUshort(i,s),s+=2;var d=f>>>8;if((d&=15)!=0)throw"unknown kern table format: "+d;s=e.kern.readFormat0(i,s,u)}return u},e.kern.readFormat0=function(i,s,o){var a=e._bin,c=-1,l=a.readUshort(i,s);s+=2,a.readUshort(i,s),s+=2,a.readUshort(i,s),s+=2,a.readUshort(i,s),s+=2;for(var u=0;u<l;u++){var h=a.readUshort(i,s);s+=2;var f=a.readUshort(i,s);s+=2;var d=a.readShort(i,s);s+=2,h!=c&&(o.glyph1.push(h),o.rval.push({glyph2:[],vals:[]}));var m=o.rval[o.rval.length-1];m.glyph2.push(f),m.vals.push(d),c=h}return s},e.loca={},e.loca.parse=function(i,s,o,a){var c=e._bin,l=[],u=a.head.indexToLocFormat,h=a.maxp.numGlyphs+1;if(u==0)for(var f=0;f<h;f++)l.push(c.readUshort(i,s+(f<<1))<<1);if(u==1)for(f=0;f<h;f++)l.push(c.readUint(i,s+(f<<2)));return l},e.maxp={},e.maxp.parse=function(i,s,o){var a=e._bin,c={},l=a.readUint(i,s);return s+=4,c.numGlyphs=a.readUshort(i,s),s+=2,l==65536&&(c.maxPoints=a.readUshort(i,s),s+=2,c.maxContours=a.readUshort(i,s),s+=2,c.maxCompositePoints=a.readUshort(i,s),s+=2,c.maxCompositeContours=a.readUshort(i,s),s+=2,c.maxZones=a.readUshort(i,s),s+=2,c.maxTwilightPoints=a.readUshort(i,s),s+=2,c.maxStorage=a.readUshort(i,s),s+=2,c.maxFunctionDefs=a.readUshort(i,s),s+=2,c.maxInstructionDefs=a.readUshort(i,s),s+=2,c.maxStackElements=a.readUshort(i,s),s+=2,c.maxSizeOfInstructions=a.readUshort(i,s),s+=2,c.maxComponentElements=a.readUshort(i,s),s+=2,c.maxComponentDepth=a.readUshort(i,s),s+=2),c},e.name={},e.name.parse=function(i,s,o){var a=e._bin,c={};a.readUshort(i,s),s+=2;var l=a.readUshort(i,s);s+=2,a.readUshort(i,s);for(var u,h=["copyright","fontFamily","fontSubfamily","ID","fullName","version","postScriptName","trademark","manufacturer","designer","description","urlVendor","urlDesigner","licence","licenceURL","---","typoFamilyName","typoSubfamilyName","compatibleFull","sampleText","postScriptCID","wwsFamilyName","wwsSubfamilyName","lightPalette","darkPalette"],f=s+=2,d=0;d<l;d++){var m=a.readUshort(i,s);s+=2;var v=a.readUshort(i,s);s+=2;var g=a.readUshort(i,s);s+=2;var p=a.readUshort(i,s);s+=2;var _=a.readUshort(i,s);s+=2;var y=a.readUshort(i,s);s+=2;var x,b=h[p],w=f+12*l+y;if(m==0)x=a.readUnicode(i,w,_/2);else if(m==3&&v==0)x=a.readUnicode(i,w,_/2);else if(v==0)x=a.readASCII(i,w,_);else if(v==1)x=a.readUnicode(i,w,_/2);else if(v==3)x=a.readUnicode(i,w,_/2);else{if(m!=1)throw"unknown encoding "+v+", platformID: "+m;x=a.readASCII(i,w,_),console.debug("reading unknown MAC encoding "+v+" as ASCII")}var S="p"+m+","+g.toString(16);c[S]==null&&(c[S]={}),c[S][b!==void 0?b:p]=x,c[S]._lang=g}for(var M in c)if(c[M].postScriptName!=null&&c[M]._lang==1033)return c[M];for(var M in c)if(c[M].postScriptName!=null&&c[M]._lang==0)return c[M];for(var M in c)if(c[M].postScriptName!=null&&c[M]._lang==3084)return c[M];for(var M in c)if(c[M].postScriptName!=null)return c[M];for(var M in c){u=M;break}return console.debug("returning name table with languageID "+c[u]._lang),c[u]},e["OS/2"]={},e["OS/2"].parse=function(i,s,o){var a=e._bin.readUshort(i,s);s+=2;var c={};if(a==0)e["OS/2"].version0(i,s,c);else if(a==1)e["OS/2"].version1(i,s,c);else if(a==2||a==3||a==4)e["OS/2"].version2(i,s,c);else{if(a!=5)throw"unknown OS/2 table version: "+a;e["OS/2"].version5(i,s,c)}return c},e["OS/2"].version0=function(i,s,o){var a=e._bin;return o.xAvgCharWidth=a.readShort(i,s),s+=2,o.usWeightClass=a.readUshort(i,s),s+=2,o.usWidthClass=a.readUshort(i,s),s+=2,o.fsType=a.readUshort(i,s),s+=2,o.ySubscriptXSize=a.readShort(i,s),s+=2,o.ySubscriptYSize=a.readShort(i,s),s+=2,o.ySubscriptXOffset=a.readShort(i,s),s+=2,o.ySubscriptYOffset=a.readShort(i,s),s+=2,o.ySuperscriptXSize=a.readShort(i,s),s+=2,o.ySuperscriptYSize=a.readShort(i,s),s+=2,o.ySuperscriptXOffset=a.readShort(i,s),s+=2,o.ySuperscriptYOffset=a.readShort(i,s),s+=2,o.yStrikeoutSize=a.readShort(i,s),s+=2,o.yStrikeoutPosition=a.readShort(i,s),s+=2,o.sFamilyClass=a.readShort(i,s),s+=2,o.panose=a.readBytes(i,s,10),s+=10,o.ulUnicodeRange1=a.readUint(i,s),s+=4,o.ulUnicodeRange2=a.readUint(i,s),s+=4,o.ulUnicodeRange3=a.readUint(i,s),s+=4,o.ulUnicodeRange4=a.readUint(i,s),s+=4,o.achVendID=[a.readInt8(i,s),a.readInt8(i,s+1),a.readInt8(i,s+2),a.readInt8(i,s+3)],s+=4,o.fsSelection=a.readUshort(i,s),s+=2,o.usFirstCharIndex=a.readUshort(i,s),s+=2,o.usLastCharIndex=a.readUshort(i,s),s+=2,o.sTypoAscender=a.readShort(i,s),s+=2,o.sTypoDescender=a.readShort(i,s),s+=2,o.sTypoLineGap=a.readShort(i,s),s+=2,o.usWinAscent=a.readUshort(i,s),s+=2,o.usWinDescent=a.readUshort(i,s),s+=2},e["OS/2"].version1=function(i,s,o){var a=e._bin;return s=e["OS/2"].version0(i,s,o),o.ulCodePageRange1=a.readUint(i,s),s+=4,o.ulCodePageRange2=a.readUint(i,s),s+=4},e["OS/2"].version2=function(i,s,o){var a=e._bin;return s=e["OS/2"].version1(i,s,o),o.sxHeight=a.readShort(i,s),s+=2,o.sCapHeight=a.readShort(i,s),s+=2,o.usDefault=a.readUshort(i,s),s+=2,o.usBreak=a.readUshort(i,s),s+=2,o.usMaxContext=a.readUshort(i,s),s+=2},e["OS/2"].version5=function(i,s,o){var a=e._bin;return s=e["OS/2"].version2(i,s,o),o.usLowerOpticalPointSize=a.readUshort(i,s),s+=2,o.usUpperOpticalPointSize=a.readUshort(i,s),s+=2},e.post={},e.post.parse=function(i,s,o){var a=e._bin,c={};return c.version=a.readFixed(i,s),s+=4,c.italicAngle=a.readFixed(i,s),s+=4,c.underlinePosition=a.readShort(i,s),s+=2,c.underlineThickness=a.readShort(i,s),s+=2,c},e==null&&(e={}),e.U==null&&(e.U={}),e.U.codeToGlyph=function(i,s){var o=i.cmap,a=-1;if(o.p0e4!=null?a=o.p0e4:o.p3e1!=null?a=o.p3e1:o.p1e0!=null?a=o.p1e0:o.p0e3!=null&&(a=o.p0e3),a==-1)throw"no familiar platform and encoding!";var c=o.tables[a];if(c.format==0)return s>=c.map.length?0:c.map[s];if(c.format==4){for(var l=-1,u=0;u<c.endCount.length;u++)if(s<=c.endCount[u]){l=u;break}return l==-1||c.startCount[l]>s?0:65535&(c.idRangeOffset[l]!=0?c.glyphIdArray[s-c.startCount[l]+(c.idRangeOffset[l]>>1)-(c.idRangeOffset.length-l)]:s+c.idDelta[l])}if(c.format==12){if(s>c.groups[c.groups.length-1][1])return 0;for(u=0;u<c.groups.length;u++){var h=c.groups[u];if(h[0]<=s&&s<=h[1])return h[2]+(s-h[0])}return 0}throw"unknown cmap table format "+c.format},e.U.glyphToPath=function(i,s){var o={cmds:[],crds:[]};if(i.SVG&&i.SVG.entries[s]){var a=i.SVG.entries[s];return a==null?o:(typeof a=="string"&&(a=e.SVG.toPath(a),i.SVG.entries[s]=a),a)}if(i.CFF){var c={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:i.CFF.Private?i.CFF.Private.defaultWidthX:0,open:!1},l=i.CFF,u=i.CFF.Private;if(l.ROS){for(var h=0;l.FDSelect[h+2]<=s;)h+=2;u=l.FDArray[l.FDSelect[h+1]].Private}e.U._drawCFF(i.CFF.CharStrings[s],c,l,u,o)}else i.glyf&&e.U._drawGlyf(s,i,o);return o},e.U._drawGlyf=function(i,s,o){var a=s.glyf[i];a==null&&(a=s.glyf[i]=e.glyf._parseGlyf(s,i)),a!=null&&(a.noc>-1?e.U._simpleGlyph(a,o):e.U._compoGlyph(a,s,o))},e.U._simpleGlyph=function(i,s){for(var o=0;o<i.noc;o++){for(var a=o==0?0:i.endPts[o-1]+1,c=i.endPts[o],l=a;l<=c;l++){var u=l==a?c:l-1,h=l==c?a:l+1,f=1&i.flags[l],d=1&i.flags[u],m=1&i.flags[h],v=i.xs[l],g=i.ys[l];if(l==a)if(f){if(!d){e.U.P.moveTo(s,v,g);continue}e.U.P.moveTo(s,i.xs[u],i.ys[u])}else d?e.U.P.moveTo(s,i.xs[u],i.ys[u]):e.U.P.moveTo(s,(i.xs[u]+v)/2,(i.ys[u]+g)/2);f?d&&e.U.P.lineTo(s,v,g):m?e.U.P.qcurveTo(s,v,g,i.xs[h],i.ys[h]):e.U.P.qcurveTo(s,v,g,(v+i.xs[h])/2,(g+i.ys[h])/2)}e.U.P.closePath(s)}},e.U._compoGlyph=function(i,s,o){for(var a=0;a<i.parts.length;a++){var c={cmds:[],crds:[]},l=i.parts[a];e.U._drawGlyf(l.glyphIndex,s,c);for(var u=l.m,h=0;h<c.crds.length;h+=2){var f=c.crds[h],d=c.crds[h+1];o.crds.push(f*u.a+d*u.b+u.tx),o.crds.push(f*u.c+d*u.d+u.ty)}for(h=0;h<c.cmds.length;h++)o.cmds.push(c.cmds[h])}},e.U._getGlyphClass=function(i,s){var o=e._lctf.getInterval(s,i);return o==-1?0:s[o+2]},e.U.getPairAdjustment=function(i,s,o){var a=!1;if(i.GPOS)for(var c=i.GPOS,l=c.lookupList,u=c.featureList,h=[],f=0;f<u.length;f++){var d=u[f];if(d.tag=="kern"){a=!0;for(var m=0;m<d.tab.length;m++)if(!h[d.tab[m]]){h[d.tab[m]]=!0;for(var v=l[d.tab[m]],g=0;g<v.tabs.length;g++)if(v.tabs[g]!=null){var p,_=v.tabs[g];if((!_.coverage||(p=e._lctf.coverageIndex(_.coverage,s))!=-1)&&v.ltype!=1){if(v.ltype==2){var y=null;if(_.fmt==1){var x=_.pairsets[p];for(f=0;f<x.length;f++)x[f].gid2==o&&(y=x[f])}else if(_.fmt==2){var b=e.U._getGlyphClass(s,_.classDef1),w=e.U._getGlyphClass(o,_.classDef2);y=_.matrix[b][w]}if(y){var S=0;return y.val1&&y.val1[2]&&(S+=y.val1[2]),y.val2&&y.val2[0]&&(S+=y.val2[0]),S}}}}}}}if(i.kern&&!a){var M=i.kern.glyph1.indexOf(s);if(M!=-1){var E=i.kern.rval[M].glyph2.indexOf(o);if(E!=-1)return i.kern.rval[M].vals[E]}}return 0},e.U._applySubs=function(i,s,o,a){for(var c=i.length-s-1,l=0;l<o.tabs.length;l++)if(o.tabs[l]!=null){var u,h=o.tabs[l];if(!h.coverage||(u=e._lctf.coverageIndex(h.coverage,i[s]))!=-1){if(o.ltype==1)i[s],h.fmt==1?i[s]=i[s]+h.delta:i[s]=h.newg[u];else if(o.ltype==4)for(var f=h.vals[u],d=0;d<f.length;d++){var m=f[d],v=m.chain.length;if(!(v>c)){for(var g=!0,p=0,_=0;_<v;_++){for(;i[s+p+(1+_)]==-1;)p++;m.chain[_]!=i[s+p+(1+_)]&&(g=!1)}if(g){for(i[s]=m.nglyph,_=0;_<v+p;_++)i[s+_+1]=-1;break}}}else if(o.ltype==5&&h.fmt==2)for(var y=e._lctf.getInterval(h.cDef,i[s]),x=h.cDef[y+2],b=h.scset[x],w=0;w<b.length;w++){var S=b[w],M=S.input;if(!(M.length>c)){for(g=!0,_=0;_<M.length;_++){var E=e._lctf.getInterval(h.cDef,i[s+1+_]);if(y==-1&&h.cDef[E+2]!=M[_]){g=!1;break}}if(g){var T=S.substLookupRecords;for(d=0;d<T.length;d+=2)T[d],T[d+1]}}}else if(o.ltype==6&&h.fmt==3){if(!e.U._glsCovered(i,h.backCvg,s-h.backCvg.length)||!e.U._glsCovered(i,h.inptCvg,s)||!e.U._glsCovered(i,h.ahedCvg,s+h.inptCvg.length))continue;var L=h.lookupRec;for(w=0;w<L.length;w+=2){y=L[w];var P=a[L[w+1]];e.U._applySubs(i,s+y,P,a)}}}}},e.U._glsCovered=function(i,s,o){for(var a=0;a<s.length;a++)if(e._lctf.coverageIndex(s[a],i[o+a])==-1)return!1;return!0},e.U.glyphsToPath=function(i,s,o){for(var a={cmds:[],crds:[]},c=0,l=0;l<s.length;l++){var u=s[l];if(u!=-1){for(var h=l<s.length-1&&s[l+1]!=-1?s[l+1]:0,f=e.U.glyphToPath(i,u),d=0;d<f.crds.length;d+=2)a.crds.push(f.crds[d]+c),a.crds.push(f.crds[d+1]);for(o&&a.cmds.push(o),d=0;d<f.cmds.length;d++)a.cmds.push(f.cmds[d]);o&&a.cmds.push("X"),c+=i.hmtx.aWidth[u],l<s.length-1&&(c+=e.U.getPairAdjustment(i,u,h))}}return a},e.U.P={},e.U.P.moveTo=function(i,s,o){i.cmds.push("M"),i.crds.push(s,o)},e.U.P.lineTo=function(i,s,o){i.cmds.push("L"),i.crds.push(s,o)},e.U.P.curveTo=function(i,s,o,a,c,l,u){i.cmds.push("C"),i.crds.push(s,o,a,c,l,u)},e.U.P.qcurveTo=function(i,s,o,a,c){i.cmds.push("Q"),i.crds.push(s,o,a,c)},e.U.P.closePath=function(i){i.cmds.push("Z")},e.U._drawCFF=function(i,s,o,a,c){for(var l=s.stack,u=s.nStems,h=s.haveWidth,f=s.width,d=s.open,m=0,v=s.x,g=s.y,p=0,_=0,y=0,x=0,b=0,w=0,S=0,M=0,E=0,T=0,L={val:0,size:0};m<i.length;){e.CFF.getCharString(i,m,L);var P=L.val;if(m+=L.size,P=="o1"||P=="o18")l.length%2!=0&&!h&&(f=l.shift()+a.nominalWidthX),u+=l.length>>1,l.length=0,h=!0;else if(P=="o3"||P=="o23")l.length%2!=0&&!h&&(f=l.shift()+a.nominalWidthX),u+=l.length>>1,l.length=0,h=!0;else if(P=="o4")l.length>1&&!h&&(f=l.shift()+a.nominalWidthX,h=!0),d&&e.U.P.closePath(c),g+=l.pop(),e.U.P.moveTo(c,v,g),d=!0;else if(P=="o5")for(;l.length>0;)v+=l.shift(),g+=l.shift(),e.U.P.lineTo(c,v,g);else if(P=="o6"||P=="o7")for(var A=l.length,z=P=="o6",V=0;V<A;V++){var N=l.shift();z?v+=N:g+=N,z=!z,e.U.P.lineTo(c,v,g)}else if(P=="o8"||P=="o24"){A=l.length;for(var C=0;C+6<=A;)p=v+l.shift(),_=g+l.shift(),y=p+l.shift(),x=_+l.shift(),v=y+l.shift(),g=x+l.shift(),e.U.P.curveTo(c,p,_,y,x,v,g),C+=6;P=="o24"&&(v+=l.shift(),g+=l.shift(),e.U.P.lineTo(c,v,g))}else{if(P=="o11")break;if(P=="o1234"||P=="o1235"||P=="o1236"||P=="o1237")P=="o1234"&&(_=g,y=(p=v+l.shift())+l.shift(),T=x=_+l.shift(),w=x,M=g,v=(S=(b=(E=y+l.shift())+l.shift())+l.shift())+l.shift(),e.U.P.curveTo(c,p,_,y,x,E,T),e.U.P.curveTo(c,b,w,S,M,v,g)),P=="o1235"&&(p=v+l.shift(),_=g+l.shift(),y=p+l.shift(),x=_+l.shift(),E=y+l.shift(),T=x+l.shift(),b=E+l.shift(),w=T+l.shift(),S=b+l.shift(),M=w+l.shift(),v=S+l.shift(),g=M+l.shift(),l.shift(),e.U.P.curveTo(c,p,_,y,x,E,T),e.U.P.curveTo(c,b,w,S,M,v,g)),P=="o1236"&&(p=v+l.shift(),_=g+l.shift(),y=p+l.shift(),T=x=_+l.shift(),w=x,S=(b=(E=y+l.shift())+l.shift())+l.shift(),M=w+l.shift(),v=S+l.shift(),e.U.P.curveTo(c,p,_,y,x,E,T),e.U.P.curveTo(c,b,w,S,M,v,g)),P=="o1237"&&(p=v+l.shift(),_=g+l.shift(),y=p+l.shift(),x=_+l.shift(),E=y+l.shift(),T=x+l.shift(),b=E+l.shift(),w=T+l.shift(),S=b+l.shift(),M=w+l.shift(),Math.abs(S-v)>Math.abs(M-g)?v=S+l.shift():g=M+l.shift(),e.U.P.curveTo(c,p,_,y,x,E,T),e.U.P.curveTo(c,b,w,S,M,v,g));else if(P=="o14"){if(l.length>0&&!h&&(f=l.shift()+o.nominalWidthX,h=!0),l.length==4){var O=l.shift(),k=l.shift(),U=l.shift(),R=l.shift(),F=e.CFF.glyphBySE(o,U),H=e.CFF.glyphBySE(o,R);e.U._drawCFF(o.CharStrings[F],s,o,a,c),s.x=O,s.y=k,e.U._drawCFF(o.CharStrings[H],s,o,a,c)}d&&(e.U.P.closePath(c),d=!1)}else if(P=="o19"||P=="o20")l.length%2!=0&&!h&&(f=l.shift()+a.nominalWidthX),u+=l.length>>1,l.length=0,h=!0,m+=u+7>>3;else if(P=="o21")l.length>2&&!h&&(f=l.shift()+a.nominalWidthX,h=!0),g+=l.pop(),v+=l.pop(),d&&e.U.P.closePath(c),e.U.P.moveTo(c,v,g),d=!0;else if(P=="o22")l.length>1&&!h&&(f=l.shift()+a.nominalWidthX,h=!0),v+=l.pop(),d&&e.U.P.closePath(c),e.U.P.moveTo(c,v,g),d=!0;else if(P=="o25"){for(;l.length>6;)v+=l.shift(),g+=l.shift(),e.U.P.lineTo(c,v,g);p=v+l.shift(),_=g+l.shift(),y=p+l.shift(),x=_+l.shift(),v=y+l.shift(),g=x+l.shift(),e.U.P.curveTo(c,p,_,y,x,v,g)}else if(P=="o26")for(l.length%2&&(v+=l.shift());l.length>0;)p=v,_=g+l.shift(),v=y=p+l.shift(),g=(x=_+l.shift())+l.shift(),e.U.P.curveTo(c,p,_,y,x,v,g);else if(P=="o27")for(l.length%2&&(g+=l.shift());l.length>0;)_=g,y=(p=v+l.shift())+l.shift(),x=_+l.shift(),v=y+l.shift(),g=x,e.U.P.curveTo(c,p,_,y,x,v,g);else if(P=="o10"||P=="o29"){var Y=P=="o10"?a:o;if(l.length==0)console.debug("error: empty stack");else{var J=l.pop(),ie=Y.Subrs[J+Y.Bias];s.x=v,s.y=g,s.nStems=u,s.haveWidth=h,s.width=f,s.open=d,e.U._drawCFF(ie,s,o,a,c),v=s.x,g=s.y,u=s.nStems,h=s.haveWidth,f=s.width,d=s.open}}else if(P=="o30"||P=="o31"){var ne=l.length,ee=(C=0,P=="o31");for(C+=ne-(A=-3&ne);C<A;)ee?(_=g,y=(p=v+l.shift())+l.shift(),g=(x=_+l.shift())+l.shift(),A-C==5?(v=y+l.shift(),C++):v=y,ee=!1):(p=v,_=g+l.shift(),y=p+l.shift(),x=_+l.shift(),v=y+l.shift(),A-C==5?(g=x+l.shift(),C++):g=x,ee=!0),e.U.P.curveTo(c,p,_,y,x,v,g),C+=4}else{if((P+"").charAt(0)=="o")throw console.debug("Unknown operation: "+P,i),P;l.push(P)}}}s.x=v,s.y=g,s.nStems=u,s.haveWidth=h,s.width=f,s.open=d};var t=e,n={Typr:t};return r.Typr=t,r.default=n,Object.defineProperty(r,"__esModule",{value:!0}),r})({}).Typr}/*!
|
|
Custom bundle of woff2otf (https://github.com/arty-name/woff2otf) with fflate
|
|
(https://github.com/101arrowz/fflate) for use in Troika text rendering.
|
|
Original licenses apply:
|
|
- fflate: https://github.com/101arrowz/fflate/blob/master/LICENSE (MIT)
|
|
- woff2otf.js: https://github.com/arty-name/woff2otf/blob/master/woff2otf.js (Apache2)
|
|
*/function AN(){return(function(r){var e=Uint8Array,t=Uint16Array,n=Uint32Array,i=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=function(P,A){for(var z=new t(31),V=0;V<31;++V)z[V]=A+=1<<P[V-1];var N=new n(z[30]);for(V=1;V<30;++V)for(var C=z[V];C<z[V+1];++C)N[C]=C-z[V]<<5|V;return[z,N]},c=a(i,2),l=c[0],u=c[1];l[28]=258,u[258]=28;for(var h=a(s,0)[0],f=new t(32768),d=0;d<32768;++d){var m=(43690&d)>>>1|(21845&d)<<1;m=(61680&(m=(52428&m)>>>2|(13107&m)<<2))>>>4|(3855&m)<<4,f[d]=((65280&m)>>>8|(255&m)<<8)>>>1}var v=function(P,A,z){for(var V=P.length,N=0,C=new t(A);N<V;++N)++C[P[N]-1];var O,k=new t(A);for(N=0;N<A;++N)k[N]=k[N-1]+C[N-1]<<1;{O=new t(1<<A);var U=15-A;for(N=0;N<V;++N)if(P[N])for(var R=N<<4|P[N],F=A-P[N],H=k[P[N]-1]++<<F,Y=H|(1<<F)-1;H<=Y;++H)O[f[H]>>>U]=R}return O},g=new e(288);for(d=0;d<144;++d)g[d]=8;for(d=144;d<256;++d)g[d]=9;for(d=256;d<280;++d)g[d]=7;for(d=280;d<288;++d)g[d]=8;var p=new e(32);for(d=0;d<32;++d)p[d]=5;var _=v(g,9),y=v(p,5),x=function(P){for(var A=P[0],z=1;z<P.length;++z)P[z]>A&&(A=P[z]);return A},b=function(P,A,z){var V=A/8|0;return(P[V]|P[V+1]<<8)>>(7&A)&z},w=function(P,A){var z=A/8|0;return(P[z]|P[z+1]<<8|P[z+2]<<16)>>(7&A)},S=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],M=function(P,A,z){var V=new Error(A||S[P]);if(V.code=P,Error.captureStackTrace&&Error.captureStackTrace(V,M),!z)throw V;return V},E=function(P,A,z){var V=P.length;if(!V||z&&!z.l&&V<5)return A||new e(0);var N=!A||z,C=!z||z.i;z||(z={}),A||(A=new e(3*V));var O,k=function(Ee){var De=A.length;if(Ee>De){var Ve=new e(Math.max(2*De,Ee));Ve.set(A),A=Ve}},U=z.f||0,R=z.p||0,F=z.b||0,H=z.l,Y=z.d,J=z.m,ie=z.n,ne=8*V;do{if(!H){z.f=U=b(P,R,1);var ee=b(P,R+1,3);if(R+=3,!ee){var ge=P[(xe=((O=R)/8|0)+(7&O&&1)+4)-4]|P[xe-3]<<8,me=xe+ge;if(me>V){C&&M(0);break}N&&k(F+ge),A.set(P.subarray(xe,me),F),z.b=F+=ge,z.p=R=8*me;continue}if(ee==1)H=_,Y=y,J=9,ie=5;else if(ee==2){var te=b(P,R,31)+257,D=b(P,R+10,15)+4,Q=te+b(P,R+5,31)+1;R+=14;for(var j=new e(Q),K=new e(19),W=0;W<D;++W)K[o[W]]=b(P,R+3*W,7);R+=3*D;var ye=x(K),re=(1<<ye)-1,fe=v(K,ye);for(W=0;W<Q;){var xe,ce=fe[b(P,R,re)];if(R+=15&ce,(xe=ce>>>4)<16)j[W++]=xe;else{var Pe=0,B=0;for(xe==16?(B=3+b(P,R,3),R+=2,Pe=j[W-1]):xe==17?(B=3+b(P,R,7),R+=3):xe==18&&(B=11+b(P,R,127),R+=7);B--;)j[W++]=Pe}}var I=j.subarray(0,te),$=j.subarray(te);J=x(I),ie=x($),H=v(I,J),Y=v($,ie)}else M(1);if(R>ne){C&&M(0);break}}N&&k(F+131072);for(var he=(1<<J)-1,de=(1<<ie)-1,pe=R;;pe=R){var Me=(Pe=H[w(P,R)&he])>>>4;if((R+=15&Pe)>ne){C&&M(0);break}if(Pe||M(2),Me<256)A[F++]=Me;else{if(Me==256){pe=R,H=null;break}var we=Me-254;if(Me>264){var ue=i[W=Me-257];we=b(P,R,(1<<ue)-1)+l[W],R+=ue}var Ce=Y[w(P,R)&de],ze=Ce>>>4;if(Ce||M(3),R+=15&Ce,$=h[ze],ze>3&&(ue=s[ze],$+=w(P,R)&(1<<ue)-1,R+=ue),R>ne){C&&M(0);break}N&&k(F+131072);for(var Le=F+we;F<Le;F+=4)A[F]=A[F-$],A[F+1]=A[F+1-$],A[F+2]=A[F+2-$],A[F+3]=A[F+3-$];F=Le}}z.l=H,z.p=pe,z.b=F,H&&(U=1,z.m=J,z.d=Y,z.n=ie)}while(!U);return F==A.length?A:(function(Ee,De,Ve){(Ve==null||Ve>Ee.length)&&(Ve=Ee.length);var je=new(Ee instanceof t?t:Ee instanceof n?n:e)(Ve-De);return je.set(Ee.subarray(De,Ve)),je})(A,0,F)},T=new e(0),L=typeof TextDecoder<"u"&&new TextDecoder;try{L.decode(T,{stream:!0})}catch{}return r.convert_streams=function(P){var A=new DataView(P),z=0;function V(){var te=A.getUint16(z);return z+=2,te}function N(){var te=A.getUint32(z);return z+=4,te}function C(te){ge.setUint16(me,te),me+=2}function O(te){ge.setUint32(me,te),me+=4}for(var k={signature:N(),flavor:N(),length:N(),numTables:V(),reserved:V(),totalSfntSize:N(),majorVersion:V(),minorVersion:V(),metaOffset:N(),metaLength:N(),metaOrigLength:N(),privOffset:N(),privLength:N()},U=0;Math.pow(2,U)<=k.numTables;)U++;U--;for(var R=16*Math.pow(2,U),F=16*k.numTables-R,H=12,Y=[],J=0;J<k.numTables;J++)Y.push({tag:N(),offset:N(),compLength:N(),origLength:N(),origChecksum:N()}),H+=16;var ie,ne=new Uint8Array(12+16*Y.length+Y.reduce((function(te,D){return te+D.origLength+4}),0)),ee=ne.buffer,ge=new DataView(ee),me=0;return O(k.flavor),C(k.numTables),C(R),C(U),C(F),Y.forEach((function(te){O(te.tag),O(te.origChecksum),O(H),O(te.origLength),te.outOffset=H,(H+=te.origLength)%4!=0&&(H+=4-H%4)})),Y.forEach((function(te){var D,Q=P.slice(te.offset,te.offset+te.compLength);if(te.compLength!=te.origLength){var j=new Uint8Array(te.origLength);D=new Uint8Array(Q,2),E(D,j)}else j=new Uint8Array(Q);ne.set(j,te.outOffset);var K=0;(H=te.outOffset+te.origLength)%4!=0&&(K=4-H%4),ne.set(new Uint8Array(K).buffer,te.outOffset+te.origLength),ie=H+K})),ee.slice(0,ie)},Object.defineProperty(r,"__esModule",{value:!0}),r})({}).convert_streams}function CN(r,e){const t={M:2,L:2,Q:4,C:6,Z:0},n={C:"18g,ca,368,1kz",D:"17k,6,2,2+4,5+c,2+6,2+1,10+1,9+f,j+11,2+1,a,2,2+1,15+2,3,j+2,6+3,2+8,2,2,2+1,w+a,4+e,3+3,2,3+2,3+5,23+w,2f+4,3,2+9,2,b,2+3,3,1k+9,6+1,3+1,2+2,2+d,30g,p+y,1,1+1g,f+x,2,sd2+1d,jf3+4,f+3,2+4,2+2,b+3,42,2,4+2,2+1,2,3,t+1,9f+w,2,el+2,2+g,d+2,2l,2+1,5,3+1,2+1,2,3,6,16wm+1v",R:"17m+3,2,2,6+3,m,15+2,2+2,h+h,13,3+8,2,2,3+1,2,p+1,x,5+4,5,a,2,2,3,u,c+2,g+1,5,2+1,4+1,5j,6+1,2,b,2+2,f,2+1,1s+2,2,3+1,7,1ez0,2,2+1,4+4,b,4,3,b,42,2+2,4,3,2+1,2,o+3,ae,ep,x,2o+2,3+1,3,5+1,6",L:"x9u,jff,a,fd,jv",T:"4t,gj+33,7o+4,1+1,7c+18,2,2+1,2+1,2,21+a,2,1b+k,h,2u+6,3+5,3+1,2+3,y,2,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,3,7,6+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+d,1,1+1,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,ek,3+1,r+4,1e+4,6+5,2p+c,1+3,1,1+2,1+b,2db+2,3y,2p+v,ff+3,30+1,n9x,1+2,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,5s,6y+2,ea,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+9,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2,2b+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,470+8,at4+4,1o+6,t5,1s+3,2a,f5l+1,2+3,43o+2,a+7,1+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,1,gzau,v+2n,3l+6n"},i=1,s=2,o=4,a=8,c=16,l=32;let u;function h(b){if(!u){const w={R:s,L:i,D:o,C:c,U:l,T:a};u=new Map;for(let S in n){let M=0;n[S].split(",").forEach(E=>{let[T,L]=E.split("+");T=parseInt(T,36),L=L?parseInt(L,36):0,u.set(M+=T,w[S]);for(let P=L;P--;)u.set(++M,w[S])})}}return u.get(b)||l}const f=1,d=2,m=3,v=4,g=[null,"isol","init","fina","medi"];function p(b){const w=new Uint8Array(b.length);let S=l,M=f,E=-1;for(let T=0;T<b.length;T++){const L=b.codePointAt(T);let P=h(L)|0,A=f;P&a||(S&(i|o|c)?P&(s|o|c)?(A=m,(M===f||M===m)&&w[E]++):P&(i|l)&&(M===d||M===v)&&w[E]--:S&(s|l)&&(M===d||M===v)&&w[E]--,M=w[T]=A,S=P,E=T,L>65535&&T++)}return w}function _(b,w){const S=[];for(let E=0;E<w.length;E++){const T=w.codePointAt(E);T>65535&&E++,S.push(r.U.codeToGlyph(b,T))}const M=b.GSUB;if(M){const{lookupList:E,featureList:T}=M;let L;const P=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws)$/,A=[];T.forEach(z=>{if(P.test(z.tag))for(let V=0;V<z.tab.length;V++){if(A[z.tab[V]])continue;A[z.tab[V]]=!0;const N=E[z.tab[V]],C=/^(isol|init|fina|medi)$/.test(z.tag);C&&!L&&(L=p(w));for(let O=0;O<S.length;O++)(!L||!C||g[L[O]]===z.tag)&&r.U._applySubs(S,O,N,E)}})}return S}function y(...b){for(let w=0;w<b.length;w++)if(typeof b[w]=="number")return b[w]}function x(b){const w=Object.create(null),S=b["OS/2"],M=b.hhea,E=b.head.unitsPerEm,T=y(S&&S.sTypoAscender,M&&M.ascender,E),L={unitsPerEm:E,ascender:T,descender:y(S&&S.sTypoDescender,M&&M.descender,0),capHeight:y(S&&S.sCapHeight,T),xHeight:y(S&&S.sxHeight,T),lineGap:y(S&&S.sTypoLineGap,M&&M.lineGap),forEachGlyph(P,A,z,V){let N=0;const C=1/L.unitsPerEm*A,O=_(b,P);let k=0,U=-1;return O.forEach((R,F)=>{if(R!==-1){let H=w[R];if(!H){const{cmds:Y,crds:J}=r.U.glyphToPath(b,R);let ie="",ne=0;for(let D=0,Q=Y.length;D<Q;D++){const j=t[Y[D]];ie+=Y[D];for(let K=1;K<=j;K++)ie+=(K>1?",":"")+J[ne++]}let ee,ge,me,te;if(J.length){ee=ge=1/0,me=te=-1/0;for(let D=0,Q=J.length;D<Q;D+=2){let j=J[D],K=J[D+1];j<ee&&(ee=j),K<ge&&(ge=K),j>me&&(me=j),K>te&&(te=K)}}else ee=me=ge=te=0;H=w[R]={index:R,advanceWidth:b.hmtx.aWidth[R],xMin:ee,yMin:ge,xMax:me,yMax:te,path:ie,pathCommandCount:Y.length}}U!==-1&&(N+=r.U.getPairAdjustment(b,U,R)*C),V.call(null,H,N,k),H.advanceWidth&&(N+=H.advanceWidth*C),z&&(N+=z*A),U=R}k+=P.codePointAt(k)>65535?2:1}),N}};return L}return function(w){const S=new Uint8Array(w,0,4),M=r._bin.readASCII(S,0,4);if(M==="wOFF")w=e(w);else if(M==="wOF2")throw new Error("woff2 fonts not supported");return x(r.parse(w)[0])}}const RN=Gc({name:"Typr Font Parser",dependencies:[TN,AN,CN],init(r,e,t){const n=r(),i=e();return t(n,i)}}),bo={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff",sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},PN=new Ne;function fo(){return(self.performance||Date).now()}const uy=Object.create(null);function Sw(r,e){r=IN({},r);const t=fo();if(r.font=UN(r.font||bo.defaultFontURL),r.text=""+r.text,r.sdfGlyphSize=r.sdfGlyphSize||bo.sdfGlyphSize,r.colorRanges!=null){let h={};for(let f in r.colorRanges)if(r.colorRanges.hasOwnProperty(f)){let d=r.colorRanges[f];typeof d!="number"&&(d=PN.set(d).getHex()),h[f]=d}r.colorRanges=h}Object.freeze(r);const{textureWidth:n,sdfExponent:i}=bo,{sdfGlyphSize:s}=r,o=n/s*4;let a=uy[s];if(!a){const h=document.createElement("canvas");h.width=n,h.height=s*256/o,a=uy[s]={glyphCount:0,sdfGlyphSize:s,sdfCanvas:h,sdfTexture:new Ft(h,void 0,void 0,void 0,Pt,Pt),contextLost:!1,glyphsByFont:new Map},a.sdfTexture.generateMipmaps=!1,LN(a)}const{sdfTexture:c,sdfCanvas:l}=a;let u=a.glyphsByFont.get(r.font);u||a.glyphsByFont.set(r.font,u=new Map),NN(r).then(h=>{const{glyphIds:f,glyphPositions:d,fontSize:m,unitsPerEm:v,timings:g}=h,p=[],_=new Float32Array(f.length*4),y=m/v;let x=0,b=0;const w=fo();f.forEach((L,P)=>{let A=u.get(L);if(!A){const{path:C,pathBounds:O}=h.glyphData[L],k=Math.max(O[2]-O[0],O[3]-O[1])/s*(bo.sdfMargin*s+.5),U=a.glyphCount++,R=[O[0]-k,O[1]-k,O[2]+k,O[3]+k];u.set(L,A={path:C,atlasIndex:U,sdfViewBox:R}),p.push(A)}const{sdfViewBox:z}=A,V=d[b++],N=d[b++];_[x++]=V+z[0]*y,_[x++]=N+z[1]*y,_[x++]=V+z[2]*y,_[x++]=N+z[3]*y,f[P]=A.atlasIndex}),g.quads=(g.quads||0)+(fo()-w);const S=fo();g.sdf={};const M=l.height,E=Math.ceil(a.glyphCount/o),T=Math.pow(2,Math.ceil(Math.log2(E*s)));T>M&&(console.info(`Increasing SDF texture size ${M}->${T}`),MN(l,n,T),c.dispose()),Promise.all(p.map(L=>Ew(L,a,r.gpuAccelerateSDF).then(({timing:P})=>{g.sdf[L.atlasIndex]=P}))).then(()=>{p.length&&!a.contextLost&&(Mw(a),c.needsUpdate=!0),g.sdfTotal=fo()-S,g.total=fo()-t,e(Object.freeze({parameters:r,sdfTexture:c,sdfGlyphSize:s,sdfExponent:i,glyphBounds:_,glyphAtlasIndices:f,glyphColors:h.glyphColors,caretPositions:h.caretPositions,caretHeight:h.caretHeight,chunkedBounds:h.chunkedBounds,ascender:h.ascender,descender:h.descender,lineHeight:h.lineHeight,capHeight:h.capHeight,xHeight:h.xHeight,topBaseline:h.topBaseline,blockBounds:h.blockBounds,visibleBounds:h.visibleBounds,timings:h.timings}))})}),Promise.resolve().then(()=>{a.contextLost||EN(l)})}function Ew({path:r,atlasIndex:e,sdfViewBox:t},{sdfGlyphSize:n,sdfCanvas:i,contextLost:s},o){if(s)return Promise.resolve({timing:-1});const{textureWidth:a,sdfExponent:c}=bo,l=Math.max(t[2]-t[0],t[3]-t[1]),u=Math.floor(e/4),h=u%(a/n)*n,f=Math.floor(u/(a/n))*n,d=e%4;return _N(n,n,r,t,l,c,i,h,f,d,o)}function LN(r){const e=r.sdfCanvas;e.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),r.contextLost=!0}),e.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),r.contextLost=!1;const n=[];r.glyphsByFont.forEach(i=>{i.forEach(s=>{n.push(Ew(s,r,!0))})}),Promise.all(n).then(()=>{Mw(r),r.sdfTexture.needsUpdate=!0})})}function DN({font:r,characters:e,sdfGlyphSize:t},n){let i=Array.isArray(e)?e.join(`
|
|
`):""+e;Sw({font:r,sdfGlyphSize:t,text:i},n)}function IN(r,e){for(let t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}let Kl;function UN(r){return Kl||(Kl=typeof document>"u"?{}:document.createElement("a")),Kl.href=r,Kl.href}function Mw(r){if(typeof createImageBitmap!="function"){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:t}=r,{width:n,height:i}=e,s=r.sdfCanvas.getContext("webgl");let o=t.image.data;(!o||o.length!==n*i*4)&&(o=new Uint8Array(n*i*4),t.image={width:n,height:i,data:o},t.flipY=!1,t.isDataTexture=!0),s.readPixels(0,0,n,i,s.RGBA,s.UNSIGNED_BYTE,o)}}const ON=Gc({name:"Typesetter",dependencies:[bo,RN,vN,_E],init(r,e,t,n){const{defaultFontURL:i}=r;return t(e,n(),{defaultFontURL:i})}}),NN=Gc({name:"Typesetter",dependencies:[ON],init(r){return function(e){return new Promise(t=>{r.typeset(e,t)})}},getTransferables(r){const e=[r.glyphPositions.buffer,r.glyphIds.buffer];return r.caretPositions&&e.push(r.caretPositions.buffer),r.glyphColors&&e.push(r.glyphColors.buffer),e}}),hy={};function FN(r){let e=hy[r];if(!e){const t=new Nr(1,1,r,r),n=t.clone(),i=t.attributes,s=n.attributes,o=new st,a=i.uv.count;for(let c=0;c<a;c++)s.position.array[c*3]*=-1,s.normal.array[c*3+2]*=-1;["position","normal","uv"].forEach(c=>{o.setAttribute(c,new He([...i[c].array,...s[c].array],i[c].itemSize))}),o.setIndex([...t.index.array,...n.index.array.map(c=>c+a)]),o.translate(.5,.5,0),e=hy[r]=o}return e}const kN="aTroikaGlyphBounds",fy="aTroikaGlyphIndex",zN="aTroikaGlyphColor";class BN extends Am{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new Wn,this.boundingBox=new Hn}computeBoundingSphere(){}computeBoundingBox(){}setSide(e){const t=this.getIndex().count;this.setDrawRange(e===vn?t/2:0,e===Dt?t:t/2)}set detail(e){if(e!==this._detail){this._detail=e,(typeof e!="number"||e<1)&&(e=1);let t=FN(e);["position","normal","uv"].forEach(n=>{this.attributes[n]=t.attributes[n].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,n,i,s){Ed(this,kN,e,4),Ed(this,fy,t,1),Ed(this,zN,s,3),this._blockBounds=n,this._chunkedBounds=i,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:n}=this;if(t){const{PI:i,floor:s,min:o,max:a,sin:c,cos:l}=Math,u=i/2,h=i*2,f=Math.abs(t),d=e[0]/f,m=e[2]/f,v=s((d+u)/h)!==s((m+u)/h)?-f:o(c(d)*f,c(m)*f),g=s((d-u)/h)!==s((m-u)/h)?f:a(c(d)*f,c(m)*f),p=s((d+i)/h)!==s((m+i)/h)?f*2:a(f-l(d)*f,f-l(m)*f);n.min.set(v,e[1],t<0?-p:0),n.max.set(g,e[3],t<0?0:p)}else n.min.set(e[0],e[1],0),n.max.set(e[2],e[3],0);n.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(fy).count,n=this._chunkedBounds;if(n)for(let i=n.length;i--;){t=n[i].end;let s=n[i].rect;if(s[1]<e.w&&s[3]>e.y&&s[0]<e.z&&s[2]>e.x)break}this.instanceCount=t}}function Ed(r,e,t,n){const i=r.getAttribute(e);t?i&&i.array.length===t.length?(i.array.set(t),i.needsUpdate=!0):(r.setAttribute(e,new vs(t,n)),delete r._maxInstanceCount,r.dispose()):i&&r.deleteAttribute(e)}const GN=`
|
|
uniform vec2 uTroikaSDFTextureSize;
|
|
uniform float uTroikaSDFGlyphSize;
|
|
uniform vec4 uTroikaTotalBounds;
|
|
uniform vec4 uTroikaClipRect;
|
|
uniform mat3 uTroikaOrient;
|
|
uniform bool uTroikaUseGlyphColors;
|
|
uniform float uTroikaDistanceOffset;
|
|
uniform float uTroikaBlurRadius;
|
|
uniform vec2 uTroikaPositionOffset;
|
|
uniform float uTroikaCurveRadius;
|
|
attribute vec4 aTroikaGlyphBounds;
|
|
attribute float aTroikaGlyphIndex;
|
|
attribute vec3 aTroikaGlyphColor;
|
|
varying vec2 vTroikaGlyphUV;
|
|
varying vec4 vTroikaTextureUVBounds;
|
|
varying float vTroikaTextureChannel;
|
|
varying vec3 vTroikaGlyphColor;
|
|
varying vec2 vTroikaGlyphDimensions;
|
|
`,VN=`
|
|
vec4 bounds = aTroikaGlyphBounds;
|
|
bounds.xz += uTroikaPositionOffset.x;
|
|
bounds.yw -= uTroikaPositionOffset.y;
|
|
|
|
vec4 outlineBounds = vec4(
|
|
bounds.xy - uTroikaDistanceOffset - uTroikaBlurRadius,
|
|
bounds.zw + uTroikaDistanceOffset + uTroikaBlurRadius
|
|
);
|
|
vec4 clippedBounds = vec4(
|
|
clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw),
|
|
clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw)
|
|
);
|
|
|
|
vec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy);
|
|
|
|
position.xy = mix(bounds.xy, bounds.zw, clippedXY);
|
|
|
|
uv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy);
|
|
|
|
float rad = uTroikaCurveRadius;
|
|
if (rad != 0.0) {
|
|
float angle = position.x / rad;
|
|
position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad);
|
|
normal.xz = vec2(sin(angle), cos(angle));
|
|
}
|
|
|
|
position = uTroikaOrient * position;
|
|
normal = uTroikaOrient * normal;
|
|
|
|
vTroikaGlyphUV = clippedXY.xy;
|
|
vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
|
|
|
|
float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;
|
|
vec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;
|
|
vec2 txStartUV = txUvPerSquare * vec2(
|
|
mod(floor(aTroikaGlyphIndex / 4.0), txCols),
|
|
floor(floor(aTroikaGlyphIndex / 4.0) / txCols)
|
|
);
|
|
vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare);
|
|
vTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0);
|
|
`,HN=`
|
|
uniform sampler2D uTroikaSDFTexture;
|
|
uniform vec2 uTroikaSDFTextureSize;
|
|
uniform float uTroikaSDFGlyphSize;
|
|
uniform float uTroikaSDFExponent;
|
|
uniform float uTroikaDistanceOffset;
|
|
uniform float uTroikaFillOpacity;
|
|
uniform float uTroikaOutlineOpacity;
|
|
uniform float uTroikaBlurRadius;
|
|
uniform vec3 uTroikaStrokeColor;
|
|
uniform float uTroikaStrokeWidth;
|
|
uniform float uTroikaStrokeOpacity;
|
|
uniform bool uTroikaSDFDebug;
|
|
varying vec2 vTroikaGlyphUV;
|
|
varying vec4 vTroikaTextureUVBounds;
|
|
varying float vTroikaTextureChannel;
|
|
varying vec2 vTroikaGlyphDimensions;
|
|
|
|
float troikaSdfValueToSignedDistance(float alpha) {
|
|
// Inverse of exponential encoding in webgl-sdf-generator
|
|
|
|
float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y);
|
|
float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension;
|
|
float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0);
|
|
return signedDist;
|
|
}
|
|
|
|
float troikaGlyphUvToSdfValue(vec2 glyphUV) {
|
|
vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);
|
|
vec4 rgba = texture2D(uTroikaSDFTexture, textureUV);
|
|
float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1
|
|
return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a;
|
|
}
|
|
|
|
float troikaGlyphUvToDistance(vec2 uv) {
|
|
return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv));
|
|
}
|
|
|
|
float troikaGetAADist() {
|
|
|
|
#if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300
|
|
return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5;
|
|
#else
|
|
return vTroikaGlyphDimensions.x / 64.0;
|
|
#endif
|
|
}
|
|
|
|
float troikaGetFragDistValue() {
|
|
vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize);
|
|
float distance = troikaGlyphUvToDistance(clampedGlyphUV);
|
|
|
|
// Extrapolate distance when outside bounds:
|
|
distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 :
|
|
length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions);
|
|
|
|
|
|
|
|
return distance;
|
|
}
|
|
|
|
float troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) {
|
|
#if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)
|
|
float alpha = step(-distanceOffset, -distance);
|
|
#else
|
|
|
|
float alpha = smoothstep(
|
|
distanceOffset + aaDist,
|
|
distanceOffset - aaDist,
|
|
distance
|
|
);
|
|
#endif
|
|
|
|
return alpha;
|
|
}
|
|
`,WN=`
|
|
float aaDist = troikaGetAADist();
|
|
float fragDistance = troikaGetFragDistValue();
|
|
float edgeAlpha = uTroikaSDFDebug ?
|
|
troikaGlyphUvToSdfValue(vTroikaGlyphUV) :
|
|
troikaGetEdgeAlpha(fragDistance, uTroikaDistanceOffset, max(aaDist, uTroikaBlurRadius));
|
|
|
|
#if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL)
|
|
vec4 fillRGBA = gl_FragColor;
|
|
fillRGBA.a *= uTroikaFillOpacity;
|
|
vec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity);
|
|
if (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb;
|
|
gl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep(
|
|
-uTroikaStrokeWidth - aaDist,
|
|
-uTroikaStrokeWidth + aaDist,
|
|
fragDistance
|
|
));
|
|
gl_FragColor.a *= edgeAlpha;
|
|
#endif
|
|
|
|
if (edgeAlpha == 0.0) {
|
|
discard;
|
|
}
|
|
`;function XN(r){const e=zp(r,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new be},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new mt(0,0,0,0)},uTroikaClipRect:{value:new mt(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new be},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new Ne},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new rt},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:GN,vertexTransform:VN,fragmentDefs:HN,fragmentColorTransform:WN,customRewriter({vertexShader:t,fragmentShader:n}){let i=/\buniform\s+vec3\s+diffuse\b/;return i.test(n)&&(n=n.replace(i,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),i.test(t)||(t=t.replace(bw,`uniform vec3 diffuse;
|
|
$&
|
|
vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;
|
|
`))),{vertexShader:t,fragmentShader:n}}});return e.transparent=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const hg=new cr({color:16777215,side:Dt,transparent:!0}),dy=8421504,py=new Ke,Jl=new G,Md=new G,Da=[],qN=new G,Td="+x+y";function my(r){return Array.isArray(r)?r[0]:r}let Tw=()=>{const r=new Ot(new Nr(1,1),hg);return Tw=()=>r,r},Aw=()=>{const r=new Ot(new Nr(1,1,32,1),hg);return Aw=()=>r,r};const YN={type:"syncstart"},jN={type:"synccomplete"},Cw=["font","fontSize","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],$N=Cw.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let Rw=class extends Ot{constructor(){const e=new BN;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.fontSize=.1,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=dy,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=Td,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(YN),Sw({text:this.text,font:this.font,fontSize:this.fontSize||.1,letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const n=this._queuedSyncs;n&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{n.forEach(i=>i&&i())})),this.dispatchEvent(jN),e&&e()})))}onBeforeRender(e,t,n,i,s,o){this.sync(),s.isTroikaTextMaterial&&this._prepareForRender(s),s._hadOwnSide=s.hasOwnProperty("side"),this.geometry.setSide(s._actualSide=s.side),s.side=Oi}onAfterRender(e,t,n,i,s,o){s._hadOwnSide?s.side=s._actualSide:delete s.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=hg.clone());if((!e||e.baseMaterial!==t)&&(e=this._derivedMaterial=XN(t),t.addEventListener("dispose",function n(){t.removeEventListener("dispose",n),e.dispose()})),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let n=e._outlineMtl;return n||(n=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),n.isTextOutlineMaterial=!0,n.depthWrite=!1,n.map=null,e.addEventListener("dispose",function i(){e.removeEventListener("dispose",i),n.dispose()})),[n,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return my(this.material).getDepthMaterial()}get customDistanceMaterial(){return my(this.material).getDistanceMaterial()}_prepareForRender(e){const t=e.isTextOutlineMaterial,n=e.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:a,blockBounds:c}=i;n.uTroikaSDFTexture.value=a,n.uTroikaSDFTextureSize.value.set(a.image.width,a.image.height),n.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,n.uTroikaSDFExponent.value=i.sdfExponent,n.uTroikaTotalBounds.value.fromArray(c),n.uTroikaUseGlyphColors.value=!t&&!!i.glyphColors;let l=0,u=0,h=0,f,d,m,v=0,g=0;if(t){let{outlineWidth:_,outlineOffsetX:y,outlineOffsetY:x,outlineBlur:b,outlineOpacity:w}=this;l=this._parsePercent(_)||0,u=Math.max(0,this._parsePercent(b)||0),f=w,v=this._parsePercent(y)||0,g=this._parsePercent(x)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(m=this.strokeColor,n.uTroikaStrokeColor.value.set(m??dy),d=this.strokeOpacity,d==null&&(d=1)),f=this.fillOpacity;n.uTroikaDistanceOffset.value=l,n.uTroikaPositionOffset.value.set(v,g),n.uTroikaBlurRadius.value=u,n.uTroikaStrokeWidth.value=h,n.uTroikaStrokeOpacity.value=d,n.uTroikaFillOpacity.value=f??1,n.uTroikaCurveRadius.value=this.curveRadius||0;let p=this.clipRect;if(p&&Array.isArray(p)&&p.length===4)n.uTroikaClipRect.value.fromArray(p);else{const _=(this.fontSize||.1)*100;n.uTroikaClipRect.value.set(c[0]-_,c[1]-_,c[2]+_,c[3]+_)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const s=t?this.outlineColor||0:this.color;if(s==null)delete e.color;else{const a=e.hasOwnProperty("color")?e.color:e.color=new Ne;(s!==a._input||typeof s=="object")&&a.set(a._input=s)}let o=this.orientation||Td;if(o!==e._orientation){let a=n.uTroikaOrient.value;o=o.replace(/[^-+xyz]/g,"");let c=o!==Td&&o.match(/^([-+])([xyz])([-+])([xyz])$/);if(c){let[,l,u,h,f]=c;Jl.set(0,0,0)[u]=l==="-"?1:-1,Md.set(0,0,0)[f]=h==="-"?-1:1,py.lookAt(qN,Jl.cross(Md),Md),a.setFromMatrix4(py)}else a.identity();e._orientation=o}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),n=t?parseFloat(t[1]):NaN;e=(isNaN(n)?0:n/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new be){t.copy(e);const n=this.curveRadius;return n&&(t.x=Math.atan2(e.x,Math.abs(n)-Math.abs(e.z))*Math.abs(n)),t}worldPositionToTextCoords(e,t=new be){return Jl.copy(e),this.localPositionToTextCoords(this.worldToLocal(Jl),t)}raycast(e,t){const{textRenderInfo:n,curveRadius:i}=this;if(n){const s=n.blockBounds,o=i?Aw():Tw(),a=o.geometry,{position:c,uv:l}=a.attributes;for(let u=0;u<l.count;u++){let h=s[0]+l.getX(u)*(s[2]-s[0]);const f=s[1]+l.getY(u)*(s[3]-s[1]);let d=0;i&&(d=i-Math.cos(h/i)*i,h=Math.sin(h/i)*i),c.setXYZ(u,h,f,d)}a.boundingSphere=this.geometry.boundingSphere,a.boundingBox=this.geometry.boundingBox,o.matrixWorld=this.matrixWorld,o.material.side=this.material.side,Da.length=0,o.raycast(e,Da);for(let u=0;u<Da.length;u++)Da[u].object=this,t.push(Da[u])}}copy(e){const t=this.geometry;return super.copy(e),this.geometry=t,$N.forEach(n=>{this[n]=e[n]}),this}clone(){return new this.constructor().copy(this)}};Cw.forEach(r=>{const e="_private_"+r;Object.defineProperty(Rw.prototype,r,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});const ZN=q.forwardRef(({sdfGlyphSize:r=64,anchorX:e="center",anchorY:t="middle",font:n,fontSize:i=1,children:s,characters:o,onSync:a,...c},l)=>{const u=Kt(({invalidate:m})=>m),[h]=q.useState(()=>new Rw),[f,d]=q.useMemo(()=>{const m=[];let v="";return q.Children.forEach(s,g=>{typeof g=="string"||typeof g=="number"?v+=g:m.push(g)}),[m,v]},[s]);return rS(()=>new Promise(m=>DN({font:n,characters:o},m)),["troika-text",n,o]),q.useLayoutEffect(()=>void h.sync(()=>{u(),a&&a(h)})),q.useEffect(()=>()=>h.dispose(),[h]),q.createElement("primitive",Tc({object:h,ref:l,font:n,text:d,anchorX:e,anchorY:t,fontSize:i,sdfGlyphSize:r},c),f)});var Ia={exports:{}},gy;function KN(){if(gy)return Ia.exports;gy=1;var r={ellipse:"…",chars:[" ","-"],max:140,truncate:!0};function e(n,i,s,o){if(n<=i)return n;if(i<2)return n.slice(0,i-s.length)+s;for(var a=i-s.length,c=Math.floor(a/2),l=c,u=n.length-c,h=0;h<c;h++){var f=n.charAt(h),d=n.length-h,m=n.charAt(d);o.indexOf(f)!==-1&&(l=h),o.indexOf(m)!==-1&&(u=d)}return n.slice(0,l)+s+n.slice(u)}function t(n,i,s,o,a){if(n.length<=i)return n;for(var c=i-s.length,l=c,u=0;u<=c;u++){var h=n.charAt(u);o.indexOf(h)!==-1&&(l=u)}return!a&&l==c?"":n.slice(0,l)+s}return Ia.exports=function(n,i,s){if(typeof n!="string"||n.length===0||i===0)return"";s=s||{};for(var o in r)(s[o]===null||typeof s[o]>"u")&&(s[o]=r[o]);return s.max=i||s.max,s.truncate=="middle"?e(n,s.max,s.ellipse,s.chars):t(n,s.max,s.ellipse,s.chars,s.truncate)},Ia.exports.ellipsizeMiddle=e,Ia.exports.ellipsize=t,Ia.exports}var JN=KN();const QN=ki(JN);/*!
|
|
* hold-event
|
|
* https://github.com/yomotsu/hold-event
|
|
* (c) 2020 @yomotsu
|
|
* Released under the MIT License.
|
|
*/var Za;(function(r){r.HOLD_START="holdStart",r.HOLD_END="holdEnd",r.HOLDING="holding"})(Za||(Za={}));class eF{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}removeEventListener(e,t){const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e)}}}class tF extends eF{constructor(e){super(),this._enabled=!0,this._holding=!1,this._intervalId=-1,this._deltaTime=0,this._elapsedTime=0,this._lastTime=0,this._holdStart=t=>{if(!this._enabled||this._holding)return;this._deltaTime=0,this._elapsedTime=0,this._lastTime=performance.now(),this.dispatchEvent({type:Za.HOLD_START,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t}),this._holding=!0;const n=()=>{this._intervalId=this.holdIntervalDelay?window.setTimeout(n,this.holdIntervalDelay):window.requestAnimationFrame(n);const i=performance.now();this._deltaTime=i-this._lastTime,this._elapsedTime+=this._deltaTime,this._lastTime=performance.now(),this.dispatchEvent({type:Za.HOLDING,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t})};this._intervalId=this.holdIntervalDelay?window.setTimeout(n,this.holdIntervalDelay):window.requestAnimationFrame(n)},this._holdEnd=t=>{if(!this._enabled||!this._holding)return;const n=performance.now();this._deltaTime=n-this._lastTime,this._elapsedTime+=this._deltaTime,this._lastTime=performance.now(),this.dispatchEvent({type:Za.HOLD_END,deltaTime:this._deltaTime,elapsedTime:this._elapsedTime,originalEvent:t}),window.clearTimeout(this._intervalId),window.cancelAnimationFrame(this._intervalId),this._holding=!1},this.holdIntervalDelay=e}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._enabled||this._holdEnd())}}class Eh extends tF{constructor(e,t){super(t),this._holdStart=this._holdStart.bind(this),this._holdEnd=this._holdEnd.bind(this);const n=s=>{nF(s)||s.keyCode===e&&this._holdStart(s)},i=s=>{s.keyCode===e&&this._holdEnd(s)};document.addEventListener("keydown",n),document.addEventListener("keyup",i),window.addEventListener("blur",this._holdEnd)}}function nF(r){const e=r.target;return e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA"||e.isContentEditable}var Ad={exports:{}};/*!
|
|
Copyright (c) 2018 Jed Watson.
|
|
Licensed under the MIT License (MIT), see
|
|
http://jedwatson.github.io/classnames
|
|
*/var vy;function iF(){return vy||(vy=1,(function(r){(function(){var e={}.hasOwnProperty;function t(){for(var s="",o=0;o<arguments.length;o++){var a=arguments[o];a&&(s=i(s,n(a)))}return s}function n(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var a in s)e.call(s,a)&&s[a]&&(o=i(o,a));return o}function i(s,o){return o?s?s+" "+o:s+o:s}r.exports?(t.default=t,r.exports=t):window.classNames=t})()})(Ad)),Ad.exports}iF();(function(){try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(`._canvas_670zp_1 {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
}
|
|
._container_155l7_1 {
|
|
transform-origin: bottom right;
|
|
overflow: hidden;
|
|
position: absolute;
|
|
border: solid 1px var(--radial-menu-border);
|
|
}
|
|
|
|
._container_155l7_1._disabled_155l7_7 {
|
|
opacity: 0.6;
|
|
}
|
|
|
|
._container_155l7_1._disabled_155l7_7 ._contentContainer_155l7_10 {
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
._container_155l7_1:not(._disabled_155l7_7) ._contentContainer_155l7_10 {
|
|
cursor: pointer;
|
|
}
|
|
|
|
._container_155l7_1:not(._disabled_155l7_7) ._contentContainer_155l7_10:hover {
|
|
color: var(--radial-menu-active-color);
|
|
background: var(--radial-menu-active-background);
|
|
}
|
|
|
|
._container_155l7_1 ._contentContainer_155l7_10 {
|
|
width: 200%;
|
|
height: 200%;
|
|
transform-origin: 50% 50%;
|
|
border-radius: 50%;
|
|
outline: none;
|
|
transition: background 150ms ease-in-out;
|
|
color: var(--radial-menu-color);
|
|
}
|
|
|
|
._container_155l7_1 ._contentContainer_155l7_10 ._contentInner_155l7_35 {
|
|
position: absolute;
|
|
width: 100%;
|
|
text-align: center;
|
|
}
|
|
|
|
._container_155l7_1 ._contentContainer_155l7_10 ._contentInner_155l7_35 ._content_155l7_10 {
|
|
display: inline-block;
|
|
}
|
|
|
|
._container_155l7_1 svg {
|
|
margin: 0 auto;
|
|
fill: var(--radial-menu-active-color);
|
|
height: 25px;
|
|
width: 25px;
|
|
display: block;
|
|
}
|
|
._container_x9hyx_1 {
|
|
border-radius: 50%;
|
|
z-index: 9;
|
|
position: relative;
|
|
height: 175px;
|
|
width: 175px;
|
|
border: solid 5px var(--radial-menu-border);
|
|
overflow: hidden;
|
|
background: var(--radial-menu-background);
|
|
}
|
|
|
|
._container_x9hyx_1:before {
|
|
content: ' ';
|
|
background: var(--radial-menu-border);
|
|
border-radius: 50%;
|
|
height: 25px;
|
|
width: 25px;
|
|
position: absolute;
|
|
z-index: 9;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
}`)),document.head.appendChild(r)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var _y,yy;function Pw(r,e=[]){const t=e.length;for(const n of r){const i=e.indexOf(n);if(i>-1){const s=[...e.slice(i),n].map(o=>o.data.id);throw new Error(`Invalid Graph: Circular node path detected: ${s.join(" -> ")}.`)}t>n.depth&&(n.depth=t,Pw(n.out,[...e,n]))}}function Lw(r,e){let t=!1;const n=r.reduce((o,a)=>({...o,[a.id]:{data:a,out:[],depth:-1,ins:[]}}),{});try{for(const o of e){const a=o.source,c=o.target;if(!n.hasOwnProperty(a))throw new Error(`Missing source Node ${a}`);if(!n.hasOwnProperty(c))throw new Error(`Missing target Node ${c}`);const l=n[a],u=n[c];u.ins.push(l),l.out.push(u)}Pw(Object.values(n))}catch{t=!0}const i=Object.keys(n).map(o=>n[o].depth),s=Math.max(...i);return{invalid:t,depths:n,maxDepth:s||1}}const xy=["radialin","radialout"];function rF({nodes:r,edges:e,mode:t="lr",nodeLevelRatio:n=2}){const{depths:i,maxDepth:s,invalid:o}=Lw(r,e);if(o)return null;const a=xy.includes(t)?1:5,c=r.length/s*n*a;if(t){const l=(d,m)=>v=>d?(i[v.id].depth-s/2)*c*(m?-1:1):void 0,u=l(["lr","rl"].includes(t),t==="rl"),h=l(["td","bu"].includes(t),t==="td"),f=l(["zin","zout"].includes(t),t==="zout");r.forEach(d=>{d.fx=u(d),d.fy=h(d),d.fz=f(d)})}return xy.includes(t)?sI(l=>{const u=i[l.id];return(t==="radialin"?s-u.depth:u.depth)*c}).strength(1):null}function sF(r){return new Promise((e,t)=>{let n;function i(){n?e(n):(n=r.step(),i())}i()})}function Vc(r){const e=[],t=[];return r.forEachNode((n,i)=>{e.push({...i,id:n,radius:i.size||1})}),r.forEachEdge((n,i)=>{t.push({...i,id:n})}),{nodes:e,edges:t}}function oF(){const r=C=>()=>C;let t=C=>C.index,n=[],i=[],s,o,a=[100,100],c=r(1),l=r(-1),u=r(100),h=r(.1),f={},d=.1,m=.001,v=[],g=[0,0],p,_=C=>C.cluster,y="treemap",x=!0,b=.1;function w(C){if(!x)return w;y==="force"&&(p.tick(),A());for(let O=0,k=n.length,U,R=C*b;O<k;++O)U=n[O],U.vx+=(f[_(U)].x-U.x)*R,U.vy+=(f[_(U)].y-U.y)*R}function S(){n&&(y==="treemap"?z():N())}w.initialize=function(C){n=C,S()};function M(C){let O=_(C.source),k=_(C.target);return O<=k?O+"~"+k:k+"~"+O}function E(C){let O=new Map,k={};return C.forEach(function(U){O.has(_(U))||O.set(_(U),{count:0,sumforceNodeSize:0})}),C.forEach(function(U){k=O.get(_(U)),k.count=k.count+1,k.sumforceNodeSize=k.sumforceNodeSize+Math.PI*(c(U)*c(U))*1.3,O.set(_(U),k)}),O}function T(C){let O=new Map,k=[];return C.forEach(function(U){let R=M(U),F;O.has(R)?F=O.get(R):F=0,F+=1,O.set(R,F)}),O.forEach(function(U,R){let F,H;F=R.split("~")[0],H=R.split("~")[1],F!==void 0&&H!==void 0&&k.push({source:F,target:H,count:U})}),k}function L(){let C=[],O=[],k=new Map,U,R,F,H,Y;H=E(n),Y=T(i);for(U of H.keys())F=H.get(U),C.push({id:U,size:F.count,r:Math.sqrt(F.sumforceNodeSize/Math.PI)}),k.set(U,R);return Y.forEach(function(J){let ie=k.get(J.source),ne=k.get(J.target);ie!==void 0&&ne!==void 0&&O.push({source:ie,target:ne,count:J.count})}),{nodes:C,links:O}}function P(){let C=[],O,k,U;U=E(w.nodes());for(O of U.keys())k=U.get(O),C.push({id:O,size:k.count});return{id:"clustersTree",children:C}}function A(){return f.none={x:0,y:0},v.forEach(function(C){y==="treemap"?f[C.data.id]={x:C.x0+(C.x1-C.x0)/2-g[0],y:C.y0+(C.y1-C.y0)/2-g[1]}:f[C.id]={x:C.x-g[0],y:C.y-g[1]}}),f}function z(){let C=HI().size(w.size());o=fh(P()).sum(O=>O.radius).sort(function(O,k){return k.height-O.height||k.value-O.value}),v=C(o).leaves(),A()}function V(){let C=0;n.length!==0&&i.forEach(function(O){let k,U;if(n){if(k=O.source,U=O.target,typeof O.source!="object"&&(k=n.find(R=>R.id===O.source)),typeof O.target!="object"&&(U=n.find(R=>R.id===O.target)),k===void 0||U===void 0)throw Error("Error setting links, couldnt find nodes for a link (see it on the console)");O.source=k,O.target=U,O.index=C++}})}function N(){let C;!n||!n.length||(V(),C=L(),s.size>0&&C.nodes.forEach(O=>{var k,U,R,F;O.fx=(U=(k=s.get(O.id))==null?void 0:k.position)==null?void 0:U.x,O.fy=(F=(R=s.get(O.id))==null?void 0:R.position)==null?void 0:F.y}),p=x1(C.nodes).force("x",wp(a[0]/2).strength(.1)).force("y",Sp(a[1]/2).strength(.1)).force("collide",d1(O=>O.r).iterations(4)).force("charge",b1().strength(l)).force("links",p1(C.nodes.length?C.links:[]).distance(u).strength(h)),v=p.nodes(),A())}return w.template=function(C){return arguments.length?(y=C,S(),w):y},w.groupBy=function(C){return arguments.length?typeof C=="string"?(_=function(O){return O[C]},w):(_=C,w):_},w.enableGrouping=function(C){return arguments.length?(x=C,w):x},w.strength=function(C){return arguments.length?(b=C,w):b},w.getLinkStrength=function(C){return x?_(C.source)===_(C.target)?typeof d=="function"?d(C):d:typeof m=="function"?m(C):m:typeof d=="function"?d(C):d},w.id=function(C){return arguments.length?(t=C,w):t},w.size=function(C){return arguments.length?(a=C,w):a},w.linkStrengthInterCluster=function(C){return arguments.length?(m=C,w):m},w.linkStrengthIntraCluster=function(C){return arguments.length?(d=C,w):d},w.nodes=function(C){return arguments.length?(n=C,w):n},w.links=function(C){return arguments.length?(C===null?i=[]:i=C,S(),w):i},w.template=function(C){return arguments.length?(y=C,S(),w):y},w.forceNodeSize=function(C){return arguments.length?(c=typeof C=="function"?C:r(+C),S(),w):c},w.nodeSize=w.forceNodeSize,w.forceCharge=function(C){return arguments.length?(l=typeof C=="function"?C:r(+C),S(),w):l},w.forceLinkDistance=function(C){return arguments.length?(u=typeof C=="function"?C:r(+C),S(),w):u},w.forceLinkStrength=function(C){return arguments.length?(h=typeof C=="function"?C:r(+C),S(),w):h},w.offset=function(C){return arguments.length?(g=typeof C=="function"?C:r(+C),w):g},w.getFocis=A,w.setClusters=function(C){return s=C,w},w}function br({graph:r,nodeLevelRatio:e=2,mode:t=null,dimensions:n=2,nodeStrength:i=-250,linkDistance:s=50,clusterStrength:o=.5,linkStrengthInterCluster:a=.01,linkStrengthIntraCluster:c=.5,forceLinkDistance:l=100,forceLinkStrength:u=.1,clusterType:h="force",forceCharge:f=-700,getNodePosition:d,drags:m,clusters:v,clusterAttribute:g,forceLayout:p}){const{nodes:_,edges:y}=Vc(r),b=n===2&&y.length>25?i*2:i;let w,S;p==="forceDirected2d"?(w=wp(),S=Sp()):(w=wp(600).strength(.05),S=Sp(600).strength(.05));const M=x1().force("center",qL(0,0)).force("link",p1()).force("charge",b1().strength(b)).force("x",w).force("y",S).force("z",oI()).force("collide",d1(P=>P.radius+10)).force("dagRadial",rF({nodes:_,edges:y,mode:t,nodeLevelRatio:e})).stop();let E;if(g){let P=f;if(_!=null&&_.length){const A=Math.ceil(_.length/200);P=f*A}E=oF().setClusters(v).strength(o).template(h).groupBy(A=>A.data[g]).links(y).size([100,100]).linkStrengthInterCluster(a).linkStrengthIntraCluster(c).forceLinkDistance(l).forceLinkStrength(u).forceCharge(P).forceNodeSize(A=>A.radius)}let T=M.numDimensions(n).nodes(_);if(E&&(T=T.force("group",E)),s){let P=T.force("link");P&&(P.id(A=>A.id).links(y).distance(s),E&&(P=P.strength((E==null?void 0:E.getLinkStrength)??.1)))}const L=new Map(_.map(P=>[P.id,P]));return{step(){for(;M.alpha()>.01;)M.tick();return!0},getNodePosition(P){var A,z;if(d){const V=d(P,{graph:r,drags:m,nodes:_,edges:y});if(V)return V}return(A=m==null?void 0:m[P])!=null&&A.position?(z=m==null?void 0:m[P])==null?void 0:z.position:L.get(P)}}}function aF({graph:r,radius:e,drags:t,getNodePosition:n}){const i=qI(r,{scale:e}),{nodes:s,edges:o}=Vc(r);return{step(){return!0},getNodePosition(a){var c,l;if(n){const u=n(a,{graph:r,drags:t,nodes:s,edges:o});if(u)return u}return(c=t==null?void 0:t[a])!=null&&c.position?(l=t==null?void 0:t[a])==null?void 0:l.position:i==null?void 0:i[a]}}}const cF={td:{x:"x",y:"y",factor:-1},lr:{x:"y",y:"x",factor:1}};function by({graph:r,drags:e,mode:t="td",nodeSeparation:n=1,nodeSize:i=[50,50],getNodePosition:s}){const{nodes:o,edges:a}=Vc(r),{depths:c}=Lw(o,a),l=Object.keys(c).map(v=>c[v]),u=LI().id(v=>v.data.id).parentId(v=>{var g,p,_;return(_=(p=(g=v.ins)==null?void 0:g[0])==null?void 0:p.data)==null?void 0:_.id})(l),f=kI().separation(()=>n).nodeSize(i)(fh(u)).descendants(),d=cF[t],m=new Map(o.map(v=>{const{x:g,y:p}=f.find(_=>_.data.id===v.id);return[v.id,{...v,[d.x]:g*d.factor,[d.y]:p*d.factor,z:0}]}));return{step(){return!0},getNodePosition(v){var g,p;if(s){const _=s(v,{graph:r,drags:e,nodes:o,edges:a});if(_)return _}return(g=e==null?void 0:e[v])!=null&&g.position?(p=e==null?void 0:e[v])==null?void 0:p.position:m.get(v)}}}function lF({graph:r,margin:e,drags:t,getNodePosition:n,ratio:i,gridSize:s,maxIterations:o}){const{nodes:a,edges:c}=Vc(r),l=JI(r,{maxIterations:o,inputReducer:(u,h)=>({...h,x:h.x||0,y:h.y||0}),settings:{ratio:i,margin:e,gridSize:s}});return{step(){return!0},getNodePosition(u){var h,f;if(n){const d=n(u,{graph:r,drags:t,nodes:a,edges:c});if(d)return d}return(h=t==null?void 0:t[u])!=null&&h.position?(f=t==null?void 0:t[u])==null?void 0:f.position:l==null?void 0:l[u]}}}function uF({graph:r,drags:e,iterations:t,...n}){aU.assign(r);const i=rU(r,{iterations:t,settings:n});return{step(){return!0},getNodePosition(s){var o;return((o=e==null?void 0:e[s])==null?void 0:o.position)||(i==null?void 0:i[s])}}}function hF({graph:r,drags:e,getNodePosition:t}){const{nodes:n,edges:i}=Vc(r);return{step(){return!0},getNodePosition(s){return t(s,{graph:r,drags:e,nodes:n,edges:i})}}}const fF=["forceDirected2d","treeTd2d","treeLr2d","radialOut2d","treeTd3d","treeLr3d","radialOut3d","forceDirected3d"];function dF({type:r,...e}){if(fF.includes(r)){const{nodeStrength:t,linkDistance:n,nodeLevelRatio:i}=e;if(r==="forceDirected2d")return br({...e,dimensions:2,nodeLevelRatio:i||2,nodeStrength:t||-250,linkDistance:n,forceLayout:r});if(r==="treeTd2d")return br({...e,mode:"td",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:r});if(r==="treeLr2d")return br({...e,mode:"lr",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-250,linkDistance:n||50,forceLayout:r});if(r==="radialOut2d")return br({...e,mode:"radialout",dimensions:2,nodeLevelRatio:i||5,nodeStrength:t||-500,linkDistance:n||100,forceLayout:r});if(r==="treeTd3d")return br({...e,mode:"td",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||50});if(r==="treeLr3d")return br({...e,mode:"lr",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||50,forceLayout:r});if(r==="radialOut3d")return br({...e,mode:"radialout",dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-500,linkDistance:n||100,forceLayout:r});if(r==="forceDirected3d")return br({...e,dimensions:3,nodeLevelRatio:i||2,nodeStrength:t||-250,linkDistance:n,forceLayout:r})}else if(r==="circular2d"){const{radius:t}=e;return aF({...e,radius:t||300})}else{if(r==="hierarchicalTd")return by({...e,mode:"td"});if(r==="hierarchicalLr")return by({...e,mode:"lr"});if(r==="nooverlap"){const{graph:t,maxIterations:n,ratio:i,margin:s,gridSize:o,...a}=e;return lF({graph:t,margin:s||10,maxIterations:n||50,ratio:i||10,gridSize:o||20,...a})}else if(r==="forceatlas2"){const{graph:t,iterations:n,gravity:i,scalingRatio:s,...o}=e;return uF({type:"forceatlas2",graph:t,...o,scalingRatio:s||100,gravity:i||10,iterations:n||50})}else if(r==="custom")return hF({...e})}throw new Error(`Layout ${r} not found.`)}function Dw({nodeCount:r,nodePosition:e,labelType:t,camera:n}){return(i,s)=>{var o;if(n&&e&&((o=n==null?void 0:n.position)==null?void 0:o.z)/(n==null?void 0:n.zoom)-(e==null?void 0:e.z)>6e3)return!1;if(t==="all")return!0;if(t==="nodes"&&i==="node")return!0;if(t==="edges"&&i==="edge")return!0;if(t==="auto"&&i==="node"){if(s>7)return!0;if(n&&e&&n.position.z/n.zoom-e.z<3e3)return!0}return!1}}function Iw(r,e){switch(e){case"above":return r;case"below":return-r;case"inline":case"natural":default:return 0}}function pF({graph:r}){const e=hU(r);return{ranks:e,getSizeForNode:t=>e[t]*80}}function mF({graph:r}){const e=dU.degreeCentrality(r);return{ranks:e,getSizeForNode:t=>e[t]*20}}function gF({graph:r,attribute:e,defaultSize:t}){const n=new Map;return e?r.forEachNode((i,s)=>{var o;const a=(o=s.data)==null?void 0:o[e];isNaN(a)&&console.warn(`Attribute ${a} is not a number for node ${s.id}`),n.set(i,a||0)}):console.warn("Attribute sizing configured but no attribute provided"),{getSizeForNode:i=>!e||!n?t:n.get(i)}}const wy={pagerank:pF,centrality:mF,attribute:gF,none:({defaultSize:r})=>({getSizeForNode:e=>r})};function vF({type:r,...e}){var t;const n=(t=wy[r])==null?void 0:t.call(wy,e);if(!n&&r!=="default")throw new Error(`Unknown sizing strategy: ${r}`);const{graph:i,minSize:s,maxSize:o}=e,a=new Map;let c,l;if(i.forEachNode((u,h)=>{let f;r==="default"?f=h.size||e.defaultSize:f=n.getSizeForNode(u),(c===void 0||f<c)&&(c=f),(l===void 0||f>l)&&(l=f),a.set(u,f)}),r!=="none"){const u=Jw().domain([c,l]).rangeRound([s,o]);for(const[h,f]of a)a.set(h,u(f))}return a}function _F(r,e,t){r.clear();const n=new Set;for(const i of e)try{n.has(i.id)||(r.addNode(i.id,i),n.add(i.id))}catch(s){console.error(`[Graph] Error adding node '${i.id}`,s)}for(const i of t)if(!(!n.has(i.source)||!n.has(i.target)))try{r.addEdge(i.source,i.target,i)}catch(s){console.error(`[Graph] Error adding edge '${i.source} -> ${i.target}`,s)}return r}function yF({graph:r,layout:e,sizingType:t,labelType:n,sizingAttribute:i,defaultNodeSize:s,minNodeSize:o,maxNodeSize:a,clusterAttribute:c}){const l=[],u=[],h=new Map,f=vF({graph:r,type:t,attribute:i,minSize:o,maxSize:a,defaultSize:s}),d=r.nodes().length,m=Dw({nodeCount:d,labelType:n});return r.forEachNode((v,g)=>{const p=e.getNodePosition(v),{data:_,fill:y,icon:x,label:b,size:w,...S}=g,M=f.get(g.id),E=m("node",M),L=(r.inboundNeighbors(g.id)||[]).map(A=>r.getNodeAttributes(A)),P={...g,size:M,labelVisible:E,label:b,icon:x,fill:y,cluster:c?_[c]:void 0,parents:L,data:{...S,..._??{}},position:{...p,x:p.x||0,y:p.y||0,z:p.z||1}};h.set(g.id,P),l.push(P)}),r.forEachEdge((v,g)=>{const p=h.get(g.source),_=h.get(g.target);if(p&&_){const{data:y,id:x,label:b,size:w,...S}=g,M=m("edge",w);u.push({...g,id:x,label:b,labelVisible:M,size:w,data:{...S,id:x,...y||{}}})}}),{nodes:l,edges:u}}const Vn={mass:10,tension:1e3,friction:300,precision:.1};function Uw(r,e,t){const n=e.getLength(),i=r==="end"?n:n/2,s=r==="end"?t/2:0,o=(i-s)/n,a=e.getPointAt(o),c=e.getTangentAt(o);return[a,c]}function Ow(r){return[r+6,2+r/1.5]}const Cd=.7;function Nw(r,e,t=0){const n=new G(r.x,r.y||0,r.z||0),i=new G(e.x,e.y||0,e.z||0),s=new G().addVectors(n,i).divideScalar(2);return s.setLength(s.length()+t)}function xF(r,e,t=-1){const n=r.clone(),i=e.clone(),s=new G().subVectors(i,n),o=s.length(),a=s.clone().normalize(),c=new G().subVectors(i,n).divideScalar(2),l=Math.abs(a.x)%1,u=new G(-a.y,a.x-l*a.z,l*a.y).normalize(),h=new G().add(n).add(c).add(u.multiplyScalar(o/4).multiplyScalar(t));return[r,h,e]}function wc(r,e,t,n,i,s){const o=Sy(r,t,e),a=Sy(t,r,n);return i?new $u(...xF(o,a,s)):new gm(o,a)}function Sc(r){return new G(r.position.x,r.position.y,r.position.z||0)}function Sy(r,e,t){const n=r.distanceTo(e);return r.clone().add(e.clone().sub(r).multiplyScalar(t/n))}function Ey(r,e){return{...r,position:{...r.position,x:r.position.x+e.x,y:r.position.y+e.y,z:r.position.z+e.z}}}function bF({edge:r,edges:e,curved:t}){let n=t,i;const s=e.filter(o=>o.target===r.target&&o.source===r.source).map(o=>o.id);if(s.length>1){n=!0;const o=s.indexOf(r.id);s.length===2?i=o===0?Cd:-Cd:i=(o-Math.floor(s.length/2))*Cd}return{curved:n,curveOffset:i}}function Ec(r){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of r)e=Math.min(e,a.position.x),t=Math.max(t,a.position.x),n=Math.min(n,a.position.y),i=Math.max(i,a.position.y),s=Math.min(s,a.position.z),o=Math.max(o,a.position.z);return{height:i-n,width:t-e,minX:e,maxX:t,minY:n,maxY:i,minZ:s,maxZ:o,x:(t+e)/2,y:(i+n)/2,z:(o+s)/2}}function wF(r,e){return e?r.reduce((t,n)=>{const i=n.data[e];return i&&t.set(i,[...t.get(i)||[],n]),t},new Map):new Map}function SF({nodes:r,clusterAttribute:e}){const t=new Map;if(e){const n=wF(r,e);for(const[i,s]of n){const o=Ec(s);t.set(i,{label:i,nodes:s,position:o})}}return t}const fg=({sensitivity:r=7,interval:e=50,timeout:t=0,disabled:n,onPointerOver:i,onPointerOut:s})=>{const o=q.useRef(!1),a=q.useRef(null),c=q.useRef(0),l=q.useRef({x:null,y:null,px:null,py:null}),u=q.useCallback(g=>{l.current.x=g.clientX,l.current.y=g.clientY},[]),h=q.useCallback(g=>{a.current=clearTimeout(a.current);const{px:p,x:_,py:y,y:x}=l.current;Math.abs(p-_)+Math.abs(y-x)<r?(c.current=1,i(g)):(l.current.px=_,l.current.py=x,a.current=setTimeout(()=>h(g),e))},[e,i,r]),f=q.useCallback(()=>{clearTimeout(a.current),typeof window<"u"&&document.removeEventListener("mousemove",u,!1)},[u]),d=q.useCallback(g=>{n||(o.current=!0,f(),c.current!==1&&(l.current.px=g.pointer.x,l.current.py=g.pointer.y,typeof window<"u"&&document.addEventListener("mousemove",u,!1),a.current=setTimeout(()=>h(g),t)))},[f,h,n,u,t]),m=q.useCallback(g=>{a.current=clearTimeout(a.current),c.current=0,s(g)},[s]),v=q.useCallback(g=>{o.current=!1,f(),c.current===1&&(a.current=setTimeout(()=>m(g),t))},[f,m,t]);return{pointerOver:d,pointerOut:v}},Fw=({draggable:r,set:e,position:t,bounds:n,onDragStart:i,onDragEnd:s})=>{const o=Kt(g=>g.camera),a=Kt(g=>g.raycaster),c=Kt(g=>g.size),l=Kt(g=>g.gl),{mouse2D:u,mouse3D:h,offset:f,normal:d,plane:m}=q.useMemo(()=>({mouse2D:new be,mouse3D:new G,offset:new G,normal:new G,plane:new Qi}),[]),v=q.useMemo(()=>l.domElement.getBoundingClientRect(),[l.domElement]);return vE({onDragStart:({event:g})=>{const{eventObject:p,point:_}=g;p.getWorldPosition(f).sub(_),h.copy(_),i()},onDrag:({xy:g,buttons:p,cancel:_})=>{if(p!==1){_();return}const y=(g[0]-((v==null?void 0:v.left)??0))/c.width*2-1,x=-((g[1]-((v==null?void 0:v.top)??0))/c.height)*2+1;u.set(y,x),a.setFromCamera(u,o),o.getWorldDirection(d).negate(),m.setFromNormalAndCoplanarPoint(d,h),a.ray.intersectPlane(m,h);const b=new G(t.x,t.y,t.z).copy(h).add(f);if(n){const w=new G((n.minX+n.maxX)/2,(n.minY+n.maxY)/2,(n.minZ+n.maxZ)/2),S=(n.maxX-n.minX)/2,M=b.clone().sub(w);M.length()>S&&(M.normalize().multiplyScalar(S),b.copy(w).add(M))}return e(b)},onDragEnd:s},{drag:{enabled:r,threshold:10}})},{Provider:EF,useStore:Ue}=mU(),MF=({actives:r=[],selections:e=[],collapsedNodeIds:t=[],theme:n})=>DE(i=>({theme:{...n,edge:{...n.edge,label:{...n.edge.label,fontSize:n.edge.label.fontSize??6}}},edges:[],nodes:[],collapsedNodeIds:t,clusters:new Map,panning:!1,draggingIds:[],actives:r,edgeContextMenus:new Set,edgeMeshes:[],selections:e,hoveredNodeId:null,drags:{},graph:new St({multi:!0}),setTheme:s=>i(o=>({...o,theme:s})),setClusters:s=>i(o=>({...o,clusters:s})),setEdgeContextMenus:s=>i(o=>({...o,edgeContextMenus:s})),setEdgeMeshes:s=>i(o=>({...o,edgeMeshes:s})),setPanning:s=>i(o=>({...o,panning:s})),setDrags:s=>i(o=>({...o,drags:s})),addDraggingId:s=>i(o=>({...o,draggingIds:[...o.draggingIds,s]})),removeDraggingId:s=>i(o=>({...o,draggingIds:o.draggingIds.filter(a=>a!==s)})),setActives:s=>i(o=>({...o,actives:s})),setSelections:s=>i(o=>({...o,selections:s})),setHoveredNodeId:s=>i(o=>({...o,hoveredNodeId:s})),setNodes:s=>i(o=>({...o,nodes:s,centerPosition:Ec(s)})),setEdges:s=>i(o=>({...o,edges:s})),setNodePosition:(s,o)=>i(a=>{var c,l;const u=a.nodes.find(v=>v.id===s),h=Sc(u),d=new G(o.x,o.y,o.z).sub(h),m=[...a.nodes];if((c=a.selections)!=null&&c.includes(s))(l=a.selections)==null||l.forEach(v=>{const g=a.nodes.find(p=>p.id===v);if(g){const p=a.nodes.indexOf(g);m[p]=Ey(g,d)}});else{const v=a.nodes.indexOf(u);m[v]=Ey(u,d)}return{...a,drags:{...a.drags,[s]:u},nodes:m}}),setCollapsedNodeIds:(s=[])=>i(o=>({...o,collapsedNodeIds:s})),setClusterPosition:(s,o)=>i(a=>{const c=new Map(a.clusters),l=c.get(s);if(l){const u=l.position,h=new G(o.x-u.x,o.y-u.y,o.z-(u.z??0)),f=[...a.nodes],d={...a.drags};f.forEach((g,p)=>{g.cluster===s&&(f[p]={...g,position:{...g.position,x:g.position.x+h.x,y:g.position.y+h.y,z:g.position.z+(h.z??0)}},d[g.id]=g)});const m=f.filter(g=>g.cluster===s),v=Ec(m);return c.set(s,{...l,position:v}),{...a,drags:{...d,[s]:l},clusters:c,nodes:f}}return a})}));function kw({nodeId:r,nodes:e,edges:t,currentHiddenNodes:n,currentHiddenEdges:i}){const s=[],o=[],a=n.map(d=>d.id),c=i.map(d=>d.id),l=t.filter(d=>d.source===r),u=l.map(d=>d.target);o.push(...l);for(const d of u){const m=t.filter(g=>g.target===d&&g.source!==r);let v=!1;if((m.length===0||m.length>0&&!a.includes(d)&&m.map(p=>p.id).every(p=>c.includes(p)))&&(v=!0),v){const g=e.find(_=>_.id===d);g&&s.push(g);const p=kw({nodeId:d,nodes:e,edges:t,currentHiddenEdges:o,currentHiddenNodes:s});o.push(...p.hiddenEdges),s.push(...p.hiddenNodes)}}const h=Object.values(o.reduce((d,m)=>({...d,[m.id]:m}),{})),f=Object.values(s.reduce((d,m)=>({...d,[m.id]:m}),{}));return{hiddenEdges:h,hiddenNodes:f}}const TF=({collapsedIds:r,nodes:e,edges:t})=>{const n=[],i=[];for(const l of r){const{hiddenEdges:u,hiddenNodes:h}=kw({nodeId:l,nodes:e,edges:t,currentHiddenEdges:i,currentHiddenNodes:n});n.push(...h),i.push(...u)}const s=n.map(l=>l.id),o=i.map(l=>l.id),a=e.filter(l=>!s.includes(l.id)),c=t.filter(l=>!o.includes(l.id));return{visibleNodes:a,visibleEdges:c}},AF=({layoutType:r,sizingType:e,labelType:t,sizingAttribute:n,clusterAttribute:i,selections:s,nodes:o,edges:a,actives:c,collapsedNodeIds:l,defaultNodeSize:u,maxNodeSize:h,minNodeSize:f,layoutOverrides:d,constrainDragging:m})=>{const v=Ue(R=>R.graph),g=Ue(R=>R.clusters),p=Ue(R=>R.nodes),_=Ue(R=>R.setClusters),y=Ue(R=>R.collapsedNodeIds),x=Ue(R=>R.setEdges),b=Ue(R=>R.nodes),w=Ue(R=>R.setNodes),S=Ue(R=>R.setSelections),M=Ue(R=>R.setActives),E=Ue(R=>R.drags),T=Ue(R=>R.setDrags),L=Ue(R=>R.setCollapsedNodeIds),P=q.useRef(!1),A=q.useRef(null),z=Kt(R=>R.camera),V=q.useRef(E),N=q.useRef([]);q.useEffect(()=>{var R;if(!i)return;const F=p.map(Y=>Y.id),H=o.find(Y=>!F.includes(Y.id));if(H){const Y=H.data[i],J=g.get(Y),ie={...V.current};(R=J==null?void 0:J.nodes)==null||R.forEach(ne=>ie[ne.id]=void 0),V.current=ie,T(ie)}},[p,o,i,g,T]);const{visibleEdges:C,visibleNodes:O}=q.useMemo(()=>TF({collapsedIds:y,nodes:o,edges:a}),[y,o,a]),k=q.useCallback(R=>{const F={...V.current};R.forEach(H=>F[H.id]=H),V.current=F,T(F)},[T]),U=q.useCallback(async R=>{A.current=R||dF({...d,type:r,graph:v,drags:V.current,clusters:N==null?void 0:N.current,clusterAttribute:i}),await sF(A.current);const F=yF({graph:v,layout:A.current,sizingType:e,labelType:t,sizingAttribute:n,maxNodeSize:h,minNodeSize:f,defaultNodeSize:u,clusterAttribute:i}),H=SF({nodes:F.nodes,clusterAttribute:i});m&&H.forEach(Y=>{var J,ie;const ne=N.current.get(Y.label);(ne==null?void 0:ne.nodes.length)===Y.nodes.length&&(Y.position=((ie=(J=N.current)==null?void 0:J.get(Y.label))==null?void 0:ie.position)??Y.position)}),x(F.edges),w(F.nodes),_(H),i&&k(F.nodes)},[d,r,i,e,t,n,h,f,u,x,w,_]);return q.useEffect(()=>{V.current=E},[E,i,U]),q.useEffect(()=>{N.current=g},[g]),q.useEffect(()=>{const R=b.map(H=>({...H,labelVisible:Dw({nodeCount:b==null?void 0:b.length,labelType:t,camera:z,nodePosition:H==null?void 0:H.position})("node",H==null?void 0:H.size)}));R.some((H,Y)=>H.labelVisible!==b[Y].labelVisible)&&w(R)},[z,z.zoom,z.position.z,w,b,t]),q.useEffect(()=>{P.current&&S(s)},[s,S]),q.useEffect(()=>{P.current&&M(c)},[c,M]),q.useEffect(()=>{async function R(){P.current=!1,_F(v,O,C),await U(),requestAnimationFrame(()=>P.current=!0)}R()},[O,C]),q.useEffect(()=>{P.current&&L(l)},[l,L]),q.useEffect(()=>{P.current&&(V.current={},T({}),U())},[r,U,T]),q.useEffect(()=>{P.current&&U(A.current)},[e,n,t,U]),{updateLayout:U}},Mc=({text:r,fontSize:e=7,fontUrl:t,color:n="#2A6475",opacity:i=1,stroke:s,active:o,ellipsis:a=75,rotation:c})=>{const l=a&&!o?QN(r,a):r,u=q.useMemo(()=>new Ne(n),[n]),h=q.useMemo(()=>s?new Ne(s):void 0,[s]);return Se.jsx(yw,{position:[0,0,1],children:Se.jsx(ZN,{font:t,fontSize:e,color:u,fillOpacity:i,textAlign:"center",outlineWidth:s?1:0,outlineColor:h,depthOffset:0,maxWidth:100,overflowWrap:"break-word",rotation:c,children:l})})},CF=({color:r="#D8E6EA",size:e=1,opacity:t=.5,animated:n,strokeWidth:i=5,innerRadius:s=4,segments:o=25})=>{const a=q.useMemo(()=>new Ne(r),[r]),{ringSize:c,ringOpacity:l}=Gn({from:{ringOpacity:0,ringSize:[1e-5,1e-5,1e-5]},to:{ringOpacity:t,ringSize:[e/2,e/2,1]},config:{...Vn,duration:n?void 0:0}}),u=i/10,h=s+u;return Se.jsx(yw,{position:[0,0,1],children:Se.jsxs(Gt.mesh,{scale:c,children:[Se.jsx("ringGeometry",{attach:"geometry",args:[s,h,o]}),Se.jsx(Gt.meshBasicMaterial,{attach:"material",color:a,transparent:!0,depthTest:!1,opacity:l,side:Dt,fog:!0})]})})},RF=({color:r,id:e,size:t,selected:n,opacity:i=1,animated:s})=>{const{scale:o,nodeOpacity:a}=Gn({from:{scale:[1e-5,1e-5,1e-5],nodeOpacity:0},to:{scale:[t,t,t],nodeOpacity:i},config:{...Vn,duration:s?void 0:0}}),c=q.useMemo(()=>new Ne(r),[r]),l=Ue(u=>u.theme);return Se.jsxs(Se.Fragment,{children:[Se.jsxs(Gt.mesh,{userData:{id:e,type:"node"},scale:o,children:[Se.jsx("sphereGeometry",{attach:"geometry",args:[1,25,25]}),Se.jsx(Gt.meshPhongMaterial,{attach:"material",side:Dt,transparent:!0,fog:!0,opacity:a,color:c})]}),Se.jsx(CF,{opacity:n?.5:0,size:t,animated:s,color:n?l.ring.activeFill:l.ring.fill})]})},zw=q.createContext({controls:null,resetControls:()=>{},zoomIn:()=>{},zoomOut:()=>{},dollyIn:()=>{},dollyOut:()=>{},panLeft:()=>{},panRight:()=>{},panUp:()=>{},panDown:()=>{},freeze:()=>{},unFreeze:()=>{}}),Mh=()=>{const r=q.useContext(zw);if(r===void 0)throw new Error("`useCameraControls` hook must be used within a `ControlsProvider` component");return r};nn.install({THREE:{MOUSE:qy,Vector2:be,Vector3:G,Vector4:mt,Quaternion:ln,Matrix4:Ke,Spherical:Yb,Box3:Hn,Sphere:Wn,Raycaster:Im,MathUtils:{DEG2RAD:(_y=bu)==null?void 0:_y.DEG2RAD,clamp:(yy=bu)==null?void 0:yy.clamp}}});Zb({ThreeCameraControls:nn});const Th={ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40},My=new Eh(Th.ARROW_LEFT,100),Ty=new Eh(Th.ARROW_RIGHT,100),Ay=new Eh(Th.ARROW_UP,100),Cy=new Eh(Th.ARROW_DOWN,100),PF=q.forwardRef(({mode:r="rotate",children:e,animated:t,disabled:n,minDistance:i=1e3,maxDistance:s=5e4},o)=>{const a=q.useRef(null),c=Kt(L=>L.camera),l=Kt(L=>L.gl),u=r==="orbit",h=Ue(L=>L.setPanning),f=Ue(L=>L.draggingIds.length>0),d=q.useRef(0),[m,v]=q.useState(!1);uh((L,P)=>{var A,z;(A=a.current)!=null&&A.enabled&&((z=a.current)==null||z.update(P)),u&&(a.current.azimuthAngle+=20*P*bu.DEG2RAD)},-1),q.useEffect(()=>()=>{var L;return(L=a.current)==null?void 0:L.dispose()},[]);const g=q.useCallback(()=>{var L;(L=a.current)==null||L.zoom(c.zoom/2,t)},[t,c.zoom]),p=q.useCallback(()=>{var L;(L=a.current)==null||L.zoom(-c.zoom/2,t)},[t,c.zoom]),_=q.useCallback(L=>{var P;(P=a.current)==null||P.dolly(L,t)},[t]),y=q.useCallback(L=>{var P;(P=a.current)==null||P.dolly(L,t)},[t]),x=q.useCallback(L=>{var P;u||(P=a.current)==null||P.truck(-.03*L.deltaTime,0,t)},[t,u]),b=q.useCallback(L=>{var P;u||(P=a.current)==null||P.truck(.03*L.deltaTime,0,t)},[t,u]),w=q.useCallback(L=>{var P;u||(P=a.current)==null||P.truck(0,.03*L.deltaTime,t)},[t,u]),S=q.useCallback(L=>{var P;u||(P=a.current)==null||P.truck(0,-.03*L.deltaTime,t)},[t,u]),M=q.useCallback(L=>{L.code==="Space"&&(r==="rotate"?a.current.mouseButtons.left=nn.ACTION.TRUCK:a.current.mouseButtons.left=nn.ACTION.ROTATE)},[r]),E=q.useCallback(L=>{L.code==="Space"&&(r==="rotate"?a.current.mouseButtons.left=nn.ACTION.ROTATE:a.current.mouseButtons.left=nn.ACTION.TRUCK)},[r]);q.useEffect(()=>(n||(My.addEventListener("holding",b),Ty.addEventListener("holding",x),Ay.addEventListener("holding",w),Cy.addEventListener("holding",S),typeof window<"u"&&(window.addEventListener("keydown",M),window.addEventListener("keyup",E))),()=>{My.removeEventListener("holding",b),Ty.removeEventListener("holding",x),Ay.removeEventListener("holding",w),Cy.removeEventListener("holding",S),typeof window<"u"&&(window.removeEventListener("keydown",M),window.removeEventListener("keyup",E))}),[n,M,E,S,b,x,w]),q.useEffect(()=>{n?(a.current.mouseButtons.left=nn.ACTION.NONE,a.current.mouseButtons.middle=nn.ACTION.NONE,a.current.mouseButtons.wheel=nn.ACTION.NONE):(a.current.mouseButtons.left=nn.ACTION.TRUCK,a.current.mouseButtons.middle=nn.ACTION.TRUCK,a.current.mouseButtons.wheel=nn.ACTION.DOLLY)},[n]),q.useEffect(()=>{const L=()=>h(!0),P=()=>h(!1),A=a.current;return A&&(A.addEventListener("control",L),A.addEventListener("controlend",P)),()=>{A&&(A.removeEventListener("control",L),A.removeEventListener("controlend",P))}},[a,h]),q.useEffect(()=>{f?(a.current.mouseButtons.left=nn.ACTION.NONE,a.current.touches.one=nn.ACTION.NONE):r==="rotate"?(a.current.mouseButtons.left=nn.ACTION.ROTATE,a.current.touches.one=nn.ACTION.TOUCH_ROTATE):(a.current.touches.one=nn.ACTION.TOUCH_TRUCK,a.current.mouseButtons.left=nn.ACTION.TRUCK)},[f,r]);const T=q.useMemo(()=>({controls:a.current,zoomIn:()=>g(),zoomOut:()=>p(),dollyIn:(L=1e3)=>_(L),dollyOut:(L=-1e3)=>y(L),panLeft:(L=100)=>b({deltaTime:L}),panRight:(L=100)=>x({deltaTime:L}),panDown:(L=100)=>S({deltaTime:L}),panUp:(L=100)=>w({deltaTime:L}),resetControls:L=>{var P;return(P=a.current)==null?void 0:P.reset(L)},freeze:()=>{a.current.truckSpeed&&(d.current=a.current.truckSpeed),a.current.truckSpeed=0},unFreeze:()=>a.current.truckSpeed=d.current}),[g,p,b,x,S,w,a.current]);return q.useImperativeHandle(o,()=>T),Se.jsxs(zw.Provider,{value:T,children:[Se.jsx("threeCameraControls",{ref:L=>{a.current=L,m||v(!0)},args:[c,l.domElement],smoothTime:.1,minDistance:i,dollyToCursor:!0,maxDistance:s}),e]})});function Bw(r,e){const t=e.position.z;r<t?r-=t:r+=t;const n=e.fov/e.zoom*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(r)}function LF(r,e){return Bw(r,e)*e.aspect}function Ry(r,e){var t,n,i,s;const o=LF(1,r),a=Bw(1,r),c={x0:((t=r==null?void 0:r.position)==null?void 0:t.x)-o/2,x1:((n=r==null?void 0:r.position)==null?void 0:n.x)+o/2,y0:((i=r==null?void 0:r.position)==null?void 0:i.y)-a/2,y1:((s=r==null?void 0:r.position)==null?void 0:s.y)+a/2};return(e==null?void 0:e.x)>c.x0&&(e==null?void 0:e.x)<c.x1&&(e==null?void 0:e.y)>c.y0&&(e==null?void 0:e.y)<c.y1}function Py(r,e){return e.reduce((t,n)=>Math.abs(n-r%Math.PI)<Math.abs(t-r%Math.PI)?n:t)}function DF(r,e){const t=Py(r,[0,Math.PI]),n=Py(e,[Math.PI/2,3*Math.PI/2]);return{horizontalRotation:t-r%Math.PI,verticalRotation:n-e%Math.PI}}const Ql=50,IF=({animated:r,disabled:e,layoutType:t})=>{const n=Ue(v=>v.nodes),[i,s]=q.useState(!1),o=Kt(v=>v.invalidate),{controls:a}=Mh(),c=Kt(v=>v.camera),l=q.useRef(!1),u=q.useCallback(async(v,g)=>{const p=(g==null?void 0:g.animated)!==void 0?g==null?void 0:g.animated:!0,_=(g==null?void 0:g.centerOnlyIfNodesNotInView)!==void 0?g==null?void 0:g.centerOnlyIfNodesNotInView:!1;if(!l.current||!_||_&&(v!=null&&v.some(y=>!Ry(c,y.position)))){const{x:y,y:x,z:b}=Ec(v);await a.setTarget(y,x,b,p),i||s(!0),o()}},[o,a,n]),h=q.useCallback(async(v,g={animated:!0,fitOnlyIfNodesNotInView:!1})=>{const{fitOnlyIfNodesNotInView:p}=g;if(!p||p&&(v!=null&&v.some(_=>!Ry(c,_.position)))){const{minX:_,maxX:y,minY:x,maxY:b,minZ:w,maxZ:S}=Ec(v);if(!t.includes("3d")){const{horizontalRotation:M,verticalRotation:E}=DF(a==null?void 0:a.azimuthAngle,a==null?void 0:a.polarAngle);a==null||a.rotate(M,E,!0)}await(a==null?void 0:a.zoomTo(1,g==null?void 0:g.animated)),await(a==null?void 0:a.fitToBox(new Hn(new G(_,x,w),new G(y,b,S)),g==null?void 0:g.animated,{cover:!1,paddingLeft:Ql,paddingRight:Ql,paddingBottom:Ql,paddingTop:Ql}))}},[c,a,t]),f=q.useCallback(v=>{let g=null;return v!=null&&v.length&&(g=v.reduce((p,_)=>{const y=n.find(x=>x.id===_);if(y)p.push(y);else throw new Error(`Attempted to center ${_} but it was not found in the nodes`);return p},[])),g},[n]),d=q.useCallback((v,g)=>{const p=f(v);u(p||n,{animated:r,centerOnlyIfNodesNotInView:g==null?void 0:g.centerOnlyIfNodesNotInView})},[r,u,f,n]),m=q.useCallback(async(v,g)=>{const p=f(v);await h(p||n,{animated:r,...g})},[r,h,f,n]);return q.useLayoutEffect(()=>{async function v(){a&&(n!=null&&n.length)&&(l.current||(await u(n,{animated:!1}),await h(n,{animated:!1}),l.current=!0))}v()},[a,u,n,r,c,h]),{centerNodes:u,centerNodesById:d,fitNodesInViewById:m,isCentered:i}},UF=({image:r,id:e,size:t,opacity:n=1,animated:i})=>{const s=q.useMemo(()=>new Ob().load(r),[r]),{scale:o,spriteOpacity:a}=Gn({from:{scale:[1e-5,1e-5,1e-5],spriteOpacity:0},to:{scale:[t,t,t],spriteOpacity:n},config:{...Vn,duration:i?void 0:0}});return Se.jsx(Gt.sprite,{userData:{id:e,type:"node"},scale:o,children:Se.jsx(Gt.spriteMaterial,{attach:"material",opacity:a,fog:!0,depthTest:!1,transparent:!0,side:Dt,children:Se.jsx("primitive",{attach:"map",object:s,minFilter:Pt})})})},OF=({animated:r,disabled:e,id:t,draggable:n=!1,labelFontUrl:i,contextMenu:s,onClick:o,onDoubleClick:a,onPointerOver:c,onDragged:l,onPointerOut:u,onContextMenu:h,renderNode:f,constrainDragging:d})=>{var m,v,g;const p=Mh(),_=Ue($=>$.theme),y=Ue($=>$.nodes.find(he=>he.id===t)),x=Ue($=>$.edges),b=Ue($=>$.draggingIds),w=Ue($=>$.collapsedNodeIds),S=Ue($=>$.addDraggingId),M=Ue($=>$.removeDraggingId),E=Ue($=>$.setHoveredNodeId),T=Ue($=>$.setNodePosition),L=Ue($=>$.setCollapsedNodeIds),P=Ue($=>$.collapsedNodeIds.includes(t)),A=Ue($=>{var he;return(he=$.actives)==null?void 0:he.includes(t)}),z=Ue($=>{var he;return(he=$.selections)==null?void 0:he.includes(t)}),V=Ue($=>{var he;return((he=$.selections)==null?void 0:he.length)>0}),N=Ue($=>$.centerPosition),C=Ue($=>$.clusters.get(y.cluster)),O=b.includes(t),k=b.length>0,{position:U,label:R,subLabel:F,size:H=7,labelVisible:Y=!0}=y,J=q.useRef(null),[ie,ne]=q.useState(!1),[ee,ge]=q.useState(!1),me=ie||z||A,te=V?me?_.node.selectedOpacity:_.node.inactiveOpacity:_.node.opacity,D=q.useMemo(()=>x.filter(he=>he.source===t).length>0||P,[x,t,P]),Q=q.useCallback(()=>{D&&L(P?w.filter($=>$!==t):[...w,t])},[D,w,t,P,L]),[{nodePosition:j,labelPosition:K,subLabelPosition:W}]=Gn(()=>({from:{nodePosition:N?[N.x,N.y,0]:[0,0,0],labelPosition:[0,-(H+7),2],subLabelPosition:[0,-(H+14),2]},to:{nodePosition:U?[U.x,U.y,me?U.z+1:U.z]:[0,0,0],labelPosition:[0,-(H+7),2],subLabelPosition:[0,-(H+14),2]},config:{...Vn,duration:r&&!k?void 0:0}}),[O,U,r,H,me]),ye=Fw({draggable:n,position:U,bounds:d?C==null?void 0:C.position:void 0,set:$=>T(t,$),onDragStart:()=>{S(t),ne(!0)},onDragEnd:()=>{M(t),l==null||l(y)}});ds(ie&&!k&&o!==void 0,"pointer"),ds(ie&&n&&!O&&o===void 0,"grab"),ds(O,"grabbing");const re=me||O,fe=re?_.node.activeFill:y.fill||_.node.fill,{pointerOver:xe,pointerOut:ce}=fg({disabled:e||O,onPointerOver:$=>{p.freeze(),ne(!0),c==null||c(y,$),E(t)},onPointerOut:$=>{p.unFreeze(),ne(!1),u==null||u(y,$),E(null)}}),Pe=q.useMemo(()=>f?f({id:t,color:fe,size:H,active:re,opacity:te,animated:r,selected:z,node:y}):Se.jsx(Se.Fragment,{children:y.icon?Se.jsx(UF,{id:t,image:y.icon||"",size:H+8,opacity:te,animated:r,color:fe,node:y,active:re,selected:z}):Se.jsx(RF,{id:t,size:H,opacity:te,animated:r,color:fe,node:y,active:re,selected:z})}),[f,t,fe,H,re,te,r,z,y]),B=q.useMemo(()=>{var $,he,de;return Y&&(Y||z||ie)&&R&&Se.jsxs(Se.Fragment,{children:[Se.jsx(Gt.group,{position:K,children:Se.jsx(Mc,{text:R,fontUrl:i,opacity:te,stroke:_.node.label.stroke,active:z||ie||O||A,color:z||ie||O||A?_.node.label.activeColor:_.node.label.color})}),F&&Se.jsx(Gt.group,{position:W,children:Se.jsx(Mc,{text:F,fontUrl:i,fontSize:5,opacity:te,stroke:($=_.node.subLabel)==null?void 0:$.stroke,active:z||ie||O||A,color:z||ie||O||A?(he=_.node.subLabel)==null?void 0:he.activeColor:(de=_.node.subLabel)==null?void 0:de.color})})]})},[ie,A,O,z,R,i,K,Y,te,F,W,_.node.label.activeColor,_.node.label.color,_.node.label.stroke,(m=_.node.subLabel)==null?void 0:m.activeColor,(v=_.node.subLabel)==null?void 0:v.color,(g=_.node.subLabel)==null?void 0:g.stroke]),I=q.useMemo(()=>ee&&s&&Se.jsx(jm,{prepend:!0,center:!0,children:s({data:y,canCollapse:D,isCollapsed:P,onCollapse:Q,onClose:()=>ge(!1)})}),[ee,s,y,D,P,Q]);return Se.jsxs(Gt.group,{renderOrder:1,userData:{id:t,type:"node"},ref:J,position:j,onPointerOver:xe,onPointerOut:ce,onClick:$=>{!e&&!O&&(o==null||o(y,{canCollapse:D,isCollapsed:P},$))},onDoubleClick:$=>{!e&&!O&&(a==null||a(y,$))},onContextMenu:()=>{e||(ge(!0),h==null||h(y,{canCollapse:D,isCollapsed:P,onCollapse:Q}))},...ye(),children:[Pe,I,B]})},NF=({animated:r,color:e="#D8E6EA",length:t,opacity:n=.5,position:i,rotation:s,size:o=1,onActive:a,onContextMenu:c})=>{const l=q.useMemo(()=>new Ne(e),[e]),u=q.useRef(null),h=Ue(g=>g.draggingIds.length>0),f=Ue(g=>g.centerPosition),[{pos:d,arrowOpacity:m}]=Gn(()=>({from:{pos:f?[f.x,f.y,f.z]:[0,0,0],arrowOpacity:0},to:{pos:[i.x,i.y,i.z],arrowOpacity:n},config:{...Vn,duration:r&&!h?void 0:0}}),[r,h,n,i]),v=q.useCallback(()=>{var g;const p=new G(0,1,0);(g=u.current)==null||g.quaternion.setFromUnitVectors(p,s)},[s,u]);return q.useEffect(()=>v(),[v]),Se.jsxs(Gt.mesh,{position:d,ref:u,scale:[1,1,1],onPointerOver:()=>a(!0),onPointerOut:()=>a(!1),onPointerDown:g=>{g.nativeEvent.buttons===2&&(g.stopPropagation(),c())},children:[Se.jsx("cylinderGeometry",{args:[0,o,t,20,1,!0],attach:"geometry"}),Se.jsx(Gt.meshBasicMaterial,{attach:"material",color:l,depthTest:!1,opacity:m,transparent:!0,side:Dt,fog:!0})]})},FF=({curveOffset:r,animated:e,color:t="#000",curve:n,curved:i=!1,id:s,opacity:o=1,size:a=1,onContextMenu:c,onClick:l,onPointerOver:u,onPointerOut:h})=>{const f=q.useRef(null),d=Ue(_=>_.draggingIds.length>0),m=q.useMemo(()=>new Ne(t),[t]),v=Ue(_=>_.centerPosition),g=q.useRef(!1),{lineOpacity:p}=Gn({from:{lineOpacity:0},to:{lineOpacity:o},config:{...Vn,duration:e?void 0:0}});return Gn(()=>{const _=n.getPoint(0),y=n.getPoint(1);return{from:{fromVertices:g.current?[y==null?void 0:y.x,y==null?void 0:y.y,(y==null?void 0:y.z)||0]:[v==null?void 0:v.x,v==null?void 0:v.y,(v==null?void 0:v.z)||0],toVertices:[_==null?void 0:_.x,_==null?void 0:_.y,(_==null?void 0:_.z)||0]},to:{fromVertices:[_==null?void 0:_.x,_==null?void 0:_.y,(_==null?void 0:_.z)||0],toVertices:[y==null?void 0:y.x,y==null?void 0:y.y,(y==null?void 0:y.z)||0]},onChange:x=>{const{fromVertices:b,toVertices:w}=x.value,S=new G(...b),M=new G(...w),E=wc(S,0,M,0,i,r);f.current.copy(new ys(E,20,a/2,5,!1))},config:{...Vn,duration:e&&!d?void 0:0}}},[e,d,n,a]),q.useEffect(()=>{g.current=!0},[]),Se.jsxs("mesh",{userData:{id:s,type:"edge"},onPointerOver:u,onPointerOut:h,onClick:l,onPointerDown:_=>{_.nativeEvent.buttons===2&&(_.stopPropagation(),c())},children:[Se.jsx("tubeGeometry",{attach:"geometry",ref:f}),Se.jsx(Gt.meshBasicMaterial,{attach:"material",opacity:p,fog:!0,transparent:!0,depthTest:!1,color:m})]})},Ly=3,kF=({animated:r,arrowPlacement:e="end",contextMenu:t,disabled:n,labelPlacement:i="inline",id:s,interpolation:o,labelFontUrl:a,onContextMenu:c,onClick:l,onPointerOver:u,onPointerOut:h})=>{const f=Ue(Q=>Q.theme),d=Ue(Q=>Q.draggingIds.length>0),[m,v]=q.useState(!1),[g,p]=q.useState(!1),_=Ue(Q=>Q.edges),y=_.find(Q=>Q.id===s),{target:x,source:b,label:w,labelVisible:S=!1,size:M=1,fill:E}=y,T=Ue(Q=>Q.nodes.find(j=>j.id===b)),L=Ue(Q=>Q.nodes.find(j=>j.id===x)),P=(M+f.edge.label.fontSize)/2,[A,z]=q.useMemo(()=>Ow(M),[M]),{curveOffset:V,curved:N}=q.useMemo(()=>bF({edge:y,edges:_,curved:o==="curved"}),[y,_,o]),[C,O,k]=q.useMemo(()=>{const Q=Sc(T),j=T.size,K=Sc(L),W=L.size;let ye=wc(Q,j,K,W,N,V);const[re,fe]=Uw(e,ye,A);return e==="end"&&(ye=wc(Q,j,re,0,N,V)),[ye,re,fe]},[T,L,N,V,e,A]),U=q.useMemo(()=>{let Q=Nw(T.position,L.position,Iw(P,i));if(N){const j=new G().subVectors(Q,C.getPoint(.5));switch(i){case"above":j.y=j.y-Ly;break;case"below":j.y=j.y+Ly;break}Q=Q.sub(j)}return Q},[T.position,L.position,P,i,N,C]),R=Ue(Q=>{var j;return(j=Q.selections)==null?void 0:j.includes(s)}),F=Ue(Q=>{var j;return(j=Q.selections)==null?void 0:j.length}),H=Ue(Q=>{var j;return(j=Q.actives)==null?void 0:j.includes(s)}),Y=Ue(Q=>Q.centerPosition),J=F?R||H?f.edge.selectedOpacity:f.edge.inactiveOpacity:f.edge.opacity,[{labelPosition:ie}]=Gn(()=>({from:{labelPosition:Y?[Y.x,Y.y,Y.z]:[0,0,0]},to:{labelPosition:[U.x,U.y,U.z]},config:{...Vn,duration:r&&!d?void 0:0}}),[U,r,d]),ne=q.useMemo(()=>new Ir(0,0,i==="natural"?0:Math.atan((L.position.y-T.position.y)/(L.position.x-T.position.x))),[L.position.x,L.position.y,T.position.x,T.position.y,i]);ds(m&&!d&&l!==void 0,"pointer");const{pointerOver:ee,pointerOut:ge}=fg({disabled:n,onPointerOver:Q=>{v(!0),u==null||u(y,Q)},onPointerOut:Q=>{v(!1),h==null||h(y,Q)}}),me=q.useMemo(()=>e!=="none"&&Se.jsx(NF,{animated:r,color:R||m||H?f.arrow.activeFill:E||f.arrow.fill,length:A,opacity:J,position:O,rotation:k,size:z,onActive:v,onContextMenu:()=>{n||(p(!0),c==null||c(y))}}),[E,m,r,A,e,O,k,z,n,y,H,R,c,J,f.arrow.activeFill,f.arrow.fill]),te=q.useMemo(()=>S&&w&&Se.jsx(Gt.group,{position:ie,onContextMenu:()=>{n||(p(!0),c==null||c(y))},onPointerOver:ee,onPointerOut:ge,children:Se.jsx(Mc,{text:w,ellipsis:15,fontUrl:a,stroke:f.edge.label.stroke,color:R||m||H?f.edge.label.activeColor:f.edge.label.color,opacity:J,fontSize:f.edge.label.fontSize,rotation:ne})}),[m,n,y,H,R,w,a,ie,ne,S,c,ge,ee,J,f.edge.label.activeColor,f.edge.label.color,f.edge.label.fontSize,f.edge.label.stroke]),D=q.useMemo(()=>g&&t&&Se.jsx(jm,{prepend:!0,center:!0,position:U,children:t({data:y,onClose:()=>p(!1)})}),[g,t,U,y]);return Se.jsxs("group",{children:[Se.jsx(FF,{curveOffset:V,animated:r,color:R||m||H?f.edge.activeFill:E||f.edge.fill,curve:C,curved:N,id:s,opacity:J,size:M,onClick:Q=>{n||l==null||l(y,Q)},onPointerOver:ee,onPointerOut:ge,onContextMenu:()=>{n||(p(!0),c==null||c(y))}}),me,te,D]})},Dy=new lr(0,0,0);function zF(r,e){const t=q.useRef(),n=Ue(l=>l.theme);Ue(l=>{t.current=l});const i=q.useRef(new Map);q.useRef(new lr(0,0,0));const s=q.useRef(),o=e==="curved",a=q.useCallback(l=>{const u=[],h=i.current,{nodes:f}=t.current,d=new Map(f.map(v=>[v.id,v])),m=n.edge.label.fontSize;return r!=="none"&&!s.current&&(s.current=new Ts(0,1,1,20,1,!0)),l.forEach(v=>{const{target:g,source:p,size:_=1}=v,y=d.get(p),x=d.get(g);if(!y||!x)return;const b=`${y.position.x},${y.position.y},${x.position.x},${x.position.y},${_}`;if(h.has(b)){u.push(h.get(b));return}const w=Sc(y),S=y.size+m,M=Sc(x),E=x.size+m;let T=wc(w,S,M,E,o),L=new ys(T,20,_/2,5,!1);if(r==="none"){u.push(L),h.set(b,L);return}const[P,A]=Ow(_),z=s.current.clone();z.scale(A,P,A);const[V,N]=Uw(r,T,P),C=new ln;if(C.setFromUnitVectors(new G(0,1,0),N),z.applyQuaternion(C),z.translate(V.x,V.y,V.z),r&&r==="end"){const k=wc(w,S,V,0,o);L=new ys(k,20,_/2,5,!1)}const O=Kc([L,z]);u.push(O),h.set(b,O)}),u},[r,o,n.edge.label.fontSize]),c=q.useCallback((l,u)=>{const h=a(l),f=a(u);return Kc([f.length?Kc(f):Dy,h.length?Kc(h):Dy],!0)},[a]);return{getGeometries:a,getGeometry:c}}function BF(r,e,t){const n=q.useRef(r);q.useEffect(()=>{n.current=r},[r]);const i=Ue(h=>h.edgeContextMenus),s=Ue(q.useCallback(h=>h.setEdgeContextMenus,[])),o=q.useRef(!1),a=q.useCallback(()=>{o.current=!0},[]),c=q.useRef(!1),l=q.useCallback(()=>{c.current=!0},[]),u=q.useCallback((h,f)=>{const{onClick:d,onContextMenu:m,onPointerOver:v,onPointerOut:g}=n.current;if(d&&o.current&&!t){o.current=!1;for(const p of f)d(p)}if((e||m)&&c.current&&!t){c.current=!1;const p=new Set(i);let _=!1;for(const y of f)i.has(y.id)||(p.add(y.id),_=!0,m==null||m(y));_&&s(p)}v&&f.filter(_=>!h.includes(_)).forEach(_=>{v(_)}),g&&h.filter(_=>!f.includes(_)).forEach(_=>{g(_)})},[e,t,i,s]);return{handleClick:a,handleContextMenu:l,handleIntersections:u}}function GF(r,e){const t=q.useRef(r),n=q.useRef();q.useEffect(()=>{t.current=r;const o=r.getAttribute("position");n.current=new Float32Array(o.array.length)},[r]);const i=q.useCallback(()=>{const o=t.current.getAttribute("position");return{from:new Float32Array(o.array.length),to:o.array}},[]),s=q.useCallback(o=>{const a=n.current;a.set(o);const c=new wt(a,3,!1);t.current.setAttribute("position",c),c.needsUpdate=!0},[]);Gn(()=>{if(!e)return null;const o=i();return{from:{positions:o.from},to:{positions:o.to},onChange:a=>{s(a.value.positions)},config:{...Vn,duration:e?void 0:0}}},[e,i,s])}function VF(r,e,t){const[{activeOpacity:n,inactiveOpacity:i}]=Gn(()=>({from:{activeOpacity:0,inactiveOpacity:0},to:{activeOpacity:e?t.edge.selectedOpacity:t.edge.opacity,inactiveOpacity:e?t.edge.inactiveOpacity:t.edge.opacity},config:{...Vn,duration:r?void 0:0}}),[r,e,t]);return{activeOpacity:n,inactiveOpacity:i}}const HF=({animated:r,color:e,contextMenu:t,edge:n,labelFontUrl:i,labelPlacement:s="inline",opacity:o})=>{const a=Ue(T=>T.theme),{target:c,source:l,label:u,labelVisible:h=!1,size:f=1}=n,d=Ue(T=>T.nodes),[m,v]=q.useMemo(()=>[d.find(T=>T.id===l),d.find(T=>T.id===c)],[d,l,c]),g=Ue(T=>T.draggingIds.length>0),p=q.useMemo(()=>(f+a.edge.label.fontSize)/2,[f,a.edge.label.fontSize]),_=q.useMemo(()=>Nw(m.position,v.position,Iw(p,s)),[m.position,v.position,p,s]),y=Ue(T=>T.edgeContextMenus),x=Ue(T=>T.setEdgeContextMenus),[{labelPosition:b}]=Gn(()=>({from:{labelPosition:[0,0,0]},to:{labelPosition:[_.x,_.y,_.z]},config:{...Vn,duration:r&&!g?void 0:0}}),[_,r,g]),w=q.useCallback(T=>{y.delete(T),x(new Set(y))},[y,x]),S=q.useMemo(()=>s==="natural"?new Ir(0,0,0):new Ir(0,0,Math.atan2(v.position.y-m.position.y,v.position.x-m.position.x)),[s,v.position.y,v.position.x,m.position.y,m.position.x]),M=q.useMemo(()=>({prepend:!0,center:!0,position:_}),[_]),E=q.useMemo(()=>({text:u,ellipsis:15,fontUrl:i,stroke:a.edge.label.stroke,color:e,opacity:o,fontSize:a.edge.label.fontSize,rotation:S}),[u,i,a.edge.label.stroke,e,o,a.edge.label.fontSize,S]);return Se.jsxs("group",{children:[h&&u&&Se.jsx(Gt.group,{position:b,children:Se.jsx(Mc,{...E})}),t&&y.has(n.id)&&Se.jsx(jm,{...M,children:t({data:n,onClose:()=>w(n.id)})})]})},WF=({interpolation:r="linear",arrowPlacement:e="end",labelPlacement:t="inline",animated:n,contextMenu:i,disabled:s,edges:o,labelFontUrl:a,onClick:c,onContextMenu:l,onPointerOut:u,onPointerOver:h})=>{const f=Ue(U=>U.theme),{getGeometries:d,getGeometry:m}=zF(e,r),v=Ue(U=>U.draggingIds),g=Ue(U=>U.edgeMeshes),p=Ue(U=>U.setEdgeMeshes),_=Ue(U=>U.actives||[]),y=Ue(U=>U.selections||[]),[x,b,w,S]=q.useMemo(()=>{const U=[],R=[],F=[],H=[];return o.forEach(Y=>{if(v.includes(Y.source)||v.includes(Y.target)){y.includes(Y.id)||_.includes(Y.id)?F.push(Y):H.push(Y);return}y.includes(Y.id)||_.includes(Y.id)?U.push(Y):R.push(Y)}),[U,R,F,H]},[o,_,y,v]),M=!!y.length,E=q.useMemo(()=>m(x,b),[m,x,b]),{activeOpacity:T,inactiveOpacity:L}=VF(n,M,f);GF(E,n),q.useEffect(()=>{if(v.length===0){const R=d(o).map(F=>new Ot(F));p(R)}},[d,p,o,v.length]);const P=q.useRef(new Ot),A=q.useRef(new Ot),z=q.useCallback(U=>{if(!U.camera)return[];const R=U.intersectObjects(g);return R.length?R.map(F=>o[g.indexOf(F.object)]):[]},[g,o]),{handleClick:V,handleContextMenu:N,handleIntersections:C}=BF({onClick:c,onContextMenu:l,onPointerOut:u,onPointerOver:h},i,s),O=q.useRef([]),k=q.useRef([]);return uh(U=>{if(P.current.geometry=E,s)return;const R=O.current;if((v.length||v.length===0&&R!==null)&&(A.current.geometry=m(w,S)),O.current=v,v.length)return;const F=k.current,H=z(U.raycaster);C(F,H),H.join()!==F.join()&&(A.current.geometry=m(H,[])),k.current=H}),Se.jsxs("group",{onClick:V,onContextMenu:N,children:[Se.jsxs("mesh",{ref:P,children:[Se.jsx(Gt.meshBasicMaterial,{attach:"material-0",color:f.edge.fill,depthTest:!1,fog:!0,opacity:L,side:Dt,transparent:!0}),Se.jsx(Gt.meshBasicMaterial,{attach:"material-1",color:f.edge.activeFill,depthTest:!1,fog:!0,opacity:T,side:Dt,transparent:!0})]}),Se.jsxs("mesh",{ref:A,children:[Se.jsx(Gt.meshBasicMaterial,{attach:"material-0",color:f.edge.fill,depthTest:!1,fog:!0,opacity:L,side:Dt,transparent:!0}),Se.jsx(Gt.meshBasicMaterial,{attach:"material-1",color:f.edge.activeFill,depthTest:!1,fog:!0,opacity:T,side:Dt,transparent:!0})]}),o.map(U=>Se.jsx(HF,{animated:n,contextMenu:i,color:f.edge.label.color,disabled:s,edge:U,labelFontUrl:a,labelPlacement:t},U.id))]})},XF=({outerRadius:r,innerRadius:e,padding:t,normalizedFill:n,normalizedStroke:i,opacity:s,animated:o,theme:a})=>{var c;const{opacity:l}=Gn({from:{opacity:0},to:{opacity:s},config:{...Vn,duration:o?void 0:0}});return Se.jsxs(Se.Fragment,{children:[Se.jsxs("mesh",{children:[Se.jsx("ringGeometry",{attach:"geometry",args:[r,0,128]}),Se.jsx(Gt.meshBasicMaterial,{attach:"material",color:n,transparent:!0,depthTest:!1,opacity:(c=a.cluster)!=null&&c.fill?l:0,side:Dt,fog:!0})]}),Se.jsxs("mesh",{children:[Se.jsx("ringGeometry",{attach:"geometry",args:[r,e+t,128]}),Se.jsx(Gt.meshBasicMaterial,{attach:"material",color:i,transparent:!0,depthTest:!1,opacity:l,side:Dt,fog:!0})]})]})},qF=({animated:r,position:e,padding:t=40,labelFontUrl:n,disabled:i,radius:s=2,nodes:o,label:a,onClick:c,onPointerOver:l,onPointerOut:u,draggable:h=!1,onDragged:f,onRender:d})=>{var m,v,g,p,_,y,x;const b=Ue(D=>D.theme),w=Math.max(e.width,e.height)/2,S=w-s+t,[M,E]=q.useState(!1),T=Ue(D=>D.centerPosition),L=Ue(D=>D.nodes),P=Mh(),A=Ue(D=>D.draggingIds),z=A.includes(a),V=A.length>0,N=Ue(D=>{var Q;return(Q=D.actives)==null?void 0:Q.some(j=>o.some(K=>K.id===j))}),C=Ue(D=>D.hoveredNodeId),O=Ue(D=>{var Q;return(Q=D.selections)==null?void 0:Q.some(j=>o.some(K=>K.id===j))}),U=Ue(D=>{var Q;return((Q=D.selections)==null?void 0:Q.length)>0})?O||M||N?(m=b.cluster)==null?void 0:m.selectedOpacity:(v=b.cluster)==null?void 0:v.inactiveOpacity:(g=b.cluster)==null?void 0:g.opacity,R=q.useMemo(()=>{var D,Q;const j=[0,-S,2],K=(Q=(D=b.cluster)==null?void 0:D.label)==null?void 0:Q.offset;return K?[j[0]-K[0],j[1]-K[1],j[2]-K[2]]:j},[S,(_=(p=b.cluster)==null?void 0:p.label)==null?void 0:_.offset]),{circlePosition:F}=Gn({from:{circlePosition:[T.x,T.y,-1]},to:{circlePosition:e?[e.x,e.y,-1]:[0,0,-1]},config:{...Vn,duration:r&&!V?void 0:0}}),H=q.useMemo(()=>{var D;return new Ne((D=b.cluster)==null?void 0:D.stroke)},[(y=b.cluster)==null?void 0:y.stroke]),Y=q.useMemo(()=>{var D;return new Ne((D=b.cluster)==null?void 0:D.fill)},[(x=b.cluster)==null?void 0:x.fill]),J=Ue(D=>D.addDraggingId),ie=Ue(D=>D.removeDraggingId),ne=Ue(D=>D.setClusterPosition),ee=Fw({draggable:h&&!C,position:{x:e.x,y:e.y,z:-1},set:D=>ne(a,D),onDragStart:()=>{J(a),E(!0)},onDragEnd:()=>{ie(a),E(!1);const D=L.filter(Q=>Q.cluster===a);f==null||f({nodes:D,label:a})}});ds(M&&!V&&c!==void 0,"pointer"),ds(M&&h&&!z&&c===void 0,"grab"),ds(z,"grabbing");const{pointerOver:ge,pointerOut:me}=fg({disabled:i,onPointerOver:D=>{E(!0),P.freeze(),l==null||l({nodes:o,label:a},D)},onPointerOut:D=>{E(!1),P.unFreeze(),u==null||u({nodes:o,label:a},D)}});return q.useMemo(()=>{var D,Q,j;return b.cluster&&Se.jsx(Gt.group,{userData:{id:a,type:"cluster"},position:F,onPointerOver:ge,onPointerOut:me,onClick:K=>{!i&&!z&&(c==null||c({nodes:o,label:a},K))},...ee(),children:d?d({label:{position:R,text:a,opacity:U,fontUrl:n},opacity:U,outerRadius:S,innerRadius:w,padding:t,theme:b}):Se.jsxs(Se.Fragment,{children:[Se.jsx(XF,{outerRadius:S,innerRadius:w,padding:t,normalizedFill:Y,normalizedStroke:H,opacity:U,animated:r,theme:b}),((D=b.cluster)==null?void 0:D.label)&&Se.jsx(Gt.group,{position:R,children:Se.jsx(Mc,{text:a,opacity:U,fontUrl:n,stroke:b.cluster.label.stroke,active:!1,color:(Q=b.cluster)==null?void 0:Q.label.color,fontSize:((j=b.cluster)==null?void 0:j.label.fontSize)??12})})]})})},[b,F,ge,me,S,Y,w,t,H,R,a,U,n,i,c,o,ee,z,d,r])},YF=q.forwardRef(({onNodeClick:r,onNodeDoubleClick:e,onNodeContextMenu:t,onEdgeContextMenu:n,onEdgeClick:i,onEdgePointerOver:s,onEdgePointerOut:o,onNodePointerOver:a,onNodePointerOut:c,onClusterClick:l,onNodeDragged:u,onClusterDragged:h,onClusterPointerOver:f,onClusterPointerOut:d,contextMenu:m,animated:v,disabled:g,draggable:p,constrainDragging:_=!1,edgeLabelPosition:y,edgeArrowPosition:x,edgeInterpolation:b="linear",labelFontUrl:w,renderNode:S,onRenderCluster:M,...E},T)=>{const{layoutType:L,clusterAttribute:P}=E,A=Kt(ee=>ee.gl),z=Kt(ee=>ee.scene),V=Kt(ee=>ee.camera),{updateLayout:N}=AF({...E,constrainDragging:_});if(P&&!(L==="forceDirected2d"||L==="forceDirected3d"))throw new Error("Clustering is only supported for the force directed layouts.");const C=Ue(ee=>ee.graph),O=Ue(ee=>ee.nodes),k=Ue(ee=>ee.edges),U=Ue(ee=>[...ee.clusters.values()]),{centerNodesById:R,fitNodesInViewById:F,isCentered:H}=IF({animated:v,disabled:g,layoutType:L});q.useImperativeHandle(T,()=>({centerGraph:R,fitNodesInView:F,graph:C,renderScene:()=>A.render(z,V)}),[R,F,C,A,z,V]);const Y=q.useCallback(ee=>{u==null||u(ee),P&&N()},[P,u,N]),J=q.useMemo(()=>O.map(ee=>Se.jsx(OF,{id:ee==null?void 0:ee.id,labelFontUrl:w,draggable:p,constrainDragging:_,disabled:g,animated:v,contextMenu:m,renderNode:S,onClick:r,onDoubleClick:e,onContextMenu:t,onPointerOver:a,onPointerOut:c,onDragged:Y},ee==null?void 0:ee.id)),[_,v,m,g,p,w,O,r,t,e,Y,c,a,S]),ie=q.useMemo(()=>v?k.map(ee=>Se.jsx(kF,{id:ee.id,disabled:g,animated:v,labelFontUrl:w,labelPlacement:y,arrowPlacement:x,interpolation:b,contextMenu:m,onClick:i,onContextMenu:n,onPointerOver:s,onPointerOut:o},ee.id)):Se.jsx(WF,{edges:k,disabled:g,animated:v,labelFontUrl:w,labelPlacement:y,arrowPlacement:x,interpolation:b,contextMenu:m,onClick:i,onContextMenu:n,onPointerOver:s,onPointerOut:o}),[v,m,g,x,b,y,k,w,i,n,o,s]),ne=q.useMemo(()=>U.map(ee=>Se.jsx(qF,{animated:v,disabled:g,draggable:p,labelFontUrl:w,onClick:l,onPointerOver:f,onPointerOut:d,onDragged:h,onRender:M,...ee},ee.label)),[v,U,g,p,w,l,d,f,h,M]);return H&&Se.jsxs(q.Fragment,{children:[ie,J,ne]})}),jF={canvas:{background:"#1E2026"},node:{fill:"#7A8C9E",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC"},subLabel:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#54616D",activeFill:"#1DE9AC"},edge:{fill:"#474B56",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#1E2026",color:"#ACBAC7",activeColor:"#1DE9AC",fontSize:6}},arrow:{fill:"#474B56",activeFill:"#1DE9AC"},cluster:{stroke:"#474B56",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#1E2026",color:"#ACBAC7"}}},$F={canvas:{background:"#fff"},node:{fill:"#7CA0AB",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.2,label:{color:"#2A6475",stroke:"#fff",activeColor:"#1DE9AC"},subLabel:{color:"#ddd",stroke:"transparent",activeColor:"#1DE9AC"}},lasso:{border:"1px solid #55aaff",background:"rgba(75, 160, 255, 0.1)"},ring:{fill:"#D8E6EA",activeFill:"#1DE9AC"},edge:{fill:"#D8E6EA",activeFill:"#1DE9AC",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475",activeColor:"#1DE9AC",fontSize:6}},arrow:{fill:"#D8E6EA",activeFill:"#1DE9AC"},cluster:{stroke:"#D8E6EA",opacity:1,selectedOpacity:1,inactiveOpacity:.1,label:{stroke:"#fff",color:"#2A6475"}}};function eu(r,e,t){const{offsetX:n,offsetY:i}=r,{width:s,height:o}=t;e.set(n/s*2-1,-(i/o)*2+1)}function ZF(r){const e=document.createElement("div");return e.style.pointerEvents="none",e.style.border=r.lasso.border,e.style.backgroundColor=r.lasso.background,e.style.position="fixed",e}const KF=({children:r,type:e="none",onLasso:t,onLassoEnd:n,disabled:i})=>{var s;const o=Ue(A=>A.theme),a=Kt(A=>A.camera),c=Kt(A=>A.gl),l=Kt(A=>A.setEvents),u=Kt(A=>A.size),h=Kt(A=>A.get),f=Kt(A=>A.scene),d=Mh(),m=Ue(A=>A.actives),v=Ue(A=>A.setActives),g=Ue(A=>A.edges),p=Ue(A=>A.edgeMeshes),_=q.useRef(!1),y=q.useRef(null),x=q.useRef(null),b=q.useRef(ZF(o)),w=q.useRef(null),S=q.useRef(!1),M=q.useRef(h().events.enabled),E=q.useRef((s=d.controls)==null?void 0:s.enabled);q.useEffect(()=>{_.current&&(t==null||t(m)),_.current=!0},[m,t]);const T=q.useCallback(A=>{if(S.current){const[z,V,N]=w.current;N.x=Math.max(z.x,A.clientX),N.y=Math.max(z.y,A.clientY),V.x=Math.min(z.x,A.clientX),V.y=Math.min(z.y,A.clientY),b.current.style.left=`${V.x}px`,b.current.style.top=`${V.y}px`,b.current.style.width=`${N.x-V.x}px`,b.current.style.height=`${N.y-V.y}px`,eu(A,y.current.endPoint,u),eu(A,x.current.endPoint,u);const C=[],O=x.current.select().sort(U=>U.uuid).map(U=>g[p.indexOf(U)].id);C.push(...O);const k=y.current.select().sort(U=>U.uuid).filter(U=>{var R,F;return U.isMesh&&((R=U.userData)==null?void 0:R.id)&&(((F=U.userData)==null?void 0:F.type)===e||e==="all")}).map(U=>U.userData.id);C.push(...k),requestAnimationFrame(()=>{v(C)}),document.addEventListener("pointermove",T,{passive:!0,capture:!0,once:!0})}},[g,p,v,u,e]),L=q.useCallback(()=>{var A;S.current&&(l({enabled:M.current}),S.current=!1,(A=b.current.parentElement)==null||A.removeChild(b.current),d.controls.enabled=E.current,n==null||n(m),document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",L))},[l,d.controls,n,m,T]),P=q.useCallback(A=>{var z,V;if(A.shiftKey){M.current=h().events.enabled,E.current=(z=d.controls)==null?void 0:z.enabled,y.current=new Vg(a,f);const N=new ac;p.length&&N.add(...p),x.current=new Vg(a,N),w.current=[new be,new be,new be];const[C]=w.current;d.controls.enabled=!1,l({enabled:!1}),S.current=!0,(V=c.domElement.parentElement)==null||V.appendChild(b.current),b.current.style.left=`${A.clientX}px`,b.current.style.top=`${A.clientY}px`,b.current.style.width="0px",b.current.style.height="0px",C.x=A.clientX,C.y=A.clientY,eu(A,y.current.startPoint,u),eu(A,x.current.startPoint,u),document.addEventListener("pointermove",T,{passive:!0,capture:!0,once:!0}),document.addEventListener("pointerup",L,{passive:!0})}},[a,d.controls,p,h,c.domElement.parentElement,T,L,f,l,u]);return q.useEffect(()=>{if(!(i||e==="none"))return typeof window<"u"&&(document.addEventListener("pointerdown",P,{passive:!0}),document.addEventListener("pointermove",T,{passive:!0}),document.addEventListener("pointerup",L,{passive:!0})),()=>{typeof window<"u"&&(document.removeEventListener("pointerdown",P),document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",L))}},[e,i,P,T,L]),Se.jsx("group",{children:r})},JF="_canvas_670zp_1",QF={canvas:JF},ek={alpha:!0,antialias:!0},tk={position:[0,0,1e3],near:5,far:5e4,fov:10},nk=q.forwardRef(({cameraMode:r="pan",layoutType:e="forceDirected2d",sizingType:t="default",labelType:n="auto",theme:i=$F,animated:s=!0,defaultNodeSize:o=7,minNodeSize:a=5,maxNodeSize:c=15,lassoType:l="none",glOptions:u={},edges:h,children:f,nodes:d,minDistance:m,maxDistance:v,onCanvasClick:g,disabled:p,onLasso:_,onLassoEnd:y,...x},b)=>{var w,S;const M=q.useRef(null),E=q.useRef(null),T=q.useRef(null);q.useImperativeHandle(b,()=>({centerGraph:(N,C)=>{var O;return(O=M.current)==null?void 0:O.centerGraph(N,C)},fitNodesInView:(N,C)=>{var O;return(O=M.current)==null?void 0:O.fitNodesInView(N,C)},zoomIn:()=>{var N;return(N=E.current)==null?void 0:N.zoomIn()},zoomOut:()=>{var N;return(N=E.current)==null?void 0:N.zoomOut()},dollyIn:N=>{var C;return(C=E.current)==null?void 0:C.dollyIn(N)},dollyOut:N=>{var C;return(C=E.current)==null?void 0:C.dollyOut(N)},panLeft:()=>{var N;return(N=E.current)==null?void 0:N.panLeft()},panRight:()=>{var N;return(N=E.current)==null?void 0:N.panRight()},panDown:()=>{var N;return(N=E.current)==null?void 0:N.panDown()},panUp:()=>{var N;return(N=E.current)==null?void 0:N.panUp()},resetControls:N=>{var C;return(C=E.current)==null?void 0:C.resetControls(N)},getControls:()=>{var N;return(N=E.current)==null?void 0:N.controls},getGraph:()=>{var N;return(N=M.current)==null?void 0:N.graph},exportCanvas:()=>(M.current.renderScene(),T.current.toDataURL()),freeze:()=>{var N;return(N=E.current)==null?void 0:N.freeze()},unFreeze:()=>{var N;return(N=E.current)==null?void 0:N.unFreeze()}}));const{selections:L,actives:P,collapsedNodeIds:A}=x,z=h.length+d.length>400?!1:s,V=q.useMemo(()=>({...u,...ek}),[u]);return Se.jsx("div",{className:QF.canvas,children:Se.jsx(XL,{legacy:!0,linear:!0,ref:T,flat:!0,gl:V,camera:tk,onPointerMissed:g,children:Se.jsxs(EF,{createStore:()=>MF({selections:L,actives:P,theme:i,collapsedNodeIds:A}),children:[((w=i.canvas)==null?void 0:w.background)&&Se.jsx("color",{attach:"background",args:[i.canvas.background]}),Se.jsx("ambientLight",{intensity:1}),f,((S=i.canvas)==null?void 0:S.fog)&&Se.jsx("fog",{attach:"fog",args:[i.canvas.fog,4e3,9e3]}),Se.jsx(PF,{mode:r,ref:E,disabled:p,minDistance:m,maxDistance:v,animated:s,children:Se.jsx(KF,{disabled:p,type:l,onLasso:_,onLassoEnd:y,children:Se.jsx(q.Suspense,{children:Se.jsx(YF,{ref:M,disabled:p,animated:z,edges:h,nodes:d,layoutType:e,sizingType:t,labelType:n,defaultNodeSize:o,minNodeSize:a,maxNodeSize:c,...x})})})})]})})})}),tu={identity:"#22d3ee",knowledge:"#6366f1",rules:"#a78bfa",events:"#fbbf24"},ik={identity:"Identität",knowledge:"Wissen",rules:"Regeln",events:"Ereignisse"},Rd=new Set(["auto","agent","hermes"]);function hk({data:r,onDelete:e}){const[t,n]=q.useState(null),i=q.useMemo(()=>{const l={};return r.edges.forEach(u=>{l[u.source]=(l[u.source]||0)+1,l[u.target]=(l[u.target]||0)+1}),l},[r]),s=q.useMemo(()=>r.nodes.map(l=>({id:l.id,label:l.content.length>26?l.content.slice(0,25)+"…":l.content,fill:tu[l.category]||"#64748b",size:6+Math.min(i[l.id]||0,6)*2})),[r,i]),o=q.useMemo(()=>r.edges.map(l=>({id:`${l.source}->${l.target}`,source:l.source,target:l.target,size:.4+l.weight})),[r]),a=t?r.nodes.find(l=>l.id===t)??null:null,c=q.useMemo(()=>{if(!t)return[];const l=new Set;return r.edges.forEach(u=>{u.source===t&&l.add(u.target),u.target===t&&l.add(u.source)}),r.nodes.filter(u=>l.has(u.id))},[t,r]);return r.nodes.length?Se.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_280px] gap-3",children:[Se.jsx("div",{className:"relative h-[480px] rounded-2xl border border-border/60 bg-[#070a0f] overflow-hidden",children:Se.jsx(nk,{nodes:s,edges:o,theme:jF,layoutType:"forceDirected2d",labelType:"nodes",edgeArrowPosition:"none",draggable:!0,onNodeClick:l=>n(l.id),onCanvasClick:()=>n(null)})}),Se.jsx("div",{className:"rounded-2xl border border-border/60 bg-card/45 backdrop-blur-md p-4 min-h-[480px]",children:a?Se.jsxs(Se.Fragment,{children:[Se.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[Se.jsx("span",{className:"w-3 h-3 rounded-full",style:{background:tu[a.category],boxShadow:`0 0 0 2px ${Rd.has(a.source)?"#34d399":"#475569"}`}}),Se.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:tu[a.category]},children:ik[a.category]||a.category}),Se.jsxs("span",{className:`ml-auto text-[10px] font-mono flex items-center gap-1 ${Rd.has(a.source)?"text-emerald-400":"text-muted-foreground/70"}`,children:[Rd.has(a.source)&&Se.jsx(Qw,{className:"h-2.5 w-2.5"}),a.source]})]}),Se.jsx("div",{className:"text-sm text-foreground leading-relaxed mb-4 break-words",children:a.content}),Se.jsxs("div",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70 mb-2 flex items-center gap-1",children:[Se.jsx(Cg,{className:"h-3 w-3"})," verwandte Fakten"]}),Se.jsx("div",{className:"flex flex-col gap-1.5 mb-4",children:c.length?c.map(l=>Se.jsxs("button",{onClick:()=>n(l.id),className:"flex items-center gap-2 text-[11px] text-muted-foreground hover:text-foreground text-left transition-colors",children:[Se.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:tu[l.category]}}),Se.jsx("span",{className:"truncate",children:l.content})]},l.id)):Se.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"—"})}),Se.jsxs("button",{onClick:()=>{e(a.id),n(null)},className:"flex items-center gap-1.5 text-[11px] text-red-400 border border-red-500/20 rounded-lg px-2.5 py-1.5 hover:bg-red-500/5 transition-all",children:[Se.jsx(eS,{className:"h-3.5 w-3.5"})," vergessen"]})]}):Se.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center text-muted-foreground/70 gap-2 pt-24",children:[Se.jsx(Cg,{className:"h-6 w-6"}),Se.jsx("div",{className:"text-xs max-w-[180px] leading-relaxed",children:"Einen Knoten wählen, um den Fakt und seine semantischen Nachbarn zu sehen."})]})})]}):Se.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/60 rounded-2xl p-12 text-center",children:"Noch keine Fakten — der Graph füllt sich, sobald Hermes lernt oder du Einträge anlegst."})}export{hk as GraphView};
|